@uipath/maestro-builder-sdk 6.93.3 → 6.93.4

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.
@@ -249,6 +249,10 @@ type Preservation = {
249
249
  omitLayout?: boolean;
250
250
  variableLanes?: Array<'inputs' | 'outputs' | 'inputOutputs'>;
251
251
  omitInputDefaults?: string[];
252
+ unbridgedInArgs?: Array<{
253
+ name: string;
254
+ trigger: string;
255
+ }>;
252
256
  omitMetadata?: Array<'caseAppEnabled' | 'caseIdentifierType' | 'publishVersion'>;
253
257
  publishVersion?: number;
254
258
  nodeFields?: Record<string, Record<string, unknown>>;
@@ -18,7 +18,7 @@ import { preserveSchemaVersion } from '../schema-version.js';
18
18
  import { ownEntry } from '../core/own-entry.js';
19
19
  import { EVENT_FILTER_OPERATORS, eventFilterExpressionOf, eventFilterFromTreeLeaf, eventFilterProblem, EXPRESSION_FILTER_OPERATORS, filterExprFromLeaf } from '../core/event-filters.js';
20
20
  import { CASE_FILTER_SPELLING, caseSubscriptionBody, caseSubscriptionOwners } from './subscription.js';
21
- 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, TYPED_TRIGGER_DISPLAY_KEYS, } from './preserve.js';
21
+ import { CASE_NODE_CANVAS_FIELDS, CASE_NODE_LAYOUT_FIELDS, isTypedInputField, isUnrestorableSlotId, planElementIds, 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, TYPED_TRIGGER_DISPLAY_KEYS, } from './preserve.js';
22
22
  import { stableId } from '../core/stable-id.js';
