@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.
- package/dist/browser/BlockSelector-DFX-DZHl.js +3243 -0
- package/dist/browser/BlockSelector-DFX-DZHl.js.map +1 -0
- package/dist/browser/PieceMarkdown-U6OUTwRi.js +66 -0
- package/dist/browser/PieceMarkdown-U6OUTwRi.js.map +1 -0
- package/dist/browser/{connection-5ri_Ex8F.js → connection-Ci_pI3kD.js} +2 -2
- package/dist/browser/{connection-5ri_Ex8F.js.map → connection-Ci_pI3kD.js.map} +1 -1
- package/dist/browser/{connection-form-FoGRZSTT.js → connection-form-BuW6qOAF.js} +6 -5
- package/dist/browser/{connection-form-FoGRZSTT.js.map → connection-form-BuW6qOAF.js.map} +1 -1
- package/dist/browser/data-tree-BLn565V5.js +63 -0
- package/dist/browser/data-tree-BLn565V5.js.map +1 -0
- package/dist/browser/document-models/connection/index.js +2 -2
- package/dist/browser/document-models/index.js +3 -3
- package/dist/browser/document-models/workflow/index.js +2 -2
- package/dist/browser/{document-models-DAAo3Bln.js → document-models-B2IDRvBZ.js} +3 -3
- package/dist/browser/{document-models-DAAo3Bln.js.map → document-models-B2IDRvBZ.js.map} +1 -1
- package/dist/browser/{editor-ioEkaHLb.js → editor-B1-_KRbr.js} +10 -11
- package/dist/browser/{editor-ioEkaHLb.js.map → editor-B1-_KRbr.js.map} +1 -1
- package/dist/browser/editor-DBcq58Fr.js +6847 -0
- package/dist/browser/editor-DBcq58Fr.js.map +1 -0
- package/dist/browser/{editor-CX_SY6s_.js → editor-DPGuck1V.js} +8 -8
- package/dist/browser/editor-DPGuck1V.js.map +1 -0
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/connection-editor/module.js.map +1 -1
- package/dist/browser/editors/runtime/index.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js.map +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/index.js +5 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{module-DxQBeqBh.js → module-DFCANOuI.js} +3 -3
- package/dist/browser/{module-DxQBeqBh.js.map → module-DFCANOuI.js.map} +1 -1
- package/dist/browser/{module-DIQ3tQ2M.js → module-FuSfFXPT.js} +2 -2
- package/dist/browser/{module-DIQ3tQ2M.js.map → module-FuSfFXPT.js.map} +1 -1
- package/dist/browser/reactor/index.js +2 -2
- package/dist/browser/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/browser/runtime-queries-C9SoXGm2.js +791 -0
- package/dist/browser/runtime-queries-C9SoXGm2.js.map +1 -0
- package/dist/browser/trigger-text-B2mo1fiB.js +493 -0
- package/dist/browser/trigger-text-B2mo1fiB.js.map +1 -0
- package/dist/browser/upgrade-manifests-B62uqKVp.js +8 -0
- package/dist/browser/{upgrade-manifests-CAE3ivDp.js.map → upgrade-manifests-B62uqKVp.js.map} +1 -1
- package/dist/browser/{workflow-CP_X_Njm.js → workflow-DjTleFFO.js} +2 -2
- package/dist/browser/{workflow-CP_X_Njm.js.map → workflow-DjTleFFO.js.map} +1 -1
- package/dist/node/{BlockSelector-DfCL1GAk.mjs → BlockSelector-CF4xOFNG.mjs} +2 -2
- package/dist/node/{BlockSelector-DfCL1GAk.mjs.map → BlockSelector-CF4xOFNG.mjs.map} +1 -1
- package/dist/node/{PieceMarkdown-BMhBGa4t.mjs → PieceMarkdown-DwpCBISY.mjs} +2 -2
- package/dist/node/{PieceMarkdown-BMhBGa4t.mjs.map → PieceMarkdown-DwpCBISY.mjs.map} +1 -1
- package/dist/node/{connection-form-BbWKMBHt.mjs → connection-form-CYlSCGTK.mjs} +3 -3
- package/dist/node/{connection-form-BbWKMBHt.mjs.map → connection-form-CYlSCGTK.mjs.map} +1 -1
- package/dist/node/{connection-DJFsS9rQ.mjs → connection-i6ISRY0F.mjs} +2 -2
- package/dist/node/{connection-DJFsS9rQ.mjs.map → connection-i6ISRY0F.mjs.map} +1 -1
- package/dist/node/{data-tree-DAlZbha-.mjs → data-tree-DmhiI_Jk.mjs} +3 -3
- package/dist/node/{data-tree-DAlZbha-.mjs.map → data-tree-DmhiI_Jk.mjs.map} +1 -1
- package/dist/node/document-models/connection/index.mjs +2 -2
- package/dist/node/document-models/index.mjs +3 -3
- package/dist/node/document-models/workflow/index.mjs +2 -2
- package/dist/node/{editor-tHhPmmR_.mjs → editor-B653s9Xv.mjs} +15 -15
- package/dist/node/editor-B653s9Xv.mjs.map +1 -0
- package/dist/node/{editor-CAfTlm6l.mjs → editor-C6B1IKNB.mjs} +9 -10
- package/dist/node/{editor-CAfTlm6l.mjs.map → editor-C6B1IKNB.mjs.map} +1 -1
- package/dist/node/{editor-mRrsuvh4.mjs → editor-k8zOuO2n.mjs} +6 -6
- package/dist/node/editor-k8zOuO2n.mjs.map +1 -0
- package/dist/node/editors/connection-editor/module.mjs +1 -1
- package/dist/node/editors/connection-editor/module.mjs.map +1 -1
- package/dist/node/editors/workflow-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-editor/module.mjs.map +1 -1
- package/dist/node/editors/workflow-studio/module.mjs +1 -1
- package/dist/node/{graphql-BGVLRhC1.mjs → graphql-D76E1YiQ.mjs} +2 -2
- package/dist/node/{graphql-BGVLRhC1.mjs.map → graphql-D76E1YiQ.mjs.map} +1 -1
- package/dist/node/index.mjs +3 -3
- package/dist/node/{module-DPg8IYIn.mjs → module-DV3LLvxo.mjs} +2 -2
- package/dist/node/{module-DPg8IYIn.mjs.map → module-DV3LLvxo.mjs.map} +1 -1
- package/dist/node/{module-Bl_4mnxR.mjs → module-weVJEMpP.mjs} +2 -2
- package/dist/node/{module-Bl_4mnxR.mjs.map → module-weVJEMpP.mjs.map} +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/{browser/rolldown-runtime-DC62tzP2.js → node/rolldown-runtime-B4iAMlE-.mjs} +3 -1
- package/dist/node/trigger-text-D98Ip9qF.mjs +492 -0
- package/dist/node/trigger-text-D98Ip9qF.mjs.map +1 -0
- package/dist/node/upgrade-manifests-CO9zzPnE.mjs +8 -0
- package/dist/node/{upgrade-manifests-7SFwDrhd.mjs.map → upgrade-manifests-CO9zzPnE.mjs.map} +1 -1
- package/dist/node/{workflow-CPlqsc5D.mjs → workflow-BS5m4jtr.mjs} +2 -2
- package/dist/node/{workflow-CPlqsc5D.mjs.map → workflow-BS5m4jtr.mjs.map} +1 -1
- package/dist/powerhouse.manifest.json +1 -1
- package/dist/style.css +3 -2903
- package/dist/types/editors/connection-editor/editor.d.ts +3 -1
- package/dist/types/editors/connection-editor/editor.d.ts.map +1 -1
- package/dist/types/editors/connection-editor/module.d.ts +2 -1
- package/dist/types/editors/connection-editor/module.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/editor.d.ts +3 -1
- package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/module.d.ts +2 -1
- package/dist/types/editors/workflow-editor/module.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/browser/BlockSelector-BMI6RtS_.js +0 -8596
- package/dist/browser/BlockSelector-BMI6RtS_.js.map +0 -1
- package/dist/browser/PieceMarkdown-B8EEaQgT.js +0 -21435
- package/dist/browser/PieceMarkdown-B8EEaQgT.js.map +0 -1
- package/dist/browser/assets/entry-oIniX8Dq.js +0 -418
- package/dist/browser/assets/projection-entry-CdlLTrjU.js +0 -482
- package/dist/browser/block-type-kX-27vVt.js +0 -44
- package/dist/browser/block-type-kX-27vVt.js.map +0 -1
- package/dist/browser/data-tree-Bae8a2NP.js +0 -1896
- package/dist/browser/data-tree-Bae8a2NP.js.map +0 -1
- package/dist/browser/editor-CX_SY6s_.js.map +0 -1
- package/dist/browser/editor-DUtYefNU.js +0 -17626
- package/dist/browser/editor-DUtYefNU.js.map +0 -1
- package/dist/browser/graphql-Cr1ia6fo.js +0 -2474
- package/dist/browser/graphql-Cr1ia6fo.js.map +0 -1
- package/dist/browser/icon-components-CJ4I3Y6Y-DQj9fo1T.js +0 -3188
- package/dist/browser/icon-components-CJ4I3Y6Y-DQj9fo1T.js.map +0 -1
- package/dist/browser/runtime-queries-DehIdatq.js +0 -2615
- package/dist/browser/runtime-queries-DehIdatq.js.map +0 -1
- package/dist/browser/trigger-text-Cepiqt6x.js +0 -6131
- package/dist/browser/trigger-text-Cepiqt6x.js.map +0 -1
- package/dist/browser/upgrade-manifests-CAE3ivDp.js +0 -8
- package/dist/node/editor-mRrsuvh4.mjs.map +0 -1
- package/dist/node/editor-tHhPmmR_.mjs.map +0 -1
- package/dist/node/icon-components-CJ4I3Y6Y-DyXkyBjD.mjs +0 -3188
- package/dist/node/icon-components-CJ4I3Y6Y-DyXkyBjD.mjs.map +0 -1
- package/dist/node/rolldown-runtime-BMI-E3GI.mjs +0 -44
- package/dist/node/trigger-text-nrUcI93G.mjs +0 -7327
- package/dist/node/trigger-text-nrUcI93G.mjs.map +0 -1
- package/dist/node/upgrade-manifests-7SFwDrhd.mjs +0 -8
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
import { ambientRenownTokenProvider } from "@powerhousedao/reactor-browser/graphql-client";
|
|
2
|
+
import { blockKey } from "@powerhousedao/pieces-framework/block-type";
|
|
3
|
+
import { CORE_PIECE_NAME, checkTriggerStrategy } from "@powerhousedao/pieces-framework/workflow";
|
|
4
|
+
import { QueryClient, infiniteQueryOptions, queryOptions } from "@tanstack/react-query";
|
|
5
|
+
//#region editors/workflow-editor/ui/forms.ts
|
|
6
|
+
const POLL_INTERVAL_PROP = {
|
|
7
|
+
name: "pollEverySeconds",
|
|
8
|
+
displayName: "Poll every (seconds)",
|
|
9
|
+
type: "NUMBER",
|
|
10
|
+
required: false,
|
|
11
|
+
description: "How often the reactor checks this trigger; 60 at the least. Omit to follow the piece's own cadence."
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region editors/workflow-editor/ui/blocks.ts
|
|
15
|
+
const CORE_PIECE = CORE_PIECE_NAME;
|
|
16
|
+
const REACTOR_PIECE = "@powerhousedao/piece-reactor";
|
|
17
|
+
const core = (kind, name) => ({
|
|
18
|
+
pieceName: CORE_PIECE,
|
|
19
|
+
kind,
|
|
20
|
+
name
|
|
21
|
+
});
|
|
22
|
+
const MANUAL_TRIGGER = core("trigger", "manual");
|
|
23
|
+
const SCHEDULE_TRIGGER = core("trigger", "schedule");
|
|
24
|
+
const WEBHOOK_TRIGGER = core("trigger", "webhook");
|
|
25
|
+
const BRANCH_BLOCK = core("action", "branch");
|
|
26
|
+
const ASSERT_BLOCK = core("action", "assert");
|
|
27
|
+
function sameBlock(a, b) {
|
|
28
|
+
return Boolean(a && b && blockKey(a) === blockKey(b));
|
|
29
|
+
}
|
|
30
|
+
function isCoreBlock(block) {
|
|
31
|
+
return block.pieceName === CORE_PIECE;
|
|
32
|
+
}
|
|
33
|
+
function isReactorPieceBlock(block) {
|
|
34
|
+
return block.pieceName === REACTOR_PIECE;
|
|
35
|
+
}
|
|
36
|
+
function stepBlock(step) {
|
|
37
|
+
return {
|
|
38
|
+
pieceName: step.pieceName,
|
|
39
|
+
pieceVersion: step.pieceVersion,
|
|
40
|
+
kind: "action",
|
|
41
|
+
name: step.actionName
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function triggerBlock(trigger) {
|
|
45
|
+
return {
|
|
46
|
+
pieceName: trigger.pieceName,
|
|
47
|
+
pieceVersion: trigger.pieceVersion,
|
|
48
|
+
kind: "trigger",
|
|
49
|
+
name: trigger.triggerName
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function stepFields(block) {
|
|
53
|
+
return {
|
|
54
|
+
pieceName: block.pieceName,
|
|
55
|
+
pieceVersion: block.pieceVersion,
|
|
56
|
+
actionName: block.name
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function triggerFields(block) {
|
|
60
|
+
return {
|
|
61
|
+
pieceName: block.pieceName,
|
|
62
|
+
pieceVersion: block.pieceVersion,
|
|
63
|
+
triggerName: block.name
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function pinBlock(pick, installedVersion) {
|
|
67
|
+
const pieceVersion = pick.pieceVersion ?? installedVersion(pick.pieceName);
|
|
68
|
+
if (!pieceVersion) return void 0;
|
|
69
|
+
return {
|
|
70
|
+
pieceName: pick.pieceName,
|
|
71
|
+
pieceVersion,
|
|
72
|
+
kind: pick.kind,
|
|
73
|
+
name: pick.name
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const reactor = (kind, name) => ({
|
|
77
|
+
pieceName: REACTOR_PIECE,
|
|
78
|
+
kind,
|
|
79
|
+
name
|
|
80
|
+
});
|
|
81
|
+
const TRIGGER_PRESETS = [
|
|
82
|
+
{
|
|
83
|
+
label: "Manual",
|
|
84
|
+
block: MANUAL_TRIGGER,
|
|
85
|
+
group: "core",
|
|
86
|
+
description: "Fired on demand with a payload.",
|
|
87
|
+
defaultConfig: {}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: "Schedule",
|
|
91
|
+
block: SCHEDULE_TRIGGER,
|
|
92
|
+
group: "core",
|
|
93
|
+
description: "Fires on a cron expression or fixed interval.",
|
|
94
|
+
defaultConfig: {
|
|
95
|
+
mode: "cron",
|
|
96
|
+
cron: "0 9 * * 1-5",
|
|
97
|
+
timezone: "UTC"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: "Webhook",
|
|
102
|
+
block: WEBHOOK_TRIGGER,
|
|
103
|
+
group: "core",
|
|
104
|
+
description: "Fires when a provider POSTs to this workflow's URL.",
|
|
105
|
+
defaultConfig: {
|
|
106
|
+
methods: "POST",
|
|
107
|
+
scheme: "none",
|
|
108
|
+
responseMode: "async"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: "Document event",
|
|
113
|
+
block: reactor("trigger", "document-event"),
|
|
114
|
+
group: "powerhouse",
|
|
115
|
+
description: "Fires when a matching document operation lands.",
|
|
116
|
+
defaultConfig: {}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "Document created",
|
|
120
|
+
block: reactor("trigger", "document-created"),
|
|
121
|
+
group: "powerhouse",
|
|
122
|
+
description: "Fires when a document is added to a drive.",
|
|
123
|
+
defaultConfig: {}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: "Document deleted",
|
|
127
|
+
block: reactor("trigger", "document-deleted"),
|
|
128
|
+
group: "powerhouse",
|
|
129
|
+
description: "Fires when a document is removed from a drive.",
|
|
130
|
+
defaultConfig: {}
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
const STEP_PRESETS = [
|
|
134
|
+
{
|
|
135
|
+
label: "Branch",
|
|
136
|
+
block: BRANCH_BLOCK,
|
|
137
|
+
group: "core",
|
|
138
|
+
description: "Routes true/false on a condition.",
|
|
139
|
+
defaultConfig: {}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
label: "Assert",
|
|
143
|
+
block: ASSERT_BLOCK,
|
|
144
|
+
group: "core",
|
|
145
|
+
description: "Fails the run when a value is blank, rejected or not allowed.",
|
|
146
|
+
defaultConfig: {
|
|
147
|
+
value: "",
|
|
148
|
+
allowValues: []
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
label: "Create document",
|
|
153
|
+
block: reactor("action", "document-create"),
|
|
154
|
+
group: "powerhouse",
|
|
155
|
+
description: "Creates a Powerhouse document.",
|
|
156
|
+
defaultConfig: {
|
|
157
|
+
documentType: "",
|
|
158
|
+
name: ""
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: "Dispatch actions",
|
|
163
|
+
block: reactor("action", "document-dispatch"),
|
|
164
|
+
group: "powerhouse",
|
|
165
|
+
description: "Sends actions to a document.",
|
|
166
|
+
defaultConfig: { documentId: "" }
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: "Get document",
|
|
170
|
+
block: reactor("action", "document-get"),
|
|
171
|
+
group: "powerhouse",
|
|
172
|
+
description: "Reads a document's current state.",
|
|
173
|
+
defaultConfig: { documentId: "" }
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
label: "Find documents",
|
|
177
|
+
block: reactor("action", "document-find"),
|
|
178
|
+
group: "powerhouse",
|
|
179
|
+
description: "Lists documents by type and name.",
|
|
180
|
+
defaultConfig: { documentType: "" }
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
label: "List document types",
|
|
184
|
+
block: reactor("action", "document-types"),
|
|
185
|
+
group: "powerhouse",
|
|
186
|
+
description: "Document models installed on this reactor.",
|
|
187
|
+
defaultConfig: {}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: "Get document schema",
|
|
191
|
+
block: reactor("action", "document-schema"),
|
|
192
|
+
group: "powerhouse",
|
|
193
|
+
description: "Action and state schemas of a document type.",
|
|
194
|
+
defaultConfig: { documentType: "" }
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region editors/workflow-editor/runtime-client.ts
|
|
199
|
+
const DEFAULT_RUNTIME_URL = "http://localhost:4001/graphql/workflow-runtime";
|
|
200
|
+
function createTransport(url, options) {
|
|
201
|
+
const doFetch = options.fetch ?? ((input, init) => fetch(input, init));
|
|
202
|
+
const tokenOf = options.token ?? ambientRenownTokenProvider;
|
|
203
|
+
return {
|
|
204
|
+
url,
|
|
205
|
+
gql: (query, variables) => gql(url, doFetch, tokenOf, query, variables)
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
var RuntimeRequestError = class extends Error {
|
|
209
|
+
code;
|
|
210
|
+
constructor(message, code) {
|
|
211
|
+
super(message);
|
|
212
|
+
this.code = code;
|
|
213
|
+
this.name = "RuntimeRequestError";
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
function isSyncingError(error) {
|
|
217
|
+
return error instanceof RuntimeRequestError && error.code === "WORKFLOW_SYNCING";
|
|
218
|
+
}
|
|
219
|
+
async function gql(url, doFetch, tokenOf, query, variables) {
|
|
220
|
+
const token = await tokenOf();
|
|
221
|
+
const body = await (await doFetch(url, {
|
|
222
|
+
method: "POST",
|
|
223
|
+
headers: {
|
|
224
|
+
"content-type": "application/json",
|
|
225
|
+
...token ? { authorization: `Bearer ${token}` } : {}
|
|
226
|
+
},
|
|
227
|
+
body: JSON.stringify({
|
|
228
|
+
query,
|
|
229
|
+
variables
|
|
230
|
+
})
|
|
231
|
+
})).json();
|
|
232
|
+
const first = body.errors?.[0];
|
|
233
|
+
if (first) {
|
|
234
|
+
const code = first.extensions?.code;
|
|
235
|
+
throw new RuntimeRequestError(first.message, typeof code === "string" ? code : void 0);
|
|
236
|
+
}
|
|
237
|
+
if (!body.data) throw new Error("Empty GraphQL response");
|
|
238
|
+
return body.data;
|
|
239
|
+
}
|
|
240
|
+
function blockInput(block) {
|
|
241
|
+
return {
|
|
242
|
+
pieceName: block.pieceName,
|
|
243
|
+
pieceVersion: block.pieceVersion,
|
|
244
|
+
name: block.name,
|
|
245
|
+
kind: block.kind
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function getBlockForm(t, block) {
|
|
249
|
+
return t.gql(`query Descriptor($block: BlockInput!) {
|
|
250
|
+
workflowRuntime { blockDescriptor(block: $block) }
|
|
251
|
+
}`, { block: blockInput(block) }).then((data) => {
|
|
252
|
+
const descriptor = data.workflowRuntime.blockDescriptor;
|
|
253
|
+
const entry = descriptor?.action ?? descriptor?.trigger;
|
|
254
|
+
if (!descriptor || !entry) return null;
|
|
255
|
+
const strategy = !descriptor.action && Boolean(descriptor.trigger) ? checkTriggerStrategy(entry.strategy) : void 0;
|
|
256
|
+
if (strategy && "issue" in strategy) throw new Error(strategy.issue);
|
|
257
|
+
const delivery = strategy?.delivery;
|
|
258
|
+
const polled = delivery === "poll" && !isCoreBlock(block) && !isReactorPieceBlock(block);
|
|
259
|
+
const props = entry.props;
|
|
260
|
+
return {
|
|
261
|
+
title: isCoreBlock(block) ? entry.displayName : `${descriptor.displayName} · ${entry.displayName}`,
|
|
262
|
+
requireAuth: entry.requireAuth,
|
|
263
|
+
...entry.requireReactor === "read" || entry.requireReactor === "write" ? { requireReactor: entry.requireReactor } : {},
|
|
264
|
+
auth: !descriptor.auth ? "none" : entry.requireAuth ? "required" : "optional",
|
|
265
|
+
props: polled ? [...props, POLL_INTERVAL_PROP] : props,
|
|
266
|
+
...entry.ports ? { ports: entry.ports } : {},
|
|
267
|
+
...delivery ? { triggerDelivery: delivery } : {},
|
|
268
|
+
...entry.display ? { display: entry.display } : {},
|
|
269
|
+
...entry.description ? { description: entry.description } : {},
|
|
270
|
+
...entry.propertyGroups ? { propertyGroups: entry.propertyGroups } : {},
|
|
271
|
+
...entry.classification ? { classification: entry.classification } : {},
|
|
272
|
+
...entry.errorHandlingOptions ? { errorHandling: entry.errorHandlingOptions } : {}
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function atVersion(listing) {
|
|
277
|
+
return listing.entries.map((entry) => ({
|
|
278
|
+
...entry,
|
|
279
|
+
pieceName: listing.name,
|
|
280
|
+
pieceVersion: listing.version
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
function fetchPieceCatalog(t) {
|
|
284
|
+
return t.gql(`query Catalog { workflowRuntime { pieceCatalog } }`, {}).then((data) => data.workflowRuntime.pieceCatalog);
|
|
285
|
+
}
|
|
286
|
+
async function fetchPieceActions(t, packageName) {
|
|
287
|
+
const listing = (await t.gql(`query Actions($packageName: String!) {
|
|
288
|
+
workflowRuntime { pieceActions(packageName: $packageName) }
|
|
289
|
+
}`, { packageName })).workflowRuntime.pieceActions;
|
|
290
|
+
return atVersion({
|
|
291
|
+
...listing,
|
|
292
|
+
entries: listing.actions
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
async function fetchPieceTriggers(t, packageName) {
|
|
296
|
+
const listing = (await t.gql(`query Triggers($packageName: String!) {
|
|
297
|
+
workflowRuntime { pieceTriggers(packageName: $packageName) }
|
|
298
|
+
}`, { packageName })).workflowRuntime.pieceTriggers;
|
|
299
|
+
return atVersion({
|
|
300
|
+
...listing,
|
|
301
|
+
entries: listing.triggers
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
async function searchPieces(t, query, filter) {
|
|
305
|
+
return (await t.gql(`query SearchPieces($query: String!, $kind: String!, $sources: [String!], $categories: [String!], $limit: Int) {
|
|
306
|
+
workflowRuntime { searchPieces(query: $query, kind: $kind, sources: $sources, categories: $categories, limit: $limit) {
|
|
307
|
+
status indexedPieces error
|
|
308
|
+
pieces {
|
|
309
|
+
pieceName pieceVersion displayName description logoUrl categories source deprecated unsupported namedPiece
|
|
310
|
+
blocks { pieceName pieceVersion name pieceDisplayName logoUrl displayName description kind strategy unsupported }
|
|
311
|
+
}
|
|
312
|
+
} }
|
|
313
|
+
}`, {
|
|
314
|
+
query,
|
|
315
|
+
kind: filter.kind,
|
|
316
|
+
sources: filter.sources ?? null,
|
|
317
|
+
categories: filter.categories ?? null,
|
|
318
|
+
limit: filter.limit ?? null
|
|
319
|
+
})).workflowRuntime.searchPieces;
|
|
320
|
+
}
|
|
321
|
+
function fetchBlockOutputTree(t, block, config) {
|
|
322
|
+
return t.gql(`query OutputTree($block: BlockInput!, $config: Unknown) {
|
|
323
|
+
workflowRuntime { blockOutputTree(block: $block, config: $config) }
|
|
324
|
+
}`, {
|
|
325
|
+
block: blockInput(block),
|
|
326
|
+
config: config ?? {}
|
|
327
|
+
}).then((data) => data.workflowRuntime.blockOutputTree);
|
|
328
|
+
}
|
|
329
|
+
function fetchStepOutputTree(t, workflowId, stepId) {
|
|
330
|
+
return t.gql(`query StepOutputTree($workflowId: String!, $stepId: String!) {
|
|
331
|
+
workflowRuntime { stepOutputTree(workflowId: $workflowId, stepId: $stepId) }
|
|
332
|
+
}`, {
|
|
333
|
+
workflowId,
|
|
334
|
+
stepId
|
|
335
|
+
}).then((data) => data.workflowRuntime.stepOutputTree);
|
|
336
|
+
}
|
|
337
|
+
function fetchConnections(t) {
|
|
338
|
+
return t.gql(`query Connections { workflowRuntime { connections { id name connectorId authType status accountLabel } } }`, {}).then((data) => data.workflowRuntime.connections);
|
|
339
|
+
}
|
|
340
|
+
function checkConnection(t, connectionId) {
|
|
341
|
+
return t.gql(`mutation CheckConnection($connectionId: String!) {
|
|
342
|
+
workflowRuntime {
|
|
343
|
+
checkConnection(connectionId: $connectionId) {
|
|
344
|
+
ok
|
|
345
|
+
detail
|
|
346
|
+
accountLabel
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}`, { connectionId }).then((data) => data.workflowRuntime.checkConnection);
|
|
350
|
+
}
|
|
351
|
+
function fetchReactorAccess(t) {
|
|
352
|
+
return t.gql(`query ReactorAccess {
|
|
353
|
+
workflowRuntime { authEnforcement reactorIdentity { address key } authConditions }
|
|
354
|
+
}`, {}).then((data) => data.workflowRuntime);
|
|
355
|
+
}
|
|
356
|
+
function fetchReactorAccessDenial(t, workflowId) {
|
|
357
|
+
return t.gql(`query ReactorAccessDenial($workflowId: String!) {
|
|
358
|
+
workflowRuntime { reactorAccessDenial(workflowId: $workflowId) }
|
|
359
|
+
}`, { workflowId }).then((data) => data.workflowRuntime.reactorAccessDenial);
|
|
360
|
+
}
|
|
361
|
+
async function fetchOAuthRedirectUri(t) {
|
|
362
|
+
const uri = (await t.gql(`query OAuthRedirectUri { workflowRuntime { oauthRedirectUri } }`, {})).workflowRuntime.oauthRedirectUri;
|
|
363
|
+
return uri === null ? null : new URL(uri, t.url).href;
|
|
364
|
+
}
|
|
365
|
+
async function startOAuth(t, connectionId, options = {}) {
|
|
366
|
+
return (await t.gql(`mutation StartOAuth($connectionId: String!, $redirectUri: String, $returnUrl: String) {
|
|
367
|
+
workflowRuntime {
|
|
368
|
+
startOAuth(connectionId: $connectionId, redirectUri: $redirectUri, returnUrl: $returnUrl) {
|
|
369
|
+
state authorizationUrl redirectUri expiresAt
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}`, {
|
|
373
|
+
connectionId,
|
|
374
|
+
redirectUri: options.redirectUri ?? null,
|
|
375
|
+
returnUrl: options.returnUrl ?? null
|
|
376
|
+
})).workflowRuntime.startOAuth;
|
|
377
|
+
}
|
|
378
|
+
async function fetchOAuthAttempt(t, state) {
|
|
379
|
+
return (await t.gql(`query OAuthAttempt($state: String!) {
|
|
380
|
+
workflowRuntime { oauthAttempt(state: $state) { connectionId status error } }
|
|
381
|
+
}`, { state })).workflowRuntime.oauthAttempt;
|
|
382
|
+
}
|
|
383
|
+
const SECRET_FIELDS = "ref label version status createdAt updatedAt";
|
|
384
|
+
async function createSecret(t, value, label) {
|
|
385
|
+
return (await t.gql(`mutation CreateSecret($value: String!, $label: String) {
|
|
386
|
+
workflowRuntime { createSecret(value: $value, label: $label) { ${SECRET_FIELDS} } }
|
|
387
|
+
}`, {
|
|
388
|
+
value,
|
|
389
|
+
label: label ?? null
|
|
390
|
+
})).workflowRuntime.createSecret;
|
|
391
|
+
}
|
|
392
|
+
async function rotateSecret(t, ref, value) {
|
|
393
|
+
return (await t.gql(`mutation RotateSecret($ref: String!, $value: String!) {
|
|
394
|
+
workflowRuntime { rotateSecret(ref: $ref, value: $value) { ${SECRET_FIELDS} } }
|
|
395
|
+
}`, {
|
|
396
|
+
ref,
|
|
397
|
+
value
|
|
398
|
+
})).workflowRuntime.rotateSecret;
|
|
399
|
+
}
|
|
400
|
+
async function fetchSecretStat(t, ref) {
|
|
401
|
+
return (await t.gql(`query Secret($ref: String!) {
|
|
402
|
+
workflowRuntime { secret(ref: $ref) { ${SECRET_FIELDS} } }
|
|
403
|
+
}`, { ref })).workflowRuntime.secret;
|
|
404
|
+
}
|
|
405
|
+
async function fetchWebhookEndpoint(t, workflowId, driveId) {
|
|
406
|
+
return (await t.gql(`query WebhookEndpoint($workflowId: String!, $driveId: String) {
|
|
407
|
+
workflowRuntime {
|
|
408
|
+
webhookEndpoint(workflowId: $workflowId, driveId: $driveId) {
|
|
409
|
+
workflowId url absoluteUrl armed createdAt
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}`, {
|
|
413
|
+
workflowId,
|
|
414
|
+
driveId: driveId ?? null
|
|
415
|
+
})).workflowRuntime.webhookEndpoint;
|
|
416
|
+
}
|
|
417
|
+
async function testTrigger(t, workflowId, driveId) {
|
|
418
|
+
return (await t.gql(`mutation TestTrigger($workflowId: String!, $driveId: String) {
|
|
419
|
+
workflowRuntime { testTrigger(workflowId: $workflowId, driveId: $driveId) }
|
|
420
|
+
}`, {
|
|
421
|
+
workflowId,
|
|
422
|
+
driveId: driveId ?? null
|
|
423
|
+
})).workflowRuntime.testTrigger;
|
|
424
|
+
}
|
|
425
|
+
async function testCoreTrigger(t, workflowId, options = {}) {
|
|
426
|
+
return (await t.gql(`mutation TestCoreTrigger($workflowId: String!, $payload: Unknown, $timeoutSeconds: Int, $driveId: String) {
|
|
427
|
+
workflowRuntime {
|
|
428
|
+
testTrigger(workflowId: $workflowId, payload: $payload, timeoutSeconds: $timeoutSeconds, driveId: $driveId)
|
|
429
|
+
}
|
|
430
|
+
}`, {
|
|
431
|
+
workflowId,
|
|
432
|
+
payload: options.payload ?? null,
|
|
433
|
+
timeoutSeconds: options.timeoutSeconds ?? null,
|
|
434
|
+
driveId: options.driveId ?? null
|
|
435
|
+
})).workflowRuntime.testTrigger;
|
|
436
|
+
}
|
|
437
|
+
async function cancelTriggerTest(t, workflowId) {
|
|
438
|
+
return (await t.gql(`mutation CancelTriggerTest($workflowId: String!) {
|
|
439
|
+
workflowRuntime { cancelTriggerTest(workflowId: $workflowId) }
|
|
440
|
+
}`, { workflowId })).workflowRuntime.cancelTriggerTest;
|
|
441
|
+
}
|
|
442
|
+
async function testStep(t, workflowId, stepId, driveId) {
|
|
443
|
+
return (await t.gql(`mutation TestStep($workflowId: String!, $stepId: String!, $driveId: String) {
|
|
444
|
+
workflowRuntime {
|
|
445
|
+
testStep(workflowId: $workflowId, stepId: $stepId, driveId: $driveId) {
|
|
446
|
+
runId status output error errorName durationMs
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}`, {
|
|
450
|
+
workflowId,
|
|
451
|
+
stepId,
|
|
452
|
+
driveId: driveId ?? null
|
|
453
|
+
})).workflowRuntime.testStep;
|
|
454
|
+
}
|
|
455
|
+
async function blockResolutions(t, workflowId) {
|
|
456
|
+
return (await t.gql(`query BlockResolutions($workflowId: String!) {
|
|
457
|
+
workflowRuntime {
|
|
458
|
+
blockResolutions(workflowId: $workflowId) {
|
|
459
|
+
stepId pieceName pieceVersion name kind resolvedVersion source match note latestVersion
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}`, { workflowId })).workflowRuntime.blockResolutions;
|
|
463
|
+
}
|
|
464
|
+
const RUN_ROW_FIELDS = `id workflowId workflowName workflowVersion triggerKind
|
|
465
|
+
triggerPayload status error errorName startedAt endedAt rerunOf warningNotes`;
|
|
466
|
+
const STEP_ROW_FIELDS = "stepId stepKey pieceName blockName status port error errorName startedAt endedAt";
|
|
467
|
+
const RUN_FIELDS = `${RUN_ROW_FIELDS} steps { ${STEP_ROW_FIELDS} input output }`;
|
|
468
|
+
const RUN_LIST_FIELDS = `${RUN_ROW_FIELDS} steps { ${STEP_ROW_FIELDS} }`;
|
|
469
|
+
function scopeVariables(scope, limit) {
|
|
470
|
+
return {
|
|
471
|
+
workflowId: scope.workflowId ?? null,
|
|
472
|
+
driveId: scope.driveId ?? null,
|
|
473
|
+
excludeTriggerKinds: scope.excludeTriggerKinds ?? null,
|
|
474
|
+
limit: scope.limit ?? limit
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
async function fetchRuns(t, scope = {}) {
|
|
478
|
+
return (await t.gql(`query Runs($workflowId: String, $driveId: String, $limit: Int, $excludeTriggerKinds: [String!]) {
|
|
479
|
+
workflowRuntime { runs(workflowId: $workflowId, driveId: $driveId, limit: $limit, excludeTriggerKinds: $excludeTriggerKinds) { ${RUN_FIELDS} } }
|
|
480
|
+
}`, scopeVariables(scope, 30))).workflowRuntime.runs;
|
|
481
|
+
}
|
|
482
|
+
async function fetchRunsPage(t, scope = {}, cursor = null) {
|
|
483
|
+
const { limit, ...rest } = scopeVariables(scope, 30);
|
|
484
|
+
return (await t.gql(`query RunsPage($workflowId: String, $driveId: String, $excludeTriggerKinds: [String!], $paging: WorkflowRunsPagingInput) {
|
|
485
|
+
workflowRuntime {
|
|
486
|
+
runsPage(workflowId: $workflowId, driveId: $driveId, excludeTriggerKinds: $excludeTriggerKinds, paging: $paging) {
|
|
487
|
+
items { ${RUN_LIST_FIELDS} } hasNextPage cursor
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}`, {
|
|
491
|
+
...rest,
|
|
492
|
+
paging: {
|
|
493
|
+
limit,
|
|
494
|
+
cursor
|
|
495
|
+
}
|
|
496
|
+
})).workflowRuntime.runsPage;
|
|
497
|
+
}
|
|
498
|
+
async function fetchRun(t, runId) {
|
|
499
|
+
return (await t.gql(`query Run($id: String!) { workflowRuntime { run(id: $id) { ${RUN_FIELDS} } } }`, { id: runId })).workflowRuntime.run;
|
|
500
|
+
}
|
|
501
|
+
async function fireWorkflow(t, workflowId, payload) {
|
|
502
|
+
return (await t.gql(`mutation Fire($workflowId: String!, $payload: Unknown) {
|
|
503
|
+
workflowRuntime { fire(workflowId: $workflowId, payload: $payload) { runId status error } }
|
|
504
|
+
}`, {
|
|
505
|
+
workflowId,
|
|
506
|
+
payload: payload ?? {}
|
|
507
|
+
})).workflowRuntime.fire;
|
|
508
|
+
}
|
|
509
|
+
async function rerunRun(t, runId) {
|
|
510
|
+
return (await t.gql(`mutation Rerun($runId: String!) {
|
|
511
|
+
workflowRuntime { rerun(runId: $runId) { runId status error } }
|
|
512
|
+
}`, { runId })).workflowRuntime.rerun;
|
|
513
|
+
}
|
|
514
|
+
async function loadBlockOptions(t, block, propName, input, connectionId, searchValue, reactorConnectionId) {
|
|
515
|
+
return (await t.gql(`query Options($block: BlockInput!, $propName: String!, $input: Unknown, $connectionId: String, $searchValue: String, $reactorConnectionId: String) {
|
|
516
|
+
workflowRuntime { blockOptions(block: $block, propName: $propName, input: $input, connectionId: $connectionId, searchValue: $searchValue, reactorConnectionId: $reactorConnectionId) }
|
|
517
|
+
}`, {
|
|
518
|
+
block: blockInput(block),
|
|
519
|
+
propName,
|
|
520
|
+
input,
|
|
521
|
+
connectionId: connectionId ?? null,
|
|
522
|
+
searchValue: searchValue ?? null,
|
|
523
|
+
reactorConnectionId: reactorConnectionId ?? null
|
|
524
|
+
})).workflowRuntime.blockOptions;
|
|
525
|
+
}
|
|
526
|
+
const operations = {
|
|
527
|
+
getBlockForm,
|
|
528
|
+
fetchPieceCatalog,
|
|
529
|
+
fetchPieceActions,
|
|
530
|
+
fetchPieceTriggers,
|
|
531
|
+
searchPieces,
|
|
532
|
+
fetchBlockOutputTree,
|
|
533
|
+
fetchStepOutputTree,
|
|
534
|
+
fetchConnections,
|
|
535
|
+
checkConnection,
|
|
536
|
+
fetchReactorAccess,
|
|
537
|
+
fetchReactorAccessDenial,
|
|
538
|
+
fetchOAuthRedirectUri,
|
|
539
|
+
startOAuth,
|
|
540
|
+
fetchOAuthAttempt,
|
|
541
|
+
createSecret,
|
|
542
|
+
rotateSecret,
|
|
543
|
+
fetchSecretStat,
|
|
544
|
+
fetchWebhookEndpoint,
|
|
545
|
+
testTrigger,
|
|
546
|
+
testCoreTrigger,
|
|
547
|
+
cancelTriggerTest,
|
|
548
|
+
testStep,
|
|
549
|
+
blockResolutions,
|
|
550
|
+
fetchRuns,
|
|
551
|
+
fetchRunsPage,
|
|
552
|
+
fetchRun,
|
|
553
|
+
fireWorkflow,
|
|
554
|
+
rerunRun,
|
|
555
|
+
loadBlockOptions
|
|
556
|
+
};
|
|
557
|
+
function createRuntimeClient(url, options = {}) {
|
|
558
|
+
const transport = createTransport(url, options);
|
|
559
|
+
const bound = Object.fromEntries(Object.entries(operations).map(([name, operation]) => [name, (...args) => operation(transport, ...args)]));
|
|
560
|
+
return {
|
|
561
|
+
...transport,
|
|
562
|
+
...bound
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region editors/workflow-editor/run-kinds.ts
|
|
567
|
+
const TEST_TRIGGER_KIND = "test";
|
|
568
|
+
function realRuns(runs) {
|
|
569
|
+
return runs.filter((run) => run.triggerKind !== TEST_TRIGGER_KIND);
|
|
570
|
+
}
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region editors/workflow-editor/ui/query-keys.ts
|
|
573
|
+
function blockPart(block) {
|
|
574
|
+
return [
|
|
575
|
+
block.pieceName,
|
|
576
|
+
block.pieceVersion,
|
|
577
|
+
block.kind,
|
|
578
|
+
block.name
|
|
579
|
+
];
|
|
580
|
+
}
|
|
581
|
+
function blockRefKey(block) {
|
|
582
|
+
return blockPart(block).join(" ");
|
|
583
|
+
}
|
|
584
|
+
function resolverKey(scope, kind, input) {
|
|
585
|
+
return [
|
|
586
|
+
scope,
|
|
587
|
+
kind,
|
|
588
|
+
blockPart(input.block),
|
|
589
|
+
input.propName,
|
|
590
|
+
input.refreshers,
|
|
591
|
+
input.connectionId ?? null,
|
|
592
|
+
input.searchValue ?? null,
|
|
593
|
+
input.reactorConnectionId ?? null
|
|
594
|
+
];
|
|
595
|
+
}
|
|
596
|
+
const runtimeKeys = {
|
|
597
|
+
all: (scope) => [scope],
|
|
598
|
+
catalog: (scope) => [scope, "catalog"],
|
|
599
|
+
form: (scope, block) => [
|
|
600
|
+
scope,
|
|
601
|
+
"form",
|
|
602
|
+
blockPart(block)
|
|
603
|
+
],
|
|
604
|
+
pieceActions: (scope, packageName) => [
|
|
605
|
+
scope,
|
|
606
|
+
"pieceActions",
|
|
607
|
+
packageName
|
|
608
|
+
],
|
|
609
|
+
pieceTriggers: (scope, packageName) => [
|
|
610
|
+
scope,
|
|
611
|
+
"pieceTriggers",
|
|
612
|
+
packageName
|
|
613
|
+
],
|
|
614
|
+
searchPieces: (scope, query, filter) => [
|
|
615
|
+
scope,
|
|
616
|
+
"searchPieces",
|
|
617
|
+
query,
|
|
618
|
+
filter
|
|
619
|
+
],
|
|
620
|
+
outputTrees: (scope) => [scope, "outputTree"],
|
|
621
|
+
outputTree: (scope, block, config) => [
|
|
622
|
+
scope,
|
|
623
|
+
"outputTree",
|
|
624
|
+
blockPart(block),
|
|
625
|
+
config ?? {}
|
|
626
|
+
],
|
|
627
|
+
stepOutputTree: (scope, workflowId, stepId, testedAt) => [
|
|
628
|
+
scope,
|
|
629
|
+
"outputTree",
|
|
630
|
+
"step",
|
|
631
|
+
workflowId,
|
|
632
|
+
stepId,
|
|
633
|
+
testedAt
|
|
634
|
+
],
|
|
635
|
+
options: (scope, input) => resolverKey(scope, "options", input),
|
|
636
|
+
dynamic: (scope, input) => resolverKey(scope, "dynamic", input),
|
|
637
|
+
connections: (scope, filter) => filter === void 0 ? [scope, "connections"] : [
|
|
638
|
+
scope,
|
|
639
|
+
"connections",
|
|
640
|
+
filter
|
|
641
|
+
],
|
|
642
|
+
webhook: (scope, workflowId) => [
|
|
643
|
+
scope,
|
|
644
|
+
"webhook",
|
|
645
|
+
workflowId
|
|
646
|
+
],
|
|
647
|
+
latestRun: (scope, workflowId) => [
|
|
648
|
+
scope,
|
|
649
|
+
"latestRun",
|
|
650
|
+
workflowId
|
|
651
|
+
],
|
|
652
|
+
allRuns: (scope) => [scope, "runs"],
|
|
653
|
+
runs: (scope, runsScope) => [
|
|
654
|
+
scope,
|
|
655
|
+
"runs",
|
|
656
|
+
{
|
|
657
|
+
workflowId: runsScope.workflowId ?? null,
|
|
658
|
+
driveId: runsScope.driveId ?? null,
|
|
659
|
+
limit: runsScope.limit ?? null
|
|
660
|
+
}
|
|
661
|
+
],
|
|
662
|
+
runPages: (scope, runsScope) => [
|
|
663
|
+
scope,
|
|
664
|
+
"runs",
|
|
665
|
+
"pages",
|
|
666
|
+
{
|
|
667
|
+
workflowId: runsScope.workflowId ?? null,
|
|
668
|
+
driveId: runsScope.driveId ?? null,
|
|
669
|
+
limit: runsScope.limit ?? null
|
|
670
|
+
}
|
|
671
|
+
],
|
|
672
|
+
run: (scope, runId) => [
|
|
673
|
+
scope,
|
|
674
|
+
"run",
|
|
675
|
+
runId
|
|
676
|
+
],
|
|
677
|
+
reactorAccess: (scope, viewer) => [
|
|
678
|
+
scope,
|
|
679
|
+
"reactorAccess",
|
|
680
|
+
viewer
|
|
681
|
+
],
|
|
682
|
+
reactorDenial: (scope, workflowId) => [
|
|
683
|
+
scope,
|
|
684
|
+
"reactorDenial",
|
|
685
|
+
workflowId
|
|
686
|
+
],
|
|
687
|
+
secret: (scope, ref) => [
|
|
688
|
+
scope,
|
|
689
|
+
"secret",
|
|
690
|
+
ref
|
|
691
|
+
],
|
|
692
|
+
allBlockResolutions: (scope, workflowId) => [
|
|
693
|
+
scope,
|
|
694
|
+
"blockResolutions",
|
|
695
|
+
workflowId
|
|
696
|
+
],
|
|
697
|
+
blockResolutions: (scope, workflowId, blocks) => [
|
|
698
|
+
scope,
|
|
699
|
+
"blockResolutions",
|
|
700
|
+
workflowId,
|
|
701
|
+
blocks.map(blockPart)
|
|
702
|
+
]
|
|
703
|
+
};
|
|
704
|
+
function queryKind(key) {
|
|
705
|
+
return typeof key[1] === "string" ? key[1] : void 0;
|
|
706
|
+
}
|
|
707
|
+
const SHARED_STALE_MS = 18e5;
|
|
708
|
+
const RESOLVER_STALE_MS = 3e5;
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region editors/workflow-editor/runtime-queries.ts
|
|
711
|
+
function createRuntimeQueryClient() {
|
|
712
|
+
return new QueryClient({ defaultOptions: {
|
|
713
|
+
queries: {
|
|
714
|
+
retry: false,
|
|
715
|
+
refetchOnWindowFocus: false
|
|
716
|
+
},
|
|
717
|
+
mutations: { retry: false }
|
|
718
|
+
} });
|
|
719
|
+
}
|
|
720
|
+
const catalogQuery = (client) => queryOptions({
|
|
721
|
+
queryKey: runtimeKeys.catalog(client.url),
|
|
722
|
+
queryFn: () => client.fetchPieceCatalog(),
|
|
723
|
+
staleTime: SHARED_STALE_MS
|
|
724
|
+
});
|
|
725
|
+
const blockFormQuery = (client, block) => queryOptions({
|
|
726
|
+
queryKey: runtimeKeys.form(client.url, block),
|
|
727
|
+
queryFn: () => client.getBlockForm(block),
|
|
728
|
+
staleTime: SHARED_STALE_MS
|
|
729
|
+
});
|
|
730
|
+
const pieceActionsQuery = (client, packageName) => queryOptions({
|
|
731
|
+
queryKey: runtimeKeys.pieceActions(client.url, packageName),
|
|
732
|
+
queryFn: () => client.fetchPieceActions(packageName),
|
|
733
|
+
staleTime: SHARED_STALE_MS
|
|
734
|
+
});
|
|
735
|
+
const pieceTriggersQuery = (client, packageName) => queryOptions({
|
|
736
|
+
queryKey: runtimeKeys.pieceTriggers(client.url, packageName),
|
|
737
|
+
queryFn: () => client.fetchPieceTriggers(packageName),
|
|
738
|
+
staleTime: SHARED_STALE_MS
|
|
739
|
+
});
|
|
740
|
+
const outputTreeQuery = (client, block, config) => queryOptions({
|
|
741
|
+
queryKey: runtimeKeys.outputTree(client.url, block, config),
|
|
742
|
+
queryFn: () => client.fetchBlockOutputTree(block, config),
|
|
743
|
+
staleTime: Infinity
|
|
744
|
+
});
|
|
745
|
+
const stepOutputTreeQuery = (client, workflowId, stepId, testedAt) => queryOptions({
|
|
746
|
+
queryKey: runtimeKeys.stepOutputTree(client.url, workflowId, stepId, testedAt),
|
|
747
|
+
queryFn: () => client.fetchStepOutputTree(workflowId, stepId),
|
|
748
|
+
staleTime: Infinity
|
|
749
|
+
});
|
|
750
|
+
const REAL_RUNS = [TEST_TRIGGER_KIND];
|
|
751
|
+
const runsQuery = (client, scope) => queryOptions({
|
|
752
|
+
queryKey: runtimeKeys.runs(client.url, scope),
|
|
753
|
+
queryFn: () => client.fetchRuns({
|
|
754
|
+
...scope,
|
|
755
|
+
excludeTriggerKinds: REAL_RUNS
|
|
756
|
+
}).then(realRuns),
|
|
757
|
+
staleTime: 0
|
|
758
|
+
});
|
|
759
|
+
const runPagesQuery = (client, scope) => infiniteQueryOptions({
|
|
760
|
+
queryKey: runtimeKeys.runPages(client.url, scope),
|
|
761
|
+
queryFn: ({ pageParam }) => client.fetchRunsPage({
|
|
762
|
+
...scope,
|
|
763
|
+
excludeTriggerKinds: REAL_RUNS
|
|
764
|
+
}, pageParam),
|
|
765
|
+
initialPageParam: null,
|
|
766
|
+
getNextPageParam: (page) => page.hasNextPage && page.cursor ? page.cursor : void 0,
|
|
767
|
+
staleTime: 0
|
|
768
|
+
});
|
|
769
|
+
function runsOfPages(pages) {
|
|
770
|
+
const seen = /* @__PURE__ */ new Set();
|
|
771
|
+
return realRuns(pages.flatMap((page) => page.items)).filter((run) => {
|
|
772
|
+
if (seen.has(run.id)) return false;
|
|
773
|
+
seen.add(run.id);
|
|
774
|
+
return true;
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
const FINISHED = /* @__PURE__ */ new Set(["SUCCEEDED", "FAILED"]);
|
|
778
|
+
const runQuery = (client, runId) => queryOptions({
|
|
779
|
+
queryKey: runtimeKeys.run(client.url, runId),
|
|
780
|
+
queryFn: () => client.fetchRun(runId),
|
|
781
|
+
staleTime: (query) => query.state.data && FINISHED.has(query.state.data.status) ? Infinity : 0
|
|
782
|
+
});
|
|
783
|
+
const secretStatQuery = (client, ref) => queryOptions({
|
|
784
|
+
queryKey: runtimeKeys.secret(client.url, ref),
|
|
785
|
+
queryFn: () => client.fetchSecretStat(ref),
|
|
786
|
+
staleTime: 0
|
|
787
|
+
});
|
|
788
|
+
//#endregion
|
|
789
|
+
export { MANUAL_TRIGGER as A, stepFields as B, fetchRun as C, ASSERT_BLOCK as D, isSyncingError as E, WEBHOOK_TRIGGER as F, triggerFields as H, isCoreBlock as I, pinBlock as L, SCHEDULE_TRIGGER as M, STEP_PRESETS as N, BRANCH_BLOCK as O, TRIGGER_PRESETS as P, sameBlock as R, createRuntimeClient as S, fetchRunsPage as T, triggerBlock as V, runtimeKeys as _, pieceActionsQuery as a, DEFAULT_RUNTIME_URL as b, runQuery as c, secretStatQuery as d, stepOutputTreeQuery as f, queryKind as g, blockRefKey as h, outputTreeQuery as i, REACTOR_PIECE as j, CORE_PIECE as k, runsOfPages as l, SHARED_STALE_MS as m, catalogQuery as n, pieceTriggersQuery as o, RESOLVER_STALE_MS as p, createRuntimeQueryClient as r, runPagesQuery as s, blockFormQuery as t, runsQuery as u, TEST_TRIGGER_KIND as v, fetchRuns as w, RuntimeRequestError as x, realRuns as y, stepBlock as z };
|
|
790
|
+
|
|
791
|
+
//# sourceMappingURL=runtime-queries-C9SoXGm2.js.map
|