@uipath/maestro-builder-sdk 6.86.11 → 6.86.13
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 +125 -17
- package/dist/case/preserve.d.ts +10 -2
- package/dist/case/preserve.js +20 -1
- 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))
|
|
@@ -878,9 +917,18 @@ function legacyCamelWireName(value) {
|
|
|
878
917
|
*
|
|
879
918
|
* With `owner`, the lift is strict (the external task shape): a row that is not
|
|
880
919
|
* one of the three containers, or a container whose body is not an object, is
|
|
881
|
-
* refused. Without it,
|
|
920
|
+
* refused. Without it, a row that holds no authored value is skipped, as the
|
|
921
|
+
* connector lift always did: a container with no body, a valueless `file`
|
|
922
|
+
* row. A row that holds one and is not in the shape compile writes is refused
|
|
923
|
+
* by name (`connectorTask`), never dropped: compile would write the task
|
|
924
|
+
* without that value. Two such shapes are saved by older Designers:
|
|
925
|
+
*
|
|
926
|
+
* - one row per parameter, `{ name: 'saveAsDraft', target: 'query', value: 'false' }`,
|
|
927
|
+
* instead of the `queryParameters` container;
|
|
928
|
+
* - a container that carries its fields in `value`, `{ name: 'body', value: { … } }`,
|
|
929
|
+
* instead of `body`.
|
|
882
930
|
*/
|
|
883
|
-
function connectorInputs(slots, resolved, owner) {
|
|
931
|
+
function connectorInputs(slots, resolved, owner, task) {
|
|
884
932
|
// A carried query or path field is a parameter too, which the library's
|
|
885
933
|
// `operation.parameters` does not list.
|
|
886
934
|
const parameterNames = [
|
|
@@ -910,6 +958,16 @@ function connectorInputs(slots, resolved, owner) {
|
|
|
910
958
|
}
|
|
911
959
|
if (owner && !CONNECTOR_INPUT_CONTAINERS.has(name))
|
|
912
960
|
throw new Error(`${owner} has unsupported input row "${name}".`);
|
|
961
|
+
const who = owner ?? task ?? 'connector task';
|
|
962
|
+
if (!CONNECTOR_INPUT_CONTAINERS.has(name)) {
|
|
963
|
+
if (hasAuthoredValue(slot?.value))
|
|
964
|
+
throw new Error(`${who} has input row "${name}" (target ${JSON.stringify(slot?.target ?? null)}), an input saved as its own row; ` +
|
|
965
|
+
`decompile lifts only the pathParameters / queryParameters / body containers, so the value would be lost. ` + CONNECTOR_INPUT_REMEDY);
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
if (hasAuthoredValue(slot?.value))
|
|
969
|
+
throw new Error(`${who} input container "${name}" carries its fields in "value", not "body"; ` +
|
|
970
|
+
`decompile does not lift that shape, so the fields would be lost. ` + CONNECTOR_INPUT_REMEDY);
|
|
913
971
|
const body = slot?.body;
|
|
914
972
|
if (owner && body === undefined)
|
|
915
973
|
continue;
|
|
@@ -926,6 +984,22 @@ function connectorInputs(slots, resolved, owner) {
|
|
|
926
984
|
return inputs;
|
|
927
985
|
}
|
|
928
986
|
const CONNECTOR_INPUT_CONTAINERS = new Set(['pathParameters', 'queryParameters', 'body']);
|
|
987
|
+
/**
|
|
988
|
+
* The way out of an input shape `connectorInputs` refuses. Opening and saving
|
|
989
|
+
* the plan does not help: the platform's disk -> canvas -> disk pipeline and its
|
|
990
|
+
* migration to the latest schema keep both shapes as saved. The current
|
|
991
|
+
* Designer writes the containers when it adds a connector activity.
|
|
992
|
+
*/
|
|
993
|
+
const CONNECTOR_INPUT_REMEDY = 'Opening and saving the plan keeps this shape. In Studio Web, delete the task and add the connector activity again, ' +
|
|
994
|
+
'then decompile the saved plan.';
|
|
995
|
+
/** A saved row value that says something: not absent, `null`, `""` or `{}`. */
|
|
996
|
+
function hasAuthoredValue(value) {
|
|
997
|
+
if (value === undefined || value === null || value === '')
|
|
998
|
+
return false;
|
|
999
|
+
if (typeof value === 'object' && !Array.isArray(value))
|
|
1000
|
+
return Object.keys(value).length > 0;
|
|
1001
|
+
return true;
|
|
1002
|
+
}
|
|
929
1003
|
function connectorCall(task, refs, library) {
|
|
930
1004
|
if (!library)
|
|
931
1005
|
throw new Error(`connector task "${task.displayName ?? task.id ?? '?'}" needs the connector library; pass DecompileOptions.library or --library.`);
|
|
@@ -951,7 +1025,7 @@ function connectorCall(task, refs, library) {
|
|
|
951
1025
|
// values instead of refusing them as unknown inputs (#1362).
|
|
952
1026
|
const carried = savedFieldsMissingFromLibrary(savedConfiguration(context), fromLibrary);
|
|
953
1027
|
const resolved = withCarriedFields(fromLibrary, carried);
|
|
954
|
-
const inputs = connectorInputs(Array.isArray(data.inputs) ? data.inputs : [], resolved);
|
|
1028
|
+
const inputs = connectorInputs(Array.isArray(data.inputs) ? data.inputs : [], resolved, undefined, `connector task "${task.displayName ?? task.id ?? '?'}"`);
|
|
955
1029
|
const connection = bindingName(context.get('connection')?.value, refs);
|
|
956
1030
|
const folder = bindingName(context.get('folderKey')?.value, refs);
|
|
957
1031
|
const options = opts([
|
|
@@ -1253,6 +1327,26 @@ function businessRuleCall(task, refs) {
|
|
|
1253
1327
|
function isTypedInputDefault(value) {
|
|
1254
1328
|
return isTypedInputField('default', value);
|
|
1255
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
|
+
}
|
|
1256
1350
|
/**
|
|
1257
1351
|
* Fields of a resource io row that change what the plan does and that no
|
|
1258
1352
|
* builder call writes, so decompile refuses them by name rather than carry
|
|
@@ -1270,6 +1364,8 @@ const RESOURCE_ROW_REFUSED = new Set(['renamed']);
|
|
|
1270
1364
|
* For example `{ displayName: 'echoIn', title: 'echoIn' }`.
|
|
1271
1365
|
* - `omit: ['target']`: an extract the Designer saved with no `target`
|
|
1272
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`).
|
|
1273
1369
|
*
|
|
1274
1370
|
* A custom (`{ assign }`) output has its own spelling and is not handled here.
|
|
1275
1371
|
*/
|
|
@@ -1289,10 +1385,11 @@ function resourceRowShape(task, row, side) {
|
|
|
1289
1385
|
}
|
|
1290
1386
|
// Compile writes an extract's target as `=<id>` (an own-name row's id is its
|
|
1291
1387
|
// variable, `=<var>`); any other target is behavior no builder call writes.
|
|
1292
|
-
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)
|
|
1293
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}").`);
|
|
1294
1390
|
const omit = side === 'outputs' && row.target === undefined ? { omit: ['target'] } : {};
|
|
1295
|
-
|
|
1391
|
+
const targetOf = side === 'outputs' ? outputTargetOf(row) : undefined;
|
|
1392
|
+
return { ...(Object.keys(fields).length ? { fields } : {}), ...omit, ...(targetOf ? { target: targetOf } : {}) };
|
|
1296
1393
|
}
|
|
1297
1394
|
/** The resource a task's carried row `fields` / `omit` describe (`typedResource`), when it has any. */
|
|
1298
1395
|
function carriedResource(task, plan) {
|
|
@@ -1317,10 +1414,14 @@ function emptyIoLists(task) {
|
|
|
1317
1414
|
const empty = ['inputs', 'outputs'].filter((side) => Array.isArray(task.data?.[side]) && task.data[side].length === 0);
|
|
1318
1415
|
return empty.length ? { emptyIo: [...empty] } : {};
|
|
1319
1416
|
}
|
|
1320
|
-
function ioArg(rows, kind, task) {
|
|
1417
|
+
function ioArg(rows, kind, task, varKeyById) {
|
|
1321
1418
|
const valueField = kind === 'inputs' ? 'value' : 'source';
|
|
1322
1419
|
const entries = rows.map((row) => {
|
|
1323
|
-
|
|
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;
|
|
1324
1425
|
// A stored literal that itself looks quoted is written in one more pair, so
|
|
1325
1426
|
// `.inputs()` / `{ assign }` (which strip one pair, as `sdd convert` does)
|
|
1326
1427
|
// compile it back to the same text.
|
|
@@ -1332,8 +1433,6 @@ function ioArg(rows, kind, task) {
|
|
|
1332
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.`);
|
|
1333
1434
|
}
|
|
1334
1435
|
const value = tsLiteral(spelled);
|
|
1335
|
-
// A custom output (`custom: true`) assigns its value; it reads no result field.
|
|
1336
|
-
const custom = kind === 'outputs' && row.custom === true;
|
|
1337
1436
|
// An input's `required` / `default` are the resource parameter's flag and
|
|
1338
1437
|
// default value, which `.inputs()` types (`{ value, required, default }`).
|
|
1339
1438
|
const typed = (row.type && row.type !== 'string' ? `, type: ${tsLiteral(row.type)}` : '')
|
|
@@ -1361,7 +1460,7 @@ function emitTask(out, depth, task, lane, refs, library) {
|
|
|
1361
1460
|
if (outputs)
|
|
1362
1461
|
refuseUnwrittenOutputs(task, outputs);
|
|
1363
1462
|
if (outputs?.lifted.length)
|
|
1364
|
-
out.line(inner, `.outputs(${ioArg(outputs.lifted, 'outputs', task)})`);
|
|
1463
|
+
out.line(inner, `.outputs(${ioArg(outputs.lifted, 'outputs', task, refs.varKeyById)})`);
|
|
1365
1464
|
if (task.isRequired !== undefined)
|
|
1366
1465
|
out.line(inner, task.isRequired ? '.required()' : '.required(false)');
|
|
1367
1466
|
if (task.shouldRunOnlyOnce !== undefined)
|
|
@@ -1692,9 +1791,12 @@ function emitVariables(out, depth, plan, triggerNameById, triggerIsTimer) {
|
|
|
1692
1791
|
for (const output of variables.outputs ?? [])
|
|
1693
1792
|
out.line(depth, `.output({ ${key(output.name)}: ${varSpec(output)} })`);
|
|
1694
1793
|
const declaredElsewhere = new Set([...(variables.inputs ?? []), ...(variables.outputs ?? [])].map((entry) => entry.name));
|
|
1794
|
+
const keys = variableKeys(plan);
|
|
1695
1795
|
for (const variable of variables.inputOutputs ?? []) {
|
|
1696
1796
|
if (declaredElsewhere.has(variable.name) || (variable.custom && produced.has(variable.name)))
|
|
1697
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);
|
|
1698
1800
|
const body = variable.body ?? variable._jsonSchema;
|
|
1699
1801
|
const description = variableDescription(variable);
|
|
1700
1802
|
if (description !== undefined) {
|
|
@@ -1705,14 +1807,14 @@ function emitVariables(out, depth, plan, triggerNameById, triggerIsTimer) {
|
|
|
1705
1807
|
['description', tsLiteral(description)],
|
|
1706
1808
|
]);
|
|
1707
1809
|
const defaultValue = variable.default !== undefined ? `, ${tsLiteral(variable.default)}` : '';
|
|
1708
|
-
out.line(depth, `.var(${
|
|
1810
|
+
out.line(depth, `.var(${declaredAs}, ${spec}${defaultValue})`);
|
|
1709
1811
|
continue;
|
|
1710
1812
|
}
|
|
1711
1813
|
const type = variable.type === 'jsonSchema' && body !== undefined
|
|
1712
1814
|
? `jsonSchema(${tsLiteral(body)})`
|
|
1713
1815
|
: tsLiteral(variable.type);
|
|
1714
1816
|
const defaultValue = variable.default !== undefined ? `, ${tsLiteral(variable.default)}` : '';
|
|
1715
|
-
out.line(depth, `.var(${
|
|
1817
|
+
out.line(depth, `.var(${declaredAs}, ${type}${defaultValue})`);
|
|
1716
1818
|
}
|
|
1717
1819
|
}
|
|
1718
1820
|
function triggerData(node) {
|
|
@@ -2077,7 +2179,9 @@ function actionInputShape(task, row) {
|
|
|
2077
2179
|
/**
|
|
2078
2180
|
* What an action form output row has that compile would not write the same
|
|
2079
2181
|
* way: `omit` lists the fields the Designer row lacks (`target`, which compile
|
|
2080
|
-
* 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`
|
|
2081
2185
|
* is carried when it names another element than the task (the converter wires
|
|
2082
2186
|
* an output to its task only on a matching `elementId`).
|
|
2083
2187
|
*/
|
|
@@ -2091,9 +2195,11 @@ function actionOutputShape(task, row) {
|
|
|
2091
2195
|
omit.push('_jsonSchema');
|
|
2092
2196
|
if (row.elementId === undefined)
|
|
2093
2197
|
omit.push('elementId');
|
|
2198
|
+
const targetOf = outputTargetOf(row);
|
|
2094
2199
|
return {
|
|
2095
2200
|
...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
|
|
2096
2201
|
...(omit.length ? { omit } : {}),
|
|
2202
|
+
...(targetOf ? { target: targetOf } : {}),
|
|
2097
2203
|
};
|
|
2098
2204
|
}
|
|
2099
2205
|
/**
|
|
@@ -2167,15 +2273,17 @@ function identityPreservation(plan) {
|
|
|
2167
2273
|
name: row.name ?? '',
|
|
2168
2274
|
...(row.id ? { id: row.id } : {}),
|
|
2169
2275
|
...customRowLabel(row, plan),
|
|
2170
|
-
// A form output's `originalVar` when the Designer spelled it as the variable, not the slot id
|
|
2171
|
-
|
|
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)))
|
|
2172
2280
|
? { originalVar: row.originalVar } : {}),
|
|
2173
2281
|
...actionOutputShape(task, row),
|
|
2174
2282
|
...resourceRowShape(task, row, 'outputs'),
|
|
2175
2283
|
})),
|
|
2176
2284
|
...emptyIoLists(task),
|
|
2177
2285
|
...carriedResource(task, plan),
|
|
2178
|
-
...(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) } : {}),
|
|
2179
2287
|
}))),
|
|
2180
2288
|
entryConditions: (stage.data?.entryConditions ?? []).map(conditionIdentity),
|
|
2181
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. */
|
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.13",
|
|
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": "a9f27ba26a5984b9391ae2025df3e6c4b5a93c3c"
|
|
107
107
|
}
|