@uipath/maestro-builder-sdk 6.86.20 → 6.86.22

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.
@@ -16,6 +16,8 @@ interface IoRow {
16
16
  _jsonSchema?: unknown;
17
17
  /** A third copy of an action form output's `body` the Designer can save. */
18
18
  jsonSchema?: unknown;
19
+ /** The readable alias `@uipath/case-schema`'s id migration stamps on a row. */
20
+ canonicalId?: string;
19
21
  custom?: boolean;
20
22
  elementId?: string;
21
23
  var?: string;
@@ -731,8 +731,10 @@ const ACTION_DATA_KEYS = new Set([
731
731
  */
732
732
  const ACTION_INPUT_ROW_KEYS = new Set([
733
733
  'name', 'type', 'subType', 'displayName', 'value', 'required', 'options', 'body', 'source', 'id', 'var', 'elementId',
734
+ 'canonicalId',
734
735
  ]);
735
- const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'target', 'originalVar', '_jsonSchema', 'jsonSchema']);
736
+ const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'target', 'originalVar', '_jsonSchema', 'jsonSchema']
737
+ .filter((key) => key !== 'canonicalId'));
736
738
  function actionFields(rows, side, owner) {
737
739
  if (!rows?.length)
738
740
  return undefined;
@@ -743,6 +745,12 @@ function actionFields(rows, side, owner) {
743
745
  throw new Error(`${owner} form ${side} "${row.name ?? '?'}" has unsupported field "${unknown}".`);
744
746
  // The key names alone are not enough: compile rewrites these from the
745
747
  // row's id and value, so a row whose values differ would change silently.
748
+ // `canonicalId` is the readable alias `@uipath/case-schema`'s id migration
749
+ // stamps on a row (and then skips it on); it is carried only as a copy of
750
+ // the id (`actionInputShape`), since any other value renames how the
751
+ // Designer spells references to the row.
752
+ if (side === 'input' && row.canonicalId !== undefined && (row.id === undefined || row.canonicalId !== row.id))
753
+ throw new Error(`${owner} form input "${row.name ?? '?'}" has canonicalId "${String(row.canonicalId)}", which is not its id.`);
746
754
  if (row.var !== undefined && side === 'input' && row.var !== row.id)
747
755
  throw new Error(`${owner} form input "${row.name ?? '?'}" has var "${String(row.var)}", which is not its id; compile writes var as the id.`);
748
756
  if (side === 'output' && row.var !== undefined && row.var !== row.value)
@@ -2206,9 +2214,13 @@ function prunePreservation(preservation, plan) {
2206
2214
  * `elementId` that is not the task's is carried.
2207
2215
  */
2208
2216
  function actionInputShape(task, row) {
2209
- if (task.type !== 'action' || !row.id || row.elementId === undefined || row.elementId === task.elementId)
2217
+ if (task.type !== 'action' || !row.id)
2210
2218
  return {};
2211
- return { elementId: row.elementId };
2219
+ return {
2220
+ ...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
2221
+ // `actionFields` has checked it is a copy of the id.
2222
+ ...(row.canonicalId !== undefined ? { canonicalId: true } : {}),
2223
+ };
2212
2224
  }
2213
2225
  /**
2214
2226
  * What an action form output row has that compile would not write the same
@@ -2310,10 +2322,11 @@ function identityPreservation(plan) {
2310
2322
  name: row.name ?? '',
2311
2323
  ...(row.id ? { id: row.id } : {}),
2312
2324
  ...customRowLabel(row, plan),
2313
- // A form output's `originalVar` when the Designer spelled it as the variable, not the slot id,
2314
- // and a resource extract's when it names the variable an own-name row wrote first.
2315
- ...(typeof row.originalVar === 'string' && row.originalVar !== row.id
2316
- && (task.type === 'action' || (row.custom !== true && row.id !== undefined && row.id === row.var && ownEntry(TASK_KIND_METHOD, task.type)))
2325
+ // The row's `originalVar` when the Designer spelled it as something other than
2326
+ // the row's id, the spelling compile writes: the variable (`decision`), the
2327
+ // field's own default variable (`status` on a row that writes `intakeStatus`),
2328
+ // or the variable an own-name extract wrote first (`firstResults`).
2329
+ ...(typeof row.originalVar === 'string' && row.originalVar !== row.id && (row.custom !== true || task.type === 'action')
2317
2330
  ? { originalVar: row.originalVar } : {}),
2318
2331
  ...actionOutputShape(task, row),
2319
2332
  ...resourceRowShape(task, row, 'outputs'),
@@ -181,11 +181,12 @@ interface StageIdentity {
181
181
  entryConditions?: ConditionIdentity[];
182
182
  /** The resource the rows' `fields` / `omit` describe; they are applied only while the task still names it. */
183
183
  resource?: ResourceTaskIdentity;
184
- /** `elementId` only for an action form input whose row names another element than its task. `fields`: a resource task row's Designer fields compile does not write (`displayName`, `title`, `body`, ...). */
184
+ /** `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`, ...). */
185
185
  inputs?: Array<{
186
186
  name: string;
187
187
  id?: string;
188
188
  elementId?: string;
189
+ canonicalId?: true;
189
190
  fields?: Record<string, unknown>;
190
191
  }>;
191
192
  /** `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. */
@@ -1356,6 +1356,83 @@ function applyPreservedIdentities(result, preservation) {
1356
1356
  });
1357
1357
  }
1358
1358
  };
