@uipath/maestro-builder-sdk 6.120.4 → 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/decompile.d.ts +1 -0
- package/dist/case/decompile.js +77 -14
- package/dist/case/preserve.d.ts +29 -1
- package/dist/case/preserve.js +11 -5
- package/dist/case/serialize.js +178 -9
- package/package.json +2 -2
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
|
|
@@ -1441,6 +1451,16 @@ function outputTargetOf(row) {
|
|
|
1441
1451
|
*
|
|
1442
1452
|
* A custom (`{ assign }`) output has its own spelling and is not handled here.
|
|
1443
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
|
+
}
|
|
1444
1464
|
function resourceRowShape(task, row, side) {
|
|
1445
1465
|
if (!ownEntry(TASK_KIND_METHOD, task.type) || row.custom === true)
|
|
1446
1466
|
return {};
|
|
@@ -1655,16 +1675,15 @@ function taskOutputRows(task) {
|
|
|
1655
1675
|
}
|
|
1656
1676
|
/**
|
|
1657
1677
|
* Refuse, naming the task and the row, a plan whose output rows a recompile
|
|
1658
|
-
* would not write back
|
|
1659
|
-
*
|
|
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.
|
|
1660
1682
|
*
|
|
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.
|
|
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).
|
|
1668
1687
|
*/
|
|
1669
1688
|
function refuseUnwrittenOutputs(task, plan) {
|
|
1670
1689
|
const rows = Array.isArray(task.data?.outputs) ? task.data.outputs : [];
|
|
@@ -1673,10 +1692,6 @@ function refuseUnwrittenOutputs(task, plan) {
|
|
|
1673
1692
|
const lost = rows.find((row) => !plan.lifted.includes(row) && !plan.rebuilt.includes(row));
|
|
1674
1693
|
if (lost)
|
|
1675
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.`);
|
|
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
1695
|
}
|
|
1681
1696
|
function escalationSource(escalation, slaName, index) {
|
|
1682
1697
|
if (escalation.action?.type !== 'notification')
|
|
@@ -2394,14 +2409,42 @@ function prunePreservation(preservation, plan) {
|
|
|
2394
2409
|
* input as `{ name, type, value }`; the Designer also gives it `var` (its id)
|
|
2395
2410
|
* and `elementId` (the task's), which compile restores from the id. Only an
|
|
2396
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.
|
|
2397
2425
|
*/
|
|
2398
2426
|
function actionInputShape(task, row) {
|
|
2399
|
-
if (task.type !== 'action'
|
|
2427
|
+
if (task.type !== 'action')
|
|
2400
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');
|
|
2401
2443
|
return {
|
|
2402
2444
|
...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
|
|
2403
2445
|
// `actionFields` has checked it is a copy of the id.
|
|
2404
2446
|
...(row.canonicalId !== undefined ? { canonicalId: true } : {}),
|
|
2447
|
+
...(omit.length ? { omit } : {}),
|
|
2405
2448
|
};
|
|
2406
2449
|
}
|
|
2407
2450
|
/**
|
|
@@ -2518,6 +2561,24 @@ function customRowIdentity(task, row, plan) {
|
|
|
2518
2561
|
const shape = customRowShape(row, carriedApart, varRows);
|
|
2519
2562
|
return shape ? { customRow: shape } : {};
|
|
2520
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
|
+
}
|
|
2521
2582
|
/** Whether a plan declaring `version` keeps its custom rows' saved `elementId` on read (V32.0.3 and later). */
|
|
2522
2583
|
function customElementIdIsOwn(version) {
|
|
2523
2584
|
return typeof version === 'string' && /^\d+\.\d+\.\d+$/.test(version) && compareSchemaVersions(version, '32.0.3') >= 0;
|
|
@@ -2569,7 +2630,9 @@ function identityPreservation(plan) {
|
|
|
2569
2630
|
...unaliasedOwnNameRow(row, plan),
|
|
2570
2631
|
...actionOutputShape(task, row),
|
|
2571
2632
|
...resourceRowShape(task, row, 'outputs'),
|
|
2633
|
+
...resourceOutputValue(task, row),
|
|
2572
2634
|
...customRowIdentity(task, row, plan),
|
|
2635
|
+
...interleavedCustomSource(task, row),
|
|
2573
2636
|
...rowHoldsSavedTaskElementId(stage, task, row),
|
|
2574
2637
|
})),
|
|
2575
2638
|
...emptyIoLists(task),
|
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
|
@@ -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();
|
|
@@ -1943,6 +2017,14 @@ function applySubscriptionFilters(result, preservation) {
|
|
|
1943
2017
|
const sub = entry && written.find((candidate) => candidate.inputRow === row);
|
|
1944
2018
|
if (!entry || !sub)
|
|
1945
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
|
+
}
|
|
1946
2028
|
const computed = sub.conditions.some((c) => c.expression !== undefined);
|
|
1947
2029
|
const filters = sub.inputRow.body?.filters;
|
|
1948
2030
|
if (entry.emptyVariables && !computed && filters)
|
|
@@ -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)
|
|
@@ -2897,6 +3059,13 @@ function isSdkOutputSlotId(id, variable) {
|
|
|
2897
3059
|
return false;
|
|
2898
3060
|
return SDK_OUTPUT_SLOT_ID.test(id);
|
|
2899
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();
|
|
2900
3069
|
/** Action form output rows whose variable is the author's explicit `value`; see applyPreservedIdentities. */
|
|
2901
3070
|
const NAMED_ACTION_OUTPUT_ROWS = new WeakSet();
|
|
2902
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
|
}
|