@uipath/maestro-builder-sdk 6.120.6 → 6.120.8

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.
@@ -30,7 +30,9 @@
30
30
  *
31
31
  * - outputs, while the element calls the same operation (same `connectorKey`,
32
32
  * `objectName`, `method`, `path` and event `operation`) and each saved row's
33
- * compiled counterpart writes the same variable;
33
+ * compiled counterpart writes the same variable, or the saved row is the
34
+ * Designer's reassignment of the output to a case variable the plan still
35
+ * declares (`reassignedToCaseVariable`);
34
36
  * - inputs, while it calls the same operation and every input holds the value
35
37
  * it was saved with (an input only one side has must be empty).
36
38
  *
@@ -294,23 +296,64 @@ function sameOperation(bag, entry) {
294
296
  * where compile put its first own row, around the rows compile writes for the
295
297
  * author; a built own row the element was saved without is dropped. Nothing,
296
298
  * when a saved row's counterpart writes another variable.
299
+ *
300
+ * A saved row's counterpart is a built row that reads its source: one that
301
+ * also writes its variable when there is one, and of those the one with its
302
+ * id, else the last. An event trigger's `outputs`
303
+ * (`outputs: { responseRow: { source: '=response' } }`) compile writes as
304
+ * extracts beside the trigger's own rows, with the same source and no id; the
305
+ * Designer saves the trigger's own row reassigned instead (`{ id:
306
+ * 'responseRow', var: 'responseRow', originalVar: 'response', source:
307
+ * '=response' }`). The extract that writes the saved row's variable is its
308
+ * counterpart, and having no id it says nothing about renumbering, so the
309
+ * ids are compared only when the counterpart has one.
297
310
  */
298
- function outputsBack(built, set) {
299
- const builtOwn = new Map(built.filter(isOwnOutput).map((row) => [row.source, row]));
311
+ function outputsBack(built, set, caseVariables) {
312
+ const builtOwn = built.filter(isOwnOutput);
313
+ const counterpartOf = (row) => {
314
+ const reading = builtOwn.filter((candidate) => candidate.source === row.source);
315
+ const writing = reading.filter((candidate) => row.var !== undefined && candidate.var === row.var);
316
+ const pool = writing.length ? writing : reading;
317
+ return pool.find((candidate) => candidate.id === row.id) ?? pool.at(-1);
318
+ };
300
319
  for (const row of set.rows) {
301
- const counterpart = builtOwn.get(row.source);
302
- if (counterpart && (counterpart.id !== row.id || (row.var !== undefined && counterpart.var !== row.var)))
320
+ const counterpart = counterpartOf(row);
321
+ if (!counterpart)
322
+ continue;
323
+ if (counterpart.id !== undefined && counterpart.id !== row.id)
324
+ return undefined;
325
+ if (row.var !== undefined && counterpart.var !== row.var && !reassignedToCaseVariable(row, counterpart, caseVariables))
303
326
  return undefined;
304
327
  }
305
- const own = set.rows.flatMap((row) => {
306
- const counterpart = builtOwn.get(row.source);
307
- return counterpart ? [structuredClone(row)] : [];
308
- });
328
+ const own = set.rows.flatMap((row) => (counterpartOf(row) ? [structuredClone(row)] : []));
309
329
  const firstOwn = built.findIndex(isOwnOutput);
310
330
  const others = built.filter((row) => !isOwnOutput(row));
311
331
  const at = firstOwn < 0 ? 0 : firstOwn;
312
332
  return [...others.slice(0, at), ...own, ...others.slice(at)];
313
333
  }
334
+ /**
335
+ * Whether saved own row `row` is the Designer's reassignment of the output to
336
+ * a case variable the compiled plan still declares, where compile wrote the
337
+ * output to its own variable. The Designer saves such a row as `{ id:
338
+ * 'response2', var: 'inquiry', originalVar: 'response2', value: 'inquiry' }`
339
+ * with `inquiry` a root variable. No builder call writes an element's own row
340
+ * into another variable, so compile's counterpart writes `var: 'response2'`
341
+ * on every round trip, and refusing the saved row on that difference dropped
342
+ * the reassignment: the output stopped writing `inquiry`, and a later task
343
+ * reading `vars.inquiry` read nothing.
344
+ */
345
+ function reassignedToCaseVariable(row, counterpart, caseVariables) {
346
+ return typeof row.var === 'string' && row.var !== row.id && counterpart.var === counterpart.id && caseVariables.has(row.var);
347
+ }
348
+ /** The ids of the case's root variables (`variables.inputs`, `outputs`, `inputOutputs`). */
349
+ function caseVariableIds(result) {
350
+ const ids = new Set();
351
+ for (const lane of ['inputs', 'outputs', 'inputOutputs'])
352
+ for (const variable of Array.isArray(result?.variables?.[lane]) ? result.variables[lane] : [])
353
+ if (typeof variable?.id === 'string')
354
+ ids.add(variable.id);
355
+ return ids;
356
+ }
314
357
  /** The value an input row holds: its `body`, else its `value`. */
315
358
  function inputValue(row) {
316
359
  if (!row)
@@ -342,6 +385,7 @@ export function applyConnectorRows(result, entries) {
342
385
  if (!entries?.length)
343
386
  return;
344
387
  const byOwner = new Map(entries.map((entry) => [entry.owner, entry]));
388
+ const caseVariables = caseVariableIds(result);
345
389
  for (const { key, bag } of caseConnectorRowOwners(result)) {
346
390
  const entry = byOwner.get(key);
347
391
  if (!entry || !sameOperation(bag, entry))
@@ -353,7 +397,7 @@ export function applyConnectorRows(result, entries) {
353
397
  if (!set)
354
398
  continue;
355
399
  const built = Array.isArray(bag[field]) ? bag[field] : [];
356
- const back = field === 'inputs' ? inputsBack(built, set) : outputsBack(built, set);
400
+ const back = field === 'inputs' ? inputsBack(built, set) : outputsBack(built, set, caseVariables);
357
401
  if (!back)
358
402
  continue;
359
403
  if (set.absent && back.length === 0)
@@ -743,9 +743,9 @@ const ACTION_DATA_KEYS = new Set([
743
743
  */
744
744
  const ACTION_INPUT_ROW_KEYS = new Set([
745
745
  'name', 'type', 'subType', 'displayName', 'value', 'required', 'options', 'body', 'source', 'id', 'var', 'elementId',
746
- 'canonicalId',
746
+ 'canonicalId', 'target',
747
747
  ]);
748
- const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'target', 'originalVar', '_jsonSchema', 'jsonSchema']
748
+ const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'originalVar', '_jsonSchema', 'jsonSchema']
749
749
  .filter((key) => key !== 'canonicalId'));
750
750
  function actionFields(rows, side, owner) {
751
751
  if (!rows?.length)
@@ -761,6 +761,11 @@ function actionFields(rows, side, owner) {
761
761
  // stamps on a row (and then skips it on); it is carried only as a copy of
762
762
  // the id (`actionInputShape`), since any other value renames how the
763
763
  // Designer spells references to the row.
764
+ // An input's `target` is the slot Studio Web says it fills (`"bodyField"`, the
765
+ // HITL task arguments); nothing reads it to run the case, so it is carried
766
+ // verbatim (`actionInputShape`), as long as it is a string.
767
+ if (side === 'input' && row.target !== undefined && typeof row.target !== 'string')
768
+ throw new Error(`${owner} form input "${row.name ?? '?'}" has a non-string target ${JSON.stringify(row.target)}.`);
764
769
  if (side === 'input' && row.canonicalId !== undefined && (row.id === undefined || row.canonicalId !== row.id))
765
770
  throw new Error(`${owner} form input "${row.name ?? '?'}" has canonicalId "${String(row.canonicalId)}", which is not its id.`);
766
771
  if (row.var !== undefined && side === 'input' && row.var !== row.id)
@@ -2430,10 +2435,14 @@ function prunePreservation(preservation, plan) {
2430
2435
  * writes such a row with no `elementId`, so it is recorded even when the
2431
2436
  * task's `elementId` is the `<stageId>-<taskId>` compile writes. Any other
2432
2437
  * `elementId` is carried as the value itself.
2438
+ * - A `target` (`"bodyField"`) is carried on any row, e.g. the Designer's
2439
+ * { name: 'note', type: 'string', target: 'bodyField', value: '=vars.note' }
2440
+ * records `{ name: 'note', target: 'bodyField' }`.
2433
2441
  */
2434
2442
  function actionInputShape(task, row) {
2435
2443
  if (task.type !== 'action')
2436
2444
  return {};
2445
+ const target = typeof row.target === 'string' ? { target: row.target } : {};
2437
2446
  const omit = [];
2438
2447
  if (row.type === undefined)
2439
2448
  omit.push('type');
@@ -2442,6 +2451,7 @@ function actionInputShape(task, row) {
2442
2451
  return {
2443
2452
  ...(own ? { taskElementId: true } : row.elementId !== undefined ? { elementId: row.elementId } : {}),
2444
2453
  ...(omit.length ? { omit } : {}),
2454
+ ...target,
2445
2455
  };
2446
2456
  }
2447
2457
  if (row.var === undefined)
@@ -2453,6 +2463,7 @@ function actionInputShape(task, row) {
2453
2463
  // `actionFields` has checked it is a copy of the id.
2454
2464
  ...(row.canonicalId !== undefined ? { canonicalId: true } : {}),
2455
2465
  ...(omit.length ? { omit } : {}),
2466
+ ...target,
2456
2467
  };
2457
2468
  }
2458
2469
  /**
@@ -235,13 +235,14 @@ interface StageIdentity {
235
235
  entryConditions?: ConditionIdentity[];
236
236
  /** The resource the rows' `fields` / `omit` describe; they are applied only while the task still names it. */
237
237
  resource?: ResourceTaskIdentity;
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`, ...). */
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. `target`: the slot an action form input was saved with (`"bodyField"`), which compile does not write. `fields`: a resource task row's Designer fields compile does not write (`displayName`, `title`, `body`, ...). */
239
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. */
240
240
  inputs?: Array<{
241
241
  name: string;
242
242
  id?: string;
243
243
  elementId?: string;
244
244
  canonicalId?: true;
245
+ target?: string;
245
246
  fields?: Record<string, unknown>;
246
247
  omit?: string[];
247
248
  taskElementId?: true;
@@ -385,6 +385,11 @@ export function caseJsonPreservationErrors(payload) {
385
385
  errors.push(`task "${task.name}" ${side} "${row.name}" omits "${String(field)}", which is not an omittable field`);
386
386
  }
387
387
  }