1359
+ // Take a row's carried id, or report that another row holds it now (`false`);
1360
+ // a held id is tried again once every row has taken its own (`deferredClaims`).
1361
+ const claimRowId = (target, row, currentId) => {
1362
+ // A nested own-name row (`app_id: '=response.app_id'`, written bare since
1363
+ // builder-sdk#1241) whose carried id is not its variable is a row an
1364
+ // SDK 6.67.1-era plan wrote reassigned, with a root companion that
1365
+ // readers spell (`=vars.app_id`). It keeps that shape: the carried slot id
1366
+ // goes on the row, `var` stays, and the companion comes back. Decided
1367
+ // here, on identities `followRenames` has already paired, so a renamed
1368
+ // task or stage keeps it too.
1369
+ if (target && typeof row.id === 'string' && isCarriedNestedReassignment(target, row.id) && !heldOutputIds.has(row.id)) {
1370
+ reassignCarried(target, row.id);
1371
+ if (currentId !== undefined)
1372
+ heldOutputIds.delete(currentId);
1373
+ heldOutputIds.add(row.id);
1374
+ return true;
1375
+ }
1376
+ // An own-name row's id IS its variable's name (`emitTaskOutput`). A
1377
+ // preserved id that differs — an `o<hash>` slot from a plan an older
1378
+ // SDK wrote — would rename the variable out from under every
1379
+ // `=vars.<name>` reader, so the typed rule wins and the row migrates.
1380
+ // A Designer reassignment is different: its slot id is not one this SDK
1381
+ // mints (`{ id: 'invoiceData2', var: 'invoiceData' }`, `{ id:
1382
+ // 'outApproved', var: 'approved' }`), or it records its own `originalVar`
1383
+ // spelling. The row is the slot that writes the variable, not the
1384
+ // variable, and it keeps that shape.
1385
+ if (target && OWN_NAME_OUTPUT_ROWS.has(target) && row.id !== target.id) {
1386
+ if (typeof row.id !== 'string' || row.id === target.var || target.name !== row.name)
1387
+ return true;
1388
+ if (typeof row.originalVar !== 'string' && isSdkOutputSlotId(row.id, target.var))
1389
+ return true;
1390
+ if (heldOutputIds.has(row.id))
1391
+ return false;
1392
+ reassignCarried(target, row.id);
1393
+ if (typeof row.originalVar === 'string')
1394
+ target.originalVar = row.originalVar;
1395
+ if (currentId !== undefined)
1396
+ heldOutputIds.delete(currentId);
1397
+ heldOutputIds.add(row.id);
1398
+ return true;
1399
+ }
1400
+ if (target && typeof row.id === 'string' && row.id !== currentId && heldOutputIds.has(row.id))
1401
+ return false;
1402
+ // A reassigned row (slot id, `originalVar` the slot) whose carried id IS
1403
+ // its variable was saved in the own-name shape; see `ownNameRestored`.
1404
+ if (target && typeof row.id === 'string' && row.id === target.var && target.id !== target.var && target.originalVar === target.id)
1405
+ ownNameRestored.push(target);
1406
+ // Designer reassignment: { name: 'Action', value: 'decision' } keeps var 'decision', slot id 'action'.
1407
+ if (target && typeof row.id === 'string' && NAMED_ACTION_OUTPUT_ROWS.has(target) && row.id !== target.var) {
1408
+ reassignCarried(target, row.id);
1409
+ // The Designer's other spellings (`originalVar: 'decision'`, the variable, or the field's own name).
1410
+ if (typeof row.originalVar === 'string' && designerOriginalVar(row.originalVar, target))
1411
+ target.originalVar = row.originalVar;
1412
+ }
1413
+ else {
1414
+ takeRow(target, row.id, true);
1415
+ // The Designer's own `originalVar` spelling on a reassigned row (the
1416
+ // field's default variable, `status` on a row that writes
1417
+ // `intakeStatus`), while the row is still that output, reassigned.
1418
+ if (target && typeof row.originalVar === 'string' && target.name === row.name && designerOriginalVar(row.originalVar, target)
1419
+ && typeof row.id === 'string' && target.var !== row.id && typeof target.originalVar === 'string') {
1420
+ const spelling = row.originalVar;
1421
+ rowRenames.push(() => { if (target.id === row.id && target.originalVar === row.id)
1422
+ target.originalVar = spelling; });
1423
+ }
1424
+ }
1425
+ if (target && typeof row.id === 'string' && typeof currentId === 'string') {
1426
+ heldOutputIds.delete(currentId);
1427
+ heldOutputIds.add(row.id);
1428
+ }
1429
+ return true;
1430
+ };
1431
+ // Rows whose carried id another row held when they were reached. Example: a
1432
+ // later task's row was compiled as `invoiceNumber2` and carries
1433
+ // `invoiceNumber3`; the earlier task's row that carries `invoiceNumber2` gets it
1434
+ // once the later row has moved.
1435
+ const deferredClaims = [];
1359
1436
  // `actionRows`: the rows are an action task's form outputs, the only rows
