@uipath/maestro-builder-sdk 6.86.27 → 6.87.1
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/README.md +2 -0
- package/dist/api-index.md +5 -1
- package/dist/api-members.md +4 -0
- package/dist/bpmn/check-cli.js +38 -7
- package/dist/bpmn/decompile-cli.js +4 -3
- package/dist/bpmn/decompile.js +4 -3
- package/dist/bpmn/merge-cli.js +19 -1
- package/dist/bpmn/merge-placement.d.ts +33 -0
- package/dist/bpmn/merge-placement.js +899 -0
- package/dist/bpmn/merge.d.ts +7 -0
- package/dist/bpmn/merge.js +44 -2
- package/dist/bpmn/serialize.js +2 -1
- package/dist/bpmn/source-types.d.ts +17 -0
- package/dist/bpmn/source-types.js +136 -0
- package/dist/bpmn-api.md +1201 -0
- package/dist/check.js +24 -54
- package/dist/cli/commands/bpmn.js +3 -0
- package/dist/core/step-ports.d.ts +37 -0
- package/dist/decompile.js +20 -38
- package/dist/flow-node-type.d.ts +30 -1
- package/dist/flow-step-exits.d.ts +10 -1
- package/dist/flow-step-exits.js +18 -6
- package/dist/nodes/hitl/flow/node-type.js +76 -1
- package/dist/script-function-scope.d.ts +38 -0
- package/dist/script-function-scope.js +1 -1
- package/package.json +2 -2
package/dist/bpmn/merge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BpmnPlacementReport } from './merge-placement.js';
|
|
1
2
|
export interface BpmnMergeOptions {
|
|
2
3
|
/**
|
|
3
4
|
* `compile(decompile(original))` captured BEFORE the author's edits — what a faithful
|
|
@@ -15,5 +16,11 @@ export interface BpmnMergeResult {
|
|
|
15
16
|
authored: string[];
|
|
16
17
|
/** Element ids present in the original but gone from the edited process. */
|
|
17
18
|
removed: string[];
|
|
19
|
+
/**
|
|
20
|
+
* What the merge drew: the edit's new flow nodes and sequence flows get diagram
|
|
21
|
+
* geometry in the original's diagram, and every existing shape keeps its bounds unless
|
|
22
|
+
* a full container had to grow (merge-placement.ts). Empty when the original has no diagram.
|
|
23
|
+
*/
|
|
24
|
+
layout: BpmnPlacementReport;
|
|
18
25
|
}
|
|
19
26
|
export declare function mergeBpmn(originalXml: string, editedXml: string, options?: BpmnMergeOptions): BpmnMergeResult;
|
package/dist/bpmn/merge.js
CHANGED
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
* children of its sub-process. The document root is merged the same way, so a
|
|
29
29
|
* definition the edit needs (a new `bpmn:error`) lands beside the process.
|
|
30
30
|
*
|
|
31
|
+
* The diagram is the original's. What the edit added is drawn into it, and nothing that
|
|
32
|
+
* was there moves (merge-placement.ts), so a brownfield edit needs no `format`.
|
|
33
|
+
*
|
|
31
34
|
* Without a `baseline` the merge is two-way: take the edited process, re-attach the
|
|
32
35
|
* original diagram by element id. Correct whenever decompile was faithful for every
|
|
33
36
|
* element, and still much better than a bare recompile, which drops layout entirely.
|
|
@@ -65,6 +68,7 @@
|
|
|
65
68
|
* edits that row: the merge changes what the edit changed and nothing else.
|
|
66
69
|
*/
|
|
67
70
|
import { ownEntry } from '../core/own-entry.js';
|
|
71
|
+
import { placeAddedElements } from './merge-placement.js';
|
|
68
72
|
import { findByLocal, parseXmlRanges } from './xml-ranges.js';
|
|
69
73
|
const WIRING = new Set(['incoming', 'outgoing']);
|
|
70
74
|
const isWiring = (range) => WIRING.has(range.local);
|
|
@@ -637,7 +641,45 @@ function twoWay(originalXml, editedXml) {
|
|
|
637
641
|
let merged = originalXml.slice(0, originalProcess.innerStart) + body + originalXml.slice(originalProcess.innerEnd);
|
|
638
642
|
if (removed.length > 0)
|
|
639
643
|
merged = withoutDiagramFor(merged, kept, new Set(removed));
|
|
640
|
-
return {
|
|
644
|
+
return { ...withPlacement(originalXml, withDeclarations(merged, editedXml)), preserved: [], authored, removed };
|
|
645
|
+
}
|
|
646
|
+
/** Each sequence flow's `sourceRef -> targetRef`, by id, anywhere in the document's processes. */
|
|
647
|
+
function flowEnds(xml) {
|
|
648
|
+
const ends = new Map();
|
|
649
|
+
for (const root of parseXmlRanges(xml))
|
|
650
|
+
for (const flow of allByLocal(root.children.filter((c) => c.local === 'process'), 'sequenceFlow'))
|
|
651
|
+
if (flow.id !== undefined)
|
|
652
|
+
ends.set(flow.id, `${flow.attributes.sourceRef ?? ''}->${flow.attributes.targetRef ?? ''}`);
|
|
653
|
+
return ends;
|
|
654
|
+
}
|
|
655
|
+
/** Each element's parent (its process or sub-process), by id, for every element under the document's processes. */
|
|
656
|
+
function scopes(xml) {
|
|
657
|
+
const parents = new Map();
|
|
658
|
+
const visit = (scope) => {
|
|
659
|
+
for (const child of scope.children) {
|
|
660
|
+
if (child.id === undefined)
|
|
661
|
+
continue;
|
|
662
|
+
parents.set(child.id, scope.id ?? '');
|
|
663
|
+
visit(child);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
for (const root of parseXmlRanges(xml))
|
|
667
|
+
root.children.filter((c) => c.local === 'process').forEach(visit);
|
|
668
|
+
return parents;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Draw what the edit added into the original's diagram (merge-placement.ts): a shape for
|
|
672
|
+
* each new flow node, an edge for each new sequence flow, and a new route for a kept flow
|
|
673
|
+
* whose ends the edit moved.
|
|
674
|
+
*/
|
|
675
|
+
function withPlacement(originalXml, merged) {
|
|
676
|
+
const originalIds = modelIds(originalXml);
|
|
677
|
+
const before = flowEnds(originalXml);
|
|
678
|
+
const rewired = new Set([...flowEnds(merged)].filter(([id, ends]) => before.has(id) && before.get(id) !== ends).map(([id]) => id));
|
|
679
|
+
const scopeBefore = scopes(originalXml);
|
|
680
|
+
const rescoped = new Set([...scopes(merged)].filter(([id, scope]) => scopeBefore.has(id) && scopeBefore.get(id) !== scope).map(([id]) => id));
|
|
681
|
+
const { xml, report } = placeAddedElements(merged, { isAdded: (id) => !originalIds.has(id), rewired, rescoped });
|
|
682
|
+
return { xml, layout: report };
|
|
641
683
|
}
|
|
642
684
|
export function mergeBpmn(originalXml, editedXml, options = {}) {
|
|
643
685
|
processOf(originalXml, 'original');
|
|
@@ -657,5 +699,5 @@ export function mergeBpmn(originalXml, editedXml, options = {}) {
|
|
|
657
699
|
const removed = [...originalIds].filter((id) => !kept.has(id));
|
|
658
700
|
if (removed.length > 0)
|
|
659
701
|
merged = withoutDiagramFor(merged, kept, originalIds);
|
|
660
|
-
return {
|
|
702
|
+
return { ...withPlacement(originalXml, withDeclarations(merged, editedXml)), preserved: ctx.preserved, authored: ctx.authored, removed };
|
|
661
703
|
}
|
package/dist/bpmn/serialize.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*
|
|
12
12
|
* **Semantic-only, no diagram.** BPMN validation is layout-independent, so no
|
|
13
13
|
* `bpmndi:BPMNDiagram` is emitted here; `uip maestro bpmn format` adds geometry
|
|
14
|
-
*
|
|
14
|
+
* to a greenfield file, and a brownfield merge keeps the original's and draws what
|
|
15
|
+
* the edit added (merge-placement.ts).
|
|
15
16
|
*/
|
|
16
17
|
import BpmnModdle from 'bpmn-moddle';
|
|
17
18
|
import { createRequire } from 'node:module';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Diagnostic } from './check.js';
|
|
2
|
+
/**
|
|
3
|
+
* The libraries the program reads: what Node >= 22.6 implements. ES2024
|
|
4
|
+
* (`toSorted`, `Object.groupBy`) plus the later pieces Node 22 already ships:
|
|
5
|
+
* the Set methods (`union`), the iterator helpers (`Iterator.from`) and
|
|
6
|
+
* `Array.fromAsync`. No DOM: `lib.dom.d.ts` is two thirds of the text a DOM
|
|
7
|
+
* program reads and tripled its cold build. Node's own globals come from
|
|
8
|
+
* RUNTIME_GLOBALS instead.
|
|
9
|
+
*
|
|
10
|
+
* The `esnext.*` files are not a fixed set: a later TypeScript can add an API
|
|
11
|
+
* to one that Node 22 lacks, and `check` would then pass a call that throws.
|
|
12
|
+
* `bpmn-cli.test.ts` pins every declaration they make, so such an addition
|
|
13
|
+
* fails a test instead of reaching an author.
|
|
14
|
+
*/
|
|
15
|
+
export declare const TYPE_CHECK_LIBS: readonly ["lib.es2024.d.ts", "lib.esnext.collection.d.ts", "lib.esnext.iterator.d.ts", "lib.esnext.array.d.ts"];
|
|
16
|
+
/** Every type error in `file` and the author's files it imports, or none. */
|
|
17
|
+
export declare function sourceTypeDiagnostics(file: string): Diagnostic[];
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { dirname, isAbsolute, join, relative } from 'node:path';
|
|
2
|
+
import { typescript } from '../core/typescript-module.js';
|
|
3
|
+
import { sdkResolvingHost } from '../script-function-scope.js';
|
|
4
|
+
/**
|
|
5
|
+
* TypeScript codes that mean "the program could not see something", not "the
|
|
6
|
+
* call is wrong": cannot find module (2307, 2792), the "install type
|
|
7
|
+
* definitions for node" family (2580, 2591, 2592, 2593) for a name the shim
|
|
8
|
+
* leaves out, a DOM-only global (2584), a missing type library (2688). A plain
|
|
9
|
+
* missing name (2304) stays an error: it is usually a typo, or a CommonJS name
|
|
10
|
+
* (`__dirname`) that an ES module does not have when it runs either.
|
|
11
|
+
*/
|
|
12
|
+
const ENVIRONMENT_CODES = new Set([2307, 2580, 2584, 2591, 2592, 2593, 2688, 2792]);
|
|
13
|
+
/**
|
|
14
|
+
* Node's runtime globals, declared loosely, for a program that loads neither
|
|
15
|
+
* `@types/node` nor the DOM lib.
|
|
16
|
+
*
|
|
17
|
+
* The authored source runs on Node, so `setTimeout`, `fetch`, `URL`,
|
|
18
|
+
* `structuredClone`, `process` and `import.meta.url` all exist when it runs; a
|
|
19
|
+
* program without them fails `check` on a source that works. Loading
|
|
20
|
+
* `@types/node` instead would make the result depend on what the author's tree
|
|
21
|
+
* happens to have installed, and would cost more than the rest of the program,
|
|
22
|
+
* so the names are declared here as loosely as still lets them be used as
|
|
23
|
+
* values, types and constructors. Checking the author's NODE calls is not this
|
|
24
|
+
* pass's job; checking the SDK calls is. Served as a virtual `.d.ts`, so
|
|
25
|
+
* `skipLibCheck` covers it and no diagnostic is reported against it.
|
|
26
|
+
*/
|
|
27
|
+
const RUNTIME_GLOBALS = [
|
|
28
|
+
'interface ImportMeta { url: string; dirname: string; filename: string; resolve(specifier: string): string; }',
|
|
29
|
+
'declare var process: any;',
|
|
30
|
+
'declare var Buffer: any;',
|
|
31
|
+
'declare var global: typeof globalThis;',
|
|
32
|
+
'declare var console: any;',
|
|
33
|
+
'declare var crypto: any;',
|
|
34
|
+
'declare var performance: any;',
|
|
35
|
+
'declare function setTimeout(callback: (...args: any[]) => void, ms?: number, ...args: any[]): any;',
|
|
36
|
+
'declare function setInterval(callback: (...args: any[]) => void, ms?: number, ...args: any[]): any;',
|
|
37
|
+
'declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;',
|
|
38
|
+
'declare function clearTimeout(handle?: any): void;',
|
|
39
|
+
'declare function clearInterval(handle?: any): void;',
|
|
40
|
+
'declare function clearImmediate(handle?: any): void;',
|
|
41
|
+
'declare function queueMicrotask(callback: () => void): void;',
|
|
42
|
+
'declare function structuredClone<T>(value: T, options?: any): T;',
|
|
43
|
+
'declare function fetch(input: any, init?: any): Promise<any>;',
|
|
44
|
+
'declare function atob(data: string): string;',
|
|
45
|
+
'declare function btoa(data: string): string;',
|
|
46
|
+
'declare var navigator: any;',
|
|
47
|
+
'declare var WebAssembly: any;',
|
|
48
|
+
...[
|
|
49
|
+
'URL', 'URLSearchParams', 'URLPattern', 'DOMException', 'AbortController', 'AbortSignal',
|
|
50
|
+
'Event', 'EventTarget', 'CustomEvent', 'MessageEvent', 'CloseEvent', 'TextEncoder', 'TextDecoder',
|
|
51
|
+
'TransformStream', 'TransformStreamDefaultController', 'WritableStream', 'WritableStreamDefaultController',
|
|
52
|
+
'WritableStreamDefaultWriter', 'ReadableStream', 'ReadableStreamDefaultReader', 'ReadableStreamBYOBReader',
|
|
53
|
+
'ReadableStreamBYOBRequest', 'ReadableByteStreamController', 'ReadableStreamDefaultController',
|
|
54
|
+
'ByteLengthQueuingStrategy', 'CountQueuingStrategy', 'TextEncoderStream', 'TextDecoderStream',
|
|
55
|
+
'CompressionStream', 'DecompressionStream', 'BroadcastChannel', 'MessageChannel', 'MessagePort', 'Blob', 'File',
|
|
56
|
+
'Performance', 'PerformanceEntry', 'PerformanceMark', 'PerformanceMeasure', 'PerformanceObserver',
|
|
57
|
+
'PerformanceObserverEntryList', 'PerformanceResourceTiming', 'FormData', 'Headers', 'Request', 'Response',
|
|
58
|
+
'WebSocket', 'Crypto', 'CryptoKey', 'SubtleCrypto', 'Navigator', 'SuppressedError', 'DisposableStack',
|
|
59
|
+
'AsyncDisposableStack', 'Float16Array',
|
|
60
|
+
].map((name) => `declare class ${name} { constructor(...args: any[]); [key: string]: any; static [key: string]: any; }`),
|
|
61
|
+
].join('\n');
|
|
62
|
+
/**
|
|
63
|
+
* The libraries the program reads: what Node >= 22.6 implements. ES2024
|
|
64
|
+
* (`toSorted`, `Object.groupBy`) plus the later pieces Node 22 already ships:
|
|
65
|
+
* the Set methods (`union`), the iterator helpers (`Iterator.from`) and
|
|
66
|
+
* `Array.fromAsync`. No DOM: `lib.dom.d.ts` is two thirds of the text a DOM
|
|
67
|
+
* program reads and tripled its cold build. Node's own globals come from
|
|
68
|
+
* RUNTIME_GLOBALS instead.
|
|
69
|
+
*
|
|
70
|
+
* The `esnext.*` files are not a fixed set: a later TypeScript can add an API
|
|
71
|
+
* to one that Node 22 lacks, and `check` would then pass a call that throws.
|
|
72
|
+
* `bpmn-cli.test.ts` pins every declaration they make, so such an addition
|
|
73
|
+
* fails a test instead of reaching an author.
|
|
74
|
+
*/
|
|
75
|
+
export const TYPE_CHECK_LIBS = [
|
|
76
|
+
'lib.es2024.d.ts', 'lib.esnext.collection.d.ts', 'lib.esnext.iterator.d.ts', 'lib.esnext.array.d.ts',
|
|
77
|
+
];
|
|
78
|
+
/** The virtual file the runtime globals are served as, beside the source. */
|
|
79
|
+
const RUNTIME_GLOBALS_FILE = '__maestro-bpmn-runtime-globals__.d.ts';
|
|
80
|
+
/** Every type error in `file` and the author's files it imports, or none. */
|
|
81
|
+
export function sourceTypeDiagnostics(file) {
|
|
82
|
+
const ts = typescript();
|
|
83
|
+
const options = {
|
|
84
|
+
noEmit: true, skipLibCheck: true, allowImportingTsExtensions: true, allowJs: false,
|
|
85
|
+
// Every file is a module, as the loader runs it: Node detects a `.ts` file's
|
|
86
|
+
// ESM syntax with no `"type": "module"` (so top-level `await` works), where
|
|
87
|
+
// NodeNext would type it as CommonJS and refuse the `await` (TS1309).
|
|
88
|
+
// Bundler resolution still honours the SDK's `exports` and their `types`.
|
|
89
|
+
target: ts.ScriptTarget.ES2023, module: ts.ModuleKind.ESNext, moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
90
|
+
moduleDetection: ts.ModuleDetectionKind.Force,
|
|
91
|
+
lib: [...TYPE_CHECK_LIBS],
|
|
92
|
+
// No automatic `@types` walk up the tree, so the result does not depend on
|
|
93
|
+
// what the author's folder happens to have installed.
|
|
94
|
+
types: [],
|
|
95
|
+
};
|
|
96
|
+
const shim = join(dirname(file), RUNTIME_GLOBALS_FILE);
|
|
97
|
+
const host = sdkResolvingHost(ts, options);
|
|
98
|
+
const getSourceFile = host.getSourceFile.bind(host);
|
|
99
|
+
host.getSourceFile = (name, language, ...rest) => (name === shim
|
|
100
|
+
? ts.createSourceFile(name, RUNTIME_GLOBALS, language)
|
|
101
|
+
: getSourceFile(name, language, ...rest));
|
|
102
|
+
const fileExists = host.fileExists.bind(host);
|
|
103
|
+
host.fileExists = (name) => name === shim || fileExists(name);
|
|
104
|
+
const program = ts.createProgram([file, shim], options, host);
|
|
105
|
+
const cwd = process.cwd();
|
|
106
|
+
const out = [];
|
|
107
|
+
for (const sf of program.getSourceFiles()) {
|
|
108
|
+
if (sf.isDeclarationFile || sf.fileName.includes('/node_modules/'))
|
|
109
|
+
continue;
|
|
110
|
+
const found = [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)];
|
|
111
|
+
for (const d of found)
|
|
112
|
+
out.push(toDiagnostic(ts, d, cwd));
|
|
113
|
+
}
|
|
114
|
+
// Program-wide ones (a bad option, a missing lib) carry no file; report them too.
|
|
115
|
+
for (const d of program.getGlobalDiagnostics())
|
|
116
|
+
out.push(toDiagnostic(ts, d, cwd));
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
function toDiagnostic(ts, d, cwd) {
|
|
120
|
+
const text = ts.flattenDiagnosticMessageText(d.messageText, '\n ');
|
|
121
|
+
let where;
|
|
122
|
+
if (d.file && d.start !== undefined) {
|
|
123
|
+
const { line, character } = d.file.getLineAndCharacterOfPosition(d.start);
|
|
124
|
+
// Relative when the file is under the working directory, as an author types it; absolute otherwise.
|
|
125
|
+
const rel = relative(cwd, d.file.fileName);
|
|
126
|
+
const shown = rel && !rel.startsWith('..') && !isAbsolute(rel) ? rel : d.file.fileName;
|
|
127
|
+
where = `${shown}:${line + 1}:${character + 1}`;
|
|
128
|
+
}
|
|
129
|
+
const environment = ENVIRONMENT_CODES.has(d.code);
|
|
130
|
+
return {
|
|
131
|
+
level: environment || d.category !== ts.DiagnosticCategory.Error ? 'warning' : 'error',
|
|
132
|
+
code: `TS${d.code}`,
|
|
133
|
+
message: where ? `${where} ${text}` : text,
|
|
134
|
+
...(where ? { where } : {}),
|
|
135
|
+
};
|
|
136
|
+
}
|