@lunora/studio 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (174) hide show
  1. package/__assets__/package-og.svg +1 -1
  2. package/dist/index.d.ts +29 -18
  3. package/dist/index.js +29 -29
  4. package/dist/mount.d.ts +1 -1
  5. package/dist/mount.js +1 -1
  6. package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
  7. package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +24 -36
  8. package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +13 -9
  9. package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +15 -15
  10. package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +10 -10
  11. package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +147 -204
  12. package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
  13. package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +107 -69
  14. package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +41 -53
  15. package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +37 -44
  16. package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
  17. package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +39 -46
  18. package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
  19. package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +15 -15
  20. package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +44 -31
  21. package/dist/packem_chunks/SettingsPanel.js +390 -0
  22. package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +12 -252
  23. package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +10 -68
  24. package/dist/packem_chunks/analytics-panel.js +261 -0
  25. package/dist/packem_chunks/auth-config-panel.js +179 -0
  26. package/dist/packem_chunks/auth-sessions-panel.js +175 -0
  27. package/dist/packem_chunks/dashboards-panel.js +779 -0
  28. package/dist/packem_chunks/fanout-panel.js +481 -0
  29. package/dist/packem_chunks/flags-panel.js +176 -0
  30. package/dist/packem_chunks/kv-browser.js +1896 -0
  31. package/dist/packem_chunks/log-drains-panel.js +273 -0
  32. package/dist/packem_chunks/organizations-panel.js +670 -0
  33. package/dist/packem_chunks/payments-panel.js +185 -0
  34. package/dist/packem_chunks/permissions-panel.js +804 -0
  35. package/dist/packem_chunks/queues-panel.js +147 -0
  36. package/dist/packem_chunks/rls-panel.js +313 -0
  37. package/dist/packem_chunks/schedule-panel.js +831 -0
  38. package/dist/packem_chunks/sparkline.js +79 -0
  39. package/dist/packem_chunks/storage-rules-panel.js +138 -0
  40. package/dist/packem_chunks/subscriptions-panel.js +236 -0
  41. package/dist/packem_chunks/users-panel.js +1265 -0
  42. package/dist/packem_chunks/vector-browser.js +281 -0
  43. package/dist/packem_chunks/workflows-panel.js +562 -0
  44. package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-CdaxLGkE.js} +3 -0
  45. package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-B6u_wnz-.js} +2 -2
  46. package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-Drz4UO0a.js} +2 -1
  47. package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-B5BertvU.js} +1 -1
  48. package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-ANTHLWWh.js} +198 -247
  49. package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-CjgTG_wa.js} +37 -66
  50. package/dist/packem_shared/HomePanel-c2FodE9t.js +14 -0
  51. package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-CspFdbUT.js} +2 -1
  52. package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-BEJXtsBn.js} +163 -60
  53. package/dist/packem_shared/Studio-CVTtA_sB.js +16 -0
  54. package/dist/packem_shared/{StudioApp-CHOZA-z-.js → StudioApp-BSYV2fz6.js} +277 -3
  55. package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-DzqyvUU3.js} +1 -1
  56. package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-B6MyY_al.d.ts} +1 -1
  57. package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-Bb__F5-u.js} +1 -1
  58. package/dist/packem_shared/browser-storage-d03UsV7v.js +249 -0
  59. package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
  60. package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-Dsg6nRjo.js} +1 -1
  61. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
  62. package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-D7nNzBYm.js} +4 -99
  63. package/dist/packem_shared/{HomePanel-Cw16stjq.js → home-panel-aOR_drVv.js} +833 -469
  64. package/dist/packem_shared/{internal-rXJEAhXS.js → internal-FcNZ3beb.js} +1 -1
  65. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
  66. package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-Doy1XlQq.js} +4 -44
  67. package/dist/packem_shared/select-UkNYCT3s.js +273 -0
  68. package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
  69. package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-KgMPHS4u.js} +1 -1
  70. package/dist/packem_shared/studio-dMTJ-kRR.js +3987 -0
  71. package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
  72. package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-VMo0ftxD.js} +1 -1
  73. package/dist/packem_shared/use-admin-query-BViPA3US.js +105 -0
  74. package/dist/packem_shared/use-auth-capabilities-BHkoBnbZ.js +32 -0
  75. package/dist/standalone/chunk-2DS7JLWL.js +13 -0
  76. package/dist/standalone/chunk-2K47A3P6.js +1 -0
  77. package/dist/standalone/chunk-2NGUNNGW.js +1 -0
  78. package/dist/standalone/chunk-2PDQ4KZ6.js +1 -0
  79. package/dist/standalone/chunk-3BP4BTLR.js +4 -0
  80. package/dist/standalone/chunk-3OA7PECS.js +6 -0
  81. package/dist/standalone/chunk-4QHKBC77.js +1 -0
  82. package/dist/standalone/chunk-57LYXHXH.js +1 -0
  83. package/dist/standalone/chunk-5NSZVXCS.js +1 -0
  84. package/dist/standalone/chunk-5OIBXYZM.js +1 -0
  85. package/dist/standalone/chunk-63XKJQTQ.js +1 -0
  86. package/dist/standalone/chunk-6RC6L33K.js +4 -0
  87. package/dist/standalone/chunk-6VTGE3WJ.js +1 -0
  88. package/dist/standalone/chunk-7PBZKXYA.js +1 -0
  89. package/dist/standalone/chunk-7POIIWC5.js +3 -0
  90. package/dist/standalone/chunk-7RYIQKZA.js +1 -0
  91. package/dist/standalone/chunk-7TJJXVSE.js +1 -0
  92. package/dist/standalone/chunk-AB6QGMBF.js +1 -0
  93. package/dist/standalone/chunk-AHILM3ZP.js +1 -0
  94. package/dist/standalone/chunk-AQGOX5DK.js +1 -0
  95. package/dist/standalone/chunk-ASLGNHAX.js +1 -0
  96. package/dist/standalone/chunk-BHTPZS7L.js +4 -0
  97. package/dist/standalone/chunk-BJGBHGK3.js +1 -0
  98. package/dist/standalone/chunk-D7HKX4DI.js +1 -0
  99. package/dist/standalone/chunk-DGWTR4G7.js +1 -0
  100. package/dist/standalone/chunk-DSX53PBM.js +1 -0
  101. package/dist/standalone/chunk-DV2MNASX.js +1 -0
  102. package/dist/standalone/chunk-DWDILV2E.js +1 -0
  103. package/dist/standalone/chunk-E7AVZZKO.js +1 -0
  104. package/dist/standalone/chunk-EGJX34WM.js +1 -0
  105. package/dist/standalone/chunk-FCR3HKFV.js +1 -0
  106. package/dist/standalone/chunk-FKO3HO6I.js +4 -0
  107. package/dist/standalone/chunk-FQKNJSRA.js +76 -0
  108. package/dist/standalone/chunk-G2TFEWEQ.js +4 -0
  109. package/dist/standalone/chunk-GABMIICA.js +1 -0
  110. package/dist/standalone/chunk-GTM65MVX.js +1 -0
  111. package/dist/standalone/chunk-GZXPPJVK.js +1 -0
  112. package/dist/standalone/chunk-HFBRE65A.js +1 -0
  113. package/dist/standalone/chunk-HFMQNUBC.js +1 -0
  114. package/dist/standalone/chunk-HG7Q5B3H.js +1 -0
  115. package/dist/standalone/chunk-HTQL7AXU.js +1 -0
  116. package/dist/standalone/chunk-HV7G6DFP.js +5 -0
  117. package/dist/standalone/chunk-ITLLHEVG.js +1 -0
  118. package/dist/standalone/chunk-J6J54MBP.js +1 -0
  119. package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
  120. package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
  121. package/dist/standalone/chunk-KG3QTFWE.js +1 -0
  122. package/dist/standalone/chunk-KGS7KM4A.js +2 -0
  123. package/dist/standalone/chunk-KODWGUAB.js +1 -0
  124. package/dist/standalone/chunk-KZ6INM5M.js +1 -0
  125. package/dist/standalone/chunk-MGFEVTRI.js +1 -0
  126. package/dist/standalone/chunk-N2QDG3MW.js +1 -0
  127. package/dist/standalone/chunk-N4JI6VQD.js +1 -0
  128. package/dist/standalone/chunk-NNISYDNI.js +1 -0
  129. package/dist/standalone/chunk-O4PXDNR3.js +1 -0
  130. package/dist/standalone/chunk-O77VNUFD.js +1 -0
  131. package/dist/standalone/chunk-OD2POGPJ.js +1 -0
  132. package/dist/standalone/chunk-OXCK3ZUG.js +1 -0
  133. package/dist/standalone/chunk-P7DSVO4U.js +1 -0
  134. package/dist/standalone/chunk-PKAM3N5C.js +1 -0
  135. package/dist/standalone/chunk-QGXGBHQO.js +1 -0
  136. package/dist/standalone/chunk-QHA3TAEJ.js +1 -0
  137. package/dist/standalone/chunk-QQWC62X7.js +1 -0
  138. package/dist/standalone/chunk-RMYA7NAH.js +1 -0
  139. package/dist/standalone/chunk-RRCPZMC2.js +22 -0
  140. package/dist/standalone/chunk-S53RUBW5.js +1 -0
  141. package/dist/standalone/chunk-SB4GT6PK.js +1 -0
  142. package/dist/standalone/chunk-SEU5V7I6.js +1 -0
  143. package/dist/standalone/chunk-SHIOUDOT.js +1 -0
  144. package/dist/standalone/chunk-SIDRSX7Y.js +1 -0
  145. package/dist/standalone/chunk-SVR644RF.js +1 -0
  146. package/dist/standalone/chunk-TAD43CG5.js +1 -0
  147. package/dist/standalone/chunk-TBMYIZIO.js +1 -0
  148. package/dist/standalone/chunk-TICVNLPM.js +1 -0
  149. package/dist/standalone/chunk-TQ36RWOP.js +1 -0
  150. package/dist/standalone/chunk-UGMRUEBU.js +1 -0
  151. package/dist/standalone/chunk-UII66UVF.js +1 -0
  152. package/dist/standalone/chunk-VJPQUBN6.js +8 -0
  153. package/dist/standalone/chunk-VLXV72QE.js +1 -0
  154. package/dist/standalone/chunk-VMJKJWG6.js +1 -0
  155. package/dist/standalone/chunk-VPDPN5RR.js +2 -0
  156. package/dist/standalone/chunk-VSEGZA3J.js +1 -0
  157. package/dist/standalone/chunk-VXBZQIGY.js +4 -0
  158. package/dist/standalone/chunk-W7PCVQTE.js +1 -0
  159. package/dist/standalone/chunk-XLILSHPE.js +1 -0
  160. package/dist/standalone/chunk-XURNGQSS.js +1 -0
  161. package/dist/standalone/chunk-YJGANMU7.js +18 -0
  162. package/dist/standalone/chunk-YQQJ4N6U.js +1 -0
  163. package/dist/standalone/chunk-ZH7UES4T.js +2 -0
  164. package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
  165. package/dist/standalone/chunk-ZQCVDXDL.js +1 -0
  166. package/dist/standalone/studio.js +104 -246
  167. package/dist/styles.css +1 -1
  168. package/package.json +13 -12
  169. package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
  170. package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
  171. package/dist/packem_shared/Studio-DFWAlcuf.js +0 -33
  172. package/dist/packem_shared/studio-Bj8psK1c.js +0 -10303
  173. package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
  174. package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
