@w6w/embed 0.2.33 → 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.
- package/dist/{CreateFunctionModal-glk2zg1r.js → CreateFunctionModal-CYNHJUGJ.js} +3 -3
- package/dist/{CreateFunctionModal-glk2zg1r.js.map → CreateFunctionModal-CYNHJUGJ.js.map} +1 -1
- package/dist/{DocumentFormModal-Cw85R4wk.js → DocumentFormModal-CLmdGx34.js} +2 -2
- package/dist/{DocumentFormModal-Cw85R4wk.js.map → DocumentFormModal-CLmdGx34.js.map} +1 -1
- package/dist/ImportSpecModal-BzEyiNWD.js +378 -0
- package/dist/ImportSpecModal-BzEyiNWD.js.map +1 -0
- package/dist/WorkflowEditor-CxTuK8_d.js +1272 -0
- package/dist/WorkflowEditor-CxTuK8_d.js.map +1 -0
- package/dist/apps-CyEszfIu.js +106 -0
- package/dist/apps-CyEszfIu.js.map +1 -0
- package/dist/callable-row-actions-BPBPflMn.js +56 -0
- package/dist/callable-row-actions-BPBPflMn.js.map +1 -0
- package/dist/callables-dLF2IcwA.js +317 -0
- package/dist/callables-dLF2IcwA.js.map +1 -0
- package/dist/chrome/HistoryView.d.ts +3 -0
- package/dist/chrome/TagEditor.d.ts +6 -1
- package/dist/chrome/workspace.d.ts +16 -0
- package/dist/documents-hgltn0xe.js +1017 -0
- package/dist/documents-hgltn0xe.js.map +1 -0
- package/dist/draft.mjs +1 -1
- package/dist/editor/WaitingForm.d.ts +19 -0
- package/dist/editor-apps-DsGrGKfe.js +178 -0
- package/dist/editor-apps-DsGrGKfe.js.map +1 -0
- package/dist/{editor-tools-Dn7TgCP4.js → editor-tools-Ct7YPPj8.js} +681 -783
- package/dist/editor-tools-Ct7YPPj8.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +18 -18
- package/dist/{endpoints-zOuwci2U.js → endpoints-DJxXRh-I.js} +12 -12
- package/dist/{endpoints-zOuwci2U.js.map → endpoints-DJxXRh-I.js.map} +1 -1
- package/dist/forms.mjs +1 -1
- package/dist/index.mjs +140 -115
- package/dist/index.mjs.map +1 -1
- package/dist/lib/callable-row-actions.d.ts +17 -0
- package/dist/lib/history-query.d.ts +22 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/run-event-stream.d.ts +122 -0
- package/dist/lib/run-log-nodes.d.ts +43 -0
- package/dist/lib/tag-editor.d.ts +6 -0
- package/dist/lib/workflow-live-run.d.ts +7 -0
- package/dist/lib/workflow-validity.d.ts +7 -1
- package/dist/lib.mjs +52 -47
- package/dist/lists/CallableKindList.d.ts +12 -0
- package/dist/lists/CallableRowParts.d.ts +8 -1
- package/dist/lists/EndpointList.d.ts +3 -0
- package/dist/lists/FunctionList.d.ts +3 -0
- package/dist/lists/WorkflowList.d.ts +3 -0
- package/dist/lists.d.ts +1 -0
- package/dist/lists.mjs +1589 -1513
- package/dist/lists.mjs.map +1 -1
- package/dist/rail.mjs +1 -1
- package/dist/repos/callables.d.ts +25 -0
- package/dist/repos/documents.d.ts +9 -1
- package/dist/repos/history.d.ts +5 -1
- package/dist/repos/saved-file-names.d.ts +10 -0
- package/dist/repos/workflows.d.ts +19 -13
- package/dist/repos.mjs +338 -329
- package/dist/{setup-incomplete-BHs3Lpfy.js → setup-incomplete-6PAbN0EW.js} +50 -49
- package/dist/setup-incomplete-6PAbN0EW.js.map +1 -0
- package/dist/spec-import-BKyfhTYG.js +200 -0
- package/dist/spec-import-BKyfhTYG.js.map +1 -0
- package/dist/{use-callable-draft-w4tDTYcb.js → use-callable-draft-7HwfTuYQ.js} +3 -3
- package/dist/{use-callable-draft-w4tDTYcb.js.map → use-callable-draft-7HwfTuYQ.js.map} +1 -1
- package/package.json +3 -3
- package/src/styles.css +43 -0
- package/dist/ImportSpecModal-fU5RsVTa.js +0 -252
- package/dist/ImportSpecModal-fU5RsVTa.js.map +0 -1
- package/dist/WorkflowEditor-C7oudiIb.js +0 -1169
- package/dist/WorkflowEditor-C7oudiIb.js.map +0 -1
- package/dist/apps-FMcQfyL2.js +0 -92
- package/dist/apps-FMcQfyL2.js.map +0 -1
- package/dist/callable-record-Bhxim8C1.js +0 -14
- package/dist/callable-record-Bhxim8C1.js.map +0 -1
- package/dist/callables-B49tS2vv.js +0 -297
- package/dist/callables-B49tS2vv.js.map +0 -1
- package/dist/editor-apps-HEOclsxL.js +0 -152
- package/dist/editor-apps-HEOclsxL.js.map +0 -1
- package/dist/editor-tools-Dn7TgCP4.js.map +0 -1
- package/dist/setup-incomplete-BHs3Lpfy.js.map +0 -1
- package/dist/spec-import-CGPqUUjN.js +0 -272
- package/dist/spec-import-CGPqUUjN.js.map +0 -1
- package/dist/workflows-Dz8LMjnt.js +0 -626
- package/dist/workflows-Dz8LMjnt.js.map +0 -1
|
@@ -0,0 +1,1017 @@
|
|
|
1
|
+
var H = (e) => {
|
|
2
|
+
throw TypeError(e);
|
|
3
|
+
};
|
|
4
|
+
var j = (e, t, n) => t.has(e) || H("Cannot " + n);
|
|
5
|
+
var d = (e, t, n) => (j(e, t, "read from private field"), n ? n.call(e) : t.get(e)), S = (e, t, n) => t.has(e) ? H("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), k = (e, t, n, o) => (j(e, t, "write to private field"), o ? o.call(e, n) : t.set(e, n), n), P = (e, t, n) => (j(e, t, "access private method"), n);
|
|
6
|
+
import { useQueryClient as y, useMutation as h, useQuery as T } from "@tanstack/react-query";
|
|
7
|
+
import { isTerminalRunStatus as x, path as A } from "@w6w/sdk";
|
|
8
|
+
import { useEffect as re, useCallback as se, useSyncExternalStore as ie } from "react";
|
|
9
|
+
import { u as f } from "./client-context-CX61Bgw-.js";
|
|
10
|
+
import { foldStateLog as ae } from "@w6w/expr";
|
|
11
|
+
function ue(e) {
|
|
12
|
+
return (e == null ? void 0 : e.nodes) ?? (e == null ? void 0 : e.steps) ?? void 0;
|
|
13
|
+
}
|
|
14
|
+
const W = "Node failed without reporting a reason.", ce = "Run failed without reporting a reason.";
|
|
15
|
+
function K(e) {
|
|
16
|
+
return e === void 0 || !x(e);
|
|
17
|
+
}
|
|
18
|
+
function le(e, t) {
|
|
19
|
+
return t || e === void 0 ? !1 : !x(e);
|
|
20
|
+
}
|
|
21
|
+
const ct = [0, 1500];
|
|
22
|
+
function lt(e, t, n) {
|
|
23
|
+
return e !== void 0 && x(e) && t === n;
|
|
24
|
+
}
|
|
25
|
+
function dt(e, t) {
|
|
26
|
+
return le(e, t) ? e === "queued" ? "Queued…" : "Running…" : "Run";
|
|
27
|
+
}
|
|
28
|
+
function ft(e) {
|
|
29
|
+
return e === "run_not_cancelable" ? "reconcile" : "surface";
|
|
30
|
+
}
|
|
31
|
+
function de(e, t) {
|
|
32
|
+
if (!e) return [];
|
|
33
|
+
const n = t ? fe(t) : void 0;
|
|
34
|
+
return Object.entries(e).map(([o, r]) => ({
|
|
35
|
+
...Y(o, r),
|
|
36
|
+
...z(r),
|
|
37
|
+
...(n == null ? void 0 : n.get(o)) ?? {}
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
function fe(e) {
|
|
41
|
+
const t = [...e].sort((r, s) => r.seq - s.seq), n = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const r of t) {
|
|
43
|
+
if (r.nodeId === null || r.nodeId === void 0) continue;
|
|
44
|
+
const s = { path: r.path };
|
|
45
|
+
r.item !== void 0 && (s.item = r.item), r.old !== void 0 && (s.old = r.old), r.new !== void 0 && (s.new = r.new), r.warning !== void 0 && (s.warning = r.warning);
|
|
46
|
+
const a = n.get(r.nodeId) ?? { writes: [], lastSeq: r.seq };
|
|
47
|
+
a.writes.push(s), a.lastSeq = r.seq, n.set(r.nodeId, a);
|
|
48
|
+
}
|
|
49
|
+
const o = /* @__PURE__ */ new Map();
|
|
50
|
+
for (const [r, { writes: s, lastSeq: a }] of n)
|
|
51
|
+
o.set(r, { stateWrites: s, stateAfter: ae(t, a) });
|
|
52
|
+
return o;
|
|
53
|
+
}
|
|
54
|
+
const pe = /* @__PURE__ */ new Set([
|
|
55
|
+
"not_on_path",
|
|
56
|
+
"condition",
|
|
57
|
+
"stopped",
|
|
58
|
+
"disabled"
|
|
59
|
+
]);
|
|
60
|
+
function Y(e, t) {
|
|
61
|
+
return {
|
|
62
|
+
id: e,
|
|
63
|
+
status: t.status,
|
|
64
|
+
...t.status === "skipped" && pe.has(t.skipReason) ? { skipReason: t.skipReason } : {},
|
|
65
|
+
startedAt: t.startedAt,
|
|
66
|
+
finishedAt: t.finishedAt,
|
|
67
|
+
input: t.input,
|
|
68
|
+
output: t.output,
|
|
69
|
+
...Array.isArray(t.logs) && t.logs.length ? { logs: t.logs.filter((n) => typeof n == "string") } : {},
|
|
70
|
+
...t.meta !== void 0 && t.meta !== null ? { meta: t.meta } : {},
|
|
71
|
+
...ge(t.usage),
|
|
72
|
+
...he(t)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function ge(e) {
|
|
76
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return {};
|
|
77
|
+
const t = (s) => typeof s == "number" && Number.isFinite(s) && s >= 0, { memoryBytes: n, cpuMs: o } = e, r = {
|
|
78
|
+
...t(n) ? { memoryBytes: n } : {},
|
|
79
|
+
...t(o) ? { cpuMs: o } : {}
|
|
80
|
+
};
|
|
81
|
+
return Object.keys(r).length ? { usage: r } : {};
|
|
82
|
+
}
|
|
83
|
+
const ye = /* @__PURE__ */ new Set(["succeeded", "failed", "running"]);
|
|
84
|
+
function z(e) {
|
|
85
|
+
if (!e || !Array.isArray(e.iterations)) return {};
|
|
86
|
+
const t = e.iterations.filter((o) => o !== null && typeof o == "object").map((o) => {
|
|
87
|
+
var u;
|
|
88
|
+
const r = o.nodes !== null && typeof o.nodes == "object" ? o.nodes : {}, s = Object.entries(r).map(([i, l]) => ({
|
|
89
|
+
...Y(i, l),
|
|
90
|
+
...z(l)
|
|
91
|
+
})), a = typeof o.failedNodeId == "string" && o.failedNodeId !== "" ? o.failedNodeId : (u = s.find((i) => i.status === "failed")) == null ? void 0 : u.id, c = ye.has(o.status) ? o.status : s.some((i) => i.status === "failed") ? "failed" : s.some((i) => i.status === "running") ? "running" : "succeeded";
|
|
92
|
+
return {
|
|
93
|
+
index: o.index,
|
|
94
|
+
status: c,
|
|
95
|
+
...a !== void 0 ? { failedNodeId: a } : {},
|
|
96
|
+
steps: s
|
|
97
|
+
};
|
|
98
|
+
}).sort((o, r) => o.index - r.index), n = (o) => typeof o == "number" && Number.isFinite(o);
|
|
99
|
+
return {
|
|
100
|
+
iterations: t,
|
|
101
|
+
...n(e.iterationsTotal) ? { iterationsTotal: e.iterationsTotal } : {},
|
|
102
|
+
...n(e.iterationsFailed) ? { iterationsFailed: e.iterationsFailed } : {},
|
|
103
|
+
...typeof e.iterationsTruncated == "boolean" ? { iterationsTruncated: e.iterationsTruncated } : {}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function he(e) {
|
|
107
|
+
const t = U(e.error);
|
|
108
|
+
return t ? { error: t } : e.status === "failed" ? { error: { message: W } } : {};
|
|
109
|
+
}
|
|
110
|
+
function U(e) {
|
|
111
|
+
if (e != null) {
|
|
112
|
+
if (typeof e == "string" && e !== "") return { message: e };
|
|
113
|
+
if (typeof e == "object") {
|
|
114
|
+
const t = e, n = typeof t.code == "string" ? t.code : void 0, o = typeof t.message == "string" && t.message !== "" ? t.message : n || we(e);
|
|
115
|
+
return {
|
|
116
|
+
...n !== void 0 ? { code: n } : {},
|
|
117
|
+
message: o || "Unknown error.",
|
|
118
|
+
...typeof t.phase == "string" ? { phase: t.phase } : {},
|
|
119
|
+
...typeof t.retryable == "boolean" ? { retryable: t.retryable } : {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return { message: String(e) || "Unknown error." };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function we(e) {
|
|
126
|
+
try {
|
|
127
|
+
return JSON.stringify(e) ?? "";
|
|
128
|
+
} catch {
|
|
129
|
+
return "";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function pt(e, t) {
|
|
133
|
+
if (!e) return {};
|
|
134
|
+
const n = new Set(t.filter((i) => i.error !== void 0).map((i) => i.id)), o = new Set(
|
|
135
|
+
t.filter((i) => i.error !== void 0 && i.error.message !== W).map((i) => i.id)
|
|
136
|
+
), r = (e.stepErrors ?? []).map((i) => ({ e: i, id: i.nodeId ?? i.stepId ?? "" })).filter(({ id: i }) => !o.has(i)).map(({ e: i, id: l }) => ({
|
|
137
|
+
stepId: l,
|
|
138
|
+
error: U(i.error) ?? { message: W }
|
|
139
|
+
})), s = U(e.error), a = (i) => s !== void 0 && (i == null ? void 0 : i.message) === s.message && (i == null ? void 0 : i.code) === s.code;
|
|
140
|
+
let u = t.some((i) => a(i.error)) || r.some((i) => a(i.error)) ? void 0 : s;
|
|
141
|
+
return !u && e.status === "failed" && n.size === 0 && r.length === 0 && (u = { message: ce }), {
|
|
142
|
+
...u ? { runError: u } : {},
|
|
143
|
+
...r.length > 0 ? { stepErrors: r } : {}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function me(e) {
|
|
147
|
+
var n;
|
|
148
|
+
const t = (n = e == null ? void 0 : e[e.length - 1]) == null ? void 0 : n.with;
|
|
149
|
+
if (!(t === null || typeof t != "object" || Array.isArray(t)))
|
|
150
|
+
return t;
|
|
151
|
+
}
|
|
152
|
+
async function gt(e, t, n) {
|
|
153
|
+
var o;
|
|
154
|
+
if (e) {
|
|
155
|
+
if (n)
|
|
156
|
+
try {
|
|
157
|
+
const r = (o = await n()) == null ? void 0 : o.find((s) => s.nodeId === e);
|
|
158
|
+
if (r) {
|
|
159
|
+
const s = r.input;
|
|
160
|
+
return s === null || typeof s != "object" || Array.isArray(s) ? void 0 : Object.keys(s).length > 0 ? s : void 0;
|
|
161
|
+
}
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
return me(await t(e));
|
|
166
|
+
} catch {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function yt(e, t, n) {
|
|
172
|
+
const o = e.find((s) => {
|
|
173
|
+
var a;
|
|
174
|
+
return !!((a = s.uses) != null && a.app) && t(s.uses.app);
|
|
175
|
+
});
|
|
176
|
+
if (o) return { id: o.id, manual: !0 };
|
|
177
|
+
const r = e.find(
|
|
178
|
+
(s) => {
|
|
179
|
+
var a;
|
|
180
|
+
return !!((a = s.uses) != null && a.app) && n({ app: s.uses.app, ...s.uses.trigger === !0 ? { trigger: !0 } : {} });
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
return r ? { id: r.id, manual: !1 } : void 0;
|
|
184
|
+
}
|
|
185
|
+
const be = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled"]);
|
|
186
|
+
function Se(e) {
|
|
187
|
+
return new Promise((t) => setTimeout(t, e));
|
|
188
|
+
}
|
|
189
|
+
async function J(e, t = Se) {
|
|
190
|
+
for (let n = 0; n < 600; n++) {
|
|
191
|
+
const o = await e();
|
|
192
|
+
if (be.has(o.status)) return o;
|
|
193
|
+
await t(500);
|
|
194
|
+
}
|
|
195
|
+
return e();
|
|
196
|
+
}
|
|
197
|
+
const ke = {
|
|
198
|
+
status: "",
|
|
199
|
+
kind: "",
|
|
200
|
+
from: "",
|
|
201
|
+
to: "",
|
|
202
|
+
q: "",
|
|
203
|
+
trigger: "",
|
|
204
|
+
offset: 0
|
|
205
|
+
}, V = /^(entry|kind):.{1,200}$/;
|
|
206
|
+
function ve(e) {
|
|
207
|
+
if (!V.test(e)) return {};
|
|
208
|
+
const t = e.slice(e.indexOf(":") + 1);
|
|
209
|
+
return e.startsWith("entry:") ? { entry: t } : { trigger: t };
|
|
210
|
+
}
|
|
211
|
+
const Z = 25, qe = /* @__PURE__ */ new Set([
|
|
212
|
+
"queued",
|
|
213
|
+
"running",
|
|
214
|
+
"succeeded",
|
|
215
|
+
"failed",
|
|
216
|
+
"canceled"
|
|
217
|
+
]), Te = /* @__PURE__ */ new Set(["function", "endpoint", "workflow"]), Re = /^\d{4}-\d{2}-\d{2}$/;
|
|
218
|
+
function O(e) {
|
|
219
|
+
if (!Re.test(e)) return !1;
|
|
220
|
+
const { y: t, m: n, d: o } = D(e), r = new Date(t, n - 1, o);
|
|
221
|
+
return r.getFullYear() === t && r.getMonth() === n - 1 && r.getDate() === o;
|
|
222
|
+
}
|
|
223
|
+
function D(e) {
|
|
224
|
+
const [t, n, o] = e.split("-").map(Number);
|
|
225
|
+
return { y: t, m: n, d: o };
|
|
226
|
+
}
|
|
227
|
+
function ht(e) {
|
|
228
|
+
const t = new URLSearchParams(e), n = t.get("status") ?? "", o = t.get("kind") ?? "", r = t.get("from") ?? "", s = t.get("to") ?? "", a = t.get("q") ?? "", c = t.get("trigger") ?? "", u = t.get("offset");
|
|
229
|
+
let i = 0;
|
|
230
|
+
if (u !== null) {
|
|
231
|
+
const l = Number(u);
|
|
232
|
+
Number.isInteger(l) && l >= 0 && (i = l);
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
status: qe.has(n) ? n : "",
|
|
236
|
+
kind: Te.has(o) ? o : "",
|
|
237
|
+
from: O(r) ? r : "",
|
|
238
|
+
to: O(s) ? s : "",
|
|
239
|
+
q: a,
|
|
240
|
+
trigger: V.test(c) ? c : "",
|
|
241
|
+
offset: i
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function wt(e) {
|
|
245
|
+
const t = new URLSearchParams();
|
|
246
|
+
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.trigger && t.set("trigger", e.trigger), e.offset > 0 && t.set("offset", String(e.offset));
|
|
247
|
+
const n = t.toString();
|
|
248
|
+
return n === "" ? "" : `?${n}`;
|
|
249
|
+
}
|
|
250
|
+
function X(e, t, n) {
|
|
251
|
+
const o = {};
|
|
252
|
+
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 !== "" && O(t.from)) {
|
|
253
|
+
const { y: s, m: a, d: c } = D(t.from);
|
|
254
|
+
o.from = new Date(s, a - 1, c).toISOString();
|
|
255
|
+
}
|
|
256
|
+
if (t.to !== "" && O(t.to)) {
|
|
257
|
+
const { y: s, m: a, d: c } = D(t.to);
|
|
258
|
+
o.to = new Date(s, a - 1, c + 1).toISOString();
|
|
259
|
+
}
|
|
260
|
+
const r = t.q.trim();
|
|
261
|
+
return r !== "" && (o.q = r), t.trigger && Object.assign(o, ve(t.trigger)), n.paged && (o.limit = String(n.limit ?? Z), t.offset > 0 && (o.offset = String(t.offset))), o;
|
|
262
|
+
}
|
|
263
|
+
const G = {
|
|
264
|
+
root: ["history"],
|
|
265
|
+
list(e, t, n) {
|
|
266
|
+
return ["history", "list", e, t, n];
|
|
267
|
+
},
|
|
268
|
+
stats(e, t) {
|
|
269
|
+
return ["history", "stats", e, t];
|
|
270
|
+
},
|
|
271
|
+
exists(e) {
|
|
272
|
+
return ["history", "exists", e];
|
|
273
|
+
},
|
|
274
|
+
detail(e, t) {
|
|
275
|
+
return ["history", "detail", e, t];
|
|
276
|
+
},
|
|
277
|
+
triggers(e) {
|
|
278
|
+
return ["history", "triggers", e];
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
function Ee(e, t, n, o = Z) {
|
|
282
|
+
return e.request({
|
|
283
|
+
method: "GET",
|
|
284
|
+
path: "/history",
|
|
285
|
+
query: X(t, n, { paged: !0, limit: o })
|
|
286
|
+
}).then((r) => r.body);
|
|
287
|
+
}
|
|
288
|
+
function mt(e, t, n) {
|
|
289
|
+
return e.request({
|
|
290
|
+
method: "GET",
|
|
291
|
+
path: "/history/stats",
|
|
292
|
+
query: X(t, n, { paged: !1 })
|
|
293
|
+
}).then((o) => o.body.stats);
|
|
294
|
+
}
|
|
295
|
+
async function Ae(e, t) {
|
|
296
|
+
var a, c, u;
|
|
297
|
+
const n = /* @__PURE__ */ new Map();
|
|
298
|
+
let o;
|
|
299
|
+
try {
|
|
300
|
+
const { workflow: i } = await e.console.workflows.get(t);
|
|
301
|
+
o = Array.isArray(i.nodes) ? i.nodes : [];
|
|
302
|
+
} catch {
|
|
303
|
+
return n;
|
|
304
|
+
}
|
|
305
|
+
for (const i of o) {
|
|
306
|
+
const l = (a = i.uses) == null ? void 0 : a.app, p = (c = i.uses) == null ? void 0 : c.action;
|
|
307
|
+
typeof i.id != "string" || typeof l != "string" || typeof p != "string" || n.set(i.id, { app: l, action: p, ...((u = i.uses) == null ? void 0 : u.trigger) === !0 ? { trigger: !0 } : {} });
|
|
308
|
+
}
|
|
309
|
+
const r = [...new Set([...n.values()].map((i) => i.app))].filter(
|
|
310
|
+
(i) => !i.startsWith("@w6w/")
|
|
311
|
+
), s = await Promise.all(
|
|
312
|
+
r.map(async (i) => {
|
|
313
|
+
const l = [...n.values()].some((w) => w.app === i && w.trigger), [p, R] = await Promise.all([
|
|
314
|
+
e.console.apps.get(i).catch(() => null),
|
|
315
|
+
l ? e.console.apps.getTriggers(i).catch(() => []) : Promise.resolve([])
|
|
316
|
+
]), g = /* @__PURE__ */ new Map();
|
|
317
|
+
for (const w of (p == null ? void 0 : p.actions) ?? []) g.set(`a:${w.key}`, w.title);
|
|
318
|
+
for (const w of R) g.set(`t:${w.key}`, w.title);
|
|
319
|
+
return { app: i, displayName: p == null ? void 0 : p.app.displayName, titles: g };
|
|
320
|
+
})
|
|
321
|
+
);
|
|
322
|
+
for (const i of n.values()) {
|
|
323
|
+
const l = s.find((R) => R.app === i.app);
|
|
324
|
+
if (!l) continue;
|
|
325
|
+
l.displayName && (i.appName = l.displayName);
|
|
326
|
+
const p = l.titles.get(`${i.trigger ? "t" : "a"}:${i.action}`);
|
|
327
|
+
p && (i.actionName = p);
|
|
328
|
+
}
|
|
329
|
+
return n;
|
|
330
|
+
}
|
|
331
|
+
const Me = {
|
|
332
|
+
"@w6w/trigger": "Manual trigger",
|
|
333
|
+
"@w6w/webhook": "Webhook",
|
|
334
|
+
"@w6w/scheduler": "Schedule",
|
|
335
|
+
"@w6w/form": "Form"
|
|
336
|
+
};
|
|
337
|
+
function bt(e) {
|
|
338
|
+
const t = [];
|
|
339
|
+
for (const [o, r] of e) {
|
|
340
|
+
const s = Me[r.app];
|
|
341
|
+
if (!s && !r.trigger) continue;
|
|
342
|
+
const a = s ?? `${r.appName ?? r.app} · ${r.actionName ?? r.action}`;
|
|
343
|
+
t.push({ nodeId: o, label: a, app: r.app });
|
|
344
|
+
}
|
|
345
|
+
const n = /* @__PURE__ */ new Map();
|
|
346
|
+
for (const o of t) n.set(o.label, (n.get(o.label) ?? 0) + 1);
|
|
347
|
+
return t.map(
|
|
348
|
+
(o) => (n.get(o.label) ?? 0) > 1 ? { ...o, label: `${o.label} (${o.nodeId})` } : o
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
function St(e, t) {
|
|
352
|
+
if (e.triggerNodeId) {
|
|
353
|
+
const n = t.find((o) => o.nodeId === e.triggerNodeId);
|
|
354
|
+
if (n) return n.label;
|
|
355
|
+
}
|
|
356
|
+
return e.trigger ? e.trigger === "manual" ? "Manual run" : e.trigger.charAt(0).toUpperCase() + e.trigger.slice(1) : null;
|
|
357
|
+
}
|
|
358
|
+
async function kt(e, t) {
|
|
359
|
+
if (t.kind === "workflow") {
|
|
360
|
+
const [r, s] = await Promise.all([
|
|
361
|
+
e.console.workflows.getRun(t.id),
|
|
362
|
+
Ae(e, t.callableId)
|
|
363
|
+
]), a = r;
|
|
364
|
+
return {
|
|
365
|
+
id: t.id,
|
|
366
|
+
kind: "workflow",
|
|
367
|
+
callableName: t.callableName,
|
|
368
|
+
status: r.status,
|
|
369
|
+
startedAt: t.startedAt,
|
|
370
|
+
finishedAt: t.finishedAt,
|
|
371
|
+
durationMs: t.durationMs,
|
|
372
|
+
input: a.input ?? a.event ?? r.variables,
|
|
373
|
+
output: r.output,
|
|
374
|
+
error: r.error,
|
|
375
|
+
rerunOf: t.rerunOf ?? null,
|
|
376
|
+
steps: de(ue(r)).map((c) => {
|
|
377
|
+
const u = s.get(c.id);
|
|
378
|
+
return u ? { ...c, node: u } : c;
|
|
379
|
+
})
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
const o = (await e.request({
|
|
383
|
+
method: "GET",
|
|
384
|
+
path: `/invocations/${encodeURIComponent(t.id)}`
|
|
385
|
+
})).body.invocation;
|
|
386
|
+
return {
|
|
387
|
+
id: t.id,
|
|
388
|
+
kind: t.kind,
|
|
389
|
+
callableName: t.callableName,
|
|
390
|
+
status: o.status,
|
|
391
|
+
startedAt: o.startedAt,
|
|
392
|
+
finishedAt: o.finishedAt,
|
|
393
|
+
durationMs: o.durationMs,
|
|
394
|
+
input: o.input,
|
|
395
|
+
output: o.output,
|
|
396
|
+
error: o.error,
|
|
397
|
+
rerunOf: t.rerunOf ?? null
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function Ne(e) {
|
|
401
|
+
const t = e == null ? void 0 : e.raw, n = t == null ? void 0 : t.invocationId;
|
|
402
|
+
return typeof n == "string" ? n : void 0;
|
|
403
|
+
}
|
|
404
|
+
function Fe(e) {
|
|
405
|
+
return e !== null && typeof e == "object" && !Array.isArray(e) ? e : {};
|
|
406
|
+
}
|
|
407
|
+
async function Ce(e, t, n) {
|
|
408
|
+
const o = encodeURIComponent(t.callableId);
|
|
409
|
+
if (t.kind === "workflow") {
|
|
410
|
+
const u = (await e.request({
|
|
411
|
+
method: "POST",
|
|
412
|
+
path: `/runs/${encodeURIComponent(t.id)}/rerun`,
|
|
413
|
+
body: { allowUnpublished: !0 }
|
|
414
|
+
})).body.runId;
|
|
415
|
+
return await J(() => e.console.workflows.getRun(u), n), u;
|
|
416
|
+
}
|
|
417
|
+
const r = await e.request({
|
|
418
|
+
method: "GET",
|
|
419
|
+
path: `/invocations/${encodeURIComponent(t.id)}`
|
|
420
|
+
}), s = Fe(r.body.invocation.input), a = t.kind === "function" ? { inputs: s, allowUnpublished: !0, rerunOf: t.id } : { input: s, allowUnpublished: !0, rerunOf: t.id };
|
|
421
|
+
try {
|
|
422
|
+
const u = (await e.request({
|
|
423
|
+
method: "POST",
|
|
424
|
+
path: `/${t.kind === "function" ? "functions" : "endpoints"}/${o}/invoke`,
|
|
425
|
+
body: a
|
|
426
|
+
})).body.invocationId;
|
|
427
|
+
if (typeof u != "string") throw new Error("The server did not return an invocation id.");
|
|
428
|
+
return u;
|
|
429
|
+
} catch (c) {
|
|
430
|
+
const u = Ne(c);
|
|
431
|
+
if (u === void 0) throw c;
|
|
432
|
+
return u;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
async function vt(e, t, n = {}) {
|
|
436
|
+
const o = await Ce(e, t, n.sleep);
|
|
437
|
+
return Ie(e, t.callableId, o);
|
|
438
|
+
}
|
|
439
|
+
async function Ie(e, t, n) {
|
|
440
|
+
return (await Ee(
|
|
441
|
+
e,
|
|
442
|
+
{ callable: t },
|
|
443
|
+
{ ...ke, q: n },
|
|
444
|
+
1
|
|
445
|
+
)).executions.find((r) => r.id === n) ?? null;
|
|
446
|
+
}
|
|
447
|
+
var m, E, v;
|
|
448
|
+
class Ke {
|
|
449
|
+
constructor() {
|
|
450
|
+
S(this, m, "");
|
|
451
|
+
S(this, E, "");
|
|
452
|
+
S(this, v, []);
|
|
453
|
+
}
|
|
454
|
+
push(t) {
|
|
455
|
+
k(this, m, d(this, m) + t);
|
|
456
|
+
const n = [];
|
|
457
|
+
for (; ; ) {
|
|
458
|
+
const o = d(this, m).search(/\r\n|\r|\n/);
|
|
459
|
+
if (o < 0) break;
|
|
460
|
+
const r = d(this, m).slice(0, o);
|
|
461
|
+
if (k(this, m, d(this, m).slice(o + (d(this, m).startsWith(`\r
|
|
462
|
+
`, o) ? 2 : 1))), r === "") {
|
|
463
|
+
d(this, v).length > 0 && n.push({ event: d(this, E) || "message", data: d(this, v).join(`
|
|
464
|
+
`) }), k(this, E, ""), k(this, v, []);
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
if (r.startsWith(":")) continue;
|
|
468
|
+
const s = r.indexOf(":"), a = s < 0 ? r : r.slice(0, s);
|
|
469
|
+
let c = s < 0 ? "" : r.slice(s + 1);
|
|
470
|
+
c.startsWith(" ") && (c = c.slice(1)), a === "event" ? k(this, E, c) : a === "data" && d(this, v).push(c);
|
|
471
|
+
}
|
|
472
|
+
return n;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
m = new WeakMap(), E = new WeakMap(), v = new WeakMap();
|
|
476
|
+
function Oe(e) {
|
|
477
|
+
return `/runs/${encodeURIComponent(e)}/events`;
|
|
478
|
+
}
|
|
479
|
+
function $e(e) {
|
|
480
|
+
return e === "succeeded" || e === "failed" || e === "canceled";
|
|
481
|
+
}
|
|
482
|
+
async function Qe(e) {
|
|
483
|
+
const t = typeof e.token == "function" ? await e.token() : e.token;
|
|
484
|
+
return typeof t != "string" || t.trim() === "" ? null : {
|
|
485
|
+
...e.headers ?? {},
|
|
486
|
+
accept: "text/event-stream",
|
|
487
|
+
authorization: `Bearer ${t}`
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function _e(e, t) {
|
|
491
|
+
return new Promise((n) => {
|
|
492
|
+
if (t.aborted) return n();
|
|
493
|
+
const o = () => {
|
|
494
|
+
clearTimeout(r), t.removeEventListener("abort", o), n();
|
|
495
|
+
}, r = setTimeout(o, e);
|
|
496
|
+
t.addEventListener("abort", o);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
async function je(e) {
|
|
500
|
+
const t = e.sleep ?? _e, n = e.retryMinMs ?? 1e3, o = e.retryMaxMs ?? 15e3;
|
|
501
|
+
let r = n, s = null;
|
|
502
|
+
const a = (u) => {
|
|
503
|
+
u !== s && (s = u, e.onMode(u));
|
|
504
|
+
};
|
|
505
|
+
for (a("connecting"); ; ) {
|
|
506
|
+
if (e.signal.aborted) return c("done");
|
|
507
|
+
switch (await Pe(e, (i) => {
|
|
508
|
+
i ? (r = n, a("live")) : a("fallback");
|
|
509
|
+
})) {
|
|
510
|
+
case "terminal":
|
|
511
|
+
case "aborted":
|
|
512
|
+
return c("done");
|
|
513
|
+
case "refused":
|
|
514
|
+
case "gone":
|
|
515
|
+
return c("fallback");
|
|
516
|
+
case "reconnect":
|
|
517
|
+
continue;
|
|
518
|
+
case "dropped":
|
|
519
|
+
a("fallback"), await t(r, e.signal), r = Math.min(r * 2, o);
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
function c(u) {
|
|
524
|
+
return a(u), u;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
async function Pe(e, t) {
|
|
528
|
+
var l, p;
|
|
529
|
+
const n = e.firstSnapshotMs ?? 3e3, o = e.idleTimeoutMs ?? 45e3, r = new AbortController(), s = () => r.abort();
|
|
530
|
+
e.signal.addEventListener("abort", s);
|
|
531
|
+
let a = !1;
|
|
532
|
+
const c = setTimeout(() => {
|
|
533
|
+
a || t(!1);
|
|
534
|
+
}, n);
|
|
535
|
+
let u;
|
|
536
|
+
const i = () => {
|
|
537
|
+
clearTimeout(u), u = setTimeout(() => r.abort(), o);
|
|
538
|
+
};
|
|
539
|
+
try {
|
|
540
|
+
const R = await Qe(e.config);
|
|
541
|
+
if (!R) return "refused";
|
|
542
|
+
i();
|
|
543
|
+
let g;
|
|
544
|
+
try {
|
|
545
|
+
g = await e.fetchImpl(`${e.config.baseUrl}${Oe(e.runId)}`, {
|
|
546
|
+
method: "GET",
|
|
547
|
+
headers: R,
|
|
548
|
+
signal: r.signal,
|
|
549
|
+
cache: "no-store"
|
|
550
|
+
});
|
|
551
|
+
} catch {
|
|
552
|
+
return e.signal.aborted ? "aborted" : "dropped";
|
|
553
|
+
}
|
|
554
|
+
const w = g.headers.get("content-type") ?? "";
|
|
555
|
+
if (g.status === 401 || g.status === 403 || g.status === 404)
|
|
556
|
+
return await ((l = g.body) == null ? void 0 : l.cancel().catch(() => {
|
|
557
|
+
})), "refused";
|
|
558
|
+
if (!g.ok || !g.body)
|
|
559
|
+
return await ((p = g.body) == null ? void 0 : p.cancel().catch(() => {
|
|
560
|
+
})), "dropped";
|
|
561
|
+
if (!w.includes("text/event-stream"))
|
|
562
|
+
return await g.body.cancel().catch(() => {
|
|
563
|
+
}), "refused";
|
|
564
|
+
const M = g.body.getReader();
|
|
565
|
+
r.signal.addEventListener("abort", () => {
|
|
566
|
+
M.cancel().catch(() => {
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
const ne = new TextDecoder(), oe = new Ke();
|
|
570
|
+
for (; ; ) {
|
|
571
|
+
let _;
|
|
572
|
+
try {
|
|
573
|
+
_ = await M.read();
|
|
574
|
+
} catch {
|
|
575
|
+
return e.signal.aborted ? "aborted" : "dropped";
|
|
576
|
+
}
|
|
577
|
+
if (_.done) return e.signal.aborted ? "aborted" : "dropped";
|
|
578
|
+
i();
|
|
579
|
+
for (const I of oe.push(ne.decode(_.value, { stream: !0 })))
|
|
580
|
+
if (I.event === "snapshot") {
|
|
581
|
+
let N;
|
|
582
|
+
try {
|
|
583
|
+
N = JSON.parse(I.data).run;
|
|
584
|
+
} catch {
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (typeof N != "object" || N === null) continue;
|
|
588
|
+
if (a = !0, e.onSnapshot(N), t(!0), $e(N.status))
|
|
589
|
+
return await M.cancel().catch(() => {
|
|
590
|
+
}), "terminal";
|
|
591
|
+
} else {
|
|
592
|
+
if (I.event === "reconnect")
|
|
593
|
+
return await M.cancel().catch(() => {
|
|
594
|
+
}), "reconnect";
|
|
595
|
+
if (I.event === "gone")
|
|
596
|
+
return await M.cancel().catch(() => {
|
|
597
|
+
}), "gone";
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
} finally {
|
|
601
|
+
clearTimeout(c), clearTimeout(u), e.signal.removeEventListener("abort", s), r.abort();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
var b, q, F, C, L;
|
|
605
|
+
class We {
|
|
606
|
+
/** `start` opens the stream for a run (normally {@link streamRun}) and stops on `signal`. */
|
|
607
|
+
constructor(t) {
|
|
608
|
+
S(this, C);
|
|
609
|
+
S(this, b, /* @__PURE__ */ new Map());
|
|
610
|
+
S(this, q, /* @__PURE__ */ new Map());
|
|
611
|
+
S(this, F);
|
|
612
|
+
k(this, F, t);
|
|
613
|
+
}
|
|
614
|
+
/** The run's current stream mode, or `null` when nothing streams it. */
|
|
615
|
+
mode(t) {
|
|
616
|
+
var n;
|
|
617
|
+
return ((n = d(this, b).get(t)) == null ? void 0 : n.mode) ?? null;
|
|
618
|
+
}
|
|
619
|
+
/** Subscribe to mode changes of one run (for `useSyncExternalStore`). */
|
|
620
|
+
subscribe(t, n) {
|
|
621
|
+
let o = d(this, q).get(t);
|
|
622
|
+
return o || (o = /* @__PURE__ */ new Set(), d(this, q).set(t, o)), o.add(n), () => {
|
|
623
|
+
o.delete(n), o.size === 0 && d(this, q).delete(t);
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
acquire(t) {
|
|
627
|
+
let n = d(this, b).get(t);
|
|
628
|
+
if (n)
|
|
629
|
+
clearTimeout(n.stopTimer), n.stopTimer = void 0, n.refs++;
|
|
630
|
+
else {
|
|
631
|
+
const s = new AbortController(), a = {
|
|
632
|
+
refs: 1,
|
|
633
|
+
ctl: s,
|
|
634
|
+
mode: "connecting"
|
|
635
|
+
};
|
|
636
|
+
n = a, d(this, b).set(t, a), d(this, F).call(this, t, s.signal, (c) => {
|
|
637
|
+
d(this, b).get(t) === a && (a.mode = c, P(this, C, L).call(this, t));
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
const o = n;
|
|
641
|
+
let r = !1;
|
|
642
|
+
return () => {
|
|
643
|
+
r || (r = !0, o.refs--, !(o.refs > 0) && (o.stopTimer = setTimeout(() => {
|
|
644
|
+
o.refs > 0 || d(this, b).get(t) !== o || (d(this, b).delete(t), o.ctl.abort(), P(this, C, L).call(this, t));
|
|
645
|
+
}, 0)));
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
b = new WeakMap(), q = new WeakMap(), F = new WeakMap(), C = new WeakSet(), L = function(t) {
|
|
650
|
+
for (const n of [...d(this, q).get(t) ?? []]) n();
|
|
651
|
+
};
|
|
652
|
+
function Ue(e) {
|
|
653
|
+
return e === null || e === "fallback";
|
|
654
|
+
}
|
|
655
|
+
function De(e) {
|
|
656
|
+
const t = e.nodes ?? e.steps ?? {}, n = Object.keys(t).sort().map((o) => {
|
|
657
|
+
var r;
|
|
658
|
+
return `${o}=${String((r = t[o]) == null ? void 0 : r.status)}`;
|
|
659
|
+
});
|
|
660
|
+
return `${String(e.status)}|${n.join(",")}`;
|
|
661
|
+
}
|
|
662
|
+
const Le = (e) => ["workflows", e];
|
|
663
|
+
function xe(e, t) {
|
|
664
|
+
return e.workflows.list({ project: t });
|
|
665
|
+
}
|
|
666
|
+
function qt(e, t = !0) {
|
|
667
|
+
const n = f();
|
|
668
|
+
return T({
|
|
669
|
+
queryKey: Le(e),
|
|
670
|
+
queryFn: () => xe(n, e),
|
|
671
|
+
enabled: t
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
const Ge = (e) => ["workflow", e];
|
|
675
|
+
function He(e, t) {
|
|
676
|
+
return e.workflows.get(t);
|
|
677
|
+
}
|
|
678
|
+
function Tt(e, t = !0) {
|
|
679
|
+
const n = f();
|
|
680
|
+
return T({
|
|
681
|
+
queryKey: Ge(e),
|
|
682
|
+
queryFn: () => He(n, e),
|
|
683
|
+
enabled: t
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
function Rt(e) {
|
|
687
|
+
const t = f(), n = y();
|
|
688
|
+
return h({
|
|
689
|
+
mutationFn: (o) => e ? t.console.workflows.upsert(o, { project: e }) : Promise.reject(new Error("No project selected yet.")),
|
|
690
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["workflows"] })
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
function Et(e) {
|
|
694
|
+
const t = f(), n = y();
|
|
695
|
+
return h({
|
|
696
|
+
mutationFn: (o) => e ? t.console.workflows.upsert(o.definition, {
|
|
697
|
+
project: e,
|
|
698
|
+
ifUnmodifiedSince: o.ifUnmodifiedSince
|
|
699
|
+
}) : Promise.reject(new Error("No project selected yet.")),
|
|
700
|
+
// The single-workflow cache too: its `updatedAt` is the next save's precondition, so leaving
|
|
701
|
+
// it stale makes the very next save from the same panel a 409. Awaited, so a caller's own
|
|
702
|
+
// `onSuccess` (the modal closing) runs only once the fresh token is in.
|
|
703
|
+
onSuccess: () => Promise.all([
|
|
704
|
+
n.invalidateQueries({ queryKey: ["workflows"] }),
|
|
705
|
+
n.invalidateQueries({ queryKey: ["workflow"] })
|
|
706
|
+
])
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
function At() {
|
|
710
|
+
const e = f(), t = y();
|
|
711
|
+
return h({
|
|
712
|
+
mutationFn: (n) => e.workflows.archive(n),
|
|
713
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["workflows"] })
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
function Mt() {
|
|
717
|
+
const e = f(), t = y();
|
|
718
|
+
return h({
|
|
719
|
+
mutationFn: (n) => e.workflows.delete(n),
|
|
720
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["workflows"] })
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
const Q = (e) => ["runs", e];
|
|
724
|
+
function Nt(e) {
|
|
725
|
+
const t = f();
|
|
726
|
+
return T({
|
|
727
|
+
queryKey: Q(e),
|
|
728
|
+
queryFn: () => t.console.workflows.listRuns(e)
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
function Be(e, t, n, o) {
|
|
732
|
+
return e.workflows.run(t, { variables: n, input: o, allowUnpublished: !0 }).then((r) => J(() => e.console.workflows.getRun(r.runId)));
|
|
733
|
+
}
|
|
734
|
+
function Ft() {
|
|
735
|
+
const e = f(), t = y();
|
|
736
|
+
return h({
|
|
737
|
+
mutationFn: (n) => Be(e, n.id, n.variables, n.input),
|
|
738
|
+
onSuccess: (n, o) => t.invalidateQueries({ queryKey: Q(o.id) }),
|
|
739
|
+
onSettled: () => t.invalidateQueries({ queryKey: G.root })
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
function Ct(e, t, n, o, r) {
|
|
743
|
+
return e.workflows.run(t, { variables: n, input: o, entry: r, wait: !0 });
|
|
744
|
+
}
|
|
745
|
+
function Ye(e, t, n, o) {
|
|
746
|
+
return e.workflows.run(t, { variables: n, input: o, allowUnpublished: !0 }).then((r) => ({ runId: r.runId }));
|
|
747
|
+
}
|
|
748
|
+
async function ze(e, t, n, o) {
|
|
749
|
+
return { runId: (await e.request({
|
|
750
|
+
method: "POST",
|
|
751
|
+
path: A`/workflows/${t}/nodes/${n}/run`,
|
|
752
|
+
body: {
|
|
753
|
+
continue: !0,
|
|
754
|
+
stopAt: o.stopAt,
|
|
755
|
+
...o.nodes ? { state: { nodes: o.nodes } } : {},
|
|
756
|
+
...o.input ? { input: o.input } : {}
|
|
757
|
+
}
|
|
758
|
+
})).body.runId };
|
|
759
|
+
}
|
|
760
|
+
function It(e, t) {
|
|
761
|
+
return e.request({
|
|
762
|
+
method: "GET",
|
|
763
|
+
path: A`/workflows/${t}/node-samples`
|
|
764
|
+
}).then((n) => n.body.nodeSamples ?? []);
|
|
765
|
+
}
|
|
766
|
+
function Kt(e, t) {
|
|
767
|
+
return e.request({
|
|
768
|
+
method: "GET",
|
|
769
|
+
path: A`/workflows/${t}/test-inputs`
|
|
770
|
+
}).then((n) => n.body.testInputs ?? []);
|
|
771
|
+
}
|
|
772
|
+
function Ot(e, t, n, o) {
|
|
773
|
+
return e.request({
|
|
774
|
+
method: "PUT",
|
|
775
|
+
path: A`/workflows/${t}/nodes/${n}/test-input`,
|
|
776
|
+
body: { input: o }
|
|
777
|
+
}).then(() => {
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function $t() {
|
|
781
|
+
const e = f(), t = y();
|
|
782
|
+
return h({
|
|
783
|
+
mutationFn: (n) => ze(e, n.id, n.nodeId, n.body),
|
|
784
|
+
onSuccess: (n, o) => t.invalidateQueries({ queryKey: Q(o.id) }),
|
|
785
|
+
onSettled: () => t.invalidateQueries({ queryKey: G.root })
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
function Qt() {
|
|
789
|
+
const e = f(), t = y();
|
|
790
|
+
return h({
|
|
791
|
+
mutationFn: (n) => Ye(e, n.id, n.variables, n.input),
|
|
792
|
+
onSuccess: (n, o) => t.invalidateQueries({ queryKey: Q(o.id) }),
|
|
793
|
+
onSettled: () => t.invalidateQueries({ queryKey: G.root })
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
function Je(e, t) {
|
|
797
|
+
return e.workflows.cancel(t);
|
|
798
|
+
}
|
|
799
|
+
function _t() {
|
|
800
|
+
const e = f();
|
|
801
|
+
return h({
|
|
802
|
+
mutationFn: (t) => Je(e, t)
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
function Ve(e, t) {
|
|
806
|
+
return e.console.workflows.getRun(t);
|
|
807
|
+
}
|
|
808
|
+
const $ = (e) => ["run", e];
|
|
809
|
+
function Ze(e) {
|
|
810
|
+
const t = e.config;
|
|
811
|
+
return !t || typeof t.baseUrl != "string" || typeof globalThis.fetch != "function" ? null : { baseUrl: t.baseUrl, token: t.token ?? null, headers: t.headers };
|
|
812
|
+
}
|
|
813
|
+
const B = /* @__PURE__ */ new WeakMap();
|
|
814
|
+
function ee(e, t) {
|
|
815
|
+
let n = B.get(e);
|
|
816
|
+
if (n || (n = /* @__PURE__ */ new WeakMap(), B.set(e, n)), n.has(t)) return n.get(t) ?? null;
|
|
817
|
+
const o = Ze(e), r = o ? new We((s, a, c) => {
|
|
818
|
+
let u = null;
|
|
819
|
+
je({
|
|
820
|
+
config: o,
|
|
821
|
+
runId: s,
|
|
822
|
+
signal: a,
|
|
823
|
+
onMode: c,
|
|
824
|
+
fetchImpl: (i, l) => globalThis.fetch(i, l),
|
|
825
|
+
onSnapshot: (i) => {
|
|
826
|
+
t.setQueryData($(s), i);
|
|
827
|
+
const l = De(i);
|
|
828
|
+
u !== null && l !== u && t.invalidateQueries({
|
|
829
|
+
queryKey: [...$(s), "state-writes", "live"]
|
|
830
|
+
}), u = l;
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}) : null;
|
|
834
|
+
return n.set(t, r), r;
|
|
835
|
+
}
|
|
836
|
+
function te(e, t) {
|
|
837
|
+
const n = se(
|
|
838
|
+
(r) => e && t != null ? e.subscribe(t, r) : () => {
|
|
839
|
+
},
|
|
840
|
+
[e, t]
|
|
841
|
+
);
|
|
842
|
+
return ie(n, () => e && t != null ? e.mode(t) : null, () => null);
|
|
843
|
+
}
|
|
844
|
+
function jt(e) {
|
|
845
|
+
const t = f(), n = y(), o = ee(t, n), r = te(o, e), s = e != null ? n.getQueryData($(e)) : void 0, a = s !== void 0 && !K(s.status), c = o !== null && e != null && !a, u = c ? Ue(r ?? "connecting") : !a;
|
|
846
|
+
return re(() => {
|
|
847
|
+
if (!(!c || o === null || e == null))
|
|
848
|
+
return o.acquire(e);
|
|
849
|
+
}, [o, e, c]), T({
|
|
850
|
+
queryKey: $(e ?? ""),
|
|
851
|
+
queryFn: () => Ve(t, e),
|
|
852
|
+
enabled: e != null && u,
|
|
853
|
+
refetchInterval: (i) => {
|
|
854
|
+
var l;
|
|
855
|
+
return u && K((l = i.state.data) == null ? void 0 : l.status) ? 500 : !1;
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function Xe(e, t) {
|
|
860
|
+
return e.request({
|
|
861
|
+
method: "GET",
|
|
862
|
+
path: A`/runs/${t}/state-writes`
|
|
863
|
+
}).then((n) => ({ writes: n.body.writes ?? [], truncated: n.body.truncated === !0 }));
|
|
864
|
+
}
|
|
865
|
+
function et(e, t) {
|
|
866
|
+
return ["run", e, "state-writes", K(t) ? "live" : "final"];
|
|
867
|
+
}
|
|
868
|
+
function Pt(e, t) {
|
|
869
|
+
const n = f(), o = y(), r = ee(n, o), s = te(r, e), a = K(t), c = r !== null && e != null && s !== "fallback";
|
|
870
|
+
return T({
|
|
871
|
+
queryKey: et(e ?? "", t),
|
|
872
|
+
queryFn: () => Xe(n, e),
|
|
873
|
+
enabled: e != null,
|
|
874
|
+
refetchInterval: a && !c ? 500 : !1,
|
|
875
|
+
retry: !1
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
function Wt(e) {
|
|
879
|
+
return e.shared ? e.sourceRepo == null ? "pending" : "synced" : "private";
|
|
880
|
+
}
|
|
881
|
+
function tt(e) {
|
|
882
|
+
return ["documents", e];
|
|
883
|
+
}
|
|
884
|
+
function nt(e, t) {
|
|
885
|
+
return ["documents", "detail", e, t];
|
|
886
|
+
}
|
|
887
|
+
function Ut(e, t, n = !0) {
|
|
888
|
+
const o = f();
|
|
889
|
+
return T({
|
|
890
|
+
queryKey: nt(e, t),
|
|
891
|
+
queryFn: async () => await o.documents.get(e, { project: t }),
|
|
892
|
+
enabled: n
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
function Dt(e, t = !0) {
|
|
896
|
+
const n = f();
|
|
897
|
+
return T({
|
|
898
|
+
queryKey: tt(e),
|
|
899
|
+
// Cast to DocWithProvenance[], same as useDocumentQuery above: the wire
|
|
900
|
+
// response already carries `shared`/`source*`/`syncedAt` (repo.list()
|
|
901
|
+
// serializes every document the same way repo.get() does), but the SDK's
|
|
902
|
+
// own `Doc` type doesn't declare them yet (D-5). Without this cast,
|
|
903
|
+
// DocumentsPage.tsx's list rows have no type-visible way to branch on
|
|
904
|
+
// `d.shared` the way DocumentDetailPage.tsx already does.
|
|
905
|
+
queryFn: async () => await n.documents.list({ project: e }),
|
|
906
|
+
enabled: t
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
function Lt() {
|
|
910
|
+
const e = f(), t = y();
|
|
911
|
+
return h({
|
|
912
|
+
mutationFn: (n) => e.documents.create(n.input, { project: n.project }),
|
|
913
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
function xt() {
|
|
917
|
+
const e = f(), t = y();
|
|
918
|
+
return h({
|
|
919
|
+
mutationFn: (n) => e.documents.update(n.id, n.patch, { project: n.project }),
|
|
920
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
function Gt() {
|
|
924
|
+
const e = f(), t = y();
|
|
925
|
+
return h({
|
|
926
|
+
mutationFn: (n) => e.documents.delete(n.id, { project: n.project }),
|
|
927
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
function Ht() {
|
|
931
|
+
const e = f(), t = y();
|
|
932
|
+
return h({
|
|
933
|
+
mutationFn: (n) => e.request({
|
|
934
|
+
method: "POST",
|
|
935
|
+
path: A`/documents/${n.id}/sync`,
|
|
936
|
+
query: { project: n.project }
|
|
937
|
+
}),
|
|
938
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["documents"] })
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
async function Bt(e, t) {
|
|
942
|
+
return (await e.documents.list({ project: t })).map((o) => ({ key: o.key, format: o.format }));
|
|
943
|
+
}
|
|
944
|
+
export {
|
|
945
|
+
Rt as $,
|
|
946
|
+
It as A,
|
|
947
|
+
Kt as B,
|
|
948
|
+
xe as C,
|
|
949
|
+
de as D,
|
|
950
|
+
ke as E,
|
|
951
|
+
J as F,
|
|
952
|
+
vt as G,
|
|
953
|
+
Z as H,
|
|
954
|
+
gt as I,
|
|
955
|
+
dt as J,
|
|
956
|
+
pt as K,
|
|
957
|
+
ue as L,
|
|
958
|
+
$ as M,
|
|
959
|
+
et as N,
|
|
960
|
+
Be as O,
|
|
961
|
+
Ct as P,
|
|
962
|
+
Q,
|
|
963
|
+
ce as R,
|
|
964
|
+
W as S,
|
|
965
|
+
Ot as T,
|
|
966
|
+
K as U,
|
|
967
|
+
ze as V,
|
|
968
|
+
Ye as W,
|
|
969
|
+
lt as X,
|
|
970
|
+
U as Y,
|
|
971
|
+
At as Z,
|
|
972
|
+
_t as _,
|
|
973
|
+
xt as a,
|
|
974
|
+
Gt as a0,
|
|
975
|
+
Mt as a1,
|
|
976
|
+
Ut as a2,
|
|
977
|
+
Dt as a3,
|
|
978
|
+
jt as a4,
|
|
979
|
+
$t as a5,
|
|
980
|
+
Pt as a6,
|
|
981
|
+
Ft as a7,
|
|
982
|
+
Nt as a8,
|
|
983
|
+
Et as a9,
|
|
984
|
+
Qt as aa,
|
|
985
|
+
Ht as ab,
|
|
986
|
+
Tt as ac,
|
|
987
|
+
qt as ad,
|
|
988
|
+
Ge as ae,
|
|
989
|
+
bt as af,
|
|
990
|
+
Le as ag,
|
|
991
|
+
ct as b,
|
|
992
|
+
Je as c,
|
|
993
|
+
ft as d,
|
|
994
|
+
Ae as e,
|
|
995
|
+
nt as f,
|
|
996
|
+
Wt as g,
|
|
997
|
+
tt as h,
|
|
998
|
+
ht as i,
|
|
999
|
+
wt as j,
|
|
1000
|
+
Ie as k,
|
|
1001
|
+
kt as l,
|
|
1002
|
+
Ee as m,
|
|
1003
|
+
mt as n,
|
|
1004
|
+
Ve as o,
|
|
1005
|
+
Xe as p,
|
|
1006
|
+
He as q,
|
|
1007
|
+
St as r,
|
|
1008
|
+
yt as s,
|
|
1009
|
+
ve as t,
|
|
1010
|
+
Lt as u,
|
|
1011
|
+
G as v,
|
|
1012
|
+
X as w,
|
|
1013
|
+
le as x,
|
|
1014
|
+
me as y,
|
|
1015
|
+
Bt as z
|
|
1016
|
+
};
|
|
1017
|
+
//# sourceMappingURL=documents-hgltn0xe.js.map
|