1360
1437
  // whose identity may omit `_jsonSchema` / `elementId` or name another
1361
1438
  // `elementId` (#1636). On any other row those would remove or re-point a
@@ -1398,48 +1475,8 @@ function applyPreservedIdentities(result, preservation) {
1398
1475
  rowRenames.push(() => { if (target.body !== undefined)
1399
1476
  target.jsonSchema = structuredClone(target.body); });
1400
1477
  carryRowShape(target, row);
1401
- // A nested own-name row (`app_id: '=response.app_id'`, written bare since
1402
- // builder-sdk#1241) whose carried id is not its variable is a row an
1403
- // SDK 6.67.1-era plan wrote reassigned, with a root companion that
1404
- // readers spell (`=vars.app_id`). It keeps that shape: the carried slot id
1405
- // goes on the row, `var` stays, and the companion comes back. Decided
1406
- // here, on identities `followRenames` has already paired, so a renamed
1407
- // task or stage keeps it too.
1408
- if (target && typeof row.id === 'string' && isCarriedNestedReassignment(target, row.id) && !heldOutputIds.has(row.id)) {
1409
- reassignCarried(target, row.id);
1410
- heldOutputIds.delete(currentId);
1411
- heldOutputIds.add(row.id);
1412
- return;
1413
- }
1414
- // An own-name row's id IS its variable's name (`emitTaskOutput`). A
1415
- // preserved id that differs — an `o<hash>` slot from a plan an older
1416
- // SDK wrote — would rename the variable out from under every
1417
- // `=vars.<name>` reader, so the typed rule wins and the row migrates.
1418
- if (target && OWN_NAME_OUTPUT_ROWS.has(target) && row.id !== target.id)
1419
- return;
1420
- if (target && typeof row.id === 'string' && row.id !== currentId && heldOutputIds.has(row.id))
1421
- return;
1422
- // A reassigned row (slot id, `originalVar` the slot) whose carried id IS
1423
- // its variable was saved in the own-name shape; see `ownNameRestored`.
1424
- if (target && typeof row.id === 'string' && row.id === target.var && target.id !== target.var && target.originalVar === target.id)
1425
- ownNameRestored.push(target);
1426
- // Designer reassignment: { name: 'Action', value: 'decision' } keeps var 'decision', slot id 'action'.
1427
- if (target && typeof row.id === 'string' && NAMED_ACTION_OUTPUT_ROWS.has(target) && row.id !== target.var) {
1428
- reassignCarried(target, row.id);
1429
- // The Designer's other spellings: `originalVar: 'decision'`, only while
1430
- // the row still writes 'decision', and the field's own variable before
1431
- // the reassignment, `originalVar: 'Action'`, only while the row is still
1432
- // the 'Action' field.
1433
- if (row.originalVar === target.var || (row.originalVar !== undefined && row.originalVar === target.name))
1434
- target.originalVar = row.originalVar;
1435
- }
1436
- else {
1437
- takeRow(target, row.id, true);
1438
- }
1439
- if (target && typeof row.id === 'string' && typeof currentId === 'string') {
1440
- heldOutputIds.delete(currentId);
1441
- heldOutputIds.add(row.id);
1442
- }
1478
+ if (!claimRowId(target, row, currentId))
1479
+ deferredClaims.push(() => claimRowId(target, row, target.id));
1443
1480
  });
1444
1481
  };
