botium-core 1.11.14 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botium-cjs.js +853 -579
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +471 -198
- 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/Capabilities.js +4 -1
- package/src/Defaults.js +1 -0
- package/src/Enums.js +6 -0
- package/src/containers/plugins/SimpleRestContainer.js +32 -1
- 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/MatchFunctions.js +21 -0
- package/src/scripting/ScriptingProvider.js +55 -40
- package/src/scripting/helper.js +57 -4
- 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/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 +42 -2
- package/test/convo/convos/continuefailing.convo.txt +19 -0
- package/test/convo/transcript.spec.js +34 -0
- 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/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-cjs.js
CHANGED
|
@@ -27,7 +27,7 @@ var isJson$1 = require('is-json');
|
|
|
27
27
|
var esprima = require('esprima');
|
|
28
28
|
var markdownIt = require('markdown-it');
|
|
29
29
|
var xlsx = require('xlsx');
|
|
30
|
-
var sync = require('csv-parse/
|
|
30
|
+
var sync = require('csv-parse/sync');
|
|
31
31
|
var yaml = require('yaml');
|
|
32
32
|
var child_process = require('child_process');
|
|
33
33
|
var socket = require('socket.io-client');
|
|
@@ -79,12 +79,12 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
|
79
79
|
var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
|
|
80
80
|
|
|
81
81
|
var name = "botium-core";
|
|
82
|
-
var version$1 = "1.
|
|
82
|
+
var version$1 = "1.12.1";
|
|
83
83
|
var description = "The Selenium for Chatbots";
|
|
84
84
|
var main = "index.js";
|
|
85
85
|
var module$1 = "dist/botium-es.js";
|
|
86
86
|
var engines = {
|
|
87
|
-
node: ">=
|
|
87
|
+
node: ">=14.0.0"
|
|
88
88
|
};
|
|
89
89
|
var scripts = {
|
|
90
90
|
postinstall: "node ./report.js",
|
|
@@ -111,66 +111,66 @@ var bugs = {
|
|
|
111
111
|
};
|
|
112
112
|
var homepage = "https://www.botium.ai";
|
|
113
113
|
var dependencies = {
|
|
114
|
-
"@babel/runtime": "^7.
|
|
115
|
-
async: "^3.2.
|
|
116
|
-
"body-parser": "^1.19.
|
|
114
|
+
"@babel/runtime": "^7.16.7",
|
|
115
|
+
async: "^3.2.3",
|
|
116
|
+
"body-parser": "^1.19.1",
|
|
117
117
|
boolean: "^3.1.4",
|
|
118
118
|
bottleneck: "^2.19.5",
|
|
119
|
-
"csv-parse": "^
|
|
120
|
-
debug: "^4.3.
|
|
119
|
+
"csv-parse": "^5.0.4",
|
|
120
|
+
debug: "^4.3.3",
|
|
121
121
|
esprima: "^4.0.1",
|
|
122
|
-
express: "^4.17.
|
|
122
|
+
express: "^4.17.2",
|
|
123
123
|
globby: "11.0.4",
|
|
124
|
-
ioredis: "^4.
|
|
124
|
+
ioredis: "^4.28.3",
|
|
125
125
|
"is-class": "^0.0.9",
|
|
126
126
|
"is-json": "^2.0.1",
|
|
127
127
|
jsonpath: "^1.1.1",
|
|
128
128
|
lodash: "^4.17.21",
|
|
129
|
-
"markdown-it": "^12.2
|
|
130
|
-
"mime-types": "^2.1.
|
|
129
|
+
"markdown-it": "^12.3.2",
|
|
130
|
+
"mime-types": "^2.1.34",
|
|
131
131
|
mkdirp: "^1.0.4",
|
|
132
132
|
moment: "^2.29.1",
|
|
133
133
|
mustache: "^4.2.0",
|
|
134
134
|
"promise-retry": "^2.0.1",
|
|
135
|
-
"promise.allsettled": "^1.0.
|
|
135
|
+
"promise.allsettled": "^1.0.5",
|
|
136
136
|
randomatic: "^3.1.1",
|
|
137
137
|
request: "^2.88.2",
|
|
138
138
|
rimraf: "^3.0.2",
|
|
139
139
|
"sanitize-filename": "^1.6.3",
|
|
140
|
-
slugify: "^1.6.
|
|
141
|
-
"socket.io": "^4.
|
|
142
|
-
"socket.io-client": "^4.
|
|
140
|
+
slugify: "^1.6.5",
|
|
141
|
+
"socket.io": "^4.4.1",
|
|
142
|
+
"socket.io-client": "^4.4.1",
|
|
143
143
|
"socketio-auth": "^0.1.1",
|
|
144
144
|
"swagger-jsdoc": "^6.1.0",
|
|
145
|
-
"swagger-ui-express": "^4.
|
|
145
|
+
"swagger-ui-express": "^4.3.0",
|
|
146
146
|
uuid: "^8.3.2",
|
|
147
|
-
vm2: "^3.9.
|
|
147
|
+
vm2: "^3.9.5",
|
|
148
148
|
"write-yaml": "^1.0.0",
|
|
149
|
-
xlsx: "^0.17.
|
|
149
|
+
xlsx: "^0.17.5",
|
|
150
150
|
xregexp: "^5.1.0",
|
|
151
151
|
yaml: "^1.10.2"
|
|
152
152
|
};
|
|
153
153
|
var devDependencies = {
|
|
154
|
-
"@babel/core": "^7.
|
|
155
|
-
"@babel/node": "^7.
|
|
156
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
157
|
-
"@babel/preset-env": "^7.
|
|
154
|
+
"@babel/core": "^7.16.12",
|
|
155
|
+
"@babel/node": "^7.16.8",
|
|
156
|
+
"@babel/plugin-transform-runtime": "^7.16.10",
|
|
157
|
+
"@babel/preset-env": "^7.16.11",
|
|
158
158
|
chai: "^4.3.4",
|
|
159
159
|
"chai-as-promised": "^7.1.1",
|
|
160
160
|
"cross-env": "^7.0.3",
|
|
161
|
-
eslint: "^7.
|
|
161
|
+
eslint: "^8.7.0",
|
|
162
162
|
"eslint-config-standard": "^16.0.3",
|
|
163
|
-
"eslint-plugin-import": "^2.
|
|
163
|
+
"eslint-plugin-import": "^2.25.4",
|
|
164
164
|
"eslint-plugin-node": "^11.1.0",
|
|
165
|
-
"eslint-plugin-promise": "^
|
|
165
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
166
166
|
"eslint-plugin-standard": "^4.1.0",
|
|
167
167
|
"license-checker": "^25.0.1",
|
|
168
168
|
"license-compatibility-checker": "^0.3.5",
|
|
169
|
-
mocha: "^9.
|
|
170
|
-
nock: "^13.
|
|
171
|
-
"npm-check-updates": "^
|
|
169
|
+
mocha: "^9.2.0",
|
|
170
|
+
nock: "^13.2.2",
|
|
171
|
+
"npm-check-updates": "^12.2.1",
|
|
172
172
|
nyc: "^15.1.0",
|
|
173
|
-
rollup: "^2.
|
|
173
|
+
rollup: "^2.66.0",
|
|
174
174
|
"rollup-plugin-babel": "^4.4.0",
|
|
175
175
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
176
176
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -325,8 +325,9 @@ var Capabilities = {
|
|
|
325
325
|
SCRIPTING_NORMALIZE_TEXT: 'SCRIPTING_NORMALIZE_TEXT',
|
|
326
326
|
SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
|
|
327
327
|
SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
|
|
328
|
+
SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS: 'SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS',
|
|
328
329
|
SCRIPTING_FORCE_BOT_CONSUMED: 'SCRIPTING_FORCE_BOT_CONSUMED',
|
|
329
|
-
// regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
|
|
330
|
+
// regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, wildcardExact, wildcardExactIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
|
|
330
331
|
SCRIPTING_MATCHING_MODE: 'SCRIPTING_MATCHING_MODE',
|
|
331
332
|
// all, first, random
|
|
332
333
|
SCRIPTING_UTTEXPANSION_MODE: 'SCRIPTING_UTTEXPANSION_MODE',
|
|
@@ -340,6 +341,8 @@ var Capabilities = {
|
|
|
340
341
|
SCRIPTING_MEMORYEXPANSION_KEEP_ORIG: 'SCRIPTING_MEMORYEXPANSION_KEEP_ORIG',
|
|
341
342
|
// word, non_whitespace, joker
|
|
342
343
|
SCRIPTING_MEMORY_MATCHING_MODE: 'SCRIPTING_MEMORY_MATCHING_MODE',
|
|
344
|
+
// varnames, testcasenames
|
|
345
|
+
SCRIPTING_MEMORY_COLUMN_MODE: 'SCRIPTING_MEMORY_COLUMN_MODE',
|
|
343
346
|
// Botium Lifecycle Hooks
|
|
344
347
|
CUSTOMHOOK_ONBUILD: 'CUSTOMHOOK_ONBUILD',
|
|
345
348
|
CUSTOMHOOK_ONSTART: 'CUSTOMHOOK_ONSTART',
|
|
@@ -465,6 +468,7 @@ Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER;
|
|
|
465
468
|
Capabilities.SCRIPTING_NORMALIZE_TEXT;
|
|
466
469
|
Capabilities.SCRIPTING_ENABLE_MEMORY;
|
|
467
470
|
Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS;
|
|
471
|
+
Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS;
|
|
468
472
|
Capabilities.SCRIPTING_FORCE_BOT_CONSUMED;
|
|
469
473
|
Capabilities.SCRIPTING_MATCHING_MODE;
|
|
470
474
|
Capabilities.SCRIPTING_UTTEXPANSION_MODE;
|
|
@@ -475,6 +479,7 @@ Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE;
|
|
|
475
479
|
Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX;
|
|
476
480
|
Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG;
|
|
477
481
|
Capabilities.SCRIPTING_MEMORY_MATCHING_MODE;
|
|
482
|
+
Capabilities.SCRIPTING_MEMORY_COLUMN_MODE;
|
|
478
483
|
Capabilities.CUSTOMHOOK_ONBUILD;
|
|
479
484
|
Capabilities.CUSTOMHOOK_ONSTART;
|
|
480
485
|
Capabilities.CUSTOMHOOK_ONUSERSAYS;
|
|
@@ -553,6 +558,7 @@ var Defaults$1 = {
|
|
|
553
558
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'justLineTag',
|
|
554
559
|
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: '16',
|
|
555
560
|
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false,
|
|
561
|
+
[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: false,
|
|
556
562
|
[Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: false,
|
|
557
563
|
[Capabilities.ASSERTERS]: [],
|
|
558
564
|
[Capabilities.LOGIC_HOOKS]: [],
|
|
@@ -594,7 +600,7 @@ var Fluent_1 = class Fluent {
|
|
|
594
600
|
|
|
595
601
|
Exec() {
|
|
596
602
|
return new Promise((resolve, reject) => {
|
|
597
|
-
async__default[
|
|
603
|
+
async__default["default"].eachSeries(this.tasks, (task, cb) => {
|
|
598
604
|
try {
|
|
599
605
|
const taskResult = task();
|
|
600
606
|
|
|
@@ -684,7 +690,7 @@ var Fluent_1 = class Fluent {
|
|
|
684
690
|
}
|
|
685
691
|
|
|
686
692
|
this.compiler.ExpandConvos();
|
|
687
|
-
async__default[
|
|
693
|
+
async__default["default"].eachSeries(this.compiler.convos, (convo, convoDone) => {
|
|
688
694
|
this.container.Start().then(() => convo.Run(this.container)).then(() => this.container.Stop()).then(() => convoDone()).catch(convoDone);
|
|
689
695
|
}, err => {
|
|
690
696
|
if (err) return reject(err);else resolve();
|
|
@@ -696,7 +702,7 @@ var Fluent_1 = class Fluent {
|
|
|
696
702
|
|
|
697
703
|
UserSaysText(msg) {
|
|
698
704
|
this.tasks.push(() => {
|
|
699
|
-
if (lodash__default[
|
|
705
|
+
if (lodash__default["default"].isFunction(msg)) {
|
|
700
706
|
msg = msg();
|
|
701
707
|
}
|
|
702
708
|
|
|
@@ -714,7 +720,7 @@ var Fluent_1 = class Fluent {
|
|
|
714
720
|
|
|
715
721
|
UserSays(msg) {
|
|
716
722
|
this.tasks.push(() => {
|
|
717
|
-
if (lodash__default[
|
|
723
|
+
if (lodash__default["default"].isFunction(msg)) {
|
|
718
724
|
msg = msg();
|
|
719
725
|
}
|
|
720
726
|
|
|
@@ -730,10 +736,10 @@ var Fluent_1 = class Fluent {
|
|
|
730
736
|
|
|
731
737
|
WaitBotSays(channel = null, timeoutMillis = null, callback = null) {
|
|
732
738
|
if (!callback) {
|
|
733
|
-
if (timeoutMillis && lodash__default[
|
|
739
|
+
if (timeoutMillis && lodash__default["default"].isFunction(timeoutMillis)) {
|
|
734
740
|
callback = timeoutMillis;
|
|
735
741
|
timeoutMillis = null;
|
|
736
|
-
} else if (!timeoutMillis && channel && lodash__default[
|
|
742
|
+
} else if (!timeoutMillis && channel && lodash__default["default"].isFunction(channel)) {
|
|
737
743
|
callback = channel;
|
|
738
744
|
timeoutMillis = null;
|
|
739
745
|
channel = null;
|
|
@@ -759,10 +765,10 @@ var Fluent_1 = class Fluent {
|
|
|
759
765
|
|
|
760
766
|
WaitBotSaysText(channel = null, timeoutMillis = null, callback = null) {
|
|
761
767
|
if (!callback) {
|
|
762
|
-
if (timeoutMillis && lodash__default[
|
|
768
|
+
if (timeoutMillis && lodash__default["default"].isFunction(timeoutMillis)) {
|
|
763
769
|
callback = timeoutMillis;
|
|
764
770
|
timeoutMillis = null;
|
|
765
|
-
} else if (!timeoutMillis && channel && lodash__default[
|
|
771
|
+
} else if (!timeoutMillis && channel && lodash__default["default"].isFunction(channel)) {
|
|
766
772
|
callback = channel;
|
|
767
773
|
timeoutMillis = null;
|
|
768
774
|
channel = null;
|
|
@@ -874,7 +880,7 @@ function getCjsExportFromNamespace (n) {
|
|
|
874
880
|
return n && n['default'] || n;
|
|
875
881
|
}
|
|
876
882
|
|
|
877
|
-
const BotiumError$
|
|
883
|
+
const BotiumError$7 = class BotiumError extends Error {
|
|
878
884
|
/**
|
|
879
885
|
*
|
|
880
886
|
* @param message
|
|
@@ -899,11 +905,32 @@ const BotiumError$6 = class BotiumError extends Error {
|
|
|
899
905
|
this.context.message = message.message || message;
|
|
900
906
|
}
|
|
901
907
|
|
|
908
|
+
isAsserterError() {
|
|
909
|
+
if (this.context) {
|
|
910
|
+
const errArr = lodash__default["default"].isArray(this.context) ? this.context : [this.context];
|
|
911
|
+
const hasNotAsserterError = errArr.findIndex(errDetail => {
|
|
912
|
+
if (errDetail.type === 'list') {
|
|
913
|
+
if (errDetail.errors) {
|
|
914
|
+
return errDetail.errors.findIndex(e => e.type !== 'asserter') >= 0;
|
|
915
|
+
} else {
|
|
916
|
+
return true;
|
|
917
|
+
}
|
|
918
|
+
} else {
|
|
919
|
+
return errDetail.type !== 'asserter';
|
|
920
|
+
}
|
|
921
|
+
}) >= 0;
|
|
922
|
+
if (hasNotAsserterError) return false;
|
|
923
|
+
return true;
|
|
924
|
+
} else {
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
902
929
|
prettify(includeJson) {
|
|
903
930
|
const lines = [];
|
|
904
931
|
|
|
905
932
|
if (this.context) {
|
|
906
|
-
const errArr = lodash__default[
|
|
933
|
+
const errArr = lodash__default["default"].isArray(this.context) ? this.context : [this.context];
|
|
907
934
|
errArr.forEach(errDetail => {
|
|
908
935
|
lines.push('########################################');
|
|
909
936
|
|
|
@@ -952,7 +979,7 @@ const BotiumError$6 = class BotiumError extends Error {
|
|
|
952
979
|
};
|
|
953
980
|
|
|
954
981
|
const _getChildErrorsFromContext = context => {
|
|
955
|
-
if (context && context.errors && lodash__default[
|
|
982
|
+
if (context && context.errors && lodash__default["default"].isArray(context.errors)) {
|
|
956
983
|
return context.errors;
|
|
957
984
|
}
|
|
958
985
|
|
|
@@ -960,10 +987,10 @@ const _getChildErrorsFromContext = context => {
|
|
|
960
987
|
};
|
|
961
988
|
|
|
962
989
|
const botiumErrorFromErr$2 = (message, err) => {
|
|
963
|
-
if (err instanceof BotiumError$
|
|
964
|
-
return new BotiumError$
|
|
990
|
+
if (err instanceof BotiumError$7) {
|
|
991
|
+
return new BotiumError$7(message, err.context, true);
|
|
965
992
|
} else {
|
|
966
|
-
return new BotiumError$
|
|
993
|
+
return new BotiumError$7(message, {
|
|
967
994
|
err
|
|
968
995
|
}, true);
|
|
969
996
|
}
|
|
@@ -978,7 +1005,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
978
1005
|
let children = [];
|
|
979
1006
|
|
|
980
1007
|
for (const error of errors) {
|
|
981
|
-
if (error instanceof BotiumError$
|
|
1008
|
+
if (error instanceof BotiumError$7) {
|
|
982
1009
|
const childErrors = flat && _getChildErrorsFromContext(error.context);
|
|
983
1010
|
|
|
984
1011
|
if (childErrors && childErrors.length) {
|
|
@@ -991,7 +1018,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
991
1018
|
}
|
|
992
1019
|
}
|
|
993
1020
|
|
|
994
|
-
const result = new BotiumError$
|
|
1021
|
+
const result = new BotiumError$7(message, {
|
|
995
1022
|
errors: children,
|
|
996
1023
|
type,
|
|
997
1024
|
source
|
|
@@ -1000,7 +1027,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
1000
1027
|
};
|
|
1001
1028
|
|
|
1002
1029
|
var BotiumError_1 = {
|
|
1003
|
-
BotiumError: BotiumError$
|
|
1030
|
+
BotiumError: BotiumError$7,
|
|
1004
1031
|
botiumErrorFromErr: botiumErrorFromErr$2,
|
|
1005
1032
|
botiumErrorFromList: botiumErrorFromList$2
|
|
1006
1033
|
};
|
|
@@ -1092,6 +1119,18 @@ var LogicHookConsts = {
|
|
|
1092
1119
|
}, {
|
|
1093
1120
|
name: 'TEXT_WILDCARD_ALL_IC',
|
|
1094
1121
|
className: 'TextWildcardAllICAsserter'
|
|
1122
|
+
}, {
|
|
1123
|
+
name: 'TEXT_WILDCARDEXACT_ANY',
|
|
1124
|
+
className: 'TextWildcardExactAnyAsserter'
|
|
1125
|
+
}, {
|
|
1126
|
+
name: 'TEXT_WILDCARDEXACT_ANY_IC',
|
|
1127
|
+
className: 'TextWildcardExactAnyICAsserter'
|
|
1128
|
+
}, {
|
|
1129
|
+
name: 'TEXT_WILDCARDEXACT_ALL',
|
|
1130
|
+
className: 'TextWildcardExactAllAsserter'
|
|
1131
|
+
}, {
|
|
1132
|
+
name: 'TEXT_WILDCARDEXACT_ALL_IC',
|
|
1133
|
+
className: 'TextWildcardExactAllICAsserter'
|
|
1095
1134
|
}, {
|
|
1096
1135
|
name: 'TEXT_REGEXP_ANY',
|
|
1097
1136
|
className: 'TextRegexpAnyAsserter'
|
|
@@ -1166,10 +1205,10 @@ LogicHookConsts.DEFAULT_USER_INPUTS;
|
|
|
1166
1205
|
|
|
1167
1206
|
const {
|
|
1168
1207
|
NodeVM: NodeVM$2
|
|
1169
|
-
} = vm2__default[
|
|
1170
|
-
const debug$k = debug__default[
|
|
1208
|
+
} = vm2__default["default"];
|
|
1209
|
+
const debug$k = debug__default["default"]('botium-core-asserterUtils');
|
|
1171
1210
|
const {
|
|
1172
|
-
BotiumError: BotiumError$
|
|
1211
|
+
BotiumError: BotiumError$6
|
|
1173
1212
|
} = BotiumError_1;
|
|
1174
1213
|
const {
|
|
1175
1214
|
DEFAULT_ASSERTERS,
|
|
@@ -1320,10 +1359,10 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1320
1359
|
|
|
1321
1360
|
const _checkUnsafe = () => {
|
|
1322
1361
|
if (!this.caps[Capabilities.SECURITY_ALLOW_UNSAFE]) {
|
|
1323
|
-
throw new BotiumError$
|
|
1362
|
+
throw new BotiumError$6('Security Error. Using unsafe component is not allowed', {
|
|
1324
1363
|
type: 'security',
|
|
1325
1364
|
subtype: 'allow unsafe',
|
|
1326
|
-
source: path__default[
|
|
1365
|
+
source: path__default["default"].basename(__filename),
|
|
1327
1366
|
cause: {
|
|
1328
1367
|
src: !!src,
|
|
1329
1368
|
ref,
|
|
@@ -1340,17 +1379,17 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1340
1379
|
try {
|
|
1341
1380
|
const CheckClass = commonjsRequire(packageName);
|
|
1342
1381
|
|
|
1343
|
-
if (isClass__default[
|
|
1382
|
+
if (isClass__default["default"](CheckClass)) {
|
|
1344
1383
|
return new CheckClass({
|
|
1345
1384
|
ref,
|
|
1346
1385
|
...this.buildScriptContext
|
|
1347
1386
|
}, this.caps, args);
|
|
1348
|
-
} else if (lodash__default[
|
|
1387
|
+
} else if (lodash__default["default"].isFunction(CheckClass)) {
|
|
1349
1388
|
return CheckClass({
|
|
1350
1389
|
ref,
|
|
1351
1390
|
...this.buildScriptContext
|
|
1352
1391
|
}, this.caps, args);
|
|
1353
|
-
} else if (isClass__default[
|
|
1392
|
+
} else if (isClass__default["default"](CheckClass.PluginClass)) {
|
|
1354
1393
|
return new CheckClass.PluginClass({
|
|
1355
1394
|
ref,
|
|
1356
1395
|
...this.buildScriptContext
|
|
@@ -1363,7 +1402,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1363
1402
|
}
|
|
1364
1403
|
}
|
|
1365
1404
|
|
|
1366
|
-
if (isClass__default[
|
|
1405
|
+
if (isClass__default["default"](src)) {
|
|
1367
1406
|
try {
|
|
1368
1407
|
const CheckClass = src;
|
|
1369
1408
|
return new CheckClass({
|
|
@@ -1375,7 +1414,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1375
1414
|
}
|
|
1376
1415
|
}
|
|
1377
1416
|
|
|
1378
|
-
if (lodash__default[
|
|
1417
|
+
if (lodash__default["default"].isFunction(src)) {
|
|
1379
1418
|
try {
|
|
1380
1419
|
return src({
|
|
1381
1420
|
ref,
|
|
@@ -1386,15 +1425,15 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1386
1425
|
}
|
|
1387
1426
|
}
|
|
1388
1427
|
|
|
1389
|
-
if (lodash__default[
|
|
1428
|
+
if (lodash__default["default"].isObject(src) && !lodash__default["default"].isString(src)) {
|
|
1390
1429
|
try {
|
|
1391
1430
|
const hookObject = Object.keys(src).reduce((result, key) => {
|
|
1392
1431
|
result[key] = args => {
|
|
1393
1432
|
const script = src[key];
|
|
1394
1433
|
|
|
1395
|
-
if (lodash__default[
|
|
1434
|
+
if (lodash__default["default"].isFunction(script)) {
|
|
1396
1435
|
return script(args);
|
|
1397
|
-
} else if (lodash__default[
|
|
1436
|
+
} else if (lodash__default["default"].isString(script)) {
|
|
1398
1437
|
try {
|
|
1399
1438
|
const vm = new NodeVM$2({
|
|
1400
1439
|
eval: false,
|
|
@@ -1418,7 +1457,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1418
1457
|
}
|
|
1419
1458
|
}
|
|
1420
1459
|
|
|
1421
|
-
if (lodash__default[
|
|
1460
|
+
if (lodash__default["default"].isString(src)) {
|
|
1422
1461
|
const loadErr = [];
|
|
1423
1462
|
const tryLoads = [{
|
|
1424
1463
|
tryLoadPackageName: src,
|
|
@@ -1449,30 +1488,35 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1449
1488
|
}
|
|
1450
1489
|
}
|
|
1451
1490
|
|
|
1452
|
-
if (isClass__default[
|
|
1491
|
+
if (isClass__default["default"](CheckClass)) {
|
|
1453
1492
|
return new CheckClass({
|
|
1454
1493
|
ref,
|
|
1455
1494
|
...this.buildScriptContext
|
|
1456
1495
|
}, this.caps, args);
|
|
1457
|
-
} else if (lodash__default[
|
|
1496
|
+
} else if (lodash__default["default"].isFunction(CheckClass)) {
|
|
1458
1497
|
return CheckClass({
|
|
1459
1498
|
ref,
|
|
1460
1499
|
...this.buildScriptContext
|
|
1461
1500
|
}, this.caps, args);
|
|
1462
|
-
} else if (isClass__default[
|
|
1501
|
+
} else if (isClass__default["default"](CheckClass.PluginClass)) {
|
|
1463
1502
|
return new CheckClass.PluginClass({
|
|
1464
1503
|
ref,
|
|
1465
1504
|
...this.buildScriptContext
|
|
1466
1505
|
}, this.caps, args);
|
|
1506
|
+
} else if (lodash__default["default"].isFunction(CheckClass.PluginClass)) {
|
|
1507
|
+
return CheckClass.PluginClass({
|
|
1508
|
+
ref,
|
|
1509
|
+
...this.buildScriptContext
|
|
1510
|
+
}, this.caps, args);
|
|
1467
1511
|
} else {
|
|
1468
1512
|
throw new Error(`${src} class or function expected`);
|
|
1469
1513
|
}
|
|
1470
1514
|
};
|
|
1471
1515
|
|
|
1472
1516
|
for (const tryLoad of tryLoads) {
|
|
1473
|
-
const tryLoadFile = path__default[
|
|
1517
|
+
const tryLoadFile = path__default["default"].resolve(process.cwd(), tryLoad.tryLoadPackageName);
|
|
1474
1518
|
|
|
1475
|
-
if (fs__default[
|
|
1519
|
+
if (fs__default["default"].existsSync(tryLoadFile)) {
|
|
1476
1520
|
_checkUnsafe();
|
|
1477
1521
|
|
|
1478
1522
|
try {
|
|
@@ -1541,7 +1585,7 @@ class BotiumMockMedia$1 {
|
|
|
1541
1585
|
|
|
1542
1586
|
prettify(indent = 0) {
|
|
1543
1587
|
const sections = [];
|
|
1544
|
-
if (this.mediaUri) sections.push(lodash__default[
|
|
1588
|
+
if (this.mediaUri) sections.push(lodash__default["default"].truncate(this.mediaUri, {
|
|
1545
1589
|
length: 200
|
|
1546
1590
|
}));
|
|
1547
1591
|
if (this.mimeType) sections.push(this.mimeType);
|
|
@@ -1561,8 +1605,8 @@ class BotiumMockButton$1 {
|
|
|
1561
1605
|
prettify(indent = 0) {
|
|
1562
1606
|
const sections = [];
|
|
1563
1607
|
if (this.text) sections.push(this.text);
|
|
1564
|
-
if (this.payload) sections.push(lodash__default[
|
|
1565
|
-
if (this.imageUri) sections.push(lodash__default[
|
|
1608
|
+
if (this.payload) sections.push(lodash__default["default"].isObject(this.payload) ? JSON.stringify(this.payload) : this.payload);
|
|
1609
|
+
if (this.imageUri) sections.push(lodash__default["default"].truncate(this.imageUri, {
|
|
1566
1610
|
length: 200
|
|
1567
1611
|
}));
|
|
1568
1612
|
return `${' '.repeat(indent)}BUTTON(${sections.join(' | ')})`;
|
|
@@ -1646,7 +1690,7 @@ BotiumMockRichMessageTypes.BotiumMockForm;
|
|
|
1646
1690
|
class BotiumMockAsserter$1 {
|
|
1647
1691
|
constructor(fromJson = {}) {
|
|
1648
1692
|
this.name = fromJson.name;
|
|
1649
|
-
this.args = lodash__default[
|
|
1693
|
+
this.args = lodash__default["default"].cloneDeep(fromJson.args);
|
|
1650
1694
|
}
|
|
1651
1695
|
|
|
1652
1696
|
}
|
|
@@ -1654,7 +1698,7 @@ class BotiumMockAsserter$1 {
|
|
|
1654
1698
|
class BotiumMockUserInput$1 {
|
|
1655
1699
|
constructor(fromJson = {}) {
|
|
1656
1700
|
this.name = fromJson.name;
|
|
1657
|
-
this.args = lodash__default[
|
|
1701
|
+
this.args = lodash__default["default"].cloneDeep(fromJson.args);
|
|
1658
1702
|
}
|
|
1659
1703
|
|
|
1660
1704
|
}
|
|
@@ -1662,7 +1706,7 @@ class BotiumMockUserInput$1 {
|
|
|
1662
1706
|
class BotiumMockLogicHook$1 {
|
|
1663
1707
|
constructor(fromJson = {}) {
|
|
1664
1708
|
this.name = fromJson.name;
|
|
1665
|
-
this.args = lodash__default[
|
|
1709
|
+
this.args = lodash__default["default"].cloneDeep(fromJson.args);
|
|
1666
1710
|
}
|
|
1667
1711
|
|
|
1668
1712
|
}
|
|
@@ -1719,10 +1763,22 @@ var BotiumMockMessage_1 = class BotiumMockMessage {
|
|
|
1719
1763
|
|
|
1720
1764
|
};
|
|
1721
1765
|
|
|
1766
|
+
var Enums = {
|
|
1767
|
+
E_SCRIPTING_MEMORY_COLUMN_MODE: {
|
|
1768
|
+
VARNAMES: 'varnames',
|
|
1769
|
+
TESTCASENAMES: 'testcasenames'
|
|
1770
|
+
}
|
|
1771
|
+
};
|
|
1772
|
+
Enums.E_SCRIPTING_MEMORY_COLUMN_MODE;
|
|
1773
|
+
|
|
1774
|
+
const {
|
|
1775
|
+
E_SCRIPTING_MEMORY_COLUMN_MODE: E_SCRIPTING_MEMORY_COLUMN_MODE$1
|
|
1776
|
+
} = Enums;
|
|
1777
|
+
|
|
1722
1778
|
const normalizeText$1 = (str, doCleanup) => {
|
|
1723
|
-
if (str && lodash__default[
|
|
1779
|
+
if (str && lodash__default["default"].isArray(str)) {
|
|
1724
1780
|
str = str.join(' ');
|
|
1725
|
-
} else if (str && !lodash__default[
|
|
1781
|
+
} else if (str && !lodash__default["default"].isString(str)) {
|
|
1726
1782
|
if (str.toString) {
|
|
1727
1783
|
str = str.toString();
|
|
1728
1784
|
} else {
|
|
@@ -1760,13 +1816,13 @@ const quoteRegexpString$2 = str => {
|
|
|
1760
1816
|
|
|
1761
1817
|
const removeBuffers$1 = obj => {
|
|
1762
1818
|
const jsonString = JSON.stringify(obj, (key, value) => {
|
|
1763
|
-
if (lodash__default[
|
|
1819
|
+
if (lodash__default["default"].isBuffer(value)) {
|
|
1764
1820
|
return '(binary data)';
|
|
1765
1821
|
} else if (value && value.type && value.type === 'Buffer') {
|
|
1766
1822
|
return '(binary data)';
|
|
1767
1823
|
} else if (key.toLowerCase() === 'base64') {
|
|
1768
1824
|
return '(base64 data)';
|
|
1769
|
-
} else if (lodash__default[
|
|
1825
|
+
} else if (lodash__default["default"].isString(value) && value.startsWith('data:')) {
|
|
1770
1826
|
return '(base64 data url)';
|
|
1771
1827
|
}
|
|
1772
1828
|
|
|
@@ -1776,10 +1832,10 @@ const removeBuffers$1 = obj => {
|
|
|
1776
1832
|
};
|
|
1777
1833
|
|
|
1778
1834
|
const toString$3 = value => {
|
|
1779
|
-
if (lodash__default[
|
|
1780
|
-
if (lodash__default[
|
|
1781
|
-
if (lodash__default[
|
|
1782
|
-
if (lodash__default[
|
|
1835
|
+
if (lodash__default["default"].isUndefined(value)) return undefined;
|
|
1836
|
+
if (lodash__default["default"].isString(value)) return value;
|
|
1837
|
+
if (lodash__default["default"].isNumber(value)) return value.toString();
|
|
1838
|
+
if (lodash__default["default"].isArray(value)) return value.map(v => toString$3(v)).join(',');
|
|
1783
1839
|
|
|
1784
1840
|
try {
|
|
1785
1841
|
return JSON.stringify(value);
|
|
@@ -1790,7 +1846,7 @@ const toString$3 = value => {
|
|
|
1790
1846
|
};
|
|
1791
1847
|
|
|
1792
1848
|
const flatString = str => {
|
|
1793
|
-
return str.split('\n').map(s => s.trim()).join(' ');
|
|
1849
|
+
return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
|
|
1794
1850
|
};
|
|
1795
1851
|
|
|
1796
1852
|
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
@@ -1810,7 +1866,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1810
1866
|
let textLinesAccepted = true;
|
|
1811
1867
|
|
|
1812
1868
|
for (const rawLine of lines) {
|
|
1813
|
-
if (lodash__default[
|
|
1869
|
+
if (lodash__default["default"].isString(rawLine)) {
|
|
1814
1870
|
let optional = false;
|
|
1815
1871
|
let not = false;
|
|
1816
1872
|
let logicLine = rawLine;
|
|
@@ -1876,13 +1932,13 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1876
1932
|
textLinesRaw = [];
|
|
1877
1933
|
}
|
|
1878
1934
|
}
|
|
1879
|
-
} else if (lodash__default[
|
|
1935
|
+
} else if (lodash__default["default"].isObject(rawLine)) {
|
|
1880
1936
|
if (rawLine.asserter) {
|
|
1881
1937
|
if (sender !== 'bot') throw new Error(`Failed to parse conversation. No asserter "${rawLine.asserter}" expected in section "${sender}"`);
|
|
1882
1938
|
if (!context.IsAsserterValid(rawLine.asserter)) throw new Error(`Failed to parse conversation. No asserter "${rawLine.asserter}" registered for section "${sender}"`);
|
|
1883
1939
|
convoStep.asserters.push({
|
|
1884
1940
|
name: rawLine.asserter,
|
|
1885
|
-
args: (rawLine.args && lodash__default[
|
|
1941
|
+
args: (rawLine.args && lodash__default["default"].isString(rawLine.args) ? [rawLine.args] : rawLine.args) || [],
|
|
1886
1942
|
not: !!rawLine.not,
|
|
1887
1943
|
optional: !!rawLine.optional
|
|
1888
1944
|
});
|
|
@@ -1891,7 +1947,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1891
1947
|
if (!context.IsLogicHookValid(logicHookName)) throw new Error(`Failed to parse conversation. No logichook "${logicHookName}" registered for section "${sender}"`);
|
|
1892
1948
|
convoStep.logicHooks.push({
|
|
1893
1949
|
name: logicHookName,
|
|
1894
|
-
args: (rawLine.args && lodash__default[
|
|
1950
|
+
args: (rawLine.args && lodash__default["default"].isString(rawLine.args) ? [rawLine.args] : rawLine.args) || []
|
|
1895
1951
|
});
|
|
1896
1952
|
} else if (rawLine.userinput || rawLine.userInput) {
|
|
1897
1953
|
const userInputName = rawLine.userinput || rawLine.userInput;
|
|
@@ -1899,7 +1955,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1899
1955
|
if (!context.IsUserInputValid(userInputName)) throw new Error(`Failed to parse conversation. No userinput "${userInputName}" registered for section "${sender}"`);
|
|
1900
1956
|
convoStep.userInputs.push({
|
|
1901
1957
|
name: userInputName,
|
|
1902
|
-
args: (rawLine.args && lodash__default[
|
|
1958
|
+
args: (rawLine.args && lodash__default["default"].isString(rawLine.args) ? [rawLine.args] : rawLine.args) || []
|
|
1903
1959
|
});
|
|
1904
1960
|
} else {
|
|
1905
1961
|
let name = Object.keys(rawLine)[0];
|
|
@@ -1926,19 +1982,19 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1926
1982
|
if (sender !== 'me' && context.IsAsserterValid(name)) {
|
|
1927
1983
|
convoStep.asserters.push({
|
|
1928
1984
|
name,
|
|
1929
|
-
args: (content && lodash__default[
|
|
1985
|
+
args: (content && lodash__default["default"].isString(content) ? [content] : content) || [],
|
|
1930
1986
|
not,
|
|
1931
1987
|
optional
|
|
1932
1988
|
});
|
|
1933
1989
|
} else if (sender === 'me' && context.IsUserInputValid(name)) {
|
|
1934
1990
|
convoStep.userInputs.push({
|
|
1935
1991
|
name,
|
|
1936
|
-
args: (content && lodash__default[
|
|
1992
|
+
args: (content && lodash__default["default"].isString(content) ? [content] : content) || []
|
|
1937
1993
|
});
|
|
1938
1994
|
} else if (context.IsLogicHookValid(name)) {
|
|
1939
1995
|
convoStep.logicHooks.push({
|
|
1940
1996
|
name,
|
|
1941
|
-
args: (content && lodash__default[
|
|
1997
|
+
args: (content && lodash__default["default"].isString(content) ? [content] : content) || []
|
|
1942
1998
|
});
|
|
1943
1999
|
} else {
|
|
1944
2000
|
throw new Error(`Failed to parse conversation. Line not recognized '${JSON.stringify(rawLine)}'`);
|
|
@@ -1974,7 +2030,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1974
2030
|
|
|
1975
2031
|
const content = textLines.join(' ');
|
|
1976
2032
|
|
|
1977
|
-
if (isJson__default[
|
|
2033
|
+
if (isJson__default["default"](content)) {
|
|
1978
2034
|
convoStep.sourceData = JSON.parse(content);
|
|
1979
2035
|
} else {
|
|
1980
2036
|
/// csv has always just 1 line, and has no eol setting
|
|
@@ -2081,9 +2137,9 @@ const convoStepToObject$1 = step => {
|
|
|
2081
2137
|
if (step.cards && step.cards.length > 0) {
|
|
2082
2138
|
step.cards.forEach(c => {
|
|
2083
2139
|
let cardTexts = [];
|
|
2084
|
-
if (c.text) cardTexts = cardTexts.concat(lodash__default[
|
|
2085
|
-
if (c.subtext) cardTexts = cardTexts.concat(lodash__default[
|
|
2086
|
-
if (c.content) cardTexts = cardTexts.concat(lodash__default[
|
|
2140
|
+
if (c.text) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.text) ? c.text : [c.text]);
|
|
2141
|
+
if (c.subtext) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2142
|
+
if (c.content) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.content) ? c.content : [c.content]);
|
|
2087
2143
|
|
|
2088
2144
|
if (cardTexts.length > 0) {
|
|
2089
2145
|
result.push({
|
|
@@ -2182,7 +2238,7 @@ const _decompileButton = b => {
|
|
|
2182
2238
|
let buttonScript = '';
|
|
2183
2239
|
|
|
2184
2240
|
if (b.payload) {
|
|
2185
|
-
buttonScript += lodash__default[
|
|
2241
|
+
buttonScript += lodash__default["default"].isObject(b.payload) ? JSON.stringify(b.payload) : flatString(b.payload);
|
|
2186
2242
|
|
|
2187
2243
|
if (b.text) {
|
|
2188
2244
|
buttonScript += `|${flatString(b.text)}`;
|
|
@@ -2221,17 +2277,17 @@ const convoStepToLines$2 = step => {
|
|
|
2221
2277
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
|
|
2222
2278
|
}
|
|
2223
2279
|
|
|
2224
|
-
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.map(b => flatString(b.text)).join('|'));
|
|
2280
|
+
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
|
|
2225
2281
|
if (step.media && step.media.length > 0) lines.push('MEDIA ' + step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri).join('|'));
|
|
2226
2282
|
|
|
2227
2283
|
if (step.cards && step.cards.length > 0) {
|
|
2228
2284
|
step.cards.forEach(c => {
|
|
2229
2285
|
let cardTexts = [];
|
|
2230
|
-
if (c.text) cardTexts = cardTexts.concat(lodash__default[
|
|
2231
|
-
if (c.subtext) cardTexts = cardTexts.concat(lodash__default[
|
|
2232
|
-
if (c.content) cardTexts = cardTexts.concat(lodash__default[
|
|
2286
|
+
if (c.text) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.text) ? c.text : [c.text]);
|
|
2287
|
+
if (c.subtext) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2288
|
+
if (c.content) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.content) ? c.content : [c.content]);
|
|
2233
2289
|
if (cardTexts.length > 0) lines.push('CARDS ' + cardTexts.map(c => flatString(c)).join('|'));
|
|
2234
|
-
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.map(b => flatString(b.text)).join('|'));
|
|
2290
|
+
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
|
|
2235
2291
|
if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
|
|
2236
2292
|
});
|
|
2237
2293
|
}
|
|
@@ -2247,6 +2303,71 @@ const convoStepToLines$2 = step => {
|
|
|
2247
2303
|
return lines.map(l => l.trim());
|
|
2248
2304
|
};
|
|
2249
2305
|
|
|
2306
|
+
const linesToScriptingMemories$2 = (lines, columnMode = null) => {
|
|
2307
|
+
const guessScriptingMemoryColumnMode = lines => {
|
|
2308
|
+
if (lines && lines.length > 1) {
|
|
2309
|
+
if (lines[1].trim().startsWith('$')) return E_SCRIPTING_MEMORY_COLUMN_MODE$1.TESTCASENAMES;
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
return E_SCRIPTING_MEMORY_COLUMN_MODE$1.VARNAMES;
|
|
2313
|
+
};
|
|
2314
|
+
|
|
2315
|
+
columnMode = columnMode || guessScriptingMemoryColumnMode(lines);
|
|
2316
|
+
const scriptingMemories = [];
|
|
2317
|
+
|
|
2318
|
+
if (columnMode === E_SCRIPTING_MEMORY_COLUMN_MODE$1.TESTCASENAMES) {
|
|
2319
|
+
const caseNames = lines[0].split('|').map(name => name.trim()).slice(1);
|
|
2320
|
+
const varNames = [];
|
|
2321
|
+
const varValues = [];
|
|
2322
|
+
|
|
2323
|
+
for (let row = 1; row < lines.length; row++) {
|
|
2324
|
+
if (!lines[row] || lines[row].length === 0) continue;
|
|
2325
|
+
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
2326
|
+
varNames.push(rawRow[0]);
|
|
2327
|
+
varValues.push(rawRow.slice(1));
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
for (let caseIndex = 0; caseIndex < caseNames.length; caseIndex++) {
|
|
2331
|
+
const caseName = caseNames[caseIndex];
|
|
2332
|
+
const values = varNames.reduce((agg, varName, varIndex) => {
|
|
2333
|
+
agg[varName] = varValues[varIndex][caseIndex] || null;
|
|
2334
|
+
return agg;
|
|
2335
|
+
}, {});
|
|
2336
|
+
const scriptingMemory = {
|
|
2337
|
+
header: {
|
|
2338
|
+
name: caseName
|
|
2339
|
+
},
|
|
2340
|
+
values: values
|
|
2341
|
+
};
|
|
2342
|
+
scriptingMemories.push(scriptingMemory);
|
|
2343
|
+
}
|
|
2344
|
+
} else {
|
|
2345
|
+
const varNames = lines[0].split('|').map(name => name.trim()).slice(1);
|
|
2346
|
+
|
|
2347
|
+
for (let row = 1; row < lines.length; row++) {
|
|
2348
|
+
if (!lines[row] || lines[row].length === 0) continue;
|
|
2349
|
+
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
2350
|
+
const caseName = rawRow[0];
|
|
2351
|
+
const values = rawRow.slice(1);
|
|
2352
|
+
const varValues = {};
|
|
2353
|
+
|
|
2354
|
+
for (let varIndex = 0; varIndex < varNames.length; varIndex++) {
|
|
2355
|
+
varValues[varNames[varIndex]] = values[varIndex];
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
const scriptingMemory = {
|
|
2359
|
+
header: {
|
|
2360
|
+
name: caseName
|
|
2361
|
+
},
|
|
2362
|
+
values: varValues
|
|
2363
|
+
};
|
|
2364
|
+
scriptingMemories.push(scriptingMemory);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
return scriptingMemories;
|
|
2369
|
+
};
|
|
2370
|
+
|
|
2250
2371
|
var helper = {
|
|
2251
2372
|
normalizeText: normalizeText$1,
|
|
2252
2373
|
splitStringInNonEmptyLines: splitStringInNonEmptyLines$1,
|
|
@@ -2259,22 +2380,23 @@ var helper = {
|
|
|
2259
2380
|
convoStepToObject: convoStepToObject$1,
|
|
2260
2381
|
validSenders: validSenders$3,
|
|
2261
2382
|
validateSender: validateSender$1,
|
|
2262
|
-
validateConvo: validateConvo$2
|
|
2383
|
+
validateConvo: validateConvo$2,
|
|
2384
|
+
linesToScriptingMemories: linesToScriptingMemories$2
|
|
2263
2385
|
};
|
|
2264
2386
|
|
|
2265
|
-
const debug$j = debug__default[
|
|
2387
|
+
const debug$j = debug__default["default"]('botium-core-ScriptingMemory');
|
|
2266
2388
|
const {
|
|
2267
2389
|
v1: uuidv1
|
|
2268
|
-
} = uuid__default[
|
|
2390
|
+
} = uuid__default["default"];
|
|
2269
2391
|
const {
|
|
2270
2392
|
NodeVM: NodeVM$1
|
|
2271
|
-
} = vm2__default[
|
|
2393
|
+
} = vm2__default["default"];
|
|
2272
2394
|
const {
|
|
2273
2395
|
quoteRegexpString: quoteRegexpString$1,
|
|
2274
2396
|
toString: toString$2
|
|
2275
2397
|
} = helper;
|
|
2276
2398
|
const {
|
|
2277
|
-
BotiumError: BotiumError$
|
|
2399
|
+
BotiumError: BotiumError$5
|
|
2278
2400
|
} = BotiumError_1; // If they got parameter, then it will be a string always.
|
|
2279
2401
|
// the receiver can decide what to do with it,
|
|
2280
2402
|
// convert to int,
|
|
@@ -2289,14 +2411,14 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2289
2411
|
return new Date().toLocaleString('en-EN');
|
|
2290
2412
|
},
|
|
2291
2413
|
$now_DE: () => {
|
|
2292
|
-
return moment__default[
|
|
2414
|
+
return moment__default["default"]().format('DD.MM.YYYY, HH:mm:ss');
|
|
2293
2415
|
},
|
|
2294
2416
|
$now_ISO: () => {
|
|
2295
2417
|
return new Date().toISOString();
|
|
2296
2418
|
},
|
|
2297
2419
|
$date: pattern => {
|
|
2298
2420
|
if (pattern) {
|
|
2299
|
-
return moment__default[
|
|
2421
|
+
return moment__default["default"]().format(pattern);
|
|
2300
2422
|
}
|
|
2301
2423
|
|
|
2302
2424
|
return new Date().toLocaleDateString();
|
|
@@ -2305,10 +2427,10 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2305
2427
|
return new Date().toLocaleDateString('en-EN');
|
|
2306
2428
|
},
|
|
2307
2429
|
$date_DE: () => {
|
|
2308
|
-
return moment__default[
|
|
2430
|
+
return moment__default["default"]().format('YYYY.MM.DD');
|
|
2309
2431
|
},
|
|
2310
2432
|
$date_ISO: () => {
|
|
2311
|
-
return moment__default[
|
|
2433
|
+
return moment__default["default"]().format('YYYY-MM-DD');
|
|
2312
2434
|
},
|
|
2313
2435
|
$time: () => {
|
|
2314
2436
|
return new Date().toLocaleTimeString();
|
|
@@ -2317,19 +2439,19 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2317
2439
|
return new Date().toLocaleTimeString('en-EN');
|
|
2318
2440
|
},
|
|
2319
2441
|
$time_DE: () => {
|
|
2320
|
-
return moment__default[
|
|
2442
|
+
return moment__default["default"]().format('HH:mm:ss');
|
|
2321
2443
|
},
|
|
2322
2444
|
$time_ISO: () => {
|
|
2323
|
-
return moment__default[
|
|
2445
|
+
return moment__default["default"]().format('HH:mm:ss');
|
|
2324
2446
|
},
|
|
2325
2447
|
$time_HH_MM: () => {
|
|
2326
|
-
return moment__default[
|
|
2448
|
+
return moment__default["default"]().format('HH:mm');
|
|
2327
2449
|
},
|
|
2328
2450
|
$time_HH: () => {
|
|
2329
|
-
return moment__default[
|
|
2451
|
+
return moment__default["default"]().format('HH');
|
|
2330
2452
|
},
|
|
2331
2453
|
$time_H_A: () => {
|
|
2332
|
-
return moment__default[
|
|
2454
|
+
return moment__default["default"]().format('h A');
|
|
2333
2455
|
},
|
|
2334
2456
|
$timestamp: () => {
|
|
2335
2457
|
return Date.now();
|
|
@@ -2338,26 +2460,26 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2338
2460
|
return new Date().getFullYear();
|
|
2339
2461
|
},
|
|
2340
2462
|
$month: () => {
|
|
2341
|
-
return moment__default[
|
|
2463
|
+
return moment__default["default"]().format('MMMM');
|
|
2342
2464
|
},
|
|
2343
2465
|
$month_MM: () => {
|
|
2344
|
-
return moment__default[
|
|
2466
|
+
return moment__default["default"]().format('MM');
|
|
2345
2467
|
},
|
|
2346
2468
|
$day_of_month: () => {
|
|
2347
2469
|
return new Date().getDate();
|
|
2348
2470
|
},
|
|
2349
2471
|
$day_of_week: () => {
|
|
2350
|
-
return moment__default[
|
|
2472
|
+
return moment__default["default"]().format('dddd');
|
|
2351
2473
|
},
|
|
2352
2474
|
$random: length => {
|
|
2353
2475
|
if (length == null) {
|
|
2354
2476
|
throw Error('random function used without args!');
|
|
2355
2477
|
}
|
|
2356
2478
|
|
|
2357
|
-
return randomatic__default[
|
|
2479
|
+
return randomatic__default["default"]('0', length);
|
|
2358
2480
|
},
|
|
2359
2481
|
$random10: () => {
|
|
2360
|
-
return randomatic__default[
|
|
2482
|
+
return randomatic__default["default"]('0', 10);
|
|
2361
2483
|
},
|
|
2362
2484
|
$uniqid: () => {
|
|
2363
2485
|
return uuidv1();
|
|
@@ -2408,7 +2530,7 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2408
2530
|
throw Error('msg function used at invalid position!');
|
|
2409
2531
|
}
|
|
2410
2532
|
|
|
2411
|
-
const root = jsonpath__default[
|
|
2533
|
+
const root = jsonpath__default["default"].query(mockMsg, jsonPath);
|
|
2412
2534
|
if (root && root.length > 0) return root[0];else return '';
|
|
2413
2535
|
},
|
|
2414
2536
|
numberOfArguments: 1
|
|
@@ -2437,16 +2559,16 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2437
2559
|
}
|
|
2438
2560
|
};
|
|
2439
2561
|
|
|
2440
|
-
const SCRIPTING_FUNCTIONS$1 = lodash__default[
|
|
2562
|
+
const SCRIPTING_FUNCTIONS$1 = lodash__default["default"].mapValues(SCRIPTING_FUNCTIONS_RAW, (funcOrStruct, name) => {
|
|
2441
2563
|
const func = funcOrStruct.handler || funcOrStruct;
|
|
2442
2564
|
const numberOfArguments = funcOrStruct.handler ? funcOrStruct.numberOfArguments || 0 : funcOrStruct.length;
|
|
2443
2565
|
return {
|
|
2444
2566
|
handler: (caps, ...rest) => {
|
|
2445
2567
|
if (!caps[Capabilities.SECURITY_ALLOW_UNSAFE] && funcOrStruct.unsafe) {
|
|
2446
|
-
throw new BotiumError$
|
|
2568
|
+
throw new BotiumError$5(`Security Error. Using unsafe scripting memory function ${name} is not allowed`, {
|
|
2447
2569
|
type: 'security',
|
|
2448
2570
|
subtype: 'allow unsafe',
|
|
2449
|
-
source: path__default[
|
|
2571
|
+
source: path__default["default"].basename(__filename),
|
|
2450
2572
|
cause: {
|
|
2451
2573
|
SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
|
|
2452
2574
|
functionName: name
|
|
@@ -2493,7 +2615,7 @@ const _apply = (scriptingMemory, str, caps, mockMsg) => {
|
|
|
2493
2615
|
|
|
2494
2616
|
for (const key of allKeys) {
|
|
2495
2617
|
// scripting memory is stronger
|
|
2496
|
-
if (lodash__default[
|
|
2618
|
+
if (lodash__default["default"].has(scriptingMemory, key)) {
|
|
2497
2619
|
const keyRegexp = new RegExp(`\\${key}`, 'g');
|
|
2498
2620
|
str = str.replace(keyRegexp, scriptingMemory[key]);
|
|
2499
2621
|
} else {
|
|
@@ -2516,11 +2638,11 @@ const _apply = (scriptingMemory, str, caps, mockMsg) => {
|
|
|
2516
2638
|
};
|
|
2517
2639
|
|
|
2518
2640
|
const extractVarNames = text => {
|
|
2519
|
-
return (lodash__default[
|
|
2641
|
+
return (lodash__default["default"].isString(text) ? text.match(/\$[A-Za-z]\w+/g) : false) || [];
|
|
2520
2642
|
};
|
|
2521
2643
|
|
|
2522
2644
|
const fill = (container, scriptingMemory, result, utterance, scriptingEvents) => {
|
|
2523
|
-
debug$j(`fill start: ${util__default[
|
|
2645
|
+
debug$j(`fill start: ${util__default["default"].inspect(scriptingMemory)}`);
|
|
2524
2646
|
let varRegex;
|
|
2525
2647
|
|
|
2526
2648
|
switch (container.caps[Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]) {
|
|
@@ -2537,17 +2659,17 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
|
|
|
2537
2659
|
break;
|
|
2538
2660
|
}
|
|
2539
2661
|
|
|
2540
|
-
if (result && lodash__default[
|
|
2662
|
+
if (result && lodash__default["default"].isString(result) && utterance && container.caps[Capabilities.SCRIPTING_ENABLE_MEMORY]) {
|
|
2541
2663
|
const utterances = scriptingEvents.resolveUtterance({
|
|
2542
2664
|
utterance
|
|
2543
2665
|
});
|
|
2544
2666
|
utterances.forEach(expected => {
|
|
2545
|
-
if (lodash__default[
|
|
2667
|
+
if (lodash__default["default"].isUndefined(expected)) return;
|
|
2546
2668
|
expected = toString$2(expected);
|
|
2547
2669
|
let reExpected = expected;
|
|
2548
2670
|
|
|
2549
2671
|
if (container.caps[Capabilities.SCRIPTING_MATCHING_MODE] !== 'regexp' && container.caps[Capabilities.SCRIPTING_MATCHING_MODE] !== 'regexpIgnoreCase') {
|
|
2550
|
-
reExpected = lodash__default[
|
|
2672
|
+
reExpected = lodash__default["default"].isString(expected) ? quoteRegexpString$1(expected).replace(/\\\$/g, '$') : expected;
|
|
2551
2673
|
}
|
|
2552
2674
|
|
|
2553
2675
|
const varMatches = extractVarNames(expected);
|
|
@@ -2571,7 +2693,7 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
|
|
|
2571
2693
|
}
|
|
2572
2694
|
}
|
|
2573
2695
|
});
|
|
2574
|
-
debug$j(`fill end: ${util__default[
|
|
2696
|
+
debug$j(`fill end: ${util__default["default"].inspect(scriptingMemory)}`);
|
|
2575
2697
|
}
|
|
2576
2698
|
};
|
|
2577
2699
|
|
|
@@ -2590,9 +2712,9 @@ ScriptingMemory.extractVarNames;
|
|
|
2590
2712
|
ScriptingMemory.RESERVED_WORDS;
|
|
2591
2713
|
ScriptingMemory.SCRIPTING_FUNCTIONS;
|
|
2592
2714
|
|
|
2593
|
-
const debug$i = debug__default[
|
|
2715
|
+
const debug$i = debug__default["default"]('botium-core-Convo');
|
|
2594
2716
|
const {
|
|
2595
|
-
BotiumError: BotiumError$
|
|
2717
|
+
BotiumError: BotiumError$4,
|
|
2596
2718
|
botiumErrorFromErr: botiumErrorFromErr$1,
|
|
2597
2719
|
botiumErrorFromList: botiumErrorFromList$1
|
|
2598
2720
|
} = BotiumError_1;
|
|
@@ -2632,7 +2754,9 @@ class ConvoStepAssert {
|
|
|
2632
2754
|
}
|
|
2633
2755
|
|
|
2634
2756
|
toString() {
|
|
2635
|
-
return (this.optional ? '?' : '') + (this.not ? '!' : '') + this.name + '(' + (this.args ? this.args.
|
|
2757
|
+
return (this.optional ? '?' : '') + (this.not ? '!' : '') + this.name + '(' + (this.args ? this.args.map(a => lodash__default["default"].truncate(a, {
|
|
2758
|
+
length: 200
|
|
2759
|
+
})).join(',') : 'no args') + ')';
|
|
2636
2760
|
}
|
|
2637
2761
|
|
|
2638
2762
|
}
|
|
@@ -2644,7 +2768,9 @@ class ConvoStepLogicHook {
|
|
|
2644
2768
|
}
|
|
2645
2769
|
|
|
2646
2770
|
toString() {
|
|
2647
|
-
return this.name + '(' + (this.args ? this.args.
|
|
2771
|
+
return this.name + '(' + (this.args ? this.args.map(a => lodash__default["default"].truncate(a, {
|
|
2772
|
+
length: 200
|
|
2773
|
+
})).join(',') : 'no args') + ')';
|
|
2648
2774
|
}
|
|
2649
2775
|
|
|
2650
2776
|
}
|
|
@@ -2656,7 +2782,9 @@ class ConvoStepUserInput {
|
|
|
2656
2782
|
}
|
|
2657
2783
|
|
|
2658
2784
|
toString() {
|
|
2659
|
-
return this.name + '(' + (this.args ? this.args.
|
|
2785
|
+
return this.name + '(' + (this.args ? this.args.map(a => lodash__default["default"].truncate(a, {
|
|
2786
|
+
length: 200
|
|
2787
|
+
})).join(',') : 'no args') + ')';
|
|
2660
2788
|
}
|
|
2661
2789
|
|
|
2662
2790
|
}
|
|
@@ -2670,9 +2798,9 @@ class ConvoStep$1 {
|
|
|
2670
2798
|
this.stepTag = fromJson.stepTag;
|
|
2671
2799
|
this.not = fromJson.not;
|
|
2672
2800
|
this.optional = fromJson.optional;
|
|
2673
|
-
this.asserters = lodash__default[
|
|
2674
|
-
this.logicHooks = lodash__default[
|
|
2675
|
-
this.userInputs = lodash__default[
|
|
2801
|
+
this.asserters = lodash__default["default"].map(fromJson.asserters, asserter => new ConvoStepAssert(asserter));
|
|
2802
|
+
this.logicHooks = lodash__default["default"].map(fromJson.logicHooks, logicHook => new ConvoStepLogicHook(logicHook));
|
|
2803
|
+
this.userInputs = lodash__default["default"].map(fromJson.userInputs, userInput => new ConvoStepUserInput(userInput));
|
|
2676
2804
|
}
|
|
2677
2805
|
|
|
2678
2806
|
hasInteraction() {
|
|
@@ -2764,8 +2892,8 @@ class Convo$6 {
|
|
|
2764
2892
|
this.context = context;
|
|
2765
2893
|
this.header = new ConvoHeader$1(fromJson.header);
|
|
2766
2894
|
|
|
2767
|
-
if (fromJson.conversation && lodash__default[
|
|
2768
|
-
this.conversation = lodash__default[
|
|
2895
|
+
if (fromJson.conversation && lodash__default["default"].isArray(fromJson.conversation)) {
|
|
2896
|
+
this.conversation = lodash__default["default"].map(fromJson.conversation, step => new ConvoStep$1(step));
|
|
2769
2897
|
} else {
|
|
2770
2898
|
this.conversation = [];
|
|
2771
2899
|
}
|
|
@@ -2805,7 +2933,7 @@ class Convo$6 {
|
|
|
2805
2933
|
}
|
|
2806
2934
|
|
|
2807
2935
|
toString() {
|
|
2808
|
-
return this.header.toString() + (this.sourceTag ? ` (${util__default[
|
|
2936
|
+
return this.header.toString() + (this.sourceTag ? ` (${util__default["default"].inspect(this.sourceTag)})` : '') + ': ' + this.conversation.map(c => c.toString()).join(' | ');
|
|
2809
2937
|
}
|
|
2810
2938
|
|
|
2811
2939
|
async Run(container) {
|
|
@@ -2986,7 +3114,7 @@ class Convo$6 {
|
|
|
2986
3114
|
});
|
|
2987
3115
|
await this._checkBotRepliesConsumed(container);
|
|
2988
3116
|
|
|
2989
|
-
const coreMsg = lodash__default[
|
|
3117
|
+
const coreMsg = lodash__default["default"].omit(removeBuffers(meMsg), ['sourceData']);
|
|
2990
3118
|
|
|
2991
3119
|
debug$i(`${this.header.name}/${convoStep.stepTag}: user says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
2992
3120
|
await new Promise(resolve => {
|
|
@@ -2999,7 +3127,7 @@ class Convo$6 {
|
|
|
2999
3127
|
lastMeConvoStep = convoStep;
|
|
3000
3128
|
transcriptStep.botBegin = new Date();
|
|
3001
3129
|
|
|
3002
|
-
if (!lodash__default[
|
|
3130
|
+
if (!lodash__default["default"].isNull(meMsg.messageText) || meMsg.sourceData || meMsg.userInputs && meMsg.userInputs.length || meMsg.logicHooks && meMsg.logicHooks.length) {
|
|
3003
3131
|
try {
|
|
3004
3132
|
Object.assign(meMsg, {
|
|
3005
3133
|
header: this.header,
|
|
@@ -3026,7 +3154,7 @@ class Convo$6 {
|
|
|
3026
3154
|
});
|
|
3027
3155
|
continue;
|
|
3028
3156
|
} else {
|
|
3029
|
-
debug$i(`${this.header.name}/${convoStep.stepTag}: message not found in #me section, message not sent to container ${util__default[
|
|
3157
|
+
debug$i(`${this.header.name}/${convoStep.stepTag}: message not found in #me section, message not sent to container ${util__default["default"].inspect(convoStep)}`);
|
|
3030
3158
|
transcriptStep.botEnd = new Date();
|
|
3031
3159
|
await this.scriptingEvents.onMeEnd({
|
|
3032
3160
|
convo: this,
|
|
@@ -3076,7 +3204,7 @@ class Convo$6 {
|
|
|
3076
3204
|
transcriptStep.botEnd = new Date();
|
|
3077
3205
|
transcriptStep.actual = new BotiumMockMessage_1(botMsg);
|
|
3078
3206
|
|
|
3079
|
-
const coreMsg = lodash__default[
|
|
3207
|
+
const coreMsg = lodash__default["default"].omit(removeBuffers(botMsg), ['sourceData']);
|
|
3080
3208
|
|
|
3081
3209
|
debug$i(`${this.header.name}: bot says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
3082
3210
|
} catch (err) {
|
|
@@ -3105,7 +3233,7 @@ class Convo$6 {
|
|
|
3105
3233
|
if (prepared) {
|
|
3106
3234
|
transcriptStep.actual = new BotiumMockMessage_1(botMsg);
|
|
3107
3235
|
|
|
3108
|
-
const coreMsg = lodash__default[
|
|
3236
|
+
const coreMsg = lodash__default["default"].omit(removeBuffers(botMsg), ['sourceData']);
|
|
3109
3237
|
|
|
3110
3238
|
debug$i(`${this.header.name}: onBotPrepare (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
3111
3239
|
}
|
|
@@ -3121,7 +3249,7 @@ class Convo$6 {
|
|
|
3121
3249
|
}
|
|
3122
3250
|
|
|
3123
3251
|
if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
|
|
3124
|
-
const failErr = new BotiumError$
|
|
3252
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
|
|
3125
3253
|
debug$i(failErr);
|
|
3126
3254
|
|
|
3127
3255
|
try {
|
|
@@ -3224,7 +3352,7 @@ class Convo$6 {
|
|
|
3224
3352
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3225
3353
|
} catch (failErr) {}
|
|
3226
3354
|
|
|
3227
|
-
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$
|
|
3355
|
+
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$4) {
|
|
3228
3356
|
assertErrors.push(err);
|
|
3229
3357
|
} else {
|
|
3230
3358
|
throw failErr;
|
|
@@ -3241,7 +3369,7 @@ class Convo$6 {
|
|
|
3241
3369
|
}
|
|
3242
3370
|
}
|
|
3243
3371
|
} else {
|
|
3244
|
-
const failErr = new BotiumError$
|
|
3372
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util__default["default"].inspect(convoStep.sender)}`);
|
|
3245
3373
|
debug$i(failErr);
|
|
3246
3374
|
|
|
3247
3375
|
try {
|
|
@@ -3252,7 +3380,7 @@ class Convo$6 {
|
|
|
3252
3380
|
}
|
|
3253
3381
|
} catch (err) {
|
|
3254
3382
|
if (lastMeConvoStep) {
|
|
3255
|
-
if (err instanceof BotiumError$
|
|
3383
|
+
if (err instanceof BotiumError$4 && err.context) {
|
|
3256
3384
|
err.context.input = new ConvoStep$1(lastMeConvoStep);
|
|
3257
3385
|
err.context.transcript = [...transcriptSteps, { ...transcriptStep
|
|
3258
3386
|
}];
|
|
@@ -3264,7 +3392,14 @@ class Convo$6 {
|
|
|
3264
3392
|
}
|
|
3265
3393
|
|
|
3266
3394
|
transcriptStep.err = err;
|
|
3267
|
-
|
|
3395
|
+
|
|
3396
|
+
if (err instanceof BotiumError$4 && container.caps[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]) {
|
|
3397
|
+
if (!err.isAsserterError()) {
|
|
3398
|
+
throw err;
|
|
3399
|
+
}
|
|
3400
|
+
} else {
|
|
3401
|
+
throw err;
|
|
3402
|
+
}
|
|
3268
3403
|
} finally {
|
|
3269
3404
|
if (convoStep.sender !== 'begin' && convoStep.sender !== 'end' && !skipTranscriptStep) {
|
|
3270
3405
|
transcriptStep.scriptingMemory = Object.assign({}, scriptingMemory);
|
|
@@ -3279,30 +3414,38 @@ class Convo$6 {
|
|
|
3279
3414
|
transcript.steps = transcriptSteps.filter(s => s);
|
|
3280
3415
|
transcript.scriptingMemory = scriptingMemory;
|
|
3281
3416
|
transcript.convoEnd = new Date();
|
|
3417
|
+
|
|
3418
|
+
if (container.caps[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]) {
|
|
3419
|
+
const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
|
|
3420
|
+
|
|
3421
|
+
if (transcriptStepErrs && transcriptStepErrs.length > 0) {
|
|
3422
|
+
transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3282
3425
|
}
|
|
3283
3426
|
}
|
|
3284
3427
|
|
|
3285
3428
|
_compareObject(container, scriptingMemory, convoStep, result, expected, botMsg) {
|
|
3286
3429
|
if (expected === null || expected === undefined) return;
|
|
3287
3430
|
|
|
3288
|
-
if (lodash__default[
|
|
3289
|
-
if (!lodash__default[
|
|
3290
|
-
throw new BotiumError$
|
|
3431
|
+
if (lodash__default["default"].isArray(expected)) {
|
|
3432
|
+
if (!lodash__default["default"].isArray(result)) {
|
|
3433
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array, got "${result}"`);
|
|
3291
3434
|
}
|
|
3292
3435
|
|
|
3293
3436
|
if (expected.length !== result.length) {
|
|
3294
|
-
throw new BotiumError$
|
|
3437
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array length ${expected.length}, got ${result.length}`);
|
|
3295
3438
|
}
|
|
3296
3439
|
|
|
3297
3440
|
for (let i = 0; i < expected.length; i++) {
|
|
3298
3441
|
this._compareObject(container, scriptingMemory, convoStep, result[i], expected[i]);
|
|
3299
3442
|
}
|
|
3300
|
-
} else if (lodash__default[
|
|
3301
|
-
lodash__default[
|
|
3443
|
+
} else if (lodash__default["default"].isObject(expected)) {
|
|
3444
|
+
lodash__default["default"].forOwn(expected, (value, key) => {
|
|
3302
3445
|
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
3303
3446
|
this._compareObject(container, scriptingMemory, convoStep, result[key], expected[key]);
|
|
3304
3447
|
} else {
|
|
3305
|
-
throw new BotiumError$
|
|
3448
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response "${result}" missing expected property: ${key}`);
|
|
3306
3449
|
}
|
|
3307
3450
|
});
|
|
3308
3451
|
} else {
|
|
@@ -3350,7 +3493,7 @@ class Convo$6 {
|
|
|
3350
3493
|
utterance
|
|
3351
3494
|
});
|
|
3352
3495
|
return utterances.reduce((acc, expected) => {
|
|
3353
|
-
if (lodash__default[
|
|
3496
|
+
if (lodash__default["default"].isUndefined(expected)) return acc;else return acc.concat(ScriptingMemory.extractVarNames(toString$1(expected)) || []);
|
|
3354
3497
|
}, []);
|
|
3355
3498
|
}
|
|
3356
3499
|
|
|
@@ -3430,17 +3573,17 @@ class Convo$6 {
|
|
|
3430
3573
|
const alreadyThereAt = parentPConvos.indexOf(includeLogicHook);
|
|
3431
3574
|
|
|
3432
3575
|
if (alreadyThereAt >= 0) {
|
|
3433
|
-
throw new BotiumError$
|
|
3576
|
+
throw new BotiumError$4(`Partial convos are included circular. "${includeLogicHook}" is referenced by "/${parentPConvos.slice(0, alreadyThereAt).join('/')}" and by "/${parentPConvos.join('/')}" `);
|
|
3434
3577
|
}
|
|
3435
3578
|
|
|
3436
3579
|
if (!partialConvos || Object.keys(partialConvos).length === 0) {
|
|
3437
|
-
throw new BotiumError$
|
|
3580
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (There are no partial convos)`);
|
|
3438
3581
|
}
|
|
3439
3582
|
|
|
3440
3583
|
const partialConvo = partialConvos[includeLogicHook];
|
|
3441
3584
|
|
|
3442
3585
|
if (!partialConvo) {
|
|
3443
|
-
throw new BotiumError$
|
|
3586
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
|
|
3444
3587
|
}
|
|
3445
3588
|
|
|
3446
3589
|
_getEffectiveConversationRecursive(partialConvo.conversation, [...parentPConvos, includeLogicHook], result, true);
|
|
@@ -3473,11 +3616,11 @@ var RetryHelper_1 = class RetryHelper {
|
|
|
3473
3616
|
const onErrorRegexp = caps[`RETRY_${section.toUpperCase()}_ONERROR_REGEXP`] || [];
|
|
3474
3617
|
|
|
3475
3618
|
if (onErrorRegexp) {
|
|
3476
|
-
if (lodash__default[
|
|
3619
|
+
if (lodash__default["default"].isArray(onErrorRegexp)) {
|
|
3477
3620
|
onErrorRegexp.forEach(r => {
|
|
3478
|
-
if (lodash__default[
|
|
3621
|
+
if (lodash__default["default"].isString(r)) this.retryErrorPatterns.push(new RegExp(r, 'i'));else this.retryErrorPatterns.push(r);
|
|
3479
3622
|
});
|
|
3480
|
-
} else if (lodash__default[
|
|
3623
|
+
} else if (lodash__default["default"].isString(onErrorRegexp)) {
|
|
3481
3624
|
this.retryErrorPatterns.push(new RegExp(onErrorRegexp, 'i'));
|
|
3482
3625
|
} else {
|
|
3483
3626
|
this.retryErrorPatterns.push(onErrorRegexp);
|
|
@@ -3487,7 +3630,7 @@ var RetryHelper_1 = class RetryHelper {
|
|
|
3487
3630
|
|
|
3488
3631
|
shouldRetry(err) {
|
|
3489
3632
|
if (!err || this.retryErrorPatterns.length === 0) return false;
|
|
3490
|
-
const errString = util__default[
|
|
3633
|
+
const errString = util__default["default"].inspect(err);
|
|
3491
3634
|
|
|
3492
3635
|
for (const re of this.retryErrorPatterns) {
|
|
3493
3636
|
if (errString.match(re)) return true;
|
|
@@ -3504,9 +3647,9 @@ const {
|
|
|
3504
3647
|
} = helper;
|
|
3505
3648
|
|
|
3506
3649
|
const _normalize = botresponse => {
|
|
3507
|
-
if (lodash__default[
|
|
3650
|
+
if (lodash__default["default"].isUndefined(botresponse)) return '';
|
|
3508
3651
|
|
|
3509
|
-
if (lodash__default[
|
|
3652
|
+
if (lodash__default["default"].isObject(botresponse) && lodash__default["default"].has(botresponse, 'messageText')) {
|
|
3510
3653
|
return toString(botresponse.messageText) || '';
|
|
3511
3654
|
}
|
|
3512
3655
|
|
|
@@ -3514,7 +3657,7 @@ const _normalize = botresponse => {
|
|
|
3514
3657
|
};
|
|
3515
3658
|
|
|
3516
3659
|
const regexp = ignoreCase => (botresponse, utterance) => {
|
|
3517
|
-
if (lodash__default[
|
|
3660
|
+
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3518
3661
|
utterance = toString(utterance);
|
|
3519
3662
|
botresponse = _normalize(botresponse);
|
|
3520
3663
|
const regexp = ignoreCase ? new RegExp(utterance, 'i') : new RegExp(utterance, '');
|
|
@@ -3522,7 +3665,7 @@ const regexp = ignoreCase => (botresponse, utterance) => {
|
|
|
3522
3665
|
};
|
|
3523
3666
|
|
|
3524
3667
|
const wildcard = ignoreCase => (botresponse, utterance) => {
|
|
3525
|
-
if (lodash__default[
|
|
3668
|
+
if (lodash__default["default"].isUndefined(botresponse)) {
|
|
3526
3669
|
if (utterance.trim() === '*') return true;else return false;
|
|
3527
3670
|
}
|
|
3528
3671
|
|
|
@@ -3539,8 +3682,26 @@ const wildcard = ignoreCase => (botresponse, utterance) => {
|
|
|
3539
3682
|
return regexp.test(botresponse);
|
|
3540
3683
|
};
|
|
3541
3684
|
|
|
3685
|
+
const wildcardExact = ignoreCase => (botresponse, utterance) => {
|
|
3686
|
+
if (lodash__default["default"].isUndefined(botresponse)) {
|
|
3687
|
+
if (utterance.trim() === '*') return true;else return false;
|
|
3688
|
+
}
|
|
3689
|
+
|
|
3690
|
+
utterance = toString(utterance);
|
|
3691
|
+
botresponse = _normalize(botresponse);
|
|
3692
|
+
const numWildcards = utterance.split('*').length - 1;
|
|
3693
|
+
|
|
3694
|
+
if (numWildcards > 10) {
|
|
3695
|
+
throw new Error('Maximum number of 10 wildcards supported.');
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
const utteranceRe = '^' + quoteRegexpString(utterance).replace(/\\\*/g, '(.*)') + '$';
|
|
3699
|
+
const regexp = ignoreCase ? new RegExp(utteranceRe, 'i') : new RegExp(utteranceRe, '');
|
|
3700
|
+
return regexp.test(botresponse);
|
|
3701
|
+
};
|
|
3702
|
+
|
|
3542
3703
|
const include = ignoreCase => (botresponse, utterance) => {
|
|
3543
|
-
if (lodash__default[
|
|
3704
|
+
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3544
3705
|
utterance = toString(utterance);
|
|
3545
3706
|
botresponse = _normalize(botresponse);
|
|
3546
3707
|
|
|
@@ -3553,7 +3714,7 @@ const include = ignoreCase => (botresponse, utterance) => {
|
|
|
3553
3714
|
};
|
|
3554
3715
|
|
|
3555
3716
|
const equals = ignoreCase => (botresponse, utterance) => {
|
|
3556
|
-
if (lodash__default[
|
|
3717
|
+
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3557
3718
|
utterance = toString(utterance);
|
|
3558
3719
|
botresponse = _normalize(botresponse);
|
|
3559
3720
|
|
|
@@ -3570,6 +3731,8 @@ const getMatchFunction$1 = matchingMode => {
|
|
|
3570
3731
|
return regexp(matchingMode === 'regexpIgnoreCase');
|
|
3571
3732
|
} else if (matchingMode === 'wildcard' || matchingMode === 'wildcardIgnoreCase' || matchingMode === 'wildcardLowerCase') {
|
|
3572
3733
|
return wildcard(matchingMode === 'wildcardIgnoreCase' || matchingMode === 'wildcardLowerCase');
|
|
3734
|
+
} else if (matchingMode === 'wildcardExact' || matchingMode === 'wildcardExactIgnoreCase') {
|
|
3735
|
+
return wildcardExact(matchingMode === 'wildcardExactIgnoreCase');
|
|
3573
3736
|
} else if (matchingMode === 'include' || matchingMode === 'includeIgnoreCase' || matchingMode === 'includeLowerCase') {
|
|
3574
3737
|
return include(matchingMode === 'includeIgnoreCase' || matchingMode === 'includeLowerCase');
|
|
3575
3738
|
} else if (matchingMode === 'equals' || matchingMode === 'equalsIgnoreCase') {
|
|
@@ -3582,6 +3745,7 @@ const getMatchFunction$1 = matchingMode => {
|
|
|
3582
3745
|
var MatchFunctions = {
|
|
3583
3746
|
regexp,
|
|
3584
3747
|
wildcard,
|
|
3748
|
+
wildcardExact,
|
|
3585
3749
|
include,
|
|
3586
3750
|
equals,
|
|
3587
3751
|
getMatchFunction: getMatchFunction$1
|
|
@@ -3606,7 +3770,7 @@ const isStringJson = string => {
|
|
|
3606
3770
|
|
|
3607
3771
|
|
|
3608
3772
|
const isJsonObject$1 = (json, stringIsJson = true) => {
|
|
3609
|
-
if (!stringIsJson && lodash__default[
|
|
3773
|
+
if (!stringIsJson && lodash__default["default"].isString(json)) {
|
|
3610
3774
|
return false;
|
|
3611
3775
|
}
|
|
3612
3776
|
|
|
@@ -3649,7 +3813,7 @@ const optionalJson = json => {
|
|
|
3649
3813
|
};
|
|
3650
3814
|
|
|
3651
3815
|
const shortenJsonString = obj => {
|
|
3652
|
-
let str = lodash__default[
|
|
3816
|
+
let str = lodash__default["default"].isString(obj) ? obj : JSON.stringify(obj, null, 2);
|
|
3653
3817
|
const length = str.length;
|
|
3654
3818
|
|
|
3655
3819
|
if (length > 1000) {
|
|
@@ -3711,7 +3875,7 @@ var Utils = {
|
|
|
3711
3875
|
};
|
|
3712
3876
|
|
|
3713
3877
|
const _ensureList = queryResult => {
|
|
3714
|
-
if (lodash__default[
|
|
3878
|
+
if (lodash__default["default"].isArray(queryResult)) {
|
|
3715
3879
|
return queryResult;
|
|
3716
3880
|
}
|
|
3717
3881
|
|
|
@@ -3729,7 +3893,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3729
3893
|
const utterancesJsonpath = options.UTTERANCES_JSONPATH;
|
|
3730
3894
|
let scriptData = scriptBuffer;
|
|
3731
3895
|
|
|
3732
|
-
if (lodash__default[
|
|
3896
|
+
if (lodash__default["default"].isString(scriptData)) {
|
|
3733
3897
|
try {
|
|
3734
3898
|
scriptData = JSON.parse(scriptData);
|
|
3735
3899
|
} catch (err) {
|
|
@@ -3738,7 +3902,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3738
3902
|
}
|
|
3739
3903
|
|
|
3740
3904
|
if (checkerJsonpath) {
|
|
3741
|
-
const scouldExist = jsonpath__default[
|
|
3905
|
+
const scouldExist = jsonpath__default["default"].query(scriptData, checkerJsonpath);
|
|
3742
3906
|
|
|
3743
3907
|
if (!scouldExist || scouldExist.length === 0) {
|
|
3744
3908
|
return;
|
|
@@ -3751,7 +3915,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3751
3915
|
let rootObjects;
|
|
3752
3916
|
|
|
3753
3917
|
try {
|
|
3754
|
-
rootObjects = _ensureList(jsonpath__default[
|
|
3918
|
+
rootObjects = _ensureList(jsonpath__default["default"].query(scriptData, rootJsonpath));
|
|
3755
3919
|
} catch (err) {
|
|
3756
3920
|
throw new Error(`Root jsonpath ${rootJsonpath} invalid: ${err.message}`);
|
|
3757
3921
|
}
|
|
@@ -3765,7 +3929,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3765
3929
|
let intent;
|
|
3766
3930
|
|
|
3767
3931
|
try {
|
|
3768
|
-
intent = _ensureList(jsonpath__default[
|
|
3932
|
+
intent = _ensureList(jsonpath__default["default"].query(json, utteranceRefsJsonpath));
|
|
3769
3933
|
} catch (err) {
|
|
3770
3934
|
throw new Error(`Intents jsonpath ${utteranceRefsJsonpath} invalid: ${err.message}`);
|
|
3771
3935
|
}
|
|
@@ -3779,7 +3943,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3779
3943
|
}
|
|
3780
3944
|
|
|
3781
3945
|
try {
|
|
3782
|
-
result[intent] = result[intent].concat(jsonpath__default[
|
|
3946
|
+
result[intent] = result[intent].concat(jsonpath__default["default"].query(json, utterancesJsonpath));
|
|
3783
3947
|
} catch (err) {
|
|
3784
3948
|
throw new Error(`Utterances jsonpath ${utteranceRefsJsonpath} invalid: ${err.message}`);
|
|
3785
3949
|
}
|
|
@@ -3798,10 +3962,10 @@ var JsonToJson = {
|
|
|
3798
3962
|
|
|
3799
3963
|
const {
|
|
3800
3964
|
NodeVM
|
|
3801
|
-
} = vm2__default[
|
|
3802
|
-
const debug$h = debug__default[
|
|
3965
|
+
} = vm2__default["default"];
|
|
3966
|
+
const debug$h = debug__default["default"]('botium-core-HookUtils');
|
|
3803
3967
|
const {
|
|
3804
|
-
BotiumError: BotiumError$
|
|
3968
|
+
BotiumError: BotiumError$3
|
|
3805
3969
|
} = BotiumError_1;
|
|
3806
3970
|
|
|
3807
3971
|
const executeHook$2 = async (caps, hook, args) => {
|
|
@@ -3813,7 +3977,7 @@ const executeHookSync$1 = (caps, hook, args) => {
|
|
|
3813
3977
|
return;
|
|
3814
3978
|
}
|
|
3815
3979
|
|
|
3816
|
-
if (lodash__default[
|
|
3980
|
+
if (lodash__default["default"].isFunction(hook)) {
|
|
3817
3981
|
try {
|
|
3818
3982
|
return hook(args);
|
|
3819
3983
|
} catch (err) {
|
|
@@ -3821,7 +3985,7 @@ const executeHookSync$1 = (caps, hook, args) => {
|
|
|
3821
3985
|
}
|
|
3822
3986
|
}
|
|
3823
3987
|
|
|
3824
|
-
if (lodash__default[
|
|
3988
|
+
if (lodash__default["default"].isString(hook)) {
|
|
3825
3989
|
try {
|
|
3826
3990
|
const vm = new NodeVM({
|
|
3827
3991
|
eval: false,
|
|
@@ -3830,7 +3994,7 @@ const executeHookSync$1 = (caps, hook, args) => {
|
|
|
3830
3994
|
});
|
|
3831
3995
|
const r = vm.run(hook);
|
|
3832
3996
|
|
|
3833
|
-
if (lodash__default[
|
|
3997
|
+
if (lodash__default["default"].isFunction(r)) {
|
|
3834
3998
|
return r(args);
|
|
3835
3999
|
} else {
|
|
3836
4000
|
return r;
|
|
@@ -3850,16 +4014,16 @@ const getHook$3 = (caps, data) => {
|
|
|
3850
4014
|
|
|
3851
4015
|
const allowUnsafe = !!caps[Capabilities.SECURITY_ALLOW_UNSAFE];
|
|
3852
4016
|
|
|
3853
|
-
if (lodash__default[
|
|
4017
|
+
if (lodash__default["default"].isFunction(data)) {
|
|
3854
4018
|
debug$h('found hook, type: function definition');
|
|
3855
4019
|
return data;
|
|
3856
4020
|
}
|
|
3857
4021
|
|
|
3858
|
-
if (lodash__default[
|
|
4022
|
+
if (lodash__default["default"].isString(data)) {
|
|
3859
4023
|
let resultWithRequire;
|
|
3860
|
-
let tryLoadFile = path__default[
|
|
4024
|
+
let tryLoadFile = path__default["default"].resolve(process.cwd(), data);
|
|
3861
4025
|
|
|
3862
|
-
if (fs__default[
|
|
4026
|
+
if (fs__default["default"].existsSync(tryLoadFile)) {
|
|
3863
4027
|
try {
|
|
3864
4028
|
resultWithRequire = commonjsRequire(tryLoadFile);
|
|
3865
4029
|
} catch (err) {}
|
|
@@ -3873,10 +4037,10 @@ const getHook$3 = (caps, data) => {
|
|
|
3873
4037
|
|
|
3874
4038
|
if (resultWithRequire) {
|
|
3875
4039
|
if (!allowUnsafe) {
|
|
3876
|
-
throw new BotiumError$
|
|
4040
|
+
throw new BotiumError$3('Security Error. Using unsafe custom hook with require is not allowed', {
|
|
3877
4041
|
type: 'security',
|
|
3878
4042
|
subtype: 'allow unsafe',
|
|
3879
|
-
source: path__default[
|
|
4043
|
+
source: path__default["default"].basename(__filename),
|
|
3880
4044
|
cause: {
|
|
3881
4045
|
SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
|
|
3882
4046
|
hookData: data
|
|
@@ -3884,7 +4048,7 @@ const getHook$3 = (caps, data) => {
|
|
|
3884
4048
|
});
|
|
3885
4049
|
}
|
|
3886
4050
|
|
|
3887
|
-
if (lodash__default[
|
|
4051
|
+
if (lodash__default["default"].isFunction(resultWithRequire)) {
|
|
3888
4052
|
debug$h(`found hook, type: require, in ${tryLoadFile}`);
|
|
3889
4053
|
return resultWithRequire;
|
|
3890
4054
|
} else {
|
|
@@ -3893,16 +4057,16 @@ const getHook$3 = (caps, data) => {
|
|
|
3893
4057
|
}
|
|
3894
4058
|
|
|
3895
4059
|
try {
|
|
3896
|
-
esprima__default[
|
|
4060
|
+
esprima__default["default"].parseScript(data);
|
|
3897
4061
|
} catch (err) {
|
|
3898
|
-
throw new Error(`Cant load hook, syntax is not valid - ${util__default[
|
|
4062
|
+
throw new Error(`Cant load hook, syntax is not valid - ${util__default["default"].inspect(err)}`);
|
|
3899
4063
|
}
|
|
3900
4064
|
|
|
3901
4065
|
debug$h('Found hook, type: JavaScript as String');
|
|
3902
4066
|
return data;
|
|
3903
4067
|
}
|
|
3904
4068
|
|
|
3905
|
-
throw new Error(`Not valid hook ${util__default[
|
|
4069
|
+
throw new Error(`Not valid hook ${util__default["default"].inspect(data)}`);
|
|
3906
4070
|
};
|
|
3907
4071
|
|
|
3908
4072
|
var HookUtils = {
|
|
@@ -3924,7 +4088,7 @@ var precompile$1 = (caps, scriptBuffer, options, filename) => {
|
|
|
3924
4088
|
throw new Error('Script is not defined');
|
|
3925
4089
|
}
|
|
3926
4090
|
|
|
3927
|
-
if (lodash__default[
|
|
4091
|
+
if (lodash__default["default"].isString(scriptBuffer)) {
|
|
3928
4092
|
try {
|
|
3929
4093
|
scriptBuffer = JSON.parse(scriptBuffer);
|
|
3930
4094
|
} catch (err) {}
|
|
@@ -3949,7 +4113,7 @@ var Script = {
|
|
|
3949
4113
|
precompile: precompile$1
|
|
3950
4114
|
};
|
|
3951
4115
|
|
|
3952
|
-
const debug$g = debug__default[
|
|
4116
|
+
const debug$g = debug__default["default"]('botium-core-PrecompilerMarkdownRasa');
|
|
3953
4117
|
const htmlCommentRegexp = /(<!--.*?-->)/g;
|
|
3954
4118
|
|
|
3955
4119
|
var precompile = (caps, scriptBuffer, options, filename) => {
|
|
@@ -3957,7 +4121,7 @@ var precompile = (caps, scriptBuffer, options, filename) => {
|
|
|
3957
4121
|
return;
|
|
3958
4122
|
}
|
|
3959
4123
|
|
|
3960
|
-
const md = new markdownIt__default[
|
|
4124
|
+
const md = new markdownIt__default["default"]();
|
|
3961
4125
|
const parsed = md.parse(scriptBuffer, {});
|
|
3962
4126
|
|
|
3963
4127
|
const _extractFromRasaIntent = content => {
|
|
@@ -4041,7 +4205,7 @@ var precompile = (caps, scriptBuffer, options, filename) => {
|
|
|
4041
4205
|
if (!intent) {
|
|
4042
4206
|
debug$g(`Intent not found, dropping me texts ${JSON.stringify(meTexts)}`);
|
|
4043
4207
|
} else {
|
|
4044
|
-
meTexts = lodash__default[
|
|
4208
|
+
meTexts = lodash__default["default"].uniq(meTexts);
|
|
4045
4209
|
utterances[intent] = meTexts;
|
|
4046
4210
|
}
|
|
4047
4211
|
}
|
|
@@ -4049,7 +4213,7 @@ var precompile = (caps, scriptBuffer, options, filename) => {
|
|
|
4049
4213
|
intent = null;
|
|
4050
4214
|
meTexts = [];
|
|
4051
4215
|
} else {
|
|
4052
|
-
debug$g(`Markdown entry ignored ${util__default[
|
|
4216
|
+
debug$g(`Markdown entry ignored ${util__default["default"].inspect(entry)}`);
|
|
4053
4217
|
}
|
|
4054
4218
|
}
|
|
4055
4219
|
|
|
@@ -4065,7 +4229,7 @@ var MarkdownRasa = {
|
|
|
4065
4229
|
precompile: precompile
|
|
4066
4230
|
};
|
|
4067
4231
|
|
|
4068
|
-
const debug$f = debug__default[
|
|
4232
|
+
const debug$f = debug__default["default"]('botium-core-CapabilitiesUtils');
|
|
4069
4233
|
const {
|
|
4070
4234
|
toJsonWeak
|
|
4071
4235
|
} = Utils;
|
|
@@ -4073,16 +4237,16 @@ const {
|
|
|
4073
4237
|
var getAllCapValues$1 = (capNamePrefix, caps) => {
|
|
4074
4238
|
const allCapValues = [];
|
|
4075
4239
|
|
|
4076
|
-
const jsonPathCaps = lodash__default[
|
|
4240
|
+
const jsonPathCaps = lodash__default["default"].pickBy(caps, (v, k) => k.startsWith(capNamePrefix));
|
|
4077
4241
|
|
|
4078
|
-
lodash__default[
|
|
4079
|
-
const val = lodash__default[
|
|
4242
|
+
lodash__default["default"](jsonPathCaps).keys().sort().each(key => {
|
|
4243
|
+
const val = lodash__default["default"].isFunction(caps[key]) ? caps[key]() : caps[key];
|
|
4080
4244
|
|
|
4081
|
-
if (lodash__default[
|
|
4245
|
+
if (lodash__default["default"].isArray(val)) {
|
|
4082
4246
|
val.forEach(p => {
|
|
4083
4247
|
allCapValues.push(`${p}`.trim());
|
|
4084
4248
|
});
|
|
4085
|
-
} else if (lodash__default[
|
|
4249
|
+
} else if (lodash__default["default"].isString(val)) {
|
|
4086
4250
|
val.split(',').forEach(p => {
|
|
4087
4251
|
allCapValues.push(p.trim());
|
|
4088
4252
|
});
|
|
@@ -4115,7 +4279,7 @@ var flatCababilities$1 = (caps, prefix) => {
|
|
|
4115
4279
|
if (capNames.length === 1 && capNames[0] === prefix) {
|
|
4116
4280
|
const val = toJsonWeak(caps[capNames[0]]);
|
|
4117
4281
|
|
|
4118
|
-
if (lodash__default[
|
|
4282
|
+
if (lodash__default["default"].isArray(val)) {
|
|
4119
4283
|
val.forEach(entry => result.push(entry));
|
|
4120
4284
|
} else {
|
|
4121
4285
|
result.push(val);
|
|
@@ -4177,7 +4341,7 @@ var CapabilitiesUtils = {
|
|
|
4177
4341
|
flatCababilities: flatCababilities$1
|
|
4178
4342
|
};
|
|
4179
4343
|
|
|
4180
|
-
const debug$e = debug__default[
|
|
4344
|
+
const debug$e = debug__default["default"]('botium-core-Precompilers');
|
|
4181
4345
|
const {
|
|
4182
4346
|
isJsonObject
|
|
4183
4347
|
} = Utils;
|
|
@@ -4204,14 +4368,14 @@ var execute = (scriptBuffer, options) => {
|
|
|
4204
4368
|
|
|
4205
4369
|
for (const capSuffixAndVal of ownCaps) {
|
|
4206
4370
|
if (!capSuffixAndVal.NAME) {
|
|
4207
|
-
debug$e(`Precompiler name not defined in ${util__default[
|
|
4371
|
+
debug$e(`Precompiler name not defined in ${util__default["default"].inspect(capSuffixAndVal)}`);
|
|
4208
4372
|
return null;
|
|
4209
4373
|
}
|
|
4210
4374
|
|
|
4211
4375
|
const provider = PROVIDERS[capSuffixAndVal.NAME];
|
|
4212
4376
|
|
|
4213
4377
|
if (!provider) {
|
|
4214
|
-
throw new Error(`Precompiler ${util__default[
|
|
4378
|
+
throw new Error(`Precompiler ${util__default["default"].inspect(capSuffixAndVal.NAME)} not found using caps ${util__default["default"].inspect(capSuffixAndVal)}`);
|
|
4215
4379
|
}
|
|
4216
4380
|
|
|
4217
4381
|
const result = provider.precompile(caps, scriptBuffer, capSuffixAndVal, filename);
|
|
@@ -4289,7 +4453,7 @@ var CompilerBase_1 = class CompilerBase {
|
|
|
4289
4453
|
}
|
|
4290
4454
|
|
|
4291
4455
|
_GetOptionalCapability(cap, def = null) {
|
|
4292
|
-
if (lodash__default[
|
|
4456
|
+
if (lodash__default["default"].isUndefined(this.caps[cap])) {
|
|
4293
4457
|
return def;
|
|
4294
4458
|
}
|
|
4295
4459
|
|
|
@@ -4314,7 +4478,7 @@ var Utterance_1 = class Utterance {
|
|
|
4314
4478
|
this.sourceTag = fromJson.sourceTag;
|
|
4315
4479
|
this.utterances = [];
|
|
4316
4480
|
|
|
4317
|
-
if (fromJson.utterances && lodash__default[
|
|
4481
|
+
if (fromJson.utterances && lodash__default["default"].isArray(fromJson.utterances)) {
|
|
4318
4482
|
this.utterances = fromJson.utterances;
|
|
4319
4483
|
} else if (fromJson.utterances) {
|
|
4320
4484
|
this.utterances.push(fromJson.utterances);
|
|
@@ -4322,12 +4486,15 @@ var Utterance_1 = class Utterance {
|
|
|
4322
4486
|
}
|
|
4323
4487
|
|
|
4324
4488
|
toString() {
|
|
4325
|
-
return this.name + (this.sourceTag ? ` (${util__default[
|
|
4489
|
+
return this.name + (this.sourceTag ? ` (${util__default["default"].inspect(this.sourceTag)})` : '') + ': ' + this.utterances.join('|');
|
|
4326
4490
|
}
|
|
4327
4491
|
|
|
4328
4492
|
};
|
|
4329
4493
|
|
|
4330
|
-
const debug$d = debug__default[
|
|
4494
|
+
const debug$d = debug__default["default"]('botium-core-CompilerXlsx');
|
|
4495
|
+
const {
|
|
4496
|
+
E_SCRIPTING_MEMORY_COLUMN_MODE
|
|
4497
|
+
} = Enums;
|
|
4331
4498
|
const {
|
|
4332
4499
|
Convo: Convo$5
|
|
4333
4500
|
} = Convo_1;
|
|
@@ -4356,7 +4523,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4356
4523
|
super.Validate();
|
|
4357
4524
|
|
|
4358
4525
|
if (this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL] !== undefined) {
|
|
4359
|
-
if (lodash__default[
|
|
4526
|
+
if (lodash__default["default"].isString(this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]) && this.colnames.findIndex(c => c === this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]) < 0) {
|
|
4360
4527
|
throw new Error(`SCRIPTING_XLSX_STARTCOL ${this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]} invalid (A-Z)`);
|
|
4361
4528
|
} else if (this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL] < 1 || this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL] > this.colnames.length) {
|
|
4362
4529
|
throw new Error(`SCRIPTING_XLSX_STARTCOL ${this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]} invalid (1-${this.colnames.length})`);
|
|
@@ -4365,7 +4532,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4365
4532
|
}
|
|
4366
4533
|
|
|
4367
4534
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
4368
|
-
const workbook = xlsx__default[
|
|
4535
|
+
const workbook = xlsx__default["default"].read(scriptBuffer, {
|
|
4369
4536
|
type: 'buffer'
|
|
4370
4537
|
});
|
|
4371
4538
|
if (!workbook) throw new Error('Workbook not readable');
|
|
@@ -4402,7 +4569,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4402
4569
|
throw Error(`Invalid script type ${scriptType}`);
|
|
4403
4570
|
}
|
|
4404
4571
|
|
|
4405
|
-
debug$d(`sheet names for ${scriptType}: ${util__default[
|
|
4572
|
+
debug$d(`sheet names for ${scriptType}: ${util__default["default"].inspect(sheetnames)}`);
|
|
4406
4573
|
const scriptResults = [];
|
|
4407
4574
|
sheetnames.forEach(sheetname => {
|
|
4408
4575
|
const sheet = workbook.Sheets[sheetname];
|
|
@@ -4414,14 +4581,14 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4414
4581
|
hasNameCol
|
|
4415
4582
|
} = this._findOrigin(sheet, scriptType);
|
|
4416
4583
|
|
|
4417
|
-
debug$d(`evaluating sheet name for ${scriptType}: ${util__default[
|
|
4584
|
+
debug$d(`evaluating sheet name for ${scriptType}: ${util__default["default"].inspect(sheetname)}, rowindex ${rowindex}, colindex ${colindex}`);
|
|
4418
4585
|
|
|
4419
4586
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO || scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
4420
4587
|
const parseCell = (sender, content) => {
|
|
4421
4588
|
if (!content) return {
|
|
4422
4589
|
messageText: ''
|
|
4423
4590
|
};
|
|
4424
|
-
if (!lodash__default[
|
|
4591
|
+
if (!lodash__default["default"].isString(content)) content = '' + content;
|
|
4425
4592
|
let eolSplit = null;
|
|
4426
4593
|
let lines = [];
|
|
4427
4594
|
|
|
@@ -4640,49 +4807,120 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4640
4807
|
}
|
|
4641
4808
|
|
|
4642
4809
|
if (scriptType === Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY) {
|
|
4643
|
-
const
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
while (true) {
|
|
4647
|
-
const variableNameCell = this.colnames[colindexTemp] + rowindex;
|
|
4810
|
+
const guessScriptingMemoryColumnMode = () => {
|
|
4811
|
+
const line1Cell = this.colnames[colindex] + (rowindex + 1);
|
|
4648
4812
|
|
|
4649
|
-
if (sheet[
|
|
4650
|
-
|
|
4651
|
-
} else {
|
|
4652
|
-
break;
|
|
4813
|
+
if (sheet[line1Cell] && sheet[line1Cell].v) {
|
|
4814
|
+
if (sheet[line1Cell].v.startsWith('$')) return E_SCRIPTING_MEMORY_COLUMN_MODE.TESTCASENAMES;
|
|
4653
4815
|
}
|
|
4654
4816
|
|
|
4655
|
-
|
|
4656
|
-
}
|
|
4817
|
+
return E_SCRIPTING_MEMORY_COLUMN_MODE.VARNAMES;
|
|
4818
|
+
};
|
|
4657
4819
|
|
|
4658
|
-
|
|
4820
|
+
const columnMode = this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE] || guessScriptingMemoryColumnMode();
|
|
4659
4821
|
|
|
4660
|
-
|
|
4661
|
-
const
|
|
4822
|
+
if (columnMode === E_SCRIPTING_MEMORY_COLUMN_MODE.TESTCASENAMES) {
|
|
4823
|
+
const caseNames = [];
|
|
4824
|
+
let colindexTemp = colindex + 1;
|
|
4662
4825
|
|
|
4663
|
-
|
|
4664
|
-
const
|
|
4665
|
-
const values = {};
|
|
4826
|
+
while (true) {
|
|
4827
|
+
const caseNameCell = this.colnames[colindexTemp] + rowindex;
|
|
4666
4828
|
|
|
4667
|
-
|
|
4668
|
-
|
|
4829
|
+
if (sheet[caseNameCell] && sheet[caseNameCell].v) {
|
|
4830
|
+
caseNames.push(sheet[caseNameCell].v);
|
|
4831
|
+
} else {
|
|
4832
|
+
break;
|
|
4833
|
+
}
|
|
4669
4834
|
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4835
|
+
colindexTemp++;
|
|
4836
|
+
}
|
|
4837
|
+
|
|
4838
|
+
const varNames = [];
|
|
4839
|
+
const varValues = [];
|
|
4840
|
+
rowindex += 1;
|
|
4841
|
+
|
|
4842
|
+
while (true) {
|
|
4843
|
+
const varNameCell = this.colnames[colindex] + rowindex;
|
|
4844
|
+
|
|
4845
|
+
if (sheet[varNameCell] && sheet[varNameCell].v) {
|
|
4846
|
+
varNames.push(sheet[varNameCell].v);
|
|
4847
|
+
const values = [];
|
|
4848
|
+
|
|
4849
|
+
for (let i = 0; i < caseNames.length; i++) {
|
|
4850
|
+
const variableValueCell = this.colnames[colindex + 1 + i] + rowindex;
|
|
4851
|
+
|
|
4852
|
+
if (sheet[variableValueCell] && sheet[variableValueCell].v) {
|
|
4853
|
+
values.push(sheet[variableValueCell].v.toString());
|
|
4854
|
+
} else {
|
|
4855
|
+
values.push(null);
|
|
4856
|
+
}
|
|
4674
4857
|
}
|
|
4858
|
+
|
|
4859
|
+
varValues.push(values);
|
|
4860
|
+
rowindex += 1;
|
|
4861
|
+
} else {
|
|
4862
|
+
break;
|
|
4675
4863
|
}
|
|
4864
|
+
}
|
|
4676
4865
|
|
|
4677
|
-
|
|
4866
|
+
for (let caseIndex = 0; caseIndex < caseNames.length; caseIndex++) {
|
|
4867
|
+
const caseName = caseNames[caseIndex];
|
|
4868
|
+
const values = varNames.reduce((agg, varName, varIndex) => {
|
|
4869
|
+
agg[varName] = varValues[varIndex][caseIndex] || null;
|
|
4870
|
+
return agg;
|
|
4871
|
+
}, {});
|
|
4678
4872
|
scriptResults.push({
|
|
4679
4873
|
header: {
|
|
4680
4874
|
name: caseName
|
|
4681
4875
|
},
|
|
4682
4876
|
values: values
|
|
4683
4877
|
});
|
|
4684
|
-
}
|
|
4685
|
-
|
|
4878
|
+
}
|
|
4879
|
+
} else {
|
|
4880
|
+
const variableNames = [];
|
|
4881
|
+
let colindexTemp = colindex + 1;
|
|
4882
|
+
|
|
4883
|
+
while (true) {
|
|
4884
|
+
const variableNameCell = this.colnames[colindexTemp] + rowindex;
|
|
4885
|
+
|
|
4886
|
+
if (sheet[variableNameCell] && sheet[variableNameCell].v) {
|
|
4887
|
+
variableNames.push(sheet[variableNameCell].v);
|
|
4888
|
+
} else {
|
|
4889
|
+
break;
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4892
|
+
colindexTemp++;
|
|
4893
|
+
}
|
|
4894
|
+
|
|
4895
|
+
rowindex += 1;
|
|
4896
|
+
|
|
4897
|
+
while (true) {
|
|
4898
|
+
const caseNameCell = this.colnames[colindex] + rowindex;
|
|
4899
|
+
|
|
4900
|
+
if (sheet[caseNameCell] && sheet[caseNameCell].v) {
|
|
4901
|
+
const caseName = sheet[caseNameCell].v;
|
|
4902
|
+
const values = {};
|
|
4903
|
+
|
|
4904
|
+
for (let i = 0; i < variableNames.length; i++) {
|
|
4905
|
+
const variableValueCell = this.colnames[colindex + 1 + i] + rowindex;
|
|
4906
|
+
|
|
4907
|
+
if (sheet[variableValueCell] && sheet[variableValueCell].v) {
|
|
4908
|
+
values[variableNames[i]] = sheet[variableValueCell].v.toString();
|
|
4909
|
+
} else {
|
|
4910
|
+
values[variableNames[i]] = null;
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
|
|
4914
|
+
rowindex += 1;
|
|
4915
|
+
scriptResults.push({
|
|
4916
|
+
header: {
|
|
4917
|
+
name: caseName
|
|
4918
|
+
},
|
|
4919
|
+
values: values
|
|
4920
|
+
});
|
|
4921
|
+
} else {
|
|
4922
|
+
break;
|
|
4923
|
+
}
|
|
4686
4924
|
}
|
|
4687
4925
|
}
|
|
4688
4926
|
}
|
|
@@ -4740,12 +4978,12 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4740
4978
|
throw new Error(errors.map(e => e.message).join(' - '));
|
|
4741
4979
|
}
|
|
4742
4980
|
|
|
4743
|
-
const wb = xlsx__default[
|
|
4744
|
-
const ws = xlsx__default[
|
|
4981
|
+
const wb = xlsx__default["default"].utils.book_new();
|
|
4982
|
+
const ws = xlsx__default["default"].utils.json_to_sheet(data, {
|
|
4745
4983
|
header: ['me', 'bot']
|
|
4746
4984
|
});
|
|
4747
|
-
xlsx__default[
|
|
4748
|
-
const xlsxOutput = xlsx__default[
|
|
4985
|
+
xlsx__default["default"].utils.book_append_sheet(wb, ws, sheetname);
|
|
4986
|
+
const xlsxOutput = xlsx__default["default"].write(wb, {
|
|
4749
4987
|
type: 'buffer'
|
|
4750
4988
|
});
|
|
4751
4989
|
return xlsxOutput;
|
|
@@ -4760,9 +4998,9 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4760
4998
|
_findOrigin(sheet, scriptType) {
|
|
4761
4999
|
let rowindex = this.caps[Capabilities.SCRIPTING_XLSX_STARTROW];
|
|
4762
5000
|
let colindex = this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL];
|
|
4763
|
-
let hasNameCol = lodash__default[
|
|
5001
|
+
let hasNameCol = lodash__default["default"].has(this.caps, Capabilities.SCRIPTING_XLSX_HASNAMECOL) ? !!this.caps[Capabilities.SCRIPTING_XLSX_HASNAMECOL] : null;
|
|
4764
5002
|
|
|
4765
|
-
if (lodash__default[
|
|
5003
|
+
if (lodash__default["default"].isString(this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL])) {
|
|
4766
5004
|
colindex = this.colnames.findIndex(c => c === this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]);
|
|
4767
5005
|
} else if (colindex !== undefined) {
|
|
4768
5006
|
colindex = colindex - 1;
|
|
@@ -4815,7 +5053,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4815
5053
|
}
|
|
4816
5054
|
}
|
|
4817
5055
|
|
|
4818
|
-
if (lodash__default[
|
|
5056
|
+
if (lodash__default["default"].isNull(hasNameCol)) {
|
|
4819
5057
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO || scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
4820
5058
|
if (this.caps[Capabilities.SCRIPTING_XLSX_HASHEADERS]) {
|
|
4821
5059
|
if (this._get(sheet, rowindex - 1, colindex) && this._get(sheet, rowindex - 1, colindex + 1) && this._get(sheet, rowindex - 1, colindex + 2)) {
|
|
@@ -4842,7 +5080,8 @@ const {
|
|
|
4842
5080
|
linesToConvoStep: linesToConvoStep$3,
|
|
4843
5081
|
convoStepToLines,
|
|
4844
5082
|
validateConvo,
|
|
4845
|
-
validSenders: validSenders$2
|
|
5083
|
+
validSenders: validSenders$2,
|
|
5084
|
+
linesToScriptingMemories: linesToScriptingMemories$1
|
|
4846
5085
|
} = helper;
|
|
4847
5086
|
var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
4848
5087
|
constructor(context, caps = {}) {
|
|
@@ -4873,7 +5112,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4873
5112
|
let scriptData = scriptBuffer;
|
|
4874
5113
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4875
5114
|
|
|
4876
|
-
const lines = lodash__default[
|
|
5115
|
+
const lines = lodash__default["default"].map(scriptData.split(this.eol), line => line.trim());
|
|
4877
5116
|
|
|
4878
5117
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
4879
5118
|
return this._compileConvo(lines, false);
|
|
@@ -4973,30 +5212,12 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4973
5212
|
|
|
4974
5213
|
_compileScriptingMemory(lines) {
|
|
4975
5214
|
if (lines && lines.length > 1) {
|
|
4976
|
-
const
|
|
4977
|
-
const scriptingMemories = [];
|
|
4978
|
-
|
|
4979
|
-
for (let row = 1; row < lines.length; row++) {
|
|
4980
|
-
if (!lines[row] || lines[row].length === 0) continue;
|
|
4981
|
-
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
4982
|
-
const caseName = rawRow[0];
|
|
4983
|
-
const values = rawRow.slice(1);
|
|
4984
|
-
const json = {};
|
|
5215
|
+
const scriptingMemories = linesToScriptingMemories$1(lines, this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE]);
|
|
4985
5216
|
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
}
|
|
4989
|
-
|
|
4990
|
-
const scriptingMemory = {
|
|
4991
|
-
header: {
|
|
4992
|
-
name: caseName
|
|
4993
|
-
},
|
|
4994
|
-
values: json
|
|
4995
|
-
};
|
|
4996
|
-
scriptingMemories.push(scriptingMemory);
|
|
5217
|
+
if (scriptingMemories && scriptingMemories.length > 0) {
|
|
5218
|
+
this.context.AddScriptingMemories(scriptingMemories);
|
|
4997
5219
|
}
|
|
4998
5220
|
|
|
4999
|
-
this.context.AddScriptingMemories(scriptingMemories);
|
|
5000
5221
|
return scriptingMemories;
|
|
5001
5222
|
}
|
|
5002
5223
|
}
|
|
@@ -5040,7 +5261,10 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
5040
5261
|
|
|
5041
5262
|
};
|
|
5042
5263
|
|
|
5043
|
-
const
|
|
5264
|
+
const {
|
|
5265
|
+
parse
|
|
5266
|
+
} = sync__default["default"];
|
|
5267
|
+
const debug$c = debug__default["default"]('botium-core-CompilerCsv');
|
|
5044
5268
|
const {
|
|
5045
5269
|
Convo: Convo$3
|
|
5046
5270
|
} = Convo_1;
|
|
@@ -5056,13 +5280,13 @@ const DEFAULT_MULTIROW_COLUMN_SENDER = 1;
|
|
|
5056
5280
|
const DEFAULT_MULTIROW_COLUMN_TEXT = 2;
|
|
5057
5281
|
|
|
5058
5282
|
const _findColIndex = (header, colName) => {
|
|
5059
|
-
if (lodash__default[
|
|
5283
|
+
if (lodash__default["default"].isString(colName)) {
|
|
5060
5284
|
const result = header.findIndex(h => h === colName);
|
|
5061
5285
|
if (result >= 0) return result;
|
|
5062
5286
|
throw new Error(`Column name ${colName} not found.`);
|
|
5063
5287
|
}
|
|
5064
5288
|
|
|
5065
|
-
if (lodash__default[
|
|
5289
|
+
if (lodash__default["default"].isNumber(colName)) {
|
|
5066
5290
|
return colName;
|
|
5067
5291
|
}
|
|
5068
5292
|
|
|
@@ -5112,7 +5336,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5112
5336
|
let rows;
|
|
5113
5337
|
|
|
5114
5338
|
try {
|
|
5115
|
-
rows =
|
|
5339
|
+
rows = parse(scriptData, {
|
|
5116
5340
|
delimiter,
|
|
5117
5341
|
escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
|
|
5118
5342
|
quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
|
|
@@ -5213,7 +5437,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5213
5437
|
}
|
|
5214
5438
|
}
|
|
5215
5439
|
|
|
5216
|
-
const conversationIds = lodash__default[
|
|
5440
|
+
const conversationIds = lodash__default["default"].uniq(rows.map(r => r[colConversationId]));
|
|
5217
5441
|
|
|
5218
5442
|
const convos = conversationIds.map(conversationId => {
|
|
5219
5443
|
const convoRows = rows.map((row, i) => {
|
|
@@ -5245,13 +5469,14 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5245
5469
|
|
|
5246
5470
|
};
|
|
5247
5471
|
|
|
5248
|
-
const debug$b = debug__default[
|
|
5472
|
+
const debug$b = debug__default["default"]('botium-core-CompilerObject');
|
|
5249
5473
|
const {
|
|
5250
5474
|
Convo: Convo$2
|
|
5251
5475
|
} = Convo_1;
|
|
5252
5476
|
const {
|
|
5253
5477
|
linesToConvoStep: linesToConvoStep$1,
|
|
5254
|
-
validSenders: validSenders$1
|
|
5478
|
+
validSenders: validSenders$1,
|
|
5479
|
+
linesToScriptingMemories
|
|
5255
5480
|
} = helper;
|
|
5256
5481
|
var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
5257
5482
|
constructor(context, caps = {}) {
|
|
@@ -5342,7 +5567,7 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5342
5567
|
const names = Object.keys(utterancesRaw || {});
|
|
5343
5568
|
|
|
5344
5569
|
for (const name of names) {
|
|
5345
|
-
if (!lodash__default[
|
|
5570
|
+
if (!lodash__default["default"].isArray(utterancesRaw[name])) {
|
|
5346
5571
|
throw new Error(`The '${name}' utterance has to be an array.`);
|
|
5347
5572
|
}
|
|
5348
5573
|
|
|
@@ -5358,31 +5583,14 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5358
5583
|
|
|
5359
5584
|
_compileScriptingMemory(lines) {
|
|
5360
5585
|
if (lines && lines.length > 0) {
|
|
5361
|
-
if (lodash__default[
|
|
5586
|
+
if (lodash__default["default"].isString(lines[0])) {
|
|
5362
5587
|
if (lines.length > 1) {
|
|
5363
|
-
const
|
|
5364
|
-
const scriptingMemories = [];
|
|
5365
|
-
|
|
5366
|
-
for (let row = 1; row < lines.length; row++) {
|
|
5367
|
-
const rawRow = lines[row].split('|').map(name => name.trim());
|
|
5368
|
-
const caseName = rawRow[0];
|
|
5369
|
-
const values = rawRow.slice(1);
|
|
5370
|
-
const json = {};
|
|
5371
|
-
|
|
5372
|
-
for (let col = 0; col < names.length; col++) {
|
|
5373
|
-
json[names[col]] = values[col];
|
|
5374
|
-
}
|
|
5588
|
+
const scriptingMemories = linesToScriptingMemories(lines, this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE]);
|
|
5375
5589
|
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
name: caseName
|
|
5379
|
-
},
|
|
5380
|
-
values: json
|
|
5381
|
-
};
|
|
5382
|
-
scriptingMemories.push(scriptingMemory);
|
|
5590
|
+
if (scriptingMemories && scriptingMemories.length > 0) {
|
|
5591
|
+
this.context.AddScriptingMemories(scriptingMemories);
|
|
5383
5592
|
}
|
|
5384
5593
|
|
|
5385
|
-
this.context.AddScriptingMemories(scriptingMemories);
|
|
5386
5594
|
return scriptingMemories;
|
|
5387
5595
|
}
|
|
5388
5596
|
} else {
|
|
@@ -5406,7 +5614,7 @@ var CompilerYaml_1 = class CompilerYaml extends CompilerObjectBase_1 {
|
|
|
5406
5614
|
}
|
|
5407
5615
|
|
|
5408
5616
|
Deserialize(scriptData) {
|
|
5409
|
-
return yaml__default[
|
|
5617
|
+
return yaml__default["default"].parse(scriptData);
|
|
5410
5618
|
}
|
|
5411
5619
|
|
|
5412
5620
|
};
|
|
@@ -5438,8 +5646,8 @@ var CompilerJson_1 = class CompilerJson extends CompilerObjectBase_1 {
|
|
|
5438
5646
|
|
|
5439
5647
|
};
|
|
5440
5648
|
|
|
5441
|
-
const debug$a = debug__default[
|
|
5442
|
-
const md = new markdownIt__default[
|
|
5649
|
+
const debug$a = debug__default["default"]('botium-core-CompilerMarkdown');
|
|
5650
|
+
const md = new markdownIt__default["default"]();
|
|
5443
5651
|
const {
|
|
5444
5652
|
Convo: Convo$1
|
|
5445
5653
|
} = Convo_1;
|
|
@@ -5488,7 +5696,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5488
5696
|
|
|
5489
5697
|
depth = 1;
|
|
5490
5698
|
} else {
|
|
5491
|
-
debug$a(`Markdown entry "${util__default[
|
|
5699
|
+
debug$a(`Markdown entry "${util__default["default"].inspect(entry)}" ignored. Unknown heading`);
|
|
5492
5700
|
}
|
|
5493
5701
|
} else if (entry.type === 'bullet_list_open') {
|
|
5494
5702
|
if (depth < 1) {
|
|
@@ -5568,14 +5776,14 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5568
5776
|
|
|
5569
5777
|
};
|
|
5570
5778
|
|
|
5571
|
-
promise__default[
|
|
5572
|
-
const debug$9 = debug__default[
|
|
5779
|
+
promise__default["default"].shim();
|
|
5780
|
+
const debug$9 = debug__default["default"]('botium-core-ScriptingProvider');
|
|
5573
5781
|
const {
|
|
5574
5782
|
Convo,
|
|
5575
5783
|
ConvoStep
|
|
5576
5784
|
} = Convo_1;
|
|
5577
5785
|
const {
|
|
5578
|
-
BotiumError: BotiumError$
|
|
5786
|
+
BotiumError: BotiumError$2,
|
|
5579
5787
|
botiumErrorFromList,
|
|
5580
5788
|
botiumErrorFromErr
|
|
5581
5789
|
} = BotiumError_1;
|
|
@@ -5595,7 +5803,7 @@ const p = (retryHelper, fn) => {
|
|
|
5595
5803
|
});
|
|
5596
5804
|
|
|
5597
5805
|
if (retryHelper) {
|
|
5598
|
-
return promiseRetry__default[
|
|
5806
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
5599
5807
|
return promise().catch(err => {
|
|
5600
5808
|
if (retryHelper.shouldRetry(err)) {
|
|
5601
5809
|
debug$9(`Asserter trial #${number} failed, retry activated`);
|
|
@@ -5622,7 +5830,7 @@ const pnot = (retryHelper, fn, errTemplate) => {
|
|
|
5622
5830
|
});
|
|
5623
5831
|
|
|
5624
5832
|
if (retryHelper) {
|
|
5625
|
-
return promiseRetry__default[
|
|
5833
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
5626
5834
|
return promise().catch(() => {
|
|
5627
5835
|
if (retryHelper.shouldRetry(errTemplate)) {
|
|
5628
5836
|
debug$9(`Asserter trial #${number} failed, !retry activated`);
|
|
@@ -5639,7 +5847,7 @@ const pnot = (retryHelper, fn, errTemplate) => {
|
|
|
5639
5847
|
|
|
5640
5848
|
var ScriptingProvider_1 = class ScriptingProvider {
|
|
5641
5849
|
constructor(caps) {
|
|
5642
|
-
this.caps = caps || lodash__default[
|
|
5850
|
+
this.caps = caps || lodash__default["default"].cloneDeep(Defaults$1.Capabilities);
|
|
5643
5851
|
this.compilers = {};
|
|
5644
5852
|
this.convos = [];
|
|
5645
5853
|
this.utterances = {};
|
|
@@ -5840,22 +6048,22 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5840
6048
|
});
|
|
5841
6049
|
},
|
|
5842
6050
|
assertBotResponse: (botresponse, tomatch, stepTag, meMsg) => {
|
|
5843
|
-
if (!lodash__default[
|
|
6051
|
+
if (!lodash__default["default"].isArray(tomatch)) {
|
|
5844
6052
|
tomatch = [tomatch];
|
|
5845
6053
|
}
|
|
5846
6054
|
|
|
5847
6055
|
debug$9(`assertBotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} = ${tomatch} ...`);
|
|
5848
6056
|
|
|
5849
|
-
const found = lodash__default[
|
|
6057
|
+
const found = lodash__default["default"].find(tomatch, utt => this.matchFn(botresponse, utt));
|
|
5850
6058
|
|
|
5851
|
-
if (lodash__default[
|
|
6059
|
+
if (lodash__default["default"].isNil(found)) {
|
|
5852
6060
|
let message = `${stepTag}: Bot response `;
|
|
5853
6061
|
message += meMsg ? `(on ${meMsg}) ` : '';
|
|
5854
6062
|
message += botresponse ? '"' + botresponse + '"' : '<no response>';
|
|
5855
6063
|
message += ' expected to match ';
|
|
5856
6064
|
message += tomatch && tomatch.length > 1 ? 'one of ' : '';
|
|
5857
6065
|
message += `${tomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5858
|
-
throw new BotiumError$
|
|
6066
|
+
throw new BotiumError$2(message, {
|
|
5859
6067
|
type: 'asserter',
|
|
5860
6068
|
source: 'TextMatchAsserter',
|
|
5861
6069
|
context: {
|
|
@@ -5870,22 +6078,22 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5870
6078
|
}
|
|
5871
6079
|
},
|
|
5872
6080
|
assertBotNotResponse: (botresponse, nottomatch, stepTag, meMsg) => {
|
|
5873
|
-
if (!lodash__default[
|
|
6081
|
+
if (!lodash__default["default"].isArray(nottomatch)) {
|
|
5874
6082
|
nottomatch = [nottomatch];
|
|
5875
6083
|
}
|
|
5876
6084
|
|
|
5877
6085
|
debug$9(`assertBotNotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} != ${nottomatch} ...`);
|
|
5878
6086
|
|
|
5879
|
-
const found = lodash__default[
|
|
6087
|
+
const found = lodash__default["default"].find(nottomatch, utt => this.matchFn(botresponse, utt));
|
|
5880
6088
|
|
|
5881
|
-
if (!lodash__default[
|
|
6089
|
+
if (!lodash__default["default"].isNil(found)) {
|
|
5882
6090
|
let message = `${stepTag}: Bot response `;
|
|
5883
6091
|
message += meMsg ? `(on ${meMsg}) ` : '';
|
|
5884
6092
|
message += botresponse ? '"' + botresponse + '"' : '<no response>';
|
|
5885
6093
|
message += ' expected NOT to match ';
|
|
5886
6094
|
message += nottomatch && nottomatch.length > 1 ? 'one of ' : '';
|
|
5887
6095
|
message += `${nottomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5888
|
-
throw new BotiumError$
|
|
6096
|
+
throw new BotiumError$2(message, {
|
|
5889
6097
|
type: 'asserter',
|
|
5890
6098
|
source: 'TextMatchAsserter',
|
|
5891
6099
|
context: {
|
|
@@ -5932,7 +6140,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5932
6140
|
if (asserter[notAsserterType]) {
|
|
5933
6141
|
return p(this.retryHelperAsserter, () => asserter[notAsserterType](params));
|
|
5934
6142
|
} else {
|
|
5935
|
-
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$
|
|
6143
|
+
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$2(`${convoStep.stepTag}: Expected asserter ${asserter.name || asserterSpec.name} with args "${params.args}" to fail`, {
|
|
5936
6144
|
type: 'asserter',
|
|
5937
6145
|
source: asserter.name || asserterSpec.name,
|
|
5938
6146
|
params: {
|
|
@@ -6042,7 +6250,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6042
6250
|
utterance,
|
|
6043
6251
|
resolveEmptyIfUnknown = false
|
|
6044
6252
|
}) {
|
|
6045
|
-
if (lodash__default[
|
|
6253
|
+
if (lodash__default["default"].isString(utterance)) {
|
|
6046
6254
|
if (this.utterances[utterance]) {
|
|
6047
6255
|
return this.utterances[utterance].utterances;
|
|
6048
6256
|
} else {
|
|
@@ -6050,7 +6258,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6050
6258
|
|
|
6051
6259
|
if (this.utterances[parts[0]]) {
|
|
6052
6260
|
const uttArgs = parts.slice(1);
|
|
6053
|
-
return this.utterances[parts[0]].utterances.map(utt => util__default[
|
|
6261
|
+
return this.utterances[parts[0]].utterances.map(utt => util__default["default"].format(utt, ...uttArgs));
|
|
6054
6262
|
}
|
|
6055
6263
|
}
|
|
6056
6264
|
}
|
|
@@ -6154,22 +6362,22 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6154
6362
|
}
|
|
6155
6363
|
|
|
6156
6364
|
ReadBotiumFilesFromDirectory(convoDir, globFilter) {
|
|
6157
|
-
const filelist = globby__default[
|
|
6365
|
+
const filelist = globby__default["default"].sync(globPattern, {
|
|
6158
6366
|
cwd: convoDir,
|
|
6159
6367
|
gitignore: true
|
|
6160
6368
|
});
|
|
6161
6369
|
|
|
6162
6370
|
if (globFilter) {
|
|
6163
|
-
const filelistGlobbed = globby__default[
|
|
6371
|
+
const filelistGlobbed = globby__default["default"].sync(globFilter, {
|
|
6164
6372
|
cwd: convoDir,
|
|
6165
6373
|
gitignore: true
|
|
6166
6374
|
});
|
|
6167
6375
|
|
|
6168
|
-
lodash__default[
|
|
6376
|
+
lodash__default["default"].remove(filelist, file => filelistGlobbed.indexOf(file) < 0);
|
|
6169
6377
|
}
|
|
6170
6378
|
|
|
6171
|
-
lodash__default[
|
|
6172
|
-
const isSkip = skipPattern.test(path__default[
|
|
6379
|
+
lodash__default["default"].remove(filelist, file => {
|
|
6380
|
+
const isSkip = skipPattern.test(path__default["default"].basename(file));
|
|
6173
6381
|
if (isSkip) debug$9(`ReadBotiumFilesFromDirectory - skipping file '${file}'`);
|
|
6174
6382
|
return isSkip;
|
|
6175
6383
|
});
|
|
@@ -6179,11 +6387,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6179
6387
|
|
|
6180
6388
|
ReadScriptsFromDirectory(convoDir, globFilter) {
|
|
6181
6389
|
let filelist = [];
|
|
6182
|
-
const convoDirStats = fs__default[
|
|
6390
|
+
const convoDirStats = fs__default["default"].statSync(convoDir);
|
|
6183
6391
|
|
|
6184
6392
|
if (convoDirStats.isFile()) {
|
|
6185
|
-
filelist = [path__default[
|
|
6186
|
-
convoDir = path__default[
|
|
6393
|
+
filelist = [path__default["default"].basename(convoDir)];
|
|
6394
|
+
convoDir = path__default["default"].dirname(convoDir);
|
|
6187
6395
|
} else {
|
|
6188
6396
|
filelist = this.ReadBotiumFilesFromDirectory(convoDir, globFilter);
|
|
6189
6397
|
}
|
|
@@ -6206,9 +6414,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6206
6414
|
if (scriptingMemories) dirScriptingMemories.push(...scriptingMemories);
|
|
6207
6415
|
});
|
|
6208
6416
|
debug$9(`ReadConvosFromDirectory(${convoDir}) found convos:\n ${dirConvos.length ? dirConvos.join('\n') : 'none'}`);
|
|
6209
|
-
debug$9(`ReadConvosFromDirectory(${convoDir}) found utterances:\n ${dirUtterances.length ? lodash__default[
|
|
6417
|
+
debug$9(`ReadConvosFromDirectory(${convoDir}) found utterances:\n ${dirUtterances.length ? lodash__default["default"].map(dirUtterances, u => u).join('\n') : 'none'}`);
|
|
6210
6418
|
debug$9(`ReadConvosFromDirectory(${convoDir}) found partial convos:\n ${dirPartialConvos.length ? dirPartialConvos.join('\n') : 'none'}`);
|
|
6211
|
-
debug$9(`ReadConvosFromDirectory(${convoDir}) scripting memories:\n ${dirScriptingMemories.length ? dirScriptingMemories.map(dirScriptingMemory => util__default[
|
|
6419
|
+
debug$9(`ReadConvosFromDirectory(${convoDir}) scripting memories:\n ${dirScriptingMemories.length ? dirScriptingMemories.map(dirScriptingMemory => util__default["default"].inspect(dirScriptingMemory)).join('\n') : 'none'}`);
|
|
6212
6420
|
return {
|
|
6213
6421
|
convos: dirConvos,
|
|
6214
6422
|
utterances: dirUtterances,
|
|
@@ -6217,14 +6425,40 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6217
6425
|
};
|
|
6218
6426
|
}
|
|
6219
6427
|
|
|
6428
|
+
ReadScriptFromBuffer(scriptBuffer, scriptingFormat, scriptingTypes = null) {
|
|
6429
|
+
if (lodash__default["default"].isString(scriptingTypes)) scriptingTypes = [scriptingTypes];
|
|
6430
|
+
if (lodash__default["default"].isArray(scriptingTypes) && scriptingTypes.length === 0) scriptingTypes = null;
|
|
6431
|
+
const result = {
|
|
6432
|
+
convos: [],
|
|
6433
|
+
utterances: [],
|
|
6434
|
+
pconvos: [],
|
|
6435
|
+
scriptingMemories: []
|
|
6436
|
+
};
|
|
6437
|
+
|
|
6438
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_UTTERANCES)) {
|
|
6439
|
+
result.utterances = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_UTTERANCES);
|
|
6440
|
+
}
|
|
6441
|
+
|
|
6442
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_PCONVO)) {
|
|
6443
|
+
result.pconvos = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6444
|
+
}
|
|
6445
|
+
|
|
6446
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_CONVO)) {
|
|
6447
|
+
result.convos = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_CONVO);
|
|
6448
|
+
}
|
|
6449
|
+
|
|
6450
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY)) {
|
|
6451
|
+
result.scriptingMemories = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6452
|
+
}
|
|
6453
|
+
|
|
6454
|
+
return result;
|
|
6455
|
+
}
|
|
6456
|
+
|
|
6220
6457
|
ReadScript(convoDir, filename) {
|
|
6221
|
-
let
|
|
6222
|
-
let fileUtterances = [];
|
|
6223
|
-
let filePartialConvos = [];
|
|
6224
|
-
let fileScriptingMemories = [];
|
|
6458
|
+
let result = {};
|
|
6225
6459
|
|
|
6226
6460
|
try {
|
|
6227
|
-
let scriptBuffer = fs__default[
|
|
6461
|
+
let scriptBuffer = fs__default["default"].readFileSync(path__default["default"].resolve(convoDir, filename));
|
|
6228
6462
|
const precompResponse = precompilers.execute(scriptBuffer, {
|
|
6229
6463
|
convoDir,
|
|
6230
6464
|
filename,
|
|
@@ -6238,36 +6472,25 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6238
6472
|
}
|
|
6239
6473
|
|
|
6240
6474
|
if (filename.endsWith('.xlsx') || filename.endsWith('.xlsm')) {
|
|
6241
|
-
|
|
6242
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6243
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_CONVO);
|
|
6244
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6475
|
+
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]);
|
|
6245
6476
|
} else if (filename.endsWith('.convo.txt')) {
|
|
6246
|
-
|
|
6477
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_CONVO);
|
|
6247
6478
|
} else if (filename.endsWith('.pconvo.txt')) {
|
|
6248
|
-
|
|
6479
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6249
6480
|
} else if (filename.endsWith('.utterances.txt')) {
|
|
6250
|
-
|
|
6481
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_UTTERANCES);
|
|
6251
6482
|
} else if (filename.endsWith('.scriptingmemory.txt')) {
|
|
6252
|
-
|
|
6483
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6253
6484
|
} else if (filename.endsWith('.convo.csv')) {
|
|
6254
|
-
|
|
6485
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_CONVO);
|
|
6255
6486
|
} else if (filename.endsWith('.pconvo.csv')) {
|
|
6256
|
-
|
|
6487
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6257
6488
|
} else if (filename.endsWith('.yaml') || filename.endsWith('.yml')) {
|
|
6258
|
-
|
|
6259
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6260
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_CONVO);
|
|
6261
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6489
|
+
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]);
|
|
6262
6490
|
} else if (filename.endsWith('.json')) {
|
|
6263
|
-
|
|
6264
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6265
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_CONVO);
|
|
6266
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6491
|
+
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]);
|
|
6267
6492
|
} else if (filename.endsWith('.markdown') || filename.endsWith('.md')) {
|
|
6268
|
-
|
|
6269
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, Constants.SCRIPTING_TYPE_CONVO);
|
|
6270
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6493
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, [Constants.SCRIPTING_TYPE_UTTERANCES, Constants.SCRIPTING_TYPE_PCONVO, Constants.SCRIPTING_TYPE_CONVO]);
|
|
6271
6494
|
} else {
|
|
6272
6495
|
debug$9(`ReadScript - dropped file: ${filename}, filename not supported`);
|
|
6273
6496
|
}
|
|
@@ -6277,8 +6500,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6277
6500
|
} // Compilers saved the convos, and we alter here the saved version too
|
|
6278
6501
|
|
|
6279
6502
|
|
|
6280
|
-
if (
|
|
6281
|
-
|
|
6503
|
+
if (result.convos && result.convos.length > 0) {
|
|
6504
|
+
result.convos.forEach(fileConvo => {
|
|
6282
6505
|
fileConvo.sourceTag = {
|
|
6283
6506
|
convoDir,
|
|
6284
6507
|
filename
|
|
@@ -6291,12 +6514,12 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6291
6514
|
|
|
6292
6515
|
const isSkip = c => c.header.name && skipPattern.test(c.header.name.toLowerCase());
|
|
6293
6516
|
|
|
6294
|
-
|
|
6295
|
-
|
|
6517
|
+
result.convos.filter(c => isSkip(c)).forEach(c => debug$9(`ReadScript - skipping convo '${c.header.name}'`));
|
|
6518
|
+
result.convos = result.convos.filter(c => !isSkip(c));
|
|
6296
6519
|
}
|
|
6297
6520
|
|
|
6298
|
-
if (
|
|
6299
|
-
|
|
6521
|
+
if (result.pconvos && result.pconvos.length > 0) {
|
|
6522
|
+
result.pconvos.forEach(filePartialConvo => {
|
|
6300
6523
|
filePartialConvo.sourceTag = {
|
|
6301
6524
|
convoDir,
|
|
6302
6525
|
filename
|
|
@@ -6308,23 +6531,23 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6308
6531
|
});
|
|
6309
6532
|
}
|
|
6310
6533
|
|
|
6311
|
-
if (
|
|
6312
|
-
|
|
6534
|
+
if (result.scriptingMemories && result.scriptingMemories.length > 0) {
|
|
6535
|
+
result.scriptingMemories.forEach(scriptingMemory => {
|
|
6313
6536
|
scriptingMemory.sourceTag = {
|
|
6314
6537
|
filename
|
|
6315
6538
|
};
|
|
6316
6539
|
});
|
|
6317
6540
|
}
|
|
6318
6541
|
|
|
6319
|
-
if (
|
|
6320
|
-
|
|
6542
|
+
if (result.utterances) {
|
|
6543
|
+
result.utterances = this._tagAndCleanupUtterances(result.utterances, convoDir, filename);
|
|
6321
6544
|
}
|
|
6322
6545
|
|
|
6323
6546
|
return {
|
|
6324
|
-
convos:
|
|
6325
|
-
utterances:
|
|
6326
|
-
pconvos:
|
|
6327
|
-
scriptingMemories:
|
|
6547
|
+
convos: result.convos || [],
|
|
6548
|
+
utterances: result.utterances || [],
|
|
6549
|
+
pconvos: result.pconvos || [],
|
|
6550
|
+
scriptingMemories: result.scriptingMemories || []
|
|
6328
6551
|
};
|
|
6329
6552
|
}
|
|
6330
6553
|
|
|
@@ -6351,7 +6574,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6351
6574
|
});
|
|
6352
6575
|
|
|
6353
6576
|
if (aggregatedNoNames.length) {
|
|
6354
|
-
throw new BotiumError$
|
|
6577
|
+
throw new BotiumError$2('Scripting Memory Definition(s) without name', {
|
|
6355
6578
|
type: 'Scripting Memory',
|
|
6356
6579
|
subtype: 'Scripting Memory without name',
|
|
6357
6580
|
source: 'ScriptingProvider',
|
|
@@ -6367,7 +6590,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6367
6590
|
});
|
|
6368
6591
|
|
|
6369
6592
|
if (aggregatedNoVariables.length) {
|
|
6370
|
-
throw new BotiumError$
|
|
6593
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariables.map(e => e.header.name).join(', ')} without variable`, {
|
|
6371
6594
|
type: 'Scripting Memory',
|
|
6372
6595
|
subtype: 'Scripting Memory without variable',
|
|
6373
6596
|
source: 'ScriptingProvider',
|
|
@@ -6379,11 +6602,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6379
6602
|
|
|
6380
6603
|
|
|
6381
6604
|
const aggregatedNoVariableNames = this.scriptingMemories.filter(entry => {
|
|
6382
|
-
return !lodash__default[
|
|
6605
|
+
return !lodash__default["default"].isUndefined(entry.values['']);
|
|
6383
6606
|
});
|
|
6384
6607
|
|
|
6385
6608
|
if (aggregatedNoVariableNames.length) {
|
|
6386
|
-
throw new BotiumError$
|
|
6609
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariableNames.map(e => e.header.name).join(', ')} without variable name`, {
|
|
6387
6610
|
type: 'Scripting Memory',
|
|
6388
6611
|
subtype: 'Scripting Memory without variable name',
|
|
6389
6612
|
source: 'ScriptingProvider',
|
|
@@ -6415,7 +6638,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6415
6638
|
}
|
|
6416
6639
|
|
|
6417
6640
|
if (aggregatedDuplicates.length) {
|
|
6418
|
-
throw new BotiumError$
|
|
6641
|
+
throw new BotiumError$2(`Scripting Memory Definition name(s) "${lodash__default["default"].uniq(aggregatedDuplicates.map(d => d.scriptingMemory.header.name)).join(', ')}" are not unique`, {
|
|
6419
6642
|
type: 'Scripting Memory',
|
|
6420
6643
|
subtype: 'Scripting Memory name collision',
|
|
6421
6644
|
source: 'ScriptingProvider',
|
|
@@ -6438,7 +6661,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6438
6661
|
const k1 = Object.keys(entry.values);
|
|
6439
6662
|
const k2 = Object.keys(scriptingMemory.values);
|
|
6440
6663
|
|
|
6441
|
-
const kInt = lodash__default[
|
|
6664
|
+
const kInt = lodash__default["default"].intersection(k1, k2);
|
|
6442
6665
|
|
|
6443
6666
|
return kInt.length && (kInt.length !== k1.length || kInt.length !== k2.length);
|
|
6444
6667
|
});
|
|
@@ -6452,7 +6675,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6452
6675
|
}
|
|
6453
6676
|
|
|
6454
6677
|
if (aggregatedIntersections.length) {
|
|
6455
|
-
throw new BotiumError$
|
|
6678
|
+
throw new BotiumError$2(`Scripting Memory Definitions "${aggregatedIntersections.map(i => i.scriptingMemory.header.name).join(', ')}" are invalid because variable name collision"`, {
|
|
6456
6679
|
type: 'Scripting Memory',
|
|
6457
6680
|
subtype: 'Scripting Memory variable name collision',
|
|
6458
6681
|
source: 'ScriptingProvider',
|
|
@@ -6476,7 +6699,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6476
6699
|
const convosOriginalAll = [];
|
|
6477
6700
|
this.convos.forEach(convo => {
|
|
6478
6701
|
const convoVariables = convo.GetScriptingMemoryAllVariables(this);
|
|
6479
|
-
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Variables to replace, all: "${util__default[
|
|
6702
|
+
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Variables to replace, all: "${util__default["default"].inspect(convoVariables)}"`);
|
|
6480
6703
|
|
|
6481
6704
|
if (!convoVariables.length) {
|
|
6482
6705
|
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - skipped, no variable found to replace`);
|
|
@@ -6490,13 +6713,13 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6490
6713
|
for (const [key, scriptingMemories] of variablesToScriptingMemory.entries()) {
|
|
6491
6714
|
const variableNames = JSON.parse(key);
|
|
6492
6715
|
|
|
6493
|
-
if (lodash__default[
|
|
6716
|
+
if (lodash__default["default"].intersection(variableNames, convoVariables).length) {
|
|
6494
6717
|
const convosExpandedVariable = [];
|
|
6495
6718
|
multipliers.push(scriptingMemories.length);
|
|
6496
6719
|
scriptingMemories.forEach(scriptingMemory => {
|
|
6497
6720
|
// Appending the case name to name
|
|
6498
6721
|
for (const convoToExpand of convosToExpand) {
|
|
6499
|
-
const convoExpanded = lodash__default[
|
|
6722
|
+
const convoExpanded = lodash__default["default"].cloneDeep(convoToExpand);
|
|
6500
6723
|
|
|
6501
6724
|
convoExpanded.header.name = convoToExpand.header.name + '.' + scriptingMemory.header.name;
|
|
6502
6725
|
variableNames.forEach(name => {
|
|
@@ -6522,7 +6745,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6522
6745
|
convosToExpand = convosExpandedVariable;
|
|
6523
6746
|
convosExpandedConvo = convosExpandedVariable;
|
|
6524
6747
|
} else {
|
|
6525
|
-
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Scripting memory ${key} ignored because there is no common variable with convo ${util__default[
|
|
6748
|
+
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Scripting memory ${key} ignored because there is no common variable with convo ${util__default["default"].inspect(convoVariables)}`);
|
|
6526
6749
|
}
|
|
6527
6750
|
}
|
|
6528
6751
|
|
|
@@ -6541,6 +6764,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6541
6764
|
|
|
6542
6765
|
debug$9(`ExpandScriptingMemoryToConvos - ${convosExpandedAll.length} convo expanded, added to convos (${this.convos.length}). Result ${convosExpandedAll.length + this.convos.length} convo`);
|
|
6543
6766
|
this.convos = this.convos.concat(convosExpandedAll);
|
|
6767
|
+
|
|
6768
|
+
this._sortConvos();
|
|
6544
6769
|
}
|
|
6545
6770
|
|
|
6546
6771
|
ExpandUtterancesToConvos({
|
|
@@ -6549,11 +6774,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6549
6774
|
} = {}) {
|
|
6550
6775
|
const expandedConvos = [];
|
|
6551
6776
|
|
|
6552
|
-
if (lodash__default[
|
|
6777
|
+
if (lodash__default["default"].isUndefined(useNameAsIntent)) {
|
|
6553
6778
|
useNameAsIntent = !!this.caps[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT];
|
|
6554
6779
|
}
|
|
6555
6780
|
|
|
6556
|
-
if (lodash__default[
|
|
6781
|
+
if (lodash__default["default"].isUndefined(incomprehensionUtt)) {
|
|
6557
6782
|
incomprehensionUtt = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION];
|
|
6558
6783
|
}
|
|
6559
6784
|
|
|
@@ -6571,7 +6796,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6571
6796
|
debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}`);
|
|
6572
6797
|
}
|
|
6573
6798
|
|
|
6574
|
-
lodash__default[
|
|
6799
|
+
lodash__default["default"].keys(this.utterances).filter(u => u !== incomprehensionUtt).forEach(uttName => {
|
|
6575
6800
|
const utt = this.utterances[uttName];
|
|
6576
6801
|
expandedConvos.push(new Convo(this._buildScriptContext(), {
|
|
6577
6802
|
header: {
|
|
@@ -6580,6 +6805,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6580
6805
|
},
|
|
6581
6806
|
conversation: [{
|
|
6582
6807
|
sender: 'me',
|
|
6808
|
+
logicHooks: [{
|
|
6809
|
+
name: 'SKIP_BOT_UNCONSUMED'
|
|
6810
|
+
}],
|
|
6583
6811
|
messageText: utt.name,
|
|
6584
6812
|
stepTag: 'Step 1 - tell utterance'
|
|
6585
6813
|
}, useNameAsIntent ? {
|
|
@@ -6659,7 +6887,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6659
6887
|
|
|
6660
6888
|
if (currentStep.sender === 'bot' || currentStep.sender === 'begin' || currentStep.sender === 'end') {
|
|
6661
6889
|
const currentStepsStack = convoStepsStack.slice();
|
|
6662
|
-
currentStepsStack.push(lodash__default[
|
|
6890
|
+
currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
|
|
6663
6891
|
|
|
6664
6892
|
this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack);
|
|
6665
6893
|
} else if (currentStep.sender === 'me') {
|
|
@@ -6698,14 +6926,14 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6698
6926
|
const currentStepsStack = convoStepsStack.slice();
|
|
6699
6927
|
|
|
6700
6928
|
if (uttArgs) {
|
|
6701
|
-
utt = util__default[
|
|
6929
|
+
utt = util__default["default"].format(utt, ...uttArgs);
|
|
6702
6930
|
}
|
|
6703
6931
|
|
|
6704
|
-
currentStepsStack.push(Object.assign(lodash__default[
|
|
6932
|
+
currentStepsStack.push(Object.assign(lodash__default["default"].cloneDeep(currentStep), {
|
|
6705
6933
|
messageText: utt
|
|
6706
6934
|
}));
|
|
6707
6935
|
|
|
6708
|
-
const currentConvoLabeled = lodash__default[
|
|
6936
|
+
const currentConvoLabeled = lodash__default["default"].cloneDeep(currentConvo);
|
|
6709
6937
|
|
|
6710
6938
|
Object.assign(currentConvoLabeled.header, {
|
|
6711
6939
|
name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, utt)}`
|
|
@@ -6746,12 +6974,12 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6746
6974
|
const lineTag = `${index + 1}`.padStart(`${sampleinputs.length}`.length, '0');
|
|
6747
6975
|
const currentStepsStack = convoStepsStack.slice();
|
|
6748
6976
|
|
|
6749
|
-
const currentStepMod = lodash__default[
|
|
6977
|
+
const currentStepMod = lodash__default["default"].cloneDeep(currentStep);
|
|
6750
6978
|
|
|
6751
6979
|
currentStepMod.userInputs[uiIndex] = sampleinput;
|
|
6752
6980
|
currentStepsStack.push(currentStepMod);
|
|
6753
6981
|
|
|
6754
|
-
const currentConvoLabeled = lodash__default[
|
|
6982
|
+
const currentConvoLabeled = lodash__default["default"].cloneDeep(currentConvo);
|
|
6755
6983
|
|
|
6756
6984
|
Object.assign(currentConvoLabeled.header, {
|
|
6757
6985
|
name: `${currentConvo.header.name}/${ui.name}-${utterancePostfix(lineTag, sampleinput.args && sampleinput.args.length ? sampleinput.args.join(', ') : 'no-args')}`
|
|
@@ -6767,20 +6995,20 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6767
6995
|
|
|
6768
6996
|
if (useUnexpanded) {
|
|
6769
6997
|
const currentStepsStack = convoStepsStack.slice();
|
|
6770
|
-
currentStepsStack.push(lodash__default[
|
|
6998
|
+
currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
|
|
6771
6999
|
|
|
6772
7000
|
this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack);
|
|
6773
7001
|
}
|
|
6774
7002
|
}
|
|
6775
7003
|
} else {
|
|
6776
|
-
expandedConvos.push(Object.assign(lodash__default[
|
|
6777
|
-
conversation: convoStepsStack
|
|
7004
|
+
expandedConvos.push(Object.assign(lodash__default["default"].cloneDeep(currentConvo), {
|
|
7005
|
+
conversation: lodash__default["default"].cloneDeep(convoStepsStack)
|
|
6778
7006
|
}));
|
|
6779
7007
|
}
|
|
6780
7008
|
}
|
|
6781
7009
|
|
|
6782
7010
|
_sortConvos() {
|
|
6783
|
-
this.convos = lodash__default[
|
|
7011
|
+
this.convos = lodash__default["default"].sortBy(this.convos, [convo => convo.header.sort || convo.header.name]);
|
|
6784
7012
|
let i = 0;
|
|
6785
7013
|
this.convos.forEach(convo => {
|
|
6786
7014
|
convo.header.order = ++i;
|
|
@@ -6796,8 +7024,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6796
7024
|
}
|
|
6797
7025
|
|
|
6798
7026
|
AddConvos(convos) {
|
|
6799
|
-
if (convos && lodash__default[
|
|
6800
|
-
this.convos = lodash__default[
|
|
7027
|
+
if (convos && lodash__default["default"].isArray(convos)) {
|
|
7028
|
+
this.convos = lodash__default["default"].concat(this.convos, convos);
|
|
6801
7029
|
} else if (convos) {
|
|
6802
7030
|
this.convos.push(convos);
|
|
6803
7031
|
}
|
|
@@ -6832,16 +7060,16 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6832
7060
|
};
|
|
6833
7061
|
};
|
|
6834
7062
|
|
|
6835
|
-
if (utterances && !lodash__default[
|
|
7063
|
+
if (utterances && !lodash__default["default"].isArray(utterances)) {
|
|
6836
7064
|
utterances = [utterances];
|
|
6837
7065
|
}
|
|
6838
7066
|
|
|
6839
7067
|
if (utterances) {
|
|
6840
|
-
lodash__default[
|
|
7068
|
+
lodash__default["default"].forEach(utterances, utt => {
|
|
6841
7069
|
const eu = this.utterances[utt.name];
|
|
6842
7070
|
|
|
6843
7071
|
if (eu) {
|
|
6844
|
-
eu.utterances = lodash__default[
|
|
7072
|
+
eu.utterances = lodash__default["default"].uniq(lodash__default["default"].concat(eu.utterances, utt.utterances));
|
|
6845
7073
|
} else {
|
|
6846
7074
|
this.utterances[utt.name] = utt;
|
|
6847
7075
|
}
|
|
@@ -6859,7 +7087,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6859
7087
|
}
|
|
6860
7088
|
|
|
6861
7089
|
AddPartialConvos(convos) {
|
|
6862
|
-
if (convos && lodash__default[
|
|
7090
|
+
if (convos && lodash__default["default"].isArray(convos)) {
|
|
6863
7091
|
for (let i = 0; i < convos.length; i++) {
|
|
6864
7092
|
const convo = convos[i];
|
|
6865
7093
|
this.AddPartialConvos(convo);
|
|
@@ -6888,14 +7116,14 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6888
7116
|
}
|
|
6889
7117
|
|
|
6890
7118
|
AddScriptingMemories(scriptingMemories) {
|
|
6891
|
-
if (scriptingMemories && lodash__default[
|
|
7119
|
+
if (scriptingMemories && lodash__default["default"].isArray(scriptingMemories)) {
|
|
6892
7120
|
for (let i = 0; i < scriptingMemories.length; i++) {
|
|
6893
7121
|
const scriptingMemory = scriptingMemories[i];
|
|
6894
7122
|
this.AddScriptingMemories(scriptingMemory);
|
|
6895
7123
|
}
|
|
6896
7124
|
} else if (scriptingMemories) {
|
|
6897
7125
|
if (!scriptingMemories.header || !scriptingMemories.header.name) {
|
|
6898
|
-
throw new BotiumError$
|
|
7126
|
+
throw new BotiumError$2('Scripting Memory Definition has no name', {
|
|
6899
7127
|
type: 'Compiler',
|
|
6900
7128
|
subtype: 'Scripting memory without name',
|
|
6901
7129
|
source: 'ScriptingProvider',
|
|
@@ -6906,7 +7134,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6906
7134
|
}
|
|
6907
7135
|
|
|
6908
7136
|
if (!scriptingMemories.values || !Object.keys(scriptingMemories.values).length) {
|
|
6909
|
-
throw new BotiumError$
|
|
7137
|
+
throw new BotiumError$2('Scripting Memory Definition has no variables', {
|
|
6910
7138
|
type: 'Compiler',
|
|
6911
7139
|
subtype: 'Scripting memory without variable',
|
|
6912
7140
|
source: 'ScriptingProvider',
|
|
@@ -6916,8 +7144,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6916
7144
|
});
|
|
6917
7145
|
}
|
|
6918
7146
|
|
|
6919
|
-
if (scriptingMemories.values && !lodash__default[
|
|
6920
|
-
throw new BotiumError$
|
|
7147
|
+
if (scriptingMemories.values && !lodash__default["default"].isUndefined(scriptingMemories.values[''])) {
|
|
7148
|
+
throw new BotiumError$2('Scripting Memory Definition variable has no name', {
|
|
6921
7149
|
type: 'Compiler',
|
|
6922
7150
|
subtype: 'Scripting memory without variable name',
|
|
6923
7151
|
source: 'ScriptingProvider',
|
|
@@ -6983,9 +7211,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6983
7211
|
let currentChildren = root;
|
|
6984
7212
|
|
|
6985
7213
|
for (const convoNode of convoNodes) {
|
|
6986
|
-
const convoNodeValues = convoNode.sender === 'me' ? convoNode.convoSteps.map(convoStep => lodash__default[
|
|
7214
|
+
const convoNodeValues = convoNode.sender === 'me' ? convoNode.convoSteps.map(convoStep => lodash__default["default"].pick(convoStep, pickMeNodeProps)) : convoNode.convoSteps.map(convoStep => lodash__default["default"].pick(convoStep, pickBotNodeProps));
|
|
6987
7215
|
const convoNodeHeader = {
|
|
6988
|
-
header: lodash__default[
|
|
7216
|
+
header: lodash__default["default"].pick(convo.header, ['name', 'description']),
|
|
6989
7217
|
sourceTag: convo.sourceTag,
|
|
6990
7218
|
convoStepIndices: convoNode.convoStepIndices
|
|
6991
7219
|
};
|
|
@@ -6996,16 +7224,16 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6996
7224
|
|
|
6997
7225
|
if (!hash) {
|
|
6998
7226
|
if (convoNode.sender === 'bot') {
|
|
6999
|
-
hash = crypto__default[
|
|
7227
|
+
hash = crypto__default["default"].createHash('md5').update(JSON.stringify(convoNode.convoSteps.map(convoStep => lodash__default["default"].pick(convoStep, pickBotHashProps)))).digest('hex');
|
|
7000
7228
|
} else {
|
|
7001
|
-
hash = crypto__default[
|
|
7229
|
+
hash = crypto__default["default"].createHash('md5').update(JSON.stringify(convoNode.convoSteps.map(convoStep => lodash__default["default"].pick(convoStep, pickMeHashProps)))).digest('hex');
|
|
7002
7230
|
}
|
|
7003
7231
|
}
|
|
7004
7232
|
|
|
7005
7233
|
const existingChildNode = currentChildren.find(c => c.hash === hash);
|
|
7006
7234
|
|
|
7007
7235
|
if (existingChildNode) {
|
|
7008
|
-
existingChildNode.convos.push(lodash__default[
|
|
7236
|
+
existingChildNode.convos.push(lodash__default["default"].cloneDeep(convoNodeHeader));
|
|
7009
7237
|
currentChildren = existingChildNode.childNodes;
|
|
7010
7238
|
continue;
|
|
7011
7239
|
}
|
|
@@ -7024,7 +7252,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7024
7252
|
if (existingConvo) {
|
|
7025
7253
|
existingConvo.convoStepIndices = [...existingConvo.convoStepIndices, ...convoNodeHeader.convoStepIndices];
|
|
7026
7254
|
} else {
|
|
7027
|
-
existingBotNode.convos.push(lodash__default[
|
|
7255
|
+
existingBotNode.convos.push(lodash__default["default"].cloneDeep(convoNodeHeader));
|
|
7028
7256
|
}
|
|
7029
7257
|
|
|
7030
7258
|
currentChildren = existingBotNode.childNodes;
|
|
@@ -7033,10 +7261,10 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7033
7261
|
|
|
7034
7262
|
const node = {
|
|
7035
7263
|
sender: convoNode.sender,
|
|
7036
|
-
key: randomatic__default[
|
|
7264
|
+
key: randomatic__default["default"]('0', 20),
|
|
7037
7265
|
hash: hash,
|
|
7038
7266
|
convoNodes: convoNodeValues,
|
|
7039
|
-
convos: [lodash__default[
|
|
7267
|
+
convos: [lodash__default["default"].cloneDeep(convoNodeHeader)],
|
|
7040
7268
|
childNodes: []
|
|
7041
7269
|
};
|
|
7042
7270
|
|
|
@@ -7115,7 +7343,7 @@ var NoRepo_1 = class NoRepo extends BaseRepo_1 {
|
|
|
7115
7343
|
};
|
|
7116
7344
|
|
|
7117
7345
|
var ProcessUtils = createCommonjsModule(function (module) {
|
|
7118
|
-
const debug = debug__default[
|
|
7346
|
+
const debug = debug__default["default"]('botium-core-ProcessUtils');
|
|
7119
7347
|
module.exports = {
|
|
7120
7348
|
childCommandLineRun: (cmd, ignoreErrors = false, processOptions = {}) => {
|
|
7121
7349
|
const cmdOptions = cmd.split(' ');
|
|
@@ -7125,8 +7353,8 @@ var ProcessUtils = createCommonjsModule(function (module) {
|
|
|
7125
7353
|
},
|
|
7126
7354
|
childProcessRun: (cmd, cmdOptions, ignoreErrors = false, processOptions = {}) => {
|
|
7127
7355
|
return new Promise((resolve, reject) => {
|
|
7128
|
-
debug('Running Command: ' + cmd + ' ' + lodash__default[
|
|
7129
|
-
const runningProcess = child_process__default[
|
|
7356
|
+
debug('Running Command: ' + cmd + ' ' + lodash__default["default"].join(cmdOptions, ' '));
|
|
7357
|
+
const runningProcess = child_process__default["default"].spawn(cmd, cmdOptions, processOptions);
|
|
7130
7358
|
const stdout = [];
|
|
7131
7359
|
const stderr = [];
|
|
7132
7360
|
runningProcess.stdout.on('data', data => {
|
|
@@ -7157,7 +7385,7 @@ var ProcessUtils = createCommonjsModule(function (module) {
|
|
|
7157
7385
|
if (ignoreErrors) {
|
|
7158
7386
|
resolve();
|
|
7159
7387
|
} else {
|
|
7160
|
-
reject(new Error(`${cmd} failed: ${util__default[
|
|
7388
|
+
reject(new Error(`${cmd} failed: ${util__default["default"].inspect(err)}`));
|
|
7161
7389
|
}
|
|
7162
7390
|
});
|
|
7163
7391
|
});
|
|
@@ -7167,7 +7395,7 @@ var ProcessUtils = createCommonjsModule(function (module) {
|
|
|
7167
7395
|
ProcessUtils.childCommandLineRun;
|
|
7168
7396
|
ProcessUtils.childProcessRun;
|
|
7169
7397
|
|
|
7170
|
-
const debug$8 = debug__default[
|
|
7398
|
+
const debug$8 = debug__default["default"]('botium-core-GitRepo');
|
|
7171
7399
|
var GitRepo_1 = class GitRepo extends BaseRepo_1 {
|
|
7172
7400
|
Validate() {
|
|
7173
7401
|
return super.Validate().then(() => {
|
|
@@ -7183,9 +7411,9 @@ var GitRepo_1 = class GitRepo extends BaseRepo_1 {
|
|
|
7183
7411
|
|
|
7184
7412
|
Prepare() {
|
|
7185
7413
|
return new Promise((resolve, reject) => {
|
|
7186
|
-
async__default[
|
|
7187
|
-
this.workingDirectory = path__default[
|
|
7188
|
-
mkdirp__default[
|
|
7414
|
+
async__default["default"].series([cloneDirectoryCreated => {
|
|
7415
|
+
this.workingDirectory = path__default["default"].resolve(this.tempDirectory, 'git');
|
|
7416
|
+
mkdirp__default["default"](this.workingDirectory, err => {
|
|
7189
7417
|
if (err) {
|
|
7190
7418
|
return cloneDirectoryCreated(new Error(`Unable to create clone directory ${this.workingDirectory}: ${err}`));
|
|
7191
7419
|
}
|
|
@@ -7198,7 +7426,7 @@ var GitRepo_1 = class GitRepo extends BaseRepo_1 {
|
|
|
7198
7426
|
cwd: this.workingDirectory
|
|
7199
7427
|
}).then(() => cloneReady()).catch(cloneReady);
|
|
7200
7428
|
}, workingDirectoryChanged => {
|
|
7201
|
-
this.workingDirectory = path__default[
|
|
7429
|
+
this.workingDirectory = path__default["default"].resolve(this.workingDirectory, this.sources[Source.GITDIR]);
|
|
7202
7430
|
workingDirectoryChanged();
|
|
7203
7431
|
}, prepareReady => {
|
|
7204
7432
|
if (this.sources[Source.GITPREPARECMD]) {
|
|
@@ -7227,13 +7455,13 @@ var LocalRepo_1 = class LocalRepo extends BaseRepo_1 {
|
|
|
7227
7455
|
this._AssertSourceExists(Source.LOCALPATH);
|
|
7228
7456
|
|
|
7229
7457
|
const checkPath = this.sources[Source.LOCALPATH];
|
|
7230
|
-
fs__default[
|
|
7458
|
+
fs__default["default"].stat(checkPath, (err, stats) => {
|
|
7231
7459
|
if (err) {
|
|
7232
7460
|
throw new Error(`${checkPath} not available: ${err}`);
|
|
7233
7461
|
}
|
|
7234
7462
|
|
|
7235
7463
|
if (stats.isDirectory() && !stats.isSymbolicLink()) {
|
|
7236
|
-
fs__default[
|
|
7464
|
+
fs__default["default"].access(checkPath, fs__default["default"].constants.W_OK, err1 => {
|
|
7237
7465
|
if (err) {
|
|
7238
7466
|
throw new Error(`${checkPath} not writeable: ${err}`);
|
|
7239
7467
|
}
|
|
@@ -7247,7 +7475,7 @@ var LocalRepo_1 = class LocalRepo extends BaseRepo_1 {
|
|
|
7247
7475
|
|
|
7248
7476
|
Prepare() {
|
|
7249
7477
|
// No need to prepare anything
|
|
7250
|
-
this.workingDirectory = path__default[
|
|
7478
|
+
this.workingDirectory = path__default["default"].resolve(this.sources[Source.LOCALPATH]);
|
|
7251
7479
|
return Promise.resolve();
|
|
7252
7480
|
}
|
|
7253
7481
|
|
|
@@ -7311,7 +7539,7 @@ var Queue_1 = class Queue {
|
|
|
7311
7539
|
|
|
7312
7540
|
return new Promise((resolve, reject) => {
|
|
7313
7541
|
let listener = null;
|
|
7314
|
-
const timeoutRequest = async__default[
|
|
7542
|
+
const timeoutRequest = async__default["default"].timeout(timeoutCallback => {
|
|
7315
7543
|
listener = msg => {
|
|
7316
7544
|
timeoutCallback(null, msg);
|
|
7317
7545
|
};
|
|
@@ -7324,7 +7552,7 @@ var Queue_1 = class Queue {
|
|
|
7324
7552
|
reject(new QueueTimeoutError_1(timeoutMillis));
|
|
7325
7553
|
} else if (err) {
|
|
7326
7554
|
this.listeners.splice(this.listeners.indexOf(listener), 1);
|
|
7327
|
-
reject(new Error(`Queue pop error ${util__default[
|
|
7555
|
+
reject(new Error(`Queue pop error ${util__default["default"].inspect(err)}`));
|
|
7328
7556
|
} else {
|
|
7329
7557
|
resolve(msg);
|
|
7330
7558
|
}
|
|
@@ -7338,7 +7566,7 @@ var Queue_1 = class Queue {
|
|
|
7338
7566
|
|
|
7339
7567
|
};
|
|
7340
7568
|
|
|
7341
|
-
const debug$7 = debug__default[
|
|
7569
|
+
const debug$7 = debug__default["default"]('botium-connector-BaseContainer');
|
|
7342
7570
|
const {
|
|
7343
7571
|
executeHook: executeHook$1,
|
|
7344
7572
|
getHook: getHook$1
|
|
@@ -7370,8 +7598,8 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7370
7598
|
const opts = {};
|
|
7371
7599
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT]) opts.maxConcurrent = this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT];
|
|
7372
7600
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) opts.minTime = this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME];
|
|
7373
|
-
this.userSaysLimiter = new bottleneck__default[
|
|
7374
|
-
debug$7(`Build: Applying userSays rate limits ${util__default[
|
|
7601
|
+
this.userSaysLimiter = new bottleneck__default["default"](opts);
|
|
7602
|
+
debug$7(`Build: Applying userSays rate limits ${util__default["default"].inspect(opts)}`);
|
|
7375
7603
|
}
|
|
7376
7604
|
|
|
7377
7605
|
return new Promise((resolve, reject) => {
|
|
@@ -7420,7 +7648,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7420
7648
|
|
|
7421
7649
|
return new Promise((resolve, reject) => {
|
|
7422
7650
|
this.queues[channel].pop(timeoutMillis).then(botMsg => {
|
|
7423
|
-
if (lodash__default[
|
|
7651
|
+
if (lodash__default["default"].isError(botMsg)) {
|
|
7424
7652
|
reject(botMsg);
|
|
7425
7653
|
} else {
|
|
7426
7654
|
resolve(botMsg);
|
|
@@ -7455,14 +7683,14 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7455
7683
|
Clean() {
|
|
7456
7684
|
this.userSaysLimiter = null;
|
|
7457
7685
|
return new Promise((resolve, reject) => {
|
|
7458
|
-
async__default[
|
|
7686
|
+
async__default["default"].series([hookExecuted => {
|
|
7459
7687
|
this._RunCustomHook('onClean', this.onCleanHook).then(() => hookExecuted()).catch(() => hookExecuted());
|
|
7460
7688
|
}, cleanupTasksDone => {
|
|
7461
7689
|
if (this.cleanupTasks) {
|
|
7462
|
-
async__default[
|
|
7690
|
+
async__default["default"].series(this.cleanupTasks.map(task => {
|
|
7463
7691
|
return cb => {
|
|
7464
7692
|
task(err => {
|
|
7465
|
-
if (err) debug$7(`Cleanup failed: ${util__default[
|
|
7693
|
+
if (err) debug$7(`Cleanup failed: ${util__default["default"].inspect(err)}`);
|
|
7466
7694
|
cb();
|
|
7467
7695
|
});
|
|
7468
7696
|
};
|
|
@@ -7475,8 +7703,8 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7475
7703
|
}, rimraffed => {
|
|
7476
7704
|
if (this.caps[Capabilities.CLEANUPTEMPDIR]) {
|
|
7477
7705
|
debug$7(`Cleanup rimrafing temp dir ${this.tempDirectory}`);
|
|
7478
|
-
rimraf__default[
|
|
7479
|
-
if (err) debug$7(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default[
|
|
7706
|
+
rimraf__default["default"](this.tempDirectory, err => {
|
|
7707
|
+
if (err) debug$7(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default["default"].inspect(err)}`);
|
|
7480
7708
|
rimraffed();
|
|
7481
7709
|
});
|
|
7482
7710
|
} else {
|
|
@@ -7484,7 +7712,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7484
7712
|
}
|
|
7485
7713
|
}], err => {
|
|
7486
7714
|
if (err) {
|
|
7487
|
-
return reject(new Error(`Cleanup failed ${util__default[
|
|
7715
|
+
return reject(new Error(`Cleanup failed ${util__default["default"].inspect(err)}`));
|
|
7488
7716
|
}
|
|
7489
7717
|
|
|
7490
7718
|
resolve();
|
|
@@ -7518,7 +7746,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7518
7746
|
}
|
|
7519
7747
|
|
|
7520
7748
|
async _QueueBotSays(botMsg) {
|
|
7521
|
-
if (lodash__default[
|
|
7749
|
+
if (lodash__default["default"].isError(botMsg)) {
|
|
7522
7750
|
if (!this.queues.default) {
|
|
7523
7751
|
this.queues.default = new Queue_1();
|
|
7524
7752
|
}
|
|
@@ -7545,16 +7773,16 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7545
7773
|
try {
|
|
7546
7774
|
await executeHook$1(this.caps, hook, Object.assign({
|
|
7547
7775
|
container: this,
|
|
7548
|
-
request: request__default[
|
|
7776
|
+
request: request__default["default"]
|
|
7549
7777
|
}, args));
|
|
7550
7778
|
} catch (err) {
|
|
7551
|
-
debug$7(`_RunCustomHook ${name} finished with error: ${err.message || util__default[
|
|
7779
|
+
debug$7(`_RunCustomHook ${name} finished with error: ${err.message || util__default["default"].inspect(err)}`);
|
|
7552
7780
|
}
|
|
7553
7781
|
}
|
|
7554
7782
|
|
|
7555
7783
|
};
|
|
7556
7784
|
|
|
7557
|
-
const debug$6 = debug__default[
|
|
7785
|
+
const debug$6 = debug__default["default"]('botium-connector-GridContainer');
|
|
7558
7786
|
var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
7559
7787
|
Validate() {
|
|
7560
7788
|
return super.Validate().then(() => {
|
|
@@ -7564,10 +7792,10 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7564
7792
|
|
|
7565
7793
|
Build() {
|
|
7566
7794
|
this.buildPromise = this._defer();
|
|
7567
|
-
async__default[
|
|
7795
|
+
async__default["default"].series([baseComplete => {
|
|
7568
7796
|
super.Build().then(() => baseComplete()).catch(baseComplete);
|
|
7569
7797
|
}, socketComplete => {
|
|
7570
|
-
this.socket = socket__default[
|
|
7798
|
+
this.socket = socket__default["default"](this.caps[Capabilities.BOTIUMGRIDURL]);
|
|
7571
7799
|
this.socket.on('connect', () => {
|
|
7572
7800
|
debug$6('connected');
|
|
7573
7801
|
this.socket.emit('authentication', {
|
|
@@ -7578,7 +7806,7 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7578
7806
|
debug$6(`connect_error ${err.message}`);
|
|
7579
7807
|
});
|
|
7580
7808
|
this.socket.on('connect_timeout', timeout => {
|
|
7581
|
-
debug$6(`connect_timeout ${util__default[
|
|
7809
|
+
debug$6(`connect_timeout ${util__default["default"].inspect(timeout)}`);
|
|
7582
7810
|
});
|
|
7583
7811
|
this.socket.on('error', err => {
|
|
7584
7812
|
debug$6(`error ${err.message}`);
|
|
@@ -7622,7 +7850,7 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7622
7850
|
}
|
|
7623
7851
|
});
|
|
7624
7852
|
this.socket.on(Events.MESSAGE_RECEIVEDFROMBOT, botMsg => {
|
|
7625
|
-
debug$6(`MESSAGE_RECEIVEDFROMBOT ${util__default[
|
|
7853
|
+
debug$6(`MESSAGE_RECEIVEDFROMBOT ${util__default["default"].inspect(botMsg)}`);
|
|
7626
7854
|
|
|
7627
7855
|
this._QueueBotSays(new BotiumMockMessage_1(botMsg));
|
|
7628
7856
|
});
|
|
@@ -7741,7 +7969,7 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7741
7969
|
|
|
7742
7970
|
_ValidateCustomHook(capKey) {
|
|
7743
7971
|
if (this.caps[capKey]) {
|
|
7744
|
-
if (!lodash__default[
|
|
7972
|
+
if (!lodash__default["default"].isString(this.caps[capKey])) {
|
|
7745
7973
|
throw new Error(`Custom Hook ${capKey} has to be a command line string`);
|
|
7746
7974
|
}
|
|
7747
7975
|
}
|
|
@@ -7778,10 +8006,10 @@ var InProcessContainer_1 = class InProcessContainer extends BaseContainer_1 {
|
|
|
7778
8006
|
|
|
7779
8007
|
};
|
|
7780
8008
|
|
|
7781
|
-
const debug$5 = debug__default[
|
|
8009
|
+
const debug$5 = debug__default["default"]('botium-core-inbound-proxy');
|
|
7782
8010
|
|
|
7783
8011
|
const buildRedisHandler = (redisurl, topic) => {
|
|
7784
|
-
const redis = new ioredis__default[
|
|
8012
|
+
const redis = new ioredis__default["default"](redisurl);
|
|
7785
8013
|
redis.on('connect', () => {
|
|
7786
8014
|
debug$5(`Redis connected to ${JSON.stringify(redisurl || 'default')}`);
|
|
7787
8015
|
});
|
|
@@ -7832,10 +8060,10 @@ const startProxy$1 = async ({
|
|
|
7832
8060
|
processEvent
|
|
7833
8061
|
}) => {
|
|
7834
8062
|
return new Promise((resolve, reject) => {
|
|
7835
|
-
const app = express__default[
|
|
8063
|
+
const app = express__default["default"]();
|
|
7836
8064
|
setupEndpoints({
|
|
7837
8065
|
app,
|
|
7838
|
-
middleware: [bodyParser__default[
|
|
8066
|
+
middleware: [bodyParser__default["default"].json(), bodyParser__default["default"].urlencoded({
|
|
7839
8067
|
extended: true
|
|
7840
8068
|
})],
|
|
7841
8069
|
endpoint: endpoint || '/',
|
|
@@ -7860,8 +8088,8 @@ proxy.startProxy;
|
|
|
7860
8088
|
|
|
7861
8089
|
const {
|
|
7862
8090
|
v4: uuidv4
|
|
7863
|
-
} = uuid__default[
|
|
7864
|
-
const debug$4 = debug__default[
|
|
8091
|
+
} = uuid__default["default"];
|
|
8092
|
+
const debug$4 = debug__default["default"]('botium-connector-simplerest');
|
|
7865
8093
|
const {
|
|
7866
8094
|
startProxy
|
|
7867
8095
|
} = proxy;
|
|
@@ -7879,8 +8107,11 @@ const {
|
|
|
7879
8107
|
const {
|
|
7880
8108
|
escapeJSONString
|
|
7881
8109
|
} = Utils;
|
|
8110
|
+
const {
|
|
8111
|
+
BotiumError: BotiumError$1
|
|
8112
|
+
} = BotiumError_1;
|
|
7882
8113
|
|
|
7883
|
-
mustache__default[
|
|
8114
|
+
mustache__default["default"].escape = s => s;
|
|
7884
8115
|
|
|
7885
8116
|
var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
7886
8117
|
constructor({
|
|
@@ -7895,14 +8126,14 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7895
8126
|
if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
|
|
7896
8127
|
const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
|
|
7897
8128
|
this.inboundEvents = [];
|
|
7898
|
-
this._processOrderedInboundEventsArrayAsync = lodash__default[
|
|
8129
|
+
this._processOrderedInboundEventsArrayAsync = lodash__default["default"].debounce(() => {
|
|
7899
8130
|
const events = [...this.inboundEvents];
|
|
7900
8131
|
this.inboundEvents = [];
|
|
7901
8132
|
|
|
7902
8133
|
const jsonPath = this._getMustachedVal(this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH], false);
|
|
7903
8134
|
|
|
7904
|
-
const sortedEvents = lodash__default[
|
|
7905
|
-
const qr = jsonpath__default[
|
|
8135
|
+
const sortedEvents = lodash__default["default"].sortBy(events, event => {
|
|
8136
|
+
const qr = jsonpath__default["default"].query(event, jsonPath);
|
|
7906
8137
|
return qr[0];
|
|
7907
8138
|
});
|
|
7908
8139
|
|
|
@@ -7916,10 +8147,10 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7916
8147
|
Validate() {
|
|
7917
8148
|
if (!this.caps[Capabilities.SIMPLEREST_URL]) throw new Error('SIMPLEREST_URL capability required');
|
|
7918
8149
|
if (!this.caps[Capabilities.SIMPLEREST_METHOD] && !this.caps[Capabilities.SIMPLEREST_VERB]) throw new Error('SIMPLEREST_METHOD/SIMPLEREST_VERB capability required');
|
|
7919
|
-
if (lodash__default[
|
|
8150
|
+
if (lodash__default["default"].keys(this.caps).findIndex(k => k.startsWith(Capabilities.SIMPLEREST_RESPONSE_JSONPATH)) < 0 && !this.caps[Capabilities.SIMPLEREST_RESPONSE_HOOK]) throw new Error('SIMPLEREST_RESPONSE_JSONPATH or SIMPLEREST_RESPONSE_HOOK capability required');
|
|
7920
8151
|
|
|
7921
8152
|
if (this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) {
|
|
7922
|
-
lodash__default[
|
|
8153
|
+
lodash__default["default"].isObject(this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) || JSON.parse(this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]);
|
|
7923
8154
|
}
|
|
7924
8155
|
|
|
7925
8156
|
if (this.caps[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE] !== 'MERGE' && this.caps[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE] !== 'REPLACE') throw new Error('SIMPLEREST_CONTEXT_MERGE_OR_REPLACE capability only MERGE or REPLACE allowed');
|
|
@@ -7950,7 +8181,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7950
8181
|
|
|
7951
8182
|
Start() {
|
|
7952
8183
|
return new Promise((resolve, reject) => {
|
|
7953
|
-
async__default[
|
|
8184
|
+
async__default["default"].series([contextInitComplete => {
|
|
7954
8185
|
this.view = {
|
|
7955
8186
|
container: this,
|
|
7956
8187
|
context: {},
|
|
@@ -7965,7 +8196,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7965
8196
|
// (render(text) is required for forcing mustache to replace valiables in the text first,
|
|
7966
8197
|
// then send it to the function.)
|
|
7967
8198
|
// (mapKeys: remove starting $)
|
|
7968
|
-
fnc: lodash__default[
|
|
8199
|
+
fnc: lodash__default["default"].mapValues(lodash__default["default"].mapKeys(SCRIPTING_FUNCTIONS, (value, key) => key.substring(1)), descriptor => {
|
|
7969
8200
|
const safeCaps = Object.assign({}, this.caps, {
|
|
7970
8201
|
[Capabilities.SECURITY_ALLOW_UNSAFE]: true
|
|
7971
8202
|
});
|
|
@@ -7987,7 +8218,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7987
8218
|
|
|
7988
8219
|
if (this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) {
|
|
7989
8220
|
try {
|
|
7990
|
-
this.view.context = lodash__default[
|
|
8221
|
+
this.view.context = lodash__default["default"].isObject(this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) ? lodash__default["default"].cloneDeep(this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) : JSON.parse(this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]);
|
|
7991
8222
|
} catch (err) {
|
|
7992
8223
|
contextInitComplete(`parsing SIMPLEREST_INIT_CONTEXT failed, no JSON detected (${err.message})`);
|
|
7993
8224
|
}
|
|
@@ -8024,7 +8255,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8024
8255
|
pingComplete();
|
|
8025
8256
|
}
|
|
8026
8257
|
}, initComplete => {
|
|
8027
|
-
if (lodash__default[
|
|
8258
|
+
if (lodash__default["default"].isString(this.caps[Capabilities.SIMPLEREST_INIT_TEXT])) {
|
|
8028
8259
|
this._doRequest({
|
|
8029
8260
|
messageText: this.caps[Capabilities.SIMPLEREST_INIT_TEXT]
|
|
8030
8261
|
}, !!this.caps[Capabilities.SIMPLEREST_INIT_PROCESS_RESPONSE], true).then(() => initComplete()).catch(initComplete);
|
|
@@ -8133,9 +8364,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8133
8364
|
|
|
8134
8365
|
if (jsonPathsContext.length > 0) {
|
|
8135
8366
|
for (const jsonPathContext of jsonPathsContext) {
|
|
8136
|
-
const contextNodes = jsonpath__default[
|
|
8367
|
+
const contextNodes = jsonpath__default["default"].query(body, jsonPathContext);
|
|
8137
8368
|
|
|
8138
|
-
if (lodash__default[
|
|
8369
|
+
if (lodash__default["default"].isArray(contextNodes) && contextNodes.length > 0) {
|
|
8139
8370
|
if (mergeMode === 'MERGE') {
|
|
8140
8371
|
Object.assign(this.view.context, contextNodes[0]);
|
|
8141
8372
|
} else if (mergeMode === 'REPLACE') {
|
|
@@ -8151,7 +8382,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8151
8382
|
}
|
|
8152
8383
|
}
|
|
8153
8384
|
|
|
8154
|
-
debug$4(`current session context: ${util__default[
|
|
8385
|
+
debug$4(`current session context: ${util__default["default"].inspect(this.view.context)}`);
|
|
8155
8386
|
}
|
|
8156
8387
|
|
|
8157
8388
|
const result = [];
|
|
@@ -8162,9 +8393,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8162
8393
|
|
|
8163
8394
|
if (jsonPathsBody.length > 0) {
|
|
8164
8395
|
for (const jsonPathBody of jsonPathsBody) {
|
|
8165
|
-
const rb = jsonpath__default[
|
|
8396
|
+
const rb = jsonpath__default["default"].query(body, jsonPathBody);
|
|
8166
8397
|
|
|
8167
|
-
if (lodash__default[
|
|
8398
|
+
if (lodash__default["default"].isArray(rb)) {
|
|
8168
8399
|
rb.forEach(r => jsonPathRoots.push(r));
|
|
8169
8400
|
} else if (rb) {
|
|
8170
8401
|
jsonPathRoots.push(rb);
|
|
@@ -8179,25 +8410,25 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8179
8410
|
const buttons = [];
|
|
8180
8411
|
const jsonPathsMedia = getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps);
|
|
8181
8412
|
jsonPathsMedia.forEach(jsonPath => {
|
|
8182
|
-
const responseMedia = jsonpath__default[
|
|
8413
|
+
const responseMedia = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
|
|
8183
8414
|
|
|
8184
8415
|
if (responseMedia) {
|
|
8185
|
-
(lodash__default[
|
|
8416
|
+
(lodash__default["default"].isArray(responseMedia) ? lodash__default["default"].flattenDeep(responseMedia) : [responseMedia]).forEach(m => media.push({
|
|
8186
8417
|
mediaUri: m,
|
|
8187
|
-
mimeType: mimeTypes__default[
|
|
8418
|
+
mimeType: mimeTypes__default["default"].lookup(m) || 'application/unknown'
|
|
8188
8419
|
}));
|
|
8189
|
-
debug$4(`found response media: ${util__default[
|
|
8420
|
+
debug$4(`found response media: ${util__default["default"].inspect(media)}`);
|
|
8190
8421
|
}
|
|
8191
8422
|
});
|
|
8192
8423
|
const jsonPathsButtons = getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps);
|
|
8193
8424
|
jsonPathsButtons.forEach(jsonPath => {
|
|
8194
|
-
const responseButtons = jsonpath__default[
|
|
8425
|
+
const responseButtons = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
|
|
8195
8426
|
|
|
8196
8427
|
if (responseButtons) {
|
|
8197
|
-
(lodash__default[
|
|
8428
|
+
(lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => buttons.push({
|
|
8198
8429
|
text: b
|
|
8199
8430
|
}));
|
|
8200
|
-
debug$4(`found response buttons: ${util__default[
|
|
8431
|
+
debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
|
|
8201
8432
|
}
|
|
8202
8433
|
});
|
|
8203
8434
|
let hasMessageText = false;
|
|
@@ -8205,9 +8436,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8205
8436
|
|
|
8206
8437
|
for (const jsonPath of jsonPathsTexts) {
|
|
8207
8438
|
debug$4(`eval json path ${jsonPath}`);
|
|
8208
|
-
const responseTexts = jsonpath__default[
|
|
8209
|
-
debug$4(`found response texts: ${util__default[
|
|
8210
|
-
const messageTexts = lodash__default[
|
|
8439
|
+
const responseTexts = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
|
|
8440
|
+
debug$4(`found response texts: ${util__default["default"].inspect(responseTexts)}`);
|
|
8441
|
+
const messageTexts = lodash__default["default"].isArray(responseTexts) ? lodash__default["default"].flattenDeep(responseTexts) : [responseTexts];
|
|
8211
8442
|
|
|
8212
8443
|
for (const [messageTextIndex, messageText] of messageTexts.entries()) {
|
|
8213
8444
|
if (!messageText) continue;
|
|
@@ -8257,12 +8488,28 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8257
8488
|
msg.sourceData = msg.sourceData || {};
|
|
8258
8489
|
msg.sourceData.requestOptions = requestOptions;
|
|
8259
8490
|
this.waitProcessQueue = [];
|
|
8260
|
-
request__default[
|
|
8491
|
+
request__default["default"](requestOptions, async (err, response, body) => {
|
|
8261
8492
|
if (err) {
|
|
8262
8493
|
return reject(new Error(`rest request failed: ${err.message}`));
|
|
8263
8494
|
} else {
|
|
8264
8495
|
if (response.statusCode >= 400) {
|
|
8265
8496
|
debug$4(`got error response: ${response.statusCode}/${response.statusMessage}`);
|
|
8497
|
+
|
|
8498
|
+
if (debug$4.enabled && body) {
|
|
8499
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8500
|
+
}
|
|
8501
|
+
|
|
8502
|
+
if (body) {
|
|
8503
|
+
const jsonBody = Utils.toJsonWeak(body);
|
|
8504
|
+
const errKey = Object.keys(jsonBody).find(k => k.startsWith('err') || k.startsWith('fail'));
|
|
8505
|
+
|
|
8506
|
+
if (errKey) {
|
|
8507
|
+
return reject(new BotiumError$1(`got error response: ${response.statusCode}/${response.statusMessage} - ${jsonBody[errKey]}`, {
|
|
8508
|
+
message: Utils.shortenJsonString(body)
|
|
8509
|
+
}));
|
|
8510
|
+
}
|
|
8511
|
+
}
|
|
8512
|
+
|
|
8266
8513
|
return reject(new Error(`got error response: ${response.statusCode}/${response.statusMessage}`));
|
|
8267
8514
|
}
|
|
8268
8515
|
|
|
@@ -8351,7 +8598,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8351
8598
|
this.view.msg.messageText = nonEncodedMessage;
|
|
8352
8599
|
|
|
8353
8600
|
if (msg.ADD_QUERY_PARAM && Object.keys(msg.ADD_QUERY_PARAM).length > 0) {
|
|
8354
|
-
const appendToUri = Object.keys(msg.ADD_QUERY_PARAM).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(this._getMustachedVal(lodash__default[
|
|
8601
|
+
const appendToUri = Object.keys(msg.ADD_QUERY_PARAM).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(this._getMustachedVal(lodash__default["default"].isString(msg.ADD_QUERY_PARAM[key]) ? msg.ADD_QUERY_PARAM[key] : JSON.stringify(msg.ADD_QUERY_PARAM[key]), false))}`).join('&');
|
|
8355
8602
|
|
|
8356
8603
|
if (requestOptions.uri.indexOf('?') > 0) {
|
|
8357
8604
|
requestOptions.uri = `${requestOptions.uri}&${appendToUri}`;
|
|
@@ -8360,13 +8607,23 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8360
8607
|
}
|
|
8361
8608
|
}
|
|
8362
8609
|
|
|
8610
|
+
if (msg.ADD_FORM_PARAM && Object.keys(msg.ADD_FORM_PARAM).length > 0) {
|
|
8611
|
+
requestOptions.form = {};
|
|
8612
|
+
|
|
8613
|
+
for (const formKey of Object.keys(msg.ADD_FORM_PARAM)) {
|
|
8614
|
+
const formValue = this._getMustachedVal(lodash__default["default"].isString(msg.ADD_FORM_PARAM[formKey]) ? msg.ADD_FORM_PARAM[formKey] : JSON.stringify(msg.ADD_FORM_PARAM[formKey]), false);
|
|
8615
|
+
|
|
8616
|
+
requestOptions.form[formKey] = formValue;
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
8619
|
+
|
|
8363
8620
|
if (msg.ADD_HEADER && Object.keys(msg.ADD_HEADER).length > 0) {
|
|
8364
8621
|
requestOptions.headers = requestOptions.headers || {};
|
|
8365
8622
|
|
|
8366
8623
|
for (const headerKey of Object.keys(msg.ADD_HEADER)) {
|
|
8367
8624
|
let headerValue;
|
|
8368
8625
|
|
|
8369
|
-
if (lodash__default[
|
|
8626
|
+
if (lodash__default["default"].isString(msg.ADD_HEADER[headerKey])) {
|
|
8370
8627
|
headerValue = this._getMustachedVal(msg.ADD_HEADER[headerKey], false);
|
|
8371
8628
|
} else {
|
|
8372
8629
|
headerValue = this._getMustachedVal(JSON.stringify(msg.ADD_HEADER[headerKey]), true);
|
|
@@ -8402,7 +8659,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8402
8659
|
response,
|
|
8403
8660
|
body
|
|
8404
8661
|
} = await new Promise(resolve => {
|
|
8405
|
-
request__default[
|
|
8662
|
+
request__default["default"](pingConfig, (err, response, body) => {
|
|
8406
8663
|
resolve({
|
|
8407
8664
|
err,
|
|
8408
8665
|
response,
|
|
@@ -8416,16 +8673,26 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8416
8673
|
await timeout(pingConfig.timeout);
|
|
8417
8674
|
} else if (response.statusCode >= 400) {
|
|
8418
8675
|
debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
|
|
8676
|
+
|
|
8677
|
+
if (debug$4.enabled && body) {
|
|
8678
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8679
|
+
}
|
|
8680
|
+
|
|
8419
8681
|
await timeout(pingConfig.timeout);
|
|
8420
8682
|
} else {
|
|
8421
|
-
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}`);
|
|
8683
|
+
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
|
|
8684
|
+
|
|
8685
|
+
if (debug$4.enabled && body) {
|
|
8686
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8687
|
+
}
|
|
8688
|
+
|
|
8422
8689
|
return body;
|
|
8423
8690
|
}
|
|
8424
8691
|
}
|
|
8425
8692
|
}
|
|
8426
8693
|
|
|
8427
8694
|
async _parseResponseBody(body) {
|
|
8428
|
-
if (!lodash__default[
|
|
8695
|
+
if (!lodash__default["default"].isObject(body) && lodash__default["default"].isString(body)) {
|
|
8429
8696
|
try {
|
|
8430
8697
|
body = JSON.parse(body);
|
|
8431
8698
|
} catch (err) {
|
|
@@ -8442,22 +8709,22 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8442
8709
|
}, this.view));
|
|
8443
8710
|
}
|
|
8444
8711
|
|
|
8445
|
-
if (lodash__default[
|
|
8712
|
+
if (lodash__default["default"].isObject(body)) return body;else if (lodash__default["default"].isString(body)) return JSON.parse(body);else return null;
|
|
8446
8713
|
}
|
|
8447
8714
|
|
|
8448
8715
|
_getCapValue(capName) {
|
|
8449
|
-
return lodash__default[
|
|
8716
|
+
return lodash__default["default"].isFunction(this.caps[capName]) ? this.caps[capName]() : this.caps[capName];
|
|
8450
8717
|
}
|
|
8451
8718
|
|
|
8452
8719
|
_getMustachedCap(capName, json) {
|
|
8453
8720
|
const capValue = this._getCapValue(capName);
|
|
8454
8721
|
|
|
8455
|
-
const template = lodash__default[
|
|
8722
|
+
const template = lodash__default["default"].isString(capValue) ? capValue : JSON.stringify(capValue);
|
|
8456
8723
|
return this._getMustachedVal(template, json);
|
|
8457
8724
|
}
|
|
8458
8725
|
|
|
8459
8726
|
_getMustachedVal(template, json) {
|
|
8460
|
-
const raw = mustache__default[
|
|
8727
|
+
const raw = mustache__default["default"].render(template, this.view);
|
|
8461
8728
|
|
|
8462
8729
|
if (json) {
|
|
8463
8730
|
try {
|
|
@@ -8481,7 +8748,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8481
8748
|
for (const jsonPathTemplate of jsonPathsSelector) {
|
|
8482
8749
|
const jsonPath = this._getMustachedVal(jsonPathTemplate, false);
|
|
8483
8750
|
|
|
8484
|
-
const hasResult = jsonpath__default[
|
|
8751
|
+
const hasResult = jsonpath__default["default"].query(event, jsonPath);
|
|
8485
8752
|
|
|
8486
8753
|
if (hasResult && hasResult.length > 0) {
|
|
8487
8754
|
const check = jsonPathValue && this._getMustachedVal(jsonPathValue, false);
|
|
@@ -8514,12 +8781,12 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8514
8781
|
|
|
8515
8782
|
async _buildInbound() {
|
|
8516
8783
|
if (this.caps[Capabilities.SIMPLEREST_INBOUND_REDISURL] && this.caps[Capabilities.SIMPLEREST_INBOUND_SELECTOR_JSONPATH] && this.caps[Capabilities.SIMPLEREST_INBOUND_SELECTOR_VALUE]) {
|
|
8517
|
-
this.redis = new ioredis__default[
|
|
8784
|
+
this.redis = new ioredis__default["default"](this.caps[Capabilities.SIMPLEREST_INBOUND_REDISURL]);
|
|
8518
8785
|
this.redis.on('connect', () => {
|
|
8519
8786
|
debug$4(`Redis connected to ${JSON.stringify(this.caps[Capabilities.SIMPLEREST_INBOUND_REDISURL] || 'default')}`);
|
|
8520
8787
|
});
|
|
8521
8788
|
this.redis.on('message', (channel, event) => {
|
|
8522
|
-
if (!lodash__default[
|
|
8789
|
+
if (!lodash__default["default"].isString(event)) {
|
|
8523
8790
|
return debug$4(`WARNING: received non-string message from ${channel}, ignoring: ${event}`);
|
|
8524
8791
|
}
|
|
8525
8792
|
|
|
@@ -8636,12 +8903,16 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8636
8903
|
return;
|
|
8637
8904
|
}
|
|
8638
8905
|
|
|
8639
|
-
request__default[
|
|
8906
|
+
request__default["default"](pollConfig, async (err, response, body) => {
|
|
8640
8907
|
if (err) {
|
|
8641
8908
|
debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
|
|
8642
8909
|
} else {
|
|
8643
8910
|
if (response.statusCode >= 400) {
|
|
8644
8911
|
debug$4(`_runPolling: got error response: ${response.statusCode}/${response.statusMessage}, request: ${JSON.stringify(pollConfig)}`);
|
|
8912
|
+
|
|
8913
|
+
if (debug$4.enabled && body) {
|
|
8914
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8915
|
+
}
|
|
8645
8916
|
} else if (body) {
|
|
8646
8917
|
debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8647
8918
|
|
|
@@ -8734,13 +9005,13 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8734
9005
|
}
|
|
8735
9006
|
|
|
8736
9007
|
if (this.caps[Capabilities.SIMPLEREST_EXTRA_OPTIONS]) {
|
|
8737
|
-
lodash__default[
|
|
9008
|
+
lodash__default["default"].merge(httpConfig, this.caps[Capabilities.SIMPLEREST_EXTRA_OPTIONS]);
|
|
8738
9009
|
}
|
|
8739
9010
|
}
|
|
8740
9011
|
|
|
8741
9012
|
};
|
|
8742
9013
|
|
|
8743
|
-
const debug$3 = debug__default[
|
|
9014
|
+
const debug$3 = debug__default["default"]('botium-connector-PluginConnectorContainer-helper');
|
|
8744
9015
|
const {
|
|
8745
9016
|
BotiumError
|
|
8746
9017
|
} = BotiumError_1;
|
|
@@ -8774,7 +9045,7 @@ const loadConnectorModule = (PluginClass, args) => {
|
|
|
8774
9045
|
return new PluginClass(args);
|
|
8775
9046
|
} catch (err) {}
|
|
8776
9047
|
|
|
8777
|
-
if (lodash__default[
|
|
9048
|
+
if (lodash__default["default"].isFunction(PluginClass)) {
|
|
8778
9049
|
const result = PluginClass(args);
|
|
8779
9050
|
|
|
8780
9051
|
if (result && result.UserSays) {
|
|
@@ -8785,7 +9056,7 @@ const loadConnectorModule = (PluginClass, args) => {
|
|
|
8785
9056
|
const response = PluginClass(msg, args);
|
|
8786
9057
|
|
|
8787
9058
|
if (response && args.queueBotSays) {
|
|
8788
|
-
if (lodash__default[
|
|
9059
|
+
if (lodash__default["default"].isString(response)) {
|
|
8789
9060
|
setTimeout(() => args.queueBotSays({
|
|
8790
9061
|
messageText: response
|
|
8791
9062
|
}), 0);
|
|
@@ -8825,7 +9096,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
|
|
|
8825
9096
|
return pluginInstance;
|
|
8826
9097
|
}
|
|
8827
9098
|
|
|
8828
|
-
if (lodash__default[
|
|
9099
|
+
if (lodash__default["default"].isFunction(pluginLoaderSpec)) {
|
|
8829
9100
|
const pluginInstance = pluginLoaderSpec(args);
|
|
8830
9101
|
debug$3('Botium plugin loaded from function call');
|
|
8831
9102
|
return pluginInstance;
|
|
@@ -8833,10 +9104,10 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
|
|
|
8833
9104
|
|
|
8834
9105
|
const loadErr = [];
|
|
8835
9106
|
|
|
8836
|
-
if (lodash__default[
|
|
8837
|
-
const tryLoadFile = path__default[
|
|
9107
|
+
if (lodash__default["default"].isString(pluginLoaderSpec)) {
|
|
9108
|
+
const tryLoadFile = path__default["default"].resolve(process.cwd(), pluginLoaderSpec);
|
|
8838
9109
|
|
|
8839
|
-
if (fs__default[
|
|
9110
|
+
if (fs__default["default"].existsSync(tryLoadFile)) {
|
|
8840
9111
|
_checkUnsafe(args.caps, 'Using work dir', {
|
|
8841
9112
|
modulepath,
|
|
8842
9113
|
containermode
|
|
@@ -8909,7 +9180,7 @@ var plugins = {
|
|
|
8909
9180
|
tryLoadPlugin: tryLoadPlugin$1
|
|
8910
9181
|
};
|
|
8911
9182
|
|
|
8912
|
-
const debug$2 = debug__default[
|
|
9183
|
+
const debug$2 = debug__default["default"]('botium-connector-PluginConnectorContainer');
|
|
8913
9184
|
const {
|
|
8914
9185
|
tryLoadPlugin
|
|
8915
9186
|
} = plugins;
|
|
@@ -8946,7 +9217,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8946
9217
|
|
|
8947
9218
|
Build() {
|
|
8948
9219
|
try {
|
|
8949
|
-
return super.Build().then(() => promiseRetry__default[
|
|
9220
|
+
return super.Build().then(() => promiseRetry__default["default"]((retry, number) => {
|
|
8950
9221
|
return (this.pluginInstance.Build ? this.pluginInstance.Build() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8951
9222
|
if (this.retryHelperBuild.shouldRetry(err)) {
|
|
8952
9223
|
debug$2(`Build trial #${number} failed, retry activated`);
|
|
@@ -8957,7 +9228,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8957
9228
|
});
|
|
8958
9229
|
}, this.retryHelperBuild.retrySettings)).then(() => this);
|
|
8959
9230
|
} catch (err) {
|
|
8960
|
-
return Promise.reject(new Error(`Build - Botium plugin failed: ${util__default[
|
|
9231
|
+
return Promise.reject(new Error(`Build - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
8961
9232
|
}
|
|
8962
9233
|
}
|
|
8963
9234
|
|
|
@@ -8965,7 +9236,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8965
9236
|
this.eventEmitter.emit(Events.CONTAINER_STARTING, this);
|
|
8966
9237
|
|
|
8967
9238
|
try {
|
|
8968
|
-
return super.Start().then(() => promiseRetry__default[
|
|
9239
|
+
return super.Start().then(() => promiseRetry__default["default"]((retry, number) => {
|
|
8969
9240
|
return (this.pluginInstance.Start ? this.pluginInstance.Start() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8970
9241
|
if (this.retryHelperStart.shouldRetry(err)) {
|
|
8971
9242
|
debug$2(`Start trial #${number} failed, retry activated`);
|
|
@@ -8983,13 +9254,13 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8983
9254
|
});
|
|
8984
9255
|
} catch (err) {
|
|
8985
9256
|
this.eventEmitter.emit(Events.CONTAINER_START_ERROR, this, err);
|
|
8986
|
-
return Promise.reject(new Error(`Start - Botium plugin failed: ${util__default[
|
|
9257
|
+
return Promise.reject(new Error(`Start - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
8987
9258
|
}
|
|
8988
9259
|
}
|
|
8989
9260
|
|
|
8990
9261
|
UserSaysImpl(mockMsg) {
|
|
8991
9262
|
try {
|
|
8992
|
-
return promiseRetry__default[
|
|
9263
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
8993
9264
|
return (this.pluginInstance.UserSays(mockMsg) || Promise.resolve()).catch(err => {
|
|
8994
9265
|
if (this.retryHelperUserSays.shouldRetry(err)) {
|
|
8995
9266
|
debug$2(`UserSays trial #${number} failed, retry activated`);
|
|
@@ -9003,7 +9274,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9003
9274
|
return this;
|
|
9004
9275
|
});
|
|
9005
9276
|
} catch (err) {
|
|
9006
|
-
return Promise.reject(new Error(`UserSays - Botium plugin failed: ${util__default[
|
|
9277
|
+
return Promise.reject(new Error(`UserSays - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
9007
9278
|
}
|
|
9008
9279
|
}
|
|
9009
9280
|
|
|
@@ -9011,7 +9282,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9011
9282
|
this.eventEmitter.emit(Events.CONTAINER_STOPPING, this);
|
|
9012
9283
|
|
|
9013
9284
|
try {
|
|
9014
|
-
return super.Stop().then(() => promiseRetry__default[
|
|
9285
|
+
return super.Stop().then(() => promiseRetry__default["default"]((retry, number) => {
|
|
9015
9286
|
return (this.pluginInstance.Stop ? this.pluginInstance.Stop() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
9016
9287
|
if (this.retryHelperStop.shouldRetry(err)) {
|
|
9017
9288
|
debug$2(`Stop trial #${number} failed, retry activated`);
|
|
@@ -9029,7 +9300,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9029
9300
|
});
|
|
9030
9301
|
} catch (err) {
|
|
9031
9302
|
this.eventEmitter.emit(Events.CONTAINER_STOP_ERROR, this, err);
|
|
9032
|
-
return Promise.reject(new Error(`Stop - Botium plugin failed: ${util__default[
|
|
9303
|
+
return Promise.reject(new Error(`Stop - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
9033
9304
|
}
|
|
9034
9305
|
}
|
|
9035
9306
|
|
|
@@ -9037,7 +9308,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9037
9308
|
this.eventEmitter.emit(Events.CONTAINER_CLEANING, this);
|
|
9038
9309
|
|
|
9039
9310
|
try {
|
|
9040
|
-
return promiseRetry__default[
|
|
9311
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
9041
9312
|
return (this.pluginInstance.Clean ? this.pluginInstance.Clean() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
9042
9313
|
if (this.retryHelperClean.shouldRetry(err)) {
|
|
9043
9314
|
debug$2(`Clean trial #${number} failed, retry activated`);
|
|
@@ -9055,7 +9326,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9055
9326
|
});
|
|
9056
9327
|
} catch (err) {
|
|
9057
9328
|
this.eventEmitter.emit(Events.CONTAINER_CLEAN_ERROR, this, err);
|
|
9058
|
-
return Promise.reject(new Error(`Clean - Botium plugin failed: ${util__default[
|
|
9329
|
+
return Promise.reject(new Error(`Clean - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
9059
9330
|
}
|
|
9060
9331
|
}
|
|
9061
9332
|
|
|
@@ -9065,17 +9336,17 @@ var require$$2 = getCjsExportFromNamespace(_package$1);
|
|
|
9065
9336
|
|
|
9066
9337
|
const {
|
|
9067
9338
|
boolean
|
|
9068
|
-
} = boolean__default[
|
|
9069
|
-
const debug$1 = debug__default[
|
|
9339
|
+
} = boolean__default["default"];
|
|
9340
|
+
const debug$1 = debug__default["default"]('botium-core-BotDriver');
|
|
9070
9341
|
const {
|
|
9071
9342
|
version
|
|
9072
9343
|
} = require$$2;
|
|
9073
9344
|
var BotDriver_1 = class BotDriver {
|
|
9074
9345
|
constructor(caps = {}, sources = {}, envs = {}) {
|
|
9075
|
-
this.eventEmitter = new events__default[
|
|
9076
|
-
this.caps = lodash__default[
|
|
9077
|
-
this.sources = lodash__default[
|
|
9078
|
-
this.envs = lodash__default[
|
|
9346
|
+
this.eventEmitter = new events__default["default"]();
|
|
9347
|
+
this.caps = lodash__default["default"].cloneDeep(Defaults$1.Capabilities);
|
|
9348
|
+
this.sources = lodash__default["default"].cloneDeep(Defaults$1.Sources);
|
|
9349
|
+
this.envs = lodash__default["default"].cloneDeep(Defaults$1.Envs);
|
|
9079
9350
|
this._fetchedConfigFiles = [];
|
|
9080
9351
|
|
|
9081
9352
|
this._fetchConfigFromFiles(['./botium.json', process.env.NODE_ENV && `./botium.${process.env.NODE_ENV}.json`, './botium.local.json', process.env.NODE_ENV && `./botium.${process.env.NODE_ENV}.local.json`]);
|
|
@@ -9083,10 +9354,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9083
9354
|
const botiumConfigEnv = process.env.BOTIUM_CONFIG;
|
|
9084
9355
|
|
|
9085
9356
|
if (botiumConfigEnv) {
|
|
9086
|
-
const checkDir = path__default[
|
|
9087
|
-
const checkFileBase = path__default[
|
|
9357
|
+
const checkDir = path__default["default"].dirname(botiumConfigEnv);
|
|
9358
|
+
const checkFileBase = path__default["default"].basename(botiumConfigEnv, '.json');
|
|
9088
9359
|
|
|
9089
|
-
if (!this._fetchConfigFromFiles([botiumConfigEnv, process.env.NODE_ENV && path__default[
|
|
9360
|
+
if (!this._fetchConfigFromFiles([botiumConfigEnv, process.env.NODE_ENV && path__default["default"].join(checkDir, `${checkFileBase}.${process.env.NODE_ENV}.json`), path__default["default"].join(checkDir, `${checkFileBase}.local.json`), process.env.NODE_ENV && path__default["default"].join(checkDir, `${checkFileBase}.${process.env.NODE_ENV}.local.json`)])) {
|
|
9090
9361
|
throw new Error(`FAILED: Botium configuration file ${botiumConfigEnv} not available`);
|
|
9091
9362
|
}
|
|
9092
9363
|
}
|
|
@@ -9113,7 +9384,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9113
9384
|
});
|
|
9114
9385
|
if (caps) this._mergeCaps(this.caps, caps);
|
|
9115
9386
|
if (sources) this._mergeCaps(this.sources, sources);
|
|
9116
|
-
if (envs) this.envs = lodash__default[
|
|
9387
|
+
if (envs) this.envs = lodash__default["default"].merge(this.envs, envs);
|
|
9117
9388
|
}
|
|
9118
9389
|
|
|
9119
9390
|
on(event, listener) {
|
|
@@ -9150,7 +9421,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9150
9421
|
}
|
|
9151
9422
|
|
|
9152
9423
|
setEnvs(envs) {
|
|
9153
|
-
this.envs = lodash__default[
|
|
9424
|
+
this.envs = lodash__default["default"].merge(this.envs, envs);
|
|
9154
9425
|
return this;
|
|
9155
9426
|
}
|
|
9156
9427
|
|
|
@@ -9166,14 +9437,14 @@ var BotDriver_1 = class BotDriver {
|
|
|
9166
9437
|
|
|
9167
9438
|
Build() {
|
|
9168
9439
|
debug$1(`Build - Botium Core Version: ${version}`);
|
|
9169
|
-
debug$1(`Build - Capabilites: ${util__default[
|
|
9170
|
-
debug$1(`Build - Sources : ${util__default[
|
|
9171
|
-
debug$1(`Build - Envs : ${util__default[
|
|
9440
|
+
debug$1(`Build - Capabilites: ${util__default["default"].inspect(this.caps)}`);
|
|
9441
|
+
debug$1(`Build - Sources : ${util__default["default"].inspect(this.sources)}`);
|
|
9442
|
+
debug$1(`Build - Envs : ${util__default["default"].inspect(this.envs)}`);
|
|
9172
9443
|
this.eventEmitter.emit(Events.CONTAINER_BUILDING);
|
|
9173
9444
|
return new Promise((resolve, reject) => {
|
|
9174
9445
|
let repo = null;
|
|
9175
9446
|
let container = null;
|
|
9176
|
-
async__default[
|
|
9447
|
+
async__default["default"].series([driverValidated => {
|
|
9177
9448
|
this._validate().then(() => driverValidated()).catch(driverValidated);
|
|
9178
9449
|
}, repoValidated => {
|
|
9179
9450
|
try {
|
|
@@ -9201,8 +9472,8 @@ var BotDriver_1 = class BotDriver {
|
|
|
9201
9472
|
this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
|
|
9202
9473
|
|
|
9203
9474
|
if (this.tempDirectory) {
|
|
9204
|
-
rimraf__default[
|
|
9205
|
-
if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default[
|
|
9475
|
+
rimraf__default["default"](this.tempDirectory, err => {
|
|
9476
|
+
if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default["default"].inspect(err)}`);
|
|
9206
9477
|
});
|
|
9207
9478
|
}
|
|
9208
9479
|
|
|
@@ -9231,7 +9502,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9231
9502
|
|
|
9232
9503
|
_loadConfigFile(filename) {
|
|
9233
9504
|
try {
|
|
9234
|
-
const configJson = JSON.parse(fs__default[
|
|
9505
|
+
const configJson = JSON.parse(fs__default["default"].readFileSync(filename));
|
|
9235
9506
|
|
|
9236
9507
|
if (configJson.botium) {
|
|
9237
9508
|
if (configJson.botium.Capabilities) this._mergeCaps(this.caps, configJson.botium.Capabilities);
|
|
@@ -9243,7 +9514,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9243
9514
|
return false;
|
|
9244
9515
|
}
|
|
9245
9516
|
} catch (err) {
|
|
9246
|
-
throw new Error(`FAILED: loading Botium configuration file ${filename}: ${util__default[
|
|
9517
|
+
throw new Error(`FAILED: loading Botium configuration file ${filename}: ${util__default["default"].inspect(err)}`);
|
|
9247
9518
|
}
|
|
9248
9519
|
} // fetches config from files ordered by priority later files overwrite previous
|
|
9249
9520
|
|
|
@@ -9252,8 +9523,8 @@ var BotDriver_1 = class BotDriver {
|
|
|
9252
9523
|
const fetchedFiles = [];
|
|
9253
9524
|
|
|
9254
9525
|
for (const file of files) {
|
|
9255
|
-
if (file && fs__default[
|
|
9256
|
-
const absFilePath = path__default[
|
|
9526
|
+
if (file && fs__default["default"].existsSync(file)) {
|
|
9527
|
+
const absFilePath = path__default["default"].resolve(file);
|
|
9257
9528
|
|
|
9258
9529
|
if (this._fetchedConfigFiles.indexOf(absFilePath) < 0) {
|
|
9259
9530
|
this._loadConfigFile(file);
|
|
@@ -9282,11 +9553,11 @@ var BotDriver_1 = class BotDriver {
|
|
|
9282
9553
|
if (!caps) return;
|
|
9283
9554
|
Object.keys(newCaps).forEach(capKey => {
|
|
9284
9555
|
if (!Object.prototype.hasOwnProperty.call(caps, capKey)) {
|
|
9285
|
-
if (lodash__default[
|
|
9556
|
+
if (lodash__default["default"].isString(newCaps[capKey])) {
|
|
9286
9557
|
try {
|
|
9287
9558
|
caps[capKey] = JSON.parse(newCaps[capKey]);
|
|
9288
9559
|
|
|
9289
|
-
if (lodash__default[
|
|
9560
|
+
if (lodash__default["default"].isFinite(caps[capKey])) {
|
|
9290
9561
|
caps[capKey] = caps[capKey].toString();
|
|
9291
9562
|
}
|
|
9292
9563
|
} catch (err) {
|
|
@@ -9299,10 +9570,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9299
9570
|
return;
|
|
9300
9571
|
}
|
|
9301
9572
|
|
|
9302
|
-
if (lodash__default[
|
|
9573
|
+
if (lodash__default["default"].isArray(caps[capKey])) {
|
|
9303
9574
|
let newCapArray = newCaps[capKey];
|
|
9304
9575
|
|
|
9305
|
-
if (!lodash__default[
|
|
9576
|
+
if (!lodash__default["default"].isArray(newCapArray)) {
|
|
9306
9577
|
try {
|
|
9307
9578
|
newCapArray = JSON.parse(newCapArray);
|
|
9308
9579
|
} catch (err) {
|
|
@@ -9310,7 +9581,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9310
9581
|
}
|
|
9311
9582
|
}
|
|
9312
9583
|
|
|
9313
|
-
if (lodash__default[
|
|
9584
|
+
if (lodash__default["default"].isArray(newCapArray)) {
|
|
9314
9585
|
newCapArray.forEach(capElement => {
|
|
9315
9586
|
const mergeKey = this._findKeyProperty(capElement);
|
|
9316
9587
|
|
|
@@ -9318,7 +9589,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9318
9589
|
const oldElement = caps[capKey].find(oldElement => oldElement[mergeKey] && oldElement[mergeKey] === capElement[mergeKey]);
|
|
9319
9590
|
|
|
9320
9591
|
if (oldElement) {
|
|
9321
|
-
lodash__default[
|
|
9592
|
+
lodash__default["default"].merge(oldElement, capElement);
|
|
9322
9593
|
|
|
9323
9594
|
return;
|
|
9324
9595
|
}
|
|
@@ -9334,10 +9605,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9334
9605
|
}
|
|
9335
9606
|
}
|
|
9336
9607
|
|
|
9337
|
-
if (!lodash__default[
|
|
9608
|
+
if (!lodash__default["default"].isArray(caps[capKey]) && lodash__default["default"].isObject(caps[capKey])) {
|
|
9338
9609
|
let newCapObject = newCaps[capKey];
|
|
9339
9610
|
|
|
9340
|
-
if (!lodash__default[
|
|
9611
|
+
if (!lodash__default["default"].isObject(newCapObject)) {
|
|
9341
9612
|
try {
|
|
9342
9613
|
newCapObject = JSON.parse(newCapObject);
|
|
9343
9614
|
} catch (err) {
|
|
@@ -9345,15 +9616,15 @@ var BotDriver_1 = class BotDriver {
|
|
|
9345
9616
|
}
|
|
9346
9617
|
}
|
|
9347
9618
|
|
|
9348
|
-
if (lodash__default[
|
|
9349
|
-
lodash__default[
|
|
9619
|
+
if (lodash__default["default"].isObject(newCapObject)) {
|
|
9620
|
+
lodash__default["default"].merge(caps[capKey], newCapObject);
|
|
9350
9621
|
|
|
9351
9622
|
return;
|
|
9352
9623
|
}
|
|
9353
9624
|
}
|
|
9354
9625
|
|
|
9355
|
-
if (lodash__default[
|
|
9356
|
-
if (!lodash__default[
|
|
9626
|
+
if (lodash__default["default"].isBoolean(caps[capKey])) {
|
|
9627
|
+
if (!lodash__default["default"].isBoolean(newCaps[capKey])) {
|
|
9357
9628
|
caps[capKey] = boolean(newCaps[capKey]);
|
|
9358
9629
|
return;
|
|
9359
9630
|
}
|
|
@@ -9378,10 +9649,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9378
9649
|
throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
|
|
9379
9650
|
}
|
|
9380
9651
|
|
|
9381
|
-
this.tempDirectory = path__default[
|
|
9652
|
+
this.tempDirectory = path__default["default"].resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename__default["default"](`${this.caps[Capabilities.PROJECTNAME]} ${moment__default["default"]().format('YYYYMMDD HHmmss')} ${randomatic__default["default"]('Aa0', 5)}`));
|
|
9382
9653
|
|
|
9383
9654
|
try {
|
|
9384
|
-
mkdirp__default[
|
|
9655
|
+
mkdirp__default["default"].sync(this.tempDirectory);
|
|
9385
9656
|
} catch (err) {
|
|
9386
9657
|
throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
|
|
9387
9658
|
}
|
|
@@ -9409,7 +9680,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9409
9680
|
return new LocalRepo(this.tempDirectory, this.sources);
|
|
9410
9681
|
}
|
|
9411
9682
|
|
|
9412
|
-
throw new Error(`No Repo provider found for Sources ${util__default[
|
|
9683
|
+
throw new Error(`No Repo provider found for Sources ${util__default["default"].inspect(this.sources)}`);
|
|
9413
9684
|
}
|
|
9414
9685
|
|
|
9415
9686
|
_getContainer(repo) {
|
|
@@ -9433,7 +9704,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9433
9704
|
|
|
9434
9705
|
};
|
|
9435
9706
|
|
|
9436
|
-
const debug = debug__default[
|
|
9707
|
+
const debug = debug__default["default"]('botium-core-Plugins');
|
|
9437
9708
|
const PLUGIN_TYPE_CONNECTOR = 'PLUGIN_TYPE_CONNECTOR';
|
|
9438
9709
|
const PLUGIN_TYPE_ASSERTER = 'PLUGIN_TYPE_ASSERTER';
|
|
9439
9710
|
const PLUGIN_TYPE_LOGICHOOK = 'PLUGIN_TYPE_LOGICHOOK';
|
|
@@ -9461,7 +9732,7 @@ const getConnectorPlugin = (filename, pathToRes) => {
|
|
|
9461
9732
|
const pluginPath = commonjsRequire.resolve(filename);
|
|
9462
9733
|
|
|
9463
9734
|
if (!pluginPath.startsWith(pathToRes)) {
|
|
9464
|
-
debug(`Plugin mismatch error. Plugin ${path__default[
|
|
9735
|
+
debug(`Plugin mismatch error. Plugin ${path__default["default"].resolve(pathToRes, filename)} loaded from ${pluginPath}! `);
|
|
9465
9736
|
return null;
|
|
9466
9737
|
}
|
|
9467
9738
|
|
|
@@ -9513,7 +9784,7 @@ const getOtherPlugin = (filename, pathToRes, type) => {
|
|
|
9513
9784
|
const pluginPath = commonjsRequire.resolve(filename);
|
|
9514
9785
|
|
|
9515
9786
|
if (!pluginPath.startsWith(pathToRes)) {
|
|
9516
|
-
debug(`Plugin mismatch error. Plugin ${path__default[
|
|
9787
|
+
debug(`Plugin mismatch error. Plugin ${path__default["default"].resolve(pathToRes, filename)} loaded from ${pluginPath}! `);
|
|
9517
9788
|
return null;
|
|
9518
9789
|
}
|
|
9519
9790
|
|
|
@@ -9560,9 +9831,9 @@ const getPlugins = async (type, resourcesDir) => {
|
|
|
9560
9831
|
return Promise.resolve([]);
|
|
9561
9832
|
}
|
|
9562
9833
|
|
|
9563
|
-
const pathToRes = path__default[
|
|
9834
|
+
const pathToRes = path__default["default"].resolve(resourcesDir);
|
|
9564
9835
|
|
|
9565
|
-
if (!fs__default[
|
|
9836
|
+
if (!fs__default["default"].existsSync(pathToRes)) {
|
|
9566
9837
|
debug(`Cant load plugins, directory ${pathToRes} does not exists`);
|
|
9567
9838
|
return [];
|
|
9568
9839
|
}
|
|
@@ -9570,7 +9841,7 @@ const getPlugins = async (type, resourcesDir) => {
|
|
|
9570
9841
|
let items;
|
|
9571
9842
|
|
|
9572
9843
|
try {
|
|
9573
|
-
items = fs__default[
|
|
9844
|
+
items = fs__default["default"].readdirSync(pathToRes).filter(item => path__default["default"].extname(item) === '.js' || item.indexOf('.') === -1);
|
|
9574
9845
|
} catch (err) {
|
|
9575
9846
|
debug(`Cant load plugins, failed to read directory ${pathToRes} - ${err.message}`);
|
|
9576
9847
|
return [];
|
|
@@ -9616,6 +9887,7 @@ var botiumCore = {
|
|
|
9616
9887
|
ScriptingConstants: Constants,
|
|
9617
9888
|
Capabilities: Capabilities,
|
|
9618
9889
|
Defaults: Defaults$1,
|
|
9890
|
+
Enums: Enums,
|
|
9619
9891
|
Source: Source,
|
|
9620
9892
|
Events: Events,
|
|
9621
9893
|
Plugins: Plugins,
|
|
@@ -9635,31 +9907,33 @@ var botiumCore_2 = botiumCore.ScriptingProvider;
|
|
|
9635
9907
|
var botiumCore_3 = botiumCore.ScriptingConstants;
|
|
9636
9908
|
var botiumCore_4 = botiumCore.Capabilities;
|
|
9637
9909
|
var botiumCore_5 = botiumCore.Defaults;
|
|
9638
|
-
var botiumCore_6 = botiumCore.
|
|
9639
|
-
var botiumCore_7 = botiumCore.
|
|
9640
|
-
var botiumCore_8 = botiumCore.
|
|
9641
|
-
var botiumCore_9 = botiumCore.
|
|
9642
|
-
var botiumCore_10 = botiumCore.
|
|
9643
|
-
var botiumCore_11 = botiumCore.
|
|
9644
|
-
var botiumCore_12 = botiumCore.
|
|
9645
|
-
var botiumCore_13 = botiumCore.
|
|
9646
|
-
var botiumCore_14 = botiumCore.
|
|
9647
|
-
var botiumCore_15 = botiumCore.
|
|
9910
|
+
var botiumCore_6 = botiumCore.Enums;
|
|
9911
|
+
var botiumCore_7 = botiumCore.Source;
|
|
9912
|
+
var botiumCore_8 = botiumCore.Events;
|
|
9913
|
+
var botiumCore_9 = botiumCore.Plugins;
|
|
9914
|
+
var botiumCore_10 = botiumCore.BotiumError;
|
|
9915
|
+
var botiumCore_11 = botiumCore.ScriptingMemory;
|
|
9916
|
+
var botiumCore_12 = botiumCore.HookUtils;
|
|
9917
|
+
var botiumCore_13 = botiumCore.LogicHookConstants;
|
|
9918
|
+
var botiumCore_14 = botiumCore.Lib;
|
|
9919
|
+
var botiumCore_15 = botiumCore.InboundProxy;
|
|
9920
|
+
var botiumCore_16 = botiumCore.BotiumMockRichMessageTypes;
|
|
9648
9921
|
|
|
9649
9922
|
exports.BotDriver = botiumCore_1;
|
|
9650
|
-
exports.BotiumError =
|
|
9651
|
-
exports.BotiumMockRichMessageTypes =
|
|
9923
|
+
exports.BotiumError = botiumCore_10;
|
|
9924
|
+
exports.BotiumMockRichMessageTypes = botiumCore_16;
|
|
9652
9925
|
exports.Capabilities = botiumCore_4;
|
|
9653
9926
|
exports.Defaults = botiumCore_5;
|
|
9654
|
-
exports.
|
|
9655
|
-
exports.
|
|
9656
|
-
exports.
|
|
9657
|
-
exports.
|
|
9658
|
-
exports.
|
|
9659
|
-
exports.
|
|
9927
|
+
exports.Enums = botiumCore_6;
|
|
9928
|
+
exports.Events = botiumCore_8;
|
|
9929
|
+
exports.HookUtils = botiumCore_12;
|
|
9930
|
+
exports.InboundProxy = botiumCore_15;
|
|
9931
|
+
exports.Lib = botiumCore_14;
|
|
9932
|
+
exports.LogicHookConstants = botiumCore_13;
|
|
9933
|
+
exports.Plugins = botiumCore_9;
|
|
9660
9934
|
exports.ScriptingConstants = botiumCore_3;
|
|
9661
|
-
exports.ScriptingMemory =
|
|
9935
|
+
exports.ScriptingMemory = botiumCore_11;
|
|
9662
9936
|
exports.ScriptingProvider = botiumCore_2;
|
|
9663
|
-
exports.Source =
|
|
9664
|
-
exports[
|
|
9937
|
+
exports.Source = botiumCore_7;
|
|
9938
|
+
exports["default"] = botiumCore;
|
|
9665
9939
|
//# sourceMappingURL=botium-cjs.js.map
|