@uipath/maestro-builder-sdk 6.120.18 → 6.120.19

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.
@@ -20,6 +20,10 @@
20
20
  * are all readable downstream. `nodeDeclaredVars` supplies them; being stricter
21
21
  * than the platform here would reject working processes.
22
22
  *
23
+ * A declared name is not always a readable one: a process input is scoped to its start
24
+ * event and an output to its end event, and a read of either from another element is
25
+ * `EXPR_ARGUMENT_REF` (#2138, `BpmnRoots.args`).
26
+ *
23
27
  * A loop's item binds `iterator.<itemVar>`, and a script output writes `=result.…`
24
28
  * — different namespaces, left alone (only `vars.` is the author's to get wrong).
25
29
  * Variables are SCOPED: a sub-process sees the enclosing variables plus its own.
@@ -20,13 +20,19 @@
20
20
  * are all readable downstream. `nodeDeclaredVars` supplies them; being stricter
21
21
  * than the platform here would reject working processes.
22
22
  *
23
+ * A declared name is not always a readable one: a process input is scoped to its start
24
+ * event and an output to its end event, and a read of either from another element is
25
+ * `EXPR_ARGUMENT_REF` (#2138, `BpmnRoots.args`).
26
+ *
23
27
  * A loop's item binds `iterator.<itemVar>`, and a script output writes `=result.…`
24
28
  * — different namespaces, left alone (only `vars.` is the author's to get wrong).
25
29
  * Variables are SCOPED: a sub-process sees the enclosing variables plus its own.
26
30
  */
27
- import { checkExpression } from '../core/expr-check.js';
28
- import { nodeDeclaredVars } from './declared-vars.js';
31
+ import { checkExpression, extractRefs } from '../core/expr-check.js';
32
+ import { nodeDeclaredVars, publicDeclarationScope } from './declared-vars.js';
29
33
  import { CompileRefusal } from '../core/compile-refusal.js';
34
+ import { tsLiteral } from '../core/ts-literal.js';
35
+ import { isExpressionValue } from './expression-value.js';
30
36
  const NOUN = 'variable';
31
37
  const NAMESPACE = 'vars';
32
38
  const BINDING_NOUN = 'binding';
@@ -36,6 +42,7 @@ function checkExpr(expr, where, roots, out) {
36
42
  return;
37
43
  for (const d of checkExpression(expr, { roots: roots.vars, noun: NOUN, namespace: NAMESPACE }))
38
44
  out.push({ ...d, where });
45
+ argumentReads(expr, where, roots, out);
39
46
  for (const d of checkExpression(expr, { roots: roots.bindings, noun: BINDING_NOUN, namespace: BINDING_NAMESPACE }))
40
47
  out.push({ ...d, where });
41
48
  // A process variable is always read through the `vars` namespace. The bare
@@ -56,7 +63,55 @@ function checkExpr(expr, where, roots, out) {
56
63
  }
57
64
  }
58
65
  /**
59
- * Check every `=`-expression VALUE of a `field → expression` map (keys are targets).
66
+ * Report each read of a process argument — see {@link BpmnRoots.args}. One finding
67
+ * per argument per expression, naming the form that IS readable: the start-event
68
+ * mapping into a process variable for an input, the variable the end event maps from
69
+ * for an output.
70
+ */
71
+ function argumentReads(expr, where, roots, out) {
72
+ if (!roots.args.size)
73
+ return;
74
+ const seen = new Set();
75
+ for (const ref of extractRefs(expr, NAMESPACE)) {
76
+ const arg = roots.args.get(ref.root);
77
+ if (!arg || seen.has(arg.decl.id))
78
+ continue;
79
+ seen.add(arg.decl.id);
80
+ out.push({ level: 'error', code: 'EXPR_ARGUMENT_REF', message: argumentMessage(ref.root, arg), where });
81
+ }
82
+ }
83
+ function argumentMessage(root, { decl, scope }) {
84
+ const type = typeof decl.type === 'string' ? decl.type : 'string';
85
+ if (decl.direction === 'output') {
86
+ return (`\`vars.${root}\` reads process output \`${decl.id}\`, which is scoped to \`${scope}\` and only ` +
87
+ `written by its mapping: Studio Web reports "A variable is unresolved" on a read of it, and ` +
88
+ `\`validate\` reports VARIABLE_DOES_NOT_EXIST. Compute the value into a \`.var()\`, read that variable here, ` +
89
+ `and map it onto \`${decl.id}\` in \`${scope}\`'s payload.`);
90
+ }
91
+ const local = `${decl.id}In`;
92
+ return (`\`vars.${root}\` reads process input \`${decl.id}\`, which is scoped to \`${scope}\`: Studio Web ` +
93
+ `reports "A variable is unresolved" on a read of it from any other element, and \`validate\` reports ` +
94
+ `VARIABLE_NOT_SET (the engine runs it; the designer does not accept it). Map it, as the canvas ` +
95
+ `does, into a variable scoped to that start event and read the variable: ` +
96
+ `\`.var(${tsLiteral(local)}, ${tsLiteral(type)}, { elementId: ${tsLiteral(scope)} })\` and ` +
97
+ `\`.startEvent(${tsLiteral(scope)}, { payload: { type: ` +
98
+ `'BPMN.Variables', outputRows: [{ name: ${tsLiteral(decl.name)}, type: ${tsLiteral(type)}, ` +
99
+ `source: ${tsLiteral(`=vars.${decl.id}`)}, var: ${tsLiteral(local)} }] } })\`, then read \`=vars.${local}\`.`);
100
+ }
101
+ /** What a field's string values are, which decides which of them `checkExprValues` checks. */
102
+ var FieldValues;
103
+ (function (FieldValues) {
104
+ /** Every string is an expression and is checked: a script task's `outputs`, expressions against the result. */
105
+ FieldValues[FieldValues["Expressions"] = 0] = "Expressions";
106
+ /**
107
+ * A string is an expression only when `isExpressionValue` says so, the same rule
108
+ * `serialize` applies; literal text is not a read. `.task({ set })` and a script task's
109
+ * `inputs`: `set: { label: 'vars.amount' }` assigns the text "vars.amount".
110
+ */
111
+ FieldValues[FieldValues["LiteralOrExpression"] = 1] = "LiteralOrExpression";
112
+ })(FieldValues || (FieldValues = {}));
113
+ /**
114
+ * Check every expression VALUE of a `field → value` map (keys are targets), as `kind` says.
60
115
  *
61
116
  * A value need not be a string. A script task's `inputs` are the keys of its `args`
62
117
  * JSON body, and the designer nests objects there (`{"args":{"name":"=vars.x"}}`), so
@@ -64,10 +119,12 @@ function checkExpr(expr, where, roots, out) {
64
119
  * Handing it to `checkExpr` as if it were a string is what crashed `build()` with
65
120
  * `expr.replace is not a function` on six deployed processes.
66
121
  */
67
- function checkExprValues(rec, where, roots, out) {
122
+ function checkExprValues(rec, where, roots, out, kind) {
68
123
  for (const v of Object.values(rec ?? {})) {
69
- if (typeof v === 'string')
70
- checkExpr(v, where, roots, out);
124
+ if (typeof v === 'string') {
125
+ if (kind === FieldValues.Expressions || isExpressionValue(v))
126
+ checkExpr(v, where, roots, out);
127
+ }
71
128
  else
72
129
  deepExprStrings(v, where, roots, out);
73
130
  }
@@ -75,7 +132,7 @@ function checkExprValues(rec, where, roots, out) {
75
132
  /** Reach `=`-expression strings anywhere in a connector's (possibly nested) inputs. */
76
133
  function deepExprStrings(val, where, roots, out) {
77
134
  if (typeof val === 'string') {
78
- if (val.startsWith('='))
135
+ if (isExpressionValue(val))
79
136
  checkExpr(val, where, roots, out);
80
137
  return;
81
138
  }
@@ -96,10 +153,13 @@ function walk(nodes, flows, rootsIn, out) {
96
153
  // script task's output, a variable task's assignment target. Collect them for
97
154
  // the WHOLE scope before walking: a flow condition is checked first but may
98
155
  // read a node declared later in authoring order.
99
- const roots = { vars: new Set(rootsIn.vars), varIds: rootsIn.varIds, bindings: rootsIn.bindings };
156
+ const roots = { ...rootsIn, vars: new Set(rootsIn.vars), args: new Map(rootsIn.args) };
100
157
  for (const n of nodes)
101
- for (const name of nodeDeclaredVars(n))
158
+ for (const name of nodeDeclaredVars(n)) {
102
159
  roots.vars.add(name);
160
+ // A node writing that name makes it readable, whatever else declares it.
161
+ roots.args.delete(name);
162
+ }
103
163
  for (const f of flows) {
104
164
  const found = [];
105
165
  checkExpr(f.condition, `flow "${f.id}" condition`, roots, found);
@@ -142,7 +202,7 @@ function walkNode(n, roots, located) {
142
202
  // `error` joins `vars` (so `vars.error` resolves) but NOT `varIds`: it is a
143
203
  // scoped runtime binding, not a declared variable, so `=error` is not a bare
144
204
  // spelling of one.
145
- const errRoots = { vars: new Set(roots.vars).add('error'), varIds: roots.varIds, bindings: roots.bindings };
205
+ const errRoots = { ...roots, vars: new Set(roots.vars).add('error') };
146
206
  for (const row of ('errorMapping' in n ? n.errorMapping : undefined) ?? []) {
147
207
  checkExpr(row.condition, `${at} errorMapping "${row.code}" condition`, errRoots, out);
148
208
  }
@@ -156,19 +216,15 @@ function walkNode(n, roots, located) {
156
216
  checkExpr(n.loop.collection, `${at} loop collection`, roots, out);
157
217
  // The iterator bindings (`iterator.item`, `iterator.<itemVar>`) are the loop's
158
218
  // own, not author declarations, so a completion condition may read them.
159
- const loopRoots = {
160
- vars: new Set(roots.vars).add('iterator'),
161
- varIds: roots.varIds,
162
- bindings: roots.bindings,
163
- };
219
+ const loopRoots = { ...roots, vars: new Set(roots.vars).add('iterator') };
164
220
  checkExpr(n.loop.completion, `${at} loop completion`, loopRoots, out);
165
221
  }
166
222
  if (n.kind === 'scriptTask') {
167
- checkExprValues(n.inputs, `${at} input`, roots, out);
168
- checkExprValues(n.outputs, `${at} output`, roots, out);
223
+ checkExprValues(n.inputs, `${at} input`, roots, out, FieldValues.LiteralOrExpression);
224
+ checkExprValues(n.outputs, `${at} output`, roots, out, FieldValues.Expressions);
169
225
  }
170
226
  else if (n.kind === 'task') {
171
- checkExprValues(n.set, `${at} assignment`, roots, out);
227
+ checkExprValues(n.set, `${at} assignment`, roots, out, FieldValues.LiteralOrExpression);
172
228
  }
173
229
  else if (n.kind === 'connector') {
174
230
  deepExprStrings(n.inputs, `${at} input`, roots, out);
@@ -178,7 +234,9 @@ function walkNode(n, roots, located) {
178
234
  // plus the ones it declares. The loop COLLECTION is evaluated in the
179
235
  // enclosing scope (before entry); the body and completion see the sub-scope.
180
236
  checkExpr(n.loop?.collection, `${at} loop collection`, roots, out);
181
- const subRoots = { vars: new Set(roots.vars), varIds: new Set(roots.varIds), bindings: roots.bindings };
237
+ // Only the process's own arguments are reported: a sub-process's declarations,
238
+ // whatever their direction, are left to the platform's own scoping.
239
+ const subRoots = { ...roots, vars: new Set(roots.vars), varIds: new Set(roots.varIds), args: new Map(roots.args) };
182
240
  // By ID as well as display name, exactly as the root scope below: an expression
183
241
  // reads `vars.<id>`. This added the name alone, so a sub-process variable whose
184
242
  // display name differed from its id — every `errorVar`, displayed as `Error` —
@@ -187,6 +245,8 @@ function walkNode(n, roots, located) {
187
245
  subRoots.vars.add(v.id);
188
246
  subRoots.vars.add(v.name);
189
247
  subRoots.varIds.add(v.id);
248
+ subRoots.args.delete(v.id);
249
+ subRoots.args.delete(v.name);
190
250
  }
191
251
  checkExpr(n.loop?.completion, `${at} loop completion`, subRoots, out);
192
252
  flush();
@@ -220,11 +280,41 @@ export function checkBpmnExpressions(built) {
220
280
  // connector turns into bindings at serialize time — the author's own spelling
221
281
  // is what they would reference, so both are legitimate roots.
222
282
  bindings: new Set([...built.bindings.map((b) => b.id), ...connectorBindingNames(built.nodes)]),
283
+ args: processArguments(built),
223
284
  };
224
285
  const out = [];
225
286
  walk(built.nodes, built.flows, roots, out);
226
287
  return out;
227
288
  }
289
+ /**
290
+ * The top-level arguments no expression may read — see {@link BpmnRoots.args}.
291
+ *
292
+ * An argument is one only where it is SCOPED TO AN ELEMENT: its `elementId`, or the
293
+ * element `publicDeclarationScope` writes for it (the manual start event for an input,
294
+ * the end event that writes an output). One scoped to the process itself is root state
295
+ * to `validate`, which counts every declaration whose `elementId` is the process as
296
+ * available everywhere, so it is left alone, as is one written with no `elementId` at
297
+ * all (`null`, a legacy import), which `validate` already reports as missing.
298
+ *
299
+ * Keyed by id and by display name, as `vars` is. A spelling an internal variable
300
+ * shares is left out: the canvas resolves the reference to that variable.
301
+ */
302
+ function processArguments(built) {
303
+ const scopeOf = publicDeclarationScope(built.nodes, built.id);
304
+ const readable = new Set(built.variables.filter((v) => v.direction === 'inputOutput').flatMap((v) => [v.id, v.name]));
305
+ const args = new Map();
306
+ for (const v of built.variables) {
307
+ if (v.direction === 'inputOutput' || v.elementId === null)
308
+ continue;
309
+ const scope = v.elementId ?? scopeOf(v);
310
+ if (scope === built.id)
311
+ continue;
312
+ for (const key of [v.id, v.name])
313
+ if (!readable.has(key) && !args.has(key))
314
+ args.set(key, { decl: v, scope });
315
+ }
316
+ return args;
317
+ }
228
318
  /** Every symbolic connection/folder name in a graph, at any nesting depth. */
229
319
  function connectorBindingNames(nodes) {
230
320
  const out = [];
@@ -1938,9 +1938,13 @@ export interface VarOpts {
1938
1938
  * the process's manual START event and a top-level `.output()` to the END event
1939
1939
  * whose mapping writes it (or the only end event): that is how every Studio Web
1940
1940
  * export and converter output declares a process's public contract, and what the
1941
- * canvas, the entry-point derivation and the graders read it from. The engine itself
1942
- * resolves `vars.<id>` by id whatever the scope, so a script may read an input
1943
- * directly with no start-event bridge. `uip maestro bpmn validate` (1.203+) requires
1941
+ * canvas, the entry-point derivation and the graders read it from. It also decides
1942
+ * who may READ it: an input scoped to the start event is readable only by that start
1943
+ * event's own mapping, and an output by nobody. The engine resolves `vars.<id>` by id
1944
+ * whatever the scope, so a direct read runs, but Studio Web shows "A variable is
1945
+ * unresolved" on it and `validate` reports `VARIABLE_NOT_SET`; `check` reports it as
1946
+ * `EXPR_ARGUMENT_REF`. Map an input, on the start event, into a `.var()` scoped to that
1947
+ * start event and read the variable, as the canvas does (see `.input()`). `uip maestro bpmn validate` (1.203+) requires
1944
1948
  * SOME `elementId`: a declaration with none is `ROOT_VARIABLE_MISSING_ELEMENT_ID`,
1945
1949
  * and every `vars.<id>` read of it fails `VARIABLE_DOES_NOT_EXIST`. Name an element
1946
1950
  * to scope the variable to it explicitly (the node whose output fills it, a specific
@@ -3495,7 +3499,26 @@ declare abstract class ScopeBuilder {
3495
3499
  */
3496
3500
  var(id: string, type: BpmnVarType, opts?: VarOpts): this;
3497
3501
  /**
3498
- * A read-only entry input (`uipath:input`).
3502
+ * A read-only entry input (`uipath:input`), scoped to the manual start event.
3503
+ *
3504
+ * Only the start event's own mapping reads it. Every other element reads the variable
3505
+ * that mapping copies it into, scoped to the start event — which is what Studio Web
3506
+ * writes when an input is added on the canvas: a
3507
+ * `vars.<input>` read anywhere else is "A variable is unresolved" on the canvas, and
3508
+ * `check` reports it as `EXPR_ARGUMENT_REF`.
3509
+ *
3510
+ * ```ts
3511
+ * bpmn('approve')
3512
+ * .input('amount', 'number')
3513
+ * .var('amountIn', 'number', { elementId: 'start' })
3514
+ * .startEvent('start', {
3515
+ * payload: {
3516
+ * type: 'BPMN.Variables',
3517
+ * outputRows: [{ name: 'amount', type: 'number', source: '=vars.amount', var: 'amountIn' }],
3518
+ * },
3519
+ * })
3520
+ * // downstream: '=vars.amountIn > 1000', never '=vars.amount > 1000'
3521
+ * ```
3499
3522
  *
3500
3523
  * @param id - The input's name.
3501
3524
  * @param type - A `types.*` descriptor, or another product spelling ({@link BpmnVarType}).
@@ -2468,7 +2468,26 @@ class ScopeBuilder {
2468
2468
  return this.declareVar(id, type, 'inputOutput', opts);
2469
2469
  }
2470
2470
  /**
2471
- * A read-only entry input (`uipath:input`).
2471
+ * A read-only entry input (`uipath:input`), scoped to the manual start event.
2472
+ *
2473
+ * Only the start event's own mapping reads it. Every other element reads the variable
2474
+ * that mapping copies it into, scoped to the start event — which is what Studio Web
2475
+ * writes when an input is added on the canvas: a
2476
+ * `vars.<input>` read anywhere else is "A variable is unresolved" on the canvas, and
2477
+ * `check` reports it as `EXPR_ARGUMENT_REF`.
2478
+ *
2479
+ * ```ts
2480
+ * bpmn('approve')
2481
+ * .input('amount', 'number')
2482
+ * .var('amountIn', 'number', { elementId: 'start' })
2483
+ * .startEvent('start', {
2484
+ * payload: {
2485
+ * type: 'BPMN.Variables',
2486
+ * outputRows: [{ name: 'amount', type: 'number', source: '=vars.amount', var: 'amountIn' }],
2487
+ * },
2488
+ * })
2489
+ * // downstream: '=vars.amountIn > 1000', never '=vars.amount > 1000'
2490
+ * ```
2472
2491
  *
2473
2492
  * @param id - The input's name.
2474
2493
  * @param type - A `types.*` descriptor, or another product spelling ({@link BpmnVarType}).
@@ -5,7 +5,7 @@
5
5
  * It lives outside `bpmn-sdk.ts` so the checker does not import the builder back
6
6
  * (the runtime import cycle FB003 reported).
7
7
  */
8
- import type { BpmnNode } from './bpmn-sdk.js';
8
+ import type { BpmnNode, BpmnVarDecl } from './bpmn-sdk.js';
9
9
  /**
10
10
  * The variables a connector task's output rows land in.
11
11
  *
@@ -58,3 +58,32 @@ export declare function typedNodeDeclaredVars(n: Extract<BpmnNode, {
58
58
  * @internal
59
59
  */
60
60
  export declare function nodeDeclaredVars(n: BpmnNode): string[];
61
+ /**
62
+ * Where an unscoped PUBLIC declaration belongs at the top level of a process.
63
+ *
64
+ * Every real artifact agrees: across the 97 Studio Web exports and converter outputs
65
+ * measured (`research/bpmn-roundtrip/corpus/`, the run-6 `v1` arm), all 107 public
66
+ * `uipath:input` declarations are scoped to the process's manual START event and all
67
+ * 37 `uipath:output` declarations to the END event whose mapping writes them — none to
68
+ * the process. The engine does not need it (`BpmnDataManager.EvaluateProcessVariables`
69
+ * seeds every declaration into one variables scope by id, and an expression resolves
70
+ * `vars.<id>` there whatever the declaration's `elementId`), but the canvas, the
71
+ * entry-point derivation and the graders that read a process's contract do: a process
72
+ * input is "the start event's input". Until this, the SDK wrote the process id, which
73
+ * validated and ran and was the one placement nothing else on the platform produces —
74
+ * cluster D of docs/BPMN_AUTHORING_ERGONOMICS_DESIGN.md §1b.
75
+ *
76
+ * Shared by the serializer, which writes it, and the expression check, which needs to
77
+ * know where a public argument is readable from (#2138).
78
+ *
79
+ * The rule, mirrored by `bpmn-decompile` so an unscoped declaration round-trips without
80
+ * an explicit `elementId`:
81
+ * - `input` → the one root start event with no event definition and no trigger,
82
+ * when there is exactly one; else the process.
83
+ * - `output` → the one root end event whose payload writes `var="<id>"`; else the one
84
+ * root end event, when there is exactly one; else the process.
85
+ * - `inputOutput` → the process (an internal variable is process-level state; the
86
+ * engine's debug variables report lists exactly those).
87
+ * An explicit `elementId` always wins, and `null` still means "write none".
88
+ */
89
+ export declare function publicDeclarationScope(nodes: BpmnNode[], processId: string): (v: BpmnVarDecl) => string;
@@ -80,3 +80,46 @@ export function nodeDeclaredVars(n) {
80
80
  return Object.keys(n.set);
81
81
  return [];
82
82
  }
83
+ /**
84
+ * Where an unscoped PUBLIC declaration belongs at the top level of a process.
85
+ *
86
+ * Every real artifact agrees: across the 97 Studio Web exports and converter outputs
87
+ * measured (`research/bpmn-roundtrip/corpus/`, the run-6 `v1` arm), all 107 public
88
+ * `uipath:input` declarations are scoped to the process's manual START event and all
89
+ * 37 `uipath:output` declarations to the END event whose mapping writes them — none to
90
+ * the process. The engine does not need it (`BpmnDataManager.EvaluateProcessVariables`
91
+ * seeds every declaration into one variables scope by id, and an expression resolves
92
+ * `vars.<id>` there whatever the declaration's `elementId`), but the canvas, the
93
+ * entry-point derivation and the graders that read a process's contract do: a process
94
+ * input is "the start event's input". Until this, the SDK wrote the process id, which
95
+ * validated and ran and was the one placement nothing else on the platform produces —
96
+ * cluster D of docs/BPMN_AUTHORING_ERGONOMICS_DESIGN.md §1b.
97
+ *
98
+ * Shared by the serializer, which writes it, and the expression check, which needs to
99
+ * know where a public argument is readable from (#2138).
100
+ *
101
+ * The rule, mirrored by `bpmn-decompile` so an unscoped declaration round-trips without
102
+ * an explicit `elementId`:
103
+ * - `input` → the one root start event with no event definition and no trigger,
104
+ * when there is exactly one; else the process.
105
+ * - `output` → the one root end event whose payload writes `var="<id>"`; else the one
106
+ * root end event, when there is exactly one; else the process.
107
+ * - `inputOutput` → the process (an internal variable is process-level state; the
108
+ * engine's debug variables report lists exactly those).
109
+ * An explicit `elementId` always wins, and `null` still means "write none".
110
+ */
111
+ export function publicDeclarationScope(nodes, processId) {
112
+ const manualStarts = nodes.filter((n) => n.kind === 'startEvent' && n.event === undefined && n.trigger === undefined);
113
+ const ends = nodes.filter((n) => n.kind === 'endEvent');
114
+ return (v) => {
115
+ if (v.direction === 'input')
116
+ return manualStarts.length === 1 ? manualStarts[0].id : processId;
117
+ if (v.direction === 'output') {
118
+ const writers = ends.filter((e) => (e.payload?.outputRows ?? []).some((r) => r.var === v.id));
119
+ if (writers.length === 1)
120
+ return writers[0].id;
121
+ return ends.length === 1 ? ends[0].id : processId;
122
+ }
123
+ return processId;
124
+ };
125
+ }
@@ -1176,7 +1176,17 @@ function publicDeclarationScopeOf(process, processId) {
1176
1176
  // payload — manual to this side, not manual to the emitter. The round trip then moved
1177
1177
  // a public input's `elementId` from the trigger start to the process. Excluding ANY
1178
1178
  // typed payload makes the two agree for every shape the SDK can emit.
1179
- const manualStarts = elements.filter((el) => el.$type === 'bpmn:StartEvent' && !(el.eventDefinitions ?? []).length && payloadOf(el) === undefined);
1179
+ //
1180
+ // A `uipath:mapping` is not a typed payload: it is the `BPMN.Variables` mapping a
1181
+ // manual start carries to copy its inputs into process variables (the canvas's own
1182
+ // shape, and the only element allowed to read an input — #2138). It decompiles to
1183
+ // `.startEvent(id, { payload })`, which the emitter counts as manual, so it is one here.
1184
+ const manualStarts = elements.filter((el) => {
1185
+ if (el.$type !== 'bpmn:StartEvent' || (el.eventDefinitions ?? []).length)
1186
+ return false;
1187
+ const payload = payloadOf(el);
1188
+ return payload === undefined || payload.$type === 'uipath:Mapping';
1189
+ });
1180
1190
  const ends = elements.filter((el) => el.$type === 'bpmn:EndEvent');
1181
1191
  return (kind, v) => {
1182
1192
  if (kind === 'input')
@@ -0,0 +1,16 @@
1
+ /**
2
+ * expression-value — whether a value-or-expression field holds an expression.
3
+ *
4
+ * Some BPMN fields take either an `=`-expression or a literal: a `.task({ set })`
5
+ * value and a script task's `inputs` value. The rule for both is the one the
6
+ * serializer applies: a string starting with `=` is an expression, anything else is
7
+ * literal text. `serialize` writes a literal `set` value as `=js:"<text>"`
8
+ * (`assignmentSource`), and a literal script input as a JSON string in the `args`
9
+ * body. Neither reads a variable.
10
+ *
11
+ * `serialize` and `bpmn-expr-check` both call this, so the check reports a variable
12
+ * read only where the emitted artifact reads one. For example, `set: { label:
13
+ * 'vars.amount' }` assigns the text "vars.amount" and is not checked as a read.
14
+ */
15
+ /** True when `value` is an `=`-expression, false when it is literal text. */
16
+ export declare function isExpressionValue(value: string): boolean;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * expression-value — whether a value-or-expression field holds an expression.
3
+ *
4
+ * Some BPMN fields take either an `=`-expression or a literal: a `.task({ set })`
5
+ * value and a script task's `inputs` value. The rule for both is the one the
6
+ * serializer applies: a string starting with `=` is an expression, anything else is
7
+ * literal text. `serialize` writes a literal `set` value as `=js:"<text>"`
8
+ * (`assignmentSource`), and a literal script input as a JSON string in the `args`
9
+ * body. Neither reads a variable.
10
+ *
11
+ * `serialize` and `bpmn-expr-check` both call this, so the check reports a variable
12
+ * read only where the emitted artifact reads one. For example, `set: { label:
13
+ * 'vars.amount' }` assigns the text "vars.amount" and is not checked as a read.
14
+ */
15
+ /** True when `value` is an `=`-expression, false when it is literal text. */
16
+ export function isExpressionValue(value) {
17
+ return value.startsWith('=');
18
+ }
@@ -181,32 +181,6 @@ export declare function implicitNodeVars(nodes: BpmnNode[], declared: BpmnVarDec
181
181
  * An explicit `resourceKey` on the declaration is never overridden.
182
182
  */
183
183
  export declare function folderCompanionKeys(built: BuiltBpmn, sink: Map<string, Record<string, unknown>>): Map<string, string>;
184
- /**
185
- * Where an unscoped PUBLIC declaration belongs at the top level of a process.
186
- *
187
- * Every real artifact agrees: across the 97 Studio Web exports and converter outputs
188
- * measured (`research/bpmn-roundtrip/corpus/`, the run-6 `v1` arm), all 107 public
189
- * `uipath:input` declarations are scoped to the process's manual START event and all
190
- * 37 `uipath:output` declarations to the END event whose mapping writes them — none to
191
- * the process. The engine does not need it (`BpmnDataManager.EvaluateProcessVariables`
192
- * seeds every declaration into one variables scope by id, and an expression resolves
193
- * `vars.<id>` there whatever the declaration's `elementId`), but the canvas, the
194
- * entry-point derivation and the graders that read a process's contract do: a process
195
- * input is "the start event's input". Until this, the SDK wrote the process id, which
196
- * validated and ran and was the one placement nothing else on the platform produces —
197
- * cluster D of docs/BPMN_AUTHORING_ERGONOMICS_DESIGN.md §1b.
198
- *
199
- * The rule, mirrored by `bpmn-decompile` so an unscoped declaration round-trips without
200
- * an explicit `elementId`:
201
- * - `input` → the one root start event with no event definition and no trigger,
202
- * when there is exactly one; else the process.
203
- * - `output` → the one root end event whose payload writes `var="<id>"`; else the one
204
- * root end event, when there is exactly one; else the process.
205
- * - `inputOutput` → the process (an internal variable is process-level state; the
206
- * engine's debug variables report lists exactly those).
207
- * An explicit `elementId` always wins, and `null` still means "write none".
208
- */
209
- export declare function publicDeclarationScope(nodes: BpmnNode[], processId: string): (v: BpmnVarDecl) => string;
210
184
  /** Flatten a scope's nodes (recursing sub-processes) for global scans. */
211
185
  export declare function allNodes(nodes: BpmnNode[]): BpmnNode[];
212
186
  export {};
@@ -21,8 +21,9 @@ import { createConnectorEvent, createExternalTask } from './intsvc.js';
21
21
  import { connectorEventErrorVar, intsvcOutputVar } from './intsvc-vars.js';
22
22
  import { IMPLICIT_CONNECTION } from './managed-http.js';
23
23
  import { createExtensionPayload, createTypedNode, rowDeclaration, typedNodeOutputVar, verbatimOutputRows } from './typed-node.js';
24
- import { connectorOutputVars, nodeDeclaredVars, typedNodeDeclaredVars } from './declared-vars.js';
24
+ import { connectorOutputVars, nodeDeclaredVars, publicDeclarationScope, typedNodeDeclaredVars } from './declared-vars.js';
25
25
  import { defaultEntryPointId } from './entry-point-id.js';
26
+ import { isExpressionValue } from './expression-value.js';
26
27
  import { parseXmlRanges } from './xml-ranges.js';
27
28
  import { ownEntry } from '../core/own-entry.js';
28
29
  import { CompileRefusal } from '../core/compile-refusal.js';
@@ -1130,7 +1131,7 @@ function outputRows(ctx, map, custom = false) {
1130
1131
  * too, since JSON permits them raw and only ES2019+ accepts them in a literal.
1131
1132
  */
1132
1133
  function assignmentSource(value) {
1133
- if (value.startsWith('='))
1134
+ if (isExpressionValue(value))
1134
1135
  return value;
1135
1136
  // Escape sequences, not the raw characters, so the regexes survive an editor.
1136
1137
  const literal = JSON.stringify(value).replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
@@ -1437,46 +1438,6 @@ function orderVars(vars, order) {
1437
1438
  .sort((a, b) => a.r - b.r || a.i - b.i)
1438
1439
  .map((e) => e.v);
1439
1440
  }
1440
- /**
1441
- * Where an unscoped PUBLIC declaration belongs at the top level of a process.
1442
- *
1443
- * Every real artifact agrees: across the 97 Studio Web exports and converter outputs
1444
- * measured (`research/bpmn-roundtrip/corpus/`, the run-6 `v1` arm), all 107 public
1445
- * `uipath:input` declarations are scoped to the process's manual START event and all
1446
- * 37 `uipath:output` declarations to the END event whose mapping writes them — none to
1447
- * the process. The engine does not need it (`BpmnDataManager.EvaluateProcessVariables`
1448
- * seeds every declaration into one variables scope by id, and an expression resolves
1449
- * `vars.<id>` there whatever the declaration's `elementId`), but the canvas, the
1450
- * entry-point derivation and the graders that read a process's contract do: a process
1451
- * input is "the start event's input". Until this, the SDK wrote the process id, which
1452
- * validated and ran and was the one placement nothing else on the platform produces —
1453
- * cluster D of docs/BPMN_AUTHORING_ERGONOMICS_DESIGN.md §1b.
1454
- *
1455
- * The rule, mirrored by `bpmn-decompile` so an unscoped declaration round-trips without
1456
- * an explicit `elementId`:
1457
- * - `input` → the one root start event with no event definition and no trigger,
1458
- * when there is exactly one; else the process.
1459
- * - `output` → the one root end event whose payload writes `var="<id>"`; else the one
1460
- * root end event, when there is exactly one; else the process.
1461
- * - `inputOutput` → the process (an internal variable is process-level state; the
1462
- * engine's debug variables report lists exactly those).
1463
- * An explicit `elementId` always wins, and `null` still means "write none".
1464
- */
1465
- export function publicDeclarationScope(nodes, processId) {
1466
- const manualStarts = nodes.filter((n) => n.kind === 'startEvent' && n.event === undefined && n.trigger === undefined);
1467
- const ends = nodes.filter((n) => n.kind === 'endEvent');
1468
- return (v) => {
1469
- if (v.direction === 'input')
1470
- return manualStarts.length === 1 ? manualStarts[0].id : processId;
1471
- if (v.direction === 'output') {
1472
- const writers = ends.filter((e) => (e.payload?.outputRows ?? []).some((r) => r.var === v.id));
1473
- if (writers.length === 1)
1474
- return writers[0].id;
1475
- return ends.length === 1 ? ends[0].id : processId;
1476
- }
1477
- return processId;
1478
- };
1479
- }
1480
1441
  // ─── Small helpers ────────────────────────────────────────────────────────────
1481
1442
  function cap(s) {
1482
1443
  return s.charAt(0).toUpperCase() + s.slice(1);
package/dist/bpmn-api.md CHANGED
@@ -95,7 +95,7 @@ The set of node/flow/variable methods common to the process root and every sub-p
95
95
  - `ScopeBuilder.flowIds(entries: PinnedFlowId[]): this` — Give the edges the nesting constructs IMPLY the ids you choose.
96
96
  - `ScopeBuilder.sequenceFlow(source: string, target: string, opts?: FlowOpts): this` — A sequence flow from `source` to `target` (1-1 with `bpmn:sequenceFlow`).
97
97
  - `ScopeBuilder.var(id: string, type: BpmnVarType, opts?: VarOpts): this` — A mutable flow variable (`uipath:inputOutput`).
98
- - `ScopeBuilder.input(id: string, type: BpmnVarType, opts?: VarOpts): this` — A read-only entry input (`uipath:input`).
98
+ - `ScopeBuilder.input(id: string, type: BpmnVarType, opts?: VarOpts): this` — A read-only entry input (`uipath:input`), scoped to the manual start event.
99
99
  - `ScopeBuilder.output(id: string, type: BpmnVarType, opts?: VarOpts): this` — A return value (`uipath:output`).
100
100
  - `ScopeBuilder.vars(entries: VarEntry[]): this` — Several declarations as one call — the array form of `.var()` / `.input()` / `.output()`.
101
101
 
@@ -479,7 +479,7 @@ What every ACTIVITY accepts, on top of its own options — a script task, a vari
479
479
  - `ConnectorOpts.version?: string` — Connector action version (defaults to the library's newest match).
480
480
  - `ConnectorOpts.connection?: string` — Symbolic connection name declared in bindings.json (→ ConnectionId).
481
481
  - `ConnectorOpts.folder?: string` — Symbolic folder name declared in bindings.json (→ connectionFolderKey).
482
- - `ConnectorOpts.object?: string` — Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List All Records" on `'acr_user'`, NetSuite's "Get…
482
+ - `ConnectorOpts.object?: string` — Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List Records" on `'acr_user'`, NetSuite's "Get…
483
483
  - `ConnectorOpts.carried?: CarriedConnectorOperation` — Flow only, and written by decompile, not by an author: the `.flow` file's own description of an operation the connector…
484
484
 
485
485
  ### `HumanTaskAppOpts`
@@ -24,7 +24,7 @@ export interface ConnectorOpts {
24
24
  /** Symbolic folder name declared in bindings.json (→ connectionFolderKey). Required with `connection`. */
25
25
  folder?: string;
26
26
  /**
27
- * Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List All
27
+ * Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List
28
28
  * Records" on `'acr_user'`, NetSuite's "Get Record" on `'AccountingPeriod'`.
29
29
  *
30
30
  * A generic (`GenericExpanded`) operation encodes only the VERB in its node
@@ -37,7 +37,7 @@ export interface ConnectorOpts {
37
37
  * sorted first, silently.
38
38
  *
39
39
  * ```ts
40
- * connector('uipath-servicenow-servicenow', 'list-all-records', {},
40
+ * connector('uipath-servicenow-servicenow', 'list-records', {},
41
41
  * { connection: 'servicenow', folder: 'shared', object: 'acr_user' })
42
42
  * ```
43
43
  *
@@ -50,6 +50,13 @@ export interface ListEnvelopeRow {
50
50
  * a dispatcher that needs to normalise between the CLI and the platform.
51
51
  */
52
52
  cliShape?: string;
53
+ /**
54
+ * Set on a row whose `nodeType` the current library no longer serves (the
55
+ * operation was renamed and the measurement re-keyed). Readers still match
56
+ * it, for libraries built before the rename; `checkCuratedOverlay` does not
57
+ * require the library to carry it.
58
+ */
59
+ keyRetired?: string;
53
60
  }
54
61
  /**
55
62
  * Every declared row, from `<libraryDir>/list-envelopes.json`. An absent file is
@@ -354,6 +354,7 @@ export declare const REFUSALS: {
354
354
  readonly EVENT_UNPREPARED: "lint";
355
355
  readonly EVENT_WHERE_NOT_SCALAR: "lowering";
356
356
  readonly EXCEPTION_STAGE_REQUIRED: "lint";
357
+ readonly EXPR_ARGUMENT_REF: "lint";
357
358
  readonly EXPR_BARE_VAR_REF: "lint";
358
359
  readonly EXPR_SYNTAX: "lowering";
359
360
  readonly EXPR_UNDECLARED_REF: "lint";
@@ -428,6 +428,7 @@ export const REFUSALS = {
428
428
  EVENT_UNPREPARED: 'lint',
429
429
  EVENT_WHERE_NOT_SCALAR: 'lowering',
430
430
  EXCEPTION_STAGE_REQUIRED: 'lint',
431
+ EXPR_ARGUMENT_REF: 'lint',
431
432
  EXPR_BARE_VAR_REF: 'lint',
432
433
  EXPR_SYNTAX: 'lowering',
433
434
  EXPR_UNDECLARED_REF: 'lint',