fix: introduce CloudEventV1 and CloudEventV03 interfaces (#194)

This extracts all of the attributes from a `CloudEventVX` that
are not generated by the constructor (id and specversion) into their
own `CloudEventVXAttributes` interface which the `CloudEventVX`
interface extends. This allows TS devs to optionally provide `id`
and `specversion` with proper autocompletion.

Additionally, I have added a union type, `CE` in `cloudevent.ts` which
represents any of `CloudEventV1`, `CloudEventv03`, `CloudEventV1Attributes`
and `CloudEventV03Attributes` interfaces.

Finally, this commit changes all of the user facing API to be `.ts` instead
of `.js` files.

The existing documentation in `./docs` was removed. It should be replaced with generated
HTML from tsdocs, pending some other method of publishing API documentation. That will
come as a separate, docs-only PR.

Fixes: https://github.com/cloudevents/skd-javascript/issues/188

Signed-off-by: Lance Ball <lball@redhat.com>
This commit is contained in:
Lance Ball 2020-05-29 17:49:02 -04:00 committed by GitHub
parent 15cd7638da
commit a5befbe0cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
99 changed files with 500 additions and 25285 deletions

4
.gitignore vendored
View File

@ -5,8 +5,10 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Generated typedefs
# Generated files
*.d.ts
index.js
lib
# Runtime data
pids

View File

@ -1,30 +0,0 @@
{
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc"]
},
"source": {
"include": ["lib", "package.json", "README.md"],
"includePattern": ".js$",
"excludePattern": "(node_modules/|docs|examples|coverage|test)"
},
"plugins": [
"plugins/markdown",
"plugins/ignore-typedef"
],
"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"
}
}

View File

@ -1,535 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
BinaryHTTPEmitter - 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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
BinaryHTTPEmitter
</h1>
<section>
<header>
<h2>
BinaryHTTPEmitter
</h2>
<div class="class-description">
<p>A class to emit binary CloudEvents over HTTP.</p>
</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<span class='name-container'>
<a class="link-icon" href="#BinaryHTTPEmitter">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="BinaryHTTPEmitter">
<span class="type-signature"></span>new BinaryHTTPEmitter<span class="signature">(version)</span><span class="type-signature"></span>
</h4>
</span>
<div class="description">
<p>Create a new {BinaryHTTPEmitter} for the provided CloudEvent specification version.
Once an instance is created for a given spec version, it may only be used to send
events for that version.
Default version is 1.0</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>version</code></td>
<td class="type">
<span class="param-type">
string
</span>
</td>
<td class="description last">
<p>the CloudEvent HTTP specification version.
Default: 1.0</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_emitter_binary.js.html">bindings/http/emitter_binary.js</a>, <a href="bindings_http_emitter_binary.js.html#line35">line 35</a>
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<span class='name-container'>
<a class="link-icon" href="#emit">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="emit">
<span class="type-signature">(async) </span>emit<span class="signature">(options, cloudevent)</span><span class="type-signature"> &rarr; {Promise}</span>
</h4>
</span>
<div class="description">
<p>Sends this cloud event to a receiver over HTTP.</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>options</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="description last">
<p>The configuration options for this event. Options
provided other than <code>url</code> will be passed along to Node.js <code>http.request</code>.
https://nodejs.org/api/http.html#http_http_request_options_callback</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">
URL
</span>
</td>
<td class="description last">
<p>The HTTP/S url that should receive this event</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>cloudevent</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="description last">
<p>the CloudEvent to be sent</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_emitter_binary.js.html">bindings/http/emitter_binary.js</a>, <a href="bindings_http_emitter_binary.js.html#line55">line 55</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>

View File

