@oomol-lab/open-flow 0.1.0-alpha.9 → 0.1.0-beta.10

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 (74) hide show
  1. package/README.md +5 -1
  2. package/dist/browser/DesignerIcon-DjgOMYI5.js +2065 -0
  3. package/dist/browser/createResourceDialog-DNBueSYZ.js +505 -0
  4. package/dist/browser/{dist-n9WmBm5w.js → dist-BKuSVKCC.js} +1 -1
  5. package/dist/browser/dist-BMRLCebL.js +1893 -0
  6. package/dist/browser/{dist-DWzdGVm9.js → dist-By46o5UV.js} +74 -74
  7. package/dist/browser/dist-CP0883sY.js +4 -0
  8. package/dist/browser/{dist-B0Q2Mn0n.js → dist-Cc0y2Pli.js} +809 -810
  9. package/dist/browser/dist-CeSZ2xSM.js +444 -0
  10. package/dist/browser/{dist-Bc9TvHYl.js → dist-Dg_VXC8f.js} +134 -135
  11. package/dist/browser/{dist-DhsGR_K3.js → dist-DmuE3M0R.js} +47 -48
  12. package/dist/browser/{dist-D5mdziGP.js → dist-DpDLsYtO.js} +18 -19
  13. package/dist/browser/dist-DxahK_I8.js +2688 -0
  14. package/dist/browser/{dist-DXgEYMFx.js → dist-meg_oHVR.js} +230 -230
  15. package/dist/browser/{esm-YIGXG-Js.js → esm-yhVU_KbQ.js} +14 -15
  16. package/dist/browser/flow-authoring-module.d.ts +2 -2
  17. package/dist/browser/flow-authoring-node.d.ts +9 -4
  18. package/dist/browser/flow-authoring.d.ts +2 -1
  19. package/dist/browser/flow-authoring.js +752 -162
  20. package/dist/browser/flow-change.d.ts +122 -13
  21. package/dist/browser/flow-change.js +326 -96
  22. package/dist/browser/flow-notifications.d.ts +5 -0
  23. package/dist/browser/flowChanges-B2ttnaj9.js +12265 -0
  24. package/dist/browser/{flowRunInputEditorStore-DXOyyY7o.js → flowRunInputEditorStore-DDidwd8h.js} +1528 -783
  25. package/dist/browser/{flowWorkspace-D7-rBA1-.js → flowWorkspace-Dr8-Hut9.js} +42428 -42499
  26. package/dist/browser/getPseudoElementBounds-5LArT6Xc.js +7147 -0
  27. package/dist/browser/icons-KIOgjHpD.js +730 -0
  28. package/dist/browser/languages-DgJehE1g.js +62 -0
  29. package/dist/browser/lib-C5Ipyfps.js +7856 -0
  30. package/dist/browser/licenses.md +119 -1
  31. package/dist/browser/main-DmjVyuWr.js +76 -0
  32. package/dist/browser/{markdownContent-ColGUxHy.js → markdownContent-DUfLdnUt.js} +4811 -4795
  33. package/dist/browser/theme.css +63 -0
  34. package/dist/browser/theme.css.d.ts +1 -0
  35. package/dist/browser/typeScriptSession-_TgJ_7Oq.js +2578 -0
  36. package/dist/browser/waitNotificationInputs-BPulOxYt.js +26 -0
  37. package/dist/browser/workbench-contract.d.ts +2 -1
  38. package/dist/browser/workbench.css +1 -1
  39. package/dist/browser/workbench.d.ts +47 -1
  40. package/dist/browser/workbench.js +1524 -1768
  41. package/dist/browser/workbenchSelect-CbXrdwxW.js +1375 -0
  42. package/dist/common/connector-action.d.ts +6 -0
  43. package/dist/common/connector-action.js +37 -29
  44. package/dist/common/control-api-conformance.d.ts +1 -0
  45. package/dist/common/control-api-conformance.js +171 -51
  46. package/dist/common/control-api-errors.d.ts +28 -0
  47. package/dist/common/control-api.d.ts +80 -21
  48. package/dist/common/control-api.js +311 -131
  49. package/dist/common/flow-encoding.d.ts +2 -2
  50. package/dist/common/flow-encoding.js +28 -9
  51. package/dist/common/flow-notifications.d.ts +5 -0
  52. package/dist/common/flow-semantics.d.ts +4 -0
  53. package/dist/common/flow-semantics.js +3544 -1098
  54. package/dist/common/integration-trigger.d.ts +1 -0
  55. package/dist/common/licenses.md +1 -25
  56. package/dist/common/localization.d.ts +21 -0
  57. package/dist/common/localization.js +62 -0
  58. package/dist/common/provider-triggers.js +4 -1
  59. package/dist/common/run-events.js +2 -1
  60. package/dist/common/run-lifecycle.d.ts +17 -2
  61. package/dist/common/run-lifecycle.js +53 -2
  62. package/dist/common/runtime-contract.d.ts +1 -1
  63. package/dist/common/runtime-contract.js +27 -0
  64. package/dist/common/scheduler.d.ts +68 -7
  65. package/dist/common/scheduler.js +528 -240
  66. package/dist/index.d.ts +2 -1
  67. package/package.json +10 -1
  68. package/dist/browser/addNodeOptions-DRndy4EK.js +0 -6910
  69. package/dist/browser/createLucideIcon-CqjqCezK.js +0 -5537
  70. package/dist/browser/createResourceDialog-A64dDFCG.js +0 -467
  71. package/dist/browser/dist-CUkceEvN.js +0 -1620
  72. package/dist/browser/dist-CVtP-E2c.js +0 -1543
  73. package/dist/browser/dist-DQVavPcf.js +0 -2328
  74. package/dist/browser/field-CKGQHCIi.js +0 -312
