@bpmn-ld/bpmn-ld 0.0.0-stage → 0.1.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 +201 -0
- package/README.md +125 -2
- package/contexts/combined.jsonld +3 -0
- package/contexts/core.jsonld +170 -0
- package/contexts/di.jsonld +37 -0
- package/dist/analyze/analyze.d.ts +3 -0
- package/dist/analyze/analyze.js +11 -0
- package/dist/analyze/findings.d.ts +8 -0
- package/dist/analyze/findings.js +1 -0
- package/dist/analyze/report.d.ts +3 -0
- package/dist/analyze/report.js +9 -0
- package/dist/analyze/rules/ad-hoc-completion-condition.d.ts +2 -0
- package/dist/analyze/rules/ad-hoc-completion-condition.js +7 -0
- package/dist/analyze/rules/cannot-reach-end.d.ts +2 -0
- package/dist/analyze/rules/cannot-reach-end.js +28 -0
- package/dist/analyze/rules/compensation-association.d.ts +2 -0
- package/dist/analyze/rules/compensation-association.js +13 -0
- package/dist/analyze/rules/dead-end.d.ts +2 -0
- package/dist/analyze/rules/dead-end.js +13 -0
- package/dist/analyze/rules/end-event.d.ts +2 -0
- package/dist/analyze/rules/end-event.js +8 -0
- package/dist/analyze/rules/error-catch.d.ts +2 -0
- package/dist/analyze/rules/error-catch.js +14 -0
- package/dist/analyze/rules/escalation-catch.d.ts +2 -0
- package/dist/analyze/rules/escalation-catch.js +14 -0
- package/dist/analyze/rules/gateway-cardinality.d.ts +3 -0
- package/dist/analyze/rules/gateway-cardinality.js +17 -0
- package/dist/analyze/rules/index.d.ts +4 -0
- package/dist/analyze/rules/index.js +21 -0
- package/dist/analyze/rules/instantiating-gateway.d.ts +2 -0
- package/dist/analyze/rules/instantiating-gateway.js +14 -0
- package/dist/analyze/rules/non-interrupting-start.d.ts +2 -0
- package/dist/analyze/rules/non-interrupting-start.js +14 -0
- package/dist/analyze/rules/reachability.d.ts +2 -0
- package/dist/analyze/rules/reachability.js +25 -0
- package/dist/analyze/rules/rule.d.ts +7 -0
- package/dist/analyze/rules/rule.js +1 -0
- package/dist/analyze/rules/signal-catch.d.ts +2 -0
- package/dist/analyze/rules/signal-catch.js +12 -0
- package/dist/analyze/rules/split-join-pairing.d.ts +3 -0
- package/dist/analyze/rules/split-join-pairing.js +50 -0
- package/dist/analyze/rules/start-event.d.ts +2 -0
- package/dist/analyze/rules/start-event.js +8 -0
- package/dist/analyze/rules/task-message-flow.d.ts +2 -0
- package/dist/analyze/rules/task-message-flow.js +19 -0
- package/dist/analyze/scope-graph.d.ts +56 -0
- package/dist/analyze/scope-graph.js +89 -0
- package/dist/analyze-cli.d.ts +1 -0
- package/dist/analyze-cli.js +5 -0
- package/dist/analyze-run.d.ts +12 -0
- package/dist/analyze-run.js +85 -0
- package/dist/bpmn-ld-cli.d.ts +1 -0
- package/dist/bpmn-ld-cli.js +90 -0
- package/dist/build-cli.d.ts +1 -0
- package/dist/build-cli.js +2 -0
- package/dist/build.d.ts +3 -0
- package/dist/build.js +38 -0
- package/dist/check-xml/check.d.ts +3 -0
- package/dist/check-xml/check.js +11 -0
- package/dist/check-xml/lint.d.ts +2 -0
- package/dist/check-xml/lint.js +47 -0
- package/dist/check-xml/moddle.d.ts +6 -0
- package/dist/check-xml/moddle.js +23 -0
- package/dist/check-xml/types.d.ts +20 -0
- package/dist/check-xml/types.js +1 -0
- package/dist/check-xml/xsd.d.ts +2 -0
- package/dist/check-xml/xsd.js +25 -0
- package/dist/check-xml-cli.d.ts +1 -0
- package/dist/check-xml-cli.js +5 -0
- package/dist/check-xml-run.d.ts +10 -0
- package/dist/check-xml-run.js +77 -0
- package/dist/convert/analyze-output.d.ts +3 -0
- package/dist/convert/analyze-output.js +8 -0
- package/dist/convert/convert.d.ts +19 -0
- package/dist/convert/convert.js +96 -0
- package/dist/convert/errors.d.ts +5 -0
- package/dist/convert/errors.js +8 -0
- package/dist/convert/extensions.d.ts +23 -0
- package/dist/convert/extensions.js +103 -0
- package/dist/convert/mapping-check.d.ts +15 -0
- package/dist/convert/mapping-check.js +66 -0
- package/dist/convert/mapping.d.ts +52 -0
- package/dist/convert/mapping.js +273 -0
- package/dist/convert/namespaces.d.ts +2 -0
- package/dist/convert/namespaces.js +19 -0
- package/dist/convert/validate-output.d.ts +2 -0
- package/dist/convert/validate-output.js +28 -0
- package/dist/convert/warnings.d.ts +9 -0
- package/dist/convert/warnings.js +67 -0
- package/dist/convert/xml-reader.d.ts +11 -0
- package/dist/convert/xml-reader.js +84 -0
- package/dist/convert-cli.d.ts +1 -0
- package/dist/convert-cli.js +5 -0
- package/dist/convert-run.d.ts +10 -0
- package/dist/convert-run.js +125 -0
- package/dist/coverage-cli.d.ts +1 -0
- package/dist/coverage-cli.js +8 -0
- package/dist/coverage-mappings.d.ts +3 -0
- package/dist/coverage-mappings.js +34 -0
- package/dist/coverage-scope.d.ts +11 -0
- package/dist/coverage-scope.js +187 -0
- package/dist/coverage-xsd.d.ts +15 -0
- package/dist/coverage-xsd.js +55 -0
- package/dist/coverage.d.ts +35 -0
- package/dist/coverage.js +152 -0
- package/dist/docs-cli.d.ts +1 -0
- package/dist/docs-cli.js +18 -0
- package/dist/docs.d.ts +8 -0
- package/dist/docs.js +136 -0
- package/dist/eval/checks.d.ts +19 -0
- package/dist/eval/checks.js +252 -0
- package/dist/eval/regenerate.d.ts +10 -0
- package/dist/eval/regenerate.js +48 -0
- package/dist/eval-regenerate-cli.d.ts +1 -0
- package/dist/eval-regenerate-cli.js +16 -0
- package/dist/export/data.d.ts +10 -0
- package/dist/export/data.js +127 -0
- package/dist/export/diagram.d.ts +8 -0
- package/dist/export/diagram.js +112 -0
- package/dist/export/element.d.ts +27 -0
- package/dist/export/element.js +175 -0
- package/dist/export/export.d.ts +22 -0
- package/dist/export/export.js +124 -0
- package/dist/export/extensions.d.ts +18 -0
- package/dist/export/extensions.js +122 -0
- package/dist/export/layout-export.d.ts +4 -0
- package/dist/export/layout-export.js +25 -0
- package/dist/export/mapping-check.d.ts +39 -0
- package/dist/export/mapping-check.js +175 -0
- package/dist/export/normalize.d.ts +3 -0
- package/dist/export/normalize.js +67 -0
- package/dist/export-cli.d.ts +1 -0
- package/dist/export-cli.js +5 -0
- package/dist/export-run.d.ts +10 -0
- package/dist/export-run.js +157 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/install-skill-run.d.ts +8 -0
- package/dist/install-skill-run.js +30 -0
- package/dist/install-skill.d.ts +23 -0
- package/dist/install-skill.js +76 -0
- package/dist/layout/collaboration.d.ts +36 -0
- package/dist/layout/collaboration.js +152 -0
- package/dist/layout/di.d.ts +15 -0
- package/dist/layout/di.js +52 -0
- package/dist/layout/extract.d.ts +2 -0
- package/dist/layout/extract.js +99 -0
- package/dist/layout/lanes.d.ts +30 -0
- package/dist/layout/lanes.js +112 -0
- package/dist/layout/layering.d.ts +7 -0
- package/dist/layout/layering.js +53 -0
- package/dist/layout/layout.d.ts +12 -0
- package/dist/layout/layout.js +299 -0
- package/dist/layout/model.d.ts +52 -0
- package/dist/layout/model.js +10 -0
- package/dist/layout/placement.d.ts +25 -0
- package/dist/layout/placement.js +256 -0
- package/dist/layout/standalone.d.ts +8 -0
- package/dist/layout/standalone.js +50 -0
- package/dist/layout-cli.d.ts +1 -0
- package/dist/layout-cli.js +5 -0
- package/dist/layout-run.d.ts +9 -0
- package/dist/layout-run.js +105 -0
- package/dist/loader.d.ts +5 -0
- package/dist/loader.js +7 -0
- package/dist/namespace.d.ts +5 -0
- package/dist/namespace.js +5 -0
- package/dist/ontology.d.ts +19 -0
- package/dist/ontology.js +94 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.js +2 -0
- package/dist/render/geometry.d.ts +40 -0
- package/dist/render/geometry.js +81 -0
- package/dist/render/renderer.d.ts +31 -0
- package/dist/render/renderer.js +369 -0
- package/dist/render/symbols.d.ts +10 -0
- package/dist/render/symbols.js +26 -0
- package/dist/render/text.d.ts +20 -0
- package/dist/render/text.js +28 -0
- package/dist/render-cli.d.ts +1 -0
- package/dist/render-cli.js +7 -0
- package/dist/render-run.d.ts +9 -0
- package/dist/render-run.js +161 -0
- package/dist/render.d.ts +4 -0
- package/dist/render.js +4 -0
- package/dist/schema-overrides.d.ts +14 -0
- package/dist/schema-overrides.js +36 -0
- package/dist/schema-validate.d.ts +5 -0
- package/dist/schema-validate.js +8 -0
- package/dist/schema.d.ts +6 -0
- package/dist/schema.js +114 -0
- package/dist/shacl.d.ts +15 -0
- package/dist/shacl.js +37 -0
- package/dist/validate-cli.d.ts +1 -0
- package/dist/validate-cli.js +5 -0
- package/dist/validate-run.d.ts +8 -0
- package/dist/validate-run.js +58 -0
- package/dist/validate.d.ts +11 -0
- package/dist/validate.js +94 -0
- package/dist/versioning-cli.d.ts +1 -0
- package/dist/versioning-cli.js +18 -0
- package/dist/versioning.d.ts +17 -0
- package/dist/versioning.js +45 -0
- package/ontology/core.ttl +993 -0
- package/ontology/di.ttl +167 -0
- package/package.json +76 -4
- package/schema/bpmn-ld.schema.json +15230 -0
- package/shapes/core.shapes.ttl +398 -0
- package/skills/bpmn-ld/SKILL.md +154 -0
- package/skills/bpmn-ld/evals/models/order-approval-di.jsonld +296 -0
- package/skills/bpmn-ld/evals/models/refund-di.bpmn +82 -0
- package/skills/bpmn-ld/evals/models/refund.bpmn +18 -0
- package/skills/bpmn-ld/evals/outputs/explain-collaboration.md +22 -0
- package/skills/bpmn-ld/evals/outputs/explain-order-approval.md +24 -0
- package/skills/bpmn-ld/evals/outputs/explain-refund.md +17 -0
- package/skills/bpmn-ld/evals/outputs/generate-activity-compensation.jsonld +39 -0
- package/skills/bpmn-ld/evals/outputs/generate-ad-hoc-sub-process.jsonld +52 -0
- package/skills/bpmn-ld/evals/outputs/generate-boundary-event.jsonld +27 -0
- package/skills/bpmn-ld/evals/outputs/generate-collaboration.jsonld +49 -0
- package/skills/bpmn-ld/evals/outputs/generate-conditions.jsonld +93 -0
- package/skills/bpmn-ld/evals/outputs/generate-diagram-properties.jsonld +340 -0
- package/skills/bpmn-ld/evals/outputs/generate-error.jsonld +217 -0
- package/skills/bpmn-ld/evals/outputs/generate-escalation.jsonld +231 -0
- package/skills/bpmn-ld/evals/outputs/generate-event-definition-ref.jsonld +67 -0
- package/skills/bpmn-ld/evals/outputs/generate-event-sub-process.jsonld +54 -0
- package/skills/bpmn-ld/evals/outputs/generate-exclusive-choice.jsonld +32 -0
- package/skills/bpmn-ld/evals/outputs/generate-instantiating-gateway.jsonld +24 -0
- package/skills/bpmn-ld/evals/outputs/generate-lane-partition.jsonld +46 -0
- package/skills/bpmn-ld/evals/outputs/generate-link-event.expect.json +11 -0
- package/skills/bpmn-ld/evals/outputs/generate-link-event.jsonld +57 -0
- package/skills/bpmn-ld/evals/outputs/generate-loop.jsonld +30 -0
- package/skills/bpmn-ld/evals/outputs/generate-message.jsonld +61 -0
- package/skills/bpmn-ld/evals/outputs/generate-parallel-branches.jsonld +25 -0
- package/skills/bpmn-ld/evals/outputs/generate-process-attributes.jsonld +49 -0
- package/skills/bpmn-ld/evals/outputs/generate-script-task.jsonld +18 -0
- package/skills/bpmn-ld/evals/outputs/generate-signal.jsonld +178 -0
- package/skills/bpmn-ld/evals/outputs/generate-sub-process.jsonld +31 -0
- package/skills/bpmn-ld/evals/outputs/generate-targeted-compensation.jsonld +40 -0
- package/skills/bpmn-ld/evals/outputs/generate-task-implementation.jsonld +18 -0
- package/skills/bpmn-ld/evals/outputs/generate-task-message-references.jsonld +49 -0
- package/skills/bpmn-ld/evals/outputs/generate-transaction.jsonld +48 -0
- package/skills/bpmn-ld/evals/outputs/modify-order-approval.jsonld +376 -0
- package/skills/bpmn-ld/evals/outputs/modify-refund.jsonld +373 -0
- package/skills/bpmn-ld/evals/outputs/order-approval.jsonld +29 -0
- package/skills/bpmn-ld/evals/outputs/refine-order-approval.jsonld +377 -0
- package/skills/bpmn-ld/evals/prompts/explain-collaboration.md +3 -0
- package/skills/bpmn-ld/evals/prompts/explain-order-approval.md +3 -0
- package/skills/bpmn-ld/evals/prompts/explain-refund.md +3 -0
- package/skills/bpmn-ld/evals/prompts/generate-activity-compensation.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-ad-hoc-sub-process.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-boundary-event.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-collaboration.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-conditions.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-diagram-properties.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-error.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-escalation.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-event-definition-ref.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-event-sub-process.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-exclusive-choice.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-instantiating-gateway.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-lane-partition.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-link-event.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-loop.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-message.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-parallel-branches.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-process-attributes.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-script-task.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-signal.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-sub-process.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-targeted-compensation.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-task-implementation.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-task-message-references.md +1 -0
- package/skills/bpmn-ld/evals/prompts/generate-transaction.md +1 -0
- package/skills/bpmn-ld/evals/prompts/modify-order-approval.md +4 -0
- package/skills/bpmn-ld/evals/prompts/modify-refund.md +4 -0
- package/skills/bpmn-ld/evals/prompts/order-approval.md +1 -0
- package/skills/bpmn-ld/evals/prompts/refine-order-approval.md +8 -0
- package/skills/bpmn-ld/examples/positive/activity-compensation.jsonld +39 -0
- package/skills/bpmn-ld/examples/positive/ad-hoc-sub-process.jsonld +52 -0
- package/skills/bpmn-ld/examples/positive/boundary-event.jsonld +27 -0
- package/skills/bpmn-ld/examples/positive/collaboration.jsonld +49 -0
- package/skills/bpmn-ld/examples/positive/conditions.jsonld +93 -0
- package/skills/bpmn-ld/examples/positive/diagram-properties.jsonld +340 -0
- package/skills/bpmn-ld/examples/positive/error.jsonld +208 -0
- package/skills/bpmn-ld/examples/positive/escalation.jsonld +231 -0
- package/skills/bpmn-ld/examples/positive/event-definition-ref.jsonld +142 -0
- package/skills/bpmn-ld/examples/positive/event-sub-process.jsonld +54 -0
- package/skills/bpmn-ld/examples/positive/exclusive-choice.jsonld +32 -0
- package/skills/bpmn-ld/examples/positive/instantiating-gateway.jsonld +24 -0
- package/skills/bpmn-ld/examples/positive/lane-partition.jsonld +46 -0
- package/skills/bpmn-ld/examples/positive/link-event.expect.json +10 -0
- package/skills/bpmn-ld/examples/positive/link-event.jsonld +138 -0
- package/skills/bpmn-ld/examples/positive/loop.jsonld +30 -0
- package/skills/bpmn-ld/examples/positive/message.jsonld +60 -0
- package/skills/bpmn-ld/examples/positive/order-approval.jsonld +29 -0
- package/skills/bpmn-ld/examples/positive/parallel-branches.jsonld +25 -0
- package/skills/bpmn-ld/examples/positive/process-attributes.jsonld +49 -0
- package/skills/bpmn-ld/examples/positive/script-task.jsonld +18 -0
- package/skills/bpmn-ld/examples/positive/signal.jsonld +150 -0
- package/skills/bpmn-ld/examples/positive/sub-process.jsonld +31 -0
- package/skills/bpmn-ld/examples/positive/targeted-compensation.jsonld +40 -0
- package/skills/bpmn-ld/examples/positive/task-implementation.jsonld +18 -0
- package/skills/bpmn-ld/examples/positive/task-message-references.jsonld +151 -0
- package/skills/bpmn-ld/examples/positive/transaction.jsonld +48 -0
- package/skills/bpmn-ld/references/clarification-and-refinement.md +60 -0
- package/skills/bpmn-ld/references/common-mistakes.md +110 -0
- package/skills/bpmn-ld/references/explain-and-document.md +36 -0
- package/skills/bpmn-ld/references/modify-existing-model.md +49 -0
- package/skills/bpmn-ld/references/patterns.md +292 -0
- package/skills/bpmn-ld/references/render-output.md +1 -0
- package/skills/bpmn-ld/references/rule-catalogue.md +183 -0
- package/skills/bpmn-ld/references/vocabulary-summary.md +65 -0
- package/skills/bpmn-ld/template.jsonld +14 -0
- package/templates/combined.jsonld +3 -0
- package/templates/core.jsonld +170 -0
- package/templates/core.shapes.ttl +398 -0
- package/templates/core.ttl +993 -0
- package/templates/di.jsonld +37 -0
- package/templates/di.ttl +167 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { XMLParser } from "fast-xml-parser";
|
|
2
|
+
import { ConversionError } from "./errors.js";
|
|
3
|
+
const XMLNS = "xmlns";
|
|
4
|
+
const parser = new XMLParser({
|
|
5
|
+
preserveOrder: true,
|
|
6
|
+
ignoreAttributes: false,
|
|
7
|
+
attributeNamePrefix: "@_",
|
|
8
|
+
attributesGroupName: ":@",
|
|
9
|
+
trimValues: true,
|
|
10
|
+
parseTagValue: false,
|
|
11
|
+
parseAttributeValue: false,
|
|
12
|
+
htmlEntities: true,
|
|
13
|
+
});
|
|
14
|
+
const splitName = (qualified) => {
|
|
15
|
+
const index = qualified.indexOf(":");
|
|
16
|
+
return index < 0 ? ["", qualified] : [qualified.slice(0, index), qualified.slice(index + 1)];
|
|
17
|
+
};
|
|
18
|
+
const tagOf = (node) => Object.keys(node).find((key) => key !== ":@" && key !== "#text");
|
|
19
|
+
const resolve = (nodes, scope, parent) => {
|
|
20
|
+
const seen = new Map();
|
|
21
|
+
return nodes.flatMap((node) => {
|
|
22
|
+
const tag = tagOf(node);
|
|
23
|
+
if (tag === undefined)
|
|
24
|
+
return [];
|
|
25
|
+
const raw = (node[":@"] ?? {});
|
|
26
|
+
const local = new Map(scope);
|
|
27
|
+
const declarations = [];
|
|
28
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
29
|
+
const name = key.slice(2);
|
|
30
|
+
const declared = name === XMLNS ? "" : name.startsWith(`${XMLNS}:`) ? name.slice(XMLNS.length + 1) : undefined;
|
|
31
|
+
if (declared === undefined)
|
|
32
|
+
continue;
|
|
33
|
+
local.set(declared, value);
|
|
34
|
+
declarations.push([declared, value]);
|
|
35
|
+
}
|
|
36
|
+
const attributes = {};
|
|
37
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
38
|
+
const name = key.slice(2);
|
|
39
|
+
if (name === XMLNS || name.startsWith(`${XMLNS}:`))
|
|
40
|
+
continue;
|
|
41
|
+
const [prefix, localName] = splitName(name);
|
|
42
|
+
attributes[prefix ? `{${local.get(prefix) ?? prefix}}${localName}` : localName] = value;
|
|
43
|
+
}
|
|
44
|
+
const content = node[tag];
|
|
45
|
+
const [prefix, name] = splitName(tag);
|
|
46
|
+
const index = (seen.get(name) ?? 0) + 1;
|
|
47
|
+
seen.set(name, index);
|
|
48
|
+
const location = parent === null ? `/${name}` : `${parent}/${name}[${index}]`;
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
namespace: local.get(prefix) ?? "",
|
|
52
|
+
name,
|
|
53
|
+
attributes,
|
|
54
|
+
declarations,
|
|
55
|
+
children: resolve(content, local, location),
|
|
56
|
+
text: content
|
|
57
|
+
.filter((child) => "#text" in child)
|
|
58
|
+
.map((child) => String(child["#text"]))
|
|
59
|
+
.join(""),
|
|
60
|
+
location,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export const readXml = (xml) => {
|
|
66
|
+
let parsed;
|
|
67
|
+
try {
|
|
68
|
+
parsed = parser.parse(xml, true);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw new ConversionError("malformed-xml", `input is not well-formed XML: ${error instanceof Error ? error.message : String(error)}`);
|
|
72
|
+
}
|
|
73
|
+
const [root] = resolve(parsed.filter((node) => !("?xml" in node)), new Map(), null);
|
|
74
|
+
if (!root)
|
|
75
|
+
throw new ConversionError("malformed-xml", "input is not well-formed XML: no root element");
|
|
76
|
+
return root;
|
|
77
|
+
};
|
|
78
|
+
export const collectIds = (element, ids = new Set()) => {
|
|
79
|
+
if (element.attributes.id !== undefined)
|
|
80
|
+
ids.add(element.attributes.id);
|
|
81
|
+
for (const child of element.children)
|
|
82
|
+
collectIds(child, ids);
|
|
83
|
+
return ids;
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const EXIT_OK = 0;
|
|
2
|
+
export declare const EXIT_CHECK_FAILED = 1;
|
|
3
|
+
export declare const EXIT_USAGE = 2;
|
|
4
|
+
export interface CliResult {
|
|
5
|
+
exitCode: number;
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const USAGE = "Usage: convert <input.bpmn> [options]\n\nConverts a BPMN 2.0 XML file to BPMN-LD JSON-LD.\n\nOptions:\n -o, --output <file> Write JSON-LD to <file> instead of standard output\n --base <iri> Document base IRI (default: derived from the input file name)\n --strict Exit with code 1 if the conversion produced any warning\n --validate Validate the output against the JSON Schema and SHACL shapes\n -h, --help Show this help\n\nWarnings and errors are written to standard error.\n\nExit codes:\n 0 Converted successfully\n 1 Strict mode found warnings, or validation failed\n 2 Usage error or unusable input (missing file, malformed XML, not BPMN)\n";
|
|
10
|
+
export declare const runConvert: (argv: string[]) => Promise<CliResult>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { convert } from "./convert/convert.js";
|
|
3
|
+
import { ConversionError } from "./convert/errors.js";
|
|
4
|
+
import { validateConverted } from "./convert/validate-output.js";
|
|
5
|
+
export const EXIT_OK = 0;
|
|
6
|
+
export const EXIT_CHECK_FAILED = 1;
|
|
7
|
+
export const EXIT_USAGE = 2;
|
|
8
|
+
export const USAGE = `Usage: convert <input.bpmn> [options]
|
|
9
|
+
|
|
10
|
+
Converts a BPMN 2.0 XML file to BPMN-LD JSON-LD.
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
-o, --output <file> Write JSON-LD to <file> instead of standard output
|
|
14
|
+
--base <iri> Document base IRI (default: derived from the input file name)
|
|
15
|
+
--strict Exit with code 1 if the conversion produced any warning
|
|
16
|
+
--validate Validate the output against the JSON Schema and SHACL shapes
|
|
17
|
+
-h, --help Show this help
|
|
18
|
+
|
|
19
|
+
Warnings and errors are written to standard error.
|
|
20
|
+
|
|
21
|
+
Exit codes:
|
|
22
|
+
0 Converted successfully
|
|
23
|
+
1 Strict mode found warnings, or validation failed
|
|
24
|
+
2 Usage error or unusable input (missing file, malformed XML, not BPMN)
|
|
25
|
+
`;
|
|
26
|
+
class UsageError extends Error {
|
|
27
|
+
}
|
|
28
|
+
const parseArgs = (argv) => {
|
|
29
|
+
const options = { input: "", strict: false, validate: false };
|
|
30
|
+
let input;
|
|
31
|
+
const valueOf = (flag, index) => {
|
|
32
|
+
const value = argv[index];
|
|
33
|
+
if (value === undefined || value.startsWith("-"))
|
|
34
|
+
throw new UsageError(`${flag} requires a value`);
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
for (let i = 0; i < argv.length; i++) {
|
|
38
|
+
const arg = argv[i];
|
|
39
|
+
if (arg === "-h" || arg === "--help")
|
|
40
|
+
return "help";
|
|
41
|
+
else if (arg === "-o" || arg === "--output")
|
|
42
|
+
options.output = valueOf(arg, ++i);
|
|
43
|
+
else if (arg === "--base")
|
|
44
|
+
options.base = valueOf(arg, ++i);
|
|
45
|
+
else if (arg === "--strict")
|
|
46
|
+
options.strict = true;
|
|
47
|
+
else if (arg === "--validate")
|
|
48
|
+
options.validate = true;
|
|
49
|
+
else if (arg.startsWith("-"))
|
|
50
|
+
throw new UsageError(`unknown option ${arg}`);
|
|
51
|
+
else if (input !== undefined)
|
|
52
|
+
throw new UsageError(`unexpected extra argument ${arg}`);
|
|
53
|
+
else
|
|
54
|
+
input = arg;
|
|
55
|
+
}
|
|
56
|
+
if (input === undefined)
|
|
57
|
+
throw new UsageError("missing input file");
|
|
58
|
+
options.input = input;
|
|
59
|
+
return options;
|
|
60
|
+
};
|
|
61
|
+
const usageFailure = (message) => ({ exitCode: EXIT_USAGE, stdout: "", stderr: `error: ${message}\n\n${USAGE}` });
|
|
62
|
+
const readInput = (path) => {
|
|
63
|
+
try {
|
|
64
|
+
return readFileSync(path, "utf8");
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
const reason = error.code === "ENOENT" ? "no such file" : (error.message ?? "cannot read");
|
|
68
|
+
throw new UsageError(`cannot read ${path}: ${reason}`);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export const runConvert = async (argv) => {
|
|
72
|
+
let options;
|
|
73
|
+
try {
|
|
74
|
+
options = parseArgs(argv);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (error instanceof UsageError)
|
|
78
|
+
return usageFailure(error.message);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
if (options === "help")
|
|
82
|
+
return { exitCode: EXIT_OK, stdout: USAGE, stderr: "" };
|
|
83
|
+
let xml;
|
|
84
|
+
try {
|
|
85
|
+
xml = readInput(options.input);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return { exitCode: EXIT_USAGE, stdout: "", stderr: `error: ${error.message}\n` };
|
|
89
|
+
}
|
|
90
|
+
let result;
|
|
91
|
+
try {
|
|
92
|
+
result = convert(xml, { base: options.base, fileName: options.input });
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error instanceof ConversionError)
|
|
96
|
+
return { exitCode: EXIT_USAGE, stdout: "", stderr: `error: ${options.input}: ${error.message} (${error.code})\n` };
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
const lines = result.warnings.map((w) => `warning: ${w.kind} ${w.construct} at ${w.location}${w.message ? `: ${w.message}` : ""}`);
|
|
100
|
+
let exitCode = EXIT_OK;
|
|
101
|
+
if (options.strict && result.warnings.length > 0) {
|
|
102
|
+
lines.push(`error: strict mode: ${result.warnings.length} warning(s)`);
|
|
103
|
+
exitCode = EXIT_CHECK_FAILED;
|
|
104
|
+
}
|
|
105
|
+
if (options.validate) {
|
|
106
|
+
const errors = await validateConverted(result.document);
|
|
107
|
+
if (errors.length > 0) {
|
|
108
|
+
lines.push(...errors.map((e) => `error: validation: ${e}`));
|
|
109
|
+
exitCode = EXIT_CHECK_FAILED;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const json = `${JSON.stringify(result.document, null, 2)}\n`;
|
|
113
|
+
let stdout = "";
|
|
114
|
+
if (options.output === undefined)
|
|
115
|
+
stdout = json;
|
|
116
|
+
else {
|
|
117
|
+
try {
|
|
118
|
+
writeFileSync(options.output, json);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return { exitCode: EXIT_USAGE, stdout: "", stderr: [...lines, `error: cannot write ${options.output}: ${error.message}`].join("\n") + "\n" };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { exitCode, stdout, stderr: lines.length ? `${lines.join("\n")}\n` : "" };
|
|
125
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ROOT } from "./paths.js";
|
|
2
|
+
import { writeReports } from "./coverage.js";
|
|
3
|
+
const { summary, unclassified } = writeReports(ROOT);
|
|
4
|
+
console.log(`coverage: ${summary.total.covered} covered, ${summary.total.gap} gaps, ${summary.total["out-of-scope"]} out of scope`);
|
|
5
|
+
if (unclassified.length) {
|
|
6
|
+
console.error(`unclassified XSD types: ${unclassified.join(", ")}`);
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const BUILT_IN_PROPERTIES = {
|
|
2
|
+
id: "@id",
|
|
3
|
+
};
|
|
4
|
+
export const CLASS_ALIASES = {
|
|
5
|
+
Diagram: "BPMNDiagram",
|
|
6
|
+
Plane: "BPMNPlane",
|
|
7
|
+
Node: "DiagramElement",
|
|
8
|
+
Shape: "BPMNShape",
|
|
9
|
+
LabeledShape: "BPMNShape",
|
|
10
|
+
Edge: "BPMNEdge",
|
|
11
|
+
LabeledEdge: "BPMNEdge",
|
|
12
|
+
Label: "BPMNLabel",
|
|
13
|
+
};
|
|
14
|
+
export const PROPERTY_ALIASES = {
|
|
15
|
+
flowElement: "flowElements",
|
|
16
|
+
laneSet: "laneSets",
|
|
17
|
+
artifact: "artifacts",
|
|
18
|
+
lane: "lanes",
|
|
19
|
+
eventDefinition: "eventDefinitions",
|
|
20
|
+
participant: "participants",
|
|
21
|
+
messageFlow: "messageFlows",
|
|
22
|
+
dataInput: "dataInputs",
|
|
23
|
+
dataOutput: "dataOutputs",
|
|
24
|
+
inputSet: "inputSets",
|
|
25
|
+
outputSet: "outputSets",
|
|
26
|
+
dataInputAssociation: "dataInputAssociations",
|
|
27
|
+
dataOutputAssociation: "dataOutputAssociations",
|
|
28
|
+
assignment: "assignments",
|
|
29
|
+
waypoint: "waypoints",
|
|
30
|
+
BPMNPlane: "plane",
|
|
31
|
+
BPMNLabel: "label",
|
|
32
|
+
Bounds: "bounds",
|
|
33
|
+
"Plane.DiagramElement": "planeElements",
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type CoverageScope = {
|
|
2
|
+
inScope: string[];
|
|
3
|
+
outOfScopeTypes: Record<string, string[]>;
|
|
4
|
+
outOfScopeProperties: Record<string, string[]>;
|
|
5
|
+
outOfScopeReasons?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const IN_SCOPE_TYPES: string[];
|
|
8
|
+
export declare const OUT_OF_SCOPE_TYPES: Record<string, string[]>;
|
|
9
|
+
export declare const OUT_OF_SCOPE_PROPERTIES: Record<string, string[]>;
|
|
10
|
+
export declare const OUT_OF_SCOPE_REASONS: Record<string, string>;
|
|
11
|
+
export declare const REAL_SCOPE: CoverageScope;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export const IN_SCOPE_TYPES = [
|
|
2
|
+
"tBaseElement",
|
|
3
|
+
"tRootElement",
|
|
4
|
+
"tFlowElement",
|
|
5
|
+
"tFlowNode",
|
|
6
|
+
"tProcess",
|
|
7
|
+
"tSubProcess",
|
|
8
|
+
"tAdHocSubProcess",
|
|
9
|
+
"tTransaction",
|
|
10
|
+
"tActivity",
|
|
11
|
+
"tTask",
|
|
12
|
+
"tUserTask",
|
|
13
|
+
"tServiceTask",
|
|
14
|
+
"tScriptTask",
|
|
15
|
+
"tSendTask",
|
|
16
|
+
"tReceiveTask",
|
|
17
|
+
"tManualTask",
|
|
18
|
+
"tBusinessRuleTask",
|
|
19
|
+
"tGateway",
|
|
20
|
+
"tExclusiveGateway",
|
|
21
|
+
"tParallelGateway",
|
|
22
|
+
"tInclusiveGateway",
|
|
23
|
+
"tEventBasedGateway",
|
|
24
|
+
"tComplexGateway",
|
|
25
|
+
"tSequenceFlow",
|
|
26
|
+
"tArtifact",
|
|
27
|
+
"tAssociation",
|
|
28
|
+
"tEvent",
|
|
29
|
+
"tCatchEvent",
|
|
30
|
+
"tThrowEvent",
|
|
31
|
+
"tStartEvent",
|
|
32
|
+
"tEndEvent",
|
|
33
|
+
"tIntermediateCatchEvent",
|
|
34
|
+
"tIntermediateThrowEvent",
|
|
35
|
+
"tBoundaryEvent",
|
|
36
|
+
"tImplicitThrowEvent",
|
|
37
|
+
"tEventDefinition",
|
|
38
|
+
"tMessageEventDefinition",
|
|
39
|
+
"tTimerEventDefinition",
|
|
40
|
+
"tErrorEventDefinition",
|
|
41
|
+
"tSignalEventDefinition",
|
|
42
|
+
"tEscalationEventDefinition",
|
|
43
|
+
"tConditionalEventDefinition",
|
|
44
|
+
"tLinkEventDefinition",
|
|
45
|
+
"tCompensateEventDefinition",
|
|
46
|
+
"tCancelEventDefinition",
|
|
47
|
+
"tTerminateEventDefinition",
|
|
48
|
+
"tMessage",
|
|
49
|
+
"tSignal",
|
|
50
|
+
"tError",
|
|
51
|
+
"tEscalation",
|
|
52
|
+
"tExpression",
|
|
53
|
+
"tFormalExpression",
|
|
54
|
+
"tLaneSet",
|
|
55
|
+
"tLane",
|
|
56
|
+
"tCollaboration",
|
|
57
|
+
"tParticipant",
|
|
58
|
+
"tMessageFlow",
|
|
59
|
+
"tAssignment",
|
|
60
|
+
"tDataAssociation",
|
|
61
|
+
"tDataInput",
|
|
62
|
+
"tDataInputAssociation",
|
|
63
|
+
"tDataObject",
|
|
64
|
+
"tDataObjectReference",
|
|
65
|
+
"tDataOutput",
|
|
66
|
+
"tDataOutputAssociation",
|
|
67
|
+
"tDataStore",
|
|
68
|
+
"tDataStoreReference",
|
|
69
|
+
"tInputOutputSpecification",
|
|
70
|
+
"tInputSet",
|
|
71
|
+
"tOutputSet",
|
|
72
|
+
"BPMNDiagram",
|
|
73
|
+
"BPMNPlane",
|
|
74
|
+
"BPMNShape",
|
|
75
|
+
"BPMNEdge",
|
|
76
|
+
"BPMNLabel",
|
|
77
|
+
"Bounds",
|
|
78
|
+
"Point",
|
|
79
|
+
"DiagramElement",
|
|
80
|
+
"Diagram",
|
|
81
|
+
"Node",
|
|
82
|
+
"Edge",
|
|
83
|
+
"LabeledEdge",
|
|
84
|
+
"Shape",
|
|
85
|
+
"LabeledShape",
|
|
86
|
+
"Label",
|
|
87
|
+
"Plane",
|
|
88
|
+
];
|
|
89
|
+
export const OUT_OF_SCOPE_TYPES = {
|
|
90
|
+
data: [
|
|
91
|
+
"tDataState",
|
|
92
|
+
"tInputOutputBinding",
|
|
93
|
+
"tItemDefinition",
|
|
94
|
+
"tProperty",
|
|
95
|
+
],
|
|
96
|
+
artifacts: ["tGroup", "tTextAnnotation", "tText"],
|
|
97
|
+
choreography: [
|
|
98
|
+
"tCallChoreography",
|
|
99
|
+
"tChoreography",
|
|
100
|
+
"tChoreographyActivity",
|
|
101
|
+
"tChoreographyTask",
|
|
102
|
+
"tGlobalChoreographyTask",
|
|
103
|
+
"tSubChoreography",
|
|
104
|
+
],
|
|
105
|
+
conversation: [
|
|
106
|
+
"tCallConversation",
|
|
107
|
+
"tConversation",
|
|
108
|
+
"tConversationAssociation",
|
|
109
|
+
"tConversationLink",
|
|
110
|
+
"tConversationNode",
|
|
111
|
+
"tGlobalConversation",
|
|
112
|
+
"tSubConversation",
|
|
113
|
+
"tMessageFlowAssociation",
|
|
114
|
+
"tParticipantAssociation",
|
|
115
|
+
"tParticipantMultiplicity",
|
|
116
|
+
],
|
|
117
|
+
correlation: [
|
|
118
|
+
"tCorrelationKey",
|
|
119
|
+
"tCorrelationProperty",
|
|
120
|
+
"tCorrelationPropertyBinding",
|
|
121
|
+
"tCorrelationPropertyRetrievalExpression",
|
|
122
|
+
"tCorrelationSubscription",
|
|
123
|
+
],
|
|
124
|
+
services: ["tEndPoint", "tInterface", "tOperation", "tPartnerEntity", "tPartnerRole"],
|
|
125
|
+
resources: [
|
|
126
|
+
"tHumanPerformer",
|
|
127
|
+
"tPerformer",
|
|
128
|
+
"tPotentialOwner",
|
|
129
|
+
"tResource",
|
|
130
|
+
"tResourceAssignmentExpression",
|
|
131
|
+
"tResourceParameter",
|
|
132
|
+
"tResourceParameterBinding",
|
|
133
|
+
"tResourceRole",
|
|
134
|
+
],
|
|
135
|
+
callable: [
|
|
136
|
+
"tCallableElement",
|
|
137
|
+
"tCallActivity",
|
|
138
|
+
"tGlobalBusinessRuleTask",
|
|
139
|
+
"tGlobalManualTask",
|
|
140
|
+
"tGlobalScriptTask",
|
|
141
|
+
"tGlobalTask",
|
|
142
|
+
"tGlobalUserTask",
|
|
143
|
+
],
|
|
144
|
+
loops: ["tComplexBehaviorDefinition", "tLoopCharacteristics", "tMultiInstanceLoopCharacteristics", "tStandardLoopCharacteristics"],
|
|
145
|
+
"categories-and-monitoring": ["tAuditing", "tCategory", "tCategoryValue", "tMonitoring", "tRelationship"],
|
|
146
|
+
"documentation-and-extensions": [
|
|
147
|
+
"tBaseElementWithMixedContent",
|
|
148
|
+
"tDocumentation",
|
|
149
|
+
"tExtension",
|
|
150
|
+
"tExtensionElements",
|
|
151
|
+
"tRendering",
|
|
152
|
+
"tScript",
|
|
153
|
+
],
|
|
154
|
+
"di-styling": ["BPMNLabelStyle", "Font", "Style"],
|
|
155
|
+
};
|
|
156
|
+
export const OUT_OF_SCOPE_PROPERTIES = {
|
|
157
|
+
data: ["property", "ioBinding", "dataState", "itemSubjectRef"],
|
|
158
|
+
artifacts: ["artifact"],
|
|
159
|
+
choreography: ["choreographyRef", "definitionalCollaborationRef"],
|
|
160
|
+
conversation: [
|
|
161
|
+
"conversationNode",
|
|
162
|
+
"conversationAssociation",
|
|
163
|
+
"conversationLink",
|
|
164
|
+
"participantAssociation",
|
|
165
|
+
"messageFlowAssociation",
|
|
166
|
+
"participantMultiplicity",
|
|
167
|
+
"choreographyActivityShape",
|
|
168
|
+
"participantBandKind",
|
|
169
|
+
],
|
|
170
|
+
correlation: ["correlationKey", "correlationSubscription"],
|
|
171
|
+
services: ["supportedInterfaceRef", "interfaceRef", "endPointRef"],
|
|
172
|
+
resources: ["resourceRole"],
|
|
173
|
+
loops: ["loopCharacteristics"],
|
|
174
|
+
"categories-and-monitoring": ["auditing", "monitoring", "categoryValueRef", "supports"],
|
|
175
|
+
"documentation-and-extensions": ["documentation", "extensionElements", "extension", "rendering"],
|
|
176
|
+
"di-styling": ["BPMNLabelStyle", "labelStyle"],
|
|
177
|
+
derived: ["incoming", "outgoing"],
|
|
178
|
+
};
|
|
179
|
+
export const OUT_OF_SCOPE_REASONS = {
|
|
180
|
+
derived: "FlowNode.incoming and FlowNode.outgoing are derived from the sequence flows; storing them would duplicate the graph. The exporter computes them from the sequence flows.",
|
|
181
|
+
};
|
|
182
|
+
export const REAL_SCOPE = {
|
|
183
|
+
inScope: IN_SCOPE_TYPES,
|
|
184
|
+
outOfScopeTypes: OUT_OF_SCOPE_TYPES,
|
|
185
|
+
outOfScopeProperties: OUT_OF_SCOPE_PROPERTIES,
|
|
186
|
+
outOfScopeReasons: OUT_OF_SCOPE_REASONS,
|
|
187
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type XsdMember = {
|
|
2
|
+
name: string;
|
|
3
|
+
kind: "attribute" | "element";
|
|
4
|
+
};
|
|
5
|
+
export type XsdType = {
|
|
6
|
+
file: string;
|
|
7
|
+
name: string;
|
|
8
|
+
base: string | null;
|
|
9
|
+
abstract: boolean;
|
|
10
|
+
members: XsdMember[];
|
|
11
|
+
};
|
|
12
|
+
export declare const parseXsd: (file: string, xml: string) => XsdType[];
|
|
13
|
+
export declare const XSD_FILES: string[];
|
|
14
|
+
export declare const XSD_DIR = "reference/bpmn-xsd";
|
|
15
|
+
export declare const loadXsdTypes: (root: string) => XsdType[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { XMLParser } from "fast-xml-parser";
|
|
4
|
+
const parser = new XMLParser({
|
|
5
|
+
ignoreAttributes: false,
|
|
6
|
+
attributeNamePrefix: "@_",
|
|
7
|
+
removeNSPrefix: true,
|
|
8
|
+
isArray: (name) => ["complexType", "element", "attribute", "sequence", "choice", "all", "complexContent", "extension"].includes(name),
|
|
9
|
+
});
|
|
10
|
+
const asList = (value) => (Array.isArray(value) ? value : value ? [value] : []);
|
|
11
|
+
const localName = (qname) => qname.replace(/^.*:/, "");
|
|
12
|
+
const collectMembers = (node, members) => {
|
|
13
|
+
for (const attribute of asList(node.attribute)) {
|
|
14
|
+
const name = (attribute["@_name"] ?? attribute["@_ref"]);
|
|
15
|
+
if (name)
|
|
16
|
+
members.push({ name: localName(name), kind: "attribute" });
|
|
17
|
+
}
|
|
18
|
+
for (const element of asList(node.element)) {
|
|
19
|
+
const name = (element["@_name"] ?? element["@_ref"]);
|
|
20
|
+
if (name)
|
|
21
|
+
members.push({ name: localName(name), kind: "element" });
|
|
22
|
+
}
|
|
23
|
+
for (const group of ["sequence", "choice", "all", "complexContent", "extension"]) {
|
|
24
|
+
for (const child of asList(node[group]))
|
|
25
|
+
collectMembers(child, members);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const baseOf = (node) => {
|
|
29
|
+
for (const content of asList(node.complexContent)) {
|
|
30
|
+
for (const extension of asList(content.extension)) {
|
|
31
|
+
const base = extension["@_base"];
|
|
32
|
+
if (base)
|
|
33
|
+
return localName(base);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
export const parseXsd = (file, xml) => {
|
|
39
|
+
const schema = parser.parse(xml).schema;
|
|
40
|
+
return asList(schema.complexType).map((type) => {
|
|
41
|
+
const members = [];
|
|
42
|
+
collectMembers(type, members);
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
return {
|
|
45
|
+
file,
|
|
46
|
+
name: type["@_name"],
|
|
47
|
+
base: baseOf(type),
|
|
48
|
+
abstract: type["@_abstract"] === "true",
|
|
49
|
+
members: members.filter((m) => !seen.has(`${m.kind}:${m.name}`) && seen.add(`${m.kind}:${m.name}`)),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export const XSD_FILES = ["Semantic.xsd", "BPMNDI.xsd", "DC.xsd", "DI.xsd"];
|
|
54
|
+
export const XSD_DIR = "reference/bpmn-xsd";
|
|
55
|
+
export const loadXsdTypes = (root) => XSD_FILES.flatMap((file) => parseXsd(file, readFileSync(join(root, XSD_DIR, file), "utf8")));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Store } from "n3";
|
|
2
|
+
import type { XsdType } from "./coverage-xsd.ts";
|
|
3
|
+
import type { CoverageScope } from "./coverage-scope.ts";
|
|
4
|
+
export type Status = "covered" | "gap" | "out-of-scope";
|
|
5
|
+
export type CoverageItem = {
|
|
6
|
+
id: string;
|
|
7
|
+
kind: "class" | "property";
|
|
8
|
+
xsd: string;
|
|
9
|
+
ontology: string | null;
|
|
10
|
+
status: Status;
|
|
11
|
+
group?: string;
|
|
12
|
+
reason?: string;
|
|
13
|
+
};
|
|
14
|
+
export type Counts = Record<Status, number>;
|
|
15
|
+
export type CoverageReport = {
|
|
16
|
+
summary: {
|
|
17
|
+
classes: Counts;
|
|
18
|
+
properties: Counts;
|
|
19
|
+
total: Counts;
|
|
20
|
+
};
|
|
21
|
+
unclassified: string[];
|
|
22
|
+
items: CoverageItem[];
|
|
23
|
+
};
|
|
24
|
+
export declare const checkCoverage: (store: Store, types: XsdType[], scope: CoverageScope) => CoverageReport;
|
|
25
|
+
export declare const renderMarkdown: (report: CoverageReport) => string;
|
|
26
|
+
export declare const renderJson: (report: CoverageReport) => string;
|
|
27
|
+
export declare const generateReports: (root: string) => {
|
|
28
|
+
report: CoverageReport;
|
|
29
|
+
markdown: string;
|
|
30
|
+
json: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const REPORT_MARKDOWN = "reports/coverage.md";
|
|
33
|
+
export declare const REPORT_JSON = "reports/coverage.json";
|
|
34
|
+
export declare const writeReports: (root: string) => CoverageReport;
|
|
35
|
+
export declare const readReport: (root: string, file: string) => string;
|