@uipath/maestro-builder-sdk 6.120.3 → 6.120.4

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.
@@ -17,6 +17,12 @@ export declare function caseConnectorOwners(plan: Record<string, any>): Array<{
17
17
  key: string;
18
18
  bag: Record<string, any>;
19
19
  }>;
20
+ /**
21
+ * Whether a context row named `name` counts when comparing the element
22
+ * compile built (`bag`) with a saved one: always, except a row in
23
+ * {@link ACTIVITY_SAVED_ONLY_ROWS} on an activity whose built context lacks it.
24
+ */
25
+ export declare function comparesContextRow(bag: Record<string, any>, name: string): boolean;
20
26
  /**
21
27
  * The saved context of a connector element, when it has a `metadata` row with
22
28
  * an object body (the Designer's state) that compile could not have written
@@ -81,6 +81,34 @@ function isEmptyInput(value) {
81
81
  || (Array.isArray(value) && value.length === 0) || (isObject(value) && Object.keys(value).length === 0);
82
82
  }
83
83
  const EVENT_SERVICE_TYPES = new Set(['Intsvc.EventTrigger', 'Intsvc.WaitForEvent']);
84
+ /**
85
+ * Context rows an older Case Designer saves on an `execute-connector-activity`
86
+ * task that compile never writes there (`connectorTaskData` in serialize.ts):
87
+ * `operation` (`list`, `create`, `replace`, `SendEmailV2`, ...), the name of
88
+ * the action the task calls. On an activity it repeats what `objectName`,
89
+ * `method`, `path` and the metadata's activity type id already say, and no
90
+ * source edit can set it, so a saved row that compile's side lacks is no sign
91
+ * of an edit. The saved copy is then the only thing that keeps it.
92
+ *
93
+ * An event element's `operation` is different: compile writes it from the
94
+ * event the source names, so it is compared there as any other row.
95
+ *
96
+ * For instance, a task saved with `objectName: query`, `method: POST`,
97
+ * `path: /hubs/datawarehouse/query` and `operation: list` is the same element
98
+ * as the one compile builds with the first three rows and no `operation`.
99
+ */
100
+ const ACTIVITY_SAVED_ONLY_ROWS = new Set(['operation']);
101
+ /**
102
+ * Whether a context row named `name` counts when comparing the element
103
+ * compile built (`bag`) with a saved one: always, except a row in
104
+ * {@link ACTIVITY_SAVED_ONLY_ROWS} on an activity whose built context lacks it.
105
+ */
106
+ export function comparesContextRow(bag, name) {
107
+ if (!ACTIVITY_SAVED_ONLY_ROWS.has(name) || EVENT_SERVICE_TYPES.has(bag?.serviceType))
108
+ return true;
109
+ const built = Array.isArray(bag?.context) ? bag.context : [];
110
+ return built.some((row) => isObject(row) && row.name === name);
111
+ }
84
112
  const JSON_STRING = '=jsonString:';
85
113
  /** The context row a flagged-V2 plan's connector elements carry (`stampConnectorConfigVersion`). */
86
114
  const V2_CONFIG_ROW = 'activityConfigurationVersion';
@@ -193,7 +221,9 @@ function actionIdentity(context) {
193
221
  * one side only reading as no value. So adding or removing a `folderKey`
194
222
  * row (an edit that adds or drops `folder:`) gets compile's context, while
195
223
  * a Designer row compile never writes and that holds no value (a bare
196
- * `method`) still compares equal. `connectorKey` must be on both sides;
224
+ * `method`) still compares equal, and so does an activity's saved
225
+ * `operation` row, which compile never writes there
226
+ * ({@link comparesContextRow}). `connectorKey` must be on both sides;
197
227
  * - the action is the same: the activity type id agrees, and the wire
198
228
  * activity type is curated on both sides or generic on both, wherever both
199
229
  * sides carry them ({@link actionIdentity}), so switching to an action's
