@nextera.one/axis-server-sdk 2.2.3 → 2.2.5
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/{index-DbSxdR0f.d.ts → index-CwXlBXJf.d.ts} +40 -25
- package/dist/{index-B2G6cbRL.d.mts → index-ldPtIocV.d.mts} +40 -25
- package/dist/index.d.mts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +262 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +258 -94
- package/dist/index.mjs.map +1 -1
- package/dist/sensors/index.d.mts +1 -1
- package/dist/sensors/index.d.ts +1 -1
- package/dist/sensors/index.js +260 -98
- package/dist/sensors/index.js.map +1 -1
- package/dist/sensors/index.mjs +256 -94
- package/dist/sensors/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -273,17 +273,76 @@ var init_intent_policy_decorator = __esm({
|
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
275
|
|
|
276
|
-
// src/decorators/handler.decorator.ts
|
|
276
|
+
// src/decorators/handler-sensors.decorator.ts
|
|
277
277
|
import "reflect-metadata";
|
|
278
|
-
function
|
|
278
|
+
function HandlerSensors(sensors) {
|
|
279
279
|
return (target) => {
|
|
280
|
-
Reflect.defineMetadata(
|
|
280
|
+
Reflect.defineMetadata(HANDLER_SENSORS_KEY, sensors, target);
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
"src/decorators/handler.decorator.ts"() {
|
|
286
|
-
|
|
283
|
+
var HANDLER_SENSORS_KEY;
|
|
284
|
+
var init_handler_sensors_decorator = __esm({
|
|
285
|
+
"src/decorators/handler-sensors.decorator.ts"() {
|
|
286
|
+
HANDLER_SENSORS_KEY = "axis:handler:sensors";
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// src/decorators/observer.decorator.ts
|
|
291
|
+
import "reflect-metadata";
|
|
292
|
+
function isBindingOptions(value) {
|
|
293
|
+
return !!value && typeof value === "object" && "use" in value;
|
|
294
|
+
}
|
|
295
|
+
function isDefinitionOptions(value) {
|
|
296
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
|
|
297
|
+
}
|
|
298
|
+
function toObserverBinding(input) {
|
|
299
|
+
if (!input) return null;
|
|
300
|
+
if (isBindingOptions(input)) {
|
|
301
|
+
const refs = Array.isArray(input.use) ? input.use : [input.use];
|
|
302
|
+
return { refs, tags: input.tags, events: input.events };
|
|
303
|
+
}
|
|
304
|
+
if (Array.isArray(input)) {
|
|
305
|
+
return { refs: input };
|
|
306
|
+
}
|
|
307
|
+
if (typeof input === "function" || typeof input === "string") {
|
|
308
|
+
return { refs: [input] };
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
function Observer(input) {
|
|
313
|
+
return ((target, propertyKey) => {
|
|
314
|
+
const binding = toObserverBinding(input);
|
|
315
|
+
if (binding) {
|
|
316
|
+
if (propertyKey !== void 0) {
|
|
317
|
+
const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
|
|
318
|
+
existing2.push(binding);
|
|
319
|
+
Reflect.defineMetadata(
|
|
320
|
+
OBSERVER_BINDINGS_KEY,
|
|
321
|
+
existing2,
|
|
322
|
+
target,
|
|
323
|
+
propertyKey
|
|
324
|
+
);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
328
|
+
existing.push(binding);
|
|
329
|
+
Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (propertyKey !== void 0) {
|
|
333
|
+
throw new Error(
|
|
334
|
+
"@Observer method usage must reference one or more observer classes or names"
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
const definition = isDefinitionOptions(input) ? input : {};
|
|
338
|
+
Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
var OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
|
|
342
|
+
var init_observer_decorator = __esm({
|
|
343
|
+
"src/decorators/observer.decorator.ts"() {
|
|
344
|
+
OBSERVER_METADATA_KEY = "axis:observer";
|
|
345
|
+
OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
|
|
287
346
|
}
|
|
288
347
|
});
|
|
289
348
|
|
|
@@ -303,6 +362,21 @@ var init_intent_body_decorator = __esm({
|
|
|
303
362
|
|
|
304
363
|
// src/decorators/intent.decorator.ts
|
|
305
364
|
import "reflect-metadata";
|
|
365
|
+
function isIntentSensorBindingOptions(value) {
|
|
366
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && "use" in value;
|
|
367
|
+
}
|
|
368
|
+
function toIntentSensorBinding(input) {
|
|
369
|
+
if (isIntentSensorBindingOptions(input)) {
|
|
370
|
+
return {
|
|
371
|
+
ref: input.use,
|
|
372
|
+
when: input.when || "before"
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
ref: input,
|
|
377
|
+
when: "before"
|
|
378
|
+
};
|
|
379
|
+
}
|
|
306
380
|
function Intent(action, options) {
|
|
307
381
|
return (target, propertyKey) => {
|
|
308
382
|
const metadata = { intent: action, ...options };
|
|
@@ -350,90 +424,62 @@ var init_intent_decorator = __esm({
|
|
|
350
424
|
}
|
|
351
425
|
});
|
|
352
426
|
|
|
353
|
-
// src/decorators/
|
|
354
|
-
import "reflect-metadata";
|
|
355
|
-
function IntentSensors(sensors) {
|
|
356
|
-
return (target, propertyKey) => {
|
|
357
|
-
Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
var INTENT_SENSORS_KEY;
|
|
361
|
-
var init_intent_sensors_decorator = __esm({
|
|
362
|
-
"src/decorators/intent-sensors.decorator.ts"() {
|
|
363
|
-
INTENT_SENSORS_KEY = "axis:intent:sensors";
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
// src/decorators/observer.decorator.ts
|
|
427
|
+
// src/decorators/handler.decorator.ts
|
|
368
428
|
import "reflect-metadata";
|
|
369
|
-
function
|
|
370
|
-
return
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
const binding = toBinding(input);
|
|
392
|
-
if (binding) {
|
|
393
|
-
if (propertyKey !== void 0) {
|
|
394
|
-
const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
|
|
395
|
-
existing2.push(binding);
|
|
396
|
-
Reflect.defineMetadata(
|
|
397
|
-
OBSERVER_BINDINGS_KEY,
|
|
398
|
-
existing2,
|
|
399
|
-
target,
|
|
400
|
-
propertyKey
|
|
401
|
-
);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
405
|
-
existing.push(binding);
|
|
406
|
-
Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
|
|
407
|
-
return;
|
|
429
|
+
function Handler(intentOrOptions, options) {
|
|
430
|
+
return (target) => {
|
|
431
|
+
const intent = typeof intentOrOptions === "string" ? intentOrOptions : void 0;
|
|
432
|
+
const handlerOptions = typeof intentOrOptions === "string" ? options : intentOrOptions;
|
|
433
|
+
const sensorBindings = Array.isArray(handlerOptions?.is) ? handlerOptions.is.map(
|
|
434
|
+
(input) => toIntentSensorBinding(input)
|
|
435
|
+
) : [];
|
|
436
|
+
const observerBindings = Array.isArray(
|
|
437
|
+
handlerOptions?.observe
|
|
438
|
+
) ? handlerOptions.observe.map((input) => toObserverBinding(input)).filter((binding) => !!binding) : [];
|
|
439
|
+
Reflect.defineMetadata(
|
|
440
|
+
HANDLER_METADATA_KEY,
|
|
441
|
+
{ intent, ...handlerOptions || {} },
|
|
442
|
+
target
|
|
443
|
+
);
|
|
444
|
+
if (sensorBindings.length > 0) {
|
|
445
|
+
const existing = Reflect.getMetadata(HANDLER_SENSORS_KEY, target) || [];
|
|
446
|
+
Reflect.defineMetadata(
|
|
447
|
+
HANDLER_SENSORS_KEY,
|
|
448
|
+
[...existing, ...sensorBindings],
|
|
449
|
+
target
|
|
450
|
+
);
|
|
408
451
|
}
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
452
|
+
if (observerBindings.length > 0) {
|
|
453
|
+
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
454
|
+
Reflect.defineMetadata(
|
|
455
|
+
OBSERVER_BINDINGS_KEY,
|
|
456
|
+
[...existing, ...observerBindings],
|
|
457
|
+
target
|
|
412
458
|
);
|
|
413
459
|
}
|
|
414
|
-
|
|
415
|
-
Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
|
|
416
|
-
});
|
|
460
|
+
};
|
|
417
461
|
}
|
|
418
|
-
var
|
|
419
|
-
var
|
|
420
|
-
"src/decorators/
|
|
421
|
-
|
|
422
|
-
|
|
462
|
+
var HANDLER_METADATA_KEY;
|
|
463
|
+
var init_handler_decorator = __esm({
|
|
464
|
+
"src/decorators/handler.decorator.ts"() {
|
|
465
|
+
init_handler_sensors_decorator();
|
|
466
|
+
init_observer_decorator();
|
|
467
|
+
init_intent_decorator();
|
|
468
|
+
HANDLER_METADATA_KEY = "axis:handler";
|
|
423
469
|
}
|
|
424
470
|
});
|
|
425
471
|
|
|
426
|
-
// src/decorators/
|
|
472
|
+
// src/decorators/intent-sensors.decorator.ts
|
|
427
473
|
import "reflect-metadata";
|
|
428
|
-
function
|
|
429
|
-
return (target) => {
|
|
430
|
-
Reflect.defineMetadata(
|
|
474
|
+
function IntentSensors(sensors) {
|
|
475
|
+
return (target, propertyKey) => {
|
|
476
|
+
Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
|
|
431
477
|
};
|
|
432
478
|
}
|
|
433
|
-
var
|
|
434
|
-
var
|
|
435
|
-
"src/decorators/
|
|
436
|
-
|
|
479
|
+
var INTENT_SENSORS_KEY;
|
|
480
|
+
var init_intent_sensors_decorator = __esm({
|
|
481
|
+
"src/decorators/intent-sensors.decorator.ts"() {
|
|
482
|
+
INTENT_SENSORS_KEY = "axis:intent:sensors";
|
|
437
483
|
}
|
|
438
484
|
});
|
|
439
485
|
|
|
@@ -1106,6 +1152,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1106
1152
|
timestamp: startedAt,
|
|
1107
1153
|
chainId: envelope.chainId,
|
|
1108
1154
|
stepId: step.stepId,
|
|
1155
|
+
handler: step.handler,
|
|
1109
1156
|
intent: step.intent,
|
|
1110
1157
|
envelope,
|
|
1111
1158
|
step,
|
|
@@ -1140,6 +1187,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1140
1187
|
timestamp: finishedAt,
|
|
1141
1188
|
chainId: envelope.chainId,
|
|
1142
1189
|
stepId: step.stepId,
|
|
1190
|
+
handler: step.handler,
|
|
1143
1191
|
intent: step.intent,
|
|
1144
1192
|
effect,
|
|
1145
1193
|
envelope,
|
|
@@ -1154,6 +1202,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1154
1202
|
timestamp: finishedAt,
|
|
1155
1203
|
chainId: envelope.chainId,
|
|
1156
1204
|
stepId: step.stepId,
|
|
1205
|
+
handler: step.handler,
|
|
1157
1206
|
intent: step.intent,
|
|
1158
1207
|
envelope,
|
|
1159
1208
|
step,
|
|
@@ -1168,6 +1217,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1168
1217
|
timestamp: finishedAt,
|
|
1169
1218
|
chainId: envelope.chainId,
|
|
1170
1219
|
stepId: step.stepId,
|
|
1220
|
+
handler: step.handler,
|
|
1171
1221
|
intent: step.intent,
|
|
1172
1222
|
effect,
|
|
1173
1223
|
envelope,
|
|
@@ -1198,6 +1248,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1198
1248
|
timestamp: finishedAt,
|
|
1199
1249
|
chainId: envelope.chainId,
|
|
1200
1250
|
stepId: step.stepId,
|
|
1251
|
+
handler: step.handler,
|
|
1201
1252
|
intent: step.intent,
|
|
1202
1253
|
error: error.message,
|
|
1203
1254
|
envelope,
|
|
@@ -2329,15 +2380,19 @@ function observerRefKey(ref) {
|
|
|
2329
2380
|
function sensorRefKey(ref) {
|
|
2330
2381
|
return typeof ref === "string" ? ref : ref.name;
|
|
2331
2382
|
}
|
|
2332
|
-
function
|
|
2383
|
+
function sensorBindingKey(binding) {
|
|
2384
|
+
return `${binding.when}:${sensorRefKey(binding.ref)}`;
|
|
2385
|
+
}
|
|
2386
|
+
function mergeIntentSensorBindings(...sensorGroups) {
|
|
2333
2387
|
const merged = /* @__PURE__ */ new Map();
|
|
2334
2388
|
for (const group of sensorGroups) {
|
|
2335
2389
|
if (!Array.isArray(group)) continue;
|
|
2336
|
-
for (const
|
|
2337
|
-
const
|
|
2390
|
+
for (const input of group) {
|
|
2391
|
+
const binding = toIntentSensorBinding(input);
|
|
2392
|
+
const key = sensorBindingKey(binding);
|
|
2338
2393
|
const existing = merged.get(key);
|
|
2339
|
-
if (!existing || typeof existing === "string" && typeof ref !== "string") {
|
|
2340
|
-
merged.set(key,
|
|
2394
|
+
if (!existing || typeof existing.ref === "string" && typeof binding.ref !== "string") {
|
|
2395
|
+
merged.set(key, binding);
|
|
2341
2396
|
}
|
|
2342
2397
|
}
|
|
2343
2398
|
}
|
|
@@ -2412,6 +2467,8 @@ var init_intent_router = __esm({
|
|
|
2412
2467
|
this.handlers = /* @__PURE__ */ new Map();
|
|
2413
2468
|
/** Per-intent sensor refs (resolved through SensorRegistry at call time) */
|
|
2414
2469
|
this.intentSensors = /* @__PURE__ */ new Map();
|
|
2470
|
+
/** Per-intent handler identifier (e.g. UsersHandler.usersPage) */
|
|
2471
|
+
this.intentHandlerRefs = /* @__PURE__ */ new Map();
|
|
2415
2472
|
/** Per-intent body decoders */
|
|
2416
2473
|
this.intentDecoders = /* @__PURE__ */ new Map();
|
|
2417
2474
|
/** Per-intent TLV schemas */
|
|
@@ -2487,6 +2544,16 @@ var init_intent_router = __esm({
|
|
|
2487
2544
|
*/
|
|
2488
2545
|
register(intent, handler) {
|
|
2489
2546
|
this.handlers.set(intent, handler);
|
|
2547
|
+
if (typeof handler === "function" && handler.name) {
|
|
2548
|
+
this.intentHandlerRefs.set(intent, handler.name);
|
|
2549
|
+
} else if (handler && typeof handler === "object") {
|
|
2550
|
+
const objectName = handler.constructor?.name;
|
|
2551
|
+
if (objectName) {
|
|
2552
|
+
this.intentHandlerRefs.set(intent, `${objectName}.handle`);
|
|
2553
|
+
}
|
|
2554
|
+
} else {
|
|
2555
|
+
this.intentHandlerRefs.set(intent, `intent:${intent}`);
|
|
2556
|
+
}
|
|
2490
2557
|
}
|
|
2491
2558
|
/**
|
|
2492
2559
|
* Automatically registers all `@Intent`-decorated methods from a handler instance.
|
|
@@ -2517,6 +2584,10 @@ var init_intent_router = __esm({
|
|
|
2517
2584
|
} else {
|
|
2518
2585
|
this.register(intentName, fn);
|
|
2519
2586
|
}
|
|
2587
|
+
this.intentHandlerRefs.set(
|
|
2588
|
+
intentName,
|
|
2589
|
+
`${instance.constructor.name}.${String(route.methodName)}`
|
|
2590
|
+
);
|
|
2520
2591
|
this.registerIntentMeta(
|
|
2521
2592
|
intentName,
|
|
2522
2593
|
proto,
|
|
@@ -2557,15 +2628,18 @@ var init_intent_router = __esm({
|
|
|
2557
2628
|
async route(frame) {
|
|
2558
2629
|
const start = process.hrtime();
|
|
2559
2630
|
let intent = "unknown";
|
|
2631
|
+
let handlerRef;
|
|
2560
2632
|
try {
|
|
2561
2633
|
const intentBytes = frame.headers.get(TLV_INTENT);
|
|
2562
2634
|
if (!intentBytes) throw new Error("Missing intent");
|
|
2563
2635
|
intent = this.decoder.decode(intentBytes);
|
|
2636
|
+
handlerRef = this.intentHandlerRefs.get(intent);
|
|
2564
2637
|
const observerBindings = this.getObservers(intent);
|
|
2565
2638
|
await this.emitIntentObservers(observerBindings, {
|
|
2566
2639
|
event: "intent.received",
|
|
2567
2640
|
timestamp: Date.now(),
|
|
2568
2641
|
intent,
|
|
2642
|
+
handler: handlerRef,
|
|
2569
2643
|
frame
|
|
2570
2644
|
});
|
|
2571
2645
|
let effect;
|
|
@@ -2640,9 +2714,9 @@ var init_intent_router = __esm({
|
|
|
2640
2714
|
if (!handler) {
|
|
2641
2715
|
throw new Error(`Intent not found: ${intent}`);
|
|
2642
2716
|
}
|
|
2643
|
-
const
|
|
2644
|
-
if (
|
|
2645
|
-
await this.runIntentSensors(
|
|
2717
|
+
const sensorBindings = this.intentSensors.get(intent);
|
|
2718
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2719
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "before");
|
|
2646
2720
|
}
|
|
2647
2721
|
const decoder = this.intentDecoders.get(intent);
|
|
2648
2722
|
let decodedBody = frame.body;
|
|
@@ -2684,11 +2758,18 @@ var init_intent_router = __esm({
|
|
|
2684
2758
|
);
|
|
2685
2759
|
}
|
|
2686
2760
|
}
|
|
2761
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2762
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "after", {
|
|
2763
|
+
decodedBody,
|
|
2764
|
+
effect
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2687
2767
|
}
|
|
2688
2768
|
await this.emitIntentObservers(observerBindings, {
|
|
2689
2769
|
event: "intent.completed",
|
|
2690
2770
|
timestamp: Date.now(),
|
|
2691
2771
|
intent,
|
|
2772
|
+
handler: handlerRef,
|
|
2692
2773
|
frame,
|
|
2693
2774
|
effect,
|
|
2694
2775
|
metadata: effect.metadata
|
|
@@ -2700,6 +2781,7 @@ var init_intent_router = __esm({
|
|
|
2700
2781
|
event: "intent.failed",
|
|
2701
2782
|
timestamp: Date.now(),
|
|
2702
2783
|
intent,
|
|
2784
|
+
handler: handlerRef,
|
|
2703
2785
|
frame,
|
|
2704
2786
|
error: e.message
|
|
2705
2787
|
});
|
|
@@ -2727,7 +2809,7 @@ var init_intent_router = __esm({
|
|
|
2727
2809
|
methodName
|
|
2728
2810
|
);
|
|
2729
2811
|
const meta = Reflect.getMetadata(INTENT_METADATA_KEY, proto, methodName);
|
|
2730
|
-
const combined =
|
|
2812
|
+
const combined = mergeIntentSensorBindings(
|
|
2731
2813
|
handlerSensors,
|
|
2732
2814
|
Array.isArray(intentSensors) ? intentSensors : void 0,
|
|
2733
2815
|
Array.isArray(meta?.is) ? meta.is : void 0
|
|
@@ -2869,8 +2951,10 @@ var init_intent_router = __esm({
|
|
|
2869
2951
|
if (!this.observerDispatcher || bindings.length === 0) return;
|
|
2870
2952
|
await this.observerDispatcher.dispatch(bindings, context);
|
|
2871
2953
|
}
|
|
2872
|
-
async runIntentSensors(
|
|
2873
|
-
for (const
|
|
2954
|
+
async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
|
|
2955
|
+
for (const binding of sensorBindings) {
|
|
2956
|
+
if (binding.when !== stage && binding.when !== "both") continue;
|
|
2957
|
+
const sensorRef = binding.ref;
|
|
2874
2958
|
const sensor = this.resolveIntentSensor(sensorRef);
|
|
2875
2959
|
const sensorName = sensorRefKey(sensorRef);
|
|
2876
2960
|
if (!sensor) {
|
|
@@ -2887,9 +2971,12 @@ var init_intent_router = __esm({
|
|
|
2887
2971
|
frameBody: frame.body,
|
|
2888
2972
|
metadata: {
|
|
2889
2973
|
phase: "intent",
|
|
2974
|
+
stage,
|
|
2890
2975
|
intent,
|
|
2891
2976
|
schema: this.getSchema(intent),
|
|
2892
|
-
validators: this.getValidators(intent)
|
|
2977
|
+
validators: this.getValidators(intent),
|
|
2978
|
+
decodedBody: extras?.decodedBody,
|
|
2979
|
+
effect: extras?.effect
|
|
2893
2980
|
}
|
|
2894
2981
|
};
|
|
2895
2982
|
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
@@ -8068,6 +8155,61 @@ var init_disk_upload_file_store = __esm({
|
|
|
8068
8155
|
function unique(values) {
|
|
8069
8156
|
return Array.from(new Set(values));
|
|
8070
8157
|
}
|
|
8158
|
+
function matchesObserverIntent(intents, intent) {
|
|
8159
|
+
if (!intents || intents.length === 0) {
|
|
8160
|
+
return true;
|
|
8161
|
+
}
|
|
8162
|
+
if (!intent) {
|
|
8163
|
+
return false;
|
|
8164
|
+
}
|
|
8165
|
+
return intents.includes(intent);
|
|
8166
|
+
}
|
|
8167
|
+
function normalizeHandlerToken(value) {
|
|
8168
|
+
return value.trim().toLowerCase();
|
|
8169
|
+
}
|
|
8170
|
+
function matchesObserverHandler(handlers, handler) {
|
|
8171
|
+
if (!handlers || handlers.length === 0) {
|
|
8172
|
+
return true;
|
|
8173
|
+
}
|
|
8174
|
+
if (!handler) {
|
|
8175
|
+
return false;
|
|
8176
|
+
}
|
|
8177
|
+
const normalizedHandler = normalizeHandlerToken(handler);
|
|
8178
|
+
return handlers.some((candidate) => {
|
|
8179
|
+
if (!candidate) {
|
|
8180
|
+
return false;
|
|
8181
|
+
}
|
|
8182
|
+
const normalizedCandidate = normalizeHandlerToken(candidate);
|
|
8183
|
+
return normalizedHandler === normalizedCandidate || normalizedHandler.endsWith(`.${normalizedCandidate}`) || normalizedHandler.startsWith(`${normalizedCandidate}.`) || normalizedCandidate.endsWith(`.${normalizedHandler}`) || normalizedCandidate.startsWith(`${normalizedHandler}.`);
|
|
8184
|
+
});
|
|
8185
|
+
}
|
|
8186
|
+
function observerRefKey2(ref) {
|
|
8187
|
+
return typeof ref === "string" ? ref : ref.name || "(anonymous)";
|
|
8188
|
+
}
|
|
8189
|
+
function mergeBindingRefs(...bindingGroups) {
|
|
8190
|
+
const merged = /* @__PURE__ */ new Map();
|
|
8191
|
+
for (const bindings of bindingGroups) {
|
|
8192
|
+
for (const binding of bindings) {
|
|
8193
|
+
for (const ref of binding.refs) {
|
|
8194
|
+
const key = observerRefKey2(ref);
|
|
8195
|
+
const current = merged.get(key);
|
|
8196
|
+
if (!current) {
|
|
8197
|
+
merged.set(key, {
|
|
8198
|
+
refs: [ref],
|
|
8199
|
+
tags: binding.tags ? [...new Set(binding.tags)] : void 0,
|
|
8200
|
+
events: binding.events ? [...new Set(binding.events)] : void 0
|
|
8201
|
+
});
|
|
8202
|
+
continue;
|
|
8203
|
+
}
|
|
8204
|
+
current.tags = Array.from(
|
|
8205
|
+
/* @__PURE__ */ new Set([...current.tags || [], ...binding.tags || []])
|
|
8206
|
+
);
|
|
8207
|
+
current.events = current.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...current.events || [], ...binding.events]));
|
|
8208
|
+
}
|
|
8209
|
+
}
|
|
8210
|
+
}
|
|
8211
|
+
return Array.from(merged.values());
|
|
8212
|
+
}
|
|
8071
8213
|
var ObserverDispatcherService;
|
|
8072
8214
|
var init_observer_dispatcher_service = __esm({
|
|
8073
8215
|
"src/engine/observer-dispatcher.service.ts"() {
|
|
@@ -8078,9 +8220,20 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8078
8220
|
this.logger = createAxisLogger(_ObserverDispatcherService.name);
|
|
8079
8221
|
}
|
|
8080
8222
|
async dispatch(bindings, context) {
|
|
8081
|
-
|
|
8223
|
+
const explicitBindings = bindings || [];
|
|
8224
|
+
const implicitRegistrations = this.getImplicitRegistrations();
|
|
8225
|
+
if (!explicitBindings.length && implicitRegistrations.length === 0) {
|
|
8226
|
+
return;
|
|
8227
|
+
}
|
|
8082
8228
|
const invoked = /* @__PURE__ */ new Set();
|
|
8083
|
-
|
|
8229
|
+
const implicitBindings = implicitRegistrations.map(
|
|
8230
|
+
(registration) => ({
|
|
8231
|
+
refs: [registration.instance.constructor],
|
|
8232
|
+
events: registration.events
|
|
8233
|
+
})
|
|
8234
|
+
);
|
|
8235
|
+
const merged = mergeBindingRefs(explicitBindings, implicitBindings);
|
|
8236
|
+
for (const binding of merged) {
|
|
8084
8237
|
if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
|
|
8085
8238
|
continue;
|
|
8086
8239
|
}
|
|
@@ -8091,6 +8244,9 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8091
8244
|
continue;
|
|
8092
8245
|
}
|
|
8093
8246
|
if (invoked.has(registration.name)) continue;
|
|
8247
|
+
if (!matchesObserverIntent(registration.intents, context.intent) || !matchesObserverHandler(registration.handlers, context.handler)) {
|
|
8248
|
+
continue;
|
|
8249
|
+
}
|
|
8094
8250
|
if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
|
|
8095
8251
|
continue;
|
|
8096
8252
|
}
|
|
@@ -8116,6 +8272,9 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8116
8272
|
}
|
|
8117
8273
|
}
|
|
8118
8274
|
}
|
|
8275
|
+
getImplicitRegistrations() {
|
|
8276
|
+
return this.registry.list();
|
|
8277
|
+
}
|
|
8119
8278
|
};
|
|
8120
8279
|
}
|
|
8121
8280
|
});
|
|
@@ -12730,6 +12889,8 @@ __export(index_exports, {
|
|
|
12730
12889
|
startStage: () => startStage,
|
|
12731
12890
|
tieKnot: () => tieKnot,
|
|
12732
12891
|
tlv: () => tlv,
|
|
12892
|
+
toIntentSensorBinding: () => toIntentSensorBinding,
|
|
12893
|
+
toObserverBinding: () => toObserverBinding,
|
|
12733
12894
|
u64be: () => u64be,
|
|
12734
12895
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
12735
12896
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
@@ -12761,6 +12922,7 @@ var init_index = __esm({
|
|
|
12761
12922
|
init_intent_body_decorator();
|
|
12762
12923
|
init_intent_sensors_decorator();
|
|
12763
12924
|
init_observer_decorator();
|
|
12925
|
+
init_observer_decorator();
|
|
12764
12926
|
init_handler_sensors_decorator();
|
|
12765
12927
|
init_sensor_decorator();
|
|
12766
12928
|
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|
|
@@ -13128,6 +13290,8 @@ export {
|
|
|
13128
13290
|
startStage,
|
|
13129
13291
|
tieKnot,
|
|
13130
13292
|
tlv,
|
|
13293
|
+
toIntentSensorBinding,
|
|
13294
|
+
toObserverBinding,
|
|
13131
13295
|
u64be,
|
|
13132
13296
|
unpackPasskeyLoginOptionsReq,
|
|
13133
13297
|
unpackPasskeyLoginVerifyReq,
|