@uipath/maestro-builder-sdk 6.79.0 → 6.80.0

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.
@@ -0,0 +1,371 @@
1
+ import { MANAGED_HTTP_CONNECTOR_KEY, MANAGED_HTTP_ENDPOINT, MANAGED_HTTP_ENDPOINT_METHOD, MANAGED_HTTP_OBJECT_NAME, } from '../core/managed-http.js';
2
+ import { taskOutputRefs } from './task-output-ref.js';
3
+ import metadata from './http-request-metadata.json' with { type: 'json' };
4
+ /**
5
+ * The Designer's `metadata` context entry body, copied byte for byte from
6
+ * UiPath/cli `packages/case-tool/src/services/sdd-convert/http-request-metadata.json`
7
+ * (last changed in 06c4c1d01f, 2026-10-15; read at b37f32997c). It is the
8
+ * activity's configuration as Studio Web saves it; Studio Web reads it to show
9
+ * the task, so it is copied rather than rebuilt. `case-http-request.test.ts`
10
+ * pins its hash, and its activity identity to `core/managed-http.ts`.
11
+ */
12
+ export const HTTP_REQUEST_METADATA = metadata;
13
+ export const HTTP_REQUEST_METADATA_PROVENANCE = {
14
+ repo: 'UiPath/cli',
15
+ path: 'packages/case-tool/src/services/sdd-convert/http-request-metadata.json',
16
+ commit: '06c4c1d01f1bcb0a196902aea0f9508d6cbf85f3',
17
+ sha256: 'b2a15368b204e5189d6aab1bfc1ea1db2a16e47710920025a43649f858388785',
18
+ };
19
+ export const HTTP_REQUEST_SERVICE_TYPE = 'Intsvc.UnifiedHttpRequest';
20
+ /** The plan's one binding a manual request names: no resource, so no `bindings_v2.json` entry. */
21
+ export const HTTP_REQUEST_IMPLICIT_CONNECTION = 'ImplicitConnection';
22
+ export const HTTP_REQUEST_IMPLICIT_BINDING_ID = 'bHttpImplicit';
23
+ export const HTTP_REQUEST_CONNECTION_NAME = `${MANAGED_HTTP_CONNECTOR_KEY} connection`;
24
+ /** The methods the activity offers. */
25
+ export const HTTP_REQUEST_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'];
26
+ /** The methods the activity sends a body with; it clears the body for the rest. */
27
+ const BODY_METHODS = new Set(['POST', 'PUT', 'PATCH']);
28
+ /**
29
+ * Headers that carry a credential. A header value is written into the plan as
30
+ * authored, and the plan is committed, packed and pulled, so a credential there
31
+ * has leaked. The GA skill's rule and grader use this list (`check_http_request_case.py`).
32
+ */
33
+ const CREDENTIAL_HEADERS = new Set(['authorization', 'proxy-authorization', 'cookie', 'x-api-key', 'api-key']);
34
+ /**
35
+ * Query parameter names that carry a credential, in lower case. The query is
36
+ * written into the plan with the request, so a key here ships like a header.
37
+ */
38
+ const CREDENTIAL_QUERY_KEYS = new Set([
39
+ 'api_key', 'apikey', 'api-key', 'access_token', 'token', 'key', 'secret', 'client_secret', 'password', 'sig', 'signature',
40
+ ]);
41
+ /** The activity's four outputs, in the order the Designer saves them: `[name, id base, source]`. */
42
+ export const HTTP_REQUEST_OUTPUTS = [
43
+ { name: 'code', base: 'code', displayName: 'Response status code', type: 'number', source: '=response.code' },
44
+ { name: 'headers', base: 'headers', displayName: 'Response headers', type: 'object', source: '=response.headers' },
45
+ { name: 'body', base: 'body', displayName: 'Response body', type: 'object', source: '=response.body' },
46
+ { name: 'Error', base: 'error', displayName: 'Error', type: 'jsonSchema', source: '=Error' },
47
+ ];
48
+ /** The `Error` output's schema, as the Designer and the CLI write it. */
49
+ const ERROR_SCHEMA = {
50
+ type: 'object',
51
+ properties: {
52
+ code: { type: 'string' }, message: { type: 'string' }, detail: { type: 'string' },
53
+ category: { type: 'string' }, status: { type: 'number' }, element: { type: 'string' },
54
+ },
55
+ };
56
+ const isObjectOfText = (value) => typeof value === 'object' && value !== null && !Array.isArray(value)
57
+ && Object.values(value).every((v) => typeof v === 'string');
58
+ /**
59
+ * Why compile cannot write `spec` as authored, or `undefined`: the request's
60
+ * `lowering` refusals (`docs/CHECK_COMPILE_CONTRACT_DESIGN.md` §3.1), each a
61
+ * case where the serializer would drop or rewrite what the source says.
62
+ * `serialize` throws it; `check` gets it through collect mode.
63
+ *
64
+ * @param owner - The task as messages name it, e.g. `HTTP request task "Fetch"`.
65
+ */
66
+ export function httpRequestRefusal(owner, spec) {
67
+ const connector = spec.connector;
68
+ if (connector !== undefined) {
69
+ // Nothing to bind the connection through.
70
+ const missing = ['key', 'connection', 'folder'].filter((k) => typeof connector[k] !== 'string' || !connector[k].trim());
71
+ if (missing.length)
72
+ return {
73
+ code: 'HTTP_REQUEST_CONNECTOR',
74
+ message: `${owner} reuses a connector's authentication but has no ${missing.join(', ')}.`,
75
+ suggestion: "Pass connector: { key: '<connector key>', connection: '<connection binding>', folder: '<folder binding>' }, or drop connector to call url directly.",
76
+ };
77
+ // A connector request is written with `path`, so a `url` would be dropped.
78
+ if (spec.url !== undefined)
79
+ return {
80
+ code: 'HTTP_REQUEST_TARGET',
81
+ message: `${owner} calls through a connector, which reads a path relative to the connector's base URL, so its url would be dropped.`,
82
+ suggestion: `Write the address as path (for example path: '/rest/api/3/myself'), or drop connector to call url directly.`,
83
+ };
84
+ }
85
+ else if (spec.path !== undefined) {
86
+ // A request without a connector is written with `url`, so a `path` would be dropped.
87
+ return {
88
+ code: 'HTTP_REQUEST_TARGET',
89
+ message: `${owner} has path, which only a connector request reads, so it would be dropped; a request without a connector calls url.`,
90
+ suggestion: 'Put the full address in url, or add connector: { key, connection, folder }.',
91
+ };
92
+ }
93
+ // Written by spreading the object, which would scramble anything but an object of text.
94
+ for (const [field, value] of [['headers', spec.headers], ['query', spec.query]])
95
+ if (value !== undefined && !isObjectOfText(value))
96
+ return { code: 'HTTP_REQUEST_FIELD', message: `${owner} ${field} must be an object of text values.` };
97
+ // Text that is neither JSON nor an expression would be wrapped as `=js:( … )`,
98
+ // which the activity evaluates: compile would turn the author's text into code.
99
+ if (typeof spec.body === 'string' && !spec.body.startsWith('=') && !parsesAsJson(spec.body))
100
+ return {
101
+ code: 'HTTP_REQUEST_BODY_FORM',
102
+ message: `${owner} body is neither JSON nor an \`=\` expression. The activity evaluates its body as JavaScript, so the text would be written as code.`,
103
+ suggestion: 'Pass the body as an object, JSON text, or an expression such as `=js:vars.payload`.',
104
+ };
105
+ if (spec.body !== undefined && typeof spec.body !== 'string') {
106
+ const leaf = unlowerableLeaf(spec.body);
107
+ if (leaf !== undefined)
108
+ return {
109
+ code: 'HTTP_REQUEST_BODY_EXPRESSION',
110
+ message: `${owner} body has the value ${JSON.stringify(leaf)}, an \`=\` expression compile cannot write as a JavaScript value inside the body.`,
111
+ suggestion: "Write the value as `=js:<expression>` (for example '=js:vars.amount * 2'), as a reference (`=vars.amount`), "
112
+ + "or as another task's output (`=${taskOutput('Stage', 'Task', 'body')}`).",
113
+ };
114
+ }
115
+ return undefined;
116
+ }
117
+ const parsesAsJson = (text) => {
118
+ try {
119
+ JSON.parse(text);
120
+ return true;
121
+ }
122
+ catch {
123
+ return false;
124
+ }
125
+ };
126
+ /** A dotted reference such as `vars.customer.id`: JavaScript as written. */
127
+ const REFERENCE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
128
+ /** Property reads after a reference: `.field.sub`. */
129
+ const DOTTED_TAIL = /^(?:\.[A-Za-z_$][\w$]*)*$/;
130
+ /**
131
+ * Whether `text` is exactly one `taskOutput()` marker (`vars.$xref('S','T','body')`),
132
+ * optionally followed by property reads. It is a reference once lowered: the
133
+ * whole plan's markers are lowered to `vars.<output id>` after the body is
134
+ * written (`lowerPlanTaskOutputRefs` in `serialize.ts`), so the activity never
135
+ * sees `$xref`.
136
+ */
137
+ function isTaskOutputReference(text) {
138
+ const refs = taskOutputRefs(text);
139
+ return refs.length === 1 && refs[0].index === 0 && DOTTED_TAIL.test(text.slice(refs[0].whole.length));
140
+ }
141
+ /**
142
+ * The JavaScript an `=` leaf of an object body stands for: `=js:<code>` is the
143
+ * code, parenthesized; `=<reference>` is the reference, a `taskOutput()`
144
+ * marker included. `undefined` for any other `=` text, which compile refuses
145
+ * (`HTTP_REQUEST_BODY_EXPRESSION`).
146
+ */
147
+ function leafCode(value) {
148
+ if (value.startsWith('=js:')) {
149
+ const code = value.slice('=js:'.length).trim();
150
+ return code === '' ? undefined : `(${code})`;
151
+ }
152
+ const reference = value.slice(1).trim();
153
+ return REFERENCE.test(reference) || isTaskOutputReference(reference) ? reference : undefined;
154
+ }
155
+ const isExpressionLeaf = (value) => typeof value === 'string' && value.startsWith('=');
156
+ const childrenOf = (value) => Array.isArray(value) ? value : typeof value === 'object' && value !== null ? Object.values(value) : [];
157
+ function hasExpressionLeaf(value) {
158
+ return isExpressionLeaf(value) || childrenOf(value).some(hasExpressionLeaf);
159
+ }
160
+ /** The first `=` leaf compile cannot lower, or `undefined`. */
161
+ function unlowerableLeaf(value) {
162
+ if (isExpressionLeaf(value))
163
+ return leafCode(value) === undefined ? value : undefined;
164
+ for (const child of childrenOf(value)) {
165
+ const found = unlowerableLeaf(child);
166
+ if (found !== undefined)
167
+ return found;
168
+ }
169
+ return undefined;
170
+ }
171
+ /**
172
+ * An object body as the JavaScript literal the activity evaluates. Without an
173
+ * `=` leaf it is exactly `JSON.stringify`. An `=` leaf is written as the code it
174
+ * stands for (`{"probe":vars.id}`), so the request carries the value, not the
175
+ * expression's text. Keys are JSON-quoted; `__proto__` is computed, because a
176
+ * plain `"__proto__":` key would set the prototype instead of a field.
177
+ */
178
+ function bodyLiteral(value) {
179
+ if (!hasExpressionLeaf(value))
180
+ return JSON.stringify(value);
181
+ if (isExpressionLeaf(value)) {
182
+ const code = leafCode(value);
183
+ if (code === undefined)
184
+ throw new Error(`internal SDK error: body value ${JSON.stringify(value)} reached the writer unrefused`);
185
+ return code;
186
+ }
187
+ if (Array.isArray(value))
188
+ return `[${value.map((item) => (item === undefined ? 'null' : bodyLiteral(item))).join(',')}]`;
189
+ const entries = Object.entries(value).filter(([, item]) => item !== undefined);
190
+ return `{${entries.map(([key, item]) => `${key === '__proto__' ? '["__proto__"]' : JSON.stringify(key)}:${bodyLiteral(item)}`).join(',')}}`;
191
+ }
192
+ /**
193
+ * What `check` says about a request compile writes as authored: the `lint`
194
+ * findings (§3.1), each an error a person should fix and `compile` does not
195
+ * look for.
196
+ *
197
+ * @param owner - The task as messages name it, e.g. `HTTP request task "Fetch"`.
198
+ */
199
+ export function httpRequestLint(owner, spec) {
200
+ const found = [];
201
+ if (!HTTP_REQUEST_METHODS.includes(spec.method))
202
+ found.push({ code: 'HTTP_REQUEST_METHOD', message: `${owner} has method ${JSON.stringify(spec.method)}; the activity offers ${HTTP_REQUEST_METHODS.join(', ')}.` });
203
+ if (spec.connector === undefined && (typeof spec.url !== 'string' || !spec.url.trim()))
204
+ found.push({
205
+ code: 'HTTP_REQUEST_NO_URL',
206
+ message: `${owner} names no connector, so it calls url directly, and has none.`,
207
+ suggestion: "Pass url (for example url: 'https://api.example.com/items'), or connector: { key, connection, folder } with a path.",
208
+ });
209
+ // A literal value is the secret itself, written into the plan; an `=` value is read at run time.
210
+ const literalCredential = (fields, names) => Object.entries(isObjectOfText(fields) ? fields : {}).find(([k, v]) => names.has(k.toLowerCase()) && !v.startsWith('='))?.[0];
211
+ const credentials = [
212
+ ['header', literalCredential(spec.headers, CREDENTIAL_HEADERS)],
213
+ ['query parameter', literalCredential(spec.query, CREDENTIAL_QUERY_KEYS)],
214
+ ];
215
+ for (const [where, name] of credentials)
216
+ if (name !== undefined)
217
+ found.push({
218
+ code: 'HTTP_REQUEST_CREDENTIAL_HEADER',
219
+ message: `${owner} sends a "${name}" ${where}. Its value is written into the case plan as authored, so the credential `
220
+ + 'ships in caseplan.case and in every pull and package of it.',
221
+ suggestion: 'Authenticate through a connection instead: connector: { key, connection, folder } reuses that connector\'s stored credential.',
222
+ });
223
+ if (spec.body !== undefined && !BODY_METHODS.has(spec.method))
224
+ found.push({
225
+ code: 'HTTP_REQUEST_BODY_METHOD',
226
+ message: `${owner} sends a body with ${spec.method}, which the activity sends without one: it clears the body.`,
227
+ suggestion: 'Use POST, PUT or PATCH to send a body, or drop body.',
228
+ });
229
+ return found;
230
+ }
231
+ /**
232
+ * The request as the activity reads it from the `body` input, in the CLI's key
233
+ * order. A literal body is wrapped the way the Designer's editor wraps one,
234
+ * `=js:( … )`, with `requestBodyType: "raw"` in manual mode; an object body's
235
+ * `=` values are written as the JavaScript they stand for ({@link bodyLiteral});
236
+ * an expression body is kept as written.
237
+ */
238
+ export function httpRequestBody(spec) {
239
+ const body = { authentication: spec.connector ? 'connector' : 'manual' };
240
+ if (spec.connector)
241
+ body.targetConnector = spec.connector.key;
242
+ body.method = spec.method;
243
+ if (spec.connector && spec.path !== undefined)
244
+ body.path = spec.path;
245
+ if (!spec.connector && spec.url !== undefined)
246
+ body.url = spec.url;
247
+ if (spec.headers !== undefined)
248
+ body.headers = { ...spec.headers };
249
+ if (spec.query !== undefined)
250
+ body.query = { ...spec.query };
251
+ if (spec.body !== undefined) {
252
+ if (!spec.connector)
253
+ body.requestBodyType = 'raw';
254
+ const text = typeof spec.body === 'string' ? spec.body : bodyLiteral(spec.body);
255
+ body.body = text.startsWith('=') ? text : `=js:( ${text})`;
256
+ }
257
+ return body;
258
+ }
259
+ /**
260
+ * The body as source writes it: the JSON text a `=js:( … )` body wraps, or the
261
+ * value itself, which compile writes as it stands, when it is an expression or
262
+ * wraps something other than JSON (an object body whose `=` values were
263
+ * written as JavaScript).
264
+ */
265
+ export function httpRequestBodySource(value) {
266
+ const wrapped = /^=js:\( ([\s\S]*)\)$/.exec(value);
267
+ return wrapped && parsesAsJson(wrapped[1]) ? wrapped[1] : value;
268
+ }
269
+ /**
270
+ * Which of the activity's outputs an `.outputs()` row writes to a case
271
+ * variable: its `source` must be one of the four, once each.
272
+ */
273
+ export function httpRequestOutputMappings(owner, outputs) {
274
+ const bySource = new Map();
275
+ for (const o of outputs ?? []) {
276
+ // A custom `{ assign }` row reads no result: it is written beside the four, as on every kind.
277
+ if (o.custom)
278
+ continue;
279
+ const known = HTTP_REQUEST_OUTPUTS.find((row) => row.source === o.source);
280
+ if (known === undefined)
281
+ return {
282
+ code: 'HTTP_REQUEST_OUTPUT',
283
+ message: `${owner} output "${o.var}" reads ${JSON.stringify(o.source)}; an HTTP request has the activity's outputs only: `
284
+ + `${HTTP_REQUEST_OUTPUTS.map((row) => row.source).join(', ')}.`,
285
+ suggestion: 'Map one of those to a case variable, for example .outputs({ reply: \'=response.body\' }), and read a field of the body as reply.<field>.',
286
+ };
287
+ if (bySource.has(o.source))
288
+ return { code: 'HTTP_REQUEST_OUTPUT', message: `${owner} writes ${o.source} to two variables, "${bySource.get(o.source)}" and "${o.var}".` };
289
+ bySource.set(o.source, o.var);
290
+ }
291
+ return bySource;
292
+ }
293
+ /**
294
+ * The task's four output rows. `claim` gives each a document-unique id (the
295
+ * Designer's `code`, `code2`, … rule); a mapped output writes the case variable
296
+ * the author named instead, keeping its own id as `originalVar`, as the CLI does
297
+ * for an arrow row (`Body -> payload`).
298
+ */
299
+ export function httpRequestOutputs(elementId, claim, mappings) {
300
+ return HTTP_REQUEST_OUTPUTS.map((row) => {
301
+ const id = claim(row.base);
302
+ const variable = mappings.get(row.source);
303
+ const out = {
304
+ name: row.name, displayName: row.displayName, type: row.type, source: row.source,
305
+ ...(row.name === 'Error' ? { _jsonSchema: structuredClone(ERROR_SCHEMA) } : {}),
306
+ id, var: variable ?? id, value: variable ?? id, elementId,
307
+ ...(row.name === 'Error' ? { body: structuredClone(ERROR_SCHEMA) } : {}),
308
+ };
309
+ if (variable !== undefined) {
310
+ out.target = `=${id}`;
311
+ out.originalVar = id;
312
+ }
313
+ return out;
314
+ });
315
+ }
316
+ /** A container input, with the `v` id the Designer writes (minted by the caller). */
317
+ export function httpRequestInputs(elementId, mint, request) {
318
+ return ['pathParameters', 'queryParameters', 'body'].map((name) => {
319
+ const id = mint(name);
320
+ return { name, type: 'json', target: name, id, var: id, elementId, ...(name === 'body' ? { body: request } : {}) };
321
+ });
322
+ }
323
+ /** The context rows, in the Designer's order; `connection` is a binding reference. */
324
+ export function httpRequestContext(connection, resourceKey, folderKey) {
325
+ const row = (name, value) => ({ name, value, type: 'string' });
326
+ return [
327
+ row('connectorKey', MANAGED_HTTP_CONNECTOR_KEY),
328
+ row('connection', connection),
329
+ row('resourceKey', resourceKey),
330
+ row('folderKey', folderKey),
331
+ row('method', MANAGED_HTTP_ENDPOINT_METHOD),
332
+ row('path', MANAGED_HTTP_ENDPOINT),
333
+ row('objectName', MANAGED_HTTP_OBJECT_NAME),
334
+ { name: 'metadata', type: 'json', body: structuredClone(HTTP_REQUEST_METADATA) },
335
+ row('activityConfigurationVersion', 'v2'),
336
+ ];
337
+ }
338
+ /** A task `data`'s `metadata` context row, or undefined. */
339
+ const metadataRow = (data) => {
340
+ const context = data?.context;
341
+ return Array.isArray(context)
342
+ ? context.find((row) => row?.name === 'metadata' && row?.type === 'json')
343
+ : undefined;
344
+ };
345
+ /**
346
+ * The `metadata` body a saved http-request task carries when it is not the
347
+ * vendored copy compile writes (a Designer save from another connector
348
+ * version), or undefined. Decompile preserves it, so a round trip keeps the
349
+ * version the Designer saved instead of writing `HTTP_REQUEST_METADATA`.
350
+ */
351
+ export function savedHttpRequestMetadata(data) {
352
+ const body = metadataRow(data)?.body;
353
+ if (typeof body !== 'object' || body === null || Array.isArray(body))
354
+ return undefined;
355
+ return JSON.stringify(body) === JSON.stringify(HTTP_REQUEST_METADATA) ? undefined : body;
356
+ }
357
+ /**
358
+ * Write a preserved `metadata` body over the one compile wrote. False when
359
+ * `data` has no `metadata` row (the task is no longer an http-request task).
360
+ */
361
+ export function writeHttpRequestMetadata(data, metadata) {
362
+ const row = metadataRow(data);
363
+ if (!row)
364
+ return false;
365
+ row.body = structuredClone(metadata);
366
+ return true;
367
+ }
368
+ /** The context row names, in order: decompile lifts exactly these. */
369
+ export const HTTP_REQUEST_CONTEXT = [
370
+ 'connectorKey', 'connection', 'resourceKey', 'folderKey', 'method', 'path', 'objectName', 'metadata', 'activityConfigurationVersion',
371
+ ];
@@ -87,6 +87,11 @@ export interface PreservedConnectorConfiguration extends PreservedTaskRef {
87
87
  */
88
88
  cachedFieldValues?: Record<string, unknown>;
89
89
  }