@@ -208,7 +238,7 @@ function unchanged(bag, entry, v2) {
208
238
  if (!builtRows.has('connectorKey') || !saved.has('connectorKey'))
209
239
  return false;
210
240
  for (const name of new Set([...builtRows.keys(), ...saved.keys()])) {
211
- if (name === 'metadata')
241
+ if (name === 'metadata' || (typeof name === 'string' && !comparesContextRow(bag, name)))
212
242
  continue;
213
243
  // On a flagged-V2 plan `activityConfigurationVersion: v2` is compile's
214
244
  // repair: it is written on connection-bound contexts, on a trigger or task
@@ -54,6 +54,7 @@
54
54
  * the same operation. An extract the author edits (another source or
55
55
  * variable) gets compile's row.
56
56
  */
57
+ import { comparesContextRow } from './connector-saved-context.js';
57
58
  import { caseSubscriptionOwners } from './subscription.js';
58
59
  const CONNECTOR_ACTIVITY_TYPE = 'execute-connector-activity';
59
60
  /** The context rows that name the operation an element calls. */
@@ -260,10 +261,14 @@ function extractsBack(bag, shapes) {
260
261
  delete row.target;
261
262
  }
262
263
  }
263
- /** Whether the element compile built calls the operation the rows were saved for. */
264
+ /**
265
+ * Whether the element compile built calls the operation the rows were saved
266
+ * for. An activity's saved `operation` row, which compile never writes there,
267
+ * does not count (`comparesContextRow`).
268
+ */
264
269
  function sameOperation(bag, entry) {
265
270
  const now = operationOf(bag);
266
- return OPERATION_ROWS.every((name) => now[name] === entry.operation[name]);
271
+ return OPERATION_ROWS.every((name) => !comparesContextRow(bag, name) || now[name] === entry.operation[name]);
267
272
  }
268
273
  /**
269
274
  * The saved outputs over the built ones: the saved own rows in saved order,
@@ -924,7 +924,7 @@ function savedConfiguration(context) {
924
924
  /**
925
925
  * The activity type the task was saved against (`Curated`, ...): the saved
926
926
  * configuration's `instanceParameters.activityType`, else the activity
927
- * metadata's. It picks between a curated activity and the generic one on the
927
+ * metadata's, else `Curated` for an older Designer's `isCurated: true`. It picks between a curated activity and the generic one on the
928
928
  * same object and path (`Library.identifyAction`).
929
929
  */
930
930
  function connectorActivityType(context) {
@@ -941,7 +941,14 @@ function connectorActivityType(context) {
941
941
  }
942
942
  }
943
943
  const fromActivity = activity?.activityType;
944
- return typeof fromActivity === 'string' && fromActivity ? fromActivity : undefined;
944
+ if (typeof fromActivity === 'string' && fromActivity)
945
+ return fromActivity;
946
+ // An older Designer (the v10 canvas plan) saved neither, only
947
+ // `designTimeMetadata.activityConfig.isCurated`. `true` is a curated
948
+ // activity, e.g. Outlook "Send Email", which shares POST
949
+ // /hubs/productivity/send-mail-v2 with the generic `insert-record-deprecated-`.
950
+ // `false` is left unread: those plans save it on generic records and events alike.
951
+ return context.get('metadata')?.body?.designTimeMetadata?.activityConfig?.isCurated === true ? 'Curated' : undefined;
945
952
  }
