@nextera.one/axis-server-sdk 2.1.8 → 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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -793,6 +793,7 @@ declare function extractDtoSchema(dto: Function): DtoSchema;
|
|
|
793
793
|
declare function buildDtoDecoder(dto: Function): (bodyBytes: Buffer) => Record<string, any>;
|
|
794
794
|
|
|
795
795
|
declare abstract class AxisTlvDto {
|
|
796
|
+
static afterDecode?(dto: Record<string, any>): void;
|
|
796
797
|
}
|
|
797
798
|
|
|
798
799
|
declare class AxisIdDto extends AxisTlvDto {
|
package/dist/index.d.ts
CHANGED
|
@@ -793,6 +793,7 @@ declare function extractDtoSchema(dto: Function): DtoSchema;
|
|
|
793
793
|
declare function buildDtoDecoder(dto: Function): (bodyBytes: Buffer) => Record<string, any>;
|
|
794
794
|
|
|
795
795
|
declare abstract class AxisTlvDto {
|
|
796
|
+
static afterDecode?(dto: Record<string, any>): void;
|
|
796
797
|
}
|
|
797
798
|
|
|
798
799
|
declare class AxisIdDto extends AxisTlvDto {
|
package/dist/index.js
CHANGED
|
@@ -621,9 +621,12 @@ var require_dto_schema_util = __commonJS({
|
|
|
621
621
|
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
622
622
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
623
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
|
+
}
|
|
624
627
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
625
628
|
if (fieldMetas.length === 0) {
|
|
626
|
-
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 }).`);
|
|
627
630
|
}
|
|
628
631
|
const tagByProp = /* @__PURE__ */ new Map();
|
|
629
632
|
const fields = fieldMetas.map((m) => {
|
|
@@ -651,14 +654,18 @@ var require_dto_schema_util = __commonJS({
|
|
|
651
654
|
return { fields, validators };
|
|
652
655
|
}
|
|
653
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
|
+
}
|
|
654
660
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
655
661
|
if (fieldMetas.length === 0) {
|
|
656
|
-
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 }).`);
|
|
657
663
|
}
|
|
658
664
|
const tagMap = /* @__PURE__ */ new Map();
|
|
659
665
|
for (const m of fieldMetas) {
|
|
660
666
|
tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
|
|
661
667
|
}
|
|
668
|
+
const afterDecode = dto.afterDecode;
|
|
662
669
|
return (bodyBytes) => {
|
|
663
670
|
const tlvMap2 = (0, tlv_1.decodeTLVs)(new Uint8Array(bodyBytes));
|
|
664
671
|
const result = {};
|
|
@@ -693,6 +700,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
693
700
|
result[meta.property] = raw;
|
|
694
701
|
}
|
|
695
702
|
}
|
|
703
|
+
afterDecode?.(result);
|
|
696
704
|
return result;
|
|
697
705
|
};
|
|
698
706
|
}
|