@uipath/maestro-builder-sdk 6.122.8 → 6.122.9

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.
@@ -151,6 +151,11 @@ export type BpmnNode = {
151
151
  interrupting?: boolean;
152
152
  /** A start event's own `uipath:entryPointId`; `false` writes none. */
153
153
  entryPointId?: string | false;
154
+ /**
155
+ * Variable updates after the event: see {@link VariableUpdatesOpts}. Nested, not
156
+ * spread, so an event arm never reads as an activity (`ActivityNodeFields`).
157
+ */
158
+ variableUpdates?: VariableUpdatesOpts;
154
159
  } | {
155
160
  kind: 'boundaryEvent';
156
161
  id: string;
@@ -256,6 +261,8 @@ export type BpmnNode = {
256
261
  skipCondition?: string;
257
262
  /** The type's emission spec, supplied inline — see {@link ActivityNodeOpts.spec}. */
258
263
  spec?: RegistryTypeSpec;
264
+ /** The BPMN element to write instead of the registry's — see {@link ActivityNodeOpts.element}. */
265
+ element?: PlainTaskElement;
259
266
  /** Emit `context` exactly as given — for importers; see `TypedNodeInput`. */
260
267
  contextVerbatim?: boolean;
261
268
  }) | (ActivityNodeFields & {
@@ -386,13 +393,44 @@ export interface ErrorMappingRow {
386
393
  /** Human-facing detail. Carried, not interpreted. */
387
394
  detail?: string;
388
395
  }
396
+ /**
397
+ * Variable updates on a node: the product's trailing `uipath:mapping`
398
+ * (`BPMN.Variables`, every row `custom="true"`) that assigns process variables
399
+ * once the node has run.
400
+ *
401
+ * Studio Web writes it as a SECOND mapping after the node's own payload (after
402
+ * `uipath:scriptVersion` on a script task), for example:
403
+ *
404
+ * ```xml
405
+ * <uipath:mapping version="v1">
406
+ * <uipath:type value="BPMN.Variables" version="v1" />
407
+ * <uipath:output name="total" type="number" source="=js:vars.sum.output.total" var="total" custom="true" />
408
+ * </uipath:mapping>
409
+ * ```
410
+ *
411
+ * `.scriptTask('sum', { script, updates: { total: '=js:vars.sum.output.total' } })` writes
412
+ * that, typing each row from the variable's declaration.
413
+ */
414
+ export interface VariableUpdatesOpts {
415
+ /**
416
+ * variable id -> the `=`-expression assigned to it after the node runs. Each row is
417
+ * named after its variable, typed from the variable's declaration (`string` when
418
+ * undeclared) and marked `custom="true"`.
419
+ */
420
+ updates?: Record<string, string>;
421
+ /**
422
+ * The update rows spelled out, in document order: what an import writes, so each
423
+ * row's own `type` and attributes survive. Written after any `updates` rows.
424
+ */
425
+ updateRows?: TypedOutputRow[];
426
+ }
389
427
  /**
390
428
  * The fields every activity arm of {@link BpmnNode} carries — the built form of
391
429
  * {@link ActivityOpts}. One shape, so the serializer emits `uipath:retry`,
392
430
  * `uipath:errorMapping` and the loop characteristics from a single place regardless of
393
431
  * which activity it is walking.
394
432
  */
395
- export interface ActivityNodeFields {
433
+ export interface ActivityNodeFields extends VariableUpdatesOpts {
396
434
  /** `uipath:tags` on the node — see {@link ActivityOpts.tags}. */
397
435
  tags?: Record<string, string>;
398
436
  /** Retry policy (`uipath:retry`). */
@@ -761,7 +799,7 @@ export interface ExtensionPayload {
761
799
  * Options for `.startEvent()`. At most one of `message` / `timer` picks the
762
800
  * event definition (`timer` wins if both are set); neither means a plain start.
763
801
  */
764
- export interface StartOpts {
802
+ export interface StartOpts extends VariableUpdatesOpts {
765
803
  /** Display name the designer shows on the event. */
766
804
  name?: string;
767
805
  /** Start when this message arrives — declares/reuses a definitions-level `bpmn:message`; `NO_MESSAGE` for none — see {@link MessageLike}. */
@@ -868,7 +906,7 @@ export interface StartOpts {
868
906
  * Options for `.endEvent()`. `terminate`, `error`, or `message` picks the event
869
907
  * definition, checked in that order; none of them means a plain end.
870
908
  */
871
- export interface EndOpts {
909
+ export interface EndOpts extends VariableUpdatesOpts {
872
910
  /** Display name the designer shows on the event. */
873
911
  name?: string;
874
912
  /** End as a TERMINATE event — abort the whole process instance, not just this path. */
@@ -1012,7 +1050,7 @@ export interface RetrySpec {
1012
1050
  * would be silently dropped in serialization and the step would run anyway. It
1013
1051
  * therefore lives on {@link BpmnConnectorOpts} alone, where it works.
1014
1052
  */
1015
- export interface ActivityOpts {
1053
+ export interface ActivityOpts extends VariableUpdatesOpts {
1016
1054
  /**
1017
1055
  * `uipath:tags` on the activity — key/value pairs the designer carries alongside
1018
1056
  * the node, as a SIBLING of its payload.
@@ -1881,6 +1919,12 @@ export interface ActivityNodeOpts extends ActivityOpts {
1881
1919
  * the type needs, so a node authored from scratch still wants the registry's.
1882
1920
  */
1883
1921
  spec?: RegistryTypeSpec;
1922
+ /**
1923
+ * The task element to write instead of the registry's, spelled as the XML is
1924
+ * (`bpmn:serviceTask`). For importers: Studio Web writes `Orchestrator.StartFlowProcess`
1925
+ * as a `bpmn:serviceTask`, which the registry types as a `bpmn:callActivity`.
1926
+ */
1927
+ element?: PlainTaskElement;
1884
1928
  /** Variable the type's own output lands in. Defaults to `<id>_<outputName>`. */
1885
1929
  outputVar?: string;
1886
1930
  /** Extra output rows: variable id → `=`-expression against the node's result. */
@@ -3,6 +3,7 @@ import { BPMN_SCHEMA_VERSIONS } from './format-profile.js';
3
3
  import { schemaVersionRefusal } from '../schema-version.js';
4
4
  import { bindingRequiredFields, REGISTRY_GAPS, registryType } from './typed-node.js';
5
5
  import { resolveResourceKeyPattern } from './resource-key-pattern.js';
6
+ import { PLAIN_TASK_ELEMENTS } from './task-elements.js';
6
7
  import { quickHumanTaskRows } from './human-task-form.js';
7
8
  import { CompileRefusal } from '../core/compile-refusal.js';
8
9
  import { DATA_SERVICE_ACTIVITY_TYPE, dataServiceContext, dataServiceWire, isPendingEntity, pendsOnFolderKeyRow, refuseEntityShape, } from './data-service.js';
@@ -33,6 +34,10 @@ function normTimer(t) {
33
34
  * ```
34
35
  */
35
36
  export const NO_MESSAGE = Symbol.for('@uipath/maestro-builder-sdk/bpmn/noMessage');
37
+ /** An event's `updates` / `updateRows`, or undefined when it sets neither. */
38
+ function variableUpdatesOf(opts) {
39
+ return opts.updates === undefined && opts.updateRows === undefined ? undefined : { updates: opts.updates, updateRows: opts.updateRows };
40
+ }
36
41
  /**
37
42
  * The `uipath:type` version of an app-backed `.humanTask()`. PO.BpmnEngine
38
43
  * (`AppTasksCreateArgs`) reads the app from `name`/`folderPath` only on `v2`; on `v1` it
@@ -46,10 +51,6 @@ const HITL_APP_TYPE_VERSION = 'v2';
46
51
  * app's tenant key, which nothing offline has.
47
52
  */
48
53
  const HITL_APP_RESOURCE_KEY_PATTERN = '${metadata.folderPath}.${metadata.name}';
49
- /** Every {@link PlainTaskElement}, for the run-time check in `.plainTask()`. */
50
- const PLAIN_TASK_ELEMENTS = new Set([
51
- 'bpmn:callActivity', 'bpmn:task', 'bpmn:userTask', 'bpmn:serviceTask', 'bpmn:sendTask', 'bpmn:manualTask', 'bpmn:businessRuleTask', 'bpmn:receiveTask',
52
- ]);
53
54
  /** Bookkeeping the nesting sugar shares across every scope of one process. */
54
55
  class SugarRegistry {
55
56
  /** Flow ids the builder wrote by implication rather than from an explicit `.sequenceFlow()`. */
@@ -769,6 +770,7 @@ class ScopeBuilder {
769
770
  name: opts.name,
770
771
  payload: opts.payload,
771
772
  interrupting: opts.interrupting === false ? false : undefined,
773
+ variableUpdates: variableUpdatesOf(opts),
772
774
  // `error` is handled here rather than in `startCatchDef` because it needs the
773
775
  // definitions registry to intern the `bpmn:error`, exactly as `endEvent` does —
774
776
  // and because an intermediate catch event (the other `startCatchDef` caller)
@@ -795,7 +797,7 @@ class ScopeBuilder {
795
797
  event = toErrorDef(this._defs, opts.error, `endEvent "${id}"`);
796
798
  else if (opts.message !== undefined)
797
799
  event = toMessageDef(this._defs, opts.message, `endEvent "${id}"`);
798
- return this.push({ kind: 'endEvent', id, name: opts.name, event, payload: opts.payload });
800
+ return this.push({ kind: 'endEvent', id, name: opts.name, event, payload: opts.payload, variableUpdates: variableUpdatesOf(opts) });
799
801
  }
800
802
  /**
801
803
  * An intermediate catch event (authorable: message / timer).
@@ -945,6 +947,8 @@ class ScopeBuilder {
945
947
  tags: opts.tags,
946
948
  retry: opts.retry,
947
949
  errorMapping: opts.errorMapping,
950
+ updates: opts.updates,
951
+ updateRows: opts.updateRows,
948
952
  loop: opts.loop,
949
953
  }, body);
950
954
  }
@@ -966,6 +970,8 @@ class ScopeBuilder {
966
970
  retry: opts.retry,
967
971
  loop: opts.loop,
968
972
  errorMapping: opts.errorMapping,
973
+ updates: opts.updates,
974
+ updateRows: opts.updateRows,
969
975
  }, body);
970
976
  }
971
977
  /**
@@ -1015,6 +1021,8 @@ class ScopeBuilder {
1015
1021
  tags: opts.tags,
1016
1022
  retry: opts.retry,
1017
1023
  errorMapping: opts.errorMapping,
1024
+ updates: opts.updates,
1025
+ updateRows: opts.updateRows,
1018
1026
  loop: opts.loop,
1019
1027
  }, body);
1020
1028
  }
@@ -1049,6 +1057,8 @@ class ScopeBuilder {
1049
1057
  retry: bpmnOpts.retry,
1050
1058
  loop: bpmnOpts.loop,
1051
1059
  errorMapping: bpmnOpts.errorMapping,
1060
+ updates: bpmnOpts.updates,
1061
+ updateRows: bpmnOpts.updateRows,
1052
1062
  }, body);
1053
1063
  }
1054
1064
  /**
@@ -1125,6 +1135,8 @@ class ScopeBuilder {
1125
1135
  tags: opts.tags,
1126
1136
  retry: opts.retry,
1127
1137
  errorMapping: opts.errorMapping,
1138
+ updates: opts.updates,
1139
+ updateRows: opts.updateRows,
1128
1140
  loop: opts.loop,
1129
1141
  }, body);
1130
1142
  }
@@ -1292,6 +1304,8 @@ class ScopeBuilder {
1292
1304
  tags: opts.tags,
1293
1305
  retry: opts.retry,
1294
1306
  errorMapping: opts.errorMapping,
1307
+ updates: opts.updates,
1308
+ updateRows: opts.updateRows,
1295
1309
  loop: opts.loop,
1296
1310
  }, body);
1297
1311
  }
@@ -1452,6 +1466,8 @@ class ScopeBuilder {
1452
1466
  tags: opts.tags,
1453
1467
  retry: opts.retry,
1454
1468
  errorMapping: opts.errorMapping,
1469
+ updates: opts.updates,
1470
+ updateRows: opts.updateRows,
1455
1471
  loop: opts.loop,
1456
1472
  }, body);
1457
1473
  }
@@ -1654,6 +1670,8 @@ class ScopeBuilder {
1654
1670
  tags: opts.tags,
1655
1671
  retry: opts.retry,
1656
1672
  errorMapping: opts.errorMapping,
1673
+ updates: opts.updates,
1674
+ updateRows: opts.updateRows,
1657
1675
  loop: opts.loop,
1658
1676
  }, body);
1659
1677
  }
@@ -1788,6 +1806,8 @@ class ScopeBuilder {
1788
1806
  tags: o.tags,
1789
1807
  retry: o.retry,
1790
1808
  errorMapping: o.errorMapping,
1809
+ updates: o.updates,
1810
+ updateRows: o.updateRows,
1791
1811
  loop: o.loop,
1792
1812
  }, body);
1793
1813
  }
@@ -1820,6 +1840,8 @@ class ScopeBuilder {
1820
1840
  tags: o.tags,
1821
1841
  retry: o.retry,
1822
1842
  errorMapping: o.errorMapping,
1843
+ updates: o.updates,
1844
+ updateRows: o.updateRows,
1823
1845
  loop: o.loop,
1824
1846
  }, body);
1825
1847
  }
@@ -1877,6 +1899,8 @@ class ScopeBuilder {
1877
1899
  tags: opts.tags,
1878
1900
  retry: opts.retry,
1879
1901
  errorMapping: opts.errorMapping,
1902
+ updates: opts.updates,
1903
+ updateRows: opts.updateRows,
1880
1904
  loop: opts.loop,
1881
1905
  }, body);
1882
1906
  }
@@ -1943,6 +1967,8 @@ class ScopeBuilder {
1943
1967
  tags: opts.tags,
1944
1968
  retry: opts.retry,
1945
1969
  errorMapping: opts.errorMapping,
1970
+ updates: opts.updates,
1971
+ updateRows: opts.updateRows,
1946
1972
  loop: opts.loop,
1947
1973
  }, body);
1948
1974
  }
@@ -1991,6 +2017,8 @@ class ScopeBuilder {
1991
2017
  tags: opts.tags,
1992
2018
  retry: opts.retry,
1993
2019
  errorMapping: opts.errorMapping,
2020
+ updates: opts.updates,
2021
+ updateRows: opts.updateRows,
1994
2022
  loop: opts.loop,
1995
2023
  });
1996
2024
  }
@@ -2072,6 +2100,8 @@ class ScopeBuilder {
2072
2100
  tags: opts.tags,
2073
2101
  retry: opts.retry,
2074
2102
  errorMapping: opts.errorMapping,
2103
+ updates: opts.updates,
2104
+ updateRows: opts.updateRows,
2075
2105
  loop: opts.loop,
2076
2106
  }, body);
2077
2107
  }
@@ -2114,6 +2144,9 @@ class ScopeBuilder {
2114
2144
  * @returns This builder, so calls chain.
2115
2145
  */
2116
2146
  activity(id, type, opts = {}, body) {
2147
+ if (opts.element !== undefined && !PLAIN_TASK_ELEMENTS.has(opts.element)) {
2148
+ throw new CompileRefusal('BPMN_ACTIVITY_ELEMENT_INVALID', `.activity('${id}', '${type}'): element "${opts.element}" is not a task element. Use one of: ${[...PLAIN_TASK_ELEMENTS].join(', ')}.`);
2149
+ }
2117
2150
  if (type === 'BPMN.ScriptTask') {
2118
2151
  throw new CompileRefusal('BPMN_ACTIVITY_SCRIPT_TASK_TYPE', `.activity('${id}', 'BPMN.ScriptTask'): this writes a script task with no script, whose mapping type replaces the script's extension type, so nothing runs and its outputs read back null. ` +
2119
2152
  `Use .scriptTask('${id}', { script, outputs }) instead; its mapping type is 'BPMN.Variables'.`);
@@ -2128,6 +2161,7 @@ class ScopeBuilder {
2128
2161
  inputs: opts.inputs ?? {},
2129
2162
  inputRows: opts.inputRows,
2130
2163
  spec: opts.spec,
2164
+ element: opts.element,
2131
2165
  typeVersion: opts.typeVersion,
2132
2166
  inputSchema: opts.inputSchema,
2133
2167
  outputVar: opts.outputVar,
@@ -2139,6 +2173,8 @@ class ScopeBuilder {
2139
2173
  tags: opts.tags,
2140
2174
  retry: opts.retry,
2141
2175
  errorMapping: opts.errorMapping,
2176
+ updates: opts.updates,
2177
+ updateRows: opts.updateRows,
2142
2178
  loop: opts.loop,
2143
2179
  }, body);
2144
2180
  }
@@ -2691,6 +2727,8 @@ export class SubProcessBuilder extends ScopeBuilder {
2691
2727
  loop: opts.loop,
2692
2728
  retry: opts.retry,
2693
2729
  errorMapping: opts.errorMapping,
2730
+ updates: opts.updates,
2731
+ updateRows: opts.updateRows,
2694
2732
  nodes: this._nodes,
2695
2733
  flows: this._flows,
2696
2734
  variables: this._vars,
@@ -57,6 +57,7 @@ import BpmnModdle from 'bpmn-moddle';
57
57
  import { flattenConnectorBody } from '../core/connector-inputs.js';
58
58
  import { createRequire } from 'node:module';
59
59
  import { isSnapshotType, registryType, rowDeclaration } from './typed-node.js';
60
+ import { PLAIN_TASK_ELEMENTS } from './task-elements.js';
60
61
  import { errorSchema, errorSchemaWithResponse } from './bpmn-sdk.js';
61
62
  import { SCRIPT_ARGS_ENVELOPE, defaultScriptInputSchema } from './serialize.js';
62
63
  import { BPMN_SCHEMA_VERSIONS } from './format-profile.js';
@@ -300,6 +301,12 @@ let runUnmodelled = new Map();
300
301
  let runScriptTypes = new Map();
301
302
  /** Whether this run's source names `NO_MESSAGE`, so the import lists it. */
302
303
  let runUsesNoMessage = false;
304
+ /**
305
+ * Elements whose variable updates an emitter wrote as `updateRows`, so the header can
306
+ * name any element that carries a mapping besides its payload and was NOT carried.
307
+ * Keyed by element, not id, since a scope read twice emits the same element twice.
308
+ */
309
+ let runUpdatesCarried = new Set();
303
310
  let runLiftPlans = new Map();
304
311
  let runLiftSkipped = [];
305
312
  let runLiftCalls = new Map();
@@ -551,12 +558,68 @@ function emitConnectorLift(chain, el, payload, plan) {
551
558
  ['tags', tagsOf(el)],
552
559
  ['retry', emitRetry(retryOf(el))],
553
560
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
561
+ ['updateRows', emitUpdateRows(el)],
554
562
  ['loop', emitLoop(el)],
555
563
  ]);
556
564
  const call = `.connector(${tsText(el.id)}, ${tsText(plan.key)}, ${tsText(plan.action)}, ${record(plan.inputs) ?? '{}'}${optionalArg(options)})`;
557
565
  runLiftCalls.set(el.id, call);
558
566
  chain.add(call);
559
567
  }
568
+ /**
569
+ * The node's VARIABLE UPDATES: a `BPMN.Variables` `uipath:mapping` after its payload,
570
+ * holding only output rows, which Studio Web writes to assign process variables once
571
+ * the node has run (see `VariableUpdatesOpts`). Undefined when the element has none, or
572
+ * has a shape `updateRows` cannot reproduce (several such mappings, or one with
573
+ * context or input rows), which the source header names instead.
574
+ *
575
+ * `payloadOf` returns the FIRST payload, so this is never the node's own mapping.
576
+ */
577
+ function variableUpdatesOf(el) {
578
+ const payload = payloadOf(el);
579
+ if (payload === undefined)
580
+ return undefined;
581
+ const extra = (el.extensionElements?.values ?? []).filter((x) => x !== payload && x.$type === 'uipath:Mapping');
582
+ if (extra.length !== 1)
583
+ return undefined;
584
+ const mapping = extra[0];
585
+ if (extensionTypeOf(mapping) !== 'BPMN.Variables' || mapping.context !== undefined || (mapping.input ?? []).length)
586
+ return undefined;
587
+ return mapping;
588
+ }
589
+ /** Whether the element carries a mapping besides its payload, whatever its shape. */
590
+ function hasExtraMapping(el) {
591
+ const payload = payloadOf(el);
592
+ return payload !== undefined && (el.extensionElements?.values ?? []).some((x) => x !== payload && x.$type === 'uipath:Mapping');
593
+ }
594
+ /**
595
+ * The node's variable updates as `updateRows` option source, in document order, and
596
+ * recorded as carried. Rows are written verbatim (type, `custom`, `target` and all):
597
+ * the product types a row independently of the variable's declaration.
598
+ */
599
+ function emitUpdateRows(el) {
600
+ const mapping = variableUpdatesOf(el);
601
+ if (mapping === undefined)
602
+ return undefined;
603
+ const rows = mapping.output ?? [];
604
+ if (!rows.length)
605
+ return undefined;
606
+ runUpdatesCarried.add(el);
607
+ const rendered = rows.map((row) => opts([
608
+ ['name', tsText(row.name)],
609
+ ['type', row.type !== undefined ? tsText(row.type) : undefined],
610
+ ['var', row.var !== undefined ? tsText(row.var) : undefined],
611
+ ['source', row.source !== undefined ? tsText(row.source) : undefined],
612
+ ['custom', row.custom ? 'true' : undefined],
613
+ ['description', row.description !== undefined ? tsText(row.description) : undefined],
614
+ ['target', row.target !== undefined ? tsText(row.target) : undefined],
615
+ ['schema', row.body !== undefined ? jsonLiteral(row.body) : undefined],
616
+ ]));
617
+ return `[${rendered.join(', ')}]`;
618
+ }
619
+ /** Every flow element of `scope`, sub-process contents included, in document order. */
620
+ function allFlowElements(scope) {
621
+ return (scope.flowElements ?? []).flatMap((el) => [el, ...allFlowElements(el)]);
622
+ }
560
623
  function payloadOf(el) {
561
624
  for (const ext of el.extensionElements?.values ?? []) {
562
625
  if (ext.$type === 'uipath:Activity' || ext.$type === 'uipath:Event' || ext.$type === 'uipath:Mapping')
@@ -921,6 +984,7 @@ function emitQuickHumanTask(chain, el, payload) {
921
984
  ['tags', tagsOf(el)],
922
985
  ['retry', emitRetry(retryOf(el))],
923
986
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
987
+ ['updateRows', emitUpdateRows(el)],
924
988
  ['loop', emitLoop(el)],
925
989
  ])})`);
926
990
  return true;
@@ -1000,13 +1064,22 @@ function emitTypedNode(chain, el, payload, type) {
1000
1064
  ['outputs', verbatimRows === undefined ? record(extras) : undefined],
1001
1065
  ['skipCondition', payload.skipCondition !== undefined ? tsText(payload.skipCondition) : undefined],
1002
1066
  ['contextVerbatim', Object.keys(ctx).length ? 'true' : undefined],
1067
+ ['element', elementAsWritten(el, spec)],
1003
1068
  ['entryPointId', entryPointOption(el)],
1004
1069
  ['tags', tagsOf(el)],
1005
1070
  ['retry', emitRetry(retryOf(el))],
1006
1071
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
1072
+ ['updateRows', emitUpdateRows(el)],
1007
1073
  ['loop', emitLoop(el)],
1008
1074
  ]))})`);
1009
1075
  }
1076
+ /** The `element` option: the node's task element when it is not the registry's, else undefined. */
1077
+ function elementAsWritten(el, spec) {
1078
+ if (el.$type === spec.element)
1079
+ return undefined;
1080
+ const element = `bpmn:${localName(el.$type)}`;
1081
+ return PLAIN_TASK_ELEMENTS.has(element) ? tsText(element) : undefined;
1082
+ }
1010
1083
  /** The registry's spec for a type, or `undefined` when neither the snapshot nor `uip` lists it. */
1011
1084
  function listedSpec(type) {
1012
1085
  try {
@@ -1122,6 +1195,7 @@ function emitUnlistedTypedNode(chain, el, payload, type) {
1122
1195
  ['tags', tagsOf(el)],
1123
1196
  ['retry', emitRetry(retryOf(el))],
1124
1197
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
1198
+ ['updateRows', emitUpdateRows(el)],
1125
1199
  ['loop', emitLoop(el)],
1126
1200
  ])})`);
1127
1201
  }
@@ -1294,6 +1368,7 @@ function emitScriptTask(chain, el, payload, type) {
1294
1368
  ['tags', tagsOf(el)],
1295
1369
  ['retry', emitRetry(retryOf(el))],
1296
1370
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
1371
+ ['updateRows', emitUpdateRows(el)],
1297
1372
  ['loop', emitLoop(el)],
1298
1373
  ])})`);
1299
1374
  }
@@ -1313,6 +1388,7 @@ function emitVariableTask(chain, el, payload) {
1313
1388
  ['tags', tagsOf(el)],
1314
1389
  ['retry', emitRetry(retryOf(el))],
1315
1390
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
1391
+ ['updateRows', emitUpdateRows(el)],
1316
1392
  ['loop', emitLoop(el)],
1317
1393
  ])})`);
1318
1394
  }
@@ -2067,6 +2143,7 @@ function emitTriggerStartEvent(chain, el, payload, type) {
2067
2143
  ...eventOptions(el),
2068
2144
  ['trigger', trigger],
2069
2145
  ['entryPointId', entryPointOption(el)],
2146
+ ['updateRows', emitUpdateRows(el)],
2070
2147
  ])})`);
2071
2148
  }
