@oomol-lab/open-flow 0.1.0-alpha.1 → 0.1.0-alpha.12
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/README.md +5 -1
- package/dist/browser/addNodeOptions-BYQXyUmQ.js +9571 -0
- package/dist/browser/carbon-DMCVsjHo.js +53 -0
- package/dist/browser/{project-change.js → change-7rp2OZLm.js} +16 -46
- package/dist/browser/createResourceDialog-CWD62rU0.js +467 -0
- package/dist/browser/{dist-o4dBuwiG.js → dist-3Mj8q8Pr.js} +28 -28
- package/dist/browser/{dist-CIq6ue3I.js → dist-BKuSVKCC.js} +1115 -1103
- package/dist/browser/{dist-DL0SDskM.js → dist-BMqL-qR5.js} +473 -906
- package/dist/browser/{dist-CLZJNoWB.js → dist-BN4ZCyOB.js} +10 -10
- package/dist/browser/{dist-zyY--HOV.js → dist-BpopSHwP.js} +3 -3
- package/dist/browser/dist-C46JByB-.js +252 -0
- package/dist/browser/{dist-BbyiRq3c.js → dist-CJpzJrLM.js} +294 -284
- package/dist/browser/{dist-Djd02JSy.js → dist-CPuF50D9.js} +198 -198
- package/dist/browser/{dist-CvcmLAMW.js → dist-CUSrALSX.js} +115 -115
- package/dist/browser/dist-CeSZ2xSM.js +444 -0
- package/dist/browser/{dist-7oZK9QXZ.js → dist-DMi8_lU3.js} +5 -5
- package/dist/browser/{dist-B9OV3YTx.js → dist-DUzA0Ukh.js} +22 -22
- package/dist/browser/{dist-aWSZx4q1.js → dist-DWADUsVB.js} +75 -75
- package/dist/browser/{dist-BLk5M0uK.js → dist-Mecbzdl2.js} +3 -3
- package/dist/browser/{esm-DXw7EADW.js → esm-DmVDlOEJ.js} +14 -24
- package/dist/browser/flow-authoring-edge.d.ts +3 -0
- package/dist/browser/flow-authoring-module.d.ts +4 -0
- package/dist/browser/flow-authoring-node.d.ts +86 -0
- package/dist/browser/flow-authoring.d.ts +4 -0
- package/dist/browser/flow-authoring.js +783 -0
- package/dist/browser/{project-change.d.ts → flow-change.d.ts} +29 -37
- package/dist/browser/flow-change.js +234 -0
- package/dist/browser/{project-notifications.d.ts → flow-notifications.d.ts} +6 -3
- package/dist/browser/flowRunInputEditorStore-BYxwvHZl.js +8952 -0
- package/dist/browser/flowWorkspace-Bwqmoq-c.js +47439 -0
- package/dist/browser/languages-DgJehE1g.js +62 -0
- package/dist/browser/lib-C5Ipyfps.js +7856 -0
- package/dist/browser/{lib-S4ccuMeT.js → lib-GrGxYjsJ.js} +3 -5
- package/dist/browser/licenses.md +620 -12
- package/dist/browser/main-DmjVyuWr.js +76 -0
- package/dist/browser/{markdownContent-ZZFfSRqO.js → markdownContent-0teWaxq8.js} +5188 -5144
- package/dist/browser/theme.css +63 -0
- package/dist/browser/theme.css.d.ts +1 -0
- package/dist/browser/typeScriptSession-D5neIpug.js +2560 -0
- package/dist/browser/{composite-7VwgfnXx.js → useOpenInteractionType-CRgOHg5M.js} +2209 -2750
- package/dist/browser/workbench-contract.d.ts +6 -6
- package/dist/browser/workbench.css +1 -1
- package/dist/browser/workbench.d.ts +18 -2
- package/dist/browser/workbench.js +4200 -2233
- package/dist/common/connector-action.d.ts +6 -0
- package/dist/common/connector-action.js +38 -30
- package/dist/common/control-api-conformance.js +262 -359
- package/dist/common/control-api-errors.d.ts +32 -24
- package/dist/common/control-api.d.ts +57 -73
- package/dist/common/control-api.js +199 -205
- package/dist/common/cron-trigger.d.ts +1 -1
- package/dist/common/cron-trigger.js +1 -1
- package/dist/common/flow-encoding.d.ts +11 -0
- package/dist/common/{project-encoding.js → flow-encoding.js} +14 -13
- package/dist/common/{project-notifications.d.ts → flow-notifications.d.ts} +6 -3
- package/dist/common/{project-semantics.d.ts → flow-semantics.d.ts} +11 -12
- package/dist/common/{project-semantics.js → flow-semantics.js} +959 -934
- package/dist/common/integration-trigger.d.ts +2 -1
- package/dist/common/integration-trigger.js +1 -1
- package/dist/common/licenses.md +1 -25
- package/dist/common/localization.d.ts +21 -0
- package/dist/common/localization.js +62 -0
- package/dist/common/poll-trigger.d.ts +1 -1
- package/dist/common/provider-triggers.js +1057 -948
- package/dist/common/run-lifecycle.js +1 -1
- package/dist/common/runtime-contract.d.ts +1 -1
- package/dist/common/runtime-contract.js +1 -1
- package/dist/common/scheduler.d.ts +8 -7
- package/dist/common/scheduler.js +251 -232
- package/dist/common/webhook-trigger.d.ts +1 -1
- package/dist/common/webhook-trigger.js +35 -1
- package/package.json +23 -10
- package/dist/browser/addNodeOptions-DqoIueCR.js +0 -33746
- package/dist/browser/carbon-nMY84Amv.js +0 -53
- package/dist/browser/createResourceDialog-ByuJWdSL.js +0 -439
- package/dist/browser/dist-n-z5HtaO.js +0 -4
- package/dist/browser/flowWorkspace-DwVMpcar.js +0 -22092
- package/dist/common/project-encoding.d.ts +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CodeModule, JsonValue } from '../browser/
|
|
1
|
+
import type { CodeModule, JsonValue } from '../browser/flow-change.js';
|
|
2
2
|
export { currentEngineContract, findEngineContract, type EngineContract } from './engine-contract.js';
|
|
3
3
|
export type RuntimeModule = Pick<CodeModule, 'imports' | 'source'>;
|
|
4
4
|
export interface RuntimeProgram {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ConnectorCapability, JsonValue } from '../browser/
|
|
2
|
-
import type { PreparedFlow } from './
|
|
1
|
+
import type { ConnectorCapability, JsonValue } from '../browser/flow-change.js';
|
|
2
|
+
import type { PreparedFlow } from './flow-semantics.js';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
3
4
|
export type SchedulerEvent = {
|
|
4
5
|
readonly flowId: string;
|
|
5
6
|
readonly parentJobId?: string;
|
|
@@ -69,7 +70,6 @@ interface TaskInvocationBase {
|
|
|
69
70
|
readonly jobId: string;
|
|
70
71
|
readonly nodeId: string;
|
|
71
72
|
readonly runId: string;
|
|
72
|
-
readonly signal: AbortSignal;
|
|
73
73
|
}
|
|
74
74
|
export type TaskInvocation = TaskInvocationBase & ({
|
|
75
75
|
readonly capabilities: readonly ConnectorCapability[];
|
|
@@ -86,14 +86,15 @@ export interface SchedulerFailure {
|
|
|
86
86
|
readonly message: string;
|
|
87
87
|
}
|
|
88
88
|
export interface FlowRunOptions {
|
|
89
|
+
readonly bindingValues?: Readonly<Record<string, string>>;
|
|
89
90
|
readonly createId: () => string;
|
|
90
|
-
readonly emit?: (event: SchedulerEvent) => void
|
|
91
|
+
readonly emit?: (event: SchedulerEvent) => Effect.Effect<void, Error>;
|
|
92
|
+
readonly flowId: string;
|
|
91
93
|
readonly inputs?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
|
|
92
|
-
readonly invokeTask: (invocation: TaskInvocation) =>
|
|
94
|
+
readonly invokeTask: (invocation: TaskInvocation) => Effect.Effect<unknown, Error>;
|
|
93
95
|
readonly projectFailure?: (error: unknown) => SchedulerFailure;
|
|
94
96
|
readonly runId: string;
|
|
95
|
-
readonly signal?: AbortSignal;
|
|
96
97
|
readonly trigger?: TriggerSeed;
|
|
97
98
|
}
|
|
98
|
-
export declare function runFlow(prepared: PreparedFlow, options: FlowRunOptions):
|
|
99
|
+
export declare function runFlow(prepared: PreparedFlow, options: FlowRunOptions): Effect.Effect<FlowRunResult, Error>;
|
|
99
100
|
export {};
|
package/dist/common/scheduler.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import * as e from "effect/Effect";
|
|
2
|
+
import * as t from "effect/Exit";
|
|
3
|
+
import * as n from "effect/FiberSet";
|
|
4
|
+
//#region src/flow/common/change.ts
|
|
5
|
+
function r(e) {
|
|
6
|
+
return Object.fromEntries(e.map((e) => [e.handle, e]));
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
1
9
|
//#region src/execution/common/scheduler.ts
|
|
2
|
-
function
|
|
10
|
+
function i(e, t) {
|
|
3
11
|
return t?.(e) ?? {
|
|
4
12
|
code: "node.failed",
|
|
5
13
|
message: e instanceof Error ? e.message : String(e)
|
|
6
14
|
};
|
|
7
15
|
}
|
|
8
|
-
var
|
|
16
|
+
var a = class {
|
|
9
17
|
#e = [];
|
|
10
18
|
#t = 0;
|
|
11
19
|
get length() {
|
|
@@ -18,9 +26,9 @@ var t = class {
|
|
|
18
26
|
let e = this.#e[this.#t];
|
|
19
27
|
return this.#t += 1, this.#t >= 64 && this.#t * 2 >= this.#e.length && (this.#e.splice(0, this.#t), this.#t = 0), e;
|
|
20
28
|
}
|
|
21
|
-
},
|
|
29
|
+
}, o = class {
|
|
22
30
|
#e;
|
|
23
|
-
#t = new
|
|
31
|
+
#t = new a();
|
|
24
32
|
#n;
|
|
25
33
|
#r;
|
|
26
34
|
constructor(e, t, n) {
|
|
@@ -42,13 +50,13 @@ var t = class {
|
|
|
42
50
|
take() {
|
|
43
51
|
return this.#t.length > 0 ? this.#t.shift() : this.#r;
|
|
44
52
|
}
|
|
45
|
-
},
|
|
53
|
+
}, s = class {
|
|
46
54
|
#e;
|
|
47
55
|
#t;
|
|
48
56
|
#n;
|
|
49
57
|
#r = !1;
|
|
50
|
-
constructor(e, t,
|
|
51
|
-
this.#t = e, this.#n = new Map(Object.entries(
|
|
58
|
+
constructor(e, t, n) {
|
|
59
|
+
this.#t = e, this.#n = new Map(Object.entries(n).map(([e, n]) => [e, new o(t, e, n)])), this.#e = [...this.#n.values()].some((e) => e.dynamic);
|
|
52
60
|
}
|
|
53
61
|
get ready() {
|
|
54
62
|
return (!this.#r || this.#e) && [...this.#n.values()].every((e) => e.ready);
|
|
@@ -67,15 +75,15 @@ var t = class {
|
|
|
67
75
|
return this.#e || (this.#r = !0), Object.fromEntries([...this.#n].map(([e, t]) => [e, t.take()]));
|
|
68
76
|
}
|
|
69
77
|
};
|
|
70
|
-
function
|
|
78
|
+
function c(e, t) {
|
|
71
79
|
switch (t.kind) {
|
|
72
80
|
case "condition": return { [t.input.handle]: t.input };
|
|
73
81
|
case "value": return {};
|
|
74
|
-
case "subflow": return e.subflows[t.subflowId].inputs;
|
|
75
|
-
case "task": return t.task == null ? e.tasks[t.taskId].inputs : t.task.inputs;
|
|
82
|
+
case "subflow": return r(e.subflows[t.subflowId].inputs);
|
|
83
|
+
case "task": return r(t.task == null ? e.tasks[t.taskId].inputs : t.task.inputs);
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
|
-
function
|
|
86
|
+
function l(e, t) {
|
|
79
87
|
if (t.name != null) return t.name;
|
|
80
88
|
switch (t.kind) {
|
|
81
89
|
case "condition": return;
|
|
@@ -84,17 +92,17 @@ function a(e, t) {
|
|
|
84
92
|
case "task": return t.task == null ? e.tasks[t.taskId].name : t.task.name;
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
|
-
function
|
|
95
|
+
function u(e, t) {
|
|
88
96
|
return t.kind == "task" ? t.task == null ? e.tasks[t.taskId].executor.kind : "javascript" : t.kind;
|
|
89
97
|
}
|
|
90
|
-
function
|
|
98
|
+
function d(e, t, n, r) {
|
|
91
99
|
let i = e.get(t) ?? /* @__PURE__ */ new Map(), a = i.get(n) ?? [];
|
|
92
100
|
a.push(r), i.set(n, a), e.set(t, i);
|
|
93
101
|
}
|
|
94
|
-
function
|
|
102
|
+
function f(e, t, n) {
|
|
95
103
|
return e.get(t)?.get(n) ?? [];
|
|
96
104
|
}
|
|
97
|
-
function
|
|
105
|
+
function p(e) {
|
|
98
106
|
let t = new Map(Object.entries(e.nodes).map(([t, n]) => [t, new Set(Object.values(n.inputs).flatMap((t) => t.kind == "sources" ? t.sources.flatMap((t) => t.kind == "node" && e.nodes[t.nodeId] != null ? [t.nodeId] : []) : []))])), n = [];
|
|
99
107
|
for (; t.size > 0;) {
|
|
100
108
|
let e = [...t].filter(([, e]) => e.size == 0).map(([e]) => e).toSorted();
|
|
@@ -104,18 +112,18 @@ function l(e) {
|
|
|
104
112
|
}
|
|
105
113
|
return n;
|
|
106
114
|
}
|
|
107
|
-
function
|
|
115
|
+
function m(e, t) {
|
|
108
116
|
if (e === t) return !0;
|
|
109
117
|
if (e == null || t == null || typeof e != "object" || typeof t != "object") return !1;
|
|
110
|
-
if (Array.isArray(e) || Array.isArray(t)) return Array.isArray(e) && Array.isArray(t) && e.length == t.length && e.every((e, n) =>
|
|
118
|
+
if (Array.isArray(e) || Array.isArray(t)) return Array.isArray(e) && Array.isArray(t) && e.length == t.length && e.every((e, n) => m(e, t[n]));
|
|
111
119
|
let n = Object.entries(e), r = Object.entries(t), i = t;
|
|
112
|
-
return n.length == r.length && n.every(([e, t]) => Object.hasOwn(i, e) &&
|
|
120
|
+
return n.length == r.length && n.every(([e, t]) => Object.hasOwn(i, e) && m(t, i[e]));
|
|
113
121
|
}
|
|
114
|
-
function
|
|
122
|
+
function h(e, t, n) {
|
|
115
123
|
let r = Object.hasOwn(n, t.input) ? n[t.input] : null, i = t.value;
|
|
116
124
|
switch (t.operator) {
|
|
117
|
-
case "==": return i !== void 0 &&
|
|
118
|
-
case "!=": return i !== void 0 && !
|
|
125
|
+
case "==": return i !== void 0 && m(r, i);
|
|
126
|
+
case "!=": return i !== void 0 && !m(r, i);
|
|
119
127
|
case ">": return typeof r == "number" && typeof i == "number" && r > i;
|
|
120
128
|
case ">=": return typeof r == "number" && typeof i == "number" && r >= i;
|
|
121
129
|
case "<": return typeof r == "number" && typeof i == "number" && r < i;
|
|
@@ -123,7 +131,7 @@ function d(e, t, n) {
|
|
|
123
131
|
case "contains":
|
|
124
132
|
case "notContains": {
|
|
125
133
|
let e;
|
|
126
|
-
return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) =>
|
|
134
|
+
return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) => m(e, i))), e == null ? !1 : t.operator == "contains" ? e : !e;
|
|
127
135
|
}
|
|
128
136
|
case "startsWith": return typeof r == "string" && typeof i == "string" && r.startsWith(i);
|
|
129
137
|
case "endsWith": return typeof r == "string" && typeof i == "string" && r.endsWith(i);
|
|
@@ -136,7 +144,7 @@ function d(e, t, n) {
|
|
|
136
144
|
case "hasValue":
|
|
137
145
|
case "notHasValue": {
|
|
138
146
|
if (r == null || Array.isArray(r) || typeof r != "object" || i === void 0) return !1;
|
|
139
|
-
let e = Object.values(r).some((e) =>
|
|
147
|
+
let e = Object.values(r).some((e) => m(e, i));
|
|
140
148
|
return t.operator == "hasValue" ? e : !e;
|
|
141
149
|
}
|
|
142
150
|
case "isEmpty":
|
|
@@ -150,230 +158,241 @@ function d(e, t, n) {
|
|
|
150
158
|
case "isFalse": return r === !1;
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
|
-
function
|
|
161
|
+
function g(e, t) {
|
|
154
162
|
if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`Node "${t}" must return an object.`);
|
|
155
163
|
return e;
|
|
156
164
|
}
|
|
157
|
-
function
|
|
158
|
-
return e.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}, (e) => {
|
|
168
|
-
t.removeEventListener("abort", i), r(e);
|
|
165
|
+
function _(a, o, m, v, b, x = {}, S, C) {
|
|
166
|
+
return e.scoped(e.gen(function* () {
|
|
167
|
+
yield* a.emit({
|
|
168
|
+
flowId: o.flowId,
|
|
169
|
+
...b == null ? {} : {
|
|
170
|
+
parentJobId: b.jobId,
|
|
171
|
+
parentRunId: b.runId
|
|
172
|
+
},
|
|
173
|
+
runId: m,
|
|
174
|
+
type: "run.started"
|
|
169
175
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
let r = T.get(t.input) ?? [];
|
|
185
|
-
r.push({
|
|
176
|
+
let w = p(o.graph), T = w.length, E = new Map(Object.entries(o.graph.nodes).map(([e, t]) => [e, new s(e, t, c(a.prepared, t))])), D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
|
|
177
|
+
for (let [e, t] of Object.entries(o.graph.nodes)) for (let [n, r] of Object.entries(t.inputs)) if (r.kind == "sources") for (let t of r.sources) if (t.kind == "binding") {
|
|
178
|
+
let r = O.get(t.bindingId) ?? [];
|
|
179
|
+
r.push({
|
|
180
|
+
handle: n,
|
|
181
|
+
nodeId: e
|
|
182
|
+
}), O.set(t.bindingId, r);
|
|
183
|
+
} else if (t.kind == "flow") {
|
|
184
|
+
let r = D.get(t.input) ?? [];
|
|
185
|
+
r.push({
|
|
186
|
+
handle: n,
|
|
187
|
+
nodeId: e
|
|
188
|
+
}), D.set(t.input, r);
|
|
189
|
+
} else t.kind == "node" && d(k, t.nodeId, t.output, {
|
|
186
190
|
handle: n,
|
|
187
191
|
nodeId: e
|
|
188
|
-
}), T.set(t.input, r);
|
|
189
|
-
} else t.kind == "node" && s(E, t.nodeId, t.output, {
|
|
190
|
-
handle: n,
|
|
191
|
-
nodeId: e
|
|
192
|
-
});
|
|
193
|
-
for (let [e, t] of Object.entries(n.outputs)) for (let n of t.sources) n.kind == "node" && s(D, n.nodeId, n.output, e);
|
|
194
|
-
let O = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set(), A = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Set(), P = new AbortController(), F = AbortSignal.any([g, P.signal]), I, L = !1, R, z = (e, t) => {
|
|
195
|
-
P.signal.aborted || (w.get(e.nodeId).push(e.handle, t), R(e.nodeId));
|
|
196
|
-
}, B = async (e, n, r, i) => {
|
|
197
|
-
await t.emit({
|
|
198
|
-
handle: r,
|
|
199
|
-
jobId: n,
|
|
200
|
-
nodeId: e,
|
|
201
|
-
runId: u,
|
|
202
|
-
type: "node.output",
|
|
203
|
-
value: i
|
|
204
192
|
});
|
|
205
|
-
for (let t of
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
193
|
+
for (let [e, t] of Object.entries(o.outputs)) for (let n of t.sources) n.kind == "node" && d(A, n.nodeId, n.output, e);
|
|
194
|
+
let j = /* @__PURE__ */ new Map(), M = yield* n.make(), N = yield* n.runtime(M)(), P = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Set(), R, z, B, V = (e, t) => {
|
|
195
|
+
R ?? (E.get(e.nodeId).push(e.handle, t), B(e.nodeId));
|
|
196
|
+
}, H = (t, n, r, i) => e.gen(function* () {
|
|
197
|
+
yield* a.emit({
|
|
198
|
+
handle: r,
|
|
199
|
+
jobId: n,
|
|
200
|
+
nodeId: t,
|
|
201
|
+
runId: m,
|
|
202
|
+
type: "node.output",
|
|
203
|
+
value: i
|
|
204
|
+
});
|
|
205
|
+
for (let e of f(k, t, r)) V(e, i);
|
|
206
|
+
for (let e of f(A, t, r)) I.set(e, i), S != null && (yield* S(e, i));
|
|
207
|
+
}), U = (t, n, i, o) => {
|
|
208
|
+
let s = e.gen(function* () {
|
|
209
|
+
let s = u(a.prepared, n), c = l(a.prepared, n), d = Object.fromEntries(Object.entries(o).filter(([e]) => {
|
|
210
|
+
let t = n.inputs[e];
|
|
211
|
+
return t?.kind != "sources" || t.sources.every((e) => e.kind != "binding");
|
|
212
|
+
}));
|
|
213
|
+
yield* a.emit({
|
|
214
|
+
inputs: d,
|
|
215
|
+
jobId: i,
|
|
216
|
+
nodeId: t,
|
|
217
|
+
nodeKind: s,
|
|
218
|
+
...c == null ? {} : { nodeTitle: c },
|
|
219
|
+
runId: m,
|
|
220
|
+
type: "node.started"
|
|
221
|
+
});
|
|
222
|
+
let f;
|
|
223
|
+
switch (n.kind) {
|
|
224
|
+
case "condition": {
|
|
225
|
+
let e = n.cases.find((e) => {
|
|
226
|
+
if (e.expressions.length == 0) return !1;
|
|
227
|
+
let t = e.expressions.map((e) => h(n, e, o));
|
|
228
|
+
return e.relation == "all" ? t.every(Boolean) : t.some(Boolean);
|
|
229
|
+
})?.output ?? n.defaultOutput;
|
|
230
|
+
f = e == null ? {} : { [e]: o[n.input.handle] ?? null }, e != null && (yield* H(t, i, e, f[e]));
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
case "value":
|
|
234
|
+
f = Object.fromEntries(n.values.map((e) => [e.handle, e.value ?? null]));
|
|
235
|
+
for (let [e, n] of Object.entries(f)) yield* H(t, i, e, n);
|
|
236
|
+
break;
|
|
237
|
+
case "subflow": {
|
|
238
|
+
let e = a.prepared.subflows[n.subflowId];
|
|
239
|
+
f = yield* _(a, {
|
|
240
|
+
flowId: n.subflowId,
|
|
241
|
+
graph: y(e.graph),
|
|
242
|
+
inputs: r(e.inputs),
|
|
243
|
+
kind: "subflow",
|
|
244
|
+
outputs: r(e.outputs)
|
|
245
|
+
}, a.createId(), o, {
|
|
246
|
+
jobId: i,
|
|
247
|
+
runId: m
|
|
248
|
+
}, {}, (e, n) => H(t, i, e, n));
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
case "task": {
|
|
252
|
+
let r = yield* a.invokeTask({
|
|
253
|
+
input: o,
|
|
254
|
+
invocationId: a.createId(),
|
|
255
|
+
jobId: i,
|
|
256
|
+
nodeId: t,
|
|
257
|
+
runId: m,
|
|
258
|
+
...n.task == null ? { taskId: n.taskId } : {
|
|
259
|
+
capabilities: n.task.capabilities ?? [],
|
|
260
|
+
moduleId: n.task.moduleId
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
f = yield* e.try({
|
|
264
|
+
try: () => g(r, t),
|
|
265
|
+
catch: (e) => e instanceof Error ? e : Error(String(e))
|
|
266
|
+
});
|
|
267
|
+
for (let [e, n] of Object.entries(f)) yield* H(t, i, e, n);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
248
270
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
271
|
+
return yield* a.emit({
|
|
272
|
+
jobId: i,
|
|
273
|
+
nodeId: t,
|
|
274
|
+
runId: m,
|
|
275
|
+
type: "node.completed"
|
|
276
|
+
}), f;
|
|
277
|
+
});
|
|
278
|
+
return n.timeoutMs == null ? s : s.pipe(e.timeoutOrElse({
|
|
279
|
+
duration: n.timeoutMs,
|
|
280
|
+
orElse: () => e.fail(/* @__PURE__ */ Error(`Node "${t}" timed out.`))
|
|
281
|
+
}));
|
|
282
|
+
}, W = (t) => {
|
|
283
|
+
let n = o.graph.nodes[t], r = E.get(t).take(), s = a.createId(), c = F.get(t) ?? 0;
|
|
284
|
+
F.set(t, c + 1), j.set(t, (j.get(t) ?? 0) + 1), N(U(t, n, s, r).pipe(e.tap((n) => e.gen(function* () {
|
|
285
|
+
let e = P.get(t) ?? [];
|
|
286
|
+
e.push({
|
|
287
|
+
jobId: s,
|
|
288
|
+
order: c,
|
|
289
|
+
outputs: n
|
|
290
|
+
}), P.set(t, e), L.has(t) || (L.add(t), yield* a.emit({
|
|
291
|
+
...b == null ? {} : {
|
|
292
|
+
parentJobId: b.jobId,
|
|
293
|
+
parentRunId: b.runId
|
|
294
|
+
},
|
|
295
|
+
progress: L.size / T * 100,
|
|
296
|
+
runId: m,
|
|
297
|
+
type: "run.progress"
|
|
298
|
+
}));
|
|
299
|
+
})), e.tapError((n) => e.gen(function* () {
|
|
300
|
+
R ?? (z ??= n);
|
|
301
|
+
let r = i(n, a.projectFailure);
|
|
302
|
+
yield* a.emit({
|
|
303
|
+
...r,
|
|
304
|
+
jobId: s,
|
|
305
|
+
nodeId: t,
|
|
306
|
+
runId: m,
|
|
307
|
+
type: "node.failed"
|
|
308
|
+
}).pipe(e.ignore);
|
|
309
|
+
})), e.tapCause((t) => e.sync(() => {
|
|
310
|
+
R ??= t;
|
|
311
|
+
})), e.ensuring(e.sync(() => {
|
|
312
|
+
j.set(t, (j.get(t) ?? 1) - 1), B(t);
|
|
313
|
+
}))));
|
|
314
|
+
};
|
|
315
|
+
B = (e) => {
|
|
316
|
+
if (R != null) return;
|
|
317
|
+
let t = o.graph.nodes[e], n = E.get(e);
|
|
318
|
+
for (; n.ready && (j.get(e) ?? 0) < t.concurrency;) W(e);
|
|
319
|
+
};
|
|
320
|
+
for (let [e, t] of Object.entries(x)) {
|
|
321
|
+
let n = E.get(e);
|
|
322
|
+
if (n != null) for (let [e, r] of Object.entries(t)) n.launch(e, r);
|
|
323
|
+
}
|
|
324
|
+
for (let [t, n] of O) {
|
|
325
|
+
if (!Object.hasOwn(a.bindingValues, t)) return yield* e.fail(/* @__PURE__ */ Error(`Variable binding "${t}" is unresolved.`));
|
|
326
|
+
for (let e of n) V(e, a.bindingValues[t]);
|
|
327
|
+
}
|
|
328
|
+
for (let [e, t] of Object.entries(o.inputs)) {
|
|
329
|
+
let n = Object.hasOwn(v, e) ? v[e] : t.value;
|
|
330
|
+
if (n !== void 0) {
|
|
331
|
+
for (let t of Object.entries(o.outputs)) t[1].sources.some((t) => t.kind == "flow" && t.input == e) && (I.set(t[0], n), S != null && (yield* S(t[0], n)));
|
|
332
|
+
for (let t of D.get(e) ?? []) V(t, n);
|
|
263
333
|
}
|
|
264
|
-
return await t.emit({
|
|
265
|
-
jobId: r,
|
|
266
|
-
nodeId: e,
|
|
267
|
-
runId: u,
|
|
268
|
-
type: "node.completed"
|
|
269
|
-
}), a;
|
|
270
|
-
} finally {
|
|
271
|
-
p != null && clearTimeout(p);
|
|
272
334
|
}
|
|
273
|
-
|
|
274
|
-
let
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
335
|
+
if (C != null) for (let e of f(k, C.nodeId, "payload")) V(e, C.payload);
|
|
336
|
+
for (let e of w) B(e);
|
|
337
|
+
let G = yield* e.raceFirst(n.awaitEmpty(M), n.join(M)).pipe(e.exit);
|
|
338
|
+
if (z != null) return yield* n.clear(M), yield* a.emit({
|
|
339
|
+
message: z.message,
|
|
340
|
+
runId: m,
|
|
341
|
+
type: "run.failed"
|
|
342
|
+
}).pipe(e.ignore), yield* e.fail(z);
|
|
343
|
+
if (R != null) return yield* n.clear(M), yield* e.failCause(R);
|
|
344
|
+
if (t.isFailure(G)) return yield* e.failCause(G.cause);
|
|
345
|
+
if (o.kind == "subflow") {
|
|
346
|
+
let e = Object.fromEntries(I);
|
|
347
|
+
return yield* a.emit({
|
|
348
|
+
result: {
|
|
349
|
+
kind: "function-outputs",
|
|
350
|
+
outputs: e,
|
|
351
|
+
target: "subflow"
|
|
287
352
|
},
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}));
|
|
292
|
-
}).catch(async (n) => {
|
|
293
|
-
L || (L = !0, I = n, P.abort(n));
|
|
294
|
-
let i = e(n, t.projectFailure);
|
|
295
|
-
await t.emit({
|
|
296
|
-
...i,
|
|
297
|
-
jobId: o,
|
|
298
|
-
nodeId: r,
|
|
299
|
-
runId: u,
|
|
300
|
-
type: "node.failed"
|
|
301
|
-
}).catch(() => void 0);
|
|
302
|
-
}).finally(() => {
|
|
303
|
-
k.delete(c), O.set(r, (O.get(r) ?? 1) - 1), R(r);
|
|
304
|
-
}), k.add(c);
|
|
305
|
-
};
|
|
306
|
-
R = (e) => {
|
|
307
|
-
if (P.signal.aborted) return;
|
|
308
|
-
let t = n.graph.nodes[e], r = w.get(e);
|
|
309
|
-
for (; r.ready && (O.get(e) ?? 0) < t.concurrency;) H(e);
|
|
310
|
-
};
|
|
311
|
-
for (let [e, t] of Object.entries(y)) {
|
|
312
|
-
let n = w.get(e);
|
|
313
|
-
if (n != null) for (let [e, r] of Object.entries(t)) n.launch(e, r);
|
|
314
|
-
}
|
|
315
|
-
for (let [e, t] of Object.entries(n.inputs)) {
|
|
316
|
-
let r = Object.hasOwn(p, e) ? p[e] : t.value;
|
|
317
|
-
if (r !== void 0) {
|
|
318
|
-
for (let t of Object.entries(n.outputs)) t[1].sources.some((t) => t.kind == "flow" && t.input == e) && (M.set(t[0], r), await b?.(t[0], r));
|
|
319
|
-
for (let t of T.get(e) ?? []) z(t, r);
|
|
353
|
+
runId: m,
|
|
354
|
+
type: "run.completed"
|
|
355
|
+
}), e;
|
|
320
356
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
kind: "function-outputs",
|
|
335
|
-
outputs: e,
|
|
336
|
-
target: "subflow"
|
|
337
|
-
},
|
|
338
|
-
runId: u,
|
|
357
|
+
let K = new Set(Object.values(o.graph.nodes).flatMap((e) => Object.values(e.inputs).flatMap((e) => e.kind == "sources" ? e.sources.filter((e) => e.kind == "node").map((e) => e.nodeId) : []))), q = {
|
|
358
|
+
kind: "node-results",
|
|
359
|
+
nodes: w.filter((e) => !K.has(e)).map((e) => ({
|
|
360
|
+
jobs: (P.get(e) ?? []).toSorted((e, t) => e.order - t.order).map(({ jobId: e, outputs: t }) => ({
|
|
361
|
+
jobId: e,
|
|
362
|
+
outputs: t
|
|
363
|
+
})),
|
|
364
|
+
nodeId: e
|
|
365
|
+
}))
|
|
366
|
+
};
|
|
367
|
+
return yield* a.emit({
|
|
368
|
+
result: q,
|
|
369
|
+
runId: m,
|
|
339
370
|
type: "run.completed"
|
|
340
|
-
}),
|
|
341
|
-
}
|
|
342
|
-
let U = new Set(Object.values(n.graph.nodes).flatMap((e) => Object.values(e.inputs).flatMap((e) => e.kind == "sources" ? e.sources.filter((e) => e.kind == "node").map((e) => e.nodeId) : []))), W = {
|
|
343
|
-
kind: "node-results",
|
|
344
|
-
nodes: S.filter((e) => !U.has(e)).map((e) => ({
|
|
345
|
-
jobs: (A.get(e) ?? []).toSorted((e, t) => e.order - t.order).map(({ jobId: e, outputs: t }) => ({
|
|
346
|
-
jobId: e,
|
|
347
|
-
outputs: t
|
|
348
|
-
})),
|
|
349
|
-
nodeId: e
|
|
350
|
-
}))
|
|
351
|
-
};
|
|
352
|
-
return await t.emit({
|
|
353
|
-
result: W,
|
|
354
|
-
runId: u,
|
|
355
|
-
type: "run.completed"
|
|
356
|
-
}), W;
|
|
371
|
+
}), q;
|
|
372
|
+
}));
|
|
357
373
|
}
|
|
358
|
-
|
|
359
|
-
let
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
function v(t, n) {
|
|
375
|
+
let r = n.emit ?? (() => e.void);
|
|
376
|
+
return e.gen(function* () {
|
|
377
|
+
let i = n.trigger == null ? void 0 : t.graph.nodes[n.trigger.nodeId];
|
|
378
|
+
return n.trigger != null && (i == null || "inputs" in i) ? yield* e.fail(/* @__PURE__ */ Error(`Node "${n.trigger.nodeId}" is not a TriggerNode in Flow "${n.flowId}".`)) : yield* _({
|
|
379
|
+
bindingValues: n.bindingValues ?? {},
|
|
380
|
+
createId: n.createId,
|
|
381
|
+
emit: r,
|
|
382
|
+
invokeTask: n.invokeTask,
|
|
383
|
+
prepared: t,
|
|
384
|
+
projectFailure: n.projectFailure
|
|
385
|
+
}, {
|
|
386
|
+
flowId: n.flowId,
|
|
387
|
+
graph: y(t.graph),
|
|
388
|
+
inputs: {},
|
|
389
|
+
kind: "flow",
|
|
390
|
+
outputs: {}
|
|
391
|
+
}, n.runId, {}, void 0, n.inputs, void 0, n.trigger);
|
|
392
|
+
});
|
|
374
393
|
}
|
|
375
|
-
function
|
|
394
|
+
function y(e) {
|
|
376
395
|
return { nodes: Object.fromEntries(Object.entries(e.nodes).filter((e) => "inputs" in e[1])) };
|
|
377
396
|
}
|
|
378
397
|
//#endregion
|
|
379
|
-
export {
|
|
398
|
+
export { v as runFlow };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JsonValue, WebhookInputDefinition, WebhookOptions } from '../browser/
|
|
1
|
+
import type { JsonValue, WebhookInputDefinition, WebhookOptions } from '../browser/flow-change.js';
|
|
2
2
|
export declare const maximumWebhookBodyBytes: number;
|
|
3
3
|
export declare function webhookEndpointId(url: URL): string | undefined;
|
|
4
4
|
export declare function webhookOccurrenceId(endpointId: string, runtimeVersion: number, key: string | null): Promise<string | undefined>;
|