@hatua/model 0.0.0 → 0.1.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 +21 -0
- package/dist/authoring.d.ts +47 -0
- package/dist/blocks.d.ts +119 -0
- package/dist/blocks.test.d.ts +1 -0
- package/dist/connections.d.ts +61 -0
- package/dist/connections.test.d.ts +1 -0
- package/dist/diagnostic.d.ts +60 -0
- package/dist/execution.d.ts +43 -0
- package/dist/fixtures.d.ts +10 -0
- package/dist/generated/diagnostics.d.ts +18 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +965 -0
- package/dist/loops.test.d.ts +1 -0
- package/dist/metadata.d.ts +45 -0
- package/dist/metadata.test.d.ts +1 -0
- package/dist/rules.conformance.test.d.ts +1 -0
- package/dist/scope.d.ts +162 -0
- package/dist/scope.test.d.ts +1 -0
- package/dist/segment.d.ts +107 -0
- package/dist/segment.test.d.ts +1 -0
- package/dist/slots.d.ts +161 -0
- package/dist/slots.test.d.ts +1 -0
- package/dist/tree.d.ts +311 -0
- package/dist/tree.test.d.ts +1 -0
- package/dist/validity.d.ts +167 -0
- package/dist/validity.test.d.ts +1 -0
- package/package.json +27 -5
- package/README.md +0 -5
package/dist/index.js
ADDED
|
@@ -0,0 +1,965 @@
|
|
|
1
|
+
import { TRIGGER_BUILTIN as e, isMappable as t } from "@hatua/schema";
|
|
2
|
+
import { CORE_FUNCTIONS as n, elementOf as r, sourceReference as i, validate as a } from "@hatua/expressions";
|
|
3
|
+
//#region src/tree.ts
|
|
4
|
+
var o = (e, t) => e && Object.hasOwn(e, t) ? e[t] : void 0;
|
|
5
|
+
function* s(e) {
|
|
6
|
+
yield {
|
|
7
|
+
id: null,
|
|
8
|
+
steps: e.steps
|
|
9
|
+
};
|
|
10
|
+
for (let t of e.blocks ?? []) yield {
|
|
11
|
+
id: t.id,
|
|
12
|
+
block: t,
|
|
13
|
+
steps: t.steps
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function c(e, t) {
|
|
17
|
+
for (let n of s(e)) if (n.id === t) return n;
|
|
18
|
+
}
|
|
19
|
+
var l = "core.try", u = "core.repeat";
|
|
20
|
+
function* d(e) {
|
|
21
|
+
let t = e.branches ?? [];
|
|
22
|
+
for (let [e, n] of t.entries()) yield {
|
|
23
|
+
kind: "branch",
|
|
24
|
+
keyword: f(t, e),
|
|
25
|
+
always: !1,
|
|
26
|
+
branch: n,
|
|
27
|
+
steps: n.steps
|
|
28
|
+
};
|
|
29
|
+
e.steps && (yield {
|
|
30
|
+
kind: "body",
|
|
31
|
+
keyword: p(e),
|
|
32
|
+
always: e.use === "core.try" || e.use === "core.repeat",
|
|
33
|
+
steps: e.steps
|
|
34
|
+
}), e.handler && (yield {
|
|
35
|
+
kind: "handler",
|
|
36
|
+
keyword: "on failure",
|
|
37
|
+
always: !1,
|
|
38
|
+
steps: e.handler
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function f(e, t) {
|
|
42
|
+
return e.some((e) => e.when !== void 0) ? e[t]?.when === void 0 ? "else" : t === 0 ? "if" : "else if" : "and";
|
|
43
|
+
}
|
|
44
|
+
var p = (e) => e.use === "core.try" ? "attempt" : "loop", m = (e) => !d(e).next().done, ee = (e) => e.name || e.id;
|
|
45
|
+
function te(e) {
|
|
46
|
+
let t = [...d(e)], n = [e.use], r = t.filter((e) => e.kind === "branch").length;
|
|
47
|
+
r > 0 && n.push(`${r} ${r === 1 ? "branch" : "branches"}`);
|
|
48
|
+
for (let e of t) e.kind !== "branch" && (e.kind === "handler" ? n.push("handler") : n.push(`${e.steps.length} ${e.steps.length === 1 ? "step" : "steps"}`));
|
|
49
|
+
return n.join(" · ");
|
|
50
|
+
}
|
|
51
|
+
function* h(e) {
|
|
52
|
+
for (let t of e) {
|
|
53
|
+
yield t;
|
|
54
|
+
for (let e of d(t)) yield* h(e.steps);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function* g(e) {
|
|
58
|
+
for (let t of s(e)) for (let e of h(t.steps)) yield {
|
|
59
|
+
step: e,
|
|
60
|
+
board: t.id,
|
|
61
|
+
id: e.id
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
var _ = ({ board: e, id: t }) => e === null ? t : `${e}/${t}`, v = (e) => e === null ? "board:root" : `board:${e}`, ne = ({ board: e, id: t, kind: n, branchIndex: r }) => `${_({
|
|
65
|
+
board: e,
|
|
66
|
+
id: t
|
|
67
|
+
})}#${n}${r === void 0 ? "" : `:${r}`}`;
|
|
68
|
+
function re(e, t) {
|
|
69
|
+
let n = c(e, t.board);
|
|
70
|
+
if (n) {
|
|
71
|
+
for (let e of h(n.steps)) if (e.id === t.id) return e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
var y = (e, t) => t === null ? e.vars ?? [] : c(e, t)?.block?.vars ?? [], ie = (e, t, n) => y(e, t).find((e) => e.key === n);
|
|
75
|
+
function ae(e, t) {
|
|
76
|
+
let n = c(e, t);
|
|
77
|
+
return new Set(n ? [...h(n.steps)].map((e) => e.id) : []);
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/blocks.ts
|
|
81
|
+
var oe = "block.", se = "core.return", b = (e) => e.startsWith("block.") ? e.slice(6) : null, x = (e, t) => e.blocks?.find((e) => e.id === t), S = (e, t) => ce(t.params, e), C = (e, t) => ce(t.outputs, e), ce = (e, t) => {
|
|
82
|
+
let n = t.with ?? {}, r = [];
|
|
83
|
+
for (let t of e ?? []) {
|
|
84
|
+
let e = o(n, t.k);
|
|
85
|
+
typeof e == "string" && r.push({
|
|
86
|
+
name: t.k,
|
|
87
|
+
template: e,
|
|
88
|
+
expectedType: t.t
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return r;
|
|
92
|
+
};
|
|
93
|
+
function w(e) {
|
|
94
|
+
let t = [], n = (e) => {
|
|
95
|
+
for (let r of e) {
|
|
96
|
+
let e = b(r.use);
|
|
97
|
+
e !== null && t.push(e);
|
|
98
|
+
for (let e of d(r)) n(e.steps);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return n(e), t;
|
|
102
|
+
}
|
|
103
|
+
function le(e) {
|
|
104
|
+
let t = /* @__PURE__ */ new Map();
|
|
105
|
+
for (let n of e.blocks ?? []) t.has(n.id) || t.set(n.id, w(n.steps));
|
|
106
|
+
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = [], o = /* @__PURE__ */ new Set(), s = 0, c = (e) => {
|
|
107
|
+
r.set(e, s), i.set(e, s), s += 1, a.push(e), o.add(e);
|
|
108
|
+
for (let n of t.get(e) ?? []) t.has(n) && (r.has(n) ? o.has(n) && i.set(e, Math.min(i.get(e) ?? 0, r.get(n) ?? 0)) : (c(n), i.set(e, Math.min(i.get(e) ?? 0, i.get(n) ?? 0))));
|
|
109
|
+
if (i.get(e) !== r.get(e)) return;
|
|
110
|
+
let l = [], u;
|
|
111
|
+
do {
|
|
112
|
+
if (u = a.pop(), u === void 0) break;
|
|
113
|
+
o.delete(u), l.push(u);
|
|
114
|
+
} while (u !== e);
|
|
115
|
+
let d = l.length === 1 && (t.get(e) ?? []).includes(e);
|
|
116
|
+
if (l.length > 1 || d) for (let e of l) n.add(e);
|
|
117
|
+
};
|
|
118
|
+
for (let e of t.keys()) r.has(e) || c(e);
|
|
119
|
+
return n;
|
|
120
|
+
}
|
|
121
|
+
function ue(e, t) {
|
|
122
|
+
let n = [];
|
|
123
|
+
for (let { step: r, board: i, id: a } of g(e)) b(r.use) === t && n.push({
|
|
124
|
+
board: i,
|
|
125
|
+
id: a
|
|
126
|
+
});
|
|
127
|
+
return n;
|
|
128
|
+
}
|
|
129
|
+
var de = (e) => {
|
|
130
|
+
let t = e?.params?.length ?? 0, n = e?.outputs?.length ?? 0;
|
|
131
|
+
return `${t} ${t === 1 ? "param" : "params"} · ${n} ${n === 1 ? "output" : "outputs"}`;
|
|
132
|
+
};
|
|
133
|
+
function fe(e, t) {
|
|
134
|
+
let n = /* @__PURE__ */ new Set();
|
|
135
|
+
for (let e of t) e.blockId && n.add(e.blockId);
|
|
136
|
+
let r = /* @__PURE__ */ new Map();
|
|
137
|
+
for (let t of e.blocks ?? []) for (let e of w(t.steps)) {
|
|
138
|
+
let n = r.get(e);
|
|
139
|
+
n ? n.push(t.id) : r.set(e, [t.id]);
|
|
140
|
+
}
|
|
141
|
+
let i = [...n];
|
|
142
|
+
for (let e = i.pop(); e !== void 0; e = i.pop()) for (let t of r.get(e) ?? []) n.has(t) || (n.add(t), i.push(t));
|
|
143
|
+
return n;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/slots.ts
|
|
147
|
+
var T = {
|
|
148
|
+
text: "text",
|
|
149
|
+
mono: "text",
|
|
150
|
+
textarea: "text",
|
|
151
|
+
number: "number",
|
|
152
|
+
ref: "unknown",
|
|
153
|
+
map: "unknown"
|
|
154
|
+
};
|
|
155
|
+
function E(e, n) {
|
|
156
|
+
let r = e.with ?? {}, i = [];
|
|
157
|
+
for (let e of n.fields ?? []) {
|
|
158
|
+
if (!t(e.kind)) continue;
|
|
159
|
+
let n = o(r, e.k);
|
|
160
|
+
if (e.kind === "map") {
|
|
161
|
+
for (let t of M(n)) i.push({
|
|
162
|
+
name: `${e.k}.${t.key}`,
|
|
163
|
+
template: t.value,
|
|
164
|
+
expectedType: t.type
|
|
165
|
+
});
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
typeof n == "string" && i.push({
|
|
169
|
+
name: e.k,
|
|
170
|
+
template: n,
|
|
171
|
+
expectedType: T[e.kind] ?? "text"
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return i;
|
|
175
|
+
}
|
|
176
|
+
var D = (e) => ({
|
|
177
|
+
name: "when",
|
|
178
|
+
template: e,
|
|
179
|
+
expectedType: "boolean"
|
|
180
|
+
}), pe = "core.map", me = "core.for_each", he = "core.fork", ge = "core.set_var", O = "list", _e = "item", k = (e) => ({
|
|
181
|
+
name: "until",
|
|
182
|
+
template: e,
|
|
183
|
+
expectedType: "boolean"
|
|
184
|
+
}), A = (e) => e.t ? e.t : "unknown";
|
|
185
|
+
function j(e, t, n) {
|
|
186
|
+
let r = n.with ?? {}, i = o(r, "key");
|
|
187
|
+
if (typeof i != "string") return null;
|
|
188
|
+
let a = ie(e, t, i);
|
|
189
|
+
if (!a) return null;
|
|
190
|
+
let s = o(r, "value");
|
|
191
|
+
return typeof s == "string" ? {
|
|
192
|
+
name: "value",
|
|
193
|
+
template: s,
|
|
194
|
+
expectedType: A(a)
|
|
195
|
+
} : null;
|
|
196
|
+
}
|
|
197
|
+
function ve(e) {
|
|
198
|
+
return typeof e.value == "string" ? {
|
|
199
|
+
name: e.key,
|
|
200
|
+
template: e.value,
|
|
201
|
+
expectedType: A(e)
|
|
202
|
+
} : null;
|
|
203
|
+
}
|
|
204
|
+
function M(e) {
|
|
205
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "object" && !!e && typeof e.key == "string" && typeof e.value == "string" && typeof e.type == "string") : [];
|
|
206
|
+
}
|
|
207
|
+
function N(e, t, n, r) {
|
|
208
|
+
let i = b(n.use);
|
|
209
|
+
if (i !== null) {
|
|
210
|
+
let t = x(e, i);
|
|
211
|
+
return t ? S(n, t) : [];
|
|
212
|
+
}
|
|
213
|
+
if (n.use === "core.return" && t !== null) {
|
|
214
|
+
let r = x(e, t);
|
|
215
|
+
return r ? C(n, r) : [];
|
|
216
|
+
}
|
|
217
|
+
if (n.use === "core.set_var") {
|
|
218
|
+
let r = j(e, t, n);
|
|
219
|
+
return r ? [r] : [];
|
|
220
|
+
}
|
|
221
|
+
return r ? E(n, r) : [];
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/authoring.ts
|
|
225
|
+
function ye(e) {
|
|
226
|
+
return e === "core.try" ? {
|
|
227
|
+
steps: [],
|
|
228
|
+
handler: []
|
|
229
|
+
} : e === "core.for_each" || e === "core.repeat" ? { steps: [] } : e === "core.fork" ? { branches: [{
|
|
230
|
+
label: "Condition",
|
|
231
|
+
when: "",
|
|
232
|
+
steps: []
|
|
233
|
+
}, {
|
|
234
|
+
label: "Otherwise",
|
|
235
|
+
steps: []
|
|
236
|
+
}] } : {};
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/generated/diagnostics.ts
|
|
240
|
+
var P = {
|
|
241
|
+
FIELD_REQUIRED: {
|
|
242
|
+
code: "FIELD_REQUIRED",
|
|
243
|
+
blocks: "publish",
|
|
244
|
+
message: "{label} is required."
|
|
245
|
+
},
|
|
246
|
+
COMPONENT_UNKNOWN: {
|
|
247
|
+
code: "COMPONENT_UNKNOWN",
|
|
248
|
+
blocks: "edit",
|
|
249
|
+
message: "Nothing declares \"{use}\". It may no longer be available."
|
|
250
|
+
},
|
|
251
|
+
FORK_HAS_NO_BRANCHES: {
|
|
252
|
+
code: "FORK_HAS_NO_BRANCHES",
|
|
253
|
+
blocks: "publish",
|
|
254
|
+
message: "This fork has no branches. Add the two paths it chooses between."
|
|
255
|
+
},
|
|
256
|
+
FORK_NEEDS_TWO_BRANCHES: {
|
|
257
|
+
code: "FORK_NEEDS_TWO_BRANCHES",
|
|
258
|
+
blocks: "publish",
|
|
259
|
+
message: "A fork needs at least two branches — add the other path."
|
|
260
|
+
},
|
|
261
|
+
BRANCH_UNREACHABLE_AFTER: {
|
|
262
|
+
code: "BRANCH_UNREACHABLE_AFTER",
|
|
263
|
+
blocks: "publish",
|
|
264
|
+
message: "\"{label}\" has no condition, so nothing after it can ever run. Only the last branch may be unconditional."
|
|
265
|
+
},
|
|
266
|
+
LOOP_HAS_NO_BODY: {
|
|
267
|
+
code: "LOOP_HAS_NO_BODY",
|
|
268
|
+
blocks: "publish",
|
|
269
|
+
message: "This loop repeats nothing. Add at least one Step inside it."
|
|
270
|
+
},
|
|
271
|
+
TRY_HAS_NO_BODY: {
|
|
272
|
+
code: "TRY_HAS_NO_BODY",
|
|
273
|
+
blocks: "publish",
|
|
274
|
+
message: "This try protects nothing. Add at least one Step to its body."
|
|
275
|
+
},
|
|
276
|
+
TRY_HAS_NO_HANDLER: {
|
|
277
|
+
code: "TRY_HAS_NO_HANDLER",
|
|
278
|
+
blocks: "publish",
|
|
279
|
+
message: "This try has no handler, so a failure has nowhere to go. Add a Step to `handler:`."
|
|
280
|
+
},
|
|
281
|
+
LOOP_LIST_NOT_A_LIST: {
|
|
282
|
+
code: "LOOP_LIST_NOT_A_LIST",
|
|
283
|
+
blocks: "publish",
|
|
284
|
+
message: "\"{name}\" is {actual}, not a list, so there is nothing to iterate."
|
|
285
|
+
},
|
|
286
|
+
REPEAT_HAS_NO_CONDITION: {
|
|
287
|
+
code: "REPEAT_HAS_NO_CONDITION",
|
|
288
|
+
blocks: "publish",
|
|
289
|
+
message: "This repeat has no condition, so nothing ever ends it. Give it an `until`."
|
|
290
|
+
},
|
|
291
|
+
VAR_UNKNOWN: {
|
|
292
|
+
code: "VAR_UNKNOWN",
|
|
293
|
+
blocks: "publish",
|
|
294
|
+
message: "No variable called \"{name}\" is declared on this board."
|
|
295
|
+
},
|
|
296
|
+
BLOCK_UNKNOWN: {
|
|
297
|
+
code: "BLOCK_UNKNOWN",
|
|
298
|
+
blocks: "publish",
|
|
299
|
+
message: "No block called \"{name}\" is declared in this workflow."
|
|
300
|
+
},
|
|
301
|
+
BLOCK_RECURSION: {
|
|
302
|
+
code: "BLOCK_RECURSION",
|
|
303
|
+
blocks: "publish",
|
|
304
|
+
message: "\"{name}\" calls itself, directly or through another block."
|
|
305
|
+
},
|
|
306
|
+
RETURN_OUTSIDE_BLOCK: {
|
|
307
|
+
code: "RETURN_OUTSIDE_BLOCK",
|
|
308
|
+
blocks: "publish",
|
|
309
|
+
message: "`core.return` publishes a block's outputs, and this is not inside a block."
|
|
310
|
+
},
|
|
311
|
+
BLOCK_PATH_WITHOUT_RETURN: {
|
|
312
|
+
code: "BLOCK_PATH_WITHOUT_RETURN",
|
|
313
|
+
blocks: "publish",
|
|
314
|
+
message: "\"{name}\" declares outputs, but a path through it can finish without returning."
|
|
315
|
+
},
|
|
316
|
+
STEP_AFTER_RETURN: {
|
|
317
|
+
code: "STEP_AFTER_RETURN",
|
|
318
|
+
blocks: "publish",
|
|
319
|
+
message: "Nothing after `core.return` can run."
|
|
320
|
+
},
|
|
321
|
+
BLOCK_ID_DUPLICATE: {
|
|
322
|
+
code: "BLOCK_ID_DUPLICATE",
|
|
323
|
+
blocks: "publish",
|
|
324
|
+
message: "More than one block is called \"{name}\"."
|
|
325
|
+
},
|
|
326
|
+
DECLARATION_KEY_DUPLICATE: {
|
|
327
|
+
code: "DECLARATION_KEY_DUPLICATE",
|
|
328
|
+
blocks: "publish",
|
|
329
|
+
message: "More than one {side} of \"{block}\" is called \"{name}\"."
|
|
330
|
+
},
|
|
331
|
+
STEP_ID_DUPLICATE: {
|
|
332
|
+
code: "STEP_ID_DUPLICATE",
|
|
333
|
+
blocks: "publish",
|
|
334
|
+
message: "More than one step on this board is called \"{name}\"."
|
|
335
|
+
},
|
|
336
|
+
CONNECTION_NOT_ESTABLISHED: {
|
|
337
|
+
code: "CONNECTION_NOT_ESTABLISHED",
|
|
338
|
+
blocks: "publish",
|
|
339
|
+
message: "\"{name}\" is not connected yet. Connect it before publishing."
|
|
340
|
+
},
|
|
341
|
+
CONNECTION_UNKNOWN: {
|
|
342
|
+
code: "CONNECTION_UNKNOWN",
|
|
343
|
+
blocks: "edit",
|
|
344
|
+
message: "\"{name}\" is not declared in this workflow."
|
|
345
|
+
},
|
|
346
|
+
CONNECTION_UNRESOLVABLE: {
|
|
347
|
+
code: "CONNECTION_UNRESOLVABLE",
|
|
348
|
+
blocks: "publish",
|
|
349
|
+
message: "\"{name}\" no longer resolves. Reconnect it or pick another."
|
|
350
|
+
},
|
|
351
|
+
CONNECTION_TYPE_MISMATCH: {
|
|
352
|
+
code: "CONNECTION_TYPE_MISMATCH",
|
|
353
|
+
blocks: "edit",
|
|
354
|
+
message: "{label} needs a {wanted} connection, but \"{name}\" is {actual}."
|
|
355
|
+
}
|
|
356
|
+
}, F = (e, t = {}) => P[e].message.replace(/\{(\w+)\}/g, (e, n) => Object.hasOwn(t, n) ? t[n] ?? e : e), I = (e, t, n) => ({
|
|
357
|
+
code: e,
|
|
358
|
+
message: F(e, n),
|
|
359
|
+
blocks: P[e].blocks,
|
|
360
|
+
...t
|
|
361
|
+
}), be = (e) => new Map(e.map((e) => [e.use, e])), L = (e) => typeof e == "string" && e.trim() !== "";
|
|
362
|
+
function R(e) {
|
|
363
|
+
return (e.connections ?? []).filter((e) => !L(e.ref)).map((e) => I("CONNECTION_NOT_ESTABLISHED", { connectionId: e.id }, { name: e.id }));
|
|
364
|
+
}
|
|
365
|
+
function z(e, t, n) {
|
|
366
|
+
let r = new Map((e.connections ?? []).map((e) => [e.id, e])), i = [], a = (e, a, s) => {
|
|
367
|
+
let c = t.get(a);
|
|
368
|
+
if (c) for (let t of c.fields) {
|
|
369
|
+
if (t.kind !== "conn") continue;
|
|
370
|
+
let a = o(s, t.k);
|
|
371
|
+
if (typeof a != "string" || a.trim() === "") continue;
|
|
372
|
+
let c = r.get(a);
|
|
373
|
+
if (!c) {
|
|
374
|
+
i.push(I("CONNECTION_UNKNOWN", {
|
|
375
|
+
...e,
|
|
376
|
+
connectionId: a,
|
|
377
|
+
fieldKey: t.k
|
|
378
|
+
}, { name: a }));
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (!L(c.ref) || !n || !t.conn_type) continue;
|
|
382
|
+
let l = n.get(c.ref);
|
|
383
|
+
if (!l) {
|
|
384
|
+
i.push(I("CONNECTION_UNRESOLVABLE", {
|
|
385
|
+
...e,
|
|
386
|
+
connectionId: c.id,
|
|
387
|
+
fieldKey: t.k
|
|
388
|
+
}, { name: c.id }));
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
l !== t.conn_type && i.push(I("CONNECTION_TYPE_MISMATCH", {
|
|
392
|
+
...e,
|
|
393
|
+
connectionId: c.id,
|
|
394
|
+
fieldKey: t.k
|
|
395
|
+
}, {
|
|
396
|
+
label: t.label,
|
|
397
|
+
wanted: t.conn_type,
|
|
398
|
+
name: c.id,
|
|
399
|
+
actual: l
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
for (let { step: t, board: n } of g(e)) a({
|
|
404
|
+
stepId: t.id,
|
|
405
|
+
...n === null ? {} : { blockId: n }
|
|
406
|
+
}, t.use, t.with);
|
|
407
|
+
for (let t of e.triggers ?? []) a({ triggerId: t.id }, t.use, t.with);
|
|
408
|
+
return i;
|
|
409
|
+
}
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/execution.ts
|
|
412
|
+
function xe(e, t) {
|
|
413
|
+
let n = [], r = (e) => {
|
|
414
|
+
for (let i of e ?? []) {
|
|
415
|
+
i.id === t && n.push(i);
|
|
416
|
+
for (let e of i.iterations ?? []) r(e.steps);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
return r(e.steps), n;
|
|
420
|
+
}
|
|
421
|
+
var B = {
|
|
422
|
+
failed: 4,
|
|
423
|
+
running: 3,
|
|
424
|
+
pending: 2,
|
|
425
|
+
succeeded: 1,
|
|
426
|
+
skipped: 0
|
|
427
|
+
};
|
|
428
|
+
function Se(e) {
|
|
429
|
+
let t = null;
|
|
430
|
+
for (let n of e) (!t || B[n.status] > B[t]) && (t = n.status);
|
|
431
|
+
return t;
|
|
432
|
+
}
|
|
433
|
+
function Ce(e, t) {
|
|
434
|
+
return (e.log ?? []).filter((e) => e.step === t);
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/metadata.ts
|
|
438
|
+
function we(e) {
|
|
439
|
+
let t = /* @__PURE__ */ new Map();
|
|
440
|
+
for (let n of e) n.metadata?.length && t.set(n.use, n.metadata);
|
|
441
|
+
return t;
|
|
442
|
+
}
|
|
443
|
+
function V(e, t) {
|
|
444
|
+
let n = [], r = (e) => {
|
|
445
|
+
for (let i of e) {
|
|
446
|
+
let e = t(i.id);
|
|
447
|
+
e && i.metadata && n.push({
|
|
448
|
+
use: e,
|
|
449
|
+
values: i.metadata
|
|
450
|
+
});
|
|
451
|
+
for (let e of i.iterations ?? []) e.steps && r(e.steps);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
return r(e.steps), n;
|
|
455
|
+
}
|
|
456
|
+
function Te(e, t, n) {
|
|
457
|
+
let r = /* @__PURE__ */ new Map();
|
|
458
|
+
for (let { use: i, values: a } of V(e, n)) for (let e of t.get(i) ?? []) {
|
|
459
|
+
if (e.role !== "measure") continue;
|
|
460
|
+
let t = a[e.k];
|
|
461
|
+
if (typeof t != "number") continue;
|
|
462
|
+
let n = r.get(e.k);
|
|
463
|
+
n ? n.total += t : r.set(e.k, {
|
|
464
|
+
key: e.k,
|
|
465
|
+
label: e.label,
|
|
466
|
+
total: t,
|
|
467
|
+
...e.unit ? { unit: e.unit } : {}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return [...r.values()];
|
|
471
|
+
}
|
|
472
|
+
function Ee(e, t, n, r, i) {
|
|
473
|
+
let a, o, s = /* @__PURE__ */ new Set();
|
|
474
|
+
for (let [e, n] of t) {
|
|
475
|
+
let t = n.find((e) => e.k === r && e.role === "measure"), c = n.find((e) => e.k === i && e.role === "dimension");
|
|
476
|
+
t && c && (a ??= t, o ??= c, s.add(e));
|
|
477
|
+
}
|
|
478
|
+
if (!a || !o) return null;
|
|
479
|
+
let c = /* @__PURE__ */ new Map();
|
|
480
|
+
for (let { use: t, values: a } of V(e, n)) {
|
|
481
|
+
if (!s.has(t)) continue;
|
|
482
|
+
let e = a[r], n = a[i];
|
|
483
|
+
if (typeof e != "number" || n == null) continue;
|
|
484
|
+
let o = String(n);
|
|
485
|
+
c.set(o, (c.get(o) ?? 0) + e);
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
measure: r,
|
|
489
|
+
measureLabel: a.label,
|
|
490
|
+
dimension: i,
|
|
491
|
+
dimensionLabel: o.label,
|
|
492
|
+
...a.unit ? { unit: a.unit } : {},
|
|
493
|
+
rows: [...c].map(([e, t]) => ({
|
|
494
|
+
value: e,
|
|
495
|
+
total: t
|
|
496
|
+
})).sort((e, t) => t.total - e.total)
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/scope.ts
|
|
501
|
+
function H(e, t) {
|
|
502
|
+
let n = c(e, t.board);
|
|
503
|
+
return n ? U(n.steps, t.id, []) ?? [] : [];
|
|
504
|
+
}
|
|
505
|
+
function U(e, t, n) {
|
|
506
|
+
let r = [];
|
|
507
|
+
for (let i of e) {
|
|
508
|
+
if (i.id === t) return [...n, ...r];
|
|
509
|
+
let e = i.branches ?? [], a = i.steps ?? [], o = i.handler ?? [];
|
|
510
|
+
if (e.length > 0 || a.length > 0 || o.length > 0) {
|
|
511
|
+
let s = [...n, ...r], c = i.use === "core.try" ? s : [...s, i], l = [
|
|
512
|
+
...e.map((e) => [e.steps, c]),
|
|
513
|
+
[a, c],
|
|
514
|
+
[o, [...s, i]]
|
|
515
|
+
];
|
|
516
|
+
for (let [e, n] of l) {
|
|
517
|
+
let r = U(e, t, n);
|
|
518
|
+
if (r) return r;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
De(i) || r.push(i);
|
|
522
|
+
}
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
var De = (e) => e.use === "core.try" || e.use === "core.for_each";
|
|
526
|
+
function Oe(t, n = null, r = [], i = []) {
|
|
527
|
+
let a = n === null ? void 0 : x(t, n);
|
|
528
|
+
if (n !== null && !a) return [];
|
|
529
|
+
let o = new Map(r.map((e) => [e.use, e])), s = [], c = /* @__PURE__ */ new Set();
|
|
530
|
+
for (let e of i) c.has(e.k) || (c.add(e.k), s.push({
|
|
531
|
+
path: `run.${e.k}`,
|
|
532
|
+
kind: "context",
|
|
533
|
+
label: e.label,
|
|
534
|
+
type: Le(e),
|
|
535
|
+
...e.description ? { description: e.description } : {}
|
|
536
|
+
}));
|
|
537
|
+
if (a) {
|
|
538
|
+
let e = /* @__PURE__ */ new Set();
|
|
539
|
+
for (let t of a.params ?? []) e.has(t.k) || (e.add(t.k), s.push({
|
|
540
|
+
path: `params.${t.k}`,
|
|
541
|
+
kind: "param",
|
|
542
|
+
label: t.label,
|
|
543
|
+
type: J(t)
|
|
544
|
+
}));
|
|
545
|
+
} else {
|
|
546
|
+
for (let e of t.triggers ?? []) s.push({
|
|
547
|
+
path: `triggers.${e.id}`,
|
|
548
|
+
kind: "trigger",
|
|
549
|
+
label: e.name ?? e.id,
|
|
550
|
+
type: Y(o.get(e.use)?.outputs ?? [])
|
|
551
|
+
});
|
|
552
|
+
(t.triggers?.length ?? 0) > 1 && s.push({
|
|
553
|
+
path: e,
|
|
554
|
+
kind: "builtin",
|
|
555
|
+
label: "Which trigger fired",
|
|
556
|
+
type: { type: "text" }
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
for (let e of a ? a.vars ?? [] : t.vars ?? []) s.push({
|
|
560
|
+
path: `var.${e.key}`,
|
|
561
|
+
kind: "var",
|
|
562
|
+
label: e.key,
|
|
563
|
+
type: Pe(e)
|
|
564
|
+
});
|
|
565
|
+
return s;
|
|
566
|
+
}
|
|
567
|
+
function W(e, t, n = [], r = [], i = G()) {
|
|
568
|
+
return ke(e, t, n, r, /* @__PURE__ */ new Set(), i);
|
|
569
|
+
}
|
|
570
|
+
var G = () => ({
|
|
571
|
+
elements: /* @__PURE__ */ new Map(),
|
|
572
|
+
entries: /* @__PURE__ */ new Map(),
|
|
573
|
+
boards: /* @__PURE__ */ new Map()
|
|
574
|
+
});
|
|
575
|
+
function ke(e, t, n, r, i, a) {
|
|
576
|
+
let o = new Map(n.map((e) => [e.use, e])), s = v(t.board), c = a.boards.get(s);
|
|
577
|
+
return c || (c = Oe(e, t.board, n, r), a.boards.set(s, c)), [...c, ...H(e, t).map((s) => Ae(e, t.board, s, o.get(s.use), {
|
|
578
|
+
manifests: n,
|
|
579
|
+
context: r,
|
|
580
|
+
resolving: i,
|
|
581
|
+
elements: a.elements,
|
|
582
|
+
entries: a.entries
|
|
583
|
+
}))];
|
|
584
|
+
}
|
|
585
|
+
function Ae(e, t, n, r, i) {
|
|
586
|
+
let a = i.resolving.size === 0, o = _({
|
|
587
|
+
board: t,
|
|
588
|
+
id: n.id
|
|
589
|
+
});
|
|
590
|
+
if (a) {
|
|
591
|
+
let e = i.entries.get(o);
|
|
592
|
+
if (e) return e;
|
|
593
|
+
}
|
|
594
|
+
let s = {
|
|
595
|
+
path: `steps.${n.id}`,
|
|
596
|
+
kind: "step",
|
|
597
|
+
label: n.name ?? n.id,
|
|
598
|
+
type: Fe(e, t, n, r, i)
|
|
599
|
+
};
|
|
600
|
+
return a && i.entries.set(o, s), s;
|
|
601
|
+
}
|
|
602
|
+
function K(e, t) {
|
|
603
|
+
let n = t.split(".");
|
|
604
|
+
for (let t = n.length; t > 0; t--) {
|
|
605
|
+
let r = e.find((e) => e.path === n.slice(0, t).join("."));
|
|
606
|
+
if (!r) continue;
|
|
607
|
+
let i = r.type;
|
|
608
|
+
for (let e of n.slice(t)) {
|
|
609
|
+
if (!i.members || !Object.hasOwn(i.members, e)) return null;
|
|
610
|
+
i = i.members[e];
|
|
611
|
+
}
|
|
612
|
+
return i;
|
|
613
|
+
}
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
function je(e, t, n, a = [], s = [], c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map()) {
|
|
617
|
+
let u = _({
|
|
618
|
+
board: t,
|
|
619
|
+
id: n.id
|
|
620
|
+
}), d = l.get(u);
|
|
621
|
+
if (d !== void 0) return d;
|
|
622
|
+
let f = o(n.with, O);
|
|
623
|
+
if (typeof f != "string") return q(l, u, null);
|
|
624
|
+
let p = i(f);
|
|
625
|
+
if (p === null) return q(l, u, null);
|
|
626
|
+
if (c.has(u)) return null;
|
|
627
|
+
let m = K(ke(e, {
|
|
628
|
+
board: t,
|
|
629
|
+
id: n.id
|
|
630
|
+
}, a, s, /* @__PURE__ */ new Set([...c, u]), {
|
|
631
|
+
elements: l,
|
|
632
|
+
entries: /* @__PURE__ */ new Map(),
|
|
633
|
+
boards: /* @__PURE__ */ new Map()
|
|
634
|
+
}), p);
|
|
635
|
+
return !m || m.type !== "list" || !m.members ? q(l, u, null) : q(l, u, r(m));
|
|
636
|
+
}
|
|
637
|
+
var q = (e, t, n) => (e.set(t, n), n);
|
|
638
|
+
function Me(e) {
|
|
639
|
+
let t = Object.create(null);
|
|
640
|
+
for (let n of e?.outputs ?? []) n.k in t || (t[n.k] = J(n));
|
|
641
|
+
return {
|
|
642
|
+
type: "object",
|
|
643
|
+
members: t
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function J(e) {
|
|
647
|
+
let t = e.of ? Ne(e.of) : void 0;
|
|
648
|
+
return {
|
|
649
|
+
type: e.t,
|
|
650
|
+
...t ? { members: t } : {}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
var Ne = (e) => {
|
|
654
|
+
let t = Object.create(null);
|
|
655
|
+
for (let n of e) t[n.k] = J(n);
|
|
656
|
+
return t;
|
|
657
|
+
};
|
|
658
|
+
function Pe(e) {
|
|
659
|
+
let t = e.of ? Ne(e.of) : void 0;
|
|
660
|
+
return {
|
|
661
|
+
type: A(e),
|
|
662
|
+
...t ? { members: t } : {}
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
function Fe(e, t, n, r, i) {
|
|
666
|
+
if (n.use === "core.map") return Ie(n);
|
|
667
|
+
let a = b(n.use);
|
|
668
|
+
if (a !== null) return Me(x(e, a));
|
|
669
|
+
let o = Y(r?.outputs ?? []);
|
|
670
|
+
if (n.use !== "core.for_each") return o;
|
|
671
|
+
let s = je(e, t, n, i.manifests, i.context, i.resolving, i.elements);
|
|
672
|
+
if (!s) return o;
|
|
673
|
+
let c = Object.create(null);
|
|
674
|
+
for (let [e, t] of Object.entries(o.members ?? {})) c[e] = t.type === "item" ? s : t;
|
|
675
|
+
return {
|
|
676
|
+
type: "object",
|
|
677
|
+
members: c
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
function Ie(e) {
|
|
681
|
+
let t = Object.create(null);
|
|
682
|
+
for (let n of M(e.with?.entries)) t[n.key] = { type: n.type };
|
|
683
|
+
return {
|
|
684
|
+
type: "object",
|
|
685
|
+
members: t
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function Le(e) {
|
|
689
|
+
let t = e.of ? Re(e.of) : void 0;
|
|
690
|
+
return {
|
|
691
|
+
type: e.t,
|
|
692
|
+
...t ? { members: t } : {}
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
var Re = (e) => {
|
|
696
|
+
let t = Object.create(null);
|
|
697
|
+
for (let n of e) t[n.k] = Le(n);
|
|
698
|
+
return t;
|
|
699
|
+
};
|
|
700
|
+
function Y(e) {
|
|
701
|
+
let t = Object.create(null);
|
|
702
|
+
for (let n of e) t[n.k] = ze(n);
|
|
703
|
+
return {
|
|
704
|
+
type: "object",
|
|
705
|
+
members: t
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
function ze(e) {
|
|
709
|
+
let t = e.of ? Y(e.of).members : void 0;
|
|
710
|
+
return {
|
|
711
|
+
type: e.t,
|
|
712
|
+
...t ? { members: t } : {}
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region src/segment.ts
|
|
717
|
+
function X(e, t) {
|
|
718
|
+
let n = (e) => {
|
|
719
|
+
let r = e.findIndex((e) => e.id === t);
|
|
720
|
+
if (r !== -1) return {
|
|
721
|
+
steps: e,
|
|
722
|
+
index: r
|
|
723
|
+
};
|
|
724
|
+
for (let t of e) for (let e of d(t)) {
|
|
725
|
+
let t = n(e.steps);
|
|
726
|
+
if (t) return t;
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
return n(e.steps);
|
|
730
|
+
}
|
|
731
|
+
function Be(e, t, n) {
|
|
732
|
+
let r = X(e, t), i = X(e, n);
|
|
733
|
+
if (!r || !i || r.steps !== i.steps) return;
|
|
734
|
+
let a = Math.min(r.index, i.index), o = Math.max(r.index, i.index);
|
|
735
|
+
return {
|
|
736
|
+
board: e.id,
|
|
737
|
+
steps: r.steps.slice(a, o + 1).map((e) => e.id)
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
var Ve = ({ board: e, id: t }) => ({
|
|
741
|
+
board: e,
|
|
742
|
+
steps: [t]
|
|
743
|
+
});
|
|
744
|
+
function He(e, t) {
|
|
745
|
+
let n = c(e, t.board);
|
|
746
|
+
if (!n) return [];
|
|
747
|
+
let r = new Set(t.steps), i = t.steps.reduce((e, t) => e ?? X(n, t), void 0);
|
|
748
|
+
return i ? i.steps.filter((e) => r.has(e.id)) : [];
|
|
749
|
+
}
|
|
750
|
+
var Ue = (e, t) => e !== void 0 && e.board === t.board && e.steps.includes(t.id);
|
|
751
|
+
function We(e, t, n) {
|
|
752
|
+
let r = X(e, t);
|
|
753
|
+
return r?.steps[r.index + n]?.id;
|
|
754
|
+
}
|
|
755
|
+
var Ge = (e) => [...h(e)].some((e) => e.use === se), Ke = (e, t) => {
|
|
756
|
+
if (!e.when) return !0;
|
|
757
|
+
let [n, r] = e.when;
|
|
758
|
+
return String(o(t, n) ?? "") === r;
|
|
759
|
+
}, Z = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : !1;
|
|
760
|
+
function qe(e, t) {
|
|
761
|
+
let n = [], r = (e, t, r) => {
|
|
762
|
+
for (let i of t ?? []) Z(o(r, i.k)) && n.push(I("FIELD_REQUIRED", {
|
|
763
|
+
...e,
|
|
764
|
+
fieldKey: i.k
|
|
765
|
+
}, { label: i.label }));
|
|
766
|
+
}, i = (e, r, i) => {
|
|
767
|
+
let a = t.get(r);
|
|
768
|
+
if (a) for (let t of a.fields ?? []) t.req && Ke(t, i) && Z(o(i, t.k)) && n.push(I("FIELD_REQUIRED", {
|
|
769
|
+
...e,
|
|
770
|
+
fieldKey: t.k
|
|
771
|
+
}, { label: t.label }));
|
|
772
|
+
};
|
|
773
|
+
for (let { step: t, board: a } of g(e)) {
|
|
774
|
+
let s = {
|
|
775
|
+
stepId: t.id,
|
|
776
|
+
...$(a)
|
|
777
|
+
}, c = t.with ?? {}, l = b(t.use);
|
|
778
|
+
if (l !== null) {
|
|
779
|
+
r(s, x(e, l)?.params, c);
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (t.use === "core.return") {
|
|
783
|
+
r(s, nt(e, a)?.outputs, c);
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
if (t.use === "core.set_var") {
|
|
787
|
+
for (let [e, t] of Xe) Z(o(c, e)) && n.push(I("FIELD_REQUIRED", {
|
|
788
|
+
...s,
|
|
789
|
+
fieldKey: e
|
|
790
|
+
}, { label: t }));
|
|
791
|
+
continue;
|
|
792
|
+
}
|
|
793
|
+
i(s, t.use, c);
|
|
794
|
+
}
|
|
795
|
+
for (let t of e.triggers ?? []) i({ triggerId: t.id }, t.use, t.with ?? {});
|
|
796
|
+
return n;
|
|
797
|
+
}
|
|
798
|
+
function Je(e, t) {
|
|
799
|
+
let n = [];
|
|
800
|
+
for (let { step: r, board: i } of g(e)) {
|
|
801
|
+
let a = b(r.use);
|
|
802
|
+
if (a !== null) {
|
|
803
|
+
if (x(e, a)) continue;
|
|
804
|
+
n.push(I("BLOCK_UNKNOWN", {
|
|
805
|
+
stepId: r.id,
|
|
806
|
+
...$(i)
|
|
807
|
+
}, { name: a }));
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
t.has(r.use) || n.push(I("COMPONENT_UNKNOWN", {
|
|
811
|
+
stepId: r.id,
|
|
812
|
+
...$(i)
|
|
813
|
+
}, { use: r.use }));
|
|
814
|
+
}
|
|
815
|
+
for (let r of e.triggers ?? []) t.has(r.use) || n.push(I("COMPONENT_UNKNOWN", { triggerId: r.id }, { use: r.use }));
|
|
816
|
+
return n;
|
|
817
|
+
}
|
|
818
|
+
function Ye(e, t = /* @__PURE__ */ new Map()) {
|
|
819
|
+
let n = [], r = [...t.values()];
|
|
820
|
+
for (let { step: t, board: i } of g(e)) {
|
|
821
|
+
let a = {
|
|
822
|
+
stepId: t.id,
|
|
823
|
+
...$(i)
|
|
824
|
+
};
|
|
825
|
+
if (t.use === "core.fork") {
|
|
826
|
+
let e = t.branches ?? [];
|
|
827
|
+
e.length === 0 ? n.push(I("FORK_HAS_NO_BRANCHES", a)) : e.length < 2 && n.push(I("FORK_NEEDS_TWO_BRANCHES", a)), e.some((e) => e.when !== void 0) && e.forEach((t, r) => {
|
|
828
|
+
t.when === void 0 && r !== e.length - 1 && n.push(I("BRANCH_UNREACHABLE_AFTER", a, { label: t.label }));
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
if ((t.use === "core.for_each" || t.use === "core.repeat") && (t.steps ?? []).length === 0 && n.push(I("LOOP_HAS_NO_BODY", a)), t.use === "core.repeat" && (t.until ?? "").trim() === "" && n.push(I("REPEAT_HAS_NO_CONDITION", a)), t.use === "core.try" && ((t.steps ?? []).length === 0 && n.push(I("TRY_HAS_NO_BODY", a)), (t.handler ?? []).length === 0 && n.push(I("TRY_HAS_NO_HANDLER", a))), t.use === "core.for_each") {
|
|
832
|
+
let o = Qe(e, i, t, r);
|
|
833
|
+
o && o.type !== "list" && o.type !== "unknown" && o.type !== "item" && n.push(I("LOOP_LIST_NOT_A_LIST", {
|
|
834
|
+
...a,
|
|
835
|
+
fieldKey: O
|
|
836
|
+
}, {
|
|
837
|
+
name: Ze(t) ?? "list",
|
|
838
|
+
actual: o.type
|
|
839
|
+
}));
|
|
840
|
+
}
|
|
841
|
+
if (t.use === "core.set_var") {
|
|
842
|
+
let r = o(t.with ?? {}, "key");
|
|
843
|
+
typeof r == "string" && r !== "" && !y(e, i).some((e) => e.key === r) && n.push(I("VAR_UNKNOWN", {
|
|
844
|
+
...a,
|
|
845
|
+
fieldKey: "key"
|
|
846
|
+
}, { name: r }));
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return n;
|
|
850
|
+
}
|
|
851
|
+
var Xe = [["key", "Variable"], ["value", "Value"]];
|
|
852
|
+
function Ze(e) {
|
|
853
|
+
let t = o(e.with, O);
|
|
854
|
+
return typeof t == "string" ? i(t) : null;
|
|
855
|
+
}
|
|
856
|
+
function Qe(e, t, n, r) {
|
|
857
|
+
let i = Ze(n);
|
|
858
|
+
return i === null ? null : K(W(e, {
|
|
859
|
+
board: t,
|
|
860
|
+
id: n.id
|
|
861
|
+
}, r), i);
|
|
862
|
+
}
|
|
863
|
+
function Q(e) {
|
|
864
|
+
return e.some((e) => {
|
|
865
|
+
if (e.use === "core.return") return !0;
|
|
866
|
+
if (e.use === "core.repeat") return Q(e.steps ?? []);
|
|
867
|
+
if (e.use === "core.try") return Q(e.steps ?? []) && Q(e.handler ?? []);
|
|
868
|
+
if (e.use !== "core.fork") return !1;
|
|
869
|
+
let t = e.branches ?? [];
|
|
870
|
+
return t.length === 0 ? !1 : t.some((e) => e.when !== void 0) ? t.at(-1)?.when === void 0 && t.every((e) => Q(e.steps)) : t.some((e) => Q(e.steps));
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
function $e(e) {
|
|
874
|
+
let t = [], n = /* @__PURE__ */ new Set();
|
|
875
|
+
for (let r of e.blocks ?? []) n.has(r.id) && t.push(I("BLOCK_ID_DUPLICATE", { blockId: r.id }, { name: r.id })), n.add(r.id);
|
|
876
|
+
for (let n of e.blocks ?? []) for (let [e, r] of [["parameter", n.params], ["output", n.outputs]]) {
|
|
877
|
+
let i = /* @__PURE__ */ new Set();
|
|
878
|
+
for (let a of r ?? []) i.has(a.k) && t.push(I("DECLARATION_KEY_DUPLICATE", { blockId: n.id }, {
|
|
879
|
+
side: e,
|
|
880
|
+
block: n.id,
|
|
881
|
+
name: a.k
|
|
882
|
+
})), i.add(a.k);
|
|
883
|
+
}
|
|
884
|
+
for (let n of le(e)) t.push(I("BLOCK_RECURSION", { blockId: n }, { name: n }));
|
|
885
|
+
for (let n of s(e)) {
|
|
886
|
+
let e = /* @__PURE__ */ new Set();
|
|
887
|
+
for (let r of h(n.steps)) e.has(r.id) && t.push(I("STEP_ID_DUPLICATE", {
|
|
888
|
+
stepId: r.id,
|
|
889
|
+
...$(n.id)
|
|
890
|
+
}, { name: r.id })), e.add(r.id), r.use === "core.return" && n.id === null && t.push(I("RETURN_OUTSIDE_BLOCK", { stepId: r.id }));
|
|
891
|
+
for (let e of et(n.steps)) tt(e, n.id, t);
|
|
892
|
+
n.block && (n.block.outputs ?? []).length > 0 && (Q(n.steps) || t.push(I("BLOCK_PATH_WITHOUT_RETURN", { blockId: n.id ?? void 0 }, { name: n.block.id })));
|
|
893
|
+
}
|
|
894
|
+
return t;
|
|
895
|
+
}
|
|
896
|
+
function* et(e) {
|
|
897
|
+
yield e;
|
|
898
|
+
for (let t of e) for (let e of d(t)) yield* et(e.steps);
|
|
899
|
+
}
|
|
900
|
+
function tt(e, t, n) {
|
|
901
|
+
let r = e.findIndex((e) => Q([e]));
|
|
902
|
+
if (r !== -1) for (let i of e.slice(r + 1)) n.push(I("STEP_AFTER_RETURN", {
|
|
903
|
+
stepId: i.id,
|
|
904
|
+
...$(t)
|
|
905
|
+
}));
|
|
906
|
+
}
|
|
907
|
+
var $ = (e) => e === null ? {} : { blockId: e }, nt = (e, t) => t === null ? void 0 : x(e, t);
|
|
908
|
+
function rt(e, t, n = [], r = at) {
|
|
909
|
+
let i = [], o = [...t.values()], s = G();
|
|
910
|
+
for (let { step: c, board: l } of g(e)) {
|
|
911
|
+
let u = {
|
|
912
|
+
stepId: c.id,
|
|
913
|
+
...$(l)
|
|
914
|
+
}, d, f = (t) => {
|
|
915
|
+
if (t.template.trim() !== "") {
|
|
916
|
+
d ??= W(e, {
|
|
917
|
+
board: l,
|
|
918
|
+
id: c.id
|
|
919
|
+
}, o, n, s);
|
|
920
|
+
for (let e of a(t.template, t.expectedType, {
|
|
921
|
+
scope: d,
|
|
922
|
+
functions: r
|
|
923
|
+
})) e.severity === "error" && i.push({
|
|
924
|
+
code: e.code,
|
|
925
|
+
message: e.message,
|
|
926
|
+
blocks: "publish",
|
|
927
|
+
fieldKey: t.name,
|
|
928
|
+
...u
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
for (let n of N(e, l, c, t.get(c.use))) f(n);
|
|
933
|
+
for (let e of c.branches ?? []) e.when !== void 0 && f(D(e.when));
|
|
934
|
+
typeof c.until == "string" && f(k(c.until));
|
|
935
|
+
}
|
|
936
|
+
return i;
|
|
937
|
+
}
|
|
938
|
+
function it(e, t, n = [], r) {
|
|
939
|
+
let i = [
|
|
940
|
+
...Je(e, t),
|
|
941
|
+
...qe(e, t),
|
|
942
|
+
...Ye(e, t),
|
|
943
|
+
...$e(e),
|
|
944
|
+
...rt(e, t, n),
|
|
945
|
+
...R(e),
|
|
946
|
+
...z(e, t, r)
|
|
947
|
+
], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (e, t, n) => {
|
|
948
|
+
let r = e.get(t);
|
|
949
|
+
r ? r.push(n) : e.set(t, [n]);
|
|
950
|
+
};
|
|
951
|
+
for (let e of i) e.stepId ? l(a, _({
|
|
952
|
+
board: e.blockId ?? null,
|
|
953
|
+
id: e.stepId
|
|
954
|
+
}), e) : e.triggerId ? l(o, e.triggerId, e) : e.blockId ? l(s, e.blockId, e) : e.connectionId && l(c, e.connectionId, e);
|
|
955
|
+
return {
|
|
956
|
+
byStep: a,
|
|
957
|
+
byTrigger: o,
|
|
958
|
+
byBlock: s,
|
|
959
|
+
byConnection: c,
|
|
960
|
+
all: i
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
var at = new Map(n.map((e) => [e.qualified, { spec: e }]));
|
|
964
|
+
//#endregion
|
|
965
|
+
export { oe as BLOCK_PREFIX, T as FIELD_KIND_TYPES, he as FORK_VERB, O as FOR_EACH_LIST_FIELD, me as FOR_EACH_VERB, _e as ITEM_BINDING, pe as MAPPING_VERB, u as REPEAT_VERB, se as RETURN_VERB, ge as SET_VAR_VERB, l as TRY_VERB, b as blockIdOf, x as blockOf, Me as blockOutputType, $e as blockRules, v as boardKey, c as boardOf, Oe as boardScope, s as boards, ye as bornRegionsOf, ue as callSitesOf, S as callSlots, w as callsOf, de as contractSummary, le as cyclicBlocks, we as descriptorsByUse, rt as expressionRules, Ke as fieldVisible, re as findStep, F as formatDefinitionMessage, be as indexManifests, m as isContainer, Ce as logFor, je as loopElementType, Ye as malformedContainers, M as mapEntries, z as mismatchedConnections, qe as missingRequiredFields, ee as nameOf, G as newScopeMemo, o as own, Ee as pivot, I as raise, xe as recordsFor, ne as regionKey, d as regionsOf, k as repeatSlot, C as returnSlots, W as scopeFor, Be as segmentBetween, Ue as segmentHolds, Ve as segmentOf, Ge as segmentReturns, He as segmentSteps, j as setVarSlot, We as siblingFrom, X as siblingsOf, E as slotsFor, N as slotsForStep, Se as statusOf, ae as stepIds, _ as stepKey, te as summaryOf, Te as totals, fe as troubledBlocks, K as typeAtPath, Je as unknownComponents, R as unresolvedConnections, H as upstreamOf, it as validateDefinition, ie as variableOn, ve as variableSlot, A as variableType, y as varsOn, g as walkDocument, h as walkSteps, D as whenSlot };
|