@nextera.one/axis-server-sdk 2.1.7 → 2.1.9
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.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -334,12 +334,16 @@ __export(intent_decorator_exports, {
|
|
|
334
334
|
import "reflect-metadata";
|
|
335
335
|
function Intent(action, options) {
|
|
336
336
|
return (target, propertyKey) => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
337
|
+
const metadata = { intent: action, ...options };
|
|
338
|
+
Reflect.defineMetadata(INTENT_METADATA_KEY, metadata, target, propertyKey);
|
|
339
|
+
if (options?.sensitivity) {
|
|
340
|
+
Reflect.defineMetadata(
|
|
341
|
+
SENSITIVITY_METADATA_KEY,
|
|
342
|
+
options.sensitivity,
|
|
343
|
+
target,
|
|
344
|
+
propertyKey
|
|
345
|
+
);
|
|
346
|
+
}
|
|
343
347
|
const routes = Reflect.getMetadata(INTENT_ROUTES_KEY, target.constructor) || [];
|
|
344
348
|
routes.push({
|
|
345
349
|
action,
|
|
@@ -347,6 +351,7 @@ function Intent(action, options) {
|
|
|
347
351
|
absolute: options?.absolute,
|
|
348
352
|
frame: options?.frame,
|
|
349
353
|
kind: options?.kind,
|
|
354
|
+
sensitivity: options?.sensitivity,
|
|
350
355
|
chain: options?.chain,
|
|
351
356
|
bodyProfile: options?.bodyProfile,
|
|
352
357
|
tlv: options?.tlv,
|
|
@@ -359,6 +364,7 @@ function Intent(action, options) {
|
|
|
359
364
|
var INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
|
|
360
365
|
var init_intent_decorator = __esm({
|
|
361
366
|
"src/decorators/intent.decorator.ts"() {
|
|
367
|
+
init_intent_policy_decorator();
|
|
362
368
|
INTENT_METADATA_KEY = "axis:intent";
|
|
363
369
|
INTENT_ROUTES_KEY = "axis:intent_routes";
|
|
364
370
|
}
|
|
@@ -627,9 +633,12 @@ var require_dto_schema_util = __commonJS({
|
|
|
627
633
|
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
628
634
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
629
635
|
function extractDtoSchema2(dto) {
|
|
636
|
+
if (typeof dto !== "function") {
|
|
637
|
+
throw new Error(`extractDtoSchema expected a class constructor but received ${typeof dto} (${String(dto)}) \u2014 did you pass a plain object or instance to @Intent({ dto }) instead of a class?`);
|
|
638
|
+
}
|
|
630
639
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
631
640
|
if (fieldMetas.length === 0) {
|
|
632
|
-
throw new Error(`DTO class ${dto.name} has no @TlvField decorators \u2014 nothing to validate
|
|
641
|
+
throw new Error(`DTO class ${dto.name || "<anonymous>"} has no @TlvField decorators \u2014 nothing to validate. Make sure the class extends AxisTlvDto and its fields are annotated with @TlvField(tag, { kind }).`);
|
|
633
642
|
}
|
|
634
643
|
const tagByProp = /* @__PURE__ */ new Map();
|
|
635
644
|
const fields = fieldMetas.map((m) => {
|
|
@@ -657,14 +666,18 @@ var require_dto_schema_util = __commonJS({
|
|
|
657
666
|
return { fields, validators };
|
|
658
667
|
}
|
|
659
668
|
function buildDtoDecoder2(dto) {
|
|
669
|
+
if (typeof dto !== "function") {
|
|
670
|
+
throw new Error(`buildDtoDecoder expected a class constructor but received ${typeof dto} (${String(dto)}) \u2014 did you pass a plain object or instance to @Intent({ dto }) instead of a class?`);
|
|
671
|
+
}
|
|
660
672
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
661
673
|
if (fieldMetas.length === 0) {
|
|
662
|
-
throw new Error(`DTO class ${dto.name} has no @TlvField decorators \u2014 cannot build decoder
|
|
674
|
+
throw new Error(`DTO class ${dto.name || "<anonymous>"} has no @TlvField decorators \u2014 cannot build decoder. Make sure the class extends AxisTlvDto and its fields are annotated with @TlvField(tag, { kind }).`);
|
|
663
675
|
}
|
|
664
676
|
const tagMap = /* @__PURE__ */ new Map();
|
|
665
677
|
for (const m of fieldMetas) {
|
|
666
678
|
tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
|
|
667
679
|
}
|
|
680
|
+
const afterDecode = dto.afterDecode;
|
|
668
681
|
return (bodyBytes) => {
|
|
669
682
|
const tlvMap2 = (0, tlv_1.decodeTLVs)(new Uint8Array(bodyBytes));
|
|
670
683
|
const result = {};
|
|
@@ -699,6 +712,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
699
712
|
result[meta.property] = raw;
|
|
700
713
|
}
|
|
701
714
|
}
|
|
715
|
+
afterDecode?.(result);
|
|
702
716
|
return result;
|
|
703
717
|
};
|
|
704
718
|
}
|
|
@@ -2651,7 +2665,7 @@ var require_intent_router = __commonJS({
|
|
|
2651
2665
|
}
|
|
2652
2666
|
const methodSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto, methodName);
|
|
2653
2667
|
const classSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto.constructor);
|
|
2654
|
-
const sensitivity = methodSensitivity ?? classSensitivity;
|
|
2668
|
+
const sensitivity = meta?.sensitivity ?? methodSensitivity ?? classSensitivity;
|
|
2655
2669
|
if (sensitivity) {
|
|
2656
2670
|
this.intentSensitivity.set(intent, sensitivity);
|
|
2657
2671
|
}
|