myio-js-library 0.1.591 → 0.1.593

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.591",
993
+ version: "0.1.593",
994
994
  description: "A clean, standalone JS SDK for MYIO projects",
995
995
  license: "MIT",
996
996
  repository: "github:gh-myio/myio-js-library",
@@ -180557,6 +180557,15 @@ var CSS5 = `
180557
180557
  --cscard-switch-on:#2563eb;
180558
180558
  --cscard-danger:#dc2626;
180559
180559
  --cscard-select-ring:#7c3aed;
180560
+ /* health axis (GCDR RFC-0085) \u2014 ONLY the dot of the v3 badge and the
180561
+ "Sistema" pills. Deliberately never the border or the header wash:
180562
+ those two already belong to entityStatus and connectivity. */
180563
+ --cscard-health-ok:#22c55e;
180564
+ --cscard-health-warn:#f59e0b;
180565
+ --cscard-health-bad:#ef4444;
180566
+ --cscard-health-silent:#94a3b8;
180567
+ --cscard-health-pill-bg:#f1f5f9;
180568
+ --cscard-health-pill-fg:#334155;
180560
180569
  box-sizing:border-box;
180561
180570
  position:relative;
180562
180571
  display:flex;flex-direction:row;
@@ -180595,6 +180604,8 @@ var CSS5 = `
180595
180604
  --cscard-border-active-glow:rgba(34,197,94,.4);
180596
180605
  --cscard-border-inactive:#475569;
180597
180606
  --cscard-switch-off:#475569;
180607
+ --cscard-health-pill-bg:#1e2d45;
180608
+ --cscard-health-pill-fg:#cbd5e1;
180598
180609
  }
180599
180610
 
180600
180611
  /* \u2500\u2500 registry axis: card border follows entityStatus, not connectivity \u2500\u2500 */
