@nextera.one/axis-server-sdk 2.2.4 → 2.2.6

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.
@@ -1295,6 +1295,7 @@ var init_axis_chain_executor = __esm({
1295
1295
  timestamp: startedAt,
1296
1296
  chainId: envelope.chainId,
1297
1297
  stepId: step.stepId,
1298
+ handler: step.handler,
1298
1299
  intent: step.intent,
1299
1300
  envelope,
1300
1301
  step,
@@ -1329,6 +1330,7 @@ var init_axis_chain_executor = __esm({
1329
1330
  timestamp: finishedAt,
1330
1331
  chainId: envelope.chainId,
1331
1332
  stepId: step.stepId,
1333
+ handler: step.handler,
1332
1334
  intent: step.intent,
1333
1335
  effect,
1334
1336
  envelope,
@@ -1343,6 +1345,7 @@ var init_axis_chain_executor = __esm({
1343
1345
  timestamp: finishedAt,
1344
1346
  chainId: envelope.chainId,
1345
1347
  stepId: step.stepId,
1348
+ handler: step.handler,
1346
1349
  intent: step.intent,
1347
1350
  envelope,
1348
1351
  step,
@@ -1357,6 +1360,7 @@ var init_axis_chain_executor = __esm({
1357
1360
  timestamp: finishedAt,
1358
1361
  chainId: envelope.chainId,
1359
1362
  stepId: step.stepId,
1363
+ handler: step.handler,
1360
1364
  intent: step.intent,
1361
1365
  effect,
1362
1366
  envelope,
@@ -1387,6 +1391,7 @@ var init_axis_chain_executor = __esm({
1387
1391
  timestamp: finishedAt,
1388
1392
  chainId: envelope.chainId,
1389
1393
  stepId: step.stepId,
1394
+ handler: step.handler,
1390
1395
  intent: step.intent,
1391
1396
  error: error.message,
1392
1397
  envelope,
@@ -2605,6 +2610,8 @@ var init_intent_router = __esm({
2605
2610
  this.handlers = /* @__PURE__ */ new Map();
2606
2611
  /** Per-intent sensor refs (resolved through SensorRegistry at call time) */
2607
2612
  this.intentSensors = /* @__PURE__ */ new Map();
2613
+ /** Per-intent handler identifier (e.g. UsersHandler.usersPage) */
2614
+ this.intentHandlerRefs = /* @__PURE__ */ new Map();
2608
2615
  /** Per-intent body decoders */
2609
2616
  this.intentDecoders = /* @__PURE__ */ new Map();
2610
2617
  /** Per-intent TLV schemas */
@@ -2680,6 +2687,16 @@ var init_intent_router = __esm({
2680
2687
  */
2681
2688
  register(intent, handler) {
2682
2689
  this.handlers.set(intent, handler);
2690
+ if (typeof handler === "function" && handler.name) {
2691
+ this.intentHandlerRefs.set(intent, handler.name);
2692
+ } else if (handler && typeof handler === "object") {
2693
+ const objectName = handler.constructor?.name;
2694
+ if (objectName) {
2695
+ this.intentHandlerRefs.set(intent, `${objectName}.handle`);
2696
+ }
2697
+ } else {
2698
+ this.intentHandlerRefs.set(intent, `intent:${intent}`);
2699
+ }
2683
2700
  }
2684
2701
  /**
2685
2702
  * Automatically registers all `@Intent`-decorated methods from a handler instance.
@@ -2710,6 +2727,10 @@ var init_intent_router = __esm({
2710
2727
  } else {
2711
2728
  this.register(intentName, fn);
2712
2729
  }
2730
+ this.intentHandlerRefs.set(
2731
+ intentName,
2732
+ `${instance.constructor.name}.${String(route.methodName)}`
2733
+ );
2713
2734
  this.registerIntentMeta(
2714
2735
  intentName,
2715
2736
  proto,
@@ -2750,15 +2771,18 @@ var init_intent_router = __esm({
2750
2771
  async route(frame) {
2751
2772
  const start = process.hrtime();
2752
2773
  let intent = "unknown";
2774
+ let handlerRef;
2753
2775
  try {
2754
2776
  const intentBytes = frame.headers.get(TLV_INTENT);
2755
2777
  if (!intentBytes) throw new Error("Missing intent");
2756
2778
  intent = this.decoder.decode(intentBytes);
2779
+ handlerRef = this.intentHandlerRefs.get(intent);
2757
2780
  const observerBindings = this.getObservers(intent);
2758
2781
  await this.emitIntentObservers(observerBindings, {
2759
2782
  event: "intent.received",
2760
2783
  timestamp: Date.now(),
2761
2784
  intent,
2785
+ handler: handlerRef,
2762
2786
  frame
2763
2787
  });
2764
2788
  let effect;
@@ -2888,6 +2912,7 @@ var init_intent_router = __esm({
2888
2912
  event: "intent.completed",
2889
2913
  timestamp: Date.now(),
2890
2914
  intent,
2915
+ handler: handlerRef,
2891
2916
  frame,
2892
2917
  effect,
2893
2918
  metadata: effect.metadata
@@ -2899,6 +2924,7 @@ var init_intent_router = __esm({
2899
2924
  event: "intent.failed",
2900
2925
  timestamp: Date.now(),
2901
2926
  intent,
2927
+ handler: handlerRef,
2902
2928
  frame,
2903
2929
  error: e.message
2904
2930
  });
@@ -3065,8 +3091,11 @@ var init_intent_router = __esm({
3065
3091
  return this.intentRateLimits.get(intent);
3066
3092
  }
3067
3093
  async emitIntentObservers(bindings, context) {
3068
- if (!this.observerDispatcher || bindings.length === 0) return;
3069
- await this.observerDispatcher.dispatch(bindings, context);
3094
+ if (!this.observerDispatcher) return;
3095
+ await this.observerDispatcher.dispatch(
3096
+ bindings.length > 0 ? bindings : void 0,
3097
+ context
3098
+ );
3070
3099
  }
3071
3100
  async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
3072
3101
  for (const binding of sensorBindings) {
@@ -8232,6 +8261,61 @@ var init_disk_upload_file_store = __esm({
8232
8261
  function unique(values) {
8233
8262
  return Array.from(new Set(values));
8234
8263
  }
8264
+ function matchesObserverIntent(intents, intent) {
8265
+ if (!intents || intents.length === 0) {
8266
+ return true;
8267
+ }
8268
+ if (!intent) {
8269
+ return false;
8270
+ }
8271
+ return intents.includes(intent);
8272
+ }
8273
+ function normalizeHandlerToken(value) {
8274
+ return value.trim().toLowerCase();
8275
+ }
8276
+ function matchesObserverHandler(handlers, handler) {
8277
+ if (!handlers || handlers.length === 0) {
8278
+ return true;
8279
+ }
8280
+ if (!handler) {
8281
+ return false;
8282
+ }
8283
+ const normalizedHandler = normalizeHandlerToken(handler);
8284
+ return handlers.some((candidate) => {
8285
+ if (!candidate) {
8286
+ return false;
8287
+ }
8288
+ const normalizedCandidate = normalizeHandlerToken(candidate);
8289
+ return normalizedHandler === normalizedCandidate || normalizedHandler.endsWith(`.${normalizedCandidate}`) || normalizedHandler.startsWith(`${normalizedCandidate}.`) || normalizedCandidate.endsWith(`.${normalizedHandler}`) || normalizedCandidate.startsWith(`${normalizedHandler}.`);
8290
+ });
8291
+ }
8292
+ function observerRefKey2(ref) {
8293
+ return typeof ref === "string" ? ref : ref.name || "(anonymous)";
8294
+ }
8295
+ function mergeBindingRefs(...bindingGroups) {
8296
+ const merged = /* @__PURE__ */ new Map();
8297
+ for (const bindings of bindingGroups) {
8298
+ for (const binding of bindings) {
8299
+ for (const ref of binding.refs) {
8300
+ const key = observerRefKey2(ref);
8301
+ const current = merged.get(key);
8302
+ if (!current) {
8303
+ merged.set(key, {
8304
+ refs: [ref],
8305
+ tags: binding.tags ? [...new Set(binding.tags)] : void 0,
8306
+ events: binding.events ? [...new Set(binding.events)] : void 0
8307
+ });
8308
+ continue;
8309
+ }
8310
+ current.tags = Array.from(
8311
+ /* @__PURE__ */ new Set([...current.tags || [], ...binding.tags || []])
8312
+ );
8313
+ current.events = current.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...current.events || [], ...binding.events]));
8314
+ }
8315
+ }
8316
+ }
8317
+ return Array.from(merged.values());
8318
+ }
8235
8319
  var ObserverDispatcherService;
8236
8320
  var init_observer_dispatcher_service = __esm({
8237
8321
  "src/engine/observer-dispatcher.service.ts"() {
@@ -8242,9 +8326,20 @@ var init_observer_dispatcher_service = __esm({
8242
8326
  this.logger = createAxisLogger(_ObserverDispatcherService.name);
8243
8327
  }
8244
8328
  async dispatch(bindings, context) {
8245
- if (!bindings || bindings.length === 0) return;
8329
+ const explicitBindings = bindings || [];
8330
+ const implicitRegistrations = this.getImplicitRegistrations();
8331
+ if (!explicitBindings.length && implicitRegistrations.length === 0) {
8332
+ return;
8333
+ }
8246
8334
  const invoked = /* @__PURE__ */ new Set();
8247
- for (const binding of bindings) {
8335
+ const implicitBindings = implicitRegistrations.map(
8336
+ (registration) => ({
8337
+ refs: [registration.instance.constructor],
8338
+ events: registration.events
8339
+ })
8340
+ );
8341
+ const merged = mergeBindingRefs(explicitBindings, implicitBindings);
8342
+ for (const binding of merged) {
8248
8343
  if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
8249
8344
  continue;
8250
8345
  }
@@ -8255,6 +8350,9 @@ var init_observer_dispatcher_service = __esm({
8255
8350
  continue;
8256
8351
  }
8257
8352
  if (invoked.has(registration.name)) continue;
8353
+ if (!matchesObserverIntent(registration.intents, context.intent) || !matchesObserverHandler(registration.handlers, context.handler)) {
8354
+ continue;
8355
+ }
8258
8356
  if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
8259
8357
  continue;
8260
8358
  }
@@ -8280,6 +8378,9 @@ var init_observer_dispatcher_service = __esm({
8280
8378
  }
8281
8379
  }
8282
8380
  }
8381
+ getImplicitRegistrations() {
8382
+ return this.registry.list();
8383
+ }
8283
8384
  };
8284
8385
  }
8285
8386
  });