@@ -1,257 +1,17 @@
1
1
  import { c } from 'react/compiler-runtime';
2
2
  import { useLunora } from '@lunora/react';
3
- import { useState, useEffect, useRef, useId } from 'react';
4
- import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
5
- import { h as formatCell, f as fireAndForget, c as callOptions, a as adminRef, e as errorMessage } from './internal-rXJEAhXS.js';
6
- import { X as XAxis, B as Bar, T as Tooltip, E as EvilBarChart } from './bar-chart-CzJAgqkp.js';
3
+ import { useState, useRef, useEffect, useId } from 'react';
4
+ import { u as usePersistedList, n as newId, A as Alert, S as SqlResultChart } from '../packem_shared/browser-storage-d03UsV7v.js';
5
+ import { ShardInput } from '../packem_shared/ShardInput-gx_DZXXn.js';
6
+ import { c as TableHead, a as TableHeader, b as TableRow, e as TableCell, d as TableBody, T as Table } from '../packem_shared/table-DsCa9Qp9.js';
7
+ import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
8
+ import { ADMIN_FUNCTIONS } from '../packem_shared/ADMIN_FUNCTIONS-CdaxLGkE.js';
9
+ import { f as fireAndForget, c as callOptions, a as adminRef, e as errorMessage } from '../packem_shared/internal-FcNZ3beb.js';
10
+ import { r as recordShard } from '../packem_shared/shard-history-DyebH1R5.js';
11
+ import { C as CellValue } from '../packem_shared/data-grid-Dsg6nRjo.js';
12
+ import { E as ExportMenu } from '../packem_shared/grid-features-D7nNzBYm.js';
13
+ import { c as cn } from '../packem_shared/utils-B05Dmz_H.js';
7
14
  import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
