arvo-event-handler 2.2.13 → 2.3.0

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.
@@ -55,7 +55,10 @@ export default abstract class AbstractArvoEventHandler {
55
55
  * - Properly handling span lifecycle (creation and completion)
56
56
  * - Propagating context appropriately
57
57
  */
58
- abstract execute(event: ArvoEvent, opentelemetry: ArvoEventHandlerOpenTelemetryOptions): Promise<ArvoEvent[]>;
58
+ abstract execute(event: ArvoEvent, opentelemetry: ArvoEventHandlerOpenTelemetryOptions): Promise<{
59
+ events: ArvoEvent[];
60
+ [key: string]: unknown;
61
+ }>;
59
62
  /**
60
63
  * Provides the schema for system error events.
61
64
  *
@@ -99,7 +99,9 @@ export default class ArvoEventHandler<TContract extends ArvoContract> extends Ab
99
99
  * in handler configuration
100
100
  * @throws `ExecutionViolation` for explicitly handled runtime errors
101
101
  */
102
- execute(event: ArvoEvent, opentelemetry?: ArvoEventHandlerOpenTelemetryOptions): Promise<ArvoEvent[]>;
102
+ execute(event: ArvoEvent, opentelemetry?: ArvoEventHandlerOpenTelemetryOptions): Promise<{
103
+ events: ArvoEvent[];
104
+ }>;
103
105
  /**
104
106
  * Provides access to the system error event schema configuration.
105
107
  * The schema defines the structure of error events emitted during execution failures.
@@ -257,7 +257,9 @@ var ArvoEventHandler = /** @class */ (function (_super) {
257
257
  case 2:
258
258
  _handleOutput = _k.sent();
259
259
  if (!_handleOutput)
260
- return [2 /*return*/, []];
260
+ return [2 /*return*/, {
261
+ events: [],
262
+ }];
261
263
  outputs = [];
262
264
  if (Array.isArray(_handleOutput)) {
263
265
  outputs = _handleOutput;
@@ -282,7 +284,9 @@ var ArvoEventHandler = /** @class */ (function (_super) {
282
284
  level: 'INFO',
283
285
  message: 'Event handled successfully',
284
286
  });
285
- return [2 /*return*/, result];
287
+ return [2 /*return*/, {
288
+ events: result,
289
+ }];
286
290
  case 3:
287
291
  error_1 = _k.sent();
288
292
  (0, arvo_core_1.exceptionToSpan)(error_1);
@@ -310,7 +314,9 @@ var ArvoEventHandler = /** @class */ (function (_super) {
310
314
  _e = _d[_c], key = _e[0], value = _e[1];
311
315
  span.setAttribute("to_emit.0.".concat(key), value);
312
316
  }
313
- return [2 /*return*/, [result]];
317
+ return [2 /*return*/, {
318
+ events: [result],
319
+ }];
314
320
  case 4:
315
321
  span.end();
316
322
  return [7 /*endfinally*/];
@@ -63,7 +63,9 @@ export declare class ArvoEventRouter extends AbstractArvoEventHandler {
63
63
  * @throws {ConfigViolation} When no registered handler exists for the event type
64
64
  * @throws Other Violation error which are thrown by the registered event handlers
65
65
  */
66
- execute(event: ArvoEvent, opentelemetry?: ArvoEventHandlerOpenTelemetryOptions): Promise<ArvoEvent[]>;
66
+ execute(event: ArvoEvent, opentelemetry?: ArvoEventHandlerOpenTelemetryOptions): Promise<{
67
+ events: ArvoEvent[];
68
+ }>;
67
69
  /**
68
70
  * System error schema configuration.
69
71
  * Error events follow format: sys.<handler-source>.error
@@ -166,7 +166,7 @@ var ArvoEventRouter = /** @class */ (function (_super) {
166
166
  context: api_1.context.active(),
167
167
  },
168
168
  fn: function (span) { return __awaiter(_this, void 0, void 0, function () {
169
- var otelSpanHeaders, newEvent, _i, _a, _b, key, value, results, resultingEvents, index, _c, _d, _e, key, value, error_1;
169
+ var otelSpanHeaders, newEvent, _i, _a, _b, key, value, results, resultingEvents, index, _c, _d, _e, key, value, error_1, events;
170
170
  var _this = this;
171
171
  return __generator(this, function (_f) {
172
172
  switch (_f.label) {
@@ -201,7 +201,7 @@ var ArvoEventRouter = /** @class */ (function (_super) {
201
201
  })];
202
202
  case 2:
203
203
  results = _f.sent();
204
- resultingEvents = results.map(function (event) {
204
+ resultingEvents = results.events.map(function (event) {
205
205
  var _a;
206
206
  return new arvo_core_1.ArvoEvent({
207
207
  id: event.id,
@@ -230,10 +230,11 @@ var ArvoEventRouter = /** @class */ (function (_super) {
230
230
  span.setAttribute("to_emit.".concat(index, ".").concat(key), value);
231
231
  }
232
232
  }
233
- return [2 /*return*/, resultingEvents];
233
+ return [2 /*return*/, { events: resultingEvents }];
234
234
  case 3:
235
235
  error_1 = _f.sent();
236
- return [2 /*return*/, (0, utils_1.handleArvoEventHandlerCommonError)(error_1, otelSpanHeaders, this.systemErrorSchema.type, this.source, event, this.executionunits, function (param, extensions) { return (0, arvo_core_1.createArvoEvent)(param, extensions); })];
236
+ events = (0, utils_1.handleArvoEventHandlerCommonError)(error_1, otelSpanHeaders, this.systemErrorSchema.type, this.source, event, this.executionunits, function (param, extensions) { return (0, arvo_core_1.createArvoEvent)(param, extensions); });
237
+ return [2 /*return*/, { events: events }];
237
238
  case 4:
238
239
  span.end();
239
240
  return [7 /*endfinally*/];
@@ -42,7 +42,9 @@ export default class MultiArvoEventHandler extends AbstractArvoEventHandler {
42
42
  * @throws {ConfigViolation} When event destination does not match handler source
43
43
  * @throws Other Violation error which are thrown by the event handler function
44
44
  */
45
- execute(event: ArvoEvent, opentelemetry?: ArvoEventHandlerOpenTelemetryOptions): Promise<ArvoEvent[]>;
45
+ execute(event: ArvoEvent, opentelemetry?: ArvoEventHandlerOpenTelemetryOptions): Promise<{
46
+ events: ArvoEvent[];
47
+ }>;
46
48
  /**
47
49
  * System error schema configuration.
48
50
  * Error events follow format: sys.<handler-source>.error
@@ -126,7 +126,7 @@ var MultiArvoEventHandler = /** @class */ (function (_super) {
126
126
  case 0:
127
127
  otelConfig = (0, utils_1.createEventHandlerTelemetryConfig)('MutliArvoEventHandler', this.spanOptions, opentelemetry, event);
128
128
  return [4 /*yield*/, arvo_core_1.ArvoOpenTelemetry.getInstance().startActiveSpan(__assign(__assign({}, otelConfig), { fn: function (span) { return __awaiter(_this, void 0, void 0, function () {
129
- var otelSpanHeaders, _i, _a, _b, key, value, _handlerOutput, outputs, resultingEvents, error_1;
129
+ var otelSpanHeaders, _i, _a, _b, key, value, _handlerOutput, outputs, resultingEvents, error_1, events;
130
130
  return __generator(this, function (_c) {
131
131
  switch (_c.label) {
132
132
  case 0:
@@ -154,7 +154,9 @@ var MultiArvoEventHandler = /** @class */ (function (_super) {
154
154
  case 2:
155
155
  _handlerOutput = _c.sent();
156
156
  if (!_handlerOutput)
157
- return [2 /*return*/, []];
157
+ return [2 /*return*/, {
158
+ events: [],
159
+ }];
158
160
  outputs = [];
159
161
  if (Array.isArray(_handlerOutput)) {
160
162
  outputs = _handlerOutput;
@@ -167,10 +169,11 @@ var MultiArvoEventHandler = /** @class */ (function (_super) {
167
169
  level: 'INFO',
168
170
  message: "Event processing completed successfully - Generated ".concat(resultingEvents.length, " new event(s)"),
169
171
  });
170
- return [2 /*return*/, resultingEvents];
172
+ return [2 /*return*/, { events: resultingEvents }];
171
173
  case 3:
172
174
  error_1 = _c.sent();
173
- return [2 /*return*/, (0, utils_1.handleArvoEventHandlerCommonError)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function (param, extensions) { return (0, arvo_core_1.createArvoEvent)(param, extensions); })];
175
+ events = (0, utils_1.handleArvoEventHandlerCommonError)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function (param, extensions) { return (0, arvo_core_1.createArvoEvent)(param, extensions); });
176
+ return [2 /*return*/, { events: events }];
174
177
  case 4:
175
178
  span.end();
176
179
  return [7 /*endfinally*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-event-handler",
3
- "version": "2.2.13",
3
+ "version": "2.3.0",
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": {
@@ -53,7 +53,7 @@
53
53
  "dependencies": {
54
54
  "@opentelemetry/api": "^1.9.0",
55
55
  "@opentelemetry/core": "^1.30.1",
56
- "arvo-core": "^2.2.13",
56
+ "arvo-core": "^2.3.0",
57
57
  "uuid": "^11.1.0",
58
58
  "zod": "^3.25.67"
59
59
  },