@lunora/studio 1.0.0-alpha.94 → 1.0.0-alpha.96

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.
Files changed (163) hide show
  1. package/dist/index.d.ts +5 -5
  2. package/dist/index.js +1 -1
  3. package/dist/mount.d.ts +2 -2
  4. package/dist/mount.js +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +1 -1
  7. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
  8. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  9. package/dist/packem_chunks/FileBrowser.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  17. package/dist/packem_chunks/SchemaViewer.js +1 -1
  18. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  19. package/dist/packem_chunks/SettingsPanel.js +1 -1
  20. package/dist/packem_chunks/SqlEditorPanel.js +6 -6
  21. package/dist/packem_chunks/TableEditor.js +1 -1
  22. package/dist/packem_chunks/agents-panel.js +1 -1
  23. package/dist/packem_chunks/analytics-panel.js +1 -1
  24. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  25. package/dist/packem_chunks/auth-config-panel.js +1 -1
  26. package/dist/packem_chunks/auth-sessions-panel.js +1 -1
  27. package/dist/packem_chunks/containers-panel.js +1 -1
  28. package/dist/packem_chunks/dashboards-panel.js +1 -1
  29. package/dist/packem_chunks/fanout-panel.js +1 -1
  30. package/dist/packem_chunks/flags-panel.js +1 -1
  31. package/dist/packem_chunks/issues-panel.js +1 -1
  32. package/dist/packem_chunks/kv-browser.js +1 -1
  33. package/dist/packem_chunks/log-drains-panel.js +2 -2
  34. package/dist/packem_chunks/migrations-route.js +1 -1
  35. package/dist/packem_chunks/organizations-panel.js +1 -1
  36. package/dist/packem_chunks/payments-panel.js +1 -1
  37. package/dist/packem_chunks/permissions-panel.js +1 -1
  38. package/dist/packem_chunks/queues-panel.js +1 -1
  39. package/dist/packem_chunks/rls-panel.js +1 -1
  40. package/dist/packem_chunks/schedule-panel.js +1 -1
  41. package/dist/packem_chunks/sparkline.js +1 -1
  42. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  43. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  44. package/dist/packem_chunks/sync-client-panel.js +1 -1
  45. package/dist/packem_chunks/traces-panel.js +1 -1
  46. package/dist/packem_chunks/users-panel.js +1 -1
  47. package/dist/packem_chunks/vector-browser.js +1 -1
  48. package/dist/packem_chunks/workflows-panel.js +1 -1
  49. package/dist/packem_shared/{DataBrowser-H4oUFkPJ.js → DataBrowser-CPNKM0KZ.js} +1 -1
  50. package/dist/packem_shared/{GlobalDataBrowser-CeA8bDjX.js → GlobalDataBrowser-BSmyOO0n.js} +1 -1
  51. package/dist/packem_shared/{HomePanel-DLP1nQdC.js → HomePanel-BUO6BcYQ.js} +1 -1
  52. package/dist/packem_shared/{MigrationsPanel-dm_M75mR.js → MigrationsPanel-BAnvY79E.js} +1 -1
  53. package/dist/packem_shared/{ScheduledJobs-DDJG9Je7.js → ScheduledJobs-pHVlh2xU.js} +1 -1
  54. package/dist/packem_shared/{Studio-BYg65qWq.js → Studio-DG_n-8Pc.js} +1 -1
  55. package/dist/packem_shared/{StudioApp-D0UOg0a_.js → StudioApp-bavavhpe.js} +1 -1
  56. package/dist/packem_shared/advisor-view-CGcwvlMo.js +1 -0
  57. package/dist/packem_shared/{app.d-DW7yZsfu.d.ts → app.d-D1bPR8FO.d.ts} +8 -8
  58. package/dist/packem_shared/bar-chart-B8oDHgnw.js +6 -0
  59. package/dist/packem_shared/{card-CIDGUN6K.js → card-BMKx5UdA.js} +1 -1
  60. package/dist/packem_shared/{dropdown-menu-C3RQ_HlW.js → dropdown-menu-BgS2zw1i.js} +1 -1
  61. package/dist/packem_shared/error-alert-_2q2VtVG.js +1 -0
  62. package/dist/packem_shared/{grid-features-Db_BNYRo.js → grid-features-Y2YSjhCf.js} +2 -2
  63. package/dist/packem_shared/home-panel-Ir3YHReO.js +3 -0
  64. package/dist/packem_shared/result-chart-0VgP_3FP.js +1 -0
  65. package/dist/packem_shared/schema-diagram-GVgnLWTf.js +2 -0
  66. package/dist/packem_shared/{select-Bul-DeII.js → select-BssZMiFY.js} +1 -1
  67. package/dist/packem_shared/{sparkline-CgjeUU2I.js → sparkline-BNvxiJj_.js} +1 -1
  68. package/dist/packem_shared/{stat-card-fm_TF1mo.js → stat-card-BGJdhfm6.js} +1 -1
  69. package/dist/packem_shared/studio-C9Qvg13j.js +2 -0
  70. package/dist/packem_shared/{table-DdJBrClo.js → table-DZAB8cs3.js} +1 -1
  71. package/dist/packem_shared/{trace-handoff-Dw7mwjxu.js → trace-handoff-CuZ6WGgo.js} +1 -1
  72. package/dist/packem_shared/use-async-submit-B32whHJO.js +1 -0
  73. package/dist/standalone/{chunk-TITX6XEA.js → chunk-2FRLB5SB.js} +1 -1
  74. package/dist/standalone/chunk-2IFGRS6R.js +1 -0
  75. package/dist/standalone/{chunk-DBMFI2HC.js → chunk-2NO45MRI.js} +1 -1
  76. package/dist/standalone/{chunk-D62SDRMM.js → chunk-2YGNOZPZ.js} +1 -1
  77. package/dist/standalone/{chunk-UIGAA3GV.js → chunk-34WN3PEC.js} +1 -1
  78. package/dist/standalone/{chunk-ZVAGD3FT.js → chunk-3PXUIMP2.js} +1 -1
  79. package/dist/standalone/chunk-3SCGCJYS.js +1 -0
  80. package/dist/standalone/{chunk-465RIA2L.js → chunk-3WISGFZ7.js} +1 -1
  81. package/dist/standalone/{chunk-2OUIHY7G.js → chunk-44T6NSYY.js} +1 -1
  82. package/dist/standalone/{chunk-IBVBIKUI.js → chunk-57BUSXRD.js} +1 -1
  83. package/dist/standalone/{chunk-3FIN5PH4.js → chunk-6V27P65N.js} +2 -2
  84. package/dist/standalone/{chunk-OM36OEHZ.js → chunk-7KU3LR7G.js} +1 -1
  85. package/dist/standalone/{chunk-G6GX5TVB.js → chunk-7URLLMST.js} +1 -1
  86. package/dist/standalone/{chunk-RNOSWEMO.js → chunk-AB5WGAX6.js} +2 -2
  87. package/dist/standalone/{chunk-M7AWSDGY.js → chunk-AQZMKZMP.js} +1 -1
  88. package/dist/standalone/{chunk-VVNQP4CI.js → chunk-AUXEGD24.js} +1 -1
  89. package/dist/standalone/{chunk-JYLYJT27.js → chunk-BAJXBWFJ.js} +5 -5
  90. package/dist/standalone/{chunk-SCKKQIAE.js → chunk-BLJANR7J.js} +1 -1
  91. package/dist/standalone/{chunk-5TDGHWYU.js → chunk-BMYWOK5Q.js} +1 -1
  92. package/dist/standalone/{chunk-SKYFKPJC.js → chunk-CFXL7MQK.js} +1 -1
  93. package/dist/standalone/chunk-CZZWYUTR.js +1 -0
  94. package/dist/standalone/{chunk-QNHU4SKL.js → chunk-D7B2KFWM.js} +1 -1
  95. package/dist/standalone/{chunk-O3UMJLO3.js → chunk-DGO2XJOT.js} +1 -1
  96. package/dist/standalone/{chunk-2T22UR7E.js → chunk-DXJWFZFI.js} +1 -1
  97. package/dist/standalone/{chunk-QXECM52Z.js → chunk-E2C6CK7F.js} +1 -1
  98. package/dist/standalone/{chunk-PGVJE5F5.js → chunk-ECF57FQF.js} +1 -1
  99. package/dist/standalone/{chunk-BN4CIAXU.js → chunk-ESIEIGR3.js} +1 -1
  100. package/dist/standalone/chunk-ETU7KIO4.js +11 -0
  101. package/dist/standalone/{chunk-6K46XGR5.js → chunk-EYIEO5QZ.js} +1 -1
  102. package/dist/standalone/chunk-FA6AR5QU.js +1 -0
  103. package/dist/standalone/chunk-GL7YL3VF.js +1 -0
  104. package/dist/standalone/{chunk-LZKU262J.js → chunk-HJC67CE4.js} +1 -1
  105. package/dist/standalone/{chunk-WI4XINU2.js → chunk-I7FF5IIJ.js} +1 -1
  106. package/dist/standalone/{chunk-PE7TI4TQ.js → chunk-IGBUUFPN.js} +1 -1
  107. package/dist/standalone/{chunk-Z4AX76YZ.js → chunk-J4POSI6T.js} +1 -1
  108. package/dist/standalone/{chunk-A3DBEJLO.js → chunk-JRAUQ4L2.js} +1 -1
  109. package/dist/standalone/{chunk-3KXDX76D.js → chunk-KGPNIBOV.js} +1 -1
  110. package/dist/standalone/{chunk-4LCY5XUR.js → chunk-LT236J7E.js} +1 -1
  111. package/dist/standalone/{chunk-AQ4JNJF3.js → chunk-LV5UVTHL.js} +1 -1
  112. package/dist/standalone/{chunk-KEVIGWKP.js → chunk-LZ2RREQV.js} +1 -1
  113. package/dist/standalone/{chunk-ZNAGZU6H.js → chunk-LZGOETI3.js} +1 -1
  114. package/dist/standalone/{chunk-JEZDJ7D6.js → chunk-MVJMAEP4.js} +1 -1
  115. package/dist/standalone/{chunk-2O65JEMI.js → chunk-NQ4FA65F.js} +1 -1
  116. package/dist/standalone/{chunk-IUUSMC2R.js → chunk-NSUBZT43.js} +1 -1
  117. package/dist/standalone/{chunk-ZA5YIHZM.js → chunk-OZK52CH2.js} +1 -1
  118. package/dist/standalone/{chunk-7ONX5YGW.js → chunk-Q2QILUP4.js} +1 -1
  119. package/dist/standalone/{chunk-DMJDUC4L.js → chunk-QNQTMABQ.js} +1 -1
  120. package/dist/standalone/{chunk-VNQB6HY4.js → chunk-QVPKPH2T.js} +1 -1
  121. package/dist/standalone/{chunk-ABYJC3LS.js → chunk-SFQX7RUJ.js} +1 -1
  122. package/dist/standalone/{chunk-DYMO6MDG.js → chunk-TAWXVVAZ.js} +1 -1
  123. package/dist/standalone/{chunk-YTWBHPAT.js → chunk-TGQH54CS.js} +1 -1
  124. package/dist/standalone/{chunk-U6KDYJJC.js → chunk-TKFI6XYV.js} +1 -1
  125. package/dist/standalone/{chunk-EQZTSISX.js → chunk-TMGHRD6W.js} +1 -1
  126. package/dist/standalone/{chunk-JWXKUXYA.js → chunk-TVRCPIAV.js} +1 -1
  127. package/dist/standalone/{chunk-3DJ3IUUG.js → chunk-U5MIBWJD.js} +1 -1
  128. package/dist/standalone/chunk-U7ILDM43.js +59 -0
  129. package/dist/standalone/{chunk-UGU5GYDV.js → chunk-UE6A3CRB.js} +1 -1
  130. package/dist/standalone/{chunk-BNAMPDZ2.js → chunk-UZHRBXA7.js} +1 -1
  131. package/dist/standalone/chunk-VWKQ6X2S.js +1 -0
  132. package/dist/standalone/{chunk-TMNKNTC4.js → chunk-WOBRLIBX.js} +1 -1
  133. package/dist/standalone/{chunk-7YJNH3RB.js → chunk-WPERYUTG.js} +1 -1
  134. package/dist/standalone/{chunk-UZERI5YC.js → chunk-WQH3LT2P.js} +1 -1
  135. package/dist/standalone/chunk-WQJOV6L5.js +3 -0
  136. package/dist/standalone/{chunk-XNGYYOLS.js → chunk-YEGFNH56.js} +4 -4
  137. package/dist/standalone/{chunk-NNKN2XEZ.js → chunk-YOKL7XDT.js} +1 -1
  138. package/dist/standalone/{chunk-YD5O2NWK.js → chunk-ZCPQGIQW.js} +1 -1
  139. package/dist/standalone/{chunk-QM4EXWKF.js → chunk-ZURV2PEP.js} +1 -1
  140. package/dist/standalone/studio.js +1 -1
  141. package/dist/styles.css +1 -1
  142. package/package.json +6 -6
  143. package/dist/packem_shared/advisor-view-Coipc04R.js +0 -1
  144. package/dist/packem_shared/bar-chart-DraN_srt.js +0 -9
  145. package/dist/packem_shared/error-alert--Ie7ofJ0.js +0 -1
  146. package/dist/packem_shared/home-panel-BtxdqXDe.js +0 -3
  147. package/dist/packem_shared/result-chart-Gywg9DOk.js +0 -1
  148. package/dist/packem_shared/schema-diagram-DTRaCp6Y.js +0 -2
  149. package/dist/packem_shared/studio-Drf4en3j.js +0 -2
  150. package/dist/packem_shared/use-async-submit-BFIMhRqh.js +0 -1
  151. package/dist/standalone/chunk-5KCULF7S.js +0 -11
  152. package/dist/standalone/chunk-GZMKPBTJ.js +0 -1
  153. package/dist/standalone/chunk-ILNELDFC.js +0 -1
  154. package/dist/standalone/chunk-MV4A2PAK.js +0 -1
  155. package/dist/standalone/chunk-Q2Q7FR3R.js +0 -1
  156. package/dist/standalone/chunk-S3DWUXGY.js +0 -62
  157. package/dist/standalone/chunk-UBIPFCOZ.js +0 -1
  158. package/dist/standalone/chunk-ZQPWVALL.js +0 -3
  159. package/dist/standalone/chunk-ZZJ7VUVZ.js +0 -1
  160. /package/dist/standalone/{chunk-7H7LZRLP.js → chunk-4KIQ5RLS.js} +0 -0
  161. /package/dist/standalone/{chunk-UU2QJMGJ.js → chunk-MKYEFQCA.js} +0 -0
  162. /package/dist/standalone/{chunk-KUVMORDQ.js → chunk-PKSAWP56.js} +0 -0
  163. /package/dist/standalone/{chunk-MIQTKZAR.js → chunk-WJQLNYGX.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FunctionDescriptor } from "./packem_shared/app.d-DW7yZsfu.js";
2
- export { type a as FunctionKind, type R as RunStatus, b as ScheduledJobs, type c as ScheduledJobsProps, d as Studio, e as StudioApp, type S as StudioAppProps, type f as StudioProps } from "./packem_shared/app.d-DW7yZsfu.js";
1
+ import { F as FunctionDescriptor } from "./packem_shared/app.d-D1bPR8FO.js";
2
+ export { type a as FunctionKind, type R as RunStatus, b as ScheduledJobs, type c as ScheduledJobsProps, d as Studio, e as StudioApp, type S as StudioAppProps, type f as StudioProps } from "./packem_shared/app.d-D1bPR8FO.js";
3
3
  import { ReactElement, ReactNode, ErrorInfo, Component, ChangeEvent } from 'react';
4
4
  import '@lunora/advisor';
5
5
  import { CapturedMail } from '@lunora/mail';
@@ -106,7 +106,7 @@ interface ShardInputProps {
106
106
  }
107
107
  /**
108
108
  * Shard-key text field shared by every shard-scoped panel. Backed by a
109
- * `<datalist>` of recently-used shard keys (see {@link loadRecentShards}) so an
109
+ * `<datalist>` of recently-used shard keys (see {@link loadRecentShards}) so an
110
110
  * operator can pick a shard they've visited instead of retyping it — the closest
111
111
  * to a shard picker possible without server-side shard enumeration, which
112
112
  * Durable Objects don't support. Panels remain responsible for recording a shard
@@ -332,7 +332,7 @@ type LogLevel = "debug" | "error" | "fatal" | "info" | "log" | "trace" | "warn";
332
332
  */