@@ -180674,6 +180685,44 @@ var CSS5 = `
180674
180685
  font:700 9px 'Nunito', system-ui, sans-serif;background:var(--cscard-unknown-bg);
180675
180686
  color:var(--cscard-muted);margin-left:4px;
180676
180687
  }
180688
+
180689
+ /* \u2500\u2500 health badge (GCDR RFC-0085): "\u25CF v3 rc14.1.24" right after the
180690
+ connectivity badge. The dot is the ::before so the pill's text stays the
180691
+ plain "v3 <firmware>" an operator scans for during a rollout; the health
180692
+ status lives in the dot colour only (healthy/degraded/unhealthy/silent). */
180693
+ .myio-cscard__health-badge{
180694
+ display:inline-flex;align-items:center;gap:4px;padding:1px 7px;border-radius:999px;
180695
+ font:800 10px 'Nunito', system-ui, sans-serif;background:var(--cscard-health-pill-bg);
180696
+ color:var(--cscard-health-pill-fg);margin-left:4px;white-space:nowrap;cursor:default;
180697
+ }
180698
+ .myio-cscard__health-badge::before{
180699
+ content:'';width:6px;height:6px;border-radius:50%;display:inline-block;flex-shrink:0;
180700
+ background:var(--cscard-health-silent);
180701
+ }
180702
+ .myio-cscard__health-badge--healthy::before{background:var(--cscard-health-ok);}
180703
+ .myio-cscard__health-badge--degraded::before{background:var(--cscard-health-warn);}
180704
+ .myio-cscard__health-badge--unhealthy::before{background:var(--cscard-health-bad);}
180705
+ .myio-cscard__health-badge--silent::before{background:var(--cscard-health-silent);}
180706
+ .myio-cscard__health-badge--silent{color:var(--cscard-muted);}
180707
+ .myio-cscard__health-mismatch{font-weight:800;margin-left:1px;}
180708
+
180709
+ /* \u2500\u2500 "Sistema" row (GCDR RFC-0085): three pills under Status \u2014 temperature
180710
+ (amber tint), uptime (blue tint), load (grey). Informational only (O-10:
180711
+ no thresholds yet), so the tints are fixed per pill, not per value. */
180712
+ .myio-cscard__system .myio-cscard__value{display:inline-flex;align-items:center;gap:4px;}
180713
+ .myio-cscard__syspill{
180714
+ display:inline-flex;align-items:center;gap:3px;padding:1px 7px;border-radius:999px;
180715
+ font:700 10px 'Nunito', system-ui, sans-serif;background:var(--cscard-health-pill-bg);
180716
+ color:var(--cscard-health-pill-fg);white-space:nowrap;cursor:default;
180717
+ }
180718
+ .myio-cscard__syspill--temperature{background:var(--cscard-warning-bg);color:var(--cscard-warning);}
180719
+ .myio-cscard__syspill--uptime{background:var(--cscard-online-bg);color:var(--cscard-online);}
180720
+ .myio-cscard__syspill--load{background:var(--cscard-unknown-bg);color:var(--cscard-unknown);}
180721
+ .myio-cscard[data-theme="dark"] .myio-cscard__syspill--temperature{color:#fbbf24;}
180722
+ .myio-cscard[data-theme="dark"] .myio-cscard__syspill--uptime{color:#93c5fd;}
180723
+ .myio-cscard[data-theme="dark"] .myio-cscard__syspill--load{color:var(--cscard-muted);}
180724
+ .myio-cscard--compact .myio-cscard__system{min-height:18px;padding:1px 0;}
180725
+ .myio-cscard--compact .myio-cscard__syspill{padding:0 6px;font-size:9.5px;}
180677
180726
  .myio-cscard__divergence-flag{
180678
180727
  display:inline-flex;align-items:center;justify-content:center;margin-left:4px;cursor:pointer;
180679
180728
  font-size:11px;line-height:1;border-radius:6px;padding:1px 3px;
@@ -181181,6 +181230,11 @@ var STALE_BADGE_TEXT = {
181181
181230
  pt: "desatualizado",
181182
181231
  en: "stale"
181183
181232
  };
181233
+ var DEFAULT_HEALTH_LABELS = {
181234
+ pt: { badge: "v3", system: "Sistema", silentSince: "sem resposta desde {when}" },
181235
+ en: { badge: "v3", system: "System", silentSince: "silent since {when}" }
181236
+ };
181237
+ var HEALTH_REGISTRY_WORD = { pt: "cadastro", en: "registry" };
181184
181238
  var LATENCY_TREND_FLAT_THRESHOLD_MS = 100;
181185
181239
  function latencyTrend(current, previous) {
181186
181240
  if (previous == null) return null;
@@ -181247,6 +181301,30 @@ function formatDuration5(ms) {
181247
181301
  const minutes = totalMin % 60;
181248
181302
  return hours > 0 ? `${hours}h${minutes}min` : `${minutes}min`;
181249
181303
  }
181304
+ function formatUptime2(seconds) {
181305
+ const totalMin = Math.max(0, Math.floor(seconds / 60));
181306
+ if (totalMin < 60) return `${totalMin}min`;
181307
+ const totalHours = Math.floor(totalMin / 60);
181308
+ if (totalHours < 24) return `${totalHours}h${String(totalMin % 60).padStart(2, "0")}`;
181309
+ const days = Math.floor(totalHours / 24);
181310
+ return `${days}d ${String(totalHours % 24).padStart(2, "0")}h`;
181311
+ }
181312
+ function formatLoad(load, language) {
181313
+ const fixed = load.toFixed(2);
181314
+ return language === "pt" ? fixed.replace(".", ",") : fixed;
181315
+ }
181316
+ function isFiniteNumber(v) {
181317
+ return typeof v === "number" && Number.isFinite(v);
181318
+ }
181319
+ function isHealthSilent(h3) {
181320
+ if (!h3.checkedAt) return false;
181321
+ const checked = Date.parse(h3.checkedAt);
181322
+ if (Number.isNaN(checked)) return false;
181323
+ if (!h3.successAt) return true;
181324
+ const success = Date.parse(h3.successAt);
181325
+ if (Number.isNaN(success)) return false;
181326
+ return checked > success;
181327
+ }
181250
181328
  var CentralStatusCard = class _CentralStatusCard {
181251
181329
  el;
181252
181330
  params;
@@ -181357,6 +181435,85 @@ var CentralStatusCard = class _CentralStatusCard {
181357
181435
  const defaults = this.language() === "en" ? DEFAULT_LABELS_EN : DEFAULT_LABELS_PT;
181358
181436
  return { ...defaults, ...this.params.labels || {} };
181359
181437
  }
181438
+ healthLabels() {
181439
+ return { ...DEFAULT_HEALTH_LABELS[this.language()], ...this.params.labels?.health || {} };
181440
+ }
181441
+ /**
181442
+ * `● v3 <firmware>` pill (GCDR RFC-0085 §5.5/§5.6) — rendered right after
181443
+ * the connectivity badge, ONLY when `support === 'SUPPORTED'`. The health
181444
+ * status lives in the dot colour (healthy/degraded/unhealthy), grey when
181445
+ * the last probe failed; the text is the firmware an operator scans for
181446
+ * during a rollout. "≠" follows the version when the registry disagrees.
181447
+ * It never touches data-connectivity / data-status, so the frame and the
181448
+ * header wash keep following their own two axes.
181449
+ */
181450
+ healthBadgeHtml(nowMs) {
181451
+ const h3 = this.params.health;
181452
+ if (!h3 || h3.support !== "SUPPORTED") return "";
181453
+ const hl = this.healthLabels();
181454
+ const lang = this.language();
181455
+ const firmware = h3.firmware ? String(h3.firmware) : "";
181456
+ const silent = isHealthSilent(h3);
181457
+ const mismatch = !!(h3.registryFirmware && firmware && h3.registryFirmware !== firmware);
181458
+ const modifier = silent ? "silent" : h3.status ? h3.status : "";
181459
+ const text2 = firmware ? `${hl.badge} ${firmware}` : hl.badge;
181460
+ const titleParts = [hl.badge];
181461
+ if (!silent && h3.status) titleParts.push(h3.status);
181462
+ if (firmware) titleParts.push(firmware);
181463
+ if (mismatch) titleParts.push(`\u2260 ${HEALTH_REGISTRY_WORD[lang]} ${h3.registryFirmware}`);
181464
+ if (silent) titleParts.push(hl.silentSince.replace("{when}", formatSince(h3.successAt, nowMs, lang)));
181465
+ const title = titleParts.join(" \xB7 ");
181466
+ return `<span class="myio-cscard__health-badge${modifier ? ` myio-cscard__health-badge--${modifier}` : ""}" data-role="health-badge" data-health-status="${escAttr6(
181467
+ silent ? "silent" : h3.status || ""
181468
+ )}" title="${escAttr6(title)}" aria-label="${escAttr6(title)}">${escAttr6(text2)}${mismatch ? ` <span class="myio-cscard__health-mismatch" aria-hidden="true">\u2260</span>` : ""}</span>`;
181469
+ }
181470
+ /**
181471
+ * "Sistema" row (GCDR RFC-0085 §5.5 mock-up verdict): the three system
181472
+ * pills got their own row under Status because, on the Status row itself,
181473
+ * they squeezed the switch and the ⓘ. Each pill is omitted when its value
181474
+ * is null; the row is omitted when `system` is null or has nothing to show.
181475
+ */
181476
+ systemRowHtml() {
181477
+ const h3 = this.params.health;
181478
+ if (!h3 || h3.support !== "SUPPORTED" || !h3.system) return "";
181479
+ const sys = h3.system;
181480
+ const lang = this.language();
181481
+ const en = lang === "en";
181482
+ const pills = [];
181483
+ if (isFiniteNumber(sys.temperatureC)) {
181484
+ const label = en ? "temperature" : "temperatura";
181485
+ pills.push(
181486
+ `<span class="myio-cscard__syspill myio-cscard__syspill--temperature" data-role="system-temperature" title="${escAttr6(
181487
+ label
181488
+ )}" aria-label="${escAttr6(`${label}: ${Math.round(sys.temperatureC)} \xB0C`)}">\u{1F321} ${Math.round(sys.temperatureC)} \xB0C</span>`
181489
+ );
181490
+ }
181491
+ if (isFiniteNumber(sys.uptimeSeconds)) {
181492
+ const label = "uptime";
181493
+ const value = formatUptime2(sys.uptimeSeconds);
181494
+ pills.push(
181495
+ `<span class="myio-cscard__syspill myio-cscard__syspill--uptime" data-role="system-uptime" title="${escAttr6(
181496
+ label
181497
+ )}" aria-label="${escAttr6(`${label}: ${value}`)}">\u23F1 ${escAttr6(value)}</span>`
181498
+ );
181499
+ }
181500
+ if (isFiniteNumber(sys.load1m)) {
181501
+ const label = en ? "load (1 min)" : "carga (1 min)";
181502
+ const value = formatLoad(sys.load1m, lang);
181503
+ pills.push(
181504
+ `<span class="myio-cscard__syspill myio-cscard__syspill--load" data-role="system-load" title="${escAttr6(
181505
+ label
181506
+ )}" aria-label="${escAttr6(`${label}: ${value}`)}">\u2699 ${escAttr6(value)}</span>`
181507
+ );
181508
+ }
181509
+ if (pills.length === 0) return "";
181510
+ const hl = this.healthLabels();
181511
+ return `<div class="myio-cscard__row myio-cscard__system">
181512
+ ${this.iconHtml("system", "\u{1F9E9}")}
181513
+ <span class="myio-cscard__label">${escAttr6(hl.system)}</span>
181514
+ <span class="myio-cscard__value">${pills.join("")}</span>
181515
+ </div>`;
181516
+ }
181360
181517
  /**
181361
181518
  * Icon markup for a decorative row icon. Icons are never the sole semantic
181362
181519
  * signal (see "Icons are decorative, not semantic") — every row still shows
@@ -181684,6 +181841,8 @@ var CentralStatusCard = class _CentralStatusCard {
181684
181841
  const probeText = probe ? `${escAttr6(probe.label)}${probe.latencyMs != null ? ` <span class="myio-cscard__muted">${probe.latencyMs}ms</span>${latencyTrendHtml}` : ""}` : null;
181685
181842
  const statusChecked = p.entityStatus === "ACTIVE";
181686
181843
  const statusDisabled = this.statusBusy || !!p.statusReadonly;
181844
+ const healthBadgeHtml = this.healthBadgeHtml(nowMs);
181845
+ const systemRowHtml = this.systemRowHtml();
181687
181846
  const compactEvidenceLine = variant === "compact" ? `<div class="myio-cscard__evidence-line">${devicesText ? escAttr6(devicesText) : ""}${probeText ? (devicesText ? " \xB7 " : "") + probeText : ""}</div>` : "";
181688
181847
  this.el.innerHTML = `
181689
181848
  ${alarmBadgeHtml}
@@ -181704,7 +181863,7 @@ var CentralStatusCard = class _CentralStatusCard {
181704
181863
  <span class="myio-cscard__label">${escAttr6(l.connectivity)}</span>
181705
181864
  <span class="myio-cscard__badge myio-cscard__badge--${connectivity}" role="status">${escAttr6(
181706
181865
  connLabel
181707
- )}</span>${staleBadge}${divergenceFlagHtml}
181866
+ )}</span>${healthBadgeHtml}${staleBadge}${divergenceFlagHtml}
181708
181867
  </div>
181709
181868
 
181710
181869
  <div class="myio-cscard__row myio-cscard__monitoring">
@@ -181757,6 +181916,7 @@ var CentralStatusCard = class _CentralStatusCard {
181757
181916
  )}</span>
181758
181917
  ${this.statusError ? `<span class="myio-cscard__err" role="alert" aria-live="assertive">${escAttr6(this.statusError)}</span>` : `<span class="myio-cscard__err" role="alert" aria-live="assertive" hidden></span>`}
181759
181918
  </div>
181919
+ ${systemRowHtml}
181760
181920
  </section>
181761
181921
  </div>
181762
181922
  </div>
package/dist/index.d.cts CHANGED
@@ -29731,6 +29731,47 @@ interface CentralDivergence {
29731
29731
  /** Worker-proposed status. */
