@nextera.one/axis-server-sdk 2.2.3 → 2.2.4
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-B2G6cbRL.d.mts → index-C4ApiXHX.d.mts} +38 -25
- package/dist/{index-DbSxdR0f.d.ts → index-QGwgvVDY.d.ts} +38 -25
- package/dist/index.d.mts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +162 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -92
- 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 +160 -96
- package/dist/sensors/index.js.map +1 -1
- package/dist/sensors/index.mjs +156 -92
- 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
|
|
|
@@ -2472,15 +2518,19 @@ function observerRefKey(ref) {
|
|
|
2472
2518
|
function sensorRefKey(ref) {
|
|
2473
2519
|
return typeof ref === "string" ? ref : ref.name;
|
|
2474
2520
|
}
|
|
2475
|
-
function
|
|
2521
|
+
function sensorBindingKey(binding) {
|
|
2522
|
+
return `${binding.when}:${sensorRefKey(binding.ref)}`;
|
|
2523
|
+
}
|
|
2524
|
+
function mergeIntentSensorBindings(...sensorGroups) {
|
|
2476
2525
|
const merged = /* @__PURE__ */ new Map();
|
|
2477
2526
|
for (const group of sensorGroups) {
|
|
2478
2527
|
if (!Array.isArray(group)) continue;
|
|
2479
|
-
for (const
|
|
2480
|
-
const
|
|
2528
|
+
for (const input of group) {
|
|
2529
|
+
const binding = toIntentSensorBinding(input);
|
|
2530
|
+
const key = sensorBindingKey(binding);
|
|
2481
2531
|
const existing = merged.get(key);
|
|
2482
|
-
if (!existing || typeof existing === "string" && typeof ref !== "string") {
|
|
2483
|
-
merged.set(key,
|
|
2532
|
+
if (!existing || typeof existing.ref === "string" && typeof binding.ref !== "string") {
|
|
2533
|
+
merged.set(key, binding);
|
|
2484
2534
|
}
|
|
2485
2535
|
}
|
|
2486
2536
|
}
|
|
@@ -2783,9 +2833,9 @@ var init_intent_router = __esm({
|
|
|
2783
2833
|
if (!handler) {
|
|
2784
2834
|
throw new Error(`Intent not found: ${intent}`);
|
|
2785
2835
|
}
|
|
2786
|
-
const
|
|
2787
|
-
if (
|
|
2788
|
-
await this.runIntentSensors(
|
|
2836
|
+
const sensorBindings = this.intentSensors.get(intent);
|
|
2837
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2838
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "before");
|
|
2789
2839
|
}
|
|
2790
2840
|
const decoder = this.intentDecoders.get(intent);
|
|
2791
2841
|
let decodedBody = frame.body;
|
|
@@ -2827,6 +2877,12 @@ var init_intent_router = __esm({
|
|
|
2827
2877
|
);
|
|
2828
2878
|
}
|
|
2829
2879
|
}
|
|
2880
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2881
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "after", {
|
|
2882
|
+
decodedBody,
|
|
2883
|
+
effect
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2830
2886
|
}
|
|
2831
2887
|
await this.emitIntentObservers(observerBindings, {
|
|
2832
2888
|
event: "intent.completed",
|
|
@@ -2870,7 +2926,7 @@ var init_intent_router = __esm({
|
|
|
2870
2926
|
methodName
|
|
2871
2927
|
);
|
|
2872
2928
|
const meta = Reflect.getMetadata(INTENT_METADATA_KEY, proto, methodName);
|
|
2873
|
-
const combined =
|
|
2929
|
+
const combined = mergeIntentSensorBindings(
|
|
2874
2930
|
handlerSensors,
|
|
2875
2931
|
Array.isArray(intentSensors) ? intentSensors : void 0,
|
|
2876
2932
|
Array.isArray(meta?.is) ? meta.is : void 0
|
|
@@ -3012,8 +3068,10 @@ var init_intent_router = __esm({
|
|
|
3012
3068
|
if (!this.observerDispatcher || bindings.length === 0) return;
|
|
3013
3069
|
await this.observerDispatcher.dispatch(bindings, context);
|
|
3014
3070
|
}
|
|
3015
|
-
async runIntentSensors(
|
|
3016
|
-
for (const
|
|
3071
|
+
async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
|
|
3072
|
+
for (const binding of sensorBindings) {
|
|
3073
|
+
if (binding.when !== stage && binding.when !== "both") continue;
|
|
3074
|
+
const sensorRef = binding.ref;
|
|
3017
3075
|
const sensor = this.resolveIntentSensor(sensorRef);
|
|
3018
3076
|
const sensorName = sensorRefKey(sensorRef);
|
|
3019
3077
|
if (!sensor) {
|
|
@@ -3030,9 +3088,12 @@ var init_intent_router = __esm({
|
|
|
3030
3088
|
frameBody: frame.body,
|
|
3031
3089
|
metadata: {
|
|
3032
3090
|
phase: "intent",
|
|
3091
|
+
stage,
|
|
3033
3092
|
intent,
|
|
3034
3093
|
schema: this.getSchema(intent),
|
|
3035
|
-
validators: this.getValidators(intent)
|
|
3094
|
+
validators: this.getValidators(intent),
|
|
3095
|
+
decodedBody: extras?.decodedBody,
|
|
3096
|
+
effect: extras?.effect
|
|
3036
3097
|
}
|
|
3037
3098
|
};
|
|
3038
3099
|
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
@@ -10676,6 +10737,8 @@ __export(index_exports, {
|
|
|
10676
10737
|
startStage: () => startStage,
|
|
10677
10738
|
tieKnot: () => tieKnot,
|
|
10678
10739
|
tlv: () => tlv,
|
|
10740
|
+
toIntentSensorBinding: () => toIntentSensorBinding,
|
|
10741
|
+
toObserverBinding: () => toObserverBinding,
|
|
10679
10742
|
u64be: () => u64be,
|
|
10680
10743
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
10681
10744
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
@@ -10707,6 +10770,7 @@ var init_index = __esm({
|
|
|
10707
10770
|
init_intent_body_decorator();
|
|
10708
10771
|
init_intent_sensors_decorator();
|
|
10709
10772
|
init_observer_decorator();
|
|
10773
|
+
init_observer_decorator();
|
|
10710
10774
|
init_handler_sensors_decorator();
|
|
10711
10775
|
init_sensor_decorator();
|
|
10712
10776
|
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|