arvo-core 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/ArvoContract/index.d.ts +3 -3
- package/dist/ArvoContract/index.js +3 -3
- package/dist/ArvoEvent/helpers.d.ts +2 -1
- package/dist/ArvoEvent/helpers.js +1 -0
- package/dist/ArvoEvent/index.d.ts +5 -4
- package/dist/ArvoEvent/index.js +1 -0
- package/dist/ArvoEvent/types.d.ts +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -33,13 +33,13 @@ export default class ArvoContract<T extends string = string, TAccepts extends Ar
|
|
33
33
|
get uri(): T;
|
34
34
|
/**
|
35
35
|
* Gets the accepted record type and schema.
|
36
|
-
* @returns {
|
36
|
+
* @returns {TAccepts} The frozen accepts object.
|
37
37
|
*/
|
38
38
|
get accepts(): TAccepts;
|
39
39
|
/**
|
40
40
|
* Gets all emitted event types and schemas as a readonly record.
|
41
41
|
* Use this when you need to access all emitted events at once.
|
42
|
-
* @returns {
|
42
|
+
* @returns {Record<ExtractEventType<TEmits>, TEmits>} A frozen record of all emitted events.
|
43
43
|
*/
|
44
44
|
get emits(): Record<ExtractEventType<TEmits>, TEmits>;
|
45
45
|
/**
|
@@ -47,7 +47,7 @@ export default class ArvoContract<T extends string = string, TAccepts extends Ar
|
|
47
47
|
* Use this when you need to access a single emitted event by its type.
|
48
48
|
* @template U - The type of the emit record to retrieve.
|
49
49
|
* @param {U} type - The type of the emit record.
|
50
|
-
* @returns {
|
50
|
+
* @returns {Extract<TEmits, { type: U }>} The emit record.
|
51
51
|
* @throws {Error} If the emit type is not found in the contract.
|
52
52
|
*/
|
53
53
|
getEmit<U extends ExtractEventType<TEmits>>(type: U): Extract<TEmits, {
|
@@ -37,7 +37,7 @@ var ArvoContract = /** @class */ (function () {
|
|
37
37
|
Object.defineProperty(ArvoContract.prototype, "accepts", {
|
38
38
|
/**
|
39
39
|
* Gets the accepted record type and schema.
|
40
|
-
* @returns {
|
40
|
+
* @returns {TAccepts} The frozen accepts object.
|
41
41
|
*/
|
42
42
|
get: function () {
|
43
43
|
return Object.freeze(this._accepts);
|
@@ -49,7 +49,7 @@ var ArvoContract = /** @class */ (function () {
|
|
49
49
|
/**
|
50
50
|
* Gets all emitted event types and schemas as a readonly record.
|
51
51
|
* Use this when you need to access all emitted events at once.
|
52
|
-
* @returns {
|
52
|
+
* @returns {Record<ExtractEventType<TEmits>, TEmits>} A frozen record of all emitted events.
|
53
53
|
*/
|
54
54
|
get: function () {
|
55
55
|
return Object.freeze(this._emits.reduce(function (acc, emit) {
|
@@ -66,7 +66,7 @@ var ArvoContract = /** @class */ (function () {
|
|
66
66
|
* Use this when you need to access a single emitted event by its type.
|
67
67
|
* @template U - The type of the emit record to retrieve.
|
68
68
|
* @param {U} type - The type of the emit record.
|
69
|
-
* @returns {
|
69
|
+
* @returns {Extract<TEmits, { type: U }>} The emit record.
|
70
70
|
* @throws {Error} If the emit type is not found in the contract.
|
71
71
|
*/
|
72
72
|
ArvoContract.prototype.getEmit = function (type) {
|
@@ -9,6 +9,7 @@ import { ArvoEventData, CloudEventExtension, CreateArvoEvent } from './types';
|
|
9
9
|
*
|
10
10
|
* @template TData - The type of the event data, extending ArvoEventData.
|
11
11
|
* @template TExtension - The type of the cloud event extension, extending CloudEventExtension.
|
12
|
+
* @template TType - The type name of the event
|
12
13
|
*
|
13
14
|
* @param {CreateArvoEvent<TData>} event - The event data and metadata to create the ArvoEvent.
|
14
15
|
* @param {TExtension} [extensions] - Optional cloud event extensions.
|
@@ -37,4 +38,4 @@ import { ArvoEventData, CloudEventExtension, CreateArvoEvent } from './types';
|
|
37
38
|
* telemetryContext
|
38
39
|
* );
|
39
40
|
*/
|
40
|
-
export declare const createArvoEvent: <TData extends ArvoEventData, TExtension extends CloudEventExtension>(event: CreateArvoEvent<TData>, extensions?: TExtension, telemetry?: TelemetryContext) => ArvoEvent<TData, TExtension>;
|
41
|
+
export declare const createArvoEvent: <TData extends ArvoEventData, TExtension extends CloudEventExtension, TType extends string>(event: CreateArvoEvent<TData, TType>, extensions?: TExtension, telemetry?: TelemetryContext) => ArvoEvent<TData, TExtension>;
|
@@ -17,6 +17,7 @@ var uuid_1 = require("uuid");
|
|
17
17
|
*
|
18
18
|
* @template TData - The type of the event data, extending ArvoEventData.
|
19
19
|
* @template TExtension - The type of the cloud event extension, extending CloudEventExtension.
|
20
|
+
* @template TType - The type name of the event
|
20
21
|
*
|
21
22
|
* @param {CreateArvoEvent<TData>} event - The event data and metadata to create the ArvoEvent.
|
22
23
|
* @param {TExtension} [extensions] - Optional cloud event extensions.
|
@@ -3,12 +3,13 @@ import { ArvoEventData, ArvoExtension, CloudEventContext, CloudEventExtension, O
|
|
3
3
|
* Represents an ArvoEvent, which extends the CloudEvent specification.
|
4
4
|
* @template TData - The type of the event data, extending ArvoEventData.
|
5
5
|
* @template TExtension - The type of additional extensions, extending CloudEventExtension.
|
6
|
+
* @template TType - The type name of the event
|
6
7
|
*/
|
7
|
-
export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExtension extends CloudEventExtension = CloudEventExtension> {
|
8
|
+
export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExtension extends CloudEventExtension = CloudEventExtension, TType extends string = string> {
|
8
9
|
readonly id: string;
|
9
10
|
readonly source: string;
|
10
11
|
readonly specversion: string;
|
11
|
-
readonly type:
|
12
|
+
readonly type: TType;
|
12
13
|
readonly subject: string;
|
13
14
|
readonly datacontenttype: string;
|
14
15
|
readonly dataschema: string | null;
|
@@ -36,7 +37,7 @@ export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExt
|
|
36
37
|
id: string;
|
37
38
|
source: string;
|
38
39
|
specversion: string;
|
39
|
-
type:
|
40
|
+
type: TType;
|
40
41
|
subject: string;
|
41
42
|
datacontenttype: string;
|
42
43
|
dataschema: string | null;
|
@@ -77,7 +78,7 @@ export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExt
|
|
77
78
|
'cloudevents.event_source': string;
|
78
79
|
'cloudevents.event_spec_version': string;
|
79
80
|
'cloudevents.event_subject': string;
|
80
|
-
'cloudevents.event_type': string;
|
81
|
+
'cloudevents.event_type': string | TType;
|
81
82
|
'cloudevents.event_time': string;
|
82
83
|
'cloudevents.event_datacontenttype': string;
|
83
84
|
'cloudevents.event_dataschema': string;
|
package/dist/ArvoEvent/index.js
CHANGED
@@ -17,6 +17,7 @@ var OpenTelemetry_1 = require("../OpenTelemetry");
|
|
17
17
|
* Represents an ArvoEvent, which extends the CloudEvent specification.
|
18
18
|
* @template TData - The type of the event data, extending ArvoEventData.
|
19
19
|
* @template TExtension - The type of additional extensions, extending CloudEventExtension.
|
20
|
+
* @template TType - The type name of the event
|
20
21
|
*/
|
21
22
|
var ArvoEvent = /** @class */ (function () {
|
22
23
|
/**
|
@@ -23,8 +23,9 @@ export type OpenTelemetryExtension = z.infer<typeof OpenTelemetryExtensionSchema
|
|
23
23
|
/**
|
24
24
|
* Represents the input parameters for creating an ArvoEvent.
|
25
25
|
* @template TData - The type of the event data, extending ArvoEventData.
|
26
|
+
* @template TType - The type name of the event
|
26
27
|
*/
|
27
|
-
export type CreateArvoEvent<TData extends ArvoEventData> = {
|
28
|
+
export type CreateArvoEvent<TData extends ArvoEventData, TType extends string> = {
|
28
29
|
/** Unique identifier of the event. Must be a non-empty string. If not provided, a UUID will be generated. */
|
29
30
|
id?: string;
|
30
31
|
/** Timestamp of when the occurrence happened. Must be in ISO 8601 format with timezone offset. */
|
@@ -34,7 +35,7 @@ export type CreateArvoEvent<TData extends ArvoEventData> = {
|
|
34
35
|
/** The version of the CloudEvents specification used. Must be '1.0' for this version. */
|
35
36
|
specversion?: '1.0';
|
36
37
|
/** Describes the type of event. Should be prefixed with a reverse-DNS name. */
|
37
|
-
type:
|
38
|
+
type: TType;
|
38
39
|
/** Identifies the subject of the event. For Arvo, this must be the Process Id. */
|
39
40
|
subject: string;
|
40
41
|
/** Content type of the data value. Must include 'application/cloudevents+json' or
|