arvo-event-handler 3.0.6 → 3.0.7
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/dist/ArvoEventHandler/helpers.d.ts +2 -2
- package/dist/ArvoEventHandler/index.d.ts +4 -4
- package/dist/ArvoEventHandler/index.js +12 -33
- package/dist/ArvoEventHandler/types.d.ts +5 -3
- package/dist/ArvoMachine/createMachine.d.ts +4 -2
- package/dist/ArvoMachine/types.d.ts +5 -1
- package/dist/ArvoOrchestrator/index.d.ts +4 -4
- package/dist/ArvoOrchestrator/index.js +10 -30
- package/dist/ArvoOrchestrator/types.d.ts +2 -2
- package/dist/ArvoResumable/index.d.ts +2 -2
- package/dist/ArvoResumable/index.js +11 -31
- package/dist/ArvoResumable/types.d.ts +4 -2
- package/dist/IArvoEventHandler/index.d.ts +37 -0
- package/dist/IArvoEventHandler/index.js +2 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -3
- package/dist/types.d.ts +2 -2
- package/dist/utils/SimpleEventBroker/helper.d.ts +2 -2
- package/package.json +5 -4
- package/dist/AbstractArvoEventHandler/index.d.ts +0 -91
- package/dist/AbstractArvoEventHandler/index.js +0 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ArvoContract } from 'arvo-core';
|
|
2
2
|
import ArvoEventHandler from '.';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ArvoEventHandlerParam } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Creates an instance of `ArvoEventHandler` for the specified versioned contract and handlers.
|
|
6
6
|
*
|
|
@@ -42,4 +42,4 @@ import type { IArvoEventHandler } from './types';
|
|
|
42
42
|
* @param param - Configuration object containing contract, versioned handlers, execution units, and span settings
|
|
43
43
|
* @returns A fully configured `ArvoEventHandler` instance for the given contract
|
|
44
44
|
*/
|
|
45
|
-
export declare const createArvoEventHandler: <TContract extends ArvoContract>(param:
|
|
45
|
+
export declare const createArvoEventHandler: <TContract extends ArvoContract>(param: ArvoEventHandlerParam<TContract>) => ArvoEventHandler<TContract>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type SpanOptions } from '@opentelemetry/api';
|
|
2
2
|
import { type ArvoContract, type ArvoEvent } from 'arvo-core';
|
|
3
|
-
import
|
|
3
|
+
import IArvoEventHandler from '../IArvoEventHandler';
|
|
4
4
|
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
5
|
-
import type { ArvoEventHandlerFunction,
|
|
5
|
+
import type { ArvoEventHandlerFunction, ArvoEventHandlerParam } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* `ArvoEventHandler` is the foundational component for building stateless,
|
|
8
8
|
* contract-bound services in the Arvo system.
|
|
@@ -83,7 +83,7 @@ import type { ArvoEventHandlerFunction, IArvoEventHandler } from './types';
|
|
|
83
83
|
* - `'analytics.workflow'` → to pipe events into observability systems
|
|
84
84
|
* - `'external.partner.sync'` → to route to external services
|
|
85
85
|
*/
|
|
86
|
-
export default class ArvoEventHandler<TContract extends ArvoContract>
|
|
86
|
+
export default class ArvoEventHandler<TContract extends ArvoContract> implements IArvoEventHandler {
|
|
87
87
|
/** Contract instance that defines the event schema and validation rules */
|
|
88
88
|
readonly contract: TContract;
|
|
89
89
|
/** Computational cost metric associated with event handling operations */
|
|
@@ -111,7 +111,7 @@ export default class ArvoEventHandler<TContract extends ArvoContract> extends Ab
|
|
|
111
111
|
* @param param - Handler configuration including contract, execution units, and handler implementations
|
|
112
112
|
* @throws When handler implementations are missing for any contract version
|
|
113
113
|
*/
|
|
114
|
-
constructor(param:
|
|
114
|
+
constructor(param: ArvoEventHandlerParam<TContract>);
|
|
115
115
|
/**
|
|
116
116
|
* Processes an incoming event according to the handler's contract specifications. This method
|
|
117
117
|
* handles the complete lifecycle of event processing including validation, execution, error
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __assign = (this && this.__assign) || function () {
|
|
18
3
|
__assign = Object.assign || function(t) {
|
|
19
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -72,13 +57,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
72
57
|
}
|
|
73
58
|
return t;
|
|
74
59
|
};
|
|
75
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
76
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
77
|
-
};
|
|
78
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
79
61
|
var api_1 = require("@opentelemetry/api");
|
|
80
62
|
var arvo_core_1 = require("arvo-core");
|
|
81
|
-
var AbstractArvoEventHandler_1 = __importDefault(require("../AbstractArvoEventHandler"));
|
|
82
63
|
var errors_1 = require("../errors");
|
|
83
64
|
var utils_1 = require("../utils");
|
|
84
65
|
var ArvoDomain_1 = require("../ArvoDomain");
|
|
@@ -162,8 +143,7 @@ var ArvoDomain_1 = require("../ArvoDomain");
|
|
|
162
143
|
* - `'analytics.workflow'` → to pipe events into observability systems
|
|
163
144
|
* - `'external.partner.sync'` → to route to external services
|
|
164
145
|
*/
|
|
165
|
-
var ArvoEventHandler = /** @class */ (function (
|
|
166
|
-
__extends(ArvoEventHandler, _super);
|
|
146
|
+
var ArvoEventHandler = /** @class */ (function () {
|
|
167
147
|
/**
|
|
168
148
|
* Initializes a new ArvoEventHandler instance with the specified contract and configuration.
|
|
169
149
|
* Validates handler implementations against contract versions during initialization.
|
|
@@ -177,20 +157,18 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
177
157
|
function ArvoEventHandler(param) {
|
|
178
158
|
var _a;
|
|
179
159
|
var _b, _c;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
for (var _i = 0, _d = Object.keys(_this.contract.versions); _i < _d.length; _i++) {
|
|
160
|
+
this.systemErrorDomain = undefined;
|
|
161
|
+
this.contract = param.contract;
|
|
162
|
+
this.executionunits = param.executionunits;
|
|
163
|
+
this.handler = param.handler;
|
|
164
|
+
this.systemErrorDomain = param.systemErrorDomain;
|
|
165
|
+
for (var _i = 0, _d = Object.keys(this.contract.versions); _i < _d.length; _i++) {
|
|
187
166
|
var contractVersions = _d[_i];
|
|
188
|
-
if (!
|
|
189
|
-
throw new Error("Contract ".concat(
|
|
167
|
+
if (!this.handler[contractVersions]) {
|
|
168
|
+
throw new Error("Contract ".concat(this.contract.uri, " requires handler implementation for version ").concat(contractVersions));
|
|
190
169
|
}
|
|
191
170
|
}
|
|
192
|
-
|
|
193
|
-
return _this;
|
|
171
|
+
this.spanOptions = __assign(__assign({ kind: api_1.SpanKind.CONSUMER }, param.spanOptions), { attributes: __assign(__assign((_a = {}, _a[arvo_core_1.ArvoExecution.ATTR_SPAN_KIND] = arvo_core_1.ArvoExecutionSpanKind.EVENT_HANDLER, _a[arvo_core_1.OpenInference.ATTR_SPAN_KIND] = arvo_core_1.OpenInferenceSpanKind.CHAIN, _a), ((_c = (_b = param.spanOptions) === null || _b === void 0 ? void 0 : _b.attributes) !== null && _c !== void 0 ? _c : {})), { 'arvo.handler.source': this.source, 'arvo.contract.uri': this.contract.uri }) });
|
|
194
172
|
}
|
|
195
173
|
Object.defineProperty(ArvoEventHandler.prototype, "source", {
|
|
196
174
|
/** The source identifier for events produced by this handler */
|
|
@@ -308,6 +286,7 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
308
286
|
event: event.domain,
|
|
309
287
|
},
|
|
310
288
|
span: span,
|
|
289
|
+
spanHeaders: otelSpanHeaders,
|
|
311
290
|
})];
|
|
312
291
|
case 2:
|
|
313
292
|
_handleOutput = _z.sent();
|
|
@@ -441,5 +420,5 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
441
420
|
configurable: true
|
|
442
421
|
});
|
|
443
422
|
return ArvoEventHandler;
|
|
444
|
-
}(
|
|
423
|
+
}());
|
|
445
424
|
exports.default = ArvoEventHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Span, SpanOptions } from '@opentelemetry/api';
|
|
2
|
-
import type { ArvoContract, ArvoEvent, ArvoSemanticVersion, CreateArvoEvent, InferArvoEvent, VersionedArvoContract } from 'arvo-core';
|
|
2
|
+
import type { ArvoContract, ArvoEvent, ArvoSemanticVersion, CreateArvoEvent, InferArvoEvent, OpenTelemetryHeaders, VersionedArvoContract } from 'arvo-core';
|
|
3
3
|
import type { z } from 'zod';
|
|
4
4
|
/**
|
|
5
5
|
* Represents the input for an ArvoEvent handler function.
|
|
@@ -18,6 +18,8 @@ export type ArvoEventHandlerFunctionInput<TContract extends VersionedArvoContrac
|
|
|
18
18
|
contract: TContract;
|
|
19
19
|
/** The OpenTelemetry span */
|
|
20
20
|
span: Span;
|
|
21
|
+
/** The span headers */
|
|
22
|
+
spanHeaders: OpenTelemetryHeaders;
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
25
|
* Represents the output of an ArvoEvent handler function.
|
|
@@ -69,7 +71,7 @@ export type ArvoEventHandlerFunction<TContract extends ArvoContract> = {
|
|
|
69
71
|
/**
|
|
70
72
|
* Interface for an ArvoEvent handler.
|
|
71
73
|
*/
|
|
72
|
-
export
|
|
74
|
+
export type ArvoEventHandlerParam<TContract extends ArvoContract> = {
|
|
73
75
|
/**
|
|
74
76
|
* The contract for the handler defining its input and outputs as well as the description.
|
|
75
77
|
*/
|
|
@@ -103,4 +105,4 @@ export interface IArvoEventHandler<TContract extends ArvoContract> {
|
|
|
103
105
|
* @default undefined — uses standard fallback broadcast domains
|
|
104
106
|
*/
|
|
105
107
|
systemErrorDomain?: (string | null)[];
|
|
106
|
-
}
|
|
108
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ArvoOrchestratorEventTypeGen, type InferVersionedArvoContract, type VersionedArvoContract } from 'arvo-core';
|
|
1
|
+
import { type ArvoOrchestratorEventTypeGen, CreateArvoEvent, type InferVersionedArvoContract, type VersionedArvoContract } from 'arvo-core';
|
|
2
2
|
import { type ActionFunction, type MachineConfig, type MachineContext, type MetaObject, type ParameterizedObject, type SetupTypes } from 'xstate';
|
|
3
3
|
import type { z } from 'zod';
|
|
4
4
|
import ArvoMachine from '.';
|
|
@@ -185,7 +185,9 @@ export declare function setupArvoMachine<TContext extends MachineContext, TSelfC
|
|
|
185
185
|
}): {
|
|
186
186
|
createMachine: <const TConfig extends MachineConfig<TContext, InferServiceContract<TServiceContracts>["events"], ToProvidedActor<{}, {}>, ToParameterizedObject<TActions & {
|
|
187
187
|
enqueueArvoEvent: EnqueueArvoEventActionParam;
|
|
188
|
-
}>, ToParameterizedObject<TGuards>, never, TTag, InferVersionedArvoContract<TSelfContract>["accepts"], z.input<TSelfContract["emits"][ReturnType<typeof ArvoOrchestratorEventTypeGen.complete<ExtractOrchestratorType<TSelfContract["accepts"]["type"]>>>]
|
|
188
|
+
}>, ToParameterizedObject<TGuards>, never, TTag, InferVersionedArvoContract<TSelfContract>["accepts"], z.input<TSelfContract["emits"][ReturnType<typeof ArvoOrchestratorEventTypeGen.complete<ExtractOrchestratorType<TSelfContract["accepts"]["type"]>>>]> & {
|
|
189
|
+
__id?: CreateArvoEvent<Record<string, unknown>, string>["id"];
|
|
190
|
+
}, InferServiceContract<TServiceContracts>["emitted"], TMeta>>(config: TConfig & {
|
|
189
191
|
id: string;
|
|
190
192
|
version?: TSelfContract["version"];
|
|
191
193
|
}) => ArvoMachine<string, TSelfContract["version"], TSelfContract, TServiceContracts, import("xstate").StateMachine<TContext, { [K in keyof TServiceContracts]: import("./types").InferEmittableEventsFromVersionedArvoContract<TServiceContracts[K]>; }[keyof TServiceContracts], {}, never, import("xstate").IsNever<TActions & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArvoContract, ArvoEventData, ArvoOrchestratorEventTypeGen, ArvoSemanticVersion, CloudEventExtension, InferVersionedArvoContract, VersionedArvoContract } from 'arvo-core';
|
|
1
|
+
import type { ArvoContract, ArvoEventData, ArvoOrchestratorEventTypeGen, ArvoSemanticVersion, CloudEventExtension, CreateArvoEvent, InferVersionedArvoContract, VersionedArvoContract } from 'arvo-core';
|
|
2
2
|
import type { Invert, IsNever, ParameterizedObject, UnknownActorLogic, Values } from 'xstate';
|
|
3
3
|
import type { z } from 'zod';
|
|
4
4
|
/**
|
|
@@ -35,6 +35,10 @@ export type ArvoMachineContext = {
|
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
export type EnqueueArvoEventActionParam<TData extends ArvoEventData = ArvoEventData, TType extends string = string, TExtension extends CloudEventExtension = CloudEventExtension> = {
|
|
38
|
+
/**
|
|
39
|
+
* The event id
|
|
40
|
+
*/
|
|
41
|
+
id?: CreateArvoEvent<TData, TType>['id'];
|
|
38
42
|
/**
|
|
39
43
|
* The domain configuration for multi-domain event broadcasting.
|
|
40
44
|
*
|
|
@@ -4,15 +4,15 @@ import type { EnqueueArvoEventActionParam } from '../ArvoMachine/types';
|
|
|
4
4
|
import type { IMachineExectionEngine } from '../MachineExecutionEngine/interface';
|
|
5
5
|
import type { IMachineMemory } from '../MachineMemory/interface';
|
|
6
6
|
import type { IMachineRegistry } from '../MachineRegistry/interface';
|
|
7
|
-
import type {
|
|
7
|
+
import type { ArvoOrchestratorParam, MachineMemoryRecord } from './types';
|
|
8
8
|
import { SyncEventResource } from '../SyncEventResource';
|
|
9
|
-
import
|
|
9
|
+
import IArvoEventHandler from '../IArvoEventHandler';
|
|
10
10
|
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
11
11
|
/**
|
|
12
12
|
* Orchestrates state machine execution and lifecycle management.
|
|
13
13
|
* Handles machine resolution, state management, event processing and error handling.
|
|
14
14
|
*/
|
|
15
|
-
export declare class ArvoOrchestrator
|
|
15
|
+
export declare class ArvoOrchestrator implements IArvoEventHandler {
|
|
16
16
|
readonly executionunits: number;
|
|
17
17
|
readonly registry: IMachineRegistry;
|
|
18
18
|
readonly executionEngine: IMachineExectionEngine;
|
|
@@ -27,7 +27,7 @@ export declare class ArvoOrchestrator extends AbstractArvoEventHandler {
|
|
|
27
27
|
* @param params - Configuration parameters
|
|
28
28
|
* @throws Error if machines in registry have different sources
|
|
29
29
|
*/
|
|
30
|
-
constructor({ executionunits, memory, registry, executionEngine, requiresResourceLocking, systemErrorDomain, }:
|
|
30
|
+
constructor({ executionunits, memory, registry, executionEngine, requiresResourceLocking, systemErrorDomain, }: ArvoOrchestratorParam);
|
|
31
31
|
/**
|
|
32
32
|
* Creates emittable event from execution result
|
|
33
33
|
* @param event - Source event to emit
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __assign = (this && this.__assign) || function () {
|
|
18
3
|
__assign = Object.assign || function(t) {
|
|
19
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -61,9 +46,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
61
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
47
|
}
|
|
63
48
|
};
|
|
64
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
|
-
};
|
|
67
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
50
|
exports.ArvoOrchestrator = void 0;
|
|
69
51
|
var api_1 = require("@opentelemetry/api");
|
|
@@ -71,15 +53,13 @@ var arvo_core_1 = require("arvo-core");
|
|
|
71
53
|
var utils_1 = require("../utils");
|
|
72
54
|
var error_1 = require("./error");
|
|
73
55
|
var SyncEventResource_1 = require("../SyncEventResource");
|
|
74
|
-
var AbstractArvoEventHandler_1 = __importDefault(require("../AbstractArvoEventHandler"));
|
|
75
56
|
var errors_1 = require("../errors");
|
|
76
57
|
var ArvoDomain_1 = require("../ArvoDomain");
|
|
77
58
|
/**
|
|
78
59
|
* Orchestrates state machine execution and lifecycle management.
|
|
79
60
|
* Handles machine resolution, state management, event processing and error handling.
|
|
80
61
|
*/
|
|
81
|
-
var ArvoOrchestrator = /** @class */ (function (
|
|
82
|
-
__extends(ArvoOrchestrator, _super);
|
|
62
|
+
var ArvoOrchestrator = /** @class */ (function () {
|
|
83
63
|
/**
|
|
84
64
|
* Creates a new orchestrator instance
|
|
85
65
|
* @param params - Configuration parameters
|
|
@@ -87,9 +67,8 @@ var ArvoOrchestrator = /** @class */ (function (_super) {
|
|
|
87
67
|
*/
|
|
88
68
|
function ArvoOrchestrator(_a) {
|
|
89
69
|
var executionunits = _a.executionunits, memory = _a.memory, registry = _a.registry, executionEngine = _a.executionEngine, requiresResourceLocking = _a.requiresResourceLocking, systemErrorDomain = _a.systemErrorDomain;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
_this.executionunits = executionunits;
|
|
70
|
+
this.systemErrorDomain = [];
|
|
71
|
+
this.executionunits = executionunits;
|
|
93
72
|
var representativeMachine = registry.machines[0];
|
|
94
73
|
var lastSeenVersions = [];
|
|
95
74
|
for (var _i = 0, _b = registry.machines; _i < _b.length; _i++) {
|
|
@@ -102,11 +81,10 @@ var ArvoOrchestrator = /** @class */ (function (_super) {
|
|
|
102
81
|
}
|
|
103
82
|
lastSeenVersions.push(machine.version);
|
|
104
83
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return _this;
|
|
84
|
+
this.registry = registry;
|
|
85
|
+
this.executionEngine = executionEngine;
|
|
86
|
+
this.syncEventResource = new SyncEventResource_1.SyncEventResource(memory, requiresResourceLocking);
|
|
87
|
+
this.systemErrorDomain = systemErrorDomain;
|
|
110
88
|
}
|
|
111
89
|
Object.defineProperty(ArvoOrchestrator.prototype, "source", {
|
|
112
90
|
get: function () {
|
|
@@ -257,6 +235,7 @@ var ArvoOrchestrator = /** @class */ (function (_super) {
|
|
|
257
235
|
}
|
|
258
236
|
// Create the event
|
|
259
237
|
var emittableEvent = (0, arvo_core_1.createArvoEvent)({
|
|
238
|
+
id: event.id,
|
|
260
239
|
source: this.source,
|
|
261
240
|
type: event.type,
|
|
262
241
|
subject: subject,
|
|
@@ -459,6 +438,7 @@ var ArvoOrchestrator = /** @class */ (function (_super) {
|
|
|
459
438
|
rawMachineEmittedEvents.push({
|
|
460
439
|
type: machine.contracts.self
|
|
461
440
|
.metadata.completeEventType,
|
|
441
|
+
id: executionResult.finalOutput.__id,
|
|
462
442
|
data: executionResult.finalOutput,
|
|
463
443
|
to: (_t = (_s = parsedEventSubject.meta) === null || _s === void 0 ? void 0 : _s.redirectto) !== null && _t !== void 0 ? _t : parsedEventSubject.execution.initiator,
|
|
464
444
|
domain: orchestrationParentSubject
|
|
@@ -621,5 +601,5 @@ var ArvoOrchestrator = /** @class */ (function (_super) {
|
|
|
621
601
|
configurable: true
|
|
622
602
|
});
|
|
623
603
|
return ArvoOrchestrator;
|
|
624
|
-
}(
|
|
604
|
+
}());
|
|
625
605
|
exports.ArvoOrchestrator = ArvoOrchestrator;
|
|
@@ -71,7 +71,7 @@ export type MachineMemoryRecord = {
|
|
|
71
71
|
/**
|
|
72
72
|
* Interface defining the core components of an Arvo orchestrator.
|
|
73
73
|
*/
|
|
74
|
-
export
|
|
74
|
+
export type ArvoOrchestratorParam = {
|
|
75
75
|
/** The cost of the execution of the orchestrator */
|
|
76
76
|
executionunits: number;
|
|
77
77
|
/** Memory interface for storing and retrieving machine state */
|
|
@@ -85,7 +85,7 @@ export interface IArvoOrchestrator {
|
|
|
85
85
|
* Optional configuration to customize where system error events are emitted.
|
|
86
86
|
*/
|
|
87
87
|
systemErrorDomain?: (string | null)[];
|
|
88
|
-
}
|
|
88
|
+
};
|
|
89
89
|
/**
|
|
90
90
|
* Configuration interface for creating an Arvo orchestrator instance.
|
|
91
91
|
*/
|
|
@@ -4,7 +4,7 @@ import type { ArvoResumableHandler, ArvoResumableState } from './types';
|
|
|
4
4
|
import type { IMachineMemory } from '../MachineMemory/interface';
|
|
5
5
|
import { SyncEventResource } from '../SyncEventResource/index';
|
|
6
6
|
import type { EnqueueArvoEventActionParam } from '../ArvoMachine/types';
|
|
7
|
-
import
|
|
7
|
+
import IArvoEventHandler from '../IArvoEventHandler';
|
|
8
8
|
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
9
9
|
/**
|
|
10
10
|
* ArvoResumable - A stateful orchestration handler for managing distributed workflows
|
|
@@ -37,7 +37,7 @@ import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
|
37
37
|
* @see {@link ArvoResumableHandler} Handler interface documentation
|
|
38
38
|
* @see {@link ArvoResumableState} State structure documentation
|
|
39
39
|
*/
|
|
40
|
-
export declare class ArvoResumable<TMemory extends Record<string, any> = Record<string, any>, TSelfContract extends ArvoOrchestratorContract = ArvoOrchestratorContract, TServiceContract extends Record<string, VersionedArvoContract<any, any>> = Record<string, VersionedArvoContract<any, any>>>
|
|
40
|
+
export declare class ArvoResumable<TMemory extends Record<string, any> = Record<string, any>, TSelfContract extends ArvoOrchestratorContract = ArvoOrchestratorContract, TServiceContract extends Record<string, VersionedArvoContract<any, any>> = Record<string, VersionedArvoContract<any, any>>> implements IArvoEventHandler {
|
|
41
41
|
readonly executionunits: number;
|
|
42
42
|
readonly syncEventResource: SyncEventResource<ArvoResumableState<TMemory>>;
|
|
43
43
|
readonly source: string;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __assign = (this && this.__assign) || function () {
|
|
18
3
|
__assign = Object.assign || function(t) {
|
|
19
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -70,9 +55,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
70
55
|
}
|
|
71
56
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
57
|
};
|
|
73
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
74
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
75
|
-
};
|
|
76
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
59
|
exports.ArvoResumable = void 0;
|
|
78
60
|
var api_1 = require("@opentelemetry/api");
|
|
@@ -80,7 +62,6 @@ var arvo_core_1 = require("arvo-core");
|
|
|
80
62
|
var error_1 = require("../ArvoOrchestrator/error");
|
|
81
63
|
var index_1 = require("../SyncEventResource/index");
|
|
82
64
|
var index_2 = require("../utils/index");
|
|
83
|
-
var AbstractArvoEventHandler_1 = __importDefault(require("../AbstractArvoEventHandler"));
|
|
84
65
|
var errors_1 = require("../errors");
|
|
85
66
|
var ArvoDomain_1 = require("../ArvoDomain");
|
|
86
67
|
/**
|
|
@@ -114,19 +95,16 @@ var ArvoDomain_1 = require("../ArvoDomain");
|
|
|
114
95
|
* @see {@link ArvoResumableHandler} Handler interface documentation
|
|
115
96
|
* @see {@link ArvoResumableState} State structure documentation
|
|
116
97
|
*/
|
|
117
|
-
var ArvoResumable = /** @class */ (function (
|
|
118
|
-
__extends(ArvoResumable, _super);
|
|
98
|
+
var ArvoResumable = /** @class */ (function () {
|
|
119
99
|
function ArvoResumable(param) {
|
|
120
100
|
var _a;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
_this.systemErrorDomain = param.systemErrorDomain;
|
|
129
|
-
return _this;
|
|
101
|
+
this.systemErrorDomain = [];
|
|
102
|
+
this.executionunits = param.executionunits;
|
|
103
|
+
this.source = param.contracts.self.type;
|
|
104
|
+
this.syncEventResource = new index_1.SyncEventResource(param.memory, (_a = param.requiresResourceLocking) !== null && _a !== void 0 ? _a : true);
|
|
105
|
+
this.contracts = param.contracts;
|
|
106
|
+
this.handler = param.handler;
|
|
107
|
+
this.systemErrorDomain = param.systemErrorDomain;
|
|
130
108
|
}
|
|
131
109
|
Object.defineProperty(ArvoResumable.prototype, "requiresResourceLocking", {
|
|
132
110
|
get: function () {
|
|
@@ -317,6 +295,7 @@ var ArvoResumable = /** @class */ (function (_super) {
|
|
|
317
295
|
}
|
|
318
296
|
// Create the event
|
|
319
297
|
var emittableEvent = (0, arvo_core_1.createArvoEvent)({
|
|
298
|
+
id: event.id,
|
|
320
299
|
source: this.source,
|
|
321
300
|
type: event.type,
|
|
322
301
|
subject: subject,
|
|
@@ -538,6 +517,7 @@ var ArvoResumable = /** @class */ (function (_super) {
|
|
|
538
517
|
for (_d = 0, _e = __spreadArray(__spreadArray([], ((executionResult === null || executionResult === void 0 ? void 0 : executionResult.output)
|
|
539
518
|
? [
|
|
540
519
|
{
|
|
520
|
+
id: executionResult.output.__id,
|
|
541
521
|
data: executionResult.output,
|
|
542
522
|
type: this.contracts.self.metadata.completeEventType,
|
|
543
523
|
to: (_3 = (_2 = parsedEventSubject.meta) === null || _2 === void 0 ? void 0 : _2.redirectto) !== null && _3 !== void 0 ? _3 : parsedEventSubject.execution.initiator,
|
|
@@ -694,5 +674,5 @@ var ArvoResumable = /** @class */ (function (_super) {
|
|
|
694
674
|
configurable: true
|
|
695
675
|
});
|
|
696
676
|
return ArvoResumable;
|
|
697
|
-
}(
|
|
677
|
+
}());
|
|
698
678
|
exports.ArvoResumable = ArvoResumable;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VersionedArvoContract, ArvoSemanticVersion, InferVersionedArvoContract, ArvoContract, ArvoEvent, InferArvoEvent } from 'arvo-core';
|
|
1
|
+
import type { VersionedArvoContract, ArvoSemanticVersion, InferVersionedArvoContract, ArvoContract, ArvoEvent, InferArvoEvent, CreateArvoEvent } from 'arvo-core';
|
|
2
2
|
import type { EnqueueArvoEventActionParam } from '../ArvoMachine/types';
|
|
3
3
|
import type { Span } from '@opentelemetry/api';
|
|
4
4
|
type ExtractServiceEventTypes<TServiceContract extends Record<string, VersionedArvoContract<any, any>>> = {
|
|
@@ -41,7 +41,9 @@ type Handler<TState extends ArvoResumableState<Record<string, any>>, TSelfContra
|
|
|
41
41
|
context?: TState['state$$'];
|
|
42
42
|
output?: {
|
|
43
43
|
[L in keyof InferVersionedArvoContract<TSelfContract>['emits']]: EnqueueArvoEventActionParam<InferVersionedArvoContract<TSelfContract>['emits'][L]['data'], InferVersionedArvoContract<TSelfContract>['emits'][L]['type']>['data'];
|
|
44
|
-
}[keyof InferVersionedArvoContract<TSelfContract>['emits']]
|
|
44
|
+
}[keyof InferVersionedArvoContract<TSelfContract>['emits']] & {
|
|
45
|
+
__id?: CreateArvoEvent<Record<string, unknown>, string>['id'];
|
|
46
|
+
};
|
|
45
47
|
services?: Array<{
|
|
46
48
|
[K in keyof TServiceContract]: EnqueueArvoEventActionParam<InferVersionedArvoContract<TServiceContract[K]>['accepts']['data'], InferVersionedArvoContract<TServiceContract[K]>['accepts']['type']>;
|
|
47
49
|
}[keyof TServiceContract]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ArvoContractRecord, ArvoEvent } from 'arvo-core';
|
|
2
|
+
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* The interface for Arvo event handlers.
|
|
5
|
+
*
|
|
6
|
+
* This class defines the basic structure for all Arvo event handlers.
|
|
7
|
+
* It provides an abstract method for executing events, which must be
|
|
8
|
+
* implemented by any concrete subclass.
|
|
9
|
+
*/
|
|
10
|
+
export default interface IArvoEventHandler {
|
|
11
|
+
/**
|
|
12
|
+
* Unique identifier for the event handler source system
|
|
13
|
+
*/
|
|
14
|
+
source: string;
|
|
15
|
+
/**
|
|
16
|
+
* Executes the event handling logic for a given Arvo event.
|
|
17
|
+
*
|
|
18
|
+
* @param event - The Arvo event to be processed.
|
|
19
|
+
* @param opentelemetry - Configuration for OpenTelemetry integration
|
|
20
|
+
*
|
|
21
|
+
* @returns A promise that resolves to an array of resulting Arvo events.
|
|
22
|
+
* These events represent the outcome of processing the input event.
|
|
23
|
+
*/
|
|
24
|
+
execute(event: ArvoEvent, opentelemetry: ArvoEventHandlerOpenTelemetryOptions): Promise<{
|
|
25
|
+
events: ArvoEvent[];
|
|
26
|
+
metadata?: Record<string, any>;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Provides the schema for system error events.
|
|
30
|
+
*
|
|
31
|
+
* @returns An object containing the error event type and schema.
|
|
32
|
+
*
|
|
33
|
+
* This defines the structure for system error events that may be emitted
|
|
34
|
+
* when an unexpected error occurs during event handling.
|
|
35
|
+
*/
|
|
36
|
+
systemErrorSchema: ArvoContractRecord;
|
|
37
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import IArvoEventHandler from './IArvoEventHandler';
|
|
2
2
|
import ArvoEventHandler from './ArvoEventHandler';
|
|
3
3
|
import { createArvoEventHandler } from './ArvoEventHandler/helpers';
|
|
4
|
-
import { ArvoEventHandlerFunction, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunctionOutput
|
|
4
|
+
import { ArvoEventHandlerFunction, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunctionOutput } from './ArvoEventHandler/types';
|
|
5
5
|
import { ConfigViolation, ContractViolation, ExecutionViolation } from './errors';
|
|
6
6
|
import { ArvoEventHandlerOpenTelemetryOptions, EventHandlerFactory, PartialExcept } from './types';
|
|
7
7
|
import { coalesce, coalesceOrDefault, getValueOrDefault, isNullOrUndefined } from './utils';
|
|
@@ -12,7 +12,7 @@ import { ArvoMachineContext, EnqueueArvoEventActionParam } from './ArvoMachine/t
|
|
|
12
12
|
import { ArvoOrchestrator } from './ArvoOrchestrator';
|
|
13
13
|
import { TransactionViolation, TransactionViolationCause } from './ArvoOrchestrator/error';
|
|
14
14
|
import { createArvoOrchestrator } from './ArvoOrchestrator/factory';
|
|
15
|
-
import {
|
|
15
|
+
import { ArvoOrchestratorParam, MachineMemoryRecord } from './ArvoOrchestrator/types';
|
|
16
16
|
import { MachineExecutionEngine } from './MachineExecutionEngine';
|
|
17
17
|
import { IMachineExectionEngine } from './MachineExecutionEngine/interface';
|
|
18
18
|
import { ExecuteMachineInput, ExecuteMachineOutput } from './MachineExecutionEngine/types';
|
|
@@ -31,4 +31,4 @@ declare const xstate: {
|
|
|
31
31
|
emit: typeof emit;
|
|
32
32
|
assign: typeof assign;
|
|
33
33
|
};
|
|
34
|
-
export { ArvoEventHandler, createArvoEventHandler, IArvoEventHandler, ArvoEventHandlerFunctionOutput, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunction, PartialExcept, isNullOrUndefined, getValueOrDefault, coalesce, coalesceOrDefault, AbstractArvoEventHandler, ArvoEventHandlerOpenTelemetryOptions, EventHandlerFactory, ContractViolation, ConfigViolation, ExecutionViolation, ArvoMachine, setupArvoMachine, ArvoMachineContext, EnqueueArvoEventActionParam, IMachineRegistry, MachineRegistry, MachineExecutionEngine, IMachineExectionEngine, ExecuteMachineInput, ExecuteMachineOutput, IMachineMemory, SimpleMachineMemory, MachineMemoryRecord, IArvoOrchestrator, TransactionViolation, TransactionViolationCause, ArvoOrchestrator, createArvoOrchestrator, SimpleEventBroker, createSimpleEventBroker, TelemetredSimpleMachineMemory, xstate, ArvoResumable, createArvoResumable, ArvoResumableHandler, ArvoResumableState, ArvoDomain, resolveEventDomain, };
|
|
34
|
+
export { ArvoEventHandler, createArvoEventHandler, IArvoEventHandler, ArvoEventHandlerFunctionOutput, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunction, PartialExcept, isNullOrUndefined, getValueOrDefault, coalesce, coalesceOrDefault, IArvoEventHandler as AbstractArvoEventHandler, ArvoEventHandlerOpenTelemetryOptions, EventHandlerFactory, ContractViolation, ConfigViolation, ExecutionViolation, ArvoMachine, setupArvoMachine, ArvoMachineContext, EnqueueArvoEventActionParam, IMachineRegistry, MachineRegistry, MachineExecutionEngine, IMachineExectionEngine, ExecuteMachineInput, ExecuteMachineOutput, IMachineMemory, SimpleMachineMemory, MachineMemoryRecord, ArvoOrchestratorParam as IArvoOrchestrator, TransactionViolation, TransactionViolationCause, ArvoOrchestrator, createArvoOrchestrator, SimpleEventBroker, createSimpleEventBroker, TelemetredSimpleMachineMemory, xstate, ArvoResumable, createArvoResumable, ArvoResumableHandler, ArvoResumableState, ArvoDomain, resolveEventDomain, };
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveEventDomain = exports.ArvoDomain = exports.createArvoResumable = exports.ArvoResumable = exports.xstate = exports.TelemetredSimpleMachineMemory = exports.createSimpleEventBroker = exports.SimpleEventBroker = exports.createArvoOrchestrator = exports.ArvoOrchestrator = exports.TransactionViolationCause = exports.TransactionViolation = exports.SimpleMachineMemory = exports.MachineExecutionEngine = exports.MachineRegistry = exports.setupArvoMachine = exports.ArvoMachine = exports.ExecutionViolation = exports.ConfigViolation = exports.ContractViolation = exports.
|
|
7
|
-
var AbstractArvoEventHandler_1 = __importDefault(require("./AbstractArvoEventHandler"));
|
|
8
|
-
exports.AbstractArvoEventHandler = AbstractArvoEventHandler_1.default;
|
|
6
|
+
exports.resolveEventDomain = exports.ArvoDomain = exports.createArvoResumable = exports.ArvoResumable = exports.xstate = exports.TelemetredSimpleMachineMemory = exports.createSimpleEventBroker = exports.SimpleEventBroker = exports.createArvoOrchestrator = exports.ArvoOrchestrator = exports.TransactionViolationCause = exports.TransactionViolation = exports.SimpleMachineMemory = exports.MachineExecutionEngine = exports.MachineRegistry = exports.setupArvoMachine = exports.ArvoMachine = exports.ExecutionViolation = exports.ConfigViolation = exports.ContractViolation = exports.coalesceOrDefault = exports.coalesce = exports.getValueOrDefault = exports.isNullOrUndefined = exports.createArvoEventHandler = exports.ArvoEventHandler = void 0;
|
|
9
7
|
var ArvoEventHandler_1 = __importDefault(require("./ArvoEventHandler"));
|
|
10
8
|
exports.ArvoEventHandler = ArvoEventHandler_1.default;
|
|
11
9
|
var helpers_1 = require("./ArvoEventHandler/helpers");
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type IArvoEventHandler from './IArvoEventHandler';
|
|
2
2
|
/**
|
|
3
3
|
* Makes properties optional except specified keys
|
|
4
4
|
*
|
|
@@ -29,4 +29,4 @@ export type ArvoEventHandlerOpenTelemetryOptions = {
|
|
|
29
29
|
*
|
|
30
30
|
* @template T - Configuration object type
|
|
31
31
|
*/
|
|
32
|
-
export type EventHandlerFactory<T = void> = T extends void ? () =>
|
|
32
|
+
export type EventHandlerFactory<T = void> = T extends void ? () => IArvoEventHandler : (config: T) => IArvoEventHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ArvoEvent } from 'arvo-core';
|
|
2
2
|
import { SimpleEventBroker } from '.';
|
|
3
|
-
import type
|
|
3
|
+
import type IArvoEventHandler from '../../IArvoEventHandler';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a local event broker configured with domain event handlers and provides event resolution capabilities
|
|
6
6
|
*
|
|
@@ -153,7 +153,7 @@ import type AbstractArvoEventHandler from '../../AbstractArvoEventHandler';
|
|
|
153
153
|
* without requiring external message brokers, making test suites faster and
|
|
154
154
|
* more reliable while maintaining production-like behavior patterns.
|
|
155
155
|
*/
|
|
156
|
-
export declare const createSimpleEventBroker: (eventHandlers:
|
|
156
|
+
export declare const createSimpleEventBroker: (eventHandlers: IArvoEventHandler[], options?: {
|
|
157
157
|
onError?: (error: Error, event: ArvoEvent) => void;
|
|
158
158
|
onDomainedEvents?: (param: {
|
|
159
159
|
domain: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arvo-event-handler",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "Type-safe event handler system with versioning, telemetry, and contract validation for distributed Arvo event-driven architectures, featuring routing and multi-handler support.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -46,10 +46,11 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@opentelemetry/api": "^1.9.0",
|
|
48
48
|
"@opentelemetry/core": "^1.30.1",
|
|
49
|
-
"arvo-core": "^3.0.
|
|
49
|
+
"arvo-core": "^3.0.7",
|
|
50
50
|
"uuid": "^11.1.0",
|
|
51
|
-
"xstate": "^5.
|
|
52
|
-
"zod": "^3.25.
|
|
51
|
+
"xstate": "^5.23.0",
|
|
52
|
+
"zod": "^3.25.74",
|
|
53
|
+
"zod-to-json-schema": "^3.24.6"
|
|
53
54
|
},
|
|
54
55
|
"engines": {
|
|
55
56
|
"node": ">=18.0.0"
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { ArvoContractRecord, ArvoEvent } from 'arvo-core';
|
|
2
|
-
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Abstract base class for Arvo event handlers.
|
|
5
|
-
*
|
|
6
|
-
* @abstract
|
|
7
|
-
* @description
|
|
8
|
-
* This class defines the basic structure for all Arvo event handlers.
|
|
9
|
-
* It provides an abstract method for executing events, which must be
|
|
10
|
-
* implemented by any concrete subclass.
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export default abstract class AbstractArvoEventHandler {
|
|
14
|
-
/**
|
|
15
|
-
* Unique identifier for the event handler source system
|
|
16
|
-
*/
|
|
17
|
-
abstract source: string;
|
|
18
|
-
/**
|
|
19
|
-
* Executes the event handling logic for a given Arvo event.
|
|
20
|
-
*
|
|
21
|
-
* @abstract
|
|
22
|
-
* @param event - The Arvo event to be processed. This event should conform
|
|
23
|
-
* to the expected schema for the specific handler implementation.
|
|
24
|
-
* @param opentelemetry - Configuration for OpenTelemetry integration
|
|
25
|
-
*
|
|
26
|
-
* @returns {Promise<ArvoEvent[]>} A promise that resolves to an array of resulting Arvo events.
|
|
27
|
-
* These events represent the outcome of processing the input event.
|
|
28
|
-
*
|
|
29
|
-
* @description
|
|
30
|
-
* This method defines the core event processing logic that each concrete handler must implement.
|
|
31
|
-
* It should handle the complete lifecycle of an event, including:
|
|
32
|
-
* - Validation of the input event
|
|
33
|
-
* - Processing of the event according to business rules
|
|
34
|
-
* - Generation of any resulting events
|
|
35
|
-
* - Error handling and reporting
|
|
36
|
-
* - OpenTelemetry integration for observability
|
|
37
|
-
*
|
|
38
|
-
* @throws {Error}
|
|
39
|
-
* - When the input event fails validation
|
|
40
|
-
* - When processing encounters an unrecoverable error
|
|
41
|
-
* - When the handler is unable to properly execute the event
|
|
42
|
-
*
|
|
43
|
-
* @remarks
|
|
44
|
-
* Implementation considerations:
|
|
45
|
-
* - Ensure proper error handling and event validation
|
|
46
|
-
* - Implement appropriate retry logic for transient failures
|
|
47
|
-
* - Use the provided OpenTelemetry configuration for tracing
|
|
48
|
-
* - Consider performance implications for long-running operations
|
|
49
|
-
* - Maintain idempotency where appropriate
|
|
50
|
-
* - Document any specific requirements for event schemas
|
|
51
|
-
*
|
|
52
|
-
* The method should handle observability concerns by:
|
|
53
|
-
* - Creating appropriate spans for tracing
|
|
54
|
-
* - Recording relevant attributes and events
|
|
55
|
-
* - Properly handling span lifecycle (creation and completion)
|
|
56
|
-
* - Propagating context appropriately
|
|
57
|
-
*/
|
|
58
|
-
abstract execute(event: ArvoEvent, opentelemetry: ArvoEventHandlerOpenTelemetryOptions): Promise<{
|
|
59
|
-
events: ArvoEvent[];
|
|
60
|
-
metadata?: Record<string, any>;
|
|
61
|
-
}>;
|
|
62
|
-
/**
|
|
63
|
-
* Provides the schema for system error events.
|
|
64
|
-
*
|
|
65
|
-
* @abstract
|
|
66
|
-
* @returns {ArvoContractRecord} An object containing the error event type and schema.
|
|
67
|
-
*
|
|
68
|
-
* @description
|
|
69
|
-
* This getter should define the structure for system error events that may be emitted
|
|
70
|
-
* when an unexpected error occurs during event handling.
|
|
71
|
-
*
|
|
72
|
-
* @remarks
|
|
73
|
-
* - The returned ArvoContractRecord typically includes:
|
|
74
|
-
* - `type`: A string representing the error event type.
|
|
75
|
-
* - `schema`: The schema definition for the error event.
|
|
76
|
-
* - Implementations should ensure that the error schema is consistent with the
|
|
77
|
-
* overall system's error handling strategy.
|
|
78
|
-
* - The error event type often follows a pattern like 'sys.[eventType].error'.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* public get systemErrorSchema(): ArvoContractRecord {
|
|
83
|
-
* return {
|
|
84
|
-
* type: 'sys.myEvent.error',
|
|
85
|
-
* schema: MyCustomErrorSchema
|
|
86
|
-
* };
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
abstract get systemErrorSchema(): ArvoContractRecord;
|
|
91
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Abstract base class for Arvo event handlers.
|
|
5
|
-
*
|
|
6
|
-
* @abstract
|
|
7
|
-
* @description
|
|
8
|
-
* This class defines the basic structure for all Arvo event handlers.
|
|
9
|
-
* It provides an abstract method for executing events, which must be
|
|
10
|
-
* implemented by any concrete subclass.
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
var AbstractArvoEventHandler = /** @class */ (function () {
|
|
14
|
-
function AbstractArvoEventHandler() {
|
|
15
|
-
}
|
|
16
|
-
return AbstractArvoEventHandler;
|
|
17
|
-
}());
|
|
18
|
-
exports.default = AbstractArvoEventHandler;
|