arvo-core 1.1.20 → 1.1.22

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.
@@ -1,6 +1,6 @@
1
1
  import ArvoEvent from '.';
2
2
  import { ArvoEventData, CloudEventExtension, CreateArvoEvent } from './types';
3
- import { ExecutionOpenTelemetryConfiguration } from '../types';
3
+ import { ExecutionOpenTelemetryConfiguration } from '../OpenTelemetry/types';
4
4
  /**
5
5
  * Creates an ArvoEvent with the provided data and extensions.
6
6
  *
@@ -12,6 +12,7 @@ import { ExecutionOpenTelemetryConfiguration } from '../types';
12
12
  *
13
13
  * @param {CreateArvoEvent<TData>} event - The event data and metadata to create the ArvoEvent.
14
14
  * @param {TExtension} [extensions] - Optional cloud event extensions.
15
+ * @param {ExecutionOpenTelemetryConfiguration} [opentelemetry] - Optional opentelemetry configuration object
15
16
  *
16
17
  * @returns {ArvoEvent<TData, TExtension>} The created ArvoEvent instance.
17
18
  *
@@ -21,6 +21,7 @@ var uuid_1 = require("uuid");
21
21
  *
22
22
  * @param {CreateArvoEvent<TData>} event - The event data and metadata to create the ArvoEvent.
23
23
  * @param {TExtension} [extensions] - Optional cloud event extensions.
24
+ * @param {ExecutionOpenTelemetryConfiguration} [opentelemetry] - Optional opentelemetry configuration object
24
25
  *
25
26
  * @returns {ArvoEvent<TData, TExtension>} The created ArvoEvent instance.
26
27
  *
@@ -46,9 +47,9 @@ var uuid_1 = require("uuid");
46
47
  * );
47
48
  */
