botium-core 1.11.16 → 1.12.3
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 +493 -202
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +484 -194
- package/dist/botium-es.js.map +1 -1
- package/index.js +1 -0
- package/package.json +29 -29
- package/samples/connectors/custom/botium-connector-myapi.js +3 -3
- package/samples/extensions/asserterHooks/DummyAsserter.js +3 -3
- package/src/BotDriver.js +3 -3
- package/src/Capabilities.js +9 -0
- package/src/Defaults.js +1 -1
- package/src/Enums.js +6 -0
- package/src/containers/BaseContainer.js +20 -10
- package/src/containers/PluginConnectorContainer.js +1 -0
- package/src/containers/plugins/SimpleRestContainer.js +98 -30
- package/src/scripting/BotiumError.js +21 -0
- package/src/scripting/CompilerCsv.js +1 -1
- package/src/scripting/CompilerObjectBase.js +4 -14
- package/src/scripting/CompilerTxt.js +4 -15
- package/src/scripting/CompilerXlsx.js +81 -25
- package/src/scripting/Convo.js +16 -4
- package/src/scripting/ScriptingProvider.js +6 -0
- package/src/scripting/helper.js +54 -1
- package/src/scripting/logichook/LogicHookUtils.js +2 -0
- package/src/scripting/logichook/asserter/JsonPathAsserter.js +1 -1
- package/src/scripting/logichook/logichooks/ClearQueueLogicHook.js +1 -1
- package/src/scripting/logichook/userinput/MediaInput.js +14 -2
- package/test/connectors/convos/hello.convo.txt +6 -0
- package/test/connectors/simplerest.spec.js +106 -2
- package/test/convo/convos/continuefailing.convo.txt +19 -0
- package/test/convo/transcript.spec.js +34 -0
- package/test/scripting/scriptingProvider.spec.js +4 -4
- package/test/scripting/scriptingmemory/convosMultiMemorySameCols/buy.convo.txt +6 -0
- package/test/scripting/scriptingmemory/convosMultiMemorySameCols/products1.scriptingmemory.txt +2 -0
- package/test/scripting/scriptingmemory/convosMultiMemorySameCols/products2.scriptingmemory.txt +2 -0
- package/test/scripting/scriptingmemory/convosSimpleCols/buy.convo.txt +8 -0
- package/test/scripting/scriptingmemory/convosSimpleCols/product.scriptingmemory.txt +3 -0
- package/test/scripting/scriptingmemory/convosTwoTablesCols/buy.convo.txt +6 -0
- package/test/scripting/scriptingmemory/convosTwoTablesCols/customer.xlsx +0 -0
- package/test/scripting/scriptingmemory/convosTwoTablesCols/product.xlsx +0 -0
- package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +45 -0
- package/test/scripting/userinputs/mediaInputConvos.spec.js +53 -2
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.3";
|
|
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,23 +68,23 @@ 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.17.2",
|
|
72
|
+
async: "^3.2.3",
|
|
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.4",
|
|
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.28.
|
|
81
|
+
ioredis: "^4.28.5",
|
|
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.2
|
|
87
|
-
"mime-types": "^2.1.
|
|
86
|
+
"markdown-it": "^12.3.2",
|
|
87
|
+
"mime-types": "^2.1.34",
|
|
88
88
|
mkdirp: "^1.0.4",
|
|
89
89
|
moment: "^2.29.1",
|
|
90
90
|
mustache: "^4.2.0",
|
|
@@ -94,40 +94,40 @@ var dependencies = {
|
|
|
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.5",
|
|
98
|
+
"socket.io": "^4.4.1",
|
|
99
|
+
"socket.io-client": "^4.4.1",
|
|
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.7",
|
|
105
105
|
"write-yaml": "^1.0.0",
|
|
106
|
-
xlsx: "^0.
|
|
106
|
+
xlsx: "^0.18.2",
|
|
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.16.
|
|
113
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
114
|
-
"@babel/preset-env": "^7.16.
|
|
115
|
-
chai: "^4.3.
|
|
111
|
+
"@babel/core": "^7.17.2",
|
|
112
|
+
"@babel/node": "^7.16.8",
|
|
113
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
114
|
+
"@babel/preset-env": "^7.16.11",
|
|
115
|
+
chai: "^4.3.6",
|
|
116
116
|
"chai-as-promised": "^7.1.1",
|
|
117
117
|
"cross-env": "^7.0.3",
|
|
118
|
-
eslint: "^8.
|
|
118
|
+
eslint: "^8.9.0",
|
|
119
119
|
"eslint-config-standard": "^16.0.3",
|
|
120
|
-
"eslint-plugin-import": "^2.25.
|
|
120
|
+
"eslint-plugin-import": "^2.25.4",
|
|
121
121
|
"eslint-plugin-node": "^11.1.0",
|
|
122
|
-
"eslint-plugin-promise": "^
|
|
122
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
123
123
|
"eslint-plugin-standard": "^4.1.0",
|
|
124
124
|
"license-checker": "^25.0.1",
|
|
125
125
|
"license-compatibility-checker": "^0.3.5",
|
|
126
|
-
mocha: "^9.
|
|
127
|
-
nock: "^13.
|
|
128
|
-
"npm-check-updates": "^12.
|
|
126
|
+
mocha: "^9.2.0",
|
|
127
|
+
nock: "^13.2.4",
|
|
128
|
+
"npm-check-updates": "^12.3.0",
|
|
129
129
|
nyc: "^15.1.0",
|
|
130
|
-
rollup: "^2.
|
|
130
|
+
rollup: "^2.67.2",
|
|
131
131
|
"rollup-plugin-babel": "^4.4.0",
|
|
132
132
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
133
133
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -244,6 +244,11 @@ var Capabilities = {
|
|
|
244
244
|
SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
|
|
245
245
|
SIMPLEREST_MEDIA_JSONPATH: 'SIMPLEREST_MEDIA_JSONPATH',
|
|
246
246
|
SIMPLEREST_BUTTONS_JSONPATH: 'SIMPLEREST_BUTTONS_JSONPATH',
|
|
247
|
+
SIMPLEREST_CARDS_JSONPATH: 'SIMPLEREST_CARDS_JSONPATH',
|
|
248
|
+
SIMPLEREST_CARD_TEXT_JSONPATH: 'SIMPLEREST_CARD_TEXT_JSONPATH',
|
|
249
|
+
SIMPLEREST_CARD_SUBTEXT_JSONPATH: 'SIMPLEREST_CARD_SUBTEXT_JSONPATH',
|
|
250
|
+
SIMPLEREST_CARD_BUTTONS_JSONPATH: 'SIMPLEREST_CARD_BUTTONS_JSONPATH',
|
|
251
|
+
SIMPLEREST_CARD_ATTACHMENTS_JSONPATH: 'SIMPLEREST_CARD_ATTACHMENTS_JSONPATH',
|
|
247
252
|
SIMPLEREST_CONTEXT_JSONPATH: 'SIMPLEREST_CONTEXT_JSONPATH',
|
|
248
253
|
SIMPLEREST_CONTEXT_MERGE_OR_REPLACE: 'SIMPLEREST_CONTEXT_MERGE_OR_REPLACE',
|
|
249
254
|
SIMPLEREST_CONVERSATION_ID_TEMPLATE: 'SIMPLEREST_CONVERSATION_ID_TEMPLATE',
|
|
@@ -282,6 +287,7 @@ var Capabilities = {
|
|
|
282
287
|
SCRIPTING_NORMALIZE_TEXT: 'SCRIPTING_NORMALIZE_TEXT',
|
|
283
288
|
SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
|
|
284
289
|
SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
|
|
290
|
+
SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS: 'SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS',
|
|
285
291
|
SCRIPTING_FORCE_BOT_CONSUMED: 'SCRIPTING_FORCE_BOT_CONSUMED',
|
|
286
292
|
// regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, wildcardExact, wildcardExactIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
|
|
287
293
|
SCRIPTING_MATCHING_MODE: 'SCRIPTING_MATCHING_MODE',
|
|
@@ -297,6 +303,8 @@ var Capabilities = {
|
|
|
297
303
|
SCRIPTING_MEMORYEXPANSION_KEEP_ORIG: 'SCRIPTING_MEMORYEXPANSION_KEEP_ORIG',
|
|
298
304
|
// word, non_whitespace, joker
|
|
299
305
|
SCRIPTING_MEMORY_MATCHING_MODE: 'SCRIPTING_MEMORY_MATCHING_MODE',
|
|
306
|
+
// varnames, testcasenames
|
|
307
|
+
SCRIPTING_MEMORY_COLUMN_MODE: 'SCRIPTING_MEMORY_COLUMN_MODE',
|
|
300
308
|
// Botium Lifecycle Hooks
|
|
301
309
|
CUSTOMHOOK_ONBUILD: 'CUSTOMHOOK_ONBUILD',
|
|
302
310
|
CUSTOMHOOK_ONSTART: 'CUSTOMHOOK_ONSTART',
|
|
@@ -311,6 +319,7 @@ var Capabilities = {
|
|
|
311
319
|
// API Calls Rate Limiting
|
|
312
320
|
RATELIMIT_USERSAYS_MAXCONCURRENT: 'RATELIMIT_USERSAYS_MAXCONCURRENT',
|
|
313
321
|
RATELIMIT_USERSAYS_MINTIME: 'RATELIMIT_USERSAYS_MINTIME',
|
|
322
|
+
RATELIMIT_BOTTLENECK_FN: 'RATELIMIT_BOTTLENECK_FN',
|
|
314
323
|
SECURITY_ALLOW_UNSAFE: 'SECURITY_ALLOW_UNSAFE',
|
|
315
324
|
PRECOMPILERS: 'PRECOMPILERS'
|
|
316
325
|
};
|
|
@@ -386,6 +395,11 @@ Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
|
|
|
386
395
|
Capabilities.SIMPLEREST_RESPONSE_HOOK;
|
|
387
396
|
Capabilities.SIMPLEREST_MEDIA_JSONPATH;
|
|
388
397
|
Capabilities.SIMPLEREST_BUTTONS_JSONPATH;
|
|
398
|
+
Capabilities.SIMPLEREST_CARDS_JSONPATH;
|
|
399
|
+
Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH;
|
|
400
|
+
Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH;
|
|
401
|
+
Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH;
|
|
402
|
+
Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH;
|
|
389
403
|
Capabilities.SIMPLEREST_CONTEXT_JSONPATH;
|
|
390
404
|
Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE;
|
|
391
405
|
Capabilities.SIMPLEREST_CONVERSATION_ID_TEMPLATE;
|
|
@@ -422,6 +436,7 @@ Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER;
|
|
|
422
436
|
Capabilities.SCRIPTING_NORMALIZE_TEXT;
|
|
423
437
|
Capabilities.SCRIPTING_ENABLE_MEMORY;
|
|
424
438
|
Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS;
|
|
439
|
+
Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS;
|
|
425
440
|
Capabilities.SCRIPTING_FORCE_BOT_CONSUMED;
|
|
426
441
|
Capabilities.SCRIPTING_MATCHING_MODE;
|
|
427
442
|
Capabilities.SCRIPTING_UTTEXPANSION_MODE;
|
|
@@ -432,6 +447,7 @@ Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE;
|
|
|
432
447
|
Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX;
|
|
433
448
|
Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG;
|
|
434
449
|
Capabilities.SCRIPTING_MEMORY_MATCHING_MODE;
|
|
450
|
+
Capabilities.SCRIPTING_MEMORY_COLUMN_MODE;
|
|
435
451
|
Capabilities.CUSTOMHOOK_ONBUILD;
|
|
436
452
|
Capabilities.CUSTOMHOOK_ONSTART;
|
|
437
453
|
Capabilities.CUSTOMHOOK_ONUSERSAYS;
|
|
@@ -443,6 +459,7 @@ Capabilities.LOGIC_HOOKS;
|
|
|
443
459
|
Capabilities.USER_INPUTS;
|
|
444
460
|
Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT;
|
|
445
461
|
Capabilities.RATELIMIT_USERSAYS_MINTIME;
|
|
462
|
+
Capabilities.RATELIMIT_BOTTLENECK_FN;
|
|
446
463
|
Capabilities.SECURITY_ALLOW_UNSAFE;
|
|
447
464
|
Capabilities.PRECOMPILERS;
|
|
448
465
|
|
|
@@ -491,7 +508,6 @@ var Defaults$1 = {
|
|
|
491
508
|
[Capabilities.SIMPLEREST_METHOD]: 'GET',
|
|
492
509
|
[Capabilities.SIMPLEREST_IGNORE_EMPTY]: true,
|
|
493
510
|
[Capabilities.SIMPLEREST_TIMEOUT]: 10000,
|
|
494
|
-
[Capabilities.SIMPLEREST_EXTRA_OPTIONS]: {},
|
|
495
511
|
[Capabilities.SIMPLEREST_STRICT_SSL]: true,
|
|
496
512
|
[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
|
|
497
513
|
[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
|
|
@@ -510,6 +526,7 @@ var Defaults$1 = {
|
|
|
510
526
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'justLineTag',
|
|
511
527
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: '16',
|
|
512
528
|
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false,
|
|
529
|
+
[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: false,
|
|
513
530
|
[Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: false,
|
|
514
531
|
[Capabilities.ASSERTERS]: [],
|
|
515
532
|
[Capabilities.LOGIC_HOOKS]: [],
|
|
@@ -831,7 +848,7 @@ function getCjsExportFromNamespace (n) {
|
|
|
831
848
|
return n && n['default'] || n;
|
|
832
849
|
}
|
|
833
850
|
|
|
834
|
-
const BotiumError$
|
|
851
|
+
const BotiumError$7 = class BotiumError extends Error {
|
|
835
852
|
/**
|
|
836
853
|
*
|
|
837
854
|
* @param message
|
|
@@ -856,6 +873,27 @@ const BotiumError$6 = class BotiumError extends Error {
|
|
|
856
873
|
this.context.message = message.message || message;
|
|
857
874
|
}
|
|
858
875
|
|
|
876
|
+
isAsserterError() {
|
|
877
|
+
if (this.context) {
|
|
878
|
+
const errArr = lodash.isArray(this.context) ? this.context : [this.context];
|
|
879
|
+
const hasNotAsserterError = errArr.findIndex(errDetail => {
|
|
880
|
+
if (errDetail.type === 'list') {
|
|
881
|
+
if (errDetail.errors) {
|
|
882
|
+
return errDetail.errors.findIndex(e => e.type !== 'asserter') >= 0;
|
|
883
|
+
} else {
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
} else {
|
|
887
|
+
return errDetail.type !== 'asserter';
|
|
888
|
+
}
|
|
889
|
+
}) >= 0;
|
|
890
|
+
if (hasNotAsserterError) return false;
|
|
891
|
+
return true;
|
|
892
|
+
} else {
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
859
897
|
prettify(includeJson) {
|
|
860
898
|
const lines = [];
|
|
861
899
|
|
|
@@ -917,10 +955,10 @@ const _getChildErrorsFromContext = context => {
|
|
|
917
955
|
};
|
|
918
956
|
|
|
919
957
|
const botiumErrorFromErr$2 = (message, err) => {
|
|
920
|
-
if (err instanceof BotiumError$
|
|
921
|
-
return new BotiumError$
|
|
958
|
+
if (err instanceof BotiumError$7) {
|
|
959
|
+
return new BotiumError$7(message, err.context, true);
|
|
922
960
|
} else {
|
|
923
|
-
return new BotiumError$
|
|
961
|
+
return new BotiumError$7(message, {
|
|
924
962
|
err
|
|
925
963
|
}, true);
|
|
926
964
|
}
|
|
@@ -935,7 +973,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
935
973
|
let children = [];
|
|
936
974
|
|
|
937
975
|
for (const error of errors) {
|
|
938
|
-
if (error instanceof BotiumError$
|
|
976
|
+
if (error instanceof BotiumError$7) {
|
|
939
977
|
const childErrors = flat && _getChildErrorsFromContext(error.context);
|
|
940
978
|
|
|
941
979
|
if (childErrors && childErrors.length) {
|
|
@@ -948,7 +986,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
948
986
|
}
|
|
949
987
|
}
|
|
950
988
|
|
|
951
|
-
const result = new BotiumError$
|
|
989
|
+
const result = new BotiumError$7(message, {
|
|
952
990
|
errors: children,
|
|
953
991
|
type,
|
|
954
992
|
source
|
|
@@ -957,7 +995,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
957
995
|
};
|
|
958
996
|
|
|
959
997
|
var BotiumError_1 = {
|
|
960
|
-
BotiumError: BotiumError$
|
|
998
|
+
BotiumError: BotiumError$7,
|
|
961
999
|
botiumErrorFromErr: botiumErrorFromErr$2,
|
|
962
1000
|
botiumErrorFromList: botiumErrorFromList$2
|
|
963
1001
|
};
|
|
@@ -1138,7 +1176,7 @@ const {
|
|
|
1138
1176
|
} = vm2;
|
|
1139
1177
|
const debug$k = debug$l('botium-core-asserterUtils');
|
|
1140
1178
|
const {
|
|
1141
|
-
BotiumError: BotiumError$
|
|
1179
|
+
BotiumError: BotiumError$6
|
|
1142
1180
|
} = BotiumError_1;
|
|
1143
1181
|
const {
|
|
1144
1182
|
DEFAULT_ASSERTERS,
|
|
@@ -1289,7 +1327,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1289
1327
|
|
|
1290
1328
|
const _checkUnsafe = () => {
|
|
1291
1329
|
if (!this.caps[Capabilities.SECURITY_ALLOW_UNSAFE]) {
|
|
1292
|
-
throw new BotiumError$
|
|
1330
|
+
throw new BotiumError$6('Security Error. Using unsafe component is not allowed', {
|
|
1293
1331
|
type: 'security',
|
|
1294
1332
|
subtype: 'allow unsafe',
|
|
1295
1333
|
source: path.basename(__filename),
|
|
@@ -1433,6 +1471,11 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1433
1471
|
ref,
|
|
1434
1472
|
...this.buildScriptContext
|
|
1435
1473
|
}, this.caps, args);
|
|
1474
|
+
} else if (lodash.isFunction(CheckClass.PluginClass)) {
|
|
1475
|
+
return CheckClass.PluginClass({
|
|
1476
|
+
ref,
|
|
1477
|
+
...this.buildScriptContext
|
|
1478
|
+
}, this.caps, args);
|
|
1436
1479
|
} else {
|
|
1437
1480
|
throw new Error(`${src} class or function expected`);
|
|
1438
1481
|
}
|
|
@@ -1688,6 +1731,18 @@ var BotiumMockMessage_1 = class BotiumMockMessage {
|
|
|
1688
1731
|
|
|
1689
1732
|
};
|
|
1690
1733
|
|
|
1734
|
+
var Enums = {
|
|
1735
|
+
E_SCRIPTING_MEMORY_COLUMN_MODE: {
|
|
1736
|
+
VARNAMES: 'varnames',
|
|
1737
|
+
TESTCASENAMES: 'testcasenames'
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
Enums.E_SCRIPTING_MEMORY_COLUMN_MODE;
|
|
1741
|
+
|
|
1742
|
+
const {
|
|
1743
|
+
E_SCRIPTING_MEMORY_COLUMN_MODE: E_SCRIPTING_MEMORY_COLUMN_MODE$1
|
|
1744
|
+
} = Enums;
|
|
1745
|
+
|
|
1691
1746
|
const normalizeText$1 = (str, doCleanup) => {
|
|
1692
1747
|
if (str && lodash.isArray(str)) {
|
|
1693
1748
|
str = str.join(' ');
|
|
@@ -2216,6 +2271,71 @@ const convoStepToLines$2 = step => {
|
|
|
2216
2271
|
return lines.map(l => l.trim());
|
|
2217
2272
|
};
|
|
2218
2273
|
|
|
2274
|
+
const linesToScriptingMemories$2 = (lines, columnMode = null) => {
|
|
2275
|
+
const guessScriptingMemoryColumnMode = lines => {
|
|
2276
|
+
if (lines && lines.length > 1) {
|
|
2277
|
+
if (lines[1].trim().startsWith('$')) return E_SCRIPTING_MEMORY_COLUMN_MODE$1.TESTCASENAMES;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
return E_SCRIPTING_MEMORY_COLUMN_MODE$1.VARNAMES;
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
columnMode = columnMode || guessScriptingMemoryColumnMode(lines);
|
|
2284
|
+
const scriptingMemories = [];
|
|
2285
|
+
|
|
2286
|
+
if (columnMode === E_SCRIPTING_MEMORY_COLUMN_MODE$1.TESTCASENAMES) {
|
|
2287
|
+
const caseNames = lines[0].split('|').map(name => name.trim()).slice(1);
|
|
2288
|
+
const varNames = [];
|
|
2289
|
+
const varValues = [];
|
|
2290
|
+
|
|
2291
|
+
for (let row = 1; row < lines.length; row++) {
|
|
2292
|
+
if (!lines[row] || lines[row].length === 0) continue;
|
|
2293
|
+
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
2294
|
+
varNames.push(rawRow[0]);
|
|
2295
|
+
varValues.push(rawRow.slice(1));
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
for (let caseIndex = 0; caseIndex < caseNames.length; caseIndex++) {
|
|
2299
|
+
const caseName = caseNames[caseIndex];
|
|
2300
|
+
const values = varNames.reduce((agg, varName, varIndex) => {
|
|
2301
|
+
agg[varName] = varValues[varIndex][caseIndex] || null;
|
|
2302
|
+
return agg;
|
|
2303
|
+
}, {});
|
|
2304
|
+
const scriptingMemory = {
|
|
2305
|
+
header: {
|
|
2306
|
+
name: caseName
|
|
2307
|
+
},
|
|
2308
|
+
values: values
|
|
2309
|
+
};
|
|
2310
|
+
scriptingMemories.push(scriptingMemory);
|
|
2311
|
+
}
|
|
2312
|
+
} else {
|
|
2313
|
+
const varNames = lines[0].split('|').map(name => name.trim()).slice(1);
|
|
2314
|
+
|
|
2315
|
+
for (let row = 1; row < lines.length; row++) {
|
|
2316
|
+
if (!lines[row] || lines[row].length === 0) continue;
|
|
2317
|
+
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
2318
|
+
const caseName = rawRow[0];
|
|
2319
|
+
const values = rawRow.slice(1);
|
|
2320
|
+
const varValues = {};
|
|
2321
|
+
|
|
2322
|
+
for (let varIndex = 0; varIndex < varNames.length; varIndex++) {
|
|
2323
|
+
varValues[varNames[varIndex]] = values[varIndex];
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
const scriptingMemory = {
|
|
2327
|
+
header: {
|
|
2328
|
+
name: caseName
|
|
2329
|
+
},
|
|
2330
|
+
values: varValues
|
|
2331
|
+
};
|
|
2332
|
+
scriptingMemories.push(scriptingMemory);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
return scriptingMemories;
|
|
2337
|
+
};
|
|
2338
|
+
|
|
2219
2339
|
var helper = {
|
|
2220
2340
|
normalizeText: normalizeText$1,
|
|
2221
2341
|
splitStringInNonEmptyLines: splitStringInNonEmptyLines$1,
|
|
@@ -2228,7 +2348,8 @@ var helper = {
|
|
|
2228
2348
|
convoStepToObject: convoStepToObject$1,
|
|
2229
2349
|
validSenders: validSenders$3,
|
|
2230
2350
|
validateSender: validateSender$1,
|
|
2231
|
-
validateConvo: validateConvo$2
|
|
2351
|
+
validateConvo: validateConvo$2,
|
|
2352
|
+
linesToScriptingMemories: linesToScriptingMemories$2
|
|
2232
2353
|
};
|
|
2233
2354
|
|
|
2234
2355
|
const debug$j = debug$l('botium-core-ScriptingMemory');
|
|
@@ -2243,7 +2364,7 @@ const {
|
|
|
2243
2364
|
toString: toString$2
|
|
2244
2365
|
} = helper;
|
|
2245
2366
|
const {
|
|
2246
|
-
BotiumError: BotiumError$
|
|
2367
|
+
BotiumError: BotiumError$5
|
|
2247
2368
|
} = BotiumError_1; // If they got parameter, then it will be a string always.
|
|
2248
2369
|
// the receiver can decide what to do with it,
|
|
2249
2370
|
// convert to int,
|
|
@@ -2412,7 +2533,7 @@ const SCRIPTING_FUNCTIONS$1 = lodash.mapValues(SCRIPTING_FUNCTIONS_RAW, (funcOrS
|
|
|
2412
2533
|
return {
|
|
2413
2534
|
handler: (caps, ...rest) => {
|
|
2414
2535
|
if (!caps[Capabilities.SECURITY_ALLOW_UNSAFE] && funcOrStruct.unsafe) {
|
|
2415
|
-
throw new BotiumError$
|
|
2536
|
+
throw new BotiumError$5(`Security Error. Using unsafe scripting memory function ${name} is not allowed`, {
|
|
2416
2537
|
type: 'security',
|
|
2417
2538
|
subtype: 'allow unsafe',
|
|
2418
2539
|
source: path.basename(__filename),
|
|
@@ -2561,7 +2682,7 @@ ScriptingMemory.SCRIPTING_FUNCTIONS;
|
|
|
2561
2682
|
|
|
2562
2683
|
const debug$i = debug$l('botium-core-Convo');
|
|
2563
2684
|
const {
|
|
2564
|
-
BotiumError: BotiumError$
|
|
2685
|
+
BotiumError: BotiumError$4,
|
|
2565
2686
|
botiumErrorFromErr: botiumErrorFromErr$1,
|
|
2566
2687
|
botiumErrorFromList: botiumErrorFromList$1
|
|
2567
2688
|
} = BotiumError_1;
|
|
@@ -2601,7 +2722,9 @@ class ConvoStepAssert {
|
|
|
2601
2722
|
}
|
|
2602
2723
|
|
|
2603
2724
|
toString() {
|
|
2604
|
-
return (this.optional ? '?' : '') + (this.not ? '!' : '') + this.name + '(' + (this.args ? this.args.
|
|
2725
|
+
return (this.optional ? '?' : '') + (this.not ? '!' : '') + this.name + '(' + (this.args ? this.args.map(a => lodash.truncate(a, {
|
|
2726
|
+
length: 200
|
|
2727
|
+
})).join(',') : 'no args') + ')';
|
|
2605
2728
|
}
|
|
2606
2729
|
|
|
2607
2730
|
}
|
|
@@ -2613,7 +2736,9 @@ class ConvoStepLogicHook {
|
|
|
2613
2736
|
}
|
|
2614
2737
|
|
|
2615
2738
|
toString() {
|
|
2616
|
-
return this.name + '(' + (this.args ? this.args.
|
|
2739
|
+
return this.name + '(' + (this.args ? this.args.map(a => lodash.truncate(a, {
|
|
2740
|
+
length: 200
|
|
2741
|
+
})).join(',') : 'no args') + ')';
|
|
2617
2742
|
}
|
|
2618
2743
|
|
|
2619
2744
|
}
|
|
@@ -2625,7 +2750,9 @@ class ConvoStepUserInput {
|
|
|
2625
2750
|
}
|
|
2626
2751
|
|
|
2627
2752
|
toString() {
|
|
2628
|
-
return this.name + '(' + (this.args ? this.args.
|
|
2753
|
+
return this.name + '(' + (this.args ? this.args.map(a => lodash.truncate(a, {
|
|
2754
|
+
length: 200
|
|
2755
|
+
})).join(',') : 'no args') + ')';
|
|
2629
2756
|
}
|
|
2630
2757
|
|
|
2631
2758
|
}
|
|
@@ -3090,7 +3217,7 @@ class Convo$6 {
|
|
|
3090
3217
|
}
|
|
3091
3218
|
|
|
3092
3219
|
if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
|
|
3093
|
-
const failErr = new BotiumError$
|
|
3220
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
|
|
3094
3221
|
debug$i(failErr);
|
|
3095
3222
|
|
|
3096
3223
|
try {
|
|
@@ -3193,7 +3320,7 @@ class Convo$6 {
|
|
|
3193
3320
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3194
3321
|
} catch (failErr) {}
|
|
3195
3322
|
|
|
3196
|
-
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$
|
|
3323
|
+
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$4) {
|
|
3197
3324
|
assertErrors.push(err);
|
|
3198
3325
|
} else {
|
|
3199
3326
|
throw failErr;
|
|
@@ -3210,7 +3337,7 @@ class Convo$6 {
|
|
|
3210
3337
|
}
|
|
3211
3338
|
}
|
|
3212
3339
|
} else {
|
|
3213
|
-
const failErr = new BotiumError$
|
|
3340
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util.inspect(convoStep.sender)}`);
|
|
3214
3341
|
debug$i(failErr);
|
|
3215
3342
|
|
|
3216
3343
|
try {
|
|
@@ -3221,7 +3348,7 @@ class Convo$6 {
|
|
|
3221
3348
|
}
|
|
3222
3349
|
} catch (err) {
|
|
3223
3350
|
if (lastMeConvoStep) {
|
|
3224
|
-
if (err instanceof BotiumError$
|
|
3351
|
+
if (err instanceof BotiumError$4 && err.context) {
|
|
3225
3352
|
err.context.input = new ConvoStep$1(lastMeConvoStep);
|
|
3226
3353
|
err.context.transcript = [...transcriptSteps, { ...transcriptStep
|
|
3227
3354
|
}];
|
|
@@ -3233,7 +3360,14 @@ class Convo$6 {
|
|
|
3233
3360
|
}
|
|
3234
3361
|
|
|
3235
3362
|
transcriptStep.err = err;
|
|
3236
|
-
|
|
3363
|
+
|
|
3364
|
+
if (err instanceof BotiumError$4 && container.caps[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]) {
|
|
3365
|
+
if (!err.isAsserterError()) {
|
|
3366
|
+
throw err;
|
|
3367
|
+
}
|
|
3368
|
+
} else {
|
|
3369
|
+
throw err;
|
|
3370
|
+
}
|
|
3237
3371
|
} finally {
|
|
3238
3372
|
if (convoStep.sender !== 'begin' && convoStep.sender !== 'end' && !skipTranscriptStep) {
|
|
3239
3373
|
transcriptStep.scriptingMemory = Object.assign({}, scriptingMemory);
|
|
@@ -3248,6 +3382,14 @@ class Convo$6 {
|
|
|
3248
3382
|
transcript.steps = transcriptSteps.filter(s => s);
|
|
3249
3383
|
transcript.scriptingMemory = scriptingMemory;
|
|
3250
3384
|
transcript.convoEnd = new Date();
|
|
3385
|
+
|
|
3386
|
+
if (container.caps[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]) {
|
|
3387
|
+
const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
|
|
3388
|
+
|
|
3389
|
+
if (transcriptStepErrs && transcriptStepErrs.length > 0) {
|
|
3390
|
+
transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3251
3393
|
}
|
|
3252
3394
|
}
|
|
3253
3395
|
|
|
@@ -3256,11 +3398,11 @@ class Convo$6 {
|
|
|
3256
3398
|
|
|
3257
3399
|
if (lodash.isArray(expected)) {
|
|
3258
3400
|
if (!lodash.isArray(result)) {
|
|
3259
|
-
throw new BotiumError$
|
|
3401
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array, got "${result}"`);
|
|
3260
3402
|
}
|
|
3261
3403
|
|
|
3262
3404
|
if (expected.length !== result.length) {
|
|
3263
|
-
throw new BotiumError$
|
|
3405
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array length ${expected.length}, got ${result.length}`);
|
|
3264
3406
|
}
|
|
3265
3407
|
|
|
3266
3408
|
for (let i = 0; i < expected.length; i++) {
|
|
@@ -3271,7 +3413,7 @@ class Convo$6 {
|
|
|
3271
3413
|
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
3272
3414
|
this._compareObject(container, scriptingMemory, convoStep, result[key], expected[key]);
|
|
3273
3415
|
} else {
|
|
3274
|
-
throw new BotiumError$
|
|
3416
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response "${result}" missing expected property: ${key}`);
|
|
3275
3417
|
}
|
|
3276
3418
|
});
|
|
3277
3419
|
} else {
|
|
@@ -3399,17 +3541,17 @@ class Convo$6 {
|
|
|
3399
3541
|
const alreadyThereAt = parentPConvos.indexOf(includeLogicHook);
|
|
3400
3542
|
|
|
3401
3543
|
if (alreadyThereAt >= 0) {
|
|
3402
|
-
throw new BotiumError$
|
|
3544
|
+
throw new BotiumError$4(`Partial convos are included circular. "${includeLogicHook}" is referenced by "/${parentPConvos.slice(0, alreadyThereAt).join('/')}" and by "/${parentPConvos.join('/')}" `);
|
|
3403
3545
|
}
|
|
3404
3546
|
|
|
3405
3547
|
if (!partialConvos || Object.keys(partialConvos).length === 0) {
|
|
3406
|
-
throw new BotiumError$
|
|
3548
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (There are no partial convos)`);
|
|
3407
3549
|
}
|
|
3408
3550
|
|
|
3409
3551
|
const partialConvo = partialConvos[includeLogicHook];
|
|
3410
3552
|
|
|
3411
3553
|
if (!partialConvo) {
|
|
3412
|
-
throw new BotiumError$
|
|
3554
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
|
|
3413
3555
|
}
|
|
3414
3556
|
|
|
3415
3557
|
_getEffectiveConversationRecursive(partialConvo.conversation, [...parentPConvos, includeLogicHook], result, true);
|
|
@@ -3791,7 +3933,7 @@ const {
|
|
|
3791
3933
|
} = vm2;
|
|
3792
3934
|
const debug$h = debug$l('botium-core-HookUtils');
|
|
3793
3935
|
const {
|
|
3794
|
-
BotiumError: BotiumError$
|
|
3936
|
+
BotiumError: BotiumError$3
|
|
3795
3937
|
} = BotiumError_1;
|
|
3796
3938
|
|
|
3797
3939
|
const executeHook$2 = async (caps, hook, args) => {
|
|
@@ -3863,7 +4005,7 @@ const getHook$3 = (caps, data) => {
|
|
|
3863
4005
|
|
|
3864
4006
|
if (resultWithRequire) {
|
|
3865
4007
|
if (!allowUnsafe) {
|
|
3866
|
-
throw new BotiumError$
|
|
4008
|
+
throw new BotiumError$3('Security Error. Using unsafe custom hook with require is not allowed', {
|
|
3867
4009
|
type: 'security',
|
|
3868
4010
|
subtype: 'allow unsafe',
|
|
3869
4011
|
source: path.basename(__filename),
|
|
@@ -4318,6 +4460,9 @@ var Utterance_1 = class Utterance {
|
|
|
4318
4460
|
};
|
|
4319
4461
|
|
|
4320
4462
|
const debug$d = debug$l('botium-core-CompilerXlsx');
|
|
4463
|
+
const {
|
|
4464
|
+
E_SCRIPTING_MEMORY_COLUMN_MODE
|
|
4465
|
+
} = Enums;
|
|
4321
4466
|
const {
|
|
4322
4467
|
Convo: Convo$5
|
|
4323
4468
|
} = Convo_1;
|
|
@@ -4630,49 +4775,120 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4630
4775
|
}
|
|
4631
4776
|
|
|
4632
4777
|
if (scriptType === Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY) {
|
|
4633
|
-
const
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
while (true) {
|
|
4637
|
-
const variableNameCell = this.colnames[colindexTemp] + rowindex;
|
|
4778
|
+
const guessScriptingMemoryColumnMode = () => {
|
|
4779
|
+
const line1Cell = this.colnames[colindex] + (rowindex + 1);
|
|
4638
4780
|
|
|
4639
|
-
if (sheet[
|
|
4640
|
-
|
|
4641
|
-
} else {
|
|
4642
|
-
break;
|
|
4781
|
+
if (sheet[line1Cell] && sheet[line1Cell].v) {
|
|
4782
|
+
if (sheet[line1Cell].v.startsWith('$')) return E_SCRIPTING_MEMORY_COLUMN_MODE.TESTCASENAMES;
|
|
4643
4783
|
}
|
|
4644
4784
|
|
|
4645
|
-
|
|
4646
|
-
}
|
|
4785
|
+
return E_SCRIPTING_MEMORY_COLUMN_MODE.VARNAMES;
|
|
4786
|
+
};
|
|
4647
4787
|
|
|
4648
|
-
|
|
4788
|
+
const columnMode = this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE] || guessScriptingMemoryColumnMode();
|
|
4649
4789
|
|
|
4650
|
-
|
|
4651
|
-
const
|
|
4790
|
+
if (columnMode === E_SCRIPTING_MEMORY_COLUMN_MODE.TESTCASENAMES) {
|
|
4791
|
+
const caseNames = [];
|
|
4792
|
+
let colindexTemp = colindex + 1;
|
|
4793
|
+
|
|
4794
|
+
while (true) {
|
|
4795
|
+
const caseNameCell = this.colnames[colindexTemp] + rowindex;
|
|
4796
|
+
|
|
4797
|
+
if (sheet[caseNameCell] && sheet[caseNameCell].v) {
|
|
4798
|
+
caseNames.push(sheet[caseNameCell].v);
|
|
4799
|
+
} else {
|
|
4800
|
+
break;
|
|
4801
|
+
}
|
|
4802
|
+
|
|
4803
|
+
colindexTemp++;
|
|
4804
|
+
}
|
|
4652
4805
|
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4806
|
+
const varNames = [];
|
|
4807
|
+
const varValues = [];
|
|
4808
|
+
rowindex += 1;
|
|
4656
4809
|
|
|
4657
|
-
|
|
4658
|
-
|
|
4810
|
+
while (true) {
|
|
4811
|
+
const varNameCell = this.colnames[colindex] + rowindex;
|
|
4659
4812
|
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4813
|
+
if (sheet[varNameCell] && sheet[varNameCell].v) {
|
|
4814
|
+
varNames.push(sheet[varNameCell].v);
|
|
4815
|
+
const values = [];
|
|
4816
|
+
|
|
4817
|
+
for (let i = 0; i < caseNames.length; i++) {
|
|
4818
|
+
const variableValueCell = this.colnames[colindex + 1 + i] + rowindex;
|
|
4819
|
+
|
|
4820
|
+
if (sheet[variableValueCell] && sheet[variableValueCell].v) {
|
|
4821
|
+
values.push(sheet[variableValueCell].v.toString());
|
|
4822
|
+
} else {
|
|
4823
|
+
values.push(null);
|
|
4824
|
+
}
|
|
4664
4825
|
}
|
|
4826
|
+
|
|
4827
|
+
varValues.push(values);
|
|
4828
|
+
rowindex += 1;
|
|
4829
|
+
} else {
|
|
4830
|
+
break;
|
|
4665
4831
|
}
|
|
4832
|
+
}
|
|
4666
4833
|
|
|
4667
|
-
|
|
4834
|
+
for (let caseIndex = 0; caseIndex < caseNames.length; caseIndex++) {
|
|
4835
|
+
const caseName = caseNames[caseIndex];
|
|
4836
|
+
const values = varNames.reduce((agg, varName, varIndex) => {
|
|
4837
|
+
agg[varName] = varValues[varIndex][caseIndex] || null;
|
|
4838
|
+
return agg;
|
|
4839
|
+
}, {});
|
|
4668
4840
|
scriptResults.push({
|
|
4669
4841
|
header: {
|
|
4670
4842
|
name: caseName
|
|
4671
4843
|
},
|
|
4672
4844
|
values: values
|
|
4673
4845
|
});
|
|
4674
|
-
}
|
|
4675
|
-
|
|
4846
|
+
}
|
|
4847
|
+
} else {
|
|
4848
|
+
const variableNames = [];
|
|
4849
|
+
let colindexTemp = colindex + 1;
|
|
4850
|
+
|
|
4851
|
+
while (true) {
|
|
4852
|
+
const variableNameCell = this.colnames[colindexTemp] + rowindex;
|
|
4853
|
+
|
|
4854
|
+
if (sheet[variableNameCell] && sheet[variableNameCell].v) {
|
|
4855
|
+
variableNames.push(sheet[variableNameCell].v);
|
|
4856
|
+
} else {
|
|
4857
|
+
break;
|
|
4858
|
+
}
|
|
4859
|
+
|
|
4860
|
+
colindexTemp++;
|
|
4861
|
+
}
|
|
4862
|
+
|
|
4863
|
+
rowindex += 1;
|
|
4864
|
+
|
|
4865
|
+
while (true) {
|
|
4866
|
+
const caseNameCell = this.colnames[colindex] + rowindex;
|
|
4867
|
+
|
|
4868
|
+
if (sheet[caseNameCell] && sheet[caseNameCell].v) {
|
|
4869
|
+
const caseName = sheet[caseNameCell].v;
|
|
4870
|
+
const values = {};
|
|
4871
|
+
|
|
4872
|
+
for (let i = 0; i < variableNames.length; i++) {
|
|
4873
|
+
const variableValueCell = this.colnames[colindex + 1 + i] + rowindex;
|
|
4874
|
+
|
|
4875
|
+
if (sheet[variableValueCell] && sheet[variableValueCell].v) {
|
|
4876
|
+
values[variableNames[i]] = sheet[variableValueCell].v.toString();
|
|
4877
|
+
} else {
|
|
4878
|
+
values[variableNames[i]] = null;
|
|
4879
|
+
}
|
|
4880
|
+
}
|
|
4881
|
+
|
|
4882
|
+
rowindex += 1;
|
|
4883
|
+
scriptResults.push({
|
|
4884
|
+
header: {
|
|
4885
|
+
name: caseName
|
|
4886
|
+
},
|
|
4887
|
+
values: values
|
|
4888
|
+
});
|
|
4889
|
+
} else {
|
|
4890
|
+
break;
|
|
4891
|
+
}
|
|
4676
4892
|
}
|
|
4677
4893
|
}
|
|
4678
4894
|
}
|
|
@@ -4832,7 +5048,8 @@ const {
|
|
|
4832
5048
|
linesToConvoStep: linesToConvoStep$3,
|
|
4833
5049
|
convoStepToLines,
|
|
4834
5050
|
validateConvo,
|
|
4835
|
-
validSenders: validSenders$2
|
|
5051
|
+
validSenders: validSenders$2,
|
|
5052
|
+
linesToScriptingMemories: linesToScriptingMemories$1
|
|
4836
5053
|
} = helper;
|
|
4837
5054
|
var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
4838
5055
|
constructor(context, caps = {}) {
|
|
@@ -4963,30 +5180,12 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4963
5180
|
|
|
4964
5181
|
_compileScriptingMemory(lines) {
|
|
4965
5182
|
if (lines && lines.length > 1) {
|
|
4966
|
-
const
|
|
4967
|
-
const scriptingMemories = [];
|
|
4968
|
-
|
|
4969
|
-
for (let row = 1; row < lines.length; row++) {
|
|
4970
|
-
if (!lines[row] || lines[row].length === 0) continue;
|
|
4971
|
-
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
4972
|
-
const caseName = rawRow[0];
|
|
4973
|
-
const values = rawRow.slice(1);
|
|
4974
|
-
const json = {};
|
|
4975
|
-
|
|
4976
|
-
for (let col = 0; col < names.length; col++) {
|
|
4977
|
-
json[names[col]] = values[col];
|
|
4978
|
-
}
|
|
5183
|
+
const scriptingMemories = linesToScriptingMemories$1(lines, this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE]);
|
|
4979
5184
|
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
name: caseName
|
|
4983
|
-
},
|
|
4984
|
-
values: json
|
|
4985
|
-
};
|
|
4986
|
-
scriptingMemories.push(scriptingMemory);
|
|
5185
|
+
if (scriptingMemories && scriptingMemories.length > 0) {
|
|
5186
|
+
this.context.AddScriptingMemories(scriptingMemories);
|
|
4987
5187
|
}
|
|
4988
5188
|
|
|
4989
|
-
this.context.AddScriptingMemories(scriptingMemories);
|
|
4990
5189
|
return scriptingMemories;
|
|
4991
5190
|
}
|
|
4992
5191
|
}
|
|
@@ -5030,6 +5229,9 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
5030
5229
|
|
|
5031
5230
|
};
|
|
5032
5231
|
|
|
5232
|
+
const {
|
|
5233
|
+
parse
|
|
5234
|
+
} = sync;
|
|
5033
5235
|
const debug$c = debug$l('botium-core-CompilerCsv');
|
|
5034
5236
|
const {
|
|
5035
5237
|
Convo: Convo$3
|
|
@@ -5102,7 +5304,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5102
5304
|
let rows;
|
|
5103
5305
|
|
|
5104
5306
|
try {
|
|
5105
|
-
rows =
|
|
5307
|
+
rows = parse(scriptData, {
|
|
5106
5308
|
delimiter,
|
|
5107
5309
|
escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
|
|
5108
5310
|
quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
|
|
@@ -5241,7 +5443,8 @@ const {
|
|
|
5241
5443
|
} = Convo_1;
|
|
5242
5444
|
const {
|
|
5243
5445
|
linesToConvoStep: linesToConvoStep$1,
|
|
5244
|
-
validSenders: validSenders$1
|
|
5446
|
+
validSenders: validSenders$1,
|
|
5447
|
+
linesToScriptingMemories
|
|
5245
5448
|
} = helper;
|
|
5246
5449
|
var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
5247
5450
|
constructor(context, caps = {}) {
|
|
@@ -5350,29 +5553,12 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5350
5553
|
if (lines && lines.length > 0) {
|
|
5351
5554
|
if (lodash.isString(lines[0])) {
|
|
5352
5555
|
if (lines.length > 1) {
|
|
5353
|
-
const
|
|
5354
|
-
const scriptingMemories = [];
|
|
5355
|
-
|
|
5356
|
-
for (let row = 1; row < lines.length; row++) {
|
|
5357
|
-
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
5358
|
-
const caseName = rawRow[0];
|
|
5359
|
-
const values = rawRow.slice(1);
|
|
5360
|
-
const json = {};
|
|
5556
|
+
const scriptingMemories = linesToScriptingMemories(lines, this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE]);
|
|
5361
5557
|
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
}
|
|
5365
|
-
|
|
5366
|
-
const scriptingMemory = {
|
|
5367
|
-
header: {
|
|
5368
|
-
name: caseName
|
|
5369
|
-
},
|
|
5370
|
-
values: json
|
|
5371
|
-
};
|
|
5372
|
-
scriptingMemories.push(scriptingMemory);
|
|
5558
|
+
if (scriptingMemories && scriptingMemories.length > 0) {
|
|
5559
|
+
this.context.AddScriptingMemories(scriptingMemories);
|
|
5373
5560
|
}
|
|
5374
5561
|
|
|
5375
|
-
this.context.AddScriptingMemories(scriptingMemories);
|
|
5376
5562
|
return scriptingMemories;
|
|
5377
5563
|
}
|
|
5378
5564
|
} else {
|
|
@@ -5565,7 +5751,7 @@ const {
|
|
|
5565
5751
|
ConvoStep
|
|
5566
5752
|
} = Convo_1;
|
|
5567
5753
|
const {
|
|
5568
|
-
BotiumError: BotiumError$
|
|
5754
|
+
BotiumError: BotiumError$2,
|
|
5569
5755
|
botiumErrorFromList,
|
|
5570
5756
|
botiumErrorFromErr
|
|
5571
5757
|
} = BotiumError_1;
|
|
@@ -5845,7 +6031,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5845
6031
|
message += ' expected to match ';
|
|
5846
6032
|
message += tomatch && tomatch.length > 1 ? 'one of ' : '';
|
|
5847
6033
|
message += `${tomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5848
|
-
throw new BotiumError$
|
|
6034
|
+
throw new BotiumError$2(message, {
|
|
5849
6035
|
type: 'asserter',
|
|
5850
6036
|
source: 'TextMatchAsserter',
|
|
5851
6037
|
context: {
|
|
@@ -5875,7 +6061,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5875
6061
|
message += ' expected NOT to match ';
|
|
5876
6062
|
message += nottomatch && nottomatch.length > 1 ? 'one of ' : '';
|
|
5877
6063
|
message += `${nottomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5878
|
-
throw new BotiumError$
|
|
6064
|
+
throw new BotiumError$2(message, {
|
|
5879
6065
|
type: 'asserter',
|
|
5880
6066
|
source: 'TextMatchAsserter',
|
|
5881
6067
|
context: {
|
|
@@ -5922,7 +6108,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5922
6108
|
if (asserter[notAsserterType]) {
|
|
5923
6109
|
return p(this.retryHelperAsserter, () => asserter[notAsserterType](params));
|
|
5924
6110
|
} else {
|
|
5925
|
-
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$
|
|
6111
|
+
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$2(`${convoStep.stepTag}: Expected asserter ${asserter.name || asserterSpec.name} with args "${params.args}" to fail`, {
|
|
5926
6112
|
type: 'asserter',
|
|
5927
6113
|
source: asserter.name || asserterSpec.name,
|
|
5928
6114
|
params: {
|
|
@@ -6356,7 +6542,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6356
6542
|
});
|
|
6357
6543
|
|
|
6358
6544
|
if (aggregatedNoNames.length) {
|
|
6359
|
-
throw new BotiumError$
|
|
6545
|
+
throw new BotiumError$2('Scripting Memory Definition(s) without name', {
|
|
6360
6546
|
type: 'Scripting Memory',
|
|
6361
6547
|
subtype: 'Scripting Memory without name',
|
|
6362
6548
|
source: 'ScriptingProvider',
|
|
@@ -6372,7 +6558,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6372
6558
|
});
|
|
6373
6559
|
|
|
6374
6560
|
if (aggregatedNoVariables.length) {
|
|
6375
|
-
throw new BotiumError$
|
|
6561
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariables.map(e => e.header.name).join(', ')} without variable`, {
|
|
6376
6562
|
type: 'Scripting Memory',
|
|
6377
6563
|
subtype: 'Scripting Memory without variable',
|
|
6378
6564
|
source: 'ScriptingProvider',
|
|
@@ -6388,7 +6574,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6388
6574
|
});
|
|
6389
6575
|
|
|
6390
6576
|
if (aggregatedNoVariableNames.length) {
|
|
6391
|
-
throw new BotiumError$
|
|
6577
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariableNames.map(e => e.header.name).join(', ')} without variable name`, {
|
|
6392
6578
|
type: 'Scripting Memory',
|
|
6393
6579
|
subtype: 'Scripting Memory without variable name',
|
|
6394
6580
|
source: 'ScriptingProvider',
|
|
@@ -6420,7 +6606,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6420
6606
|
}
|
|
6421
6607
|
|
|
6422
6608
|
if (aggregatedDuplicates.length) {
|
|
6423
|
-
throw new BotiumError$
|
|
6609
|
+
throw new BotiumError$2(`Scripting Memory Definition name(s) "${lodash.uniq(aggregatedDuplicates.map(d => d.scriptingMemory.header.name)).join(', ')}" are not unique`, {
|
|
6424
6610
|
type: 'Scripting Memory',
|
|
6425
6611
|
subtype: 'Scripting Memory name collision',
|
|
6426
6612
|
source: 'ScriptingProvider',
|
|
@@ -6457,7 +6643,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6457
6643
|
}
|
|
6458
6644
|
|
|
6459
6645
|
if (aggregatedIntersections.length) {
|
|
6460
|
-
throw new BotiumError$
|
|
6646
|
+
throw new BotiumError$2(`Scripting Memory Definitions "${aggregatedIntersections.map(i => i.scriptingMemory.header.name).join(', ')}" are invalid because variable name collision"`, {
|
|
6461
6647
|
type: 'Scripting Memory',
|
|
6462
6648
|
subtype: 'Scripting Memory variable name collision',
|
|
6463
6649
|
source: 'ScriptingProvider',
|
|
@@ -6546,6 +6732,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6546
6732
|
|
|
6547
6733
|
debug$9(`ExpandScriptingMemoryToConvos - ${convosExpandedAll.length} convo expanded, added to convos (${this.convos.length}). Result ${convosExpandedAll.length + this.convos.length} convo`);
|
|
6548
6734
|
this.convos = this.convos.concat(convosExpandedAll);
|
|
6735
|
+
|
|
6736
|
+
this._sortConvos();
|
|
6549
6737
|
}
|
|
6550
6738
|
|
|
6551
6739
|
ExpandUtterancesToConvos({
|
|
@@ -6585,6 +6773,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6585
6773
|
},
|
|
6586
6774
|
conversation: [{
|
|
6587
6775
|
sender: 'me',
|
|
6776
|
+
logicHooks: [{
|
|
6777
|
+
name: 'SKIP_BOT_UNCONSUMED'
|
|
6778
|
+
}],
|
|
6588
6779
|
messageText: utt.name,
|
|
6589
6780
|
stepTag: 'Step 1 - tell utterance'
|
|
6590
6781
|
}, useNameAsIntent ? {
|
|
@@ -6900,7 +7091,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6900
7091
|
}
|
|
6901
7092
|
} else if (scriptingMemories) {
|
|
6902
7093
|
if (!scriptingMemories.header || !scriptingMemories.header.name) {
|
|
6903
|
-
throw new BotiumError$
|
|
7094
|
+
throw new BotiumError$2('Scripting Memory Definition has no name', {
|
|
6904
7095
|
type: 'Compiler',
|
|
6905
7096
|
subtype: 'Scripting memory without name',
|
|
6906
7097
|
source: 'ScriptingProvider',
|
|
@@ -6911,7 +7102,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6911
7102
|
}
|
|
6912
7103
|
|
|
6913
7104
|
if (!scriptingMemories.values || !Object.keys(scriptingMemories.values).length) {
|
|
6914
|
-
throw new BotiumError$
|
|
7105
|
+
throw new BotiumError$2('Scripting Memory Definition has no variables', {
|
|
6915
7106
|
type: 'Compiler',
|
|
6916
7107
|
subtype: 'Scripting memory without variable',
|
|
6917
7108
|
source: 'ScriptingProvider',
|
|
@@ -6922,7 +7113,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6922
7113
|
}
|
|
6923
7114
|
|
|
6924
7115
|
if (scriptingMemories.values && !lodash.isUndefined(scriptingMemories.values[''])) {
|
|
6925
|
-
throw new BotiumError$
|
|
7116
|
+
throw new BotiumError$2('Scripting Memory Definition variable has no name', {
|
|
6926
7117
|
type: 'Compiler',
|
|
6927
7118
|
subtype: 'Scripting memory without variable name',
|
|
6928
7119
|
source: 'ScriptingProvider',
|
|
@@ -7357,7 +7548,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7357
7548
|
this.tempDirectory = tempDirectory;
|
|
7358
7549
|
this.cleanupTasks = [];
|
|
7359
7550
|
this.queues = {};
|
|
7360
|
-
this.
|
|
7551
|
+
this.bottleneck = null;
|
|
7361
7552
|
}
|
|
7362
7553
|
|
|
7363
7554
|
Validate() {
|
|
@@ -7367,18 +7558,33 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7367
7558
|
this.onBotResponseHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONBOTRESPONSE]);
|
|
7368
7559
|
this.onStopHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONSTOP]);
|
|
7369
7560
|
this.onCleanHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONCLEAN]);
|
|
7370
|
-
return Promise.resolve();
|
|
7371
|
-
}
|
|
7372
7561
|
|
|
7373
|
-
|
|
7374
|
-
|
|
7562
|
+
if (this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN]) {
|
|
7563
|
+
if (lodash.isFunction(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN])) {
|
|
7564
|
+
this.bottleneck = this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN];
|
|
7565
|
+
debug$7('Validate: Applying userSays rate limits from capability');
|
|
7566
|
+
} else {
|
|
7567
|
+
const limiter = new bottleneck(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN]);
|
|
7568
|
+
|
|
7569
|
+
this.bottleneck = fn => limiter.schedule(fn);
|
|
7570
|
+
|
|
7571
|
+
debug$7(`Validate: Applying userSays rate limits ${util.inspect(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN])}`);
|
|
7572
|
+
}
|
|
7573
|
+
} else if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT] || this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) {
|
|
7375
7574
|
const opts = {};
|
|
7376
7575
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT]) opts.maxConcurrent = this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT];
|
|
7377
7576
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) opts.minTime = this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME];
|
|
7378
|
-
|
|
7379
|
-
|
|
7577
|
+
const limiter = new bottleneck(opts);
|
|
7578
|
+
|
|
7579
|
+
this.bottleneck = fn => limiter.schedule(fn);
|
|
7580
|
+
|
|
7581
|
+
debug$7(`Validate: Applying userSays rate limits ${util.inspect(opts)}`);
|
|
7380
7582
|
}
|
|
7381
7583
|
|
|
7584
|
+
return Promise.resolve();
|
|
7585
|
+
}
|
|
7586
|
+
|
|
7587
|
+
Build() {
|
|
7382
7588
|
return new Promise((resolve, reject) => {
|
|
7383
7589
|
this._RunCustomHook('onBuild', this.onBuildHook).then(() => resolve(this)).catch(err => reject(err));
|
|
7384
7590
|
});
|
|
@@ -7404,8 +7610,8 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7404
7610
|
meMsg
|
|
7405
7611
|
}).then(() => this.UserSaysImpl(meMsg));
|
|
7406
7612
|
|
|
7407
|
-
if (this.
|
|
7408
|
-
return this.
|
|
7613
|
+
if (this.bottleneck) {
|
|
7614
|
+
return this.bottleneck(run);
|
|
7409
7615
|
} else {
|
|
7410
7616
|
return run();
|
|
7411
7617
|
}
|
|
@@ -7884,16 +8090,23 @@ const {
|
|
|
7884
8090
|
const {
|
|
7885
8091
|
escapeJSONString
|
|
7886
8092
|
} = Utils;
|
|
8093
|
+
const {
|
|
8094
|
+
BotiumError: BotiumError$1
|
|
8095
|
+
} = BotiumError_1;
|
|
7887
8096
|
|
|
7888
8097
|
mustache.escape = s => s;
|
|
7889
8098
|
|
|
7890
8099
|
var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
7891
8100
|
constructor({
|
|
7892
8101
|
queueBotSays,
|
|
7893
|
-
caps
|
|
8102
|
+
caps,
|
|
8103
|
+
bottleneck
|
|
7894
8104
|
}) {
|
|
7895
8105
|
this.queueBotSays = queueBotSays;
|
|
7896
8106
|
this.caps = Object.assign({}, Defaults, caps);
|
|
8107
|
+
|
|
8108
|
+
this.bottleneck = bottleneck || (fn => fn());
|
|
8109
|
+
|
|
7897
8110
|
this.processInbound = false;
|
|
7898
8111
|
this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
|
|
7899
8112
|
|
|
@@ -8180,31 +8393,82 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8180
8393
|
}
|
|
8181
8394
|
|
|
8182
8395
|
for (const jsonPathRoot of jsonPathRoots) {
|
|
8183
|
-
const
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
}
|
|
8194
|
-
|
|
8396
|
+
const _retrieveMedia = (jsonPathMediaRoot, jsonPathsMedia) => {
|
|
8397
|
+
const retrievedMedia = [];
|
|
8398
|
+
jsonPathsMedia.forEach(jsonPath => {
|
|
8399
|
+
const responseMedia = jsonpath.query(jsonPathMediaRoot, jsonPath);
|
|
8400
|
+
|
|
8401
|
+
if (responseMedia) {
|
|
8402
|
+
(lodash.isArray(responseMedia) ? lodash.flattenDeep(responseMedia) : [responseMedia]).forEach(m => retrievedMedia.push({
|
|
8403
|
+
mediaUri: m,
|
|
8404
|
+
mimeType: mimeTypes.lookup(m) || 'application/unknown'
|
|
8405
|
+
}));
|
|
8406
|
+
}
|
|
8407
|
+
});
|
|
8408
|
+
return retrievedMedia;
|
|
8409
|
+
};
|
|
8410
|
+
|
|
8411
|
+
const _retrieveButtons = (jsonPathButtonRoot, jsonPathsButtons) => {
|
|
8412
|
+
const retrievedButtons = [];
|
|
8413
|
+
jsonPathsButtons.forEach(jsonPath => {
|
|
8414
|
+
const responseButtons = jsonpath.query(jsonPathButtonRoot, jsonPath);
|
|
8415
|
+
|
|
8416
|
+
if (responseButtons) {
|
|
8417
|
+
(lodash.isArray(responseButtons) ? lodash.flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
|
|
8418
|
+
text: b
|
|
8419
|
+
}));
|
|
8420
|
+
}
|
|
8421
|
+
});
|
|
8422
|
+
return retrievedButtons;
|
|
8423
|
+
};
|
|
8424
|
+
|
|
8425
|
+
const _getCardText = responseCardText => {
|
|
8426
|
+
if (responseCardText) {
|
|
8427
|
+
const texts = lodash.isArray(responseCardText) ? lodash.flattenDeep(responseCardText) : [responseCardText];
|
|
8428
|
+
|
|
8429
|
+
if (texts.length > 1) {
|
|
8430
|
+
debug$4(`more than one text found for card: ${util.inspect(texts)}`);
|
|
8431
|
+
}
|
|
8432
|
+
|
|
8433
|
+
if (texts.length > 0) {
|
|
8434
|
+
return texts[0];
|
|
8435
|
+
}
|
|
8195
8436
|
}
|
|
8196
|
-
}
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8437
|
+
};
|
|
8438
|
+
|
|
8439
|
+
const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
|
|
8440
|
+
|
|
8441
|
+
debug$4(`found response media: ${util.inspect(media)}`);
|
|
8442
|
+
|
|
8443
|
+
const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
|
|
8444
|
+
|
|
8445
|
+
debug$4(`found response buttons: ${util.inspect(buttons)}`);
|
|
8446
|
+
const cards = [];
|
|
8447
|
+
const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
|
|
8448
|
+
jsonPathsCards.forEach(jsonPath => {
|
|
8449
|
+
const responseCards = jsonpath.query(jsonPathRoot, jsonPath);
|
|
8450
|
+
|
|
8451
|
+
if (responseCards) {
|
|
8452
|
+
(lodash.isArray(responseCards) ? lodash.flattenDeep(responseCards) : [responseCards]).forEach(c => {
|
|
8453
|
+
const card = {};
|
|
8454
|
+
const jsonPathsCardText = getAllCapValues(Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH, this.caps);
|
|
8455
|
+
jsonPathsCardText.forEach(jsonPath => {
|
|
8456
|
+
card.text = _getCardText(jsonpath.query(c, jsonPath));
|
|
8457
|
+
});
|
|
8458
|
+
const jsonPathsCardSubText = getAllCapValues(Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH, this.caps);
|
|
8459
|
+
jsonPathsCardSubText.forEach(jsonPath => {
|
|
8460
|
+
card.subtext = _getCardText(jsonpath.query(c, jsonPath));
|
|
8461
|
+
});
|
|
8462
|
+
card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
|
|
8463
|
+
card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
|
|
8464
|
+
|
|
8465
|
+
if (lodash.keys(card).length > 0) {
|
|
8466
|
+
cards.push(card);
|
|
8467
|
+
}
|
|
8468
|
+
});
|
|
8206
8469
|
}
|
|
8207
8470
|
});
|
|
8471
|
+
debug$4(`found response cards: ${util.inspect(cards)}`);
|
|
8208
8472
|
let hasMessageText = false;
|
|
8209
8473
|
const jsonPathsTexts = getAllCapValues(Capabilities.SIMPLEREST_RESPONSE_JSONPATH, this.caps);
|
|
8210
8474
|
|
|
@@ -8221,7 +8485,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8221
8485
|
sourceData: body,
|
|
8222
8486
|
messageText,
|
|
8223
8487
|
media,
|
|
8224
|
-
buttons
|
|
8488
|
+
buttons,
|
|
8489
|
+
cards
|
|
8225
8490
|
};
|
|
8226
8491
|
await executeHook(this.caps, this.responseHook, Object.assign({
|
|
8227
8492
|
botMsg,
|
|
@@ -8237,7 +8502,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8237
8502
|
messageText: '',
|
|
8238
8503
|
sourceData: body,
|
|
8239
8504
|
media,
|
|
8240
|
-
buttons
|
|
8505
|
+
buttons,
|
|
8506
|
+
cards
|
|
8241
8507
|
};
|
|
8242
8508
|
const beforeHookKeys = Object.keys(botMsg);
|
|
8243
8509
|
await executeHook(this.caps, this.responseHook, Object.assign({
|
|
@@ -8246,7 +8512,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8246
8512
|
}, this.view));
|
|
8247
8513
|
const afterHookKeys = Object.keys(botMsg);
|
|
8248
8514
|
|
|
8249
|
-
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8515
|
+
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8250
8516
|
result.push(botMsg);
|
|
8251
8517
|
}
|
|
8252
8518
|
}
|
|
@@ -8273,6 +8539,17 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8273
8539
|
debug$4(Utils.shortenJsonString(body));
|
|
8274
8540
|
}
|
|
8275
8541
|
|
|
8542
|
+
if (body) {
|
|
8543
|
+
const jsonBody = Utils.toJsonWeak(body);
|
|
8544
|
+
const errKey = Object.keys(jsonBody).find(k => k.startsWith('err') || k.startsWith('fail'));
|
|
8545
|
+
|
|
8546
|
+
if (errKey) {
|
|
8547
|
+
return reject(new BotiumError$1(`got error response: ${response.statusCode}/${response.statusMessage} - ${jsonBody[errKey]}`, {
|
|
8548
|
+
message: Utils.shortenJsonString(body)
|
|
8549
|
+
}));
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8552
|
+
|
|
8276
8553
|
return reject(new Error(`got error response: ${response.statusCode}/${response.statusMessage}`));
|
|
8277
8554
|
}
|
|
8278
8555
|
|
|
@@ -8370,6 +8647,16 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8370
8647
|
}
|
|
8371
8648
|
}
|
|
8372
8649
|
|
|
8650
|
+
if (msg.ADD_FORM_PARAM && Object.keys(msg.ADD_FORM_PARAM).length > 0) {
|
|
8651
|
+
requestOptions.form = {};
|
|
8652
|
+
|
|
8653
|
+
for (const formKey of Object.keys(msg.ADD_FORM_PARAM)) {
|
|
8654
|
+
const formValue = this._getMustachedVal(lodash.isString(msg.ADD_FORM_PARAM[formKey]) ? msg.ADD_FORM_PARAM[formKey] : JSON.stringify(msg.ADD_FORM_PARAM[formKey]), false);
|
|
8655
|
+
|
|
8656
|
+
requestOptions.form[formKey] = formValue;
|
|
8657
|
+
}
|
|
8658
|
+
}
|
|
8659
|
+
|
|
8373
8660
|
if (msg.ADD_HEADER && Object.keys(msg.ADD_HEADER).length > 0) {
|
|
8374
8661
|
requestOptions.headers = requestOptions.headers || {};
|
|
8375
8662
|
|
|
@@ -8411,7 +8698,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8411
8698
|
err,
|
|
8412
8699
|
response,
|
|
8413
8700
|
body
|
|
8414
|
-
} = await new Promise(resolve => {
|
|
8701
|
+
} = await this.bottleneck(() => new Promise(resolve => {
|
|
8415
8702
|
request(pingConfig, (err, response, body) => {
|
|
8416
8703
|
resolve({
|
|
8417
8704
|
err,
|
|
@@ -8419,7 +8706,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8419
8706
|
body
|
|
8420
8707
|
});
|
|
8421
8708
|
});
|
|
8422
|
-
});
|
|
8709
|
+
}));
|
|
8423
8710
|
|
|
8424
8711
|
if (err) {
|
|
8425
8712
|
debug$4(`_waitForUrlResponse error on url check ${pingConfig.uri}: ${err}`);
|
|
@@ -8943,6 +9230,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8943
9230
|
this.pluginInstance = tryLoadPlugin(this.caps[Capabilities.CONTAINERMODE], this.caps[Capabilities.PLUGINMODULEPATH], {
|
|
8944
9231
|
container: this,
|
|
8945
9232
|
queueBotSays: msg => this._QueueBotSays(msg),
|
|
9233
|
+
bottleneck: this.bottleneck,
|
|
8946
9234
|
eventEmitter: this.eventEmitter,
|
|
8947
9235
|
caps: this.caps,
|
|
8948
9236
|
sources: this.sources,
|
|
@@ -9190,9 +9478,9 @@ var BotDriver_1 = class BotDriver {
|
|
|
9190
9478
|
|
|
9191
9479
|
Build() {
|
|
9192
9480
|
debug$1(`Build - Botium Core Version: ${version}`);
|
|
9193
|
-
debug$1(`Build - Capabilites: ${
|
|
9194
|
-
debug$1(`Build - Sources
|
|
9195
|
-
debug$1(`Build - Envs
|
|
9481
|
+
debug$1(`Build - Capabilites: ${JSON.stringify(lodash.pickBy(this.caps, (value, key) => Defaults$1.Capabilities[key] !== value), null, 2)}`);
|
|
9482
|
+
debug$1(`Build - Sources: ${JSON.stringify(lodash.pickBy(this.sources, (value, key) => Defaults$1.Sources[key] !== value), null, 2)}`);
|
|
9483
|
+
debug$1(`Build - Envs: ${JSON.stringify(lodash.pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
|
|
9196
9484
|
this.eventEmitter.emit(Events.CONTAINER_BUILDING);
|
|
9197
9485
|
return new Promise((resolve, reject) => {
|
|
9198
9486
|
let repo = null;
|
|
@@ -9640,6 +9928,7 @@ var botiumCore = {
|
|
|
9640
9928
|
ScriptingConstants: Constants,
|
|
9641
9929
|
Capabilities: Capabilities,
|
|
9642
9930
|
Defaults: Defaults$1,
|
|
9931
|
+
Enums: Enums,
|
|
9643
9932
|
Source: Source,
|
|
9644
9933
|
Events: Events,
|
|
9645
9934
|
Plugins: Plugins,
|
|
@@ -9659,16 +9948,17 @@ var botiumCore_2 = botiumCore.ScriptingProvider;
|
|
|
9659
9948
|
var botiumCore_3 = botiumCore.ScriptingConstants;
|
|
9660
9949
|
var botiumCore_4 = botiumCore.Capabilities;
|
|
9661
9950
|
var botiumCore_5 = botiumCore.Defaults;
|
|
9662
|
-
var botiumCore_6 = botiumCore.
|
|
9663
|
-
var botiumCore_7 = botiumCore.
|
|
9664
|
-
var botiumCore_8 = botiumCore.
|
|
9665
|
-
var botiumCore_9 = botiumCore.
|
|
9666
|
-
var botiumCore_10 = botiumCore.
|
|
9667
|
-
var botiumCore_11 = botiumCore.
|
|
9668
|
-
var botiumCore_12 = botiumCore.
|
|
9669
|
-
var botiumCore_13 = botiumCore.
|
|
9670
|
-
var botiumCore_14 = botiumCore.
|
|
9671
|
-
var botiumCore_15 = botiumCore.
|
|
9672
|
-
|
|
9673
|
-
|
|
9951
|
+
var botiumCore_6 = botiumCore.Enums;
|
|
9952
|
+
var botiumCore_7 = botiumCore.Source;
|
|
9953
|
+
var botiumCore_8 = botiumCore.Events;
|
|
9954
|
+
var botiumCore_9 = botiumCore.Plugins;
|
|
9955
|
+
var botiumCore_10 = botiumCore.BotiumError;
|
|
9956
|
+
var botiumCore_11 = botiumCore.ScriptingMemory;
|
|
9957
|
+
var botiumCore_12 = botiumCore.HookUtils;
|
|
9958
|
+
var botiumCore_13 = botiumCore.LogicHookConstants;
|
|
9959
|
+
var botiumCore_14 = botiumCore.Lib;
|
|
9960
|
+
var botiumCore_15 = botiumCore.InboundProxy;
|
|
9961
|
+
var botiumCore_16 = botiumCore.BotiumMockRichMessageTypes;
|
|
9962
|
+
|
|
9963
|
+
export { botiumCore_1 as BotDriver, botiumCore_10 as BotiumError, botiumCore_16 as BotiumMockRichMessageTypes, botiumCore_4 as Capabilities, botiumCore_5 as Defaults, botiumCore_6 as Enums, botiumCore_8 as Events, botiumCore_12 as HookUtils, botiumCore_15 as InboundProxy, botiumCore_14 as Lib, botiumCore_13 as LogicHookConstants, botiumCore_9 as Plugins, botiumCore_3 as ScriptingConstants, botiumCore_11 as ScriptingMemory, botiumCore_2 as ScriptingProvider, botiumCore_7 as Source, botiumCore as default };
|
|
9674
9964
|
//# sourceMappingURL=botium-es.js.map
|