@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/sensors/index.mjs
CHANGED
|
@@ -593,17 +593,76 @@ var init_intent_policy_decorator = __esm({
|
|
|
593
593
|
}
|
|
594
594
|
});
|
|
595
595
|
|
|
596
|
-
// src/decorators/handler.decorator.ts
|
|
596
|
+
// src/decorators/handler-sensors.decorator.ts
|
|
597
597
|
import "reflect-metadata";
|
|
598
|
-
function
|
|
598
|
+
function HandlerSensors(sensors) {
|
|
599
599
|
return (target) => {
|
|
600
|
-
Reflect.defineMetadata(
|
|
600
|
+
Reflect.defineMetadata(HANDLER_SENSORS_KEY, sensors, target);
|
|
601
601
|
};
|
|
602
602
|
}
|
|
603
|
-
var
|
|
604
|
-
var
|
|
605
|
-
"src/decorators/handler.decorator.ts"() {
|
|
606
|
-
|
|
603
|
+
var HANDLER_SENSORS_KEY;
|
|
604
|
+
var init_handler_sensors_decorator = __esm({
|
|
605
|
+
"src/decorators/handler-sensors.decorator.ts"() {
|
|
606
|
+
HANDLER_SENSORS_KEY = "axis:handler:sensors";
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
// src/decorators/observer.decorator.ts
|
|
611
|
+
import "reflect-metadata";
|
|
612
|
+
function isBindingOptions(value) {
|
|
613
|
+
return !!value && typeof value === "object" && "use" in value;
|
|
614
|
+
}
|
|
615
|
+
function isDefinitionOptions(value) {
|
|
616
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
|
|
617
|
+
}
|
|
618
|
+
function toObserverBinding(input) {
|
|
619
|
+
if (!input) return null;
|
|
620
|
+
if (isBindingOptions(input)) {
|
|
621
|
+
const refs = Array.isArray(input.use) ? input.use : [input.use];
|
|
622
|
+
return { refs, tags: input.tags, events: input.events };
|
|
623
|
+
}
|
|
624
|
+
if (Array.isArray(input)) {
|
|
625
|
+
return { refs: input };
|
|
626
|
+
}
|
|
627
|
+
if (typeof input === "function" || typeof input === "string") {
|
|
628
|
+
return { refs: [input] };
|
|
629
|
+
}
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
function Observer(input) {
|
|
633
|
+
return ((target, propertyKey) => {
|
|
634
|
+
const binding = toObserverBinding(input);
|
|
635
|
+
if (binding) {
|
|
636
|
+
if (propertyKey !== void 0) {
|
|
637
|
+
const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
|
|
638
|
+
existing2.push(binding);
|
|
639
|
+
Reflect.defineMetadata(
|
|
640
|
+
OBSERVER_BINDINGS_KEY,
|
|
641
|
+
existing2,
|
|
642
|
+
target,
|
|
643
|
+
propertyKey
|
|
644
|
+
);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
648
|
+
existing.push(binding);
|
|
649
|
+
Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (propertyKey !== void 0) {
|
|
653
|
+
throw new Error(
|
|
654
|
+
"@Observer method usage must reference one or more observer classes or names"
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
const definition = isDefinitionOptions(input) ? input : {};
|
|
658
|
+
Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
var OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
|
|
662
|
+
var init_observer_decorator = __esm({
|
|
663
|
+
"src/decorators/observer.decorator.ts"() {
|
|
664
|
+
OBSERVER_METADATA_KEY = "axis:observer";
|
|
665
|
+
OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
|
|
607
666
|
}
|
|
608
667
|
});
|
|
609
668
|
|
|
@@ -623,6 +682,21 @@ var init_intent_body_decorator = __esm({
|
|
|
623
682
|
|
|
624
683
|
// src/decorators/intent.decorator.ts
|
|
625
684
|
import "reflect-metadata";
|
|
685
|
+
function isIntentSensorBindingOptions(value) {
|
|
686
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && "use" in value;
|
|
687
|
+
}
|
|
688
|
+
function toIntentSensorBinding(input) {
|
|
689
|
+
if (isIntentSensorBindingOptions(input)) {
|
|
690
|
+
return {
|
|
691
|
+
ref: input.use,
|
|
692
|
+
when: input.when || "before"
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
return {
|
|
696
|
+
ref: input,
|
|
697
|
+
when: "before"
|
|
698
|
+
};
|
|
699
|
+
}
|
|
626
700
|
function Intent(action, options) {
|
|
627
701
|
return (target, propertyKey) => {
|
|
628
702
|
const metadata = { intent: action, ...options };
|
|
@@ -670,90 +744,62 @@ var init_intent_decorator = __esm({
|
|
|
670
744
|
}
|
|
671
745
|
});
|
|
672
746
|
|
|
673
|
-
// src/decorators/
|
|
674
|
-
import "reflect-metadata";
|
|
675
|
-
function IntentSensors(sensors) {
|
|
676
|
-
return (target, propertyKey) => {
|
|
677
|
-
Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
var INTENT_SENSORS_KEY;
|
|
681
|
-
var init_intent_sensors_decorator = __esm({
|
|
682
|
-
"src/decorators/intent-sensors.decorator.ts"() {
|
|
683
|
-
INTENT_SENSORS_KEY = "axis:intent:sensors";
|
|
684
|
-
}
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
// src/decorators/observer.decorator.ts
|
|
747
|
+
// src/decorators/handler.decorator.ts
|
|
688
748
|
import "reflect-metadata";
|
|
689
|
-
function
|
|
690
|
-
return
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
const binding = toBinding(input);
|
|
712
|
-
if (binding) {
|
|
713
|
-
if (propertyKey !== void 0) {
|
|
714
|
-
const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
|
|
715
|
-
existing2.push(binding);
|
|
716
|
-
Reflect.defineMetadata(
|
|
717
|
-
OBSERVER_BINDINGS_KEY,
|
|
718
|
-
existing2,
|
|
719
|
-
target,
|
|
720
|
-
propertyKey
|
|
721
|
-
);
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
|
-
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
725
|
-
existing.push(binding);
|
|
726
|
-
Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
|
|
727
|
-
return;
|
|
749
|
+
function Handler(intentOrOptions, options) {
|
|
750
|
+
return (target) => {
|
|
751
|
+
const intent = typeof intentOrOptions === "string" ? intentOrOptions : void 0;
|
|
752
|
+
const handlerOptions = typeof intentOrOptions === "string" ? options : intentOrOptions;
|
|
753
|
+
const sensorBindings = Array.isArray(handlerOptions?.is) ? handlerOptions.is.map(
|
|
754
|
+
(input) => toIntentSensorBinding(input)
|
|
755
|
+
) : [];
|
|
756
|
+
const observerBindings = Array.isArray(
|
|
757
|
+
handlerOptions?.observe
|
|
758
|
+
) ? handlerOptions.observe.map((input) => toObserverBinding(input)).filter((binding) => !!binding) : [];
|
|
759
|
+
Reflect.defineMetadata(
|
|
760
|
+
HANDLER_METADATA_KEY,
|
|
761
|
+
{ intent, ...handlerOptions || {} },
|
|
762
|
+
target
|
|
763
|
+
);
|
|
764
|
+
if (sensorBindings.length > 0) {
|
|
765
|
+
const existing = Reflect.getMetadata(HANDLER_SENSORS_KEY, target) || [];
|
|
766
|
+
Reflect.defineMetadata(
|
|
767
|
+
HANDLER_SENSORS_KEY,
|
|
768
|
+
[...existing, ...sensorBindings],
|
|
769
|
+
target
|
|
770
|
+
);
|
|
728
771
|
}
|
|
729
|
-
if (
|
|
730
|
-
|
|
731
|
-
|
|
772
|
+
if (observerBindings.length > 0) {
|
|
773
|
+
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
774
|
+
Reflect.defineMetadata(
|
|
775
|
+
OBSERVER_BINDINGS_KEY,
|
|
776
|
+
[...existing, ...observerBindings],
|
|
777
|
+
target
|
|
732
778
|
);
|
|
733
779
|
}
|
|
734
|
-
|
|
735
|
-
Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
|
|
736
|
-
});
|
|
780
|
+
};
|
|
737
781
|
}
|
|
738
|
-
var
|
|
739
|
-
var
|
|
740
|
-
"src/decorators/
|
|
741
|
-
|
|
742
|
-
|
|
782
|
+
var HANDLER_METADATA_KEY;
|
|
783
|
+
var init_handler_decorator = __esm({
|
|
784
|
+
"src/decorators/handler.decorator.ts"() {
|
|
785
|
+
init_handler_sensors_decorator();
|
|
786
|
+
init_observer_decorator();
|
|
787
|
+
init_intent_decorator();
|
|
788
|
+
HANDLER_METADATA_KEY = "axis:handler";
|
|
743
789
|
}
|
|
744
790
|
});
|
|
745
791
|
|
|
746
|
-
// src/decorators/
|
|
792
|
+
// src/decorators/intent-sensors.decorator.ts
|
|
747
793
|
import "reflect-metadata";
|
|
748
|
-
function
|
|
749
|
-
return (target) => {
|
|
750
|
-
Reflect.defineMetadata(
|
|
794
|
+
function IntentSensors(sensors) {
|
|
795
|
+
return (target, propertyKey) => {
|
|
796
|
+
Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
|
|
751
797
|
};
|
|
752
798
|
}
|
|
753
|
-
var
|
|
754
|
-
var
|
|
755
|
-
"src/decorators/
|
|
756
|
-
|
|
799
|
+
var INTENT_SENSORS_KEY;
|
|
800
|
+
var init_intent_sensors_decorator = __esm({
|
|
801
|
+
"src/decorators/intent-sensors.decorator.ts"() {
|
|
802
|
+
INTENT_SENSORS_KEY = "axis:intent:sensors";
|
|
757
803
|
}
|
|
758
804
|
});
|
|
759
805
|
|
|
@@ -1249,6 +1295,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1249
1295
|
timestamp: startedAt,
|
|
1250
1296
|
chainId: envelope.chainId,
|
|
1251
1297
|
stepId: step.stepId,
|
|
1298
|
+
handler: step.handler,
|
|
1252
1299
|
intent: step.intent,
|
|
1253
1300
|
envelope,
|
|
1254
1301
|
step,
|
|
@@ -1283,6 +1330,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1283
1330
|
timestamp: finishedAt,
|
|
1284
1331
|
chainId: envelope.chainId,
|
|
1285
1332
|
stepId: step.stepId,
|
|
1333
|
+
handler: step.handler,
|
|
1286
1334
|
intent: step.intent,
|
|
1287
1335
|
effect,
|
|
1288
1336
|
envelope,
|
|
@@ -1297,6 +1345,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1297
1345
|
timestamp: finishedAt,
|
|
1298
1346
|
chainId: envelope.chainId,
|
|
1299
1347
|
stepId: step.stepId,
|
|
1348
|
+
handler: step.handler,
|
|
1300
1349
|
intent: step.intent,
|
|
1301
1350
|
envelope,
|
|
1302
1351
|
step,
|
|
@@ -1311,6 +1360,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1311
1360
|
timestamp: finishedAt,
|
|
1312
1361
|
chainId: envelope.chainId,
|
|
1313
1362
|
stepId: step.stepId,
|
|
1363
|
+
handler: step.handler,
|
|
1314
1364
|
intent: step.intent,
|
|
1315
1365
|
effect,
|
|
1316
1366
|
envelope,
|
|
@@ -1341,6 +1391,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1341
1391
|
timestamp: finishedAt,
|
|
1342
1392
|
chainId: envelope.chainId,
|
|
1343
1393
|
stepId: step.stepId,
|
|
1394
|
+
handler: step.handler,
|
|
1344
1395
|
intent: step.intent,
|
|
1345
1396
|
error: error.message,
|
|
1346
1397
|
envelope,
|
|
@@ -2472,15 +2523,19 @@ function observerRefKey(ref) {
|
|
|
2472
2523
|
function sensorRefKey(ref) {
|
|
2473
2524
|
return typeof ref === "string" ? ref : ref.name;
|
|
2474
2525
|
}
|
|
2475
|
-
function
|
|
2526
|
+
function sensorBindingKey(binding) {
|
|
2527
|
+
return `${binding.when}:${sensorRefKey(binding.ref)}`;
|
|
2528
|
+
}
|
|
2529
|
+
function mergeIntentSensorBindings(...sensorGroups) {
|
|
2476
2530
|
const merged = /* @__PURE__ */ new Map();
|
|
2477
2531
|
for (const group of sensorGroups) {
|
|
2478
2532
|
if (!Array.isArray(group)) continue;
|
|
2479
|
-
for (const
|
|
2480
|
-
const
|
|
2533
|
+
for (const input of group) {
|
|
2534
|
+
const binding = toIntentSensorBinding(input);
|
|
2535
|
+
const key = sensorBindingKey(binding);
|
|
2481
2536
|
const existing = merged.get(key);
|
|
2482
|
-
if (!existing || typeof existing === "string" && typeof ref !== "string") {
|
|
2483
|
-
merged.set(key,
|
|
2537
|
+
if (!existing || typeof existing.ref === "string" && typeof binding.ref !== "string") {
|
|
2538
|
+
merged.set(key, binding);
|
|
2484
2539
|
}
|
|
2485
2540
|
}
|
|
2486
2541
|
}
|
|
@@ -2555,6 +2610,8 @@ var init_intent_router = __esm({
|
|
|
2555
2610
|
this.handlers = /* @__PURE__ */ new Map();
|
|
2556
2611
|
/** Per-intent sensor refs (resolved through SensorRegistry at call time) */
|
|
2557
2612
|
this.intentSensors = /* @__PURE__ */ new Map();
|
|
2613
|
+
/** Per-intent handler identifier (e.g. UsersHandler.usersPage) */
|
|
2614
|
+
this.intentHandlerRefs = /* @__PURE__ */ new Map();
|
|
2558
2615
|
/** Per-intent body decoders */
|
|
2559
2616
|
this.intentDecoders = /* @__PURE__ */ new Map();
|
|
2560
2617
|
/** Per-intent TLV schemas */
|
|
@@ -2630,6 +2687,16 @@ var init_intent_router = __esm({
|
|
|
2630
2687
|
*/
|
|
2631
2688
|
register(intent, handler) {
|
|
2632
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
|
+
}
|
|
2633
2700
|
}
|
|
2634
2701
|
/**
|
|
2635
2702
|
* Automatically registers all `@Intent`-decorated methods from a handler instance.
|
|
@@ -2660,6 +2727,10 @@ var init_intent_router = __esm({
|
|
|
2660
2727
|
} else {
|
|
2661
2728
|
this.register(intentName, fn);
|
|
2662
2729
|
}
|
|
2730
|
+
this.intentHandlerRefs.set(
|
|
2731
|
+
intentName,
|
|
2732
|
+
`${instance.constructor.name}.${String(route.methodName)}`
|
|
2733
|
+
);
|
|
2663
2734
|
this.registerIntentMeta(
|
|
2664
2735
|
intentName,
|
|
2665
2736
|
proto,
|
|
@@ -2700,15 +2771,18 @@ var init_intent_router = __esm({
|
|
|
2700
2771
|
async route(frame) {
|
|
2701
2772
|
const start = process.hrtime();
|
|
2702
2773
|
let intent = "unknown";
|
|
2774
|
+
let handlerRef;
|
|
2703
2775
|
try {
|
|
2704
2776
|
const intentBytes = frame.headers.get(TLV_INTENT);
|
|
2705
2777
|
if (!intentBytes) throw new Error("Missing intent");
|
|
2706
2778
|
intent = this.decoder.decode(intentBytes);
|
|
2779
|
+
handlerRef = this.intentHandlerRefs.get(intent);
|
|
2707
2780
|
const observerBindings = this.getObservers(intent);
|
|
2708
2781
|
await this.emitIntentObservers(observerBindings, {
|
|
2709
2782
|
event: "intent.received",
|
|
2710
2783
|
timestamp: Date.now(),
|
|
2711
2784
|
intent,
|
|
2785
|
+
handler: handlerRef,
|
|
2712
2786
|
frame
|
|
2713
2787
|
});
|
|
2714
2788
|
let effect;
|
|
@@ -2783,9 +2857,9 @@ var init_intent_router = __esm({
|
|
|
2783
2857
|
if (!handler) {
|
|
2784
2858
|
throw new Error(`Intent not found: ${intent}`);
|
|
2785
2859
|
}
|
|
2786
|
-
const
|
|
2787
|
-
if (
|
|
2788
|
-
await this.runIntentSensors(
|
|
2860
|
+
const sensorBindings = this.intentSensors.get(intent);
|
|
2861
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2862
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "before");
|
|
2789
2863
|
}
|
|
2790
2864
|
const decoder = this.intentDecoders.get(intent);
|
|
2791
2865
|
let decodedBody = frame.body;
|
|
@@ -2827,11 +2901,18 @@ var init_intent_router = __esm({
|
|
|
2827
2901
|
);
|
|
2828
2902
|
}
|
|
2829
2903
|
}
|
|
2904
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2905
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "after", {
|
|
2906
|
+
decodedBody,
|
|
2907
|
+
effect
|
|
2908
|
+
});
|
|
2909
|
+
}
|
|
2830
2910
|
}
|
|
2831
2911
|
await this.emitIntentObservers(observerBindings, {
|
|
2832
2912
|
event: "intent.completed",
|
|
2833
2913
|
timestamp: Date.now(),
|
|
2834
2914
|
intent,
|
|
2915
|
+
handler: handlerRef,
|
|
2835
2916
|
frame,
|
|
2836
2917
|
effect,
|
|
2837
2918
|
metadata: effect.metadata
|
|
@@ -2843,6 +2924,7 @@ var init_intent_router = __esm({
|
|
|
2843
2924
|
event: "intent.failed",
|
|
2844
2925
|
timestamp: Date.now(),
|
|
2845
2926
|
intent,
|
|
2927
|
+
handler: handlerRef,
|
|
2846
2928
|
frame,
|
|
2847
2929
|
error: e.message
|
|
2848
2930
|
});
|
|
@@ -2870,7 +2952,7 @@ var init_intent_router = __esm({
|
|
|
2870
2952
|
methodName
|
|
2871
2953
|
);
|
|
2872
2954
|
const meta = Reflect.getMetadata(INTENT_METADATA_KEY, proto, methodName);
|
|
2873
|
-
const combined =
|
|
2955
|
+
const combined = mergeIntentSensorBindings(
|
|
2874
2956
|
handlerSensors,
|
|
2875
2957
|
Array.isArray(intentSensors) ? intentSensors : void 0,
|
|
2876
2958
|
Array.isArray(meta?.is) ? meta.is : void 0
|
|
@@ -3012,8 +3094,10 @@ var init_intent_router = __esm({
|
|
|
3012
3094
|
if (!this.observerDispatcher || bindings.length === 0) return;
|
|
3013
3095
|
await this.observerDispatcher.dispatch(bindings, context);
|
|
3014
3096
|
}
|
|
3015
|
-
async runIntentSensors(
|
|
3016
|
-
for (const
|
|
3097
|
+
async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
|
|
3098
|
+
for (const binding of sensorBindings) {
|
|
3099
|
+
if (binding.when !== stage && binding.when !== "both") continue;
|
|
3100
|
+
const sensorRef = binding.ref;
|
|
3017
3101
|
const sensor = this.resolveIntentSensor(sensorRef);
|
|
3018
3102
|
const sensorName = sensorRefKey(sensorRef);
|
|
3019
3103
|
if (!sensor) {
|
|
@@ -3030,9 +3114,12 @@ var init_intent_router = __esm({
|
|
|
3030
3114
|
frameBody: frame.body,
|
|
3031
3115
|
metadata: {
|
|
3032
3116
|
phase: "intent",
|
|
3117
|
+
stage,
|
|
3033
3118
|
intent,
|
|
3034
3119
|
schema: this.getSchema(intent),
|
|
3035
|
-
validators: this.getValidators(intent)
|
|
3120
|
+
validators: this.getValidators(intent),
|
|
3121
|
+
decodedBody: extras?.decodedBody,
|
|
3122
|
+
effect: extras?.effect
|
|
3036
3123
|
}
|
|
3037
3124
|
};
|
|
3038
3125
|
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
@@ -8171,6 +8258,61 @@ var init_disk_upload_file_store = __esm({
|
|
|
8171
8258
|
function unique(values) {
|
|
8172
8259
|
return Array.from(new Set(values));
|
|
8173
8260
|
}
|
|
8261
|
+
function matchesObserverIntent(intents, intent) {
|
|
8262
|
+
if (!intents || intents.length === 0) {
|
|
8263
|
+
return true;
|
|
8264
|
+
}
|
|
8265
|
+
if (!intent) {
|
|
8266
|
+
return false;
|
|
8267
|
+
}
|
|
8268
|
+
return intents.includes(intent);
|
|
8269
|
+
}
|
|
8270
|
+
function normalizeHandlerToken(value) {
|
|
8271
|
+
return value.trim().toLowerCase();
|
|
8272
|
+
}
|
|
8273
|
+
function matchesObserverHandler(handlers, handler) {
|
|
8274
|
+
if (!handlers || handlers.length === 0) {
|
|
8275
|
+
return true;
|
|
8276
|
+
}
|
|
8277
|
+
if (!handler) {
|
|
8278
|
+
return false;
|
|
8279
|
+
}
|
|
8280
|
+
const normalizedHandler = normalizeHandlerToken(handler);
|
|
8281
|
+
return handlers.some((candidate) => {
|
|
8282
|
+
if (!candidate) {
|
|
8283
|
+
return false;
|
|
8284
|
+
}
|
|
8285
|
+
const normalizedCandidate = normalizeHandlerToken(candidate);
|
|
8286
|
+
return normalizedHandler === normalizedCandidate || normalizedHandler.endsWith(`.${normalizedCandidate}`) || normalizedHandler.startsWith(`${normalizedCandidate}.`) || normalizedCandidate.endsWith(`.${normalizedHandler}`) || normalizedCandidate.startsWith(`${normalizedHandler}.`);
|
|
8287
|
+
});
|
|
8288
|
+
}
|
|
8289
|
+
function observerRefKey2(ref) {
|
|
8290
|
+
return typeof ref === "string" ? ref : ref.name || "(anonymous)";
|
|
8291
|
+
}
|
|
8292
|
+
function mergeBindingRefs(...bindingGroups) {
|
|
8293
|
+
const merged = /* @__PURE__ */ new Map();
|
|
8294
|
+
for (const bindings of bindingGroups) {
|
|
8295
|
+
for (const binding of bindings) {
|
|
8296
|
+
for (const ref of binding.refs) {
|
|
8297
|
+
const key = observerRefKey2(ref);
|
|
8298
|
+
const current = merged.get(key);
|
|
8299
|
+
if (!current) {
|
|
8300
|
+
merged.set(key, {
|
|
8301
|
+
refs: [ref],
|
|
8302
|
+
tags: binding.tags ? [...new Set(binding.tags)] : void 0,
|
|
8303
|
+
events: binding.events ? [...new Set(binding.events)] : void 0
|
|
8304
|
+
});
|
|
8305
|
+
continue;
|
|
8306
|
+
}
|
|
8307
|
+
current.tags = Array.from(
|
|
8308
|
+
/* @__PURE__ */ new Set([...current.tags || [], ...binding.tags || []])
|
|
8309
|
+
);
|
|
8310
|
+
current.events = current.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...current.events || [], ...binding.events]));
|
|
8311
|
+
}
|
|
8312
|
+
}
|
|
8313
|
+
}
|
|
8314
|
+
return Array.from(merged.values());
|
|
8315
|
+
}
|
|
8174
8316
|
var ObserverDispatcherService;
|
|
8175
8317
|
var init_observer_dispatcher_service = __esm({
|
|
8176
8318
|
"src/engine/observer-dispatcher.service.ts"() {
|
|
@@ -8181,9 +8323,20 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8181
8323
|
this.logger = createAxisLogger(_ObserverDispatcherService.name);
|
|
8182
8324
|
}
|
|
8183
8325
|
async dispatch(bindings, context) {
|
|
8184
|
-
|
|
8326
|
+
const explicitBindings = bindings || [];
|
|
8327
|
+
const implicitRegistrations = this.getImplicitRegistrations();
|
|
8328
|
+
if (!explicitBindings.length && implicitRegistrations.length === 0) {
|
|
8329
|
+
return;
|
|
8330
|
+
}
|
|
8185
8331
|
const invoked = /* @__PURE__ */ new Set();
|
|
8186
|
-
|
|
8332
|
+
const implicitBindings = implicitRegistrations.map(
|
|
8333
|
+
(registration) => ({
|
|
8334
|
+
refs: [registration.instance.constructor],
|
|
8335
|
+
events: registration.events
|
|
8336
|
+
})
|
|
8337
|
+
);
|
|
8338
|
+
const merged = mergeBindingRefs(explicitBindings, implicitBindings);
|
|
8339
|
+
for (const binding of merged) {
|
|
8187
8340
|
if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
|
|
8188
8341
|
continue;
|
|
8189
8342
|
}
|
|
@@ -8194,6 +8347,9 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8194
8347
|
continue;
|
|
8195
8348
|
}
|
|
8196
8349
|
if (invoked.has(registration.name)) continue;
|
|
8350
|
+
if (!matchesObserverIntent(registration.intents, context.intent) || !matchesObserverHandler(registration.handlers, context.handler)) {
|
|
8351
|
+
continue;
|
|
8352
|
+
}
|
|
8197
8353
|
if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
|
|
8198
8354
|
continue;
|
|
8199
8355
|
}
|
|
@@ -8219,6 +8375,9 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8219
8375
|
}
|
|
8220
8376
|
}
|
|
8221
8377
|
}
|
|
8378
|
+
getImplicitRegistrations() {
|
|
8379
|
+
return this.registry.list();
|
|
8380
|
+
}
|
|
8222
8381
|
};
|
|
8223
8382
|
}
|
|
8224
8383
|
});
|
|
@@ -10676,6 +10835,8 @@ __export(index_exports, {
|
|
|
10676
10835
|
startStage: () => startStage,
|
|
10677
10836
|
tieKnot: () => tieKnot,
|
|
10678
10837
|
tlv: () => tlv,
|
|
10838
|
+
toIntentSensorBinding: () => toIntentSensorBinding,
|
|
10839
|
+
toObserverBinding: () => toObserverBinding,
|
|
10679
10840
|
u64be: () => u64be,
|
|
10680
10841
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
10681
10842
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
@@ -10707,6 +10868,7 @@ var init_index = __esm({
|
|
|
10707
10868
|
init_intent_body_decorator();
|
|
10708
10869
|
init_intent_sensors_decorator();
|
|
10709
10870
|
init_observer_decorator();
|
|
10871
|
+
init_observer_decorator();
|
|
10710
10872
|
init_handler_sensors_decorator();
|
|
10711
10873
|
init_sensor_decorator();
|
|
10712
10874
|
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|