8
- import { ShardInput } from './ShardInput-gx_DZXXn.js';
9
- import { cva } from 'class-variance-authority';
10
- import { c as cn } from './utils-B05Dmz_H.js';
11
- import { c as TableHead, a as TableHeader, b as TableRow, e as TableCell, d as TableBody, T as Table } from './table-_RzNvy3R.js';
12
- import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-DmBqMZ-z.js';
13
- import { r as recordShard } from './shard-history-DyebH1R5.js';
14
- import { C as CellValue } from './data-grid-B5CaV3wS.js';
15
- import { E as ExportMenu } from './grid-features-CzUfqgsM.js';
16
-
17
- const MAX_BARS = 50;
18
- const RESULT_CHART_CONFIG = {
19
- value: {
20
- colors: {
21
- dark: ["var(--chart-1)"],
22
- light: ["var(--chart-1)"]
23
- },
24
- label: "value"
25
- }
26
- };
27
- const pickColumns = (result) => {
28
- const value = result.columns.find((column) => result.rows.length > 0 && result.rows.every((row) => typeof row[column] === "number")) ?? null;
29
- const label = result.columns.find((column) => column !== value) ?? null;
30
- return {
31
- label,
32
- value
33
- };
34
- };
35
- const SqlResultChart = (t0) => {
36
- const $ = c(15);
37
- const {
38
- result
39
- } = t0;
40
- const t = useT();
41
- let t1;
42
- if ($[0] !== result) {
43
- t1 = pickColumns(result);
44
- $[0] = result;
45
- $[1] = t1;
46
- } else {
47
- t1 = $[1];
48
- }
49
- const {
50
- label,
51
- value
52
- } = t1;
53
- let t2;
54
- if ($[2] !== label || $[3] !== result || $[4] !== value) {
55
- t2 = value === null ? [] : result.rows.slice(0, MAX_BARS).map((row, index) => ({
56
- label: label === null ? `#${(index + 1).toString()}` : formatCell(row[label]),
57
- value: Number(row[value]) || 0
58
- }));
59
- $[2] = label;
60
- $[3] = result;
61
- $[4] = value;
62
- $[5] = t2;
63
- } else {
64
- t2 = $[5];
65
- }
66
- const data = t2;
67
- if (value === null) {
68
- let t32;
69
- if ($[6] !== t) {
70
- t32 = t("No numeric column to chart.");
71
- $[6] = t;
72
- $[7] = t32;
73
- } else {
74
- t32 = $[7];
75
- }
76
- let t42;
77
- if ($[8] !== t32) {
78
- t42 = /* @__PURE__ */ jsxDEV("p", {
79
- className: "p-4 text-sm text-muted-foreground",
80
- "data-testid": "sql-chart-empty",
81
- children: t32
82
- }, void 0, false);
83
- $[8] = t32;
84
- $[9] = t42;
85
- } else {
86
- t42 = $[9];
87
- }
88
- return t42;
89
- }
90
- let t3;
91
- let t4;
92
- let t5;
93
- if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
94
- t3 = /* @__PURE__ */ jsxDEV(XAxis, {
95
- dataKey: "label"
96
- }, void 0, false);
97
- t4 = /* @__PURE__ */ jsxDEV(Bar, {
98
- dataKey: "value"
99
- }, void 0, false);
100
- t5 = /* @__PURE__ */ jsxDEV(Tooltip, {}, void 0, false);
101
- $[10] = t3;
102
- $[11] = t4;
103
- $[12] = t5;
104
- } else {
105
- t3 = $[10];
106
- t4 = $[11];
107
- t5 = $[12];
108
- }
109
- let t6;
110
- if ($[13] !== data) {
111
- t6 = /* @__PURE__ */ jsxDEV("div", {
112
- className: "h-80 w-full p-3",
113
- "data-testid": "sql-chart",
114
- children: /* @__PURE__ */ jsxDEV(EvilBarChart, {
115
- className: "h-full w-full",
116
- config: RESULT_CHART_CONFIG,
117
- data,
118
- children: [t3, t4, t5]
119
- }, void 0, true)
120
- }, void 0, false);
121
- $[13] = data;
122
- $[14] = t6;
123
- } else {
124
- t6 = $[14];
125
- }
126
- return t6;
127
- };
128
-
129
- const alertVariants = cva("flex items-start gap-2 rounded-md border px-3 py-2 text-sm [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0", {
130
- defaultVariants: {
131
- variant: "default"
132
- },
133
- variants: {
134
- variant: {
135
- default: "border-border bg-muted/40 text-foreground",
136
- destructive: "border-destructive/40 bg-destructive/5 text-destructive",
137
- warning: "border-amber-500/40 bg-amber-500/5 text-amber-700 dark:text-amber-400"
138
- }
139
- }
140
- });
141
- const Alert = (t0) => {
142
- const $ = c(10);
143
- const {
144
- children,
145
- className,
146
- icon,
147
- testId,
148
- variant
149
- } = t0;
150
- let t1;
151
- if ($[0] !== className || $[1] !== variant) {
152
- t1 = cn(alertVariants({
153
- variant
154
- }), className);
155
- $[0] = className;
156
- $[1] = variant;
157
- $[2] = t1;
158
- } else {
159
- t1 = $[2];
160
- }
161
- let t2;
162
- if ($[3] !== children) {
163
- t2 = /* @__PURE__ */ jsxDEV("div", {
164
- className: "min-w-0 flex-1",
165
- children
166
- }, void 0, false);
167
- $[3] = children;
168
- $[4] = t2;
169
- } else {
170
- t2 = $[4];
171
- }
172
- let t3;
173
- if ($[5] !== icon || $[6] !== t1 || $[7] !== t2 || $[8] !== testId) {
174
- t3 = /* @__PURE__ */ jsxDEV("div", {
175
- className: t1,
176
- "data-testid": testId,
177
- role: "alert",
178
- children: [icon, t2]
179
- }, void 0, true);
180
- $[5] = icon;
181
- $[6] = t1;
182
- $[7] = t2;
183
- $[8] = testId;
184
- $[9] = t3;
185
- } else {
186
- t3 = $[9];
187
- }
188
- return t3;
189
- };
190
-
191
- const store = () => {
192
- try {
193
- return globalThis.localStorage;
194
- } catch {
195
- return void 0;
196
- }
197
- };
198
- const loadJsonArray = function(key) {
199
- try {
200
- const raw = store()?.getItem(key) ?? void 0;
201
- const parsed = raw === void 0 ? [] : JSON.parse(raw);
202
- return Array.isArray(parsed) ? parsed : [];
203
- } catch {
204
- return [];
205
- }
206
- };
207
- const saveJson = (key, value) => {
208
- const storage = store();
209
- if (storage === void 0) {
210
- return;
211
- }
212
- try {
213
- storage.setItem(key, JSON.stringify(value));
214
- } catch {
215
- }
216
- };
217
- const usePersistedList = function(key) {
218
- const $ = c(8);
219
- let t0;
220
- if ($[0] !== key) {
221
- t0 = () => loadJsonArray(key);
222
- $[0] = key;
223
- $[1] = t0;
224
- } else {
225
- t0 = $[1];
226
- }
227
- const [value, setValue] = useState(t0);
228
- let t1;
229
- let t2;
230
- if ($[2] !== key || $[3] !== value) {
231
- t1 = () => {
232
- saveJson(key, value);
233
- };
234
- t2 = [key, value];
235
- $[2] = key;
236
- $[3] = value;
237
- $[4] = t1;
238
- $[5] = t2;
239
- } else {
240
- t1 = $[4];
241
- t2 = $[5];
242
- }
243
- useEffect(t1, t2);
244
- let t3;
245
- if ($[6] !== value) {
246
- t3 = [value, setValue];
247
- $[6] = value;
248
- $[7] = t3;
249
- } else {
250
- t3 = $[7];
251
- }
252
- return t3;
253
- };
254
- const newId = (prefix) => globalThis.crypto?.randomUUID?.() ?? `${prefix}-${globalThis.performance.now().toString(36)}`;
255
15
 