333
333
  interface LogEntry {
334
334
  exitCode?: number;
335
- /** Structured fields from a `ctx.log.&lt;level>(message, fields)` / `ctx.log.with(fields)` call, when present. */
335
+ /** Structured fields from a `ctx.log.<level>(message, fields)` / `ctx.log.with(fields)` call, when present. */
336
336
  fields?: Record<string, unknown>;
337
337
  functionPath?: string;
338
338
  instance?: string;
@@ -1236,7 +1236,7 @@ interface SchemaViewerProps {
1236
1236
  readonly initialShardKey?: string;
1237
1237
  /**
1238
1238
  * Table to auto-expand once the shard's tables load. Set by the Insights
1239
- * "add the index" deep-link (`/schema?table=&lt;name>`) so the operator lands
1239
+ * "add the index" deep-link (`/schema?table=<name>`) so the operator lands
1240
1240
  * directly on the scanned table's index list instead of hunting for it.
1241
1241
  * Re-applied whenever the value changes, so following the link a second time
1242
1242
  * (same tab already open) re-expands the target.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{StudioApp as r}from"./packem_shared/StudioApp-D0UOg0a_.js";import{CommandPalette as a,openCommandPalette as f}from"./packem_shared/CommandPalette-mPR8-vIm.js";import{S as m}from"./packem_shared/studio-Drf4en3j.js";import{ConfirmButton as l}from"./packem_shared/ConfirmButton-CTL3f3kr.js";import{default as s}from"./packem_shared/ConnectionBadge-DOk0CQWo.js";import{ErrorBoundary as d}from"./packem_shared/ErrorBoundary-DvzYskH7.js";import{ShardInput as P}from"./packem_shared/ShardInput-BVn2iCU0.js";import{default as A}from"./packem_chunks/AdvisorHealthPanel.js";import{DEFAULT_INSIGHT_THRESHOLDS as I,deriveInsights as T}from"./packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js";import{InsightsPanel as g}from"./packem_chunks/InsightsPanel.js";import{default as F}from"./packem_chunks/SecurityAdvisorPanel.js";import{default as h}from"./packem_shared/ApiDocsPanel-Cu_QmzO0.js";import{default as C}from"./packem_shared/ApiReferencePanel-DuIU1P8B.js";import{default as O}from"./packem_chunks/ApiTab.js";import{default as N}from"./packem_shared/OpenRpcReferencePanel-DXeffPFr.js";import{DataBrowser as U}from"./packem_shared/DataBrowser-H4oUFkPJ.js";import{DataFilters as b,toFilterClauses as v}from"./packem_shared/DataFilters-B26ZeqBZ.js";import{GlobalDataBrowser as y}from"./packem_shared/GlobalDataBrowser-CeA8bDjX.js";import{TableEditor as q}from"./packem_chunks/TableEditor.js";import{ExportImportPanel as V}from"./packem_chunks/ExportImportPanel.js";import{MigrationsPanel as j}from"./packem_shared/MigrationsPanel-dm_M75mR.js";import{PitrPanel as z}from"./packem_chunks/PitrPanel.js";import{FunctionRunner as Q}from"./packem_chunks/FunctionRunner.js";import{FunctionStatsPanel as Y}from"./packem_chunks/FunctionStatsPanel.js";import{DeploymentHealthPanel as $}from"./packem_chunks/DeploymentHealthPanel.js";import{H as oe}from"./packem_shared/home-panel-BtxdqXDe.js";import{AuditPanel as te}from"./packem_chunks/AuditPanel.js";import{LogsPanel as fe}from"./packem_chunks/LogsPanel.js";import{MailPanel as me}from"./packem_chunks/MailPanel.js";import{ScheduledJobs as le}from"./packem_shared/ScheduledJobs-DDJG9Je7.js";import{NotificationsPanel as se}from"./packem_chunks/NotificationsPanel.js";import{HealthPanel as de}from"./packem_chunks/HealthPanel.js";import{aggregateMetrics as Pe,shardsToAggregate as Se}from"./packem_shared/aggregateMetrics-BNfajLa2.js";import{MetricsPanel as ce}from"./packem_chunks/MetricsPanel.js";import{SchemaViewer as Te}from"./packem_chunks/SchemaViewer.js";import{SettingsPanel as ge}from"./packem_chunks/SettingsPanel.js";import{SqlEditorPanel as Fe}from"./packem_chunks/SqlEditorPanel.js";import{FileBrowser as he}from"./packem_chunks/FileBrowser.js";import{DEFAULT_AUTO_REFRESH_MS as Ce,useAutoRefresh as He}from"./packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{default as Le}from"./packem_shared/useDebounced-CU-uftxO.js";import{DEFAULT_LOCALE as Me,createStudioI18n as Ue,studioI18n as Be,useT as be}from"./packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{StudioI18nProvider as we}from"./packem_shared/StudioI18nProvider-CZ5h4nrV.js";import{ADMIN_FUNCTIONS as Ge,ADMIN_FUNCTION_PREFIX as qe}from"./packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{default as Ve}from"./packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js";export{Ge as ADMIN_FUNCTIONS,qe as ADMIN_FUNCTION_PREFIX,A as AdvisorHealthPanel,h as ApiDocsPanel,C as ApiReferencePanel,O as ApiTab,te as AuditPanel,a as CommandPalette,l as ConfirmButton,s as ConnectionBadge,Ce as DEFAULT_AUTO_REFRESH_MS,I as DEFAULT_INSIGHT_THRESHOLDS,Me as DEFAULT_LOCALE,U as DataBrowser,b as DataFilters,$ as DeploymentHealthPanel,d as ErrorBoundary,V as ExportImportPanel,he as FileBrowser,Q as FunctionRunner,Y as FunctionStatsPanel,y as GlobalDataBrowser,de as HealthPanel,oe as HomePanel,g as InsightsPanel,fe as LogsPanel,me as MailPanel,ce as MetricsPanel,j as MigrationsPanel,se as NotificationsPanel,N as OpenRpcReferencePanel,z as PitrPanel,Ve as STUDIO_ROOT_CLASS,le as ScheduledJobs,Te as SchemaViewer,F as SecurityAdvisorPanel,ge as SettingsPanel,P as ShardInput,Fe as SqlEditorPanel,m as Studio,r as StudioApp,we as StudioI18nProvider,q as TableEditor,Pe as aggregateMetrics,Ue as createStudioI18n,T as deriveInsights,f as openCommandPalette,Se as shardsToAggregate,Be as studioI18n,v as toFilterClauses,He as useAutoRefresh,Le as useDebounced,be as useT};
1
+ import{StudioApp as r}from"./packem_shared/StudioApp-bavavhpe.js";import{CommandPalette as a,openCommandPalette as f}from"./packem_shared/CommandPalette-mPR8-vIm.js";import{S as m}from"./packem_shared/studio-C9Qvg13j.js";import{ConfirmButton as l}from"./packem_shared/ConfirmButton-CTL3f3kr.js";import{default as s}from"./packem_shared/ConnectionBadge-DOk0CQWo.js";import{ErrorBoundary as d}from"./packem_shared/ErrorBoundary-DvzYskH7.js";import{ShardInput as P}from"./packem_shared/ShardInput-BVn2iCU0.js";import{default as A}from"./packem_chunks/AdvisorHealthPanel.js";import{DEFAULT_INSIGHT_THRESHOLDS as I,deriveInsights as T}from"./packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js";import{InsightsPanel as g}from"./packem_chunks/InsightsPanel.js";import{default as F}from"./packem_chunks/SecurityAdvisorPanel.js";import{default as h}from"./packem_shared/ApiDocsPanel-Cu_QmzO0.js";import{default as C}from"./packem_shared/ApiReferencePanel-DuIU1P8B.js";import{default as O}from"./packem_chunks/ApiTab.js";import{default as N}from"./packem_shared/OpenRpcReferencePanel-DXeffPFr.js";import{DataBrowser as U}from"./packem_shared/DataBrowser-CPNKM0KZ.js";import{DataFilters as b,toFilterClauses as v}from"./packem_shared/DataFilters-B26ZeqBZ.js";import{GlobalDataBrowser as y}from"./packem_shared/GlobalDataBrowser-BSmyOO0n.js";import{TableEditor as q}from"./packem_chunks/TableEditor.js";import{ExportImportPanel as V}from"./packem_chunks/ExportImportPanel.js";import{MigrationsPanel as j}from"./packem_shared/MigrationsPanel-BAnvY79E.js";import{PitrPanel as z}from"./packem_chunks/PitrPanel.js";import{FunctionRunner as Q}from"./packem_chunks/FunctionRunner.js";import{FunctionStatsPanel as Y}from"./packem_chunks/FunctionStatsPanel.js";import{DeploymentHealthPanel as $}from"./packem_chunks/DeploymentHealthPanel.js";import{H as oe}from"./packem_shared/home-panel-Ir3YHReO.js";import{AuditPanel as te}from"./packem_chunks/AuditPanel.js";import{LogsPanel as fe}from"./packem_chunks/LogsPanel.js";import{MailPanel as me}from"./packem_chunks/MailPanel.js";import{ScheduledJobs as le}from"./packem_shared/ScheduledJobs-pHVlh2xU.js";import{default as se}from"./packem_chunks/NotificationsPanel.js";import{HealthPanel as de}from"./packem_chunks/HealthPanel.js";import{aggregateMetrics as Pe,shardsToAggregate as Se}from"./packem_shared/aggregateMetrics-BNfajLa2.js";import{MetricsPanel as ce}from"./packem_chunks/MetricsPanel.js";import{SchemaViewer as Te}from"./packem_chunks/SchemaViewer.js";import{SettingsPanel as ge}from"./packem_chunks/SettingsPanel.js";import{SqlEditorPanel as Fe}from"./packem_chunks/SqlEditorPanel.js";import{FileBrowser as he}from"./packem_chunks/FileBrowser.js";import{DEFAULT_AUTO_REFRESH_MS as Ce,useAutoRefresh as He}from"./packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{default as Le}from"./packem_shared/useDebounced-CU-uftxO.js";import{DEFAULT_LOCALE as Me,createStudioI18n as Ue,studioI18n as Be,useT as be}from"./packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{StudioI18nProvider as we}from"./packem_shared/StudioI18nProvider-CZ5h4nrV.js";import{ADMIN_FUNCTIONS as Ge,ADMIN_FUNCTION_PREFIX as qe}from"./packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{default as Ve}from"./packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js";export{Ge as ADMIN_FUNCTIONS,qe as ADMIN_FUNCTION_PREFIX,A as AdvisorHealthPanel,h as ApiDocsPanel,C as ApiReferencePanel,O as ApiTab,te as AuditPanel,a as CommandPalette,l as ConfirmButton,s as ConnectionBadge,Ce as DEFAULT_AUTO_REFRESH_MS,I as DEFAULT_INSIGHT_THRESHOLDS,Me as DEFAULT_LOCALE,U as DataBrowser,b as DataFilters,$ as DeploymentHealthPanel,d as ErrorBoundary,V as ExportImportPanel,he as FileBrowser,Q as FunctionRunner,Y as FunctionStatsPanel,y as GlobalDataBrowser,de as HealthPanel,oe as HomePanel,g as InsightsPanel,fe as LogsPanel,me as MailPanel,ce as MetricsPanel,j as MigrationsPanel,se as NotificationsPanel,N as OpenRpcReferencePanel,z as PitrPanel,Ve as STUDIO_ROOT_CLASS,le as ScheduledJobs,Te as SchemaViewer,F as SecurityAdvisorPanel,ge as SettingsPanel,P as ShardInput,Fe as SqlEditorPanel,m as Studio,r as StudioApp,we as StudioI18nProvider,q as TableEditor,Pe as aggregateMetrics,Ue as createStudioI18n,T as deriveInsights,f as openCommandPalette,Se as shardsToAggregate,Be as studioI18n,v as toFilterClauses,He as useAutoRefresh,Le as useDebounced,be as useT};
package/dist/mount.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Root } from 'react-dom/client';
2
- import { S as StudioAppProps } from "./packem_shared/app.d-DW7yZsfu.js";
2
+ import { S as StudioAppProps } from "./packem_shared/app.d-D1bPR8FO.js";
3
3
  import '@lunora/client';
4
4
  import 'react';
5
5
  import '@lingui/core';
@@ -15,7 +15,7 @@ interface MountStudioOptions extends StudioAppProps {
15
15
  * Mount the batteries-included {@link StudioApp} into the DOM and return the
16
16
  * React root (call `.unmount()` to tear it down). This is the entry the
17
17
  * standalone app's `main.tsx` and the `@lunora/vite` dev route both call — it
18
- * keeps the host HTML to a single `&lt;div id="root">` plus one script.
18
+ * keeps the host HTML to a single `<div id="root">` plus one script.
19
19
  */
20
20
  declare const mountStudio: (options?: MountStudioOptions) => Root;
21
21
  export { MountStudioOptions, mountStudio };
package/dist/mount.js CHANGED
@@ -1 +1 @@
1
- import{LunoraError as a}from"@lunora/errors";import{createRoot as s}from"react-dom/client";import{StudioApp as i}from"./packem_shared/StudioApp-D0UOg0a_.js";import{jsx as l}from"react/jsx-runtime";const p=(n={})=>{const{container:t="#root",...o}=n,e=typeof t=="string"?document.querySelector(t):t;if(e===null)throw new a("INTERNAL",`mountStudio: container ${typeof t=="string"?t:"element"} not found`);const r=s(e);return r.render(l(i,{adminToken:o.adminToken,basePath:o.basePath,baseUrl:o.baseUrl,locale:o.locale,rulesInstalled:o.rulesInstalled,studio:o.studio})),r};export{p as mountStudio};
1
+ import{LunoraError as a}from"@lunora/errors";import{createRoot as s}from"react-dom/client";import{StudioApp as i}from"./packem_shared/StudioApp-bavavhpe.js";import{jsx as l}from"react/jsx-runtime";const p=(n={})=>{const{container:t="#root",...o}=n,e=typeof t=="string"?document.querySelector(t):t;if(e===null)throw new a("INTERNAL",`mountStudio: container ${typeof t=="string"?t:"element"} not found`);const r=s(e);return r.render(l(i,{adminToken:o.adminToken,basePath:o.basePath,baseUrl:o.baseUrl,locale:o.locale,rulesInstalled:o.rulesInstalled,studio:o.studio})),r};export{p as mountStudio};
@@ -1 +1 @@
1
- import{scoreAdvisor as $}from"@lunora/advisor";import{E as w}from"../packem_shared/error-alert--Ie7ofJ0.js";import{c,u as i}from"../packem_shared/card-CIDGUN6K.js";import{n as j,d as A,m as f,p as m,f as R,u as o}from"../packem_shared/table-DdJBrClo.js";import{N}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as I}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as x}from"../packem_shared/utils-bhneXptQ.js";import{jsx as e,jsxs as a}from"react/jsx-runtime";const d={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},k={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},S=(t,r)=>`exempt: ${t.exemptReason===void 0||t.exemptReason===""?r:t.exemptReason}`,E=t=>t.toSorted((r,l)=>r.coverage==="clean"&&l.coverage!=="clean"?1:l.coverage==="clean"&&r.coverage!=="clean"?-1:r.score-l.score),U=({testId:t="advisor-health"})=>{const r=I(),l=N(v.getAdvisories,{},{live:!0}),p=N(v.getAdvisorProcedures,{},{live:!0}),u=l.data?.advisories??null,h=p.data?.procedures??null,s=u===null||h===null?null:$(h,u),g=p.error??l.error;if(g!==null)return e(w,{error:g,testId:`${t}-error`});if(s===null)return e(c,{children:e(i,{className:"py-8 text-center text-muted-foreground","data-testid":`${t}-loading`,children:r("Loading…")})});const b=E(s.procedures);return a("div",{className:"space-y-4","data-testid":t,children:[e(c,{children:a(i,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[a("div",{children:[e("span",{className:x("text-4xl font-semibold tabular-nums",k[s.grade]),"data-testid":`${t}-score`,children:s.score}),e("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),e("span",{className:x("text-sm font-medium uppercase tracking-wide",k[s.grade]),"data-testid":`${t}-grade`,children:s.grade}),a("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${t}-summary`,children:[a("span",{className:d.clean,children:[s.summary.clean," ",r("clean")]}),a("span",{className:d.warned,children:[s.summary.warned," ",r("warned")]}),a("span",{className:d.failing,children:[s.summary.failing," ",r("failing")]}),a("span",{className:d.exempt,children:[s.summary.exempt," ",r("exempt")]})]})]})}),s.project.checks.length>0&&e(c,{children:a(i,{className:"py-4 text-sm","data-testid":`${t}-project`,children:[a("span",{className:"font-medium",children:[r("Schema & config")," ",s.project.score,"/100"]}),a("span",{className:"text-muted-foreground",children:[" — ",s.project.checks.map(n=>n.name).join(", ")]})]})}),e(c,{children:e(i,{className:"p-0",children:a(j,{children:[e(A,{children:a(f,{children:[e(m,{className:"w-20",children:r("Score")}),e(m,{children:r("Procedure")}),e(m,{className:"w-32",children:r("Kind")}),e(m,{children:r("Rules fired")})]})}),e(R,{children:b.map(n=>a(f,{"data-testid":`${t}-row`,children:[e(o,{className:x("tabular-nums font-medium",d[n.coverage]),children:n.coverage==="exempt"?"—":n.score}),e(o,{className:"font-mono text-xs",children:n.id}),a(o,{className:"text-muted-foreground text-xs",children:[n.visibility," ",n.kind,n.sensitivity.level==="high"&&e("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:r("sensitive")})]}),e(o,{className:"text-muted-foreground text-xs",children:n.coverage==="exempt"?S(n,r("no reason given")):n.checks.map(y=>y.name).join(", ")})]},n.id))})]})})})]})};export{U as default};
1
+ import{scoreAdvisor as $}from"@lunora/advisor";import{U as w}from"../packem_shared/error-alert-_2q2VtVG.js";import{c,f as i}from"../packem_shared/card-BMKx5UdA.js";import{d as j,n as R,f as g,m,b as A,p as o}from"../packem_shared/table-DZAB8cs3.js";import{N}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as I}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as x}from"../packem_shared/utils-bhneXptQ.js";import{jsx as e,jsxs as a}from"react/jsx-runtime";const l={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},k={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},S=(t,r)=>`exempt: ${t.exemptReason===void 0||t.exemptReason===""?r:t.exemptReason}`,T=t=>t.toSorted((r,d)=>r.coverage==="clean"&&d.coverage!=="clean"?1:d.coverage==="clean"&&r.coverage!=="clean"?-1:r.score-d.score),O=({testId:t="advisor-health"})=>{const r=I(),d=N(v.getAdvisories,{},{live:!0}),p=N(v.getAdvisorProcedures,{},{live:!0}),u=d.data?.advisories??null,h=p.data?.procedures??null,s=u===null||h===null?null:$(h,u),f=p.error??d.error;if(f!==null)return e(w,{error:f,testId:`${t}-error`});if(s===null)return e(c,{children:e(i,{className:"py-8 text-center text-muted-foreground","data-testid":`${t}-loading`,children:r("Loading…")})});const b=T(s.procedures);return a("div",{className:"space-y-4","data-testid":t,children:[e(c,{children:a(i,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[a("div",{children:[e("span",{className:x("text-4xl font-semibold tabular-nums",k[s.grade]),"data-testid":`${t}-score`,children:s.score}),e("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),e("span",{className:x("text-sm font-medium uppercase tracking-wide",k[s.grade]),"data-testid":`${t}-grade`,children:s.grade}),a("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${t}-summary`,children:[a("span",{className:l.clean,children:[s.summary.clean," ",r("clean")]}),a("span",{className:l.warned,children:[s.summary.warned," ",r("warned")]}),a("span",{className:l.failing,children:[s.summary.failing," ",r("failing")]}),a("span",{className:l.exempt,children:[s.summary.exempt," ",r("exempt")]})]})]})}),s.project.checks.length>0&&e(c,{children:a(i,{className:"py-4 text-sm","data-testid":`${t}-project`,children:[a("span",{className:"font-medium",children:[r("Schema & config")," ",s.project.score,"/100"]}),a("span",{className:"text-muted-foreground",children:[" — ",s.project.checks.map(n=>n.name).join(", ")]})]})}),e(c,{children:e(i,{className:"p-0",children:a(j,{children:[e(R,{children:a(g,{children:[e(m,{className:"w-20",children:r("Score")}),e(m,{children:r("Procedure")}),e(m,{className:"w-32",children:r("Kind")}),e(m,{children:r("Rules fired")})]})}),e(A,{children:b.map(n=>a(g,{"data-testid":`${t}-row`,children:[e(o,{className:x("tabular-nums font-medium",l[n.coverage]),children:n.coverage==="exempt"?"—":n.score}),e(o,{className:"font-mono text-xs",children:n.id}),a(o,{className:"text-muted-foreground text-xs",children:[n.visibility," ",n.kind,n.sensitivity.level==="high"&&e("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:r("sensitive")})]}),e(o,{className:"text-muted-foreground text-xs",children:n.coverage==="exempt"?S(n,r("no reason given")):n.checks.map(y=>y.name).join(", ")})]},n.id))})]})})})]})};export{O as default};
@@ -1 +1 @@
1
- import{useVirtualizer as z,observeElementRect as V}from"@tanstack/react-virtual";import{useState as j,useMemo as w,useRef as q}from"react";import{E as F}from"../packem_shared/error-alert--Ie7ofJ0.js";import{L as H}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as O}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as _}from"../packem_shared/badge-BbuuAio7.js";import{c as B,u as D}from"../packem_shared/card-CIDGUN6K.js";import{E as J}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as P}from"../packem_shared/input-JHu63lTv.js";import{n as U,d as W,m as S,p as l,f as Z,u as d}from"../packem_shared/table-DdJBrClo.js";import{N as G}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as Q}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Y}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ee}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as o,jsx as e}from"react/jsx-runtime";const y=80,te=i=>{if(i===void 0)return"";const t=JSON.stringify(i);return t.length>y?`${t.slice(0,y)}…`:t},re=41,$=480,L=5,ae=(i,t)=>V(i,n=>{t(n.height>0?n:{height:$,width:n.width})}),we=({initialShardKey:i})=>{const t=X(),{queryShardKey:n,setShardKey:b,shardKey:C}=Q(i),[m,E]=j(""),{data:u,error:p,errorSource:I,isLoading:A,liveError:K}=G(Y.getAuditLog,{},{live:!0,shardKey:n}),c=w(()=>u?.entries??[],[u]),s=w(()=>{const a=m.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,m]),f=q(null),g=z({count:s.length,estimateSize:()=>re,getScrollElement:()=>f.current,initialRect:{height:$,width:800},observeElementRect:ae,overscan:8}),h=g.getVirtualItems(),M=g.getTotalSize(),x=h[0]?.start??0,v=M-(h.at(-1)?.end??0),R={height:x},T={height:v},k=a=>{E(a.target.value)};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[e(O,{onChange:b,testId:"au-shard-input",value:C}),e(H,{message:K,prefix:"au"}),e(P,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:k,placeholder:t("filter op, table, id"),value:m})]}),p!==null&&e(F,{error:I,testId:"au-error"}),p===null&&!A&&s.length===0&&e(J,{description:t("State-changing admin operations are recorded here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),s.length>0&&e(B,{className:"overflow-hidden py-0",children:e(D,{className:"max-h-[30rem] overflow-auto px-0",ref:f,children:o(U,{"data-testid":"au-table",children:[e(W,{children:o(S,{children:[e(l,{children:t("time")}),e(l,{children:t("op")}),e(l,{children:t("table")}),e(l,{children:t("id")}),e(l,{children:t("detail")})]})}),o(Z,{children:[x>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:L,style:R})}),h.map(a=>{const r=s[a.index],N=te(r.detail);return o(S,{"data-testid":"au-row",children:[e(d,{className:"text-muted-foreground tabular-nums",children:ee(r.ts,"—")}),e(d,{children:e(_,{variant:"secondary",children:r.op})}),e(d,{className:"font-medium",children:r.table??e("span",{className:"text-muted-foreground",children:"—"})}),e(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??e("span",{className:"text-muted-foreground",children:"—"})}),e(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||e("span",{className:"text-muted-foreground",children:"—"})})]},r.seq)}),v>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:L,style:T})})]})]})})})]})};export{we as AuditPanel};
1
+ import{useVirtualizer as A,observeElementRect as V}from"@tanstack/react-virtual";import{useState as j,useMemo as w,useRef as q}from"react";import{U as F}from"../packem_shared/error-alert-_2q2VtVG.js";import{L as H}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as O}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as U}from"../packem_shared/badge-BbuuAio7.js";import{c as _,f as B}from"../packem_shared/card-BMKx5UdA.js";import{E as D}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as J}from"../packem_shared/input-JHu63lTv.js";import{d as P,n as W,f as S,m as d,b as Z,p as l}from"../packem_shared/table-DZAB8cs3.js";import{N as G}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as Q}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Y}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ee}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as o,jsx as e}from"react/jsx-runtime";const y=80,te=i=>{if(i===void 0)return"";const t=JSON.stringify(i);return t.length>y?`${t.slice(0,y)}…`:t},re=41,L=480,b=5,ae=(i,t)=>V(i,n=>{t(n.height>0?n:{height:L,width:n.width})}),we=({initialShardKey:i})=>{const t=X(),{queryShardKey:n,setShardKey:$,shardKey:C}=Q(i),[m,I]=j(""),{data:u,error:f,errorSource:E,isLoading:K,liveError:M}=G(Y.getAuditLog,{},{live:!0,shardKey:n}),c=w(()=>u?.entries??[],[u]),s=w(()=>{const a=m.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,m]),p=q(null),g=A({count:s.length,estimateSize:()=>re,getScrollElement:()=>p.current,initialRect:{height:L,width:800},observeElementRect:ae,overscan:8}),h=g.getVirtualItems(),R=g.getTotalSize(),x=h[0]?.start??0,v=R-(h.at(-1)?.end??0),T={height:x},k={height:v},z=a=>{I(a.target.value)};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[e(O,{onChange:$,testId:"au-shard-input",value:C}),e(H,{message:M,prefix:"au"}),e(J,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:z,placeholder:t("filter op, table, id"),value:m})]}),f!==null&&e(F,{error:E,testId:"au-error"}),f===null&&!K&&s.length===0&&e(D,{description:t("State-changing admin operations are recorded here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),s.length>0&&e(_,{className:"overflow-hidden py-0",children:e(B,{className:"max-h-[30rem] overflow-auto px-0",ref:p,children:o(P,{"data-testid":"au-table",children:[e(W,{children:o(S,{children:[e(d,{children:t("time")}),e(d,{children:t("op")}),e(d,{children:t("table")}),e(d,{children:t("id")}),e(d,{children:t("detail")})]})}),o(Z,{children:[x>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:b,style:T})}),h.map(a=>{const r=s[a.index],N=te(r.detail);return o(S,{"data-testid":"au-row",children:[e(l,{className:"text-muted-foreground tabular-nums",children:ee(r.ts,"—")}),e(l,{children:e(U,{variant:"secondary",children:r.op})}),e(l,{className:"font-medium",children:r.table??e("span",{className:"text-muted-foreground",children:"—"})}),e(l,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??e("span",{className:"text-muted-foreground",children:"—"})}),e(l,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||e("span",{className:"text-muted-foreground",children:"—"})})]},r.seq)}),v>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:b,style:k})})]})]})})})]})};export{we as AuditPanel};
@@ -1 +1 @@
1
- import{c as ie}from"react/compiler-runtime";import{useLunora as ce}from"@lunora/react";import{useQuery as me}from"@tanstack/react-query";import{g as le}from"../packem_shared/badge-BbuuAio7.js";import{c as se}from"../packem_shared/card-CIDGUN6K.js";import{E as pe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as re}from"../packem_shared/skeleton-C1wQ9M5t.js";import{useT as he}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as ue}from"../packem_shared/internal-zkEvTqy8.js";import{c as te}from"../packem_shared/utils-bhneXptQ.js";import{jsxs as o,jsx as l}from"react/jsx-runtime";const fe="/_lunora/health",ge="/_lunora/health/ready",xe=(n,e)=>(n.endsWith("/")?n.slice(0,-1):n)+e,Ne=()=>{const n=ce();return async e=>{const w=e==="ready"?ge:fe,t=n.getAuthToken(),$=xe(n.url,w);try{const r=await fetch($,{headers:t===null?{}:{authorization:`Bearer ${t}`}});let d=null;try{d=await r.json()}catch{d=null}return{body:d,ok:r.ok,status:r.status}}catch(r){return{body:null,error:r instanceof Error?r.message:String(r),ok:!1,status:0}}}},de={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ve={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},ye=n=>n==="unhealthy"?"crit":n==="degraded"?"warn":"ok",ne=n=>{const e=ie(13),{label:w,level:t,testId:$,value:r}=n,d=de[t];let c;e[0]!==d?(c=te("size-1.5 shrink-0 rounded-full",d),e[0]=d,e[1]=c):c=e[1];let m;e[2]!==c?(m=l("span",{"aria-hidden":"true",className:c}),e[2]=c,e[3]=m):m=e[3];let x;e[4]!==w||e[5]!==m?(x=o("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,w]}),e[4]=w,e[5]=m,e[6]=x):x=e[6];let N;e[7]!==$||e[8]!==r?(N=l("span",{className:"text-lg font-semibold text-foreground","data-testid":$,children:r}),e[7]=$,e[8]=r,e[9]=N):N=e[9];let u;return e[10]!==x||e[11]!==N?(u=l(se,{className:"gap-0 py-0",children:o("div",{className:"flex flex-col gap-2.5 p-4",children:[x,N]})}),e[10]=x,e[11]=N,e[12]=u):u=e[12],u},Ie=n=>{const e=ie(115),{probe:w}=n,t=he(),$=Ne(),r=w??$;let d;e[0]!==r?(d=async()=>{const[a,i]=await Promise.all([r("live"),r("ready")]);return{live:a,ready:i}},e[0]=r,e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=["deployment-health"],e[2]=c):c=e[2];let m;e[3]!==d?(m={queryFn:d,queryKey:c},e[3]=d,e[4]=m):m=e[4];const{data:x,isPending:N}=me(m),u=x?.live??null,oe=x?.ready??null;if(N){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=o("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[l(re,{className:"h-16 w-full"}),l(re,{className:"h-40 w-full"})]}),e[5]=a):a=e[5],a}const s=u?.body??null;if(s===null){const a=u?.status===403;let i;e[6]!==a||e[7]!==u?.error||e[8]!==t?(i=a?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:u?.error??t("no response")}),e[6]=a,e[7]=u?.error,e[8]=t,e[9]=i):i=e[9];let f;e[10]!==t?(f=t("Health endpoint unavailable"),e[10]=t,e[11]=f):f=e[11];let h;return e[12]!==i||e[13]!==f?(h=l(pe,{description:i,testId:"deployment-health-error",title:f}),e[12]=i,e[13]=f,e[14]=h):h=e[14],h}let Z;e[15]!==s.status?(Z=ye(s.status),e[15]=s.status,e[16]=Z):Z=e[16];const _=Z;let p;if(s.status==="unhealthy"){let a;e[17]!==t?(a=t("Unhealthy"),e[17]=t,e[18]=a):a=e[18],p=a}else if(s.status==="degraded"){let a;e[19]!==t?(a=t("Degraded"),e[19]=t,e[20]=a):a=e[20],p=a}else{let a;e[21]!==t?(a=t("Healthy"),e[21]=t,e[22]=a):a=e[22],p=a}const j=oe?.ok??!1,Y=j?"ok":"crit";let C,P,v,y,b,S,z,k,V,H;if(e[23]!==s.appName||e[24]!==s.appVersion||e[25]!==s.checks||e[26]!==s.timestamp||e[27]!==_||e[28]!==Y||e[29]!==j||e[30]!==p||e[31]!==t){const a=[...s.checks].toSorted(be);H="flex flex-col gap-6",P="deployment-health";let i;e[42]!==t?(i=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint — wire an uptime monitor or a Cloudflare Health Check at it."),e[42]=t,e[43]=i):i=e[43],e[44]!==i?(v=l("p",{className:"text-sm text-muted-foreground",children:i}),e[44]=i,e[45]=v):v=e[45];const f=ve[_];let h;e[46]!==f?(h=te("flex size-10 shrink-0 items-center justify-center rounded-full",f),e[46]=f,e[47]=h):h=e[47];const ae=de[_];let T;e[48]!==ae?(T=te("size-3 rounded-full",ae),e[48]=ae,e[49]=T):T=e[49];let D;e[50]!==T?(D=l("span",{className:T}),e[50]=T,e[51]=D):D=e[51];let E;e[52]!==h||e[53]!==D?(E=l("span",{"aria-hidden":"true",className:h,children:D}),e[52]=h,e[53]=D,e[54]=E):E=e[54];let L;e[55]!==p?(L=l("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:p}),e[55]=p,e[56]=L):L=e[56];let q;e[57]!==s.appName||e[58]!==s.appVersion?(q=o("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[s.appName," · ",s.appVersion]}),e[57]=s.appName,e[58]=s.appVersion,e[59]=q):q=e[59];let R;e[60]!==L||e[61]!==q?(R=o("div",{className:"grid leading-tight",children:[L,q]}),e[60]=L,e[61]=q,e[62]=R):R=e[62];let U;e[63]!==E||e[64]!==R?(U=o("div",{className:"flex items-center gap-3",children:[E,R]}),e[63]=E,e[64]=R,e[65]=U):U=e[65];let A;e[66]!==t?(A=t("Checked"),e[66]=t,e[67]=A):A=e[67];let B;e[68]!==A?(B=l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:A}),e[68]=A,e[69]=B):B=e[69];let F;e[70]!==s.timestamp?(F=ue(s.timestamp),e[70]=s.timestamp,e[71]=F):F=e[71];let K;e[72]!==F?(K=l("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:F}),e[72]=F,e[73]=K):K=e[73];let Q;e[74]!==B||e[75]!==K?(Q=o("div",{className:"text-end",children:[B,K]}),e[74]=B,e[75]=K,e[76]=Q):Q=e[76],e[77]!==U||e[78]!==Q?(y=l(se,{className:"gap-0 py-0",children:o("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[U,Q]})}),e[77]=U,e[78]=Q,e[79]=y):y=e[79];let W;e[80]!==t?(W=t("Liveness"),e[80]=t,e[81]=W):W=e[81];let G;e[82]!==_||e[83]!==p||e[84]!==W?(G=l(ne,{label:W,level:_,testId:"dh-liveness",value:p}),e[82]=_,e[83]=p,e[84]=W,e[85]=G):G=e[85];let J;e[86]!==t?(J=t("Readiness"),e[86]=t,e[87]=J):J=e[87];let M;e[88]!==j||e[89]!==t?(M=t(j?"Ready":"Not ready"),e[88]=j,e[89]=t,e[90]=M):M=e[90];let O;e[91]!==Y||e[92]!==J||e[93]!==M?(O=l(ne,{label:J,level:Y,testId:"dh-readiness",value:M}),e[91]=Y,e[92]=J,e[93]=M,e[94]=O):O=e[94],e[95]!==G||e[96]!==O?(b=o("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[G,O]}),e[95]=G,e[96]=O,e[97]=b):b=e[97],C=se,S="gap-0 py-0",z="dh-checks";let X;e[98]!==t?(X=t("Subsystem checks"),e[98]=t,e[99]=X):X=e[99],e[100]!==X?(k=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:X})}),e[100]=X,e[101]=k):k=e[101],V=a.length===0?l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):l("ul",{className:"divide-y divide-border",children:a.map(g=>o("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[o("span",{className:"flex items-center gap-2",children:[l("span",{"aria-hidden":"true",className:te("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),l("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&l(le,{variant:"outline",children:t("Critical")})]}),o("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&l("span",{className:"text-muted-foreground",children:g.message}),l(le,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[23]=s.appName,e[24]=s.appVersion,e[25]=s.checks,e[26]=s.timestamp,e[27]=_,e[28]=Y,e[29]=j,e[30]=p,e[31]=t,e[32]=C,e[33]=P,e[34]=v,e[35]=y,e[36]=b,e[37]=S,e[38]=z,e[39]=k,e[40]=V,e[41]=H}else C=e[32],P=e[33],v=e[34],y=e[35],b=e[36],S=e[37],z=e[38],k=e[39],V=e[40],H=e[41];let I;e[102]!==C||e[103]!==S||e[104]!==z||e[105]!==k||e[106]!==V?(I=o(C,{className:S,"data-testid":z,children:[k,V]}),e[102]=C,e[103]=S,e[104]=z,e[105]=k,e[106]=V,e[107]=I):I=e[107];let ee;return e[108]!==P||e[109]!==v||e[110]!==y||e[111]!==b||e[112]!==I||e[113]!==H?(ee=o("div",{className:H,"data-testid":P,children:[v,y,b,I]}),e[108]=P,e[109]=v,e[110]=y,e[111]=b,e[112]=I,e[113]=H,e[114]=ee):ee=e[114],ee};function be(n,e){return n.name.localeCompare(e.name)}export{Ie as DeploymentHealthPanel};
1
+ import{c as ie}from"react/compiler-runtime";import{useLunora as ce}from"@lunora/react";import{useQuery as me}from"@tanstack/react-query";import{g as le}from"../packem_shared/badge-BbuuAio7.js";import{c as se}from"../packem_shared/card-BMKx5UdA.js";import{E as pe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as re}from"../packem_shared/skeleton-C1wQ9M5t.js";import{useT as he}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as ue}from"../packem_shared/internal-zkEvTqy8.js";import{c as te}from"../packem_shared/utils-bhneXptQ.js";import{jsxs as o,jsx as l}from"react/jsx-runtime";const fe="/_lunora/health",ge="/_lunora/health/ready",xe=(n,e)=>(n.endsWith("/")?n.slice(0,-1):n)+e,Ne=()=>{const n=ce();return async e=>{const w=e==="ready"?ge:fe,t=n.getAuthToken(),$=xe(n.url,w);try{const r=await fetch($,{headers:t===null?{}:{authorization:`Bearer ${t}`}});let d=null;try{d=await r.json()}catch{d=null}return{body:d,ok:r.ok,status:r.status}}catch(r){return{body:null,error:r instanceof Error?r.message:String(r),ok:!1,status:0}}}},de={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ve={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},ye=n=>n==="unhealthy"?"crit":n==="degraded"?"warn":"ok",ne=n=>{const e=ie(13),{label:w,level:t,testId:$,value:r}=n,d=de[t];let c;e[0]!==d?(c=te("size-1.5 shrink-0 rounded-full",d),e[0]=d,e[1]=c):c=e[1];let m;e[2]!==c?(m=l("span",{"aria-hidden":"true",className:c}),e[2]=c,e[3]=m):m=e[3];let x;e[4]!==w||e[5]!==m?(x=o("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,w]}),e[4]=w,e[5]=m,e[6]=x):x=e[6];let N;e[7]!==$||e[8]!==r?(N=l("span",{className:"text-lg font-semibold text-foreground","data-testid":$,children:r}),e[7]=$,e[8]=r,e[9]=N):N=e[9];let u;return e[10]!==x||e[11]!==N?(u=l(se,{className:"gap-0 py-0",children:o("div",{className:"flex flex-col gap-2.5 p-4",children:[x,N]})}),e[10]=x,e[11]=N,e[12]=u):u=e[12],u},Ie=n=>{const e=ie(115),{probe:w}=n,t=he(),$=Ne(),r=w??$;let d;e[0]!==r?(d=async()=>{const[a,i]=await Promise.all([r("live"),r("ready")]);return{live:a,ready:i}},e[0]=r,e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=["deployment-health"],e[2]=c):c=e[2];let m;e[3]!==d?(m={queryFn:d,queryKey:c},e[3]=d,e[4]=m):m=e[4];const{data:x,isPending:N}=me(m),u=x?.live??null,oe=x?.ready??null;if(N){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=o("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[l(re,{className:"h-16 w-full"}),l(re,{className:"h-40 w-full"})]}),e[5]=a):a=e[5],a}const s=u?.body??null;if(s===null){const a=u?.status===403;let i;e[6]!==a||e[7]!==u?.error||e[8]!==t?(i=a?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:u?.error??t("no response")}),e[6]=a,e[7]=u?.error,e[8]=t,e[9]=i):i=e[9];let f;e[10]!==t?(f=t("Health endpoint unavailable"),e[10]=t,e[11]=f):f=e[11];let h;return e[12]!==i||e[13]!==f?(h=l(pe,{description:i,testId:"deployment-health-error",title:f}),e[12]=i,e[13]=f,e[14]=h):h=e[14],h}let Z;e[15]!==s.status?(Z=ye(s.status),e[15]=s.status,e[16]=Z):Z=e[16];const _=Z;let p;if(s.status==="unhealthy"){let a;e[17]!==t?(a=t("Unhealthy"),e[17]=t,e[18]=a):a=e[18],p=a}else if(s.status==="degraded"){let a;e[19]!==t?(a=t("Degraded"),e[19]=t,e[20]=a):a=e[20],p=a}else{let a;e[21]!==t?(a=t("Healthy"),e[21]=t,e[22]=a):a=e[22],p=a}const j=oe?.ok??!1,Y=j?"ok":"crit";let C,P,v,y,b,S,z,k,V,H;if(e[23]!==s.appName||e[24]!==s.appVersion||e[25]!==s.checks||e[26]!==s.timestamp||e[27]!==_||e[28]!==Y||e[29]!==j||e[30]!==p||e[31]!==t){const a=[...s.checks].toSorted(be);H="flex flex-col gap-6",P="deployment-health";let i;e[42]!==t?(i=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint — wire an uptime monitor or a Cloudflare Health Check at it."),e[42]=t,e[43]=i):i=e[43],e[44]!==i?(v=l("p",{className:"text-sm text-muted-foreground",children:i}),e[44]=i,e[45]=v):v=e[45];const f=ve[_];let h;e[46]!==f?(h=te("flex size-10 shrink-0 items-center justify-center rounded-full",f),e[46]=f,e[47]=h):h=e[47];const ae=de[_];let T;e[48]!==ae?(T=te("size-3 rounded-full",ae),e[48]=ae,e[49]=T):T=e[49];let D;e[50]!==T?(D=l("span",{className:T}),e[50]=T,e[51]=D):D=e[51];let E;e[52]!==h||e[53]!==D?(E=l("span",{"aria-hidden":"true",className:h,children:D}),e[52]=h,e[53]=D,e[54]=E):E=e[54];let L;e[55]!==p?(L=l("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:p}),e[55]=p,e[56]=L):L=e[56];let q;e[57]!==s.appName||e[58]!==s.appVersion?(q=o("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[s.appName," · ",s.appVersion]}),e[57]=s.appName,e[58]=s.appVersion,e[59]=q):q=e[59];let R;e[60]!==L||e[61]!==q?(R=o("div",{className:"grid leading-tight",children:[L,q]}),e[60]=L,e[61]=q,e[62]=R):R=e[62];let U;e[63]!==E||e[64]!==R?(U=o("div",{className:"flex items-center gap-3",children:[E,R]}),e[63]=E,e[64]=R,e[65]=U):U=e[65];let A;e[66]!==t?(A=t("Checked"),e[66]=t,e[67]=A):A=e[67];let B;e[68]!==A?(B=l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:A}),e[68]=A,e[69]=B):B=e[69];let F;e[70]!==s.timestamp?(F=ue(s.timestamp),e[70]=s.timestamp,e[71]=F):F=e[71];let K;e[72]!==F?(K=l("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:F}),e[72]=F,e[73]=K):K=e[73];let Q;e[74]!==B||e[75]!==K?(Q=o("div",{className:"text-end",children:[B,K]}),e[74]=B,e[75]=K,e[76]=Q):Q=e[76],e[77]!==U||e[78]!==Q?(y=l(se,{className:"gap-0 py-0",children:o("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[U,Q]})}),e[77]=U,e[78]=Q,e[79]=y):y=e[79];let W;e[80]!==t?(W=t("Liveness"),e[80]=t,e[81]=W):W=e[81];let G;e[82]!==_||e[83]!==p||e[84]!==W?(G=l(ne,{label:W,level:_,testId:"dh-liveness",value:p}),e[82]=_,e[83]=p,e[84]=W,e[85]=G):G=e[85];let J;e[86]!==t?(J=t("Readiness"),e[86]=t,e[87]=J):J=e[87];let M;e[88]!==j||e[89]!==t?(M=t(j?"Ready":"Not ready"),e[88]=j,e[89]=t,e[90]=M):M=e[90];let O;e[91]!==Y||e[92]!==J||e[93]!==M?(O=l(ne,{label:J,level:Y,testId:"dh-readiness",value:M}),e[91]=Y,e[92]=J,e[93]=M,e[94]=O):O=e[94],e[95]!==G||e[96]!==O?(b=o("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[G,O]}),e[95]=G,e[96]=O,e[97]=b):b=e[97],C=se,S="gap-0 py-0",z="dh-checks";let X;e[98]!==t?(X=t("Subsystem checks"),e[98]=t,e[99]=X):X=e[99],e[100]!==X?(k=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:X})}),e[100]=X,e[101]=k):k=e[101],V=a.length===0?l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):l("ul",{className:"divide-y divide-border",children:a.map(g=>o("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[o("span",{className:"flex items-center gap-2",children:[l("span",{"aria-hidden":"true",className:te("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),l("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&l(le,{variant:"outline",children:t("Critical")})]}),o("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&l("span",{className:"text-muted-foreground",children:g.message}),l(le,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[23]=s.appName,e[24]=s.appVersion,e[25]=s.checks,e[26]=s.timestamp,e[27]=_,e[28]=Y,e[29]=j,e[30]=p,e[31]=t,e[32]=C,e[33]=P,e[34]=v,e[35]=y,e[36]=b,e[37]=S,e[38]=z,e[39]=k,e[40]=V,e[41]=H}else C=e[32],P=e[33],v=e[34],y=e[35],b=e[36],S=e[37],z=e[38],k=e[39],V=e[40],H=e[41];let I;e[102]!==C||e[103]!==S||e[104]!==z||e[105]!==k||e[106]!==V?(I=o(C,{className:S,"data-testid":z,children:[k,V]}),e[102]=C,e[103]=S,e[104]=z,e[105]=k,e[106]=V,e[107]=I):I=e[107];let ee;return e[108]!==P||e[109]!==v||e[110]!==y||e[111]!==b||e[112]!==I||e[113]!==H?(ee=o("div",{className:H,"data-testid":P,children:[v,y,b,I]}),e[108]=P,e[109]=v,e[110]=y,e[111]=b,e[112]=I,e[113]=H,e[114]=ee):ee=e[114],ee};function be(n,e){return n.name.localeCompare(e.name)}export{Ie as DeploymentHealthPanel};
@@ -1,3 +1,3 @@
1
- import{c as xe}from"react/compiler-runtime";import{LunoraError as ne}from"@lunora/errors";import{useLunora as be}from"@lunora/react";import{useState as q}from"react";import{ConfirmButton as he}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{ShardInput as ge}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as Ne}from"../packem_shared/button-BkCrNcAs.js";import{u as ie,c as ce}from"../packem_shared/card-CIDGUN6K.js";import{l as we}from"../packem_shared/textarea-Bu2-jKAs.js";import{U as ye}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as Se}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as de,b as oe,f as me,g as fe}from"../packem_shared/internal-zkEvTqy8.js";import{r as pe}from"../packem_shared/shard-history-DMEW5VBE.js";import{jsx as l,jsxs as h}from"react/jsx-runtime";const Ie=fe(Z.exportShard),ve=fe(Z.importShard),je=u=>u.map(e=>JSON.stringify(e)).join(`
1
+ import{c as xe}from"react/compiler-runtime";import{LunoraError as ne}from"@lunora/errors";import{useLunora as be}from"@lunora/react";import{useState as q}from"react";import{ConfirmButton as he}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{ShardInput as ge}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as Ne}from"../packem_shared/button-BkCrNcAs.js";import{f as ie,c as ce}from"../packem_shared/card-BMKx5UdA.js";import{l as we}from"../packem_shared/textarea-Bu2-jKAs.js";import{U as ye}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as Se}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as de,b as oe,f as me,g as fe}from"../packem_shared/internal-zkEvTqy8.js";import{r as pe}from"../packem_shared/shard-history-DMEW5VBE.js";import{jsx as l,jsxs as h}from"react/jsx-runtime";const Ie=fe(Z.exportShard),ve=fe(Z.importShard),je=u=>u.map(e=>JSON.stringify(e)).join(`
2
2
  `),$e=u=>{const e=[],ee=u.split(`
3
3
  `);for(const[a,g]of ee.entries()){const t=g.trim();if(t==="")continue;const r=JSON.parse(t);if(typeof r!="object"||r===null)throw new ne("INTERNAL",`line ${(a+1).toString()}: expected a { table, doc } object`);const x=r;if(typeof x.table!="string"||typeof x.doc!="object"||x.doc===null||Array.isArray(x.doc))throw new ne("INTERNAL",`line ${(a+1).toString()}: expected a { table, doc } object`);e.push(x)}return e},Be=u=>{const e=xe(94),{initialShardKey:ee}=u,a=be(),g=ye(),t=Se(),[r,x]=q(ee??""),[o,se]=q(""),[c,B]=q(!1),[H,K]=q(null),[n,te]=q(null),[N,ae]=q(null);let Q;e[0]!==a||e[1]!==r?(Q=async()=>{B(!0),K(null),te(null);try{const i=await a.query(Ie,{},de(r));pe(r),se(je(i.rows)),ae(i.rows.length)}catch(i){K(oe(i))}B(!1)},e[0]=a,e[1]=r,e[2]=Q):Q=e[2];const z=Q;let V;e[3]!==a||e[4]!==g||e[5]!==o||e[6]!==r||e[7]!==t?(V=async()=>{B(!0),K(null),te(null),ae(null);let i;try{i=$e(o)}catch(s){K(t("Invalid NDJSON: {message}",{message:oe(s)})),B(!1);return}try{const s=await a.query(ve,{rows:i},de(r));pe(r),te(s),g(Z.readTablePage),g(Z.listTables)}catch(s){K(oe(s))}B(!1)},e[3]=a,e[4]=g,e[5]=o,e[6]=r,e[7]=t,e[8]=V):V=e[8];const G=V;let w,y,S,d,I,m,p,v,j,f,$;if(e[9]!==c||e[10]!==N||e[11]!==z||e[12]!==n||e[13]!==G||e[14]!==o||e[15]!==r||e[16]!==t){const i=n===null?0:Object.values(n.inserted).reduce(Ee,0);let s;e[28]!==z?(s=()=>{me(z())},e[28]=z,e[29]=s):s=e[29];const re=s;let X;e[30]!==G?(X=()=>{me(G())},e[30]=G,e[31]=X):X=e[31];const le=X;let Y;e[32]===Symbol.for("react.memo_cache_sentinel")?(Y=b=>{se(b.target.value)},e[32]=Y):Y=e[32];const ue=Y;$="flex flex-col gap-4",S="lunora-export-import";let C;e[33]!==t?(C=t("Export"),e[33]=t,e[34]=C):C=e[34];let T;e[35]!==C?(T=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:C})}),e[35]=C,e[36]=T):T=e[36];let L;e[37]!==r?(L=l(ge,{onChange:x,testId:"ei-shard-input",value:r}),e[37]=r,e[38]=L):L=e[38];let J;e[39]!==t?(J=t("Export"),e[39]=t,e[40]=J):J=e[40];let R;e[41]!==c||e[42]!==re||e[43]!==J?(R=l(Ne,{"data-testid":"ei-export",disabled:c,onClick:re,type:"button",children:J}),e[41]=c,e[42]=re,e[43]=J,e[44]=R):R=e[44];let _;e[45]!==L||e[46]!==R?(_=h("div",{className:"flex flex-wrap items-center gap-2",children:[L,R]}),e[45]=L,e[46]=R,e[47]=_):_=e[47];let k;e[48]!==N||e[49]!==t?(k=N!==null&&l("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:t("Exported {count} rows.",{count:N})}),e[48]=N,e[49]=t,e[50]=k):k=e[50];let D;e[51]!==_||e[52]!==k?(D=h(ie,{className:"flex flex-col gap-3 p-4",children:[_,k]}),e[51]=_,e[52]=k,e[53]=D):D=e[53],e[54]!==T||e[55]!==D?(d=h(ce,{className:"rounded-xl border border-border bg-card shadow-xs",children:[T,D]}),e[54]=T,e[55]=D,e[56]=d):d=e[56],y=ce,j="rounded-xl border border-border bg-card shadow-xs";let F;e[57]!==t?(F=t("Import"),e[57]=t,e[58]=F):F=e[58],e[59]!==F?(f=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:F})}),e[59]=F,e[60]=f):f=e[60],w=ie,I="flex flex-col gap-3 p-4",e[61]!==o?(m=l(we,{"aria-label":"NDJSON",className:"font-mono text-xs min-h-40 rounded-md","data-testid":"ei-ndjson",onChange:ue,placeholder:'{"table":"messages","doc":{…}}',value:o}),e[61]=o,e[62]=m):m=e[62];let M;e[63]!==t?(M=t("Import (writes rows)?"),e[63]=t,e[64]=M):M=e[64];let P;e[65]!==c||e[66]!==o?(P=c||o.trim()==="",e[65]=c,e[66]=o,e[67]=P):P=e[67];let U;e[68]!==t?(U=t("Import"),e[68]=t,e[69]=U):U=e[69],e[70]!==le||e[71]!==M||e[72]!==P||e[73]!==U?(p=l("div",{className:"flex flex-wrap items-center gap-2",children:l(he,{confirmLabel:M,disabled:P,onConfirm:le,testId:"ei-import",children:U})}),e[70]=le,e[71]=M,e[72]=P,e[73]=U,e[74]=p):p=e[74],v=n!==null&&h("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[l("p",{className:"text-sm text-muted-foreground",children:t("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:n.conflicts,errors:n.errors.length,inserted:i})}),n.errors.length>0&&l("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:n.errors.map(b=>l("li",{className:"text-xs text-destructive",children:t("line {line} ({table}): {message}",{line:b.line,message:b.message,table:b.table})},`${b.table}-${b.line.toString()}`))})]}),e[9]=c,e[10]=N,e[11]=z,e[12]=n,e[13]=G,e[14]=o,e[15]=r,e[16]=t,e[17]=w,e[18]=y,e[19]=S,e[20]=d,e[21]=I,e[22]=m,e[23]=p,e[24]=v,e[25]=j,e[26]=f,e[27]=$}else w=e[17],y=e[18],S=e[19],d=e[20],I=e[21],m=e[22],p=e[23],v=e[24],j=e[25],f=e[26],$=e[27];let E;e[75]!==w||e[76]!==I||e[77]!==m||e[78]!==p||e[79]!==v?(E=h(w,{className:I,children:[m,p,v]}),e[75]=w,e[76]=I,e[77]=m,e[78]=p,e[79]=v,e[80]=E):E=e[80];let O;e[81]!==y||e[82]!==E||e[83]!==j||e[84]!==f?(O=h(y,{className:j,children:[f,E]}),e[81]=y,e[82]=E,e[83]=j,e[84]=f,e[85]=O):O=e[85];let A;e[86]!==H?(A=H!==null&&l("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:H}),e[86]=H,e[87]=A):A=e[87];let W;return e[88]!==S||e[89]!==d||e[90]!==O||e[91]!==A||e[92]!==$?(W=h("div",{className:$,"data-testid":S,children:[d,O,A]}),e[88]=S,e[89]=d,e[90]=O,e[91]=A,e[92]=$,e[93]=W):W=e[93],W};function Ee(u,e){return u+e}export{Be as ExportImportPanel};
@@ -1,4 +1,4 @@
1
- import{c as M}from"react/compiler-runtime";import{useState as E,useEffect as le,useRef as he,useMemo as fe,useCallback as nt}from"react";import{ShardInput as ot}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as se}from"../packem_shared/button-BkCrNcAs.js";import{E as Se}from"../packem_shared/empty-state-Cg7t_8qu.js";import{useT as lt}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{z as st}from"../packem_shared/grid-features-Db_BNYRo.js";import{c as at,u as it}from"../packem_shared/card-CIDGUN6K.js";import{f as Ne}from"../packem_shared/checkbox-StT4Gob6.js";import{p as oe,d as ct,m as me,f as dt,n as ut,u as te}from"../packem_shared/table-DdJBrClo.js";import{l as Ce,f as q,b as ee,d as xe,g as $e,c as ft}from"../packem_shared/internal-zkEvTqy8.js";import{ConfirmButton as ht}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{g as ce}from"../packem_shared/badge-BbuuAio7.js";import{jsx as s,jsxs as T,Fragment as je}from"react/jsx-runtime";import{u as mt}from"../packem_shared/input-JHu63lTv.js";import{d as pt}from"../packem_shared/cf-links-Dmg86v1D.js";import{useLunora as gt}from"@lunora/react";import{useAutoRefresh as bt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";const Ke=(d,e,t)=>{const{onCopy:r,onDelete:l,onDownload:n,onToggleSelect:c}=t,i=()=>{r(d.key)},o=()=>{n(d.key)},u=()=>{l(d.key)},h=()=>{c(d.key)};return{copy:i,download:o,name:d.key.slice(e.length),remove:u,toggle:h}},De=d=>{const e=M(31),{busy:t,buttonClassName:r,copied:l,objectKey:n,onCopy:c,onDelete:i,onDownload:o,t:u}=d,h=`storage-copy-${n}`;let f;e[0]!==l||e[1]!==u?(f=u(l?"Copied":"Copy URL"),e[0]=l,e[1]=u,e[2]=f):f=e[2];let m;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==h||e[7]!==f?(m=s(se,{className:r,"data-testid":h,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=h,e[7]=f,e[8]=m):m=e[8];const k=`storage-download-${n}`;let a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let v;e[11]!==t||e[12]!==r||e[13]!==o||e[14]!==k||e[15]!==a?(v=s(se,{className:r,"data-testid":k,disabled:t,onClick:o,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=o,e[14]=k,e[15]=a,e[16]=v):v=e[16];let S;e[17]!==u?(S=u("Delete object?"),e[17]=u,e[18]=S):S=e[18];const y=`storage-delete-${n}`;let g;e[19]!==u?(g=u("Delete"),e[19]=u,e[20]=g):g=e[20];let x;e[21]!==t||e[22]!==i||e[23]!==S||e[24]!==y||e[25]!==g?(x=s(ht,{confirmLabel:S,disabled:t,onConfirm:i,testId:y,children:g}),e[21]=t,e[22]=i,e[23]=S,e[24]=y,e[25]=g,e[26]=x):x=e[26];let b;return e[27]!==x||e[28]!==m||e[29]!==v?(b=T(je,{children:[m,v,x]}),e[27]=x,e[28]=m,e[29]=v,e[30]=b):b=e[30],b},Te=d=>{const e=M(14),{objectKey:t,references:r,t:l}=d;if(r===void 0)return null;if(r.length===0){const h=`storage-orphan-${t}`;let f;e[0]!==l?(f=l("Orphan"),e[0]=l,e[1]=f):f=e[1];let m;return e[2]!==h||e[3]!==f?(m=s(ce,{"data-testid":h,variant:"warning",children:f}),e[2]=h,e[3]=f,e[4]=m):m=e[4],m}let n;e[5]!==r?(n=r.map(yt).join(`
1
+ import{c as M}from"react/compiler-runtime";import{useState as E,useEffect as le,useRef as he,useMemo as fe,useCallback as nt}from"react";import{ShardInput as ot}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as se}from"../packem_shared/button-BkCrNcAs.js";import{E as Se}from"../packem_shared/empty-state-Cg7t_8qu.js";import{useT as lt}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{z as st}from"../packem_shared/grid-features-Y2YSjhCf.js";import{c as at,f as it}from"../packem_shared/card-BMKx5UdA.js";import{f as Ne}from"../packem_shared/checkbox-StT4Gob6.js";import{m as oe,n as ct,f as me,b as dt,d as ut,p as te}from"../packem_shared/table-DZAB8cs3.js";import{l as Ce,f as q,b as ee,d as xe,g as $e,c as ft}from"../packem_shared/internal-zkEvTqy8.js";import{ConfirmButton as ht}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{g as ce}from"../packem_shared/badge-BbuuAio7.js";import{jsx as s,jsxs as T,Fragment as je}from"react/jsx-runtime";import{u as mt}from"../packem_shared/input-JHu63lTv.js";import{d as pt}from"../packem_shared/cf-links-Dmg86v1D.js";import{useLunora as gt}from"@lunora/react";import{useAutoRefresh as bt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";const Ke=(d,e,t)=>{const{onCopy:r,onDelete:l,onDownload:n,onToggleSelect:c}=t,i=()=>{r(d.key)},o=()=>{n(d.key)},u=()=>{l(d.key)},h=()=>{c(d.key)};return{copy:i,download:o,name:d.key.slice(e.length),remove:u,toggle:h}},De=d=>{const e=M(31),{busy:t,buttonClassName:r,copied:l,objectKey:n,onCopy:c,onDelete:i,onDownload:o,t:u}=d,h=`storage-copy-${n}`;let f;e[0]!==l||e[1]!==u?(f=u(l?"Copied":"Copy URL"),e[0]=l,e[1]=u,e[2]=f):f=e[2];let m;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==h||e[7]!==f?(m=s(se,{className:r,"data-testid":h,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=h,e[7]=f,e[8]=m):m=e[8];const k=`storage-download-${n}`;let a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let v;e[11]!==t||e[12]!==r||e[13]!==o||e[14]!==k||e[15]!==a?(v=s(se,{className:r,"data-testid":k,disabled:t,onClick:o,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=o,e[14]=k,e[15]=a,e[16]=v):v=e[16];let S;e[17]!==u?(S=u("Delete object?"),e[17]=u,e[18]=S):S=e[18];const y=`storage-delete-${n}`;let g;e[19]!==u?(g=u("Delete"),e[19]=u,e[20]=g):g=e[20];let x;e[21]!==t||e[22]!==i||e[23]!==S||e[24]!==y||e[25]!==g?(x=s(ht,{confirmLabel:S,disabled:t,onConfirm:i,testId:y,children:g}),e[21]=t,e[22]=i,e[23]=S,e[24]=y,e[25]=g,e[26]=x):x=e[26];let b;return e[27]!==x||e[28]!==m||e[29]!==v?(b=T(je,{children:[m,v,x]}),e[27]=x,e[28]=m,e[29]=v,e[30]=b):b=e[30],b},Te=d=>{const e=M(14),{objectKey:t,references:r,t:l}=d;if(r===void 0)return null;if(r.length===0){const h=`storage-orphan-${t}`;let f;e[0]!==l?(f=l("Orphan"),e[0]=l,e[1]=f):f=e[1];let m;return e[2]!==h||e[3]!==f?(m=s(ce,{"data-testid":h,variant:"warning",children:f}),e[2]=h,e[3]=f,e[4]=m):m=e[4],m}let n;e[5]!==r?(n=r.map(yt).join(`
2
2
  `),e[5]=r,e[6]=n):n=e[6];const c=n,i=`storage-refs-${t}`;let o;e[7]!==r.length||e[8]!==l?(o=r.length===1?l("1 record"):l("{count} records",{count:r.length}),e[7]=r.length,e[8]=l,e[9]=o):o=e[9];let u;return e[10]!==c||e[11]!==i||e[12]!==o?(u=s(ce,{"data-testid":i,title:c,variant:"secondary",children:o}),e[10]=c,e[11]=i,e[12]=o,e[13]=u):u=e[13],u},Fe=d=>{const e=M(7),{objectKey:t,onToggle:r,selected:l,t:n}=d;let c;e[0]!==n?(c=n("Select row"),e[0]=n,e[1]=c):c=e[1];const i=`storage-select-${t}`;let o;return e[2]!==r||e[3]!==l||e[4]!==c||e[5]!==i?(o=s(Ne,{"aria-label":c,checked:l,"data-testid":i,onCheckedChange:r}),e[2]=r,e[3]=l,e[4]=c,e[5]=i,e[6]=o):o=e[6],o};function yt(d){return`${d.table}·${d.id}`}const xt=d=>{const e=M(10),{colSpan:t,name:r,onEnter:l}=d;let n;e[0]!==r||e[1]!==l?(n=()=>{l(r)},e[0]=r,e[1]=l,e[2]=n):n=e[2];const c=n;let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=s("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=i):i=e[3];let o;e[4]!==c||e[5]!==r?(o=T("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:c,type:"button",children:[i,r]}),e[4]=c,e[5]=r,e[6]=o):o=e[6];let u;return e[7]!==t||e[8]!==o?(u=s(me,{children:s(te,{colSpan:t,children:o})}),e[7]=t,e[8]=o,e[9]=u):u=e[9],u},vt=d=>{const e=M(37),{busy:t,copiedKey:r,handlers:l,object:n,prefix:c,references:i,selected:o,showReferences:u,t:h}=d;let f;e[0]!==l||e[1]!==n||e[2]!==c?(f=Ke(n,c,l),e[0]=l,e[1]=n,e[2]=c,e[3]=f):f=e[3];const{copy:m,download:k,name:a,remove:v,toggle:S}=f;let y;e[4]!==n.key||e[5]!==o||e[6]!==h||e[7]!==S?(y=s(te,{className:"w-8",children:s(Fe,{objectKey:n.key,onToggle:S,selected:o,t:h})}),e[4]=n.key,e[5]=o,e[6]=h,e[7]=S,e[8]=y):y=e[8];let g;e[9]!==a?(g=s(te,{className:"font-mono text-xs",children:a}),e[9]=a,e[10]=g):g=e[10];let x;e[11]!==n.size?(x=Ce(n.size),e[11]=n.size,e[12]=x):x=e[12];let b;e[13]!==x?(b=s(te,{className:"tabular-nums text-muted-foreground",children:x}),e[13]=x,e[14]=b):b=e[14];const C=n.httpMetadata?.contentType??"";let w;e[15]!==C?(w=s(te,{children:C}),e[15]=C,e[16]=w):w=e[16];let N;e[17]!==n.key||e[18]!==i||e[19]!==u||e[20]!==h?(N=u&&s(te,{children:s(Te,{objectKey:n.key,references:i,t:h})}),e[17]=n.key,e[18]=i,e[19]=u,e[20]=h,e[21]=N):N=e[21];const z=r===n.key;let $;e[22]!==t||e[23]!==m||e[24]!==k||e[25]!==n.key||e[26]!==v||e[27]!==h||e[28]!==z?($=s(te,{className:"text-right",children:s("span",{className:"inline-flex items-center gap-1",children:s(De,{busy:t,copied:z,objectKey:n.key,onCopy:m,onDelete:v,onDownload:k,t:h})})}),e[22]=t,e[23]=m,e[24]=k,e[25]=n.key,e[26]=v,e[27]=h,e[28]=z,e[29]=$):$=e[29];let D;return e[30]!==$||e[31]!==y||e[32]!==g||e[33]!==b||e[34]!==w||e[35]!==N?(D=T(me,{"data-testid":"fb-row",children:[y,g,b,w,N,$]}),e[30]=$,e[31]=y,e[32]=g,e[33]=b,e[34]=w,e[35]=N,e[36]=D):D=e[36],D},kt=d=>{const e=M(65),{allSelected:t,busy:r,copiedKey:l,files:n,folders:c,handlers:i,onEnterFolder:o,prefix:u,references:h,selected:f,showReferences:m,someSelected:k,t:a,toggleSelectAll:v}=d;let S;e[0]!==a?(S=a("Select all rows"),e[0]=a,e[1]=S):S=e[1];let y;e[2]!==t||e[3]!==k||e[4]!==S||e[5]!==v?(y=s(oe,{className:"w-8",children:s(Ne,{"aria-label":S,checked:t,"data-testid":"storage-select-all",indeterminate:k,onCheckedChange:v})}),e[2]=t,e[3]=k,e[4]=S,e[5]=v,e[6]=y):y=e[6];let g;e[7]!==a?(g=a("key"),e[7]=a,e[8]=g):g=e[8];let x;e[9]!==g?(x=s(oe,{children:g}),e[9]=g,e[10]=x):x=e[10];let b;e[11]!==a?(b=a("size"),e[11]=a,e[12]=b):b=e[12];let C;e[13]!==b?(C=s(oe,{children:b}),e[13]=b,e[14]=C):C=e[14];let w;e[15]!==a?(w=a("content-type"),e[15]=a,e[16]=w):w=e[16];let N;e[17]!==w?(N=s(oe,{children:w}),e[17]=w,e[18]=N):N=e[18];let z;e[19]!==m||e[20]!==a?(z=m&&s(oe,{children:a("used by")}),e[19]=m,e[20]=a,e[21]=z):z=e[21];let $;e[22]!==a?($=a("Actions"),e[22]=a,e[23]=$):$=e[23];let D;e[24]!==$?(D=s(oe,{"aria-label":$}),e[24]=$,e[25]=D):D=e[25];let K;e[26]!==D||e[27]!==y||e[28]!==x||e[29]!==C||e[30]!==N||e[31]!==z?(K=s(ct,{children:T(me,{children:[y,x,C,N,z,D]})}),e[26]=D,e[27]=y,e[28]=x,e[29]=C,e[30]=N,e[31]=z,e[32]=K):K=e[32];let F;if(e[33]!==c||e[34]!==o||e[35]!==m){let R;e[37]!==o||e[38]!==m?(R=O=>s(xt,{colSpan:m?6:5,name:O,onEnter:o},O),e[37]=o,e[38]=m,e[39]=R):R=e[39],F=c.map(R),e[33]=c,e[34]=o,e[35]=m,e[36]=F}else F=e[36];let U;if(e[40]!==r||e[41]!==l||e[42]!==n||e[43]!==i||e[44]!==u||e[45]!==h||e[46]!==f||e[47]!==m||e[48]!==a){let R;e[50]!==r||e[51]!==l||e[52]!==i||e[53]!==u||e[54]!==h||e[55]!==f||e[56]!==m||e[57]!==a?(R=O=>s(vt,{busy:r,copiedKey:l,handlers:i,object:O,prefix:u,references:h[O.key],selected:f.has(O.key),showReferences:m,t:a},O.key),e[50]=r,e[51]=l,e[52]=i,e[53]=u,e[54]=h,e[55]=f,e[56]=m,e[57]=a,e[58]=R):R=e[58],U=n.map(R),e[40]=r,e[41]=l,e[42]=n,e[43]=i,e[44]=u,e[45]=h,e[46]=f,e[47]=m,e[48]=a,e[49]=U}else U=e[49];let L;e[59]!==F||e[60]!==U?(L=T(dt,{children:[F,U]}),e[59]=F,e[60]=U,e[61]=L):L=e[61];let B;return e[62]!==K||e[63]!==L?(B=s(at,{className:"overflow-hidden py-0",children:s(it,{className:"px-0",children:T(ut,{"data-testid":"fb-table",children:[K,L]})})}),e[62]=K,e[63]=L,e[64]=B):B=e[64],B},wt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],St=3600,ve=(d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;const t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},Nt=(d,e,t)=>{const r=t==="desc"?-1:1;return d.toSorted((l,n)=>{const c=ve(l,e),i=ve(n,e);return(typeof c=="number"&&typeof i=="number"?c-i:String(c).localeCompare(String(i)))*r})},Ct=(d,e)=>{const t=new Set,r=[];for(const l of d){const n=l.key.slice(e.length),c=n.indexOf("/");c===-1?r.push(l):t.add(n.slice(0,c+1))}return{files:r,folders:[...t].toSorted((l,n)=>l.localeCompare(n))}},$t=d=>{const e=M(59),{bucket:t,buckets:r,busy:l,draftPrefix:n,expiry:c,fileInputRef:i,onBucketChange:o,onExpiryChange:u,onFileChange:h,onList:f,onPrefixChange:m,onUploadClick:k,t:a}=d;let v;e[0]!==m?(v=P=>{m(P.target.value)},e[0]=m,e[1]=v):v=e[1];const S=v;let y;e[2]!==o?(y=P=>{o(P.target.value)},e[2]=o,e[3]=y):y=e[3];const g=y;let x;e[4]!==u?(x=P=>{u(Number.parseInt(P.target.value,10))},e[4]=u,e[5]=x):x=e[5];const b=x;let C;e[6]!==t||e[7]!==r||e[8]!==g||e[9]!==a?(C=r.length>0&&s("select",{"aria-label":a("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:g,value:t,children:r.map(zt)}),e[6]=t,e[7]=r,e[8]=g,e[9]=a,e[10]=C):C=e[10];let w;e[11]!==a?(w=a("Key prefix"),e[11]=a,e[12]=w):w=e[12];let N;e[13]!==a?(N=a("key prefix (optional)"),e[13]=a,e[14]=N):N=e[14];let z;e[15]!==n||e[16]!==S||e[17]!==w||e[18]!==N?(z=s(mt,{"aria-label":w,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:S,placeholder:N,value:n}),e[15]=n,e[16]=S,e[17]=w,e[18]=N,e[19]=z):z=e[19];let $;e[20]!==a?($=a("List"),e[20]=a,e[21]=$):$=e[21];let D;e[22]!==l||e[23]!==f||e[24]!==$?(D=s(se,{"data-testid":"fb-list",disabled:l,onClick:f,size:"sm",type:"button",children:$}),e[22]=l,e[23]=f,e[24]=$,e[25]=D):D=e[25];let K;e[26]!==l||e[27]!==a?(K=a(l?"Uploading…":"Upload"),e[26]=l,e[27]=a,e[28]=K):K=e[28];let F;e[29]!==l||e[30]!==k||e[31]!==K?(F=s(se,{"data-testid":"storage-upload",disabled:l,onClick:k,size:"sm",type:"button",variant:"outline",children:K}),e[29]=l,e[30]=k,e[31]=K,e[32]=F):F=e[32];let U;e[33]!==i||e[34]!==h?(U=s("input",{className:"hidden","data-testid":"storage-file-input",onChange:h,ref:i,type:"file"}),e[33]=i,e[34]=h,e[35]=U):U=e[35];let L;e[36]!==a?(L=a("Link expiry"),e[36]=a,e[37]=L):L=e[37];let B;e[38]!==a?(B=wt.map(P=>s("option",{value:P.seconds,children:a(P.label)},P.seconds)),e[38]=a,e[39]=B):B=e[39];let R;e[40]!==c||e[41]!==b||e[42]!==B?(R=s("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:b,value:c,children:B}),e[40]=c,e[41]=b,e[42]=B,e[43]=R):R=e[43];let O;e[44]!==L||e[45]!==R?(O=T("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[L,R]}),e[44]=L,e[45]=R,e[46]=O):O=e[46];let I;e[47]!==a?(I=a("Open in Cloudflare"),e[47]=a,e[48]=I):I=e[48];let A;e[49]!==I?(A=s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:pt,rel:"noreferrer",target:"_blank",children:I}),e[49]=I,e[50]=A):A=e[50];let W;return e[51]!==F||e[52]!==U||e[53]!==O||e[54]!==A||e[55]!==C||e[56]!==z||e[57]!==D?(W=T("div",{className:"flex flex-wrap items-center gap-2",children:[C,z,D,F,U,O,A]}),e[51]=F,e[52]=U,e[53]=O,e[54]=A,e[55]=C,e[56]=z,e[57]=D,e[58]=W):W=e[58],W},jt=d=>{const e=M(66),{onSortKeyChange:t,onThumbSizeChange:r,showGrid:l,showList:n,sortDirection:c,sortKey:i,t:o,tagKeys:u,thumbSize:h,toggleSortDirection:f,view:m}=d;let k;e[0]!==t?(k=Z=>{t(Z.target.value)},e[0]=t,e[1]=k):k=e[1];const a=k;let v;e[2]!==r?(v=Z=>{r(Number.parseInt(Z.target.value,10))},e[2]=r,e[3]=v):v=e[3];const S=v,y=m==="list";let g;e[4]!==o?(g=o("List"),e[4]=o,e[5]=g):g=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==g?(x=s("button",{"aria-pressed":y,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:n,type:"button",children:g}),e[6]=n,e[7]=y,e[8]=g,e[9]=x):x=e[9];const b=m==="grid";let C;e[10]!==o?(C=o("Grid"),e[10]=o,e[11]=C):C=e[11];let w;e[12]!==l||e[13]!==b||e[14]!==C?(w=s("button",{"aria-pressed":b,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:l,type:"button",children:C}),e[12]=l,e[13]=b,e[14]=C,e[15]=w):w=e[15];let N;e[16]!==x||e[17]!==w?(N=T("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[x,w]}),e[16]=x,e[17]=w,e[18]=N):N=e[18];let z;e[19]!==o?(z=o("Sort"),e[19]=o,e[20]=z):z=e[20];let $;e[21]!==o?($=o("Name"),e[21]=o,e[22]=$):$=e[22];let D;e[23]!==$?(D=s("option",{value:"name",children:$}),e[23]=$,e[24]=D):D=e[24];let K;e[25]!==o?(K=o("size"),e[25]=o,e[26]=K):K=e[26];let F;e[27]!==K?(F=s("option",{value:"size",children:K}),e[27]=K,e[28]=F):F=e[28];let U;e[29]!==o?(U=o("Type"),e[29]=o,e[30]=U):U=e[30];let L;e[31]!==U?(L=s("option",{value:"type",children:U}),e[31]=U,e[32]=L):L=e[32];let B;e[33]!==o?(B=o("Modified"),e[33]=o,e[34]=B):B=e[34];let R;e[35]!==B?(R=s("option",{value:"date",children:B}),e[35]=B,e[36]=R):R=e[36];let O;e[37]!==u?(O=u.map(Kt),e[37]=u,e[38]=O):O=e[38];let I;e[39]!==a||e[40]!==i||e[41]!==D||e[42]!==F||e[43]!==L||e[44]!==R||e[45]!==O?(I=T("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:a,value:i,children:[D,F,L,R,O]}),e[39]=a,e[40]=i,e[41]=D,e[42]=F,e[43]=L,e[44]=R,e[45]=O,e[46]=I):I=e[46];let A;e[47]!==z||e[48]!==I?(A=T("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[z,I]}),e[47]=z,e[48]=I,e[49]=A):A=e[49];let W;e[50]!==o?(W=o("Toggle sort direction"),e[50]=o,e[51]=W):W=e[51];const P=c==="asc"?"↑":"↓";let G;e[52]!==W||e[53]!==P||e[54]!==f?(G=s("button",{"aria-label":W,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:f,type:"button",children:P}),e[52]=W,e[53]=P,e[54]=f,e[55]=G):G=e[55];let Y;e[56]!==S||e[57]!==o||e[58]!==h||e[59]!==m?(Y=m==="grid"&&T("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[o("Thumbnail size"),s("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:S,step:8,type:"range",value:h})]}),e[56]=S,e[57]=o,e[58]=h,e[59]=m,e[60]=Y):Y=e[60];let re;return e[61]!==A||e[62]!==G||e[63]!==Y||e[64]!==N?(re=T("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[N,A,G,Y]}),e[61]=A,e[62]=G,e[63]=Y,e[64]=N,e[65]=re):re=e[65],re};function zt(d){return s("option",{value:d,children:d},d)}function Kt(d){return s("option",{value:`tag:${d}`,children:d},d)}const Dt=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,Tt=d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Dt.test(d.key),Ft=()=>{const d=M(1);let e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=s("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:s("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},Rt=d=>{const e=M(13),{object:t,resolveUrl:r}=d,[l,n]=E(null),[c,i]=E(!1);let o;e[0]!==t?(o=Tt(t),e[0]=t,e[1]=o):o=e[1];const u=o;let h,f;e[2]!==u||e[3]!==t.key||e[4]!==r?(h=()=>{if(!u)return;const v={cancelled:!1};return q((async()=>{try{const S=await r(t.key);v.cancelled||n(S)}catch{v.cancelled||i(!0)}})()),()=>{v.cancelled=!0}},f=[u,t.key,r],e[2]=u,e[3]=t.key,e[4]=r,e[5]=h,e[6]=f):(h=e[5],f=e[6]),le(h,f);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{i(!0)},e[7]=m):m=e[7];const k=m;let a;return e[8]!==c||e[9]!==u||e[10]!==t.key||e[11]!==l?(a=s("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:u&&l!==null&&!c?s("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:k,src:l}):s(Ft,{})}),e[8]=c,e[9]=u,e[10]=t.key,e[11]=l,e[12]=a):a=e[12],a},Lt=d=>{const e=M(42),{busy:t,copiedKey:r,handlers:l,object:n,prefix:c,references:i,resolveUrl:o,selected:u,showReferences:h,t:f}=d;let m;e[0]!==l||e[1]!==n||e[2]!==c?(m=Ke(n,c,l),e[0]=l,e[1]=n,e[2]=c,e[3]=m):m=e[3];const{copy:k,download:a,name:v,remove:S,toggle:y}=m;let g;e[4]!==n||e[5]!==o?(g=s(Rt,{object:n,resolveUrl:o}),e[4]=n,e[5]=o,e[6]=g):g=e[6];let x;e[7]!==n.key||e[8]!==u||e[9]!==f||e[10]!==y?(x=s("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:s(Fe,{objectKey:n.key,onToggle:y,selected:u,t:f})}),e[7]=n.key,e[8]=u,e[9]=f,e[10]=y,e[11]=x):x=e[11];let b;e[12]!==g||e[13]!==x?(b=T("div",{className:"relative",children:[g,x]}),e[12]=g,e[13]=x,e[14]=b):b=e[14];let C;e[15]!==v?(C=s("p",{className:"truncate font-mono text-xs",title:v,children:v}),e[15]=v,e[16]=C):C=e[16];let w;e[17]!==n.size?(w=Ce(n.size),e[17]=n.size,e[18]=w):w=e[18];let N;e[19]!==w?(N=s("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:w}),e[19]=w,e[20]=N):N=e[20];let z;e[21]!==n.key||e[22]!==i||e[23]!==h||e[24]!==f?(z=h&&s("div",{className:"mt-1",children:s(Te,{objectKey:n.key,references:i,t:f})}),e[21]=n.key,e[22]=i,e[23]=h,e[24]=f,e[25]=z):z=e[25];let $;e[26]!==C||e[27]!==N||e[28]!==z?($=T("div",{className:"min-w-0",children:[C,N,z]}),e[26]=C,e[27]=N,e[28]=z,e[29]=$):$=e[29];const D=r===n.key;let K;e[30]!==t||e[31]!==k||e[32]!==a||e[33]!==n.key||e[34]!==S||e[35]!==f||e[36]!==D?(K=s("div",{className:"flex items-center gap-1",children:s(De,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:D,objectKey:n.key,onCopy:k,onDelete:S,onDownload:a,t:f})}),e[30]=t,e[31]=k,e[32]=a,e[33]=n.key,e[34]=S,e[35]=f,e[36]=D,e[37]=K):K=e[37];let F;return e[38]!==K||e[39]!==b||e[40]!==$?(F=T("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[b,$,K]}),e[38]=K,e[39]=b,e[40]=$,e[41]=F):F=e[41],F},Ot=d=>{const e=M(9),{name:t,onEnter:r}=d;let l;e[0]!==t||e[1]!==r?(l=()=>{r(t)},e[0]=t,e[1]=r,e[2]=l):l=e[2];const n=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:s("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:s("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=c):c=e[3];let i;e[4]!==t?(i=s("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=i):i=e[5];let o;return e[6]!==n||e[7]!==i?(o=T("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:n,type:"button",children:[c,i]}),e[6]=n,e[7]=i,e[8]=o):o=e[8],o},Et=d=>{const e=M(34),{busy:t,copiedKey:r,files:l,folders:n,handlers:c,onEnterFolder:i,prefix:o,references:u,resolveUrl:h,selected:f,showReferences:m,size:k,t:a}=d;let v;e[0]!==k?(v=k.toString(),e[0]=k,e[1]=v):v=e[1];const S=`repeat(auto-fill, minmax(${v}px, 1fr))`;let y;e[2]!==S?(y={gridTemplateColumns:S},e[2]=S,e[3]=y):y=e[3];const g=y;let x;if(e[4]!==n||e[5]!==i){let w;e[7]!==i?(w=N=>s(Ot,{name:N,onEnter:i},N),e[7]=i,e[8]=w):w=e[8],x=n.map(w),e[4]=n,e[5]=i,e[6]=x}else x=e[6];let b;if(e[9]!==t||e[10]!==r||e[11]!==l||e[12]!==c||e[13]!==o||e[14]!==u||e[15]!==h||e[16]!==f||e[17]!==m||e[18]!==a){let w;e[20]!==t||e[21]!==r||e[22]!==c||e[23]!==o||e[24]!==u||e[25]!==h||e[26]!==f||e[27]!==m||e[28]!==a?(w=N=>s(Lt,{busy:t,copiedKey:r,handlers:c,object:N,prefix:o,references:u[N.key],resolveUrl:h,selected:f.has(N.key),showReferences:m,t:a},N.key),e[20]=t,e[21]=r,e[22]=c,e[23]=o,e[24]=u,e[25]=h,e[26]=f,e[27]=m,e[28]=a,e[29]=w):w=e[29],b=l.map(w),e[9]=t,e[10]=r,e[11]=l,e[12]=c,e[13]=o,e[14]=u,e[15]=h,e[16]=f,e[17]=m,e[18]=a,e[19]=b}else b=e[19];let C;return e[30]!==g||e[31]!==x||e[32]!==b?(C=T("div",{className:"grid gap-4","data-testid":"fb-gallery",style:g,children:[x,b]}),e[30]=g,e[31]=x,e[32]=b,e[33]=C):C=e[33],C},Ut=d=>{const e=M(23),{reference:t,t:r}=d,l=`fb-dangling-${t.table}-${t.id}-${t.column}`,n=`${t.table}·${t.id}`;let c;e[0]!==n?(c=s(ce,{variant:"secondary",children:n}),e[0]=n,e[1]=c):c=e[1];let i;e[2]!==t.column?(i=s("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=i):i=e[3];let o;e[4]!==r?(o=r("→"),e[4]=r,e[5]=o):o=e[5];let u;e[6]!==o?(u=s("span",{className:"text-muted-foreground/60",children:o}),e[6]=o,e[7]=u):u=e[7];let h;e[8]!==t.key?(h=s("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=h):h=e[9];let f;e[10]!==c||e[11]!==i||e[12]!==u||e[13]!==h?(f=T("span",{className:"flex flex-wrap items-center gap-1.5",children:[c,i,u,h]}),e[10]=c,e[11]=i,e[12]=u,e[13]=h,e[14]=f):f=e[14];let m;e[15]!==r?(m=r("Missing object"),e[15]=r,e[16]=m):m=e[16];let k;e[17]!==m?(k=s(ce,{className:"border-destructive/40 text-destructive",variant:"outline",children:m}),e[17]=m,e[18]=k):k=e[18];let a;return e[19]!==l||e[20]!==k||e[21]!==f?(a=T("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":l,children:[f,k]}),e[19]=l,e[20]=k,e[21]=f,e[22]=a):a=e[22],a},_t=d=>{const e=M(37),{busy:t,onCheck:r,references:l,t:n,truncated:c}=d;let i;e[0]!==n?(i=n("Integrity"),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==i?(o=s("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[2]=i,e[3]=o):o=e[3];let u;e[4]!==n?(u=n("Orphaned objects"),e[4]=n,e[5]=u):u=e[5];let h;e[6]!==u?(h=s("span",{className:"text-sm font-medium text-foreground",children:u}),e[6]=u,e[7]=h):h=e[7];let f;e[8]!==n?(f=n("Find records whose file reference points at an object the bucket no longer has."),e[8]=n,e[9]=f):f=e[9];let m;e[10]!==f?(m=s("span",{className:"text-xs text-muted-foreground",children:f}),e[10]=f,e[11]=m):m=e[11];let k;e[12]!==o||e[13]!==h||e[14]!==m?(k=T("div",{className:"flex flex-col gap-1",children:[o,h,m]}),e[12]=o,e[13]=h,e[14]=m,e[15]=k):k=e[15];let a;e[16]!==t||e[17]!==n?(a=n(t?"Checking…":"Check for orphans"),e[16]=t,e[17]=n,e[18]=a):a=e[18];let v;e[19]!==t||e[20]!==r||e[21]!==a?(v=s(se,{"data-testid":"fb-orphans-check",disabled:t,onClick:r,size:"sm",type:"button",variant:"outline",children:a}),e[19]=t,e[20]=r,e[21]=a,e[22]=v):v=e[22];let S;e[23]!==k||e[24]!==v?(S=T("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[k,v]}),e[23]=k,e[24]=v,e[25]=S):S=e[25];let y;e[26]!==l?.length||e[27]!==n?(y=l?.length===0&&s(Se,{description:n("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:n("No dangling references.")}),e[26]=l?.length,e[27]=n,e[28]=y):y=e[28];let g;e[29]!==l||e[30]!==n||e[31]!==c?(g=l!==void 0&&l.length>0&&T(je,{children:[c&&s("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:n("Showing the first {count} dangling references — the scan was truncated.",{count:l.length})}),s("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:l.map(b=>s(Ut,{reference:b,t:n},`${b.table}·${b.id}·${b.column}`))})]}),e[29]=l,e[30]=n,e[31]=c,e[32]=g):g=e[32];let x;return e[33]!==S||e[34]!==y||e[35]!==g?(x=T("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[S,y,g]}),e[33]=S,e[34]=y,e[35]=g,e[36]=x):x=e[36],x},Bt=function(d,e){const t=M(18);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[0]=r):r=t[0];const[l,n]=E(r);let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=y=>{n(g=>{const x=new Set(g);return x.has(y)?x.delete(y):x.add(y),x})},t[1]=c):c=t[1];const i=c;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{n(new Set)},t[2]=o):o=t[2];const u=o;let h,f,m;if(t[3]!==d||t[4]!==e||t[5]!==l){let y;t[9]!==e?(y=g=>e(g),t[9]=e,t[10]=y):y=t[10],f=d.map(y),h=f.length>0&&f.every(g=>l.has(g)),m=!h&&f.some(g=>l.has(g)),t[3]=d,t[4]=e,t[5]=l,t[6]=h,t[7]=f,t[8]=m}else h=t[6],f=t[7],m=t[8];const k=m;let a;t[11]!==f?(a=()=>{n(y=>f.every(g=>y.has(g))?new Set:new Set(f))},t[11]=f,t[12]=a):a=t[12];const v=a;let S;return t[13]!==h||t[14]!==l||t[15]!==k||t[16]!==v?(S={allSelected:h,clear:u,selected:l,someSelected:k,toggle:i,toggleAll:v},t[13]=h,t[14]=l,t[15]=k,t[16]=v,t[17]=S):S=t[17],S},It=$e(ze.storageReferences),Mt=$e(ze.storageOrphans),ke=1e4,At=1e3,Pt=3600,Wt=(d,e)=>{if(!("document"in globalThis))return;const t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},qt=d=>d.key,Gt=({initialPrefix:d,pageSize:e})=>{const t=gt(),[r,l]=E(d??""),[n,c]=E(d??""),[i,o]=E(St),[u,h]=E("list"),[f,m]=E(128),[k,a]=E("name"),[v,S]=E("asc"),[y,g]=E(void 0),[x,b]=E(void 0),[C,w]=E(!1),[N,z]=E(void 0),[$,D]=E(void 0),[K,F]=E(""),[U,L]=E({}),[B,R]=E(!1),[O,I]=E(void 0),[A,W]=E(!1),[P,G]=E(!1),[Y,re]=E([]),[Z,pe]=E(""),ne=he(0),Q=he(0);le(()=>{const p={cancelled:!1};return q((async()=>{try{const j=await t.listStorageBuckets();if(!p.cancelled){re(j);const[_]=j;_!==void 0&&pe(H=>H===""?_:H)}}catch{}})()),()=>{p.cancelled=!0}},[t]);const V=fe(()=>({list:p=>t.listStorageObjects({...p,bucket:Z}),remove:p=>t.deleteStorageObject(p,{bucket:Z}),signedUrl:(p,j)=>t.signedStorageUrl(p,{...j,bucket:Z}),upload:p=>t.uploadStorageObject({...p,bucket:Z})}),[Z,t]),X=nt(async(p,j,_)=>{ne.current+=1;const H=ne.current;b(void 0),w(!0);try{const J=await V.list({cursor:j,limit:e,prefix:p});if(H!==ne.current)return;g(ye=>_&&ye!==void 0?[...ye,...J.objects]:J.objects),D(J.cursor)}catch(J){if(H!==ne.current)return;_||g(void 0),b(ee(J))}finally{H===ne.current&&w(!1)}},[e,V]);le(()=>{q(X(d??"",void 0,!1))},[X,d]);const Re=(y?.length??0)<=e;bt(()=>{q(X(r,void 0,!1))},Re);const{files:de,folders:Le}=Ct(y??[],r),Oe=fe(()=>{const p=new Set;for(const j of de)for(const _ of Object.keys(j.customMetadata??{}))p.add(_);return[...p].toSorted((j,_)=>j.localeCompare(_))},[de]),ie=Nt(de,k,v),ue=fe(()=>[...new Set(ie.map(p=>p.key))].toSorted((p,j)=>p.localeCompare(j)).join(`
3
3
  `),[ie]);le(()=>{const p=ue===""?[]:ue.split(`
4
4
  `);if(p.length===0){L({});return}const j={current:!0};return q((async()=>{try{const _=await t.query(It,{keys:p},xe(K));j.current&&(L(_.references??{}),R(Object.keys(_.storageColumns??{}).length>0))}catch{j.current&&(L({}),R(!1))}})()),()=>{j.current=!1}},[t,ue,K]);const{allSelected:Ee,clear:ae,selected:ge,someSelected:Ue,toggle:_e,toggleAll:Be}=Bt(ie,qt),Ie=()=>{l(n),ae(),q(X(n,void 0,!1))},Me=()=>{q(X(r,$,!0))},be=p=>{l(p),c(p),ae(),q(X(p,void 0,!1))},Ae=p=>{be(`${r}${p}`)},Pe=p=>V.signedUrl(p,{expiresInSeconds:Pt}),We=()=>{h("list")},qe=()=>{h("grid")},Ge=p=>{a(p)},He=()=>{S(p=>p==="asc"?"desc":"asc")},Ze=p=>{m(p)},Ve=p=>{o(p)},Xe=()=>{b(void 0),w(!0),q((async()=>{try{for(const p of ge)await V.remove(p);await X(r,void 0,!1),ae()}catch(p){b(ee(p))}w(!1)})())},Ye=p=>{b(void 0),q((async()=>{try{const j=await V.signedUrl(p,{expiresInSeconds:i});ft(j)&&z(p)}catch(j){b(ee(j))}})())},Qe=p=>{b(void 0),q((async()=>{try{const j=await V.signedUrl(p,{expiresInSeconds:i}),_=p.slice(p.lastIndexOf("/")+1)||p;Wt(j,_)}catch(j){b(ee(j))}})())};le(()=>{if(N===void 0)return;const p=globalThis.setTimeout(()=>{z(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[N]);const Je=p=>{b(void 0),w(!0),q((async()=>{try{await V.remove(p),await X(r,void 0,!1)}catch(j){b(ee(j))}w(!1)})())},et=p=>{const j=`${r}${p.name}`;b(void 0),w(!0),q((async()=>{try{const _=await p.arrayBuffer();await V.upload({body:_,contentType:p.type===""?void 0:p.type,key:j}),await X(r,void 0,!1)}catch(_){b(ee(_))}w(!1)})())};le(()=>{Q.current+=1,I(void 0),G(!1)},[K]);const tt=()=>{Q.current+=1;const p=Q.current;b(void 0),W(!0),q((async()=>{try{const j=[];let _;do{const H=await V.list({cursor:_,limit:At});for(const J of H.objects)j.push(J.key);_=j.length>=ke?void 0:H.cursor}while(_!==void 0);if(j.length>=ke)p===Q.current&&(I([]),G(!0));else{const H=await t.query(Mt,{liveKeys:j},xe(K));p===Q.current&&(I(H.references??[]),G(H.truncated===!0))}}catch(j){p===Q.current&&(I([]),G(!1),b(ee(j)))}p===Q.current&&W(!1)})())},rt=p=>{ne.current+=1,Q.current+=1,pe(p),l(d??""),c(d??""),g(void 0),I(void 0),G(!1),ae()};return{allSelected:Ee,bucket:Z,buckets:Y,bulkDelete:Xe,busy:C,checkOrphans:tt,clearSelection:ae,copiedKey:N,danglingBusy:A,danglingReferences:O,danglingTruncated:P,draftPrefix:n,enterFolder:Ae,error:x,expiry:i,files:ie,folders:Le,hasObjects:y!==void 0&&y.length>0,hasStorageColumns:B,listFirst:Ie,loaded:y!==void 0,loadMore:Me,navigate:be,nextCursor:$,onCopy:Ye,onDelete:Je,onDownload:Qe,onExpiryChange:Ve,onFile:et,onSortKeyChange:Ge,onThumbSizeChange:Ze,prefix:r,referenceShard:K,references:U,resolveUrl:Pe,selectBucket:rt,selected:ge,setDraftPrefix:c,setReferenceShard:F,showGrid:qe,showList:We,someSelected:Ue,sortDirection:v,sortKey:k,tagKeys:Oe,thumbSize:f,toggleSelect:_e,toggleSelectAll:Be,toggleSortDirection:He,view:u}},Ht=100,we=d=>{const e=M(6),{label:t,onNavigate:r,target:l}=d;let n;e[0]!==r||e[1]!==l?(n=()=>{r(l)},e[0]=r,e[1]=l,e[2]=n):n=e[2];const c=n;let i;return e[3]!==c||e[4]!==t?(i=s("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:c,type:"button",children:t}),e[3]=c,e[4]=t,e[5]=i):i=e[5],i},Zt=d=>{const e=M(11),{onNavigate:t,prefix:r,t:l}=d;let n;if(e[0]!==t||e[1]!==r||e[2]!==l){const c=r.split("/").filter(Vt);let i;e[4]!==l?(i=l("Folder path"),e[4]=l,e[5]=i):i=e[5];let o;e[6]!==l?(o=l("root"),e[6]=l,e[7]=o):o=e[7];let u;e[8]!==t||e[9]!==o?(u=s(we,{label:o,onNavigate:t,target:""}),e[8]=t,e[9]=o,e[10]=u):u=e[10],n=T("nav",{"aria-label":i,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[u,c.map((h,f)=>T("span",{className:"flex items-center gap-0.5",children:[s("span",{className:"text-muted-foreground/50",children:"/"}),s(we,{label:h,onNavigate:t,target:`${c.slice(0,f+1).join("/")}/`})]},`${h}-${f.toString()}`))]}),e[0]=t,e[1]=r,e[2]=l,e[3]=n}else n=e[3];return n},pr=({initialPrefix:d,pageSize:e=Ht})=>{const t=lt(),r=Gt({initialPrefix:d,pageSize:e}),l=he(null),{onCopy:n,onDelete:c,onDownload:i,onFile:o,toggleSelect:u}=r,h={onCopy:n,onDelete:c,onDownload:i,onToggleSelect:u},f=()=>{l.current?.click()},m=a=>{const v=a.target,S=v.files?.[0];v.value="",S&&o(S)},k=r.loaded&&!r.hasObjects;return T("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[s($t,{bucket:r.bucket,buckets:r.buckets,busy:r.busy,draftPrefix:r.draftPrefix,expiry:r.expiry,fileInputRef:l,onBucketChange:r.selectBucket,onExpiryChange:r.onExpiryChange,onFileChange:m,onList:r.listFirst,onPrefixChange:r.setDraftPrefix,onUploadClick:f,t}),r.loaded&&s(Zt,{onNavigate:r.navigate,prefix:r.prefix,t}),r.hasObjects&&s(jt,{onSortKeyChange:r.onSortKeyChange,onThumbSizeChange:r.onThumbSizeChange,showGrid:r.showGrid,showList:r.showList,sortDirection:r.sortDirection,sortKey:r.sortKey,t,tagKeys:r.tagKeys,thumbSize:r.thumbSize,toggleSortDirection:r.toggleSortDirection,view:r.view}),r.hasStorageColumns&&T("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[s("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),s(ot,{id:"fb-reference-shard-input",onChange:r.setReferenceShard,testId:"fb-reference-shard-input",value:r.referenceShard}),s("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),r.hasStorageColumns&&s(_t,{busy:r.danglingBusy,onCheck:r.checkOrphans,references:r.danglingReferences,t,truncated:r.danglingTruncated}),r.selected.size>0&&s(st,{count:r.selected.size,editable:!0,onClear:r.clearSelection,onDelete:r.bulkDelete}),r.error!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:r.error}),k&&s(Se,{description:t("Objects you upload to your R2 buckets will appear here."),icon:T("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[s("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),s("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),r.hasObjects&&r.view==="list"&&s(kt,{allSelected:r.allSelected,busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:h,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,selected:r.selected,showReferences:r.hasStorageColumns,someSelected:r.someSelected,t,toggleSelectAll:r.toggleSelectAll}),r.hasObjects&&r.view==="grid"&&s(Et,{busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:h,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,resolveUrl:r.resolveUrl,selected:r.selected,showReferences:r.hasStorageColumns,size:r.thumbSize,t}),r.nextCursor!==void 0&&s("div",{children:s(se,{"data-testid":"fb-next",disabled:r.busy,onClick:r.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})};function Vt(d){return d!==""}export{pr as FileBrowser};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{useState as W}from"react";import{E as G}from"../packem_shared/error-alert--Ie7ofJ0.js";import{L as J}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as Q}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as V}from"../packem_shared/badge-BbuuAio7.js";import{u as X}from"../packem_shared/button-BkCrNcAs.js";import{c as Y,u as Z}from"../packem_shared/card-CIDGUN6K.js";import{E as ee}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as te,d as re,m as j,p as l,f as ae,u as n}from"../packem_shared/table-DdJBrClo.js";import{N as se}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as le}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as ne}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ie}from"../packem_shared/internal-zkEvTqy8.js";import{c as P}from"../packem_shared/utils-bhneXptQ.js";import{jsx as t,jsxs as y}from"react/jsx-runtime";const ce={action:"outline",mutation:"default",query:"secondary"},z=r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,de=r=>r.calls===0?"—":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,me=r=>{const e=r.conflicts??0;return r.calls===0?"—":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},ue={calls:(r,e)=>e.calls-r.calls,recent:(r,e)=>e.lastCalledAt-r.lastCalledAt,slowest:(r,e)=>e.maxDurationMs-r.maxDurationMs},Ae=r=>{const e=U(47),{functions:K,initialShardKey:O}=r,s=ne(),{queryShardKey:_,setShardKey:N,shardKey:v}=le(O),[o,R]=W("recent");let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={},e[0]=M):M=e[0];let w;e[1]!==_?(w={live:!0,shardKey:_},e[1]=_,e[2]=w):w=e[2];const{data:B,error:i,errorSource:$,liveError:S}=se(oe.getFunctionStats,M,w),k=B?.functions??null;let E;e[3]!==K?(E=new Map((K??[]).map(he)),e[3]=K,e[4]=E):E=e[4];const L=E;let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=b=>{R(b.currentTarget.dataset.sort)},e[5]=C):C=e[5];const H=C;let F;if(e[6]!==i||e[7]!==$||e[8]!==L||e[9]!==S||e[10]!==N||e[11]!==v||e[12]!==o||e[13]!==k||e[14]!==s){const b=k===null?[]:k.toSorted(ue[o]);let c;e[16]!==s?(c=s("Recent"),e[16]=s,e[17]=c):c=e[17];let d;e[18]!==c?(d={key:"recent",label:c},e[18]=c,e[19]=d):d=e[19];let m;e[20]!==s?(m=s("Most called"),e[20]=s,e[21]=m):m=e[21];let u;e[22]!==m?(u={key:"calls",label:m},e[22]=m,e[23]=u):u=e[23];let h;e[24]!==s?(h=s("Slowest"),e[24]=s,e[25]=h):h=e[25];let f;e[26]!==h?(f={key:"slowest",label:h},e[26]=h,e[27]=f):f=e[27];let I;e[28]!==f||e[29]!==d||e[30]!==u?(I=[d,u,f],e[28]=f,e[29]=d,e[30]=u,e[31]=I):I=e[31];const T=I;let p;e[32]!==N||e[33]!==v?(p=t(Q,{onChange:N,testId:"fs-shard-input",value:v}),e[32]=N,e[33]=v,e[34]=p):p=e[34];let x;e[35]!==S?(x=t(J,{message:S,prefix:"fs"}),e[35]=S,e[36]=x):x=e[36];let g;e[37]!==T||e[38]!==o?(g=t("div",{className:"ml-auto flex items-center gap-1",role:"group",children:T.map(a=>t(X,{"data-sort":a.key,"data-testid":`fs-sort-${a.key}`,onClick:H,size:"sm",type:"button",variant:o===a.key?"secondary":"ghost",children:a.label},a.key))}),e[37]=T,e[38]=o,e[39]=g):g=e[39];let A;e[40]!==p||e[41]!==x||e[42]!==g?(A=y("div",{className:"flex flex-wrap items-center gap-2",children:[p,x,g]}),e[40]=p,e[41]=x,e[42]=g,e[43]=A):A=e[43];let D;e[44]!==i||e[45]!==$?(D=i!==null&&t(G,{error:$,testId:"fs-error"}),e[44]=i,e[45]=$,e[46]=D):D=e[46],F=y("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[A,D,k!==null&&b.length===0&&i===null&&t(ee,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:y("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M3 3v18h18"}),t("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),b.length>0&&t(Y,{className:"overflow-hidden py-0",children:t(Z,{className:"px-0",children:y(te,{"data-testid":"fs-table",children:[t(re,{children:y(j,{children:[t(l,{children:s("function")}),t(l,{children:s("kind")}),t(l,{className:"text-right",children:s("calls")}),t(l,{className:"text-right",children:s("errors")}),t(l,{className:"text-right",children:s("conflicts")}),t(l,{className:"text-right",children:s("avg")}),t(l,{className:"text-right",children:s("max")}),t(l,{children:s("last run")}),t(l,{children:s("last error")})]})}),t(ae,{children:b.map(a=>{const q=L.get(a.path);return y(j,{"data-testid":`fs-row-${a.path}`,children:[t(n,{className:"font-medium",children:a.path}),t(n,{children:q===void 0?t("span",{className:"text-muted-foreground",children:"—"}):t(V,{variant:ce[q],children:q})}),t(n,{className:"text-right tabular-nums",children:a.calls}),t(n,{className:P("text-right tabular-nums",a.errors>0&&"text-destructive"),children:de(a)}),t(n,{className:P("text-right tabular-nums",(a.conflicts??0)>0&&"text-warning"),children:me(a)}),t(n,{className:"text-right tabular-nums",children:a.calls===0?"—":z(a.totalDurationMs/a.calls)}),t(n,{className:"text-right tabular-nums",children:a.calls===0?"—":z(a.maxDurationMs)}),t(n,{className:"text-muted-foreground",children:ie(a.lastCalledAt,"—")}),t(n,{className:"max-w-[24ch] truncate text-destructive",title:a.lastErrorMessage??void 0,children:a.lastErrorMessage??t("span",{className:"text-muted-foreground",children:"—"})})]},a.path)})})]})})})]}),e[6]=i,e[7]=$,e[8]=L,e[9]=S,e[10]=N,e[11]=v,e[12]=o,e[13]=k,e[14]=s,e[15]=F}else F=e[15];return F};function he(r){return[r.path,r.kind]}export{Ae as FunctionStatsPanel};
1
+ import{c as H}from"react/compiler-runtime";import{useState as W}from"react";import{U as G}from"../packem_shared/error-alert-_2q2VtVG.js";import{L as J}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as Q}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as V}from"../packem_shared/badge-BbuuAio7.js";import{u as X}from"../packem_shared/button-BkCrNcAs.js";import{c as Y,f as Z}from"../packem_shared/card-BMKx5UdA.js";import{E as ee}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as te,n as re,f as j,m as l,b as ae,p as n}from"../packem_shared/table-DZAB8cs3.js";import{N as se}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as le}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as ne}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ie}from"../packem_shared/internal-zkEvTqy8.js";import{c as P}from"../packem_shared/utils-bhneXptQ.js";import{jsx as t,jsxs as y}from"react/jsx-runtime";const ce={action:"outline",mutation:"default",query:"secondary"},z=r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,de=r=>r.calls===0?"—":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,me=r=>{const e=r.conflicts??0;return r.calls===0?"—":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},he={calls:(r,e)=>e.calls-r.calls,recent:(r,e)=>e.lastCalledAt-r.lastCalledAt,slowest:(r,e)=>e.maxDurationMs-r.maxDurationMs},De=r=>{const e=H(47),{functions:_,initialShardKey:O}=r,s=ne(),{queryShardKey:A,setShardKey:N,shardKey:v}=le(O),[o,R]=W("recent");let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={},e[0]=M):M=e[0];let w;e[1]!==A?(w={live:!0,shardKey:A},e[1]=A,e[2]=w):w=e[2];const{data:U,error:i,errorSource:$,liveError:S}=se(oe.getFunctionStats,M,w),b=U?.functions??null;let C;e[3]!==_?(C=new Map((_??[]).map(ue)),e[3]=_,e[4]=C):C=e[4];const L=C;let F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=k=>{R(k.currentTarget.dataset.sort)},e[5]=F):F=e[5];const B=F;let E;if(e[6]!==i||e[7]!==$||e[8]!==L||e[9]!==S||e[10]!==N||e[11]!==v||e[12]!==o||e[13]!==b||e[14]!==s){const k=b===null?[]:b.toSorted(he[o]);let c;e[16]!==s?(c=s("Recent"),e[16]=s,e[17]=c):c=e[17];let d;e[18]!==c?(d={key:"recent",label:c},e[18]=c,e[19]=d):d=e[19];let m;e[20]!==s?(m=s("Most called"),e[20]=s,e[21]=m):m=e[21];let h;e[22]!==m?(h={key:"calls",label:m},e[22]=m,e[23]=h):h=e[23];let u;e[24]!==s?(u=s("Slowest"),e[24]=s,e[25]=u):u=e[25];let f;e[26]!==u?(f={key:"slowest",label:u},e[26]=u,e[27]=f):f=e[27];let I;e[28]!==f||e[29]!==d||e[30]!==h?(I=[d,h,f],e[28]=f,e[29]=d,e[30]=h,e[31]=I):I=e[31];const T=I;let p;e[32]!==N||e[33]!==v?(p=t(Q,{onChange:N,testId:"fs-shard-input",value:v}),e[32]=N,e[33]=v,e[34]=p):p=e[34];let x;e[35]!==S?(x=t(J,{message:S,prefix:"fs"}),e[35]=S,e[36]=x):x=e[36];let g;e[37]!==T||e[38]!==o?(g=t("div",{className:"ml-auto flex items-center gap-1",role:"group",children:T.map(a=>t(X,{"data-sort":a.key,"data-testid":`fs-sort-${a.key}`,onClick:B,size:"sm",type:"button",variant:o===a.key?"secondary":"ghost",children:a.label},a.key))}),e[37]=T,e[38]=o,e[39]=g):g=e[39];let D;e[40]!==p||e[41]!==x||e[42]!==g?(D=y("div",{className:"flex flex-wrap items-center gap-2",children:[p,x,g]}),e[40]=p,e[41]=x,e[42]=g,e[43]=D):D=e[43];let K;e[44]!==i||e[45]!==$?(K=i!==null&&t(G,{error:$,testId:"fs-error"}),e[44]=i,e[45]=$,e[46]=K):K=e[46],E=y("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,K,b!==null&&k.length===0&&i===null&&t(ee,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:y("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M3 3v18h18"}),t("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),k.length>0&&t(Y,{className:"overflow-hidden py-0",children:t(Z,{className:"px-0",children:y(te,{"data-testid":"fs-table",children:[t(re,{children:y(j,{children:[t(l,{children:s("function")}),t(l,{children:s("kind")}),t(l,{className:"text-right",children:s("calls")}),t(l,{className:"text-right",children:s("errors")}),t(l,{className:"text-right",children:s("conflicts")}),t(l,{className:"text-right",children:s("avg")}),t(l,{className:"text-right",children:s("max")}),t(l,{children:s("last run")}),t(l,{children:s("last error")})]})}),t(ae,{children:k.map(a=>{const q=L.get(a.path);return y(j,{"data-testid":`fs-row-${a.path}`,children:[t(n,{className:"font-medium",children:a.path}),t(n,{children:q===void 0?t("span",{className:"text-muted-foreground",children:"—"}):t(V,{variant:ce[q],children:q})}),t(n,{className:"text-right tabular-nums",children:a.calls}),t(n,{className:P("text-right tabular-nums",a.errors>0&&"text-destructive"),children:de(a)}),t(n,{className:P("text-right tabular-nums",(a.conflicts??0)>0&&"text-warning"),children:me(a)}),t(n,{className:"text-right tabular-nums",children:a.calls===0?"—":z(a.totalDurationMs/a.calls)}),t(n,{className:"text-right tabular-nums",children:a.calls===0?"—":z(a.maxDurationMs)}),t(n,{className:"text-muted-foreground",children:ie(a.lastCalledAt,"—")}),t(n,{className:"max-w-[24ch] truncate text-destructive",title:a.lastErrorMessage??void 0,children:a.lastErrorMessage??t("span",{className:"text-muted-foreground",children:"—"})})]},a.path)})})]})})})]}),e[6]=i,e[7]=$,e[8]=L,e[9]=S,e[10]=N,e[11]=v,e[12]=o,e[13]=b,e[14]=s,e[15]=E}else E=e[15];return E};function ue(r){return[r.path,r.kind]}export{De as FunctionStatsPanel};
@@ -1 +1 @@
1
- import{c as ae}from"react/compiler-runtime";import{useLunora as pe}from"@lunora/react";import{useState as w,useRef as F,useEffect as L,useCallback as ge}from"react";import xe from"../packem_shared/ConnectionBadge-DOk0CQWo.js";import{L as ve}from"../packem_shared/live-status-CmuRLFKf.js";import{g as z}from"../packem_shared/badge-BbuuAio7.js";import{c as A}from"../packem_shared/card-CIDGUN6K.js";import{N as be}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as Ne,f as G,d as ee,b as te,g as j}from"../packem_shared/internal-zkEvTqy8.js";import{l as ye}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as $}from"../packem_shared/utils-bhneXptQ.js";import{jsx as l,jsxs as d}from"react/jsx-runtime";import{shardsToAggregate as we}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{S as Q}from"../packem_shared/sparkline-CgjeUU2I.js";const ke={crit:"destructive",ok:"secondary",warn:"default"},_=(s,e)=>e===0?"—":`${(s/e*100).toFixed(1)}%`,V=(s,e,r)=>Number.isNaN(s)?"ok":s>=r?"crit":s>=e?"warn":"ok",ne=.01,oe=.05,Se=s=>{const e=ae(36),{errorCount:r,logsError:t,topErrors:a,worstFunctions:h}=s,o=le();let n;e[0]!==o?(n=o("Functions by error rate"),e[0]=o,e[1]=n):n=e[1];let f;e[2]!==n?(f=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=f):f=e[3];let m;e[4]!==o||e[5]!==h?(m=h.length===0?l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:o("No function activity yet.")}):l("ul",{className:"divide-y divide-border",children:h.map(N=>d("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[l("span",{className:"truncate font-mono text-foreground",children:N.path}),d("span",{className:"flex shrink-0 items-center gap-2",children:[l("span",{className:"tabular-nums text-muted-foreground",children:o("{count} calls",{count:N.calls.toString()})}),l(z,{variant:ke[V(N.errors/N.calls,ne,oe)],children:_(N.errors,N.calls)})]})]},N.path))}),e[4]=o,e[5]=h,e[6]=m):m=e[6];let p;e[7]!==f||e[8]!==m?(p=d(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[f,m]}),e[7]=f,e[8]=m,e[9]=p):p=e[9];let v;e[10]!==o?(v=o("Recent errors"),e[10]=o,e[11]=v):v=e[11];let i;e[12]!==v?(i=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=i):i=e[13];const c=r>0?"destructive":"outline";let g;e[14]!==r||e[15]!==c?(g=l(z,{"data-testid":"hl-error-count",variant:c,children:r}),e[14]=r,e[15]=c,e[16]=g):g=e[16];let x;e[17]!==i||e[18]!==g?(x=d("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[i,g]}),e[17]=i,e[18]=g,e[19]=x):x=e[19];let k;e[20]!==t?(k=t!==null&&l("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:t}),e[20]=t,e[21]=k):k=e[21];let S;e[22]!==t||e[23]!==o||e[24]!==a.length?(S=t===null&&a.length===0&&l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:o("No recent errors.")}),e[22]=t,e[23]=o,e[24]=a.length,e[25]=S):S=e[25];let q;e[26]!==a?(q=a.length>0&&l("ul",{className:"divide-y divide-border",children:a.map(qe)}),e[26]=a,e[27]=q):q=e[27];let b;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==x?(b=d(A,{className:"gap-0 py-0",children:[x,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=x,e[32]=b):b=e[32];let y;return e[33]!==b||e[34]!==p?(y=d("div",{className:"grid gap-3 lg:grid-cols-2",children:[p,b]}),e[33]=b,e[34]=p,e[35]=y):y=e[35],y};function qe(s,e){return d("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[d("span",{className:"flex items-center gap-2",children:[l("time",{className:"shrink-0 text-muted-foreground",children:Ne(s.timestamp)}),s.functionPath!==void 0&&l("span",{className:"truncate font-mono text-foreground",children:s.functionPath})]}),l("span",{className:"text-destructive",children:s.message})]},`${s.timestamp.toString()}-${e.toString()}`)}const re={completed:0,failed:2,in_progress:1},Ee=s=>{let e=0,r=0,t=0,a=0,h=!1;const o=[];for(const{metrics:n}of s){if(n===null){a+=1;continue}t+=1,e+=n.requests,r+=n.errors,o.push(...n.history??[]),h||=n.historyTruncated===!0}return{errors:r,failed:a,history:o,historyTruncated:h,reachable:t,requests:e}},Me=s=>{const e=new Map;for(const r of s)for(const t of r){const a=e.get(t.path);if(a===void 0){e.set(t.path,{...t});continue}a.calls+=t.calls,a.errors+=t.errors,a.totalDurationMs+=t.totalDurationMs,a.scans=(a.scans??0)+(t.scans??0),a.maxDurationMs=Math.max(a.maxDurationMs,t.maxDurationMs),a.lastCalledAt=Math.max(a.lastCalledAt,t.lastCalledAt),(t.lastErrorAt??0)>(a.lastErrorAt??0)&&(a.lastErrorAt=t.lastErrorAt,a.lastErrorMessage=t.lastErrorMessage)}return[...e.values()]},$e=s=>{const e=new Map;for(const r of s)for(const t of r){const a=e.get(t.id);if(a===void 0){e.set(t.id,t);continue}const h=re[t.status]-re[a.status];(h>0||h===0&&(t.updatedAt??0)>(a.updatedAt??0))&&e.set(t.id,t)}return[...e.values()]},Ae=j(E.getAuthMetrics),je=j(E.getFunctionStats),Ie=j(E.getLogs),Te=j(E.getMetrics),Pe=j(E.migrationStatus),Re=5,se=2e3,Ce=5,De=.1,Fe=.3,Le=1,Oe=50,_e=(s,e,r)=>s>=r?"crit":s>=e?"warn":"ok",ze=s=>{const e=new Map;for(const t of s??[]){const a=e.get(t.bucketMs)??{calls:0,errors:0};a.calls+=t.calls,a.errors+=t.errors,e.set(t.bucketMs,a)}const r=[...e.entries()].toSorted((t,a)=>t[0]-a[0]);return{errors:r.map(([,t])=>t.errors),requests:r.map(([,t])=>t.calls)}},Ke=s=>{let e=0,r=0;for(const a of s)a.status==="failed"?e+=1:a.status==="in_progress"&&(r+=1);let t="ok";return e>0?t="crit":r>0&&(t="warn"),{failed:e,level:t,running:r}},He=(s,e)=>s.failed>0?e("{count} failed",{count:s.failed.toString()}):s.running>0?e("{count} running",{count:s.running.toString()}):e("OK"),ie={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ce={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Ue={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Be=s=>s.includes("crit")?"crit":s.includes("warn")?"warn":"ok",O=s=>{const e=ae(19),{chart:r,label:t,level:a,testId:h,value:o}=s,n=ie[a];let f;e[0]!==n?(f=$("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=f):f=e[1];let m;e[2]!==f?(m=l("span",{"aria-hidden":"true",className:f}),e[2]=f,e[3]=m):m=e[3];let p;e[4]!==t||e[5]!==m?(p=d("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,t]}),e[4]=t,e[5]=m,e[6]=p):p=e[6];const v=ce[a];let i;e[7]!==v?(i=$("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=i):i=e[8];let c;e[9]!==i||e[10]!==h||e[11]!==o?(c=l("span",{className:i,"data-testid":h,children:o}),e[9]=i,e[10]=h,e[11]=o,e[12]=c):c=e[12];let g;e[13]!==r||e[14]!==c?(g=d("div",{className:"flex items-center justify-between gap-3",children:[c,r]}),e[13]=r,e[14]=c,e[15]=g):g=e[15];let x;return e[16]!==p||e[17]!==g?(x=l(A,{className:"gap-0 py-0",children:d("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]})}),e[16]=p,e[17]=g,e[18]=x):x=e[18],x},Ge=async(s,e,r)=>{const t=await Promise.all(r.map(i=>{const c=ee(i);return Promise.allSettled([s.query(Te,{},c),s.query(je,{},c),s.query(Pe,{},c)])})),a=ee(e),h=typeof s.schedulerStatus=="function"?s.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[o,n,f]=await Promise.allSettled([s.query(Ie,{},a),s.query(Ae,{},a),h]),m=t.map(([i,c,g])=>({functions:c.status==="fulfilled"?c.value.functions:[],metrics:i.status==="fulfilled"?i.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),p=Ee(m),v=t[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:o.status==="fulfilled"?o.value.entries:[],functions:Me(m.map(i=>i.functions)),logsError:o.status==="rejected"?te(o.reason):null,metricsError:p.reachable===0&&v?.status==="rejected"?te(v.reason):null,migrations:$e(m.map(i=>i.migrations)),scheduler:f.status==="fulfilled"?f.value:null,totals:p}},Qe=s=>{const e=s?.history??[];return{attempts:e.map(r=>r.attempts),failures:e.map(r=>r.failures)}},dt=({initialShardKey:s})=>{const e=pe(),r=le(),[t,a]=w([]),[h,o]=w(null),[n,f]=w(null),[m,p]=w(null),[v,i]=w([]),[c,g]=w(null),[x,k]=w(null),[S,q]=w([]),[b]=w(ye),y=F(!1),N=F(!0);L(()=>(N.current=!0,()=>{N.current=!1}),[]);const I=s??"",T=ge(async()=>{if(y.current)return;y.current=!0;const u=await Ge(e,I,we(I,b));if(!N.current){y.current=!1;return}f(u.totals),p(u.metricsError),i(u.functions),q(u.migrations),a(u.entries),o(u.logsError),g(u.auth),k(u.scheduler),y.current=!1},[e,b,I]);L(()=>{G(T())},[T]);const K=F(0),M=F(null),de=()=>{const u=Date.now()-K.current;if(u>=se){K.current=Date.now(),G(T());return}M.current===null&&(M.current=setTimeout(()=>{M.current=null,K.current=Date.now(),G(T())},se-u))};L(()=>()=>{M.current!==null&&clearTimeout(M.current)},[]);const{data:W,liveError:ue}=be(E.getMetrics,{},{live:!0,shardKey:I});L(()=>{W!==void 0&&de()},[W]);const Z=t.filter(u=>u.level==="error"),me=Z.slice(0,Re),P=ze(n?.history),J=Qe(c),he=v.filter(u=>u.calls>0).toSorted((u,B)=>B.errors/B.calls-u.errors/u.calls||B.calls-u.calls).slice(0,Ce),H=Ke(S),fe=n===null||n.requests===0?0:n.errors/n.requests,U=V(fe,ne,oe),X=c===null?"ok":V(c.failureRate,De,Fe),Y=x===null?"ok":_e(x.backlog,Le,Oe),R=Be([U,X,Y,H.level]);let C,D;return R==="crit"?(C=r("Critical"),D=r("One or more service levels are breached.")):R==="warn"?(C=r("Degraded"),D=r("Some service levels need attention.")):(C=r("All systems healthy"),D=r("All service levels are within target.")),d("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[d(A,{className:"gap-0 py-0",children:[d("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[d("div",{className:"flex items-center gap-3",children:[l("span",{"aria-hidden":"true",className:$("flex size-10 shrink-0 items-center justify-center rounded-full",Ue[R]),children:l("span",{className:$("size-3 rounded-full",ie[R])})}),d("div",{className:"grid leading-tight",children:[l("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:C}),l("span",{className:"text-[13px] text-muted-foreground",children:D})]})]}),d("div",{className:"flex flex-wrap items-center gap-4",children:[d("div",{className:"text-end",children:[l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r("Requests")}),d("div",{className:"flex items-center justify-end gap-2",children:[P.requests.length>=2&&l(Q,{ariaLabel:r("Requests over time"),className:"h-6 w-20 text-foreground",series:P.requests,testId:"hl-spark-requests"}),l("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),l("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),d("div",{className:"text-end",children:[l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r("Error rate")}),l("div",{className:$("text-lg font-semibold tabular-nums",ce[U]),"data-testid":"hl-error-rate",children:n===null?"—":_(n.errors,n.requests)})]}),l("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),d("div",{className:"flex items-center gap-2",children:[l(xe,{}),l(ve,{message:ue,prefix:"hl"})]})]})]}),m!==null&&l("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:m}),m===null&&n?.historyTruncated===!0&&l("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:r("Showing a partial request/error history — one or more shards have more data than the trend chart can display.")})]}),d("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[l(O,{chart:P.errors.length>=2?l(Q,{ariaLabel:r("Errors over time"),className:"h-7 w-20 text-destructive",series:P.errors,testId:"hl-spark-errors"}):void 0,label:r("Error rate"),level:U,testId:"hl-slo-errorrate",value:n===null?"—":_(n.errors,n.requests)}),l(O,{chart:J.failures.length>=2?l(Q,{ariaLabel:r("Auth failures over time"),className:"h-7 w-20 text-destructive",series:J.failures,testId:"hl-spark-auth"}):void 0,label:r("Auth failures"),level:X,testId:"hl-slo-auth",value:c===null?"—":_(c.failures,c.attempts)}),l(O,{label:r("Scheduler backlog"),level:Y,testId:"hl-slo-backlog",value:x===null?"—":x.backlog.toString()}),l(O,{label:r("Migrations"),level:H.level,testId:"hl-slo-migrations",value:He(H,r)})]}),l(Se,{errorCount:Z.length,logsError:h,topErrors:me,worstFunctions:he}),d(A,{className:"gap-0 py-0",children:[d("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Shards seen")}),l(z,{"data-testid":"hl-shard-count",variant:"outline",children:b.length})]}),b.length>0&&l("ul",{className:"flex flex-wrap gap-1.5 p-4",children:b.map(u=>l("li",{"data-testid":"hl-shard",children:l(z,{variant:"secondary",children:u})},u))})]})]})};export{dt as HealthPanel};
1
+ import{c as ae}from"react/compiler-runtime";import{useLunora as pe}from"@lunora/react";import{useState as w,useRef as F,useEffect as L,useCallback as ge}from"react";import xe from"../packem_shared/ConnectionBadge-DOk0CQWo.js";import{L as ve}from"../packem_shared/live-status-CmuRLFKf.js";import{g as z}from"../packem_shared/badge-BbuuAio7.js";import{c as A}from"../packem_shared/card-BMKx5UdA.js";import{N as be}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as Ne,f as G,d as ee,b as te,g as j}from"../packem_shared/internal-zkEvTqy8.js";import{l as ye}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as $}from"../packem_shared/utils-bhneXptQ.js";import{jsx as l,jsxs as d}from"react/jsx-runtime";import{shardsToAggregate as we}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{S as Q}from"../packem_shared/sparkline-BNvxiJj_.js";const ke={crit:"destructive",ok:"secondary",warn:"default"},_=(s,e)=>e===0?"—":`${(s/e*100).toFixed(1)}%`,V=(s,e,r)=>Number.isNaN(s)?"ok":s>=r?"crit":s>=e?"warn":"ok",ne=.01,oe=.05,Se=s=>{const e=ae(36),{errorCount:r,logsError:t,topErrors:a,worstFunctions:h}=s,o=le();let n;e[0]!==o?(n=o("Functions by error rate"),e[0]=o,e[1]=n):n=e[1];let f;e[2]!==n?(f=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=f):f=e[3];let m;e[4]!==o||e[5]!==h?(m=h.length===0?l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:o("No function activity yet.")}):l("ul",{className:"divide-y divide-border",children:h.map(N=>d("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[l("span",{className:"truncate font-mono text-foreground",children:N.path}),d("span",{className:"flex shrink-0 items-center gap-2",children:[l("span",{className:"tabular-nums text-muted-foreground",children:o("{count} calls",{count:N.calls.toString()})}),l(z,{variant:ke[V(N.errors/N.calls,ne,oe)],children:_(N.errors,N.calls)})]})]},N.path))}),e[4]=o,e[5]=h,e[6]=m):m=e[6];let p;e[7]!==f||e[8]!==m?(p=d(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[f,m]}),e[7]=f,e[8]=m,e[9]=p):p=e[9];let v;e[10]!==o?(v=o("Recent errors"),e[10]=o,e[11]=v):v=e[11];let i;e[12]!==v?(i=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=i):i=e[13];const c=r>0?"destructive":"outline";let g;e[14]!==r||e[15]!==c?(g=l(z,{"data-testid":"hl-error-count",variant:c,children:r}),e[14]=r,e[15]=c,e[16]=g):g=e[16];let x;e[17]!==i||e[18]!==g?(x=d("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[i,g]}),e[17]=i,e[18]=g,e[19]=x):x=e[19];let k;e[20]!==t?(k=t!==null&&l("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:t}),e[20]=t,e[21]=k):k=e[21];let S;e[22]!==t||e[23]!==o||e[24]!==a.length?(S=t===null&&a.length===0&&l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:o("No recent errors.")}),e[22]=t,e[23]=o,e[24]=a.length,e[25]=S):S=e[25];let q;e[26]!==a?(q=a.length>0&&l("ul",{className:"divide-y divide-border",children:a.map(qe)}),e[26]=a,e[27]=q):q=e[27];let b;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==x?(b=d(A,{className:"gap-0 py-0",children:[x,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=x,e[32]=b):b=e[32];let y;return e[33]!==b||e[34]!==p?(y=d("div",{className:"grid gap-3 lg:grid-cols-2",children:[p,b]}),e[33]=b,e[34]=p,e[35]=y):y=e[35],y};function qe(s,e){return d("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[d("span",{className:"flex items-center gap-2",children:[l("time",{className:"shrink-0 text-muted-foreground",children:Ne(s.timestamp)}),s.functionPath!==void 0&&l("span",{className:"truncate font-mono text-foreground",children:s.functionPath})]}),l("span",{className:"text-destructive",children:s.message})]},`${s.timestamp.toString()}-${e.toString()}`)}const re={completed:0,failed:2,in_progress:1},Ee=s=>{let e=0,r=0,t=0,a=0,h=!1;const o=[];for(const{metrics:n}of s){if(n===null){a+=1;continue}t+=1,e+=n.requests,r+=n.errors,o.push(...n.history??[]),h||=n.historyTruncated===!0}return{errors:r,failed:a,history:o,historyTruncated:h,reachable:t,requests:e}},Me=s=>{const e=new Map;for(const r of s)for(const t of r){const a=e.get(t.path);if(a===void 0){e.set(t.path,{...t});continue}a.calls+=t.calls,a.errors+=t.errors,a.totalDurationMs+=t.totalDurationMs,a.scans=(a.scans??0)+(t.scans??0),a.maxDurationMs=Math.max(a.maxDurationMs,t.maxDurationMs),a.lastCalledAt=Math.max(a.lastCalledAt,t.lastCalledAt),(t.lastErrorAt??0)>(a.lastErrorAt??0)&&(a.lastErrorAt=t.lastErrorAt,a.lastErrorMessage=t.lastErrorMessage)}return[...e.values()]},$e=s=>{const e=new Map;for(const r of s)for(const t of r){const a=e.get(t.id);if(a===void 0){e.set(t.id,t);continue}const h=re[t.status]-re[a.status];(h>0||h===0&&(t.updatedAt??0)>(a.updatedAt??0))&&e.set(t.id,t)}return[...e.values()]},Ae=j(E.getAuthMetrics),je=j(E.getFunctionStats),Ie=j(E.getLogs),Te=j(E.getMetrics),Pe=j(E.migrationStatus),Re=5,se=2e3,Ce=5,De=.1,Fe=.3,Le=1,Oe=50,_e=(s,e,r)=>s>=r?"crit":s>=e?"warn":"ok",ze=s=>{const e=new Map;for(const t of s??[]){const a=e.get(t.bucketMs)??{calls:0,errors:0};a.calls+=t.calls,a.errors+=t.errors,e.set(t.bucketMs,a)}const r=[...e.entries()].toSorted((t,a)=>t[0]-a[0]);return{errors:r.map(([,t])=>t.errors),requests:r.map(([,t])=>t.calls)}},Ke=s=>{let e=0,r=0;for(const a of s)a.status==="failed"?e+=1:a.status==="in_progress"&&(r+=1);let t="ok";return e>0?t="crit":r>0&&(t="warn"),{failed:e,level:t,running:r}},He=(s,e)=>s.failed>0?e("{count} failed",{count:s.failed.toString()}):s.running>0?e("{count} running",{count:s.running.toString()}):e("OK"),ie={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ce={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Ue={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Be=s=>s.includes("crit")?"crit":s.includes("warn")?"warn":"ok",O=s=>{const e=ae(19),{chart:r,label:t,level:a,testId:h,value:o}=s,n=ie[a];let f;e[0]!==n?(f=$("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=f):f=e[1];let m;e[2]!==f?(m=l("span",{"aria-hidden":"true",className:f}),e[2]=f,e[3]=m):m=e[3];let p;e[4]!==t||e[5]!==m?(p=d("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,t]}),e[4]=t,e[5]=m,e[6]=p):p=e[6];const v=ce[a];let i;e[7]!==v?(i=$("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=i):i=e[8];let c;e[9]!==i||e[10]!==h||e[11]!==o?(c=l("span",{className:i,"data-testid":h,children:o}),e[9]=i,e[10]=h,e[11]=o,e[12]=c):c=e[12];let g;e[13]!==r||e[14]!==c?(g=d("div",{className:"flex items-center justify-between gap-3",children:[c,r]}),e[13]=r,e[14]=c,e[15]=g):g=e[15];let x;return e[16]!==p||e[17]!==g?(x=l(A,{className:"gap-0 py-0",children:d("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]})}),e[16]=p,e[17]=g,e[18]=x):x=e[18],x},Ge=async(s,e,r)=>{const t=await Promise.all(r.map(i=>{const c=ee(i);return Promise.allSettled([s.query(Te,{},c),s.query(je,{},c),s.query(Pe,{},c)])})),a=ee(e),h=typeof s.schedulerStatus=="function"?s.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[o,n,f]=await Promise.allSettled([s.query(Ie,{},a),s.query(Ae,{},a),h]),m=t.map(([i,c,g])=>({functions:c.status==="fulfilled"?c.value.functions:[],metrics:i.status==="fulfilled"?i.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),p=Ee(m),v=t[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:o.status==="fulfilled"?o.value.entries:[],functions:Me(m.map(i=>i.functions)),logsError:o.status==="rejected"?te(o.reason):null,metricsError:p.reachable===0&&v?.status==="rejected"?te(v.reason):null,migrations:$e(m.map(i=>i.migrations)),scheduler:f.status==="fulfilled"?f.value:null,totals:p}},Qe=s=>{const e=s?.history??[];return{attempts:e.map(r=>r.attempts),failures:e.map(r=>r.failures)}},dt=({initialShardKey:s})=>{const e=pe(),r=le(),[t,a]=w([]),[h,o]=w(null),[n,f]=w(null),[m,p]=w(null),[v,i]=w([]),[c,g]=w(null),[x,k]=w(null),[S,q]=w([]),[b]=w(ye),y=F(!1),N=F(!0);L(()=>(N.current=!0,()=>{N.current=!1}),[]);const I=s??"",T=ge(async()=>{if(y.current)return;y.current=!0;const u=await Ge(e,I,we(I,b));if(!N.current){y.current=!1;return}f(u.totals),p(u.metricsError),i(u.functions),q(u.migrations),a(u.entries),o(u.logsError),g(u.auth),k(u.scheduler),y.current=!1},[e,b,I]);L(()=>{G(T())},[T]);const K=F(0),M=F(null),de=()=>{const u=Date.now()-K.current;if(u>=se){K.current=Date.now(),G(T());return}M.current===null&&(M.current=setTimeout(()=>{M.current=null,K.current=Date.now(),G(T())},se-u))};L(()=>()=>{M.current!==null&&clearTimeout(M.current)},[]);const{data:W,liveError:ue}=be(E.getMetrics,{},{live:!0,shardKey:I});L(()=>{W!==void 0&&de()},[W]);const Z=t.filter(u=>u.level==="error"),me=Z.slice(0,Re),P=ze(n?.history),J=Qe(c),he=v.filter(u=>u.calls>0).toSorted((u,B)=>B.errors/B.calls-u.errors/u.calls||B.calls-u.calls).slice(0,Ce),H=Ke(S),fe=n===null||n.requests===0?0:n.errors/n.requests,U=V(fe,ne,oe),X=c===null?"ok":V(c.failureRate,De,Fe),Y=x===null?"ok":_e(x.backlog,Le,Oe),R=Be([U,X,Y,H.level]);let C,D;return R==="crit"?(C=r("Critical"),D=r("One or more service levels are breached.")):R==="warn"?(C=r("Degraded"),D=r("Some service levels need attention.")):(C=r("All systems healthy"),D=r("All service levels are within target.")),d("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[d(A,{className:"gap-0 py-0",children:[d("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[d("div",{className:"flex items-center gap-3",children:[l("span",{"aria-hidden":"true",className:$("flex size-10 shrink-0 items-center justify-center rounded-full",Ue[R]),children:l("span",{className:$("size-3 rounded-full",ie[R])})}),d("div",{className:"grid leading-tight",children:[l("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:C}),l("span",{className:"text-[13px] text-muted-foreground",children:D})]})]}),d("div",{className:"flex flex-wrap items-center gap-4",children:[d("div",{className:"text-end",children:[l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r("Requests")}),d("div",{className:"flex items-center justify-end gap-2",children:[P.requests.length>=2&&l(Q,{ariaLabel:r("Requests over time"),className:"h-6 w-20 text-foreground",series:P.requests,testId:"hl-spark-requests"}),l("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),l("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),d("div",{className:"text-end",children:[l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r("Error rate")}),l("div",{className:$("text-lg font-semibold tabular-nums",ce[U]),"data-testid":"hl-error-rate",children:n===null?"—":_(n.errors,n.requests)})]}),l("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),d("div",{className:"flex items-center gap-2",children:[l(xe,{}),l(ve,{message:ue,prefix:"hl"})]})]})]}),m!==null&&l("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:m}),m===null&&n?.historyTruncated===!0&&l("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:r("Showing a partial request/error history — one or more shards have more data than the trend chart can display.")})]}),d("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[l(O,{chart:P.errors.length>=2?l(Q,{ariaLabel:r("Errors over time"),className:"h-7 w-20 text-destructive",series:P.errors,testId:"hl-spark-errors"}):void 0,label:r("Error rate"),level:U,testId:"hl-slo-errorrate",value:n===null?"—":_(n.errors,n.requests)}),l(O,{chart:J.failures.length>=2?l(Q,{ariaLabel:r("Auth failures over time"),className:"h-7 w-20 text-destructive",series:J.failures,testId:"hl-spark-auth"}):void 0,label:r("Auth failures"),level:X,testId:"hl-slo-auth",value:c===null?"—":_(c.failures,c.attempts)}),l(O,{label:r("Scheduler backlog"),level:Y,testId:"hl-slo-backlog",value:x===null?"—":x.backlog.toString()}),l(O,{label:r("Migrations"),level:H.level,testId:"hl-slo-migrations",value:He(H,r)})]}),l(Se,{errorCount:Z.length,logsError:h,topErrors:me,worstFunctions:he}),d(A,{className:"gap-0 py-0",children:[d("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Shards seen")}),l(z,{"data-testid":"hl-shard-count",variant:"outline",children:b.length})]}),b.length>0&&l("ul",{className:"flex flex-wrap gap-1.5 p-4",children:b.map(u=>l("li",{"data-testid":"hl-shard",children:l(z,{variant:"secondary",children:u})},u))})]})]})};export{dt as HealthPanel};
@@ -1 +1 @@
1
- import{c as P}from"react/compiler-runtime";import{useLunora as te}from"@lunora/react";import{useNavigate as ne}from"@tanstack/react-router";import{useState as H,useRef as ae,useEffectEvent as R,useEffect as D,useCallback as re,useMemo as ie}from"react";import{ShardInput as se}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{N as k}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as le}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as T}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as E,d as A,g as C}from"../packem_shared/internal-zkEvTqy8.js";import{r as ce}from"../packem_shared/shard-history-DMEW5VBE.js";import{E as U,A as de}from"../packem_shared/advisor-view-Coipc04R.js";import{ConfirmButton as ue}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{jsx as S}from"react/jsx-runtime";import{deriveInsights as fe}from"../packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js";import{runAdvisor as he,RUNTIME_LINTS as me}from"@lunora/advisor";const pe=t=>{const{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},ge=(t,e,r)=>{const n=`"${t}"`,a=`"${e}"`,o=r.map(l=>`"${l}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${a} ON ${n} (${o});`},be=t=>{const e=P(19),{fields:r,indexName:n,table:a,testId:o}=t,l=M(),[$,h]=H(!1);let d;e[0]!==r||e[1]!==n||e[2]!==a?(d=()=>{const v="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(v===void 0)return;const x=ge(a,n,r);E(v.writeText(x)),h(!0)},e[0]=r,e[1]=n,e[2]=a,e[3]=d):d=e[3];const g=d;if($){const v=`${o}-applied`;let x;e[4]!==l?(x=l("CREATE INDEX SQL copied to clipboard."),e[4]=l,e[5]=x):x=e[5];let w;return e[6]!==v||e[7]!==x?(w=S("span",{className:"text-xs text-muted-foreground","data-testid":v,children:x}),e[6]=v,e[7]=x,e[8]=w):w=e[8],w}let y;e[9]!==l?(y=l("Apply?"),e[9]=l,e[10]=y):y=e[10];let u;e[11]!==l||e[12]!==a?(u=l("Apply index on {table}",{table:a}),e[11]=l,e[12]=a,e[13]=u):u=e[13];let b;return e[14]!==g||e[15]!==y||e[16]!==u||e[17]!==o?(b=S(ue,{confirmLabel:y,onConfirm:g,testId:o,children:u}),e[14]=g,e[15]=y,e[16]=u,e[17]=o,e[18]=b):b=e[18],b},xe=(t,e)=>{const r=new Map;for(const n of e){const a=`${n.table} ${n.index}`;r.set(a,(r.get(a)??0)+n.reads)}return t.map(n=>({index:n.index,reads:r.get(`${n.table} ${n.index}`)??0,table:n.table}))},ye=t=>{const e=new Map;for(const r of t)for(const n of r.scannedTables??[])e.set(n.table,(e.get(n.table)??0)+n.scans);return[...e].map(([r,n])=>({scans:n,table:r}))},X=(t,e)=>e.map(r=>({index:r.name,table:t})),ve=t=>{const e=xe(t.declaredIndexes??[],t.indexHits??[]),r=ye(t.functions??[]),n=t.shardTraffic??[],a=t.analyticsMetrics,o=a&&a.indexHits.length>0?a.indexHits:e,l=a&&a.tableScans.length>0?a.tableScans:r,$=a&&a.shardTraffic.length>0?a.shardTraffic:n,h=he({indexHits:o,schema:{tables:[]},shardTraffic:$,tableScans:l},{lints:me,source:"runtime"}),d=t.suppressHotScanTables;return(d===void 0?h:h.filter(g=>!(g.metadata.kind==="hot_scan"&&typeof g.metadata.table=="string"&&d.has(g.metadata.table)))).map(g=>U(g))},$e=C(T.listTables),Se=C(T.listTableIndexes),we=C(T.listTablesIndexes),K=t=>`${(t*100).toFixed(1)}%`,B=t=>`${(t/1e3).toFixed(2)}s`,Te=t=>{if(t.length<=1)return t[0]??"";const e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},Ie=(t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],J=(t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:K(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict — consider sharding to cut contention.",{rate:K(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:K(e.value)}),"missing-index":t("Slowest call took {duration} — it full-scanned {tables} with no index.",{duration:B(e.value),tables:Te(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:B(e.value)})})[e.kind],Ee=t=>{const e=P(10),{onJump:r,table:n}=t,a=M();let o;e[0]!==r||e[1]!==n?(o=()=>{r(n)},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=o,$=`in-add-index-${n}`;let h;e[3]!==a||e[4]!==n?(h=a("Add index on {table}",{table:n}),e[3]=a,e[4]=n,e[5]=h):h=e[5];let d;return e[6]!==l||e[7]!==$||e[8]!==h?(d=S(oe,{"data-testid":$,onClick:l,size:"sm",type:"button",variant:"outline",children:h}),e[6]=l,e[7]=$,e[8]=h,e[9]=d):d=e[9],d},Je=({initialShardKey:t,loadShardTraffic:e})=>{const r=te(),n=ne(),a=M(),{queryShardKey:o,setShardKey:l,shardKey:$}=le(t),[h,d]=H(null),[g,y]=H(null),u=ae(""),b=k(T.getMetrics,{},{live:!0,shardKey:o}),v=k(T.getFunctionStats,{},{live:!0,shardKey:o}),x=k(T.getAdvisories,{},{live:!0,shardKey:o}),w=b.data??null,L=v.data?.functions??null,_=x.data?.advisories??null,z=b.data?.indexHits??null,q=b.error!==null&&v.error!==null?b.error:null,Q=e??(i=>r.shardTraffic(i)),V=async(i,m)=>{const s=i[0];if(s===void 0||s===""){u.current===m&&y(null);return}try{const f=await Q(s);if(u.current!==m)return;const c=new Map;for(const p of f.shards)c.has(p.shardKey)||c.set(p.shardKey,{requests:p.requests,shardKey:p.shardKey});y([...c.values()])}catch{u.current===m&&y(null)}},G=async(i,m)=>{const s=await Promise.allSettled(i.map(async c=>[c,await r.query(Se,{table:c},A(m))])),f=[];for(const c of s)if(c.status==="fulfilled"){const[p,I]=c.value;f.push(...X(p,I.indexes))}return f},F=R(async i=>{u.current=i;let m=[];try{const s=await r.query($e,{},A(i));if(u.current!==i)return;ce(i),m=s.map(c=>c.name);let f=[];if(m.length>0)try{const c=await r.query(we,{tables:m},A(i));if(u.current!==i)return;for(const[p,I]of Object.entries(c.indexesByTable))f.push(...X(p,I))}catch{if(f=await G(m,i),u.current!==i)return}d(f)}catch{u.current===i&&d(null)}await V(m,i)});D(()=>{E(F(o))},[o]);const W=R(()=>{b.refetch(),v.refetch(),x.refetch(),E(F(o))});D(()=>{const i=()=>{document.visibilityState==="visible"&&W()};return document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i)}},[]);const j=re(i=>{E(n({search:{table:i},to:"/schema"}))},[n]),N=fe(w,L),Y=new Set(N.filter(i=>i.kind==="missing-index").flatMap(i=>i.tables??[])),O=ve({declaredIndexes:h??[],functions:L,indexHits:z,shardTraffic:g,suppressHotScanTables:Y}),Z=ie(()=>{const i=N.map(s=>{const f=s.kind==="missing-index"?s.tables??[]:[];return{action:f.length>0?f.map(c=>S(Ee,{onJump:j,table:c},c)):void 0,description:s.message===void 0?J(a,s):`${J(a,s)} — ${s.message}`,entity:s.fn,issueType:Ie(a,s),key:`${s.kind}:${s.fn??""}`,level:s.severity}}),m=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(_??[]).map(s=>{const f=U(s);if(m.has(s.name)&&pe(s.metadata)){const{table:c,suggestedIndex:p}=s.metadata,I=`in-apply-index-${c}-${p.name}`;return{...f,action:S(be,{fields:p.fields,indexName:p.name,table:c,testId:I})}}return f}),...O,...i]},[_,N,j,O,a]),ee=S(se,{onChange:l,testId:"in-shard-input",value:$});return S(de,{error:q,errorSource:q===null?void 0:b.errorSource,rows:Z,testId:"lunora-insights",toolbar:ee})};export{Je as InsightsPanel};
1
+ import{c as P}from"react/compiler-runtime";import{useLunora as te}from"@lunora/react";import{useNavigate as ne}from"@tanstack/react-router";import{useState as H,useRef as ae,useEffectEvent as R,useEffect as D,useCallback as re,useMemo as ie}from"react";import{ShardInput as se}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{N as k}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as le}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as T}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as E,d as A,g as C}from"../packem_shared/internal-zkEvTqy8.js";import{r as ce}from"../packem_shared/shard-history-DMEW5VBE.js";import{E as U,A as de}from"../packem_shared/advisor-view-CGcwvlMo.js";import{ConfirmButton as ue}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{jsx as S}from"react/jsx-runtime";import{deriveInsights as fe}from"../packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js";import{runAdvisor as he,RUNTIME_LINTS as me}from"@lunora/advisor";const pe=t=>{const{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},ge=(t,e,r)=>{const n=`"${t}"`,a=`"${e}"`,o=r.map(l=>`"${l}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${a} ON ${n} (${o});`},be=t=>{const e=P(19),{fields:r,indexName:n,table:a,testId:o}=t,l=M(),[$,h]=H(!1);let d;e[0]!==r||e[1]!==n||e[2]!==a?(d=()=>{const v="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(v===void 0)return;const x=ge(a,n,r);E(v.writeText(x)),h(!0)},e[0]=r,e[1]=n,e[2]=a,e[3]=d):d=e[3];const g=d;if($){const v=`${o}-applied`;let x;e[4]!==l?(x=l("CREATE INDEX SQL copied to clipboard."),e[4]=l,e[5]=x):x=e[5];let w;return e[6]!==v||e[7]!==x?(w=S("span",{className:"text-xs text-muted-foreground","data-testid":v,children:x}),e[6]=v,e[7]=x,e[8]=w):w=e[8],w}let y;e[9]!==l?(y=l("Apply?"),e[9]=l,e[10]=y):y=e[10];let u;e[11]!==l||e[12]!==a?(u=l("Apply index on {table}",{table:a}),e[11]=l,e[12]=a,e[13]=u):u=e[13];let b;return e[14]!==g||e[15]!==y||e[16]!==u||e[17]!==o?(b=S(ue,{confirmLabel:y,onConfirm:g,testId:o,children:u}),e[14]=g,e[15]=y,e[16]=u,e[17]=o,e[18]=b):b=e[18],b},xe=(t,e)=>{const r=new Map;for(const n of e){const a=`${n.table} ${n.index}`;r.set(a,(r.get(a)??0)+n.reads)}return t.map(n=>({index:n.index,reads:r.get(`${n.table} ${n.index}`)??0,table:n.table}))},ye=t=>{const e=new Map;for(const r of t)for(const n of r.scannedTables??[])e.set(n.table,(e.get(n.table)??0)+n.scans);return[...e].map(([r,n])=>({scans:n,table:r}))},X=(t,e)=>e.map(r=>({index:r.name,table:t})),ve=t=>{const e=xe(t.declaredIndexes??[],t.indexHits??[]),r=ye(t.functions??[]),n=t.shardTraffic??[],a=t.analyticsMetrics,o=a&&a.indexHits.length>0?a.indexHits:e,l=a&&a.tableScans.length>0?a.tableScans:r,$=a&&a.shardTraffic.length>0?a.shardTraffic:n,h=he({indexHits:o,schema:{tables:[]},shardTraffic:$,tableScans:l},{lints:me,source:"runtime"}),d=t.suppressHotScanTables;return(d===void 0?h:h.filter(g=>!(g.metadata.kind==="hot_scan"&&typeof g.metadata.table=="string"&&d.has(g.metadata.table)))).map(g=>U(g))},$e=C(T.listTables),Se=C(T.listTableIndexes),we=C(T.listTablesIndexes),K=t=>`${(t*100).toFixed(1)}%`,B=t=>`${(t/1e3).toFixed(2)}s`,Te=t=>{if(t.length<=1)return t[0]??"";const e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},Ie=(t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],J=(t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:K(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict — consider sharding to cut contention.",{rate:K(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:K(e.value)}),"missing-index":t("Slowest call took {duration} — it full-scanned {tables} with no index.",{duration:B(e.value),tables:Te(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:B(e.value)})})[e.kind],Ee=t=>{const e=P(10),{onJump:r,table:n}=t,a=M();let o;e[0]!==r||e[1]!==n?(o=()=>{r(n)},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=o,$=`in-add-index-${n}`;let h;e[3]!==a||e[4]!==n?(h=a("Add index on {table}",{table:n}),e[3]=a,e[4]=n,e[5]=h):h=e[5];let d;return e[6]!==l||e[7]!==$||e[8]!==h?(d=S(oe,{"data-testid":$,onClick:l,size:"sm",type:"button",variant:"outline",children:h}),e[6]=l,e[7]=$,e[8]=h,e[9]=d):d=e[9],d},Je=({initialShardKey:t,loadShardTraffic:e})=>{const r=te(),n=ne(),a=M(),{queryShardKey:o,setShardKey:l,shardKey:$}=le(t),[h,d]=H(null),[g,y]=H(null),u=ae(""),b=k(T.getMetrics,{},{live:!0,shardKey:o}),v=k(T.getFunctionStats,{},{live:!0,shardKey:o}),x=k(T.getAdvisories,{},{live:!0,shardKey:o}),w=b.data??null,L=v.data?.functions??null,_=x.data?.advisories??null,z=b.data?.indexHits??null,q=b.error!==null&&v.error!==null?b.error:null,Q=e??(i=>r.shardTraffic(i)),V=async(i,m)=>{const s=i[0];if(s===void 0||s===""){u.current===m&&y(null);return}try{const f=await Q(s);if(u.current!==m)return;const c=new Map;for(const p of f.shards)c.has(p.shardKey)||c.set(p.shardKey,{requests:p.requests,shardKey:p.shardKey});y([...c.values()])}catch{u.current===m&&y(null)}},G=async(i,m)=>{const s=await Promise.allSettled(i.map(async c=>[c,await r.query(Se,{table:c},A(m))])),f=[];for(const c of s)if(c.status==="fulfilled"){const[p,I]=c.value;f.push(...X(p,I.indexes))}return f},F=R(async i=>{u.current=i;let m=[];try{const s=await r.query($e,{},A(i));if(u.current!==i)return;ce(i),m=s.map(c=>c.name);let f=[];if(m.length>0)try{const c=await r.query(we,{tables:m},A(i));if(u.current!==i)return;for(const[p,I]of Object.entries(c.indexesByTable))f.push(...X(p,I))}catch{if(f=await G(m,i),u.current!==i)return}d(f)}catch{u.current===i&&d(null)}await V(m,i)});D(()=>{E(F(o))},[o]);const W=R(()=>{b.refetch(),v.refetch(),x.refetch(),E(F(o))});D(()=>{const i=()=>{document.visibilityState==="visible"&&W()};return document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i)}},[]);const j=re(i=>{E(n({search:{table:i},to:"/schema"}))},[n]),N=fe(w,L),Y=new Set(N.filter(i=>i.kind==="missing-index").flatMap(i=>i.tables??[])),O=ve({declaredIndexes:h??[],functions:L,indexHits:z,shardTraffic:g,suppressHotScanTables:Y}),Z=ie(()=>{const i=N.map(s=>{const f=s.kind==="missing-index"?s.tables??[]:[];return{action:f.length>0?f.map(c=>S(Ee,{onJump:j,table:c},c)):void 0,description:s.message===void 0?J(a,s):`${J(a,s)} — ${s.message}`,entity:s.fn,issueType:Ie(a,s),key:`${s.kind}:${s.fn??""}`,level:s.severity}}),m=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(_??[]).map(s=>{const f=U(s);if(m.has(s.name)&&pe(s.metadata)){const{table:c,suggestedIndex:p}=s.metadata,I=`in-apply-index-${c}-${p.name}`;return{...f,action:S(be,{fields:p.fields,indexName:p.name,table:c,testId:I})}}return f}),...O,...i]},[_,N,j,O,a]),ee=S(se,{onChange:l,testId:"in-shard-input",value:$});return S(de,{error:q,errorSource:q===null?void 0:b.errorSource,rows:Z,testId:"lunora-insights",toolbar:ee})};export{Je as InsightsPanel};