@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
@@ -0,0 +1,562 @@
1
+ import { useLunora } from '@lunora/react';
2
+ import { useState, useEffect, useMemo } from 'react';
3
+ import { B as Button } from '../packem_shared/button-BhsN2uZH.js';
4
+ import { C as Card, a as CardContent } from '../packem_shared/card-DURq3ElK.js';
5
+ import { E as EmptyState } from '../packem_shared/empty-state-DY_oe0k6.js';
6
+ import { I as Input } from '../packem_shared/input-XH4r1Pt1.js';
7
+ import { T as Table, a as TableHeader, b as TableRow, c as TableHead, d as TableBody, e as TableCell } from '../packem_shared/table-DsCa9Qp9.js';
8
+ import { T as Textarea } from '../packem_shared/textarea-D3gaCU_-.js';
9
+ import { u as useAdminQuery } from '../packem_shared/use-admin-query-BViPA3US.js';
10
+ import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
11
+ import { ADMIN_FUNCTIONS } from '../packem_shared/ADMIN_FUNCTIONS-CdaxLGkE.js';
12
+ import { f as fireAndForget, e as errorMessage, c as callOptions, a as adminRef } from '../packem_shared/internal-FcNZ3beb.js';
13
+ import { jsxDEV } from 'react/jsx-dev-runtime';
14
+
15
+ const STATUS_FILTERS = ["queued", "running", "paused", "waiting", "complete", "errored", "terminated"];
16
+ const ACTIONS = ["pause", "resume", "terminate"];
17
+ const NOT_CONFIGURED_CODE = "WORKFLOWS_NOT_CONFIGURED";
18
+ const isNotConfigured = (error) => typeof error === "object" && error !== null && error.code === NOT_CONFIGURED_CODE;
19
+ const formatStepPayload = (step) => {
20
+ const value = step.error ?? step.output;
21
+ if (value === void 0) {
22
+ return "—";
23
+ }
24
+ try {
25
+ return JSON.stringify(value);
26
+ } catch {
27
+ return "(unserializable)";
28
+ }
29
+ };
30
+ const WorkflowInstanceHistory = ({
31
+ loadDetail,
32
+ loadInstances,
33
+ readOnly,
34
+ runAction,
35
+ workflowName
36
+ }) => {
37
+ const client = useLunora();
38
+ const t = useT();
39
+ const [instances, setInstances] = useState(null);
40
+ const [detail, setDetail] = useState(null);
41
+ const [statusFilter, setStatusFilter] = useState("");
42
+ const [error, setError] = useState(null);
43
+ const [notConfigured, setNotConfigured] = useState(false);
44
+ const [busyId, setBusyId] = useState(null);
45
+ const detailImpl = loadDetail ?? ((arguments_) => client.getWorkflowInstance(arguments_));
46
+ const clientOwned = loadInstances === void 0;
47
+ const clientAction = clientOwned ? (arguments_) => client.setWorkflowInstanceStatus(arguments_) : void 0;
48
+ const actionImpl = readOnly ? void 0 : runAction ?? clientAction;
49
+ const load = async () => {
50
+ setError(null);
51
+ setNotConfigured(false);
52
+ const status = statusFilter === "" ? void 0 : statusFilter;
53
+ try {
54
+ if (loadInstances === void 0) {
55
+ const page = await client.listWorkflowInstances({
56
+ name: workflowName,
57
+ status
58
+ });
59
+ if (page.configured === false) {
60
+ setInstances(null);
61
+ setNotConfigured(true);
62
+ return;
63
+ }
64
+ setInstances(page.instances);
65
+ return;
66
+ }
67
+ setInstances(await loadInstances({
68
+ name: workflowName,
69
+ status
70
+ }));
71
+ } catch (error_) {
72
+ setInstances(null);
73
+ if (isNotConfigured(error_)) {
74
+ setNotConfigured(true);
75
+ } else {
76
+ setError(errorMessage(error_));
77
+ }
78
+ }
79
+ };
80
+ useEffect(() => {
81
+ setDetail(null);
82
+ fireAndForget(load());
83
+ }, [workflowName, statusFilter]);
84
+ const openDetail = async (id) => {
85
+ setError(null);
86
+ try {
87
+ setDetail(await detailImpl({
88
+ id,
89
+ name: workflowName
90
+ }));
91
+ } catch (error_) {
92
+ setError(errorMessage(error_));
93
+ }
94
+ };
95
+ const act = async (id, action) => {
96
+ if (actionImpl === void 0) {
97
+ return;
98
+ }
99
+ setBusyId(id);
100
+ setError(null);
101
+ try {
102
+ await actionImpl({
103
+ action,
104
+ id,
105
+ name: workflowName
106
+ });
107
+ await load();
108
+ } catch (error_) {
109
+ setError(errorMessage(error_));
110
+ } finally {
111
+ setBusyId(null);
112
+ }
113
+ };
114
+ return /* @__PURE__ */ jsxDEV("div", {
115
+ className: "flex flex-col gap-3",
116
+ "data-testid": "lunora-workflow-instances",
117
+ children: [/* @__PURE__ */ jsxDEV("div", {
118
+ className: "flex items-center justify-between gap-2",
119
+ children: [/* @__PURE__ */ jsxDEV("h3", {
120
+ className: "text-sm font-medium",
121
+ children: t("Instance history")
122
+ }, void 0, false), /* @__PURE__ */ jsxDEV("select", {
123
+ "aria-label": t("Filter by status"),
124
+ className: "h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50",
125
+ "data-testid": "workflow-instances-filter",
126
+ onChange: (event) => {
127
+ setStatusFilter(event.target.value);
128
+ },
129
+ value: statusFilter,
130
+ children: [/* @__PURE__ */ jsxDEV("option", {
131
+ value: "",
132
+ children: t("All statuses")
133
+ }, void 0, false), STATUS_FILTERS.map((status) => /* @__PURE__ */ jsxDEV("option", {
134
+ value: status,
135
+ children: status
136
+ }, status, false))]
137
+ }, void 0, true)]
138
+ }, void 0, true), error !== null && /* @__PURE__ */ jsxDEV("p", {
139
+ className: "text-sm text-destructive",
140
+ "data-testid": "workflow-instances-error",
141
+ role: "alert",
142
+ children: error
143
+ }, void 0, false), notConfigured && /* @__PURE__ */ jsxDEV(EmptyState, {
144
+ description: t("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),
145
+ testId: "workflow-instances-unconfigured",
146
+ title: t("Workflow inspection not configured")
147
+ }, void 0, false), !notConfigured && instances !== null && instances.length === 0 && /* @__PURE__ */ jsxDEV(EmptyState, {
148
+ description: t("No instances match this filter for the selected workflow."),
149
+ testId: "workflow-instances-empty",
150
+ title: t("No instances")
151
+ }, void 0, false), instances !== null && instances.length > 0 && /* @__PURE__ */ jsxDEV(Card, {
152
+ className: "overflow-hidden py-0",
153
+ children: /* @__PURE__ */ jsxDEV(CardContent, {
154
+ className: "px-0",
155
+ children: /* @__PURE__ */ jsxDEV(Table, {
156
+ "data-testid": "workflow-instances-table",
157
+ children: [/* @__PURE__ */ jsxDEV(TableHeader, {
158
+ children: /* @__PURE__ */ jsxDEV(TableRow, {
159
+ children: [/* @__PURE__ */ jsxDEV(TableHead, {
160
+ children: t("Instance id")
161
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
162
+ children: t("Status")
163
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
164
+ children: t("Created")
165
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
166
+ children: t("Ended")
167
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
168
+ "aria-label": t("Actions")
169
+ }, void 0, false)]
170
+ }, void 0, true)
171
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableBody, {
172
+ children: instances.map((instance) => /* @__PURE__ */ jsxDEV(TableRow, {
173
+ "data-testid": `workflow-instance-${instance.id}`,
174
+ children: [/* @__PURE__ */ jsxDEV(TableCell, {
175
+ className: "font-mono text-xs",
176
+ children: instance.id
177
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
178
+ className: "font-mono text-xs",
179
+ children: instance.status
180
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
181
+ className: "text-muted-foreground tabular-nums",
182
+ children: instance.createdOn ?? "—"
183
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
184
+ className: "text-muted-foreground tabular-nums",
185
+ children: instance.endedOn ?? "—"
186
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
187
+ className: "text-right",
188
+ children: /* @__PURE__ */ jsxDEV("div", {
189
+ className: "flex justify-end gap-1.5",
190
+ children: [/* @__PURE__ */ jsxDEV(Button, {
191
+ "data-testid": `workflow-instance-steps-${instance.id}`,
192
+ onClick: () => {
193
+ fireAndForget(openDetail(instance.id));
194
+ },
195
+ size: "sm",
196
+ type: "button",
197
+ variant: "outline",
198
+ children: t("Steps")
199
+ }, void 0, false), actionImpl !== void 0 && ACTIONS.map((action) => /* @__PURE__ */ jsxDEV(Button, {
200
+ "data-testid": `workflow-instance-${action}-${instance.id}`,
201
+ disabled: busyId === instance.id,
202
+ onClick: () => {
203
+ fireAndForget(act(instance.id, action));
204
+ },
205
+ size: "sm",
206
+ type: "button",
207
+ variant: "ghost",
208
+ children: t(action)
209
+ }, action, false))]
210
+ }, void 0, true)
211
+ }, void 0, false)]
212
+ }, instance.id, true))
213
+ }, void 0, false)]
214
+ }, void 0, true)
215
+ }, void 0, false)
216
+ }, void 0, false), detail !== null && /* @__PURE__ */ jsxDEV(Card, {
217
+ className: "overflow-hidden py-0",
218
+ "data-testid": "workflow-instance-detail",
219
+ children: /* @__PURE__ */ jsxDEV(CardContent, {
220
+ className: "flex flex-col gap-2 px-4 py-3",
221
+ children: [/* @__PURE__ */ jsxDEV("div", {
222
+ className: "flex items-center justify-between",
223
+ children: [/* @__PURE__ */ jsxDEV("span", {
224
+ className: "font-mono text-xs",
225
+ children: [t("Steps"), " · ", detail.id]
226
+ }, void 0, true), /* @__PURE__ */ jsxDEV(Button, {
227
+ "data-testid": "workflow-instance-detail-close",
228
+ onClick: () => {
229
+ setDetail(null);
230
+ },
231
+ size: "xs",
232
+ type: "button",
233
+ variant: "ghost",
234
+ children: t("Close")
235
+ }, void 0, false)]
236
+ }, void 0, true), detail.steps.length === 0 ? /* @__PURE__ */ jsxDEV("p", {
237
+ className: "text-xs text-muted-foreground",
238
+ children: t("This instance has no recorded steps yet.")
239
+ }, void 0, false) : /* @__PURE__ */ jsxDEV(Table, {
240
+ "data-testid": "workflow-instance-steps",
241
+ children: [/* @__PURE__ */ jsxDEV(TableHeader, {
242
+ children: /* @__PURE__ */ jsxDEV(TableRow, {
243
+ children: [/* @__PURE__ */ jsxDEV(TableHead, {
244
+ children: t("Step")
245
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
246
+ children: t("Type")
247
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
248
+ children: t("Attempts")
249
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
250
+ children: t("Started")
251
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
252
+ children: t("Output")
253
+ }, void 0, false)]
254
+ }, void 0, true)
255
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableBody, {
256
+ children: detail.steps.map((step, index) => /* @__PURE__ */ jsxDEV(TableRow, {
257
+ "data-testid": `workflow-step-${String(index)}`,
258
+ children: [/* @__PURE__ */ jsxDEV(TableCell, {
259
+ className: "font-mono text-xs",
260
+ children: step.name
261
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
262
+ className: "text-xs text-muted-foreground",
263
+ children: step.type ?? "—"
264
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
265
+ className: "tabular-nums",
266
+ children: step.attempts ?? "—"
267
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
268
+ className: "text-muted-foreground tabular-nums",
269
+ children: step.start ?? "—"
270
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
271
+ className: "font-mono text-xs text-muted-foreground",
272
+ children: formatStepPayload(step)
273
+ }, void 0, false)]
274
+ }, `${step.name}:${String(index)}`, true))
275
+ }, void 0, false)]
276
+ }, void 0, true)]
277
+ }, void 0, true)
278
+ }, void 0, false)]
279
+ }, void 0, true);
280
+ };
281
+
282
+ const CREATE_WORKFLOW_INSTANCE = adminRef(ADMIN_FUNCTIONS.createWorkflowInstance);
283
+ const GET_WORKFLOW_INSTANCE_STATUS = adminRef(ADMIN_FUNCTIONS.getWorkflowInstanceStatus);
284
+ const formatPayload = (instance) => {
285
+ if (instance.error) {
286
+ return `${instance.error.name}: ${instance.error.message}`;
287
+ }
288
+ if (instance.output === void 0) {
289
+ return "—";
290
+ }
291
+ try {
292
+ return JSON.stringify(instance.output);
293
+ } catch {
294
+ return "(unserializable)";
295
+ }
296
+ };
297
+ const WorkflowsPanel = () => {
298
+ const client = useLunora();
299
+ const t = useT();
300
+ const {
301
+ data,
302
+ error
303
+ } = useAdminQuery(ADMIN_FUNCTIONS.listWorkflows, {});
304
+ const [selectedExport, setSelectedExport] = useState("");
305
+ const [instanceIdInput, setInstanceIdInput] = useState("");
306
+ const [paramsText, setParamsText] = useState("");
307
+ const [starting, setStarting] = useState(false);
308
+ const [startError, setStartError] = useState(null);
309
+ const [instances, setInstances] = useState([]);
310
+ const [refreshingId, setRefreshingId] = useState(null);
311
+ const loaded = data !== void 0;
312
+ const workflows = useMemo(() => Array.isArray(data?.workflows) ? [...data.workflows].toSorted((a, b) => a.exportName.localeCompare(b.exportName)) : [], [data]);
313
+ const selectedExportName = useMemo(() => {
314
+ if (workflows.some((workflow) => workflow.exportName === selectedExport)) {
315
+ return selectedExport;
316
+ }
317
+ return workflows[0]?.exportName ?? "";
318
+ }, [workflows, selectedExport]);
319
+ const selectedWorkflow = useMemo(() => workflows.find((workflow_0) => workflow_0.exportName === selectedExportName), [workflows, selectedExportName]);
320
+ const upsertInstance = (next) => {
321
+ setInstances((previous) => {
322
+ const rest = previous.filter((entry) => !(entry.exportName === next.exportName && entry.id === next.id));
323
+ return [next, ...rest];
324
+ });
325
+ };
326
+ const start = async () => {
327
+ const exportName = selectedExportName;
328
+ if (exportName === "") {
329
+ return;
330
+ }
331
+ let parameters;
332
+ const trimmed = paramsText.trim();
333
+ if (trimmed !== "") {
334
+ try {
335
+ parameters = JSON.parse(trimmed);
336
+ } catch {
337
+ setStartError(t("Params must be valid JSON"));
338
+ return;
339
+ }
340
+ }
341
+ setStarting(true);
342
+ setStartError(null);
343
+ try {
344
+ const id = instanceIdInput.trim();
345
+ const result = await client.query(CREATE_WORKFLOW_INSTANCE, {
346
+ exportName,
347
+ id: id === "" ? void 0 : id,
348
+ params: parameters
349
+ }, callOptions(""));
350
+ upsertInstance({
351
+ exportName,
352
+ id: result.id,
353
+ status: result.status
354
+ });
355
+ setInstanceIdInput("");
356
+ } catch (error_) {
357
+ setStartError(errorMessage(error_));
358
+ } finally {
359
+ setStarting(false);
360
+ }
361
+ };
362
+ const startInstance = () => {
363
+ fireAndForget(start());
364
+ };
365
+ const refreshInstance = async (exportName_0, id_0) => {
366
+ setRefreshingId(id_0);
367
+ try {
368
+ const result_0 = await client.query(GET_WORKFLOW_INSTANCE_STATUS, {
369
+ exportName: exportName_0,
370
+ id: id_0
371
+ }, callOptions(""));
372
+ upsertInstance({
373
+ error: result_0.error,
374
+ exportName: exportName_0,
375
+ id: result_0.id,
376
+ output: result_0.output,
377
+ status: result_0.status
378
+ });
379
+ } catch (error__0) {
380
+ setStartError(errorMessage(error__0));
381
+ } finally {
382
+ setRefreshingId(null);
383
+ }
384
+ };
385
+ const onSelectedExportChange = (event) => {
386
+ setSelectedExport(event.target.value);
387
+ };
388
+ const onInstanceIdChange = (event_0) => {
389
+ setInstanceIdInput(event_0.target.value);
390
+ };
391
+ const onParamsChange = (event_1) => {
392
+ setParamsText(event_1.target.value);
393
+ };
394
+ const onRefreshClick = (event_2) => {
395
+ const {
396
+ export: exportName_1,
397
+ id: id_1
398
+ } = event_2.currentTarget.dataset;
399
+ if (exportName_1 !== void 0 && id_1 !== void 0) {
400
+ fireAndForget(refreshInstance(exportName_1, id_1));
401
+ }
402
+ };
403
+ return /* @__PURE__ */ jsxDEV("div", {
404
+ className: "flex flex-col gap-6",
405
+ "data-testid": "lunora-workflows-panel",
406
+ children: [error !== null && /* @__PURE__ */ jsxDEV("p", {
407
+ className: "text-sm text-destructive",
408
+ "data-testid": "workflows-error",
409
+ role: "alert",
410
+ children: error
411
+ }, void 0, false), /* @__PURE__ */ jsxDEV("p", {
412
+ className: "text-sm text-muted-foreground",
413
+ children: t("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")
414
+ }, void 0, false), loaded && workflows.length === 0 ? /* @__PURE__ */ jsxDEV(EmptyState, {
415
+ description: t("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),
416
+ testId: "workflows-empty",
417
+ title: t("No workflows defined")
418
+ }, void 0, false) : /* @__PURE__ */ jsxDEV(Card, {
419
+ className: "overflow-hidden py-0",
420
+ children: /* @__PURE__ */ jsxDEV(CardContent, {
421
+ className: "px-0",
422
+ children: /* @__PURE__ */ jsxDEV(Table, {
423
+ "data-testid": "workflows-table",
424
+ children: [/* @__PURE__ */ jsxDEV(TableHeader, {
425
+ children: /* @__PURE__ */ jsxDEV(TableRow, {
426
+ children: [/* @__PURE__ */ jsxDEV(TableHead, {
427
+ children: t("Export")
428
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
429
+ children: t("Name")
430
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
431
+ children: t("Class")
432
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
433
+ children: t("Binding")
434
+ }, void 0, false)]
435
+ }, void 0, true)
436
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableBody, {
437
+ children: workflows.map((workflow_1) => /* @__PURE__ */ jsxDEV(TableRow, {
438
+ "data-testid": `workflows-row-${workflow_1.exportName}`,
439
+ children: [/* @__PURE__ */ jsxDEV(TableCell, {
440
+ className: "font-mono text-xs",
441
+ children: workflow_1.exportName
442
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
443
+ className: "font-mono text-xs text-muted-foreground",
444
+ children: workflow_1.name
445
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
446
+ className: "font-mono text-xs text-muted-foreground",
447
+ children: workflow_1.className
448
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
449
+ className: "font-mono text-xs text-muted-foreground",
450
+ children: workflow_1.binding
451
+ }, void 0, false)]
452
+ }, workflow_1.exportName, true))
453
+ }, void 0, false)]
454
+ }, void 0, true)
455
+ }, void 0, false)
456
+ }, void 0, false), workflows.length > 0 && /* @__PURE__ */ jsxDEV("div", {
457
+ className: "flex flex-col gap-3",
458
+ "data-testid": "workflows-start",
459
+ children: [/* @__PURE__ */ jsxDEV("h3", {
460
+ className: "text-sm font-medium",
461
+ children: t("Start instance")
462
+ }, void 0, false), startError !== null && /* @__PURE__ */ jsxDEV("p", {
463
+ className: "text-sm text-destructive",
464
+ "data-testid": "workflows-start-error",
465
+ role: "alert",
466
+ children: startError
467
+ }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
468
+ className: "flex flex-wrap items-center gap-2",
469
+ children: [/* @__PURE__ */ jsxDEV("select", {
470
+ "aria-label": t("Workflow"),
471
+ className: "h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50",
472
+ "data-testid": "workflows-start-select",
473
+ onChange: onSelectedExportChange,
474
+ value: selectedExportName,
475
+ children: workflows.map((workflow_2) => /* @__PURE__ */ jsxDEV("option", {
476
+ value: workflow_2.exportName,
477
+ children: workflow_2.exportName
478
+ }, workflow_2.exportName, false))
479
+ }, void 0, false), /* @__PURE__ */ jsxDEV(Input, {
480
+ "aria-label": t("Instance id (optional)"),
481
+ className: "max-w-48",
482
+ "data-testid": "workflows-start-id",
483
+ onChange: onInstanceIdChange,
484
+ placeholder: t("Instance id (optional)"),
485
+ value: instanceIdInput
486
+ }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
487
+ "data-testid": "workflows-start-button",
488
+ disabled: starting || selectedExportName === "",
489
+ onClick: startInstance,
490
+ children: starting ? t("Starting…") : t("Start instance")
491
+ }, void 0, false)]
492
+ }, void 0, true), /* @__PURE__ */ jsxDEV(Textarea, {
493
+ "aria-label": t("Params (JSON)"),
494
+ className: "font-mono",
495
+ "data-testid": "workflows-start-params",
496
+ onChange: onParamsChange,
497
+ placeholder: t("Params (JSON, optional)"),
498
+ value: paramsText
499
+ }, void 0, false)]
500
+ }, void 0, true), instances.length > 0 && /* @__PURE__ */ jsxDEV("div", {
501
+ className: "flex flex-col gap-3",
502
+ "data-testid": "workflows-instances",
503
+ children: [/* @__PURE__ */ jsxDEV("h3", {
504
+ className: "text-sm font-medium",
505
+ children: t("Instances")
506
+ }, void 0, false), /* @__PURE__ */ jsxDEV(Card, {
507
+ className: "overflow-hidden py-0",
508
+ children: /* @__PURE__ */ jsxDEV(CardContent, {
509
+ className: "px-0",
510
+ children: /* @__PURE__ */ jsxDEV(Table, {
511
+ "data-testid": "workflows-instances-table",
512
+ children: [/* @__PURE__ */ jsxDEV(TableHeader, {
513
+ children: /* @__PURE__ */ jsxDEV(TableRow, {
514
+ children: [/* @__PURE__ */ jsxDEV(TableHead, {
515
+ children: t("Workflow")
516
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
517
+ children: t("Instance id")
518
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
519
+ children: t("Status")
520
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
521
+ children: t("Output")
522
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {}, void 0, false)]
523
+ }, void 0, true)
524
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableBody, {
525
+ children: instances.map((instance) => /* @__PURE__ */ jsxDEV(TableRow, {
526
+ "data-testid": `workflows-instance-${instance.id}`,
527
+ children: [/* @__PURE__ */ jsxDEV(TableCell, {
528
+ className: "font-mono text-xs",
529
+ children: instance.exportName
530
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
531
+ className: "font-mono text-xs text-muted-foreground",
532
+ children: instance.id
533
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
534
+ className: "font-mono text-xs",
535
+ children: instance.status
536
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
537
+ className: "font-mono text-xs text-muted-foreground",
538
+ children: formatPayload(instance)
539
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
540
+ children: /* @__PURE__ */ jsxDEV(Button, {
541
+ "data-export": instance.exportName,
542
+ "data-id": instance.id,
543
+ "data-testid": `workflows-instance-refresh-${instance.id}`,
544
+ disabled: refreshingId === instance.id,
545
+ onClick: onRefreshClick,
546
+ size: "xs",
547
+ variant: "outline",
548
+ children: refreshingId === instance.id ? t("Refreshing…") : t("Refresh")
549
+ }, void 0, false)
550
+ }, void 0, false)]
551
+ }, `${instance.exportName}:${instance.id}`, true))
552
+ }, void 0, false)]
553
+ }, void 0, true)
554
+ }, void 0, false)
555
+ }, void 0, false)]
556
+ }, void 0, true), selectedWorkflow !== void 0 && /* @__PURE__ */ jsxDEV(WorkflowInstanceHistory, {
557
+ workflowName: selectedWorkflow.name
558
+ }, void 0, false)]
559
+ }, void 0, true);
560
+ };
561
+
562
+ export { WorkflowsPanel as default };
@@ -12,7 +12,10 @@ const ADMIN_FUNCTIONS = {
12
12
  getAuditLog: "__lunora_admin__:getAuditLog",
13
13
  getAuthMetrics: "__lunora_admin__:getAuthMetrics",
14
14
  getCapturedMail: "__lunora_admin__:getCapturedMail",
15
+ getFanoutMetrics: "__lunora_admin__:getFanoutMetrics",
15
16
  getFunctionStats: "__lunora_admin__:getFunctionStats",
17
+ listFlags: "__lunora_admin__:listFlags",
18
+ listQueues: "__lunora_admin__:listQueues",
16
19
  listSubscriptions: "__lunora_admin__:listSubscriptions",
17
20
  listTableIndexes: "__lunora_admin__:listTableIndexes",
18
21
  listWorkflows: "__lunora_admin__:listWorkflows",
@@ -4,8 +4,8 @@ import { useState, useEffect } from 'react';
4
4
  import { B as Button } from './button-BhsN2uZH.js';
5
5
  import { E as EmptyState } from './empty-state-DY_oe0k6.js';
6
6
  import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
7
- import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-DmBqMZ-z.js';
8
- import { c as callOptions, a as adminRef, g as copyToClipboard } from './internal-rXJEAhXS.js';
7
+ import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-CdaxLGkE.js';
8
+ import { c as callOptions, a as adminRef, b as copyToClipboard } from './internal-FcNZ3beb.js';
9
9
  import { jsxDEV } from 'react/jsx-dev-runtime';
10
10
 
11
11
  const LIST_TABLES = adminRef(ADMIN_FUNCTIONS.listTables);
@@ -1,7 +1,8 @@
1
1
  import { c } from 'react/compiler-runtime';
2
2
  import { useLunora } from '@lunora/react';
3
3
  import { E as EmptyState } from './empty-state-DY_oe0k6.js';
4
- import { u as useAdminSpec, S as Skeleton, R as ReferenceView } from './reference-view-B4E49Lip.js';
4
+ import { S as Skeleton } from './skeleton-CGhL0p20.js';
5
+ import { u as useAdminSpec, R as ReferenceView } from './reference-view-Doy1XlQq.js';
5
6
  import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
6
7
  import { jsxDEV } from 'react/jsx-dev-runtime';
7
8
 
@@ -3,7 +3,7 @@ import { Dialog } from '@base-ui/react/dialog';
3
3
  import { useNavigate } from '@tanstack/react-router';
4
4
  import { useState, useRef, useEffect } from 'react';
5
5
  import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
6
- import { f as fireAndForget } from './internal-rXJEAhXS.js';
6
+ import { f as fireAndForget } from './internal-FcNZ3beb.js';
7
7
  import { c as cn } from './utils-B05Dmz_H.js';
8
8
  import { jsxDEV } from 'react/jsx-dev-runtime';
9
9