@lunora/studio 1.0.0-alpha.5 → 1.0.0-alpha.50

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 (198) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/index.d.ts +45 -23
  4. package/dist/index.js +31 -31
  5. package/dist/mount.d.ts +1 -1
  6. package/dist/mount.js +3 -2
  7. package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
  8. package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +29 -41
  9. package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +16 -11
  10. package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +55 -32
  11. package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +15 -32
  12. package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +153 -208
  13. package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
  14. package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +108 -69
  15. package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +46 -58
  16. package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +45 -139
  17. package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
  18. package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +44 -51
  19. package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
  20. package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +17 -16
  21. package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +47 -31
  22. package/dist/packem_chunks/SettingsPanel.js +391 -0
  23. package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +159 -387
  24. package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +13 -94
  25. package/dist/packem_chunks/agents-panel.js +326 -0
  26. package/dist/packem_chunks/analytics-panel.js +261 -0
  27. package/dist/packem_chunks/auth-config-panel.js +365 -0
  28. package/dist/packem_chunks/auth-sessions-panel.js +175 -0
  29. package/dist/packem_chunks/containers-panel.js +261 -0
  30. package/dist/packem_chunks/dashboards-panel.js +781 -0
  31. package/dist/packem_chunks/fanout-panel.js +482 -0
  32. package/dist/packem_chunks/flags-panel.js +176 -0
  33. package/dist/packem_chunks/issues-panel.js +188 -0
  34. package/dist/packem_chunks/kv-browser.js +1896 -0
  35. package/dist/packem_chunks/log-drains-panel.js +273 -0
  36. package/dist/packem_chunks/organizations-panel.js +3178 -0
  37. package/dist/packem_chunks/payments-panel.js +186 -0
  38. package/dist/packem_chunks/permissions-panel.js +805 -0
  39. package/dist/packem_chunks/queues-panel.js +1075 -0
  40. package/dist/packem_chunks/rls-panel.js +315 -0
  41. package/dist/packem_chunks/schedule-panel.js +831 -0
  42. package/dist/packem_chunks/sparkline.js +79 -0
  43. package/dist/packem_chunks/storage-rules-panel.js +140 -0
  44. package/dist/packem_chunks/subscriptions-panel.js +238 -0
  45. package/dist/packem_chunks/users-panel.js +1731 -0
  46. package/dist/packem_chunks/vector-browser.js +281 -0
  47. package/dist/packem_chunks/workflows-panel.js +562 -0
  48. package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-DNeyYtUN.js} +8 -0
  49. package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-_aEZxAMX.js} +2 -2
  50. package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-Dd8pcswz.js} +2 -1
  51. package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-BXV4eKf5.js} +1 -1
  52. package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-C8hejnub.js} +201 -250
  53. package/dist/packem_shared/{DataFilters-FNquMaiu.js → DataFilters-B1Q7mrt7.js} +6 -2
  54. package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-CxJxRRf2.js} +37 -66
  55. package/dist/packem_shared/HomePanel-Ye8PaqQL.js +14 -0
  56. package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-CWaf0ZtX.js} +2 -1
  57. package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-dHMgnJbx.js} +163 -60
  58. package/dist/packem_shared/{ShardInput-gx_DZXXn.js → ShardInput-CZnpHILL.js} +1 -1
  59. package/dist/packem_shared/Studio-xJLTlLpf.js +16 -0
  60. package/dist/packem_shared/{StudioApp-D4azxYBu.js → StudioApp-oCQholCL.js} +6 -21
  61. package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-Cx21PS_T.js} +6 -6
  62. package/dist/packem_shared/alert-CdAET2K_.js +68 -0
  63. package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-CGdOmLTm.d.ts} +1 -1
  64. package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-DSwcWIRy.js} +5 -4
  65. package/dist/packem_shared/browser-storage-L4gOP5gJ.js +105 -0
  66. package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
  67. package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-C9I16KWr.js} +1 -1
  68. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
  69. package/dist/packem_shared/error-alert-vIPQoN3Y.js +114 -0
  70. package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-B_fZH4iQ.js} +133 -164
  71. package/dist/packem_shared/home-panel-D62G8108.js +1889 -0
  72. package/dist/packem_shared/internal-zwBoOv24.js +122 -0
  73. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
  74. package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-DUULLuOi.js} +8 -61
  75. package/dist/packem_shared/result-chart-DZradBAS.js +119 -0
  76. package/dist/packem_shared/scroll-area-DLhcy-ml.js +93 -0
  77. package/dist/packem_shared/select-UkNYCT3s.js +273 -0
  78. package/dist/packem_shared/shard-history-AxiJ1WPP.js +16 -0
  79. package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
  80. package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-BnA1kC9X.js} +1 -1
  81. package/dist/packem_shared/studio-WZUOecDv.js +4069 -0
  82. package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
  83. package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-huX4VmgI.js} +19 -9
  84. package/dist/packem_shared/use-admin-query-BGJ010yZ.js +106 -0
  85. package/dist/packem_shared/use-async-submit-DGCtuDyz.js +91 -0
  86. package/dist/standalone/chunk-22C6COGE.js +13 -0
  87. package/dist/standalone/chunk-2CCWLKQW.js +1 -0
  88. package/dist/standalone/chunk-2JTPX3CV.js +1 -0
  89. package/dist/standalone/chunk-2K47A3P6.js +1 -0
  90. package/dist/standalone/chunk-2MLA6WFH.js +1 -0
  91. package/dist/standalone/chunk-2NGUNNGW.js +1 -0
  92. package/dist/standalone/chunk-3CPQ5IQU.js +1 -0
  93. package/dist/standalone/chunk-3GXGLNKW.js +1 -0
  94. package/dist/standalone/chunk-3OA7PECS.js +6 -0
  95. package/dist/standalone/chunk-4AXW2ECS.js +13 -0
  96. package/dist/standalone/chunk-4BVRLBEW.js +1 -0
  97. package/dist/standalone/chunk-4PC7IXNY.js +1 -0
  98. package/dist/standalone/chunk-4QHKBC77.js +1 -0
  99. package/dist/standalone/chunk-5OIBXYZM.js +1 -0
  100. package/dist/standalone/chunk-5OZQHQ26.js +1 -0
  101. package/dist/standalone/chunk-6RREMPQX.js +2 -0
  102. package/dist/standalone/chunk-6ZBU3JWR.js +3 -0
  103. package/dist/standalone/chunk-7LDYSHOU.js +1 -0
  104. package/dist/standalone/chunk-7TJJXVSE.js +1 -0
  105. package/dist/standalone/chunk-A2DBMISD.js +1 -0
  106. package/dist/standalone/chunk-A3ZJACVT.js +4 -0
  107. package/dist/standalone/chunk-A66LI6OV.js +4 -0
  108. package/dist/standalone/chunk-AHILM3ZP.js +1 -0
  109. package/dist/standalone/chunk-AITOCPML.js +1 -0
  110. package/dist/standalone/chunk-APSSZB6Z.js +1 -0
  111. package/dist/standalone/chunk-BGG56IF5.js +1 -0
  112. package/dist/standalone/chunk-BJGBHGK3.js +1 -0
  113. package/dist/standalone/chunk-CJXJIRSN.js +1 -0
  114. package/dist/standalone/chunk-CKSHCYGC.js +2 -0
  115. package/dist/standalone/chunk-DR6LGPXE.js +1 -0
  116. package/dist/standalone/chunk-DWDILV2E.js +1 -0
  117. package/dist/standalone/chunk-EEWKIQUE.js +1 -0
  118. package/dist/standalone/chunk-EOE5NDMK.js +1 -0
  119. package/dist/standalone/chunk-FAUN4Z72.js +1 -0
  120. package/dist/standalone/chunk-G7ZBM54M.js +1 -0
  121. package/dist/standalone/chunk-GTM65MVX.js +1 -0
  122. package/dist/standalone/chunk-HAJSYWFT.js +8 -0
  123. package/dist/standalone/chunk-HQM6MBPS.js +1 -0
  124. package/dist/standalone/chunk-HTQNZXDT.js +1 -0
  125. package/dist/standalone/chunk-HV7G6DFP.js +5 -0
  126. package/dist/standalone/chunk-IO2XEI6T.js +1 -0
  127. package/dist/standalone/chunk-ITQKVEP7.js +19 -0
  128. package/dist/standalone/chunk-IZN4TYMN.js +1 -0
  129. package/dist/standalone/chunk-J6J54MBP.js +1 -0
  130. package/dist/standalone/chunk-JM7XBQVK.js +1 -0
  131. package/dist/standalone/chunk-JPILGFXT.js +1 -0
  132. package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
  133. package/dist/standalone/chunk-JUDPYSJZ.js +1 -0
  134. package/dist/standalone/chunk-K4S652EQ.js +4 -0
  135. package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
  136. package/dist/standalone/chunk-KJFFID72.js +1 -0
  137. package/dist/standalone/chunk-KJJ3WM6H.js +4 -0
  138. package/dist/standalone/chunk-KZ6INM5M.js +1 -0
  139. package/dist/standalone/chunk-L7SK4ZZD.js +1 -0
  140. package/dist/standalone/chunk-LAK5VSPI.js +1 -0
  141. package/dist/standalone/chunk-LJAAZNQ6.js +1 -0
  142. package/dist/standalone/chunk-LUP4YTBS.js +1 -0
  143. package/dist/standalone/chunk-LX7KONE3.js +1 -0
  144. package/dist/standalone/chunk-MDTNVR3G.js +1 -0
  145. package/dist/standalone/chunk-NS23QR4W.js +1 -0
  146. package/dist/standalone/chunk-NW6SZZ5O.js +1 -0
  147. package/dist/standalone/chunk-O3NAGRTR.js +1 -0
  148. package/dist/standalone/chunk-P2ERTKMB.js +1 -0
  149. package/dist/standalone/chunk-PS3XCCZD.js +1 -0
  150. package/dist/standalone/chunk-QAFAJBAW.js +1 -0
  151. package/dist/standalone/chunk-RRCPZMC2.js +22 -0
  152. package/dist/standalone/chunk-RS7S7XVP.js +1 -0
  153. package/dist/standalone/chunk-S5NTGHCG.js +1 -0
  154. package/dist/standalone/chunk-S7AB7Y75.js +1 -0
  155. package/dist/standalone/chunk-SDMZKBTD.js +1 -0
  156. package/dist/standalone/chunk-SDQE2IUJ.js +1 -0
  157. package/dist/standalone/chunk-SEU5V7I6.js +1 -0
  158. package/dist/standalone/chunk-SHERR7ZP.js +1 -0
  159. package/dist/standalone/chunk-SHJUAHC6.js +1 -0
  160. package/dist/standalone/chunk-TAD43CG5.js +1 -0
  161. package/dist/standalone/chunk-TO6D2PJC.js +6 -0
  162. package/dist/standalone/chunk-TQ36RWOP.js +1 -0
  163. package/dist/standalone/chunk-TYN6SQ73.js +1 -0
  164. package/dist/standalone/chunk-U26QNHMO.js +1 -0
  165. package/dist/standalone/chunk-UK64ZSUW.js +1 -0
  166. package/dist/standalone/chunk-UTHHHJYS.js +1 -0
  167. package/dist/standalone/chunk-V43BLH4J.js +1 -0
  168. package/dist/standalone/chunk-VL23Y44O.js +4 -0
  169. package/dist/standalone/chunk-VL6HOZHF.js +1 -0
  170. package/dist/standalone/chunk-VLXV72QE.js +1 -0
  171. package/dist/standalone/chunk-W666BB6V.js +1 -0
  172. package/dist/standalone/chunk-W6JKUZKD.js +1 -0
  173. package/dist/standalone/chunk-WI7GWFEG.js +1 -0
  174. package/dist/standalone/chunk-WUFVFVHJ.js +1 -0
  175. package/dist/standalone/chunk-WVTPZ6CM.js +1 -0
  176. package/dist/standalone/chunk-X2TQRMQV.js +1 -0
  177. package/dist/standalone/chunk-X4676IX6.js +1 -0
  178. package/dist/standalone/chunk-X4QFAAZ5.js +76 -0
  179. package/dist/standalone/chunk-XJU5SRNL.js +4 -0
  180. package/dist/standalone/chunk-XNJNSCLM.js +1 -0
  181. package/dist/standalone/chunk-XWPZBZSZ.js +3 -0
  182. package/dist/standalone/chunk-YLHDKM2P.js +1 -0
  183. package/dist/standalone/chunk-ZHVTQ37P.js +1 -0
  184. package/dist/standalone/chunk-ZIGWVHCS.js +1 -0
  185. package/dist/standalone/chunk-ZPP2KOR4.js +1 -0
  186. package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
  187. package/dist/standalone/studio.js +104 -246
  188. package/dist/styles.css +2 -2
  189. package/package.json +17 -15
  190. package/dist/packem_shared/HomePanel-Cw16stjq.js +0 -1273
  191. package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
  192. package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
  193. package/dist/packem_shared/Studio-BmSGSIuY.js +0 -33
  194. package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
  195. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  196. package/dist/packem_shared/studio-H9fuQgSj.js +0 -10303
  197. package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
  198. package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
