@uipath/maestro-builder-sdk 6.122.0 → 6.122.2

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.
@@ -593,12 +593,13 @@ export interface CaseHttpRequestSpec {
593
593
  */
594
594
  query?: Record<string, string>;
595
595
  /**
596
- * The request body, for POST, PUT or PATCH: an object, JSON text, or an `=`
597
- * expression (`=js:vars.payload`). In an object, a value `=js:<expression>`
598
- * or `=<reference>` (`=vars.id`) is sent as the value it reads.
596
+ * The request body, for POST, PUT or PATCH: an object, JSON text, a
597
+ * `taskOutput()` (read at run time), or an `=` expression (`=js:vars.payload`).
598
+ * In an object, a value `=js:<expression>`, `=<reference>` (`=vars.id`) or
599
+ * `taskOutput()` is sent as the value it reads.
599
600
  *
600
601
  * @enforcedBy HTTP_REQUEST_BODY_METHOD `check` reports a body on another method.
601
- * @enforcedBy HTTP_REQUEST_BODY_FORM compile refuses text that is neither JSON nor an expression.
602
+ * @enforcedBy HTTP_REQUEST_BODY_FORM compile refuses text that is neither JSON, a `taskOutput()`, nor an expression.
602
603
  * @enforcedBy HTTP_REQUEST_BODY_EXPRESSION compile refuses an object value that is another kind of `=` expression.
603
604
  */
604
605
  body?: string | Record<string, unknown> | unknown[];
@@ -1743,9 +1744,10 @@ declare class TaskBuilder {
1743
1744
  * Designer's suffixed key: `Result2: '=Result'` is its own bare output. This
1744
1745
  * is the output an SDD lists with no `->` arrow. Read it elsewhere with
1745
1746
  * {@link taskOutput | taskOutput('<stage>', '<task>', '<output>')} (or the
1746
- * SDD's `$xref` marker copied as written), which compiles to `vars.<id>`
1747
- * of that output, so a plan built from an SDD needs no case variable the SDD
1748
- * does not declare.
1747
+ * SDD's `$xref` marker copied as written), which compiles to `=vars.<id>`
1748
+ * of that output as a whole value (`=js:vars.<id>?.field` with property
1749
+ * reads; `vars.<id>` inside an expression), so a plan built from an SDD needs
1750
+ * no case variable the SDD does not declare.
1749
1751
  *
1750
1752
  * Pass `{ assign, type }` for a **custom** output: the SDD's `x = expr` row.
1751
1753
  * When the task completes, the case variable is set to `assign` — a literal,
@@ -786,9 +786,10 @@ class TaskBuilder {
786
786
  * Designer's suffixed key: `Result2: '=Result'` is its own bare output. This
787
787
  * is the output an SDD lists with no `->` arrow. Read it elsewhere with
788
788
  * {@link taskOutput | taskOutput('<stage>', '<task>', '<output>')} (or the
789
- * SDD's `$xref` marker copied as written), which compiles to `vars.<id>`
790
- * of that output, so a plan built from an SDD needs no case variable the SDD
791
- * does not declare.
789
+ * SDD's `$xref` marker copied as written), which compiles to `=vars.<id>`
790
+ * of that output as a whole value (`=js:vars.<id>?.field` with property
791
+ * reads; `vars.<id>` inside an expression), so a plan built from an SDD needs
792
+ * no case variable the SDD does not declare.
792
793
  *
793
794
  * Pass `{ assign, type }` for a **custom** output: the SDD's `x = expr` row.
794
795
  * When the task completes, the case variable is set to `assign` — a literal,
@@ -713,17 +713,18 @@ function checkStage(stage, diags, refStage, refPlacement) {
713
713
  if (o.custom)
714
714
  continue; // an assigned value, not a result field
715
715
  // `=response.X` and `=response[...]`. `check` does not see the
716
- // artifact's argument list, so an artifact whose own output argument is
717
- // named `response` is flagged too (the trade-off BUSINESS_RULE_OUTPUT_SOURCE
718
- // makes for `=result.`). A bare `=response` is left alone: it names
716
+ // artifact's argument list, and an output argument named `response`
717
+ // (an object) is read `=response.<field>`, the source the SDD and
718
+ // `validate --strict --sdd` expect. So this is a warning that names
719
+ // that case, not an error. A bare `=response` is left alone: it names
719
720
  // such an argument whole, and has no field to suggest.
720
721
  if (!/^=\s*response\s*[.[]/.test(o.source))
721
722
  continue;
722
723
  const fix = /^=\s*response\s*\.\s*(.+)$/.exec(o.source)?.[1];
723
724
  diags.push({
724
- level: 'error',
725
+ level: 'warning',
725
726
  code: 'REFERENCE_OUTPUT_SOURCE',
726
- message: `Task "${t.name}" (${t.kind}) output "${o.var}" reads "${o.source}". This ${t.kind} task's result fields are read directly; \`=response.<field>\` is the connector form and reads nothing here. Write ${fix !== undefined ? `"=${fix}"` : 'the field without the `response` prefix'} (the source the Designer and \`uip maestro case sdd convert\` write).`,
727
+ message: `Task "${t.name}" (${t.kind}) output "${o.var}" reads "${o.source}", the connector form. Keep it only if the ${t.kind}'s own output argument is an object named \`response\` (the SDD lists \`response.<field>\`; \`uip maestro case tasks describe --type ${t.kind} --id <entityKey>\` lists the outputs). Otherwise write ${fix !== undefined ? `"=${fix}"` : 'the field without the `response` prefix'}, the source the Designer writes.`,
727
728
  where: t.name,
728
729
  });
729
730
  }
@@ -86,9 +86,9 @@ const EVENT_SERVICE_TYPES = new Set(['Intsvc.EventTrigger', 'Intsvc.WaitForEvent
86
86
  * task that compile never writes there (`connectorTaskData` in serialize.ts):
87
87
  * `operation` (`list`, `create`, `replace`, `SendEmailV2`, ...), the name of
88
88
  * the action the task calls. On an activity it repeats what `objectName`,
89
- * `method`, `path` and the metadata's activity type id already say, and no
90
- * source edit can set it, so a saved row that compile's side lacks is no sign
91
- * of an edit. The saved copy is then the only thing that keeps it.
89
+ * `method` and `path` already say, and no source edit can set it, so a saved
90
+ * row that compile's side lacks is no sign of an edit. The saved copy is then
91
+ * the only thing that keeps it.
92
92
  *
93
93
  * An event element's `operation` is different: compile writes it from the
94
94
  * event the source names, so it is compared there as any other row.
@@ -189,34 +189,34 @@ export function savedConnectorContext(owner, bag) {
189
189
  /** Whether a wire `activityType` is a generic CRUD one (`Generic`, `GenericExpanded`, `GenericTrigger`). */
190
190
  const isGenericKind = (activityType) => activityType.startsWith('Generic');
191
191
  /**
192
- * Which action a context was built for: the `uiPathActivityTypeId` its
193
- * `metadata` row names (in `activityPropertyConfiguration`, else in
194
- * `activityMetadata.activity`) and the essential configuration's
195
- * `instanceParameters.activityType` (`Curated` or `Generic`). A curated
196
- * activity and its generic twin share `method`, `path` and `objectName`
197
- * (Outlook `send-email` and `insert-record-deprecated-`), so only these tell
198
- * them apart. Either is `undefined` when the context does not say.
192
+ * The wire activity type a context was built for: the essential
193
+ * configuration's `instanceParameters.activityType` (`Curated`, `Generic`,
194
+ * `CuratedTrigger`, ...), or `undefined` when the context does not say.
195
+ *
196
+ * With the connector rows, this is all that names an action: it is what
197
+ * decompile reads to find the action the source names
198
+ * (`Library.identifyAction` and `identifyEvent` take the rows and this kind,
199
+ * nothing else). A curated activity and its generic twin share `method`,
200
+ * `path` and `objectName` (Outlook `send-email` and
201
+ * `insert-record-deprecated-`), so the kind is what tells them apart.
202
+ *
203
+ * The `uiPathActivityTypeId` is not compared: catalog and library ids may
204
+ * differ for the same action, so the wire identity is compared instead.
199
205
  */
200
- function actionIdentity(context) {
206
+ function wireActivityType(context) {
201
207
  const raw = context.find((row) => row.name === 'metadata')?.body;
202
208
  if (!isObject(raw))
203
- return {};
204
- const body = raw;
205
- const id = body.activityPropertyConfiguration?.uiPathActivityTypeId ?? body.activityMetadata?.activity?.uiPathActivityTypeId;
206
- let activityType;
207
- const encoded = body.activityPropertyConfiguration?.configuration;
208
- if (typeof encoded === 'string' && encoded.startsWith(JSON_STRING)) {
209
- try {
210
- activityType = JSON.parse(encoded.slice(JSON_STRING.length))?.essentialConfiguration?.instanceParameters?.activityType;
211
- }
212
- catch {
213
- activityType = undefined;
214
- }
209
+ return undefined;
210
+ const encoded = raw.activityPropertyConfiguration?.configuration;
211
+ if (typeof encoded !== 'string' || !encoded.startsWith(JSON_STRING))
212
+ return undefined;
213
+ try {
214
+ const activityType = JSON.parse(encoded.slice(JSON_STRING.length))?.essentialConfiguration?.instanceParameters?.activityType;
215
+ return typeof activityType === 'string' && activityType ? activityType : undefined;
216
+ }
217
+ catch {
218
+ return undefined;
215
219
  }
216
- return {
217
- typeId: typeof id === 'string' && id ? id : undefined,
218
- activityType: typeof activityType === 'string' && activityType ? activityType : undefined,
219
- };
220
220
  }
221
221
  /**
222
222
  * Whether the element compile built is the one the context was saved for:
@@ -228,10 +228,11 @@ function actionIdentity(context) {
228
228
  * `method`) still compares equal, and so does an activity's saved
229
229
  * `operation` row, which compile never writes there
230
230
  * ({@link comparesContextRow}). `connectorKey` must be on both sides;
231
- * - the action is the same: the activity type id agrees, and the wire
232
- * activity type is curated on both sides or generic on both, wherever both
233
- * sides carry them ({@link actionIdentity}), so switching to an action's
234
- * curated or generic twin gets compile's context;
231
+ * - the action is the same: the wire activity type is curated on both
232
+ * sides or generic on both, wherever both sides carry it
233
+ * ({@link wireActivityType}), so switching to an action's curated or
234
+ * generic twin gets compile's context. The activity type id is not
235
+ * compared: it is the saving catalog's, not the action's;
235
236
  * - every input holds the same value (an input only one side has must be
236
237
  * empty, as compile writes `body: {}` for an unused container).
237
238
  */
@@ -254,13 +255,11 @@ function unchanged(bag, entry, v2) {
254
255
  if (stable(builtRows.get(name)?.value) !== stable(saved.get(name)?.value))
255
256
  return false;
256
257
  }
257
- const [now, then] = [actionIdentity(built), actionIdentity(entry.context)];
258
- if (now.typeId && then.typeId && now.typeId !== then.typeId)
259
- return false;
258
+ const [now, then] = [wireActivityType(built), wireActivityType(entry.context)];
260
259
  // Only the curated / generic split names a twin: an event's saved kind
261
260
  // varies with no change of action (a trigger saved as `CuratedWaitFor` that
262
- // compile writes as `CuratedTrigger`, the same activity type id).
263
- if (now.activityType && then.activityType && isGenericKind(now.activityType) !== isGenericKind(then.activityType))
261
+ // compile writes as `CuratedTrigger`).
262
+ if (now && then && isGenericKind(now) !== isGenericKind(then))
264
263
  return false;
265
264
  const values = inputValues(bag);
266
265
  for (const name of new Set([...Object.keys(values), ...Object.keys(entry.inputs)])) {
@@ -26,7 +26,7 @@
26
26
  */
27
27
  import { parse } from 'acorn';
28
28
  import { MANAGED_HTTP_CONNECTOR_KEY, MANAGED_HTTP_ENDPOINT, MANAGED_HTTP_ENDPOINT_METHOD, MANAGED_HTTP_OBJECT_NAME, } from '../core/managed-http.js';
29
- import { taskOutputRefs } from './task-output-ref.js';
29
+ import { isWholeTaskOutputMarker } from './task-output-ref.js';
30
30
  import metadata from './http-request-metadata.json' with { type: 'json' };
31
31
  /**
32
32
  * The Designer's `metadata` context entry body, copied byte for byte from
@@ -123,11 +123,11 @@ export function httpRequestRefusal(owner, spec) {
123
123
  return { code: 'HTTP_REQUEST_FIELD', message: `${owner} ${field} must be an object of text values.` };
124
124
  // Text that is neither JSON nor an expression would be wrapped as `=js:( … )`,
125
125
  // which the activity evaluates: compile would turn the author's text into code.
126
- if (typeof spec.body === 'string' && !spec.body.startsWith('=') && !parsesAsJson(spec.body))
126
+ if (typeof spec.body === 'string' && !spec.body.startsWith('=') && !isWholeTaskOutputMarker(spec.body) && !parsesAsJson(spec.body))
127
127
  return {
128
128
  code: 'HTTP_REQUEST_BODY_FORM',
129
129
  message: `${owner} body is neither JSON nor an \`=\` expression. The activity evaluates its body as JavaScript, so the text would be written as code.`,
130
- suggestion: 'Pass the body as an object, JSON text, or an expression such as `=js:vars.payload`.',
130
+ suggestion: 'Pass the body as an object, JSON text, a `taskOutput()`, or an expression such as `=js:vars.payload`.',
131
131
  };
132
132
  if (spec.body !== undefined && typeof spec.body !== 'string') {
133
133
  const leaf = unlowerableLeaf(spec.body);
@@ -154,19 +154,6 @@ const parsesAsJson = (text) => {
154
154
  };
155
155
  /** A dotted reference such as `vars.customer.id`: JavaScript as written. */
156
156
  const REFERENCE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
157
- /** Property reads after a reference: `.field.sub`. */
158
- const DOTTED_TAIL = /^(?:\.[A-Za-z_$][\w$]*)*$/;
159
- /**
160
- * Whether `text` is exactly one `taskOutput()` marker (`vars.$xref('S','T','body')`),
161
- * optionally followed by property reads. It is a reference once lowered: the
162
- * whole plan's markers are lowered to `vars.<output id>` after the body is
163
- * written (`lowerPlanTaskOutputRefs` in `serialize.ts`), so the activity never
164
- * sees `$xref`.
165
- */
166
- function isTaskOutputReference(text) {
167
- const refs = taskOutputRefs(text);
168
- return refs.length === 1 && refs[0].index === 0 && DOTTED_TAIL.test(text.slice(refs[0].whole.length));
169
- }
170
157
  /**
171
158
  * `code` parenthesized as one JavaScript expression, `(<code>\n)`, or
172
159
  * `undefined` when it is not exactly one. The parentheses close on a new line,
@@ -215,14 +202,17 @@ function oneExpression(code) {
215
202
  * (`HTTP_REQUEST_BODY_EXPRESSION`).
216
203
  */
217
204
  function leafCode(value) {
205
+ // A bare marker is lowered to `vars.<id>` over the finished plan (`lowerPlanTaskOutputRefs`).
206
+ if (isWholeTaskOutputMarker(value))
207
+ return value;
218
208
  if (value.startsWith('=js:')) {
219
209
  const code = value.slice('=js:'.length).trim();
220
210
  return code === '' ? undefined : oneExpression(code);
221
211
  }
222
212
  const reference = value.slice(1).trim();
223
- return REFERENCE.test(reference) || isTaskOutputReference(reference) ? reference : undefined;
213
+ return REFERENCE.test(reference) || isWholeTaskOutputMarker(reference) ? reference : undefined;
224
214
  }
225
- const isExpressionLeaf = (value) => typeof value === 'string' && value.startsWith('=');
215
+ const isExpressionLeaf = (value) => typeof value === 'string' && (value.startsWith('=') || isWholeTaskOutputMarker(value));
226
216
  const childrenOf = (value) => Array.isArray(value) ? value : typeof value === 'object' && value !== null ? Object.values(value) : [];
227
217
  function hasExpressionLeaf(value) {
228
218
  return isExpressionLeaf(value) || childrenOf(value).some(hasExpressionLeaf);
@@ -276,8 +266,8 @@ export function httpRequestLint(owner, spec) {
276
266
  message: `${owner} names no connector, so it calls url directly, and has none.`,
277
267
  suggestion: "Pass url (for example url: 'https://api.example.com/items'), or connector: { key, connection, folder } with a path.",
278
268
  });
279
- // A literal value is the secret itself, written into the plan; an `=` value is read at run time.
280
- const literalCredential = (fields, names) => Object.entries(isObjectOfText(fields) ? fields : {}).find(([k, v]) => names.has(k.toLowerCase()) && !v.startsWith('='))?.[0];
269
+ // A literal value is the secret itself, written into the plan; an `=` value or a `taskOutput()` is read at run time.
270
+ const literalCredential = (fields, names) => Object.entries(isObjectOfText(fields) ? fields : {}).find(([k, v]) => names.has(k.toLowerCase()) && !v.startsWith('=') && !isWholeTaskOutputMarker(v))?.[0];
281
271
  const credentials = [
282
272
  ['header', literalCredential(spec.headers, CREDENTIAL_HEADERS)],
283
273
  ['query parameter', literalCredential(spec.query, CREDENTIAL_QUERY_KEYS)],
@@ -2,8 +2,9 @@
2
2
  * Reference-mode task kinds: a task that runs a separately published artifact
3
3
  * (a process, agent, RPA or API workflow, ...) and binds its arguments with
4
4
  * `.inputs()` / `.outputs()`. The artifact's result fields are at the top of
5
- * its result, so an extract reads `=<Field>`, not the connector form
6
- * `=response.<field>` (builder-sdk#1565). Shared by the builder (which kinds
5
+ * its result, so an extract reads `=<Field>` (`=<Argument>.<field>` for an
6
+ * object argument), not the connector form `=response.<field>` unless the
7
+ * argument itself is named `response` (builder-sdk#1565). Shared by the builder (which kinds
7
8
  * take `.inputs()`) and `check` (REFERENCE_OUTPUT_SOURCE).
8
9
  */
9
10
  import type { TaskKind } from './case-sdk.js';
@@ -47,7 +47,7 @@ import { SCRIPT_INPUTS, scriptOutputMappings, scriptOutputs, storedScript } from
47
47
  import { DOCUMENT_EXTRACTION_NAME, DOCUMENT_EXTRACTION_RESOURCE, DOCUMENT_EXTRACTION_SERVICE_TYPE, DOCUMENT_EXTRACTION_VERSION, documentExtractionContext, documentExtractionInputs, documentExtractionOutputMappings, documentExtractionOutputs, documentExtractionRefusal, } from './document-extraction.js';
48
48
  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';
49
49
  import { connectorPlaceholderData, connectorPlaceholderKindOf, isConnectorPlaceholder } from './connector-placeholder.js';
50
- import { lowerTaskOutputRefs, planTaskOutputs, resolveInPlan, unresolvedTaskOutputRef } from './task-output-ref.js';
50
+ import { isWholeTaskOutputMarker, lowerTaskOutputRefs, taskOutputRefs, planTaskOutputs, resolveInPlan, unresolvedTaskOutputRef } from './task-output-ref.js';
51
51
  import { applyCustomRowShape } from './custom-output-shape.js';
52
52
  /** The ids a serialize pass hashed from element ids, by the document it returned. */
53
53
  const ELEMENT_SEEDED_IDS = new WeakMap();
@@ -456,7 +456,7 @@ function serializeCase(built, opts) {
456
456
  */
457
457
  function lowerPlanTaskOutputRefs(plan) {
458
458
  let tasks;
459
- const lower = (text) => lowerTaskOutputRefs(text, (ref) => {
459
+ const lowerText = (text) => lowerTaskOutputRefs(text, (ref) => {
460
460
  tasks ??= planTaskOutputs(plan);
461
461
  const resolved = resolveInPlan(tasks, ref);
462
462
  if ('why' in resolved)
@@ -465,6 +465,17 @@ function lowerPlanTaskOutputRefs(plan) {
465
465
  // left, and the stood-in task's own refusal is what `check` reports.
466
466
  return 'standIn' in resolved ? undefined : resolved.variable;
467
467
  });
468
+ // A bare marker as a whole value (`<- "S"."T".out`) is a reference, so it gets
469
+ // the `=` a literal `vars.<id>` would lack, as `sdd convert` writes it:
470
+ // `=vars.<id>`, or with property reads `=js:vars.<id>?.field` (strict validate
471
+ // accepts no other bare `=` form, and `?.` reads empty while the producer has
472
+ // not run). An author's own `=` value is left as written.
473
+ const lower = (text) => {
474
+ const lowered = lowerText(text);
475
+ if (lowered === text || !isWholeTaskOutputMarker(text))
476
+ return lowered;
477
+ return taskOutputRefs(text)[0].whole.length === text.length ? `=${lowered}` : lowerText(`=js:${text}`);
478
+ };
468
479
  const walk = (value) => {
469
480
  if (typeof value === 'string')
470
481
  return value.includes('$xref') ? lower(value) : value;
@@ -38,6 +38,11 @@ export declare function taskOutputRefs(text: string): Array<TaskOutputRef & {
38
38
  whole: string;
39
39
  index: number;
40
40
  }>;
41
+ /**
42
+ * Whether `text` is exactly one marker, optionally followed by property reads
43
+ * (`.field.sub`), with no `=` prefix: a reference once lowered.
44
+ */
45
+ export declare function isWholeTaskOutputMarker(text: string): boolean;
41
46
  /**
42
47
  * Replace every marker in `text` with what `lower` returns for it. In a `=js:`
43
48
  * expression, a marker followed by a property read gets the optional chain
@@ -49,6 +49,14 @@ export function taskOutputRefs(text) {
49
49
  return { stage: arg(1), task: arg(5), output: arg(9), whole: m[0], index: m.index ?? 0 };
50
50
  });
51
51
  }
52
+ /**
53
+ * Whether `text` is exactly one marker, optionally followed by property reads
54
+ * (`.field.sub`), with no `=` prefix: a reference once lowered.
55
+ */
56
+ export function isWholeTaskOutputMarker(text) {
57
+ const refs = taskOutputRefs(text);
58
+ return refs.length === 1 && refs[0].index === 0 && /^(?:\.[A-Za-z_$][\w$]*)*$/.test(text.slice(refs[0].whole.length));
59
+ }
52
60
  /**
53
61
  * Replace every marker in `text` with what `lower` returns for it. In a `=js:`
54
62
  * expression, a marker followed by a property read gets the optional chain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.122.0",
3
+ "version": "6.122.2",
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",
@@ -126,5 +126,5 @@
126
126
  "@types/node": "^22.7.0",
127
127
  "esbuild": "^0.28.1"
128
128
  },
129
- "gitref": "e76d86fad9a1820eb4e282807215e14b55258dfe"
129
+ "gitref": "9dc07468c4ac6ba476bb237a0bbc206e3c3f22ab"
130
130
  }