@ -1,716 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
BinaryHTTPReceiver - 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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
BinaryHTTPReceiver
</h1>
<section>
<header>
<h2>
BinaryHTTPReceiver
</h2>
<div class="class-description">
<p>/**
A class that receives binary CloudEvents over HTTP. This class can be used
if you know that all incoming events will be using binary transport. If
events can come as either binary or structured, use {HTTPReceiver}.</p>
</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<span class='name-container'>
<a class="link-icon" href="#BinaryHTTPReceiver">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="BinaryHTTPReceiver">
<span class="type-signature"></span>new BinaryHTTPReceiver<span class="signature">(version)</span><span class="type-signature"></span>
</h4>
</span>
<div class="description">
<p>Creates a new BinaryHTTPReceiver to accept events over HTTP.</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>version</code></td>
<td class="type">
<span class="param-type">
string
</span>
</td>
<td class="description last">
<p>the Cloud Event specification version to use. Default &quot;1.0&quot;</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_receiver_binary.js.html">bindings/http/receiver_binary.js</a>, <a href="bindings_http_receiver_binary.js.html#line20">line 20</a>
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<span class='name-container'>
<a class="link-icon" href="#check">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="check">
<span class="type-signature"></span>check<span class="signature">(payload, headers)</span><span class="type-signature"> &rarr; {boolean}</span>
</h4>
</span>
<div class="description">
<p>Checks an incoming HTTP request to determine if it conforms to the
Cloud Event specification for this receiver.</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>payload</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="description last">
<p>the HTTP request body</p>
</td>
</tr>
<tr>
<td class="name"><code>headers</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="description last">
<p>the HTTP request headers</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_receiver_binary.js.html">bindings/http/receiver_binary.js</a>, <a href="bindings_http_receiver_binary.js.html#line37">line 37</a>
</li>
</ul>
</dd>
</dl>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
<p>if the event does not conform to the spec</p>
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">
<a href="ValidationError.html">ValidationError</a>
</span>
</dd>
</dl>
</dt>
<dd></dd>
</dl>
<span class='name-container'>
<a class="link-icon" href="#parse">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="parse">
<span class="type-signature"></span>parse<span class="signature">(payload, headers)</span><span class="type-signature"> &rarr; {<a href="CloudEvent.html">CloudEvent</a>}</span>
</h4>
</span>
<div class="description">
<p>Parses an incoming HTTP request, converting it to a {CloudEvent}
instance if it conforms to the Cloud Event specification for this receiver.</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>payload</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="description last">
<p>the HTTP request body</p>
</td>
</tr>
<tr>
<td class="name"><code>headers</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="description last">
<p>the HTTP request headers</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_receiver_binary.js.html">bindings/http/receiver_binary.js</a>, <a href="bindings_http_receiver_binary.js.html#line50">line 50</a>
</li>
</ul>
</dd>
</dl>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
<p>of the event does not conform to the spec</p>
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">
<a href="ValidationError.html">ValidationError</a>
</span>
</dd>
</dl>
</dt>
<dd></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>

File diff suppressed because it is too large Load Diff

View File

@ -1,923 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
HTTPEmitter - 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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
HTTPEmitter
</h1>
<section>
<header>
<h2>
HTTPEmitter
</h2>
<div class="class-description">
<p>const {
SPEC_V03,
SPEC_V1
} = require(&quot;./constants&quot;);</p>
<p>/**
A class which is capable of sending binary and structured events using
the CloudEvents HTTP Protocol Binding specification.</p>
</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<span class='name-container'>
<a class="link-icon" href="#HTTPEmitter">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="HTTPEmitter">
<span class="type-signature"></span>new HTTPEmitter<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span>
</h4>
</span>
<div class="description">
<p>Creates a new instance of {HTTPEmitter}. The default emitter uses the 1.0
protocol specification in binary mode.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>The configuration options for this event emitter</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">
URL
</span>
</td>
<td class="attributes">
</td>
<td class="description last">
<p>The endpoint that will receive the sent events.</p>
</td>
</tr>
<tr>
<td class="name"><code>version</code></td>
<td class="type">
<span class="param-type">
string
</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>The HTTP binding specification version. Default: &quot;1.0&quot;</p>
</td>
</tr>
</tbody>
</table>
</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_emitter.js.html">bindings/http/http_emitter.js</a>, <a href="bindings_http_http_emitter.js.html#line28">line 28</a>
</li>
</ul>
</dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li>
<a href="https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md">https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md</a>
</li>
<li>
<a href="https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md#13-content-modes">https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md#13-content-modes</a>
</li>
</ul>
</dd>
</dl>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
<p>if no options.url is provided or an unknown specification version is provided.</p>
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">
TypeError
</span>
</dd>
</dl>
</dt>
<dd></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<span class='name-container'>
<a class="link-icon" href="#headers">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="headers">
<span class="type-signature"></span>headers<span class="signature">(event)</span><span class="type-signature"> &rarr; {Object}</span>
</h4>
</span>
<div class="description">
<p>Returns the HTTP headers that will be sent for this event when the HTTP transmission
mode is &quot;binary&quot;. Events sent over HTTP in structured mode only have a single CE header
and that is &quot;ce-id&quot;, corresponding to the event ID.</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>event</code></td>
<td class="type">
<span class="param-type">
<a href="CloudEvent.html">CloudEvent</a>
</span>
</td>
<td class="description last">
<p>a CloudEvent</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_emitter.js.html">bindings/http/http_emitter.js</a>, <a href="bindings_http_http_emitter.js.html#line77">line 77</a>
</li>
</ul>
</dd>
</dl>
<span class='name-container'>
<a class="link-icon" href="#send">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="send">
<span class="type-signature"></span>send<span class="signature">(event, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span>
</h4>
</span>
<div class="description">
<p>Sends the {CloudEvent} to an event receiver over HTTP POST</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>event</code></td>
<td class="type">
<span class="param-type">
<a href="CloudEvent.html">CloudEvent</a>
</span>
</td>
<td class="attributes">
</td>
<td class="description last">
<p>the CloudEvent to be sent</p>
</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>The configuration options for this event. Options
provided will be passed along to Node.js <code>http.request()</code>.
https://nodejs.org/api/http.html#http_http_request_options_callback</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">
URL
</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>The HTTP/S url that should receive this event.
The URL is optional if one was provided when this emitter was constructed.
In that case, it will be used as the recipient endpoint. The endpoint can
be overridden by providing a URL here.</p>
</td>
</tr>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">
string
</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>the message mode for sending this event.
Possible values are &quot;binary&quot; and &quot;structured&quot;. Default: structured</p>
</td>
</tr>
</tbody>
</table>
</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_emitter.js.html">bindings/http/http_emitter.js</a>, <a href="bindings_http_http_emitter.js.html#line56">line 56</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>

View File

@ -1,427 +0,0 @@
<!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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></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#line28">line 28</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"> &rarr; {<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 (&quot;Content-Type&quot;)</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#line49">line 49</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>

View File

@ -1,485 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
StructuredHTTPEmitter - 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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
StructuredHTTPEmitter
</h1>
<section>
<header>
<h2>
StructuredHTTPEmitter
</h2>
<div class="class-description">
<p>const {
DATA_ATTRIBUTE,
DEFAULT_CE_CONTENT_TYPE,
HEADERS,
HEADER_CONTENT_TYPE
} = require(&quot;./constants.js&quot;);</p>
<p>const defaults = {
[HEADERS]: {
[HEADER_CONTENT_TYPE]: DEFAULT_CE_CONTENT_TYPE
},
method: &quot;POST&quot;
};</p>
<p>/**
A class for sending {CloudEvent} instances over HTTP.</p>
</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<span class='name-container'>
<a class="link-icon" href="#StructuredHTTPEmitter">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="StructuredHTTPEmitter">
<span class="type-signature"></span>new StructuredHTTPEmitter<span class="signature">()</span><span class="type-signature"></span>
</h4>
</span>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="bindings_http_emitter_structured.js.html">bindings/http/emitter_structured.js</a>, <a href="bindings_http_emitter_structured.js.html#line22">line 22</a>
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<span class='name-container'>
<a class="link-icon" href="#emit">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="emit">
<span class="type-signature">(async) </span>emit<span class="signature">(options, cloudevent)</span><span class="type-signature"> &rarr; {Promise}</span>
</h4>
</span>
<div class="description">
<p>Sends the event over HTTP</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>options</code></td>
<td class="type">
<span class="param-type">
Object
</span>
</td>
<td class="description last">
<p>The configuration options for this event. Options
provided will be passed along to Node.js <code>http.request()</code>.
https://nodejs.org/api/http.html#http_http_request_options_callback</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">
URL
</span>
</td>
<td class="description last">
<p>The HTTP/S url that should receive this event</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>cloudevent</code></td>
<td class="type">
<span class="param-type">
<a href="CloudEvent.html">CloudEvent</a>
</span>
</td>
<td class="description last">
<p>The CloudEvent to be sent</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_emitter_structured.js.html">bindings/http/emitter_structured.js</a>, <a href="bindings_http_emitter_structured.js.html#line34">line 34</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>

View File

@ -1,726 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
StructuredHTTPReceiver - 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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
StructuredHTTPReceiver
</h1>
<section>
<header>
<h2>
StructuredHTTPReceiver
</h2>
<div class="class-description">
<p>/**
A utility class used to receive structured CloudEvents
over HTTP.</p>
</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<span class='name-container'>
<a class="link-icon" href="#StructuredHTTPReceiver">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="StructuredHTTPReceiver">
<span class="type-signature"></span>new StructuredHTTPReceiver<span class="signature">(version)</span><span class="type-signature"></span>
</h4>
</span>
<div class="description">
<p>Creates a new StructuredHTTPReceiver. Supports Cloud Events specification
versions 0.3 and 1.0 (default).</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>version</code></td>
<td class="type">
<span class="param-type">
string
</span>
</td>
<td class="description last">
<p>the Cloud Events specification version. Default: 1.0.</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_receiver_structured.js.html">bindings/http/receiver_structured.js</a>, <a href="bindings_http_receiver_structured.js.html#line21">line 21</a>
</li>
</ul>
</dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li>
{StructuredReceiver}
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<span class='name-container'>
<a class="link-icon" href="#check">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="check">
<span class="type-signature"></span>check<span class="signature">(payload, headers)</span><span class="type-signature"> &rarr; {boolean}</span>
</h4>
</span>
<div class="description">
<p>Checks whether the provided payload and headers conform to the Cloud Events
specification version supported by this instance.</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>payload</code></td>
<td class="type">
<span class="param-type">
object
</span>
</td>
<td class="description last">
<p>the cloud event data payload</p>
</td>
</tr>
<tr>
<td class="name"><code>headers</code></td>
<td class="type">
<span class="param-type">
object
</span>
</td>
<td class="description last">
<p>the HTTP headers received for this cloud event</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_receiver_structured.js.html">bindings/http/receiver_structured.js</a>, <a href="bindings_http_receiver_structured.js.html#line38">line 38</a>
</li>
</ul>
</dd>
</dl>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
<p>if the payload and header combination do not conform to the spec</p>
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">
<a href="ValidationError.html">ValidationError</a>
</span>
</dd>
</dl>
</dt>
<dd></dd>
</dl>
<span class='name-container'>
<a class="link-icon" href="#parse">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="parse">
<span class="type-signature"></span>parse<span class="signature">(payload, headers)</span><span class="type-signature"> &rarr; {<a href="CloudEvent.html">CloudEvent</a>}</span>
</h4>
</span>
<div class="description">
<p>Creates a new CloudEvent instance based on the provided payload and headers.</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>payload</code></td>
<td class="type">
<span class="param-type">
object
</span>
</td>
<td class="description last">
<p>the cloud event data payload</p>
</td>
</tr>
<tr>
<td class="name"><code>headers</code></td>
<td class="type">
<span class="param-type">
object
</span>
</td>
<td class="description last">
<p>the HTTP headers received for this cloud event</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_receiver_structured.js.html">bindings/http/receiver_structured.js</a>, <a href="bindings_http_receiver_structured.js.html#line50">line 50</a>
</li>
</ul>
</dd>
</dl>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
<p>if the payload and header combination do not conform to the spec</p>
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">
<a href="ValidationError.html">ValidationError</a>
</span>
</dd>
</dl>
</dt>
<dd></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>

View File

@ -1,352 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
ValidationError - 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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
ValidationError
</h1>
<section>
<header>
<h2>
ValidationError
</h2>
<div class="class-description">
<p>A Error class that will be thrown when a CloudEvent
cannot be properly validated against a specification.</p>
</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<span class='name-container'>
<a class="link-icon" href="#ValidationError">
<svg height="20" width="20" style="fill: black;">
<use xlink:href="#linkIcon"></use>
</svg>
</a>
<h4 class="name" id="ValidationError">
<span class="type-signature"></span>new ValidationError<span class="signature">(message, errors<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span>
</h4>
</span>
<div class="description">
<p>Constructs a new {ValidationError} with the message
and array of additional errors.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">
string
</span>
</td>
<td class="attributes">
</td>
<td class="description last">
<p>the error message</p>
</td>
</tr>
<tr>
<td class="name"><code>errors</code></td>
<td class="type">
<span class="param-type">
Array.&lt;string>
</span>
|
<span class="param-type">
Array.&lt;ErrorObject>
</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>any additional errors related to validation</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_validation_validation_error.js.html">bindings/http/validation/validation_error.js</a>, <a href="bindings_http_validation_validation_error.js.html#line17">line 17</a>
</li>
</ul>
</dd>
</dl>
</div>
</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>

View File

@ -1,202 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
bindings/http/emitter_binary.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/emitter_binary.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const { default: Axios } = require("axios");
const EmitterV1 = require("./v1").BinaryEmitter;
const EmitterV3 = require("./v03").BinaryEmitter;
const {
HEADERS,
BINARY_HEADERS_03,
BINARY_HEADERS_1,
HEADER_CONTENT_TYPE,
DEFAULT_CONTENT_TYPE,
DATA_ATTRIBUTE,
SPEC_V1,
SPEC_V03
} = require("./constants.js");
const defaults = {
[HEADERS]: {
[HEADER_CONTENT_TYPE]: DEFAULT_CONTENT_TYPE
},
method: "POST"
};
/**
* A class to emit binary CloudEvents over HTTP.
*/
class BinaryHTTPEmitter {
/**
* Create a new {BinaryHTTPEmitter} for the provided CloudEvent specification version.
* Once an instance is created for a given spec version, it may only be used to send
* events for that version.
* Default version is 1.0
* @param {string} version - the CloudEvent HTTP specification version.
* Default: 1.0
*/
constructor(version) {
if (version === SPEC_V1) {
this.headerParserMap = EmitterV1;
this.extensionPrefix = BINARY_HEADERS_1.EXTENSIONS_PREFIX;
} else if (version === SPEC_V03) {
this.headerParserMap = EmitterV3;
this.extensionPrefix = BINARY_HEADERS_03.EXTENSIONS_PREFIX;
}
}
/**
* Sends this cloud event to a receiver over HTTP.
*
* @param {Object} options The configuration options for this event. Options
* provided other than `url` will be passed along to Node.js `http.request`.
* https://nodejs.org/api/http.html#http_http_request_options_callback
* @param {URL} options.url The HTTP/S url that should receive this event
* @param {Object} cloudevent the CloudEvent to be sent
* @returns {Promise} Promise with an eventual response from the receiver
*/
async emit(options, cloudevent) {
const config = { ...options, ...defaults };
const headers = config[HEADERS];
this.headerParserMap.forEach((parser, getterName) => {
const value = cloudevent[getterName];
if (value) {
headers[parser.headerName] = parser.parse(value);
}
});
// Set the cloudevent payload
const formatted = cloudevent.format();
let data = formatted.data;
data = (formatted.data_base64 ? formatted.data_base64 : data);
// Have extensions?
const exts = cloudevent.getExtensions();
Object.keys(exts)
.filter((ext) => Object.hasOwnProperty.call(exts, ext))
.forEach((ext) => {
headers[this.extensionPrefix + ext] = exts[ext];
});
config[DATA_ATTRIBUTE] = data;
config[HEADERS] = headers;
// Return the Promise
// @ts-ignore Types of property 'url' are incompatible. Type 'URL' is not assignable to type 'string'.
return Axios.request(config);
}
}
module.exports = BinaryHTTPEmitter;
</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>

View File

@ -1,156 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
bindings/http/emitter_structured.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/emitter_structured.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const { default: Axios } = require("axios");
/** @typedef {import("../../cloudevent")} CloudEvent */
const {
DATA_ATTRIBUTE,
DEFAULT_CE_CONTENT_TYPE,
HEADERS,
HEADER_CONTENT_TYPE
} = require("./constants.js");
const defaults = {
[HEADERS]: {
[HEADER_CONTENT_TYPE]: DEFAULT_CE_CONTENT_TYPE
},
method: "POST"
};
/**
* A class for sending {CloudEvent} instances over HTTP.
*/
class StructuredHTTPEmitter {
// TODO: Do we really need a class here? There is no state maintenance
/**
* Sends the event over HTTP
* @param {Object} options The configuration options for this event. Options
* provided will be passed along to Node.js `http.request()`.
* https://nodejs.org/api/http.html#http_http_request_options_callback
* @param {URL} options.url The HTTP/S url that should receive this event
* @param {CloudEvent} cloudevent The CloudEvent to be sent
* @returns {Promise} Promise with an eventual response from the receiver
*/
async emit(options, cloudevent) {
const config = { ...defaults, ...options };
config[DATA_ATTRIBUTE] = cloudevent.format();
// @ts-ignore Types of property 'url' are incompatible. Type 'URL' is not assignable to type 'string'.
return Axios.request(config);
}
}
module.exports = StructuredHTTPEmitter;
</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>

