@w6w/embed 0.2.34 → 0.2.35

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 (74) hide show
  1. package/dist/{CreateFunctionModal-glk2zg1r.js → CreateFunctionModal-CYNHJUGJ.js} +3 -3
  2. package/dist/{CreateFunctionModal-glk2zg1r.js.map → CreateFunctionModal-CYNHJUGJ.js.map} +1 -1
  3. package/dist/{DocumentFormModal-B3OkvI5v.js → DocumentFormModal-CLmdGx34.js} +2 -2
  4. package/dist/{DocumentFormModal-B3OkvI5v.js.map → DocumentFormModal-CLmdGx34.js.map} +1 -1
  5. package/dist/ImportSpecModal-BzEyiNWD.js +378 -0
  6. package/dist/ImportSpecModal-BzEyiNWD.js.map +1 -0
  7. package/dist/WorkflowEditor-CxTuK8_d.js +1272 -0
  8. package/dist/WorkflowEditor-CxTuK8_d.js.map +1 -0
  9. package/dist/{apps-CFWdgGst.js → apps-CyEszfIu.js} +33 -33
  10. package/dist/{apps-CFWdgGst.js.map → apps-CyEszfIu.js.map} +1 -1
  11. package/dist/callable-row-actions-BPBPflMn.js +56 -0
  12. package/dist/callable-row-actions-BPBPflMn.js.map +1 -0
  13. package/dist/callables-dLF2IcwA.js +317 -0
  14. package/dist/callables-dLF2IcwA.js.map +1 -0
  15. package/dist/chrome/TagEditor.d.ts +6 -1
  16. package/dist/chrome/workspace.d.ts +16 -0
  17. package/dist/documents-hgltn0xe.js +1017 -0
  18. package/dist/documents-hgltn0xe.js.map +1 -0
  19. package/dist/draft.mjs +1 -1
  20. package/dist/editor/WaitingForm.d.ts +19 -0
  21. package/dist/{editor-apps-ShwCmvLY.js → editor-apps-DsGrGKfe.js} +3 -3
  22. package/dist/{editor-apps-ShwCmvLY.js.map → editor-apps-DsGrGKfe.js.map} +1 -1
  23. package/dist/{editor-tools-rY9nddqr.js → editor-tools-Ct7YPPj8.js} +682 -784
  24. package/dist/editor-tools-Ct7YPPj8.js.map +1 -0
  25. package/dist/editor.mjs +1 -1
  26. package/dist/editors.mjs +18 -18
  27. package/dist/{endpoints-zOuwci2U.js → endpoints-DJxXRh-I.js} +12 -12
  28. package/dist/{endpoints-zOuwci2U.js.map → endpoints-DJxXRh-I.js.map} +1 -1
  29. package/dist/forms.mjs +1 -1
  30. package/dist/index.mjs +140 -115
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/lib/callable-row-actions.d.ts +17 -0
  33. package/dist/lib/index.d.ts +2 -0
  34. package/dist/lib/run-event-stream.d.ts +122 -0
  35. package/dist/lib/tag-editor.d.ts +6 -0
  36. package/dist/lib/workflow-live-run.d.ts +7 -0
  37. package/dist/lib/workflow-validity.d.ts +7 -1
  38. package/dist/lib.mjs +52 -47
  39. package/dist/lists/CallableKindList.d.ts +12 -0
  40. package/dist/lists/CallableRowParts.d.ts +8 -1
  41. package/dist/lists/EndpointList.d.ts +3 -0
  42. package/dist/lists/FunctionList.d.ts +3 -0
  43. package/dist/lists/WorkflowList.d.ts +3 -0
  44. package/dist/lists.d.ts +1 -0
  45. package/dist/lists.mjs +1589 -1513
  46. package/dist/lists.mjs.map +1 -1
  47. package/dist/rail.mjs +1 -1
  48. package/dist/repos/callables.d.ts +25 -0
  49. package/dist/repos/documents.d.ts +9 -1
  50. package/dist/repos/saved-file-names.d.ts +10 -0
  51. package/dist/repos/workflows.d.ts +19 -13
  52. package/dist/repos.mjs +333 -328
  53. package/dist/{setup-incomplete-BHs3Lpfy.js → setup-incomplete-6PAbN0EW.js} +50 -49
  54. package/dist/setup-incomplete-6PAbN0EW.js.map +1 -0
  55. package/dist/spec-import-BKyfhTYG.js +200 -0
  56. package/dist/spec-import-BKyfhTYG.js.map +1 -0
  57. package/dist/{use-callable-draft-w4tDTYcb.js → use-callable-draft-7HwfTuYQ.js} +3 -3
  58. package/dist/{use-callable-draft-w4tDTYcb.js.map → use-callable-draft-7HwfTuYQ.js.map} +1 -1
  59. package/package.json +3 -3
  60. package/src/styles.css +43 -0
  61. package/dist/ImportSpecModal-SQvTwtcX.js +0 -252
  62. package/dist/ImportSpecModal-SQvTwtcX.js.map +0 -1
  63. package/dist/WorkflowEditor-D2EfEP-U.js +0 -1201
  64. package/dist/WorkflowEditor-D2EfEP-U.js.map +0 -1
  65. package/dist/callable-record-Bhxim8C1.js +0 -14
  66. package/dist/callable-record-Bhxim8C1.js.map +0 -1
  67. package/dist/callables-B49tS2vv.js +0 -297
  68. package/dist/callables-B49tS2vv.js.map +0 -1
  69. package/dist/editor-tools-rY9nddqr.js.map +0 -1
  70. package/dist/setup-incomplete-BHs3Lpfy.js.map +0 -1
  71. package/dist/spec-import-CPbDnnuv.js +0 -272
  72. package/dist/spec-import-CPbDnnuv.js.map +0 -1
  73. package/dist/workflows-RhR8kwt7.js +0 -667
  74. package/dist/workflows-RhR8kwt7.js.map +0 -1