2072
2149
  /**
@@ -2207,6 +2284,8 @@ function emitEvent(chain, el, kind, payload, type) {
2207
2284
  ['interrupting', kind === 'startEvent' && el.isInterrupting === false ? 'false' : undefined],
2208
2285
  ['entryPointId', entryPointOption(el)],
2209
2286
  ['payload', eventPayload],
2287
+ // `.startEvent()` / `.endEvent()` carry updates; the intermediate events do not.
2288
+ ['updateRows', kind === 'startEvent' || kind === 'endEvent' ? emitUpdateRows(el) : undefined],
2210
2289
  ]))})`);
2211
2290
  }
2212
2291
  /**
@@ -2360,6 +2439,7 @@ function emitElement(chain, el, depth, indent) {
2360
2439
  ['tags', tagsOf(el)],
2361
2440
  ['retry', emitRetry(retryOf(el))],
2362
2441
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
2442
+ ['updateRows', emitUpdateRows(el)],
2363
2443
  ['loop', emitLoop(el)],
2364
2444
  ]))})`);
2365
2445
  return;
@@ -2392,6 +2472,7 @@ function emitElement(chain, el, depth, indent) {
2392
2472
  ['tags', tagsOf(el)],
2393
2473
  ['retry', emitRetry(retryOf(el))],
2394
2474
  ['errorMapping', emitErrorMapping(errorMappingOf(el))],
2475
+ ['updateRows', emitUpdateRows(el)],
2395
2476
  ]))})`);
2396
2477
  return;
2397
2478
  }
@@ -2777,6 +2858,7 @@ export async function decompile(xml, options = {}) {
2777
2858
  runUnmodelled = new Map();
2778
2859
  runScriptTypes = new Map();
2779
2860
  runUsesNoMessage = false;
2861
+ runUpdatesCarried = new Set();
2780
2862
  runLiftPlans = new Map();
2781
2863
  runLiftSkipped = [];
2782
2864
  runLiftCalls = new Map();
@@ -2857,6 +2939,18 @@ export async function decompile(xml, options = {}) {
2857
2939
  '\n'
2858
2940
  : '';
2859
2941
  runScriptTypes = new Map();
2942
+ // Every element with a mapping besides its payload that no emitter carried as
2943
+ // `updateRows` — a shape the builder cannot state — is named, so the loss on a bare
2944
+ // recompile is stated rather than silent. `bpmn merge` keeps the original's.
2945
+ const uncarried = allFlowElements(process).filter((el) => hasExtraMapping(el) && !runUpdatesCarried.has(el));
2946
+ runUpdatesCarried = new Set();
2947
+ const updatesNote = uncarried.length
2948
+ ? `// VARIABLE UPDATES LEFT TO THE ORIGINAL. These elements carry a uipath:mapping\n` +
2949
+ `// after their payload that this source cannot state as \`updateRows\`, so a bare\n` +
2950
+ `// recompile drops it; \`bpmn merge\` back into the original keeps it:\n` +
2951
+ uncarried.map((el) => `// - ${commentText(String(el.id))}\n`).join('') +
2952
+ '\n'
2953
+ : '';
2860
2954
  if (runUsesNoMessage)
2861
2955
  importedNames.push('NO_MESSAGE');
2862
2956
  runUsesNoMessage = false;
@@ -2867,7 +2961,7 @@ export async function decompile(xml, options = {}) {
2867
2961
  lifted: [...runLiftPlans.keys()],
2868
2962
  verbatim: runLiftSkipped,
2869
2963
  preamble: {
2870
- prefix: `${host.note}${otherPools}${unmodelledNote}${scriptTypeNote}${imports}`,
2964
+ prefix: `${host.note}${otherPools}${unmodelledNote}${scriptTypeNote}${updatesNote}${imports}`,
2871
2965
  head: `bpmn(${tsText(process.id)})`,
2872
2966
  calls: [...(nameCall !== undefined ? [nameCall] : []), ...chain.all.slice(0, preambleLines)],
2873
2967
  },
@@ -2883,7 +2977,7 @@ export async function decompile(xml, options = {}) {
2883
2977
  binding: 'processBuilder',
2884
2978
  indent,
2885
2979
  });
2886
- return `${host.note}${otherPools}${unmodelledNote}${scriptTypeNote}${imports}${body}\n`;
2980
+ return `${host.note}${otherPools}${unmodelledNote}${scriptTypeNote}${updatesNote}${imports}${body}\n`;
2887
2981
  }
2888
2982
  /**
2889
2983
  * Variable ids the serializer creates on its own from a node's output rows.
@@ -740,7 +740,7 @@ function createNode(ctx, n) {
740
740
  const el = createTypedNode(m, n.id, n.trigger.type, { name: n.name, outputVar: n.trigger.outputVar }, (varId) => ctx.authoredVarType.get(varId));
741
741
  const triggerDef = eventDefinition(ctx, n.event);
742
742
  el.eventDefinitions = triggerDef ? [triggerDef] : [];
743
- return el;
743
+ return attachVariableUpdates(ctx, el, n.variableUpdates ?? {});
744
744
  }
745
745
  const el = m.create(`bpmn:${cap(n.kind)}`, { id: n.id, name: n.name });
746
746
  // Only the exception is written: BPMN's default is interrupting, and an
@@ -749,6 +749,7 @@ function createNode(ctx, n) {
749
749
  if (n.kind === 'startEvent' && n.interrupting === false)
750
750
  el.isInterrupting = false;
751
751
  attachExtensionPayload(ctx, el, n.payload);
752
+ attachVariableUpdates(ctx, el, n.variableUpdates ?? {});
752
753
  const def = eventDefinition(ctx, n.event);
753
754
  if (def)
754
755
  el.eventDefinitions = [def];
@@ -793,6 +794,7 @@ function createNode(ctx, n) {
793
794
  inputs: n.inputs,
794
795
  inputRows: n.inputRows,
795
796
  spec: n.spec,
797
+ element: n.element === undefined ? undefined : moddleTaskType(n.element),
796
798
  typeVersion: n.typeVersion,
797
799
  inputSchema: n.inputSchema,
798
800
  outputVar: n.outputVar,
@@ -905,6 +907,39 @@ function attachExtensionPayload(ctx, el, payload) {
905
907
  inputRows: payload.inputRows,
906
908
  }));
907
909
  }
910
+ /**
911
+ * The node's variable updates (`updates` / `updateRows`) as the product writes them: a
912
+ * second `uipath:mapping` (`BPMN.Variables`, rows `custom="true"`) right after the
913
+ * node's own payload, and after `uipath:scriptVersion` when that follows the payload,
914
+ * which is where Studio Web puts it on a script task. See `VariableUpdatesOpts`.
915
+ *
916
+ * Done once, here, for every kind that can carry them, rather than in each creator.
917
+ */
918
+ function attachVariableUpdates(ctx, el, n) {
919
+ const rows = [
920
+ ...outputRows(ctx, n.updates ?? {}, true),
921
+ ...(n.updateRows ? verbatimOutputRows(ctx.m, n.updateRows) : []),
922
+ ];
923
+ if (!rows.length)
924
+ return el;
925
+ const mapping = ctx.m.create('uipath:Mapping', {
926
+ version: 'v1',
927
+ type: ctx.m.create('uipath:Type', { value: 'BPMN.Variables', version: 'v1' }),
928
+ output: rows,
929
+ });
930
+ const ext = (el.extensionElements ??= ctx.m.create('bpmn:ExtensionElements', { values: [] }));
931
+ const values = (ext.values ??= []);
932
+ const PAYLOADS = new Set(['uipath:Mapping', 'uipath:Activity', 'uipath:Event']);
933
+ let at = values.findIndex((v) => PAYLOADS.has(v.$type));
934
+ if (at === -1) {
935
+ values.push(mapping);
936
+ return el;
937
+ }
938
+ if (values[at + 1]?.$type === 'uipath:ScriptVersion')
939
+ at++;
940
+ values.splice(at + 1, 0, mapping);
941
+ return el;
942
+ }
908
943
  /**
909
944
  * Attach what every ACTIVITY can carry — a retry policy and a multi-instance loop
910
945
  * — to an element its own creator has already built.
@@ -934,7 +969,7 @@ function applyActivityFields(ctx, el, n) {
934
969
  }
935
970
  if (n.loop)
936
971
  el.loopCharacteristics = buildLoopCharacteristics(ctx, n.loop);
937
- return el;
972
+ return attachVariableUpdates(ctx, el, n);
938
973
  }
939
974
  /**
940
975
  * `uipath:errorMapping` — how an activity classifies its failures.
@@ -0,0 +1,2 @@
1
+ /** Every {@link PlainTaskElement}: the elements `.plainTask()` and `.activity({ element })` accept. */
2
+ export declare const PLAIN_TASK_ELEMENTS: ReadonlySet<string>;
@@ -0,0 +1,4 @@
1
+ /** Every {@link PlainTaskElement}: the elements `.plainTask()` and `.activity({ element })` accept. */
2
+ export const PLAIN_TASK_ELEMENTS = new Set([
3
+ 'bpmn:callActivity', 'bpmn:task', 'bpmn:userTask', 'bpmn:serviceTask', 'bpmn:sendTask', 'bpmn:manualTask', 'bpmn:businessRuleTask', 'bpmn:receiveTask',
4
+ ]);
@@ -344,6 +344,8 @@ export declare function connectorInputsShadowed(id: string, type: string, inputs
344
344
  export interface TypedNodeInput {
345
345
  /** Display name the designer shows. */
346
346
  name?: string;
347
+ /** The moddle element to write instead of the spec's (`bpmn:ServiceTask`) — see `ActivityNodeOpts.element`. */
348
+ element?: string;
347
349
  /** Context values, by field name — the registry decides which are required. */
348
350
  context?: Record<string, unknown>;
349
351
  /** Context rows spelled out, replacing `context` — see {@link TypedContextRow}. */
@@ -553,7 +553,8 @@ export function createTypedNode(m, id, type, input,
553
553
  * Optional so a caller with no variable context still gets today's behaviour.
554
554
  */
555
555
  varType) {
556
- const spec = registryType(type, input.spec);
556
+ const registered = registryType(type, input.spec);
557
+ const spec = input.element === undefined ? registered : { ...registered, element: input.element };
557
558
  if (!spec.element || !spec.tag) {
558
559
  throw new CompileRefusal('BPMN_TYPE_NOT_AUTHORABLE', `extension type "${type}" has no element/tag in the registry snapshot; it cannot be authored.`);
559
560
  }