@fluidgrids/workflows 2026.1027.0 → 2026.1027.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -5
- package/dist/{assemble-DMOuaxRI.d.ts → assemble-CrpUyd_3.d.ts} +20 -2
- package/dist/{assemble-BJo9TECS.d.cts → assemble-DEf3znGD.d.cts} +20 -2
- package/dist/chunk-3M34AUIY.cjs +27 -0
- package/dist/chunk-5AW745OG.js +25 -0
- package/dist/{chunk-RRQ5HOBF.cjs → chunk-6AIAC2FP.cjs} +4 -4
- package/dist/{chunk-GO34UHSY.js → chunk-6BEW4QD6.js} +3 -3
- package/dist/{chunk-SS4LT2IP.js → chunk-6U446SKY.js} +5 -10
- package/dist/{chunk-AU3YW7FZ.cjs → chunk-7YR7DI7B.cjs} +46 -51
- package/dist/{chunk-27HASETB.cjs → chunk-CSYBNN3V.cjs} +3 -1
- package/dist/{chunk-LRM6JXJA.cjs → chunk-E3APHA6O.cjs} +19 -1
- package/dist/{chunk-BWSLWF2E.js → chunk-EEAIM35V.js} +38 -12
- package/dist/{chunk-X4HKU3MX.js → chunk-IHKXLG6I.js} +3 -1
- package/dist/chunk-MBBKGD7K.js +440 -0
- package/dist/{chunk-LSKSBVL4.cjs → chunk-OSPTJCDI.cjs} +6 -6
- package/dist/{chunk-KUTMY2IO.cjs → chunk-TQF7MYEN.cjs} +101 -75
- package/dist/{chunk-BYJ7QTLY.cjs → chunk-TWOYB4Y7.cjs} +13 -13
- package/dist/{chunk-PL73GJR4.js → chunk-UB2BHU2M.js} +1 -1
- package/dist/{chunk-REV7ZOA4.js → chunk-UJNHTS6D.js} +13 -2
- package/dist/{chunk-IZQNUNSU.cjs → chunk-UWQWD7BP.cjs} +17 -17
- package/dist/{chunk-4DPEGDPW.js → chunk-W32BSO3M.js} +4 -4
- package/dist/{chunk-LMX35GNQ.js → chunk-XBIID5DY.js} +4 -4
- package/dist/chunk-Y7NWR3WH.cjs +450 -0
- package/dist/codegen/index.cjs +7 -7
- package/dist/codegen/index.js +5 -5
- package/dist/index.cjs +30 -30
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/ir/index.cjs +118 -116
- package/dist/ir/index.d.cts +18 -8
- package/dist/ir/index.d.ts +18 -8
- package/dist/ir/index.js +21 -19
- package/dist/{lower-Dw5grNrI.d.ts → lower-CXggJTIo.d.ts} +20 -2
- package/dist/{lower-DcOY8ux0.d.cts → lower-DAzvsJCo.d.cts} +20 -2
- package/dist/node-evaluator-CH3XCJND.cjs +17 -0
- package/dist/node-evaluator-TULXA3WE.js +8 -0
- package/dist/quickjs/index.cjs +32 -78
- package/dist/quickjs/index.d.cts +4 -4
- package/dist/quickjs/index.d.ts +4 -4
- package/dist/quickjs/index.js +32 -78
- package/dist/roundtrip/index.cjs +201 -128
- package/dist/roundtrip/index.d.cts +7 -4
- package/dist/roundtrip/index.d.ts +7 -4
- package/dist/roundtrip/index.js +87 -18
- package/package.json +44 -18
- package/dist/chunk-265J2FCH.cjs +0 -33
- package/dist/chunk-LUXCXFOE.cjs +0 -269
- package/dist/chunk-S34NJE3A.js +0 -262
- package/dist/chunk-SRQRLWOS.js +0 -31
- package/dist/node-evaluator-2GTUZVPK.cjs +0 -17
- package/dist/node-evaluator-RMYEWCXZ.js +0 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkG4UEPUGO_cjs = require('./chunk-G4UEPUGO.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunk6AIAC2FP_cjs = require('./chunk-6AIAC2FP.cjs');
|
|
5
|
+
var chunkE3APHA6O_cjs = require('./chunk-E3APHA6O.cjs');
|
|
6
6
|
|
|
7
7
|
// src/builder/descriptors.ts
|
|
8
8
|
function op(nodeType, version, operation) {
|
|
@@ -82,52 +82,52 @@ function edge(from, options = {}) {
|
|
|
82
82
|
return { kind: "edge", from, ...options };
|
|
83
83
|
}
|
|
84
84
|
function isTier1Workflow(value) {
|
|
85
|
-
return
|
|
85
|
+
return chunkE3APHA6O_cjs.isRecord(value) && value["__fluidgrids"] === WORKFLOW_MARKER && chunkE3APHA6O_cjs.isRecord(value["recording"]);
|
|
86
86
|
}
|
|
87
87
|
function deepMerge(base, extra, path) {
|
|
88
88
|
for (const [key, value] of Object.entries(extra)) {
|
|
89
|
-
const existing = base
|
|
90
|
-
if (
|
|
89
|
+
const existing = chunkE3APHA6O_cjs.ownValue(base, key);
|
|
90
|
+
if (chunkE3APHA6O_cjs.isRecord(existing) && chunkE3APHA6O_cjs.isRecord(value)) {
|
|
91
91
|
deepMerge(existing, value, `${path}.${key}`);
|
|
92
92
|
} else if (existing !== void 0) {
|
|
93
|
-
throw new
|
|
93
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(
|
|
94
94
|
`extra sets ${path}.${key}, which the builder already wrote; use the typed option`
|
|
95
95
|
);
|
|
96
96
|
} else {
|
|
97
|
-
base
|
|
97
|
+
chunkE3APHA6O_cjs.setOwn(base, key, lowerValue(value, `${path}.${key}`));
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
function lowerValue(value, path) {
|
|
102
|
-
const model =
|
|
103
|
-
if (model) return
|
|
102
|
+
const model = chunk6AIAC2FP_cjs.refModelOf(value);
|
|
103
|
+
if (model) return chunkE3APHA6O_cjs.formatRefTemplate(model);
|
|
104
104
|
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
105
105
|
if (typeof value === "number") {
|
|
106
|
-
if (!Number.isFinite(value)) throw new
|
|
106
|
+
if (!Number.isFinite(value)) throw new chunk6AIAC2FP_cjs.BuilderError(`${path} is not a finite number`);
|
|
107
107
|
return value;
|
|
108
108
|
}
|
|
109
109
|
if (Array.isArray(value))
|
|
110
110
|
return value.map((item, index) => lowerValue(item, `${path}[${index}]`));
|
|
111
|
-
if (
|
|
112
|
-
throw new
|
|
111
|
+
if (chunk6AIAC2FP_cjs.isPredicate(value)) {
|
|
112
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`${path} is a condition; conditions belong in wf.if({ condition })`);
|
|
113
113
|
}
|
|
114
|
-
if (
|
|
114
|
+
if (chunkE3APHA6O_cjs.isRecord(value)) {
|
|
115
115
|
const proto = Object.getPrototypeOf(value);
|
|
116
116
|
if (proto !== Object.prototype && proto !== null) {
|
|
117
|
-
throw new
|
|
117
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`${path} is not a plain object`);
|
|
118
118
|
}
|
|
119
119
|
const out = {};
|
|
120
120
|
for (const [key, child] of Object.entries(value)) {
|
|
121
121
|
if (child === void 0) continue;
|
|
122
|
-
out
|
|
122
|
+
chunkE3APHA6O_cjs.setOwn(out, key, lowerValue(child, `${path}.${key}`));
|
|
123
123
|
}
|
|
124
124
|
return out;
|
|
125
125
|
}
|
|
126
|
-
throw new
|
|
126
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`${path} cannot be stored in a workflow definition (${typeof value})`);
|
|
127
127
|
}
|
|
128
128
|
function lowerObject(value, path) {
|
|
129
129
|
const lowered = lowerValue(value, path);
|
|
130
|
-
if (!
|
|
130
|
+
if (!chunkE3APHA6O_cjs.isRecord(lowered)) throw new chunk6AIAC2FP_cjs.BuilderError(`${path} must be an object`);
|
|
131
131
|
return lowered;
|
|
132
132
|
}
|
|
133
133
|
function slugify(text) {
|
|
@@ -142,24 +142,24 @@ function nodeRef(id) {
|
|
|
142
142
|
kind: "node",
|
|
143
143
|
id,
|
|
144
144
|
// An untyped reference serves every output type; the static type comes from the operation.
|
|
145
|
-
output:
|
|
145
|
+
output: chunk6AIAC2FP_cjs.makeRef({ kind: "node", nodeId: id }),
|
|
146
146
|
handle: (name) => handleRef(id, name)
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
function isNodeRef(value) {
|
|
150
|
-
return
|
|
150
|
+
return chunkE3APHA6O_cjs.isRecord(value) && value["kind"] === "node" && typeof value["id"] === "string";
|
|
151
151
|
}
|
|
152
152
|
function isHandleRef(value) {
|
|
153
|
-
return
|
|
153
|
+
return chunkE3APHA6O_cjs.isRecord(value) && value["kind"] === "handle" && typeof value["nodeId"] === "string";
|
|
154
154
|
}
|
|
155
155
|
function isEdgeSpec(value) {
|
|
156
|
-
return
|
|
156
|
+
return chunkE3APHA6O_cjs.isRecord(value) && value["kind"] === "edge" && "from" in value;
|
|
157
157
|
}
|
|
158
158
|
function sourceOf(from) {
|
|
159
159
|
if (typeof from === "string") return { source: from };
|
|
160
160
|
if (isHandleRef(from)) return { source: from.nodeId, sourceHandle: from.handle };
|
|
161
161
|
if (isNodeRef(from)) return { source: from.id };
|
|
162
|
-
throw new
|
|
162
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("after takes node references, handles, node ids or edge(\u2026) entries");
|
|
163
163
|
}
|
|
164
164
|
function defaultEdgeId(source, target, sourceHandle, targetHandle) {
|
|
165
165
|
return ["e", source, target, sourceHandle, targetHandle].filter((part) => Boolean(part)).join("-");
|
|
@@ -176,7 +176,7 @@ function limitWait(limit) {
|
|
|
176
176
|
const match = /^([1-9][0-9]*)([smhdw])$/.exec(limit);
|
|
177
177
|
const unit = match?.[2] !== void 0 ? LIMIT_UNITS[match[2]] : void 0;
|
|
178
178
|
if (!match?.[1] || !unit)
|
|
179
|
-
throw new
|
|
179
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`limit "${limit}" must look like 30s, 15m, 2h, 3d or 1w`);
|
|
180
180
|
return { amount: Number(match[1]), unit };
|
|
181
181
|
}
|
|
182
182
|
return { amount: limit.amount, unit: limit.unit };
|
|
@@ -187,18 +187,21 @@ var WorkflowBuilder = class {
|
|
|
187
187
|
}
|
|
188
188
|
autoIds;
|
|
189
189
|
/** `$json`: the current item's JSON. */
|
|
190
|
-
json =
|
|
190
|
+
json = chunk6AIAC2FP_cjs.makeRef({ kind: "json" });
|
|
191
191
|
/** `$vars`: workflow variables. */
|
|
192
|
-
vars =
|
|
192
|
+
vars = chunk6AIAC2FP_cjs.makeRef({ kind: "vars" });
|
|
193
193
|
/** `$now`. */
|
|
194
|
-
now =
|
|
194
|
+
now = chunk6AIAC2FP_cjs.makeRef({ kind: "now" });
|
|
195
195
|
/** `$execution`: run metadata. */
|
|
196
|
-
execution =
|
|
196
|
+
execution = chunk6AIAC2FP_cjs.makeRef({ kind: "execution" });
|
|
197
197
|
nodes = [];
|
|
198
198
|
edges = [];
|
|
199
199
|
notes = [];
|
|
200
200
|
ids = /* @__PURE__ */ new Set();
|
|
201
|
+
/** Ids given explicitly; a second edge with the same explicit id is an error. */
|
|
201
202
|
edgeIds = /* @__PURE__ */ new Set();
|
|
203
|
+
/** Edges whose id is the default, as indices into `edges`, with the unsuffixed default id. */
|
|
204
|
+
defaultIds = [];
|
|
202
205
|
edgeOrder;
|
|
203
206
|
/** A reference to a node by id, for nodes declared later in the source. */
|
|
204
207
|
ref(id) {
|
|
@@ -218,9 +221,9 @@ var WorkflowBuilder = class {
|
|
|
218
221
|
const sugar = {};
|
|
219
222
|
if (condition !== void 0) {
|
|
220
223
|
if (typeof condition === "string") sugar["condition"] = condition;
|
|
221
|
-
else if (
|
|
224
|
+
else if (chunk6AIAC2FP_cjs.isPredicate(condition)) sugar["conditionTree"] = chunk6AIAC2FP_cjs.conditionTreeOf(condition);
|
|
222
225
|
else
|
|
223
|
-
throw new
|
|
226
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(
|
|
224
227
|
"condition takes a comparison such as x.output.total.gte(500), and(), or() or a string"
|
|
225
228
|
);
|
|
226
229
|
}
|
|
@@ -260,7 +263,7 @@ var WorkflowBuilder = class {
|
|
|
260
263
|
const sugar = {};
|
|
261
264
|
if (mode !== void 0) sugar["mode"] = mode;
|
|
262
265
|
if (inputs !== void 0 && rest.after !== void 0) {
|
|
263
|
-
throw new
|
|
266
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("merge takes inputs or after, not both");
|
|
264
267
|
}
|
|
265
268
|
const after = inputs?.map(
|
|
266
269
|
(input, index) => edge(input, { targetHandle: `input-${index + 1}` })
|
|
@@ -377,7 +380,7 @@ var WorkflowBuilder = class {
|
|
|
377
380
|
}
|
|
378
381
|
/** A sticky note on the canvas. */
|
|
379
382
|
note(content, options) {
|
|
380
|
-
if (typeof content !== "string") throw new
|
|
383
|
+
if (typeof content !== "string") throw new chunk6AIAC2FP_cjs.BuilderError("A note takes Markdown text");
|
|
381
384
|
this.claimId(options.id, "sticky note");
|
|
382
385
|
const near = options.near === void 0 ? void 0 : typeof options.near === "string" ? options.near : options.near.id;
|
|
383
386
|
this.notes.push({
|
|
@@ -404,11 +407,12 @@ var WorkflowBuilder = class {
|
|
|
404
407
|
* differs from the order the code declares its edges in.
|
|
405
408
|
*/
|
|
406
409
|
edgeOrderIs(order) {
|
|
407
|
-
if (this.edgeOrder) throw new
|
|
410
|
+
if (this.edgeOrder) throw new chunk6AIAC2FP_cjs.BuilderError("edgeOrderIs() may be called once");
|
|
408
411
|
this.edgeOrder = [...order];
|
|
409
412
|
}
|
|
410
413
|
/** The recording, once the callback has returned. */
|
|
411
414
|
finish(key, document) {
|
|
415
|
+
this.assignDefaultEdgeIds();
|
|
412
416
|
return {
|
|
413
417
|
format: RECORDING_FORMAT,
|
|
414
418
|
formatVersion: RECORDING_FORMAT_VERSION,
|
|
@@ -421,27 +425,49 @@ var WorkflowBuilder = class {
|
|
|
421
425
|
};
|
|
422
426
|
}
|
|
423
427
|
claimId(id, what) {
|
|
424
|
-
if (typeof id !== "string" || id === "") throw new
|
|
425
|
-
if (this.ids.has(id)) throw new
|
|
428
|
+
if (typeof id !== "string" || id === "") throw new chunk6AIAC2FP_cjs.BuilderError(`A ${what} needs an id`);
|
|
429
|
+
if (this.ids.has(id)) throw new chunk6AIAC2FP_cjs.BuilderError(`Duplicate id "${id}"`);
|
|
426
430
|
this.ids.add(id);
|
|
427
431
|
}
|
|
428
432
|
resolveId(options, operation) {
|
|
429
433
|
if (options.id !== void 0) return options.id;
|
|
430
434
|
if (!this.autoIds) {
|
|
431
|
-
throw new
|
|
435
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`Every node needs an id (a ${operation.nodeType} node has none)`);
|
|
432
436
|
}
|
|
433
437
|
const base = slugify(options.label ?? operation.nodeType.split(/[:/]/).pop() ?? "node");
|
|
434
438
|
let candidate = base;
|
|
435
439
|
for (let suffix = 2; this.ids.has(candidate); suffix++) candidate = `${base}-${suffix}`;
|
|
436
440
|
return candidate;
|
|
437
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* Give every edge declared without an id its default id. Explicit ids are
|
|
444
|
+
* claimed first, so a default never takes an id the code names; a default that
|
|
445
|
+
* is taken gets `-2`, `-3`, … in declaration order. The result depends only on
|
|
446
|
+
* the builder calls.
|
|
447
|
+
*/
|
|
448
|
+
assignDefaultEdgeIds() {
|
|
449
|
+
const taken = new Set(this.edgeIds);
|
|
450
|
+
for (const { index, base } of this.defaultIds) {
|
|
451
|
+
let id = base;
|
|
452
|
+
for (let suffix = 2; taken.has(id); suffix++) id = `${base}-${suffix}`;
|
|
453
|
+
taken.add(id);
|
|
454
|
+
const built = this.edges[index];
|
|
455
|
+
if (built) built.id = id;
|
|
456
|
+
}
|
|
457
|
+
this.defaultIds.length = 0;
|
|
458
|
+
}
|
|
438
459
|
addEdge(spec, target) {
|
|
439
460
|
const { source, sourceHandle } = sourceOf(spec.from);
|
|
440
|
-
const
|
|
441
|
-
if (id !== void 0)
|
|
442
|
-
|
|
443
|
-
|
|
461
|
+
const explicit = typeof spec.id === "string" ? spec.id : void 0;
|
|
462
|
+
if (spec.id !== void 0 && spec.id !== false && explicit === void 0)
|
|
463
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("An edge id must be a string or false");
|
|
464
|
+
if (explicit !== void 0) {
|
|
465
|
+
if (this.edgeIds.has(explicit)) throw new chunk6AIAC2FP_cjs.BuilderError(`Duplicate edge id "${explicit}"`);
|
|
466
|
+
this.edgeIds.add(explicit);
|
|
444
467
|
}
|
|
468
|
+
const base = spec.id === void 0 ? defaultEdgeId(source, target, sourceHandle, spec.targetHandle) : void 0;
|
|
469
|
+
const id = explicit ?? base;
|
|
470
|
+
if (base !== void 0) this.defaultIds.push({ index: this.edges.length, base });
|
|
445
471
|
const built = id !== void 0 ? { id, source, target } : { source, target };
|
|
446
472
|
if (sourceHandle !== void 0) built["sourceHandle"] = sourceHandle;
|
|
447
473
|
if (spec.targetHandle !== void 0) built["targetHandle"] = spec.targetHandle;
|
|
@@ -457,12 +483,12 @@ var WorkflowBuilder = class {
|
|
|
457
483
|
}
|
|
458
484
|
add(operation, options, sugar) {
|
|
459
485
|
if (!isOperation(operation)) {
|
|
460
|
-
throw new
|
|
486
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(
|
|
461
487
|
"The first argument must be a node operation (nodes.*, triggers.* or a generated client)"
|
|
462
488
|
);
|
|
463
489
|
}
|
|
464
490
|
if (typeof options !== "object" || options === null || Array.isArray(options)) {
|
|
465
|
-
throw new
|
|
491
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("Node options must be an object");
|
|
466
492
|
}
|
|
467
493
|
const id = this.resolveId(options, operation);
|
|
468
494
|
this.claimId(id, "node");
|
|
@@ -479,17 +505,17 @@ var WorkflowBuilder = class {
|
|
|
479
505
|
if (explicitArgs || Object.keys(sugarArgs).length > 0) {
|
|
480
506
|
for (const key of Object.keys(sugarArgs)) {
|
|
481
507
|
if (explicitArgs && Object.hasOwn(explicitArgs, key)) {
|
|
482
|
-
throw new
|
|
508
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`${where}: "${key}" is set twice (by an option and in args)`);
|
|
483
509
|
}
|
|
484
510
|
}
|
|
485
511
|
args["state"] = { ...explicitArgs, ...sugarArgs };
|
|
486
512
|
}
|
|
487
513
|
if (options.connection !== void 0 && options.connections !== void 0) {
|
|
488
|
-
throw new
|
|
514
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`${where}: use connection (names) or connections (ids), not both`);
|
|
489
515
|
}
|
|
490
516
|
const connectionNames = options.connection === void 0 ? void 0 : typeof options.connection === "string" ? [options.connection] : [...options.connection];
|
|
491
517
|
if (connectionNames?.some((name) => typeof name !== "string" || name === "")) {
|
|
492
|
-
throw new
|
|
518
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`${where}: connection names must be non-empty strings`);
|
|
493
519
|
}
|
|
494
520
|
if (options.connections !== void 0)
|
|
495
521
|
args["connections"] = lowerValue(options.connections, `${where} connections`);
|
|
@@ -500,7 +526,7 @@ var WorkflowBuilder = class {
|
|
|
500
526
|
if (Object.keys(args).length > 0 || connectionNames) node["args"] = args;
|
|
501
527
|
const hasSugar = options.retry !== void 0 || options.timeout !== void 0 || options.onError !== void 0;
|
|
502
528
|
if (options.errorConfig !== void 0 && hasSugar) {
|
|
503
|
-
throw new
|
|
529
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`${where}: use errorConfig or retry / timeout / onError, not both`);
|
|
504
530
|
}
|
|
505
531
|
if (options.errorConfig !== void 0) {
|
|
506
532
|
node["errorConfig"] = lowerObject(options.errorConfig, `${where} errorConfig`);
|
|
@@ -540,7 +566,7 @@ var WorkflowBuilder = class {
|
|
|
540
566
|
};
|
|
541
567
|
function defineWorkflow(options, build) {
|
|
542
568
|
if (typeof options !== "object" || options === null || typeof options.key !== "string" || options.key === "") {
|
|
543
|
-
throw new
|
|
569
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("defineWorkflow needs a key");
|
|
544
570
|
}
|
|
545
571
|
const builder = new WorkflowBuilder(options.autoIds === true);
|
|
546
572
|
build(builder);
|
|
@@ -560,7 +586,7 @@ function defineWorkflow(options, build) {
|
|
|
560
586
|
}
|
|
561
587
|
|
|
562
588
|
// src/generated/version.ts
|
|
563
|
-
var SDK_VERSION = "2026.1027.
|
|
589
|
+
var SDK_VERSION = "2026.1027.1";
|
|
564
590
|
|
|
565
591
|
// src/builder/assemble.ts
|
|
566
592
|
var LAYOUT_FORMAT = "fluidgrids.layout";
|
|
@@ -579,19 +605,19 @@ function resolveConnection(resolver, name) {
|
|
|
579
605
|
return Object.hasOwn(resolver, name) ? resolver[name] : void 0;
|
|
580
606
|
}
|
|
581
607
|
function parseLayoutSidecar(value) {
|
|
582
|
-
if (!
|
|
583
|
-
throw new
|
|
608
|
+
if (!chunkE3APHA6O_cjs.isRecord(value) || value["format"] !== LAYOUT_FORMAT || value["formatVersion"] !== LAYOUT_FORMAT_VERSION) {
|
|
609
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(
|
|
584
610
|
`A layout file must have format "${LAYOUT_FORMAT}" and formatVersion ${LAYOUT_FORMAT_VERSION}`
|
|
585
611
|
);
|
|
586
612
|
}
|
|
587
613
|
const positions = value["positions"];
|
|
588
|
-
if (!
|
|
614
|
+
if (!chunkE3APHA6O_cjs.isRecord(positions)) throw new chunk6AIAC2FP_cjs.BuilderError("A layout file needs a positions object");
|
|
589
615
|
const parsed = {};
|
|
590
616
|
for (const [id, position] of Object.entries(positions)) {
|
|
591
|
-
if (!
|
|
592
|
-
throw new
|
|
617
|
+
if (!chunkE3APHA6O_cjs.isRecord(position) || typeof position["x"] !== "number" || typeof position["y"] !== "number") {
|
|
618
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`The layout position of "${id}" must be { x, y }`);
|
|
593
619
|
}
|
|
594
|
-
parsed
|
|
620
|
+
chunkE3APHA6O_cjs.setOwn(parsed, id, { x: position["x"], y: position["y"] });
|
|
595
621
|
}
|
|
596
622
|
const sidecar = {
|
|
597
623
|
format: LAYOUT_FORMAT,
|
|
@@ -599,15 +625,15 @@ function parseLayoutSidecar(value) {
|
|
|
599
625
|
positions: parsed
|
|
600
626
|
};
|
|
601
627
|
if (value["stickyNotes"] !== void 0) {
|
|
602
|
-
if (!Array.isArray(value["stickyNotes"]) || !value["stickyNotes"].every(
|
|
603
|
-
throw new
|
|
628
|
+
if (!Array.isArray(value["stickyNotes"]) || !value["stickyNotes"].every(chunkE3APHA6O_cjs.isRecord)) {
|
|
629
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("stickyNotes in a layout file must be an array of objects");
|
|
604
630
|
}
|
|
605
|
-
sidecar.stickyNotes =
|
|
631
|
+
sidecar.stickyNotes = chunkE3APHA6O_cjs.cloneJson(value["stickyNotes"]);
|
|
606
632
|
}
|
|
607
633
|
if (value["metaLayout"] !== void 0) {
|
|
608
|
-
if (!
|
|
609
|
-
throw new
|
|
610
|
-
sidecar.metaLayout =
|
|
634
|
+
if (!chunkE3APHA6O_cjs.isRecord(value["metaLayout"]))
|
|
635
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("metaLayout in a layout file must be an object");
|
|
636
|
+
sidecar.metaLayout = chunkE3APHA6O_cjs.cloneJson(value["metaLayout"]);
|
|
611
637
|
}
|
|
612
638
|
return sidecar;
|
|
613
639
|
}
|
|
@@ -622,7 +648,7 @@ function orderEdges(edges, order) {
|
|
|
622
648
|
);
|
|
623
649
|
const valid = indices.length === edges.length && new Set(indices).size === indices.length && indices.every((index) => Number.isInteger(index) && index >= 0 && index < edges.length);
|
|
624
650
|
if (!valid)
|
|
625
|
-
throw new
|
|
651
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(
|
|
626
652
|
"edgeOrderIs() must name every edge exactly once, by id or declaration position"
|
|
627
653
|
);
|
|
628
654
|
return indices.map((index) => edges[index]);
|
|
@@ -630,7 +656,7 @@ function orderEdges(edges, order) {
|
|
|
630
656
|
function assembleRecording(recording, options = {}) {
|
|
631
657
|
const missing = /* @__PURE__ */ new Set();
|
|
632
658
|
const nodes2 = recording.nodes.map((recorded) => {
|
|
633
|
-
const node =
|
|
659
|
+
const node = chunkE3APHA6O_cjs.cloneJson(recorded.node);
|
|
634
660
|
if (recorded.connectionNames) {
|
|
635
661
|
const refs = [];
|
|
636
662
|
for (const name of recorded.connectionNames) {
|
|
@@ -638,14 +664,14 @@ function assembleRecording(recording, options = {}) {
|
|
|
638
664
|
if (ref) refs.push({ connectionId: ref.connectionId, adapter: ref.adapter });
|
|
639
665
|
else missing.add(name);
|
|
640
666
|
}
|
|
641
|
-
const args =
|
|
667
|
+
const args = chunkE3APHA6O_cjs.isRecord(node["args"]) ? node["args"] : {};
|
|
642
668
|
args["connections"] = refs;
|
|
643
669
|
node["args"] = args;
|
|
644
670
|
}
|
|
645
671
|
return node;
|
|
646
672
|
});
|
|
647
673
|
if (missing.size > 0) throw new UnresolvedConnectionsError([...missing].sort());
|
|
648
|
-
const edges = orderEdges(
|
|
674
|
+
const edges = orderEdges(chunkE3APHA6O_cjs.cloneJson(recording.edges), recording.edgeOrder);
|
|
649
675
|
const ids = nodes2.map((node) => String(node["id"]));
|
|
650
676
|
const positions = options.layout?.positions ?? {};
|
|
651
677
|
const needsAuto = ids.some((id) => !Object.hasOwn(positions, id));
|
|
@@ -655,19 +681,19 @@ function assembleRecording(recording, options = {}) {
|
|
|
655
681
|
const position = Object.hasOwn(positions, id) ? positions[id] : auto.get(id);
|
|
656
682
|
if (position) node["position"] = { x: position.x, y: position.y };
|
|
657
683
|
}
|
|
658
|
-
const stickyNotes = options.layout?.stickyNotes !== void 0 || recording.notes.length > 0 ? [...options.layout?.stickyNotes ?
|
|
684
|
+
const stickyNotes = options.layout?.stickyNotes !== void 0 || recording.notes.length > 0 ? [...options.layout?.stickyNotes ? chunkE3APHA6O_cjs.cloneJson(options.layout.stickyNotes) : []] : void 0;
|
|
659
685
|
for (const recorded of recording.notes) {
|
|
660
686
|
const anchor = recorded.near !== void 0 ? nodes2.find((node) => node["id"] === recorded.near) : void 0;
|
|
661
|
-
const anchorPosition =
|
|
687
|
+
const anchorPosition = chunkE3APHA6O_cjs.isRecord(anchor?.["position"]) ? anchor["position"] : { x: 0, y: 0 };
|
|
662
688
|
const x = typeof anchorPosition["x"] === "number" ? anchorPosition["x"] : 0;
|
|
663
689
|
const y = typeof anchorPosition["y"] === "number" ? anchorPosition["y"] : 0;
|
|
664
|
-
stickyNotes?.push({ ...
|
|
690
|
+
stickyNotes?.push({ ...chunkE3APHA6O_cjs.cloneJson(recorded.note), position: { x, y: y - 220 } });
|
|
665
691
|
}
|
|
666
|
-
const document =
|
|
667
|
-
const extraData =
|
|
692
|
+
const document = chunkE3APHA6O_cjs.cloneJson(recording.document);
|
|
693
|
+
const extraData = chunkE3APHA6O_cjs.isRecord(document["data"]) ? document["data"] : {};
|
|
668
694
|
for (const key of ["nodes", "edges", "stickyNotes"]) {
|
|
669
695
|
if (Object.hasOwn(extraData, key))
|
|
670
|
-
throw new
|
|
696
|
+
throw new chunk6AIAC2FP_cjs.BuilderError(`extra.data.${key} is written by the builder`);
|
|
671
697
|
}
|
|
672
698
|
delete document["data"];
|
|
673
699
|
const authoring = options.authoring ?? {
|
|
@@ -687,22 +713,22 @@ function assembleRecording(recording, options = {}) {
|
|
|
687
713
|
...stickyNotes !== void 0 ? { stickyNotes } : {}
|
|
688
714
|
};
|
|
689
715
|
for (const key of ["config"]) if (document[key] !== void 0) out[key] = document[key];
|
|
690
|
-
if (options.pinnedData !== void 0) out["pinnedData"] =
|
|
716
|
+
if (options.pinnedData !== void 0) out["pinnedData"] = chunkE3APHA6O_cjs.cloneJson(options.pinnedData);
|
|
691
717
|
if (options.layout?.metaLayout !== void 0) {
|
|
692
|
-
const meta =
|
|
718
|
+
const meta = chunkE3APHA6O_cjs.isRecord(document["meta"]) ? document["meta"] : {};
|
|
693
719
|
if (meta["layout"] !== void 0)
|
|
694
|
-
throw new
|
|
695
|
-
meta["layout"] =
|
|
720
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("meta.layout comes from the layout file; do not set it in code");
|
|
721
|
+
meta["layout"] = chunkE3APHA6O_cjs.cloneJson(options.layout.metaLayout);
|
|
696
722
|
document["meta"] = meta;
|
|
697
723
|
}
|
|
698
724
|
for (const [key, value] of Object.entries(document)) {
|
|
699
|
-
if (!Object.hasOwn(out, key) && value !== void 0) out
|
|
725
|
+
if (!Object.hasOwn(out, key) && value !== void 0) chunkE3APHA6O_cjs.setOwn(out, key, value);
|
|
700
726
|
}
|
|
701
727
|
return out;
|
|
702
728
|
}
|
|
703
729
|
function toIR(workflow, options = {}) {
|
|
704
730
|
if (!isTier1Workflow(workflow))
|
|
705
|
-
throw new
|
|
731
|
+
throw new chunk6AIAC2FP_cjs.BuilderError("toIR takes the value defineWorkflow returned");
|
|
706
732
|
return assembleRecording(workflow.recording, options);
|
|
707
733
|
}
|
|
708
734
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk7YR7DI7B_cjs = require('./chunk-7YR7DI7B.cjs');
|
|
4
|
+
var chunkE3APHA6O_cjs = require('./chunk-E3APHA6O.cjs');
|
|
5
5
|
|
|
6
6
|
// src/ir/diff.ts
|
|
7
7
|
function keyPath(base, key) {
|
|
8
8
|
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? base ? `${base}.${key}` : key : `${base}[${JSON.stringify(key)}]`;
|
|
9
9
|
}
|
|
10
10
|
function diffValues(before, after, path, out) {
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
11
|
+
if (chunkE3APHA6O_cjs.deepEqual(before, after)) return;
|
|
12
|
+
if (chunkE3APHA6O_cjs.isRecord(before) && chunkE3APHA6O_cjs.isRecord(after)) {
|
|
13
13
|
const keys = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].sort();
|
|
14
14
|
for (const key of keys) {
|
|
15
|
-
const left = before
|
|
16
|
-
const right = after
|
|
15
|
+
const left = chunkE3APHA6O_cjs.ownValue(before, key);
|
|
16
|
+
const right = chunkE3APHA6O_cjs.ownValue(after, key);
|
|
17
17
|
if (left === void 0 && right !== void 0)
|
|
18
18
|
out.push({ kind: "added", path: keyPath(path, key), after: right });
|
|
19
19
|
else if (left !== void 0 && right === void 0)
|
|
@@ -28,7 +28,7 @@ function byId(items) {
|
|
|
28
28
|
const map = /* @__PURE__ */ new Map();
|
|
29
29
|
if (!Array.isArray(items)) return map;
|
|
30
30
|
items.forEach((item, index) => {
|
|
31
|
-
if (!
|
|
31
|
+
if (!chunkE3APHA6O_cjs.isRecord(item)) return;
|
|
32
32
|
const id = typeof item["id"] === "string" ? item["id"] : `#${index}`;
|
|
33
33
|
if (!map.has(id)) map.set(id, item);
|
|
34
34
|
});
|
|
@@ -48,23 +48,23 @@ function diffCollection(before, after, path, out) {
|
|
|
48
48
|
const common = (ids, other) => ids.filter((id) => other.has(id));
|
|
49
49
|
const leftOrder = common([...left.keys()], right);
|
|
50
50
|
const rightOrder = common([...right.keys()], left);
|
|
51
|
-
if (!
|
|
51
|
+
if (!chunkE3APHA6O_cjs.deepEqual(leftOrder, rightOrder)) {
|
|
52
52
|
out.push({ kind: "reordered", path, before: leftOrder, after: rightOrder });
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
function diffDefinitions(before, after) {
|
|
56
|
-
const left =
|
|
57
|
-
const right =
|
|
56
|
+
const left = chunk7YR7DI7B_cjs.hashedProjection(before);
|
|
57
|
+
const right = chunk7YR7DI7B_cjs.hashedProjection(after);
|
|
58
58
|
const out = [];
|
|
59
|
-
if (!
|
|
59
|
+
if (!chunkE3APHA6O_cjs.isRecord(left) || !chunkE3APHA6O_cjs.isRecord(right)) {
|
|
60
60
|
diffValues(left, right, "", out);
|
|
61
61
|
return out;
|
|
62
62
|
}
|
|
63
63
|
const { data: leftData, ...leftRest } = left;
|
|
64
64
|
const { data: rightData, ...rightRest } = right;
|
|
65
65
|
diffValues(leftRest, rightRest, "", out);
|
|
66
|
-
const leftDataRecord =
|
|
67
|
-
const rightDataRecord =
|
|
66
|
+
const leftDataRecord = chunkE3APHA6O_cjs.isRecord(leftData) ? leftData : {};
|
|
67
|
+
const rightDataRecord = chunkE3APHA6O_cjs.isRecord(rightData) ? rightData : {};
|
|
68
68
|
const { nodes: leftNodes, edges: leftEdges, ...leftDataRest } = leftDataRecord;
|
|
69
69
|
const { nodes: rightNodes, edges: rightEdges, ...rightDataRest } = rightDataRecord;
|
|
70
70
|
diffCollection(leftNodes, rightNodes, "data.nodes", out);
|
|
@@ -17,6 +17,17 @@ function deepEqual(left, right) {
|
|
|
17
17
|
}
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
+
function setOwn(target, key, value) {
|
|
21
|
+
Object.defineProperty(target, key, {
|
|
22
|
+
value,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function ownValue(record, key) {
|
|
29
|
+
return Object.hasOwn(record, key) ? record[key] : void 0;
|
|
30
|
+
}
|
|
20
31
|
function cloneJson(value) {
|
|
21
32
|
return structuredCloneJson(value);
|
|
22
33
|
}
|
|
@@ -25,7 +36,7 @@ function structuredCloneJson(value) {
|
|
|
25
36
|
if (isRecord(value)) {
|
|
26
37
|
const out = {};
|
|
27
38
|
for (const [key, child] of Object.entries(value)) {
|
|
28
|
-
if (child !== void 0) out
|
|
39
|
+
if (child !== void 0) setOwn(out, key, structuredCloneJson(child));
|
|
29
40
|
}
|
|
30
41
|
return out;
|
|
31
42
|
}
|
|
@@ -167,4 +178,4 @@ function isJsIdentifier(name) {
|
|
|
167
178
|
return IDENTIFIER.test(name);
|
|
168
179
|
}
|
|
169
180
|
|
|
170
|
-
export { cloneJson, deepEqual, formatRefExpression, formatRefTemplate, hasLegacyTemplate, isJsIdentifier, isRecord, parseRefExpression, parseTemplate, segmentFromKey };
|
|
181
|
+
export { cloneJson, deepEqual, formatRefExpression, formatRefTemplate, hasLegacyTemplate, isJsIdentifier, isRecord, ownValue, parseRefExpression, parseTemplate, segmentFromKey, setOwn };
|