1445
1482
  const takeConditions = (current, wanted) => {
@@ -1538,6 +1575,10 @@ function applyPreservedIdentities(result, preservation) {
1538
1575
  Object.assign(input, { id: row.id, var: row.id, elementId: row.elementId ?? task.elementId });
1539
1576
  if (input.elementId === undefined)
1540
1577
  delete input.elementId;
1578
+ // The schema migration's readable alias of the id, which it stamps
1579
+ // once and then skips the row on: the same id again.
1580
+ if (row.canonicalId === true)
1581
+ input.canonicalId = row.id;
1541
1582
  return;
1542
1583
  }
1543
1584
  takeRow(input, row.id, false);
@@ -1557,6 +1598,12 @@ function applyPreservedIdentities(result, preservation) {
1557
1598
  }
1558
1599
  const metadata = result.metadata;
1559
1600
  takeConditions(metadata.caseExitRules, identities.caseExitRules);
1601
+ for (let pending = deferredClaims; pending.length;) {
1602
+ const next = pending.filter((claim) => !claim());
1603
+ if (next.length === pending.length)
1604
+ break;
1605
+ pending = next;
1606
+ }
1560
1607
  takeSlas(metadata.slaRules, identities.slaRules);
1561
1608
  restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
1562
1609
  restoreSlaIds();
@@ -2559,6 +2606,17 @@ function triggerOutputRows(nodes) {
2559
2606
  return nodes.flatMap((node) => node.type === 'uipath.case.trigger' ? (node.data?.inputs?.outputs ?? [])
2560
2607
  : node.type === 'case-management:Trigger' ? (node.data?.uipath?.outputs ?? []) : []);
2561
2608
  }
2609
+ /**
2610
+ * Whether a carried `originalVar` is one the Designer writes on `row`: the
2611
+ * variable the row writes (`decision`), or the field's own default variable,
2612
+ * spelled as the field (`companyNumber`, `decision`) or camelCased (`pdfCount`
2613
+ * for `pdf_count`). Any of these still holds while the row is the same output;
2614
+ * a variable spelling the row no longer writes does not.
2615
+ */
2616
+ function designerOriginalVar(originalVar, row) {
2617
+ const name = typeof row.name === 'string' ? row.name : undefined;
2618
+ return originalVar === row.var || (name !== undefined && (originalVar === name || originalVar === camelizeName(name)));
2619
+ }
2562
2620
  /** Every `outputs[]` row a rule's wait-for-connector bag carries, across a condition list. */
2563
2621
  function ruleOutputRows(conditions) {
2564
2622
  const bag = CASE_FORMAT_PROFILE.waitConnectorRuleBagField;
@@ -2575,6 +2633,23 @@ function planOutputRows(result, stages) {
2575
2633
  ...ruleOutputRows(result.metadata?.caseExitRules),
2576
2634
  ];
2577
2635
  }
2636
+ /**
2637
+ * The slot id `emitTaskOutput` mints for a reassigned output (`ozLtpBmNr`):
2638
+ * `o` and 8 base-62 characters (`IdGen.make('o', 8)`), with the numeric suffix
2639
+ * `claimOutputId` adds when it is taken.
2640
+ */
2641
+ const SDK_OUTPUT_SLOT_ID = /^o[A-Za-z0-9]{8}\d*$/;
2642
+ /**
2643
+ * Whether a carried output id is an SDK-minted slot (`SDK_OUTPUT_SLOT_ID`).
2644
+ * An id that is the row's variable plus a number (`orderNum2` into `orderNum`)
2645
+ * is the Designer's numbering, which the SDK never mints, even when it also
2646
+ * has the slot's shape.
2647
+ */
2648
+ function isSdkOutputSlotId(id, variable) {
2649
+ if (typeof variable === 'string' && id.length > variable.length && id.startsWith(variable) && /^\d+$/.test(id.slice(variable.length)))
2650
+ return false;
2651
+ return SDK_OUTPUT_SLOT_ID.test(id);
2652
+ }
2578
2653
  /** Action form output rows whose variable is the author's explicit `value`; see applyPreservedIdentities. */
2579
2654
  const NAMED_ACTION_OUTPUT_ROWS = new WeakSet();
2580
2655
  /** 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.86.20",
3
+ "version": "6.86.22",
4
4
  "description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.uipath.com/maestro",
@@ -103,5 +103,5 @@
103
103
  "@types/node": "^22.7.0",
104
104
  "esbuild": "^0.28.1"
105
105
  },
106
- "gitref": "e802da118b3c4f36c932a0e15950c80cf88b7c14"
106
+ "gitref": "5f41a8dcaad179d995dfe163d6b72120b35a2690"
107
107
  }