arvo-event-handler 3.0.10 → 3.0.11

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.
@@ -22,7 +22,7 @@ export type CreateSystemErrorEventsParams = {
22
22
  /**
23
23
  * Creates system error events
24
24
  */
25
- export declare const createSystemErrorEvents: ({ error, event, otelHeaders, orchestrationParentSubject, initEventId, selfContract, systemErrorDomain, executionunits, source, domain, handlerType, }: CreateSystemErrorEventsParams & {
25
+ export declare const createSystemErrorEvents: ({ error, event, otelHeaders, orchestrationParentSubject: _orchestrationParentSubject, initEventId, selfContract, systemErrorDomain, executionunits, source, domain, handlerType, }: CreateSystemErrorEventsParams & {
26
26
  error: Error;
27
27
  }) => ArvoEvent[];
28
28
  export declare const handleOrchestrationErrors: (_handlerType: ArvoOrchestrationHandlerType, param: CreateSystemErrorEventsParams & {
@@ -58,22 +58,26 @@ var types_1 = require("./types");
58
58
  * Creates system error events
59
59
  */
60
60
  var createSystemErrorEvents = function (_a) {
61
- var _b, _c, _d, _e;
62
- var error = _a.error, event = _a.event, otelHeaders = _a.otelHeaders, orchestrationParentSubject = _a.orchestrationParentSubject, initEventId = _a.initEventId, selfContract = _a.selfContract, systemErrorDomain = _a.systemErrorDomain, executionunits = _a.executionunits, source = _a.source, domain = _a.domain, handlerType = _a.handlerType;
61
+ var _b, _c, _d, _e, _f;
62
+ var error = _a.error, event = _a.event, otelHeaders = _a.otelHeaders, _orchestrationParentSubject = _a.orchestrationParentSubject, initEventId = _a.initEventId, selfContract = _a.selfContract, systemErrorDomain = _a.systemErrorDomain, executionunits = _a.executionunits, source = _a.source, domain = _a.domain, handlerType = _a.handlerType;
63
63
  // In case of none transaction errors like errors from
64
64
  // the machine or the event creation etc, the are workflow
65
65
  // error and shuold be handled by the workflow. Then are
66
66
  // called system error and must be sent
67
67
  // to the initiator. In as good of a format as possible
68
68
  var parsedEventSubject = null;
69
- try {
70
- parsedEventSubject = arvo_core_1.ArvoOrchestrationSubject.parse(event.subject);
71
- }
72
- catch (e) {
73
- (0, arvo_core_1.logToSpan)({
74
- level: 'WARNING',
75
- message: "Unable to parse event subject: ".concat(e.message),
76
- });
69
+ var orchestrationParentSubject = null;
70
+ if (handlerType === 'orchestrator' || handlerType === 'resumable') {
71
+ orchestrationParentSubject = _orchestrationParentSubject;
72
+ try {
73
+ parsedEventSubject = arvo_core_1.ArvoOrchestrationSubject.parse(event.subject);
74
+ }
75
+ catch (e) {
76
+ (0, arvo_core_1.logToSpan)({
77
+ level: 'WARNING',
78
+ message: "Unable to parse event subject: ".concat(e.message),
79
+ });
80
+ }
77
81
  }
78
82
  var domainSets = new Set(systemErrorDomain
79
83
  ? systemErrorDomain.map(function (item) {
@@ -86,8 +90,8 @@ var createSystemErrorEvents = function (_a) {
86
90
  })
87
91
  : [event.domain, domain, null]);
88
92
  var result = [];
89
- for (var _i = 0, _f = Array.from(domainSets); _i < _f.length; _i++) {
90
- var _dom = _f[_i];
93
+ for (var _i = 0, _g = Array.from(domainSets); _i < _g.length; _i++) {
94
+ var _dom = _g[_i];
91
95
  var factoryBuilder = handlerType === 'handler' ? arvo_core_1.createArvoEventFactory : arvo_core_1.createArvoOrchestratorEventFactory;
92
96
  result.push(factoryBuilder(selfContract).systemError({
93
97
  source: source,
@@ -98,11 +102,11 @@ var createSystemErrorEvents = function (_a) {
98
102
  subject: orchestrationParentSubject !== null && orchestrationParentSubject !== void 0 ? orchestrationParentSubject : event.subject,
99
103
  // The system error must always go back to
100
104
  // the source which initiated it
101
- to: (_b = parsedEventSubject === null || parsedEventSubject === void 0 ? void 0 : parsedEventSubject.execution.initiator) !== null && _b !== void 0 ? _b : event.source,
105
+ to: (_c = (_b = parsedEventSubject === null || parsedEventSubject === void 0 ? void 0 : parsedEventSubject.execution) === null || _b === void 0 ? void 0 : _b.initiator) !== null && _c !== void 0 ? _c : event.source,
102
106
  error: error,
103
- traceparent: (_c = otelHeaders.traceparent) !== null && _c !== void 0 ? _c : undefined,
104
- tracestate: (_d = otelHeaders.tracestate) !== null && _d !== void 0 ? _d : undefined,
105
- accesscontrol: (_e = event.accesscontrol) !== null && _e !== void 0 ? _e : undefined,
107
+ traceparent: (_d = otelHeaders.traceparent) !== null && _d !== void 0 ? _d : undefined,
108
+ tracestate: (_e = otelHeaders.tracestate) !== null && _e !== void 0 ? _e : undefined,
109
+ accesscontrol: (_f = event.accesscontrol) !== null && _f !== void 0 ? _f : undefined,
106
110
  executionunits: executionunits,
107
111
  // If there is initEventID then use that.
108
112
  // Otherwise, use event id. If the error is in init event
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-event-handler",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
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,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "@opentelemetry/api": "^1.9.0",
48
48
  "@opentelemetry/core": "^1.30.1",
49
- "arvo-core": "^3.0.10",
49
+ "arvo-core": "^3.0.11",
50
50
  "uuid": "^11.1.0",
51
51
  "xstate": "^5.23.0",
52
52
  "zod": "^3.25.74",