@uipath/maestro-builder-sdk 6.120.12 → 6.120.13

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.
@@ -331,18 +331,35 @@ function counterpartOf(builtOwn, row) {
331
331
  * 'responseRow', var: 'responseRow', originalVar: 'response', source:
332
332
  * '=response' }`). The extract that writes the saved row's variable is its
333
333
  * counterpart, and having no id it says nothing about renumbering, so the
334
- * ids are compared only when the counterpart has one.
334
+ * ids are compared only when the counterpart has one ({@link writesSameVariable}).
335
335
  */
336
336
  function outputsDiverge(builtOwn, set, caseVariables) {
337
337
  return set.rows.some((row) => {
338
338
  const counterpart = counterpartOf(builtOwn, row);
339
- if (!counterpart)
339
+ if (!counterpart || writesSameVariable(counterpart, row))
340
340
  return false;
341
341
  if (counterpart.id !== undefined && counterpart.id !== row.id)
342
342
  return true;
343
- return row.var !== undefined && counterpart.var !== row.var && !reassignedToCaseVariable(row, counterpart, caseVariables);
343
+ return !reassignedToCaseVariable(row, counterpart, caseVariables);
344
344
  });
345
345
  }
346
+ /**
347
+ * Whether the built `counterpart` of saved own row `saved` writes the variable
348
+ * the saved row wrote.
349
+ *
350
+ * Compile writes an element's own row with `id == var`, so the id names the
351
+ * variable. An event trigger's declared output (`eventTrigger({ outputs: {
352
+ * caseRecord: { source: "=response" } } })`) is written with no id: its `var`
353
+ * names the variable. Decompile declares a trigger's own row that way when
354
+ * Studio Web saved it without `elementId`, and the saved row may still have
355
+ * its slot id (`{ id: "caseRecord", var: "caseRecord" }`), which an id-less
356
+ * row cannot match.
357
+ */
358
+ function writesSameVariable(counterpart, saved) {
359
+ if (counterpart.id === undefined)
360
+ return saved.var === undefined ? saved.id === undefined : counterpart.var === saved.var;
361
+ return counterpart.id === saved.id && (saved.var === undefined || counterpart.var === saved.var);
362
+ }
346
363
  /**
347
364
  * The saved outputs over the built ones: the saved own rows in saved order,
348
365
  * where compile put its first own row, around the rows compile writes for the
@@ -24,13 +24,21 @@
24
24
  * exit conditions, then its tasks' entry conditions set by set), then
25
25
  * `metadata.caseExitRules`, then a preserved Case Manager configuration's tasks.
26
26
  *
27
- * One gap, on purpose: the platform's generated-name list is localized (about
28
- * 270 templates in nine languages). Only the English numbered templates are
29
- * mirrored here. A localized generated name that repeats is therefore
30
- * suffixed (`Regla de entrada 1 2`) where the platform would renumber it
31
- * (`Regla de entrada 2`). Only a decompiled pre-V32 document saved by a
32
- * localized Designer can reach that, and the result is still unique.
27
+ * The platform's numbered templates are localized (68 of them, in nine
28
+ * languages), and all are mirrored here: a decompiled pre-V32 document saved
29
+ * by a localized Designer repeats them (`開始ルール 1` on every task of a
30
+ * Japanese plan), and the platform renumbers each repeat (`開始ルール 2`). With
31
+ * the English list only, compile suffixed them instead (`開始ルール 1 2`), so an
32
+ * unedited round trip renamed every such condition.
33
+ * `tests/case-v32-native.test.ts` checks the list against the pin's.
33
34
  */
35
+ /**
36
+ * The Designer's numbered condition names, every language
37
+ * (`NUMBERED_RULE_NAME_TEMPLATES` in `CaseManagementRuleNameTemplates.ts`,
38
+ * `@uipath/case-schema` 0.1173.0), verbatim: `{{number}}` is the counter, and
39
+ * the French ones put a no-break space (U+00A0) before it.
40
+ */
41
+ export declare const NUMBERED_RULE_NAME_TEMPLATES: readonly string[];
34
42
  /**
35
43
  * Rename repeated condition names in place, first occurrence wins, so the
36
44
  * document carries the names the platform's V31 -> V32 and V32 -> V32.0.1
@@ -24,24 +24,95 @@
24
24
  * exit conditions, then its tasks' entry conditions set by set), then
25
25
  * `metadata.caseExitRules`, then a preserved Case Manager configuration's tasks.
26
26
  *
27
- * One gap, on purpose: the platform's generated-name list is localized (about
28
- * 270 templates in nine languages). Only the English numbered templates are
29
- * mirrored here. A localized generated name that repeats is therefore
30
- * suffixed (`Regla de entrada 1 2`) where the platform would renumber it
31
- * (`Regla de entrada 2`). Only a decompiled pre-V32 document saved by a
32
- * localized Designer can reach that, and the result is still unique.
27
+ * The platform's numbered templates are localized (68 of them, in nine
28
+ * languages), and all are mirrored here: a decompiled pre-V32 document saved
29
+ * by a localized Designer repeats them (`開始ルール 1` on every task of a
30
+ * Japanese plan), and the platform renumbers each repeat (`開始ルール 2`). With
31
+ * the English list only, compile suffixed them instead (`開始ルール 1 2`), so an
32
+ * unedited round trip renamed every such condition.
33
+ * `tests/case-v32-native.test.ts` checks the list against the pin's.
33
34
  */
34
- /** The Designer's English numbered condition names (`CaseManagementRuleNameTemplates.ts`). */
35
- const NUMBERED_TEMPLATES = [
36
- 'Case completion rule',
37
- 'Case exit',
38
- 'Completion rule',
39
- 'Condition',
40
- 'Entry rule',
41
- 'Exit rule',
35
+ /**
36
+ * The Designer's numbered condition names, every language
37
+ * (`NUMBERED_RULE_NAME_TEMPLATES` in `CaseManagementRuleNameTemplates.ts`,
38
+ * `@uipath/case-schema` 0.1173.0), verbatim: `{{number}}` is the counter, and
39
+ * the French ones put a no-break space (U+00A0) before it.
40
+ */
41
+ export const NUMBERED_RULE_NAME_TEMPLATES = [
42
+ 'Abschlussregel {{number}}',
43
+ 'Austrittsregel {{number}}',
44
+ 'Bedingung {{number}}',
45
+ 'Case completion rule {{number}}',
46
+ 'Case exit {{number}}',
47
+ 'Completion rule {{number}}',
48
+ 'Condición {{number}}',
49
+ 'Condition {{number}}',
50
+ 'Condição {{number}}',
51
+ 'Condiție {{number}}',
52
+ 'Eintrittsregel {{number}}',
53
+ 'Entry rule {{number}}',
54
+ 'Exit rule {{number}}',
55
+ 'Fallabschlussregel {{number}}',
56
+ 'Fallaustritt {{number}}',
57
+ 'Giriş kuralı {{number}}',
58
+ 'Ieșire din caz {{number}}',
59
+ 'Koşul {{number}}',
60
+ 'Regla de entrada {{number}}',
61
+ 'Regla de finalización de caso {{number}}',
62
+ 'Regla de finalización del caso {{number}}',
63
+ 'Regla de finalización {{number}}',
64
+ 'Regla de salida {{number}}',
65
+ 'Regra de conclusão de caso {{number}}',
66
+ 'Regra de conclusão do caso {{number}}',
67
+ 'Regra de conclusão {{number}}',
68
+ 'Regra de entrada {{number}}',
69
+ 'Regra de saída {{number}}',
70
+ 'Regulă de finalizare a cazului {{number}}',
71
+ 'Regulă de finalizare {{number}}',
72
+ 'Regulă de ieșire {{number}}',
73
+ 'Regulă de intrare {{number}}',
74
+ 'Règle de fin du cas\u00A0{{number}}',
75
+ 'Règle de fin\u00A0{{number}}',
76
+ 'Règle d’entrée\u00A0{{number}}',
77
+ 'Règles de sortie\u00A0{{number}}',
78
+ 'Salida de caso {{number}}',
79
+ 'Salida del caso {{number}}',
80
+ 'Saída de caso {{number}}',
81
+ 'Saída do caso: {{number}}',
82
+ 'Sortie de cas\u00A0{{number}}',
83
+ 'Tamamlama kuralı {{number}}',
84
+ 'Çıkış kuralı {{number}}',
85
+ 'İşlem birimi tamamlama kuralı {{number}}',
86
+ 'İşlem birimi çıkışı {{number}}',
87
+ 'ケースの終了 {{number}}',
88
+ 'ケース完了ルール {{number}}',
89
+ '完了ルール {{number}}',
90
+ '完成規則 {{number}}',
91
+ '完成规则 {{number}}',
92
+ '条件 {{number}}',
93
+ '案件完成規則 {{number}}',
94
+ '案件結束 {{number}}',
95
+ '案例完成规则 {{number}}',
96
+ '案例退出 {{number}}',
97
+ '條件 {{number}}',
98
+ '終了ルール {{number}}',
99
+ '輸入規則 {{number}}',
100
+ '进入规则 {{number}}',
101
+ '退出規則 {{number}}',
102
+ '退出规则 {{number}}',
103
+ '開始ルール {{number}}',
104
+ '사례 완료 규칙 {{number}}',
105
+ '사례 종료 {{number}}',
106
+ '완료 규칙 {{number}}',
107
+ '조건 {{number}}',
108
+ '종료 규칙 {{number}}',
109
+ '진입 규칙 {{number}}',
42
110
  ];
43
111
  const escapeRegex = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
44
- const numbered = (flags) => NUMBERED_TEMPLATES.map((prefix) => ({ prefix, pattern: new RegExp(`^${escapeRegex(prefix)} \\d+$`, flags) }));
112
+ const numbered = (flags) => NUMBERED_RULE_NAME_TEMPLATES.map((template) => ({
113
+ template,
114
+ pattern: new RegExp(`^${escapeRegex(template).replace('\\{\\{number\\}\\}', '\\d+')}$`, flags),
115
+ }));
45
116
  const NUMBERED_EXACT = numbered('');
46
117
  const NUMBERED_LOOSE = numbered('i');
47
118
  const TRAILING_NUMBER = /^(.*\D)(\d+)$/;
@@ -123,8 +194,8 @@ export function dedupeConditionNames(plan) {
123
194
  };
124
195
  // V31 -> V32: only a repeated generated name, renumbered from 1.
125
196
  pass((name, taken) => {
126
- const template = NUMBERED_EXACT.find(({ pattern }) => pattern.test(name));
127
- return template ? nextNumberedName(taken, (n) => `${template.prefix} ${n}`) : undefined;
197
+ const match = NUMBERED_EXACT.find(({ pattern }) => pattern.test(name));
198
+ return match ? nextNumberedName(taken, (n) => match.template.replace('{{number}}', String(n))) : undefined;
128
199
  });
129
200
  // V32 -> V32.0.1: every remaining repeat.
130
201
  pass((name, taken) => {
@@ -556,8 +556,10 @@ export function applyPreservation(result, preservation, options = {}) {
556
556
  // After the ids are restored: an unchanged connector element takes its saved own io rows.
557
557
  applyConnectorRows(result, preservation.connectorRows);
558
558
  applySubscriptionBindings(result, preservation.subscriptionBindings);
559
- // Last, once every row has its saved name and the connector rows are back.
559
+ // Once every row has its saved name and the connector rows are back.
560
560
  restoreOutputInterleaving(result, preservation.identities);
561
+ // Last: an unchanged task's output rows take their full saved order.
562
+ restoreOutputRowOrder(result, preservation.identities);
561
563
  Object.assign(result, preservation.topLevel ?? {});
562
564
  Object.assign(result.metadata, preservation.metadata ?? {});
563
565
  const metadata = result.metadata;
@@ -1300,6 +1302,49 @@ function restoreNoTasks(data, spelling) {
1300
1302
  }
1301
1303
  /** The fields compile writes on a resource task's input that the row can be saved without (decompile's `resourceRowShape`). */
1302
1304
  const RESOURCE_INPUT_OMITTABLE = new Set(['id', 'var', 'elementId']);
1305
+ /**
1306
+ * Each task's output rows back in the order they were saved in, while the task
1307
+ * still has exactly the rows it was saved with.
1308
+ *
1309
+ * Compile writes a connector task's rows as `uip maestro case sdd convert`
1310
+ * does: `response`, `Error`, then the author's extracts. The Case Designer
1311
+ * writes the extracts before `Error`:
1312
+ *
1313
+ * saved: response4, createdById, id, updatedById, error12
1314
+ * compiled: response4, error12, createdById, id, updatedById
1315
+ *
1316
+ * Row order is part of the plan the Designer reads, so an unedited round trip
1317
+ * keeps it. The saved order is the identity's `outputs`, read once every id is
1318
+ * final. A task whose rows the edit changed (a row added or removed, or one
1319
+ * with no id to match on) keeps compile's order.
1320
+ */
1321
+ function restoreOutputRowOrder(result, identities) {
1322
+ const savedOrder = new Map();
1323
+ for (const stage of identities?.stages ?? [])
1324
+ for (const lane of stage.tasks ?? [])
1325
+ for (const task of lane)
1326
+ if (typeof task.id === 'string' && task.outputs?.length && task.outputs.every((row) => typeof row.id === 'string'))
1327
+ savedOrder.set(task.id, task.outputs.map((row) => row.id));
1328
+ if (!savedOrder.size)
1329
+ return;
1330
+ for (const node of result.nodes ?? []) {
1331
+ if (!String(node?.type ?? '').endsWith('Stage'))
1332
+ continue;
1333
+ for (const task of (node.data?.tasks ?? []).flat()) {
1334
+ const order = savedOrder.get(task?.id);
1335
+ const rows = task?.data?.outputs;
1336
+ if (!order || !Array.isArray(rows) || rows.length !== order.length)
1337
+ continue;
1338
+ const at = new Map(order.map((id, index) => [id, index]));
1339
+ if (at.size !== order.length)
1340
+ continue;
1341
+ const ids = rows.map((row) => row?.id);
1342
+ if (!ids.every((id) => typeof id === 'string' && at.has(id)) || new Set(ids).size !== ids.length)
1343
+ continue;
1344
+ rows.sort((left, right) => at.get(left.id) - at.get(right.id));
1345
+ }
1346
+ }
1347
+ }
1303
1348
  /**
1304
1349
  * A task entry condition's saved `isInterrupting`, and the absence of a name
1305
1350
  * it was saved with (`ConditionIdentity`), by position. The name goes only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.120.12",
3
+ "version": "6.120.13",
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": "e13203349421d4dad00a32436c1c29eb0b547534"
127
+ "gitref": "265277b8bbf1f2fb15a625631533026b7a7ca33c"
128
128
  }