@uipath/maestro-builder-sdk 6.120.20 → 6.120.22

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.
@@ -43,8 +43,20 @@ export interface BpmnLocatedDiagnostic extends ExprDiagnostic {
43
43
  /** The field's path inside that element — see {@link BpmnExprField.path}. */
44
44
  path?: string;
45
45
  }
46
+ /**
47
+ * Codes that advise how NEW expression text should be written. `check --baseline` drops
48
+ * them on an element the edit did not change (check-baseline.ts): an untouched
49
+ * expression is the original's, and an edit is not asked to rewrite it.
50
+ */
51
+ export declare const AUTHORING_ADVICE_CODES: ReadonlySet<string>;
46
52
  /** Every first-level expression problem in a built BPMN process, stamped with its location. */
47
53
  export declare function checkBpmnExpressions(built: BuiltBpmn): BpmnLocatedDiagnostic[];
54
+ /**
55
+ * Every expression in a built BPMN process that the platform reads as C# while the
56
+ * author most likely meant JavaScript (#2137): `EXPR_BARE_PREFIX` and
57
+ * `EXPR_BARE_PREFIX_JS_SYNTAX`, on the same fields as {@link checkBpmnExpressions}.
58
+ */
59
+ export declare function checkBpmnExpressionLanguage(built: BuiltBpmn): BpmnLocatedDiagnostic[];
48
60
  /**
49
61
  * Was thrown by `BpmnBuilder.build()` when the first-level expression check found an
50
62
  * undeclared `vars.<name>` reference. `message` lists every problem; `diagnostics`
@@ -126,6 +126,144 @@ function argumentMessage(root, { decl, scope }) {
126
126
  `'BPMN.Variables', outputRows: [{ name: ${tsLiteral(decl.name)}, type: ${tsLiteral(type)}, ` +
127
127
  `source: ${tsLiteral(`=vars.${decl.id}`)}, var: ${tsLiteral(local)} }] } })\`, then read \`=vars.${local}\`.`);
128
128
  }
129
+ // Expression language (#2137): Studio Web and the Maestro runtime read a bare `=` as
130
+ // C# and only `=js:` as JavaScript. compile keeps the authored text, since a bare `=`
131
+ // may be deliberate C#, so check reports it instead.
132
+ /** A value the platform reads as a JavaScript expression. */
133
+ const JS_EXPR_PREFIX = '=js:';
134
+ /** Another `=<marker>:` prefix (`=jsonString:` in node metadata) — not a bare-`=` expression. */
135
+ const OTHER_PREFIX = /^=[A-Za-z]+:/;
136
+ /**
137
+ * A Data Fabric lookup, which the runtime resolves itself rather than as C# or JavaScript:
138
+ * `=datafabric[bindings.<entity>?folderPath=bindings.<folder>]["qes:{...}"]` or
139
+ * `=datafabric.<Entity>["qes:{...}"]` (Studio Web `DataFabricEditorUtils`). Its query
140
+ * tail is JSON with unescaped quotes, so it is not an expression in either language.
141
+ */
142
+ const DATA_FABRIC_LOOKUP = /^=\s*datafabric\s*[.[]/;
143
+ /**
144
+ * One dotted / indexed path (`vars.a.b`, `vars.items[0].id`, `response`, `out_合計`): the
145
+ * same read in C# and JavaScript, both of which take Unicode letters in a name.
146
+ */
147
+ const PLAIN_PATH = /^[\p{L}_$][\p{L}\p{N}_$]*(?:\s*\.\s*[\p{L}_$][\p{L}\p{N}_$]*|\s*\[\s*(?:\d+|"[^"\\]*")\s*\])*$/u;
148
+ /** A literal that is the same value in C# and JavaScript. */
149
+ const PLAIN_LITERAL = /^(?:-?\d+(?:\.\d+)?|true|false|null|"[^"\\]*")$/;
150
+ /**
151
+ * JavaScript that C# (DynamicExpresso) does not have, each with how the message names it.
152
+ * `definite: false` marks one that is also legal C# in some processes (a JSON property
153
+ * named `length`), so it is a warning, not an error.
154
+ */
155
+ const JS_ONLY = [
156
+ { re: /`/, named: 'a template literal', definite: true },
157
+ { re: /===|!==/, named: '`===` / `!==`', definite: true },
158
+ { re: /\bJSON\s*\./, named: '`JSON`', definite: true },
159
+ { re: /\.\s*[a-z_$][\w$]*\s*\(/, named: 'a lower-case (JavaScript) method call', definite: true },
160
+ { re: /\bundefined\b/, named: '`undefined`', definite: true },
161
+ { re: /\bfunction\b/, named: '`function`', definite: true },
162
+ { re: /\.\s*length\b(?!\s*\()/, named: '`.length`', definite: false },
163
+ ];
164
+ /**
165
+ * C# that JavaScript does not have: a .NET member call (`.Contains(`, `.ToString(`), a
166
+ * collection's `.Count` / `.Length`, a .NET type (`String.IsNullOrEmpty`), an interpolated
167
+ * or verbatim string. A body with one is C#, so `=js:` + the same text is no fix.
168
+ */
169
+ const CSHARP_ONLY = [
170
+ /\.\s*[A-Z]\w*\s*\(/,
171
+ /\.\s*(?:Count|Length)\b/,
172
+ /\b(?:String|string|Convert|DateTime|TimeSpan|Guid|Math|double|int|long|decimal|bool|Enumerable|Newtonsoft)\s*\./,
173
+ /[$@]"/,
174
+ ];
175
+ /**
176
+ * `body` with the contents of every string literal emptied, so text inside one
177
+ * (`"a.length"`, `"`"`) is not read as code. Reads C# regular strings and chars
178
+ * (backslash escapes, also JavaScript's `'...'`), C# verbatim strings (`@"..."`, `$@"..."`,
179
+ * where `""` is the only escape) and JavaScript template literals. A template literal
180
+ * keeps its backticks, so it is still reported as JavaScript, and a verbatim string its
181
+ * `@`, so it is still read as C#.
182
+ *
183
+ * `undefined` when `body` does not read as an expression in either language: a string
184
+ * that never closes, or one followed directly by a word or another quote (`"a"b`).
185
+ */
186
+ function maskStrings(body) {
187
+ let out = '';
188
+ let i = 0;
189
+ while (i < body.length) {
190
+ const c = body[i];
191
+ const verbatim = /^(?:@\$?|\$@)"/.exec(body.slice(i, i + 3));
192
+ if (verbatim || c === '"' || c === "'" || c === '`') {
193
+ const quote = verbatim ? '"' : c;
194
+ i += verbatim ? verbatim[0].length : 1;
195
+ if (verbatim)
196
+ while (i < body.length && !(body[i] === '"' && body[i + 1] !== '"'))
197
+ i += body[i] === '"' ? 2 : 1;
198
+ else
199
+ while (i < body.length && body[i] !== quote)
200
+ i += body[i] === '\\' ? 2 : 1;
201
+ if (i >= body.length || /[\w$"'`]/.test(body[i + 1] ?? ''))
202
+ return undefined;
203
+ // A verbatim string keeps its `@`/`$@`, so CSHARP_ONLY still sees it is C#.
204
+ out += `${verbatim ? verbatim[0].slice(0, -1) : ''}${quote}${quote}`;
205
+ i++;
206
+ }
207
+ else {
208
+ out += c;
209
+ i++;
210
+ }
211
+ }
212
+ return out;
213
+ }
214
+ /** `text` for a message, cut to a readable length. */
215
+ function shownExpr(text) {
216
+ return JSON.stringify(text.length > 80 ? `${text.slice(0, 77)}...` : text);
217
+ }
218
+ /** Report one `=`-expression whose bare `=` prefix makes it C#. */
219
+ function checkLanguagePrefix(expr, where, out) {
220
+ if (!expr || !expr.startsWith('=') || expr.startsWith(JS_EXPR_PREFIX) || OTHER_PREFIX.test(expr))
221
+ return;
222
+ if (DATA_FABRIC_LOOKUP.test(expr))
223
+ return;
224
+ const body = expr.slice(1).trim();
225
+ if (body === '' || PLAIN_PATH.test(body) || PLAIN_LITERAL.test(body))
226
+ return;
227
+ const code = maskStrings(body);
228
+ if (code === undefined)
229
+ return;
230
+ const shown = shownExpr(expr);
231
+ const csharp = CSHARP_ONLY.some((re) => re.test(code));
232
+ // `=js:` + the same text is a fix only when the body has no C# of its own.
233
+ const suggestion = csharp ? {} : { suggestion: `${JS_EXPR_PREFIX}${body}` };
234
+ const fix = csharp ? 'Rewrite it in JavaScript and prefix it with `=js:`.' : 'Prefix it with `=js:`.';
235
+ const jsOnly = JS_ONLY.find(({ re }) => re.test(code));
236
+ if (jsOnly?.definite) {
237
+ out.push({
238
+ level: 'error',
239
+ code: 'EXPR_BARE_PREFIX_JS_SYNTAX',
240
+ message: `Expression ${shown} starts with a bare \`=\`, which Studio Web and the Maestro runtime read as C#, `
241
+ + `but it uses ${jsOnly.named}, which is JavaScript. The run faults or the condition reads false, `
242
+ + `while validate passes. ${fix}`,
243
+ ...suggestion,
244
+ where,
245
+ });
246
+ return;
247
+ }
248
+ const uses = jsOnly ? ` It uses ${jsOnly.named}, which C# has only as a member of that name.` : '';
249
+ out.push({
250
+ level: 'warning',
251
+ code: 'EXPR_BARE_PREFIX',
252
+ message: `Expression ${shown} starts with a bare \`=\`, which Studio Web and the Maestro runtime read as C#; `
253
+ + `only \`=js:\` marks JavaScript.${uses} Studio Web opens it in its C# editor. `
254
+ + (csharp
255
+ ? 'It uses C#, so keep it if the C# is meant; otherwise rewrite it in JavaScript and prefix it with `=js:`.'
256
+ : 'Prefix it with `=js:`, unless the C# is meant (an expression decompiled from the canvas, say).'),
257
+ ...suggestion,
258
+ where,
259
+ });
260
+ }
261
+ /**
262
+ * Codes that advise how NEW expression text should be written. `check --baseline` drops
263
+ * them on an element the edit did not change (check-baseline.ts): an untouched
264
+ * expression is the original's, and an edit is not asked to rewrite it.
265
+ */
266
+ export const AUTHORING_ADVICE_CODES = new Set(['EXPR_BARE_PREFIX']);
129
267
  /** Every finding on one field. */
130
268
  function checkField(f, out) {
131
269
  if (f.form === 'script')
@@ -144,6 +282,23 @@ export function checkBpmnExpressions(built) {
144
282
  }
145
283
  return out;
146
284
  }
285
+ /**
286
+ * Every expression in a built BPMN process that the platform reads as C# while the
287
+ * author most likely meant JavaScript (#2137): `EXPR_BARE_PREFIX` and
288
+ * `EXPR_BARE_PREFIX_JS_SYNTAX`, on the same fields as {@link checkBpmnExpressions}.
289
+ */
290
+ export function checkBpmnExpressionLanguage(built) {
291
+ const out = [];
292
+ for (const f of bpmnExpressionFields(built)) {
293
+ if (f.form !== 'expression')
294
+ continue;
295
+ const found = [];
296
+ checkLanguagePrefix(f.text, f.where, found);
297
+ for (const d of found)
298
+ out.push({ ...d, elementId: f.elementId, path: f.path });
299
+ }
300
+ return out;
301
+ }
147
302
  /**
148
303
  * Was thrown by `BpmnBuilder.build()` when the first-level expression check found an
149
304
  * undeclared `vars.<name>` reference. `message` lists every problem; `diagnostics`
@@ -377,7 +377,12 @@ export interface BpmnFlow {
377
377
  target: string;
378
378
  /** Edge label the designer shows. */
379
379
  name?: string;
380
- /** `=`-expression gating this flow (exclusive/inclusive gateway outgoing). Read a declared process variable as `=vars.<id>`. */
380
+ /**
381
+ * `=`-expression gating this flow (exclusive/inclusive gateway outgoing), e.g.
382
+ * `'=js:vars.status == "ok"'`. Read a declared process variable as `vars.<id>`. Write
383
+ * `=js:` for JavaScript: Studio Web and the runtime read a bare `=` as C#, and
384
+ * `check` says so (`EXPR_BARE_PREFIX`).
385
+ */
381
386
  condition?: string;
382
387
  /**
383
388
  * Set on a flow the builder wrote by implication — an arm's chain, a handler's path,
@@ -2065,7 +2070,7 @@ export interface MessageHandlerOpts extends HandlerOpts {
2065
2070
  * arm nobody gave a condition cannot be written.
2066
2071
  */
2067
2072
  export type ChooseArm = {
2068
- /** `=`-expression selecting this arm, e.g. `'=vars.action == "Approved"'`. */
2073
+ /** `=`-expression selecting this arm, e.g. `'=js:vars.action == "Approved"'`. */
2069
2074
  when: string;
2070
2075
  /** Not on a conditioned arm. */
2071
2076
  otherwise?: never;
@@ -3363,7 +3368,7 @@ declare abstract class ScopeBuilder {
3363
3368
  * .startEvent('start')
3364
3369
  * .task('decide', { set: { action: 'Approved' } })
3365
3370
  * .choose('approved', [
3366
- * { when: '=vars.action == "Approved"', label: 'Yes', body: (b) => b.task('post', { set: { status: 'posted' } }) },
3371
+ * { when: '=js:vars.action == "Approved"', label: 'Yes', body: (b) => b.task('post', { set: { status: 'posted' } }) },
3367
3372
  * { otherwise: true, label: 'No', body: (b) => b.task('reject', { set: { status: 'rejected' } }) },
3368
3373
  * ])
3369
3374
  * .endEvent('done')
@@ -3468,7 +3473,7 @@ declare abstract class ScopeBuilder {
3468
3473
  * ])
3469
3474
  * .startEvent('Start_1')
3470
3475
  * .choose('Gw_1', [
3471
- * { when: '=vars.total > 1000', body: (b) => b.task('Review').goto('Done') },
3476
+ * { when: '=js:vars.total > 1000', body: (b) => b.task('Review').goto('Done') },
3472
3477
  * { otherwise: true, body: (b) => b.task('Pay').goto('Done') },
3473
3478
  * ])
3474
3479
  * .endEvent('Done')
@@ -3679,7 +3684,7 @@ export declare class PathBuilder extends ScopeBuilder {
3679
3684
  * .startEvent('start')
3680
3685
  * .scriptTask('attempt', { script: 'return { ok: true };', outputs: { ok: '=result.response.ok' } })
3681
3686
  * .choose('worked', [
3682
- * { when: '=vars.ok == true', body: (b) => b.endEvent('done') },
3687
+ * { when: '=js:vars.ok == true', body: (b) => b.endEvent('done') },
3683
3688
  * { otherwise: true, body: (b) => b.goto('attempt') },
3684
3689
  * ])
3685
3690
  * .sequenceFlow('start', 'attempt')
@@ -2263,7 +2263,7 @@ class ScopeBuilder {
2263
2263
  * .startEvent('start')
2264
2264
  * .task('decide', { set: { action: 'Approved' } })
2265
2265
  * .choose('approved', [
2266
- * { when: '=vars.action == "Approved"', label: 'Yes', body: (b) => b.task('post', { set: { status: 'posted' } }) },
2266
+ * { when: '=js:vars.action == "Approved"', label: 'Yes', body: (b) => b.task('post', { set: { status: 'posted' } }) },
2267
2267
  * { otherwise: true, label: 'No', body: (b) => b.task('reject', { set: { status: 'rejected' } }) },
2268
2268
  * ])
2269
2269
  * .endEvent('done')
@@ -2399,7 +2399,7 @@ class ScopeBuilder {
2399
2399
  * ])
2400
2400
  * .startEvent('Start_1')
2401
2401
  * .choose('Gw_1', [
2402
- * { when: '=vars.total > 1000', body: (b) => b.task('Review').goto('Done') },
2402
+ * { when: '=js:vars.total > 1000', body: (b) => b.task('Review').goto('Done') },
2403
2403
  * { otherwise: true, body: (b) => b.task('Pay').goto('Done') },
2404
2404
  * ])
2405
2405
  * .endEvent('Done')
@@ -2711,7 +2711,7 @@ export class PathBuilder extends ScopeBuilder {
2711
2711
  * .startEvent('start')
2712
2712
  * .scriptTask('attempt', { script: 'return { ok: true };', outputs: { ok: '=result.response.ok' } })
2713
2713
  * .choose('worked', [
2714
- * { when: '=vars.ok == true', body: (b) => b.endEvent('done') },
2714
+ * { when: '=js:vars.ok == true', body: (b) => b.endEvent('done') },
2715
2715
  * { otherwise: true, body: (b) => b.goto('attempt') },
2716
2716
  * ])
2717
2717
  * .sequenceFlow('start', 'attempt')
@@ -18,6 +18,9 @@
18
18
  * - `edited` otherwise: an element the edit changed or added, or an untouched element
19
19
  * the original does not have the finding on (an edit elsewhere broke it).
20
20
  *
21
+ * A pre-existing finding of a code in `AUTHORING_ADVICE_CODES` (advice on how to write a
22
+ * new expression, such as `EXPR_BARE_PREFIX`) is dropped: the edit did not write that text.
23
+ *
21
24
  * An element is unchanged when the edited build and the original's build hold the same
22
25
  * element under its id: the same node (kind, name, type, inputs, outputs, extension
23
26
  * payload, every field the builder carries), the same sequence flow (source, target,
@@ -34,6 +37,7 @@
34
37
  */
35
38
  import { baselineSummary, preExistingFindings, scopeFindings } from '../core/baseline-scope.js';
36
39
  import { refusalClass } from '../core/refusals.js';
40
+ import { AUTHORING_ADVICE_CODES } from './bpmn-expr-check.js';
37
41
  import { checkModel } from './check.js';
38
42
  import { readStamp, sourceDigest } from './decompile-stamp.js';
39
43
  import { stableJson } from './lift-verify.js';
@@ -116,7 +120,8 @@ export function scopeToEdit(edited, baseline) {
116
120
  const place = placeOf(d, editedIndex);
117
121
  return { ...d, ...(place !== '' ? { nodeId: place } : {}), ...(cls !== undefined ? { class: cls } : {}) };
118
122
  });
119
- const out = scopeFindings(classed, preExisting, PRE_EXISTING_LOWERING_NOTE);
123
+ const out = scopeFindings(classed, preExisting, PRE_EXISTING_LOWERING_NOTE)
124
+ .filter((d) => !(d.origin === 'pre-existing' && AUTHORING_ADVICE_CODES.has(d.code)));
120
125
  const stop = edited.checked.stoppedAt;
121
126
  if (stop) {
122
127
  const at = stop.code !== undefined ? `[${stop.code}] ` : '';
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { parse } from 'acorn';
19
19
  import { jsChildren, memberName, scopeBinds } from './script-js.js';
20
- import { checkBpmnExpressions } from './bpmn-expr-check.js';
20
+ import { checkBpmnExpressionLanguage, checkBpmnExpressions } from './bpmn-expr-check.js';
21
21
  import { allNodes, collectSerializerModel, folderCompanionKeys, implicitNodeVars, processId } from './serialize.js';
22
22
  import { refreshConnectionDiagnostics } from './refresh-connections.js';
23
23
  import { KNOWN_METHOD_SET } from './known-methods.js';
@@ -207,7 +207,8 @@ function refreshConnections(built, definitions, stoodIn, diags) {
207
207
  }
208
208
  /**
209
209
  * The first-level expression check (bpmn-expr-check): an undeclared `vars.<name>` or
210
- * `bindings.<name>` read, or a declared variable read without `vars.`.
210
+ * `bindings.<name>` read, a declared variable read without `vars.`, or an expression
211
+ * whose bare `=` prefix makes it C# when JavaScript was meant (#2137).
211
212
  *
212
213
  * Both codes are `lint` (decided on #1712): the serializer writes the read exactly as
213
214
  * authored, so `compile` writes it and `check` is where it is reported. It ran in
@@ -217,7 +218,7 @@ function refreshConnections(built, definitions, stoodIn, diags) {
217
218
  */
218
219
  function checkExpressions(built, diags) {
219
220
  const nodeIds = new Set(allNodes(built.nodes).map((n) => n.id));
220
- for (const d of checkBpmnExpressions(built)) {
221
+ for (const d of [...checkBpmnExpressions(built), ...checkBpmnExpressionLanguage(built)]) {
221
222
  diags.push({
222
223
  level: d.level,
223
224
  code: d.code,
package/dist/bpmn-api.md CHANGED
@@ -615,7 +615,7 @@ One sequence flow in the built graph — the edge from `source` to `target` (`bp
615
615
  - `BpmnFlow.source: string` — The id of the element the flow leaves.
616
616
  - `BpmnFlow.target: string` — The id of the element it arrives at.
617
617
  - `BpmnFlow.name?: string` — Edge label the designer shows.
618
- - `BpmnFlow.condition?: string` — `=`-expression gating this flow (exclusive/inclusive gateway outgoing).
618
+ - `BpmnFlow.condition?: string` — `=`-expression gating this flow (exclusive/inclusive gateway outgoing), e.g. `'=js:vars.status == "ok"'`.
619
619
  - `BpmnFlow.implied?: true` — Set on a flow the builder wrote by implication — an arm's chain, a handler's path, a construct's join, or a…
620
620
 
621
621
  ### `BpmnVarDecl`
@@ -21,7 +21,7 @@ import { compareSchemaVersions, preserveSchemaVersion } from '../schema-version.
21
21
  import { ownEntry } from '../core/own-entry.js';
22
22
  import { eventFilterExpressionOf, eventFilterFromTreeLeaf, eventFilterJmes, eventFilterOperator, eventFilterProblem, EXPRESSION_FILTER_OPERATORS, filterExprFromLeaf } from '../core/event-filters.js';
23
23
  import { CASE_FILTER_SPELLING, caseSubscriptionBody, caseSubscriptionOwners } from './subscription.js';
24
- import { CASE_NODE_CANVAS_FIELDS, CASE_NODE_LAYOUT_FIELDS, isTypedInputField, isUnrestorableSlotId, planElementIds, PRESERVED_STAGE_DATA_KEYS, PRESERVED_TRIGGER_DATA_KEYS, RESOURCE_INPUT_WRITTEN, RESOURCE_OUTPUT_WRITTEN, CASE_EMPTY_LISTS, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint, PRESERVED_ACTION_DATA_KEYS, TYPED_TRIGGER_DISPLAY_KEYS, } from './preserve.js';
24
+ import { CASE_NODE_CANVAS_FIELDS, CASE_NODE_LAYOUT_FIELDS, isTypedInputField, isUnrestorableSlotId, planElementIds, PRESERVED_STAGE_DATA_KEYS, PRESERVED_TRIGGER_DATA_KEYS, RESOURCE_INPUT_WRITTEN, RESOURCE_OUTPUT_WRITTEN, outputRowName, CASE_EMPTY_LISTS, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint, PRESERVED_ACTION_DATA_KEYS, TYPED_TRIGGER_DISPLAY_KEYS, } from './preserve.js';
25
25
  import { stableId } from '../core/stable-id.js';
26
26
  import { ACTION_CONTEXT_COPIES, ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
27
27
  import { resourceIdentity, SOLUTION_FOLDER } from './resource-identity.js';
@@ -1498,6 +1498,21 @@ function resourceOutputValue(task, row) {
1498
1498
  return {};
1499
1499
  return row.value === undefined || row.value === row.var ? {} : { value: { value: structuredClone(row.value), var: row.var } };
1500
1500
  }
1501
+ /**
1502
+ * A resource task output's saved `name` when it is not the one compile writes
1503
+ * (`outputRowName`): the author's label, carried with the `source` and `var`
1504
+ * it was saved beside (`label` on `PreservedOutputRow`). Example:
1505
+ * `{ name: 'ReworkCount', source: '=js:(vars.reworkCount || 0) + 1', var: 'reworkCount' }`,
1506
+ * which compile would name `reworkCount`. Without it the row came back under
1507
+ * compile's name and its carried `displayName` (keyed by the saved name) was lost.
1508
+ */
1509
+ function resourceOutputLabel(task, row) {
1510
+ if (!ownEntry(TASK_KIND_METHOD, task.type) || row.custom === true)
1511
+ return {};
1512
+ if (typeof row.name !== 'string' || typeof row.source !== 'string' || typeof row.var !== 'string')
1513
+ return {};
1514
+ return row.name === outputRowName(row.source, row.var) ? {} : { label: { source: row.source, var: row.var } };
1515
+ }
1501
1516
  function resourceRowShape(task, row, side) {
1502
1517
  if (!ownEntry(TASK_KIND_METHOD, task.type) || row.custom === true)
1503
1518
  return {};
@@ -2801,6 +2816,7 @@ function identityPreservation(plan) {
2801
2816
  ...actionOutputShape(task, row),
2802
2817
  ...resourceRowShape(task, row, 'outputs'),
2803
2818
  ...resourceOutputValue(task, row),
2819
+ ...resourceOutputLabel(task, row),
2804
2820
  ...customRowIdentity(task, row, plan),
2805
2821
  ...interleavedCustomSource(task, row),
2806
2822
  ...rowHoldsSavedTaskElementId(stage, task, row),
@@ -47,6 +47,24 @@ export declare const CASE_NODE_CANVAS_FIELDS: readonly ["selected", "dragging",
47
47
  */
48
48
  export declare const RESOURCE_INPUT_WRITTEN: ReadonlySet<string>;
49
49
  export declare const RESOURCE_OUTPUT_WRITTEN: ReadonlySet<string>;
50
+ /**
51
+ * The `name` compile writes on the task output row that reads `source` into
52
+ * `variable` (`emitTaskOutput`): a connector result field's path under
53
+ * `response` (`=response.CreatedBy.Id` is `CreatedBy.Id`), else the path's
54
+ * last segment (`=Decision.output` is `output`, `=APIOutput1` is
55
+ * `APIOutput1`). A `=js:` expression is no field path, so its row is named
56
+ * after the variable it writes: `reworkCount: '=js:(vars.reworkCount || 0) + 1'`
57
+ * is `reworkCount`, not the expression's text after its last dot.
58
+ *
59
+ * The Case Designer names a connector task's extract after the field's path
60
+ * in the response, so one task that reads `CreatedBy.Id`, `Id` and
61
+ * `UpdatedBy.Id` has three rows with three names. The last segment would name
62
+ * all three `Id`.
63
+ *
64
+ * Decompile reads this too: a saved row whose `name` is not this one carries
65
+ * it (`label` on `PreservedOutputRow`).
66
+ */
67
+ export declare function outputRowName(source: string, variable: string): string;
50
68
  /** Whether `.inputs()` types an input's `required` (a boolean) or `default` (a string, number, boolean or null). */
51
69
  export declare function isTypedInputField(key: 'required' | 'default', value: unknown): boolean;
52
70
  /**
@@ -372,6 +390,18 @@ export interface PreservedOutputRow {
372
390
  value: unknown;
373
391
  var: string;
374
392
  };
393
+ /**
394
+ * A resource task output saved with a `name` that is not the one compile
395
+ * writes (`outputRowName`), with the `source` and `var` it was saved beside.
396
+ * The row's label is the author's, which `.outputs()` has no slot for:
397
+ * `{ name: 'ReworkCount', source: '=js:(vars.reworkCount || 0) + 1', var: 'reworkCount' }`.
398
+ * Compile writes this entry's `name` back while the row still reads that
399
+ * source into that variable; an edit to either takes compile's name.
400
+ */
401
+ label?: {
402
+ source: string;
403
+ var: string;
404
+ };
375
405
  }
376
406
  /**
377
407
  * Non-authoring Case JSON lanes retained by decompile/recompile.
@@ -53,6 +53,31 @@ export const CASE_NODE_CANVAS_FIELDS = ['selected', 'dragging', 'extent'];
53
53
  */
54
54
  export const RESOURCE_INPUT_WRITTEN = new Set(['name', 'type', 'id', 'var', 'elementId', 'value', 'required', 'default']);
55
55
  export const RESOURCE_OUTPUT_WRITTEN = new Set(['name', 'type', 'id', 'var', 'originalVar', 'value', 'source', 'target', 'elementId']);
56
+ /**
57
+ * The `name` compile writes on the task output row that reads `source` into
58
+ * `variable` (`emitTaskOutput`): a connector result field's path under
59
+ * `response` (`=response.CreatedBy.Id` is `CreatedBy.Id`), else the path's
60
+ * last segment (`=Decision.output` is `output`, `=APIOutput1` is
61
+ * `APIOutput1`). A `=js:` expression is no field path, so its row is named
62
+ * after the variable it writes: `reworkCount: '=js:(vars.reworkCount || 0) + 1'`
63
+ * is `reworkCount`, not the expression's text after its last dot.
64
+ *
65
+ * The Case Designer names a connector task's extract after the field's path
66
+ * in the response, so one task that reads `CreatedBy.Id`, `Id` and
67
+ * `UpdatedBy.Id` has three rows with three names. The last segment would name
68
+ * all three `Id`.
69
+ *
70
+ * Decompile reads this too: a saved row whose `name` is not this one carries
71
+ * it (`label` on `PreservedOutputRow`).
72
+ */
73
+ export function outputRowName(source, variable) {
74
+ if (source.startsWith('=js:'))
75
+ return variable;
76
+ const path = source.replace(/^=/, '');
77
+ if (path.startsWith('response.') && path.length > 'response.'.length)
78
+ return path.slice('response.'.length);
79
+ return path.split('.').pop() || source;
80
+ }
56
81
  /** Whether `.inputs()` types an input's `required` (a boolean) or `default` (a string, number, boolean or null). */
57
82
  export function isTypedInputField(key, value) {
58
83
  if (key === 'required')
@@ -418,6 +443,8 @@ export function caseJsonPreservationErrors(payload) {
418
443
  errors.push(...customRowShapeErrors(`task "${task.name}" output "${row.name}"`, row.customRow));
419
444
  if (row.savedSource !== undefined && typeof row.savedSource !== 'string')
420
445
  errors.push(`task "${task.name}" output "${row.name}" savedSource must be a string`);
446
+ if (row.label !== undefined && (!row.label || typeof row.label !== 'object' || typeof row.label.source !== 'string' || typeof row.label.var !== 'string'))
447
+ errors.push(`task "${task.name}" output "${row.name}" label must be an object with "source" and "var" strings`);
421
448
  }
422
449
  for (const id of payload.omitTaskDisplayNames ?? [])
423
450
  if (typeof id !== 'string' || id === '')
@@ -9,7 +9,7 @@
9
9
  * name) are resolved here to the generated ids.
10
10
  */
11
11
  import { IdGen, offlineBindingSeed } from './ids.js';
12
- import { CASE_EMPTY_LISTS, isUnrestorableSlotId, METADATA_ABSENT_READING, planElementIds, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint } from './preserve.js';
12
+ import { CASE_EMPTY_LISTS, isUnrestorableSlotId, METADATA_ABSENT_READING, planElementIds, STAGE_EMPTY_LISTS, TASK_EMPTY_LISTS, taskFingerprint, outputRowName } from './preserve.js';
13
13
  import { v31TaskSets } from './task-sets.js';
14
14
  import { camelizeName, defaultActionOutputVar } from './action-output-var.js';
15
15
  import { ACTION_CONTEXT_COPIES, ACTION_FORM_KIND_CONTEXT, ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
@@ -1719,6 +1719,12 @@ function applyPreservedIdentities(result, preservation, warn) {
1719
1719
  if (target && actionRows && row.bodyCopies?.includes('jsonSchema'))
1720
1720
  rowRenames.push(() => { if (target.body !== undefined)
1721
1721
  target.jsonSchema = structuredClone(target.body); });
1722
+ // A resource output saved with its author's label (`label`) gets it back
1723
+ // while it still reads the saved source into the saved variable, before
1724
+ // its carried fields, which go only onto the row of the saved name.
1725
+ const label = row.label;
1726
+ if (target && !actionRows && label && target.source === label.source && target.var === label.var)
1727
+ target.name = row.name;
1722
1728
  carryRowShape(target, row);
1723
1729
  if (!claimRowId(target, row, currentId))
1724
1730
  deferredClaims.push({ target, row });
@@ -3357,7 +3363,7 @@ const OWN_NAME_OUTPUT_ROWS = new WeakSet();
3357
3363
  function emitTaskOutput(o, elementId, ids, seed, resolver) {
3358
3364
  if (o.custom)
3359
3365
  return emitCustomOutput(o, resolver);
3360
- const field = outputRowName(o.source);
3366
+ const field = outputRowName(o.source, o.var);
3361
3367
  // A reassigned row registers the readable companion once (declared vars take
3362
3368
  // precedence in the merge); an own-name row is the variable and registers none.
3363
3369
  const companion = () => {
@@ -4083,23 +4089,6 @@ function isOwnNameOutput(o) {
4083
4089
  // (builder-sdk#1241).
4084
4090
  return keepsOwnSourceName(o.var, o.source);
4085
4091
  }
4086
- /**
4087
- * The `name` of the row that reads `source`: a connector result field's path
4088
- * under `response` (`=response.CreatedBy.Id` is `CreatedBy.Id`), else the
4089
- * path's last segment (`=Decision.output` is `output`, `=APIOutput1` is
4090
- * `APIOutput1`).
4091
- *
4092
- * The Case Designer names a connector task's extract after the field's path
4093
- * in the response, so one task that reads `CreatedBy.Id`, `Id` and
4094
- * `UpdatedBy.Id` has three rows with three names. The last segment would name
4095
- * all three `Id`.
4096
- */
4097
- function outputRowName(source) {
4098
- const path = source.replace(/^=/, '');
4099
- if (path.startsWith('response.') && path.length > 'response.'.length)
4100
- return path.slice('response.'.length);
4101
- return path.split('.').pop() || source;
4102
- }
4103
4092
  /**
4104
4093
  * Whether variable `name` is the own name of the field `source` reads: the
4105
4094
  * path's last segment (`keepsOwnName`, `=response.app_id` into `app_id`), or,
@@ -355,6 +355,8 @@ export declare const REFUSALS: {
355
355
  readonly EVENT_WHERE_NOT_SCALAR: "lowering";
356
356
  readonly EXCEPTION_STAGE_REQUIRED: "lint";
357
357
  readonly EXPR_ARGUMENT_REF: "lint";
358
+ readonly EXPR_BARE_PREFIX: "lint";
359
+ readonly EXPR_BARE_PREFIX_JS_SYNTAX: "lint";
358
360
  readonly EXPR_BARE_VAR_REF: "lint";
359
361
  readonly EXPR_SYNTAX: "lowering";
360
362
  readonly EXPR_UNDECLARED_REF: "lint";
@@ -429,6 +429,8 @@ export const REFUSALS = {
429
429
  EVENT_WHERE_NOT_SCALAR: 'lowering',
430
430
  EXCEPTION_STAGE_REQUIRED: 'lint',
431
431
  EXPR_ARGUMENT_REF: 'lint',
432
+ EXPR_BARE_PREFIX: 'lint',
433
+ EXPR_BARE_PREFIX_JS_SYNTAX: 'lint',
432
434
  EXPR_BARE_VAR_REF: 'lint',
433
435
  EXPR_SYNTAX: 'lowering',
434
436
  EXPR_UNDECLARED_REF: 'lint',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.120.20",
3
+ "version": "6.120.22",
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",
@@ -124,5 +124,5 @@
124
124
  "@types/node": "^22.7.0",
125
125
  "esbuild": "^0.28.1"
126
126
  },
127
- "gitref": "fba3d99fba6ecd89a4f5b85e8d8c09f202e8a53e"
127
+ "gitref": "3631ba8b929fc9aa1c002841bb812003ee4c4d74"
128
128
  }