@uipath/maestro-builder-sdk 6.124.15 → 6.124.17

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.
@@ -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 writes that loss into the original). If this edge matters to your edit, '
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
- + 'Connect each one with an edge in the .flow first, or edit that node\'s JSON directly.';
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. Connect it in the .flow or edit its JSON directly.`);
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). See merge.ts.
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
@@ -33,7 +33,7 @@ interface RtFlow {
33
33
  /** One difference, or one inconsistency in the merged file. */
34
34
  export interface MergeFinding {
35
35
  /** Which comparison found it. */
36
- kind: 'node-removed' | 'node-added' | 'node-type' | 'implicit-end' | 'edge-handle-renamed' | 'edge-rewired' | 'edge-removed' | 'edge-added' | 'handle-ids' | 'binding-removed' | 'binding-added' | 'variable-added' | 'variable-changed' | 'undeclared-handle' | 'duplicate-binding' | 'agent-sidecar' | 'agent-storage' | 'agent-prompt-input' | 'agent-embedded-edit' | 'outputs-superseded' | 'entry-point-repaired' | 'extract-draft' | 'processor-provisioned';
36
+ kind: 'node-removed' | 'node-added' | 'node-type' | 'implicit-end' | 'edge-handle-renamed' | 'edge-rewired' | 'edge-removed' | 'edge-added' | 'handle-ids' | 'binding-removed' | 'binding-added' | 'variable-added' | 'variable-changed' | 'undeclared-handle' | 'duplicate-binding' | 'agent-sidecar' | 'agent-storage' | 'agent-prompt-input' | 'agent-embedded-edit' | 'outputs-superseded' | 'entry-point-repaired' | 'extract-draft' | 'processor-provisioned' | 'taxonomy-ids-minted';
37
37
  /** The finding, phrased for the author, naming the node, edge or row. */
38
38
  message: string;
39
39
  /**
@@ -41,10 +41,22 @@ export interface MergeFinding {
41
41
  * `binding-removed`, which leave the merged file doing what the original does,
42
42
  * for `agent-embedded-edit`, which reports what merge did not carry, for
43
43
  * `outputs-superseded`, which reports a declaration merge corrected, and for
44
- * `entry-point-repaired` and `processor-provisioned`, which report a fix
45
- * merge made.
44
+ * `entry-point-repaired`, `processor-provisioned` and `taxonomy-ids-minted`,
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 {};
@@ -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
- out.push({ kind: 'node-removed', refuses: true, message: `the round trip drops ${scope}; merge will not write it.` });
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
- message: `the round trip rewires ${r[0].sourceNodeId}@${r[0].sourcePort}${where(scope)} from `
187
- + `${r.map((e) => `${e.targetNodeId}@${e.targetPort}`).join(', ')} to ${live.map((e) => `${e.targetNodeId}@${e.targetPort}`).join(', ')}; merge will write the new target.`,
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 will not write it.` });
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({ kind: 'node-removed', refuses: true, message: `the round trip drops node "${n.id}" (${n.type})${where(scope)}; merge will not write it.` });
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. See merge-roundtrip.ts.
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. See merge-roundtrip.ts.
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';
@@ -109,7 +116,8 @@ import { keepProcessInputReads } from './merge-process-inputs.js';
109
116
  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