View File

@ -1,205 +0,0 @@
<!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_emitter.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/http_emitter.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const BinaryHTTPEmitter = require("./emitter_binary.js");
const StructuredEmitter = require("./emitter_structured.js");
/** @typedef {import("../../cloudevent")} CloudEvent */
const {
SPEC_V03,
SPEC_V1
} = require("./constants");
/**
* A class which is capable of sending binary and structured events using
* the CloudEvents HTTP Protocol Binding specification.
*
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md#13-content-modes
*/
class HTTPEmitter {
/**
* Creates a new instance of {HTTPEmitter}. The default emitter uses the 1.0
* protocol specification in binary mode.
*
* @param {Object} [options] The configuration options for this event emitter
* @param {URL} options.url The endpoint that will receive the sent events.
* @param {string} [options.version] The HTTP binding specification version. Default: "1.0"
* @throws {TypeError} if no options.url is provided or an unknown specification version is provided.
*/
constructor({ url, version = SPEC_V1 } = { url: undefined }) {
if (version !== SPEC_V03 &amp;&amp; version !== SPEC_V1) {
throw new TypeError(
`Unknown CloudEvent specification version: ${version}`);
}
if (!url) {
throw new TypeError("A default endpoint URL is required for a CloudEvent emitter");
}
this.binary = new BinaryHTTPEmitter(version);
this.structured = new StructuredEmitter();
this.url = url;
}
/**
* Sends the {CloudEvent} to an event receiver over HTTP POST
*
* @param {CloudEvent} event the CloudEvent to be sent
* @param {Object} [options] The configuration options for this event. Options
* provided will be passed along to Node.js `http.request()`.
* https://nodejs.org/api/http.html#http_http_request_options_callback
* @param {URL} [options.url] The HTTP/S url that should receive this event.
* The URL is optional if one was provided when this emitter was constructed.
* In that case, it will be used as the recipient endpoint. The endpoint can
* be overridden by providing a URL here.
* @param {string} [options.mode] the message mode for sending this event.
* Possible values are "binary" and "structured". Default: structured
* @returns {Promise} Promise with an eventual response from the receiver
*/
send(event, { url, mode = "binary", ...httpOpts } = { url: undefined }) {
if (!url) { url = this.url; }
// @ts-ignore Property 'url' does not exist on type '{}'
httpOpts.url = url;
if (mode === "binary") {
// @ts-ignore Property 'url' is missing in type '{}' but required in type '{ url: URL; }'.
return this.binary.emit(httpOpts, event);
} else if (mode === "structured") {
// @ts-ignore Property 'url' is missing in type '{}' but required in type '{ url: URL; }'.
return this.structured.emit(httpOpts, event);
}
throw new TypeError(`Unknown transport mode ${mode}.`);
}
/**
* Returns the HTTP headers that will be sent for this event when the HTTP transmission
* mode is "binary". Events sent over HTTP in structured mode only have a single CE header
* and that is "ce-id", corresponding to the event ID.
* @param {CloudEvent} event a CloudEvent
* @returns {Object} the headers that will be sent for the event
*/
headers(event) {
const headers = {};
this.binary.headerParserMap.forEach((parser, getterName) => {
const value = event[getterName];
if (value) {
headers[parser.headerName] = parser.parse(value);
}
});
return headers;
}
}
module.exports = HTTPEmitter;
</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>

View File

@ -1,205 +0,0 @@
<!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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></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.js");
// const V03Structured = require("./v03/receiver_structured_0_3.js");
// const V1Binary = require("./receiver_binary_1.js");
// const V1Structured = require("./v1/receiver_structured_1.js");
const BinaryReceiver = require("./receiver_binary.js");
const StructuredReceiver = require("./receiver_structured.js");
const ValidationError = require("./validation/validation_error.js");
const {
BINARY,
STRUCTURED,
SPEC_V03,
SPEC_V1,
HEADER_CONTENT_TYPE,
MIME_CE,
BINARY_HEADERS_1,
DEFAULT_SPEC_VERSION_HEADER
} = require("./constants");
/** @typedef {import("../../cloudevent")} CloudEvent */
/**
* 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 StructuredReceiver(SPEC_V1),
binary: new BinaryReceiver(SPEC_V1)
},
v03: {
structured: new StructuredReceiver(SPEC_V03),
binary: new BinaryReceiver(SPEC_V03)
}
};
}
/**
* 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) {
const contentType = headers[HEADER_CONTENT_TYPE];
if (contentType &amp;&amp; contentType.startsWith(MIME_CE)) {
return STRUCTURED;
}
if (headers[BINARY_HEADERS_1.ID]) {
return BINARY;
}
throw new ValidationError("no cloud event detected");
}
function getVersion(mode, headers, body) {
if (mode === BINARY) {
// Check the headers for the version
const versionHeader = headers[DEFAULT_SPEC_VERSION_HEADER];
if (versionHeader) {
return versionHeader;
}
} else {
// structured mode - the version is in the body
return (typeof body === "string")
? JSON.parse(body).specversion : body.specversion;
}
return SPEC_V1;
}
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>

View File

@ -1,169 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
bindings/http/receiver_binary.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/receiver_binary.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const ReceiverV1 = require("./v1/receiver_binary_1.js");
const ReceiverV3 = require("./v03/receiver_binary_0_3.js");
const { SPEC_V03, SPEC_V1 } = require("./constants.js");
const { check, parse } = require("./validation/binary.js");
/** @typedef {import("../../cloudevent")} CloudEvent */
/**
* A class that receives binary CloudEvents over HTTP. This class can be used
* if you know that all incoming events will be using binary transport. If
* events can come as either binary or structured, use {HTTPReceiver}.
*/
class BinaryHTTPReceiver {
/**
* Creates a new BinaryHTTPReceiver to accept events over HTTP.
*
* @param {string} version the Cloud Event specification version to use. Default "1.0"
*/
constructor(version = SPEC_V1) {
if (version === SPEC_V1) {
this.receiver = new ReceiverV1();
} else if (version === SPEC_V03) {
this.receiver = new ReceiverV3();
}
}
/**
* Checks an incoming HTTP request to determine if it conforms to the
* Cloud Event specification for this receiver.
*
* @param {Object} payload the HTTP request body
* @param {Object} headers the HTTP request headers
* @returns {boolean} true if the the provided payload and headers conform to the spec
* @throws {ValidationError} if the event does not conform to the spec
*/
check(payload, headers) {
return check(payload, headers, this.receiver);
}
/**
* Parses an incoming HTTP request, converting it to a {CloudEvent}
* instance if it conforms to the Cloud Event specification for this receiver.
*
* @param {Object} payload the HTTP request body
* @param {Object} headers the HTTP request headers
* @returns {CloudEvent} an instance of CloudEvent representing the incoming request
* @throws {ValidationError} of the event does not conform to the spec
*/
parse(payload, headers) {
return parse(payload, headers, this.receiver);
}
}
module.exports = BinaryHTTPReceiver;
</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>

View File

@ -1,169 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
bindings/http/receiver_structured.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/receiver_structured.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const ReceiverV1 = require("./v1/receiver_structured_1.js");
const ReceiverV3 = require("./v03/receiver_structured_0_3.js");
const { SPEC_V03, SPEC_V1 } = require("./constants.js");
const { check, parse } = require("./validation/structured.js");
/** @typedef {import("../../cloudevent")} CloudEvent */
/**
* A utility class used to receive structured CloudEvents
* over HTTP.
* @see {StructuredReceiver}
*/
class StructuredHTTPReceiver {
/**
* Creates a new StructuredHTTPReceiver. Supports Cloud Events specification
* versions 0.3 and 1.0 (default).
*
* @param {string} version the Cloud Events specification version. Default: 1.0.
*/
constructor(version = SPEC_V1) {
if (version === SPEC_V1) {
this.receiver = new ReceiverV1();
} else if (version === SPEC_V03) {
this.receiver = new ReceiverV3();
}
}
/**
* Checks whether the provided payload and headers conform to the Cloud Events
* specification version supported by this instance.
*
* @param {object} payload the cloud event data payload
* @param {object} headers the HTTP headers received for this cloud event
* @returns {boolean} true if the payload and header combination are valid
* @throws {ValidationError} if the payload and header combination do not conform to the spec
*/
check(payload, headers) {
return check(payload, headers, this.receiver);
}
/**
* Creates a new CloudEvent instance based on the provided payload and headers.
*
* @param {object} payload the cloud event data payload
* @param {object} headers the HTTP headers received for this cloud event
* @returns {CloudEvent} a new CloudEvent instance for the provided headers and payload
* @throws {ValidationError} if the payload and header combination do not conform to the spec
*/
parse(payload, headers) {
return parse(payload, headers, this.receiver);
}
}
module.exports = StructuredHTTPReceiver;
</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>

View File

@ -1,149 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
bindings/http/v03/emitter_binary_0_3.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/v03/emitter_binary_0_3.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const {
HEADER_CONTENT_TYPE,
BINARY_HEADERS_03 : {
CONTENT_ENCODING,
SUBJECT,
TYPE,
SPEC_VERSION,
SOURCE,
ID,
TIME,
SCHEMA_URL
}
} = require("../constants.js");
function parser(header, parser = (v) => v) {
return { headerName: header, parse: parser };
}
const passThroughParser = parser;
/**
* A utility Map used to retrieve the header names for a CloudEvent
* using the CloudEvent getter function.
*/
const headerMap = new Map();
headerMap.set("dataContentType", passThroughParser(HEADER_CONTENT_TYPE));
headerMap.set("dataContentEncoding", passThroughParser(CONTENT_ENCODING));
headerMap.set("subject", passThroughParser(SUBJECT));
headerMap.set("type", passThroughParser(TYPE));
headerMap.set("specversion", passThroughParser(SPEC_VERSION));
headerMap.set("source", passThroughParser(SOURCE));
headerMap.set("id", passThroughParser(ID));
headerMap.set("time", passThroughParser(TIME));
headerMap.set("schemaURL", passThroughParser(SCHEMA_URL));
module.exports = headerMap;
</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>

View File

