@uipath/maestro-builder-sdk 6.120.28 → 6.120.29

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.
@@ -1417,9 +1417,24 @@ function restoreTaskEntryShape(task, wanted) {
1417
1417
  * held by one, so the rows take theirs together: the ids are released, then
1418
1418
  * claimed. A chain that ends at a row with no claim (an id the source does not
1419
1419
  * carry for it) still waits, and its rows keep the ids compile gave them.
1420
+ *
1421
+ * A claim whose id a settled row holds never succeeds: the source saved that
1422
+ * id on two rows (validate's `CASE_MGMT_OUTPUT_ID_DUPLICATE`), and the first
1423
+ * keeps it. When another claim waits for the id such a row holds, the row
1424
+ * gives it up and gets a fresh one (`remint`, once no claim moves any more).
1425
+ * A plan saved with three writers of `flag`,
1426
+ *
1427
+ * A `flag`, B `flag` (the repeat), C `flag2`
1428
+ *
1429
+ * compiles as `flag`, `flag2`, `flag3`: B can never take `flag`, so it moves
1430
+ * off `flag2`, C takes `flag2`, and B gets `flag3`, an id no saved row holds.
1420
1431
  */
1421
- function settleDeferredClaims(deferred, held, claim) {
1432
+ function settleDeferredClaims(deferred, held, claim, remint) {
1422
1433
  let pending = deferred;
1434
+ // Rows that gave up the id compile wrote them with, to remint at the end.
1435
+ const vacated = [];
1436
+ const settle = () => { for (const target of vacated)
1437
+ remint(target); };
1423
1438
  while (pending.length) {
1424
1439
  const next = pending.filter(({ target, row }) => !claim(target, row));
1425
1440
  if (next.length < pending.length) {
@@ -1428,6 +1443,16 @@ function settleDeferredClaims(deferred, held, claim) {
1428
1443
  }
1429
1444
  // Stuck: find a ring of claims, each wanting the id the next one holds.
1430
1445
  const byHeldId = new Map(pending.map((entry) => [entry.target?.id, entry]));
1446
+ // A claim on an id a settled row holds, whose own id another claim waits for.
1447
+ const wanted = new Set(pending.map((entry) => entry.row.id));
1448
+ const dead = pending.find((entry) => !vacated.includes(entry.target) && !byHeldId.has(entry.row.id)
1449
+ && typeof entry.target?.id === 'string' && wanted.has(entry.target.id));
1450
+ if (dead) {
1451
+ held.delete(dead.target.id);
1452
+ vacated.push(dead.target);
1453
+ pending = pending.filter((entry) => entry !== dead);
1454
+ continue;
1455
+ }
1431
1456
  let ring;
1432
1457
  for (const start of pending) {
1433
1458
  const path = [];
@@ -1440,7 +1465,7 @@ function settleDeferredClaims(deferred, held, claim) {
1440
1465
  }
1441
1466
  }
1442
1467
  if (!ring)
1443
- return;
1468
+ return settle();
1444
1469
  for (const { target } of ring)
1445
1470
  held.delete(target.id);
1446
1471
  // `claimRowId` frees the id the row held when it moves; in a ring that id
@@ -1452,6 +1477,7 @@ function settleDeferredClaims(deferred, held, claim) {
1452
1477
  held.add(target.id);
1453
1478
  pending = pending.filter((entry) => !ring.includes(entry));
1454
1479
  }
1480
+ settle();
1455
1481
  }
1456
1482
  function applyPreservedIdentities(result, preservation, warn) {
1457
1483
  const identities = preservation.identities;
@@ -1967,7 +1993,48 @@ function applyPreservedIdentities(result, preservation, warn) {
1967
1993
  for (const row of droppedConnectorOutputRows(result, preservation.connectorRows, finalVar))
1968
1994
  if (typeof row.id === 'string')
1969
1995
  heldOutputIds.delete(row.id);
1970
- settleDeferredClaims(deferredClaims, heldOutputIds, (target, row) => claimRowId(target, row, target.id));
1996
+ // A fresh id for a row that gave up its compiled id (`settleDeferredClaims`):
1997
+ // the next free suffix of its variable that no row holds and no saved row
1998
+ // carries, so it reads as compile's repair of the repeat, not a saved id. A
1999
+ // row that is its own variable (a connector's `response7`) is numbered from
2000
+ // the id's stem (`response`), as compile numbers it. Like compile's own
2001
+ // allocator (`caseVarNames`), it never takes the name of a case variable or
2002
+ // of a variable another row writes: an own row's `var` follows its id, so
2003
+ // that would redirect the row into that variable.
2004
+ const carriedOutputIds = new Set();
2005
+ const collectCarried = (value, key = '') => {
2006
+ if (Array.isArray(value)) {
2007
+ for (const item of value) {
2008
+ if (key === 'outputs' && typeof item?.id === 'string')
2009
+ carriedOutputIds.add(item.id);
2010
+ collectCarried(item, key);
2011
+ }
2012
+ }
2013
+ else if (value && typeof value === 'object')
2014
+ for (const [k, v] of Object.entries(value))
2015
+ collectCarried(v, k);
2016
+ };
2017
+ collectCarried(identities);
2018
+ const remint = (target) => {
2019
+ const own = typeof target?.id === 'string' && (target.var === undefined || target.var === target.id);
2020
+ const base = own ? String(target.id).replace(/\d+$/, '') || String(target.id) : String(target.var);
2021
+ const variables = (result.variables ?? {});
2022
+ const reserved = new Set();
2023
+ for (const entry of Object.values(variables).flat())
2024
+ for (const name of [entry?.id, entry?.name])
2025
+ if (typeof name === 'string')
2026
+ reserved.add(name);
2027
+ for (const row of planOutputRows(result, stages))
2028
+ if (row !== target && typeof row?.var === 'string')
2029
+ reserved.add(row.var);
2030
+ const taken = (candidate) => heldOutputIds.has(candidate) || carriedOutputIds.has(candidate) || reserved.has(candidate);
2031
+ let id = `${base}2`;
2032
+ for (let n = 3; taken(id); n++)
2033
+ id = `${base}${n}`;
2034
+ takeRow(target, id, true);
2035
+ heldOutputIds.add(id);
2036
+ };
2037
+ settleDeferredClaims(deferredClaims, heldOutputIds, (target, row) => claimRowId(target, row, target.id), remint);
1971
2038
  takeSlas(metadata.slaRules, identities.slaRules);
1972
2039
  restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
1973
2040
  restoreSlaIds();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.120.28",
3
+ "version": "6.120.29",
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": "eb3ce4c9b197cfbe128a9d08062c1b77dd305693"
127
+ "gitref": "b9f4e3a5ecb624b793b0158eb99d7dae5a70b532"
128
128
  }