@mega-yfue/eufy-sdk 0.5.0-beta.22 → 0.5.0-beta.23

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.js CHANGED
@@ -10505,6 +10505,11 @@ var SuctionLevel = {
10505
10505
  };
10506
10506
  var SUCTION_LABEL = enumLabels(SuctionLevel);
10507
10507
  var ALL_SUCTION_LEVELS = [0, 1, 2, 3, 4, 5];
10508
+ function levelFromCatalog(member) {
10509
+ if (Object.hasOwn(SuctionLevel, member))
10510
+ return SuctionLevel[member];
10511
+ return Object.hasOwn(SUCTION_LABEL, member) ? Number(member) : void 0;
10512
+ }
10508
10513
  function suctionLevelName(value) {
10509
10514
  return SUCTION_LABEL[value];
10510
10515
  }
@@ -10565,13 +10570,15 @@ var SUCTION = {
10565
10570
  },
10566
10571
  /**
10567
10572
  * The per-model level range — sourced from the SKU's `get_product_data_point` catalog for DP 158
10568
- * when available. `undefined` when no catalog entry exists for DP 158. `setSuctionLevel` is only
10573
+ * when available. `undefined` when no catalog entry exists for DP 158, or when no listed member maps
10574
+ * to a known level (so a caller never reads `[]` as "nothing selectable"). `setSuctionLevel` is only
10569
10575
  * installed on AIoT devices (gated by `available: isAiotVacuum` on the `level` entry), so
10570
10576
  * `supportedLevels` is harmless data on a non-AIoT device.
10571
10577
  */
10572
10578
  actions({ ctx }) {
10573
10579
  const catalogRange = ctx.dpCatalog?.enumRanges.get(SUCTION_DP.SUCTION);
10574
- const supportedLevels = catalogRange?.filter((v) => v in SUCTION_LABEL);
10580
+ const levels = catalogRange?.flatMap((m) => levelFromCatalog(m) ?? []);
10581
+ const supportedLevels = levels?.length ? levels : void 0;
10575
10582
  return { supportedLevels };
10576
10583
  }
10577
10584
  };
@@ -10613,28 +10620,29 @@ function parseEnumRange(values) {
10613
10620
  if (values === null || values === void 0)
10614
10621
  return [];
10615
10622
  if (Array.isArray(values))
10616
- return toNumberArray(values);
10623
+ return toMemberArray(values);
10617
10624
  if (typeof values === "string") {
10618
10625
  try {
10619
10626
  const parsed = JSON.parse(values);
10620
10627
  if (Array.isArray(parsed))
10621
- return toNumberArray(parsed);
10628
+ return toMemberArray(parsed);
10622
10629
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
10623
10630
  const obj = parsed;
10624
10631
  if (Array.isArray(obj.range))
10625
- return toNumberArray(obj.range);
10632
+ return toMemberArray(obj.range);
10626
10633
  }
10627
10634
  } catch {
10628
10635
  }
10629
10636
  }
10630
10637
  return [];
10631
10638
  }
10632
- function toNumberArray(arr) {
10639
+ function toMemberArray(arr) {
10633
10640
  const result = [];
10634
10641
  for (const v of arr) {
10635
- const n = typeof v === "number" ? v : typeof v === "string" ? Number(v) : NaN;
10636
- if (Number.isInteger(n))
10637
- result.push(n);
10642
+ if (typeof v === "number" && Number.isFinite(v))
10643
+ result.push(String(v));
10644
+ else if (typeof v === "string" && v !== "")
10645
+ result.push(v);
10638
10646
  }
10639
10647
  return result;
10640
10648
  }