@bpmn-ld/bpmn-ld 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +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 +2 -0
- package/dist/bpmn-ld-cli.js +97 -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/cheat-sheet-catalog.d.ts +10 -0
- package/dist/cheat-sheet-catalog.js +72 -0
- package/dist/cheat-sheet-cli.d.ts +1 -0
- package/dist/cheat-sheet-cli.js +7 -0
- package/dist/cheat-sheet-compose.d.ts +13 -0
- package/dist/cheat-sheet-compose.js +107 -0
- package/dist/cheat-sheet-run.d.ts +11 -0
- package/dist/cheat-sheet-run.js +65 -0
- package/dist/cheat-sheet-svg.d.ts +2 -0
- package/dist/cheat-sheet-svg.js +2 -0
- package/dist/cheat-sheet.d.ts +2 -0
- package/dist/cheat-sheet.js +2 -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 +77 -4
- package/reference/bpmn-xsd/BPMN20.xsd +37 -0
- package/reference/bpmn-xsd/BPMNDI.xsd +100 -0
- package/reference/bpmn-xsd/DC.xsd +29 -0
- package/reference/bpmn-xsd/DI.xsd +100 -0
- package/reference/bpmn-xsd/Semantic.xsd +1562 -0
- package/reference/rospocher/ATTRIBUTION.md +22 -0
- package/reference/rospocher/BPMNOntology.owl +8937 -0
- package/reference/rospocher-verified.json +221 -0
- 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,19 @@
|
|
|
1
|
+
export interface Check {
|
|
2
|
+
name: string;
|
|
3
|
+
run: (file: string) => Promise<string[]>;
|
|
4
|
+
}
|
|
5
|
+
export interface Failure {
|
|
6
|
+
check: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface FileResult {
|
|
10
|
+
file: string;
|
|
11
|
+
failures: Failure[];
|
|
12
|
+
}
|
|
13
|
+
export declare const CHECKS: Check[];
|
|
14
|
+
export declare const EXPLANATION_CHECKS: Check[];
|
|
15
|
+
export declare const MODIFICATION_CHECKS: Check[];
|
|
16
|
+
export declare const evaluateFile: (file: string, checks?: Check[]) => Promise<FileResult>;
|
|
17
|
+
export declare const evaluateOutputs: (dir: string, checks?: Check[]) => Promise<FileResult[]>;
|
|
18
|
+
export declare const evaluateExplanations: (dir: string, checks?: Check[]) => Promise<FileResult[]>;
|
|
19
|
+
export declare const evaluateModifications: (dir: string, checks?: Check[]) => Promise<FileResult[]>;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { convert } from "../convert/convert.js";
|
|
5
|
+
import { analyze } from "../analyze/analyze.js";
|
|
6
|
+
import { checkXml } from "../check-xml/check.js";
|
|
7
|
+
import { layoutAndExport } from "../export/layout-export.js";
|
|
8
|
+
import { ExportInputError } from "../export/export.js";
|
|
9
|
+
import { layoutDocument, LayoutInputError } from "../layout/layout.js";
|
|
10
|
+
import { compileSchema, validateWithSchema } from "../schema-validate.js";
|
|
11
|
+
import { validateShacl } from "../shacl.js";
|
|
12
|
+
import { validateExample } from "../validate.js";
|
|
13
|
+
const WARNING_PREFIX = "warning ";
|
|
14
|
+
const severityPrefix = (severity) => (severity === "error" ? "" : WARNING_PREFIX);
|
|
15
|
+
const validateSchema = compileSchema();
|
|
16
|
+
const structural = {
|
|
17
|
+
name: "structural",
|
|
18
|
+
run: async (file) => (await validateExample(file)).errors,
|
|
19
|
+
};
|
|
20
|
+
const schema = {
|
|
21
|
+
name: "schema",
|
|
22
|
+
run: async (file) => validateWithSchema(JSON.parse(readFileSync(file, "utf8")), validateSchema),
|
|
23
|
+
};
|
|
24
|
+
const shacl = {
|
|
25
|
+
name: "shacl",
|
|
26
|
+
run: async (file) => {
|
|
27
|
+
const result = await validateShacl(file);
|
|
28
|
+
const messages = result.violations.map((v) => `${v.focusNode} violates ${v.sourceShape}`);
|
|
29
|
+
if (!result.conforms && messages.length === 0)
|
|
30
|
+
messages.push("SHACL validation failed");
|
|
31
|
+
return messages;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const analyzer = {
|
|
35
|
+
name: "analyzer",
|
|
36
|
+
run: async (file) => {
|
|
37
|
+
const findings = await analyze(JSON.parse(readFileSync(file, "utf8")), pathToFileURL(resolve(file)).href);
|
|
38
|
+
return findings.map((f) => `${severityPrefix(f.severity)}${f.rule} ${f.node ?? "-"}: ${f.message}`);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const layout = {
|
|
42
|
+
name: "layout",
|
|
43
|
+
run: async (file) => {
|
|
44
|
+
try {
|
|
45
|
+
layoutDocument(JSON.parse(readFileSync(file, "utf8")));
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error instanceof LayoutInputError)
|
|
50
|
+
return error.errors;
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const exportXml = async (file) => (await layoutAndExport(JSON.parse(readFileSync(file, "utf8")), { documentUrl: pathToFileURL(resolve(file)).href })).xml;
|
|
56
|
+
const exported = {
|
|
57
|
+
name: "export",
|
|
58
|
+
run: async (file) => {
|
|
59
|
+
try {
|
|
60
|
+
await exportXml(file);
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error instanceof ExportInputError)
|
|
65
|
+
return error.errors;
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const reports = new Map();
|
|
71
|
+
const externalReport = (file) => {
|
|
72
|
+
const key = `${resolve(file)}\n${readFileSync(file, "utf8")}`;
|
|
73
|
+
let report = reports.get(key);
|
|
74
|
+
if (!report) {
|
|
75
|
+
report = exportXml(file).then(checkXml);
|
|
76
|
+
reports.set(key, report);
|
|
77
|
+
}
|
|
78
|
+
return report;
|
|
79
|
+
};
|
|
80
|
+
const external = (name) => ({
|
|
81
|
+
name,
|
|
82
|
+
run: async (file) => {
|
|
83
|
+
const result = (await externalReport(file)).checks[name];
|
|
84
|
+
return result.issues.map((issue) => `${severityPrefix(issue.severity)}${issue.rule ? `${issue.rule}: ` : ""}${issue.message}`);
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
export const CHECKS = [structural, schema, shacl, analyzer, layout, exported, external("xsd"), external("moddle"), external("lint")];
|
|
88
|
+
const MODEL_LINE = /^Model:\s*(\S+)\s*$/m;
|
|
89
|
+
const collectNames = (value, names) => {
|
|
90
|
+
if (Array.isArray(value))
|
|
91
|
+
value.forEach((item) => collectNames(item, names));
|
|
92
|
+
else if (value && typeof value === "object")
|
|
93
|
+
for (const [key, child] of Object.entries(value)) {
|
|
94
|
+
if (key === "name" && typeof child === "string")
|
|
95
|
+
names.add(child);
|
|
96
|
+
else
|
|
97
|
+
collectNames(child, names);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const modelNames = (modelFile) => {
|
|
101
|
+
const text = readFileSync(modelFile, "utf8");
|
|
102
|
+
const document = extname(modelFile) === ".bpmn" ? convert(text, { fileName: modelFile }).document : JSON.parse(text);
|
|
103
|
+
const names = new Set();
|
|
104
|
+
collectNames(document, names);
|
|
105
|
+
return [...names];
|
|
106
|
+
};
|
|
107
|
+
const normalize = (text) => text.replace(/\s+/g, " ").toLowerCase();
|
|
108
|
+
const mentionsElements = {
|
|
109
|
+
name: "mentions-elements",
|
|
110
|
+
run: async (file) => {
|
|
111
|
+
const evalsDir = dirname(dirname(file));
|
|
112
|
+
const prompt = readFileSync(join(evalsDir, "prompts", `${basename(file, ".md")}.md`), "utf8");
|
|
113
|
+
const model = prompt.match(MODEL_LINE)?.[1];
|
|
114
|
+
if (!model)
|
|
115
|
+
return ["prompt has no Model line"];
|
|
116
|
+
const explanation = normalize(readFileSync(file, "utf8"));
|
|
117
|
+
return modelNames(resolve(dirname(evalsDir), model))
|
|
118
|
+
.filter((name) => !explanation.includes(normalize(name)))
|
|
119
|
+
.map((name) => `does not mention "${name}"`);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
export const EXPLANATION_CHECKS = [mentionsElements];
|
|
123
|
+
const ALLOWED_LINE = /^Allowed-changes:[ \t]*(.*)$/m;
|
|
124
|
+
const DI_TYPES = new Set(["BPMNDiagram", "BPMNPlane", "BPMNShape", "BPMNEdge", "BPMNLabel", "Bounds", "Point"]);
|
|
125
|
+
const loadDocument = (modelFile) => {
|
|
126
|
+
const text = readFileSync(modelFile, "utf8");
|
|
127
|
+
return extname(modelFile) === ".bpmn" ? convert(text, { fileName: modelFile }).document : JSON.parse(text);
|
|
128
|
+
};
|
|
129
|
+
const isNode = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
130
|
+
const isDi = (node) => DI_TYPES.has(String(node.type));
|
|
131
|
+
const indexNodes = (value, elements, di) => {
|
|
132
|
+
if (Array.isArray(value))
|
|
133
|
+
value.forEach((item) => indexNodes(item, elements, di));
|
|
134
|
+
else if (isNode(value)) {
|
|
135
|
+
if (typeof value.id === "string")
|
|
136
|
+
(isDi(value) ? di : elements).set(value.id, value);
|
|
137
|
+
for (const [key, child] of Object.entries(value))
|
|
138
|
+
if (key !== "@context")
|
|
139
|
+
indexNodes(child, elements, di);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const ownProperties = (node) => {
|
|
143
|
+
const strip = (value) => {
|
|
144
|
+
if (Array.isArray(value))
|
|
145
|
+
return value.map(strip).filter((item) => item !== undefined);
|
|
146
|
+
if (isNode(value))
|
|
147
|
+
return typeof value.id === "string" ? undefined : Object.fromEntries(Object.entries(value).map(([k, v]) => [k, strip(v)]));
|
|
148
|
+
return value;
|
|
149
|
+
};
|
|
150
|
+
return JSON.stringify(Object.fromEntries(Object.entries(node).filter(([key]) => key !== "id").map(([key, value]) => [key, strip(value)]).sort(([a], [b]) => a.localeCompare(b))));
|
|
151
|
+
};
|
|
152
|
+
const modificationContext = (file) => {
|
|
153
|
+
const evalsDir = dirname(dirname(file));
|
|
154
|
+
const prompt = readFileSync(join(evalsDir, "prompts", `${basename(file, ".jsonld")}.md`), "utf8");
|
|
155
|
+
const model = prompt.match(MODEL_LINE)?.[1];
|
|
156
|
+
if (!model)
|
|
157
|
+
throw new Error("prompt has no Model line");
|
|
158
|
+
const allowedText = prompt.match(ALLOWED_LINE)?.[1];
|
|
159
|
+
if (allowedText === undefined)
|
|
160
|
+
throw new Error("prompt has no Allowed-changes line");
|
|
161
|
+
const allowed = new Set(allowedText.split(",").map((id) => id.trim()).filter(Boolean));
|
|
162
|
+
const before = { elements: new Map(), di: new Map() };
|
|
163
|
+
const after = { elements: new Map(), di: new Map() };
|
|
164
|
+
indexNodes(loadDocument(resolve(dirname(evalsDir), model)), before.elements, before.di);
|
|
165
|
+
indexNodes(JSON.parse(readFileSync(file, "utf8")), after.elements, after.di);
|
|
166
|
+
return { allowed, before, after };
|
|
167
|
+
};
|
|
168
|
+
const unchangedElements = {
|
|
169
|
+
name: "unchanged-elements",
|
|
170
|
+
run: async (file) => {
|
|
171
|
+
const { allowed, before, after } = modificationContext(file);
|
|
172
|
+
const failures = [];
|
|
173
|
+
for (const [id, node] of before.elements) {
|
|
174
|
+
if (allowed.has(id))
|
|
175
|
+
continue;
|
|
176
|
+
const next = after.elements.get(id);
|
|
177
|
+
if (!next)
|
|
178
|
+
failures.push(`element "${id}" was removed`);
|
|
179
|
+
else if (ownProperties(node) !== ownProperties(next))
|
|
180
|
+
failures.push(`element "${id}" changed`);
|
|
181
|
+
}
|
|
182
|
+
for (const id of after.elements.keys())
|
|
183
|
+
if (!before.elements.has(id) && !allowed.has(id))
|
|
184
|
+
failures.push(`element "${id}" was added`);
|
|
185
|
+
return failures;
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
const unchangedDi = {
|
|
189
|
+
name: "unchanged-di",
|
|
190
|
+
run: async (file) => {
|
|
191
|
+
const { allowed, before, after } = modificationContext(file);
|
|
192
|
+
const failures = [];
|
|
193
|
+
for (const [id, node] of before.di) {
|
|
194
|
+
if (node.type !== "BPMNShape" && node.type !== "BPMNEdge")
|
|
195
|
+
continue;
|
|
196
|
+
const next = after.di.get(id);
|
|
197
|
+
const element = String(node.bpmnElement);
|
|
198
|
+
if (!next) {
|
|
199
|
+
if (!allowed.has(element))
|
|
200
|
+
failures.push(`diagram element "${id}" was removed`);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const key = node.type === "BPMNShape" ? "bounds" : "waypoints";
|
|
204
|
+
if (JSON.stringify(node[key]) !== JSON.stringify(next[key]))
|
|
205
|
+
failures.push(`diagram element "${id}" changed its ${key}`);
|
|
206
|
+
}
|
|
207
|
+
return failures;
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
export const MODIFICATION_CHECKS = [unchangedElements, unchangedDi];
|
|
211
|
+
const loadExpected = (file) => {
|
|
212
|
+
const expectFile = join(dirname(file), `${basename(file, extname(file))}.expect.json`);
|
|
213
|
+
return existsSync(expectFile) ? JSON.parse(readFileSync(expectFile, "utf8")) : {};
|
|
214
|
+
};
|
|
215
|
+
export const evaluateFile = async (file, checks = CHECKS) => {
|
|
216
|
+
const failures = [];
|
|
217
|
+
const expected = loadExpected(file);
|
|
218
|
+
for (const [name, messages] of Object.entries(expected))
|
|
219
|
+
for (const message of messages)
|
|
220
|
+
if (!message.startsWith(WARNING_PREFIX))
|
|
221
|
+
failures.push({ check: name, message: `error findings cannot be recorded as expected: ${message}` });
|
|
222
|
+
for (const check of checks) {
|
|
223
|
+
try {
|
|
224
|
+
const remaining = [...(expected[check.name] ?? [])];
|
|
225
|
+
for (const message of await check.run(file)) {
|
|
226
|
+
const index = remaining.indexOf(message);
|
|
227
|
+
if (index >= 0)
|
|
228
|
+
remaining.splice(index, 1);
|
|
229
|
+
else
|
|
230
|
+
failures.push({ check: check.name, message });
|
|
231
|
+
}
|
|
232
|
+
for (const message of remaining)
|
|
233
|
+
failures.push({ check: check.name, message: `expected finding missing: ${message}` });
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
failures.push({ check: check.name, message: error.message });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return { file, failures };
|
|
240
|
+
};
|
|
241
|
+
export const evaluateOutputs = async (dir, checks = CHECKS) => Promise.all(readdirSync(dir)
|
|
242
|
+
.filter((f) => f.endsWith(".jsonld"))
|
|
243
|
+
.sort()
|
|
244
|
+
.map((f) => evaluateFile(join(dir, f), checks)));
|
|
245
|
+
export const evaluateExplanations = async (dir, checks = EXPLANATION_CHECKS) => Promise.all(readdirSync(dir)
|
|
246
|
+
.filter((f) => f.startsWith("explain-") && f.endsWith(".md"))
|
|
247
|
+
.sort()
|
|
248
|
+
.map((f) => evaluateFile(join(dir, f), checks)));
|
|
249
|
+
export const evaluateModifications = async (dir, checks = MODIFICATION_CHECKS) => Promise.all(readdirSync(dir)
|
|
250
|
+
.filter((f) => (f.startsWith("modify-") || f.startsWith("refine-")) && f.endsWith(".jsonld"))
|
|
251
|
+
.sort()
|
|
252
|
+
.map((f) => evaluateFile(join(dir, f), checks)));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const EXPLAIN_PREFIX = "explain-";
|
|
2
|
+
export declare const outputExtension: (name: string) => string;
|
|
3
|
+
export type Generator = (prompt: string) => Promise<string>;
|
|
4
|
+
export interface RegenerationEntry {
|
|
5
|
+
name: string;
|
|
6
|
+
status: "unchanged" | "changed" | "new";
|
|
7
|
+
diff: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const lineDiff: (before: string, after: string) => string;
|
|
10
|
+
export declare const regenerate: (dir: string, generate: Generator) => Promise<RegenerationEntry[]>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
export const EXPLAIN_PREFIX = "explain-";
|
|
4
|
+
export const outputExtension = (name) => (name.startsWith(EXPLAIN_PREFIX) ? ".md" : ".jsonld");
|
|
5
|
+
export const lineDiff = (before, after) => {
|
|
6
|
+
const a = before.split("\n");
|
|
7
|
+
const b = after.split("\n");
|
|
8
|
+
const lcs = Array.from({ length: a.length + 1 }, () => new Array(b.length + 1).fill(0));
|
|
9
|
+
for (let i = a.length - 1; i >= 0; i--)
|
|
10
|
+
for (let j = b.length - 1; j >= 0; j--)
|
|
11
|
+
lcs[i][j] = a[i] === b[j] ? lcs[i + 1][j + 1] + 1 : Math.max(lcs[i + 1][j], lcs[i][j + 1]);
|
|
12
|
+
const lines = [];
|
|
13
|
+
let i = 0;
|
|
14
|
+
let j = 0;
|
|
15
|
+
while (i < a.length && j < b.length) {
|
|
16
|
+
if (a[i] === b[j])
|
|
17
|
+
(i++, j++);
|
|
18
|
+
else if (lcs[i + 1][j] >= lcs[i][j + 1])
|
|
19
|
+
lines.push(`-${a[i++]}`);
|
|
20
|
+
else
|
|
21
|
+
lines.push(`+${b[j++]}`);
|
|
22
|
+
}
|
|
23
|
+
while (i < a.length)
|
|
24
|
+
lines.push(`-${a[i++]}`);
|
|
25
|
+
while (j < b.length)
|
|
26
|
+
lines.push(`+${b[j++]}`);
|
|
27
|
+
return lines.join("\n");
|
|
28
|
+
};
|
|
29
|
+
export const regenerate = async (dir, generate) => {
|
|
30
|
+
const outputs = join(dir, "outputs");
|
|
31
|
+
mkdirSync(outputs, { recursive: true });
|
|
32
|
+
const report = [];
|
|
33
|
+
for (const file of readdirSync(join(dir, "prompts")).filter((f) => f.endsWith(".md")).sort()) {
|
|
34
|
+
const name = file.replace(/\.md$/, "");
|
|
35
|
+
const target = join(outputs, `${name}${outputExtension(name)}`);
|
|
36
|
+
const generated = await generate(readFileSync(join(dir, "prompts", file), "utf8"));
|
|
37
|
+
const existed = existsSync(target);
|
|
38
|
+
const previous = existed ? readFileSync(target, "utf8") : "";
|
|
39
|
+
writeFileSync(target, generated);
|
|
40
|
+
if (!existed)
|
|
41
|
+
report.push({ name, status: "new", diff: lineDiff("", generated) });
|
|
42
|
+
else if (previous === generated)
|
|
43
|
+
report.push({ name, status: "unchanged", diff: "" });
|
|
44
|
+
else
|
|
45
|
+
report.push({ name, status: "changed", diff: lineDiff(previous, generated) });
|
|
46
|
+
}
|
|
47
|
+
return report;
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { regenerate } from "./eval/regenerate.js";
|
|
3
|
+
import { ROOT } from "./paths.js";
|
|
4
|
+
const dir = process.argv[2] ?? `${ROOT}skills/bpmn-ld/evals`;
|
|
5
|
+
const command = process.env.BPMN_LD_EVAL_GENERATOR ?? "claude -p";
|
|
6
|
+
const generate = async (prompt) => {
|
|
7
|
+
const run = spawnSync(command, { input: prompt, encoding: "utf8", shell: true, maxBuffer: 64 * 1024 * 1024 });
|
|
8
|
+
if (run.status !== 0)
|
|
9
|
+
throw new Error(`generator "${command}" failed: ${run.stderr}`);
|
|
10
|
+
return run.stdout;
|
|
11
|
+
};
|
|
12
|
+
for (const entry of await regenerate(dir, generate)) {
|
|
13
|
+
console.log(`${entry.status.padEnd(9)}${entry.name}`);
|
|
14
|
+
if (entry.diff)
|
|
15
|
+
console.log(entry.diff);
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ElementMapping } from "../convert/mapping.ts";
|
|
2
|
+
export declare const DATA_MAPPINGS: Record<string, ElementMapping>;
|
|
3
|
+
export declare const EXPRESSION_ELEMENTS: string[];
|
|
4
|
+
export declare const MAPPINGS: Record<string, ElementMapping>;
|
|
5
|
+
export declare const THROW_EVENTS: string[];
|
|
6
|
+
export declare const CATCH_EVENTS: string[];
|
|
7
|
+
export declare const CONTAINS: Record<string, Record<string, string>>;
|
|
8
|
+
export declare const EVENT_DEFINITION_ROOTS: Record<string, string>;
|
|
9
|
+
export declare const DATA_ROOT_ELEMENTS: Record<string, string>;
|
|
10
|
+
export declare const childRank: (key: string) => number;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { CONTAINMENT, ELEMENT_MAPPINGS } from "../convert/mapping.js";
|
|
2
|
+
const named = { id: "id", name: "name" };
|
|
3
|
+
const flowDataElements = ["dataObject", "dataObjectReference", "dataStoreReference"];
|
|
4
|
+
export const DATA_MAPPINGS = {
|
|
5
|
+
dataObject: { type: "DataObject", attributes: { ...named, isCollection: "isCollection" } },
|
|
6
|
+
dataObjectReference: { type: "DataObjectReference", attributes: { ...named, dataObjectRef: "dataObjectRef" } },
|
|
7
|
+
dataStore: {
|
|
8
|
+
type: "DataStore",
|
|
9
|
+
attributes: { ...named, capacity: "capacity", isUnlimited: "isUnlimited" },
|
|
10
|
+
},
|
|
11
|
+
dataStoreReference: { type: "DataStoreReference", attributes: { ...named, dataStoreRef: "dataStoreRef" } },
|
|
12
|
+
};
|
|
13
|
+
const CONTAINER_ACTIVITIES = ["subProcess", "adHocSubProcess", "transaction"];
|
|
14
|
+
const ACTIVITIES = ["task", "businessRuleTask", "manualTask", "receiveTask", "sendTask", "scriptTask", "serviceTask", "userTask", ...CONTAINER_ACTIVITIES];
|
|
15
|
+
const withIoSpecification = Object.fromEntries(ACTIVITIES.map((name) => [
|
|
16
|
+
name,
|
|
17
|
+
{ ...ELEMENT_MAPPINGS[name], singles: { ...ELEMENT_MAPPINGS[name].singles, ioSpecification: "ioSpecification" } },
|
|
18
|
+
]));
|
|
19
|
+
const dataItem = { ...named, isCollection: "isCollection" };
|
|
20
|
+
const SET_MAPPINGS = {
|
|
21
|
+
ioSpecification: { type: "InputOutputSpecification", attributes: { id: "id" } },
|
|
22
|
+
dataInput: { type: "DataInput", attributes: dataItem },
|
|
23
|
+
dataOutput: { type: "DataOutput", attributes: dataItem },
|
|
24
|
+
inputSet: {
|
|
25
|
+
type: "InputSet",
|
|
26
|
+
attributes: { id: "id" },
|
|
27
|
+
textLists: {
|
|
28
|
+
dataInputRefs: "dataInputRefs",
|
|
29
|
+
optionalInputRefs: "optionalInputRefs",
|
|
30
|
+
whileExecutingInputRefs: "whileExecutingInputRefs",
|
|
31
|
+
outputSetRefs: "outputSetRefs",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
outputSet: {
|
|
35
|
+
type: "OutputSet",
|
|
36
|
+
attributes: { id: "id" },
|
|
37
|
+
textLists: {
|
|
38
|
+
dataOutputRefs: "dataOutputRefs",
|
|
39
|
+
optionalOutputRefs: "optionalOutputRefs",
|
|
40
|
+
whileExecutingOutputRefs: "whileExecutingOutputRefs",
|
|
41
|
+
inputSetRefs: "inputSetRefs",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const expression = () => ({
|
|
46
|
+
type: "FormalExpression",
|
|
47
|
+
attributes: { language: "language", evaluatesToTypeRef: "evaluatesToTypeRef" },
|
|
48
|
+
bodyTerm: "body",
|
|
49
|
+
anonymous: true,
|
|
50
|
+
});
|
|
51
|
+
const association = (type) => ({
|
|
52
|
+
type,
|
|
53
|
+
attributes: { id: "id" },
|
|
54
|
+
textLists: { sourceRef: "sourceRef" },
|
|
55
|
+
textChildren: { targetRef: "targetRef" },
|
|
56
|
+
singles: { transformation: "transformation" },
|
|
57
|
+
});
|
|
58
|
+
const ASSOCIATION_MAPPINGS = {
|
|
59
|
+
dataInputAssociation: association("DataInputAssociation"),
|
|
60
|
+
dataOutputAssociation: association("DataOutputAssociation"),
|
|
61
|
+
assignment: { type: "Assignment", attributes: { id: "id" }, singles: { from: "from", to: "to" } },
|
|
62
|
+
transformation: expression(),
|
|
63
|
+
from: expression(),
|
|
64
|
+
to: expression(),
|
|
65
|
+
};
|
|
66
|
+
const CONDITION_ELEMENTS = ["completionCondition", "condition", "activationCondition"];
|
|
67
|
+
export const EXPRESSION_ELEMENTS = ["conditionExpression", ...CONDITION_ELEMENTS, "transformation", "from", "to"];
|
|
68
|
+
export const MAPPINGS = {
|
|
69
|
+
...ELEMENT_MAPPINGS,
|
|
70
|
+
...withIoSpecification,
|
|
71
|
+
...DATA_MAPPINGS,
|
|
72
|
+
...SET_MAPPINGS,
|
|
73
|
+
...ASSOCIATION_MAPPINGS,
|
|
74
|
+
};
|
|
75
|
+
const flowData = Object.fromEntries(flowDataElements.map((name) => [name, "flowElements"]));
|
|
76
|
+
const associations = { dataInputAssociation: "dataInputAssociations", dataOutputAssociation: "dataOutputAssociations" };
|
|
77
|
+
const throwData = { dataInput: "dataInputs", dataInputAssociation: "dataInputAssociations", inputSet: "inputSets" };
|
|
78
|
+
const catchData = { dataOutput: "dataOutputs", dataOutputAssociation: "dataOutputAssociations", outputSet: "outputSets" };
|
|
79
|
+
export const THROW_EVENTS = ["intermediateThrowEvent", "implicitThrowEvent", "endEvent"];
|
|
80
|
+
export const CATCH_EVENTS = ["startEvent", "intermediateCatchEvent", "boundaryEvent"];
|
|
81
|
+
const dataContainment = {
|
|
82
|
+
process: flowData,
|
|
83
|
+
...Object.fromEntries(CONTAINER_ACTIVITIES.map((name) => [name, { ...flowData, ...associations }])),
|
|
84
|
+
...Object.fromEntries(ACTIVITIES.filter((name) => !CONTAINER_ACTIVITIES.includes(name)).map((name) => [name, associations])),
|
|
85
|
+
...Object.fromEntries(THROW_EVENTS.map((name) => [name, throwData])),
|
|
86
|
+
...Object.fromEntries(CATCH_EVENTS.map((name) => [name, catchData])),
|
|
87
|
+
assignment: {},
|
|
88
|
+
dataInputAssociation: { assignment: "assignments" },
|
|
89
|
+
dataOutputAssociation: { assignment: "assignments" },
|
|
90
|
+
ioSpecification: { dataInput: "dataInputs", dataOutput: "dataOutputs", inputSet: "inputSets", outputSet: "outputSets" },
|
|
91
|
+
};
|
|
92
|
+
export const CONTAINS = Object.fromEntries([...new Set([...Object.keys(CONTAINMENT), ...Object.keys(dataContainment)])].map((name) => [
|
|
93
|
+
name,
|
|
94
|
+
{ ...CONTAINMENT[name], ...dataContainment[name] },
|
|
95
|
+
]));
|
|
96
|
+
export const EVENT_DEFINITION_ROOTS = Object.fromEntries(Object.keys(CONTAINMENT.startEvent).map((name) => [ELEMENT_MAPPINGS[name].type, name]));
|
|
97
|
+
export const DATA_ROOT_ELEMENTS = { DataStore: "dataStore" };
|
|
98
|
+
const DATA_CHILD_ORDER = [
|
|
99
|
+
"incoming",
|
|
100
|
+
"outgoing",
|
|
101
|
+
"ioSpecification",
|
|
102
|
+
"dataInput",
|
|
103
|
+
"dataOutput",
|
|
104
|
+
"dataInputAssociation",
|
|
105
|
+
"dataOutputAssociation",
|
|
106
|
+
"inputSet",
|
|
107
|
+
"outputSet",
|
|
108
|
+
"partitionElement",
|
|
109
|
+
"source",
|
|
110
|
+
"target",
|
|
111
|
+
"sourceRef",
|
|
112
|
+
"targetRef",
|
|
113
|
+
"transformation",
|
|
114
|
+
"assignment",
|
|
115
|
+
];
|
|
116
|
+
export const childRank = (key) => {
|
|
117
|
+
if (key.startsWith("@_"))
|
|
118
|
+
return -1;
|
|
119
|
+
if (key === "extensionElements")
|
|
120
|
+
return -0.5;
|
|
121
|
+
if (key === "eventDefinitionRef")
|
|
122
|
+
return DATA_CHILD_ORDER.length + 0.5;
|
|
123
|
+
if (CONDITION_ELEMENTS.includes(key))
|
|
124
|
+
return DATA_CHILD_ORDER.length + 1;
|
|
125
|
+
const index = DATA_CHILD_ORDER.indexOf(key);
|
|
126
|
+
return index === -1 ? DATA_CHILD_ORDER.length : index;
|
|
127
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Extensions } from "./extensions.ts";
|
|
2
|
+
import { type ExportWarning, type Json, type XmlNode } from "./element.ts";
|
|
3
|
+
export declare const DIAGRAM_NAMESPACES: Record<string, string>;
|
|
4
|
+
export declare const DIAGRAM_EXPORT: Record<string, {
|
|
5
|
+
attributes: string[];
|
|
6
|
+
children: string[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare const exportDiagram: (node: Json, location: string, warnings: ExportWarning[], extensions: Extensions) => XmlNode;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { DC_NAMESPACE, DD_NAMESPACE, DI_NAMESPACE } from "../convert/mapping.js";
|
|
2
|
+
import { isObject, unsupported } from "./element.js";
|
|
3
|
+
export const DIAGRAM_NAMESPACES = {
|
|
4
|
+
"@_xmlns:bpmndi": DI_NAMESPACE,
|
|
5
|
+
"@_xmlns:dc": DC_NAMESPACE,
|
|
6
|
+
"@_xmlns:di": DD_NAMESPACE,
|
|
7
|
+
};
|
|
8
|
+
export const DIAGRAM_EXPORT = {
|
|
9
|
+
BPMNDiagram: { attributes: ["id", "name", "resolution"], children: ["plane"] },
|
|
10
|
+
BPMNPlane: { attributes: ["id", "bpmnElement"], children: ["planeElements"] },
|
|
11
|
+
BPMNShape: {
|
|
12
|
+
attributes: ["id", "bpmnElement", "isExpanded", "isHorizontal", "isMarkerVisible", "isMessageVisible"],
|
|
13
|
+
children: ["bounds", "label"],
|
|
14
|
+
},
|
|
15
|
+
BPMNEdge: { attributes: ["id", "bpmnElement", "sourceElement", "targetElement", "messageVisibleKind"], children: ["waypoints", "label"] },
|
|
16
|
+
BPMNLabel: { attributes: [], children: ["bounds"] },
|
|
17
|
+
Bounds: { attributes: ["x", "y", "width", "height"], children: [] },
|
|
18
|
+
waypoint: { attributes: ["x", "y"], children: [] },
|
|
19
|
+
};
|
|
20
|
+
const text = (value) => String(value);
|
|
21
|
+
const attributes = (node, names, handled) => {
|
|
22
|
+
const result = {};
|
|
23
|
+
for (const name of names) {
|
|
24
|
+
handled.add(name);
|
|
25
|
+
if (node[name] !== undefined)
|
|
26
|
+
result[`@_${name}`] = text(node[name]);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
const report = (node, handled, element, location, warnings, extensions, foreign = true) => {
|
|
31
|
+
for (const key of Object.keys(node).sort()) {
|
|
32
|
+
if (!handled.has(key) && !(foreign && extensions.attribute(key, node[key], element)))
|
|
33
|
+
warnings.push(unsupported("unsupported-property", key, `${location}/${key}`, node));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const base = () => new Set(["type"]);
|
|
37
|
+
const exportBounds = (node, location, warnings, extensions) => {
|
|
38
|
+
const handled = base();
|
|
39
|
+
const element = attributes(node, DIAGRAM_EXPORT.Bounds.attributes, handled);
|
|
40
|
+
report(node, handled, element, location, warnings, extensions, false);
|
|
41
|
+
return element;
|
|
42
|
+
};
|
|
43
|
+
const exportLabel = (node, location, warnings, extensions) => {
|
|
44
|
+
const handled = base();
|
|
45
|
+
const element = {};
|
|
46
|
+
handled.add("bounds");
|
|
47
|
+
if (isObject(node.bounds))
|
|
48
|
+
element["dc:Bounds"] = exportBounds(node.bounds, `${location}/bounds`, warnings, extensions);
|
|
49
|
+
report(node, handled, element, location, warnings, extensions);
|
|
50
|
+
return element;
|
|
51
|
+
};
|
|
52
|
+
const exportPoint = (node, location, warnings, extensions) => {
|
|
53
|
+
const handled = base();
|
|
54
|
+
const element = attributes(node, DIAGRAM_EXPORT.waypoint.attributes, handled);
|
|
55
|
+
report(node, handled, element, location, warnings, extensions, false);
|
|
56
|
+
return element;
|
|
57
|
+
};
|
|
58
|
+
const exportShape = (node, location, warnings, extensions) => {
|
|
59
|
+
const handled = base();
|
|
60
|
+
handled.add("id");
|
|
61
|
+
const element = attributes(node, DIAGRAM_EXPORT.BPMNShape.attributes, handled);
|
|
62
|
+
handled.add("bounds");
|
|
63
|
+
handled.add("label");
|
|
64
|
+
if (isObject(node.bounds))
|
|
65
|
+
element["dc:Bounds"] = exportBounds(node.bounds, `${location}/bounds`, warnings, extensions);
|
|
66
|
+
if (isObject(node.label))
|
|
67
|
+
element["bpmndi:BPMNLabel"] = exportLabel(node.label, `${location}/label`, warnings, extensions);
|
|
68
|
+
report(node, handled, element, location, warnings, extensions);
|
|
69
|
+
return element;
|
|
70
|
+
};
|
|
71
|
+
const exportEdge = (node, location, warnings, extensions) => {
|
|
72
|
+
const handled = base();
|
|
73
|
+
const element = attributes(node, DIAGRAM_EXPORT.BPMNEdge.attributes, handled);
|
|
74
|
+
handled.add("waypoints");
|
|
75
|
+
handled.add("label");
|
|
76
|
+
if (Array.isArray(node.waypoints)) {
|
|
77
|
+
element["di:waypoint"] = node.waypoints.map((waypoint, index) => exportPoint(waypoint, `${location}/waypoints/${index}`, warnings, extensions));
|
|
78
|
+
}
|
|
79
|
+
if (isObject(node.label))
|
|
80
|
+
element["bpmndi:BPMNLabel"] = exportLabel(node.label, `${location}/label`, warnings, extensions);
|
|
81
|
+
report(node, handled, element, location, warnings, extensions);
|
|
82
|
+
return element;
|
|
83
|
+
};
|
|
84
|
+
const exportPlane = (node, location, warnings, extensions) => {
|
|
85
|
+
const handled = base();
|
|
86
|
+
const element = attributes(node, DIAGRAM_EXPORT.BPMNPlane.attributes, handled);
|
|
87
|
+
handled.add("planeElements");
|
|
88
|
+
const members = Array.isArray(node.planeElements) ? node.planeElements : [];
|
|
89
|
+
const children = [];
|
|
90
|
+
members.forEach((member, index) => {
|
|
91
|
+
const memberLocation = `${location}/planeElements/${index}`;
|
|
92
|
+
if (member.type === "BPMNShape")
|
|
93
|
+
children.push({ "bpmndi:BPMNShape": exportShape(member, memberLocation, warnings, extensions) });
|
|
94
|
+
else if (member.type === "BPMNEdge")
|
|
95
|
+
children.push({ "bpmndi:BPMNEdge": exportEdge(member, memberLocation, warnings, extensions) });
|
|
96
|
+
else
|
|
97
|
+
warnings.push(unsupported("unsupported-element", String(member.type), memberLocation, member));
|
|
98
|
+
});
|
|
99
|
+
if (children.length > 0)
|
|
100
|
+
element["#children"] = children;
|
|
101
|
+
report(node, handled, element, location, warnings, extensions);
|
|
102
|
+
return element;
|
|
103
|
+
};
|
|
104
|
+
export const exportDiagram = (node, location, warnings, extensions) => {
|
|
105
|
+
const handled = base();
|
|
106
|
+
const element = attributes(node, DIAGRAM_EXPORT.BPMNDiagram.attributes, handled);
|
|
107
|
+
handled.add("plane");
|
|
108
|
+
if (isObject(node.plane))
|
|
109
|
+
element["bpmndi:BPMNPlane"] = exportPlane(node.plane, `${location}/plane`, warnings, extensions);
|
|
110
|
+
report(node, handled, element, location, warnings, extensions, false);
|
|
111
|
+
return element;
|
|
112
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Extensions } from "./extensions.ts";
|
|
2
|
+
export interface ExportWarning {
|
|
3
|
+
kind: "unsupported";
|
|
4
|
+
code: WarningCode;
|
|
5
|
+
construct: string;
|
|
6
|
+
location: string;
|
|
7
|
+
node?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
}
|
|
10
|
+
export type WarningCode = "unsupported-root" | "unsupported-element" | "unsupported-property";
|
|
11
|
+
export type Json = Record<string, any>;
|
|
12
|
+
export type XmlNode = Record<string, any>;
|
|
13
|
+
export declare const isObject: (value: unknown) => value is Json;
|
|
14
|
+
export declare const unsupported: (code: WarningCode, construct: string, location: string, owner?: Json) => ExportWarning;
|
|
15
|
+
export declare const SUPPORTED_ELEMENTS: Record<string, string[]>;
|
|
16
|
+
export declare const elementName: (type: unknown) => string | undefined;
|
|
17
|
+
export declare class ExportContext {
|
|
18
|
+
readonly warnings: ExportWarning[];
|
|
19
|
+
readonly roots: Record<string, XmlNode[]>;
|
|
20
|
+
private readonly usedIds;
|
|
21
|
+
private readonly references;
|
|
22
|
+
readonly extensions: Extensions;
|
|
23
|
+
constructor(usedIds: Set<string>, extensions: Extensions);
|
|
24
|
+
reference(root: string, attribute: string, value: string): string;
|
|
25
|
+
}
|
|
26
|
+
export declare const collectIds: (value: unknown, ids?: Set<string>) => Set<string>;
|
|
27
|
+
export declare const exportElement: (name: string, node: Json, location: string, context: ExportContext) => XmlNode;
|