@uipath/maestro-builder-sdk 6.120.3 → 6.120.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.
- package/dist/case/connector-saved-context.d.ts +6 -0
- package/dist/case/connector-saved-context.js +32 -2
- package/dist/case/connector-saved-rows.js +7 -2
- package/dist/case/decompile.d.ts +1 -0
- package/dist/case/decompile.js +116 -21
- package/dist/case/plan-connectors.js +57 -20
- package/dist/case/preserve.d.ts +52 -1
- package/dist/case/preserve.js +11 -5
- package/dist/case/serialize.js +218 -13
- package/package.json +2 -2
|
@@ -17,6 +17,12 @@ export declare function caseConnectorOwners(plan: Record<string, any>): Array<{
|
|
|
17
17
|
key: string;
|
|
18
18
|
bag: Record<string, any>;
|
|
19
19
|
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Whether a context row named `name` counts when comparing the element
|
|
22
|
+
* compile built (`bag`) with a saved one: always, except a row in
|
|
23
|
+
* {@link ACTIVITY_SAVED_ONLY_ROWS} on an activity whose built context lacks it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function comparesContextRow(bag: Record<string, any>, name: string): boolean;
|
|
20
26
|
/**
|
|
21
27
|
* The saved context of a connector element, when it has a `metadata` row with
|
|
22
28
|
* an object body (the Designer's state) that compile could not have written
|
|
@@ -81,6 +81,34 @@ function isEmptyInput(value) {
|
|
|
81
81
|
|| (Array.isArray(value) && value.length === 0) || (isObject(value) && Object.keys(value).length === 0);
|
|
82
82
|
}
|
|
83
83
|
const EVENT_SERVICE_TYPES = new Set(['Intsvc.EventTrigger', 'Intsvc.WaitForEvent']);
|
|
84
|
+
/**
|
|
85
|
+
* Context rows an older Case Designer saves on an `execute-connector-activity`
|
|
86
|
+
* task that compile never writes there (`connectorTaskData` in serialize.ts):
|
|
87
|
+
* `operation` (`list`, `create`, `replace`, `SendEmailV2`, ...), the name of
|
|
88
|
+
* the action the task calls. On an activity it repeats what `objectName`,
|
|
89
|
+
* `method`, `path` and the metadata's activity type id already say, and no
|
|
90
|
+
* source edit can set it, so a saved row that compile's side lacks is no sign
|
|
91
|
+
* of an edit. The saved copy is then the only thing that keeps it.
|
|
92
|
+
*
|
|
93
|
+
* An event element's `operation` is different: compile writes it from the
|
|
94
|
+
* event the source names, so it is compared there as any other row.
|
|
95
|
+
*
|
|
96
|
+
* For instance, a task saved with `objectName: query`, `method: POST`,
|
|
97
|
+
* `path: /hubs/datawarehouse/query` and `operation: list` is the same element
|
|
98
|
+
* as the one compile builds with the first three rows and no `operation`.
|
|
99
|
+
*/
|
|
100
|
+
const ACTIVITY_SAVED_ONLY_ROWS = new Set(['operation']);
|
|
101
|
+
/**
|
|
102
|
+
* Whether a context row named `name` counts when comparing the element
|
|
103
|
+
* compile built (`bag`) with a saved one: always, except a row in
|
|
104
|
+
* {@link ACTIVITY_SAVED_ONLY_ROWS} on an activity whose built context lacks it.
|
|
105
|
+
*/
|
|
106
|
+
export function comparesContextRow(bag, name) {
|
|
107
|
+
if (!ACTIVITY_SAVED_ONLY_ROWS.has(name) || EVENT_SERVICE_TYPES.has(bag?.serviceType))
|
|
108
|
+
return true;
|
|
109
|
+
const built = Array.isArray(bag?.context) ? bag.context : [];
|
|
110
|
+
return built.some((row) => isObject(row) && row.name === name);
|
|
111
|
+
}
|
|
84
112
|
const JSON_STRING = '=jsonString:';
|
|
85
113
|
/** The context row a flagged-V2 plan's connector elements carry (`stampConnectorConfigVersion`). */
|
|
86
114
|
const V2_CONFIG_ROW = 'activityConfigurationVersion';
|
|
@@ -193,7 +221,9 @@ function actionIdentity(context) {
|
|
|
193
221
|
* one side only reading as no value. So adding or removing a `folderKey`
|
|
194
222
|
* row (an edit that adds or drops `folder:`) gets compile's context, while
|
|
195
223
|
* a Designer row compile never writes and that holds no value (a bare
|
|
196
|
-
* `method`) still compares equal
|
|
224
|
+
* `method`) still compares equal, and so does an activity's saved
|
|
225
|
+
* `operation` row, which compile never writes there
|
|
226
|
+
* ({@link comparesContextRow}). `connectorKey` must be on both sides;
|
|
197
227
|
* - the action is the same: the activity type id agrees, and the wire
|
|
198
228
|
* activity type is curated on both sides or generic on both, wherever both
|
|
199
229
|
* sides carry them ({@link actionIdentity}), so switching to an action's
|
|
@@ -208,7 +238,7 @@ function unchanged(bag, entry, v2) {
|
|
|
208
238
|
if (!builtRows.has('connectorKey') || !saved.has('connectorKey'))
|
|
209
239
|
return false;
|
|
210
240
|
for (const name of new Set([...builtRows.keys(), ...saved.keys()])) {
|
|
211
|
-
if (name === 'metadata')
|
|
241
|
+
if (name === 'metadata' || (typeof name === 'string' && !comparesContextRow(bag, name)))
|
|
212
242
|
continue;
|
|
213
243
|
// On a flagged-V2 plan `activityConfigurationVersion: v2` is compile's
|
|
214
244
|
// repair: it is written on connection-bound contexts, on a trigger or task
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
* the same operation. An extract the author edits (another source or
|
|
55
55
|
* variable) gets compile's row.
|
|
56
56
|
*/
|
|
57
|
+
import { comparesContextRow } from './connector-saved-context.js';
|
|
57
58
|
import { caseSubscriptionOwners } from './subscription.js';
|
|
58
59
|
const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
|
|
59
60
|
/** The context rows that name the operation an element calls. */
|
|
@@ -260,10 +261,14 @@ function extractsBack(bag, shapes) {
|
|
|
260
261
|
delete row.target;
|
|
261
262
|
}
|
|
262
263
|
}
|
|
263
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* Whether the element compile built calls the operation the rows were saved
|
|
266
|
+
* for. An activity's saved `operation` row, which compile never writes there,
|
|
267
|
+
* does not count (`comparesContextRow`).
|
|
268
|
+
*/
|
|
264
269
|
function sameOperation(bag, entry) {
|
|
265
270
|
const now = operationOf(bag);
|
|
266
|
-
return OPERATION_ROWS.every((name) => now[name] === entry.operation[name]);
|
|
271
|
+
return OPERATION_ROWS.every((name) => !comparesContextRow(bag, name) || now[name] === entry.operation[name]);
|
|
267
272
|
}
|
|
268
273
|
/**
|
|
269
274
|
* The saved outputs over the built ones: the saved own rows in saved order,
|
package/dist/case/decompile.d.ts
CHANGED
package/dist/case/decompile.js
CHANGED
|
@@ -465,12 +465,22 @@ function preservedSubscriptionFilters(plan) {
|
|
|
465
465
|
...(spelling && spelling.leaf !== CASE_FILTER_SPELLING.leaf ? { leaf: 'js' } : {}),
|
|
466
466
|
...designerFilterIds(bag, key, tree, reads),
|
|
467
467
|
...(!spelling && isEmptyObject(body.variables) ? { emptyVariables: true } : {}),
|
|
468
|
+
...(savedEmptyBody(bag) ? { emptyBody: true } : {}),
|
|
468
469
|
};
|
|
469
470
|
if (Object.keys(entry).length > 1)
|
|
470
471
|
out.push(entry);
|
|
471
472
|
}
|
|
472
473
|
return out;
|
|
473
474
|
}
|
|
475
|
+
/**
|
|
476
|
+
* Whether a subscription's `body` input is the Case Designer's "no parameters"
|
|
477
|
+
* spelling, `body: {}` with no `value`, where compile writes `value: ''`
|
|
478
|
+
* (`eventInput`). Both read the same (`subscriptionBody`).
|
|
479
|
+
*/
|
|
480
|
+
function savedEmptyBody(bag) {
|
|
481
|
+
const row = Array.isArray(bag.inputs) ? bag.inputs[0] : undefined;
|
|
482
|
+
return isEmptyObject(row?.body) && row?.value === undefined;
|
|
483
|
+
}
|
|
474
484
|
/**
|
|
475
485
|
* The tree's own ids (`uuId`, each leaf's `uiId`) when they are not the ones
|
|
476
486
|
* compile mints. Compile hashes them from the owner's element id
|
|
@@ -924,7 +934,7 @@ function savedConfiguration(context) {
|
|
|
924
934
|
/**
|
|
925
935
|
* The activity type the task was saved against (`Curated`, ...): the saved
|
|
926
936
|
* configuration's `instanceParameters.activityType`, else the activity
|
|
927
|
-
* metadata's
|
|
937
|
+
* metadata's, else `Curated` for an older Designer's `isCurated: true`. It picks between a curated activity and the generic one on the
|
|
928
938
|
* same object and path (`Library.identifyAction`).
|
|
929
939
|
*/
|
|
930
940
|
function connectorActivityType(context) {
|
|
@@ -941,7 +951,14 @@ function connectorActivityType(context) {
|
|
|
941
951
|
}
|
|
942
952
|
}
|
|
943
953
|
const fromActivity = activity?.activityType;
|
|
944
|
-
|
|
954
|
+
if (typeof fromActivity === 'string' && fromActivity)
|
|
955
|
+
return fromActivity;
|
|
956
|
+
// An older Designer (the v10 canvas plan) saved neither, only
|
|
957
|
+
// `designTimeMetadata.activityConfig.isCurated`. `true` is a curated
|
|
958
|
+
// activity, e.g. Outlook "Send Email", which shares POST
|
|
959
|
+
// /hubs/productivity/send-mail-v2 with the generic `insert-record-deprecated-`.
|
|
960
|
+
// `false` is left unread: those plans save it on generic records and events alike.
|
|
961
|
+
return context.get('metadata')?.body?.designTimeMetadata?.activityConfig?.isCurated === true ? 'Curated' : undefined;
|
|
945
962
|
}
|
|
946
963
|
function connectorVersion(context) {
|
|
947
964
|
const metadata = context.get('metadata')?.body;
|
|
@@ -1434,6 +1451,16 @@ function outputTargetOf(row) {
|
|
|
1434
1451
|
*
|
|
1435
1452
|
* A custom (`{ assign }`) output has its own spelling and is not handled here.
|
|
1436
1453
|
*/
|
|
1454
|
+
/**
|
|
1455
|
+
* A resource task output's saved `value` when it is not its `var`, the value
|
|
1456
|
+
* compile writes (`{ id: 'error2', var: 'error2', value: 'error' }`): carried
|
|
1457
|
+
* with the `var` it was saved beside (preserve.ts, `value` on an output row).
|
|
1458
|
+
*/
|
|
1459
|
+
function resourceOutputValue(task, row) {
|
|
1460
|
+
if (!ownEntry(TASK_KIND_METHOD, task.type) || row.custom === true || typeof row.var !== 'string')
|
|
1461
|
+
return {};
|
|
1462
|
+
return row.value === undefined || row.value === row.var ? {} : { value: { value: structuredClone(row.value), var: row.var } };
|
|
1463
|
+
}
|
|
1437
1464
|
function resourceRowShape(task, row, side) {
|
|
1438
1465
|
if (!ownEntry(TASK_KIND_METHOD, task.type) || row.custom === true)
|
|
1439
1466
|
return {};
|
|
@@ -1648,16 +1675,15 @@ function taskOutputRows(task) {
|
|
|
1648
1675
|
}
|
|
1649
1676
|
/**
|
|
1650
1677
|
* Refuse, naming the task and the row, a plan whose output rows a recompile
|
|
1651
|
-
* would not write back
|
|
1652
|
-
*
|
|
1678
|
+
* would not write back (`docs/CASE_DECOMPILE_DESIGN.md`, refusal boundary;
|
|
1679
|
+
* #1457): a row in neither `taskOutputRows` list would vanish with no message.
|
|
1680
|
+
* For instance a result-field extract `{ var: 'route', source: '=approved' }` on
|
|
1681
|
+
* a wait-for-timer task, which has no result to read and no SDK form for it.
|
|
1653
1682
|
*
|
|
1654
|
-
*
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
* connector's `response`) would come back after it. A custom row reads only
|
|
1659
|
-
* the rows before it, so its value could change. An extract reads the task's
|
|
1660
|
-
* result, so where it is listed does not matter.
|
|
1683
|
+
* A custom row listed before one of the task's own rows (ahead of a
|
|
1684
|
+
* connector's `Error`) is not refused: compile writes the own rows first, and
|
|
1685
|
+
* puts the custom row back in its saved place from the payload's row order
|
|
1686
|
+
* (`restoreOutputInterleaving` in serialize.ts).
|
|
1661
1687
|
*/
|
|
1662
1688
|
function refuseUnwrittenOutputs(task, plan) {
|
|
1663
1689
|
const rows = Array.isArray(task.data?.outputs) ? task.data.outputs : [];
|
|
@@ -1666,17 +1692,14 @@ function refuseUnwrittenOutputs(task, plan) {
|
|
|
1666
1692
|
const lost = rows.find((row) => !plan.lifted.includes(row) && !plan.rebuilt.includes(row));
|
|
1667
1693
|
if (lost)
|
|
1668
1694
|
throw new Error(`${owner} has output row "${lost.name ?? lost.var ?? '?'}" (source ${JSON.stringify(lost.source ?? null)}), which the SDK cannot write on a ${kind} task: only a custom { assign } output reads no task result. Decompile refuses it rather than drop it on recompile.`);
|
|
1669
|
-
const firstCustom = rows.findIndex((row) => row.custom === true && plan.lifted.includes(row));
|
|
1670
|
-
const lateOwn = firstCustom < 0 ? undefined : rows.slice(firstCustom).find((row) => plan.rebuilt.includes(row));
|
|
1671
|
-
if (lateOwn)
|
|
1672
|
-
throw new Error(`${owner} lists custom output "${rows[firstCustom].var ?? rows[firstCustom].name ?? '?'}" before its own row "${lateOwn.name ?? '?'}"; the SDK writes the task's own rows first, so a recompile would move the custom row after it and change what it reads.`);
|
|
1673
1695
|
}
|
|
1674
1696
|
function escalationSource(escalation, slaName, index) {
|
|
1675
1697
|
if (escalation.action?.type !== 'notification')
|
|
1676
1698
|
throw new Error(`SLA escalation "${escalation.displayName ?? escalation.id ?? index}" has unsupported action "${escalation.action?.type}".`);
|
|
1699
|
+
// An empty list is carried as `notify: []`: compile writes it back as
|
|
1700
|
+
// `recipients: []`, and check warns ESCALATION_NO_RECIPIENTS, as `case
|
|
1701
|
+
// validate` warns CASE_MGMT_STAGE_ESCALATION_RECIPIENTS_MISSING.
|
|
1677
1702
|
const recipients = escalation.action.recipients ?? [];
|
|
1678
|
-
if (recipients.length === 0)
|
|
1679
|
-
throw new Error(`SLA escalation "${escalation.displayName ?? escalation.id ?? index}" has no notification recipients.`);
|
|
1680
1703
|
const notify = recipients.map((recipient) => {
|
|
1681
1704
|
if (recipient.scope !== 'User' && recipient.scope !== 'UserGroup')
|
|
1682
1705
|
throw new Error(`SLA escalation "${escalation.displayName ?? escalation.id ?? index}" has unsupported recipient scope "${recipient.scope}".`);
|
|
@@ -1716,7 +1739,8 @@ function emitStage(stageOut, depth, stage, refs, library, selectNextStage) {
|
|
|
1716
1739
|
// The stage's own calls, collected first so they can be written as one chain or as statements.
|
|
1717
1740
|
const out = new Emit();
|
|
1718
1741
|
const inner = depth + 1;
|
|
1719
|
-
|
|
1742
|
+
// `""` too: a stage saved with `description: ""` keeps it (compile writes what the source gives).
|
|
1743
|
+
if (typeof data.description === 'string')
|
|
1720
1744
|
out.line(inner, `.description(${tsLiteral(data.description)})`);
|
|
1721
1745
|
if (data.isRequired !== undefined)
|
|
1722
1746
|
out.line(inner, data.isRequired ? '.required()' : '.required(false)');
|
|
@@ -2318,7 +2342,13 @@ function ruleInputIdentity(inputs) {
|
|
|
2318
2342
|
function slaIdentity(sla) {
|
|
2319
2343
|
return {
|
|
2320
2344
|
...(sla.id ? { id: sla.id } : {}),
|
|
2321
|
-
escalations: (sla.escalationRule ?? []).map((entry) => ({
|
|
2345
|
+
escalations: (sla.escalationRule ?? []).map((entry) => ({
|
|
2346
|
+
...(entry.id ? { id: entry.id } : {}),
|
|
2347
|
+
// `escalationSource` writes atRiskPercentage only for an at-risk trigger.
|
|
2348
|
+
...(entry.triggerInfo?.type === 'sla-breached' && typeof entry.triggerInfo.atRiskPercentage === 'number'
|
|
2349
|
+
? { breachedAtRisk: entry.triggerInfo.atRiskPercentage }
|
|
2350
|
+
: {}),
|
|
2351
|
+
})),
|
|
2322
2352
|
...(Array.isArray(sla.escalationRule) && sla.escalationRule.length === 0 ? { emptyEscalationRule: true } : {}),
|
|
2323
2353
|
};
|
|
2324
2354
|
}
|
|
@@ -2379,14 +2409,42 @@ function prunePreservation(preservation, plan) {
|
|
|
2379
2409
|
* input as `{ name, type, value }`; the Designer also gives it `var` (its id)
|
|
2380
2410
|
* and `elementId` (the task's), which compile restores from the id. Only an
|
|
2381
2411
|
* `elementId` that is not the task's is carried.
|
|
2412
|
+
*
|
|
2413
|
+
* The rows the Designer saves are not all that shape, and what is saved is
|
|
2414
|
+
* carried, so the plan comes back as it was:
|
|
2415
|
+
* - `omit`: the fields compile writes that the row was saved without: `type`
|
|
2416
|
+
* (read as `string`), and, on a row with an id, `var` and `elementId`
|
|
2417
|
+
* (`{ id: 'purchaseOrder', name, type, value }` stays without them).
|
|
2418
|
+
* - A row with no id keeps the `elementId` it was saved with:
|
|
2419
|
+
* `taskElementId: true` when it is the task's, with the meaning it has on
|
|
2420
|
+
* any io row (`rowHoldsSavedTaskElementId`): the row was saved with its
|
|
2421
|
+
* task's `elementId`, and compile writes back the task's final one. Compile
|
|
2422
|
+
* writes such a row with no `elementId`, so it is recorded even when the
|
|
2423
|
+
* task's `elementId` is the `<stageId>-<taskId>` compile writes. Any other
|
|
2424
|
+
* `elementId` is carried as the value itself.
|
|
2382
2425
|
*/
|
|
2383
2426
|
function actionInputShape(task, row) {
|
|
2384
|
-
if (task.type !== 'action'
|
|
2427
|
+
if (task.type !== 'action')
|
|
2385
2428
|
return {};
|
|
2429
|
+
const omit = [];
|
|
2430
|
+
if (row.type === undefined)
|
|
2431
|
+
omit.push('type');
|
|
2432
|
+
if (!row.id) {
|
|
2433
|
+
const own = row.elementId !== undefined && row.elementId === task.elementId;
|
|
2434
|
+
return {
|
|
2435
|
+
...(own ? { taskElementId: true } : row.elementId !== undefined ? { elementId: row.elementId } : {}),
|
|
2436
|
+
...(omit.length ? { omit } : {}),
|
|
2437
|
+
};
|
|
2438
|
+
}
|
|
2439
|
+
if (row.var === undefined)
|
|
2440
|
+
omit.push('var');
|
|
2441
|
+
if (row.elementId === undefined)
|
|
2442
|
+
omit.push('elementId');
|
|
2386
2443
|
return {
|
|
2387
2444
|
...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
|
|
2388
2445
|
// `actionFields` has checked it is a copy of the id.
|
|
2389
2446
|
...(row.canonicalId !== undefined ? { canonicalId: true } : {}),
|
|
2447
|
+
...(omit.length ? { omit } : {}),
|
|
2390
2448
|
};
|
|
2391
2449
|
}
|
|
2392
2450
|
/**
|
|
@@ -2503,10 +2561,43 @@ function customRowIdentity(task, row, plan) {
|
|
|
2503
2561
|
const shape = customRowShape(row, carriedApart, varRows);
|
|
2504
2562
|
return shape ? { customRow: shape } : {};
|
|
2505
2563
|
}
|
|
2564
|
+
/**
|
|
2565
|
+
* The saved `source` of a custom row listed before one of its task's other
|
|
2566
|
+
* (not custom) rows, which compile writes after them. Compile puts the row
|
|
2567
|
+
* back in its saved place (`restoreOutputInterleaving`), and checks this
|
|
2568
|
+
* source there: a row edited to read a row it would then precede keeps
|
|
2569
|
+
* compile's order. For instance, an action task saved as
|
|
2570
|
+
* [approved, decision (custom, `=approved`), note] records
|
|
2571
|
+
* `savedSource: '=approved'` on `decision`.
|
|
2572
|
+
*/
|
|
2573
|
+
function interleavedCustomSource(task, row) {
|
|
2574
|
+
if (row.custom !== true)
|
|
2575
|
+
return {};
|
|
2576
|
+
const rows = task.data?.outputs ?? [];
|
|
2577
|
+
const at = rows.indexOf(row);
|
|
2578
|
+
if (!rows.slice(at + 1).some((other) => other?.custom !== true))
|
|
2579
|
+
return {};
|
|
2580
|
+
return { savedSource: typeof row.source === 'string' ? row.source : '' };
|
|
2581
|
+
}
|
|
2506
2582
|
/** Whether a plan declaring `version` keeps its custom rows' saved `elementId` on read (V32.0.3 and later). */
|
|
2507
2583
|
function customElementIdIsOwn(version) {
|
|
2508
2584
|
return typeof version === 'string' && /^\d+\.\d+\.\d+$/.test(version) && compareSchemaVersions(version, '32.0.3') >= 0;
|
|
2509
2585
|
}
|
|
2586
|
+
/**
|
|
2587
|
+
* A task's saved `elementId` when it is not the `<stageId>-<taskId>` compile
|
|
2588
|
+
* writes, e.g. `Stage_old-tOld` on a task Studio Web copied from another stage
|
|
2589
|
+
* (preserve.ts, `elementId` on a task identity).
|
|
2590
|
+
*/
|
|
2591
|
+
function savedTaskElementId(stage, task) {
|
|
2592
|
+
if (typeof task.elementId !== 'string' || !stage.id || !task.id)
|
|
2593
|
+
return {};
|
|
2594
|
+
return task.elementId === `${stage.id}-${task.id}` ? {} : { elementId: task.elementId };
|
|
2595
|
+
}
|
|
2596
|
+
/** `taskElementId: true` on an io row saved with its task's carried `elementId` ({@link savedTaskElementId}). */
|
|
2597
|
+
function rowHoldsSavedTaskElementId(stage, task, row) {
|
|
2598
|
+
const saved = savedTaskElementId(stage, task).elementId;
|
|
2599
|
+
return saved !== undefined && row.elementId === saved ? { taskElementId: true } : {};
|
|
2600
|
+
}
|
|
2510
2601
|
function identityPreservation(plan) {
|
|
2511
2602
|
const ambiguous = ambiguousSlaIds(plan);
|
|
2512
2603
|
const conditionIdentity = (condition, _index, list) => conditionIdentityOf(condition, ambiguous, list);
|
|
@@ -2522,9 +2613,10 @@ function identityPreservation(plan) {
|
|
|
2522
2613
|
tasks: (stage.data?.tasks ?? []).map((lane) => lane.map((task) => ({
|
|
2523
2614
|
name: taskSourceName(task),
|
|
2524
2615
|
...(task.id ? { id: task.id } : {}),
|
|
2616
|
+
...savedTaskElementId(stage, task),
|
|
2525
2617
|
entryConditions: (task.entryConditions ?? []).map(conditionIdentity),
|
|
2526
2618
|
...emptyLists(task, TASK_EMPTY_LISTS),
|
|
2527
|
-
inputs: (task.data?.inputs ?? []).map((row) => ({ name: row.name ?? '', ...(row.id ? { id: row.id } : {}), ...actionInputShape(task, row), ...resourceRowShape(task, row, 'inputs') })),
|
|
2619
|
+
inputs: (task.data?.inputs ?? []).map((row) => ({ name: row.name ?? '', ...(row.id ? { id: row.id } : {}), ...actionInputShape(task, row), ...resourceRowShape(task, row, 'inputs'), ...rowHoldsSavedTaskElementId(stage, task, row) })),
|
|
2528
2620
|
outputs: (task.data?.outputs ?? []).map((row) => ({
|
|
2529
2621
|
name: row.name ?? '',
|
|
2530
2622
|
...(row.id ? { id: row.id } : {}),
|
|
@@ -2538,7 +2630,10 @@ function identityPreservation(plan) {
|
|
|
2538
2630
|
...unaliasedOwnNameRow(row, plan),
|
|
2539
2631
|
...actionOutputShape(task, row),
|
|
2540
2632
|
...resourceRowShape(task, row, 'outputs'),
|
|
2633
|
+
...resourceOutputValue(task, row),
|
|
2541
2634
|
...customRowIdentity(task, row, plan),
|
|
2635
|
+
...interleavedCustomSource(task, row),
|
|
2636
|
+
...rowHoldsSavedTaskElementId(stage, task, row),
|
|
2542
2637
|
})),
|
|
2543
2638
|
...emptyIoLists(task),
|
|
2544
2639
|
...carriedResource(task, plan),
|
|
@@ -262,33 +262,58 @@ function wireType(value) {
|
|
|
262
262
|
return 'boolean';
|
|
263
263
|
return undefined;
|
|
264
264
|
}
|
|
265
|
-
/**
|
|
266
|
-
|
|
265
|
+
/**
|
|
266
|
+
* The connector ACTION's two tenant answers: the registry node and the `is
|
|
267
|
+
* resources describe` reply, from what the tasks on the operation saved.
|
|
268
|
+
*
|
|
269
|
+
* `w` is the first task on the operation, and the entry's text is its own.
|
|
270
|
+
* The fields are every task's (`wires`, `w` first): one entry stands for the
|
|
271
|
+
* operation, so it must declare each field any task on it sends. Two Data
|
|
272
|
+
* Service "Create Entity Record" tasks that write two entities send two field
|
|
273
|
+
* sets on one path, for instance `{ caseNumber, status }` and
|
|
274
|
+
* `{ caseNumber, eventTime, actor }`; the entry declares all four. A field two
|
|
275
|
+
* tasks send with values of different JSON types gets no type.
|
|
276
|
+
*/
|
|
277
|
+
function actionAnswers(w, nodeType, wires = [w]) {
|
|
267
278
|
const fields = new Map();
|
|
279
|
+
// The fields whose type was read off a sent value, not a saved declaration.
|
|
280
|
+
const valueTyped = new Set();
|
|
268
281
|
const add = (name, location, type, displayName) => {
|
|
269
282
|
if (typeof name !== 'string' || !name || fields.has(name))
|
|
270
283
|
return;
|
|
271
284
|
fields.set(name, { name, location, ...(type ? { type } : {}), ...(typeof displayName === 'string' && displayName ? { displayName } : {}) });
|
|
272
285
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (
|
|
280
|
-
|
|
286
|
+
const addSent = (name, location, type) => {
|
|
287
|
+
const field = fields.get(name);
|
|
288
|
+
if (!field) {
|
|
289
|
+
add(name, location, type);
|
|
290
|
+
valueTyped.add(name);
|
|
291
|
+
}
|
|
292
|
+
else if (valueTyped.has(name) && field.type !== type)
|
|
293
|
+
delete field.type;
|
|
294
|
+
};
|
|
295
|
+
// The live connector's field list each task's Designer saved, then every value each task sends.
|
|
296
|
+
for (const wire of wires) {
|
|
297
|
+
const saved = wire.optional.fieldsContainer?.inputFields;
|
|
298
|
+
for (const f of Array.isArray(saved) ? saved : []) {
|
|
299
|
+
if (!isObject(f) || f.request === false)
|
|
300
|
+
continue;
|
|
301
|
+
const location = typeof f.fieldLocation === 'string' ? ownEntry(LOCATIONS, f.fieldLocation) : undefined;
|
|
302
|
+
if (location)
|
|
303
|
+
add(f.name, location, typeof f.type === 'string' ? f.type : undefined, f.displayName);
|
|
304
|
+
}
|
|
281
305
|
}
|
|
282
306
|
for (const m of String(w.path ?? '').matchAll(/\{([^}]+)\}/g))
|
|
283
307
|
add(m[1], 'path', 'string');
|
|
284
308
|
const slot = { pathParameters: 'path', queryParameters: 'query', body: 'body' };
|
|
285
|
-
for (const
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
309
|
+
for (const wire of wires)
|
|
310
|
+
for (const row of Array.isArray(wire.bag.inputs) ? wire.bag.inputs : []) {
|
|
311
|
+
const location = typeof row?.name === 'string' ? ownEntry(slot, row.name) : undefined;
|
|
312
|
+
if (!location || !isObject(row.body))
|
|
313
|
+
continue;
|
|
314
|
+
for (const [name, value] of Object.entries(row.body))
|
|
315
|
+
addSent(name, location, wireType(value));
|
|
316
|
+
}
|
|
292
317
|
const parameters = [...fields.values()].filter((f) => f.location !== 'body')
|
|
293
318
|
.map((f) => ({ name: f.name, type: f.location, dataType: f.type ?? 'string', required: false, ...(f.displayName ? { displayName: f.displayName } : {}) }));
|
|
294
319
|
const multipart = Array.isArray(w.apc.multipartParameters) ? w.apc.multipartParameters : [];
|
|
@@ -410,6 +435,18 @@ export function planConnectors(plan, library) {
|
|
|
410
435
|
// and the first wire on an operation is the one its entry is built from.
|
|
411
436
|
const bags = planConnectorBags(plan);
|
|
412
437
|
const ordered = [...bags.filter((b) => b.bag.serviceType === WAIT), ...bags.filter((b) => b.bag.serviceType !== WAIT)];
|
|
438
|
+
const actionKey = (w) => JSON.stringify([w.connectorKey, w.method, w.path, w.objectName, w.version]);
|
|
439
|
+
// Every action wire the library cannot name, by operation: the entry built
|
|
440
|
+
// from the first declares the fields of all (`actionAnswers`).
|
|
441
|
+
const actionWires = new Map();
|
|
442
|
+
for (const { bag } of ordered) {
|
|
443
|
+
const w = wireOf(bag);
|
|
444
|
+
if (!w || w.kind !== 'action' || known(library, w))
|
|
445
|
+
continue;
|
|
446
|
+
const list = actionWires.get(actionKey(w)) ?? [];
|
|
447
|
+
list.push(w);
|
|
448
|
+
actionWires.set(actionKey(w), list);
|
|
449
|
+
}
|
|
413
450
|
for (const { owner, names, bag } of ordered) {
|
|
414
451
|
const w = wireOf(bag);
|
|
415
452
|
if (!w || known(library, w))
|
|
@@ -420,7 +457,7 @@ export function planConnectors(plan, library) {
|
|
|
420
457
|
// One action id per operation: object and verb, with a counter when two
|
|
421
458
|
// paths share them or a library layer already holds the node type.
|
|
422
459
|
const base = `${slug(w.objectName)}-${slug(w.method)}`;
|
|
423
|
-
const operationKey =
|
|
460
|
+
const operationKey = actionKey(w);
|
|
424
461
|
let id = actionIds.get(operationKey);
|
|
425
462
|
if (id === undefined) {
|
|
426
463
|
id = base;
|
|
@@ -430,7 +467,7 @@ export function planConnectors(plan, library) {
|
|
|
430
467
|
id = `${base}-${n}`;
|
|
431
468
|
actionIds.set(operationKey, id);
|
|
432
469
|
}
|
|
433
|
-
const answers = actionAnswers(w, `uipath.connector.${w.connectorKey}.${id}
|
|
470
|
+
const answers = actionAnswers(w, `uipath.connector.${w.connectorKey}.${id}`, actionWires.get(operationKey));
|
|
434
471
|
node = answers.node;
|
|
435
472
|
const canonical = extractCanonical(node);
|
|
436
473
|
if (!canonical)
|
|
@@ -455,7 +492,7 @@ export function planConnectors(plan, library) {
|
|
|
455
492
|
}
|
|
456
493
|
entry.provenance = { source: PLAN_CONNECTOR_SOURCE };
|
|
457
494
|
const question = libraryQuestion(w.kind, { connectorKey: w.connectorKey, httpMethod: w.method, endpoint: w.path, objectName: w.objectName, eventOperation: w.operation });
|
|
458
|
-
// Two wires on one operation give one entry: the first one's.
|
|
495
|
+
// Two wires on one operation give one entry: the first one's text, with every one's fields (`actionAnswers`).
|
|
459
496
|
const key = JSON.stringify([entry.nodeType, entry.operation?.objectName ?? '', entry.version]);
|
|
460
497
|
let connector = byKey.get(key);
|
|
461
498
|
if (!connector) {
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -194,8 +194,15 @@ interface ConditionIdentity {
|
|
|
194
194
|
}
|
|
195
195
|
interface SlaIdentity {
|
|
196
196
|
id?: string;
|
|
197
|
+
/**
|
|
198
|
+
* `breachedAtRisk`: an `sla-breached` escalation's leftover
|
|
199
|
+
* `triggerInfo.atRiskPercentage`. The Designer keeps the percentage when an
|
|
200
|
+
* `at-risk` escalation is switched to `sla-breached`; the engine ignores it
|
|
201
|
+
* there and the source does not spell it, so the read value is carried.
|
|
202
|
+
*/
|
|
197
203
|
escalations?: Array<{
|
|
198
204
|
id?: string;
|
|
205
|
+
breachedAtRisk?: number;
|
|
199
206
|
}>;
|
|
200
207
|
/**
|
|
201
208
|
* The SLA spelled an empty `escalationRule: []`. The serializer omits the
|
|
@@ -212,16 +219,32 @@ interface StageIdentity {
|
|
|
212
219
|
tasks?: Array<Array<{
|
|
213
220
|
name: string;
|
|
214
221
|
id?: string;
|
|
222
|
+
/**
|
|
223
|
+
* The task's saved `elementId`, only when it is not `<stageId>-<taskId>`, the
|
|
224
|
+
* value compile writes. A task Studio Web copied, or one whose stage or task
|
|
225
|
+
* id changed after it was saved, keeps the `elementId` it was created with
|
|
226
|
+
* (`Stage_old-tOld`), and so do the io rows that name it. The converter only
|
|
227
|
+
* matches a task's rows to it by equality, so the saved value is carried and
|
|
228
|
+
* written back on the task and on each of its rows saved with it
|
|
229
|
+
* (`taskElementId: true` on the row), and only those: Studio Web re-stamps
|
|
230
|
+
* some rows with `<stageId>-<taskId>` and leaves others, and the converter
|
|
231
|
+
* drops a row whose `elementId` is not the task's, so which rows hold it is
|
|
232
|
+
* part of what the plan does.
|
|
233
|
+
*/
|
|
234
|
+
elementId?: string;
|
|
215
235
|
entryConditions?: ConditionIdentity[];
|
|
216
236
|
/** The resource the rows' `fields` / `omit` describe; they are applied only while the task still names it. */
|
|
217
237
|
resource?: ResourceTaskIdentity;
|
|
218
238
|
/** `elementId` only for an action form input whose row names another element than its task. `canonicalId: true`: an action form input saved with the schema migration's `canonicalId`, a copy of its id. `fields`: a resource task row's Designer fields compile does not write (`displayName`, `title`, `body`, ...). */
|
|
239
|
+
/** `omit` on an action form input: the fields compile writes that it was saved without (`type`; `var`, `elementId` on a row with an id). `taskElementId: true`: the row was saved with its task's `elementId`; compile writes back the task's final `elementId` (see `elementId` above). An action form input with no id, which compile writes with no `elementId`, carries it whenever its `elementId` is the task's. */
|
|
219
240
|
inputs?: Array<{
|
|
220
241
|
name: string;
|
|
221
242
|
id?: string;
|
|
222
243
|
elementId?: string;
|
|
223
244
|
canonicalId?: true;
|
|
224
245
|
fields?: Record<string, unknown>;
|
|
246
|
+
omit?: string[];
|
|
247
|
+
taskElementId?: true;
|
|
225
248
|
}>;
|
|
226
249
|
/** `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>`). `bodyCopies`: the extra copies of its `body` an action form output was saved with (`jsonSchema`), which compile writes back from the body. */
|
|
227
250
|
/** `var` and `custom: true`: a custom row whose label (`name`) is not the name of the variable it assigns. */
|
|
@@ -314,6 +337,27 @@ export interface PreservedOutputRow {
|
|
|
314
337
|
custom?: true;
|
|
315
338
|
noAlias?: true;
|
|
316
339
|
customRow?: CustomRowShape;
|
|
340
|
+
/**
|
|
341
|
+
* The `source` a custom row saved ahead of one of its task's other rows
|
|
342
|
+
* assigned. Compile restores the saved interleaving (`restoreOutputInterleaving`)
|
|
343
|
+
* only while a custom row that would come before a row its source names
|
|
344
|
+
* still assigns this saved source: an edit that makes the row read a row
|
|
345
|
+
* listed after it keeps compile's order.
|
|
346
|
+
*/
|
|
347
|
+
savedSource?: string;
|
|
348
|
+
/** The row was saved with its task's carried `elementId` (see `elementId` on the task identity). */
|
|
349
|
+
taskElementId?: true;
|
|
350
|
+
/**
|
|
351
|
+
* A resource task output's saved `value` when it is not the row's `var` (the
|
|
352
|
+
* value compile writes), with the `var` it was saved beside. Studio Web
|
|
353
|
+
* leaves `value` as it was when the row's variable changes, e.g.
|
|
354
|
+
* `{ id: 'error2', var: 'error2', value: 'error' }`. Compile writes it back
|
|
355
|
+
* while the row still writes that variable.
|
|
356
|
+
*/
|
|
357
|
+
value?: {
|
|
358
|
+
value: unknown;
|
|
359
|
+
var: string;
|
|
360
|
+
};
|
|
317
361
|
}
|
|
318
362
|
/**
|
|
319
363
|
* Non-authoring Case JSON lanes retained by decompile/recompile.
|
|
@@ -588,7 +632,8 @@ export interface CaseJsonPreservation {
|
|
|
588
632
|
* One subscription's Designer-owned filter state. Only what compile would not
|
|
589
633
|
* write itself is recorded: `expression: 'inline'` (the older `${…}` template,
|
|
590
634
|
* no `filters.variables`), `leaf: 'js'` (a `=js:(…)` tree value),
|
|
591
|
-
* `emptyVariables` (a literal-only filter saved with `variables: {}`),
|
|
635
|
+
* `emptyVariables` (a literal-only filter saved with `variables: {}`),
|
|
636
|
+
* `emptyBody` (a subscription with no `where` saved as `body: {}`), and the
|
|
592
637
|
* tree's own ids when Studio Web minted them (`uuId`, and each leaf's `uiId`
|
|
593
638
|
* with the condition it filters on).
|
|
594
639
|
*/
|
|
@@ -617,6 +662,12 @@ export interface PreservedSubscriptionFilter {
|
|
|
617
662
|
leaf?: 'js';
|
|
618
663
|
/** The plan saved a literal-only filter with an empty `filters.variables` map (older Studio Web builds). */
|
|
619
664
|
emptyVariables?: true;
|
|
665
|
+
/**
|
|
666
|
+
* The plan saved a subscription with no `where` as `body: {}` with no
|
|
667
|
+
* `value` (the Case Designer's spelling); compile writes `value: ''`. Both
|
|
668
|
+
* read as "no parameters". Applied only while the row still has no body.
|
|
669
|
+
*/
|
|
670
|
+
emptyBody?: true;
|
|
620
671
|
/** The tree's `uuId`. */
|
|
621
672
|
uuId?: string | null;
|
|
622
673
|
/** Each tree leaf's `uiId`, in tree order, with the condition it holds. */
|
package/dist/case/preserve.js
CHANGED
|
@@ -378,17 +378,21 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
378
378
|
if (written.has(field) && !(side === 'input' && (field === 'required' || field === 'default') && !isTypedInputField(field, value)))
|
|
379
379
|
errors.push(`task "${task.name}" ${side} "${row.name}" field "${field}" is owned by the typed Case serializer`);
|
|
380
380
|
for (const field of row.omit ?? [])
|
|
381
|
-
// `target` (a resource extract or an action form output),
|
|
382
|
-
// `_jsonSchema` / `elementId` (an action form output, #1636)
|
|
383
|
-
|
|
381
|
+
// `target` (a resource extract or an action form output),
|
|
382
|
+
// `_jsonSchema` / `elementId` (an action form output, #1636), and
|
|
383
|
+
// `type` / `var` / `elementId` (an action form input).
|
|
384
|
+
if (side === 'output' ? !(field === 'target' || field === '_jsonSchema' || field === 'elementId') : !(field === 'type' || field === 'var' || field === 'elementId'))
|
|
384
385
|
errors.push(`task "${task.name}" ${side} "${row.name}" omits "${String(field)}", which is not an omittable field`);
|
|
385
386
|
}
|
|
386
387
|
}
|
|
387
388
|
for (const stage of payload.identities?.stages ?? [])
|
|
388
389
|
for (const task of (stage.tasks ?? []).flat())
|
|
389
|
-
for (const row of task.outputs ?? [])
|
|
390
|
+
for (const row of task.outputs ?? []) {
|
|
390
391
|
if (row.customRow !== undefined)
|
|
391
392
|
errors.push(...customRowShapeErrors(`task "${task.name}" output "${row.name}"`, row.customRow));
|
|
393
|
+
if (row.savedSource !== undefined && typeof row.savedSource !== 'string')
|
|
394
|
+
errors.push(`task "${task.name}" output "${row.name}" savedSource must be a string`);
|
|
395
|
+
}
|
|
392
396
|
for (const id of payload.omitTaskDisplayNames ?? [])
|
|
393
397
|
if (typeof id !== 'string' || id === '')
|
|
394
398
|
errors.push('omitted task displayName ids must be non-empty strings');
|
|
@@ -492,7 +496,7 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
492
496
|
if (typeof entry?.owner !== 'string' || !/^(trigger|task|rule):/.test(entry.owner))
|
|
493
497
|
errors.push(`preserved subscription filter owner ${JSON.stringify(entry?.owner)} is not a trigger, task or rule key`);
|
|
494
498
|
for (const field of Object.keys(entry ?? {}))
|
|
495
|
-
if (!['owner', 'expression', 'leaf', 'emptyVariables', 'uuId', 'leaves'].includes(field))
|
|
499
|
+
if (!['owner', 'expression', 'leaf', 'emptyVariables', 'emptyBody', 'uuId', 'leaves'].includes(field))
|
|
496
500
|
errors.push(`preserved subscription filter "${entry.owner}" field "${field}" is not allowed in the preservation channel`);
|
|
497
501
|
if (entry?.expression !== undefined && entry.expression !== 'inline')
|
|
498
502
|
errors.push(`preserved subscription filter "${entry.owner}" expression spelling must be "inline"`);
|
|
@@ -500,6 +504,8 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
500
504
|
errors.push(`preserved subscription filter "${entry.owner}" leaf spelling must be "js"`);
|
|
501
505
|
if (entry?.emptyVariables !== undefined && entry.emptyVariables !== true)
|
|
502
506
|
errors.push(`preserved subscription filter "${entry.owner}" emptyVariables must be true`);
|
|
507
|
+
if (entry?.emptyBody !== undefined && entry.emptyBody !== true)
|
|
508
|
+
errors.push(`preserved subscription filter "${entry.owner}" emptyBody must be true`);
|
|
503
509
|
const isId = (value) => value === null || typeof value === 'string';
|
|
504
510
|
if (entry?.uuId !== undefined && !isId(entry.uuId))
|
|
505
511
|
errors.push(`preserved subscription filter "${entry.owner}" uuId must be a string or null`);
|
package/dist/case/serialize.js
CHANGED
|
@@ -555,6 +555,8 @@ export function applyPreservation(result, preservation, options = {}) {
|
|
|
555
555
|
applySubscriptionFilters(result, preservation);
|
|
556
556
|
// After the ids are restored: an unchanged connector element takes its saved own io rows.
|
|
557
557
|
applyConnectorRows(result, preservation.connectorRows);
|
|
558
|
+
// Last, once every row has its saved name and the connector rows are back.
|
|
559
|
+
restoreOutputInterleaving(result, preservation.identities);
|
|
558
560
|
Object.assign(result, preservation.topLevel ?? {});
|
|
559
561
|
Object.assign(result.metadata, preservation.metadata ?? {});
|
|
560
562
|
const metadata = result.metadata;
|
|
@@ -1280,6 +1282,58 @@ function restoreNoTasks(data, spelling) {
|
|
|
1280
1282
|
else
|
|
1281
1283
|
data.tasks = [];
|
|
1282
1284
|
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Retry the output-id claims that found their carried id held by another row
|
|
1287
|
+
* (`claimRowId` returned `false`), until none moves.
|
|
1288
|
+
*
|
|
1289
|
+
* A claim waits for the row that holds its id to move to the id it carries.
|
|
1290
|
+
* When the waits form a ring, none can go first. Compile numbers a connector
|
|
1291
|
+
* element's `response` row in plan order, and the Designer in the order the
|
|
1292
|
+
* author added the elements, so a plan saved as
|
|
1293
|
+
*
|
|
1294
|
+
* wait task `response3`, activity `response4`, entry rule `response2`
|
|
1295
|
+
*
|
|
1296
|
+
* compiles as `response2`, `response3`, `response4`: each row wants the id
|
|
1297
|
+
* the next one holds. Every id in a ring is wanted by a row of the ring and
|
|
1298
|
+
* held by one, so the rows take theirs together: the ids are released, then
|
|
1299
|
+
* claimed. A chain that ends at a row with no claim (an id the source does not
|
|
1300
|
+
* carry for it) still waits, and its rows keep the ids compile gave them.
|
|
1301
|
+
*/
|
|
1302
|
+
function settleDeferredClaims(deferred, held, claim) {
|
|
1303
|
+
let pending = deferred;
|
|
1304
|
+
while (pending.length) {
|
|
1305
|
+
const next = pending.filter(({ target, row }) => !claim(target, row));
|
|
1306
|
+
if (next.length < pending.length) {
|
|
1307
|
+
pending = next;
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
1310
|
+
// Stuck: find a ring of claims, each wanting the id the next one holds.
|
|
1311
|
+
const byHeldId = new Map(pending.map((entry) => [entry.target?.id, entry]));
|
|
1312
|
+
let ring;
|
|
1313
|
+
for (const start of pending) {
|
|
1314
|
+
const path = [];
|
|
1315
|
+
for (let at = start; at && !path.includes(at); at = byHeldId.get(at.row.id))
|
|
1316
|
+
path.push(at);
|
|
1317
|
+
const last = path[path.length - 1];
|
|
1318
|
+
if (path.length > 1 && byHeldId.get(last.row.id) === start) {
|
|
1319
|
+
ring = path;
|
|
1320
|
+
break;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
if (!ring)
|
|
1324
|
+
return;
|
|
1325
|
+
for (const { target } of ring)
|
|
1326
|
+
held.delete(target.id);
|
|
1327
|
+
// `claimRowId` frees the id the row held when it moves; in a ring that id
|
|
1328
|
+
// is another member's now, so the ring's final ids are held again after.
|
|
1329
|
+
for (const { target, row } of ring)
|
|
1330
|
+
claim(target, row);
|
|
1331
|
+
for (const { target } of ring)
|
|
1332
|
+
if (typeof target?.id === 'string')
|
|
1333
|
+
held.add(target.id);
|
|
1334
|
+
pending = pending.filter((entry) => !ring.includes(entry));
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1283
1337
|
function applyPreservedIdentities(result, preservation, warn) {
|
|
1284
1338
|
const identities = preservation.identities;
|
|
1285
1339
|
if (!identities)
|
|
@@ -1334,6 +1388,8 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1334
1388
|
if (!carriedCompanions.has(row.var))
|
|
1335
1389
|
carriedCompanions.set(row.var, { id: row.var, name: row.var, type: row.type, elementId: 'root', custom: true });
|
|
1336
1390
|
};
|
|
1391
|
+
// Tasks saved with an `elementId` other than `<stageId>-<taskId>`, written back once every id is final.
|
|
1392
|
+
const savedTaskElementIds = [];
|
|
1337
1393
|
// Tasks whose custom rows carry a saved shape (`customRowShape`).
|
|
1338
1394
|
const customRowShapes = [];
|
|
1339
1395
|
const nodes = result.nodes;
|
|
@@ -1494,7 +1550,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1494
1550
|
// `elementId` (#1636). On any other row those would remove or re-point a
|
|
1495
1551
|
// field compile writes: a resource extract without its task's `elementId`
|
|
1496
1552
|
// is one the converter never reads (#1419).
|
|
1497
|
-
const takeOutputRows = (outputRows, wantedRows, actionRows = false) => {
|
|
1553
|
+
const takeOutputRows = (outputRows, wantedRows, actionRows = false, elementIdRows) => {
|
|
1498
1554
|
// A custom row's own label goes back on the one custom row that still
|
|
1499
1555
|
// assigns its variable (matched once every id is final).
|
|
1500
1556
|
for (const row of wantedRows)
|
|
@@ -1518,6 +1574,17 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1518
1574
|
// A positional match never takes a row a name match owns.
|
|
1519
1575
|
: named.has(outputRows[index]?.name) ? undefined : outputRows[index];
|
|
1520
1576
|
const currentId = target?.id;
|
|
1577
|
+
if (target)
|
|
1578
|
+
elementIdRows?.matched.add(target);
|
|
1579
|
+
if (target && row.taskElementId === true)
|
|
1580
|
+
elementIdRows?.saved.add(target);
|
|
1581
|
+
// A resource output's saved `value` (a stale Designer copy, `value: 'error'`
|
|
1582
|
+
// on a row that writes `error2`) goes back while the row still writes the
|
|
1583
|
+
// variable it was saved beside and compile wrote its own `value: <var>`.
|
|
1584
|
+
const saved = row.value;
|
|
1585
|
+
if (target && !actionRows && saved && typeof saved.var === 'string')
|
|
1586
|
+
targetSpellings.push(() => { if (target.var === saved.var && target.value === target.var)
|
|
1587
|
+
target.value = structuredClone(saved.value); });
|
|
1521
1588
|
// An action form output the Designer saved with no `target` (or no
|
|
1522
1589
|
// `_jsonSchema` copy of its body, or no `elementId`) keeps none, and one
|
|
1523
1590
|
// whose `elementId` names another element keeps that.
|
|
@@ -1532,7 +1599,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1532
1599
|
target.jsonSchema = structuredClone(target.body); });
|
|
1533
1600
|
carryRowShape(target, row);
|
|
1534
1601
|
if (!claimRowId(target, row, currentId))
|
|
1535
|
-
deferredClaims.push(
|
|
1602
|
+
deferredClaims.push({ target, row });
|
|
1536
1603
|
});
|
|
1537
1604
|
};
|
|
1538
1605
|
const takeConditions = (current, wanted) => {
|
|
@@ -1602,7 +1669,15 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1602
1669
|
(wanted ?? []).forEach((sla, index) => {
|
|
1603
1670
|
const target = current?.[index];
|
|
1604
1671
|
want(target, sla.id);
|
|
1605
|
-
(sla.escalations ?? []).forEach((entry, escalationIndex) =>
|
|
1672
|
+
(sla.escalations ?? []).forEach((entry, escalationIndex) => {
|
|
1673
|
+
const escalation = target?.escalationRule?.[escalationIndex];
|
|
1674
|
+
want(escalation, entry.id);
|
|
1675
|
+
// The read sla-breached escalation kept a stale atRiskPercentage; put it
|
|
1676
|
+
// back only while this escalation is still sla-breached without one.
|
|
1677
|
+
const info = escalation?.triggerInfo;
|
|
1678
|
+
if (typeof entry.breachedAtRisk === 'number' && info?.type === 'sla-breached' && info.atRiskPercentage === undefined)
|
|
1679
|
+
info.atRiskPercentage = entry.breachedAtRisk;
|
|
1680
|
+
});
|
|
1606
1681
|
// The read SLA spelled `escalationRule: []`; `emitSla` omits an empty list.
|
|
1607
1682
|
if (sla.emptyEscalationRule === true && target && target.escalationRule === undefined)
|
|
1608
1683
|
target.escalationRule = [];
|
|
@@ -1656,6 +1731,9 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1656
1731
|
&& taskIdentity.resource.name === compiledRef.name && taskIdentity.resource.folderPath === compiledRef.folderPath;
|
|
1657
1732
|
const rowShape = (row) => (resourceKept ? row : { name: row.name });
|
|
1658
1733
|
take(task, taskIdentity.id);
|
|
1734
|
+
const elementIdRows = { saved: new Set(), matched: new Set() };
|
|
1735
|
+
if (task && stage && typeof taskIdentity.elementId === 'string')
|
|
1736
|
+
savedTaskElementIds.push({ stage, task, elementId: taskIdentity.elementId, rows: elementIdRows });
|
|
1659
1737
|
restoreEmptyLists(task, taskIdentity.emptyLists, TASK_EMPTY_LISTS);
|
|
1660
1738
|
takeConditions(task?.entryConditions, taskIdentity.entryConditions);
|
|
1661
1739
|
// An input row is matched by name when the name is unique on both sides
|
|
@@ -1667,12 +1745,34 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1667
1745
|
wantedInputs.forEach((row, index) => {
|
|
1668
1746
|
const byName = once(wantedInputs.map((r) => r.name), row.name) && once(inputRows.map((r) => r?.name), row.name);
|
|
1669
1747
|
const input = byName ? inputRows.find((r) => r?.name === row.name) : inputRows[index];
|
|
1748
|
+
if (input)
|
|
1749
|
+
elementIdRows.matched.add(input);
|
|
1750
|
+
if (input && row.taskElementId === true)
|
|
1751
|
+
elementIdRows.saved.add(input);
|
|
1670
1752
|
// An action form input is written `{ name, type, value }`; the Designer's
|
|
1671
1753
|
// row also has its id, `var` (the id) and `elementId`, which come back.
|
|
1672
|
-
if (task?.type === 'action' && input && input.id === undefined &&
|
|
1754
|
+
if (task?.type === 'action' && input && input.id === undefined && input.name === row.name) {
|
|
1755
|
+
// The fields the row was saved without: a `type` compile defaulted
|
|
1756
|
+
// to `string` (a type the source spells stays, `string` included),
|
|
1757
|
+
// and the `var` / `elementId` of a row with an id.
|
|
1758
|
+
const omit = new Set(row.omit ?? []);
|
|
1759
|
+
if (omit.has('type') && UNTYPED_ACTION_INPUT_ROWS.has(input))
|
|
1760
|
+
delete input.type;
|
|
1761
|
+
if (typeof row.id !== 'string') {
|
|
1762
|
+
// A row saved with no id keeps the `elementId` it had: its task's
|
|
1763
|
+
// (final once every id is), or the element it names.
|
|
1764
|
+
if (row.taskElementId === true)
|
|
1765
|
+
rowRenames.push(() => { if (typeof task.elementId === 'string')
|
|
1766
|
+
input.elementId = task.elementId; });
|
|
1767
|
+
else if (typeof row.elementId === 'string')
|
|
1768
|
+
input.elementId = row.elementId;
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1673
1771
|
Object.assign(input, { id: row.id, var: row.id, elementId: row.elementId ?? task.elementId });
|
|
1674
|
-
if (input.elementId === undefined)
|
|
1772
|
+
if (input.elementId === undefined || omit.has('elementId'))
|
|
1675
1773
|
delete input.elementId;
|
|
1774
|
+
if (omit.has('var'))
|
|
1775
|
+
delete input.var;
|
|
1676
1776
|
// The schema migration's readable alias of the id, which it stamps
|
|
1677
1777
|
// once and then skips the row on: the same id again.
|
|
1678
1778
|
if (row.canonicalId === true)
|
|
@@ -1692,7 +1792,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1692
1792
|
if (task && shapes.length)
|
|
1693
1793
|
customRowShapes.push({ task, shapes });
|
|
1694
1794
|
takeOutputRows(task?.data?.outputs ?? [], (taskIdentity.outputs ?? [])
|
|
1695
|
-
.map((row) => ({ ...row, ...(!isAction && !resourceKept ? { fields: undefined, omit: undefined } : {}) })), isAction);
|
|
1795
|
+
.map((row) => ({ ...row, ...(!isAction && !resourceKept ? { fields: undefined, omit: undefined } : {}) })), isAction, elementIdRows);
|
|
1696
1796
|
// Only on the kind the lists were saved on (`emptyIoType`; a payload from
|
|
1697
1797
|
// before it was recorded was written for resource tasks only), and never
|
|
1698
1798
|
// on a connector placeholder, whose `data: {}` is its contract (#1354).
|
|
@@ -1705,12 +1805,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1705
1805
|
}
|
|
1706
1806
|
const metadata = result.metadata;
|
|
1707
1807
|
takeConditions(metadata.caseExitRules, identities.caseExitRules);
|
|
1708
|
-
|
|
1709
|
-
const next = pending.filter((claim) => !claim());
|
|
1710
|
-
if (next.length === pending.length)
|
|
1711
|
-
break;
|
|
1712
|
-
pending = next;
|
|
1713
|
-
}
|
|
1808
|
+
settleDeferredClaims(deferredClaims, heldOutputIds, (target, row) => claimRowId(target, row, target.id));
|
|
1714
1809
|
takeSlas(metadata.slaRules, identities.slaRules);
|
|
1715
1810
|
restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
|
|
1716
1811
|
restoreSlaIds();
|
|
@@ -1820,6 +1915,21 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1820
1915
|
row.source = source;
|
|
1821
1916
|
for (const rename of rowRenames)
|
|
1822
1917
|
rename();
|
|
1918
|
+
// A task's saved `elementId` (a copied task's `Stage_old-tOld`) goes back on
|
|
1919
|
+
// the task, and on each of its rows that compile gave the `<stageId>-<taskId>`
|
|
1920
|
+
// it writes and that either was saved with the task's value or is new (an
|
|
1921
|
+
// edit added it, and it is wired to its task as compile means it to be). A
|
|
1922
|
+
// row saved with `<stageId>-<taskId>` keeps it, and so does one naming
|
|
1923
|
+
// another element (`root`).
|
|
1924
|
+
for (const { stage, task, elementId, rows } of savedTaskElementIds) {
|
|
1925
|
+
const written = `${stage.id}-${task.id}`;
|
|
1926
|
+
if (task.elementId !== written)
|
|
1927
|
+
continue;
|
|
1928
|
+
task.elementId = elementId;
|
|
1929
|
+
for (const row of [...(task.data?.inputs ?? []), ...(task.data?.outputs ?? [])])
|
|
1930
|
+
if (row?.elementId === written && (rows.saved.has(row) || !rows.matched.has(row)))
|
|
1931
|
+
row.elementId = elementId;
|
|
1932
|
+
}
|
|
1823
1933
|
settleOwnNameRows(result, stages, ownNameRestored, identities);
|
|
1824
1934
|
for (const spell of targetSpellings)
|
|
1825
1935
|
spell();
|
|
@@ -1907,6 +2017,14 @@ function applySubscriptionFilters(result, preservation) {
|
|
|
1907
2017
|
const sub = entry && written.find((candidate) => candidate.inputRow === row);
|
|
1908
2018
|
if (!entry || !sub)
|
|
1909
2019
|
continue;
|
|
2020
|
+
// The Designer's "no parameters" spelling, while compile still writes none.
|
|
2021
|
+
// `body: {}` takes the place of `value: ''`, so the row's other keys keep their order.
|
|
2022
|
+
if (entry.emptyBody && sub.inputRow.body === undefined && sub.inputRow.value === '') {
|
|
2023
|
+
const fields = Object.entries(sub.inputRow).map(([key, value]) => (key === 'value' ? ['body', {}] : [key, value]));
|
|
2024
|
+
for (const key of Object.keys(sub.inputRow))
|
|
2025
|
+
delete sub.inputRow[key];
|
|
2026
|
+
Object.assign(sub.inputRow, Object.fromEntries(fields));
|
|
2027
|
+
}
|
|
1910
2028
|
const computed = sub.conditions.some((c) => c.expression !== undefined);
|
|
1911
2029
|
const filters = sub.inputRow.body?.filters;
|
|
1912
2030
|
if (entry.emptyVariables && !computed && filters)
|
|
@@ -2216,6 +2334,84 @@ function emitTrigger(t, i, triggerId, resolver) {
|
|
|
2216
2334
|
function laneSets(lanes) {
|
|
2217
2335
|
return v31TaskSets(lanes, (task) => task.entry.some((condition) => condition.rules.some((group) => group.some((r) => r.rule === 'runs-sequentially'))));
|
|
2218
2336
|
}
|
|
2337
|
+
/**
|
|
2338
|
+
* Put a task's custom `{ assign }` output rows back between its other rows
|
|
2339
|
+
* where the plan was saved with them.
|
|
2340
|
+
*
|
|
2341
|
+
* Compile writes a task's own rows first (an action task's form fields, a
|
|
2342
|
+
* connector's `response` and `Error`), then the rows the source lists. Studio
|
|
2343
|
+
* Web can save a custom row ahead of an own row: an action task whose form
|
|
2344
|
+
* gained a field after the custom row was added saves the new field after it.
|
|
2345
|
+
* A custom row's value can read the rows listed before it, so moving it is a
|
|
2346
|
+
* change, not a spelling. For instance, saved as
|
|
2347
|
+
* [disputeFiled, disputeCount (custom), Action, Error]
|
|
2348
|
+
* compile writes [disputeFiled, Action, Error, disputeCount]; this puts
|
|
2349
|
+
* `disputeCount` back before `Action`.
|
|
2350
|
+
*
|
|
2351
|
+
* The payload's `outputs` list every saved row by name, in saved order. Only
|
|
2352
|
+
* the interleaving is restored: the custom rows keep the order compile wrote,
|
|
2353
|
+
* and so do the other rows. So when an edit reorders the source's outputs,
|
|
2354
|
+
* or the custom rows and the other rows disagree with the saved order in any
|
|
2355
|
+
* other way, compile's order stands. A row the payload does not name (one the
|
|
2356
|
+
* author added) stays where compile wrote it, and a task whose row names
|
|
2357
|
+
* repeat is left alone, since a name then names no single row. Nor is it
|
|
2358
|
+
* restored when an edited custom row would then read a row listed after it
|
|
2359
|
+
* (`readsALaterRow`).
|
|
2360
|
+
*/
|
|
2361
|
+
function restoreOutputInterleaving(result, identities) {
|
|
2362
|
+
const stages = result.nodes.filter((node) => String(node?.type).endsWith('Stage'));
|
|
2363
|
+
for (const stageIdentity of identities?.stages ?? []) {
|
|
2364
|
+
const stage = stages.find((candidate) => candidate.data?.label === stageIdentity.label);
|
|
2365
|
+
for (const taskIdentity of (stageIdentity.tasks ?? []).flat()) {
|
|
2366
|
+
const rows = stageTask(stage, taskIdentity.name)?.data?.outputs;
|
|
2367
|
+
const saved = (taskIdentity.outputs ?? []).map((row) => row.name);
|
|
2368
|
+
if (!Array.isArray(rows) || !saved.length)
|
|
2369
|
+
continue;
|
|
2370
|
+
const names = rows.map((row) => row?.name);
|
|
2371
|
+
if (new Set(names).size !== names.length || new Set(saved).size !== saved.length)
|
|
2372
|
+
continue;
|
|
2373
|
+
const kept = saved.filter((name) => names.includes(name));
|
|
2374
|
+
const isCustom = (name) => rows[names.indexOf(name)]?.custom === true;
|
|
2375
|
+
if (!kept.some(isCustom) || kept.every(isCustom))
|
|
2376
|
+
continue;
|
|
2377
|
+
const current = names.filter((name) => kept.includes(name));
|
|
2378
|
+
const same = (pick) => JSON.stringify(current.filter(pick)) === JSON.stringify(kept.filter(pick));
|
|
2379
|
+
if (!same(isCustom) || !same((name) => !isCustom(name)))
|
|
2380
|
+
continue;
|
|
2381
|
+
// The slots the kept rows hold now, filled in saved order.
|
|
2382
|
+
const slots = names.flatMap((name, index) => (kept.includes(name) ? [index] : []));
|
|
2383
|
+
const byName = new Map(rows.map((row) => [row.name, row]));
|
|
2384
|
+
const reordered = [...rows];
|
|
2385
|
+
slots.forEach((slot, i) => { reordered[slot] = byName.get(kept[i]); });
|
|
2386
|
+
if (readsALaterRow(reordered, taskIdentity.outputs ?? []))
|
|
2387
|
+
continue;
|
|
2388
|
+
rows.splice(0, rows.length, ...reordered);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* Whether restored order `rows` puts an edited custom row ahead of a row its
|
|
2394
|
+
* source names. A custom row's value reads the rows listed before it, so a
|
|
2395
|
+
* fresh build (custom rows last) has it read every own row. A custom row
|
|
2396
|
+
* still assigning its saved source (`savedSource`) reads what it read when
|
|
2397
|
+
* saved, in its saved place. One edited to read a row the saved order lists
|
|
2398
|
+
* after it does not, and keeps compile's order. For instance, saved as
|
|
2399
|
+
* [approved, decision (custom, `=approved`), note], an edit to
|
|
2400
|
+
* `decision: { assign: "=note" }` would restore to
|
|
2401
|
+
* [approved, decision, note], with `decision` reading `note` before it is
|
|
2402
|
+
* written; compile's [approved, note, decision] stands.
|
|
2403
|
+
* A row is named by its `var` or `name` as an identifier in the source.
|
|
2404
|
+
*/
|
|
2405
|
+
function readsALaterRow(rows, saved) {
|
|
2406
|
+
return rows.some((row, index) => {
|
|
2407
|
+
if (row?.custom !== true || typeof row.source !== 'string')
|
|
2408
|
+
return false;
|
|
2409
|
+
if (saved.find((entry) => entry.name === row.name)?.savedSource === row.source)
|
|
2410
|
+
return false;
|
|
2411
|
+
const names = new Set(row.source.match(/[A-Za-z_$][\w$]*/g) ?? []);
|
|
2412
|
+
return rows.slice(index + 1).some((later) => later?.custom !== true && [later?.var, later?.name].some((name) => typeof name === 'string' && names.has(name)));
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2219
2415
|
/** One emitted task of a stage node, by its (case-unique) display name, in any set. */
|
|
2220
2416
|
function stageTask(stage, name) {
|
|
2221
2417
|
for (const lane of stage?.data?.tasks ?? [])
|
|
@@ -2232,7 +2428,7 @@ function emitStage(stage, lanes, si, stageId, laneTaskIds, ids, resolver) {
|
|
|
2232
2428
|
isPendingParent: false,
|
|
2233
2429
|
tasks: lanes.map((lane, li) => lane.map((task, ti) => emitTask(task, stage.label, laneTaskIds[li][ti], ids, resolver))),
|
|
2234
2430
|
};
|
|
2235
|
-
if (stage.description)
|
|
2431
|
+
if (stage.description !== undefined)
|
|
2236
2432
|
data.description = stage.description;
|
|
2237
2433
|
if (stage.required !== undefined)
|
|
2238
2434
|
data.isRequired = stage.required;
|
|
@@ -2598,6 +2794,8 @@ function caseEventFilterReads(filters, kind) {
|
|
|
2598
2794
|
*/
|
|
2599
2795
|
function emitActionField(f, outputElementId, resolver) {
|
|
2600
2796
|
const row = { name: f.name, type: f.type ?? 'string' };
|
|
2797
|
+
if (outputElementId === undefined && f.type === undefined)
|
|
2798
|
+
UNTYPED_ACTION_INPUT_ROWS.add(row);
|
|
2601
2799
|
if (f.subType !== undefined)
|
|
2602
2800
|
row.subType = f.subType;
|
|
2603
2801
|
if (f.displayName !== undefined)
|
|
@@ -2861,6 +3059,13 @@ function isSdkOutputSlotId(id, variable) {
|
|
|
2861
3059
|
return false;
|
|
2862
3060
|
return SDK_OUTPUT_SLOT_ID.test(id);
|
|
2863
3061
|
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Action form input rows whose source spells no `type`, which compile writes
|
|
3064
|
+
* as `string`. Only these lose the `type` a row was saved without
|
|
3065
|
+
* (`omit: ['type']`): `{ name: 'Customer', type: 'string' }` typed in the
|
|
3066
|
+
* source keeps it.
|
|
3067
|
+
*/
|
|
3068
|
+
const UNTYPED_ACTION_INPUT_ROWS = new WeakSet();
|
|
2864
3069
|
/** Action form output rows whose variable is the author's explicit `value`; see applyPreservedIdentities. */
|
|
2865
3070
|
const NAMED_ACTION_OUTPUT_ROWS = new WeakSet();
|
|
2866
3071
|
/** Rows `emitTaskOutput` wrote in the own-name shape (`id == var`); see applyPreservedIdentities. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.120.
|
|
3
|
+
"version": "6.120.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",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"@types/node": "^22.7.0",
|
|
125
125
|
"esbuild": "^0.28.1"
|
|
126
126
|
},
|
|
127
|
-
"gitref": "
|
|
127
|
+
"gitref": "100acc44efeb5f552ad50a399162c41d714be9ea"
|
|
128
128
|
}
|