@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.
@@ -9464,9 +9464,10 @@ var init_timeline_store = __esm({
9464
9464
  // src/utils/axis-tlv-codec.ts
9465
9465
  function encodeAxisTlvDto(dtoClass, data, context = {}) {
9466
9466
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9467
+ const effectiveContext = withDtoName(dtoClass, context);
9467
9468
  const items = schema.fields.flatMap((field) => {
9468
9469
  const value = data[field.name];
9469
- if (!shouldEncodeField(field, value, data, context)) return [];
9470
+ if (!shouldEncodeField(field, value, data, effectiveContext)) return [];
9470
9471
  if (value === void 0 || value === null) {
9471
9472
  if (field.required) {
9472
9473
  throw new Error(`Missing required TLV response field: ${field.name}`);
@@ -9479,17 +9480,18 @@ function encodeAxisTlvDto(dtoClass, data, context = {}) {
9479
9480
  }
9480
9481
  function projectAxisTlvDto(dtoClass, data, context = {}) {
9481
9482
  const schema = (0, import_dto_schema2.extractDtoSchema)(dtoClass);
9483
+ const effectiveContext = withDtoName(dtoClass, context);
9482
9484
  const result = {};
9483
9485
  for (const field of schema.fields) {
9484
9486
  const value = data[field.name];
9485
- if (!shouldEncodeField(field, value, data, context)) continue;
9487
+ if (!shouldEncodeField(field, value, data, effectiveContext)) continue;
9486
9488
  if (value === void 0 || value === null) continue;
9487
9489
  result[field.name] = value;
9488
9490
  }
9489
9491
  return result;
9490
9492
  }
9491
9493
  function shouldEncodeField(field, value, data, context) {
9492
- const rule = field.encode;
9494
+ const rule = resolveEncodeRule(field, value, data, context);
9493
9495
  if (rule === void 0) return true;
9494
9496
  if (rule === false) return false;
9495
9497
  if (rule.onlyRoles?.length && !hasAnyRole(context, rule.onlyRoles)) {
@@ -9509,6 +9511,22 @@ function shouldEncodeField(field, value, data, context) {
9509
9511
  }
9510
9512
  return true;
9511
9513
  }
9514
+ function withDtoName(dtoClass, context) {
9515
+ return {
9516
+ ...context,
9517
+ dtoName: context.dtoName ?? dtoClass.name
9518
+ };
9519
+ }
9520
+ function resolveEncodeRule(field, value, data, context) {
9521
+ return context.visibilityRegistry?.resolve({
9522
+ intent: context.intent,
9523
+ dtoName: context.dtoName,
9524
+ field,
9525
+ value,
9526
+ data,
9527
+ context
9528
+ }) ?? field.encode;
9529
+ }
9512
9530
  function hasAnyRole(context, expectedRoles) {
9513
9531
  const actualRoles = context.roles ?? [];
9514
9532
  return expectedRoles.some((role) => actualRoles.includes(role));
@@ -9556,6 +9574,82 @@ var init_axis_tlv_codec = __esm({
9556
9574
  }
9557
9575
  });
9558
9576
 
9577
+ // src/utils/axis-tlv-visibility-registry.ts
9578
+ function overrideKey(override) {
9579
+ return [
9580
+ normalizeKey(override.intent),
9581
+ normalizeKey(override.dtoName),
9582
+ normalizeKey(override.field),
9583
+ override.tag ?? ""
9584
+ ].join("|");
9585
+ }
9586
+ function normalizeKey(value) {
9587
+ return typeof value === "string" ? value.trim() : "";
9588
+ }
9589
+ function matchScore(override, input) {
9590
+ if (override.enabled === false) return -1;
9591
+ const intent = normalizeKey(input.intent);
9592
+ const dtoName = normalizeKey(input.dtoName);
9593
+ const overrideIntent = normalizeKey(override.intent);
9594
+ const overrideDtoName = normalizeKey(override.dtoName);
9595
+ const overrideField = normalizeKey(override.field);
9596
+ const fieldName = normalizeKey(input.field.name);
9597
+ if (overrideIntent && overrideIntent !== intent) return -1;
9598
+ if (overrideDtoName && overrideDtoName !== dtoName) return -1;
9599
+ const fieldMatches = Boolean(overrideField && overrideField === fieldName);
9600
+ const tagMatches = typeof override.tag === "number" && override.tag === input.field.tag;
9601
+ if (!fieldMatches && !tagMatches) return -1;
9602
+ return (overrideIntent ? 100 : 0) + (overrideDtoName ? 50 : 0) + (fieldMatches ? 10 : 0) + (tagMatches ? 8 : 0);
9603
+ }
9604
+ var AxisTlvVisibilityRegistry;
9605
+ var init_axis_tlv_visibility_registry = __esm({
9606
+ "src/utils/axis-tlv-visibility-registry.ts"() {
9607
+ AxisTlvVisibilityRegistry = class {
9608
+ constructor(overrides = []) {
9609
+ this.overrides = [];
9610
+ this.setOverrides(overrides);
9611
+ }
9612
+ setOverrides(overrides) {
9613
+ this.overrides = overrides.map((override) => ({ ...override }));
9614
+ }
9615
+ listOverrides() {
9616
+ return this.overrides.map((override) => ({ ...override }));
9617
+ }
9618
+ upsert(override) {
9619
+ const key = overrideKey(override);
9620
+ const index = this.overrides.findIndex((item) => overrideKey(item) === key);
9621
+ if (index >= 0) {
9622
+ this.overrides[index] = { ...override };
9623
+ return;
9624
+ }
9625
+ this.overrides.push({ ...override });
9626
+ }
9627
+ remove(match) {
9628
+ const before = this.overrides.length;
9629
+ this.overrides = this.overrides.filter(
9630
+ (item) => overrideKey(item) !== overrideKey(match)
9631
+ );
9632
+ return before - this.overrides.length;
9633
+ }
9634
+ resolve(input) {
9635
+ let bestScore = -1;
9636
+ let bestIndex = -1;
9637
+ let best;
9638
+ this.overrides.forEach((override, index) => {
9639
+ const score = matchScore(override, input);
9640
+ if (score < 0) return;
9641
+ if (score > bestScore || score === bestScore && index > bestIndex) {
9642
+ bestScore = score;
9643
+ bestIndex = index;
9644
+ best = override;
9645
+ }
9646
+ });
9647
+ return best?.encode;
9648
+ }
9649
+ };
9650
+ }
9651
+ });
9652
+
9559
9653
  // src/loom/loom.types.ts
9560
9654
  function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
9561
9655
  return `ar:${context}:${scope}:${softid}`;
@@ -11023,6 +11117,7 @@ __export(index_exports, {
11023
11117
  AxisSensorChainService: () => AxisSensorChainService,
11024
11118
  AxisStream: () => AxisStream,
11025
11119
  AxisTlvDto: () => AxisTlvDto,
11120
+ AxisTlvVisibilityRegistry: () => AxisTlvVisibilityRegistry,
11026
11121
  BAND: () => BAND,
11027
11122
  BodyProfile: () => BodyProfile2,
11028
11123
  BodyProfileValidator: () => BodyProfileValidator,
@@ -11368,6 +11463,7 @@ var init_index = __esm({
11368
11463
  init_cce_pipeline();
11369
11464
  init_cce_types();
11370
11465
  init_axis_tlv_codec();
11466
+ init_axis_tlv_visibility_registry();
11371
11467
  init_loom_types();
11372
11468
  init_loom_engine();
11373
11469
  init_idel_compiler();