arvo-event-handler 3.0.25 → 3.0.26
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 +0 -1
- package/dist/ArvoEventHandler/helpers.js +0 -1
- package/dist/ArvoEventHandler/index.js +6 -6
- package/dist/ArvoEventHandler/types.d.ts +1 -1
- package/dist/ArvoMachine/createMachine.d.ts +19 -10
- package/dist/ArvoOrchestrator/factory.d.ts +0 -1
- package/dist/ArvoOrchestrator/factory.js +4 -5
- package/dist/ArvoOrchestrator/index.js +1 -1
- package/dist/ArvoOrchestrator/types.d.ts +1 -1
- package/dist/ArvoResumable/factory.d.ts +0 -1
- package/dist/ArvoResumable/factory.js +0 -1
- package/package.json +6 -5
|
@@ -14,7 +14,6 @@ import type { ArvoEventHandlerParam } from './types';
|
|
|
14
14
|
* ```ts
|
|
15
15
|
* const handler = createArvoEventHandler({
|
|
16
16
|
* contract: userContract,
|
|
17
|
-
* executionunits: 1,
|
|
18
17
|
* handler: {
|
|
19
18
|
* '1.0.0': async ({ event, domain, span }) => {
|
|
20
19
|
* if (domain.event !== domain.self) {
|
|
@@ -72,18 +72,18 @@ var utils_1 = require("../utils");
|
|
|
72
72
|
var ArvoEventHandler = /** @class */ (function () {
|
|
73
73
|
function ArvoEventHandler(param) {
|
|
74
74
|
var _a;
|
|
75
|
-
var _b, _c, _d;
|
|
75
|
+
var _b, _c, _d, _e;
|
|
76
76
|
this.contract = param.contract;
|
|
77
|
-
this.executionunits = param.executionunits;
|
|
77
|
+
this.executionunits = (_b = param.executionunits) !== null && _b !== void 0 ? _b : 0;
|
|
78
78
|
this.handler = param.handler;
|
|
79
|
-
this.defaultEventEmissionDomains = __assign({ systemError: [ArvoDomain_1.ArvoDomain.ORCHESTRATION_CONTEXT], emits: [ArvoDomain_1.ArvoDomain.ORCHESTRATION_CONTEXT] }, ((
|
|
80
|
-
for (var _i = 0,
|
|
81
|
-
var contractVersions =
|
|
79
|
+
this.defaultEventEmissionDomains = __assign({ systemError: [ArvoDomain_1.ArvoDomain.ORCHESTRATION_CONTEXT], emits: [ArvoDomain_1.ArvoDomain.ORCHESTRATION_CONTEXT] }, ((_c = param.defaultEventEmissionDomains) !== null && _c !== void 0 ? _c : {}));
|
|
80
|
+
for (var _i = 0, _f = Object.keys(this.contract.versions); _i < _f.length; _i++) {
|
|
81
|
+
var contractVersions = _f[_i];
|
|
82
82
|
if (!this.handler[contractVersions]) {
|
|
83
83
|
throw new Error("Contract ".concat(this.contract.uri, " requires handler implementation for version ").concat(contractVersions));
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
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), ((
|
|
86
|
+
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), ((_e = (_d = param.spanOptions) === null || _d === void 0 ? void 0 : _d.attributes) !== null && _e !== void 0 ? _e : {})), { 'arvo.handler.source': this.source, 'arvo.contract.uri': this.contract.uri }) });
|
|
87
87
|
}
|
|
88
88
|
Object.defineProperty(ArvoEventHandler.prototype, "source", {
|
|
89
89
|
/** The source identifier for events produced by this handler */
|
|
@@ -70,7 +70,7 @@ export type ArvoEventHandlerParam<TContract extends ArvoContract> = {
|
|
|
70
70
|
* The default execution cost of the function.
|
|
71
71
|
* This can represent a dollar value or some other number with a rate card.
|
|
72
72
|
*/
|
|
73
|
-
executionunits
|
|
73
|
+
executionunits?: number;
|
|
74
74
|
/**
|
|
75
75
|
* The functional handler of the event which takes the input, performs an action, and returns the result.
|
|
76
76
|
* @param params - The input parameters for the handler function.
|
|
@@ -138,17 +138,23 @@ export declare function setupArvoMachine<TContext extends MachineContext, TSelfC
|
|
|
138
138
|
}, InferServiceContract<TServiceContracts>["emitted"], TMeta>>(config: TConfig & {
|
|
139
139
|
id: string;
|
|
140
140
|
version?: TSelfContract["version"];
|
|
141
|
-
}) => ArvoMachine<string, TSelfContract["version"], TSelfContract, TServiceContracts, import("xstate").StateMachine<TContext, { [K in keyof TServiceContracts]: import("./types").InferEmittableEventsFromVersionedArvoContract<TServiceContracts[K]>; }[keyof TServiceContracts], {}, never,
|
|
141
|
+
}) => ArvoMachine<string, TSelfContract["version"], TSelfContract, TServiceContracts, import("xstate").StateMachine<TContext, { [K in keyof TServiceContracts]: import("./types").InferEmittableEventsFromVersionedArvoContract<TServiceContracts[K]>; }[keyof TServiceContracts], {}, never, (TActions & {
|
|
142
142
|
enqueueArvoEvent: EnqueueArvoEventActionParam;
|
|
143
|
-
}
|
|
144
|
-
type: K_1;
|
|
145
|
-
params:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
type:
|
|
143
|
+
} extends infer T extends Record<string, import("xstate").NonReducibleUnknown> ? { [K_1 in keyof T as K_1 & string]: {
|
|
144
|
+
type: K_1 & string;
|
|
145
|
+
params: T[K_1];
|
|
146
|
+
}; } : never)[keyof (TActions & {
|
|
147
|
+
enqueueArvoEvent: EnqueueArvoEventActionParam;
|
|
148
|
+
} extends infer T_1 extends Record<string, import("xstate").NonReducibleUnknown> ? { [K_1 in keyof T_1 as K_1 & string]: {
|
|
149
|
+
type: K_1 & string;
|
|
150
|
+
params: T_1[K_1];
|
|
151
|
+
}; } : never)], { [K_2 in keyof TGuards as K_2 & string]: {
|
|
152
|
+
type: K_2 & string;
|
|
153
|
+
params: TGuards[K_2];
|
|
154
|
+
}; }[keyof { [K_2 in keyof TGuards as K_2 & string]: {
|
|
155
|
+
type: K_2 & string;
|
|
150
156
|
params: TGuards[K_2];
|
|
151
|
-
}; }
|
|
157
|
+
}; }], never, {} | {
|
|
152
158
|
[x: string]: {} | /*elided*/ any | {
|
|
153
159
|
[x: string]: {} | /*elided*/ any | /*elided*/ any;
|
|
154
160
|
};
|
|
@@ -156,5 +162,8 @@ export declare function setupArvoMachine<TContext extends MachineContext, TSelfC
|
|
|
156
162
|
[x: string]: {} | {
|
|
157
163
|
[x: string]: {} | /*elided*/ any | /*elided*/ any;
|
|
158
164
|
} | /*elided*/ any;
|
|
159
|
-
}, TTag, TSelfContract["accepts"]["schema"]["_output"], { [K_3 in string & keyof TSelfContract["emits"]]: import("arvo-core").InferArvoEvent<import("arvo-core").ArvoEvent<TSelfContract["emits"][K_3]["_output"], Record<string, any>, K_3>>; }[`arvo.orc.${ExtractOrchestratorType<TSelfContract["accepts"]["type"]>}.done`]["data"], { [K_4 in keyof TServiceContracts]: EnqueueArvoEventActionParam<z.input<TServiceContracts[K_4]["accepts"]["schema"]>, TServiceContracts[K_4]["accepts"]["type"], Record<string, string | number | boolean | null>>; }[keyof TServiceContracts], TMeta,
|
|
165
|
+
}, TTag, TSelfContract["accepts"]["schema"]["_output"], { [K_3 in string & keyof TSelfContract["emits"]]: import("arvo-core").InferArvoEvent<import("arvo-core").ArvoEvent<TSelfContract["emits"][K_3]["_output"], Record<string, any>, K_3>>; }[`arvo.orc.${ExtractOrchestratorType<TSelfContract["accepts"]["type"]>}.done`]["data"], { [K_4 in keyof TServiceContracts]: EnqueueArvoEventActionParam<z.input<TServiceContracts[K_4]["accepts"]["schema"]>, TServiceContracts[K_4]["accepts"]["type"], Record<string, string | number | boolean | null>>; }[keyof TServiceContracts], TMeta, {
|
|
166
|
+
id: any;
|
|
167
|
+
states: any;
|
|
168
|
+
}>>;
|
|
160
169
|
};
|
|
@@ -18,7 +18,6 @@ import type { CreateArvoOrchestratorParam } from './types';
|
|
|
18
18
|
* ```typescript
|
|
19
19
|
* const orchestrator = createArvoOrchestrator({
|
|
20
20
|
* memory: new SimpleMachineMemory(),
|
|
21
|
-
* executionunits: 1,
|
|
22
21
|
* machines: [userOnboardingMachine, paymentMachine]
|
|
23
22
|
* });
|
|
24
23
|
*
|
|
@@ -32,7 +32,6 @@ var errors_1 = require("../errors");
|
|
|
32
32
|
* ```typescript
|
|
33
33
|
* const orchestrator = createArvoOrchestrator({
|
|
34
34
|
* memory: new SimpleMachineMemory(),
|
|
35
|
-
* executionunits: 1,
|
|
36
35
|
* machines: [userOnboardingMachine, paymentMachine]
|
|
37
36
|
* });
|
|
38
37
|
*
|
|
@@ -51,16 +50,16 @@ var createArvoOrchestrator = function (_a) {
|
|
|
51
50
|
var registry = new (MachineRegistry_1.MachineRegistry.bind.apply(MachineRegistry_1.MachineRegistry, __spreadArray([void 0], machines, false)))();
|
|
52
51
|
var requiresResourceLocking = _locking !== null && _locking !== void 0 ? _locking : machines.some(function (machine) { return machine.requiresResourceLocking; });
|
|
53
52
|
var representativeMachine = registry.machines[0];
|
|
54
|
-
var lastSeenVersions =
|
|
53
|
+
var lastSeenVersions = new Set();
|
|
55
54
|
for (var _i = 0, _b = registry.machines; _i < _b.length; _i++) {
|
|
56
55
|
var machine = _b[_i];
|
|
57
56
|
if (representativeMachine.source !== machine.source) {
|
|
58
|
-
throw new errors_1.ConfigViolation("All the machines in the orchestrator must have
|
|
57
|
+
throw new errors_1.ConfigViolation("All the machines in the orchestrator must have source '".concat(representativeMachine.source, "'. Make sure all machine are implementing versions of the same self contract"));
|
|
59
58
|
}
|
|
60
|
-
if (lastSeenVersions.
|
|
59
|
+
if (lastSeenVersions.has(machine.version)) {
|
|
61
60
|
throw new errors_1.ConfigViolation("An orchestrator must have unique machine versions. Machine ID:".concat(machine.id, " has duplicate version ").concat(machine.version, "."));
|
|
62
61
|
}
|
|
63
|
-
lastSeenVersions.
|
|
62
|
+
lastSeenVersions.add(machine.version);
|
|
64
63
|
}
|
|
65
64
|
return new _1.ArvoOrchestrator({
|
|
66
65
|
executionunits: executionunits,
|
|
@@ -67,7 +67,7 @@ var ArvoOrchestrator = /** @class */ (function () {
|
|
|
67
67
|
var _b;
|
|
68
68
|
var executionunits = _a.executionunits, memory = _a.memory, registry = _a.registry, executionEngine = _a.executionEngine, requiresResourceLocking = _a.requiresResourceLocking, defaultEventEmissionDomains = _a.defaultEventEmissionDomains, spanOptions = _a.spanOptions;
|
|
69
69
|
var _c, _d, _e, _f, _g, _h, _j;
|
|
70
|
-
this.executionunits = executionunits;
|
|
70
|
+
this.executionunits = executionunits !== null && executionunits !== void 0 ? executionunits : 0;
|
|
71
71
|
this.registry = registry;
|
|
72
72
|
this.executionEngine = executionEngine;
|
|
73
73
|
this.syncEventResource = new SyncEventResource_1.SyncEventResource(memory, requiresResourceLocking);
|
|
@@ -84,7 +84,7 @@ export type MachineMemoryRecord = OrchestrationExecutionMemoryRecord<{
|
|
|
84
84
|
*/
|
|
85
85
|
export type ArvoOrchestratorParam = {
|
|
86
86
|
/** Computational cost metric assigned to orchestrator operations */
|
|
87
|
-
executionunits
|
|
87
|
+
executionunits?: number;
|
|
88
88
|
/** Memory interface for state persistence and retrieval */
|
|
89
89
|
memory: IMachineMemory<MachineMemoryRecord>;
|
|
90
90
|
/** Registry for managing and resolving machine instances */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arvo-event-handler",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.26",
|
|
4
4
|
"description": "A complete set of orthogonal event handler and orchestration primitives for Arvo based applications, featuring declarative state machines (XState), imperative resumables for agentic workflows, contract-based routing, OpenTelemetry observability, and in-memory event broker for building composable event-driven architectures.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -36,10 +36,12 @@
|
|
|
36
36
|
"observability"
|
|
37
37
|
],
|
|
38
38
|
"author": "Saad Ahmad <saadkwi12@hotmail.com>",
|
|
39
|
+
"homepage": "https://www.arvo.land",
|
|
39
40
|
"license": "MIT",
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@biomejs/biome": "1.9.4",
|
|
42
43
|
"@jest/globals": "29.7.0",
|
|
44
|
+
"@opentelemetry/core": "2.2.0",
|
|
43
45
|
"@opentelemetry/auto-instrumentations-node": "0.49.1",
|
|
44
46
|
"@opentelemetry/exporter-metrics-otlp-proto": "0.52.1",
|
|
45
47
|
"@opentelemetry/exporter-trace-otlp-grpc": "0.53.0",
|
|
@@ -64,11 +66,10 @@
|
|
|
64
66
|
},
|
|
65
67
|
"dependencies": {
|
|
66
68
|
"@opentelemetry/api": "1.9.0",
|
|
67
|
-
"
|
|
68
|
-
"arvo-core": "3.0.25",
|
|
69
|
+
"arvo-core": "3.0.26",
|
|
69
70
|
"uuid": "11.1.0",
|
|
70
|
-
"xstate": "5.
|
|
71
|
-
"zod": "3.25.
|
|
71
|
+
"xstate": "5.25.0",
|
|
72
|
+
"zod": "3.25.76",
|
|
72
73
|
"zod-to-json-schema": "3.25.0"
|
|
73
74
|
},
|
|
74
75
|
"engines": {
|