@uipath/maestro-builder-sdk 6.85.5 → 6.85.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.
@@ -1658,9 +1658,11 @@ export interface ActivityNodeOpts extends ActivityOpts {
1658
1658
  * on a machine that has it, then `node scripts/materialize-bpmn-registry.mjs` to add it
1659
1659
  * to the snapshot for good.
1660
1660
  *
1661
- * `bpmn-decompile` cannot recover this — it reads the artifact, not the registry — so
1662
- * an import of such a node comes back as a plain `.activity()` that needs the spec
1663
- * added by hand.
1661
+ * `bpmn-decompile` writes one for an imported node whose type the registry does not
1662
+ * list, read off the artifact itself: the element, the payload's tag, and nothing to
1663
+ * derive, with every context, input and output row spelled out beside it. That spec
1664
+ * carries the node through a round trip exactly; it says nothing about which fields
1665
+ * the type needs, so a node authored from scratch still wants the registry's.
1664
1666
  */
1665
1667
  spec?: RegistryTypeSpec;
1666
1668
  /** Variable the type's own output lands in. Defaults to `<id>_<outputName>`. */
@@ -2,7 +2,7 @@ import { allNodes, collectSerializerRefusals, folderCompanionKeys, implicitNodeV
2
2
  import { KNOWN_METHOD_SET } from './known-methods.js';
3
3
  import { EQUALS_EXPR_DIALECT, checkConnectorLookups, checkConnectorResources, checkConnectorSchema, } from '../core/connector-checks.js';
4
4
  import { checkEventResolution, checkEventSubscription, eventParamsFor, } from '../core/event-checks.js';
5
- import { bindingRequiredFields, CASE_RUNTIME_INTERNAL_TYPES, CONNECTOR_ACTIVITY_TYPES, missingRequiredContext, missingRequiredInputs, REGISTRY_GAPS, registryType, } from './typed-node.js';
5
+ import { bindingRequiredFields, CASE_RUNTIME_INTERNAL_TYPES, CONNECTOR_ACTIVITY_TYPES, missingRequiredContext, missingRequiredInputs, platformEnforcesRequired, REGISTRY_GAPS, registryType, } from './typed-node.js';
6
6
  import { ownEntry } from '../core/own-entry.js';
7
7
  import { isManagedHttpV2, managedHttpAbsoluteUrl, managedHttpMissing } from './managed-http.js';
8
8
  import { connectorV2Missing, isConnectorV2 } from './connector.js';
@@ -1499,11 +1499,21 @@ inEventSubProcess = false) {
1499
1499
  : connectorV2
1500
1500
  ? connectorV2Missing(n.type, contextNames)
1501
1501
  : missingRequiredContext(n.type, contextNames, n.spec);
1502
+ // ERROR only where `uip maestro bpmn validate` holds the node to the field; a WARNING
1503
+ // where only the registry calls it required. For a type whose payload the canvas
1504
+ // owns (dynamic, or a discovered `Intsvc.*` type) the CLI skips the required check,
1505
+ // so an error here refused files the platform accepts: Studio Web's own triggers
1506
+ // (no `connectionId` input, they write a `connection` context row) and its
1507
+ // `Intsvc.*Execution` nodes (#1679). See `platformEnforcesRequired`. A V2 connector
1508
+ // node is judged by its own contract (`connectorV2Missing`), which stays an error.
1509
+ const enforced = platformEnforcesRequired(n.type, contextNames, n.spec);
1510
+ const notEnforcedNote = ' `uip maestro bpmn validate` does not require it for this type, so check only warns.';
1502
1511
  for (const field of requiredContext) {
1512
+ const gate = managedHttp || connectorV2 || enforced.context;
1503
1513
  diags.push({
1504
- level: 'error',
1514
+ level: gate ? 'error' : 'warning',
1505
1515
  code: 'EMPTY_REQUIRED_FIELD',
1506
- message: `"${n.id}" (${n.type}) is missing required field "${field}".`,
1516
+ message: `"${n.id}" (${n.type}) is missing required field "${field}".${gate ? '' : notEnforcedNote}`,
1507
1517
  where: n.id,
1508
1518
  });
1509
1519
  }
@@ -1527,9 +1537,9 @@ inEventSubProcess = false) {
1527
1537
  inputView[row.name] = row.value ?? row.body ?? '';
1528
1538
  for (const field of connectorV2 ? [] : missingRequiredInputs(n.type, inputView, contextNames, n.spec)) {
1529
1539
  diags.push({
1530
- level: 'error',
1540
+ level: enforced.inputs ? 'error' : 'warning',
1531
1541
  code: 'EMPTY_REQUIRED_FIELD',
1532
- message: `"${n.id}" (${n.type}) is missing required input "${field}".`,
1542
+ message: `"${n.id}" (${n.type}) is missing required input "${field}".${enforced.inputs ? '' : notEnforcedNote}`,
1533
1543
  where: n.id,
1534
1544
  });
1535
1545
  }
@@ -903,7 +903,10 @@ function emitQuickHumanTask(chain, el, payload) {
903
903
  * owes you.
904
904
  */
905
905
  function emitTypedNode(chain, el, payload, type) {
906
- const spec = registryType(type);
906
+ const listed = listedSpec(type);
907
+ if (!listed)
908
+ return emitUnlistedTypedNode(chain, el, payload, type);
909
+ const spec = listed;
907
910
  const id = el.id;
908
911
  if (type === 'Actions.HITL' && emitQuickHumanTask(chain, el, payload))
909
912
  return;
@@ -972,6 +975,92 @@ function emitTypedNode(chain, el, payload, type) {
972
975
  ['loop', emitLoop(el)],
973
976
  ]))})`);
974
977
  }
978
+ /** The registry's spec for a type, or `undefined` when neither the snapshot nor `uip` lists it. */
979
+ function listedSpec(type) {
980
+ try {
981
+ return registryType(type);
982
+ }
983
+ catch {
984
+ return undefined;
985
+ }
986
+ }
987
+ /**
988
+ * The emission spec for a type the registry does not list, read off the element
989
+ * that carries it.
990
+ *
991
+ * Decompile needs a spec only to know how the builder will WRITE the node back: which
992
+ * element, which `uipath:*` tag, and which rows it derives on its own. With every row
993
+ * spelled out verbatim (`contextRows`, `inputRows`, `outputRows`) the builder derives
994
+ * nothing, so the artifact already holds the whole answer: the element is the
995
+ * element, the tag is the payload's own tag, and the context, inputs and output the
996
+ * spec would otherwise default are all empty. Nothing about the type is guessed.
997
+ *
998
+ * Deployed processes and the BPMN engine's own test data carry types the registry has
999
+ * never listed (`Maestro.TaskCancellationHandler`, `Orchestrator.StartInlineAgentJob`,
1000
+ * the `ConversationalService.*` family); refusing them made the whole process
1001
+ * un-importable for a node the author may never touch.
1002
+ */
1003
+ function artifactSpec(el, payload) {
1004
+ const tag = String(payload.$type);
1005
+ const [ns, local] = tag.split(':');
1006
+ return {
1007
+ element: el.$type,
1008
+ // `uipath:Activity` is the moddle type; the spec spells the XML tag, `uipath:activity`.
1009
+ tag: `${ns}:${local.charAt(0).toLowerCase()}${local.slice(1)}`,
1010
+ inputPattern: 'separateInputs',
1011
+ inputName: null,
1012
+ inputTarget: null,
1013
+ context: [],
1014
+ inputs: [],
1015
+ output: null,
1016
+ eventDefinition: null,
1017
+ requiresDiscovery: false,
1018
+ bindingPattern: 'none',
1019
+ };
1020
+ }
1021
+ /** A spec as source, for the `spec` option. */
1022
+ function emitSpec(spec) {
1023
+ return opts([
1024
+ ['element', spec.element === null ? 'null' : tsText(spec.element)],
1025
+ ['tag', spec.tag === null ? 'null' : tsText(spec.tag)],
1026
+ ['inputPattern', tsText(spec.inputPattern)],
1027
+ ['inputName', 'null'],
1028
+ ['inputTarget', 'null'],
1029
+ ['context', '[]'],
1030
+ ['inputs', '[]'],
1031
+ ['output', 'null'],
1032
+ ['eventDefinition', 'null'],
1033
+ ['requiresDiscovery', 'false'],
1034
+ ['bindingPattern', tsText(spec.bindingPattern)],
1035
+ ]);
1036
+ }
1037
+ /**
1038
+ * A node whose extension type the registry does not list — carried verbatim.
1039
+ *
1040
+ * Written as `.activity()` with the spec read off the artifact ({@link artifactSpec})
1041
+ * and every row spelled out, so the recompile reproduces the element exactly and the
1042
+ * rest of the process stays editable. Event elements never reach here: an unlisted type
1043
+ * cannot describe one (`typeDescribesElement`), so the event emitter keeps the element.
1044
+ */
1045
+ function emitUnlistedTypedNode(chain, el, payload, type) {
1046
+ const id = el.id;
1047
+ const inputRows = payload.input ?? [];
1048
+ chain.add(`.activity(${tsText(id)}, ${tsText(type)}, ${opts([
1049
+ ['name', el.name !== undefined ? tsText(el.name) : undefined],
1050
+ ['spec', emitSpec(artifactSpec(el, payload))],
1051
+ ['typeVersion', payload.type?.version && payload.type.version !== 'v1' ? tsText(payload.type.version) : undefined],
1052
+ ['contextRows', emitContextRows(payload)],
1053
+ ['inputSchema', payload.context?.inputSchema?.body !== undefined ? jsonLiteral(payload.context.inputSchema.body) : undefined],
1054
+ ['inputRows', emitInputRows(inputRows)],
1055
+ ['outputRows', emitOutputRows(payload) ?? '[]'],
1056
+ ['skipCondition', payload.skipCondition !== undefined ? tsText(payload.skipCondition) : undefined],
1057
+ ['entryPointId', entryPointOption(el)],
1058
+ ['tags', tagsOf(el)],
1059
+ ['retry', emitRetry(retryOf(el))],
1060
+ ['errorMapping', emitErrorMapping(errorMappingOf(el))],
1061
+ ['loop', emitLoop(el)],
1062
+ ])})`);
1063
+ }
975
1064
  /**
976
1065
  * Whether `inputs` — a name→value record — would reproduce these `separateInputs`
977
1066
  * rows, or whether they need spelling out as `inputRows`.
@@ -2595,7 +2684,12 @@ lifted = new Set()) {
2595
2684
  // declaration on the way back in (`implicitNodeVars`' script arm), so they are
2596
2685
  // skipped here too, or the source redeclares every one of them in `.vars()`.
2597
2686
  const spelledOutScriptRows = localName(el.$type) === 'scriptTask' && type === 'BPMN.Variables' && outputRowsNeedSpellingOut(payload);
2598
- if (payload && type && (spelledOutScriptRows || (type !== 'BPMN.Variables' && typeDescribesElement(localName(el.$type), type)))) {
2687
+ // A type the registry does not list is emitted on its own element with every row
2688
+ // spelled out (`emitUnlistedTypedNode`), and those rows declare their variables on
2689
+ // the way back in like any typed node's — so they are candidates too, wherever the
2690
+ // typed path is the one that writes the element.
2691
+ const unlistedTyped = !!payload && !!type && type !== 'BPMN.Variables' && !ELEMENT_OWNS.has(localName(el.$type)) && !listedSpec(type);
2692
+ if (payload && type && (spelledOutScriptRows || unlistedTyped || (type !== 'BPMN.Variables' && typeDescribesElement(localName(el.$type), type)))) {
2599
2693
  for (const row of payload.output ?? []) {
2600
2694
  if (!row.var)
2601
2695
  continue;
@@ -472,6 +472,34 @@ export declare function createExtensionPayload(m: BpmnModdle, type: string, rows
472
472
  * @returns Its fields that must be bound, with the target each binding needs.
473
473
  */
474
474
  export declare function bindingRequiredFields(type: string, inline?: RegistryTypeSpec): RegistryContextField[];
475
+ /**
476
+ * Whether `uip maestro bpmn validate` holds a node to the registry's required fields.
477
+ *
478
+ * The CLI's contract half (`validateContext` / `validateInputs`) skips the required
479
+ * check for a type whose payload the canvas owns: one the registry marks `isDynamic`,
480
+ * or an `Intsvc.*` type that `requiresDiscovery` (its fields are discovered from the
481
+ * connector at design time). The one exception is a V1 `Intsvc.ActivityExecution`
482
+ * (`activityConfigurationVersion` absent or `v1`), whose context IS held to the
483
+ * contract. `check` reads the same two flags from the snapshot, so it errors exactly
484
+ * where the CLI refuses, and warns where only the registry says "required".
485
+ *
486
+ * Known limit: the CLI also reads a process-level `uipath:intsvcActivityConfig`
487
+ * version for an unversioned node. The built model does not carry that marker, so an
488
+ * unversioned node here counts as V1, which is the stricter reading (#1691).
489
+ *
490
+ * @param type - The extension type.
491
+ * @param context - The node's context values (for `activityConfigurationVersion`).
492
+ * @returns `context` and `inputs`: whether each half's required fields are enforced.
493
+ */
494
+ export declare function platformEnforcesRequired(type: string, context?: Record<string, unknown>, inline?: RegistryTypeSpec): {
495
+ context: boolean;
496
+ inputs: boolean;
497
+ };
498
+ /**
499
+ * True for an `Intsvc.ActivityExecution` whose own version is V1 — absent or `v1`, as
500
+ * the CLI's `isIntsvcActivityExecutionV1` reads it.
501
+ */
502
+ export declare function isActivityExecutionV1(type: string, context?: Record<string, unknown>): boolean;
475
503
  /**
476
504
  * Required context fields the author left unset and the registry cannot default.
477
505
  *
@@ -123,21 +123,18 @@ export const REGISTRY_GAPS = {
123
123
  // that they are undeclared and wrong that they are invalid — recorded here rather
124
124
  // than by loosening the guard, which is what catches an author's typo.
125
125
  // `requiredContext` — context fields the PLATFORM requires and the registry
126
- // snapshot does not mark required (or, here, does not declare at all).
126
+ // snapshot does not mark required (or does not declare at all). Empty today.
127
127
  //
128
- // `Intsvc.ActivityExecution` must carry `activity`; without it `uip maestro bpmn
129
- // validate` reports
130
- //
131
- // [canvas] [ERROR] EMPTY_REQUIRED_FIELD: The field 'activity' in node 'op' is
132
- // required but has no value.
133
- //
134
- // and `check` could not know, because it derives required fields from the snapshot.
135
- // The connector emitter has always written `activity`, so this only bites a
136
- // hand-rolled `.activity()` — but it bit it at the LAST rung. The divergence is
137
- // measured rather than assumed: `bpmn-registry-required-drift.test.ts` diffs the
138
- // required-field set the canvas validator carries against the snapshot's, over every
139
- // type both know, and asserts the only difference is what this table records.
140
- 'Intsvc.ActivityExecution': { extraContext: ['activity', 'resourceKey'], requiredContext: ['activity'] },
128
+ // `Intsvc.ActivityExecution`'s `activity` used to be recorded here, on a 2026-09-28
129
+ // measurement (`EMPTY_REQUIRED_FIELD: The field 'activity' … is required`). It no
130
+ // longer holds: on uip 1.205.0, and on the `@uipath/maestro-validation` the tests
131
+ // pin, a node with `activity` blank or absent validates. The canvas rule now reads
132
+ // `required` off the XML row, not the design schema, and the CLI's contract half
133
+ // does not list `activity` at all. 380 Studio Web-written nodes in the production
134
+ // corpus carry no `activity` and validate; `check` refused every one (#1679). The
135
+ // SDK still WRITES it (`.activity()` fills it from `operation`); it just does not
136
+ // demand it of a file that lacks it.
137
+ 'Intsvc.ActivityExecution': { extraContext: ['activity', 'resourceKey'] },
141
138
  // `outputRowsFixed` — the type permits EXACTLY the output row its spec declares.