@@ -1,72 +1,471 @@
1
- //#region src/flow/common/edgeChanges.ts
2
- function e(e, t, r) {
3
- let i = {
4
- source: r.source,
5
- sourceHandle: r.sourceHandle,
6
- target: r.target,
7
- targetHandle: r.targetHandle
8
- }, a = n(e, t)?.nodes[r.target], o = a != null && "inputs" in a ? a.inputs[r.targetHandle] : void 0;
9
- return o?.kind == "sources" && o.sources.some((e) => e.kind == "node" && e.nodeId == r.source && e.output == r.sourceHandle) ? [] : [{
10
- edge: i,
11
- kind: "graph.edge.connect",
12
- target: t
13
- }];
1
+ //#region ../../node_modules/.bun/nanoid@6.0.1/node_modules/nanoid/index.browser.js
2
+ var e = (e) => crypto.getRandomValues(new Uint8Array(e)), t = (e, t, n) => {
3
+ let r = 256 - 256 % e.length;
4
+ if (r === 256) {
5
+ let r = e.length - 1;
6
+ return (i = t) => {
7
+ if (!i) return "";
8
+ let a = "";
9
+ for (;;) {
10
+ let t = n(i), o = i;
11
+ for (; o--;) if (a += e[t[o] & r], a.length >= i) return a;
12
+ }
13
+ };
14
+ }
15
+ let i = Math.ceil(409.6 * t / r);
16
+ return (a = t) => {
17
+ if (!a) return "";
18
+ let o = "";
19
+ for (;;) {
20
+ let t = n(i), s = i;
21
+ for (; s--;) if (t[s] < r && (o += e[t[s] % e.length], o.length >= a)) return o;
22
+ }
23
+ };
24
+ }, n = (n, r = 21) => t(n, r | 0, e), r = Object.prototype.hasOwnProperty;
25
+ function i(e, t) {
26
+ var n, a;
27
+ if (e === t) return !0;
28
+ if (e && t && (n = e.constructor) === t.constructor) {
29
+ if (n === Date) return e.getTime() === t.getTime();
30
+ if (n === RegExp) return e.toString() === t.toString();
31
+ if (n === Array) {
32
+ if ((a = e.length) === t.length) for (; a-- && i(e[a], t[a]););
33
+ return a === -1;
34
+ }
35
+ if (!n || typeof e == "object") {
36
+ for (n in a = 0, e) if (r.call(e, n) && ++a && !r.call(t, n) || !(n in t) || !i(e[n], t[n])) return !1;
37
+ return Object.keys(t).length === a;
38
+ }
39
+ }
40
+ return e !== e && t !== t;
14
41
  }
15
- function t(e, t, r) {
16
- let i = {
17
- source: r.source,
18
- sourceHandle: r.sourceHandle,
19
- target: r.target,
20
- targetHandle: r.targetHandle
21
- }, a = n(e, t)?.nodes[r.target], o = a != null && "inputs" in a ? a.inputs[r.targetHandle] : void 0;
22
- return o?.kind != "sources" || !o.sources.some((e) => e.kind == "node" && e.nodeId == r.source && e.output == r.sourceHandle) ? [] : [{
23
- edge: i,
24
- kind: "graph.edge.disconnect",
25
- target: t
26
- }];
42
+ //#endregion
43
+ //#region src/flow/common/change.ts
44
+ var a = class extends Error {
45
+ constructor(e) {
46
+ super(e), this.name = "FlowChangeError";
47
+ }
48
+ };
49
+ function o(e) {
50
+ throw new a(e);
27
51
  }
28
- function n(e, t) {
29
- return t.kind == "flow" ? e.document.graph : e.document.subflows[t.id]?.graph;
52
+ function s(e, t) {
53
+ if (t.kind == "flow") return e.graph;
54
+ let n = e.subflows[t.id];
55
+ return n ?? o("The target Subflow does not exist."), n.graph;
30
56
  }
31
- //#endregion
32
- //#region src/flow/common/moduleChanges.ts
33
- async function r(e) {
34
- try {
35
- let { parse: t } = await import("./lib-GrGxYjsJ.js"), n = t(e, {
36
- errorRecovery: !0,
37
- sourceType: "module"
38
- }).program, r = /* @__PURE__ */ new Set();
39
- for (let e of n.body) {
40
- if (e.type != "ImportDeclaration") continue;
41
- let t = /^\.\/(.+)\.mjs$/.exec(e.source.value);
42
- t?.[1] != null && r.add(t[1]);
57
+ function c(e, t, n) {
58
+ if (t.kind == "flow") return {
59
+ ...e,
60
+ graph: n
61
+ };
62
+ let r = e.subflows[t.id];
63
+ return r ?? o("The target Subflow does not exist."), {
64
+ ...e,
65
+ subflows: {
66
+ ...e.subflows,
67
+ [t.id]: {
68
+ ...r,
69
+ graph: n
70
+ }
43
71
  }
44
- return [...r].toSorted();
45
- } catch {
46
- return [];
47
- }
72
+ };
48
73
  }
49
- function i(e, t, n) {
50
- return [{
51
- imports: n,
52
- kind: "module.source.replace",
53
- moduleId: e,
54
- source: t
55
- }];
74
+ function l(e, t) {
75
+ if (!("inputs" in e)) return e;
76
+ let n = { ...e.inputs };
77
+ for (let [e, r] of Object.entries(n)) {
78
+ if (r.kind != "sources") continue;
79
+ let i = r.sources.filter((e) => e.kind != "node" || !t.has(e.nodeId));
80
+ i.length == 0 ? delete n[e] : n[e] = {
81
+ kind: "sources",
82
+ sources: i
83
+ };
84
+ }
85
+ return {
86
+ ...e,
87
+ inputs: n
88
+ };
56
89
  }
57
- function a(e, t) {
58
- return [{
59
- kind: "module.rename",
60
- moduleId: e,
61
- name: t
62
- }];
90
+ function u(e, t) {
91
+ let n = { ...e.document }, r = { ...e.modules };
92
+ for (let e of t) switch (e.kind) {
93
+ case "binding.create":
94
+ n.bindings[e.bindingId] != null && o("A Binding with this ID already exists."), n.bindings = {
95
+ ...n.bindings,
96
+ [e.bindingId]: e.binding
97
+ };
98
+ break;
99
+ case "binding.delete": {
100
+ n.bindings[e.bindingId] ?? o("The Binding does not exist.");
101
+ let t = { ...n.bindings };
102
+ delete t[e.bindingId], n.bindings = t;
103
+ break;
104
+ }
105
+ case "binding.target.set": {
106
+ let t = n.bindings[e.bindingId];
107
+ t ?? o("The Binding does not exist."), t.target != e.before && o("The Binding target changed before this operation was applied."), n.bindings = {
108
+ ...n.bindings,
109
+ [e.bindingId]: {
110
+ ...t,
111
+ target: e.value
112
+ }
113
+ };
114
+ break;
115
+ }
116
+ case "graph.edge.connect": {
117
+ let t = s(n, e.target);
118
+ t.nodes[e.edge.source] ?? o("The source Node does not exist.");
119
+ let r = t.nodes[e.edge.target];
120
+ (r == null || !("inputs" in r)) && o("The target Node does not accept inputs.");
121
+ let a = r.inputs[e.edge.targetHandle];
122
+ i(a, e.before) || o("The target input changed before this operation was applied.");
123
+ let l = {
124
+ kind: "node",
125
+ nodeId: e.edge.source,
126
+ output: e.edge.sourceHandle
127
+ }, u = a?.kind == "sources" ? a.sources.filter((e) => e.kind != "binding" || n.bindings[e.bindingId]?.kind != "variable") : [];
128
+ u.some((e) => e.kind == "node" && e.nodeId == l.nodeId && e.output == l.output) && o("The Nodes are already connected.");
129
+ let d = {
130
+ ...r,
131
+ inputs: {
132
+ ...r.inputs,
133
+ [e.edge.targetHandle]: {
134
+ kind: "sources",
135
+ sources: [...u, l]
136
+ }
137
+ }
138
+ };
139
+ Object.assign(n, c(n, e.target, { nodes: {
140
+ ...t.nodes,
141
+ [e.edge.target]: d
142
+ } }));
143
+ break;
144
+ }
145
+ case "graph.edge.disconnect": {
146
+ let t = s(n, e.target), r = t.nodes[e.edge.target];
147
+ (r == null || !("inputs" in r)) && o("The target Node does not accept inputs.");
148
+ let a = r.inputs[e.edge.targetHandle];
149
+ (a?.kind != "sources" || !i(a, e.before)) && o("The target input changed before this operation was applied.");
150
+ let l = a.sources.filter((t) => t.kind != "node" || t.nodeId != e.edge.source || t.output != e.edge.sourceHandle);
151
+ l.length == a.sources.length && o("The Nodes are not connected.");
152
+ let u = { ...r.inputs };
153
+ l.length == 0 ? delete u[e.edge.targetHandle] : u[e.edge.targetHandle] = {
154
+ kind: "sources",
155
+ sources: l
156
+ }, Object.assign(n, c(n, e.target, { nodes: {
157
+ ...t.nodes,
158
+ [e.edge.target]: {
159
+ ...r,
160
+ inputs: u
161
+ }
162
+ } }));
163
+ break;
164
+ }
165
+ case "graph.node.additional-inputs.set": {
166
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
167
+ r?.kind != "task" && o("The Task Node does not exist."), i(r.additionalInputs, e.before) || o("The Task Node inputs changed before this operation was applied.");
168
+ let { additionalInputs: a, ...l } = r, u = e.value == null ? l : {
169
+ ...l,
170
+ additionalInputs: e.value
171
+ };
172
+ Object.assign(n, c(n, e.target, { nodes: {
173
+ ...t.nodes,
174
+ [e.nodeId]: u
175
+ } }));
176
+ break;
177
+ }
178
+ case "graph.node.condition.set": {
179
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
180
+ r?.kind != "condition" && o("The Condition Node does not exist."), (!i(r.cases, e.before.cases) || r.defaultOutput != e.before.defaultOutput || !i(r.input, e.before.input)) && o("The Condition Node changed before this operation was applied.");
181
+ let { defaultOutput: a, ...l } = r, u = e.value.defaultOutput == null ? {
182
+ ...l,
183
+ ...e.value
184
+ } : {
185
+ ...r,
186
+ ...e.value
187
+ };
188
+ Object.assign(n, c(n, e.target, { nodes: {
189
+ ...t.nodes,
190
+ [e.nodeId]: u
191
+ } }));
192
+ break;
193
+ }
194
+ case "graph.node.create": {
195
+ let t = s(n, e.target);
196
+ t.nodes[e.nodeId] != null && o("A Node with this ID already exists in the target graph."), e.target.kind == "subflow" && !("inputs" in e.node) && o("Trigger Nodes cannot be created inside a Subflow."), Object.assign(n, c(n, e.target, { nodes: {
197
+ ...t.nodes,
198
+ [e.nodeId]: e.node
199
+ } }));
200
+ break;
201
+ }
202
+ case "graph.node.delete": {
203
+ let t = s(n, e.target);
204
+ t.nodes[e.nodeId] ?? o("The Node does not exist in the target graph.");
205
+ let r = /* @__PURE__ */ new Set([e.nodeId]), i = Object.fromEntries(Object.entries(t.nodes).flatMap(([e, t]) => r.has(e) ? [] : [[e, l(t, r)]]));
206
+ if (Object.assign(n, c(n, e.target, { nodes: i })), e.target.kind == "subflow") {
207
+ let t = n.subflows[e.target.id], i = t.outputs.map((e) => ({
208
+ ...e,
209
+ sources: e.sources.filter((e) => e.kind != "node" || !r.has(e.nodeId))
210
+ }));
211
+ n.subflows = {
212
+ ...n.subflows,
213
+ [e.target.id]: {
214
+ ...t,
215
+ outputs: i
216
+ }
217
+ };
218
+ }
219
+ break;
220
+ }
221
+ case "graph.node.field.set": {
222
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
223
+ r ?? o("The Node does not exist in the target graph."), i(Reflect.get(r, e.field), e.before) || o("The Node field changed before this operation was applied."), e.field == "concurrency" && e.value == null && o("Node concurrency cannot be removed.");
224
+ let a = { ...r };
225
+ e.value == null ? Reflect.deleteProperty(a, e.field) : Object.assign(a, { [e.field]: e.value }), Object.assign(n, c(n, e.target, { nodes: {
226
+ ...t.nodes,
227
+ [e.nodeId]: a
228
+ } }));
229
+ break;
230
+ }
231
+ case "graph.node.input.set": {
232
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
233
+ (r == null || !("inputs" in r)) && o("The Node does not accept inputs."), i(r.inputs[e.handle], e.before) || o("The Node input changed before this operation was applied.");
234
+ let a = { ...r.inputs };
235
+ e.value == null ? delete a[e.handle] : a[e.handle] = e.value, Object.assign(n, c(n, e.target, { nodes: {
236
+ ...t.nodes,
237
+ [e.nodeId]: {
238
+ ...r,
239
+ inputs: a
240
+ }
241
+ } }));
242
+ break;
243
+ }
244
+ case "graph.node.task.name.set": {
245
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
246
+ (r?.kind != "task" || r.task == null) && o("The inline Task Node does not exist."), r.task.name != e.before && o("The inline Task name changed before this operation was applied.");
247
+ let i = {
248
+ ...r,
249
+ task: {
250
+ ...r.task,
251
+ name: e.value
252
+ }
253
+ };
254
+ Object.assign(n, c(n, e.target, { nodes: {
255
+ ...t.nodes,
256
+ [e.nodeId]: i
257
+ } }));
258
+ break;
259
+ }
260
+ case "graph.node.task.ports.set": {
261
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
262
+ (r?.kind != "task" || r.task == null) && o("The inline Task Node does not exist."), i({
263
+ inputs: r.task.inputs,
264
+ outputs: r.task.outputs
265
+ }, e.before) || o("The inline Task ports changed before this operation was applied.");
266
+ let a = {
267
+ ...r,
268
+ task: {
269
+ ...r.task,
270
+ ...e.value
271
+ }
272
+ };
273
+ Object.assign(n, c(n, e.target, { nodes: {
274
+ ...t.nodes,
275
+ [e.nodeId]: a
276
+ } }));
277
+ break;
278
+ }
279
+ case "graph.node.values.set": {
280
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
281
+ r?.kind != "value" && o("The Value Node does not exist."), i(r.values, e.before) || o("The Value Node changed before this operation was applied."), Object.assign(n, c(n, e.target, { nodes: {
282
+ ...t.nodes,
283
+ [e.nodeId]: {
284
+ ...r,
285
+ values: e.value
286
+ }
287
+ } }));
288
+ break;
289
+ }
290
+ case "graph.node.wait.set": {
291
+ let t = n.graph, r = t.nodes[e.nodeId];
292
+ (r?.kind != "wait" || !i({
293
+ actions: r.actions,
294
+ ...r.notification == null ? {} : { notification: r.notification },
295
+ prompt: r.prompt
296
+ }, e.before)) && o("The Wait Node changed before this operation was applied.");
297
+ let { notification: a, ...s } = r, c = e.value.notification == null ? {
298
+ ...s,
299
+ ...e.value
300
+ } : {
301
+ ...r,
302
+ ...e.value
303
+ };
304
+ n.graph = { nodes: {
305
+ ...t.nodes,
306
+ [e.nodeId]: c
307
+ } };
308
+ break;
309
+ }
310
+ case "graph.node.webhook.set": {
311
+ let t = s(n, e.target), r = t.nodes[e.nodeId];
312
+ r?.kind != "webhook" && o("The Webhook Node does not exist."), (!i(r.inputsDef, e.before.inputsDef) || !i(r.options, e.before.options)) && o("The Webhook Node changed before this operation was applied.");
313
+ let { options: a, ...l } = r, u = e.value.options == null ? {
314
+ ...l,
315
+ inputsDef: e.value.inputsDef
316
+ } : {
317
+ ...r,
318
+ ...e.value
319
+ };
320
+ Object.assign(n, c(n, e.target, { nodes: {
321
+ ...t.nodes,
322
+ [e.nodeId]: u
323
+ } }));
324
+ break;
325
+ }
326
+ case "graph.trigger.config.set": {
327
+ let t = n.graph, r = t.nodes[e.nodeId];
328
+ (r == null || r.kind != "integration" && r.kind != "poll") && o("The configurable Trigger Node does not exist."), i(r.config[e.name], e.before) || o("The Trigger configuration changed before this operation was applied.");
329
+ let a = { ...r.config };
330
+ e.value === void 0 ? delete a[e.name] : a[e.name] = e.value, n.graph = { nodes: {
331
+ ...t.nodes,
332
+ [e.nodeId]: {
333
+ ...r,
334
+ config: a
335
+ }
336
+ } };
337
+ break;
338
+ }
339
+ case "graph.trigger.schedule.set": {
340
+ let t = n.graph, r = t.nodes[e.nodeId];
341
+ (r == null || r.kind != "cron" && r.kind != "poll") && o("The scheduled Trigger Node does not exist."), i(r.kind == "cron" ? r.cronTimes : r.pollTimes, e.before) || o("The Trigger schedule changed before this operation was applied.");
342
+ let a = r.kind == "cron" ? {
343
+ ...r,
344
+ cronTimes: e.value
345
+ } : {
346
+ ...r,
347
+ pollTimes: e.value
348
+ };
349
+ n.graph = { nodes: {
350
+ ...t.nodes,
351
+ [e.nodeId]: a
352
+ } };
353
+ break;
354
+ }
355
+ case "module.create":
356
+ r[e.moduleId] != null && o("A CodeModule with this ID already exists."), r[e.moduleId] = e.module;
357
+ break;
358
+ case "module.delete":
359
+ r[e.moduleId] ?? o("The CodeModule does not exist."), delete r[e.moduleId];
360
+ break;
361
+ case "module.rename": {
362
+ let t = r[e.moduleId];
363
+ t ?? o("The CodeModule does not exist."), t.name != e.before && o("The CodeModule name changed before this operation was applied."), r[e.moduleId] = {
364
+ ...t,
365
+ name: e.name
366
+ };
367
+ break;
368
+ }
369
+ case "module.source.replace": {
370
+ let t = r[e.moduleId];
371
+ t ?? o("The CodeModule does not exist."), (t.source != e.beforeSource || !i(t.imports, e.beforeImports)) && o("The CodeModule source changed before this operation was applied."), r[e.moduleId] = {
372
+ ...t,
373
+ imports: e.imports,
374
+ source: e.source
375
+ };
376
+ break;
377
+ }
378
+ case "subflow.create":
379
+ n.subflows[e.subflowId] != null && o("A Subflow with this ID already exists."), n.subflows = {
380
+ ...n.subflows,
381
+ [e.subflowId]: e.subflow
382
+ };
383
+ break;
384
+ case "subflow.definition.set": {
385
+ let t = n.subflows[e.subflowId];
386
+ t ?? o("The Subflow does not exist."), i({
387
+ inputs: t.inputs,
388
+ name: t.name,
389
+ outputs: t.outputs
390
+ }, e.before) || o("The Subflow definition changed before this operation was applied."), n.subflows = {
391
+ ...n.subflows,
392
+ [e.subflowId]: {
393
+ ...e.definition,
394
+ graph: t.graph
395
+ }
396
+ };
397
+ break;
398
+ }
399
+ case "subflow.delete": {
400
+ n.subflows[e.subflowId] ?? o("The Subflow does not exist.");
401
+ let t = { ...n.subflows };
402
+ delete t[e.subflowId], n.subflows = t;
403
+ break;
404
+ }
405
+ case "task.create":
406
+ n.tasks[e.taskId] != null && o("A Task with this ID already exists."), n.tasks = {
407
+ ...n.tasks,
408
+ [e.taskId]: e.task
409
+ };
410
+ break;
411
+ case "task.connector.connection.set": {
412
+ let t = n.tasks[e.taskId];
413
+ (t == null || !("executor" in t) || t.executor.kind != "connector") && o("The Connector Task does not exist."), t.executor.connectionId != e.before && o("The Connector Task connection changed before this operation was applied.");
414
+ let { connectionId: r, ...i } = t.executor, a = e.value == null ? i : {
415
+ ...i,
416
+ connectionId: e.value
417
+ };
418
+ n.tasks = {
419
+ ...n.tasks,
420
+ [e.taskId]: {
421
+ ...t,
422
+ executor: a
423
+ }
424
+ };
425
+ break;
426
+ }
427
+ case "task.delete": {
428
+ n.tasks[e.taskId] ?? o("The Task does not exist.");
429
+ let t = { ...n.tasks };
430
+ delete t[e.taskId], n.tasks = t;
431
+ break;
432
+ }
433
+ case "task.llm.mode.set": {
434
+ let t = n.tasks[e.taskId];
435
+ (t == null || !("executor" in t) || t.executor.kind != "llm") && o("The LLM Task does not exist."), t.executor.mode != e.before && o("The LLM Task mode changed before this operation was applied."), n.tasks = {
436
+ ...n.tasks,
437
+ [e.taskId]: {
438
+ ...t,
439
+ executor: {
440
+ ...t.executor,
441
+ mode: e.value
442
+ }
443
+ }
444
+ };
445
+ break;
446
+ }
447
+ case "task.name.set": {
448
+ let t = n.tasks[e.taskId];
449
+ t ?? o("The Task does not exist."), t.name != e.before && o("The Task name changed before this operation was applied."), n.tasks = {
450
+ ...n.tasks,
451
+ [e.taskId]: {
452
+ ...t,
453
+ name: e.value
454
+ }
455
+ };
456
+ break;
457
+ }
458
+ }
459
+ return {
460
+ document: n,
461
+ modelVersion: e.modelVersion,
462
+ modules: r
463
+ };
63
464
  }
64
465
  //#endregion
65
466
  //#region src/flow/common/nodeChanges.ts
66
- function o(e, t, n, r = {
67
- imports: [],
68
- source: "export default function run(input) {\n return { result: input.value }\n}\n"
69
- }, i = {
467
+ var d = "export default async function (inputs, context) {\n return { result: inputs.value }\n}\n";
468
+ function f(e, t, n, r = void 0, i = {
70
469
  inputs: [{
71
470
  handle: "value",
72
471
  jsonSchema: {},
@@ -82,7 +481,10 @@ function o(e, t, n, r = {
82
481
  return [{
83
482
  kind: "module.create",
84
483
  module: {
85
- ...r,
484
+ ...r ?? {
485
+ imports: [],
486
+ source: d
487
+ },
86
488
  name: n
87
489
  },
88
490
  moduleId: t.moduleId
@@ -90,7 +492,7 @@ function o(e, t, n, r = {
90
492
  kind: "graph.node.create",
91
493
  node: {
92
494
  concurrency: 1,
93
- inputs: b(i.inputs),
495
+ inputs: A(i.inputs),
94
496
  kind: "task",
95
497
  name: n,
96
498
  task: {
@@ -104,7 +506,7 @@ function o(e, t, n, r = {
104
506
  target: e
105
507
  }];
106
508
  }
107
- function s(e, t, n) {
509
+ function p(e, t, n) {
108
510
  return [{
109
511
  kind: "task.create",
110
512
  task: n,
@@ -113,7 +515,7 @@ function s(e, t, n) {
113
515
  kind: "graph.node.create",
114
516
  node: {
115
517
  concurrency: 1,
116
- inputs: b(n.inputs),
518
+ inputs: A(n.inputs),
117
519
  kind: "task",
118
520
  name: n.name,
119
521
  taskId: t.taskId
@@ -122,9 +524,9 @@ function s(e, t, n) {
122
524
  target: e
123
525
  }];
124
526
  }
125
- function c(e, t, n, r, i, a = {}) {
527
+ function m(e, t, n, r, i, a = {}) {
126
528
  let o = a.inputs ?? {};
127
- return s(e, t, {
529
+ return p(e, t, {
128
530
  executor: {
129
531
  kind: "llm",
130
532
  mode: r
@@ -137,13 +539,13 @@ function c(e, t, n, r, i, a = {}) {
137
539
  type: "array"
138
540
  },
139
541
  nullable: !0,
140
- value: x(o, "messages", null)
542
+ value: j(o, "messages", null)
141
543
  },
142
544
  {
143
545
  handle: "input",
144
546
  jsonSchema: { type: "string" },
145
547
  nullable: !1,
146
- value: x(o, "input", "Alex")
548
+ value: j(o, "input", "Alex")
147
549
  },
148
550
  {
149
551
  handle: "template",
@@ -153,7 +555,7 @@ function c(e, t, n, r, i, a = {}) {
153
555
  type: "array"
154
556
  },
155
557
  nullable: !1,
156
- value: x(o, "template", [{
558
+ value: j(o, "template", [{
157
559
  content: "Hello, I'm {{input}}",
158
560
  role: "user"
159
561
  }])
@@ -162,7 +564,7 @@ function c(e, t, n, r, i, a = {}) {
162
564
  handle: "model",
163
565
  jsonSchema: { type: "object" },
164
566
  nullable: !1,
165
- value: x(o, "model", { model: "deepseek-v4-flash" })
567
+ value: j(o, "model", { model: "deepseek-v4-flash" })
166
568
  }
167
569
  ],
168
570
  name: n,
@@ -175,7 +577,7 @@ function c(e, t, n, r, i, a = {}) {
175
577
  }]
176
578
  });
177
579
  }
178
- function l(e, t, n) {
580
+ function h(e, t, n) {
179
581
  return [{
180
582
  kind: "graph.node.create",
181
583
  node: {
@@ -206,7 +608,7 @@ function l(e, t, n) {
206
608
  target: e
207
609
  }];
208
610
  }
209
- function u(e, t, n) {
611
+ function g(e, t, n) {
210
612
  return [{
211
613
  kind: "graph.node.create",
212
614
  node: {
@@ -225,7 +627,31 @@ function u(e, t, n) {
225
627
  target: e
226
628
  }];
227
629
  }
228
- function d(e, t, n) {
630
+ function _(e, t, n) {
631
+ return [{
632
+ kind: "graph.node.create",
633
+ node: {
634
+ actions: ["continue"],
635
+ concurrency: 1,
636
+ input: {
637
+ handle: "value",
638
+ jsonSchema: {},
639
+ nullable: !0,
640
+ value: null
641
+ },
642
+ inputs: { value: {
643
+ kind: "value",
644
+ value: null
645
+ } },
646
+ kind: "wait",
647
+ name: n,
648
+ prompt: n
649
+ },
650
+ nodeId: t,
651
+ target: e
652
+ }];
653
+ }
654
+ function v(e, t, n) {
229
655
  return [{
230
656
  kind: "graph.node.create",
231
657
  node: n,
@@ -233,7 +659,7 @@ function d(e, t, n) {
233
659
  target: e
234
660
  }];
235
661
  }
236
- function f(e, t, n, r) {
662
+ function y(e, t, n, r) {
237
663
  let i = r.name ?? n.displayName, a = n.type == "poll" ? {
238
664
  bindingId: t.bindingId,
239
665
  config: r.config,
@@ -252,22 +678,22 @@ function f(e, t, n, r) {
252
678
  kind: "integration",
253
679
  name: i
254
680
  };
255
- return [{
681
+ return [...r.connectionId == null ? [] : [{
256
682
  binding: {
257
683
  kind: "connection",
258
684
  target: r.connectionId
259
685
  },
260
686
  bindingId: t.bindingId,
261
687
  kind: "binding.create"
262
- }, {
688
+ }], {
263
689
  kind: "graph.node.create",
264
690
  node: a,
265
691
  nodeId: t.nodeId,
266
692
  target: e
267
693
  }];
268
694
  }
269
- function p(e, t, n) {
270
- let r = y(e, t)?.nodes;
695
+ function b(e, t, n) {
696
+ let r = k(e, t)?.nodes;
271
697
  if (r == null) return [];
272
698
  let i = new Set(n), a = n.flatMap((e) => {
273
699
  let n = r[e];
@@ -280,132 +706,296 @@ function p(e, t, n) {
280
706
  moduleId: n.task.moduleId
281
707
  }] : []];
282
708
  });
283
- if (t.kind == "subflow") return a;
709
+ if (t.kind == "subflow") return w(e, a);
284
710
  let o = new Set(n.flatMap((e) => {
285
711
  let t = r[e];
286
712
  return t?.kind == "poll" || t?.kind == "integration" ? [t.bindingId] : [];
287
713
  }));
288
- for (let t of o) Object.entries(e.document.graph.nodes).some(([e, n]) => !i.has(e) && (n.kind == "poll" || n.kind == "integration") && n.bindingId == t) || a.push({
714
+ for (let t of o) !Object.entries(e.document.graph.nodes).some(([e, n]) => !i.has(e) && (n.kind == "poll" || n.kind == "integration") && n.bindingId == t) && e.document.bindings[t] != null && a.push({
289
715
  bindingId: t,
290
716
  kind: "binding.delete"
291
717
  });
292
- return a;
718
+ return w(e, a);
293
719
  }
294
- function m(e, t, n, r) {
295
- let i = y(e, t)?.nodes[n];
720
+ function x(e, t, n, r) {
721
+ let i = k(e, t)?.nodes[n];
296
722
  if (i == null || !("inputs" in i)) return;
297
- let { concurrency: a, name: o, timeoutMs: s, ...c } = i;
298
- return S(t, n, {
299
- ...c,
300
- ...r
301
- });
723
+ let a = [];
724
+ return i.concurrency != r.concurrency && a.push({
725
+ before: i.concurrency,
726
+ field: "concurrency",
727
+ kind: "graph.node.field.set",
728
+ nodeId: n,
729
+ target: t,
730
+ value: r.concurrency
731
+ }), i.name != r.name && a.push({
732
+ before: i.name,
733
+ field: "name",
734
+ kind: "graph.node.field.set",
735
+ nodeId: n,
736
+ target: t,
737
+ value: r.name
738
+ }), i.timeoutMs != r.timeoutMs && a.push({
739
+ before: i.timeoutMs,
740
+ field: "timeoutMs",
741
+ kind: "graph.node.field.set",
742
+ nodeId: n,
743
+ target: t,
744
+ value: r.timeoutMs
745
+ }), a;
302
746
  }
303
- function h(e, t, n, r) {
304
- let i = y(e, t)?.nodes[n];
305
- if (i == null || !("inputs" in i)) return;
306
- let a = { ...i.inputs };
307
- for (let [e, t] of Object.entries(r)) t === void 0 ? delete a[e] : a[e] = {
308
- kind: "value",
309
- value: t
747
+ function S(e, t, n, r) {
748
+ let a = k(e, t)?.nodes[n];
749
+ if (a == null || !("inputs" in a)) return;
750
+ let o = [];
751
+ for (let [e, s] of Object.entries(r)) {
752
+ let r = a.inputs[e], c = s === void 0 ? void 0 : {
753
+ kind: "value",
754
+ value: s
755
+ };
756
+ i(r, c) || o.push({
757
+ before: r,
758
+ handle: e,
759
+ kind: "graph.node.input.set",
760
+ nodeId: n,
761
+ target: t,
762
+ value: c
763
+ });
764
+ }
765
+ return w(e, o);
766
+ }
767
+ function C(e, t, n, r, i, a) {
768
+ let o = k(e, t)?.nodes[n];
769
+ if (o == null || !("inputs" in o)) return;
770
+ let s = o.inputs[r], c = s?.kind == "sources" && s.sources.length == 1 && s.sources[0]?.kind == "binding" ? s.sources[0].bindingId : void 0, l = c == null ? void 0 : e.document.bindings[c], u = T(e.document);
771
+ return c != null && l?.kind == "variable" && (u.get(c) ?? 0) == 1 ? l.target == i ? [] : [{
772
+ before: l.target,
773
+ bindingId: c,
774
+ kind: "binding.target.set",
775
+ value: i
776
+ }] : [{
777
+ binding: {
778
+ kind: "variable",
779
+ target: i
780
+ },
781
+ bindingId: a,
782
+ kind: "binding.create"
783
+ }, ...w(e, [{
784
+ before: s,
785
+ handle: r,
786
+ kind: "graph.node.input.set",
787
+ nodeId: n,
788
+ target: t,
789
+ value: {
790
+ kind: "sources",
791
+ sources: [{
792
+ bindingId: a,
793
+ kind: "binding"
794
+ }]
795
+ }
796
+ }])];
797
+ }
798
+ function w(e, t) {
799
+ let n = T(e.document), r = u(e, t), i = T(r.document);
800
+ return [...t, ...[...n.keys()].flatMap((e) => i.has(e) || r.document.bindings[e]?.kind != "variable" ? [] : [{
801
+ bindingId: e,
802
+ kind: "binding.delete"
803
+ }])];
804
+ }
805
+ function T(e) {
806
+ let t = /* @__PURE__ */ new Map(), n = (e) => {
807
+ t.set(e, (t.get(e) ?? 0) + 1);
310
808
  };
311
- return S(t, n, {
312
- ...i,
313
- inputs: a
314
- });
809
+ for (let t of [e.graph, ...Object.values(e.subflows).map((e) => e.graph)]) for (let e of Object.values(t.nodes)) {
810
+ if ((e.kind == "poll" || e.kind == "integration") && n(e.bindingId), !("inputs" in e)) continue;
811
+ let t = [...Object.values(e.inputs), ...e.kind == "wait" && e.notification != null ? Object.values(e.notification.inputs) : []];
812
+ for (let e of t) if (e.kind == "sources") for (let t of e.sources) t.kind == "binding" && n(t.bindingId);
813
+ }
814
+ return t;
315
815
  }
316
- function g(e, t, n) {
816
+ function E(e, t, n) {
317
817
  let r = e.document.tasks[t];
318
- if (!(r == null || !("executor" in r) || r.executor.kind != "connector")) return [{
319
- kind: "task.replace",
320
- task: {
321
- ...r,
322
- executor: {
323
- ...r.executor,
324
- connectionId: n
325
- }
326
- },
327
- taskId: t
818
+ if (!(r == null || !("executor" in r) || r.executor.kind != "connector")) return r.executor.connectionId == n ? [] : [{
819
+ before: r.executor.connectionId,
820
+ kind: "task.connector.connection.set",
821
+ taskId: t,
822
+ value: n
328
823
  }];
329
824
  }
330
- function _(e, t, n, r) {
331
- let i = e.document.graph.nodes[n];
332
- if (i == null) return;
333
- let a = {
334
- ...r.description == null ? {} : { description: r.description },
335
- icon: i.icon,
336
- name: r.name
337
- }, o;
338
- switch (r.kind) {
339
- case "webhook":
340
- if (i.kind != "webhook") return;
341
- o = Object.keys(r.options).length == 0 ? {
342
- ...a,
343
- inputsDef: r.inputs,
344
- kind: "webhook"
345
- } : {
346
- ...a,
825
+ function D(e, t, n, r) {
826
+ let a = e.document.graph.nodes[n];
827
+ if (a == null) return;
828
+ let o = [];
829
+ switch (a.name != r.name && o.push({
830
+ before: a.name,
831
+ field: "name",
832
+ kind: "graph.node.field.set",
833
+ nodeId: n,
834
+ target: t,
835
+ value: r.name
836
+ }), a.description != r.description && o.push({
837
+ before: a.description,
838
+ field: "description",
839
+ kind: "graph.node.field.set",
840
+ nodeId: n,
841
+ target: t,
842
+ value: r.description
843
+ }), r.kind) {
844
+ case "webhook": {
845
+ if (a.kind != "webhook") return;
846
+ let e = {
347
847
  inputsDef: r.inputs,
348
- kind: "webhook",
349
- options: r.options
848
+ options: Object.keys(r.options).length == 0 ? void 0 : r.options
849
+ }, s = {
850
+ inputsDef: a.inputsDef,
851
+ options: a.options
350
852
  };
853
+ i(s, e) || o.push({
854
+ before: s,
855
+ kind: "graph.node.webhook.set",
856
+ nodeId: n,
857
+ target: t,
858
+ value: e
859
+ });
351
860
  break;
861
+ }
352
862
  case "cron":
353
- if (i.kind != "cron") return;
354
- o = {
355
- ...a,
356
- cronTimes: r.schedule,
357
- kind: "cron"
358
- };
863
+ if (a.kind != "cron") return;
864
+ i(a.cronTimes, r.schedule) || o.push({
865
+ before: a.cronTimes,
866
+ kind: "graph.trigger.schedule.set",
867
+ nodeId: n,
868
+ value: r.schedule
869
+ });
359
870
  break;
360
871
  case "poll":
361
- if (i.kind != "poll") return;
362
- o = {
363
- ...i,
364
- ...a,
365
- config: r.config,
366
- pollTimes: r.schedule
367
- };
872
+ if (a.kind != "poll") return;
873
+ for (let e of /* @__PURE__ */ new Set([...Object.keys(a.config), ...Object.keys(r.config)])) i(a.config[e], r.config[e]) || o.push({
874
+ before: a.config[e],
875
+ kind: "graph.trigger.config.set",
876
+ name: e,
877
+ nodeId: n,
878
+ value: r.config[e]
879
+ });
880
+ i(a.pollTimes, r.schedule) || o.push({
881
+ before: a.pollTimes,
882
+ kind: "graph.trigger.schedule.set",
883
+ nodeId: n,
884
+ value: r.schedule
885
+ });
368
886
  break;
369
887
  case "integration":
370
- if (i.kind != "integration") return;
371
- o = {
372
- ...i,
373
- ...a,
374
- config: r.config
375
- };
888
+ if (a.kind != "integration") return;
889
+ for (let e of /* @__PURE__ */ new Set([...Object.keys(a.config), ...Object.keys(r.config)])) i(a.config[e], r.config[e]) || o.push({
890
+ before: a.config[e],
891
+ kind: "graph.trigger.config.set",
892
+ name: e,
893
+ nodeId: n,
894
+ value: r.config[e]
895
+ });
376
896
  }
377
- return S(t, n, o);
897
+ return o;
378
898
  }
379
- function v(e, t, n, r) {
899
+ function O(e, t, n, r) {
380
900
  let i = e.document.graph.nodes[n];
381
- if (!(i == null || i.kind != "poll" && i.kind != "integration") && e.document.bindings[i.bindingId]?.kind == "connection") return [{
901
+ if (i == null || i.kind != "poll" && i.kind != "integration") return;
902
+ let a = e.document.bindings[i.bindingId];
903
+ if (a == null) return [{
382
904
  binding: {
383
905
  kind: "connection",
384
906
  target: r
385
907
  },
386
908
  bindingId: i.bindingId,
387
- kind: "binding.replace"
909
+ kind: "binding.create"
910
+ }];
911
+ if (a.kind == "connection") return a.target == r ? [] : [{
912
+ before: a.target,
913
+ bindingId: i.bindingId,
914
+ kind: "binding.target.set",
915
+ value: r
388
916
  }];
389
917
  }
390
- function y(e, t) {
918
+ function k(e, t) {
391
919
  return t.kind == "flow" ? e.document.graph : e.document.subflows[t.id]?.graph;
392
920
  }
393
- function b(e) {
394
- return Object.fromEntries(e.flatMap((e) => Object.hasOwn(e, "value") ? [[e.handle, {
921
+ function A(e) {
922
+ return Object.fromEntries(e.flatMap((e) => "handle" in e && Object.hasOwn(e, "value") ? [[e.handle, {
395
923
  kind: "value",
396
924
  value: e.value
397
925
  }]] : []));
398
926
  }
399
- function x(e, t, n) {
927
+ function j(e, t, n) {
400
928
  return e != null && Object.hasOwn(e, t) ? e[t] : n;
401
929
  }
402
- function S(e, t, n) {
930
+ //#endregion
931
+ //#region src/flow/common/edgeChanges.ts
932
+ function M(e, t, n) {
933
+ let r = {
934
+ source: n.source,
935
+ sourceHandle: n.sourceHandle,
936
+ target: n.target,
937
+ targetHandle: n.targetHandle
938
+ }, i = P(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
939
+ return a?.kind == "sources" && a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : w(e, [{
940
+ before: a,
941
+ edge: r,
942
+ kind: "graph.edge.connect",
943
+ target: t
944
+ }]);
945
+ }
946
+ function N(e, t, n) {
947
+ let r = {
948
+ source: n.source,
949
+ sourceHandle: n.sourceHandle,
950
+ target: n.target,
951
+ targetHandle: n.targetHandle
952
+ }, i = P(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
953
+ return a?.kind != "sources" || !a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : [{
954
+ before: a,
955
+ edge: r,
956
+ kind: "graph.edge.disconnect",
957
+ target: t
958
+ }];
959
+ }
960
+ function P(e, t) {
961
+ return t.kind == "flow" ? e.document.graph : e.document.subflows[t.id]?.graph;
962
+ }
963
+ //#endregion
964
+ //#region src/flow/common/moduleChanges.ts
965
+ async function F(e) {
966
+ try {
967
+ let { parse: t } = await import("./lib-GrGxYjsJ.js"), n = t(e, {
968
+ errorRecovery: !0,
969
+ sourceType: "module"
970
+ }).program, r = /* @__PURE__ */ new Set();
971
+ for (let e of n.body) {
972
+ if (e.type != "ImportDeclaration") continue;
973
+ let t = /^\.\/(.+)\.mjs$/.exec(e.source.value);
974
+ t?.[1] != null && r.add(t[1]);
975
+ }
976
+ return [...r].toSorted();
977
+ } catch {
978
+ return [];
979
+ }
980
+ }
981
+ function I(e, t, n, r, i) {
403
982
  return [{
404
- kind: "graph.node.replace",
405
- node: n,
406
- nodeId: t,
407
- target: e
983
+ beforeImports: n,
984
+ beforeSource: t,
985
+ imports: i,
986
+ kind: "module.source.replace",
987
+ moduleId: e,
988
+ source: r
989
+ }];
990
+ }
991
+ function L(e, t, n) {
992
+ return [{
993
+ before: t,
994
+ kind: "module.rename",
995
+ moduleId: e,
996
+ name: n
408
997
  }];
409
998
  }
999
+ var R = n("23456789abcdefghjkmnpqrstuvwxyz", 10);
410
1000
  //#endregion
411
- export { e as connect, d as createBuiltinTrigger, o as createCodeTask, l as createCondition, c as createLlmTask, s as createManagedTask, f as createProviderTrigger, u as createValue, p as deleteNodes, t as disconnect, r as moduleImports, a as renameModule, i as replaceModuleSource, g as setConnectorConnection, h as setInputValues, v as setTriggerConnection, m as updateSettings, _ as updateTrigger };
1001
+ export { w as cleanVariableBindings, M as connect, R as createAuthoringId, v as createBuiltinTrigger, f as createCodeTask, h as createCondition, m as createLlmTask, p as createManagedTask, y as createProviderTrigger, g as createValue, _ as createWait, b as deleteNodes, N as disconnect, F as moduleImports, L as renameModule, I as replaceModuleSource, E as setConnectorConnection, S as setInputValues, C as setInputVariable, O as setTriggerConnection, x as updateSettings, D as updateTrigger };