@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.js
CHANGED
|
@@ -267,17 +267,76 @@ var init_intent_policy_decorator = __esm({
|
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
|
|
270
|
-
// src/decorators/handler.decorator.ts
|
|
271
|
-
function
|
|
270
|
+
// src/decorators/handler-sensors.decorator.ts
|
|
271
|
+
function HandlerSensors(sensors) {
|
|
272
272
|
return (target) => {
|
|
273
|
-
Reflect.defineMetadata(
|
|
273
|
+
Reflect.defineMetadata(HANDLER_SENSORS_KEY, sensors, target);
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
-
var import_reflect_metadata4,
|
|
277
|
-
var
|
|
278
|
-
"src/decorators/handler.decorator.ts"() {
|
|
276
|
+
var import_reflect_metadata4, HANDLER_SENSORS_KEY;
|
|
277
|
+
var init_handler_sensors_decorator = __esm({
|
|
278
|
+
"src/decorators/handler-sensors.decorator.ts"() {
|
|
279
279
|
import_reflect_metadata4 = require("reflect-metadata");
|
|
280
|
-
|
|
280
|
+
HANDLER_SENSORS_KEY = "axis:handler:sensors";
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// src/decorators/observer.decorator.ts
|
|
285
|
+
function isBindingOptions(value) {
|
|
286
|
+
return !!value && typeof value === "object" && "use" in value;
|
|
287
|
+
}
|
|
288
|
+
function isDefinitionOptions(value) {
|
|
289
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && !isBindingOptions(value);
|
|
290
|
+
}
|
|
291
|
+
function toObserverBinding(input) {
|
|
292
|
+
if (!input) return null;
|
|
293
|
+
if (isBindingOptions(input)) {
|
|
294
|
+
const refs = Array.isArray(input.use) ? input.use : [input.use];
|
|
295
|
+
return { refs, tags: input.tags, events: input.events };
|
|
296
|
+
}
|
|
297
|
+
if (Array.isArray(input)) {
|
|
298
|
+
return { refs: input };
|
|
299
|
+
}
|
|
300
|
+
if (typeof input === "function" || typeof input === "string") {
|
|
301
|
+
return { refs: [input] };
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
function Observer(input) {
|
|
306
|
+
return ((target, propertyKey) => {
|
|
307
|
+
const binding = toObserverBinding(input);
|
|
308
|
+
if (binding) {
|
|
309
|
+
if (propertyKey !== void 0) {
|
|
310
|
+
const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
|
|
311
|
+
existing2.push(binding);
|
|
312
|
+
Reflect.defineMetadata(
|
|
313
|
+
OBSERVER_BINDINGS_KEY,
|
|
314
|
+
existing2,
|
|
315
|
+
target,
|
|
316
|
+
propertyKey
|
|
317
|
+
);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
321
|
+
existing.push(binding);
|
|
322
|
+
Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (propertyKey !== void 0) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
"@Observer method usage must reference one or more observer classes or names"
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
const definition = isDefinitionOptions(input) ? input : {};
|
|
331
|
+
Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
var import_reflect_metadata5, OBSERVER_METADATA_KEY, OBSERVER_BINDINGS_KEY;
|
|
335
|
+
var init_observer_decorator = __esm({
|
|
336
|
+
"src/decorators/observer.decorator.ts"() {
|
|
337
|
+
import_reflect_metadata5 = require("reflect-metadata");
|
|
338
|
+
OBSERVER_METADATA_KEY = "axis:observer";
|
|
339
|
+
OBSERVER_BINDINGS_KEY = "axis:observer:bindings";
|
|
281
340
|
}
|
|
282
341
|
});
|
|
283
342
|
|
|
@@ -287,15 +346,30 @@ function IntentBody(decoder) {
|
|
|
287
346
|
Reflect.defineMetadata(INTENT_BODY_KEY, decoder, target, propertyKey);
|
|
288
347
|
};
|
|
289
348
|
}
|
|
290
|
-
var
|
|
349
|
+
var import_reflect_metadata6, INTENT_BODY_KEY;
|
|
291
350
|
var init_intent_body_decorator = __esm({
|
|
292
351
|
"src/decorators/intent-body.decorator.ts"() {
|
|
293
|
-
|
|
352
|
+
import_reflect_metadata6 = require("reflect-metadata");
|
|
294
353
|
INTENT_BODY_KEY = "axis:intent:body";
|
|
295
354
|
}
|
|
296
355
|
});
|
|
297
356
|
|
|
298
357
|
// src/decorators/intent.decorator.ts
|
|
358
|
+
function isIntentSensorBindingOptions(value) {
|
|
359
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && "use" in value;
|
|
360
|
+
}
|
|
361
|
+
function toIntentSensorBinding(input) {
|
|
362
|
+
if (isIntentSensorBindingOptions(input)) {
|
|
363
|
+
return {
|
|
364
|
+
ref: input.use,
|
|
365
|
+
when: input.when || "before"
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
ref: input,
|
|
370
|
+
when: "before"
|
|
371
|
+
};
|
|
372
|
+
}
|
|
299
373
|
function Intent(action, options) {
|
|
300
374
|
return (target, propertyKey) => {
|
|
301
375
|
const metadata = { intent: action, ...options };
|
|
@@ -333,10 +407,10 @@ function Intent(action, options) {
|
|
|
333
407
|
Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
|
|
334
408
|
};
|
|
335
409
|
}
|
|
336
|
-
var
|
|
410
|
+
var import_reflect_metadata7, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
|
|
337
411
|
var init_intent_decorator = __esm({
|
|
338
412
|
"src/decorators/intent.decorator.ts"() {
|
|
339
|
-
|
|
413
|
+
import_reflect_metadata7 = require("reflect-metadata");
|
|
340
414
|
init_intent_body_decorator();
|
|
341
415
|
init_intent_policy_decorator();
|
|
342
416
|
INTENT_METADATA_KEY = "axis:intent";
|
|
@@ -344,90 +418,62 @@ var init_intent_decorator = __esm({
|
|
|
344
418
|
}
|
|
345
419
|
});
|
|
346
420
|
|
|
347
|
-
// src/decorators/
|
|
348
|
-
function
|
|
349
|
-
return (target
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (isBindingOptions(input)) {
|
|
371
|
-
const refs = Array.isArray(input.use) ? input.use : [input.use];
|
|
372
|
-
return { refs, tags: input.tags, events: input.events };
|
|
373
|
-
}
|
|
374
|
-
if (Array.isArray(input)) {
|
|
375
|
-
return { refs: input };
|
|
376
|
-
}
|
|
377
|
-
if (typeof input === "function" || typeof input === "string") {
|
|
378
|
-
return { refs: [input] };
|
|
379
|
-
}
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
function Observer(input) {
|
|
383
|
-
return ((target, propertyKey) => {
|
|
384
|
-
const binding = toBinding(input);
|
|
385
|
-
if (binding) {
|
|
386
|
-
if (propertyKey !== void 0) {
|
|
387
|
-
const existing2 = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target, propertyKey) || [];
|
|
388
|
-
existing2.push(binding);
|
|
389
|
-
Reflect.defineMetadata(
|
|
390
|
-
OBSERVER_BINDINGS_KEY,
|
|
391
|
-
existing2,
|
|
392
|
-
target,
|
|
393
|
-
propertyKey
|
|
394
|
-
);
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
398
|
-
existing.push(binding);
|
|
399
|
-
Reflect.defineMetadata(OBSERVER_BINDINGS_KEY, existing, target);
|
|
400
|
-
return;
|
|
421
|
+
// src/decorators/handler.decorator.ts
|
|
422
|
+
function Handler(intentOrOptions, options) {
|
|
423
|
+
return (target) => {
|
|
424
|
+
const intent = typeof intentOrOptions === "string" ? intentOrOptions : void 0;
|
|
425
|
+
const handlerOptions = typeof intentOrOptions === "string" ? options : intentOrOptions;
|
|
426
|
+
const sensorBindings = Array.isArray(handlerOptions?.is) ? handlerOptions.is.map(
|
|
427
|
+
(input) => toIntentSensorBinding(input)
|
|
428
|
+
) : [];
|
|
429
|
+
const observerBindings = Array.isArray(
|
|
430
|
+
handlerOptions?.observe
|
|
431
|
+
) ? handlerOptions.observe.map((input) => toObserverBinding(input)).filter((binding) => !!binding) : [];
|
|
432
|
+
Reflect.defineMetadata(
|
|
433
|
+
HANDLER_METADATA_KEY,
|
|
434
|
+
{ intent, ...handlerOptions || {} },
|
|
435
|
+
target
|
|
436
|
+
);
|
|
437
|
+
if (sensorBindings.length > 0) {
|
|
438
|
+
const existing = Reflect.getMetadata(HANDLER_SENSORS_KEY, target) || [];
|
|
439
|
+
Reflect.defineMetadata(
|
|
440
|
+
HANDLER_SENSORS_KEY,
|
|
441
|
+
[...existing, ...sensorBindings],
|
|
442
|
+
target
|
|
443
|
+
);
|
|
401
444
|
}
|
|
402
|
-
if (
|
|
403
|
-
|
|
404
|
-
|
|
445
|
+
if (observerBindings.length > 0) {
|
|
446
|
+
const existing = Reflect.getMetadata(OBSERVER_BINDINGS_KEY, target) || [];
|
|
447
|
+
Reflect.defineMetadata(
|
|
448
|
+
OBSERVER_BINDINGS_KEY,
|
|
449
|
+
[...existing, ...observerBindings],
|
|
450
|
+
target
|
|
405
451
|
);
|
|
406
452
|
}
|
|
407
|
-
|
|
408
|
-
Reflect.defineMetadata(OBSERVER_METADATA_KEY, definition, target);
|
|
409
|
-
});
|
|
453
|
+
};
|
|
410
454
|
}
|
|
411
|
-
var import_reflect_metadata8,
|
|
412
|
-
var
|
|
413
|
-
"src/decorators/
|
|
455
|
+
var import_reflect_metadata8, HANDLER_METADATA_KEY;
|
|
456
|
+
var init_handler_decorator = __esm({
|
|
457
|
+
"src/decorators/handler.decorator.ts"() {
|
|
414
458
|
import_reflect_metadata8 = require("reflect-metadata");
|
|
415
|
-
|
|
416
|
-
|
|
459
|
+
init_handler_sensors_decorator();
|
|
460
|
+
init_observer_decorator();
|
|
461
|
+
init_intent_decorator();
|
|
462
|
+
HANDLER_METADATA_KEY = "axis:handler";
|
|
417
463
|
}
|
|
418
464
|
});
|
|
419
465
|
|
|
420
|
-
// src/decorators/
|
|
421
|
-
function
|
|
422
|
-
return (target) => {
|
|
423
|
-
Reflect.defineMetadata(
|
|
466
|
+
// src/decorators/intent-sensors.decorator.ts
|
|
467
|
+
function IntentSensors(sensors) {
|
|
468
|
+
return (target, propertyKey) => {
|
|
469
|
+
Reflect.defineMetadata(INTENT_SENSORS_KEY, sensors, target, propertyKey);
|
|
424
470
|
};
|
|
425
471
|
}
|
|
426
|
-
var import_reflect_metadata9,
|
|
427
|
-
var
|
|
428
|
-
"src/decorators/
|
|
472
|
+
var import_reflect_metadata9, INTENT_SENSORS_KEY;
|
|
473
|
+
var init_intent_sensors_decorator = __esm({
|
|
474
|
+
"src/decorators/intent-sensors.decorator.ts"() {
|
|
429
475
|
import_reflect_metadata9 = require("reflect-metadata");
|
|
430
|
-
|
|
476
|
+
INTENT_SENSORS_KEY = "axis:intent:sensors";
|
|
431
477
|
}
|
|
432
478
|
});
|
|
433
479
|
|
|
@@ -1031,6 +1077,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1031
1077
|
timestamp: startedAt,
|
|
1032
1078
|
chainId: envelope.chainId,
|
|
1033
1079
|
stepId: step.stepId,
|
|
1080
|
+
handler: step.handler,
|
|
1034
1081
|
intent: step.intent,
|
|
1035
1082
|
envelope,
|
|
1036
1083
|
step,
|
|
@@ -1065,6 +1112,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1065
1112
|
timestamp: finishedAt,
|
|
1066
1113
|
chainId: envelope.chainId,
|
|
1067
1114
|
stepId: step.stepId,
|
|
1115
|
+
handler: step.handler,
|
|
1068
1116
|
intent: step.intent,
|
|
1069
1117
|
effect,
|
|
1070
1118
|
envelope,
|
|
@@ -1079,6 +1127,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1079
1127
|
timestamp: finishedAt,
|
|
1080
1128
|
chainId: envelope.chainId,
|
|
1081
1129
|
stepId: step.stepId,
|
|
1130
|
+
handler: step.handler,
|
|
1082
1131
|
intent: step.intent,
|
|
1083
1132
|
envelope,
|
|
1084
1133
|
step,
|
|
@@ -1093,6 +1142,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1093
1142
|
timestamp: finishedAt,
|
|
1094
1143
|
chainId: envelope.chainId,
|
|
1095
1144
|
stepId: step.stepId,
|
|
1145
|
+
handler: step.handler,
|
|
1096
1146
|
intent: step.intent,
|
|
1097
1147
|
effect,
|
|
1098
1148
|
envelope,
|
|
@@ -1123,6 +1173,7 @@ var init_axis_chain_executor = __esm({
|
|
|
1123
1173
|
timestamp: finishedAt,
|
|
1124
1174
|
chainId: envelope.chainId,
|
|
1125
1175
|
stepId: step.stepId,
|
|
1176
|
+
handler: step.handler,
|
|
1126
1177
|
intent: step.intent,
|
|
1127
1178
|
error: error.message,
|
|
1128
1179
|
envelope,
|
|
@@ -2254,15 +2305,19 @@ function observerRefKey(ref) {
|
|
|
2254
2305
|
function sensorRefKey(ref) {
|
|
2255
2306
|
return typeof ref === "string" ? ref : ref.name;
|
|
2256
2307
|
}
|
|
2257
|
-
function
|
|
2308
|
+
function sensorBindingKey(binding) {
|
|
2309
|
+
return `${binding.when}:${sensorRefKey(binding.ref)}`;
|
|
2310
|
+
}
|
|
2311
|
+
function mergeIntentSensorBindings(...sensorGroups) {
|
|
2258
2312
|
const merged = /* @__PURE__ */ new Map();
|
|
2259
2313
|
for (const group of sensorGroups) {
|
|
2260
2314
|
if (!Array.isArray(group)) continue;
|
|
2261
|
-
for (const
|
|
2262
|
-
const
|
|
2315
|
+
for (const input of group) {
|
|
2316
|
+
const binding = toIntentSensorBinding(input);
|
|
2317
|
+
const key = sensorBindingKey(binding);
|
|
2263
2318
|
const existing = merged.get(key);
|
|
2264
|
-
if (!existing || typeof existing === "string" && typeof ref !== "string") {
|
|
2265
|
-
merged.set(key,
|
|
2319
|
+
if (!existing || typeof existing.ref === "string" && typeof binding.ref !== "string") {
|
|
2320
|
+
merged.set(key, binding);
|
|
2266
2321
|
}
|
|
2267
2322
|
}
|
|
2268
2323
|
}
|
|
@@ -2338,6 +2393,8 @@ var init_intent_router = __esm({
|
|
|
2338
2393
|
this.handlers = /* @__PURE__ */ new Map();
|
|
2339
2394
|
/** Per-intent sensor refs (resolved through SensorRegistry at call time) */
|
|
2340
2395
|
this.intentSensors = /* @__PURE__ */ new Map();
|
|
2396
|
+
/** Per-intent handler identifier (e.g. UsersHandler.usersPage) */
|
|
2397
|
+
this.intentHandlerRefs = /* @__PURE__ */ new Map();
|
|
2341
2398
|
/** Per-intent body decoders */
|
|
2342
2399
|
this.intentDecoders = /* @__PURE__ */ new Map();
|
|
2343
2400
|
/** Per-intent TLV schemas */
|
|
@@ -2413,6 +2470,16 @@ var init_intent_router = __esm({
|
|
|
2413
2470
|
*/
|
|
2414
2471
|
register(intent, handler) {
|
|
2415
2472
|
this.handlers.set(intent, handler);
|
|
2473
|
+
if (typeof handler === "function" && handler.name) {
|
|
2474
|
+
this.intentHandlerRefs.set(intent, handler.name);
|
|
2475
|
+
} else if (handler && typeof handler === "object") {
|
|
2476
|
+
const objectName = handler.constructor?.name;
|
|
2477
|
+
if (objectName) {
|
|
2478
|
+
this.intentHandlerRefs.set(intent, `${objectName}.handle`);
|
|
2479
|
+
}
|
|
2480
|
+
} else {
|
|
2481
|
+
this.intentHandlerRefs.set(intent, `intent:${intent}`);
|
|
2482
|
+
}
|
|
2416
2483
|
}
|
|
2417
2484
|
/**
|
|
2418
2485
|
* Automatically registers all `@Intent`-decorated methods from a handler instance.
|
|
@@ -2443,6 +2510,10 @@ var init_intent_router = __esm({
|
|
|
2443
2510
|
} else {
|
|
2444
2511
|
this.register(intentName, fn);
|
|
2445
2512
|
}
|
|
2513
|
+
this.intentHandlerRefs.set(
|
|
2514
|
+
intentName,
|
|
2515
|
+
`${instance.constructor.name}.${String(route.methodName)}`
|
|
2516
|
+
);
|
|
2446
2517
|
this.registerIntentMeta(
|
|
2447
2518
|
intentName,
|
|
2448
2519
|
proto,
|
|
@@ -2483,15 +2554,18 @@ var init_intent_router = __esm({
|
|
|
2483
2554
|
async route(frame) {
|
|
2484
2555
|
const start = process.hrtime();
|
|
2485
2556
|
let intent = "unknown";
|
|
2557
|
+
let handlerRef;
|
|
2486
2558
|
try {
|
|
2487
2559
|
const intentBytes = frame.headers.get(import_axis_protocol2.TLV_INTENT);
|
|
2488
2560
|
if (!intentBytes) throw new Error("Missing intent");
|
|
2489
2561
|
intent = this.decoder.decode(intentBytes);
|
|
2562
|
+
handlerRef = this.intentHandlerRefs.get(intent);
|
|
2490
2563
|
const observerBindings = this.getObservers(intent);
|
|
2491
2564
|
await this.emitIntentObservers(observerBindings, {
|
|
2492
2565
|
event: "intent.received",
|
|
2493
2566
|
timestamp: Date.now(),
|
|
2494
2567
|
intent,
|
|
2568
|
+
handler: handlerRef,
|
|
2495
2569
|
frame
|
|
2496
2570
|
});
|
|
2497
2571
|
let effect;
|
|
@@ -2566,9 +2640,9 @@ var init_intent_router = __esm({
|
|
|
2566
2640
|
if (!handler) {
|
|
2567
2641
|
throw new Error(`Intent not found: ${intent}`);
|
|
2568
2642
|
}
|
|
2569
|
-
const
|
|
2570
|
-
if (
|
|
2571
|
-
await this.runIntentSensors(
|
|
2643
|
+
const sensorBindings = this.intentSensors.get(intent);
|
|
2644
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2645
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "before");
|
|
2572
2646
|
}
|
|
2573
2647
|
const decoder = this.intentDecoders.get(intent);
|
|
2574
2648
|
let decodedBody = frame.body;
|
|
@@ -2610,11 +2684,18 @@ var init_intent_router = __esm({
|
|
|
2610
2684
|
);
|
|
2611
2685
|
}
|
|
2612
2686
|
}
|
|
2687
|
+
if (sensorBindings && sensorBindings.length > 0) {
|
|
2688
|
+
await this.runIntentSensors(sensorBindings, intent, frame, "after", {
|
|
2689
|
+
decodedBody,
|
|
2690
|
+
effect
|
|
2691
|
+
});
|
|
2692
|
+
}
|
|
2613
2693
|
}
|
|
2614
2694
|
await this.emitIntentObservers(observerBindings, {
|
|
2615
2695
|
event: "intent.completed",
|
|
2616
2696
|
timestamp: Date.now(),
|
|
2617
2697
|
intent,
|
|
2698
|
+
handler: handlerRef,
|
|
2618
2699
|
frame,
|
|
2619
2700
|
effect,
|
|
2620
2701
|
metadata: effect.metadata
|
|
@@ -2626,6 +2707,7 @@ var init_intent_router = __esm({
|
|
|
2626
2707
|
event: "intent.failed",
|
|
2627
2708
|
timestamp: Date.now(),
|
|
2628
2709
|
intent,
|
|
2710
|
+
handler: handlerRef,
|
|
2629
2711
|
frame,
|
|
2630
2712
|
error: e.message
|
|
2631
2713
|
});
|
|
@@ -2653,7 +2735,7 @@ var init_intent_router = __esm({
|
|
|
2653
2735
|
methodName
|
|
2654
2736
|
);
|
|
2655
2737
|
const meta = Reflect.getMetadata(INTENT_METADATA_KEY, proto, methodName);
|
|
2656
|
-
const combined =
|
|
2738
|
+
const combined = mergeIntentSensorBindings(
|
|
2657
2739
|
handlerSensors,
|
|
2658
2740
|
Array.isArray(intentSensors) ? intentSensors : void 0,
|
|
2659
2741
|
Array.isArray(meta?.is) ? meta.is : void 0
|
|
@@ -2795,8 +2877,10 @@ var init_intent_router = __esm({
|
|
|
2795
2877
|
if (!this.observerDispatcher || bindings.length === 0) return;
|
|
2796
2878
|
await this.observerDispatcher.dispatch(bindings, context);
|
|
2797
2879
|
}
|
|
2798
|
-
async runIntentSensors(
|
|
2799
|
-
for (const
|
|
2880
|
+
async runIntentSensors(sensorBindings, intent, frame, stage, extras) {
|
|
2881
|
+
for (const binding of sensorBindings) {
|
|
2882
|
+
if (binding.when !== stage && binding.when !== "both") continue;
|
|
2883
|
+
const sensorRef = binding.ref;
|
|
2800
2884
|
const sensor = this.resolveIntentSensor(sensorRef);
|
|
2801
2885
|
const sensorName = sensorRefKey(sensorRef);
|
|
2802
2886
|
if (!sensor) {
|
|
@@ -2813,9 +2897,12 @@ var init_intent_router = __esm({
|
|
|
2813
2897
|
frameBody: frame.body,
|
|
2814
2898
|
metadata: {
|
|
2815
2899
|
phase: "intent",
|
|
2900
|
+
stage,
|
|
2816
2901
|
intent,
|
|
2817
2902
|
schema: this.getSchema(intent),
|
|
2818
|
-
validators: this.getValidators(intent)
|
|
2903
|
+
validators: this.getValidators(intent),
|
|
2904
|
+
decodedBody: extras?.decodedBody,
|
|
2905
|
+
effect: extras?.effect
|
|
2819
2906
|
}
|
|
2820
2907
|
};
|
|
2821
2908
|
if (sensor.supports && !sensor.supports(sensorInput)) continue;
|
|
@@ -7995,6 +8082,61 @@ var init_disk_upload_file_store = __esm({
|
|
|
7995
8082
|
function unique(values) {
|
|
7996
8083
|
return Array.from(new Set(values));
|
|
7997
8084
|
}
|
|
8085
|
+
function matchesObserverIntent(intents, intent) {
|
|
8086
|
+
if (!intents || intents.length === 0) {
|
|
8087
|
+
return true;
|
|
8088
|
+
}
|
|
8089
|
+
if (!intent) {
|
|
8090
|
+
return false;
|
|
8091
|
+
}
|
|
8092
|
+
return intents.includes(intent);
|
|
8093
|
+
}
|
|
8094
|
+
function normalizeHandlerToken(value) {
|
|
8095
|
+
return value.trim().toLowerCase();
|
|
8096
|
+
}
|
|
8097
|
+
function matchesObserverHandler(handlers, handler) {
|
|
8098
|
+
if (!handlers || handlers.length === 0) {
|
|
8099
|
+
return true;
|
|
8100
|
+
}
|
|
8101
|
+
if (!handler) {
|
|
8102
|
+
return false;
|
|
8103
|
+
}
|
|
8104
|
+
const normalizedHandler = normalizeHandlerToken(handler);
|
|
8105
|
+
return handlers.some((candidate) => {
|
|
8106
|
+
if (!candidate) {
|
|
8107
|
+
return false;
|
|
8108
|
+
}
|
|
8109
|
+
const normalizedCandidate = normalizeHandlerToken(candidate);
|
|
8110
|
+
return normalizedHandler === normalizedCandidate || normalizedHandler.endsWith(`.${normalizedCandidate}`) || normalizedHandler.startsWith(`${normalizedCandidate}.`) || normalizedCandidate.endsWith(`.${normalizedHandler}`) || normalizedCandidate.startsWith(`${normalizedHandler}.`);
|
|
8111
|
+
});
|
|
8112
|
+
}
|
|
8113
|
+
function observerRefKey2(ref) {
|
|
8114
|
+
return typeof ref === "string" ? ref : ref.name || "(anonymous)";
|
|
8115
|
+
}
|
|
8116
|
+
function mergeBindingRefs(...bindingGroups) {
|
|
8117
|
+
const merged = /* @__PURE__ */ new Map();
|
|
8118
|
+
for (const bindings of bindingGroups) {
|
|
8119
|
+
for (const binding of bindings) {
|
|
8120
|
+
for (const ref of binding.refs) {
|
|
8121
|
+
const key = observerRefKey2(ref);
|
|
8122
|
+
const current = merged.get(key);
|
|
8123
|
+
if (!current) {
|
|
8124
|
+
merged.set(key, {
|
|
8125
|
+
refs: [ref],
|
|
8126
|
+
tags: binding.tags ? [...new Set(binding.tags)] : void 0,
|
|
8127
|
+
events: binding.events ? [...new Set(binding.events)] : void 0
|
|
8128
|
+
});
|
|
8129
|
+
continue;
|
|
8130
|
+
}
|
|
8131
|
+
current.tags = Array.from(
|
|
8132
|
+
/* @__PURE__ */ new Set([...current.tags || [], ...binding.tags || []])
|
|
8133
|
+
);
|
|
8134
|
+
current.events = current.events === void 0 || binding.events === void 0 ? void 0 : Array.from(/* @__PURE__ */ new Set([...current.events || [], ...binding.events]));
|
|
8135
|
+
}
|
|
8136
|
+
}
|
|
8137
|
+
}
|
|
8138
|
+
return Array.from(merged.values());
|
|
8139
|
+
}
|
|
7998
8140
|
var ObserverDispatcherService;
|
|
7999
8141
|
var init_observer_dispatcher_service = __esm({
|
|
8000
8142
|
"src/engine/observer-dispatcher.service.ts"() {
|
|
@@ -8005,9 +8147,20 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8005
8147
|
this.logger = createAxisLogger(_ObserverDispatcherService.name);
|
|
8006
8148
|
}
|
|
8007
8149
|
async dispatch(bindings, context) {
|
|
8008
|
-
|
|
8150
|
+
const explicitBindings = bindings || [];
|
|
8151
|
+
const implicitRegistrations = this.getImplicitRegistrations();
|
|
8152
|
+
if (!explicitBindings.length && implicitRegistrations.length === 0) {
|
|
8153
|
+
return;
|
|
8154
|
+
}
|
|
8009
8155
|
const invoked = /* @__PURE__ */ new Set();
|
|
8010
|
-
|
|
8156
|
+
const implicitBindings = implicitRegistrations.map(
|
|
8157
|
+
(registration) => ({
|
|
8158
|
+
refs: [registration.instance.constructor],
|
|
8159
|
+
events: registration.events
|
|
8160
|
+
})
|
|
8161
|
+
);
|
|
8162
|
+
const merged = mergeBindingRefs(explicitBindings, implicitBindings);
|
|
8163
|
+
for (const binding of merged) {
|
|
8011
8164
|
if (binding.events && binding.events.length > 0 && !binding.events.includes(context.event)) {
|
|
8012
8165
|
continue;
|
|
8013
8166
|
}
|
|
@@ -8018,6 +8171,9 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8018
8171
|
continue;
|
|
8019
8172
|
}
|
|
8020
8173
|
if (invoked.has(registration.name)) continue;
|
|
8174
|
+
if (!matchesObserverIntent(registration.intents, context.intent) || !matchesObserverHandler(registration.handlers, context.handler)) {
|
|
8175
|
+
continue;
|
|
8176
|
+
}
|
|
8021
8177
|
if (registration.events && registration.events.length > 0 && !registration.events.includes(context.event)) {
|
|
8022
8178
|
continue;
|
|
8023
8179
|
}
|
|
@@ -8043,6 +8199,9 @@ var init_observer_dispatcher_service = __esm({
|
|
|
8043
8199
|
}
|
|
8044
8200
|
}
|
|
8045
8201
|
}
|
|
8202
|
+
getImplicitRegistrations() {
|
|
8203
|
+
return this.registry.list();
|
|
8204
|
+
}
|
|
8046
8205
|
};
|
|
8047
8206
|
}
|
|
8048
8207
|
});
|
|
@@ -12661,6 +12820,8 @@ __export(index_exports, {
|
|
|
12661
12820
|
startStage: () => startStage,
|
|
12662
12821
|
tieKnot: () => tieKnot,
|
|
12663
12822
|
tlv: () => tlv,
|
|
12823
|
+
toIntentSensorBinding: () => toIntentSensorBinding,
|
|
12824
|
+
toObserverBinding: () => toObserverBinding,
|
|
12664
12825
|
u64be: () => u64be,
|
|
12665
12826
|
unpackPasskeyLoginOptionsReq: () => unpackPasskeyLoginOptionsReq,
|
|
12666
12827
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
@@ -12693,6 +12854,7 @@ var init_index = __esm({
|
|
|
12693
12854
|
init_intent_body_decorator();
|
|
12694
12855
|
init_intent_sensors_decorator();
|
|
12695
12856
|
init_observer_decorator();
|
|
12857
|
+
init_observer_decorator();
|
|
12696
12858
|
init_handler_sensors_decorator();
|
|
12697
12859
|
init_sensor_decorator();
|
|
12698
12860
|
import_tlv_field2 = __toESM(require_tlv_field_decorator());
|
|
@@ -13044,6 +13206,8 @@ init_index();
|
|
|
13044
13206
|
startStage,
|
|
13045
13207
|
tieKnot,
|
|
13046
13208
|
tlv,
|
|
13209
|
+
toIntentSensorBinding,
|
|
13210
|
+
toObserverBinding,
|
|
13047
13211
|
u64be,
|
|
13048
13212
|
unpackPasskeyLoginOptionsReq,
|
|
13049
13213
|
unpackPasskeyLoginVerifyReq,
|