@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,6 +1,26 @@
1
+ //#region ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
2
+ var e = Object.prototype.hasOwnProperty;
3
+ function t(n, r) {
4
+ var i, a;
5
+ if (n === r) return !0;
6
+ if (n && r && (i = n.constructor) === r.constructor) {
7
+ if (i === Date) return n.getTime() === r.getTime();
8
+ if (i === RegExp) return n.toString() === r.toString();
9
+ if (i === Array) {
10
+ if ((a = n.length) === r.length) for (; a-- && t(n[a], r[a]););
11
+ return a === -1;
12
+ }
13
+ if (!i || typeof n == "object") {
14
+ for (i in a = 0, n) if (e.call(n, i) && ++a && !e.call(r, i) || !(i in r) || !t(n[i], r[i])) return !1;
15
+ return Object.keys(r).length === a;
16
+ }
17
+ }
18
+ return n !== n && r !== r;
19
+ }
20
+ //#endregion
1
21
  //#region src/flow/common/change.ts
2
- var e = 80;
3
- function t(e) {
22
+ var n = 80;
23
+ function r(e) {
4
24
  let t = e.trim();
5
25
  if (t.length == 0) return "empty";
6
26
  if (t.length > 80) return "tooLong";
@@ -10,25 +30,32 @@ function t(e) {
10
30
  }
11
31
  if (!/^[\p{L}\p{N}](?:[\p{L}\p{N} _-]*[\p{L}\p{N}])?$/u.test(t)) return "specialCharacter";
12
32
  }
13
- function n(e) {
14
- return Object.fromEntries(e.map((e) => [e.handle, e]));
33
+ function i(e) {
34
+ return e.length <= 256 && /^[A-Za-z_][A-Za-z0-9_]*$/.test(e) && e.slice(0, 3).toUpperCase() != "OO_";
15
35
  }
16
- var r = class extends Error {};
17
- function i() {
18
- throw new r();
36
+ function a(e) {
37
+ return Object.fromEntries(e.flatMap((e) => "handle" in e ? [[e.handle, e]] : []));
19
38
  }
20
- function a(e, t) {
39
+ var o = class extends Error {
40
+ constructor(e) {
41
+ super(e), this.name = "FlowChangeError";
42
+ }
43
+ };
44
+ function s(e) {
45
+ throw new o(e);
46
+ }
47
+ function c(e, t) {
21
48
  if (t.kind == "flow") return e.graph;
22
49
  let n = e.subflows[t.id];
23
- return n ?? i(), n.graph;
50
+ return n ?? s("The target Subflow does not exist."), n.graph;
24
51
  }
25
- function o(e, t, n) {
52
+ function l(e, t, n) {
26
53
  if (t.kind == "flow") return {
27
54
  ...e,
28
55
  graph: n
29
56
  };
30
57
  let r = e.subflows[t.id];
31
- return r ?? i(), {
58
+ return r ?? s("The target Subflow does not exist."), {
32
59
  ...e,
33
60
  subflows: {
34
61
  ...e.subflows,
@@ -39,7 +66,7 @@ function o(e, t, n) {
39
66
  }
40
67
  };
41
68
  }
42
- function s(e, t) {
69
+ function u(e, t) {
43
70
  if (!("inputs" in e)) return e;
44
71
  let n = { ...e.inputs };
45
72
  for (let [e, r] of Object.entries(n)) {
@@ -55,93 +82,129 @@ function s(e, t) {
55
82
  inputs: n
56
83
  };
57
84
  }
58
- function c(e, t) {
59
- let n = { ...e.document }, r = { ...e.modules };
60
- for (let e of t) switch (e.kind) {
85
+ function d(e, n) {
86
+ let r = { ...e.document }, i = { ...e.modules };
87
+ for (let e of n) switch (e.kind) {
61
88
  case "binding.create":
62
- n.bindings[e.bindingId] != null && i(), n.bindings = {
63
- ...n.bindings,
64
- [e.bindingId]: e.binding
65
- };
66
- break;
67
- case "binding.replace":
68
- n.bindings[e.bindingId] ?? i(), n.bindings = {
69
- ...n.bindings,
89
+ r.bindings[e.bindingId] != null && s("A Binding with this ID already exists."), r.bindings = {
90
+ ...r.bindings,
70
91
  [e.bindingId]: e.binding
71
92
  };
72
93
  break;
73
94
  case "binding.delete": {
74
- n.bindings[e.bindingId] ?? i();
75
- let t = { ...n.bindings };
76
- delete t[e.bindingId], n.bindings = t;
95
+ r.bindings[e.bindingId] ?? s("The Binding does not exist.");
96
+ let t = { ...r.bindings };
97
+ delete t[e.bindingId], r.bindings = t;
98
+ break;
99
+ }
100
+ case "binding.target.set": {
101
+ let t = r.bindings[e.bindingId];
102
+ t ?? s("The Binding does not exist."), t.target != e.before && s("The Binding target changed before this operation was applied."), r.bindings = {
103
+ ...r.bindings,
104
+ [e.bindingId]: {
105
+ ...t,
106
+ target: e.value
107
+ }
108
+ };
77
109
  break;
78
110
  }
79
111
  case "graph.edge.connect": {
80
- let t = a(n, e.target);
81
- t.nodes[e.edge.source] ?? i();
82
- let r = t.nodes[e.edge.target];
83
- (r == null || !("inputs" in r)) && i();
84
- let s = r.inputs[e.edge.targetHandle], c = {
112
+ let n = c(r, e.target);
113
+ n.nodes[e.edge.source] ?? s("The source Node does not exist.");
114
+ let i = n.nodes[e.edge.target];
115
+ (i == null || !("inputs" in i)) && s("The target Node does not accept inputs.");
116
+ let a = i.inputs[e.edge.targetHandle];
117
+ t(a, e.before) || s("The target input changed before this operation was applied.");
118
+ let o = {
85
119
  kind: "node",
86
120
  nodeId: e.edge.source,
87
121
  output: e.edge.sourceHandle
88
- }, l = s?.kind == "sources" ? s.sources : [];
89
- l.some((e) => e.kind == "node" && e.nodeId == c.nodeId && e.output == c.output) && i();
90
- let u = {
91
- ...r,
122
+ }, u = a?.kind == "sources" ? a.sources.filter((e) => e.kind != "binding" || r.bindings[e.bindingId]?.kind != "variable") : [];
123
+ u.some((e) => e.kind == "node" && e.nodeId == o.nodeId && e.output == o.output) && s("The Nodes are already connected.");
124
+ let d = {
125
+ ...i,
92
126
  inputs: {
93
- ...r.inputs,
127
+ ...i.inputs,
94
128
  [e.edge.targetHandle]: {
95
129
  kind: "sources",
96
- sources: [...l, c]
130
+ sources: [...u, o]
97
131
  }
98
132
  }
99
133
  };
100
- Object.assign(n, o(n, e.target, { nodes: {
101
- ...t.nodes,
102
- [e.edge.target]: u
134
+ Object.assign(r, l(r, e.target, { nodes: {
135
+ ...n.nodes,
136
+ [e.edge.target]: d
103
137
  } }));
104
138
  break;
105
139
  }
106
140
  case "graph.edge.disconnect": {
107
- let t = a(n, e.target), r = t.nodes[e.edge.target];
108
- (r == null || !("inputs" in r)) && i();
109
- let s = r.inputs[e.edge.targetHandle];
110
- s?.kind != "sources" && i();
111
- let c = s.sources.filter((t) => t.kind != "node" || t.nodeId != e.edge.source || t.output != e.edge.sourceHandle);
112
- c.length == s.sources.length && i();
113
- let l = { ...r.inputs };
114
- c.length == 0 ? delete l[e.edge.targetHandle] : l[e.edge.targetHandle] = {
141
+ let n = c(r, e.target), i = n.nodes[e.edge.target];
142
+ (i == null || !("inputs" in i)) && s("The target Node does not accept inputs.");
143
+ let a = i.inputs[e.edge.targetHandle];
144
+ (a?.kind != "sources" || !t(a, e.before)) && s("The target input changed before this operation was applied.");
145
+ let o = a.sources.filter((t) => t.kind != "node" || t.nodeId != e.edge.source || t.output != e.edge.sourceHandle);
146
+ o.length == a.sources.length && s("The Nodes are not connected.");
147
+ let u = { ...i.inputs };
148
+ o.length == 0 ? delete u[e.edge.targetHandle] : u[e.edge.targetHandle] = {
115
149
  kind: "sources",
116
- sources: c
117
- }, Object.assign(n, o(n, e.target, { nodes: {
118
- ...t.nodes,
150
+ sources: o
151
+ }, Object.assign(r, l(r, e.target, { nodes: {
152
+ ...n.nodes,
119
153
  [e.edge.target]: {
120
- ...r,
121
- inputs: l
154
+ ...i,
155
+ inputs: u
122
156
  }
123
157
  } }));
124
158
  break;
125
159
  }
160
+ case "graph.node.additional-inputs.set": {
161
+ let n = c(r, e.target), i = n.nodes[e.nodeId];
162
+ i?.kind != "task" && s("The Task Node does not exist."), t(i.additionalInputs, e.before) || s("The Task Node inputs changed before this operation was applied.");
163
+ let { additionalInputs: a, ...o } = i, u = e.value == null ? o : {
164
+ ...o,
165
+ additionalInputs: e.value
166
+ };
167
+ Object.assign(r, l(r, e.target, { nodes: {
168
+ ...n.nodes,
169
+ [e.nodeId]: u
170
+ } }));
171
+ break;
172
+ }
173
+ case "graph.node.condition.set": {
174
+ let n = c(r, e.target), i = n.nodes[e.nodeId];
175
+ i?.kind != "condition" && s("The Condition Node does not exist."), (!t(i.cases, e.before.cases) || i.defaultOutput != e.before.defaultOutput || !t(i.input, e.before.input)) && s("The Condition Node changed before this operation was applied.");
176
+ let { defaultOutput: a, ...o } = i, u = e.value.defaultOutput == null ? {
177
+ ...o,
178
+ ...e.value
179
+ } : {
180
+ ...i,
181
+ ...e.value
182
+ };
183
+ Object.assign(r, l(r, e.target, { nodes: {
184
+ ...n.nodes,
185
+ [e.nodeId]: u
186
+ } }));
187
+ break;
188
+ }
126
189
  case "graph.node.create": {
127
- let t = a(n, e.target);
128
- (t.nodes[e.nodeId] != null || e.target.kind == "subflow" && !("inputs" in e.node)) && i(), Object.assign(n, o(n, e.target, { nodes: {
190
+ let t = c(r, e.target);
191
+ t.nodes[e.nodeId] != null && s("A Node with this ID already exists in the target graph."), e.target.kind == "subflow" && !("inputs" in e.node) && s("Trigger Nodes cannot be created inside a Subflow."), Object.assign(r, l(r, e.target, { nodes: {
129
192
  ...t.nodes,
130
193
  [e.nodeId]: e.node
131
194
  } }));
132
195
  break;
133
196
  }
134
197
  case "graph.node.delete": {
135
- let t = a(n, e.target);
136
- t.nodes[e.nodeId] ?? i();
137
- let r = /* @__PURE__ */ new Set([e.nodeId]), c = Object.fromEntries(Object.entries(t.nodes).flatMap(([e, t]) => r.has(e) ? [] : [[e, s(t, r)]]));
138
- if (Object.assign(n, o(n, e.target, { nodes: c })), e.target.kind == "subflow") {
139
- let t = n.subflows[e.target.id], i = t.outputs.map((e) => ({
198
+ let t = c(r, e.target);
199
+ t.nodes[e.nodeId] ?? s("The Node does not exist in the target graph.");
200
+ let n = /* @__PURE__ */ new Set([e.nodeId]), i = Object.fromEntries(Object.entries(t.nodes).flatMap(([e, t]) => n.has(e) ? [] : [[e, u(t, n)]]));
201
+ if (Object.assign(r, l(r, e.target, { nodes: i })), e.target.kind == "subflow") {
202
+ let t = r.subflows[e.target.id], i = t.outputs.map((e) => ({
140
203
  ...e,
141
- sources: e.sources.filter((e) => e.kind != "node" || !r.has(e.nodeId))
204
+ sources: e.sources.filter((e) => e.kind != "node" || !n.has(e.nodeId))
142
205
  }));
143
- n.subflows = {
144
- ...n.subflows,
206
+ r.subflows = {
207
+ ...r.subflows,
145
208
  [e.target.id]: {
146
209
  ...t,
147
210
  outputs: i
@@ -150,82 +213,249 @@ function c(e, t) {
150
213
  }
151
214
  break;
152
215
  }
153
- case "graph.node.replace": {
154
- let t = a(n, e.target);
155
- (t.nodes[e.nodeId] == null || e.target.kind == "subflow" && !("inputs" in e.node)) && i(), Object.assign(n, o(n, e.target, { nodes: {
216
+ case "graph.node.field.set": {
217
+ let n = c(r, e.target), i = n.nodes[e.nodeId];
218
+ i ?? s("The Node does not exist in the target graph."), t(Reflect.get(i, e.field), e.before) || s("The Node field changed before this operation was applied."), e.field == "concurrency" && e.value == null && s("Node concurrency cannot be removed.");
219
+ let a = { ...i };
220
+ e.value == null ? Reflect.deleteProperty(a, e.field) : Object.assign(a, { [e.field]: e.value }), Object.assign(r, l(r, e.target, { nodes: {
221
+ ...n.nodes,
222
+ [e.nodeId]: a
223
+ } }));
224
+ break;
225
+ }
226
+ case "graph.node.input.set": {
227
+ let n = c(r, e.target), i = n.nodes[e.nodeId];
228
+ (i == null || !("inputs" in i)) && s("The Node does not accept inputs."), t(i.inputs[e.handle], e.before) || s("The Node input changed before this operation was applied.");
229
+ let a = { ...i.inputs };
230
+ e.value == null ? delete a[e.handle] : a[e.handle] = e.value, Object.assign(r, l(r, e.target, { nodes: {
231
+ ...n.nodes,
232
+ [e.nodeId]: {
233
+ ...i,
234
+ inputs: a
235
+ }
236
+ } }));
237
+ break;
238
+ }
239
+ case "graph.node.task.name.set": {
240
+ let t = c(r, e.target), n = t.nodes[e.nodeId];
241
+ (n?.kind != "task" || n.task == null) && s("The inline Task Node does not exist."), n.task.name != e.before && s("The inline Task name changed before this operation was applied.");
242
+ let i = {
243
+ ...n,
244
+ task: {
245
+ ...n.task,
246
+ name: e.value
247
+ }
248
+ };
249
+ Object.assign(r, l(r, e.target, { nodes: {
156
250
  ...t.nodes,
157
- [e.nodeId]: e.node
251
+ [e.nodeId]: i
158
252
  } }));
159
253
  break;
160
254
  }
255
+ case "graph.node.task.ports.set": {
256
+ let n = c(r, e.target), i = n.nodes[e.nodeId];
257
+ (i?.kind != "task" || i.task == null) && s("The inline Task Node does not exist."), t({
258
+ inputs: i.task.inputs,
259
+ outputs: i.task.outputs
260
+ }, e.before) || s("The inline Task ports changed before this operation was applied.");
261
+ let a = {
262
+ ...i,
263
+ task: {
264
+ ...i.task,
265
+ ...e.value
266
+ }
267
+ };
268
+ Object.assign(r, l(r, e.target, { nodes: {
269
+ ...n.nodes,
270
+ [e.nodeId]: a
271
+ } }));
272
+ break;
273
+ }
274
+ case "graph.node.values.set": {
275
+ let n = c(r, e.target), i = n.nodes[e.nodeId];
276
+ i?.kind != "value" && s("The Value Node does not exist."), t(i.values, e.before) || s("The Value Node changed before this operation was applied."), Object.assign(r, l(r, e.target, { nodes: {
277
+ ...n.nodes,
278
+ [e.nodeId]: {
279
+ ...i,
280
+ values: e.value
281
+ }
282
+ } }));
283
+ break;
284
+ }
285
+ case "graph.node.wait.set": {
286
+ let n = r.graph, i = n.nodes[e.nodeId];
287
+ (i?.kind != "wait" || !t({
288
+ actions: i.actions,
289
+ ...i.notification == null ? {} : { notification: i.notification },
290
+ prompt: i.prompt
291
+ }, e.before)) && s("The Wait Node changed before this operation was applied.");
292
+ let { notification: a, ...o } = i, c = e.value.notification == null ? {
293
+ ...o,
294
+ ...e.value
295
+ } : {
296
+ ...i,
297
+ ...e.value
298
+ };
299
+ r.graph = { nodes: {
300
+ ...n.nodes,
301
+ [e.nodeId]: c
302
+ } };
303
+ break;
304
+ }
305
+ case "graph.node.webhook.set": {
306
+ let n = c(r, e.target), i = n.nodes[e.nodeId];
307
+ i?.kind != "webhook" && s("The Webhook Node does not exist."), (!t(i.inputsDef, e.before.inputsDef) || !t(i.options, e.before.options)) && s("The Webhook Node changed before this operation was applied.");
308
+ let { options: a, ...o } = i, u = e.value.options == null ? {
309
+ ...o,
310
+ inputsDef: e.value.inputsDef
311
+ } : {
312
+ ...i,
313
+ ...e.value
314
+ };
315
+ Object.assign(r, l(r, e.target, { nodes: {
316
+ ...n.nodes,
317
+ [e.nodeId]: u
318
+ } }));
319
+ break;
320
+ }
321
+ case "graph.trigger.config.set": {
322
+ let n = r.graph, i = n.nodes[e.nodeId];
323
+ (i == null || i.kind != "integration" && i.kind != "poll") && s("The configurable Trigger Node does not exist."), t(i.config[e.name], e.before) || s("The Trigger configuration changed before this operation was applied.");
324
+ let a = { ...i.config };
325
+ e.value === void 0 ? delete a[e.name] : a[e.name] = e.value, r.graph = { nodes: {
326
+ ...n.nodes,
327
+ [e.nodeId]: {
328
+ ...i,
329
+ config: a
330
+ }
331
+ } };
332
+ break;
333
+ }
334
+ case "graph.trigger.schedule.set": {
335
+ let n = r.graph, i = n.nodes[e.nodeId];
336
+ (i == null || i.kind != "cron" && i.kind != "poll") && s("The scheduled Trigger Node does not exist."), t(i.kind == "cron" ? i.cronTimes : i.pollTimes, e.before) || s("The Trigger schedule changed before this operation was applied.");
337
+ let a = i.kind == "cron" ? {
338
+ ...i,
339
+ cronTimes: e.value
340
+ } : {
341
+ ...i,
342
+ pollTimes: e.value
343
+ };
344
+ r.graph = { nodes: {
345
+ ...n.nodes,
346
+ [e.nodeId]: a
347
+ } };
348
+ break;
349
+ }
161
350
  case "module.create":
162
- r[e.moduleId] != null && i(), r[e.moduleId] = e.module;
351
+ i[e.moduleId] != null && s("A CodeModule with this ID already exists."), i[e.moduleId] = e.module;
163
352
  break;
164
353
  case "module.delete":
165
- r[e.moduleId] ?? i(), delete r[e.moduleId];
354
+ i[e.moduleId] ?? s("The CodeModule does not exist."), delete i[e.moduleId];
166
355
  break;
167
356
  case "module.rename": {
168
- let t = r[e.moduleId];
169
- t ?? i(), r[e.moduleId] = {
357
+ let t = i[e.moduleId];
358
+ t ?? s("The CodeModule does not exist."), t.name != e.before && s("The CodeModule name changed before this operation was applied."), i[e.moduleId] = {
170
359
  ...t,
171
360
  name: e.name
172
361
  };
173
362
  break;
174
363
  }
175
364
  case "module.source.replace": {
176
- let t = r[e.moduleId];
177
- t ?? i(), r[e.moduleId] = {
178
- ...t,
365
+ let n = i[e.moduleId];
366
+ n ?? s("The CodeModule does not exist."), (n.source != e.beforeSource || !t(n.imports, e.beforeImports)) && s("The CodeModule source changed before this operation was applied."), i[e.moduleId] = {
367
+ ...n,
179
368
  imports: e.imports,
180
369
  source: e.source
181
370
  };
182
371
  break;
183
372
  }
184
373
  case "subflow.create":
185
- n.subflows[e.subflowId] != null && i(), n.subflows = {
186
- ...n.subflows,
374
+ r.subflows[e.subflowId] != null && s("A Subflow with this ID already exists."), r.subflows = {
375
+ ...r.subflows,
187
376
  [e.subflowId]: e.subflow
188
377
  };
189
378
  break;
190
- case "subflow.definition.replace": {
191
- let t = n.subflows[e.subflowId];
192
- t ?? i(), n.subflows = {
193
- ...n.subflows,
379
+ case "subflow.definition.set": {
380
+ let n = r.subflows[e.subflowId];
381
+ n ?? s("The Subflow does not exist."), t({
382
+ inputs: n.inputs,
383
+ name: n.name,
384
+ outputs: n.outputs
385
+ }, e.before) || s("The Subflow definition changed before this operation was applied."), r.subflows = {
386
+ ...r.subflows,
194
387
  [e.subflowId]: {
195
388
  ...e.definition,
196
- graph: t.graph
389
+ graph: n.graph
197
390
  }
198
391
  };
199
392
  break;
200
393
  }
201
394
  case "subflow.delete": {
202
- n.subflows[e.subflowId] ?? i();
203
- let t = { ...n.subflows };
204
- delete t[e.subflowId], n.subflows = t;
395
+ r.subflows[e.subflowId] ?? s("The Subflow does not exist.");
396
+ let t = { ...r.subflows };
397
+ delete t[e.subflowId], r.subflows = t;
205
398
  break;
206
399
  }
207
400
  case "task.create":
208
- n.tasks[e.taskId] != null && i(), n.tasks = {
209
- ...n.tasks,
401
+ r.tasks[e.taskId] != null && s("A Task with this ID already exists."), r.tasks = {
402
+ ...r.tasks,
210
403
  [e.taskId]: e.task
211
404
  };
212
405
  break;
406
+ case "task.connector.connection.set": {
407
+ let t = r.tasks[e.taskId];
408
+ (t == null || !("executor" in t) || t.executor.kind != "connector") && s("The Connector Task does not exist."), t.executor.connectionId != e.before && s("The Connector Task connection changed before this operation was applied.");
409
+ let { connectionId: n, ...i } = t.executor, a = e.value == null ? i : {
410
+ ...i,
411
+ connectionId: e.value
412
+ };
413
+ r.tasks = {
414
+ ...r.tasks,
415
+ [e.taskId]: {
416
+ ...t,
417
+ executor: a
418
+ }
419
+ };
420
+ break;
421
+ }
213
422
  case "task.delete": {
214
- n.tasks[e.taskId] ?? i();
215
- let t = { ...n.tasks };
216
- delete t[e.taskId], n.tasks = t;
423
+ r.tasks[e.taskId] ?? s("The Task does not exist.");
424
+ let t = { ...r.tasks };
425
+ delete t[e.taskId], r.tasks = t;
426
+ break;
427
+ }
428
+ case "task.llm.mode.set": {
429
+ let t = r.tasks[e.taskId];
430
+ (t == null || !("executor" in t) || t.executor.kind != "llm") && s("The LLM Task does not exist."), t.executor.mode != e.before && s("The LLM Task mode changed before this operation was applied."), r.tasks = {
431
+ ...r.tasks,
432
+ [e.taskId]: {
433
+ ...t,
434
+ executor: {
435
+ ...t.executor,
436
+ mode: e.value
437
+ }
438
+ }
439
+ };
440
+ break;
441
+ }
442
+ case "task.name.set": {
443
+ let t = r.tasks[e.taskId];
444
+ t ?? s("The Task does not exist."), t.name != e.before && s("The Task name changed before this operation was applied."), r.tasks = {
445
+ ...r.tasks,
446
+ [e.taskId]: {
447
+ ...t,
448
+ name: e.value
449
+ }
450
+ };
217
451
  break;
218
452
  }
219
- case "task.replace": n.tasks[e.taskId] ?? i(), n.tasks = {
220
- ...n.tasks,
221
- [e.taskId]: e.task
222
- };
223
453
  }
224
454
  return {
225
- document: n,
455
+ document: r,
226
456
  modelVersion: e.modelVersion,
227
- modules: r
457
+ modules: i
228
458
  };
229
459
  }
230
460
  //#endregion
231
- export { r as FlowChangeError, c as applyFlowChanges, n as portsByHandle, t as resourceNameIssue, e as resourceNameMaxLength };
461
+ export { o as FlowChangeError, d as applyFlowChanges, a as portsByHandle, r as resourceNameIssue, n as resourceNameMaxLength, i as validVariableName };
@@ -12,4 +12,9 @@ export type FlowChangeEvent = {
12
12
  readonly kind: 'run.created';
13
13
  readonly runId: string;
14
14
  readonly version: 1;
15
+ } | {
16
+ readonly flowId: string;
17
+ readonly kind: 'run.changed';
18
+ readonly runId: string;
19
+ readonly version: 1;
15
20
  };