@@ -0,0 +1,261 @@
1
+ import { c } from 'react/compiler-runtime';
2
+ import { createAnalyticsSqlClient } from '@lunora/bindings/analytics';
3
+ import { useState, useMemo, useCallback, useEffect } from 'react';
4
+ import { C as Card } from '../packem_shared/card-DURq3ElK.js';
5
+ import { E as EmptyState } from '../packem_shared/empty-state-DY_oe0k6.js';
6
+ import { T as Table, a as TableHeader, b as TableRow, d as TableBody, e as TableCell, c as TableHead } from '../packem_shared/table-DsCa9Qp9.js';
7
+ import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
8
+ import { e as errorMessage, f as fireAndForget, h as formatCell } from '../packem_shared/internal-zwBoOv24.js';
9
+ import { jsxDEV } from 'react/jsx-dev-runtime';
10
+
11
+ const DEFAULT_DATASET = "ANALYTICS";
12
+ const PANEL_QUERIES = [{
13
+ key: "volume",
14
+ sql: (dataset) => `SELECT blob2 AS fn, count() AS calls FROM ${dataset} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,
15
+ title: "Request volume per function"
16
+ }, {
17
+ key: "latency",
18
+ sql: (dataset) => `SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${dataset} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,
19
+ title: "Latency p50 / p95 per function"
20
+ }, {
21
+ key: "hotShards",
22
+ sql: (dataset) => `SELECT blob3 AS shard, count() AS calls FROM ${dataset} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,
23
+ title: "Hot shards"
24
+ }];
25
+ const INITIAL_PANEL_STATE = {
26
+ error: null,
27
+ loading: true,
28
+ result: null
29
+ };
30
+ const PanelResult = (t0) => {
31
+ const $ = c(27);
32
+ const {
33
+ state,
34
+ title
35
+ } = t0;
36
+ const t = useT();
37
+ const {
38
+ error,
39
+ loading,
40
+ result
41
+ } = state;
42
+ const t1 = `analytics-panel-${title}`;
43
+ let t2;
44
+ if ($[0] !== t || $[1] !== title) {
45
+ t2 = t(title);
46
+ $[0] = t;
47
+ $[1] = title;
48
+ $[2] = t2;
49
+ } else {
50
+ t2 = $[2];
51
+ }
52
+ let t3;
53
+ if ($[3] !== t2) {
54
+ t3 = /* @__PURE__ */ jsxDEV("header", {
55
+ className: "border-b border-border px-4 py-3",
56
+ children: /* @__PURE__ */ jsxDEV("span", {
57
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
58
+ children: t2
59
+ }, void 0, false)
60
+ }, void 0, false);
61
+ $[3] = t2;
62
+ $[4] = t3;
63
+ } else {
64
+ t3 = $[4];
65
+ }
66
+ let t4;
67
+ if ($[5] !== loading || $[6] !== t) {
68
+ t4 = loading && /* @__PURE__ */ jsxDEV("p", {
69
+ className: "px-4 py-8 text-center text-sm text-muted-foreground",
70
+ "data-testid": "analytics-loading",
71
+ children: t("Loading…")
72
+ }, void 0, false);
73
+ $[5] = loading;
74
+ $[6] = t;
75
+ $[7] = t4;
76
+ } else {
77
+ t4 = $[7];
78
+ }
79
+ let t5;
80
+ if ($[8] !== error || $[9] !== loading) {
81
+ t5 = !loading && error !== null && /* @__PURE__ */ jsxDEV("p", {
82
+ className: "px-4 py-8 text-center text-sm text-destructive",
83
+ "data-testid": "analytics-error",
84
+ role: "alert",
85
+ children: error
86
+ }, void 0, false);
87
+ $[8] = error;
88
+ $[9] = loading;
89
+ $[10] = t5;
90
+ } else {
91
+ t5 = $[10];
92
+ }
93
+ let t6;
94
+ if ($[11] !== error || $[12] !== loading || $[13] !== result || $[14] !== t) {
95
+ t6 = !loading && error === null && result !== null && result.rows.length === 0 && /* @__PURE__ */ jsxDEV("p", {
96
+ className: "px-4 py-8 text-center text-sm text-muted-foreground",
97
+ "data-testid": "analytics-empty-rows",
98
+ children: t("No data points yet.")
99
+ }, void 0, false);
100
+ $[11] = error;
101
+ $[12] = loading;
102
+ $[13] = result;
103
+ $[14] = t;
104
+ $[15] = t6;
105
+ } else {
106
+ t6 = $[15];
107
+ }
108
+ let t7;
109
+ if ($[16] !== error || $[17] !== loading || $[18] !== result) {
110
+ t7 = !loading && error === null && result !== null && result.rows.length > 0 && /* @__PURE__ */ jsxDEV(Table, {
111
+ children: [/* @__PURE__ */ jsxDEV(TableHeader, {
112
+ children: /* @__PURE__ */ jsxDEV(TableRow, {
113
+ children: result.columns.map(_temp)
114
+ }, void 0, false)
115
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableBody, {
116
+ children: result.rows.map((row, rowIndex) => /* @__PURE__ */ jsxDEV(TableRow, {
117
+ children: result.columns.map((column_0) => /* @__PURE__ */ jsxDEV(TableCell, {
118
+ className: "font-mono text-xs",
119
+ children: formatCell(row[column_0.name])
120
+ }, column_0.name, false))
121
+ }, rowIndex, false))
122
+ }, void 0, false)]
123
+ }, void 0, true);
124
+ $[16] = error;
125
+ $[17] = loading;
126
+ $[18] = result;
127
+ $[19] = t7;
128
+ } else {
129
+ t7 = $[19];
130
+ }
131
+ let t8;
132
+ if ($[20] !== t1 || $[21] !== t3 || $[22] !== t4 || $[23] !== t5 || $[24] !== t6 || $[25] !== t7) {
133
+ t8 = /* @__PURE__ */ jsxDEV(Card, {
134
+ className: "gap-0 py-0",
135
+ "data-testid": t1,
136
+ children: [t3, t4, t5, t6, t7]
137
+ }, void 0, true);
138
+ $[20] = t1;
139
+ $[21] = t3;
140
+ $[22] = t4;
141
+ $[23] = t5;
142
+ $[24] = t6;
143
+ $[25] = t7;
144
+ $[26] = t8;
145
+ } else {
146
+ t8 = $[26];
147
+ }
148
+ return t8;
149
+ };
150
+ const AnalyticsPanel = ({
151
+ config,
152
+ dataset = DEFAULT_DATASET,
153
+ runQuery
154
+ } = {}) => {
155
+ const t = useT();
156
+ const [states, setStates] = useState({});
157
+ const run = useMemo(() => {
158
+ if (runQuery !== void 0) {
159
+ return runQuery;
160
+ }
161
+ if (config === void 0) {
162
+ return null;
163
+ }
164
+ const client = createAnalyticsSqlClient({
165
+ accountId: config.accountId,
166
+ apiToken: config.apiToken
167
+ });
168
+ return (sql) => client.query(sql);
169
+ }, [config, runQuery]);
170
+ const load = useCallback(async (token) => {
171
+ if (run === null) {
172
+ return;
173
+ }
174
+ for (const panel of PANEL_QUERIES) {
175
+ if (token.cancelled) {
176
+ return;
177
+ }
178
+ setStates((current) => {
179
+ return {
180
+ ...current,
181
+ [panel.key]: {
182
+ error: null,
183
+ loading: true,
184
+ result: null
185
+ }
186
+ };
187
+ });
188
+ try {
189
+ const result = await run(panel.sql(dataset));
190
+ if (!token.cancelled) {
191
+ setStates((current_1) => {
192
+ return {
193
+ ...current_1,
194
+ [panel.key]: {
195
+ error: null,
196
+ loading: false,
197
+ result
198
+ }
199
+ };
200
+ });
201
+ }
202
+ } catch (error_) {
203
+ if (!token.cancelled) {
204
+ setStates((current_0) => {
205
+ return {
206
+ ...current_0,
207
+ [panel.key]: {
208
+ error: errorMessage(error_),
209
+ loading: false,
210
+ result: null
211
+ }
212
+ };
213
+ });
214
+ }
215
+ }
216
+ }
217
+ }, [run, dataset]);
218
+ useEffect(() => {
219
+ const token_0 = {
220
+ cancelled: false
221
+ };
222
+ fireAndForget(load(token_0));
223
+ return () => {
224
+ token_0.cancelled = true;
225
+ };
226
+ }, [load]);
227
+ if (run === null) {
228
+ return /* @__PURE__ */ jsxDEV(EmptyState, {
229
+ description: t("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),
230
+ icon: /* @__PURE__ */ jsxDEV("svg", {
231
+ "aria-hidden": "true",
232
+ fill: "none",
233
+ stroke: "currentColor",
234
+ strokeLinecap: "round",
235
+ strokeLinejoin: "round",
236
+ strokeWidth: 1.6,
237
+ viewBox: "0 0 24 24",
238
+ children: /* @__PURE__ */ jsxDEV("path", {
239
+ d: "M5 20V10m6.5 10V4M18 20v-7M3 20h18"
240
+ }, void 0, false)
241
+ }, void 0, false),
242
+ testId: "analytics-not-configured",
243
+ title: t("Analytics is not configured.")
244
+ }, void 0, false);
245
+ }
246
+ return /* @__PURE__ */ jsxDEV("div", {
247
+ className: "flex flex-col gap-4",
248
+ "data-testid": "lunora-analytics-panel",
249
+ children: PANEL_QUERIES.map((panel_0) => /* @__PURE__ */ jsxDEV(PanelResult, {
250
+ state: states[panel_0.key] ?? INITIAL_PANEL_STATE,
251
+ title: panel_0.title
252
+ }, panel_0.key, false))
253
+ }, void 0, false);
254
+ };
255
+ function _temp(column) {
256
+ return /* @__PURE__ */ jsxDEV(TableHead, {
257
+ children: column.name
258
+ }, column.name, false);
259
+ }
260
+
261
+ export { AnalyticsPanel };
@@ -0,0 +1,365 @@
1
+ import { c } from 'react/compiler-runtime';
2
+ import { useLunora } from '@lunora/react';
3
+ import { B as Badge } from '../packem_shared/badge-B2PKA1-5.js';
4
+ import { C as Card, a as CardContent } from '../packem_shared/card-DURq3ElK.js';
5
+ import { a as useClientQuery } from '../packem_shared/use-admin-query-BGJ010yZ.js';
6
+ import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
7
+ import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
8
+
9
+ const CAPABILITY_ROWS = [{
10
+ key: "accounts",
11
+ label: "Accounts"
12
+ }, {
13
+ key: "admin",
14
+ label: "Admin"
15
+ }, {
16
+ key: "organization",
17
+ label: "Organizations"
18
+ }, {
19
+ key: "passkey",
20
+ label: "Passkeys"
21
+ }, {
22
+ key: "twoFactor",
23
+ label: "Two-factor"
24
+ }];
25
+ const formatDuration = (seconds) => {
26
+ if (seconds === void 0) {
27
+ return "—";
28
+ }
29
+ const units = [[86400, "d"], [3600, "h"], [60, "m"]];
30
+ for (const [size, suffix] of units) {
31
+ if (seconds >= size && seconds % size === 0) {
32
+ return `${String(seconds / size)}${suffix}`;
33
+ }
34
+ }
35
+ return `${String(seconds)}s`;
36
+ };
37
+ const ConfigCard = (t0) => {
38
+ const $ = c(8);
39
+ const {
40
+ children,
41
+ heading,
42
+ testId
43
+ } = t0;
44
+ let t1;
45
+ if ($[0] !== heading) {
46
+ t1 = /* @__PURE__ */ jsxDEV("header", {
47
+ className: "border-b border-border px-4 py-3",
48
+ children: /* @__PURE__ */ jsxDEV("span", {
49
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
50
+ children: heading
51
+ }, void 0, false)
52
+ }, void 0, false);
53
+ $[0] = heading;
54
+ $[1] = t1;
55
+ } else {
56
+ t1 = $[1];
57
+ }
58
+ let t2;
59
+ if ($[2] !== children) {
60
+ t2 = /* @__PURE__ */ jsxDEV(CardContent, {
61
+ className: "p-3",
62
+ children
63
+ }, void 0, false);
64
+ $[2] = children;
65
+ $[3] = t2;
66
+ } else {
67
+ t2 = $[3];
68
+ }
69
+ let t3;
70
+ if ($[4] !== t1 || $[5] !== t2 || $[6] !== testId) {
71
+ t3 = /* @__PURE__ */ jsxDEV(Card, {
72
+ className: "gap-0 py-0",
73
+ "data-testid": testId,
74
+ children: [t1, t2]
75
+ }, void 0, true);
76
+ $[4] = t1;
77
+ $[5] = t2;
78
+ $[6] = testId;
79
+ $[7] = t3;
80
+ } else {
81
+ t3 = $[7];
82
+ }
83
+ return t3;
84
+ };
85
+ const KeyValue = (t0) => {
86
+ const $ = c(7);
87
+ const {
88
+ label,
89
+ value
90
+ } = t0;
91
+ let t1;
92
+ if ($[0] !== label) {
93
+ t1 = /* @__PURE__ */ jsxDEV("span", {
94
+ className: "text-sm",
95
+ children: label
96
+ }, void 0, false);
97
+ $[0] = label;
98
+ $[1] = t1;
99
+ } else {
100
+ t1 = $[1];
101
+ }
102
+ let t2;
103
+ if ($[2] !== value) {
104
+ t2 = /* @__PURE__ */ jsxDEV("span", {
105
+ className: "text-sm text-muted-foreground tabular-nums",
106
+ children: value
107
+ }, void 0, false);
108
+ $[2] = value;
109
+ $[3] = t2;
110
+ } else {
111
+ t2 = $[3];
112
+ }
113
+ let t3;
114
+ if ($[4] !== t1 || $[5] !== t2) {
115
+ t3 = /* @__PURE__ */ jsxDEV("div", {
116
+ className: "flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",
117
+ children: [t1, t2]
118
+ }, void 0, true);
119
+ $[4] = t1;
120
+ $[5] = t2;
121
+ $[6] = t3;
122
+ } else {
123
+ t3 = $[6];
124
+ }
125
+ return t3;
126
+ };
127
+ const AuthConfigPanel = () => {
128
+ const $ = c(20);
129
+ const client = useLunora();
130
+ const t = useT();
131
+ let t0;
132
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
133
+ t0 = ["lunora-auth-config"];
134
+ $[0] = t0;
135
+ } else {
136
+ t0 = $[0];
137
+ }
138
+ let t1;
139
+ if ($[1] !== client) {
140
+ t1 = () => client.getAuthConfig();
141
+ $[1] = client;
142
+ $[2] = t1;
143
+ } else {
144
+ t1 = $[2];
145
+ }
146
+ const {
147
+ data: config,
148
+ error
149
+ } = useClientQuery(t0, t1);
150
+ let t2;
151
+ if ($[3] !== t) {
152
+ t2 = (on) => /* @__PURE__ */ jsxDEV(Badge, {
153
+ variant: on ? "success" : "outline",
154
+ children: on ? t("Enabled") : t("Disabled")
155
+ }, void 0, false);
156
+ $[3] = t;
157
+ $[4] = t2;
158
+ } else {
159
+ t2 = $[4];
160
+ }
161
+ const statusBadge = t2;
162
+ let t3;
163
+ if ($[5] !== error) {
164
+ t3 = error !== null && /* @__PURE__ */ jsxDEV("p", {
165
+ className: "px-4 py-8 text-center text-sm text-destructive",
166
+ "data-testid": "auth-config-error",
167
+ role: "alert",
168
+ children: error
169
+ }, void 0, false);
170
+ $[5] = error;
171
+ $[6] = t3;
172
+ } else {
173
+ t3 = $[6];
174
+ }
175
+ let t4;
176
+ if ($[7] !== config || $[8] !== error || $[9] !== t) {
177
+ t4 = error === null && config === void 0 && /* @__PURE__ */ jsxDEV("p", {
178
+ className: "px-4 py-8 text-center text-sm text-muted-foreground",
179
+ "data-testid": "auth-config-loading",
180
+ children: t("Loading auth configuration…")
181
+ }, void 0, false);
182
+ $[7] = config;
183
+ $[8] = error;
184
+ $[9] = t;
185
+ $[10] = t4;
186
+ } else {
187
+ t4 = $[10];
188
+ }
189
+ let t5;
190
+ if ($[11] !== config || $[12] !== error || $[13] !== statusBadge || $[14] !== t) {
191
+ t5 = error === null && config !== void 0 && /* @__PURE__ */ jsxDEV(Fragment, {
192
+ children: [/* @__PURE__ */ jsxDEV(ConfigCard, {
193
+ heading: t("Enabled capabilities"),
194
+ testId: "auth-config-capabilities",
195
+ children: /* @__PURE__ */ jsxDEV("ul", {
196
+ className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
197
+ children: CAPABILITY_ROWS.map((row) => {
198
+ const enabled = config.capabilities[row.key];
199
+ return /* @__PURE__ */ jsxDEV("li", {
200
+ className: "flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",
201
+ "data-testid": `auth-config-cap-${row.key}`,
202
+ children: [/* @__PURE__ */ jsxDEV("span", {
203
+ className: "text-sm",
204
+ children: t(row.label)
205
+ }, void 0, false), statusBadge(enabled)]
206
+ }, row.key, true);
207
+ })
208
+ }, void 0, false)
209
+ }, void 0, false), /* @__PURE__ */ jsxDEV(ConfigCard, {
210
+ heading: t("Plugins"),
211
+ testId: "auth-config-plugins",
212
+ children: config.plugins.length === 0 ? /* @__PURE__ */ jsxDEV("p", {
213
+ className: "text-sm text-muted-foreground",
214
+ children: t("No plugins enabled.")
215
+ }, void 0, false) : /* @__PURE__ */ jsxDEV("div", {
216
+ className: "flex flex-wrap gap-2",
217
+ children: config.plugins.map(_temp)
218
+ }, void 0, false)
219
+ }, void 0, false), /* @__PURE__ */ jsxDEV(ConfigCard, {
220
+ heading: t("Sign-in methods"),
221
+ testId: "auth-config-signin",
222
+ children: /* @__PURE__ */ jsxDEV("div", {
223
+ className: "flex flex-col gap-2",
224
+ children: [/* @__PURE__ */ jsxDEV(KeyValue, {
225
+ label: t("Email & password"),
226
+ value: statusBadge(config.emailAndPassword)
227
+ }, void 0, false), /* @__PURE__ */ jsxDEV(KeyValue, {
228
+ label: t("Social providers"),
229
+ value: config.socialProviders.length === 0 ? t("None") : /* @__PURE__ */ jsxDEV("span", {
230
+ className: "flex flex-wrap justify-end gap-1",
231
+ children: config.socialProviders.map(_temp2)
232
+ }, void 0, false)
233
+ }, void 0, false)]
234
+ }, void 0, true)
235
+ }, void 0, false), config.organization.enabled && /* @__PURE__ */ jsxDEV(ConfigCard, {
236
+ heading: t("Organizations"),
237
+ testId: "auth-config-org",
238
+ children: /* @__PURE__ */ jsxDEV("div", {
239
+ className: "flex flex-col gap-2",
240
+ children: [/* @__PURE__ */ jsxDEV(KeyValue, {
241
+ label: t("Teams"),
242
+ value: statusBadge(config.organization.teams)
243
+ }, void 0, false), /* @__PURE__ */ jsxDEV(KeyValue, {
244
+ label: t("Custom roles"),
245
+ value: statusBadge(config.organization.roles)
246
+ }, void 0, false)]
247
+ }, void 0, true)
248
+ }, void 0, false), /* @__PURE__ */ jsxDEV(ConfigCard, {
249
+ heading: t("Session policy"),
250
+ testId: "auth-config-session",
251
+ children: /* @__PURE__ */ jsxDEV("div", {
252
+ className: "flex flex-col gap-2",
253
+ children: [/* @__PURE__ */ jsxDEV(KeyValue, {
254
+ label: t("Expires in"),
255
+ value: formatDuration(config.session.expiresIn)
256
+ }, void 0, false), /* @__PURE__ */ jsxDEV(KeyValue, {
257
+ label: t("Refresh after"),
258
+ value: formatDuration(config.session.updateAge)
259
+ }, void 0, false), /* @__PURE__ */ jsxDEV(KeyValue, {
260
+ label: t("Fresh window"),
261
+ value: formatDuration(config.session.freshAge)
262
+ }, void 0, false), /* @__PURE__ */ jsxDEV(KeyValue, {
263
+ label: t("Cookie cache"),
264
+ value: statusBadge(config.session.cookieCache === true)
265
+ }, void 0, false)]
266
+ }, void 0, true)
267
+ }, void 0, false), /* @__PURE__ */ jsxDEV(ConfigCard, {
268
+ heading: t("Rate limit"),
269
+ testId: "auth-config-ratelimit",
270
+ children: /* @__PURE__ */ jsxDEV("div", {
271
+ className: "flex flex-col gap-2",
272
+ children: [/* @__PURE__ */ jsxDEV(KeyValue, {
273
+ label: t("Status"),
274
+ value: statusBadge(config.rateLimit.enabled)
275
+ }, void 0, false), config.rateLimit.enabled && /* @__PURE__ */ jsxDEV(Fragment, {
276
+ children: [/* @__PURE__ */ jsxDEV(KeyValue, {
277
+ label: t("Max requests"),
278
+ value: config.rateLimit.max ?? "—"
279
+ }, void 0, false), /* @__PURE__ */ jsxDEV(KeyValue, {
280
+ label: t("Window"),
281
+ value: formatDuration(config.rateLimit.window)
282
+ }, void 0, false)]
283
+ }, void 0, true)]
284
+ }, void 0, true)
285
+ }, void 0, false), config.userFields.length > 0 && /* @__PURE__ */ jsxDEV(ConfigCard, {
286
+ heading: t("Plugin user fields"),
287
+ testId: "auth-config-user-fields",
288
+ children: /* @__PURE__ */ jsxDEV("ul", {
289
+ className: "flex flex-col gap-2",
290
+ children: config.userFields.map((field) => /* @__PURE__ */ jsxDEV("li", {
291
+ className: "flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",
292
+ "data-testid": `auth-config-user-field-${field.name}`,
293
+ children: [/* @__PURE__ */ jsxDEV("span", {
294
+ className: "flex flex-col",
295
+ children: [/* @__PURE__ */ jsxDEV("span", {
296
+ className: "font-mono text-xs",
297
+ children: field.name
298
+ }, void 0, false), field.plugin !== void 0 && /* @__PURE__ */ jsxDEV("span", {
299
+ className: "text-[11px] text-muted-foreground",
300
+ children: field.plugin
301
+ }, void 0, false)]
302
+ }, void 0, true), /* @__PURE__ */ jsxDEV("span", {
303
+ className: "flex items-center gap-1",
304
+ children: [/* @__PURE__ */ jsxDEV(Badge, {
305
+ variant: "outline",
306
+ children: field.type
307
+ }, void 0, false), field.required && /* @__PURE__ */ jsxDEV(Badge, {
308
+ variant: "secondary",
309
+ children: t("required")
310
+ }, void 0, false), field.unique && /* @__PURE__ */ jsxDEV(Badge, {
311
+ variant: "secondary",
312
+ children: t("unique")
313
+ }, void 0, false)]
314
+ }, void 0, true)]
315
+ }, field.name, true))
316
+ }, void 0, false)
317
+ }, void 0, false), /* @__PURE__ */ jsxDEV(Card, {
318
+ className: "gap-0 py-0",
319
+ children: /* @__PURE__ */ jsxDEV("p", {
320
+ className: "px-4 py-3 text-xs text-muted-foreground",
321
+ "data-testid": "auth-config-note",
322
+ children: t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")
323
+ }, void 0, false)
324
+ }, void 0, false)]
325
+ }, void 0, true);
326
+ $[11] = config;
327
+ $[12] = error;
328
+ $[13] = statusBadge;
329
+ $[14] = t;
330
+ $[15] = t5;
331
+ } else {
332
+ t5 = $[15];
333
+ }
334
+ let t6;
335
+ if ($[16] !== t3 || $[17] !== t4 || $[18] !== t5) {
336
+ t6 = /* @__PURE__ */ jsxDEV("div", {
337
+ className: "flex flex-col gap-4",
338
+ "data-testid": "auth-config",
339
+ children: [t3, t4, t5]
340
+ }, void 0, true);
341
+ $[16] = t3;
342
+ $[17] = t4;
343
+ $[18] = t5;
344
+ $[19] = t6;
345
+ } else {
346
+ t6 = $[19];
347
+ }
348
+ return t6;
349
+ };
350
+ function _temp(plugin) {
351
+ return /* @__PURE__ */ jsxDEV(Badge, {
352
+ "data-testid": `auth-config-plugin-${plugin}`,
353
+ variant: "outline",
354
+ children: plugin
355
+ }, plugin, false);
356
+ }
357
+ function _temp2(provider) {
358
+ return /* @__PURE__ */ jsxDEV(Badge, {
359
+ "data-testid": `auth-config-provider-${provider}`,
360
+ variant: "outline",
361
+ children: provider
362
+ }, provider, false);
363
+ }
364
+
365
+ export { AuthConfigPanel };