@uipath/maestro-builder-sdk 6.93.7 → 6.93.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.
@@ -1012,13 +1012,23 @@ export interface ScriptTaskOpts extends ActivityOpts {
1012
1012
  * is anything else. `uip maestro bpmn validate` accepts both, so nothing in the
1013
1013
  * toolchain catches the wrong one — which is why the SDK emitted it for so long.
1014
1014
  *
1015
- * The option is kept rather than removed because it shipped (v3.25.0), and an
1016
- * importer may still meet a legacy artifact carrying the invalid value. Decompile
1017
- * does NOT preserve it: reproducing markup the contract rejects is propagating a
1018
- * defect, not fidelity — the same call the round trip already makes for a bare
1019
- * `<uipath:input name="args">`.
1020
- */
1021
- type?: string;
1015
+ * Any other value replaces the script's extension type, so the script never runs
1016
+ * and its outputs read back null — and `uip maestro bpmn validate` and a live
1017
+ * debug both still pass. So `.scriptTask()` refuses every value but
1018
+ * `BPMN.Variables` with `BPMN_SCRIPT_TASK_TYPE_INVALID`, the same way
1019
+ * `.plainTask()` refuses an element it cannot emit. `uip maestro bpmn registry get
1020
+ * BPMN.ScriptTask` lists `BPMN.ScriptTask`; do not copy it here. `.activity()`
1021
+ * refuses that type too (`BPMN_ACTIVITY_SCRIPT_TASK_TYPE`).
1022
+ *
1023
+ * The option is kept rather than removed because it shipped (v3.25.0) and code
1024
+ * that spells the default out still compiles. Decompile does NOT preserve any
1025
+ * other type an artifact may carry (the legacy `BPMN.ScriptTask` included): it
1026
+ * writes none, so the source is one this method accepts, and the header of the
1027
+ * decompiled source lists each task it normalised. Reproducing markup the contract
1028
+ * rejects is propagating a defect, not fidelity — the same call the round trip
1029
+ * already makes for a bare `<uipath:input name="args">`.
1030
+ */
1031
+ type?: 'BPMN.Variables';
1022
1032
  }
1023
1033
  /** Options for `.task()` — a display name and the variable assignments the task makes. */
