@w6w/embed 0.0.0-stage → 0.1.0

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 (102) hide show
  1. package/LICENSE +105 -0
  2. package/README.md +166 -2
  3. package/dist/W6WEmbedProvider.d.ts +29 -0
  4. package/dist/chrome/CallFromCodeButton.d.ts +155 -0
  5. package/dist/chrome/CallableSettingsModal.d.ts +17 -0
  6. package/dist/chrome/ConfirmModal.d.ts +20 -0
  7. package/dist/chrome/DangerZone.d.ts +19 -0
  8. package/dist/chrome/ExecutionProfileHeader.d.ts +69 -0
  9. package/dist/chrome/HistoryButton.d.ts +8 -0
  10. package/dist/chrome/HistoryModal.d.ts +9 -0
  11. package/dist/chrome/HistoryView.d.ts +15 -0
  12. package/dist/chrome/ImportSpecModal.d.ts +40 -0
  13. package/dist/chrome/JsonToggle.d.ts +51 -0
  14. package/dist/chrome/Modal.d.ts +20 -0
  15. package/dist/chrome/RightRail.d.ts +24 -0
  16. package/dist/chrome/TagEditor.d.ts +23 -0
  17. package/dist/chrome/VersionHistoryModal.d.ts +38 -0
  18. package/dist/chrome/history-open-run.d.ts +7 -0
  19. package/dist/chrome/index.d.ts +36 -0
  20. package/dist/chrome/workspace.d.ts +67 -0
  21. package/dist/client-context-CX61Bgw-.js +16 -0
  22. package/dist/client-context-CX61Bgw-.js.map +1 -0
  23. package/dist/draft/autosave-flush.d.ts +63 -0
  24. package/dist/draft/autosave.d.ts +68 -0
  25. package/dist/draft/client-context.d.ts +8 -0
  26. package/dist/draft/draft-registry.d.ts +14 -0
  27. package/dist/draft/index.d.ts +15 -0
  28. package/dist/draft/use-workflow-draft.d.ts +67 -0
  29. package/dist/draft/workflow-save.d.ts +48 -0
  30. package/dist/draft-registry-YF0tqNN0.js +49 -0
  31. package/dist/draft-registry-YF0tqNN0.js.map +1 -0
  32. package/dist/draft.d.ts +2 -0
  33. package/dist/draft.mjs +18 -0
  34. package/dist/draft.mjs.map +1 -0
  35. package/dist/editor/WorkflowEditor.d.ts +12 -0
  36. package/dist/editor/WorkflowSettingsModal.d.ts +17 -0
  37. package/dist/editor/definition.d.ts +31 -0
  38. package/dist/editor/editor-apps.d.ts +7 -0
  39. package/dist/editor/types.d.ts +34 -0
  40. package/dist/editor.d.ts +9 -0
  41. package/dist/editor.mjs +2170 -0
  42. package/dist/editor.mjs.map +1 -0
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.mjs +67 -0
  45. package/dist/index.mjs.map +1 -0
  46. package/dist/lib/callable-descriptors.d.ts +77 -0
  47. package/dist/lib/callable-kind.d.ts +13 -0
  48. package/dist/lib/code-rail.d.ts +45 -0
  49. package/dist/lib/document-sources.d.ts +26 -0
  50. package/dist/lib/error-handler-self.d.ts +25 -0
  51. package/dist/lib/history-query.d.ts +135 -0
  52. package/dist/lib/import-paste.d.ts +41 -0
  53. package/dist/lib/index.d.ts +17 -0
  54. package/dist/lib/new-id.d.ts +10 -0
  55. package/dist/lib/rail-settings.d.ts +196 -0
  56. package/dist/lib/save-invalidation.d.ts +24 -0
  57. package/dist/lib/sdk-snippets.d.ts +96 -0
  58. package/dist/lib/settings-rail.d.ts +68 -0
  59. package/dist/lib/slug.d.ts +69 -0
  60. package/dist/lib/spec-import-invalidation.d.ts +48 -0
  61. package/dist/lib/tag-editor.d.ts +36 -0
  62. package/dist/lib/trigger-preview.d.ts +89 -0
  63. package/dist/lib/workflow-live-run.d.ts +165 -0
  64. package/dist/lib/workflow-poll.d.ts +8 -0
  65. package/dist/lib/workflow-route.d.ts +26 -0
  66. package/dist/lib/workflow-settings.d.ts +72 -0
  67. package/dist/lib/workflow-validity.d.ts +92 -0
  68. package/dist/lib/workflow-variables.d.ts +106 -0
  69. package/dist/lib.d.ts +2 -0
  70. package/dist/lib.mjs +62 -0
  71. package/dist/lib.mjs.map +1 -0
  72. package/dist/project-context-Dbk0Gr1K.js +16 -0
  73. package/dist/project-context-Dbk0Gr1K.js.map +1 -0
  74. package/dist/project-context.d.ts +11 -0
  75. package/dist/rail/CodeTool.d.ts +2 -0
  76. package/dist/rail/ErrorHandlingTool.d.ts +22 -0
  77. package/dist/rail/ExpressionScope.d.ts +21 -0
  78. package/dist/rail/SettingsTool.d.ts +27 -0
  79. package/dist/rail/editor-tools.d.ts +2 -0
  80. package/dist/rail/rail-env.d.ts +18 -0
  81. package/dist/rail/settings-sections.d.ts +93 -0
  82. package/dist/repos/documents.d.ts +102 -0
  83. package/dist/repos/history.d.ts +24 -0
  84. package/dist/repos/index.d.ts +22 -0
  85. package/dist/repos/spec-import.d.ts +44 -0
  86. package/dist/repos/step-tests.d.ts +19 -0
  87. package/dist/repos/vars.d.ts +25 -0
  88. package/dist/repos/vault.d.ts +24 -0
  89. package/dist/repos/versions.d.ts +112 -0
  90. package/dist/repos.d.ts +2 -0
  91. package/dist/repos.mjs +94 -0
  92. package/dist/repos.mjs.map +1 -0
  93. package/dist/slug-ByKQgxrf.js +642 -0
  94. package/dist/slug-ByKQgxrf.js.map +1 -0
  95. package/dist/spec-import-HgO7ZkLZ.js +898 -0
  96. package/dist/spec-import-HgO7ZkLZ.js.map +1 -0
  97. package/dist/spec-import-invalidation-D3retX4Q.js +18 -0
  98. package/dist/spec-import-invalidation-D3retX4Q.js.map +1 -0
  99. package/dist/use-workflow-draft-oI02dsP-.js +314 -0
  100. package/dist/use-workflow-draft-oI02dsP-.js.map +1 -0
  101. package/package.json +71 -3
  102. package/src/styles.css +829 -0
