bpmn-client 1.0.2 → 1.2.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.
Files changed (44) hide show
  1. package/.env +4 -0
  2. package/Sample/.env +4 -0
  3. package/Sample/CarExample.js +62 -0
  4. package/Sample/CarExample.ts +97 -0
  5. package/Sample/package.json +44 -0
  6. package/Sample/test.js +33 -0
  7. package/Sample/test.ts +32 -0
  8. package/Sample/tsconfig.json +17 -0
  9. package/index.js +10 -18
  10. package/index.ts +1 -139
  11. package/package.json +9 -25
  12. package/src/BPMNClient.js +235 -0
  13. package/src/BPMNClient.ts +236 -0
  14. package/src/index.js +15 -0
  15. package/src/index.ts +4 -0
  16. package/src/interfaces/DataObjects.js +2 -0
  17. package/src/interfaces/DataObjects.ts +97 -0
  18. package/src/interfaces/Enums.js +117 -0
  19. package/src/interfaces/Enums.ts +71 -0
  20. package/test/.eslintrc.json +20 -0
  21. package/test/feature/.env +5 -0
  22. package/test/feature/carServer.js +117 -0
  23. package/test/helpers/setup.js +9 -0
  24. package/test/logs/Buy Used Carrepairsfalse cleaning +0 -0
  25. package/test/logs/Buy Used Carrepairstrue cleaning +0 -0
  26. package/test/logs/Buy Used Carscenario CaseId +0 -0
  27. package/test/logs/carrepairsfalse cleaning +0 -0
  28. package/test/logs/carrepairstrue cleaning +0 -0
  29. package/test/mocha.opts +5 -0
  30. package/test/resources/Invoice.js +91 -0
  31. package/test/resources/car.js +69 -0
  32. package/test/resources/loop.js +50 -0
  33. package/test.js +64 -0
  34. package/test.ts +94 -4
  35. package/test2.js +270 -0
  36. package/test2.ts +326 -0
  37. package/tsconfig.json +4 -4
  38. package/BPMNClient.d.ts +0 -36
  39. package/BPMNClient.js +0 -144
  40. package/BPMNClient.js.map +0 -1
  41. package/BPMNClient.ts +0 -139
  42. package/index.d.ts +0 -1
  43. package/index.js.map +0 -1
  44. package/npm.list +0 -579
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NODE_SUBTYPE = exports.EXECUTION_STATUS = exports.TOKEN_STATUS = exports.ITEM_STATUS = exports.FLOW_ACTION = exports.NODE_ACTION = exports.EXECUTION_EVENT = exports.BPMN_TYPE = void 0;
4
+ var BPMN_TYPE;
5
+ (function (BPMN_TYPE) {
6
+ BPMN_TYPE["UserTask"] = "bpmn:UserTask";
7
+ BPMN_TYPE["ScriptTask"] = "bpmn:ScriptTask";
8
+ BPMN_TYPE["ServiceTask"] = "bpmn:ServiceTask";
9
+ BPMN_TYPE["SendTask"] = "bpmn:SendTask";
10
+ BPMN_TYPE["ReceiveTask"] = "bpmn:ReceiveTask";
11
+ BPMN_TYPE["BusinessRuleTask"] = "bpmn:BusinessRuleTask";
12
+ BPMN_TYPE["SubProcess"] = "bpmn:SubProces";
13
+ BPMN_TYPE["ParallelGateway"] = "bpmn:ParallelGateway";
14
+ BPMN_TYPE["EventBasedGateway"] = "bpmn:EventBasedGateway";
15
+ BPMN_TYPE["InclusiveGateway"] = "bpmn:InclusiveGateway";
16
+ BPMN_TYPE["ExclusiveGateway"] = "bpmn:ExclusiveGateway";
17
+ BPMN_TYPE["BoundaryEvent"] = "bpmn:BoundaryEvent";
18
+ BPMN_TYPE["StartEvent"] = "bpmn:StartEvent";
19
+ BPMN_TYPE["IntermediateCatchEvent"] = "bpmn:IntermediateCatchEvent";
20
+ BPMN_TYPE["IntermediateThrowEvent"] = "bpmn:IntermediateThrowEvent";
21
+ BPMN_TYPE["EndEvent"] = "bpmn:EndEvent";
22
+ BPMN_TYPE["SequenceFlow"] = "bpmn:SequenceFlow";
23
+ BPMN_TYPE["MessageFlow"] = "bpmn:MessageFlow";
24
+ BPMN_TYPE["CallActivity"] = "bpmn:CallActivity";
25
+ })(BPMN_TYPE || (BPMN_TYPE = {}));
26
+ exports.BPMN_TYPE = BPMN_TYPE;
27
+ var NODE_SUBTYPE;
28
+ (function (NODE_SUBTYPE) {
29
+ NODE_SUBTYPE["timer"] = "timer";
30
+ NODE_SUBTYPE["message"] = "message";
31
+ NODE_SUBTYPE["signal"] = "signal";
32
+ NODE_SUBTYPE["error"] = "error";
33
+ NODE_SUBTYPE["escalation"] = "escalation";
34
+ })(NODE_SUBTYPE || (NODE_SUBTYPE = {}));
35
+ exports.NODE_SUBTYPE = NODE_SUBTYPE;
36
+ /*
37
+ * ALL events
38
+ */
39
+ var EXECUTION_EVENT;
40
+ (function (EXECUTION_EVENT) {
41
+ EXECUTION_EVENT["node_enter"] = "enter";
42
+ EXECUTION_EVENT["node_start"] = "start";
43
+ EXECUTION_EVENT["node_wait"] = "wait";
44
+ EXECUTION_EVENT["node_end"] = "end";
45
+ EXECUTION_EVENT["node_terminated"] = "terminated";
46
+ EXECUTION_EVENT["transform_input"] = "transformInput";
47
+ EXECUTION_EVENT["transform_output"] = "transformOutput";
48
+ EXECUTION_EVENT["flow_take"] = "take";
49
+ EXECUTION_EVENT["flow_discard"] = "discard";
50
+ EXECUTION_EVENT["process_loaded"] = "process.loaded";
51
+ EXECUTION_EVENT["process_start"] = "process.start";
52
+ EXECUTION_EVENT["process_started"] = "process.started";
53
+ EXECUTION_EVENT["process_invoke"] = "process.invoke";
54
+ EXECUTION_EVENT["process_invoked"] = "process.invoked";
55
+ EXECUTION_EVENT["process_restored"] = "process.restored";
56
+ EXECUTION_EVENT["process_resumed"] = "process_resumed";
57
+ EXECUTION_EVENT["process_wait"] = "process.wait";
58
+ EXECUTION_EVENT["process_end"] = "process.end";
59
+ EXECUTION_EVENT["process_terminated"] = "executeion.terminate";
60
+ EXECUTION_EVENT["token_start"] = "token.start";
61
+ EXECUTION_EVENT["token_wait"] = "token.wait";
62
+ EXECUTION_EVENT["token_end"] = "token.end";
63
+ EXECUTION_EVENT["token_terminated"] = "token.terminated";
64
+ })(EXECUTION_EVENT || (EXECUTION_EVENT = {}));
65
+ exports.EXECUTION_EVENT = EXECUTION_EVENT;
66
+ /*
67
+ * possible actions by node
68
+ */
69
+ // must be same as above
70
+ var NODE_ACTION;
71
+ (function (NODE_ACTION) {
72
+ NODE_ACTION[NODE_ACTION["continue"] = 1] = "continue";
73
+ NODE_ACTION[NODE_ACTION["wait"] = 2] = "wait";
74
+ NODE_ACTION[NODE_ACTION["end"] = 3] = "end";
75
+ NODE_ACTION[NODE_ACTION["stop"] = 4] = "stop";
76
+ NODE_ACTION[NODE_ACTION["error"] = 5] = "error";
77
+ NODE_ACTION[NODE_ACTION["abort"] = 6] = "abort";
78
+ })(NODE_ACTION || (NODE_ACTION = {}));
79
+ exports.NODE_ACTION = NODE_ACTION;
80
+ ;
81
+ var ITEM_STATUS;
82
+ (function (ITEM_STATUS) {
83
+ ITEM_STATUS["enter"] = "enter";
84
+ ITEM_STATUS["start"] = "start";
85
+ ITEM_STATUS["wait"] = "wait";
86
+ ITEM_STATUS["end"] = "end";
87
+ ITEM_STATUS["terminated"] = "terminated";
88
+ ITEM_STATUS["discard"] = "discard";
89
+ })(ITEM_STATUS || (ITEM_STATUS = {}));
90
+ exports.ITEM_STATUS = ITEM_STATUS;
91
+ //type ITEMSTATUS = 'enter' | 'start' | 'wait' | 'end' | 'terminated' | 'discard';
92
+ var EXECUTION_STATUS;
93
+ (function (EXECUTION_STATUS) {
94
+ EXECUTION_STATUS["running"] = "running";
95
+ EXECUTION_STATUS["wait"] = "wait";
96
+ EXECUTION_STATUS["end"] = "end";
97
+ EXECUTION_STATUS["terminated"] = "terminated";
98
+ })(EXECUTION_STATUS || (EXECUTION_STATUS = {}));
99
+ exports.EXECUTION_STATUS = EXECUTION_STATUS;
100
+ var TOKEN_STATUS;
101
+ (function (TOKEN_STATUS) {
102
+ TOKEN_STATUS["running"] = "running";
103
+ TOKEN_STATUS["wait"] = "wait";
104
+ TOKEN_STATUS["end"] = "end";
105
+ TOKEN_STATUS["terminated"] = "terminated";
106
+ })(TOKEN_STATUS || (TOKEN_STATUS = {}));
107
+ exports.TOKEN_STATUS = TOKEN_STATUS;
108
+ /*
109
+ * possible actions by flow
110
+ */
111
+ // must be same as above
112
+ var FLOW_ACTION;
113
+ (function (FLOW_ACTION) {
114
+ FLOW_ACTION["take"] = "take";
115
+ FLOW_ACTION["discard"] = "discard";
116
+ })(FLOW_ACTION || (FLOW_ACTION = {}));
117
+ exports.FLOW_ACTION = FLOW_ACTION;
@@ -0,0 +1,71 @@
1
+
2
+ enum BPMN_TYPE {
3
+ UserTask = 'bpmn:UserTask',
4
+ ScriptTask = 'bpmn:ScriptTask',
5
+ ServiceTask = 'bpmn:ServiceTask',
6
+ SendTask = 'bpmn:SendTask',
7
+ ReceiveTask = 'bpmn:ReceiveTask',
8
+ BusinessRuleTask = 'bpmn:BusinessRuleTask',
9
+ SubProcess = 'bpmn:SubProces',
10
+ ParallelGateway = 'bpmn:ParallelGateway',
11
+ EventBasedGateway = 'bpmn:EventBasedGateway',
12
+ InclusiveGateway = 'bpmn:InclusiveGateway',
13
+ ExclusiveGateway = 'bpmn:ExclusiveGateway',
14
+ BoundaryEvent = 'bpmn:BoundaryEvent',
15
+ StartEvent = 'bpmn:StartEvent',
16
+ IntermediateCatchEvent = 'bpmn:IntermediateCatchEvent',
17
+ IntermediateThrowEvent = 'bpmn:IntermediateThrowEvent',
18
+ EndEvent = 'bpmn:EndEvent',
19
+ SequenceFlow = 'bpmn:SequenceFlow',
20
+ MessageFlow = 'bpmn:MessageFlow',
21
+ CallActivity = 'bpmn:CallActivity'
22
+ }
23
+
24
+ enum NODE_SUBTYPE {
25
+ timer = 'timer',
26
+ message = 'message',
27
+ signal = 'signal',
28
+ error = 'error',
29
+ escalation = 'escalation'
30
+ }
31
+ /*
32
+ * ALL events
33
+ */
34
+ enum EXECUTION_EVENT {
35
+ node_enter = 'enter', node_start = 'start', node_wait = 'wait', node_end = 'end', node_terminated = 'terminated',
36
+ transform_input = 'transformInput', transform_output ='transformOutput',
37
+ flow_take = 'take', flow_discard = 'discard',
38
+ process_loaded ='process.loaded',
39
+ process_start = 'process.start', process_started = 'process.started',
40
+ process_invoke = 'process.invoke', process_invoked = 'process.invoked',
41
+ process_restored = 'process.restored', process_resumed = 'process_resumed',
42
+ process_wait = 'process.wait',
43
+ process_end = 'process.end', process_terminated = 'executeion.terminate' ,
44
+ token_start = 'token.start', token_wait = 'token.wait', token_end = 'token.end', token_terminated = 'token.terminated'
45
+ }
46
+ /*
47
+ * possible actions by node
48
+ */
49
+ // must be same as above
50
+ enum NODE_ACTION { continue = 1, wait, end , stop , error , abort };
51
+
52
+ enum ITEM_STATUS { enter = 'enter', start = 'start', wait = 'wait', end = 'end', terminated = 'terminated' , discard= 'discard'}
53
+
54
+ //type ITEMSTATUS = 'enter' | 'start' | 'wait' | 'end' | 'terminated' | 'discard';
55
+
56
+ enum EXECUTION_STATUS { running='running',wait='wait', end = 'end' , terminated ='terminated' }
57
+
58
+ enum TOKEN_STATUS { running = 'running', wait = 'wait', end = 'end', terminated = 'terminated' }
59
+ /*
60
+ * possible actions by flow
61
+ */
62
+ // must be same as above
63
+
64
+ enum FLOW_ACTION { take = 'take', discard = 'discard' }
65
+
66
+
67
+ export {
68
+ BPMN_TYPE ,
69
+ EXECUTION_EVENT, NODE_ACTION, FLOW_ACTION,
70
+ ITEM_STATUS, TOKEN_STATUS, EXECUTION_STATUS , NODE_SUBTYPE
71
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "env": {
3
+ "mocha": true
4
+ },
5
+ "rules": {
6
+ "no-unused-expressions": 0,
7
+ "no-var": 1,
8
+ "prefer-arrow-callback": 1
9
+ },
10
+ "globals": {
11
+ "expect": false,
12
+ "Feature": false,
13
+ "Scenario": false,
14
+ "Given": false,
15
+ "When": false,
16
+ "Then": false,
17
+ "And": false,
18
+ "But": false
19
+ }
20
+ }
@@ -0,0 +1,5 @@
1
+ API_KEY=1234
2
+ MONGO_DB_URL=mongodb://localhost:27017?retryWrites=true&w=majority
3
+ MONGO_DB_NAME=bpmn
4
+ SENDGRID_API_KEY=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
5
+
@@ -0,0 +1,117 @@
1
+ const { BPMNClient } = require("../../src/");
2
+
3
+
4
+
5
+ const API_KEY = '12345';
6
+ //const HOST = 'localhost';
7
+ //const PORT = '3000';
8
+ const HOST = 'test.omniworkflow.com';
9
+ const PORT = '443';
10
+
11
+ const BASE_URL = 'api';
12
+
13
+
14
+ console.log('-------- car.js -----------');
15
+
16
+ const server = new BPMNClient(HOST, PORT, API_KEY);
17
+
18
+ var caseId = Math.floor(Math.random() * 10000);
19
+
20
+ let name = 'Buy Used Car';
21
+ let process;
22
+ let response;
23
+ let instanceId;
24
+
25
+ Feature('Buy Used Car- clean and repair', () => {
26
+ Scenario('Simple', () => {
27
+ Given('Start Buy Used Car Process', async () => {
28
+ response = await server.engine.start(name, { caseId: caseId });
29
+ instanceId = response.id;
30
+ console.log('**instanceId', response.id, instanceId);
31
+ console.log(' after start ', response.data.caseId);
32
+ });
33
+ Then('check for output', () => {
34
+ expect(response.data.caseId).equals(caseId);
35
+ expect(getItem('task_Buy').status).equals('wait');
36
+ });
37
+
38
+ When('a process defintion is executed', async () => {
39
+
40
+ const data = { needsCleaning: "Yes", needsRepairs: "Yes" };
41
+ const query = {
42
+ id: instanceId,
43
+ "items.elementId": 'task_Buy'
44
+ };
45
+ console.log(query);
46
+ response = await server.engine.invoke(query, data);
47
+ });
48
+
49
+ When('engine get', async () => {
50
+ const query = { id: instanceId };
51
+
52
+ response = await server.engine.get(query);
53
+
54
+ expect(response.id).equals(instanceId);
55
+
56
+ });
57
+
58
+
59
+ Then('check for output to have engine', () => {
60
+ expect(getItem('task_Buy').status).equals('end');
61
+ });
62
+
63
+ and('Clean it', async () => {
64
+
65
+ const query = {
66
+ "data.caseId": caseId,
67
+ "items.elementId": 'task_clean'
68
+ };
69
+ console.log(query);
70
+ await server.engine.invoke(query, {});
71
+ });
72
+
73
+ and('Repair it', async () => {
74
+ const query = { id: instanceId, "items.elementId": 'task_repair' };
75
+ response = await server.engine.invoke(query, {});
76
+ });
77
+ and('Drive it 1', async () => {
78
+ const query = {
79
+ id: instanceId,
80
+ "items.elementId": 'task_Drive'
81
+ };
82
+ response = await server.engine.invoke(query, {});
83
+ });
84
+
85
+ and('Case Complete', async () => {
86
+
87
+ console.log(response.status);
88
+ expect(getItem('task_Drive').status).equals('end');
89
+
90
+ });
91
+
92
+
93
+ //
94
+ and('find instances', async () => {
95
+
96
+ var insts = await server.datastore.findInstances({ id: response.id });
97
+ expect(insts).to.have.lengthOf(1);
98
+
99
+ });
100
+
101
+ and('find items', async () => {
102
+
103
+ var items = await server.datastore.findItems({ id: response.id } );
104
+ expect(items).to.have.lengthOf(17);
105
+
106
+ });
107
+
108
+
109
+
110
+
111
+ });
112
+
113
+ });
114
+
115
+ function getItem(id) {
116
+ return response.items.filter(item => { return item.elementId == id; })[0];
117
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ process.env.NODE_ENV = 'test';
4
+ Error.stackTraceLimit = 20;
5
+ global.expect = require('chai').expect;
6
+ global.assert = require('chai').assert;
7
+
8
+
9
+
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ --timeout 50000
2
+ --reporter spec
3
+ --recursive
4
+ --require ./test/helpers/setup.js
5
+ --ui mocha-cakes-2
@@ -0,0 +1,91 @@
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 };
@@ -0,0 +1,69 @@
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 };
@@ -0,0 +1,50 @@
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 };
package/test.js ADDED
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const _1 = require("./");
13
+ console.log("Testing BPMNClient");
14
+ const dotenv = require('dotenv');
15
+ const res = dotenv.config();
16
+ console.log(res);
17
+ test();
18
+ function test() {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const server = new _1.BPMNClient(process.env.HOST, process.env.PORT, process.env.API_KEY);
21
+ const caseId = 3040;
22
+ var defs = yield server.definitions.list();
23
+ console.log(defs);
24
+ var def = yield server.definitions.load('Buy Used Car');
25
+ console.log(def['elements']);
26
+ //var instance = await server.engine.start("Buy Used Car", {});
27
+ var instance = yield server.engine.start("Buy Used Car", { caseId: caseId });
28
+ console.log("instance.id", instance.id, instance.name, instance.status, instance.data.caseId);
29
+ var response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_Buy' }, { needsCleaning: "Yes", needsRepairs: "Yes" });
30
+ console.log('after buy', response.id, response.data);
31
+ response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_clean' }, {});
32
+ console.log('after clean', response.id, response.data);
33
+ response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_repair' }, {});
34
+ console.log('after repair', response.id, response.data);
35
+ try {
36
+ response = yield server.engine.invoke({ id: instance.id, "items.elementId": 'task_Drive' }, {});
37
+ console.log('after drive', response.id, response.data);
38
+ }
39
+ catch (exc) {
40
+ console.log(exc);
41
+ }
42
+ var insts = yield server.datastore.findInstances({ data: { caseId: caseId } });
43
+ insts.forEach(inst => {
44
+ console.log('Inst for CaseId id==>' + inst.id, inst.name, inst.data.caseId, 'status==>', inst.status);
45
+ });
46
+ var insts = yield server.datastore.findInstances({ id: instance.id });
47
+ insts.forEach(inst => {
48
+ for (var i = 0; i < inst.items.length; i++) {
49
+ var item = inst.items[i];
50
+ console.log(' item: elementId==>' + item.elementId, item.name, 'status==>', item.status);
51
+ }
52
+ });
53
+ var inst = yield server.engine.get({ id: instance.id });
54
+ for (var i = 0; i < inst.items.length; i++) {
55
+ var item = inst.items[i];
56
+ console.log(' item: elementId==>' + item.elementId, item.name, 'status==>', item.status);
57
+ }
58
+ // var items = await server.datastore.findItems({ query: { "items.elementId": "task_Buy" } });
59
+ var items = yield server.datastore.findItems({ id: instance.id });
60
+ items.forEach(item => {
61
+ console.log('item: id==>' + item.elementId, item.type, item.name, 'status==>', item.status);
62
+ });
63
+ });
64
+ }