@nextera.one/axis-server-sdk 2.1.9 → 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 CHANGED
@@ -681,7 +681,7 @@ declare function Handler(intent?: string): ClassDecorator;
681
681
 
682
682
  declare const INTENT_METADATA_KEY = "axis:intent";
683
683
  declare const INTENT_ROUTES_KEY = "axis:intent_routes";
684
- type IntentKind = 'create' | 'read' | 'update' | 'delete' | 'action';
684
+ type IntentKind = "create" | "read" | "update" | "delete" | "action";
685
685
  type AxisIntentSensorRef = string | Function;
686
686
  interface AxisIntentSensorOptions {
687
687
  is?: AxisIntentSensorRef[];
@@ -689,11 +689,11 @@ interface AxisIntentSensorOptions {
689
689
  interface IntentTlvField {
690
690
  name: string;
691
691
  tag: number;
692
- kind: 'utf8' | 'u64' | 'bytes' | 'bytes16' | 'bool' | 'obj' | 'arr';
692
+ kind: "utf8" | "u64" | "bytes" | "bytes16" | "bool" | "obj" | "arr";
693
693
  required?: boolean;
694
694
  maxLen?: number;
695
695
  max?: string;
696
- scope?: 'header' | 'body';
696
+ scope?: "header" | "body";
697
697
  }
698
698
  interface IntentRoute extends AxisIntentSensorOptions {
699
699
  action: string;
@@ -703,7 +703,7 @@ interface IntentRoute extends AxisIntentSensorOptions {
703
703
  kind?: IntentKind;
704
704
  sensitivity?: SensitivityLevel;
705
705
  chain?: boolean | ChainOptions;
706
- bodyProfile?: 'TLV_MAP' | 'RAW' | 'TLV_OBJ' | 'TLV_ARR';
706
+ bodyProfile?: "TLV_MAP" | "RAW" | "TLV_OBJ" | "TLV_ARR";
707
707
  tlv?: IntentTlvField[];
708
708
  dto?: Function;
709
709
  }
@@ -713,9 +713,10 @@ interface IntentOptions extends AxisIntentSensorOptions {
713
713
  absolute?: boolean;
714
714
  frame?: boolean;
715
715
  chain?: boolean | ChainOptions;
716
- bodyProfile?: 'TLV_MAP' | 'RAW' | 'TLV_OBJ' | 'TLV_ARR';
716
+ bodyProfile?: "TLV_MAP" | "RAW" | "TLV_OBJ" | "TLV_ARR";
717
717
  tlv?: IntentTlvField[];
718
718
  dto?: Function;
719
+ decoder?: (buf: Buffer) => any;
719
720
  }
720
721
  declare function Intent(action: string, options?: IntentOptions): MethodDecorator;
721
722
 
@@ -793,7 +794,7 @@ declare function extractDtoSchema(dto: Function): DtoSchema;
793
794
  declare function buildDtoDecoder(dto: Function): (bodyBytes: Buffer) => Record<string, any>;
794
795
 
795
796
  declare abstract class AxisTlvDto {
796
- static afterDecode?(dto: Record<string, any>): void;
797
+ static afterDecode(_dto: Record<string, any>): void;
797
798
  }
798
799
 
799
800
  declare class AxisIdDto extends AxisTlvDto {
package/dist/index.d.ts CHANGED
@@ -681,7 +681,7 @@ declare function Handler(intent?: string): ClassDecorator;
681
681
 
682
682
  declare const INTENT_METADATA_KEY = "axis:intent";
683
683
  declare const INTENT_ROUTES_KEY = "axis:intent_routes";
684
- type IntentKind = 'create' | 'read' | 'update' | 'delete' | 'action';
684
+ type IntentKind = "create" | "read" | "update" | "delete" | "action";
685
685
  type AxisIntentSensorRef = string | Function;
686
686
  interface AxisIntentSensorOptions {
687
687
  is?: AxisIntentSensorRef[];
@@ -689,11 +689,11 @@ interface AxisIntentSensorOptions {
689
689
  interface IntentTlvField {
690
690
  name: string;
691
691
  tag: number;
692
- kind: 'utf8' | 'u64' | 'bytes' | 'bytes16' | 'bool' | 'obj' | 'arr';
692
+ kind: "utf8" | "u64" | "bytes" | "bytes16" | "bool" | "obj" | "arr";
693
693
  required?: boolean;
694
694
  maxLen?: number;
695
695
  max?: string;
696
- scope?: 'header' | 'body';
696
+ scope?: "header" | "body";
697
697
  }
698
698
  interface IntentRoute extends AxisIntentSensorOptions {
699
699
  action: string;
@@ -703,7 +703,7 @@ interface IntentRoute extends AxisIntentSensorOptions {
703
703
  kind?: IntentKind;
704
704
  sensitivity?: SensitivityLevel;
705
705
  chain?: boolean | ChainOptions;
706
- bodyProfile?: 'TLV_MAP' | 'RAW' | 'TLV_OBJ' | 'TLV_ARR';
706
+ bodyProfile?: "TLV_MAP" | "RAW" | "TLV_OBJ" | "TLV_ARR";
707
707
  tlv?: IntentTlvField[];
708
708
  dto?: Function;
709
709
  }
@@ -713,9 +713,10 @@ interface IntentOptions extends AxisIntentSensorOptions {
713
713
  absolute?: boolean;
714
714
  frame?: boolean;
715
715
  chain?: boolean | ChainOptions;
716
- bodyProfile?: 'TLV_MAP' | 'RAW' | 'TLV_OBJ' | 'TLV_ARR';
716
+ bodyProfile?: "TLV_MAP" | "RAW" | "TLV_OBJ" | "TLV_ARR";
717
717
  tlv?: IntentTlvField[];
718
718
  dto?: Function;
719
+ decoder?: (buf: Buffer) => any;
719
720
  }
720
721
  declare function Intent(action: string, options?: IntentOptions): MethodDecorator;
721
722
 
@@ -793,7 +794,7 @@ declare function extractDtoSchema(dto: Function): DtoSchema;
793
794
  declare function buildDtoDecoder(dto: Function): (bodyBytes: Buffer) => Record<string, any>;
794
795
 
795
796
  declare abstract class AxisTlvDto {
796
- static afterDecode?(dto: Record<string, any>): void;
797
+ static afterDecode(_dto: Record<string, any>): void;
797
798
  }
798
799
 
799
800
  declare class AxisIdDto extends AxisTlvDto {
package/dist/index.js CHANGED
@@ -318,6 +318,25 @@ var init_handler_decorator = __esm({
318
318
  }
319
319
  });
320
320
 
321
+ // src/decorators/intent-body.decorator.ts
322
+ var intent_body_decorator_exports = {};
323
+ __export(intent_body_decorator_exports, {
324
+ INTENT_BODY_KEY: () => INTENT_BODY_KEY,
325
+ IntentBody: () => IntentBody
326
+ });
327
+ function IntentBody(decoder) {
328
+ return (target, propertyKey) => {
329
+ Reflect.defineMetadata(INTENT_BODY_KEY, decoder, target, propertyKey);
330
+ };
331
+ }
332
+ var import_reflect_metadata4, INTENT_BODY_KEY;
333
+ var init_intent_body_decorator = __esm({
334
+ "src/decorators/intent-body.decorator.ts"() {
335
+ import_reflect_metadata4 = require("reflect-metadata");
336
+ INTENT_BODY_KEY = "axis:intent:body";
337
+ }
338
+ });
339
+
321
340
  // src/decorators/intent.decorator.ts
322
341
  var intent_decorator_exports = {};
323
342
  __export(intent_decorator_exports, {
@@ -329,6 +348,14 @@ function Intent(action, options) {
329
348
  return (target, propertyKey) => {
330
349
  const metadata = { intent: action, ...options };
331
350
  Reflect.defineMetadata(INTENT_METADATA_KEY, metadata, target, propertyKey);
351
+ if (options?.decoder) {
352
+ Reflect.defineMetadata(
353
+ INTENT_BODY_KEY,
354
+ options.decoder,
355
+ target,
356
+ propertyKey
357
+ );
358
+ }
332
359
  if (options?.sensitivity) {
333
360
  Reflect.defineMetadata(
334
361
  SENSITIVITY_METADATA_KEY,
@@ -354,35 +381,17 @@ function Intent(action, options) {
354
381
  Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
355
382
  };
356
383
  }
357
- var import_reflect_metadata4, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
384
+ var import_reflect_metadata5, INTENT_METADATA_KEY, INTENT_ROUTES_KEY;
358
385
  var init_intent_decorator = __esm({
359
386
  "src/decorators/intent.decorator.ts"() {
360
- import_reflect_metadata4 = require("reflect-metadata");
387
+ import_reflect_metadata5 = require("reflect-metadata");
388
+ init_intent_body_decorator();
361
389
  init_intent_policy_decorator();
362
390
  INTENT_METADATA_KEY = "axis:intent";
363
391
  INTENT_ROUTES_KEY = "axis:intent_routes";
364
392
  }
365
393
  });
366
394
 
367
- // src/decorators/intent-body.decorator.ts
368
- var intent_body_decorator_exports = {};
369
- __export(intent_body_decorator_exports, {
370
- INTENT_BODY_KEY: () => INTENT_BODY_KEY,
371
- IntentBody: () => IntentBody
372
- });
373
- function IntentBody(decoder) {
374
- return (target, propertyKey) => {
375
- Reflect.defineMetadata(INTENT_BODY_KEY, decoder, target, propertyKey);
376
- };
377
- }
378
- var import_reflect_metadata5, INTENT_BODY_KEY;
379
- var init_intent_body_decorator = __esm({
380
- "src/decorators/intent-body.decorator.ts"() {
381
- import_reflect_metadata5 = require("reflect-metadata");
382
- INTENT_BODY_KEY = "axis:intent:body";
383
- }
384
- });
385
-
386
395
  // src/decorators/intent-sensors.decorator.ts
387
396
  var intent_sensors_decorator_exports = {};
388
397
  __export(intent_sensors_decorator_exports, {
@@ -665,7 +674,8 @@ var require_dto_schema_util = __commonJS({
665
674
  for (const m of fieldMetas) {
666
675
  tagMap.set(m.tag, { property: m.property, kind: m.options.kind });
667
676
  }
668
- const afterDecode = dto.afterDecode;
677
+ const dtoClass = dto;
678
+ const afterDecode = typeof dtoClass.afterDecode === "function" ? dtoClass.afterDecode.bind(dtoClass) : void 0;
669
679
  return (bodyBytes) => {
670
680
  const tlvMap2 = (0, tlv_1.decodeTLVs)(new Uint8Array(bodyBytes));
671
681
  const result = {};
@@ -716,6 +726,8 @@ var AxisTlvDto;
716
726
  var init_axis_tlv_dto = __esm({
717
727
  "src/base/axis-tlv.dto.ts"() {
718
728
  AxisTlvDto = class {
729
+ static afterDecode(_dto) {
730
+ }
719
731
  };
720
732
  }
721
733
  });