23
23
  import { ACTION_CONTEXT_COPIES, ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
24
24
  import { resourceIdentity, SOLUTION_FOLDER } from './resource-identity.js';
@@ -1749,6 +1749,28 @@ function variableDescription(entry) {
1749
1749
  throw new Error(`variable "${entry.name}" has a non-string "description", which is not authorable.`);
1750
1750
  return description;
1751
1751
  }
1752
+ /**
1753
+ * The `elementId` compile writes on each root `inputOutputs` row, by name: an
1754
+ * In-arg's companion takes the trigger the In-arg is bound to, every other row
1755
+ * `root`. An In-arg whose saved trigger is not a trigger node of the plan is
1756
+ * left out: compile binds it to the primary trigger, which this does not track.
1757
+ */
1758
+ function companionElementIds(plan) {
1759
+ const triggers = new Set((plan.nodes ?? []).filter(isTrigger).map((node) => node.id));
1760
+ const out = new Map();
1761
+ for (const row of plan.variables?.inputOutputs ?? [])
1762
+ if (row?.name)
1763
+ out.set(row.name, 'root');
1764
+ for (const input of plan.variables?.inputs ?? []) {
1765
+ if (!input?.name)
1766
+ continue;
1767
+ if (typeof input.elementId === 'string' && triggers.has(input.elementId))
1768
+ out.set(input.name, input.elementId);
1769
+ else
1770
+ out.delete(input.name);
1771
+ }
1772
+ return out;
1773
+ }
1752
1774
  /**
1753
1775
  * The root `inputOutputs` rows decompile turns into a `.var()`: not an In- or
1754
1776
  * Out-arg's companion, nor a custom row a task output writes. These are the
@@ -1867,6 +1889,23 @@ function inArgsInBridgeOrder(plan) {
1867
1889
  }
1868
1890
  return inputs;
1869
1891
  }
1892
+ /**
1893
+ * In-args bound to a trigger of the plan that no row of that trigger reads
1894
+ * (`{ source: "=vars.<slot>" }`, in `data.inputs.outputs` or a V30 trigger's
1895
+ * stray `data.uipath.outputs`), each with that trigger's id. Compile writes
1896
+ * that bridge row for every In-arg.
1897
+ */
1898
+ function unbridgedInArgs(plan) {
1899
+ const triggers = new Map((plan.nodes ?? []).filter(isTrigger).map((node) => [node.id, node]));
1900
+ return (plan.variables?.inputs ?? []).flatMap((input) => {
1901
+ const node = typeof input.elementId === 'string' ? triggers.get(input.elementId) : undefined;
1902
+ if (!node || typeof node.id !== 'string' || typeof input.id !== 'string' || !input.name)
1903
+ return [];
1904
+ const stray = node.type === 'uipath.case.trigger' ? (node.data?.uipath?.outputs ?? []) : [];
1905
+ const rows = [...(triggerData(node).bag?.outputs ?? []), ...stray];
1906
+ return rows.some((row) => row?.source === `=vars.${input.id}`) ? [] : [{ name: input.name, trigger: node.id }];
1907
+ });
1908
+ }
1870
1909
  function emitVariables(out, depth, plan, triggerNameById, triggerIsTimer) {
1871
1910
  const variables = plan.variables ?? {};
1872
1911
  const produced = producedVariableNames(plan);
@@ -2831,6 +2870,8 @@ export function collectPreservation(plan) {
2831
2870
  const legacyVariableDefaults = {};
2832
2871
  const variableOrder = {};
2833
2872
  const declaredInOut = declaredInOutNames(plan);
2873
+ const writtenElementId = companionElementIds(plan);
2874
+ let elementIds;
2834
2875
  for (const lane of ['inputs', 'outputs', 'inputOutputs']) {
2835
2876
  const rows = plan.variables?.[lane] ?? [];
2836
2877
  if (rows.length)
@@ -2853,6 +2894,23 @@ export function collectPreservation(plan) {
2853
2894
  const formalOutput = (plan.variables?.outputs ?? []).find((candidate) => candidate.name === row.name);
2854
2895
  if (lane === 'inputOutputs' && formalOutput && row.default !== undefined && formalOutput.default !== row.default)
2855
2896
  fields.default = row.default;
2897
+ // The element a root row belongs to. Compile writes the In-arg's trigger on
2898
+ // its companion and `root` on every other row; Studio Web can save another
2899
+ // (a `.var()` row it keeps under `trigger_1` after the In-arg that put it
2900
+ // there went). The converter copies it into the BPMN variables, so it is
2901
+ // carried with the value compile writes, and applied only while compile
2902
+ // still writes that value.
2903
+ if (lane === 'inputOutputs' && typeof row.elementId === 'string') {
2904
+ const written = writtenElementId.get(row.name);
2905
+ if (written !== undefined && written !== row.elementId)
2906
+ Object.assign(fields, {
2907
+ elementId: row.elementId,
2908
+ ...(written === 'root' ? {} : { writtenElementId: written }),
2909
+ // One that named no element when saved stays as saved; compile cannot
2910
+ // tell an element an edit deleted from one that was never there.
2911
+ ...(row.elementId === 'root' || (elementIds ??= planElementIds(plan)).has(row.elementId) ? {} : { elementIdUnresolved: true }),
2912
+ });
2913
+ }
2856
2914
  if (lane === 'outputs' && row.var !== undefined)
2857
2915
  fields.var = row.var;
2858
2916
  // `body` is typed only on a structured (`jsonSchema`) variable. On any
@@ -2885,6 +2943,9 @@ export function collectPreservation(plan) {
2885
2943
  .map((row) => row.name);
2886
2944
  if (omitInputDefaults.length)
2887
2945
  preservation.omitInputDefaults = omitInputDefaults;
2946
+ const unbridged = unbridgedInArgs(plan);
2947
+ if (unbridged.length)
2948
+ preservation.unbridgedInArgs = unbridged;
2888
2949
  if (Object.keys(variableFields).length)
2889
2950
  preservation.variableFields = variableFields;
2890
2951
  if (Object.keys(legacyVariableDefaults).length)
@@ -6,6 +6,14 @@ import type { BindingsView } from '../core/binding-messages.js';
6
6
  import { type PreservedResourceWire } from './resource-wire.js';
7
7
  import { type PreservedDocumentExtractionData } from './document-extraction-saved.js';
8
8
  export type PreservedVariableLane = 'inputs' | 'outputs' | 'inputOutputs';
9
+ /**
10
+ * The ids a variable row's `elementId` can name in `plan`: every node (stages,
11
+ * triggers), and every task, by its own id and by the `<stageId>-<taskId>`
12
+ * form Studio Web writes on task io rows.
13
+ */
14
+ export declare function planElementIds(plan: {
15
+ nodes?: unknown;
16
+ }): Set<string>;
9
17
  /**
10
18
  * A preserved `inputs[]` / `outputs[]` slot id copied verbatim from its name is
11
19
  * the STRICT_FORMAL_ARG_ID defect, not an identity to keep; the minted id stands.
@@ -302,6 +310,18 @@ export interface CaseJsonPreservation {
302
310
  * platform's V23 -> V24 migration does when it makes the same change.
303
311
  */
304
312
  legacyTriggerIds?: string[];
313
+ /**
314
+ * In-args whose trigger has no bridge row reading them (no `{ source:
315
+ * "=vars.<slot>" }` in its `outputs`). Compile writes that row for every
316
+ * In-arg; a Studio Web plan can lack it, and then the companion is never set
317
+ * when the case starts. Compile leaves the row out again for each In-arg
318
+ * only while it is still bound to the trigger that lacked the row: an edit
319
+ * that binds it to another trigger gets that trigger's bridge.
320
+ */
321
+ unbridgedInArgs?: Array<{
322
+ name: string;
323
+ trigger: string;
324
+ }>;
305
325
  /**
306
326
  * Opaque V30 layout side-car. Decompile folds a node's inline
307
327
  * {@link CASE_NODE_LAYOUT_FIELDS} into it, the platform's disk form.
@@ -345,7 +365,16 @@ export interface CaseJsonPreservation {
345
365
  * being silently rewritten.
346
366
  */
347
367
  publishVersion?: number;
348
- /** Designer-internal variable fields keyed by lane and variable name. */
368
+ /**
369
+ * Designer-internal variable fields keyed by lane and variable name. On an
370
+ * `inputOutputs` row, `elementId` is the element Studio Web saved the row
371
+ * under when compile writes another (`writtenElementId`, absent for `root`);
372
+ * compile puts it back only while it still writes that value, so a source
373
+ * edit that moves the row (a `.var()` made an In-arg) keeps compile's. It is
374
+ * also put back only while it is `root` or names an element of the plan
375
+ * (`planElementIds`), unless it named none when saved
376
+ * (`elementIdUnresolved`): an edit that deletes that element gets `root`.
377
+ */
349
378
  variableFields?: Partial<Record<PreservedVariableLane, Record<string, Record<string, unknown>>>>;
350
379
  /**
351
380
  * Legacy non-string defaults retained by decompile/recompile. Each value must
@@ -4,6 +4,23 @@ import { Bindings } from '../core/bindings.js';
4
4
  import { bindingIdCandidates, offlineBindingLabel } from './ids.js';
5
5
  import { resourceBindingSeed, resourceWireError } from './resource-wire.js';
6
6
  import { preservedDocumentExtractionDataError } from './document-extraction-saved.js';
7
+ /**
8
+ * The ids a variable row's `elementId` can name in `plan`: every node (stages,
9
+ * triggers), and every task, by its own id and by the `<stageId>-<taskId>`
10
+ * form Studio Web writes on task io rows.
11
+ */
12
+ export function planElementIds(plan) {
13
+ const ids = new Set();
14
+ for (const node of (Array.isArray(plan.nodes) ? plan.nodes : [])) {
15
+ if (typeof node?.id !== 'string')
16
+ continue;
17
+ ids.add(node.id);
18
+ for (const task of (node.data?.tasks ?? []).flat())
19
+ if (typeof task?.id === 'string')
20
+ ids.add(task.id).add(`${node.id}-${task.id}`);
21
+ }
22
+ return ids;
23
+ }
7
24
  /**
8
25
  * A preserved `inputs[]` / `outputs[]` slot id copied verbatim from its name is
9
26
  * the STRICT_FORMAL_ARG_ID defect, not an identity to keep; the minted id stands.
@@ -280,6 +297,13 @@ export function caseJsonPreservationErrors(payload) {
280
297
  continue;
281
298
  }
282
299
  // A carried `body` names the non-structured type it was saved for.
300
+ for (const [name, fields] of Object.entries(rows ?? {}))
301
+ for (const field of ['elementId', 'writtenElementId'])
302
+ if (fields[field] !== undefined && (typeof fields[field] !== 'string' || fields[field] === ''))
303
+ errors.push(`variable "${name}" carried ${field} must be a non-empty string`);
304
+ for (const [name, fields] of Object.entries(rows ?? {}))
305
+ if (fields.elementIdUnresolved !== undefined && fields.elementIdUnresolved !== true)
306
+ errors.push(`variable "${name}" carried elementIdUnresolved must be true when present`);
283
307
  for (const [name, fields] of Object.entries(rows ?? {}))
284
308
  if (fields.body !== undefined && (typeof fields.bodyType !== 'string' || fields.bodyType === 'jsonSchema'))
285
309
  errors.push(`variable "${name}" carried body needs the non-jsonSchema type it was saved for (bodyType)`);
@@ -288,12 +312,12 @@ export function caseJsonPreservationErrors(payload) {
288
312
  if (lane === 'inputOutputs' && field === 'value')
289
313
  errors.push(`variable "${name}" field "value" on inputOutputs is behavior (a process mapping's var) and cannot be preserved`);
290
314
  else if (!PRESERVED_VARIABLE_KEYS.has(field)
291
- && !(lane === 'inputOutputs' && (field === 'default' || field === 'custom'))
315
+ && !(lane === 'inputOutputs' && (field === 'default' || field === 'custom' || field === 'elementId' || field === 'writtenElementId' || field === 'elementIdUnresolved'))
292
316
  && !(lane === 'outputs' && field === 'var')
293
317
  && field !== 'body' && field !== 'bodyType')
294
318
  errors.push(`variable "${name}" field "${field}" is not an allowed preserved designer field`);
295
319
  else if (VARIABLE_KEYS.has(field)
296
- && !(lane === 'inputOutputs' && field === 'default')
320
+ && !(lane === 'inputOutputs' && (field === 'default' || field === 'elementId'))
297
321
  && !(lane === 'outputs' && field === 'var')
298
322
  && field !== 'body')
299
323
  errors.push(`variable "${name}" field "${field}" is owned by the typed Case serializer`);
@@ -314,6 +338,10 @@ export function caseJsonPreservationErrors(payload) {
314
338
  errors.push(`legacy variable default "${name}" must be a JSON-encodable non-string value`);
315
339
  }
316
340
  }
341
+ if (payload.unbridgedInArgs !== undefined
342
+ && (!Array.isArray(payload.unbridgedInArgs) || !payload.unbridgedInArgs.every((entry) => entry !== null && typeof entry === 'object'
343
+ && typeof entry.name === 'string' && entry.name !== '' && typeof entry.trigger === 'string' && entry.trigger !== '')))
344
+ errors.push('preserved "unbridgedInArgs" must be an array of { name, trigger } with non-empty strings');
317
345
  if (payload.legacyTriggerIds !== undefined
318
346
  && (!Array.isArray(payload.legacyTriggerIds) || !payload.legacyTriggerIds.every((id) => typeof id === 'string')))
319
347
  errors.push('preserved "legacyTriggerIds" must be an array of trigger id strings');
@@ -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 { CASE_EMPTY_LISTS, isUnrestorableSlotId, METADATA_ABSENT_READING, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint } from './preserve.js';
12
+ import { CASE_EMPTY_LISTS, isUnrestorableSlotId, METADATA_ABSENT_READING, planElementIds, 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';
@@ -624,6 +624,7 @@ export function applyPreservation(result, preservation, options = {}) {
624
624
  const named = new Set(order ?? []);
625
625
  variables[lane] = [...ordered, ...rows.filter((row) => !named.has(String(row.name ?? '')))];
626
626
  }
627
+ let elementIds;
627
628
  for (const [lane, byName] of Object.entries(preservation.variableFields ?? {})) {
628
629
  const rows = variables[lane] ?? [];
629
630
  for (const [name, fields] of Object.entries(byName ?? {})) {
@@ -632,16 +633,27 @@ export function applyPreservation(result, preservation, options = {}) {
632
633
  continue;
633
634
  // `custom` alone has nothing to mark when no row is written: an older SDK's
634
635
  // companion for a variable an output writes, which this one migrates away.
635
- if (!row && Object.keys(fields).every((field) => field === 'custom'))
636
+ // A carried `elementId` likewise has no row to re-point.
637
+ if (!row && Object.keys(fields).every((field) => field === 'custom' || (lane === 'inputOutputs' && (field === 'elementId' || field === 'writtenElementId' || field === 'elementIdUnresolved'))))
636
638
  continue;
637
639
  if (!row)
638
640
  throw new CompileRefusal('PRESERVATION_TARGET_MISSING', `preserved variable "${name}" was not regenerated in variables.${lane}.`);
639
641
  for (const [field, value] of Object.entries(fields)) {
640
642
  // `bodyType` is the type a carried `body` was saved for, not a field.
641
- if (field === 'bodyType')
643
+ if (field === 'bodyType' || field === 'writtenElementId' || field === 'elementIdUnresolved')
642
644
  continue;
643
645
  if (row[field] === value)
644
646
  continue;
647
+ // A saved `elementId` replaces the one compile writes only while compile
648
+ // writes the value it wrote at decompile; an edit that moved the row wins.
649
+ // It must also still name an element of the plan (or have named none when
650
+ // saved): an edit that deleted the trigger it names gets compile's `root`.
651
+ if (lane === 'inputOutputs' && field === 'elementId') {
652
+ const stillThere = value === 'root' || fields.elementIdUnresolved === true || (elementIds ??= planElementIds(result)).has(String(value));
653
+ if (stillThere && row.elementId === (fields.writtenElementId ?? 'root'))
654
+ row.elementId = value;
655
+ continue;
656
+ }
645
657
  // A carried `body` describes the type it was saved with. A variable the
646
658
  // edit gave another type (a `string`, or a `jsonSchema` with the schema
647
659
  // the author typed) does not get it.
@@ -676,6 +688,23 @@ export function applyPreservation(result, preservation, options = {}) {
676
688
  row.default = value;
677
689
  }
678
690
  }
691
+ // An In-arg its trigger had no bridge row for: drop the row compile wrote,
692
+ // and the `outputs` list when that row was its only entry. Only while the
693
+ // In-arg is still bound to that trigger: one an edit rebinds keeps its bridge.
694
+ for (const { name, trigger } of preservation.unbridgedInArgs ?? []) {
695
+ const input = (variables.inputs ?? []).find((candidate) => candidate.name === name);
696
+ if (!input || typeof input.id !== 'string' || input.elementId !== trigger)
697
+ continue;
698
+ const node = result.nodes.find((candidate) => candidate.id === input.elementId);
699
+ const bag = node?.data?.[CASE_FORMAT_PROFILE.triggerBagField];
700
+ if (!Array.isArray(bag?.outputs))
701
+ continue;
702
+ bag.outputs = bag.outputs.filter((row) => row?.source !== `=vars.${input.id}`);
703
+ if (!bag.outputs.length)
704
+ delete bag.outputs;
705
+ if (!Object.keys(bag).length)
706
+ delete node.data[CASE_FORMAT_PROFILE.triggerBagField];
707
+ }
679
708
  for (const name of preservation.omitInputDefaults ?? []) {
680
709
  const row = (variables.inputs ?? []).find((candidate) => candidate.name === name);
681
710
  if (row?.default === '')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.93.3",
3
+ "version": "6.93.4",
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",
@@ -111,5 +111,5 @@
111
111
  "@types/node": "^22.7.0",
112
112
  "esbuild": "^0.28.1"
113
113
  },
114
- "gitref": "b79fb2c5ae6006191f9e66aa74fdf305741d6fa4"
114
+ "gitref": "eaccb8095e2b8920cc42d99737e369fd6ab30f8d"
115
115
  }