@uipath/maestro-builder-sdk 5.2.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/LICENSE +21 -0
- package/README.md +322 -0
- package/dist/bindings-v2.d.ts +37 -0
- package/dist/bindings-v2.js +155 -0
- package/dist/bindings.d.ts +6 -0
- package/dist/bindings.js +6 -0
- package/dist/bpmn/bpmn-expr-check.d.ts +41 -0
- package/dist/bpmn/bpmn-expr-check.js +218 -0
- package/dist/bpmn/bpmn-sdk.d.ts +2257 -0
- package/dist/bpmn/bpmn-sdk.js +1476 -0
- package/dist/bpmn/check-cli.d.ts +3 -0
- package/dist/bpmn/check-cli.js +32 -0
- package/dist/bpmn/check.d.ts +25 -0
- package/dist/bpmn/check.js +430 -0
- package/dist/bpmn/compile-cli.d.ts +3 -0
- package/dist/bpmn/compile-cli.js +60 -0
- package/dist/bpmn/connector.d.ts +56 -0
- package/dist/bpmn/connector.js +199 -0
- package/dist/bpmn/decompile-cli.d.ts +8 -0
- package/dist/bpmn/decompile-cli.js +54 -0
- package/dist/bpmn/decompile.d.ts +6 -0
- package/dist/bpmn/decompile.js +1108 -0
- package/dist/bpmn/format-profile.d.ts +27 -0
- package/dist/bpmn/format-profile.js +11 -0
- package/dist/bpmn/intsvc.d.ts +77 -0
- package/dist/bpmn/intsvc.js +155 -0
- package/dist/bpmn/load.d.ts +4 -0
- package/dist/bpmn/load.js +22 -0
- package/dist/bpmn/merge-cli.d.ts +3 -0
- package/dist/bpmn/merge-cli.js +45 -0
- package/dist/bpmn/merge.d.ts +19 -0
- package/dist/bpmn/merge.js +293 -0
- package/dist/bpmn/registry-types.json +1869 -0
- package/dist/bpmn/serialize.d.ts +28 -0
- package/dist/bpmn/serialize.js +757 -0
- package/dist/bpmn/tidy-cli.d.ts +2 -0
- package/dist/bpmn/tidy-cli.js +39 -0
- package/dist/bpmn/typed-node.d.ts +382 -0
- package/dist/bpmn/typed-node.js +551 -0
- package/dist/bpmn/uipath-moddle.v1.json +823 -0
- package/dist/bpmn/xml-ranges.d.ts +45 -0
- package/dist/bpmn/xml-ranges.js +151 -0
- package/dist/case/case-expr-check.d.ts +35 -0
- package/dist/case/case-expr-check.js +85 -0
- package/dist/case/case-sdk.d.ts +1282 -0
- package/dist/case/case-sdk.js +923 -0
- package/dist/case/check-cli.d.ts +3 -0
- package/dist/case/check-cli.js +31 -0
- package/dist/case/check.d.ts +18 -0
- package/dist/case/check.js +456 -0
- package/dist/case/compile-cli.d.ts +3 -0
- package/dist/case/compile-cli.js +291 -0
- package/dist/case/decompile-cli.d.ts +9 -0
- package/dist/case/decompile-cli.js +117 -0
- package/dist/case/decompile.d.ts +187 -0
- package/dist/case/decompile.js +1170 -0
- package/dist/case/entry-points.d.ts +79 -0
- package/dist/case/entry-points.js +118 -0
- package/dist/case/format-profile.d.ts +60 -0
- package/dist/case/format-profile.js +79 -0
- package/dist/case/ids.d.ts +24 -0
- package/dist/case/ids.js +76 -0
- package/dist/case/load.d.ts +12 -0
- package/dist/case/load.js +32 -0
- package/dist/case/preserve.d.ts +133 -0
- package/dist/case/preserve.js +105 -0
- package/dist/case/serialize.d.ts +10 -0
- package/dist/case/serialize.js +1414 -0
- package/dist/check-cli.d.ts +3 -0
- package/dist/check-cli.js +118 -0
- package/dist/check.d.ts +146 -0
- package/dist/check.js +4898 -0
- package/dist/cli/commands/bpmn.d.ts +2 -0
- package/dist/cli/commands/bpmn.js +73 -0
- package/dist/cli/commands/case.d.ts +2 -0
- package/dist/cli/commands/case.js +60 -0
- package/dist/cli/commands/flow.d.ts +2 -0
- package/dist/cli/commands/flow.js +99 -0
- package/dist/cli/commands/registry.d.ts +10 -0
- package/dist/cli/commands/registry.js +170 -0
- package/dist/cli/common.d.ts +30 -0
- package/dist/cli/common.js +92 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli-run.d.ts +2 -0
- package/dist/cli-run.js +42 -0
- package/dist/compile-cli.d.ts +3 -0
- package/dist/compile-cli.js +160 -0
- package/dist/config.d.ts +47 -0
- package/dist/config.js +201 -0
- package/dist/core/actions.d.ts +3244 -0
- package/dist/core/actions.js +1062 -0
- package/dist/core/binding-messages.d.ts +1 -0
- package/dist/core/binding-messages.js +16 -0
- package/dist/core/bindings.d.ts +12 -0
- package/dist/core/bindings.js +67 -0
- package/dist/core/ceql.d.ts +73 -0
- package/dist/core/ceql.js +272 -0
- package/dist/core/cli-spelling.d.ts +39 -0
- package/dist/core/cli-spelling.js +62 -0
- package/dist/core/connector-raw-node.d.ts +21 -0
- package/dist/core/connector-raw-node.js +47 -0
- package/dist/core/connectors.d.ts +184 -0
- package/dist/core/connectors.js +128 -0
- package/dist/core/expr-check.d.ts +93 -0
- package/dist/core/expr-check.js +186 -0
- package/dist/core/expr.d.ts +323 -0
- package/dist/core/expr.js +400 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.js +10 -0
- package/dist/core/library.d.ts +440 -0
- package/dist/core/library.js +1183 -0
- package/dist/core/list-envelope.d.ts +45 -0
- package/dist/core/list-envelope.js +97 -0
- package/dist/core/lookup-store.d.ts +22 -0
- package/dist/core/lookup-store.js +85 -0
- package/dist/core/lookups.d.ts +227 -0
- package/dist/core/lookups.js +231 -0
- package/dist/core/node-classes.d.ts +234 -0
- package/dist/core/node-classes.js +158 -0
- package/dist/core/script-return.d.ts +68 -0
- package/dist/core/script-return.js +197 -0
- package/dist/core/stable-id.d.ts +28 -0
- package/dist/core/stable-id.js +37 -0
- package/dist/core-definitions.json +16249 -0
- package/dist/decompile-cli.d.ts +3 -0
- package/dist/decompile-cli.js +131 -0
- package/dist/decompile.d.ts +138 -0
- package/dist/decompile.js +2482 -0
- package/dist/emit.d.ts +10 -0
- package/dist/emit.js +60 -0
- package/dist/event-filters.d.ts +130 -0
- package/dist/event-filters.js +137 -0
- package/dist/flow-expr-check.d.ts +17 -0
- package/dist/flow-expr-check.js +193 -0
- package/dist/flow-sdk.d.ts +1341 -0
- package/dist/flow-sdk.js +1164 -0
- package/dist/flow-variables.d.ts +13 -0
- package/dist/flow-variables.js +42 -0
- package/dist/format-profile.d.ts +72 -0
- package/dist/format-profile.js +97 -0
- package/dist/generators/_connections.py +287 -0
- package/dist/generators/_events.py +355 -0
- package/dist/generators/_lookups.py +114 -0
- package/dist/generators/_naming.py +185 -0
- package/dist/generators/_objects.py +299 -0
- package/dist/generators/_resolve.py +273 -0
- package/dist/generators/convert_library_to_md.py +1441 -0
- package/dist/generators/extract_library.py +125 -0
- package/dist/generators/generate_connectors_ts.py +936 -0
- package/dist/generators/generate_library_json.py +2527 -0
- package/dist/generators/generate_triggers_ts.py +110 -0
- package/dist/generators/materialize_registry.py +155 -0
- package/dist/generators/prepare_connector.py +1688 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +35 -0
- package/dist/ixp-definition.json +1982 -0
- package/dist/library.d.ts +6 -0
- package/dist/library.js +6 -0
- package/dist/load.d.ts +16 -0
- package/dist/load.js +95 -0
- package/dist/merge-cli.d.ts +3 -0
- package/dist/merge-cli.js +47 -0
- package/dist/merge.d.ts +125 -0
- package/dist/merge.js +0 -0
- package/dist/migrate.d.ts +15 -0
- package/dist/migrate.js +245 -0
- package/dist/node-runtime.d.ts +3 -0
- package/dist/node-runtime.js +22 -0
- package/dist/package-name.d.ts +17 -0
- package/dist/package-name.js +17 -0
- package/dist/ref-resolve.d.ts +77 -0
- package/dist/ref-resolve.js +170 -0
- package/dist/registry/cache.d.ts +55 -0
- package/dist/registry/cache.js +134 -0
- package/dist/registry/curated-overlay.d.ts +16 -0
- package/dist/registry/curated-overlay.js +62 -0
- package/dist/registry/extractor.d.ts +22 -0
- package/dist/registry/extractor.js +18 -0
- package/dist/registry/materialize-bin.d.ts +2 -0
- package/dist/registry/materialize-bin.js +7 -0
- package/dist/registry/materialize-cli.d.ts +1 -0
- package/dist/registry/materialize-cli.js +46 -0
- package/dist/registry/materializer.d.ts +23 -0
- package/dist/registry/materializer.js +34 -0
- package/dist/registry/path-cli.d.ts +1 -0
- package/dist/registry/path-cli.js +56 -0
- package/dist/registry/prepare-cli.d.ts +62 -0
- package/dist/registry/prepare-cli.js +185 -0
- package/dist/registry/pull-cli.d.ts +1 -0
- package/dist/registry/pull-cli.js +274 -0
- package/dist/registry/python.d.ts +26 -0
- package/dist/registry/python.js +46 -0
- package/dist/registry/search-cli.d.ts +52 -0
- package/dist/registry/search-cli.js +159 -0
- package/dist/schema-version.d.ts +165 -0
- package/dist/schema-version.js +148 -0
- package/dist/serialize.d.ts +64 -0
- package/dist/serialize.js +6398 -0
- package/lib/README.md +112 -0
- package/lib/library-json.samples/index.json +158 -0
- package/lib/library-json.samples/invariant-collections.json +83 -0
- package/lib/library-json.samples/list-envelopes.json +123 -0
- package/lib/library-json.samples/uipath-atlassian-jira/create-issue@1.0.0.json +131 -0
- package/lib/library-json.samples/uipath-atlassian-jira/create-issue@1.0.0.v1def.json +306 -0
- package/lib/library-json.samples/uipath-atlassian-jira/generic/create_issue/create@1.0.0.json +86 -0
- package/lib/library-json.samples/uipath-atlassian-jira/generic/create_issue/create@1.0.0.v1def.json +208 -0
- package/lib/library-json.samples/uipath-atlassian-jira/get-issue@1.0.0.json +2040 -0
- package/lib/library-json.samples/uipath-atlassian-jira/get-issue@1.0.0.v1def.json +195 -0
- package/lib/library-json.samples/uipath-google-vertex/execute-google-vertex-agent@1.0.0.json +169 -0
- package/lib/library-json.samples/uipath-google-vertex/execute-google-vertex-agent@1.0.0.v1def.json +209 -0
- package/lib/library-json.samples/uipath-http-webhook/event-http-webhook@1.0.0.json +63 -0
- package/lib/library-json.samples/uipath-http-webhook/event-http-webhook@1.0.0.v1def.json +262 -0
- package/lib/library-json.samples/uipath-http-webhook/trigger-http-webhook@1.0.0.json +63 -0
- package/lib/library-json.samples/uipath-http-webhook/trigger-http-webhook@1.0.0.v1def.json +213 -0
- package/lib/library-json.samples/uipath-microsoft-azureactivedirectory/list-groups@1.0.0.json +227 -0
- package/lib/library-json.samples/uipath-microsoft-azureactivedirectory/list-groups@1.0.0.v1def.json +373 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-file-created@1.0.0.json +116 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-file-created@1.0.0.v1def.json +369 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-list-item-added@1.0.0.json +56 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-list-item-added@1.0.0.v1def.json +256 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-file-created@1.0.0.json +116 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-file-created@1.0.0.v1def.json +320 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-list-item-added@1.0.0.json +56 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-list-item-added@1.0.0.v1def.json +207 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/event-email-received@1.0.0.json +107 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/event-email-received@1.0.0.v1def.json +264 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/send-email@1.0.0.json +142 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/send-email@1.0.0.v1def.json +306 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/trigger-email-received@1.0.0.json +107 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/trigger-email-received@1.0.0.v1def.json +217 -0
- package/lib/library-json.samples/uipath-microsoft-powerautomate/invoke-a-microsoft-power-automate-flow@1.0.0.json +85 -0
- package/lib/library-json.samples/uipath-microsoft-powerautomate/invoke-a-microsoft-power-automate-flow@1.0.0.v1def.json +209 -0
- package/lib/library-json.samples/uipath-salesforce-slack/send-message-to-user@1.0.0.json +755 -0
- package/lib/library-json.samples/uipath-salesforce-slack/send-message-to-user@1.0.0.v1def.json +513 -0
- package/lib/library-json.samples/uipath-uipath-dataservice/query-entity-records@1.0.0.json +122 -0
- package/lib/library-json.samples/uipath-uipath-dataservice/query-entity-records@1.0.0.v1def.json +227 -0
- package/package.json +85 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bpmn-expr-check — the BPMN adapter over the shared `core/expr-check`, run by
|
|
3
|
+
* `BpmnBuilder.build()` before it hands back the model to be serialized.
|
|
4
|
+
*
|
|
5
|
+
* A BPMN `=`-expression reads a declared variable as `=vars.<name>` (a gateway
|
|
6
|
+
* flow `condition`, a script `input`, a multi-instance `collection`/`completion`,
|
|
7
|
+
* a variable assignment). `vars.` is a CLOSED namespace, so a reference to a name
|
|
8
|
+
* nothing declares is a definite mistake — and this is the ONLY thing that
|
|
9
|
+
* catches it early: a `=vars.<typo>` reaches run time and reads `undefined`,
|
|
10
|
+
* silently taking the wrong path. So this flags every undeclared `vars.<root>`,
|
|
11
|
+
* exactly as the flow check flags `$vars`.
|
|
12
|
+
*
|
|
13
|
+
* "Declared" means what it means to the platform, which is wider than
|
|
14
|
+
* `.var()`/`.input()`/`.output()`: a node's output `var` is itself a declaration
|
|
15
|
+
* (the canvas model keys a variable off each output), so a connector's
|
|
16
|
+
* `<id>_response`, a script task's output and a variable task's assignment target
|
|
17
|
+
* are all readable downstream. `nodeDeclaredVars` supplies them; being stricter
|
|
18
|
+
* than the platform here would reject working processes.
|
|
19
|
+
*
|
|
20
|
+
* A loop's item binds `iterator.<itemVar>`, and a script output writes `=result.…`
|
|
21
|
+
* — different namespaces, left alone (only `vars.` is the author's to get wrong).
|
|
22
|
+
* Variables are SCOPED: a sub-process sees the enclosing variables plus its own.
|
|
23
|
+
*/
|
|
24
|
+
import { checkExpression } from '../core/expr-check.js';
|
|
25
|
+
import { nodeDeclaredVars } from './bpmn-sdk.js';
|
|
26
|
+
const NOUN = 'variable';
|
|
27
|
+
const NAMESPACE = 'vars';
|
|
28
|
+
const BINDING_NOUN = 'binding';
|
|
29
|
+
const BINDING_NAMESPACE = 'bindings';
|
|
30
|
+
function checkExpr(expr, where, roots, out) {
|
|
31
|
+
if (!expr)
|
|
32
|
+
return;
|
|
33
|
+
for (const d of checkExpression(expr, { roots: roots.vars, noun: NOUN, namespace: NAMESPACE }))
|
|
34
|
+
out.push({ ...d, where });
|
|
35
|
+
for (const d of checkExpression(expr, { roots: roots.bindings, noun: BINDING_NOUN, namespace: BINDING_NAMESPACE }))
|
|
36
|
+
out.push({ ...d, where });
|
|
37
|
+
// A process variable is always read through the `vars` namespace. The bare
|
|
38
|
+
// spelling is especially easy to confuse with a script task's local input
|
|
39
|
+
// identifiers: `inputs: { amount: '=vars.amount' }` makes `amount` local only
|
|
40
|
+
// inside the script body. On a flow condition or mapping, `=amount` reaches
|
|
41
|
+
// the runtime as an unresolved identifier while both XML validators accept it.
|
|
42
|
+
// Keep this intentionally narrow (a single optionally-parenthesized name) so
|
|
43
|
+
// local declarations inside arbitrary `=js:` programs are not guessed at.
|
|
44
|
+
const bare = expr.match(/^\s*=(?:js:)?\s*\(?\s*([A-Za-z_$][\w$]*)\s*\)?\s*$/)?.[1];
|
|
45
|
+
if (bare && roots.varIds.has(bare)) {
|
|
46
|
+
out.push({
|
|
47
|
+
level: 'error',
|
|
48
|
+
code: 'EXPR_BARE_VAR_REF',
|
|
49
|
+
message: `Expression reads declared variable \`${bare}\` without the \`vars\` namespace; use \`=vars.${bare}\`.`,
|
|
50
|
+
where,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Check every `=`-expression VALUE of a `field → expression` map (keys are targets). */
|
|
55
|
+
function checkExprValues(rec, where, roots, out) {
|
|
56
|
+
for (const v of Object.values(rec ?? {}))
|
|
57
|
+
checkExpr(v, where, roots, out);
|
|
58
|
+
}
|
|
59
|
+
/** Reach `=`-expression strings anywhere in a connector's (possibly nested) inputs. */
|
|
60
|
+
function deepExprStrings(val, where, roots, out) {
|
|
61
|
+
if (typeof val === 'string') {
|
|
62
|
+
if (val.startsWith('='))
|
|
63
|
+
checkExpr(val, where, roots, out);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(val)) {
|
|
67
|
+
for (const v of val)
|
|
68
|
+
deepExprStrings(v, where, roots, out);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (val && typeof val === 'object') {
|
|
72
|
+
for (const v of Object.values(val))
|
|
73
|
+
deepExprStrings(v, where, roots, out);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function walk(nodes, flows, rootsIn, out) {
|
|
77
|
+
// A node's output `var` IS a variable declaration to the platform (its canvas
|
|
78
|
+
// model keys a variable off each output's `var`), so a downstream read of one
|
|
79
|
+
// resolves without any `uipath:variables` entry — a connector's response, a
|
|
80
|
+
// script task's output, a variable task's assignment target. Collect them for
|
|
81
|
+
// the WHOLE scope before walking: a flow condition is checked first but may
|
|
82
|
+
// read a node declared later in authoring order.
|
|
83
|
+
const roots = { vars: new Set(rootsIn.vars), varIds: rootsIn.varIds, bindings: rootsIn.bindings };
|
|
84
|
+
for (const n of nodes)
|
|
85
|
+
for (const name of nodeDeclaredVars(n))
|
|
86
|
+
roots.vars.add(name);
|
|
87
|
+
for (const f of flows)
|
|
88
|
+
checkExpr(f.condition, `flow "${f.id}" condition`, roots, out);
|
|
89
|
+
for (const n of nodes) {
|
|
90
|
+
const at = `${n.kind} "${n.id}"`;
|
|
91
|
+
// An errorMapping row's `condition` is an expression on EVERY activity kind, so
|
|
92
|
+
// it is checked before the per-kind arms rather than inside them. Worth checking
|
|
93
|
+
// here specifically because the CANVAS treats an undeclared reference in it as a
|
|
94
|
+
// blocking error while `uip maestro bpmn validate` says nothing at all — so
|
|
95
|
+
// without this the author's first sign of trouble is the designer refusing the
|
|
96
|
+
// artifact, long after every gate this repo runs went green.
|
|
97
|
+
// Events carry no errorMapping — the field exists on the activity arms only.
|
|
98
|
+
//
|
|
99
|
+
// `error` is a BUILT-IN root here, not an author declaration. The skill's
|
|
100
|
+
// expression reference says so outright — "Error mapping conditions may inspect the
|
|
101
|
+
// built-in error object through `vars.error`, for example
|
|
102
|
+
// `=vars.error.code == \"SERVICE_UNAVAILABLE\"`" — and that example is the whole
|
|
103
|
+
// point of the scenario: a row exists to classify a failure, so the only thing worth
|
|
104
|
+
// branching on is the failure. Requiring `.var('error', …)` first forced authors to
|
|
105
|
+
// declare a DECOY variable whose only purpose was to quiet this check, and which then
|
|
106
|
+
// shipped as a real `uipath:inputOutput` row in the artifact.
|
|
107
|
+
//
|
|
108
|
+
// Scoped to this one expression slot rather than added to the shared root set: outside
|
|
109
|
+
// an errorMapping condition there is no error object in scope, so `vars.error` there
|
|
110
|
+
// really is an undeclared reference and should still be reported.
|
|
111
|
+
// `error` joins `vars` (so `vars.error` resolves) but NOT `varIds`: it is a
|
|
112
|
+
// scoped runtime binding, not a declared variable, so `=error` is not a bare
|
|
113
|
+
// spelling of one.
|
|
114
|
+
const errRoots = { vars: new Set(roots.vars).add('error'), varIds: roots.varIds, bindings: roots.bindings };
|
|
115
|
+
for (const row of ('errorMapping' in n ? n.errorMapping : undefined) ?? []) {
|
|
116
|
+
checkExpr(row.condition, `${at} errorMapping "${row.code}" condition`, errRoots, out);
|
|
117
|
+
}
|
|
118
|
+
// A loop's collection and completion condition, on every activity kind EXCEPT the
|
|
119
|
+
// sub-process, which checks its own below in the right scopes. Only that arm used to
|
|
120
|
+
// check them, so a `.scriptTask({ loop })` — the commonest looping shape — had
|
|
121
|
+
// neither expression checked. It matters more now the engine HONOURS the completion
|
|
122
|
+
// condition: an unevaluatable one is swallowed there and the loop runs the whole
|
|
123
|
+
// collection, so this is the gate that reports it.
|
|
124
|
+
if (n.kind !== 'subProcess' && 'loop' in n && n.loop !== undefined) {
|
|
125
|
+
checkExpr(n.loop.collection, `${at} loop collection`, roots, out);
|
|
126
|
+
// The iterator bindings (`iterator.item`, `iterator.<itemVar>`) are the loop's
|
|
127
|
+
// own, not author declarations, so a completion condition may read them.
|
|
128
|
+
const loopRoots = {
|
|
129
|
+
vars: new Set(roots.vars).add('iterator'),
|
|
130
|
+
varIds: roots.varIds,
|
|
131
|
+
bindings: roots.bindings,
|
|
132
|
+
};
|
|
133
|
+
checkExpr(n.loop.completion, `${at} loop completion`, loopRoots, out);
|
|
134
|
+
}
|
|
135
|
+
if (n.kind === 'scriptTask') {
|
|
136
|
+
checkExprValues(n.inputs, `${at} input`, roots, out);
|
|
137
|
+
checkExprValues(n.outputs, `${at} output`, roots, out);
|
|
138
|
+
}
|
|
139
|
+
else if (n.kind === 'task') {
|
|
140
|
+
checkExprValues(n.set, `${at} assignment`, roots, out);
|
|
141
|
+
}
|
|
142
|
+
else if (n.kind === 'connector') {
|
|
143
|
+
deepExprStrings(n.inputs, `${at} input`, roots, out);
|
|
144
|
+
}
|
|
145
|
+
else if (n.kind === 'subProcess') {
|
|
146
|
+
// A sub-process is its own variable scope: it sees the enclosing variables
|
|
147
|
+
// plus the ones it declares. The loop COLLECTION is evaluated in the
|
|
148
|
+
// enclosing scope (before entry); the body and completion see the sub-scope.
|
|
149
|
+
checkExpr(n.loop?.collection, `${at} loop collection`, roots, out);
|
|
150
|
+
const subRoots = { vars: new Set(roots.vars), varIds: new Set(roots.varIds), bindings: roots.bindings };
|
|
151
|
+
for (const v of n.variables)
|
|
152
|
+
subRoots.vars.add(v.name);
|
|
153
|
+
checkExpr(n.loop?.completion, `${at} loop completion`, subRoots, out);
|
|
154
|
+
walk(n.nodes, n.flows, subRoots, out);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** Every first-level expression problem in a built BPMN process, stamped with its location. */
|
|
159
|
+
export function checkBpmnExpressions(built) {
|
|
160
|
+
const roots = {
|
|
161
|
+
// Keyed by ID, which is what an expression reads — `BpmnVarDecl.id` is documented as
|
|
162
|
+
// "what expressions read as `vars.<id>`", and every product-shaped artifact agrees:
|
|
163
|
+
// the fixtures under skills `edit/*/fixture` declare
|
|
164
|
+
// `<uipath:inputOutput id="Var_OrderId" name="OrderId">` and reference
|
|
165
|
+
// `=vars.Var_OrderId`, never the display name.
|
|
166
|
+
//
|
|
167
|
+
// This read `v.name`, so a variable given a friendly name became unreferenceable: the
|
|
168
|
+
// id an expression uses was not in the root set and every reference to it failed
|
|
169
|
+
// EXPR_UNDECLARED_REF. It only looked right because `.var()` defaults `name` to the id,
|
|
170
|
+
// so the bug was invisible until a display name differed — which is exactly what
|
|
171
|
+
// `bpmn-decompile` produces from any real artifact, so it blocked the whole
|
|
172
|
+
// decompile-edit-recompile round trip.
|
|
173
|
+
//
|
|
174
|
+
// The display name is accepted too. It is not what the wire uses, but an author who
|
|
175
|
+
// wrote `vars.<displayName>` in an existing process should get the reference resolved
|
|
176
|
+
// rather than a spurious error from a stricter check.
|
|
177
|
+
vars: new Set(built.variables.flatMap((v) => [v.id, v.name])),
|
|
178
|
+
varIds: new Set(built.variables.map((v) => v.id)),
|
|
179
|
+
// Author-declared bindings, plus the symbolic connection/folder names a
|
|
180
|
+
// connector turns into bindings at serialize time — the author's own spelling
|
|
181
|
+
// is what they would reference, so both are legitimate roots.
|
|
182
|
+
bindings: new Set([...built.bindings.map((b) => b.id), ...connectorBindingNames(built.nodes)]),
|
|
183
|
+
};
|
|
184
|
+
const out = [];
|
|
185
|
+
walk(built.nodes, built.flows, roots, out);
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
/** Every symbolic connection/folder name in a graph, at any nesting depth. */
|
|
189
|
+
function connectorBindingNames(nodes) {
|
|
190
|
+
const out = [];
|
|
191
|
+
for (const n of nodes) {
|
|
192
|
+
if (n.kind === 'connector') {
|
|
193
|
+
if (n.connection)
|
|
194
|
+
out.push(n.connection);
|
|
195
|
+
if (n.folder)
|
|
196
|
+
out.push(n.folder);
|
|
197
|
+
}
|
|
198
|
+
if (n.kind === 'subProcess')
|
|
199
|
+
out.push(...connectorBindingNames(n.nodes));
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Thrown by `BpmnBuilder.build()` when the first-level expression check finds an
|
|
205
|
+
* undeclared `vars.<name>` reference. Same shape/rationale as the flow's
|
|
206
|
+
* `FlowBuildError`: `message` lists every problem; `diagnostics` carries them
|
|
207
|
+
* structured.
|
|
208
|
+
*/
|
|
209
|
+
export class BpmnBuildError extends Error {
|
|
210
|
+
diagnostics;
|
|
211
|
+
constructor(built, diagnostics) {
|
|
212
|
+
const label = built.name || built.id || 'process';
|
|
213
|
+
const lines = diagnostics.map((d) => ` ✗ [${d.code}] in ${d.where}: ${d.message}${d.suggestion ? ` (did you mean "${d.suggestion}"?)` : ''}`);
|
|
214
|
+
super(`Cannot build BPMN process "${label}" — ${diagnostics.length} expression problem(s):\n${lines.join('\n')}`);
|
|
215
|
+
this.name = 'BpmnBuildError';
|
|
216
|
+
this.diagnostics = diagnostics;
|
|
217
|
+
}
|
|
218
|
+
}
|