29732
29732
  proposed: string;
29733
29733
  }
29734
+ /** `health_support` of GCDR RFC-0085 — whether the central answers `/v3/health`. */
29735
+ type CentralHealthSupport = 'SUPPORTED' | 'UNSUPPORTED' | 'UNREACHABLE' | 'UNKNOWN';
29736
+ /** `status` of the `/v3/health` body — drives the dot colour of the v3 badge. */
29737
+ type CentralHealthStatus = 'healthy' | 'degraded' | 'unhealthy';
29738
+ /** `system.*` of the last health snapshot — the three "Sistema" pills. */
29739
+ interface CentralHealthSystem {
29740
+ /** SoC temperature in °C — rendered as an integer, e.g. "63 °C". */
29741
+ temperatureC?: number | null;
29742
+ /** Seconds since boot — rendered as "12min" / "15h48" / "3d 02h". */
29743
+ uptimeSeconds?: number | null;
29744
+ /** 1-minute load average — two decimals in the card's locale ("0,83" pt / "0.83" en). */
29745
+ load1m?: number | null;
29746
+ }
29747
+ /**
29748
+ * Health probe of GCDR RFC-0085 (amendment to RFC-0231). Nothing is rendered
29749
+ * unless `support === 'SUPPORTED'` — absence IS the signal: on a list of
29750
+ * cards, "the ones with a second badge are on the new build". The badge
29751
+ * never colours the card frame or the header (those are the two existing
29752
+ * axes: border = entityStatus, header wash + badge = connectivity).
29753
+ */
29754
+ interface CentralHealthInfo {
29755
+ support: CentralHealthSupport;
29756
+ /** Dot colour: green `healthy`, amber `degraded`, red `unhealthy`. */
29757
+ status?: CentralHealthStatus | null;
29758
+ /** Firmware reported by the central — badge text "v3 rc14.1.24" (just "v3" when null). */
29759
+ firmware?: string | null;
29760
+ /** Firmware of the registry — when set and different from `firmware`, a "≠" follows the version and both go in the title. */
29761
+ registryFirmware?: string | null;
29762
+ /** ISO — last probe attempt. */
29763
+ checkedAt?: string | null;
29764
+ /** ISO — last OK probe. `checkedAt` later than `successAt` = last probe failed → grey dot + "silent since" title. */
29765
+ successAt?: string | null;
29766
+ /** "Sistema" row under Status; hidden when null. */
29767
+ system?: CentralHealthSystem | null;
29768
+ }
29769
+ /** i18n of the health badge + "Sistema" row. `{when}` is interpolated in `silentSince`. */
29770
+ interface CentralStatusCardHealthLabels {
29771
+ badge?: string;
29772
+ system?: string;
29773
+ silentSince?: string;
29774
+ }
29734
29775
  /**
29735
29776
  * Worker/history vocabulary (`orchestrator_devices_status_history`) —
29736
29777
  * DELIBERATELY NOT the same union as `CentralConnectivity` (ONLINE/OFFLINE/
@@ -29858,6 +29899,7 @@ interface CentralStatusCardLabels {
29858
29899
  reportButton?: string;
29859
29900
  settingsButton?: string;
29860
29901
  selectCheckbox?: string;
29902
+ health?: CentralStatusCardHealthLabels;
29861
29903
  }
29862
29904
  /**
29863
29905
  * Event passed to onMonitoringToggle. `next` is the requested state, `previous`
@@ -29960,6 +30002,13 @@ interface CreateCentralStatusCardParams {
29960
30002
  showDivergence?: boolean;
29961
30003
  /** Show the 🔄 force-sync button (default: false; cockpit passes true). */
