@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,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xml-ranges — locate elements by their SOURCE RANGE in an XML document.
|
|
3
|
+
*
|
|
4
|
+
* A tolerant scanner, not a parser: it reports where each element's text begins and
|
|
5
|
+
* ends and nothing about what it means. That is all a merge needs, and it is the only
|
|
6
|
+
* shape that can preserve an element **byte for byte** — the merged document is the
|
|
7
|
+
* original text with a few ranges spliced, so anything untouched is untouched in the
|
|
8
|
+
* literal sense, down to attribute order, quoting and indentation.
|
|
9
|
+
*
|
|
10
|
+
* Why not `bpmn-moddle`, which the SDK already depends on: a moddle round trip
|
|
11
|
+
* normalises. It drops attributes its descriptor does not declare, and the whole point
|
|
12
|
+
* of a brownfield merge is to carry through exactly the payloads the builder does NOT
|
|
13
|
+
* model. Reading with moddle would lose the thing being preserved.
|
|
14
|
+
*
|
|
15
|
+
* Correspondingly, this file must not be mistaken for a general XML implementation. It
|
|
16
|
+
* handles what a `.bpmn` contains — elements, attributes, comments, CDATA, processing
|
|
17
|
+
* instructions, a doctype — and it assumes well-formed input, because every caller has
|
|
18
|
+
* either just written the file or is about to hand it to a real parser anyway.
|
|
19
|
+
*/
|
|
20
|
+
/** One element's place in the source text. */
|
|
21
|
+
export interface XmlRange {
|
|
22
|
+
/** Qualified name as written, e.g. `bpmn:scriptTask`. */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** Name without its prefix, e.g. `scriptTask`. */
|
|
25
|
+
readonly local: string;
|
|
26
|
+
/** `id` attribute, when present — how a merge keys one document's element to another's. */
|
|
27
|
+
readonly id?: string;
|
|
28
|
+
/** Offset of `<`. */
|
|
29
|
+
readonly start: number;
|
|
30
|
+
/** Offset just past `>` of the close tag (or of the self-closing tag). */
|
|
31
|
+
readonly end: number;
|
|
32
|
+
/** Offset just past `>` of the OPEN tag — where this element's content begins. */
|
|
33
|
+
readonly innerStart: number;
|
|
34
|
+
/** Offset of `<` of the close tag. Equals `innerStart` when self-closing. */
|
|
35
|
+
readonly innerEnd: number;
|
|
36
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
37
|
+
readonly children: readonly XmlRange[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Every element in the document, as a tree of source ranges. The returned array holds
|
|
41
|
+
* the top-level elements — a `.bpmn` has exactly one, `bpmn:definitions`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseXmlRanges(xml: string): readonly XmlRange[];
|
|
44
|
+
/** Depth-first search for the first element with the given local name. */
|
|
45
|
+
export declare function findByLocal(nodes: readonly XmlRange[], local: string): XmlRange | undefined;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xml-ranges — locate elements by their SOURCE RANGE in an XML document.
|
|
3
|
+
*
|
|
4
|
+
* A tolerant scanner, not a parser: it reports where each element's text begins and
|
|
5
|
+
* ends and nothing about what it means. That is all a merge needs, and it is the only
|
|
6
|
+
* shape that can preserve an element **byte for byte** — the merged document is the
|
|
7
|
+
* original text with a few ranges spliced, so anything untouched is untouched in the
|
|
8
|
+
* literal sense, down to attribute order, quoting and indentation.
|
|
9
|
+
*
|
|
10
|
+
* Why not `bpmn-moddle`, which the SDK already depends on: a moddle round trip
|
|
11
|
+
* normalises. It drops attributes its descriptor does not declare, and the whole point
|
|
12
|
+
* of a brownfield merge is to carry through exactly the payloads the builder does NOT
|
|
13
|
+
* model. Reading with moddle would lose the thing being preserved.
|
|
14
|
+
*
|
|
15
|
+
* Correspondingly, this file must not be mistaken for a general XML implementation. It
|
|
16
|
+
* handles what a `.bpmn` contains — elements, attributes, comments, CDATA, processing
|
|
17
|
+
* instructions, a doctype — and it assumes well-formed input, because every caller has
|
|
18
|
+
* either just written the file or is about to hand it to a real parser anyway.
|
|
19
|
+
*/
|
|
20
|
+
const ATTRIBUTE = /([^\s=/>]+)\s*=\s*("([^"]*)"|'([^']*)')/g;
|
|
21
|
+
function parseAttributes(source) {
|
|
22
|
+
const attributes = {};
|
|
23
|
+
for (const match of source.matchAll(ATTRIBUTE)) {
|
|
24
|
+
attributes[match[1]] = match[3] ?? match[4] ?? '';
|
|
25
|
+
}
|
|
26
|
+
return attributes;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Find the `>` that closes a tag opening at `from`, ignoring any inside a quoted
|
|
30
|
+
* attribute value — `targetNamespace="http://…/>"` is not the end of the tag.
|
|
31
|
+
*/
|
|
32
|
+
function endOfTag(xml, from) {
|
|
33
|
+
let quote = null;
|
|
34
|
+
for (let i = from; i < xml.length; i += 1) {
|
|
35
|
+
const c = xml[i];
|
|
36
|
+
if (quote) {
|
|
37
|
+
if (c === quote)
|
|
38
|
+
quote = null;
|
|
39
|
+
}
|
|
40
|
+
else if (c === '"' || c === "'") {
|
|
41
|
+
quote = c;
|
|
42
|
+
}
|
|
43
|
+
else if (c === '>') {
|
|
44
|
+
return i;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`xml-ranges: unterminated tag at offset ${from}`);
|
|
48
|
+
}
|
|
49
|
+
/** Skip a construct that ends with a known terminator; returns the offset past it. */
|
|
50
|
+
function skipUntil(xml, from, terminator) {
|
|
51
|
+
const at = xml.indexOf(terminator, from);
|
|
52
|
+
if (at < 0)
|
|
53
|
+
throw new Error(`xml-ranges: unterminated ${terminator.trim()} at offset ${from}`);
|
|
54
|
+
return at + terminator.length;
|
|
55
|
+
}
|
|
56
|
+
function* rawTags(xml) {
|
|
57
|
+
let i = 0;
|
|
58
|
+
while (i < xml.length) {
|
|
59
|
+
const lt = xml.indexOf('<', i);
|
|
60
|
+
if (lt < 0)
|
|
61
|
+
return;
|
|
62
|
+
// Constructs that are not element tags, and whose bodies may contain `<` or `>`.
|
|
63
|
+
if (xml.startsWith('<!--', lt)) {
|
|
64
|
+
i = skipUntil(xml, lt, '-->');
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (xml.startsWith('<![CDATA[', lt)) {
|
|
68
|
+
i = skipUntil(xml, lt, ']]>');
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (xml.startsWith('<?', lt)) {
|
|
72
|
+
i = skipUntil(xml, lt, '?>');
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (xml.startsWith('<!', lt)) {
|
|
76
|
+
i = endOfTag(xml, lt) + 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const gt = endOfTag(xml, lt);
|
|
80
|
+
const body = xml.slice(lt + 1, gt);
|
|
81
|
+
const closing = body.startsWith('/');
|
|
82
|
+
const selfClosing = body.endsWith('/');
|
|
83
|
+
const inner = body.replace(/^\//, '').replace(/\/$/, '');
|
|
84
|
+
const name = inner.split(/[\s/]/, 1)[0] ?? '';
|
|
85
|
+
yield {
|
|
86
|
+
name,
|
|
87
|
+
start: lt,
|
|
88
|
+
end: gt + 1,
|
|
89
|
+
selfClosing,
|
|
90
|
+
closing,
|
|
91
|
+
attributes: closing ? {} : parseAttributes(inner.slice(name.length)),
|
|
92
|
+
};
|
|
93
|
+
i = gt + 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Every element in the document, as a tree of source ranges. The returned array holds
|
|
98
|
+
* the top-level elements — a `.bpmn` has exactly one, `bpmn:definitions`.
|
|
99
|
+
*/
|
|
100
|
+
export function parseXmlRanges(xml) {
|
|
101
|
+
const roots = [];
|
|
102
|
+
const stack = [];
|
|
103
|
+
const finish = (tag, node, end) => {
|
|
104
|
+
const range = {
|
|
105
|
+
name: node.tag.name,
|
|
106
|
+
local: node.tag.name.includes(':') ? node.tag.name.split(':').pop() : node.tag.name,
|
|
107
|
+
...(node.tag.attributes.id !== undefined ? { id: node.tag.attributes.id } : {}),
|
|
108
|
+
start: node.tag.start,
|
|
109
|
+
end,
|
|
110
|
+
innerStart: node.tag.end,
|
|
111
|
+
innerEnd: node.tag.selfClosing ? node.tag.end : tag.start,
|
|
112
|
+
attributes: node.tag.attributes,
|
|
113
|
+
children: node.children,
|
|
114
|
+
};
|
|
115
|
+
const parent = stack[stack.length - 1];
|
|
116
|
+
if (parent)
|
|
117
|
+
parent.children.push(range);
|
|
118
|
+
else
|
|
119
|
+
roots.push(range);
|
|
120
|
+
};
|
|
121
|
+
for (const tag of rawTags(xml)) {
|
|
122
|
+
if (tag.closing) {
|
|
123
|
+
const node = stack.pop();
|
|
124
|
+
if (!node)
|
|
125
|
+
throw new Error(`xml-ranges: stray </${tag.name}> at offset ${tag.start}`);
|
|
126
|
+
finish(tag, node, tag.end);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (tag.selfClosing) {
|
|
130
|
+
const node = { tag, children: [] };
|
|
131
|
+
finish(tag, node, tag.end);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
stack.push({ tag, children: [] });
|
|
135
|
+
}
|
|
136
|
+
if (stack.length > 0) {
|
|
137
|
+
throw new Error(`xml-ranges: unclosed <${stack[stack.length - 1].tag.name}>`);
|
|
138
|
+
}
|
|
139
|
+
return roots;
|
|
140
|
+
}
|
|
141
|
+
/** Depth-first search for the first element with the given local name. */
|
|
142
|
+
export function findByLocal(nodes, local) {
|
|
143
|
+
for (const node of nodes) {
|
|
144
|
+
if (node.local === local)
|
|
145
|
+
return node;
|
|
146
|
+
const nested = findByLocal(node.children, local);
|
|
147
|
+
if (nested)
|
|
148
|
+
return nested;
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case-expr-check — the CASE adapter over the shared `core/expr-check`, run by
|
|
3
|
+
* `CaseBuilder.build()` before it hands back the model to be serialized.
|
|
4
|
+
*
|
|
5
|
+
* A case `=js:` gate reads a declared variable as `=js:vars.<name>` — the `vars.`
|
|
6
|
+
* namespace, NOT `case.` (a `case.` reference resolves to nothing; the platform's
|
|
7
|
+
* `uip maestro case validate` only IGNORES it, which is why it looks accepted).
|
|
8
|
+
* `vars.` is a CLOSED namespace: a reference to a name no variable declares is a
|
|
9
|
+
* definite mistake, and `validate` says so (`vars.<name> does not exist`). So this
|
|
10
|
+
* flags every undeclared `vars.<root>`, exactly as the flow check flags `$vars`,
|
|
11
|
+
* and `build()` is the fast pre-`validate` gate.
|
|
12
|
+
*
|
|
13
|
+
* The surfaces that carry a `=js:` gate: every rule's `expression`, a task's
|
|
14
|
+
* `skipWhen`, and each SLA's `when`. Stage/task STRUCTURAL references
|
|
15
|
+
* (`rule.stage` / `rule.tasks`) are a different thing and are checked by
|
|
16
|
+
* `case/check.ts`, not here.
|
|
17
|
+
*/
|
|
18
|
+
import { type ExprDiagnostic } from '../core/expr-check.js';
|
|
19
|
+
import type { BuiltCase } from './case-sdk.js';
|
|
20
|
+
/** A diagnostic plus the part of the case it was found in. */
|
|
21
|
+
export interface CaseLocatedDiagnostic extends ExprDiagnostic {
|
|
22
|
+
where: string;
|
|
23
|
+
}
|
|
24
|
+
/** Every first-level expression problem in a built case, each stamped with its location. */
|
|
25
|
+
export declare function checkCaseExpressions(built: BuiltCase): CaseLocatedDiagnostic[];
|
|
26
|
+
/**
|
|
27
|
+
* Thrown by `CaseBuilder.build()` when the first-level expression check finds a
|
|
28
|
+
* likely-typo'd case-variable reference. Same shape/rationale as the flow's
|
|
29
|
+
* `FlowBuildError`: `message` lists every problem; `diagnostics` carries them
|
|
30
|
+
* structured.
|
|
31
|
+
*/
|
|
32
|
+
export declare class CaseBuildError extends Error {
|
|
33
|
+
readonly diagnostics: CaseLocatedDiagnostic[];
|
|
34
|
+
constructor(built: BuiltCase, diagnostics: CaseLocatedDiagnostic[]);
|
|
35
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case-expr-check — the CASE adapter over the shared `core/expr-check`, run by
|
|
3
|
+
* `CaseBuilder.build()` before it hands back the model to be serialized.
|
|
4
|
+
*
|
|
5
|
+
* A case `=js:` gate reads a declared variable as `=js:vars.<name>` — the `vars.`
|
|
6
|
+
* namespace, NOT `case.` (a `case.` reference resolves to nothing; the platform's
|
|
7
|
+
* `uip maestro case validate` only IGNORES it, which is why it looks accepted).
|
|
8
|
+
* `vars.` is a CLOSED namespace: a reference to a name no variable declares is a
|
|
9
|
+
* definite mistake, and `validate` says so (`vars.<name> does not exist`). So this
|
|
10
|
+
* flags every undeclared `vars.<root>`, exactly as the flow check flags `$vars`,
|
|
11
|
+
* and `build()` is the fast pre-`validate` gate.
|
|
12
|
+
*
|
|
13
|
+
* The surfaces that carry a `=js:` gate: every rule's `expression`, a task's
|
|
14
|
+
* `skipWhen`, and each SLA's `when`. Stage/task STRUCTURAL references
|
|
15
|
+
* (`rule.stage` / `rule.tasks`) are a different thing and are checked by
|
|
16
|
+
* `case/check.ts`, not here.
|
|
17
|
+
*/
|
|
18
|
+
import { checkExpression } from '../core/expr-check.js';
|
|
19
|
+
const NOUN = 'case variable';
|
|
20
|
+
const NAMESPACE = 'vars';
|
|
21
|
+
function checkExpr(expr, where, roots, out) {
|
|
22
|
+
if (!expr)
|
|
23
|
+
return;
|
|
24
|
+
for (const d of checkExpression(expr, { roots, noun: NOUN, namespace: NAMESPACE })) {
|
|
25
|
+
out.push({ ...d, where });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Every rule's `=js:` gate across an AND/OR rule matrix. */
|
|
29
|
+
function checkRules(rules, where, roots, out) {
|
|
30
|
+
for (const group of rules ?? [])
|
|
31
|
+
for (const r of group)
|
|
32
|
+
checkExpr(r.expression, where, roots, out);
|
|
33
|
+
}
|
|
34
|
+
/** Every first-level expression problem in a built case, each stamped with its location. */
|
|
35
|
+
export function checkCaseExpressions(built) {
|
|
36
|
+
const roots = new Set(built.vars.map((v) => v.name));
|
|
37
|
+
// Task output bindings declare readable case variables too (`=vars.<var>`),
|
|
38
|
+
// via a root `inputOutputs` companion — include them so a gate that reads a
|
|
39
|
+
// task output is not flagged as an undeclared reference.
|
|
40
|
+
for (const stage of built.stages)
|
|
41
|
+
for (const lane of stage.lanes)
|
|
42
|
+
for (const task of lane)
|
|
43
|
+
for (const o of task.outputs ?? [])
|
|
44
|
+
roots.add(o.var);
|
|
45
|
+
// Event-trigger payload extractions declare readable case variables too.
|
|
46
|
+
for (const t of built.triggers)
|
|
47
|
+
for (const o of t.eventOutputs ?? [])
|
|
48
|
+
roots.add(o.var);
|
|
49
|
+
const out = [];
|
|
50
|
+
built.slaRules.forEach((sla, i) => checkExpr(sla.expression, `case SLA #${i + 1}`, roots, out));
|
|
51
|
+
built.caseExit.forEach((ce, i) => checkRules(ce.rules, `case completion #${i + 1}`, roots, out));
|
|
52
|
+
for (const stage of built.stages) {
|
|
53
|
+
const at = `stage "${stage.label}"`;
|
|
54
|
+
for (const ec of stage.entry)
|
|
55
|
+
checkRules(ec.rules, `${at} entry`, roots, out);
|
|
56
|
+
for (const xc of stage.exit)
|
|
57
|
+
checkRules(xc.rules, `${at} exit`, roots, out);
|
|
58
|
+
stage.slaRules.forEach((sla, i) => checkExpr(sla.expression, `${at} SLA #${i + 1}`, roots, out));
|
|
59
|
+
for (const lane of stage.lanes) {
|
|
60
|
+
for (const task of lane) {
|
|
61
|
+
const tat = `task "${task.name}" in ${at}`;
|
|
62
|
+
checkExpr(task.skip, `${tat} skipWhen`, roots, out);
|
|
63
|
+
for (const ec of task.entry)
|
|
64
|
+
checkRules(ec.rules, `${tat} entry`, roots, out);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Thrown by `CaseBuilder.build()` when the first-level expression check finds a
|
|
72
|
+
* likely-typo'd case-variable reference. Same shape/rationale as the flow's
|
|
73
|
+
* `FlowBuildError`: `message` lists every problem; `diagnostics` carries them
|
|
74
|
+
* structured.
|
|
75
|
+
*/
|
|
76
|
+
export class CaseBuildError extends Error {
|
|
77
|
+
diagnostics;
|
|
78
|
+
constructor(built, diagnostics) {
|
|
79
|
+
const label = built.name || built.id || 'case';
|
|
80
|
+
const lines = diagnostics.map((d) => ` ✗ [${d.code}] in ${d.where}: ${d.message}${d.suggestion ? ` (did you mean "${d.suggestion}"?)` : ''}`);
|
|
81
|
+
super(`Cannot build case "${label}" — ${diagnostics.length} expression problem(s):\n${lines.join('\n')}`);
|
|
82
|
+
this.name = 'CaseBuildError';
|
|
83
|
+
this.diagnostics = diagnostics;
|
|
84
|
+
}
|
|
85
|
+
}
|