@fluidgrids/workflows 0.0.0-stage → 2026.1027.0
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/LICENSE +9 -0
- package/README.md +187 -2
- package/dist/assemble-BJo9TECS.d.cts +569 -0
- package/dist/assemble-DMOuaxRI.d.ts +569 -0
- package/dist/chunk-265J2FCH.cjs +33 -0
- package/dist/chunk-27HASETB.cjs +250 -0
- package/dist/chunk-4DPEGDPW.js +74 -0
- package/dist/chunk-5LUIDMF4.js +42 -0
- package/dist/chunk-AU3YW7FZ.cjs +279 -0
- package/dist/chunk-BWSLWF2E.js +722 -0
- package/dist/chunk-BYJ7QTLY.cjs +76 -0
- package/dist/chunk-G4UEPUGO.cjs +46 -0
- package/dist/chunk-GO34UHSY.js +95 -0
- package/dist/chunk-IZQNUNSU.cjs +931 -0
- package/dist/chunk-KUTMY2IO.cjs +745 -0
- package/dist/chunk-LMX35GNQ.js +893 -0
- package/dist/chunk-LRM6JXJA.cjs +181 -0
- package/dist/chunk-LSKSBVL4.cjs +102 -0
- package/dist/chunk-LUXCXFOE.cjs +269 -0
- package/dist/chunk-PL73GJR4.js +174 -0
- package/dist/chunk-REV7ZOA4.js +170 -0
- package/dist/chunk-RRQ5HOBF.cjs +185 -0
- package/dist/chunk-S34NJE3A.js +262 -0
- package/dist/chunk-SRQRLWOS.js +31 -0
- package/dist/chunk-SS4LT2IP.js +268 -0
- package/dist/chunk-X4HKU3MX.js +244 -0
- package/dist/codegen/index.cjs +18 -0
- package/dist/codegen/index.d.cts +15 -0
- package/dist/codegen/index.d.ts +15 -0
- package/dist/codegen/index.js +5 -0
- package/dist/expressions-DhHaqyar.d.cts +62 -0
- package/dist/expressions-DhHaqyar.d.ts +62 -0
- package/dist/hash-CZkTXPCX.d.cts +15 -0
- package/dist/hash-CZkTXPCX.d.ts +15 -0
- package/dist/index.cjs +117 -0
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +4 -0
- package/dist/ir/index.cjs +1244 -0
- package/dist/ir/index.d.cts +828 -0
- package/dist/ir/index.d.ts +828 -0
- package/dist/ir/index.js +1120 -0
- package/dist/lower-DcOY8ux0.d.cts +49 -0
- package/dist/lower-Dw5grNrI.d.ts +49 -0
- package/dist/manifest-Bp9ZJlav.d.ts +60 -0
- package/dist/manifest-Duf-gHdO.d.cts +60 -0
- package/dist/node-evaluator-2GTUZVPK.cjs +17 -0
- package/dist/node-evaluator-RMYEWCXZ.js +8 -0
- package/dist/quickjs/index.cjs +92 -0
- package/dist/quickjs/index.d.cts +18 -0
- package/dist/quickjs/index.d.ts +18 -0
- package/dist/quickjs/index.js +90 -0
- package/dist/roundtrip/index.cjs +1375 -0
- package/dist/roundtrip/index.d.cts +287 -0
- package/dist/roundtrip/index.d.ts +287 -0
- package/dist/roundtrip/index.js +1328 -0
- package/dist/types-Dr2Fn1Ax.d.cts +225 -0
- package/dist/types-Dr2Fn1Ax.d.ts +225 -0
- package/package.json +117 -4
- package/schema/ir-v2.schema.json +655 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/ir/canonical-json.ts
|
|
4
|
+
var CanonicalJsonError = class extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "CanonicalJsonError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function isPlainObject(value) {
|
|
11
|
+
const proto = Object.getPrototypeOf(value);
|
|
12
|
+
return proto === Object.prototype || proto === null;
|
|
13
|
+
}
|
|
14
|
+
function serialize(value, path, out) {
|
|
15
|
+
if (value === null) {
|
|
16
|
+
out.push("null");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
switch (typeof value) {
|
|
20
|
+
case "boolean":
|
|
21
|
+
out.push(value ? "true" : "false");
|
|
22
|
+
return;
|
|
23
|
+
case "number":
|
|
24
|
+
if (!Number.isFinite(value)) {
|
|
25
|
+
throw new CanonicalJsonError(`${path} is not a finite number`);
|
|
26
|
+
}
|
|
27
|
+
out.push(JSON.stringify(value));
|
|
28
|
+
return;
|
|
29
|
+
case "string":
|
|
30
|
+
out.push(JSON.stringify(value));
|
|
31
|
+
return;
|
|
32
|
+
case "object":
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
throw new CanonicalJsonError(`${path} is a ${typeof value}, which JSON cannot represent`);
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
out.push("[");
|
|
39
|
+
value.forEach((item, index) => {
|
|
40
|
+
if (item === void 0) {
|
|
41
|
+
throw new CanonicalJsonError(`${path}[${index}] is undefined`);
|
|
42
|
+
}
|
|
43
|
+
if (index > 0) out.push(",");
|
|
44
|
+
serialize(item, `${path}[${index}]`, out);
|
|
45
|
+
});
|
|
46
|
+
out.push("]");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (!isPlainObject(value)) {
|
|
50
|
+
throw new CanonicalJsonError(`${path} is not a plain JSON object`);
|
|
51
|
+
}
|
|
52
|
+
const record = value;
|
|
53
|
+
const keys = Object.keys(record).filter((key) => record[key] !== void 0).sort();
|
|
54
|
+
out.push("{");
|
|
55
|
+
keys.forEach((key, index) => {
|
|
56
|
+
if (index > 0) out.push(",");
|
|
57
|
+
out.push(JSON.stringify(key), ":");
|
|
58
|
+
serialize(record[key], `${path}.${key}`, out);
|
|
59
|
+
});
|
|
60
|
+
out.push("}");
|
|
61
|
+
}
|
|
62
|
+
function canonicalJson(value) {
|
|
63
|
+
const out = [];
|
|
64
|
+
serialize(value, "$", out);
|
|
65
|
+
return out.join("");
|
|
66
|
+
}
|
|
67
|
+
function sortKeysDeep(value) {
|
|
68
|
+
if (Array.isArray(value)) return value.map(sortKeysDeep);
|
|
69
|
+
if (value !== null && typeof value === "object") {
|
|
70
|
+
const record = value;
|
|
71
|
+
const sorted = {};
|
|
72
|
+
for (const key of Object.keys(record).sort()) {
|
|
73
|
+
if (record[key] !== void 0) sorted[key] = sortKeysDeep(record[key]);
|
|
74
|
+
}
|
|
75
|
+
return sorted;
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
function stableStringify(value) {
|
|
80
|
+
canonicalJson(value);
|
|
81
|
+
return `${JSON.stringify(sortKeysDeep(value), null, 2)}
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/ir/sha256.ts
|
|
86
|
+
var K = new Uint32Array([
|
|
87
|
+
1116352408,
|
|
88
|
+
1899447441,
|
|
89
|
+
3049323471,
|
|
90
|
+
3921009573,
|
|
91
|
+
961987163,
|
|
92
|
+
1508970993,
|
|
93
|
+
2453635748,
|
|
94
|
+
2870763221,
|
|
95
|
+
3624381080,
|
|
96
|
+
310598401,
|
|
97
|
+
607225278,
|
|
98
|
+
1426881987,
|
|
99
|
+
1925078388,
|
|
100
|
+
2162078206,
|
|
101
|
+
2614888103,
|
|
102
|
+
3248222580,
|
|
103
|
+
3835390401,
|
|
104
|
+
4022224774,
|
|
105
|
+
264347078,
|
|
106
|
+
604807628,
|
|
107
|
+
770255983,
|
|
108
|
+
1249150122,
|
|
109
|
+
1555081692,
|
|
110
|
+
1996064986,
|
|
111
|
+
2554220882,
|
|
112
|
+
2821834349,
|
|
113
|
+
2952996808,
|
|
114
|
+
3210313671,
|
|
115
|
+
3336571891,
|
|
116
|
+
3584528711,
|
|
117
|
+
113926993,
|
|
118
|
+
338241895,
|
|
119
|
+
666307205,
|
|
120
|
+
773529912,
|
|
121
|
+
1294757372,
|
|
122
|
+
1396182291,
|
|
123
|
+
1695183700,
|
|
124
|
+
1986661051,
|
|
125
|
+
2177026350,
|
|
126
|
+
2456956037,
|
|
127
|
+
2730485921,
|
|
128
|
+
2820302411,
|
|
129
|
+
3259730800,
|
|
130
|
+
3345764771,
|
|
131
|
+
3516065817,
|
|
132
|
+
3600352804,
|
|
133
|
+
4094571909,
|
|
134
|
+
275423344,
|
|
135
|
+
430227734,
|
|
136
|
+
506948616,
|
|
137
|
+
659060556,
|
|
138
|
+
883997877,
|
|
139
|
+
958139571,
|
|
140
|
+
1322822218,
|
|
141
|
+
1537002063,
|
|
142
|
+
1747873779,
|
|
143
|
+
1955562222,
|
|
144
|
+
2024104815,
|
|
145
|
+
2227730452,
|
|
146
|
+
2361852424,
|
|
147
|
+
2428436474,
|
|
148
|
+
2756734187,
|
|
149
|
+
3204031479,
|
|
150
|
+
3329325298
|
|
151
|
+
]);
|
|
152
|
+
function rotr(value, bits) {
|
|
153
|
+
return value >>> bits | value << 32 - bits;
|
|
154
|
+
}
|
|
155
|
+
function utf8(text) {
|
|
156
|
+
const bytes = [];
|
|
157
|
+
for (const char of text) {
|
|
158
|
+
let code = char.codePointAt(0) ?? 0;
|
|
159
|
+
if (code >= 55296 && code <= 57343) code = 65533;
|
|
160
|
+
if (code < 128) {
|
|
161
|
+
bytes.push(code);
|
|
162
|
+
} else if (code < 2048) {
|
|
163
|
+
bytes.push(192 | code >> 6, 128 | code & 63);
|
|
164
|
+
} else if (code < 65536) {
|
|
165
|
+
bytes.push(224 | code >> 12, 128 | code >> 6 & 63, 128 | code & 63);
|
|
166
|
+
} else {
|
|
167
|
+
bytes.push(
|
|
168
|
+
240 | code >> 18,
|
|
169
|
+
128 | code >> 12 & 63,
|
|
170
|
+
128 | code >> 6 & 63,
|
|
171
|
+
128 | code & 63
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return Uint8Array.from(bytes);
|
|
176
|
+
}
|
|
177
|
+
function sha256Hex(text) {
|
|
178
|
+
const message = utf8(text);
|
|
179
|
+
const bitLength = message.length * 8;
|
|
180
|
+
const paddedLength = Math.ceil((message.length + 9) / 64) * 64;
|
|
181
|
+
const padded = new Uint8Array(paddedLength);
|
|
182
|
+
padded.set(message);
|
|
183
|
+
padded[message.length] = 128;
|
|
184
|
+
const view = new DataView(padded.buffer);
|
|
185
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296));
|
|
186
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0);
|
|
187
|
+
const hash = new Uint32Array([
|
|
188
|
+
1779033703,
|
|
189
|
+
3144134277,
|
|
190
|
+
1013904242,
|
|
191
|
+
2773480762,
|
|
192
|
+
1359893119,
|
|
193
|
+
2600822924,
|
|
194
|
+
528734635,
|
|
195
|
+
1541459225
|
|
196
|
+
]);
|
|
197
|
+
const w = new Uint32Array(64);
|
|
198
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
199
|
+
for (let i = 0; i < 16; i++) w[i] = view.getUint32(offset + i * 4);
|
|
200
|
+
for (let i = 16; i < 64; i++) {
|
|
201
|
+
const w15 = w[i - 15] ?? 0;
|
|
202
|
+
const w2 = w[i - 2] ?? 0;
|
|
203
|
+
const s0 = rotr(w15, 7) ^ rotr(w15, 18) ^ w15 >>> 3;
|
|
204
|
+
const s1 = rotr(w2, 17) ^ rotr(w2, 19) ^ w2 >>> 10;
|
|
205
|
+
w[i] = (w[i - 16] ?? 0) + s0 + (w[i - 7] ?? 0) + s1 >>> 0;
|
|
206
|
+
}
|
|
207
|
+
let a = hash[0] ?? 0;
|
|
208
|
+
let b = hash[1] ?? 0;
|
|
209
|
+
let c = hash[2] ?? 0;
|
|
210
|
+
let d = hash[3] ?? 0;
|
|
211
|
+
let e = hash[4] ?? 0;
|
|
212
|
+
let f = hash[5] ?? 0;
|
|
213
|
+
let g = hash[6] ?? 0;
|
|
214
|
+
let h = hash[7] ?? 0;
|
|
215
|
+
for (let i = 0; i < 64; i++) {
|
|
216
|
+
const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
217
|
+
const ch = e & f ^ ~e & g;
|
|
218
|
+
const t1 = h + s1 + ch + (K[i] ?? 0) + (w[i] ?? 0) >>> 0;
|
|
219
|
+
const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
220
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
221
|
+
const t2 = s0 + maj >>> 0;
|
|
222
|
+
h = g;
|
|
223
|
+
g = f;
|
|
224
|
+
f = e;
|
|
225
|
+
e = d + t1 >>> 0;
|
|
226
|
+
d = c;
|
|
227
|
+
c = b;
|
|
228
|
+
b = a;
|
|
229
|
+
a = t1 + t2 >>> 0;
|
|
230
|
+
}
|
|
231
|
+
hash[0] = (hash[0] ?? 0) + a >>> 0;
|
|
232
|
+
hash[1] = (hash[1] ?? 0) + b >>> 0;
|
|
233
|
+
hash[2] = (hash[2] ?? 0) + c >>> 0;
|
|
234
|
+
hash[3] = (hash[3] ?? 0) + d >>> 0;
|
|
235
|
+
hash[4] = (hash[4] ?? 0) + e >>> 0;
|
|
236
|
+
hash[5] = (hash[5] ?? 0) + f >>> 0;
|
|
237
|
+
hash[6] = (hash[6] ?? 0) + g >>> 0;
|
|
238
|
+
hash[7] = (hash[7] ?? 0) + h >>> 0;
|
|
239
|
+
}
|
|
240
|
+
return Array.from(hash, (word) => word.toString(16).padStart(8, "0")).join("");
|
|
241
|
+
}
|
|
242
|
+
function sha256Tagged(text) {
|
|
243
|
+
return `sha256:${sha256Hex(text)}`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
exports.CanonicalJsonError = CanonicalJsonError;
|
|
247
|
+
exports.canonicalJson = canonicalJson;
|
|
248
|
+
exports.sha256Hex = sha256Hex;
|
|
249
|
+
exports.sha256Tagged = sha256Tagged;
|
|
250
|
+
exports.stableStringify = stableStringify;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { hashedProjection } from './chunk-SS4LT2IP.js';
|
|
2
|
+
import { isRecord, deepEqual } from './chunk-REV7ZOA4.js';
|
|
3
|
+
|
|
4
|
+
// src/ir/diff.ts
|
|
5
|
+
function keyPath(base, key) {
|
|
6
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? base ? `${base}.${key}` : key : `${base}[${JSON.stringify(key)}]`;
|
|
7
|
+
}
|
|
8
|
+
function diffValues(before, after, path, out) {
|
|
9
|
+
if (deepEqual(before, after)) return;
|
|
10
|
+
if (isRecord(before) && isRecord(after)) {
|
|
11
|
+
const keys = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].sort();
|
|
12
|
+
for (const key of keys) {
|
|
13
|
+
const left = before[key];
|
|
14
|
+
const right = after[key];
|
|
15
|
+
if (left === void 0 && right !== void 0)
|
|
16
|
+
out.push({ kind: "added", path: keyPath(path, key), after: right });
|
|
17
|
+
else if (left !== void 0 && right === void 0)
|
|
18
|
+
out.push({ kind: "removed", path: keyPath(path, key), before: left });
|
|
19
|
+
else diffValues(left, right, keyPath(path, key), out);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
out.push({ kind: "changed", path, before, after });
|
|
24
|
+
}
|
|
25
|
+
function byId(items) {
|
|
26
|
+
const map = /* @__PURE__ */ new Map();
|
|
27
|
+
if (!Array.isArray(items)) return map;
|
|
28
|
+
items.forEach((item, index) => {
|
|
29
|
+
if (!isRecord(item)) return;
|
|
30
|
+
const id = typeof item["id"] === "string" ? item["id"] : `#${index}`;
|
|
31
|
+
if (!map.has(id)) map.set(id, item);
|
|
32
|
+
});
|
|
33
|
+
return map;
|
|
34
|
+
}
|
|
35
|
+
function diffCollection(before, after, path, out) {
|
|
36
|
+
const left = byId(before);
|
|
37
|
+
const right = byId(after);
|
|
38
|
+
for (const [id, item] of left) {
|
|
39
|
+
if (!right.has(id)) out.push({ kind: "removed", path: `${path}[${id}]`, before: item });
|
|
40
|
+
}
|
|
41
|
+
for (const [id, item] of right) {
|
|
42
|
+
const previous = left.get(id);
|
|
43
|
+
if (!previous) out.push({ kind: "added", path: `${path}[${id}]`, after: item });
|
|
44
|
+
else diffValues(previous, item, `${path}[${id}]`, out);
|
|
45
|
+
}
|
|
46
|
+
const common = (ids, other) => ids.filter((id) => other.has(id));
|
|
47
|
+
const leftOrder = common([...left.keys()], right);
|
|
48
|
+
const rightOrder = common([...right.keys()], left);
|
|
49
|
+
if (!deepEqual(leftOrder, rightOrder)) {
|
|
50
|
+
out.push({ kind: "reordered", path, before: leftOrder, after: rightOrder });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function diffDefinitions(before, after) {
|
|
54
|
+
const left = hashedProjection(before);
|
|
55
|
+
const right = hashedProjection(after);
|
|
56
|
+
const out = [];
|
|
57
|
+
if (!isRecord(left) || !isRecord(right)) {
|
|
58
|
+
diffValues(left, right, "", out);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
const { data: leftData, ...leftRest } = left;
|
|
62
|
+
const { data: rightData, ...rightRest } = right;
|
|
63
|
+
diffValues(leftRest, rightRest, "", out);
|
|
64
|
+
const leftDataRecord = isRecord(leftData) ? leftData : {};
|
|
65
|
+
const rightDataRecord = isRecord(rightData) ? rightData : {};
|
|
66
|
+
const { nodes: leftNodes, edges: leftEdges, ...leftDataRest } = leftDataRecord;
|
|
67
|
+
const { nodes: rightNodes, edges: rightEdges, ...rightDataRest } = rightDataRecord;
|
|
68
|
+
diffCollection(leftNodes, rightNodes, "data.nodes", out);
|
|
69
|
+
diffCollection(leftEdges, rightEdges, "data.edges", out);
|
|
70
|
+
diffValues(leftDataRest, rightDataRest, "data", out);
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { diffDefinitions };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/ir/layout.ts
|
|
2
|
+
var LAYOUT_COLUMN_WIDTH = 300;
|
|
3
|
+
var LAYOUT_ROW_HEIGHT = 170;
|
|
4
|
+
function autoLayout(nodeIds, edges) {
|
|
5
|
+
const depth = /* @__PURE__ */ new Map();
|
|
6
|
+
const roots = nodeIds.filter((id) => !edges.some((edge) => edge.target === id));
|
|
7
|
+
const queue = [...roots];
|
|
8
|
+
for (const id of queue) depth.set(id, 0);
|
|
9
|
+
const guardLimit = nodeIds.length * nodeIds.length + 1;
|
|
10
|
+
for (let guard = 0; queue.length > 0 && guard < guardLimit; guard++) {
|
|
11
|
+
const current = queue.shift();
|
|
12
|
+
if (current === void 0) break;
|
|
13
|
+
const currentDepth = depth.get(current) ?? 0;
|
|
14
|
+
for (const edge of edges) {
|
|
15
|
+
if (edge.source !== current) continue;
|
|
16
|
+
const next = currentDepth + 1;
|
|
17
|
+
if (next > (depth.get(edge.target) ?? -1) && next < nodeIds.length) {
|
|
18
|
+
depth.set(edge.target, next);
|
|
19
|
+
queue.push(edge.target);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const maxDepth = Math.max(0, ...depth.values());
|
|
24
|
+
const columns = /* @__PURE__ */ new Map();
|
|
25
|
+
for (const id of nodeIds) {
|
|
26
|
+
const column = depth.get(id) ?? maxDepth + 1;
|
|
27
|
+
columns.set(column, [...columns.get(column) ?? [], id]);
|
|
28
|
+
}
|
|
29
|
+
const positions = /* @__PURE__ */ new Map();
|
|
30
|
+
for (const [column, ids] of columns) {
|
|
31
|
+
ids.forEach((id, row) => {
|
|
32
|
+
positions.set(id, {
|
|
33
|
+
x: column * LAYOUT_COLUMN_WIDTH,
|
|
34
|
+
// `+ 0` turns the -0 Math.round can return into 0, so JSON never sees -0.
|
|
35
|
+
y: Math.round((row - (ids.length - 1) / 2) * LAYOUT_ROW_HEIGHT) + 0
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return positions;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { LAYOUT_COLUMN_WIDTH, LAYOUT_ROW_HEIGHT, autoLayout };
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkG4UEPUGO_cjs = require('./chunk-G4UEPUGO.cjs');
|
|
4
|
+
var chunk27HASETB_cjs = require('./chunk-27HASETB.cjs');
|
|
5
|
+
var chunkLRM6JXJA_cjs = require('./chunk-LRM6JXJA.cjs');
|
|
6
|
+
|
|
7
|
+
// src/ir/node-types.ts
|
|
8
|
+
var EXECUTOR_INTERNAL_TYPES = /* @__PURE__ */ new Set([
|
|
9
|
+
"internal:if",
|
|
10
|
+
"internal:switch",
|
|
11
|
+
"internal:loop",
|
|
12
|
+
"internal:merge",
|
|
13
|
+
"internal:set",
|
|
14
|
+
"internal:filter",
|
|
15
|
+
"internal:aggregate",
|
|
16
|
+
"internal:wait",
|
|
17
|
+
"internal:noop",
|
|
18
|
+
"internal:code",
|
|
19
|
+
"internal:http",
|
|
20
|
+
"internal:transform",
|
|
21
|
+
"internal:validate",
|
|
22
|
+
"internal:log",
|
|
23
|
+
"internal:error",
|
|
24
|
+
"internal:subworkflow",
|
|
25
|
+
"internal:compare-datasets",
|
|
26
|
+
"internal:split-out",
|
|
27
|
+
"internal:limit",
|
|
28
|
+
"internal:dedupe",
|
|
29
|
+
"internal:sort",
|
|
30
|
+
"internal:datatable",
|
|
31
|
+
"internal:respond-to-webhook",
|
|
32
|
+
"internal:send-and-wait",
|
|
33
|
+
"if",
|
|
34
|
+
"switch",
|
|
35
|
+
"loop",
|
|
36
|
+
"merge",
|
|
37
|
+
"set",
|
|
38
|
+
"filter",
|
|
39
|
+
"aggregate",
|
|
40
|
+
"wait",
|
|
41
|
+
"noop",
|
|
42
|
+
"code",
|
|
43
|
+
"http",
|
|
44
|
+
"transform",
|
|
45
|
+
"validate",
|
|
46
|
+
"log",
|
|
47
|
+
"error",
|
|
48
|
+
"subworkflow"
|
|
49
|
+
]);
|
|
50
|
+
var CODE_WORKFLOW_NODE_TYPE = "internal:code-workflow";
|
|
51
|
+
var WAIT_FOR_SIGNAL_NODE_TYPE = "internal:wait-for-signal";
|
|
52
|
+
var V2_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
53
|
+
CODE_WORKFLOW_NODE_TYPE,
|
|
54
|
+
WAIT_FOR_SIGNAL_NODE_TYPE
|
|
55
|
+
]);
|
|
56
|
+
var INTERNAL_TRIGGER_TYPES = /* @__PURE__ */ new Set([
|
|
57
|
+
"internal:api",
|
|
58
|
+
"internal:schedule",
|
|
59
|
+
"internal:webhook",
|
|
60
|
+
"internal:form",
|
|
61
|
+
"internal:error-trigger",
|
|
62
|
+
"internal:workflow-call",
|
|
63
|
+
"internal:rss-feed",
|
|
64
|
+
"internal:http-poll",
|
|
65
|
+
"internal:database-poll",
|
|
66
|
+
"internal:email-imap",
|
|
67
|
+
"internal:file-upload",
|
|
68
|
+
"internal:record-change",
|
|
69
|
+
"internal:state-change"
|
|
70
|
+
]);
|
|
71
|
+
function usesMergedParameters(type) {
|
|
72
|
+
const lower = type.toLowerCase();
|
|
73
|
+
return EXECUTOR_INTERNAL_TYPES.has(lower) || V2_NODE_TYPES.has(lower);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/ir/normalize.ts
|
|
77
|
+
function isNonEmptyString(value) {
|
|
78
|
+
return typeof value === "string" && value !== "";
|
|
79
|
+
}
|
|
80
|
+
function firstTruthy(...values) {
|
|
81
|
+
for (const value of values) if (value) return value;
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
function readPosition(value) {
|
|
85
|
+
if (!chunkLRM6JXJA_cjs.isRecord(value)) return void 0;
|
|
86
|
+
const { x, y } = value;
|
|
87
|
+
return typeof x === "number" && typeof y === "number" && Number.isFinite(x) && Number.isFinite(y) ? { x, y } : void 0;
|
|
88
|
+
}
|
|
89
|
+
function removeIfEmpty(parent, key) {
|
|
90
|
+
const value = parent[key];
|
|
91
|
+
if (chunkLRM6JXJA_cjs.isRecord(value) && Object.keys(value).length === 0) delete parent[key];
|
|
92
|
+
}
|
|
93
|
+
function normalizeLabel(node, data) {
|
|
94
|
+
if (node["label"] === void 0 && typeof data["label"] === "string")
|
|
95
|
+
node["label"] = data["label"];
|
|
96
|
+
if (data["label"] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(data["label"], node["label"])) delete data["label"];
|
|
97
|
+
}
|
|
98
|
+
function normalizeOperation(node, data) {
|
|
99
|
+
if (!isNonEmptyString(node["operation_name"]) && isNonEmptyString(data["operation_name"])) {
|
|
100
|
+
node["operation_name"] = data["operation_name"];
|
|
101
|
+
}
|
|
102
|
+
if (data["operation_name"] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(data["operation_name"], node["operation_name"])) {
|
|
103
|
+
delete data["operation_name"];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function normalizeVersion(node, data, merged) {
|
|
107
|
+
if (merged) return;
|
|
108
|
+
const effective = firstTruthy(data["version"], node["version"]);
|
|
109
|
+
if (typeof effective === "string") node["version"] = effective;
|
|
110
|
+
if (data["version"] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(data["version"], node["version"]))
|
|
111
|
+
delete data["version"];
|
|
112
|
+
if (data["nodeVersion"] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(data["nodeVersion"], node["version"])) {
|
|
113
|
+
delete data["nodeVersion"];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function normalizeExternalState(node, data) {
|
|
117
|
+
const args = chunkLRM6JXJA_cjs.isRecord(node["args"]) ? node["args"] : void 0;
|
|
118
|
+
const dataArgs = chunkLRM6JXJA_cjs.isRecord(data["args"]) ? data["args"] : void 0;
|
|
119
|
+
const effective = firstTruthy(args?.["state"], dataArgs?.["state"], data["state"]);
|
|
120
|
+
if (effective !== void 0 && args?.["state"] === void 0) {
|
|
121
|
+
const nextArgs = args ?? {};
|
|
122
|
+
nextArgs["state"] = effective;
|
|
123
|
+
node["args"] = nextArgs;
|
|
124
|
+
}
|
|
125
|
+
const rootState = chunkLRM6JXJA_cjs.isRecord(node["args"]) ? node["args"]["state"] : void 0;
|
|
126
|
+
if (dataArgs && dataArgs["state"] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(dataArgs["state"], rootState)) {
|
|
127
|
+
delete dataArgs["state"];
|
|
128
|
+
}
|
|
129
|
+
if (data["state"] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(data["state"], rootState)) delete data["state"];
|
|
130
|
+
}
|
|
131
|
+
function normalizeMergedState(node, data) {
|
|
132
|
+
const args = chunkLRM6JXJA_cjs.isRecord(node["args"]) ? node["args"] : {};
|
|
133
|
+
const dataArgs = chunkLRM6JXJA_cjs.isRecord(data["args"]) ? data["args"] : void 0;
|
|
134
|
+
const config = chunkLRM6JXJA_cjs.isRecord(node["config"]) ? node["config"] : void 0;
|
|
135
|
+
const dataState = chunkLRM6JXJA_cjs.isRecord(dataArgs?.["state"]) ? dataArgs["state"] : void 0;
|
|
136
|
+
const rootState = chunkLRM6JXJA_cjs.isRecord(args["state"]) ? args["state"] : void 0;
|
|
137
|
+
if (config === void 0 && dataState === void 0) return;
|
|
138
|
+
args["state"] = { ...config, ...dataState, ...rootState };
|
|
139
|
+
node["args"] = args;
|
|
140
|
+
if (config !== void 0) delete node["config"];
|
|
141
|
+
if (dataArgs && dataState !== void 0) delete dataArgs["state"];
|
|
142
|
+
}
|
|
143
|
+
function normalizeConnections(node, data) {
|
|
144
|
+
const dataArgs = chunkLRM6JXJA_cjs.isRecord(data["args"]) ? data["args"] : void 0;
|
|
145
|
+
if (!dataArgs) return;
|
|
146
|
+
for (const key of ["connections", "credentials"]) {
|
|
147
|
+
const args = chunkLRM6JXJA_cjs.isRecord(node["args"]) ? node["args"] : void 0;
|
|
148
|
+
if (!args?.[key] && dataArgs[key]) {
|
|
149
|
+
const nextArgs = args ?? {};
|
|
150
|
+
nextArgs[key] = dataArgs[key];
|
|
151
|
+
node["args"] = nextArgs;
|
|
152
|
+
}
|
|
153
|
+
const rootValue = chunkLRM6JXJA_cjs.isRecord(node["args"]) ? node["args"][key] : void 0;
|
|
154
|
+
if (dataArgs[key] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(dataArgs[key], rootValue)) delete dataArgs[key];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function normalizeContext(node, data) {
|
|
158
|
+
const dataArgs = chunkLRM6JXJA_cjs.isRecord(data["args"]) ? data["args"] : void 0;
|
|
159
|
+
const args = chunkLRM6JXJA_cjs.isRecord(node["args"]) ? node["args"] : void 0;
|
|
160
|
+
if (!dataArgs || dataArgs["context"] === void 0) return;
|
|
161
|
+
if (args && chunkLRM6JXJA_cjs.deepEqual(dataArgs["context"], args["context"])) delete dataArgs["context"];
|
|
162
|
+
}
|
|
163
|
+
function normalizeErrorConfig(node, data) {
|
|
164
|
+
const dataArgs = chunkLRM6JXJA_cjs.isRecord(data["args"]) ? data["args"] : void 0;
|
|
165
|
+
const dataState = chunkLRM6JXJA_cjs.isRecord(dataArgs?.["state"]) ? dataArgs["state"] : void 0;
|
|
166
|
+
const effective = node["errorConfig"] ?? data["errorConfig"] ?? dataState?.["errorConfig"];
|
|
167
|
+
if (effective !== void 0 && effective !== null) node["errorConfig"] = effective;
|
|
168
|
+
if (data["errorConfig"] !== void 0 && chunkLRM6JXJA_cjs.deepEqual(data["errorConfig"], node["errorConfig"])) {
|
|
169
|
+
delete data["errorConfig"];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function normalizeExecutionSettings(node, data) {
|
|
173
|
+
const root = chunkLRM6JXJA_cjs.isRecord(node["executionSettings"]) ? node["executionSettings"] : void 0;
|
|
174
|
+
const mirror = chunkLRM6JXJA_cjs.isRecord(data["executionSettings"]) ? data["executionSettings"] : void 0;
|
|
175
|
+
if (!root && !mirror) return;
|
|
176
|
+
const merged = { ...root };
|
|
177
|
+
for (const [key, value] of Object.entries(mirror ?? {}))
|
|
178
|
+
if (!Object.hasOwn(merged, key)) merged[key] = value;
|
|
179
|
+
if (root?.["executeOnce"] === true || mirror?.["executeOnce"] === true)
|
|
180
|
+
merged["executeOnce"] = true;
|
|
181
|
+
if (mirror && Object.hasOwn(mirror, "runOn")) {
|
|
182
|
+
merged["runOn"] = mirror["runOn"];
|
|
183
|
+
data["executionSettings"] = { runOn: mirror["runOn"] };
|
|
184
|
+
} else {
|
|
185
|
+
if (mirror) delete data["executionSettings"];
|
|
186
|
+
}
|
|
187
|
+
node["executionSettings"] = merged;
|
|
188
|
+
}
|
|
189
|
+
function normalizeDisabled(node, data) {
|
|
190
|
+
if (node["disabled"] === true || data["disabled"] === true) node["disabled"] = true;
|
|
191
|
+
delete data["disabled"];
|
|
192
|
+
}
|
|
193
|
+
function normalizeNode(raw) {
|
|
194
|
+
if (!chunkLRM6JXJA_cjs.isRecord(raw)) return raw;
|
|
195
|
+
const node = chunkLRM6JXJA_cjs.cloneJson(raw);
|
|
196
|
+
const type = typeof node["type"] === "string" ? node["type"] : "";
|
|
197
|
+
const merged = usesMergedParameters(type);
|
|
198
|
+
const data = chunkLRM6JXJA_cjs.isRecord(node["data"]) ? node["data"] : {};
|
|
199
|
+
normalizeLabel(node, data);
|
|
200
|
+
normalizeOperation(node, data);
|
|
201
|
+
normalizeVersion(node, data, merged);
|
|
202
|
+
normalizeErrorConfig(node, data);
|
|
203
|
+
if (merged) normalizeMergedState(node, data);
|
|
204
|
+
else normalizeExternalState(node, data);
|
|
205
|
+
normalizeConnections(node, data);
|
|
206
|
+
normalizeContext(node, data);
|
|
207
|
+
normalizeExecutionSettings(node, data);
|
|
208
|
+
normalizeDisabled(node, data);
|
|
209
|
+
if (chunkLRM6JXJA_cjs.isRecord(data["args"])) removeIfEmpty(data, "args");
|
|
210
|
+
if (Object.keys(data).length === 0) delete node["data"];
|
|
211
|
+
else node["data"] = data;
|
|
212
|
+
return node;
|
|
213
|
+
}
|
|
214
|
+
function normalizeDefinition(definition) {
|
|
215
|
+
if (!chunkLRM6JXJA_cjs.isRecord(definition) || !chunkLRM6JXJA_cjs.isRecord(definition["data"])) return definition;
|
|
216
|
+
const doc = chunkLRM6JXJA_cjs.cloneJson(definition);
|
|
217
|
+
const data = doc["data"];
|
|
218
|
+
const rawNodes = Array.isArray(data["nodes"]) ? data["nodes"] : [];
|
|
219
|
+
const nodes = rawNodes.map(normalizeNode);
|
|
220
|
+
data["nodes"] = nodes;
|
|
221
|
+
const edges = Array.isArray(data["edges"]) ? data["edges"].filter(chunkLRM6JXJA_cjs.isRecord) : [];
|
|
222
|
+
const ids = nodes.flatMap(
|
|
223
|
+
(node) => chunkLRM6JXJA_cjs.isRecord(node) && typeof node["id"] === "string" ? [node["id"]] : []
|
|
224
|
+
);
|
|
225
|
+
const missing = nodes.some(
|
|
226
|
+
(node) => chunkLRM6JXJA_cjs.isRecord(node) && readPosition(node["position"]) === void 0
|
|
227
|
+
);
|
|
228
|
+
if (missing) {
|
|
229
|
+
const meta = chunkLRM6JXJA_cjs.isRecord(doc["meta"]) ? doc["meta"] : void 0;
|
|
230
|
+
const metaLayout = chunkLRM6JXJA_cjs.isRecord(meta?.["layout"]) ? meta["layout"] : void 0;
|
|
231
|
+
const computed = chunkG4UEPUGO_cjs.autoLayout(
|
|
232
|
+
ids,
|
|
233
|
+
edges.flatMap(
|
|
234
|
+
(edge) => typeof edge["source"] === "string" && typeof edge["target"] === "string" ? [{ source: edge["source"], target: edge["target"] }] : []
|
|
235
|
+
)
|
|
236
|
+
);
|
|
237
|
+
for (const node of nodes) {
|
|
238
|
+
if (!chunkLRM6JXJA_cjs.isRecord(node) || typeof node["id"] !== "string") continue;
|
|
239
|
+
if (readPosition(node["position"]) !== void 0) continue;
|
|
240
|
+
const fromMeta = readPosition(metaLayout?.[node["id"]]);
|
|
241
|
+
const position = fromMeta ?? computed.get(node["id"]);
|
|
242
|
+
if (position) node["position"] = { x: position.x, y: position.y };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
doc["schemaVersion"] = 2;
|
|
246
|
+
return doc;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/ir/hash.ts
|
|
250
|
+
function hashedProjection(definition) {
|
|
251
|
+
const normalized = normalizeDefinition(definition);
|
|
252
|
+
if (!chunkLRM6JXJA_cjs.isRecord(normalized)) return normalized;
|
|
253
|
+
const copy = { ...normalized };
|
|
254
|
+
delete copy["authoring"];
|
|
255
|
+
return copy;
|
|
256
|
+
}
|
|
257
|
+
function irHash(definition) {
|
|
258
|
+
return chunk27HASETB_cjs.sha256Tagged(chunk27HASETB_cjs.canonicalJson(hashedProjection(definition)));
|
|
259
|
+
}
|
|
260
|
+
function sourceHash(files) {
|
|
261
|
+
const entries = [...files].sort(
|
|
262
|
+
(a, b) => a.path === b.path ? a.content < b.content ? -1 : a.content > b.content ? 1 : 0 : a.path < b.path ? -1 : 1
|
|
263
|
+
).map((file) => [file.path, file.content]);
|
|
264
|
+
return chunk27HASETB_cjs.sha256Tagged(chunk27HASETB_cjs.canonicalJson(entries));
|
|
265
|
+
}
|
|
266
|
+
function buildIdOf(bundle) {
|
|
267
|
+
return chunk27HASETB_cjs.sha256Tagged(bundle);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
exports.CODE_WORKFLOW_NODE_TYPE = CODE_WORKFLOW_NODE_TYPE;
|
|
271
|
+
exports.INTERNAL_TRIGGER_TYPES = INTERNAL_TRIGGER_TYPES;
|
|
272
|
+
exports.V2_NODE_TYPES = V2_NODE_TYPES;
|
|
273
|
+
exports.WAIT_FOR_SIGNAL_NODE_TYPE = WAIT_FOR_SIGNAL_NODE_TYPE;
|
|
274
|
+
exports.buildIdOf = buildIdOf;
|
|
275
|
+
exports.hashedProjection = hashedProjection;
|
|
276
|
+
exports.irHash = irHash;
|
|
277
|
+
exports.normalizeDefinition = normalizeDefinition;
|
|
278
|
+
exports.sourceHash = sourceHash;
|
|
279
|
+
exports.usesMergedParameters = usesMergedParameters;
|