- import { DYNAMIC_EXTRACT_TYPE, isIdpProcessorReadOnly, readIdpProcessorFolderPath, readIdpProcessorKey } from './nodes/document/flow/family.js';
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 refusing = options.strict ? findings.filter((f) => f.refuses) : [];
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));
@@ -583,6 +598,10 @@ function mergeFlowFindings(original, edited, options) {
583
598
  // none gets the key the edited compile minted for it, kept or edited
584
599
  // (provisionKeylessExtractNodes). ──
585
600
  const processorRepairs = provisionKeylessExtractNodes([...finalNodes, ...subflowScopes.flatMap((sf) => sf?.nodes ?? [])], byId([...(edited.nodes ?? []), ...Object.values(edited.subflows ?? {}).flatMap((sf) => sf?.nodes ?? [])]));
601
+ // ── Taxonomy ids: an Extract document group or field the merged node leaves
602
+ // without an id gets the one the edited compile minted for it, kept or
603
+ // edited (mintMissingTaxonomyIds). ──
604
+ const taxonomyRepairs = mintMissingTaxonomyIds([...finalNodes, ...subflowScopes.flatMap((sf) => sf?.nodes ?? [])], byId([...(edited.nodes ?? []), ...Object.values(edited.subflows ?? {}).flatMap((sf) => sf?.nodes ?? [])]), edited.id ?? original.id ?? '');
586
605
  // ── Variables: the same delta as nodes, per entry — what the author did not
587
606
  // change stays the original's, so compile's own spellings (an added
588
607
  // `name`, a re-derived End output type) do not reach the file (#1261).
@@ -614,6 +633,7 @@ function mergeFlowFindings(original, edited, options) {
614
633
  // one already taken elsewhere in the file, gets a fresh id, from ids unused
615
634
  // anywhere in the file. ──
616
635
  result.edges = withFileUniqueEdgeIds(edited.edges ?? [], subflowScopes).edges;
636
+ keepDetachedEdges(result, original, detached, finalNodes, subflowScopes);
617
637
  // ── Placement: a node the edit ADDED has no original position. Unless the
618
638
  // author set one, it has compile's placeholder, an emission-index slot
619
639
  // that can land on an original node. Put it next to its predecessor,
@@ -693,6 +713,7 @@ function mergeFlowFindings(original, edited, options) {
693
713
  ...(options.baseline ? roundTripFindings(original, options.baseline, result, superseded.rootVariables) : []),
694
714
  ...entryPointRepairs,
695
715
  ...processorRepairs,
716
+ ...taxonomyRepairs,
696
717
  ...mergedFileFindings(result, original),
697
718
  ];
698
719
  const agentFindings = (authored) => embeddedAgentFindings(!!options.baseline, [
@@ -706,6 +727,52 @@ function mergeFlowFindings(original, edited, options) {
706
727
  ], authored);
707
728
  return { result, findings, agentFindings, draftRefusals: drafts.refused };
708
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
+ }
709
776
  /**
710
777
  * Replace a non-GUID root `entryPointId` with the edited compile's GUID: publish
711
778
  * refuses non-GUIDs (1205). The edited id is deterministic; a GUID is never replaced.
@@ -771,6 +838,37 @@ function provisionKeylessExtractNodes(nodes, editedNodes) {
771
838
  }
772
839
  return out;
773
840
  }
841
+ /**
842
+ * Give each Extract document group and field that has no taxonomy id the one
843
+ * the edited compile minted for it (`x-uipath-field-group-id`,
844
+ * `x-uipath-field-id`), the way `uip maestro flow nodes schema set` filled them.
845
+ *
846
+ * Compile mints an id for every entry that has none, the same one on every
847
+ * recompile, so the no-edit baseline carries the same id as the edit, and the
848
+ * delta merge read it as unchanged and kept the original's id-less entry:
849
+ * `flow validate` kept warning, with no CLI-free way to repair it (#2259). A
850
+ * node kept from the original gets the ids too, since that is the repair a
851
+ * decompile -> merge round trip exists to make. An id the node names is never
852
+ * replaced, and a node with every id is left as it is.
853
+ */
854
+ function mintMissingTaxonomyIds(nodes, editedNodes, flowId) {
855
+ const out = [];
856
+ for (const node of nodes) {
857
+ const filled = fillMissingTaxonomyIds(node, editedNodes.get(node.id), flowId);
858
+ if (filled === undefined)
859
+ continue;
860
+ const parts = [
861
+ filled.groupIds > 0 ? `${filled.groupIds} field group id(s) (x-uipath-field-group-id)` : '',
862
+ filled.fieldIds > 0 ? `${filled.fieldIds} field id(s) (x-uipath-field-id)` : '',
863
+ filled.parentGroupIds > 0 ? `${filled.parentGroupIds} parent group reference(s)` : '',
864
+ ].filter((p) => p.length > 0);
865
+ out.push({
866
+ kind: 'taxonomy-ids-minted', refuses: false,
867
+ message: `Extract document node "${node.id}" had taxonomy entries with no id; gave them ${parts.join(', ')}, the ones compile minted.`,
868
+ });
869
+ }
870
+ return out;
871
+ }
774
872
  /**
775
873
  * Whether the merged node for `orig` must be built from the original rather than
776
874
  * taken from `edited`: the original is an embedded agent and the edited node is
@@ -7,3 +7,5 @@ export declare const documentFlowFamily: FlowNodeFamily;
7
7
  * `merge.ts`) and `bindings_v2.json`: pure, and not part of the public surface.
8
8
  */
9
9
  export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, DYNAMIC_EXTRACT_TYPE, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorReadOnly, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorFolderPath, readIdpProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, type IdpProcessorBindingRow, type WorkflowNodeLike, } from './idp-processor.js';
10
+ /** The taxonomy ids `merge` gives an Extract document node (#2259): pure, and not part of the public surface. */
11
+ export { fillMissingTaxonomyIds, type FilledTaxonomyIds } from './merge-taxonomy.js';
@@ -12,3 +12,5 @@ export const documentFlowFamily = {
12
12
  * `merge.ts`) and `bindings_v2.json`: pure, and not part of the public surface.
13
13
  */
14
14
  export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, DYNAMIC_EXTRACT_TYPE, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorReadOnly, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorFolderPath, readIdpProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, } from './idp-processor.js';
