@oomol-lab/open-flow 0.1.0-beta.1 → 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 (54) hide show
  1. package/dist/browser/DesignerIcon-DjgOMYI5.js +2065 -0
  2. package/dist/browser/{createResourceDialog-DXQz0thK.js → createResourceDialog-DNBueSYZ.js} +161 -160
  3. package/dist/browser/{dist-BMqL-qR5.js → dist-BMRLCebL.js} +291 -292
  4. package/dist/browser/{dist-DWADUsVB.js → dist-By46o5UV.js} +47 -47
  5. package/dist/browser/dist-CP0883sY.js +4 -0
  6. package/dist/browser/{dist-CJpzJrLM.js → dist-Cc0y2Pli.js} +811 -812
  7. package/dist/browser/{dist-DUzA0Ukh.js → dist-Dg_VXC8f.js} +134 -135
  8. package/dist/browser/{dist-3Mj8q8Pr.js → dist-DmuE3M0R.js} +53 -54
  9. package/dist/browser/{dist-BN4ZCyOB.js → dist-DpDLsYtO.js} +14 -15
  10. package/dist/browser/dist-DxahK_I8.js +2688 -0
  11. package/dist/browser/{dist-CPuF50D9.js → dist-meg_oHVR.js} +335 -335
  12. package/dist/browser/{esm-DGQbgYoJ.js → esm-yhVU_KbQ.js} +5 -6
  13. package/dist/browser/flow-authoring-module.d.ts +2 -2
  14. package/dist/browser/flow-authoring-node.d.ts +6 -3
  15. package/dist/browser/flow-authoring.d.ts +1 -1
  16. package/dist/browser/flow-authoring.js +509 -209
  17. package/dist/browser/flow-change.d.ts +113 -9
  18. package/dist/browser/flow-change.js +323 -96
  19. package/dist/browser/flow-notifications.d.ts +5 -0
  20. package/dist/browser/flowChanges-B2ttnaj9.js +12265 -0
  21. package/dist/browser/{flowRunInputEditorStore-BeyUSWpO.js → flowRunInputEditorStore-DDidwd8h.js} +728 -719
  22. package/dist/browser/{flowWorkspace-DwyxAOBH.js → flowWorkspace-Dr8-Hut9.js} +40821 -42895
  23. package/dist/browser/{getPseudoElementBounds-ESJExRFX.js → getPseudoElementBounds-5LArT6Xc.js} +1827 -2322
  24. package/dist/browser/icons-KIOgjHpD.js +730 -0
  25. package/dist/browser/{markdownContent-DdlIRN3_.js → markdownContent-DUfLdnUt.js} +1 -1
  26. package/dist/browser/{typeScriptSession-mPCiA9sV.js → typeScriptSession-_TgJ_7Oq.js} +256 -257
  27. package/dist/browser/waitNotificationInputs-BPulOxYt.js +26 -0
  28. package/dist/browser/workbench.css +1 -1
  29. package/dist/browser/workbench.d.ts +3 -1
  30. package/dist/browser/workbench.js +1136 -1038
  31. package/dist/browser/{workbenchSelect-B2s1HV-Y.js → workbenchSelect-CbXrdwxW.js} +479 -478
  32. package/dist/common/control-api-conformance.d.ts +1 -0
  33. package/dist/common/control-api-conformance.js +126 -47
  34. package/dist/common/control-api-errors.d.ts +12 -0
  35. package/dist/common/control-api.d.ts +60 -15
  36. package/dist/common/control-api.js +225 -101
  37. package/dist/common/flow-encoding.js +24 -8
  38. package/dist/common/flow-notifications.d.ts +5 -0
  39. package/dist/common/flow-semantics.d.ts +1 -0
  40. package/dist/common/flow-semantics.js +3464 -1113
  41. package/dist/common/integration-trigger.d.ts +1 -0
  42. package/dist/common/provider-triggers.js +4 -1
  43. package/dist/common/run-events.js +2 -1
  44. package/dist/common/run-lifecycle.d.ts +17 -2
  45. package/dist/common/run-lifecycle.js +53 -2
  46. package/dist/common/runtime-contract.d.ts +1 -1
  47. package/dist/common/runtime-contract.js +27 -0
  48. package/dist/common/scheduler.d.ts +65 -4
  49. package/dist/common/scheduler.js +420 -146
  50. package/dist/index.d.ts +2 -1
  51. package/package.json +1 -1
  52. package/dist/browser/diagnostics-BGoGFvHA.js +0 -9237
  53. package/dist/browser/dist-BpopSHwP.js +0 -1543
  54. package/dist/browser/dist-CUSrALSX.js +0 -1620
