@jylups/flowable-bpmn-js 0.0.0-stage → 0.0.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +282 -2
  3. package/assets/flowable-bpmn-js-touch.css +76 -0
  4. package/assets/flowable-bpmn-js.css +70 -0
  5. package/dist/assets/bpmn-font/css/bpmn-codes.css +110 -0
  6. package/dist/assets/bpmn-font/css/bpmn-embedded.css +168 -0
  7. package/dist/assets/bpmn-font/css/bpmn.css +166 -0
  8. package/dist/assets/bpmn-font/font/bpmn.eot +0 -0
  9. package/dist/assets/bpmn-font/font/bpmn.svg +228 -0
  10. package/dist/assets/bpmn-font/font/bpmn.ttf +0 -0
  11. package/dist/assets/bpmn-font/font/bpmn.woff +0 -0
  12. package/dist/assets/bpmn-font/font/bpmn.woff2 +0 -0
  13. package/dist/assets/bpmn-js-bpmnlint.css +263 -0
  14. package/dist/assets/bpmn-js.css +151 -0
  15. package/dist/assets/diagram-js.css +1325 -0
  16. package/dist/assets/flowable-bpmn-js-touch.css +76 -0
  17. package/dist/assets/flowable-bpmn-js.css +70 -0
  18. package/dist/assets/properties-panel.css +1905 -0
  19. package/dist/flowable-bpmn-modeler.development.js +128087 -0
  20. package/dist/flowable-bpmn-modeler.development.js.map +1 -0
  21. package/dist/flowable-bpmn-modeler.production.min.js +348 -0
  22. package/dist/flowable-bpmn-navigated-viewer.development.js +28092 -0
  23. package/dist/flowable-bpmn-navigated-viewer.development.js.map +1 -0
  24. package/dist/flowable-bpmn-navigated-viewer.production.min.js +2 -0
  25. package/dist/flowable-bpmn-viewer.development.js +26751 -0
  26. package/dist/flowable-bpmn-viewer.development.js.map +1 -0
  27. package/dist/flowable-bpmn-viewer.production.min.js +2 -0
  28. package/index.d.ts +107 -0
  29. package/index.js +32 -0
  30. package/lib/Modeler.js +68 -0
  31. package/lib/NavigatedViewer.js +30 -0
  32. package/lib/NewDiagram.js +69 -0
  33. package/lib/Theme.js +32 -0
  34. package/lib/Viewer.js +32 -0
  35. package/lib/distro/Modeler.js +5 -0
  36. package/lib/distro/NavigatedViewer.js +5 -0
  37. package/lib/distro/Viewer.js +5 -0
  38. package/lib/draw/TypedTaskRenderer.js +81 -0
  39. package/lib/draw/index.js +10 -0
  40. package/lib/features/touch/InputTracker.js +34 -0
  41. package/lib/features/touch/LICENSE +21 -0
  42. package/lib/features/touch/TouchContextPad.js +197 -0
  43. package/lib/features/touch/TouchInteraction.js +1276 -0
  44. package/lib/features/touch/TouchLabelEditing.js +60 -0
  45. package/lib/features/touch/index.js +40 -0
  46. package/lib/features/typed-tasks/ReplaceWithTypedTaskHandler.js +63 -0
  47. package/lib/features/typed-tasks/TypedTaskPaletteProvider.js +76 -0
  48. package/lib/features/typed-tasks/TypedTaskReplaceMenuProvider.js +71 -0
  49. package/lib/features/typed-tasks/TypedTasks.js +127 -0
  50. package/lib/features/typed-tasks/icons.js +99 -0
  51. package/lib/features/typed-tasks/index.js +17 -0
  52. package/lib/lint/FlowableLinting.js +23 -0
  53. package/lib/lint/index.js +44 -0
  54. package/lib/lint/module.js +15 -0
  55. package/lib/lint/rules/called-element.js +19 -0
  56. package/lib/lint/rules/service-task-implementation.js +81 -0
  57. package/lib/lint/rules/valid-durations.js +102 -0
  58. package/lib/lint/values.js +71 -0
  59. package/lib/xml/FlowableXML.js +50 -0
  60. package/lib/xml/index.js +6 -0
  61. package/package.json +80 -4
