@nextera.one/axis-server-sdk 2.3.20 → 2.3.21

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.mjs CHANGED
@@ -8689,8 +8689,9 @@ var init_sensor_registry = __esm({
8689
8689
  "src/engine/registry/sensor.registry.ts"() {
8690
8690
  init_axis_logger();
8691
8691
  SensorRegistry = class _SensorRegistry {
8692
- constructor(configService) {
8692
+ constructor(configService, sensorConfigProvider) {
8693
8693
  this.configService = configService;
8694
+ this.sensorConfigProvider = sensorConfigProvider;
8694
8695
  this.sensors = [];
8695
8696
  this.sensorsByName = /* @__PURE__ */ new Map();
8696
8697
  this.sensorsByType = /* @__PURE__ */ new Map();
@@ -8700,22 +8701,6 @@ var init_sensor_registry = __esm({
8700
8701
  if (!sensor.name) {
8701
8702
  throw new Error("AxisSensor must have a name");
8702
8703
  }
8703
- const enabledSensorsStr = this.configService?.get("ENABLED_SENSORS");
8704
- const disabledSensorsStr = this.configService?.get("DISABLED_SENSORS");
8705
- const enabledSensors = enabledSensorsStr ? enabledSensorsStr.split(",").map((s) => s.trim()) : null;
8706
- const disabledSensors = disabledSensorsStr ? disabledSensorsStr.split(",").map((s) => s.trim()) : [];
8707
- if (enabledSensors && !enabledSensors.includes(sensor.name)) {
8708
- this.logger.log(
8709
- `Skipping disabled sensor (not in ENABLED_SENSORS): ${sensor.name}`
8710
- );
8711
- return;
8712
- }
8713
- if (disabledSensors.includes(sensor.name)) {
8714
- this.logger.log(
8715
- `Skipping disabled sensor (in DISABLED_SENSORS): ${sensor.name}`
8716
- );
8717
- return;
8718
- }
8719
8704
  if (sensor.order === void 0) {
8720
8705
  throw new Error(`AxisSensor "${sensor.name}" must have an order field`);
8721
8706
  }
@@ -8739,18 +8724,21 @@ var init_sensor_registry = __esm({
8739
8724
  );
8740
8725
  }
8741
8726
  list() {
8742
- return [...this.sensors].sort(
8727
+ return this.filterEnabledSensors(this.sensors).sort(
8743
8728
  (a, b) => (a.order ?? 999) - (b.order ?? 999)
8744
8729
  );
8745
8730
  }
8746
8731
  resolve(ref) {
8747
8732
  if (typeof ref === "string") {
8748
- return this.sensorsByName.get(ref);
8733
+ const sensor2 = this.sensorsByName.get(ref);
8734
+ return sensor2 && this.isSensorEnabled(sensor2) ? sensor2 : void 0;
8749
8735
  }
8750
- return this.sensorsByType.get(ref) ?? this.sensorsByName.get(ref.name);
8736
+ const sensor = this.sensorsByType.get(ref) ?? this.sensorsByName.get(ref.name);
8737
+ return sensor && this.isSensorEnabled(sensor) ? sensor : void 0;
8751
8738
  }
8752
8739
  getByName(name) {
8753
- return this.sensorsByName.get(name);
8740
+ const sensor = this.sensorsByName.get(name);
8741
+ return sensor && this.isSensorEnabled(sensor) ? sensor : void 0;
8754
8742
  }
8755
8743
  getPreDecodeSensors() {
8756
8744
  return this.list().filter(
@@ -8773,6 +8761,22 @@ var init_sensor_registry = __esm({
8773
8761
  this.sensorsByName.clear();
8774
8762
  this.sensorsByType.clear();
8775
8763
  }
8764
+ getSensorConfig() {
8765
+ const providerSnapshot = this.sensorConfigProvider?.getSensorConfig();
8766
+ const source = this.getSensorsSource(providerSnapshot);
8767
+ if (source !== "ENV" && providerSnapshot) {
8768
+ return {
8769
+ source,
8770
+ enabledSensors: this.normalizeList(providerSnapshot.enabledSensors),
8771
+ disabledSensors: this.normalizeList(providerSnapshot.disabledSensors)
8772
+ };
8773
+ }
8774
+ return {
8775
+ source,
8776
+ enabledSensors: this.parseConfigList("ENABLED_SENSORS"),
8777
+ disabledSensors: this.parseConfigList("DISABLED_SENSORS")
8778
+ };
8779
+ }
8776
8780
  isPreDecodeSensor(sensor) {
8777
8781
  const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
8778
8782
  if (phase) return phase === "PRE_DECODE";
@@ -8792,6 +8796,48 @@ var init_sensor_registry = __esm({
8792
8796
  this.sensorsByName.set(sensorType.name, sensor);
8793
8797
  }
8794
8798
  }
8799
+ filterEnabledSensors(sensors) {
8800
+ return sensors.filter((sensor) => this.isSensorEnabled(sensor));
8801
+ }
8802
+ isSensorEnabled(sensor) {
8803
+ const config = this.getSensorConfig();
8804
+ const enabled = new Set(config.enabledSensors);
8805
+ const disabled = new Set(config.disabledSensors);
8806
+ const names = this.getSensorNames(sensor);
8807
+ if (names.some((name) => disabled.has(name))) {
8808
+ return false;
8809
+ }
8810
+ if (enabled.size > 0 && !names.some((name) => enabled.has(name))) {
8811
+ return false;
8812
+ }
8813
+ return true;
8814
+ }
8815
+ getSensorNames(sensor) {
8816
+ const names = [sensor.name];
8817
+ const constructorName = sensor.constructor?.name;
8818
+ if (constructorName && !names.includes(constructorName)) {
8819
+ names.push(constructorName);
8820
+ }
8821
+ return names;
8822
+ }
8823
+ getSensorsSource(providerSnapshot) {
8824
+ const raw = this.configService?.get("SENSORS_SOURCE") ?? providerSnapshot?.source ?? "ENV";
8825
+ const normalized = String(raw || "ENV").trim().toUpperCase();
8826
+ return normalized || "ENV";
8827
+ }
8828
+ parseConfigList(key) {
8829
+ return this.normalizeList(this.configService?.get(key));
8830
+ }
8831
+ normalizeList(value) {
8832
+ if (!value) return [];
8833
+ if (Array.isArray(value)) {
8834
+ return value.map((entry) => String(entry).trim()).filter(Boolean);
8835
+ }
8836
+ if (typeof value === "string") {
8837
+ return value.split(",").map((entry) => entry.trim()).filter(Boolean);
8838
+ }
8839
+ return [];
8840
+ }
8795
8841
  };
8796
8842
  }
8797
8843
  });