myio-js-library 0.1.585 → 0.1.586

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.cjs CHANGED
@@ -989,7 +989,7 @@ module.exports = __toCommonJS(src_exports);
989
989
  // package.json
990
990
  var package_default = {
991
991
  name: "myio-js-library",
992
- version: "0.1.585",
992
+ version: "0.1.586",
993
993
  description: "A clean, standalone JS SDK for MYIO projects",
994
994
  license: "MIT",
995
995
  repository: "github:gh-myio/myio-js-library",
@@ -29328,6 +29328,7 @@ function createDateRangePicker($2, input, opts) {
29328
29328
  } else {
29329
29329
  ranges = {
29330
29330
  "Hoje": [moment().startOf("day"), moment().endOf("day")],
29331
+ "Ontem": [moment().subtract(1, "day").startOf("day"), moment().subtract(1, "day").endOf("day")],
29331
29332
  "\xDAltimos 7 dias": [moment().subtract(6, "days").startOf("day"), moment().endOf("day")],
29332
29333
  "\xDAltimos 15 dias": [moment().subtract(14, "days").startOf("day"), moment().endOf("day")],
29333
29334
  "\xDAltimos 30 dias": [moment().subtract(29, "days").startOf("day"), moment().endOf("day")],
@@ -63622,6 +63623,7 @@ var DeviceProfileTab = class {
63622
63623
  const slaveIdNum = typeof slaveId === "string" ? parseInt(slaveId, 10) : slaveId;
63623
63624
  let page = 1;
63624
63625
  let match = null;
63626
+ let fallback = null;
63625
63627
  for (; page <= 50 && !match; page++) {
63626
63628
  const res = await fetch(
63627
63629
  `${INGESTION_API_BASE2}/management/devices?page=${page}&limit=100&customerId=${encodeURIComponent(
@@ -63633,15 +63635,18 @@ var DeviceProfileTab = class {
63633
63635
  const json = await res.json();
63634
63636
  const list = json?.data || [];
63635
63637
  for (const d of list) {
63636
- const gwId = d.gateway?.hardwareUuid || d.gatewayId || d.gateway?.id;
63637
- if (gwId === centralId && d.slaveId === slaveIdNum) {
63638
+ if (d.slaveId !== slaveIdNum) continue;
63639
+ if (d.gateway?.hardwareUuid === centralId) {
63638
63640
  match = { id: d.id };
63639
63641
  break;
63640
63642
  }
63643
+ if (!fallback && (d.gatewayId === centralId || d.gateway?.id === centralId)) fallback = { id: d.id };
63641
63644
  }
63645
+ if (match) break;
63642
63646
  const totalPages = json?.pagination?.pages || 1;
63643
63647
  if (page >= totalPages) break;
63644
63648
  }
63649
+ if (!match && fallback) match = fallback;
63645
63650
  if (!match) {
63646
63651
  return { ok: false, message: `Nenhum device na Ingestion API com centralId=${centralId} e slaveId=${slaveIdNum}.` };
63647
63652
  }
@@ -111485,27 +111490,30 @@ async function fetchIngestionDevicesAllPaged(customerId) {
111485
111490
  }
111486
111491
  function findIngestionDeviceByCentralSlaveId(devices, centralId, slaveId) {
111487
111492
  const slaveIdNum = typeof slaveId === "string" ? parseInt(slaveId, 10) : slaveId;
111488
- for (const device of devices) {
111489
- const deviceGatewayId = device.gateway?.hardwareUuid || device.gatewayId || device.gateway?.id;
111490
- if (deviceGatewayId === centralId && device.slaveId === slaveIdNum) {
111491
- console.log(
111492
- "[UpsellModal] Found matching device:",
111493
- device.name,
111494
- "gatewayId:",
111495
- deviceGatewayId,
111496
- "slaveId:",
111497
- device.slaveId
111498
- );
111499
- return device;
111500
- }
111493
+ const bySlave = devices.filter((d) => d.slaveId === slaveIdNum);
111494
+ const match = bySlave.find((d) => d.gateway?.hardwareUuid === centralId) || bySlave.find((d) => d.gatewayId === centralId || d.gateway?.id === centralId);
111495
+ if (match) {
111496
+ console.log(
111497
+ "[UpsellModal] Found matching device:",
111498
+ match.name,
111499
+ "via:",
111500
+ match.gateway?.hardwareUuid === centralId ? "hardwareUuid" : "gatewayId",
111501
+ "centralId:",
111502
+ centralId,
111503
+ "slaveId:",
111504
+ match.slaveId
111505
+ );
111506
+ return match;
111501
111507
  }
111502
111508
  console.log("[UpsellModal] No match found. Looking for centralId:", centralId, "slaveId:", slaveIdNum);
111503
111509
  devices.slice(0, 3).forEach((d, i) => {
111504
111510
  console.log(
111505
111511
  `[UpsellModal] Sample device ${i}:`,
111506
111512
  d.name,
111507
- "gateway(hwUuid|id):",
111508
- d.gateway?.hardwareUuid || d.gatewayId || d.gateway?.id,
111513
+ "gateway hwUuid / id:",
111514
+ d.gateway?.hardwareUuid,
111515
+ "/",
111516
+ d.gatewayId || d.gateway?.id,
111509
111517
  "slaveId:",
111510
111518
  d.slaveId
111511
111519
  );
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  // package.json
11
11
  var package_default = {
12
12
  name: "myio-js-library",
13
- version: "0.1.585",
13
+ version: "0.1.586",
14
14
  description: "A clean, standalone JS SDK for MYIO projects",
15
15
  license: "MIT",
16
16
  repository: "github:gh-myio/myio-js-library",
@@ -27624,6 +27624,7 @@ function createDateRangePicker($2, input, opts) {
27624
27624
  } else {
27625
27625
  ranges = {
27626
27626
  "Hoje": [moment().startOf("day"), moment().endOf("day")],
27627
+ "Ontem": [moment().subtract(1, "day").startOf("day"), moment().subtract(1, "day").endOf("day")],
27627
27628
  "\xDAltimos 7 dias": [moment().subtract(6, "days").startOf("day"), moment().endOf("day")],
27628
27629
  "\xDAltimos 15 dias": [moment().subtract(14, "days").startOf("day"), moment().endOf("day")],
27629
27630
  "\xDAltimos 30 dias": [moment().subtract(29, "days").startOf("day"), moment().endOf("day")],
@@ -61918,6 +61919,7 @@ var DeviceProfileTab = class {
61918
61919
  const slaveIdNum = typeof slaveId === "string" ? parseInt(slaveId, 10) : slaveId;
61919
61920
  let page = 1;
61920
61921
  let match = null;
61922
+ let fallback = null;
61921
61923
  for (; page <= 50 && !match; page++) {
61922
61924
  const res = await fetch(
61923
61925
  `${INGESTION_API_BASE2}/management/devices?page=${page}&limit=100&customerId=${encodeURIComponent(
@@ -61929,15 +61931,18 @@ var DeviceProfileTab = class {
61929
61931
  const json = await res.json();
61930
61932
  const list = json?.data || [];
61931
61933
  for (const d of list) {
61932
- const gwId = d.gateway?.hardwareUuid || d.gatewayId || d.gateway?.id;
61933
- if (gwId === centralId && d.slaveId === slaveIdNum) {
61934
+ if (d.slaveId !== slaveIdNum) continue;
61935
+ if (d.gateway?.hardwareUuid === centralId) {
61934
61936
  match = { id: d.id };
61935
61937
  break;
61936
61938
  }
61939
+ if (!fallback && (d.gatewayId === centralId || d.gateway?.id === centralId)) fallback = { id: d.id };
61937
61940
  }
61941
+ if (match) break;
61938
61942
  const totalPages = json?.pagination?.pages || 1;
61939
61943
  if (page >= totalPages) break;
61940
61944
  }
61945
+ if (!match && fallback) match = fallback;
61941
61946
  if (!match) {
61942
61947
  return { ok: false, message: `Nenhum device na Ingestion API com centralId=${centralId} e slaveId=${slaveIdNum}.` };
61943
61948
  }
@@ -108513,27 +108518,30 @@ async function fetchIngestionDevicesAllPaged(customerId) {
108513
108518
  }
108514
108519
  function findIngestionDeviceByCentralSlaveId(devices, centralId, slaveId) {
108515
108520
  const slaveIdNum = typeof slaveId === "string" ? parseInt(slaveId, 10) : slaveId;
108516
- for (const device of devices) {
108517
- const deviceGatewayId = device.gateway?.hardwareUuid || device.gatewayId || device.gateway?.id;
108518
- if (deviceGatewayId === centralId && device.slaveId === slaveIdNum) {
108519
- console.log(
108520
- "[UpsellModal] Found matching device:",
108521
- device.name,
108522
- "gatewayId:",
108523
- deviceGatewayId,
108524
- "slaveId:",
108525
- device.slaveId
108526
- );
108527
- return device;
108528
- }
108521
+ const bySlave = devices.filter((d) => d.slaveId === slaveIdNum);
108522
+ const match = bySlave.find((d) => d.gateway?.hardwareUuid === centralId) || bySlave.find((d) => d.gatewayId === centralId || d.gateway?.id === centralId);
108523
+ if (match) {
108524
+ console.log(
108525
+ "[UpsellModal] Found matching device:",
108526
+ match.name,
108527
+ "via:",
108528
+ match.gateway?.hardwareUuid === centralId ? "hardwareUuid" : "gatewayId",
108529
+ "centralId:",
108530
+ centralId,
108531
+ "slaveId:",
108532
+ match.slaveId
108533
+ );
108534
+ return match;
108529
108535
  }
108530
108536
  console.log("[UpsellModal] No match found. Looking for centralId:", centralId, "slaveId:", slaveIdNum);
108531
108537
  devices.slice(0, 3).forEach((d, i) => {
108532
108538
  console.log(
108533
108539
  `[UpsellModal] Sample device ${i}:`,
108534
108540
  d.name,
108535
- "gateway(hwUuid|id):",
108536
- d.gateway?.hardwareUuid || d.gatewayId || d.gateway?.id,
108541
+ "gateway hwUuid / id:",
108542
+ d.gateway?.hardwareUuid,
108543
+ "/",
108544
+ d.gatewayId || d.gateway?.id,
108537
108545
  "slaveId:",
108538
108546
  d.slaveId
108539
108547
  );
@@ -5524,7 +5524,7 @@
5524
5524
 
5525
5525
  // package.json
5526
5526
  var package_default = {
5527
- version: "0.1.585"};
5527
+ version: "0.1.586"};
5528
5528
 
5529
5529
  // src/utils/format/energy.ts
5530
5530
  function formatPower(value, decimals = 2) {
@@ -33019,6 +33019,7 @@
33019
33019
  } else {
33020
33020
  ranges = {
33021
33021
  "Hoje": [moment().startOf("day"), moment().endOf("day")],
33022
+ "Ontem": [moment().subtract(1, "day").startOf("day"), moment().subtract(1, "day").endOf("day")],
33022
33023
  "\xDAltimos 7 dias": [moment().subtract(6, "days").startOf("day"), moment().endOf("day")],
33023
33024
  "\xDAltimos 15 dias": [moment().subtract(14, "days").startOf("day"), moment().endOf("day")],
33024
33025
  "\xDAltimos 30 dias": [moment().subtract(29, "days").startOf("day"), moment().endOf("day")],
@@ -67276,6 +67277,7 @@ ${kpiRows}` : ""}
67276
67277
  const slaveIdNum = typeof slaveId === "string" ? parseInt(slaveId, 10) : slaveId;
67277
67278
  let page = 1;
67278
67279
  let match = null;
67280
+ let fallback = null;
67279
67281
  for (; page <= 50 && !match; page++) {
67280
67282
  const res = await fetch(
67281
67283
  `${INGESTION_API_BASE2}/management/devices?page=${page}&limit=100&customerId=${encodeURIComponent(
@@ -67287,15 +67289,18 @@ ${kpiRows}` : ""}
67287
67289
  const json = await res.json();
67288
67290
  const list = json?.data || [];
67289
67291
  for (const d of list) {
67290
- const gwId = d.gateway?.hardwareUuid || d.gatewayId || d.gateway?.id;
67291
- if (gwId === centralId && d.slaveId === slaveIdNum) {
67292
+ if (d.slaveId !== slaveIdNum) continue;
67293
+ if (d.gateway?.hardwareUuid === centralId) {
67292
67294
  match = { id: d.id };
67293
67295
  break;
67294
67296
  }
67297
+ if (!fallback && (d.gatewayId === centralId || d.gateway?.id === centralId)) fallback = { id: d.id };
67295
67298
  }
67299
+ if (match) break;
67296
67300
  const totalPages = json?.pagination?.pages || 1;
67297
67301
  if (page >= totalPages) break;
67298
67302
  }
67303
+ if (!match && fallback) match = fallback;
67299
67304
  if (!match) {
67300
67305
  return { ok: false, message: `Nenhum device na Ingestion API com centralId=${centralId} e slaveId=${slaveIdNum}.` };
67301
67306
  }
@@ -113728,27 +113733,30 @@ ${state5.year}-03-15T08,15`)}">${esc7(state5.csv)}</textarea>
113728
113733
  }
113729
113734
  function findIngestionDeviceByCentralSlaveId(devices, centralId, slaveId) {
113730
113735
  const slaveIdNum = typeof slaveId === "string" ? parseInt(slaveId, 10) : slaveId;
113731
- for (const device of devices) {
113732
- const deviceGatewayId = device.gateway?.hardwareUuid || device.gatewayId || device.gateway?.id;
113733
- if (deviceGatewayId === centralId && device.slaveId === slaveIdNum) {
113734
- console.log(
113735
- "[UpsellModal] Found matching device:",
113736
- device.name,
113737
- "gatewayId:",
113738
- deviceGatewayId,
113739
- "slaveId:",
113740
- device.slaveId
113741
- );
113742
- return device;
113743
- }
113736
+ const bySlave = devices.filter((d) => d.slaveId === slaveIdNum);
113737
+ const match = bySlave.find((d) => d.gateway?.hardwareUuid === centralId) || bySlave.find((d) => d.gatewayId === centralId || d.gateway?.id === centralId);
113738
+ if (match) {
113739
+ console.log(
113740
+ "[UpsellModal] Found matching device:",
113741
+ match.name,
113742
+ "via:",
113743
+ match.gateway?.hardwareUuid === centralId ? "hardwareUuid" : "gatewayId",
113744
+ "centralId:",
113745
+ centralId,
113746
+ "slaveId:",
113747
+ match.slaveId
113748
+ );
113749
+ return match;
113744
113750
  }
113745
113751
  console.log("[UpsellModal] No match found. Looking for centralId:", centralId, "slaveId:", slaveIdNum);
113746
113752
  devices.slice(0, 3).forEach((d, i) => {
113747
113753
  console.log(
113748
113754
  `[UpsellModal] Sample device ${i}:`,
113749
113755
  d.name,
113750
- "gateway(hwUuid|id):",
113751
- d.gateway?.hardwareUuid || d.gatewayId || d.gateway?.id,
113756
+ "gateway hwUuid / id:",
113757
+ d.gateway?.hardwareUuid,
113758
+ "/",
113759
+ d.gatewayId || d.gateway?.id,
113752
113760
  "slaveId:",
113753
113761
  d.slaveId
113754
113762
  );