142
139
  // A mapped second row is refused:
143
140
  //
@@ -715,6 +712,40 @@ function moddleElementOf(element) {
715
712
  export function bindingRequiredFields(type, inline) {
716
713
  return registryType(type, inline).context.filter((f) => f.bindingInfo !== null && f.required);
717
714
  }
715
+ /**
716
+ * Whether `uip maestro bpmn validate` holds a node to the registry's required fields.
717
+ *
718
+ * The CLI's contract half (`validateContext` / `validateInputs`) skips the required
719
+ * check for a type whose payload the canvas owns: one the registry marks `isDynamic`,
720
+ * or an `Intsvc.*` type that `requiresDiscovery` (its fields are discovered from the
721
+ * connector at design time). The one exception is a V1 `Intsvc.ActivityExecution`
722
+ * (`activityConfigurationVersion` absent or `v1`), whose context IS held to the
723
+ * contract. `check` reads the same two flags from the snapshot, so it errors exactly
724
+ * where the CLI refuses, and warns where only the registry says "required".
725
+ *
726
+ * Known limit: the CLI also reads a process-level `uipath:intsvcActivityConfig`
727
+ * version for an unversioned node. The built model does not carry that marker, so an
728
+ * unversioned node here counts as V1, which is the stricter reading (#1691).
729
+ *
730
+ * @param type - The extension type.
731
+ * @param context - The node's context values (for `activityConfigurationVersion`).
732
+ * @returns `context` and `inputs`: whether each half's required fields are enforced.
733
+ */
734
+ export function platformEnforcesRequired(type, context = {}, inline) {
735
+ const spec = registryType(type, inline);
736
+ const canvasOwned = spec.isDynamic === true || (type.startsWith('Intsvc.') && spec.requiresDiscovery);
737
+ return { context: !canvasOwned || isActivityExecutionV1(type, context), inputs: !canvasOwned };
738
+ }
739
+ /**
740
+ * True for an `Intsvc.ActivityExecution` whose own version is V1 — absent or `v1`, as
741
+ * the CLI's `isIntsvcActivityExecutionV1` reads it.
742
+ */
743
+ export function isActivityExecutionV1(type, context = {}) {
744
+ if (type !== 'Intsvc.ActivityExecution')
745
+ return false;
746
+ const version = context.activityConfigurationVersion;
747
+ return version === undefined || version === null || version === '' || version === 'v1';
748
+ }
718
749
  /**
719
750
  * Required context fields the author left unset and the registry cannot default.
720
751
  *
package/dist/check.js CHANGED
@@ -1712,26 +1712,27 @@ function checkNodeUpdates(built, diags) {
1712
1712
  // A variable declared by `{ shared }` (#924) is a `.var()` like any other.
1713
1713
  ...planSharedInputs({ roots: sharedInputRoots(built), outputs: built.outputs, vars: built.vars }).autoVars.map((v) => v.name),
1714
1714
  ]);
1715
+ const judge = (updates, stepName) => {
1716
+ for (const name of Object.keys(updates ?? {})) {
1717
+ if (writable.has(name))
1718
+ continue;
1719
+ if (inputs.has(name)) {
1720
+ diags.push({
1721
+ level: 'error', code: 'UPDATE_INPUT_READONLY', step: stepName,
1722
+ message: `{ updates } assigns "${name}", but it is a flow INPUT — the caller owns its value. Declare a .var() instead.`,
1723
+ });
1724
+ }
1725
+ else {
1726
+ diags.push({
1727
+ level: 'error', code: 'UPDATE_UNKNOWN_VAR', step: stepName,
1728
+ message: `{ updates } assigns "${name}", which is not a declared .var() or output.`,
1729
+ });
1730
+ }
1731
+ }
1732
+ };
1715
1733
  const visit = (steps) => {
1716
1734
  for (const s of steps) {
1717
- const updates = s.options?.updates;
1718
- const stepName = 'name' in s ? s.name : undefined;
1719
- for (const name of Object.keys(updates ?? {})) {
1720
- if (writable.has(name))
1721
- continue;
1722
- if (inputs.has(name)) {
1723
- diags.push({
1724
- level: 'error', code: 'UPDATE_INPUT_READONLY', step: stepName,
1725
- message: `{ updates } assigns "${name}", but it is a flow INPUT — the caller owns its value. Declare a .var() instead.`,
1726
- });
1727
- }
1728
- else {
1729
- diags.push({
1730
- level: 'error', code: 'UPDATE_UNKNOWN_VAR', step: stepName,
1731
- message: `{ updates } assigns "${name}", which is not a declared .var() or output.`,
1732
- });
1733
- }
1734
- }
1735
+ judge(s.options?.updates, 'name' in s ? s.name : undefined);
1735
1736
  if (s.kind === 'branch') {
1736
1737
  visit(s.then);
1737
1738
  visit(s.otherwise);
@@ -1749,6 +1750,10 @@ function checkNodeUpdates(built, diags) {
1749
1750
  visit(s.body);
1750
1751
  }
1751
1752
  };
1753
+ // A root's own `{ updates }` (#1673).
1754
+ judge(built.triggerOptions?.updates, built.triggerId ?? 'start');
1755
+ for (const ep of built.entryPoints ?? [])
1756
+ judge(ep.options?.updates, ep.id);
1752
1757
  visit(built.steps);
1753
1758
  }
1754
1759
  /**
package/dist/decompile.js CHANGED
@@ -273,10 +273,11 @@ function hasRenamedLabel(node, defaultLabel) {
273
273
  const label = node.display?.label;
274
274
  return typeof label === 'string' && label !== defaultLabel;
275
275
  }
276
- /** `triggerOptParts` as the `.trigger(spec, { ... })` options argument. */
277
- function triggerOptsArg(node) {
278
- const parts = triggerOptParts(node);
279
- return parts.length ? `, { ${parts.join(', ')} }` : '';
276
+ /** `updates: { <var>: <value>, … }` for a node's `variableUpdates` rows, in file order; `undefined` for none. */
277
+ function updatesPart(rows, imp, inputNames) {
278
+ if (rows.length === 0)
279
+ return undefined;
280
+ return `updates: { ${rows.map((u) => `${key(u.variableId)}: ${emitVal(u.expression, imp, inputNames)}`).join(', ')} }`;
280
281
  }
281
282
  /**
282
283
  * The full node-options argument for steps that can carry both an exact
@@ -299,11 +300,9 @@ function optsArgWith(node, ctx, extra) {
299
300
  const label = node.display?.label;
300
301
  if (typeof label === 'string' && label !== node.id)
301
302
  parts.push(`label: ${tsLiteral(label)}`);
302
- const updates = ctx.flow.variables?.variableUpdates?.[node.id] ?? [];
303
- if (updates.length) {
304
- const entries = updates.map((u) => `${key(u.variableId)}: ${emitVal(u.expression, ctx.imp, ctx.inputNames)}`);
305
- parts.push(`updates: { ${entries.join(', ')} }`);
306
- }
303
+ const updates = updatesPart(ctx.flow.variables?.variableUpdates?.[node.id] ?? [], ctx.imp, ctx.inputNames);
304
+ if (updates)
305
+ parts.push(updates);
307
306
  // A draft the canvas saved: `compile` writes it back only when the step says
308
307
  // so AND the source carries its definition (carriedPairs), so a draft an agent
309
308
  // adds of the same operation is still refused (StepOptions.draft).
@@ -1338,12 +1337,17 @@ function declExpr(g, withDefault, imp, shared) {
1338
1337
  function sharedCopies(flow, triggers) {
1339
1338
  const globals = readFlowGlobals(flow.variables, runStrict);
1340
1339
  const byInput = new Map();
1341
- const unrecognized = [];
1340
+ const updates = new Map();
1342
1341
  const fed = new Map();
1343
1342
  for (const t of triggers) {
1344
1343
  const rows = flow.variables?.variableUpdates?.[t.id] ?? [];
1345
1344
  const seenOnRoot = new Set();
1345
+ const rest = [];
1346
1346
  for (const row of rows) {
1347
+ if (rest.length > 0) {
1348
+ rest.push(row);
1349
+ continue;
1350
+ }
1347
1351
  const src = unwrapSource(row.expression);
1348
1352
  const m = src?.startsWith('=js:') ? /^\$vars\.([A-Za-z0-9_]+)\.output\.([A-Za-z0-9_]+)$/.exec(src.slice(4).trim()) : null;
1349
1353
  const inp = m && m[1] === t.id
@@ -1353,13 +1357,15 @@ function sharedCopies(flow, triggers) {
1353
1357
  const ok = inp !== undefined && target !== undefined && target.type === inp.type
1354
1358
  && !byInput.has(`${t.id}\0${inp.id}`) && !seenOnRoot.has(row.variableId);
1355
1359
  if (!ok) {
1356
- unrecognized.push({ trigger: t.id, variableId: row.variableId });
1360
+ rest.push(row);
1357
1361
  continue;
1358
1362
  }
1359
1363
  seenOnRoot.add(row.variableId);
1360
1364
  byInput.set(`${t.id}\0${inp.id}`, row.variableId);
1361
1365
  fed.set(row.variableId, (fed.get(row.variableId) ?? 0) + 1);
1362
1366
  }
1367
+ if (rest.length > 0)
1368
+ updates.set(t.id, rest);
1363
1369
  }
1364
1370
  const auto = new Set();
1365
1371
  for (const name of fed.keys()) {
@@ -1368,7 +1374,7 @@ function sharedCopies(flow, triggers) {
1368
1374
  && g.subType === undefined && g.schema === undefined)
1369
1375
  auto.add(name);
1370
1376
  }
1371
- return { byInput, auto, unrecognized };
1377
+ return { byInput, auto, updates };
1372
1378
  }
1373
1379
  function emitVariables(e, depth, flow, imp, epTriggers = new Set(), shared) {
1374
1380
  const globals = readFlowGlobals(flow.variables, runStrict);
@@ -1411,7 +1417,7 @@ function triggerFactory(t, imp, inputNames) {
1411
1417
  return `${imp.use('onEvent')}(${sub})`;
1412
1418
  return undefined;
1413
1419
  }
1414
- function emitTrigger(e, depth, trigger, imp, o, inputNames = new Set()) {
1420
+ function emitTrigger(e, depth, trigger, imp, o, inputNames = new Set(), extra = []) {
1415
1421
  // The trigger's id is addressable — a flow's inputs are published as its
1416
1422
  // output — so a renamed one has to survive the round trip. `start` is the
1417
1423
  // default and stays implicit.
@@ -1419,7 +1425,8 @@ function emitTrigger(e, depth, trigger, imp, o, inputNames = new Set()) {
1419
1425
  e.line(depth, `.triggerId(${tsLiteral(trigger.id)})`);
1420
1426
  const factory = triggerFactory(trigger, imp, inputNames);
1421
1427
  if (factory !== undefined) {
1422
- e.line(depth, `.trigger(${factory}${triggerOptsArg(trigger)})`);
1428
+ const parts = [...triggerOptParts(trigger), ...extra];
1429
+ e.line(depth, `.trigger(${factory}${parts.length ? `, { ${parts.join(', ')} }` : ''})`);
1423
1430
  return;
1424
1431
  }
1425
1432
  if (o.bestEffort === false) {
@@ -2974,8 +2981,12 @@ function emitChildFlowIn(name, child, trigger, ctx) {
2974
2981
  // The one trigger a subflow may carry names its Start node (#1050).
2975
2982
  const childStart = trigger && FLOW_TRIGGER_TYPES.byTypeName(trigger.type)?.type.subflowStart
2976
2983
  ? triggerFactory(trigger, ctx.imp, ctx.inputNames) : undefined;
2977
- if (childStart !== undefined && hasRenamedLabel(trigger, SUBFLOW_START_LABEL)) {
2978
- parts.push(`.trigger(${childStart}, { ${triggerOptParts(trigger, SUBFLOW_START_LABEL).join(', ')} })`);
2984
+ // Its rows are the child trigger's own `{ updates }` (#1673).
2985
+ const startUpdates = trigger === undefined ? undefined
2986
+ : updatesPart(child.variables?.variableUpdates?.[trigger.id] ?? [], ctx.imp, childCtx.inputNames);
2987
+ if (childStart !== undefined && (hasRenamedLabel(trigger, SUBFLOW_START_LABEL) || startUpdates !== undefined)) {
2988
+ const startOpts = [...triggerOptParts(trigger, SUBFLOW_START_LABEL), ...(startUpdates === undefined ? [] : [startUpdates])];
2989
+ parts.push(`.trigger(${childStart}, { ${startOpts.join(', ')} })`);
2979
2990
  }
2980
2991
  const scope = scopeIds(child.nodes ?? [], undefined);
2981
2992
  const entries = trigger ? scopeSuccEdges(childCtx.graph, trigger.id, scope) : [];
@@ -3184,8 +3195,15 @@ export function decompile(flow, options = {}) {
3184
3195
  const trigger = triggerNodes.find((n) => (n.inputs ?? {}).isDefaultEntryPoint === true)
3185
3196
  ?? graph.byId.get('start')
3186
3197
  ?? triggerNodes[0];
3198
+ // `{ shared }` input copies on the roots (#924); every other trigger-level
3199
+ // row is the trigger's own `{ updates }` (#1673).
3200
+ const shared = sharedCopies(flow, triggerNodes);
3201
+ const rootUpdates = (t) => {
3202
+ const part = updatesPart(shared.updates.get(t.id) ?? [], imp, inputNames);
3203
+ return part === undefined ? [] : [part];
3204
+ };
3187
3205
  if (trigger)
3188
- emitTrigger(e, d, trigger, imp, options, inputNames);
3206
+ emitTrigger(e, d, trigger, imp, options, inputNames, rootUpdates(trigger));
3189
3207
  // Nodes no trigger reaches. The region walk below starts at the trigger's
3190
3208
  // successor and follows edges, so a node with no path from any root was
3191
3209
  // silently absent from the source — it survived only as a `.layout()` key,
@@ -3206,19 +3224,6 @@ export function decompile(flow, options = {}) {
3206
3224
  e.line(d, `// TODO: node ${commentText(tsLiteral(n.id))} (${commentText(n.type)}) is not reachable from any trigger and is NOT in this source; recompiling drops it. Connect it in the .flow or edit its JSON directly.`);
3207
3225
  }
3208
3226
  }
3209
- // `{ shared }` input copies on the roots (#924). Any other trigger-level
3210
- // update has no builder spelling: say so instead of dropping it.
3211
- const shared = sharedCopies(flow, triggerNodes);
3212
- if (shared.unrecognized.length) {
3213
- const listing = shared.unrecognized.map((u) => `${tsLiteral(u.variableId)} on ${tsLiteral(u.trigger)}`).join(', ');
3214
- const message = `${shared.unrecognized.length} variable update(s) on a trigger node are not a { shared } input copy: ${listing}. `
3215
- + 'The builder writes a trigger-level update only for { type, shared: \'<var>\' } (the row `<var> ← $vars.<trigger>.output.<input>`), '
3216
- + 'so this source omits them and recompiling drops them.';
3217
- if (runStrict)
3218
- throw new Error(`decompile: ${message}`);
3219
- warnOnce(message);
3220
- e.line(d, `// TODO: ${commentText(message)}`);
3221
- }
3222
3227
  emitVariables(e, d, flow, imp, new Set(triggerNodes.filter((t) => t !== trigger).map((t) => t.id)), shared);
3223
3228
  // Reconstruct the body: structured control flow recovered from the graph.
3224
3229
  const ctx = {
@@ -3337,6 +3342,9 @@ function entryPointSeg(t, scope, ipdom, ctx) {
3337
3342
  optParts.push(`inputs: { ${scoped.map((g) => `${key(g.name ?? g.id)}: ${declExpr(g, true, ctx.imp, sharedOf(g))}`).join(', ')} }`);
3338
3343
  }
3339
3344
  optParts.push(...triggerOptParts(t));
3345
+ const updates = updatesPart(ctx.shared?.updates.get(t.id) ?? [], ctx.imp, ctx.inputNames);
3346
+ if (updates)
3347
+ optParts.push(updates);
3340
3348
  const firsts = scopeSuccEdges(ctx.graph, t.id, scope);
3341
3349
  // A prefix that forks needs post-dominators over ITS nodes, which the root's
3342
3350
  // map (computed from the default trigger) does not cover.
@@ -257,9 +257,18 @@ export interface NodeOptions {
257
257
  * Variable.
258
258
  *
259
259
  * @remarks
260
- * Not accepted on `.branch()`, `.switch()`, `.parallel()`, or `.trigger()` —
261
- * the platform strips updates from decision/switch/merge nodes on save, and a
262
- * trigger has not run anything to assign from.
260
+ * Not accepted on `.branch()`, `.switch()` or `.parallel()` — the platform
261
+ * strips updates from decision/switch/merge nodes on save.
262
+ *
263
+ * On `.trigger()` and `.entryPoint()` the rows run when the root fires,
264
+ * after the root's `{ shared }` input copies, and may read what the trigger
265
+ * published. For instance
266
+ *
267
+ * ```ts
268
+ * .trigger(manual(), { updates: { doc: js`${input('payload')}.document ?? ${v('doc')}` } })
269
+ * ```
270
+ *
271
+ * writes the row `doc ← $vars.start.output.payload.document ?? $vars.doc`.
263
272
  */
264
273
  updates?: Record<string, Expr | unknown>;
265
274
  /**
@@ -686,7 +695,7 @@ export interface BuiltEntryPoint {
686
695
  id: string;
687
696
  /** What fires this root: any built-in trigger factory, or a custom trigger. */
688
697
  trigger: TriggerSpec;
689
- /** Node options for the trigger node — exact `version` selection and canvas `label`. */
698
+ /** Node options for the trigger node — exact `version` selection, canvas `label`, and `updates`. */
690
699
  options?: NodeOptions;
691
700
  /** Inputs scoped to this root (globals bound to it via `triggerNodeId`). */
692
701
  inputs: VarDecl[];
@@ -1398,12 +1407,13 @@ declare class FlowBuilder extends StepList {
1398
1407
  * `conversationTrigger()`, or `voiceTrigger()`.
1399
1408
  * @param options - `version` (exact trigger definition version), `label`
1400
1409
  * (what the canvas shows on the trigger node; default: the trigger
1401
- * definition's label, e.g. `Manual trigger`), and `inputs` — this root's scoped inputs, declared like
1410
+ * definition's label, e.g. `Manual trigger`), `updates` (variable rows run when this root fires; see
1411
+ * {@link NodeOptions.updates}), and `inputs` — this root's scoped inputs, declared like
1402
1412
  * `.input()`.
1403
1413
  * @param prefixFn - Optional sub-builder for the root's prefix steps.
1404
1414
  * @returns This builder, so calls chain.
1405
1415
  */
1406
- entryPoint(id: string, trigger: TriggerSpec | FlowTrigger, options?: Pick<NodeOptions, 'version' | 'label'> & {
1416
+ entryPoint(id: string, trigger: TriggerSpec | FlowTrigger, options?: Pick<NodeOptions, 'version' | 'label' | 'updates'> & {
1407
1417
  inputs?: Record<string, FlowTypeDesc | VarSpec>;
1408
1418
  }, prefixFn?: (b: StepList) => void): this;
1409
1419
  /**
package/dist/flow-sdk.js CHANGED
@@ -977,9 +977,6 @@ class FlowBuilder extends StepList {
977
977
  * @defaultValue the manual trigger
978
978
  */
979
979
  trigger(spec, options) {
980
- if (options?.updates) {
981
- throw new CompileRefusal('UPDATES_NOT_SUPPORTED', '.trigger(): { updates } is not supported — a trigger has not run anything to assign from.');
982
- }
983
980
  this._trigger = spec;
984
981
  if (options)
985
982
  this._triggerOptions = options;
@@ -1028,7 +1025,8 @@ class FlowBuilder extends StepList {
1028
1025
  * `conversationTrigger()`, or `voiceTrigger()`.
1029
1026
  * @param options - `version` (exact trigger definition version), `label`
1030
1027
  * (what the canvas shows on the trigger node; default: the trigger
1031
- * definition's label, e.g. `Manual trigger`), and `inputs` — this root's scoped inputs, declared like
1028
+ * definition's label, e.g. `Manual trigger`), `updates` (variable rows run when this root fires; see
1029
+ * {@link NodeOptions.updates}), and `inputs` — this root's scoped inputs, declared like
1032
1030
  * `.input()`.
1033
1031
  * @param prefixFn - Optional sub-builder for the root's prefix steps.
1034
1032
  * @returns This builder, so calls chain.
@@ -1043,11 +1041,12 @@ class FlowBuilder extends StepList {
1043
1041
  this._entryPoints.push({
1044
1042
  id,
1045
1043
  trigger: trigger,
1046
- ...(options?.version !== undefined || options?.label !== undefined
1044
+ ...(options?.version !== undefined || options?.label !== undefined || options?.updates !== undefined
1047
1045
  ? {
1048
1046
  options: {
1049
1047
  ...(options.version !== undefined ? { version: options.version } : {}),
1050
1048
  ...(options.label !== undefined ? { label: options.label } : {}),
1049
+ ...(options.updates !== undefined ? { updates: options.updates } : {}),
1051
1050
  },
1052
1051
  }
1053
1052
  : {}),
package/dist/serialize.js CHANGED
@@ -1954,6 +1954,11 @@ function serializeFlow(built, opts) {
1954
1954
  });
1955
1955
  start.inputs = {};
1956
1956
  scope.nodes.push(start);
1957
+ // The child's `.trigger(manual(), { updates })`: rows run when the caller starts it (#1673).
1958
+ const startUpdates = child.triggerOptions?.updates;
1959
+ if (startUpdates && Object.keys(startUpdates).length > 0) {
1960
+ scope.variableUpdates[startId] = [...(scope.variableUpdates[startId] ?? []), ...renderUpdates(startUpdates, scope.rename)];
1961
+ }
1957
1962
  const tails = emit(child.steps, [{ node: startId, port: 'output' }], scope);
1958
1963
  // Same as the root's implicit End — mapped against the SUBFLOW's own
1959
1964
  // outputs, which is the scope the product validates a subflow body in.
@@ -3518,10 +3523,13 @@ function serializeFlow(built, opts) {
3518
3523
  // event's output rows in order, so the row sees the trigger's input mapping
3519
3524
  // (measured live, #924). The default root's row is written against `start`
3520
3525
  // and renamed with every other `input()` read, so `.triggerId()` follows.
3526
+ // The root's own `{ updates }` (`.trigger(spec, { updates })`,
3527
+ // `.entryPoint(id, spec, { updates })`) follow the copies, in the order
3528
+ // written, so they can read a variable a copy just set (#1673).
3521
3529
  {
3522
3530
  const roots = [
3523
- { node: built.triggerId ?? 'start', read: 'start', inputs: built.inputs },
3524
- ...entryPoints.map((ep) => ({ node: ep.id, read: ep.id, inputs: ep.inputs })),
3531
+ { node: built.triggerId ?? 'start', read: 'start', inputs: built.inputs, updates: built.triggerOptions?.updates },
3532
+ ...entryPoints.map((ep) => ({ node: ep.id, read: ep.id, inputs: ep.inputs, updates: ep.options?.updates })),
3525
3533
  ];
3526
3534
  for (const r of roots) {
3527
3535
  const copies = {};
@@ -3529,9 +3537,10 @@ function serializeFlow(built, opts) {
3529
3537
  if (inp.shared !== undefined)
3530
3538
  copies[inp.shared] = new Expr(`$vars.${r.read}.output.${inp.name}`);
3531
3539
  }
3532
- if (Object.keys(copies).length === 0)
3540
+ const rows = [...renderUpdates(copies, root.rename), ...renderUpdates(r.updates ?? {}, root.rename)];
3541
+ if (rows.length === 0)
3533
3542
  continue;
3534
- root.variableUpdates[r.node] = [...(root.variableUpdates[r.node] ?? []), ...renderUpdates(copies, root.rename)];
3543
+ root.variableUpdates[r.node] = [...(root.variableUpdates[r.node] ?? []), ...rows];
3535
3544
  }
3536
3545
  }
3537
3546
  const globals = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.85.5",
3
+ "version": "6.85.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": "a60a4c0ce7835f89af7abf7fdd2e6c05c0925789"
106
+ "gitref": "32a61ae6d171e0e4f47383fe8bd4d2f5d747e550"
107
107
  }