@uipath/maestro-builder-sdk 6.86.5 → 6.86.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.
@@ -111,9 +111,48 @@ function checkRules(built, rules, where, roots, out) {
111
111
  checkFilterExprs(built, r.connector, `${where} wait-for-connector rule`, roots, out);
112
112
  }
113
113
  }
114
+ /**
115
+ * The case-schema `sanitizeVariableIdentifierIntoStringWithoutBrackets`: an
116
+ * identifier with a segment that is not a JS name has every character outside
117
+ * `[a-zA-Z0-9_]` replaced by `_` (`Stage 1` -> `Stage_1`). A segment that starts
118
+ * with `stage-` / `Stage_` exempts the whole identifier, as there.
119
+ */
120
+ function platformIdentifier(identifier) {
121
+ const segments = identifier.split('.').filter(Boolean);
122
+ if (segments.some((s) => s.startsWith('stage-') || s.startsWith('Stage_')))
123
+ return identifier;
124
+ return segments.some((s) => !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)) ? identifier.replace(/[^a-zA-Z0-9_]/g, '_') : identifier;
125
+ }
126
+ /**
127
+ * Variables the platform declares for every case, which a plan's gates may read
128
+ * though no row of the plan declares them. `uip maestro case validate` adds the
129
+ * same set to the variables it checks against (case-schema
130
+ * `validateCaseManagementVariables`), and the BPMN converter writes each one:
131
+ *
132
+ * - `stageHasRun_<stage label>` per stage (`getCaseStateVariables`), set in the
133
+ * initial variables setup and updated when the stage exits or completes. The
134
+ * platform's own V11->V12 migration writes gates on it:
135
+ * `=js:(vars.stageHasRun_Review != true)` for "first time this stage runs";
136
+ * - the hidden event-subprocess rows `tasksEventSubprocessResponse`,
137
+ * `mainEventSubprocessResponse`, `connectorResponse` and `eventMetadata`.
138
+ *
139
+ * Not here: the per-SLA `stageSla_<stage>_<sla id>` rows, whose ids compile
140
+ * mints after this check runs.
141
+ */
142
+ function platformVariables(built) {
143
+ return [
144
+ ...built.stages.map((s) => `stageHasRun_${platformIdentifier(s.label)}`),
145
+ 'tasksEventSubprocessResponse',
146
+ 'mainEventSubprocessResponse',
147
+ 'connectorResponse',
148
+ 'eventMetadata',
149
+ ];
150
+ }
114
151
  /** Every first-level expression problem in a built case, each stamped with its location. */
