bpmnlint 11.15.0 → 12.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/lib/types.d.ts CHANGED
@@ -1,81 +1,20 @@
1
- export type ModdleElement = any;
2
-
3
- export interface Reporter {
4
-
5
- report(id: string, message: string): void;
6
-
7
- report(id: string, message: string, path: string[]): void;
8
-
9
- report(id: string, message: string, context: {
10
- path?: string[],
11
- [key: string]: any
12
- }) : void;
13
- }
14
-
15
- export interface Resolver {
16
-
17
- resolveRule(pkg: string, ruleName: string): Promise<RuleFactory> | RuleFactory,
18
-
19
- resolveConfig(pkg: string, configName: string): Promise<Config> | Config;
20
- }
21
-
22
- export type EnterFn = (element: ModdleElement, reporter: Reporter) => boolean | void;
23
-
24
- export type LeaveFn = (element: ModdleElement, reporter: Reporter) => void;
25
-
26
- export type CheckDefinition = EnterFn | {
27
- enter: EnterFn
28
- } | {
29
- leave: LeaveFn
30
- } | {
31
- enter: EnterFn,
32
- leave: LeaveFn
33
- };
34
-
35
- export type RuleDefinition = {
36
- meta?: {
37
- documentation?: {
38
- url?: string
39
- }
40
- },
41
- check: CheckDefinition
42
- };
43
-
44
- export type RuleFactory = (ruleOptions?: any) => RuleDefinition;
45
-
46
- export type ReportingCategoryMap = {
47
- 0: 'off',
48
- 1: 'warn',
49
- 2: 'error',
50
- 3: 'info'
51
- };
52
-
53
- export type ReportingCategoryIndex = keyof ReportingCategoryMap;
54
- export type ReportingCategory = ReportingCategoryMap[ReportingCategoryIndex];
55
-
56
- export type RuleErrorCategory = 'rule-error';
57
-
58
- export type RuleConfig =
59
- ReportingCategoryIndex |
60
- ReportingCategory |
61
- [ ReportingCategoryIndex, config?: any ] |
62
- [ ReportingCategory, config?: any ];
63
-
64
- export type RuleConfigs = Record<string, RuleConfig>;
65
-
66
- export type Config = {
67
- extends?: string | string[],
68
- rules?: RuleConfigs
69
- };
70
-
71
- export type TransformRuleFn = (
72
- rule: RuleDefinition,
73
- options: { pkg: string, ruleName: string }
74
- ) => RuleDefinition;
75
-
76
- export type Report = {
77
- id?: string,
78
- path?: string[],
79
- message: string,
80
- [key: string]: any
81
- };
1
+ export type {
2
+ ModdleElement,
3
+ Product,
4
+ Reporter,
5
+ Resolver,
6
+ EnterFn,
7
+ LeaveFn,
8
+ CheckDefinition,
9
+ RuleDefinition,
10
+ RuleFactory,
11
+ ReportingCategoryMap,
12
+ ReportingCategoryIndex,
13
+ ReportingCategory,
14
+ RuleErrorCategory,
15
+ RuleConfig,
16
+ RuleConfigs,
17
+ Config,
18
+ TransformRuleFn,
19
+ Report
20
+ } from '@bpmn-io/lint-core/lib/types';
package/package.json CHANGED
@@ -1,8 +1,47 @@
1
1
  {
2
2
  "name": "bpmnlint",
3
3
  "description": "Validate your BPMN diagrams based on configurable lint rules",
4
- "version": "11.15.0",
4
+ "version": "12.1.0",
5
5
  "main": "lib/index.js",
6
+ "exports": {
7
+ ".": "./lib/index.js",
8
+ "./lib/index": "./lib/index.js",
9
+ "./lib/index.js": "./lib/index.js",
10
+ "./lib/linter": "./lib/linter.js",
11
+ "./lib/linter.js": "./lib/linter.js",
12
+ "./lib/resolver/helper": "./lib/resolver/helper.js",
13
+ "./lib/resolver/helper.js": "./lib/resolver/helper.js",
14
+ "./lib/resolver/node-resolver": "./lib/resolver/node-resolver.js",
15
+ "./lib/resolver/node-resolver.js": "./lib/resolver/node-resolver.js",
16
+ "./lib/resolver/static-resolver": "./lib/resolver/static-resolver.js",
17
+ "./lib/resolver/static-resolver.js": "./lib/resolver/static-resolver.js",
18
+ "./lib/support/compile-config": "./lib/support/compile-config.js",
19
+ "./lib/support/compile-config.js": "./lib/support/compile-config.js",
20
+ "./lib/test-rule": "./lib/test-rule.js",
21
+ "./lib/test-rule.js": "./lib/test-rule.js",
22
+ "./lib/testers/helper": "./lib/testers/helper.js",
23
+ "./lib/testers/helper.js": "./lib/testers/helper.js",
24
+ "./lib/traverse": "./lib/traverse.js",
25
+ "./lib/traverse.js": "./lib/traverse.js",
26
+ "./bin/bpmnlint": "./bin/bpmnlint.js",
27
+ "./bin/bpmnlint.js": "./bin/bpmnlint.js",
28
+ "./lib/testers/rule-tester": {
29
+ "types": "./lib/testers/rule-tester.d.ts",
30
+ "default": "./lib/testers/rule-tester.js"
31
+ },
32
+ "./lib/testers/rule-tester.js": {
33
+ "types": "./lib/testers/rule-tester.d.ts",
34
+ "default": "./lib/testers/rule-tester.js"
35
+ },
36
+ "./lib/types": {
37
+ "types": "./lib/types.d.ts"
38
+ },
39
+ "./rules/*.js": "./rules/*.js",
40
+ "./rules/*": "./rules/*.js",
41
+ "./config/*.js": "./config/*.js",
42
+ "./config/*": "./config/*.js",
43
+ "./package.json": "./package.json"
44
+ },
6
45
  "keywords": [
7
46
  "bpmnlint",
8
47
  "bpmn",
@@ -23,7 +62,7 @@
23
62
  }
24
63
  ],