29962
30004
  showForceSync?: boolean;
30005
+ /**
30006
+ * Health probe of GCDR RFC-0085: `● v3 <firmware>` badge next to the
30007
+ * connectivity badge + a "Sistema" row (🌡 temp · ⏱ uptime · ⚙ load) right
30008
+ * under Status. Rendered ONLY when `support === 'SUPPORTED'`; omit (or pass
30009
+ * any other `support`) to keep today's look. Never colours the frame.
30010
+ */
30011
+ health?: CentralHealthInfo | null;
29963
30012
  /**
29964
30013
  * Wires the 📈 timeline button next to Monitoramento — opens a modal with a
29965
30014
  * period selector (24h/7d/30d/90d), a stacked connectivity bar, and the raw
@@ -29991,7 +30040,7 @@ interface CreateCentralStatusCardParams {
29991
30040
  * are NEVER the sole semantic signal (see Accessibility / "icons are
29992
30041
  * decorative"). Omit to use the theme defaults; pass `false`/'' to render none.
29993
30042
  */
29994
- icons?: Partial<Record<'connectivity' | 'monitoring' | 'status' | 'forceSync' | 'lastAttempt' | 'lastSuccess' | 'probe' | 'devices' | 'divergence' | 'timeline' | 'dashboard' | 'report' | 'settings', string | HTMLElement | false>>;
30043
+ icons?: Partial<Record<'connectivity' | 'monitoring' | 'status' | 'forceSync' | 'lastAttempt' | 'lastSuccess' | 'probe' | 'devices' | 'divergence' | 'timeline' | 'dashboard' | 'report' | 'settings' | 'system', string | HTMLElement | false>>;
29995
30044
  /** Persist the Monitoramento flag (boolean: next = true means monitoring ON). */
29996
30045
  onMonitoringToggle?: (e: CentralMonitoringToggleEvent) => Promise<void>;
29997
30046
  /** Persist the Status flag ('ACTIVE' | 'INACTIVE' string union — never a boolean). */
