@uipath/maestro-builder-sdk 6.86.12 → 6.86.14
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/case/case-expr-check.d.ts +6 -0
- package/dist/case/case-expr-check.js +9 -1
- package/dist/case/decompile.js +87 -14
- package/dist/case/preserve.d.ts +10 -2
- package/dist/case/preserve.js +20 -1
- package/dist/case/resource-wire.d.ts +12 -1
- package/dist/case/resource-wire.js +19 -4
- package/dist/case/serialize.js +59 -5
- package/package.json +2 -2
|
@@ -22,6 +22,12 @@ import type { BuiltCase } from './case-sdk.js';
|
|
|
22
22
|
export interface CaseLocatedDiagnostic extends ExprDiagnostic {
|
|
23
23
|
where: string;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The platform variable that says whether the stage labelled `label` has run
|
|
27
|
+
* (case-schema `baseLocalStageHasRunVariableInfoForStage`): `Stage 1` ->
|
|
28
|
+
* `stageHasRun_Stage_1`. Exported for the Case fuzzer's stage renames.
|
|
29
|
+
*/
|
|
30
|
+
export declare function stageHasRunVariable(label: string): string;
|
|
25
31
|
/** Every first-level expression problem in a built case, each stamped with its location. */
|
|
26
32
|
export declare function checkCaseExpressions(built: BuiltCase): CaseLocatedDiagnostic[];
|
|
27
33
|
/**
|
|
@@ -123,6 +123,14 @@ function platformIdentifier(identifier) {
|
|
|
123
123
|
return identifier;
|
|
124
124
|
return segments.some((s) => !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)) ? identifier.replace(/[^a-zA-Z0-9_]/g, '_') : identifier;
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* The platform variable that says whether the stage labelled `label` has run
|
|
128
|
+
* (case-schema `baseLocalStageHasRunVariableInfoForStage`): `Stage 1` ->
|
|
129
|
+
* `stageHasRun_Stage_1`. Exported for the Case fuzzer's stage renames.
|
|
130
|
+
*/
|
|
131
|
+
export function stageHasRunVariable(label) {
|
|
132
|
+
return `stageHasRun_${platformIdentifier(label)}`;
|
|
133
|
+
}
|
|
126
134
|
/**
|
|
127
135
|
* Variables the platform declares for every case, which a plan's gates may read
|
|
128
136
|
* though no row of the plan declares them. `uip maestro case validate` adds the
|
|
@@ -141,7 +149,7 @@ function platformIdentifier(identifier) {
|
|
|
141
149
|
*/
|
|
142
150
|
function platformVariables(built) {
|
|
143
151
|
return [
|
|
144
|
-
...built.stages.map((s) =>
|
|
152
|
+
...built.stages.map((s) => stageHasRunVariable(s.label)),
|
|
145
153
|
'tasksEventSubprocessResponse',
|
|
146
154
|
'mainEventSubprocessResponse',
|
|
147
155
|
'connectorResponse',
|
package/dist/case/decompile.js
CHANGED
|
@@ -119,6 +119,7 @@ function buildRefs(plan, library, diagnostics) {
|
|
|
119
119
|
slaNameById: new Map(),
|
|
120
120
|
escalationNameById: new Map(),
|
|
121
121
|
bindingById: new Map(),
|
|
122
|
+
varKeyById: variableKeys(plan),
|
|
122
123
|
library,
|
|
123
124
|
diagnostics,
|
|
124
125
|
};
|
|
@@ -142,6 +143,44 @@ function buildRefs(plan, library, diagnostics) {
|
|
|
142
143
|
addSlaRefs(plan.metadata?.slaRules, refs, seenSlaIds);
|
|
143
144
|
return refs;
|
|
144
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* The key the source declares and writes each root `inputOutputs` variable
|
|
148
|
+
* by, for the variables whose `id` is not their `name`. Every reference in a
|
|
149
|
+
* plan spells the id (`=vars.lastTask`, an output's `var: 'lastTask'`); the
|
|
150
|
+
* `name` is the label the Case Designer shows (`{ id: 'lastTask', name:
|
|
151
|
+
* 'LastTask' }`).
|
|
152
|
+
*
|
|
153
|
+
* - A variable the source declares with `.var()` is declared by its id, so the
|
|
154
|
+
* gates that read it and the outputs that write it name a declared variable.
|
|
155
|
+
* Compile puts the Designer's name back from the identity payload
|
|
156
|
+
* (`{ name: 'LastTask', id: 'lastTask' }`).
|
|
157
|
+
* - An In- or Out-arg's companion row is declared by `.input()` / `.output()`
|
|
158
|
+
* under the argument's name, which callers see, so it keeps the name; compile
|
|
159
|
+
* renames the rows that write it to the carried id.
|
|
160
|
+
*
|
|
161
|
+
* Only an id that no other variable is named and no other row has is used as
|
|
162
|
+
* a key; any other variable keeps its name.
|
|
163
|
+
*/
|
|
164
|
+
function variableKeys(plan) {
|
|
165
|
+
const variables = plan.variables ?? {};
|
|
166
|
+
const rows = variables.inputOutputs ?? [];
|
|
167
|
+
const args = new Set([...(variables.inputs ?? []), ...(variables.outputs ?? [])].map((entry) => entry.name));
|
|
168
|
+
const count = (values, value) => values.filter((v) => v === value).length;
|
|
169
|
+
const ids = rows.map((row) => row.id);
|
|
170
|
+
const names = rows.map((row) => row.name);
|
|
171
|
+
const keys = new Map();
|
|
172
|
+
for (const row of rows) {
|
|
173
|
+
if (typeof row.id !== 'string' || typeof row.name !== 'string' || row.id === row.name)
|
|
174
|
+
continue;
|
|
175
|
+
if (args.has(row.name)) {
|
|
176
|
+
if (count(names, row.name) === 1)
|
|
177
|
+
keys.set(row.id, row.name);
|
|
178
|
+
}
|
|
179
|
+
else if (count(ids, row.id) === 1 && !names.includes(row.id) && !args.has(row.id))
|
|
180
|
+
keys.set(row.id, row.id);
|
|
181
|
+
}
|
|
182
|
+
return keys;
|
|
183
|
+
}
|
|
145
184
|
function diagnose(refs, diagnostic) {
|
|
146
185
|
if (!refs.diagnostics)
|
|
147
186
|
throw new Error(diagnostic.message);
|
|
@@ -679,7 +718,7 @@ function actionFields(rows, side, owner) {
|
|
|
679
718
|
throw new Error(`${owner} form input "${row.name ?? '?'}" has var "${String(row.var)}", which is not its id; compile writes var as the id.`);
|
|
680
719
|
if (side === 'output' && row.var !== undefined && row.var !== row.value)
|
|
681
720
|
throw new Error(`${owner} form output "${row.name ?? '?'}" has var "${String(row.var)}" but value "${String(row.value)}"; compile writes both from value.`);
|
|
682
|
-
if (side === 'output' && row.target !== undefined && row.target !== `=${row.id ?? ''}`)
|
|
721
|
+
if (side === 'output' && row.target !== undefined && row.target !== `=${row.id ?? ''}` && outputTargetOf(row) === undefined)
|
|
683
722
|
throw new Error(`${owner} form output "${row.name ?? '?'}" has target "${String(row.target)}", which is not "=<id>"; compile writes target from the id.`);
|
|
684
723
|
// Compile writes an output's `_jsonSchema` as a copy of its `body`.
|
|
685
724
|
if (row._jsonSchema !== undefined && JSON.stringify(row._jsonSchema) !== JSON.stringify(row.body))
|
|
@@ -1288,6 +1327,26 @@ function businessRuleCall(task, refs) {
|
|
|
1288
1327
|
function isTypedInputDefault(value) {
|
|
1289
1328
|
return isTypedInputField('default', value);
|
|
1290
1329
|
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Which of its own variables an output row's `target` names, when the Designer
|
|
1332
|
+
* wrote it as something other than the row's id: `'var'` (the variable the
|
|
1333
|
+
* output writes) or `'originalVar'` (the one it wrote before a reassignment).
|
|
1334
|
+
* Compile writes `target: "=<id>"`; the row's `var` decides what the output
|
|
1335
|
+
* writes either way, so this is the Designer's spelling and is carried
|
|
1336
|
+
* (`applyPreservedIdentities` writes it back from the final ids). Example:
|
|
1337
|
+
* `{ id: 'vOwn1234', var: 'status', originalVar: 'Action', target: '=status' }`
|
|
1338
|
+
* gives `'var'`. Any other target (a routing target such as
|
|
1339
|
+
* `=orchestrator.JobAttachments`) gives `undefined`.
|
|
1340
|
+
*/
|
|
1341
|
+
function outputTargetOf(row) {
|
|
1342
|
+
if (typeof row.target !== 'string' || row.target === `=${row.id}`)
|
|
1343
|
+
return undefined;
|
|
1344
|
+
if (typeof row.var === 'string' && row.var && row.target === `=${row.var}`)
|
|
1345
|
+
return 'var';
|
|
1346
|
+
if (typeof row.originalVar === 'string' && row.originalVar && row.target === `=${row.originalVar}`)
|
|
1347
|
+
return 'originalVar';
|
|
1348
|
+
return undefined;
|
|
1349
|
+
}
|
|
1291
1350
|
/**
|
|
1292
1351
|
* Fields of a resource io row that change what the plan does and that no
|
|
1293
1352
|
* builder call writes, so decompile refuses them by name rather than carry
|
|
@@ -1305,6 +1364,8 @@ const RESOURCE_ROW_REFUSED = new Set(['renamed']);
|
|
|
1305
1364
|
* For example `{ displayName: 'echoIn', title: 'echoIn' }`.
|
|
1306
1365
|
* - `omit: ['target']`: an extract the Designer saved with no `target`
|
|
1307
1366
|
* (compile writes `target: "=<id>"` on every extract).
|
|
1367
|
+
* - `target: 'var' | 'originalVar'`: an extract whose `target` names its
|
|
1368
|
+
* variable or its original variable rather than its id (`outputTargetOf`).
|
|
1308
1369
|
*
|
|
1309
1370
|
* A custom (`{ assign }`) output has its own spelling and is not handled here.
|
|
1310
1371
|
*/
|
|
@@ -1324,10 +1385,11 @@ function resourceRowShape(task, row, side) {
|
|
|
1324
1385
|
}
|
|
1325
1386
|
// Compile writes an extract's target as `=<id>` (an own-name row's id is its
|
|
1326
1387
|
// variable, `=<var>`); any other target is behavior no builder call writes.
|
|
1327
|
-
if (side === 'outputs' && row.target !== undefined && row.target !== `=${row.id}` && row
|
|
1388
|
+
if (side === 'outputs' && row.target !== undefined && row.target !== `=${row.id}` && outputTargetOf(row) === undefined)
|
|
1328
1389
|
throw new Error(`${task.type} task "${task.displayName ?? task.id ?? '?'}" output "${row.name ?? '?'}" has unsupported target ${JSON.stringify(row.target)} (compile writes "=${row.id}").`);
|
|
1329
1390
|
const omit = side === 'outputs' && row.target === undefined ? { omit: ['target'] } : {};
|
|
1330
|
-
|
|
1391
|
+
const targetOf = side === 'outputs' ? outputTargetOf(row) : undefined;
|
|
1392
|
+
return { ...(Object.keys(fields).length ? { fields } : {}), ...omit, ...(targetOf ? { target: targetOf } : {}) };
|
|
1331
1393
|
}
|
|
1332
1394
|
/** The resource a task's carried row `fields` / `omit` describe (`typedResource`), when it has any. */
|
|
1333
1395
|
function carriedResource(task, plan) {
|
|
@@ -1352,10 +1414,14 @@ function emptyIoLists(task) {
|
|
|
1352
1414
|
const empty = ['inputs', 'outputs'].filter((side) => Array.isArray(task.data?.[side]) && task.data[side].length === 0);
|
|
1353
1415
|
return empty.length ? { emptyIo: [...empty] } : {};
|
|
1354
1416
|
}
|
|
1355
|
-
function ioArg(rows, kind, task) {
|
|
1417
|
+
function ioArg(rows, kind, task, varKeyById) {
|
|
1356
1418
|
const valueField = kind === 'inputs' ? 'value' : 'source';
|
|
1357
1419
|
const entries = rows.map((row) => {
|
|
1358
|
-
|
|
1420
|
+
// A custom output (`custom: true`) assigns its value; it reads no result field.
|
|
1421
|
+
const custom = kind === 'outputs' && row.custom === true;
|
|
1422
|
+
// It names the variable it assigns the way the source declares it
|
|
1423
|
+
// (an In-arg's companion by the argument's name; see `variableKeys`).
|
|
1424
|
+
const name = kind === 'inputs' ? row.name : custom ? (varKeyById?.get(String(row.var)) ?? row.var) : row.var;
|
|
1359
1425
|
// A stored literal that itself looks quoted is written in one more pair, so
|
|
1360
1426
|
// `.inputs()` / `{ assign }` (which strip one pair, as `sdd convert` does)
|
|
1361
1427
|
// compile it back to the same text.
|
|
@@ -1367,8 +1433,6 @@ function ioArg(rows, kind, task) {
|
|
|
1367
1433
|
throw new Error(`${String(task.type)} task "${task.displayName ?? task.id ?? '?'}" ${what} stores the literal ${JSON.stringify(stored)}, which cannot be written as ${kind === 'inputs' ? '.inputs()' : '{ assign }'} source without losing its quotes: it is wrapped in one quote and contains both \\' and \\", and the SDK reads one wrapping pair of quotes off a literal the way \`uip maestro case sdd convert\` does. Decompile refuses it rather than change the value on recompile. Edit the value in the Case Designer (drop the wrapping quotes, or one of the escaped quotes) and decompile again.`);
|
|
1368
1434
|
}
|
|
1369
1435
|
const value = tsLiteral(spelled);
|
|
1370
|
-
// A custom output (`custom: true`) assigns its value; it reads no result field.
|
|
1371
|
-
const custom = kind === 'outputs' && row.custom === true;
|
|
1372
1436
|
// An input's `required` / `default` are the resource parameter's flag and
|
|
1373
1437
|
// default value, which `.inputs()` types (`{ value, required, default }`).
|
|
1374
1438
|
const typed = (row.type && row.type !== 'string' ? `, type: ${tsLiteral(row.type)}` : '')
|
|
@@ -1396,7 +1460,7 @@ function emitTask(out, depth, task, lane, refs, library) {
|
|
|
1396
1460
|
if (outputs)
|
|
1397
1461
|
refuseUnwrittenOutputs(task, outputs);
|
|
1398
1462
|
if (outputs?.lifted.length)
|
|
1399
|
-
out.line(inner, `.outputs(${ioArg(outputs.lifted, 'outputs', task)})`);
|
|
1463
|
+
out.line(inner, `.outputs(${ioArg(outputs.lifted, 'outputs', task, refs.varKeyById)})`);
|
|
1400
1464
|
if (task.isRequired !== undefined)
|
|
1401
1465
|
out.line(inner, task.isRequired ? '.required()' : '.required(false)');
|
|
1402
1466
|
if (task.shouldRunOnlyOnce !== undefined)
|
|
@@ -1727,9 +1791,12 @@ function emitVariables(out, depth, plan, triggerNameById, triggerIsTimer) {
|
|
|
1727
1791
|
for (const output of variables.outputs ?? [])
|
|
1728
1792
|
out.line(depth, `.output({ ${key(output.name)}: ${varSpec(output)} })`);
|
|
1729
1793
|
const declaredElsewhere = new Set([...(variables.inputs ?? []), ...(variables.outputs ?? [])].map((entry) => entry.name));
|
|
1794
|
+
const keys = variableKeys(plan);
|
|
1730
1795
|
for (const variable of variables.inputOutputs ?? []) {
|
|
1731
1796
|
if (declaredElsewhere.has(variable.name) || (variable.custom && produced.has(variable.name)))
|
|
1732
1797
|
continue;
|
|
1798
|
+
// Declared by its id where that is not its name (see `variableKeys`).
|
|
1799
|
+
const declaredAs = tsLiteral(keys.get(String(variable.id)) ?? variable.name);
|
|
1733
1800
|
const body = variable.body ?? variable._jsonSchema;
|
|
1734
1801
|
const description = variableDescription(variable);
|
|
1735
1802
|
if (description !== undefined) {
|
|
@@ -1740,14 +1807,14 @@ function emitVariables(out, depth, plan, triggerNameById, triggerIsTimer) {
|
|
|
1740
1807
|
['description', tsLiteral(description)],
|
|
1741
1808
|
]);
|
|
1742
1809
|
const defaultValue = variable.default !== undefined ? `, ${tsLiteral(variable.default)}` : '';
|
|
1743
|
-
out.line(depth, `.var(${
|
|
1810
|
+
out.line(depth, `.var(${declaredAs}, ${spec}${defaultValue})`);
|
|
1744
1811
|
continue;
|
|
1745
1812
|
}
|
|
1746
1813
|
const type = variable.type === 'jsonSchema' && body !== undefined
|
|
1747
1814
|
? `jsonSchema(${tsLiteral(body)})`
|
|
1748
1815
|
: tsLiteral(variable.type);
|
|
1749
1816
|
const defaultValue = variable.default !== undefined ? `, ${tsLiteral(variable.default)}` : '';
|
|
1750
|
-
out.line(depth, `.var(${
|
|
1817
|
+
out.line(depth, `.var(${declaredAs}, ${type}${defaultValue})`);
|
|
1751
1818
|
}
|
|
1752
1819
|
}
|
|
1753
1820
|
function triggerData(node) {
|
|
@@ -2112,7 +2179,9 @@ function actionInputShape(task, row) {
|
|
|
2112
2179
|
/**
|
|
2113
2180
|
* What an action form output row has that compile would not write the same
|
|
2114
2181
|
* way: `omit` lists the fields the Designer row lacks (`target`, which compile
|
|
2115
|
-
* always writes; `_jsonSchema` beside a `body`; `elementId`),
|
|
2182
|
+
* always writes; `_jsonSchema` beside a `body`; `elementId`), `target` names
|
|
2183
|
+
* the variable a target spelled as `=<var>` or `=<originalVar>` names
|
|
2184
|
+
* (`outputTargetOf`), and `elementId`
|
|
2116
2185
|
* is carried when it names another element than the task (the converter wires
|
|
2117
2186
|
* an output to its task only on a matching `elementId`).
|
|
2118
2187
|
*/
|
|
@@ -2126,9 +2195,11 @@ function actionOutputShape(task, row) {
|
|
|
2126
2195
|
omit.push('_jsonSchema');
|
|
2127
2196
|
if (row.elementId === undefined)
|
|
2128
2197
|
omit.push('elementId');
|
|
2198
|
+
const targetOf = outputTargetOf(row);
|
|
2129
2199
|
return {
|
|
2130
2200
|
...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
|
|
2131
2201
|
...(omit.length ? { omit } : {}),
|
|
2202
|
+
...(targetOf ? { target: targetOf } : {}),
|
|
2132
2203
|
};
|
|
2133
2204
|
}
|
|
2134
2205
|
/**
|
|
@@ -2202,15 +2273,17 @@ function identityPreservation(plan) {
|
|
|
2202
2273
|
name: row.name ?? '',
|
|
2203
2274
|
...(row.id ? { id: row.id } : {}),
|
|
2204
2275
|
...customRowLabel(row, plan),
|
|
2205
|
-
// A form output's `originalVar` when the Designer spelled it as the variable, not the slot id
|
|
2206
|
-
|
|
2276
|
+
// A form output's `originalVar` when the Designer spelled it as the variable, not the slot id,
|
|
2277
|
+
// and a resource extract's when it names the variable an own-name row wrote first.
|
|
2278
|
+
...(typeof row.originalVar === 'string' && row.originalVar !== row.id
|
|
2279
|
+
&& (task.type === 'action' || (row.custom !== true && row.id !== undefined && row.id === row.var && ownEntry(TASK_KIND_METHOD, task.type)))
|
|
2207
2280
|
? { originalVar: row.originalVar } : {}),
|
|
2208
2281
|
...actionOutputShape(task, row),
|
|
2209
2282
|
...resourceRowShape(task, row, 'outputs'),
|
|
2210
2283
|
})),
|
|
2211
2284
|
...emptyIoLists(task),
|
|
2212
2285
|
...carriedResource(task, plan),
|
|
2213
|
-
...(shapes.filter((other) => other === shape(task)).length > 1 ? { fingerprint: taskFingerprint(task) } : {}),
|
|
2286
|
+
...(shapes.filter((other) => other === shape(task)).length > 1 ? { fingerprint: taskFingerprint(task, plan.bindings) } : {}),
|
|
2214
2287
|
}))),
|
|
2215
2288
|
entryConditions: (stage.data?.entryConditions ?? []).map(conditionIdentity),
|
|
2216
2289
|
exitConditions: (stage.data?.exitConditions ?? []).map(conditionIdentity),
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -188,7 +188,7 @@ interface StageIdentity {
|
|
|
188
188
|
elementId?: string;
|
|
189
189
|
fields?: Record<string, unknown>;
|
|
190
190
|
}>;
|
|
191
|
-
/** `originalVar` only when it is not the row's `id` (the serializer's own spelling). `elementId` when an action form output names another element than its task. `fields` as on an input. `omit`: the fields an action form output (`target`, `_jsonSchema`, `elementId`) or a resource extract (`target`) was saved without that compile writes. */
|
|
191
|
+
/** `originalVar` only when it is not the row's `id` (the serializer's own spelling). `elementId` when an action form output names another element than its task. `fields` as on an input. `omit`: the fields an action form output (`target`, `_jsonSchema`, `elementId`) or a resource extract (`target`) was saved without that compile writes. `target`: which of the row's variables its saved `target` names when that is not its id (`=<var>` or `=<originalVar>`; compile writes `=<id>`). */
|
|
192
192
|
/** `var` and `custom: true`: a custom row whose label (`name`) is not the name of the variable it assigns. */
|
|
193
193
|
outputs?: Array<{
|
|
194
194
|
name: string;
|
|
@@ -197,6 +197,7 @@ interface StageIdentity {
|
|
|
197
197
|
elementId?: string;
|
|
198
198
|
fields?: Record<string, unknown>;
|
|
199
199
|
omit?: string[];
|
|
200
|
+
target?: 'var' | 'originalVar';
|
|
200
201
|
var?: string;
|
|
201
202
|
custom?: true;
|
|
202
203
|
}>;
|
|
@@ -239,8 +240,15 @@ export declare const CASE_EMPTY_LISTS: readonly ["slaRules"];
|
|
|
239
240
|
* A task less its rows, its ids and every display name (a condition's defaults
|
|
240
241
|
* to its task's): what renaming it leaves alone, so a rename beside a deleted
|
|
241
242
|
* sibling of the same shape can be told from the delete.
|
|
243
|
+
*
|
|
244
|
+
* Both sides must read the task as compile writes it before the payload is
|
|
245
|
+
* applied, since `followRenames` runs on that compile. So a `=bindings.<id>`
|
|
246
|
+
* reference reads as the binding row it names, less its id (compile mints a
|
|
247
|
+
* fresh id there that the payload replaces later), and an action task's
|
|
248
|
+
* carried data fields (`PRESERVED_ACTION_DATA_KEYS`, which compile does not
|
|
249
|
+
* write) are left out.
|
|
242
250
|
*/
|
|
243
|
-
export declare function taskFingerprint(task: object): string;
|
|
251
|
+
export declare function taskFingerprint(task: object, bindings?: unknown): string;
|
|
244
252
|
interface CaseIdentityPreservation {
|
|
245
253
|
id?: string;
|
|
246
254
|
triggers?: Array<{
|
package/dist/case/preserve.js
CHANGED
|
@@ -75,11 +75,27 @@ export const CASE_EMPTY_LISTS = ['slaRules'];
|
|
|
75
75
|
* A task less its rows, its ids and every display name (a condition's defaults
|
|
76
76
|
* to its task's): what renaming it leaves alone, so a rename beside a deleted
|
|
77
77
|
* sibling of the same shape can be told from the delete.
|
|
78
|
+
*
|
|
79
|
+
* Both sides must read the task as compile writes it before the payload is
|
|
80
|
+
* applied, since `followRenames` runs on that compile. So a `=bindings.<id>`
|
|
81
|
+
* reference reads as the binding row it names, less its id (compile mints a
|
|
82
|
+
* fresh id there that the payload replaces later), and an action task's
|
|
83
|
+
* carried data fields (`PRESERVED_ACTION_DATA_KEYS`, which compile does not
|
|
84
|
+
* write) are left out.
|
|
78
85
|
*/
|
|
79
|
-
export function taskFingerprint(task) {
|
|
86
|
+
export function taskFingerprint(task, bindings = []) {
|
|
87
|
+
const rows = new Map();
|
|
88
|
+
for (const row of Array.isArray(bindings) ? bindings : [])
|
|
89
|
+
if (row && typeof row === 'object' && typeof row.id === 'string')
|
|
90
|
+
rows.set(row.id, row);
|
|
80
91
|
const canonical = (value) => {
|
|
81
92
|
if (Array.isArray(value))
|
|
82
93
|
return value.map(canonical);
|
|
94
|
+
if (typeof value === 'string') {
|
|
95
|
+
const bound = /^=bindings\.([\w-]+)$/.exec(value);
|
|
96
|
+
const row = bound ? rows.get(bound[1]) : undefined;
|
|
97
|
+
return row ? { binding: canonical(row) } : value;
|
|
98
|
+
}
|
|
83
99
|
if (!value || typeof value !== 'object')
|
|
84
100
|
return value;
|
|
85
101
|
return Object.fromEntries(Object.entries(value)
|
|
@@ -89,6 +105,9 @@ export function taskFingerprint(task) {
|
|
|
89
105
|
};
|
|
90
106
|
const { data, ...rest } = task;
|
|
91
107
|
const { inputs: _inputs, outputs: _outputs, ...fields } = data ?? {};
|
|
108
|
+
if (rest.type === 'action')
|
|
109
|
+
for (const key of PRESERVED_ACTION_DATA_KEYS)
|
|
110
|
+
delete fields[key];
|
|
92
111
|
return stableId(JSON.stringify(canonical({ ...rest, data: fields })));
|
|
93
112
|
}
|
|
94
113
|
/** The condition a preserved leaf id belongs to, as one comparable string. */
|
|
@@ -22,6 +22,16 @@ export declare function liftResourceName(value: unknown, rows: BindingRows): unk
|
|
|
22
22
|
* `solution_folder.<name>` key; the builder spells that folder
|
|
23
23
|
* `solution_folder` (resource-identity.ts).
|
|
24
24
|
* - A row with a `default` names that folder.
|
|
25
|
+
* - A row whose `default` is itself a `=bindings.<id>` reference (Studio Web
|
|
26
|
+
* chains the task's folderPath row to a second folderPath row) names what
|
|
27
|
+
* that row names, read by these same rules:
|
|
28
|
+
*
|
|
29
|
+
* { id: 'f2', resourceKey: '=bindings.f1.Billing', default: '=bindings.f1' }
|
|
30
|
+
* { id: 'f1', resourceKey: 'Billing' } -> no folder ('')
|
|
31
|
+
*
|
|
32
|
+
* The reference is never the folder itself: written into the source as
|
|
33
|
+
* `folder: '=bindings.f1'`, compile reads it as a bindings.json label, which
|
|
34
|
+
* the project has none of.
|
|
25
35
|
* - A row with no `default` (V27 Studio Web) writes its folder only in its key,
|
|
26
36
|
* `<folder>.<name>`: a key equal to the name has no folder. Any other key
|
|
27
37
|
* names no folder this can read, and the lift fails.
|
|
@@ -29,8 +39,9 @@ export declare function liftResourceName(value: unknown, rows: BindingRows): unk
|
|
|
29
39
|
* @param value - The task's `data.folderPath`.
|
|
30
40
|
* @param name - The literal the task's `data.name` lifted to.
|
|
31
41
|
* @param rows - The plan's root binding rows.
|
|
42
|
+
* @param seen - The rows already read along a chain (a cycle fails the lift).
|
|
32
43
|
*/
|
|
33
|
-
export declare function liftResourceFolder(value: unknown, name: unknown, rows: BindingRows): unknown;
|
|
44
|
+
export declare function liftResourceFolder(value: unknown, name: unknown, rows: BindingRows, seen?: ReadonlySet<string>): unknown;
|
|
34
45
|
/**
|
|
35
46
|
* The root rows a task's saved `data.name` / `data.folderPath` read, with any
|
|
36
47
|
* row they chain to (a folderPath row whose `default` or `resourceKey` is
|
|
@@ -51,6 +51,16 @@ export function liftResourceName(value, rows) {
|
|
|
51
51
|
* `solution_folder.<name>` key; the builder spells that folder
|
|
52
52
|
* `solution_folder` (resource-identity.ts).
|
|
53
53
|
* - A row with a `default` names that folder.
|
|
54
|
+
* - A row whose `default` is itself a `=bindings.<id>` reference (Studio Web
|
|
55
|
+
* chains the task's folderPath row to a second folderPath row) names what
|
|
56
|
+
* that row names, read by these same rules:
|
|
57
|
+
*
|
|
58
|
+
* { id: 'f2', resourceKey: '=bindings.f1.Billing', default: '=bindings.f1' }
|
|
59
|
+
* { id: 'f1', resourceKey: 'Billing' } -> no folder ('')
|
|
60
|
+
*
|
|
61
|
+
* The reference is never the folder itself: written into the source as
|
|
62
|
+
* `folder: '=bindings.f1'`, compile reads it as a bindings.json label, which
|
|
63
|
+
* the project has none of.
|
|
54
64
|
* - A row with no `default` (V27 Studio Web) writes its folder only in its key,
|
|
55
65
|
* `<folder>.<name>`: a key equal to the name has no folder. Any other key
|
|
56
66
|
* names no folder this can read, and the lift fails.
|
|
@@ -58,17 +68,22 @@ export function liftResourceName(value, rows) {
|
|
|
58
68
|
* @param value - The task's `data.folderPath`.
|
|
59
69
|
* @param name - The literal the task's `data.name` lifted to.
|
|
60
70
|
* @param rows - The plan's root binding rows.
|
|
71
|
+
* @param seen - The rows already read along a chain (a cycle fails the lift).
|
|
61
72
|
*/
|
|
62
|
-
export function liftResourceFolder(value, name, rows) {
|
|
73
|
+
export function liftResourceFolder(value, name, rows, seen = new Set()) {
|
|
63
74
|
const id = bindingRefId(value);
|
|
64
75
|
if (id === undefined)
|
|
65
76
|
return value;
|
|
66
|
-
const row = rows.get(id);
|
|
77
|
+
const row = seen.has(id) ? undefined : rows.get(id);
|
|
67
78
|
const key = row?.resourceKey;
|
|
68
79
|
if (typeof key === 'string' && isInSolutionKey(key))
|
|
69
80
|
return SOLUTION_FOLDER;
|
|
70
|
-
if (typeof row?.default === 'string')
|
|
71
|
-
|
|
81
|
+
if (typeof row?.default === 'string') {
|
|
82
|
+
if (bindingRefId(row.default) === undefined)
|
|
83
|
+
return row.default;
|
|
84
|
+
const next = liftResourceFolder(row.default, name, rows, new Set([...seen, id]));
|
|
85
|
+
return isLiftFailure(next) ? { field: 'folderPath', value: value, id, row } : next;
|
|
86
|
+
}
|
|
72
87
|
if (row && typeof key === 'string' && typeof name === 'string' && name) {
|
|
73
88
|
if (key === name)
|
|
74
89
|
return '';
|
package/dist/case/serialize.js
CHANGED
|
@@ -1117,6 +1117,13 @@ export function followRenames(result, preservation) {
|
|
|
1117
1117
|
claimed.add(to[0].task);
|
|
1118
1118
|
}
|
|
1119
1119
|
const movedTo = (label, name) => moves.get(label)?.get(name);
|
|
1120
|
+
// The binding rows this compile ends with: its own, then the carried rows
|
|
1121
|
+
// the payload appends later, so a `=bindings.<id>` reads as the row it names
|
|
1122
|
+
// in `taskFingerprint` on both sides.
|
|
1123
|
+
const boundRows = [
|
|
1124
|
+
...(Array.isArray(result.bindings) ? result.bindings : []),
|
|
1125
|
+
...(preservation.readBindings ?? []), ...(preservation.unreadBindings ?? []), ...(preservation.bindings ?? []),
|
|
1126
|
+
];
|
|
1120
1127
|
const taskNames = new Map();
|
|
1121
1128
|
for (const side of stageSides) {
|
|
1122
1129
|
if (!side.target)
|
|
@@ -1129,7 +1136,7 @@ export function followRenames(result, preservation) {
|
|
|
1129
1136
|
// the renamed task still has wins, then the old name closest to the new one,
|
|
1130
1137
|
// then the earlier task.
|
|
1131
1138
|
const candidates = missing.flatMap((task, from) => extra.flatMap((candidate, to) => candidate.rows === rowNames(task.inputs, task.outputs)
|
|
1132
|
-
? [{ from, to, same: Number(task.fingerprint !== undefined && task.fingerprint === taskFingerprint(candidate.task)), score: nameAffinity(task.name, candidate.name) }]
|
|
1139
|
+
? [{ from, to, same: Number(task.fingerprint !== undefined && task.fingerprint === taskFingerprint(candidate.task, boundRows)), score: nameAffinity(task.name, candidate.name) }]
|
|
1133
1140
|
: []));
|
|
1134
1141
|
candidates.sort((a, b) => b.same - a.same || b.score - a.score || a.from - b.from || a.to - b.to);
|
|
1135
1142
|
const renames = new Map();
|
|
@@ -1242,6 +1249,8 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1242
1249
|
};
|
|
1243
1250
|
// Applied after `rewrite`, so a preserved row id is never itself rewritten.
|
|
1244
1251
|
const rowRenames = [];
|
|
1252
|
+
// Output `target` spellings (`carryRowShape`), applied once every row id is final.
|
|
1253
|
+
const targetSpellings = [];
|
|
1245
1254
|
const takeRow = (row, wanted, output) => {
|
|
1246
1255
|
if (!row || !wanted || typeof row.id !== 'string' || row.id === wanted)
|
|
1247
1256
|
return;
|
|
@@ -1295,7 +1304,7 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1295
1304
|
// the id renames. Example: `{ name: 'echoIn', fields: { displayName: 'echoIn',
|
|
1296
1305
|
// title: 'echoIn' } }` gives the compiled `echoIn` row both back.
|
|
1297
1306
|
const carryRowShape = (row, wanted) => {
|
|
1298
|
-
if (!row || row.name !== wanted.name || (!wanted.fields && !wanted.omit))
|
|
1307
|
+
if (!row || row.name !== wanted.name || (!wanted.fields && !wanted.omit && !wanted.target && wanted.originalVar === undefined))
|
|
1299
1308
|
return;
|
|
1300
1309
|
rowRenames.push(() => {
|
|
1301
1310
|
// A key the compiled row already has is typed (an input `required` /
|
|
@@ -1307,6 +1316,25 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1307
1316
|
if (key === 'target')
|
|
1308
1317
|
delete row.target;
|
|
1309
1318
|
});
|
|
1319
|
+
// Two Designer spellings, applied once every row id is final:
|
|
1320
|
+
// - An own-name row (`id == var`) saved with the variable it wrote before a
|
|
1321
|
+
// reassignment, `originalVar: 'firstResults'`, gets it back while it is
|
|
1322
|
+
// still own-name. Compile writes such a row with no `originalVar`, or
|
|
1323
|
+
// with its own id when a root variable shares the name (the controlled
|
|
1324
|
+
// alias); the Designer reads all three as a reassignment.
|
|
1325
|
+
// - An output whose `target` names its variable, or the one it wrote before
|
|
1326
|
+
// a reassignment, rather than its id gets that spelling back from the
|
|
1327
|
+
// row's final names: `{ var: 'status', target: '=status' }`.
|
|
1328
|
+
if (wanted.target || wanted.originalVar !== undefined) {
|
|
1329
|
+
const field = wanted.target;
|
|
1330
|
+
targetSpellings.push(() => {
|
|
1331
|
+
if (wanted.originalVar !== undefined && row.id === row.var && wanted.originalVar !== row.id
|
|
1332
|
+
&& (row.originalVar === undefined || row.originalVar === row.id))
|
|
1333
|
+
row.originalVar = wanted.originalVar;
|
|
1334
|
+
if (field && typeof row.target === 'string' && typeof row[field] === 'string' && row[field])
|
|
1335
|
+
row.target = `=${row[field]}`;
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1310
1338
|
};
|
|
1311
1339
|
// `actionRows`: the rows are an action task's form outputs, the only rows
|
|
1312
1340
|
// whose identity may omit `_jsonSchema` / `elementId` or name another
|
|
@@ -1374,8 +1402,11 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1374
1402
|
// Designer reassignment: { name: 'Action', value: 'decision' } keeps var 'decision', slot id 'action'.
|
|
1375
1403
|
if (target && typeof row.id === 'string' && NAMED_ACTION_OUTPUT_ROWS.has(target) && row.id !== target.var) {
|
|
1376
1404
|
reassignCarried(target, row.id);
|
|
1377
|
-
// The Designer's other
|
|
1378
|
-
|
|
1405
|
+
// The Designer's other spellings: `originalVar: 'decision'`, only while
|
|
1406
|
+
// the row still writes 'decision', and the field's own variable before
|
|
1407
|
+
// the reassignment, `originalVar: 'Action'`, only while the row is still
|
|
1408
|
+
// the 'Action' field.
|
|
1409
|
+
if (row.originalVar === target.var || (row.originalVar !== undefined && row.originalVar === target.name))
|
|
1379
1410
|
target.originalVar = row.originalVar;
|
|
1380
1411
|
}
|
|
1381
1412
|
else {
|
|
@@ -1520,9 +1551,21 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1520
1551
|
if (carriedCompanions.has(row?.var) && row.id === row.var && row.originalVar === undefined)
|
|
1521
1552
|
row.originalVar = row.id;
|
|
1522
1553
|
}
|
|
1554
|
+
// Variables the source declares by their id (`.var('lastTask')` for the
|
|
1555
|
+
// Designer's `{ id: 'lastTask', name: 'LastTask' }`, see decompile's
|
|
1556
|
+
// `variableKeys`) get the Designer's name back, and so does each custom row
|
|
1557
|
+
// that assigns one, which the Designer labels with the variable's name.
|
|
1558
|
+
const renamedVariables = new Map();
|
|
1523
1559
|
for (const [lane, rows] of Object.entries(identities.variables ?? {}))
|
|
1524
1560
|
(rows ?? []).forEach((row) => {
|
|
1525
|
-
|
|
1561
|
+
let variable = variables[lane]?.find((candidate) => candidate.name === row.name);
|
|
1562
|
+
if (!variable && lane === 'inputOutputs' && typeof row.id === 'string') {
|
|
1563
|
+
variable = variables[lane]?.find((candidate) => candidate.id === row.id && candidate.name === row.id);
|
|
1564
|
+
if (variable) {
|
|
1565
|
+
variable.name = row.name;
|
|
1566
|
+
renamedVariables.set(row.id, row.name);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1526
1569
|
// The Designer saved this structured variable's schema in `body` only.
|
|
1527
1570
|
if (variable && row.omit?.includes('_jsonSchema') && variable.body !== undefined)
|
|
1528
1571
|
delete variable._jsonSchema;
|
|
@@ -1530,6 +1573,10 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1530
1573
|
return;
|
|
1531
1574
|
take(variable, row.id);
|
|
1532
1575
|
});
|
|
1576
|
+
if (renamedVariables.size)
|
|
1577
|
+
for (const row of [...planOutputRows(result, stages), ...triggerOutputRows(nodes)])
|
|
1578
|
+
if (row?.custom === true && row.name === row.var && renamedVariables.has(row.var))
|
|
1579
|
+
row.name = renamedVariables.get(row.var);
|
|
1533
1580
|
const replace = idRenamer(replacements);
|
|
1534
1581
|
// Every field that carries an id GENERATED by this serialize pass has to be
|
|
1535
1582
|
// rewritten when preservation renames the node that id belongs to. Missing one
|
|
@@ -1595,6 +1642,8 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1595
1642
|
for (const rename of rowRenames)
|
|
1596
1643
|
rename();
|
|
1597
1644
|
settleOwnNameRows(result, stages, ownNameRestored, identities);
|
|
1645
|
+
for (const spell of targetSpellings)
|
|
1646
|
+
spell();
|
|
1598
1647
|
// An id hashed from a generated element id is re-minted from the preserved one,
|
|
1599
1648
|
// wherever it is spelled, including inside a `=jsonString:` configuration.
|
|
1600
1649
|
const reseeded = new Map();
|
|
@@ -2481,6 +2530,11 @@ function settleOwnNameRows(result, stages, restored, identities) {
|
|
|
2481
2530
|
if (variables.inputOutputs)
|
|
2482
2531
|
variables.inputOutputs = variables.inputOutputs.filter((entry) => !(names.has(entry?.id) && entry.custom === true && entry.elementId === 'root'));
|
|
2483
2532
|
}
|
|
2533
|
+
/** Every `outputs[]` row the plan's trigger nodes carry. */
|
|
2534
|
+
function triggerOutputRows(nodes) {
|
|
2535
|
+
return nodes.flatMap((node) => node.type === 'uipath.case.trigger' ? (node.data?.inputs?.outputs ?? [])
|
|
2536
|
+
: node.type === 'case-management:Trigger' ? (node.data?.uipath?.outputs ?? []) : []);
|
|
2537
|
+
}
|
|
2484
2538
|
/** Every `outputs[]` row a rule's wait-for-connector bag carries, across a condition list. */
|
|
2485
2539
|
function ruleOutputRows(conditions) {
|
|
2486
2540
|
const bag = CASE_FORMAT_PROFILE.waitConnectorRuleBagField;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.86.
|
|
3
|
+
"version": "6.86.14",
|
|
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",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"@types/node": "^22.7.0",
|
|
104
104
|
"esbuild": "^0.28.1"
|
|
105
105
|
},
|
|
106
|
-
"gitref": "
|
|
106
|
+
"gitref": "29d3614d87d4be34691ea2af7e41ff3a9f8c882f"
|
|
107
107
|
}
|