48
49
  var createArvoEvent = function (event, extensions, opentelemetry) {
49
- if (opentelemetry === void 0) { opentelemetry = {
50
+ opentelemetry = opentelemetry !== null && opentelemetry !== void 0 ? opentelemetry : {
50
51
  tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
51
- }; }
52
+ };
52
53
  var span = opentelemetry.tracer.startSpan("createArvoEvent<".concat(event.type, ">"), {});
53
54
  return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
54
55
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -1,7 +1,7 @@
1
1
  import ArvoContract from '../ArvoContract';
2
2
  import { z } from 'zod';
3
3
  import { CreateArvoEvent } from '../ArvoEvent/types';
4
- import { ExecutionOpenTelemetryConfiguration } from '../types';
4
+ import { ExecutionOpenTelemetryConfiguration } from '../OpenTelemetry/types';
5
5
  /**
6
6
  * A factory class for creating contractual ArvoEvents based on a given ArvoContract.
7
7
  *
@@ -24,6 +24,7 @@ export default class ArvoEventFactory<TUri extends string = string, TType extend
24
24
  * @template TExtension - The type of extensions to add to the event.
25
25
  * @param event - The event to create. The field 'type' is automatically infered
26
26
  * @param [extensions] - Optional extensions to add to the event.
27
+ * @param [opentelemetry] - Optional opentelemetry configuration object
27
28
  * @returns The created ArvoEvent as per the accept record of the contract.
28
29
  * @throws If the event data fails validation against the contract.
29
30
  */
@@ -35,6 +36,7 @@ export default class ArvoEventFactory<TUri extends string = string, TType extend
35
36
  * @template TExtension - The type of extensions to add to the event.
36
37
  * @param event - The event to create.
37
38
  * @param [extensions] - Optional extensions to add to the event.
39
+ * @param [opentelemetry] - Optional opentelemetry configuration object
38
40
  * @returns The created ArvoEvent as per one of the emits records of the contract.
39
41
  * @throws If the event data fails validation against the contract.
40
42
  */
@@ -45,6 +47,7 @@ export default class ArvoEventFactory<TUri extends string = string, TType extend
45
47
  * @template TExtension - The type of extensions to add to the event.
46
48
  * @param event - The event to create, including the error.
47
49
  * @param [extensions] - Optional extensions to add to the event.
50
+ * @param [opentelemetry] - Optional opentelemtry configuration object
48
51
  * @returns The created system error ArvoEvent.
49
52
  */
50
53
  systemError<TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<any, any>, 'data' | 'type' | 'datacontenttype' | 'dataschema'> & {
@@ -49,14 +49,15 @@ var ArvoEventFactory = /** @class */ (function () {
49
49
  * @template TExtension - The type of extensions to add to the event.
50
50
  * @param event - The event to create. The field 'type' is automatically infered
51
51
  * @param [extensions] - Optional extensions to add to the event.
52
+ * @param [opentelemetry] - Optional opentelemetry configuration object
52
53
  * @returns The created ArvoEvent as per the accept record of the contract.
53
54
  * @throws If the event data fails validation against the contract.
54
55
  */
55
56
  ArvoEventFactory.prototype.accepts = function (event, extensions, opentelemetry) {
56
57
  var _this = this;
57
- if (opentelemetry === void 0) { opentelemetry = {
58
+ opentelemetry = opentelemetry !== null && opentelemetry !== void 0 ? opentelemetry : {
58
59
  tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
59
- }; }
60
+ };
60
61
  var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.accepts<").concat(this.contract.accepts.type, ">.create"));
61
62
  return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
62
63
  var _a, _b, _c, _d;
@@ -89,14 +90,15 @@ var ArvoEventFactory = /** @class */ (function () {
89
90
  * @template TExtension - The type of extensions to add to the event.
90
91
  * @param event - The event to create.
91
92
  * @param [extensions] - Optional extensions to add to the event.
93
+ * @param [opentelemetry] - Optional opentelemetry configuration object
92
94
  * @returns The created ArvoEvent as per one of the emits records of the contract.
93
95
  * @throws If the event data fails validation against the contract.
94
96
  */
95
97
  ArvoEventFactory.prototype.emits = function (event, extensions, opentelemetry) {
96
98
  var _this = this;
97
- if (opentelemetry === void 0) { opentelemetry = {
98
- tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
99
- }; }
99
+ opentelemetry = opentelemetry !== null && opentelemetry !== void 0 ? opentelemetry : {
100
+ tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)()
101
+ };
100
102
  var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.emits<").concat(event.type, ">.create"));
101
103
  return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
102
104
  var _a, _b, _c, _d;
@@ -128,13 +130,14 @@ var ArvoEventFactory = /** @class */ (function () {
128
130
  * @template TExtension - The type of extensions to add to the event.
129
131
  * @param event - The event to create, including the error.
130
132
  * @param [extensions] - Optional extensions to add to the event.
133
+ * @param [opentelemetry] - Optional opentelemtry configuration object
131
134
  * @returns The created system error ArvoEvent.
132
135
  */
133
136
  ArvoEventFactory.prototype.systemError = function (event, extensions, opentelemetry) {
134
137
  var _this = this;
135
- if (opentelemetry === void 0) { opentelemetry = {
138
+ opentelemetry = opentelemetry !== null && opentelemetry !== void 0 ? opentelemetry : {
136
139
  tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
137
- }; }
140
+ };
138
141
  var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.systemError<sys.").concat(this.contract.accepts.type, ".error>.create"));
139
142
  return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
140
143
  var _a, _b, _c, _d, _e;
@@ -4,33 +4,72 @@ import { ArvoOrchestratorVersion, ArvoOrchestrationSubjectContent } from './type
4
4
  */
5
5
  export default class ArvoOrchestrationSubject {
6
6
  /**
7
- * Creates a new Arvo orchestration subject.
7
+ * Represents a wildcard version number used when version matching is not required.
8
+ * Format follows semantic versioning pattern.
9
+ */
10
+ static readonly WildCardMachineVersion: ArvoOrchestratorVersion;
11
+ /**
12
+ * Creates a new Arvo orchestration subject with basic required parameters.
13
+ * This is a convenience method that wraps the more detailed {@link create} method.
14
+ *
15
+ * @param param - Configuration object for the orchestration subject
16
+ * @param param.orchestator - Name identifier of the orchestrator
17
+ * @param param.version - Version of the orchestrator. If null, defaults to {@link WildCardMachineVersion}
18
+ * @param param.initiator - Identifier of the entity initiating the orchestration
19
+ * @returns A base64 encoded string containing the compressed orchestration subject data
20
+ * @throws Error if the provided parameters result in invalid subject content
8
21
  *
9
- * @param param - Parameters for creating the subject
10
- * @param param.orchestrator - Name of the orchestrator
11
- * @param param.version - Version of the orchestrator
12
- * @param param.initiator - Initiator of the orchestration
13
- * @returns A base64 encoded string representing the orchestration subject
22
+ * @example
23
+ * ```typescript
24
+ * const subject = ArvoOrchestrationSubject.new({
25
+ * orchestator: "mainProcess",
26
+ * version: "1.0.0",
27
+ * initiator: "systemA"
28
+ * });
29
+ * ```
14
30
  */
15
31
  static new(param: {
16
32
  orchestator: string;
17
- version: ArvoOrchestratorVersion;
33
+ version: ArvoOrchestratorVersion | null;
18
34
  initiator: string;
19
35
  }): string;
20
36
  /**
21
- * Creates an Arvo orchestration subject from the provided content.
37
+ * Creates an Arvo orchestration subject from detailed content parameters.
38
+ * The content is validated, compressed using zlib, and encoded in base64 format.
22
39
  *
23
- * @param param - The orchestration subject content
24
- * @returns A base64 encoded string representing the orchestration subject
25
- * @throws Error if the provided content is invalid or if compression fails
40
+ * @param param - Detailed orchestration subject content following the {@link ArvoOrchestrationSubjectContent} structure
41
+ * @returns A base64 encoded string containing the compressed orchestration subject data
42
+ * @throws Error if validation fails or compression encounters an error
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const subject = ArvoOrchestrationSubject.create({
47
+ * orchestrator: {
48
+ * name: "mainProcess",
49
+ * version: "1.0.0"
50
+ * },
51
+ * execution: {
52
+ * id: "550e8400-e29b-41d4-a716-446655440000",
53
+ * initiator: "systemA"
54
+ * }
55
+ * });
56
+ * ```
26
57
  */
27
58
  static create(param: ArvoOrchestrationSubjectContent): string;
28
59
  /**
29
- * Parses a base64 encoded Arvo orchestration subject string.
60
+ * Parses a base64 encoded orchestration subject string back into its structured content form.
61
+ * Performs decompression, JSON parsing, and validation of the subject content.
62
+ *
63
+ * @param subject - Base64 encoded string representing the compressed orchestration subject
64
+ * @returns The decoded and validated {@link ArvoOrchestrationSubjectContent}
65
+ * @throws Error if decompression, parsing, or validation fails
30
66
  *
31
- * @param subject - The base64 encoded subject string to parse
32
- * @returns The parsed ArvoOrchestrationSubjectContent
33
- * @throws Error if parsing or validation fails
67
+ * @example
68
+ * ```typescript
69
+ * const content = ArvoOrchestrationSubject.parse(encodedSubject);
70
+ * console.log(content.orchestrator.name);
71
+ * console.log(content.execution.id);
72
+ * ```
34
73
  */
35
74
  static parse(subject: string): ArvoOrchestrationSubjectContent;
36
75
  }
@@ -34,19 +34,31 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
34
34
  function ArvoOrchestrationSubject() {
35
35
  }
36
36
  /**
37
- * Creates a new Arvo orchestration subject.
37
+ * Creates a new Arvo orchestration subject with basic required parameters.
38
+ * This is a convenience method that wraps the more detailed {@link create} method.
38
39
  *
39
- * @param param - Parameters for creating the subject
40
- * @param param.orchestrator - Name of the orchestrator
41
- * @param param.version - Version of the orchestrator
42
- * @param param.initiator - Initiator of the orchestration
43
- * @returns A base64 encoded string representing the orchestration subject
40
+ * @param param - Configuration object for the orchestration subject
41
+ * @param param.orchestator - Name identifier of the orchestrator
42
+ * @param param.version - Version of the orchestrator. If null, defaults to {@link WildCardMachineVersion}
43
+ * @param param.initiator - Identifier of the entity initiating the orchestration
44
+ * @returns A base64 encoded string containing the compressed orchestration subject data
45
+ * @throws Error if the provided parameters result in invalid subject content
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const subject = ArvoOrchestrationSubject.new({
50
+ * orchestator: "mainProcess",
51
+ * version: "1.0.0",
52
+ * initiator: "systemA"
53
+ * });
54
+ * ```
44
55
  */
45
56
  ArvoOrchestrationSubject.new = function (param) {
57
+ var _a;
46
58
  return ArvoOrchestrationSubject.create({
47
59
  orchestrator: {
48
60
  name: param.orchestator,
49
- version: param.version,
61
+ version: (_a = param.version) !== null && _a !== void 0 ? _a : ArvoOrchestrationSubject.WildCardMachineVersion,
50
62
  },
51
63
  execution: {
52
64
  id: (0, uuid_1.v4)(),
@@ -55,11 +67,26 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
55
67
  });
56
68
  };
57
69
  /**
58
- * Creates an Arvo orchestration subject from the provided content.
70
+ * Creates an Arvo orchestration subject from detailed content parameters.
71
+ * The content is validated, compressed using zlib, and encoded in base64 format.
72
+ *
73
+ * @param param - Detailed orchestration subject content following the {@link ArvoOrchestrationSubjectContent} structure
74
+ * @returns A base64 encoded string containing the compressed orchestration subject data
75
+ * @throws Error if validation fails or compression encounters an error
59
76
  *
60
- * @param param - The orchestration subject content
61
- * @returns A base64 encoded string representing the orchestration subject
62
- * @throws Error if the provided content is invalid or if compression fails
77
+ * @example
78
+ * ```typescript
79
+ * const subject = ArvoOrchestrationSubject.create({
80
+ * orchestrator: {
81
+ * name: "mainProcess",
82
+ * version: "1.0.0"
83
+ * },
84
+ * execution: {
85
+ * id: "550e8400-e29b-41d4-a716-446655440000",
86
+ * initiator: "systemA"
87
+ * }
88
+ * });
89
+ * ```
63
90
  */
64
91
  ArvoOrchestrationSubject.create = function (param) {
65
92
  try {
@@ -76,11 +103,19 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
76
103
  }
77
104
  };
78
105
  /**
79
- * Parses a base64 encoded Arvo orchestration subject string.
106
+ * Parses a base64 encoded orchestration subject string back into its structured content form.
107
+ * Performs decompression, JSON parsing, and validation of the subject content.
108
+ *
109
+ * @param subject - Base64 encoded string representing the compressed orchestration subject
110
+ * @returns The decoded and validated {@link ArvoOrchestrationSubjectContent}
111
+ * @throws Error if decompression, parsing, or validation fails
80
112
  *
81
- * @param subject - The base64 encoded subject string to parse
82
- * @returns The parsed ArvoOrchestrationSubjectContent
83
- * @throws Error if parsing or validation fails
113
+ * @example
114
+ * ```typescript
115
+ * const content = ArvoOrchestrationSubject.parse(encodedSubject);
116
+ * console.log(content.orchestrator.name);
117
+ * console.log(content.execution.id);
118
+ * ```
84
119
  */
85
120
  ArvoOrchestrationSubject.parse = function (subject) {
86
121
  try {
@@ -97,6 +132,11 @@ var ArvoOrchestrationSubject = /** @class */ (function () {
97
132
  throw new Error((0, utils_1.cleanString)("\n Error parsing orchestration subject string to the context. \n Error -> ".concat(e.message, " \n subject -> ").concat(subject, "\n ")));
98
133
  }
99
134
  };
135
+ /**
136
+ * Represents a wildcard version number used when version matching is not required.
137
+ * Format follows semantic versioning pattern.
138
+ */
139
+ ArvoOrchestrationSubject.WildCardMachineVersion = '0.0.0';
100
140
  return ArvoOrchestrationSubject;
101
141
  }());
102
142
  exports.default = ArvoOrchestrationSubject;
@@ -1,3 +1,4 @@
1
+ import { Tracer } from '@opentelemetry/api';
1
2
  /**
2
3
  * Represents the available log levels for telemetry.
3
4
  * - DEBUG: Used for detailed information, typically of interest only when diagnosing problems.
@@ -17,3 +18,16 @@ export type OpenTelemetryHeaders = {
17
18
  /** The tracestate header value */
18
19
  tracestate: string | null;
19
20
  };
21
+ /**
22
+ * Configuration options for OpenTelemetry integration in execution context.
23
+ *
24
+ * This type defines how tracing should be configured and inherited within
25
+ * the execution pipeline.
26
+ */
27
+ export type ExecutionOpenTelemetryConfiguration = {
28
+ /**
29
+ * OpenTelemetry tracer instance to use for creating spans.
30
+ * If not provided, a default tracer may be used depending on the implementation.
31
+ */
32
+ tracer: Tracer;
33
+ };
package/dist/index.d.ts CHANGED
@@ -23,11 +23,12 @@ import { ArvoOrchestrationSubjectContentSchema, ArvoOrchestratorVersionSchema }
23
23
  import { ArvoOrchestrationSubjectContent, ArvoOrchestratorVersion } from './ArvoOrchestrationSubject/type';
24
24
  import ArvoEventHttp from './ArvoEventHttp';
25
25
  import { ArvoEventHttpConfig } from './ArvoEventHttp/types';
26
- import { InferArvoContract, InferArvoEvent, InferArvoOrchestratorContract, ExecutionOpenTelemetryConfiguration } from './types';
26
+ import { InferArvoContract, InferArvoEvent, InferArvoOrchestratorContract } from './types';
27
27
  import { createArvoOrchestratorContract } from './ArvoOrchestratorContract/helpers';
28
28
  import ArvoOrchestratorContract from './ArvoOrchestratorContract';
29
29
  import { ICreateArvoOrchestratorContract, IArvoOrchestratorContract } from './ArvoOrchestratorContract/types';
30
30
  import { ArvoOrchestratorEventTypeGen } from './ArvoOrchestratorContract/typegen';
31
+ import { ExecutionOpenTelemetryConfiguration } from './OpenTelemetry/types';
31
32
  /**
32
33
  * Collection of Zod schemas for validating various aspects of Arvo events.
33
34
  * @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
package/dist/types.d.ts CHANGED
@@ -3,20 +3,6 @@ import ArvoContract from './ArvoContract';
3
3
  import ArvoEvent from './ArvoEvent';
4
4
  import { ArvoExtension, OpenTelemetryExtension } from './ArvoEvent/types';
5
5
  import ArvoOrchestratorContract from './ArvoOrchestratorContract';
6
- import { Tracer } from '@opentelemetry/api';
7
- /**
8
- * Configuration options for OpenTelemetry integration in execution context.
9
- *
10
- * This type defines how tracing should be configured and inherited within
11
- * the execution pipeline.
12
- */
13
- export type ExecutionOpenTelemetryConfiguration = {
14
- /**
15
- * OpenTelemetry tracer instance to use for creating spans.
16
- * If not provided, a default tracer may be used depending on the implementation.
17
- */
18
- tracer: Tracer;
19
- };
20
6
  /**
21
7
  * A type utility that infers the structure of an ArvoEvent.
22
8
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-core",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "This core package contains all the core classes and components of the Arvo Event Driven System",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -50,6 +50,6 @@
50
50
  "@opentelemetry/core": "^1.27.0",
51
51
  "uuid": "^10.0.0",
52
52
  "zod": "^3.23.8",
53
- "zod-to-json-schema": "^3.23.2"
53
+ "zod-to-json-schema": "^3.23.5"
54
54
  }
55
55
  }