@powerhousedao/workflow 6.2.3-dev.69 → 6.2.3-dev.70

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