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

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.
@@ -8793,8 +8793,9 @@ var init_sensor_registry = __esm({
8793
8793
  "src/engine/registry/sensor.registry.ts"() {
8794
8794
  init_axis_logger();
8795
8795
  SensorRegistry = class _SensorRegistry {
8796
- constructor(configService) {
8796
+ constructor(configService, sensorConfigProvider) {
8797
8797
  this.configService = configService;
8798
+ this.sensorConfigProvider = sensorConfigProvider;
8798
8799
  this.sensors = [];
8799
8800
  this.sensorsByName = /* @__PURE__ */ new Map();
8800
8801
  this.sensorsByType = /* @__PURE__ */ new Map();
@@ -8804,22 +8805,6 @@ var init_sensor_registry = __esm({
8804
8805
  if (!sensor.name) {
8805
8806
  throw new Error("AxisSensor must have a name");
8806
8807
  }
8807
- const enabledSensorsStr = this.configService?.get("ENABLED_SENSORS");
8808
- const disabledSensorsStr = this.configService?.get("DISABLED_SENSORS");
8809
- const enabledSensors = enabledSensorsStr ? enabledSensorsStr.split(",").map((s) => s.trim()) : null;
8810
- const disabledSensors = disabledSensorsStr ? disabledSensorsStr.split(",").map((s) => s.trim()) : [];
8811
- if (enabledSensors && !enabledSensors.includes(sensor.name)) {
8812
- this.logger.log(
8813
- `Skipping disabled sensor (not in ENABLED_SENSORS): ${sensor.name}`
8814
- );
8815
- return;
8816
- }
8817
- if (disabledSensors.includes(sensor.name)) {
8818
- this.logger.log(
8819
- `Skipping disabled sensor (in DISABLED_SENSORS): ${sensor.name}`
8820
- );
8821
- return;
8822
- }
8823
8808
  if (sensor.order === void 0) {
8824
8809
  throw new Error(`AxisSensor "${sensor.name}" must have an order field`);
8825
8810
  }
@@ -8843,18 +8828,21 @@ var init_sensor_registry = __esm({
8843
8828
  );
8844
8829
  }
8845
8830
  list() {
8846
- return [...this.sensors].sort(
8831
+ return this.filterEnabledSensors(this.sensors).sort(
8847
8832
  (a, b) => (a.order ?? 999) - (b.order ?? 999)
8848
8833
  );
8849
8834
  }
8850
8835
  resolve(ref) {
8851
8836
  if (typeof ref === "string") {
8852
- return this.sensorsByName.get(ref);
8837
+ const sensor2 = this.sensorsByName.get(ref);
8838
+ return sensor2 && this.isSensorEnabled(sensor2) ? sensor2 : void 0;
8853
8839
  }
8854
- return this.sensorsByType.get(ref) ?? this.sensorsByName.get(ref.name);
8840
+ const sensor = this.sensorsByType.get(ref) ?? this.sensorsByName.get(ref.name);
8841
+ return sensor && this.isSensorEnabled(sensor) ? sensor : void 0;
8855
8842
  }
8856
8843
  getByName(name) {
8857
- return this.sensorsByName.get(name);
8844
+ const sensor = this.sensorsByName.get(name);
8845
+ return sensor && this.isSensorEnabled(sensor) ? sensor : void 0;
8858
8846
  }
8859
8847
  getPreDecodeSensors() {
8860
8848
  return this.list().filter(
@@ -8877,6 +8865,22 @@ var init_sensor_registry = __esm({
8877
8865
  this.sensorsByName.clear();
8878
8866
  this.sensorsByType.clear();
8879
8867
  }
8868
+ getSensorConfig() {
8869
+ const providerSnapshot = this.sensorConfigProvider?.getSensorConfig();
8870
+ const source = this.getSensorsSource(providerSnapshot);
8871
+ if (source !== "ENV" && providerSnapshot) {
8872
+ return {
8873
+ source,
8874
+ enabledSensors: this.normalizeList(providerSnapshot.enabledSensors),
8875
+ disabledSensors: this.normalizeList(providerSnapshot.disabledSensors)
8876
+ };
8877
+ }
8878
+ return {
8879
+ source,
8880
+ enabledSensors: this.parseConfigList("ENABLED_SENSORS"),
8881
+ disabledSensors: this.parseConfigList("DISABLED_SENSORS")
8882
+ };
8883
+ }
8880
8884
  isPreDecodeSensor(sensor) {
8881
8885
  const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
8882
8886
  if (phase) return phase === "PRE_DECODE";
@@ -8896,6 +8900,48 @@ var init_sensor_registry = __esm({
8896
8900
  this.sensorsByName.set(sensorType.name, sensor);
8897
8901
  }
8898
8902
  }
8903
+ filterEnabledSensors(sensors) {
8904
+ return sensors.filter((sensor) => this.isSensorEnabled(sensor));
8905
+ }
8906
+ isSensorEnabled(sensor) {
8907
+ const config = this.getSensorConfig();
8908
+ const enabled = new Set(config.enabledSensors);
8909
+ const disabled = new Set(config.disabledSensors);
8910
+ const names = this.getSensorNames(sensor);
8911
+ if (names.some((name) => disabled.has(name))) {
8912
+ return false;
8913
+ }
8914
+ if (enabled.size > 0 && !names.some((name) => enabled.has(name))) {
8915
+ return false;
8916
+ }
8917
+ return true;
8918
+ }
8919
+ getSensorNames(sensor) {
8920
+ const names = [sensor.name];
8921
+ const constructorName = sensor.constructor?.name;
8922
+ if (constructorName && !names.includes(constructorName)) {
8923
+ names.push(constructorName);
8924
+ }
8925
+ return names;
8926
+ }
8927
+ getSensorsSource(providerSnapshot) {
8928
+ const raw = this.configService?.get("SENSORS_SOURCE") ?? providerSnapshot?.source ?? "ENV";
8929
+ const normalized = String(raw || "ENV").trim().toUpperCase();
8930
+ return normalized || "ENV";
8931
+ }
8932
+ parseConfigList(key) {
8933
+ return this.normalizeList(this.configService?.get(key));
8934
+ }
8935
+ normalizeList(value) {
8936
+ if (!value) return [];
8937
+ if (Array.isArray(value)) {
8938
+ return value.map((entry) => String(entry).trim()).filter(Boolean);
8939
+ }
8940
+ if (typeof value === "string") {
8941
+ return value.split(",").map((entry) => entry.trim()).filter(Boolean);
8942
+ }
8943
+ return [];
8944
+ }
8899
8945
  };
8900
8946
  }
8901
8947
  });