bpmn-client 1.0.1 → 1.2.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.
@@ -0,0 +1,219 @@
1
+ import { IInstanceData, IItemData , IDefinitionData} from './interfaces/DataObjects';
2
+
3
+
4
+ const dotenv = require('dotenv');
5
+ const res = dotenv.config();
6
+
7
+ console.log("BPMNClient 1.2");
8
+
9
+ const https = require('https');
10
+ const http = require('http');
11
+
12
+ class WebService {
13
+ statusCode;
14
+ result;
15
+ constructor() { }
16
+ async invoke(params, options) {
17
+
18
+ var driver = http;
19
+ var body = JSON.stringify(params);
20
+
21
+ console.log(options, params);
22
+ if (options.port == 443)
23
+ driver = https;
24
+
25
+ let data = '';
26
+ let self = this;
27
+ return new Promise(function (resolve, reject) {
28
+ try {
29
+
30
+ driver.request(options, function (res) {
31
+ console.log('STATUS: ' + res.statusCode);
32
+ //console.log(res);
33
+ self.statusCode = res.statusCode;
34
+ res.setEncoding('utf8');
35
+ res.on('data', function (chunk) {
36
+ data += chunk;
37
+ });
38
+ res.on('end', () => {
39
+ self.result = JSON.parse(data);
40
+
41
+ resolve(self.result);
42
+ });
43
+
44
+
45
+ }).on("error", (err) => {
46
+ console.log("Error: " + err.message);
47
+ reject(err);
48
+ }).end(body);
49
+ }
50
+ catch (exc) {
51
+ console.log(exc);
52
+ }
53
+
54
+ });
55
+
56
+ }
57
+ }
58
+ class BPMNClient extends WebService {
59
+ host;
60
+ port;
61
+ apiKey;
62
+ engine: ClientEngine;
63
+ datastore: ClientDatastore;
64
+ constructor(host, port, apiKey) {
65
+ super();
66
+ this.host = host;
67
+ this.port = port;
68
+ this.apiKey = apiKey;
69
+ this.engine = new ClientEngine(this);
70
+ this.datastore = new ClientDatastore(this);
71
+ }
72
+
73
+ async get(url, data = {}) {
74
+ return await this.request(url, 'GET', data);
75
+
76
+ }
77
+ async post(url, data = {}) {
78
+ return await this.request(url, 'POST', data);
79
+
80
+ }
81
+ async put(url, data = {}) {
82
+ return await this.request(url, 'PUT', data);
83
+
84
+ }
85
+ async del(url, data = {}) {
86
+ return await this.request(url, 'DELETE', data);
87
+
88
+ }
89
+ async request(url, method, params) {
90
+
91
+ var body = JSON.stringify(params);
92
+
93
+ var options;
94
+
95
+ if (params) {
96
+ options = {
97
+ host: this.host,
98
+ port: this.port,
99
+ path: '/api/' + url,
100
+ method: method,
101
+ headers: {
102
+ "Content-Type": "application/json",
103
+ "x-api-key": this.apiKey,
104
+ "Accept": "*/*",
105
+ // "User-Agent": "PostmanRuntime/ 7.26.8",
106
+ // "Accept-Encoding": "gzip, deflate, br",
107
+ "Connection": "keep-alive",
108
+ "Content-Length": Buffer.byteLength(body)
109
+ }
110
+ };
111
+ }
112
+ else {
113
+ options = {
114
+ host: this.host,
115
+ port: this.port,
116
+ path: '/api/' + url,
117
+ method: method
118
+ };
119
+ }
120
+
121
+
122
+ return await this.invoke(params, options);
123
+
124
+ }
125
+
126
+ }
127
+
128
+ class ClientEngine {
129
+ private client: BPMNClient;
130
+
131
+ constructor(client) {
132
+ this.client = client;
133
+ }
134
+ async start(name, data): Promise<IInstanceData> {
135
+ const ret = await this.client.post('engine/start', { name, data });
136
+ if (ret['errors']) {
137
+ console.log(ret['errors']);
138
+ throw new Error(ret['errors']);
139
+ }
140
+ const instance = ret as IInstanceData;
141
+ return instance;
142
+ }
143
+ async invoke(query, data): Promise<IInstanceData> {
144
+ const ret = await this.client.put('engine/invoke', { query, data });
145
+ if (ret['errors']) {
146
+ console.log(ret['errors']);
147
+ throw new Error(ret['errors']);
148
+ }
149
+ const instance = ret['instance'] as IInstanceData;
150
+ return instance;
151
+ }
152
+
153
+ async get(query): Promise<IInstanceData> {
154
+ const ret = await this.client.get('engine/get', query);
155
+ if (ret['errors']) {
156
+ console.log(ret['errors']);
157
+ throw new Error(ret['errors']);
158
+ }
159
+ const instance = ret['instance'] as IInstanceData;
160
+ return instance;
161
+ }
162
+ }
163
+ class ClientDatastore {
164
+ private client: BPMNClient;
165
+
166
+ constructor(client) {
167
+ this.client = client;
168
+ }
169
+ async findItems(query): Promise<IItemData[]> {
170
+ var res = await this.client.get('datastore/findItems', query);
171
+ if (res['errors']) {
172
+ console.log(res['errors']);
173
+ throw new Error(res['errors']);
174
+ }
175
+ const items = res['items'] as IItemData[];
176
+ return items;
177
+
178
+ }
179
+ async findInstances(query): Promise<IInstanceData[]> {
180
+ const res = await this.client.get('datastore/findInstances', query);
181
+ if (res['errors']) {
182
+ console.log(res['errors']);
183
+ throw new Error(res['errors']);
184
+ }
185
+ const instances = res['instances'] as IInstanceData[];
186
+ return instances;
187
+ }
188
+ async deleteInstances(query) {
189
+ return await this.client.del('datastore/delete', query);
190
+ }
191
+ }
192
+ class ClientDefinitions {
193
+ private client: BPMNClient;
194
+
195
+ constructor(client) {
196
+ this.client = client;
197
+ }
198
+ async list(): Promise<string[]> {
199
+ var res = await this.client.get('definitions/list', []);
200
+ if (res['errors']) {
201
+ console.log(res['errors']);
202
+ throw new Error(res['errors']);
203
+ }
204
+ return res as string[];
205
+
206
+ }
207
+ async load(name): Promise<IDefinitionData> {
208
+ const res = await this.client.get(encodeURI('definitions/load/' + name), { name: name });
209
+ if (res['errors']) {
210
+ console.log(res['errors']);
211
+ throw new Error(res['errors']);
212
+ }
213
+ console.log(res);
214
+ return res as IDefinitionData;
215
+ }
216
+ }
217
+
218
+
219
+ export { BPMNClient , ClientEngine,ClientDatastore , ClientDefinitions}
package/src/index.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./interfaces/Enums"), exports);
14
+ __exportStar(require("./interfaces/DataObjects"), exports);
15
+ __exportStar(require("./BPMNClient"), exports);
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './interfaces/Enums';
2
+ export * from './interfaces/DataObjects';
3
+ export * from './BPMNClient';
4
+
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,97 @@
1
+ import { ITEM_STATUS, } from './Enums';
2
+
3
+ interface IItemData {
4
+ id: string; // System generated unique Id
5
+ itemKey: string; // application assigned key to call the item by
6
+ elementId: string; // bpmn element
7
+ name: string; // name of bpmn element
8
+ type: string; // bpmn element type
9
+ tokenId: any; // execution Token
10
+ userId: any;
11
+ startedAt: any;
12
+ endedAt: any;
13
+ seq: any;
14
+ timeDue: Date;
15
+ status: ITEM_STATUS;
16
+ data: any;
17
+ messageId;
18
+ signalId;
19
+ assignments;
20
+ authorizations;
21
+ notifications;
22
+ }
23
+ interface IInstanceData {
24
+ id;
25
+ name;
26
+ status;
27
+ startedAt;
28
+ endedAt;
29
+ saved;
30
+ data;
31
+ items;
32
+ source;
33
+ logs;
34
+ tokens;
35
+ loops;
36
+ parentItemId; // used for subProcess Calls
37
+ involvements;
38
+ authorizations;
39
+ }
40
+
41
+
42
+
43
+ interface IDefinitionData {
44
+ name: any;
45
+ processes: Map<any, any>;
46
+ rootElements: any;
47
+ nodes: Map<any, any>;
48
+ flows: any[];
49
+ source: any;
50
+ logger: any;
51
+ accessRules: any[];
52
+ }
53
+
54
+
55
+ interface IElementData {
56
+ id: any;
57
+ type: any;
58
+ name: any;
59
+ behaviours: Map<any, any>;
60
+ }
61
+
62
+ interface IFlowData {
63
+
64
+ }
65
+
66
+ interface IEventData {
67
+ elementId: string;
68
+ processId: string;
69
+ type;
70
+ name;
71
+ subType;
72
+ signalId?: string;
73
+ messageId?: string;
74
+ // timer info
75
+ expression;
76
+ expressionFormat; // cron/iso
77
+ referenceDateTime; // start time of event or last time timer ran
78
+ maxRepeat;
79
+ repeatCount;
80
+ timeDue?: Date;
81
+
82
+ }
83
+ interface IBpmnModelData {
84
+ name;
85
+ source;
86
+ svg;
87
+ processes: IProcessData[];
88
+ events: IEventData[];
89
+ saved;
90
+ // parse(definition: IDefinition);
91
+ }
92
+ interface IProcessData {
93
+ id;
94
+ name;
95
+ isExecutable;
96
+ }
97
+ export { IItemData, IInstanceData , IDefinitionData, IElementData, IFlowData , IBpmnModelData, IProcessData, IEventData }
@@ -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