@@ -0,0 +1,898 @@
1
+ import { useQueryClient as c, useMutation as u, useQuery as l, keepPreviousData as Q } from "@tanstack/react-query";
2
+ import { isTerminalRunStatus as C, path as f } from "@w6w/sdk";
3
+ import { u as s } from "./client-context-CX61Bgw-.js";
4
+ import { useCallback as A } from "react";
5
+ import { i as N } from "./spec-import-invalidation-D3retX4Q.js";
6
+ const S = "Step failed without reporting a reason.", P = "Run failed without reporting a reason.";
7
+ function M(e) {
8
+ return e === void 0 || !C(e);
9
+ }
10
+ function L(e, t) {
11
+ return t || e === void 0 ? !1 : !C(e);
12
+ }
13
+ function Ee(e, t) {
14
+ return L(e, t) ? e === "queued" ? "Queued…" : "Running…" : "Run";
15
+ }
16
+ function Ke(e) {
17
+ return e === "run_not_cancelable" ? "reconcile" : "surface";
18
+ }
19
+ function O(e) {
20
+ return e ? Object.entries(e).map(([t, n]) => ({
21
+ id: t,
22
+ status: n.status,
23
+ startedAt: n.startedAt,
24
+ finishedAt: n.finishedAt,
25
+ input: n.input,
26
+ output: n.output,
27
+ ...n.meta !== void 0 && n.meta !== null ? { meta: n.meta } : {},
28
+ ...D(n)
29
+ })) : [];
30
+ }
31
+ function D(e) {
32
+ const t = b(e.error);
33
+ return t ? { error: t } : e.status === "failed" ? { error: { message: S } } : {};
34
+ }
35
+ function b(e) {
36
+ if (e != null) {
37
+ if (typeof e == "string" && e !== "") return { message: e };
38
+ if (typeof e == "object") {
39
+ const t = e, n = typeof t.code == "string" ? t.code : void 0, o = typeof t.message == "string" && t.message !== "" ? t.message : n || _(e);
40
+ return {
41
+ ...n !== void 0 ? { code: n } : {},
42
+ message: o || "Unknown error.",
43
+ ...typeof t.phase == "string" ? { phase: t.phase } : {},
44
+ ...typeof t.retryable == "boolean" ? { retryable: t.retryable } : {}
45
+ };
46
+ }
47
+ return { message: String(e) || "Unknown error." };
48
+ }
49
+ }
50
+ function _(e) {
51
+ try {
52
+ return JSON.stringify(e) ?? "";
53
+ } catch {
54
+ return "";
55
+ }
56
+ }
57
+ function Fe(e, t) {
58
+ if (!e) return {};
59
+ const n = new Set(t.filter((i) => i.error !== void 0).map((i) => i.id)), o = new Set(
60
+ t.filter((i) => i.error !== void 0 && i.error.message !== S).map((i) => i.id)
61
+ ), r = (e.stepErrors ?? []).filter((i) => !o.has(i.stepId)).map((i) => ({
62
+ stepId: i.stepId,
63
+ error: b(i.error) ?? { message: S }
64
+ })), a = b(e.error), d = (i) => a !== void 0 && (i == null ? void 0 : i.message) === a.message && (i == null ? void 0 : i.code) === a.code;
65
+ let w = t.some((i) => d(i.error)) || r.some((i) => d(i.error)) ? void 0 : a;
66
+ return !w && e.status === "failed" && n.size === 0 && r.length === 0 && (w = { message: P }), {
67
+ ...w ? { runError: w } : {},
68
+ ...r.length > 0 ? { stepErrors: r } : {}
69
+ };
70
+ }
71
+ function $(e) {
72
+ var n;
73
+ const t = (n = e == null ? void 0 : e[e.length - 1]) == null ? void 0 : n.with;
74
+ if (!(t === null || typeof t != "object" || Array.isArray(t)))
75
+ return t;
76
+ }
77
+ async function Re(e, t) {
78
+ if (e)
79
+ try {
80
+ return $(await t(e));
81
+ } catch {
82
+ return;
83
+ }
84
+ }
85
+ const j = {
86
+ status: "",
87
+ kind: "",
88
+ from: "",
89
+ to: "",
90
+ q: "",
91
+ offset: 0
92
+ }, v = 25, W = /* @__PURE__ */ new Set([
93
+ "queued",
94
+ "running",
95
+ "succeeded",
96
+ "failed",
97
+ "canceled"
98
+ ]), x = /* @__PURE__ */ new Set(["function", "endpoint", "workflow"]), V = /^\d{4}-\d{2}-\d{2}$/;
99
+ function m(e) {
100
+ if (!V.test(e)) return !1;
101
+ const { y: t, m: n, d: o } = g(e), r = new Date(t, n - 1, o);
102
+ return r.getFullYear() === t && r.getMonth() === n - 1 && r.getDate() === o;
103
+ }
104
+ function g(e) {
105
+ const [t, n, o] = e.split("-").map(Number);
106
+ return { y: t, m: n, d: o };
107
+ }
108
+ function Ie(e) {
109
+ const t = new URLSearchParams(e), n = t.get("status") ?? "", o = t.get("kind") ?? "", r = t.get("from") ?? "", a = t.get("to") ?? "", d = t.get("q") ?? "", p = t.get("offset");
110
+ let w = 0;
111
+ if (p !== null) {
112
+ const i = Number(p);
113
+ Number.isInteger(i) && i >= 0 && (w = i);
114
+ }
115
+ return {
116
+ status: W.has(n) ? n : "",
117
+ kind: x.has(o) ? o : "",
118
+ from: m(r) ? r : "",
119
+ to: m(a) ? a : "",
120
+ q: d,
121
+ offset: w
122
+ };
123
+ }
124
+ function Qe(e) {
125
+ const t = new URLSearchParams();
126
+ e.status !== "" && t.set("status", e.status), e.kind !== "" && t.set("kind", e.kind), e.from !== "" && t.set("from", e.from), e.to !== "" && t.set("to", e.to), e.q !== "" && t.set("q", e.q), e.offset > 0 && t.set("offset", String(e.offset));
127
+ const n = t.toString();
128
+ return n === "" ? "" : `?${n}`;
129
+ }
130
+ function E(e, t, n) {
131
+ const o = {};
132
+ if ("project" in e ? (o.project = e.project, t.kind !== "" && (o.kind = t.kind)) : o.callable = e.callable, t.status !== "" && (o.status = t.status), t.from !== "" && m(t.from)) {
133
+ const { y: a, m: d, d: p } = g(t.from);
134
+ o.from = new Date(a, d - 1, p).toISOString();
135
+ }
136
+ if (t.to !== "" && m(t.to)) {
137
+ const { y: a, m: d, d: p } = g(t.to);
138
+ o.to = new Date(a, d - 1, p + 1).toISOString();
139
+ }
140
+ const r = t.q.trim();
141
+ return r !== "" && (o.q = r), n.paged && (o.limit = String(n.limit ?? v), t.offset > 0 && (o.offset = String(t.offset))), o;
142
+ }
143
+ const y = {
144
+ root: ["history"],
145
+ list(e, t, n) {
146
+ return ["history", "list", e, t, n];
147
+ },
148
+ stats(e, t) {
149
+ return ["history", "stats", e, t];
150
+ },
151
+ exists(e) {
152
+ return ["history", "exists", e];
153
+ },
154
+ detail(e, t) {
155
+ return ["history", "detail", e, t];
156
+ }
157
+ };
158
+ function K(e, t, n, o = v) {
159
+ return e.request({
160
+ method: "GET",
161
+ path: "/history",
162
+ query: E(t, n, { paged: !0, limit: o })
163
+ }).then((r) => r.body);
164
+ }
165
+ function U(e, t, n) {
166
+ return e.request({
167
+ method: "GET",
168
+ path: "/history/stats",
169
+ query: E(t, n, { paged: !1 })
170
+ }).then((o) => o.body.stats);
171
+ }
172
+ async function H(e, t) {
173
+ if (t.kind === "workflow") {
174
+ const r = await e.console.workflows.getRun(t.id);
175
+ return {
176
+ id: t.id,
177
+ kind: "workflow",
178
+ callableName: t.callableName,
179
+ status: r.status,
180
+ startedAt: t.startedAt,
181
+ finishedAt: t.finishedAt,
182
+ durationMs: t.durationMs,
183
+ input: r.variables,
184
+ output: r.output,
185
+ error: r.error,
186
+ steps: O(r.steps)
187
+ };
188
+ }
189
+ const o = (await e.request({
190
+ method: "GET",
191
+ path: `/invocations/${encodeURIComponent(t.id)}`
192
+ })).body.invocation;
193
+ return {
194
+ id: t.id,
195
+ kind: t.kind,
196
+ callableName: t.callableName,
197
+ status: o.status,
198
+ startedAt: o.startedAt,
199
+ finishedAt: o.finishedAt,
200
+ durationMs: o.durationMs,
201
+ input: o.input,
202
+ output: o.output,
203
+ error: o.error
204
+ };
205
+ }
206
+ const B = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled"]);
207
+ function G(e) {
208
+ return new Promise((t) => setTimeout(t, e));
209
+ }
210
+ async function Y(e, t = G) {
211
+ for (let n = 0; n < 600; n++) {
212
+ const o = await e();
213
+ if (B.has(o.status)) return o;
214
+ await t(500);
215
+ }
216
+ return e();
217
+ }
218
+ const J = (e) => ["workflows", e];
219
+ function z(e, t) {
220
+ return e.workflows.list({ project: t });
221
+ }
222
+ function Ae(e, t = !0) {
223
+ const n = s();
224
+ return l({
225
+ queryKey: J(e),
226
+ queryFn: () => z(n, e),
227
+ enabled: t
228
+ });
229
+ }
230
+ const F = (e) => ["workflow", e];
231
+ function Z(e, t) {
232
+ return e.workflows.get(t);
233
+ }
234
+ function Ne(e, t = !0) {
235
+ const n = s();
236
+ return l({
237
+ queryKey: F(e),
238
+ queryFn: () => Z(n, e),
239
+ enabled: t
240
+ });
241
+ }
242
+ function Pe(e) {
243
+ const t = s(), n = c();
244
+ return u({
245
+ mutationFn: (o) => e ? t.console.workflows.upsert(o, { project: e }) : Promise.reject(new Error("No project selected yet.")),
246
+ onSuccess: () => n.invalidateQueries({ queryKey: ["workflows"] })
247
+ });
248
+ }
249
+ function Me(e) {
250
+ const t = s(), n = c();
251
+ return u({
252
+ mutationFn: (o) => e ? t.console.workflows.upsert(o.definition, {
253
+ project: e,
254
+ ifUnmodifiedSince: o.ifUnmodifiedSince
255
+ }) : Promise.reject(new Error("No project selected yet.")),
256
+ onSuccess: () => n.invalidateQueries({ queryKey: ["workflows"] })
257
+ });
258
+ }
259
+ function Le() {
260
+ const e = s(), t = c();
261
+ return u({
262
+ mutationFn: (n) => e.workflows.archive(n),
263
+ onSuccess: () => t.invalidateQueries({ queryKey: ["workflows"] })
264
+ });
265
+ }
266
+ function Oe() {
267
+ const e = s(), t = c();
268
+ return u({
269
+ mutationFn: (n) => e.workflows.delete(n),
270
+ onSuccess: () => t.invalidateQueries({ queryKey: ["workflows"] })
271
+ });
272
+ }
273
+ const T = (e) => ["runs", e];
274
+ function De(e) {
275
+ const t = s();
276
+ return l({
277
+ queryKey: T(e),
278
+ queryFn: () => t.console.workflows.listRuns(e)
279
+ });
280
+ }
281
+ function X(e, t, n, o) {
282
+ return e.workflows.run(t, { variables: n, input: o, allowUnpublished: !0 }).then((r) => Y(() => e.console.workflows.getRun(r.runId)));
283
+ }
284
+ function _e() {
285
+ const e = s(), t = c();
286
+ return u({
287
+ mutationFn: (n) => X(e, n.id, n.variables, n.input),
288
+ onSuccess: (n, o) => t.invalidateQueries({ queryKey: T(o.id) }),
289
+ onSettled: () => t.invalidateQueries({ queryKey: y.root })
290
+ });
291
+ }
292
+ function $e(e, t, n, o) {
293
+ return e.workflows.run(t, { variables: n, input: o, wait: !0 });
294
+ }
295
+ function ee(e, t, n, o) {
296
+ return e.workflows.run(t, { variables: n, input: o, allowUnpublished: !0 }).then((r) => ({ runId: r.runId }));
297
+ }
298
+ function je() {
299
+ const e = s(), t = c();
300
+ return u({
301
+ mutationFn: (n) => ee(e, n.id, n.variables, n.input),
302
+ onSuccess: (n, o) => t.invalidateQueries({ queryKey: T(o.id) }),
303
+ onSettled: () => t.invalidateQueries({ queryKey: y.root })
304
+ });
305
+ }
306
+ function te(e, t) {
307
+ return e.workflows.cancel(t);
308
+ }
309
+ function We() {
310
+ const e = s();
311
+ return u({
312
+ mutationFn: (t) => te(e, t)
313
+ });
314
+ }
315
+ function ne(e, t) {
316
+ return e.console.workflows.getRun(t);
317
+ }
318
+ const oe = (e) => ["run", e];
319
+ function xe(e) {
320
+ const t = s();
321
+ return l({
322
+ queryKey: oe(e ?? ""),
323
+ queryFn: () => ne(t, e),
324
+ enabled: e != null,
325
+ refetchInterval: (n) => {
326
+ var o;
327
+ return M((o = n.state.data) == null ? void 0 : o.status) ? 500 : !1;
328
+ }
329
+ });
330
+ }
331
+ const re = {
332
+ function: (e) => ["function", e],
333
+ endpoint: (e) => ["endpoint", e],
334
+ workflow: (e) => ["workflow", e]
335
+ };
336
+ function R(e, t) {
337
+ return re[e](t);
338
+ }
339
+ function se(e, t, n) {
340
+ e.invalidateQueries({ queryKey: t }), e.invalidateQueries({ queryKey: n });
341
+ }
342
+ const ie = (e) => R("endpoint", e), ae = (e) => R("function", e), h = {
343
+ function: "functions",
344
+ workflow: "workflows",
345
+ endpoint: "endpoints"
346
+ }, ue = {
347
+ function: "invoke",
348
+ endpoint: "invoke",
349
+ workflow: "run"
350
+ };
351
+ function k(e, t) {
352
+ return ["versions", e, t];
353
+ }
354
+ function ce(e, t, n) {
355
+ return ["version", e, t, n];
356
+ }
357
+ function Ve(e, t, n) {
358
+ const o = s();
359
+ return l({
360
+ queryKey: k(e, t),
361
+ queryFn: async () => {
362
+ switch (e) {
363
+ case "workflow":
364
+ return await o.workflows.listVersions(t);
365
+ case "function":
366
+ return await o.functions.listVersions(t);
367
+ case "endpoint":
368
+ return (await o.request({
369
+ method: "GET",
370
+ path: f`/${h.endpoint}/${t}/versions`
371
+ })).body;
372
+ }
373
+ },
374
+ enabled: n && e !== null && t !== ""
375
+ });
376
+ }
377
+ function Ue(e, t, n, o) {
378
+ const r = s();
379
+ return l({
380
+ queryKey: ce(e, t, n),
381
+ queryFn: async () => {
382
+ const a = n;
383
+ switch (e) {
384
+ case "workflow":
385
+ return await r.workflows.getVersion(t, a);
386
+ case "function":
387
+ return await r.functions.getVersion(t, a);
388
+ case "endpoint":
389
+ return (await r.request({
390
+ method: "GET",
391
+ path: f`/${h.endpoint}/${t}/versions/${String(a)}`
392
+ })).body.version;
393
+ }
394
+ },
395
+ enabled: o && e !== null && t !== "" && n !== null
396
+ });
397
+ }
398
+ function He(e) {
399
+ const t = s(), n = c();
400
+ return u({
401
+ mutationFn: async (o) => {
402
+ switch (e) {
403
+ case "workflow":
404
+ return await t.workflows.publish(o);
405
+ case "function":
406
+ return await t.functions.publish(o);
407
+ case "endpoint":
408
+ return (await t.request({
409
+ method: "POST",
410
+ path: f`/${h.endpoint}/${o}/publish`
411
+ })).body;
412
+ }
413
+ },
414
+ onSuccess: (o, r) => {
415
+ n.invalidateQueries({ queryKey: k(e, r) });
416
+ }
417
+ });
418
+ }
419
+ function Be(e) {
420
+ const t = s(), n = c();
421
+ return u({
422
+ mutationFn: async (o) => {
423
+ switch (e) {
424
+ case "workflow":
425
+ return o.enabled ? await t.workflows.enable(o.id) : await t.workflows.disable(o.id), { enabled: o.enabled };
426
+ case "function":
427
+ return o.enabled ? await t.functions.enable(o.id) : await t.functions.disable(o.id), { enabled: o.enabled };
428
+ case "endpoint":
429
+ return (await t.request({
430
+ method: "POST",
431
+ path: f`/${h.endpoint}/${o.id}/${o.enabled ? "enable" : "disable"}`
432
+ })).body;
433
+ }
434
+ },
435
+ onSuccess: (o, r) => {
436
+ n.invalidateQueries({ queryKey: k(e, r.id) });
437
+ }
438
+ });
439
+ }
440
+ function Ge(e) {
441
+ const t = s(), n = c();
442
+ return u({
443
+ mutationFn: async (o) => {
444
+ switch (e) {
445
+ case "workflow":
446
+ return { reverted: await t.workflows.revert(o.id, o.versionNumber) };
447
+ case "function":
448
+ return { reverted: await t.functions.revert(o.id, o.versionNumber) };
449
+ case "endpoint":
450
+ return (await t.request({
451
+ method: "POST",
452
+ path: f`/${h.endpoint}/${o.id}/versions/${String(o.versionNumber)}/revert`
453
+ })).body;
454
+ }
455
+ },
456
+ onSuccess: (o, r) => {
457
+ let a;
458
+ switch (e) {
459
+ case "function":
460
+ a = ae(r.id);
461
+ break;
462
+ case "workflow":
463
+ a = F(r.id);
464
+ break;
465
+ case "endpoint":
466
+ a = ie(r.id);
467
+ break;
468
+ }
469
+ se(n, k(e, r.id), a);
470
+ }
471
+ });
472
+ }
473
+ function Ye(e) {
474
+ const t = s(), n = c();
475
+ return u({
476
+ mutationFn: async (o) => {
477
+ if (e === "workflow") {
478
+ const a = await t.workflows.runVersion(o.id, o.versionNumber, {});
479
+ return { runId: a.runId, status: a.status };
480
+ }
481
+ return (await t.request({
482
+ method: "POST",
483
+ path: f`/${h[e]}/${o.id}/versions/${String(o.versionNumber)}/${ue[e]}`,
484
+ body: {}
485
+ })).body;
486
+ },
487
+ onSettled: () => n.invalidateQueries({ queryKey: y.root })
488
+ });
489
+ }
490
+ const Je = (e, t) => ["stepTests", e, t];
491
+ function ze(e, t, n) {
492
+ return e.console.stepTests.list(t, n);
493
+ }
494
+ function Ze(e, t, n, o) {
495
+ return e.console.stepTests.save(t, n, o);
496
+ }
497
+ function Xe(e, t, n, o) {
498
+ return e.console.stepTests.recordRun(t, n, o).then(() => {
499
+ });
500
+ }
501
+ const I = { project: "" };
502
+ function et(e, t, n = v) {
503
+ const o = s();
504
+ return l({
505
+ queryKey: y.list(e ?? I, t, n),
506
+ queryFn: () => K(o, e, t, n),
507
+ enabled: e !== null,
508
+ placeholderData: Q
509
+ });
510
+ }
511
+ function tt(e, t) {
512
+ const n = s();
513
+ return l({
514
+ queryKey: y.stats(e ?? I, t),
515
+ queryFn: () => U(n, e, t),
516
+ enabled: e !== null
517
+ });
518
+ }
519
+ function nt(e) {
520
+ var o, r;
521
+ const t = s(), n = l({
522
+ queryKey: y.exists(e),
523
+ queryFn: () => K(t, { callable: e }, j, 1)
524
+ });
525
+ return {
526
+ hasExecuted: (((r = (o = n.data) == null ? void 0 : o.executions) == null ? void 0 : r.length) ?? 0) > 0,
527
+ isLoading: n.isLoading
528
+ };
529
+ }
530
+ function ot(e) {
531
+ const t = s();
532
+ return l({
533
+ queryKey: y.detail((e == null ? void 0 : e.kind) ?? "function", (e == null ? void 0 : e.id) ?? ""),
534
+ queryFn: () => H(t, e),
535
+ enabled: e !== null
536
+ });
537
+ }
538
+ function le(e) {
539
+ return ["vars", e];
540
+ }
541
+ function rt(e, t = !0) {
542
+ const n = s();
543
+ return l({
544
+ queryKey: le(e),
545
+ enabled: t,
546
+ queryFn: async () => (await n.request({
547
+ method: "GET",
548
+ path: "/vars",
549
+ query: { project: e }
550
+ })).body.vars
551
+ });
552
+ }
553
+ function st() {
554
+ const e = s(), t = c();
555
+ return u({
556
+ mutationFn: async (n) => (await e.request({
557
+ method: "POST",
558
+ path: "/vars",
559
+ query: { project: n.project },
560
+ body: {
561
+ name: n.input.name,
562
+ type: n.input.type,
563
+ value: n.input.value,
564
+ description: n.input.description
565
+ }
566
+ })).body.var,
567
+ onSuccess: () => t.invalidateQueries({ queryKey: ["vars"] })
568
+ });
569
+ }
570
+ function it() {
571
+ const e = s(), t = c();
572
+ return u({
573
+ mutationFn: async (n) => (await e.request({
574
+ method: "PATCH",
575
+ path: f`/vars/${n.id}`,
576
+ query: { project: n.project },
577
+ body: {
578
+ type: n.patch.type,
579
+ value: n.patch.value,
580
+ description: n.patch.description
581
+ }
582
+ })).body.var,
583
+ onSuccess: () => t.invalidateQueries({ queryKey: ["vars"] })
584
+ });
585
+ }
586
+ function at() {
587
+ const e = s(), t = c();
588
+ return u({
589
+ mutationFn: async (n) => {
590
+ await e.request({
591
+ method: "DELETE",
592
+ path: f`/vars/${n.id}`,
593
+ query: { project: n.project }
594
+ });
595
+ },
596
+ onSuccess: () => t.invalidateQueries({ queryKey: ["vars"] })
597
+ });
598
+ }
599
+ const q = ["secrets"];
600
+ function de(e) {
601
+ return e.console.vault.list();
602
+ }
603
+ function ut() {
604
+ const e = s();
605
+ return l({ queryKey: q, queryFn: () => de(e) });
606
+ }
607
+ function fe(e, t) {
608
+ return e.console.vault.seal(t);
609
+ }
610
+ function ct() {
611
+ const e = s();
612
+ return A((t) => fe(e, t), [e]);
613
+ }
614
+ function lt() {
615
+ const e = s(), t = c();
616
+ return u({
617
+ mutationFn: (n) => e.console.vault.create(n),
618
+ onSuccess: () => t.invalidateQueries({ queryKey: q })
619
+ });
620
+ }
621
+ function dt(e) {
622
+ const t = s(), n = c();
623
+ return u({
624
+ mutationFn: (o) => t.console.vault.update(e, o),
625
+ onSuccess: () => n.invalidateQueries({ queryKey: q })
626
+ });
627
+ }
628
+ function ft() {
629
+ const e = s(), t = c();
630
+ return u({
631
+ mutationFn: (n) => e.console.vault.delete(n),
632
+ onSuccess: () => t.invalidateQueries({ queryKey: q })
633
+ });
634
+ }
635
+ function pt(e) {
636
+ return e.shared ? e.sourceRepo == null ? "pending" : "synced" : "private";
637
+ }
638
+ function pe(e) {
639
+ return ["documents", e];
640
+ }
641
+ function we(e, t) {
642
+ return ["documents", "detail", e, t];
643
+ }
644
+ function wt(e, t, n = !0) {
645
+ const o = s();
646
+ return l({
647
+ queryKey: we(e, t),
648
+ queryFn: async () => await o.documents.get(e, { project: t }),
649
+ enabled: n
650
+ });
651
+ }
652
+ function yt(e, t = !0) {
653
+ const n = s();
654
+ return l({
655
+ queryKey: pe(e),
656
+ // Cast to DocWithProvenance[], same as useDocumentQuery above: the wire
657
+ // response already carries `shared`/`source*`/`syncedAt` (repo.list()
658
+ // serializes every document the same way repo.get() does), but the SDK's
659
+ // own `Doc` type doesn't declare them yet (D-5). Without this cast,
660
+ // DocumentsPage.tsx's list rows have no type-visible way to branch on
661
+ // `d.shared` the way DocumentDetailPage.tsx already does.
662
+ queryFn: async () => await n.documents.list({ project: e }),
663
+ enabled: t
664
+ });
665
+ }
666
+ function ht() {
667
+ const e = s(), t = c();
668
+ return u({
669
+ mutationFn: (n) => e.documents.create(n.input, { project: n.project }),
670
+ onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
671
+ });
672
+ }
673
+ function mt() {
674
+ const e = s(), t = c();
675
+ return u({
676
+ mutationFn: (n) => e.documents.update(n.id, n.patch, { project: n.project }),
677
+ onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
678
+ });
679
+ }
680
+ function kt() {
681
+ const e = s(), t = c();
682
+ return u({
683
+ mutationFn: (n) => e.documents.delete(n.id, { project: n.project }),
684
+ onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
685
+ });
686
+ }
687
+ function qt() {
688
+ const e = s(), t = c();
689
+ return u({
690
+ mutationFn: (n) => e.request({
691
+ method: "POST",
692
+ path: f`/documents/${n.id}/sync`,
693
+ query: { project: n.project }
694
+ }),
695
+ onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
696
+ });
697
+ }
698
+ const ye = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", he = 248, me = (e) => crypto.getRandomValues(new Uint8Array(e));
699
+ function ke(e, t = 16, n = me) {
700
+ let o = "";
701
+ for (; o.length < t; )
702
+ for (const r of n(Math.max(t - o.length, 8)))
703
+ if (!(r >= he) && (o += ye[r % 62], o.length === t))
704
+ break;
705
+ return `${e}_${o}`;
706
+ }
707
+ const qe = {
708
+ function: {
709
+ kind: "function",
710
+ listTitle: "Functions",
711
+ listDescription: 'A Function is a reusable, vendor-abstracted operation — "Send Email", "Create Contact" — with a stable interface bound to one swappable app action. Switch provider by re-binding; callers never change.',
712
+ emptyCopy: "None yet — click “New function” to create one, or “Import” to bring in a spec document.",
713
+ newLabel: "+ New function",
714
+ newIdPrefix: "fn",
715
+ importOpenTestId: "functions-import-open",
716
+ showArchivedTestId: "functions-show-archived",
717
+ archivedBadgeTestId: "function-archived",
718
+ openRowTitle: "Open this function in the editor.",
719
+ editor: {
720
+ backLabel: "← Functions",
721
+ newTitle: "New function",
722
+ notFoundTitle: "Function not found",
723
+ saveLabel: "Save"
724
+ },
725
+ settings: {
726
+ canEditKey: !0,
727
+ hasTags: !1,
728
+ namePlaceholder: "Send Email",
729
+ keyPlaceholder: "send-email",
730
+ keyHintSuffix: ""
731
+ }
732
+ },
733
+ endpoint: {
734
+ kind: "endpoint",
735
+ listTitle: "Endpoints",
736
+ listDescription: "An Endpoint is a named, stable entry point that dispatches to one app action, Function, or Workflow. Callers bind to the Endpoint; the target behind it can change — promote an action to a Function or a Workflow, or re-bind it — without breaking a single caller.",
737
+ emptyCopy: "None yet — click “New endpoint” to create one.",
738
+ newLabel: "+ New endpoint",
739
+ newIdPrefix: "ep",
740
+ importOpenTestId: "endpoints-import-open",
741
+ showArchivedTestId: "endpoints-show-archived",
742
+ archivedBadgeTestId: "endpoint-archived",
743
+ openRowTitle: "Open this endpoint in the editor.",
744
+ editor: {
745
+ backLabel: "← Endpoints",
746
+ newTitle: "New endpoint",
747
+ notFoundTitle: "Endpoint not found",
748
+ saveLabel: "Save"
749
+ },
750
+ settings: {
751
+ canEditKey: !1,
752
+ hasTags: !1,
753
+ namePlaceholder: "My endpoint",
754
+ keyPlaceholder: "send-email",
755
+ keyHintSuffix: ""
756
+ }
757
+ },
758
+ workflow: {
759
+ kind: "workflow",
760
+ listTitle: "Workflows",
761
+ listDescription: "A Workflow is a durable, multi-step run: each step calls an app action, a Function, or another Workflow, and a run keeps its own state, history and error handling.",
762
+ emptyCopy: "None yet — click “New workflow” to create one.",
763
+ newLabel: "+ New workflow",
764
+ newIdPrefix: "wf",
765
+ importOpenTestId: "workflows-import-open",
766
+ showArchivedTestId: "workflows-show-archived",
767
+ archivedBadgeTestId: "workflow-archived",
768
+ openRowTitle: "Open this workflow in the visual editor.",
769
+ editor: {
770
+ backLabel: "← Workflows",
771
+ newTitle: "New workflow",
772
+ notFoundTitle: "Workflow not found",
773
+ saveLabel: "Save"
774
+ },
775
+ settings: {
776
+ canEditKey: !0,
777
+ hasTags: !0,
778
+ namePlaceholder: "My workflow",
779
+ keyPlaceholder: "unset",
780
+ keyHintSuffix: " Leave empty to unset."
781
+ }
782
+ }
783
+ };
784
+ function Se(e) {
785
+ return qe[e];
786
+ }
787
+ function St(e) {
788
+ return ke(Se(e).newIdPrefix);
789
+ }
790
+ function bt(e, t) {
791
+ const n = s(), o = c();
792
+ return u({
793
+ mutationFn: async (r) => (await n.request({
794
+ method: "POST",
795
+ path: "/spec/import",
796
+ body: r
797
+ })).body,
798
+ // A row exists in every `201` outcome (T2.1.2 §E creates it even when
799
+ // some references stayed unresolved), so the list is stale either way —
800
+ // but ONLY the list the imported kind actually belongs to (AC-3): the
801
+ // unconditional `functionsKey` this used to invalidate left an imported
802
+ // Endpoint or Workflow's own list stale while pointlessly invalidating
803
+ // Functions.
804
+ onSuccess: (r) => N(o, r.kind, t, e)
805
+ });
806
+ }
807
+ export {
808
+ kt as $,
809
+ Xe as A,
810
+ Re as B,
811
+ qe as C,
812
+ Ee as D,
813
+ j as E,
814
+ Fe as F,
815
+ oe as G,
816
+ v as H,
817
+ ye as I,
818
+ X as J,
819
+ $e as K,
820
+ T as L,
821
+ Ze as M,
822
+ fe as N,
823
+ q as O,
824
+ M as P,
825
+ ee as Q,
826
+ P as R,
827
+ S,
828
+ Je as T,
829
+ b as U,
830
+ Le as V,
831
+ We as W,
832
+ ht as X,
833
+ lt as Y,
834
+ st as Z,
835
+ Pe as _,
836
+ te as a,
837
+ ft as a0,
838
+ at as a1,
839
+ Oe as a2,
840
+ wt as a3,
841
+ yt as a4,
842
+ ot as a5,
843
+ nt as a6,
844
+ et as a7,
845
+ tt as a8,
846
+ bt as a9,
847
+ Ye as aa,
848
+ xe as ab,
849
+ He as ac,
850
+ Ge as ad,
851
+ _e as ae,
852
+ De as af,
853
+ Me as ag,
854
+ ct as ah,
855
+ ut as ai,
856
+ Be as aj,
857
+ je as ak,
858
+ qt as al,
859
+ mt as am,
860
+ dt as an,
861
+ it as ao,
862
+ rt as ap,
863
+ Ue as aq,
864
+ Ve as ar,
865
+ Ne as as,
866
+ Ae as at,
867
+ le as au,
868
+ ce as av,
869
+ k as aw,
870
+ F as ax,
871
+ J as ay,
872
+ Ke as b,
873
+ R as c,
874
+ Se as d,
875
+ we as e,
876
+ pt as f,
877
+ pe as g,
878
+ Ie as h,
879
+ Qe as i,
880
+ H as j,
881
+ K as k,
882
+ U as l,
883
+ ne as m,
884
+ Z as n,
885
+ y as o,
886
+ E as p,
887
+ se as q,
888
+ L as r,
889
+ $ as s,
890
+ de as t,
891
+ ze as u,
892
+ z as v,
893
+ O as w,
894
+ St as x,
895
+ ke as y,
896
+ Y as z
897
+ };
898
+ //# sourceMappingURL=spec-import-HgO7ZkLZ.js.map