@nextera.one/axis-server-sdk 2.3.24 → 2.3.26

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.
@@ -764,7 +764,11 @@ function Intent(action, options) {
764
764
  bodyProfile: options?.bodyProfile,
765
765
  tlv: options?.tlv,
766
766
  dto: options?.dto,
767
- is: options?.is
767
+ is: options?.is,
768
+ maxUseCount: options?.maxUseCount,
769
+ useCount: options?.useCount,
770
+ duration: options?.duration,
771
+ maxDuration: options?.maxDuration
768
772
  });
769
773
  Reflect.defineMetadata(INTENT_ROUTES_KEY, routes, target.constructor);
770
774
  };
@@ -9536,9 +9540,10 @@ var init_timeline_store = __esm({
9536
9540
  // src/utils/axis-tlv-codec.ts
9537
9541
  function encodeAxisTlvDto(dtoClass, data, context = {}) {
9538
9542
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9543
+ const effectiveContext = withDtoName(dtoClass, context);
9539
9544
  const items = schema.fields.flatMap((field) => {
9540
9545
  const value = data[field.name];
9541
- if (!shouldEncodeField(field, value, data, context)) return [];
9546
+ if (!shouldEncodeField(field, value, data, effectiveContext)) return [];
9542
9547
  if (value === void 0 || value === null) {
9543
9548
  if (field.required) {
9544
9549
  throw new Error(`Missing required TLV response field: ${field.name}`);
@@ -9551,17 +9556,18 @@ function encodeAxisTlvDto(dtoClass, data, context = {}) {
9551
9556
  }
9552
9557
  function projectAxisTlvDto(dtoClass, data, context = {}) {
9553
9558
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9559
+ const effectiveContext = withDtoName(dtoClass, context);
9554
9560
  const result = {};
9555
9561
  for (const field of schema.fields) {
9556
9562
  const value = data[field.name];
9557
- if (!shouldEncodeField(field, value, data, context)) continue;
9563
+ if (!shouldEncodeField(field, value, data, effectiveContext)) continue;
9558
9564
  if (value === void 0 || value === null) continue;
9559
9565
  result[field.name] = value;
9560
9566
  }
9561
9567
  return result;
9562
9568
  }
9563
9569
  function shouldEncodeField(field, value, data, context) {
9564
- const rule = field.encode;
9570
+ const rule = resolveEncodeRule(field, value, data, context);
9565
9571
  if (rule === void 0) return true;
9566
9572
  if (rule === false) return false;
9567
9573
  if (rule.onlyRoles?.length && !hasAnyRole(context, rule.onlyRoles)) {
@@ -9581,6 +9587,22 @@ function shouldEncodeField(field, value, data, context) {
9581
9587
  }
9582
9588
  return true;
9583
9589
  }
9590
+ function withDtoName(dtoClass, context) {
9591
+ return {
9592
+ ...context,
9593
+ dtoName: context.dtoName ?? dtoClass.name
9594
+ };
9595
+ }
9596
+ function resolveEncodeRule(field, value, data, context) {
9597
+ return context.visibilityRegistry?.resolve({
9598
+ intent: context.intent,
9599
+ dtoName: context.dtoName,
9600
+ field,
9601
+ value,
9602
+ data,
9603
+ context
9604
+ }) ?? field.encode;
9605
+ }
9584
9606
  function hasAnyRole(context, expectedRoles) {
9585
9607
  const actualRoles = context.roles ?? [];
9586
9608
  return expectedRoles.some((role) => actualRoles.includes(role));
@@ -9628,6 +9650,82 @@ var init_axis_tlv_codec = __esm({
9628
9650
  }
9629
9651
  });
9630
9652
 
9653
+ // src/utils/axis-tlv-visibility-registry.ts
9654
+ function overrideKey(override) {
9655
+ return [
9656
+ normalizeKey(override.intent),
9657
+ normalizeKey(override.dtoName),
9658
+ normalizeKey(override.field),
9659
+ override.tag ?? ""
9660
+ ].join("|");
9661
+ }
9662
+ function normalizeKey(value) {
9663
+ return typeof value === "string" ? value.trim() : "";
9664
+ }
9665
+ function matchScore(override, input) {
9666
+ if (override.enabled === false) return -1;
9667
+ const intent = normalizeKey(input.intent);
9668
+ const dtoName = normalizeKey(input.dtoName);
9669
+ const overrideIntent = normalizeKey(override.intent);
9670
+ const overrideDtoName = normalizeKey(override.dtoName);
9671
+ const overrideField = normalizeKey(override.field);
9672
+ const fieldName = normalizeKey(input.field.name);
9673
+ if (overrideIntent && overrideIntent !== intent) return -1;
9674
+ if (overrideDtoName && overrideDtoName !== dtoName) return -1;
9675
+ const fieldMatches = Boolean(overrideField && overrideField === fieldName);
9676
+ const tagMatches = typeof override.tag === "number" && override.tag === input.field.tag;
9677
+ if (!fieldMatches && !tagMatches) return -1;
9678
+ return (overrideIntent ? 100 : 0) + (overrideDtoName ? 50 : 0) + (fieldMatches ? 10 : 0) + (tagMatches ? 8 : 0);
9679
+ }
9680
+ var AxisTlvVisibilityRegistry;
9681
+ var init_axis_tlv_visibility_registry = __esm({
9682
+ "src/utils/axis-tlv-visibility-registry.ts"() {
9683
+ AxisTlvVisibilityRegistry = class {
9684
+ constructor(overrides = []) {
9685
+ this.overrides = [];
9686
+ this.setOverrides(overrides);
9687
+ }
9688
+ setOverrides(overrides) {
9689
+ this.overrides = overrides.map((override) => ({ ...override }));
9690
+ }
9691
+ listOverrides() {
9692
+ return this.overrides.map((override) => ({ ...override }));
9693
+ }
9694
+ upsert(override) {
9695
+ const key = overrideKey(override);
9696
+ const index = this.overrides.findIndex((item) => overrideKey(item) === key);
9697
+ if (index >= 0) {
9698
+ this.overrides[index] = { ...override };
9699
+ return;
9700
+ }
9701
+ this.overrides.push({ ...override });
9702
+ }
9703
+ remove(match) {
9704
+ const before = this.overrides.length;
9705
+ this.overrides = this.overrides.filter(
9706
+ (item) => overrideKey(item) !== overrideKey(match)
9707
+ );
9708
+ return before - this.overrides.length;
9709
+ }
9710
+ resolve(input) {
9711
+ let bestScore = -1;
9712
+ let bestIndex = -1;
9713
+ let best;
9714
+ this.overrides.forEach((override, index) => {
9715
+ const score = matchScore(override, input);
9716
+ if (score < 0) return;
9717
+ if (score > bestScore || score === bestScore && index > bestIndex) {
9718
+ bestScore = score;
9719
+ bestIndex = index;
9720
+ best = override;
9721
+ }
9722
+ });
9723
+ return best?.encode;
9724
+ }
9725
+ };
9726
+ }
9727
+ });
9728
+
9631
9729
  // src/loom/loom.types.ts
9632
9730
  function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
9633
9731
  return `ar:${context}:${scope}:${softid}`;
@@ -11092,6 +11190,7 @@ __export(index_exports, {
11092
11190
  AxisSensorChainService: () => AxisSensorChainService,
11093
11191
  AxisStream: () => AxisStream,
11094
11192
  AxisTlvDto: () => AxisTlvDto,
11193
+ AxisTlvVisibilityRegistry: () => AxisTlvVisibilityRegistry,
11095
11194
  BAND: () => BAND,
11096
11195
  BodyProfile: () => BodyProfile2,
11097
11196
  BodyProfileValidator: () => BodyProfileValidator,
@@ -11437,6 +11536,7 @@ var init_index = __esm({
11437
11536
  init_cce_pipeline();
11438
11537
  init_cce_types();
11439
11538
  init_axis_tlv_codec();
11539
+ init_axis_tlv_visibility_registry();
11440
11540
  init_loom_types();
11441
11541
  init_loom_engine();
11442
11542
  init_idel_compiler();