@uipath/maestro-builder-sdk 6.124.3 → 6.124.5

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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The wire fields whose plain-string value is JavaScript (no `=js:` prefix):
3
+ * a script body, a decision or switch `expression`, a loop's `condition` and
4
+ * `completionCondition`, a `conditionExpression` an older compile wrote bare, a transform's
5
+ * `collection`. `serialize` renames `$vars` reads in exactly these and in
6
+ * `=js:` values. A loop's `completionCondition` is listed for files written
7
+ * before #1763: the SDK now writes it as a jsExpression envelope, because the
8
+ * runtime ignores the bare string.
9
+ */
10
+ export declare const RAW_JS_FIELDS: Set<string>;
11
+ /**
12
+ * Every `$vars.<from>` read (the whole root, not a prefix of a longer one) read as
13
+ * `$vars.<to>`, held to the slots that hold code: a `=js:` value anywhere,
14
+ * and a value under a `RAW_JS_FIELDS` key or an output's `source`. A label, a
15
+ * description or any other text that happens to start `$vars.` is data, and so
16
+ * is a literal envelope and everything under a node's `display` and `ui`.
17
+ */
18
+ export declare function renameInputReads<T>(v: T, from: string, to: string): T;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Rewriting `$vars.<name>` reads in the code slots of a flow's nodes: shared by
3
+ * decompile (a process-level input read moves to its trigger's output,
4
+ * `bindProcessInputReads`) and merge (an edit's read of one moves back,
5
+ * `merge-process-inputs.ts`).
6
+ */
7
+ import { escapeRegExp } from './escape-regexp.js';
8
+ import { mapJsCode } from './js-code-spans.js';
9
+ /**
10
+ * The wire fields whose plain-string value is JavaScript (no `=js:` prefix):
11
+ * a script body, a decision or switch `expression`, a loop's `condition` and
12
+ * `completionCondition`, a `conditionExpression` an older compile wrote bare, a transform's
13
+ * `collection`. `serialize` renames `$vars` reads in exactly these and in
14
+ * `=js:` values. A loop's `completionCondition` is listed for files written
15
+ * before #1763: the SDK now writes it as a jsExpression envelope, because the
16
+ * runtime ignores the bare string.
17
+ */
18
+ export const RAW_JS_FIELDS = new Set(['script', 'expression', 'condition', 'completionCondition', 'conditionExpression', 'collection']);
19
+ /**
20
+ * Every `$vars.<from>` read (the whole root, not a prefix of a longer one) read as
21
+ * `$vars.<to>`, held to the slots that hold code: a `=js:` value anywhere,
22
+ * and a value under a `RAW_JS_FIELDS` key or an output's `source`. A label, a
23
+ * description or any other text that happens to start `$vars.` is data, and so
24
+ * is a literal envelope and everything under a node's `display` and `ui`.
25
+ */
26
+ export function renameInputReads(v, from, to) {
27
+ const re = new RegExp(`\\$vars\\.${escapeRegExp(from)}(?![A-Za-z0-9_$])`, 'g');
28
+ // a function: `$&` in `to` is data
29
+ const inCode = (js) => mapJsCode(js, (code) => code.replace(re, () => `$vars.${to}`));
30
+ const walk = (x, key) => {
31
+ if (typeof x === 'string') {
32
+ if (!x.includes(`$vars.${from}`))
33
+ return x;
34
+ if (x.startsWith('=js:'))
35
+ return '=js:' + inCode(x.slice(4));
36
+ if (key !== undefined && (RAW_JS_FIELDS.has(key) || key === 'source'))
37
+ return inCode(x);
38
+ return x;
39
+ }
40
+ if (Array.isArray(x))
41
+ return x.map((y) => walk(y, key));
42
+ if (x && typeof x === 'object') {
43
+ // A literal envelope's `expression` is its text, not code.
44
+ if (x.type === 'literal')
45
+ return x;
46
+ return Object.fromEntries(Object.entries(x).map(([k, y]) => [k, k === 'display' || k === 'ui' ? y : walk(y, k)]));
47
+ }
48
+ return x;
49
+ };
50
+ return walk(v);
51
+ }
package/dist/decompile.js CHANGED
@@ -44,6 +44,7 @@ import { readFlowGlobals } from './flow-variables.js';
44
44
  import { FLOW_TYPE_NAMES, runtimeEquivalentFlowType } from './flow-types.js';