90
+ /** An HTTP request task's saved `metadata` context body, verbatim. */
91
+ export interface PreservedHttpRequestMetadata extends PreservedTaskRef {
92
+ /** The body as the Designer saved it. */
93
+ metadata: Record<string, unknown>;
94
+ }
90
95
  /**
91
96
  * The stage `data` fields the Case Designer owns: canvas nesting state and the
92
97
  * primary-stage marker. None changes what the case does (the platform's
@@ -321,6 +326,12 @@ export interface CaseJsonPreservation {
321
326
  taskFields?: PreservedTaskFields[];
322
327
  /** Designer-saved connector `optionalConfiguration`s, by task. */
323
328
  connectorConfigurations?: PreservedConnectorConfiguration[];
329
+ /**
330
+ * HTTP request tasks' Designer-saved `metadata` bodies, where they differ from
331
+ * the vendored copy compile writes (`HTTP_REQUEST_METADATA`), so a save from
332
+ * another connector version is written back instead of downgraded.
333
+ */
334
+ httpRequestMetadata?: PreservedHttpRequestMetadata[];
324
335
  /**
325
336
  * Action tasks' Designer-owned `data` fields: the `context` rows the Designer
326
337
  * saves with a form (its `hitlType`, quick-form schema ids, and a copy of the
@@ -385,6 +385,12 @@ export function caseJsonPreservationErrors(payload) {
385
385
  && (!entry.cachedFieldValues || typeof entry.cachedFieldValues !== 'object' || Array.isArray(entry.cachedFieldValues)))
386
386
  errors.push(`preserved connector configuration of task "${entry.task}" has cachedFieldValues that is not an object`);
387
387
  }
388
+ for (const entry of payload.httpRequestMetadata ?? []) {
389
+ if (!Number.isInteger(entry?.lane) || entry.lane < 0)
390
+ errors.push(`preserved http-request metadata lane "${entry?.lane}" is not a non-negative integer`);
391
+ if (!entry?.metadata || typeof entry.metadata !== 'object' || Array.isArray(entry.metadata))
392
+ errors.push(`preserved http-request metadata of task "${entry?.task}" must be an object`);
393
+ }
388
394
  for (const index of payload.manualTriggerServiceTypeNone ?? [])
389
395
  if (!Number.isInteger(index) || index < 0)
390
396
  errors.push(`manual trigger position "${index}" is not a non-negative integer`);
@@ -38,6 +38,7 @@ import { CompileRefusal } from '../core/compile-refusal.js';
38
38
  import { implicitInArgBuiltTrigger, unboundInArgMessage } from './in-arg-binding.js';
39
39
  import { jsonClone } from '../core/json-clone.js';
40
40
  import { taskShapeProblems } from './task-shape.js';
41
+ import { HTTP_REQUEST_CONNECTION_NAME, HTTP_REQUEST_IMPLICIT_BINDING_ID, HTTP_REQUEST_IMPLICIT_CONNECTION, HTTP_REQUEST_SERVICE_TYPE, httpRequestBody, httpRequestContext, httpRequestInputs, httpRequestOutputMappings, httpRequestOutputs, httpRequestRefusal, writeHttpRequestMetadata, } from './http-request.js';
41
42
  import { connectorPlaceholderData, isConnectorPlaceholder } from './connector-placeholder.js';
42
43
  import { lowerTaskOutputRefs, planTaskOutputs, resolveInPlan, unresolvedTaskOutputRef } from './task-output-ref.js';
43
44
  /** The ids a serialize pass hashed from element ids, by the document it returned. */
