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