botium-core 1.11.13 → 1.12.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/dist/botium-cjs.js +692 -524
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +323 -155
- package/dist/botium-es.js.map +1 -1
- package/package.json +30 -29
- package/samples/connectors/custom/botium-connector-myapi.js +3 -3
- package/samples/extensions/asserterHooks/DummyAsserter.js +3 -3
- package/src/Capabilities.js +7 -1
- package/src/Defaults.js +1 -0
- package/src/containers/plugins/SimpleRestContainer.js +129 -52
- package/src/scripting/CompilerCsv.js +1 -1
- package/src/scripting/MatchFunctions.js +21 -0
- package/src/scripting/ScriptingProvider.js +49 -40
- package/src/scripting/helper.js +3 -3
- package/src/scripting/logichook/LogicHookConsts.js +4 -0
- package/src/scripting/logichook/LogicHookUtils.js +2 -0
- package/src/scripting/logichook/asserter/JsonPathAsserter.js +1 -1
- package/src/scripting/logichook/asserter/TextWildcardExactAllAsserter.js +8 -0
- package/src/scripting/logichook/asserter/TextWildcardExactAllICAsserter.js +8 -0
- package/src/scripting/logichook/asserter/TextWildcardExactAnyAsserter.js +8 -0
- package/src/scripting/logichook/asserter/TextWildcardExactAnyICAsserter.js +8 -0
- package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -4
- package/test/connectors/convos/hello.convo.txt +6 -0
- package/test/connectors/simplerest.spec.js +129 -2
- package/test/scripting/asserters/convos/text_wildcardexact_all_nok.yml +7 -0
- package/test/scripting/asserters/convos/text_wildcardexact_all_ok.yml +7 -0
- package/test/scripting/asserters/convos/text_wildcardexact_any_nok.yml +7 -0
- package/test/scripting/asserters/convos/text_wildcardexact_any_ok.yml +7 -0
- package/test/scripting/asserters/textWildcardExactAllAsserter.spec.js +51 -0
- package/test/scripting/asserters/textWildcardExactAnyAsserter.spec.js +51 -0
- package/test/scripting/matching/matchingmode.spec.js +43 -0
package/dist/botium-es.js
CHANGED
|
@@ -23,7 +23,7 @@ import isJson$1 from 'is-json';
|
|
|
23
23
|
import esprima from 'esprima';
|
|
24
24
|
import markdownIt from 'markdown-it';
|
|
25
25
|
import xlsx from 'xlsx';
|
|
26
|
-
import sync from 'csv-parse/
|
|
26
|
+
import sync from 'csv-parse/sync';
|
|
27
27
|
import yaml from 'yaml';
|
|
28
28
|
import child_process from 'child_process';
|
|
29
29
|
import socket from 'socket.io-client';
|
|
@@ -36,12 +36,12 @@ import express from 'express';
|
|
|
36
36
|
import bodyParser from 'body-parser';
|
|
37
37
|
|
|
38
38
|
var name = "botium-core";
|
|
39
|
-
var version$1 = "1.
|
|
39
|
+
var version$1 = "1.12.0";
|
|
40
40
|
var description = "The Selenium for Chatbots";
|
|
41
41
|
var main = "index.js";
|
|
42
42
|
var module = "dist/botium-es.js";
|
|
43
43
|
var engines = {
|
|
44
|
-
node: ">=
|
|
44
|
+
node: ">=14.0.0"
|
|
45
45
|
};
|
|
46
46
|
var scripts = {
|
|
47
47
|
postinstall: "node ./report.js",
|
|
@@ -68,65 +68,66 @@ var bugs = {
|
|
|
68
68
|
};
|
|
69
69
|
var homepage = "https://www.botium.ai";
|
|
70
70
|
var dependencies = {
|
|
71
|
-
"@babel/runtime": "^7.
|
|
72
|
-
async: "^3.2.
|
|
73
|
-
"body-parser": "^1.19.
|
|
71
|
+
"@babel/runtime": "^7.16.5",
|
|
72
|
+
async: "^3.2.2",
|
|
73
|
+
"body-parser": "^1.19.1",
|
|
74
74
|
boolean: "^3.1.4",
|
|
75
75
|
bottleneck: "^2.19.5",
|
|
76
|
-
"csv-parse": "^
|
|
77
|
-
debug: "^4.3.
|
|
76
|
+
"csv-parse": "^5.0.3",
|
|
77
|
+
debug: "^4.3.3",
|
|
78
78
|
esprima: "^4.0.1",
|
|
79
|
-
express: "^4.17.
|
|
79
|
+
express: "^4.17.2",
|
|
80
80
|
globby: "11.0.4",
|
|
81
|
-
ioredis: "^4.
|
|
81
|
+
ioredis: "^4.28.2",
|
|
82
82
|
"is-class": "^0.0.9",
|
|
83
83
|
"is-json": "^2.0.1",
|
|
84
84
|
jsonpath: "^1.1.1",
|
|
85
85
|
lodash: "^4.17.21",
|
|
86
|
-
"markdown-it": "^12.
|
|
87
|
-
"mime-types": "^2.1.
|
|
86
|
+
"markdown-it": "^12.3.0",
|
|
87
|
+
"mime-types": "^2.1.34",
|
|
88
88
|
mkdirp: "^1.0.4",
|
|
89
89
|
moment: "^2.29.1",
|
|
90
90
|
mustache: "^4.2.0",
|
|
91
91
|
"promise-retry": "^2.0.1",
|
|
92
|
-
"promise.allsettled": "^1.0.
|
|
92
|
+
"promise.allsettled": "^1.0.5",
|
|
93
93
|
randomatic: "^3.1.1",
|
|
94
94
|
request: "^2.88.2",
|
|
95
95
|
rimraf: "^3.0.2",
|
|
96
96
|
"sanitize-filename": "^1.6.3",
|
|
97
|
-
slugify: "^1.6.
|
|
98
|
-
"socket.io": "^4.
|
|
99
|
-
"socket.io-client": "^4.
|
|
97
|
+
slugify: "^1.6.4",
|
|
98
|
+
"socket.io": "^4.4.0",
|
|
99
|
+
"socket.io-client": "^4.4.0",
|
|
100
100
|
"socketio-auth": "^0.1.1",
|
|
101
101
|
"swagger-jsdoc": "^6.1.0",
|
|
102
|
-
"swagger-ui-express": "^4.
|
|
102
|
+
"swagger-ui-express": "^4.3.0",
|
|
103
103
|
uuid: "^8.3.2",
|
|
104
|
-
vm2: "^3.9.
|
|
104
|
+
vm2: "^3.9.5",
|
|
105
105
|
"write-yaml": "^1.0.0",
|
|
106
|
-
xlsx: "^0.17.
|
|
106
|
+
xlsx: "^0.17.4",
|
|
107
107
|
xregexp: "^5.1.0",
|
|
108
108
|
yaml: "^1.10.2"
|
|
109
109
|
};
|
|
110
110
|
var devDependencies = {
|
|
111
|
-
"@babel/core": "^7.
|
|
112
|
-
"@babel/node": "^7.
|
|
113
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
114
|
-
"@babel/preset-env": "^7.
|
|
111
|
+
"@babel/core": "^7.16.5",
|
|
112
|
+
"@babel/node": "^7.16.5",
|
|
113
|
+
"@babel/plugin-transform-runtime": "^7.16.5",
|
|
114
|
+
"@babel/preset-env": "^7.16.5",
|
|
115
115
|
chai: "^4.3.4",
|
|
116
116
|
"chai-as-promised": "^7.1.1",
|
|
117
117
|
"cross-env": "^7.0.3",
|
|
118
|
-
eslint: "^
|
|
118
|
+
eslint: "^8.4.1",
|
|
119
119
|
"eslint-config-standard": "^16.0.3",
|
|
120
|
-
"eslint-plugin-import": "^2.
|
|
120
|
+
"eslint-plugin-import": "^2.25.3",
|
|
121
121
|
"eslint-plugin-node": "^11.1.0",
|
|
122
|
-
"eslint-plugin-promise": "^5.
|
|
122
|
+
"eslint-plugin-promise": "^5.2.0",
|
|
123
123
|
"eslint-plugin-standard": "^4.1.0",
|
|
124
124
|
"license-checker": "^25.0.1",
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
"license-compatibility-checker": "^0.3.5",
|
|
126
|
+
mocha: "^9.1.3",
|
|
127
|
+
nock: "^13.2.1",
|
|
128
|
+
"npm-check-updates": "^12.0.5",
|
|
128
129
|
nyc: "^15.1.0",
|
|
129
|
-
rollup: "^2.
|
|
130
|
+
rollup: "^2.61.1",
|
|
130
131
|
"rollup-plugin-babel": "^4.4.0",
|
|
131
132
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
132
133
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -188,6 +189,7 @@ var Capabilities = {
|
|
|
188
189
|
SIMPLEREST_PING_BODY: 'SIMPLEREST_PING_BODY',
|
|
189
190
|
SIMPLEREST_PING_BODY_RAW: 'SIMPLEREST_PING_BODY_RAW',
|
|
190
191
|
SIMPLEREST_PING_HEADERS: 'SIMPLEREST_PING_HEADERS',
|
|
192
|
+
SIMPLEREST_PING_REQUEST_HOOK: 'SIMPLEREST_PING_REQUEST_HOOK',
|
|
191
193
|
SIMPLEREST_PING_RETRIES: 'SIMPLEREST_PING_RETRIES',
|
|
192
194
|
SIMPLEREST_PING_TIMEOUT: 'SIMPLEREST_PING_TIMEOUT',
|
|
193
195
|
SIMPLEREST_PING_UPDATE_CONTEXT: 'SIMPLEREST_PING_UPDATE_CONTEXT',
|
|
@@ -197,6 +199,7 @@ var Capabilities = {
|
|
|
197
199
|
SIMPLEREST_START_BODY: 'SIMPLEREST_START_BODY',
|
|
198
200
|
SIMPLEREST_START_BODY_RAW: 'SIMPLEREST_START_BODY_RAW',
|
|
199
201
|
SIMPLEREST_START_HEADERS: 'SIMPLEREST_START_HEADERS',
|
|
202
|
+
SIMPLEREST_START_REQUEST_HOOK: 'SIMPLEREST_START_REQUEST_HOOK',
|
|
200
203
|
SIMPLEREST_START_RETRIES: 'SIMPLEREST_START_RETRIES',
|
|
201
204
|
SIMPLEREST_START_TIMEOUT: 'SIMPLEREST_START_TIMEOUT',
|
|
202
205
|
SIMPLEREST_START_UPDATE_CONTEXT: 'SIMPLEREST_START_UPDATE_CONTEXT',
|
|
@@ -206,10 +209,12 @@ var Capabilities = {
|
|
|
206
209
|
SIMPLEREST_STOP_BODY: 'SIMPLEREST_STOP_BODY',
|
|
207
210
|
SIMPLEREST_STOP_BODY_RAW: 'SIMPLEREST_STOP_BODY_RAW',
|
|
208
211
|
SIMPLEREST_STOP_HEADERS: 'SIMPLEREST_STOP_HEADERS',
|
|
212
|
+
SIMPLEREST_STOP_REQUEST_HOOK: 'SIMPLEREST_STOP_REQUEST_HOOK',
|
|
209
213
|
SIMPLEREST_STOP_RETRIES: 'SIMPLEREST_STOP_RETRIES',
|
|
210
214
|
SIMPLEREST_STOP_TIMEOUT: 'SIMPLEREST_STOP_TIMEOUT',
|
|
211
215
|
SIMPLEREST_INIT_CONTEXT: 'SIMPLEREST_INIT_CONTEXT',
|
|
212
216
|
SIMPLEREST_INIT_TEXT: 'SIMPLEREST_INIT_TEXT',
|
|
217
|
+
SIMPLEREST_INIT_PROCESS_RESPONSE: 'SIMPLEREST_INIT_PROCESS_RESPONSE',
|
|
213
218
|
SIMPLEREST_PROXY_URL: 'SIMPLEREST_PROXY_URL',
|
|
214
219
|
SIMPLEREST_STRICT_SSL: 'SIMPLEREST_STRICT_SSL',
|
|
215
220
|
SIMPLEREST_URL: 'SIMPLEREST_URL',
|
|
@@ -224,11 +229,13 @@ var Capabilities = {
|
|
|
224
229
|
SIMPLEREST_START_HOOK: 'SIMPLEREST_START_HOOK',
|
|
225
230
|
SIMPLEREST_STOP_HOOK: 'SIMPLEREST_STOP_HOOK',
|
|
226
231
|
SIMPLEREST_REQUEST_HOOK: 'SIMPLEREST_REQUEST_HOOK',
|
|
232
|
+
SIMPLEREST_PARSER_HOOK: 'SIMPLEREST_PARSER_HOOK',
|
|
227
233
|
SIMPLEREST_POLL_URL: 'SIMPLEREST_POLL_URL',
|
|
228
234
|
SIMPLEREST_POLL_VERB: 'SIMPLEREST_POLL_VERB',
|
|
229
235
|
SIMPLEREST_POLL_BODY: 'SIMPLEREST_POLL_BODY',
|
|
230
236
|
SIMPLEREST_POLL_BODY_RAW: 'SIMPLEREST_POLL_BODY_RAW',
|
|
231
237
|
SIMPLEREST_POLL_HEADERS: 'SIMPLEREST_POLL_HEADERS',
|
|
238
|
+
SIMPLEREST_POLL_REQUEST_HOOK: 'SIMPLEREST_POLL_REQUEST_HOOK',
|
|
232
239
|
SIMPLEREST_POLL_INTERVAL: 'SIMPLEREST_POLL_INTERVAL',
|
|
233
240
|
SIMPLEREST_POLL_TIMEOUT: 'SIMPLEREST_PING_TIMEOUT',
|
|
234
241
|
SIMPLEREST_POLL_UPDATE_CONTEXT: 'SIMPLEREST_POLL_UPDATE_CONTEXT',
|
|
@@ -276,7 +283,7 @@ var Capabilities = {
|
|
|
276
283
|
SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
|
|
277
284
|
SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
|
|
278
285
|
SCRIPTING_FORCE_BOT_CONSUMED: 'SCRIPTING_FORCE_BOT_CONSUMED',
|
|
279
|
-
// regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
|
|
286
|
+
// regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, wildcardExact, wildcardExactIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
|
|
280
287
|
SCRIPTING_MATCHING_MODE: 'SCRIPTING_MATCHING_MODE',
|
|
281
288
|
// all, first, random
|
|
282
289
|
SCRIPTING_UTTEXPANSION_MODE: 'SCRIPTING_UTTEXPANSION_MODE',
|
|
@@ -324,6 +331,7 @@ Capabilities.SIMPLEREST_PING_VERB;
|
|
|
324
331
|
Capabilities.SIMPLEREST_PING_BODY;
|
|
325
332
|
Capabilities.SIMPLEREST_PING_BODY_RAW;
|
|
326
333
|
Capabilities.SIMPLEREST_PING_HEADERS;
|
|
334
|
+
Capabilities.SIMPLEREST_PING_REQUEST_HOOK;
|
|
327
335
|
Capabilities.SIMPLEREST_PING_RETRIES;
|
|
328
336
|
Capabilities.SIMPLEREST_PING_TIMEOUT;
|
|
329
337
|
Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT;
|
|
@@ -333,6 +341,7 @@ Capabilities.SIMPLEREST_START_VERB;
|
|
|
333
341
|
Capabilities.SIMPLEREST_START_BODY;
|
|
334
342
|
Capabilities.SIMPLEREST_START_BODY_RAW;
|
|
335
343
|
Capabilities.SIMPLEREST_START_HEADERS;
|
|
344
|
+
Capabilities.SIMPLEREST_START_REQUEST_HOOK;
|
|
336
345
|
Capabilities.SIMPLEREST_START_RETRIES;
|
|
337
346
|
Capabilities.SIMPLEREST_START_TIMEOUT;
|
|
338
347
|
Capabilities.SIMPLEREST_START_UPDATE_CONTEXT;
|
|
@@ -342,10 +351,12 @@ Capabilities.SIMPLEREST_STOP_VERB;
|
|
|
342
351
|
Capabilities.SIMPLEREST_STOP_BODY;
|
|
343
352
|
Capabilities.SIMPLEREST_STOP_BODY_RAW;
|
|
344
353
|
Capabilities.SIMPLEREST_STOP_HEADERS;
|
|
354
|
+
Capabilities.SIMPLEREST_STOP_REQUEST_HOOK;
|
|
345
355
|
Capabilities.SIMPLEREST_STOP_RETRIES;
|
|
346
356
|
Capabilities.SIMPLEREST_STOP_TIMEOUT;
|
|
347
357
|
Capabilities.SIMPLEREST_INIT_CONTEXT;
|
|
348
358
|
Capabilities.SIMPLEREST_INIT_TEXT;
|
|
359
|
+
Capabilities.SIMPLEREST_INIT_PROCESS_RESPONSE;
|
|
349
360
|
Capabilities.SIMPLEREST_PROXY_URL;
|
|
350
361
|
Capabilities.SIMPLEREST_STRICT_SSL;
|
|
351
362
|
Capabilities.SIMPLEREST_URL;
|
|
@@ -360,11 +371,13 @@ Capabilities.SIMPLEREST_BODY_RAW;
|
|
|
360
371
|
Capabilities.SIMPLEREST_START_HOOK;
|
|
361
372
|
Capabilities.SIMPLEREST_STOP_HOOK;
|
|
362
373
|
Capabilities.SIMPLEREST_REQUEST_HOOK;
|
|
374
|
+
Capabilities.SIMPLEREST_PARSER_HOOK;
|
|
363
375
|
Capabilities.SIMPLEREST_POLL_URL;
|
|
364
376
|
Capabilities.SIMPLEREST_POLL_VERB;
|
|
365
377
|
Capabilities.SIMPLEREST_POLL_BODY;
|
|
366
378
|
Capabilities.SIMPLEREST_POLL_BODY_RAW;
|
|
367
379
|
Capabilities.SIMPLEREST_POLL_HEADERS;
|
|
380
|
+
Capabilities.SIMPLEREST_POLL_REQUEST_HOOK;
|
|
368
381
|
Capabilities.SIMPLEREST_POLL_INTERVAL;
|
|
369
382
|
Capabilities.SIMPLEREST_POLL_TIMEOUT;
|
|
370
383
|
Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT;
|
|
@@ -462,6 +475,7 @@ var Defaults$1 = {
|
|
|
462
475
|
[Capabilities.SIMPLEREST_PING_VERB]: 'GET',
|
|
463
476
|
[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT]: true,
|
|
464
477
|
[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE]: false,
|
|
478
|
+
[Capabilities.SIMPLEREST_INIT_PROCESS_RESPONSE]: false,
|
|
465
479
|
[Capabilities.SIMPLEREST_STOP_RETRIES]: 6,
|
|
466
480
|
[Capabilities.SIMPLEREST_STOP_TIMEOUT]: 10000,
|
|
467
481
|
[Capabilities.SIMPLEREST_STOP_VERB]: 'GET',
|
|
@@ -817,7 +831,7 @@ function getCjsExportFromNamespace (n) {
|
|
|
817
831
|
return n && n['default'] || n;
|
|
818
832
|
}
|
|
819
833
|
|
|
820
|
-
const BotiumError$
|
|
834
|
+
const BotiumError$7 = class BotiumError extends Error {
|
|
821
835
|
/**
|
|
822
836
|
*
|
|
823
837
|
* @param message
|
|
@@ -903,10 +917,10 @@ const _getChildErrorsFromContext = context => {
|
|
|
903
917
|
};
|
|
904
918
|
|
|
905
919
|
const botiumErrorFromErr$2 = (message, err) => {
|
|
906
|
-
if (err instanceof BotiumError$
|
|
907
|
-
return new BotiumError$
|
|
920
|
+
if (err instanceof BotiumError$7) {
|
|
921
|
+
return new BotiumError$7(message, err.context, true);
|
|
908
922
|
} else {
|
|
909
|
-
return new BotiumError$
|
|
923
|
+
return new BotiumError$7(message, {
|
|
910
924
|
err
|
|
911
925
|
}, true);
|
|
912
926
|
}
|
|
@@ -921,7 +935,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
921
935
|
let children = [];
|
|
922
936
|
|
|
923
937
|
for (const error of errors) {
|
|
924
|
-
if (error instanceof BotiumError$
|
|
938
|
+
if (error instanceof BotiumError$7) {
|
|
925
939
|
const childErrors = flat && _getChildErrorsFromContext(error.context);
|
|
926
940
|
|
|
927
941
|
if (childErrors && childErrors.length) {
|
|
@@ -934,7 +948,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
934
948
|
}
|
|
935
949
|
}
|
|
936
950
|
|
|
937
|
-
const result = new BotiumError$
|
|
951
|
+
const result = new BotiumError$7(message, {
|
|
938
952
|
errors: children,
|
|
939
953
|
type,
|
|
940
954
|
source
|
|
@@ -943,7 +957,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
943
957
|
};
|
|
944
958
|
|
|
945
959
|
var BotiumError_1 = {
|
|
946
|
-
BotiumError: BotiumError$
|
|
960
|
+
BotiumError: BotiumError$7,
|
|
947
961
|
botiumErrorFromErr: botiumErrorFromErr$2,
|
|
948
962
|
botiumErrorFromList: botiumErrorFromList$2
|
|
949
963
|
};
|
|
@@ -1035,6 +1049,18 @@ var LogicHookConsts = {
|
|
|
1035
1049
|
}, {
|
|
1036
1050
|
name: 'TEXT_WILDCARD_ALL_IC',
|
|
1037
1051
|
className: 'TextWildcardAllICAsserter'
|
|
1052
|
+
}, {
|
|
1053
|
+
name: 'TEXT_WILDCARDEXACT_ANY',
|
|
1054
|
+
className: 'TextWildcardExactAnyAsserter'
|
|
1055
|
+
}, {
|
|
1056
|
+
name: 'TEXT_WILDCARDEXACT_ANY_IC',
|
|
1057
|
+
className: 'TextWildcardExactAnyICAsserter'
|
|
1058
|
+
}, {
|
|
1059
|
+
name: 'TEXT_WILDCARDEXACT_ALL',
|
|
1060
|
+
className: 'TextWildcardExactAllAsserter'
|
|
1061
|
+
}, {
|
|
1062
|
+
name: 'TEXT_WILDCARDEXACT_ALL_IC',
|
|
1063
|
+
className: 'TextWildcardExactAllICAsserter'
|
|
1038
1064
|
}, {
|
|
1039
1065
|
name: 'TEXT_REGEXP_ANY',
|
|
1040
1066
|
className: 'TextRegexpAnyAsserter'
|
|
@@ -1112,7 +1138,7 @@ const {
|
|
|
1112
1138
|
} = vm2;
|
|
1113
1139
|
const debug$k = debug$l('botium-core-asserterUtils');
|
|
1114
1140
|
const {
|
|
1115
|
-
BotiumError: BotiumError$
|
|
1141
|
+
BotiumError: BotiumError$6
|
|
1116
1142
|
} = BotiumError_1;
|
|
1117
1143
|
const {
|
|
1118
1144
|
DEFAULT_ASSERTERS,
|
|
@@ -1263,7 +1289,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1263
1289
|
|
|
1264
1290
|
const _checkUnsafe = () => {
|
|
1265
1291
|
if (!this.caps[Capabilities.SECURITY_ALLOW_UNSAFE]) {
|
|
1266
|
-
throw new BotiumError$
|
|
1292
|
+
throw new BotiumError$6('Security Error. Using unsafe component is not allowed', {
|
|
1267
1293
|
type: 'security',
|
|
1268
1294
|
subtype: 'allow unsafe',
|
|
1269
1295
|
source: path.basename(__filename),
|
|
@@ -1407,6 +1433,11 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1407
1433
|
ref,
|
|
1408
1434
|
...this.buildScriptContext
|
|
1409
1435
|
}, this.caps, args);
|
|
1436
|
+
} else if (lodash.isFunction(CheckClass.PluginClass)) {
|
|
1437
|
+
return CheckClass.PluginClass({
|
|
1438
|
+
ref,
|
|
1439
|
+
...this.buildScriptContext
|
|
1440
|
+
}, this.caps, args);
|
|
1410
1441
|
} else {
|
|
1411
1442
|
throw new Error(`${src} class or function expected`);
|
|
1412
1443
|
}
|
|
@@ -1733,7 +1764,7 @@ const toString$3 = value => {
|
|
|
1733
1764
|
};
|
|
1734
1765
|
|
|
1735
1766
|
const flatString = str => {
|
|
1736
|
-
return str.split('\n').map(s => s.trim()).join(' ');
|
|
1767
|
+
return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
|
|
1737
1768
|
};
|
|
1738
1769
|
|
|
1739
1770
|
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
@@ -2164,7 +2195,7 @@ const convoStepToLines$2 = step => {
|
|
|
2164
2195
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
|
|
2165
2196
|
}
|
|
2166
2197
|
|
|
2167
|
-
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.map(b => flatString(b.text)).join('|'));
|
|
2198
|
+
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
|
|
2168
2199
|
if (step.media && step.media.length > 0) lines.push('MEDIA ' + step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri).join('|'));
|
|
2169
2200
|
|
|
2170
2201
|
if (step.cards && step.cards.length > 0) {
|
|
@@ -2174,7 +2205,7 @@ const convoStepToLines$2 = step => {
|
|
|
2174
2205
|
if (c.subtext) cardTexts = cardTexts.concat(lodash.isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2175
2206
|
if (c.content) cardTexts = cardTexts.concat(lodash.isArray(c.content) ? c.content : [c.content]);
|
|
2176
2207
|
if (cardTexts.length > 0) lines.push('CARDS ' + cardTexts.map(c => flatString(c)).join('|'));
|
|
2177
|
-
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.map(b => flatString(b.text)).join('|'));
|
|
2208
|
+
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
|
|
2178
2209
|
if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
|
|
2179
2210
|
});
|
|
2180
2211
|
}
|
|
@@ -2217,7 +2248,7 @@ const {
|
|
|
2217
2248
|
toString: toString$2
|
|
2218
2249
|
} = helper;
|
|
2219
2250
|
const {
|
|
2220
|
-
BotiumError: BotiumError$
|
|
2251
|
+
BotiumError: BotiumError$5
|
|
2221
2252
|
} = BotiumError_1; // If they got parameter, then it will be a string always.
|
|
2222
2253
|
// the receiver can decide what to do with it,
|
|
2223
2254
|
// convert to int,
|
|
@@ -2386,7 +2417,7 @@ const SCRIPTING_FUNCTIONS$1 = lodash.mapValues(SCRIPTING_FUNCTIONS_RAW, (funcOrS
|
|
|
2386
2417
|
return {
|
|
2387
2418
|
handler: (caps, ...rest) => {
|
|
2388
2419
|
if (!caps[Capabilities.SECURITY_ALLOW_UNSAFE] && funcOrStruct.unsafe) {
|
|
2389
|
-
throw new BotiumError$
|
|
2420
|
+
throw new BotiumError$5(`Security Error. Using unsafe scripting memory function ${name} is not allowed`, {
|
|
2390
2421
|
type: 'security',
|
|
2391
2422
|
subtype: 'allow unsafe',
|
|
2392
2423
|
source: path.basename(__filename),
|
|
@@ -2535,7 +2566,7 @@ ScriptingMemory.SCRIPTING_FUNCTIONS;
|
|
|
2535
2566
|
|
|
2536
2567
|
const debug$i = debug$l('botium-core-Convo');
|
|
2537
2568
|
const {
|
|
2538
|
-
BotiumError: BotiumError$
|
|
2569
|
+
BotiumError: BotiumError$4,
|
|
2539
2570
|
botiumErrorFromErr: botiumErrorFromErr$1,
|
|
2540
2571
|
botiumErrorFromList: botiumErrorFromList$1
|
|
2541
2572
|
} = BotiumError_1;
|
|
@@ -3064,7 +3095,7 @@ class Convo$6 {
|
|
|
3064
3095
|
}
|
|
3065
3096
|
|
|
3066
3097
|
if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
|
|
3067
|
-
const failErr = new BotiumError$
|
|
3098
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
|
|
3068
3099
|
debug$i(failErr);
|
|
3069
3100
|
|
|
3070
3101
|
try {
|
|
@@ -3167,7 +3198,7 @@ class Convo$6 {
|
|
|
3167
3198
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3168
3199
|
} catch (failErr) {}
|
|
3169
3200
|
|
|
3170
|
-
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$
|
|
3201
|
+
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$4) {
|
|
3171
3202
|
assertErrors.push(err);
|
|
3172
3203
|
} else {
|
|
3173
3204
|
throw failErr;
|
|
@@ -3184,7 +3215,7 @@ class Convo$6 {
|
|
|
3184
3215
|
}
|
|
3185
3216
|
}
|
|
3186
3217
|
} else {
|
|
3187
|
-
const failErr = new BotiumError$
|
|
3218
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util.inspect(convoStep.sender)}`);
|
|
3188
3219
|
debug$i(failErr);
|
|
3189
3220
|
|
|
3190
3221
|
try {
|
|
@@ -3195,7 +3226,7 @@ class Convo$6 {
|
|
|
3195
3226
|
}
|
|
3196
3227
|
} catch (err) {
|
|
3197
3228
|
if (lastMeConvoStep) {
|
|
3198
|
-
if (err instanceof BotiumError$
|
|
3229
|
+
if (err instanceof BotiumError$4 && err.context) {
|
|
3199
3230
|
err.context.input = new ConvoStep$1(lastMeConvoStep);
|
|
3200
3231
|
err.context.transcript = [...transcriptSteps, { ...transcriptStep
|
|
3201
3232
|
}];
|
|
@@ -3230,11 +3261,11 @@ class Convo$6 {
|
|
|
3230
3261
|
|
|
3231
3262
|
if (lodash.isArray(expected)) {
|
|
3232
3263
|
if (!lodash.isArray(result)) {
|
|
3233
|
-
throw new BotiumError$
|
|
3264
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array, got "${result}"`);
|
|
3234
3265
|
}
|
|
3235
3266
|
|
|
3236
3267
|
if (expected.length !== result.length) {
|
|
3237
|
-
throw new BotiumError$
|
|
3268
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array length ${expected.length}, got ${result.length}`);
|
|
3238
3269
|
}
|
|
3239
3270
|
|
|
3240
3271
|
for (let i = 0; i < expected.length; i++) {
|
|
@@ -3245,7 +3276,7 @@ class Convo$6 {
|
|
|
3245
3276
|
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
3246
3277
|
this._compareObject(container, scriptingMemory, convoStep, result[key], expected[key]);
|
|
3247
3278
|
} else {
|
|
3248
|
-
throw new BotiumError$
|
|
3279
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response "${result}" missing expected property: ${key}`);
|
|
3249
3280
|
}
|
|
3250
3281
|
});
|
|
3251
3282
|
} else {
|
|
@@ -3373,17 +3404,17 @@ class Convo$6 {
|
|
|
3373
3404
|
const alreadyThereAt = parentPConvos.indexOf(includeLogicHook);
|
|
3374
3405
|
|
|
3375
3406
|
if (alreadyThereAt >= 0) {
|
|
3376
|
-
throw new BotiumError$
|
|
3407
|
+
throw new BotiumError$4(`Partial convos are included circular. "${includeLogicHook}" is referenced by "/${parentPConvos.slice(0, alreadyThereAt).join('/')}" and by "/${parentPConvos.join('/')}" `);
|
|
3377
3408
|
}
|
|
3378
3409
|
|
|
3379
3410
|
if (!partialConvos || Object.keys(partialConvos).length === 0) {
|
|
3380
|
-
throw new BotiumError$
|
|
3411
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (There are no partial convos)`);
|
|
3381
3412
|
}
|
|
3382
3413
|
|
|
3383
3414
|
const partialConvo = partialConvos[includeLogicHook];
|
|
3384
3415
|
|
|
3385
3416
|
if (!partialConvo) {
|
|
3386
|
-
throw new BotiumError$
|
|
3417
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
|
|
3387
3418
|
}
|
|
3388
3419
|
|
|
3389
3420
|
_getEffectiveConversationRecursive(partialConvo.conversation, [...parentPConvos, includeLogicHook], result, true);
|
|
@@ -3482,6 +3513,24 @@ const wildcard = ignoreCase => (botresponse, utterance) => {
|
|
|
3482
3513
|
return regexp.test(botresponse);
|
|
3483
3514
|
};
|
|
3484
3515
|
|
|
3516
|
+
const wildcardExact = ignoreCase => (botresponse, utterance) => {
|
|
3517
|
+
if (lodash.isUndefined(botresponse)) {
|
|
3518
|
+
if (utterance.trim() === '*') return true;else return false;
|
|
3519
|
+
}
|
|
3520
|
+
|
|
3521
|
+
utterance = toString(utterance);
|
|
3522
|
+
botresponse = _normalize(botresponse);
|
|
3523
|
+
const numWildcards = utterance.split('*').length - 1;
|
|
3524
|
+
|
|
3525
|
+
if (numWildcards > 10) {
|
|
3526
|
+
throw new Error('Maximum number of 10 wildcards supported.');
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
const utteranceRe = '^' + quoteRegexpString(utterance).replace(/\\\*/g, '(.*)') + '$';
|
|
3530
|
+
const regexp = ignoreCase ? new RegExp(utteranceRe, 'i') : new RegExp(utteranceRe, '');
|
|
3531
|
+
return regexp.test(botresponse);
|
|
3532
|
+
};
|
|
3533
|
+
|
|
3485
3534
|
const include = ignoreCase => (botresponse, utterance) => {
|
|
3486
3535
|
if (lodash.isUndefined(botresponse)) return false;
|
|
3487
3536
|
utterance = toString(utterance);
|
|
@@ -3513,6 +3562,8 @@ const getMatchFunction$1 = matchingMode => {
|
|
|
3513
3562
|
return regexp(matchingMode === 'regexpIgnoreCase');
|
|
3514
3563
|
} else if (matchingMode === 'wildcard' || matchingMode === 'wildcardIgnoreCase' || matchingMode === 'wildcardLowerCase') {
|
|
3515
3564
|
return wildcard(matchingMode === 'wildcardIgnoreCase' || matchingMode === 'wildcardLowerCase');
|
|
3565
|
+
} else if (matchingMode === 'wildcardExact' || matchingMode === 'wildcardExactIgnoreCase') {
|
|
3566
|
+
return wildcardExact(matchingMode === 'wildcardExactIgnoreCase');
|
|
3516
3567
|
} else if (matchingMode === 'include' || matchingMode === 'includeIgnoreCase' || matchingMode === 'includeLowerCase') {
|
|
3517
3568
|
return include(matchingMode === 'includeIgnoreCase' || matchingMode === 'includeLowerCase');
|
|
3518
3569
|
} else if (matchingMode === 'equals' || matchingMode === 'equalsIgnoreCase') {
|
|
@@ -3525,6 +3576,7 @@ const getMatchFunction$1 = matchingMode => {
|
|
|
3525
3576
|
var MatchFunctions = {
|
|
3526
3577
|
regexp,
|
|
3527
3578
|
wildcard,
|
|
3579
|
+
wildcardExact,
|
|
3528
3580
|
include,
|
|
3529
3581
|
equals,
|
|
3530
3582
|
getMatchFunction: getMatchFunction$1
|
|
@@ -3744,7 +3796,7 @@ const {
|
|
|
3744
3796
|
} = vm2;
|
|
3745
3797
|
const debug$h = debug$l('botium-core-HookUtils');
|
|
3746
3798
|
const {
|
|
3747
|
-
BotiumError: BotiumError$
|
|
3799
|
+
BotiumError: BotiumError$3
|
|
3748
3800
|
} = BotiumError_1;
|
|
3749
3801
|
|
|
3750
3802
|
const executeHook$2 = async (caps, hook, args) => {
|
|
@@ -3816,7 +3868,7 @@ const getHook$3 = (caps, data) => {
|
|
|
3816
3868
|
|
|
3817
3869
|
if (resultWithRequire) {
|
|
3818
3870
|
if (!allowUnsafe) {
|
|
3819
|
-
throw new BotiumError$
|
|
3871
|
+
throw new BotiumError$3('Security Error. Using unsafe custom hook with require is not allowed', {
|
|
3820
3872
|
type: 'security',
|
|
3821
3873
|
subtype: 'allow unsafe',
|
|
3822
3874
|
source: path.basename(__filename),
|
|
@@ -4983,6 +5035,9 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4983
5035
|
|
|
4984
5036
|
};
|
|
4985
5037
|
|
|
5038
|
+
const {
|
|
5039
|
+
parse
|
|
5040
|
+
} = sync;
|
|
4986
5041
|
const debug$c = debug$l('botium-core-CompilerCsv');
|
|
4987
5042
|
const {
|
|
4988
5043
|
Convo: Convo$3
|
|
@@ -5055,7 +5110,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5055
5110
|
let rows;
|
|
5056
5111
|
|
|
5057
5112
|
try {
|
|
5058
|
-
rows =
|
|
5113
|
+
rows = parse(scriptData, {
|
|
5059
5114
|
delimiter,
|
|
5060
5115
|
escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
|
|
5061
5116
|
quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
|
|
@@ -5518,7 +5573,7 @@ const {
|
|
|
5518
5573
|
ConvoStep
|
|
5519
5574
|
} = Convo_1;
|
|
5520
5575
|
const {
|
|
5521
|
-
BotiumError: BotiumError$
|
|
5576
|
+
BotiumError: BotiumError$2,
|
|
5522
5577
|
botiumErrorFromList,
|
|
5523
5578
|
botiumErrorFromErr
|
|
5524
5579
|
} = BotiumError_1;
|
|
@@ -5798,7 +5853,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5798
5853
|
message += ' expected to match ';
|
|
5799
5854
|
message += tomatch && tomatch.length > 1 ? 'one of ' : '';
|
|
5800
5855
|
message += `${tomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5801
|
-
throw new BotiumError$
|
|
5856
|
+
throw new BotiumError$2(message, {
|
|
5802
5857
|
type: 'asserter',
|
|
5803
5858
|
source: 'TextMatchAsserter',
|
|
5804
5859
|
context: {
|
|
@@ -5828,7 +5883,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5828
5883
|
message += ' expected NOT to match ';
|
|
5829
5884
|
message += nottomatch && nottomatch.length > 1 ? 'one of ' : '';
|
|
5830
5885
|
message += `${nottomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5831
|
-
throw new BotiumError$
|
|
5886
|
+
throw new BotiumError$2(message, {
|
|
5832
5887
|
type: 'asserter',
|
|
5833
5888
|
source: 'TextMatchAsserter',
|
|
5834
5889
|
context: {
|
|
@@ -5875,7 +5930,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5875
5930
|
if (asserter[notAsserterType]) {
|
|
5876
5931
|
return p(this.retryHelperAsserter, () => asserter[notAsserterType](params));
|
|
5877
5932
|
} else {
|
|
5878
|
-
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$
|
|
5933
|
+
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$2(`${convoStep.stepTag}: Expected asserter ${asserter.name || asserterSpec.name} with args "${params.args}" to fail`, {
|
|
5879
5934
|
type: 'asserter',
|
|
5880
5935
|
source: asserter.name || asserterSpec.name,
|
|
5881
5936
|
params: {
|
|
@@ -6160,11 +6215,37 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6160
6215
|
};
|
|
6161
6216
|
}
|
|
6162
6217
|
|
|
6218
|
+
ReadScriptFromBuffer(scriptBuffer, scriptingFormat, scriptingTypes = null) {
|
|
6219
|
+
if (lodash.isString(scriptingTypes)) scriptingTypes = [scriptingTypes];
|
|
6220
|
+
if (lodash.isArray(scriptingTypes) && scriptingTypes.length === 0) scriptingTypes = null;
|
|
6221
|
+
const result = {
|
|
6222
|
+
convos: [],
|
|
6223
|
+
utterances: [],
|
|
6224
|
+
pconvos: [],
|
|
6225
|
+
scriptingMemories: []
|
|
6226
|
+
};
|
|
6227
|
+
|
|
6228
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_UTTERANCES)) {
|
|
6229
|
+
result.utterances = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_UTTERANCES);
|
|
6230
|
+
}
|
|
6231
|
+
|
|
6232
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_PCONVO)) {
|
|
6233
|
+
result.pconvos = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6234
|
+
}
|
|
6235
|
+
|
|
6236
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_CONVO)) {
|
|
6237
|
+
result.convos = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_CONVO);
|
|
6238
|
+
}
|
|
6239
|
+
|
|
6240
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY)) {
|
|
6241
|
+
result.scriptingMemories = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6242
|
+
}
|
|
6243
|
+
|
|
6244
|
+
return result;
|
|
6245
|
+
}
|
|
6246
|
+
|
|
6163
6247
|
ReadScript(convoDir, filename) {
|
|
6164
|
-
let
|
|
6165
|
-
let fileUtterances = [];
|
|
6166
|
-
let filePartialConvos = [];
|
|
6167
|
-
let fileScriptingMemories = [];
|
|
6248
|
+
let result = {};
|
|
6168
6249
|
|
|
6169
6250
|
try {
|
|
6170
6251
|
let scriptBuffer = fs.readFileSync(path.resolve(convoDir, filename));
|
|
@@ -6181,36 +6262,25 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6181
6262
|
}
|
|
6182
6263
|
|
|
6183
6264
|
if (filename.endsWith('.xlsx') || filename.endsWith('.xlsm')) {
|
|
6184
|
-
|
|
6185
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6186
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_CONVO);
|
|
6187
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6265
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, [Constants.SCRIPTING_TYPE_UTTERANCES, Constants.SCRIPTING_TYPE_PCONVO, Constants.SCRIPTING_TYPE_CONVO, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY]);
|
|
6188
6266
|
} else if (filename.endsWith('.convo.txt')) {
|
|
6189
|
-
|
|
6267
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_CONVO);
|
|
6190
6268
|
} else if (filename.endsWith('.pconvo.txt')) {
|
|
6191
|
-
|
|
6269
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6192
6270
|
} else if (filename.endsWith('.utterances.txt')) {
|
|
6193
|
-
|
|
6271
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_UTTERANCES);
|
|
6194
6272
|
} else if (filename.endsWith('.scriptingmemory.txt')) {
|
|
6195
|
-
|
|
6273
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6196
6274
|
} else if (filename.endsWith('.convo.csv')) {
|
|
6197
|
-
|
|
6275
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_CONVO);
|
|
6198
6276
|
} else if (filename.endsWith('.pconvo.csv')) {
|
|
6199
|
-
|
|
6277
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6200
6278
|
} else if (filename.endsWith('.yaml') || filename.endsWith('.yml')) {
|
|
6201
|
-
|
|
6202
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6203
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_CONVO);
|
|
6204
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6279
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, [Constants.SCRIPTING_TYPE_UTTERANCES, Constants.SCRIPTING_TYPE_PCONVO, Constants.SCRIPTING_TYPE_CONVO, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY]);
|
|
6205
6280
|
} else if (filename.endsWith('.json')) {
|
|
6206
|
-
|
|
6207
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6208
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_CONVO);
|
|
6209
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6281
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, [Constants.SCRIPTING_TYPE_UTTERANCES, Constants.SCRIPTING_TYPE_PCONVO, Constants.SCRIPTING_TYPE_CONVO, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY]);
|
|
6210
6282
|
} else if (filename.endsWith('.markdown') || filename.endsWith('.md')) {
|
|
6211
|
-
|
|
6212
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, Constants.SCRIPTING_TYPE_CONVO);
|
|
6213
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6283
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, [Constants.SCRIPTING_TYPE_UTTERANCES, Constants.SCRIPTING_TYPE_PCONVO, Constants.SCRIPTING_TYPE_CONVO]);
|
|
6214
6284
|
} else {
|
|
6215
6285
|
debug$9(`ReadScript - dropped file: ${filename}, filename not supported`);
|
|
6216
6286
|
}
|
|
@@ -6220,8 +6290,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6220
6290
|
} // Compilers saved the convos, and we alter here the saved version too
|
|
6221
6291
|
|
|
6222
6292
|
|
|
6223
|
-
if (
|
|
6224
|
-
|
|
6293
|
+
if (result.convos && result.convos.length > 0) {
|
|
6294
|
+
result.convos.forEach(fileConvo => {
|
|
6225
6295
|
fileConvo.sourceTag = {
|
|
6226
6296
|
convoDir,
|
|
6227
6297
|
filename
|
|
@@ -6234,12 +6304,12 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6234
6304
|
|
|
6235
6305
|
const isSkip = c => c.header.name && skipPattern.test(c.header.name.toLowerCase());
|
|
6236
6306
|
|
|
6237
|
-
|
|
6238
|
-
|
|
6307
|
+
result.convos.filter(c => isSkip(c)).forEach(c => debug$9(`ReadScript - skipping convo '${c.header.name}'`));
|
|
6308
|
+
result.convos = result.convos.filter(c => !isSkip(c));
|
|
6239
6309
|
}
|
|
6240
6310
|
|
|
6241
|
-
if (
|
|
6242
|
-
|
|
6311
|
+
if (result.pconvos && result.pconvos.length > 0) {
|
|
6312
|
+
result.pconvos.forEach(filePartialConvo => {
|
|
6243
6313
|
filePartialConvo.sourceTag = {
|
|
6244
6314
|
convoDir,
|
|
6245
6315
|
filename
|
|
@@ -6251,23 +6321,23 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6251
6321
|
});
|
|
6252
6322
|
}
|
|
6253
6323
|
|
|
6254
|
-
if (
|
|
6255
|
-
|
|
6324
|
+
if (result.scriptingMemories && result.scriptingMemories.length > 0) {
|
|
6325
|
+
result.scriptingMemories.forEach(scriptingMemory => {
|
|
6256
6326
|
scriptingMemory.sourceTag = {
|
|
6257
6327
|
filename
|
|
6258
6328
|
};
|
|
6259
6329
|
});
|
|
6260
6330
|
}
|
|
6261
6331
|
|
|
6262
|
-
if (
|
|
6263
|
-
|
|
6332
|
+
if (result.utterances) {
|
|
6333
|
+
result.utterances = this._tagAndCleanupUtterances(result.utterances, convoDir, filename);
|
|
6264
6334
|
}
|
|
6265
6335
|
|
|
6266
6336
|
return {
|
|
6267
|
-
convos:
|
|
6268
|
-
utterances:
|
|
6269
|
-
pconvos:
|
|
6270
|
-
scriptingMemories:
|
|
6337
|
+
convos: result.convos || [],
|
|
6338
|
+
utterances: result.utterances || [],
|
|
6339
|
+
pconvos: result.pconvos || [],
|
|
6340
|
+
scriptingMemories: result.scriptingMemories || []
|
|
6271
6341
|
};
|
|
6272
6342
|
}
|
|
6273
6343
|
|
|
@@ -6294,7 +6364,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6294
6364
|
});
|
|
6295
6365
|
|
|
6296
6366
|
if (aggregatedNoNames.length) {
|
|
6297
|
-
throw new BotiumError$
|
|
6367
|
+
throw new BotiumError$2('Scripting Memory Definition(s) without name', {
|
|
6298
6368
|
type: 'Scripting Memory',
|
|
6299
6369
|
subtype: 'Scripting Memory without name',
|
|
6300
6370
|
source: 'ScriptingProvider',
|
|
@@ -6310,7 +6380,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6310
6380
|
});
|
|
6311
6381
|
|
|
6312
6382
|
if (aggregatedNoVariables.length) {
|
|
6313
|
-
throw new BotiumError$
|
|
6383
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariables.map(e => e.header.name).join(', ')} without variable`, {
|
|
6314
6384
|
type: 'Scripting Memory',
|
|
6315
6385
|
subtype: 'Scripting Memory without variable',
|
|
6316
6386
|
source: 'ScriptingProvider',
|
|
@@ -6326,7 +6396,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6326
6396
|
});
|
|
6327
6397
|
|
|
6328
6398
|
if (aggregatedNoVariableNames.length) {
|
|
6329
|
-
throw new BotiumError$
|
|
6399
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariableNames.map(e => e.header.name).join(', ')} without variable name`, {
|
|
6330
6400
|
type: 'Scripting Memory',
|
|
6331
6401
|
subtype: 'Scripting Memory without variable name',
|
|
6332
6402
|
source: 'ScriptingProvider',
|
|
@@ -6358,7 +6428,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6358
6428
|
}
|
|
6359
6429
|
|
|
6360
6430
|
if (aggregatedDuplicates.length) {
|
|
6361
|
-
throw new BotiumError$
|
|
6431
|
+
throw new BotiumError$2(`Scripting Memory Definition name(s) "${lodash.uniq(aggregatedDuplicates.map(d => d.scriptingMemory.header.name)).join(', ')}" are not unique`, {
|
|
6362
6432
|
type: 'Scripting Memory',
|
|
6363
6433
|
subtype: 'Scripting Memory name collision',
|
|
6364
6434
|
source: 'ScriptingProvider',
|
|
@@ -6395,7 +6465,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6395
6465
|
}
|
|
6396
6466
|
|
|
6397
6467
|
if (aggregatedIntersections.length) {
|
|
6398
|
-
throw new BotiumError$
|
|
6468
|
+
throw new BotiumError$2(`Scripting Memory Definitions "${aggregatedIntersections.map(i => i.scriptingMemory.header.name).join(', ')}" are invalid because variable name collision"`, {
|
|
6399
6469
|
type: 'Scripting Memory',
|
|
6400
6470
|
subtype: 'Scripting Memory variable name collision',
|
|
6401
6471
|
source: 'ScriptingProvider',
|
|
@@ -6717,7 +6787,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6717
6787
|
}
|
|
6718
6788
|
} else {
|
|
6719
6789
|
expandedConvos.push(Object.assign(lodash.cloneDeep(currentConvo), {
|
|
6720
|
-
conversation: convoStepsStack
|
|
6790
|
+
conversation: lodash.cloneDeep(convoStepsStack)
|
|
6721
6791
|
}));
|
|
6722
6792
|
}
|
|
6723
6793
|
}
|
|
@@ -6838,7 +6908,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6838
6908
|
}
|
|
6839
6909
|
} else if (scriptingMemories) {
|
|
6840
6910
|
if (!scriptingMemories.header || !scriptingMemories.header.name) {
|
|
6841
|
-
throw new BotiumError$
|
|
6911
|
+
throw new BotiumError$2('Scripting Memory Definition has no name', {
|
|
6842
6912
|
type: 'Compiler',
|
|
6843
6913
|
subtype: 'Scripting memory without name',
|
|
6844
6914
|
source: 'ScriptingProvider',
|
|
@@ -6849,7 +6919,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6849
6919
|
}
|
|
6850
6920
|
|
|
6851
6921
|
if (!scriptingMemories.values || !Object.keys(scriptingMemories.values).length) {
|
|
6852
|
-
throw new BotiumError$
|
|
6922
|
+
throw new BotiumError$2('Scripting Memory Definition has no variables', {
|
|
6853
6923
|
type: 'Compiler',
|
|
6854
6924
|
subtype: 'Scripting memory without variable',
|
|
6855
6925
|
source: 'ScriptingProvider',
|
|
@@ -6860,7 +6930,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6860
6930
|
}
|
|
6861
6931
|
|
|
6862
6932
|
if (scriptingMemories.values && !lodash.isUndefined(scriptingMemories.values[''])) {
|
|
6863
|
-
throw new BotiumError$
|
|
6933
|
+
throw new BotiumError$2('Scripting Memory Definition variable has no name', {
|
|
6864
6934
|
type: 'Compiler',
|
|
6865
6935
|
subtype: 'Scripting memory without variable name',
|
|
6866
6936
|
source: 'ScriptingProvider',
|
|
@@ -7822,6 +7892,9 @@ const {
|
|
|
7822
7892
|
const {
|
|
7823
7893
|
escapeJSONString
|
|
7824
7894
|
} = Utils;
|
|
7895
|
+
const {
|
|
7896
|
+
BotiumError: BotiumError$1
|
|
7897
|
+
} = BotiumError_1;
|
|
7825
7898
|
|
|
7826
7899
|
mustache.escape = s => s;
|
|
7827
7900
|
|
|
@@ -7869,7 +7942,22 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7869
7942
|
this.startHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_START_HOOK]);
|
|
7870
7943
|
this.stopHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_STOP_HOOK]);
|
|
7871
7944
|
this.requestHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_REQUEST_HOOK]);
|
|
7945
|
+
this.parserHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_PARSER_HOOK]);
|
|
7872
7946
|
this.responseHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_RESPONSE_HOOK]);
|
|
7947
|
+
this.pollRequestHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_POLL_REQUEST_HOOK]);
|
|
7948
|
+
this.requestHooks = {};
|
|
7949
|
+
|
|
7950
|
+
if (this.caps[Capabilities.SIMPLEREST_PING_REQUEST_HOOK]) {
|
|
7951
|
+
this.requestHooks.SIMPLEREST_PING = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_PING_REQUEST_HOOK]);
|
|
7952
|
+
}
|
|
7953
|
+
|
|
7954
|
+
if (this.caps[Capabilities.SIMPLEREST_START_REQUEST_HOOK]) {
|
|
7955
|
+
this.requestHooks.SIMPLEREST_START = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_START_REQUEST_HOOK]);
|
|
7956
|
+
}
|
|
7957
|
+
|
|
7958
|
+
if (this.caps[Capabilities.SIMPLEREST_STOP_REQUEST_HOOK]) {
|
|
7959
|
+
this.requestHooks.SIMPLEREST_STOP = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_STOP_REQUEST_HOOK]);
|
|
7960
|
+
}
|
|
7873
7961
|
}
|
|
7874
7962
|
|
|
7875
7963
|
Build() {
|
|
@@ -7924,17 +8012,24 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7924
8012
|
contextInitComplete();
|
|
7925
8013
|
}, startHookComplete => {
|
|
7926
8014
|
executeHook(this.caps, this.startHook, this.view).then(() => startHookComplete()).catch(startHookComplete);
|
|
8015
|
+
}, inboundListenerComplete => {
|
|
8016
|
+
this._subscribeInbound().then(() => inboundListenerComplete()).catch(inboundListenerComplete);
|
|
8017
|
+
}, startPollingComplete => {
|
|
8018
|
+
this._startPolling().then(() => startPollingComplete()).catch(startPollingComplete);
|
|
7927
8019
|
}, pingComplete => {
|
|
7928
8020
|
if (this.caps[Capabilities.SIMPLEREST_PING_URL]) {
|
|
7929
|
-
this._makeCall('SIMPLEREST_PING').then(
|
|
8021
|
+
this._makeCall('SIMPLEREST_PING').then(body => {
|
|
7930
8022
|
if (this.caps[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT] || this.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE]) {
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
8023
|
+
return this._parseResponseBody(body).then(body => {
|
|
8024
|
+
if (body) {
|
|
8025
|
+
debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} returned JSON response: ${Utils.shortenJsonString(body)}`);
|
|
8026
|
+
return this._processBodyAsync(body, !!this.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT]);
|
|
8027
|
+
} else {
|
|
8028
|
+
debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} didn't return JSON response, ignoring it.`);
|
|
8029
|
+
}
|
|
8030
|
+
}).catch(err => {
|
|
8031
|
+
debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} didn't return JSON response, ignoring it (${err.message})`);
|
|
8032
|
+
});
|
|
7938
8033
|
}
|
|
7939
8034
|
}).then(() => {
|
|
7940
8035
|
pingComplete();
|
|
@@ -7948,27 +8043,26 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7948
8043
|
if (lodash.isString(this.caps[Capabilities.SIMPLEREST_INIT_TEXT])) {
|
|
7949
8044
|
this._doRequest({
|
|
7950
8045
|
messageText: this.caps[Capabilities.SIMPLEREST_INIT_TEXT]
|
|
7951
|
-
},
|
|
8046
|
+
}, !!this.caps[Capabilities.SIMPLEREST_INIT_PROCESS_RESPONSE], true).then(() => initComplete()).catch(initComplete);
|
|
7952
8047
|
} else {
|
|
7953
8048
|
initComplete();
|
|
7954
8049
|
}
|
|
7955
|
-
}, inboundListenerComplete => {
|
|
7956
|
-
this._subscribeInbound().then(() => inboundListenerComplete()).catch(inboundListenerComplete);
|
|
7957
|
-
}, startPollingComplete => {
|
|
7958
|
-
this._startPolling().then(() => startPollingComplete()).catch(startPollingComplete);
|
|
7959
8050
|
}, startCallComplete => {
|
|
7960
8051
|
this.processInbound = true;
|
|
7961
8052
|
|
|
7962
8053
|
if (this.caps[Capabilities.SIMPLEREST_START_URL]) {
|
|
7963
|
-
this._makeCall('SIMPLEREST_START').then(
|
|
8054
|
+
this._makeCall('SIMPLEREST_START').then(body => {
|
|
7964
8055
|
if (this.caps[Capabilities.SIMPLEREST_START_UPDATE_CONTEXT] || this.caps[Capabilities.SIMPLEREST_START_PROCESS_RESPONSE]) {
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
8056
|
+
return this._parseResponseBody(body).then(body => {
|
|
8057
|
+
if (body) {
|
|
8058
|
+
debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} returned JSON response: ${Utils.shortenJsonString(body)}`);
|
|
8059
|
+
return this._processBodyAsync(body, !!this.caps[Capabilities.SIMPLEREST_START_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_START_UPDATE_CONTEXT]);
|
|
8060
|
+
} else {
|
|
8061
|
+
debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} didn't return JSON response, ignoring it.`);
|
|
8062
|
+
}
|
|
8063
|
+
}).catch(err => {
|
|
8064
|
+
debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} didn't return JSON response, ignoring it (${err.message})`);
|
|
8065
|
+
});
|
|
7972
8066
|
}
|
|
7973
8067
|
}).then(() => {
|
|
7974
8068
|
startCallComplete();
|
|
@@ -8179,30 +8273,46 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8179
8273
|
msg.sourceData = msg.sourceData || {};
|
|
8180
8274
|
msg.sourceData.requestOptions = requestOptions;
|
|
8181
8275
|
this.waitProcessQueue = [];
|
|
8182
|
-
request(requestOptions, (err, response, body) => {
|
|
8276
|
+
request(requestOptions, async (err, response, body) => {
|
|
8183
8277
|
if (err) {
|
|
8184
|
-
reject(new Error(`rest request failed: ${err.message}`));
|
|
8278
|
+
return reject(new Error(`rest request failed: ${err.message}`));
|
|
8185
8279
|
} else {
|
|
8186
8280
|
if (response.statusCode >= 400) {
|
|
8187
8281
|
debug$4(`got error response: ${response.statusCode}/${response.statusMessage}`);
|
|
8282
|
+
|
|
8283
|
+
if (debug$4.enabled && body) {
|
|
8284
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8285
|
+
}
|
|
8286
|
+
|
|
8287
|
+
if (body) {
|
|
8288
|
+
const jsonBody = Utils.toJsonWeak(body);
|
|
8289
|
+
const errKey = Object.keys(jsonBody).find(k => k.startsWith('err') || k.startsWith('fail'));
|
|
8290
|
+
|
|
8291
|
+
if (errKey) {
|
|
8292
|
+
return reject(new BotiumError$1(`got error response: ${response.statusCode}/${response.statusMessage} - ${jsonBody[errKey]}`, {
|
|
8293
|
+
message: Utils.shortenJsonString(body)
|
|
8294
|
+
}));
|
|
8295
|
+
}
|
|
8296
|
+
}
|
|
8297
|
+
|
|
8188
8298
|
return reject(new Error(`got error response: ${response.statusCode}/${response.statusMessage}`));
|
|
8189
8299
|
}
|
|
8190
8300
|
|
|
8191
8301
|
if (body) {
|
|
8192
8302
|
debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8193
8303
|
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8304
|
+
try {
|
|
8305
|
+
body = await this._parseResponseBody(body);
|
|
8306
|
+
} catch (err) {
|
|
8307
|
+
debug$4(`ignoring not JSON formatted response body: ${err.message}`);
|
|
8308
|
+
resolve(this);
|
|
8197
8309
|
|
|
8198
|
-
|
|
8199
|
-
} catch (err) {
|
|
8200
|
-
debug$4(`ignoring not JSON formatted response body (${err.message})`);
|
|
8201
|
-
resolve(this);
|
|
8310
|
+
this._emptyWaitProcessQueue();
|
|
8202
8311
|
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8312
|
+
return;
|
|
8313
|
+
}
|
|
8314
|
+
|
|
8315
|
+
if (body) {
|
|
8206
8316
|
this._processBodyAsync(body, isFromUser, updateContext).then(() => resolve(this)).then(() => this._emptyWaitProcessQueue());
|
|
8207
8317
|
} else {
|
|
8208
8318
|
debug$4('ignoring response body (no string and no JSON object)');
|
|
@@ -8282,6 +8392,16 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8282
8392
|
}
|
|
8283
8393
|
}
|
|
8284
8394
|
|
|
8395
|
+
if (msg.ADD_FORM_PARAM && Object.keys(msg.ADD_FORM_PARAM).length > 0) {
|
|
8396
|
+
requestOptions.form = {};
|
|
8397
|
+
|
|
8398
|
+
for (const formKey of Object.keys(msg.ADD_FORM_PARAM)) {
|
|
8399
|
+
const formValue = this._getMustachedVal(lodash.isString(msg.ADD_FORM_PARAM[formKey]) ? msg.ADD_FORM_PARAM[formKey] : JSON.stringify(msg.ADD_FORM_PARAM[formKey]), false);
|
|
8400
|
+
|
|
8401
|
+
requestOptions.form[formKey] = formValue;
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
8404
|
+
|
|
8285
8405
|
if (msg.ADD_HEADER && Object.keys(msg.ADD_HEADER).length > 0) {
|
|
8286
8406
|
requestOptions.headers = requestOptions.headers || {};
|
|
8287
8407
|
|
|
@@ -8338,14 +8458,45 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8338
8458
|
await timeout(pingConfig.timeout);
|
|
8339
8459
|
} else if (response.statusCode >= 400) {
|
|
8340
8460
|
debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
|
|
8461
|
+
|
|
8462
|
+
if (debug$4.enabled && body) {
|
|
8463
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8464
|
+
}
|
|
8465
|
+
|
|
8341
8466
|
await timeout(pingConfig.timeout);
|
|
8342
8467
|
} else {
|
|
8343
|
-
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}`);
|
|
8468
|
+
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
|
|
8469
|
+
|
|
8470
|
+
if (debug$4.enabled && body) {
|
|
8471
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8472
|
+
}
|
|
8473
|
+
|
|
8344
8474
|
return body;
|
|
8345
8475
|
}
|
|
8346
8476
|
}
|
|
8347
8477
|
}
|
|
8348
8478
|
|
|
8479
|
+
async _parseResponseBody(body) {
|
|
8480
|
+
if (!lodash.isObject(body) && lodash.isString(body)) {
|
|
8481
|
+
try {
|
|
8482
|
+
body = JSON.parse(body);
|
|
8483
|
+
} catch (err) {
|
|
8484
|
+
if (!this.parserHook) throw err;
|
|
8485
|
+
}
|
|
8486
|
+
}
|
|
8487
|
+
|
|
8488
|
+
if (this.parserHook) {
|
|
8489
|
+
await executeHook(this.caps, this.parserHook, Object.assign({
|
|
8490
|
+
body,
|
|
8491
|
+
changeBody: b => {
|
|
8492
|
+
body = b;
|
|
8493
|
+
}
|
|
8494
|
+
}, this.view));
|
|
8495
|
+
}
|
|
8496
|
+
|
|
8497
|
+
if (lodash.isObject(body)) return body;else if (lodash.isString(body)) return JSON.parse(body);else return null;
|
|
8498
|
+
}
|
|
8499
|
+
|
|
8349
8500
|
_getCapValue(capName) {
|
|
8350
8501
|
return lodash.isFunction(this.caps[capName]) ? this.caps[capName]() : this.caps[capName];
|
|
8351
8502
|
}
|
|
@@ -8488,7 +8639,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8488
8639
|
}
|
|
8489
8640
|
}
|
|
8490
8641
|
|
|
8491
|
-
_runPolling() {
|
|
8642
|
+
async _runPolling() {
|
|
8492
8643
|
if (!this.processInbound) return;
|
|
8493
8644
|
|
|
8494
8645
|
if (this.caps[Capabilities.SIMPLEREST_POLL_URL]) {
|
|
@@ -8528,23 +8679,36 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8528
8679
|
|
|
8529
8680
|
this._addRequestOptions(pollConfig);
|
|
8530
8681
|
|
|
8531
|
-
|
|
8682
|
+
try {
|
|
8683
|
+
await executeHook(this.caps, this.pollRequestHook, Object.assign({
|
|
8684
|
+
requestOptions: pollConfig
|
|
8685
|
+
}, this.view));
|
|
8686
|
+
} catch (err) {
|
|
8687
|
+
debug$4(`_runPolling: exeucting request hook failed - (${err.message})`);
|
|
8688
|
+
return;
|
|
8689
|
+
}
|
|
8690
|
+
|
|
8691
|
+
request(pollConfig, async (err, response, body) => {
|
|
8532
8692
|
if (err) {
|
|
8533
8693
|
debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
|
|
8534
8694
|
} else {
|
|
8535
8695
|
if (response.statusCode >= 400) {
|
|
8536
8696
|
debug$4(`_runPolling: got error response: ${response.statusCode}/${response.statusMessage}, request: ${JSON.stringify(pollConfig)}`);
|
|
8697
|
+
|
|
8698
|
+
if (debug$4.enabled && body) {
|
|
8699
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8700
|
+
}
|
|
8537
8701
|
} else if (body) {
|
|
8538
8702
|
debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8539
8703
|
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8704
|
+
try {
|
|
8705
|
+
body = await this._parseResponseBody(body);
|
|
8706
|
+
} catch (err) {
|
|
8707
|
+
debug$4(`_runPolling: ignoring not JSON formatted response body: ${err.message}`);
|
|
8708
|
+
return;
|
|
8709
|
+
}
|
|
8710
|
+
|
|
8711
|
+
if (body) {
|
|
8548
8712
|
setTimeout(() => this._processBodyAsync(body, true, !!this.caps[Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT]), 0);
|
|
8549
8713
|
} else {
|
|
8550
8714
|
debug$4('_runPolling: ignoring response body (no string and no JSON object)');
|
|
@@ -8607,6 +8771,10 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8607
8771
|
|
|
8608
8772
|
this._addRequestOptions(httpConfig);
|
|
8609
8773
|
|
|
8774
|
+
await executeHook(this.caps, this.requestHooks[capPrefix], Object.assign({
|
|
8775
|
+
requestOptions: httpConfig
|
|
8776
|
+
}, this.view));
|
|
8777
|
+
|
|
8610
8778
|
const retries = this._getCapValue(`${capPrefix}_RETRIES`);
|
|
8611
8779
|
|
|
8612
8780
|
debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
|