@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/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
|
|
|
@@ -2329,15 +2375,19 @@ function observerRefKey(ref) {
|
|
|
2329
2375
|
function sensorRefKey(ref) {
|
|
2330
2376
|
return typeof ref === "string" ? ref : ref.name;
|
|
2331
2377
|
}
|
|
2332
|
-
function
|
|
2378
|
+
function sensorBindingKey(binding) {
|
|
2379
|
+
return `${binding.when}:${sensorRefKey(binding.ref)}`;
|
|
2380
|
+
}
|
|
2381
|
+
function mergeIntentSensorBindings(...sensorGroups) {
|
|
2333
2382
|
const merged = /* @__PURE__ */ new Map();
|
|
2334
2383
|
for (const group of sensorGroups) {
|
|
2335
2384
|
if (!Array.isArray(group)) continue;
|
|
2336
|
-
for (const
|
|
2337
|
-
const
|
|
2385
|
+
for (const input of group) {
|
|
2386
|
+
const binding = toIntentSensorBinding(input);
|
|
2387
|
+
const key = sensorBindingKey(binding);
|
|
2338
2388
|
const existing = merged.get(key);
|
|
2339
|
-
if (!existing || typeof existing === "string" && typeof ref !== "string") {
|
|
2340
|
-
merged.set(key,
|
|
2389
|
+
if (!existing || typeof existing.ref === "string" && typeof binding.ref !== "string") {
|
|
2390
|
+
merged.set(key, binding);
|
|
2341
2391
|
}
|
|
2342
2392
|
}
|
|
2343
2393
|
}
|
|
@@ -2640,9 +2690,9 @@ var init_intent_router = __esm({
|
|
|
2640
2690
|
if (!handler) {
|
|
2641
2691
|
throw new Error(`Intent not found: ${intent}`);
|
|
2642
2692
|
}
|
|
2643
|
-
const
|
|
2644
|
-
if (
|
|
2645
|
-
await this.runIntentSensors(
|
|
2693
|
+
const sensorBindings = this.intentSensors.get(intent);
|
|
2694
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2695
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "before");
|
|
2646
2696
|
}
|
|
2647
2697
|
const decoder = this.intentDecoders.get(intent);
|
|
2648
2698
|
let decodedBody = frame.body;
|
|
@@ -2684,6 +2734,12 @@ var init_intent_router = __esm({
|
|
|
2684
2734
|
);
|
|
2685
2735
|
}
|
|
2686
2736
|
}
|
|
2737
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2738
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "after", {
|
|
2739
|
+
decodedBody,
|
|
2740
|
+
effect
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2687
2743
|
}
|
|
2688
2744
|
await this.emitIntentObservers(observerBindings, {
|
|
2689
2745
|
event: "intent.completed",
|
|
@@ -2727,7 +2783,7 @@ var init_intent_router = __esm({
|
|
|
2727
2783
|
methodName
|
|
2728
2784
|
);
|
|
2729
2785
|
const meta = Reflect.getMetadata(INTENT_METADATA_KEY, proto, methodName);
|
|
2730
|
-
const combined =
|
|
2786
|
+
const combined = mergeIntentSensorBindings(
|
|
2731
2787
|
handlerSensors,
|
|
2732
2788
|
Array.isArray(intentSensors) ? intentSensors : void 0,
|
|
2733
2789
|
Array.isArray(meta?.is) ? meta.is : void 0
|
|
@@ -2869,8 +2925,10 @@ var init_intent_router = __esm({
|
|
|
2869
2925
|
if (!this.observerDispatcher || bindings.length === 0) return;
|
|
2870
2926
|
await this.observerDispatcher.dispatch(bindings, context);
|
|
2871
2927
|
}
|
|
2872
|
-
async runIntentSensors(
|
|
2873
|
-
for (const
|
|
2928
|
+
async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
|
|
2929
|
+
for (const binding of sensorBindings) {
|
|
2930
|
+
if (binding.when !== stage && binding.when !== "both") continue;
|
|
2931
|
+
const sensorRef = binding.ref;
|
|
2874
2932
|
const sensor = this.resolveIntentSensor(sensorRef);
|
|
2875
2933
|
const sensorName = sensorRefKey(sensorRef);
|
|
2876
2934
|
if (!sensor) {
|
|
@@ -2887,9 +2945,12 @@ var init_intent_router = __esm({
|
|
|
2887
2945
|
frameBody: frame.body,
|
|
2888
2946
|
metadata: {
|
|
2889
2947
|
phase: "intent",
|
|
2948
|
+
stage,
|
|
2890
2949
|
intent,
|
|
2891
2950
|
schema: this.getSchema(intent),
|
|
2892
|
-
validators: this.getValidators(intent)
|
|
2951
|
+
validators: this.getValidators(intent),
|
|
2952
|
+
decodedBody: extras?.decodedBody,
|
|
2953
|
+
effect: extras?.effect
|
|
2893
2954
|
}
|
|
2894
2955
|
};
|
|
2895
2956
|
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
@@ -12730,6 +12791,8 @@ __export(index_exports, {
|
|
|
12730
12791
|
startStage: () => startStage,
|
|
12731
12792
|
tieKnot: () => tieKnot,
|
|
12732
12793
|
tlv: () => tlv,
|
|
12794
|
+
toIntentSensorBinding: () => toIntentSensorBinding,
|
|
12795
|
+
toObserverBinding: () => toObserverBinding,
|
|
12733
12796
|
u64be: () => u64be,
|
|
12734
12797
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
12735
12798
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
@@ -12761,6 +12824,7 @@ var init_index = __esm({
|
|
|
12761
12824
|
init_intent_body_decorator();
|
|
12762
12825
|
init_intent_sensors_decorator();
|
|
12763
12826
|
init_observer_decorator();
|
|
12827
|
+
init_observer_decorator();
|
|
12764
12828
|
init_handler_sensors_decorator();
|
|
12765
12829
|
init_sensor_decorator();
|
|
12766
12830
|
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|
|
@@ -13128,6 +13192,8 @@ export {
|
|
|
13128
13192
|
startStage,
|
|
13129
13193
|
tieKnot,
|
|
13130
13194
|
tlv,
|
|
13195
|
+
toIntentSensorBinding,
|
|
13196
|
+
toObserverBinding,
|
|
13131
13197
|
u64be,
|
|
13132
13198
|
unpackPasskeyLoginOptionsReq,
|
|
13133
13199
|
unpackPasskeyLoginVerifyReq,
|