arvo-core 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -22,6 +22,7 @@ import { ArvoEventData, CloudEventExtension, CreateArvoEvent } from './types';
|
|
22
22
|
* - If no `datacontenttype` is provided, it defaults to `application/cloudevents+json;charset=UTF-8;profile=arvo`.
|
23
23
|
* - If a non-compatible `datacontenttype` is provided, a warning will be logged to the span.
|
24
24
|
* - The `source`, `subject`, `to`, `redirectto`, and `dataschema` fields are URI-encoded.
|
25
|
+
* - If no `to` (null, undefined or empty string) is provided, then the `type` value is used by default
|
25
26
|
*
|
26
27
|
* @example
|
27
28
|
* const event = createArvoEvent(
|
@@ -31,7 +32,7 @@ import { ArvoEventData, CloudEventExtension, CreateArvoEvent } from './types';
|
|
31
32
|
* subject: 'example-subject',
|
32
33
|
* data: { key: 'value' }
|
33
34
|
* },
|
34
|
-
* {
|
35
|
+
* { customextension: 'value' },
|
35
36
|
* );
|
36
37
|
*/
|
37
38
|
export declare const createArvoEvent: <TData extends ArvoEventData, TExtension extends CloudEventExtension, TType extends string>(event: CreateArvoEvent<TData, TType>, extensions?: TExtension) => ArvoEvent<TData, TExtension, TType>;
|
@@ -32,6 +32,7 @@ var uuid_1 = require("uuid");
|
|
32
32
|
* - If no `datacontenttype` is provided, it defaults to `application/cloudevents+json;charset=UTF-8;profile=arvo`.
|
33
33
|
* - If a non-compatible `datacontenttype` is provided, a warning will be logged to the span.
|
34
34
|
* - The `source`, `subject`, `to`, `redirectto`, and `dataschema` fields are URI-encoded.
|
35
|
+
* - If no `to` (null, undefined or empty string) is provided, then the `type` value is used by default
|
35
36
|
*
|
36
37
|
* @example
|
37
38
|
* const event = createArvoEvent(
|
@@ -41,7 +42,7 @@ var uuid_1 = require("uuid");
|
|
41
42
|
* subject: 'example-subject',
|
42
43
|
* data: { key: 'value' }
|
43
44
|
* },
|
44
|
-
* {
|
45
|
+
* { customextension: 'value' },
|
45
46
|
* );
|
46
47
|
*/
|
47
48
|
var createArvoEvent = function (event, extensions) {
|
@@ -70,7 +71,7 @@ var createArvoEvent = function (event, extensions) {
|
|
70
71
|
time: (_h = event.time) !== null && _h !== void 0 ? _h : (0, utils_1.createTimestamp)(),
|
71
72
|
source: encodeURI(event.source),
|
72
73
|
subject: encodeURI(event.subject),
|
73
|
-
to: event.to ? encodeURI(event.to) :
|
74
|
+
to: event.to ? encodeURI(event.to) : encodeURI(event.type),
|
74
75
|
redirectto: event.redirectto ? encodeURI(event.redirectto) : null,
|
75
76
|
dataschema: event.dataschema ? encodeURI(event.dataschema) : null,
|
76
77
|
}, event.data, extensions);
|