388
+ for (const stage of payload.identities?.stages ?? [])
389
+ for (const task of (stage.tasks ?? []).flat())
390
+ for (const row of task.inputs ?? [])
391
+ if (row.target !== undefined && typeof row.target !== 'string')
392
+ errors.push(`task "${task.name}" input "${row.name}" target must be a string`);
388
393
  for (const stage of payload.identities?.stages ?? [])
389
394
  for (const task of (stage.tasks ?? []).flat())
390
395
  for (const row of task.outputs ?? []) {
@@ -1750,8 +1750,11 @@ function applyPreservedIdentities(result, preservation, warn) {
1750
1750
  if (input && row.taskElementId === true)
1751
1751
  elementIdRows.saved.add(input);
1752
1752
  // An action form input is written `{ name, type, value }`; the Designer's
1753
- // row also has its id, `var` (the id) and `elementId`, which come back.
1753
+ // row also has its id, `var` (the id) and `elementId`, which come back,
1754
+ // and the `target` it was saved with (`"bodyField"`), on any row.
1754
1755
  if (task?.type === 'action' && input && input.id === undefined && input.name === row.name) {
1756
+ if (typeof row.target === 'string' && input.target === undefined)
1757
+ input.target = row.target;
1755
1758
  // The fields the row was saved without: a `type` compile defaulted
1756
1759
  // to `string` (a type the source spells stays, `string` included),
1757
1760
  // and the `var` / `elementId` of a row with an id.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.120.6",
3
+ "version": "6.120.8",
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": "596cf9e55591a9453fb651e8857bfc83b15e67b9"
127
+ "gitref": "3a3d4e840c450128bb797ce23c1bcbcb2a783704"
128
128
  }