@@ -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,28 +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) {
33
+ function i(e) {
14
34
  return e.length <= 256 && /^[A-Za-z_][A-Za-z0-9_]*$/.test(e) && e.slice(0, 3).toUpperCase() != "OO_";
15
35
  }
16
- function r(e) {
36
+ function a(e) {
17
37
  return Object.fromEntries(e.flatMap((e) => "handle" in e ? [[e.handle, e]] : []));
18
38
  }
19
- var i = class extends Error {};
20
- function a() {
21
- throw new i();
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);
22
46
  }
23
- function o(e, t) {
47
+ function c(e, t) {
24
48
  if (t.kind == "flow") return e.graph;
25
49
  let n = e.subflows[t.id];
26
- return n ?? a(), n.graph;
50
+ return n ?? s("The target Subflow does not exist."), n.graph;
27
51
  }
28
- function s(e, t, n) {
52
+ function l(e, t, n) {
29
53
  if (t.kind == "flow") return {
30
54
  ...e,
31
55
  graph: n
32
56
  };
33
57
  let r = e.subflows[t.id];
34
- return r ?? a(), {
58
+ return r ?? s("The target Subflow does not exist."), {
35
59
  ...e,
36
60
  subflows: {
37
61
  ...e.subflows,
@@ -42,7 +66,7 @@ function s(e, t, n) {
42
66
  }
43
67
  };
44
68
  }
45
- function c(e, t) {
69
+ function u(e, t) {
46
70
  if (!("inputs" in e)) return e;
47
71
  let n = { ...e.inputs };
48
72
  for (let [e, r] of Object.entries(n)) {
@@ -58,93 +82,129 @@ function c(e, t) {
58
82
  inputs: n
59
83
  };
60
84
  }
61
- function l(e, t) {
62
- let n = { ...e.document }, r = { ...e.modules };
63
- 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) {
64
88
  case "binding.create":
65
- n.bindings[e.bindingId] != null && a(), n.bindings = {
66
- ...n.bindings,
67
- [e.bindingId]: e.binding
68
- };
69
- break;
70
- case "binding.replace":
71
- n.bindings[e.bindingId] ?? a(), n.bindings = {
72
- ...n.bindings,
89
+ r.bindings[e.bindingId] != null && s("A Binding with this ID already exists."), r.bindings = {
90
+ ...r.bindings,
73
91
  [e.bindingId]: e.binding
74
92
  };
75
93
  break;
76
94
  case "binding.delete": {
77
- n.bindings[e.bindingId] ?? a();
78
- let t = { ...n.bindings };
79
- 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
+ };
80
109
  break;
81
110
  }
82
111
  case "graph.edge.connect": {
83
- let t = o(n, e.target);
84
- t.nodes[e.edge.source] ?? a();
85
- let r = t.nodes[e.edge.target];
86
- (r == null || !("inputs" in r)) && a();
87
- let i = 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 = {
88
119
  kind: "node",
89
120
  nodeId: e.edge.source,
90
121
  output: e.edge.sourceHandle
91
- }, l = i?.kind == "sources" ? i.sources.filter((e) => e.kind != "binding" || n.bindings[e.bindingId]?.kind != "variable") : [];
92
- l.some((e) => e.kind == "node" && e.nodeId == c.nodeId && e.output == c.output) && a();
93
- let u = {
94
- ...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,
95
126
  inputs: {
96
- ...r.inputs,
127
+ ...i.inputs,
97
128
  [e.edge.targetHandle]: {
98
129
  kind: "sources",
99
- sources: [...l, c]
130
+ sources: [...u, o]
100
131
  }
101
132
  }
102
133
  };
103
- Object.assign(n, s(n, e.target, { nodes: {
104
- ...t.nodes,
105
- [e.edge.target]: u
134
+ Object.assign(r, l(r, e.target, { nodes: {
135
+ ...n.nodes,
136
+ [e.edge.target]: d
106
137
  } }));
107
138
  break;
108
139
  }
109
140
  case "graph.edge.disconnect": {
110
- let t = o(n, e.target), r = t.nodes[e.edge.target];
111
- (r == null || !("inputs" in r)) && a();
112
- let i = r.inputs[e.edge.targetHandle];
113
- i?.kind != "sources" && a();
114
- let c = i.sources.filter((t) => t.kind != "node" || t.nodeId != e.edge.source || t.output != e.edge.sourceHandle);
115
- c.length == i.sources.length && a();
116
- let l = { ...r.inputs };
117
- 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] = {
118
149
  kind: "sources",
119
- sources: c
120
- }, Object.assign(n, s(n, e.target, { nodes: {
121
- ...t.nodes,
150
+ sources: o
151
+ }, Object.assign(r, l(r, e.target, { nodes: {
152
+ ...n.nodes,
122
153
  [e.edge.target]: {
123
- ...r,
124
- inputs: l
154
+ ...i,
155
+ inputs: u
125
156
  }
126
157
  } }));
127
158
  break;
128
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
+ }
129
189
  case "graph.node.create": {
130
- let t = o(n, e.target);
131
- (t.nodes[e.nodeId] != null || e.target.kind == "subflow" && !("inputs" in e.node)) && a(), Object.assign(n, s(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: {
132
192
  ...t.nodes,
133
193
  [e.nodeId]: e.node
134
194
  } }));
135
195
  break;
136
196
  }
137
197
  case "graph.node.delete": {
138
- let t = o(n, e.target);
139
- t.nodes[e.nodeId] ?? a();
140
- let r = /* @__PURE__ */ new Set([e.nodeId]), i = Object.fromEntries(Object.entries(t.nodes).flatMap(([e, t]) => r.has(e) ? [] : [[e, c(t, r)]]));
141
- if (Object.assign(n, s(n, e.target, { nodes: i })), e.target.kind == "subflow") {
142
- 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) => ({
143
203
  ...e,
144
- 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))
145
205
  }));
146
- n.subflows = {
147
- ...n.subflows,
206
+ r.subflows = {
207
+ ...r.subflows,
148
208
  [e.target.id]: {
149
209
  ...t,
150
210
  outputs: i
@@ -153,82 +213,249 @@ function l(e, t) {
153
213
  }
154
214
  break;
155
215
  }
156
- case "graph.node.replace": {
157
- let t = o(n, e.target);
158
- (t.nodes[e.nodeId] == null || e.target.kind == "subflow" && !("inputs" in e.node)) && a(), Object.assign(n, s(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: {
159
250
  ...t.nodes,
160
- [e.nodeId]: e.node
251
+ [e.nodeId]: i
161
252
  } }));
162
253
  break;
163
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
+ }
164
350
  case "module.create":
165
- r[e.moduleId] != null && a(), r[e.moduleId] = e.module;
351
+ i[e.moduleId] != null && s("A CodeModule with this ID already exists."), i[e.moduleId] = e.module;
166
352
  break;
167
353
  case "module.delete":
168
- r[e.moduleId] ?? a(), delete r[e.moduleId];
354
+ i[e.moduleId] ?? s("The CodeModule does not exist."), delete i[e.moduleId];
169
355
  break;
170
356
  case "module.rename": {
171
- let t = r[e.moduleId];
172
- t ?? a(), 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] = {
173
359
  ...t,
174
360
  name: e.name
175
361
  };
176
362
  break;
177
363
  }
178
364
  case "module.source.replace": {
179
- let t = r[e.moduleId];
180
- t ?? a(), r[e.moduleId] = {
181
- ...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,
182
368
  imports: e.imports,
183
369
  source: e.source
184
370
  };
185
371
  break;
186
372
  }
187
373
  case "subflow.create":
188
- n.subflows[e.subflowId] != null && a(), n.subflows = {
189
- ...n.subflows,
374
+ r.subflows[e.subflowId] != null && s("A Subflow with this ID already exists."), r.subflows = {
375
+ ...r.subflows,
190
376
  [e.subflowId]: e.subflow
191
377
  };
192
378
  break;
193
- case "subflow.definition.replace": {
194
- let t = n.subflows[e.subflowId];
195
- t ?? a(), n.subflows = {
196
- ...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,
197
387
  [e.subflowId]: {
198
388
  ...e.definition,
199
- graph: t.graph
389
+ graph: n.graph
200
390
  }
201
391
  };
202
392
  break;
203
393
  }
204
394
  case "subflow.delete": {
205
- n.subflows[e.subflowId] ?? a();
206
- let t = { ...n.subflows };
207
- 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;
208
398
  break;
209
399
  }
210
400
  case "task.create":
211
- n.tasks[e.taskId] != null && a(), n.tasks = {
212
- ...n.tasks,
401
+ r.tasks[e.taskId] != null && s("A Task with this ID already exists."), r.tasks = {
402
+ ...r.tasks,
213
403
  [e.taskId]: e.task
214
404
  };
215
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
+ }
216
422
  case "task.delete": {
217
- n.tasks[e.taskId] ?? a();
218
- let t = { ...n.tasks };
219
- 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
+ };
220
451
  break;
221
452
  }
222
- case "task.replace": n.tasks[e.taskId] ?? a(), n.tasks = {
223
- ...n.tasks,
224
- [e.taskId]: e.task
225
- };
226
453
  }
227
454
  return {
228
- document: n,
455
+ document: r,
229
456
  modelVersion: e.modelVersion,
230
- modules: r
457
+ modules: i
231
458
  };
232
459
  }
233
460
  //#endregion
234
- export { i as FlowChangeError, l as applyFlowChanges, r as portsByHandle, t as resourceNameIssue, e as resourceNameMaxLength, n as validVariableName };
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
  };