@ -1,147 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
bindings/http/v1/emitter_binary_1.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/v1/emitter_binary_1.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const {
HEADER_CONTENT_TYPE,
BINARY_HEADERS_1 : {
SUBJECT,
TYPE,
SPEC_VERSION,
SOURCE,
ID,
TIME,
DATA_SCHEMA
}
} = require("../constants.js");
function parser(header, parser = (v) => v) {
return { headerName: header, parse: parser };
}
const passThroughParser = parser;
/**
* A utility Map used to retrieve the header names for a CloudEvent
* using the CloudEvent getter function.
*/
const headerMap = new Map();
headerMap.set("dataContentType", passThroughParser(HEADER_CONTENT_TYPE));
headerMap.set("subject", passThroughParser(SUBJECT));
headerMap.set("type", passThroughParser(TYPE));
headerMap.set("specversion", passThroughParser(SPEC_VERSION));
headerMap.set("source", passThroughParser(SOURCE));
headerMap.set("id", passThroughParser(ID));
headerMap.set("time", passThroughParser(TIME));
headerMap.set("dataSchema", passThroughParser(DATA_SCHEMA));
module.exports = headerMap;
</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>

View File

@ -1,136 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
bindings/http/validation/validation_error.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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
bindings/http/validation/validation_error.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @ignore
* @typedef {import("ajv").ErrorObject} ErrorObject
* */
/**
* A Error class that will be thrown when a CloudEvent
* cannot be properly validated against a specification.
*/
class ValidationError extends TypeError {
/**
* Constructs a new {ValidationError} with the message
* and array of additional errors.
* @param {string} message the error message
* @param {string[]|ErrorObject[]} [errors] any additional errors related to validation
*/
constructor(message, errors) {
super(message);
this.errors = errors ? errors : [];
}
}
module.exports = ValidationError;</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>

View File

@ -1,432 +0,0 @@
<!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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
cloudevent.js
</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const Spec1 = require("./bindings/http/v1/spec_1.js");
const Spec03 = require("./bindings/http/v03/spec_0_3.js");
const Formatter = require("./formats/json/formatter.js");
const { SPEC_V1, SPEC_V03 } = require("./bindings/http/constants.js");
const { isBinary } = require("./bindings/http/validation/fun.js");
/**
* An CloudEvent describes event data in common formats to provide
* interopability across services, platforms and systems.
* @see https://github.com/cloudevents/spec/blob/v1.0/spec.md
*/
class CloudEvent {
/**
* Creates a new CloudEvent instance
* @param {object} options CloudEvent properties as a simple object
* @param {string} options.source Identifies the context in which an event happened as a URI reference
* @param {string} options.type Describes the type of event related to the originating occurrence
* @param {string} [options.id] A unique ID for this event - if not supplied, will be autogenerated
* @param {string} [options.time] A timestamp for this event. May also be provided as a Date
* @param {string} [options.subject] Describes the subject of the event in the context of the event producer
* @param {string} [options.dataContentType] The mime content type for the event data
* @param {string} [options.dataSchema] The URI of the schema that the event data adheres to (v1.0 events)
* @param {string} [options.schemaURL] The URI of the schema that the event data adheres to (v0.3 events)
* @param {string} [options.dataContentEncoding] The content encoding for the event data (v0.3 events)
* @param {string} [options.specversion] The CloudEvent specification version for this event - default: 1.0
* @param {*} [options.data] The event payload
*/
constructor({
id,
source,
type,
dataContentType,
time,
subject,
dataSchema,
schemaURL,
dataContentEncoding,
data,
specversion = SPEC_V1 } = {
id: undefined,
source: undefined,
type: undefined,
dataContentType: undefined,
time: undefined,
subject: undefined,
dataSchema: undefined,
schemaURL: undefined,
dataContentEncoding: undefined,
data: undefined
}) {
if (!type || !source) {
throw new TypeError("event type and source are required");
}
switch (specversion) {
case SPEC_V1:
this.spec = new Spec1();
break;
case SPEC_V03:
this.spec = new Spec03();
break;
default:
throw new TypeError(`unknown specification version ${specversion}`);
}
this.source = source;
this.type = type;
this.dataContentType = dataContentType;
this.data = data;
this.subject = subject;
if (dataSchema) {
this.dataSchema = dataSchema;
}
// TODO: Deprecated in 1.0
if (dataContentEncoding) {
this.dataContentEncoding = dataContentEncoding;
}
// TODO: Deprecated in 1.0
if (schemaURL) {
this.schemaURL = schemaURL;
}
if (id) {
this.id = id;
}
if (time) {
this.time = time;
}
this.formatter = new Formatter();
}
/**
* Gets or sets the event id. Source + id must be unique for each distinct event.
* @see https://github.com/cloudevents/spec/blob/master/spec.md#id
* @type {string}
*/
get id() {
return this.spec.id;
}
set id(id) {
this.spec.id = id;
}
/**
* Gets or sets the origination source of this event as a URI.
* @type {string}
* @see https://github.com/cloudevents/spec/blob/master/spec.md#source-1
*/
get source() {
return this.spec.source;
}
set source(source) {
this.spec.source = source;
}
/**
* Gets the CloudEvent specification version
* @type {string}
* @see https://github.com/cloudevents/spec/blob/master/spec.md#specversion
*/
get specversion() {
return this.spec.specversion;
}
/**
* Gets or sets the event type
* @type {string}
* @see https://github.com/cloudevents/spec/blob/master/spec.md#type
*/
get type() {
return this.spec.type;
}
set type(type) {
this.spec.type = type;
}
/**
* Gets or sets the content type of the data value for this event
* @type {string}
* @see https://github.com/cloudevents/spec/blob/master/spec.md#datacontenttype
*/
get dataContentType() {
return this.spec.dataContentType;
}
set dataContentType(contenttype) {
this.spec.dataContentType = contenttype;
}
/**
* Gets or sets the event's data schema
* @type {string}
* @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#dataschema
*/
get dataSchema() {
if (this.spec instanceof Spec1) {
return this.spec.dataSchema;
}
throw new TypeError("cannot get dataSchema from version 0.3 event");
}
set dataSchema(dataschema) {
if (this.spec instanceof Spec1) {
this.spec.dataSchema = dataschema;
} else {
throw new TypeError("cannot set dataSchema on version 0.3 event");
}
}
/**
* Gets or sets the event's data content encoding
* @type {string}
* @see https://github.com/cloudevents/spec/blob/v0.3/spec.md#datacontentencoding
*/
get dataContentEncoding() {
if (this.spec instanceof Spec03) {
return this.spec.dataContentEncoding;
}
throw new TypeError("cannot get dataContentEncoding from version 1.0 event");
}
set dataContentEncoding(dataContentEncoding) {
if (this.spec instanceof Spec03) {
this.spec.dataContentEncoding = dataContentEncoding;
} else {
throw new TypeError("cannot set dataContentEncoding on version 1.0 event");
}
}
/**
* Gets or sets the event subject
* @type {string}
* @see https://github.com/cloudevents/spec/blob/v1.0/spec.md#subject
*/
get subject() {
return this.spec.subject;
}
set subject(subject) {
this.spec.subject = subject;
}
/**
* Gets or sets the timestamp for this event as an ISO formatted date string
* @type {string}
* @see https://github.com/cloudevents/spec/blob/master/spec.md#time
*/
get time() {
return this.spec.time;
}
set time(time) {
this.spec.time = new Date(time).toISOString();
}
/**
* DEPRECATED: Gets or sets the schema URL for this event. Throws {TypeError}
* if this is a version 1.0 event.
* @type {string}
* @see https://github.com/cloudevents/spec/blob/v0.3/spec.md#schemaurl
*/
get schemaURL() {
if (this.spec instanceof Spec03) {
return this.spec.schemaURL;
}
throw new TypeError("cannot get schemaURL from version 1.0 event");
}
// TODO: Deprecated in 1.0
set schemaURL(schemaurl) {
if (schemaurl &amp;&amp; (this.spec instanceof Spec03)) {
this.spec.schemaURL = schemaurl;
} else if (schemaurl) {
throw new TypeError("cannot set schemaURL on version 1.0 event");
}
}
/**
* Gets or sets the data for this event
* @see https://github.com/cloudevents/spec/blob/master/spec.md#event-data
* @type {*}
*/
get data() {
return this.spec.data;
}
set data(data) {
this.spec.data = data;
}
/**
* 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
* @throws {ValidationError} if this event cannot be validated against the specification
*/
format() {
this.spec.check();
const payload = {
data: undefined,
data_base64: undefined,
...this.spec.payload
};
// Handle when is binary, creating the data_base64
if (isBinary(payload.data)) {
// TODO: The call to this.spec.data formats the binary data
// I think having a side effect like this is an anti-pattern.
// FIXIT
payload.data_base64 = this.spec.data;
delete payload.data;
} else {
delete payload.data_base64;
}
return this.formatter.format(payload);
}
/**
* Formats the CloudEvent as JSON. No specification validation is performed.
* @returns {string} the CloudEvent as a JSON string
*/
toString() {
return this.formatter.toString(this.spec.payload);
}
/**
* Adds an extension attribute to this CloudEvent
* @see https://github.com/cloudevents/spec/blob/master/spec.md#extension-context-attributes
* @param {string} key the name of the extension attribute
* @param {*} value the value of the extension attribute
* @returns {void}
*/
addExtension(key, value) {
this.spec.addExtension(key, value);
this.extensions = { [key]: value, ...this.extensions };
}
/**
* 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 {}
*/
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>

Binary file not shown.

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 116 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 118 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 120 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 114 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 120 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 117 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 116 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 120 KiB

View File

@ -1,148 +0,0 @@
<!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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></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("../../bindings/http/validation/fun.js");
const ValidationError = require("../../bindings/http/validation/validation_error.js");
const invalidPayloadTypeError = new ValidationError("invalid payload type, allowed are: string or object");
const nullOrUndefinedPayload = new ValidationError("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);
}
isDefinedOrThrow(payload, nullOrUndefinedPayload);
isStringOrObjectOrThrow(payload, invalidPayloadTypeError);
return asJSON(payload);
}
}
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>

View File

@ -1,325 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Global - 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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">
Global
</h1>
<section>
<header>
<h2>
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="headerMap">
<span class="type-signature">(constant) </span>headerMap<span class="type-signature"></span>
</h4>
<div class="description">
<p>A utility Map used to retrieve the header names for a CloudEvent
using the CloudEvent getter function.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="bindings_http_v03_emitter_binary_0_3.js.html">bindings/http/v03/emitter_binary_0_3.js</a>, <a href="bindings_http_v03_emitter_binary_0_3.js.html#line24">line 24</a>
</li>
</ul>
</dd>
</dl>
<h4 class="name" id="headerMap">
<span class="type-signature">(constant) </span>headerMap<span class="type-signature"></span>
</h4>
<div class="description">
<p>A utility Map used to retrieve the header names for a CloudEvent
using the CloudEvent getter function.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="bindings_http_v1_emitter_binary_1.js.html">bindings/http/v1/emitter_binary_1.js</a>, <a href="bindings_http_v1_emitter_binary_1.js.html#line23">line 23</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>