45
45
  import { outputBackingGlobal, outputBackingName } from './flow-output-backing.js';
46
46
  import { mapJsCode } from './core/js-code-spans.js';
47
+ import { RAW_JS_FIELDS, renameInputReads } from './core/input-reads.js';
47
48
  import { VARS_READ_RE } from './core/vars-read.js';
48
49
  import { contributionPort, forwardFanOut } from './core/definition-handles.js';
49
50
  import { STICKY_NOTE_TYPE } from './core/definitionless-node-types.js';
@@ -2485,6 +2486,14 @@ function region(cursor, stop, scope, ipdom, ctx, refInto) {
2485
2486
  flagDropped(node, ctx, segs);
2486
2487
  return segs;
2487
2488
  }
2489
+ // Arms that never meet, not every one of them ending: side lists off the one port.
2490
+ const sides = stopBehind === undefined ? sideListFanOut(node, stop, scope, ctx, ipdom, refInto) : undefined;
2491
+ if (sides) {
2492
+ segs.push(...sides.segs);
2493
+ cursor = sides.cursor;
2494
+ flagDropped(node, ctx, segs);
2495
+ continue;
2496
+ }
2488
2497
  // Unstructured fan-out we can't fold — best-effort marker.
2489
2498
  // No successor is walked: leave the edges unaccounted so `flagDropped` names each.
2490
2499
  const why = stopBehind !== undefined ? terminateBehindStepWhy(stopBehind) : '';
@@ -2496,6 +2505,63 @@ function region(cursor, stop, scope, ipdom, ctx, refInto) {
2496
2505
  }
2497
2506
  return segs;
2498
2507
  }
2508
+ /**
2509
+ * A fan-out whose arms never meet and do not all end, spelled as side lists off
2510
+ * the one port: every arm but the last is `.stepToList(<port>, …)`, and the walk
2511
+ * goes on down the last arm. For instance `prep@success -> a -> End` beside
2512
+ * `prep@success -> b` (b's path left open, which the canvas and the classic CLI
2513
+ * both write) is
2514
+ *
2515
+ * ```ts
2516
+ * .step('prep', …)
2517
+ * .stepToList('success', (p) => p.step('a', …).return({}))
2518
+ * .step('b', …)
2519
+ * ```
2520
+ *
2521
+ * which serialize writes back as the same two edges out of `prep@success`: a
2522
+ * side list leaves from the port the main path also continues from, and under
2523
+ * `.openTails()` (which decompile always emits) neither path gains an End.
2524
+ * There is no join to lose: the file has none, and `.parallel(...)` would add
2525
+ * one (a Merge waits for every arm, which this flow never did). An arm that
2526
+ * does reach a step of the last arm's path ends in `.stepToRef(...)`, the edge
2527
+ * the file has.
2528
+ *
2529
+ * `undefined`, so the caller keeps its marker, when the port has more than two
2530
+ * edges (a port takes one side list), when the edges leave more than one port, from a human task (whose ports a side list may not rewire), when
2531
+ * an arm goes straight into the enclosing loop's handle, or when an arm would
2532
+ * walk past the region's `stop` the last arm does not reach (the enclosing
2533
+ * construct emits that node).
2534
+ */
2535
+ function sideListFanOut(node, stop, scope, ctx, ipdom, refInto) {
2536
+ const edges = scopeSuccEdges(ctx.graph, node.id, scope);
2537
+ // Exactly two: a port takes one side list (PORT_ALREADY_ROUTED), so a third arm
2538
+ // has nowhere to go and the fan-out keeps the marker.
2539
+ if (edges.length !== 2)
2540
+ return undefined;
2541
+ const port = edges[0].sourcePort;
2542
+ if (edges.some((e) => e.sourcePort !== port) || ctx.graph.primaryOutcomePort(node.id) !== undefined)
2543
+ return undefined;
2544
+ const main = edges[edges.length - 1];
2545
+ const mainReach = forwardReach([main.targetNodeId], scope, ctx.graph);
2546
+ for (const e of edges.slice(0, -1)) {
2547
+ // An arm straight into the enclosing container's handle is no side list.
2548
+ if (e.targetNodeId === ctx.breakInto)
2549
+ return undefined;
2550
+ const reach = forwardReach([e.targetNodeId], scope, ctx.graph);
2551
+ if (stop !== EXIT && reach.has(stop) && !mainReach.has(stop))
2552
+ return undefined;
2553
+ }
2554
+ // A side path may also hand control back to what the enclosing side path rejoins.
2555
+ const into = new Set([...mainReach, ...(refInto ?? [])]);
2556
+ const segs = [];
2557
+ for (const e of edges.slice(0, -1)) {
2558
+ const body = edgeRegion(e, EXIT, scope, ipdom, ctx, into);
2559
+ if (body.length === 0)
2560
+ return undefined;
2561
+ segs.push(`.stepToList(${tsLiteral(port)}, ${armCb('p', body)})`);
2562
+ }
2563
+ return { segs, cursor: follow(ctx.graph, node.id, main.targetNodeId) };
2564
+ }
2499
2565
  /** A branch/switch node's arm labels (the designer edge text), when non-default. */