@@ -0,0 +1,60 @@
1
+ export var EDITOR_SELECTOR = '.djs-direct-editing-content';
2
+
3
+
4
+ /**
5
+ * Label editing with touch gestures. Neither part changes anything for a
6
+ * mouse.
7
+ *
8
+ * - A double tap opens the label editor from touchend, and iOS then moves the
9
+ * focus away as part of the tap, which can close the editor before the user
10
+ * types. Cancelling that touchend and focusing the editor again keeps it
11
+ * open. iOS shows the keyboard only when the user taps the editor itself.
12
+ * - cmmn-js finishes an edit on element.mousedown, drag.init or a viewbox
13
+ * change, and a tap sends only element.click: a tap on the canvas finishes
14
+ * it here. With a mouse, the mousedown before the click has finished it.
15
+ *
16
+ * @param {EventBus} eventBus
17
+ * @param {DirectEditing} directEditing
18
+ */
19
+ export default function TouchLabelEditing(eventBus, directEditing) {
20
+ var justOpened = false;
21
+
22
+ eventBus.on('directEditing.activate', function() {
23
+ justOpened = true;
24
+ });
25
+
26
+ eventBus.on('canvas.init', function(event) {
27
+ var container = event.svg.parentElement;
28
+
29
+ if (!container) {
30
+ return;
31
+ }
32
+
33
+ // registered after the touch gestures' listener on the canvas, which
34
+ // opens the editor, so this runs after it for the same touchend
35
+ container.addEventListener('touchend', function(touchEvent) {
36
+ if (!justOpened) {
37
+ return;
38
+ }
39
+
40
+ justOpened = false;
41
+ touchEvent.preventDefault();
42
+
43
+ var editor = container.querySelector(EDITOR_SELECTOR);
44
+
45
+ if (editor) {
46
+ editor.focus();
47
+ }
48
+ });
49
+ });
50
+
51
+ eventBus.on('element.click', function() {
52
+ justOpened = false;
53
+
54
+ if (directEditing.isActive()) {
55
+ directEditing.complete();
56
+ }
57
+ });
58
+ }
59
+
60
+ TouchLabelEditing.$inject = [ 'eventBus', 'directEditing' ];
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Touch editing for the modeler, as an optional module:
3
+ *
4
+ * import { Modeler, TouchModule } from '@jylups/flowable-bpmn-js';
5
+ * import '@jylups/flowable-bpmn-js/assets/flowable-bpmn-js-touch.css';
6
+ *
7
+ * new Modeler({ additionalModules: [ TouchModule ] });
8
+ *
9
+ * It turns itself on only where (pointer: coarse) matches, so a desktop with
10
+ * a mouse is unchanged. assets/flowable-bpmn-js-touch.css makes the touch
11
+ * targets larger.
12
+ *
13
+ * The gestures come from bpmn-js-touch-interaction (MIT, see LICENSE in this
14
+ * folder), as adapted in @jylups/cmmn-js; the other services fix what the
15
+ * modeler needs on top of them.
16
+ */
17
+ import {
18
+ InteractionEventsModule,
19
+ TouchFix,
20
+ TouchInteraction
21
+ } from './TouchInteraction.js';
22
+
23
+ import TouchContextPad from './TouchContextPad.js';
24
+ import TouchLabelEditing from './TouchLabelEditing.js';
25
+
26
+ export default {
27
+ __depends__: [
28
+ InteractionEventsModule
29
+ ],
30
+ __init__: [
31
+ 'touchInteraction',
32
+ 'touchFix',
33
+ 'touchLabelEditing',
34
+ 'touchContextPad'
35
+ ],
36
+ touchInteraction: [ 'type', TouchInteraction ],
37
+ touchFix: [ 'type', TouchFix ],
38
+ touchLabelEditing: [ 'type', TouchLabelEditing ],
39
+ touchContextPad: [ 'type', TouchContextPad ]
40
+ };
@@ -0,0 +1,63 @@
1
+ import { is } from 'bpmn-js/lib/util/ModelUtil';
2
+
3
+ import { getImplementationChange } from './TypedTasks.js';
4
+
5
+
6
+ /**
7
+ * Command 'flowable.replaceWithTypedTask': makes an element a typed service
8
+ * task, or a plain service task (taskType null), in one undo step.
9
+ *
10
+ * An element that is not a service task is replaced with one first (the
11
+ * Flowable behaviors drop what a service task can't hold). Then whatever the
12
+ * previous implementation set is removed, and the type and its default
13
+ * fields are set.
14
+ *
15
+ * Context: { element, taskType }; after execution also { newElement }.
16
+ */
17
+ export default class ReplaceWithTypedTaskHandler {
18
+
19
+ constructor(bpmnReplace, modeling, bpmnFactory) {
20
+ this._bpmnReplace = bpmnReplace;
21
+ this._modeling = modeling;
22
+ this._bpmnFactory = bpmnFactory;
23
+ }
24
+
25
+ preExecute(context) {
26
+ const { element, taskType } = context;
27
+
28
+ const serviceTask = is(element, 'bpmn:ServiceTask')
29
+ ? element
30
+ : this._bpmnReplace.replaceElement(element, { type: 'bpmn:ServiceTask' });
31
+
32
+ const businessObject = serviceTask.businessObject;
33
+ const { attributes, values } = getImplementationChange(businessObject, taskType, this._bpmnFactory);
34
+
35
+ if (Object.keys(attributes).length) {
36
+ this._modeling.updateModdleProperties(serviceTask, businessObject, attributes);
37
+ }
38
+
39
+ if (values) {
40
+ this._setExtensionValues(serviceTask, businessObject, values);
41
+ }
42
+
43
+ context.newElement = serviceTask;
44
+ }
45
+
46
+ _setExtensionValues(element, businessObject, values) {
47
+ let extensionElements = businessObject.get('extensionElements');
48
+
49
+ if (!extensionElements) {
50
+ extensionElements = this._bpmnFactory.create('bpmn:ExtensionElements', { values: [] });
51
+ extensionElements.$parent = businessObject;
52
+ }
53
+
54
+ values.forEach(value => {
55
+ value.$parent = extensionElements;
56
+ });
57
+
58
+ // the Flowable behaviors attach a new container and remove an empty one
59
+ this._modeling.updateModdleProperties(element, extensionElements, { values });
60
+ }
61
+ }
62
+
63
+ ReplaceWithTypedTaskHandler.$inject = [ 'bpmnReplace', 'modeling', 'bpmnFactory' ];
@@ -0,0 +1,76 @@
1
+ import { TASK_TYPES, createDefaultFields } from './TypedTasks.js';
2
+
3
+
4
+ /**
5
+ * Adds a palette entry per typed service task, in its own group after the
6
+ * bpmn-js entries.
7
+ */
8
+ export default class TypedTaskPaletteProvider {
9
+
10
+ constructor(palette, create, elementFactory, bpmnFactory, translate) {
11
+ this._create = create;
12
+ this._elementFactory = elementFactory;
13
+ this._bpmnFactory = bpmnFactory;
14
+ this._translate = translate;
15
+
16
+ palette.registerProvider(this);
17
+ }
18
+
19
+ getPaletteEntries() {
20
+ return entries => {
21
+ const added = {};
22
+
23
+ TASK_TYPES.forEach(taskType => {
24
+ const start = event => this._create.start(event, this.createShape(taskType.type));
25
+
26
+ added[`create.flowable-${ taskType.type }-task`] = {
27
+ group: 'flowable-tasks',
28
+ className: `flowable-icon flowable-icon-${ taskType.type }`,
29
+ title: this._translate(`Create ${ lowerFirst(taskType.label) }`),
30
+ action: { dragstart: start, click: start }
31
+ };
32
+ });
33
+
34
+ return { ...entries, ...added };
35
+ };
36
+ }
37
+
38
+ /**
39
+ * A new service task shape of a type, with its default fields.
40
+ *
41
+ * @param {string} type - e.g. 'mail'
42
+ */
43
+ createShape(type) {
44
+ const taskType = TASK_TYPES.find(candidate => candidate.type === type);
45
+
46
+ if (!taskType) {
47
+ throw new Error(`unknown task type <${ type }>`);
48
+ }
49
+
50
+ const businessObject = this._bpmnFactory.create('bpmn:ServiceTask', { 'flowable:type': type });
51
+ const fields = createDefaultFields(this._bpmnFactory, taskType);
52
+
53
+ if (fields.length) {
54
+ const extensionElements = this._bpmnFactory.create('bpmn:ExtensionElements', { values: fields });
55
+
56
+ extensionElements.$parent = businessObject;
57
+ fields.forEach(field => {
58
+ field.$parent = extensionElements;
59
+ });
60
+
61
+ businessObject.set('extensionElements', extensionElements);
62
+ }
63
+
64
+ return this._elementFactory.createShape({ type: 'bpmn:ServiceTask', businessObject });
65
+ }
66
+ }
67
+
68
+ TypedTaskPaletteProvider.$inject = [ 'palette', 'create', 'elementFactory', 'bpmnFactory', 'translate' ];
69
+
70
+
71
+ /**
72
+ * 'Mail task' -> 'mail task'; acronyms such as 'HTTP task' stay.
73
+ */
74
+ function lowerFirst(label) {
75
+ return /^[A-Z][A-Z]/.test(label) ? label : label.charAt(0).toLowerCase() + label.slice(1);
76
+ }
@@ -0,0 +1,71 @@
1
+ import { isAny } from 'bpmn-js/lib/util/ModelUtil';
2
+
3
+ import { TASK_TYPES, getTypedTask } from './TypedTasks.js';
4
+
5
+ const GROUP = { id: 'flowable-tasks', name: 'Flowable tasks' };
6
+
7
+
8
+ /**
9
+ * Adds the typed service tasks to the replace menu of tasks and call
10
+ * activities, and a plain service task entry for typed tasks (bpmn-js hides
11
+ * its own, since the element already is a service task).
12
+ */
13
+ export default class TypedTaskReplaceMenuProvider {
14
+
15
+ constructor(popupMenu, commandStack, rules, translate) {
16
+ this._commandStack = commandStack;
17
+ this._rules = rules;
18
+ this._translate = translate;
19
+
20
+ popupMenu.registerProvider('bpmn-replace', this);
21
+ }
22
+
23
+ getPopupMenuEntries(target) {
24
+ return entries => ({ ...entries, ...this._getEntries(target) });
25
+ }
26
+
27
+ _getEntries(target) {
28
+ if (Array.isArray(target) || !isAny(target, [ 'bpmn:Task', 'bpmn:CallActivity' ]) ||
29
+ !this._rules.allowed('shape.replace', { element: target })) {
30
+ return {};
31
+ }
32
+
33
+ const translate = this._translate;
34
+ const current = getTypedTask(target);
35
+ const group = { id: GROUP.id, name: translate(GROUP.name) };
36
+ const entries = {};
37
+
38
+ if (current) {
39
+ entries['replace-with-flowable-service-task'] = {
40
+ label: translate('Service task'),
41
+ className: 'bpmn-icon-service',
42
+ group,
43
+ action: () => this._replace(target, null)
44
+ };
45
+ }
46
+
47
+ TASK_TYPES
48
+ .filter(taskType => taskType !== current)
49
+ .forEach(taskType => {
50
+ entries[`replace-with-flowable-${ taskType.type }-task`] = {
51
+ label: translate(taskType.label),
52
+ className: `flowable-icon flowable-icon-${ taskType.type }`,
53
+ group,
54
+ action: () => this._replace(target, taskType)
55
+ };
56
+ });
57
+
58
+ return entries;
59
+ }
60
+
61
+ _replace(element, taskType) {
62
+ const context = { element, taskType };
63
+
64
+ this._commandStack.execute('flowable.replaceWithTypedTask', context);
65
+
66
+ return context.newElement;
67
+ }
68
+ }
69
+
70
+ TypedTaskReplaceMenuProvider.$inject = [ 'popupMenu', 'commandStack', 'rules', 'translate' ];
71
+
@@ -0,0 +1,127 @@
1
+ import { is } from 'bpmn-js/lib/util/ModelUtil';
2
+
3
+
4
+ /**
5
+ * The typed service tasks: service tasks whose flowable:type selects an
6
+ * engine implementation. `fields` are the <flowable:field> values a new task
7
+ * of the type starts with.
8
+ */
9
+ export const TASK_TYPES = [
10
+ { type: 'mail', label: 'Mail task' },
11
+ { type: 'http', label: 'HTTP task', fields: { requestMethod: 'GET' } },
12
+ { type: 'shell', label: 'Shell task' },
13
+ { type: 'camel', label: 'Camel task' },
14
+ { type: 'dmn', label: 'Decision task' },
15
+ { type: 'case', label: 'Case task' },
16
+ { type: 'send-event', label: 'Send event task' },
17
+ { type: 'external-worker', label: 'External worker task' }
18
+ ];
19
+
20
+ /**
21
+ * Service task attributes that belong to one implementation; changing the
22
+ * type removes them.
23
+ */
24
+ const IMPLEMENTATION_ATTRIBUTES = [
25
+ 'flowable:type',
26
+ 'flowable:class',
27
+ 'flowable:expression',
28
+ 'flowable:delegateExpression',
29
+ 'flowable:resultVariableName',
30
+ 'flowable:resultVariable',
31
+ 'flowable:useLocalScopeForResultVariable',
32
+ 'flowable:storeResultVariableAsTransient',
33
+ 'flowable:triggerable',
34
+ 'flowable:parallelInSameTransaction',
35
+ 'flowable:caseDefinitionKey',
36
+ 'flowable:caseInstanceName',
37
+ 'flowable:businessKey',
38
+ 'flowable:inheritBusinessKey',
39
+ 'flowable:inheritVariables',
40
+ 'flowable:fallbackToDefaultTenant',
41
+ 'flowable:idVariableName',
42
+ 'flowable:topic',
43
+ 'flowable:doNotIncludeVariables'
44
+ ];
45
+
46
+ /**
47
+ * Extension elements that belong to one implementation.
48
+ */
49
+ const IMPLEMENTATION_ELEMENTS = [
50
+ 'flowable:Field',
51
+ 'flowable:HttpRequestHandler',
52
+ 'flowable:HttpResponseHandler',
53
+ 'flowable:In',
54
+ 'flowable:Out',
55
+ 'flowable:ExternalWorkerInParameter',
56
+ 'flowable:ExternalWorkerOutParameter',
57
+ 'flowable:EventInParameter',
58
+ 'flowable:EventOutParameter',
59
+ 'flowable:EventType',
60
+ 'flowable:TriggerEventType',
61
+ 'flowable:SendSynchronously',
62
+ 'flowable:TriggerEventCorrelationParameter',
63
+ 'flowable:ChannelKey',
64
+ 'flowable:SystemChannel'
65
+ ];
66
+
67
+
68
+ export function getTaskType(type) {
69
+ return TASK_TYPES.find(taskType => taskType.type === type);
70
+ }
71
+
72
+ /**
73
+ * The flowable:type of a service task, if it is one of the typed tasks.
74
+ */
75
+ export function getTypedTask(element) {
76
+ const businessObject = element && element.businessObject;
77
+
78
+ if (!is(businessObject, 'bpmn:ServiceTask')) {
79
+ return null;
80
+ }
81
+
82
+ return getTaskType(businessObject.get('flowable:type')) || null;
83
+ }
84
+
85
+ /**
86
+ * The <flowable:field> elements a new task of a type starts with.
87
+ */
88
+ export function createDefaultFields(bpmnFactory, taskType) {
89
+ return Object.entries(taskType.fields || {}).map(([ name, value ]) =>
90
+ bpmnFactory.create('flowable:Field', { name, string: value })
91
+ );
92
+ }
93
+
94
+ /**
95
+ * Properties to set on a service task so it has a type's implementation,
96
+ * and nothing left of another one: unset attributes, kept and added
97
+ * extension elements.
98
+ *
99
+ * @param {ModdleElement} businessObject - a bpmn:ServiceTask
100
+ * @param {Object|null} taskType - null for a plain service task
101
+ * @param {BpmnFactory} bpmnFactory
102
+ *
103
+ * @return {{ attributes: Object, values: ModdleElement[]|null }} values is
104
+ * null when the extension elements stay as they are
105
+ */
106
+ export function getImplementationChange(businessObject, taskType, bpmnFactory) {
107
+ const attributes = {};
108
+
109
+ IMPLEMENTATION_ATTRIBUTES.forEach(name => {
110
+ if (businessObject.get(name) !== undefined) {
111
+ attributes[name] = undefined;
112
+ }
113
+ });
114
+
115
+ if (taskType) {
116
+ attributes['flowable:type'] = taskType.type;
117
+ }
118
+
119
+ const extensionElements = businessObject.get('extensionElements');
120
+ const current = (extensionElements && extensionElements.get('values')) || [];
121
+ const kept = current.filter(value => !IMPLEMENTATION_ELEMENTS.some(type => is(value, type)));
122
+ const added = taskType ? createDefaultFields(bpmnFactory, taskType) : [];
123
+
124
+ const values = kept.length === current.length && !added.length ? null : [ ...added, ...kept ];
125
+
126
+ return { attributes, values };
127
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Icons of the typed service tasks, drawn for this project on a 24 x 24
3
+ * grid as outlines (stroke only, round caps and joins). Each icon is a list
4
+ * of SVG elements: [ tag, attributes ].
5
+ *
6
+ * The task renderer draws them on the canvas; assets/flowable-bpmn-js.css
7
+ * (generated from here by `npm run icons`) shows them in the palette and the
8
+ * replace menu.
9
+ */
10
+ export const ICONS = {
11
+
12
+ // an envelope
13
+ mail: [
14
+ [ 'rect', { x: 3, y: 6, width: 18, height: 12, rx: 1.5 } ],
15
+ [ 'path', { d: 'M3.5 7 L12 13 L20.5 7' } ]
16
+ ],
17
+
18
+ // a globe
19
+ http: [
20
+ [ 'circle', { cx: 12, cy: 12, r: 8.5 } ],
21
+ [ 'path', { d: 'M3.5 12 H20.5' } ],
22
+ [ 'path', { d: 'M12 3.5 C8.4 7 8.4 17 12 20.5 C15.6 17 15.6 7 12 3.5' } ]
23
+ ],
24
+
25
+ // a terminal prompt
26
+ shell: [
27
+ [ 'rect', { x: 3, y: 5, width: 18, height: 14, rx: 2 } ],
28
+ [ 'path', { d: 'M7 9.5 L10 12 L7 14.5' } ],
29
+ [ 'path', { d: 'M12 15 H16.5' } ]
30
+ ],
31
+
32
+ // a route between two endpoints
33
+ camel: [
34
+ [ 'circle', { cx: 6, cy: 6.5, r: 2.2 } ],
35
+ [ 'circle', { cx: 18, cy: 17.5, r: 2.2 } ],
36
+ [ 'path', { d: 'M8.2 6.5 H13 C16.2 6.5 16.2 12 12 12 C7.8 12 7.8 17.5 11 17.5 H15.8' } ]
37
+ ],
38
+
39
+ // a decision table
40
+ dmn: [
41
+ [ 'rect', { x: 3.5, y: 5, width: 17, height: 14, rx: 1 } ],
42
+ [ 'path', { d: 'M3.5 9.5 H20.5' } ],
43
+ [ 'path', { d: 'M3.5 14.25 H20.5' } ],
44
+ [ 'path', { d: 'M9.5 9.5 V19' } ]
45
+ ],
46
+
47
+ // a briefcase
48
+ case: [
49
+ [ 'rect', { x: 3.5, y: 8, width: 17, height: 11, rx: 1.5 } ],
50
+ [ 'path', { d: 'M9 8 V6.2 C9 5.5 9.5 5 10.2 5 H13.8 C14.5 5 15 5.5 15 6.2 V8' } ],
51
+ [ 'path', { d: 'M3.5 12.5 H20.5' } ]
52
+ ],
53
+
54
+ // a signal sent out
55
+ 'send-event': [
56
+ [ 'circle', { cx: 12, cy: 12, r: 1.8 } ],
57
+ [ 'path', { d: 'M8.6 8.6 C6.7 10.5 6.7 13.5 8.6 15.4' } ],
58
+ [ 'path', { d: 'M15.4 8.6 C17.3 10.5 17.3 13.5 15.4 15.4' } ],
59
+ [ 'path', { d: 'M5.6 5.6 C2.1 9.1 2.1 14.9 5.6 18.4' } ],
60
+ [ 'path', { d: 'M18.4 5.6 C21.9 9.1 21.9 14.9 18.4 18.4' } ]
61
+ ],
62
+
63
+ // work handed out of the process
64
+ 'external-worker': [
65
+ [ 'path', { d: 'M14 4.5 H19.5 V10' } ],
66
+ [ 'path', { d: 'M19.5 4.5 L11 13' } ],
67
+ [ 'path', { d: 'M17 13.5 V18.5 C17 19.1 16.6 19.5 16 19.5 H5.5 C4.9 19.5 4.5 19.1 4.5 18.5 V8 C4.5 7.4 4.9 7 5.5 7 H10.5' } ]
68
+ ]
69
+ };
70
+
71
+ /**
72
+ * Stroke attributes shared by all icons.
73
+ */
74
+ export const ICON_STYLE = {
75
+ fill: 'none',
76
+ 'stroke-width': 1.5,
77
+ 'stroke-linecap': 'round',
78
+ 'stroke-linejoin': 'round'
79
+ };
80
+
81
+ /**
82
+ * An icon as standalone SVG markup.
83
+ *
84
+ * @param {string} type - e.g. 'mail'
85
+ * @param {string} [color='currentColor']
86
+ *
87
+ * @return {string}
88
+ */
89
+ export function toSvg(type, color = 'currentColor') {
90
+ const style = { ...ICON_STYLE, stroke: color };
91
+
92
+ const body = ICONS[type].map(([ tag, attrs ]) => `<${ tag }${ toAttrs(attrs) }/>`).join('');
93
+
94
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"${ toAttrs(style) }>${ body }</svg>`;
95
+ }
96
+
97
+ function toAttrs(attrs) {
98
+ return Object.entries(attrs).map(([ name, value ]) => ` ${ name }="${ value }"`).join('');
99
+ }
@@ -0,0 +1,17 @@
1
+ import ReplaceWithTypedTaskHandler from './ReplaceWithTypedTaskHandler.js';
2
+ import TypedTaskPaletteProvider from './TypedTaskPaletteProvider.js';
3
+ import TypedTaskReplaceMenuProvider from './TypedTaskReplaceMenuProvider.js';
4
+
5
+ /**
6
+ * Palette and replace menu entries for the typed service tasks (mail, HTTP,
7
+ * shell, Camel, decision, case, send event and external worker).
8
+ */
9
+ export default {
10
+ __init__: [
11
+ 'typedTaskPaletteProvider',
12
+ 'typedTaskReplaceMenuProvider',
13
+ [ 'commandStack', commandStack => commandStack.registerHandler('flowable.replaceWithTypedTask', ReplaceWithTypedTaskHandler) ]
14
+ ],
15
+ typedTaskPaletteProvider: [ 'type', TypedTaskPaletteProvider ],
16
+ typedTaskReplaceMenuProvider: [ 'type', TypedTaskReplaceMenuProvider ]
17
+ };
@@ -0,0 +1,23 @@
1
+ import { createFlowableLinterConfig } from './index.js';
2
+
3
+ /**
4
+ * After bpmn-js-bpmnlint read its configuration: lints with the Flowable
5
+ * rules unless `linting.bpmnlint` sets another linter configuration, and
6
+ * shows the issues unless `linting.active` is false.
7
+ */
8
+ export default class FlowableLinting {
9
+
10
+ constructor(config, eventBus, linting) {
11
+ eventBus.once('diagram.init', () => {
12
+ if (!config || !config.bpmnlint) {
13
+ linting.setLinterConfig(createFlowableLinterConfig());
14
+ }
15
+
16
+ if (!config || config.active !== false) {
17
+ linting.toggle(true);
18
+ }
19
+ });
20
+ }
21
+ }
22
+
23
+ FlowableLinting.$inject = [ 'config.linting', 'eventBus', 'linting' ];
@@ -0,0 +1,44 @@
1
+ import StaticResolver from 'bpmnlint/lib/resolver/static-resolver';
2
+
3
+ import calledElement from './rules/called-element.js';
4
+ import serviceTaskImplementation from './rules/service-task-implementation.js';
5
+ import validDurations from './rules/valid-durations.js';
6
+
7
+ const PACKAGE = 'bpmnlint-plugin-flowable';
8
+
9
+ /**
10
+ * The Flowable lint rules, as bpmnlint rule factories by name.
11
+ */
12
+ export const FLOWABLE_RULES = {
13
+ 'called-element': calledElement,
14
+ 'service-task-implementation': serviceTaskImplementation,
15
+ 'valid-durations': validDurations
16
+ };
17
+
18
+ /**
19
+ * A bpmnlint configuration with the Flowable rules, all reported as errors.
20
+ */
21
+ export const flowableLintConfig = {
22
+ rules: Object.fromEntries(Object.keys(FLOWABLE_RULES).map(name => [ `flowable/${ name }`, 'error' ]))
23
+ };
24
+
25
+ /**
26
+ * The linter configuration for bpmn-js-bpmnlint: `{ config, resolver }`.
27
+ *
28
+ * @param {Object} [config] - a bpmnlint configuration; the Flowable rules by
29
+ * default. Rules named `flowable/<rule>` resolve to the Flowable rules;
30
+ * other rules and configurations need a resolver of their own.
31
+ *
32
+ * @return {{ config: Object, resolver: StaticResolver }}
33
+ */
34
+ export function createFlowableLinterConfig(config = flowableLintConfig) {
35
+ const cache = {};
36
+
37
+ Object.entries(FLOWABLE_RULES).forEach(([ name, rule ]) => {
38
+ cache[`rule:${ PACKAGE }/${ name }`] = rule;
39
+ });
40
+
41
+ cache[`config:${ PACKAGE }/recommended`] = flowableLintConfig;
42
+
43
+ return { config, resolver: new StaticResolver(cache) };
44
+ }
@@ -0,0 +1,15 @@
1
+ import LintingModule from 'bpmn-js-bpmnlint';
2
+
3
+ import FlowableLinting from './FlowableLinting.js';
4
+
5
+ /**
6
+ * Lints the diagram with the Flowable rules while it is edited, with
7
+ * bpmn-js-bpmnlint: issues show on the elements, and a button counts them
8
+ * and turns the overlays on and off. Listen to `linting.completed` for the
9
+ * issues, for example to list them in a problems view.
10
+ */
11
+ export default {
12
+ __depends__: [ LintingModule ],
13
+ __init__: [ 'flowableLinting' ],
14
+ flowableLinting: [ 'type', FlowableLinting ]
15
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Each call activity names the process it calls.
3
+ */
4
+ export default function calledElement() {
5
+
6
+ function check(node, reporter) {
7
+ if (!node.$instanceOf('bpmn:CallActivity')) {
8
+ return;
9
+ }
10
+
11
+ const called = node.get('calledElement');
12
+
13
+ if (!called || !called.trim()) {
14
+ reporter.report(node.id, 'Call activity has no called element');
15
+ }
16
+ }
17
+
18
+ return { check };
19
+ }