256
16
  const SQL_KEYWORDS = ["ORDER BY", "GROUP BY", "LEFT JOIN", "RIGHT JOIN", "INNER JOIN", "OUTER JOIN", "CROSS JOIN", "EXPLAIN QUERY PLAN", "SELECT", "DISTINCT", "FROM", "WHERE", "HAVING", "LIMIT", "OFFSET", "JOIN", "ON", "AND", "OR", "AS", "ASC", "DESC", "WITH", "UNION", "EXPLAIN"];
257
17
  const SQL_NEWLINE_CLAUSES = ["FROM", "WHERE", "ORDER BY", "GROUP BY", "HAVING", "LIMIT", "OFFSET", "UNION", "JOIN", "LEFT JOIN", "RIGHT JOIN", "INNER JOIN", "OUTER JOIN", "CROSS JOIN"];
@@ -2559,4 +2319,4 @@ function _temp(column) {
2559
2319
  }, column, false);
2560
2320
  }
2561
2321
 
2562
- export { Alert as A, SqlEditorPanel as S, SqlResultChart as a, newId as n, usePersistedList as u };
2322
+ export { SqlEditorPanel };
@@ -2,74 +2,14 @@ import { c } from 'react/compiler-runtime';
2
2
  import { useLunora } from '@lunora/react';