package/dist/index.d.ts CHANGED
@@ -29731,6 +29731,47 @@ interface CentralDivergence {
29731
29731
  /** Worker-proposed status. */
29732
29732
  proposed: string;
29733
29733
  }
29734
+ /** `health_support` of GCDR RFC-0085 — whether the central answers `/v3/health`. */
29735
+ type CentralHealthSupport = 'SUPPORTED' | 'UNSUPPORTED' | 'UNREACHABLE' | 'UNKNOWN';
29736
+ /** `status` of the `/v3/health` body — drives the dot colour of the v3 badge. */
29737
+ type CentralHealthStatus = 'healthy' | 'degraded' | 'unhealthy';
29738
+ /** `system.*` of the last health snapshot — the three "Sistema" pills. */
29739
+ interface CentralHealthSystem {
29740
+ /** SoC temperature in °C — rendered as an integer, e.g. "63 °C". */
29741
+ temperatureC?: number | null;
29742
+ /** Seconds since boot — rendered as "12min" / "15h48" / "3d 02h". */
29743
+ uptimeSeconds?: number | null;
29744
+ /** 1-minute load average — two decimals in the card's locale ("0,83" pt / "0.83" en). */
29745
+ load1m?: number | null;
29746
+ }
29747
+ /**
29748
+ * Health probe of GCDR RFC-0085 (amendment to RFC-0231). Nothing is rendered
29749
+ * unless `support === 'SUPPORTED'` — absence IS the signal: on a list of
29750
+ * cards, "the ones with a second badge are on the new build". The badge
29751
+ * never colours the card frame or the header (those are the two existing
29752
+ * axes: border = entityStatus, header wash + badge = connectivity).
29753
+ */
29754
+ interface CentralHealthInfo {
29755
+ support: CentralHealthSupport;
29756
+ /** Dot colour: green `healthy`, amber `degraded`, red `unhealthy`. */
29757
+ status?: CentralHealthStatus | null;
29758
+ /** Firmware reported by the central — badge text "v3 rc14.1.24" (just "v3" when null). */
29759
+ firmware?: string | null;
29760
+ /** Firmware of the registry — when set and different from `firmware`, a "≠" follows the version and both go in the title. */
29761
+ registryFirmware?: string | null;
29762
+ /** ISO — last probe attempt. */
29763
+ checkedAt?: string | null;
29764
+ /** ISO — last OK probe. `checkedAt` later than `successAt` = last probe failed → grey dot + "silent since" title. */
29765
+ successAt?: string | null;
29766
+ /** "Sistema" row under Status; hidden when null. */
29767
+ system?: CentralHealthSystem | null;
29768
+ }
29769
+ /** i18n of the health badge + "Sistema" row. `{when}` is interpolated in `silentSince`. */
29770
+ interface CentralStatusCardHealthLabels {
29771
+ badge?: string;
29772
+ system?: string;
29773
+ silentSince?: string;
29774
+ }
29734
29775
  /**
29735
29776
  * Worker/history vocabulary (`orchestrator_devices_status_history`) —
29736
29777
  * DELIBERATELY NOT the same union as `CentralConnectivity` (ONLINE/OFFLINE/
@@ -29858,6 +29899,7 @@ interface CentralStatusCardLabels {
29858
29899
  reportButton?: string;
29859
29900
  settingsButton?: string;
29860
29901
  selectCheckbox?: string;
29902
+ health?: CentralStatusCardHealthLabels;
29861
29903
  }
29862
29904
  /**
29863
29905
  * Event passed to onMonitoringToggle. `next` is the requested state, `previous`
@@ -29960,6 +30002,13 @@ interface CreateCentralStatusCardParams {
29960
30002
  showDivergence?: boolean;
29961
30003
  /** Show the 🔄 force-sync button (default: false; cockpit passes true). */
29962
30004
  showForceSync?: boolean;
30005
+ /**
30006
+ * Health probe of GCDR RFC-0085: `● v3 <firmware>` badge next to the
30007
+ * connectivity badge + a "Sistema" row (🌡 temp · ⏱ uptime · ⚙ load) right
30008
+ * under Status. Rendered ONLY when `support === 'SUPPORTED'`; omit (or pass
30009
+ * any other `support`) to keep today's look. Never colours the frame.
30010
+ */
30011
+ health?: CentralHealthInfo | null;
29963
30012
  /**
29964
30013
  * Wires the 📈 timeline button next to Monitoramento — opens a modal with a
29965
30014
  * period selector (24h/7d/30d/90d), a stacked connectivity bar, and the raw
@@ -29991,7 +30040,7 @@ interface CreateCentralStatusCardParams {
29991
30040
  * are NEVER the sole semantic signal (see Accessibility / "icons are
29992
30041
  * decorative"). Omit to use the theme defaults; pass `false`/'' to render none.
29993
30042
  */
29994
- icons?: Partial<Record<'connectivity' | 'monitoring' | 'status' | 'forceSync' | 'lastAttempt' | 'lastSuccess' | 'probe' | 'devices' | 'divergence' | 'timeline' | 'dashboard' | 'report' | 'settings', string | HTMLElement | false>>;
30043
+ icons?: Partial<Record<'connectivity' | 'monitoring' | 'status' | 'forceSync' | 'lastAttempt' | 'lastSuccess' | 'probe' | 'devices' | 'divergence' | 'timeline' | 'dashboard' | 'report' | 'settings' | 'system', string | HTMLElement | false>>;
29995
30044
  /** Persist the Monitoramento flag (boolean: next = true means monitoring ON). */