@@ -215,6 +216,7 @@ function serializeCase(built, opts) {
215
216
  ownNameRows: new Map(),
216
217
  outputIds: new Set(),
217
218
  ownOutputVars: ownOutputVars(built),
219
+ caseVarNames: new Set([...built.vars.map((v) => v.name), ...mappedFixedOutputVars(built)]),
218
220
  slaId: new Map(),
219
221
  slaIdByName: new Map(),
220
222
  escalationId: new Map(),
@@ -709,6 +711,16 @@ export function applyPreservation(result, preservation, options = {}) {
709
711
  if (written === 'different' && !options.overwrite)
710
712
  throw new CompileRefusal('PRESERVATION_FIELD_COLLISION', `preserved connector configuration of task "${entry.stage}/${entry.task}" collides with serializer-owned output.`);
711
713
  }
714
+ for (const entry of preservation.httpRequestMetadata ?? []) {
715
+ const stage = stageNodes.find((candidate) => candidate.data?.label === entry.stage);
716
+ const task = stageTask(stage, entry.task);
717
+ // A deleted task, or one the edit made another kind, gets nothing: the
718
+ // saved metadata describes the HTTP request activity only. The vendored
719
+ // copy compile wrote is not authored, so replacing it is no collision.
720
+ if (!task || task.type !== 'http-request')
721
+ continue;
722
+ writeHttpRequestMetadata(task.data, entry.metadata);
723
+ }
712
724
  for (const entry of preservation.actionDataFields ?? []) {
713
725
  const stage = stageNodes.find((candidate) => candidate.data?.label === entry.stage);
714
726
  const task = stageTask(stage, entry.task);
@@ -1098,6 +1110,7 @@ export function followRenames(result, preservation) {
1098
1110
  },
1099
1111
  ...(preservation.taskFields ? { taskFields: preservation.taskFields.map(ref) } : {}),
1100
1112
  ...(preservation.connectorConfigurations ? { connectorConfigurations: preservation.connectorConfigurations.map(ref) } : {}),
1113
+ ...(preservation.httpRequestMetadata ? { httpRequestMetadata: preservation.httpRequestMetadata.map(ref) } : {}),
1101
1114
  ...(preservation.actionDataFields ? { actionDataFields: preservation.actionDataFields.map(ref) } : {}),
1102
1115
  ...(preservation.omitTaskElementIds ? { omitTaskElementIds: preservation.omitTaskElementIds.map(ref) } : {}),
1103
1116
  ...(preservation.omitStagePositions ? { omitStagePositions: preservation.omitStagePositions.map(stageName) } : {}),
@@ -2051,6 +2064,9 @@ function taskData(task, resolver, taskId, stageId, ids) {
2051
2064
  : {};
2052
2065
  return withCustomOutputs(data, task, resolver);
2053
2066
  }
2067
+ case 'http-request':
2068
+ // Only `{ assign }` rows are written beside the four: a mapped row is one of them.
2069
+ return withCustomOutputs(httpRequestTaskData(task, resolver, `${stageId}-${taskId}`), { ...task, outputs: task.outputs?.filter((o) => o.custom) }, resolver);
2054
2070
  case 'wait-for-connector':
2055
2071
  // A placeholder returned `{}` above; naming the connector/operation emits
2056
2072
  // the `context` subscription, and a resolved one the full bag.
@@ -2717,6 +2733,77 @@ function externalTaskData(kind, spec, resolver, elementId, where) {
2717
2733
  context.push(io('activityConfigurationVersion', 'string', { value: 'v2' }));
2718
2734
  return { ...data, serviceType: externalServiceType(kind, mode) };
2719
2735
  }
2736
+ /**
2737
+ * An HTTP request task (`case/http-request.ts`): the generic HTTP connector's
2738
+ * activity, with the request in the `body` input. A manual request names the
2739
+ * plan's one `ImplicitConnection` binding; a connector request binds the
2740
+ * connection and its folder the way a connector task does (`bindingRef`,
2741
+ * `folderBindingRef`), and carries those two rows on the task too, as the
2742
+ * Designer saves it.
2743
+ */
2744
+ function httpRequestTaskData(task, resolver, elementId) {
2745
+ const where = `HTTP request task "${task.name}"`;
2746
+ const spec = task.http;
2747
+ if (!spec)
2748
+ throw new Error(`internal SDK error: ${where} has no request.`);
2749
+ const refused = httpRequestRefusal(where, spec);
2750
+ if (refused)
2751
+ throw new CompileRefusal(refused.code, refused.message, refused.suggestion);
2752
+ const mappings = httpRequestOutputMappings(where, task.outputs);
2753
+ if (!(mappings instanceof Map))
2754
+ throw new CompileRefusal(mappings.code, mappings.message, mappings.suggestion);
2755
+ // A mapped output writes a case variable the source may not declare. Its row
2756
+ // is reassigned (`var` is not its id), so like a connector extract's it needs
2757
+ // a root entry for `=vars.<name>` to read; a declared `.var()` wins the name.
2758
+ for (const variable of mappings.values())
2759
+ if (!resolver.varCompanions.has(variable))
2760
+ resolver.varCompanions.set(variable, { id: variable, name: variable, type: 'object', elementId: 'root', custom: true });
2761
+ let connection;
2762
+ let resourceKey = null;
2763
+ let folderKey = null;
2764
+ const bindings = [];
2765
+ if (spec.connector) {
2766
+ const target = { key: spec.connector.key };
2767
+ refuseBindingLabels(resolver, spec.connector, { where, target });
2768
+ const connRef = bindingRef(resolver, spec.connector.connection, 'Connection', 'ConnectionId', HTTP_REQUEST_CONNECTION_NAME, { attribute: 'connection', where, target });
2769
+ const folderRef = folderBindingRef(resolver, spec.connector.folder, connRef, { attribute: 'folder', where, target });
2770
+ if (!connRef || !folderRef)
2771
+ throw new Error(`internal SDK error: ${where} bound no connection or folder.`);
2772
+ connection = `=bindings.${connRef.id}`;
2773
+ resourceKey = connRef.resourceKey;
2774
+ folderKey = `=bindings.${folderRef.id}`;
2775
+ for (const id of [connRef.id, folderRef.id])
2776
+ bindings.push(jsonClone(resolver.bindingSink.get(id)));
2777
+ }
2778
+ else {
2779
+ if (!resolver.bindingSink.has(HTTP_REQUEST_IMPLICIT_BINDING_ID))
2780
+ resolver.bindingSink.set(HTTP_REQUEST_IMPLICIT_BINDING_ID, {
2781
+ id: HTTP_REQUEST_IMPLICIT_BINDING_ID,
2782
+ name: HTTP_REQUEST_CONNECTION_NAME,
2783
+ type: 'string',
2784
+ resource: 'Connection',
2785
+ resourceKey: HTTP_REQUEST_IMPLICIT_CONNECTION,
2786
+ default: HTTP_REQUEST_IMPLICIT_CONNECTION,
2787
+ propertyAttribute: 'ConnectionId',
2788
+ });
2789
+ connection = `=bindings.${HTTP_REQUEST_IMPLICIT_BINDING_ID}`;
2790
+ }
2791
+ return {
2792
+ serviceType: HTTP_REQUEST_SERVICE_TYPE,
2793
+ // The container ids follow `ioSlot`, every connector task's.
2794
+ inputs: httpRequestInputs(elementId, (name) => `v${name}`, httpRequestBody(spec)),
2795
+ // An output's `var` is its id, so an id a case variable has would point the
2796
+ // response at that variable: `code`, `code2`, … skip them, as convert does.
2797
+ outputs: httpRequestOutputs(elementId, (base) => {
2798
+ let id = claimOutputId(resolver, base);
2799
+ while (resolver.caseVarNames.has(id))
2800
+ id = claimOutputId(resolver, base);
2801
+ return id;
2802
+ }, mappings),
2803
+ context: httpRequestContext(connection, resourceKey, folderKey),
2804
+ bindings,
2805
+ };
2806
+ }
2720
2807
  /** A context/output name/value entry (the caseplan `InputOutput` shape). */
2721
2808
  function io(name, type, extra) {
2722
2809
  return { name, type, ...extra };
@@ -3028,6 +3115,24 @@ function isOwnNameOutput(o) {
3028
3115
  * outputs and action form outputs (whose row id is the variable). Collected
3029
3116
  * before any row is emitted, so `claimOutputId` can keep suffixes off them.
3030
3117
  */
3118
+ /**
3119
+ * The case variables a fixed-output task's `.outputs()` maps (an HTTP
3120
+ * request's), declared or not. Collected before any task is emitted, so no
3121
+ * task's own output row takes one of them as its id, whatever the task order:
3122
+ * an undeclared one gets a root companion, and a row id equal to it would make
3123
+ * two writers of one variable, or read back as unmapped.
3124
+ */
3125
+ function mappedFixedOutputVars(built) {
3126
+ const vars = new Set();
3127
+ for (const stage of built.stages)
3128
+ for (const lane of stage.lanes)
3129
+ for (const task of lane)
3130
+ if (task.kind === 'http-request')
3131
+ for (const o of task.outputs ?? [])
3132
+ if (!o.custom)
3133
+ vars.add(o.var);
3134
+ return vars;
3135
+ }
3031
3136
  function ownOutputVars(built) {
3032
3137
  const vars = new Set();
3033
3138
  for (const stage of built.stages)
@@ -160,6 +160,16 @@ export declare const REFUSALS: {
160
160
  readonly CASE_IN_ARG_UNBOUND: "lowering";
161
161
  readonly CASE_LAYOUT_NODE_MATCH: "lowering";
162
162
  readonly CASE_LAYOUT_UNKNOWN_FIELD: "lowering";
163
+ readonly HTTP_REQUEST_CONNECTOR: "lowering";
164
+ readonly HTTP_REQUEST_TARGET: "lowering";
165
+ readonly HTTP_REQUEST_FIELD: "lowering";
166
+ readonly HTTP_REQUEST_OUTPUT: "lowering";
167
+ readonly HTTP_REQUEST_BODY_FORM: "lowering";
168
+ readonly HTTP_REQUEST_BODY_EXPRESSION: "lowering";
169
+ readonly HTTP_REQUEST_METHOD: "lint";
170
+ readonly HTTP_REQUEST_NO_URL: "lint";
171
+ readonly HTTP_REQUEST_CREDENTIAL_HEADER: "lint";
172
+ readonly HTTP_REQUEST_BODY_METHOD: "lint";
163
173
  readonly RULE_SELECTS_ADHOC_TASK: "lint";
164
174
  readonly SELECTED_STAGE_EXITED_NO_EXIT: "lint";
165
175
  readonly SLA_RESPONSE_REENTERS_STAGE: "lint";
@@ -281,6 +291,7 @@ export declare const REFUSALS: {
281
291
  readonly ERROR_READ_VIA_OUT: "lint";
282
292
  readonly ERROR_START_OUTSIDE_EVENT_SUBPROCESS: "lint";
283
293
  readonly ESCALATION_NO_RECIPIENTS: "lint";
294
+ readonly ESCALATION_RECIPIENT_UNRESOLVED: "lint";
284
295
  readonly ESCALATION_ZERO_ATRISK_PCT: "lint";
285
296
  readonly EVENT_BYOA_UNVERIFIED: "lowering";
286
297
  readonly EVENT_FILTERS_NOT_ARRAY: "lowering";
@@ -209,6 +209,19 @@ export const REFUSALS = {
209
209
  CASE_IN_ARG_UNBOUND: 'lowering',
210
210
  CASE_LAYOUT_NODE_MATCH: 'lowering',
211
211
  CASE_LAYOUT_UNKNOWN_FIELD: 'lowering',
212
+ // Case http-request task (case/http-request.ts). `lowering`: compile would
213
+ // drop or rewrite what the source says. `lint`: compile writes it as
214
+ // authored, and only `check` reports it.
215
+ HTTP_REQUEST_CONNECTOR: 'lowering',
216
+ HTTP_REQUEST_TARGET: 'lowering',
217
+ HTTP_REQUEST_FIELD: 'lowering',
218
+ HTTP_REQUEST_OUTPUT: 'lowering',
219
+ HTTP_REQUEST_BODY_FORM: 'lowering',
220
+ HTTP_REQUEST_BODY_EXPRESSION: 'lowering',
221
+ HTTP_REQUEST_METHOD: 'lint',
222
+ HTTP_REQUEST_NO_URL: 'lint',
223
+ HTTP_REQUEST_CREDENTIAL_HEADER: 'lint',
224
+ HTTP_REQUEST_BODY_METHOD: 'lint',
212
225
  // Case check: what a condition's references mean (case/check-rule-semantics.ts).
213
226
  RULE_SELECTS_ADHOC_TASK: 'lint',
214
227
  SELECTED_STAGE_EXITED_NO_EXIT: 'lint',
@@ -340,6 +353,7 @@ export const REFUSALS = {
340
353
  ERROR_READ_VIA_OUT: 'lint',
341
354
  ERROR_START_OUTSIDE_EVENT_SUBPROCESS: 'lint',
342
355
  ESCALATION_NO_RECIPIENTS: 'lint',
356
+ ESCALATION_RECIPIENT_UNRESOLVED: 'lint',
343
357
  ESCALATION_ZERO_ATRISK_PCT: 'lint',
344
358
  EVENT_BYOA_UNVERIFIED: 'lowering',
345
359
  EVENT_FILTERS_NOT_ARRAY: 'lowering',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.79.0",
3
+ "version": "6.80.0",
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": "17e7d1e2255264246d52aa2d9dbc1cdcf86df8a0"
106
+ "gitref": "42acd5e20650a9c9102e87297a3754b766b0c4ca"
107
107
  }