@uipath/maestro-builder-sdk 6.86.6 → 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;
@@ -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
@@ -2386,6 +2425,7 @@ export function collectPreservation(plan) {
2386
2425
  const connectorConfigurations = [];
2387
2426
  const httpRequestMetadata = [];
2388
2427
  const omitTaskElementIds = [];
2428
+ const omitTaskDisplayNames = [];
2389
2429
  const actionDataFields = [];
2390
2430
  const documentExtractionData = [];
2391
2431
  const omitStagePositions = [];
@@ -2410,6 +2450,10 @@ export function collectPreservation(plan) {
2410
2450
  // `omitTaskElementIds` in preserve.ts.
2411
2451
  if (!Object.prototype.hasOwnProperty.call(task, 'elementId'))
2412
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);
2413
2457
  const fields = Object.fromEntries(Object.entries(task).filter(([name]) => !taskKnown.has(name) && name !== 'elementId'));
2414
2458
  for (const field of Object.keys(fields))
2415
2459
  throw new Error(`task "${task.displayName ?? task.id ?? '?'}" has unsupported field "${field}", which is not allowed in the collision-refusing preservation channel.`);
@@ -2465,6 +2509,8 @@ export function collectPreservation(plan) {
2465
2509
  preservation.subscriptionFilters = subscriptionFilterEntries;
2466
2510
  if (omitTaskElementIds.length)
2467
2511
  preservation.omitTaskElementIds = omitTaskElementIds;
2512
+ if (omitTaskDisplayNames.length)
2513
+ preservation.omitTaskDisplayNames = omitTaskDisplayNames;
2468
2514
  if (actionDataFields.length)
2469
2515
  preservation.actionDataFields = actionDataFields;
2470
2516
  if (documentExtractionData.length)
@@ -410,6 +410,17 @@ export interface CaseJsonPreservation {
410
410
  * contract; greenfield authoring still always gets one.
411
411
  */
412
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[];
413
424
  /** Opaque wire identities aligned to typed constructs by name and position. */
414
425
  identities?: CaseIdentityPreservation;
415
426
  /**
@@ -315,6 +315,9 @@ export function caseJsonPreservationErrors(payload) {
315
315
  errors.push(`task "${task.name}" ${side} "${row.name}" omits "${String(field)}", which is not an omittable field`);
316
316
  }
317
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');
318
321
  for (const entry of payload.omitTaskElementIds ?? [])
319
322
  if (!Number.isInteger(entry.lane) || entry.lane < 0)
320
323
  errors.push(`omitted-elementId task lane "${entry.lane}" is not a non-negative integer`);
@@ -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
@@ -3341,7 +3351,10 @@ function emitRule(r, seed, ownerId, ids, resolver, site) {
3341
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)}).`);
3342
3352
  out.businessEventType = r.businessEvent;
3343
3353
  }
3344
- 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)
3345
3358
  out.conditionExpression = r.expression;
3346
3359
  return out;
3347
3360
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.6",
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": "6fed189493e2005b3b20ac7b157cd98115465ebb"
106
+ "gitref": "0a4dddd7aa5cb592cb1a9a15ef0c9a483859c6b2"
107
107
  }