@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.mjs
CHANGED
|
@@ -633,9 +633,12 @@ var require_dto_schema_util = __commonJS({
|
|
|
633
633
|
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
634
634
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
635
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
|
+
}
|
|
636
639
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
637
640
|
if (fieldMetas.length === 0) {
|
|
638
|
-
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 }).`);
|
|
639
642
|
}
|
|
640
643
|
const tagByProp = /* @__PURE__ */ new Map();
|
|
641
644
|
const fields = fieldMetas.map((m) => {
|
|
@@ -663,14 +666,18 @@ var require_dto_schema_util = __commonJS({
|
|
|
663
666
|
return { fields, validators };
|
|
664
667
|
}
|
|
665
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
|
+
}
|
|
666
672
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
667
673
|
if (fieldMetas.length === 0) {
|
|
668
|
-
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 }).`);
|
|
669
675
|
}
|
|
670
676
|
const tagMap = /* @__PURE__ */ new Map();
|
|
671
677
|
for (const m of fieldMetas) {
|
|
672
678
|
tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
|
|
673
679
|
}
|
|
680
|
+
const afterDecode = dto.afterDecode;
|
|
674
681
|
return (bodyBytes) => {
|
|
675
682
|
const tlvMap2 = (0, tlv_1.decodeTLVs)(new Uint8Array(bodyBytes));
|
|
676
683
|
const result = {};
|
|
@@ -705,6 +712,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
705
712
|
result[meta.property] = raw;
|
|
706
713
|
}
|
|
707
714
|
}
|
|
715
|
+
afterDecode?.(result);
|
|
708
716
|
return result;
|
|
709
717
|
};
|
|
710
718
|
}
|