View File

@ -1,4 +0,0 @@
<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>

Before

Width:  |  Height:  |  Size: 199 B

View File

@ -1,4 +0,0 @@
<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>

Before

Width:  |  Height:  |  Size: 398 B

View File

@ -1,279 +0,0 @@
<!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="BinaryHTTPEmitter-nav"><a href="BinaryHTTPEmitter.html">BinaryHTTPEmitter</a><ul class='methods'><li data-type="method" id="BinaryHTTPEmitter-emit-nav"><a href="BinaryHTTPEmitter.html#emit">emit</a></li></ul></li><li id="BinaryHTTPReceiver-nav"><a href="BinaryHTTPReceiver.html">BinaryHTTPReceiver</a><ul class='methods'><li data-type="method" id="BinaryHTTPReceiver-check-nav"><a href="BinaryHTTPReceiver.html#check">check</a></li><li data-type="method" id="BinaryHTTPReceiver-parse-nav"><a href="BinaryHTTPReceiver.html#parse">parse</a></li></ul></li><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-format-nav"><a href="CloudEvent.html#format">format</a></li><li data-type="method" id="CloudEvent-getExtensions-nav"><a href="CloudEvent.html#getExtensions">getExtensions</a></li><li data-type="method" id="CloudEvent-toString-nav"><a href="CloudEvent.html#toString">toString</a></li></ul></li><li id="HTTPEmitter-nav"><a href="HTTPEmitter.html">HTTPEmitter</a><ul class='methods'><li data-type="method" id="HTTPEmitter-headers-nav"><a href="HTTPEmitter.html#headers">headers</a></li><li data-type="method" id="HTTPEmitter-send-nav"><a href="HTTPEmitter.html#send">send</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><li id="StructuredHTTPEmitter-nav"><a href="StructuredHTTPEmitter.html">StructuredHTTPEmitter</a><ul class='methods'><li data-type="method" id="StructuredHTTPEmitter-emit-nav"><a href="StructuredHTTPEmitter.html#emit">emit</a></li></ul></li><li id="StructuredHTTPReceiver-nav"><a href="StructuredHTTPReceiver.html">StructuredHTTPReceiver</a><ul class='methods'><li data-type="method" id="StructuredHTTPReceiver-check-nav"><a href="StructuredHTTPReceiver.html#check">check</a></li><li data-type="method" id="StructuredHTTPReceiver-parse-nav"><a href="StructuredHTTPReceiver.html#parse">parse</a></li></ul></li><li id="ValidationError-nav"><a href="ValidationError.html">ValidationError</a></li></ul><h3 id="global-nav">Global</h3><ul><li><a href="global.html#headerMap">headerMap</a></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&amp;utm_medium=referral&amp;utm_content=cloudevents/sdk-javascript&amp;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&amp;utm_medium=referral&amp;utm_content=cloudevents/sdk-javascript&amp;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(&quot;cloudevents-sdk&quot;);
// 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>To emit events, you'll need to decide whether the event should be sent in
binary or structured format, and determine what version of the CloudEvents
specification you want to send the event as.</p>
<p>By default, the <code>HTTPEmitter</code> will emit events over HTTP POST using the
1.0 specification, in binary mode. You can emit 0.3 events by providing
the specication version in the constructor to <code>HTTPEmitter</code>. To send
structured events, add that string as a parameter to <code>emitter.sent()</code>.</p>
<pre class="prettyprint source lang-js"><code>const { CloudEvent, HTTPEmitter } = require(&quot;cloudevents-sdk&quot;);
// With only an endpoint URL, this creates a v1 emitter
const v1Emitter = new HTTPEmitter({
url: &quot;https://cloudevents.io/example&quot;
});
const event = new CloudEvent({
type, source, data
});
// By default, the emitter will send binary events
v1Emitter.send(event).then((response) => {
// handle the response
}).catch(console.error);
// To send a structured event, just add that as an option
v1Emitter.send(event, { mode: &quot;structured&quot; })
.then((response) => {
// handle the response
}).catch(console.error);
// To send an event to an alternate URL, add that as an option
v1Emitter.send(event, { url: &quot;https://alternate.com/api&quot; })
.then((response) => {
// handle the response
}).catch(console.error);
// Sending a v0.3 event works the same, just let the emitter know when
// you create it that you are working with the 0.3 spec
const v03Emitter = new HTTPEmitter({
url: &quot;https://cloudevents.io/example&quot;,
version: &quot;0.3&quot;
});
// Again, the default is to send binary events
// To send a structured event or to an alternate URL, provide those
// as parameters in a options object as above
v3Emitter.send(event)
.then((response) => {
// handle the response
}).catch(console.error);
</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>

View File

@ -1,23 +0,0 @@
'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';
}
}
}
})();

View File

@ -1,91 +0,0 @@
'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;
}

View File

@ -1,27 +0,0 @@
@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;
}
}

View File

@ -1,900 +0,0 @@
* {
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;
}

View File

@ -1,111 +0,0 @@
/* 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;
}

View File

@ -1,138 +0,0 @@
/* 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 {
/* */ }

View File

@ -1,7 +1,7 @@
/* eslint-disable no-console */
const express = require("express");
const { HTTPReceiver } = require("../../");
const { HTTPReceiver } = require("../../src");
const app = express();
const receiver = new HTTPReceiver();

View File

@ -1,11 +0,0 @@
const CloudEvent = require("./lib/cloudevent.js");
const HTTPReceiver = require("./lib/bindings/http/http_receiver.js");
const HTTPEmitter = require("./lib/bindings/http/http_emitter.js");
const Constants = require("./lib/bindings/http/constants.js");
module.exports = {
CloudEvent,
HTTPReceiver,
HTTPEmitter,
Constants
};

250
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "cloudevents-sdk",
"version": "1.0.0",
"version": "2.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -318,6 +318,44 @@
"integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==",
"dev": true
},
"@paztis/typedoc": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@paztis/typedoc/-/typedoc-0.1.6.tgz",
"integrity": "sha512-C6ywLbqa81u0FV907QrUHxYbi6n4lJyD7vCcmpVXZvShTfALT8NmeLLhMaLuAd8h3kl4N/Kkr3MSJpeCFjy5yQ==",
"dev": true,
"requires": {
"@types/minimatch": "3.0.3",
"fs-extra": "^8.1.0",
"handlebars": "^4.7.2",
"highlight.js": "^9.18.0",
"lodash": "^4.17.15",
"marked": "^0.8.0",
"minimatch": "^3.0.0",
"progress": "^2.0.3",
"shelljs": "^0.8.3",
"typedoc-default-themes": "0.8.0-0"
},
"dependencies": {
"highlight.js": {
"version": "9.18.1",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.1.tgz",
"integrity": "sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg==",
"dev": true
},
"typedoc-default-themes": {
"version": "0.8.0-0",
"resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.8.0-0.tgz",
"integrity": "sha512-blFWppm5aKnaPOa1tpGO9MLu+njxq7P3rtkXK4QxJBNszA+Jg7x0b+Qx0liXU1acErur6r/iZdrwxp5DUFdSXw==",
"dev": true,
"requires": {
"backbone": "^1.4.0",
"jquery": "^3.4.1",
"lunr": "^2.3.8",
"underscore": "^1.9.1"
}
}
}
},
"@types/ajv": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/ajv/-/ajv-1.0.0.tgz",
@ -342,6 +380,12 @@
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
"dev": true
},
"@types/minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
},
"@types/minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.0.tgz",
@ -349,9 +393,9 @@
"dev": true
},
"@types/node": {
"version": "13.13.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.6.tgz",
"integrity": "sha512-zqRj8ugfROCjXCNbmPBe2mmQ0fJWP9lQaN519hwunOgpHgVykme4G6FW95++dyNFDvJUk4rtExkVkL0eciu5NA==",
"version": "13.13.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.9.tgz",
"integrity": "sha512-EPZBIGed5gNnfWCiwEIwTE2Jdg4813odnG8iNPMQGrqVxrI+wL68SPtPeCX+ZxGBaA6pKAVc6jaKgP/Q0QzfdQ==",
"dev": true
},
"@types/normalize-package-data": {
@ -540,6 +584,15 @@
"follow-redirects": "1.5.10"
}
},
"backbone": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/backbone/-/backbone-1.4.0.tgz",
"integrity": "sha512-RLmDrRXkVdouTg38jcgHhyQ/2zjg7a8E6sz2zxfz21Hh17xDJYUHBZimVIt5fUyS8vbfpeSmTL3gUjTEvUV3qQ==",
"dev": true,
"requires": {
"underscore": ">=1.8.3"
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
@ -552,12 +605,6 @@
"integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==",
"dev": true
},
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==",
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -624,15 +671,6 @@
"quick-lru": "^4.0.1"
}
},
"catharsis": {
"version": "0.8.11",
"resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.11.tgz",
"integrity": "sha512-a+xUyMV7hD1BrDQA/3iPV7oc+6W26BgVJO05PGEoatMyIuPScQKsde6i3YorWX1qs+AZjnJ18NqdKoCtKiNh1g==",
"dev": true,
"requires": {
"lodash": "^4.17.14"
}
},
"chai": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz",
@ -1518,12 +1556,6 @@
"integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
"dev": true
},
"entities": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.0.2.tgz",
"integrity": "sha512-dmD3AvJQBUjKpcNkoqr+x+IF0SdRtPz9Vk0uTy4yWqga9ibB6s4v++QFWNohjiUGoMlF552ZvNyXDxz5iW0qmw==",
"dev": true
},
"error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@ -1569,12 +1601,6 @@
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
"dev": true
},
"escape-string-regexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
"integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==",
"dev": true
},
"eslint": {
"version": "6.8.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz",
@ -2203,6 +2229,17 @@
"null-check": "^1.0.0"
}
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -3417,6 +3454,12 @@
"istanbul-lib-report": "^3.0.0"
}
},
"jquery": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz",
"integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==",
"dev": true
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@ -3433,54 +3476,6 @@
"esprima": "^4.0.0"
}
},
"js2xmlparser": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.1.tgz",
"integrity": "sha512-KrPTolcw6RocpYjdC7pL7v62e55q7qOMHvLX1UCLc5AAS8qeJ6nukarEJAF2KL2PZxlbGueEbINqZR2bDe/gUw==",
"dev": true,
"requires": {
"xmlcreate": "^2.0.3"
}
},
"jsdoc": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.4.tgz",
"integrity": "sha512-3G9d37VHv7MFdheviDCjUfQoIjdv4TC5zTTf5G9VODLtOnVS6La1eoYBDlbWfsRT3/Xo+j2MIqki2EV12BZfwA==",
"dev": true,
"requires": {
"@babel/parser": "^7.9.4",
"bluebird": "^3.7.2",
"catharsis": "^0.8.11",
"escape-string-regexp": "^2.0.0",
"js2xmlparser": "^4.0.1",
"klaw": "^3.0.0",
"markdown-it": "^10.0.0",
"markdown-it-anchor": "^5.2.7",
"marked": "^0.8.2",
"mkdirp": "^1.0.4",
"requizzle": "^0.2.3",
"strip-json-comments": "^3.1.0",
"taffydb": "2.6.2",
"underscore": "~1.10.2"
}
},
"jsdoc-fresh": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/jsdoc-fresh/-/jsdoc-fresh-1.0.2.tgz",
"integrity": "sha512-MXs+8QBaRw6Mzl9ofxKlIgG9Dh0cnpnjNRyo3vGBOVzIMi4Oqp0uyNeXGiayR8e2I5bvAKnaVLFreRlLd9ODlg==",
"dev": true,
"requires": {
"taffydb": "^2.7.3"
},
"dependencies": {
"taffydb": {
"version": "2.7.3",
"resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.7.3.tgz",
"integrity": "sha1-KtNxaWKUmPylvIQkMJbTzeDsOjQ=",
"dev": true
}
}
},
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@ -3519,6 +3514,15 @@
"minimist": "^1.2.5"
}
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
},
"jsonparse": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
@ -3541,15 +3545,6 @@
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
"dev": true
},
"klaw": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz",
"integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.9"
}
},
"levn": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
@ -3566,15 +3561,6 @@
"integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=",
"dev": true
},
"linkify-it": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz",
"integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==",
"dev": true,
"requires": {
"uc.micro": "^1.0.1"
}
},
"load-json-file": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
@ -3668,6 +3654,12 @@
"signal-exit": "^3.0.0"
}
},
"lunr": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.8.tgz",
"integrity": "sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg==",
"dev": true
},
"make-dir": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@ -3691,37 +3683,12 @@
"integrity": "sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g==",
"dev": true
},
"markdown-it": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz",
"integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"entities": "~2.0.0",
"linkify-it": "^2.0.0",
"mdurl": "^1.0.1",
"uc.micro": "^1.0.5"
}
},
"markdown-it-anchor": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz",
"integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==",
"dev": true
},
"marked": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.8.2.tgz",
"integrity": "sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw==",
"dev": true
},
"mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=",
"dev": true
},
"meow": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/meow/-/meow-7.0.1.tgz",
@ -3921,12 +3888,6 @@
}
}
},
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true
},
"mocha": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.2.tgz",
@ -4888,15 +4849,6 @@
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"dev": true
},
"requizzle": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz",
"integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==",
"dev": true,
"requires": {
"lodash": "^4.17.14"
}
},
"resolve": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
@ -5606,12 +5558,6 @@
}
}
},
"taffydb": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz",
"integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=",
"dev": true
},
"test-exclude": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",
@ -5750,12 +5696,6 @@
"integrity": "sha512-q2ktq4n/uLuNNShyayit+DTobV2ApPEo/6so68JaD5ojvc/6GClBipedB9zNWYxRSAlZXAe405Rlijzl6qDiSw==",
"dev": true
},
"uc.micro": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
"integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==",
"dev": true
},
"uglify-js": {
"version": "3.9.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.9.3.tgz",
@ -5778,6 +5718,12 @@
"integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=",
"dev": true
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true
},
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
@ -5926,12 +5872,6 @@
"typedarray-to-buffer": "^3.1.5"
}
},
"xmlcreate": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.3.tgz",
"integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ==",
"dev": true
},
"xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",

