arvo-event-handler 3.0.6 → 3.0.8
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 +13 -34
- package/dist/ArvoEventHandler/types.d.ts +5 -3
- package/dist/ArvoMachine/createMachine.d.ts +4 -2
- package/dist/ArvoMachine/createMachine.js +1 -1
- package/dist/ArvoMachine/types.d.ts +5 -1
- package/dist/ArvoOrchestrationUtils/createEmitableEvent.d.ts +30 -0
- package/dist/ArvoOrchestrationUtils/createEmitableEvent.js +160 -0
- package/dist/ArvoOrchestrationUtils/error.d.ts +18 -0
- package/dist/{ArvoOrchestrator → ArvoOrchestrationUtils}/error.js +14 -9
- package/dist/ArvoOrchestrationUtils/handlerErrors.d.ts +35 -0
- package/dist/ArvoOrchestrationUtils/handlerErrors.js +184 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionState.d.ts +11 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionState.js +7 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/acquireLockWithValidation.d.ts +8 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/acquireLockWithValidation.js +69 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/index.d.ts +40 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/index.js +228 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/validateAndParseSubject.d.ts +7 -0
- package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/validateAndParseSubject.js +25 -0
- package/dist/ArvoOrchestrationUtils/types.d.ts +1 -0
- package/dist/ArvoOrchestrationUtils/types.js +2 -0
- package/dist/ArvoOrchestrator/factory.js +13 -0
- package/dist/ArvoOrchestrator/index.d.ts +5 -21
- package/dist/ArvoOrchestrator/index.js +93 -505
- package/dist/ArvoOrchestrator/types.d.ts +5 -4
- package/dist/ArvoResumable/factory.d.ts +2 -2
- package/dist/ArvoResumable/factory.js +1 -1
- package/dist/ArvoResumable/index.d.ts +6 -20
- package/dist/ArvoResumable/index.js +85 -462
- package/dist/ArvoResumable/types.d.ts +8 -5
- package/dist/IArvoEventHandler/index.d.ts +36 -0
- package/dist/IArvoEventHandler/index.js +2 -0
- package/dist/MachineExecutionEngine/index.d.ts +1 -1
- package/dist/MachineRegistry/index.d.ts +1 -1
- package/dist/SyncEventResource/index.d.ts +1 -1
- package/dist/SyncEventResource/index.js +1 -1
- package/dist/index.d.ts +14 -13
- package/dist/index.js +24 -23
- 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
- package/dist/ArvoOrchestrator/error.d.ts +0 -16
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { VersionedArvoContract, ArvoSemanticVersion, InferVersionedArvoContract, ArvoContract, ArvoEvent, InferArvoEvent } from 'arvo-core';
|
|
2
|
-
import type { EnqueueArvoEventActionParam } from '../ArvoMachine/types';
|
|
3
1
|
import type { Span } from '@opentelemetry/api';
|
|
2
|
+
import type { ArvoContract, ArvoEvent, ArvoSemanticVersion, CreateArvoEvent, InferArvoEvent, InferVersionedArvoContract, VersionedArvoContract } from 'arvo-core';
|
|
3
|
+
import type { EnqueueArvoEventActionParam } from '../ArvoMachine/types';
|
|
4
|
+
import type { OrchestrationExecutionMemoryRecord } from '../ArvoOrchestrationUtils/orchestrationExecutionState';
|
|
4
5
|
type ExtractServiceEventTypes<TServiceContract extends Record<string, VersionedArvoContract<any, any>>> = {
|
|
5
6
|
[K in keyof TServiceContract]: {
|
|
6
7
|
[L in keyof InferVersionedArvoContract<TServiceContract[K]>['emits']]: {
|
|
@@ -41,7 +42,9 @@ type Handler<TState extends ArvoResumableState<Record<string, any>>, TSelfContra
|
|
|
41
42
|
context?: TState['state$$'];
|
|
42
43
|
output?: {
|
|
43
44
|
[L in keyof InferVersionedArvoContract<TSelfContract>['emits']]: EnqueueArvoEventActionParam<InferVersionedArvoContract<TSelfContract>['emits'][L]['data'], InferVersionedArvoContract<TSelfContract>['emits'][L]['type']>['data'];
|
|
44
|
-
}[keyof InferVersionedArvoContract<TSelfContract>['emits']]
|
|
45
|
+
}[keyof InferVersionedArvoContract<TSelfContract>['emits']] & {
|
|
46
|
+
__id?: CreateArvoEvent<Record<string, unknown>, string>['id'];
|
|
47
|
+
};
|
|
45
48
|
services?: Array<{
|
|
46
49
|
[K in keyof TServiceContract]: EnqueueArvoEventActionParam<InferVersionedArvoContract<TServiceContract[K]>['accepts']['data'], InferVersionedArvoContract<TServiceContract[K]>['accepts']['type']>;
|
|
47
50
|
}[keyof TServiceContract]>;
|
|
@@ -86,7 +89,7 @@ type Handler<TState extends ArvoResumableState<Record<string, any>>, TSelfContra
|
|
|
86
89
|
export type ArvoResumableHandler<TState extends ArvoResumableState<Record<string, any>>, TSelfContract extends ArvoContract, TServiceContract extends Record<string, VersionedArvoContract<any, any>>> = {
|
|
87
90
|
[V in ArvoSemanticVersion & keyof TSelfContract['versions']]: Handler<TState, VersionedArvoContract<TSelfContract, V>, TServiceContract>;
|
|
88
91
|
};
|
|
89
|
-
export type ArvoResumableState<T extends Record<string, any>> = {
|
|
92
|
+
export type ArvoResumableState<T extends Record<string, any>> = OrchestrationExecutionMemoryRecord<{
|
|
90
93
|
/**
|
|
91
94
|
* Current execution status of the orchestration workflow
|
|
92
95
|
*
|
|
@@ -147,5 +150,5 @@ export type ArvoResumableState<T extends Record<string, any>> = {
|
|
|
147
150
|
};
|
|
148
151
|
/** The state used by the resumable */
|
|
149
152
|
state$$: T | null;
|
|
150
|
-
}
|
|
153
|
+
}>;
|
|
151
154
|
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Provides the schema for system error events.
|
|
29
|
+
*
|
|
30
|
+
* @returns An object containing the error event type and schema.
|
|
31
|
+
*
|
|
32
|
+
* This defines the structure for system error events that may be emitted
|
|
33
|
+
* when an unexpected error occurs during event handling.
|
|
34
|
+
*/
|
|
35
|
+
systemErrorSchema: ArvoContractRecord;
|
|
36
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
1
2
|
import type { IMachineExectionEngine } from './interface';
|
|
2
3
|
import type { ExecuteMachineInput, ExecuteMachineOutput } from './types';
|
|
3
|
-
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Handles state machine execution, event processing, and lifecycle management.
|
|
6
6
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ArvoEvent } from 'arvo-core';
|
|
2
2
|
import type ArvoMachine from '../ArvoMachine';
|
|
3
|
-
import type { IMachineRegistry } from './interface';
|
|
4
3
|
import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
|
|
4
|
+
import type { IMachineRegistry } from './interface';
|
|
5
5
|
/**
|
|
6
6
|
* Registry for managing and resolving ArvoMachine instances.
|
|
7
7
|
* Provides functionality to store multiple machine instances and resolve them based on events.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Span } from '@opentelemetry/api';
|
|
1
2
|
import { type ArvoEvent } from 'arvo-core';
|
|
2
3
|
import type { IMachineMemory } from '../MachineMemory/interface';
|
|
3
4
|
import type { AcquiredLockStatusType, ReleasedLockStatusType } from './types';
|
|
4
|
-
import type { Span } from '@opentelemetry/api';
|
|
5
5
|
/**
|
|
6
6
|
* A synchronous event resource that manages machine memory state based on event subjects.
|
|
7
7
|
*
|
|
@@ -38,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.SyncEventResource = void 0;
|
|
40
40
|
var arvo_core_1 = require("arvo-core");
|
|
41
|
-
var error_1 = require("../
|
|
41
|
+
var error_1 = require("../ArvoOrchestrationUtils/error");
|
|
42
42
|
var errors_1 = require("../errors");
|
|
43
43
|
/**
|
|
44
44
|
* A synchronous event resource that manages machine memory state based on event subjects.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { assign, emit } from 'xstate';
|
|
2
|
+
import { ArvoDomain, resolveEventDomain } from './ArvoDomain';
|
|
2
3
|
import ArvoEventHandler from './ArvoEventHandler';
|
|
3
4
|
import { createArvoEventHandler } from './ArvoEventHandler/helpers';
|
|
4
|
-
import { ArvoEventHandlerFunction, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunctionOutput
|
|
5
|
-
import { ConfigViolation, ContractViolation, ExecutionViolation } from './errors';
|
|
6
|
-
import { ArvoEventHandlerOpenTelemetryOptions, EventHandlerFactory, PartialExcept } from './types';
|
|
7
|
-
import { coalesce, coalesceOrDefault, getValueOrDefault, isNullOrUndefined } from './utils';
|
|
8
|
-
import { assign, emit } from 'xstate';
|
|
5
|
+
import { ArvoEventHandlerFunction, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunctionOutput } from './ArvoEventHandler/types';
|
|
9
6
|
import ArvoMachine from './ArvoMachine';
|
|
10
7
|
import { setupArvoMachine } from './ArvoMachine/createMachine';
|
|
11
8
|
import { ArvoMachineContext, EnqueueArvoEventActionParam } from './ArvoMachine/types';
|
|
9
|
+
import { isTransactionViolationError, TransactionViolation, TransactionViolationCause } from './ArvoOrchestrationUtils/error';
|
|
12
10
|
import { ArvoOrchestrator } from './ArvoOrchestrator';
|
|
13
|
-
import { TransactionViolation, TransactionViolationCause } from './ArvoOrchestrator/error';
|
|
14
11
|
import { createArvoOrchestrator } from './ArvoOrchestrator/factory';
|
|
15
|
-
import {
|
|
12
|
+
import { ArvoOrchestratorParam, MachineMemoryRecord } from './ArvoOrchestrator/types';
|
|
13
|
+
import { ArvoResumable } from './ArvoResumable';
|
|
14
|
+
import { createArvoResumable } from './ArvoResumable/factory';
|
|
15
|
+
import { ArvoResumableHandler, ArvoResumableState } from './ArvoResumable/types';
|
|
16
|
+
import IArvoEventHandler from './IArvoEventHandler';
|
|
16
17
|
import { MachineExecutionEngine } from './MachineExecutionEngine';
|
|
17
18
|
import { IMachineExectionEngine } from './MachineExecutionEngine/interface';
|
|
18
19
|
import { ExecuteMachineInput, ExecuteMachineOutput } from './MachineExecutionEngine/types';
|
|
@@ -21,14 +22,14 @@ import { TelemetredSimpleMachineMemory } from './MachineMemory/TelemetredSimple'
|
|
|
21
22
|
import { IMachineMemory } from './MachineMemory/interface';
|
|
22
23
|
import { MachineRegistry } from './MachineRegistry';
|
|
23
24
|
import { IMachineRegistry } from './MachineRegistry/interface';
|
|
25
|
+
import { ConfigViolation, ContractViolation, ExecutionViolation } from './errors';
|
|
26
|
+
import { ArvoEventHandlerOpenTelemetryOptions, EventHandlerFactory, PartialExcept } from './types';
|
|
27
|
+
import { coalesce, coalesceOrDefault, getValueOrDefault, isNullOrUndefined } from './utils';
|
|
24
28
|
import { SimpleEventBroker } from './utils/SimpleEventBroker';
|
|
25
29
|
import { createSimpleEventBroker } from './utils/SimpleEventBroker/helper';
|
|
26
|
-
import {
|
|
27
|
-
import { createArvoResumable } from './ArvoResumable/factory';
|
|
28
|
-
import { ArvoResumableHandler, ArvoResumableState } from './ArvoResumable/types';
|
|
29
|
-
import { ArvoDomain, resolveEventDomain } from './ArvoDomain';
|
|
30
|
+
import { OrchestrationExecutionStatus } from './ArvoOrchestrationUtils/orchestrationExecutionState';
|
|
30
31
|
declare const xstate: {
|
|
31
32
|
emit: typeof emit;
|
|
32
33
|
assign: typeof assign;
|
|
33
34
|
};
|
|
34
|
-
export { ArvoEventHandler, createArvoEventHandler, IArvoEventHandler, ArvoEventHandlerFunctionOutput, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunction, PartialExcept, isNullOrUndefined, getValueOrDefault, coalesce, coalesceOrDefault,
|
|
35
|
+
export { ArvoEventHandler, createArvoEventHandler, IArvoEventHandler, ArvoEventHandlerFunctionOutput, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunction, PartialExcept, isNullOrUndefined, getValueOrDefault, coalesce, coalesceOrDefault, ArvoEventHandlerOpenTelemetryOptions, EventHandlerFactory, ContractViolation, ConfigViolation, ExecutionViolation, ArvoMachine, setupArvoMachine, ArvoMachineContext, EnqueueArvoEventActionParam, IMachineRegistry, MachineRegistry, MachineExecutionEngine, IMachineExectionEngine, ExecuteMachineInput, ExecuteMachineOutput, IMachineMemory, SimpleMachineMemory, MachineMemoryRecord, ArvoOrchestratorParam, TransactionViolation, TransactionViolationCause, ArvoOrchestrator, createArvoOrchestrator, SimpleEventBroker, createSimpleEventBroker, TelemetredSimpleMachineMemory, xstate, ArvoResumable, createArvoResumable, ArvoResumableHandler, ArvoResumableState, ArvoDomain, resolveEventDomain, isTransactionViolationError, OrchestrationExecutionStatus };
|
package/dist/index.js
CHANGED
|
@@ -3,34 +3,31 @@ 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
|
|
8
|
-
|
|
6
|
+
exports.OrchestrationExecutionStatus = exports.isTransactionViolationError = 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;
|
|
7
|
+
var xstate_1 = require("xstate");
|
|
8
|
+
var ArvoDomain_1 = require("./ArvoDomain");
|
|
9
|
+
Object.defineProperty(exports, "ArvoDomain", { enumerable: true, get: function () { return ArvoDomain_1.ArvoDomain; } });
|
|
10
|
+
Object.defineProperty(exports, "resolveEventDomain", { enumerable: true, get: function () { return ArvoDomain_1.resolveEventDomain; } });
|
|
9
11
|
var ArvoEventHandler_1 = __importDefault(require("./ArvoEventHandler"));
|
|
10
12
|
exports.ArvoEventHandler = ArvoEventHandler_1.default;
|
|
11
13
|
var helpers_1 = require("./ArvoEventHandler/helpers");
|
|
12
14
|
Object.defineProperty(exports, "createArvoEventHandler", { enumerable: true, get: function () { return helpers_1.createArvoEventHandler; } });
|
|
13
|
-
var errors_1 = require("./errors");
|
|
14
|
-
Object.defineProperty(exports, "ConfigViolation", { enumerable: true, get: function () { return errors_1.ConfigViolation; } });
|
|
15
|
-
Object.defineProperty(exports, "ContractViolation", { enumerable: true, get: function () { return errors_1.ContractViolation; } });
|
|
16
|
-
Object.defineProperty(exports, "ExecutionViolation", { enumerable: true, get: function () { return errors_1.ExecutionViolation; } });
|
|
17
|
-
var utils_1 = require("./utils");
|
|
18
|
-
Object.defineProperty(exports, "coalesce", { enumerable: true, get: function () { return utils_1.coalesce; } });
|
|
19
|
-
Object.defineProperty(exports, "coalesceOrDefault", { enumerable: true, get: function () { return utils_1.coalesceOrDefault; } });
|
|
20
|
-
Object.defineProperty(exports, "getValueOrDefault", { enumerable: true, get: function () { return utils_1.getValueOrDefault; } });
|
|
21
|
-
Object.defineProperty(exports, "isNullOrUndefined", { enumerable: true, get: function () { return utils_1.isNullOrUndefined; } });
|
|
22
|
-
var xstate_1 = require("xstate");
|
|
23
15
|
var ArvoMachine_1 = __importDefault(require("./ArvoMachine"));
|
|
24
16
|
exports.ArvoMachine = ArvoMachine_1.default;
|
|
25
17
|
var createMachine_1 = require("./ArvoMachine/createMachine");
|
|
26
18
|
Object.defineProperty(exports, "setupArvoMachine", { enumerable: true, get: function () { return createMachine_1.setupArvoMachine; } });
|
|
27
|
-
var
|
|
28
|
-
Object.defineProperty(exports, "
|
|
29
|
-
var error_1 = require("./ArvoOrchestrator/error");
|
|
19
|
+
var error_1 = require("./ArvoOrchestrationUtils/error");
|
|
20
|
+
Object.defineProperty(exports, "isTransactionViolationError", { enumerable: true, get: function () { return error_1.isTransactionViolationError; } });
|
|
30
21
|
Object.defineProperty(exports, "TransactionViolation", { enumerable: true, get: function () { return error_1.TransactionViolation; } });
|
|
31
22
|
Object.defineProperty(exports, "TransactionViolationCause", { enumerable: true, get: function () { return error_1.TransactionViolationCause; } });
|
|
23
|
+
var ArvoOrchestrator_1 = require("./ArvoOrchestrator");
|
|
24
|
+
Object.defineProperty(exports, "ArvoOrchestrator", { enumerable: true, get: function () { return ArvoOrchestrator_1.ArvoOrchestrator; } });
|
|
32
25
|
var factory_1 = require("./ArvoOrchestrator/factory");
|
|
33
26
|
Object.defineProperty(exports, "createArvoOrchestrator", { enumerable: true, get: function () { return factory_1.createArvoOrchestrator; } });
|
|
27
|
+
var ArvoResumable_1 = require("./ArvoResumable");
|
|
28
|
+
Object.defineProperty(exports, "ArvoResumable", { enumerable: true, get: function () { return ArvoResumable_1.ArvoResumable; } });
|
|
29
|
+
var factory_2 = require("./ArvoResumable/factory");
|
|
30
|
+
Object.defineProperty(exports, "createArvoResumable", { enumerable: true, get: function () { return factory_2.createArvoResumable; } });
|
|
34
31
|
var MachineExecutionEngine_1 = require("./MachineExecutionEngine");
|
|
35
32
|
Object.defineProperty(exports, "MachineExecutionEngine", { enumerable: true, get: function () { return MachineExecutionEngine_1.MachineExecutionEngine; } });
|
|
36
33
|
var Simple_1 = require("./MachineMemory/Simple");
|
|
@@ -39,17 +36,21 @@ var TelemetredSimple_1 = require("./MachineMemory/TelemetredSimple");
|
|
|
39
36
|
Object.defineProperty(exports, "TelemetredSimpleMachineMemory", { enumerable: true, get: function () { return TelemetredSimple_1.TelemetredSimpleMachineMemory; } });
|
|
40
37
|
var MachineRegistry_1 = require("./MachineRegistry");
|
|
41
38
|
Object.defineProperty(exports, "MachineRegistry", { enumerable: true, get: function () { return MachineRegistry_1.MachineRegistry; } });
|
|
39
|
+
var errors_1 = require("./errors");
|
|
40
|
+
Object.defineProperty(exports, "ConfigViolation", { enumerable: true, get: function () { return errors_1.ConfigViolation; } });
|
|
41
|
+
Object.defineProperty(exports, "ContractViolation", { enumerable: true, get: function () { return errors_1.ContractViolation; } });
|
|
42
|
+
Object.defineProperty(exports, "ExecutionViolation", { enumerable: true, get: function () { return errors_1.ExecutionViolation; } });
|
|
43
|
+
var utils_1 = require("./utils");
|
|
44
|
+
Object.defineProperty(exports, "coalesce", { enumerable: true, get: function () { return utils_1.coalesce; } });
|
|
45
|
+
Object.defineProperty(exports, "coalesceOrDefault", { enumerable: true, get: function () { return utils_1.coalesceOrDefault; } });
|
|
46
|
+
Object.defineProperty(exports, "getValueOrDefault", { enumerable: true, get: function () { return utils_1.getValueOrDefault; } });
|
|
47
|
+
Object.defineProperty(exports, "isNullOrUndefined", { enumerable: true, get: function () { return utils_1.isNullOrUndefined; } });
|
|
42
48
|
var SimpleEventBroker_1 = require("./utils/SimpleEventBroker");
|
|
43
49
|
Object.defineProperty(exports, "SimpleEventBroker", { enumerable: true, get: function () { return SimpleEventBroker_1.SimpleEventBroker; } });
|
|
44
50
|
var helper_1 = require("./utils/SimpleEventBroker/helper");
|
|
45
51
|
Object.defineProperty(exports, "createSimpleEventBroker", { enumerable: true, get: function () { return helper_1.createSimpleEventBroker; } });
|
|
46
|
-
var
|
|
47
|
-
Object.defineProperty(exports, "
|
|
48
|
-
var factory_2 = require("./ArvoResumable/factory");
|
|
49
|
-
Object.defineProperty(exports, "createArvoResumable", { enumerable: true, get: function () { return factory_2.createArvoResumable; } });
|
|
50
|
-
var ArvoDomain_1 = require("./ArvoDomain");
|
|
51
|
-
Object.defineProperty(exports, "ArvoDomain", { enumerable: true, get: function () { return ArvoDomain_1.ArvoDomain; } });
|
|
52
|
-
Object.defineProperty(exports, "resolveEventDomain", { enumerable: true, get: function () { return ArvoDomain_1.resolveEventDomain; } });
|
|
52
|
+
var orchestrationExecutionState_1 = require("./ArvoOrchestrationUtils/orchestrationExecutionState");
|
|
53
|
+
Object.defineProperty(exports, "OrchestrationExecutionStatus", { enumerable: true, get: function () { return orchestrationExecutionState_1.OrchestrationExecutionStatus; } });
|
|
53
54
|
var xstate = {
|
|
54
55
|
emit: xstate_1.emit,
|
|
55
56
|
assign: xstate_1.assign,
|
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.8",
|
|
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.8",
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type ArvoEvent, ViolationError } from 'arvo-core';
|
|
2
|
-
export declare enum TransactionViolationCause {
|
|
3
|
-
READ_FAILURE = "READ_MACHINE_MEMORY_FAILURE",
|
|
4
|
-
LOCK_FAILURE = "LOCK_MACHINE_MEMORY_FAILURE",
|
|
5
|
-
WRITE_FAILURE = "WRITE_MACHINE_MEMORY_FAILURE",
|
|
6
|
-
LOCK_UNACQUIRED = "LOCK_UNACQUIRED",
|
|
7
|
-
INVALID_SUBJECT = "INVALID_SUBJECT"
|
|
8
|
-
}
|
|
9
|
-
export declare class TransactionViolation extends ViolationError<'OrchestratorTransaction'> {
|
|
10
|
-
readonly cause: TransactionViolationCause;
|
|
11
|
-
constructor(param: {
|
|
12
|
-
cause: TransactionViolationCause;
|
|
13
|
-
message: string;
|
|
14
|
-
initiatingEvent: ArvoEvent;
|
|
15
|
-
});
|
|
16
|
-
}
|