myio-js-library 0.1.590 → 0.1.591

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
@@ -990,7 +990,7 @@ module.exports = __toCommonJS(src_exports);
990
990
  // package.json
991
991
  var package_default = {
992
992
  name: "myio-js-library",
993
- version: "0.1.590",
993
+ version: "0.1.591",
994
994
  description: "A clean, standalone JS SDK for MYIO projects",
995
995
  license: "MIT",
996
996
  repository: "github:gh-myio/myio-js-library",
@@ -21716,7 +21716,7 @@ async function valuateDomainMoney(opts) {
21716
21716
  const timezone = opts.timezone || TARIFF_DEFAULT_TIMEZONE;
21717
21717
  const devices = (opts.devices || []).filter((d) => d && d.key && isMoneyConvertibleGroup(opts.domain, d.group));
21718
21718
  const categoryByKey = /* @__PURE__ */ new Map();
21719
- for (const d of devices) categoryByKey.set(d.key, resolveMoneyCategory(opts.rule, d.group));
21719
+ for (const d of devices) categoryByKey.set(d.key, d.category || resolveMoneyCategory(opts.rule, d.group));
21720
21720
  const categories = Array.from(new Set(Array.from(categoryByKey.values()).filter(Boolean)));
21721
21721
  const trees = {};
21722
21722
  const years = yearsSpanned(opts.startTs, opts.endTs, timezone);
@@ -63427,7 +63427,8 @@ var TariffApiError = class extends Error {
63427
63427
  };
63428
63428
  function joinUrl(baseUrl, basePath, path) {
63429
63429
  const b = baseUrl.replace(/\/+$/, "");
63430
- const bp = basePath ? `/${basePath.replace(/^\/+|\/+$/g, "")}` : "";
63430
+ let bp = basePath ? `/${basePath.replace(/^\/+|\/+$/g, "")}` : "";
63431
+ if (bp && b.toLowerCase().endsWith(bp.toLowerCase())) bp = "";
63431
63432
  const p = path.startsWith("/") ? path : `/${path}`;
63432
63433
  return `${b}${bp}${p}`;
63433
63434
  }
@@ -64257,6 +64258,14 @@ var DeviceProfileTab = class {
64257
64258
  if (!client) throw new Error("GCDR n\xE3o configurado.");
64258
64259
  const updated = await client.setDeviceCategory(this.gcdrDeviceId(), value || null);
64259
64260
  this.tariff = { ...this.tariff, current: updated.id ? updated.tariffCategory : value || null };
64261
+ try {
64262
+ window.dispatchEvent(
64263
+ new CustomEvent("myio:tariffs-updated", {
64264
+ detail: { source: "device-category", deviceId: this.gcdrDeviceId(), category: value || null, ts: Date.now() }
64265
+ })
64266
+ );
64267
+ } catch {
64268
+ }
64260
64269
  } else if (kind === "entity-label") {
64261
64270
  await this.saveEntityField({ label: value });
64262
64271
  } else if (kind === "entity-profile") {
package/dist/index.d.cts CHANGED
@@ -17174,6 +17174,11 @@ interface MoneyDevice {
17174
17174
  key: string;
17175
17175
  /** Dashboard group (`lojas`, `areacomum`, `entrada`, …). */
17176
17176
  group: string;
17177
+ /**
17178
+ * Tariff category of the device itself (GCDR `device.tariffCategory`, RFC-0081). When set it
17179
+ * wins over `rule`; empty → falls back to the rule. Non-convertible groups (Q8) stay physical.
17180
+ */
17181
+ category?: string | null;
17177
17182
  }
17178
17183
  type QtyMap = Map<string, number> | Record<string, number>;
17179
17184
  interface ValuateDomainOptions {
package/dist/index.d.ts CHANGED
@@ -17174,6 +17174,11 @@ interface MoneyDevice {
17174
17174
  key: string;
17175
17175
  /** Dashboard group (`lojas`, `areacomum`, `entrada`, …). */
17176
17176
  group: string;
17177
+ /**
17178
+ * Tariff category of the device itself (GCDR `device.tariffCategory`, RFC-0081). When set it
17179
+ * wins over `rule`; empty → falls back to the rule. Non-convertible groups (Q8) stay physical.
17180
+ */
17181
+ category?: string | null;
17177
17182
  }
17178
17183
  type QtyMap = Map<string, number> | Record<string, number>;
17179
17184
  interface ValuateDomainOptions {
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.590",
13
+ version: "0.1.591",
14
14
  description: "A clean, standalone JS SDK for MYIO projects",
15
15
  license: "MIT",
16
16
  repository: "github:gh-myio/myio-js-library",
@@ -20011,7 +20011,7 @@ async function valuateDomainMoney(opts) {
20011
20011
  const timezone = opts.timezone || TARIFF_DEFAULT_TIMEZONE;
20012
20012
  const devices = (opts.devices || []).filter((d) => d && d.key && isMoneyConvertibleGroup(opts.domain, d.group));
20013
20013
  const categoryByKey = /* @__PURE__ */ new Map();
20014
- for (const d of devices) categoryByKey.set(d.key, resolveMoneyCategory(opts.rule, d.group));
20014
+ for (const d of devices) categoryByKey.set(d.key, d.category || resolveMoneyCategory(opts.rule, d.group));
20015
20015
  const categories = Array.from(new Set(Array.from(categoryByKey.values()).filter(Boolean)));
20016
20016
  const trees = {};
20017
20017
  const years = yearsSpanned(opts.startTs, opts.endTs, timezone);
@@ -61722,7 +61722,8 @@ var TariffApiError = class extends Error {
61722
61722
  };
61723
61723
  function joinUrl(baseUrl, basePath, path) {
61724
61724
  const b = baseUrl.replace(/\/+$/, "");
61725
- const bp = basePath ? `/${basePath.replace(/^\/+|\/+$/g, "")}` : "";
61725
+ let bp = basePath ? `/${basePath.replace(/^\/+|\/+$/g, "")}` : "";
61726
+ if (bp && b.toLowerCase().endsWith(bp.toLowerCase())) bp = "";
61726
61727
  const p = path.startsWith("/") ? path : `/${path}`;
61727
61728
  return `${b}${bp}${p}`;
61728
61729
  }
@@ -62552,6 +62553,14 @@ var DeviceProfileTab = class {
62552
62553
  if (!client) throw new Error("GCDR n\xE3o configurado.");
62553
62554
  const updated = await client.setDeviceCategory(this.gcdrDeviceId(), value || null);
62554
62555
  this.tariff = { ...this.tariff, current: updated.id ? updated.tariffCategory : value || null };
62556
+ try {
62557
+ window.dispatchEvent(
62558
+ new CustomEvent("myio:tariffs-updated", {
62559
+ detail: { source: "device-category", deviceId: this.gcdrDeviceId(), category: value || null, ts: Date.now() }
62560
+ })
62561
+ );
62562
+ } catch {
62563
+ }
62555
62564
  } else if (kind === "entity-label") {
62556
62565
  await this.saveEntityField({ label: value });
62557
62566
  } else if (kind === "entity-profile") {
@@ -5524,7 +5524,7 @@
5524
5524
 
5525
5525
  // package.json
5526
5526
  var package_default = {
5527
- version: "0.1.590"};
5527
+ version: "0.1.591"};
5528
5528
 
5529
5529
  // src/utils/format/energy.ts
5530
5530
  function formatPower(value, decimals = 2) {
@@ -25414,7 +25414,7 @@
25414
25414
  const timezone = opts.timezone || TARIFF_DEFAULT_TIMEZONE;
25415
25415
  const devices = (opts.devices || []).filter((d) => d && d.key && isMoneyConvertibleGroup(opts.domain, d.group));
25416
25416
  const categoryByKey = /* @__PURE__ */ new Map();
25417
- for (const d of devices) categoryByKey.set(d.key, resolveMoneyCategory(opts.rule, d.group));
25417
+ for (const d of devices) categoryByKey.set(d.key, d.category || resolveMoneyCategory(opts.rule, d.group));
25418
25418
  const categories = Array.from(new Set(Array.from(categoryByKey.values()).filter(Boolean)));
25419
25419
  const trees = {};
25420
25420
  const years = yearsSpanned(opts.startTs, opts.endTs, timezone);
@@ -67080,7 +67080,8 @@ ${kpiRows}` : ""}
67080
67080
  };
67081
67081
  function joinUrl(baseUrl, basePath, path) {
67082
67082
  const b = baseUrl.replace(/\/+$/, "");
67083
- const bp = basePath ? `/${basePath.replace(/^\/+|\/+$/g, "")}` : "";
67083
+ let bp = basePath ? `/${basePath.replace(/^\/+|\/+$/g, "")}` : "";
67084
+ if (bp && b.toLowerCase().endsWith(bp.toLowerCase())) bp = "";
67084
67085
  const p = path.startsWith("/") ? path : `/${path}`;
67085
67086
  return `${b}${bp}${p}`;
67086
67087
  }
@@ -67910,6 +67911,14 @@ ${kpiRows}` : ""}
67910
67911
  if (!client) throw new Error("GCDR n\xE3o configurado.");
67911
67912
  const updated = await client.setDeviceCategory(this.gcdrDeviceId(), value || null);
67912
67913
  this.tariff = { ...this.tariff, current: updated.id ? updated.tariffCategory : value || null };
67914
+ try {
67915
+ window.dispatchEvent(
67916
+ new CustomEvent("myio:tariffs-updated", {
67917
+ detail: { source: "device-category", deviceId: this.gcdrDeviceId(), category: value || null, ts: Date.now() }
67918
+ })
67919
+ );
67920
+ } catch {
67921
+ }
67913
67922
  } else if (kind === "entity-label") {
67914
67923
  await this.saveEntityField({ label: value });
67915
67924
  } else if (kind === "entity-profile") {