25
64
  "engines": {
26
- "node": ">= 20"
65
+ "node": ">= 24"
27
66
  },
28
67
  "license": "MIT",
29
68
  "scripts": {
@@ -40,16 +79,10 @@
40
79
  "bpmnlint": "./bin/bpmnlint.js"
41
80
  },
42
81
  "dependencies": {
43
- "@bpmn-io/moddle-utils": "^0.3.0",
44
- "ansi-colors": "^4.1.3",
82
+ "@bpmn-io/lint-core": "^0.1.0",
45
83
  "bpmn-moddle": "^10.1.0",
46
84
  "bpmnlint-utils": "^1.1.1",
47
- "cli-table": "^0.3.11",
48
- "color-support": "^1.1.3",
49
- "min-dash": "^5.1.0",
50
- "mri": "^1.2.0",
51
- "pluralize": "^8.0.0",
52
- "tiny-glob": "^0.2.9"
85
+ "min-dash": "^5.1.0"
53
86
  },
54
87
  "devDependencies": {
55
88
  "@bpmn-io/bpmnlint-generate-docs-images": "^1.2.0",
@@ -1,4 +1,9 @@
1
1
  const {
2
+ groupBy
3
+ } = require('min-dash');
4
+
5
+ const {
6
+ is,
2
7
  isAny
3
8
  } = require('bpmnlint-utils');
4
9
 
@@ -9,7 +14,9 @@ const {
9
14
 
10
15
  /**
11
16
  * A rule that checks that no fake join is modeled by attempting
12
- * to give a task or event join semantics.
17
+ * to give an element join semantics, i.e. a task or event with
18
+ * multiple incoming flows, or a link catch event targeted by
19
+ * multiple link throw events.
13
20
  *
14
21
  * Users should model a parallel joining gateway
15
22
  * to achieve the desired behavior.
@@ -20,6 +27,10 @@ module.exports = function() {
20
27
 
21
28
  function check(node, reporter) {
22
29
 
30
+ if (is(node, 'bpmn:FlowElementsContainer')) {
31
+ checkLinks(node, reporter);
32
+ }
33
+
23
34
  if (!isAny(node, [
24
35
  'bpmn:Activity',
25
36
  'bpmn:Event'
@@ -34,8 +45,46 @@ module.exports = function() {
34
45
  }
35
46
  }
36
47
 
48
+ function checkLinks(container, reporter) {
49
+
50
+ const links = (container.flowElements || []).filter(isLinkEvent);
51
+
52
+ // links are resolved by name, per scope
53
+ const names = groupBy(links.filter(getLinkName), getLinkName);
54
+
55
+ for (const [ name, events ] of Object.entries(names)) {
56
+ const throwEvents = events.filter(event => is(event, 'bpmn:ThrowEvent'));
57
+ const catchEvents = events.filter(event => is(event, 'bpmn:CatchEvent'));
58
+
59
+ // ignore ambiguous catch
60
+ if (throwEvents.length > 1 && catchEvents.length === 1) {
61
+ reporter.report(
62
+ catchEvents[0].id,
63
+ `Link throw events with link name <${ name }> do not join`
64
+ );
65
+ }
66
+ }
67
+ }
68
+
37
69
  return annotateRule('fake-join', {
38
70
  check
39
71
  });
40
72
 
41
- };
73
+ };
74
+
75
+
76
+ // helpers /////////////////
77
+
78
+ function isLinkEvent(node) {
79
+ return is(node, 'bpmn:Event') && !!getLinkDefinition(node);
80
+ }
81
+
82
+ function getLinkDefinition(linkEvent) {
83
+ return (linkEvent.eventDefinitions || []).find(
84
+ definition => is(definition, 'bpmn:LinkEventDefinition')
85
+ );
86
+ }
87
+
88
+ function getLinkName(linkEvent) {
89
+ return getLinkDefinition(linkEvent).name;
90
+ }