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.
Files changed (46) hide show
  1. package/dist/ArvoEventHandler/helpers.d.ts +2 -2
  2. package/dist/ArvoEventHandler/index.d.ts +4 -4
  3. package/dist/ArvoEventHandler/index.js +13 -34
  4. package/dist/ArvoEventHandler/types.d.ts +5 -3
  5. package/dist/ArvoMachine/createMachine.d.ts +4 -2
  6. package/dist/ArvoMachine/createMachine.js +1 -1
  7. package/dist/ArvoMachine/types.d.ts +5 -1
  8. package/dist/ArvoOrchestrationUtils/createEmitableEvent.d.ts +30 -0
  9. package/dist/ArvoOrchestrationUtils/createEmitableEvent.js +160 -0
  10. package/dist/ArvoOrchestrationUtils/error.d.ts +18 -0
  11. package/dist/{ArvoOrchestrator → ArvoOrchestrationUtils}/error.js +14 -9
  12. package/dist/ArvoOrchestrationUtils/handlerErrors.d.ts +35 -0
  13. package/dist/ArvoOrchestrationUtils/handlerErrors.js +184 -0
  14. package/dist/ArvoOrchestrationUtils/orchestrationExecutionState.d.ts +11 -0
  15. package/dist/ArvoOrchestrationUtils/orchestrationExecutionState.js +7 -0
  16. package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/acquireLockWithValidation.d.ts +8 -0
  17. package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/acquireLockWithValidation.js +69 -0
  18. package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/index.d.ts +40 -0
  19. package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/index.js +228 -0
  20. package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/validateAndParseSubject.d.ts +7 -0
  21. package/dist/ArvoOrchestrationUtils/orchestrationExecutionWrapper/validateAndParseSubject.js +25 -0
  22. package/dist/ArvoOrchestrationUtils/types.d.ts +1 -0
  23. package/dist/ArvoOrchestrationUtils/types.js +2 -0
  24. package/dist/ArvoOrchestrator/factory.js +13 -0
  25. package/dist/ArvoOrchestrator/index.d.ts +5 -21
  26. package/dist/ArvoOrchestrator/index.js +93 -505
  27. package/dist/ArvoOrchestrator/types.d.ts +5 -4
  28. package/dist/ArvoResumable/factory.d.ts +2 -2
  29. package/dist/ArvoResumable/factory.js +1 -1
  30. package/dist/ArvoResumable/index.d.ts +6 -20
  31. package/dist/ArvoResumable/index.js +85 -462
  32. package/dist/ArvoResumable/types.d.ts +8 -5
  33. package/dist/IArvoEventHandler/index.d.ts +36 -0
  34. package/dist/IArvoEventHandler/index.js +2 -0
  35. package/dist/MachineExecutionEngine/index.d.ts +1 -1
  36. package/dist/MachineRegistry/index.d.ts +1 -1
  37. package/dist/SyncEventResource/index.d.ts +1 -1
  38. package/dist/SyncEventResource/index.js +1 -1
  39. package/dist/index.d.ts +14 -13
  40. package/dist/index.js +24 -23
  41. package/dist/types.d.ts +2 -2
  42. package/dist/utils/SimpleEventBroker/helper.d.ts +2 -2
  43. package/package.json +5 -4
  44. package/dist/AbstractArvoEventHandler/index.d.ts +0 -91
  45. package/dist/AbstractArvoEventHandler/index.js +0 -18
  46. package/dist/ArvoOrchestrator/error.d.ts +0 -16
@@ -1,6 +1,7 @@
1
1
  import type { ArvoEvent, InferArvoEvent } from 'arvo-core';
2
2
  import type { Snapshot } from 'xstate';
3
3
  import type ArvoMachine from '../ArvoMachine';
4
+ import type { OrchestrationExecutionMemoryRecord } from '../ArvoOrchestrationUtils/orchestrationExecutionState';
4
5
  import type { IMachineExectionEngine } from '../MachineExecutionEngine/interface';
5
6
  import type { IMachineMemory } from '../MachineMemory/interface';
6
7
  import type { IMachineRegistry } from '../MachineRegistry/interface';