946
953
  function connectorVersion(context) {
947
954
  const metadata = context.get('metadata')?.body;
@@ -1674,9 +1681,10 @@ function refuseUnwrittenOutputs(task, plan) {
1674
1681
  function escalationSource(escalation, slaName, index) {
1675
1682
  if (escalation.action?.type !== 'notification')
1676
1683
  throw new Error(`SLA escalation "${escalation.displayName ?? escalation.id ?? index}" has unsupported action "${escalation.action?.type}".`);
1684
+ // An empty list is carried as `notify: []`: compile writes it back as
1685
+ // `recipients: []`, and check warns ESCALATION_NO_RECIPIENTS, as `case
1686
+ // validate` warns CASE_MGMT_STAGE_ESCALATION_RECIPIENTS_MISSING.
1677
1687
  const recipients = escalation.action.recipients ?? [];
1678
- if (recipients.length === 0)
1679
- throw new Error(`SLA escalation "${escalation.displayName ?? escalation.id ?? index}" has no notification recipients.`);
1680
1688
  const notify = recipients.map((recipient) => {
1681
1689
  if (recipient.scope !== 'User' && recipient.scope !== 'UserGroup')
1682
1690
  throw new Error(`SLA escalation "${escalation.displayName ?? escalation.id ?? index}" has unsupported recipient scope "${recipient.scope}".`);
@@ -1716,7 +1724,8 @@ function emitStage(stageOut, depth, stage, refs, library, selectNextStage) {
1716
1724
  // The stage's own calls, collected first so they can be written as one chain or as statements.
1717
1725
  const out = new Emit();
1718
1726
  const inner = depth + 1;
1719
- if (data.description)
1727
+ // `""` too: a stage saved with `description: ""` keeps it (compile writes what the source gives).
1728
+ if (typeof data.description === 'string')
1720
1729
  out.line(inner, `.description(${tsLiteral(data.description)})`);
1721
1730
  if (data.isRequired !== undefined)
1722
1731
  out.line(inner, data.isRequired ? '.required()' : '.required(false)');
@@ -2318,7 +2327,13 @@ function ruleInputIdentity(inputs) {
2318
2327
  function slaIdentity(sla) {
2319
2328
  return {
2320
2329
  ...(sla.id ? { id: sla.id } : {}),
2321
- escalations: (sla.escalationRule ?? []).map((entry) => ({ ...(entry.id ? { id: entry.id } : {}) })),
2330
+ escalations: (sla.escalationRule ?? []).map((entry) => ({
2331
+ ...(entry.id ? { id: entry.id } : {}),
2332
+ // `escalationSource` writes atRiskPercentage only for an at-risk trigger.
2333
+ ...(entry.triggerInfo?.type === 'sla-breached' && typeof entry.triggerInfo.atRiskPercentage === 'number'
2334
+ ? { breachedAtRisk: entry.triggerInfo.atRiskPercentage }
2335
+ : {}),
2336
+ })),
2322
2337
  ...(Array.isArray(sla.escalationRule) && sla.escalationRule.length === 0 ? { emptyEscalationRule: true } : {}),
2323
2338
  };
2324
2339
  }
@@ -2507,6 +2522,21 @@ function customRowIdentity(task, row, plan) {
2507
2522
  function customElementIdIsOwn(version) {
2508
2523
  return typeof version === 'string' && /^\d+\.\d+\.\d+$/.test(version) && compareSchemaVersions(version, '32.0.3') >= 0;
2509
2524
  }
2525
+ /**
2526
+ * A task's saved `elementId` when it is not the `<stageId>-<taskId>` compile
2527
+ * writes, e.g. `Stage_old-tOld` on a task Studio Web copied from another stage
2528
+ * (preserve.ts, `elementId` on a task identity).
2529
+ */
2530
+ function savedTaskElementId(stage, task) {
2531
+ if (typeof task.elementId !== 'string' || !stage.id || !task.id)
2532
+ return {};
2533
+ return task.elementId === `${stage.id}-${task.id}` ? {} : { elementId: task.elementId };
2534
+ }
2535
+ /** `taskElementId: true` on an io row saved with its task's carried `elementId` ({@link savedTaskElementId}). */
2536
+ function rowHoldsSavedTaskElementId(stage, task, row) {
2537
+ const saved = savedTaskElementId(stage, task).elementId;
2538
+ return saved !== undefined && row.elementId === saved ? { taskElementId: true } : {};
2539
+ }
2510
2540
  function identityPreservation(plan) {
2511
2541
  const ambiguous = ambiguousSlaIds(plan);
2512
2542
  const conditionIdentity = (condition, _index, list) => conditionIdentityOf(condition, ambiguous, list);
@@ -2522,9 +2552,10 @@ function identityPreservation(plan) {
2522
2552
  tasks: (stage.data?.tasks ?? []).map((lane) => lane.map((task) => ({
2523
2553
  name: taskSourceName(task),
2524
2554
  ...(task.id ? { id: task.id } : {}),
2555
+ ...savedTaskElementId(stage, task),
2525
2556
  entryConditions: (task.entryConditions ?? []).map(conditionIdentity),
2526
2557
  ...emptyLists(task, TASK_EMPTY_LISTS),
2527
- inputs: (task.data?.inputs ?? []).map((row) => ({ name: row.name ?? '', ...(row.id ? { id: row.id } : {}), ...actionInputShape(task, row), ...resourceRowShape(task, row, 'inputs') })),
2558
+ inputs: (task.data?.inputs ?? []).map((row) => ({ name: row.name ?? '', ...(row.id ? { id: row.id } : {}), ...actionInputShape(task, row), ...resourceRowShape(task, row, 'inputs'), ...rowHoldsSavedTaskElementId(stage, task, row) })),
2528
2559
  outputs: (task.data?.outputs ?? []).map((row) => ({
2529
2560
  name: row.name ?? '',
2530
2561
  ...(row.id ? { id: row.id } : {}),
@@ -2539,6 +2570,7 @@ function identityPreservation(plan) {
2539
2570
  ...actionOutputShape(task, row),
2540
2571
  ...resourceRowShape(task, row, 'outputs'),
2541
2572
  ...customRowIdentity(task, row, plan),
2573
+ ...rowHoldsSavedTaskElementId(stage, task, row),
2542
2574
  })),
2543
2575
  ...emptyIoLists(task),
2544
2576
  ...carriedResource(task, plan),
@@ -262,33 +262,58 @@ function wireType(value) {
262
262
  return 'boolean';
263
263
  return undefined;
264
264
  }
265
- /** The connector ACTION's two tenant answers: the registry node and the `is resources describe` reply, from what the task saved. */
266
- function actionAnswers(w, nodeType) {
265
+ /**
266
+ * The connector ACTION's two tenant answers: the registry node and the `is
267
+ * resources describe` reply, from what the tasks on the operation saved.
268
+ *
269
+ * `w` is the first task on the operation, and the entry's text is its own.
270
+ * The fields are every task's (`wires`, `w` first): one entry stands for the
271
+ * operation, so it must declare each field any task on it sends. Two Data
272
+ * Service "Create Entity Record" tasks that write two entities send two field
273
+ * sets on one path, for instance `{ caseNumber, status }` and
274
+ * `{ caseNumber, eventTime, actor }`; the entry declares all four. A field two
275
+ * tasks send with values of different JSON types gets no type.
276
+ */
277
+ function actionAnswers(w, nodeType, wires = [w]) {
267
278
  const fields = new Map();
279
+ // The fields whose type was read off a sent value, not a saved declaration.
280
+ const valueTyped = new Set();
268
281
  const add = (name, location, type, displayName) => {
269
282
  if (typeof name !== 'string' || !name || fields.has(name))
270
283
  return;
271
284
  fields.set(name, { name, location, ...(type ? { type } : {}), ...(typeof displayName === 'string' && displayName ? { displayName } : {}) });
272
285
  };
273
- // The live connector's field list the Designer saved, then every value the task sends.
274
- const saved = w.optional.fieldsContainer?.inputFields;
275
- for (const f of Array.isArray(saved) ? saved : []) {
276
- if (!isObject(f) || f.request === false)
277
- continue;
278
- const location = typeof f.fieldLocation === 'string' ? ownEntry(LOCATIONS, f.fieldLocation) : undefined;
279
- if (location)
280
- add(f.name, location, typeof f.type === 'string' ? f.type : undefined, f.displayName);
286
+ const addSent = (name, location, type) => {
287
+ const field = fields.get(name);
288
+ if (!field) {
289
+ add(name, location, type);
290
+ valueTyped.add(name);
291
+ }
292
+ else if (valueTyped.has(name) && field.type !== type)
293
+ delete field.type;
294
+ };
295
+ // The live connector's field list each task's Designer saved, then every value each task sends.
296
+ for (const wire of wires) {
297
+ const saved = wire.optional.fieldsContainer?.inputFields;
298
+ for (const f of Array.isArray(saved) ? saved : []) {
299
+ if (!isObject(f) || f.request === false)
300
+ continue;
301
+ const location = typeof f.fieldLocation === 'string' ? ownEntry(LOCATIONS, f.fieldLocation) : undefined;
302
+ if (location)
303
+ add(f.name, location, typeof f.type === 'string' ? f.type : undefined, f.displayName);
304
+ }
281
305
  }
282
306
  for (const m of String(w.path ?? '').matchAll(/\{([^}]+)\}/g))
283
307
  add(m[1], 'path', 'string');
284
308
  const slot = { pathParameters: 'path', queryParameters: 'query', body: 'body' };
285
- for (const row of Array.isArray(w.bag.inputs) ? w.bag.inputs : []) {
286
- const location = typeof row?.name === 'string' ? ownEntry(slot, row.name) : undefined;
287
- if (!location || !isObject(row.body))
288
- continue;
289
- for (const [name, value] of Object.entries(row.body))
290
- add(name, location, wireType(value));
291
- }
309
+ for (const wire of wires)
310
+ for (const row of Array.isArray(wire.bag.inputs) ? wire.bag.inputs : []) {
311
+ const location = typeof row?.name === 'string' ? ownEntry(slot, row.name) : undefined;
312
+ if (!location || !isObject(row.body))
313
+ continue;
314
+ for (const [name, value] of Object.entries(row.body))
315
+ addSent(name, location, wireType(value));
316
+ }
292
317
  const parameters = [...fields.values()].filter((f) => f.location !== 'body')
293
318
  .map((f) => ({ name: f.name, type: f.location, dataType: f.type ?? 'string', required: false, ...(f.displayName ? { displayName: f.displayName } : {}) }));
294
319
  const multipart = Array.isArray(w.apc.multipartParameters) ? w.apc.multipartParameters : [];
@@ -410,6 +435,18 @@ export function planConnectors(plan, library) {
410
435
  // and the first wire on an operation is the one its entry is built from.
411
436
  const bags = planConnectorBags(plan);
412
437
  const ordered = [...bags.filter((b) => b.bag.serviceType === WAIT), ...bags.filter((b) => b.bag.serviceType !== WAIT)];
438
+ const actionKey = (w) => JSON.stringify([w.connectorKey, w.method, w.path, w.objectName, w.version]);
439
+ // Every action wire the library cannot name, by operation: the entry built
440
+ // from the first declares the fields of all (`actionAnswers`).
441
+ const actionWires = new Map();
442
+ for (const { bag } of ordered) {
443
+ const w = wireOf(bag);
444
+ if (!w || w.kind !== 'action' || known(library, w))
445
+ continue;
446
+ const list = actionWires.get(actionKey(w)) ?? [];
447
+ list.push(w);
448
+ actionWires.set(actionKey(w), list);
449
+ }
413
450
  for (const { owner, names, bag } of ordered) {
414
451
  const w = wireOf(bag);
415
452
  if (!w || known(library, w))
@@ -420,7 +457,7 @@ export function planConnectors(plan, library) {
420
457
  // One action id per operation: object and verb, with a counter when two
421
458
  // paths share them or a library layer already holds the node type.
422
459
  const base = `${slug(w.objectName)}-${slug(w.method)}`;
423
- const operationKey = JSON.stringify([w.connectorKey, w.method, w.path, w.objectName, w.version]);
460
+ const operationKey = actionKey(w);
424
461
  let id = actionIds.get(operationKey);
425
462
  if (id === undefined) {
426
463
  id = base;
@@ -430,7 +467,7 @@ export function planConnectors(plan, library) {
430
467
  id = `${base}-${n}`;
431
468
  actionIds.set(operationKey, id);
432
469
  }
433
- const answers = actionAnswers(w, `uipath.connector.${w.connectorKey}.${id}`);
470
+ const answers = actionAnswers(w, `uipath.connector.${w.connectorKey}.${id}`, actionWires.get(operationKey));
434
471
  node = answers.node;
435
472
  const canonical = extractCanonical(node);
436
473
  if (!canonical)
@@ -455,7 +492,7 @@ export function planConnectors(plan, library) {
455
492
  }
456
493
  entry.provenance = { source: PLAN_CONNECTOR_SOURCE };
457
494
  const question = libraryQuestion(w.kind, { connectorKey: w.connectorKey, httpMethod: w.method, endpoint: w.path, objectName: w.objectName, eventOperation: w.operation });
458
- // Two wires on one operation give one entry: the first one's.
495
+ // Two wires on one operation give one entry: the first one's text, with every one's fields (`actionAnswers`).
459
496
  const key = JSON.stringify([entry.nodeType, entry.operation?.objectName ?? '', entry.version]);
460
497
  let connector = byKey.get(key);
461
498
  if (!connector) {
@@ -194,8 +194,15 @@ interface ConditionIdentity {
194
194
  }
195
195
  interface SlaIdentity {
196
196
  id?: string;
197
+ /**
198
+ * `breachedAtRisk`: an `sla-breached` escalation's leftover
199
+ * `triggerInfo.atRiskPercentage`. The Designer keeps the percentage when an
200
+ * `at-risk` escalation is switched to `sla-breached`; the engine ignores it
201
+ * there and the source does not spell it, so the read value is carried.
202
+ */
197
203
  escalations?: Array<{
198
204
  id?: string;
205
+ breachedAtRisk?: number;
199
206
  }>;
200
207
  /**
201
208
  * The SLA spelled an empty `escalationRule: []`. The serializer omits the
@@ -212,6 +219,19 @@ interface StageIdentity {
212
219
  tasks?: Array<Array<{
213
220
  name: string;
214
221
  id?: string;
222
+ /**
223
+ * The task's saved `elementId`, only when it is not `<stageId>-<taskId>`, the
224
+ * value compile writes. A task Studio Web copied, or one whose stage or task
225
+ * id changed after it was saved, keeps the `elementId` it was created with
226
+ * (`Stage_old-tOld`), and so do the io rows that name it. The converter only
227
+ * matches a task's rows to it by equality, so the saved value is carried and
228
+ * written back on the task and on each of its rows saved with it
229
+ * (`taskElementId: true` on the row), and only those: Studio Web re-stamps
230
+ * some rows with `<stageId>-<taskId>` and leaves others, and the converter
231
+ * drops a row whose `elementId` is not the task's, so which rows hold it is
232
+ * part of what the plan does.
233
+ */
234
+ elementId?: string;
215
235
  entryConditions?: ConditionIdentity[];
216
236
  /** The resource the rows' `fields` / `omit` describe; they are applied only while the task still names it. */
217
237
  resource?: ResourceTaskIdentity;
@@ -222,6 +242,7 @@ interface StageIdentity {
222
242
  elementId?: string;
223
243
  canonicalId?: true;
224
244
  fields?: Record<string, unknown>;
245
+ taskElementId?: true;
225
246
  }>;
226
247
  /** `originalVar` only when it is not the row's `id` (the serializer's own spelling). `elementId` when an action form output names another element than its task. `fields` as on an input. `omit`: the fields an action form output (`target`, `_jsonSchema`, `elementId`) or a resource extract (`target`) was saved without that compile writes. `target`: which of the row's variables its saved `target` names when that is not its id (`=<var>` or `=<originalVar>`; compile writes `=<id>`). `bodyCopies`: the extra copies of its `body` an action form output was saved with (`jsonSchema`), which compile writes back from the body. */
227
248
  /** `var` and `custom: true`: a custom row whose label (`name`) is not the name of the variable it assigns. */
@@ -314,6 +335,8 @@ export interface PreservedOutputRow {
314
335
  custom?: true;
315
336
  noAlias?: true;
316
337
  customRow?: CustomRowShape;
338
+ /** The row was saved with its task's carried `elementId` (see `elementId` on the task identity). */
339
+ taskElementId?: true;
317
340
  }
318
341
  /**
319
342
  * Non-authoring Case JSON lanes retained by decompile/recompile.
@@ -1334,6 +1334,8 @@ function applyPreservedIdentities(result, preservation, warn) {
1334
1334
  if (!carriedCompanions.has(row.var))
1335
1335
  carriedCompanions.set(row.var, { id: row.var, name: row.var, type: row.type, elementId: 'root', custom: true });
1336
1336
  };
1337
+ // Tasks saved with an `elementId` other than `<stageId>-<taskId>`, written back once every id is final.
1338
+ const savedTaskElementIds = [];
1337
1339
  // Tasks whose custom rows carry a saved shape (`customRowShape`).
1338
1340
  const customRowShapes = [];
1339
1341
  const nodes = result.nodes;
@@ -1494,7 +1496,7 @@ function applyPreservedIdentities(result, preservation, warn) {
1494
1496
  // `elementId` (#1636). On any other row those would remove or re-point a
1495
1497
  // field compile writes: a resource extract without its task's `elementId`
1496
1498
  // is one the converter never reads (#1419).
1497
- const takeOutputRows = (outputRows, wantedRows, actionRows = false) => {
1499
+ const takeOutputRows = (outputRows, wantedRows, actionRows = false, elementIdRows) => {
1498
1500
  // A custom row's own label goes back on the one custom row that still
1499
1501
  // assigns its variable (matched once every id is final).
1500
1502
  for (const row of wantedRows)
@@ -1518,6 +1520,10 @@ function applyPreservedIdentities(result, preservation, warn) {
1518
1520
  // A positional match never takes a row a name match owns.
1519
1521
  : named.has(outputRows[index]?.name) ? undefined : outputRows[index];
1520
1522
  const currentId = target?.id;
1523
+ if (target)
1524
+ elementIdRows?.matched.add(target);
1525
+ if (target && row.taskElementId === true)
1526
+ elementIdRows?.saved.add(target);
1521
1527
  // An action form output the Designer saved with no `target` (or no
1522
1528
  // `_jsonSchema` copy of its body, or no `elementId`) keeps none, and one
1523
1529
  // whose `elementId` names another element keeps that.
@@ -1602,7 +1608,15 @@ function applyPreservedIdentities(result, preservation, warn) {
1602
1608
  (wanted ?? []).forEach((sla, index) => {
1603
1609
  const target = current?.[index];
1604
1610
  want(target, sla.id);
1605
- (sla.escalations ?? []).forEach((entry, escalationIndex) => want(target?.escalationRule?.[escalationIndex], entry.id));
1611
+ (sla.escalations ?? []).forEach((entry, escalationIndex) => {
1612
+ const escalation = target?.escalationRule?.[escalationIndex];
1613
+ want(escalation, entry.id);
1614
+ // The read sla-breached escalation kept a stale atRiskPercentage; put it
1615
+ // back only while this escalation is still sla-breached without one.
1616
+ const info = escalation?.triggerInfo;
1617
+ if (typeof entry.breachedAtRisk === 'number' && info?.type === 'sla-breached' && info.atRiskPercentage === undefined)
1618
+ info.atRiskPercentage = entry.breachedAtRisk;
1619
+ });
1606
1620
  // The read SLA spelled `escalationRule: []`; `emitSla` omits an empty list.
1607
1621
  if (sla.emptyEscalationRule === true && target && target.escalationRule === undefined)
1608
1622
  target.escalationRule = [];
@@ -1656,6 +1670,9 @@ function applyPreservedIdentities(result, preservation, warn) {
1656
1670
  && taskIdentity.resource.name === compiledRef.name && taskIdentity.resource.folderPath === compiledRef.folderPath;
1657
1671
  const rowShape = (row) => (resourceKept ? row : { name: row.name });
1658
1672
  take(task, taskIdentity.id);
1673
+ const elementIdRows = { saved: new Set(), matched: new Set() };
1674
+ if (task && stage && typeof taskIdentity.elementId === 'string')
1675
+ savedTaskElementIds.push({ stage, task, elementId: taskIdentity.elementId, rows: elementIdRows });
1659
1676
  restoreEmptyLists(task, taskIdentity.emptyLists, TASK_EMPTY_LISTS);
1660
1677
  takeConditions(task?.entryConditions, taskIdentity.entryConditions);
1661
1678
  // An input row is matched by name when the name is unique on both sides
@@ -1667,6 +1684,10 @@ function applyPreservedIdentities(result, preservation, warn) {
1667
1684
  wantedInputs.forEach((row, index) => {
1668
1685
  const byName = once(wantedInputs.map((r) => r.name), row.name) && once(inputRows.map((r) => r?.name), row.name);
1669
1686
  const input = byName ? inputRows.find((r) => r?.name === row.name) : inputRows[index];
1687
+ if (input)
1688
+ elementIdRows.matched.add(input);
1689
+ if (input && row.taskElementId === true)
1690
+ elementIdRows.saved.add(input);
1670
1691
  // An action form input is written `{ name, type, value }`; the Designer's
1671
1692
  // row also has its id, `var` (the id) and `elementId`, which come back.
1672
1693
  if (task?.type === 'action' && input && input.id === undefined && typeof row.id === 'string' && input.name === row.name) {
@@ -1692,7 +1713,7 @@ function applyPreservedIdentities(result, preservation, warn) {
1692
1713
  if (task && shapes.length)
1693
1714
  customRowShapes.push({ task, shapes });
1694
1715
  takeOutputRows(task?.data?.outputs ?? [], (taskIdentity.outputs ?? [])
1695
- .map((row) => ({ ...row, ...(!isAction && !resourceKept ? { fields: undefined, omit: undefined } : {}) })), isAction);
1716
+ .map((row) => ({ ...row, ...(!isAction && !resourceKept ? { fields: undefined, omit: undefined } : {}) })), isAction, elementIdRows);
1696
1717
  // Only on the kind the lists were saved on (`emptyIoType`; a payload from
1697
1718
  // before it was recorded was written for resource tasks only), and never
1698
1719
  // on a connector placeholder, whose `data: {}` is its contract (#1354).
@@ -1820,6 +1841,21 @@ function applyPreservedIdentities(result, preservation, warn) {
1820
1841
  row.source = source;
1821
1842
  for (const rename of rowRenames)
1822
1843
  rename();
1844
+ // A task's saved `elementId` (a copied task's `Stage_old-tOld`) goes back on
1845
+ // the task, and on each of its rows that compile gave the `<stageId>-<taskId>`
1846
+ // it writes and that either was saved with the task's value or is new (an
1847
+ // edit added it, and it is wired to its task as compile means it to be). A
1848
+ // row saved with `<stageId>-<taskId>` keeps it, and so does one naming
1849
+ // another element (`root`).
1850
+ for (const { stage, task, elementId, rows } of savedTaskElementIds) {
1851
+ const written = `${stage.id}-${task.id}`;
1852
+ if (task.elementId !== written)
1853
+ continue;
1854
+ task.elementId = elementId;
1855
+ for (const row of [...(task.data?.inputs ?? []), ...(task.data?.outputs ?? [])])
1856
+ if (row?.elementId === written && (rows.saved.has(row) || !rows.matched.has(row)))
1857
+ row.elementId = elementId;
1858
+ }
1823
1859
  settleOwnNameRows(result, stages, ownNameRestored, identities);
1824
1860
  for (const spell of targetSpellings)
1825
1861
  spell();
@@ -2232,7 +2268,7 @@ function emitStage(stage, lanes, si, stageId, laneTaskIds, ids, resolver) {
2232
2268
  isPendingParent: false,
2233
2269
  tasks: lanes.map((lane, li) => lane.map((task, ti) => emitTask(task, stage.label, laneTaskIds[li][ti], ids, resolver))),
2234
2270
  };
2235
- if (stage.description)
2271
+ if (stage.description !== undefined)
2236
2272
  data.description = stage.description;
2237
2273
  if (stage.required !== undefined)
2238
2274
  data.isRequired = stage.required;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.120.3",
3
+ "version": "6.120.4",
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": "9f740b0bf276c4e815615529144164b9af6f1f08"
127
+ "gitref": "2e5b24a5f455c61476724c2095041b9a713267ab"
128
128
  }