@uipath/maestro-builder-sdk 6.124.3 → 6.124.4
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/core/input-reads.d.ts +18 -0
- package/dist/core/input-reads.js +51 -0
- package/dist/decompile.js +1 -42
- package/dist/merge-process-inputs.d.ts +3 -0
- package/dist/merge-process-inputs.js +86 -0
- package/dist/merge.js +4 -0
- package/package.json +2 -2
|
@@ -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';
|
|
@@ -3063,16 +3064,6 @@ function canonicalJson(v) {
|
|
|
3063
3064
|
}
|
|
3064
3065
|
return JSON.stringify(v);
|
|
3065
3066
|
}
|
|
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
3067
|
/**
|
|
3077
3068
|
* Every `$vars.<from>` read (the whole root, not a prefix of a longer one) in
|
|
3078
3069
|
* `v`'s code, read as `$vars.<to>`. Code is a `=js:` wire value, a plain
|
|
@@ -3200,38 +3191,6 @@ function bindProcessInputReads(flow) {
|
|
|
3200
3191
|
out = { ...out, nodes: rewritten, variables: { ...out.variables, ...(updates !== undefined ? { variableUpdates: updates } : {}) } };
|
|
3201
3192
|
return out;
|
|
3202
3193
|
}
|
|
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
3194
|
export function decompile(flow, options = {}) {
|
|
3236
3195
|
flow = bindProcessInputReads(foldOutputBacking(flow));
|
|
3237
3196
|
runScripts = options.scripts ?? defaultScripts();
|
|
@@ -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
|
+
}
|
package/dist/merge.js
CHANGED
|
@@ -105,6 +105,7 @@ import { placeAddedNodes, stripPlaceholderFlag, unplacedRule } from './node-plac
|
|
|
105
105
|
import { mergeAgentSidecars } from './merge-sidecars.js';
|
|
106
106
|
import { embeddedAgentFindings, isEmbeddedAgent, mergeEmbeddedAgentNode } from './merge-embedded-agent.js';
|
|
107
107
|
import { mergeObject, mergeVariables, stableJson } 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';
|
|
@@ -589,6 +590,9 @@ function mergeFlowFindings(original, edited, options) {
|
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.124.
|
|
3
|
+
"version": "6.124.4",
|
|
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": "
|
|
130
|
+
"gitref": "01e5f01259040b55ae22a4a59762834dfc0ea2e4"
|
|
131
131
|
}
|