myio-js-library 0.1.415 → 0.1.417

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
@@ -1122,7 +1122,7 @@ module.exports = __toCommonJS(index_exports);
1122
1122
  // package.json
1123
1123
  var package_default = {
1124
1124
  name: "myio-js-library",
1125
- version: "0.1.415",
1125
+ version: "0.1.417",
1126
1126
  description: "A clean, standalone JS SDK for MYIO projects",
1127
1127
  license: "MIT",
1128
1128
  repository: "github:gh-myio/myio-js-library",
@@ -105080,9 +105080,9 @@ function mapApiStats(api) {
105080
105080
  }
105081
105081
  function mapApiTrend(apiTrend) {
105082
105082
  return (apiTrend || []).map((point) => ({
105083
- label: point.period,
105084
- timestamp: new Date(point.period).getTime() || 0,
105085
- total: point.count,
105083
+ label: point.label || point.period,
105084
+ timestamp: point.timestamp || new Date(point.period).getTime() || 0,
105085
+ total: point.total ?? point.count,
105086
105086
  bySeverity: point.bySeverity ? {
105087
105087
  CRITICAL: point.bySeverity.CRITICAL ?? 0,
105088
105088
  HIGH: point.bySeverity.HIGH ?? 0,
@@ -105913,6 +105913,9 @@ var AlarmsNotificationsPanelView = class {
105913
105913
  groupedAlarms = [];
105914
105914
  // View mode: 'card' (default) or 'list' (table)
105915
105915
  viewMode = "card";
105916
+ // Trend chart data (fetched once when Dashboard tab first opens)
105917
+ trendData = [];
105918
+ trendFetched = false;
105916
105919
  // Group mode:
105917
105920
  // 'consolidado' – Por Tipo de Alarme (one row per alarm type, all devices merged)
105918
105921
  // 'separado' – Por Dispositivo - Tipo (one row per device × alarm type pair)
@@ -106301,18 +106304,32 @@ var AlarmsNotificationsPanelView = class {
106301
106304
  this.emit("cards-rendered", this.groupedAlarms.length);
106302
106305
  }
106303
106306
  /**
106304
- * Render dashboard tab content
106307
+ * Render dashboard tab content.
106308
+ * Trend data is fetched asynchronously on first open and injected when ready.
106305
106309
  */
106306
106310
  renderDashboardContent(state6) {
106307
106311
  if (!this.root) return;
106308
106312
  const container = this.root.querySelector("#dashboardContent");
106309
106313
  if (!container) return;
106310
106314
  if (container.children.length > 0) {
106311
- updateDashboard(container, state6.stats);
106315
+ updateDashboard(container, state6.stats, this.trendData);
106312
106316
  } else {
106313
- container.innerHTML = renderDashboard(state6.stats);
106317
+ container.innerHTML = renderDashboard(state6.stats, this.trendData);
106314
106318
  }
106315
106319
  this.emit("stats-updated", state6.stats);
106320
+ if (!this.trendFetched && this.params.tenantId) {
106321
+ this.trendFetched = true;
106322
+ AlarmService.getAlarmTrend(this.params.tenantId, "week", "day").then((data) => {
106323
+ this.trendData = data;
106324
+ const trendArea = container.querySelector(
106325
+ ".alarms-chart-card:nth-child(1) .alarms-chart-area"
106326
+ );
106327
+ if (trendArea) {
106328
+ updateDashboard(container, this.controller.getState().stats, this.trendData);
106329
+ }
106330
+ }).catch(() => {
106331
+ });
106332
+ }
106316
106333
  }
106317
106334
  // =====================================================================
106318
106335
  // Bulk Selection
@@ -123402,12 +123419,15 @@ function mapCustomerToGCDR(tbCustomer, _gcdrTenantId, _attrs) {
123402
123419
  }
123403
123420
  function mapAssetToGCDR(tbAsset, parentGcdrCustomerId, parentGcdrAssetId) {
123404
123421
  const name = tbAsset.label || tbAsset.name;
123405
- const dto = {
123422
+ return {
123406
123423
  name,
123407
123424
  type: mapAssetType(tbAsset.type),
123408
123425
  customerId: parentGcdrCustomerId,
123409
123426
  externalId: tbAsset.id.id,
123410
123427
  // RFC-0176-v2: forward-compat, external_id column pending RFC-0017
123428
+ // Always send parentAssetId explicitly: null when absent so the GCDR API receives
123429
+ // JSON null (DB NULL) instead of omitting the key (which the server defaults to '' → UUID error)
123430
+ parentAssetId: parentGcdrAssetId || null,
123411
123431
  metadata: {
123412
123432
  tbEntityType: "ASSET",
123413
123433
  tbId: tbAsset.id.id,
@@ -123415,10 +123435,6 @@ function mapAssetToGCDR(tbAsset, parentGcdrCustomerId, parentGcdrAssetId) {
123415
123435
  tbName: tbAsset.name
123416
123436
  }
123417
123437
  };
123418
- if (parentGcdrAssetId) {
123419
- dto.parentAssetId = parentGcdrAssetId;
123420
- }
123421
- return dto;
123422
123438
  }
123423
123439
  function mapDeviceToGCDR(tbDevice, attrs, parentGcdrAssetId, parentGcdrCustomerId) {
123424
123440
  const name = tbDevice.label || tbDevice.name;
package/dist/index.d.cts CHANGED
@@ -5785,7 +5785,8 @@ interface CreateAssetDto {
5785
5785
  customerId: string;
5786
5786
  /** TB Asset UUID — forward-compat, external_id column pending RFC-0017 (RFC-0176-v2) */
5787
5787
  externalId?: string;
5788
- parentAssetId?: string;
5788
+ /** Explicit null = no parent (sends null to GCDR so DB gets NULL, not empty string) */
5789
+ parentAssetId?: string | null;
5789
5790
  metadata?: Record<string, unknown>;
5790
5791
  }
5791
5792
  interface CreateDeviceDto {
@@ -14437,6 +14438,8 @@ interface AlarmsNotificationsPanelParams {
14437
14438
  alarmsApiBaseUrl?: string;
14438
14439
  /** Alarms API key (required — no hardcoded fallback) */
14439
14440
  alarmsApiKey?: string;
14441
+ /** GCDR Tenant ID — required for trend/stats API calls (query param tenantId) */
14442
+ tenantId?: string;
14440
14443
  /** Theme mode (default: 'dark') */
14441
14444
  themeMode?: ThemeMode;
14442
14445
  /** Enable debug logging */
@@ -14751,6 +14754,8 @@ declare class AlarmsNotificationsPanelView {
14751
14754
  private selectedTitles;
14752
14755
  private groupedAlarms;
14753
14756
  private viewMode;
14757
+ private trendData;
14758
+ private trendFetched;
14754
14759
  private groupMode;
14755
14760
  private sortCol;
14756
14761
  private sortDir;
@@ -14784,7 +14789,8 @@ declare class AlarmsNotificationsPanelView {
14784
14789
  */
14785
14790
  private renderListContent;
14786
14791
  /**
14787
- * Render dashboard tab content
14792
+ * Render dashboard tab content.
14793
+ * Trend data is fetched asynchronously on first open and injected when ready.
14788
14794
  */
14789
14795
  private renderDashboardContent;
14790
14796
  private handleAlarmSelect;
@@ -17985,6 +17991,13 @@ interface AlarmStatsApiResponse {
17985
17991
  }
17986
17992
  interface AlarmTrendApiPoint {
17987
17993
  period: string;
17994
+ /** Pre-formatted display label returned by the API (e.g. "23/02") */
17995
+ label?: string;
17996
+ /** Millisecond timestamp returned by the API */
17997
+ timestamp?: number;
17998
+ /** Total alarm count (preferred field) */
17999
+ total?: number;
18000
+ /** Total alarm count (alias — same value as total) */
17988
18001
  count: number;
17989
18002
  bySeverity?: Record<string, number>;
17990
18003
  }
package/dist/index.js CHANGED
@@ -546,7 +546,7 @@ var init_template_card = __esm({
546
546
  // package.json
547
547
  var package_default = {
548
548
  name: "myio-js-library",
549
- version: "0.1.415",
549
+ version: "0.1.417",
550
550
  description: "A clean, standalone JS SDK for MYIO projects",
551
551
  license: "MIT",
552
552
  repository: "github:gh-myio/myio-js-library",
@@ -104504,9 +104504,9 @@ function mapApiStats(api) {
104504
104504
  }
104505
104505
  function mapApiTrend(apiTrend) {
104506
104506
  return (apiTrend || []).map((point) => ({
104507
- label: point.period,
104508
- timestamp: new Date(point.period).getTime() || 0,
104509
- total: point.count,
104507
+ label: point.label || point.period,
104508
+ timestamp: point.timestamp || new Date(point.period).getTime() || 0,
104509
+ total: point.total ?? point.count,
104510
104510
  bySeverity: point.bySeverity ? {
104511
104511
  CRITICAL: point.bySeverity.CRITICAL ?? 0,
104512
104512
  HIGH: point.bySeverity.HIGH ?? 0,
@@ -105337,6 +105337,9 @@ var AlarmsNotificationsPanelView = class {
105337
105337
  groupedAlarms = [];
105338
105338
  // View mode: 'card' (default) or 'list' (table)
105339
105339
  viewMode = "card";
105340
+ // Trend chart data (fetched once when Dashboard tab first opens)
105341
+ trendData = [];
105342
+ trendFetched = false;
105340
105343
  // Group mode:
105341
105344
  // 'consolidado' – Por Tipo de Alarme (one row per alarm type, all devices merged)
105342
105345
  // 'separado' – Por Dispositivo - Tipo (one row per device × alarm type pair)
@@ -105725,18 +105728,32 @@ var AlarmsNotificationsPanelView = class {
105725
105728
  this.emit("cards-rendered", this.groupedAlarms.length);
105726
105729
  }
105727
105730
  /**
105728
- * Render dashboard tab content
105731
+ * Render dashboard tab content.
105732
+ * Trend data is fetched asynchronously on first open and injected when ready.
105729
105733
  */
105730
105734
  renderDashboardContent(state6) {
105731
105735
  if (!this.root) return;
105732
105736
  const container = this.root.querySelector("#dashboardContent");
105733
105737
  if (!container) return;
105734
105738
  if (container.children.length > 0) {
105735
- updateDashboard(container, state6.stats);
105739
+ updateDashboard(container, state6.stats, this.trendData);
105736
105740
  } else {
105737
- container.innerHTML = renderDashboard(state6.stats);
105741
+ container.innerHTML = renderDashboard(state6.stats, this.trendData);
105738
105742
  }
105739
105743
  this.emit("stats-updated", state6.stats);
105744
+ if (!this.trendFetched && this.params.tenantId) {
105745
+ this.trendFetched = true;
105746
+ AlarmService.getAlarmTrend(this.params.tenantId, "week", "day").then((data) => {
105747
+ this.trendData = data;
105748
+ const trendArea = container.querySelector(
105749
+ ".alarms-chart-card:nth-child(1) .alarms-chart-area"
105750
+ );
105751
+ if (trendArea) {
105752
+ updateDashboard(container, this.controller.getState().stats, this.trendData);
105753
+ }
105754
+ }).catch(() => {
105755
+ });
105756
+ }
105740
105757
  }
105741
105758
  // =====================================================================
105742
105759
  // Bulk Selection
@@ -122826,12 +122843,15 @@ function mapCustomerToGCDR(tbCustomer, _gcdrTenantId, _attrs) {
122826
122843
  }
122827
122844
  function mapAssetToGCDR(tbAsset, parentGcdrCustomerId, parentGcdrAssetId) {
122828
122845
  const name = tbAsset.label || tbAsset.name;
122829
- const dto = {
122846
+ return {
122830
122847
  name,
122831
122848
  type: mapAssetType(tbAsset.type),
122832
122849
  customerId: parentGcdrCustomerId,
122833
122850
  externalId: tbAsset.id.id,
122834
122851
  // RFC-0176-v2: forward-compat, external_id column pending RFC-0017
122852
+ // Always send parentAssetId explicitly: null when absent so the GCDR API receives
122853
+ // JSON null (DB NULL) instead of omitting the key (which the server defaults to '' → UUID error)
122854
+ parentAssetId: parentGcdrAssetId || null,
122835
122855
  metadata: {
122836
122856
  tbEntityType: "ASSET",
122837
122857
  tbId: tbAsset.id.id,
@@ -122839,10 +122859,6 @@ function mapAssetToGCDR(tbAsset, parentGcdrCustomerId, parentGcdrAssetId) {
122839
122859
  tbName: tbAsset.name
122840
122860
  }
122841
122861
  };
122842
- if (parentGcdrAssetId) {
122843
- dto.parentAssetId = parentGcdrAssetId;
122844
- }
122845
- return dto;
122846
122862
  }
122847
122863
  function mapDeviceToGCDR(tbDevice, attrs, parentGcdrAssetId, parentGcdrCustomerId) {
122848
122864
  const name = tbDevice.label || tbDevice.name;
@@ -551,7 +551,7 @@
551
551
 
552
552
  // package.json
553
553
  var package_default = {
554
- version: "0.1.415"};
554
+ version: "0.1.417"};
555
555
 
556
556
  // src/format/energy.ts
557
557
  function formatPower(value, decimals = 2) {
@@ -104231,9 +104231,9 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
104231
104231
  }
104232
104232
  function mapApiTrend(apiTrend) {
104233
104233
  return (apiTrend || []).map((point) => ({
104234
- label: point.period,
104235
- timestamp: new Date(point.period).getTime() || 0,
104236
- total: point.count,
104234
+ label: point.label || point.period,
104235
+ timestamp: point.timestamp || new Date(point.period).getTime() || 0,
104236
+ total: point.total ?? point.count,
104237
104237
  bySeverity: point.bySeverity ? {
104238
104238
  CRITICAL: point.bySeverity.CRITICAL ?? 0,
104239
104239
  HIGH: point.bySeverity.HIGH ?? 0,
@@ -105010,7 +105010,7 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
105010
105010
  }
105011
105011
  function renderDashboard(stats, trendData) {
105012
105012
  const kpiCards = renderKPICards(stats);
105013
- const trendChart = renderTrendChart([]);
105013
+ const trendChart = renderTrendChart(trendData || []);
105014
105014
  const stateDonut = renderStateDonutChart(stats.byState);
105015
105015
  const severityBars = renderSeverityBarChart(stats.bySeverity);
105016
105016
  return `
@@ -105040,7 +105040,7 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
105040
105040
  updateKPIValues(container, stats);
105041
105041
  const trendArea = container.querySelector(".alarms-chart-card:nth-child(1) .alarms-chart-area");
105042
105042
  if (trendArea) {
105043
- trendArea.innerHTML = renderTrendChart([]);
105043
+ trendArea.innerHTML = renderTrendChart(trendData || []);
105044
105044
  }
105045
105045
  const stateArea = container.querySelector(".alarms-chart-card:nth-child(2) .alarms-chart-area");
105046
105046
  if (stateArea) {
@@ -105064,6 +105064,9 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
105064
105064
  groupedAlarms = [];
105065
105065
  // View mode: 'card' (default) or 'list' (table)
105066
105066
  viewMode = "card";
105067
+ // Trend chart data (fetched once when Dashboard tab first opens)
105068
+ trendData = [];
105069
+ trendFetched = false;
105067
105070
  // Group mode:
105068
105071
  // 'consolidado' – Por Tipo de Alarme (one row per alarm type, all devices merged)
105069
105072
  // 'separado' – Por Dispositivo - Tipo (one row per device × alarm type pair)
@@ -105452,18 +105455,32 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
105452
105455
  this.emit("cards-rendered", this.groupedAlarms.length);
105453
105456
  }
105454
105457
  /**
105455
- * Render dashboard tab content
105458
+ * Render dashboard tab content.
105459
+ * Trend data is fetched asynchronously on first open and injected when ready.
105456
105460
  */
105457
105461
  renderDashboardContent(state6) {
105458
105462
  if (!this.root) return;
105459
105463
  const container = this.root.querySelector("#dashboardContent");
105460
105464
  if (!container) return;
105461
105465
  if (container.children.length > 0) {
105462
- updateDashboard(container, state6.stats);
105466
+ updateDashboard(container, state6.stats, this.trendData);
105463
105467
  } else {
105464
- container.innerHTML = renderDashboard(state6.stats);
105468
+ container.innerHTML = renderDashboard(state6.stats, this.trendData);
105465
105469
  }
105466
105470
  this.emit("stats-updated", state6.stats);
105471
+ if (!this.trendFetched && this.params.tenantId) {
105472
+ this.trendFetched = true;
105473
+ AlarmService.getAlarmTrend(this.params.tenantId, "week", "day").then((data) => {
105474
+ this.trendData = data;
105475
+ const trendArea = container.querySelector(
105476
+ ".alarms-chart-card:nth-child(1) .alarms-chart-area"
105477
+ );
105478
+ if (trendArea) {
105479
+ updateDashboard(container, this.controller.getState().stats, this.trendData);
105480
+ }
105481
+ }).catch(() => {
105482
+ });
105483
+ }
105467
105484
  }
105468
105485
  // =====================================================================
105469
105486
  // Bulk Selection
@@ -122550,12 +122567,15 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
122550
122567
  }
122551
122568
  function mapAssetToGCDR(tbAsset, parentGcdrCustomerId, parentGcdrAssetId) {
122552
122569
  const name = tbAsset.label || tbAsset.name;
122553
- const dto = {
122570
+ return {
122554
122571
  name,
122555
122572
  type: mapAssetType(tbAsset.type),
122556
122573
  customerId: parentGcdrCustomerId,
122557
122574
  externalId: tbAsset.id.id,
122558
122575
  // RFC-0176-v2: forward-compat, external_id column pending RFC-0017
122576
+ // Always send parentAssetId explicitly: null when absent so the GCDR API receives
122577
+ // JSON null (DB NULL) instead of omitting the key (which the server defaults to '' → UUID error)
122578
+ parentAssetId: parentGcdrAssetId || null,
122559
122579
  metadata: {
122560
122580
  tbEntityType: "ASSET",
122561
122581
  tbId: tbAsset.id.id,
@@ -122563,7 +122583,6 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
122563
122583
  tbName: tbAsset.name
122564
122584
  }
122565
122585
  };
122566
- return dto;
122567
122586
  }
122568
122587
  function mapDeviceToGCDR(tbDevice, attrs, parentGcdrAssetId, parentGcdrCustomerId) {
122569
122588
  const name = tbDevice.label || tbDevice.name;
@@ -122930,7 +122949,7 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
122930
122949
  resolveAssetDto(action, bundle, resolvedGcdrIds) {
122931
122950
  const asset = bundle.assets.find((a) => a.id.id === action.tbId);
122932
122951
  const customerGcdrId = resolvedGcdrIds.get(bundle.customer.id.id) ?? "__unknown_customer__";
122933
- return mapAssetToGCDR(asset, customerGcdrId);
122952
+ return mapAssetToGCDR(asset, customerGcdrId, void 0);
122934
122953
  }
122935
122954
  resolveDeviceDto(action, bundle, resolvedGcdrIds) {
122936
122955
  const device = bundle.devices.find((d) => d.id.id === action.tbId);