29996
30045
  onMonitoringToggle?: (e: CentralMonitoringToggleEvent) => Promise<void>;
29997
30046
  /** Persist the Status flag ('ACTIVE' | 'INACTIVE' string union — never a boolean). */
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.591",
13
+ version: "0.1.593",
14
14
  description: "A clean, standalone JS SDK for MYIO projects",
15
15
  license: "MIT",
16
16
  repository: "github:gh-myio/myio-js-library",
@@ -177584,6 +177584,15 @@ var CSS5 = `
177584
177584
  --cscard-switch-on:#2563eb;
177585
177585
  --cscard-danger:#dc2626;
177586
177586
  --cscard-select-ring:#7c3aed;
177587
+ /* health axis (GCDR RFC-0085) \u2014 ONLY the dot of the v3 badge and the
177588
+ "Sistema" pills. Deliberately never the border or the header wash:
177589
+ those two already belong to entityStatus and connectivity. */
177590
+ --cscard-health-ok:#22c55e;
177591
+ --cscard-health-warn:#f59e0b;
177592
+ --cscard-health-bad:#ef4444;
177593
+ --cscard-health-silent:#94a3b8;
177594
+ --cscard-health-pill-bg:#f1f5f9;
177595
+ --cscard-health-pill-fg:#334155;
177587
177596
  box-sizing:border-box;
177588
177597
  position:relative;
177589
177598
  display:flex;flex-direction:row;
@@ -177622,6 +177631,8 @@ var CSS5 = `
177622
177631
  --cscard-border-active-glow:rgba(34,197,94,.4);
177623
177632
  --cscard-border-inactive:#475569;
177624
177633
  --cscard-switch-off:#475569;
177634
+ --cscard-health-pill-bg:#1e2d45;
177635
+ --cscard-health-pill-fg:#cbd5e1;
177625
177636
  }
177626
177637
 
177627
177638
  /* \u2500\u2500 registry axis: card border follows entityStatus, not connectivity \u2500\u2500 */