15
+ /** The taxonomy ids `merge` gives an Extract document node (#2259): pure, and not part of the public surface. */
16
+ export { fillMissingTaxonomyIds } from './merge-taxonomy.js';
@@ -0,0 +1,25 @@
1
+ /** A flow node as merge holds it: only what this module reads. */
2
+ export interface TaxonomyNodeLike {
3
+ id: string;
4
+ type?: string;
5
+ inputs?: unknown;
6
+ }
7
+ /** How many ids {@link fillMissingTaxonomyIds} wrote onto one node. */
8
+ export interface FilledTaxonomyIds {
9
+ groupIds: number;
10
+ fieldIds: number;
11
+ parentGroupIds: number;
12
+ }
13
+ /**
14
+ * Write onto `node` (MUTATED) each taxonomy id its schema document lacks: the
15
+ * id `edited` (the edited compile's node of the same id) has for the same
16
+ * entry, else the one compile mints for it from `flowId` and the node id.
17
+ * A nested group with no parent reference gets its parent's id. `undefined`
18
+ * when the node is not an Extract document node, carries an unsaved Schema
19
+ * Editor draft, or lacks no id.
20
+ *
21
+ * For instance, an original group `Invoice` with no `x-uipath-field-group-id`
22
+ * merges to `"x-uipath-field-group-id": "<the id compile minted for Invoice>"`,
23
+ * and its field `Total` gets the field id compile minted under that group.
24
+ */
25
+ export declare function fillMissingTaxonomyIds(node: TaxonomyNodeLike, edited: TaxonomyNodeLike | undefined, flowId: string): FilledTaxonomyIds | undefined;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The taxonomy ids `merge` gives an Extract document node (builder-sdk#2259):
3
+ * every field group and field the merged node leaves without an id gets the
4
+ * one the edited compile minted for the same entry.
5
+ *
6
+ * Compile mints an id for each group and field that has none
7
+ * ({@link settleTaxonomyIds}, the same id on every recompile). So the no-edit
8
+ * baseline and the edit carry the same minted id, the delta merge reads it as
9
+ * unchanged, and the merged node keeps the original's entry, which has none.
10
+ * Merge is the only SDK-route writer of an existing flow, so without this an
11
+ * id-less taxonomy kept failing `flow validate`'s taxonomy-id warnings.
12
+ *
13
+ * Only missing ids are written, in place: an id the merged node names is never
14
+ * replaced, nothing else in the document moves (no business check is dropped,
15
+ * no object is closed), and a node with every id is not touched. A node that
16
+ * carries an unsaved Schema Editor draft (`x-uipath-schema-editor-draft`) is not
17
+ * touched either: `uip maestro flow nodes schema set` refused to write one, and
18
+ * minting ids there would turn a no-edit merge into a change of a document
19
+ * someone is still editing. Pure: the flow core is portable (FB015).
20
+ */
21
+ import { DYNAMIC_EXTRACT_TYPE } from './idp-processor.js';
22
+ import { derivedTaxonomyMint, FIELD_GROUP_ID_EXTENSION, FIELD_ID_EXTENSION, isRecord, PARENT_FIELD_GROUP_ID_EXTENSION, readOutputSchema, SCHEMA_EDITOR_DRAFT_EXTENSION, settleTaxonomyIds, } from './taxonomy.js';
23
+ const present = (id) => id !== undefined && id.length > 0;
24
+ const isNested = (group) => group.segments.length > 1;
25
+ /** The node's `inputs.schemaDocument` when it is an Extract document node with an `outputSchema` object. */
26
+ function schemaDocumentOf(node) {
27
+ if (node?.type !== DYNAMIC_EXTRACT_TYPE || !isRecord(node.inputs))
28
+ return undefined;
29
+ const document = node.inputs.schemaDocument;
30
+ return isRecord(document) && isRecord(document.outputSchema) ? document : undefined;
31
+ }
32
+ /**
33
+ * Write onto `node` (MUTATED) each taxonomy id its schema document lacks: the
34
+ * id `edited` (the edited compile's node of the same id) has for the same
35
+ * entry, else the one compile mints for it from `flowId` and the node id.
36
+ * A nested group with no parent reference gets its parent's id. `undefined`
37
+ * when the node is not an Extract document node, carries an unsaved Schema
38
+ * Editor draft, or lacks no id.
39
+ *
40
+ * For instance, an original group `Invoice` with no `x-uipath-field-group-id`
41
+ * merges to `"x-uipath-field-group-id": "<the id compile minted for Invoice>"`,
42
+ * and its field `Total` gets the field id compile minted under that group.
43
+ */
44
+ export function fillMissingTaxonomyIds(node, edited, flowId) {
45
+ const document = schemaDocumentOf(node);
46
+ if (document === undefined || Object.hasOwn(document, SCHEMA_EDITOR_DRAFT_EXTENSION))
47
+ return undefined;
48
+ const groups = readOutputSchema(document.outputSchema).groups;
49
+ const lacks = groups.some((g) => !present(g.groupId) || (isNested(g) && !present(g.parentGroupId))
50
+ || g.fields.some((f) => !present(f.fieldId)));
51
+ if (!lacks)
52
+ return undefined;
53
+ // The ids compile would settle on for this document: its own, else the edited
54
+ // compile's for the same entry, else a fresh mint. Read, never written back
55
+ // whole: only the missing ones are copied onto the node.
56
+ const settled = settleTaxonomyIds(document, schemaDocumentOf(edited), derivedTaxonomyMint(flowId, node.id)).document;
57
+ const settledGroups = new Map(readOutputSchema(settled.outputSchema).groups.map((g) => [g.pathKey, g]));
58
+ const filled = { groupIds: 0, fieldIds: 0, parentGroupIds: 0 };
59
+ for (const group of groups) {
60
+ const s = settledGroups.get(group.pathKey);
61
+ if (s === undefined)
62
+ continue;
63
+ if (!present(group.groupId) && present(s.groupId)) {
64
+ group.node[FIELD_GROUP_ID_EXTENSION] = s.groupId;
65
+ filled.groupIds++;
66
+ }
67
+ if (isNested(group) && !present(group.parentGroupId) && present(s.parentGroupId)) {
68
+ group.node[PARENT_FIELD_GROUP_ID_EXTENSION] = s.parentGroupId;
69
+ filled.parentGroupIds++;
70
+ }
71
+ const settledFields = new Map(s.fields.map((f) => [f.name, f]));
72
+ for (const field of group.fields) {
73
+ const sf = settledFields.get(field.name);
74
+ if (present(field.fieldId) || sf === undefined || !present(sf.fieldId))
75
+ continue;
76
+ field.node[FIELD_ID_EXTENSION] = sf.fieldId;
77
+ filled.fieldIds++;
78
+ }
79
+ }
80
+ return filled.groupIds + filled.fieldIds + filled.parentGroupIds > 0 ? filled : undefined;
81
+ }
@@ -5,6 +5,11 @@ export declare const FIELD_GROUP_ID_EXTENSION = "x-uipath-field-group-id";
5
5
  export declare const FIELD_ID_EXTENSION = "x-uipath-field-id";
6
6
  /** Vendor extension naming the group a nested group hangs under. */
7
7
  export declare const PARENT_FIELD_GROUP_ID_EXTENSION = "x-uipath-parent-field-group-id";
8
+ /**
9
+ * Where the Studio Web Schema Editor parks an unsaved draft of the taxonomy,
10
+ * beside the saved one (flow-schema `IXP_SCHEMA_EDITOR_DRAFT_EXTENSION`).
11
+ */
12
+ export declare const SCHEMA_EDITOR_DRAFT_EXTENSION = "x-uipath-schema-editor-draft";
8
13
  /** Vendor extension holding business checks, which reference fields by id. */
9
14
  export declare const BUSINESS_CHECKS_EXTENSION = "x-uipath-business-checks";
10
15
  /** Joins the segments of a nested field group's flattened property key: `Invoice > Line items`. */
@@ -22,6 +22,11 @@ export const FIELD_GROUP_ID_EXTENSION = 'x-uipath-field-group-id';
22
22
  export const FIELD_ID_EXTENSION = 'x-uipath-field-id';
23
23
  /** Vendor extension naming the group a nested group hangs under. */
24
24
  export const PARENT_FIELD_GROUP_ID_EXTENSION = 'x-uipath-parent-field-group-id';
25
+ /**
26
+ * Where the Studio Web Schema Editor parks an unsaved draft of the taxonomy,
27
+ * beside the saved one (flow-schema `IXP_SCHEMA_EDITOR_DRAFT_EXTENSION`).
28
+ */
29
+ export const SCHEMA_EDITOR_DRAFT_EXTENSION = 'x-uipath-schema-editor-draft';
25
30
  /** Vendor extension holding business checks, which reference fields by id. */
26
31
  export const BUSINESS_CHECKS_EXTENSION = 'x-uipath-business-checks';
27
32
  /** Joins the segments of a nested field group's flattened property key: `Invoice > Line items`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.124.15",
3
+ "version": "6.124.17",
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": "32dac4a9b497fb2affda9c8629aad6a4117637e9"
131
+ "gitref": "50cc067a825606c491d7a7c3b08a204d33887546"
132
132
  }