@nextera.one/axis-server-sdk 2.1.8 → 2.2.0
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 +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +43 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -324,6 +324,25 @@ var init_handler_decorator = __esm({
|
|
|
324
324
|
}
|
|
325
325
|
});
|
|
326
326
|
|
|
327
|
+
// src/decorators/intent-body.decorator.ts
|
|
328
|
+
var intent_body_decorator_exports = {};
|
|
329
|
+
__export(intent_body_decorator_exports, {
|
|
330
|
+
INTENT_BODY_KEY: () => INTENT_BODY_KEY,
|
|
331
|
+
IntentBody: () => IntentBody
|
|
332
|
+
});
|
|
333
|
+
import "reflect-metadata";
|
|
334
|
+
function IntentBody(decoder) {
|
|
335
|
+
return (target, propertyKey) => {
|
|
336
|
+
Reflect.defineMetadata(INTENT_BODY_KEY, decoder, target, propertyKey);
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
var INTENT_BODY_KEY;
|
|
340
|
+
var init_intent_body_decorator = __esm({
|
|
341
|
+
"src/decorators/intent-body.decorator.ts"() {
|
|
342
|
+
INTENT_BODY_KEY = "axis:intent:body";
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
|
|
327
346
|
// src/decorators/intent.decorator.ts
|
|
328
347
|
var intent_decorator_exports = {};
|
|
329
348
|
__export(intent_decorator_exports, {
|
|
@@ -336,6 +355,14 @@ function Intent(action, options) {
|
|
|
336
355
|
return (target, propertyKey) => {
|
|
337
356
|
const metadata = { intent: action, ...options };
|
|
338
357
|
Reflect.defineMetadata(INTENT_METADATA_KEY, metadata, target, propertyKey);
|
|
358
|
+
if (options?.decoder) {
|
|
359
|
+
Reflect.defineMetadata(
|
|
360
|
+
INTENT_BODY_KEY,
|
|
361
|
+
options.decoder,
|
|
362
|
+
target,
|
|
363
|
+
propertyKey
|
|
364
|
+
);
|
|
365
|
+
}
|
|
339
366
|
if (options?.sensitivity) {
|
|
340
367
|
Reflect.defineMetadata(
|
|
341
368
|
SENSITIVITY_METADATA_KEY,
|
|
@@ -364,31 +391,13 @@ function Intent(action, options) {
|
|
|
364
391
|
var INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
|
|
365
392
|
var init_intent_decorator = __esm({
|
|
366
393
|
"src/decorators/intent.decorator.ts"() {
|
|
394
|
+
init_intent_body_decorator();
|
|
367
395
|
init_intent_policy_decorator();
|
|
368
396
|
INTENT_METADATA_KEY = "axis:intent";
|
|
369
397
|
INTENT_ROUTES_KEY = "axis:intent_routes";
|
|
370
398
|
}
|
|
371
399
|
});
|
|
372
400
|
|
|
373
|
-
// src/decorators/intent-body.decorator.ts
|
|
374
|
-
var intent_body_decorator_exports = {};
|
|
375
|
-
__export(intent_body_decorator_exports, {
|
|
376
|
-
INTENT_BODY_KEY: () => INTENT_BODY_KEY,
|
|
377
|
-
IntentBody: () => IntentBody
|
|
378
|
-
});
|
|
379
|
-
import "reflect-metadata";
|
|
380
|
-
function IntentBody(decoder) {
|
|
381
|
-
return (target, propertyKey) => {
|
|
382
|
-
Reflect.defineMetadata(INTENT_BODY_KEY, decoder, target, propertyKey);
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
var INTENT_BODY_KEY;
|
|
386
|
-
var init_intent_body_decorator = __esm({
|
|
387
|
-
"src/decorators/intent-body.decorator.ts"() {
|
|
388
|
-
INTENT_BODY_KEY = "axis:intent:body";
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
|
|
392
401
|
// src/decorators/intent-sensors.decorator.ts
|
|
393
402
|
var intent_sensors_decorator_exports = {};
|
|
394
403
|
__export(intent_sensors_decorator_exports, {
|
|
@@ -633,9 +642,12 @@ var require_dto_schema_util = __commonJS({
|
|
|
633
642
|
var tlv_field_decorator_1 = require_tlv_field_decorator();
|
|
634
643
|
var tlv_1 = (init_tlv(), __toCommonJS(tlv_exports));
|
|
635
644
|
function extractDtoSchema2(dto) {
|
|
645
|
+
if (typeof dto !== "function") {
|
|
646
|
+
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?`);
|
|
647
|
+
}
|
|
636
648
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
637
649
|
if (fieldMetas.length === 0) {
|
|
638
|
-
throw new Error(`DTO class ${dto.name} has no @TlvField decorators \u2014 nothing to validate
|
|
650
|
+
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
651
|
}
|
|
640
652
|
const tagByProp = /* @__PURE__ */ new Map();
|
|
641
653
|
const fields = fieldMetas.map((m) => {
|
|
@@ -663,14 +675,19 @@ var require_dto_schema_util = __commonJS({
|
|
|
663
675
|
return { fields, validators };
|
|
664
676
|
}
|
|
665
677
|
function buildDtoDecoder2(dto) {
|
|
678
|
+
if (typeof dto !== "function") {
|
|
679
|
+
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?`);
|
|
680
|
+
}
|
|
666
681
|
const fieldMetas = Reflect.getMetadata(tlv_field_decorator_1.TLV_FIELDS_KEY, dto) || [];
|
|
667
682
|
if (fieldMetas.length === 0) {
|
|
668
|
-
throw new Error(`DTO class ${dto.name} has no @TlvField decorators \u2014 cannot build decoder
|
|
683
|
+
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
684
|
}
|
|
670
685
|
const tagMap = /* @__PURE__ */ new Map();
|
|
671
686
|
for (const m of fieldMetas) {
|
|
672
687
|
tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
|
|
673
688
|
}
|
|
689
|
+
const dtoClass = dto;
|
|
690
|
+
const afterDecode = typeof dtoClass.afterDecode === "function" ? dtoClass.afterDecode.bind(dtoClass) : void 0;
|
|
674
691
|
return (bodyBytes) => {
|
|
675
692
|
const tlvMap2 = (0, tlv_1.decodeTLVs)(new Uint8Array(bodyBytes));
|
|
676
693
|
const result = {};
|
|
@@ -705,6 +722,7 @@ var require_dto_schema_util = __commonJS({
|
|
|
705
722
|
result[meta.property] = raw;
|
|
706
723
|
}
|
|
707
724
|
}
|
|
725
|
+
afterDecode?.(result);
|
|
708
726
|
return result;
|
|
709
727
|
};
|
|
710
728
|
}
|
|
@@ -720,6 +738,8 @@ var AxisTlvDto;
|
|
|
720
738
|
var init_axis_tlv_dto = __esm({
|
|
721
739
|
"src/base/axis-tlv.dto.ts"() {
|
|
722
740
|
AxisTlvDto = class {
|
|
741
|
+
static afterDecode(_dto) {
|
|
742
|
+
}
|
|
723
743
|
};
|
|
724
744
|
}
|
|
725
745
|
});
|