3
3
  import { useNavigate, useRouter, useSearch } from '@tanstack/react-router';
4
4
  import { useRef, useState, useEffect } from 'react';
5
- import { T as TIER_META } from './storage-tier-CL98eOvn.js';
6
- import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
7
- import { f as fireAndForget } from './internal-rXJEAhXS.js';
8
- import { DataBrowser } from './DataBrowser-CtBe1So9.js';
9
- import { GlobalDataBrowser } from './GlobalDataBrowser-BTEmGrph.js';
5
+ import { T as TIER_META } from '../packem_shared/storage-tier-CL98eOvn.js';
6
+ import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
7
+ import { s as searchToDataView, d as dataViewToSearch } from '../packem_shared/data-view-params-Cd6yRVbv.js';
8
+ import { f as fireAndForget } from '../packem_shared/internal-FcNZ3beb.js';
9
+ import { DataBrowser } from '../packem_shared/DataBrowser-ANTHLWWh.js';
10
+ import { GlobalDataBrowser } from '../packem_shared/GlobalDataBrowser-CjgTG_wa.js';
10
11
  import { jsxDEV } from 'react/jsx-dev-runtime';
11
12
 
12
- const VALID_OPERATORS = /* @__PURE__ */ new Set(["contains", "eq", "gt", "gte", "lt", "lte", "ne"]);
13
- const isFilterClause = (entry) => {
14
- if (entry === null || typeof entry !== "object") {
15
- return false;
16
- }
17
- const candidate = entry;
18
- return typeof candidate.column === "string" && typeof candidate.operator === "string" && VALID_OPERATORS.has(candidate.operator);
19
- };
20
- const parseFilters = (raw) => {
21
- if (typeof raw !== "string" || raw === "") {
22
- return [];
23
- }
24
- try {
25
- const parsed = JSON.parse(raw);
26
- return Array.isArray(parsed) ? parsed.filter(isFilterClause) : [];
27
- } catch {
28
- return [];
29
- }
30
- };
31
- const parseOrder = (raw) => {
32
- if (typeof raw !== "string" || raw === "") {
33
- return void 0;
34
- }
35
- const separator = raw.lastIndexOf(":");
36
- if (separator <= 0) {
37
- return void 0;
38
- }
39
- const column = raw.slice(0, separator);
40
- const direction = raw.slice(separator + 1);
41
- if (direction !== "asc" && direction !== "desc") {
42
- return void 0;
43
- }
44
- return {
45
- column,
46
- direction
47
- };
48
- };
49
- const searchToDataView = (search) => {
50
- const filters = parseFilters(search["filters"]);
51
- const orderBy = parseOrder(search["order"]);
52
- return {
53
- filters: filters.length > 0 ? filters : void 0,
54
- orderBy,
55
- search: typeof search["search"] === "string" && search["search"] !== "" ? search["search"] : void 0,
56
- shard: typeof search["shard"] === "string" && search["shard"] !== "" ? search["shard"] : void 0,
57
- table: typeof search["table"] === "string" && search["table"] !== "" ? search["table"] : void 0,
58
- tier: search["schema"] === "global" ? "global" : "shard"
59
- };
60
- };
61
- const dataViewToSearch = (view) => {
62
- const filters = view.filters ?? [];
63
- return {
64
- filters: filters.length > 0 ? JSON.stringify(filters) : void 0,
65
- order: view.orderBy === void 0 ? void 0 : `${view.orderBy.column}:${view.orderBy.direction}`,
66
- schema: view.tier === "global" ? "global" : void 0,
67
- search: view.search !== void 0 && view.search !== "" ? view.search : void 0,
68
- shard: view.shard !== void 0 && view.shard !== "" ? view.shard : void 0,
69
- table: view.table !== void 0 && view.table !== "" ? view.table : void 0
70
- };
71
- };
72
-
73
13
  const STORAGE_KEY = "lunora-studio-saved-queries";
74
14
  const MAX_SAVED = 50;
75
15
  const store = () => {
@@ -260,14 +200,16 @@ const TableEditor = ({
260
200
  to: "/data"
261
201
  }));
262
202
  };
263
- const onSelectTable = (table_0) => {
203
+ const onSelectTable = (table_0, options) => {
264
204
  if (!onDataRoute()) {
265
205
  return;
266
206
  }
267
207
  fireAndForget(navigate({
268
208
  search: (previous_1) => {
269
209
  return {
270
- ...previous_1,
210
+ schema: previous_1["schema"],
211
+ search: options?.search,
212
+ shard: previous_1["shard"],
271
213
  table: table_0
272
214
  };
273
215
  },
@@ -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, d as formatCell } from '../packem_shared/internal-FcNZ3beb.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 };