@powerhousedao/workflow 6.2.3-dev.89 → 6.2.3-dev.90

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 (73) hide show
  1. package/dist/node/document-models/connection/index.mjs +67 -3
  2. package/dist/node/document-models/connection/index.mjs.map +1 -0
  3. package/dist/node/document-models/index.mjs +3 -3
  4. package/dist/node/document-models/workflow/index.mjs +86 -3
  5. package/dist/node/document-models/workflow/index.mjs.map +1 -0
  6. package/dist/node/editors/index.mjs +6 -4
  7. package/dist/node/editors/index.mjs.map +1 -0
  8. package/dist/node/index.mjs +5 -412
  9. package/dist/node/index.mjs.map +1 -1
  10. package/dist/node/{module-CuTg45ct.mjs → module-BXKUB58R.mjs} +9 -4
  11. package/dist/node/module-BXKUB58R.mjs.map +1 -0
  12. package/dist/node/{module-BEEASith.mjs → module-CaBtkQmd.mjs} +16 -16
  13. package/dist/node/module-CaBtkQmd.mjs.map +1 -0
  14. package/dist/node/pieces/ai/descriptor.json +1 -1
  15. package/dist/node/pieces/ai/index.mjs +13 -13
  16. package/dist/node/pieces/ai/package.json +1 -1
  17. package/dist/node/pieces/reactor/descriptor.json +1 -1
  18. package/dist/node/pieces/reactor/package.json +1 -1
  19. package/dist/node/rolldown-runtime-D7D4PA-g.mjs +13 -0
  20. package/dist/node/upgrade-manifests-BCCpSD1J.mjs +8 -0
  21. package/dist/node/{upgrade-manifests-BA5OaR4H.mjs.map → upgrade-manifests-BCCpSD1J.mjs.map} +1 -1
  22. package/dist/powerhouse.manifest.json +2 -2
  23. package/dist/types/document-models/connection/v1/actions.d.ts +1 -0
  24. package/dist/types/document-models/connection/v1/actions.d.ts.map +1 -1
  25. package/dist/types/document-models/connection/v1/module.d.ts +1 -0
  26. package/dist/types/document-models/connection/v1/module.d.ts.map +1 -1
  27. package/dist/types/document-models/document-models.d.ts +2 -0
  28. package/dist/types/document-models/document-models.d.ts.map +1 -1
  29. package/dist/types/document-models/workflow/v1/actions.d.ts +1 -0
  30. package/dist/types/document-models/workflow/v1/actions.d.ts.map +1 -1
  31. package/dist/types/document-models/workflow/v1/module.d.ts +1 -0
  32. package/dist/types/document-models/workflow/v1/module.d.ts.map +1 -1
  33. package/package.json +22 -10
  34. package/dist/node/BlockSelector-Cia1Rpwz.mjs +0 -8727
  35. package/dist/node/BlockSelector-Cia1Rpwz.mjs.map +0 -1
  36. package/dist/node/PieceMarkdown-CUSdTMH4.mjs +0 -23307
  37. package/dist/node/PieceMarkdown-CUSdTMH4.mjs.map +0 -1
  38. package/dist/node/block-type-kX-27vVt.mjs +0 -44
  39. package/dist/node/block-type-kX-27vVt.mjs.map +0 -1
  40. package/dist/node/connection-BZxipUlb.mjs +0 -90
  41. package/dist/node/connection-BZxipUlb.mjs.map +0 -1
  42. package/dist/node/connection-form-CJFKPwfg.mjs +0 -1364
  43. package/dist/node/connection-form-CJFKPwfg.mjs.map +0 -1
  44. package/dist/node/data-tree-D9jdFsaX.mjs +0 -1916
  45. package/dist/node/data-tree-D9jdFsaX.mjs.map +0 -1
  46. package/dist/node/editor-CwOjO82y.mjs +0 -3218
  47. package/dist/node/editor-CwOjO82y.mjs.map +0 -1
  48. package/dist/node/editor-NMRVprgI.mjs +0 -15573
  49. package/dist/node/editor-NMRVprgI.mjs.map +0 -1
  50. package/dist/node/editor-_c6UDRAN.mjs +0 -370
  51. package/dist/node/editor-_c6UDRAN.mjs.map +0 -1
  52. package/dist/node/editors/connection-editor/module.mjs +0 -15
  53. package/dist/node/editors/connection-editor/module.mjs.map +0 -1
  54. package/dist/node/editors/runtime/index.mjs +0 -2
  55. package/dist/node/editors/workflow-editor/module.mjs +0 -15
  56. package/dist/node/editors/workflow-editor/module.mjs.map +0 -1
  57. package/dist/node/editors/workflow-studio/module.mjs +0 -15
  58. package/dist/node/editors/workflow-studio/module.mjs.map +0 -1
  59. package/dist/node/graphql-D76E1YiQ.mjs +0 -14554
  60. package/dist/node/graphql-D76E1YiQ.mjs.map +0 -1
  61. package/dist/node/module-BEEASith.mjs.map +0 -1
  62. package/dist/node/module-CuTg45ct.mjs.map +0 -1
  63. package/dist/node/piece-auth-C0u0XTO8.mjs +0 -154
  64. package/dist/node/piece-auth-C0u0XTO8.mjs.map +0 -1
  65. package/dist/node/rolldown-runtime-B4iAMlE-.mjs +0 -35
  66. package/dist/node/runtime-queries-Ck5OoWdy.mjs +0 -3016
  67. package/dist/node/runtime-queries-Ck5OoWdy.mjs.map +0 -1
  68. package/dist/node/style.css +0 -667
  69. package/dist/node/trigger-text-T2D0a2Br.mjs +0 -3210
  70. package/dist/node/trigger-text-T2D0a2Br.mjs.map +0 -1
  71. package/dist/node/upgrade-manifests-BA5OaR4H.mjs +0 -8
  72. package/dist/node/workflow-BgURVzdc.mjs +0 -109
  73. package/dist/node/workflow-BgURVzdc.mjs.map +0 -1
