docs: add JSDocs for top level API objects (#140)
This commit add JSDoc documentation to the CloudEvent and HTTPReceiver objects exposed by the API when using the top level imports, specifically `CloudEvent` and `HTTPReceiver`. This adds a `generate-docs` npm script to generate site and API documentation for GitHub pages in `./docs`. Signed-off-by: Lance Ball <lball@redhat.com>
|
@ -13,7 +13,7 @@
|
||||||
"arrow-parens": ["error", "always"],
|
"arrow-parens": ["error", "always"],
|
||||||
"arrow-body-style": ["error", "as-needed"],
|
"arrow-body-style": ["error", "as-needed"],
|
||||||
"prefer-template": "error",
|
"prefer-template": "error",
|
||||||
"max-len": ["warn", { "code": 80 }],
|
"max-len": ["warn", { "code": 120 }],
|
||||||
"no-unused-vars": ["warn", {
|
"no-unused-vars": ["warn", {
|
||||||
"argsIgnorePattern": "^_$|^e$|^reject$|^resolve$"
|
"argsIgnorePattern": "^_$|^e$|^reject$|^resolve$"
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"tags": {
|
||||||
|
"allowUnknownTags": true,
|
||||||
|
"dictionaries": ["jsdoc"]
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"include": ["lib", "package.json", "README.md"],
|
||||||
|
"includePattern": ".js$",
|
||||||
|
"excludePattern": "(node_modules/|docs|examples|coverage|test)"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"plugins/markdown"
|
||||||
|
],
|
||||||
|
"templates": {
|
||||||
|
"referenceTitle": "cloudevents-sdk",
|
||||||
|
"disableSort": false,
|
||||||
|
"collapse": true,
|
||||||
|
"resources": {
|
||||||
|
"Concepts": "concepts.html"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"opts": {
|
||||||
|
"destination": "./docs/",
|
||||||
|
"encoding": "utf8",
|
||||||
|
"private": true,
|
||||||
|
"recurse": true,
|
||||||
|
"template": "node_modules/jsdoc-fresh"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
source "https://rubygems.org"
|
||||||
|
# Hello! This is where you manage which Jekyll version is used to run.
|
||||||
|
# When you want to use a different version, change it below, save the
|
||||||
|
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
||||||
|
#
|
||||||
|
# bundle exec jekyll serve
|
||||||
|
#
|
||||||
|
# This will help ensure the proper Jekyll version is running.
|
||||||
|
# Happy Jekylling!
|
||||||
|
|
||||||
|
gem "jekyll", "~> 3.8.5"
|
||||||
|
gem "github-pages", group: :jekyll_plugins
|
||||||
|
|
||||||
|
gem "just-the-docs"
|
||||||
|
|
||||||
|
# If you have any plugins, put them here!
|
||||||
|
group :jekyll_plugins do
|
||||||
|
gem "jekyll-feed", "~> 0.12"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
|
# and associated library.
|
||||||
|
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
|
||||||
|
gem "tzinfo", "~> 1.2"
|
||||||
|
gem "tzinfo-data"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Performance-booster for watching directories on Windows
|
||||||
|
gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?
|
||||||
|
|
|
@ -0,0 +1,263 @@
|
||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
activesupport (6.0.2.2)
|
||||||
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
|
i18n (>= 0.7, < 2)
|
||||||
|
minitest (~> 5.1)
|
||||||
|
tzinfo (~> 1.1)
|
||||||
|
zeitwerk (~> 2.2)
|
||||||
|
addressable (2.7.0)
|
||||||
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
|
coffee-script (2.4.1)
|
||||||
|
coffee-script-source
|
||||||
|
execjs
|
||||||
|
coffee-script-source (1.11.1)
|
||||||
|
colorator (1.1.0)
|
||||||
|
commonmarker (0.17.13)
|
||||||
|
ruby-enum (~> 0.5)
|
||||||
|
concurrent-ruby (1.1.6)
|
||||||
|
dnsruby (1.61.3)
|
||||||
|
addressable (~> 2.5)
|
||||||
|
em-websocket (0.5.1)
|
||||||
|
eventmachine (>= 0.12.9)
|
||||||
|
http_parser.rb (~> 0.6.0)
|
||||||
|
ethon (0.12.0)
|
||||||
|
ffi (>= 1.3.0)
|
||||||
|
eventmachine (1.2.7)
|
||||||
|
execjs (2.7.0)
|
||||||
|
faraday (1.0.1)
|
||||||
|
multipart-post (>= 1.2, < 3)
|
||||||
|
ffi (1.12.2)
|
||||||
|
forwardable-extended (2.6.0)
|
||||||
|
gemoji (3.0.1)
|
||||||
|
github-pages (204)
|
||||||
|
github-pages-health-check (= 1.16.1)
|
||||||
|
jekyll (= 3.8.5)
|
||||||
|
jekyll-avatar (= 0.7.0)
|
||||||
|
jekyll-coffeescript (= 1.1.1)
|
||||||
|
jekyll-commonmark-ghpages (= 0.1.6)
|
||||||
|
jekyll-default-layout (= 0.1.4)
|
||||||
|
jekyll-feed (= 0.13.0)
|
||||||
|
jekyll-gist (= 1.5.0)
|
||||||
|
jekyll-github-metadata (= 2.13.0)
|
||||||
|
jekyll-mentions (= 1.5.1)
|
||||||
|
jekyll-optional-front-matter (= 0.3.2)
|
||||||
|
jekyll-paginate (= 1.1.0)
|
||||||
|
jekyll-readme-index (= 0.3.0)
|
||||||
|
jekyll-redirect-from (= 0.15.0)
|
||||||
|
jekyll-relative-links (= 0.6.1)
|
||||||
|
jekyll-remote-theme (= 0.4.1)
|
||||||
|
jekyll-sass-converter (= 1.5.2)
|
||||||
|
jekyll-seo-tag (= 2.6.1)
|
||||||
|
jekyll-sitemap (= 1.4.0)
|
||||||
|
jekyll-swiss (= 1.0.0)
|
||||||
|
jekyll-theme-architect (= 0.1.1)
|
||||||
|
jekyll-theme-cayman (= 0.1.1)
|
||||||
|
jekyll-theme-dinky (= 0.1.1)
|
||||||
|
jekyll-theme-hacker (= 0.1.1)
|
||||||
|
jekyll-theme-leap-day (= 0.1.1)
|
||||||
|
jekyll-theme-merlot (= 0.1.1)
|
||||||
|
jekyll-theme-midnight (= 0.1.1)
|
||||||
|
jekyll-theme-minimal (= 0.1.1)
|
||||||
|
jekyll-theme-modernist (= 0.1.1)
|
||||||
|
jekyll-theme-primer (= 0.5.4)
|
||||||
|
jekyll-theme-slate (= 0.1.1)
|
||||||
|
jekyll-theme-tactile (= 0.1.1)
|
||||||
|
jekyll-theme-time-machine (= 0.1.1)
|
||||||
|
jekyll-titles-from-headings (= 0.5.3)
|
||||||
|
jemoji (= 0.11.1)
|
||||||
|
kramdown (= 1.17.0)
|
||||||
|
liquid (= 4.0.3)
|
||||||
|
mercenary (~> 0.3)
|
||||||
|
minima (= 2.5.1)
|
||||||
|
nokogiri (>= 1.10.4, < 2.0)
|
||||||
|
rouge (= 3.13.0)
|
||||||
|
terminal-table (~> 1.4)
|
||||||
|
github-pages-health-check (1.16.1)
|
||||||
|
addressable (~> 2.3)
|
||||||
|
dnsruby (~> 1.60)
|
||||||
|
octokit (~> 4.0)
|
||||||
|
public_suffix (~> 3.0)
|
||||||
|
typhoeus (~> 1.3)
|
||||||
|
html-pipeline (2.12.3)
|
||||||
|
activesupport (>= 2)
|
||||||
|
nokogiri (>= 1.4)
|
||||||
|
http_parser.rb (0.6.0)
|
||||||
|
i18n (0.9.5)
|
||||||
|
concurrent-ruby (~> 1.0)
|
||||||
|
jekyll (3.8.5)
|
||||||
|
addressable (~> 2.4)
|
||||||
|
colorator (~> 1.0)
|
||||||
|
em-websocket (~> 0.5)
|
||||||
|
i18n (~> 0.7)
|
||||||
|
jekyll-sass-converter (~> 1.0)
|
||||||
|
jekyll-watch (~> 2.0)
|
||||||
|
kramdown (~> 1.14)
|
||||||
|
liquid (~> 4.0)
|
||||||
|
mercenary (~> 0.3.3)
|
||||||
|
pathutil (~> 0.9)
|
||||||
|
rouge (>= 1.7, < 4)
|
||||||
|
safe_yaml (~> 1.0)
|
||||||
|
jekyll-avatar (0.7.0)
|
||||||
|
jekyll (>= 3.0, < 5.0)
|
||||||
|
jekyll-coffeescript (1.1.1)
|
||||||
|
coffee-script (~> 2.2)
|
||||||
|
coffee-script-source (~> 1.11.1)
|
||||||
|
jekyll-commonmark (1.3.1)
|
||||||
|
commonmarker (~> 0.14)
|
||||||
|
jekyll (>= 3.7, < 5.0)
|
||||||
|
jekyll-commonmark-ghpages (0.1.6)
|
||||||
|
commonmarker (~> 0.17.6)
|
||||||
|
jekyll-commonmark (~> 1.2)
|
||||||
|
rouge (>= 2.0, < 4.0)
|
||||||
|
jekyll-default-layout (0.1.4)
|
||||||
|
jekyll (~> 3.0)
|
||||||
|
jekyll-feed (0.13.0)
|
||||||
|
jekyll (>= 3.7, < 5.0)
|
||||||
|
jekyll-gist (1.5.0)
|
||||||
|
octokit (~> 4.2)
|
||||||
|
jekyll-github-metadata (2.13.0)
|
||||||
|
jekyll (>= 3.4, < 5.0)
|
||||||
|
octokit (~> 4.0, != 4.4.0)
|
||||||
|
jekyll-mentions (1.5.1)
|
||||||
|
html-pipeline (~> 2.3)
|
||||||
|
jekyll (>= 3.7, < 5.0)
|
||||||
|
jekyll-optional-front-matter (0.3.2)
|
||||||
|
jekyll (>= 3.0, < 5.0)
|
||||||
|
jekyll-paginate (1.1.0)
|
||||||
|
jekyll-readme-index (0.3.0)
|
||||||
|
jekyll (>= 3.0, < 5.0)
|
||||||
|
jekyll-redirect-from (0.15.0)
|
||||||
|
jekyll (>= 3.3, < 5.0)
|
||||||
|
jekyll-relative-links (0.6.1)
|
||||||
|
jekyll (>= 3.3, < 5.0)
|
||||||
|
jekyll-remote-theme (0.4.1)
|
||||||
|
addressable (~> 2.0)
|
||||||
|
jekyll (>= 3.5, < 5.0)
|
||||||
|
rubyzip (>= 1.3.0)
|
||||||
|
jekyll-sass-converter (1.5.2)
|
||||||
|
sass (~> 3.4)
|
||||||
|
jekyll-seo-tag (2.6.1)
|
||||||
|
jekyll (>= 3.3, < 5.0)
|
||||||
|
jekyll-sitemap (1.4.0)
|
||||||
|
jekyll (>= 3.7, < 5.0)
|
||||||
|
jekyll-swiss (1.0.0)
|
||||||
|
jekyll-theme-architect (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-cayman (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-dinky (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-hacker (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-leap-day (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-merlot (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-midnight (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-minimal (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-modernist (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-primer (0.5.4)
|
||||||
|
jekyll (> 3.5, < 5.0)
|
||||||
|
jekyll-github-metadata (~> 2.9)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-slate (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-tactile (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-theme-time-machine (0.1.1)
|
||||||
|
jekyll (~> 3.5)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
jekyll-titles-from-headings (0.5.3)
|
||||||
|
jekyll (>= 3.3, < 5.0)
|
||||||
|
jekyll-watch (2.2.1)
|
||||||
|
listen (~> 3.0)
|
||||||
|
jemoji (0.11.1)
|
||||||
|
gemoji (~> 3.0)
|
||||||
|
html-pipeline (~> 2.2)
|
||||||
|
jekyll (>= 3.0, < 5.0)
|
||||||
|
just-the-docs (0.2.8)
|
||||||
|
bundler (~> 2.1.4)
|
||||||
|
jekyll (>= 3.8.5, < 4.1.0)
|
||||||
|
jekyll-seo-tag (~> 2.0)
|
||||||
|
rake (>= 12.3.1, < 13.1.0)
|
||||||
|
kramdown (1.17.0)
|
||||||
|
liquid (4.0.3)
|
||||||
|
listen (3.2.1)
|
||||||
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||||
|
rb-inotify (~> 0.9, >= 0.9.10)
|
||||||
|
mercenary (0.3.6)
|
||||||
|
mini_portile2 (2.4.0)
|
||||||
|
minima (2.5.1)
|
||||||
|
jekyll (>= 3.5, < 5.0)
|
||||||
|
jekyll-feed (~> 0.9)
|
||||||
|
jekyll-seo-tag (~> 2.1)
|
||||||
|
minitest (5.14.0)
|
||||||
|
multipart-post (2.1.1)
|
||||||
|
nokogiri (1.10.9)
|
||||||
|
mini_portile2 (~> 2.4.0)
|
||||||
|
octokit (4.18.0)
|
||||||
|
faraday (>= 0.9)
|
||||||
|
sawyer (~> 0.8.0, >= 0.5.3)
|
||||||
|
pathutil (0.16.2)
|
||||||
|
forwardable-extended (~> 2.6)
|
||||||
|
public_suffix (3.1.1)
|
||||||
|
rake (13.0.1)
|
||||||
|
rb-fsevent (0.10.4)
|
||||||
|
rb-inotify (0.10.1)
|
||||||
|
ffi (~> 1.0)
|
||||||
|
rouge (3.13.0)
|
||||||
|
ruby-enum (0.8.0)
|
||||||
|
i18n
|
||||||
|
rubyzip (2.3.0)
|
||||||
|
safe_yaml (1.0.5)
|
||||||
|
sass (3.7.4)
|
||||||
|
sass-listen (~> 4.0.0)
|
||||||
|
sass-listen (4.0.0)
|
||||||
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||||
|
rb-inotify (~> 0.9, >= 0.9.7)
|
||||||
|
sawyer (0.8.2)
|
||||||
|
addressable (>= 2.3.5)
|
||||||
|
faraday (> 0.8, < 2.0)
|
||||||
|
terminal-table (1.8.0)
|
||||||
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||||
|
thread_safe (0.3.6)
|
||||||
|
typhoeus (1.3.1)
|
||||||
|
ethon (>= 0.9.0)
|
||||||
|
tzinfo (1.2.7)
|
||||||
|
thread_safe (~> 0.1)
|
||||||
|
tzinfo-data (1.2020.1)
|
||||||
|
tzinfo (>= 1.0.0)
|
||||||
|
unicode-display_width (1.7.0)
|
||||||
|
wdm (0.1.1)
|
||||||
|
zeitwerk (2.3.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
ruby
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
github-pages
|
||||||
|
jekyll (~> 3.8.5)
|
||||||
|
jekyll-feed (~> 0.12)
|
||||||
|
just-the-docs
|
||||||
|
tzinfo (~> 1.2)
|
||||||
|
tzinfo-data
|
||||||
|
wdm (~> 0.1.1)
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.1.4
|
|
@ -0,0 +1,426 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>
|
||||||
|
HTTPReceiver - Documentation
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script>
|
||||||
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/collapse.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<svg style="display: none;">
|
||||||
|
<defs>
|
||||||
|
<symbol id="linkIcon" fill="#706d77" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
|
||||||
|
</symbol>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||||
|
<label for="nav-trigger" class="navicon-button x">
|
||||||
|
<div class="navicon"></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label for="nav-trigger" class="overlay"></label>
|
||||||
|
|
||||||
|
<div class="top-nav-wrapper">
|
||||||
|
<ul>
|
||||||
|
<li >
|
||||||
|
<a href="index.html">
|
||||||
|
|
||||||
|
<svg fill="#6D6D6D" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h3 class="reference-title">
|
||||||
|
cloudevents-sdk
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
Resources
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<a href="concepts.html">Concepts</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Classes</h3><ul><li id="CloudEvent-nav"><a href="CloudEvent.html">CloudEvent</a><ul class='methods'><li data-type="method" id="CloudEvent-addExtension-nav"><a href="CloudEvent.html#addExtension">addExtension</a></li><li data-type="method" id="CloudEvent-data-nav"><a href="CloudEvent.html#data">data</a></li><li data-type="method" id="CloudEvent-dataContenttype-nav"><a href="CloudEvent.html#dataContenttype">dataContenttype</a></li><li data-type="method" id="CloudEvent-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getData-nav"><a href="CloudEvent.html#getData">getData</a></li><li data-type="method" id="CloudEvent-getDataContenttype-nav"><a href="CloudEvent.html#getDataContenttype">getDataContenttype</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-getFormats-nav"><a href="CloudEvent.html#getFormats">getFormats</a></li><li data-type="method" id="CloudEvent-getId-nav"><a href="CloudEvent.html#getId">getId</a></li><li data-type="method" id="CloudEvent-getSource-nav"><a href="CloudEvent.html#getSource">getSource</a></li><li data-type="method" id="CloudEvent-getSpecversion-nav"><a href="CloudEvent.html#getSpecversion">getSpecversion</a></li><li data-type="method" id="CloudEvent-getTime-nav"><a href="CloudEvent.html#getTime">getTime</a></li><li data-type="method" id="CloudEvent-getType-nav"><a href="CloudEvent.html#getType">getType</a></li><li data-type="method" id="CloudEvent-id-nav"><a href="CloudEvent.html#id">id</a></li><li data-type="method" id="CloudEvent-source-nav"><a href="CloudEvent.html#source">source</a></li><li data-type="method" id="CloudEvent-time-nav"><a href="CloudEvent.html#time">time</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li><li data-type="method" id="CloudEvent-type-nav"><a href="CloudEvent.html#type">type</a></li></ul></li><li id="HTTPReceiver-nav"><a href="HTTPReceiver.html">HTTPReceiver</a><ul class='methods'><li data-type="method" id="HTTPReceiver-accept-nav"><a href="HTTPReceiver.html#accept">accept</a></li></ul></li></ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">
|
||||||
|
HTTPReceiver
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
|
||||||
|
HTTPReceiver
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="class-description">
|
||||||
|
<p>A class to receive a CloudEvent from an HTTP POST request.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<div class="container-overview">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Constructor</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='name-container'>
|
||||||
|
<a class="link-icon" href="#HTTPReceiver">
|
||||||
|
<svg height="20" width="20" style="fill: black;">
|
||||||
|
<use xlink:href="#linkIcon"></use>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
<h4 class="name" id="HTTPReceiver">
|
||||||
|
<span class="type-signature"></span>new HTTPReceiver<span class="signature">()</span><span class="type-signature"></span>
|
||||||
|
</h4>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
<p>Create an instance of an HTTPReceiver to accept incoming CloudEvents.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source">
|
||||||
|
<ul class="dummy">
|
||||||
|
<li>
|
||||||
|
<a href="bindings_http_http_receiver.js.html">bindings/http/http_receiver.js</a>, <a href="bindings_http_http_receiver.js.html#line21">line 21</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3 class="subsection-title">Methods</h3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<span class='name-container'>
|
||||||
|
<a class="link-icon" href="#accept">
|
||||||
|
<svg height="20" width="20" style="fill: black;">
|
||||||
|
<use xlink:href="#linkIcon"></use>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
<h4 class="name" id="accept">
|
||||||
|
<span class="type-signature"></span>accept<span class="signature">(headers, body)</span><span class="type-signature"> → {<a href="CloudEvent.html">CloudEvent</a>}</span>
|
||||||
|
</h4>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="description">
|
||||||
|
<p>Acceptor for an incoming HTTP CloudEvent POST. Can process
|
||||||
|
binary and structured incoming CloudEvents.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h5>Parameters:</h5>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="params">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
|
||||||
|
<th>Type</th>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<th class="last">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>headers</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">
|
||||||
|
Object
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last">
|
||||||
|
<p>HTTP headers keyed by header name ("Content-Type")</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="name"><code>body</code></td>
|
||||||
|
|
||||||
|
|
||||||
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
|
<span class="param-type">
|
||||||
|
Object
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
||||||
|
<span class="param-type">
|
||||||
|
JSON
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<td class="description last">
|
||||||
|
<p>The body of the HTTP request</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dl class="details">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dt class="tag-source">Source:</dt>
|
||||||
|
<dd class="tag-source">
|
||||||
|
<ul class="dummy">
|
||||||
|
<li>
|
||||||
|
<a href="bindings_http_http_receiver.js.html">bindings/http/http_receiver.js</a>, <a href="bindings_http_http_receiver.js.html#line42">line 42</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
<script src="scripts/pagelocation.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,200 @@
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>
|
||||||
|
bindings/http/http_receiver.js - Documentation
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script>
|
||||||
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/collapse.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<svg style="display: none;">
|
||||||
|
<defs>
|
||||||
|
<symbol id="linkIcon" fill="#706d77" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
|
||||||
|
</symbol>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||||
|
<label for="nav-trigger" class="navicon-button x">
|
||||||
|
<div class="navicon"></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label for="nav-trigger" class="overlay"></label>
|
||||||
|
|
||||||
|
<div class="top-nav-wrapper">
|
||||||
|
<ul>
|
||||||
|
<li >
|
||||||
|
<a href="index.html">
|
||||||
|
|
||||||
|
<svg fill="#6D6D6D" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h3 class="reference-title">
|
||||||
|
cloudevents-sdk
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
Resources
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<a href="concepts.html">Concepts</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Classes</h3><ul><li id="CloudEvent-nav"><a href="CloudEvent.html">CloudEvent</a><ul class='methods'><li data-type="method" id="CloudEvent-addExtension-nav"><a href="CloudEvent.html#addExtension">addExtension</a></li><li data-type="method" id="CloudEvent-data-nav"><a href="CloudEvent.html#data">data</a></li><li data-type="method" id="CloudEvent-dataContenttype-nav"><a href="CloudEvent.html#dataContenttype">dataContenttype</a></li><li data-type="method" id="CloudEvent-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getData-nav"><a href="CloudEvent.html#getData">getData</a></li><li data-type="method" id="CloudEvent-getDataContenttype-nav"><a href="CloudEvent.html#getDataContenttype">getDataContenttype</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-getFormats-nav"><a href="CloudEvent.html#getFormats">getFormats</a></li><li data-type="method" id="CloudEvent-getId-nav"><a href="CloudEvent.html#getId">getId</a></li><li data-type="method" id="CloudEvent-getSource-nav"><a href="CloudEvent.html#getSource">getSource</a></li><li data-type="method" id="CloudEvent-getSpecversion-nav"><a href="CloudEvent.html#getSpecversion">getSpecversion</a></li><li data-type="method" id="CloudEvent-getTime-nav"><a href="CloudEvent.html#getTime">getTime</a></li><li data-type="method" id="CloudEvent-getType-nav"><a href="CloudEvent.html#getType">getType</a></li><li data-type="method" id="CloudEvent-id-nav"><a href="CloudEvent.html#id">id</a></li><li data-type="method" id="CloudEvent-source-nav"><a href="CloudEvent.html#source">source</a></li><li data-type="method" id="CloudEvent-time-nav"><a href="CloudEvent.html#time">time</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li><li data-type="method" id="CloudEvent-type-nav"><a href="CloudEvent.html#type">type</a></li></ul></li><li id="HTTPReceiver-nav"><a href="HTTPReceiver.html">HTTPReceiver</a><ul class='methods'><li data-type="method" id="HTTPReceiver-accept-nav"><a href="HTTPReceiver.html#accept">accept</a></li></ul></li></ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">
|
||||||
|
bindings/http/http_receiver.js
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<article>
|
||||||
|
<pre class="prettyprint source linenums"><code>const V03Binary = require("./receiver_binary_0_3");
|
||||||
|
const V03Structured = require("./receiver_structured_0_3.js");
|
||||||
|
const V1Binary = require("./receiver_binary_1.js");
|
||||||
|
const V1Structured = require("./receiver_structured_1.js");
|
||||||
|
const {
|
||||||
|
SPEC_V03,
|
||||||
|
SPEC_V1,
|
||||||
|
HEADER_CONTENT_TYPE,
|
||||||
|
MIME_CE,
|
||||||
|
BINARY_HEADERS_1,
|
||||||
|
DEFAULT_SPEC_VERSION_HEADER
|
||||||
|
} = require("./constants");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to receive a CloudEvent from an HTTP POST request.
|
||||||
|
*/
|
||||||
|
class HTTPReceiver {
|
||||||
|
/**
|
||||||
|
* Create an instance of an HTTPReceiver to accept incoming CloudEvents.
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
this.receivers = {
|
||||||
|
v1: {
|
||||||
|
structured: new V1Structured(),
|
||||||
|
binary: new V1Binary()
|
||||||
|
},
|
||||||
|
v03: {
|
||||||
|
structured: new V03Structured(),
|
||||||
|
binary: new V03Binary()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acceptor for an incoming HTTP CloudEvent POST. Can process
|
||||||
|
* binary and structured incoming CloudEvents.
|
||||||
|
*
|
||||||
|
* @param {Object} headers HTTP headers keyed by header name ("Content-Type")
|
||||||
|
* @param {Object|JSON} body The body of the HTTP request
|
||||||
|
* @return {CloudEvent} A new {CloudEvent} instance
|
||||||
|
*/
|
||||||
|
accept(headers, body) {
|
||||||
|
const mode = getMode(headers);
|
||||||
|
const version = getVersion(mode, headers, body);
|
||||||
|
switch (version) {
|
||||||
|
case SPEC_V1:
|
||||||
|
return this.receivers.v1[mode].parse(body, headers);
|
||||||
|
case SPEC_V03:
|
||||||
|
return this.receivers.v03[mode].parse(body, headers);
|
||||||
|
default:
|
||||||
|
console.error(
|
||||||
|
`Unknown spec version ${version}. Default to ${SPEC_V1}`);
|
||||||
|
return this.receivers.v1[mode].parse(body, headers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMode(headers) {
|
||||||
|
let mode = "unknown";
|
||||||
|
const contentType = headers[HEADER_CONTENT_TYPE];
|
||||||
|
if (contentType && contentType.startsWith(MIME_CE)) {
|
||||||
|
mode = "structured";
|
||||||
|
} else if (headers[BINARY_HEADERS_1.ID]) {
|
||||||
|
mode = "binary";
|
||||||
|
} else {
|
||||||
|
throw new TypeError("no cloud event detected");
|
||||||
|
}
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVersion(mode, headers, body) {
|
||||||
|
let version = SPEC_V1; // default to 1.0
|
||||||
|
|
||||||
|
if (mode === "binary") {
|
||||||
|
// Check the headers for the version
|
||||||
|
const versionHeader = headers[DEFAULT_SPEC_VERSION_HEADER];
|
||||||
|
if (versionHeader) { version = versionHeader; }
|
||||||
|
} else {
|
||||||
|
// structured mode - the version is in the body
|
||||||
|
version = body instanceof String
|
||||||
|
? JSON.parse(body).specversion : body.specversion;
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = HTTPReceiver;
|
||||||
|
</code></pre>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
<script src="scripts/pagelocation.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,348 @@
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>
|
||||||
|
cloudevent.js - Documentation
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script>
|
||||||
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/collapse.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<svg style="display: none;">
|
||||||
|
<defs>
|
||||||
|
<symbol id="linkIcon" fill="#706d77" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
|
||||||
|
</symbol>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||||
|
<label for="nav-trigger" class="navicon-button x">
|
||||||
|
<div class="navicon"></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label for="nav-trigger" class="overlay"></label>
|
||||||
|
|
||||||
|
<div class="top-nav-wrapper">
|
||||||
|
<ul>
|
||||||
|
<li >
|
||||||
|
<a href="index.html">
|
||||||
|
|
||||||
|
<svg fill="#6D6D6D" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h3 class="reference-title">
|
||||||
|
cloudevents-sdk
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
Resources
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<a href="concepts.html">Concepts</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Classes</h3><ul><li id="CloudEvent-nav"><a href="CloudEvent.html">CloudEvent</a><ul class='methods'><li data-type="method" id="CloudEvent-addExtension-nav"><a href="CloudEvent.html#addExtension">addExtension</a></li><li data-type="method" id="CloudEvent-data-nav"><a href="CloudEvent.html#data">data</a></li><li data-type="method" id="CloudEvent-dataContenttype-nav"><a href="CloudEvent.html#dataContenttype">dataContenttype</a></li><li data-type="method" id="CloudEvent-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getData-nav"><a href="CloudEvent.html#getData">getData</a></li><li data-type="method" id="CloudEvent-getDataContenttype-nav"><a href="CloudEvent.html#getDataContenttype">getDataContenttype</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-getFormats-nav"><a href="CloudEvent.html#getFormats">getFormats</a></li><li data-type="method" id="CloudEvent-getId-nav"><a href="CloudEvent.html#getId">getId</a></li><li data-type="method" id="CloudEvent-getSource-nav"><a href="CloudEvent.html#getSource">getSource</a></li><li data-type="method" id="CloudEvent-getSpecversion-nav"><a href="CloudEvent.html#getSpecversion">getSpecversion</a></li><li data-type="method" id="CloudEvent-getTime-nav"><a href="CloudEvent.html#getTime">getTime</a></li><li data-type="method" id="CloudEvent-getType-nav"><a href="CloudEvent.html#getType">getType</a></li><li data-type="method" id="CloudEvent-id-nav"><a href="CloudEvent.html#id">id</a></li><li data-type="method" id="CloudEvent-source-nav"><a href="CloudEvent.html#source">source</a></li><li data-type="method" id="CloudEvent-time-nav"><a href="CloudEvent.html#time">time</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li><li data-type="method" id="CloudEvent-type-nav"><a href="CloudEvent.html#type">type</a></li></ul></li><li id="HTTPReceiver-nav"><a href="HTTPReceiver.html">HTTPReceiver</a><ul class='methods'><li data-type="method" id="HTTPReceiver-accept-nav"><a href="HTTPReceiver.html#accept">accept</a></li></ul></li></ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">
|
||||||
|
cloudevent.js
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<article>
|
||||||
|
<pre class="prettyprint source linenums"><code>const Spec = require("./specs/spec_1.js");
|
||||||
|
const Formatter = require("./formats/json/formatter.js");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An instance of a CloudEvent.
|
||||||
|
*/
|
||||||
|
class CloudEvent {
|
||||||
|
/**
|
||||||
|
* Creates a new CloudEvent instance
|
||||||
|
* @param {Spec} [UserSpec] A CloudEvent version specification
|
||||||
|
* @param {Formatter} [UserFormatter] Converts the event into a readable string
|
||||||
|
*/
|
||||||
|
constructor(UserSpec, UserFormatter) {
|
||||||
|
this.spec = (UserSpec) ? new UserSpec(CloudEvent) : new Spec(CloudEvent);
|
||||||
|
this.formatter = (UserFormatter) ? new UserFormatter() : new Formatter();
|
||||||
|
|
||||||
|
// The map of extensions
|
||||||
|
this.extensions = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the formatters available to this CloudEvent
|
||||||
|
* @returns {Object} a JSON formatter
|
||||||
|
*/
|
||||||
|
getFormats() {
|
||||||
|
return { json: Formatter };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the CloudEvent as JSON. Validates the event according
|
||||||
|
* to the CloudEvent specification and throws an exception if
|
||||||
|
* it's invalid.
|
||||||
|
* @returns {JSON} the CloudEvent in JSON form
|
||||||
|
*/
|
||||||
|
format() {
|
||||||
|
// Check the constraints
|
||||||
|
this.spec.check();
|
||||||
|
|
||||||
|
// To run asData()
|
||||||
|
this.getData();
|
||||||
|
|
||||||
|
// Then, format
|
||||||
|
return this.formatter.format(this.spec.payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the CLoudEvent as JSON. No specification validation
|
||||||
|
* is performed.
|
||||||
|
* @returns {JSON} the CloudEvent in JSON form
|
||||||
|
*/
|
||||||
|
toString() {
|
||||||
|
return this.formatter.toString(this.spec.payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the event type
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#type
|
||||||
|
* @param {string} type the type of event related to the originating source
|
||||||
|
* @returns {CloudEvent} this CloudEvent
|
||||||
|
*/
|
||||||
|
type(type) {
|
||||||
|
this.spec.type(type);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the event type
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#type
|
||||||
|
* @returns {String} the type of event related to the originating source
|
||||||
|
*/
|
||||||
|
getType() {
|
||||||
|
return this.spec.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: The fact that this is exposed is problematic, given that it's
|
||||||
|
// immutable and this method will have no effect. The specification
|
||||||
|
// version is determined via the constructor - specifically the use
|
||||||
|
// of cloud event creator functions in /v03 and /v1. By default this
|
||||||
|
// object is created as a version 1.0 CloudEvent. Not documenting.
|
||||||
|
specversion(version) {
|
||||||
|
return this.spec.specversion(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the CloudEvent specification version
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#specversion
|
||||||
|
* @returns {string} The CloudEvent version that this event adheres to
|
||||||
|
*/
|
||||||
|
getSpecversion() {
|
||||||
|
return this.spec.getSpecversion();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the origination source of this event.
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#source-1
|
||||||
|
* @param {URI} source the context in which the event happened
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
source(source) {
|
||||||
|
this.spec.source(source);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the origination source of this event.
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#source-1
|
||||||
|
* @returns {string} the event source
|
||||||
|
*/
|
||||||
|
getSource() {
|
||||||
|
return this.spec.getSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the event id. Source + id must be unique for each distinct event.
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#id
|
||||||
|
* @param {string} id source+id must be unique for each distinct event
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
id(id) {
|
||||||
|
this.spec.id(id);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the event id.
|
||||||
|
* @returns {string} the event id
|
||||||
|
*/
|
||||||
|
getId() {
|
||||||
|
return this.spec.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the timestamp for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#time
|
||||||
|
* @param {Date} time timestamp when the event occurred
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
time(time) {
|
||||||
|
// TODO: Ensure that this is represented as a Date internally,
|
||||||
|
// or update the JSDoc
|
||||||
|
this.spec.time(time);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the timestamp for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#time
|
||||||
|
* @returns {Date} the timestamp for this event
|
||||||
|
*/
|
||||||
|
getTime() {
|
||||||
|
// TODO: Ensure that this is represented as a Date internally,
|
||||||
|
// or update the JSDoc
|
||||||
|
return this.spec.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Deprecated in 1.0
|
||||||
|
schemaurl(schemaurl) {
|
||||||
|
this.spec.schemaurl(schemaurl);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Deprecated in 1.0
|
||||||
|
getSchemaurl() {
|
||||||
|
return this.spec.getSchemaurl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the content type of the data value for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#datacontenttype
|
||||||
|
* @param {string} contenttype per https://tools.ietf.org/html/rfc2046
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
dataContenttype(contenttype) {
|
||||||
|
this.spec.dataContenttype(contenttype);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the content type of the data value for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#datacontenttype
|
||||||
|
* @returns {string} the content type for the data in this event
|
||||||
|
*/
|
||||||
|
getDataContenttype() {
|
||||||
|
return this.spec.getDataContenttype();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the data for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#event-data
|
||||||
|
* @param {*} data any data associated with this event
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
data(data) {
|
||||||
|
this.spec.data(data);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets any data that has been set for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#event-data
|
||||||
|
* @returns {*} any data set for this event
|
||||||
|
*/
|
||||||
|
getData() {
|
||||||
|
return this.spec.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an extension attribute to this CloudEvent
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes
|
||||||
|
* @param {*} key the name of the exteneion attribute
|
||||||
|
* @param {*} value the value of the extension attribute
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
addExtension(key, value) {
|
||||||
|
this.spec.addExtension(key, value);
|
||||||
|
|
||||||
|
// Stores locally
|
||||||
|
this.extensions[key] = value;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the extension attributes, if any, associated with this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes
|
||||||
|
* @returns {Object} the extensions attributes - if none exist will will be {}
|
||||||
|
* // TODO - this should return null or undefined if no extensions
|
||||||
|
*/
|
||||||
|
getExtensions() {
|
||||||
|
return this.extensions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = CloudEvent;
|
||||||
|
</code></pre>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
<script src="scripts/pagelocation.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,95 @@
|
||||||
|
---
|
||||||
|
title: Architecture and Concepts
|
||||||
|
nav_order: 2
|
||||||
|
---
|
||||||
|
|
||||||
|
# Architecture and Concepts
|
||||||
|
{: .no_toc }
|
||||||
|
|
||||||
|
1. TOC
|
||||||
|
{:toc}
|
||||||
|
|
||||||
|
## Spec and SDK Terms
|
||||||
|
|
||||||
|
- [Event](https://github.com/cloudevents/spec/blob/master/spec.md#event):
|
||||||
|
The canonical form of the attributes and payload of the occurrence.
|
||||||
|
- [Protocol](https://github.com/cloudevents/spec/blob/master/spec.md#protocol):
|
||||||
|
Protocol is the messaging protocol used to send/receive events. In sdk-javascript
|
||||||
|
the HTTP protocol is supported.
|
||||||
|
- [Protocol Binding](https://github.com/cloudevents/spec/blob/master/spec.md#protocol-binding):
|
||||||
|
Definition of how Events are mapped into Messages for the given Protocol. In sdk-javascript
|
||||||
|
the HTTP Protocol binding is implemented in the [`HTTPReceiver`](HTTPReceiver.html).
|
||||||
|
- [Message](https://github.com/cloudevents/spec/blob/master/spec.md#message):
|
||||||
|
The encoded form of an Event for a given encoding and protocol.
|
||||||
|
When a message is received in the sdk-javascript, the protocol implementation wraps it in a
|
||||||
|
[`CloudEvent`](CloudEvent.html).
|
||||||
|
- Message Writer: Logic required to take in a `Message` in a specific encoding and write out to a
|
||||||
|
given Protocol (request, message). A Message Writer can be a
|
||||||
|
[`StructuredWriter`](../lib/bindings/http/emitter_structured.js),
|
||||||
|
a [`BinaryWriter`](../lib/bindings/http/emitter_binary_1.js) or both, depending on what encodings a
|
||||||
|
Protocol supports.
|
||||||
|
- [`Client`](../lib/bindings/http/http_receiver.js): Interface to interact with a Protocol implementation
|
||||||
|
to send/receive Events. Clients also provide protocol agnostic features that can be
|
||||||
|
applied to events, such as extensions.
|
||||||
|
- Extensions: Anything that extends the base requirements from the CloudEvents spec.
|
||||||
|
There are several
|
||||||
|
[CloudEvents supported extensions](https://github.com/cloudevents/spec/tree/master/extensions).
|
||||||
|
|
||||||
|
## Investment Level
|
||||||
|
|
||||||
|
The amount of the SDK adopters would like to use is up to the adopter. We
|
||||||
|
support the following:
|
||||||
|
|
||||||
|
- [Resource Level](event_data_structure.md): An adopter could use the Event data structure to interact with CloudEvents
|
||||||
|
and marshal/unmarshal it to JSON.
|
||||||
|
- [Message Level](protocol_implementations.md): An adopter could use directly `Message`s implementations and `Write*` functions
|
||||||
|
to read and write CloudEvents messages from/to the wire, handling by hand the connection, the
|
||||||
|
consumption and the production of messages from/to the protocol specific APIs.
|
||||||
|
- [Protocol Level](protocol_implementations.md): An adopter could use Protocol implementations directly to consume/produce `Message`s
|
||||||
|
without interacting with the protocol specific APIs.
|
||||||
|
- [Client Level](../v2/client/client.go): An adopter selects a Protocol implementation and Events can
|
||||||
|
be directly sent and received without requiring interactions with `Message`s.
|
||||||
|
|
||||||
|
## Personas
|
||||||
|
|
||||||
|
- [Producer](https://github.com/cloudevents/spec/blob/master/spec.md#producer),
|
||||||
|
the "producer" is a specific instance, process or device that creates the data
|
||||||
|
structure describing the CloudEvent.
|
||||||
|
- [Consumer](https://github.com/cloudevents/spec/blob/master/spec.md#consumer),
|
||||||
|
a "consumer" receives the event and acts upon it. It uses the context and data
|
||||||
|
to execute some logic, which might lead to the occurrence of new events.
|
||||||
|
- [Intermediary](https://github.com/cloudevents/spec/blob/master/spec.md#intermediary),
|
||||||
|
An "intermediary" receives a message containing an event for the purpose of
|
||||||
|
forwarding it to the next receiver, which might be another intermediary or a
|
||||||
|
Consumer. A typical task for an intermediary is to route the event to
|
||||||
|
receivers based on the information in the Context.
|
||||||
|
|
||||||
|
## Interaction Models
|
||||||
|
|
||||||
|
The SDK enables the following interaction models.
|
||||||
|
|
||||||
|
### Sender
|
||||||
|
|
||||||
|
Sender, when a Producer is creating new events.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Receiver
|
||||||
|
|
||||||
|
Receiver, when a Consumer is accepting events.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Forwarder
|
||||||
|
|
||||||
|
Forwarder, when a Intermediary accepts an event only after it has successfully
|
||||||
|
continued the message to one or more Consumers.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Mutator
|
||||||
|
|
||||||
|
Mutator, when a Producer or Intermediary blocks on a response from a Consumer,
|
||||||
|
replacing the original Event.
|
||||||
|
|
||||||
|

|
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 120 KiB |
|
@ -0,0 +1,152 @@
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>
|
||||||
|
formats/json/parser.js - Documentation
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script>
|
||||||
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/collapse.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<svg style="display: none;">
|
||||||
|
<defs>
|
||||||
|
<symbol id="linkIcon" fill="#706d77" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
|
||||||
|
</symbol>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||||
|
<label for="nav-trigger" class="navicon-button x">
|
||||||
|
<div class="navicon"></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label for="nav-trigger" class="overlay"></label>
|
||||||
|
|
||||||
|
<div class="top-nav-wrapper">
|
||||||
|
<ul>
|
||||||
|
<li >
|
||||||
|
<a href="index.html">
|
||||||
|
|
||||||
|
<svg fill="#6D6D6D" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h3 class="reference-title">
|
||||||
|
cloudevents-sdk
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
Resources
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<a href="concepts.html">Concepts</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Classes</h3><ul><li id="CloudEvent-nav"><a href="CloudEvent.html">CloudEvent</a><ul class='methods'><li data-type="method" id="CloudEvent-addExtension-nav"><a href="CloudEvent.html#addExtension">addExtension</a></li><li data-type="method" id="CloudEvent-data-nav"><a href="CloudEvent.html#data">data</a></li><li data-type="method" id="CloudEvent-dataContenttype-nav"><a href="CloudEvent.html#dataContenttype">dataContenttype</a></li><li data-type="method" id="CloudEvent-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getData-nav"><a href="CloudEvent.html#getData">getData</a></li><li data-type="method" id="CloudEvent-getDataContenttype-nav"><a href="CloudEvent.html#getDataContenttype">getDataContenttype</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-getFormats-nav"><a href="CloudEvent.html#getFormats">getFormats</a></li><li data-type="method" id="CloudEvent-getId-nav"><a href="CloudEvent.html#getId">getId</a></li><li data-type="method" id="CloudEvent-getSource-nav"><a href="CloudEvent.html#getSource">getSource</a></li><li data-type="method" id="CloudEvent-getSpecversion-nav"><a href="CloudEvent.html#getSpecversion">getSpecversion</a></li><li data-type="method" id="CloudEvent-getTime-nav"><a href="CloudEvent.html#getTime">getTime</a></li><li data-type="method" id="CloudEvent-getType-nav"><a href="CloudEvent.html#getType">getType</a></li><li data-type="method" id="CloudEvent-id-nav"><a href="CloudEvent.html#id">id</a></li><li data-type="method" id="CloudEvent-source-nav"><a href="CloudEvent.html#source">source</a></li><li data-type="method" id="CloudEvent-time-nav"><a href="CloudEvent.html#time">time</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li><li data-type="method" id="CloudEvent-type-nav"><a href="CloudEvent.html#type">type</a></li></ul></li><li id="HTTPReceiver-nav"><a href="HTTPReceiver.html">HTTPReceiver</a><ul class='methods'><li data-type="method" id="HTTPReceiver-accept-nav"><a href="HTTPReceiver.html#accept">accept</a></li></ul></li></ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
<h1 class="page-title">
|
||||||
|
formats/json/parser.js
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<article>
|
||||||
|
<pre class="prettyprint source linenums"><code>const {
|
||||||
|
isString,
|
||||||
|
isDefinedOrThrow,
|
||||||
|
isStringOrObjectOrThrow
|
||||||
|
} = require("../../utils/fun.js");
|
||||||
|
|
||||||
|
const invalidPayloadTypeError =
|
||||||
|
new Error("invalid payload type, allowed are: string or object");
|
||||||
|
const nullOrUndefinedPayload =
|
||||||
|
new Error("null or undefined payload");
|
||||||
|
|
||||||
|
const asJSON = (v) => (isString(v) ? JSON.parse(v) : v);
|
||||||
|
|
||||||
|
class JSONParser {
|
||||||
|
constructor(decorator) {
|
||||||
|
this.decorator = decorator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the payload with an optional decorator
|
||||||
|
* @param {object|string} payload the JSON payload
|
||||||
|
* @return {object} the parsed JSON payload.
|
||||||
|
*/
|
||||||
|
parse(payload) {
|
||||||
|
if (this.decorator) {
|
||||||
|
payload = this.decorator.parse(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.of(payload)
|
||||||
|
|
||||||
|
.filter((p) => isDefinedOrThrow(p, nullOrUndefinedPayload))
|
||||||
|
.filter((p) => isStringOrObjectOrThrow(p, invalidPayloadTypeError))
|
||||||
|
.map(asJSON)
|
||||||
|
.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = JSONParser;
|
||||||
|
</code></pre>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
<script src="scripts/pagelocation.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 199 B |
|
@ -0,0 +1,4 @@
|
||||||
|
<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 398 B |
|
@ -0,0 +1,6 @@
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
all: $(patsubst %.dot,%.svg,$(wildcard *.dot))
|
||||||
|
|
||||||
|
%.svg: %.dot
|
||||||
|
dot -Tsvg $< -o $@
|
|
@ -0,0 +1,9 @@
|
||||||
|
digraph {
|
||||||
|
rankdir=LR;
|
||||||
|
|
||||||
|
Forwarder[shape=box]
|
||||||
|
|
||||||
|
downstream -> Forwarder;
|
||||||
|
|
||||||
|
Forwarder -> upstream;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Generated by graphviz version 2.43.0 (0)
|
||||||
|
-->
|
||||||
|
<!-- Title: %3 Pages: 1 -->
|
||||||
|
<svg width="346pt" height="44pt"
|
||||||
|
viewBox="0.00 0.00 346.02 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
|
||||||
|
<title>%3</title>
|
||||||
|
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 342.02,-40 342.02,4 -4,4"/>
|
||||||
|
<!-- Forwarder -->
|
||||||
|
<g id="node1" class="node">
|
||||||
|
<title>Forwarder</title>
|
||||||
|
<polygon fill="none" stroke="black" points="217.13,-36 142.51,-36 142.51,0 217.13,0 217.13,-36"/>
|
||||||
|
<text text-anchor="middle" x="179.82" y="-13.8" font-family="Times,serif" font-size="14.00">Forwarder</text>
|
||||||
|
</g>
|
||||||
|
<!-- upstream -->
|
||||||
|
<g id="node3" class="node">
|
||||||
|
<title>upstream</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="295.5" cy="-18" rx="42.55" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="295.5" y="-13.8" font-family="Times,serif" font-size="14.00">upstream</text>
|
||||||
|
</g>
|
||||||
|
<!-- Forwarder->upstream -->
|
||||||
|
<g id="edge2" class="edge">
|
||||||
|
<title>Forwarder->upstream</title>
|
||||||
|
<path fill="none" stroke="black" d="M217.1,-18C225.22,-18 234,-18 242.62,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="242.62,-21.5 252.62,-18 242.62,-14.5 242.62,-21.5"/>
|
||||||
|
</g>
|
||||||
|
<!-- downstream -->
|
||||||
|
<g id="node2" class="node">
|
||||||
|
<title>downstream</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="53.33" cy="-18" rx="53.16" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="53.33" y="-13.8" font-family="Times,serif" font-size="14.00">downstream</text>
|
||||||
|
</g>
|
||||||
|
<!-- downstream->Forwarder -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>downstream->Forwarder</title>
|
||||||
|
<path fill="none" stroke="black" d="M106.76,-18C115.17,-18 123.83,-18 132.09,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="132.31,-21.5 142.31,-18 132.31,-14.5 132.31,-21.5"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
|
@ -0,0 +1,7 @@
|
||||||
|
digraph {
|
||||||
|
rankdir=LR;
|
||||||
|
|
||||||
|
Mutator[shape=box]
|
||||||
|
|
||||||
|
Mutator -> upstream[dir=both];
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Generated by graphviz version 2.43.0 (0)
|
||||||
|
-->
|
||||||
|
<!-- Title: %3 Pages: 1 -->
|
||||||
|
<svg width="190pt" height="44pt"
|
||||||
|
viewBox="0.00 0.00 190.15 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
|
||||||
|
<title>%3</title>
|
||||||
|
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 186.15,-40 186.15,4 -4,4"/>
|
||||||
|
<!-- Mutator -->
|
||||||
|
<g id="node1" class="node">
|
||||||
|
<title>Mutator</title>
|
||||||
|
<polygon fill="none" stroke="black" points="61.16,-36 -0.05,-36 -0.05,0 61.16,0 61.16,-36"/>
|
||||||
|
<text text-anchor="middle" x="30.55" y="-13.8" font-family="Times,serif" font-size="14.00">Mutator</text>
|
||||||
|
</g>
|
||||||
|
<!-- upstream -->
|
||||||
|
<g id="node2" class="node">
|
||||||
|
<title>upstream</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="139.63" cy="-18" rx="42.55" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="139.63" y="-13.8" font-family="Times,serif" font-size="14.00">upstream</text>
|
||||||
|
</g>
|
||||||
|
<!-- Mutator->upstream -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>Mutator->upstream</title>
|
||||||
|
<path fill="none" stroke="black" d="M71.57,-18C76.49,-18 81.57,-18 86.64,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="71.38,-14.5 61.38,-18 71.38,-21.5 71.38,-14.5"/>
|
||||||
|
<polygon fill="black" stroke="black" points="86.96,-21.5 96.96,-18 86.96,-14.5 86.96,-21.5"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,6 @@
|
||||||
|
digraph {
|
||||||
|
rankdir=LR;
|
||||||
|
|
||||||
|
Receiver[shape=box]
|
||||||
|
downstream -> Receiver;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Generated by graphviz version 2.43.0 (0)
|
||||||
|
-->
|
||||||
|
<!-- Title: %3 Pages: 1 -->
|
||||||
|
<svg width="216pt" height="44pt"
|
||||||
|
viewBox="0.00 0.00 216.41 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
|
||||||
|
<title>%3</title>
|
||||||
|
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 212.41,-40 212.41,4 -4,4"/>
|
||||||
|
<!-- Receiver -->
|
||||||
|
<g id="node1" class="node">
|
||||||
|
<title>Receiver</title>
|
||||||
|
<polygon fill="none" stroke="black" points="208.28,-36 142.79,-36 142.79,0 208.28,0 208.28,-36"/>
|
||||||
|
<text text-anchor="middle" x="175.53" y="-13.8" font-family="Times,serif" font-size="14.00">Receiver</text>
|
||||||
|
</g>
|
||||||
|
<!-- downstream -->
|
||||||
|
<g id="node2" class="node">
|
||||||
|
<title>downstream</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="53.33" cy="-18" rx="53.16" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="53.33" y="-13.8" font-family="Times,serif" font-size="14.00">downstream</text>
|
||||||
|
</g>
|
||||||
|
<!-- downstream->Receiver -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>downstream->Receiver</title>
|
||||||
|
<path fill="none" stroke="black" d="M106.7,-18C115.33,-18 124.18,-18 132.51,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="132.74,-21.5 142.74,-18 132.74,-14.5 132.74,-21.5"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,7 @@
|
||||||
|
digraph {
|
||||||
|
rankdir=LR;
|
||||||
|
|
||||||
|
Sender[shape=box]
|
||||||
|
|
||||||
|
Sender -> upstream;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Generated by graphviz version 2.43.0 (0)
|
||||||
|
-->
|
||||||
|
<!-- Title: %3 Pages: 1 -->
|
||||||
|
<svg width="184pt" height="44pt"
|
||||||
|
viewBox="0.00 0.00 183.92 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
|
||||||
|
<title>%3</title>
|
||||||
|
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 179.92,-40 179.92,4 -4,4"/>
|
||||||
|
<!-- Sender -->
|
||||||
|
<g id="node1" class="node">
|
||||||
|
<title>Sender</title>
|
||||||
|
<polygon fill="none" stroke="black" points="54.81,-36 0.06,-36 0.06,0 54.81,0 54.81,-36"/>
|
||||||
|
<text text-anchor="middle" x="27.44" y="-13.8" font-family="Times,serif" font-size="14.00">Sender</text>
|
||||||
|
</g>
|
||||||
|
<!-- upstream -->
|
||||||
|
<g id="node2" class="node">
|
||||||
|
<title>upstream</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="133.4" cy="-18" rx="42.55" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="133.4" y="-13.8" font-family="Times,serif" font-size="14.00">upstream</text>
|
||||||
|
</g>
|
||||||
|
<!-- Sender->upstream -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>Sender->upstream</title>
|
||||||
|
<path fill="none" stroke="black" d="M54.94,-18C62.72,-18 71.52,-18 80.32,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="80.59,-21.5 90.59,-18 80.59,-14.5 80.59,-21.5"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,7 @@
|
||||||
|
digraph {
|
||||||
|
rankdir=LR;
|
||||||
|
|
||||||
|
Client -> ProtocolBinding [label="[Event]"]
|
||||||
|
ProtocolBinding -> ProtocolBindingImpl [label="[Event, Message]"]
|
||||||
|
ProtocolBindingImpl -> Protocol [label="[Message]"]
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Generated by graphviz version 2.43.0 (0)
|
||||||
|
-->
|
||||||
|
<!-- Title: %3 Pages: 1 -->
|
||||||
|
<svg width="766pt" height="44pt"
|
||||||
|
viewBox="0.00 0.00 765.55 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
|
||||||
|
<title>%3</title>
|
||||||
|
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 761.55,-40 761.55,4 -4,4"/>
|
||||||
|
<!-- Client -->
|
||||||
|
<g id="node1" class="node">
|
||||||
|
<title>Client</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="31.72" cy="-18" rx="31.95" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="31.72" y="-13.8" font-family="Times,serif" font-size="14.00">Client</text>
|
||||||
|
</g>
|
||||||
|
<!-- ProtocolBinding -->
|
||||||
|
<g id="node2" class="node">
|
||||||
|
<title>ProtocolBinding</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="210" cy="-18" rx="68.65" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="210" y="-13.8" font-family="Times,serif" font-size="14.00">ProtocolBinding</text>
|
||||||
|
</g>
|
||||||
|
<!-- Client->ProtocolBinding -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>Client->ProtocolBinding</title>
|
||||||
|
<path fill="none" stroke="black" d="M63.83,-18C82.6,-18 107.41,-18 131.2,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="131.32,-21.5 141.32,-18 131.32,-14.5 131.32,-21.5"/>
|
||||||
|
<text text-anchor="middle" x="102.44" y="-20.8" font-family="Times,serif" font-size="14.00">[Event]</text>
|
||||||
|
</g>
|
||||||
|
<!-- ProtocolBindingImpl -->
|
||||||
|
<g id="node3" class="node">
|
||||||
|
<title>ProtocolBindingImpl</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="497.82" cy="-18" rx="85.05" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="497.82" y="-13.8" font-family="Times,serif" font-size="14.00">ProtocolBindingImpl</text>
|
||||||
|
</g>
|
||||||
|
<!-- ProtocolBinding->ProtocolBindingImpl -->
|
||||||
|
<g id="edge2" class="edge">
|
||||||
|
<title>ProtocolBinding->ProtocolBindingImpl</title>
|
||||||
|
<path fill="none" stroke="black" d="M278.73,-18C315.64,-18 361.89,-18 402.29,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="402.43,-21.5 412.43,-18 402.43,-14.5 402.43,-21.5"/>
|
||||||
|
<text text-anchor="middle" x="345.56" y="-20.8" font-family="Times,serif" font-size="14.00">[Event, Message]</text>
|
||||||
|
</g>
|
||||||
|
<!-- Protocol -->
|
||||||
|
<g id="node4" class="node">
|
||||||
|
<title>Protocol</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="717.48" cy="-18" rx="40.15" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="717.48" y="-13.8" font-family="Times,serif" font-size="14.00">Protocol</text>
|
||||||
|
</g>
|
||||||
|
<!-- ProtocolBindingImpl->Protocol -->
|
||||||
|
<g id="edge3" class="edge">
|
||||||
|
<title>ProtocolBindingImpl->Protocol</title>
|
||||||
|
<path fill="none" stroke="black" d="M583.28,-18C611.62,-18 642.28,-18 667.03,-18"/>
|
||||||
|
<polygon fill="black" stroke="black" points="667.25,-21.5 677.25,-18 667.25,-14.5 667.25,-21.5"/>
|
||||||
|
<text text-anchor="middle" x="630.25" y="-20.8" font-family="Times,serif" font-size="14.00">[Message]</text>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.9 KiB |
|
@ -0,0 +1,247 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>
|
||||||
|
Home - Documentation
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script>
|
||||||
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="styles/collapse.css">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<svg style="display: none;">
|
||||||
|
<defs>
|
||||||
|
<symbol id="linkIcon" fill="#706d77" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
|
||||||
|
</symbol>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
||||||
|
<label for="nav-trigger" class="navicon-button x">
|
||||||
|
<div class="navicon"></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label for="nav-trigger" class="overlay"></label>
|
||||||
|
|
||||||
|
<div class="top-nav-wrapper">
|
||||||
|
<ul>
|
||||||
|
<li class="active" >
|
||||||
|
<a href="index.html">
|
||||||
|
|
||||||
|
|
||||||
|
<svg fill="#0095dd" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
|
||||||
|
<path d="M0 0h24v24H0z" fill="none"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<h3 class="reference-title">
|
||||||
|
cloudevents-sdk
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
Resources
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<a href="concepts.html">Concepts</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Classes</h3><ul><li id="CloudEvent-nav"><a href="CloudEvent.html">CloudEvent</a><ul class='methods'><li data-type="method" id="CloudEvent-addExtension-nav"><a href="CloudEvent.html#addExtension">addExtension</a></li><li data-type="method" id="CloudEvent-data-nav"><a href="CloudEvent.html#data">data</a></li><li data-type="method" id="CloudEvent-dataContenttype-nav"><a href="CloudEvent.html#dataContenttype">dataContenttype</a></li><li data-type="method" id="CloudEvent-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getData-nav"><a href="CloudEvent.html#getData">getData</a></li><li data-type="method" id="CloudEvent-getDataContenttype-nav"><a href="CloudEvent.html#getDataContenttype">getDataContenttype</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-getFormats-nav"><a href="CloudEvent.html#getFormats">getFormats</a></li><li data-type="method" id="CloudEvent-getId-nav"><a href="CloudEvent.html#getId">getId</a></li><li data-type="method" id="CloudEvent-getSource-nav"><a href="CloudEvent.html#getSource">getSource</a></li><li data-type="method" id="CloudEvent-getSpecversion-nav"><a href="CloudEvent.html#getSpecversion">getSpecversion</a></li><li data-type="method" id="CloudEvent-getTime-nav"><a href="CloudEvent.html#getTime">getTime</a></li><li data-type="method" id="CloudEvent-getType-nav"><a href="CloudEvent.html#getType">getType</a></li><li data-type="method" id="CloudEvent-id-nav"><a href="CloudEvent.html#id">id</a></li><li data-type="method" id="CloudEvent-source-nav"><a href="CloudEvent.html#source">source</a></li><li data-type="method" id="CloudEvent-time-nav"><a href="CloudEvent.html#time">time</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li><li data-type="method" id="CloudEvent-type-nav"><a href="CloudEvent.html#type">type</a></li></ul></li><li id="HTTPReceiver-nav"><a href="HTTPReceiver.html">HTTPReceiver</a><ul class='methods'><li data-type="method" id="HTTPReceiver-accept-nav"><a href="HTTPReceiver.html#accept">accept</a></li></ul></li></ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<section class="readme">
|
||||||
|
<article>
|
||||||
|
<h1>JavaScript SDK for CloudEvents</h1>
|
||||||
|
<p><a href="https://www.codacy.com/app/fabiojose/sdk-javascript?utm_source=github.com&utm_medium=referral&utm_content=cloudevents/sdk-javascript&utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/bd66e7c52002481993cd6d610534b0f7" alt="Codacy Badge"></a>
|
||||||
|
<a href="https://www.codacy.com/app/fabiojose/sdk-javascript?utm_source=github.com&utm_medium=referral&utm_content=cloudevents/sdk-javascript&utm_campaign=Badge_Coverage"><img src="https://api.codacy.com/project/badge/Coverage/bd66e7c52002481993cd6d610534b0f7" alt="Codacy Badge"></a>
|
||||||
|
<a href="https://travis-ci.org/cloudevents/sdk-javascript"><img src="https://travis-ci.org/cloudevents/sdk-javascript.svg?branch=master" alt="Build Status"></a>
|
||||||
|
<a href="https://www.npmjs.com/package/cloudevents-sdk"><img src="https://img.shields.io/npm/v/cloudevents-sdk.svg" alt="npm version"></a>
|
||||||
|
<a href="https://snyk.io/test/github/cloudevents/sdk-javascript"><img src="https://snyk.io/test/github/cloudevents/sdk-javascript/badge.svg" alt="vulnerabilities"></a>
|
||||||
|
<a href="http://www.apache.org/licenses/LICENSE-2.0"><img src="https://img.shields.io/github/license/cloudevents/sdk-javascript" alt="licence"></a></p>
|
||||||
|
<p>The CloudEvents SDK for JavaScript.</p>
|
||||||
|
<p>This module will help you to:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Represent CloudEvents in memory</li>
|
||||||
|
<li>Use <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#event-format">Event Formats</a> to serialize/deserialize CloudEvents</li>
|
||||||
|
<li>Use <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#protocol-binding">Protocol Bindings</a> to send/receive CloudEvents</li>
|
||||||
|
</ul>
|
||||||
|
<p><em>Note:</em> Supported
|
||||||
|
<a href="https://github.com/cloudevents/spec">CloudEvents specification</a>: 0.3, 1.0</p>
|
||||||
|
<h3>A Note on Versioning</h3>
|
||||||
|
<p>The CloudEvents protocol version is distinct from this module's version number.
|
||||||
|
For example, this module may be versioned as v2.0.0 but support the v0.3 and v1.0
|
||||||
|
versions of the CloudEvent specification.</p>
|
||||||
|
<h2>Usage</h2>
|
||||||
|
<p><strong>See the full working example: <a href="./examples/express-ex">here</a>.</strong></p>
|
||||||
|
<h3>Installation</h3>
|
||||||
|
<p>The CloudEvents SDK requires a current LTS version of Node.js. At the moment
|
||||||
|
those are Node.js 10.x and Node.js 12.x. To install in your Node.js project:</p>
|
||||||
|
<pre class="prettyprint source lang-console"><code>npm install --save cloudevents-sdk
|
||||||
|
</code></pre>
|
||||||
|
<h3>Receiving and Emitting Events</h3>
|
||||||
|
<h4>Receiving Events</h4>
|
||||||
|
<p>You can choose almost any popular web framework for port binding. Use an
|
||||||
|
<code>HTTPReceiver</code> to process the incoming HTTP request. The receiver accepts
|
||||||
|
binary and structured events in either the 1.0 or 0.3 protocol formats.</p>
|
||||||
|
<pre class="prettyprint source lang-js"><code>const {
|
||||||
|
CloudEvent,
|
||||||
|
HTTPReceiever
|
||||||
|
} = require("cloudevents-sdk");
|
||||||
|
|
||||||
|
// Create a receiver to accept events over HTTP
|
||||||
|
const receiver = new HTTPReceiver();
|
||||||
|
|
||||||
|
// body and headers come from an incoming HTTP request, e.g. express.js
|
||||||
|
const receivedEvent = receiver.accept(req.body, req.headers);
|
||||||
|
console.log(receivedEvent.format());
|
||||||
|
</code></pre>
|
||||||
|
<h4>Emitting Events</h4>
|
||||||
|
<p>Currently, to emit events, you'll need to decide whether the event is in
|
||||||
|
binary or structured format, and determine what version of the CloudEvents
|
||||||
|
specification you want to send the event as.</p>
|
||||||
|
<pre class="prettyprint source lang-js"><code>const { CloudEvent } = require("cloudevents-sdk");
|
||||||
|
const { StructuredHTTPEmitter } = require("cloudevents-sdk/v1");
|
||||||
|
|
||||||
|
const myevent = new CloudEvent()
|
||||||
|
.type("com.github.pull.create")
|
||||||
|
.source("urn:event:from:myapi/resource/123");
|
||||||
|
|
||||||
|
const emitter = new StructuredHTTPEmitter({
|
||||||
|
method: "POST",
|
||||||
|
url : "https://myserver.com"
|
||||||
|
});
|
||||||
|
|
||||||
|
// Emit the event
|
||||||
|
emitter.emit(myevent)
|
||||||
|
</code></pre>
|
||||||
|
<h2>Supported specification features</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th><a href="https://github.com/cloudevents/spec/tree/v0.3">v0.3</a></th>
|
||||||
|
<th><a href="https://github.com/cloudevents/spec/tree/v1.0">v1.0</a></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>CloudEvents Core</td>
|
||||||
|
<td>:heavy_check_mark:</td>
|
||||||
|
<td>:heavy_check_mark:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>AMQP Protocol Binding</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>AVRO Event Format</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>HTTP Protocol Binding</td>
|
||||||
|
<td>:heavy_check_mark:</td>
|
||||||
|
<td>:heavy_check_mark:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>JSON Event Format</td>
|
||||||
|
<td>:heavy_check_mark:</td>
|
||||||
|
<td>:heavy_check_mark:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Kafka Protocol Binding</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>NATS Protocol Binding</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>STAN Protocol Binding</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
<td>:x:</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2>Community</h2>
|
||||||
|
<ul>
|
||||||
|
<li>There are bi-weekly calls immediately following the <a href="https://github.com/cloudevents/spec#meeting-time">Serverless/CloudEvents
|
||||||
|
call</a> at
|
||||||
|
9am PT (US Pacific). Which means they will typically start at 10am PT, but
|
||||||
|
if the other call ends early then the SDK call will start early as well.
|
||||||
|
See the <a href="https://docs.google.com/document/d/1OVF68rpuPK5shIHILK9JOqlZBbfe91RNzQ7u_P7YCDE/edit#">CloudEvents meeting minutes</a>
|
||||||
|
to determine which week will have the call.</li>
|
||||||
|
<li>Slack: #cloudeventssdk channel under
|
||||||
|
<a href="https://slack.cncf.io/">CNCF's Slack workspace</a>.</li>
|
||||||
|
<li>Email: https://lists.cncf.io/g/cncf-cloudevents-sdk</li>
|
||||||
|
<li>Contact for additional information: Fabio José (<code>@fabiojose</code> on slack).</li>
|
||||||
|
</ul>
|
||||||
|
<h2>Contributing</h2>
|
||||||
|
<p>We love contributions from the community! Please check the
|
||||||
|
<a href="https://github.com/cloudevents/sdk-javascript/blob/master/CONTRIBUTING.md">Contributor's Guide</a>
|
||||||
|
for information on how to get involved.</p>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br class="clear">
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="scripts/linenumber.js"></script>
|
||||||
|
<script src="scripts/pagelocation.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,23 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var lineId, lines, totalLines, anchorHash;
|
||||||
|
var source = document.getElementsByClassName('prettyprint source linenums');
|
||||||
|
var i = 0;
|
||||||
|
var lineNumber = 0;
|
||||||
|
|
||||||
|
if (source && source[0]) {
|
||||||
|
anchorHash = document.location.hash.substring(1);
|
||||||
|
lines = source[0].getElementsByTagName('li');
|
||||||
|
totalLines = lines.length;
|
||||||
|
|
||||||
|
for (; i < totalLines; i++) {
|
||||||
|
lineNumber++;
|
||||||
|
lineId = 'line' + lineNumber;
|
||||||
|
lines[i].id = lineId;
|
||||||
|
if (lineId === anchorHash) {
|
||||||
|
lines[i].className += ' selected';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
|
@ -0,0 +1,91 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const $ = window.$;
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
var currentSectionNav, target;
|
||||||
|
|
||||||
|
// If an anchor hash is in the URL highlight the menu item
|
||||||
|
highlightActiveHash();
|
||||||
|
// If a specific page section is in the URL highlight the menu item
|
||||||
|
highlightActiveSection();
|
||||||
|
|
||||||
|
// If a specific page section is in the URL scroll that section up to the top
|
||||||
|
currentSectionNav = $('#' + getCurrentSectionName() + '-nav');
|
||||||
|
|
||||||
|
if (currentSectionNav.position()) {
|
||||||
|
$('nav').scrollTop(currentSectionNav.position().top);
|
||||||
|
}
|
||||||
|
|
||||||
|
// function to scroll to anchor when clicking an anchor linl
|
||||||
|
$('a[href*="#"]:not([href="#"])').click(function () {
|
||||||
|
/* eslint-disable no-invalid-this */
|
||||||
|
if (window.location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && window.location.hostname === this.hostname) {
|
||||||
|
target = $(this.hash);
|
||||||
|
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
||||||
|
if (target.length) {
|
||||||
|
$('html, body').animate({
|
||||||
|
scrollTop: target.offset().top
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* eslint-enable no-invalid-this */
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// If a new anchor section is selected, change the hightlighted menu item
|
||||||
|
$(window).bind('hashchange', function (event) {
|
||||||
|
highlightActiveHash(event);
|
||||||
|
});
|
||||||
|
|
||||||
|
function highlightActiveHash (event) {
|
||||||
|
var oldUrl, oldSubSectionElement;
|
||||||
|
|
||||||
|
// check for and remove old hash active state
|
||||||
|
if (event && event.originalEvent.oldURL) {
|
||||||
|
oldUrl = event.originalEvent.oldURL;
|
||||||
|
|
||||||
|
if (oldUrl.indexOf('#') > -1) {
|
||||||
|
oldSubSectionElement = $('#' + getCurrentSectionName() + '-' + oldUrl.substring(oldUrl.indexOf('#') + 1) + '-nav');
|
||||||
|
|
||||||
|
if (oldSubSectionElement) {
|
||||||
|
oldSubSectionElement.removeClass('active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCurrentHashName()) {
|
||||||
|
$('#' + getCurrentSectionName() + '-' + getCurrentHashName() + '-nav').addClass('active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlightActiveSection () {
|
||||||
|
var pageId = getCurrentSectionName();
|
||||||
|
|
||||||
|
$('#' + pageId + '-nav').addClass('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentSectionName () {
|
||||||
|
var path = window.location.pathname;
|
||||||
|
var pageUrl = path.split('/').pop();
|
||||||
|
|
||||||
|
var sectionName = pageUrl.substring(0, pageUrl.indexOf('.'));
|
||||||
|
|
||||||
|
// remove the wodr module- if its in the url
|
||||||
|
sectionName = sectionName.replace('module-', '');
|
||||||
|
|
||||||
|
return sectionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentHashName () {
|
||||||
|
var pageSubSectionId;
|
||||||
|
var pageSubSectionHash = window.location.hash;
|
||||||
|
|
||||||
|
if (pageSubSectionHash) {
|
||||||
|
pageSubSectionId = pageSubSectionHash.substring(1).replace('.', '');
|
||||||
|
|
||||||
|
return pageSubSectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
@media only screen and (min-width: 681px) {
|
||||||
|
nav > ul > li:hover .methods,
|
||||||
|
.active .methods {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.methods {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav > ul > li {
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav > ul > li > a {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav > ul > li.active a {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav > ul > li:hover > a,
|
||||||
|
nav > ul > li.active > a {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,900 @@
|
||||||
|
* {
|
||||||
|
box-sizing: border-box
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
color: #3e3c42;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color: #3e3c42;
|
||||||
|
background-color: #f3f3f3;
|
||||||
|
width: 100%;
|
||||||
|
font: 16px/1.875 "Avenir Next W01", "Avenir Next", "Helvetica Neue", Helvetica, sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 160%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:active {
|
||||||
|
color: #0095dd;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline
|
||||||
|
}
|
||||||
|
|
||||||
|
p, ul, ol, blockquote {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
max-width: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #706d77;
|
||||||
|
font-weight: 500;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #4b484f;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 40px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 span {
|
||||||
|
color: #999;
|
||||||
|
font-size: 32px;
|
||||||
|
display: block;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1.page-title {
|
||||||
|
border-bottom: 1px dashed #ccc;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 30px;
|
||||||
|
margin: 1.5em 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 20px;
|
||||||
|
margin: 1.5em 0 0;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3.reference-title {
|
||||||
|
display: block;
|
||||||
|
font-weight: 400;
|
||||||
|
margin-top: 2em;
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3.reference-title small {
|
||||||
|
display: inline-block;
|
||||||
|
color: #0095dd;
|
||||||
|
margin-left: 5px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3.subsection-title {
|
||||||
|
border-bottom: 1px solid #ececec;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
margin-top: 3em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 1em 0 0;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4.name {
|
||||||
|
font-size: 20px;
|
||||||
|
margin-top: 0;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
margin: 2em 0 0.5em 0;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-overview .subsection-title {
|
||||||
|
font-size: 14px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin: 8px 0 15px 0;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #4D4E53;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h6 {
|
||||||
|
font-size: 100%;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
margin: 6px 0 3px 0;
|
||||||
|
font-style: italic;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
tt, code, kbd, samp {
|
||||||
|
font-family: "Source Code Pro", monospace;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 1px 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.class-description {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: rgba(26, 159, 224, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.class-description:empty {
|
||||||
|
margin: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
background-color: white;
|
||||||
|
float: right;
|
||||||
|
min-width: 360px;
|
||||||
|
width: calc(100% - 300px);
|
||||||
|
padding: 30px;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
display: block;
|
||||||
|
max-width: 1400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
display: block;
|
||||||
|
max-width: 1400px;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.variation {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
|
||||||
|
.signature-attributes {
|
||||||
|
font-size: 60%;
|
||||||
|
color: #aaa;
|
||||||
|
font-style: italic;
|
||||||
|
font-weight: lighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 20px;
|
||||||
|
display: block;
|
||||||
|
border-top: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li a {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul ul {
|
||||||
|
padding-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li ul {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li ul li a {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
float: left;
|
||||||
|
display: block;
|
||||||
|
width: 300px;
|
||||||
|
background: #f7f7f7;
|
||||||
|
overflow-x: visible;
|
||||||
|
overflow-y: auto;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0px 30px 100px 30px;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
transition: left 0.2s;
|
||||||
|
z-index: 998;
|
||||||
|
margin-top: 0px;
|
||||||
|
top: 43px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon-button {
|
||||||
|
display: inline-block;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 1.5em;
|
||||||
|
right: 1.5em;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav h3 {
|
||||||
|
font-size: 13px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 24px;
|
||||||
|
margin: 40px 0 10px 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul {
|
||||||
|
font-size: 100%;
|
||||||
|
line-height: 17px;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style-type: none;
|
||||||
|
border: none;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul a {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul a, nav ul a:active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul a:hover, nav ul a:active {
|
||||||
|
color: hsl(200, 100%, 43%);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>ul {
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>ul li:first-child {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul li ul {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>ul>li {
|
||||||
|
border-bottom: 1px solid #e2e2e2;
|
||||||
|
padding: 10px 0 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>ul>li.active ul {
|
||||||
|
border-left: 3px solid #0095dd;
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>ul>li.active ul li.active a {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>ul>li.active a {
|
||||||
|
color: #0095dd;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>ul>li>a {
|
||||||
|
color: #706d77;
|
||||||
|
padding: 20px 0;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul ul {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul ul a {
|
||||||
|
color: #5f5c63;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav ul ul a, nav ul ul a:active {
|
||||||
|
font-family: 'bt_mono', monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
padding-left: 20px;
|
||||||
|
padding-top: 3px;
|
||||||
|
padding-bottom: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav h2 {
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>h2>a {
|
||||||
|
color: hsl(202, 71%, 50%);
|
||||||
|
border-bottom: 1px solid hsl(202, 71%, 50%);
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav>h2>a:hover {
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
background-color: #fff;
|
||||||
|
color: hsl(0, 0%, 28%);
|
||||||
|
margin-left: 300px;
|
||||||
|
display: block;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 30px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ancestors {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ancestors a {
|
||||||
|
color: #999 !important;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.important {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #950B02;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yes-def {
|
||||||
|
text-indent: -1000px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-signature {
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name, .signature {
|
||||||
|
font-family: 'bt_mono', monospace;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details {
|
||||||
|
margin-top: 14px;
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: right;
|
||||||
|
background: #ffffff;
|
||||||
|
/* Old browsers */
|
||||||
|
background: -moz-linear-gradient(left, #ffffff 0%, #fafafa 100%);
|
||||||
|
/* FF3.6-15 */
|
||||||
|
background: -webkit-linear-gradient(left, #ffffff 0%, #fafafa 100%);
|
||||||
|
/* Chrome10-25,Safari5.1-6 */
|
||||||
|
background: linear-gradient(to right, #ffffff 0%, #fafafa 100%);
|
||||||
|
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
|
||||||
|
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#fafafa', GradientType=1);
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details dt {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details dd {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details dd a {
|
||||||
|
font-style: italic;
|
||||||
|
font-weight: normal;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details ul {
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details pre.prettyprint {
|
||||||
|
margin: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.details .object-value {
|
||||||
|
padding-top: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-caption {
|
||||||
|
font-style: italic;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #545454;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint {
|
||||||
|
font-size: 13px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 3px;
|
||||||
|
overflow: auto;
|
||||||
|
background-color: #fbfbfb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.source {
|
||||||
|
width: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint code {
|
||||||
|
font-size: 100%;
|
||||||
|
line-height: 18px;
|
||||||
|
display: block;
|
||||||
|
margin: 0 30px;
|
||||||
|
background-color: #fbfbfb;
|
||||||
|
color: #4D4E53;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint>code {
|
||||||
|
padding: 30px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint .linenums code {
|
||||||
|
padding: 0 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint .linenums li:first-of-type code {
|
||||||
|
padding-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint code span.line {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums {
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums ol {
|
||||||
|
padding-left: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums li {
|
||||||
|
border-left: 3px #ddd solid
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums li.selected, .prettyprint.linenums li.selected * {
|
||||||
|
background-color: lightyellow
|
||||||
|
}
|
||||||
|
|
||||||
|
.prettyprint.linenums li * {
|
||||||
|
-webkit-user-select: text;
|
||||||
|
-moz-user-select: text;
|
||||||
|
-ms-user-select: text;
|
||||||
|
user-select: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.readme .prettyprint {
|
||||||
|
max-width: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params, .props {
|
||||||
|
border-spacing: 0;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 3px;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params .name, .props .name, .name code {
|
||||||
|
color: #4D4E53;
|
||||||
|
font-family: 'bt_mono', monospace;
|
||||||
|
font-size: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params td, .params th, .props td, .props th {
|
||||||
|
margin: 0px;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 10px;
|
||||||
|
display: table-cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params td {
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params thead tr, .props thead tr {
|
||||||
|
background-color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params .params thead tr, .props .props thead tr {
|
||||||
|
background-color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params td.description>p:first-child, .props td.description>p:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params td.description>p:last-child, .props td.description>p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dl.param-type {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.param-type dt, .param-type dd {
|
||||||
|
display: inline-block
|
||||||
|
}
|
||||||
|
|
||||||
|
.param-type dd {
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', monospace
|
||||||
|
}
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
color: #454545
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* tag source style */
|
||||||
|
|
||||||
|
.tag-deprecated {
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-source {
|
||||||
|
border-bottom: 1px solid rgba(28, 160, 224, 0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-source:first-child {
|
||||||
|
border-bottom: 1px solid rgba(28, 160, 224, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* navicon button */
|
||||||
|
|
||||||
|
.navicon-button {
|
||||||
|
position: relative;
|
||||||
|
transition: 0.25s;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
opacity: .8;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 100%;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
-webkit-box-shadow: 0px 2px 9px 0px rgba(0, 0, 0, 0.31);
|
||||||
|
-moz-box-shadow: 0px 2px 9px 0px rgba(0, 0, 0, 0.31);
|
||||||
|
box-shadow: 0px 2px 9px 0px rgba(0, 0, 0, 0.31);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon-button .navicon:before, .navicon-button .navicon:after {
|
||||||
|
transition: 0.25s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon-button:hover {
|
||||||
|
transition: 0.5s;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon-button:hover .navicon:before, .navicon-button:hover .navicon:after {
|
||||||
|
transition: 0.25s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon-button:hover .navicon:before {
|
||||||
|
top: .425rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon-button:hover .navicon:after {
|
||||||
|
top: -.425rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* navicon */
|
||||||
|
|
||||||
|
.navicon {
|
||||||
|
position: relative;
|
||||||
|
width: 1.5em;
|
||||||
|
height: .195rem;
|
||||||
|
background: #000;
|
||||||
|
top: calc(50% - .09rem);
|
||||||
|
left: calc(50% - .75rem);
|
||||||
|
transition: 0.3s;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon:before, .navicon:after {
|
||||||
|
display: block;
|
||||||
|
content: "";
|
||||||
|
height: .195rem;
|
||||||
|
width: 1.5rem;
|
||||||
|
background: #000;
|
||||||
|
position: absolute;
|
||||||
|
z-index: -1;
|
||||||
|
transition: 0.3s 0.25s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon:before {
|
||||||
|
top: 0.425rem;
|
||||||
|
height: .195rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navicon:after {
|
||||||
|
top: -0.425rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* open */
|
||||||
|
|
||||||
|
.nav-trigger:checked+label:not(.steps) .navicon:before, .nav-trigger:checked+label:not(.steps) .navicon:after {
|
||||||
|
top: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-trigger:checked+label .navicon:before, .nav-trigger:checked+label .navicon:after {
|
||||||
|
transition: 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Minus */
|
||||||
|
|
||||||
|
.nav-trigger:checked+label {
|
||||||
|
transform: scale(0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* × and + */
|
||||||
|
|
||||||
|
.nav-trigger:checked+label.plus .navicon, .nav-trigger:checked+label.x .navicon {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-trigger:checked+label.plus .navicon:before, .nav-trigger:checked+label.x .navicon:before {
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-trigger:checked+label.plus .navicon:after, .nav-trigger:checked+label.x .navicon:after {
|
||||||
|
transform: rotate(45deg);
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-trigger:checked+label.plus {
|
||||||
|
transform: scale(0.75) rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-trigger:checked~nav {
|
||||||
|
left: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-trigger:checked~.overlay {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-trigger {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
clip: rect(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlay {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: hsla(0, 0%, 0%, 0.5);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: separate;
|
||||||
|
;
|
||||||
|
display: block;
|
||||||
|
overflow-x: auto;
|
||||||
|
/*table-layout:fixed;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
table tbody td {
|
||||||
|
border-top: 1px solid hsl(207, 10%, 86%);
|
||||||
|
border-right: 1px solid #eee;
|
||||||
|
padding: 5px;
|
||||||
|
/*word-wrap: break-word;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
td table.params, td table.props {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (min-width: 320px) and (max-width: 680px) {
|
||||||
|
body {
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
#main {
|
||||||
|
padding: 30px 30px;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 360px;
|
||||||
|
}
|
||||||
|
nav {
|
||||||
|
background: #FFF;
|
||||||
|
width: 300px;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: -300px;
|
||||||
|
z-index: 3;
|
||||||
|
padding: 0 10px;
|
||||||
|
transition: left 0.2s;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
.navicon-button {
|
||||||
|
display: inline-block;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 1.5em;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
.top-nav-wrapper {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#main h1.page-title {
|
||||||
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-nav-wrapper {
|
||||||
|
background-color: #ececec;
|
||||||
|
position: fixed;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
padding: 10px 10px 0 10px;
|
||||||
|
z-index: 999;
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-nav-wrapper ul {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-nav-wrapper ul li {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 10px;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-nav-wrapper ul li.active {
|
||||||
|
border-bottom: 2px solid rgba(28, 160, 224, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-wrapper {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-wrapper svg {
|
||||||
|
position: absolute;
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.search-input {
|
||||||
|
background: transparent;
|
||||||
|
box-shadow: 0;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px solid #c7c7c7;
|
||||||
|
padding: 7px 15px 12px 35px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Smooth outline with box-shadow: */
|
||||||
|
|
||||||
|
input.search-input:focus {
|
||||||
|
border-bottom: 2px solid rgba(28, 160, 224, 1);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Hightlight JS Paradiso Light Theme */
|
||||||
|
|
||||||
|
.hljs-comment, .hljs-quote {
|
||||||
|
color: #776e71
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-variable, .hljs-template-variable, .hljs-tag, .hljs-name, .hljs-selector-id, .hljs-selector-class, .hljs-regexp, .hljs-link, .hljs-meta {
|
||||||
|
color: #ef6155
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-number, .hljs-built_in, .hljs-builtin-name, .hljs-literal, .hljs-type, .hljs-params, .hljs-deletion {
|
||||||
|
color: #f99b15
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-title, .hljs-section, .hljs-attribute {
|
||||||
|
color: #fec418
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-string, .hljs-symbol, .hljs-bullet, .hljs-addition {
|
||||||
|
color: #48b685
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-keyword, .hljs-selector-tag {
|
||||||
|
color: #815ba4
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs {
|
||||||
|
display: block;
|
||||||
|
overflow-x: auto;
|
||||||
|
background: #e7e9db;
|
||||||
|
color: #4f424c;
|
||||||
|
padding: 0.5em
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-emphasis {
|
||||||
|
font-style: italic
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-strong {
|
||||||
|
font-weight: bold
|
||||||
|
}
|
||||||
|
|
||||||
|
.link-icon {
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
margin-left: -25px;
|
||||||
|
padding-right: 5px;
|
||||||
|
padding-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.example-container .link-icon {
|
||||||
|
margin-top: -6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.example-container:hover .link-icon,
|
||||||
|
.name-container:hover .link-icon {
|
||||||
|
opacity: .5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name-container {
|
||||||
|
display: flex;
|
||||||
|
padding-top: 1em;
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
/* JSDoc prettify.js theme */
|
||||||
|
|
||||||
|
/* plain text */
|
||||||
|
.pln {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* string content */
|
||||||
|
.str {
|
||||||
|
color: hsl(104, 100%, 24%);
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a keyword */
|
||||||
|
.kwd {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a comment */
|
||||||
|
.com {
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a type name */
|
||||||
|
.typ {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a literal value */
|
||||||
|
.lit {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* punctuation */
|
||||||
|
.pun {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* lisp open bracket */
|
||||||
|
.opn {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* lisp close bracket */
|
||||||
|
.clo {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a markup tag name */
|
||||||
|
.tag {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a markup attribute name */
|
||||||
|
.atn {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a markup attribute value */
|
||||||
|
.atv {
|
||||||
|
color: #006400;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a declaration */
|
||||||
|
.dec {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a variable name */
|
||||||
|
.var {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a function name */
|
||||||
|
.fun {
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Specify class=linenums on a pre to get line numbering */
|
||||||
|
ol.linenums {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
/* Tomorrow Theme */
|
||||||
|
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||||
|
/* Pretty printing styles. Used with prettify.js. */
|
||||||
|
/* SPAN elements with the classes below are added by prettyprint. */
|
||||||
|
/* plain text */
|
||||||
|
.pln {
|
||||||
|
color: #4d4d4c; }
|
||||||
|
|
||||||
|
@media screen {
|
||||||
|
/* string content */
|
||||||
|
.str {
|
||||||
|
color: hsl(104, 100%, 24%); }
|
||||||
|
|
||||||
|
/* a keyword */
|
||||||
|
.kwd {
|
||||||
|
color: hsl(240, 100%, 50%); }
|
||||||
|
|
||||||
|
/* a comment */
|
||||||
|
.com {
|
||||||
|
color: hsl(0, 0%, 60%); }
|
||||||
|
|
||||||
|
/* a type name */
|
||||||
|
.typ {
|
||||||
|
color: hsl(240, 100%, 32%); }
|
||||||
|
|
||||||
|
/* a literal value */
|
||||||
|
.lit {
|
||||||
|
color: hsl(240, 100%, 40%); }
|
||||||
|
|
||||||
|
/* punctuation */
|
||||||
|
.pun {
|
||||||
|
color: #000000; }
|
||||||
|
|
||||||
|
/* lisp open bracket */
|
||||||
|
.opn {
|
||||||
|
color: #000000; }
|
||||||
|
|
||||||
|
/* lisp close bracket */
|
||||||
|
.clo {
|
||||||
|
color: #000000; }
|
||||||
|
|
||||||
|
/* a markup tag name */
|
||||||
|
.tag {
|
||||||
|
color: #c82829; }
|
||||||
|
|
||||||
|
/* a markup attribute name */
|
||||||
|
.atn {
|
||||||
|
color: #f5871f; }
|
||||||
|
|
||||||
|
/* a markup attribute value */
|
||||||
|
.atv {
|
||||||
|
color: #3e999f; }
|
||||||
|
|
||||||
|
/* a declaration */
|
||||||
|
.dec {
|
||||||
|
color: #f5871f; }
|
||||||
|
|
||||||
|
/* a variable name */
|
||||||
|
.var {
|
||||||
|
color: #c82829; }
|
||||||
|
|
||||||
|
/* a function name */
|
||||||
|
.fun {
|
||||||
|
color: #4271ae; } }
|
||||||
|
/* Use higher contrast and text-weight for printable form. */
|
||||||
|
@media print, projection {
|
||||||
|
.str {
|
||||||
|
color: #060; }
|
||||||
|
|
||||||
|
.kwd {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold; }
|
||||||
|
|
||||||
|
.com {
|
||||||
|
color: #600;
|
||||||
|
font-style: italic; }
|
||||||
|
|
||||||
|
.typ {
|
||||||
|
color: #404;
|
||||||
|
font-weight: bold; }
|
||||||
|
|
||||||
|
.lit {
|
||||||
|
color: #044; }
|
||||||
|
|
||||||
|
.pun, .opn, .clo {
|
||||||
|
color: #440; }
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold; }
|
||||||
|
|
||||||
|
.atn {
|
||||||
|
color: #404; }
|
||||||
|
|
||||||
|
.atv {
|
||||||
|
color: #060; } }
|
||||||
|
/* Style */
|
||||||
|
/*
|
||||||
|
pre.prettyprint {
|
||||||
|
background: white;
|
||||||
|
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px; }
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Get LI elements to show when they are in the main article */
|
||||||
|
article ul li {
|
||||||
|
list-style-type: circle;
|
||||||
|
margin-left: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Specify class=linenums on a pre to get line numbering */
|
||||||
|
ol.linenums {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0; }
|
||||||
|
|
||||||
|
/* IE indents via margin-left */
|
||||||
|
li.L0,
|
||||||
|
li.L1,
|
||||||
|
li.L2,
|
||||||
|
li.L3,
|
||||||
|
li.L4,
|
||||||
|
li.L5,
|
||||||
|
li.L6,
|
||||||
|
li.L7,
|
||||||
|
li.L8,
|
||||||
|
li.L9 {
|
||||||
|
/* */ }
|
||||||
|
|
||||||
|
/* Alternate shading for lines */
|
||||||
|
li.L1,
|
||||||
|
li.L3,
|
||||||
|
li.L5,
|
||||||
|
li.L7,
|
||||||
|
li.L9 {
|
||||||
|
/* */ }
|
|
@ -11,7 +11,13 @@ const {
|
||||||
DEFAULT_SPEC_VERSION_HEADER
|
DEFAULT_SPEC_VERSION_HEADER
|
||||||
} = require("./constants");
|
} = require("./constants");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to receive a CloudEvent from an HTTP POST request.
|
||||||
|
*/
|
||||||
class HTTPReceiver {
|
class HTTPReceiver {
|
||||||
|
/**
|
||||||
|
* Create an instance of an HTTPReceiver to accept incoming CloudEvents.
|
||||||
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.receivers = {
|
this.receivers = {
|
||||||
v1: {
|
v1: {
|
||||||
|
@ -25,6 +31,14 @@ class HTTPReceiver {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acceptor for an incoming HTTP CloudEvent POST. Can process
|
||||||
|
* binary and structured incoming CloudEvents.
|
||||||
|
*
|
||||||
|
* @param {Object} headers HTTP headers keyed by header name ("Content-Type")
|
||||||
|
* @param {Object|JSON} body The body of the HTTP request
|
||||||
|
* @return {CloudEvent} A new {CloudEvent} instance
|
||||||
|
*/
|
||||||
accept(headers, body) {
|
accept(headers, body) {
|
||||||
const mode = getMode(headers);
|
const mode = getMode(headers);
|
||||||
const version = getVersion(mode, headers, body);
|
const version = getVersion(mode, headers, body);
|
||||||
|
|
|
@ -1,24 +1,37 @@
|
||||||
const Spec = require("./specs/spec_1.js");
|
const Spec = require("./specs/spec_1.js");
|
||||||
const Formatter = require("./formats/json/formatter.js");
|
const Formatter = require("./formats/json/formatter.js");
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Class created using the Builder Design Pattern.
|
* An instance of a CloudEvent.
|
||||||
*
|
|
||||||
* https://en.wikipedia.org/wiki/Builder_pattern
|
|
||||||
*/
|
*/
|
||||||
class CloudEvent {
|
class CloudEvent {
|
||||||
constructor(_spec, _formatter) {
|
/**
|
||||||
this.spec = (_spec) ? new _spec(CloudEvent) : new Spec(CloudEvent);
|
* Creates a new CloudEvent instance
|
||||||
this.formatter = (_formatter) ? new _formatter() : new Formatter();
|
* @param {Spec} [UserSpec] A CloudEvent version specification
|
||||||
|
* @param {Formatter} [UserFormatter] Converts the event into a readable string
|
||||||
|
*/
|
||||||
|
constructor(UserSpec, UserFormatter) {
|
||||||
|
this.spec = (UserSpec) ? new UserSpec(CloudEvent) : new Spec(CloudEvent);
|
||||||
|
this.formatter = (UserFormatter) ? new UserFormatter() : new Formatter();
|
||||||
|
|
||||||
// The map of extensions
|
// The map of extensions
|
||||||
this.extensions = {};
|
this.extensions = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the formatters available to this CloudEvent
|
||||||
|
* @returns {Object} a JSON formatter
|
||||||
|
*/
|
||||||
getFormats() {
|
getFormats() {
|
||||||
return { json: Formatter };
|
return { json: Formatter };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the CloudEvent as JSON. Validates the event according
|
||||||
|
* to the CloudEvent specification and throws an exception if
|
||||||
|
* it's invalid.
|
||||||
|
* @returns {JSON} the CloudEvent in JSON form
|
||||||
|
*/
|
||||||
format() {
|
format() {
|
||||||
// Check the constraints
|
// Check the constraints
|
||||||
this.spec.check();
|
this.spec.check();
|
||||||
|
@ -30,81 +43,174 @@ class CloudEvent {
|
||||||
return this.formatter.format(this.spec.payload);
|
return this.formatter.format(this.spec.payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the CLoudEvent as JSON. No specification validation
|
||||||
|
* is performed.
|
||||||
|
* @returns {JSON} the CloudEvent in JSON form
|
||||||
|
*/
|
||||||
toString() {
|
toString() {
|
||||||
return this.formatter.toString(this.spec.payload);
|
return this.formatter.toString(this.spec.payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the event type
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#type
|
||||||
|
* @param {string} type the type of event related to the originating source
|
||||||
|
* @returns {CloudEvent} this CloudEvent
|
||||||
|
*/
|
||||||
type(type) {
|
type(type) {
|
||||||
this.spec.type(type);
|
this.spec.type(type);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the event type
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#type
|
||||||
|
* @returns {String} the type of event related to the originating source
|
||||||
|
*/
|
||||||
getType() {
|
getType() {
|
||||||
return this.spec.getType();
|
return this.spec.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: The fact that this is exposed is problematic, given that it's
|
||||||
|
// immutable and this method will have no effect. The specification
|
||||||
|
// version is determined via the constructor - specifically the use
|
||||||
|
// of cloud event creator functions in /v03 and /v1. By default this
|
||||||
|
// object is created as a version 1.0 CloudEvent. Not documenting.
|
||||||
specversion(version) {
|
specversion(version) {
|
||||||
return this.spec.specversion(version);
|
return this.spec.specversion(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the CloudEvent specification version
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#specversion
|
||||||
|
* @returns {string} The CloudEvent version that this event adheres to
|
||||||
|
*/
|
||||||
getSpecversion() {
|
getSpecversion() {
|
||||||
return this.spec.getSpecversion();
|
return this.spec.getSpecversion();
|
||||||
}
|
}
|
||||||
|
|
||||||
source(_source) {
|
/**
|
||||||
this.spec.source(_source);
|
* Sets the origination source of this event.
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#source-1
|
||||||
|
* @param {URI} source the context in which the event happened
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
source(source) {
|
||||||
|
this.spec.source(source);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the origination source of this event.
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#source-1
|
||||||
|
* @returns {string} the event source
|
||||||
|
*/
|
||||||
getSource() {
|
getSource() {
|
||||||
return this.spec.getSource();
|
return this.spec.getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
id(_id) {
|
/**
|
||||||
this.spec.id(_id);
|
* Sets the event id. Source + id must be unique for each distinct event.
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#id
|
||||||
|
* @param {string} id source+id must be unique for each distinct event
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
id(id) {
|
||||||
|
this.spec.id(id);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the event id.
|
||||||
|
* @returns {string} the event id
|
||||||
|
*/
|
||||||
getId() {
|
getId() {
|
||||||
return this.spec.getId();
|
return this.spec.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
time(_time) {
|
/**
|
||||||
this.spec.time(_time);
|
* Sets the timestamp for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#time
|
||||||
|
* @param {Date} time timestamp when the event occurred
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
time(time) {
|
||||||
|
// TODO: Ensure that this is represented as a Date internally,
|
||||||
|
// or update the JSDoc
|
||||||
|
this.spec.time(time);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the timestamp for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#time
|
||||||
|
* @returns {Date} the timestamp for this event
|
||||||
|
*/
|
||||||
getTime() {
|
getTime() {
|
||||||
|
// TODO: Ensure that this is represented as a Date internally,
|
||||||
|
// or update the JSDoc
|
||||||
return this.spec.getTime();
|
return this.spec.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
schemaurl(_schemaurl) {
|
// TODO: Deprecated in 1.0
|
||||||
this.spec.schemaurl(_schemaurl);
|
schemaurl(schemaurl) {
|
||||||
|
this.spec.schemaurl(schemaurl);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Deprecated in 1.0
|
||||||
getSchemaurl() {
|
getSchemaurl() {
|
||||||
return this.spec.getSchemaurl();
|
return this.spec.getSchemaurl();
|
||||||
}
|
}
|
||||||
|
|
||||||
dataContenttype(_contenttype) {
|
/**
|
||||||
this.spec.dataContenttype(_contenttype);
|
* Sets the content type of the data value for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#datacontenttype
|
||||||
|
* @param {string} contenttype per https://tools.ietf.org/html/rfc2046
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
dataContenttype(contenttype) {
|
||||||
|
this.spec.dataContenttype(contenttype);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the content type of the data value for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#datacontenttype
|
||||||
|
* @returns {string} the content type for the data in this event
|
||||||
|
*/
|
||||||
getDataContenttype() {
|
getDataContenttype() {
|
||||||
return this.spec.getDataContenttype();
|
return this.spec.getDataContenttype();
|
||||||
}
|
}
|
||||||
|
|
||||||
data(_data) {
|
/**
|
||||||
this.spec.data(_data);
|
* Sets the data for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#event-data
|
||||||
|
* @param {*} data any data associated with this event
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
|
data(data) {
|
||||||
|
this.spec.data(data);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets any data that has been set for this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#event-data
|
||||||
|
* @returns {*} any data set for this event
|
||||||
|
*/
|
||||||
getData() {
|
getData() {
|
||||||
return this.spec.getData();
|
return this.spec.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an extension attribute to this CloudEvent
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes
|
||||||
|
* @param {*} key the name of the extension attribute
|
||||||
|
* @param {*} value the value of the extension attribute
|
||||||
|
* @returns {CloudEvent} this CloudEvent instance
|
||||||
|
*/
|
||||||
addExtension(key, value) {
|
addExtension(key, value) {
|
||||||
this.spec.addExtension(key, value);
|
this.spec.addExtension(key, value);
|
||||||
|
|
||||||
|
@ -114,6 +220,12 @@ class CloudEvent {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the extension attributes, if any, associated with this event
|
||||||
|
* @see https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes
|
||||||
|
* @returns {Object} the extensions attributes - if none exist will will be {}
|
||||||
|
* // TODO - this should return null or undefined if no extensions
|
||||||
|
*/
|
||||||
getExtensions() {
|
getExtensions() {
|
||||||
return this.extensions;
|
return this.extensions;
|
||||||
}
|
}
|
||||||
|
|
15
package.json
|
@ -4,13 +4,14 @@
|
||||||
"description": "CloudEvents SDK for JavaScript",
|
"description": "CloudEvents SDK for JavaScript",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "standardx",
|
"lint": "standardx index.js lib examples",
|
||||||
"fix": "standardx --fix",
|
"fix": "standardx --fix",
|
||||||
"pretest": "npm run lint",
|
"pretest": "npm run lint",
|
||||||
"test": "mocha test/**/*.js",
|
"test": "mocha test/**/*.js",
|
||||||
"coverage": "nyc --reporter=lcov --reporter=text npm run test",
|
"coverage": "nyc --reporter=lcov --reporter=text npm run test",
|
||||||
"precoverage-publish": "npm run coverage",
|
"precoverage-publish": "npm run coverage",
|
||||||
"coverage-publish": "wget -qO - https://coverage.codacy.com/get.sh | bash -s report -l JavaScript -r coverage/lcov.info",
|
"coverage-publish": "wget -qO - https://coverage.codacy.com/get.sh | bash -s report -l JavaScript -r coverage/lcov.info",
|
||||||
|
"generate-docs": "jsdoc --configure .jsdoc.json --verbose",
|
||||||
"release": "standard-version"
|
"release": "standard-version"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -98,14 +99,16 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "~4.2.0",
|
"chai": "~4.2.0",
|
||||||
"mocha": "~7.1.1",
|
|
||||||
"nock": "~12.0.3",
|
|
||||||
"nyc": "~15.0.0",
|
|
||||||
"eslint-config-standard": "^14.1.1",
|
"eslint-config-standard": "^14.1.1",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.20.2",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"standardx": "^5.0.0",
|
"jsdoc": "^3.6.4",
|
||||||
"standard-version": "^7.1.0"
|
"jsdoc-fresh": "^1.0.2",
|
||||||
|
"mocha": "~7.1.1",
|
||||||
|
"nock": "~12.0.3",
|
||||||
|
"nyc": "~15.0.0",
|
||||||
|
"standard-version": "^7.1.0",
|
||||||
|
"standardx": "^5.0.0"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|