@uipath/maestro-builder-sdk 6.85.6 → 6.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-index.md +57 -57
- package/dist/api-members.md +213 -213
- package/dist/bpmn/bpmn-expr-check.d.ts +13 -5
- package/dist/bpmn/bpmn-expr-check.js +32 -9
- package/dist/bpmn/bpmn-sdk.d.ts +9 -3
- package/dist/bpmn/bpmn-sdk.js +8 -7
- package/dist/bpmn/check.js +26 -0
- package/dist/bpmn/decompile.js +96 -2
- package/dist/check.js +23 -18
- package/dist/core/refusals.d.ts +2 -2
- package/dist/core/refusals.js +2 -2
- package/dist/decompile.js +38 -30
- package/dist/flow-sdk.d.ts +16 -6
- package/dist/flow-sdk.js +4 -5
- package/dist/serialize.js +13 -4
- package/package.json +2 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* bpmn-expr-check — the BPMN adapter over the shared `core/expr-check`, run by
|
|
3
|
-
* `
|
|
3
|
+
* `check()` (`checkExpressions` in check.ts). Its codes are `lint` (decided on #1712):
|
|
4
|
+
* the serializer writes the read as authored and `bpmn compile` does not refuse it.
|
|
5
|
+
* Not by `BpmnBuilder.build()`: a throw there stopped every path that builds first,
|
|
6
|
+
* so such a process could not be checked, merged or round-tripped (#1676).
|
|
4
7
|
*
|
|
5
8
|
* A BPMN `=`-expression reads a declared variable as `=vars.<name>` (a gateway
|
|
6
9
|
* flow `condition`, a script `input`, a multi-instance `collection`/`completion`,
|
|
@@ -27,14 +30,19 @@ import { CompileRefusal } from '../core/compile-refusal.js';
|
|
|
27
30
|
/** A diagnostic plus the element it was found in. */
|
|
28
31
|
export interface BpmnLocatedDiagnostic extends ExprDiagnostic {
|
|
29
32
|
where: string;
|
|
33
|
+
/** The id of the flow or element the expression is on. */
|
|
34
|
+
elementId?: string;
|
|
30
35
|
}
|
|
31
36
|
/** Every first-level expression problem in a built BPMN process, stamped with its location. */
|
|
32
37
|
export declare function checkBpmnExpressions(built: BuiltBpmn): BpmnLocatedDiagnostic[];
|
|
33
38
|
/**
|
|
34
|
-
*
|
|
35
|
-
* undeclared `vars.<name>` reference.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
39
|
+
* Was thrown by `BpmnBuilder.build()` when the first-level expression check found an
|
|
40
|
+
* undeclared `vars.<name>` reference. `message` lists every problem; `diagnostics`
|
|
41
|
+
* carries them structured.
|
|
42
|
+
*
|
|
43
|
+
* @deprecated Nothing throws it since #1676: `check()` reports the same diagnostics,
|
|
44
|
+
* and `compile` writes the read as authored (the codes are `lint`). Kept so code
|
|
45
|
+
* that names the class still compiles.
|
|
38
46
|
*/
|
|
39
47
|
export declare class BpmnBuildError extends CompileRefusal {
|
|
40
48
|
readonly diagnostics: BpmnLocatedDiagnostic[];
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* bpmn-expr-check — the BPMN adapter over the shared `core/expr-check`, run by
|
|
3
|
-
* `
|
|
3
|
+
* `check()` (`checkExpressions` in check.ts). Its codes are `lint` (decided on #1712):
|
|
4
|
+
* the serializer writes the read as authored and `bpmn compile` does not refuse it.
|
|
5
|
+
* Not by `BpmnBuilder.build()`: a throw there stopped every path that builds first,
|
|
6
|
+
* so such a process could not be checked, merged or round-tripped (#1676).
|
|
4
7
|
*
|
|
5
8
|
* A BPMN `=`-expression reads a declared variable as `=vars.<name>` (a gateway
|
|
6
9
|
* flow `condition`, a script `input`, a multi-instance `collection`/`completion`,
|
|
@@ -85,10 +88,25 @@ function walk(nodes, flows, rootsIn, out) {
|
|
|
85
88
|
for (const n of nodes)
|
|
86
89
|
for (const name of nodeDeclaredVars(n))
|
|
87
90
|
roots.vars.add(name);
|
|
88
|
-
for (const f of flows)
|
|
89
|
-
|
|
91
|
+
for (const f of flows) {
|
|
92
|
+
const found = [];
|
|
93
|
+
checkExpr(f.condition, `flow "${f.id}" condition`, roots, found);
|
|
94
|
+
for (const d of found)
|
|
95
|
+
out.push({ ...d, elementId: f.id });
|
|
96
|
+
}
|
|
90
97
|
for (const n of nodes) {
|
|
91
|
-
|
|
98
|
+
walkNode(n, roots, out);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** The expressions on one node, each finding stamped with its id; a sub-process recurses into its own scope. */
|
|
102
|
+
function walkNode(n, roots, located) {
|
|
103
|
+
const at = `${n.kind} "${n.id}"`;
|
|
104
|
+
const out = [];
|
|
105
|
+
const flush = () => {
|
|
106
|
+
for (const d of out.splice(0))
|
|
107
|
+
located.push({ ...d, elementId: n.id });
|
|
108
|
+
};
|
|
109
|
+
{
|
|
92
110
|
// An errorMapping row's `condition` is an expression on EVERY activity kind, so
|
|
93
111
|
// it is checked before the per-kind arms rather than inside them. Worth checking
|
|
94
112
|
// here specifically because the CANVAS treats an undeclared reference in it as a
|
|
@@ -159,9 +177,11 @@ function walk(nodes, flows, rootsIn, out) {
|
|
|
159
177
|
subRoots.varIds.add(v.id);
|
|
160
178
|
}
|
|
161
179
|
checkExpr(n.loop?.completion, `${at} loop completion`, subRoots, out);
|
|
162
|
-
|
|
180
|
+
flush();
|
|
181
|
+
walk(n.nodes, n.flows, subRoots, located);
|
|
163
182
|
}
|
|
164
183
|
}
|
|
184
|
+
flush();
|
|
165
185
|
}
|
|
166
186
|
/** Every first-level expression problem in a built BPMN process, stamped with its location. */
|
|
167
187
|
export function checkBpmnExpressions(built) {
|
|
@@ -209,10 +229,13 @@ function connectorBindingNames(nodes) {
|
|
|
209
229
|
return out;
|
|
210
230
|
}
|
|
211
231
|
/**
|
|
212
|
-
*
|
|
213
|
-
* undeclared `vars.<name>` reference.
|
|
214
|
-
*
|
|
215
|
-
*
|
|
232
|
+
* Was thrown by `BpmnBuilder.build()` when the first-level expression check found an
|
|
233
|
+
* undeclared `vars.<name>` reference. `message` lists every problem; `diagnostics`
|
|
234
|
+
* carries them structured.
|
|
235
|
+
*
|
|
236
|
+
* @deprecated Nothing throws it since #1676: `check()` reports the same diagnostics,
|
|
237
|
+
* and `compile` writes the read as authored (the codes are `lint`). Kept so code
|
|
238
|
+
* that names the class still compiles.
|
|
216
239
|
*/
|
|
217
240
|
export class BpmnBuildError extends CompileRefusal {
|
|
218
241
|
diagnostics;
|
package/dist/bpmn/bpmn-sdk.d.ts
CHANGED
|
@@ -1658,9 +1658,11 @@ export interface ActivityNodeOpts extends ActivityOpts {
|
|
|
1658
1658
|
* on a machine that has it, then `node scripts/materialize-bpmn-registry.mjs` to add it
|
|
1659
1659
|
* to the snapshot for good.
|
|
1660
1660
|
*
|
|
1661
|
-
* `bpmn-decompile`
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1661
|
+
* `bpmn-decompile` writes one for an imported node whose type the registry does not
|
|
1662
|
+
* list, read off the artifact itself: the element, the payload's tag, and nothing to
|
|
1663
|
+
* derive, with every context, input and output row spelled out beside it. That spec
|
|
1664
|
+
* carries the node through a round trip exactly; it says nothing about which fields
|
|
1665
|
+
* the type needs, so a node authored from scratch still wants the registry's.
|
|
1664
1666
|
*/
|
|
1665
1667
|
spec?: RegistryTypeSpec;
|
|
1666
1668
|
/** Variable the type's own output lands in. Defaults to `<id>_<outputName>`. */
|
|
@@ -3724,6 +3726,10 @@ export declare class BpmnBuilder extends ScopeBuilder {
|
|
|
3724
3726
|
/**
|
|
3725
3727
|
* Finish the process and return the graph the serializer turns into XML.
|
|
3726
3728
|
*
|
|
3729
|
+
* It does not check expressions: `check()` reports an undeclared `vars.<name>` read
|
|
3730
|
+
* and `compile` writes it as authored, so a process that already reads one can be
|
|
3731
|
+
* checked, merged and round-tripped.
|
|
3732
|
+
*
|
|
3727
3733
|
* @returns The built process — its elements, flows and variables.
|
|
3728
3734
|
*/
|
|
3729
3735
|
build(): BuiltBpmn;
|
package/dist/bpmn/bpmn-sdk.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { connector as makeConnector } from '../core/actions.js';
|
|
2
|
-
import { checkBpmnExpressions, BpmnBuildError } from './bpmn-expr-check.js';
|
|
3
2
|
import { BPMN_SCHEMA_VERSIONS } from './format-profile.js';
|
|
4
3
|
import { schemaVersionRefusal } from '../schema-version.js';
|
|
5
4
|
import { bindingRequiredFields, REGISTRY_GAPS, registryType } from './typed-node.js';
|
|
@@ -2899,6 +2898,10 @@ export class BpmnBuilder extends ScopeBuilder {
|
|
|
2899
2898
|
/**
|
|
2900
2899
|
* Finish the process and return the graph the serializer turns into XML.
|
|
2901
2900
|
*
|
|
2901
|
+
* It does not check expressions: `check()` reports an undeclared `vars.<name>` read
|
|
2902
|
+
* and `compile` writes it as authored, so a process that already reads one can be
|
|
2903
|
+
* checked, merged and round-tripped.
|
|
2904
|
+
*
|
|
2902
2905
|
* @returns The built process — its elements, flows and variables.
|
|
2903
2906
|
*/
|
|
2904
2907
|
build() {
|
|
@@ -2966,12 +2969,10 @@ export class BpmnBuilder extends ScopeBuilder {
|
|
|
2966
2969
|
schemas: this._schemas,
|
|
2967
2970
|
preservation: this._preservation,
|
|
2968
2971
|
};
|
|
2969
|
-
//
|
|
2970
|
-
//
|
|
2971
|
-
//
|
|
2972
|
-
|
|
2973
|
-
if (errors.length)
|
|
2974
|
-
throw new BpmnBuildError(built, errors);
|
|
2972
|
+
// No expression check here: `check()` reports an undeclared `vars.<name>` read,
|
|
2973
|
+
// and `compile` writes it as authored (both codes are `lint`, decided on #1712).
|
|
2974
|
+
// It threw here, and every path builds first, so a process that already read one
|
|
2975
|
+
// could not be checked, merged or round-tripped (#1676).
|
|
2975
2976
|
return built;
|
|
2976
2977
|
}
|
|
2977
2978
|
}
|
package/dist/bpmn/check.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { checkBpmnExpressions } from './bpmn-expr-check.js';
|
|
1
2
|
import { allNodes, collectSerializerRefusals, folderCompanionKeys, implicitNodeVars, processId } from './serialize.js';
|
|
2
3
|
import { KNOWN_METHOD_SET } from './known-methods.js';
|
|
3
4
|
import { EQUALS_EXPR_DIALECT, checkConnectorLookups, checkConnectorResources, checkConnectorSchema, } from '../core/connector-checks.js';
|
|
@@ -87,6 +88,7 @@ export function check(built, opts = {}) {
|
|
|
87
88
|
const diags = [];
|
|
88
89
|
// Duplicate and missing ids (`documentIdProblems`) are the serializer's.
|
|
89
90
|
checkScope(built.nodes, built.flows, 'process', diags, true);
|
|
91
|
+
checkExpressions(built, diags);
|
|
90
92
|
checkScopedVars(built, diags);
|
|
91
93
|
checkVariableOrder(built, diags);
|
|
92
94
|
checkFolderBindings(built, diags);
|
|
@@ -100,6 +102,30 @@ export function check(built, opts = {}) {
|
|
|
100
102
|
diags.push(...serializerRefusals(built, opts, diags));
|
|
101
103
|
return diags;
|
|
102
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* The first-level expression check (bpmn-expr-check): an undeclared `vars.<name>` or
|
|
107
|
+
* `bindings.<name>` read, or a declared variable read without `vars.`.
|
|
108
|
+
*
|
|
109
|
+
* Both codes are `lint` (decided on #1712): the serializer writes the read exactly as
|
|
110
|
+
* authored, so `compile` writes it and `check` is where it is reported. It ran in
|
|
111
|
+
* `BpmnBuilder.build()` and threw, which stopped every path that builds first, so a
|
|
112
|
+
* process that already read an undeclared variable could not be checked, merged or
|
|
113
|
+
* round-tripped (#1676).
|
|
114
|
+
*/
|
|
115
|
+
function checkExpressions(built, diags) {
|
|
116
|
+
const nodeIds = new Set(allNodes(built.nodes).map((n) => n.id));
|
|
117
|
+
for (const d of checkBpmnExpressions(built)) {
|
|
118
|
+
diags.push({
|
|
119
|
+
level: d.level,
|
|
120
|
+
code: d.code,
|
|
121
|
+
// The suggestion goes in the message too: the CLI prints `[code] message` only.
|
|
122
|
+
message: `in ${d.where}: ${d.message}${d.suggestion ? ` (did you mean "${d.suggestion}"?)` : ''}`,
|
|
123
|
+
where: d.elementId ?? d.where,
|
|
124
|
+
...(d.suggestion ? { suggestion: d.suggestion } : {}),
|
|
125
|
+
...(d.elementId !== undefined && nodeIds.has(d.elementId) ? { nodeId: d.elementId } : {}),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
103
129
|
/**
|
|
104
130
|
* Every refusal `compile` would raise for `built`: the serializer's model step,
|
|
105
131
|
* run in collect mode (`collectSerializerRefusals`), each placed on its element.
|
package/dist/bpmn/decompile.js
CHANGED
|
@@ -903,7 +903,10 @@ function emitQuickHumanTask(chain, el, payload) {
|
|
|
903
903
|
* owes you.
|
|
904
904
|
*/
|
|
905
905
|
function emitTypedNode(chain, el, payload, type) {
|
|
906
|
-
const
|
|
906
|
+
const listed = listedSpec(type);
|
|
907
|
+
if (!listed)
|
|
908
|
+
return emitUnlistedTypedNode(chain, el, payload, type);
|
|
909
|
+
const spec = listed;
|
|
907
910
|
const id = el.id;
|
|
908
911
|
if (type === 'Actions.HITL' && emitQuickHumanTask(chain, el, payload))
|
|
909
912
|
return;
|
|
@@ -972,6 +975,92 @@ function emitTypedNode(chain, el, payload, type) {
|
|
|
972
975
|
['loop', emitLoop(el)],
|
|
973
976
|
]))})`);
|
|
974
977
|
}
|
|
978
|
+
/** The registry's spec for a type, or `undefined` when neither the snapshot nor `uip` lists it. */
|
|
979
|
+
function listedSpec(type) {
|
|
980
|
+
try {
|
|
981
|
+
return registryType(type);
|
|
982
|
+
}
|
|
983
|
+
catch {
|
|
984
|
+
return undefined;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* The emission spec for a type the registry does not list, read off the element
|
|
989
|
+
* that carries it.
|
|
990
|
+
*
|
|
991
|
+
* Decompile needs a spec only to know how the builder will WRITE the node back: which
|
|
992
|
+
* element, which `uipath:*` tag, and which rows it derives on its own. With every row
|
|
993
|
+
* spelled out verbatim (`contextRows`, `inputRows`, `outputRows`) the builder derives
|
|
994
|
+
* nothing, so the artifact already holds the whole answer: the element is the
|
|
995
|
+
* element, the tag is the payload's own tag, and the context, inputs and output the
|
|
996
|
+
* spec would otherwise default are all empty. Nothing about the type is guessed.
|
|
997
|
+
*
|
|
998
|
+
* Deployed processes and the BPMN engine's own test data carry types the registry has
|
|
999
|
+
* never listed (`Maestro.TaskCancellationHandler`, `Orchestrator.StartInlineAgentJob`,
|
|
1000
|
+
* the `ConversationalService.*` family); refusing them made the whole process
|
|
1001
|
+
* un-importable for a node the author may never touch.
|
|
1002
|
+
*/
|
|
1003
|
+
function artifactSpec(el, payload) {
|
|
1004
|
+
const tag = String(payload.$type);
|
|
1005
|
+
const [ns, local] = tag.split(':');
|
|
1006
|
+
return {
|
|
1007
|
+
element: el.$type,
|
|
1008
|
+
// `uipath:Activity` is the moddle type; the spec spells the XML tag, `uipath:activity`.
|
|
1009
|
+
tag: `${ns}:${local.charAt(0).toLowerCase()}${local.slice(1)}`,
|
|
1010
|
+
inputPattern: 'separateInputs',
|
|
1011
|
+
inputName: null,
|
|
1012
|
+
inputTarget: null,
|
|
1013
|
+
context: [],
|
|
1014
|
+
inputs: [],
|
|
1015
|
+
output: null,
|
|
1016
|
+
eventDefinition: null,
|
|
1017
|
+
requiresDiscovery: false,
|
|
1018
|
+
bindingPattern: 'none',
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
/** A spec as source, for the `spec` option. */
|
|
1022
|
+
function emitSpec(spec) {
|
|
1023
|
+
return opts([
|
|
1024
|
+
['element', spec.element === null ? 'null' : tsText(spec.element)],
|
|
1025
|
+
['tag', spec.tag === null ? 'null' : tsText(spec.tag)],
|
|
1026
|
+
['inputPattern', tsText(spec.inputPattern)],
|
|
1027
|
+
['inputName', 'null'],
|
|
1028
|
+
['inputTarget', 'null'],
|
|
1029
|
+
['context', '[]'],
|
|
1030
|
+
['inputs', '[]'],
|
|
1031
|
+
['output', 'null'],
|
|
1032
|
+
['eventDefinition', 'null'],
|
|
1033
|
+
['requiresDiscovery', 'false'],
|
|
1034
|
+
['bindingPattern', tsText(spec.bindingPattern)],
|
|
1035
|
+
]);
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* A node whose extension type the registry does not list — carried verbatim.
|
|
1039
|
+
*
|
|
1040
|
+
* Written as `.activity()` with the spec read off the artifact ({@link artifactSpec})
|
|
1041
|
+
* and every row spelled out, so the recompile reproduces the element exactly and the
|
|
1042
|
+
* rest of the process stays editable. Event elements never reach here: an unlisted type
|
|
1043
|
+
* cannot describe one (`typeDescribesElement`), so the event emitter keeps the element.
|
|
1044
|
+
*/
|
|
1045
|
+
function emitUnlistedTypedNode(chain, el, payload, type) {
|
|
1046
|
+
const id = el.id;
|
|
1047
|
+
const inputRows = payload.input ?? [];
|
|
1048
|
+
chain.add(`.activity(${tsText(id)}, ${tsText(type)}, ${opts([
|
|
1049
|
+
['name', el.name !== undefined ? tsText(el.name) : undefined],
|
|
1050
|
+
['spec', emitSpec(artifactSpec(el, payload))],
|
|
1051
|
+
['typeVersion', payload.type?.version && payload.type.version !== 'v1' ? tsText(payload.type.version) : undefined],
|
|
1052
|
+
['contextRows', emitContextRows(payload)],
|
|
1053
|
+
['inputSchema', payload.context?.inputSchema?.body !== undefined ? jsonLiteral(payload.context.inputSchema.body) : undefined],
|
|
1054
|
+
['inputRows', emitInputRows(inputRows)],
|
|
1055
|
+
['outputRows', emitOutputRows(payload) ?? '[]'],
|
|
1056
|
+
['skipCondition', payload.skipCondition !== undefined ? tsText(payload.skipCondition) : undefined],
|
|
1057
|
+
['entryPointId', entryPointOption(el)],
|
|
1058
|
+
['tags', tagsOf(el)],
|
|
1059
|
+
['retry', emitRetry(retryOf(el))],
|
|
1060
|
+
['errorMapping', emitErrorMapping(errorMappingOf(el))],
|
|
1061
|
+
['loop', emitLoop(el)],
|
|
1062
|
+
])})`);
|
|
1063
|
+
}
|
|
975
1064
|
/**
|
|
976
1065
|
* Whether `inputs` — a name→value record — would reproduce these `separateInputs`
|
|
977
1066
|
* rows, or whether they need spelling out as `inputRows`.
|
|
@@ -2595,7 +2684,12 @@ lifted = new Set()) {
|
|
|
2595
2684
|
// declaration on the way back in (`implicitNodeVars`' script arm), so they are
|
|
2596
2685
|
// skipped here too, or the source redeclares every one of them in `.vars()`.
|
|
2597
2686
|
const spelledOutScriptRows = localName(el.$type) === 'scriptTask' && type === 'BPMN.Variables' && outputRowsNeedSpellingOut(payload);
|
|
2598
|
-
|
|
2687
|
+
// A type the registry does not list is emitted on its own element with every row
|
|
2688
|
+
// spelled out (`emitUnlistedTypedNode`), and those rows declare their variables on
|
|
2689
|
+
// the way back in like any typed node's — so they are candidates too, wherever the
|
|
2690
|
+
// typed path is the one that writes the element.
|
|
2691
|
+
const unlistedTyped = !!payload && !!type && type !== 'BPMN.Variables' && !ELEMENT_OWNS.has(localName(el.$type)) && !listedSpec(type);
|
|
2692
|
+
if (payload && type && (spelledOutScriptRows || unlistedTyped || (type !== 'BPMN.Variables' && typeDescribesElement(localName(el.$type), type)))) {
|
|
2599
2693
|
for (const row of payload.output ?? []) {
|
|
2600
2694
|
if (!row.var)
|
|
2601
2695
|
continue;
|
package/dist/check.js
CHANGED
|
@@ -1712,26 +1712,27 @@ function checkNodeUpdates(built, diags) {
|
|
|
1712
1712
|
// A variable declared by `{ shared }` (#924) is a `.var()` like any other.
|
|
1713
1713
|
...planSharedInputs({ roots: sharedInputRoots(built), outputs: built.outputs, vars: built.vars }).autoVars.map((v) => v.name),
|
|
1714
1714
|
]);
|
|
1715
|
+
const judge = (updates, stepName) => {
|
|
1716
|
+
for (const name of Object.keys(updates ?? {})) {
|
|
1717
|
+
if (writable.has(name))
|
|
1718
|
+
continue;
|
|
1719
|
+
if (inputs.has(name)) {
|
|
1720
|
+
diags.push({
|
|
1721
|
+
level: 'error', code: 'UPDATE_INPUT_READONLY', step: stepName,
|
|
1722
|
+
message: `{ updates } assigns "${name}", but it is a flow INPUT — the caller owns its value. Declare a .var() instead.`,
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
else {
|
|
1726
|
+
diags.push({
|
|
1727
|
+
level: 'error', code: 'UPDATE_UNKNOWN_VAR', step: stepName,
|
|
1728
|
+
message: `{ updates } assigns "${name}", which is not a declared .var() or output.`,
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1715
1733
|
const visit = (steps) => {
|
|
1716
1734
|
for (const s of steps) {
|
|
1717
|
-
|
|
1718
|
-
const stepName = 'name' in s ? s.name : undefined;
|
|
1719
|
-
for (const name of Object.keys(updates ?? {})) {
|
|
1720
|
-
if (writable.has(name))
|
|
1721
|
-
continue;
|
|
1722
|
-
if (inputs.has(name)) {
|
|
1723
|
-
diags.push({
|
|
1724
|
-
level: 'error', code: 'UPDATE_INPUT_READONLY', step: stepName,
|
|
1725
|
-
message: `{ updates } assigns "${name}", but it is a flow INPUT — the caller owns its value. Declare a .var() instead.`,
|
|
1726
|
-
});
|
|
1727
|
-
}
|
|
1728
|
-
else {
|
|
1729
|
-
diags.push({
|
|
1730
|
-
level: 'error', code: 'UPDATE_UNKNOWN_VAR', step: stepName,
|
|
1731
|
-
message: `{ updates } assigns "${name}", which is not a declared .var() or output.`,
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
+
judge(s.options?.updates, 'name' in s ? s.name : undefined);
|
|
1735
1736
|
if (s.kind === 'branch') {
|
|
1736
1737
|
visit(s.then);
|
|
1737
1738
|
visit(s.otherwise);
|
|
@@ -1749,6 +1750,10 @@ function checkNodeUpdates(built, diags) {
|
|
|
1749
1750
|
visit(s.body);
|
|
1750
1751
|
}
|
|
1751
1752
|
};
|
|
1753
|
+
// A root's own `{ updates }` (#1673).
|
|
1754
|
+
judge(built.triggerOptions?.updates, built.triggerId ?? 'start');
|
|
1755
|
+
for (const ep of built.entryPoints ?? [])
|
|
1756
|
+
judge(ep.options?.updates, ep.id);
|
|
1752
1757
|
visit(built.steps);
|
|
1753
1758
|
}
|
|
1754
1759
|
/**
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -328,9 +328,9 @@ export declare const REFUSALS: {
|
|
|
328
328
|
readonly EVENT_UNPREPARED: "lint";
|
|
329
329
|
readonly EVENT_WHERE_NOT_SCALAR: "lowering";
|
|
330
330
|
readonly EXCEPTION_STAGE_REQUIRED: "lint";
|
|
331
|
-
readonly EXPR_BARE_VAR_REF: "
|
|
331
|
+
readonly EXPR_BARE_VAR_REF: "lint";
|
|
332
332
|
readonly EXPR_SYNTAX: "lowering";
|
|
333
|
-
readonly EXPR_UNDECLARED_REF: "
|
|
333
|
+
readonly EXPR_UNDECLARED_REF: "lint";
|
|
334
334
|
readonly EXTERNAL_TASK_CONNECTION: "lowering";
|
|
335
335
|
readonly EXTERNAL_TASK_DESCRIPTOR: "lint";
|
|
336
336
|
readonly EXTERNAL_TASK_DESCRIPTOR_CONTRACT: "lowering";
|
package/dist/core/refusals.js
CHANGED
|
@@ -401,9 +401,9 @@ export const REFUSALS = {
|
|
|
401
401
|
EVENT_UNPREPARED: 'lint',
|
|
402
402
|
EVENT_WHERE_NOT_SCALAR: 'lowering',
|
|
403
403
|
EXCEPTION_STAGE_REQUIRED: 'lint',
|
|
404
|
-
EXPR_BARE_VAR_REF: '
|
|
404
|
+
EXPR_BARE_VAR_REF: 'lint',
|
|
405
405
|
EXPR_SYNTAX: 'lowering',
|
|
406
|
-
EXPR_UNDECLARED_REF: '
|
|
406
|
+
EXPR_UNDECLARED_REF: 'lint',
|
|
407
407
|
EXTERNAL_TASK_CONNECTION: 'lowering',
|
|
408
408
|
EXTERNAL_TASK_DESCRIPTOR: 'lint',
|
|
409
409
|
EXTERNAL_TASK_DESCRIPTOR_CONTRACT: 'lowering',
|
package/dist/decompile.js
CHANGED
|
@@ -273,10 +273,11 @@ function hasRenamedLabel(node, defaultLabel) {
|
|
|
273
273
|
const label = node.display?.label;
|
|
274
274
|
return typeof label === 'string' && label !== defaultLabel;
|
|
275
275
|
}
|
|
276
|
-
/** `
|
|
277
|
-
function
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
/** `updates: { <var>: <value>, … }` for a node's `variableUpdates` rows, in file order; `undefined` for none. */
|
|
277
|
+
function updatesPart(rows, imp, inputNames) {
|
|
278
|
+
if (rows.length === 0)
|
|
279
|
+
return undefined;
|
|
280
|
+
return `updates: { ${rows.map((u) => `${key(u.variableId)}: ${emitVal(u.expression, imp, inputNames)}`).join(', ')} }`;
|
|
280
281
|
}
|
|
281
282
|
/**
|
|
282
283
|
* The full node-options argument for steps that can carry both an exact
|
|
@@ -299,11 +300,9 @@ function optsArgWith(node, ctx, extra) {
|
|
|
299
300
|
const label = node.display?.label;
|
|
300
301
|
if (typeof label === 'string' && label !== node.id)
|
|
301
302
|
parts.push(`label: ${tsLiteral(label)}`);
|
|
302
|
-
const updates = ctx.flow.variables?.variableUpdates?.[node.id] ?? [];
|
|
303
|
-
if (updates
|
|
304
|
-
|
|
305
|
-
parts.push(`updates: { ${entries.join(', ')} }`);
|
|
306
|
-
}
|
|
303
|
+
const updates = updatesPart(ctx.flow.variables?.variableUpdates?.[node.id] ?? [], ctx.imp, ctx.inputNames);
|
|
304
|
+
if (updates)
|
|
305
|
+
parts.push(updates);
|
|
307
306
|
// A draft the canvas saved: `compile` writes it back only when the step says
|
|
308
307
|
// so AND the source carries its definition (carriedPairs), so a draft an agent
|
|
309
308
|
// adds of the same operation is still refused (StepOptions.draft).
|
|
@@ -1338,12 +1337,17 @@ function declExpr(g, withDefault, imp, shared) {
|
|
|
1338
1337
|
function sharedCopies(flow, triggers) {
|
|
1339
1338
|
const globals = readFlowGlobals(flow.variables, runStrict);
|
|
1340
1339
|
const byInput = new Map();
|
|
1341
|
-
const
|
|
1340
|
+
const updates = new Map();
|
|
1342
1341
|
const fed = new Map();
|
|
1343
1342
|
for (const t of triggers) {
|
|
1344
1343
|
const rows = flow.variables?.variableUpdates?.[t.id] ?? [];
|
|
1345
1344
|
const seenOnRoot = new Set();
|
|
1345
|
+
const rest = [];
|
|
1346
1346
|
for (const row of rows) {
|
|
1347
|
+
if (rest.length > 0) {
|
|
1348
|
+
rest.push(row);
|
|
1349
|
+
continue;
|
|
1350
|
+
}
|
|
1347
1351
|
const src = unwrapSource(row.expression);
|
|
1348
1352
|
const m = src?.startsWith('=js:') ? /^\$vars\.([A-Za-z0-9_]+)\.output\.([A-Za-z0-9_]+)$/.exec(src.slice(4).trim()) : null;
|
|
1349
1353
|
const inp = m && m[1] === t.id
|
|
@@ -1353,13 +1357,15 @@ function sharedCopies(flow, triggers) {
|
|
|
1353
1357
|
const ok = inp !== undefined && target !== undefined && target.type === inp.type
|
|
1354
1358
|
&& !byInput.has(`${t.id}\0${inp.id}`) && !seenOnRoot.has(row.variableId);
|
|
1355
1359
|
if (!ok) {
|
|
1356
|
-
|
|
1360
|
+
rest.push(row);
|
|
1357
1361
|
continue;
|
|
1358
1362
|
}
|
|
1359
1363
|
seenOnRoot.add(row.variableId);
|
|
1360
1364
|
byInput.set(`${t.id}\0${inp.id}`, row.variableId);
|
|
1361
1365
|
fed.set(row.variableId, (fed.get(row.variableId) ?? 0) + 1);
|
|
1362
1366
|
}
|
|
1367
|
+
if (rest.length > 0)
|
|
1368
|
+
updates.set(t.id, rest);
|
|
1363
1369
|
}
|
|
1364
1370
|
const auto = new Set();
|
|
1365
1371
|
for (const name of fed.keys()) {
|
|
@@ -1368,7 +1374,7 @@ function sharedCopies(flow, triggers) {
|
|
|
1368
1374
|
&& g.subType === undefined && g.schema === undefined)
|
|
1369
1375
|
auto.add(name);
|
|
1370
1376
|
}
|
|
1371
|
-
return { byInput, auto,
|
|
1377
|
+
return { byInput, auto, updates };
|
|
1372
1378
|
}
|
|
1373
1379
|
function emitVariables(e, depth, flow, imp, epTriggers = new Set(), shared) {
|
|
1374
1380
|
const globals = readFlowGlobals(flow.variables, runStrict);
|
|
@@ -1411,7 +1417,7 @@ function triggerFactory(t, imp, inputNames) {
|
|
|
1411
1417
|
return `${imp.use('onEvent')}(${sub})`;
|
|
1412
1418
|
return undefined;
|
|
1413
1419
|
}
|
|
1414
|
-
function emitTrigger(e, depth, trigger, imp, o, inputNames = new Set()) {
|
|
1420
|
+
function emitTrigger(e, depth, trigger, imp, o, inputNames = new Set(), extra = []) {
|
|
1415
1421
|
// The trigger's id is addressable — a flow's inputs are published as its
|
|
1416
1422
|
// output — so a renamed one has to survive the round trip. `start` is the
|
|
1417
1423
|
// default and stays implicit.
|
|
@@ -1419,7 +1425,8 @@ function emitTrigger(e, depth, trigger, imp, o, inputNames = new Set()) {
|
|
|
1419
1425
|
e.line(depth, `.triggerId(${tsLiteral(trigger.id)})`);
|
|
1420
1426
|
const factory = triggerFactory(trigger, imp, inputNames);
|
|
1421
1427
|
if (factory !== undefined) {
|
|
1422
|
-
|
|
1428
|
+
const parts = [...triggerOptParts(trigger), ...extra];
|
|
1429
|
+
e.line(depth, `.trigger(${factory}${parts.length ? `, { ${parts.join(', ')} }` : ''})`);
|
|
1423
1430
|
return;
|
|
1424
1431
|
}
|
|
1425
1432
|
if (o.bestEffort === false) {
|
|
@@ -2974,8 +2981,12 @@ function emitChildFlowIn(name, child, trigger, ctx) {
|
|
|
2974
2981
|
// The one trigger a subflow may carry names its Start node (#1050).
|
|
2975
2982
|
const childStart = trigger && FLOW_TRIGGER_TYPES.byTypeName(trigger.type)?.type.subflowStart
|
|
2976
2983
|
? triggerFactory(trigger, ctx.imp, ctx.inputNames) : undefined;
|
|
2977
|
-
|
|
2978
|
-
|
|
2984
|
+
// Its rows are the child trigger's own `{ updates }` (#1673).
|
|
2985
|
+
const startUpdates = trigger === undefined ? undefined
|
|
2986
|
+
: updatesPart(child.variables?.variableUpdates?.[trigger.id] ?? [], ctx.imp, childCtx.inputNames);
|
|
2987
|
+
if (childStart !== undefined && (hasRenamedLabel(trigger, SUBFLOW_START_LABEL) || startUpdates !== undefined)) {
|
|
2988
|
+
const startOpts = [...triggerOptParts(trigger, SUBFLOW_START_LABEL), ...(startUpdates === undefined ? [] : [startUpdates])];
|
|
2989
|
+
parts.push(`.trigger(${childStart}, { ${startOpts.join(', ')} })`);
|
|
2979
2990
|
}
|
|
2980
2991
|
const scope = scopeIds(child.nodes ?? [], undefined);
|
|
2981
2992
|
const entries = trigger ? scopeSuccEdges(childCtx.graph, trigger.id, scope) : [];
|
|
@@ -3184,8 +3195,15 @@ export function decompile(flow, options = {}) {
|
|
|
3184
3195
|
const trigger = triggerNodes.find((n) => (n.inputs ?? {}).isDefaultEntryPoint === true)
|
|
3185
3196
|
?? graph.byId.get('start')
|
|
3186
3197
|
?? triggerNodes[0];
|
|
3198
|
+
// `{ shared }` input copies on the roots (#924); every other trigger-level
|
|
3199
|
+
// row is the trigger's own `{ updates }` (#1673).
|
|
3200
|
+
const shared = sharedCopies(flow, triggerNodes);
|
|
3201
|
+
const rootUpdates = (t) => {
|
|
3202
|
+
const part = updatesPart(shared.updates.get(t.id) ?? [], imp, inputNames);
|
|
3203
|
+
return part === undefined ? [] : [part];
|
|
3204
|
+
};
|
|
3187
3205
|
if (trigger)
|
|
3188
|
-
emitTrigger(e, d, trigger, imp, options, inputNames);
|
|
3206
|
+
emitTrigger(e, d, trigger, imp, options, inputNames, rootUpdates(trigger));
|
|
3189
3207
|
// Nodes no trigger reaches. The region walk below starts at the trigger's
|
|
3190
3208
|
// successor and follows edges, so a node with no path from any root was
|
|
3191
3209
|
// silently absent from the source — it survived only as a `.layout()` key,
|
|
@@ -3206,19 +3224,6 @@ export function decompile(flow, options = {}) {
|
|
|
3206
3224
|
e.line(d, `// TODO: node ${commentText(tsLiteral(n.id))} (${commentText(n.type)}) is not reachable from any trigger and is NOT in this source; recompiling drops it. Connect it in the .flow or edit its JSON directly.`);
|
|
3207
3225
|
}
|
|
3208
3226
|
}
|
|
3209
|
-
// `{ shared }` input copies on the roots (#924). Any other trigger-level
|
|
3210
|
-
// update has no builder spelling: say so instead of dropping it.
|
|
3211
|
-
const shared = sharedCopies(flow, triggerNodes);
|
|
3212
|
-
if (shared.unrecognized.length) {
|
|
3213
|
-
const listing = shared.unrecognized.map((u) => `${tsLiteral(u.variableId)} on ${tsLiteral(u.trigger)}`).join(', ');
|
|
3214
|
-
const message = `${shared.unrecognized.length} variable update(s) on a trigger node are not a { shared } input copy: ${listing}. `
|
|
3215
|
-
+ 'The builder writes a trigger-level update only for { type, shared: \'<var>\' } (the row `<var> ← $vars.<trigger>.output.<input>`), '
|
|
3216
|
-
+ 'so this source omits them and recompiling drops them.';
|
|
3217
|
-
if (runStrict)
|
|
3218
|
-
throw new Error(`decompile: ${message}`);
|
|
3219
|
-
warnOnce(message);
|
|
3220
|
-
e.line(d, `// TODO: ${commentText(message)}`);
|
|
3221
|
-
}
|
|
3222
3227
|
emitVariables(e, d, flow, imp, new Set(triggerNodes.filter((t) => t !== trigger).map((t) => t.id)), shared);
|
|
3223
3228
|
// Reconstruct the body: structured control flow recovered from the graph.
|
|
3224
3229
|
const ctx = {
|
|
@@ -3337,6 +3342,9 @@ function entryPointSeg(t, scope, ipdom, ctx) {
|
|
|
3337
3342
|
optParts.push(`inputs: { ${scoped.map((g) => `${key(g.name ?? g.id)}: ${declExpr(g, true, ctx.imp, sharedOf(g))}`).join(', ')} }`);
|
|
3338
3343
|
}
|
|
3339
3344
|
optParts.push(...triggerOptParts(t));
|
|
3345
|
+
const updates = updatesPart(ctx.shared?.updates.get(t.id) ?? [], ctx.imp, ctx.inputNames);
|
|
3346
|
+
if (updates)
|
|
3347
|
+
optParts.push(updates);
|
|
3340
3348
|
const firsts = scopeSuccEdges(ctx.graph, t.id, scope);
|
|
3341
3349
|
// A prefix that forks needs post-dominators over ITS nodes, which the root's
|
|
3342
3350
|
// map (computed from the default trigger) does not cover.
|
package/dist/flow-sdk.d.ts
CHANGED
|
@@ -257,9 +257,18 @@ export interface NodeOptions {
|
|
|
257
257
|
* Variable.
|
|
258
258
|
*
|
|
259
259
|
* @remarks
|
|
260
|
-
* Not accepted on `.branch()`, `.switch()
|
|
261
|
-
*
|
|
262
|
-
*
|
|
260
|
+
* Not accepted on `.branch()`, `.switch()` or `.parallel()` — the platform
|
|
261
|
+
* strips updates from decision/switch/merge nodes on save.
|
|
262
|
+
*
|
|
263
|
+
* On `.trigger()` and `.entryPoint()` the rows run when the root fires,
|
|
264
|
+
* after the root's `{ shared }` input copies, and may read what the trigger
|
|
265
|
+
* published. For instance
|
|
266
|
+
*
|
|
267
|
+
* ```ts
|
|
268
|
+
* .trigger(manual(), { updates: { doc: js`${input('payload')}.document ?? ${v('doc')}` } })
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* writes the row `doc ← $vars.start.output.payload.document ?? $vars.doc`.
|
|
263
272
|
*/
|
|
264
273
|
updates?: Record<string, Expr | unknown>;
|
|
265
274
|
/**
|
|
@@ -686,7 +695,7 @@ export interface BuiltEntryPoint {
|
|
|
686
695
|
id: string;
|
|
687
696
|
/** What fires this root: any built-in trigger factory, or a custom trigger. */
|
|
688
697
|
trigger: TriggerSpec;
|
|
689
|
-
/** Node options for the trigger node — exact `version` selection
|
|
698
|
+
/** Node options for the trigger node — exact `version` selection, canvas `label`, and `updates`. */
|
|
690
699
|
options?: NodeOptions;
|
|
691
700
|
/** Inputs scoped to this root (globals bound to it via `triggerNodeId`). */
|
|
692
701
|
inputs: VarDecl[];
|
|
@@ -1398,12 +1407,13 @@ declare class FlowBuilder extends StepList {
|
|
|
1398
1407
|
* `conversationTrigger()`, or `voiceTrigger()`.
|
|
1399
1408
|
* @param options - `version` (exact trigger definition version), `label`
|
|
1400
1409
|
* (what the canvas shows on the trigger node; default: the trigger
|
|
1401
|
-
* definition's label, e.g. `Manual trigger`),
|
|
1410
|
+
* definition's label, e.g. `Manual trigger`), `updates` (variable rows run when this root fires; see
|
|
1411
|
+
* {@link NodeOptions.updates}), and `inputs` — this root's scoped inputs, declared like
|
|
1402
1412
|
* `.input()`.
|
|
1403
1413
|
* @param prefixFn - Optional sub-builder for the root's prefix steps.
|
|
1404
1414
|
* @returns This builder, so calls chain.
|
|
1405
1415
|
*/
|
|
1406
|
-
entryPoint(id: string, trigger: TriggerSpec | FlowTrigger, options?: Pick<NodeOptions, 'version' | 'label'> & {
|
|
1416
|
+
entryPoint(id: string, trigger: TriggerSpec | FlowTrigger, options?: Pick<NodeOptions, 'version' | 'label' | 'updates'> & {
|
|
1407
1417
|
inputs?: Record<string, FlowTypeDesc | VarSpec>;
|
|
1408
1418
|
}, prefixFn?: (b: StepList) => void): this;
|
|
1409
1419
|
/**
|