@@ -177701,6 +177712,44 @@ var CSS5 = `
177701
177712
  font:700 9px 'Nunito', system-ui, sans-serif;background:var(--cscard-unknown-bg);
177702
177713
  color:var(--cscard-muted);margin-left:4px;
177703
177714
  }
177715
+
177716
+ /* \u2500\u2500 health badge (GCDR RFC-0085): "\u25CF v3 rc14.1.24" right after the
177717
+ connectivity badge. The dot is the ::before so the pill's text stays the
177718
+ plain "v3 <firmware>" an operator scans for during a rollout; the health
177719
+ status lives in the dot colour only (healthy/degraded/unhealthy/silent). */
177720
+ .myio-cscard__health-badge{
177721
+ display:inline-flex;align-items:center;gap:4px;padding:1px 7px;border-radius:999px;
177722
+ font:800 10px 'Nunito', system-ui, sans-serif;background:var(--cscard-health-pill-bg);
177723
+ color:var(--cscard-health-pill-fg);margin-left:4px;white-space:nowrap;cursor:default;
177724
+ }
177725
+ .myio-cscard__health-badge::before{
177726
+ content:'';width:6px;height:6px;border-radius:50%;display:inline-block;flex-shrink:0;
177727
+ background:var(--cscard-health-silent);
177728
+ }
177729
+ .myio-cscard__health-badge--healthy::before{background:var(--cscard-health-ok);}
177730
+ .myio-cscard__health-badge--degraded::before{background:var(--cscard-health-warn);}
177731
+ .myio-cscard__health-badge--unhealthy::before{background:var(--cscard-health-bad);}
177732
+ .myio-cscard__health-badge--silent::before{background:var(--cscard-health-silent);}
177733
+ .myio-cscard__health-badge--silent{color:var(--cscard-muted);}
177734
+ .myio-cscard__health-mismatch{font-weight:800;margin-left:1px;}
177735
+
177736
+ /* \u2500\u2500 "Sistema" row (GCDR RFC-0085): three pills under Status \u2014 temperature
177737
+ (amber tint), uptime (blue tint), load (grey). Informational only (O-10:
177738
+ no thresholds yet), so the tints are fixed per pill, not per value. */
177739
+ .myio-cscard__system .myio-cscard__value{display:inline-flex;align-items:center;gap:4px;}
177740
+ .myio-cscard__syspill{
177741
+ display:inline-flex;align-items:center;gap:3px;padding:1px 7px;border-radius:999px;
177742
+ font:700 10px 'Nunito', system-ui, sans-serif;background:var(--cscard-health-pill-bg);
177743
+ color:var(--cscard-health-pill-fg);white-space:nowrap;cursor:default;
177744
+ }
177745
+ .myio-cscard__syspill--temperature{background:var(--cscard-warning-bg);color:var(--cscard-warning);}
177746
+ .myio-cscard__syspill--uptime{background:var(--cscard-online-bg);color:var(--cscard-online);}
177747
+ .myio-cscard__syspill--load{background:var(--cscard-unknown-bg);color:var(--cscard-unknown);}
177748
+ .myio-cscard[data-theme="dark"] .myio-cscard__syspill--temperature{color:#fbbf24;}
177749
+ .myio-cscard[data-theme="dark"] .myio-cscard__syspill--uptime{color:#93c5fd;}
177750
+ .myio-cscard[data-theme="dark"] .myio-cscard__syspill--load{color:var(--cscard-muted);}
177751
+ .myio-cscard--compact .myio-cscard__system{min-height:18px;padding:1px 0;}
177752
+ .myio-cscard--compact .myio-cscard__syspill{padding:0 6px;font-size:9.5px;}
177704
177753
  .myio-cscard__divergence-flag{
177705
177754
  display:inline-flex;align-items:center;justify-content:center;margin-left:4px;cursor:pointer;
177706
177755
  font-size:11px;line-height:1;border-radius:6px;padding:1px 3px;
@@ -178208,6 +178257,11 @@ var STALE_BADGE_TEXT = {
178208
178257
  pt: "desatualizado",
178209
178258
  en: "stale"
178210
178259
  };
178260
+ var DEFAULT_HEALTH_LABELS = {
178261
+ pt: { badge: "v3", system: "Sistema", silentSince: "sem resposta desde {when}" },
178262
+ en: { badge: "v3", system: "System", silentSince: "silent since {when}" }
178263
+ };
178264
+ var HEALTH_REGISTRY_WORD = { pt: "cadastro", en: "registry" };
178211
178265
  var LATENCY_TREND_FLAT_THRESHOLD_MS = 100;
178212
178266
  function latencyTrend(current, previous) {
178213
178267
  if (previous == null) return null;
@@ -178274,6 +178328,30 @@ function formatDuration5(ms) {
178274
178328
  const minutes = totalMin % 60;
178275
178329
  return hours > 0 ? `${hours}h${minutes}min` : `${minutes}min`;
178276
178330
  }
178331
+ function formatUptime2(seconds) {
178332
+ const totalMin = Math.max(0, Math.floor(seconds / 60));
178333
+ if (totalMin < 60) return `${totalMin}min`;
178334
+ const totalHours = Math.floor(totalMin / 60);
178335
+ if (totalHours < 24) return `${totalHours}h${String(totalMin % 60).padStart(2, "0")}`;
178336
+ const days = Math.floor(totalHours / 24);
178337
+ return `${days}d ${String(totalHours % 24).padStart(2, "0")}h`;
178338
+ }
178339
+ function formatLoad(load, language) {
178340
+ const fixed = load.toFixed(2);
178341
+ return language === "pt" ? fixed.replace(".", ",") : fixed;
178342
+ }
178343
+ function isFiniteNumber(v) {
178344
+ return typeof v === "number" && Number.isFinite(v);
178345
+ }
178346
+ function isHealthSilent(h3) {
178347
+ if (!h3.checkedAt) return false;
178348
+ const checked = Date.parse(h3.checkedAt);
178349
+ if (Number.isNaN(checked)) return false;
178350
+ if (!h3.successAt) return true;
178351
+ const success = Date.parse(h3.successAt);
178352
+ if (Number.isNaN(success)) return false;
178353
+ return checked > success;
178354
+ }
178277
178355
  var CentralStatusCard = class _CentralStatusCard {
178278
178356
  el;
178279
178357
  params;
@@ -178384,6 +178462,85 @@ var CentralStatusCard = class _CentralStatusCard {
178384
178462
  const defaults = this.language() === "en" ? DEFAULT_LABELS_EN : DEFAULT_LABELS_PT;
178385
178463
  return { ...defaults, ...this.params.labels || {} };
178386
178464
  }
178465
+ healthLabels() {
178466
+ return { ...DEFAULT_HEALTH_LABELS[this.language()], ...this.params.labels?.health || {} };
178467
+ }
178468
+ /**
178469
+ * `● v3 <firmware>` pill (GCDR RFC-0085 §5.5/§5.6) — rendered right after
178470
+ * the connectivity badge, ONLY when `support === 'SUPPORTED'`. The health
178471
+ * status lives in the dot colour (healthy/degraded/unhealthy), grey when
178472
+ * the last probe failed; the text is the firmware an operator scans for
178473
+ * during a rollout. "≠" follows the version when the registry disagrees.
178474
+ * It never touches data-connectivity / data-status, so the frame and the
178475
+ * header wash keep following their own two axes.
178476
+ */
178477
+ healthBadgeHtml(nowMs) {
178478
+ const h3 = this.params.health;
178479
+ if (!h3 || h3.support !== "SUPPORTED") return "";
178480
+ const hl = this.healthLabels();
178481
+ const lang = this.language();
178482
+ const firmware = h3.firmware ? String(h3.firmware) : "";
178483
+ const silent = isHealthSilent(h3);
178484
+ const mismatch = !!(h3.registryFirmware && firmware && h3.registryFirmware !== firmware);
178485
+ const modifier = silent ? "silent" : h3.status ? h3.status : "";
178486
+ const text2 = firmware ? `${hl.badge} ${firmware}` : hl.badge;
178487
+ const titleParts = [hl.badge];
178488
+ if (!silent && h3.status) titleParts.push(h3.status);
178489
+ if (firmware) titleParts.push(firmware);
178490
+ if (mismatch) titleParts.push(`\u2260 ${HEALTH_REGISTRY_WORD[lang]} ${h3.registryFirmware}`);
178491
+ if (silent) titleParts.push(hl.silentSince.replace("{when}", formatSince(h3.successAt, nowMs, lang)));
178492
+ const title = titleParts.join(" \xB7 ");
178493
+ return `<span class="myio-cscard__health-badge${modifier ? ` myio-cscard__health-badge--${modifier}` : ""}" data-role="health-badge" data-health-status="${escAttr6(
178494
+ silent ? "silent" : h3.status || ""
178495
+ )}" title="${escAttr6(title)}" aria-label="${escAttr6(title)}">${escAttr6(text2)}${mismatch ? ` <span class="myio-cscard__health-mismatch" aria-hidden="true">\u2260</span>` : ""}</span>`;
178496
+ }
178497
+ /**
178498
+ * "Sistema" row (GCDR RFC-0085 §5.5 mock-up verdict): the three system
178499
+ * pills got their own row under Status because, on the Status row itself,
178500
+ * they squeezed the switch and the ⓘ. Each pill is omitted when its value
178501
+ * is null; the row is omitted when `system` is null or has nothing to show.
178502
+ */
178503
+ systemRowHtml() {
178504
+ const h3 = this.params.health;
178505
+ if (!h3 || h3.support !== "SUPPORTED" || !h3.system) return "";
178506
+ const sys = h3.system;
178507
+ const lang = this.language();
178508
+ const en = lang === "en";
178509
+ const pills = [];
178510
+ if (isFiniteNumber(sys.temperatureC)) {
178511
+ const label = en ? "temperature" : "temperatura";
178512
+ pills.push(
178513
+ `<span class="myio-cscard__syspill myio-cscard__syspill--temperature" data-role="system-temperature" title="${escAttr6(
178514
+ label
178515
+ )}" aria-label="${escAttr6(`${label}: ${Math.round(sys.temperatureC)} \xB0C`)}">\u{1F321} ${Math.round(sys.temperatureC)} \xB0C</span>`
178516
+ );
178517
+ }
178518
+ if (isFiniteNumber(sys.uptimeSeconds)) {
178519
+ const label = "uptime";
178520
+ const value = formatUptime2(sys.uptimeSeconds);
178521
+ pills.push(
178522
+ `<span class="myio-cscard__syspill myio-cscard__syspill--uptime" data-role="system-uptime" title="${escAttr6(
178523
+ label
178524
+ )}" aria-label="${escAttr6(`${label}: ${value}`)}">\u23F1 ${escAttr6(value)}</span>`
178525
+ );
178526
+ }
178527
+ if (isFiniteNumber(sys.load1m)) {
178528
+ const label = en ? "load (1 min)" : "carga (1 min)";
178529
+ const value = formatLoad(sys.load1m, lang);
178530
+ pills.push(
178531
+ `<span class="myio-cscard__syspill myio-cscard__syspill--load" data-role="system-load" title="${escAttr6(
178532
+ label
178533
+ )}" aria-label="${escAttr6(`${label}: ${value}`)}">\u2699 ${escAttr6(value)}</span>`
178534
+ );
178535
+ }
178536
+ if (pills.length === 0) return "";
178537
+ const hl = this.healthLabels();
178538
+ return `<div class="myio-cscard__row myio-cscard__system">
178539
+ ${this.iconHtml("system", "\u{1F9E9}")}
178540
+ <span class="myio-cscard__label">${escAttr6(hl.system)}</span>
178541
+ <span class="myio-cscard__value">${pills.join("")}</span>
178542
+ </div>`;
178543
+ }
178387
178544
  /**
178388
178545
  * Icon markup for a decorative row icon. Icons are never the sole semantic
178389
178546
  * signal (see "Icons are decorative, not semantic") — every row still shows
@@ -178711,6 +178868,8 @@ var CentralStatusCard = class _CentralStatusCard {
178711
178868
  const probeText = probe ? `${escAttr6(probe.label)}${probe.latencyMs != null ? ` <span class="myio-cscard__muted">${probe.latencyMs}ms</span>${latencyTrendHtml}` : ""}` : null;
178712
178869
  const statusChecked = p.entityStatus === "ACTIVE";
178713
178870
  const statusDisabled = this.statusBusy || !!p.statusReadonly;
178871
+ const healthBadgeHtml = this.healthBadgeHtml(nowMs);
178872
+ const systemRowHtml = this.systemRowHtml();
178714
178873
  const compactEvidenceLine = variant === "compact" ? `<div class="myio-cscard__evidence-line">${devicesText ? escAttr6(devicesText) : ""}${probeText ? (devicesText ? " \xB7 " : "") + probeText : ""}</div>` : "";
178715
178874
  this.el.innerHTML = `
178716
178875
  ${alarmBadgeHtml}
@@ -178731,7 +178890,7 @@ var CentralStatusCard = class _CentralStatusCard {
178731
178890
  <span class="myio-cscard__label">${escAttr6(l.connectivity)}</span>
178732
178891
  <span class="myio-cscard__badge myio-cscard__badge--${connectivity}" role="status">${escAttr6(
178733
178892
  connLabel
178734
- )}</span>${staleBadge}${divergenceFlagHtml}
178893
+ )}</span>${healthBadgeHtml}${staleBadge}${divergenceFlagHtml}
178735
178894
  </div>
178736
178895
 
178737
178896
  <div class="myio-cscard__row myio-cscard__monitoring">
@@ -178784,6 +178943,7 @@ var CentralStatusCard = class _CentralStatusCard {
178784
178943
  )}</span>
178785
178944
  ${this.statusError ? `<span class="myio-cscard__err" role="alert" aria-live="assertive">${escAttr6(this.statusError)}</span>` : `<span class="myio-cscard__err" role="alert" aria-live="assertive" hidden></span>`}
178786
178945
  </div>
178946
+ ${systemRowHtml}
178787
178947
  </section>
178788
178948
  </div>
178789
178949
  </div>