@jylups/flowable-bpmn-moddle 0.1.0-next.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -3
- package/index.js +2 -0
- package/lib/unknown.js +91 -0
- package/package.json +2 -1
- package/resources/flowable.json +195 -0
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Flowable moddle extensions for BPMN 2.0.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Built in Phase 1 of the Flowable BPMN editor ([jylups/bpmn-js-env#7](https://github.com/jylups/bpmn-js-env/issues/7)).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm install @jylups/flowable-bpmn-moddle
|
|
10
|
+
npm install @jylups/flowable-bpmn-moddle
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
@@ -44,6 +44,22 @@ const { xml: saved } = await moddle.toXML(useFlowablePrefix(rootElement));
|
|
|
44
44
|
|
|
45
45
|
Attributes Flowable reads without a namespace (listener, field, in/out and similar sub-attributes, the sequence flow `skipExpression`) are read whether or not they carry a prefix.
|
|
46
46
|
|
|
47
|
+
## Unknown Flowable elements
|
|
48
|
+
|
|
49
|
+
Flowable keeps any extension element it doesn't know, and Flowable Work/Design and users add their own. With the descriptor registered, bpmn-moddle would drop `flowable:*` elements it has no type for. Call `registerUnknownFlowableElements` with the moddle instance before importing, and they are kept and written back unchanged:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { registerUnknownFlowableElements } from '@jylups/flowable-bpmn-moddle';
|
|
53
|
+
|
|
54
|
+
registerUnknownFlowableElements(moddle, xml); // in bpmn-js: modeler.get('moddle')
|
|
55
|
+
|
|
56
|
+
const { rootElement } = await moddle.fromXML(xml, 'bpmn:Definitions');
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The Flowable Work/Design elements seen so far (`work-form-field-validation`, `task-candidates-type`, `static-process-key`, `translation`, and the condition builder `condition` with its nested conditions) are typed.
|
|
60
|
+
|
|
61
|
+
`itemSubjectRef` is kept as text, because Flowable uses values such as `xsd:string` without declaring an `itemDefinition`.
|
|
62
|
+
|
|
47
63
|
## Covered extensions
|
|
48
64
|
|
|
49
65
|
| Area | Extensions |
|
|
@@ -70,7 +86,7 @@ Listener, field and script attributes are written without a prefix, as Flowable'
|
|
|
70
86
|
|
|
71
87
|
With the descriptor registered, a `resourceAssignmentExpression` (in `potentialOwner`, `humanPerformer` and `flowable:potentialStarter`) is written with a `<formalExpression>` child, as Flowable expects, instead of bpmn-moddle's `<expression xsi:type="tFormalExpression">`.
|
|
72
88
|
|
|
73
|
-
The
|
|
89
|
+
The docker attributes Flowable writes on `BPMNEdge` (`sourceDockerX`/`Y` and `targetDockerX`/`Y`) are typed as text, so a value such as `50.0` is written back as written. They are defined on `di:LabeledEdge`, the supertype of `bpmndi:BPMNEdge`: extending `bpmndi:BPMNEdge` itself from this package would make moddle write the tag as `bPMNEdge`. `rotation` on `BPMNLabel` is still kept as an unknown attribute and written back unchanged.
|
|
74
90
|
|
|
75
91
|
The full list of Flowable extensions, and which ones are covered so far, is in the [coverage matrix](https://github.com/jylups/bpmn-js-env/blob/main/docs/coverage.md). The extensions themselves are listed in [docs/flowable-bpmn-extensions.md](https://github.com/jylups/bpmn-js-env/blob/main/docs/flowable-bpmn-extensions.md).
|
|
76
92
|
|
package/index.js
CHANGED
package/lib/unknown.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { FLOWABLE_NS } from './migrate.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Keeps flowable:* elements that the descriptor does not define.
|
|
5
|
+
*
|
|
6
|
+
* Because the Flowable namespace is registered with types, bpmn-moddle drops
|
|
7
|
+
* any flowable:* element it has no type for (an "unknown type" warning).
|
|
8
|
+
* Flowable itself keeps such elements, and Flowable Work/Design and users add
|
|
9
|
+
* their own. Before importing, this function finds the flowable:* element
|
|
10
|
+
* names in the XML that have no type and registers a generic type for each:
|
|
11
|
+
* a text body plus any child elements. Attributes are kept as unknown
|
|
12
|
+
* attributes, as for any element. The element is then read, kept and written
|
|
13
|
+
* back unchanged.
|
|
14
|
+
*
|
|
15
|
+
* Call it with the moddle instance that imports the XML (in bpmn-js:
|
|
16
|
+
* modeler.get('moddle')), before importXML / fromXML. Registered types stay
|
|
17
|
+
* on that instance.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} moddle - a bpmn-moddle instance with the Flowable descriptor
|
|
20
|
+
* @param {string} xml - the XML that is about to be imported
|
|
21
|
+
*
|
|
22
|
+
* @return {string[]} the names of the types registered, e.g. ['flowable:CustomValue']
|
|
23
|
+
*/
|
|
24
|
+
export function registerUnknownFlowableElements(moddle, xml) {
|
|
25
|
+
const pkg = moddle.getPackage('flowable');
|
|
26
|
+
|
|
27
|
+
if (!pkg) {
|
|
28
|
+
throw new Error('the Flowable descriptor is not registered with this moddle instance');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const registered = [];
|
|
32
|
+
|
|
33
|
+
for (const prefix of flowablePrefixes(xml)) {
|
|
34
|
+
const tag = new RegExp(`<${ escapeRegExp(prefix) }:([A-Za-z_][\\w.-]*)`, 'g');
|
|
35
|
+
|
|
36
|
+
for (const match of xml.matchAll(tag)) {
|
|
37
|
+
const typeName = match[1].charAt(0).toUpperCase() + match[1].slice(1);
|
|
38
|
+
const qualifiedName = `${ pkg.prefix }:${ typeName }`;
|
|
39
|
+
|
|
40
|
+
if (registered.includes(qualifiedName) || hasType(moddle, qualifiedName)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
moddle.registry.registerType({
|
|
45
|
+
name: typeName,
|
|
46
|
+
superClass: [ 'Element' ],
|
|
47
|
+
meta: { generic: true },
|
|
48
|
+
properties: [
|
|
49
|
+
{ name: 'body', isBody: true, type: 'String' },
|
|
50
|
+
{ name: 'children', type: 'Element', isMany: true }
|
|
51
|
+
]
|
|
52
|
+
}, pkg);
|
|
53
|
+
|
|
54
|
+
registered.push(qualifiedName);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return registered;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Prefixes the XML binds to the Flowable namespace.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} xml
|
|
65
|
+
*
|
|
66
|
+
* @return {Set<string>}
|
|
67
|
+
*/
|
|
68
|
+
function flowablePrefixes(xml) {
|
|
69
|
+
const prefixes = new Set();
|
|
70
|
+
const declaration = /\sxmlns:([A-Za-z_][\w.-]*)\s*=\s*(["'])([^"']*)\2/g;
|
|
71
|
+
|
|
72
|
+
for (const match of xml.matchAll(declaration)) {
|
|
73
|
+
if (match[3] === FLOWABLE_NS) {
|
|
74
|
+
prefixes.add(match[1]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return prefixes;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hasType(moddle, name) {
|
|
82
|
+
try {
|
|
83
|
+
return !!moddle.getType(name);
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function escapeRegExp(value) {
|
|
90
|
+
return value.replace(/[.*+?^${}()|[\]\\-]/g, '\\$&');
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jylups/flowable-bpmn-moddle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Flowable moddle extensions for BPMN 2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./index.js",
|
|
8
8
|
"./lib/migrate.js": "./lib/migrate.js",
|
|
9
|
+
"./lib/unknown.js": "./lib/unknown.js",
|
|
9
10
|
"./resources/flowable.json": "./resources/flowable.json",
|
|
10
11
|
"./package.json": "./package.json"
|
|
11
12
|
},
|
package/resources/flowable.json
CHANGED
|
@@ -1666,6 +1666,201 @@
|
|
|
1666
1666
|
"type": "String"
|
|
1667
1667
|
}
|
|
1668
1668
|
]
|
|
1669
|
+
},
|
|
1670
|
+
{
|
|
1671
|
+
"name": "Work-form-field-validation",
|
|
1672
|
+
"superClass": [
|
|
1673
|
+
"Element"
|
|
1674
|
+
],
|
|
1675
|
+
"meta": {
|
|
1676
|
+
"allowedIn": [
|
|
1677
|
+
"bpmn:StartEvent",
|
|
1678
|
+
"bpmn:UserTask"
|
|
1679
|
+
]
|
|
1680
|
+
},
|
|
1681
|
+
"properties": [
|
|
1682
|
+
{
|
|
1683
|
+
"name": "body",
|
|
1684
|
+
"isBody": true,
|
|
1685
|
+
"type": "String"
|
|
1686
|
+
}
|
|
1687
|
+
]
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
"name": "Task-candidates-type",
|
|
1691
|
+
"superClass": [
|
|
1692
|
+
"Element"
|
|
1693
|
+
],
|
|
1694
|
+
"meta": {
|
|
1695
|
+
"allowedIn": [
|
|
1696
|
+
"bpmn:UserTask"
|
|
1697
|
+
]
|
|
1698
|
+
},
|
|
1699
|
+
"properties": [
|
|
1700
|
+
{
|
|
1701
|
+
"name": "body",
|
|
1702
|
+
"isBody": true,
|
|
1703
|
+
"type": "String"
|
|
1704
|
+
}
|
|
1705
|
+
]
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
"name": "Static-process-key",
|
|
1709
|
+
"superClass": [
|
|
1710
|
+
"Element"
|
|
1711
|
+
],
|
|
1712
|
+
"meta": {
|
|
1713
|
+
"allowedIn": [
|
|
1714
|
+
"bpmn:CallActivity"
|
|
1715
|
+
]
|
|
1716
|
+
},
|
|
1717
|
+
"properties": [
|
|
1718
|
+
{
|
|
1719
|
+
"name": "body",
|
|
1720
|
+
"isBody": true,
|
|
1721
|
+
"type": "String"
|
|
1722
|
+
}
|
|
1723
|
+
]
|
|
1724
|
+
},
|
|
1725
|
+
{
|
|
1726
|
+
"name": "Translation",
|
|
1727
|
+
"superClass": [
|
|
1728
|
+
"Element"
|
|
1729
|
+
],
|
|
1730
|
+
"meta": {
|
|
1731
|
+
"allowedIn": [
|
|
1732
|
+
"bpmn:BaseElement"
|
|
1733
|
+
]
|
|
1734
|
+
},
|
|
1735
|
+
"properties": [
|
|
1736
|
+
{
|
|
1737
|
+
"name": "key",
|
|
1738
|
+
"isAttr": true,
|
|
1739
|
+
"type": "String"
|
|
1740
|
+
},
|
|
1741
|
+
{
|
|
1742
|
+
"name": "locale",
|
|
1743
|
+
"isAttr": true,
|
|
1744
|
+
"type": "String"
|
|
1745
|
+
},
|
|
1746
|
+
{
|
|
1747
|
+
"name": "body",
|
|
1748
|
+
"isBody": true,
|
|
1749
|
+
"type": "String"
|
|
1750
|
+
}
|
|
1751
|
+
]
|
|
1752
|
+
},
|
|
1753
|
+
{
|
|
1754
|
+
"name": "Condition",
|
|
1755
|
+
"superClass": [
|
|
1756
|
+
"Element"
|
|
1757
|
+
],
|
|
1758
|
+
"meta": {
|
|
1759
|
+
"allowedIn": [
|
|
1760
|
+
"bpmn:BaseElement"
|
|
1761
|
+
]
|
|
1762
|
+
},
|
|
1763
|
+
"properties": [
|
|
1764
|
+
{
|
|
1765
|
+
"name": "group",
|
|
1766
|
+
"isAttr": true,
|
|
1767
|
+
"type": "Boolean"
|
|
1768
|
+
},
|
|
1769
|
+
{
|
|
1770
|
+
"name": "match",
|
|
1771
|
+
"isAttr": true,
|
|
1772
|
+
"type": "String"
|
|
1773
|
+
},
|
|
1774
|
+
{
|
|
1775
|
+
"name": "targetAttribute",
|
|
1776
|
+
"isAttr": true,
|
|
1777
|
+
"type": "String"
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
"name": "sourceVariableType",
|
|
1781
|
+
"isAttr": true,
|
|
1782
|
+
"type": "String"
|
|
1783
|
+
},
|
|
1784
|
+
{
|
|
1785
|
+
"name": "sourceName",
|
|
1786
|
+
"isAttr": true,
|
|
1787
|
+
"type": "String"
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
"name": "sourceType",
|
|
1791
|
+
"isAttr": true,
|
|
1792
|
+
"type": "String"
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
"name": "operator",
|
|
1796
|
+
"isAttr": true,
|
|
1797
|
+
"type": "String"
|
|
1798
|
+
},
|
|
1799
|
+
{
|
|
1800
|
+
"name": "targetVariableType",
|
|
1801
|
+
"isAttr": true,
|
|
1802
|
+
"type": "String"
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
"name": "targetValue",
|
|
1806
|
+
"isAttr": true,
|
|
1807
|
+
"type": "String"
|
|
1808
|
+
},
|
|
1809
|
+
{
|
|
1810
|
+
"name": "targetType",
|
|
1811
|
+
"isAttr": true,
|
|
1812
|
+
"type": "String"
|
|
1813
|
+
},
|
|
1814
|
+
{
|
|
1815
|
+
"name": "conditions",
|
|
1816
|
+
"type": "Condition",
|
|
1817
|
+
"isMany": true
|
|
1818
|
+
}
|
|
1819
|
+
]
|
|
1820
|
+
},
|
|
1821
|
+
{
|
|
1822
|
+
"name": "EdgeDockers",
|
|
1823
|
+
"isAbstract": true,
|
|
1824
|
+
"extends": [
|
|
1825
|
+
"di:LabeledEdge"
|
|
1826
|
+
],
|
|
1827
|
+
"properties": [
|
|
1828
|
+
{
|
|
1829
|
+
"name": "sourceDockerX",
|
|
1830
|
+
"isAttr": true,
|
|
1831
|
+
"type": "String"
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
"name": "sourceDockerY",
|
|
1835
|
+
"isAttr": true,
|
|
1836
|
+
"type": "String"
|
|
1837
|
+
},
|
|
1838
|
+
{
|
|
1839
|
+
"name": "targetDockerX",
|
|
1840
|
+
"isAttr": true,
|
|
1841
|
+
"type": "String"
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
"name": "targetDockerY",
|
|
1845
|
+
"isAttr": true,
|
|
1846
|
+
"type": "String"
|
|
1847
|
+
}
|
|
1848
|
+
]
|
|
1849
|
+
},
|
|
1850
|
+
{
|
|
1851
|
+
"name": "ItemAwareElement",
|
|
1852
|
+
"isAbstract": true,
|
|
1853
|
+
"extends": [
|
|
1854
|
+
"bpmn:ItemAwareElement"
|
|
1855
|
+
],
|
|
1856
|
+
"properties": [
|
|
1857
|
+
{
|
|
1858
|
+
"name": "bpmn:itemSubjectRef",
|
|
1859
|
+
"isAttr": true,
|
|
1860
|
+
"type": "String",
|
|
1861
|
+
"replaces": "bpmn:ItemAwareElement#itemSubjectRef"
|
|
1862
|
+
}
|
|
1863
|
+
]
|
|
1669
1864
|
}
|
|
1670
1865
|
],
|
|
1671
1866
|
"enumerations": []
|