2500
2566
  function armLabels(node) {
2501
2567
  const i = node.inputs ?? {};
@@ -3063,16 +3129,6 @@ function canonicalJson(v) {
3063
3129
  }
3064
3130
  return JSON.stringify(v);
3065
3131
  }
3066
- /**
3067
- * The wire fields whose plain-string value is JavaScript (no `=js:` prefix):
3068
- * a script body, a decision or switch `expression`, a loop's `condition` and
3069
- * `completionCondition`, a `conditionExpression` an older compile wrote bare, a transform's
3070
- * `collection`. `serialize` renames `$vars` reads in exactly these and in
3071
- * `=js:` values. A loop's `completionCondition` is listed for files written
3072
- * before #1763: the SDK now writes it as a jsExpression envelope, because the
3073
- * runtime ignores the bare string.
3074
- */
3075
- const RAW_JS_FIELDS = new Set(['script', 'expression', 'condition', 'completionCondition', 'conditionExpression', 'collection']);
3076
3132
  /**
3077
3133
  * Every `$vars.<from>` read (the whole root, not a prefix of a longer one) in
3078
3134
  * `v`'s code, read as `$vars.<to>`. Code is a `=js:` wire value, a plain
@@ -3200,38 +3256,6 @@ function bindProcessInputReads(flow) {
3200
3256
  out = { ...out, nodes: rewritten, variables: { ...out.variables, ...(updates !== undefined ? { variableUpdates: updates } : {}) } };
3201
3257
  return out;
3202
3258
  }
3203
- /**
3204
- * `renameVarRoot`, held to the slots that hold code: a `=js:` value anywhere,
3205
- * and a value under a `RAW_JS_FIELDS` key or an output's `source`. A label, a
3206
- * description or any other text that happens to start `$vars.` is data, and so
3207
- * is a literal envelope and everything under a node's `display` and `ui`.
3208
- */
3209
- function renameInputReads(v, from, to) {
3210
- const re = new RegExp(`\\$vars\\.${escapeRegExp(from)}(?![A-Za-z0-9_$])`, 'g');
3211
- // a function: `$&` in `to` is data
3212
- const inCode = (js) => mapJsCode(js, (code) => code.replace(re, () => `$vars.${to}`));
3213
- const walk = (x, key) => {
3214
- if (typeof x === 'string') {
3215
- if (!x.includes(`$vars.${from}`))
3216
- return x;
3217
- if (x.startsWith('=js:'))
3218
- return '=js:' + inCode(x.slice(4));
3219
- if (key !== undefined && (RAW_JS_FIELDS.has(key) || key === 'source'))
3220
- return inCode(x);
3221
- return x;
3222
- }
3223
- if (Array.isArray(x))
3224
- return x.map((y) => walk(y, key));
3225
- if (x && typeof x === 'object') {
3226
- // A literal envelope's `expression` is its text, not code.
3227
- if (x.type === 'literal')
3228
- return x;
3229
- return Object.fromEntries(Object.entries(x).map(([k, y]) => [k, k === 'display' || k === 'ui' ? y : walk(y, k)]));
3230
- }
3231
- return x;
3232
- };
3233
- return walk(v);
3234
- }
3235
3259
  export function decompile(flow, options = {}) {
3236
3260
  flow = bindProcessInputReads(foldOutputBacking(flow));
3237
3261
  runScripts = options.scripts ?? defaultScripts();
@@ -0,0 +1,3 @@
1
+ import type { AnyFlow } from './edit-scope.js';
2
+ /** Move the edit's trigger-path reads of the file's process-level inputs back to `$vars.<name>`, in place. */
3
+ export declare function keepProcessInputReads(result: AnyFlow, original: AnyFlow, edited: AnyFlow): void;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * An edit's reads of a process-level flow input, in the file's spelling.
3
+ *
4
+ * Short version: a file can declare a flow input with no `triggerNodeId` (a
5
+ * "process-level" input) and read it bare, as `$vars.n`. The SDK source has no
6
+ * spelling for that, so decompile moves every read to the trigger's output,
7
+ * `$vars.start.output.n` (`bindProcessInputReads`), and compile stamps
8
+ * `triggerNodeId: "start"` on the input to match. Merge keeps the original's
9
+ * input as it was (the author did not change it), so the read an edit brought
10
+ * back must move back too:
11
+ *
12
+ * ```
13
+ * original "version": "=js:$vars.version" input: no triggerNodeId
14
+ * edited "version": "=js:($vars.start.output.version)" input: triggerNodeId "start"
15
+ * merged "version": "=js:($vars.version)" input: no triggerNodeId (kept)
16
+ * ```
17
+ *
18
+ * Left at the trigger path, the merged read resolves to null at run time: the
19
+ * trigger's output carries only the inputs bound to it (`flow validate` warns
20
+ * "read via `$vars.start.output.version`, but it has no triggerNodeId").
21
+ *
22
+ * Only text merge took from the edit is rewritten: an added node, or the
23
+ * values of an edited node and of a variable-update list that differ from the
24
+ * original's. Whatever the original wrote stays as written. Root scope only: a
25
+ * subflow is either the original's whole or the edited compile's whole, its
26
+ * inputs included, and both agree with themselves.
27
+ */
28
+ import { renameInputReads } from './core/input-reads.js';
29
+ import { isRecord } from './core/node-envelope.js';
30
+ import { stableJson } from './merge-variables.js';
31
+ /** `[trigger path, bare name]` per input the merged file keeps process-level and the edited compile bound to a trigger. */
32
+ function respelled(result, edited) {
33
+ const globalsOf = (f) => {
34
+ const g = f.variables?.globals;
35
+ return Array.isArray(g) ? g.filter(isRecord) : [];
36
+ };
37
+ const nodeIds = new Set((result.nodes ?? []).map((n) => n.id));
38
+ const bound = new Map(globalsOf(edited)
39
+ .filter((g) => g.direction === 'in' && typeof g.id === 'string' && typeof g.triggerNodeId === 'string' && g.triggerNodeId !== '')
40
+ .map((g) => [g.id, g.triggerNodeId]));
41
+ const out = [];
42
+ for (const g of globalsOf(result)) {
43
+ if (g.direction !== 'in' || typeof g.id !== 'string' || g.id === '' || nodeIds.has(g.id))
44
+ continue;
45
+ if (typeof g.triggerNodeId === 'string' && g.triggerNodeId !== '')
46
+ continue;
47
+ const trigger = bound.get(g.id);
48
+ if (trigger !== undefined)
49
+ out.push([`${trigger}.output.${g.id}`, g.id]);
50
+ }
51
+ return out;
52
+ }
53
+ /**
54
+ * `merged` with `rename` applied to the parts that differ from `orig`, keyed
55
+ * as `renameInputReads` keys its code slots. A literal envelope, a `display`
56
+ * and a `ui` are data, as there.
57
+ */
58
+ function inChangedParts(merged, orig, rename, key) {
59
+ if (stableJson(merged) === stableJson(orig))
60
+ return merged;
61
+ const atKey = (v) => (key === undefined ? rename(v) : rename({ [key]: v })[key]);
62
+ if (Array.isArray(merged) && Array.isArray(orig) && merged.length === orig.length) {
63
+ return merged.map((x, i) => inChangedParts(x, orig[i], rename, key));
64
+ }
65
+ if (isRecord(merged) && isRecord(orig) && merged.type !== 'literal' && !Array.isArray(merged) && !Array.isArray(orig)) {
66
+ return Object.fromEntries(Object.entries(merged).map(([k, v]) => [k,
67
+ k === 'display' || k === 'ui' ? v : inChangedParts(v, orig[k], rename, k)]));
68
+ }
69
+ return atKey(merged);
70
+ }
71
+ /** Move the edit's trigger-path reads of the file's process-level inputs back to `$vars.<name>`, in place. */
72
+ export function keepProcessInputReads(result, original, edited) {
73
+ const pairs = respelled(result, edited);
74
+ if (pairs.length === 0)
75
+ return;
76
+ const rename = (v) => pairs.reduce((x, [from, to]) => renameInputReads(x, from, to), v);
77
+ const origNodes = new Map((original.nodes ?? []).map((n) => [n.id, n]));
78
+ result.nodes = (result.nodes ?? []).map((n) => inChangedParts(n, origNodes.get(n.id), rename));
79
+ const vars = result.variables;
80
+ const updates = vars?.variableUpdates;
81
+ if (!isRecord(updates))
82
+ return;
83
+ const origUpdates = original.variables?.variableUpdates;
84
+ const before = isRecord(origUpdates) ? origUpdates : {};
85
+ vars.variableUpdates = Object.fromEntries(Object.entries(updates).map(([id, rows]) => [id, inChangedParts(rows, before[id], rename)]));
86
+ }
@@ -23,4 +23,39 @@ export declare function mergeVariables(original: Json, edited: Json, baseline: {
23
23
  * author changed. Built from entries, so an own `__proto__` key stays a key.
24
24
  */
25
25
  export declare function mergeObject(o: Obj, b: Obj, e: Obj, inner: (o: Json, b: Json, e: Json) => Json): Obj;
26
+ /** The fields of a node {@link withoutReturnRespellings} reads. */
27
+ interface EndLike {
28
+ id: string;
29
+ type: string;
30
+ outputs?: unknown;
31
+ }
32
+ /**
33
+ * The merged `variables` without the update rows that only re-spell what an
34
+ * End returns, where the original End returned it without one.
35
+ *
36
+ * Studio Web returns a Variable (an `inout` global) from an End through the
37
+ * End's output mapping alone, `outputs.<id>.source`, with no variable update.
38
+ * Compile writes a `.return({ items: … })` of a Variable as that mapping AND an
39
+ * update row with the same expression, and decompile reads either spelling as
40
+ * the same `.return`. So when the author edits what an End returns, the row is
41
+ * compile's spelling of the edit, not a second edit, and a file whose End had
42
+ * none keeps none.
43
+ *
44
+ * Example, the author changes what End `end` returns for Variable `items`:
45
+ *
46
+ * original end.outputs.items.source = $vars.items no rows
47
+ * edited end.outputs.items.source = ($vars.items) ?? null end: [items = ($vars.items) ?? null]
48
+ * merged end.outputs.items.source = ($vars.items) ?? null no rows
49
+ *
50
+ * A row is dropped only when all hold: the node is an End (or Terminate: a node
51
+ * whose `outputs.<id>.source` is its return mapping, `isOutputMappingNode`) the original has;
52
+ * the variable is a Variable; the row's expression is the End's mapping for it;
53
+ * and the original End wrote no row for it. A row for an Output, for a name
54
+ * that is no global, or with another expression is the author's (or the
55
+ * original's) and stays.
56
+ */
57
+ export declare function withoutReturnRespellings(variables: Json, nodes: readonly EndLike[], original: {
58
+ nodes?: readonly EndLike[];
59
+ variables?: Json;
60
+ }): Json;
26
61
  export {};
@@ -42,6 +42,7 @@
42
42
  */
43
43
  import { jsonClone } from './core/json-clone.js';
44
44
  import { CONTAINER_KEYS } from './flow-variables.js';
45
+ import { isOutputMappingNode } from './migrate.js';
45
46
  /** `jsonClone`, which also passes `undefined` (an absent section or key) through. */
46
47
  const copy = (v) => (v === undefined ? v : jsonClone(v));
47
48
  const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
@@ -368,3 +369,76 @@ function boundToGoneNode(entry, goneNodeIds) {
368
369
  const nodeId = isObj(entry.binding) ? entry.binding.nodeId : undefined;
369
370
  return typeof nodeId === 'string' && goneNodeIds.has(nodeId);
370
371
  }
372
+ /** An expression's text in either End spelling, `"=js: x"` or `{ type: 'jsExpression', expression: 'x' }`. */
373
+ function jsBody(v) {
374
+ if (typeof v === 'string')
375
+ return v.startsWith('=js:') ? v.slice(4).trim() : undefined;
376
+ return isObj(v) && v.type === 'jsExpression' && typeof v.expression === 'string' ? v.expression.trim() : undefined;
377
+ }
378
+ /**
379
+ * The merged `variables` without the update rows that only re-spell what an
380
+ * End returns, where the original End returned it without one.
381
+ *
382
+ * Studio Web returns a Variable (an `inout` global) from an End through the
383
+ * End's output mapping alone, `outputs.<id>.source`, with no variable update.
384
+ * Compile writes a `.return({ items: … })` of a Variable as that mapping AND an
385
+ * update row with the same expression, and decompile reads either spelling as
386
+ * the same `.return`. So when the author edits what an End returns, the row is
387
+ * compile's spelling of the edit, not a second edit, and a file whose End had
388
+ * none keeps none.
389
+ *
390
+ * Example, the author changes what End `end` returns for Variable `items`:
391
+ *
392
+ * original end.outputs.items.source = $vars.items no rows
393
+ * edited end.outputs.items.source = ($vars.items) ?? null end: [items = ($vars.items) ?? null]
394
+ * merged end.outputs.items.source = ($vars.items) ?? null no rows
395
+ *
396
+ * A row is dropped only when all hold: the node is an End (or Terminate: a node
397
+ * whose `outputs.<id>.source` is its return mapping, `isOutputMappingNode`) the original has;
398
+ * the variable is a Variable; the row's expression is the End's mapping for it;
399
+ * and the original End wrote no row for it. A row for an Output, for a name
400
+ * that is no global, or with another expression is the author's (or the
401
+ * original's) and stays.
402
+ */
403
+ export function withoutReturnRespellings(variables, nodes, original) {
404
+ if (!isObj(variables) || !isObj(variables.variableUpdates))
405
+ return variables;
406
+ const updates = variables.variableUpdates;
407
+ const globals = Array.isArray(variables.globals) ? variables.globals : [];
408
+ const isVariable = (id) => globals.some((g) => isObj(g) && g.id === id && g.direction === 'inout');
409
+ const origEnds = new Set((original.nodes ?? []).filter((n) => isOutputMappingNode(n.type)).map((n) => n.id));
410
+ const origUpdates = isObj(original.variables) && isObj(original.variables.variableUpdates) ? original.variables.variableUpdates : {};
411
+ // Collected as entries and built with Object.fromEntries: a node id such as
412
+ // `__proto__` assigned onto a plain object would hit the prototype setter
413
+ // and vanish from the result.
414
+ const out = [];
415
+ let changed = false;
416
+ for (const [nodeId, rows] of Object.entries(updates)) {
417
+ const end = nodes.find((n) => n.id === nodeId && isOutputMappingNode(n.type));
418
+ if (!end || !origEnds.has(nodeId) || !Array.isArray(rows)) {
419
+ out.push([nodeId, rows]);
420
+ continue;
421
+ }
422
+ const origRows = has(origUpdates, nodeId) && Array.isArray(origUpdates[nodeId]) ? origUpdates[nodeId] : [];
423
+ const kept = rows.filter((r) => {
424
+ if (!isObj(r) || typeof r.variableId !== 'string')
425
+ return true;
426
+ const id = r.variableId;
427
+ if (!isVariable(id) || origRows.some((x) => isObj(x) && x.variableId === id))
428
+ return true;
429
+ const body = jsBody(r.expression);
430
+ const mapping = isObj(end.outputs) && isObj(end.outputs[id]) ? end.outputs[id].source : undefined;
431
+ return body === undefined || body !== jsBody(mapping);
432
+ });
433
+ if (kept.length !== rows.length)
434
+ changed = true;
435
+ if (kept.length)
436
+ out.push([nodeId, kept]);
437
+ }
438
+ if (!changed)
439
+ return variables;
440
+ // An original with no `variableUpdates` key keeps none when nothing is left.
441
+ if (out.length || (isObj(original.variables) && has(original.variables, 'variableUpdates')))
442
+ return { ...variables, variableUpdates: Object.fromEntries(out) };
443
+ return Object.fromEntries(Object.entries(variables).filter(([k]) => k !== 'variableUpdates'));
444
+ }
package/dist/merge.js CHANGED
@@ -104,7 +104,8 @@ import { MergeRefusedError, mergedFileFindings, roundTripFindings } from './merg
104
104
  import { placeAddedNodes, stripPlaceholderFlag, unplacedRule } from './node-placement.js';
105
105
  import { mergeAgentSidecars } from './merge-sidecars.js';
106
106
  import { embeddedAgentFindings, isEmbeddedAgent, mergeEmbeddedAgentNode } from './merge-embedded-agent.js';
107
- import { mergeObject, mergeVariables, stableJson } from './merge-variables.js';
107
+ import { mergeObject, mergeVariables, stableJson, withoutReturnRespellings } from './merge-variables.js';
108
+ import { keepProcessInputReads } from './merge-process-inputs.js';
108
109
  import { replaceSupersededOutputs } from './merge-superseded-outputs.js';
109
110
  import { restoredConnectionMessage, withOriginalConnectionLabels } from './merge-baseline-connections.js';
110
111
  import { byId, isKept, nodeUnchanged, subflowsTakenFromEdited } from './edit-scope.js';
@@ -584,11 +585,14 @@ function mergeFlowFindings(original, edited, options) {
584
585
  if (layoutNodes)
585
586
  for (const id of goneNodeIds)
586
587
  delete layoutNodes[id];
587
- const variables = mergeVariables(original.variables, edited.variables, options.baseline, goneNodeIds);
588
+ const variables = withoutReturnRespellings(mergeVariables(original.variables, edited.variables, options.baseline, goneNodeIds), finalNodes, original);
588
589
  if (variables === undefined)
589
590
  delete result.variables;
590
591
  else
591
592
  result.variables = variables;
593
+ // An edit's reads of an input the file keeps process-level, back in the file's
594
+ // spelling: decompile moved them to the trigger's output (merge-process-inputs.ts).
595
+ keepProcessInputReads(result, original, edited);
592
596
  // ── Edges: the edited graph's edges define the wiring, under the edited
593
597
  // file's own ids. compile draws every edge id — root AND subflows — from
594
598
  // one file-wide counter, so they are already unique. Renumbering the root
package/dist/migrate.d.ts CHANGED
@@ -13,3 +13,39 @@ export declare function migrateToSchemaVersion(flow: any, target?: string): void
13
13
  * now — the rename is the point, and callers that pass no target are unchanged.
14
14
  */
15
15
  export declare function migrateTo16(flow: any): void;
16
+ /**
17
+ * Whether `type` is a node whose `outputs.<varId>.source` is an output MAPPING the
18
+ * author edits: the value assigned to a flow output variable when the run
19
+ * ends there. Only these keep the envelope on their output sources.
20
+ *
21
+ * **Why every other node's output `source` stays a plain string (MST-17759).**
22
+ * On a non-End node, `outputs.<k>.source` is the node type's own projection of
23
+ * its runtime result (`"=result.response"`, `"=Error"`), copied from the
24
+ * manifest's `outputDefinition`. The designer writes it as that plain string
25
+ * and never edits it: the manifest mappers spell it so
26
+ * (flow-workbench `packages/flow-core/src/manifest/mappers/connector.ts:317`,
27
+ * `data/queue-factory.ts:250`), and a designer-saved 1.9 file carries strings
28
+ * on every such node. The VS Code Maestro editor reads it as a string —
29
+ * `cleanSourceExpression(source)` calls `source.startsWith('=')`
30
+ * (`packages/canvas/src/utils/execution-data-transformer.ts:149`) — so the
31
+ * envelope this module used to write there crashed debug with
32
+ * `e.startsWith is not a function`.
33
+ *
34
+ * The envelope came from copying the OUTPUT of the platform's 1.2→1.3 file
35
+ * migration (`packages/migrations/src/migrations/v1.2-to-v1.3.ts`). Its doc
36
+ * comment scopes output wrapping to "End-node output mappings", but its loop
37
+ * wraps every node, so a migrated file is not the shape the designer writes.
38
+ *
39
+ * **Why End-type mappings keep the envelope.** The designer's End-node editor
40
+ * writes one. Each mapping row is bound to `outputs.<varId>.source`
41
+ * (`packages/canvas/src/components/properties-panel/contributors/end-node.ts:24`)
42
+ * and rendered by the expression `CodeEditorField`, whose default
43
+ * `valueFormat: 'expressionValue'` emits `{ type, expression, fieldType }` on
44
+ * every edit (`CodeEditorField.tsx:318-321`, `:786`); the End contributor sets
45
+ * no other `valueFormat`. Convert-to-subflow writes the same shape into the
46
+ * subflow's End nodes (`packages/canvas/src/utils/subflows/convert-to-subflow.ts:649-654`).
47
+ * flow-schema's `isEndNodeType` also counts `core.control.response`
48
+ * (`packages/flow-schema/src/validation/rules/helpers.ts:99`); the SDK does
49
+ * not emit that node, so it is not listed here.
50
+ */
51
+ export declare function isOutputMappingNode(type: unknown): boolean;
package/dist/migrate.js CHANGED
@@ -213,7 +213,7 @@ export function migrateTo16(flow) {
213
213
  * (`packages/flow-schema/src/validation/rules/helpers.ts:99`); the SDK does
214
214
  * not emit that node, so it is not listed here.
215
215
  */
216
- function isOutputMappingNode(type) {
216
+ export function isOutputMappingNode(type) {
217
217
  return type === 'core.control.end' || type === 'core.logic.terminate';
218
218
  }
219
219
  function wrapDynamicValues(flow) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.124.3",
3
+ "version": "6.124.5",
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",
@@ -127,5 +127,5 @@
127
127
  "@types/node": "^22.7.0",
128
128
  "esbuild": "^0.28.1"
129
129
  },
130
- "gitref": "5d3f82361ea40fb54a8397cac501a1e667934a78"
130
+ "gitref": "687f11905701ce1242f9d5e529882f9254529592"
131
131
  }