@oomol-lab/open-flow 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (40) hide show
  1. package/dist/browser/{addNodeOptions-B6tOfd2Y.js → addNodeOptions-DRndy4EK.js} +2237 -2599
  2. package/dist/browser/{createLucideIcon-BlEx4FzJ.js → createLucideIcon-CqjqCezK.js} +835 -869
  3. package/dist/browser/{createResourceDialog-CrBp3E8P.js → createResourceDialog-A64dDFCG.js} +140 -140
  4. package/dist/browser/{esm-CoE5_2w7.js → esm-YIGXG-Js.js} +1 -11
  5. package/dist/browser/{field-Daq9Lk-Y.js → field-CKGQHCIi.js} +88 -88
  6. package/dist/browser/{project-authoring-edge.d.ts → flow-authoring-edge.d.ts} +1 -1
  7. package/dist/browser/{project-authoring-module.d.ts → flow-authoring-module.d.ts} +1 -1
  8. package/dist/browser/{project-authoring-node.d.ts → flow-authoring-node.d.ts} +6 -12
  9. package/dist/browser/flow-authoring.d.ts +3 -0
  10. package/dist/browser/{project-authoring.js → flow-authoring.js} +72 -87
  11. package/dist/browser/{project-change.d.ts → flow-change.d.ts} +27 -36
  12. package/dist/browser/{project-change.js → flow-change.js} +69 -97
  13. package/dist/browser/{project-notifications.d.ts → flow-notifications.d.ts} +6 -3
  14. package/dist/browser/{flowWorkspace-CylW6hge.js → flowWorkspace-D7-rBA1-.js} +17147 -12754
  15. package/dist/browser/licenses.md +514 -0
  16. package/dist/browser/workbench-contract.d.ts +4 -4
  17. package/dist/browser/workbench.css +1 -1
  18. package/dist/browser/workbench.d.ts +1 -1
  19. package/dist/browser/workbench.js +969 -1073
  20. package/dist/common/control-api-conformance.js +219 -352
  21. package/dist/common/control-api-errors.d.ts +16 -24
  22. package/dist/common/control-api.d.ts +39 -68
  23. package/dist/common/control-api.js +136 -189
  24. package/dist/common/cron-trigger.d.ts +1 -1
  25. package/dist/common/flow-encoding.d.ts +11 -0
  26. package/dist/common/{project-encoding.js → flow-encoding.js} +14 -13
  27. package/dist/common/{project-notifications.d.ts → flow-notifications.d.ts} +6 -3
  28. package/dist/common/{project-semantics.d.ts → flow-semantics.d.ts} +9 -12
  29. package/dist/common/{project-semantics.js → flow-semantics.js} +591 -592
  30. package/dist/common/integration-trigger.d.ts +1 -1
  31. package/dist/common/poll-trigger.d.ts +1 -1
  32. package/dist/common/runtime-contract.d.ts +1 -1
  33. package/dist/common/scheduler.d.ts +3 -2
  34. package/dist/common/scheduler.js +159 -154
  35. package/dist/common/webhook-trigger.d.ts +1 -1
  36. package/dist/common/webhook-trigger.js +1 -1
  37. package/package.json +13 -13
  38. package/dist/browser/project-authoring-flow.d.ts +0 -4
  39. package/dist/browser/project-authoring.d.ts +0 -4
  40. package/dist/common/project-encoding.d.ts +0 -11
@@ -1,5 +1,5 @@
1
1
  import type { ConnectorProxy } from './connector-proxy.js';
2
- import type { IntegrationEndpointMethod, JsonValue, TriggerKeySnapshot } from '../browser/project-change.js';
2
+ import type { IntegrationEndpointMethod, JsonValue, TriggerKeySnapshot } from '../browser/flow-change.js';
3
3
  export declare const maximumIntegrationBodyBytes: number;
4
4
  export declare const maximumIntegrationDeliveryPages = 5;
