@uipath/maestro-builder-sdk 6.93.6 → 6.93.8
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.
- package/dist/api-index.md +53 -53
- package/dist/api-members.md +238 -238
- package/dist/bpmn/bpmn-sdk.d.ts +25 -7
- package/dist/bpmn/bpmn-sdk.js +17 -2
- package/dist/bpmn/check.d.ts +0 -17
- package/dist/bpmn/check.js +220 -0
- package/dist/bpmn/decompile.js +26 -11
- package/dist/bpmn-api.md +1 -1
- package/dist/core/refusals.d.ts +3 -0
- package/dist/core/refusals.js +3 -0
- package/package.json +2 -2
package/dist/bpmn/bpmn-sdk.d.ts
CHANGED
|
@@ -964,6 +964,9 @@ export interface ScriptTaskOpts extends ActivityOpts {
|
|
|
964
964
|
* PO.BpmnEngine returns `{ "response": <whatever the script returned> }` when
|
|
965
965
|
* `IsVersionAtLeast(version, 2)`. So the script may return any JSON value and
|
|
966
966
|
* `=result.response` is that value; `=result.Error` is its error slot.
|
|
967
|
+
* `check` reports a row on a v2-or-later task that reads `result` any other way
|
|
968
|
+
* (`=result.severity`, `=result`) as `SCRIPT_RESULT_NOT_RESPONSE`, with the
|
|
969
|
+
* corrected expression (`=result.response.severity`).
|
|
967
970
|
*
|
|
968
971
|
* Only a v1 script task spreads the return object's fields, and it must return an
|
|
969
972
|
* object or the activity throws. This SDK does not emit v1.
|
|
@@ -1009,13 +1012,23 @@ export interface ScriptTaskOpts extends ActivityOpts {
|
|
|
1009
1012
|
* is anything else. `uip maestro bpmn validate` accepts both, so nothing in the
|
|
1010
1013
|
* toolchain catches the wrong one — which is why the SDK emitted it for so long.
|
|
1011
1014
|
*
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1015
|
+
* Any other value replaces the script's extension type, so the script never runs
|
|
1016
|
+
* and its outputs read back null — and `uip maestro bpmn validate` and a live
|
|
1017
|
+
* debug both still pass. So `.scriptTask()` refuses every value but
|
|
1018
|
+
* `BPMN.Variables` with `BPMN_SCRIPT_TASK_TYPE_INVALID`, the same way
|
|
1019
|
+
* `.plainTask()` refuses an element it cannot emit. `uip maestro bpmn registry get
|
|
1020
|
+
* BPMN.ScriptTask` lists `BPMN.ScriptTask`; do not copy it here. `.activity()`
|
|
1021
|
+
* refuses that type too (`BPMN_ACTIVITY_SCRIPT_TASK_TYPE`).
|
|
1022
|
+
*
|
|
1023
|
+
* The option is kept rather than removed because it shipped (v3.25.0) and code
|
|
1024
|
+
* that spells the default out still compiles. Decompile does NOT preserve any
|
|
1025
|
+
* other type an artifact may carry (the legacy `BPMN.ScriptTask` included): it
|
|
1026
|
+
* writes none, so the source is one this method accepts, and the header of the
|
|
1027
|
+
* decompiled source lists each task it normalised. Reproducing markup the contract
|
|
1028
|
+
* rejects is propagating a defect, not fidelity — the same call the round trip
|
|
1029
|
+
* already makes for a bare `<uipath:input name="args">`.
|
|
1017
1030
|
*/
|
|
1018
|
-
type?:
|
|
1031
|
+
type?: 'BPMN.Variables';
|
|
1019
1032
|
}
|
|
1020
1033
|
/** Options for `.task()` — a display name and the variable assignments the task makes. */
|
|
1021
1034
|
export interface TaskOpts extends ActivityOpts {
|
|
@@ -3097,6 +3110,11 @@ declare abstract class ScopeBuilder {
|
|
|
3097
3110
|
* .build();
|
|
3098
3111
|
* ```
|
|
3099
3112
|
*
|
|
3113
|
+
* A script task is not built here: `'BPMN.ScriptTask'`, the type `registry get`
|
|
3114
|
+
* lists, is refused with `BPMN_ACTIVITY_SCRIPT_TASK_TYPE`. It would emit a script
|
|
3115
|
+
* task with no script whose mapping type replaces the script's extension type, so
|
|
3116
|
+
* nothing runs, and `check` and validate both pass it. Use {@link ScopeBuilder.scriptTask}.
|
|
3117
|
+
*
|
|
3100
3118
|
* @param id - The element id, unique in the process and used by `sequenceFlow`.
|
|
3101
3119
|
* @param type - The registry extension type, e.g. `'A2A.AgentExecution'`.
|
|
3102
3120
|
* @param opts - Context values, payload, output mapping and the shared activity options.
|
|
@@ -3489,7 +3507,7 @@ export declare class PathBuilder extends ScopeBuilder {
|
|
|
3489
3507
|
* bpmn('retrying')
|
|
3490
3508
|
* .var('ok', 'boolean')
|
|
3491
3509
|
* .startEvent('start')
|
|
3492
|
-
* .scriptTask('attempt', { script: 'return { ok: true };', outputs: { ok: '=result.ok' } })
|
|
3510
|
+
* .scriptTask('attempt', { script: 'return { ok: true };', outputs: { ok: '=result.response.ok' } })
|
|
3493
3511
|
* .choose('worked', [
|
|
3494
3512
|
* { when: '=vars.ok == true', body: (b) => b.endEvent('done') },
|
|
3495
3513
|
* { otherwise: true, body: (b) => b.goto('attempt') },
|
package/dist/bpmn/bpmn-sdk.js
CHANGED
|
@@ -878,6 +878,12 @@ class ScopeBuilder {
|
|
|
878
878
|
* @returns This builder, so calls chain.
|
|
879
879
|
*/
|
|
880
880
|
scriptTask(id, opts, body) {
|
|
881
|
+
// `type` is only type-restricted, and a `.bpmn.ts` loads without a type check.
|
|
882
|
+
const type = opts.type ?? 'BPMN.Variables';
|
|
883
|
+
if (type !== 'BPMN.Variables') {
|
|
884
|
+
throw new CompileRefusal('BPMN_SCRIPT_TASK_TYPE_INVALID', `.scriptTask('${id}'): type "${type}" replaces the script's extension type, so the script never runs and its outputs read back null. ` +
|
|
885
|
+
`A script task's only type is 'BPMN.Variables' (the default) — drop \`type\`.`);
|
|
886
|
+
}
|
|
881
887
|
return this.pushActivity({
|
|
882
888
|
kind: 'scriptTask',
|
|
883
889
|
id,
|
|
@@ -888,7 +894,7 @@ class ScopeBuilder {
|
|
|
888
894
|
inputs: opts.inputs ?? {},
|
|
889
895
|
outputs: opts.outputs ?? {},
|
|
890
896
|
outputRows: opts.outputRows,
|
|
891
|
-
type
|
|
897
|
+
type,
|
|
892
898
|
inputSchema: opts.inputSchema,
|
|
893
899
|
tags: opts.tags,
|
|
894
900
|
retry: opts.retry,
|
|
@@ -1992,6 +1998,11 @@ class ScopeBuilder {
|
|
|
1992
1998
|
* .build();
|
|
1993
1999
|
* ```
|
|
1994
2000
|
*
|
|
2001
|
+
* A script task is not built here: `'BPMN.ScriptTask'`, the type `registry get`
|
|
2002
|
+
* lists, is refused with `BPMN_ACTIVITY_SCRIPT_TASK_TYPE`. It would emit a script
|
|
2003
|
+
* task with no script whose mapping type replaces the script's extension type, so
|
|
2004
|
+
* nothing runs, and `check` and validate both pass it. Use {@link ScopeBuilder.scriptTask}.
|
|
2005
|
+
*
|
|
1995
2006
|
* @param id - The element id, unique in the process and used by `sequenceFlow`.
|
|
1996
2007
|
* @param type - The registry extension type, e.g. `'A2A.AgentExecution'`.
|
|
1997
2008
|
* @param opts - Context values, payload, output mapping and the shared activity options.
|
|
@@ -1999,6 +2010,10 @@ class ScopeBuilder {
|
|
|
1999
2010
|
* @returns This builder, so calls chain.
|
|
2000
2011
|
*/
|
|
2001
2012
|
activity(id, type, opts = {}, body) {
|
|
2013
|
+
if (type === 'BPMN.ScriptTask') {
|
|
2014
|
+
throw new CompileRefusal('BPMN_ACTIVITY_SCRIPT_TASK_TYPE', `.activity('${id}', 'BPMN.ScriptTask'): this writes a script task with no script, whose mapping type replaces the script's extension type, so nothing runs and its outputs read back null. ` +
|
|
2015
|
+
`Use .scriptTask('${id}', { script, outputs }) instead; its mapping type is 'BPMN.Variables'.`);
|
|
2016
|
+
}
|
|
2002
2017
|
return this.pushActivity({
|
|
2003
2018
|
kind: 'typed',
|
|
2004
2019
|
id,
|
|
@@ -2609,7 +2624,7 @@ export class PathBuilder extends ScopeBuilder {
|
|
|
2609
2624
|
* bpmn('retrying')
|
|
2610
2625
|
* .var('ok', 'boolean')
|
|
2611
2626
|
* .startEvent('start')
|
|
2612
|
-
* .scriptTask('attempt', { script: 'return { ok: true };', outputs: { ok: '=result.ok' } })
|
|
2627
|
+
* .scriptTask('attempt', { script: 'return { ok: true };', outputs: { ok: '=result.response.ok' } })
|
|
2613
2628
|
* .choose('worked', [
|
|
2614
2629
|
* { when: '=vars.ok == true', body: (b) => b.endEvent('done') },
|
|
2615
2630
|
* { otherwise: true, body: (b) => b.goto('attempt') },
|
package/dist/bpmn/check.d.ts
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* bpmn/check — fast static validation of a BuiltBpmn before serialization.
|
|
3
|
-
*
|
|
4
|
-
* Surfaces the common Maestro canvas-rule failures early (dangling flow refs,
|
|
5
|
-
* duplicate ids, a gateway branch with no condition, a superfluous gateway, an
|
|
6
|
-
* implicit join, a missing start event, a boundary event attached to nothing, an
|
|
7
|
-
* empty timer) so authoring gets instant feedback. The authoritative gate is
|
|
8
|
-
* still `uip maestro bpmn validate` (`validateBpmnCanvas`) on the emitted
|
|
9
|
-
* `.bpmn`.
|
|
10
|
-
*
|
|
11
|
-
* **An `error` here must mirror a real platform rule.** Being stricter than
|
|
12
|
-
* `validate` is worse than being looser: it refuses processes that deploy and run
|
|
13
|
-
* correctly, and the author has no way to appeal. Where this file is deliberately
|
|
14
|
-
* stricter than the platform — an unconditioned inclusive-gateway branch, an
|
|
15
|
-
* implicit join — the diagnostic is a `warning`, and its comment says which
|
|
16
|
-
* platform rule it corresponds to and how the two differ.
|
|
17
|
-
*/
|
|
18
1
|
import type { BuiltBpmn } from './bpmn-sdk.js';
|
|
19
2
|
import type { Library } from '../core/library.js';
|
|
20
3
|
import type { ResourceResolutions } from '../core/resource-resolution.js';
|
package/dist/bpmn/check.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bpmn/check — fast static validation of a BuiltBpmn before serialization.
|
|
3
|
+
*
|
|
4
|
+
* Surfaces the common Maestro canvas-rule failures early (dangling flow refs,
|
|
5
|
+
* duplicate ids, a gateway branch with no condition, a superfluous gateway, an
|
|
6
|
+
* implicit join, a missing start event, a boundary event attached to nothing, an
|
|
7
|
+
* empty timer) so authoring gets instant feedback. The authoritative gate is
|
|
8
|
+
* still `uip maestro bpmn validate` (`validateBpmnCanvas`) on the emitted
|
|
9
|
+
* `.bpmn`.
|
|
10
|
+
*
|
|
11
|
+
* **An `error` here must mirror a real platform rule.** Being stricter than
|
|
12
|
+
* `validate` is worse than being looser: it refuses processes that deploy and run
|
|
13
|
+
* correctly, and the author has no way to appeal. Where this file is deliberately
|
|
14
|
+
* stricter than the platform — an unconditioned inclusive-gateway branch, an
|
|
15
|
+
* implicit join — the diagnostic is a `warning`, and its comment says which
|
|
16
|
+
* platform rule it corresponds to and how the two differ.
|
|
17
|
+
*/
|
|
18
|
+
import { parse } from 'acorn';
|
|
1
19
|
import { checkBpmnExpressions } from './bpmn-expr-check.js';
|
|
2
20
|
import { allNodes, collectSerializerModel, folderCompanionKeys, implicitNodeVars, processId } from './serialize.js';
|
|
3
21
|
import { refreshConnectionDiagnostics } from './refresh-connections.js';
|
|
@@ -1072,8 +1090,210 @@ function readsBareIdentifier(script, name) {
|
|
|
1072
1090
|
const re = new RegExp(`(?<![\\w$.])${name.replace(/\$/g, '\\$')}(?![\\w$])(?!\\s*:)`);
|
|
1073
1091
|
return re.test(stripped);
|
|
1074
1092
|
}
|
|
1093
|
+
/** The `result` members a v2+ output may read directly: the wrapper, and the error slot. */
|
|
1094
|
+
const RESULT_MEMBERS = new Set(['response', 'Error']);
|
|
1095
|
+
const isJsNode = (v) => typeof v === 'object' && v !== null && typeof v.type === 'string';
|
|
1096
|
+
/** The child nodes of `node`, in source order. */
|
|
1097
|
+
function jsChildren(node) {
|
|
1098
|
+
const out = [];
|
|
1099
|
+
for (const [field, v] of Object.entries(node)) {
|
|
1100
|
+
if (field === 'type' || field === 'start' || field === 'end')
|
|
1101
|
+
continue;
|
|
1102
|
+
if (Array.isArray(v))
|
|
1103
|
+
for (const item of v) {
|
|
1104
|
+
if (isJsNode(item))
|
|
1105
|
+
out.push(item);
|
|
1106
|
+
}
|
|
1107
|
+
else if (isJsNode(v))
|
|
1108
|
+
out.push(v);
|
|
1109
|
+
}
|
|
1110
|
+
return out;
|
|
1111
|
+
}
|
|
1112
|
+
/** Whether a binding pattern (`result`, `{ a: result }`, `[result = 1]`, `...result`) declares `name`. */
|
|
1113
|
+
function patternBinds(p, name) {
|
|
1114
|
+
switch (p.type) {
|
|
1115
|
+
case 'Identifier': return p.name === name;
|
|
1116
|
+
case 'AssignmentPattern': return patternBinds(p.left, name);
|
|
1117
|
+
case 'RestElement': return patternBinds(p.argument, name);
|
|
1118
|
+
case 'ArrayPattern': return p.elements.some((e) => e !== null && patternBinds(e, name));
|
|
1119
|
+
// A pattern's computed key or default value is an expression, not a binding.
|
|
1120
|
+
case 'ObjectPattern': return p.properties.some((pr) => patternBinds(pr.type === 'RestElement' ? pr : pr.value, name));
|
|
1121
|
+
default: return false;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
const isFunction = (n) => /Function/.test(n.type);
|
|
1125
|
+
/** Whether a `let`/`const`/`var` declaration of the given kinds declares `name`. */
|
|
1126
|
+
function declarationBinds(n, name, kinds) {
|
|
1127
|
+
return isJsNode(n) && n.type === 'VariableDeclaration' && kinds(n.kind)
|
|
1128
|
+
&& n.declarations.some((d) => patternBinds(d.id, name));
|
|
1129
|
+
}
|
|
1130
|
+
/** Whether these statements, at the top of one block, declare `name` block-scoped: `let`, `const`, `class` or a function declaration. */
|
|
1131
|
+
function lexicallyBinds(statements, name) {
|
|
1132
|
+
return statements.some((s) => declarationBinds(s, name, (k) => k !== 'var')
|
|
1133
|
+
|| ((s.type === 'ClassDeclaration' || s.type === 'FunctionDeclaration') && isJsNode(s.id) && s.id.name === name));
|
|
1134
|
+
}
|
|
1135
|
+
/** Whether a `var` under `node` declares `name` in the function `node` belongs to: nested functions and static blocks are their own `var` scope and are not walked. */
|
|
1136
|
+
function varBinds(node, name) {
|
|
1137
|
+
if (declarationBinds(node, name, (k) => k === 'var'))
|
|
1138
|
+
return true;
|
|
1139
|
+
return jsChildren(node).some((c) => !isFunction(c) && c.type !== 'StaticBlock' && varBinds(c, name));
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Whether `node` opens a scope that declares `name`, so every `name` inside it is that
|
|
1143
|
+
* binding, not the outer one. A function: its own name (an expression's), a parameter,
|
|
1144
|
+
* a `var` anywhere in its body outside a nested function, or a block-scoped declaration
|
|
1145
|
+
* at the top of its body. A block, a `switch`, a `for` head or a `catch` parameter: the
|
|
1146
|
+
* declarations scoped to it. A declaration in a nested function shadows only inside that
|
|
1147
|
+
* function, so it is found when the walk reaches that function, never from outside.
|
|
1148
|
+
*/
|
|
1149
|
+
function scopeBinds(node, name) {
|
|
1150
|
+
if (isFunction(node)) {
|
|
1151
|
+
if (node.type === 'FunctionExpression' && isJsNode(node.id) && node.id.name === name)
|
|
1152
|
+
return true;
|
|
1153
|
+
if (node.params.some((p) => patternBinds(p, name)))
|
|
1154
|
+
return true;
|
|
1155
|
+
const body = node.body;
|
|
1156
|
+
return body.type === 'BlockStatement' && (varBinds(body, name) || lexicallyBinds(body.body, name));
|
|
1157
|
+
}
|
|
1158
|
+
switch (node.type) {
|
|
1159
|
+
case 'BlockStatement': return lexicallyBinds(node.body, name);
|
|
1160
|
+
case 'StaticBlock': return varBinds(node, name) || lexicallyBinds(node.body, name);
|
|
1161
|
+
case 'SwitchStatement': return lexicallyBinds(node.cases.flatMap((c) => c.consequent), name);
|
|
1162
|
+
case 'CatchClause': return isJsNode(node.param) && patternBinds(node.param, name);
|
|
1163
|
+
case 'ForStatement': return declarationBinds(node.init, name, (k) => k !== 'var');
|
|
1164
|
+
case 'ForInStatement':
|
|
1165
|
+
case 'ForOfStatement': return declarationBinds(node.left, name, (k) => k !== 'var');
|
|
1166
|
+
case 'ClassExpression':
|
|
1167
|
+
case 'ClassDeclaration': return isJsNode(node.id) && node.id.name === name;
|
|
1168
|
+
default: return false;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
/** The string a member selector names: `.response`, `['response']`, `` [`response`] ``; `undefined` for any other. */
|
|
1172
|
+
function memberName(member) {
|
|
1173
|
+
const prop = member.property;
|
|
1174
|
+
if (!member.computed)
|
|
1175
|
+
return prop.type === 'Identifier' ? prop.name : undefined;
|
|
1176
|
+
if (prop.type === 'Literal')
|
|
1177
|
+
return typeof prop.value === 'string' ? prop.value : undefined;
|
|
1178
|
+
const quasis = prop.quasis;
|
|
1179
|
+
return prop.type === 'TemplateLiteral' && quasis?.length === 1 ? quasis[0].value.cooked : undefined;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Where `code` reads the variable `result` other than through `result.response` or
|
|
1183
|
+
* `result.Error`: the span of each such identifier, in source order, and whether it is an object
|
|
1184
|
+
* shorthand (`{ result }`, which needs its key spelled out to be rewritten).
|
|
1185
|
+
*
|
|
1186
|
+
* `code` is parsed (acorn, as the Case checks parse JavaScript), so only real
|
|
1187
|
+
* references count: a property name (`foo.result`), an object key
|
|
1188
|
+
* (`{ result: … }`), a string, template text, regex or comment is none, while a
|
|
1189
|
+
* template's `${…}` hole is code. Optional chaining (`result?.response`,
|
|
1190
|
+
* `result?.['response']`) is the same member read. A scope that declares its own
|
|
1191
|
+
* `result` (a parameter, `var`, `let`, `const`, `class`, function or `catch` binding) is
|
|
1192
|
+
* not looked into, and only that scope: a nested function's declaration does not hide
|
|
1193
|
+
* an outer read. `undefined` when `code` is not one expression.
|
|
1194
|
+
*/
|
|
1195
|
+
function resultReads(code) {
|
|
1196
|
+
let program;
|
|
1197
|
+
try {
|
|
1198
|
+
// Parenthesized so `{ … }` is an object, closed on a new line so a trailing `// comment` ends first.
|
|
1199
|
+
program = parse(`(${code}\n)`, { ecmaVersion: 'latest', sourceType: 'script' });
|
|
1200
|
+
}
|
|
1201
|
+
catch {
|
|
1202
|
+
return undefined;
|
|
1203
|
+
}
|
|
1204
|
+
const reads = [];
|
|
1205
|
+
const visit = (node, parent) => {
|
|
1206
|
+
if (node.type === 'Identifier') {
|
|
1207
|
+
if (node.name !== 'result')
|
|
1208
|
+
return;
|
|
1209
|
+
if (parent?.type === 'MemberExpression' && parent.object === node && RESULT_MEMBERS.has(memberName(parent) ?? ''))
|
|
1210
|
+
return;
|
|
1211
|
+
reads.push({ start: node.start - 1, end: node.end - 1, shorthand: parent?.type === 'Property' && parent.shorthand === true });
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
if (scopeBinds(node, 'result'))
|
|
1215
|
+
return;
|
|
1216
|
+
for (const child of jsChildren(node)) {
|
|
1217
|
+
// A name in a property position is not a reference: `a.result`, `{ result: … }`, a
|
|
1218
|
+
// member's name, a label. A shorthand `{ result }` is one too, read through its value.
|
|
1219
|
+
const isName = child === node.key || child === node.property || child === node.label || child === node.meta;
|
|
1220
|
+
if (isName && !node.computed)
|
|
1221
|
+
continue;
|
|
1222
|
+
visit(child, node);
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
visit(program, undefined);
|
|
1226
|
+
// The fix splices these left to right, and a node's fields are not guaranteed to come in span order.
|
|
1227
|
+
return reads.sort((a, b) => a.start - b.start);
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* `source` with every `result` read that skips the v2+ wrapper sent through it
|
|
1231
|
+
* (`=result.severity` → `=result.response.severity`), or `undefined` when there is none
|
|
1232
|
+
* (or the expression does not parse, which is not this check's to report).
|
|
1233
|
+
*/
|
|
1234
|
+
function scriptResultThroughResponse(source) {
|
|
1235
|
+
const prefix = /^=(?:js:)?/.exec(source)?.[0];
|
|
1236
|
+
if (prefix === undefined || !/\bresult\b/.test(source))
|
|
1237
|
+
return undefined;
|
|
1238
|
+
const code = source.slice(prefix.length);
|
|
1239
|
+
const reads = resultReads(code);
|
|
1240
|
+
if (!reads?.length)
|
|
1241
|
+
return undefined;
|
|
1242
|
+
let fixed = '';
|
|
1243
|
+
let at = 0;
|
|
1244
|
+
for (const r of reads) {
|
|
1245
|
+
fixed += code.slice(at, r.start) + (r.shorthand ? 'result: result.response' : 'result.response');
|
|
1246
|
+
at = r.end;
|
|
1247
|
+
}
|
|
1248
|
+
return prefix + fixed + code.slice(at);
|
|
1249
|
+
}
|
|
1250
|
+
/** Whether a `uipath:scriptVersion` value is `v2` or later — the versions that wrap the return value. */
|
|
1251
|
+
function wrapsScriptResult(version) {
|
|
1252
|
+
const m = /^v(\d+)$/i.exec(version.trim());
|
|
1253
|
+
return m !== null && Number(m[1]) >= 2;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* A script task at `uipath:scriptVersion` v2 or later whose output row reads `result`
|
|
1257
|
+
* other than through `result.response`.
|
|
1258
|
+
*
|
|
1259
|
+
* The runtime wraps a v2-or-later script's return value: `ScriptActivities.DoInvokeScriptTaskAsync`
|
|
1260
|
+
* in PO.BpmnEngine returns `{ "response": <what the script returned> }` when
|
|
1261
|
+
* `IsVersionAtLeast(version, 2)`, so `=result.severity` reads a field the result does not
|
|
1262
|
+
* have and the variable comes back empty. Nothing else notices: `compile` writes the row,
|
|
1263
|
+
* `validate` accepts it and the run completes. Measured in R15 (#1872): two e2e tasks
|
|
1264
|
+
* finished their live runs with empty public outputs from exactly this.
|
|
1265
|
+
*
|
|
1266
|
+
* Only v1 spreads the returned object's fields, so a v1 task (what an absent
|
|
1267
|
+
* `uipath:scriptVersion` means; decompile spells it `'v1'`) is exempt, and a version
|
|
1268
|
+
* this file cannot read is left alone. All 29 script tasks in the real Studio Web
|
|
1269
|
+
* exports (`research/bpmn-roundtrip/FINDINGS.md`, G2) are v3, so an import carrying
|
|
1270
|
+
* this shape was already broken on the platform.
|
|
1271
|
+
*/
|
|
1272
|
+
function checkScriptResultReads(n, diags) {
|
|
1273
|
+
if (!wrapsScriptResult(n.scriptVersion))
|
|
1274
|
+
return;
|
|
1275
|
+
const rows = n.outputRows
|
|
1276
|
+
? n.outputRows.flatMap((r) => (typeof r.source === 'string' ? [{ name: r.name, source: r.source, spelled: 'outputRows' }] : []))
|
|
1277
|
+
: Object.entries(n.outputs).flatMap(([name, source]) => (typeof source === 'string' ? [{ name, source, spelled: 'outputs' }] : []));
|
|
1278
|
+
for (const row of rows) {
|
|
1279
|
+
const fixed = scriptResultThroughResponse(row.source);
|
|
1280
|
+
if (fixed === undefined)
|
|
1281
|
+
continue;
|
|
1282
|
+
diags.push({
|
|
1283
|
+
level: 'error',
|
|
1284
|
+
code: 'SCRIPT_RESULT_NOT_RESPONSE',
|
|
1285
|
+
message: `Script task "${n.id}" output "${row.name}" reads \`${row.source}\`, but a ${n.scriptVersion} script task's ` +
|
|
1286
|
+
`return value arrives wrapped as \`result.response\`, so this reads nothing and the variable comes back empty. ` +
|
|
1287
|
+
`Write \`${fixed}\`.`,
|
|
1288
|
+
where: n.id,
|
|
1289
|
+
suggestion: `In \`${row.spelled}\`, change "${row.name}" to \`${fixed}\`.`,
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1075
1293
|
/** Retry and loop options, checked per activity. */
|
|
1076
1294
|
function checkActivityFields(n, diags) {
|
|
1295
|
+
if (n.kind === 'scriptTask')
|
|
1296
|
+
checkScriptResultReads(n, diags);
|
|
1077
1297
|
// A script task whose body is missing or blank. The wire form of a script task IS its
|
|
1078
1298
|
// `<bpmn:script>` body, so without one the emitter writes an activity that parses,
|
|
1079
1299
|
// validates and runs — and does nothing. Every gate stays green: `check` passed, the
|
package/dist/bpmn/decompile.js
CHANGED
|
@@ -293,6 +293,11 @@ let runLibrary;
|
|
|
293
293
|
* header, so the omission is stated where the author reads the file.
|
|
294
294
|
*/
|
|
295
295
|
let runUnmodelled = new Map();
|
|
296
|
+
/**
|
|
297
|
+
* The script tasks whose mapping type this run normalised to `BPMN.Variables`, by id:
|
|
298
|
+
* what each carried. Announced in the source header, like `runUnmodelled`.
|
|
299
|
+
*/
|
|
300
|
+
let runScriptTypes = new Map();
|
|
296
301
|
let runLiftPlans = new Map();
|
|
297
302
|
let runLiftSkipped = [];
|
|
298
303
|
let runLiftCalls = new Map();
|
|
@@ -1202,6 +1207,13 @@ function emitScriptTask(chain, el, payload, type) {
|
|
|
1202
1207
|
// `Error`) while binding a differently-named variable, and the derived form
|
|
1203
1208
|
// names it after the variable.
|
|
1204
1209
|
const verbatim = outputRowsNeedSpellingOut(payload) ? emitOutputRows(payload) : undefined;
|
|
1210
|
+
// A script task's only mapping type is `BPMN.Variables`: any other replaces the
|
|
1211
|
+
// script's extension type, so the script never runs and its outputs read back null.
|
|
1212
|
+
// `.scriptTask()` refuses one (`BPMN_SCRIPT_TASK_TYPE_INVALID`), so the source writes
|
|
1213
|
+
// none and the recompile gets `BPMN.Variables` — repairing the task rather than
|
|
1214
|
+
// reproducing a defect `uip maestro bpmn validate` does not catch. The header says so.
|
|
1215
|
+
if (type !== undefined && type !== 'BPMN.Variables')
|
|
1216
|
+
runScriptTypes.set(el.id, `${el.id}: ${type}`);
|
|
1205
1217
|
chain.add(`.scriptTask(${tsText(el.id)}, ${opts([
|
|
1206
1218
|
['name', el.name !== undefined ? tsText(el.name) : undefined],
|
|
1207
1219
|
['script', tsText(el.script ?? '')],
|
|
@@ -1210,15 +1222,8 @@ function emitScriptTask(chain, el, payload, type) {
|
|
|
1210
1222
|
// runtime's result shape) and must survive the round trip. An absent element
|
|
1211
1223
|
// is spelled `'v1'`, the meaning it has to the runtime.
|
|
1212
1224
|
['scriptVersion', scriptVersionOf(el) !== 'v3' ? tsText(scriptVersionOf(el)) : undefined],
|
|
1213
|
-
//
|
|
1214
|
-
//
|
|
1215
|
-
// the runtime contract has no such type, so reproducing it would propagate a
|
|
1216
|
-
// defect `uip maestro bpmn validate` does not catch. Same call the round trip
|
|
1217
|
-
// already makes for a bare `<uipath:input name="args">`.
|
|
1218
|
-
[
|
|
1219
|
-
'type',
|
|
1220
|
-
type !== undefined && type !== 'BPMN.Variables' && type !== 'BPMN.ScriptTask' ? tsText(type) : undefined,
|
|
1221
|
-
],
|
|
1225
|
+
// No `type`: every type but `BPMN.Variables` is NORMALISED AWAY (below), so the
|
|
1226
|
+
// source is one `.scriptTask()` accepts.
|
|
1222
1227
|
['inputSchema', schemaBody !== undefined && !schemaIsDefault ? jsonLiteral(schemaBody) : undefined],
|
|
1223
1228
|
['inputs', record(inputs)],
|
|
1224
1229
|
['outputs', verbatim ? undefined : record(outputs)],
|
|
@@ -2617,6 +2622,7 @@ export async function decompile(xml, options = {}) {
|
|
|
2617
2622
|
// tasks come back as `.connector()`, whose declarations derive as a connector's.
|
|
2618
2623
|
runLibrary = options.library;
|
|
2619
2624
|
runUnmodelled = new Map();
|
|
2625
|
+
runScriptTypes = new Map();
|
|
2620
2626
|
runLiftPlans = new Map();
|
|
2621
2627
|
runLiftSkipped = [];
|
|
2622
2628
|
runLiftCalls = new Map();
|
|
@@ -2688,13 +2694,22 @@ export async function decompile(xml, options = {}) {
|
|
|
2688
2694
|
'\n'
|
|
2689
2695
|
: '';
|
|
2690
2696
|
runUnmodelled = new Map();
|
|
2697
|
+
const scriptTypeNote = runScriptTypes.size
|
|
2698
|
+
? `// SCRIPT TASK TYPES NORMALISED. A script task's only mapping type is\n` +
|
|
2699
|
+
`// BPMN.Variables: any other replaces the script's extension type, so the script\n` +
|
|
2700
|
+
`// never runs and its outputs read back null. These tasks carried another type,\n` +
|
|
2701
|
+
`// and this source gives them BPMN.Variables (the .scriptTask() default):\n` +
|
|
2702
|
+
[...runScriptTypes.values()].map((d) => `// - ${commentText(d)}\n`).join('') +
|
|
2703
|
+
'\n'
|
|
2704
|
+
: '';
|
|
2705
|
+
runScriptTypes = new Map();
|
|
2691
2706
|
const imports = `import { ${imported} } from ${tsText(importFrom)};\n\n`;
|
|
2692
2707
|
const nameCall = process.name !== undefined ? `${indent}.name(${tsText(process.name)})` : undefined;
|
|
2693
2708
|
options.onConnectorLift?.({
|
|
2694
2709
|
lifted: [...runLiftPlans.keys()],
|
|
2695
2710
|
verbatim: runLiftSkipped,
|
|
2696
2711
|
preamble: {
|
|
2697
|
-
prefix: `${host.note}${unmodelledNote}${imports}`,
|
|
2712
|
+
prefix: `${host.note}${unmodelledNote}${scriptTypeNote}${imports}`,
|
|
2698
2713
|
head: `bpmn(${tsText(process.id)})`,
|
|
2699
2714
|
calls: [...(nameCall !== undefined ? [nameCall] : []), ...chain.all.slice(0, preambleLines)],
|
|
2700
2715
|
},
|
|
@@ -2710,7 +2725,7 @@ export async function decompile(xml, options = {}) {
|
|
|
2710
2725
|
binding: 'processBuilder',
|
|
2711
2726
|
indent,
|
|
2712
2727
|
});
|
|
2713
|
-
return `${host.note}${unmodelledNote}${imports}${body}\n`;
|
|
2728
|
+
return `${host.note}${unmodelledNote}${scriptTypeNote}${imports}${body}\n`;
|
|
2714
2729
|
}
|
|
2715
2730
|
/**
|
|
2716
2731
|
* Variable ids the serializer creates on its own from a node's output rows.
|
package/dist/bpmn-api.md
CHANGED
|
@@ -223,7 +223,7 @@ Extends `ActivityOpts` — its fields and methods apply here too.
|
|
|
223
223
|
- `ScriptTaskOpts.outputs?: Record<string, string>` — `uipath:output` rows: variable id → `=`-expression.
|
|
224
224
|
- `ScriptTaskOpts.outputRows?: TypedOutputRow[]` — Output rows spelled out, replacing the ones `outputs` derives — see TypedOutputRow.
|
|
225
225
|
- `ScriptTaskOpts.inputSchema?: unknown` — The `uipath:inputSchema` body inside the mapping's `uipath:context` — a JSON Schema for the `args` the script receives.
|
|
226
|
-
- `ScriptTaskOpts.type?:
|
|
226
|
+
- `ScriptTaskOpts.type?: 'BPMN.Variables'` — The mapping's extension type.
|
|
227
227
|
|
|
228
228
|
### `TaskOpts`
|
|
229
229
|
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export declare const REFUSALS: {
|
|
|
65
65
|
readonly BINDING_UNDECLARED: "draft";
|
|
66
66
|
readonly BOUNDARY_NOT_ACTIVITY: "lint";
|
|
67
67
|
readonly BOUNDARY_UNATTACHED: "lowering";
|
|
68
|
+
readonly BPMN_ACTIVITY_SCRIPT_TASK_TYPE: "lowering";
|
|
68
69
|
readonly BPMN_BINDING_READ_BEFORE_DECLARED: "lowering";
|
|
69
70
|
readonly BPMN_BINDING_RESOURCE_KEY_CONFLICT: "lowering";
|
|
70
71
|
readonly BPMN_BOUNDARY_NO_EVENT: "lint";
|
|
@@ -123,6 +124,7 @@ export declare const REFUSALS: {
|
|
|
123
124
|
readonly BPMN_PATH_NOT_CONTINUED: "lowering";
|
|
124
125
|
readonly BPMN_PLAIN_TASK_ELEMENT_INVALID: "lowering";
|
|
125
126
|
readonly BPMN_RACE_ARM_NOT_WAIT: "lowering";
|
|
127
|
+
readonly BPMN_SCRIPT_TASK_TYPE_INVALID: "lowering";
|
|
126
128
|
readonly BPMN_SEQUENCE_NO_INCOMING: "lowering";
|
|
127
129
|
readonly BPMN_SOURCE_NOT_FOUND: "lowering";
|
|
128
130
|
readonly BPMN_START_ALREADY_SYNTHESIZED: "lowering";
|
|
@@ -666,6 +668,7 @@ export declare const REFUSALS: {
|
|
|
666
668
|
readonly SCRIPT_EMPTY_RETURNS: "lint";
|
|
667
669
|
readonly SCRIPT_FUNCTION_SCOPE: "lowering";
|
|
668
670
|
readonly SCRIPT_FUNCTION_UNLOWERABLE: "lowering";
|
|
671
|
+
readonly SCRIPT_RESULT_NOT_RESPONSE: "lint";
|
|
669
672
|
readonly SCRIPT_RETURNS_UNKNOWN_TYPE: "lint";
|
|
670
673
|
readonly SCRIPT_TASK_NO_BODY: "lint";
|
|
671
674
|
readonly SDK_RESOLVE_HOOK_MISSING: "lowering";
|
package/dist/core/refusals.js
CHANGED
|
@@ -114,6 +114,7 @@ export const REFUSALS = {
|
|
|
114
114
|
BINDING_UNDECLARED: 'draft',
|
|
115
115
|
BOUNDARY_NOT_ACTIVITY: 'lint',
|
|
116
116
|
BOUNDARY_UNATTACHED: 'lowering',
|
|
117
|
+
BPMN_ACTIVITY_SCRIPT_TASK_TYPE: 'lowering',
|
|
117
118
|
BPMN_BINDING_READ_BEFORE_DECLARED: 'lowering',
|
|
118
119
|
BPMN_BINDING_RESOURCE_KEY_CONFLICT: 'lowering',
|
|
119
120
|
BPMN_BOUNDARY_NO_EVENT: 'lint',
|
|
@@ -172,6 +173,7 @@ export const REFUSALS = {
|
|
|
172
173
|
BPMN_PATH_NOT_CONTINUED: 'lowering',
|
|
173
174
|
BPMN_PLAIN_TASK_ELEMENT_INVALID: 'lowering',
|
|
174
175
|
BPMN_RACE_ARM_NOT_WAIT: 'lowering',
|
|
176
|
+
BPMN_SCRIPT_TASK_TYPE_INVALID: 'lowering',
|
|
175
177
|
BPMN_SEQUENCE_NO_INCOMING: 'lowering',
|
|
176
178
|
BPMN_SOURCE_NOT_FOUND: 'lowering',
|
|
177
179
|
BPMN_START_ALREADY_SYNTHESIZED: 'lowering',
|
|
@@ -740,6 +742,7 @@ export const REFUSALS = {
|
|
|
740
742
|
SCRIPT_EMPTY_RETURNS: 'lint',
|
|
741
743
|
SCRIPT_FUNCTION_SCOPE: 'lowering',
|
|
742
744
|
SCRIPT_FUNCTION_UNLOWERABLE: 'lowering',
|
|
745
|
+
SCRIPT_RESULT_NOT_RESPONSE: 'lint',
|
|
743
746
|
SCRIPT_RETURNS_UNKNOWN_TYPE: 'lint',
|
|
744
747
|
SCRIPT_TASK_NO_BODY: 'lint',
|
|
745
748
|
SDK_RESOLVE_HOOK_MISSING: 'lowering',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.93.
|
|
3
|
+
"version": "6.93.8",
|
|
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",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"@types/node": "^22.7.0",
|
|
112
112
|
"esbuild": "^0.28.1"
|
|
113
113
|
},
|
|
114
|
-
"gitref": "
|
|
114
|
+
"gitref": "f6fd09112d497419d811bc3148995b02ceb651e0"
|
|
115
115
|
}
|