@@ -1,667 +0,0 @@
1
- import { useQueryClient as g, useMutation as w, useQuery as y } from "@tanstack/react-query";
2
- import { isTerminalRunStatus as R, path as h } from "@w6w/sdk";
3
- import { u as d } from "./client-context-CX61Bgw-.js";
4
- import { foldStateLog as C } from "@w6w/expr";
5
- function K(t) {
6
- return (t == null ? void 0 : t.nodes) ?? (t == null ? void 0 : t.steps) ?? void 0;
7
- }
8
- const q = "Node failed without reporting a reason.", $ = "Run failed without reporting a reason.";
9
- function T(t) {
10
- return t === void 0 || !R(t);
11
- }
12
- function P(t, e) {
13
- return e || t === void 0 ? !1 : !R(t);
14
- }
15
- const bt = [0, 1500];
16
- function qt(t, e, n) {
17
- return t !== void 0 && R(t) && e === n;
18
- }
19
- function vt(t, e) {
20
- return P(t, e) ? t === "queued" ? "Queued…" : "Running…" : "Run";
21
- }
22
- function It(t) {
23
- return t === "run_not_cancelable" ? "reconcile" : "surface";
24
- }
25
- function U(t, e) {
26
- if (!t) return [];
27
- const n = e ? W(e) : void 0;
28
- return Object.entries(t).map(([o, r]) => ({
29
- ...A(o, r),
30
- ...N(r),
31
- ...(n == null ? void 0 : n.get(o)) ?? {}
32
- }));
33
- }
34
- function W(t) {
35
- const e = [...t].sort((r, i) => r.seq - i.seq), n = /* @__PURE__ */ new Map();
36
- for (const r of e) {
37
- if (r.nodeId === null || r.nodeId === void 0) continue;
38
- const i = { path: r.path };
39
- r.item !== void 0 && (i.item = r.item), r.old !== void 0 && (i.old = r.old), r.new !== void 0 && (i.new = r.new), r.warning !== void 0 && (i.warning = r.warning);
40
- const a = n.get(r.nodeId) ?? { writes: [], lastSeq: r.seq };
41
- a.writes.push(i), a.lastSeq = r.seq, n.set(r.nodeId, a);
42
- }
43
- const o = /* @__PURE__ */ new Map();
44
- for (const [r, { writes: i, lastSeq: a }] of n)
45
- o.set(r, { stateWrites: i, stateAfter: C(e, a) });
46
- return o;
47
- }
48
- const Q = /* @__PURE__ */ new Set([
49
- "not_on_path",
50
- "condition",
51
- "stopped",
52
- "disabled"
53
- ]);
54
- function A(t, e) {
55
- return {
56
- id: t,
57
- status: e.status,
58
- ...e.status === "skipped" && Q.has(e.skipReason) ? { skipReason: e.skipReason } : {},
59
- startedAt: e.startedAt,
60
- finishedAt: e.finishedAt,
61
- input: e.input,
62
- output: e.output,
63
- ...Array.isArray(e.logs) && e.logs.length ? { logs: e.logs.filter((n) => typeof n == "string") } : {},
64
- ...e.meta !== void 0 && e.meta !== null ? { meta: e.meta } : {},
65
- ...D(e)
66
- };
67
- }
68
- const L = /* @__PURE__ */ new Set(["succeeded", "failed", "running"]);
69
- function N(t) {
70
- if (!t || !Array.isArray(t.iterations)) return {};
71
- const e = t.iterations.filter((o) => o !== null && typeof o == "object").map((o) => {
72
- var u;
73
- const r = o.nodes !== null && typeof o.nodes == "object" ? o.nodes : {}, i = Object.entries(r).map(([s, l]) => ({
74
- ...A(s, l),
75
- ...N(l)
76
- })), a = typeof o.failedNodeId == "string" && o.failedNodeId !== "" ? o.failedNodeId : (u = i.find((s) => s.status === "failed")) == null ? void 0 : u.id, c = L.has(o.status) ? o.status : i.some((s) => s.status === "failed") ? "failed" : i.some((s) => s.status === "running") ? "running" : "succeeded";
77
- return {
78
- index: o.index,
79
- status: c,
80
- ...a !== void 0 ? { failedNodeId: a } : {},
81
- steps: i
82
- };
83
- }).sort((o, r) => o.index - r.index), n = (o) => typeof o == "number" && Number.isFinite(o);
84
- return {
85
- iterations: e,
86
- ...n(t.iterationsTotal) ? { iterationsTotal: t.iterationsTotal } : {},
87
- ...n(t.iterationsFailed) ? { iterationsFailed: t.iterationsFailed } : {},
88
- ...typeof t.iterationsTruncated == "boolean" ? { iterationsTruncated: t.iterationsTruncated } : {}
89
- };
90
- }
91
- function D(t) {
92
- const e = v(t.error);
93
- return e ? { error: e } : t.status === "failed" ? { error: { message: q } } : {};
94
- }
95
- function v(t) {
96
- if (t != null) {
97
- if (typeof t == "string" && t !== "") return { message: t };
98
- if (typeof t == "object") {
99
- const e = t, n = typeof e.code == "string" ? e.code : void 0, o = typeof e.message == "string" && e.message !== "" ? e.message : n || j(t);
100
- return {
101
- ...n !== void 0 ? { code: n } : {},
102
- message: o || "Unknown error.",
103
- ...typeof e.phase == "string" ? { phase: e.phase } : {},
104
- ...typeof e.retryable == "boolean" ? { retryable: e.retryable } : {}
105
- };
106
- }
107
- return { message: String(t) || "Unknown error." };
108
- }
109
- }
110
- function j(t) {
111
- try {
112
- return JSON.stringify(t) ?? "";
113
- } catch {
114
- return "";
115
- }
116
- }
117
- function Rt(t, e) {
118
- if (!t) return {};
119
- const n = new Set(e.filter((s) => s.error !== void 0).map((s) => s.id)), o = new Set(
120
- e.filter((s) => s.error !== void 0 && s.error.message !== q).map((s) => s.id)
121
- ), r = (t.stepErrors ?? []).map((s) => ({ e: s, id: s.nodeId ?? s.stepId ?? "" })).filter(({ id: s }) => !o.has(s)).map(({ e: s, id: l }) => ({
122
- stepId: l,
123
- error: v(s.error) ?? { message: q }
124
- })), i = v(t.error), a = (s) => i !== void 0 && (s == null ? void 0 : s.message) === i.message && (s == null ? void 0 : s.code) === i.code;
125
- let u = e.some((s) => a(s.error)) || r.some((s) => a(s.error)) ? void 0 : i;
126
- return !u && t.status === "failed" && n.size === 0 && r.length === 0 && (u = { message: $ }), {
127
- ...u ? { runError: u } : {},
128
- ...r.length > 0 ? { stepErrors: r } : {}
129
- };
130
- }
131
- function x(t) {
132
- var n;
133
- const e = (n = t == null ? void 0 : t[t.length - 1]) == null ? void 0 : n.with;
134
- if (!(e === null || typeof e != "object" || Array.isArray(e)))
135
- return e;
136
- }
137
- async function Tt(t, e, n) {
138
- var o;
139
- if (t) {
140
- if (n)
141
- try {
142
- const r = (o = await n()) == null ? void 0 : o.find((i) => i.nodeId === t);
143
- if (r) {
144
- const i = r.input;
145
- return i === null || typeof i != "object" || Array.isArray(i) ? void 0 : Object.keys(i).length > 0 ? i : void 0;
146
- }
147
- } catch {
148
- }
149
- try {
150
- return x(await e(t));
151
- } catch {
152
- return;
153
- }
154
- }
155
- }
156
- function Et(t, e, n) {
157
- const o = t.find((i) => {
158
- var a;
159
- return !!((a = i.uses) != null && a.app) && e(i.uses.app);
160
- });
161
- if (o) return { id: o.id, manual: !0 };
162
- const r = t.find(
163
- (i) => {
164
- var a;
165
- return !!((a = i.uses) != null && a.app) && n({ app: i.uses.app, ...i.uses.trigger === !0 ? { trigger: !0 } : {} });
166
- }
167
- );
168
- return r ? { id: r.id, manual: !1 } : void 0;
169
- }
170
- const G = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled"]);
171
- function H(t) {
172
- return new Promise((e) => setTimeout(e, t));
173
- }
174
- async function F(t, e = H) {
175
- for (let n = 0; n < 600; n++) {
176
- const o = await t();
177
- if (G.has(o.status)) return o;
178
- await e(500);
179
- }
180
- return t();
181
- }
182
- const Y = {
183
- status: "",
184
- kind: "",
185
- from: "",
186
- to: "",
187
- q: "",
188
- trigger: "",
189
- offset: 0
190
- }, _ = /^(entry|kind):.{1,200}$/;
191
- function B(t) {
192
- if (!_.test(t)) return {};
193
- const e = t.slice(t.indexOf(":") + 1);
194
- return t.startsWith("entry:") ? { entry: e } : { trigger: e };
195
- }
196
- const O = 25, J = /* @__PURE__ */ new Set([
197
- "queued",
198
- "running",
199
- "succeeded",
200
- "failed",
201
- "canceled"
202
- ]), V = /* @__PURE__ */ new Set(["function", "endpoint", "workflow"]), z = /^\d{4}-\d{2}-\d{2}$/;
203
- function m(t) {
204
- if (!z.test(t)) return !1;
205
- const { y: e, m: n, d: o } = I(t), r = new Date(e, n - 1, o);
206
- return r.getFullYear() === e && r.getMonth() === n - 1 && r.getDate() === o;
207
- }
208
- function I(t) {
209
- const [e, n, o] = t.split("-").map(Number);
210
- return { y: e, m: n, d: o };
211
- }
212
- function At(t) {
213
- const e = new URLSearchParams(t), n = e.get("status") ?? "", o = e.get("kind") ?? "", r = e.get("from") ?? "", i = e.get("to") ?? "", a = e.get("q") ?? "", c = e.get("trigger") ?? "", u = e.get("offset");
214
- let s = 0;
215
- if (u !== null) {
216
- const l = Number(u);
217
- Number.isInteger(l) && l >= 0 && (s = l);
218
- }
219
- return {
220
- status: J.has(n) ? n : "",
221
- kind: V.has(o) ? o : "",
222
- from: m(r) ? r : "",
223
- to: m(i) ? i : "",
224
- q: a,
225
- trigger: _.test(c) ? c : "",
226
- offset: s
227
- };
228
- }
229
- function Nt(t) {
230
- const e = new URLSearchParams();
231
- t.status !== "" && e.set("status", t.status), t.kind !== "" && e.set("kind", t.kind), t.from !== "" && e.set("from", t.from), t.to !== "" && e.set("to", t.to), t.q !== "" && e.set("q", t.q), t.trigger && e.set("trigger", t.trigger), t.offset > 0 && e.set("offset", String(t.offset));
232
- const n = e.toString();
233
- return n === "" ? "" : `?${n}`;
234
- }
235
- function M(t, e, n) {
236
- const o = {};
237
- if ("project" in t ? (o.project = t.project, e.kind !== "" && (o.kind = e.kind)) : o.callable = t.callable, e.status !== "" && (o.status = e.status), e.from !== "" && m(e.from)) {
238
- const { y: i, m: a, d: c } = I(e.from);
239
- o.from = new Date(i, a - 1, c).toISOString();
240
- }
241
- if (e.to !== "" && m(e.to)) {
242
- const { y: i, m: a, d: c } = I(e.to);
243
- o.to = new Date(i, a - 1, c + 1).toISOString();
244
- }
245
- const r = e.q.trim();
246
- return r !== "" && (o.q = r), e.trigger && Object.assign(o, B(e.trigger)), n.paged && (o.limit = String(n.limit ?? O), e.offset > 0 && (o.offset = String(e.offset))), o;
247
- }
248
- const E = {
249
- root: ["history"],
250
- list(t, e, n) {
251
- return ["history", "list", t, e, n];
252
- },
253
- stats(t, e) {
254
- return ["history", "stats", t, e];
255
- },
256
- exists(t) {
257
- return ["history", "exists", t];
258
- },
259
- detail(t, e) {
260
- return ["history", "detail", t, e];
261
- },
262
- triggers(t) {
263
- return ["history", "triggers", t];
264
- }
265
- };
266
- function Z(t, e, n, o = O) {
267
- return t.request({
268
- method: "GET",
269
- path: "/history",
270
- query: M(e, n, { paged: !0, limit: o })
271
- }).then((r) => r.body);
272
- }
273
- function Ft(t, e, n) {
274
- return t.request({
275
- method: "GET",
276
- path: "/history/stats",
277
- query: M(e, n, { paged: !1 })
278
- }).then((o) => o.body.stats);
279
- }
280
- async function X(t, e) {
281
- var a, c, u;
282
- const n = /* @__PURE__ */ new Map();
283
- let o;
284
- try {
285
- const { workflow: s } = await t.console.workflows.get(e);
286
- o = Array.isArray(s.nodes) ? s.nodes : [];
287
- } catch {
288
- return n;
289
- }
290
- for (const s of o) {
291
- const l = (a = s.uses) == null ? void 0 : a.app, f = (c = s.uses) == null ? void 0 : c.action;
292
- typeof s.id != "string" || typeof l != "string" || typeof f != "string" || n.set(s.id, { app: l, action: f, ...((u = s.uses) == null ? void 0 : u.trigger) === !0 ? { trigger: !0 } : {} });
293
- }
294
- const r = [...new Set([...n.values()].map((s) => s.app))].filter(
295
- (s) => !s.startsWith("@w6w/")
296
- ), i = await Promise.all(
297
- r.map(async (s) => {
298
- const l = [...n.values()].some((p) => p.app === s && p.trigger), [f, k] = await Promise.all([
299
- t.console.apps.get(s).catch(() => null),
300
- l ? t.console.apps.getTriggers(s).catch(() => []) : Promise.resolve([])
301
- ]), b = /* @__PURE__ */ new Map();
302
- for (const p of (f == null ? void 0 : f.actions) ?? []) b.set(`a:${p.key}`, p.title);
303
- for (const p of k) b.set(`t:${p.key}`, p.title);
304
- return { app: s, displayName: f == null ? void 0 : f.app.displayName, titles: b };
305
- })
306
- );
307
- for (const s of n.values()) {
308
- const l = i.find((k) => k.app === s.app);
309
- if (!l) continue;
310
- l.displayName && (s.appName = l.displayName);
311
- const f = l.titles.get(`${s.trigger ? "t" : "a"}:${s.action}`);
312
- f && (s.actionName = f);
313
- }
314
- return n;
315
- }
316
- const tt = {
317
- "@w6w/trigger": "Manual trigger",
318
- "@w6w/webhook": "Webhook",
319
- "@w6w/scheduler": "Schedule",
320
- "@w6w/form": "Form"
321
- };
322
- function _t(t) {
323
- const e = [];
324
- for (const [o, r] of t) {
325
- const i = tt[r.app];
326
- if (!i && !r.trigger) continue;
327
- const a = i ?? `${r.appName ?? r.app} · ${r.actionName ?? r.action}`;
328
- e.push({ nodeId: o, label: a, app: r.app });
329
- }
330
- const n = /* @__PURE__ */ new Map();
331
- for (const o of e) n.set(o.label, (n.get(o.label) ?? 0) + 1);
332
- return e.map(
333
- (o) => (n.get(o.label) ?? 0) > 1 ? { ...o, label: `${o.label} (${o.nodeId})` } : o
334
- );
335
- }
336
- function Ot(t, e) {
337
- if (t.triggerNodeId) {
338
- const n = e.find((o) => o.nodeId === t.triggerNodeId);
339
- if (n) return n.label;
340
- }
341
- return t.trigger ? t.trigger === "manual" ? "Manual run" : t.trigger.charAt(0).toUpperCase() + t.trigger.slice(1) : null;
342
- }
343
- async function Mt(t, e) {
344
- if (e.kind === "workflow") {
345
- const [r, i] = await Promise.all([
346
- t.console.workflows.getRun(e.id),
347
- X(t, e.callableId)
348
- ]), a = r;
349
- return {
350
- id: e.id,
351
- kind: "workflow",
352
- callableName: e.callableName,
353
- status: r.status,
354
- startedAt: e.startedAt,
355
- finishedAt: e.finishedAt,
356
- durationMs: e.durationMs,
357
- input: a.input ?? a.event ?? r.variables,
358
- output: r.output,
359
- error: r.error,
360
- rerunOf: e.rerunOf ?? null,
361
- steps: U(K(r)).map((c) => {
362
- const u = i.get(c.id);
363
- return u ? { ...c, node: u } : c;
364
- })
365
- };
366
- }
367
- const o = (await t.request({
368
- method: "GET",
369
- path: `/invocations/${encodeURIComponent(e.id)}`
370
- })).body.invocation;
371
- return {
372
- id: e.id,
373
- kind: e.kind,
374
- callableName: e.callableName,
375
- status: o.status,
376
- startedAt: o.startedAt,
377
- finishedAt: o.finishedAt,
378
- durationMs: o.durationMs,
379
- input: o.input,
380
- output: o.output,
381
- error: o.error,
382
- rerunOf: e.rerunOf ?? null
383
- };
384
- }
385
- function et(t) {
386
- const e = t == null ? void 0 : t.raw, n = e == null ? void 0 : e.invocationId;
387
- return typeof n == "string" ? n : void 0;
388
- }
389
- function nt(t) {
390
- return t !== null && typeof t == "object" && !Array.isArray(t) ? t : {};
391
- }
392
- async function ot(t, e, n) {
393
- const o = encodeURIComponent(e.callableId);
394
- if (e.kind === "workflow") {
395
- const u = (await t.request({
396
- method: "POST",
397
- path: `/runs/${encodeURIComponent(e.id)}/rerun`,
398
- body: { allowUnpublished: !0 }
399
- })).body.runId;
400
- return await F(() => t.console.workflows.getRun(u), n), u;
401
- }
402
- const r = await t.request({
403
- method: "GET",
404
- path: `/invocations/${encodeURIComponent(e.id)}`
405
- }), i = nt(r.body.invocation.input), a = e.kind === "function" ? { inputs: i, allowUnpublished: !0, rerunOf: e.id } : { input: i, allowUnpublished: !0, rerunOf: e.id };
406
- try {
407
- const u = (await t.request({
408
- method: "POST",
409
- path: `/${e.kind === "function" ? "functions" : "endpoints"}/${o}/invoke`,
410
- body: a
411
- })).body.invocationId;
412
- if (typeof u != "string") throw new Error("The server did not return an invocation id.");
413
- return u;
414
- } catch (c) {
415
- const u = et(c);
416
- if (u === void 0) throw c;
417
- return u;
418
- }
419
- }
420
- async function Ct(t, e, n = {}) {
421
- const o = await ot(t, e, n.sleep);
422
- return rt(t, e.callableId, o);
423
- }
424
- async function rt(t, e, n) {
425
- return (await Z(
426
- t,
427
- { callable: e },
428
- { ...Y, q: n },
429
- 1
430
- )).executions.find((r) => r.id === n) ?? null;
431
- }
432
- const st = (t) => ["workflows", t];
433
- function it(t, e) {
434
- return t.workflows.list({ project: e });
435
- }
436
- function Kt(t, e = !0) {
437
- const n = d();
438
- return y({
439
- queryKey: st(t),
440
- queryFn: () => it(n, t),
441
- enabled: e
442
- });
443
- }
444
- const at = (t) => ["workflow", t];
445
- function ut(t, e) {
446
- return t.workflows.get(e);
447
- }
448
- function $t(t, e = !0) {
449
- const n = d();
450
- return y({
451
- queryKey: at(t),
452
- queryFn: () => ut(n, t),
453
- enabled: e
454
- });
455
- }
456
- function Pt(t) {
457
- const e = d(), n = g();
458
- return w({
459
- mutationFn: (o) => t ? e.console.workflows.upsert(o, { project: t }) : Promise.reject(new Error("No project selected yet.")),
460
- onSuccess: () => n.invalidateQueries({ queryKey: ["workflows"] })
461
- });
462
- }
463
- function Ut(t) {
464
- const e = d(), n = g();
465
- return w({
466
- mutationFn: (o) => t ? e.console.workflows.upsert(o.definition, {
467
- project: t,
468
- ifUnmodifiedSince: o.ifUnmodifiedSince
469
- }) : Promise.reject(new Error("No project selected yet.")),
470
- onSuccess: () => n.invalidateQueries({ queryKey: ["workflows"] })
471
- });
472
- }
473
- function Wt() {
474
- const t = d(), e = g();
475
- return w({
476
- mutationFn: (n) => t.workflows.archive(n),
477
- onSuccess: () => e.invalidateQueries({ queryKey: ["workflows"] })
478
- });
479
- }
480
- function Qt() {
481
- const t = d(), e = g();
482
- return w({
483
- mutationFn: (n) => t.workflows.delete(n),
484
- onSuccess: () => e.invalidateQueries({ queryKey: ["workflows"] })
485
- });
486
- }
487
- const S = (t) => ["runs", t];
488
- function Lt(t) {
489
- const e = d();
490
- return y({
491
- queryKey: S(t),
492
- queryFn: () => e.console.workflows.listRuns(t)
493
- });
494
- }
495
- function ct(t, e, n, o) {
496
- return t.workflows.run(e, { variables: n, input: o, allowUnpublished: !0 }).then((r) => F(() => t.console.workflows.getRun(r.runId)));
497
- }
498
- function Dt() {
499
- const t = d(), e = g();
500
- return w({
501
- mutationFn: (n) => ct(t, n.id, n.variables, n.input),
502
- onSuccess: (n, o) => e.invalidateQueries({ queryKey: S(o.id) }),
503
- onSettled: () => e.invalidateQueries({ queryKey: E.root })
504
- });
505
- }
506
- function jt(t, e, n, o, r) {
507
- return t.workflows.run(e, { variables: n, input: o, entry: r, wait: !0 });
508
- }
509
- function lt(t, e, n, o) {
510
- return t.workflows.run(e, { variables: n, input: o, allowUnpublished: !0 }).then((r) => ({ runId: r.runId }));
511
- }
512
- async function dt(t, e, n, o) {
513
- return { runId: (await t.request({
514
- method: "POST",
515
- path: h`/workflows/${e}/nodes/${n}/run`,
516
- body: {
517
- continue: !0,
518
- stopAt: o.stopAt,
519
- ...o.nodes ? { state: { nodes: o.nodes } } : {},
520
- ...o.input ? { input: o.input } : {}
521
- }
522
- })).body.runId };
523
- }
524
- function xt(t, e) {
525
- return t.request({
526
- method: "GET",
527
- path: h`/workflows/${e}/node-samples`
528
- }).then((n) => n.body.nodeSamples ?? []);
529
- }
530
- function Gt(t, e) {
531
- return t.request({
532
- method: "GET",
533
- path: h`/workflows/${e}/test-inputs`
534
- }).then((n) => n.body.testInputs ?? []);
535
- }
536
- function Ht(t, e, n, o) {
537
- return t.request({
538
- method: "PUT",
539
- path: h`/workflows/${e}/nodes/${n}/test-input`,
540
- body: { input: o }
541
- }).then(() => {
542
- });
543
- }
544
- function Yt() {
545
- const t = d(), e = g();
546
- return w({
547
- mutationFn: (n) => dt(t, n.id, n.nodeId, n.body),
548
- onSuccess: (n, o) => e.invalidateQueries({ queryKey: S(o.id) }),
549
- onSettled: () => e.invalidateQueries({ queryKey: E.root })
550
- });
551
- }
552
- function Bt() {
553
- const t = d(), e = g();
554
- return w({
555
- mutationFn: (n) => lt(t, n.id, n.variables, n.input),
556
- onSuccess: (n, o) => e.invalidateQueries({ queryKey: S(o.id) }),
557
- onSettled: () => e.invalidateQueries({ queryKey: E.root })
558
- });
559
- }
560
- function ft(t, e) {
561
- return t.workflows.cancel(e);
562
- }
563
- function Jt() {
564
- const t = d();
565
- return w({
566
- mutationFn: (e) => ft(t, e)
567
- });
568
- }
569
- function pt(t, e) {
570
- return t.console.workflows.getRun(e);
571
- }
572
- const wt = (t) => ["run", t];
573
- function Vt(t) {
574
- const e = d();
575
- return y({
576
- queryKey: wt(t ?? ""),
577
- queryFn: () => pt(e, t),
578
- enabled: t != null,
579
- refetchInterval: (n) => {
580
- var o;
581
- return T((o = n.state.data) == null ? void 0 : o.status) ? 500 : !1;
582
- }
583
- });
584
- }
585
- function gt(t, e) {
586
- return t.request({
587
- method: "GET",
588
- path: h`/runs/${e}/state-writes`
589
- }).then((n) => ({ writes: n.body.writes ?? [], truncated: n.body.truncated === !0 }));
590
- }
591
- function yt(t, e) {
592
- return ["run", t, "state-writes", T(e) ? "live" : "final"];
593
- }
594
- function zt(t, e) {
595
- const n = d(), o = T(e);
596
- return y({
597
- queryKey: yt(t ?? "", e),
598
- queryFn: () => gt(n, t),
599
- enabled: t != null,
600
- refetchInterval: o ? 500 : !1,
601
- retry: !1
602
- });
603
- }
604
- export {
605
- Lt as $,
606
- Tt as A,
607
- vt as B,
608
- Rt as C,
609
- K as D,
610
- Y as E,
611
- wt as F,
612
- yt as G,
613
- O as H,
614
- ct as I,
615
- jt as J,
616
- S as K,
617
- Ht as L,
618
- T as M,
619
- dt as N,
620
- lt as O,
621
- qt as P,
622
- v as Q,
623
- $ as R,
624
- q as S,
625
- Wt as T,
626
- Jt as U,
627
- Pt as V,
628
- Qt as W,
629
- Vt as X,
630
- Yt as Y,
631
- zt as Z,
632
- Dt as _,
633
- bt as a,
634
- Ut as a0,
635
- Bt as a1,
636
- $t as a2,
637
- Kt as a3,
638
- at as a4,
639
- _t as a5,
640
- st as a6,
641
- It as b,
642
- ft as c,
643
- X as d,
644
- Nt as e,
645
- At as f,
646
- rt as g,
647
- Mt as h,
648
- Z as i,
649
- Ft as j,
650
- pt as k,
651
- gt as l,
652
- ut as m,
653
- Et as n,
654
- E as o,
655
- M as p,
656
- P as q,
657
- Ot as r,
658
- x as s,
659
- B as t,
660
- xt as u,
661
- Gt as v,
662
- it as w,
663
- U as x,
664
- F as y,
665
- Ct as z
666
- };
667
- //# sourceMappingURL=workflows-RhR8kwt7.js.map