@@ -1,3016 +0,0 @@
1
- import { t as blockKey } from "./block-type-kX-27vVt.mjs";
2
- import { ambientRenownTokenProvider } from "@powerhousedao/reactor-browser/graphql-client";
3
- //#region editors/workflow-editor/ui/forms.ts
4
- const POLL_INTERVAL_PROP = {
5
- name: "pollEverySeconds",
6
- displayName: "Poll every (seconds)",
7
- type: "NUMBER",
8
- required: false,
9
- description: "How often the reactor checks this trigger; 60 at the least. Omit to follow the piece's own cadence."
10
- };
11
- //#endregion
12
- //#region ../pieces-framework/dist/workflow.js
13
- const DELIVERIES = {
14
- POLLING: "poll",
15
- WEBHOOK: "webhook",
16
- MANUAL: "manual"
17
- };
18
- const APP_WEBHOOK_UNSUPPORTED = "TriggerStrategy.APP_WEBHOOK (app-level webhooks) is not supported";
19
- function checkTriggerStrategy(strategy) {
20
- if (typeof strategy === "string" && Object.hasOwn(DELIVERIES, strategy)) return { delivery: DELIVERIES[strategy] };
21
- if (strategy === "APP_WEBHOOK") return { issue: APP_WEBHOOK_UNSUPPORTED };
22
- return { issue: strategy === void 0 || strategy === null || strategy === "" ? "The trigger declares no strategy" : `Unknown trigger strategy ${JSON.stringify(strategy)}` };
23
- }
24
- const SCHEDULE_UNIT_MS = {
25
- minutes: 6e4,
26
- hours: 36e5,
27
- days: 864e5
28
- };
29
- var ScheduleConfigError = class extends Error {
30
- constructor(message) {
31
- super(`Schedule: ${message}`);
32
- this.name = "ScheduleConfigError";
33
- }
34
- };
35
- const CRON_FIELD = /^[\d*?A-Za-z]+(?:[-/][\dA-Za-z]+)*(?:,[\d*?A-Za-z]+(?:[-/][\dA-Za-z]+)*)*$/;
36
- function isRecord$1(value) {
37
- return value !== null && typeof value === "object" && !Array.isArray(value);
38
- }
39
- function parseTimezone(value) {
40
- if (value === void 0 || value === null || value === "") return "UTC";
41
- if (typeof value !== "string") throw new ScheduleConfigError("\"timezone\" must be an IANA name");
42
- try {
43
- new Intl.DateTimeFormat("en-US", { timeZone: value });
44
- } catch {
45
- throw new ScheduleConfigError(`unknown timezone "${value}" (use an IANA name such as Europe/Lisbon)`);
46
- }
47
- return value;
48
- }
49
- function parseCronText(cron) {
50
- if (typeof cron !== "string" || cron.trim() === "") throw new ScheduleConfigError("\"cron\" is required in cron mode");
51
- const pattern = cron.trim().replace(/\s+/g, " ");
52
- const fields = pattern.split(" ");
53
- if (fields.length !== 5) throw new ScheduleConfigError(`cron "${pattern}" must have exactly five fields (minute hour day month weekday)`);
54
- const bad = fields.find((field) => !CRON_FIELD.test(field));
55
- if (bad !== void 0) throw new ScheduleConfigError(`cron "${pattern}" has an invalid field "${bad}"`);
56
- return pattern;
57
- }
58
- function parseInterval(record) {
59
- const { every, unit } = record;
60
- if (typeof every !== "number" || !Number.isInteger(every) || every < 1) throw new ScheduleConfigError("\"every\" must be a whole number of at least 1 in interval mode");
61
- if (typeof unit !== "string" || !Object.hasOwn(SCHEDULE_UNIT_MS, unit)) throw new ScheduleConfigError(`"unit" must be one of ${Object.keys(SCHEDULE_UNIT_MS).join(", ")}`);
62
- const key = unit;
63
- return {
64
- every,
65
- unit: key,
66
- everyMs: every * SCHEDULE_UNIT_MS[key]
67
- };
68
- }
69
- function parseScheduleConfig(config) {
70
- if (!isRecord$1(config)) throw new ScheduleConfigError("the config must be an object");
71
- const timezone = parseTimezone(config.timezone);
72
- if (config.mode === "cron") return {
73
- mode: "cron",
74
- cron: parseCronText(config.cron),
75
- timezone
76
- };
77
- if (config.mode === "interval") return {
78
- mode: "interval",
79
- ...parseInterval(config),
80
- timezone
81
- };
82
- throw new ScheduleConfigError(config.mode === void 0 ? "\"mode\" is required (\"cron\" or \"interval\")" : `"mode" must be "cron" or "interval", not ${JSON.stringify(config.mode)}`);
83
- }
84
- function scheduleConfigIssue(config) {
85
- try {
86
- parseScheduleConfig(config);
87
- return;
88
- } catch (error) {
89
- return error instanceof Error ? error.message : String(error);
90
- }
91
- }
92
- const NEXT_PORT = "next";
93
- const ERROR_PORT = "error";
94
- const PIECE_ACTION_PORTS = [NEXT_PORT, ERROR_PORT];
95
- const TRIGGER_PORTS = [NEXT_PORT];
96
- function flowPorts(ports) {
97
- return ports.filter((port) => port !== ERROR_PORT);
98
- }
99
- const CORE_PIECE_NAME = "@powerhousedao/piece-core";
100
- const BRANCH_PORTS = [
101
- "true",
102
- "false",
103
- ERROR_PORT
104
- ];
105
- const STOP_PORTS = [ERROR_PORT];
106
- const OTHERWISE_PORT = "otherwise";
107
- const LOOP_PORTS = [
108
- NEXT_PORT,
109
- "each",
110
- ERROR_PORT
111
- ];
112
- function isCoreAction(block, name) {
113
- return block.kind === "action" && block.pieceName === "@powerhousedao/piece-core" && block.name === name;
114
- }
115
- function routerBranchPort(index) {
116
- return `branch_${index}`;
117
- }
118
- function routerBranches(config) {
119
- const branches = config !== null && typeof config === "object" ? config.branches : void 0;
120
- if (!Array.isArray(branches)) return [];
121
- return branches.map((branch) => branch !== null && typeof branch === "object" ? branch : {});
122
- }
123
- function routerBranchName(branch, index) {
124
- return (typeof branch.name === "string" ? branch.name.trim() : "") || `Branch ${index}`;
125
- }
126
- const BRANCH_PORT = /^branch_[1-9]\d*$/;
127
- function routerPorts(config, wired = []) {
128
- const branches = config !== null && typeof config === "object" ? config.branches : void 0;
129
- const dynamic = branches !== void 0 && branches !== null && !Array.isArray(branches);
130
- return [
131
- ...routerBranches(config).map((_, i) => routerBranchPort(i + 1)),
132
- ...dynamic ? [...new Set(wired)].filter((port) => BRANCH_PORT.test(port)) : [],
133
- OTHERWISE_PORT,
134
- ERROR_PORT
135
- ];
136
- }
137
- function stepPortLabel(block, config, port) {
138
- if (isCoreAction(block, "router")) {
139
- if (port === "otherwise") return "Otherwise";
140
- const match = /^branch_(\d+)$/.exec(port);
141
- const branches = routerBranches(config);
142
- const index = match ? Number(match[1]) : 0;
143
- if (index >= 1 && index <= branches.length) return routerBranchName(branches[index - 1], index);
144
- return;
145
- }
146
- if (isCoreAction(block, "loop")) {
147
- if (port === "each") return "For each item";
148
- if (port === "next") return "After loop";
149
- }
150
- }
151
- function knownPorts(block) {
152
- if (block.kind === "trigger") return TRIGGER_PORTS;
153
- if (block.pieceName !== "@powerhousedao/piece-core") return PIECE_ACTION_PORTS;
154
- if (block.name === "branch") return BRANCH_PORTS;
155
- if (block.name === "stop") return STOP_PORTS;
156
- if (block.name === "loop") return LOOP_PORTS;
157
- if (block.name === "router") return routerPorts(void 0);
158
- return PIECE_ACTION_PORTS;
159
- }
160
- function stepPorts(block, config, portsOf = knownPorts, wired) {
161
- if (isCoreAction(block, "router")) return routerPorts(config, wired);
162
- return portsOf(block);
163
- }
164
- const DOCUMENT_REF_KEY = "$documentRef";
165
- const MAX_DEPTH = 64;
166
- function isPlainObject$1(value) {
167
- if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
168
- const proto = Object.getPrototypeOf(value);
169
- return proto === Object.prototype || proto === null;
170
- }
171
- function isRevision(value) {
172
- return isPlainObject$1(value) && Object.values(value).every((entry) => typeof entry === "number" && Number.isFinite(entry));
173
- }
174
- function isDocumentReference(value) {
175
- return isPlainObject$1(value) && typeof value.documentId === "string" && typeof value.documentType === "string" && typeof value.branch === "string" && isRevision(value.revision);
176
- }
177
- function isDocumentRefMarker(value) {
178
- return isPlainObject$1(value) && isDocumentReference(value["$documentRef"]);
179
- }
180
- function walk(value, visit, depth, seen) {
181
- if (depth > MAX_DEPTH || typeof value !== "object" || value === null) return value;
182
- if (seen.has(value)) return value;
183
- if (Array.isArray(value)) {
184
- seen.add(value);
185
- const mapped = value.map((item) => walk(item, visit, depth + 1, seen));
186
- seen.delete(value);
187
- return mapped;
188
- }
189
- if (!isPlainObject$1(value)) return value;
190
- seen.add(value);
191
- const replaced = visit(value);
192
- const result = Object.fromEntries(Object.entries(replaced ?? value).map(([key, entry]) => [key, replaced && !(key in value) ? entry : walk(entry, visit, depth + 1, seen)]));
193
- seen.delete(value);
194
- return result;
195
- }
196
- function documentRefsIn(value) {
197
- const found = [];
198
- walk(value, (node) => {
199
- if (isDocumentRefMarker(node)) found.push(node[DOCUMENT_REF_KEY]);
200
- }, 0, /* @__PURE__ */ new WeakSet());
201
- return found;
202
- }
203
- function expandDocumentRefs(value, expand) {
204
- return walk(value, (node) => {
205
- if (!isDocumentRefMarker(node)) return void 0;
206
- const { [DOCUMENT_REF_KEY]: reference, ...rest } = node;
207
- return {
208
- ...rest,
209
- ...expand(reference)
210
- };
211
- }, 0, /* @__PURE__ */ new WeakSet());
212
- }
213
- const MANUAL_INPUT_TYPES = [
214
- "text",
215
- "text_area",
216
- "number",
217
- "toggle",
218
- "date",
219
- "dropdown",
220
- "json"
221
- ];
222
- var ManualPayloadError = class extends Error {
223
- fields;
224
- constructor(fields) {
225
- super(`Manual trigger payload: ${fields.map((entry) => entry.field ? `"${entry.field}" ${entry.message}` : entry.message).join("; ")}`);
226
- this.name = "ManualPayloadError";
227
- this.fields = fields;
228
- }
229
- };
230
- function isRecord(value) {
231
- return value !== null && typeof value === "object" && !Array.isArray(value);
232
- }
233
- const text = (value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
234
- function defaultText(value) {
235
- if (value === void 0 || value === null || value === "") return void 0;
236
- if (typeof value === "string") return value;
237
- if (typeof value === "object") return JSON.stringify(value);
238
- return String(value);
239
- }
240
- function parseManualOptions(value) {
241
- const entries = Array.isArray(value) ? value.map(optionEntry) : typeof value === "string" ? value.split(/\r?\n/).map(optionLine) : [];
242
- const byValue = /* @__PURE__ */ new Map();
243
- for (const entry of entries) if (entry && !byValue.has(entry.value)) byValue.set(entry.value, entry);
244
- return [...byValue.values()];
245
- }
246
- function optionLine(line) {
247
- const at = line.indexOf(" = ");
248
- const value = (at < 0 ? line : line.slice(at + 3)).trim();
249
- if (value === "") return void 0;
250
- const label = at < 0 ? value : line.slice(0, at).trim();
251
- return {
252
- label: label === "" ? value : label,
253
- value
254
- };
255
- }
256
- function optionEntry(entry) {
257
- if (!isRecord(entry)) return optionLine(String(entry));
258
- const value = defaultText(entry.value)?.trim();
259
- if (!value) return void 0;
260
- return {
261
- label: text(entry.label) ?? value,
262
- value
263
- };
264
- }
265
- function parseManualInputs(config) {
266
- const rows = isRecord(config) ? config.inputs : void 0;
267
- if (!Array.isArray(rows)) return [];
268
- const byName = /* @__PURE__ */ new Map();
269
- for (const row of rows) {
270
- if (!isRecord(row)) continue;
271
- const name = text(row.name);
272
- const type = row.type;
273
- if (!name || !MANUAL_INPUT_TYPES.includes(type)) continue;
274
- const description = text(row.description);
275
- const defaultValue = defaultText(row.defaultValue);
276
- byName.delete(name);
277
- byName.set(name, {
278
- name,
279
- displayName: text(row.displayName) ?? name,
280
- type,
281
- required: row.required === true,
282
- ...description ? { description } : {},
283
- ...defaultValue !== void 0 ? { defaultValue } : {},
284
- ...type === "dropdown" ? { options: parseManualOptions(row.options) } : {}
285
- });
286
- }
287
- return [...byName.values()];
288
- }
289
- const ISO_DATE = /^\d{4}-\d{2}-\d{2}(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/;
290
- function coerceManualValue(input, raw) {
291
- switch (input.type) {
292
- case "text":
293
- case "text_area":
294
- if (typeof raw === "string") return { value: raw };
295
- if (typeof raw === "number" || typeof raw === "boolean") return { value: String(raw) };
296
- return { error: "must be text" };
297
- case "number": {
298
- if (typeof raw === "number" && Number.isFinite(raw)) return { value: raw };
299
- const parsed = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
300
- return Number.isFinite(parsed) ? { value: parsed } : { error: "must be a number" };
301
- }
302
- case "toggle":
303
- if (typeof raw === "boolean") return { value: raw };
304
- if (typeof raw === "string" && /^(true|false)$/i.test(raw.trim())) return { value: raw.trim().toLowerCase() === "true" };
305
- return { error: "must be true or false" };
306
- case "date": {
307
- const value = typeof raw === "string" ? raw.trim() : "";
308
- const time = ISO_DATE.test(value) ? Date.parse(value) : NaN;
309
- return Number.isNaN(time) ? { error: "must be an ISO 8601 date" } : { value: new Date(time).toISOString() };
310
- }
311
- case "dropdown": {
312
- const value = typeof raw === "string" || typeof raw === "number" ? String(raw) : "";
313
- const values = (input.options ?? []).map((option) => option.value);
314
- if (values.length === 0 ? value !== "" : values.includes(value)) return { value };
315
- return values.length > 0 ? { error: `must be one of ${values.map((v) => `"${v}"`).join(", ")}` } : { error: "must be text" };
316
- }
317
- case "json": return { value: raw };
318
- }
319
- }
320
- function manualDefault(input) {
321
- if (input.defaultValue === void 0) return void 0;
322
- if (input.type === "json") try {
323
- return JSON.parse(input.defaultValue);
324
- } catch {
325
- return input.defaultValue;
326
- }
327
- if (input.type === "dropdown") {
328
- const options = input.options ?? [];
329
- const match = options.find((option) => option.value === input.defaultValue) ?? options.find((option) => option.label === input.defaultValue);
330
- if (match) return match.value;
331
- }
332
- const coerced = coerceManualValue(input, input.defaultValue);
333
- return "value" in coerced ? coerced.value : void 0;
334
- }
335
- const isMissing = (value) => value === void 0 || value === null || value === "";
336
- function coerceManualPayload(inputs, payload) {
337
- if (payload !== void 0 && payload !== null && !isRecord(payload)) throw new ManualPayloadError([{
338
- field: "",
339
- message: "must be a JSON object"
340
- }]);
341
- const next = { ...payload };
342
- const errors = [];
343
- for (const input of inputs) {
344
- let raw = next[input.name];
345
- if (isMissing(raw)) raw = manualDefault(input);
346
- if (isMissing(raw)) {
347
- delete next[input.name];
348
- if (input.required) errors.push({
349
- field: input.name,
350
- message: "is required"
351
- });
352
- continue;
353
- }
354
- const coerced = coerceManualValue(input, raw);
355
- if ("error" in coerced) errors.push({
356
- field: input.name,
357
- message: coerced.error
358
- });
359
- else next[input.name] = coerced.value;
360
- }
361
- if (errors.length > 0) throw new ManualPayloadError(errors);
362
- return next;
363
- }
364
- const SUBFLOWS_PIECE = "@activepieces/piece-subflows";
365
- const CALLABLE_FLOW_TRIGGER$1 = "callableFlow";
366
- const CALL_FLOW_ACTION = "callFlow";
367
- //#endregion
368
- //#region editors/workflow-editor/ui/blocks.ts
369
- const CORE_PIECE = CORE_PIECE_NAME;
370
- const REACTOR_PIECE = "@powerhousedao/piece-reactor";
371
- const core = (kind, name) => ({
372
- pieceName: CORE_PIECE,
373
- kind,
374
- name
375
- });
376
- const MANUAL_TRIGGER = core("trigger", "manual");
377
- const SCHEDULE_TRIGGER = core("trigger", "schedule");
378
- const WEBHOOK_TRIGGER = core("trigger", "webhook");
379
- const BRANCH_BLOCK = core("action", "branch");
380
- const ROUTER_BLOCK = core("action", "router");
381
- const LOOP_BLOCK = core("action", "loop");
382
- const ASSERT_BLOCK = core("action", "assert");
383
- const DELAY_BLOCK = core("action", "delay");
384
- const APPROVAL_BLOCK = core("action", "approval");
385
- const STOP_BLOCK = core("action", "stop");
386
- const WAIT_FOR_WEBHOOK_BLOCK = core("action", "waitForWebhook");
387
- const SUBFLOWS_VERSION = "0.7.0";
388
- const subflows = (kind, name) => ({
389
- pieceName: SUBFLOWS_PIECE,
390
- pieceVersion: SUBFLOWS_VERSION,
391
- kind,
392
- name
393
- });
394
- const CALLABLE_FLOW_TRIGGER = subflows("trigger", CALLABLE_FLOW_TRIGGER$1);
395
- const CALL_FLOW_BLOCK = subflows("action", CALL_FLOW_ACTION);
396
- const RETURN_RESPONSE_BLOCK = subflows("action", "returnResponse");
397
- function sameBlock(a, b) {
398
- return Boolean(a && b && blockKey(a) === blockKey(b));
399
- }
400
- function isCoreBlock(block) {
401
- return block.pieceName === CORE_PIECE;
402
- }
403
- function isReactorPieceBlock(block) {
404
- return block.pieceName === REACTOR_PIECE;
405
- }
406
- function stepBlock(step) {
407
- return {
408
- pieceName: step.pieceName,
409
- pieceVersion: step.pieceVersion,
410
- kind: "action",
411
- name: step.actionName
412
- };
413
- }
414
- function triggerBlock(trigger) {
415
- return {
416
- pieceName: trigger.pieceName,
417
- pieceVersion: trigger.pieceVersion,
418
- kind: "trigger",
419
- name: trigger.triggerName
420
- };
421
- }
422
- function stepFields(block) {
423
- return {
424
- pieceName: block.pieceName,
425
- pieceVersion: block.pieceVersion,
426
- actionName: block.name
427
- };
428
- }
429
- function triggerFields(block) {
430
- return {
431
- pieceName: block.pieceName,
432
- pieceVersion: block.pieceVersion,
433
- triggerName: block.name
434
- };
435
- }
436
- function pinBlock(pick, installedVersion) {
437
- const pieceVersion = pick.pieceVersion ?? installedVersion(pick.pieceName);
438
- if (!pieceVersion) return void 0;
439
- return {
440
- pieceName: pick.pieceName,
441
- pieceVersion,
442
- kind: pick.kind,
443
- name: pick.name
444
- };
445
- }
446
- const reactor = (kind, name) => ({
447
- pieceName: REACTOR_PIECE,
448
- kind,
449
- name
450
- });
451
- const TRIGGER_PRESETS = [
452
- {
453
- label: "Manual",
454
- block: MANUAL_TRIGGER,
455
- group: "core",
456
- description: "Fired on demand with a payload.",
457
- defaultConfig: {}
458
- },
459
- {
460
- label: "Schedule",
461
- block: SCHEDULE_TRIGGER,
462
- group: "core",
463
- description: "Fires on a cron expression or fixed interval.",
464
- defaultConfig: {
465
- mode: "cron",
466
- cron: "0 9 * * 1-5",
467
- timezone: "UTC"
468
- }
469
- },
470
- {
471
- label: "Webhook",
472
- block: WEBHOOK_TRIGGER,
473
- group: "core",
474
- description: "Fires when a provider POSTs to this workflow's URL.",
475
- defaultConfig: {
476
- methods: "POST",
477
- scheme: "none",
478
- responseMode: "async"
479
- }
480
- },
481
- {
482
- label: "Callable workflow",
483
- block: CALLABLE_FLOW_TRIGGER,
484
- group: "core",
485
- description: "Fires when another workflow in this drive calls it.",
486
- defaultConfig: {
487
- mode: "simple",
488
- exampleData: { sampleData: {} }
489
- }
490
- },
491
- {
492
- label: "Document event",
493
- block: reactor("trigger", "document-event"),
494
- group: "powerhouse",
495
- description: "Fires when a matching document operation lands.",
496
- defaultConfig: {}
497
- },
498
- {
499
- label: "Document created",
500
- block: reactor("trigger", "document-created"),
501
- group: "powerhouse",
502
- description: "Fires when a document is added to a drive.",
503
- defaultConfig: {}
504
- },
505
- {
506
- label: "Document deleted",
507
- block: reactor("trigger", "document-deleted"),
508
- group: "powerhouse",
509
- description: "Fires when a document is removed from a drive.",
510
- defaultConfig: {}
511
- }
512
- ];
513
- const STEP_PRESETS = [
514
- {
515
- label: "Branch",
516
- block: BRANCH_BLOCK,
517
- group: "core",
518
- description: "Routes true/false on a condition.",
519
- defaultConfig: {}
520
- },
521
- {
522
- label: "Router",
523
- block: ROUTER_BLOCK,
524
- group: "core",
525
- description: "Takes the first of several branches whose condition holds.",
526
- defaultConfig: { branches: [{ operator: "TEXT_EXACTLY_MATCHES" }] }
527
- },
528
- {
529
- label: "Loop on items",
530
- block: LOOP_BLOCK,
531
- group: "core",
532
- description: "Runs the steps inside it once for each item of a list.",
533
- defaultConfig: { items: "" }
534
- },
535
- {
536
- label: "Assert",
537
- block: ASSERT_BLOCK,
538
- group: "core",
539
- description: "Fails the run when a value is blank, rejected or not allowed.",
540
- defaultConfig: {
541
- value: "",
542
- allowValues: []
543
- }
544
- },
545
- {
546
- label: "Delay",
547
- block: DELAY_BLOCK,
548
- group: "core",
549
- description: "Waits for a while, or until a date, then carries on.",
550
- defaultConfig: {
551
- mode: "for",
552
- amount: 5,
553
- unit: "minutes"
554
- }
555
- },
556
- {
557
- label: "Request approval",
558
- block: APPROVAL_BLOCK,
559
- group: "core",
560
- description: "Waits until someone approves or rejects the run.",
561
- defaultConfig: {
562
- title: "",
563
- approveLabel: "Approve",
564
- rejectLabel: "Reject",
565
- reasonRequiredOn: "none"
566
- }
567
- },
568
- {
569
- label: "Respond and wait for webhook",
570
- block: WAIT_FOR_WEBHOOK_BLOCK,
571
- group: "core",
572
- description: "Answers the caller with a resume URL, then waits until it is called.",
573
- defaultConfig: {
574
- responseType: "json",
575
- includeResumeUrl: true
576
- }
577
- },
578
- {
579
- label: "Stop run",
580
- block: STOP_BLOCK,
581
- group: "core",
582
- description: "Ends the run successfully, optionally answering the caller.",
583
- defaultConfig: { responseType: "json" }
584
- },
585
- {
586
- label: "Call workflow",
587
- block: CALL_FLOW_BLOCK,
588
- group: "core",
589
- description: "Runs a callable workflow in this drive, optionally waiting for its response.",
590
- defaultConfig: {
591
- mode: "simple",
592
- waitForResponse: false
593
- }
594
- },
595
- {
596
- label: "Return response",
597
- block: RETURN_RESPONSE_BLOCK,
598
- group: "core",
599
- description: "Answers the workflow that called this one.",
600
- defaultConfig: {
601
- mode: "simple",
602
- response: { response: {} }
603
- }
604
- },
605
- {
606
- label: "Create document",
607
- block: reactor("action", "document-create"),
608
- group: "powerhouse",
609
- description: "Creates a Powerhouse document.",
610
- defaultConfig: {
611
- documentType: "",
612
- name: ""
613
- }
614
- },
615
- {
616
- label: "Dispatch actions",
617
- block: reactor("action", "document-dispatch"),
618
- group: "powerhouse",
619
- description: "Sends actions to a document.",
620
- defaultConfig: { documentId: "" }
621
- },
622
- {
623
- label: "Get document",
624
- block: reactor("action", "document-get"),
625
- group: "powerhouse",
626
- description: "Reads a document's current state.",
627
- defaultConfig: { documentId: "" }
628
- },
629
- {
630
- label: "Find documents",
631
- block: reactor("action", "document-find"),
632
- group: "powerhouse",
633
- description: "Lists documents by type and name.",
634
- defaultConfig: { documentType: "" }
635
- },
636
- {
637
- label: "List document types",
638
- block: reactor("action", "document-types"),
639
- group: "powerhouse",
640
- description: "Document models installed on this reactor.",
641
- defaultConfig: {}
642
- },
643
- {
644
- label: "Get document schema",
645
- block: reactor("action", "document-schema"),
646
- group: "powerhouse",
647
- description: "Action and state schemas of a document type.",
648
- defaultConfig: { documentType: "" }
649
- }
650
- ];
651
- //#endregion
652
- //#region editors/workflow-editor/runtime-client.ts
653
- const DEFAULT_RUNTIME_URL = "http://localhost:4001/graphql/workflow-runtime";
654
- function createTransport(url, options) {
655
- const doFetch = options.fetch ?? ((input, init) => fetch(input, init));
656
- const tokenOf = options.token ?? ambientRenownTokenProvider;
657
- return {
658
- url,
659
- gql: (query, variables) => gql(url, doFetch, tokenOf, query, variables)
660
- };
661
- }
662
- var RuntimeRequestError = class extends Error {
663
- code;
664
- constructor(message, code) {
665
- super(message);
666
- this.code = code;
667
- this.name = "RuntimeRequestError";
668
- }
669
- };
670
- function isSyncingError(error) {
671
- return error instanceof RuntimeRequestError && error.code === "WORKFLOW_SYNCING";
672
- }
673
- async function gql(url, doFetch, tokenOf, query, variables) {
674
- const token = await tokenOf();
675
- const body = await (await doFetch(url, {
676
- method: "POST",
677
- headers: {
678
- "content-type": "application/json",
679
- ...token ? { authorization: `Bearer ${token}` } : {}
680
- },
681
- body: JSON.stringify({
682
- query,
683
- variables
684
- })
685
- })).json();
686
- const first = body.errors?.[0];
687
- if (first) {
688
- const code = first.extensions?.code;
689
- throw new RuntimeRequestError(first.message, typeof code === "string" ? code : void 0);
690
- }
691
- if (!body.data) throw new Error("Empty GraphQL response");
692
- return body.data;
693
- }
694
- function blockInput(block) {
695
- return {
696
- pieceName: block.pieceName,
697
- pieceVersion: block.pieceVersion,
698
- name: block.name,
699
- kind: block.kind
700
- };
701
- }
702
- function actionDefaultsOf(entry) {
703
- const timeoutSeconds = entry.defaultTimeoutSeconds;
704
- const retryAttempts = entry.defaultRetry?.maxAttempts;
705
- if (timeoutSeconds === void 0 && retryAttempts === void 0) return {};
706
- return { actionDefaults: {
707
- ...timeoutSeconds !== void 0 ? { timeoutSeconds } : {},
708
- ...retryAttempts !== void 0 ? { retryAttempts } : {}
709
- } };
710
- }
711
- function getBlockForm(t, block) {
712
- return t.gql(`query Descriptor($block: BlockInput!) {
713
- workflowRuntime { blockDescriptor(block: $block) }
714
- }`, { block: blockInput(block) }).then((data) => {
715
- const descriptor = data.workflowRuntime.blockDescriptor;
716
- const entry = descriptor?.action ?? descriptor?.trigger;
717
- if (!descriptor || !entry) return null;
718
- const strategy = !descriptor.action && Boolean(descriptor.trigger) ? checkTriggerStrategy(entry.strategy) : void 0;
719
- if (strategy && "issue" in strategy) throw new Error(strategy.issue);
720
- const delivery = strategy?.delivery;
721
- const polled = delivery === "poll" && !isCoreBlock(block) && !isReactorPieceBlock(block);
722
- const props = entry.props;
723
- return {
724
- title: isCoreBlock(block) ? entry.displayName : `${descriptor.displayName} · ${entry.displayName}`,
725
- requireAuth: entry.requireAuth,
726
- ...entry.requireReactor === "read" || entry.requireReactor === "write" ? { requireReactor: entry.requireReactor } : {},
727
- auth: !descriptor.auth ? "none" : entry.requireAuth ? "required" : "optional",
728
- props: polled ? [...props, POLL_INTERVAL_PROP] : props,
729
- ...entry.ports ? { ports: entry.ports } : {},
730
- ...delivery ? { triggerDelivery: delivery } : {},
731
- ...entry.display ? { display: entry.display } : {},
732
- ...entry.description ? { description: entry.description } : {},
733
- ...entry.propertyGroups ? { propertyGroups: entry.propertyGroups } : {},
734
- ...entry.classification ? { classification: entry.classification } : {},
735
- ...entry.errorHandlingOptions ? { errorHandling: entry.errorHandlingOptions } : {},
736
- ...actionDefaultsOf(entry)
737
- };
738
- });
739
- }
740
- function atVersion(listing) {
741
- return listing.entries.map((entry) => ({
742
- ...entry,
743
- pieceName: listing.name,
744
- pieceVersion: listing.version
745
- }));
746
- }
747
- function fetchPieceCatalog(t) {
748
- return t.gql(`query Catalog { workflowRuntime { pieceCatalog } }`, {}).then((data) => data.workflowRuntime.pieceCatalog);
749
- }
750
- async function fetchPieceActions(t, packageName) {
751
- const listing = (await t.gql(`query Actions($packageName: String!) {
752
- workflowRuntime { pieceActions(packageName: $packageName) }
753
- }`, { packageName })).workflowRuntime.pieceActions;
754
- return atVersion({
755
- ...listing,
756
- entries: listing.actions
757
- });
758
- }
759
- async function fetchPieceTriggers(t, packageName) {
760
- const listing = (await t.gql(`query Triggers($packageName: String!) {
761
- workflowRuntime { pieceTriggers(packageName: $packageName) }
762
- }`, { packageName })).workflowRuntime.pieceTriggers;
763
- return atVersion({
764
- ...listing,
765
- entries: listing.triggers
766
- });
767
- }
768
- async function searchPieces(t, query, filter) {
769
- return (await t.gql(`query SearchPieces($query: String!, $kind: String!, $sources: [String!], $categories: [String!], $limit: Int) {
770
- workflowRuntime { searchPieces(query: $query, kind: $kind, sources: $sources, categories: $categories, limit: $limit) {
771
- status indexedPieces error
772
- pieces {
773
- pieceName pieceVersion displayName description logoUrl categories source deprecated unsupported namedPiece
774
- blocks { pieceName pieceVersion name pieceDisplayName logoUrl displayName description kind strategy unsupported }
775
- }
776
- } }
777
- }`, {
778
- query,
779
- kind: filter.kind,
780
- sources: filter.sources ?? null,
781
- categories: filter.categories ?? null,
782
- limit: filter.limit ?? null
783
- })).workflowRuntime.searchPieces;
784
- }
785
- function fetchBlockOutputTree(t, block, config) {
786
- return t.gql(`query OutputTree($block: BlockInput!, $config: Unknown) {
787
- workflowRuntime { blockOutputTree(block: $block, config: $config) }
788
- }`, {
789
- block: blockInput(block),
790
- config: config ?? {}
791
- }).then((data) => data.workflowRuntime.blockOutputTree);
792
- }
793
- function fetchStepOutputTree(t, workflowId, stepId) {
794
- return t.gql(`query StepOutputTree($workflowId: String!, $stepId: String!) {
795
- workflowRuntime { stepOutputTree(workflowId: $workflowId, stepId: $stepId) }
796
- }`, {
797
- workflowId,
798
- stepId
799
- }).then((data) => data.workflowRuntime.stepOutputTree);
800
- }
801
- function fetchConnections(t) {
802
- return t.gql(`query Connections { workflowRuntime { connections { id name connectorId authType status accountLabel } } }`, {}).then((data) => data.workflowRuntime.connections);
803
- }
804
- function checkConnection(t, connectionId) {
805
- return t.gql(`mutation CheckConnection($connectionId: String!) {
806
- workflowRuntime {
807
- checkConnection(connectionId: $connectionId) {
808
- ok
809
- detail
810
- accountLabel
811
- }
812
- }
813
- }`, { connectionId }).then((data) => data.workflowRuntime.checkConnection);
814
- }
815
- function fetchReactorAccess(t) {
816
- return t.gql(`query ReactorAccess {
817
- workflowRuntime { authEnforcement reactorIdentity { address key } authConditions }
818
- }`, {}).then((data) => data.workflowRuntime);
819
- }
820
- function fetchReactorAccessDenial(t, workflowId) {
821
- return t.gql(`query ReactorAccessDenial($workflowId: String!) {
822
- workflowRuntime { reactorAccessDenial(workflowId: $workflowId) }
823
- }`, { workflowId }).then((data) => data.workflowRuntime.reactorAccessDenial);
824
- }
825
- async function fetchOAuthRedirectUri(t) {
826
- const uri = (await t.gql(`query OAuthRedirectUri { workflowRuntime { oauthRedirectUri } }`, {})).workflowRuntime.oauthRedirectUri;
827
- return uri === null ? null : new URL(uri, t.url).href;
828
- }
829
- async function startOAuth(t, connectionId, options = {}) {
830
- return (await t.gql(`mutation StartOAuth($connectionId: String!, $redirectUri: String, $returnUrl: String) {
831
- workflowRuntime {
832
- startOAuth(connectionId: $connectionId, redirectUri: $redirectUri, returnUrl: $returnUrl) {
833
- state authorizationUrl redirectUri expiresAt
834
- }
835
- }
836
- }`, {
837
- connectionId,
838
- redirectUri: options.redirectUri ?? null,
839
- returnUrl: options.returnUrl ?? null
840
- })).workflowRuntime.startOAuth;
841
- }
842
- async function fetchOAuthAttempt(t, state) {
843
- return (await t.gql(`query OAuthAttempt($state: String!) {
844
- workflowRuntime { oauthAttempt(state: $state) { connectionId status error } }
845
- }`, { state })).workflowRuntime.oauthAttempt;
846
- }
847
- const SECRET_FIELDS = "ref label ownerId manageable version status createdAt updatedAt";
848
- async function createSecret(t, documentId, value, label) {
849
- return (await t.gql(`mutation CreateSecret($value: String!, $label: String, $documentId: String!) {
850
- workflowRuntime { createSecret(value: $value, label: $label, documentId: $documentId) { ${SECRET_FIELDS} } }
851
- }`, {
852
- value,
853
- label: label ?? null,
854
- documentId
855
- })).workflowRuntime.createSecret;
856
- }
857
- async function rotateSecret(t, ref, value) {
858
- return (await t.gql(`mutation RotateSecret($ref: String!, $value: String!) {
859
- workflowRuntime { rotateSecret(ref: $ref, value: $value) { ${SECRET_FIELDS} } }
860
- }`, {
861
- ref,
862
- value
863
- })).workflowRuntime.rotateSecret;
864
- }
865
- async function fetchSecretStat(t, ref) {
866
- return (await t.gql(`query Secret($ref: String!) {
867
- workflowRuntime { secret(ref: $ref) { ${SECRET_FIELDS} } }
868
- }`, { ref })).workflowRuntime.secret;
869
- }
870
- async function fetchWebhookEndpoint(t, workflowId, driveId) {
871
- return (await t.gql(`query WebhookEndpoint($workflowId: String!, $driveId: String) {
872
- workflowRuntime {
873
- webhookEndpoint(workflowId: $workflowId, driveId: $driveId) {
874
- workflowId url absoluteUrl armed createdAt
875
- }
876
- }
877
- }`, {
878
- workflowId,
879
- driveId: driveId ?? null
880
- })).workflowRuntime.webhookEndpoint;
881
- }
882
- async function testTrigger(t, workflowId, driveId) {
883
- return (await t.gql(`mutation TestTrigger($workflowId: String!, $driveId: String) {
884
- workflowRuntime { testTrigger(workflowId: $workflowId, driveId: $driveId) }
885
- }`, {
886
- workflowId,
887
- driveId: driveId ?? null
888
- })).workflowRuntime.testTrigger;
889
- }
890
- async function testCoreTrigger(t, workflowId, options = {}) {
891
- return (await t.gql(`mutation TestCoreTrigger($workflowId: String!, $payload: Unknown, $timeoutSeconds: Int, $driveId: String) {
892
- workflowRuntime {
893
- testTrigger(workflowId: $workflowId, payload: $payload, timeoutSeconds: $timeoutSeconds, driveId: $driveId)
894
- }
895
- }`, {
896
- workflowId,
897
- payload: options.payload ?? null,
898
- timeoutSeconds: options.timeoutSeconds ?? null,
899
- driveId: options.driveId ?? null
900
- })).workflowRuntime.testTrigger;
901
- }
902
- async function cancelTriggerTest(t, workflowId) {
903
- return (await t.gql(`mutation CancelTriggerTest($workflowId: String!) {
904
- workflowRuntime { cancelTriggerTest(workflowId: $workflowId) }
905
- }`, { workflowId })).workflowRuntime.cancelTriggerTest;
906
- }
907
- async function testStep(t, workflowId, stepId, driveId) {
908
- return (await t.gql(`mutation TestStep($workflowId: String!, $stepId: String!, $driveId: String) {
909
- workflowRuntime {
910
- testStep(workflowId: $workflowId, stepId: $stepId, driveId: $driveId) {
911
- runId status output error errorName durationMs
912
- }
913
- }
914
- }`, {
915
- workflowId,
916
- stepId,
917
- driveId: driveId ?? null
918
- })).workflowRuntime.testStep;
919
- }
920
- async function blockResolutions(t, workflowId) {
921
- return (await t.gql(`query BlockResolutions($workflowId: String!) {
922
- workflowRuntime {
923
- blockResolutions(workflowId: $workflowId) {
924
- stepId pieceName pieceVersion name kind resolvedVersion source match note latestVersion
925
- }
926
- }
927
- }`, { workflowId })).workflowRuntime.blockResolutions;
928
- }
929
- const WAITPOINT_FIELDS = `id runId workflowId stepId stepKey stepPath pieceName
930
- blockName type kind status createdAt resumeAt expiresAt resolvedAt decidedBy
931
- approval { title body approveLabel rejectLabel reasonRequiredOn approvers }`;
932
- const RUN_ROW_FIELDS = `id workflowId workflowName workflowVersion triggerKind
933
- triggerPayload status error errorName startedAt endedAt rerunOf warningNotes`;
934
- const STEP_ROW_FIELDS = "stepId stepKey path pieceName blockName status port error errorName startedAt endedAt";
935
- function withIterations(run) {
936
- const iterations = run.steps.filter((step) => step.path);
937
- if (iterations.length === 0) return run;
938
- return {
939
- ...run,
940
- steps: run.steps.filter((step) => !step.path),
941
- iterations
942
- };
943
- }
944
- const RUN_FIELDS = `${RUN_ROW_FIELDS} steps { ${STEP_ROW_FIELDS} input output }`;
945
- const RUN_LIST_FIELDS = `${RUN_ROW_FIELDS} steps { ${STEP_ROW_FIELDS} }`;
946
- const RUN_DETAIL_FIELDS = `${RUN_FIELDS} iterationsTotal waitpoints { ${WAITPOINT_FIELDS} }`;
947
- function scopeVariables(scope, limit) {
948
- return {
949
- workflowId: scope.workflowId ?? null,
950
- driveId: scope.driveId ?? null,
951
- excludeTriggerKinds: scope.excludeTriggerKinds ?? null,
952
- limit: scope.limit ?? limit
953
- };
954
- }
955
- async function fetchRuns(t, scope = {}) {
956
- return (await t.gql(`query Runs($workflowId: String, $driveId: String, $limit: Int, $excludeTriggerKinds: [String!]) {
957
- workflowRuntime { runs(workflowId: $workflowId, driveId: $driveId, limit: $limit, excludeTriggerKinds: $excludeTriggerKinds) { ${RUN_FIELDS} } }
958
- }`, scopeVariables(scope, 30))).workflowRuntime.runs.map(withIterations);
959
- }
960
- async function fetchRunsPage(t, scope = {}, cursor = null) {
961
- const { limit, ...rest } = scopeVariables(scope, 30);
962
- const page = (await t.gql(`query RunsPage($workflowId: String, $driveId: String, $excludeTriggerKinds: [String!], $paging: WorkflowRunsPagingInput) {
963
- workflowRuntime {
964
- runsPage(workflowId: $workflowId, driveId: $driveId, excludeTriggerKinds: $excludeTriggerKinds, paging: $paging) {
965
- items { ${RUN_LIST_FIELDS} } hasNextPage cursor
966
- }
967
- }
968
- }`, {
969
- ...rest,
970
- paging: {
971
- limit,
972
- cursor
973
- }
974
- })).workflowRuntime.runsPage;
975
- return {
976
- ...page,
977
- items: page.items.map(withIterations)
978
- };
979
- }
980
- async function fetchRun(t, runId) {
981
- const run = (await t.gql(`query Run($id: String!) { workflowRuntime { run(id: $id) { ${RUN_DETAIL_FIELDS} } } }`, { id: runId })).workflowRuntime.run;
982
- return run ? withIterations(run) : null;
983
- }
984
- async function fetchWaitingRuns(t, scope = {}) {
985
- return (await t.gql(`query WaitingRuns($driveId: String, $workflowId: String, $first: Int) {
986
- workflowRuntime {
987
- waitingRuns(driveId: $driveId, workflowId: $workflowId, first: $first) {
988
- ${RUN_LIST_FIELDS} waitpoints { ${WAITPOINT_FIELDS} }
989
- }
990
- }
991
- }`, {
992
- driveId: scope.driveId ?? null,
993
- workflowId: scope.workflowId ?? null,
994
- first: scope.first ?? null
995
- })).workflowRuntime.waitingRuns.map(withIterations);
996
- }
997
- async function resolveWaitpoint(t, waitpointId, approved, reason) {
998
- return (await t.gql(`mutation ResolveWaitpoint($waitpointId: String!, $approved: Boolean!, $reason: String) {
999
- workflowRuntime {
1000
- resolveWaitpoint(waitpointId: $waitpointId, approved: $approved, reason: $reason) {
1001
- ${WAITPOINT_FIELDS}
1002
- }
1003
- }
1004
- }`, {
1005
- waitpointId,
1006
- approved,
1007
- reason: reason ?? null
1008
- })).workflowRuntime.resolveWaitpoint;
1009
- }
1010
- async function fireWorkflow(t, workflowId, payload) {
1011
- return (await t.gql(`mutation Fire($workflowId: String!, $payload: Unknown) {
1012
- workflowRuntime { fire(workflowId: $workflowId, payload: $payload) { runId status error } }
1013
- }`, {
1014
- workflowId,
1015
- payload: payload ?? {}
1016
- })).workflowRuntime.fire;
1017
- }
1018
- async function rerunRun(t, runId) {
1019
- return (await t.gql(`mutation Rerun($runId: String!) {
1020
- workflowRuntime { rerun(runId: $runId) { runId status error } }
1021
- }`, { runId })).workflowRuntime.rerun;
1022
- }
1023
- async function cancelRun(t, runId) {
1024
- return (await t.gql(`mutation CancelRun($runId: String!) {
1025
- workflowRuntime { cancelRun(runId: $runId) { runId status error } }
1026
- }`, { runId })).workflowRuntime.cancelRun;
1027
- }
1028
- async function loadBlockOptions(t, block, propName, input, connectionId, searchValue, reactorConnectionId, workflowId) {
1029
- return (await t.gql(`query Options($block: BlockInput!, $propName: String!, $input: Unknown, $connectionId: String, $searchValue: String, $reactorConnectionId: String, $workflowId: String) {
1030
- workflowRuntime { blockOptions(block: $block, propName: $propName, input: $input, connectionId: $connectionId, searchValue: $searchValue, reactorConnectionId: $reactorConnectionId, workflowId: $workflowId) }
1031
- }`, {
1032
- block: blockInput(block),
1033
- propName,
1034
- input,
1035
- connectionId: connectionId ?? null,
1036
- searchValue: searchValue ?? null,
1037
- reactorConnectionId: reactorConnectionId ?? null,
1038
- workflowId: workflowId ?? null
1039
- })).workflowRuntime.blockOptions;
1040
- }
1041
- const operations = {
1042
- getBlockForm,
1043
- fetchPieceCatalog,
1044
- fetchPieceActions,
1045
- fetchPieceTriggers,
1046
- searchPieces,
1047
- fetchBlockOutputTree,
1048
- fetchStepOutputTree,
1049
- fetchConnections,
1050
- checkConnection,
1051
- fetchReactorAccess,
1052
- fetchReactorAccessDenial,
1053
- fetchOAuthRedirectUri,
1054
- startOAuth,
1055
- fetchOAuthAttempt,
1056
- createSecret,
1057
- rotateSecret,
1058
- fetchSecretStat,
1059
- fetchWebhookEndpoint,
1060
- testTrigger,
1061
- testCoreTrigger,
1062
- cancelTriggerTest,
1063
- testStep,
1064
- blockResolutions,
1065
- fetchRuns,
1066
- fetchRunsPage,
1067
- fetchRun,
1068
- fetchWaitingRuns,
1069
- fireWorkflow,
1070
- rerunRun,
1071
- resolveWaitpoint,
1072
- cancelRun,
1073
- loadBlockOptions
1074
- };
1075
- function createRuntimeClient(url, options = {}) {
1076
- const transport = createTransport(url, options);
1077
- const bound = Object.fromEntries(Object.entries(operations).map(([name, operation]) => [name, (...args) => operation(transport, ...args)]));
1078
- return {
1079
- ...transport,
1080
- ...bound
1081
- };
1082
- }
1083
- //#endregion
1084
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/subscribable.js
1085
- var Subscribable = class {
1086
- constructor() {
1087
- this.listeners = /* @__PURE__ */ new Set();
1088
- this.subscribe = this.subscribe.bind(this);
1089
- }
1090
- subscribe(listener) {
1091
- this.listeners.add(listener);
1092
- this.onSubscribe();
1093
- return () => {
1094
- this.listeners.delete(listener);
1095
- this.onUnsubscribe();
1096
- };
1097
- }
1098
- hasListeners() {
1099
- return this.listeners.size > 0;
1100
- }
1101
- onSubscribe() {}
1102
- onUnsubscribe() {}
1103
- };
1104
- //#endregion
1105
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
1106
- var defaultTimeoutProvider = {
1107
- setTimeout: (callback, delay) => setTimeout(callback, delay),
1108
- clearTimeout: (timeoutId) => clearTimeout(timeoutId),
1109
- setInterval: (callback, delay) => setInterval(callback, delay),
1110
- clearInterval: (intervalId) => clearInterval(intervalId)
1111
- };
1112
- var TimeoutManager = class {
1113
- #provider = defaultTimeoutProvider;
1114
- #providerCalled = false;
1115
- setTimeoutProvider(provider) {
1116
- if (process.env.NODE_ENV !== "production") {
1117
- if (this.#providerCalled && provider !== this.#provider) console.error(`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`, {
1118
- previous: this.#provider,
1119
- provider
1120
- });
1121
- }
1122
- this.#provider = provider;
1123
- if (process.env.NODE_ENV !== "production") this.#providerCalled = false;
1124
- }
1125
- setTimeout(callback, delay) {
1126
- if (process.env.NODE_ENV !== "production") this.#providerCalled = true;
1127
- return this.#provider.setTimeout(callback, delay);
1128
- }
1129
- clearTimeout(timeoutId) {
1130
- this.#provider.clearTimeout(timeoutId);
1131
- }
1132
- setInterval(callback, delay) {
1133
- if (process.env.NODE_ENV !== "production") this.#providerCalled = true;
1134
- return this.#provider.setInterval(callback, delay);
1135
- }
1136
- clearInterval(intervalId) {
1137
- this.#provider.clearInterval(intervalId);
1138
- }
1139
- };
1140
- var timeoutManager = new TimeoutManager();
1141
- function systemSetTimeoutZero(callback) {
1142
- setTimeout(callback, 0);
1143
- }
1144
- //#endregion
1145
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/utils.js
1146
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
1147
- function noop() {}
1148
- function functionalUpdate(updater, input) {
1149
- return typeof updater === "function" ? updater(input) : updater;
1150
- }
1151
- function isValidTimeout(value) {
1152
- return typeof value === "number" && value >= 0 && value !== Infinity;
1153
- }
1154
- function timeUntilStale(updatedAt, staleTime) {
1155
- return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
1156
- }
1157
- function resolveStaleTime(staleTime, query) {
1158
- return typeof staleTime === "function" ? staleTime(query) : staleTime;
1159
- }
1160
- function resolveEnabled(enabled, query) {
1161
- return typeof enabled === "function" ? enabled(query) : enabled;
1162
- }
1163
- function matchQuery(filters, query) {
1164
- const { type = "all", exact, fetchStatus, predicate, queryKey, stale } = filters;
1165
- if (queryKey) {
1166
- if (exact) {
1167
- if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) return false;
1168
- } else if (!partialMatchKey(query.queryKey, queryKey)) return false;
1169
- }
1170
- if (type !== "all") {
1171
- const isActive = query.isActive();
1172
- if (type === "active" && !isActive) return false;
1173
- if (type === "inactive" && isActive) return false;
1174
- }
1175
- if (typeof stale === "boolean" && query.isStale() !== stale) return false;
1176
- if (fetchStatus && fetchStatus !== query.state.fetchStatus) return false;
1177
- if (predicate && !predicate(query)) return false;
1178
- return true;
1179
- }
1180
- function matchMutation(filters, mutation) {
1181
- const { exact, status, predicate, mutationKey } = filters;
1182
- if (mutationKey) {
1183
- if (!mutation.options.mutationKey) return false;
1184
- if (exact) {
1185
- if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) return false;
1186
- } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) return false;
1187
- }
1188
- if (status && mutation.state.status !== status) return false;
1189
- if (predicate && !predicate(mutation)) return false;
1190
- return true;
1191
- }
1192
- function hashQueryKeyByOptions(queryKey, options) {
1193
- return (options?.queryKeyHashFn || hashKey)(queryKey);
1194
- }
1195
- function hashKey(queryKey) {
1196
- return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
1197
- result[key] = val[key];
1198
- return result;
1199
- }, {}) : val);
1200
- }
1201
- function partialMatchKey(a, b) {
1202
- if (a === b) return true;
1203
- if (typeof a !== typeof b) return false;
1204
- if (a && b && typeof a === "object" && typeof b === "object") return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));
1205
- return false;
1206
- }
1207
- var hasOwn = Object.prototype.hasOwnProperty;
1208
- function replaceEqualDeep(a, b, depth = 0) {
1209
- if (a === b) return a;
1210
- if (depth > 500) return b;
1211
- const array = isPlainArray(a) && isPlainArray(b);
1212
- if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
1213
- const aSize = (array ? a : Object.keys(a)).length;
1214
- const bItems = array ? b : Object.keys(b);
1215
- const bSize = bItems.length;
1216
- const copy = array ? new Array(bSize) : {};
1217
- let equalItems = 0;
1218
- for (let i = 0; i < bSize; i++) {
1219
- const key = array ? i : bItems[i];
1220
- const aItem = a[key];
1221
- const bItem = b[key];
1222
- if (aItem === bItem) {
1223
- copy[key] = aItem;
1224
- if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
1225
- continue;
1226
- }
1227
- if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
1228
- copy[key] = bItem;
1229
- continue;
1230
- }
1231
- const v = replaceEqualDeep(aItem, bItem, depth + 1);
1232
- copy[key] = v;
1233
- if (v === aItem) equalItems++;
1234
- }
1235
- return aSize === bSize && equalItems === aSize ? a : copy;
1236
- }
1237
- function shallowEqualObjects(a, b) {
1238
- if (!b || Object.keys(a).length !== Object.keys(b).length) return false;
1239
- for (const key in a) if (a[key] !== b[key]) return false;
1240
- return true;
1241
- }
1242
- function isPlainArray(value) {
1243
- return Array.isArray(value) && value.length === Object.keys(value).length;
1244
- }
1245
- function isPlainObject(o) {
1246
- if (!hasObjectPrototype(o)) return false;
1247
- const ctor = o.constructor;
1248
- if (ctor === void 0) return true;
1249
- const prot = ctor.prototype;
1250
- if (!hasObjectPrototype(prot)) return false;
1251
- if (!prot.hasOwnProperty("isPrototypeOf")) return false;
1252
- if (Object.getPrototypeOf(o) !== Object.prototype) return false;
1253
- return true;
1254
- }
1255
- function hasObjectPrototype(o) {
1256
- return Object.prototype.toString.call(o) === "[object Object]";
1257
- }
1258
- function sleep(timeout) {
1259
- return new Promise((resolve) => {
1260
- timeoutManager.setTimeout(resolve, timeout);
1261
- });
1262
- }
1263
- function replaceData(prevData, data, options) {
1264
- if (typeof options.structuralSharing === "function") return options.structuralSharing(prevData, data);
1265
- else if (options.structuralSharing !== false) {
1266
- if (process.env.NODE_ENV !== "production") try {
1267
- return replaceEqualDeep(prevData, data);
1268
- } catch (error) {
1269
- console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`);
1270
- throw error;
1271
- }
1272
- return replaceEqualDeep(prevData, data);
1273
- }
1274
- return data;
1275
- }
1276
- function keepPreviousData(previousData) {
1277
- return previousData;
1278
- }
1279
- function addToEnd(items, item, max = 0) {
1280
- const newItems = [...items, item];
1281
- return max && newItems.length > max ? newItems.slice(1) : newItems;
1282
- }
1283
- function addToStart(items, item, max = 0) {
1284
- const newItems = [item, ...items];
1285
- return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
1286
- }
1287
- var skipToken = /* @__PURE__ */ Symbol();
1288
- function ensureQueryFn(options, fetchOptions) {
1289
- if (process.env.NODE_ENV !== "production") {
1290
- if (options.queryFn === skipToken) console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`);
1291
- }
1292
- if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise;
1293
- if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`));
1294
- return options.queryFn;
1295
- }
1296
- function shouldThrowError(throwOnError, params) {
1297
- if (typeof throwOnError === "function") return throwOnError(...params);
1298
- return !!throwOnError;
1299
- }
1300
- function addConsumeAwareSignal(object, getSignal, onCancelled) {
1301
- let consumed = false;
1302
- let signal;
1303
- Object.defineProperty(object, "signal", {
1304
- enumerable: true,
1305
- get: () => {
1306
- signal ??= getSignal();
1307
- if (consumed) return signal;
1308
- consumed = true;
1309
- if (signal.aborted) onCancelled();
1310
- else signal.addEventListener("abort", onCancelled, { once: true });
1311
- return signal;
1312
- }
1313
- });
1314
- return object;
1315
- }
1316
- //#endregion
1317
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/focusManager.js
1318
- var FocusManager = class extends Subscribable {
1319
- #focused;
1320
- #cleanup;
1321
- #setup;
1322
- constructor() {
1323
- super();
1324
- this.#setup = (onFocus) => {
1325
- if (!isServer && window.addEventListener) {
1326
- const listener = () => onFocus();
1327
- window.addEventListener("visibilitychange", listener, false);
1328
- return () => {
1329
- window.removeEventListener("visibilitychange", listener);
1330
- };
1331
- }
1332
- };
1333
- }
1334
- onSubscribe() {
1335
- if (!this.#cleanup) this.setEventListener(this.#setup);
1336
- }
1337
- onUnsubscribe() {
1338
- if (!this.hasListeners()) {
1339
- this.#cleanup?.();
1340
- this.#cleanup = void 0;
1341
- }
1342
- }
1343
- setEventListener(setup) {
1344
- this.#setup = setup;
1345
- this.#cleanup?.();
1346
- this.#cleanup = setup((focused) => {
1347
- if (typeof focused === "boolean") this.setFocused(focused);
1348
- else this.onFocus();
1349
- });
1350
- }
1351
- setFocused(focused) {
1352
- if (this.#focused !== focused) {
1353
- this.#focused = focused;
1354
- this.onFocus();
1355
- }
1356
- }
1357
- onFocus() {
1358
- const isFocused = this.isFocused();
1359
- this.listeners.forEach((listener) => {
1360
- listener(isFocused);
1361
- });
1362
- }
1363
- isFocused() {
1364
- if (typeof this.#focused === "boolean") return this.#focused;
1365
- return globalThis.document?.visibilityState !== "hidden";
1366
- }
1367
- };
1368
- var focusManager = new FocusManager();
1369
- //#endregion
1370
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/thenable.js
1371
- function pendingThenable() {
1372
- let resolve;
1373
- let reject;
1374
- const thenable = new Promise((_resolve, _reject) => {
1375
- resolve = _resolve;
1376
- reject = _reject;
1377
- });
1378
- thenable.status = "pending";
1379
- thenable.catch(() => {});
1380
- function finalize(data) {
1381
- Object.assign(thenable, data);
1382
- delete thenable.resolve;
1383
- delete thenable.reject;
1384
- }
1385
- thenable.resolve = (value) => {
1386
- finalize({
1387
- status: "fulfilled",
1388
- value
1389
- });
1390
- resolve(value);
1391
- };
1392
- thenable.reject = (reason) => {
1393
- finalize({
1394
- status: "rejected",
1395
- reason
1396
- });
1397
- reject(reason);
1398
- };
1399
- return thenable;
1400
- }
1401
- //#endregion
1402
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/notifyManager.js
1403
- var defaultScheduler = systemSetTimeoutZero;
1404
- function createNotifyManager() {
1405
- let queue = [];
1406
- let transactions = 0;
1407
- let notifyFn = (callback) => {
1408
- callback();
1409
- };
1410
- let batchNotifyFn = (callback) => {
1411
- callback();
1412
- };
1413
- let scheduleFn = defaultScheduler;
1414
- const schedule = (callback) => {
1415
- if (transactions) queue.push(callback);
1416
- else scheduleFn(() => {
1417
- notifyFn(callback);
1418
- });
1419
- };
1420
- const flush = () => {
1421
- const originalQueue = queue;
1422
- queue = [];
1423
- if (originalQueue.length) scheduleFn(() => {
1424
- batchNotifyFn(() => {
1425
- originalQueue.forEach((callback) => {
1426
- notifyFn(callback);
1427
- });
1428
- });
1429
- });
1430
- };
1431
- return {
1432
- batch: (callback) => {
1433
- let result;
1434
- transactions++;
1435
- try {
1436
- result = callback();
1437
- } finally {
1438
- transactions--;
1439
- if (!transactions) flush();
1440
- }
1441
- return result;
1442
- },
1443
- /**
1444
- * All calls to the wrapped function will be batched.
1445
- */
1446
- batchCalls: (callback) => {
1447
- return (...args) => {
1448
- schedule(() => {
1449
- callback(...args);
1450
- });
1451
- };
1452
- },
1453
- schedule,
1454
- /**
1455
- * Use this method to set a custom notify function.
1456
- * This can be used to for example wrap notifications with `React.act` while running tests.
1457
- */
1458
- setNotifyFunction: (fn) => {
1459
- notifyFn = fn;
1460
- },
1461
- /**
1462
- * Use this method to set a custom function to batch notifications together into a single tick.
1463
- * By default React Query will use the batch function provided by ReactDOM or React Native.
1464
- */
1465
- setBatchNotifyFunction: (fn) => {
1466
- batchNotifyFn = fn;
1467
- },
1468
- setScheduler: (fn) => {
1469
- scheduleFn = fn;
1470
- }
1471
- };
1472
- }
1473
- var notifyManager = createNotifyManager();
1474
- //#endregion
1475
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/onlineManager.js
1476
- var OnlineManager = class extends Subscribable {
1477
- #online = true;
1478
- #cleanup;
1479
- #setup;
1480
- constructor() {
1481
- super();
1482
- this.#setup = (onOnline) => {
1483
- if (!isServer && window.addEventListener) {
1484
- const onlineListener = () => onOnline(true);
1485
- const offlineListener = () => onOnline(false);
1486
- window.addEventListener("online", onlineListener, false);
1487
- window.addEventListener("offline", offlineListener, false);
1488
- return () => {
1489
- window.removeEventListener("online", onlineListener);
1490
- window.removeEventListener("offline", offlineListener);
1491
- };
1492
- }
1493
- };
1494
- }
1495
- onSubscribe() {
1496
- if (!this.#cleanup) this.setEventListener(this.#setup);
1497
- }
1498
- onUnsubscribe() {
1499
- if (!this.hasListeners()) {
1500
- this.#cleanup?.();
1501
- this.#cleanup = void 0;
1502
- }
1503
- }
1504
- setEventListener(setup) {
1505
- this.#setup = setup;
1506
- this.#cleanup?.();
1507
- this.#cleanup = setup(this.setOnline.bind(this));
1508
- }
1509
- setOnline(online) {
1510
- if (this.#online !== online) {
1511
- this.#online = online;
1512
- this.listeners.forEach((listener) => {
1513
- listener(online);
1514
- });
1515
- }
1516
- }
1517
- isOnline() {
1518
- return this.#online;
1519
- }
1520
- };
1521
- var onlineManager = new OnlineManager();
1522
- //#endregion
1523
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/retryer.js
1524
- function defaultRetryDelay(failureCount) {
1525
- return Math.min(1e3 * 2 ** failureCount, 3e4);
1526
- }
1527
- function canFetch(networkMode) {
1528
- return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
1529
- }
1530
- var CancelledError = class extends Error {
1531
- constructor(options) {
1532
- super("CancelledError");
1533
- this.revert = options?.revert;
1534
- this.silent = options?.silent;
1535
- }
1536
- };
1537
- function createRetryer(config) {
1538
- let isRetryCancelled = false;
1539
- let failureCount = 0;
1540
- let continueFn;
1541
- const thenable = pendingThenable();
1542
- const isResolved = () => thenable.status !== "pending";
1543
- const cancel = (cancelOptions) => {
1544
- if (!isResolved()) {
1545
- const error = new CancelledError(cancelOptions);
1546
- reject(error);
1547
- config.onCancel?.(error);
1548
- }
1549
- };
1550
- const cancelRetry = () => {
1551
- isRetryCancelled = true;
1552
- };
1553
- const continueRetry = () => {
1554
- isRetryCancelled = false;
1555
- };
1556
- const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
1557
- const canStart = () => canFetch(config.networkMode) && config.canRun();
1558
- const resolve = (value) => {
1559
- if (!isResolved()) {
1560
- continueFn?.();
1561
- thenable.resolve(value);
1562
- }
1563
- };
1564
- const reject = (value) => {
1565
- if (!isResolved()) {
1566
- continueFn?.();
1567
- thenable.reject(value);
1568
- }
1569
- };
1570
- const pause = () => {
1571
- return new Promise((continueResolve) => {
1572
- continueFn = (value) => {
1573
- if (isResolved() || canContinue()) continueResolve(value);
1574
- };
1575
- config.onPause?.();
1576
- }).then(() => {
1577
- continueFn = void 0;
1578
- if (!isResolved()) config.onContinue?.();
1579
- });
1580
- };
1581
- const run = () => {
1582
- if (isResolved()) return;
1583
- let promiseOrValue;
1584
- const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
1585
- try {
1586
- promiseOrValue = initialPromise ?? config.fn();
1587
- } catch (error) {
1588
- promiseOrValue = Promise.reject(error);
1589
- }
1590
- Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
1591
- if (isResolved()) return;
1592
- const retry = config.retry ?? (isServer ? 0 : 3);
1593
- const retryDelay = config.retryDelay ?? defaultRetryDelay;
1594
- const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
1595
- const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
1596
- if (isRetryCancelled || !shouldRetry) {
1597
- reject(error);
1598
- return;
1599
- }
1600
- failureCount++;
1601
- config.onFail?.(failureCount, error);
1602
- sleep(delay).then(() => {
1603
- return canContinue() ? void 0 : pause();
1604
- }).then(() => {
1605
- if (isRetryCancelled) reject(error);
1606
- else run();
1607
- });
1608
- });
1609
- };
1610
- return {
1611
- promise: thenable,
1612
- status: () => thenable.status,
1613
- cancel,
1614
- continue: () => {
1615
- continueFn?.();
1616
- return thenable;
1617
- },
1618
- cancelRetry,
1619
- continueRetry,
1620
- canStart,
1621
- start: () => {
1622
- if (canStart()) run();
1623
- else pause().then(run);
1624
- return thenable;
1625
- }
1626
- };
1627
- }
1628
- //#endregion
1629
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/removable.js
1630
- var Removable = class {
1631
- #gcTimeout;
1632
- destroy() {
1633
- this.clearGcTimeout();
1634
- }
1635
- scheduleGc() {
1636
- this.clearGcTimeout();
1637
- if (isValidTimeout(this.gcTime)) this.#gcTimeout = timeoutManager.setTimeout(() => {
1638
- this.optionalRemove();
1639
- }, this.gcTime);
1640
- }
1641
- updateGcTime(newGcTime) {
1642
- this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (isServer ? Infinity : 3e5));
1643
- }
1644
- clearGcTimeout() {
1645
- if (this.#gcTimeout) {
1646
- timeoutManager.clearTimeout(this.#gcTimeout);
1647
- this.#gcTimeout = void 0;
1648
- }
1649
- }
1650
- };
1651
- //#endregion
1652
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/query.js
1653
- var Query = class extends Removable {
1654
- #initialState;
1655
- #revertState;
1656
- #cache;
1657
- #client;
1658
- #retryer;
1659
- #defaultOptions;
1660
- #abortSignalConsumed;
1661
- constructor(config) {
1662
- super();
1663
- this.#abortSignalConsumed = false;
1664
- this.#defaultOptions = config.defaultOptions;
1665
- this.setOptions(config.options);
1666
- this.observers = [];
1667
- this.#client = config.client;
1668
- this.#cache = this.#client.getQueryCache();
1669
- this.queryKey = config.queryKey;
1670
- this.queryHash = config.queryHash;
1671
- this.#initialState = getDefaultState$1(this.options);
1672
- this.state = config.state ?? this.#initialState;
1673
- this.scheduleGc();
1674
- }
1675
- get meta() {
1676
- return this.options.meta;
1677
- }
1678
- get promise() {
1679
- return this.#retryer?.promise;
1680
- }
1681
- setOptions(options) {
1682
- this.options = {
1683
- ...this.#defaultOptions,
1684
- ...options
1685
- };
1686
- this.updateGcTime(this.options.gcTime);
1687
- if (this.state && this.state.data === void 0) {
1688
- const defaultState = getDefaultState$1(this.options);
1689
- if (defaultState.data !== void 0) {
1690
- this.setState(successState(defaultState.data, defaultState.dataUpdatedAt));
1691
- this.#initialState = defaultState;
1692
- }
1693
- }
1694
- }
1695
- optionalRemove() {
1696
- if (!this.observers.length && this.state.fetchStatus === "idle") this.#cache.remove(this);
1697
- }
1698
- setData(newData, options) {
1699
- const data = replaceData(this.state.data, newData, this.options);
1700
- this.#dispatch({
1701
- data,
1702
- type: "success",
1703
- dataUpdatedAt: options?.updatedAt,
1704
- manual: options?.manual
1705
- });
1706
- return data;
1707
- }
1708
- setState(state, setStateOptions) {
1709
- this.#dispatch({
1710
- type: "setState",
1711
- state,
1712
- setStateOptions
1713
- });
1714
- }
1715
- cancel(options) {
1716
- const promise = this.#retryer?.promise;
1717
- this.#retryer?.cancel(options);
1718
- return promise ? promise.then(noop).catch(noop) : Promise.resolve();
1719
- }
1720
- destroy() {
1721
- super.destroy();
1722
- this.cancel({ silent: true });
1723
- }
1724
- reset() {
1725
- this.destroy();
1726
- this.setState(this.#initialState);
1727
- }
1728
- isActive() {
1729
- return this.observers.some((observer) => resolveEnabled(observer.options.enabled, this) !== false);
1730
- }
1731
- isDisabled() {
1732
- if (this.getObserversCount() > 0) return !this.isActive();
1733
- return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
1734
- }
1735
- isStatic() {
1736
- if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveStaleTime(observer.options.staleTime, this) === "static");
1737
- return false;
1738
- }
1739
- isStale() {
1740
- if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale);
1741
- return this.state.data === void 0 || this.state.isInvalidated;
1742
- }
1743
- isStaleByTime(staleTime = 0) {
1744
- if (this.state.data === void 0) return true;
1745
- if (staleTime === "static") return false;
1746
- if (this.state.isInvalidated) return true;
1747
- return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
1748
- }
1749
- onFocus() {
1750
- this.observers.find((x) => x.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: false });
1751
- this.#retryer?.continue();
1752
- }
1753
- onOnline() {
1754
- this.observers.find((x) => x.shouldFetchOnReconnect())?.refetch({ cancelRefetch: false });
1755
- this.#retryer?.continue();
1756
- }
1757
- addObserver(observer) {
1758
- if (!this.observers.includes(observer)) {
1759
- this.observers.push(observer);
1760
- this.clearGcTimeout();
1761
- this.#cache.notify({
1762
- type: "observerAdded",
1763
- query: this,
1764
- observer
1765
- });
1766
- }
1767
- }
1768
- removeObserver(observer) {
1769
- if (this.observers.includes(observer)) {
1770
- this.observers = this.observers.filter((x) => x !== observer);
1771
- if (!this.observers.length) {
1772
- if (this.#retryer) {
1773
- if (this.#abortSignalConsumed) this.#retryer.cancel({ revert: true });
1774
- else this.#retryer.cancelRetry();
1775
- }
1776
- this.scheduleGc();
1777
- }
1778
- this.#cache.notify({
1779
- type: "observerRemoved",
1780
- query: this,
1781
- observer
1782
- });
1783
- }
1784
- }
1785
- getObserversCount() {
1786
- return this.observers.length;
1787
- }
1788
- invalidate() {
1789
- if (!this.state.isInvalidated) this.#dispatch({ type: "invalidate" });
1790
- }
1791
- async fetch(options, fetchOptions) {
1792
- if (this.state.fetchStatus !== "idle" && this.#retryer?.status() !== "rejected") {
1793
- if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) this.cancel({ silent: true });
1794
- else if (this.#retryer) {
1795
- this.#retryer.continueRetry();
1796
- return this.#retryer.promise;
1797
- }
1798
- }
1799
- if (options) this.setOptions(options);
1800
- if (!this.options.queryFn) {
1801
- const observer = this.observers.find((x) => x.options.queryFn);
1802
- if (observer) this.setOptions(observer.options);
1803
- }
1804
- if (process.env.NODE_ENV !== "production") {
1805
- if (!Array.isArray(this.options.queryKey)) console.error(`As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`);
1806
- }
1807
- const abortController = new AbortController();
1808
- const addSignalProperty = (object) => {
1809
- Object.defineProperty(object, "signal", {
1810
- enumerable: true,
1811
- get: () => {
1812
- this.#abortSignalConsumed = true;
1813
- return abortController.signal;
1814
- }
1815
- });
1816
- };
1817
- const fetchFn = () => {
1818
- const queryFn = ensureQueryFn(this.options, fetchOptions);
1819
- const createQueryFnContext = () => {
1820
- const queryFnContext2 = {
1821
- client: this.#client,
1822
- queryKey: this.queryKey,
1823
- meta: this.meta
1824
- };
1825
- addSignalProperty(queryFnContext2);
1826
- return queryFnContext2;
1827
- };
1828
- const queryFnContext = createQueryFnContext();
1829
- this.#abortSignalConsumed = false;
1830
- if (this.options.persister) return this.options.persister(queryFn, queryFnContext, this);
1831
- return queryFn(queryFnContext);
1832
- };
1833
- const createFetchContext = () => {
1834
- const context2 = {
1835
- fetchOptions,
1836
- options: this.options,
1837
- queryKey: this.queryKey,
1838
- client: this.#client,
1839
- state: this.state,
1840
- fetchFn
1841
- };
1842
- addSignalProperty(context2);
1843
- return context2;
1844
- };
1845
- const context = createFetchContext();
1846
- this.options.behavior?.onFetch(context, this);
1847
- this.#revertState = this.state;
1848
- if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) this.#dispatch({
1849
- type: "fetch",
1850
- meta: context.fetchOptions?.meta
1851
- });
1852
- this.#retryer = createRetryer({
1853
- initialPromise: fetchOptions?.initialPromise,
1854
- fn: context.fetchFn,
1855
- onCancel: (error) => {
1856
- if (error instanceof CancelledError && error.revert) this.setState({
1857
- ...this.#revertState,
1858
- fetchStatus: "idle"
1859
- });
1860
- abortController.abort();
1861
- },
1862
- onFail: (failureCount, error) => {
1863
- this.#dispatch({
1864
- type: "failed",
1865
- failureCount,
1866
- error
1867
- });
1868
- },
1869
- onPause: () => {
1870
- this.#dispatch({ type: "pause" });
1871
- },
1872
- onContinue: () => {
1873
- this.#dispatch({ type: "continue" });
1874
- },
1875
- retry: context.options.retry,
1876
- retryDelay: context.options.retryDelay,
1877
- networkMode: context.options.networkMode,
1878
- canRun: () => true
1879
- });
1880
- try {
1881
- const data = await this.#retryer.start();
1882
- if (data === void 0) {
1883
- if (process.env.NODE_ENV !== "production") console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`);
1884
- throw new Error(`${this.queryHash} data is undefined`);
1885
- }
1886
- this.setData(data);
1887
- this.#cache.config.onSuccess?.(data, this);
1888
- this.#cache.config.onSettled?.(data, this.state.error, this);
1889
- return data;
1890
- } catch (error) {
1891
- if (error instanceof CancelledError) {
1892
- if (error.silent) return this.#retryer.promise;
1893
- else if (error.revert) {
1894
- if (this.state.data === void 0) throw error;
1895
- return this.state.data;
1896
- }
1897
- }
1898
- this.#dispatch({
1899
- type: "error",
1900
- error
1901
- });
1902
- this.#cache.config.onError?.(error, this);
1903
- this.#cache.config.onSettled?.(this.state.data, error, this);
1904
- throw error;
1905
- } finally {
1906
- this.scheduleGc();
1907
- }
1908
- }
1909
- #dispatch(action) {
1910
- const reducer = (state) => {
1911
- switch (action.type) {
1912
- case "failed": return {
1913
- ...state,
1914
- fetchFailureCount: action.failureCount,
1915
- fetchFailureReason: action.error
1916
- };
1917
- case "pause": return {
1918
- ...state,
1919
- fetchStatus: "paused"
1920
- };
1921
- case "continue": return {
1922
- ...state,
1923
- fetchStatus: "fetching"
1924
- };
1925
- case "fetch": return {
1926
- ...state,
1927
- ...fetchState(state.data, this.options),
1928
- fetchMeta: action.meta ?? null
1929
- };
1930
- case "success":
1931
- const newState = {
1932
- ...state,
1933
- ...successState(action.data, action.dataUpdatedAt),
1934
- dataUpdateCount: state.dataUpdateCount + 1,
1935
- ...!action.manual && {
1936
- fetchStatus: "idle",
1937
- fetchFailureCount: 0,
1938
- fetchFailureReason: null
1939
- }
1940
- };
1941
- this.#revertState = action.manual ? newState : void 0;
1942
- return newState;
1943
- case "error":
1944
- const error = action.error;
1945
- return {
1946
- ...state,
1947
- error,
1948
- errorUpdateCount: state.errorUpdateCount + 1,
1949
- errorUpdatedAt: Date.now(),
1950
- fetchFailureCount: state.fetchFailureCount + 1,
1951
- fetchFailureReason: error,
1952
- fetchStatus: "idle",
1953
- status: "error",
1954
- isInvalidated: true
1955
- };
1956
- case "invalidate": return {
1957
- ...state,
1958
- isInvalidated: true
1959
- };
1960
- case "setState": return {
1961
- ...state,
1962
- ...action.state
1963
- };
1964
- }
1965
- };
1966
- this.state = reducer(this.state);
1967
- notifyManager.batch(() => {
1968
- this.observers.forEach((observer) => {
1969
- observer.onQueryUpdate();
1970
- });
1971
- this.#cache.notify({
1972
- query: this,
1973
- type: "updated",
1974
- action
1975
- });
1976
- });
1977
- }
1978
- };
1979
- function fetchState(data, options) {
1980
- return {
1981
- fetchFailureCount: 0,
1982
- fetchFailureReason: null,
1983
- fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
1984
- ...data === void 0 && {
1985
- error: null,
1986
- status: "pending"
1987
- }
1988
- };
1989
- }
1990
- function successState(data, dataUpdatedAt) {
1991
- return {
1992
- data,
1993
- dataUpdatedAt: dataUpdatedAt ?? Date.now(),
1994
- error: null,
1995
- isInvalidated: false,
1996
- status: "success"
1997
- };
1998
- }
1999
- function getDefaultState$1(options) {
2000
- const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
2001
- const hasData = data !== void 0;
2002
- const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
2003
- return {
2004
- data,
2005
- dataUpdateCount: 0,
2006
- dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
2007
- error: null,
2008
- errorUpdateCount: 0,
2009
- errorUpdatedAt: 0,
2010
- fetchFailureCount: 0,
2011
- fetchFailureReason: null,
2012
- fetchMeta: null,
2013
- isInvalidated: false,
2014
- status: hasData ? "success" : "pending",
2015
- fetchStatus: "idle"
2016
- };
2017
- }
2018
- //#endregion
2019
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
2020
- function infiniteQueryBehavior(pages) {
2021
- return { onFetch: (context, query) => {
2022
- const options = context.options;
2023
- const direction = context.fetchOptions?.meta?.fetchMore?.direction;
2024
- const oldPages = context.state.data?.pages || [];
2025
- const oldPageParams = context.state.data?.pageParams || [];
2026
- let result = {
2027
- pages: [],
2028
- pageParams: []
2029
- };
2030
- let currentPage = 0;
2031
- const fetchFn = async () => {
2032
- let cancelled = false;
2033
- const addSignalProperty = (object) => {
2034
- addConsumeAwareSignal(object, () => context.signal, () => cancelled = true);
2035
- };
2036
- const queryFn = ensureQueryFn(context.options, context.fetchOptions);
2037
- const fetchPage = async (data, param, previous) => {
2038
- if (cancelled) return Promise.reject();
2039
- if (param == null && data.pages.length) return Promise.resolve(data);
2040
- const createQueryFnContext = () => {
2041
- const queryFnContext2 = {
2042
- client: context.client,
2043
- queryKey: context.queryKey,
2044
- pageParam: param,
2045
- direction: previous ? "backward" : "forward",
2046
- meta: context.options.meta
2047
- };
2048
- addSignalProperty(queryFnContext2);
2049
- return queryFnContext2;
2050
- };
2051
- const queryFnContext = createQueryFnContext();
2052
- const page = await queryFn(queryFnContext);
2053
- const { maxPages } = context.options;
2054
- const addTo = previous ? addToStart : addToEnd;
2055
- return {
2056
- pages: addTo(data.pages, page, maxPages),
2057
- pageParams: addTo(data.pageParams, param, maxPages)
2058
- };
2059
- };
2060
- if (direction && oldPages.length) {
2061
- const previous = direction === "backward";
2062
- const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
2063
- const oldData = {
2064
- pages: oldPages,
2065
- pageParams: oldPageParams
2066
- };
2067
- result = await fetchPage(oldData, pageParamFn(options, oldData), previous);
2068
- } else {
2069
- const remainingPages = pages ?? oldPages.length;
2070
- do {
2071
- const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
2072
- if (currentPage > 0 && param == null) break;
2073
- result = await fetchPage(result, param);
2074
- currentPage++;
2075
- } while (currentPage < remainingPages);
2076
- }
2077
- return result;
2078
- };
2079
- if (context.options.persister) context.fetchFn = () => {
2080
- return context.options.persister?.(fetchFn, {
2081
- client: context.client,
2082
- queryKey: context.queryKey,
2083
- meta: context.options.meta,
2084
- signal: context.signal
2085
- }, query);
2086
- };
2087
- else context.fetchFn = fetchFn;
2088
- } };
2089
- }
2090
- function getNextPageParam(options, { pages, pageParams }) {
2091
- const lastIndex = pages.length - 1;
2092
- return pages.length > 0 ? options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams) : void 0;
2093
- }
2094
- function getPreviousPageParam(options, { pages, pageParams }) {
2095
- return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
2096
- }
2097
- function hasNextPage(options, data) {
2098
- if (!data) return false;
2099
- return getNextPageParam(options, data) != null;
2100
- }
2101
- function hasPreviousPage(options, data) {
2102
- if (!data || !options.getPreviousPageParam) return false;
2103
- return getPreviousPageParam(options, data) != null;
2104
- }
2105
- //#endregion
2106
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutation.js
2107
- var Mutation = class extends Removable {
2108
- #client;
2109
- #observers;
2110
- #mutationCache;
2111
- #retryer;
2112
- constructor(config) {
2113
- super();
2114
- this.#client = config.client;
2115
- this.mutationId = config.mutationId;
2116
- this.#mutationCache = config.mutationCache;
2117
- this.#observers = [];
2118
- this.state = config.state || getDefaultState();
2119
- this.setOptions(config.options);
2120
- this.scheduleGc();
2121
- }
2122
- setOptions(options) {
2123
- this.options = options;
2124
- this.updateGcTime(this.options.gcTime);
2125
- }
2126
- get meta() {
2127
- return this.options.meta;
2128
- }
2129
- addObserver(observer) {
2130
- if (!this.#observers.includes(observer)) {
2131
- this.#observers.push(observer);
2132
- this.clearGcTimeout();
2133
- this.#mutationCache.notify({
2134
- type: "observerAdded",
2135
- mutation: this,
2136
- observer
2137
- });
2138
- }
2139
- }
2140
- removeObserver(observer) {
2141
- this.#observers = this.#observers.filter((x) => x !== observer);
2142
- this.scheduleGc();
2143
- this.#mutationCache.notify({
2144
- type: "observerRemoved",
2145
- mutation: this,
2146
- observer
2147
- });
2148
- }
2149
- optionalRemove() {
2150
- if (!this.#observers.length) {
2151
- if (this.state.status === "pending") this.scheduleGc();
2152
- else this.#mutationCache.remove(this);
2153
- }
2154
- }
2155
- continue() {
2156
- return this.#retryer?.continue() ?? this.execute(this.state.variables);
2157
- }
2158
- async execute(variables) {
2159
- const onContinue = () => {
2160
- this.#dispatch({ type: "continue" });
2161
- };
2162
- const mutationFnContext = {
2163
- client: this.#client,
2164
- meta: this.options.meta,
2165
- mutationKey: this.options.mutationKey
2166
- };
2167
- this.#retryer = createRetryer({
2168
- fn: () => {
2169
- if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found"));
2170
- return this.options.mutationFn(variables, mutationFnContext);
2171
- },
2172
- onFail: (failureCount, error) => {
2173
- this.#dispatch({
2174
- type: "failed",
2175
- failureCount,
2176
- error
2177
- });
2178
- },
2179
- onPause: () => {
2180
- this.#dispatch({ type: "pause" });
2181
- },
2182
- onContinue,
2183
- retry: this.options.retry ?? 0,
2184
- retryDelay: this.options.retryDelay,
2185
- networkMode: this.options.networkMode,
2186
- canRun: () => this.#mutationCache.canRun(this)
2187
- });
2188
- const restored = this.state.status === "pending";
2189
- const isPaused = !this.#retryer.canStart();
2190
- try {
2191
- if (restored) onContinue();
2192
- else {
2193
- this.#dispatch({
2194
- type: "pending",
2195
- variables,
2196
- isPaused
2197
- });
2198
- if (this.#mutationCache.config.onMutate) await this.#mutationCache.config.onMutate(variables, this, mutationFnContext);
2199
- const context = await this.options.onMutate?.(variables, mutationFnContext);
2200
- if (context !== this.state.context) this.#dispatch({
2201
- type: "pending",
2202
- context,
2203
- variables,
2204
- isPaused
2205
- });
2206
- }
2207
- const data = await this.#retryer.start();
2208
- await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext);
2209
- await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext);
2210
- await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext);
2211
- await this.options.onSettled?.(data, null, variables, this.state.context, mutationFnContext);
2212
- this.#dispatch({
2213
- type: "success",
2214
- data
2215
- });
2216
- return data;
2217
- } catch (error) {
2218
- try {
2219
- await this.#mutationCache.config.onError?.(error, variables, this.state.context, this, mutationFnContext);
2220
- } catch (e) {
2221
- Promise.reject(e);
2222
- }
2223
- try {
2224
- await this.options.onError?.(error, variables, this.state.context, mutationFnContext);
2225
- } catch (e) {
2226
- Promise.reject(e);
2227
- }
2228
- try {
2229
- await this.#mutationCache.config.onSettled?.(void 0, error, this.state.variables, this.state.context, this, mutationFnContext);
2230
- } catch (e) {
2231
- Promise.reject(e);
2232
- }
2233
- try {
2234
- await this.options.onSettled?.(void 0, error, variables, this.state.context, mutationFnContext);
2235
- } catch (e) {
2236
- Promise.reject(e);
2237
- }
2238
- this.#dispatch({
2239
- type: "error",
2240
- error
2241
- });
2242
- throw error;
2243
- } finally {
2244
- this.#mutationCache.runNext(this);
2245
- }
2246
- }
2247
- #dispatch(action) {
2248
- const reducer = (state) => {
2249
- switch (action.type) {
2250
- case "failed": return {
2251
- ...state,
2252
- failureCount: action.failureCount,
2253
- failureReason: action.error
2254
- };
2255
- case "pause": return {
2256
- ...state,
2257
- isPaused: true
2258
- };
2259
- case "continue": return {
2260
- ...state,
2261
- isPaused: false
2262
- };
2263
- case "pending": return {
2264
- ...state,
2265
- context: action.context,
2266
- data: void 0,
2267
- failureCount: 0,
2268
- failureReason: null,
2269
- error: null,
2270
- isPaused: action.isPaused,
2271
- status: "pending",
2272
- variables: action.variables,
2273
- submittedAt: Date.now()
2274
- };
2275
- case "success": return {
2276
- ...state,
2277
- data: action.data,
2278
- failureCount: 0,
2279
- failureReason: null,
2280
- error: null,
2281
- status: "success",
2282
- isPaused: false
2283
- };
2284
- case "error": return {
2285
- ...state,
2286
- data: void 0,
2287
- error: action.error,
2288
- failureCount: state.failureCount + 1,
2289
- failureReason: action.error,
2290
- isPaused: false,
2291
- status: "error"
2292
- };
2293
- }
2294
- };
2295
- this.state = reducer(this.state);
2296
- notifyManager.batch(() => {
2297
- this.#observers.forEach((observer) => {
2298
- observer.onMutationUpdate(action);
2299
- });
2300
- this.#mutationCache.notify({
2301
- mutation: this,
2302
- type: "updated",
2303
- action
2304
- });
2305
- });
2306
- }
2307
- };
2308
- function getDefaultState() {
2309
- return {
2310
- context: void 0,
2311
- data: void 0,
2312
- error: null,
2313
- failureCount: 0,
2314
- failureReason: null,
2315
- isPaused: false,
2316
- status: "idle",
2317
- variables: void 0,
2318
- submittedAt: 0
2319
- };
2320
- }
2321
- //#endregion
2322
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutationCache.js
2323
- var MutationCache = class extends Subscribable {
2324
- constructor(config = {}) {
2325
- super();
2326
- this.config = config;
2327
- this.#mutations = /* @__PURE__ */ new Set();
2328
- this.#scopes = /* @__PURE__ */ new Map();
2329
- this.#mutationId = 0;
2330
- }
2331
- #mutations;
2332
- #scopes;
2333
- #mutationId;
2334
- build(client, options, state) {
2335
- const mutation = new Mutation({
2336
- client,
2337
- mutationCache: this,
2338
- mutationId: ++this.#mutationId,
2339
- options: client.defaultMutationOptions(options),
2340
- state
2341
- });
2342
- this.add(mutation);
2343
- return mutation;
2344
- }
2345
- add(mutation) {
2346
- this.#mutations.add(mutation);
2347
- const scope = scopeFor(mutation);
2348
- if (typeof scope === "string") {
2349
- const scopedMutations = this.#scopes.get(scope);
2350
- if (scopedMutations) scopedMutations.push(mutation);
2351
- else this.#scopes.set(scope, [mutation]);
2352
- }
2353
- this.notify({
2354
- type: "added",
2355
- mutation
2356
- });
2357
- }
2358
- remove(mutation) {
2359
- if (this.#mutations.delete(mutation)) {
2360
- const scope = scopeFor(mutation);
2361
- if (typeof scope === "string") {
2362
- const scopedMutations = this.#scopes.get(scope);
2363
- if (scopedMutations) {
2364
- if (scopedMutations.length > 1) {
2365
- const index = scopedMutations.indexOf(mutation);
2366
- if (index !== -1) scopedMutations.splice(index, 1);
2367
- } else if (scopedMutations[0] === mutation) this.#scopes.delete(scope);
2368
- }
2369
- }
2370
- }
2371
- this.notify({
2372
- type: "removed",
2373
- mutation
2374
- });
2375
- }
2376
- canRun(mutation) {
2377
- const scope = scopeFor(mutation);
2378
- if (typeof scope === "string") {
2379
- const firstPendingMutation = this.#scopes.get(scope)?.find((m) => m.state.status === "pending");
2380
- return !firstPendingMutation || firstPendingMutation === mutation;
2381
- } else return true;
2382
- }
2383
- runNext(mutation) {
2384
- const scope = scopeFor(mutation);
2385
- if (typeof scope === "string") return (this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused))?.continue() ?? Promise.resolve();
2386
- else return Promise.resolve();
2387
- }
2388
- clear() {
2389
- notifyManager.batch(() => {
2390
- this.#mutations.forEach((mutation) => {
2391
- this.notify({
2392
- type: "removed",
2393
- mutation
2394
- });
2395
- });
2396
- this.#mutations.clear();
2397
- this.#scopes.clear();
2398
- });
2399
- }
2400
- getAll() {
2401
- return Array.from(this.#mutations);
2402
- }
2403
- find(filters) {
2404
- const defaultedFilters = {
2405
- exact: true,
2406
- ...filters
2407
- };
2408
- return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation));
2409
- }
2410
- findAll(filters = {}) {
2411
- return this.getAll().filter((mutation) => matchMutation(filters, mutation));
2412
- }
2413
- notify(event) {
2414
- notifyManager.batch(() => {
2415
- this.listeners.forEach((listener) => {
2416
- listener(event);
2417
- });
2418
- });
2419
- }
2420
- resumePausedMutations() {
2421
- const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
2422
- return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop))));
2423
- }
2424
- };
2425
- function scopeFor(mutation) {
2426
- return mutation.options.scope?.id;
2427
- }
2428
- //#endregion
2429
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryCache.js
2430
- var QueryCache = class extends Subscribable {
2431
- constructor(config = {}) {
2432
- super();
2433
- this.config = config;
2434
- this.#queries = /* @__PURE__ */ new Map();
2435
- }
2436
- #queries;
2437
- build(client, options, state) {
2438
- const queryKey = options.queryKey;
2439
- const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
2440
- let query = this.get(queryHash);
2441
- if (!query) {
2442
- query = new Query({
2443
- client,
2444
- queryKey,
2445
- queryHash,
2446
- options: client.defaultQueryOptions(options),
2447
- state,
2448
- defaultOptions: client.getQueryDefaults(queryKey)
2449
- });
2450
- this.add(query);
2451
- }
2452
- return query;
2453
- }
2454
- add(query) {
2455
- if (!this.#queries.has(query.queryHash)) {
2456
- this.#queries.set(query.queryHash, query);
2457
- this.notify({
2458
- type: "added",
2459
- query
2460
- });
2461
- }
2462
- }
2463
- remove(query) {
2464
- const queryInMap = this.#queries.get(query.queryHash);
2465
- if (queryInMap) {
2466
- query.destroy();
2467
- if (queryInMap === query) this.#queries.delete(query.queryHash);
2468
- this.notify({
2469
- type: "removed",
2470
- query
2471
- });
2472
- }
2473
- }
2474
- clear() {
2475
- notifyManager.batch(() => {
2476
- this.getAll().forEach((query) => {
2477
- this.remove(query);
2478
- });
2479
- });
2480
- }
2481
- get(queryHash) {
2482
- return this.#queries.get(queryHash);
2483
- }
2484
- getAll() {
2485
- return [...this.#queries.values()];
2486
- }
2487
- find(filters) {
2488
- const defaultedFilters = {
2489
- exact: true,
2490
- ...filters
2491
- };
2492
- return this.getAll().find((query) => matchQuery(defaultedFilters, query));
2493
- }
2494
- findAll(filters = {}) {
2495
- const queries = this.getAll();
2496
- return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
2497
- }
2498
- notify(event) {
2499
- notifyManager.batch(() => {
2500
- this.listeners.forEach((listener) => {
2501
- listener(event);
2502
- });
2503
- });
2504
- }
2505
- onFocus() {
2506
- notifyManager.batch(() => {
2507
- this.getAll().forEach((query) => {
2508
- query.onFocus();
2509
- });
2510
- });
2511
- }
2512
- onOnline() {
2513
- notifyManager.batch(() => {
2514
- this.getAll().forEach((query) => {
2515
- query.onOnline();
2516
- });
2517
- });
2518
- }
2519
- };
2520
- //#endregion
2521
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryClient.js
2522
- var QueryClient = class {
2523
- #queryCache;
2524
- #mutationCache;
2525
- #defaultOptions;
2526
- #queryDefaults;
2527
- #mutationDefaults;
2528
- #mountCount;
2529
- #unsubscribeFocus;
2530
- #unsubscribeOnline;
2531
- constructor(config = {}) {
2532
- this.#queryCache = config.queryCache || new QueryCache();
2533
- this.#mutationCache = config.mutationCache || new MutationCache();
2534
- this.#defaultOptions = config.defaultOptions || {};
2535
- this.#queryDefaults = /* @__PURE__ */ new Map();
2536
- this.#mutationDefaults = /* @__PURE__ */ new Map();
2537
- this.#mountCount = 0;
2538
- }
2539
- mount() {
2540
- this.#mountCount++;
2541
- if (this.#mountCount !== 1) return;
2542
- this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
2543
- if (focused) {
2544
- await this.resumePausedMutations();
2545
- this.#queryCache.onFocus();
2546
- }
2547
- });
2548
- this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
2549
- if (online) {
2550
- await this.resumePausedMutations();
2551
- this.#queryCache.onOnline();
2552
- }
2553
- });
2554
- }
2555
- unmount() {
2556
- this.#mountCount--;
2557
- if (this.#mountCount !== 0) return;
2558
- this.#unsubscribeFocus?.();
2559
- this.#unsubscribeFocus = void 0;
2560
- this.#unsubscribeOnline?.();
2561
- this.#unsubscribeOnline = void 0;
2562
- }
2563
- isFetching(filters) {
2564
- return this.#queryCache.findAll({
2565
- ...filters,
2566
- fetchStatus: "fetching"
2567
- }).length;
2568
- }
2569
- isMutating(filters) {
2570
- return this.#mutationCache.findAll({
2571
- ...filters,
2572
- status: "pending"
2573
- }).length;
2574
- }
2575
- /**
2576
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
2577
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
2578
- *
2579
- * Hint: Do not use this function inside a component, because it won't receive updates.
2580
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
2581
- */
2582
- getQueryData(queryKey) {
2583
- const options = this.defaultQueryOptions({ queryKey });
2584
- return this.#queryCache.get(options.queryHash)?.state.data;
2585
- }
2586
- ensureQueryData(options) {
2587
- const defaultedOptions = this.defaultQueryOptions(options);
2588
- const query = this.#queryCache.build(this, defaultedOptions);
2589
- const cachedData = query.state.data;
2590
- if (cachedData === void 0) return this.fetchQuery(options);
2591
- if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
2592
- return Promise.resolve(cachedData);
2593
- }
2594
- getQueriesData(filters) {
2595
- return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
2596
- return [queryKey, state.data];
2597
- });
2598
- }
2599
- setQueryData(queryKey, updater, options) {
2600
- const defaultedOptions = this.defaultQueryOptions({ queryKey });
2601
- const prevData = this.#queryCache.get(defaultedOptions.queryHash)?.state.data;
2602
- const data = functionalUpdate(updater, prevData);
2603
- if (data === void 0) return;
2604
- return this.#queryCache.build(this, defaultedOptions).setData(data, {
2605
- ...options,
2606
- manual: true
2607
- });
2608
- }
2609
- setQueriesData(filters, updater, options) {
2610
- return notifyManager.batch(() => this.#queryCache.findAll(filters).map(({ queryKey }) => [queryKey, this.setQueryData(queryKey, updater, options)]));
2611
- }
2612
- getQueryState(queryKey) {
2613
- const options = this.defaultQueryOptions({ queryKey });
2614
- return this.#queryCache.get(options.queryHash)?.state;
2615
- }
2616
- removeQueries(filters) {
2617
- const queryCache = this.#queryCache;
2618
- notifyManager.batch(() => {
2619
- queryCache.findAll(filters).forEach((query) => {
2620
- queryCache.remove(query);
2621
- });
2622
- });
2623
- }
2624
- resetQueries(filters, options) {
2625
- const queryCache = this.#queryCache;
2626
- return notifyManager.batch(() => {
2627
- queryCache.findAll(filters).forEach((query) => {
2628
- query.reset();
2629
- });
2630
- return this.refetchQueries({
2631
- type: "active",
2632
- ...filters
2633
- }, options);
2634
- });
2635
- }
2636
- cancelQueries(filters, cancelOptions = {}) {
2637
- const defaultedCancelOptions = {
2638
- revert: true,
2639
- ...cancelOptions
2640
- };
2641
- const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)));
2642
- return Promise.all(promises).then(noop).catch(noop);
2643
- }
2644
- invalidateQueries(filters, options = {}) {
2645
- return notifyManager.batch(() => {
2646
- this.#queryCache.findAll(filters).forEach((query) => {
2647
- query.invalidate();
2648
- });
2649
- if (filters?.refetchType === "none") return Promise.resolve();
2650
- return this.refetchQueries({
2651
- ...filters,
2652
- type: filters?.refetchType ?? filters?.type ?? "active"
2653
- }, options);
2654
- });
2655
- }
2656
- refetchQueries(filters, options = {}) {
2657
- const fetchOptions = {
2658
- ...options,
2659
- cancelRefetch: options.cancelRefetch ?? true
2660
- };
2661
- const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
2662
- let promise = query.fetch(void 0, fetchOptions);
2663
- if (!fetchOptions.throwOnError) promise = promise.catch(noop);
2664
- return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
2665
- }));
2666
- return Promise.all(promises).then(noop);
2667
- }
2668
- fetchQuery(options) {
2669
- const defaultedOptions = this.defaultQueryOptions(options);
2670
- if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
2671
- const query = this.#queryCache.build(this, defaultedOptions);
2672
- return query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
2673
- }
2674
- prefetchQuery(options) {
2675
- return this.fetchQuery(options).then(noop).catch(noop);
2676
- }
2677
- fetchInfiniteQuery(options) {
2678
- options.behavior = infiniteQueryBehavior(options.pages);
2679
- return this.fetchQuery(options);
2680
- }
2681
- prefetchInfiniteQuery(options) {
2682
- return this.fetchInfiniteQuery(options).then(noop).catch(noop);
2683
- }
2684
- ensureInfiniteQueryData(options) {
2685
- options.behavior = infiniteQueryBehavior(options.pages);
2686
- return this.ensureQueryData(options);
2687
- }
2688
- resumePausedMutations() {
2689
- if (onlineManager.isOnline()) return this.#mutationCache.resumePausedMutations();
2690
- return Promise.resolve();
2691
- }
2692
- getQueryCache() {
2693
- return this.#queryCache;
2694
- }
2695
- getMutationCache() {
2696
- return this.#mutationCache;
2697
- }
2698
- getDefaultOptions() {
2699
- return this.#defaultOptions;
2700
- }
2701
- setDefaultOptions(options) {
2702
- this.#defaultOptions = options;
2703
- }
2704
- setQueryDefaults(queryKey, options) {
2705
- this.#queryDefaults.set(hashKey(queryKey), {
2706
- queryKey,
2707
- defaultOptions: options
2708
- });
2709
- }
2710
- getQueryDefaults(queryKey) {
2711
- const defaults = [...this.#queryDefaults.values()];
2712
- const result = {};
2713
- defaults.forEach((queryDefault) => {
2714
- if (partialMatchKey(queryKey, queryDefault.queryKey)) Object.assign(result, queryDefault.defaultOptions);
2715
- });
2716
- return result;
2717
- }
2718
- setMutationDefaults(mutationKey, options) {
2719
- this.#mutationDefaults.set(hashKey(mutationKey), {
2720
- mutationKey,
2721
- defaultOptions: options
2722
- });
2723
- }
2724
- getMutationDefaults(mutationKey) {
2725
- const defaults = [...this.#mutationDefaults.values()];
2726
- const result = {};
2727
- defaults.forEach((queryDefault) => {
2728
- if (partialMatchKey(mutationKey, queryDefault.mutationKey)) Object.assign(result, queryDefault.defaultOptions);
2729
- });
2730
- return result;
2731
- }
2732
- defaultQueryOptions(options) {
2733
- if (options._defaulted) return options;
2734
- const defaultedOptions = {
2735
- ...this.#defaultOptions.queries,
2736
- ...this.getQueryDefaults(options.queryKey),
2737
- ...options,
2738
- _defaulted: true
2739
- };
2740
- if (!defaultedOptions.queryHash) defaultedOptions.queryHash = hashQueryKeyByOptions(defaultedOptions.queryKey, defaultedOptions);
2741
- if (defaultedOptions.refetchOnReconnect === void 0) defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
2742
- if (defaultedOptions.throwOnError === void 0) defaultedOptions.throwOnError = !!defaultedOptions.suspense;
2743
- if (!defaultedOptions.networkMode && defaultedOptions.persister) defaultedOptions.networkMode = "offlineFirst";
2744
- if (defaultedOptions.queryFn === skipToken) defaultedOptions.enabled = false;
2745
- return defaultedOptions;
2746
- }
2747
- defaultMutationOptions(options) {
2748
- if (options?._defaulted) return options;
2749
- return {
2750
- ...this.#defaultOptions.mutations,
2751
- ...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
2752
- ...options,
2753
- _defaulted: true
2754
- };
2755
- }
2756
- clear() {
2757
- this.#queryCache.clear();
2758
- this.#mutationCache.clear();
2759
- }
2760
- };
2761
- //#endregion
2762
- //#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/queryOptions.js
2763
- function queryOptions(options) {
2764
- return options;
2765
- }
2766
- //#endregion
2767
- //#region ../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/infiniteQueryOptions.js
2768
- function infiniteQueryOptions(options) {
2769
- return options;
2770
- }
2771
- //#endregion
2772
- //#region editors/workflow-editor/run-kinds.ts
2773
- const TEST_TRIGGER_KIND = "test";
2774
- function realRuns(runs) {
2775
- return runs.filter((run) => run.triggerKind !== TEST_TRIGGER_KIND);
2776
- }
2777
- //#endregion
2778
- //#region editors/workflow-editor/ui/query-keys.ts
2779
- function blockPart(block) {
2780
- return [
2781
- block.pieceName,
2782
- block.pieceVersion,
2783
- block.kind,
2784
- block.name
2785
- ];
2786
- }
2787
- function blockRefKey(block) {
2788
- return blockPart(block).join(" ");
2789
- }
2790
- function resolverKey(scope, kind, input) {
2791
- return [
2792
- scope,
2793
- kind,
2794
- blockPart(input.block),
2795
- input.propName,
2796
- input.refreshers,
2797
- input.connectionId ?? null,
2798
- input.searchValue ?? null,
2799
- input.reactorConnectionId ?? null
2800
- ];
2801
- }
2802
- const runtimeKeys = {
2803
- all: (scope) => [scope],
2804
- catalog: (scope) => [scope, "catalog"],
2805
- form: (scope, block) => [
2806
- scope,
2807
- "form",
2808
- blockPart(block)
2809
- ],
2810
- pieceActions: (scope, packageName) => [
2811
- scope,
2812
- "pieceActions",
2813
- packageName
2814
- ],
2815
- pieceTriggers: (scope, packageName) => [
2816
- scope,
2817
- "pieceTriggers",
2818
- packageName
2819
- ],
2820
- searchPieces: (scope, query, filter) => [
2821
- scope,
2822
- "searchPieces",
2823
- query,
2824
- filter
2825
- ],
2826
- outputTrees: (scope) => [scope, "outputTree"],
2827
- outputTree: (scope, block, config) => [
2828
- scope,
2829
- "outputTree",
2830
- blockPart(block),
2831
- config ?? {}
2832
- ],
2833
- stepOutputTree: (scope, workflowId, stepId, testedAt) => [
2834
- scope,
2835
- "outputTree",
2836
- "step",
2837
- workflowId,
2838
- stepId,
2839
- testedAt
2840
- ],
2841
- options: (scope, input) => resolverKey(scope, "options", input),
2842
- dynamic: (scope, input) => resolverKey(scope, "dynamic", input),
2843
- connections: (scope, filter) => filter === void 0 ? [scope, "connections"] : [
2844
- scope,
2845
- "connections",
2846
- filter
2847
- ],
2848
- webhook: (scope, workflowId) => [
2849
- scope,
2850
- "webhook",
2851
- workflowId
2852
- ],
2853
- latestRun: (scope, workflowId) => [
2854
- scope,
2855
- "latestRun",
2856
- workflowId
2857
- ],
2858
- allRuns: (scope) => [scope, "runs"],
2859
- runs: (scope, runsScope) => [
2860
- scope,
2861
- "runs",
2862
- {
2863
- workflowId: runsScope.workflowId ?? null,
2864
- driveId: runsScope.driveId ?? null,
2865
- limit: runsScope.limit ?? null
2866
- }
2867
- ],
2868
- runPages: (scope, runsScope) => [
2869
- scope,
2870
- "runs",
2871
- "pages",
2872
- {
2873
- workflowId: runsScope.workflowId ?? null,
2874
- driveId: runsScope.driveId ?? null,
2875
- limit: runsScope.limit ?? null
2876
- }
2877
- ],
2878
- waitingRuns: (scope, waiting) => [
2879
- scope,
2880
- "runs",
2881
- "waiting",
2882
- {
2883
- driveId: waiting.driveId ?? null,
2884
- workflowId: waiting.workflowId ?? null,
2885
- first: waiting.first ?? null
2886
- }
2887
- ],
2888
- run: (scope, runId) => [
2889
- scope,
2890
- "run",
2891
- runId
2892
- ],
2893
- reactorAccess: (scope, viewer) => [
2894
- scope,
2895
- "reactorAccess",
2896
- viewer
2897
- ],
2898
- reactorDenial: (scope, workflowId) => [
2899
- scope,
2900
- "reactorDenial",
2901
- workflowId
2902
- ],
2903
- secret: (scope, ref) => [
2904
- scope,
2905
- "secret",
2906
- ref
2907
- ],
2908
- allBlockResolutions: (scope, workflowId) => [
2909
- scope,
2910
- "blockResolutions",
2911
- workflowId
2912
- ],
2913
- blockResolutions: (scope, workflowId, blocks) => [
2914
- scope,
2915
- "blockResolutions",
2916
- workflowId,
2917
- blocks.map(blockPart)
2918
- ]
2919
- };
2920
- function queryKind(key) {
2921
- return typeof key[1] === "string" ? key[1] : void 0;
2922
- }
2923
- const SHARED_STALE_MS = 18e5;
2924
- const RESOLVER_STALE_MS = 3e5;
2925
- //#endregion
2926
- //#region editors/workflow-editor/runtime-queries.ts
2927
- function createRuntimeQueryClient() {
2928
- return new QueryClient({ defaultOptions: {
2929
- queries: {
2930
- retry: false,
2931
- refetchOnWindowFocus: false
2932
- },
2933
- mutations: { retry: false }
2934
- } });
2935
- }
2936
- const catalogQuery = (client) => queryOptions({
2937
- queryKey: runtimeKeys.catalog(client.url),
2938
- queryFn: () => client.fetchPieceCatalog(),
2939
- staleTime: SHARED_STALE_MS
2940
- });
2941
- const blockFormQuery = (client, block) => queryOptions({
2942
- queryKey: runtimeKeys.form(client.url, block),
2943
- queryFn: () => client.getBlockForm(block),
2944
- staleTime: SHARED_STALE_MS
2945
- });
2946
- const pieceActionsQuery = (client, packageName) => queryOptions({
2947
- queryKey: runtimeKeys.pieceActions(client.url, packageName),
2948
- queryFn: () => client.fetchPieceActions(packageName),
2949
- staleTime: SHARED_STALE_MS
2950
- });
2951
- const pieceTriggersQuery = (client, packageName) => queryOptions({
2952
- queryKey: runtimeKeys.pieceTriggers(client.url, packageName),
2953
- queryFn: () => client.fetchPieceTriggers(packageName),
2954
- staleTime: SHARED_STALE_MS
2955
- });
2956
- const outputTreeQuery = (client, block, config) => queryOptions({
2957
- queryKey: runtimeKeys.outputTree(client.url, block, config),
2958
- queryFn: () => client.fetchBlockOutputTree(block, config),
2959
- staleTime: Infinity
2960
- });
2961
- const stepOutputTreeQuery = (client, workflowId, stepId, testedAt) => queryOptions({
2962
- queryKey: runtimeKeys.stepOutputTree(client.url, workflowId, stepId, testedAt),
2963
- queryFn: () => client.fetchStepOutputTree(workflowId, stepId),
2964
- staleTime: Infinity
2965
- });
2966
- const REAL_RUNS = [TEST_TRIGGER_KIND];
2967
- const runsQuery = (client, scope) => queryOptions({
2968
- queryKey: runtimeKeys.runs(client.url, scope),
2969
- queryFn: () => client.fetchRuns({
2970
- ...scope,
2971
- excludeTriggerKinds: REAL_RUNS
2972
- }).then(realRuns),
2973
- staleTime: 0
2974
- });
2975
- const runPagesQuery = (client, scope) => infiniteQueryOptions({
2976
- queryKey: runtimeKeys.runPages(client.url, scope),
2977
- queryFn: ({ pageParam }) => client.fetchRunsPage({
2978
- ...scope,
2979
- excludeTriggerKinds: REAL_RUNS
2980
- }, pageParam),
2981
- initialPageParam: null,
2982
- getNextPageParam: (page) => page.hasNextPage && page.cursor ? page.cursor : void 0,
2983
- staleTime: 0
2984
- });
2985
- function runsOfPages(pages) {
2986
- const seen = /* @__PURE__ */ new Set();
2987
- return realRuns(pages.flatMap((page) => page.items)).filter((run) => {
2988
- if (seen.has(run.id)) return false;
2989
- seen.add(run.id);
2990
- return true;
2991
- });
2992
- }
2993
- const waitingRunsQuery = (client, scope) => queryOptions({
2994
- queryKey: runtimeKeys.waitingRuns(client.url, scope),
2995
- queryFn: () => client.fetchWaitingRuns(scope),
2996
- staleTime: 0
2997
- });
2998
- const FINISHED = /* @__PURE__ */ new Set([
2999
- "SUCCEEDED",
3000
- "FAILED",
3001
- "CANCELLED"
3002
- ]);
3003
- const runQuery = (client, runId) => queryOptions({
3004
- queryKey: runtimeKeys.run(client.url, runId),
3005
- queryFn: () => client.fetchRun(runId),
3006
- staleTime: (query) => query.state.data && FINISHED.has(query.state.data.status) ? Infinity : 0
3007
- });
3008
- const secretStatQuery = (client, ref) => queryOptions({
3009
- queryKey: runtimeKeys.secret(client.url, ref),
3010
- queryFn: () => client.fetchSecretStat(ref),
3011
- staleTime: 0
3012
- });
3013
- //#endregion
3014
- export { CALL_FLOW_BLOCK as $, isValidTimeout as A, isDocumentRefMarker as At, timeoutManager as B, hasPreviousPage as C, NEXT_PORT as Ct, pendingThenable as D, documentRefsIn as Dt, notifyManager as E, coerceManualPayload as Et, resolveEnabled as F, scheduleConfigIssue as Ft, fetchRun as G, DEFAULT_RUNTIME_URL as H, resolveStaleTime as I, stepPortLabel as It, isSyncingError as J, fetchRuns as K, shallowEqualObjects as L, stepPorts as Lt, noop as M, manualDefault as Mt, replaceData as N, parseManualInputs as Nt, focusManager as O, expandDocumentRefs as Ot, replaceEqualDeep as P, parseScheduleConfig as Pt, CALLABLE_FLOW_TRIGGER as Q, shouldThrowError as R, hasNextPage as S, ManualPayloadError as St, fetchState as T, checkTriggerStrategy as Tt, RuntimeRequestError as U, Subscribable as V, createRuntimeClient as W, ASSERT_BLOCK as X, APPROVAL_BLOCK as Y, BRANCH_BLOCK as Z, queryKind as _, stepFields as _t, pieceActionsQuery as a, RETURN_RESPONSE_BLOCK as at, realRuns as b, CORE_PIECE_NAME as bt, runQuery as c, STEP_PRESETS as ct, secretStatQuery as d, WAIT_FOR_WEBHOOK_BLOCK as dt, CORE_PIECE as et, stepOutputTreeQuery as f, WEBHOOK_TRIGGER as ft, blockRefKey as g, stepBlock as gt, SHARED_STALE_MS as h, sameBlock as ht, outputTreeQuery as i, REACTOR_PIECE as it, keepPreviousData as j, knownPorts as jt, isServer as k, flowPorts as kt, runsOfPages as l, STOP_BLOCK as lt, RESOLVER_STALE_MS as m, pinBlock as mt, catalogQuery as n, LOOP_BLOCK as nt, pieceTriggersQuery as o, ROUTER_BLOCK as ot, waitingRunsQuery as p, isCoreBlock as pt, fetchRunsPage as q, createRuntimeQueryClient as r, MANUAL_TRIGGER as rt, runPagesQuery as s, SCHEDULE_TRIGGER as st, blockFormQuery as t, DELAY_BLOCK as tt, runsQuery as u, TRIGGER_PRESETS as ut, runtimeKeys as v, triggerBlock as vt, infiniteQueryBehavior as w, SUBFLOWS_PIECE as wt, QueryClient as x, DOCUMENT_REF_KEY as xt, TEST_TRIGGER_KIND as y, triggerFields as yt, timeUntilStale as z };
3015
-
3016
- //# sourceMappingURL=runtime-queries-Ck5OoWdy.mjs.map