View File

@ -4,20 +4,23 @@
"description": "CloudEvents SDK for JavaScript",
"main": "index.js",
"scripts": {
"type-check": "tsc --noEmitOnError --emitDeclarationOnly",
"prelint": "npm run type-check",
"lint": "standardx index.js lib examples",
"watch": "tsc --project tsconfig.json --watch",
"build": "tsc --project tsconfig.json",
"prelint": "npm run build",
"lint": "standardx src examples",
"fix": "standardx --fix",
"pretest": "npm run lint",
"test": "mocha test/**/*.js",
"coverage": "nyc --reporter=lcov --reporter=text npm run test",
"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"
"generate-docs": "typedoc --tsconfig ./tsconfig.json src",
"release": "standard-version",
"prepublish": "npm run build"
},
"files": [
"lib",
"index.d.ts"
"index.js",
"index.d.ts",
"lib"
],
"standard-version": {
"types": [
@ -98,15 +101,14 @@
"uuid": "~8.0.0"
},
"devDependencies": {
"@paztis/typedoc": "^0.1.6",
"@types/ajv": "^1.0.0",
"@types/axios": "^0.14.0",
"@types/node": "^13.13.5",
"@types/node": "^13.13.9",
"chai": "~4.2.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"jsdoc": "^3.6.4",
"jsdoc-fresh": "^1.0.2",
"mocha": "~7.1.1",
"nock": "~12.0.3",
"nyc": "~15.0.0",

11
src/index.ts Normal file
View File

@ -0,0 +1,11 @@
import { CloudEvent } from "./lib/cloudevent";
import { HTTPReceiver } from "./lib/bindings/http/http_receiver";
import { HTTPEmitter } from "./lib/bindings/http/http_emitter";
const Constants = require("./lib/bindings/http/constants");
export = {
CloudEvent,
HTTPReceiver,
HTTPEmitter,
Constants
};

View File

@ -1,3 +1,5 @@
import { CloudEvent } from "../../cloudevent.js";
const BinaryHTTPEmitter = require("./emitter_binary.js");
const StructuredEmitter = require("./emitter_structured.js");
const EmitterV1 = require("./v1").BinaryEmitter;
@ -17,7 +19,12 @@ const {
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md
* @see https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md#13-content-modes
*/
class HTTPEmitter {
export class HTTPEmitter {
url: URL | undefined;
binary: any;
structured: any;
static headers: Function;
/**
* Creates a new instance of {HTTPEmitter}. The default emitter uses the 1.0
* protocol specification in binary mode.
@ -55,7 +62,8 @@ class HTTPEmitter {
* Possible values are "binary" and "structured". Default: structured
* @returns {Promise} Promise with an eventual response from the receiver
*/
send(event, { url, mode = "binary", ...httpOpts } = { url: undefined }) {
send(event: CloudEvent, { url, mode = "binary", ...httpOpts } = { url: undefined }) {
// @ts-ignore Type 'URL | undefined' is not assignable to type 'undefined'. Type 'URL' is not assignable to type 'undefined'.ts(2322)
if (!url) { url = this.url; }
// @ts-ignore Property 'url' does not exist on type '{}'
httpOpts.url = url;
@ -63,7 +71,6 @@ class HTTPEmitter {
// @ts-ignore Property 'url' is missing in type '{}' but required in type '{ url: URL; }'.
return this.binary.emit(httpOpts, event);
} else if (mode === "structured") {
// @ts-ignore Property 'url' is missing in type '{}' but required in type '{ url: URL; }'.
return this.structured.emit(httpOpts, event);
}
throw new TypeError(`Unknown transport mode ${mode}.`);
@ -78,7 +85,7 @@ class HTTPEmitter {
* @param {string} [version] spec version number - default 1.0
* @returns {Object} the headers that will be sent for the event
*/
function headers(event, version = SPEC_V1) {
function headers(event: CloudEvent, version = SPEC_V1) {
const headers = {};
let headerMap;
if (version === SPEC_V1) {
@ -86,9 +93,12 @@ function headers(event, version = SPEC_V1) {
} else if (version === SPEC_V03) {
headerMap = EmitterV03;
}
headerMap.forEach((parser, getterName) => {
headerMap.forEach((parser: any, getterName: string) => {
// @ts-ignore No index signature with a parameter of type 'string' was found on type 'CloudEvent'.
const value = event[getterName];
if (value) {
// @ts-ignore Element implicitly has an 'any' type because expression of type 'any'
// can't be used to index type '{ } '.
headers[parser.headerName] = parser.parse(value);
}
});
@ -97,4 +107,3 @@ function headers(event, version = SPEC_V1) {
}
HTTPEmitter.headers = headers;
module.exports = HTTPEmitter;

View File

@ -1,27 +1,26 @@
// const V03Binary = require("./receiver_binary_0_3.js");
// const V03Structured = require("./v03/receiver_structured_0_3.js");
// const V1Binary = require("./receiver_binary_1.js");
// const V1Structured = require("./v1/receiver_structured_1.js");
const BinaryReceiver = require("./receiver_binary.js");
const StructuredReceiver = require("./receiver_structured.js");
const ValidationError = require("./validation/validation_error.js");
const {
BINARY,
STRUCTURED,
SPEC_V03,
SPEC_V1,
HEADER_CONTENT_TYPE,
MIME_CE,
BINARY_HEADERS_1,
DEFAULT_SPEC_VERSION_HEADER
} = require("./constants");
import BinaryReceiver = require("./receiver_binary.js");
import StructuredReceiver = require("./receiver_structured.js");
import ValidationError = require("./validation/validation_error.js");
const { BINARY, STRUCTURED, SPEC_V03, SPEC_V1, HEADER_CONTENT_TYPE, MIME_CE, BINARY_HEADERS_1, DEFAULT_SPEC_VERSION_HEADER } = require("./constants");
/** @typedef {import("../../cloudevent")} CloudEvent */
/**
* A class to receive a CloudEvent from an HTTP POST request.
*/
class HTTPReceiver {
export class HTTPReceiver {
receivers: {
v1: {
structured: any,
binary: any,
[key: string]: any
},
v03: {
structured: any,
binary: any,
[key: string]: any
}
};
/**
* Create an instance of an HTTPReceiver to accept incoming CloudEvents.
*/
@ -37,7 +36,6 @@ class HTTPReceiver {
}
};
}
/**
* Acceptor for an incoming HTTP CloudEvent POST. Can process
* binary and structured incoming CloudEvents.
@ -46,8 +44,8 @@ class HTTPReceiver {
* @param {Object|JSON} body The body of the HTTP request
* @return {CloudEvent} A new {CloudEvent} instance
*/
accept(headers, body) {
const mode = getMode(headers);
accept(headers: {}, body: { specversion: string }) {
const mode: string = getMode(headers);
const version = getVersion(mode, headers, body);
switch (version) {
case SPEC_V1:
@ -55,14 +53,13 @@ class HTTPReceiver {
case SPEC_V03:
return this.receivers.v03[mode].parse(body, headers);
default:
console.error(
`Unknown spec version ${version}. Default to ${SPEC_V1}`);
console.error(`Unknown spec version ${version}. Default to ${SPEC_V1}`);
return this.receivers.v1[mode].parse(body, headers);
}
}
}
function getMode(headers) {
function getMode(headers: { [key: string]: string }) {
const contentType = headers[HEADER_CONTENT_TYPE];
if (contentType && contentType.startsWith(MIME_CE)) {
return STRUCTURED;
@ -73,19 +70,18 @@ function getMode(headers) {
throw new ValidationError("no cloud event detected");
}
function getVersion(mode, headers, body) {
function getVersion(mode: string, headers: { [key: string]: string }, body: string | { specversion: string }) {
if (mode === BINARY) {
// Check the headers for the version
const versionHeader = headers[DEFAULT_SPEC_VERSION_HEADER];
if (versionHeader) {
return versionHeader;
}
} else {
}
else {
// structured mode - the version is in the body
return (typeof body === "string")
? JSON.parse(body).specversion : body.specversion;
}
return SPEC_V1;
}
module.exports = HTTPReceiver;

View File

@ -5,7 +5,7 @@ const {
ENCODING_BASE64,
BINARY_HEADERS_1,
HEADER_CONTENT_TYPE
} = require("../constants.js");
} = require("../constants");
const Spec = require("./spec_1.js");
const JSONParser = require("../../../formats/json/parser.js");

View File

@ -1,4 +1,4 @@
const CloudEvent = require("../../../cloudevent.js");
const { CloudEvent } = require("../../../cloudevent");
const {
sanityAndClone,

View File

@ -1,4 +1,4 @@
const CloudEvent = require("../../../cloudevent.js");
const { CloudEvent } = require("../../../cloudevent");
const ValidationError = require("./validation_error.js");
const {
sanityAndClone,

View File

@ -1,95 +1,84 @@
const Spec1 = require("./bindings/http/v1/spec_1.js");
const Spec03 = require("./bindings/http/v03/spec_0_3.js");
const Formatter = require("./formats/json/formatter.js");
import { CloudEventV1, CloudEventV1Attributes } from "./v1";
import { CloudEventV03, CloudEventV03Attributes } from "./v03";
import Spec1 from "./bindings/http/v1/spec_1.js";
import Spec03 from "./bindings/http/v03/spec_0_3.js";
import Formatter from "./formats/json/formatter.js";
import { isBinary } from "./bindings/http/validation/fun.js";
const { SPEC_V1, SPEC_V03 } = require("./bindings/http/constants.js");
const { isBinary } = require("./bindings/http/validation/fun.js");
export type CE = CloudEventV1 | CloudEventV1Attributes | CloudEventV03 | CloudEventV03Attributes
/**
* An CloudEvent describes event data in common formats to provide
* A CloudEvent describes event data in common formats to provide
* interoperability across services, platforms and systems.
* @see https://github.com/cloudevents/spec/blob/v1.0/spec.md
*/
class CloudEvent {
export class CloudEvent {
spec: any;
formatter: any;
extensions: {};
/**
* Creates a new CloudEvent instance
* @param {object} options CloudEvent properties as a simple object
* @param {string} options.source Identifies the context in which an event happened as a URI reference
* @param {string} options.type Describes the type of event related to the originating occurrence
* @param {string} [options.id] A unique ID for this event - if not supplied, will be autogenerated
* @param {string} [options.time] A timestamp for this event. May also be provided as a Date
* @param {string} [options.subject] Describes the subject of the event in the context of the event producer
* @param {string} [options.dataContentType] The mime content type for the event data
* @param {string} [options.dataSchema] The URI of the schema that the event data adheres to (v1.0 events)
* @param {string} [options.schemaURL] The URI of the schema that the event data adheres to (v0.3 events)
* @param {string} [options.dataContentEncoding] The content encoding for the event data (v0.3 events)
* @param {string} [options.specversion] The CloudEvent specification version for this event - default: 1.0
* @param {*} [options.data] The event payload
* @param {object} event CloudEvent properties as a simple object
* @param {string} event.source Identifies the context in which an event happened as a URI reference
* @param {string} event.type Describes the type of event related to the originating occurrence
* @param {string} [event.id] A unique ID for this event - if not supplied, will be autogenerated
* @param {string} [event.time] A timestamp for this event. May also be provided as a Date
* @param {string} [event.subject] Describes the subject of the event in the context of the event producer
* @param {string} [event.dataContentType] The mime content type for the event data
* @param {string} [event.dataSchema] The URI of the schema that the event data adheres to (v1.0 events)
* @param {string} [event.schemaURL] The URI of the schema that the event data adheres to (v0.3 events)
* @param {string} [event.dataContentEncoding] The content encoding for the event data (v0.3 events)
* @param {string} [event.specversion] The CloudEvent specification version for this event - default: 1.0
* @param {*} [event.data] The event payload
*/
constructor({
id,
source,
type,
dataContentType,
time,
subject,
dataSchema,
schemaURL,
dataContentEncoding,
data,
specversion = SPEC_V1 } = {
id: undefined,
source: undefined,
type: undefined,
dataContentType: undefined,
time: undefined,
subject: undefined,
dataSchema: undefined,
schemaURL: undefined,
dataContentEncoding: undefined,
data: undefined
}) {
if (!type || !source) {
constructor(event: CE) {
if (!event || !event.type || !event.source) {
throw new TypeError("event type and source are required");
}
switch (specversion) {
switch (event.specversion) {
case SPEC_V1:
this.spec = new Spec1();
break;
case SPEC_V03:
this.spec = new Spec03();
break;
case undefined:
this.spec = new Spec1();
break;
default:
throw new TypeError(`unknown specification version ${specversion}`);
throw new TypeError(`unknown specification version ${event.specversion}`);
}
this.source = source;
this.type = type;
this.dataContentType = dataContentType;
this.data = data;
this.subject = subject;
this.source = event.source;
this.type = event.type;
this.dataContentType = event.dataContentType;
this.data = event.data;
this.subject = event.subject;
if (dataSchema) {
this.dataSchema = dataSchema;
if (event.dataSchema) {
this.dataSchema = event.dataSchema;
}
// TODO: Deprecated in 1.0
if (dataContentEncoding) {
this.dataContentEncoding = dataContentEncoding;
if (event.dataContentEncoding) {
this.dataContentEncoding = event.dataContentEncoding;
}
// TODO: Deprecated in 1.0
if (schemaURL) {
this.schemaURL = schemaURL;
if (event.schemaURL) {
this.schemaURL = event.schemaURL;
}
if (id) {
this.id = id;
if (event.id) {
this.id = event.id;
}
if (time) {
this.time = time;
if (event.time) {
this.time = event.time;
}
this.formatter = new Formatter();
this.extensions = [];
@ -301,7 +290,7 @@ class CloudEvent {
* @param {*} value the value of the extension attribute
* @returns {void}
*/
addExtension(key, value) {
addExtension(key: string, value: any) {
this.spec.addExtension(key, value);
this.extensions = { [key]: value, ...this.extensions };
}
@ -315,5 +304,3 @@ class CloudEvent {
return this.extensions;
}
}
module.exports = CloudEvent;

135
src/lib/v03/index.ts Normal file
View File

@ -0,0 +1,135 @@
/**
* The object interface for CloudEvents 0.3.
* @see https://github.com/cloudevents/spec/blob/v0.3/spec.md
*/
export interface CloudEventV03 extends CloudEventV03Attributes {
// REQUIRED Attributes
/**
* [REQUIRED] Identifies the event. Producers MUST ensure that `source` + `id`
* is unique for each distinct event. If a duplicate event is re-sent (e.g. due
* to a network error) it MAY have the same `id`. Consumers MAY assume that
* Events with identical `source` and `id` are duplicates.
* @required Non-empty string. Unique within producer.
* @example An event counter maintained by the producer
* @example A UUID
*/
id: string;
/**
* [REQUIRED] The version of the CloudEvents specification which the event
* uses. This enables the interpretation of the context. Compliant event
* producers MUST use a value of `1.0` when referring to this version of the
* specification.
* @required MUST be a non-empty string.
*/
specversion: string;
}
export interface CloudEventV03Attributes {
/**
* [REQUIRED] Identifies the context in which an event happened. Often this
* will include information such as the type of the event source, the
* organization publishing the event or the process that produced the event. The
* exact syntax and semantics behind the data encoded in the URI is defined by
* the event producer.
* Producers MUST ensure that `source` + `id` is unique for each distinct event.
* An application MAY assign a unique `source` to each distinct producer, which
* makes it easy to produce unique IDs since no other producer will have the same
* source. The application MAY use UUIDs, URNs, DNS authorities or an
* application-specific scheme to create unique `source` identifiers.
* A source MAY include more than one producer. In that case the producers MUST
* collaborate to ensure that `source` + `id` is unique for each distinct event.
* @required Non-empty URI-reference
*/
source: string;
/**
* [REQUIRED] This attribute contains a value describing the type of event
* related to the originating occurrence. Often this attribute is used for
* routing, observability, policy enforcement, etc. The format of this is
* producer defined and might include information such as the version of the
* `type` - see
* [Versioning of Attributes in the Primer](primer.md#versioning-of-attributes)
* for more information.
* @required MUST be a non-empty string
* @should SHOULD be prefixed with a reverse-DNS name. The prefixed domain dictates the
* organization which defines the semantics of this event type.
* @example com.github.pull.create
* @example com.example.object.delete.v2
*/
type: string;
/**
* The following fields are optional.
*/
/**
* [OPTIONAL] Describes the content encoding for the data attribute for when the
* data field MUST be encoded as a string, like with structured transport binding
* modes using the JSON event format, but the datacontenttype indicates a non-string
* media type. When the data field's effective data type is not String, this attribute
* MUST NOT be set and MUST be ignored when set.
*/
dataContentEncoding?: string;
/**
* [OPTIONAL] Content type of `data` value. This attribute enables `data` to
* carry any type of content, whereby format and encoding might differ from that
* of the chosen event format. For example, an event rendered using the
* [JSON envelope](./json-format.md#3-envelope) format might carry an XML payload
* in `data`, and the consumer is informed by this attribute being set to
* "application/xml". The rules for how `data` content is rendered for different
* `datacontenttype` values are defined in the event format specifications; for
* example, the JSON event format defines the relationship in
* [section 3.1](./json-format.md#31-handling-of-data).
*/
dataContentType?: string;
/**
* [OPTIONAL] A link to the schema that the data attribute adheres to.
* Incompatible changes to the schema SHOULD be reflected by a different URL.
* If present, MUST be a non-empty URI.
*/
schemaURL?: string;
/**
* [OPTIONAL] This describes the subject of the event in the context of the
* event producer (identified by `source`). In publish-subscribe scenarios, a
* subscriber will typically subscribe to events emitted by a `source`, but the
* `source` identifier alone might not be sufficient as a qualifier for any
* specific event if the `source` context has internal sub-structure.
*
* Identifying the subject of the event in context metadata (opposed to only in
* the `data` payload) is particularly helpful in generic subscription filtering
* scenarios where middleware is unable to interpret the `data` content. In the
* above example, the subscriber might only be interested in blobs with names
* ending with '.jpg' or '.jpeg' and the `subject` attribute allows for
* constructing a simple and efficient string-suffix filter for that subset of
* events.
*
* If present, MUST be a non-empty string.
* @example "https://example.com/storage/tenant/container"
* @example "mynewfile.jpg"
*/
subject?: string;
/**
* [OPTIONAL] Timestamp of when the occurrence happened. If the time of the
* occurrence cannot be determined then this attribute MAY be set to some other
* time (such as the current time) by the CloudEvents producer, however all
* producers for the same `source` MUST be consistent in this respect. In other
* words, either they all use the actual time of the occurrence or they all use
* the same algorithm to determine the value used.
* @example "2020-08-08T14:48:09.769Z"
*/
time?: Date | string;
/**
* [OPTIONAL] The event payload. This specification does not place any restriction
* on the type of this information. It is encoded into a media format which is
* specified by the datacontenttype attribute (e.g. application/json), and adheres
* to the dataschema format when those respective attributes are present.
*/
// tslint:disable-next-line:no-any
data?: any | string | number | boolean | null;
/**
* [OPTIONAL] CloudEvents extension attributes.
*/
// tslint:disable-next-line:no-any
[key: string]: any;
}

129
src/lib/v1/index.ts Normal file
View File

@ -0,0 +1,129 @@
/**
* The object interface for CloudEvents 1.0.
* @see https://github.com/cloudevents/spec/blob/v1.0/spec.md
*/
export interface CloudEventV1 extends CloudEventV1Attributes {
// REQUIRED Attributes
/**
* [REQUIRED] Identifies the event. Producers MUST ensure that `source` + `id`
* is unique for each distinct event. If a duplicate event is re-sent (e.g. due
* to a network error) it MAY have the same `id`. Consumers MAY assume that
* Events with identical `source` and `id` are duplicates.
* @required Non-empty string. Unique within producer.
* @example An event counter maintained by the producer
* @example A UUID
*/
id: string;
/**
* [REQUIRED] The version of the CloudEvents specification which the event
* uses. This enables the interpretation of the context. Compliant event
* producers MUST use a value of `1.0` when referring to this version of the
* specification.
* @required MUST be a non-empty string.
*/
specversion: string;
}
export interface CloudEventV1Attributes {
/**
* [REQUIRED] Identifies the context in which an event happened. Often this
* will include information such as the type of the event source, the
* organization publishing the event or the process that produced the event. The
* exact syntax and semantics behind the data encoded in the URI is defined by
* the event producer.
* Producers MUST ensure that `source` + `id` is unique for each distinct event.
* An application MAY assign a unique `source` to each distinct producer, which
* makes it easy to produce unique IDs since no other producer will have the same
* source. The application MAY use UUIDs, URNs, DNS authorities or an
* application-specific scheme to create unique `source` identifiers.
* A source MAY include more than one producer. In that case the producers MUST
* collaborate to ensure that `source` + `id` is unique for each distinct event.
* @required Non-empty URI-reference
*/
source: string;
/**
* [REQUIRED] This attribute contains a value describing the type of event
* related to the originating occurrence. Often this attribute is used for
* routing, observability, policy enforcement, etc. The format of this is
* producer defined and might include information such as the version of the
* `type` - see
* [Versioning of Attributes in the Primer](primer.md#versioning-of-attributes)
* for more information.
* @required MUST be a non-empty string
* @should SHOULD be prefixed with a reverse-DNS name. The prefixed domain dictates the
* organization which defines the semantics of this event type.
* @example com.github.pull.create
* @example com.example.object.delete.v2
*/
type: string;
/**
* The following fields are optional.
*/
/**
* [OPTIONAL] Content type of `data` value. This attribute enables `data` to
* carry any type of content, whereby format and encoding might differ from that
* of the chosen event format. For example, an event rendered using the
* [JSON envelope](./json-format.md#3-envelope) format might carry an XML payload
* in `data`, and the consumer is informed by this attribute being set to
* "application/xml". The rules for how `data` content is rendered for different
* `datacontenttype` values are defined in the event format specifications; for
* example, the JSON event format defines the relationship in
* [section 3.1](./json-format.md#31-handling-of-data).
*/
dataContentType?: string;
/**
* [OPTIONAL] Identifies the schema that `data` adheres to. Incompatible
* changes to the schema SHOULD be reflected by a different URI. See
* [Versioning of Attributes in the Primer](primer.md#versioning-of-attributes)
* for more information.
* If present, MUST be a non-empty URI.
*/
dataSchema?: string;
/**
* [OPTIONAL] This describes the subject of the event in the context of the
* event producer (identified by `source`). In publish-subscribe scenarios, a
* subscriber will typically subscribe to events emitted by a `source`, but the
* `source` identifier alone might not be sufficient as a qualifier for any
* specific event if the `source` context has internal sub-structure.
*
* Identifying the subject of the event in context metadata (opposed to only in
* the `data` payload) is particularly helpful in generic subscription filtering
* scenarios where middleware is unable to interpret the `data` content. In the
* above example, the subscriber might only be interested in blobs with names
* ending with '.jpg' or '.jpeg' and the `subject` attribute allows for
* constructing a simple and efficient string-suffix filter for that subset of
* events.
*
* If present, MUST be a non-empty string.
* @example "https://example.com/storage/tenant/container"
* @example "mynewfile.jpg"
*/
subject?: string;
/**
* [OPTIONAL] Timestamp of when the occurrence happened. If the time of the
* occurrence cannot be determined then this attribute MAY be set to some other
* time (such as the current time) by the CloudEvents producer, however all
* producers for the same `source` MUST be consistent in this respect. In other
* words, either they all use the actual time of the occurrence or they all use
* the same algorithm to determine the value used.
* @example "2020-08-08T14:48:09.769Z"
*/
time?: Date | string;
/**
* [OPTIONAL] The event payload. This specification does not place any restriction
* on the type of this information. It is encoded into a media format which is
* specified by the datacontenttype attribute (e.g. application/json), and adheres
* to the dataschema format when those respective attributes are present.
*/
// tslint:disable-next-line:no-any
data?: any | string | number | boolean | null;
/**
* [OPTIONAL] CloudEvents extension attributes.
*/
// tslint:disable-next-line:no-any
[key: string]: any;
}

View File

@ -1,6 +1,6 @@
const expect = require("chai").expect;
const CloudEvent = require("../../../lib/cloudevent.js");
const { CloudEvent } = require("../../../lib/cloudevent.js");
const BinaryHTTPReceiver = require("../../../lib/bindings/http/receiver_binary.js");
const ValidationError = require("../../../lib/bindings/http/validation/validation_error.js");
const {

View File

@ -6,7 +6,7 @@ const {
HEADER_CONTENT_TYPE
} = require("../../../lib/bindings/http/constants.js");
const ValidationError = require("../../../lib/bindings/http/validation/validation_error.js");
const CloudEvent = require("../../../lib/cloudevent.js");
const { CloudEvent } = require("../../../lib/cloudevent.js");
const BinaryHTTPReceiver = require("../../../lib/bindings/http/receiver_binary.js");
const receiver = new BinaryHTTPReceiver(SPEC_V1);

View File

@ -1,7 +1,7 @@
const expect = require("chai").expect;
const ValidationError = require("../../../lib/bindings/http/validation/validation_error.js");
const HTTPStructuredReceiver = require("../../../lib/bindings/http/receiver_structured.js");
const CloudEvent = require("../../../lib/cloudevent.js");
const { CloudEvent } = require("../../../index.js");
const { SPEC_V03 } = require("../../../lib/bindings/http/constants.js");
const receiver = new HTTPStructuredReceiver(SPEC_V03);

View File

@ -1,4 +1,4 @@
const CloudEvent = require("../lib/cloudevent.js");
const { CloudEvent } = require("../");
const { SPEC_V1, SPEC_V03 } = require("../lib/bindings/http/constants.js");
const { expect } = require("chai");

View File

@ -2,7 +2,7 @@ const expect = require("chai").expect;
const nock = require("nock");
const BinaryHTTPEmitter = require("../lib/bindings/http/emitter_binary.js");
const StructuredHTTPEmitter = require("../lib/bindings/http/emitter_structured.js");
const CloudEvent = require("../lib/cloudevent.js");
const { CloudEvent } = require("../");
const {
SPEC_V03
} = require("../lib/bindings/http/constants.js");

View File

@ -3,7 +3,7 @@ const nock = require("nock");
const https = require("https");
const { asBase64 } = require("../lib/bindings/http/validation/fun.js");
const { SPEC_V1 } = require("../lib/bindings/http/constants.js");
const CloudEvent = require("../lib/cloudevent.js");
const { CloudEvent } = require("../");
const BinaryHTTPEmitter = require("../lib/bindings/http/emitter_binary.js");
const StructuredHTTPEmitter = require("../lib/bindings/http/emitter_structured.js");
const type = "com.github.pull.create";

View File

@ -1,7 +1,6 @@
const expect = require("chai").expect;
const { CloudEvent, HTTPReceiver, HTTPEmitter } = require("../");
const SpecV03 = require("../lib/bindings/http/v03").Spec;
const SpecV1 = require("../lib/bindings/http/v1").Spec;
const {
SPEC_V03,
SPEC_V1

View File

@ -1,5 +1,4 @@
const expect = require("chai").expect;
const Spec03 = require("../lib/bindings/http/v03/spec_0_3.js");
const { CloudEvent } = require("../index.js");
const {
MIME_JSON,

View File

@ -3,14 +3,22 @@
"target": "ES2016", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": true, /* Report errors in .js files. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"strict": false, /* Enable all strict type-checking options. */
"checkJs": false, /* Report errors in .js files. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true,
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"outDir": "./",
"declaration": true
},
"files": [
"index.js"
]
"compileOnSave": true,
"include": [
"src/**/*.ts"
],
"exclude": [],
"typedocOptions": {
"out": "docs",
"mode": "library"
}
}