@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.d.mts
CHANGED
|
@@ -701,6 +701,7 @@ interface IntentRoute extends AxisIntentSensorOptions {
|
|
|
701
701
|
absolute?: boolean;
|
|
702
702
|
frame?: boolean;
|
|
703
703
|
kind?: IntentKind;
|
|
704
|
+
sensitivity?: SensitivityLevel;
|
|
704
705
|
chain?: boolean | ChainOptions;
|
|
705
706
|
bodyProfile?: 'TLV_MAP' | 'RAW' | 'TLV_OBJ' | 'TLV_ARR';
|
|
706
707
|
tlv?: IntentTlvField[];
|
|
@@ -708,6 +709,7 @@ interface IntentRoute extends AxisIntentSensorOptions {
|
|
|
708
709
|
}
|
|
709
710
|
interface IntentOptions extends AxisIntentSensorOptions {
|
|
710
711
|
kind?: IntentKind;
|
|
712
|
+
sensitivity?: SensitivityLevel;
|
|
711
713
|
absolute?: boolean;
|
|
712
714
|
frame?: boolean;
|
|
713
715
|
chain?: boolean | ChainOptions;
|
|
@@ -791,6 +793,7 @@ declare function extractDtoSchema(dto: Function): DtoSchema;
|
|
|
791
793
|
declare function buildDtoDecoder(dto: Function): (bodyBytes: Buffer) => Record<string, any>;
|
|
792
794
|
|
|
793
795
|
declare abstract class AxisTlvDto {
|
|
796
|
+
static afterDecode?(dto: Record<string, any>): void;
|
|
794
797
|
}
|
|
795
798
|
|
|
796
799
|
declare class AxisIdDto extends AxisTlvDto {
|
|
@@ -1498,7 +1501,7 @@ declare class IntentRouter {
|
|
|
1498
1501
|
route(frame: AxisFrame$2): Promise<AxisEffect>;
|
|
1499
1502
|
private logIntent;
|
|
1500
1503
|
registerIntentMeta(intent: string, proto: object, methodName: string, handlerSensors?: AxisIntentSensorRef[], handlerObservers?: AxisObserverBinding[]): void;
|
|
1501
|
-
getSensitivity(intent: string):
|
|
1504
|
+
getSensitivity(intent: string): SensitivityLevel | undefined;
|
|
1502
1505
|
getContract(intent: string): Record<string, any> | undefined;
|
|
1503
1506
|
getRequiredProof(intent: string): RequiredProofKind[] | undefined;
|
|
1504
1507
|
isPublic(intent: string): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -701,6 +701,7 @@ interface IntentRoute extends AxisIntentSensorOptions {
|
|
|
701
701
|
absolute?: boolean;
|
|
702
702
|
frame?: boolean;
|
|
703
703
|
kind?: IntentKind;
|
|
704
|
+
sensitivity?: SensitivityLevel;
|
|
704
705
|
chain?: boolean | ChainOptions;
|
|
705
706
|
bodyProfile?: 'TLV_MAP' | 'RAW' | 'TLV_OBJ' | 'TLV_ARR';
|
|
706
707
|
tlv?: IntentTlvField[];
|
|
@@ -708,6 +709,7 @@ interface IntentRoute extends AxisIntentSensorOptions {
|
|
|
708
709
|
}
|
|
709
710
|
interface IntentOptions extends AxisIntentSensorOptions {
|
|
710
711
|
kind?: IntentKind;
|
|
712
|
+
sensitivity?: SensitivityLevel;
|
|
711
713
|
absolute?: boolean;
|
|
712
714
|
frame?: boolean;
|
|
713
715
|
chain?: boolean | ChainOptions;
|
|
@@ -791,6 +793,7 @@ declare function extractDtoSchema(dto: Function): DtoSchema;
|
|
|
791
793
|
declare function buildDtoDecoder(dto: Function): (bodyBytes: Buffer) => Record<string, any>;
|
|
792
794
|
|
|
793
795
|
declare abstract class AxisTlvDto {
|
|
796
|
+
static afterDecode?(dto: Record<string, any>): void;
|
|
794
797
|
}
|
|
795
798
|
|
|
796
799
|
declare class AxisIdDto extends AxisTlvDto {
|
|
@@ -1498,7 +1501,7 @@ declare class IntentRouter {
|
|
|
1498
1501
|
route(frame: AxisFrame$2): Promise<AxisEffect>;
|
|
1499
1502
|
private logIntent;
|
|
1500
1503
|
registerIntentMeta(intent: string, proto: object, methodName: string, handlerSensors?: AxisIntentSensorRef[], handlerObservers?: AxisObserverBinding[]): void;
|
|
1501
|
-
getSensitivity(intent: string):
|
|
1504
|
+
getSensitivity(intent: string): SensitivityLevel | undefined;
|
|
1502
1505
|
getContract(intent: string): Record<string, any> | undefined;
|
|
1503
1506
|
getRequiredProof(intent: string): RequiredProofKind[] | undefined;
|
|
1504
1507
|
isPublic(intent: string): boolean;
|
package/dist/index.js
CHANGED
|
@@ -327,12 +327,16 @@ __export(intent_decorator_exports, {
|
|
|
327
327
|
});
|
|
328
328
|
function Intent(action, options) {
|
|
329
329
|
return (target, propertyKey) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
330
|
+
const metadata = { intent: action, ...options };
|
|
331
|
+
Reflect.defineMetadata(INTENT_METADATA_KEY, metadata, target, propertyKey);
|
|
332
|
+
if (options?.sensitivity) {
|
|
333
|
+
Reflect.defineMetadata(
|
|
334
|
+
SENSITIVITY_METADATA_KEY,
|
|
335
|
+
options.sensitivity,
|
|
336
|
+
target,
|
|
337
|
+
propertyKey
|
|
338
|
+
);
|
|
339
|
+
}
|
|
336
340
|
const routes = Reflect.getMetadata(INTENT_ROUTES_KEY, target.constructor) || [];
|
|
337
341
|
routes.push({
|
|
338
342
|
action,
|
|
@@ -340,6 +344,7 @@ function Intent(action, options) {
|
|
|
340
344
|
absolute: options?.absolute,
|
|
341
345
|
frame: options?.frame,
|
|
342
346
|
kind: options?.kind,
|
|
347
|
+
sensitivity: options?.sensitivity,
|
|
343
348
|
chain: options?.chain,
|
|
344
349
|
bodyProfile: options?.bodyProfile,
|
|
345
350
|
tlv: options?.tlv,
|
|
@@ -353,6 +358,7 @@ var import_reflect_metadata4, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
|
|
|
353
358
|
var init_intent_decorator = __esm({
|
|
354
359
|
"src/decorators/intent.decorator.ts"() {
|
|
355
360
|
import_reflect_metadata4 = require("reflect-metadata");
|
|
361
|
+
init_intent_policy_decorator();
|
|
356
362
|
INTENT_METADATA_KEY = "axis:intent";
|
|
357
363
|
INTENT_ROUTES_KEY = "axis:intent_routes";
|
|
358
364
|
}
|
|
@@ -615,9 +621,12 @@ var require_dto_schema_util = __commonJS({
|
|
|
615
621
|
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
616
622
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
617
623
|
function extractDtoSchema2(dto) {
|
|
624
|
+
if (typeof dto !== "function") {
|
|
625
|
+
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?`);
|
|
626
|
+
}
|
|
618
627
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
619
628
|
if (fieldMetas.length === 0) {
|
|
620
|
-
throw new Error(`DTO class ${dto.name} has no @TlvField decorators \u2014 nothing to validate
|
|
629
|
+
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 }).`);
|
|
621
630
|
}
|
|
622
631
|
const tagByProp = /* @__PURE__ */ new Map();
|
|
623
632
|
const fields = fieldMetas.map((m) => {
|
|
@@ -645,14 +654,18 @@ var require_dto_schema_util = __commonJS({
|
|
|
645
654
|
return { fields, validators };
|
|
646
655
|
}
|
|
647
656
|
function buildDtoDecoder2(dto) {
|
|
657
|
+
if (typeof dto !== "function") {
|
|
658
|
+
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?`);
|
|
659
|
+
}
|
|
648
660
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
649
661
|
if (fieldMetas.length === 0) {
|
|
650
|
-
throw new Error(`DTO class ${dto.name} has no @TlvField decorators \u2014 cannot build decoder
|
|
662
|
+
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 }).`);
|
|
651
663
|
}
|
|
652
664
|
const tagMap = /* @__PURE__ */ new Map();
|
|
653
665
|
for (const m of fieldMetas) {
|
|
654
666
|
tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
|
|
655
667
|
}
|
|
668
|
+
const afterDecode = dto.afterDecode;
|
|
656
669
|
return (bodyBytes) => {
|
|
657
670
|
const tlvMap2 = (0, tlv_1.decodeTLVs)(new Uint8Array(bodyBytes));
|
|
658
671
|
const result = {};
|
|
@@ -687,6 +700,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
687
700
|
result[meta.property] = raw;
|
|
688
701
|
}
|
|
689
702
|
}
|
|
703
|
+
afterDecode?.(result);
|
|
690
704
|
return result;
|
|
691
705
|
};
|
|
692
706
|
}
|
|
@@ -2578,7 +2592,7 @@ var require_intent_router = __commonJS({
|
|
|
2578
2592
|
}
|
|
2579
2593
|
const methodSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto, methodName);
|
|
2580
2594
|
const classSensitivity = Reflect.getMetadata(intent_policy_decorator_1.SENSITIVITY_METADATA_KEY, proto.constructor);
|
|
2581
|
-
const sensitivity = methodSensitivity ?? classSensitivity;
|
|
2595
|
+
const sensitivity = meta?.sensitivity ?? methodSensitivity ?? classSensitivity;
|
|
2582
2596
|
if (sensitivity) {
|
|
2583
2597
|
this.intentSensitivity.set(intent, sensitivity);
|
|
2584
2598
|
}
|