@nextera.one/axis-server-sdk 2.3.23 → 2.3.25

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.
@@ -3876,7 +3876,8 @@ var init_intent_router = __esm({
3876
3876
  required: f.required,
3877
3877
  maxLen: f.maxLen,
3878
3878
  max: f.max,
3879
- scope: f.scope
3879
+ scope: f.scope,
3880
+ ...f.encode !== void 0 ? { encode: f.encode } : {}
3880
3881
  }))
3881
3882
  };
3882
3883
  this.intentSchemas.set(meta.intent, schema2);
@@ -3900,7 +3901,8 @@ var init_intent_router = __esm({
3900
3901
  required: f.required,
3901
3902
  maxLen: f.maxLen,
3902
3903
  max: f.max,
3903
- scope: f.scope
3904
+ scope: f.scope,
3905
+ ...f.encode !== void 0 ? { encode: f.encode } : {}
3904
3906
  }))
3905
3907
  };
3906
3908
  this.intentSchemas.set(meta.intent, schema);
@@ -9534,9 +9536,10 @@ var init_timeline_store = __esm({
9534
9536
  // src/utils/axis-tlv-codec.ts
9535
9537
  function encodeAxisTlvDto(dtoClass, data, context = {}) {
9536
9538
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9539
+ const effectiveContext = withDtoName(dtoClass, context);
9537
9540
  const items = schema.fields.flatMap((field) => {
9538
9541
  const value = data[field.name];
9539
- if (!shouldEncodeField(field, value, data, context)) return [];
9542
+ if (!shouldEncodeField(field, value, data, effectiveContext)) return [];
9540
9543
  if (value === void 0 || value === null) {
9541
9544
  if (field.required) {
9542
9545
  throw new Error(`Missing required TLV response field: ${field.name}`);
@@ -9549,17 +9552,18 @@ function encodeAxisTlvDto(dtoClass, data, context = {}) {
9549
9552
  }
9550
9553
  function projectAxisTlvDto(dtoClass, data, context = {}) {
9551
9554
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9555
+ const effectiveContext = withDtoName(dtoClass, context);
9552
9556
  const result = {};
9553
9557
  for (const field of schema.fields) {
9554
9558
  const value = data[field.name];
9555
- if (!shouldEncodeField(field, value, data, context)) continue;
9559
+ if (!shouldEncodeField(field, value, data, effectiveContext)) continue;
9556
9560
  if (value === void 0 || value === null) continue;
9557
9561
  result[field.name] = value;
9558
9562
  }
9559
9563
  return result;
9560
9564
  }
9561
9565
  function shouldEncodeField(field, value, data, context) {
9562
- const rule = field.encode;
9566
+ const rule = resolveEncodeRule(field, value, data, context);
9563
9567
  if (rule === void 0) return true;
9564
9568
  if (rule === false) return false;
9565
9569
  if (rule.onlyRoles?.length && !hasAnyRole(context, rule.onlyRoles)) {
@@ -9579,6 +9583,22 @@ function shouldEncodeField(field, value, data, context) {
9579
9583
  }
9580
9584
  return true;
9581
9585
  }
9586
+ function withDtoName(dtoClass, context) {
9587
+ return {
9588
+ ...context,
9589
+ dtoName: context.dtoName ?? dtoClass.name
9590
+ };
9591
+ }
9592
+ function resolveEncodeRule(field, value, data, context) {
9593
+ return context.visibilityRegistry?.resolve({
9594
+ intent: context.intent,
9595
+ dtoName: context.dtoName,
9596
+ field,
9597
+ value,
9598
+ data,
9599
+ context
9600
+ }) ?? field.encode;
9601
+ }
9582
9602
  function hasAnyRole(context, expectedRoles) {
9583
9603
  const actualRoles = context.roles ?? [];
9584
9604
  return expectedRoles.some((role) => actualRoles.includes(role));
@@ -9626,6 +9646,82 @@ var init_axis_tlv_codec = __esm({
9626
9646
  }
9627
9647
  });
9628
9648
 
9649
+ // src/utils/axis-tlv-visibility-registry.ts
9650
+ function overrideKey(override) {
9651
+ return [
9652
+ normalizeKey(override.intent),
9653
+ normalizeKey(override.dtoName),
9654
+ normalizeKey(override.field),
9655
+ override.tag ?? ""
9656
+ ].join("|");
9657
+ }
9658
+ function normalizeKey(value) {
9659
+ return typeof value === "string" ? value.trim() : "";
9660
+ }
9661
+ function matchScore(override, input) {
9662
+ if (override.enabled === false) return -1;
9663
+ const intent = normalizeKey(input.intent);
9664
+ const dtoName = normalizeKey(input.dtoName);
9665
+ const overrideIntent = normalizeKey(override.intent);
9666
+ const overrideDtoName = normalizeKey(override.dtoName);
9667
+ const overrideField = normalizeKey(override.field);
9668
+ const fieldName = normalizeKey(input.field.name);
9669
+ if (overrideIntent && overrideIntent !== intent) return -1;
9670
+ if (overrideDtoName && overrideDtoName !== dtoName) return -1;
9671
+ const fieldMatches = Boolean(overrideField && overrideField === fieldName);
9672
+ const tagMatches = typeof override.tag === "number" && override.tag === input.field.tag;
9673
+ if (!fieldMatches && !tagMatches) return -1;
9674
+ return (overrideIntent ? 100 : 0) + (overrideDtoName ? 50 : 0) + (fieldMatches ? 10 : 0) + (tagMatches ? 8 : 0);
9675
+ }
9676
+ var AxisTlvVisibilityRegistry;
9677
+ var init_axis_tlv_visibility_registry = __esm({
9678
+ "src/utils/axis-tlv-visibility-registry.ts"() {
9679
+ AxisTlvVisibilityRegistry = class {
9680
+ constructor(overrides = []) {
9681
+ this.overrides = [];
9682
+ this.setOverrides(overrides);
9683
+ }
9684
+ setOverrides(overrides) {
9685
+ this.overrides = overrides.map((override) => ({ ...override }));
9686
+ }
9687
+ listOverrides() {
9688
+ return this.overrides.map((override) => ({ ...override }));
9689
+ }
9690
+ upsert(override) {
9691
+ const key = overrideKey(override);
9692
+ const index = this.overrides.findIndex((item) => overrideKey(item) === key);
9693
+ if (index >= 0) {
9694
+ this.overrides[index] = { ...override };
9695
+ return;
9696
+ }
9697
+ this.overrides.push({ ...override });
9698
+ }
9699
+ remove(match) {
9700
+ const before = this.overrides.length;
9701
+ this.overrides = this.overrides.filter(
9702
+ (item) => overrideKey(item) !== overrideKey(match)
9703
+ );
9704
+ return before - this.overrides.length;
9705
+ }
9706
+ resolve(input) {
9707
+ let bestScore = -1;
9708
+ let bestIndex = -1;
9709
+ let best;
9710
+ this.overrides.forEach((override, index) => {
9711
+ const score = matchScore(override, input);
9712
+ if (score < 0) return;
9713
+ if (score > bestScore || score === bestScore && index > bestIndex) {
9714
+ bestScore = score;
9715
+ bestIndex = index;
9716
+ best = override;
9717
+ }
9718
+ });
9719
+ return best?.encode;
9720
+ }
9721
+ };
9722
+ }
9723
+ });
9724
+
9629
9725
  // src/loom/loom.types.ts
9630
9726
  function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
9631
9727
  return `ar:${context}:${scope}:${softid}`;
@@ -11090,6 +11186,7 @@ __export(index_exports, {
11090
11186
  AxisSensorChainService: () => AxisSensorChainService,
11091
11187
  AxisStream: () => AxisStream,
11092
11188
  AxisTlvDto: () => AxisTlvDto,
11189
+ AxisTlvVisibilityRegistry: () => AxisTlvVisibilityRegistry,
11093
11190
  BAND: () => BAND,
11094
11191
  BodyProfile: () => BodyProfile2,
11095
11192
  BodyProfileValidator: () => BodyProfileValidator,
@@ -11435,6 +11532,7 @@ var init_index = __esm({
11435
11532
  init_cce_pipeline();
11436
11533
  init_cce_types();
11437
11534
  init_axis_tlv_codec();
11535
+ init_axis_tlv_visibility_registry();
11438
11536
  init_loom_types();
11439
11537
  init_loom_engine();
11440
11538
  init_idel_compiler();