@uipath/maestro-builder-sdk 6.97.2 → 6.98.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 +9 -9
- package/dist/api-members.md +37 -37
- package/dist/bpmn/check-baseline.d.ts +76 -0
- package/dist/bpmn/check-baseline.js +201 -0
- package/dist/bpmn/check-cli.js +78 -9
- package/dist/bpmn/check.d.ts +29 -0
- package/dist/bpmn/check.js +11 -4
- package/dist/bpmn/lift-verify.d.ts +6 -0
- package/dist/bpmn/lift-verify.js +1 -1
- package/dist/bpmn/merge-cli.js +1 -15
- package/dist/bpmn/merge-source.d.ts +17 -0
- package/dist/bpmn/merge-source.js +29 -3
- package/dist/check-cli.js +2 -16
- package/dist/check.js +8 -46
- package/dist/cli/commands/bpmn.js +2 -0
- package/dist/core/baseline-scope.d.ts +98 -0
- package/dist/core/baseline-scope.js +132 -0
- package/dist/core/process-resource.d.ts +2 -1
- package/dist/core/process-resource.js +8 -2
- package/dist/edit-scope.d.ts +4 -22
- package/dist/edit-scope.js +4 -35
- package/dist/nodes/process/flow/check.js +27 -12
- package/dist/nodes/process/flow/spec.d.ts +19 -11
- package/package.json +4 -3
package/dist/bpmn/check-cli.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Usage:
|
|
6
6
|
* node --experimental-strip-types check-cli.js <bpmn.ts | BaseName> [--graph] [--no-types] \
|
|
7
7
|
* [--library <library-json dir>] [--connectors-local <overlay dir>] [--bindings <bindings.json>] \
|
|
8
|
-
* [--resources <resources.json>]
|
|
8
|
+
* [--resources <resources.json>] [--baseline <original.bpmn>]
|
|
9
9
|
*
|
|
10
10
|
* --resources defaults to .flow-sdk/resources.json, the ledger `registry prepare`
|
|
11
11
|
* writes, when present.
|
|
@@ -18,22 +18,30 @@
|
|
|
18
18
|
* value of the wrong type is a `TS<code>` error with its `file:line:col`, and it
|
|
19
19
|
* is reported even when the source then crashes on load or in the check.
|
|
20
20
|
* `--no-types` skips it.
|
|
21
|
+
*
|
|
22
|
+
* `--baseline <original.bpmn>` scopes the findings to the edit (check-baseline.ts): the
|
|
23
|
+
* original is decompiled, built and checked in memory the same way, and each finding is
|
|
24
|
+
* marked `(edited)` or `(pre-existing)`. A pre-existing finding (its element unchanged,
|
|
25
|
+
* and the original reports it too) is a warning, so only the edit's errors fail the
|
|
26
|
+
* check; a pre-existing lowering one is printed as a probable SDK defect.
|
|
21
27
|
*/
|
|
22
|
-
import { existsSync } from 'node:fs';
|
|
23
|
-
import { printResult, reportCompileRefusal, reportDiagnostics, reportResult } from '../cli-result.js';
|
|
28
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
29
|
+
import { diagnosticLine, printResult, reportCompileRefusal, reportDiagnostics, reportResult } from '../cli-result.js';
|
|
24
30
|
import { resolveBpmnFile, loadBuiltBpmn } from './load.js';
|
|
25
|
-
import { check } from './check.js';
|
|
31
|
+
import { check, checkModel } from './check.js';
|
|
32
|
+
import { bpmnBaselineSummary, bpmnDocumentProblem, buildOriginal, scopeToEdit } from './check-baseline.js';
|
|
26
33
|
import { sourceTypeDiagnostics } from './source-types.js';
|
|
27
34
|
import { graphModel, renderGraph } from './graph.js';
|
|
28
35
|
import { Bindings } from '../core/bindings.js';
|
|
29
|
-
import { connectorCheckOpts } from '../core/cli-library.js';
|
|
36
|
+
import { connectorCheckOpts, openCliLibrary } from '../core/cli-library.js';
|
|
37
|
+
import { fetchDefinitionsEnabled } from '../registry/fetch/fetch-definitions.js';
|
|
30
38
|
import { withFetchedDefinitions } from '../registry/fetch/with-fetched-definitions.js';
|
|
31
39
|
import { flagValue, runWhenInvokedDirectly } from '../cli-run.js';
|
|
32
40
|
import { ensureTypeScriptRuntime } from '../node-runtime.js';
|
|
33
41
|
import { readCliResources } from '../registry/prepare/resources.js';
|
|
34
42
|
import { defaultResourcesFile } from '../workdir.js';
|
|
35
43
|
/** Flags that take a value — their argument is never the source positional. */
|
|
36
|
-
const VALUE_FLAGS = new Set(['--library', '--connectors-local', '--bindings', '--resources']);
|
|
44
|
+
const VALUE_FLAGS = new Set(['--library', '--connectors-local', '--bindings', '--resources', '--baseline']);
|
|
37
45
|
/**
|
|
38
46
|
* The connector facts, resolved exactly as `compile-cli` resolves them, so the
|
|
39
47
|
* inner loop and the emit rung cannot disagree about a field, a lookup or a
|
|
@@ -57,17 +65,45 @@ function report(diags) {
|
|
|
57
65
|
}
|
|
58
66
|
export async function run(argv) {
|
|
59
67
|
if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
|
|
60
|
-
console.error('usage: check <bpmn.ts | BaseName> [--graph] [--no-types] [--library <dir>] [--connectors-local <dir>] [--bindings <file>] [--resources <file>]');
|
|
68
|
+
console.error('usage: check <bpmn.ts | BaseName> [--graph] [--no-types] [--library <dir>] [--connectors-local <dir>] [--bindings <file>] [--resources <file>] [--baseline <original.bpmn>]');
|
|
61
69
|
return 2;
|
|
62
70
|
}
|
|
63
71
|
ensureTypeScriptRuntime();
|
|
64
72
|
const graph = argv.includes('--graph');
|
|
65
73
|
const input = argv.find((a, i) => !a.startsWith('--') && !VALUE_FLAGS.has(argv[i - 1]));
|
|
66
74
|
if (input === undefined) {
|
|
67
|
-
console.error('usage: check <bpmn.ts | BaseName> [--graph] [--no-types] [--library <dir>] [--connectors-local <dir>] [--bindings <file>] [--resources <file>]');
|
|
75
|
+
console.error('usage: check <bpmn.ts | BaseName> [--graph] [--no-types] [--library <dir>] [--connectors-local <dir>] [--bindings <file>] [--resources <file>] [--baseline <original.bpmn>]');
|
|
76
|
+
return 2;
|
|
77
|
+
}
|
|
78
|
+
const baselinePath = flagValue(argv, '--baseline');
|
|
79
|
+
const original = baselinePath !== undefined ? readBaseline(baselinePath) : undefined;
|
|
80
|
+
if (original instanceof Error) {
|
|
81
|
+
console.error(`check: ${original.message}`);
|
|
82
|
+
reportResult({ error: original.message });
|
|
68
83
|
return 2;
|
|
69
84
|
}
|
|
70
85
|
const file = resolveBpmnFile(input);
|
|
86
|
+
// The original is decompiled first, on its own: when it does not decompile, that is
|
|
87
|
+
// a usage error about --baseline (exit 2), never a fault in the source being checked.
|
|
88
|
+
// It lifts connector tasks against the library `bpmn decompile` opens, and is checked
|
|
89
|
+
// below with the library the edit is checked with, so the two checks agree.
|
|
90
|
+
let baselineBuilt;
|
|
91
|
+
if (original !== undefined) {
|
|
92
|
+
try {
|
|
93
|
+
const library = openCliLibrary(argv, { always: fetchDefinitionsEnabled() });
|
|
94
|
+
baselineBuilt = await buildOriginal(original, {
|
|
95
|
+
...(library ? { library } : {}),
|
|
96
|
+
source: readFileSync(file, 'utf8'),
|
|
97
|
+
onWarning: (m) => console.error(`check: warning: ${m}`),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
const message = `--baseline ${baselinePath} does not decompile: ${error instanceof Error ? error.message : String(error)}`;
|
|
102
|
+
console.error(`check: ${message}`);
|
|
103
|
+
reportResult({ error: message });
|
|
104
|
+
return 2;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
71
107
|
const typeDiags = argv.includes('--no-types') ? [] : sourceTypeDiagnostics(file);
|
|
72
108
|
let built;
|
|
73
109
|
let diags;
|
|
@@ -76,7 +112,16 @@ export async function run(argv) {
|
|
|
76
112
|
// A connector operation no layer carries is fetched through `uip` and the check
|
|
77
113
|
// runs again, as `compile` does (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md).
|
|
78
114
|
const loaded = built;
|
|
79
|
-
diags = [
|
|
115
|
+
diags = [
|
|
116
|
+
// A type error is the edit's: the source is.
|
|
117
|
+
...(original !== undefined ? typeDiags.map((d) => ({ ...d, origin: 'edited' })) : typeDiags),
|
|
118
|
+
...(await withFetchedDefinitions(argv, (library) => {
|
|
119
|
+
const opts = bpmnCheckOpts(argv, library);
|
|
120
|
+
return baselineBuilt !== undefined
|
|
121
|
+
? scopeToEdit({ built: loaded, checked: checkModel(loaded, opts) }, { built: baselineBuilt, checked: checkModel(baselineBuilt, opts) })
|
|
122
|
+
: check(loaded, opts);
|
|
123
|
+
}, { who: 'check' })),
|
|
124
|
+
];
|
|
80
125
|
}
|
|
81
126
|
catch (error) {
|
|
82
127
|
// A value of the wrong type usually crashes the build or the check before
|
|
@@ -104,6 +149,16 @@ export async function run(argv) {
|
|
|
104
149
|
printResult(renderGraph(built).trimEnd());
|
|
105
150
|
reportResult({ graph: graphModel(built) });
|
|
106
151
|
}
|
|
152
|
+
if (original !== undefined) {
|
|
153
|
+
// Each finding says whether the edit caused it (`(edited)`, `(pre-existing)`), as
|
|
154
|
+
// `flow check --baseline` prints it. A BPMN message already carries its
|
|
155
|
+
// suggestion, so it is not appended twice.
|
|
156
|
+
for (const d of diags)
|
|
157
|
+
console.error(` ${diagnosticLine({ ...d, suggestion: undefined })}`);
|
|
158
|
+
const errors = diags.filter((d) => d.level === 'error').length;
|
|
159
|
+
console.error(`check: ${bpmnBaselineSummary(diags)}.`);
|
|
160
|
+
return errors ? 1 : 0;
|
|
161
|
+
}
|
|
107
162
|
printDiagnostics(diags);
|
|
108
163
|
const errors = diags.filter((d) => d.level === 'error').length;
|
|
109
164
|
if (errors) {
|
|
@@ -113,4 +168,18 @@ export async function run(argv) {
|
|
|
113
168
|
console.error(`check: ok${diags.length ? ` (${diags.length} warning(s))` : ''}.`);
|
|
114
169
|
return 0;
|
|
115
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* The `--baseline` file's text, or the usage error to refuse it with: a path that does
|
|
173
|
+
* not exist, or a file that is not a `.bpmn` (no `bpmn:process`), such as the `.bpmn.ts`
|
|
174
|
+
* source passed by mistake. Refused before anything is loaded, with the usage exit
|
|
175
|
+
* code, so a bad flag never reads as a failed check.
|
|
176
|
+
*/
|
|
177
|
+
function readBaseline(path) {
|
|
178
|
+
const usage = `--baseline must be the original .bpmn the source was decompiled from: ${path}`;
|
|
179
|
+
if (!existsSync(path))
|
|
180
|
+
return new Error(`${usage} (no such file)`);
|
|
181
|
+
const xml = readFileSync(path, 'utf8');
|
|
182
|
+
const problem = bpmnDocumentProblem(xml);
|
|
183
|
+
return problem === undefined ? xml : new Error(`${usage} (${problem})`);
|
|
184
|
+
}
|
|
116
185
|
runWhenInvokedDirectly(import.meta.url, 'check', run);
|
package/dist/bpmn/check.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BuiltBpmn } from './bpmn-sdk.js';
|
|
2
2
|
import type { Library } from '../core/library.js';
|
|
3
3
|
import type { ResourceResolutions } from '../core/resource-resolution.js';
|
|
4
|
+
import type { RefusalClass } from '../core/refusals.js';
|
|
4
5
|
import { type ConnectorCheckOpts } from '../core/connector-checks.js';
|
|
5
6
|
import { type EventCheckOpts } from '../core/event-checks.js';
|
|
6
7
|
export interface Diagnostic {
|
|
@@ -11,6 +12,18 @@ export interface Diagnostic {
|
|
|
11
12
|
suggestion?: string;
|
|
12
13
|
/** The id of the element `where` names, for a refusal the serializer placed on one (`serializerRefusals`). */
|
|
13
14
|
nodeId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Only when the check ran against a baseline (`bpmn check --baseline`, check-baseline.ts):
|
|
17
|
+
* the code's class (`core/refusals.ts`: `lint`, `lowering`, `draft`).
|
|
18
|
+
*/
|
|
19
|
+
class?: RefusalClass;
|
|
20
|
+
/**
|
|
21
|
+
* Only when the check ran against a baseline (`bpmn check --baseline`, check-baseline.ts):
|
|
22
|
+
* `pre-existing` when the finding's element is unchanged from the original and the
|
|
23
|
+
* original reports the same code on it, so the edit did not cause it (such a finding
|
|
24
|
+
* is a warning); `edited` for every other finding.
|
|
25
|
+
*/
|
|
26
|
+
origin?: 'edited' | 'pre-existing';
|
|
14
27
|
}
|
|
15
28
|
/**
|
|
16
29
|
* The facts this check cannot derive from the built model.
|
|
@@ -38,3 +51,19 @@ export interface BpmnCheckOpts extends ConnectorCheckOpts, EventCheckOpts {
|
|
|
38
51
|
* builds the model and stops before the XML is written.
|
|
39
52
|
*/
|
|
40
53
|
export declare function check(built: BuiltBpmn, opts?: BpmnCheckOpts): Diagnostic[];
|
|
54
|
+
/** What {@link checkModel} found, and whether the serializer pass judged the whole process. */
|
|
55
|
+
export interface CheckedBpmn {
|
|
56
|
+
diagnostics: Diagnostic[];
|
|
57
|
+
/**
|
|
58
|
+
* Set when the serializer pass stopped before it built the whole model: the
|
|
59
|
+
* scope-level refusal that stopped it (a repeated id), or the throw `check`
|
|
60
|
+
* swallowed because it had errors of its own to report. Nothing the serializer
|
|
61
|
+
* refuses past that point is reported. Absent when the pass ran to the end.
|
|
62
|
+
*/
|
|
63
|
+
stoppedAt?: {
|
|
64
|
+
code?: string;
|
|
65
|
+
message: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** {@link check}, saying whether the serializer pass stopped early, for `check --baseline` (check-baseline.ts). */
|
|
69
|
+
export declare function checkModel(built: BuiltBpmn, opts?: BpmnCheckOpts): CheckedBpmn;
|
package/dist/bpmn/check.js
CHANGED
|
@@ -116,6 +116,10 @@ function isActivityNode(n) {
|
|
|
116
116
|
* builds the model and stops before the XML is written.
|
|
117
117
|
*/
|
|
118
118
|
export function check(built, opts = {}) {
|
|
119
|
+
return checkModel(built, opts).diagnostics;
|
|
120
|
+
}
|
|
121
|
+
/** {@link check}, saying whether the serializer pass stopped early, for `check --baseline` (check-baseline.ts). */
|
|
122
|
+
export function checkModel(built, opts = {}) {
|
|
119
123
|
const diags = [];
|
|
120
124
|
// Duplicate and missing ids (`documentIdProblems`) are the serializer's.
|
|
121
125
|
checkScope(built.nodes, built.flows, 'process', diags, true);
|
|
@@ -131,11 +135,11 @@ export function check(built, opts = {}) {
|
|
|
131
135
|
checkConnectorEvents(built, opts, diags);
|
|
132
136
|
checkCarriedPayloadTags(built, diags);
|
|
133
137
|
// A `.dataService()` entity's recorded row is the serializer's (`lowerDataServiceEntity`).
|
|
134
|
-
const { refusals, definitions, stoodIn } = serializerRefusals(built, opts, diags);
|
|
138
|
+
const { refusals, definitions, stoodIn, stoppedAt } = serializerRefusals(built, opts, diags);
|
|
135
139
|
diags.push(...refusals);
|
|
136
140
|
if (definitions)
|
|
137
141
|
diags.push(...refreshConnections(built, definitions, stoodIn, diags));
|
|
138
|
-
return diags;
|
|
142
|
+
return { diagnostics: diags, ...(stoppedAt ? { stoppedAt } : {}) };
|
|
139
143
|
}
|
|
140
144
|
/**
|
|
141
145
|
* What `uip maestro bpmn refresh` refuses about the emitted connections
|
|
@@ -234,7 +238,7 @@ function serializerRefusals(built, opts, found) {
|
|
|
234
238
|
catch (error) {
|
|
235
239
|
if (!found.some((d) => d.level === 'error'))
|
|
236
240
|
throw error;
|
|
237
|
-
return { refusals: [], stoodIn: new Set() };
|
|
241
|
+
return { refusals: [], stoodIn: new Set(), stoppedAt: { message: error instanceof Error ? error.message : String(error) } };
|
|
238
242
|
}
|
|
239
243
|
const stoodIn = new Set(collected.flatMap((r) => (r.nodeId !== undefined ? [r.nodeId] : [])));
|
|
240
244
|
const out = [];
|
|
@@ -258,7 +262,10 @@ function serializerRefusals(built, opts, found) {
|
|
|
258
262
|
...(r.nodeId !== undefined ? { nodeId: r.nodeId } : {}),
|
|
259
263
|
});
|
|
260
264
|
}
|
|
261
|
-
|
|
265
|
+
// No model means collection stopped: the refusal that stopped it is the last one reported.
|
|
266
|
+
const stop = collected[collected.length - 1];
|
|
267
|
+
const stoppedAt = !definitions ? { ...(stop ? { code: stop.code } : {}), message: stop?.message ?? 'the serializer stopped' } : undefined;
|
|
268
|
+
return { refusals: out, stoodIn, ...(definitions ? { definitions } : {}), ...(stoppedAt ? { stoppedAt } : {}) };
|
|
262
269
|
}
|
|
263
270
|
/**
|
|
264
271
|
* The library-backed connector rules, shared with Flow (`core/connector-checks.ts`).
|
|
@@ -6,6 +6,12 @@ export interface GraphComparison {
|
|
|
6
6
|
/** When they do not: which source failed to build, or what differed. */
|
|
7
7
|
reason?: string;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* JSON with every object's keys sorted, so two builds that set the same fields in a
|
|
11
|
+
* different order — a start event's `payload` before or after its `event` — read as
|
|
12
|
+
* the same. `Map` values are not expected here; `canonicalGraph` flattens the one it has.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stableJson(value: unknown): string;
|
|
9
15
|
/**
|
|
10
16
|
* The part of a built process that is the process: ordered by id, `implied`
|
|
11
17
|
* provenance dropped, and `undefined` fields gone the way JSON drops them.
|
package/dist/bpmn/lift-verify.js
CHANGED
|
@@ -21,7 +21,7 @@ function sortById(xs) {
|
|
|
21
21
|
* different order — a start event's `payload` before or after its `event` — read as
|
|
22
22
|
* the same. `Map` values are not expected here; `canonicalGraph` flattens the one it has.
|
|
23
23
|
*/
|
|
24
|
-
function stableJson(value) {
|
|
24
|
+
export function stableJson(value) {
|
|
25
25
|
return JSON.stringify(value, (_key, v) => v && typeof v === 'object' && !Array.isArray(v)
|
|
26
26
|
? Object.fromEntries(Object.keys(v).sort().map((k) => [k, v[k]]))
|
|
27
27
|
: v);
|
package/dist/bpmn/merge-cli.js
CHANGED
|
@@ -41,9 +41,8 @@
|
|
|
41
41
|
import { reportCompileRefusal, reportDiagnostics, reportResult } from '../cli-result.js';
|
|
42
42
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
43
43
|
import { basename, resolve } from 'node:path';
|
|
44
|
-
import { fileURLToPath } from 'node:url';
|
|
45
44
|
import { mergeBpmn } from './merge.js';
|
|
46
|
-
import { decompiledDigest, deriveBaseline } from './merge-source.js';
|
|
45
|
+
import { decompiledDigest, deriveBaseline, stampedDecompile } from './merge-source.js';
|
|
47
46
|
import { readStamp, sourceDigest, restampSource, STAMP_MARKER } from './decompile-stamp.js';
|
|
48
47
|
import { loadBuiltBpmn } from './load.js';
|
|
49
48
|
import { serialize } from './serialize.js';
|
|
@@ -69,19 +68,6 @@ const VALUE_FLAGS = new Set([
|
|
|
69
68
|
'-o', '--baseline', '--style', '--connectors', '--library', '--connectors-local', '--bindings', '--resources',
|
|
70
69
|
]);
|
|
71
70
|
const BARE_FLAGS = new Set(['--keep-flow-ids', '--keep-unused-bindings']);
|
|
72
|
-
/** The decompile options a stamp records, as `deriveBaseline` and `decompiledDigest` take them. */
|
|
73
|
-
function stampedDecompile(stamp, library) {
|
|
74
|
-
return {
|
|
75
|
-
sdkEntry: fileURLToPath(new URL('./bpmn-sdk.js', import.meta.url)),
|
|
76
|
-
style: stamp.style,
|
|
77
|
-
keepFlowIds: stamp.keepFlowIds,
|
|
78
|
-
keepUnusedBindings: stamp.keepUnusedBindings,
|
|
79
|
-
...(stamp.connectors === 'lift' && library ? { liftLibrary: library } : {}),
|
|
80
|
-
// The tasks that decompile could not name stay verbatim, whatever has been
|
|
81
|
-
// fetched for them since, so the stamped source comes back.
|
|
82
|
-
...(stamp.verbatim.length > 0 ? { keepVerbatim: new Set(stamp.verbatim) } : {}),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
71
|
/** Refuse the merge with a coded diagnostic; nothing has been written. */
|
|
86
72
|
function refuseMerge(code, message) {
|
|
87
73
|
console.error(`bpmn-merge: ${message}`);
|
|
@@ -38,8 +38,10 @@
|
|
|
38
38
|
* Nothing here prints or reads argv; merge-cli.ts does.
|
|
39
39
|
*/
|
|
40
40
|
import type { Library } from '../core/library.js';
|
|
41
|
+
import type { BuiltBpmn } from './bpmn-sdk.js';
|
|
41
42
|
import { type BpmnSerializeOpts } from './serialize.js';
|
|
42
43
|
import { type DecompilePipelineResult } from './decompile-pipeline.js';
|
|
44
|
+
import { type DecompileStamp } from './decompile-stamp.js';
|
|
43
45
|
/** What both in-memory compiles need, and how to decompile the original. */
|
|
44
46
|
export interface SourceMergeOptions {
|
|
45
47
|
/** The library, bindings and resources `compile` would use; the edited and baseline compiles share them. */
|
|
@@ -61,6 +63,8 @@ export interface SourceMergeOptions {
|
|
|
61
63
|
/** The tasks the decompile kept verbatim because its library could not name them (its stamp's `verbatim=`). */
|
|
62
64
|
keepVerbatim?: ReadonlySet<string>;
|
|
63
65
|
}
|
|
66
|
+
/** The decompile options a stamp records, as `deriveBaseline` and `decompiledDigest` take them. */
|
|
67
|
+
export declare function stampedDecompile(stamp: DecompileStamp, library: Library | undefined): Omit<SourceMergeOptions, 'serialize'>;
|
|
64
68
|
/** The baseline merge derived from the original. */
|
|
65
69
|
export interface DerivedBaseline {
|
|
66
70
|
/** `compile(decompile(original))`, the document a `--baseline` file would hold. */
|
|
@@ -77,6 +81,19 @@ export interface DerivedBaseline {
|
|
|
77
81
|
* @returns The baseline document and what the decompile did.
|
|
78
82
|
*/
|
|
79
83
|
export declare function deriveBaseline(original: string, opts: SourceMergeOptions): Promise<DerivedBaseline>;
|
|
84
|
+
/**
|
|
85
|
+
* `decompile(original)`, built in memory: the process the author's source was before
|
|
86
|
+
* the edit. `bpmn check --baseline` checks it to learn what the original already
|
|
87
|
+
* reports (check-baseline.ts); `deriveBaseline` compiles it.
|
|
88
|
+
*
|
|
89
|
+
* @param original - The original `.bpmn` text.
|
|
90
|
+
* @param opts - The decompile options.
|
|
91
|
+
* @returns The built process and what the decompile did.
|
|
92
|
+
*/
|
|
93
|
+
export declare function buildDecompiled(original: string, opts: Omit<SourceMergeOptions, 'serialize'>): Promise<{
|
|
94
|
+
built: BuiltBpmn;
|
|
95
|
+
decompile: DecompilePipelineResult;
|
|
96
|
+
}>;
|
|
80
97
|
/**
|
|
81
98
|
* The stamp digest of `xml` decompiled with `opts`'s options: what `bpmn decompile`
|
|
82
99
|
* would record for it. Merge restamps the source with this after writing over the
|
|
@@ -2,6 +2,20 @@ import { serialize } from './serialize.js';
|
|
|
2
2
|
import { buildSource } from './lift-verify.js';
|
|
3
3
|
import { decompilePipeline } from './decompile-pipeline.js';
|
|
4
4
|
import { sourceDigest } from './decompile-stamp.js';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
/** The decompile options a stamp records, as `deriveBaseline` and `decompiledDigest` take them. */
|
|
7
|
+
export function stampedDecompile(stamp, library) {
|
|
8
|
+
return {
|
|
9
|
+
sdkEntry: fileURLToPath(new URL('./bpmn-sdk.js', import.meta.url)),
|
|
10
|
+
style: stamp.style,
|
|
11
|
+
keepFlowIds: stamp.keepFlowIds,
|
|
12
|
+
keepUnusedBindings: stamp.keepUnusedBindings,
|
|
13
|
+
...(stamp.connectors === 'lift' && library ? { liftLibrary: library } : {}),
|
|
14
|
+
// The tasks that decompile could not name stay verbatim, whatever has been
|
|
15
|
+
// fetched for them since, so the stamped source comes back.
|
|
16
|
+
...(stamp.verbatim.length > 0 ? { keepVerbatim: new Set(stamp.verbatim) } : {}),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
5
19
|
/**
|
|
6
20
|
* `compile(decompile(original))`, made in memory: the baseline the file-based pipeline
|
|
7
21
|
* writes to `X.baseline.bpmn` before the edit.
|
|
@@ -11,9 +25,21 @@ import { sourceDigest } from './decompile-stamp.js';
|
|
|
11
25
|
* @returns The baseline document and what the decompile did.
|
|
12
26
|
*/
|
|
13
27
|
export async function deriveBaseline(original, opts) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
const { built, decompile } = await buildDecompiled(original, opts);
|
|
29
|
+
return { xml: await serialize(built, opts.serialize), decompile };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `decompile(original)`, built in memory: the process the author's source was before
|
|
33
|
+
* the edit. `bpmn check --baseline` checks it to learn what the original already
|
|
34
|
+
* reports (check-baseline.ts); `deriveBaseline` compiles it.
|
|
35
|
+
*
|
|
36
|
+
* @param original - The original `.bpmn` text.
|
|
37
|
+
* @param opts - The decompile options.
|
|
38
|
+
* @returns The built process and what the decompile did.
|
|
39
|
+
*/
|
|
40
|
+
export async function buildDecompiled(original, opts) {
|
|
41
|
+
const decompile = await decompileAs(original, opts);
|
|
42
|
+
return { built: await buildSource(decompile.source, opts.sdkEntry), decompile };
|
|
17
43
|
}
|
|
18
44
|
/**
|
|
19
45
|
* The stamp digest of `xml` decompiled with `opts`'s options: what `bpmn decompile`
|
package/dist/check-cli.js
CHANGED
|
@@ -26,6 +26,7 @@ import { Bindings } from './bindings.js';
|
|
|
26
26
|
import { flagValue, flagValues, runWhenInvokedDirectly } from './cli-run.js';
|
|
27
27
|
import { ensureTypeScriptRuntime } from './node-runtime.js';
|
|
28
28
|
import { withDecompiledOriginal } from './merge-compile.js';
|
|
29
|
+
import { baselineSummary } from './core/baseline-scope.js';
|
|
29
30
|
import { loadNodePackages } from './node-packages.js';
|
|
30
31
|
/** Flags that take a value, so the value is never read as the source argument. */
|
|
31
32
|
const VALUE_FLAGS = new Set(['--library', '--bindings', '--connectors-local', '--resources', '--baseline', '--package']);
|
|
@@ -85,7 +86,7 @@ export async function run(argv) {
|
|
|
85
86
|
for (const d of diags)
|
|
86
87
|
console.log(diagnosticLine(d));
|
|
87
88
|
const errors = diags.filter((d) => d.level === 'error').length;
|
|
88
|
-
console.log(`\n${baselinePath !== undefined ? baselineSummary(diags) : `${errors} error(s), ${diags.length - errors} warning(s)`}`);
|
|
89
|
+
console.log(`\n${baselinePath !== undefined ? baselineSummary(diags, 'nodes') : `${errors} error(s), ${diags.length - errors} warning(s)`}`);
|
|
89
90
|
return errors ? 1 : 0;
|
|
90
91
|
}
|
|
91
92
|
/**
|
|
@@ -124,19 +125,4 @@ function readBaseline(path) {
|
|
|
124
125
|
}
|
|
125
126
|
return parsed;
|
|
126
127
|
}
|
|
127
|
-
/**
|
|
128
|
-
* The `--baseline` summary: the errors that fail the check (the edit's), the
|
|
129
|
-
* pre-existing lowering findings (probable SDK defects) and the other
|
|
130
|
-
* pre-existing findings, and the edit's own warnings when there are any. For
|
|
131
|
-
* instance `1 error(s) in edited nodes, 1 pre-existing SDK defect(s), 1 pre-existing warning(s)`.
|
|
132
|
-
*/
|
|
133
|
-
function baselineSummary(diags) {
|
|
134
|
-
const edited = diags.filter((d) => d.origin !== 'pre-existing');
|
|
135
|
-
const pre = diags.filter((d) => d.origin === 'pre-existing');
|
|
136
|
-
const errors = edited.filter((d) => d.level === 'error').length;
|
|
137
|
-
const defects = pre.filter((d) => d.class === 'lowering').length;
|
|
138
|
-
const warnings = edited.length - errors;
|
|
139
|
-
return `${errors} error(s) in edited nodes, ${defects} pre-existing SDK defect(s), ${pre.length - defects} pre-existing warning(s)`
|
|
140
|
-
+ (warnings ? `, ${warnings} warning(s) in edited nodes` : '');
|
|
141
|
-
}
|
|
142
128
|
runWhenInvokedDirectly(import.meta.url, 'check', run);
|
package/dist/check.js
CHANGED
|
@@ -22,7 +22,8 @@ import { resolveVersion, resolveVersionCarried } from './core/nodes/versioned.js
|
|
|
22
22
|
import { registeredRawType } from './raw-node-advice.js';
|
|
23
23
|
import { loopParallelWarning, resolveLoopDefinition, loopVersion } from './loop-version.js';
|
|
24
24
|
import { refusalClass } from './core/refusals.js';
|
|
25
|
-
import { classifyDrafts,
|
|
25
|
+
import { classifyDrafts, placeDiagnostics } from './edit-scope.js';
|
|
26
|
+
import { preExistingFindings, scopeFindings } from './core/baseline-scope.js';
|
|
26
27
|
export function check(built, opts = {}) {
|
|
27
28
|
return checkCompiled(built, opts).diagnostics;
|
|
28
29
|
}
|
|
@@ -89,47 +90,12 @@ export function checkCompiled(built, opts = {}) {
|
|
|
89
90
|
export function scopeToEdit(edited, baseline) {
|
|
90
91
|
const locate = (c) => placeDiagnostics(c.diagnostics, c.flow)
|
|
91
92
|
.map((d, i) => ({ ...d, nodeId: c.diagnostics[i].nodeId ?? d.nodeId, index: i }));
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
continue;
|
|
99
|
-
pool.set(onNode(b), [...(pool.get(onNode(b)) ?? []), b.message]);
|
|
100
|
-
}
|
|
101
|
-
const preExisting = new Set();
|
|
102
|
-
// Exact messages are matched first: of two findings of one code on a node,
|
|
103
|
-
// the one the baseline has word for word is the pre-existing one. The second
|
|
104
|
-
// pass forgives wording the edit can shift without touching the finding (a
|
|
105
|
-
// "Known steps: ..." list), but only between messages that name the same
|
|
106
|
-
// quoted subjects: `UNKNOWN_REF "lookup" in "audit"` is a different finding
|
|
107
|
-
// from the baseline's `UNKNOWN_REF "ghost" in "audit"`, so it stays edited.
|
|
108
|
-
for (const exact of [true, false]) {
|
|
109
|
-
for (const f of sorted.kept) {
|
|
110
|
-
if (preExisting.has(f.index))
|
|
111
|
-
continue;
|
|
112
|
-
const messages = pool.get(onNode(f)) ?? [];
|
|
113
|
-
const j = exact ? messages.indexOf(f.message) : messages.findIndex((m) => quotedSubjects(m) === quotedSubjects(f.message));
|
|
114
|
-
if (j < 0)
|
|
115
|
-
continue;
|
|
116
|
-
messages.splice(j, 1);
|
|
117
|
-
preExisting.add(f.index);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
for (const f of splitUnplaced(sorted.unplaced, findingCounts(baseline.diagnostics)).known)
|
|
121
|
-
preExisting.add(f.index);
|
|
122
|
-
const out = edited.diagnostics.map((d, i) => {
|
|
123
|
-
if (!preExisting.has(i))
|
|
124
|
-
return { ...d, origin: 'edited' };
|
|
125
|
-
const defect = d.level === 'error' && d.class === 'lowering';
|
|
126
|
-
return {
|
|
127
|
-
...d,
|
|
128
|
-
level: 'warning',
|
|
129
|
-
message: defect ? `${d.message}\n ${PRE_EXISTING_LOWERING_NOTE}` : d.message,
|
|
130
|
-
origin: 'pre-existing',
|
|
131
|
-
};
|
|
132
|
-
});
|
|
93
|
+
const placed = locate(edited);
|
|
94
|
+
const sorted = classifyDrafts(baseline.flow ?? {}, edited.flow ?? {}, baseline.flow, placed);
|
|
95
|
+
const kept = new Set(sorted.kept.map((f) => f.index));
|
|
96
|
+
const unplaced = new Set(sorted.unplaced.map((f) => f.index));
|
|
97
|
+
const preExisting = preExistingFindings(placed.map((f) => ({ level: f.level, code: f.code, message: f.message, place: unplaced.has(f.index) ? '' : f.nodeId, unchanged: kept.has(f.index) })), locate(baseline).map((b) => ({ level: b.level, code: b.code, message: b.message, place: b.nodeId })));
|
|
98
|
+
const out = scopeFindings(edited.diagnostics, preExisting, PRE_EXISTING_LOWERING_NOTE);
|
|
133
99
|
if (edited.stoppedAt) {
|
|
134
100
|
const at = edited.stoppedAt.code !== undefined ? `[${edited.stoppedAt.code}] ` : '';
|
|
135
101
|
out.push({
|
|
@@ -141,10 +107,6 @@ export function scopeToEdit(edited, baseline) {
|
|
|
141
107
|
}
|
|
142
108
|
return out;
|
|
143
109
|
}
|
|
144
|
-
/** The `"quoted"` names in a finding's message, in order: what it is about, apart from its wording. */
|
|
145
|
-
function quotedSubjects(message) {
|
|
146
|
-
return JSON.stringify(message.match(/"[^"]*"/g) ?? []);
|
|
147
|
-
}
|
|
148
110
|
/** What a pre-existing lowering finding adds to its message ({@link scopeToEdit}). */
|
|
149
111
|
const PRE_EXISTING_LOWERING_NOTE = 'This node is unchanged from the baseline, so this is probably an SDK defect: '
|
|
150
112
|
+ 'the SDK cannot read what the designer wrote. `compile` refuses this node; `merge --baseline-from` keeps it as saved. '
|
|
@@ -36,6 +36,7 @@ export function registerBpmnCommands(program) {
|
|
|
36
36
|
.addOption(retiredCompiledOption())
|
|
37
37
|
.option('--resources <file>', 'resource ledger that registry prepare writes (default .flow-sdk/resources.json)')
|
|
38
38
|
.option('--no-types', 'skip the TypeScript type check of the source')
|
|
39
|
+
.option('--baseline <file>', 'the original .bpmn the source was decompiled from: findings on elements the edit did not touch, which the original has too, become warnings')
|
|
39
40
|
.action(async (input, options) => {
|
|
40
41
|
let mode;
|
|
41
42
|
try {
|
|
@@ -58,6 +59,7 @@ export function registerBpmnCommands(program) {
|
|
|
58
59
|
addValue(argv, '--connectors-local', options.connectorsLocal);
|
|
59
60
|
addValue(argv, '--bindings', options.bindings);
|
|
60
61
|
addValue(argv, '--resources', options.resources);
|
|
62
|
+
addValue(argv, '--baseline', options.baseline);
|
|
61
63
|
await invoke('bpmn check', () => import('../../bpmn/check-cli.js'), argv);
|
|
62
64
|
});
|
|
63
65
|
family
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* baseline-scope — the part of `check --baseline <original>` every family shares:
|
|
3
|
+
* given each finding's place and whether that place is unchanged from the
|
|
4
|
+
* original, decide which findings the edit did not cause.
|
|
5
|
+
*
|
|
6
|
+
* The family decides the two things that are its own: where a finding sits (a
|
|
7
|
+
* Flow node, a BPMN element) and what "unchanged" means there (Flow: merge's
|
|
8
|
+
* `classifyDrafts`; BPMN: the same built element, payload and all). This file
|
|
9
|
+
* matches the findings against the original's own check, the same way for all.
|
|
10
|
+
*
|
|
11
|
+
* For instance, an edited check that reports `INTSVC_CONNECTION_MISSING` on an
|
|
12
|
+
* element `task1` the edit did not touch, while the original's check reports
|
|
13
|
+
* the same code on `task1`, gets that finding back as pre-existing. The same
|
|
14
|
+
* finding on an element the edit changed is not, and neither is a finding the
|
|
15
|
+
* original does not have.
|
|
16
|
+
*
|
|
17
|
+
* Pure: no file access, no family imports.
|
|
18
|
+
*/
|
|
19
|
+
import { type RefusalClass } from './refusals.js';
|
|
20
|
+
/** A finding of the ORIGINAL's check: its level, code, message and place (`''` when it names none). */
|
|
21
|
+
export interface BaselineFinding {
|
|
22
|
+
/**
|
|
23
|
+
* Some codes are a warning or an error depending on the rest of the process, with the
|
|
24
|
+
* same subjects either way (BPMN's SCOPED_VAR_UNKNOWN_ELEMENT turns into an error once
|
|
25
|
+
* something reads the variable), so only a finding of the same level vouches.
|
|
26
|
+
*/
|
|
27
|
+
level: 'error' | 'warning';
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
/** The node or element id the finding is on; `''` when it names none the family knows. */
|
|
31
|
+
place: string;
|
|
32
|
+
}
|
|
33
|
+
/** A finding of the EDITED check, with whether its place is unchanged from the original. */
|
|
34
|
+
export interface EditedFinding extends BaselineFinding {
|
|
35
|
+
/** The place is in the original and the edit did not change it. Ignored when `place` is `''`. */
|
|
36
|
+
unchanged: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** How many times each code-and-message pair occurs, for {@link splitUnplaced}'s baseline. */
|
|
39
|
+
export declare function findingCounts(findings: ReadonlyArray<{
|
|
40
|
+
code: string;
|
|
41
|
+
message: string;
|
|
42
|
+
}>): Map<string, number>;
|
|
43
|
+
/**
|
|
44
|
+
* Sort findings that name no node or element by whether the edit introduced
|
|
45
|
+
* them: `known` when the ORIGINAL's own check (`baseline`, as
|
|
46
|
+
* {@link findingCounts}) reports the same code and message — once per
|
|
47
|
+
* occurrence, so a second copy of a finding the original has once is
|
|
48
|
+
* `introduced` — and `introduced` otherwise. With no baseline counts (a
|
|
49
|
+
* precompiled `--baseline` file in `flow merge`), every one is `introduced`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function splitUnplaced<T extends {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
}>(unplaced: readonly T[], baseline: ReadonlyMap<string, number> | undefined): {
|
|
55
|
+
known: T[];
|
|
56
|
+
introduced: T[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The indexes into `edited` of the findings the edit did not cause:
|
|
60
|
+
*
|
|
61
|
+
* - a finding on an unchanged place is pre-existing when the original
|
|
62
|
+
* reports the same code on the same place, once per occurrence. Exact
|
|
63
|
+
* messages are matched first; a second pass forgives wording the edit can
|
|
64
|
+
* shift without touching the finding (a "Known steps: ..." list), but only
|
|
65
|
+
* between messages that name the same `"quoted"` subjects;
|
|
66
|
+
* - a finding that names no place is pre-existing when the original reports
|
|
67
|
+
* the same code and message ({@link splitUnplaced});
|
|
68
|
+
* - a finding on a changed or new place never is.
|
|
69
|
+
*
|
|
70
|
+
* Every match also needs the same level: an edited error is never vouched for by a
|
|
71
|
+
* warning the original has, since the edit is what made it an error.
|
|
72
|
+
*/
|
|
73
|
+
export declare function preExistingFindings(edited: readonly EditedFinding[], baseline: readonly BaselineFinding[]): Set<number>;
|
|
74
|
+
/** A diagnostic as {@link scopeFindings} reads and writes it. */
|
|
75
|
+
interface ScopableDiagnostic {
|
|
76
|
+
level: 'error' | 'warning';
|
|
77
|
+
code: string;
|
|
78
|
+
message: string;
|
|
79
|
+
class?: RefusalClass;
|
|
80
|
+
origin?: 'edited' | 'pre-existing';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* `diags` with an `origin` on each: `pre-existing` for the indexes in
|
|
84
|
+
* `preExisting` (a {@link preExistingFindings} result), `edited` for the rest.
|
|
85
|
+
* A pre-existing finding becomes a warning, so it does not fail the check; a
|
|
86
|
+
* pre-existing `lowering` error also gets `loweringNote` on a line of its own,
|
|
87
|
+
* since the SDK cannot write back what the original holds there.
|
|
88
|
+
*/
|
|
89
|
+
export declare function scopeFindings<D extends ScopableDiagnostic>(diags: readonly D[], preExisting: ReadonlySet<number>, loweringNote: string): D[];
|
|
90
|
+
/**
|
|
91
|
+
* The `check --baseline` summary line: the errors that fail the check (the
|
|
92
|
+
* edit's), the pre-existing lowering findings (probable SDK defects) and the
|
|
93
|
+
* other pre-existing findings, and the edit's own warnings when there are any.
|
|
94
|
+
* `places` names what was edited (`nodes`, `elements`). For instance
|
|
95
|
+
* `1 error(s) in edited nodes, 1 pre-existing SDK defect(s), 1 pre-existing warning(s)`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function baselineSummary(diags: readonly ScopableDiagnostic[], places: string): string;
|
|
98
|
+
export {};
|