1024
1034
  export interface TaskOpts extends ActivityOpts {
@@ -1197,12 +1207,13 @@ export interface DataServiceOpts extends ActivityOpts {
1197
1207
  skipCondition?: string;
1198
1208
  }
1199
1209
  /**
1200
- * Options for `.http()` — an `Intsvc.UnifiedHttpRequest` node.
1210
+ * Options for `.http()` — a V2 `Intsvc.UnifiedHttpRequest` node.
1201
1211
  *
1202
- * The field names are the registry's own context fields, so what you write is
1203
- * what the platform reads. `mode` is required-and-hidden in the registry and
1204
- * always emitted as `manual`; it is not an option because there is nothing to
1205
- * choose.
1212
+ * The request is written as the `body` row's JSON, in the shape `uip maestro bpmn registry
1213
+ * get Intsvc.UnifiedHttpRequest --input-details <request>` builds: `authentication`
1214
+ * (`manual`, or `connector` with {@link HttpOpts.connection}), `method`, `url`, and the
1215
+ * `headers`, `query` and `body` you give. A value that reads a variable is written `=js:`,
1216
+ * as the CLI writes it (`=vars.x` becomes `=js:vars.x`).
1206
1217
  */
1207
1218
  export interface HttpOpts extends ActivityOpts {
1208
1219
  /** Display name the designer shows on the task. */
@@ -1215,21 +1226,16 @@ export interface HttpOpts extends ActivityOpts {
1215
1226
  url: string;
1216
1227
  /** HTTP method. Defaults to `'GET'`, matching the registry's own default. */
1217
1228
  method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
1218
- /** Request headers — serialized to the node's json context field. */
1229
+ /** Request headers — the request's `headers`. */
1219
1230
  headers?: Record<string, unknown>;
1220
- /**
1221
- * Query parameters — serialized to the node's json context field, or to the request's
1222
- * `query` in connector mode (see {@link HttpOpts.connection}).
1223
- */
1231
+ /** Query parameters — the request's `query`. */
1224
1232
  parameters?: Record<string, unknown>;
1225
1233
  /**
1226
- * Request body — serialized to the node's json context field.
1234
+ * Request body — the request's `body`.
1227
1235
  *
1228
1236
  * @remarks
1229
- * Leave it off for a request that has none: the row is written as `{}`, which the
1230
- * runtime accepts. The registry declares the default as the text `null`, and the
1231
- * runtime refuses that (`IntSvcUnifiedHttpRequestArgs`: `Body cannot be null`,
1232
- * incident 102018) — every GET this SDK emitted before flow-v2-run-12 faulted on it.
1237
+ * Leave it off for a request that has none, a GET say: the request then carries no
1238
+ * `body` key, as the CLI writes it.
1233
1239
  */
1234
1240
  body?: unknown;
1235
1241
  /**
@@ -1237,15 +1243,19 @@ export interface HttpOpts extends ActivityOpts {
1237
1243
  * request through — which switches the node to CONNECTOR mode.
1238
1244
  *
1239
1245
  * @remarks
1240
- * Without it the node is `Intsvc.UnifiedHttpRequest` in `mode="manual"`: the
1241
- * process owns the URL, headers and auth, and nothing on the tenant is involved.
1242
- * With it the node is the V2 `Intsvc.UnifiedHttpRequest` in connector mode, as
1243
- * `uip maestro bpmn registry get Intsvc.UnifiedHttpRequest --connection-id` builds it:
1244
- * context `connectorKey` `uipath-uipath-http`, the connection bound, and a `body` row
1245
- * carrying the request
1246
- * (`{"authentication":"connector","method":"GET","targetConnector":…,"connection":…,"path":…,"url":…,"headers":…,"query":…,"body":…}`),
1247
- * whose auth is the connection's. A value that reads a variable is written `=js:`, as the
1248
- * CLI writes it (`=vars.x` becomes `=js:vars.x`). That is the shape for "call an endpoint the
1246
+ * Without it the request is MANUAL: the process owns the URL, headers and auth, and the
1247
+ * `body` row is `{"authentication":"manual","method":…,"url":…,"headers":…,"query":…,"body":…}`.
1248
+ * The node still calls the generic HTTP connector (`uipath-uipath-http`), through Studio
1249
+ * Web's implicit connection: a binding whose default and resource key are
1250
+ * `ImplicitConnection` (id `bodyYna9C`, the CLI's, shared by every manual request in the
1251
+ * process), which no tenant resource backs and `bpmn refresh` leaves out of
1252
+ * `bindings_v2.json`. Nothing on the tenant needs to exist.
1253
+ *
1254
+ * With it the node is in connector mode, as `uip maestro bpmn registry get
1255
+ * Intsvc.UnifiedHttpRequest --connection-id` builds it: the connection bound, and the
1256
+ * request
1257
+ * (`{"authentication":"connector","method":"GET","targetConnector":…,"connection":…,"path":…,"url":…,"headers":…,"query":…,"body":…}`)
1258
+ * authenticated by the connection. That is the shape for "call an endpoint the
1249
1259
  * connector catalog has no activity for, through an existing connection" — the
1250
1260
  * non-catalog HTTP fallback.
1251
1261
  *
@@ -1279,9 +1289,13 @@ export interface HttpOpts extends ActivityOpts {
1279
1289
  */
1280
1290
  outputs?: Record<string, string>;
1281
1291
  /**
1282
- * Variable the response lands in. Defaults to `<id>_response`. In connector mode it is
1283
- * the response body; the status code and headers land in `<id>_code` and `<id>_headers`,
1284
- * so it cannot be either.
1292
+ * Variable the response body lands in. Defaults to `<id>_response`. The status code,
1293
+ * headers and error land in `<id>_code`, `<id>_headers` and `<id>_Error`, so it cannot be
1294
+ * any of them, and no {@link HttpOpts.outputs} row may name any of the four.
1295
+ *
1296
+ * @remarks
1297
+ * Before #1873 it held the whole response, so a read written for that shape
1298
+ * (`vars.<id>_response.body.x`) now gets `undefined`: read `vars.<id>_response.x`.
1285
1299
  */
1286
1300
  outputVar?: string;
1287
1301
  /** `=`-expression that skips the request when truthy. */
@@ -2543,15 +2557,17 @@ declare abstract class ScopeBuilder {
2543
2557
  * `uipath:activity` / `Intsvc.UnifiedHttpRequest`).
2544
2558
  *
2545
2559
  * @remarks
2546
- * The first registry-backed typed node (`docs/BPMN_COVERAGE_DESIGN.md` Phase 3).
2547
- * Its wire shape — element, tag, context fields, output row — comes from the
2548
- * committed registry snapshot rather than hand-written emission, so it cannot
2549
- * drift from what the platform validates. Chosen as the pilot because it needs
2550
- * no tenant discovery (`RequiresDiscovery: No`) and the local engine dispatches
2551
- * it for real in `--mode live`.
2552
- *
2553
- * The response lands in `<id>_response` unless `outputVar` says otherwise, and
2554
- * that variable is readable downstream as `=vars.<name>` with no `.var()`.
2560
+ * The V2 element `uip maestro bpmn registry get Intsvc.UnifiedHttpRequest
2561
+ * --input-details <request>` builds (`managed-http.ts`): the node calls Integration
2562
+ * Service's generic HTTP connector, and the request rides in its `body` row. Without
2563
+ * {@link HttpOpts.connection} the request is manual (`"authentication":"manual"`) and
2564
+ * names Studio Web's implicit connection; with it, the request goes through that
2565
+ * connection. It needs no tenant discovery, and the local engine dispatches it for real
2566
+ * in `--mode live`.
2567
+ *
2568
+ * The response body lands in `<id>_response` unless `outputVar` says otherwise, the
2569
+ * status code in `<id>_code`, the headers in `<id>_headers` and the error payload in
2570
+ * `<id>_Error`; each is readable downstream as `=vars.<name>` with no `.var()`.
2555
2571
  *
2556
2572
  * @example
2557
2573
  * ```ts
@@ -2574,12 +2590,26 @@ declare abstract class ScopeBuilder {
2574
2590
  */
2575
2591
  http(id: string, opts: HttpOpts, body?: ActivityBodyFn): this;
2576
2592
  /**
2577
- * @internal Connector-mode `.http()`: the request through an Integration Service
2578
- * connection, as the V2 `Intsvc.UnifiedHttpRequest` element `uip maestro bpmn registry
2579
- * get Intsvc.UnifiedHttpRequest --connection-id` builds (see `managed-http.ts`). The
2580
- * connection and folder resolve exactly as `.dataService()`'s do.
2593
+ * @internal A manual `.http()` request: it authenticates itself, and names the process's
2594
+ * one implicit-connection binding (Studio Web's `ImplicitConnection`), declared here on
2595
+ * first use under the id the CLI gives it. An author's own binding of that connection is
2596
+ * reused whatever its id; one that holds the CLI's id for something else keeps it, and
2597
+ * this node's binding takes `<id>_connection`, or the first `<id>_connection_<n>` no
2598
+ * binding holds when that is taken too.
2599
+ */
2600
+ private manualHttpRequest;
2601
+ /**
2602
+ * @internal The id a manual request's implicit-connection binding takes when none is
2603
+ * declared yet: the CLI's, else `<id>_connection`, else `<id>_connection_<n>` — the first
2604
+ * no binding holds, since `declare` would hand back the holder's unrelated value.
2581
2605
  */
2582
- private connectorHttp;
2606
+ private unusedImplicitBindingId;
2607
+ /**
2608
+ * @internal A connector-mode `.http()` request, through an Integration Service
2609
+ * connection, as `uip maestro bpmn registry get Intsvc.UnifiedHttpRequest --connection-id`
2610
+ * builds it. The connection and folder resolve exactly as `.dataService()`'s do.
2611
+ */
2612
+ private connectorHttpRequest;
2583
2613
  /**
2584
2614
  * A UiPath **Data Fabric** (Data Service) record or file operation — create,
2585
2615
  * update, get, query, delete a record, or download / upload / delete a record's
@@ -3100,6 +3130,11 @@ declare abstract class ScopeBuilder {
3100
3130
  * .build();
3101
3131
  * ```
3102
3132
  *
3133
+ * A script task is not built here: `'BPMN.ScriptTask'`, the type `registry get`
3134
+ * lists, is refused with `BPMN_ACTIVITY_SCRIPT_TASK_TYPE`. It would emit a script
3135
+ * task with no script whose mapping type replaces the script's extension type, so
3136
+ * nothing runs, and `check` and validate both pass it. Use {@link ScopeBuilder.scriptTask}.
3137
+ *
3103
3138
  * @param id - The element id, unique in the process and used by `sequenceFlow`.
3104
3139
  * @param type - The registry extension type, e.g. `'A2A.AgentExecution'`.
3105
3140
  * @param opts - Context values, payload, output mapping and the shared activity options.
@@ -6,7 +6,7 @@ import { resolveResourceKeyPattern } from './resource-key-pattern.js';
6
6
  import { quickHumanTaskRows } from './human-task-form.js';
7
7
  import { CompileRefusal } from '../core/compile-refusal.js';
8
8
  import { DATA_SERVICE_ACTIVITY_TYPE, dataServiceContext, dataServiceWire, isPendingEntity, refuseEntityShape, } from './data-service.js';
9
- import { MANAGED_HTTP_CONNECTION_NAME, MANAGED_HTTP_CONNECTOR_KEY, MANAGED_HTTP_FOLDER_NAME, MANAGED_HTTP_TYPE, managedHttpContext, managedHttpInputs, managedHttpOutputs, } from './managed-http.js';
9
+ import { IMPLICIT_CONNECTION, IMPLICIT_CONNECTION_BINDING_ID, MANAGED_HTTP_CONNECTION_NAME, MANAGED_HTTP_CONNECTOR_KEY, MANAGED_HTTP_FOLDER_NAME, MANAGED_HTTP_TYPE, managedHttpContext, managedHttpInputs, managedHttpOutputs, } from './managed-http.js';
10
10
  import { ownEntry } from '../core/own-entry.js';
11
11
  export { BpmnBuildError } from './bpmn-expr-check.js';
12
12
  // @internal helpers kept on the published /bpmn subpath; SDK code imports declared-vars.js.
@@ -878,6 +878,12 @@ class ScopeBuilder {
878
878
  * @returns This builder, so calls chain.
879
879
  */
880
880
  scriptTask(id, opts, body) {
881
+ // `type` is only type-restricted, and a `.bpmn.ts` loads without a type check.
882
+ const type = opts.type ?? 'BPMN.Variables';
883
+ if (type !== 'BPMN.Variables') {
884
+ throw new CompileRefusal('BPMN_SCRIPT_TASK_TYPE_INVALID', `.scriptTask('${id}'): type "${type}" replaces the script's extension type, so the script never runs and its outputs read back null. ` +
885
+ `A script task's only type is 'BPMN.Variables' (the default) — drop \`type\`.`);
886
+ }
881
887
  return this.pushActivity({
882
888
  kind: 'scriptTask',
883
889
  id,
@@ -888,7 +894,7 @@ class ScopeBuilder {
888
894
  inputs: opts.inputs ?? {},
889
895
  outputs: opts.outputs ?? {},
890
896
  outputRows: opts.outputRows,
891
- type: opts.type ?? 'BPMN.Variables',
897
+ type,
892
898
  inputSchema: opts.inputSchema,
893
899
  tags: opts.tags,
894
900
  retry: opts.retry,
@@ -1004,15 +1010,17 @@ class ScopeBuilder {
1004
1010
  * `uipath:activity` / `Intsvc.UnifiedHttpRequest`).
1005
1011
  *
1006
1012
  * @remarks
1007
- * The first registry-backed typed node (`docs/BPMN_COVERAGE_DESIGN.md` Phase 3).
1008
- * Its wire shape — element, tag, context fields, output row — comes from the
1009
- * committed registry snapshot rather than hand-written emission, so it cannot
1010
- * drift from what the platform validates. Chosen as the pilot because it needs
1011
- * no tenant discovery (`RequiresDiscovery: No`) and the local engine dispatches
1012
- * it for real in `--mode live`.
1013
- *
1014
- * The response lands in `<id>_response` unless `outputVar` says otherwise, and
1015
- * that variable is readable downstream as `=vars.<name>` with no `.var()`.
1013
+ * The V2 element `uip maestro bpmn registry get Intsvc.UnifiedHttpRequest
1014
+ * --input-details <request>` builds (`managed-http.ts`): the node calls Integration
1015
+ * Service's generic HTTP connector, and the request rides in its `body` row. Without
1016
+ * {@link HttpOpts.connection} the request is manual (`"authentication":"manual"`) and
1017
+ * names Studio Web's implicit connection; with it, the request goes through that
1018
+ * connection. It needs no tenant discovery, and the local engine dispatches it for real
1019
+ * in `--mode live`.
1020
+ *
1021
+ * The response body lands in `<id>_response` unless `outputVar` says otherwise, the
1022
+ * status code in `<id>_code`, the headers in `<id>_headers` and the error payload in
1023
+ * `<id>_Error`; each is readable downstream as `=vars.<name>` with no `.var()`.
1016
1024
  *
1017
1025
  * @example
1018
1026
  * ```ts
@@ -1034,57 +1042,103 @@ class ScopeBuilder {
1034
1042
  * @returns This builder, so calls chain.
1035
1043
  */
1036
1044
  http(id, opts, body) {
1037
- const { name, url, method, headers, parameters, body: requestBody, outputs, outputVar, skipCondition, retry, loop, errorMapping } = opts;
1038
- if (opts.connection !== undefined)
1039
- return this.connectorHttp(id, opts, body);
1040
- if (opts.folder !== undefined || opts.connectorKey !== undefined) {
1045
+ if (opts.connection === undefined && (opts.folder !== undefined || opts.connectorKey !== undefined)) {
1041
1046
  throw new CompileRefusal('BPMN_HTTP_CONNECTOR_FIELDS_NO_CONNECTION', `http "${id}": \`folder\` and \`connectorKey\` belong to connector mode, which \`connection\` selects — ` +
1042
1047
  `pass the connection's binding name too, or drop them for a connectionless request.`);
1043
1048
  }
1049
+ const vars = { code: `${id}_code`, headers: `${id}_headers`, body: opts.outputVar ?? `${id}_response`, error: `${id}_Error` };
1050
+ // Each of the four rows writes its own variable; a second writer of one would
1051
+ // overwrite it, so neither `outputVar` nor an `outputs` row may name another's.
1052
+ const fixed = [[vars.code, 'status code'], [vars.headers, 'headers'], [vars.error, 'error']];
1053
+ const clash = fixed.find(([name]) => name === opts.outputVar);
1054
+ if (clash !== undefined) {
1055
+ throw new CompileRefusal('BPMN_HTTP_OUTPUT_VAR_RESERVED', `http "${id}": outputVar "${opts.outputVar}" is the variable .http() writes the ${clash[1]} to. ` +
1056
+ `Pick another name, or drop outputVar for the default "${id}_response".`);
1057
+ }
1058
+ const written = new Map([...fixed, [vars.body, 'response body']]);
1059
+ const taken = Object.keys(opts.outputs ?? {}).find((name) => written.has(name));
1060
+ if (taken !== undefined) {
1061
+ throw new CompileRefusal('BPMN_HTTP_OUTPUT_VAR_RESERVED', `http "${id}": outputs row "${taken}" is the variable .http() writes the ${written.get(taken)} to. ` +
1062
+ `Name the row's variable something else, or read the value from "${taken}" downstream.`);
1063
+ }
1064
+ const request = opts.connection !== undefined ? this.connectorHttpRequest(id, opts) : this.manualHttpRequest(id, opts);
1044
1065
  return this.pushActivity({
1045
1066
  kind: 'typed',
1046
1067
  id,
1047
- name,
1048
- type: 'Intsvc.UnifiedHttpRequest',
1049
- // These three are `json` context fields, so they go through as VALUES — the
1050
- // emitter encodes a json field's body. This wrapper used to `JSON.stringify`
1051
- // them itself, working around an emitter that wrote `[object Object]` for
1052
- // anything but a string; now the generic `.activity()` path accepts the same
1053
- // values this one does.
1054
- context: {
1055
- method: method ?? 'GET',
1056
- url,
1057
- ...(headers !== undefined ? { headers } : {}),
1058
- ...(parameters !== undefined ? { parameters } : {}),
1059
- ...(requestBody !== undefined ? { body: requestBody } : {}),
1060
- },
1068
+ name: opts.name,
1069
+ type: MANAGED_HTTP_TYPE,
1070
+ context: {},
1071
+ contextRows: managedHttpContext(request),
1061
1072
  inputs: {},
1062
- outputs,
1063
- outputVar,
1064
- skipCondition,
1065
- retry,
1066
- loop,
1067
- errorMapping,
1073
+ inputRows: managedHttpInputs(request),
1074
+ outputRows: managedHttpOutputs(vars),
1075
+ // `outputs` does not survive `outputRows`; the author's rows go after the four as
1076
+ // mapped rows, each typed from the variable it writes.
1077
+ mappedOutputRows: Object.entries(opts.outputs ?? {}).map(([varId, source]) => ({ name: varId, type: 'string', source, var: varId })),
1078
+ skipCondition: opts.skipCondition,
1079
+ tags: opts.tags,
1080
+ retry: opts.retry,
1081
+ errorMapping: opts.errorMapping,
1082
+ loop: opts.loop,
1068
1083
  }, body);
1069
1084
  }
1070
1085
  /**
1071
- * @internal Connector-mode `.http()`: the request through an Integration Service
1072
- * connection, as the V2 `Intsvc.UnifiedHttpRequest` element `uip maestro bpmn registry
1073
- * get Intsvc.UnifiedHttpRequest --connection-id` builds (see `managed-http.ts`). The
1074
- * connection and folder resolve exactly as `.dataService()`'s do.
1086
+ * @internal A manual `.http()` request: it authenticates itself, and names the process's
1087
+ * one implicit-connection binding (Studio Web's `ImplicitConnection`), declared here on
1088
+ * first use under the id the CLI gives it. An author's own binding of that connection is
1089
+ * reused whatever its id; one that holds the CLI's id for something else keeps it, and
1090
+ * this node's binding takes `<id>_connection`, or the first `<id>_connection_<n>` no
1091
+ * binding holds when that is taken too.
1075
1092
  */
1076
- connectorHttp(id, opts, body) {
1077
- const codeVar = `${id}_code`;
1078
- const headersVar = `${id}_headers`;
1079
- if (opts.outputVar === codeVar || opts.outputVar === headersVar) {
1080
- throw new CompileRefusal('BPMN_HTTP_OUTPUT_VAR_RESERVED', `http "${id}": outputVar "${opts.outputVar}" is the variable connector mode writes the status code or headers to. ` +
1081
- `Pick another name, or drop outputVar for the default "${id}_response".`);
1082
- }
1093
+ manualHttpRequest(id, opts) {
1094
+ const implicit = {
1095
+ id: IMPLICIT_CONNECTION_BINDING_ID,
1096
+ name: MANAGED_HTTP_CONNECTION_NAME,
1097
+ resource: 'Connection',
1098
+ propertyAttribute: 'ConnectionId',
1099
+ default: IMPLICIT_CONNECTION,
1100
+ resourceKey: IMPLICIT_CONNECTION,
1101
+ };
1102
+ const isImplicit = (b) => b.resource === 'Connection' && b.propertyAttribute.toLowerCase() === 'connectionid' && (b.resourceKey ?? b.default) === IMPLICIT_CONNECTION;
1103
+ const decl = this._bindingRegistry.bindings.find(isImplicit) ?? this._bindingRegistry.declare({ ...implicit, id: this.unusedImplicitBindingId(id) });
1104
+ return {
1105
+ authentication: 'manual',
1106
+ connection: { ref: `=bindings.${decl.id}` },
1107
+ method: opts.method ?? 'GET',
1108
+ url: opts.url,
1109
+ headers: opts.headers,
1110
+ query: opts.parameters,
1111
+ body: opts.body,
1112
+ };
1113
+ }
1114
+ /**
1115
+ * @internal The id a manual request's implicit-connection binding takes when none is
1116
+ * declared yet: the CLI's, else `<id>_connection`, else `<id>_connection_<n>` — the first
1117
+ * no binding holds, since `declare` would hand back the holder's unrelated value.
1118
+ */
1119
+ unusedImplicitBindingId(id) {
1120
+ const registry = this._bindingRegistry;
1121
+ if (!registry.has(IMPLICIT_CONNECTION_BINDING_ID))
1122
+ return IMPLICIT_CONNECTION_BINDING_ID;
1123
+ if (!registry.has(`${id}_connection`))
1124
+ return `${id}_connection`;
1125
+ let n = 2;
1126
+ while (registry.has(`${id}_connection_${n}`))
1127
+ n++;
1128
+ return `${id}_connection_${n}`;
1129
+ }
1130
+ /**
1131
+ * @internal A connector-mode `.http()` request, through an Integration Service
1132
+ * connection, as `uip maestro bpmn registry get Intsvc.UnifiedHttpRequest --connection-id`
1133
+ * builds it. The connection and folder resolve exactly as `.dataService()`'s do.
1134
+ */
1135
+ connectorHttpRequest(id, opts) {
1083
1136
  const connection = this.dataServiceBinding(id, 'connection', opts.connection, 'ConnectionId', MANAGED_HTTP_CONNECTION_NAME);
1084
1137
  const folder = opts.folder !== undefined
1085
1138
  ? this.dataServiceBinding(id, 'folder', opts.folder, 'folderKey', MANAGED_HTTP_FOLDER_NAME, connection.key)
1086
1139
  : undefined;
1087
- const request = {
1140
+ return {
1141
+ authentication: 'connector',
1088
1142
  connection,
1089
1143
  folder,
1090
1144
  targetConnector: opts.connectorKey ?? MANAGED_HTTP_CONNECTOR_KEY,
@@ -1094,28 +1148,6 @@ class ScopeBuilder {
1094
1148
  query: opts.parameters,
1095
1149
  body: opts.body,
1096
1150
  };
1097
- return this.pushActivity({
1098
- kind: 'typed',
1099
- id,
1100
- name: opts.name,
1101
- type: MANAGED_HTTP_TYPE,
1102
- context: {},
1103
- contextRows: managedHttpContext(request),
1104
- inputs: {},
1105
- inputRows: managedHttpInputs(request),
1106
- outputRows: managedHttpOutputs({
1107
- code: codeVar,
1108
- headers: headersVar,
1109
- body: opts.outputVar ?? `${id}_response`,
1110
- error: `${id}_Error`,
1111
- }),
1112
- outputs: opts.outputs,
1113
- skipCondition: opts.skipCondition,
1114
- tags: opts.tags,
1115
- retry: opts.retry,
1116
- errorMapping: opts.errorMapping,
1117
- loop: opts.loop,
1118
- }, body);
1119
1151
  }
1120
1152
  /**
1121
1153
  * A UiPath **Data Fabric** (Data Service) record or file operation — create,
@@ -1992,6 +2024,11 @@ class ScopeBuilder {
1992
2024
  * .build();
1993
2025
  * ```
1994
2026
  *
2027
+ * A script task is not built here: `'BPMN.ScriptTask'`, the type `registry get`
2028
+ * lists, is refused with `BPMN_ACTIVITY_SCRIPT_TASK_TYPE`. It would emit a script
2029
+ * task with no script whose mapping type replaces the script's extension type, so
2030
+ * nothing runs, and `check` and validate both pass it. Use {@link ScopeBuilder.scriptTask}.
2031
+ *
1995
2032
  * @param id - The element id, unique in the process and used by `sequenceFlow`.
1996
2033
  * @param type - The registry extension type, e.g. `'A2A.AgentExecution'`.
1997
2034
  * @param opts - Context values, payload, output mapping and the shared activity options.
@@ -1999,6 +2036,10 @@ class ScopeBuilder {
1999
2036
  * @returns This builder, so calls chain.
2000
2037
  */
2001
2038
  activity(id, type, opts = {}, body) {
2039
+ if (type === 'BPMN.ScriptTask') {
2040
+ 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. ` +
2041
+ `Use .scriptTask('${id}', { script, outputs }) instead; its mapping type is 'BPMN.Variables'.`);
2042
+ }
2002
2043
  return this.pushActivity({
2003
2044
  kind: 'typed',
2004
2045
  id,
@@ -24,7 +24,7 @@ import { EQUALS_EXPR_DIALECT, checkConnectorLookups, checkConnectorResources, ch
24
24
  import { checkEventResolution, checkEventSubscription, eventParamsFor, } from '../core/event-checks.js';
25
25
  import { bindingRequiredFields, CASE_RUNTIME_INTERNAL_TYPES, CONNECTOR_ACTIVITY_TYPES, missingRequiredContext, missingRequiredInputs, platformEnforcesRequired, REGISTRY_GAPS, registryType, } from './typed-node.js';
26
26
  import { ownEntry } from '../core/own-entry.js';
27
- import { isManagedHttpV2, managedHttpAbsoluteUrl, managedHttpMissing } from './managed-http.js';
27
+ import { MANAGED_HTTP_TYPE, isManagedHttpV2, managedHttpAbsoluteUrl, managedHttpMissing } from './managed-http.js';
28
28
  import { connectorV2Missing, isConnectorV2 } from './connector.js';
29
29
  /**
30
30
  * The node row a diagnostic is about, where two rules can report one row: the
@@ -1871,6 +1871,23 @@ inEventSubProcess = false) {
1871
1871
  where: n.id,
1872
1872
  }, field));
1873
1873
  }
1874
+ // The V1 manual request (`mode="manual"`, the request as context rows), which `.http()`
1875
+ // wrote before #1873 and an import still carries. The runtime faults it on the `body`
1876
+ // row (incident 102018 "Body cannot be null") with the registry default `null`
1877
+ // (flow-v2-run-12) and with `{}` (flow-v2-run-14); `validate` accepts it, so only a
1878
+ // warning, but nothing shows a V1 manual request running.
1879
+ if (n.type === MANAGED_HTTP_TYPE && !managedHttp) {
1880
+ diags.push({
1881
+ level: 'warning',
1882
+ code: 'HTTP_MANUAL_V1',
1883
+ message: `"${n.id}" (${n.type}) is the V1 manual HTTP request (mode="manual", the request as context rows), which the ` +
1884
+ `runtime faults with incident 102018 "Invalid value in Unified HttpRequest input": "Body cannot be null", ` +
1885
+ `whatever its body row holds. Write it with .http(id, { url, method, headers, parameters, body }) and no ` +
1886
+ `connection, which writes the V2 manual request (activityConfigurationVersion v2, the request in the body ` +
1887
+ `row as {"authentication":"manual",…}, through the implicit connection).`,
1888
+ where: n.id,
1889
+ });
1890
+ }
1874
1891
  const absoluteUrl = managedHttp ? managedHttpAbsoluteUrl(httpRequest) : undefined;
1875
1892
  if (absoluteUrl !== undefined) {
1876
1893
  diags.push({
@@ -293,6 +293,11 @@ let runLibrary;
293
293
  * header, so the omission is stated where the author reads the file.
294
294
  */
295
295
  let runUnmodelled = new Map();
296
+ /**
297
+ * The script tasks whose mapping type this run normalised to `BPMN.Variables`, by id:
298
+ * what each carried. Announced in the source header, like `runUnmodelled`.
299
+ */
300
+ let runScriptTypes = new Map();
296
301
  let runLiftPlans = new Map();
297
302
  let runLiftSkipped = [];
298
303
  let runLiftCalls = new Map();
@@ -1202,6 +1207,13 @@ function emitScriptTask(chain, el, payload, type) {
1202
1207
  // `Error`) while binding a differently-named variable, and the derived form
1203
1208
  // names it after the variable.
1204
1209
  const verbatim = outputRowsNeedSpellingOut(payload) ? emitOutputRows(payload) : undefined;
1210
+ // A script task's only mapping type is `BPMN.Variables`: any other replaces the
1211
+ // script's extension type, so the script never runs and its outputs read back null.
1212
+ // `.scriptTask()` refuses one (`BPMN_SCRIPT_TASK_TYPE_INVALID`), so the source writes
1213
+ // none and the recompile gets `BPMN.Variables` — repairing the task rather than
1214
+ // reproducing a defect `uip maestro bpmn validate` does not catch. The header says so.
1215
+ if (type !== undefined && type !== 'BPMN.Variables')
1216
+ runScriptTypes.set(el.id, `${el.id}: ${type}`);
1205
1217
  chain.add(`.scriptTask(${tsText(el.id)}, ${opts([
1206
1218
  ['name', el.name !== undefined ? tsText(el.name) : undefined],
1207
1219
  ['script', tsText(el.script ?? '')],
@@ -1210,15 +1222,8 @@ function emitScriptTask(chain, el, payload, type) {
1210
1222
  // runtime's result shape) and must survive the round trip. An absent element
1211
1223
  // is spelled `'v1'`, the meaning it has to the runtime.
1212
1224
  ['scriptVersion', scriptVersionOf(el) !== 'v3' ? tsText(scriptVersionOf(el)) : undefined],
1213
- // Only when it is neither the contract's value nor the invalid one this SDK
1214
- // used to emit. `BPMN.ScriptTask` is NORMALISED AWAY rather than preserved:
1215
- // the runtime contract has no such type, so reproducing it would propagate a
1216
- // defect `uip maestro bpmn validate` does not catch. Same call the round trip
1217
- // already makes for a bare `<uipath:input name="args">`.
1218
- [
1219
- 'type',
1220
- type !== undefined && type !== 'BPMN.Variables' && type !== 'BPMN.ScriptTask' ? tsText(type) : undefined,
1221
- ],
1225
+ // No `type`: every type but `BPMN.Variables` is NORMALISED AWAY (below), so the
1226
+ // source is one `.scriptTask()` accepts.
1222
1227
  ['inputSchema', schemaBody !== undefined && !schemaIsDefault ? jsonLiteral(schemaBody) : undefined],
1223
1228
  ['inputs', record(inputs)],
1224
1229
  ['outputs', verbatim ? undefined : record(outputs)],
@@ -2617,6 +2622,7 @@ export async function decompile(xml, options = {}) {
2617
2622
  // tasks come back as `.connector()`, whose declarations derive as a connector's.
2618
2623
  runLibrary = options.library;
2619
2624
  runUnmodelled = new Map();
2625
+ runScriptTypes = new Map();
2620
2626
  runLiftPlans = new Map();
2621
2627
  runLiftSkipped = [];
2622
2628
  runLiftCalls = new Map();
@@ -2688,13 +2694,22 @@ export async function decompile(xml, options = {}) {
2688
2694
  '\n'
2689
2695
  : '';
2690
2696
  runUnmodelled = new Map();
2697
+ const scriptTypeNote = runScriptTypes.size
2698
+ ? `// SCRIPT TASK TYPES NORMALISED. A script task's only mapping type is\n` +
2699
+ `// BPMN.Variables: any other replaces the script's extension type, so the script\n` +
2700
+ `// never runs and its outputs read back null. These tasks carried another type,\n` +
2701
+ `// and this source gives them BPMN.Variables (the .scriptTask() default):\n` +
2702
+ [...runScriptTypes.values()].map((d) => `// - ${commentText(d)}\n`).join('') +
2703
+ '\n'
2704
+ : '';
2705
+ runScriptTypes = new Map();
2691
2706
  const imports = `import { ${imported} } from ${tsText(importFrom)};\n\n`;
2692
2707
  const nameCall = process.name !== undefined ? `${indent}.name(${tsText(process.name)})` : undefined;
2693
2708
  options.onConnectorLift?.({
2694
2709
  lifted: [...runLiftPlans.keys()],
2695
2710
  verbatim: runLiftSkipped,
2696
2711
  preamble: {
2697
- prefix: `${host.note}${unmodelledNote}${imports}`,
2712
+ prefix: `${host.note}${unmodelledNote}${scriptTypeNote}${imports}`,
2698
2713
  head: `bpmn(${tsText(process.id)})`,
2699
2714
  calls: [...(nameCall !== undefined ? [nameCall] : []), ...chain.all.slice(0, preambleLines)],
2700
2715
  },
@@ -2710,7 +2725,7 @@ export async function decompile(xml, options = {}) {
2710
2725
  binding: 'processBuilder',
2711
2726
  indent,
2712
2727
  });
2713
- return `${host.note}${unmodelledNote}${imports}${body}\n`;
2728
+ return `${host.note}${unmodelledNote}${scriptTypeNote}${imports}${body}\n`;
2714
2729
  }
2715
2730
  /**
2716
2731
  * Variable ids the serializer creates on its own from a node's output rows.