@nextera.one/axis-server-sdk 2.3.19 → 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.
@@ -5654,7 +5654,6 @@ function buildPacket(hdr, body, sig, flags = 0) {
5654
5654
  const nonce = hm.get(T.NONCE)?.[0];
5655
5655
  const tsMs = asBigint64BE(hm.get(T.TS_MS)?.[0]);
5656
5656
  if (!intent) throw new Error("PACKET_MISSING_INTENT");
5657
- if (!actorId) throw new Error("PACKET_MISSING_ACTOR_ID");
5658
5657
  if (!nonce || nonce.length < 16 || nonce.length > 32)
5659
5658
  throw new Error("PACKET_BAD_NONCE");
5660
5659
  if (!pid) throw new Error("PACKET_MISSING_PID");
@@ -8794,8 +8793,9 @@ var init_sensor_registry = __esm({
8794
8793
  "src/engine/registry/sensor.registry.ts"() {
8795
8794
  init_axis_logger();
8796
8795
  SensorRegistry = class _SensorRegistry {
8797
- constructor(configService) {
8796
+ constructor(configService, sensorConfigProvider) {
8798
8797
  this.configService = configService;
8798
+ this.sensorConfigProvider = sensorConfigProvider;
8799
8799
  this.sensors = [];
8800
8800
  this.sensorsByName = /* @__PURE__ */ new Map();
8801
8801
  this.sensorsByType = /* @__PURE__ */ new Map();
@@ -8805,22 +8805,6 @@ var init_sensor_registry = __esm({
8805
8805
  if (!sensor.name) {
8806
8806
  throw new Error("AxisSensor must have a name");
8807
8807
  }
8808
- const enabledSensorsStr = this.configService?.get("ENABLED_SENSORS");
8809
- const disabledSensorsStr = this.configService?.get("DISABLED_SENSORS");
8810
- const enabledSensors = enabledSensorsStr ? enabledSensorsStr.split(",").map((s) => s.trim()) : null;
8811
- const disabledSensors = disabledSensorsStr ? disabledSensorsStr.split(",").map((s) => s.trim()) : [];
8812
- if (enabledSensors && !enabledSensors.includes(sensor.name)) {
8813
- this.logger.log(
8814
- `Skipping disabled sensor (not in ENABLED_SENSORS): ${sensor.name}`
8815
- );
8816
- return;
8817
- }
8818
- if (disabledSensors.includes(sensor.name)) {
8819
- this.logger.log(
8820
- `Skipping disabled sensor (in DISABLED_SENSORS): ${sensor.name}`
8821
- );
8822
- return;
8823
- }
8824
8808
  if (sensor.order === void 0) {
8825
8809
  throw new Error(`AxisSensor "${sensor.name}" must have an order field`);
8826
8810
  }
@@ -8844,18 +8828,21 @@ var init_sensor_registry = __esm({
8844
8828
  );
8845
8829
  }
8846
8830
  list() {
8847
- return [...this.sensors].sort(
8831
+ return this.filterEnabledSensors(this.sensors).sort(
8848
8832
  (a, b) => (a.order ?? 999) - (b.order ?? 999)
8849
8833
  );
8850
8834
  }
8851
8835
  resolve(ref) {
8852
8836
  if (typeof ref === "string") {
8853
- return this.sensorsByName.get(ref);
8837
+ const sensor2 = this.sensorsByName.get(ref);
8838
+ return sensor2 && this.isSensorEnabled(sensor2) ? sensor2 : void 0;
8854
8839
  }
8855
- 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;
8856
8842
  }
8857
8843
  getByName(name) {
8858
- return this.sensorsByName.get(name);
8844
+ const sensor = this.sensorsByName.get(name);
8845
+ return sensor && this.isSensorEnabled(sensor) ? sensor : void 0;
8859
8846
  }
8860
8847
  getPreDecodeSensors() {
8861
8848
  return this.list().filter(
@@ -8878,6 +8865,22 @@ var init_sensor_registry = __esm({
8878
8865
  this.sensorsByName.clear();
8879
8866
  this.sensorsByType.clear();
8880
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
+ }
8881
8884
  isPreDecodeSensor(sensor) {
8882
8885
  const phase = typeof sensor.phase === "string" ? sensor.phase : sensor.phase?.phase;
8883
8886
  if (phase) return phase === "PRE_DECODE";
@@ -8897,6 +8900,48 @@ var init_sensor_registry = __esm({
8897
8900
  this.sensorsByName.set(sensorType.name, sensor);
8898
8901
  }
8899
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
+ }
8900
8945
  };
8901
8946
  }
8902
8947
  });