bpmn-client 1.2.0 → 1.3.2

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/testCLI.ts ADDED
@@ -0,0 +1,163 @@
1
+ //import { BPMNClient } from "bpmn-client";
2
+ import { BPMNClient } from './';
3
+
4
+ import * as readline from 'readline';
5
+
6
+ const dotenv = require('dotenv');
7
+ const res = dotenv.config();
8
+
9
+ const server = new BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
10
+
11
+ const cl = readline.createInterface( process.stdin, process.stdout );
12
+ const question = function(q) {
13
+ return new Promise( (res, rej) => {
14
+ cl.question( q, answer => {
15
+ res(answer);
16
+ })
17
+ });
18
+ };
19
+
20
+ completeUserTask();
21
+
22
+ async function completeUserTask() {
23
+ console.log('Commands:');
24
+ console.log(' q to quit');
25
+ console.log(' s start process ');
26
+ console.log(' lo list outstanding items');
27
+ console.log(' l list instances for a process');
28
+ console.log(' di display Instance information');
29
+ console.log(' i invoke item');
30
+ console.log(' d delete instnaces');
31
+
32
+ let option='';
33
+ var command;
34
+ while(option!=='q')
35
+ {
36
+ command= await question('Enter Command, q to quit\n\r>');
37
+ let opts=command.split(' ');
38
+ option=opts[0];
39
+ switch(option)
40
+ {
41
+ case 'lo':
42
+ console.log("list outstanding items");
43
+ await findItems({ "items.status": "wait"});
44
+ break;
45
+ case 'l':
46
+ console.log("list instances");
47
+ await listInstances();
48
+ break;
49
+ case 'di':
50
+ console.log("displaying ");
51
+ await displayInstance();
52
+ break;
53
+ case 'i':
54
+ console.log("invoking");
55
+ await invoke();
56
+ break;
57
+
58
+ case 's':
59
+ console.log("starting");
60
+ await start();
61
+ break;
62
+ case 'd':
63
+ console.log("deleting");
64
+ await delInstances();
65
+ break;
66
+
67
+ }
68
+
69
+ }
70
+
71
+
72
+ console.log("bye");
73
+
74
+ cl.close();
75
+
76
+ }
77
+ async function start()
78
+ {
79
+ const name = await question('Please provide your process name: ');
80
+ let taskData = await question('Please provide your Task Data (json obj) if any: ');
81
+
82
+ if (taskData === ""){
83
+ taskData = {};
84
+ }else{
85
+ taskData = JSON.parse(taskData.toString());
86
+ }
87
+
88
+ let response=await server.engine.start(name, taskData);
89
+
90
+ console.log("Process "+name+" started:", response.items,'InstanceId',response.id);
91
+ }
92
+ async function findItems(query) {
93
+ var items = await server.datastore.findItems(query);
94
+
95
+ console.log(items);
96
+ for (var i = 0; i < items.length; i++) {
97
+ let item = items[i];
98
+ console.log(`${item.name} - ${item.elementId} instanceId: ${item['instanceId']}`);
99
+ }
100
+
101
+ }
102
+ async function listInstances() {
103
+ const name = await question('Please provide your process name: ');
104
+
105
+ let insts = await server.datastore.findInstances({ name: name})
106
+
107
+ for (var i = 0; i < insts.length; i++) {
108
+ let inst = insts[i];
109
+ console.log(`name: ${inst.name} status: ${inst.status} instanceId: ${inst.id}
110
+ startedAt: ${inst.startedAt} endedAt ${inst.endedAt}`, 'data:', inst.data);
111
+ }
112
+ }
113
+
114
+ async function displayInstance() {
115
+ const instanceId = await question('Please provide your Instance ID: ');
116
+
117
+ let insts = await server.datastore.findInstances({id: instanceId})
118
+
119
+ for (var i = 0; i < insts.length; i++) {
120
+ let inst = insts[i];
121
+ var items = inst.items;
122
+ console.log(`name: ${inst.name} status: ${inst.status} instanceId: ${inst.id}
123
+ startedAt: ${inst.startedAt} endedAt ${inst.endedAt}`,'data:', inst.data);
124
+ for (var j = 0; j < items.length; j++) {
125
+ let item= items[j];
126
+ console.log(`element: ${item.elementId} status: ${item.status} id: ${item.id}`);
127
+ }
128
+ }
129
+ }
130
+ async function invoke()
131
+ {
132
+ const instanceId = await question('Please provide your Instance ID: ');
133
+ const taskId = await question('Please provide your Task ID: ');
134
+ let taskData = await question('Please provide your Task Data (json obj) if any: ');
135
+
136
+ if (taskData === ""){
137
+ taskData = {};
138
+ }else{
139
+ taskData = JSON.parse(taskData.toString());
140
+ }
141
+
142
+ try {
143
+ let response = await server.engine.invoke(
144
+ { id: instanceId, "items.elementId": taskId }
145
+ , taskData);
146
+
147
+ console.log("Completed UserTask:", taskId, response.items);
148
+
149
+ }
150
+ catch (exc) {
151
+ console.log("Invoking task failed for:", taskId, instanceId);
152
+ await findItems({ id: instanceId, "items.elementId": taskId });
153
+
154
+
155
+ }
156
+ }
157
+ async function delInstances() {
158
+ const name = await question('Please provide process name to delete instnaces: ');
159
+
160
+ let response = await server.datastore.deleteInstances({ name: name });
161
+
162
+ console.log("Instances Deleted:", response['result']['deletedCount']);
163
+ }
Binary file
package/test/mocha.opts DELETED
@@ -1,5 +0,0 @@
1
- --timeout 50000
2
- --reporter spec
3
- --recursive
4
- --require ./test/helpers/setup.js
5
- --ui mocha-cakes-2
@@ -1,91 +0,0 @@
1
- const fs = require('fs');
2
-
3
- const source = file = fs.readFileSync('../../WebApp/processes/invoice.bpmn',
4
- { encoding: 'utf8', flag: 'r' });
5
-
6
- const source2 = `
7
- <?xml version="1.0" encoding="UTF-8"?>
8
- <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
9
- <bpmn2:collaboration id="Collaboration_1vzc4e2">
10
- <bpmn2:participant id="Participant_1g6enp2" name="Account Payable" processRef="Process_1" />
11
- <bpmn2:participant id="Participant_1e7gk8x" name="Manager" processRef="Process_0t314on" />
12
- <bpmn2:messageFlow id="MessageFlow_18tfm5f" sourceRef="task_cancelInvoice" targetRef="IntermediateCatchEvent_1xr94uz" />
13
- </bpmn2:collaboration>
14
- <bpmn2:process id="Process_1" isExecutable="false">
15
- <bpmn2:startEvent id="StartEvent_0wntki2">
16
- <bpmn2:outgoing>SequenceFlow_129vlnl</bpmn2:outgoing>
17
- </bpmn2:startEvent>
18
- <bpmn2:userTask id="task_issueInvoice" name="Issue Invoice">
19
- <bpmn2:incoming>SequenceFlow_129vlnl</bpmn2:incoming>
20
- <bpmn2:outgoing>SequenceFlow_1nmqrtq</bpmn2:outgoing>
21
- </bpmn2:userTask>
22
- <bpmn2:sequenceFlow id="SequenceFlow_129vlnl" sourceRef="StartEvent_0wntki2" targetRef="task_issueInvoice" />
23
- <bpmn2:sequenceFlow id="SequenceFlow_1nmqrtq" sourceRef="task_issueInvoice" targetRef="ExclusiveGateway_04dgpye" />
24
- <bpmn2:eventBasedGateway id="ExclusiveGateway_04dgpye">
25
- <bpmn2:incoming>SequenceFlow_1nmqrtq</bpmn2:incoming>
26
- <bpmn2:outgoing>SequenceFlow_147bbuq</bpmn2:outgoing>
27
- <bpmn2:outgoing>SequenceFlow_1ucmquu</bpmn2:outgoing>
28
- <bpmn2:outgoing>SequenceFlow_0dq5qq6</bpmn2:outgoing>
29
- </bpmn2:eventBasedGateway>
30
- <bpmn2:sequenceFlow id="SequenceFlow_147bbuq" sourceRef="ExclusiveGateway_04dgpye" targetRef="receiveTask_payment" />
31
- <bpmn2:sequenceFlow id="SequenceFlow_1ucmquu" sourceRef="ExclusiveGateway_04dgpye" targetRef="event_timer">
32
- <bpmn2:conditionExpression xsi:type="bpmn:tExpression">
33
- <![CDATA[(this.reminderCounter < 3)]]>
34
- </bpmn2:conditionExpression>
35
- </bpmn2:sequenceFlow>
36
- <bpmn2:sequenceFlow id="sequence_timer_reminder" sourceRef="event_timer" targetRef="task_reminder" />
37
- <bpmn2:sequenceFlow id="SequenceFlow_1ml8g8q" sourceRef="receiveTask_payment" targetRef="EndEvent_0sxnxfz" />
38
- <bpmn2:sequenceFlow id="SequenceFlow_0dq5qq6" sourceRef="ExclusiveGateway_04dgpye" targetRef="IntermediateCatchEvent_1xr94uz" />
39
- <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1xr94uz" name="Cancel by Admin">
40
- <bpmn2:incoming>SequenceFlow_0dq5qq6</bpmn2:incoming>
41
- <bpmn2:outgoing>SequenceFlow_0karre6</bpmn2:outgoing>
42
- <bpmn2:messageEventDefinition />
43
- </bpmn2:intermediateCatchEvent>
44
- <bpmn2:sequenceFlow id="SequenceFlow_0karre6" sourceRef="IntermediateCatchEvent_1xr94uz" targetRef="EndEvent_0ypa03q" />
45
- <bpmn2:endEvent id="EndEvent_0ypa03q">
46
- <bpmn2:incoming>SequenceFlow_0karre6</bpmn2:incoming>
47
- <bpmn2:terminateEventDefinition />
48
- </bpmn2:endEvent>
49
- <bpmn2:intermediateCatchEvent id="event_timer" name="30 days later">
50
- <bpmn2:incoming>SequenceFlow_1ucmquu</bpmn2:incoming>
51
- <bpmn2:outgoing>sequence_timer_reminder</bpmn2:outgoing>
52
-
53
- <bpmn2:timerEventDefinition id="TimerEventDefinition_07xu06a">
54
- <bpmn2:timeDuration xsi:type="bpmn2:tExpression">PT2S</bpmn2:timeDuration>
55
- </bpmn2:timerEventDefinition>
56
-
57
- </bpmn2:intermediateCatchEvent>
58
- <bpmn2:sendTask id="task_reminder" name="Issue Reminder">
59
- <script>
60
- <![CDATA[
61
- this.token.log('testing from the inside Issue Reminder ');
62
- ]]>
63
- </script>
64
- <bpmn2:incoming>sequence_timer_reminder</bpmn2:incoming>
65
- </bpmn2:sendTask>
66
- <bpmn2:receiveTask id="receiveTask_payment" name="Got Payment">
67
- <bpmn2:incoming>SequenceFlow_147bbuq</bpmn2:incoming>
68
- <bpmn2:outgoing>SequenceFlow_1ml8g8q</bpmn2:outgoing>
69
- </bpmn2:receiveTask>
70
- <bpmn2:endEvent id="EndEvent_0sxnxfz">
71
- <bpmn2:incoming>SequenceFlow_1ml8g8q</bpmn2:incoming>
72
- </bpmn2:endEvent>
73
- </bpmn2:process>
74
- <bpmn2:process id="Process_0t314on">
75
- <bpmn2:sequenceFlow id="SequenceFlow_1vs4h9e" sourceRef="StartEvent_0loa7qt" targetRef="task_cancelInvoice" />
76
- <bpmn2:sequenceFlow id="SequenceFlow_0yw5wjo" sourceRef="task_cancelInvoice" targetRef="IntermediateThrowEvent_0vasq6m" />
77
- <bpmn2:startEvent id="StartEvent_0loa7qt">
78
- <bpmn2:outgoing>SequenceFlow_1vs4h9e</bpmn2:outgoing>
79
- </bpmn2:startEvent>
80
- <bpmn2:userTask id="task_cancelInvoice" name="Cancel Invoice">
81
- <bpmn2:incoming>SequenceFlow_1vs4h9e</bpmn2:incoming>
82
- <bpmn2:outgoing>SequenceFlow_0yw5wjo</bpmn2:outgoing>
83
- </bpmn2:userTask>
84
- <bpmn2:endEvent id="IntermediateThrowEvent_0vasq6m">
85
- <bpmn2:incoming>SequenceFlow_0yw5wjo</bpmn2:incoming>
86
- </bpmn2:endEvent>
87
- </bpmn2:process>
88
- </bpmn2:definitions>
89
- `;
90
-
91
- module.exports = { source };
@@ -1,69 +0,0 @@
1
- const source = `
2
- <?xml version="1.0" encoding="UTF-8"?>
3
- <bpmn:definitions
4
- xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
5
- xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
6
- xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
7
- xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
8
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9
- xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
10
- exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="6.5.1">
11
- <bpmn:collaboration id="Collaboration_0memx95">
12
- <bpmn:participant id="Participant_1c0lpx5" processRef="Process_1hf9394" />
13
- </bpmn:collaboration>
14
- <bpmn:process id="Process_1hf9394" isExecutable="true">
15
- <bpmn:startEvent id="StartEvent_158yep3">
16
- <bpmn:outgoing>flow_start_buy</bpmn:outgoing>
17
- </bpmn:startEvent>
18
- <bpmn:userTask id="task_Buy" name="Buy">
19
- <bpmn:extensionElements>
20
- <camunda:formData>
21
- <camunda:formField id="repairsRequired" label="Repairs Required?" type="boolean" />
22
- <camunda:formField id="cleaningRequired" label="Cleaning Required?" type="boolean" />
23
- </camunda:formData>
24
- </bpmn:extensionElements>
25
- <bpmn:incoming>flow_start_buy</bpmn:incoming>
26
- <bpmn:outgoing>flow_buy_gateway</bpmn:outgoing>
27
- </bpmn:userTask>
28
- <bpmn:userTask id="task_clean" name="Clean">
29
- <bpmn:incoming>flow_gateway_clean</bpmn:incoming>
30
- <bpmn:outgoing>flow_clean_gateway</bpmn:outgoing>
31
- </bpmn:userTask>
32
- <bpmn:parallelGateway id="gateway_2">
33
- <bpmn:incoming>flow_repair_gateway</bpmn:incoming>
34
- <bpmn:incoming>flow_clean_gateway</bpmn:incoming>
35
- <bpmn:outgoing>flow_gateway_drive</bpmn:outgoing>
36
- </bpmn:parallelGateway>
37
- <bpmn:endEvent id="Event_19ebav7">
38
- <bpmn:incoming>flow_drive_end</bpmn:incoming>
39
- </bpmn:endEvent>
40
- <bpmn:userTask id="task_repair" name="Repair">
41
- <bpmn:incoming>flow_gateway_repair</bpmn:incoming>
42
- <bpmn:outgoing>flow_repair_gateway</bpmn:outgoing>
43
- </bpmn:userTask>
44
- <bpmn:sequenceFlow id="flow_start_buy" sourceRef="StartEvent_158yep3" targetRef="task_Buy" />
45
- <bpmn:sequenceFlow id="flow_buy_gateway" sourceRef="task_Buy" targetRef="gateway_1" />
46
- <bpmn:sequenceFlow id="flow_gateway_repair" sourceRef="gateway_1" targetRef="task_repair">
47
- <bpmn:conditionExpression>(this.needsRepairs==true)</bpmn:conditionExpression>
48
- </bpmn:sequenceFlow >
49
- <bpmn:sequenceFlow id="flow_gateway_clean" sourceRef="gateway_1" targetRef="task_clean">
50
- <bpmn:conditionExpression>(this.needsCleaning==true)</bpmn:conditionExpression>
51
- </bpmn:sequenceFlow >
52
- <bpmn:sequenceFlow id="flow_repair_gateway" sourceRef="task_repair" targetRef="gateway_2" />
53
- <bpmn:sequenceFlow id="flow_clean_gateway" sourceRef="task_clean" targetRef="gateway_2" />
54
- <bpmn:sequenceFlow id="flow_gateway_drive" sourceRef="gateway_2" targetRef="task_Drive" />
55
- <bpmn:sequenceFlow id="flow_drive_end" sourceRef="task_Drive" targetRef="Event_19ebav7" />
56
- <bpmn:userTask id="task_Drive" name="Drive">
57
- <bpmn:incoming>flow_gateway_drive</bpmn:incoming>
58
- <bpmn:outgoing>flow_drive_end</bpmn:outgoing>
59
- </bpmn:userTask>
60
- <bpmn:inclusiveGateway id="gateway_1">
61
- <bpmn:incoming>flow_buy_gateway</bpmn:incoming>
62
- <bpmn:outgoing>flow_gateway_repair</bpmn:outgoing>
63
- <bpmn:outgoing>flow_gateway_clean</bpmn:outgoing>
64
- </bpmn:inclusiveGateway>
65
- </bpmn:process>
66
- </bpmn:definitions>
67
- `;
68
-
69
- module.exports = { source };
@@ -1,50 +0,0 @@
1
-
2
- const source = `
3
- <?xml version="1.0" encoding="UTF-8"?>
4
- <bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
- xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
6
- xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
7
- xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
8
- xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1vpaa20"
9
- targetNamespace="http://bpmn.io/schema/bpmn"
10
- exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="6.5.1">
11
- <bpmn:process id="Process_15krzlx" isExecutable="false">
12
- <bpmn:startEvent id="StartEvent_12lfa5f">
13
- <bpmn:outgoing>Flow_0bb7flg</bpmn:outgoing>
14
- </bpmn:startEvent>
15
- <bpmn:sequenceFlow id="Flow_0bb7flg" sourceRef="StartEvent_12lfa5f" targetRef="scriptTask" />
16
- <bpmn:sequenceFlow id="Flow_03lw5wj" sourceRef="scriptTask" targetRef="serviceTask" />
17
- <bpmn:sequenceFlow id="Flow_0cq93ga" sourceRef="serviceTask" targetRef="sendTask" />
18
- <bpmn:endEvent id="Event_0iwmzob">
19
- <bpmn:incoming>Flow_0wyvfqv</bpmn:incoming>
20
- </bpmn:endEvent>
21
- <bpmn:sequenceFlow id="Flow_0wyvfqv" sourceRef="sendTask" targetRef="Event_0iwmzob" />
22
- <bpmn:scriptTask id="scriptTask" name="ScriptTask">
23
- <script>
24
- <![CDATA[
25
- this.token.log('testing from the inside: '+this.token.data.loopKey);
26
- ]]>
27
- </script>
28
- <bpmn:multiInstanceLoopCharacteristics isSequential="true" js:collection="(this.records)" />
29
- <bpmn:incoming>Flow_0bb7flg</bpmn:incoming>
30
- <bpmn:outgoing>Flow_03lw5wj</bpmn:outgoing>
31
- </bpmn:scriptTask>
32
-
33
-
34
- <bpmn:serviceTask id="serviceTask" name="ServiceTask"
35
- implementation="\{this.token.execution.handler.service1(this);}">
36
- <bpmn:multiInstanceLoopCharacteristics isSequential="false" js:collection="(this.records)" />
37
-
38
- <bpmn:incoming>Flow_03lw5wj</bpmn:incoming>
39
- <bpmn:outgoing>Flow_0cq93ga</bpmn:outgoing>
40
- </bpmn:serviceTask>
41
- <bpmn:sendTask id="sendTask" name="SendTask">
42
- <bpmn:incoming>Flow_0cq93ga</bpmn:incoming>
43
- <bpmn:outgoing>Flow_0wyvfqv</bpmn:outgoing>
44
- </bpmn:sendTask>
45
- </bpmn:process>
46
- </bpmn:definitions>
47
- `;
48
-
49
-
50
- module.exports = { source };