115
152
  export function checkCaseExpressions(built) {
116
153
  const roots = new Set(built.vars.map((v) => v.name));
154
+ for (const name of platformVariables(built))
155
+ roots.add(name);
117
156
  // Task output bindings declare readable case variables too (`=vars.<var>`),
118
157
  // via a root `inputOutputs` companion — include them so a gate that reads a
119
158
  // task output is not flagged as an undeclared reference.
@@ -294,6 +294,7 @@ type Preservation = {
294
294
  lane: number;
295
295
  task: string;
296
296
  }>;
297
+ omitTaskDisplayNames?: string[];
297
298
  actionDataFields?: Array<{
298
299
  stage: string;
299
300
  lane: number;
@@ -17,7 +17,7 @@ import { preserveSchemaVersion } from '../schema-version.js';
17
17
  import { ownEntry } from '../core/own-entry.js';
18
18
  import { EVENT_FILTER_OPERATORS, eventFilterExpressionOf, eventFilterFromTreeLeaf, eventFilterProblem, EXPRESSION_FILTER_OPERATORS, filterExprFromLeaf } from '../core/event-filters.js';
19
19
  import { CASE_FILTER_SPELLING, caseSubscriptionBody, caseSubscriptionOwners } from './subscription.js';
20
- import { CASE_NODE_CANVAS_FIELDS, CASE_NODE_LAYOUT_FIELDS, isTypedInputField, isUnrestorableSlotId, PRESERVED_STAGE_DATA_KEYS, PRESERVED_TRIGGER_DATA_KEYS, RESOURCE_INPUT_WRITTEN, RESOURCE_OUTPUT_WRITTEN, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint, PRESERVED_ACTION_DATA_KEYS, } from './preserve.js';
20
+ import { CASE_NODE_CANVAS_FIELDS, CASE_NODE_LAYOUT_FIELDS, isTypedInputField, isUnrestorableSlotId, PRESERVED_STAGE_DATA_KEYS, PRESERVED_TRIGGER_DATA_KEYS, RESOURCE_INPUT_WRITTEN, RESOURCE_OUTPUT_WRITTEN, CASE_EMPTY_LISTS, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint, PRESERVED_ACTION_DATA_KEYS, } from './preserve.js';
21
21
  import { stableId } from '../core/stable-id.js';
22
22
  import { ACTION_CONTEXT_COPIES, ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
23
23
  import { resourceIdentity, SOLUTION_FOLDER } from './resource-identity.js';
@@ -1614,10 +1614,49 @@ function reassignedOwnNameTargets(plan) {
1614
1614
  }
1615
1615
  return targets;
1616
1616
  }
1617
+ /**
1618
+ * The In-args in the order the source declares them: each trigger's In-args
1619
+ * in the order of their bridge rows on that trigger, in the slots those
1620
+ * In-args hold in `variables.inputs`.
1621
+ *
1622
+ * Compile writes a trigger's bridge rows (`{ source: '=vars.<slot>', var:
1623
+ * <companion> }`) in `.input()` order, and the preserved row order puts the
1624
+ * root lanes back afterwards. The Case Designer keeps the two orders apart:
1625
+ * an In-arg added to the trigger later can sit before older ones on the
1626
+ * trigger and after them in `variables.inputs`. Declaring In-args in bridge
1627
+ * order keeps both. A trigger with an In-arg no bridge row reads keeps the
1628
+ * root order.
1629
+ *
1630
+ * Example: `variables.inputs` is `[a, b, c]` and the trigger's bridge rows read
1631
+ * `[c, a, b]`; the source declares `.input({ c })`, `.input({ a })`, `.input({ b })`.
1632
+ */
1633
+ function inArgsInBridgeOrder(plan) {
1634
+ const inputs = [...(plan.variables?.inputs ?? [])];
1635
+ for (const node of (plan.nodes ?? []).filter(isTrigger)) {
1636
+ const slots = inputs.flatMap((input, index) => (input.elementId === node.id ? [index] : []));
1637
+ if (slots.length < 2)
1638
+ continue;
1639
+ const position = new Map();
1640
+ // A V30 trigger can also hold bridge rows in a stray `data.uipath` bag; the
1641
+ // platform's migration reads them after the `data.inputs` rows.
1642
+ const stray = node.type === 'uipath.case.trigger' ? (node.data?.uipath?.outputs ?? []) : [];
1643
+ [...(triggerData(node).bag?.outputs ?? []), ...stray].forEach((row, index) => {
1644
+ const slot = typeof row?.source === 'string' ? /^=vars\.(.+)$/.exec(row.source)?.[1] : undefined;
1645
+ if (slot !== undefined && !position.has(slot))
1646
+ position.set(slot, index);
1647
+ });
1648
+ const own = slots.map((index) => inputs[index]);
1649
+ if (own.some((input) => typeof input.id !== 'string' || !position.has(input.id)))
1650
+ continue;
1651
+ const ordered = [...own].sort((a, b) => position.get(a.id) - position.get(b.id));
1652
+ slots.forEach((slot, index) => { inputs[slot] = ordered[index]; });
1653
+ }
1654
+ return inputs;
1655
+ }
1617
1656
  function emitVariables(out, depth, plan, triggerNameById, triggerIsTimer) {
1618
1657
  const variables = plan.variables ?? {};
1619
1658
  const produced = producedVariableNames(plan);
1620
- for (const input of variables.inputs ?? []) {
1659
+ for (const input of inArgsInBridgeOrder(plan)) {
1621
1660
  let from = input.elementId && triggerNameById.get(input.elementId);
1622
1661
  // An In-arg with no trigger is a shape only older SDKs wrote (builder-sdk
1623
1662
  // #1368): no companion, so nothing binds it. A bare `.input()` now binds to
@@ -2105,6 +2144,7 @@ function identityPreservation(plan) {
2105
2144
  }),
2106
2145
  caseExitRules: (plan.metadata?.caseExitRules ?? []).map(conditionIdentity),
2107
2146
  slaRules: (plan.metadata?.slaRules ?? []).map(slaIdentity),
2147
+ ...emptyLists(plan.metadata ?? {}, CASE_EMPTY_LISTS),
2108
2148
  variables: Object.fromEntries(['inputs', 'outputs', 'inputOutputs'].map((lane) => [
2109
2149
  lane,
2110
2150
  (plan.variables?.[lane] ?? []).map((row) => ({ name: row.name, ...(row.id ? { id: row.id } : {}), ...variableShape(row) })),
@@ -2385,6 +2425,7 @@ export function collectPreservation(plan) {
2385
2425
  const connectorConfigurations = [];
2386
2426
  const httpRequestMetadata = [];
2387
2427
  const omitTaskElementIds = [];
2428
+ const omitTaskDisplayNames = [];
2388
2429
  const actionDataFields = [];
2389
2430
  const documentExtractionData = [];
2390
2431
  const omitStagePositions = [];
@@ -2409,6 +2450,10 @@ export function collectPreservation(plan) {
2409
2450
  // `omitTaskElementIds` in preserve.ts.
2410
2451
  if (!Object.prototype.hasOwnProperty.call(task, 'elementId'))
2411
2452
  omitTaskElementIds.push({ stage: label, lane: laneIndex, task: task.displayName ?? '' });
2453
+ // A task saved with no name must not gain `displayName: ""`: see
2454
+ // `omitTaskDisplayNames` in preserve.ts.
2455
+ if (task.displayName === undefined && typeof task.id === 'string' && task.id !== '')
2456
+ omitTaskDisplayNames.push(task.id);
2412
2457
  const fields = Object.fromEntries(Object.entries(task).filter(([name]) => !taskKnown.has(name) && name !== 'elementId'));
2413
2458
  for (const field of Object.keys(fields))
2414
2459
  throw new Error(`task "${task.displayName ?? task.id ?? '?'}" has unsupported field "${field}", which is not allowed in the collision-refusing preservation channel.`);
@@ -2464,6 +2509,8 @@ export function collectPreservation(plan) {
2464
2509
  preservation.subscriptionFilters = subscriptionFilterEntries;
2465
2510
  if (omitTaskElementIds.length)
2466
2511
  preservation.omitTaskElementIds = omitTaskElementIds;
2512
+ if (omitTaskDisplayNames.length)
2513
+ preservation.omitTaskDisplayNames = omitTaskDisplayNames;
2467
2514
  if (actionDataFields.length)
2468
2515
  preservation.actionDataFields = actionDataFields;
2469
2516
  if (documentExtractionData.length)
@@ -211,12 +211,18 @@ interface StageIdentity {
211
211
  emptyLists?: string[];
212
212
  }
213
213
  /**
214
- * The condition lists the serializer omits when empty, which the Designer
215
- * writes both as `[]` and as no field. The payload records which were `[]`;
216
- * compile writes `[]` back on a list that is still empty and absent.
214
+ * The lists the serializer omits when empty, which the Designer writes both as
215
+ * `[]` and as no field. The payload records which were `[]`; compile writes
216
+ * `[]` back on a list that is still empty and absent.
217
+ *
218
+ * `slaRules` (a stage's `data.slaRules`, the case's `metadata.slaRules`): the
219
+ * platform reads `[]` and no field alike (every `@uipath/case-schema` read is
220
+ * `slaRules ?? []` or `slaRules?.length`), so this is the Designer's spelling
221
+ * only, carried like the condition lists.
217
222
  */
218
223
  export declare const TASK_EMPTY_LISTS: readonly ["entryConditions"];
219
- export declare const STAGE_EMPTY_LISTS: readonly ["entryConditions", "exitConditions"];
224
+ export declare const STAGE_EMPTY_LISTS: readonly ["entryConditions", "exitConditions", "slaRules"];
225
+ export declare const CASE_EMPTY_LISTS: readonly ["slaRules"];
220
226
  /**
221
227
  * A task less its rows, its ids and every display name (a condition's defaults
222
228
  * to its task's): what renaming it leaves alone, so a rename beside a deleted
@@ -231,6 +237,8 @@ interface CaseIdentityPreservation {
231
237
  stages?: StageIdentity[];
232
238
  caseExitRules?: ConditionIdentity[];
233
239
  slaRules?: SlaIdentity[];
240
+ /** Fields of `CASE_EMPTY_LISTS` the read plan's `metadata` spelled `[]`. */
241
+ emptyLists?: string[];
234
242
  /** `omit: ['_jsonSchema']`: a structured variable saved with its schema in `body` only. */
235
243
  variables?: Partial<Record<PreservedVariableLane, Array<{
236
244
  name: string;
@@ -402,6 +410,17 @@ export interface CaseJsonPreservation {
402
410
  * contract; greenfield authoring still always gets one.
403
411
  */
404
412
  omitTaskElementIds?: PreservedTaskRef[];
413
+ /**
414
+ * Ids of the tasks the source saved with no `displayName`. The builder names
415
+ * every task (`.task("", ...)` for such a task), and the serializer writes
416
+ * `displayName: ""`. The two are not the same to the platform: the converter
417
+ * embeds each task's JSON verbatim in the BPMN it writes
418
+ * (`serializeTaskForCaseManagement` in `@uipath/case-schema`), and its
419
+ * validation names a task `displayName ?? data.name ?? id`, so `""` would
420
+ * replace the fallback. Compile removes the field from a listed task while
421
+ * its name is still `""`; a task the author named keeps its name.
422
+ */
423
+ omitTaskDisplayNames?: string[];
405
424
  /** Opaque wire identities aligned to typed constructs by name and position. */
406
425
  identities?: CaseIdentityPreservation;
407
426
  /**
@@ -59,12 +59,18 @@ export const STAGE_DESIGNER_FIELDS = ['parentElement', 'isInvalidDropTarget', 'i
59
59
  */
60
60
  export const PRESERVED_STAGE_DATA_KEYS = new Set([...STAGE_DESIGNER_FIELDS, 'instanceIdPrefix', 'sla', 'isCaseManagerStage']);
61
61
  /**
62
- * The condition lists the serializer omits when empty, which the Designer
63
- * writes both as `[]` and as no field. The payload records which were `[]`;
64
- * compile writes `[]` back on a list that is still empty and absent.
62
+ * The lists the serializer omits when empty, which the Designer writes both as
63
+ * `[]` and as no field. The payload records which were `[]`; compile writes
64
+ * `[]` back on a list that is still empty and absent.
65
+ *
66
+ * `slaRules` (a stage's `data.slaRules`, the case's `metadata.slaRules`): the
67
+ * platform reads `[]` and no field alike (every `@uipath/case-schema` read is
68
+ * `slaRules ?? []` or `slaRules?.length`), so this is the Designer's spelling
69
+ * only, carried like the condition lists.
65
70
  */
66
71
  export const TASK_EMPTY_LISTS = ['entryConditions'];
67
- export const STAGE_EMPTY_LISTS = ['entryConditions', 'exitConditions'];
72
+ export const STAGE_EMPTY_LISTS = ['entryConditions', 'exitConditions', 'slaRules'];
73
+ export const CASE_EMPTY_LISTS = ['slaRules'];
68
74
  /**
69
75
  * A task less its rows, its ids and every display name (a condition's defaults
70
76
  * to its task's): what renaming it leaves alone, so a rename beside a deleted
@@ -309,6 +315,9 @@ export function caseJsonPreservationErrors(payload) {
309
315
  errors.push(`task "${task.name}" ${side} "${row.name}" omits "${String(field)}", which is not an omittable field`);
310
316
  }
311
317
  }
318
+ for (const id of payload.omitTaskDisplayNames ?? [])
319
+ if (typeof id !== 'string' || id === '')
320
+ errors.push('omitted task displayName ids must be non-empty strings');
312
321
  for (const entry of payload.omitTaskElementIds ?? [])
313
322
  if (!Number.isInteger(entry.lane) || entry.lane < 0)
314
323
  errors.push(`omitted-elementId task lane "${entry.lane}" is not a non-negative integer`);
@@ -9,7 +9,7 @@
9
9
  * name) are resolved here to the generated ids.
10
10
  */
11
11
  import { IdGen, offlineBindingSeed } from './ids.js';
12
- import { isUnrestorableSlotId, METADATA_ABSENT_READING, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint } from './preserve.js';
12
+ import { CASE_EMPTY_LISTS, isUnrestorableSlotId, METADATA_ABSENT_READING, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint } from './preserve.js';
13
13
  import { v31TaskSets } from './task-sets.js';
14
14
  import { camelizeName, defaultActionOutputVar } from './action-output-var.js';
15
15
  import { ACTION_CONTEXT_COPIES, ACTION_FORM_KIND_CONTEXT, ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
@@ -855,6 +855,16 @@ export function applyPreservation(result, preservation, options = {}) {
855
855
  else if (preservation.omitLayout)
856
856
  delete result.layout;
857
857
  applyResourceWires(result, preservation.resourceWires);
858
+ // Last, after every lookup of a task by its name: a task the source saved
859
+ // with no name gets none back while it is still unnamed (preserve.ts).
860
+ if (preservation.omitTaskDisplayNames?.length) {
861
+ const unnamed = new Set(preservation.omitTaskDisplayNames);
862
+ for (const stage of stageNodes)
863
+ for (const lane of stage.data?.tasks ?? [])
864
+ for (const task of lane)
865
+ if (unnamed.has(task?.id) && task.displayName === '')
866
+ delete task.displayName;
867
+ }
858
868
  // Root rows of the original that compile does not write itself
859
869
  // (preserve.ts `unreadBindings` / `readBindings` / `bindings`): a row the
860
870
  // original read nowhere stays, as Studio Web keeps it; any other stays while
@@ -1464,6 +1474,7 @@ function applyPreservedIdentities(result, preservation) {
1464
1474
  const metadata = result.metadata;
1465
1475
  takeConditions(metadata.caseExitRules, identities.caseExitRules);
1466
1476
  takeSlas(metadata.slaRules, identities.slaRules);
1477
+ restoreEmptyLists(metadata, identities.emptyLists, CASE_EMPTY_LISTS);
1467
1478
  restoreSlaIds();
1468
1479
  const variables = result.variables;
1469
1480
  if (carriedCompanions.size) {
@@ -3340,7 +3351,10 @@ function emitRule(r, seed, ownerId, ids, resolver, site) {
3340
3351
  throw new CompileRefusal('UNKNOWN_BUSINESS_EVENT', `rule "api-event" in ${site} listens for business event "${r.businessEvent}", which the case does not declare — add .businessEvent(${JSON.stringify(r.businessEvent)}).`);
3341
3352
  out.businessEventType = r.businessEvent;
3342
3353
  }
3343
- if (r.expression)
3354
+ // An empty gate is written as given: Studio Web saves `conditionExpression: ""`
3355
+ // on rules it never gated, and the platform reads it as no gate (every
3356
+ // reader tests `conditionExpression?.length`), so it round-trips as it is.
3357
+ if (r.expression !== undefined)
3344
3358
  out.conditionExpression = r.expression;
3345
3359
  return out;
3346
3360
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.5",
3
+ "version": "6.86.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",
@@ -103,5 +103,5 @@
103
103
  "@types/node": "^22.7.0",
104
104
  "esbuild": "^0.28.1"
105
105
  },
106
- "gitref": "ab528288226a2e7a52d8d6901afc14dc14d24f0d"
106
+ "gitref": "0a4dddd7aa5cb592cb1a9a15ef0c9a483859c6b2"
107
107
  }