botium-core 1.11.13 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botium-cjs.js +692 -524
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +323 -155
- package/dist/botium-es.js.map +1 -1
- package/package.json +30 -29
- package/samples/connectors/custom/botium-connector-myapi.js +3 -3
- package/samples/extensions/asserterHooks/DummyAsserter.js +3 -3
- package/src/Capabilities.js +7 -1
- package/src/Defaults.js +1 -0
- package/src/containers/plugins/SimpleRestContainer.js +129 -52
- package/src/scripting/CompilerCsv.js +1 -1
- package/src/scripting/MatchFunctions.js +21 -0
- package/src/scripting/ScriptingProvider.js +49 -40
- package/src/scripting/helper.js +3 -3
- package/src/scripting/logichook/LogicHookConsts.js +4 -0
- package/src/scripting/logichook/LogicHookUtils.js +2 -0
- package/src/scripting/logichook/asserter/JsonPathAsserter.js +1 -1
- package/src/scripting/logichook/asserter/TextWildcardExactAllAsserter.js +8 -0
- package/src/scripting/logichook/asserter/TextWildcardExactAllICAsserter.js +8 -0
- package/src/scripting/logichook/asserter/TextWildcardExactAnyAsserter.js +8 -0
- package/src/scripting/logichook/asserter/TextWildcardExactAnyICAsserter.js +8 -0
- package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -4
- package/test/connectors/convos/hello.convo.txt +6 -0
- package/test/connectors/simplerest.spec.js +129 -2
- package/test/scripting/asserters/convos/text_wildcardexact_all_nok.yml +7 -0
- package/test/scripting/asserters/convos/text_wildcardexact_all_ok.yml +7 -0
- package/test/scripting/asserters/convos/text_wildcardexact_any_nok.yml +7 -0
- package/test/scripting/asserters/convos/text_wildcardexact_any_ok.yml +7 -0
- package/test/scripting/asserters/textWildcardExactAllAsserter.spec.js +51 -0
- package/test/scripting/asserters/textWildcardExactAnyAsserter.spec.js +51 -0
- package/test/scripting/matching/matchingmode.spec.js +43 -0
package/dist/botium-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.0";
|
|
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,65 +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.5",
|
|
115
|
+
async: "^3.2.2",
|
|
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.3",
|
|
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.2",
|
|
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.
|
|
130
|
-
"mime-types": "^2.1.
|
|
129
|
+
"markdown-it": "^12.3.0",
|
|
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.4",
|
|
141
|
+
"socket.io": "^4.4.0",
|
|
142
|
+
"socket.io-client": "^4.4.0",
|
|
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.4",
|
|
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.5",
|
|
155
|
+
"@babel/node": "^7.16.5",
|
|
156
|
+
"@babel/plugin-transform-runtime": "^7.16.5",
|
|
157
|
+
"@babel/preset-env": "^7.16.5",
|
|
158
158
|
chai: "^4.3.4",
|
|
159
159
|
"chai-as-promised": "^7.1.1",
|
|
160
160
|
"cross-env": "^7.0.3",
|
|
161
|
-
eslint: "^
|
|
161
|
+
eslint: "^8.4.1",
|
|
162
162
|
"eslint-config-standard": "^16.0.3",
|
|
163
|
-
"eslint-plugin-import": "^2.
|
|
163
|
+
"eslint-plugin-import": "^2.25.3",
|
|
164
164
|
"eslint-plugin-node": "^11.1.0",
|
|
165
|
-
"eslint-plugin-promise": "^5.
|
|
165
|
+
"eslint-plugin-promise": "^5.2.0",
|
|
166
166
|
"eslint-plugin-standard": "^4.1.0",
|
|
167
167
|
"license-checker": "^25.0.1",
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
"license-compatibility-checker": "^0.3.5",
|
|
169
|
+
mocha: "^9.1.3",
|
|
170
|
+
nock: "^13.2.1",
|
|
171
|
+
"npm-check-updates": "^12.0.5",
|
|
171
172
|
nyc: "^15.1.0",
|
|
172
|
-
rollup: "^2.
|
|
173
|
+
rollup: "^2.61.1",
|
|
173
174
|
"rollup-plugin-babel": "^4.4.0",
|
|
174
175
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
175
176
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -231,6 +232,7 @@ var Capabilities = {
|
|
|
231
232
|
SIMPLEREST_PING_BODY: 'SIMPLEREST_PING_BODY',
|
|
232
233
|
SIMPLEREST_PING_BODY_RAW: 'SIMPLEREST_PING_BODY_RAW',
|
|
233
234
|
SIMPLEREST_PING_HEADERS: 'SIMPLEREST_PING_HEADERS',
|
|
235
|
+
SIMPLEREST_PING_REQUEST_HOOK: 'SIMPLEREST_PING_REQUEST_HOOK',
|
|
234
236
|
SIMPLEREST_PING_RETRIES: 'SIMPLEREST_PING_RETRIES',
|
|
235
237
|
SIMPLEREST_PING_TIMEOUT: 'SIMPLEREST_PING_TIMEOUT',
|
|
236
238
|
SIMPLEREST_PING_UPDATE_CONTEXT: 'SIMPLEREST_PING_UPDATE_CONTEXT',
|
|
@@ -240,6 +242,7 @@ var Capabilities = {
|
|
|
240
242
|
SIMPLEREST_START_BODY: 'SIMPLEREST_START_BODY',
|
|
241
243
|
SIMPLEREST_START_BODY_RAW: 'SIMPLEREST_START_BODY_RAW',
|
|
242
244
|
SIMPLEREST_START_HEADERS: 'SIMPLEREST_START_HEADERS',
|
|
245
|
+
SIMPLEREST_START_REQUEST_HOOK: 'SIMPLEREST_START_REQUEST_HOOK',
|
|
243
246
|
SIMPLEREST_START_RETRIES: 'SIMPLEREST_START_RETRIES',
|
|
244
247
|
SIMPLEREST_START_TIMEOUT: 'SIMPLEREST_START_TIMEOUT',
|
|
245
248
|
SIMPLEREST_START_UPDATE_CONTEXT: 'SIMPLEREST_START_UPDATE_CONTEXT',
|
|
@@ -249,10 +252,12 @@ var Capabilities = {
|
|
|
249
252
|
SIMPLEREST_STOP_BODY: 'SIMPLEREST_STOP_BODY',
|
|
250
253
|
SIMPLEREST_STOP_BODY_RAW: 'SIMPLEREST_STOP_BODY_RAW',
|
|
251
254
|
SIMPLEREST_STOP_HEADERS: 'SIMPLEREST_STOP_HEADERS',
|
|
255
|
+
SIMPLEREST_STOP_REQUEST_HOOK: 'SIMPLEREST_STOP_REQUEST_HOOK',
|
|
252
256
|
SIMPLEREST_STOP_RETRIES: 'SIMPLEREST_STOP_RETRIES',
|
|
253
257
|
SIMPLEREST_STOP_TIMEOUT: 'SIMPLEREST_STOP_TIMEOUT',
|
|
254
258
|
SIMPLEREST_INIT_CONTEXT: 'SIMPLEREST_INIT_CONTEXT',
|
|
255
259
|
SIMPLEREST_INIT_TEXT: 'SIMPLEREST_INIT_TEXT',
|
|
260
|
+
SIMPLEREST_INIT_PROCESS_RESPONSE: 'SIMPLEREST_INIT_PROCESS_RESPONSE',
|
|
256
261
|
SIMPLEREST_PROXY_URL: 'SIMPLEREST_PROXY_URL',
|
|
257
262
|
SIMPLEREST_STRICT_SSL: 'SIMPLEREST_STRICT_SSL',
|
|
258
263
|
SIMPLEREST_URL: 'SIMPLEREST_URL',
|
|
@@ -267,11 +272,13 @@ var Capabilities = {
|
|
|
267
272
|
SIMPLEREST_START_HOOK: 'SIMPLEREST_START_HOOK',
|
|
268
273
|
SIMPLEREST_STOP_HOOK: 'SIMPLEREST_STOP_HOOK',
|
|
269
274
|
SIMPLEREST_REQUEST_HOOK: 'SIMPLEREST_REQUEST_HOOK',
|
|
275
|
+
SIMPLEREST_PARSER_HOOK: 'SIMPLEREST_PARSER_HOOK',
|
|
270
276
|
SIMPLEREST_POLL_URL: 'SIMPLEREST_POLL_URL',
|
|
271
277
|
SIMPLEREST_POLL_VERB: 'SIMPLEREST_POLL_VERB',
|
|
272
278
|
SIMPLEREST_POLL_BODY: 'SIMPLEREST_POLL_BODY',
|
|
273
279
|
SIMPLEREST_POLL_BODY_RAW: 'SIMPLEREST_POLL_BODY_RAW',
|
|
274
280
|
SIMPLEREST_POLL_HEADERS: 'SIMPLEREST_POLL_HEADERS',
|
|
281
|
+
SIMPLEREST_POLL_REQUEST_HOOK: 'SIMPLEREST_POLL_REQUEST_HOOK',
|
|
275
282
|
SIMPLEREST_POLL_INTERVAL: 'SIMPLEREST_POLL_INTERVAL',
|
|
276
283
|
SIMPLEREST_POLL_TIMEOUT: 'SIMPLEREST_PING_TIMEOUT',
|
|
277
284
|
SIMPLEREST_POLL_UPDATE_CONTEXT: 'SIMPLEREST_POLL_UPDATE_CONTEXT',
|
|
@@ -319,7 +326,7 @@ var Capabilities = {
|
|
|
319
326
|
SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
|
|
320
327
|
SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
|
|
321
328
|
SCRIPTING_FORCE_BOT_CONSUMED: 'SCRIPTING_FORCE_BOT_CONSUMED',
|
|
322
|
-
// regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
|
|
329
|
+
// regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, wildcardExact, wildcardExactIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
|
|
323
330
|
SCRIPTING_MATCHING_MODE: 'SCRIPTING_MATCHING_MODE',
|
|
324
331
|
// all, first, random
|
|
325
332
|
SCRIPTING_UTTEXPANSION_MODE: 'SCRIPTING_UTTEXPANSION_MODE',
|
|
@@ -367,6 +374,7 @@ Capabilities.SIMPLEREST_PING_VERB;
|
|
|
367
374
|
Capabilities.SIMPLEREST_PING_BODY;
|
|
368
375
|
Capabilities.SIMPLEREST_PING_BODY_RAW;
|
|
369
376
|
Capabilities.SIMPLEREST_PING_HEADERS;
|
|
377
|
+
Capabilities.SIMPLEREST_PING_REQUEST_HOOK;
|
|
370
378
|
Capabilities.SIMPLEREST_PING_RETRIES;
|
|
371
379
|
Capabilities.SIMPLEREST_PING_TIMEOUT;
|
|
372
380
|
Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT;
|
|
@@ -376,6 +384,7 @@ Capabilities.SIMPLEREST_START_VERB;
|
|
|
376
384
|
Capabilities.SIMPLEREST_START_BODY;
|
|
377
385
|
Capabilities.SIMPLEREST_START_BODY_RAW;
|
|
378
386
|
Capabilities.SIMPLEREST_START_HEADERS;
|
|
387
|
+
Capabilities.SIMPLEREST_START_REQUEST_HOOK;
|
|
379
388
|
Capabilities.SIMPLEREST_START_RETRIES;
|
|
380
389
|
Capabilities.SIMPLEREST_START_TIMEOUT;
|
|
381
390
|
Capabilities.SIMPLEREST_START_UPDATE_CONTEXT;
|
|
@@ -385,10 +394,12 @@ Capabilities.SIMPLEREST_STOP_VERB;
|
|
|
385
394
|
Capabilities.SIMPLEREST_STOP_BODY;
|
|
386
395
|
Capabilities.SIMPLEREST_STOP_BODY_RAW;
|
|
387
396
|
Capabilities.SIMPLEREST_STOP_HEADERS;
|
|
397
|
+
Capabilities.SIMPLEREST_STOP_REQUEST_HOOK;
|
|
388
398
|
Capabilities.SIMPLEREST_STOP_RETRIES;
|
|
389
399
|
Capabilities.SIMPLEREST_STOP_TIMEOUT;
|
|
390
400
|
Capabilities.SIMPLEREST_INIT_CONTEXT;
|
|
391
401
|
Capabilities.SIMPLEREST_INIT_TEXT;
|
|
402
|
+
Capabilities.SIMPLEREST_INIT_PROCESS_RESPONSE;
|
|
392
403
|
Capabilities.SIMPLEREST_PROXY_URL;
|
|
393
404
|
Capabilities.SIMPLEREST_STRICT_SSL;
|
|
394
405
|
Capabilities.SIMPLEREST_URL;
|
|
@@ -403,11 +414,13 @@ Capabilities.SIMPLEREST_BODY_RAW;
|
|
|
403
414
|
Capabilities.SIMPLEREST_START_HOOK;
|
|
404
415
|
Capabilities.SIMPLEREST_STOP_HOOK;
|
|
405
416
|
Capabilities.SIMPLEREST_REQUEST_HOOK;
|
|
417
|
+
Capabilities.SIMPLEREST_PARSER_HOOK;
|
|
406
418
|
Capabilities.SIMPLEREST_POLL_URL;
|
|
407
419
|
Capabilities.SIMPLEREST_POLL_VERB;
|
|
408
420
|
Capabilities.SIMPLEREST_POLL_BODY;
|
|
409
421
|
Capabilities.SIMPLEREST_POLL_BODY_RAW;
|
|
410
422
|
Capabilities.SIMPLEREST_POLL_HEADERS;
|
|
423
|
+
Capabilities.SIMPLEREST_POLL_REQUEST_HOOK;
|
|
411
424
|
Capabilities.SIMPLEREST_POLL_INTERVAL;
|
|
412
425
|
Capabilities.SIMPLEREST_POLL_TIMEOUT;
|
|
413
426
|
Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT;
|
|
@@ -505,6 +518,7 @@ var Defaults$1 = {
|
|
|
505
518
|
[Capabilities.SIMPLEREST_PING_VERB]: 'GET',
|
|
506
519
|
[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT]: true,
|
|
507
520
|
[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE]: false,
|
|
521
|
+
[Capabilities.SIMPLEREST_INIT_PROCESS_RESPONSE]: false,
|
|
508
522
|
[Capabilities.SIMPLEREST_STOP_RETRIES]: 6,
|
|
509
523
|
[Capabilities.SIMPLEREST_STOP_TIMEOUT]: 10000,
|
|
510
524
|
[Capabilities.SIMPLEREST_STOP_VERB]: 'GET',
|
|
@@ -580,7 +594,7 @@ var Fluent_1 = class Fluent {
|
|
|
580
594
|
|
|
581
595
|
Exec() {
|
|
582
596
|
return new Promise((resolve, reject) => {
|
|
583
|
-
async__default[
|
|
597
|
+
async__default["default"].eachSeries(this.tasks, (task, cb) => {
|
|
584
598
|
try {
|
|
585
599
|
const taskResult = task();
|
|
586
600
|
|
|
@@ -670,7 +684,7 @@ var Fluent_1 = class Fluent {
|
|
|
670
684
|
}
|
|
671
685
|
|
|
672
686
|
this.compiler.ExpandConvos();
|
|
673
|
-
async__default[
|
|
687
|
+
async__default["default"].eachSeries(this.compiler.convos, (convo, convoDone) => {
|
|
674
688
|
this.container.Start().then(() => convo.Run(this.container)).then(() => this.container.Stop()).then(() => convoDone()).catch(convoDone);
|
|
675
689
|
}, err => {
|
|
676
690
|
if (err) return reject(err);else resolve();
|
|
@@ -682,7 +696,7 @@ var Fluent_1 = class Fluent {
|
|
|
682
696
|
|
|
683
697
|
UserSaysText(msg) {
|
|
684
698
|
this.tasks.push(() => {
|
|
685
|
-
if (lodash__default[
|
|
699
|
+
if (lodash__default["default"].isFunction(msg)) {
|
|
686
700
|
msg = msg();
|
|
687
701
|
}
|
|
688
702
|
|
|
@@ -700,7 +714,7 @@ var Fluent_1 = class Fluent {
|
|
|
700
714
|
|
|
701
715
|
UserSays(msg) {
|
|
702
716
|
this.tasks.push(() => {
|
|
703
|
-
if (lodash__default[
|
|
717
|
+
if (lodash__default["default"].isFunction(msg)) {
|
|
704
718
|
msg = msg();
|
|
705
719
|
}
|
|
706
720
|
|
|
@@ -716,10 +730,10 @@ var Fluent_1 = class Fluent {
|
|
|
716
730
|
|
|
717
731
|
WaitBotSays(channel = null, timeoutMillis = null, callback = null) {
|
|
718
732
|
if (!callback) {
|
|
719
|
-
if (timeoutMillis && lodash__default[
|
|
733
|
+
if (timeoutMillis && lodash__default["default"].isFunction(timeoutMillis)) {
|
|
720
734
|
callback = timeoutMillis;
|
|
721
735
|
timeoutMillis = null;
|
|
722
|
-
} else if (!timeoutMillis && channel && lodash__default[
|
|
736
|
+
} else if (!timeoutMillis && channel && lodash__default["default"].isFunction(channel)) {
|
|
723
737
|
callback = channel;
|
|
724
738
|
timeoutMillis = null;
|
|
725
739
|
channel = null;
|
|
@@ -745,10 +759,10 @@ var Fluent_1 = class Fluent {
|
|
|
745
759
|
|
|
746
760
|
WaitBotSaysText(channel = null, timeoutMillis = null, callback = null) {
|
|
747
761
|
if (!callback) {
|
|
748
|
-
if (timeoutMillis && lodash__default[
|
|
762
|
+
if (timeoutMillis && lodash__default["default"].isFunction(timeoutMillis)) {
|
|
749
763
|
callback = timeoutMillis;
|
|
750
764
|
timeoutMillis = null;
|
|
751
|
-
} else if (!timeoutMillis && channel && lodash__default[
|
|
765
|
+
} else if (!timeoutMillis && channel && lodash__default["default"].isFunction(channel)) {
|
|
752
766
|
callback = channel;
|
|
753
767
|
timeoutMillis = null;
|
|
754
768
|
channel = null;
|
|
@@ -860,7 +874,7 @@ function getCjsExportFromNamespace (n) {
|
|
|
860
874
|
return n && n['default'] || n;
|
|
861
875
|
}
|
|
862
876
|
|
|
863
|
-
const BotiumError$
|
|
877
|
+
const BotiumError$7 = class BotiumError extends Error {
|
|
864
878
|
/**
|
|
865
879
|
*
|
|
866
880
|
* @param message
|
|
@@ -889,7 +903,7 @@ const BotiumError$6 = class BotiumError extends Error {
|
|
|
889
903
|
const lines = [];
|
|
890
904
|
|
|
891
905
|
if (this.context) {
|
|
892
|
-
const errArr = lodash__default[
|
|
906
|
+
const errArr = lodash__default["default"].isArray(this.context) ? this.context : [this.context];
|
|
893
907
|
errArr.forEach(errDetail => {
|
|
894
908
|
lines.push('########################################');
|
|
895
909
|
|
|
@@ -938,7 +952,7 @@ const BotiumError$6 = class BotiumError extends Error {
|
|
|
938
952
|
};
|
|
939
953
|
|
|
940
954
|
const _getChildErrorsFromContext = context => {
|
|
941
|
-
if (context && context.errors && lodash__default[
|
|
955
|
+
if (context && context.errors && lodash__default["default"].isArray(context.errors)) {
|
|
942
956
|
return context.errors;
|
|
943
957
|
}
|
|
944
958
|
|
|
@@ -946,10 +960,10 @@ const _getChildErrorsFromContext = context => {
|
|
|
946
960
|
};
|
|
947
961
|
|
|
948
962
|
const botiumErrorFromErr$2 = (message, err) => {
|
|
949
|
-
if (err instanceof BotiumError$
|
|
950
|
-
return new BotiumError$
|
|
963
|
+
if (err instanceof BotiumError$7) {
|
|
964
|
+
return new BotiumError$7(message, err.context, true);
|
|
951
965
|
} else {
|
|
952
|
-
return new BotiumError$
|
|
966
|
+
return new BotiumError$7(message, {
|
|
953
967
|
err
|
|
954
968
|
}, true);
|
|
955
969
|
}
|
|
@@ -964,7 +978,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
964
978
|
let children = [];
|
|
965
979
|
|
|
966
980
|
for (const error of errors) {
|
|
967
|
-
if (error instanceof BotiumError$
|
|
981
|
+
if (error instanceof BotiumError$7) {
|
|
968
982
|
const childErrors = flat && _getChildErrorsFromContext(error.context);
|
|
969
983
|
|
|
970
984
|
if (childErrors && childErrors.length) {
|
|
@@ -977,7 +991,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
977
991
|
}
|
|
978
992
|
}
|
|
979
993
|
|
|
980
|
-
const result = new BotiumError$
|
|
994
|
+
const result = new BotiumError$7(message, {
|
|
981
995
|
errors: children,
|
|
982
996
|
type,
|
|
983
997
|
source
|
|
@@ -986,7 +1000,7 @@ const botiumErrorFromList$2 = (errors, {
|
|
|
986
1000
|
};
|
|
987
1001
|
|
|
988
1002
|
var BotiumError_1 = {
|
|
989
|
-
BotiumError: BotiumError$
|
|
1003
|
+
BotiumError: BotiumError$7,
|
|
990
1004
|
botiumErrorFromErr: botiumErrorFromErr$2,
|
|
991
1005
|
botiumErrorFromList: botiumErrorFromList$2
|
|
992
1006
|
};
|
|
@@ -1078,6 +1092,18 @@ var LogicHookConsts = {
|
|
|
1078
1092
|
}, {
|
|
1079
1093
|
name: 'TEXT_WILDCARD_ALL_IC',
|
|
1080
1094
|
className: 'TextWildcardAllICAsserter'
|
|
1095
|
+
}, {
|
|
1096
|
+
name: 'TEXT_WILDCARDEXACT_ANY',
|
|
1097
|
+
className: 'TextWildcardExactAnyAsserter'
|
|
1098
|
+
}, {
|
|
1099
|
+
name: 'TEXT_WILDCARDEXACT_ANY_IC',
|
|
1100
|
+
className: 'TextWildcardExactAnyICAsserter'
|
|
1101
|
+
}, {
|
|
1102
|
+
name: 'TEXT_WILDCARDEXACT_ALL',
|
|
1103
|
+
className: 'TextWildcardExactAllAsserter'
|
|
1104
|
+
}, {
|
|
1105
|
+
name: 'TEXT_WILDCARDEXACT_ALL_IC',
|
|
1106
|
+
className: 'TextWildcardExactAllICAsserter'
|
|
1081
1107
|
}, {
|
|
1082
1108
|
name: 'TEXT_REGEXP_ANY',
|
|
1083
1109
|
className: 'TextRegexpAnyAsserter'
|
|
@@ -1152,10 +1178,10 @@ LogicHookConsts.DEFAULT_USER_INPUTS;
|
|
|
1152
1178
|
|
|
1153
1179
|
const {
|
|
1154
1180
|
NodeVM: NodeVM$2
|
|
1155
|
-
} = vm2__default[
|
|
1156
|
-
const debug$k = debug__default[
|
|
1181
|
+
} = vm2__default["default"];
|
|
1182
|
+
const debug$k = debug__default["default"]('botium-core-asserterUtils');
|
|
1157
1183
|
const {
|
|
1158
|
-
BotiumError: BotiumError$
|
|
1184
|
+
BotiumError: BotiumError$6
|
|
1159
1185
|
} = BotiumError_1;
|
|
1160
1186
|
const {
|
|
1161
1187
|
DEFAULT_ASSERTERS,
|
|
@@ -1306,10 +1332,10 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1306
1332
|
|
|
1307
1333
|
const _checkUnsafe = () => {
|
|
1308
1334
|
if (!this.caps[Capabilities.SECURITY_ALLOW_UNSAFE]) {
|
|
1309
|
-
throw new BotiumError$
|
|
1335
|
+
throw new BotiumError$6('Security Error. Using unsafe component is not allowed', {
|
|
1310
1336
|
type: 'security',
|
|
1311
1337
|
subtype: 'allow unsafe',
|
|
1312
|
-
source: path__default[
|
|
1338
|
+
source: path__default["default"].basename(__filename),
|
|
1313
1339
|
cause: {
|
|
1314
1340
|
src: !!src,
|
|
1315
1341
|
ref,
|
|
@@ -1326,17 +1352,17 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1326
1352
|
try {
|
|
1327
1353
|
const CheckClass = commonjsRequire(packageName);
|
|
1328
1354
|
|
|
1329
|
-
if (isClass__default[
|
|
1355
|
+
if (isClass__default["default"](CheckClass)) {
|
|
1330
1356
|
return new CheckClass({
|
|
1331
1357
|
ref,
|
|
1332
1358
|
...this.buildScriptContext
|
|
1333
1359
|
}, this.caps, args);
|
|
1334
|
-
} else if (lodash__default[
|
|
1360
|
+
} else if (lodash__default["default"].isFunction(CheckClass)) {
|
|
1335
1361
|
return CheckClass({
|
|
1336
1362
|
ref,
|
|
1337
1363
|
...this.buildScriptContext
|
|
1338
1364
|
}, this.caps, args);
|
|
1339
|
-
} else if (isClass__default[
|
|
1365
|
+
} else if (isClass__default["default"](CheckClass.PluginClass)) {
|
|
1340
1366
|
return new CheckClass.PluginClass({
|
|
1341
1367
|
ref,
|
|
1342
1368
|
...this.buildScriptContext
|
|
@@ -1349,7 +1375,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1349
1375
|
}
|
|
1350
1376
|
}
|
|
1351
1377
|
|
|
1352
|
-
if (isClass__default[
|
|
1378
|
+
if (isClass__default["default"](src)) {
|
|
1353
1379
|
try {
|
|
1354
1380
|
const CheckClass = src;
|
|
1355
1381
|
return new CheckClass({
|
|
@@ -1361,7 +1387,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1361
1387
|
}
|
|
1362
1388
|
}
|
|
1363
1389
|
|
|
1364
|
-
if (lodash__default[
|
|
1390
|
+
if (lodash__default["default"].isFunction(src)) {
|
|
1365
1391
|
try {
|
|
1366
1392
|
return src({
|
|
1367
1393
|
ref,
|
|
@@ -1372,15 +1398,15 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1372
1398
|
}
|
|
1373
1399
|
}
|
|
1374
1400
|
|
|
1375
|
-
if (lodash__default[
|
|
1401
|
+
if (lodash__default["default"].isObject(src) && !lodash__default["default"].isString(src)) {
|
|
1376
1402
|
try {
|
|
1377
1403
|
const hookObject = Object.keys(src).reduce((result, key) => {
|
|
1378
1404
|
result[key] = args => {
|
|
1379
1405
|
const script = src[key];
|
|
1380
1406
|
|
|
1381
|
-
if (lodash__default[
|
|
1407
|
+
if (lodash__default["default"].isFunction(script)) {
|
|
1382
1408
|
return script(args);
|
|
1383
|
-
} else if (lodash__default[
|
|
1409
|
+
} else if (lodash__default["default"].isString(script)) {
|
|
1384
1410
|
try {
|
|
1385
1411
|
const vm = new NodeVM$2({
|
|
1386
1412
|
eval: false,
|
|
@@ -1404,7 +1430,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1404
1430
|
}
|
|
1405
1431
|
}
|
|
1406
1432
|
|
|
1407
|
-
if (lodash__default[
|
|
1433
|
+
if (lodash__default["default"].isString(src)) {
|
|
1408
1434
|
const loadErr = [];
|
|
1409
1435
|
const tryLoads = [{
|
|
1410
1436
|
tryLoadPackageName: src,
|
|
@@ -1435,30 +1461,35 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1435
1461
|
}
|
|
1436
1462
|
}
|
|
1437
1463
|
|
|
1438
|
-
if (isClass__default[
|
|
1464
|
+
if (isClass__default["default"](CheckClass)) {
|
|
1439
1465
|
return new CheckClass({
|
|
1440
1466
|
ref,
|
|
1441
1467
|
...this.buildScriptContext
|
|
1442
1468
|
}, this.caps, args);
|
|
1443
|
-
} else if (lodash__default[
|
|
1469
|
+
} else if (lodash__default["default"].isFunction(CheckClass)) {
|
|
1444
1470
|
return CheckClass({
|
|
1445
1471
|
ref,
|
|
1446
1472
|
...this.buildScriptContext
|
|
1447
1473
|
}, this.caps, args);
|
|
1448
|
-
} else if (isClass__default[
|
|
1474
|
+
} else if (isClass__default["default"](CheckClass.PluginClass)) {
|
|
1449
1475
|
return new CheckClass.PluginClass({
|
|
1450
1476
|
ref,
|
|
1451
1477
|
...this.buildScriptContext
|
|
1452
1478
|
}, this.caps, args);
|
|
1479
|
+
} else if (lodash__default["default"].isFunction(CheckClass.PluginClass)) {
|
|
1480
|
+
return CheckClass.PluginClass({
|
|
1481
|
+
ref,
|
|
1482
|
+
...this.buildScriptContext
|
|
1483
|
+
}, this.caps, args);
|
|
1453
1484
|
} else {
|
|
1454
1485
|
throw new Error(`${src} class or function expected`);
|
|
1455
1486
|
}
|
|
1456
1487
|
};
|
|
1457
1488
|
|
|
1458
1489
|
for (const tryLoad of tryLoads) {
|
|
1459
|
-
const tryLoadFile = path__default[
|
|
1490
|
+
const tryLoadFile = path__default["default"].resolve(process.cwd(), tryLoad.tryLoadPackageName);
|
|
1460
1491
|
|
|
1461
|
-
if (fs__default[
|
|
1492
|
+
if (fs__default["default"].existsSync(tryLoadFile)) {
|
|
1462
1493
|
_checkUnsafe();
|
|
1463
1494
|
|
|
1464
1495
|
try {
|
|
@@ -1527,7 +1558,7 @@ class BotiumMockMedia$1 {
|
|
|
1527
1558
|
|
|
1528
1559
|
prettify(indent = 0) {
|
|
1529
1560
|
const sections = [];
|
|
1530
|
-
if (this.mediaUri) sections.push(lodash__default[
|
|
1561
|
+
if (this.mediaUri) sections.push(lodash__default["default"].truncate(this.mediaUri, {
|
|
1531
1562
|
length: 200
|
|
1532
1563
|
}));
|
|
1533
1564
|
if (this.mimeType) sections.push(this.mimeType);
|
|
@@ -1547,8 +1578,8 @@ class BotiumMockButton$1 {
|
|
|
1547
1578
|
prettify(indent = 0) {
|
|
1548
1579
|
const sections = [];
|
|
1549
1580
|
if (this.text) sections.push(this.text);
|
|
1550
|
-
if (this.payload) sections.push(lodash__default[
|
|
1551
|
-
if (this.imageUri) sections.push(lodash__default[
|
|
1581
|
+
if (this.payload) sections.push(lodash__default["default"].isObject(this.payload) ? JSON.stringify(this.payload) : this.payload);
|
|
1582
|
+
if (this.imageUri) sections.push(lodash__default["default"].truncate(this.imageUri, {
|
|
1552
1583
|
length: 200
|
|
1553
1584
|
}));
|
|
1554
1585
|
return `${' '.repeat(indent)}BUTTON(${sections.join(' | ')})`;
|
|
@@ -1632,7 +1663,7 @@ BotiumMockRichMessageTypes.BotiumMockForm;
|
|
|
1632
1663
|
class BotiumMockAsserter$1 {
|
|
1633
1664
|
constructor(fromJson = {}) {
|
|
1634
1665
|
this.name = fromJson.name;
|
|
1635
|
-
this.args = lodash__default[
|
|
1666
|
+
this.args = lodash__default["default"].cloneDeep(fromJson.args);
|
|
1636
1667
|
}
|
|
1637
1668
|
|
|
1638
1669
|
}
|
|
@@ -1640,7 +1671,7 @@ class BotiumMockAsserter$1 {
|
|
|
1640
1671
|
class BotiumMockUserInput$1 {
|
|
1641
1672
|
constructor(fromJson = {}) {
|
|
1642
1673
|
this.name = fromJson.name;
|
|
1643
|
-
this.args = lodash__default[
|
|
1674
|
+
this.args = lodash__default["default"].cloneDeep(fromJson.args);
|
|
1644
1675
|
}
|
|
1645
1676
|
|
|
1646
1677
|
}
|
|
@@ -1648,7 +1679,7 @@ class BotiumMockUserInput$1 {
|
|
|
1648
1679
|
class BotiumMockLogicHook$1 {
|
|
1649
1680
|
constructor(fromJson = {}) {
|
|
1650
1681
|
this.name = fromJson.name;
|
|
1651
|
-
this.args = lodash__default[
|
|
1682
|
+
this.args = lodash__default["default"].cloneDeep(fromJson.args);
|
|
1652
1683
|
}
|
|
1653
1684
|
|
|
1654
1685
|
}
|
|
@@ -1706,9 +1737,9 @@ var BotiumMockMessage_1 = class BotiumMockMessage {
|
|
|
1706
1737
|
};
|
|
1707
1738
|
|
|
1708
1739
|
const normalizeText$1 = (str, doCleanup) => {
|
|
1709
|
-
if (str && lodash__default[
|
|
1740
|
+
if (str && lodash__default["default"].isArray(str)) {
|
|
1710
1741
|
str = str.join(' ');
|
|
1711
|
-
} else if (str && !lodash__default[
|
|
1742
|
+
} else if (str && !lodash__default["default"].isString(str)) {
|
|
1712
1743
|
if (str.toString) {
|
|
1713
1744
|
str = str.toString();
|
|
1714
1745
|
} else {
|
|
@@ -1746,13 +1777,13 @@ const quoteRegexpString$2 = str => {
|
|
|
1746
1777
|
|
|
1747
1778
|
const removeBuffers$1 = obj => {
|
|
1748
1779
|
const jsonString = JSON.stringify(obj, (key, value) => {
|
|
1749
|
-
if (lodash__default[
|
|
1780
|
+
if (lodash__default["default"].isBuffer(value)) {
|
|
1750
1781
|
return '(binary data)';
|
|
1751
1782
|
} else if (value && value.type && value.type === 'Buffer') {
|
|
1752
1783
|
return '(binary data)';
|
|
1753
1784
|
} else if (key.toLowerCase() === 'base64') {
|
|
1754
1785
|
return '(base64 data)';
|
|
1755
|
-
} else if (lodash__default[
|
|
1786
|
+
} else if (lodash__default["default"].isString(value) && value.startsWith('data:')) {
|
|
1756
1787
|
return '(base64 data url)';
|
|
1757
1788
|
}
|
|
1758
1789
|
|
|
@@ -1762,10 +1793,10 @@ const removeBuffers$1 = obj => {
|
|
|
1762
1793
|
};
|
|
1763
1794
|
|
|
1764
1795
|
const toString$3 = value => {
|
|
1765
|
-
if (lodash__default[
|
|
1766
|
-
if (lodash__default[
|
|
1767
|
-
if (lodash__default[
|
|
1768
|
-
if (lodash__default[
|
|
1796
|
+
if (lodash__default["default"].isUndefined(value)) return undefined;
|
|
1797
|
+
if (lodash__default["default"].isString(value)) return value;
|
|
1798
|
+
if (lodash__default["default"].isNumber(value)) return value.toString();
|
|
1799
|
+
if (lodash__default["default"].isArray(value)) return value.map(v => toString$3(v)).join(',');
|
|
1769
1800
|
|
|
1770
1801
|
try {
|
|
1771
1802
|
return JSON.stringify(value);
|
|
@@ -1776,7 +1807,7 @@ const toString$3 = value => {
|
|
|
1776
1807
|
};
|
|
1777
1808
|
|
|
1778
1809
|
const flatString = str => {
|
|
1779
|
-
return str.split('\n').map(s => s.trim()).join(' ');
|
|
1810
|
+
return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
|
|
1780
1811
|
};
|
|
1781
1812
|
|
|
1782
1813
|
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
@@ -1796,7 +1827,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1796
1827
|
let textLinesAccepted = true;
|
|
1797
1828
|
|
|
1798
1829
|
for (const rawLine of lines) {
|
|
1799
|
-
if (lodash__default[
|
|
1830
|
+
if (lodash__default["default"].isString(rawLine)) {
|
|
1800
1831
|
let optional = false;
|
|
1801
1832
|
let not = false;
|
|
1802
1833
|
let logicLine = rawLine;
|
|
@@ -1862,13 +1893,13 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1862
1893
|
textLinesRaw = [];
|
|
1863
1894
|
}
|
|
1864
1895
|
}
|
|
1865
|
-
} else if (lodash__default[
|
|
1896
|
+
} else if (lodash__default["default"].isObject(rawLine)) {
|
|
1866
1897
|
if (rawLine.asserter) {
|
|
1867
1898
|
if (sender !== 'bot') throw new Error(`Failed to parse conversation. No asserter "${rawLine.asserter}" expected in section "${sender}"`);
|
|
1868
1899
|
if (!context.IsAsserterValid(rawLine.asserter)) throw new Error(`Failed to parse conversation. No asserter "${rawLine.asserter}" registered for section "${sender}"`);
|
|
1869
1900
|
convoStep.asserters.push({
|
|
1870
1901
|
name: rawLine.asserter,
|
|
1871
|
-
args: (rawLine.args && lodash__default[
|
|
1902
|
+
args: (rawLine.args && lodash__default["default"].isString(rawLine.args) ? [rawLine.args] : rawLine.args) || [],
|
|
1872
1903
|
not: !!rawLine.not,
|
|
1873
1904
|
optional: !!rawLine.optional
|
|
1874
1905
|
});
|
|
@@ -1877,7 +1908,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1877
1908
|
if (!context.IsLogicHookValid(logicHookName)) throw new Error(`Failed to parse conversation. No logichook "${logicHookName}" registered for section "${sender}"`);
|
|
1878
1909
|
convoStep.logicHooks.push({
|
|
1879
1910
|
name: logicHookName,
|
|
1880
|
-
args: (rawLine.args && lodash__default[
|
|
1911
|
+
args: (rawLine.args && lodash__default["default"].isString(rawLine.args) ? [rawLine.args] : rawLine.args) || []
|
|
1881
1912
|
});
|
|
1882
1913
|
} else if (rawLine.userinput || rawLine.userInput) {
|
|
1883
1914
|
const userInputName = rawLine.userinput || rawLine.userInput;
|
|
@@ -1885,7 +1916,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1885
1916
|
if (!context.IsUserInputValid(userInputName)) throw new Error(`Failed to parse conversation. No userinput "${userInputName}" registered for section "${sender}"`);
|
|
1886
1917
|
convoStep.userInputs.push({
|
|
1887
1918
|
name: userInputName,
|
|
1888
|
-
args: (rawLine.args && lodash__default[
|
|
1919
|
+
args: (rawLine.args && lodash__default["default"].isString(rawLine.args) ? [rawLine.args] : rawLine.args) || []
|
|
1889
1920
|
});
|
|
1890
1921
|
} else {
|
|
1891
1922
|
let name = Object.keys(rawLine)[0];
|
|
@@ -1912,19 +1943,19 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1912
1943
|
if (sender !== 'me' && context.IsAsserterValid(name)) {
|
|
1913
1944
|
convoStep.asserters.push({
|
|
1914
1945
|
name,
|
|
1915
|
-
args: (content && lodash__default[
|
|
1946
|
+
args: (content && lodash__default["default"].isString(content) ? [content] : content) || [],
|
|
1916
1947
|
not,
|
|
1917
1948
|
optional
|
|
1918
1949
|
});
|
|
1919
1950
|
} else if (sender === 'me' && context.IsUserInputValid(name)) {
|
|
1920
1951
|
convoStep.userInputs.push({
|
|
1921
1952
|
name,
|
|
1922
|
-
args: (content && lodash__default[
|
|
1953
|
+
args: (content && lodash__default["default"].isString(content) ? [content] : content) || []
|
|
1923
1954
|
});
|
|
1924
1955
|
} else if (context.IsLogicHookValid(name)) {
|
|
1925
1956
|
convoStep.logicHooks.push({
|
|
1926
1957
|
name,
|
|
1927
|
-
args: (content && lodash__default[
|
|
1958
|
+
args: (content && lodash__default["default"].isString(content) ? [content] : content) || []
|
|
1928
1959
|
});
|
|
1929
1960
|
} else {
|
|
1930
1961
|
throw new Error(`Failed to parse conversation. Line not recognized '${JSON.stringify(rawLine)}'`);
|
|
@@ -1960,7 +1991,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1960
1991
|
|
|
1961
1992
|
const content = textLines.join(' ');
|
|
1962
1993
|
|
|
1963
|
-
if (isJson__default[
|
|
1994
|
+
if (isJson__default["default"](content)) {
|
|
1964
1995
|
convoStep.sourceData = JSON.parse(content);
|
|
1965
1996
|
} else {
|
|
1966
1997
|
/// csv has always just 1 line, and has no eol setting
|
|
@@ -2067,9 +2098,9 @@ const convoStepToObject$1 = step => {
|
|
|
2067
2098
|
if (step.cards && step.cards.length > 0) {
|
|
2068
2099
|
step.cards.forEach(c => {
|
|
2069
2100
|
let cardTexts = [];
|
|
2070
|
-
if (c.text) cardTexts = cardTexts.concat(lodash__default[
|
|
2071
|
-
if (c.subtext) cardTexts = cardTexts.concat(lodash__default[
|
|
2072
|
-
if (c.content) cardTexts = cardTexts.concat(lodash__default[
|
|
2101
|
+
if (c.text) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.text) ? c.text : [c.text]);
|
|
2102
|
+
if (c.subtext) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2103
|
+
if (c.content) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.content) ? c.content : [c.content]);
|
|
2073
2104
|
|
|
2074
2105
|
if (cardTexts.length > 0) {
|
|
2075
2106
|
result.push({
|
|
@@ -2168,7 +2199,7 @@ const _decompileButton = b => {
|
|
|
2168
2199
|
let buttonScript = '';
|
|
2169
2200
|
|
|
2170
2201
|
if (b.payload) {
|
|
2171
|
-
buttonScript += lodash__default[
|
|
2202
|
+
buttonScript += lodash__default["default"].isObject(b.payload) ? JSON.stringify(b.payload) : flatString(b.payload);
|
|
2172
2203
|
|
|
2173
2204
|
if (b.text) {
|
|
2174
2205
|
buttonScript += `|${flatString(b.text)}`;
|
|
@@ -2207,17 +2238,17 @@ const convoStepToLines$2 = step => {
|
|
|
2207
2238
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
|
|
2208
2239
|
}
|
|
2209
2240
|
|
|
2210
|
-
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.map(b => flatString(b.text)).join('|'));
|
|
2241
|
+
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
|
|
2211
2242
|
if (step.media && step.media.length > 0) lines.push('MEDIA ' + step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri).join('|'));
|
|
2212
2243
|
|
|
2213
2244
|
if (step.cards && step.cards.length > 0) {
|
|
2214
2245
|
step.cards.forEach(c => {
|
|
2215
2246
|
let cardTexts = [];
|
|
2216
|
-
if (c.text) cardTexts = cardTexts.concat(lodash__default[
|
|
2217
|
-
if (c.subtext) cardTexts = cardTexts.concat(lodash__default[
|
|
2218
|
-
if (c.content) cardTexts = cardTexts.concat(lodash__default[
|
|
2247
|
+
if (c.text) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.text) ? c.text : [c.text]);
|
|
2248
|
+
if (c.subtext) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2249
|
+
if (c.content) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.content) ? c.content : [c.content]);
|
|
2219
2250
|
if (cardTexts.length > 0) lines.push('CARDS ' + cardTexts.map(c => flatString(c)).join('|'));
|
|
2220
|
-
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.map(b => flatString(b.text)).join('|'));
|
|
2251
|
+
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
|
|
2221
2252
|
if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
|
|
2222
2253
|
});
|
|
2223
2254
|
}
|
|
@@ -2248,19 +2279,19 @@ var helper = {
|
|
|
2248
2279
|
validateConvo: validateConvo$2
|
|
2249
2280
|
};
|
|
2250
2281
|
|
|
2251
|
-
const debug$j = debug__default[
|
|
2282
|
+
const debug$j = debug__default["default"]('botium-core-ScriptingMemory');
|
|
2252
2283
|
const {
|
|
2253
2284
|
v1: uuidv1
|
|
2254
|
-
} = uuid__default[
|
|
2285
|
+
} = uuid__default["default"];
|
|
2255
2286
|
const {
|
|
2256
2287
|
NodeVM: NodeVM$1
|
|
2257
|
-
} = vm2__default[
|
|
2288
|
+
} = vm2__default["default"];
|
|
2258
2289
|
const {
|
|
2259
2290
|
quoteRegexpString: quoteRegexpString$1,
|
|
2260
2291
|
toString: toString$2
|
|
2261
2292
|
} = helper;
|
|
2262
2293
|
const {
|
|
2263
|
-
BotiumError: BotiumError$
|
|
2294
|
+
BotiumError: BotiumError$5
|
|
2264
2295
|
} = BotiumError_1; // If they got parameter, then it will be a string always.
|
|
2265
2296
|
// the receiver can decide what to do with it,
|
|
2266
2297
|
// convert to int,
|
|
@@ -2275,14 +2306,14 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2275
2306
|
return new Date().toLocaleString('en-EN');
|
|
2276
2307
|
},
|
|
2277
2308
|
$now_DE: () => {
|
|
2278
|
-
return moment__default[
|
|
2309
|
+
return moment__default["default"]().format('DD.MM.YYYY, HH:mm:ss');
|
|
2279
2310
|
},
|
|
2280
2311
|
$now_ISO: () => {
|
|
2281
2312
|
return new Date().toISOString();
|
|
2282
2313
|
},
|
|
2283
2314
|
$date: pattern => {
|
|
2284
2315
|
if (pattern) {
|
|
2285
|
-
return moment__default[
|
|
2316
|
+
return moment__default["default"]().format(pattern);
|
|
2286
2317
|
}
|
|
2287
2318
|
|
|
2288
2319
|
return new Date().toLocaleDateString();
|
|
@@ -2291,10 +2322,10 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2291
2322
|
return new Date().toLocaleDateString('en-EN');
|
|
2292
2323
|
},
|
|
2293
2324
|
$date_DE: () => {
|
|
2294
|
-
return moment__default[
|
|
2325
|
+
return moment__default["default"]().format('YYYY.MM.DD');
|
|
2295
2326
|
},
|
|
2296
2327
|
$date_ISO: () => {
|
|
2297
|
-
return moment__default[
|
|
2328
|
+
return moment__default["default"]().format('YYYY-MM-DD');
|
|
2298
2329
|
},
|
|
2299
2330
|
$time: () => {
|
|
2300
2331
|
return new Date().toLocaleTimeString();
|
|
@@ -2303,19 +2334,19 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2303
2334
|
return new Date().toLocaleTimeString('en-EN');
|
|
2304
2335
|
},
|
|
2305
2336
|
$time_DE: () => {
|
|
2306
|
-
return moment__default[
|
|
2337
|
+
return moment__default["default"]().format('HH:mm:ss');
|
|
2307
2338
|
},
|
|
2308
2339
|
$time_ISO: () => {
|
|
2309
|
-
return moment__default[
|
|
2340
|
+
return moment__default["default"]().format('HH:mm:ss');
|
|
2310
2341
|
},
|
|
2311
2342
|
$time_HH_MM: () => {
|
|
2312
|
-
return moment__default[
|
|
2343
|
+
return moment__default["default"]().format('HH:mm');
|
|
2313
2344
|
},
|
|
2314
2345
|
$time_HH: () => {
|
|
2315
|
-
return moment__default[
|
|
2346
|
+
return moment__default["default"]().format('HH');
|
|
2316
2347
|
},
|
|
2317
2348
|
$time_H_A: () => {
|
|
2318
|
-
return moment__default[
|
|
2349
|
+
return moment__default["default"]().format('h A');
|
|
2319
2350
|
},
|
|
2320
2351
|
$timestamp: () => {
|
|
2321
2352
|
return Date.now();
|
|
@@ -2324,26 +2355,26 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2324
2355
|
return new Date().getFullYear();
|
|
2325
2356
|
},
|
|
2326
2357
|
$month: () => {
|
|
2327
|
-
return moment__default[
|
|
2358
|
+
return moment__default["default"]().format('MMMM');
|
|
2328
2359
|
},
|
|
2329
2360
|
$month_MM: () => {
|
|
2330
|
-
return moment__default[
|
|
2361
|
+
return moment__default["default"]().format('MM');
|
|
2331
2362
|
},
|
|
2332
2363
|
$day_of_month: () => {
|
|
2333
2364
|
return new Date().getDate();
|
|
2334
2365
|
},
|
|
2335
2366
|
$day_of_week: () => {
|
|
2336
|
-
return moment__default[
|
|
2367
|
+
return moment__default["default"]().format('dddd');
|
|
2337
2368
|
},
|
|
2338
2369
|
$random: length => {
|
|
2339
2370
|
if (length == null) {
|
|
2340
2371
|
throw Error('random function used without args!');
|
|
2341
2372
|
}
|
|
2342
2373
|
|
|
2343
|
-
return randomatic__default[
|
|
2374
|
+
return randomatic__default["default"]('0', length);
|
|
2344
2375
|
},
|
|
2345
2376
|
$random10: () => {
|
|
2346
|
-
return randomatic__default[
|
|
2377
|
+
return randomatic__default["default"]('0', 10);
|
|
2347
2378
|
},
|
|
2348
2379
|
$uniqid: () => {
|
|
2349
2380
|
return uuidv1();
|
|
@@ -2394,7 +2425,7 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2394
2425
|
throw Error('msg function used at invalid position!');
|
|
2395
2426
|
}
|
|
2396
2427
|
|
|
2397
|
-
const root = jsonpath__default[
|
|
2428
|
+
const root = jsonpath__default["default"].query(mockMsg, jsonPath);
|
|
2398
2429
|
if (root && root.length > 0) return root[0];else return '';
|
|
2399
2430
|
},
|
|
2400
2431
|
numberOfArguments: 1
|
|
@@ -2423,16 +2454,16 @@ const SCRIPTING_FUNCTIONS_RAW = {
|
|
|
2423
2454
|
}
|
|
2424
2455
|
};
|
|
2425
2456
|
|
|
2426
|
-
const SCRIPTING_FUNCTIONS$1 = lodash__default[
|
|
2457
|
+
const SCRIPTING_FUNCTIONS$1 = lodash__default["default"].mapValues(SCRIPTING_FUNCTIONS_RAW, (funcOrStruct, name) => {
|
|
2427
2458
|
const func = funcOrStruct.handler || funcOrStruct;
|
|
2428
2459
|
const numberOfArguments = funcOrStruct.handler ? funcOrStruct.numberOfArguments || 0 : funcOrStruct.length;
|
|
2429
2460
|
return {
|
|
2430
2461
|
handler: (caps, ...rest) => {
|
|
2431
2462
|
if (!caps[Capabilities.SECURITY_ALLOW_UNSAFE] && funcOrStruct.unsafe) {
|
|
2432
|
-
throw new BotiumError$
|
|
2463
|
+
throw new BotiumError$5(`Security Error. Using unsafe scripting memory function ${name} is not allowed`, {
|
|
2433
2464
|
type: 'security',
|
|
2434
2465
|
subtype: 'allow unsafe',
|
|
2435
|
-
source: path__default[
|
|
2466
|
+
source: path__default["default"].basename(__filename),
|
|
2436
2467
|
cause: {
|
|
2437
2468
|
SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
|
|
2438
2469
|
functionName: name
|
|
@@ -2479,7 +2510,7 @@ const _apply = (scriptingMemory, str, caps, mockMsg) => {
|
|
|
2479
2510
|
|
|
2480
2511
|
for (const key of allKeys) {
|
|
2481
2512
|
// scripting memory is stronger
|
|
2482
|
-
if (lodash__default[
|
|
2513
|
+
if (lodash__default["default"].has(scriptingMemory, key)) {
|
|
2483
2514
|
const keyRegexp = new RegExp(`\\${key}`, 'g');
|
|
2484
2515
|
str = str.replace(keyRegexp, scriptingMemory[key]);
|
|
2485
2516
|
} else {
|
|
@@ -2502,11 +2533,11 @@ const _apply = (scriptingMemory, str, caps, mockMsg) => {
|
|
|
2502
2533
|
};
|
|
2503
2534
|
|
|
2504
2535
|
const extractVarNames = text => {
|
|
2505
|
-
return (lodash__default[
|
|
2536
|
+
return (lodash__default["default"].isString(text) ? text.match(/\$[A-Za-z]\w+/g) : false) || [];
|
|
2506
2537
|
};
|
|
2507
2538
|
|
|
2508
2539
|
const fill = (container, scriptingMemory, result, utterance, scriptingEvents) => {
|
|
2509
|
-
debug$j(`fill start: ${util__default[
|
|
2540
|
+
debug$j(`fill start: ${util__default["default"].inspect(scriptingMemory)}`);
|
|
2510
2541
|
let varRegex;
|
|
2511
2542
|
|
|
2512
2543
|
switch (container.caps[Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]) {
|
|
@@ -2523,17 +2554,17 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
|
|
|
2523
2554
|
break;
|
|
2524
2555
|
}
|
|
2525
2556
|
|
|
2526
|
-
if (result && lodash__default[
|
|
2557
|
+
if (result && lodash__default["default"].isString(result) && utterance && container.caps[Capabilities.SCRIPTING_ENABLE_MEMORY]) {
|
|
2527
2558
|
const utterances = scriptingEvents.resolveUtterance({
|
|
2528
2559
|
utterance
|
|
2529
2560
|
});
|
|
2530
2561
|
utterances.forEach(expected => {
|
|
2531
|
-
if (lodash__default[
|
|
2562
|
+
if (lodash__default["default"].isUndefined(expected)) return;
|
|
2532
2563
|
expected = toString$2(expected);
|
|
2533
2564
|
let reExpected = expected;
|
|
2534
2565
|
|
|
2535
2566
|
if (container.caps[Capabilities.SCRIPTING_MATCHING_MODE] !== 'regexp' && container.caps[Capabilities.SCRIPTING_MATCHING_MODE] !== 'regexpIgnoreCase') {
|
|
2536
|
-
reExpected = lodash__default[
|
|
2567
|
+
reExpected = lodash__default["default"].isString(expected) ? quoteRegexpString$1(expected).replace(/\\\$/g, '$') : expected;
|
|
2537
2568
|
}
|
|
2538
2569
|
|
|
2539
2570
|
const varMatches = extractVarNames(expected);
|
|
@@ -2557,7 +2588,7 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
|
|
|
2557
2588
|
}
|
|
2558
2589
|
}
|
|
2559
2590
|
});
|
|
2560
|
-
debug$j(`fill end: ${util__default[
|
|
2591
|
+
debug$j(`fill end: ${util__default["default"].inspect(scriptingMemory)}`);
|
|
2561
2592
|
}
|
|
2562
2593
|
};
|
|
2563
2594
|
|
|
@@ -2576,9 +2607,9 @@ ScriptingMemory.extractVarNames;
|
|
|
2576
2607
|
ScriptingMemory.RESERVED_WORDS;
|
|
2577
2608
|
ScriptingMemory.SCRIPTING_FUNCTIONS;
|
|
2578
2609
|
|
|
2579
|
-
const debug$i = debug__default[
|
|
2610
|
+
const debug$i = debug__default["default"]('botium-core-Convo');
|
|
2580
2611
|
const {
|
|
2581
|
-
BotiumError: BotiumError$
|
|
2612
|
+
BotiumError: BotiumError$4,
|
|
2582
2613
|
botiumErrorFromErr: botiumErrorFromErr$1,
|
|
2583
2614
|
botiumErrorFromList: botiumErrorFromList$1
|
|
2584
2615
|
} = BotiumError_1;
|
|
@@ -2656,9 +2687,9 @@ class ConvoStep$1 {
|
|
|
2656
2687
|
this.stepTag = fromJson.stepTag;
|
|
2657
2688
|
this.not = fromJson.not;
|
|
2658
2689
|
this.optional = fromJson.optional;
|
|
2659
|
-
this.asserters = lodash__default[
|
|
2660
|
-
this.logicHooks = lodash__default[
|
|
2661
|
-
this.userInputs = lodash__default[
|
|
2690
|
+
this.asserters = lodash__default["default"].map(fromJson.asserters, asserter => new ConvoStepAssert(asserter));
|
|
2691
|
+
this.logicHooks = lodash__default["default"].map(fromJson.logicHooks, logicHook => new ConvoStepLogicHook(logicHook));
|
|
2692
|
+
this.userInputs = lodash__default["default"].map(fromJson.userInputs, userInput => new ConvoStepUserInput(userInput));
|
|
2662
2693
|
}
|
|
2663
2694
|
|
|
2664
2695
|
hasInteraction() {
|
|
@@ -2750,8 +2781,8 @@ class Convo$6 {
|
|
|
2750
2781
|
this.context = context;
|
|
2751
2782
|
this.header = new ConvoHeader$1(fromJson.header);
|
|
2752
2783
|
|
|
2753
|
-
if (fromJson.conversation && lodash__default[
|
|
2754
|
-
this.conversation = lodash__default[
|
|
2784
|
+
if (fromJson.conversation && lodash__default["default"].isArray(fromJson.conversation)) {
|
|
2785
|
+
this.conversation = lodash__default["default"].map(fromJson.conversation, step => new ConvoStep$1(step));
|
|
2755
2786
|
} else {
|
|
2756
2787
|
this.conversation = [];
|
|
2757
2788
|
}
|
|
@@ -2791,7 +2822,7 @@ class Convo$6 {
|
|
|
2791
2822
|
}
|
|
2792
2823
|
|
|
2793
2824
|
toString() {
|
|
2794
|
-
return this.header.toString() + (this.sourceTag ? ` (${util__default[
|
|
2825
|
+
return this.header.toString() + (this.sourceTag ? ` (${util__default["default"].inspect(this.sourceTag)})` : '') + ': ' + this.conversation.map(c => c.toString()).join(' | ');
|
|
2795
2826
|
}
|
|
2796
2827
|
|
|
2797
2828
|
async Run(container) {
|
|
@@ -2972,7 +3003,7 @@ class Convo$6 {
|
|
|
2972
3003
|
});
|
|
2973
3004
|
await this._checkBotRepliesConsumed(container);
|
|
2974
3005
|
|
|
2975
|
-
const coreMsg = lodash__default[
|
|
3006
|
+
const coreMsg = lodash__default["default"].omit(removeBuffers(meMsg), ['sourceData']);
|
|
2976
3007
|
|
|
2977
3008
|
debug$i(`${this.header.name}/${convoStep.stepTag}: user says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
2978
3009
|
await new Promise(resolve => {
|
|
@@ -2985,7 +3016,7 @@ class Convo$6 {
|
|
|
2985
3016
|
lastMeConvoStep = convoStep;
|
|
2986
3017
|
transcriptStep.botBegin = new Date();
|
|
2987
3018
|
|
|
2988
|
-
if (!lodash__default[
|
|
3019
|
+
if (!lodash__default["default"].isNull(meMsg.messageText) || meMsg.sourceData || meMsg.userInputs && meMsg.userInputs.length || meMsg.logicHooks && meMsg.logicHooks.length) {
|
|
2989
3020
|
try {
|
|
2990
3021
|
Object.assign(meMsg, {
|
|
2991
3022
|
header: this.header,
|
|
@@ -3012,7 +3043,7 @@ class Convo$6 {
|
|
|
3012
3043
|
});
|
|
3013
3044
|
continue;
|
|
3014
3045
|
} else {
|
|
3015
|
-
debug$i(`${this.header.name}/${convoStep.stepTag}: message not found in #me section, message not sent to container ${util__default[
|
|
3046
|
+
debug$i(`${this.header.name}/${convoStep.stepTag}: message not found in #me section, message not sent to container ${util__default["default"].inspect(convoStep)}`);
|
|
3016
3047
|
transcriptStep.botEnd = new Date();
|
|
3017
3048
|
await this.scriptingEvents.onMeEnd({
|
|
3018
3049
|
convo: this,
|
|
@@ -3062,7 +3093,7 @@ class Convo$6 {
|
|
|
3062
3093
|
transcriptStep.botEnd = new Date();
|
|
3063
3094
|
transcriptStep.actual = new BotiumMockMessage_1(botMsg);
|
|
3064
3095
|
|
|
3065
|
-
const coreMsg = lodash__default[
|
|
3096
|
+
const coreMsg = lodash__default["default"].omit(removeBuffers(botMsg), ['sourceData']);
|
|
3066
3097
|
|
|
3067
3098
|
debug$i(`${this.header.name}: bot says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
3068
3099
|
} catch (err) {
|
|
@@ -3091,7 +3122,7 @@ class Convo$6 {
|
|
|
3091
3122
|
if (prepared) {
|
|
3092
3123
|
transcriptStep.actual = new BotiumMockMessage_1(botMsg);
|
|
3093
3124
|
|
|
3094
|
-
const coreMsg = lodash__default[
|
|
3125
|
+
const coreMsg = lodash__default["default"].omit(removeBuffers(botMsg), ['sourceData']);
|
|
3095
3126
|
|
|
3096
3127
|
debug$i(`${this.header.name}: onBotPrepare (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
|
|
3097
3128
|
}
|
|
@@ -3107,7 +3138,7 @@ class Convo$6 {
|
|
|
3107
3138
|
}
|
|
3108
3139
|
|
|
3109
3140
|
if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
|
|
3110
|
-
const failErr = new BotiumError$
|
|
3141
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
|
|
3111
3142
|
debug$i(failErr);
|
|
3112
3143
|
|
|
3113
3144
|
try {
|
|
@@ -3210,7 +3241,7 @@ class Convo$6 {
|
|
|
3210
3241
|
this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
|
|
3211
3242
|
} catch (failErr) {}
|
|
3212
3243
|
|
|
3213
|
-
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$
|
|
3244
|
+
if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$4) {
|
|
3214
3245
|
assertErrors.push(err);
|
|
3215
3246
|
} else {
|
|
3216
3247
|
throw failErr;
|
|
@@ -3227,7 +3258,7 @@ class Convo$6 {
|
|
|
3227
3258
|
}
|
|
3228
3259
|
}
|
|
3229
3260
|
} else {
|
|
3230
|
-
const failErr = new BotiumError$
|
|
3261
|
+
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util__default["default"].inspect(convoStep.sender)}`);
|
|
3231
3262
|
debug$i(failErr);
|
|
3232
3263
|
|
|
3233
3264
|
try {
|
|
@@ -3238,7 +3269,7 @@ class Convo$6 {
|
|
|
3238
3269
|
}
|
|
3239
3270
|
} catch (err) {
|
|
3240
3271
|
if (lastMeConvoStep) {
|
|
3241
|
-
if (err instanceof BotiumError$
|
|
3272
|
+
if (err instanceof BotiumError$4 && err.context) {
|
|
3242
3273
|
err.context.input = new ConvoStep$1(lastMeConvoStep);
|
|
3243
3274
|
err.context.transcript = [...transcriptSteps, { ...transcriptStep
|
|
3244
3275
|
}];
|
|
@@ -3271,24 +3302,24 @@ class Convo$6 {
|
|
|
3271
3302
|
_compareObject(container, scriptingMemory, convoStep, result, expected, botMsg) {
|
|
3272
3303
|
if (expected === null || expected === undefined) return;
|
|
3273
3304
|
|
|
3274
|
-
if (lodash__default[
|
|
3275
|
-
if (!lodash__default[
|
|
3276
|
-
throw new BotiumError$
|
|
3305
|
+
if (lodash__default["default"].isArray(expected)) {
|
|
3306
|
+
if (!lodash__default["default"].isArray(result)) {
|
|
3307
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array, got "${result}"`);
|
|
3277
3308
|
}
|
|
3278
3309
|
|
|
3279
3310
|
if (expected.length !== result.length) {
|
|
3280
|
-
throw new BotiumError$
|
|
3311
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array length ${expected.length}, got ${result.length}`);
|
|
3281
3312
|
}
|
|
3282
3313
|
|
|
3283
3314
|
for (let i = 0; i < expected.length; i++) {
|
|
3284
3315
|
this._compareObject(container, scriptingMemory, convoStep, result[i], expected[i]);
|
|
3285
3316
|
}
|
|
3286
|
-
} else if (lodash__default[
|
|
3287
|
-
lodash__default[
|
|
3317
|
+
} else if (lodash__default["default"].isObject(expected)) {
|
|
3318
|
+
lodash__default["default"].forOwn(expected, (value, key) => {
|
|
3288
3319
|
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
3289
3320
|
this._compareObject(container, scriptingMemory, convoStep, result[key], expected[key]);
|
|
3290
3321
|
} else {
|
|
3291
|
-
throw new BotiumError$
|
|
3322
|
+
throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response "${result}" missing expected property: ${key}`);
|
|
3292
3323
|
}
|
|
3293
3324
|
});
|
|
3294
3325
|
} else {
|
|
@@ -3336,7 +3367,7 @@ class Convo$6 {
|
|
|
3336
3367
|
utterance
|
|
3337
3368
|
});
|
|
3338
3369
|
return utterances.reduce((acc, expected) => {
|
|
3339
|
-
if (lodash__default[
|
|
3370
|
+
if (lodash__default["default"].isUndefined(expected)) return acc;else return acc.concat(ScriptingMemory.extractVarNames(toString$1(expected)) || []);
|
|
3340
3371
|
}, []);
|
|
3341
3372
|
}
|
|
3342
3373
|
|
|
@@ -3416,17 +3447,17 @@ class Convo$6 {
|
|
|
3416
3447
|
const alreadyThereAt = parentPConvos.indexOf(includeLogicHook);
|
|
3417
3448
|
|
|
3418
3449
|
if (alreadyThereAt >= 0) {
|
|
3419
|
-
throw new BotiumError$
|
|
3450
|
+
throw new BotiumError$4(`Partial convos are included circular. "${includeLogicHook}" is referenced by "/${parentPConvos.slice(0, alreadyThereAt).join('/')}" and by "/${parentPConvos.join('/')}" `);
|
|
3420
3451
|
}
|
|
3421
3452
|
|
|
3422
3453
|
if (!partialConvos || Object.keys(partialConvos).length === 0) {
|
|
3423
|
-
throw new BotiumError$
|
|
3454
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (There are no partial convos)`);
|
|
3424
3455
|
}
|
|
3425
3456
|
|
|
3426
3457
|
const partialConvo = partialConvos[includeLogicHook];
|
|
3427
3458
|
|
|
3428
3459
|
if (!partialConvo) {
|
|
3429
|
-
throw new BotiumError$
|
|
3460
|
+
throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
|
|
3430
3461
|
}
|
|
3431
3462
|
|
|
3432
3463
|
_getEffectiveConversationRecursive(partialConvo.conversation, [...parentPConvos, includeLogicHook], result, true);
|
|
@@ -3459,11 +3490,11 @@ var RetryHelper_1 = class RetryHelper {
|
|
|
3459
3490
|
const onErrorRegexp = caps[`RETRY_${section.toUpperCase()}_ONERROR_REGEXP`] || [];
|
|
3460
3491
|
|
|
3461
3492
|
if (onErrorRegexp) {
|
|
3462
|
-
if (lodash__default[
|
|
3493
|
+
if (lodash__default["default"].isArray(onErrorRegexp)) {
|
|
3463
3494
|
onErrorRegexp.forEach(r => {
|
|
3464
|
-
if (lodash__default[
|
|
3495
|
+
if (lodash__default["default"].isString(r)) this.retryErrorPatterns.push(new RegExp(r, 'i'));else this.retryErrorPatterns.push(r);
|
|
3465
3496
|
});
|
|
3466
|
-
} else if (lodash__default[
|
|
3497
|
+
} else if (lodash__default["default"].isString(onErrorRegexp)) {
|
|
3467
3498
|
this.retryErrorPatterns.push(new RegExp(onErrorRegexp, 'i'));
|
|
3468
3499
|
} else {
|
|
3469
3500
|
this.retryErrorPatterns.push(onErrorRegexp);
|
|
@@ -3473,7 +3504,7 @@ var RetryHelper_1 = class RetryHelper {
|
|
|
3473
3504
|
|
|
3474
3505
|
shouldRetry(err) {
|
|
3475
3506
|
if (!err || this.retryErrorPatterns.length === 0) return false;
|
|
3476
|
-
const errString = util__default[
|
|
3507
|
+
const errString = util__default["default"].inspect(err);
|
|
3477
3508
|
|
|
3478
3509
|
for (const re of this.retryErrorPatterns) {
|
|
3479
3510
|
if (errString.match(re)) return true;
|
|
@@ -3490,9 +3521,9 @@ const {
|
|
|
3490
3521
|
} = helper;
|
|
3491
3522
|
|
|
3492
3523
|
const _normalize = botresponse => {
|
|
3493
|
-
if (lodash__default[
|
|
3524
|
+
if (lodash__default["default"].isUndefined(botresponse)) return '';
|
|
3494
3525
|
|
|
3495
|
-
if (lodash__default[
|
|
3526
|
+
if (lodash__default["default"].isObject(botresponse) && lodash__default["default"].has(botresponse, 'messageText')) {
|
|
3496
3527
|
return toString(botresponse.messageText) || '';
|
|
3497
3528
|
}
|
|
3498
3529
|
|
|
@@ -3500,7 +3531,7 @@ const _normalize = botresponse => {
|
|
|
3500
3531
|
};
|
|
3501
3532
|
|
|
3502
3533
|
const regexp = ignoreCase => (botresponse, utterance) => {
|
|
3503
|
-
if (lodash__default[
|
|
3534
|
+
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3504
3535
|
utterance = toString(utterance);
|
|
3505
3536
|
botresponse = _normalize(botresponse);
|
|
3506
3537
|
const regexp = ignoreCase ? new RegExp(utterance, 'i') : new RegExp(utterance, '');
|
|
@@ -3508,7 +3539,7 @@ const regexp = ignoreCase => (botresponse, utterance) => {
|
|
|
3508
3539
|
};
|
|
3509
3540
|
|
|
3510
3541
|
const wildcard = ignoreCase => (botresponse, utterance) => {
|
|
3511
|
-
if (lodash__default[
|
|
3542
|
+
if (lodash__default["default"].isUndefined(botresponse)) {
|
|
3512
3543
|
if (utterance.trim() === '*') return true;else return false;
|
|
3513
3544
|
}
|
|
3514
3545
|
|
|
@@ -3525,8 +3556,26 @@ const wildcard = ignoreCase => (botresponse, utterance) => {
|
|
|
3525
3556
|
return regexp.test(botresponse);
|
|
3526
3557
|
};
|
|
3527
3558
|
|
|
3559
|
+
const wildcardExact = ignoreCase => (botresponse, utterance) => {
|
|
3560
|
+
if (lodash__default["default"].isUndefined(botresponse)) {
|
|
3561
|
+
if (utterance.trim() === '*') return true;else return false;
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
utterance = toString(utterance);
|
|
3565
|
+
botresponse = _normalize(botresponse);
|
|
3566
|
+
const numWildcards = utterance.split('*').length - 1;
|
|
3567
|
+
|
|
3568
|
+
if (numWildcards > 10) {
|
|
3569
|
+
throw new Error('Maximum number of 10 wildcards supported.');
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3572
|
+
const utteranceRe = '^' + quoteRegexpString(utterance).replace(/\\\*/g, '(.*)') + '$';
|
|
3573
|
+
const regexp = ignoreCase ? new RegExp(utteranceRe, 'i') : new RegExp(utteranceRe, '');
|
|
3574
|
+
return regexp.test(botresponse);
|
|
3575
|
+
};
|
|
3576
|
+
|
|
3528
3577
|
const include = ignoreCase => (botresponse, utterance) => {
|
|
3529
|
-
if (lodash__default[
|
|
3578
|
+
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3530
3579
|
utterance = toString(utterance);
|
|
3531
3580
|
botresponse = _normalize(botresponse);
|
|
3532
3581
|
|
|
@@ -3539,7 +3588,7 @@ const include = ignoreCase => (botresponse, utterance) => {
|
|
|
3539
3588
|
};
|
|
3540
3589
|
|
|
3541
3590
|
const equals = ignoreCase => (botresponse, utterance) => {
|
|
3542
|
-
if (lodash__default[
|
|
3591
|
+
if (lodash__default["default"].isUndefined(botresponse)) return false;
|
|
3543
3592
|
utterance = toString(utterance);
|
|
3544
3593
|
botresponse = _normalize(botresponse);
|
|
3545
3594
|
|
|
@@ -3556,6 +3605,8 @@ const getMatchFunction$1 = matchingMode => {
|
|
|
3556
3605
|
return regexp(matchingMode === 'regexpIgnoreCase');
|
|
3557
3606
|
} else if (matchingMode === 'wildcard' || matchingMode === 'wildcardIgnoreCase' || matchingMode === 'wildcardLowerCase') {
|
|
3558
3607
|
return wildcard(matchingMode === 'wildcardIgnoreCase' || matchingMode === 'wildcardLowerCase');
|
|
3608
|
+
} else if (matchingMode === 'wildcardExact' || matchingMode === 'wildcardExactIgnoreCase') {
|
|
3609
|
+
return wildcardExact(matchingMode === 'wildcardExactIgnoreCase');
|
|
3559
3610
|
} else if (matchingMode === 'include' || matchingMode === 'includeIgnoreCase' || matchingMode === 'includeLowerCase') {
|
|
3560
3611
|
return include(matchingMode === 'includeIgnoreCase' || matchingMode === 'includeLowerCase');
|
|
3561
3612
|
} else if (matchingMode === 'equals' || matchingMode === 'equalsIgnoreCase') {
|
|
@@ -3568,6 +3619,7 @@ const getMatchFunction$1 = matchingMode => {
|
|
|
3568
3619
|
var MatchFunctions = {
|
|
3569
3620
|
regexp,
|
|
3570
3621
|
wildcard,
|
|
3622
|
+
wildcardExact,
|
|
3571
3623
|
include,
|
|
3572
3624
|
equals,
|
|
3573
3625
|
getMatchFunction: getMatchFunction$1
|
|
@@ -3592,7 +3644,7 @@ const isStringJson = string => {
|
|
|
3592
3644
|
|
|
3593
3645
|
|
|
3594
3646
|
const isJsonObject$1 = (json, stringIsJson = true) => {
|
|
3595
|
-
if (!stringIsJson && lodash__default[
|
|
3647
|
+
if (!stringIsJson && lodash__default["default"].isString(json)) {
|
|
3596
3648
|
return false;
|
|
3597
3649
|
}
|
|
3598
3650
|
|
|
@@ -3635,7 +3687,7 @@ const optionalJson = json => {
|
|
|
3635
3687
|
};
|
|
3636
3688
|
|
|
3637
3689
|
const shortenJsonString = obj => {
|
|
3638
|
-
let str = lodash__default[
|
|
3690
|
+
let str = lodash__default["default"].isString(obj) ? obj : JSON.stringify(obj, null, 2);
|
|
3639
3691
|
const length = str.length;
|
|
3640
3692
|
|
|
3641
3693
|
if (length > 1000) {
|
|
@@ -3697,7 +3749,7 @@ var Utils = {
|
|
|
3697
3749
|
};
|
|
3698
3750
|
|
|
3699
3751
|
const _ensureList = queryResult => {
|
|
3700
|
-
if (lodash__default[
|
|
3752
|
+
if (lodash__default["default"].isArray(queryResult)) {
|
|
3701
3753
|
return queryResult;
|
|
3702
3754
|
}
|
|
3703
3755
|
|
|
@@ -3715,7 +3767,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3715
3767
|
const utterancesJsonpath = options.UTTERANCES_JSONPATH;
|
|
3716
3768
|
let scriptData = scriptBuffer;
|
|
3717
3769
|
|
|
3718
|
-
if (lodash__default[
|
|
3770
|
+
if (lodash__default["default"].isString(scriptData)) {
|
|
3719
3771
|
try {
|
|
3720
3772
|
scriptData = JSON.parse(scriptData);
|
|
3721
3773
|
} catch (err) {
|
|
@@ -3724,7 +3776,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3724
3776
|
}
|
|
3725
3777
|
|
|
3726
3778
|
if (checkerJsonpath) {
|
|
3727
|
-
const scouldExist = jsonpath__default[
|
|
3779
|
+
const scouldExist = jsonpath__default["default"].query(scriptData, checkerJsonpath);
|
|
3728
3780
|
|
|
3729
3781
|
if (!scouldExist || scouldExist.length === 0) {
|
|
3730
3782
|
return;
|
|
@@ -3737,7 +3789,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3737
3789
|
let rootObjects;
|
|
3738
3790
|
|
|
3739
3791
|
try {
|
|
3740
|
-
rootObjects = _ensureList(jsonpath__default[
|
|
3792
|
+
rootObjects = _ensureList(jsonpath__default["default"].query(scriptData, rootJsonpath));
|
|
3741
3793
|
} catch (err) {
|
|
3742
3794
|
throw new Error(`Root jsonpath ${rootJsonpath} invalid: ${err.message}`);
|
|
3743
3795
|
}
|
|
@@ -3751,7 +3803,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3751
3803
|
let intent;
|
|
3752
3804
|
|
|
3753
3805
|
try {
|
|
3754
|
-
intent = _ensureList(jsonpath__default[
|
|
3806
|
+
intent = _ensureList(jsonpath__default["default"].query(json, utteranceRefsJsonpath));
|
|
3755
3807
|
} catch (err) {
|
|
3756
3808
|
throw new Error(`Intents jsonpath ${utteranceRefsJsonpath} invalid: ${err.message}`);
|
|
3757
3809
|
}
|
|
@@ -3765,7 +3817,7 @@ var precompile$2 = (caps, scriptBuffer, options, filename) => {
|
|
|
3765
3817
|
}
|
|
3766
3818
|
|
|
3767
3819
|
try {
|
|
3768
|
-
result[intent] = result[intent].concat(jsonpath__default[
|
|
3820
|
+
result[intent] = result[intent].concat(jsonpath__default["default"].query(json, utterancesJsonpath));
|
|
3769
3821
|
} catch (err) {
|
|
3770
3822
|
throw new Error(`Utterances jsonpath ${utteranceRefsJsonpath} invalid: ${err.message}`);
|
|
3771
3823
|
}
|
|
@@ -3784,10 +3836,10 @@ var JsonToJson = {
|
|
|
3784
3836
|
|
|
3785
3837
|
const {
|
|
3786
3838
|
NodeVM
|
|
3787
|
-
} = vm2__default[
|
|
3788
|
-
const debug$h = debug__default[
|
|
3839
|
+
} = vm2__default["default"];
|
|
3840
|
+
const debug$h = debug__default["default"]('botium-core-HookUtils');
|
|
3789
3841
|
const {
|
|
3790
|
-
BotiumError: BotiumError$
|
|
3842
|
+
BotiumError: BotiumError$3
|
|
3791
3843
|
} = BotiumError_1;
|
|
3792
3844
|
|
|
3793
3845
|
const executeHook$2 = async (caps, hook, args) => {
|
|
@@ -3799,7 +3851,7 @@ const executeHookSync$1 = (caps, hook, args) => {
|
|
|
3799
3851
|
return;
|
|
3800
3852
|
}
|
|
3801
3853
|
|
|
3802
|
-
if (lodash__default[
|
|
3854
|
+
if (lodash__default["default"].isFunction(hook)) {
|
|
3803
3855
|
try {
|
|
3804
3856
|
return hook(args);
|
|
3805
3857
|
} catch (err) {
|
|
@@ -3807,7 +3859,7 @@ const executeHookSync$1 = (caps, hook, args) => {
|
|
|
3807
3859
|
}
|
|
3808
3860
|
}
|
|
3809
3861
|
|
|
3810
|
-
if (lodash__default[
|
|
3862
|
+
if (lodash__default["default"].isString(hook)) {
|
|
3811
3863
|
try {
|
|
3812
3864
|
const vm = new NodeVM({
|
|
3813
3865
|
eval: false,
|
|
@@ -3816,7 +3868,7 @@ const executeHookSync$1 = (caps, hook, args) => {
|
|
|
3816
3868
|
});
|
|
3817
3869
|
const r = vm.run(hook);
|
|
3818
3870
|
|
|
3819
|
-
if (lodash__default[
|
|
3871
|
+
if (lodash__default["default"].isFunction(r)) {
|
|
3820
3872
|
return r(args);
|
|
3821
3873
|
} else {
|
|
3822
3874
|
return r;
|
|
@@ -3836,16 +3888,16 @@ const getHook$3 = (caps, data) => {
|
|
|
3836
3888
|
|
|
3837
3889
|
const allowUnsafe = !!caps[Capabilities.SECURITY_ALLOW_UNSAFE];
|
|
3838
3890
|
|
|
3839
|
-
if (lodash__default[
|
|
3891
|
+
if (lodash__default["default"].isFunction(data)) {
|
|
3840
3892
|
debug$h('found hook, type: function definition');
|
|
3841
3893
|
return data;
|
|
3842
3894
|
}
|
|
3843
3895
|
|
|
3844
|
-
if (lodash__default[
|
|
3896
|
+
if (lodash__default["default"].isString(data)) {
|
|
3845
3897
|
let resultWithRequire;
|
|
3846
|
-
let tryLoadFile = path__default[
|
|
3898
|
+
let tryLoadFile = path__default["default"].resolve(process.cwd(), data);
|
|
3847
3899
|
|
|
3848
|
-
if (fs__default[
|
|
3900
|
+
if (fs__default["default"].existsSync(tryLoadFile)) {
|
|
3849
3901
|
try {
|
|
3850
3902
|
resultWithRequire = commonjsRequire(tryLoadFile);
|
|
3851
3903
|
} catch (err) {}
|
|
@@ -3859,10 +3911,10 @@ const getHook$3 = (caps, data) => {
|
|
|
3859
3911
|
|
|
3860
3912
|
if (resultWithRequire) {
|
|
3861
3913
|
if (!allowUnsafe) {
|
|
3862
|
-
throw new BotiumError$
|
|
3914
|
+
throw new BotiumError$3('Security Error. Using unsafe custom hook with require is not allowed', {
|
|
3863
3915
|
type: 'security',
|
|
3864
3916
|
subtype: 'allow unsafe',
|
|
3865
|
-
source: path__default[
|
|
3917
|
+
source: path__default["default"].basename(__filename),
|
|
3866
3918
|
cause: {
|
|
3867
3919
|
SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
|
|
3868
3920
|
hookData: data
|
|
@@ -3870,7 +3922,7 @@ const getHook$3 = (caps, data) => {
|
|
|
3870
3922
|
});
|
|
3871
3923
|
}
|
|
3872
3924
|
|
|
3873
|
-
if (lodash__default[
|
|
3925
|
+
if (lodash__default["default"].isFunction(resultWithRequire)) {
|
|
3874
3926
|
debug$h(`found hook, type: require, in ${tryLoadFile}`);
|
|
3875
3927
|
return resultWithRequire;
|
|
3876
3928
|
} else {
|
|
@@ -3879,16 +3931,16 @@ const getHook$3 = (caps, data) => {
|
|
|
3879
3931
|
}
|
|
3880
3932
|
|
|
3881
3933
|
try {
|
|
3882
|
-
esprima__default[
|
|
3934
|
+
esprima__default["default"].parseScript(data);
|
|
3883
3935
|
} catch (err) {
|
|
3884
|
-
throw new Error(`Cant load hook, syntax is not valid - ${util__default[
|
|
3936
|
+
throw new Error(`Cant load hook, syntax is not valid - ${util__default["default"].inspect(err)}`);
|
|
3885
3937
|
}
|
|
3886
3938
|
|
|
3887
3939
|
debug$h('Found hook, type: JavaScript as String');
|
|
3888
3940
|
return data;
|
|
3889
3941
|
}
|
|
3890
3942
|
|
|
3891
|
-
throw new Error(`Not valid hook ${util__default[
|
|
3943
|
+
throw new Error(`Not valid hook ${util__default["default"].inspect(data)}`);
|
|
3892
3944
|
};
|
|
3893
3945
|
|
|
3894
3946
|
var HookUtils = {
|
|
@@ -3910,7 +3962,7 @@ var precompile$1 = (caps, scriptBuffer, options, filename) => {
|
|
|
3910
3962
|
throw new Error('Script is not defined');
|
|
3911
3963
|
}
|
|
3912
3964
|
|
|
3913
|
-
if (lodash__default[
|
|
3965
|
+
if (lodash__default["default"].isString(scriptBuffer)) {
|
|
3914
3966
|
try {
|
|
3915
3967
|
scriptBuffer = JSON.parse(scriptBuffer);
|
|
3916
3968
|
} catch (err) {}
|
|
@@ -3935,7 +3987,7 @@ var Script = {
|
|
|
3935
3987
|
precompile: precompile$1
|
|
3936
3988
|
};
|
|
3937
3989
|
|
|
3938
|
-
const debug$g = debug__default[
|
|
3990
|
+
const debug$g = debug__default["default"]('botium-core-PrecompilerMarkdownRasa');
|
|
3939
3991
|
const htmlCommentRegexp = /(<!--.*?-->)/g;
|
|
3940
3992
|
|
|
3941
3993
|
var precompile = (caps, scriptBuffer, options, filename) => {
|
|
@@ -3943,7 +3995,7 @@ var precompile = (caps, scriptBuffer, options, filename) => {
|
|
|
3943
3995
|
return;
|
|
3944
3996
|
}
|
|
3945
3997
|
|
|
3946
|
-
const md = new markdownIt__default[
|
|
3998
|
+
const md = new markdownIt__default["default"]();
|
|
3947
3999
|
const parsed = md.parse(scriptBuffer, {});
|
|
3948
4000
|
|
|
3949
4001
|
const _extractFromRasaIntent = content => {
|
|
@@ -4027,7 +4079,7 @@ var precompile = (caps, scriptBuffer, options, filename) => {
|
|
|
4027
4079
|
if (!intent) {
|
|
4028
4080
|
debug$g(`Intent not found, dropping me texts ${JSON.stringify(meTexts)}`);
|
|
4029
4081
|
} else {
|
|
4030
|
-
meTexts = lodash__default[
|
|
4082
|
+
meTexts = lodash__default["default"].uniq(meTexts);
|
|
4031
4083
|
utterances[intent] = meTexts;
|
|
4032
4084
|
}
|
|
4033
4085
|
}
|
|
@@ -4035,7 +4087,7 @@ var precompile = (caps, scriptBuffer, options, filename) => {
|
|
|
4035
4087
|
intent = null;
|
|
4036
4088
|
meTexts = [];
|
|
4037
4089
|
} else {
|
|
4038
|
-
debug$g(`Markdown entry ignored ${util__default[
|
|
4090
|
+
debug$g(`Markdown entry ignored ${util__default["default"].inspect(entry)}`);
|
|
4039
4091
|
}
|
|
4040
4092
|
}
|
|
4041
4093
|
|
|
@@ -4051,7 +4103,7 @@ var MarkdownRasa = {
|
|
|
4051
4103
|
precompile: precompile
|
|
4052
4104
|
};
|
|
4053
4105
|
|
|
4054
|
-
const debug$f = debug__default[
|
|
4106
|
+
const debug$f = debug__default["default"]('botium-core-CapabilitiesUtils');
|
|
4055
4107
|
const {
|
|
4056
4108
|
toJsonWeak
|
|
4057
4109
|
} = Utils;
|
|
@@ -4059,16 +4111,16 @@ const {
|
|
|
4059
4111
|
var getAllCapValues$1 = (capNamePrefix, caps) => {
|
|
4060
4112
|
const allCapValues = [];
|
|
4061
4113
|
|
|
4062
|
-
const jsonPathCaps = lodash__default[
|
|
4114
|
+
const jsonPathCaps = lodash__default["default"].pickBy(caps, (v, k) => k.startsWith(capNamePrefix));
|
|
4063
4115
|
|
|
4064
|
-
lodash__default[
|
|
4065
|
-
const val = lodash__default[
|
|
4116
|
+
lodash__default["default"](jsonPathCaps).keys().sort().each(key => {
|
|
4117
|
+
const val = lodash__default["default"].isFunction(caps[key]) ? caps[key]() : caps[key];
|
|
4066
4118
|
|
|
4067
|
-
if (lodash__default[
|
|
4119
|
+
if (lodash__default["default"].isArray(val)) {
|
|
4068
4120
|
val.forEach(p => {
|
|
4069
4121
|
allCapValues.push(`${p}`.trim());
|
|
4070
4122
|
});
|
|
4071
|
-
} else if (lodash__default[
|
|
4123
|
+
} else if (lodash__default["default"].isString(val)) {
|
|
4072
4124
|
val.split(',').forEach(p => {
|
|
4073
4125
|
allCapValues.push(p.trim());
|
|
4074
4126
|
});
|
|
@@ -4101,7 +4153,7 @@ var flatCababilities$1 = (caps, prefix) => {
|
|
|
4101
4153
|
if (capNames.length === 1 && capNames[0] === prefix) {
|
|
4102
4154
|
const val = toJsonWeak(caps[capNames[0]]);
|
|
4103
4155
|
|
|
4104
|
-
if (lodash__default[
|
|
4156
|
+
if (lodash__default["default"].isArray(val)) {
|
|
4105
4157
|
val.forEach(entry => result.push(entry));
|
|
4106
4158
|
} else {
|
|
4107
4159
|
result.push(val);
|
|
@@ -4163,7 +4215,7 @@ var CapabilitiesUtils = {
|
|
|
4163
4215
|
flatCababilities: flatCababilities$1
|
|
4164
4216
|
};
|
|
4165
4217
|
|
|
4166
|
-
const debug$e = debug__default[
|
|
4218
|
+
const debug$e = debug__default["default"]('botium-core-Precompilers');
|
|
4167
4219
|
const {
|
|
4168
4220
|
isJsonObject
|
|
4169
4221
|
} = Utils;
|
|
@@ -4190,14 +4242,14 @@ var execute = (scriptBuffer, options) => {
|
|
|
4190
4242
|
|
|
4191
4243
|
for (const capSuffixAndVal of ownCaps) {
|
|
4192
4244
|
if (!capSuffixAndVal.NAME) {
|
|
4193
|
-
debug$e(`Precompiler name not defined in ${util__default[
|
|
4245
|
+
debug$e(`Precompiler name not defined in ${util__default["default"].inspect(capSuffixAndVal)}`);
|
|
4194
4246
|
return null;
|
|
4195
4247
|
}
|
|
4196
4248
|
|
|
4197
4249
|
const provider = PROVIDERS[capSuffixAndVal.NAME];
|
|
4198
4250
|
|
|
4199
4251
|
if (!provider) {
|
|
4200
|
-
throw new Error(`Precompiler ${util__default[
|
|
4252
|
+
throw new Error(`Precompiler ${util__default["default"].inspect(capSuffixAndVal.NAME)} not found using caps ${util__default["default"].inspect(capSuffixAndVal)}`);
|
|
4201
4253
|
}
|
|
4202
4254
|
|
|
4203
4255
|
const result = provider.precompile(caps, scriptBuffer, capSuffixAndVal, filename);
|
|
@@ -4275,7 +4327,7 @@ var CompilerBase_1 = class CompilerBase {
|
|
|
4275
4327
|
}
|
|
4276
4328
|
|
|
4277
4329
|
_GetOptionalCapability(cap, def = null) {
|
|
4278
|
-
if (lodash__default[
|
|
4330
|
+
if (lodash__default["default"].isUndefined(this.caps[cap])) {
|
|
4279
4331
|
return def;
|
|
4280
4332
|
}
|
|
4281
4333
|
|
|
@@ -4300,7 +4352,7 @@ var Utterance_1 = class Utterance {
|
|
|
4300
4352
|
this.sourceTag = fromJson.sourceTag;
|
|
4301
4353
|
this.utterances = [];
|
|
4302
4354
|
|
|
4303
|
-
if (fromJson.utterances && lodash__default[
|
|
4355
|
+
if (fromJson.utterances && lodash__default["default"].isArray(fromJson.utterances)) {
|
|
4304
4356
|
this.utterances = fromJson.utterances;
|
|
4305
4357
|
} else if (fromJson.utterances) {
|
|
4306
4358
|
this.utterances.push(fromJson.utterances);
|
|
@@ -4308,12 +4360,12 @@ var Utterance_1 = class Utterance {
|
|
|
4308
4360
|
}
|
|
4309
4361
|
|
|
4310
4362
|
toString() {
|
|
4311
|
-
return this.name + (this.sourceTag ? ` (${util__default[
|
|
4363
|
+
return this.name + (this.sourceTag ? ` (${util__default["default"].inspect(this.sourceTag)})` : '') + ': ' + this.utterances.join('|');
|
|
4312
4364
|
}
|
|
4313
4365
|
|
|
4314
4366
|
};
|
|
4315
4367
|
|
|
4316
|
-
const debug$d = debug__default[
|
|
4368
|
+
const debug$d = debug__default["default"]('botium-core-CompilerXlsx');
|
|
4317
4369
|
const {
|
|
4318
4370
|
Convo: Convo$5
|
|
4319
4371
|
} = Convo_1;
|
|
@@ -4342,7 +4394,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4342
4394
|
super.Validate();
|
|
4343
4395
|
|
|
4344
4396
|
if (this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL] !== undefined) {
|
|
4345
|
-
if (lodash__default[
|
|
4397
|
+
if (lodash__default["default"].isString(this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]) && this.colnames.findIndex(c => c === this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]) < 0) {
|
|
4346
4398
|
throw new Error(`SCRIPTING_XLSX_STARTCOL ${this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]} invalid (A-Z)`);
|
|
4347
4399
|
} else if (this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL] < 1 || this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL] > this.colnames.length) {
|
|
4348
4400
|
throw new Error(`SCRIPTING_XLSX_STARTCOL ${this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]} invalid (1-${this.colnames.length})`);
|
|
@@ -4351,7 +4403,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4351
4403
|
}
|
|
4352
4404
|
|
|
4353
4405
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
4354
|
-
const workbook = xlsx__default[
|
|
4406
|
+
const workbook = xlsx__default["default"].read(scriptBuffer, {
|
|
4355
4407
|
type: 'buffer'
|
|
4356
4408
|
});
|
|
4357
4409
|
if (!workbook) throw new Error('Workbook not readable');
|
|
@@ -4388,7 +4440,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4388
4440
|
throw Error(`Invalid script type ${scriptType}`);
|
|
4389
4441
|
}
|
|
4390
4442
|
|
|
4391
|
-
debug$d(`sheet names for ${scriptType}: ${util__default[
|
|
4443
|
+
debug$d(`sheet names for ${scriptType}: ${util__default["default"].inspect(sheetnames)}`);
|
|
4392
4444
|
const scriptResults = [];
|
|
4393
4445
|
sheetnames.forEach(sheetname => {
|
|
4394
4446
|
const sheet = workbook.Sheets[sheetname];
|
|
@@ -4400,14 +4452,14 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4400
4452
|
hasNameCol
|
|
4401
4453
|
} = this._findOrigin(sheet, scriptType);
|
|
4402
4454
|
|
|
4403
|
-
debug$d(`evaluating sheet name for ${scriptType}: ${util__default[
|
|
4455
|
+
debug$d(`evaluating sheet name for ${scriptType}: ${util__default["default"].inspect(sheetname)}, rowindex ${rowindex}, colindex ${colindex}`);
|
|
4404
4456
|
|
|
4405
4457
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO || scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
4406
4458
|
const parseCell = (sender, content) => {
|
|
4407
4459
|
if (!content) return {
|
|
4408
4460
|
messageText: ''
|
|
4409
4461
|
};
|
|
4410
|
-
if (!lodash__default[
|
|
4462
|
+
if (!lodash__default["default"].isString(content)) content = '' + content;
|
|
4411
4463
|
let eolSplit = null;
|
|
4412
4464
|
let lines = [];
|
|
4413
4465
|
|
|
@@ -4726,12 +4778,12 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4726
4778
|
throw new Error(errors.map(e => e.message).join(' - '));
|
|
4727
4779
|
}
|
|
4728
4780
|
|
|
4729
|
-
const wb = xlsx__default[
|
|
4730
|
-
const ws = xlsx__default[
|
|
4781
|
+
const wb = xlsx__default["default"].utils.book_new();
|
|
4782
|
+
const ws = xlsx__default["default"].utils.json_to_sheet(data, {
|
|
4731
4783
|
header: ['me', 'bot']
|
|
4732
4784
|
});
|
|
4733
|
-
xlsx__default[
|
|
4734
|
-
const xlsxOutput = xlsx__default[
|
|
4785
|
+
xlsx__default["default"].utils.book_append_sheet(wb, ws, sheetname);
|
|
4786
|
+
const xlsxOutput = xlsx__default["default"].write(wb, {
|
|
4735
4787
|
type: 'buffer'
|
|
4736
4788
|
});
|
|
4737
4789
|
return xlsxOutput;
|
|
@@ -4746,9 +4798,9 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4746
4798
|
_findOrigin(sheet, scriptType) {
|
|
4747
4799
|
let rowindex = this.caps[Capabilities.SCRIPTING_XLSX_STARTROW];
|
|
4748
4800
|
let colindex = this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL];
|
|
4749
|
-
let hasNameCol = lodash__default[
|
|
4801
|
+
let hasNameCol = lodash__default["default"].has(this.caps, Capabilities.SCRIPTING_XLSX_HASNAMECOL) ? !!this.caps[Capabilities.SCRIPTING_XLSX_HASNAMECOL] : null;
|
|
4750
4802
|
|
|
4751
|
-
if (lodash__default[
|
|
4803
|
+
if (lodash__default["default"].isString(this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL])) {
|
|
4752
4804
|
colindex = this.colnames.findIndex(c => c === this.caps[Capabilities.SCRIPTING_XLSX_STARTCOL]);
|
|
4753
4805
|
} else if (colindex !== undefined) {
|
|
4754
4806
|
colindex = colindex - 1;
|
|
@@ -4801,7 +4853,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4801
4853
|
}
|
|
4802
4854
|
}
|
|
4803
4855
|
|
|
4804
|
-
if (lodash__default[
|
|
4856
|
+
if (lodash__default["default"].isNull(hasNameCol)) {
|
|
4805
4857
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO || scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
4806
4858
|
if (this.caps[Capabilities.SCRIPTING_XLSX_HASHEADERS]) {
|
|
4807
4859
|
if (this._get(sheet, rowindex - 1, colindex) && this._get(sheet, rowindex - 1, colindex + 1) && this._get(sheet, rowindex - 1, colindex + 2)) {
|
|
@@ -4859,7 +4911,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4859
4911
|
let scriptData = scriptBuffer;
|
|
4860
4912
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4861
4913
|
|
|
4862
|
-
const lines = lodash__default[
|
|
4914
|
+
const lines = lodash__default["default"].map(scriptData.split(this.eol), line => line.trim());
|
|
4863
4915
|
|
|
4864
4916
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
4865
4917
|
return this._compileConvo(lines, false);
|
|
@@ -5026,7 +5078,10 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
5026
5078
|
|
|
5027
5079
|
};
|
|
5028
5080
|
|
|
5029
|
-
const
|
|
5081
|
+
const {
|
|
5082
|
+
parse
|
|
5083
|
+
} = sync__default["default"];
|
|
5084
|
+
const debug$c = debug__default["default"]('botium-core-CompilerCsv');
|
|
5030
5085
|
const {
|
|
5031
5086
|
Convo: Convo$3
|
|
5032
5087
|
} = Convo_1;
|
|
@@ -5042,13 +5097,13 @@ const DEFAULT_MULTIROW_COLUMN_SENDER = 1;
|
|
|
5042
5097
|
const DEFAULT_MULTIROW_COLUMN_TEXT = 2;
|
|
5043
5098
|
|
|
5044
5099
|
const _findColIndex = (header, colName) => {
|
|
5045
|
-
if (lodash__default[
|
|
5100
|
+
if (lodash__default["default"].isString(colName)) {
|
|
5046
5101
|
const result = header.findIndex(h => h === colName);
|
|
5047
5102
|
if (result >= 0) return result;
|
|
5048
5103
|
throw new Error(`Column name ${colName} not found.`);
|
|
5049
5104
|
}
|
|
5050
5105
|
|
|
5051
|
-
if (lodash__default[
|
|
5106
|
+
if (lodash__default["default"].isNumber(colName)) {
|
|
5052
5107
|
return colName;
|
|
5053
5108
|
}
|
|
5054
5109
|
|
|
@@ -5098,7 +5153,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5098
5153
|
let rows;
|
|
5099
5154
|
|
|
5100
5155
|
try {
|
|
5101
|
-
rows =
|
|
5156
|
+
rows = parse(scriptData, {
|
|
5102
5157
|
delimiter,
|
|
5103
5158
|
escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
|
|
5104
5159
|
quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
|
|
@@ -5199,7 +5254,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5199
5254
|
}
|
|
5200
5255
|
}
|
|
5201
5256
|
|
|
5202
|
-
const conversationIds = lodash__default[
|
|
5257
|
+
const conversationIds = lodash__default["default"].uniq(rows.map(r => r[colConversationId]));
|
|
5203
5258
|
|
|
5204
5259
|
const convos = conversationIds.map(conversationId => {
|
|
5205
5260
|
const convoRows = rows.map((row, i) => {
|
|
@@ -5231,7 +5286,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5231
5286
|
|
|
5232
5287
|
};
|
|
5233
5288
|
|
|
5234
|
-
const debug$b = debug__default[
|
|
5289
|
+
const debug$b = debug__default["default"]('botium-core-CompilerObject');
|
|
5235
5290
|
const {
|
|
5236
5291
|
Convo: Convo$2
|
|
5237
5292
|
} = Convo_1;
|
|
@@ -5328,7 +5383,7 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5328
5383
|
const names = Object.keys(utterancesRaw || {});
|
|
5329
5384
|
|
|
5330
5385
|
for (const name of names) {
|
|
5331
|
-
if (!lodash__default[
|
|
5386
|
+
if (!lodash__default["default"].isArray(utterancesRaw[name])) {
|
|
5332
5387
|
throw new Error(`The '${name}' utterance has to be an array.`);
|
|
5333
5388
|
}
|
|
5334
5389
|
|
|
@@ -5344,7 +5399,7 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5344
5399
|
|
|
5345
5400
|
_compileScriptingMemory(lines) {
|
|
5346
5401
|
if (lines && lines.length > 0) {
|
|
5347
|
-
if (lodash__default[
|
|
5402
|
+
if (lodash__default["default"].isString(lines[0])) {
|
|
5348
5403
|
if (lines.length > 1) {
|
|
5349
5404
|
const names = lines[0].split('|').map(name => name.trim()).slice(1);
|
|
5350
5405
|
const scriptingMemories = [];
|
|
@@ -5392,7 +5447,7 @@ var CompilerYaml_1 = class CompilerYaml extends CompilerObjectBase_1 {
|
|
|
5392
5447
|
}
|
|
5393
5448
|
|
|
5394
5449
|
Deserialize(scriptData) {
|
|
5395
|
-
return yaml__default[
|
|
5450
|
+
return yaml__default["default"].parse(scriptData);
|
|
5396
5451
|
}
|
|
5397
5452
|
|
|
5398
5453
|
};
|
|
@@ -5424,8 +5479,8 @@ var CompilerJson_1 = class CompilerJson extends CompilerObjectBase_1 {
|
|
|
5424
5479
|
|
|
5425
5480
|
};
|
|
5426
5481
|
|
|
5427
|
-
const debug$a = debug__default[
|
|
5428
|
-
const md = new markdownIt__default[
|
|
5482
|
+
const debug$a = debug__default["default"]('botium-core-CompilerMarkdown');
|
|
5483
|
+
const md = new markdownIt__default["default"]();
|
|
5429
5484
|
const {
|
|
5430
5485
|
Convo: Convo$1
|
|
5431
5486
|
} = Convo_1;
|
|
@@ -5474,7 +5529,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5474
5529
|
|
|
5475
5530
|
depth = 1;
|
|
5476
5531
|
} else {
|
|
5477
|
-
debug$a(`Markdown entry "${util__default[
|
|
5532
|
+
debug$a(`Markdown entry "${util__default["default"].inspect(entry)}" ignored. Unknown heading`);
|
|
5478
5533
|
}
|
|
5479
5534
|
} else if (entry.type === 'bullet_list_open') {
|
|
5480
5535
|
if (depth < 1) {
|
|
@@ -5554,14 +5609,14 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5554
5609
|
|
|
5555
5610
|
};
|
|
5556
5611
|
|
|
5557
|
-
promise__default[
|
|
5558
|
-
const debug$9 = debug__default[
|
|
5612
|
+
promise__default["default"].shim();
|
|
5613
|
+
const debug$9 = debug__default["default"]('botium-core-ScriptingProvider');
|
|
5559
5614
|
const {
|
|
5560
5615
|
Convo,
|
|
5561
5616
|
ConvoStep
|
|
5562
5617
|
} = Convo_1;
|
|
5563
5618
|
const {
|
|
5564
|
-
BotiumError: BotiumError$
|
|
5619
|
+
BotiumError: BotiumError$2,
|
|
5565
5620
|
botiumErrorFromList,
|
|
5566
5621
|
botiumErrorFromErr
|
|
5567
5622
|
} = BotiumError_1;
|
|
@@ -5581,7 +5636,7 @@ const p = (retryHelper, fn) => {
|
|
|
5581
5636
|
});
|
|
5582
5637
|
|
|
5583
5638
|
if (retryHelper) {
|
|
5584
|
-
return promiseRetry__default[
|
|
5639
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
5585
5640
|
return promise().catch(err => {
|
|
5586
5641
|
if (retryHelper.shouldRetry(err)) {
|
|
5587
5642
|
debug$9(`Asserter trial #${number} failed, retry activated`);
|
|
@@ -5608,7 +5663,7 @@ const pnot = (retryHelper, fn, errTemplate) => {
|
|
|
5608
5663
|
});
|
|
5609
5664
|
|
|
5610
5665
|
if (retryHelper) {
|
|
5611
|
-
return promiseRetry__default[
|
|
5666
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
5612
5667
|
return promise().catch(() => {
|
|
5613
5668
|
if (retryHelper.shouldRetry(errTemplate)) {
|
|
5614
5669
|
debug$9(`Asserter trial #${number} failed, !retry activated`);
|
|
@@ -5625,7 +5680,7 @@ const pnot = (retryHelper, fn, errTemplate) => {
|
|
|
5625
5680
|
|
|
5626
5681
|
var ScriptingProvider_1 = class ScriptingProvider {
|
|
5627
5682
|
constructor(caps) {
|
|
5628
|
-
this.caps = caps || lodash__default[
|
|
5683
|
+
this.caps = caps || lodash__default["default"].cloneDeep(Defaults$1.Capabilities);
|
|
5629
5684
|
this.compilers = {};
|
|
5630
5685
|
this.convos = [];
|
|
5631
5686
|
this.utterances = {};
|
|
@@ -5826,22 +5881,22 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5826
5881
|
});
|
|
5827
5882
|
},
|
|
5828
5883
|
assertBotResponse: (botresponse, tomatch, stepTag, meMsg) => {
|
|
5829
|
-
if (!lodash__default[
|
|
5884
|
+
if (!lodash__default["default"].isArray(tomatch)) {
|
|
5830
5885
|
tomatch = [tomatch];
|
|
5831
5886
|
}
|
|
5832
5887
|
|
|
5833
5888
|
debug$9(`assertBotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} = ${tomatch} ...`);
|
|
5834
5889
|
|
|
5835
|
-
const found = lodash__default[
|
|
5890
|
+
const found = lodash__default["default"].find(tomatch, utt => this.matchFn(botresponse, utt));
|
|
5836
5891
|
|
|
5837
|
-
if (lodash__default[
|
|
5892
|
+
if (lodash__default["default"].isNil(found)) {
|
|
5838
5893
|
let message = `${stepTag}: Bot response `;
|
|
5839
5894
|
message += meMsg ? `(on ${meMsg}) ` : '';
|
|
5840
5895
|
message += botresponse ? '"' + botresponse + '"' : '<no response>';
|
|
5841
5896
|
message += ' expected to match ';
|
|
5842
5897
|
message += tomatch && tomatch.length > 1 ? 'one of ' : '';
|
|
5843
5898
|
message += `${tomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5844
|
-
throw new BotiumError$
|
|
5899
|
+
throw new BotiumError$2(message, {
|
|
5845
5900
|
type: 'asserter',
|
|
5846
5901
|
source: 'TextMatchAsserter',
|
|
5847
5902
|
context: {
|
|
@@ -5856,22 +5911,22 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5856
5911
|
}
|
|
5857
5912
|
},
|
|
5858
5913
|
assertBotNotResponse: (botresponse, nottomatch, stepTag, meMsg) => {
|
|
5859
|
-
if (!lodash__default[
|
|
5914
|
+
if (!lodash__default["default"].isArray(nottomatch)) {
|
|
5860
5915
|
nottomatch = [nottomatch];
|
|
5861
5916
|
}
|
|
5862
5917
|
|
|
5863
5918
|
debug$9(`assertBotNotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} != ${nottomatch} ...`);
|
|
5864
5919
|
|
|
5865
|
-
const found = lodash__default[
|
|
5920
|
+
const found = lodash__default["default"].find(nottomatch, utt => this.matchFn(botresponse, utt));
|
|
5866
5921
|
|
|
5867
|
-
if (!lodash__default[
|
|
5922
|
+
if (!lodash__default["default"].isNil(found)) {
|
|
5868
5923
|
let message = `${stepTag}: Bot response `;
|
|
5869
5924
|
message += meMsg ? `(on ${meMsg}) ` : '';
|
|
5870
5925
|
message += botresponse ? '"' + botresponse + '"' : '<no response>';
|
|
5871
5926
|
message += ' expected NOT to match ';
|
|
5872
5927
|
message += nottomatch && nottomatch.length > 1 ? 'one of ' : '';
|
|
5873
5928
|
message += `${nottomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
|
|
5874
|
-
throw new BotiumError$
|
|
5929
|
+
throw new BotiumError$2(message, {
|
|
5875
5930
|
type: 'asserter',
|
|
5876
5931
|
source: 'TextMatchAsserter',
|
|
5877
5932
|
context: {
|
|
@@ -5918,7 +5973,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
5918
5973
|
if (asserter[notAsserterType]) {
|
|
5919
5974
|
return p(this.retryHelperAsserter, () => asserter[notAsserterType](params));
|
|
5920
5975
|
} else {
|
|
5921
|
-
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$
|
|
5976
|
+
return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$2(`${convoStep.stepTag}: Expected asserter ${asserter.name || asserterSpec.name} with args "${params.args}" to fail`, {
|
|
5922
5977
|
type: 'asserter',
|
|
5923
5978
|
source: asserter.name || asserterSpec.name,
|
|
5924
5979
|
params: {
|
|
@@ -6028,7 +6083,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6028
6083
|
utterance,
|
|
6029
6084
|
resolveEmptyIfUnknown = false
|
|
6030
6085
|
}) {
|
|
6031
|
-
if (lodash__default[
|
|
6086
|
+
if (lodash__default["default"].isString(utterance)) {
|
|
6032
6087
|
if (this.utterances[utterance]) {
|
|
6033
6088
|
return this.utterances[utterance].utterances;
|
|
6034
6089
|
} else {
|
|
@@ -6036,7 +6091,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6036
6091
|
|
|
6037
6092
|
if (this.utterances[parts[0]]) {
|
|
6038
6093
|
const uttArgs = parts.slice(1);
|
|
6039
|
-
return this.utterances[parts[0]].utterances.map(utt => util__default[
|
|
6094
|
+
return this.utterances[parts[0]].utterances.map(utt => util__default["default"].format(utt, ...uttArgs));
|
|
6040
6095
|
}
|
|
6041
6096
|
}
|
|
6042
6097
|
}
|
|
@@ -6140,22 +6195,22 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6140
6195
|
}
|
|
6141
6196
|
|
|
6142
6197
|
ReadBotiumFilesFromDirectory(convoDir, globFilter) {
|
|
6143
|
-
const filelist = globby__default[
|
|
6198
|
+
const filelist = globby__default["default"].sync(globPattern, {
|
|
6144
6199
|
cwd: convoDir,
|
|
6145
6200
|
gitignore: true
|
|
6146
6201
|
});
|
|
6147
6202
|
|
|
6148
6203
|
if (globFilter) {
|
|
6149
|
-
const filelistGlobbed = globby__default[
|
|
6204
|
+
const filelistGlobbed = globby__default["default"].sync(globFilter, {
|
|
6150
6205
|
cwd: convoDir,
|
|
6151
6206
|
gitignore: true
|
|
6152
6207
|
});
|
|
6153
6208
|
|
|
6154
|
-
lodash__default[
|
|
6209
|
+
lodash__default["default"].remove(filelist, file => filelistGlobbed.indexOf(file) < 0);
|
|
6155
6210
|
}
|
|
6156
6211
|
|
|
6157
|
-
lodash__default[
|
|
6158
|
-
const isSkip = skipPattern.test(path__default[
|
|
6212
|
+
lodash__default["default"].remove(filelist, file => {
|
|
6213
|
+
const isSkip = skipPattern.test(path__default["default"].basename(file));
|
|
6159
6214
|
if (isSkip) debug$9(`ReadBotiumFilesFromDirectory - skipping file '${file}'`);
|
|
6160
6215
|
return isSkip;
|
|
6161
6216
|
});
|
|
@@ -6165,11 +6220,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6165
6220
|
|
|
6166
6221
|
ReadScriptsFromDirectory(convoDir, globFilter) {
|
|
6167
6222
|
let filelist = [];
|
|
6168
|
-
const convoDirStats = fs__default[
|
|
6223
|
+
const convoDirStats = fs__default["default"].statSync(convoDir);
|
|
6169
6224
|
|
|
6170
6225
|
if (convoDirStats.isFile()) {
|
|
6171
|
-
filelist = [path__default[
|
|
6172
|
-
convoDir = path__default[
|
|
6226
|
+
filelist = [path__default["default"].basename(convoDir)];
|
|
6227
|
+
convoDir = path__default["default"].dirname(convoDir);
|
|
6173
6228
|
} else {
|
|
6174
6229
|
filelist = this.ReadBotiumFilesFromDirectory(convoDir, globFilter);
|
|
6175
6230
|
}
|
|
@@ -6192,9 +6247,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6192
6247
|
if (scriptingMemories) dirScriptingMemories.push(...scriptingMemories);
|
|
6193
6248
|
});
|
|
6194
6249
|
debug$9(`ReadConvosFromDirectory(${convoDir}) found convos:\n ${dirConvos.length ? dirConvos.join('\n') : 'none'}`);
|
|
6195
|
-
debug$9(`ReadConvosFromDirectory(${convoDir}) found utterances:\n ${dirUtterances.length ? lodash__default[
|
|
6250
|
+
debug$9(`ReadConvosFromDirectory(${convoDir}) found utterances:\n ${dirUtterances.length ? lodash__default["default"].map(dirUtterances, u => u).join('\n') : 'none'}`);
|
|
6196
6251
|
debug$9(`ReadConvosFromDirectory(${convoDir}) found partial convos:\n ${dirPartialConvos.length ? dirPartialConvos.join('\n') : 'none'}`);
|
|
6197
|
-
debug$9(`ReadConvosFromDirectory(${convoDir}) scripting memories:\n ${dirScriptingMemories.length ? dirScriptingMemories.map(dirScriptingMemory => util__default[
|
|
6252
|
+
debug$9(`ReadConvosFromDirectory(${convoDir}) scripting memories:\n ${dirScriptingMemories.length ? dirScriptingMemories.map(dirScriptingMemory => util__default["default"].inspect(dirScriptingMemory)).join('\n') : 'none'}`);
|
|
6198
6253
|
return {
|
|
6199
6254
|
convos: dirConvos,
|
|
6200
6255
|
utterances: dirUtterances,
|
|
@@ -6203,14 +6258,40 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6203
6258
|
};
|
|
6204
6259
|
}
|
|
6205
6260
|
|
|
6261
|
+
ReadScriptFromBuffer(scriptBuffer, scriptingFormat, scriptingTypes = null) {
|
|
6262
|
+
if (lodash__default["default"].isString(scriptingTypes)) scriptingTypes = [scriptingTypes];
|
|
6263
|
+
if (lodash__default["default"].isArray(scriptingTypes) && scriptingTypes.length === 0) scriptingTypes = null;
|
|
6264
|
+
const result = {
|
|
6265
|
+
convos: [],
|
|
6266
|
+
utterances: [],
|
|
6267
|
+
pconvos: [],
|
|
6268
|
+
scriptingMemories: []
|
|
6269
|
+
};
|
|
6270
|
+
|
|
6271
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_UTTERANCES)) {
|
|
6272
|
+
result.utterances = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_UTTERANCES);
|
|
6273
|
+
}
|
|
6274
|
+
|
|
6275
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_PCONVO)) {
|
|
6276
|
+
result.pconvos = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6277
|
+
}
|
|
6278
|
+
|
|
6279
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_CONVO)) {
|
|
6280
|
+
result.convos = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_CONVO);
|
|
6281
|
+
}
|
|
6282
|
+
|
|
6283
|
+
if (!scriptingTypes || scriptingTypes.includes(Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY)) {
|
|
6284
|
+
result.scriptingMemories = this.Compile(scriptBuffer, scriptingFormat, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6285
|
+
}
|
|
6286
|
+
|
|
6287
|
+
return result;
|
|
6288
|
+
}
|
|
6289
|
+
|
|
6206
6290
|
ReadScript(convoDir, filename) {
|
|
6207
|
-
let
|
|
6208
|
-
let fileUtterances = [];
|
|
6209
|
-
let filePartialConvos = [];
|
|
6210
|
-
let fileScriptingMemories = [];
|
|
6291
|
+
let result = {};
|
|
6211
6292
|
|
|
6212
6293
|
try {
|
|
6213
|
-
let scriptBuffer = fs__default[
|
|
6294
|
+
let scriptBuffer = fs__default["default"].readFileSync(path__default["default"].resolve(convoDir, filename));
|
|
6214
6295
|
const precompResponse = precompilers.execute(scriptBuffer, {
|
|
6215
6296
|
convoDir,
|
|
6216
6297
|
filename,
|
|
@@ -6224,36 +6305,25 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6224
6305
|
}
|
|
6225
6306
|
|
|
6226
6307
|
if (filename.endsWith('.xlsx') || filename.endsWith('.xlsm')) {
|
|
6227
|
-
|
|
6228
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6229
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_CONVO);
|
|
6230
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_XSLX, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6308
|
+
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]);
|
|
6231
6309
|
} else if (filename.endsWith('.convo.txt')) {
|
|
6232
|
-
|
|
6310
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_CONVO);
|
|
6233
6311
|
} else if (filename.endsWith('.pconvo.txt')) {
|
|
6234
|
-
|
|
6312
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6235
6313
|
} else if (filename.endsWith('.utterances.txt')) {
|
|
6236
|
-
|
|
6314
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_UTTERANCES);
|
|
6237
6315
|
} else if (filename.endsWith('.scriptingmemory.txt')) {
|
|
6238
|
-
|
|
6316
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_TXT, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6239
6317
|
} else if (filename.endsWith('.convo.csv')) {
|
|
6240
|
-
|
|
6318
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_CONVO);
|
|
6241
6319
|
} else if (filename.endsWith('.pconvo.csv')) {
|
|
6242
|
-
|
|
6320
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6243
6321
|
} else if (filename.endsWith('.yaml') || filename.endsWith('.yml')) {
|
|
6244
|
-
|
|
6245
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6246
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_CONVO);
|
|
6247
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6322
|
+
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]);
|
|
6248
6323
|
} else if (filename.endsWith('.json')) {
|
|
6249
|
-
|
|
6250
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6251
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_CONVO);
|
|
6252
|
-
fileScriptingMemories = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_JSON, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY);
|
|
6324
|
+
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]);
|
|
6253
6325
|
} else if (filename.endsWith('.markdown') || filename.endsWith('.md')) {
|
|
6254
|
-
|
|
6255
|
-
fileConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, Constants.SCRIPTING_TYPE_CONVO);
|
|
6256
|
-
filePartialConvos = this.Compile(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6326
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_MARKDOWN, [Constants.SCRIPTING_TYPE_UTTERANCES, Constants.SCRIPTING_TYPE_PCONVO, Constants.SCRIPTING_TYPE_CONVO]);
|
|
6257
6327
|
} else {
|
|
6258
6328
|
debug$9(`ReadScript - dropped file: ${filename}, filename not supported`);
|
|
6259
6329
|
}
|
|
@@ -6263,8 +6333,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6263
6333
|
} // Compilers saved the convos, and we alter here the saved version too
|
|
6264
6334
|
|
|
6265
6335
|
|
|
6266
|
-
if (
|
|
6267
|
-
|
|
6336
|
+
if (result.convos && result.convos.length > 0) {
|
|
6337
|
+
result.convos.forEach(fileConvo => {
|
|
6268
6338
|
fileConvo.sourceTag = {
|
|
6269
6339
|
convoDir,
|
|
6270
6340
|
filename
|
|
@@ -6277,12 +6347,12 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6277
6347
|
|
|
6278
6348
|
const isSkip = c => c.header.name && skipPattern.test(c.header.name.toLowerCase());
|
|
6279
6349
|
|
|
6280
|
-
|
|
6281
|
-
|
|
6350
|
+
result.convos.filter(c => isSkip(c)).forEach(c => debug$9(`ReadScript - skipping convo '${c.header.name}'`));
|
|
6351
|
+
result.convos = result.convos.filter(c => !isSkip(c));
|
|
6282
6352
|
}
|
|
6283
6353
|
|
|
6284
|
-
if (
|
|
6285
|
-
|
|
6354
|
+
if (result.pconvos && result.pconvos.length > 0) {
|
|
6355
|
+
result.pconvos.forEach(filePartialConvo => {
|
|
6286
6356
|
filePartialConvo.sourceTag = {
|
|
6287
6357
|
convoDir,
|
|
6288
6358
|
filename
|
|
@@ -6294,23 +6364,23 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6294
6364
|
});
|
|
6295
6365
|
}
|
|
6296
6366
|
|
|
6297
|
-
if (
|
|
6298
|
-
|
|
6367
|
+
if (result.scriptingMemories && result.scriptingMemories.length > 0) {
|
|
6368
|
+
result.scriptingMemories.forEach(scriptingMemory => {
|
|
6299
6369
|
scriptingMemory.sourceTag = {
|
|
6300
6370
|
filename
|
|
6301
6371
|
};
|
|
6302
6372
|
});
|
|
6303
6373
|
}
|
|
6304
6374
|
|
|
6305
|
-
if (
|
|
6306
|
-
|
|
6375
|
+
if (result.utterances) {
|
|
6376
|
+
result.utterances = this._tagAndCleanupUtterances(result.utterances, convoDir, filename);
|
|
6307
6377
|
}
|
|
6308
6378
|
|
|
6309
6379
|
return {
|
|
6310
|
-
convos:
|
|
6311
|
-
utterances:
|
|
6312
|
-
pconvos:
|
|
6313
|
-
scriptingMemories:
|
|
6380
|
+
convos: result.convos || [],
|
|
6381
|
+
utterances: result.utterances || [],
|
|
6382
|
+
pconvos: result.pconvos || [],
|
|
6383
|
+
scriptingMemories: result.scriptingMemories || []
|
|
6314
6384
|
};
|
|
6315
6385
|
}
|
|
6316
6386
|
|
|
@@ -6337,7 +6407,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6337
6407
|
});
|
|
6338
6408
|
|
|
6339
6409
|
if (aggregatedNoNames.length) {
|
|
6340
|
-
throw new BotiumError$
|
|
6410
|
+
throw new BotiumError$2('Scripting Memory Definition(s) without name', {
|
|
6341
6411
|
type: 'Scripting Memory',
|
|
6342
6412
|
subtype: 'Scripting Memory without name',
|
|
6343
6413
|
source: 'ScriptingProvider',
|
|
@@ -6353,7 +6423,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6353
6423
|
});
|
|
6354
6424
|
|
|
6355
6425
|
if (aggregatedNoVariables.length) {
|
|
6356
|
-
throw new BotiumError$
|
|
6426
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariables.map(e => e.header.name).join(', ')} without variable`, {
|
|
6357
6427
|
type: 'Scripting Memory',
|
|
6358
6428
|
subtype: 'Scripting Memory without variable',
|
|
6359
6429
|
source: 'ScriptingProvider',
|
|
@@ -6365,11 +6435,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6365
6435
|
|
|
6366
6436
|
|
|
6367
6437
|
const aggregatedNoVariableNames = this.scriptingMemories.filter(entry => {
|
|
6368
|
-
return !lodash__default[
|
|
6438
|
+
return !lodash__default["default"].isUndefined(entry.values['']);
|
|
6369
6439
|
});
|
|
6370
6440
|
|
|
6371
6441
|
if (aggregatedNoVariableNames.length) {
|
|
6372
|
-
throw new BotiumError$
|
|
6442
|
+
throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariableNames.map(e => e.header.name).join(', ')} without variable name`, {
|
|
6373
6443
|
type: 'Scripting Memory',
|
|
6374
6444
|
subtype: 'Scripting Memory without variable name',
|
|
6375
6445
|
source: 'ScriptingProvider',
|
|
@@ -6401,7 +6471,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6401
6471
|
}
|
|
6402
6472
|
|
|
6403
6473
|
if (aggregatedDuplicates.length) {
|
|
6404
|
-
throw new BotiumError$
|
|
6474
|
+
throw new BotiumError$2(`Scripting Memory Definition name(s) "${lodash__default["default"].uniq(aggregatedDuplicates.map(d => d.scriptingMemory.header.name)).join(', ')}" are not unique`, {
|
|
6405
6475
|
type: 'Scripting Memory',
|
|
6406
6476
|
subtype: 'Scripting Memory name collision',
|
|
6407
6477
|
source: 'ScriptingProvider',
|
|
@@ -6424,7 +6494,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6424
6494
|
const k1 = Object.keys(entry.values);
|
|
6425
6495
|
const k2 = Object.keys(scriptingMemory.values);
|
|
6426
6496
|
|
|
6427
|
-
const kInt = lodash__default[
|
|
6497
|
+
const kInt = lodash__default["default"].intersection(k1, k2);
|
|
6428
6498
|
|
|
6429
6499
|
return kInt.length && (kInt.length !== k1.length || kInt.length !== k2.length);
|
|
6430
6500
|
});
|
|
@@ -6438,7 +6508,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6438
6508
|
}
|
|
6439
6509
|
|
|
6440
6510
|
if (aggregatedIntersections.length) {
|
|
6441
|
-
throw new BotiumError$
|
|
6511
|
+
throw new BotiumError$2(`Scripting Memory Definitions "${aggregatedIntersections.map(i => i.scriptingMemory.header.name).join(', ')}" are invalid because variable name collision"`, {
|
|
6442
6512
|
type: 'Scripting Memory',
|
|
6443
6513
|
subtype: 'Scripting Memory variable name collision',
|
|
6444
6514
|
source: 'ScriptingProvider',
|
|
@@ -6462,7 +6532,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6462
6532
|
const convosOriginalAll = [];
|
|
6463
6533
|
this.convos.forEach(convo => {
|
|
6464
6534
|
const convoVariables = convo.GetScriptingMemoryAllVariables(this);
|
|
6465
|
-
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Variables to replace, all: "${util__default[
|
|
6535
|
+
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Variables to replace, all: "${util__default["default"].inspect(convoVariables)}"`);
|
|
6466
6536
|
|
|
6467
6537
|
if (!convoVariables.length) {
|
|
6468
6538
|
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - skipped, no variable found to replace`);
|
|
@@ -6476,13 +6546,13 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6476
6546
|
for (const [key, scriptingMemories] of variablesToScriptingMemory.entries()) {
|
|
6477
6547
|
const variableNames = JSON.parse(key);
|
|
6478
6548
|
|
|
6479
|
-
if (lodash__default[
|
|
6549
|
+
if (lodash__default["default"].intersection(variableNames, convoVariables).length) {
|
|
6480
6550
|
const convosExpandedVariable = [];
|
|
6481
6551
|
multipliers.push(scriptingMemories.length);
|
|
6482
6552
|
scriptingMemories.forEach(scriptingMemory => {
|
|
6483
6553
|
// Appending the case name to name
|
|
6484
6554
|
for (const convoToExpand of convosToExpand) {
|
|
6485
|
-
const convoExpanded = lodash__default[
|
|
6555
|
+
const convoExpanded = lodash__default["default"].cloneDeep(convoToExpand);
|
|
6486
6556
|
|
|
6487
6557
|
convoExpanded.header.name = convoToExpand.header.name + '.' + scriptingMemory.header.name;
|
|
6488
6558
|
variableNames.forEach(name => {
|
|
@@ -6508,7 +6578,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6508
6578
|
convosToExpand = convosExpandedVariable;
|
|
6509
6579
|
convosExpandedConvo = convosExpandedVariable;
|
|
6510
6580
|
} else {
|
|
6511
|
-
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Scripting memory ${key} ignored because there is no common variable with convo ${util__default[
|
|
6581
|
+
debug$9(`ExpandScriptingMemoryToConvos - Convo "${convo.header.name}" - Scripting memory ${key} ignored because there is no common variable with convo ${util__default["default"].inspect(convoVariables)}`);
|
|
6512
6582
|
}
|
|
6513
6583
|
}
|
|
6514
6584
|
|
|
@@ -6535,11 +6605,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6535
6605
|
} = {}) {
|
|
6536
6606
|
const expandedConvos = [];
|
|
6537
6607
|
|
|
6538
|
-
if (lodash__default[
|
|
6608
|
+
if (lodash__default["default"].isUndefined(useNameAsIntent)) {
|
|
6539
6609
|
useNameAsIntent = !!this.caps[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT];
|
|
6540
6610
|
}
|
|
6541
6611
|
|
|
6542
|
-
if (lodash__default[
|
|
6612
|
+
if (lodash__default["default"].isUndefined(incomprehensionUtt)) {
|
|
6543
6613
|
incomprehensionUtt = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION];
|
|
6544
6614
|
}
|
|
6545
6615
|
|
|
@@ -6557,7 +6627,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6557
6627
|
debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}`);
|
|
6558
6628
|
}
|
|
6559
6629
|
|
|
6560
|
-
lodash__default[
|
|
6630
|
+
lodash__default["default"].keys(this.utterances).filter(u => u !== incomprehensionUtt).forEach(uttName => {
|
|
6561
6631
|
const utt = this.utterances[uttName];
|
|
6562
6632
|
expandedConvos.push(new Convo(this._buildScriptContext(), {
|
|
6563
6633
|
header: {
|
|
@@ -6645,7 +6715,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6645
6715
|
|
|
6646
6716
|
if (currentStep.sender === 'bot' || currentStep.sender === 'begin' || currentStep.sender === 'end') {
|
|
6647
6717
|
const currentStepsStack = convoStepsStack.slice();
|
|
6648
|
-
currentStepsStack.push(lodash__default[
|
|
6718
|
+
currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
|
|
6649
6719
|
|
|
6650
6720
|
this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack);
|
|
6651
6721
|
} else if (currentStep.sender === 'me') {
|
|
@@ -6684,14 +6754,14 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6684
6754
|
const currentStepsStack = convoStepsStack.slice();
|
|
6685
6755
|
|
|
6686
6756
|
if (uttArgs) {
|
|
6687
|
-
utt = util__default[
|
|
6757
|
+
utt = util__default["default"].format(utt, ...uttArgs);
|
|
6688
6758
|
}
|
|
6689
6759
|
|
|
6690
|
-
currentStepsStack.push(Object.assign(lodash__default[
|
|
6760
|
+
currentStepsStack.push(Object.assign(lodash__default["default"].cloneDeep(currentStep), {
|
|
6691
6761
|
messageText: utt
|
|
6692
6762
|
}));
|
|
6693
6763
|
|
|
6694
|
-
const currentConvoLabeled = lodash__default[
|
|
6764
|
+
const currentConvoLabeled = lodash__default["default"].cloneDeep(currentConvo);
|
|
6695
6765
|
|
|
6696
6766
|
Object.assign(currentConvoLabeled.header, {
|
|
6697
6767
|
name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, utt)}`
|
|
@@ -6732,12 +6802,12 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6732
6802
|
const lineTag = `${index + 1}`.padStart(`${sampleinputs.length}`.length, '0');
|
|
6733
6803
|
const currentStepsStack = convoStepsStack.slice();
|
|
6734
6804
|
|
|
6735
|
-
const currentStepMod = lodash__default[
|
|
6805
|
+
const currentStepMod = lodash__default["default"].cloneDeep(currentStep);
|
|
6736
6806
|
|
|
6737
6807
|
currentStepMod.userInputs[uiIndex] = sampleinput;
|
|
6738
6808
|
currentStepsStack.push(currentStepMod);
|
|
6739
6809
|
|
|
6740
|
-
const currentConvoLabeled = lodash__default[
|
|
6810
|
+
const currentConvoLabeled = lodash__default["default"].cloneDeep(currentConvo);
|
|
6741
6811
|
|
|
6742
6812
|
Object.assign(currentConvoLabeled.header, {
|
|
6743
6813
|
name: `${currentConvo.header.name}/${ui.name}-${utterancePostfix(lineTag, sampleinput.args && sampleinput.args.length ? sampleinput.args.join(', ') : 'no-args')}`
|
|
@@ -6753,20 +6823,20 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6753
6823
|
|
|
6754
6824
|
if (useUnexpanded) {
|
|
6755
6825
|
const currentStepsStack = convoStepsStack.slice();
|
|
6756
|
-
currentStepsStack.push(lodash__default[
|
|
6826
|
+
currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
|
|
6757
6827
|
|
|
6758
6828
|
this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack);
|
|
6759
6829
|
}
|
|
6760
6830
|
}
|
|
6761
6831
|
} else {
|
|
6762
|
-
expandedConvos.push(Object.assign(lodash__default[
|
|
6763
|
-
conversation: convoStepsStack
|
|
6832
|
+
expandedConvos.push(Object.assign(lodash__default["default"].cloneDeep(currentConvo), {
|
|
6833
|
+
conversation: lodash__default["default"].cloneDeep(convoStepsStack)
|
|
6764
6834
|
}));
|
|
6765
6835
|
}
|
|
6766
6836
|
}
|
|
6767
6837
|
|
|
6768
6838
|
_sortConvos() {
|
|
6769
|
-
this.convos = lodash__default[
|
|
6839
|
+
this.convos = lodash__default["default"].sortBy(this.convos, [convo => convo.header.sort || convo.header.name]);
|
|
6770
6840
|
let i = 0;
|
|
6771
6841
|
this.convos.forEach(convo => {
|
|
6772
6842
|
convo.header.order = ++i;
|
|
@@ -6782,8 +6852,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6782
6852
|
}
|
|
6783
6853
|
|
|
6784
6854
|
AddConvos(convos) {
|
|
6785
|
-
if (convos && lodash__default[
|
|
6786
|
-
this.convos = lodash__default[
|
|
6855
|
+
if (convos && lodash__default["default"].isArray(convos)) {
|
|
6856
|
+
this.convos = lodash__default["default"].concat(this.convos, convos);
|
|
6787
6857
|
} else if (convos) {
|
|
6788
6858
|
this.convos.push(convos);
|
|
6789
6859
|
}
|
|
@@ -6818,16 +6888,16 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6818
6888
|
};
|
|
6819
6889
|
};
|
|
6820
6890
|
|
|
6821
|
-
if (utterances && !lodash__default[
|
|
6891
|
+
if (utterances && !lodash__default["default"].isArray(utterances)) {
|
|
6822
6892
|
utterances = [utterances];
|
|
6823
6893
|
}
|
|
6824
6894
|
|
|
6825
6895
|
if (utterances) {
|
|
6826
|
-
lodash__default[
|
|
6896
|
+
lodash__default["default"].forEach(utterances, utt => {
|
|
6827
6897
|
const eu = this.utterances[utt.name];
|
|
6828
6898
|
|
|
6829
6899
|
if (eu) {
|
|
6830
|
-
eu.utterances = lodash__default[
|
|
6900
|
+
eu.utterances = lodash__default["default"].uniq(lodash__default["default"].concat(eu.utterances, utt.utterances));
|
|
6831
6901
|
} else {
|
|
6832
6902
|
this.utterances[utt.name] = utt;
|
|
6833
6903
|
}
|
|
@@ -6845,7 +6915,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6845
6915
|
}
|
|
6846
6916
|
|
|
6847
6917
|
AddPartialConvos(convos) {
|
|
6848
|
-
if (convos && lodash__default[
|
|
6918
|
+
if (convos && lodash__default["default"].isArray(convos)) {
|
|
6849
6919
|
for (let i = 0; i < convos.length; i++) {
|
|
6850
6920
|
const convo = convos[i];
|
|
6851
6921
|
this.AddPartialConvos(convo);
|
|
@@ -6874,14 +6944,14 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6874
6944
|
}
|
|
6875
6945
|
|
|
6876
6946
|
AddScriptingMemories(scriptingMemories) {
|
|
6877
|
-
if (scriptingMemories && lodash__default[
|
|
6947
|
+
if (scriptingMemories && lodash__default["default"].isArray(scriptingMemories)) {
|
|
6878
6948
|
for (let i = 0; i < scriptingMemories.length; i++) {
|
|
6879
6949
|
const scriptingMemory = scriptingMemories[i];
|
|
6880
6950
|
this.AddScriptingMemories(scriptingMemory);
|
|
6881
6951
|
}
|
|
6882
6952
|
} else if (scriptingMemories) {
|
|
6883
6953
|
if (!scriptingMemories.header || !scriptingMemories.header.name) {
|
|
6884
|
-
throw new BotiumError$
|
|
6954
|
+
throw new BotiumError$2('Scripting Memory Definition has no name', {
|
|
6885
6955
|
type: 'Compiler',
|
|
6886
6956
|
subtype: 'Scripting memory without name',
|
|
6887
6957
|
source: 'ScriptingProvider',
|
|
@@ -6892,7 +6962,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6892
6962
|
}
|
|
6893
6963
|
|
|
6894
6964
|
if (!scriptingMemories.values || !Object.keys(scriptingMemories.values).length) {
|
|
6895
|
-
throw new BotiumError$
|
|
6965
|
+
throw new BotiumError$2('Scripting Memory Definition has no variables', {
|
|
6896
6966
|
type: 'Compiler',
|
|
6897
6967
|
subtype: 'Scripting memory without variable',
|
|
6898
6968
|
source: 'ScriptingProvider',
|
|
@@ -6902,8 +6972,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6902
6972
|
});
|
|
6903
6973
|
}
|
|
6904
6974
|
|
|
6905
|
-
if (scriptingMemories.values && !lodash__default[
|
|
6906
|
-
throw new BotiumError$
|
|
6975
|
+
if (scriptingMemories.values && !lodash__default["default"].isUndefined(scriptingMemories.values[''])) {
|
|
6976
|
+
throw new BotiumError$2('Scripting Memory Definition variable has no name', {
|
|
6907
6977
|
type: 'Compiler',
|
|
6908
6978
|
subtype: 'Scripting memory without variable name',
|
|
6909
6979
|
source: 'ScriptingProvider',
|
|
@@ -6969,9 +7039,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6969
7039
|
let currentChildren = root;
|
|
6970
7040
|
|
|
6971
7041
|
for (const convoNode of convoNodes) {
|
|
6972
|
-
const convoNodeValues = convoNode.sender === 'me' ? convoNode.convoSteps.map(convoStep => lodash__default[
|
|
7042
|
+
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));
|
|
6973
7043
|
const convoNodeHeader = {
|
|
6974
|
-
header: lodash__default[
|
|
7044
|
+
header: lodash__default["default"].pick(convo.header, ['name', 'description']),
|
|
6975
7045
|
sourceTag: convo.sourceTag,
|
|
6976
7046
|
convoStepIndices: convoNode.convoStepIndices
|
|
6977
7047
|
};
|
|
@@ -6982,16 +7052,16 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6982
7052
|
|
|
6983
7053
|
if (!hash) {
|
|
6984
7054
|
if (convoNode.sender === 'bot') {
|
|
6985
|
-
hash = crypto__default[
|
|
7055
|
+
hash = crypto__default["default"].createHash('md5').update(JSON.stringify(convoNode.convoSteps.map(convoStep => lodash__default["default"].pick(convoStep, pickBotHashProps)))).digest('hex');
|
|
6986
7056
|
} else {
|
|
6987
|
-
hash = crypto__default[
|
|
7057
|
+
hash = crypto__default["default"].createHash('md5').update(JSON.stringify(convoNode.convoSteps.map(convoStep => lodash__default["default"].pick(convoStep, pickMeHashProps)))).digest('hex');
|
|
6988
7058
|
}
|
|
6989
7059
|
}
|
|
6990
7060
|
|
|
6991
7061
|
const existingChildNode = currentChildren.find(c => c.hash === hash);
|
|
6992
7062
|
|
|
6993
7063
|
if (existingChildNode) {
|
|
6994
|
-
existingChildNode.convos.push(lodash__default[
|
|
7064
|
+
existingChildNode.convos.push(lodash__default["default"].cloneDeep(convoNodeHeader));
|
|
6995
7065
|
currentChildren = existingChildNode.childNodes;
|
|
6996
7066
|
continue;
|
|
6997
7067
|
}
|
|
@@ -7010,7 +7080,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7010
7080
|
if (existingConvo) {
|
|
7011
7081
|
existingConvo.convoStepIndices = [...existingConvo.convoStepIndices, ...convoNodeHeader.convoStepIndices];
|
|
7012
7082
|
} else {
|
|
7013
|
-
existingBotNode.convos.push(lodash__default[
|
|
7083
|
+
existingBotNode.convos.push(lodash__default["default"].cloneDeep(convoNodeHeader));
|
|
7014
7084
|
}
|
|
7015
7085
|
|
|
7016
7086
|
currentChildren = existingBotNode.childNodes;
|
|
@@ -7019,10 +7089,10 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7019
7089
|
|
|
7020
7090
|
const node = {
|
|
7021
7091
|
sender: convoNode.sender,
|
|
7022
|
-
key: randomatic__default[
|
|
7092
|
+
key: randomatic__default["default"]('0', 20),
|
|
7023
7093
|
hash: hash,
|
|
7024
7094
|
convoNodes: convoNodeValues,
|
|
7025
|
-
convos: [lodash__default[
|
|
7095
|
+
convos: [lodash__default["default"].cloneDeep(convoNodeHeader)],
|
|
7026
7096
|
childNodes: []
|
|
7027
7097
|
};
|
|
7028
7098
|
|
|
@@ -7101,7 +7171,7 @@ var NoRepo_1 = class NoRepo extends BaseRepo_1 {
|
|
|
7101
7171
|
};
|
|
7102
7172
|
|
|
7103
7173
|
var ProcessUtils = createCommonjsModule(function (module) {
|
|
7104
|
-
const debug = debug__default[
|
|
7174
|
+
const debug = debug__default["default"]('botium-core-ProcessUtils');
|
|
7105
7175
|
module.exports = {
|
|
7106
7176
|
childCommandLineRun: (cmd, ignoreErrors = false, processOptions = {}) => {
|
|
7107
7177
|
const cmdOptions = cmd.split(' ');
|
|
@@ -7111,8 +7181,8 @@ var ProcessUtils = createCommonjsModule(function (module) {
|
|
|
7111
7181
|
},
|
|
7112
7182
|
childProcessRun: (cmd, cmdOptions, ignoreErrors = false, processOptions = {}) => {
|
|
7113
7183
|
return new Promise((resolve, reject) => {
|
|
7114
|
-
debug('Running Command: ' + cmd + ' ' + lodash__default[
|
|
7115
|
-
const runningProcess = child_process__default[
|
|
7184
|
+
debug('Running Command: ' + cmd + ' ' + lodash__default["default"].join(cmdOptions, ' '));
|
|
7185
|
+
const runningProcess = child_process__default["default"].spawn(cmd, cmdOptions, processOptions);
|
|
7116
7186
|
const stdout = [];
|
|
7117
7187
|
const stderr = [];
|
|
7118
7188
|
runningProcess.stdout.on('data', data => {
|
|
@@ -7143,7 +7213,7 @@ var ProcessUtils = createCommonjsModule(function (module) {
|
|
|
7143
7213
|
if (ignoreErrors) {
|
|
7144
7214
|
resolve();
|
|
7145
7215
|
} else {
|
|
7146
|
-
reject(new Error(`${cmd} failed: ${util__default[
|
|
7216
|
+
reject(new Error(`${cmd} failed: ${util__default["default"].inspect(err)}`));
|
|
7147
7217
|
}
|
|
7148
7218
|
});
|
|
7149
7219
|
});
|
|
@@ -7153,7 +7223,7 @@ var ProcessUtils = createCommonjsModule(function (module) {
|
|
|
7153
7223
|
ProcessUtils.childCommandLineRun;
|
|
7154
7224
|
ProcessUtils.childProcessRun;
|
|
7155
7225
|
|
|
7156
|
-
const debug$8 = debug__default[
|
|
7226
|
+
const debug$8 = debug__default["default"]('botium-core-GitRepo');
|
|
7157
7227
|
var GitRepo_1 = class GitRepo extends BaseRepo_1 {
|
|
7158
7228
|
Validate() {
|
|
7159
7229
|
return super.Validate().then(() => {
|
|
@@ -7169,9 +7239,9 @@ var GitRepo_1 = class GitRepo extends BaseRepo_1 {
|
|
|
7169
7239
|
|
|
7170
7240
|
Prepare() {
|
|
7171
7241
|
return new Promise((resolve, reject) => {
|
|
7172
|
-
async__default[
|
|
7173
|
-
this.workingDirectory = path__default[
|
|
7174
|
-
mkdirp__default[
|
|
7242
|
+
async__default["default"].series([cloneDirectoryCreated => {
|
|
7243
|
+
this.workingDirectory = path__default["default"].resolve(this.tempDirectory, 'git');
|
|
7244
|
+
mkdirp__default["default"](this.workingDirectory, err => {
|
|
7175
7245
|
if (err) {
|
|
7176
7246
|
return cloneDirectoryCreated(new Error(`Unable to create clone directory ${this.workingDirectory}: ${err}`));
|
|
7177
7247
|
}
|
|
@@ -7184,7 +7254,7 @@ var GitRepo_1 = class GitRepo extends BaseRepo_1 {
|
|
|
7184
7254
|
cwd: this.workingDirectory
|
|
7185
7255
|
}).then(() => cloneReady()).catch(cloneReady);
|
|
7186
7256
|
}, workingDirectoryChanged => {
|
|
7187
|
-
this.workingDirectory = path__default[
|
|
7257
|
+
this.workingDirectory = path__default["default"].resolve(this.workingDirectory, this.sources[Source.GITDIR]);
|
|
7188
7258
|
workingDirectoryChanged();
|
|
7189
7259
|
}, prepareReady => {
|
|
7190
7260
|
if (this.sources[Source.GITPREPARECMD]) {
|
|
@@ -7213,13 +7283,13 @@ var LocalRepo_1 = class LocalRepo extends BaseRepo_1 {
|
|
|
7213
7283
|
this._AssertSourceExists(Source.LOCALPATH);
|
|
7214
7284
|
|
|
7215
7285
|
const checkPath = this.sources[Source.LOCALPATH];
|
|
7216
|
-
fs__default[
|
|
7286
|
+
fs__default["default"].stat(checkPath, (err, stats) => {
|
|
7217
7287
|
if (err) {
|
|
7218
7288
|
throw new Error(`${checkPath} not available: ${err}`);
|
|
7219
7289
|
}
|
|
7220
7290
|
|
|
7221
7291
|
if (stats.isDirectory() && !stats.isSymbolicLink()) {
|
|
7222
|
-
fs__default[
|
|
7292
|
+
fs__default["default"].access(checkPath, fs__default["default"].constants.W_OK, err1 => {
|
|
7223
7293
|
if (err) {
|
|
7224
7294
|
throw new Error(`${checkPath} not writeable: ${err}`);
|
|
7225
7295
|
}
|
|
@@ -7233,7 +7303,7 @@ var LocalRepo_1 = class LocalRepo extends BaseRepo_1 {
|
|
|
7233
7303
|
|
|
7234
7304
|
Prepare() {
|
|
7235
7305
|
// No need to prepare anything
|
|
7236
|
-
this.workingDirectory = path__default[
|
|
7306
|
+
this.workingDirectory = path__default["default"].resolve(this.sources[Source.LOCALPATH]);
|
|
7237
7307
|
return Promise.resolve();
|
|
7238
7308
|
}
|
|
7239
7309
|
|
|
@@ -7297,7 +7367,7 @@ var Queue_1 = class Queue {
|
|
|
7297
7367
|
|
|
7298
7368
|
return new Promise((resolve, reject) => {
|
|
7299
7369
|
let listener = null;
|
|
7300
|
-
const timeoutRequest = async__default[
|
|
7370
|
+
const timeoutRequest = async__default["default"].timeout(timeoutCallback => {
|
|
7301
7371
|
listener = msg => {
|
|
7302
7372
|
timeoutCallback(null, msg);
|
|
7303
7373
|
};
|
|
@@ -7310,7 +7380,7 @@ var Queue_1 = class Queue {
|
|
|
7310
7380
|
reject(new QueueTimeoutError_1(timeoutMillis));
|
|
7311
7381
|
} else if (err) {
|
|
7312
7382
|
this.listeners.splice(this.listeners.indexOf(listener), 1);
|
|
7313
|
-
reject(new Error(`Queue pop error ${util__default[
|
|
7383
|
+
reject(new Error(`Queue pop error ${util__default["default"].inspect(err)}`));
|
|
7314
7384
|
} else {
|
|
7315
7385
|
resolve(msg);
|
|
7316
7386
|
}
|
|
@@ -7324,7 +7394,7 @@ var Queue_1 = class Queue {
|
|
|
7324
7394
|
|
|
7325
7395
|
};
|
|
7326
7396
|
|
|
7327
|
-
const debug$7 = debug__default[
|
|
7397
|
+
const debug$7 = debug__default["default"]('botium-connector-BaseContainer');
|
|
7328
7398
|
const {
|
|
7329
7399
|
executeHook: executeHook$1,
|
|
7330
7400
|
getHook: getHook$1
|
|
@@ -7356,8 +7426,8 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7356
7426
|
const opts = {};
|
|
7357
7427
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT]) opts.maxConcurrent = this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT];
|
|
7358
7428
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) opts.minTime = this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME];
|
|
7359
|
-
this.userSaysLimiter = new bottleneck__default[
|
|
7360
|
-
debug$7(`Build: Applying userSays rate limits ${util__default[
|
|
7429
|
+
this.userSaysLimiter = new bottleneck__default["default"](opts);
|
|
7430
|
+
debug$7(`Build: Applying userSays rate limits ${util__default["default"].inspect(opts)}`);
|
|
7361
7431
|
}
|
|
7362
7432
|
|
|
7363
7433
|
return new Promise((resolve, reject) => {
|
|
@@ -7406,7 +7476,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7406
7476
|
|
|
7407
7477
|
return new Promise((resolve, reject) => {
|
|
7408
7478
|
this.queues[channel].pop(timeoutMillis).then(botMsg => {
|
|
7409
|
-
if (lodash__default[
|
|
7479
|
+
if (lodash__default["default"].isError(botMsg)) {
|
|
7410
7480
|
reject(botMsg);
|
|
7411
7481
|
} else {
|
|
7412
7482
|
resolve(botMsg);
|
|
@@ -7441,14 +7511,14 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7441
7511
|
Clean() {
|
|
7442
7512
|
this.userSaysLimiter = null;
|
|
7443
7513
|
return new Promise((resolve, reject) => {
|
|
7444
|
-
async__default[
|
|
7514
|
+
async__default["default"].series([hookExecuted => {
|
|
7445
7515
|
this._RunCustomHook('onClean', this.onCleanHook).then(() => hookExecuted()).catch(() => hookExecuted());
|
|
7446
7516
|
}, cleanupTasksDone => {
|
|
7447
7517
|
if (this.cleanupTasks) {
|
|
7448
|
-
async__default[
|
|
7518
|
+
async__default["default"].series(this.cleanupTasks.map(task => {
|
|
7449
7519
|
return cb => {
|
|
7450
7520
|
task(err => {
|
|
7451
|
-
if (err) debug$7(`Cleanup failed: ${util__default[
|
|
7521
|
+
if (err) debug$7(`Cleanup failed: ${util__default["default"].inspect(err)}`);
|
|
7452
7522
|
cb();
|
|
7453
7523
|
});
|
|
7454
7524
|
};
|
|
@@ -7461,8 +7531,8 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7461
7531
|
}, rimraffed => {
|
|
7462
7532
|
if (this.caps[Capabilities.CLEANUPTEMPDIR]) {
|
|
7463
7533
|
debug$7(`Cleanup rimrafing temp dir ${this.tempDirectory}`);
|
|
7464
|
-
rimraf__default[
|
|
7465
|
-
if (err) debug$7(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default[
|
|
7534
|
+
rimraf__default["default"](this.tempDirectory, err => {
|
|
7535
|
+
if (err) debug$7(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default["default"].inspect(err)}`);
|
|
7466
7536
|
rimraffed();
|
|
7467
7537
|
});
|
|
7468
7538
|
} else {
|
|
@@ -7470,7 +7540,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7470
7540
|
}
|
|
7471
7541
|
}], err => {
|
|
7472
7542
|
if (err) {
|
|
7473
|
-
return reject(new Error(`Cleanup failed ${util__default[
|
|
7543
|
+
return reject(new Error(`Cleanup failed ${util__default["default"].inspect(err)}`));
|
|
7474
7544
|
}
|
|
7475
7545
|
|
|
7476
7546
|
resolve();
|
|
@@ -7504,7 +7574,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7504
7574
|
}
|
|
7505
7575
|
|
|
7506
7576
|
async _QueueBotSays(botMsg) {
|
|
7507
|
-
if (lodash__default[
|
|
7577
|
+
if (lodash__default["default"].isError(botMsg)) {
|
|
7508
7578
|
if (!this.queues.default) {
|
|
7509
7579
|
this.queues.default = new Queue_1();
|
|
7510
7580
|
}
|
|
@@ -7531,16 +7601,16 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7531
7601
|
try {
|
|
7532
7602
|
await executeHook$1(this.caps, hook, Object.assign({
|
|
7533
7603
|
container: this,
|
|
7534
|
-
request: request__default[
|
|
7604
|
+
request: request__default["default"]
|
|
7535
7605
|
}, args));
|
|
7536
7606
|
} catch (err) {
|
|
7537
|
-
debug$7(`_RunCustomHook ${name} finished with error: ${err.message || util__default[
|
|
7607
|
+
debug$7(`_RunCustomHook ${name} finished with error: ${err.message || util__default["default"].inspect(err)}`);
|
|
7538
7608
|
}
|
|
7539
7609
|
}
|
|
7540
7610
|
|
|
7541
7611
|
};
|
|
7542
7612
|
|
|
7543
|
-
const debug$6 = debug__default[
|
|
7613
|
+
const debug$6 = debug__default["default"]('botium-connector-GridContainer');
|
|
7544
7614
|
var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
7545
7615
|
Validate() {
|
|
7546
7616
|
return super.Validate().then(() => {
|
|
@@ -7550,10 +7620,10 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7550
7620
|
|
|
7551
7621
|
Build() {
|
|
7552
7622
|
this.buildPromise = this._defer();
|
|
7553
|
-
async__default[
|
|
7623
|
+
async__default["default"].series([baseComplete => {
|
|
7554
7624
|
super.Build().then(() => baseComplete()).catch(baseComplete);
|
|
7555
7625
|
}, socketComplete => {
|
|
7556
|
-
this.socket = socket__default[
|
|
7626
|
+
this.socket = socket__default["default"](this.caps[Capabilities.BOTIUMGRIDURL]);
|
|
7557
7627
|
this.socket.on('connect', () => {
|
|
7558
7628
|
debug$6('connected');
|
|
7559
7629
|
this.socket.emit('authentication', {
|
|
@@ -7564,7 +7634,7 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7564
7634
|
debug$6(`connect_error ${err.message}`);
|
|
7565
7635
|
});
|
|
7566
7636
|
this.socket.on('connect_timeout', timeout => {
|
|
7567
|
-
debug$6(`connect_timeout ${util__default[
|
|
7637
|
+
debug$6(`connect_timeout ${util__default["default"].inspect(timeout)}`);
|
|
7568
7638
|
});
|
|
7569
7639
|
this.socket.on('error', err => {
|
|
7570
7640
|
debug$6(`error ${err.message}`);
|
|
@@ -7608,7 +7678,7 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7608
7678
|
}
|
|
7609
7679
|
});
|
|
7610
7680
|
this.socket.on(Events.MESSAGE_RECEIVEDFROMBOT, botMsg => {
|
|
7611
|
-
debug$6(`MESSAGE_RECEIVEDFROMBOT ${util__default[
|
|
7681
|
+
debug$6(`MESSAGE_RECEIVEDFROMBOT ${util__default["default"].inspect(botMsg)}`);
|
|
7612
7682
|
|
|
7613
7683
|
this._QueueBotSays(new BotiumMockMessage_1(botMsg));
|
|
7614
7684
|
});
|
|
@@ -7727,7 +7797,7 @@ var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
|
7727
7797
|
|
|
7728
7798
|
_ValidateCustomHook(capKey) {
|
|
7729
7799
|
if (this.caps[capKey]) {
|
|
7730
|
-
if (!lodash__default[
|
|
7800
|
+
if (!lodash__default["default"].isString(this.caps[capKey])) {
|
|
7731
7801
|
throw new Error(`Custom Hook ${capKey} has to be a command line string`);
|
|
7732
7802
|
}
|
|
7733
7803
|
}
|
|
@@ -7764,10 +7834,10 @@ var InProcessContainer_1 = class InProcessContainer extends BaseContainer_1 {
|
|
|
7764
7834
|
|
|
7765
7835
|
};
|
|
7766
7836
|
|
|
7767
|
-
const debug$5 = debug__default[
|
|
7837
|
+
const debug$5 = debug__default["default"]('botium-core-inbound-proxy');
|
|
7768
7838
|
|
|
7769
7839
|
const buildRedisHandler = (redisurl, topic) => {
|
|
7770
|
-
const redis = new ioredis__default[
|
|
7840
|
+
const redis = new ioredis__default["default"](redisurl);
|
|
7771
7841
|
redis.on('connect', () => {
|
|
7772
7842
|
debug$5(`Redis connected to ${JSON.stringify(redisurl || 'default')}`);
|
|
7773
7843
|
});
|
|
@@ -7818,10 +7888,10 @@ const startProxy$1 = async ({
|
|
|
7818
7888
|
processEvent
|
|
7819
7889
|
}) => {
|
|
7820
7890
|
return new Promise((resolve, reject) => {
|
|
7821
|
-
const app = express__default[
|
|
7891
|
+
const app = express__default["default"]();
|
|
7822
7892
|
setupEndpoints({
|
|
7823
7893
|
app,
|
|
7824
|
-
middleware: [bodyParser__default[
|
|
7894
|
+
middleware: [bodyParser__default["default"].json(), bodyParser__default["default"].urlencoded({
|
|
7825
7895
|
extended: true
|
|
7826
7896
|
})],
|
|
7827
7897
|
endpoint: endpoint || '/',
|
|
@@ -7846,8 +7916,8 @@ proxy.startProxy;
|
|
|
7846
7916
|
|
|
7847
7917
|
const {
|
|
7848
7918
|
v4: uuidv4
|
|
7849
|
-
} = uuid__default[
|
|
7850
|
-
const debug$4 = debug__default[
|
|
7919
|
+
} = uuid__default["default"];
|
|
7920
|
+
const debug$4 = debug__default["default"]('botium-connector-simplerest');
|
|
7851
7921
|
const {
|
|
7852
7922
|
startProxy
|
|
7853
7923
|
} = proxy;
|
|
@@ -7865,8 +7935,11 @@ const {
|
|
|
7865
7935
|
const {
|
|
7866
7936
|
escapeJSONString
|
|
7867
7937
|
} = Utils;
|
|
7938
|
+
const {
|
|
7939
|
+
BotiumError: BotiumError$1
|
|
7940
|
+
} = BotiumError_1;
|
|
7868
7941
|
|
|
7869
|
-
mustache__default[
|
|
7942
|
+
mustache__default["default"].escape = s => s;
|
|
7870
7943
|
|
|
7871
7944
|
var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
7872
7945
|
constructor({
|
|
@@ -7881,14 +7954,14 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7881
7954
|
if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
|
|
7882
7955
|
const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
|
|
7883
7956
|
this.inboundEvents = [];
|
|
7884
|
-
this._processOrderedInboundEventsArrayAsync = lodash__default[
|
|
7957
|
+
this._processOrderedInboundEventsArrayAsync = lodash__default["default"].debounce(() => {
|
|
7885
7958
|
const events = [...this.inboundEvents];
|
|
7886
7959
|
this.inboundEvents = [];
|
|
7887
7960
|
|
|
7888
7961
|
const jsonPath = this._getMustachedVal(this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH], false);
|
|
7889
7962
|
|
|
7890
|
-
const sortedEvents = lodash__default[
|
|
7891
|
-
const qr = jsonpath__default[
|
|
7963
|
+
const sortedEvents = lodash__default["default"].sortBy(events, event => {
|
|
7964
|
+
const qr = jsonpath__default["default"].query(event, jsonPath);
|
|
7892
7965
|
return qr[0];
|
|
7893
7966
|
});
|
|
7894
7967
|
|
|
@@ -7902,17 +7975,32 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7902
7975
|
Validate() {
|
|
7903
7976
|
if (!this.caps[Capabilities.SIMPLEREST_URL]) throw new Error('SIMPLEREST_URL capability required');
|
|
7904
7977
|
if (!this.caps[Capabilities.SIMPLEREST_METHOD] && !this.caps[Capabilities.SIMPLEREST_VERB]) throw new Error('SIMPLEREST_METHOD/SIMPLEREST_VERB capability required');
|
|
7905
|
-
if (lodash__default[
|
|
7978
|
+
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');
|
|
7906
7979
|
|
|
7907
7980
|
if (this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) {
|
|
7908
|
-
lodash__default[
|
|
7981
|
+
lodash__default["default"].isObject(this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) || JSON.parse(this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]);
|
|
7909
7982
|
}
|
|
7910
7983
|
|
|
7911
7984
|
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');
|
|
7912
7985
|
this.startHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_START_HOOK]);
|
|
7913
7986
|
this.stopHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_STOP_HOOK]);
|
|
7914
7987
|
this.requestHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_REQUEST_HOOK]);
|
|
7988
|
+
this.parserHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_PARSER_HOOK]);
|
|
7915
7989
|
this.responseHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_RESPONSE_HOOK]);
|
|
7990
|
+
this.pollRequestHook = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_POLL_REQUEST_HOOK]);
|
|
7991
|
+
this.requestHooks = {};
|
|
7992
|
+
|
|
7993
|
+
if (this.caps[Capabilities.SIMPLEREST_PING_REQUEST_HOOK]) {
|
|
7994
|
+
this.requestHooks.SIMPLEREST_PING = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_PING_REQUEST_HOOK]);
|
|
7995
|
+
}
|
|
7996
|
+
|
|
7997
|
+
if (this.caps[Capabilities.SIMPLEREST_START_REQUEST_HOOK]) {
|
|
7998
|
+
this.requestHooks.SIMPLEREST_START = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_START_REQUEST_HOOK]);
|
|
7999
|
+
}
|
|
8000
|
+
|
|
8001
|
+
if (this.caps[Capabilities.SIMPLEREST_STOP_REQUEST_HOOK]) {
|
|
8002
|
+
this.requestHooks.SIMPLEREST_STOP = getHook(this.caps, this.caps[Capabilities.SIMPLEREST_STOP_REQUEST_HOOK]);
|
|
8003
|
+
}
|
|
7916
8004
|
}
|
|
7917
8005
|
|
|
7918
8006
|
Build() {
|
|
@@ -7921,7 +8009,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7921
8009
|
|
|
7922
8010
|
Start() {
|
|
7923
8011
|
return new Promise((resolve, reject) => {
|
|
7924
|
-
async__default[
|
|
8012
|
+
async__default["default"].series([contextInitComplete => {
|
|
7925
8013
|
this.view = {
|
|
7926
8014
|
container: this,
|
|
7927
8015
|
context: {},
|
|
@@ -7936,7 +8024,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7936
8024
|
// (render(text) is required for forcing mustache to replace valiables in the text first,
|
|
7937
8025
|
// then send it to the function.)
|
|
7938
8026
|
// (mapKeys: remove starting $)
|
|
7939
|
-
fnc: lodash__default[
|
|
8027
|
+
fnc: lodash__default["default"].mapValues(lodash__default["default"].mapKeys(SCRIPTING_FUNCTIONS, (value, key) => key.substring(1)), descriptor => {
|
|
7940
8028
|
const safeCaps = Object.assign({}, this.caps, {
|
|
7941
8029
|
[Capabilities.SECURITY_ALLOW_UNSAFE]: true
|
|
7942
8030
|
});
|
|
@@ -7958,7 +8046,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7958
8046
|
|
|
7959
8047
|
if (this.caps[Capabilities.SIMPLEREST_INIT_CONTEXT]) {
|
|
7960
8048
|
try {
|
|
7961
|
-
this.view.context = lodash__default[
|
|
8049
|
+
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]);
|
|
7962
8050
|
} catch (err) {
|
|
7963
8051
|
contextInitComplete(`parsing SIMPLEREST_INIT_CONTEXT failed, no JSON detected (${err.message})`);
|
|
7964
8052
|
}
|
|
@@ -7967,17 +8055,24 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7967
8055
|
contextInitComplete();
|
|
7968
8056
|
}, startHookComplete => {
|
|
7969
8057
|
executeHook(this.caps, this.startHook, this.view).then(() => startHookComplete()).catch(startHookComplete);
|
|
8058
|
+
}, inboundListenerComplete => {
|
|
8059
|
+
this._subscribeInbound().then(() => inboundListenerComplete()).catch(inboundListenerComplete);
|
|
8060
|
+
}, startPollingComplete => {
|
|
8061
|
+
this._startPolling().then(() => startPollingComplete()).catch(startPollingComplete);
|
|
7970
8062
|
}, pingComplete => {
|
|
7971
8063
|
if (this.caps[Capabilities.SIMPLEREST_PING_URL]) {
|
|
7972
|
-
this._makeCall('SIMPLEREST_PING').then(
|
|
8064
|
+
this._makeCall('SIMPLEREST_PING').then(body => {
|
|
7973
8065
|
if (this.caps[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT] || this.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE]) {
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
8066
|
+
return this._parseResponseBody(body).then(body => {
|
|
8067
|
+
if (body) {
|
|
8068
|
+
debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} returned JSON response: ${Utils.shortenJsonString(body)}`);
|
|
8069
|
+
return this._processBodyAsync(body, !!this.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT]);
|
|
8070
|
+
} else {
|
|
8071
|
+
debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} didn't return JSON response, ignoring it.`);
|
|
8072
|
+
}
|
|
8073
|
+
}).catch(err => {
|
|
8074
|
+
debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} didn't return JSON response, ignoring it (${err.message})`);
|
|
8075
|
+
});
|
|
7981
8076
|
}
|
|
7982
8077
|
}).then(() => {
|
|
7983
8078
|
pingComplete();
|
|
@@ -7988,30 +8083,29 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7988
8083
|
pingComplete();
|
|
7989
8084
|
}
|
|
7990
8085
|
}, initComplete => {
|
|
7991
|
-
if (lodash__default[
|
|
8086
|
+
if (lodash__default["default"].isString(this.caps[Capabilities.SIMPLEREST_INIT_TEXT])) {
|
|
7992
8087
|
this._doRequest({
|
|
7993
8088
|
messageText: this.caps[Capabilities.SIMPLEREST_INIT_TEXT]
|
|
7994
|
-
},
|
|
8089
|
+
}, !!this.caps[Capabilities.SIMPLEREST_INIT_PROCESS_RESPONSE], true).then(() => initComplete()).catch(initComplete);
|
|
7995
8090
|
} else {
|
|
7996
8091
|
initComplete();
|
|
7997
8092
|
}
|
|
7998
|
-
}, inboundListenerComplete => {
|
|
7999
|
-
this._subscribeInbound().then(() => inboundListenerComplete()).catch(inboundListenerComplete);
|
|
8000
|
-
}, startPollingComplete => {
|
|
8001
|
-
this._startPolling().then(() => startPollingComplete()).catch(startPollingComplete);
|
|
8002
8093
|
}, startCallComplete => {
|
|
8003
8094
|
this.processInbound = true;
|
|
8004
8095
|
|
|
8005
8096
|
if (this.caps[Capabilities.SIMPLEREST_START_URL]) {
|
|
8006
|
-
this._makeCall('SIMPLEREST_START').then(
|
|
8097
|
+
this._makeCall('SIMPLEREST_START').then(body => {
|
|
8007
8098
|
if (this.caps[Capabilities.SIMPLEREST_START_UPDATE_CONTEXT] || this.caps[Capabilities.SIMPLEREST_START_PROCESS_RESPONSE]) {
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8099
|
+
return this._parseResponseBody(body).then(body => {
|
|
8100
|
+
if (body) {
|
|
8101
|
+
debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} returned JSON response: ${Utils.shortenJsonString(body)}`);
|
|
8102
|
+
return this._processBodyAsync(body, !!this.caps[Capabilities.SIMPLEREST_START_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_START_UPDATE_CONTEXT]);
|
|
8103
|
+
} else {
|
|
8104
|
+
debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} didn't return JSON response, ignoring it.`);
|
|
8105
|
+
}
|
|
8106
|
+
}).catch(err => {
|
|
8107
|
+
debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} didn't return JSON response, ignoring it (${err.message})`);
|
|
8108
|
+
});
|
|
8015
8109
|
}
|
|
8016
8110
|
}).then(() => {
|
|
8017
8111
|
startCallComplete();
|
|
@@ -8098,9 +8192,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8098
8192
|
|
|
8099
8193
|
if (jsonPathsContext.length > 0) {
|
|
8100
8194
|
for (const jsonPathContext of jsonPathsContext) {
|
|
8101
|
-
const contextNodes = jsonpath__default[
|
|
8195
|
+
const contextNodes = jsonpath__default["default"].query(body, jsonPathContext);
|
|
8102
8196
|
|
|
8103
|
-
if (lodash__default[
|
|
8197
|
+
if (lodash__default["default"].isArray(contextNodes) && contextNodes.length > 0) {
|
|
8104
8198
|
if (mergeMode === 'MERGE') {
|
|
8105
8199
|
Object.assign(this.view.context, contextNodes[0]);
|
|
8106
8200
|
} else if (mergeMode === 'REPLACE') {
|
|
@@ -8116,7 +8210,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8116
8210
|
}
|
|
8117
8211
|
}
|
|
8118
8212
|
|
|
8119
|
-
debug$4(`current session context: ${util__default[
|
|
8213
|
+
debug$4(`current session context: ${util__default["default"].inspect(this.view.context)}`);
|
|
8120
8214
|
}
|
|
8121
8215
|
|
|
8122
8216
|
const result = [];
|
|
@@ -8127,9 +8221,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8127
8221
|
|
|
8128
8222
|
if (jsonPathsBody.length > 0) {
|
|
8129
8223
|
for (const jsonPathBody of jsonPathsBody) {
|
|
8130
|
-
const rb = jsonpath__default[
|
|
8224
|
+
const rb = jsonpath__default["default"].query(body, jsonPathBody);
|
|
8131
8225
|
|
|
8132
|
-
if (lodash__default[
|
|
8226
|
+
if (lodash__default["default"].isArray(rb)) {
|
|
8133
8227
|
rb.forEach(r => jsonPathRoots.push(r));
|
|
8134
8228
|
} else if (rb) {
|
|
8135
8229
|
jsonPathRoots.push(rb);
|
|
@@ -8144,25 +8238,25 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8144
8238
|
const buttons = [];
|
|
8145
8239
|
const jsonPathsMedia = getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps);
|
|
8146
8240
|
jsonPathsMedia.forEach(jsonPath => {
|
|
8147
|
-
const responseMedia = jsonpath__default[
|
|
8241
|
+
const responseMedia = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
|
|
8148
8242
|
|
|
8149
8243
|
if (responseMedia) {
|
|
8150
|
-
(lodash__default[
|
|
8244
|
+
(lodash__default["default"].isArray(responseMedia) ? lodash__default["default"].flattenDeep(responseMedia) : [responseMedia]).forEach(m => media.push({
|
|
8151
8245
|
mediaUri: m,
|
|
8152
|
-
mimeType: mimeTypes__default[
|
|
8246
|
+
mimeType: mimeTypes__default["default"].lookup(m) || 'application/unknown'
|
|
8153
8247
|
}));
|
|
8154
|
-
debug$4(`found response media: ${util__default[
|
|
8248
|
+
debug$4(`found response media: ${util__default["default"].inspect(media)}`);
|
|
8155
8249
|
}
|
|
8156
8250
|
});
|
|
8157
8251
|
const jsonPathsButtons = getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps);
|
|
8158
8252
|
jsonPathsButtons.forEach(jsonPath => {
|
|
8159
|
-
const responseButtons = jsonpath__default[
|
|
8253
|
+
const responseButtons = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
|
|
8160
8254
|
|
|
8161
8255
|
if (responseButtons) {
|
|
8162
|
-
(lodash__default[
|
|
8256
|
+
(lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => buttons.push({
|
|
8163
8257
|
text: b
|
|
8164
8258
|
}));
|
|
8165
|
-
debug$4(`found response buttons: ${util__default[
|
|
8259
|
+
debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
|
|
8166
8260
|
}
|
|
8167
8261
|
});
|
|
8168
8262
|
let hasMessageText = false;
|
|
@@ -8170,9 +8264,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8170
8264
|
|
|
8171
8265
|
for (const jsonPath of jsonPathsTexts) {
|
|
8172
8266
|
debug$4(`eval json path ${jsonPath}`);
|
|
8173
|
-
const responseTexts = jsonpath__default[
|
|
8174
|
-
debug$4(`found response texts: ${util__default[
|
|
8175
|
-
const messageTexts = lodash__default[
|
|
8267
|
+
const responseTexts = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
|
|
8268
|
+
debug$4(`found response texts: ${util__default["default"].inspect(responseTexts)}`);
|
|
8269
|
+
const messageTexts = lodash__default["default"].isArray(responseTexts) ? lodash__default["default"].flattenDeep(responseTexts) : [responseTexts];
|
|
8176
8270
|
|
|
8177
8271
|
for (const [messageTextIndex, messageText] of messageTexts.entries()) {
|
|
8178
8272
|
if (!messageText) continue;
|
|
@@ -8222,30 +8316,46 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8222
8316
|
msg.sourceData = msg.sourceData || {};
|
|
8223
8317
|
msg.sourceData.requestOptions = requestOptions;
|
|
8224
8318
|
this.waitProcessQueue = [];
|
|
8225
|
-
request__default[
|
|
8319
|
+
request__default["default"](requestOptions, async (err, response, body) => {
|
|
8226
8320
|
if (err) {
|
|
8227
|
-
reject(new Error(`rest request failed: ${err.message}`));
|
|
8321
|
+
return reject(new Error(`rest request failed: ${err.message}`));
|
|
8228
8322
|
} else {
|
|
8229
8323
|
if (response.statusCode >= 400) {
|
|
8230
8324
|
debug$4(`got error response: ${response.statusCode}/${response.statusMessage}`);
|
|
8325
|
+
|
|
8326
|
+
if (debug$4.enabled && body) {
|
|
8327
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8328
|
+
}
|
|
8329
|
+
|
|
8330
|
+
if (body) {
|
|
8331
|
+
const jsonBody = Utils.toJsonWeak(body);
|
|
8332
|
+
const errKey = Object.keys(jsonBody).find(k => k.startsWith('err') || k.startsWith('fail'));
|
|
8333
|
+
|
|
8334
|
+
if (errKey) {
|
|
8335
|
+
return reject(new BotiumError$1(`got error response: ${response.statusCode}/${response.statusMessage} - ${jsonBody[errKey]}`, {
|
|
8336
|
+
message: Utils.shortenJsonString(body)
|
|
8337
|
+
}));
|
|
8338
|
+
}
|
|
8339
|
+
}
|
|
8340
|
+
|
|
8231
8341
|
return reject(new Error(`got error response: ${response.statusCode}/${response.statusMessage}`));
|
|
8232
8342
|
}
|
|
8233
8343
|
|
|
8234
8344
|
if (body) {
|
|
8235
8345
|
debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8236
8346
|
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8347
|
+
try {
|
|
8348
|
+
body = await this._parseResponseBody(body);
|
|
8349
|
+
} catch (err) {
|
|
8350
|
+
debug$4(`ignoring not JSON formatted response body: ${err.message}`);
|
|
8351
|
+
resolve(this);
|
|
8240
8352
|
|
|
8241
|
-
|
|
8242
|
-
} catch (err) {
|
|
8243
|
-
debug$4(`ignoring not JSON formatted response body (${err.message})`);
|
|
8244
|
-
resolve(this);
|
|
8353
|
+
this._emptyWaitProcessQueue();
|
|
8245
8354
|
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8355
|
+
return;
|
|
8356
|
+
}
|
|
8357
|
+
|
|
8358
|
+
if (body) {
|
|
8249
8359
|
this._processBodyAsync(body, isFromUser, updateContext).then(() => resolve(this)).then(() => this._emptyWaitProcessQueue());
|
|
8250
8360
|
} else {
|
|
8251
8361
|
debug$4('ignoring response body (no string and no JSON object)');
|
|
@@ -8316,7 +8426,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8316
8426
|
this.view.msg.messageText = nonEncodedMessage;
|
|
8317
8427
|
|
|
8318
8428
|
if (msg.ADD_QUERY_PARAM && Object.keys(msg.ADD_QUERY_PARAM).length > 0) {
|
|
8319
|
-
const appendToUri = Object.keys(msg.ADD_QUERY_PARAM).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(this._getMustachedVal(lodash__default[
|
|
8429
|
+
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('&');
|
|
8320
8430
|
|
|
8321
8431
|
if (requestOptions.uri.indexOf('?') > 0) {
|
|
8322
8432
|
requestOptions.uri = `${requestOptions.uri}&${appendToUri}`;
|
|
@@ -8325,13 +8435,23 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8325
8435
|
}
|
|
8326
8436
|
}
|
|
8327
8437
|
|
|
8438
|
+
if (msg.ADD_FORM_PARAM && Object.keys(msg.ADD_FORM_PARAM).length > 0) {
|
|
8439
|
+
requestOptions.form = {};
|
|
8440
|
+
|
|
8441
|
+
for (const formKey of Object.keys(msg.ADD_FORM_PARAM)) {
|
|
8442
|
+
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);
|
|
8443
|
+
|
|
8444
|
+
requestOptions.form[formKey] = formValue;
|
|
8445
|
+
}
|
|
8446
|
+
}
|
|
8447
|
+
|
|
8328
8448
|
if (msg.ADD_HEADER && Object.keys(msg.ADD_HEADER).length > 0) {
|
|
8329
8449
|
requestOptions.headers = requestOptions.headers || {};
|
|
8330
8450
|
|
|
8331
8451
|
for (const headerKey of Object.keys(msg.ADD_HEADER)) {
|
|
8332
8452
|
let headerValue;
|
|
8333
8453
|
|
|
8334
|
-
if (lodash__default[
|
|
8454
|
+
if (lodash__default["default"].isString(msg.ADD_HEADER[headerKey])) {
|
|
8335
8455
|
headerValue = this._getMustachedVal(msg.ADD_HEADER[headerKey], false);
|
|
8336
8456
|
} else {
|
|
8337
8457
|
headerValue = this._getMustachedVal(JSON.stringify(msg.ADD_HEADER[headerKey]), true);
|
|
@@ -8367,7 +8487,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8367
8487
|
response,
|
|
8368
8488
|
body
|
|
8369
8489
|
} = await new Promise(resolve => {
|
|
8370
|
-
request__default[
|
|
8490
|
+
request__default["default"](pingConfig, (err, response, body) => {
|
|
8371
8491
|
resolve({
|
|
8372
8492
|
err,
|
|
8373
8493
|
response,
|
|
@@ -8381,27 +8501,58 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8381
8501
|
await timeout(pingConfig.timeout);
|
|
8382
8502
|
} else if (response.statusCode >= 400) {
|
|
8383
8503
|
debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
|
|
8504
|
+
|
|
8505
|
+
if (debug$4.enabled && body) {
|
|
8506
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8507
|
+
}
|
|
8508
|
+
|
|
8384
8509
|
await timeout(pingConfig.timeout);
|
|
8385
8510
|
} else {
|
|
8386
|
-
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}`);
|
|
8511
|
+
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
|
|
8512
|
+
|
|
8513
|
+
if (debug$4.enabled && body) {
|
|
8514
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8515
|
+
}
|
|
8516
|
+
|
|
8387
8517
|
return body;
|
|
8388
8518
|
}
|
|
8389
8519
|
}
|
|
8390
8520
|
}
|
|
8391
8521
|
|
|
8522
|
+
async _parseResponseBody(body) {
|
|
8523
|
+
if (!lodash__default["default"].isObject(body) && lodash__default["default"].isString(body)) {
|
|
8524
|
+
try {
|
|
8525
|
+
body = JSON.parse(body);
|
|
8526
|
+
} catch (err) {
|
|
8527
|
+
if (!this.parserHook) throw err;
|
|
8528
|
+
}
|
|
8529
|
+
}
|
|
8530
|
+
|
|
8531
|
+
if (this.parserHook) {
|
|
8532
|
+
await executeHook(this.caps, this.parserHook, Object.assign({
|
|
8533
|
+
body,
|
|
8534
|
+
changeBody: b => {
|
|
8535
|
+
body = b;
|
|
8536
|
+
}
|
|
8537
|
+
}, this.view));
|
|
8538
|
+
}
|
|
8539
|
+
|
|
8540
|
+
if (lodash__default["default"].isObject(body)) return body;else if (lodash__default["default"].isString(body)) return JSON.parse(body);else return null;
|
|
8541
|
+
}
|
|
8542
|
+
|
|
8392
8543
|
_getCapValue(capName) {
|
|
8393
|
-
return lodash__default[
|
|
8544
|
+
return lodash__default["default"].isFunction(this.caps[capName]) ? this.caps[capName]() : this.caps[capName];
|
|
8394
8545
|
}
|
|
8395
8546
|
|
|
8396
8547
|
_getMustachedCap(capName, json) {
|
|
8397
8548
|
const capValue = this._getCapValue(capName);
|
|
8398
8549
|
|
|
8399
|
-
const template = lodash__default[
|
|
8550
|
+
const template = lodash__default["default"].isString(capValue) ? capValue : JSON.stringify(capValue);
|
|
8400
8551
|
return this._getMustachedVal(template, json);
|
|
8401
8552
|
}
|
|
8402
8553
|
|
|
8403
8554
|
_getMustachedVal(template, json) {
|
|
8404
|
-
const raw = mustache__default[
|
|
8555
|
+
const raw = mustache__default["default"].render(template, this.view);
|
|
8405
8556
|
|
|
8406
8557
|
if (json) {
|
|
8407
8558
|
try {
|
|
@@ -8425,7 +8576,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8425
8576
|
for (const jsonPathTemplate of jsonPathsSelector) {
|
|
8426
8577
|
const jsonPath = this._getMustachedVal(jsonPathTemplate, false);
|
|
8427
8578
|
|
|
8428
|
-
const hasResult = jsonpath__default[
|
|
8579
|
+
const hasResult = jsonpath__default["default"].query(event, jsonPath);
|
|
8429
8580
|
|
|
8430
8581
|
if (hasResult && hasResult.length > 0) {
|
|
8431
8582
|
const check = jsonPathValue && this._getMustachedVal(jsonPathValue, false);
|
|
@@ -8458,12 +8609,12 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8458
8609
|
|
|
8459
8610
|
async _buildInbound() {
|
|
8460
8611
|
if (this.caps[Capabilities.SIMPLEREST_INBOUND_REDISURL] && this.caps[Capabilities.SIMPLEREST_INBOUND_SELECTOR_JSONPATH] && this.caps[Capabilities.SIMPLEREST_INBOUND_SELECTOR_VALUE]) {
|
|
8461
|
-
this.redis = new ioredis__default[
|
|
8612
|
+
this.redis = new ioredis__default["default"](this.caps[Capabilities.SIMPLEREST_INBOUND_REDISURL]);
|
|
8462
8613
|
this.redis.on('connect', () => {
|
|
8463
8614
|
debug$4(`Redis connected to ${JSON.stringify(this.caps[Capabilities.SIMPLEREST_INBOUND_REDISURL] || 'default')}`);
|
|
8464
8615
|
});
|
|
8465
8616
|
this.redis.on('message', (channel, event) => {
|
|
8466
|
-
if (!lodash__default[
|
|
8617
|
+
if (!lodash__default["default"].isString(event)) {
|
|
8467
8618
|
return debug$4(`WARNING: received non-string message from ${channel}, ignoring: ${event}`);
|
|
8468
8619
|
}
|
|
8469
8620
|
|
|
@@ -8531,7 +8682,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8531
8682
|
}
|
|
8532
8683
|
}
|
|
8533
8684
|
|
|
8534
|
-
_runPolling() {
|
|
8685
|
+
async _runPolling() {
|
|
8535
8686
|
if (!this.processInbound) return;
|
|
8536
8687
|
|
|
8537
8688
|
if (this.caps[Capabilities.SIMPLEREST_POLL_URL]) {
|
|
@@ -8571,23 +8722,36 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8571
8722
|
|
|
8572
8723
|
this._addRequestOptions(pollConfig);
|
|
8573
8724
|
|
|
8574
|
-
|
|
8725
|
+
try {
|
|
8726
|
+
await executeHook(this.caps, this.pollRequestHook, Object.assign({
|
|
8727
|
+
requestOptions: pollConfig
|
|
8728
|
+
}, this.view));
|
|
8729
|
+
} catch (err) {
|
|
8730
|
+
debug$4(`_runPolling: exeucting request hook failed - (${err.message})`);
|
|
8731
|
+
return;
|
|
8732
|
+
}
|
|
8733
|
+
|
|
8734
|
+
request__default["default"](pollConfig, async (err, response, body) => {
|
|
8575
8735
|
if (err) {
|
|
8576
8736
|
debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
|
|
8577
8737
|
} else {
|
|
8578
8738
|
if (response.statusCode >= 400) {
|
|
8579
8739
|
debug$4(`_runPolling: got error response: ${response.statusCode}/${response.statusMessage}, request: ${JSON.stringify(pollConfig)}`);
|
|
8740
|
+
|
|
8741
|
+
if (debug$4.enabled && body) {
|
|
8742
|
+
debug$4(Utils.shortenJsonString(body));
|
|
8743
|
+
}
|
|
8580
8744
|
} else if (body) {
|
|
8581
8745
|
debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8582
8746
|
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8747
|
+
try {
|
|
8748
|
+
body = await this._parseResponseBody(body);
|
|
8749
|
+
} catch (err) {
|
|
8750
|
+
debug$4(`_runPolling: ignoring not JSON formatted response body: ${err.message}`);
|
|
8751
|
+
return;
|
|
8752
|
+
}
|
|
8753
|
+
|
|
8754
|
+
if (body) {
|
|
8591
8755
|
setTimeout(() => this._processBodyAsync(body, true, !!this.caps[Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT]), 0);
|
|
8592
8756
|
} else {
|
|
8593
8757
|
debug$4('_runPolling: ignoring response body (no string and no JSON object)');
|
|
@@ -8650,6 +8814,10 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8650
8814
|
|
|
8651
8815
|
this._addRequestOptions(httpConfig);
|
|
8652
8816
|
|
|
8817
|
+
await executeHook(this.caps, this.requestHooks[capPrefix], Object.assign({
|
|
8818
|
+
requestOptions: httpConfig
|
|
8819
|
+
}, this.view));
|
|
8820
|
+
|
|
8653
8821
|
const retries = this._getCapValue(`${capPrefix}_RETRIES`);
|
|
8654
8822
|
|
|
8655
8823
|
debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
|
|
@@ -8665,13 +8833,13 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8665
8833
|
}
|
|
8666
8834
|
|
|
8667
8835
|
if (this.caps[Capabilities.SIMPLEREST_EXTRA_OPTIONS]) {
|
|
8668
|
-
lodash__default[
|
|
8836
|
+
lodash__default["default"].merge(httpConfig, this.caps[Capabilities.SIMPLEREST_EXTRA_OPTIONS]);
|
|
8669
8837
|
}
|
|
8670
8838
|
}
|
|
8671
8839
|
|
|
8672
8840
|
};
|
|
8673
8841
|
|
|
8674
|
-
const debug$3 = debug__default[
|
|
8842
|
+
const debug$3 = debug__default["default"]('botium-connector-PluginConnectorContainer-helper');
|
|
8675
8843
|
const {
|
|
8676
8844
|
BotiumError
|
|
8677
8845
|
} = BotiumError_1;
|
|
@@ -8705,7 +8873,7 @@ const loadConnectorModule = (PluginClass, args) => {
|
|
|
8705
8873
|
return new PluginClass(args);
|
|
8706
8874
|
} catch (err) {}
|
|
8707
8875
|
|
|
8708
|
-
if (lodash__default[
|
|
8876
|
+
if (lodash__default["default"].isFunction(PluginClass)) {
|
|
8709
8877
|
const result = PluginClass(args);
|
|
8710
8878
|
|
|
8711
8879
|
if (result && result.UserSays) {
|
|
@@ -8716,7 +8884,7 @@ const loadConnectorModule = (PluginClass, args) => {
|
|
|
8716
8884
|
const response = PluginClass(msg, args);
|
|
8717
8885
|
|
|
8718
8886
|
if (response && args.queueBotSays) {
|
|
8719
|
-
if (lodash__default[
|
|
8887
|
+
if (lodash__default["default"].isString(response)) {
|
|
8720
8888
|
setTimeout(() => args.queueBotSays({
|
|
8721
8889
|
messageText: response
|
|
8722
8890
|
}), 0);
|
|
@@ -8756,7 +8924,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
|
|
|
8756
8924
|
return pluginInstance;
|
|
8757
8925
|
}
|
|
8758
8926
|
|
|
8759
|
-
if (lodash__default[
|
|
8927
|
+
if (lodash__default["default"].isFunction(pluginLoaderSpec)) {
|
|
8760
8928
|
const pluginInstance = pluginLoaderSpec(args);
|
|
8761
8929
|
debug$3('Botium plugin loaded from function call');
|
|
8762
8930
|
return pluginInstance;
|
|
@@ -8764,10 +8932,10 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
|
|
|
8764
8932
|
|
|
8765
8933
|
const loadErr = [];
|
|
8766
8934
|
|
|
8767
|
-
if (lodash__default[
|
|
8768
|
-
const tryLoadFile = path__default[
|
|
8935
|
+
if (lodash__default["default"].isString(pluginLoaderSpec)) {
|
|
8936
|
+
const tryLoadFile = path__default["default"].resolve(process.cwd(), pluginLoaderSpec);
|
|
8769
8937
|
|
|
8770
|
-
if (fs__default[
|
|
8938
|
+
if (fs__default["default"].existsSync(tryLoadFile)) {
|
|
8771
8939
|
_checkUnsafe(args.caps, 'Using work dir', {
|
|
8772
8940
|
modulepath,
|
|
8773
8941
|
containermode
|
|
@@ -8840,7 +9008,7 @@ var plugins = {
|
|
|
8840
9008
|
tryLoadPlugin: tryLoadPlugin$1
|
|
8841
9009
|
};
|
|
8842
9010
|
|
|
8843
|
-
const debug$2 = debug__default[
|
|
9011
|
+
const debug$2 = debug__default["default"]('botium-connector-PluginConnectorContainer');
|
|
8844
9012
|
const {
|
|
8845
9013
|
tryLoadPlugin
|
|
8846
9014
|
} = plugins;
|
|
@@ -8877,7 +9045,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8877
9045
|
|
|
8878
9046
|
Build() {
|
|
8879
9047
|
try {
|
|
8880
|
-
return super.Build().then(() => promiseRetry__default[
|
|
9048
|
+
return super.Build().then(() => promiseRetry__default["default"]((retry, number) => {
|
|
8881
9049
|
return (this.pluginInstance.Build ? this.pluginInstance.Build() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8882
9050
|
if (this.retryHelperBuild.shouldRetry(err)) {
|
|
8883
9051
|
debug$2(`Build trial #${number} failed, retry activated`);
|
|
@@ -8888,7 +9056,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8888
9056
|
});
|
|
8889
9057
|
}, this.retryHelperBuild.retrySettings)).then(() => this);
|
|
8890
9058
|
} catch (err) {
|
|
8891
|
-
return Promise.reject(new Error(`Build - Botium plugin failed: ${util__default[
|
|
9059
|
+
return Promise.reject(new Error(`Build - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
8892
9060
|
}
|
|
8893
9061
|
}
|
|
8894
9062
|
|
|
@@ -8896,7 +9064,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8896
9064
|
this.eventEmitter.emit(Events.CONTAINER_STARTING, this);
|
|
8897
9065
|
|
|
8898
9066
|
try {
|
|
8899
|
-
return super.Start().then(() => promiseRetry__default[
|
|
9067
|
+
return super.Start().then(() => promiseRetry__default["default"]((retry, number) => {
|
|
8900
9068
|
return (this.pluginInstance.Start ? this.pluginInstance.Start() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8901
9069
|
if (this.retryHelperStart.shouldRetry(err)) {
|
|
8902
9070
|
debug$2(`Start trial #${number} failed, retry activated`);
|
|
@@ -8914,13 +9082,13 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8914
9082
|
});
|
|
8915
9083
|
} catch (err) {
|
|
8916
9084
|
this.eventEmitter.emit(Events.CONTAINER_START_ERROR, this, err);
|
|
8917
|
-
return Promise.reject(new Error(`Start - Botium plugin failed: ${util__default[
|
|
9085
|
+
return Promise.reject(new Error(`Start - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
8918
9086
|
}
|
|
8919
9087
|
}
|
|
8920
9088
|
|
|
8921
9089
|
UserSaysImpl(mockMsg) {
|
|
8922
9090
|
try {
|
|
8923
|
-
return promiseRetry__default[
|
|
9091
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
8924
9092
|
return (this.pluginInstance.UserSays(mockMsg) || Promise.resolve()).catch(err => {
|
|
8925
9093
|
if (this.retryHelperUserSays.shouldRetry(err)) {
|
|
8926
9094
|
debug$2(`UserSays trial #${number} failed, retry activated`);
|
|
@@ -8934,7 +9102,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8934
9102
|
return this;
|
|
8935
9103
|
});
|
|
8936
9104
|
} catch (err) {
|
|
8937
|
-
return Promise.reject(new Error(`UserSays - Botium plugin failed: ${util__default[
|
|
9105
|
+
return Promise.reject(new Error(`UserSays - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
8938
9106
|
}
|
|
8939
9107
|
}
|
|
8940
9108
|
|
|
@@ -8942,7 +9110,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8942
9110
|
this.eventEmitter.emit(Events.CONTAINER_STOPPING, this);
|
|
8943
9111
|
|
|
8944
9112
|
try {
|
|
8945
|
-
return super.Stop().then(() => promiseRetry__default[
|
|
9113
|
+
return super.Stop().then(() => promiseRetry__default["default"]((retry, number) => {
|
|
8946
9114
|
return (this.pluginInstance.Stop ? this.pluginInstance.Stop() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8947
9115
|
if (this.retryHelperStop.shouldRetry(err)) {
|
|
8948
9116
|
debug$2(`Stop trial #${number} failed, retry activated`);
|
|
@@ -8960,7 +9128,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8960
9128
|
});
|
|
8961
9129
|
} catch (err) {
|
|
8962
9130
|
this.eventEmitter.emit(Events.CONTAINER_STOP_ERROR, this, err);
|
|
8963
|
-
return Promise.reject(new Error(`Stop - Botium plugin failed: ${util__default[
|
|
9131
|
+
return Promise.reject(new Error(`Stop - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
8964
9132
|
}
|
|
8965
9133
|
}
|
|
8966
9134
|
|
|
@@ -8968,7 +9136,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8968
9136
|
this.eventEmitter.emit(Events.CONTAINER_CLEANING, this);
|
|
8969
9137
|
|
|
8970
9138
|
try {
|
|
8971
|
-
return promiseRetry__default[
|
|
9139
|
+
return promiseRetry__default["default"]((retry, number) => {
|
|
8972
9140
|
return (this.pluginInstance.Clean ? this.pluginInstance.Clean() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8973
9141
|
if (this.retryHelperClean.shouldRetry(err)) {
|
|
8974
9142
|
debug$2(`Clean trial #${number} failed, retry activated`);
|
|
@@ -8986,7 +9154,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8986
9154
|
});
|
|
8987
9155
|
} catch (err) {
|
|
8988
9156
|
this.eventEmitter.emit(Events.CONTAINER_CLEAN_ERROR, this, err);
|
|
8989
|
-
return Promise.reject(new Error(`Clean - Botium plugin failed: ${util__default[
|
|
9157
|
+
return Promise.reject(new Error(`Clean - Botium plugin failed: ${util__default["default"].inspect(err)}`));
|
|
8990
9158
|
}
|
|
8991
9159
|
}
|
|
8992
9160
|
|
|
@@ -8996,17 +9164,17 @@ var require$$2 = getCjsExportFromNamespace(_package$1);
|
|
|
8996
9164
|
|
|
8997
9165
|
const {
|
|
8998
9166
|
boolean
|
|
8999
|
-
} = boolean__default[
|
|
9000
|
-
const debug$1 = debug__default[
|
|
9167
|
+
} = boolean__default["default"];
|
|
9168
|
+
const debug$1 = debug__default["default"]('botium-core-BotDriver');
|
|
9001
9169
|
const {
|
|
9002
9170
|
version
|
|
9003
9171
|
} = require$$2;
|
|
9004
9172
|
var BotDriver_1 = class BotDriver {
|
|
9005
9173
|
constructor(caps = {}, sources = {}, envs = {}) {
|
|
9006
|
-
this.eventEmitter = new events__default[
|
|
9007
|
-
this.caps = lodash__default[
|
|
9008
|
-
this.sources = lodash__default[
|
|
9009
|
-
this.envs = lodash__default[
|
|
9174
|
+
this.eventEmitter = new events__default["default"]();
|
|
9175
|
+
this.caps = lodash__default["default"].cloneDeep(Defaults$1.Capabilities);
|
|
9176
|
+
this.sources = lodash__default["default"].cloneDeep(Defaults$1.Sources);
|
|
9177
|
+
this.envs = lodash__default["default"].cloneDeep(Defaults$1.Envs);
|
|
9010
9178
|
this._fetchedConfigFiles = [];
|
|
9011
9179
|
|
|
9012
9180
|
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`]);
|
|
@@ -9014,10 +9182,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9014
9182
|
const botiumConfigEnv = process.env.BOTIUM_CONFIG;
|
|
9015
9183
|
|
|
9016
9184
|
if (botiumConfigEnv) {
|
|
9017
|
-
const checkDir = path__default[
|
|
9018
|
-
const checkFileBase = path__default[
|
|
9185
|
+
const checkDir = path__default["default"].dirname(botiumConfigEnv);
|
|
9186
|
+
const checkFileBase = path__default["default"].basename(botiumConfigEnv, '.json');
|
|
9019
9187
|
|
|
9020
|
-
if (!this._fetchConfigFromFiles([botiumConfigEnv, process.env.NODE_ENV && path__default[
|
|
9188
|
+
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`)])) {
|
|
9021
9189
|
throw new Error(`FAILED: Botium configuration file ${botiumConfigEnv} not available`);
|
|
9022
9190
|
}
|
|
9023
9191
|
}
|
|
@@ -9044,7 +9212,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9044
9212
|
});
|
|
9045
9213
|
if (caps) this._mergeCaps(this.caps, caps);
|
|
9046
9214
|
if (sources) this._mergeCaps(this.sources, sources);
|
|
9047
|
-
if (envs) this.envs = lodash__default[
|
|
9215
|
+
if (envs) this.envs = lodash__default["default"].merge(this.envs, envs);
|
|
9048
9216
|
}
|
|
9049
9217
|
|
|
9050
9218
|
on(event, listener) {
|
|
@@ -9081,7 +9249,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9081
9249
|
}
|
|
9082
9250
|
|
|
9083
9251
|
setEnvs(envs) {
|
|
9084
|
-
this.envs = lodash__default[
|
|
9252
|
+
this.envs = lodash__default["default"].merge(this.envs, envs);
|
|
9085
9253
|
return this;
|
|
9086
9254
|
}
|
|
9087
9255
|
|
|
@@ -9097,14 +9265,14 @@ var BotDriver_1 = class BotDriver {
|
|
|
9097
9265
|
|
|
9098
9266
|
Build() {
|
|
9099
9267
|
debug$1(`Build - Botium Core Version: ${version}`);
|
|
9100
|
-
debug$1(`Build - Capabilites: ${util__default[
|
|
9101
|
-
debug$1(`Build - Sources : ${util__default[
|
|
9102
|
-
debug$1(`Build - Envs : ${util__default[
|
|
9268
|
+
debug$1(`Build - Capabilites: ${util__default["default"].inspect(this.caps)}`);
|
|
9269
|
+
debug$1(`Build - Sources : ${util__default["default"].inspect(this.sources)}`);
|
|
9270
|
+
debug$1(`Build - Envs : ${util__default["default"].inspect(this.envs)}`);
|
|
9103
9271
|
this.eventEmitter.emit(Events.CONTAINER_BUILDING);
|
|
9104
9272
|
return new Promise((resolve, reject) => {
|
|
9105
9273
|
let repo = null;
|
|
9106
9274
|
let container = null;
|
|
9107
|
-
async__default[
|
|
9275
|
+
async__default["default"].series([driverValidated => {
|
|
9108
9276
|
this._validate().then(() => driverValidated()).catch(driverValidated);
|
|
9109
9277
|
}, repoValidated => {
|
|
9110
9278
|
try {
|
|
@@ -9132,8 +9300,8 @@ var BotDriver_1 = class BotDriver {
|
|
|
9132
9300
|
this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
|
|
9133
9301
|
|
|
9134
9302
|
if (this.tempDirectory) {
|
|
9135
|
-
rimraf__default[
|
|
9136
|
-
if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default[
|
|
9303
|
+
rimraf__default["default"](this.tempDirectory, err => {
|
|
9304
|
+
if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default["default"].inspect(err)}`);
|
|
9137
9305
|
});
|
|
9138
9306
|
}
|
|
9139
9307
|
|
|
@@ -9162,7 +9330,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9162
9330
|
|
|
9163
9331
|
_loadConfigFile(filename) {
|
|
9164
9332
|
try {
|
|
9165
|
-
const configJson = JSON.parse(fs__default[
|
|
9333
|
+
const configJson = JSON.parse(fs__default["default"].readFileSync(filename));
|
|
9166
9334
|
|
|
9167
9335
|
if (configJson.botium) {
|
|
9168
9336
|
if (configJson.botium.Capabilities) this._mergeCaps(this.caps, configJson.botium.Capabilities);
|
|
@@ -9174,7 +9342,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9174
9342
|
return false;
|
|
9175
9343
|
}
|
|
9176
9344
|
} catch (err) {
|
|
9177
|
-
throw new Error(`FAILED: loading Botium configuration file ${filename}: ${util__default[
|
|
9345
|
+
throw new Error(`FAILED: loading Botium configuration file ${filename}: ${util__default["default"].inspect(err)}`);
|
|
9178
9346
|
}
|
|
9179
9347
|
} // fetches config from files ordered by priority later files overwrite previous
|
|
9180
9348
|
|
|
@@ -9183,8 +9351,8 @@ var BotDriver_1 = class BotDriver {
|
|
|
9183
9351
|
const fetchedFiles = [];
|
|
9184
9352
|
|
|
9185
9353
|
for (const file of files) {
|
|
9186
|
-
if (file && fs__default[
|
|
9187
|
-
const absFilePath = path__default[
|
|
9354
|
+
if (file && fs__default["default"].existsSync(file)) {
|
|
9355
|
+
const absFilePath = path__default["default"].resolve(file);
|
|
9188
9356
|
|
|
9189
9357
|
if (this._fetchedConfigFiles.indexOf(absFilePath) < 0) {
|
|
9190
9358
|
this._loadConfigFile(file);
|
|
@@ -9213,11 +9381,11 @@ var BotDriver_1 = class BotDriver {
|
|
|
9213
9381
|
if (!caps) return;
|
|
9214
9382
|
Object.keys(newCaps).forEach(capKey => {
|
|
9215
9383
|
if (!Object.prototype.hasOwnProperty.call(caps, capKey)) {
|
|
9216
|
-
if (lodash__default[
|
|
9384
|
+
if (lodash__default["default"].isString(newCaps[capKey])) {
|
|
9217
9385
|
try {
|
|
9218
9386
|
caps[capKey] = JSON.parse(newCaps[capKey]);
|
|
9219
9387
|
|
|
9220
|
-
if (lodash__default[
|
|
9388
|
+
if (lodash__default["default"].isFinite(caps[capKey])) {
|
|
9221
9389
|
caps[capKey] = caps[capKey].toString();
|
|
9222
9390
|
}
|
|
9223
9391
|
} catch (err) {
|
|
@@ -9230,10 +9398,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9230
9398
|
return;
|
|
9231
9399
|
}
|
|
9232
9400
|
|
|
9233
|
-
if (lodash__default[
|
|
9401
|
+
if (lodash__default["default"].isArray(caps[capKey])) {
|
|
9234
9402
|
let newCapArray = newCaps[capKey];
|
|
9235
9403
|
|
|
9236
|
-
if (!lodash__default[
|
|
9404
|
+
if (!lodash__default["default"].isArray(newCapArray)) {
|
|
9237
9405
|
try {
|
|
9238
9406
|
newCapArray = JSON.parse(newCapArray);
|
|
9239
9407
|
} catch (err) {
|
|
@@ -9241,7 +9409,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9241
9409
|
}
|
|
9242
9410
|
}
|
|
9243
9411
|
|
|
9244
|
-
if (lodash__default[
|
|
9412
|
+
if (lodash__default["default"].isArray(newCapArray)) {
|
|
9245
9413
|
newCapArray.forEach(capElement => {
|
|
9246
9414
|
const mergeKey = this._findKeyProperty(capElement);
|
|
9247
9415
|
|
|
@@ -9249,7 +9417,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9249
9417
|
const oldElement = caps[capKey].find(oldElement => oldElement[mergeKey] && oldElement[mergeKey] === capElement[mergeKey]);
|
|
9250
9418
|
|
|
9251
9419
|
if (oldElement) {
|
|
9252
|
-
lodash__default[
|
|
9420
|
+
lodash__default["default"].merge(oldElement, capElement);
|
|
9253
9421
|
|
|
9254
9422
|
return;
|
|
9255
9423
|
}
|
|
@@ -9265,10 +9433,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9265
9433
|
}
|
|
9266
9434
|
}
|
|
9267
9435
|
|
|
9268
|
-
if (!lodash__default[
|
|
9436
|
+
if (!lodash__default["default"].isArray(caps[capKey]) && lodash__default["default"].isObject(caps[capKey])) {
|
|
9269
9437
|
let newCapObject = newCaps[capKey];
|
|
9270
9438
|
|
|
9271
|
-
if (!lodash__default[
|
|
9439
|
+
if (!lodash__default["default"].isObject(newCapObject)) {
|
|
9272
9440
|
try {
|
|
9273
9441
|
newCapObject = JSON.parse(newCapObject);
|
|
9274
9442
|
} catch (err) {
|
|
@@ -9276,15 +9444,15 @@ var BotDriver_1 = class BotDriver {
|
|
|
9276
9444
|
}
|
|
9277
9445
|
}
|
|
9278
9446
|
|
|
9279
|
-
if (lodash__default[
|
|
9280
|
-
lodash__default[
|
|
9447
|
+
if (lodash__default["default"].isObject(newCapObject)) {
|
|
9448
|
+
lodash__default["default"].merge(caps[capKey], newCapObject);
|
|
9281
9449
|
|
|
9282
9450
|
return;
|
|
9283
9451
|
}
|
|
9284
9452
|
}
|
|
9285
9453
|
|
|
9286
|
-
if (lodash__default[
|
|
9287
|
-
if (!lodash__default[
|
|
9454
|
+
if (lodash__default["default"].isBoolean(caps[capKey])) {
|
|
9455
|
+
if (!lodash__default["default"].isBoolean(newCaps[capKey])) {
|
|
9288
9456
|
caps[capKey] = boolean(newCaps[capKey]);
|
|
9289
9457
|
return;
|
|
9290
9458
|
}
|
|
@@ -9309,10 +9477,10 @@ var BotDriver_1 = class BotDriver {
|
|
|
9309
9477
|
throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
|
|
9310
9478
|
}
|
|
9311
9479
|
|
|
9312
|
-
this.tempDirectory = path__default[
|
|
9480
|
+
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)}`));
|
|
9313
9481
|
|
|
9314
9482
|
try {
|
|
9315
|
-
mkdirp__default[
|
|
9483
|
+
mkdirp__default["default"].sync(this.tempDirectory);
|
|
9316
9484
|
} catch (err) {
|
|
9317
9485
|
throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
|
|
9318
9486
|
}
|
|
@@ -9340,7 +9508,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9340
9508
|
return new LocalRepo(this.tempDirectory, this.sources);
|
|
9341
9509
|
}
|
|
9342
9510
|
|
|
9343
|
-
throw new Error(`No Repo provider found for Sources ${util__default[
|
|
9511
|
+
throw new Error(`No Repo provider found for Sources ${util__default["default"].inspect(this.sources)}`);
|
|
9344
9512
|
}
|
|
9345
9513
|
|
|
9346
9514
|
_getContainer(repo) {
|
|
@@ -9364,7 +9532,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9364
9532
|
|
|
9365
9533
|
};
|
|
9366
9534
|
|
|
9367
|
-
const debug = debug__default[
|
|
9535
|
+
const debug = debug__default["default"]('botium-core-Plugins');
|
|
9368
9536
|
const PLUGIN_TYPE_CONNECTOR = 'PLUGIN_TYPE_CONNECTOR';
|
|
9369
9537
|
const PLUGIN_TYPE_ASSERTER = 'PLUGIN_TYPE_ASSERTER';
|
|
9370
9538
|
const PLUGIN_TYPE_LOGICHOOK = 'PLUGIN_TYPE_LOGICHOOK';
|
|
@@ -9392,7 +9560,7 @@ const getConnectorPlugin = (filename, pathToRes) => {
|
|
|
9392
9560
|
const pluginPath = commonjsRequire.resolve(filename);
|
|
9393
9561
|
|
|
9394
9562
|
if (!pluginPath.startsWith(pathToRes)) {
|
|
9395
|
-
debug(`Plugin mismatch error. Plugin ${path__default[
|
|
9563
|
+
debug(`Plugin mismatch error. Plugin ${path__default["default"].resolve(pathToRes, filename)} loaded from ${pluginPath}! `);
|
|
9396
9564
|
return null;
|
|
9397
9565
|
}
|
|
9398
9566
|
|
|
@@ -9444,7 +9612,7 @@ const getOtherPlugin = (filename, pathToRes, type) => {
|
|
|
9444
9612
|
const pluginPath = commonjsRequire.resolve(filename);
|
|
9445
9613
|
|
|
9446
9614
|
if (!pluginPath.startsWith(pathToRes)) {
|
|
9447
|
-
debug(`Plugin mismatch error. Plugin ${path__default[
|
|
9615
|
+
debug(`Plugin mismatch error. Plugin ${path__default["default"].resolve(pathToRes, filename)} loaded from ${pluginPath}! `);
|
|
9448
9616
|
return null;
|
|
9449
9617
|
}
|
|
9450
9618
|
|
|
@@ -9491,9 +9659,9 @@ const getPlugins = async (type, resourcesDir) => {
|
|
|
9491
9659
|
return Promise.resolve([]);
|
|
9492
9660
|
}
|
|
9493
9661
|
|
|
9494
|
-
const pathToRes = path__default[
|
|
9662
|
+
const pathToRes = path__default["default"].resolve(resourcesDir);
|
|
9495
9663
|
|
|
9496
|
-
if (!fs__default[
|
|
9664
|
+
if (!fs__default["default"].existsSync(pathToRes)) {
|
|
9497
9665
|
debug(`Cant load plugins, directory ${pathToRes} does not exists`);
|
|
9498
9666
|
return [];
|
|
9499
9667
|
}
|
|
@@ -9501,7 +9669,7 @@ const getPlugins = async (type, resourcesDir) => {
|
|
|
9501
9669
|
let items;
|
|
9502
9670
|
|
|
9503
9671
|
try {
|
|
9504
|
-
items = fs__default[
|
|
9672
|
+
items = fs__default["default"].readdirSync(pathToRes).filter(item => path__default["default"].extname(item) === '.js' || item.indexOf('.') === -1);
|
|
9505
9673
|
} catch (err) {
|
|
9506
9674
|
debug(`Cant load plugins, failed to read directory ${pathToRes} - ${err.message}`);
|
|
9507
9675
|
return [];
|
|
@@ -9592,5 +9760,5 @@ exports.ScriptingConstants = botiumCore_3;
|
|
|
9592
9760
|
exports.ScriptingMemory = botiumCore_10;
|
|
9593
9761
|
exports.ScriptingProvider = botiumCore_2;
|
|
9594
9762
|
exports.Source = botiumCore_6;
|
|
9595
|
-
exports[
|
|
9763
|
+
exports["default"] = botiumCore;
|
|
9596
9764
|
//# sourceMappingURL=botium-cjs.js.map
|