@nextera.one/axis-server-sdk 2.3.24 → 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.
@@ -9536,9 +9536,10 @@ var init_timeline_store = __esm({
9536
9536
  // src/utils/axis-tlv-codec.ts
9537
9537
  function encodeAxisTlvDto(dtoClass, data, context = {}) {
9538
9538
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9539
+ const effectiveContext = withDtoName(dtoClass, context);
9539
9540
  const items = schema.fields.flatMap((field) => {
9540
9541
  const value = data[field.name];
9541
- if (!shouldEncodeField(field, value, data, context)) return [];
9542
+ if (!shouldEncodeField(field, value, data, effectiveContext)) return [];
9542
9543
  if (value === void 0 || value === null) {
9543
9544
  if (field.required) {
9544
9545
  throw new Error(`Missing required TLV response field: ${field.name}`);
@@ -9551,17 +9552,18 @@ function encodeAxisTlvDto(dtoClass, data, context = {}) {
9551
9552
  }
9552
9553
  function projectAxisTlvDto(dtoClass, data, context = {}) {
9553
9554
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9555
+ const effectiveContext = withDtoName(dtoClass, context);
9554
9556
  const result = {};
9555
9557
  for (const field of schema.fields) {
9556
9558
  const value = data[field.name];
9557
- if (!shouldEncodeField(field, value, data, context)) continue;
9559
+ if (!shouldEncodeField(field, value, data, effectiveContext)) continue;
9558
9560
  if (value === void 0 || value === null) continue;
9559
9561
  result[field.name] = value;
9560
9562
  }
9561
9563
  return result;
9562
9564
  }
9563
9565
  function shouldEncodeField(field, value, data, context) {
9564
- const rule = field.encode;
9566
+ const rule = resolveEncodeRule(field, value, data, context);
9565
9567
  if (rule === void 0) return true;
9566
9568
  if (rule === false) return false;
9567
9569
  if (rule.onlyRoles?.length && !hasAnyRole(context, rule.onlyRoles)) {
@@ -9581,6 +9583,22 @@ function shouldEncodeField(field, value, data, context) {
9581
9583
  }
9582
9584
  return true;
9583
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
+ }
9584
9602
  function hasAnyRole(context, expectedRoles) {
9585
9603
  const actualRoles = context.roles ?? [];
9586
9604
  return expectedRoles.some((role) => actualRoles.includes(role));
@@ -9628,6 +9646,82 @@ var init_axis_tlv_codec = __esm({
9628
9646
  }
9629
9647
  });
9630
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
+
9631
9725
  // src/loom/loom.types.ts
9632
9726
  function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
9633
9727
  return `ar:${context}:${scope}:${softid}`;
@@ -11092,6 +11186,7 @@ __export(index_exports, {
11092
11186
  AxisSensorChainService: () => AxisSensorChainService,
11093
11187
  AxisStream: () => AxisStream,
11094
11188
  AxisTlvDto: () => AxisTlvDto,
11189
+ AxisTlvVisibilityRegistry: () => AxisTlvVisibilityRegistry,
11095
11190
  BAND: () => BAND,
11096
11191
  BodyProfile: () => BodyProfile2,
11097
11192
  BodyProfileValidator: () => BodyProfileValidator,
@@ -11437,6 +11532,7 @@ var init_index = __esm({
11437
11532
  init_cce_pipeline();
11438
11533
  init_cce_types();
11439
11534
  init_axis_tlv_codec();
11535
+ init_axis_tlv_visibility_registry();
11440
11536
  init_loom_types();
11441
11537
  init_loom_engine();
11442
11538
  init_idel_compiler();