@uipath/maestro-builder-sdk 6.120.6 → 6.120.7

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)
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.7",
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": "f927fee124eec291c9647253cc5bdb152b0b7213"
128
128
  }