@uipath/maestro-builder-sdk 6.124.16 → 6.124.18
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/dist/decompile.d.ts +12 -0
- package/dist/decompile.js +30 -7
- package/dist/merge-cli.js +4 -1
- package/dist/merge-roundtrip.d.ts +40 -0
- package/dist/merge-roundtrip.js +64 -6
- package/dist/merge.d.ts +8 -1
- package/dist/merge.js +67 -5
- package/dist/nodes/agent/flow/inline-agent-lift.js +9 -2
- package/package.json +2 -2
package/dist/decompile.d.ts
CHANGED
|
@@ -192,4 +192,16 @@ export interface DecompileOptions {
|
|
|
192
192
|
*/
|
|
193
193
|
export declare const SDK_HELPER_NAMES: readonly string[];
|
|
194
194
|
export declare function decompile(flow: FlowFile, options?: DecompileOptions): string;
|
|
195
|
+
/**
|
|
196
|
+
* The ids of the root-scope nodes `decompile` leaves out of the source because
|
|
197
|
+
* no trigger reaches them (`detachedTopLevelNodes`). A recompile cannot carry
|
|
198
|
+
* them and an author cannot have deleted them, so merge keeps them from the
|
|
199
|
+
* original (merge.ts, `keepDetachedNodes`). One rule for both, so merge never
|
|
200
|
+
* keeps a node decompile printed, or loses one it left out.
|
|
201
|
+
*
|
|
202
|
+
* Empty when the flow has no root at all (no trigger, no `start`): then nothing
|
|
203
|
+
* is reachable, every node would count as detached, and the edited file is the
|
|
204
|
+
* only graph there is.
|
|
205
|
+
*/
|
|
206
|
+
export declare function detachedNodeIds(flow: Pick<FlowFile, 'nodes' | 'edges'>): Set<string>;
|
|
195
207
|
export {};
|
package/dist/decompile.js
CHANGED
|
@@ -1694,7 +1694,7 @@ let runDropped = [];
|
|
|
1694
1694
|
/** The warning for an edge with no spelling in the emitted source. */
|
|
1695
1695
|
function droppedEdgeMessage(e) {
|
|
1696
1696
|
return `edge ${edgeName(e)} has no spelling in the decompiled source, so recompiling drops it `
|
|
1697
|
-
+ '(and merge
|
|
1697
|
+
+ '(and merge refuses to write the original without it). If this edge matters to your edit, '
|
|
1698
1698
|
+ 'change the .flow JSON directly instead of round-tripping it through the source.';
|
|
1699
1699
|
}
|
|
1700
1700
|
/**
|
|
@@ -3390,9 +3390,7 @@ export function decompile(flow, options = {}) {
|
|
|
3390
3390
|
// A node's TYPE is not enough: `uipath.connector.event.<key>.<event>` is a
|
|
3391
3391
|
// start trigger when it opens the flow and a mid-flow WAIT step when it has
|
|
3392
3392
|
// an incoming edge. Only a root can be a trigger.
|
|
3393
|
-
const triggerNodes = (flow.nodes ?? [])
|
|
3394
|
-
.filter((n) => isTrigger(n.type) && graph.inEdges(n.id).length === 0);
|
|
3395
|
-
const trigger = sourceTriggerRoot(triggerNodes) ?? graph.byId.get('start');
|
|
3393
|
+
const { triggerNodes, trigger } = flowRoots(flow.nodes ?? [], graph);
|
|
3396
3394
|
// The root the file marks as its default, when that is not `.trigger()`'s:
|
|
3397
3395
|
// its `.entryPoint()` says `default: true`.
|
|
3398
3396
|
const markedDefault = triggerNodes.find(isMarkedDefault);
|
|
@@ -3417,13 +3415,13 @@ export function decompile(flow, options = {}) {
|
|
|
3417
3415
|
if (detached.length > 0) {
|
|
3418
3416
|
const listing = detached.map((n) => `${tsLiteral(n.id)} (${n.type})`).join(', ');
|
|
3419
3417
|
const message = `${detached.length} node(s) are not reachable from any trigger — no edge leads to them: ${listing}. `
|
|
3420
|
-
+ 'The builder has no detached-node construct, so this source omits them and recompiling drops them
|
|
3421
|
-
+ '
|
|
3418
|
+
+ 'The builder has no detached-node construct, so this source omits them and recompiling drops them; '
|
|
3419
|
+
+ '`flow merge` keeps them, and their edges, from the original .flow. To edit one, connect it with an edge in the .flow first.';
|
|
3422
3420
|
if (runStrict)
|
|
3423
3421
|
throw new Error(`decompile: ${message}`);
|
|
3424
3422
|
warnOnce(message);
|
|
3425
3423
|
for (const n of detached) {
|
|
3426
|
-
e.line(d, `// TODO: node ${commentText(tsLiteral(n.id))} (${commentText(n.type)}) is not reachable from any trigger and is NOT in this source; recompiling drops it
|
|
3424
|
+
e.line(d, `// TODO: node ${commentText(tsLiteral(n.id))} (${commentText(n.type)}) is not reachable from any trigger and is NOT in this source; recompiling drops it, and \`flow merge\` keeps it from the original. To edit it, connect it in the .flow first.`);
|
|
3427
3425
|
}
|
|
3428
3426
|
}
|
|
3429
3427
|
emitVariables(e, d, flow, imp, new Set(triggerNodes.filter((t) => t !== trigger).map((t) => t.id)), shared);
|
|
@@ -3502,6 +3500,31 @@ function moduleFunctionName(node) {
|
|
|
3502
3500
|
runFunctionNames.set(node, name);
|
|
3503
3501
|
return name;
|
|
3504
3502
|
}
|
|
3503
|
+
/** The root triggers (a trigger type with no incoming edge) and the one `.trigger()` takes. */
|
|
3504
|
+
function flowRoots(nodes, graph) {
|
|
3505
|
+
const triggerNodes = nodes.filter((n) => isTrigger(n.type) && graph.inEdges(n.id).length === 0);
|
|
3506
|
+
const trigger = sourceTriggerRoot(triggerNodes) ?? graph.byId.get('start');
|
|
3507
|
+
return { triggerNodes, trigger };
|
|
3508
|
+
}
|
|
3509
|
+
/**
|
|
3510
|
+
* The ids of the root-scope nodes `decompile` leaves out of the source because
|
|
3511
|
+
* no trigger reaches them (`detachedTopLevelNodes`). A recompile cannot carry
|
|
3512
|
+
* them and an author cannot have deleted them, so merge keeps them from the
|
|
3513
|
+
* original (merge.ts, `keepDetachedNodes`). One rule for both, so merge never
|
|
3514
|
+
* keeps a node decompile printed, or loses one it left out.
|
|
3515
|
+
*
|
|
3516
|
+
* Empty when the flow has no root at all (no trigger, no `start`): then nothing
|
|
3517
|
+
* is reachable, every node would count as detached, and the edited file is the
|
|
3518
|
+
* only graph there is.
|
|
3519
|
+
*/
|
|
3520
|
+
export function detachedNodeIds(flow) {
|
|
3521
|
+
const nodes = flow.nodes ?? [];
|
|
3522
|
+
const graph = new Graph(nodes, flow.edges ?? [], undefined);
|
|
3523
|
+
const { triggerNodes, trigger } = flowRoots(nodes, graph);
|
|
3524
|
+
if (trigger === undefined && triggerNodes.length === 0)
|
|
3525
|
+
return new Set();
|
|
3526
|
+
return new Set(detachedTopLevelNodes(nodes, graph, triggerNodes, trigger).map((n) => n.id));
|
|
3527
|
+
}
|
|
3505
3528
|
/**
|
|
3506
3529
|
* Top-level nodes (no `parentId`) that no root trigger reaches over ANY edge —
|
|
3507
3530
|
* error, branch, outcome and artifact ports included, so a node that only an
|
package/dist/merge-cli.js
CHANGED
|
@@ -54,7 +54,10 @@
|
|
|
54
54
|
* omit it for a two-way merge (take the edited graph, re-attach original layout).
|
|
55
55
|
* With `--baseline`, every wire-identity difference between the baseline and
|
|
56
56
|
* the original (what the no-edit round trip changed) is printed as a warning;
|
|
57
|
-
* `--strict` refuses instead (exit 1, nothing written).
|
|
57
|
+
* `--strict` refuses instead (exit 1, nothing written). A node, subflow or edge
|
|
58
|
+
* of the original that the round trip drops, or an edge it rewires, is refused
|
|
59
|
+
* with or without `--strict` (exit 1, nothing written, the dropped node ids
|
|
60
|
+
* named). A node no trigger reaches is kept from the original. See merge.ts.
|
|
58
61
|
*
|
|
59
62
|
* Agent sidecars (#1207): an inline agent's prompts and settings live in
|
|
60
63
|
* `<source>/agent.json` beside each flow, not in the node. Merge reads that file
|
|
@@ -45,6 +45,18 @@ export interface MergeFinding {
|
|
|
45
45
|
* which report a fix merge made.
|
|
46
46
|
*/
|
|
47
47
|
refuses: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Set when the finding is data LOSS: a part of the original the round trip
|
|
50
|
+
* drops, which the author never had in the source and so cannot have deleted.
|
|
51
|
+
* `mergeFlow` refuses every such finding in every mode (`RoundTripLossError`).
|
|
52
|
+
* Names what is lost: `node` (with `subflow` for a node inside one), a whole
|
|
53
|
+
* `subflow` alone, or an `edge` as `source@port -> target@port`.
|
|
54
|
+
*/
|
|
55
|
+
loss?: {
|
|
56
|
+
node?: string;
|
|
57
|
+
subflow?: string;
|
|
58
|
+
edge?: string;
|
|
59
|
+
};
|
|
48
60
|
}
|
|
49
61
|
/**
|
|
50
62
|
* Every wire-identity difference between the original and its no-edit round
|
|
@@ -80,10 +92,38 @@ export declare function roundTripFindings(original: RtFlow, baseline: RtFlow, me
|
|
|
80
92
|
* @returns One finding per inconsistency.
|
|
81
93
|
*/
|
|
82
94
|
export declare function mergedFileFindings(merged: RtFlow, original?: RtFlow): MergeFinding[];
|
|
95
|
+
/**
|
|
96
|
+
* Whether a finding is data LOSS (`MergeFinding.loss`): a node, subflow or edge
|
|
97
|
+
* the original has that the no-edit round trip drops, or an original edge it
|
|
98
|
+
* rewires to another target while both ends stay. The author cannot have
|
|
99
|
+
* deleted any of them on purpose — none was ever in the decompiled source — so
|
|
100
|
+
* writing the merged file would delete a real part of the user's flow (#2254:
|
|
101
|
+
* a fan-out decompile could not spell lost every arm but the first).
|
|
102
|
+
* `mergeFlow` refuses these in every mode, not only under `strict`.
|
|
103
|
+
*
|
|
104
|
+
* A handle rename (`edge-handle-renamed`: same source node, same target, only
|
|
105
|
+
* the source handle spelled differently, as in `case-default-1` ->
|
|
106
|
+
* `case-case_1`) is not a loss: the wire still joins the same two nodes. It is
|
|
107
|
+
* warned, refused under `strict`, and an undeclared handle it leaves is its own
|
|
108
|
+
* finding (`undeclared-handle`).
|
|
109
|
+
*/
|
|
110
|
+
export declare function isLoss(f: MergeFinding): boolean;
|
|
83
111
|
/** Thrown by `mergeFlow` under `strict` when a finding refuses the merge. */
|
|
84
112
|
export declare class MergeRefusedError extends Error {
|
|
85
113
|
/** Every refusing finding, in report order. */
|
|
86
114
|
readonly findings: readonly MergeFinding[];
|
|
87
115
|
constructor(findings: readonly MergeFinding[]);
|
|
88
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Thrown by `mergeFlow`, with or without `strict`, when the round trip would
|
|
119
|
+
* drop a node, subflow or edge of the original (`isLoss`). Nothing is written.
|
|
120
|
+
* The message names every dropped node id, subflow and edge.
|
|
121
|
+
*/
|
|
122
|
+
export declare class RoundTripLossError extends MergeRefusedError {
|
|
123
|
+
/** The ids of the nodes the round trip drops (root and subflow nodes). */
|
|
124
|
+
readonly droppedNodes: readonly string[];
|
|
125
|
+
/** The keys of the whole subflows the round trip drops. */
|
|
126
|
+
readonly droppedSubflows: readonly string[];
|
|
127
|
+
constructor(losses: readonly MergeFinding[], others?: readonly MergeFinding[]);
|
|
128
|
+
}
|
|
89
129
|
export {};
|
package/dist/merge-roundtrip.js
CHANGED
|
@@ -133,8 +133,10 @@ export function roundTripFindings(original, baseline, merged, correctedVariables
|
|
|
133
133
|
continue;
|
|
134
134
|
}
|
|
135
135
|
if (!baseScopes.has(scope)) {
|
|
136
|
-
if (!m)
|
|
137
|
-
|
|
136
|
+
if (!m) {
|
|
137
|
+
const subflow = scope.slice('subflows.'.length);
|
|
138
|
+
out.push({ kind: 'node-removed', refuses: true, loss: { subflow }, message: `the round trip drops subflow "${subflow}"; merge refuses to delete it.` });
|
|
139
|
+
}
|
|
138
140
|
continue;
|
|
139
141
|
}
|
|
140
142
|
const oNodes = new Map(o.nodes.map((n) => [n.id, n]));
|
|
@@ -181,10 +183,16 @@ export function roundTripFindings(original, baseline, merged, correctedVariables
|
|
|
181
183
|
const live = a.filter(inMerged);
|
|
182
184
|
if (live.length === 0)
|
|
183
185
|
continue;
|
|
186
|
+
// The original edge is gone from the merged file while both its ends are
|
|
187
|
+
// still there: the merged file loses that wire and gains a wrong one, the
|
|
188
|
+
// same loss as a dropped edge (an end the author deleted takes the edge with it).
|
|
189
|
+
const lost = r.find((e) => !inMerged(e) && mNodes.has(e.sourceNodeId) && mNodes.has(e.targetNodeId));
|
|
190
|
+
const from = `${r.map((e) => `${e.targetNodeId}@${e.targetPort}`).join(', ')} to ${live.map((e) => `${e.targetNodeId}@${e.targetPort}`).join(', ')}`;
|
|
184
191
|
out.push({
|
|
185
192
|
kind: 'edge-rewired', refuses: true,
|
|
186
|
-
|
|
187
|
-
|
|
193
|
+
...(lost ? { loss: { edge: edgeText(lost) } } : {}),
|
|
194
|
+
message: `the round trip rewires ${r[0].sourceNodeId}@${r[0].sourcePort}${where(scope)} from ${from}; `
|
|
195
|
+
+ (lost ? 'merge refuses to write the new target.' : 'merge will write the new target.'),
|
|
188
196
|
});
|
|
189
197
|
}
|
|
190
198
|
// A dropped edge is reported while both its ends are in the merged file and
|
|
@@ -192,7 +200,7 @@ export function roundTripFindings(original, baseline, merged, correctedVariables
|
|
|
192
200
|
for (const e of removed) {
|
|
193
201
|
if (inMerged(e) || !mNodes.has(e.sourceNodeId) || !mNodes.has(e.targetNodeId))
|
|
194
202
|
continue;
|
|
195
|
-
out.push({ kind: 'edge-removed', refuses: true, message: `the round trip drops the edge ${edgeText(e)}${where(scope)}; merge
|
|
203
|
+
out.push({ kind: 'edge-removed', refuses: true, loss: { edge: edgeText(e) }, message: `the round trip drops the edge ${edgeText(e)}${where(scope)}; merge refuses to delete it.` });
|
|
196
204
|
}
|
|
197
205
|
// An added TERMINAL node (its definition declares no source handle — an
|
|
198
206
|
// End) is neutral when every edge into it leaves a handle the original left
|
|
@@ -215,7 +223,10 @@ export function roundTripFindings(original, baseline, merged, correctedVariables
|
|
|
215
223
|
// ── Nodes ──
|
|
216
224
|
for (const n of o.nodes) {
|
|
217
225
|
if (!bNodes.has(n.id) && !mNodes.has(n.id)) {
|
|
218
|
-
out.push({
|
|
226
|
+
out.push({
|
|
227
|
+
kind: 'node-removed', refuses: true, loss: { node: n.id, ...(scope ? { subflow: scope.slice('subflows.'.length) } : {}) },
|
|
228
|
+
message: `the round trip drops node "${n.id}" (${n.type})${where(scope)}; merge refuses to delete it.`,
|
|
229
|
+
});
|
|
219
230
|
}
|
|
220
231
|
}
|
|
221
232
|
for (const n of b.nodes) {
|
|
@@ -405,6 +416,24 @@ export function mergedFileFindings(merged, original = {}) {
|
|
|
405
416
|
}
|
|
406
417
|
return out;
|
|
407
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Whether a finding is data LOSS (`MergeFinding.loss`): a node, subflow or edge
|
|
421
|
+
* the original has that the no-edit round trip drops, or an original edge it
|
|
422
|
+
* rewires to another target while both ends stay. The author cannot have
|
|
423
|
+
* deleted any of them on purpose — none was ever in the decompiled source — so
|
|
424
|
+
* writing the merged file would delete a real part of the user's flow (#2254:
|
|
425
|
+
* a fan-out decompile could not spell lost every arm but the first).
|
|
426
|
+
* `mergeFlow` refuses these in every mode, not only under `strict`.
|
|
427
|
+
*
|
|
428
|
+
* A handle rename (`edge-handle-renamed`: same source node, same target, only
|
|
429
|
+
* the source handle spelled differently, as in `case-default-1` ->
|
|
430
|
+
* `case-case_1`) is not a loss: the wire still joins the same two nodes. It is
|
|
431
|
+
* warned, refused under `strict`, and an undeclared handle it leaves is its own
|
|
432
|
+
* finding (`undeclared-handle`).
|
|
433
|
+
*/
|
|
434
|
+
export function isLoss(f) {
|
|
435
|
+
return f.loss !== undefined;
|
|
436
|
+
}
|
|
408
437
|
/** Thrown by `mergeFlow` under `strict` when a finding refuses the merge. */
|
|
409
438
|
export class MergeRefusedError extends Error {
|
|
410
439
|
/** Every refusing finding, in report order. */
|
|
@@ -417,3 +446,32 @@ export class MergeRefusedError extends Error {
|
|
|
417
446
|
this.findings = findings;
|
|
418
447
|
}
|
|
419
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Thrown by `mergeFlow`, with or without `strict`, when the round trip would
|
|
451
|
+
* drop a node, subflow or edge of the original (`isLoss`). Nothing is written.
|
|
452
|
+
* The message names every dropped node id, subflow and edge.
|
|
453
|
+
*/
|
|
454
|
+
export class RoundTripLossError extends MergeRefusedError {
|
|
455
|
+
/** The ids of the nodes the round trip drops (root and subflow nodes). */
|
|
456
|
+
droppedNodes;
|
|
457
|
+
/** The keys of the whole subflows the round trip drops. */
|
|
458
|
+
droppedSubflows;
|
|
459
|
+
constructor(losses, others = []) {
|
|
460
|
+
super([...losses, ...others]);
|
|
461
|
+
const droppedNodes = losses.flatMap((f) => (f.loss?.node !== undefined ? [f.loss.node] : []));
|
|
462
|
+
const droppedSubflows = losses.flatMap((f) => (f.loss?.node === undefined && f.loss?.subflow !== undefined ? [f.loss.subflow] : []));
|
|
463
|
+
const quoted = (ids) => ids.map((id) => `"${id}"`).join(', ');
|
|
464
|
+
const what = [
|
|
465
|
+
...(droppedNodes.length ? [`node(s) ${quoted(droppedNodes)}`] : []),
|
|
466
|
+
...(droppedSubflows.length ? [`subflow(s) ${quoted(droppedSubflows)}`] : []),
|
|
467
|
+
];
|
|
468
|
+
this.message = (`refused: the decompiled source cannot express part of the original, so merging it would delete `
|
|
469
|
+
+ `${what.length ? what.join(' and ') : 'edge(s)'} that you did not remove. `
|
|
470
|
+
+ 'Nothing was written. Look for the TODO markers decompile left in the source, which name the shape it could not spell, '
|
|
471
|
+
+ 'and edit the .flow JSON directly for that part:\n'
|
|
472
|
+
+ [...losses, ...others].map((f) => ` - ${f.message}`).join('\n'));
|
|
473
|
+
this.name = 'RoundTripLossError';
|
|
474
|
+
this.droppedNodes = droppedNodes;
|
|
475
|
+
this.droppedSubflows = droppedSubflows;
|
|
476
|
+
}
|
|
477
|
+
}
|
package/dist/merge.d.ts
CHANGED
|
@@ -80,7 +80,14 @@
|
|
|
80
80
|
* undid it. Each difference the merged file still carries is reported through
|
|
81
81
|
* `warn`, and `strict` refuses the merge over it; the merged file is also
|
|
82
82
|
* checked for an edge that leaves a handle its kept source node does not
|
|
83
|
-
* declare.
|
|
83
|
+
* declare. A node, subflow or edge of the original the round trip DROPS, or an
|
|
84
|
+
* original edge it rewires while both ends stay, is refused in every mode
|
|
85
|
+
* (`isLoss`, `RoundTripLossError`): the author never had it in the source to
|
|
86
|
+
* delete, so writing the file would delete part of the user's flow. A root node
|
|
87
|
+
* no trigger reaches is the exception decompile announces (it leaves such a node
|
|
88
|
+
* out of the source on purpose): merge keeps it and its edges from the original
|
|
89
|
+
* (`keepDetachedNodes`), so a flow with a canvas orphan still merges. See
|
|
90
|
+
* merge-roundtrip.ts.
|
|
84
91
|
*
|
|
85
92
|
* ## A superseded output declaration is replaced
|
|
86
93
|
*
|
package/dist/merge.js
CHANGED
|
@@ -80,7 +80,14 @@
|
|
|
80
80
|
* undid it. Each difference the merged file still carries is reported through
|
|
81
81
|
* `warn`, and `strict` refuses the merge over it; the merged file is also
|
|
82
82
|
* checked for an edge that leaves a handle its kept source node does not
|
|
83
|
-
* declare.
|
|
83
|
+
* declare. A node, subflow or edge of the original the round trip DROPS, or an
|
|
84
|
+
* original edge it rewires while both ends stay, is refused in every mode
|
|
85
|
+
* (`isLoss`, `RoundTripLossError`): the author never had it in the source to
|
|
86
|
+
* delete, so writing the file would delete part of the user's flow. A root node
|
|
87
|
+
* no trigger reaches is the exception decompile announces (it leaves such a node
|
|
88
|
+
* out of the source on purpose): merge keeps it and its edges from the original
|
|
89
|
+
* (`keepDetachedNodes`), so a flow with a canvas orphan still merges. See
|
|
90
|
+
* merge-roundtrip.ts.
|
|
84
91
|
*
|
|
85
92
|
* ## A superseded output declaration is replaced
|
|
86
93
|
*
|
|
@@ -100,7 +107,7 @@ import { GUID_RE } from './core/binding-messages.js';
|
|
|
100
107
|
import { jsonClone } from './core/json-clone.js';
|
|
101
108
|
import { isRecord } from './core/node-envelope.js';
|
|
102
109
|
import { DEFINITIONLESS_NODE_TYPES } from './core/definitionless-node-types.js';
|
|
103
|
-
import { MergeRefusedError, mergedFileFindings, roundTripFindings } from './merge-roundtrip.js';
|
|
110
|
+
import { MergeRefusedError, RoundTripLossError, isLoss, mergedFileFindings, roundTripFindings } from './merge-roundtrip.js';
|
|
104
111
|
import { placeAddedNodes, stripPlaceholderFlag, unplacedRule } from './node-placement.js';
|
|
105
112
|
import { mergeAgentSidecars } from './merge-sidecars.js';
|
|
106
113
|
import { embeddedAgentFindings, isEmbeddedAgent, mergeEmbeddedAgentNode } from './merge-embedded-agent.js';
|
|
@@ -110,6 +117,7 @@ import { replaceSupersededOutputs } from './merge-superseded-outputs.js';
|
|
|
110
117
|
import { restoredConnectionMessage, withOriginalConnectionLabels } from './merge-baseline-connections.js';
|
|
111
118
|
import { extractDraftFindings } from './merge-extract-draft.js';
|
|
112
119
|
import { DYNAMIC_EXTRACT_TYPE, fillMissingTaxonomyIds, isIdpProcessorReadOnly, readIdpProcessorFolderPath, readIdpProcessorKey } from './nodes/document/flow/family.js';
|
|
120
|
+
import { detachedNodeIds } from './decompile.js';
|
|
113
121
|
import { byId, isKept, nodeUnchanged, subflowsTakenFromEdited } from './edit-scope.js';
|
|
114
122
|
export { MergeRefusedError } from './merge-roundtrip.js';
|
|
115
123
|
/**
|
|
@@ -466,12 +474,15 @@ class SidecarOverwriteError extends MergeRefusedError {
|
|
|
466
474
|
* an Extract document draft overwritten.
|
|
467
475
|
*/
|
|
468
476
|
function reportOrRefuse(findings, options, overwrites = []) {
|
|
469
|
-
const
|
|
477
|
+
const losses = findings.filter(isLoss);
|
|
478
|
+
const refusing = options.strict ? findings.filter((f) => f.refuses && !losses.includes(f)) : [];
|
|
470
479
|
for (const f of findings)
|
|
471
|
-
if (!refusing.includes(f))
|
|
480
|
+
if (!refusing.includes(f) && !losses.includes(f))
|
|
472
481
|
options.warn?.(f.message);
|
|
473
482
|
if (overwrites.length > 0)
|
|
474
|
-
throw new SidecarOverwriteError([...overwrites, ...refusing]);
|
|
483
|
+
throw new SidecarOverwriteError([...overwrites, ...losses, ...refusing]);
|
|
484
|
+
if (losses.length > 0)
|
|
485
|
+
throw new RoundTripLossError(losses, refusing);
|
|
475
486
|
if (refusing.length > 0)
|
|
476
487
|
throw new MergeRefusedError(refusing);
|
|
477
488
|
}
|
|
@@ -530,6 +541,10 @@ function mergeFlowFindings(original, edited, options) {
|
|
|
530
541
|
}
|
|
531
542
|
}
|
|
532
543
|
}
|
|
544
|
+
// A root node no trigger reaches is not in the decompiled source (decompile's
|
|
545
|
+
// detached-node warning), so the edit cannot carry it and the author cannot
|
|
546
|
+
// have deleted it: keep it, and below its edges, from the original.
|
|
547
|
+
const detached = keepDetachedNodes(original, edited, finalNodes);
|
|
533
548
|
result.nodes = finalNodes;
|
|
534
549
|
for (const node of finalNodes)
|
|
535
550
|
repairBareBranches(node, baseNodes.get(node.id));
|
|
@@ -618,6 +633,7 @@ function mergeFlowFindings(original, edited, options) {
|
|
|
618
633
|
// one already taken elsewhere in the file, gets a fresh id, from ids unused
|
|
619
634
|
// anywhere in the file. ──
|
|
620
635
|
result.edges = withFileUniqueEdgeIds(edited.edges ?? [], subflowScopes).edges;
|
|
636
|
+
keepDetachedEdges(result, original, detached, finalNodes, subflowScopes);
|
|
621
637
|
// ── Placement: a node the edit ADDED has no original position. Unless the
|
|
622
638
|
// author set one, it has compile's placeholder, an emission-index slot
|
|
623
639
|
// that can land on an original node. Put it next to its predecessor,
|
|
@@ -711,6 +727,52 @@ function mergeFlowFindings(original, edited, options) {
|
|
|
711
727
|
], authored);
|
|
712
728
|
return { result, findings, agentFindings, draftRefusals: drafts.refused };
|
|
713
729
|
}
|
|
730
|
+
/**
|
|
731
|
+
* Append to `finalNodes` each root node of the original that no trigger reaches
|
|
732
|
+
* (`detachedNodeIds`, the rule decompile uses to leave a node out of the source)
|
|
733
|
+
* and that the edited file does not have. Such a node is a canvas orphan, or the
|
|
734
|
+
* step after an all-End human task: no edit can touch it, so writing the file
|
|
735
|
+
* without it would delete part of the user's flow. Returns the kept ids. An
|
|
736
|
+
* edited node with the same id is the author's and wins.
|
|
737
|
+
*/
|
|
738
|
+
function keepDetachedNodes(original, edited, finalNodes) {
|
|
739
|
+
const editedIds = new Set((edited.nodes ?? []).map((n) => n.id));
|
|
740
|
+
const kept = new Set();
|
|
741
|
+
const ids = detachedNodeIds(original);
|
|
742
|
+
for (const n of original.nodes ?? []) {
|
|
743
|
+
if (!ids.has(n.id) || editedIds.has(n.id))
|
|
744
|
+
continue;
|
|
745
|
+
finalNodes.push(jsonClone(n));
|
|
746
|
+
kept.add(n.id);
|
|
747
|
+
}
|
|
748
|
+
return kept;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Append the original's root edges that touch a node `keepDetachedNodes` kept,
|
|
752
|
+
* when both ends are in the merged file (an edge into a node the author deleted
|
|
753
|
+
* goes with it). An id the merged file already uses is renumbered, and its
|
|
754
|
+
* `layout.edges` route follows it.
|
|
755
|
+
*/
|
|
756
|
+
function keepDetachedEdges(result, original, detached, finalNodes, subflowScopes) {
|
|
757
|
+
if (detached.size === 0)
|
|
758
|
+
return;
|
|
759
|
+
const present = new Set(finalNodes.map((n) => n.id));
|
|
760
|
+
const carried = (original.edges ?? []).filter((e) => (detached.has(e.sourceNodeId) || detached.has(e.targetNodeId))
|
|
761
|
+
&& present.has(e.sourceNodeId) && present.has(e.targetNodeId));
|
|
762
|
+
if (carried.length === 0)
|
|
763
|
+
return;
|
|
764
|
+
const { edges, renamed } = withFileUniqueEdgeIds(carried, [...subflowScopes, { edges: result.edges }]);
|
|
765
|
+
result.edges = [...(result.edges ?? []), ...edges];
|
|
766
|
+
const layout = result.layout;
|
|
767
|
+
if (renamed.size > 0 && layout?.edges) {
|
|
768
|
+
for (const [from, to] of renamed) {
|
|
769
|
+
if (!Object.hasOwn(layout.edges, from))
|
|
770
|
+
continue;
|
|
771
|
+
layout.edges[to] = layout.edges[from];
|
|
772
|
+
delete layout.edges[from];
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
714
776
|
/**
|
|
715
777
|
* Replace a non-GUID root `entryPointId` with the edited compile's GUID: publish
|
|
716
778
|
* refuses non-GUIDs (1205). The edited id is deterministic; a GUID is never replaced.
|
|
@@ -109,6 +109,13 @@ function liftableEscalationFor(agentType) {
|
|
|
109
109
|
return n.type === 'uipath.agent.resource.escalation.coded-action-app' && v === appVersion;
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Which nodes on an agent's `context` port the lift can write as a `context`
|
|
114
|
+
* entry: a context index only. Any other context resource (a Data Fabric
|
|
115
|
+
* entity set, for instance) stays reported as a dropped edge, not printed as an
|
|
116
|
+
* index with no id.
|
|
117
|
+
*/
|
|
118
|
+
const liftableContext = (n) => parseContextIndexType(n.type) !== undefined;
|
|
112
119
|
const QUICK_FORM_ESCALATION = 'uipath.agent.resource.escalation.quick-form';
|
|
113
120
|
const CONNECTOR_TOOL_PREFIX = 'uipath.agent.resource.tool.connector.';
|
|
114
121
|
/**
|
|
@@ -767,7 +774,7 @@ export function liftAgentResources(node, ctx, withMemory, agentInputs = []) {
|
|
|
767
774
|
['context', 'Context', Infinity], ['tool', 'Tool', Infinity],
|
|
768
775
|
['escalation', 'Escalation', Infinity], ...(withMemory ? [['memory', 'Memory', 1]] : []),
|
|
769
776
|
]) {
|
|
770
|
-
const targets = ctx.attachedIds(port, port === 'tool' ? liftable : port === 'escalation' ? liftableEscalation : undefined);
|
|
777
|
+
const targets = ctx.attachedIds(port, port === 'tool' ? liftable : port === 'escalation' ? liftableEscalation : port === 'context' ? liftableContext : undefined);
|
|
771
778
|
const keep = port !== 'memory'
|
|
772
779
|
&& targets.some((id, k) => id !== derivedResourceNodeId(node.id, kind, k));
|
|
773
780
|
targets.forEach((id, k) => {
|
|
@@ -986,7 +993,7 @@ export function liftAgentResources(node, ctx, withMemory, agentInputs = []) {
|
|
|
986
993
|
// `liftableToolFor` admits no other type.
|
|
987
994
|
throw new Error(`internal SDK error: tool "${t.id}" of type ${type} has no lift.`);
|
|
988
995
|
});
|
|
989
|
-
const contextSrc = resource('context').map((c) => {
|
|
996
|
+
const contextSrc = resource('context', Infinity, liftableContext).map((c) => {
|
|
990
997
|
const { name, id, folderPath, sidecar } = contextIndexIdentity(node, c, rPlain, ctx);
|
|
991
998
|
// Compile labels the node with `name`; a canvas rename is kept as `label`.
|
|
992
999
|
const label = typeof c.display?.label === 'string' && c.display.label !== '' && c.display.label !== name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.124.
|
|
3
|
+
"version": "6.124.18",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"@types/node": "^22.7.0",
|
|
129
129
|
"esbuild": "^0.28.1"
|
|
130
130
|
},
|
|
131
|
-
"gitref": "
|
|
131
|
+
"gitref": "ee27233f8a6142eb8d89ce7c3824aa8c0697fe5f"
|
|
132
132
|
}
|