@uipath/maestro-builder-sdk 6.120.4 → 6.120.6
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-rows.d.ts +10 -3
- package/dist/case/connector-saved-rows.js +37 -18
- package/dist/case/decompile.d.ts +1 -0
- package/dist/case/decompile.js +86 -15
- package/dist/case/preserve.d.ts +29 -1
- package/dist/case/preserve.js +11 -5
- package/dist/case/serialize.js +263 -30
- package/package.json +2 -2
|
@@ -33,17 +33,24 @@ export interface PreservedConnectorRows {
|
|
|
33
33
|
* `execute-connector-activity` task. A task is keyed by its own id, not its
|
|
34
34
|
* stage's: a task moved to another stage keeps its element ids, and its rows
|
|
35
35
|
* with them.
|
|
36
|
+
*
|
|
37
|
+
* `elementIds` are the spellings of the element's own id a row may carry:
|
|
38
|
+
* the one compile writes (the trigger's node id, else `<stage id>-<task or
|
|
39
|
+
* rule id>`), and an older SDK's bare task or rule id, which compile repairs
|
|
40
|
+
* (#1426).
|
|
36
41
|
*/
|
|
37
42
|
export declare function caseConnectorRowOwners(plan: Record<string, any>): Array<{
|
|
38
43
|
key: string;
|
|
39
44
|
bag: Record<string, any>;
|
|
45
|
+
elementIds: string[];
|
|
40
46
|
}>;
|
|
41
47
|
/**
|
|
42
48
|
* The saved own rows of a connector element, for each half compile would not
|
|
43
|
-
* write as it is: a row in another shape, a row missing,
|
|
44
|
-
*
|
|
49
|
+
* write as it is: a row in another shape, a row missing, a row that names
|
|
50
|
+
* another element (not one of `elementIds`, its own id's spellings), or no such
|
|
51
|
+
* field. Else `undefined`.
|
|
45
52
|
*/
|
|
46
|
-
export declare function savedConnectorRows(owner: string, bag: Record<string, any
|
|
53
|
+
export declare function savedConnectorRows(owner: string, bag: Record<string, any>, elementIds?: readonly string[]): PreservedConnectorRows | undefined;
|
|
47
54
|
/**
|
|
48
55
|
* Write each element's saved own rows back over the ones compile built, half
|
|
49
56
|
* by half, while they still describe the element. Runs after the ids are
|
|
@@ -69,17 +69,28 @@ const isObject = (value) => !!value && typeof value === 'object' && !Array.isArr
|
|
|
69
69
|
* `execute-connector-activity` task. A task is keyed by its own id, not its
|
|
70
70
|
* stage's: a task moved to another stage keeps its element ids, and its rows
|
|
71
71
|
* with them.
|
|
72
|
+
*
|
|
73
|
+
* `elementIds` are the spellings of the element's own id a row may carry:
|
|
74
|
+
* the one compile writes (the trigger's node id, else `<stage id>-<task or
|
|
75
|
+
* rule id>`), and an older SDK's bare task or rule id, which compile repairs
|
|
76
|
+
* (#1426).
|
|
72
77
|
*/
|
|
73
78
|
export function caseConnectorRowOwners(plan) {
|
|
74
|
-
const out = caseSubscriptionOwners(plan)
|
|
75
|
-
|
|
79
|
+
const out = caseSubscriptionOwners(plan).map(({ key, bag }) => {
|
|
80
|
+
const [kind, ...rest] = key.split(':');
|
|
81
|
+
if (kind === 'trigger')
|
|
82
|
+
return { key, bag, elementIds: [rest.join(':')] };
|
|
83
|
+
const [stageId, ...own] = rest;
|
|
84
|
+
const ownId = own.join(':');
|
|
85
|
+
return { key: kind === 'task' ? `task:${ownId}` : key, bag, elementIds: [`${stageId}-${ownId}`, ownId] };
|
|
86
|
+
});
|
|
76
87
|
for (const node of Array.isArray(plan?.nodes) ? plan.nodes : []) {
|
|
77
88
|
if (!String(node?.type ?? '').endsWith('Stage'))
|
|
78
89
|
continue;
|
|
79
90
|
for (const lane of Array.isArray(node.data?.tasks) ? node.data.tasks : [])
|
|
80
91
|
for (const task of Array.isArray(lane) ? lane : [])
|
|
81
92
|
if (task?.type === CONNECTOR_ACTIVITY_TYPE && isObject(task.data))
|
|
82
|
-
out.push({ key: `task:${task.id}`, bag: task.data });
|
|
93
|
+
out.push({ key: `task:${task.id}`, bag: task.data, elementIds: [`${node.id}-${task.id}`, String(task.id)] });
|
|
83
94
|
}
|
|
84
95
|
return out;
|
|
85
96
|
}
|
|
@@ -140,8 +151,10 @@ function sdkSchema(schema) {
|
|
|
140
151
|
};
|
|
141
152
|
return node(schema);
|
|
142
153
|
}
|
|
143
|
-
/** Whether
|
|
144
|
-
|
|
154
|
+
/** Whether a row's `elementId` names its own element (`elementIds`), when those are known. */
|
|
155
|
+
const ownElement = (row, elementIds) => typeof row.elementId === 'string' && (elementIds === undefined || elementIds.includes(row.elementId));
|
|
156
|
+
/** Whether compile could have written output `row` as it is (`connectorOutputs`) on its element (`elementIds`). */
|
|
157
|
+
function sdkShapedOutput(row, elementIds) {
|
|
145
158
|
if (!Object.keys(row).every((key) => SDK_OUTPUT_FIELDS.has(key)))
|
|
146
159
|
return false;
|
|
147
160
|
const error = row.source === '=Error';
|
|
@@ -149,22 +162,27 @@ function sdkShapedOutput(row) {
|
|
|
149
162
|
return false;
|
|
150
163
|
if (typeof row.var !== 'string' || row.id !== row.var || row.value !== row.var || row.target !== `=${row.var}`)
|
|
151
164
|
return false;
|
|
152
|
-
if (
|
|
165
|
+
if (!ownElement(row, elementIds))
|
|
153
166
|
return false;
|
|
154
167
|
return error ? stable(row.body) === ERROR_SCHEMA : sdkSchema(row.body);
|
|
155
168
|
}
|
|
156
|
-
/**
|
|
157
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Whether compile could have written input `row` as it is (`ioSlot`, `fileSlot`,
|
|
171
|
+
* `eventInput`) on its element (`elementIds`). A row whose `elementId` names another
|
|
172
|
+
* element is the Designer's: a copied rule keeps the rows of the rule it was
|
|
173
|
+
* copied from, `elementId` and all, and compile would point them at the copy.
|
|
174
|
+
*/
|
|
175
|
+
function sdkShapedInput(row, elementIds) {
|
|
158
176
|
if (!Object.keys(row).every((key) => SDK_INPUT_FIELDS.has(key)))
|
|
159
177
|
return false;
|
|
160
|
-
if (typeof row.var !== 'string' || row.id !== row.var ||
|
|
178
|
+
if (typeof row.var !== 'string' || row.id !== row.var || !ownElement(row, elementIds))
|
|
161
179
|
return false;
|
|
162
180
|
if (row.type === 'file')
|
|
163
181
|
return row.target === 'file' && row.body === undefined;
|
|
164
182
|
return row.type === 'json' && row.target === row.name && (row.body !== undefined) !== (row.value !== undefined);
|
|
165
183
|
}
|
|
166
184
|
/** The saved outputs half, when compile would not write it as it is. */
|
|
167
|
-
function savedOutputs(bag) {
|
|
185
|
+
function savedOutputs(bag, elementIds) {
|
|
168
186
|
if (bag.outputs !== undefined && !Array.isArray(bag.outputs))
|
|
169
187
|
return undefined;
|
|
170
188
|
const rows = (bag.outputs ?? []).filter(isOwnOutput);
|
|
@@ -174,12 +192,12 @@ function savedOutputs(bag) {
|
|
|
174
192
|
if (sources.size !== rows.length)
|
|
175
193
|
return undefined;
|
|
176
194
|
const complete = rows.length === 2 && sources.size === 2;
|
|
177
|
-
if (bag.outputs !== undefined && complete && rows.every(sdkShapedOutput))
|
|
195
|
+
if (bag.outputs !== undefined && complete && rows.every((row) => sdkShapedOutput(row, elementIds)))
|
|
178
196
|
return undefined;
|
|
179
197
|
return { rows: structuredClone(rows), ...(bag.outputs === undefined ? { absent: true } : {}) };
|
|
180
198
|
}
|
|
181
199
|
/** The saved inputs half, when compile would not write it as it is. */
|
|
182
|
-
function savedInputs(bag, activity) {
|
|
200
|
+
function savedInputs(bag, activity, elementIds) {
|
|
183
201
|
if (bag.inputs !== undefined && !Array.isArray(bag.inputs))
|
|
184
202
|
return undefined;
|
|
185
203
|
const rows = bag.inputs ?? [];
|
|
@@ -190,22 +208,23 @@ function savedInputs(bag, activity) {
|
|
|
190
208
|
if (names.size !== rows.length)
|
|
191
209
|
return undefined;
|
|
192
210
|
const complete = activity ? ACTIVITY_CONTAINERS.every((name) => names.has(name)) : rows.length === 1;
|
|
193
|
-
if (bag.inputs !== undefined && complete && rows.every(sdkShapedInput))
|
|
211
|
+
if (bag.inputs !== undefined && complete && rows.every((row) => sdkShapedInput(row, elementIds)))
|
|
194
212
|
return undefined;
|
|
195
213
|
return { rows: structuredClone(rows), ...(bag.inputs === undefined ? { absent: true } : {}) };
|
|
196
214
|
}
|
|
197
215
|
/**
|
|
198
216
|
* The saved own rows of a connector element, for each half compile would not
|
|
199
|
-
* write as it is: a row in another shape, a row missing,
|
|
200
|
-
*
|
|
217
|
+
* write as it is: a row in another shape, a row missing, a row that names
|
|
218
|
+
* another element (not one of `elementIds`, its own id's spellings), or no such
|
|
219
|
+
* field. Else `undefined`.
|
|
201
220
|
*/
|
|
202
|
-
export function savedConnectorRows(owner, bag) {
|
|
221
|
+
export function savedConnectorRows(owner, bag, elementIds) {
|
|
203
222
|
const operation = operationOf(bag);
|
|
204
223
|
if (operation.connectorKey === undefined)
|
|
205
224
|
return undefined;
|
|
206
225
|
const activity = bag.serviceType !== 'Intsvc.EventTrigger' && bag.serviceType !== 'Intsvc.WaitForEvent';
|
|
207
|
-
const outputs = savedOutputs(bag);
|
|
208
|
-
const inputs = savedInputs(bag, activity);
|
|
226
|
+
const outputs = savedOutputs(bag, elementIds);
|
|
227
|
+
const inputs = savedInputs(bag, activity, elementIds);
|
|
209
228
|
const extracts = savedExtracts(bag);
|
|
210
229
|
if (!outputs && !inputs && !extracts)
|
|
211
230
|
return undefined;
|
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
|
|
@@ -1047,6 +1057,14 @@ function connectorInputs(slots, resolved, owner, task) {
|
|
|
1047
1057
|
if (!body || typeof body !== 'object' || Array.isArray(body)) {
|
|
1048
1058
|
if (owner)
|
|
1049
1059
|
throw new Error(`${owner} input container "${name}" must carry an object body.`);
|
|
1060
|
+
// A container saved as one value, not fields: a whole-body expression,
|
|
1061
|
+
// `{ name: 'body', body: '=js:({ "id": vars.x })' }`. The SDK names a
|
|
1062
|
+
// connector's inputs field by field, so it has nowhere to put it, and
|
|
1063
|
+
// compile would write the container empty: refuse, never drop.
|
|
1064
|
+
if (hasAuthoredValue(body))
|
|
1065
|
+
throw new Error(`${who} input container "${name}" is saved as one ${typeof body === 'string' ? 'expression' : 'value'}, ` +
|
|
1066
|
+
`not as fields; the SDK sets a connector's inputs field by field, so decompile cannot lift it and the value would be lost. ` +
|
|
1067
|
+
'In Studio Web, set the fields one by one instead of the whole container, then decompile the saved plan.');
|
|
1050
1068
|
continue;
|
|
1051
1069
|
}
|
|
1052
1070
|
for (const [wireName, value] of Object.entries(body)) {
|
|
@@ -1441,6 +1459,16 @@ function outputTargetOf(row) {
|
|
|
1441
1459
|
*
|
|
1442
1460
|
* A custom (`{ assign }`) output has its own spelling and is not handled here.
|
|
1443
1461
|
*/
|
|
1462
|
+
/**
|
|
1463
|
+
* A resource task output's saved `value` when it is not its `var`, the value
|
|
1464
|
+
* compile writes (`{ id: 'error2', var: 'error2', value: 'error' }`): carried
|
|
1465
|
+
* with the `var` it was saved beside (preserve.ts, `value` on an output row).
|
|
1466
|
+
*/
|
|
1467
|
+
function resourceOutputValue(task, row) {
|
|
1468
|
+
if (!ownEntry(TASK_KIND_METHOD, task.type) || row.custom === true || typeof row.var !== 'string')
|
|
1469
|
+
return {};
|
|
1470
|
+
return row.value === undefined || row.value === row.var ? {} : { value: { value: structuredClone(row.value), var: row.var } };
|
|
1471
|
+
}
|
|
1444
1472
|
function resourceRowShape(task, row, side) {
|
|
1445
1473
|
if (!ownEntry(TASK_KIND_METHOD, task.type) || row.custom === true)
|
|
1446
1474
|
return {};
|
|
@@ -1655,16 +1683,15 @@ function taskOutputRows(task) {
|
|
|
1655
1683
|
}
|
|
1656
1684
|
/**
|
|
1657
1685
|
* Refuse, naming the task and the row, a plan whose output rows a recompile
|
|
1658
|
-
* would not write back
|
|
1659
|
-
*
|
|
1686
|
+
* would not write back (`docs/CASE_DECOMPILE_DESIGN.md`, refusal boundary;
|
|
1687
|
+
* #1457): a row in neither `taskOutputRows` list would vanish with no message.
|
|
1688
|
+
* For instance a result-field extract `{ var: 'route', source: '=approved' }` on
|
|
1689
|
+
* a wait-for-timer task, which has no result to read and no SDK form for it.
|
|
1660
1690
|
*
|
|
1661
|
-
*
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1664
|
-
*
|
|
1665
|
-
* connector's `response`) would come back after it. A custom row reads only
|
|
1666
|
-
* the rows before it, so its value could change. An extract reads the task's
|
|
1667
|
-
* result, so where it is listed does not matter.
|
|
1691
|
+
* A custom row listed before one of the task's own rows (ahead of a
|
|
1692
|
+
* connector's `Error`) is not refused: compile writes the own rows first, and
|
|
1693
|
+
* puts the custom row back in its saved place from the payload's row order
|
|
1694
|
+
* (`restoreOutputInterleaving` in serialize.ts).
|
|
1668
1695
|
*/
|
|
1669
1696
|
function refuseUnwrittenOutputs(task, plan) {
|
|
1670
1697
|
const rows = Array.isArray(task.data?.outputs) ? task.data.outputs : [];
|
|
@@ -1673,10 +1700,6 @@ function refuseUnwrittenOutputs(task, plan) {
|
|
|
1673
1700
|
const lost = rows.find((row) => !plan.lifted.includes(row) && !plan.rebuilt.includes(row));
|
|
1674
1701
|
if (lost)
|
|
1675
1702
|
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.`);
|
|
1676
|
-
const firstCustom = rows.findIndex((row) => row.custom === true && plan.lifted.includes(row));
|
|
1677
|
-
const lateOwn = firstCustom < 0 ? undefined : rows.slice(firstCustom).find((row) => plan.rebuilt.includes(row));
|
|
1678
|
-
if (lateOwn)
|
|
1679
|
-
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.`);
|
|
1680
1703
|
}
|
|
1681
1704
|
function escalationSource(escalation, slaName, index) {
|
|
1682
1705
|
if (escalation.action?.type !== 'notification')
|
|
@@ -2394,14 +2417,42 @@ function prunePreservation(preservation, plan) {
|
|
|
2394
2417
|
* input as `{ name, type, value }`; the Designer also gives it `var` (its id)
|
|
2395
2418
|
* and `elementId` (the task's), which compile restores from the id. Only an
|
|
2396
2419
|
* `elementId` that is not the task's is carried.
|
|
2420
|
+
*
|
|
2421
|
+
* The rows the Designer saves are not all that shape, and what is saved is
|
|
2422
|
+
* carried, so the plan comes back as it was:
|
|
2423
|
+
* - `omit`: the fields compile writes that the row was saved without: `type`
|
|
2424
|
+
* (read as `string`), and, on a row with an id, `var` and `elementId`
|
|
2425
|
+
* (`{ id: 'purchaseOrder', name, type, value }` stays without them).
|
|
2426
|
+
* - A row with no id keeps the `elementId` it was saved with:
|
|
2427
|
+
* `taskElementId: true` when it is the task's, with the meaning it has on
|
|
2428
|
+
* any io row (`rowHoldsSavedTaskElementId`): the row was saved with its
|
|
2429
|
+
* task's `elementId`, and compile writes back the task's final one. Compile
|
|
2430
|
+
* writes such a row with no `elementId`, so it is recorded even when the
|
|
2431
|
+
* task's `elementId` is the `<stageId>-<taskId>` compile writes. Any other
|
|
2432
|
+
* `elementId` is carried as the value itself.
|
|
2397
2433
|
*/
|
|
2398
2434
|
function actionInputShape(task, row) {
|
|
2399
|
-
if (task.type !== 'action'
|
|
2435
|
+
if (task.type !== 'action')
|
|
2400
2436
|
return {};
|
|
2437
|
+
const omit = [];
|
|
2438
|
+
if (row.type === undefined)
|
|
2439
|
+
omit.push('type');
|
|
2440
|
+
if (!row.id) {
|
|
2441
|
+
const own = row.elementId !== undefined && row.elementId === task.elementId;
|
|
2442
|
+
return {
|
|
2443
|
+
...(own ? { taskElementId: true } : row.elementId !== undefined ? { elementId: row.elementId } : {}),
|
|
2444
|
+
...(omit.length ? { omit } : {}),
|
|
2445
|
+
};
|
|
2446
|
+
}
|
|
2447
|
+
if (row.var === undefined)
|
|
2448
|
+
omit.push('var');
|
|
2449
|
+
if (row.elementId === undefined)
|
|
2450
|
+
omit.push('elementId');
|
|
2401
2451
|
return {
|
|
2402
2452
|
...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
|
|
2403
2453
|
// `actionFields` has checked it is a copy of the id.
|
|
2404
2454
|
...(row.canonicalId !== undefined ? { canonicalId: true } : {}),
|
|
2455
|
+
...(omit.length ? { omit } : {}),
|
|
2405
2456
|
};
|
|
2406
2457
|
}
|
|
2407
2458
|
/**
|
|
@@ -2518,6 +2569,24 @@ function customRowIdentity(task, row, plan) {
|
|
|
2518
2569
|
const shape = customRowShape(row, carriedApart, varRows);
|
|
2519
2570
|
return shape ? { customRow: shape } : {};
|
|
2520
2571
|
}
|
|
2572
|
+
/**
|
|
2573
|
+
* The saved `source` of a custom row listed before one of its task's other
|
|
2574
|
+
* (not custom) rows, which compile writes after them. Compile puts the row
|
|
2575
|
+
* back in its saved place (`restoreOutputInterleaving`), and checks this
|
|
2576
|
+
* source there: a row edited to read a row it would then precede keeps
|
|
2577
|
+
* compile's order. For instance, an action task saved as
|
|
2578
|
+
* [approved, decision (custom, `=approved`), note] records
|
|
2579
|
+
* `savedSource: '=approved'` on `decision`.
|
|
2580
|
+
*/
|
|
2581
|
+
function interleavedCustomSource(task, row) {
|
|
2582
|
+
if (row.custom !== true)
|
|
2583
|
+
return {};
|
|
2584
|
+
const rows = task.data?.outputs ?? [];
|
|
2585
|
+
const at = rows.indexOf(row);
|
|
2586
|
+
if (!rows.slice(at + 1).some((other) => other?.custom !== true))
|
|
2587
|
+
return {};
|
|
2588
|
+
return { savedSource: typeof row.source === 'string' ? row.source : '' };
|
|
2589
|
+
}
|
|
2521
2590
|
/** Whether a plan declaring `version` keeps its custom rows' saved `elementId` on read (V32.0.3 and later). */
|
|
2522
2591
|
function customElementIdIsOwn(version) {
|
|
2523
2592
|
return typeof version === 'string' && /^\d+\.\d+\.\d+$/.test(version) && compareSchemaVersions(version, '32.0.3') >= 0;
|
|
@@ -2569,7 +2638,9 @@ function identityPreservation(plan) {
|
|
|
2569
2638
|
...unaliasedOwnNameRow(row, plan),
|
|
2570
2639
|
...actionOutputShape(task, row),
|
|
2571
2640
|
...resourceRowShape(task, row, 'outputs'),
|
|
2641
|
+
...resourceOutputValue(task, row),
|
|
2572
2642
|
...customRowIdentity(task, row, plan),
|
|
2643
|
+
...interleavedCustomSource(task, row),
|
|
2573
2644
|
...rowHoldsSavedTaskElementId(stage, task, row),
|
|
2574
2645
|
})),
|
|
2575
2646
|
...emptyIoLists(task),
|
|
@@ -2969,7 +3040,7 @@ export function collectPreservation(plan) {
|
|
|
2969
3040
|
if (connectorConfigV2.length)
|
|
2970
3041
|
preservation.connectorConfigV2 = connectorConfigV2;
|
|
2971
3042
|
const connectorRows = caseConnectorRowOwners(plan)
|
|
2972
|
-
.map(({ key, bag }) => savedConnectorRows(key, bag))
|
|
3043
|
+
.map(({ key, bag, elementIds }) => savedConnectorRows(key, bag, elementIds))
|
|
2973
3044
|
.filter((entry) => entry !== undefined);
|
|
2974
3045
|
if (connectorRows.length)
|
|
2975
3046
|
preservation.connectorRows = connectorRows;
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -236,12 +236,14 @@ interface StageIdentity {
|
|
|
236
236
|
/** The resource the rows' `fields` / `omit` describe; they are applied only while the task still names it. */
|
|
237
237
|
resource?: ResourceTaskIdentity;
|
|
238
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. */
|
|
239
240
|
inputs?: Array<{
|
|
240
241
|
name: string;
|
|
241
242
|
id?: string;
|
|
242
243
|
elementId?: string;
|
|
243
244
|
canonicalId?: true;
|
|
244
245
|
fields?: Record<string, unknown>;
|
|
246
|
+
omit?: string[];
|
|
245
247
|
taskElementId?: true;
|
|
246
248
|
}>;
|
|
247
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. */
|
|
@@ -335,8 +337,27 @@ export interface PreservedOutputRow {
|
|
|
335
337
|
custom?: true;
|
|
336
338
|
noAlias?: true;
|
|
337
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;
|
|
338
348
|
/** The row was saved with its task's carried `elementId` (see `elementId` on the task identity). */
|
|
339
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
|
+
};
|
|
340
361
|
}
|
|
341
362
|
/**
|
|
342
363
|
* Non-authoring Case JSON lanes retained by decompile/recompile.
|
|
@@ -611,7 +632,8 @@ export interface CaseJsonPreservation {
|
|
|
611
632
|
* One subscription's Designer-owned filter state. Only what compile would not
|
|
612
633
|
* write itself is recorded: `expression: 'inline'` (the older `${…}` template,
|
|
613
634
|
* no `filters.variables`), `leaf: 'js'` (a `=js:(…)` tree value),
|
|
614
|
-
* `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
|
|
615
637
|
* tree's own ids when Studio Web minted them (`uuId`, and each leaf's `uiId`
|
|
616
638
|
* with the condition it filters on).
|
|
617
639
|
*/
|
|
@@ -640,6 +662,12 @@ export interface PreservedSubscriptionFilter {
|
|
|
640
662
|
leaf?: 'js';
|
|
641
663
|
/** The plan saved a literal-only filter with an empty `filters.variables` map (older Studio Web builds). */
|
|
642
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;
|
|
643
671
|
/** The tree's `uuId`. */
|
|
644
672
|
uuId?: string | null;
|
|
645
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
|
@@ -186,8 +186,7 @@ function collected(resolver, where, nodeId, emit, standIn) {
|
|
|
186
186
|
/** The root companions a stand-in's authored outputs need, the way an emitted node registers them. */
|
|
187
187
|
function standInCompanions(resolver, outputs) {
|
|
188
188
|
for (const o of outputs ?? [])
|
|
189
|
-
|
|
190
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
189
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
191
190
|
}
|
|
192
191
|
/**
|
|
193
192
|
* The value an author wrote, as plain JSON, for a stand-in. Deterministic, so
|
|
@@ -222,6 +221,7 @@ function serializeCase(built, opts) {
|
|
|
222
221
|
offlineBindingIds: new Map(),
|
|
223
222
|
varCompanions: new Map(),
|
|
224
223
|
ownNameRows: new Map(),
|
|
224
|
+
firstWriters: new Map(),
|
|
225
225
|
// A carried task's saved output rows keep their ids: no other row takes one.
|
|
226
226
|
outputIds: new Set(savedOutputIds(caseJsonPreservation(built)?.documentExtractionData)),
|
|
227
227
|
savedDocumentExtractions: pairSavedDocumentExtractions(carriedDocumentExtractionTasks(built), caseJsonPreservation(built)?.documentExtractionData),
|
|
@@ -392,8 +392,8 @@ function serializeCase(built, opts) {
|
|
|
392
392
|
const variables = emitVariables(built.vars, ids, triggerNodeByRef, triggerNodes, built.triggers, resolver.collect);
|
|
393
393
|
const inputOutputs = variables.inputOutputs;
|
|
394
394
|
const declared = new Set(inputOutputs.map((e) => e.id));
|
|
395
|
-
for (const
|
|
396
|
-
if (!declared.has(
|
|
395
|
+
for (const companion of orderedCompanions(resolver))
|
|
396
|
+
if (!declared.has(companion.id))
|
|
397
397
|
inputOutputs.push(companion);
|
|
398
398
|
// An own-name row that writes a variable which DOES have a root entry (a
|
|
399
399
|
// declared `.var()`, or a companion another, reassigned, writer needed) is the
|
|
@@ -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)
|
|
@@ -1524,6 +1578,13 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1524
1578
|
elementIdRows?.matched.add(target);
|
|
1525
1579
|
if (target && row.taskElementId === true)
|
|
1526
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); });
|
|
1527
1588
|
// An action form output the Designer saved with no `target` (or no
|
|
1528
1589
|
// `_jsonSchema` copy of its body, or no `elementId`) keeps none, and one
|
|
1529
1590
|
// whose `elementId` names another element keeps that.
|
|
@@ -1538,7 +1599,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1538
1599
|
target.jsonSchema = structuredClone(target.body); });
|
|
1539
1600
|
carryRowShape(target, row);
|
|
1540
1601
|
if (!claimRowId(target, row, currentId))
|
|
1541
|
-
deferredClaims.push(
|
|
1602
|
+
deferredClaims.push({ target, row });
|
|
1542
1603
|
});
|
|
1543
1604
|
};
|
|
1544
1605
|
const takeConditions = (current, wanted) => {
|
|
@@ -1690,10 +1751,28 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1690
1751
|
elementIdRows.saved.add(input);
|
|
1691
1752
|
// An action form input is written `{ name, type, value }`; the Designer's
|
|
1692
1753
|
// row also has its id, `var` (the id) and `elementId`, which come back.
|
|
1693
|
-
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
|
+
}
|
|
1694
1771
|
Object.assign(input, { id: row.id, var: row.id, elementId: row.elementId ?? task.elementId });
|
|
1695
|
-
if (input.elementId === undefined)
|
|
1772
|
+
if (input.elementId === undefined || omit.has('elementId'))
|
|
1696
1773
|
delete input.elementId;
|
|
1774
|
+
if (omit.has('var'))
|
|
1775
|
+
delete input.var;
|
|
1697
1776
|
// The schema migration's readable alias of the id, which it stamps
|
|
1698
1777
|
// once and then skips the row on: the same id again.
|
|
1699
1778
|
if (row.canonicalId === true)
|
|
@@ -1726,12 +1805,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1726
1805
|
}
|
|
1727
1806
|
const metadata = result.metadata;
|
|
1728
1807
|
takeConditions(metadata.caseExitRules, identities.caseExitRules);
|
|
1729
|
-
|
|
1730
|
-
const next = pending.filter((claim) => !claim());
|
|
1731
|
-
if (next.length === pending.length)
|
|
1732
|
-
break;
|
|
1733
|
-
pending = next;
|
|
1734
|
-
}
|
|
1808
|
+
settleDeferredClaims(deferredClaims, heldOutputIds, (target, row) => claimRowId(target, row, target.id));
|
|
1735
1809
|
takeSlas(metadata.slaRules, identities.slaRules);
|
|
1736
1810
|
restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
|
|
1737
1811
|
restoreSlaIds();
|
|
@@ -1878,6 +1952,7 @@ function applyPreservedIdentities(result, preservation, warn) {
|
|
|
1878
1952
|
held.add(row.id);
|
|
1879
1953
|
}
|
|
1880
1954
|
}
|
|
1955
|
+
dropOwnVariableCompanions(result, stages, nodes, identities);
|
|
1881
1956
|
}
|
|
1882
1957
|
// An id hashed from a generated element id is re-minted from the preserved one,
|
|
1883
1958
|
// wherever it is spelled, including inside a `=jsonString:` configuration.
|
|
@@ -1943,6 +2018,14 @@ function applySubscriptionFilters(result, preservation) {
|
|
|
1943
2018
|
const sub = entry && written.find((candidate) => candidate.inputRow === row);
|
|
1944
2019
|
if (!entry || !sub)
|
|
1945
2020
|
continue;
|
|
2021
|
+
// The Designer's "no parameters" spelling, while compile still writes none.
|
|
2022
|
+
// `body: {}` takes the place of `value: ''`, so the row's other keys keep their order.
|
|
2023
|
+
if (entry.emptyBody && sub.inputRow.body === undefined && sub.inputRow.value === '') {
|
|
2024
|
+
const fields = Object.entries(sub.inputRow).map(([key, value]) => (key === 'value' ? ['body', {}] : [key, value]));
|
|
2025
|
+
for (const key of Object.keys(sub.inputRow))
|
|
2026
|
+
delete sub.inputRow[key];
|
|
2027
|
+
Object.assign(sub.inputRow, Object.fromEntries(fields));
|
|
2028
|
+
}
|
|
1946
2029
|
const computed = sub.conditions.some((c) => c.expression !== undefined);
|
|
1947
2030
|
const filters = sub.inputRow.body?.filters;
|
|
1948
2031
|
if (entry.emptyVariables && !computed && filters)
|
|
@@ -2234,8 +2317,7 @@ function emitTrigger(t, i, triggerId, resolver) {
|
|
|
2234
2317
|
if (t.eventOutputs?.length) {
|
|
2235
2318
|
const outputs = t.eventOutputs.map((o) => {
|
|
2236
2319
|
const field = o.source.replace(/^=/, '').split('.').pop() || o.source;
|
|
2237
|
-
|
|
2238
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
2320
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
2239
2321
|
return { name: field, var: o.var, source: o.source, type: o.type, value: o.var };
|
|
2240
2322
|
});
|
|
2241
2323
|
bag.outputs = [...(bag.outputs ?? []), ...outputs];
|
|
@@ -2252,6 +2334,84 @@ function emitTrigger(t, i, triggerId, resolver) {
|
|
|
2252
2334
|
function laneSets(lanes) {
|
|
2253
2335
|
return v31TaskSets(lanes, (task) => task.entry.some((condition) => condition.rules.some((group) => group.some((r) => r.rule === 'runs-sequentially'))));
|
|
2254
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
|
+
}
|
|
2255
2415
|
/** One emitted task of a stage node, by its (case-unique) display name, in any set. */
|
|
2256
2416
|
function stageTask(stage, name) {
|
|
2257
2417
|
for (const lane of stage?.data?.tasks ?? [])
|
|
@@ -2634,6 +2794,8 @@ function caseEventFilterReads(filters, kind) {
|
|
|
2634
2794
|
*/
|
|
2635
2795
|
function emitActionField(f, outputElementId, resolver) {
|
|
2636
2796
|
const row = { name: f.name, type: f.type ?? 'string' };
|
|
2797
|
+
if (outputElementId === undefined && f.type === undefined)
|
|
2798
|
+
UNTYPED_ACTION_INPUT_ROWS.add(row);
|
|
2637
2799
|
if (f.subType !== undefined)
|
|
2638
2800
|
row.subType = f.subType;
|
|
2639
2801
|
if (f.displayName !== undefined)
|
|
@@ -2673,15 +2835,8 @@ function emitActionField(f, outputElementId, resolver) {
|
|
|
2673
2835
|
// for it). Only a suffixed, reassigned row needs the readable companion.
|
|
2674
2836
|
if (resolver && id === variable)
|
|
2675
2837
|
addOwnNameRow(resolver, variable, row);
|
|
2676
|
-
else if (resolver
|
|
2677
|
-
resolver
|
|
2678
|
-
id: variable,
|
|
2679
|
-
name: variable,
|
|
2680
|
-
type: f.type ?? 'string',
|
|
2681
|
-
elementId: 'root',
|
|
2682
|
-
custom: true,
|
|
2683
|
-
});
|
|
2684
|
-
}
|
|
2838
|
+
else if (resolver)
|
|
2839
|
+
addVarCompanion(resolver, variable, { id: variable, name: variable, type: f.type ?? 'string', elementId: 'root', custom: true });
|
|
2685
2840
|
}
|
|
2686
2841
|
if (f.required !== undefined)
|
|
2687
2842
|
row.required = f.required;
|
|
@@ -2837,6 +2992,41 @@ function settleOwnNameRows(result, stages, restored, identities) {
|
|
|
2837
2992
|
if (variables.inputOutputs)
|
|
2838
2993
|
variables.inputOutputs = variables.inputOutputs.filter((entry) => !(names.has(entry?.id) && entry.custom === true && entry.elementId === 'root'));
|
|
2839
2994
|
}
|
|
2995
|
+
/**
|
|
2996
|
+
* A custom (`{ assign }`) row Studio Web saved as its task's own output, with
|
|
2997
|
+
* an id that is its variable and the task's `elementId` (`{ custom: true, id:
|
|
2998
|
+
* 'region', var: 'region', elementId: '<stageId>-<taskId>' }`), declares that
|
|
2999
|
+
* variable itself: the platform reads every row on the task's `elementId` that
|
|
3000
|
+
* has an id as a task output variable. Compile writes a root companion for
|
|
3001
|
+
* every `{ assign }` row (`emitCustomOutput`), so such a row would come back
|
|
3002
|
+
* with a second, root declaration the plan never had. Once the saved shapes are
|
|
3003
|
+
* back, a companion is dropped when its variable has no root row in the source
|
|
3004
|
+
* (`identities.variables`) and every row that writes it is such an own row; a
|
|
3005
|
+
* row that writes it any other way (an edit can add one) keeps it.
|
|
3006
|
+
*/
|
|
3007
|
+
function dropOwnVariableCompanions(result, stages, nodes, identities) {
|
|
3008
|
+
const variables = result.variables;
|
|
3009
|
+
if (!variables?.inputOutputs?.length)
|
|
3010
|
+
return;
|
|
3011
|
+
const declared = new Set(Object.values(identities.variables ?? {}).flatMap((rows) => (rows ?? []).map((row) => row.name)));
|
|
3012
|
+
const own = new Set();
|
|
3013
|
+
for (const stage of stages)
|
|
3014
|
+
for (const task of (stage.data?.tasks ?? []).flat())
|
|
3015
|
+
for (const row of task?.data?.outputs ?? [])
|
|
3016
|
+
if (row?.custom === true && typeof row.var === 'string' && row.id === row.var
|
|
3017
|
+
&& typeof task.elementId === 'string' && row.elementId === task.elementId && row.elementId !== 'root')
|
|
3018
|
+
own.add(row.var);
|
|
3019
|
+
if (!own.size)
|
|
3020
|
+
return;
|
|
3021
|
+
const ownRow = (row) => row?.custom === true && row.id === row.var && row.elementId !== 'root';
|
|
3022
|
+
for (const row of [...planOutputRows(result, stages), ...triggerOutputRows(nodes)])
|
|
3023
|
+
if (own.has(row?.var) && !ownRow(row))
|
|
3024
|
+
own.delete(row.var);
|
|
3025
|
+
const gone = new Set([...own].filter((name) => !declared.has(name)));
|
|
3026
|
+
if (!gone.size)
|
|
3027
|
+
return;
|
|
3028
|
+
variables.inputOutputs = variables.inputOutputs.filter((entry) => !(gone.has(entry?.id) && entry.custom === true && entry.elementId === 'root'));
|
|
3029
|
+
}
|
|
2840
3030
|
/** Every `outputs[]` row the plan's trigger nodes carry. */
|
|
2841
3031
|
function triggerOutputRows(nodes) {
|
|
2842
3032
|
return nodes.flatMap((node) => node.type === 'uipath.case.trigger' ? (node.data?.inputs?.outputs ?? [])
|
|
@@ -2897,6 +3087,13 @@ function isSdkOutputSlotId(id, variable) {
|
|
|
2897
3087
|
return false;
|
|
2898
3088
|
return SDK_OUTPUT_SLOT_ID.test(id);
|
|
2899
3089
|
}
|
|
3090
|
+
/**
|
|
3091
|
+
* Action form input rows whose source spells no `type`, which compile writes
|
|
3092
|
+
* as `string`. Only these lose the `type` a row was saved without
|
|
3093
|
+
* (`omit: ['type']`): `{ name: 'Customer', type: 'string' }` typed in the
|
|
3094
|
+
* source keeps it.
|
|
3095
|
+
*/
|
|
3096
|
+
const UNTYPED_ACTION_INPUT_ROWS = new WeakSet();
|
|
2900
3097
|
/** Action form output rows whose variable is the author's explicit `value`; see applyPreservedIdentities. */
|
|
2901
3098
|
const NAMED_ACTION_OUTPUT_ROWS = new WeakSet();
|
|
2902
3099
|
/** Rows `emitTaskOutput` wrote in the own-name shape (`id == var`); see applyPreservedIdentities. */
|
|
@@ -2933,8 +3130,7 @@ function emitTaskOutput(o, elementId, ids, seed, resolver) {
|
|
|
2933
3130
|
// A reassigned row registers the readable companion once (declared vars take
|
|
2934
3131
|
// precedence in the merge); an own-name row is the variable and registers none.
|
|
2935
3132
|
const companion = () => {
|
|
2936
|
-
|
|
2937
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
3133
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
2938
3134
|
};
|
|
2939
3135
|
if (isOwnNameOutput(o)) {
|
|
2940
3136
|
const id = claimOutputId(resolver, o.var);
|
|
@@ -2971,8 +3167,7 @@ function emitTaskOutput(o, elementId, ids, seed, resolver) {
|
|
|
2971
3167
|
* Like an extract, it registers the root companion so `=vars.<var>` resolves.
|
|
2972
3168
|
*/
|
|
2973
3169
|
function emitCustomOutput(o, resolver) {
|
|
2974
|
-
|
|
2975
|
-
resolver.varCompanions.set(o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
3170
|
+
addVarCompanion(resolver, o.var, { id: o.var, name: o.var, type: o.type, elementId: 'root', custom: true });
|
|
2976
3171
|
return { name: o.var, type: o.type, custom: true, var: o.var, value: o.source, source: o.source, target: '', body: '', elementId: 'root' };
|
|
2977
3172
|
}
|
|
2978
3173
|
// ─── Business-rule task ───────────────────────────────────────────────────────
|
|
@@ -3263,8 +3458,7 @@ function scriptTaskData(task, resolver, elementId) {
|
|
|
3263
3458
|
*/
|
|
3264
3459
|
function registerMappedCompanions(resolver, mappings) {
|
|
3265
3460
|
for (const variable of mappings.values())
|
|
3266
|
-
|
|
3267
|
-
resolver.varCompanions.set(variable, { id: variable, name: variable, type: 'object', elementId: 'root', custom: true });
|
|
3461
|
+
addVarCompanion(resolver, variable, { id: variable, name: variable, type: 'object', elementId: 'root', custom: true });
|
|
3268
3462
|
}
|
|
3269
3463
|
/**
|
|
3270
3464
|
* An HTTP request task (`case/http-request.ts`): the generic HTTP connector's
|
|
@@ -3559,12 +3753,51 @@ function connectorOutputVar(resolver, base) {
|
|
|
3559
3753
|
}
|
|
3560
3754
|
/** Record an own-name row (`id == var`), the variable itself; see the variables merge in `serialize`. */
|
|
3561
3755
|
function addOwnNameRow(resolver, name, row) {
|
|
3756
|
+
if (!resolver.firstWriters.has(name))
|
|
3757
|
+
resolver.firstWriters.set(name, { own: row });
|
|
3562
3758
|
const rows = resolver.ownNameRows.get(name);
|
|
3563
3759
|
if (rows)
|
|
3564
3760
|
rows.push(row);
|
|
3565
3761
|
else
|
|
3566
3762
|
resolver.ownNameRows.set(name, [row]);
|
|
3567
3763
|
}
|
|
3764
|
+
/**
|
|
3765
|
+
* Register the root companion a reassigned or custom row needs to write
|
|
3766
|
+
* `name` (`=vars.<name>` reads it), once per variable. See `orderedCompanions`
|
|
3767
|
+
* for where and with which type it is written.
|
|
3768
|
+
*/
|
|
3769
|
+
function addVarCompanion(resolver, name, companion) {
|
|
3770
|
+
if (!resolver.firstWriters.has(name))
|
|
3771
|
+
resolver.firstWriters.set(name, {});
|
|
3772
|
+
if (!resolver.varCompanions.has(name))
|
|
3773
|
+
resolver.varCompanions.set(name, companion);
|
|
3774
|
+
}
|
|
3775
|
+
/**
|
|
3776
|
+
* The root companions, in the order their variables were first written, each
|
|
3777
|
+
* with its first writer's type when that writer is an own-name row.
|
|
3778
|
+
*
|
|
3779
|
+
* A companion belongs to the variable, and the variable is its first writer.
|
|
3780
|
+
* When an own-name row comes first (`{ id: 'status', var: 'status' }`) and a
|
|
3781
|
+
* later task writes the same variable, only the later row is reassigned and
|
|
3782
|
+
* registers the companion, but the companion still stands where `status` was
|
|
3783
|
+
* first written, typed as that row is. Example: task A saves
|
|
3784
|
+
* `{ id: 'status', var: 'status', type: 'string' }`, then task B's
|
|
3785
|
+
* `.outputs({ status: { source: '=Result', type: 'jsonSchema' } })` writes it
|
|
3786
|
+
* too: the root gets `{ id: 'status', type: 'string', ... }`, ahead of the
|
|
3787
|
+
* companion of any variable first written after task A. This is also how
|
|
3788
|
+
* compile repairs two tasks saved with one output id (validate's
|
|
3789
|
+
* CASE_MGMT_OUTPUT_ID_DUPLICATE): the first keeps the id and is the variable.
|
|
3790
|
+
*/
|
|
3791
|
+
function orderedCompanions(resolver) {
|
|
3792
|
+
const order = [...resolver.firstWriters.keys()];
|
|
3793
|
+
const at = new Map(order.map((name, index) => [name, index]));
|
|
3794
|
+
return [...resolver.varCompanions]
|
|
3795
|
+
.sort(([a], [b]) => (at.get(a) ?? order.length) - (at.get(b) ?? order.length))
|
|
3796
|
+
.map(([name, companion]) => {
|
|
3797
|
+
const own = resolver.firstWriters.get(name)?.own;
|
|
3798
|
+
return own && typeof own.type === 'string' && own.type !== companion.type ? { ...companion, type: own.type } : companion;
|
|
3799
|
+
});
|
|
3800
|
+
}
|
|
3568
3801
|
/**
|
|
3569
3802
|
* Claim a task-output row id from the document-wide pool, the Designer's
|
|
3570
3803
|
* uniqueness rule: the first claimant of `base` gets `base`, later ones get
|
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.6",
|
|
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": "596cf9e55591a9453fb651e8857bfc83b15e67b9"
|
|
128
128
|
}
|