@@ -14,7 +15,7 @@ export type TryFunctionOutput<TData, TError extends Error> = {
14
15
  /**
15
16
  * Represents the state record stored in machine memory.
16
17
  */
17
- export type MachineMemoryRecord = {
18
+ export type MachineMemoryRecord = OrchestrationExecutionMemoryRecord<{
18
19
  /** Unique identifier for the machine instance */
19
20
  subject: string;
20
21
  /**
@@ -67,11 +68,11 @@ export type MachineMemoryRecord = {
67
68
  };
68
69
  /** Machine definition string */
69
70
  machineDefinition: string | null;
70
- };
71
+ }>;
71
72
  /**
72
73
  * Interface defining the core components of an Arvo orchestrator.
73
74
  */
74
- export interface IArvoOrchestrator {
75
+ export type ArvoOrchestratorParam = {
75
76
  /** The cost of the execution of the orchestrator */
76
77
  executionunits: number;
77
78
  /** Memory interface for storing and retrieving machine state */
@@ -85,7 +86,7 @@ export interface IArvoOrchestrator {
85
86
  * Optional configuration to customize where system error events are emitted.
86
87
  */
87
88
  systemErrorDomain?: (string | null)[];
88
- }
89
+ };
89
90
  /**
90
91
  * Configuration interface for creating an Arvo orchestrator instance.
91
92
  */
@@ -1,7 +1,7 @@
1
1
  import type { ArvoOrchestratorContract, VersionedArvoContract } from 'arvo-core';
2
- import type { ArvoResumableHandler, ArvoResumableState } from './types';
3
- import type { IMachineMemory } from '../MachineMemory/interface';
4
2
  import { ArvoResumable } from '.';
3
+ import type { IMachineMemory } from '../MachineMemory/interface';
4
+ import type { ArvoResumableHandler, ArvoResumableState } from './types';
5
5
  /**
6
6
  * Factory function for creating ArvoResumable orchestrator instances
7
7
  *
@@ -12,9 +12,9 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.createArvoResumable = void 0;
15
+ var uuid_1 = require("uuid");
15
16
  var _1 = require(".");
16
17
  var utils_1 = require("../ArvoMachine/utils");
17
- var uuid_1 = require("uuid");
18
18
  /**
19
19
  * Factory function for creating ArvoResumable orchestrator instances
20
20
  *
@@ -1,11 +1,11 @@
1
- import { type ArvoEvent, type ArvoOrchestratorContract, type VersionedArvoContract, type OpenTelemetryHeaders, type ArvoSemanticVersion } from 'arvo-core';
1
+ import type { Span } from '@opentelemetry/api';
2
+ import { type ArvoEvent, type ArvoOrchestratorContract, type VersionedArvoContract } from 'arvo-core';
2
3
  import type { z } from 'zod';
3
- import type { ArvoResumableHandler, ArvoResumableState } from './types';
4
+ import type IArvoEventHandler from '../IArvoEventHandler';
4
5
  import type { IMachineMemory } from '../MachineMemory/interface';
5
6
  import { SyncEventResource } from '../SyncEventResource/index';
6
- import type { EnqueueArvoEventActionParam } from '../ArvoMachine/types';
7
- import AbstractArvoEventHandler from '../AbstractArvoEventHandler';
8
7
  import type { ArvoEventHandlerOpenTelemetryOptions } from '../types';
8
+ import type { ArvoResumableHandler, ArvoResumableState } from './types';
9
9
  /**
10
10
  * ArvoResumable - A stateful orchestration handler for managing distributed workflows
11
11
  *
@@ -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>>> extends AbstractArvoEventHandler {
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;
@@ -61,23 +61,9 @@ export declare class ArvoResumable<TMemory extends Record<string, any> = Record<
61
61
  handler: ArvoResumableHandler<ArvoResumableState<TMemory>, TSelfContract, TServiceContract>;
62
62
  systemErrorDomain?: (string | null)[];
63
63
  });
64
- protected validateInput(event: ArvoEvent): {
64
+ protected validateInput(event: ArvoEvent, span: Span): {
65
65
  contractType: 'self' | 'service';
66
66
  };
67
- /**
68
- * Creates emittable event from execution result
69
- * @param event - Source event to emit
70
- * @param otelHeaders - OpenTelemetry headers
71
- * @param orchestrationParentSubject - Parent orchestration subject
72
- * @param sourceEvent - Original triggering event
73
- * @param selfVersionedContract - The self versioned contract
74
- * @param initEventId - The id of the event which initiated the orchestration in the first place
75
- * @param _domain - The domain of the event.
76
- *
77
- * @throws {ContractViolation} On schema/contract mismatch
78
- * @throws {ExecutionViolation} On invalid parentSubject$$ format
79
- */
80
- protected createEmittableEvent(event: EnqueueArvoEventActionParam, otelHeaders: OpenTelemetryHeaders, orchestrationParentSubject: string | null, sourceEvent: ArvoEvent, selfVersionedContract: VersionedArvoContract<TSelfContract, ArvoSemanticVersion>, initEventId: string, _domain: string | null): ArvoEvent;
81
67
  /**
82
68
  * Executes the orchestration workflow for an incoming event
83
69
  *