5
5
  export type IntegrationReceiveResult = {
@@ -1,5 +1,5 @@
1
1
  import type { ConnectorProxy } from './connector-proxy.js';
2
- import type { JsonValue, TriggerKeySnapshot, TriggerSchedule } from '../browser/project-change.js';
2
+ import type { JsonValue, TriggerKeySnapshot, TriggerSchedule } from '../browser/flow-change.js';
3
3
  export declare const maximumPollCheckpointBytes: number;
4
4
  export declare const maximumPollDedupeKeyBytes = 1024;
5
5
  export declare const maximumPollEventsPerPage = 100;
@@ -1,4 +1,4 @@
1
- import type { CodeModule, JsonValue } from '../browser/project-change.js';
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,5 @@
1
- import type { ConnectorCapability, JsonValue } from '../browser/project-change.js';
2
- import type { PreparedFlow } from './project-semantics.js';
1
+ import type { ConnectorCapability, JsonValue } from '../browser/flow-change.js';
2
+ import type { PreparedFlow } from './flow-semantics.js';
3
3
  export type SchedulerEvent = {
4
4
  readonly flowId: string;
5
5
  readonly parentJobId?: string;
@@ -88,6 +88,7 @@ export interface SchedulerFailure {
88
88
  export interface FlowRunOptions {
89
89
  readonly createId: () => string;
90
90
  readonly emit?: (event: SchedulerEvent) => void | Promise<void>;
91
+ readonly flowId: string;
91
92
  readonly inputs?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
92
93
  readonly invokeTask: (invocation: TaskInvocation) => Promise<unknown>;
93
94
  readonly projectFailure?: (error: unknown) => SchedulerFailure;
@@ -1,11 +1,16 @@
1
+ //#region src/flow/common/change.ts
2
+ function e(e) {
3
+ return Object.fromEntries(e.map((e) => [e.handle, e]));
4
+ }
5
+ //#endregion
1
6
  //#region src/execution/common/scheduler.ts
2
- function e(e, t) {
7
+ function t(e, t) {
3
8
  return t?.(e) ?? {
4
9
  code: "node.failed",
5
10
  message: e instanceof Error ? e.message : String(e)
6
11
  };
7
12
  }
8
- var t = class {
13
+ var n = class {
9
14
  #e = [];
10
15
  #t = 0;
11
16
  get length() {
@@ -18,9 +23,9 @@ var t = class {
18
23
  let e = this.#e[this.#t];
19
24
  return this.#t += 1, this.#t >= 64 && this.#t * 2 >= this.#e.length && (this.#e.splice(0, this.#t), this.#t = 0), e;
20
25
  }
21
- }, n = class {
26
+ }, r = class {
22
27
  #e;
23
- #t = new t();
28
+ #t = new n();
24
29
  #n;
25
30
  #r;
26
31
  constructor(e, t, n) {
@@ -42,13 +47,13 @@ var t = class {
42
47
  take() {
43
48
  return this.#t.length > 0 ? this.#t.shift() : this.#r;
44
49
  }
45
- }, r = class {
50
+ }, i = class {
46
51
  #e;
47
52
  #t;
48
53
  #n;
49
54
  #r = !1;
50
- constructor(e, t, r) {
51
- this.#t = e, this.#n = new Map(Object.entries(r).map(([e, r]) => [e, new n(t, e, r)])), this.#e = [...this.#n.values()].some((e) => e.dynamic);
55
+ constructor(e, t, n) {
56
+ this.#t = e, this.#n = new Map(Object.entries(n).map(([e, n]) => [e, new r(t, e, n)])), this.#e = [...this.#n.values()].some((e) => e.dynamic);
52
57
  }
53
58
  get ready() {
54
59
  return (!this.#r || this.#e) && [...this.#n.values()].every((e) => e.ready);
@@ -67,15 +72,15 @@ var t = class {
67
72
  return this.#e || (this.#r = !0), Object.fromEntries([...this.#n].map(([e, t]) => [e, t.take()]));
68
73
  }
69
74
  };
70
- function i(e, t) {
71
- switch (t.kind) {
72
- case "condition": return { [t.input.handle]: t.input };
75
+ function a(t, n) {
76
+ switch (n.kind) {
77
+ case "condition": return { [n.input.handle]: n.input };
73
78
  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;
79
+ case "subflow": return e(t.subflows[n.subflowId].inputs);
80
+ case "task": return e(n.task == null ? t.tasks[n.taskId].inputs : n.task.inputs);
76
81
  }
77
82
  }
78
- function a(e, t) {
83
+ function o(e, t) {
79
84
  if (t.name != null) return t.name;
80
85
  switch (t.kind) {
81
86
  case "condition": return;
@@ -84,17 +89,17 @@ function a(e, t) {
84
89
  case "task": return t.task == null ? e.tasks[t.taskId].name : t.task.name;
85
90
  }
86
91
  }
87
- function o(e, t) {
92
+ function s(e, t) {
88
93
  return t.kind == "task" ? t.task == null ? e.tasks[t.taskId].executor.kind : "javascript" : t.kind;
89
94
  }
90
- function s(e, t, n, r) {
95
+ function c(e, t, n, r) {
91
96
  let i = e.get(t) ?? /* @__PURE__ */ new Map(), a = i.get(n) ?? [];
92
97
  a.push(r), i.set(n, a), e.set(t, i);
93
98
  }
94
- function c(e, t, n) {
99
+ function l(e, t, n) {
95
100
  return e.get(t)?.get(n) ?? [];
96
101
  }
97
- function l(e) {
102
+ function u(e) {
98
103
  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
104
  for (; t.size > 0;) {
100
105
  let e = [...t].filter(([, e]) => e.size == 0).map(([e]) => e).toSorted();
@@ -104,18 +109,18 @@ function l(e) {
104
109
  }
105
110
  return n;
106
111
  }
107
- function u(e, t) {
112
+ function d(e, t) {
108
113
  if (e === t) return !0;
109
114
  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) => u(e, t[n]));
115
+ if (Array.isArray(e) || Array.isArray(t)) return Array.isArray(e) && Array.isArray(t) && e.length == t.length && e.every((e, n) => d(e, t[n]));
111
116
  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) && u(t, i[e]));
117
+ return n.length == r.length && n.every(([e, t]) => Object.hasOwn(i, e) && d(t, i[e]));
113
118
  }
114
- function d(e, t, n) {
119
+ function f(e, t, n) {
115
120
  let r = Object.hasOwn(n, t.input) ? n[t.input] : null, i = t.value;
116
121
  switch (t.operator) {
117
- case "==": return i !== void 0 && u(r, i);
118
- case "!=": return i !== void 0 && !u(r, i);
122
+ case "==": return i !== void 0 && d(r, i);
123
+ case "!=": return i !== void 0 && !d(r, i);
119
124
  case ">": return typeof r == "number" && typeof i == "number" && r > i;
120
125
  case ">=": return typeof r == "number" && typeof i == "number" && r >= i;
121
126
  case "<": return typeof r == "number" && typeof i == "number" && r < i;
@@ -123,7 +128,7 @@ function d(e, t, n) {
123
128
  case "contains":
124
129
  case "notContains": {
125
130
  let e;
126
- return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) => u(e, i))), e == null ? !1 : t.operator == "contains" ? e : !e;
131
+ return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) => d(e, i))), e == null ? !1 : t.operator == "contains" ? e : !e;
127
132
  }
128
133
  case "startsWith": return typeof r == "string" && typeof i == "string" && r.startsWith(i);
129
134
  case "endsWith": return typeof r == "string" && typeof i == "string" && r.endsWith(i);
@@ -136,7 +141,7 @@ function d(e, t, n) {
136
141
  case "hasValue":
137
142
  case "notHasValue": {
138
143
  if (r == null || Array.isArray(r) || typeof r != "object" || i === void 0) return !1;
139
- let e = Object.values(r).some((e) => u(e, i));
144
+ let e = Object.values(r).some((e) => d(e, i));
140
145
  return t.operator == "hasValue" ? e : !e;
141
146
  }
142
147
  case "isEmpty":
@@ -150,17 +155,17 @@ function d(e, t, n) {
150
155
  case "isFalse": return r === !1;
151
156
  }
152
157
  }
153
- function f(e, t) {
158
+ function p(e, t) {
154
159
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`Node "${t}" must return an object.`);
155
160
  return e;
156
161
  }
157
- function p(e) {
162
+ function m(e) {
158
163
  return e.reason instanceof Error ? e.reason : /* @__PURE__ */ Error("Run canceled.");
159
164
  }
160
- function m(e, t) {
165
+ function h(e, t) {
161
166
  return new Promise((n, r) => {
162
167
  let i = () => {
163
- t.removeEventListener("abort", i), r(p(t));
168
+ t.removeEventListener("abort", i), r(m(t));
164
169
  };
165
170
  e.then((e) => {
166
171
  t.removeEventListener("abort", i), n(e);
@@ -169,211 +174,211 @@ function m(e, t) {
169
174
  }), t.aborted ? i() : t.addEventListener("abort", i, { once: !0 });
170
175
  });
171
176
  }
172
- async function h(t, n, u, p, g, v, y = {}, b, x) {
173
- g.throwIfAborted(), await t.emit({
174
- flowId: n.flowId,
175
- ...v == null ? {} : {
176
- parentJobId: v.jobId,
177
- parentRunId: v.runId
177
+ async function g(n, r, d, m, _, y, b = {}, x, S) {
178
+ _.throwIfAborted(), await n.emit({
179
+ flowId: r.flowId,
180
+ ...y == null ? {} : {
181
+ parentJobId: y.jobId,
182
+ parentRunId: y.runId
178
183
  },
179
- runId: u,
184
+ runId: d,
180
185
  type: "run.started"
181
186
  });
182
- let S = l(n.graph), C = S.length, w = new Map(Object.entries(n.graph.nodes).map(([e, n]) => [e, new r(e, n, i(t.prepared, n))])), T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
183
- for (let [e, t] of Object.entries(n.graph.nodes)) for (let [n, r] of Object.entries(t.inputs)) if (r.kind == "sources") for (let t of r.sources) if (t.kind == "flow") {
184
- let r = T.get(t.input) ?? [];
187
+ let C = u(r.graph), w = C.length, T = new Map(Object.entries(r.graph.nodes).map(([e, t]) => [e, new i(e, t, a(n.prepared, t))])), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map();
188
+ for (let [e, t] of Object.entries(r.graph.nodes)) for (let [n, r] of Object.entries(t.inputs)) if (r.kind == "sources") for (let t of r.sources) if (t.kind == "flow") {
189
+ let r = E.get(t.input) ?? [];
185
190
  r.push({
186
191
  handle: n,
187
192
  nodeId: e
188
- }), T.set(t.input, r);
189
- } else t.kind == "node" && s(E, t.nodeId, t.output, {
193
+ }), E.set(t.input, r);
194
+ } else t.kind == "node" && c(D, t.nodeId, t.output, {
190
195
  handle: n,
191
196
  nodeId: e
192
197
  });
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
+ for (let [e, t] of Object.entries(r.outputs)) for (let n of t.sources) n.kind == "node" && c(O, n.nodeId, n.output, e);
199
+ let k = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Set(), F = new AbortController(), I = AbortSignal.any([_, F.signal]), L, R = !1, z, B = (e, t) => {
200
+ F.signal.aborted || (T.get(e.nodeId).push(e.handle, t), z(e.nodeId));
201
+ }, V = async (e, t, r, i) => {
202
+ await n.emit({
198
203
  handle: r,
199
- jobId: n,
204
+ jobId: t,
200
205
  nodeId: e,
201
- runId: u,
206
+ runId: d,
202
207
  type: "node.output",
203
208
  value: i
204
209
  });
205
- for (let t of c(E, e, r)) z(t, i);
206
- for (let t of c(D, e, r)) M.set(t, i), await b?.(t, i);
207
- }, V = async (e, n, r, i) => {
208
- let s = o(t.prepared, n), c = a(t.prepared, n);
209
- await t.emit({
210
- inputs: i,
211
- jobId: r,
212
- nodeId: e,
213
- nodeKind: s,
214
- ...c == null ? {} : { nodeTitle: c },
215
- runId: u,
210
+ for (let t of l(D, e, r)) B(t, i);
211
+ for (let t of l(O, e, r)) N.set(t, i), await x?.(t, i);
212
+ }, H = async (t, r, i, a) => {
213
+ let c = s(n.prepared, r), l = o(n.prepared, r);
214
+ await n.emit({
215
+ inputs: a,
216
+ jobId: i,
217
+ nodeId: t,
218
+ nodeKind: c,
219
+ ...l == null ? {} : { nodeTitle: l },
220
+ runId: d,
216
221
  type: "node.started"
217
222
  });
218
- let l = n.timeoutMs == null ? void 0 : new AbortController(), p = l == null ? void 0 : setTimeout(() => l.abort(/* @__PURE__ */ Error(`Node "${e}" timed out.`)), n.timeoutMs), g = l == null ? F : AbortSignal.any([F, l.signal]);
223
+ let u = r.timeoutMs == null ? void 0 : new AbortController(), m = u == null ? void 0 : setTimeout(() => u.abort(/* @__PURE__ */ Error(`Node "${t}" timed out.`)), r.timeoutMs), _ = u == null ? I : AbortSignal.any([I, u.signal]);
219
224
  try {
220
- let a;
221
- switch (n.kind) {
225
+ let o;
226
+ switch (r.kind) {
222
227
  case "condition": {
223
- let t = n.cases.find((e) => {
228
+ let e = r.cases.find((e) => {
224
229
  if (e.expressions.length == 0) return !1;
225
- let t = e.expressions.map((e) => d(n, e, i));
230
+ let t = e.expressions.map((e) => f(r, e, a));
226
231
  return e.relation == "all" ? t.every(Boolean) : t.some(Boolean);
227
- })?.output ?? n.defaultOutput;
228
- a = t == null ? {} : { [t]: i[n.input.handle] ?? null }, t != null && await B(e, r, t, a[t]);
232
+ })?.output ?? r.defaultOutput;
233
+ o = e == null ? {} : { [e]: a[r.input.handle] ?? null }, e != null && await V(t, i, e, o[e]);
229
234
  break;
230
235
  }
231
236
  case "value":
232
- a = Object.fromEntries(Object.entries(n.values).map(([e, t]) => [e, t.value ?? null]));
233
- for (let [t, n] of Object.entries(a)) await B(e, r, t, n);
237
+ o = Object.fromEntries(r.values.map((e) => [e.handle, e.value ?? null]));
238
+ for (let [e, n] of Object.entries(o)) await V(t, i, e, n);
234
239
  break;
235
240
  case "subflow": {
236
- let o = t.prepared.subflows[n.subflowId];
237
- a = await m(h(t, {
238
- flowId: n.subflowId,
239
- graph: _(o.graph),
240
- inputs: o.inputs,
241
+ let s = n.prepared.subflows[r.subflowId];
242
+ o = await h(g(n, {
243
+ flowId: r.subflowId,
244
+ graph: v(s.graph),
245
+ inputs: e(s.inputs),
241
246
  kind: "subflow",
242
- outputs: o.outputs
243
- }, t.createId(), i, g, {
244
- jobId: r,
245
- runId: u
246
- }, {}, (t, n) => B(e, r, t, n)), g);
247
+ outputs: e(s.outputs)
248
+ }, n.createId(), a, _, {
249
+ jobId: i,
250
+ runId: d
251
+ }, {}, (e, n) => V(t, i, e, n)), _);
247
252
  break;
248
253
  }
249
254
  case "task":
250
- a = f(await m(t.invokeTask({
251
- input: i,
252
- invocationId: t.createId(),
253
- jobId: r,
254
- nodeId: e,
255
- runId: u,
256
- signal: g,
257
- ...n.task == null ? { taskId: n.taskId } : {
258
- capabilities: n.task.capabilities ?? [],
259
- moduleId: n.task.moduleId
255
+ o = p(await h(n.invokeTask({
256
+ input: a,
257
+ invocationId: n.createId(),
258
+ jobId: i,
259
+ nodeId: t,
260
+ runId: d,
261
+ signal: _,
262
+ ...r.task == null ? { taskId: r.taskId } : {
263
+ capabilities: r.task.capabilities ?? [],
264
+ moduleId: r.task.moduleId
260
265
  }
261
- }), g), e);
262
- for (let [t, n] of Object.entries(a)) await B(e, r, t, n);
266
+ }), _), t);
267
+ for (let [e, n] of Object.entries(o)) await V(t, i, e, n);
263
268
  }
264
- return await t.emit({
265
- jobId: r,
266
- nodeId: e,
267
- runId: u,
269
+ return await n.emit({
270
+ jobId: i,
271
+ nodeId: t,
272
+ runId: d,
268
273
  type: "node.completed"
269
- }), a;
274
+ }), o;
270
275
  } finally {
271
- p != null && clearTimeout(p);
276
+ m != null && clearTimeout(m);
272
277
  }
273
- }, H = (r) => {
274
- let i = n.graph.nodes[r], a = w.get(r).take(), o = t.createId(), s = j.get(r) ?? 0;
275
- j.set(r, s + 1), O.set(r, (O.get(r) ?? 0) + 1);
278
+ }, U = (e) => {
279
+ let i = r.graph.nodes[e], a = T.get(e).take(), o = n.createId(), s = M.get(e) ?? 0;
280
+ M.set(e, s + 1), k.set(e, (k.get(e) ?? 0) + 1);
276
281
  let c = Promise.resolve();
277
- c = V(r, i, o, a).then(async (e) => {
278
- let n = A.get(r) ?? [];
279
- n.push({
282
+ c = H(e, i, o, a).then(async (t) => {
283
+ let r = j.get(e) ?? [];
284
+ r.push({
280
285
  jobId: o,
281
286
  order: s,
282
- outputs: e
283
- }), A.set(r, n), N.has(r) || (N.add(r), await t.emit({
284
- ...v == null ? {} : {
285
- parentJobId: v.jobId,
286
- parentRunId: v.runId
287
+ outputs: t
288
+ }), j.set(e, r), P.has(e) || (P.add(e), await n.emit({
289
+ ...y == null ? {} : {
290
+ parentJobId: y.jobId,
291
+ parentRunId: y.runId
287
292
  },
288
- progress: N.size / C * 100,
289
- runId: u,
293
+ progress: P.size / w * 100,
294
+ runId: d,
290
295
  type: "run.progress"
291
296
  }));
292
- }).catch(async (n) => {
293
- L || (L = !0, I = n, P.abort(n));
294
- let i = e(n, t.projectFailure);
295
- await t.emit({
297
+ }).catch(async (r) => {
298
+ R || (R = !0, L = r, F.abort(r));
299
+ let i = t(r, n.projectFailure);
300
+ await n.emit({
296
301
  ...i,
297
302
  jobId: o,
298
- nodeId: r,
299
- runId: u,
303
+ nodeId: e,
304
+ runId: d,
300
305
  type: "node.failed"
301
306
  }).catch(() => void 0);
302
307
  }).finally(() => {
303
- k.delete(c), O.set(r, (O.get(r) ?? 1) - 1), R(r);
304
- }), k.add(c);
308
+ A.delete(c), k.set(e, (k.get(e) ?? 1) - 1), z(e);
309
+ }), A.add(c);
305
310
  };
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);
311
+ z = (e) => {
312
+ if (F.signal.aborted) return;
313
+ let t = r.graph.nodes[e], n = T.get(e);
314
+ for (; n.ready && (k.get(e) ?? 0) < t.concurrency;) U(e);
310
315
  };
311
- for (let [e, t] of Object.entries(y)) {
312
- let n = w.get(e);
316
+ for (let [e, t] of Object.entries(b)) {
317
+ let n = T.get(e);
313
318
  if (n != null) for (let [e, r] of Object.entries(t)) n.launch(e, r);
314
319
  }
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);
320
+ for (let [e, t] of Object.entries(r.inputs)) {
321
+ let n = Object.hasOwn(m, e) ? m[e] : t.value;
322
+ if (n !== void 0) {
323
+ for (let t of Object.entries(r.outputs)) t[1].sources.some((t) => t.kind == "flow" && t.input == e) && (N.set(t[0], n), await x?.(t[0], n));
324
+ for (let t of E.get(e) ?? []) B(t, n);
320
325
  }
321
326
  }
322
- if (x != null) for (let e of c(E, x.nodeId, "payload")) z(e, x.payload);
323
- for (let e of S) R(e);
324
- for (; k.size > 0;) await Promise.race(k);
325
- if (L) throw await t.emit({
326
- message: I instanceof Error ? I.message : String(I),
327
- runId: u,
327
+ if (S != null) for (let e of l(D, S.nodeId, "payload")) B(e, S.payload);
328
+ for (let e of C) z(e);
329
+ for (; A.size > 0;) await Promise.race(A);
330
+ if (R) throw await n.emit({
331
+ message: L instanceof Error ? L.message : String(L),
332
+ runId: d,
328
333
  type: "run.failed"
329
- }).catch(() => void 0), I;
330
- if (F.throwIfAborted(), n.kind == "subflow") {
331
- let e = Object.fromEntries(M);
332
- return await t.emit({
334
+ }).catch(() => void 0), L;
335
+ if (I.throwIfAborted(), r.kind == "subflow") {
336
+ let e = Object.fromEntries(N);
337
+ return await n.emit({
333
338
  result: {
334
339
  kind: "function-outputs",
335
340
  outputs: e,
336
341
  target: "subflow"
337
342
  },
338
- runId: u,
343
+ runId: d,
339
344
  type: "run.completed"
340
345
  }), e;
341
346
  }
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 = {
347
+ let W = new Set(Object.values(r.graph.nodes).flatMap((e) => Object.values(e.inputs).flatMap((e) => e.kind == "sources" ? e.sources.filter((e) => e.kind == "node").map((e) => e.nodeId) : []))), G = {
343
348
  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 }) => ({
349
+ nodes: C.filter((e) => !W.has(e)).map((e) => ({
350
+ jobs: (j.get(e) ?? []).toSorted((e, t) => e.order - t.order).map(({ jobId: e, outputs: t }) => ({
346
351
  jobId: e,
347
352
  outputs: t
348
353
  })),
349
354
  nodeId: e
350
355
  }))
351
356
  };
352
- return await t.emit({
353
- result: W,
354
- runId: u,
357
+ return await n.emit({
358
+ result: G,
359
+ runId: d,
355
360
  type: "run.completed"
356
- }), W;
361
+ }), G;
357
362
  }
358
- async function g(e, t) {
359
- let n = async (e) => await t.emit?.(e), r = t.signal ?? new AbortController().signal, i = t.trigger == null ? void 0 : e.flow.graph.nodes[t.trigger.nodeId];
360
- if (t.trigger != null && (i == null || "inputs" in i)) throw Error(`Node "${t.trigger.nodeId}" is not a TriggerNode in Flow "${e.flowId}".`);
361
- return await h({
363
+ async function _(e, t) {
364
+ let n = async (e) => await t.emit?.(e), r = t.signal ?? new AbortController().signal, i = t.trigger == null ? void 0 : e.graph.nodes[t.trigger.nodeId];
365
+ if (t.trigger != null && (i == null || "inputs" in i)) throw Error(`Node "${t.trigger.nodeId}" is not a TriggerNode in Flow "${t.flowId}".`);
366
+ return await g({
362
367
  createId: t.createId,
363
368
  emit: n,
364
369
  invokeTask: t.invokeTask,
365
370
  prepared: e,
366
371
  projectFailure: t.projectFailure
367
372
  }, {
368
- flowId: e.flowId,
369
- graph: _(e.flow.graph),
373
+ flowId: t.flowId,
374
+ graph: v(e.graph),
370
375
  inputs: {},
371
376
  kind: "flow",
372
377
  outputs: {}
373
378
  }, t.runId, {}, r, void 0, t.inputs, void 0, t.trigger);
374
379
  }
375
- function _(e) {
380
+ function v(e) {
376
381
  return { nodes: Object.fromEntries(Object.entries(e.nodes).filter((e) => "inputs" in e[1])) };
377
382
  }
378
383
  //#endregion
379
- export { g as runFlow };
384
+ export { _ as runFlow };
@@ -1,4 +1,4 @@
1
- import type { JsonValue, WebhookInputDefinition, WebhookOptions } from '../browser/project-change.js';
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>;
@@ -159,7 +159,7 @@ var u = [], d = [{
159
159
  }
160
160
  }
161
161
  },
162
- name: "prevents Project responses from becoming executable or controlling deployment headers",
162
+ name: "prevents Flow responses from becoming executable or controlling deployment headers",
163
163
  async verify(e) {
164
164
  await c(await l(e), {
165
165
  body: "<script>globalThis.compromised = true<\/script>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oomol-lab/open-flow",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.7",
4
4
  "description": "TypeScript contracts and Browser runtime for Open Flow.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -45,21 +45,21 @@
45
45
  "types": "./dist/common/provider-triggers.d.ts",
46
46
  "import": "./dist/common/provider-triggers.js"
47
47
  },
48
- "./project-authoring": {
49
- "types": "./dist/browser/project-authoring.d.ts",
50
- "import": "./dist/browser/project-authoring.js"
48
+ "./flow-authoring": {
49
+ "types": "./dist/browser/flow-authoring.d.ts",
50
+ "import": "./dist/browser/flow-authoring.js"
51
51
  },
52
- "./project-change": {
53
- "types": "./dist/browser/project-change.d.ts",
54
- "import": "./dist/browser/project-change.js"
52
+ "./flow-change": {
53
+ "types": "./dist/browser/flow-change.d.ts",
54
+ "import": "./dist/browser/flow-change.js"
55
55
  },
56
- "./project-encoding": {
57
- "types": "./dist/common/project-encoding.d.ts",
58
- "import": "./dist/common/project-encoding.js"
56
+ "./flow-encoding": {
57
+ "types": "./dist/common/flow-encoding.d.ts",
58
+ "import": "./dist/common/flow-encoding.js"
59
59
  },
60
- "./project-semantics": {
61
- "types": "./dist/common/project-semantics.d.ts",
62
- "import": "./dist/common/project-semantics.js"
60
+ "./flow-semantics": {
61
+ "types": "./dist/common/flow-semantics.d.ts",
62
+ "import": "./dist/common/flow-semantics.js"
63
63
  },
64
64
  "./run-lifecycle": {
65
65
  "types": "./dist/common/run-lifecycle.d.ts",
@@ -1,4 +0,0 @@
1
- import type { ChangeOperation } from './project-change.js';
2
- export declare function createFlow(flowId: string, name: string): readonly ChangeOperation[];
3
- export declare function renameFlow(flowId: string, name: string): readonly ChangeOperation[];
4
- export declare function deleteFlow(flowId: string): readonly ChangeOperation[];
@@ -1,4 +0,0 @@
1
- export { connect, disconnect } from './project-authoring-edge.js';
2
- export { createFlow, deleteFlow, renameFlow } from './project-authoring-flow.js';
3
- export { imports as moduleImports, rename as renameModule, replaceSource as replaceModuleSource } from './project-authoring-module.js';
4
- export { createBuiltinTrigger, createCodeTask, createCondition, createLlmTask, createManagedTask, createProviderTrigger, createValue, deleteNodes, setConnectorConnection, setInputValues, setTriggerConnection, updateSettings, updateTrigger, } from './project-authoring-node.js';
@@ -1,11 +0,0 @@
1
- import type { CodeModule, Graph, InputPortDefinition, JsonValue, OutputMapping, PortDefinition, ProjectDocument, RevisionContent } from '@oomol-lab/open-flow/project-change';
2
- export declare const maxJsonDepth = 64;
3
- export declare function canonicalJsonBytes(value: JsonValue): Uint8Array;
4
- export declare function digestBytes(bytes: Uint8Array): Promise<string>;
5
- export declare function canonicalPorts(value: Readonly<Record<string, InputPortDefinition | PortDefinition>>): JsonValue;
6
- export declare function canonicalOutputs(value: Readonly<Record<string, OutputMapping & PortDefinition>>): JsonValue;
7
- export declare function canonicalGraph(value: Graph): JsonValue;
8
- export declare function canonicalTask(task: ProjectDocument['tasks'][string]): JsonValue;
9
- export declare function canonicalDocument(document: ProjectDocument): JsonValue;
10
- export declare function canonicalModule(module: CodeModule): JsonValue;
11
- export declare function encodeRevision(content: RevisionContent): Uint8Array;