@veridid/workflow-parser 0.3.1 → 0.4.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.
- package/package.json +17 -32
- package/src/implementations/action.default.js +114 -0
- package/src/implementations/action.default.ts +74 -0
- package/src/implementations/display.default.js +132 -0
- package/src/implementations/display.default.ts +98 -0
- package/src/implementations/workflow.default.js +146 -0
- package/src/implementations/workflow.default.ts +64 -0
- package/src/index.js +6 -0
- package/src/index.ts +6 -0
- package/src/interfaces/actionextension.js +2 -0
- package/src/interfaces/actionextension.ts +7 -0
- package/src/interfaces/actioninterface.js +2 -0
- package/src/interfaces/actioninterface.ts +11 -0
- package/src/interfaces/displayextension.js +2 -0
- package/src/interfaces/displayextension.ts +7 -0
- package/src/interfaces/displayinterface.js +2 -0
- package/src/interfaces/displayinterface.ts +13 -0
- package/src/interfaces/workflowinterface.js +2 -0
- package/src/interfaces/workflowinterface.ts +24 -0
- package/{dist/schema.sql → src/support/Schema.sql} +2 -2
- package/src/workflowparser.js +100 -0
- package/src/workflowparser.ts +70 -0
- package/test/action.extension.js +65 -0
- package/test/action.extension.ts +22 -0
- package/test/display.extension.js +60 -0
- package/test/display.extension.ts +16 -0
- package/test/docker-compose.yml +33 -0
- package/test/pg_hba.conf +14 -0
- package/test/postgresql.conf +42 -0
- package/test/tables.sql +17 -0
- package/test/test.js +233 -0
- package/test/test.ts +159 -0
- package/test/testworkflows.json +223 -0
- package/tsconfig.json +15 -0
package/test/test.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var workflowparser_1 = require("../src/workflowparser");
|
|
40
|
+
var display_default_1 = require("../src/implementations/display.default");
|
|
41
|
+
var action_default_1 = require("../src/implementations/action.default");
|
|
42
|
+
var workflow_default_1 = require("../src/implementations/workflow.default");
|
|
43
|
+
var pg_1 = require("pg");
|
|
44
|
+
var testWorkflows = require("./testworkflows.json");
|
|
45
|
+
var action_extension_1 = require("./action.extension");
|
|
46
|
+
var display_extension_1 = require("./display.extension");
|
|
47
|
+
var testClient = new pg_1.Client({
|
|
48
|
+
user: 'admin',
|
|
49
|
+
password: 'root',
|
|
50
|
+
host: 'localhost',
|
|
51
|
+
port: 5432,
|
|
52
|
+
database: 'test_workflows'
|
|
53
|
+
});
|
|
54
|
+
connectDatabase(testClient);
|
|
55
|
+
dropTable(testClient, "workflows");
|
|
56
|
+
dropTable(testClient, "instances");
|
|
57
|
+
addTable(testClient, "CREATE TABLE workflows (\n workflow_id VARCHAR(255) PRIMARY KEY, \n name VARCHAR(255),\n initial_state VARCHAR(255),\n render JSONB,\n states JSONB\n );");
|
|
58
|
+
addTable(testClient, "CREATE TABLE instances (\n instance_id UUID PRIMARY KEY,\n workflow_id VARCHAR(255),\n client_id VARCHAR(255), \n current_state VARCHAR(255),\n state_data JSONB\n );");
|
|
59
|
+
insertWorkflows(testClient);
|
|
60
|
+
var defaultWorkflow = new workflow_default_1.DefaultWorkflow(testClient);
|
|
61
|
+
var actionExtension = new action_extension_1.ExtendedAction();
|
|
62
|
+
var defaultAction = new action_default_1.DefaultAction(actionExtension);
|
|
63
|
+
var displayExtenion = new display_extension_1.ExtendedDisplay();
|
|
64
|
+
var defaultDisplay = new display_default_1.DefaultDisplay(displayExtenion);
|
|
65
|
+
var testParser = new workflowparser_1.WorkflowParser(defaultDisplay, defaultAction, defaultWorkflow);
|
|
66
|
+
function connectDatabase(dbClient) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
dbClient.connect();
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function dropTable(dbClient, table) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var result, error_1;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
_a.trys.push([0, 2, , 3]);
|
|
81
|
+
console.log("*** Drop Table - ", table);
|
|
82
|
+
return [4 /*yield*/, dbClient.query('DROP TABLE IF EXISTS ' + table + ';')];
|
|
83
|
+
case 1:
|
|
84
|
+
result = _a.sent();
|
|
85
|
+
console.log(result);
|
|
86
|
+
return [3 /*break*/, 3];
|
|
87
|
+
case 2:
|
|
88
|
+
error_1 = _a.sent();
|
|
89
|
+
console.log("Drop workflows error=", error_1);
|
|
90
|
+
return [3 /*break*/, 3];
|
|
91
|
+
case 3: return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function addTable(dbClient, tableSql) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var result, error_2;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
_a.trys.push([0, 2, , 3]);
|
|
103
|
+
console.log("*** Create Tables");
|
|
104
|
+
return [4 /*yield*/, dbClient.query(tableSql)];
|
|
105
|
+
case 1:
|
|
106
|
+
result = _a.sent();
|
|
107
|
+
console.log(result);
|
|
108
|
+
return [3 /*break*/, 3];
|
|
109
|
+
case 2:
|
|
110
|
+
error_2 = _a.sent();
|
|
111
|
+
console.log("Drop table error=", error_2);
|
|
112
|
+
return [3 /*break*/, 3];
|
|
113
|
+
case 3: return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function insertWorkflows(dbClient) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var query, _i, _a, workflow;
|
|
121
|
+
return __generator(this, function (_b) {
|
|
122
|
+
switch (_b.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
console.log("*** Insert Workflows");
|
|
125
|
+
query = 'INSERT INTO workflows (workflow_id, name, initial_state, render, states) VALUES ($1, $2, $3, $4, $5)';
|
|
126
|
+
_i = 0, _a = testWorkflows.workflows;
|
|
127
|
+
_b.label = 1;
|
|
128
|
+
case 1:
|
|
129
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
130
|
+
workflow = _a[_i];
|
|
131
|
+
console.log("Inserting workflow:", workflow);
|
|
132
|
+
console.log("Inserting workflowID:", workflow.workflow_id);
|
|
133
|
+
return [4 /*yield*/, dbClient.query(query, [
|
|
134
|
+
workflow.workflow_id,
|
|
135
|
+
workflow.name,
|
|
136
|
+
workflow.initial_state,
|
|
137
|
+
JSON.stringify(workflow.render),
|
|
138
|
+
JSON.stringify(workflow.states)
|
|
139
|
+
])];
|
|
140
|
+
case 2:
|
|
141
|
+
_b.sent();
|
|
142
|
+
_b.label = 3;
|
|
143
|
+
case 3:
|
|
144
|
+
_i++;
|
|
145
|
+
return [3 /*break*/, 1];
|
|
146
|
+
case 4: return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function runtests() {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
+
var display;
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0:
|
|
157
|
+
console.log("~~~ Start Test 1 - Load default workflow and state");
|
|
158
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "", data: {} })];
|
|
159
|
+
case 1:
|
|
160
|
+
display = _a.sent();
|
|
161
|
+
console.log("Returns displaydata= %j", display);
|
|
162
|
+
console.log("~~~ Start Test 2 - go to Page1");
|
|
163
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "nextButton", data: {} })];
|
|
164
|
+
case 2:
|
|
165
|
+
display = _a.sent();
|
|
166
|
+
console.log("Returns displaydata= %j", display);
|
|
167
|
+
console.log("~~~ Start Test 3 - return from Page1 to menu");
|
|
168
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "backButton", data: {} })];
|
|
169
|
+
case 3:
|
|
170
|
+
display = _a.sent();
|
|
171
|
+
console.log("Returns displaydata= %j", display);
|
|
172
|
+
console.log("~~~ Start Test 4 - go to page 2");
|
|
173
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "dataButton", data: {} })];
|
|
174
|
+
case 4:
|
|
175
|
+
display = _a.sent();
|
|
176
|
+
console.log("Returns displaydata= %j", display);
|
|
177
|
+
console.log("~~~ Start Test 5 - save fixed data");
|
|
178
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "saveButton", data: {} })];
|
|
179
|
+
case 5:
|
|
180
|
+
display = _a.sent();
|
|
181
|
+
console.log("Returns displaydata= %j", display);
|
|
182
|
+
console.log("~~~ Start Test 6 - save mobile data");
|
|
183
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "stateButton", data: { "Date": "Today" } })];
|
|
184
|
+
case 6:
|
|
185
|
+
display = _a.sent();
|
|
186
|
+
console.log("Returns displaydata= %j", display);
|
|
187
|
+
console.log("~~~ Start Test 7 - return to menu");
|
|
188
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "backButton", data: {} })];
|
|
189
|
+
case 7:
|
|
190
|
+
display = _a.sent();
|
|
191
|
+
console.log("Returns displaydata= %j", display);
|
|
192
|
+
console.log("~~~ Start Test 8 - go to new workflow");
|
|
193
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "workflowButton", data: {} })];
|
|
194
|
+
case 8:
|
|
195
|
+
display = _a.sent();
|
|
196
|
+
console.log("Returns displaydata= %j", display);
|
|
197
|
+
console.log("~~~ Start Test 9 - go back to root-menu workflow");
|
|
198
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "other-menu", actionID: "homeButton", data: {} })];
|
|
199
|
+
case 9:
|
|
200
|
+
display = _a.sent();
|
|
201
|
+
console.log("Returns displaydata= %j", display);
|
|
202
|
+
console.log("~~~ Start Test 10 - go to new workflow");
|
|
203
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "workflowButton", data: {} })];
|
|
204
|
+
case 10:
|
|
205
|
+
display = _a.sent();
|
|
206
|
+
console.log("Returns displaydata= %j", display);
|
|
207
|
+
console.log("~~~ Start Test 11 - return to root-menu workflow");
|
|
208
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "other-menu", actionID: "noactionButton", data: {} })];
|
|
209
|
+
case 11:
|
|
210
|
+
display = _a.sent();
|
|
211
|
+
console.log("Returns displaydata= %j", display);
|
|
212
|
+
console.log("~~~ Start Test 12 - go to page 2");
|
|
213
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "dataButton", data: {} })];
|
|
214
|
+
case 12:
|
|
215
|
+
display = _a.sent();
|
|
216
|
+
console.log("Returns displaydata= %j", display);
|
|
217
|
+
console.log("~~~ Start Test 13 - extension test");
|
|
218
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "extensionButton", data: {} })];
|
|
219
|
+
case 13:
|
|
220
|
+
display = _a.sent();
|
|
221
|
+
console.log("Returns displaydata= %j", display);
|
|
222
|
+
console.log("~~~ Start Test 14 - return to menu");
|
|
223
|
+
return [4 /*yield*/, testParser.parse("TestPersonID", { workflowID: "root-menu", actionID: "backButton", data: {} })];
|
|
224
|
+
case 14:
|
|
225
|
+
display = _a.sent();
|
|
226
|
+
console.log("Returns displaydata= %j", display);
|
|
227
|
+
return [2 /*return*/];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// start test
|
|
233
|
+
runtests();
|
package/test/test.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { WorkflowParser } from '../src/workflowparser';
|
|
2
|
+
import { DefaultDisplay } from '../src/implementations/display.default';
|
|
3
|
+
import { DefaultAction } from '../src/implementations/action.default';
|
|
4
|
+
import { DefaultWorkflow } from '../src/implementations/workflow.default';
|
|
5
|
+
import { Client } from 'pg';
|
|
6
|
+
import * as testWorkflows from './testworkflows.json'
|
|
7
|
+
import { ExtendedAction } from './action.extension';
|
|
8
|
+
import { ExtendedDisplay } from './display.extension';
|
|
9
|
+
|
|
10
|
+
const testClient = new Client({
|
|
11
|
+
user: 'admin',
|
|
12
|
+
password: 'root',
|
|
13
|
+
host: 'localhost',
|
|
14
|
+
port: 5432,
|
|
15
|
+
database: 'test_workflows'
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
connectDatabase(testClient);
|
|
19
|
+
|
|
20
|
+
dropTable(testClient, "workflows");
|
|
21
|
+
dropTable(testClient, "instances");
|
|
22
|
+
|
|
23
|
+
addTable(testClient,
|
|
24
|
+
`CREATE TABLE workflows (
|
|
25
|
+
workflow_id VARCHAR(255) PRIMARY KEY,
|
|
26
|
+
name VARCHAR(255),
|
|
27
|
+
initial_state VARCHAR(255),
|
|
28
|
+
render JSONB,
|
|
29
|
+
states JSONB
|
|
30
|
+
);`
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
addTable(testClient,
|
|
34
|
+
`CREATE TABLE instances (
|
|
35
|
+
instance_id UUID PRIMARY KEY,
|
|
36
|
+
workflow_id VARCHAR(255),
|
|
37
|
+
client_id VARCHAR(255),
|
|
38
|
+
current_state VARCHAR(255),
|
|
39
|
+
state_data JSONB
|
|
40
|
+
);`
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
insertWorkflows(testClient);
|
|
44
|
+
const defaultWorkflow = new DefaultWorkflow(testClient);
|
|
45
|
+
|
|
46
|
+
const actionExtension = new ExtendedAction();
|
|
47
|
+
const defaultAction = new DefaultAction(actionExtension);
|
|
48
|
+
|
|
49
|
+
const displayExtenion = new ExtendedDisplay();
|
|
50
|
+
const defaultDisplay = new DefaultDisplay(displayExtenion);
|
|
51
|
+
|
|
52
|
+
const testParser = new WorkflowParser(defaultDisplay, defaultAction, defaultWorkflow);
|
|
53
|
+
|
|
54
|
+
async function connectDatabase(dbClient: Client): Promise<void>{
|
|
55
|
+
dbClient.connect()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function dropTable(dbClient: Client, table: string): Promise<void> {
|
|
59
|
+
try {
|
|
60
|
+
console.log("*** Drop Table - ", table);
|
|
61
|
+
const result = await dbClient.query('DROP TABLE IF EXISTS ' + table + ';');
|
|
62
|
+
console.log(result);
|
|
63
|
+
}
|
|
64
|
+
catch(error) {
|
|
65
|
+
console.log("Drop workflows error=", error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function addTable(dbClient: Client, tableSql: string): Promise<void> {
|
|
70
|
+
try {
|
|
71
|
+
console.log("*** Create Tables");
|
|
72
|
+
const result = await dbClient.query(tableSql);
|
|
73
|
+
console.log(result);
|
|
74
|
+
}
|
|
75
|
+
catch(error) {
|
|
76
|
+
console.log("Drop table error=", error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function insertWorkflows(dbClient: Client): Promise<void> {
|
|
81
|
+
console.log("*** Insert Workflows");
|
|
82
|
+
const query = 'INSERT INTO workflows (workflow_id, name, initial_state, render, states) VALUES ($1, $2, $3, $4, $5)';
|
|
83
|
+
for (const workflow of testWorkflows.workflows) {
|
|
84
|
+
console.log("Inserting workflow:", workflow);
|
|
85
|
+
console.log("Inserting workflowID:", workflow.workflow_id);
|
|
86
|
+
await dbClient.query(query, [
|
|
87
|
+
workflow.workflow_id,
|
|
88
|
+
workflow.name,
|
|
89
|
+
workflow.initial_state,
|
|
90
|
+
JSON.stringify(workflow.render),
|
|
91
|
+
JSON.stringify(workflow.states)
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
async function runtests(): Promise<void> {
|
|
98
|
+
console.log("~~~ Start Test 1 - Load default workflow and state");
|
|
99
|
+
let display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "", data: {} });
|
|
100
|
+
console.log("Returns displaydata= %j", display);
|
|
101
|
+
|
|
102
|
+
console.log("~~~ Start Test 2 - go to Page1");
|
|
103
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "nextButton", data: {} });
|
|
104
|
+
console.log("Returns displaydata= %j", display);
|
|
105
|
+
|
|
106
|
+
console.log("~~~ Start Test 3 - return from Page1 to menu");
|
|
107
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "backButton", data: {} });
|
|
108
|
+
console.log("Returns displaydata= %j", display);
|
|
109
|
+
|
|
110
|
+
console.log("~~~ Start Test 4 - go to page 2");
|
|
111
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "dataButton", data: {} });
|
|
112
|
+
console.log("Returns displaydata= %j", display);
|
|
113
|
+
|
|
114
|
+
console.log("~~~ Start Test 5 - save fixed data");
|
|
115
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "saveButton", data: {} });
|
|
116
|
+
console.log("Returns displaydata= %j", display);
|
|
117
|
+
|
|
118
|
+
console.log("~~~ Start Test 6 - save mobile data");
|
|
119
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "stateButton", data: {"Date": "Today"} });
|
|
120
|
+
console.log("Returns displaydata= %j", display);
|
|
121
|
+
|
|
122
|
+
console.log("~~~ Start Test 7 - return to menu");
|
|
123
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "backButton", data: {} });
|
|
124
|
+
console.log("Returns displaydata= %j", display);
|
|
125
|
+
|
|
126
|
+
console.log("~~~ Start Test 8 - go to new workflow");
|
|
127
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "workflowButton", data: {} });
|
|
128
|
+
console.log("Returns displaydata= %j", display);
|
|
129
|
+
|
|
130
|
+
console.log("~~~ Start Test 9 - go back to root-menu workflow");
|
|
131
|
+
display = await testParser.parse("TestPersonID", {workflowID: "other-menu", actionID: "homeButton", data: {} });
|
|
132
|
+
console.log("Returns displaydata= %j", display);
|
|
133
|
+
|
|
134
|
+
console.log("~~~ Start Test 10 - go to new workflow");
|
|
135
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "workflowButton", data: {} });
|
|
136
|
+
console.log("Returns displaydata= %j", display);
|
|
137
|
+
|
|
138
|
+
console.log("~~~ Start Test 11 - return to root-menu workflow");
|
|
139
|
+
display = await testParser.parse("TestPersonID", {workflowID: "other-menu", actionID: "noactionButton", data: {} });
|
|
140
|
+
console.log("Returns displaydata= %j", display);
|
|
141
|
+
|
|
142
|
+
console.log("~~~ Start Test 12 - go to page 2");
|
|
143
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "dataButton", data: {} });
|
|
144
|
+
console.log("Returns displaydata= %j", display);
|
|
145
|
+
|
|
146
|
+
console.log("~~~ Start Test 13 - extension test");
|
|
147
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "extensionButton", data: {} });
|
|
148
|
+
console.log("Returns displaydata= %j", display);
|
|
149
|
+
|
|
150
|
+
console.log("~~~ Start Test 14 - return to menu");
|
|
151
|
+
display = await testParser.parse("TestPersonID", {workflowID: "root-menu", actionID: "backButton", data: {} });
|
|
152
|
+
console.log("Returns displaydata= %j", display);
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// start test
|
|
157
|
+
runtests();
|
|
158
|
+
|
|
159
|
+
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
{
|
|
2
|
+
"workflows": [
|
|
3
|
+
{
|
|
4
|
+
"name": "Test Workflow Display Name",
|
|
5
|
+
"workflow_id": "root-menu",
|
|
6
|
+
"initial_state": "menu",
|
|
7
|
+
"render": [
|
|
8
|
+
{ }
|
|
9
|
+
],
|
|
10
|
+
"states": [
|
|
11
|
+
{
|
|
12
|
+
"name": "Test Workflow menu",
|
|
13
|
+
"state_id": "menu",
|
|
14
|
+
"display_data": [
|
|
15
|
+
{
|
|
16
|
+
"type": "image",
|
|
17
|
+
"url": "http://image.com/image.png"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "text",
|
|
21
|
+
"display": "title",
|
|
22
|
+
"text": "This is the test for workflow"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "text",
|
|
26
|
+
"text": "First time showing this page",
|
|
27
|
+
"condition": "instance?.state_data?.first==undefined"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "button",
|
|
31
|
+
"text": "Next button",
|
|
32
|
+
"action_id": "nextButton"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "button",
|
|
36
|
+
"text": "Data button",
|
|
37
|
+
"action_id": "dataButton"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "button",
|
|
41
|
+
"text": "Workflow button",
|
|
42
|
+
"action_id": "workflowButton"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"actions": [
|
|
46
|
+
{
|
|
47
|
+
"action_id": "nextButton",
|
|
48
|
+
"type": "saveData",
|
|
49
|
+
"condition": "true",
|
|
50
|
+
"value": {"first": true }
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"transitions": [
|
|
54
|
+
{
|
|
55
|
+
"transition_id": "nextButton",
|
|
56
|
+
"type": "stateTransition",
|
|
57
|
+
"state_id": "page1",
|
|
58
|
+
"workflow_id": "",
|
|
59
|
+
"condition": "actionInput.actionID=='nextButton'"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"transition_id": "dataButton",
|
|
63
|
+
"type": "stateTransition",
|
|
64
|
+
"state_id": "page2",
|
|
65
|
+
"workflow_id": "",
|
|
66
|
+
"condition": "actionInput.actionID=='dataButton'"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "Test Workflow page 1",
|
|
72
|
+
"state_id": "page1",
|
|
73
|
+
"display_data": [
|
|
74
|
+
{
|
|
75
|
+
"type": "text",
|
|
76
|
+
"text": "This is the page for testing state transitions."
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "button",
|
|
80
|
+
"text": "Go back",
|
|
81
|
+
"action_id": "backButton"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"actions": [
|
|
85
|
+
],
|
|
86
|
+
"transitions": [
|
|
87
|
+
{
|
|
88
|
+
"transition_id": "backButton",
|
|
89
|
+
"type": "stateTransition",
|
|
90
|
+
"state_id": "menu",
|
|
91
|
+
"workflow_id": "",
|
|
92
|
+
"condition": "actionInput.actionID=='backButton'"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "Test Workflow page 2 data test",
|
|
98
|
+
"state_id": "page2",
|
|
99
|
+
"display_data": [
|
|
100
|
+
{
|
|
101
|
+
"type": "text",
|
|
102
|
+
"display": "title",
|
|
103
|
+
"text": "This is the page for testing data."
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"type": "text",
|
|
107
|
+
"text": "Date={Date}",
|
|
108
|
+
"condition": "instance?.state_data?.Date!=undefined"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"type": "extended",
|
|
112
|
+
"text": "Extended text"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"type": "button",
|
|
116
|
+
"text": "Save Data",
|
|
117
|
+
"action_id": "saveButton"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"type": "button",
|
|
121
|
+
"text": "State Data",
|
|
122
|
+
"action_id": "stateButton"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "button",
|
|
126
|
+
"text": "Extension",
|
|
127
|
+
"action_id": "extensionButton"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"type": "button",
|
|
131
|
+
"text": "Go back",
|
|
132
|
+
"action_id": "backButton"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"actions": [
|
|
136
|
+
{
|
|
137
|
+
"action_id": "stateButton",
|
|
138
|
+
"type": "stateData",
|
|
139
|
+
"condition": "true",
|
|
140
|
+
"value": "action.data"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"action_id": "extensionButton",
|
|
144
|
+
"type": "extension",
|
|
145
|
+
"condition": "true",
|
|
146
|
+
"value": {"extended": true }
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"action_id": "saveButton",
|
|
150
|
+
"type": "saveData",
|
|
151
|
+
"condition": "true",
|
|
152
|
+
"value": {"data": "Hello"}
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"transitions": [
|
|
156
|
+
{
|
|
157
|
+
"transition_id": "backButton",
|
|
158
|
+
"type": "stateTransition",
|
|
159
|
+
"state_id": "menu",
|
|
160
|
+
"workflow_id": "",
|
|
161
|
+
"condition": "actionInput.actionID=='backButton'"
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "Test Other Workflow ",
|
|
169
|
+
"workflow_id": "other-menu",
|
|
170
|
+
"initial_state": "menu2",
|
|
171
|
+
"render": [
|
|
172
|
+
{ }
|
|
173
|
+
],
|
|
174
|
+
"states": [
|
|
175
|
+
{
|
|
176
|
+
"name": "Test Other Workflow menu",
|
|
177
|
+
"state_id": "menu2",
|
|
178
|
+
"display_data": [
|
|
179
|
+
{
|
|
180
|
+
"type": "title",
|
|
181
|
+
"text": "This is the other test workflow."
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"type": "button",
|
|
185
|
+
"text": "Go home workflow",
|
|
186
|
+
"action_id": "homeButton"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"type": "button",
|
|
190
|
+
"text": "No action button",
|
|
191
|
+
"action_id": "noactionButton"
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
],
|
|
195
|
+
"actions": [
|
|
196
|
+
{
|
|
197
|
+
"action_id": "homeButton",
|
|
198
|
+
"type": "workflowTransition",
|
|
199
|
+
"condition": "true",
|
|
200
|
+
"value": "root-menu"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"transitions": [
|
|
204
|
+
{
|
|
205
|
+
"transition_id": "homeButton",
|
|
206
|
+
"type": "workflowTransition",
|
|
207
|
+
"state_id": "",
|
|
208
|
+
"workflow_id": "root-menu",
|
|
209
|
+
"condition": "actionInput.actionID=='homeButton'"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"transition_id": "noactionButton",
|
|
213
|
+
"type": "workflowTransition",
|
|
214
|
+
"state_id": "",
|
|
215
|
+
"workflow_id": "root-menu",
|
|
216
|
+
"condition": "actionInput.actionID=='noactionButton'"
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"target": "es6",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
10
|
+
"experimentalDecorators": true,
|
|
11
|
+
"strictPropertyInitialization": false,
|
|
12
|
+
"resolveJsonModule": true
|
|
13
|
+
},
|
|
14
|
+
"lib": ["es2015"]
|
|
15
|
+
}
|