@bpmnkit/core 0.0.8
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 +185 -0
- package/dist/bpmn/auto-layout.d.ts +10 -0
- package/dist/bpmn/auto-layout.js +203 -0
- package/dist/bpmn/bpmn-builder.d.ts +381 -0
- package/dist/bpmn/bpmn-builder.js +1223 -0
- package/dist/bpmn/bpmn-model.d.ts +403 -0
- package/dist/bpmn/bpmn-model.js +2 -0
- package/dist/bpmn/bpmn-parser.d.ts +4 -0
- package/dist/bpmn/bpmn-parser.js +642 -0
- package/dist/bpmn/bpmn-serializer.d.ts +4 -0
- package/dist/bpmn/bpmn-serializer.js +515 -0
- package/dist/bpmn/compact.d.ts +91 -0
- package/dist/bpmn/compact.js +349 -0
- package/dist/bpmn/di-color.d.ts +9 -0
- package/dist/bpmn/di-color.js +32 -0
- package/dist/bpmn/index.d.ts +105 -0
- package/dist/bpmn/index.js +176 -0
- package/dist/bpmn/optimize/feel.d.ts +4 -0
- package/dist/bpmn/optimize/feel.js +186 -0
- package/dist/bpmn/optimize/flow.d.ts +4 -0
- package/dist/bpmn/optimize/flow.js +323 -0
- package/dist/bpmn/optimize/index.d.ts +5 -0
- package/dist/bpmn/optimize/index.js +51 -0
- package/dist/bpmn/optimize/naming.d.ts +8 -0
- package/dist/bpmn/optimize/naming.js +145 -0
- package/dist/bpmn/optimize/tasks.d.ts +4 -0
- package/dist/bpmn/optimize/tasks.js +273 -0
- package/dist/bpmn/optimize/types.d.ts +44 -0
- package/dist/bpmn/optimize/types.js +2 -0
- package/dist/bpmn/optimize/utils.d.ts +23 -0
- package/dist/bpmn/optimize/utils.js +129 -0
- package/dist/bpmn/rest-connector.d.ts +48 -0
- package/dist/bpmn/rest-connector.js +69 -0
- package/dist/bpmn/svg.d.ts +35 -0
- package/dist/bpmn/svg.js +557 -0
- package/dist/bpmn/type-guards.d.ts +136 -0
- package/dist/bpmn/type-guards.js +211 -0
- package/dist/bpmn/utils.d.ts +88 -0
- package/dist/bpmn/utils.js +207 -0
- package/dist/bpmn/zeebe-extensions.d.ts +72 -0
- package/dist/bpmn/zeebe-extensions.js +96 -0
- package/dist/dmn/compact.d.ts +44 -0
- package/dist/dmn/compact.js +125 -0
- package/dist/dmn/dmn-builder.d.ts +59 -0
- package/dist/dmn/dmn-builder.js +144 -0
- package/dist/dmn/dmn-layout.d.ts +57 -0
- package/dist/dmn/dmn-layout.js +256 -0
- package/dist/dmn/dmn-model.d.ts +158 -0
- package/dist/dmn/dmn-model.js +2 -0
- package/dist/dmn/dmn-parser.d.ts +4 -0
- package/dist/dmn/dmn-parser.js +275 -0
- package/dist/dmn/dmn-serializer.d.ts +4 -0
- package/dist/dmn/dmn-serializer.js +296 -0
- package/dist/dmn/index.d.ts +28 -0
- package/dist/dmn/index.js +51 -0
- package/dist/errors.d.ts +77 -0
- package/dist/errors.js +66 -0
- package/dist/form/compact.d.ts +20 -0
- package/dist/form/compact.js +146 -0
- package/dist/form/form-builder.d.ts +111 -0
- package/dist/form/form-builder.js +347 -0
- package/dist/form/form-model.d.ts +221 -0
- package/dist/form/form-model.js +2 -0
- package/dist/form/form-parser.d.ts +4 -0
- package/dist/form/form-parser.js +514 -0
- package/dist/form/form-serializer.d.ts +4 -0
- package/dist/form/form-serializer.js +240 -0
- package/dist/form/index.d.ts +27 -0
- package/dist/form/index.js +43 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +19 -0
- package/dist/layout/bench.d.ts +86 -0
- package/dist/layout/bench.js +225 -0
- package/dist/layout/coordinates.d.ts +62 -0
- package/dist/layout/coordinates.js +868 -0
- package/dist/layout/crossing.d.ts +8 -0
- package/dist/layout/crossing.js +60 -0
- package/dist/layout/graph.d.ts +28 -0
- package/dist/layout/graph.js +126 -0
- package/dist/layout/index.d.ts +7 -0
- package/dist/layout/index.js +5 -0
- package/dist/layout/layers.d.ts +13 -0
- package/dist/layout/layers.js +49 -0
- package/dist/layout/layout-engine.d.ts +21 -0
- package/dist/layout/layout-engine.js +191 -0
- package/dist/layout/overlap.d.ts +10 -0
- package/dist/layout/overlap.js +70 -0
- package/dist/layout/routing.d.ts +26 -0
- package/dist/layout/routing.js +439 -0
- package/dist/layout/subprocess.d.ts +14 -0
- package/dist/layout/subprocess.js +77 -0
- package/dist/layout/types.d.ts +72 -0
- package/dist/layout/types.js +37 -0
- package/dist/types/id-generator.d.ts +8 -0
- package/dist/types/id-generator.js +31 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +2 -0
- package/dist/types/xml-element.d.ts +12 -0
- package/dist/types/xml-element.js +2 -0
- package/dist/xml/index.d.ts +2 -0
- package/dist/xml/index.js +2 -0
- package/dist/xml/xml-parser.d.ts +13 -0
- package/dist/xml/xml-parser.js +271 -0
- package/package.json +38 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { BpmnAdHocSubProcess, BpmnBoundaryEvent, BpmnBusinessRuleTask, BpmnCallActivity, BpmnComplexGateway, BpmnEndEvent, BpmnEventBasedGateway, BpmnEventSubProcess, BpmnExclusiveGateway, BpmnFlowElement, BpmnInclusiveGateway, BpmnIntermediateCatchEvent, BpmnIntermediateThrowEvent, BpmnManualTask, BpmnParallelGateway, BpmnReceiveTask, BpmnScriptTask, BpmnSendTask, BpmnServiceTask, BpmnStartEvent, BpmnSubProcess, BpmnTask, BpmnTransaction, BpmnUserTask } from "./bpmn-model.js";
|
|
2
|
+
/**
|
|
3
|
+
* Narrows a flow element to {@link BpmnStartEvent}.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* for (const el of process.flowElements) {
|
|
8
|
+
* if (isBpmnStartEvent(el)) {
|
|
9
|
+
* console.log("start event definitions:", el.eventDefinitions)
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function isBpmnStartEvent(el: BpmnFlowElement): el is BpmnStartEvent;
|
|
15
|
+
/**
|
|
16
|
+
* Narrows a flow element to {@link BpmnEndEvent}.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isBpmnEndEvent(el: BpmnFlowElement): el is BpmnEndEvent;
|
|
19
|
+
/**
|
|
20
|
+
* Narrows a flow element to {@link BpmnIntermediateCatchEvent}.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isBpmnIntermediateCatchEvent(el: BpmnFlowElement): el is BpmnIntermediateCatchEvent;
|
|
23
|
+
/**
|
|
24
|
+
* Narrows a flow element to {@link BpmnIntermediateThrowEvent}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isBpmnIntermediateThrowEvent(el: BpmnFlowElement): el is BpmnIntermediateThrowEvent;
|
|
27
|
+
/**
|
|
28
|
+
* Narrows a flow element to {@link BpmnBoundaryEvent}.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isBpmnBoundaryEvent(el: BpmnFlowElement): el is BpmnBoundaryEvent;
|
|
31
|
+
/**
|
|
32
|
+
* Returns `true` for any event element (start, end, intermediate catch/throw, boundary).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const events = process.flowElements.filter(isBpmnEvent)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function isBpmnEvent(el: BpmnFlowElement): el is BpmnStartEvent | BpmnEndEvent | BpmnIntermediateCatchEvent | BpmnIntermediateThrowEvent | BpmnBoundaryEvent;
|
|
40
|
+
/**
|
|
41
|
+
* Narrows a flow element to {@link BpmnServiceTask}.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const serviceTasks = process.flowElements.filter(isBpmnServiceTask)
|
|
46
|
+
* // serviceTasks is typed as BpmnServiceTask[]
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function isBpmnServiceTask(el: BpmnFlowElement): el is BpmnServiceTask;
|
|
50
|
+
/**
|
|
51
|
+
* Narrows a flow element to {@link BpmnUserTask}.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isBpmnUserTask(el: BpmnFlowElement): el is BpmnUserTask;
|
|
54
|
+
/**
|
|
55
|
+
* Narrows a flow element to {@link BpmnScriptTask}.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isBpmnScriptTask(el: BpmnFlowElement): el is BpmnScriptTask;
|
|
58
|
+
/**
|
|
59
|
+
* Narrows a flow element to {@link BpmnBusinessRuleTask}.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isBpmnBusinessRuleTask(el: BpmnFlowElement): el is BpmnBusinessRuleTask;
|
|
62
|
+
/**
|
|
63
|
+
* Narrows a flow element to {@link BpmnCallActivity}.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isBpmnCallActivity(el: BpmnFlowElement): el is BpmnCallActivity;
|
|
66
|
+
/**
|
|
67
|
+
* Narrows a flow element to {@link BpmnSendTask}.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isBpmnSendTask(el: BpmnFlowElement): el is BpmnSendTask;
|
|
70
|
+
/**
|
|
71
|
+
* Narrows a flow element to {@link BpmnReceiveTask}.
|
|
72
|
+
*/
|
|
73
|
+
export declare function isBpmnReceiveTask(el: BpmnFlowElement): el is BpmnReceiveTask;
|
|
74
|
+
/**
|
|
75
|
+
* Narrows a flow element to {@link BpmnManualTask}.
|
|
76
|
+
*/
|
|
77
|
+
export declare function isBpmnManualTask(el: BpmnFlowElement): el is BpmnManualTask;
|
|
78
|
+
/**
|
|
79
|
+
* Narrows a flow element to the plain (untyped) {@link BpmnTask}.
|
|
80
|
+
*/
|
|
81
|
+
export declare function isBpmnTask(el: BpmnFlowElement): el is BpmnTask;
|
|
82
|
+
/**
|
|
83
|
+
* Returns `true` for any activity element (all task and sub-process types, call activity).
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const activities = process.flowElements.filter(isBpmnActivity)
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function isBpmnActivity(el: BpmnFlowElement): el is BpmnTask | BpmnServiceTask | BpmnUserTask | BpmnScriptTask | BpmnSendTask | BpmnReceiveTask | BpmnBusinessRuleTask | BpmnManualTask | BpmnCallActivity | BpmnSubProcess | BpmnAdHocSubProcess | BpmnEventSubProcess | BpmnTransaction;
|
|
91
|
+
/**
|
|
92
|
+
* Narrows a flow element to {@link BpmnSubProcess}.
|
|
93
|
+
*/
|
|
94
|
+
export declare function isBpmnSubProcess(el: BpmnFlowElement): el is BpmnSubProcess;
|
|
95
|
+
/**
|
|
96
|
+
* Narrows a flow element to {@link BpmnAdHocSubProcess}.
|
|
97
|
+
*/
|
|
98
|
+
export declare function isBpmnAdHocSubProcess(el: BpmnFlowElement): el is BpmnAdHocSubProcess;
|
|
99
|
+
/**
|
|
100
|
+
* Narrows a flow element to {@link BpmnEventSubProcess}.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isBpmnEventSubProcess(el: BpmnFlowElement): el is BpmnEventSubProcess;
|
|
103
|
+
/**
|
|
104
|
+
* Narrows a flow element to {@link BpmnTransaction}.
|
|
105
|
+
*/
|
|
106
|
+
export declare function isBpmnTransaction(el: BpmnFlowElement): el is BpmnTransaction;
|
|
107
|
+
/**
|
|
108
|
+
* Narrows a flow element to {@link BpmnExclusiveGateway}.
|
|
109
|
+
*/
|
|
110
|
+
export declare function isBpmnExclusiveGateway(el: BpmnFlowElement): el is BpmnExclusiveGateway;
|
|
111
|
+
/**
|
|
112
|
+
* Narrows a flow element to {@link BpmnParallelGateway}.
|
|
113
|
+
*/
|
|
114
|
+
export declare function isBpmnParallelGateway(el: BpmnFlowElement): el is BpmnParallelGateway;
|
|
115
|
+
/**
|
|
116
|
+
* Narrows a flow element to {@link BpmnInclusiveGateway}.
|
|
117
|
+
*/
|
|
118
|
+
export declare function isBpmnInclusiveGateway(el: BpmnFlowElement): el is BpmnInclusiveGateway;
|
|
119
|
+
/**
|
|
120
|
+
* Narrows a flow element to {@link BpmnEventBasedGateway}.
|
|
121
|
+
*/
|
|
122
|
+
export declare function isBpmnEventBasedGateway(el: BpmnFlowElement): el is BpmnEventBasedGateway;
|
|
123
|
+
/**
|
|
124
|
+
* Narrows a flow element to {@link BpmnComplexGateway}.
|
|
125
|
+
*/
|
|
126
|
+
export declare function isBpmnComplexGateway(el: BpmnFlowElement): el is BpmnComplexGateway;
|
|
127
|
+
/**
|
|
128
|
+
* Returns `true` for any gateway element (exclusive, parallel, inclusive, event-based, complex).
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const gateways = process.flowElements.filter(isBpmnGateway)
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare function isBpmnGateway(el: BpmnFlowElement): el is BpmnExclusiveGateway | BpmnParallelGateway | BpmnInclusiveGateway | BpmnEventBasedGateway | BpmnComplexGateway;
|
|
136
|
+
//# sourceMappingURL=type-guards.d.ts.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// ── Events ────────────────────────────────────────────────────────────────────
|
|
2
|
+
/**
|
|
3
|
+
* Narrows a flow element to {@link BpmnStartEvent}.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* for (const el of process.flowElements) {
|
|
8
|
+
* if (isBpmnStartEvent(el)) {
|
|
9
|
+
* console.log("start event definitions:", el.eventDefinitions)
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function isBpmnStartEvent(el) {
|
|
15
|
+
return el.type === "startEvent";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Narrows a flow element to {@link BpmnEndEvent}.
|
|
19
|
+
*/
|
|
20
|
+
export function isBpmnEndEvent(el) {
|
|
21
|
+
return el.type === "endEvent";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Narrows a flow element to {@link BpmnIntermediateCatchEvent}.
|
|
25
|
+
*/
|
|
26
|
+
export function isBpmnIntermediateCatchEvent(el) {
|
|
27
|
+
return el.type === "intermediateCatchEvent";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Narrows a flow element to {@link BpmnIntermediateThrowEvent}.
|
|
31
|
+
*/
|
|
32
|
+
export function isBpmnIntermediateThrowEvent(el) {
|
|
33
|
+
return el.type === "intermediateThrowEvent";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Narrows a flow element to {@link BpmnBoundaryEvent}.
|
|
37
|
+
*/
|
|
38
|
+
export function isBpmnBoundaryEvent(el) {
|
|
39
|
+
return el.type === "boundaryEvent";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns `true` for any event element (start, end, intermediate catch/throw, boundary).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const events = process.flowElements.filter(isBpmnEvent)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function isBpmnEvent(el) {
|
|
50
|
+
return (el.type === "startEvent" ||
|
|
51
|
+
el.type === "endEvent" ||
|
|
52
|
+
el.type === "intermediateCatchEvent" ||
|
|
53
|
+
el.type === "intermediateThrowEvent" ||
|
|
54
|
+
el.type === "boundaryEvent");
|
|
55
|
+
}
|
|
56
|
+
// ── Tasks ─────────────────────────────────────────────────────────────────────
|
|
57
|
+
/**
|
|
58
|
+
* Narrows a flow element to {@link BpmnServiceTask}.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const serviceTasks = process.flowElements.filter(isBpmnServiceTask)
|
|
63
|
+
* // serviceTasks is typed as BpmnServiceTask[]
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function isBpmnServiceTask(el) {
|
|
67
|
+
return el.type === "serviceTask";
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Narrows a flow element to {@link BpmnUserTask}.
|
|
71
|
+
*/
|
|
72
|
+
export function isBpmnUserTask(el) {
|
|
73
|
+
return el.type === "userTask";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Narrows a flow element to {@link BpmnScriptTask}.
|
|
77
|
+
*/
|
|
78
|
+
export function isBpmnScriptTask(el) {
|
|
79
|
+
return el.type === "scriptTask";
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Narrows a flow element to {@link BpmnBusinessRuleTask}.
|
|
83
|
+
*/
|
|
84
|
+
export function isBpmnBusinessRuleTask(el) {
|
|
85
|
+
return el.type === "businessRuleTask";
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Narrows a flow element to {@link BpmnCallActivity}.
|
|
89
|
+
*/
|
|
90
|
+
export function isBpmnCallActivity(el) {
|
|
91
|
+
return el.type === "callActivity";
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Narrows a flow element to {@link BpmnSendTask}.
|
|
95
|
+
*/
|
|
96
|
+
export function isBpmnSendTask(el) {
|
|
97
|
+
return el.type === "sendTask";
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Narrows a flow element to {@link BpmnReceiveTask}.
|
|
101
|
+
*/
|
|
102
|
+
export function isBpmnReceiveTask(el) {
|
|
103
|
+
return el.type === "receiveTask";
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Narrows a flow element to {@link BpmnManualTask}.
|
|
107
|
+
*/
|
|
108
|
+
export function isBpmnManualTask(el) {
|
|
109
|
+
return el.type === "manualTask";
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Narrows a flow element to the plain (untyped) {@link BpmnTask}.
|
|
113
|
+
*/
|
|
114
|
+
export function isBpmnTask(el) {
|
|
115
|
+
return el.type === "task";
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns `true` for any activity element (all task and sub-process types, call activity).
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const activities = process.flowElements.filter(isBpmnActivity)
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export function isBpmnActivity(el) {
|
|
126
|
+
return (el.type === "task" ||
|
|
127
|
+
el.type === "serviceTask" ||
|
|
128
|
+
el.type === "userTask" ||
|
|
129
|
+
el.type === "scriptTask" ||
|
|
130
|
+
el.type === "sendTask" ||
|
|
131
|
+
el.type === "receiveTask" ||
|
|
132
|
+
el.type === "businessRuleTask" ||
|
|
133
|
+
el.type === "manualTask" ||
|
|
134
|
+
el.type === "callActivity" ||
|
|
135
|
+
el.type === "subProcess" ||
|
|
136
|
+
el.type === "adHocSubProcess" ||
|
|
137
|
+
el.type === "eventSubProcess" ||
|
|
138
|
+
el.type === "transaction");
|
|
139
|
+
}
|
|
140
|
+
// ── Sub-processes ─────────────────────────────────────────────────────────────
|
|
141
|
+
/**
|
|
142
|
+
* Narrows a flow element to {@link BpmnSubProcess}.
|
|
143
|
+
*/
|
|
144
|
+
export function isBpmnSubProcess(el) {
|
|
145
|
+
return el.type === "subProcess";
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Narrows a flow element to {@link BpmnAdHocSubProcess}.
|
|
149
|
+
*/
|
|
150
|
+
export function isBpmnAdHocSubProcess(el) {
|
|
151
|
+
return el.type === "adHocSubProcess";
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Narrows a flow element to {@link BpmnEventSubProcess}.
|
|
155
|
+
*/
|
|
156
|
+
export function isBpmnEventSubProcess(el) {
|
|
157
|
+
return el.type === "eventSubProcess";
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Narrows a flow element to {@link BpmnTransaction}.
|
|
161
|
+
*/
|
|
162
|
+
export function isBpmnTransaction(el) {
|
|
163
|
+
return el.type === "transaction";
|
|
164
|
+
}
|
|
165
|
+
// ── Gateways ──────────────────────────────────────────────────────────────────
|
|
166
|
+
/**
|
|
167
|
+
* Narrows a flow element to {@link BpmnExclusiveGateway}.
|
|
168
|
+
*/
|
|
169
|
+
export function isBpmnExclusiveGateway(el) {
|
|
170
|
+
return el.type === "exclusiveGateway";
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Narrows a flow element to {@link BpmnParallelGateway}.
|
|
174
|
+
*/
|
|
175
|
+
export function isBpmnParallelGateway(el) {
|
|
176
|
+
return el.type === "parallelGateway";
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Narrows a flow element to {@link BpmnInclusiveGateway}.
|
|
180
|
+
*/
|
|
181
|
+
export function isBpmnInclusiveGateway(el) {
|
|
182
|
+
return el.type === "inclusiveGateway";
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Narrows a flow element to {@link BpmnEventBasedGateway}.
|
|
186
|
+
*/
|
|
187
|
+
export function isBpmnEventBasedGateway(el) {
|
|
188
|
+
return el.type === "eventBasedGateway";
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Narrows a flow element to {@link BpmnComplexGateway}.
|
|
192
|
+
*/
|
|
193
|
+
export function isBpmnComplexGateway(el) {
|
|
194
|
+
return el.type === "complexGateway";
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Returns `true` for any gateway element (exclusive, parallel, inclusive, event-based, complex).
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const gateways = process.flowElements.filter(isBpmnGateway)
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export function isBpmnGateway(el) {
|
|
205
|
+
return (el.type === "exclusiveGateway" ||
|
|
206
|
+
el.type === "parallelGateway" ||
|
|
207
|
+
el.type === "inclusiveGateway" ||
|
|
208
|
+
el.type === "eventBasedGateway" ||
|
|
209
|
+
el.type === "complexGateway");
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=type-guards.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { XmlElement } from "../types/xml-element.js";
|
|
2
|
+
import type { BpmnDefinitions, BpmnElementType, BpmnFlowElement, BpmnProcess, BpmnSequenceFlow } from "./bpmn-model.js";
|
|
3
|
+
import type { ZeebeExtensions } from "./zeebe-extensions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Finds the first process in a definitions document with the given id.
|
|
6
|
+
* Returns `undefined` if no process matches.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { Bpmn, findProcess } from "@bpmnkit/core"
|
|
11
|
+
*
|
|
12
|
+
* const defs = Bpmn.parse(xml)
|
|
13
|
+
* const proc = findProcess(defs, "order-process")
|
|
14
|
+
* if (proc) console.log(proc.flowElements.length)
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function findProcess(defs: BpmnDefinitions, id: string): BpmnProcess | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Finds a flow element (task, event, gateway, sub-process) by id across all
|
|
20
|
+
* processes in the definitions document.
|
|
21
|
+
*
|
|
22
|
+
* Searches nested sub-process contents recursively.
|
|
23
|
+
* Returns `undefined` if no element with that id exists.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { Bpmn, findElement, isBpmnServiceTask } from "@bpmnkit/core"
|
|
28
|
+
*
|
|
29
|
+
* const defs = Bpmn.parse(xml)
|
|
30
|
+
* const el = findElement(defs, "task1")
|
|
31
|
+
* if (el && isBpmnServiceTask(el)) {
|
|
32
|
+
* console.log("service task:", el.name)
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function findElement(defs: BpmnDefinitions, id: string): BpmnFlowElement | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Finds a flow element by id within a single process (including nested
|
|
39
|
+
* sub-process contents, searched recursively).
|
|
40
|
+
*/
|
|
41
|
+
export declare function findElementInProcess(proc: BpmnProcess, id: string): BpmnFlowElement | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Finds a sequence flow by id within a process (searches nested containers).
|
|
44
|
+
* Returns `undefined` if not found.
|
|
45
|
+
*/
|
|
46
|
+
export declare function findSequenceFlow(proc: BpmnProcess, id: string): BpmnSequenceFlow | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the `BpmnElementType` string for the element with the given id, or
|
|
49
|
+
* `"sequenceFlow"` if it is a sequence flow, or `undefined` if not found.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const type = getElementType(defs, "task1")
|
|
54
|
+
* // "serviceTask" | "userTask" | "sequenceFlow" | undefined
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function getElementType(defs: BpmnDefinitions, id: string): BpmnElementType | "sequenceFlow" | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Collects every flow element across all processes in the definitions document
|
|
60
|
+
* (top-level only, not recursing into sub-processes).
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const allElements = getAllElements(defs)
|
|
65
|
+
* const tasks = allElements.filter(isBpmnTask)
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function getAllElements(defs: BpmnDefinitions): BpmnFlowElement[];
|
|
69
|
+
/**
|
|
70
|
+
* Extracts Zeebe extension data from the raw `extensionElements` array of a
|
|
71
|
+
* flow element. This is the inverse of {@link zeebeExtensionsToXmlElements}.
|
|
72
|
+
*
|
|
73
|
+
* All fields are optional — only those present in the XML are returned.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { Bpmn, findElement, getZeebeExtensions, isBpmnServiceTask } from "@bpmnkit/core"
|
|
78
|
+
*
|
|
79
|
+
* const defs = Bpmn.parse(xml)
|
|
80
|
+
* const el = findElement(defs, "task1")
|
|
81
|
+
* if (el && isBpmnServiceTask(el)) {
|
|
82
|
+
* const ext = getZeebeExtensions(el.extensionElements)
|
|
83
|
+
* console.log(ext.taskDefinition?.type)
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function getZeebeExtensions(extensionElements: XmlElement[]): ZeebeExtensions;
|
|
88
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// ── Process / element lookup ──────────────────────────────────────────────────
|
|
2
|
+
/**
|
|
3
|
+
* Finds the first process in a definitions document with the given id.
|
|
4
|
+
* Returns `undefined` if no process matches.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { Bpmn, findProcess } from "@bpmnkit/core"
|
|
9
|
+
*
|
|
10
|
+
* const defs = Bpmn.parse(xml)
|
|
11
|
+
* const proc = findProcess(defs, "order-process")
|
|
12
|
+
* if (proc) console.log(proc.flowElements.length)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function findProcess(defs, id) {
|
|
16
|
+
return defs.processes.find((p) => p.id === id);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Finds a flow element (task, event, gateway, sub-process) by id across all
|
|
20
|
+
* processes in the definitions document.
|
|
21
|
+
*
|
|
22
|
+
* Searches nested sub-process contents recursively.
|
|
23
|
+
* Returns `undefined` if no element with that id exists.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { Bpmn, findElement, isBpmnServiceTask } from "@bpmnkit/core"
|
|
28
|
+
*
|
|
29
|
+
* const defs = Bpmn.parse(xml)
|
|
30
|
+
* const el = findElement(defs, "task1")
|
|
31
|
+
* if (el && isBpmnServiceTask(el)) {
|
|
32
|
+
* console.log("service task:", el.name)
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function findElement(defs, id) {
|
|
37
|
+
for (const proc of defs.processes) {
|
|
38
|
+
const found = findElementInProcess(proc, id);
|
|
39
|
+
if (found)
|
|
40
|
+
return found;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Finds a flow element by id within a single process (including nested
|
|
46
|
+
* sub-process contents, searched recursively).
|
|
47
|
+
*/
|
|
48
|
+
export function findElementInProcess(proc, id) {
|
|
49
|
+
return searchFlowElements(proc.flowElements, id);
|
|
50
|
+
}
|
|
51
|
+
function searchFlowElements(elements, id) {
|
|
52
|
+
for (const el of elements) {
|
|
53
|
+
if (el.id === id)
|
|
54
|
+
return el;
|
|
55
|
+
// Recurse into containers
|
|
56
|
+
if (el.type === "subProcess" ||
|
|
57
|
+
el.type === "adHocSubProcess" ||
|
|
58
|
+
el.type === "eventSubProcess" ||
|
|
59
|
+
el.type === "transaction") {
|
|
60
|
+
const nested = searchFlowElements(el.flowElements, id);
|
|
61
|
+
if (nested)
|
|
62
|
+
return nested;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Finds a sequence flow by id within a process (searches nested containers).
|
|
69
|
+
* Returns `undefined` if not found.
|
|
70
|
+
*/
|
|
71
|
+
export function findSequenceFlow(proc, id) {
|
|
72
|
+
return searchSequenceFlows(proc, id);
|
|
73
|
+
}
|
|
74
|
+
function searchSequenceFlows(proc, id) {
|
|
75
|
+
const direct = proc.sequenceFlows.find((sf) => sf.id === id);
|
|
76
|
+
if (direct)
|
|
77
|
+
return direct;
|
|
78
|
+
for (const el of proc.flowElements) {
|
|
79
|
+
if (el.type === "subProcess" ||
|
|
80
|
+
el.type === "adHocSubProcess" ||
|
|
81
|
+
el.type === "eventSubProcess" ||
|
|
82
|
+
el.type === "transaction") {
|
|
83
|
+
const nested = searchSequenceFlows(el, id);
|
|
84
|
+
if (nested)
|
|
85
|
+
return nested;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the `BpmnElementType` string for the element with the given id, or
|
|
92
|
+
* `"sequenceFlow"` if it is a sequence flow, or `undefined` if not found.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const type = getElementType(defs, "task1")
|
|
97
|
+
* // "serviceTask" | "userTask" | "sequenceFlow" | undefined
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export function getElementType(defs, id) {
|
|
101
|
+
for (const proc of defs.processes) {
|
|
102
|
+
const el = findElementInProcess(proc, id);
|
|
103
|
+
if (el)
|
|
104
|
+
return el.type;
|
|
105
|
+
if (findSequenceFlow(proc, id))
|
|
106
|
+
return "sequenceFlow";
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Collects every flow element across all processes in the definitions document
|
|
112
|
+
* (top-level only, not recursing into sub-processes).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const allElements = getAllElements(defs)
|
|
117
|
+
* const tasks = allElements.filter(isBpmnTask)
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export function getAllElements(defs) {
|
|
121
|
+
return defs.processes.flatMap((p) => p.flowElements);
|
|
122
|
+
}
|
|
123
|
+
// ── Zeebe extension extraction ────────────────────────────────────────────────
|
|
124
|
+
function localName(qualifiedName) {
|
|
125
|
+
const idx = qualifiedName.indexOf(":");
|
|
126
|
+
return idx >= 0 ? qualifiedName.slice(idx + 1) : qualifiedName;
|
|
127
|
+
}
|
|
128
|
+
function findChildren(elements, tag) {
|
|
129
|
+
return elements.filter((c) => localName(c.name) === tag);
|
|
130
|
+
}
|
|
131
|
+
function findChild(elements, tag) {
|
|
132
|
+
return elements.find((c) => localName(c.name) === tag);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Extracts Zeebe extension data from the raw `extensionElements` array of a
|
|
136
|
+
* flow element. This is the inverse of {@link zeebeExtensionsToXmlElements}.
|
|
137
|
+
*
|
|
138
|
+
* All fields are optional — only those present in the XML are returned.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* import { Bpmn, findElement, getZeebeExtensions, isBpmnServiceTask } from "@bpmnkit/core"
|
|
143
|
+
*
|
|
144
|
+
* const defs = Bpmn.parse(xml)
|
|
145
|
+
* const el = findElement(defs, "task1")
|
|
146
|
+
* if (el && isBpmnServiceTask(el)) {
|
|
147
|
+
* const ext = getZeebeExtensions(el.extensionElements)
|
|
148
|
+
* console.log(ext.taskDefinition?.type)
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export function getZeebeExtensions(extensionElements) {
|
|
153
|
+
const ext = {};
|
|
154
|
+
const taskDef = findChild(extensionElements, "taskDefinition");
|
|
155
|
+
if (taskDef) {
|
|
156
|
+
const taskDefVal = { type: taskDef.attributes.type ?? "" };
|
|
157
|
+
if (taskDef.attributes.retries !== undefined) {
|
|
158
|
+
taskDefVal.retries = taskDef.attributes.retries;
|
|
159
|
+
}
|
|
160
|
+
ext.taskDefinition = taskDefVal;
|
|
161
|
+
}
|
|
162
|
+
const ioMappingEl = findChild(extensionElements, "ioMapping");
|
|
163
|
+
if (ioMappingEl) {
|
|
164
|
+
const inputs = findChildren(ioMappingEl.children, "input").map((c) => ({
|
|
165
|
+
source: c.attributes.source ?? "",
|
|
166
|
+
target: c.attributes.target ?? "",
|
|
167
|
+
}));
|
|
168
|
+
const outputs = findChildren(ioMappingEl.children, "output").map((c) => ({ source: c.attributes.source ?? "", target: c.attributes.target ?? "" }));
|
|
169
|
+
const ioMapping = { inputs, outputs };
|
|
170
|
+
ext.ioMapping = ioMapping;
|
|
171
|
+
}
|
|
172
|
+
const headersEl = findChild(extensionElements, "taskHeaders");
|
|
173
|
+
if (headersEl) {
|
|
174
|
+
const taskHeaders = {
|
|
175
|
+
headers: findChildren(headersEl.children, "header").map((c) => ({
|
|
176
|
+
key: c.attributes.key ?? "",
|
|
177
|
+
value: c.attributes.value ?? "",
|
|
178
|
+
})),
|
|
179
|
+
};
|
|
180
|
+
ext.taskHeaders = taskHeaders;
|
|
181
|
+
}
|
|
182
|
+
const propsEl = findChild(extensionElements, "properties");
|
|
183
|
+
if (propsEl) {
|
|
184
|
+
const properties = {
|
|
185
|
+
properties: findChildren(propsEl.children, "property").map((c) => ({
|
|
186
|
+
name: c.attributes.name ?? "",
|
|
187
|
+
value: c.attributes.value ?? "",
|
|
188
|
+
})),
|
|
189
|
+
};
|
|
190
|
+
ext.properties = properties;
|
|
191
|
+
}
|
|
192
|
+
const formDefEl = findChild(extensionElements, "formDefinition");
|
|
193
|
+
if (formDefEl) {
|
|
194
|
+
const formDefinition = { formId: formDefEl.attributes.formId ?? "" };
|
|
195
|
+
ext.formDefinition = formDefinition;
|
|
196
|
+
}
|
|
197
|
+
const calledDecEl = findChild(extensionElements, "calledDecision");
|
|
198
|
+
if (calledDecEl) {
|
|
199
|
+
const calledDecision = {
|
|
200
|
+
decisionId: calledDecEl.attributes.decisionId ?? "",
|
|
201
|
+
resultVariable: calledDecEl.attributes.resultVariable ?? "",
|
|
202
|
+
};
|
|
203
|
+
ext.calledDecision = calledDecision;
|
|
204
|
+
}
|
|
205
|
+
return ext;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=utils.js.map
|