botium-core 1.12.5 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botium-cjs.js +277 -171
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +296 -190
- package/dist/botium-es.js.map +1 -1
- package/package.json +24 -24
- package/src/Capabilities.js +7 -0
- package/src/helpers/RetryHelper.js +13 -7
- package/src/scripting/CompilerCsv.js +150 -102
- package/src/scripting/Convo.js +21 -1
- package/src/scripting/ScriptingProvider.js +5 -1
- package/src/scripting/helper.js +19 -12
- package/src/scripting/logichook/LogicHookUtils.js +1 -1
- package/src/scripting/logichook/asserter/ButtonsAsserter.js +4 -2
- package/src/scripting/logichook/asserter/CardsAsserter.js +4 -2
- package/test/compiler/compilercsv.spec.js +363 -12
- package/test/compiler/compilertxt.spec.js +13 -0
- package/test/compiler/convos/csv/utterances_liveperson.csv +108 -0
- package/test/compiler/convos/csv/utterances_multicolumn3col.csv +3 -0
- package/test/compiler/convos/csv/utterances_multicolumn5col.csv +3 -0
- package/test/compiler/convos/csv/utterances_singlecolumn.csv +3 -0
- package/test/compiler/convos/csv/utterances_variable_row_len.csv +3 -0
- package/test/compiler/convos/txt/convos_args_escape.convo.txt +2 -0
- package/test/convo/convos/continuefailing_timeout.convo.txt +16 -0
- package/test/convo/retryconvo.spec.js +134 -0
- package/test/convo/transcript.spec.js +18 -1
- package/test/logichooks/hookfromsrc.spec.js +1 -1
- package/test/scripting/asserters/buttonsAsserter.spec.js +47 -0
- package/test/scripting/asserters/cardsAsserter.spec.js +39 -0
- package/test/scripting/txt/decompile.spec.js +24 -0
package/dist/botium-es.js
CHANGED
|
@@ -10,7 +10,7 @@ import randomatic from 'randomatic';
|
|
|
10
10
|
import lodash from 'lodash';
|
|
11
11
|
import boolean$1 from 'boolean';
|
|
12
12
|
import events from 'events';
|
|
13
|
-
import debug$
|
|
13
|
+
import debug$m from 'debug';
|
|
14
14
|
import vm2 from 'vm2';
|
|
15
15
|
import isClass from 'is-class';
|
|
16
16
|
import crypto from 'crypto';
|
|
@@ -36,7 +36,7 @@ import express from 'express';
|
|
|
36
36
|
import bodyParser from 'body-parser';
|
|
37
37
|
|
|
38
38
|
var name = "botium-core";
|
|
39
|
-
var version$1 = "1.
|
|
39
|
+
var version$1 = "1.13.1";
|
|
40
40
|
var description = "The Selenium for Chatbots";
|
|
41
41
|
var main = "index.js";
|
|
42
42
|
var module = "dist/botium-es.js";
|
|
@@ -68,25 +68,25 @@ var bugs = {
|
|
|
68
68
|
};
|
|
69
69
|
var homepage = "https://www.botium.ai";
|
|
70
70
|
var dependencies = {
|
|
71
|
-
"@babel/runtime": "^7.
|
|
72
|
-
async: "^3.2.
|
|
71
|
+
"@babel/runtime": "^7.18.6",
|
|
72
|
+
async: "^3.2.4",
|
|
73
73
|
"body-parser": "^1.20.0",
|
|
74
74
|
boolean: "^3.2.0",
|
|
75
75
|
bottleneck: "^2.19.5",
|
|
76
|
-
"csv-parse": "^5.0
|
|
76
|
+
"csv-parse": "^5.3.0",
|
|
77
77
|
debug: "^4.3.4",
|
|
78
78
|
esprima: "^4.0.1",
|
|
79
|
-
express: "^4.
|
|
79
|
+
express: "^4.18.1",
|
|
80
80
|
globby: "11.0.4",
|
|
81
|
-
ioredis: "^5.0
|
|
81
|
+
ioredis: "^5.1.0",
|
|
82
82
|
"is-class": "^0.0.9",
|
|
83
83
|
"is-json": "^2.0.1",
|
|
84
84
|
jsonpath: "^1.1.1",
|
|
85
85
|
lodash: "^4.17.21",
|
|
86
|
-
"markdown-it": "^
|
|
86
|
+
"markdown-it": "^13.0.1",
|
|
87
87
|
"mime-types": "^2.1.35",
|
|
88
88
|
mkdirp: "^1.0.4",
|
|
89
|
-
moment: "^2.29.
|
|
89
|
+
moment: "^2.29.4",
|
|
90
90
|
mustache: "^4.2.0",
|
|
91
91
|
"promise-retry": "^2.0.1",
|
|
92
92
|
"promise.allsettled": "^1.0.5",
|
|
@@ -95,39 +95,39 @@ var dependencies = {
|
|
|
95
95
|
rimraf: "^3.0.2",
|
|
96
96
|
"sanitize-filename": "^1.6.3",
|
|
97
97
|
slugify: "^1.6.5",
|
|
98
|
-
"socket.io": "^4.
|
|
99
|
-
"socket.io-client": "^4.
|
|
98
|
+
"socket.io": "^4.5.1",
|
|
99
|
+
"socket.io-client": "^4.5.1",
|
|
100
100
|
"socketio-auth": "^0.1.1",
|
|
101
101
|
"swagger-jsdoc": "^6.2.1",
|
|
102
|
-
"swagger-ui-express": "^4.
|
|
102
|
+
"swagger-ui-express": "^4.4.0",
|
|
103
103
|
uuid: "^8.3.2",
|
|
104
|
-
vm2: "^3.9.
|
|
104
|
+
vm2: "^3.9.10",
|
|
105
105
|
"write-yaml": "^1.0.0",
|
|
106
106
|
xlsx: "^0.18.5",
|
|
107
|
-
xregexp: "^5.1.
|
|
108
|
-
yaml: "^2.
|
|
107
|
+
xregexp: "^5.1.1",
|
|
108
|
+
yaml: "^2.1.1"
|
|
109
109
|
};
|
|
110
110
|
var devDependencies = {
|
|
111
|
-
"@babel/core": "^7.
|
|
112
|
-
"@babel/node": "^7.
|
|
113
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
114
|
-
"@babel/preset-env": "^7.
|
|
111
|
+
"@babel/core": "^7.18.6",
|
|
112
|
+
"@babel/node": "^7.18.6",
|
|
113
|
+
"@babel/plugin-transform-runtime": "^7.18.6",
|
|
114
|
+
"@babel/preset-env": "^7.18.6",
|
|
115
115
|
chai: "^4.3.6",
|
|
116
116
|
"chai-as-promised": "^7.1.1",
|
|
117
117
|
"cross-env": "^7.0.3",
|
|
118
|
-
eslint: "^8.
|
|
118
|
+
eslint: "^8.19.0",
|
|
119
119
|
"eslint-config-standard": "^17.0.0",
|
|
120
120
|
"eslint-plugin-import": "^2.26.0",
|
|
121
|
-
"eslint-plugin-n": "^15.
|
|
121
|
+
"eslint-plugin-n": "^15.2.4",
|
|
122
122
|
"eslint-plugin-promise": "^6.0.0",
|
|
123
123
|
"eslint-plugin-standard": "^4.1.0",
|
|
124
124
|
"license-checker": "^25.0.1",
|
|
125
125
|
"license-compatibility-checker": "^0.3.5",
|
|
126
|
-
mocha: "^
|
|
127
|
-
nock: "^13.2.
|
|
128
|
-
"npm-check-updates": "^
|
|
126
|
+
mocha: "^10.0.0",
|
|
127
|
+
nock: "^13.2.8",
|
|
128
|
+
"npm-check-updates": "^15.2.6",
|
|
129
129
|
nyc: "^15.1.0",
|
|
130
|
-
rollup: "^2.
|
|
130
|
+
rollup: "^2.76.0",
|
|
131
131
|
"rollup-plugin-babel": "^4.4.0",
|
|
132
132
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
133
133
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -276,6 +276,10 @@ var Capabilities = {
|
|
|
276
276
|
SCRIPTING_XLSX_SHEETNAMES_PCONVOS: 'SCRIPTING_XLSX_SHEETNAMES_PCONVOS',
|
|
277
277
|
SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'SCRIPTING_XLSX_SHEETNAMES_UTTERANCES',
|
|
278
278
|
SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY: 'SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY',
|
|
279
|
+
// hidden capability. All newly in Box created testsets will have this as true. CsvCompiler
|
|
280
|
+
// - throws less error (Box reads csv files as utterances, and convo. Compiler cant throw exception if a file is correct, but box tries to load it with incorrect script type)
|
|
281
|
+
// 4 or more colums are compiled just as utterances.
|
|
282
|
+
SCRIPTING_CSV_LEGACY_MODE_OFF: 'SCRIPTING_CSV_LEGACY_MODE_OFF',
|
|
279
283
|
SCRIPTING_CSV_DELIMITER: 'SCRIPTING_CSV_DELIMITER',
|
|
280
284
|
SCRIPTING_CSV_SKIP_HEADER: 'SCRIPTING_CSV_SKIP_HEADER',
|
|
281
285
|
SCRIPTING_CSV_QUOTE: 'SCRIPTING_CSV_QUOTE',
|
|
@@ -285,6 +289,9 @@ var Capabilities = {
|
|
|
285
289
|
SCRIPTING_CSV_MULTIROW_COLUMN_TEXT: 'SCRIPTING_CSV_MULTIROW_COLUMN_TEXT',
|
|
286
290
|
SCRIPTING_CSV_QA_COLUMN_QUESTION: 'SCRIPTING_CSV_QA_COLUMN_QUESTION',
|
|
287
291
|
SCRIPTING_CSV_QA_COLUMN_ANSWER: 'SCRIPTING_CSV_QA_COLUMN_ANSWER',
|
|
292
|
+
SCRIPTING_CSV_UTTERANCE_STARTROW: 'SCRIPTING_CSV_UTTERANCE_STARTROW',
|
|
293
|
+
SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER: 'SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER',
|
|
294
|
+
SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY: 'SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY',
|
|
288
295
|
SCRIPTING_NORMALIZE_TEXT: 'SCRIPTING_NORMALIZE_TEXT',
|
|
289
296
|
SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
|
|
290
297
|
SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
|
|
@@ -426,6 +433,7 @@ Capabilities.SCRIPTING_XLSX_SHEETNAMES;
|
|
|
426
433
|
Capabilities.SCRIPTING_XLSX_SHEETNAMES_PCONVOS;
|
|
427
434
|
Capabilities.SCRIPTING_XLSX_SHEETNAMES_UTTERANCES;
|
|
428
435
|
Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY;
|
|
436
|
+
Capabilities.SCRIPTING_CSV_LEGACY_MODE_OFF;
|
|
429
437
|
Capabilities.SCRIPTING_CSV_DELIMITER;
|
|
430
438
|
Capabilities.SCRIPTING_CSV_SKIP_HEADER;
|
|
431
439
|
Capabilities.SCRIPTING_CSV_QUOTE;
|
|
@@ -435,6 +443,9 @@ Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER;
|
|
|
435
443
|
Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT;
|
|
436
444
|
Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION;
|
|
437
445
|
Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER;
|
|
446
|
+
Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW;
|
|
447
|
+
Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER;
|
|
448
|
+
Capabilities.SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY;
|
|
438
449
|
Capabilities.SCRIPTING_NORMALIZE_TEXT;
|
|
439
450
|
Capabilities.SCRIPTING_ENABLE_MEMORY;
|
|
440
451
|
Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS;
|
|
@@ -1177,7 +1188,7 @@ LogicHookConsts.DEFAULT_USER_INPUTS;
|
|
|
1177
1188
|
const {
|
|
1178
1189
|
NodeVM: NodeVM$2
|
|
1179
1190
|
} = vm2;
|
|
1180
|
-
const debug$
|
|
1191
|
+
const debug$l = debug$m('botium-core-asserterUtils');
|
|
1181
1192
|
const {
|
|
1182
1193
|
BotiumError: BotiumError$6
|
|
1183
1194
|
} = BotiumError_1;
|
|
@@ -1242,7 +1253,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1242
1253
|
_fetchAsserters() {
|
|
1243
1254
|
this.caps[Capabilities.ASSERTERS].forEach(asserter => {
|
|
1244
1255
|
if (this.asserters[asserter.ref]) {
|
|
1245
|
-
debug$
|
|
1256
|
+
debug$l(`${asserter.ref} asserter already exists, overwriting.`);
|
|
1246
1257
|
}
|
|
1247
1258
|
|
|
1248
1259
|
this.asserters[asserter.ref] = this._loadClass(asserter, 'asserter');
|
|
@@ -1256,7 +1267,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1256
1267
|
_fetchLogicHooks() {
|
|
1257
1268
|
this.caps[Capabilities.LOGIC_HOOKS].forEach(logicHook => {
|
|
1258
1269
|
if (this.logicHooks[logicHook.ref]) {
|
|
1259
|
-
debug$
|
|
1270
|
+
debug$l(`${logicHook.ref} logic hook already exists, overwriting.`);
|
|
1260
1271
|
}
|
|
1261
1272
|
|
|
1262
1273
|
this.logicHooks[logicHook.ref] = this._loadClass(logicHook, 'logichook');
|
|
@@ -1270,7 +1281,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1270
1281
|
_fetchUserInputs() {
|
|
1271
1282
|
this.caps[Capabilities.USER_INPUTS].forEach(userInput => {
|
|
1272
1283
|
if (this.userInputs[userInput.ref]) {
|
|
1273
|
-
debug$
|
|
1284
|
+
debug$l(`${userInput.ref} userinput already exists, overwriting.`);
|
|
1274
1285
|
}
|
|
1275
1286
|
|
|
1276
1287
|
this.userInputs[userInput.ref] = this._loadClass(userInput, 'userinput');
|
|
@@ -1413,7 +1424,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1413
1424
|
});
|
|
1414
1425
|
return vm.run(script);
|
|
1415
1426
|
} catch (err) {
|
|
1416
|
-
throw new Error(
|
|
1427
|
+
throw new Error(`Script ${key} is not valid - ${err.message || err}`);
|
|
1417
1428
|
}
|
|
1418
1429
|
} else {
|
|
1419
1430
|
throw new Error(`Script "${key}" is not valid - only functions and javascript code accepted`);
|
|
@@ -1504,7 +1515,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
|
|
|
1504
1515
|
}
|
|
1505
1516
|
}
|
|
1506
1517
|
|
|
1507
|
-
loadErr.forEach(debug$
|
|
1518
|
+
loadErr.forEach(debug$l);
|
|
1508
1519
|
}
|
|
1509
1520
|
|
|
1510
1521
|
throw new Error(`Failed to fetch ${ref} ${hookType}, no idea how to load ...`);
|
|
@@ -1820,6 +1831,14 @@ const flatString = str => {
|
|
|
1820
1831
|
return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
|
|
1821
1832
|
};
|
|
1822
1833
|
|
|
1834
|
+
const _formatAppendArgs = args => {
|
|
1835
|
+
return args ? ` ${args.map(a => lodash.isString(a) ? a.replace(/\|/g, '\\|') : `${a}`).join('|')}` : '';
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1838
|
+
const _parseArgs = str => {
|
|
1839
|
+
return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
|
|
1840
|
+
};
|
|
1841
|
+
|
|
1823
1842
|
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
1824
1843
|
if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
|
|
1825
1844
|
const convoStep = {
|
|
@@ -1861,7 +1880,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1861
1880
|
const name = logicLine.split(' ')[0];
|
|
1862
1881
|
|
|
1863
1882
|
if (sender !== 'me' && context.IsAsserterValid(name)) {
|
|
1864
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1883
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1865
1884
|
convoStep.asserters.push({
|
|
1866
1885
|
name,
|
|
1867
1886
|
args,
|
|
@@ -1869,14 +1888,14 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1869
1888
|
optional
|
|
1870
1889
|
});
|
|
1871
1890
|
} else if (sender === 'me' && context.IsUserInputValid(name)) {
|
|
1872
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1891
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1873
1892
|
convoStep.userInputs.push({
|
|
1874
1893
|
name,
|
|
1875
1894
|
args
|
|
1876
1895
|
});
|
|
1877
1896
|
textLinesAccepted = false;
|
|
1878
1897
|
} else if (context.IsLogicHookValid(name)) {
|
|
1879
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1898
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1880
1899
|
convoStep.logicHooks.push({
|
|
1881
1900
|
name,
|
|
1882
1901
|
args
|
|
@@ -2226,7 +2245,7 @@ const convoStepToLines$2 = step => {
|
|
|
2226
2245
|
|
|
2227
2246
|
if (step.sender === 'me') {
|
|
2228
2247
|
step.forms && step.forms.filter(form => form.value).forEach(form => {
|
|
2229
|
-
lines.push(`FORM
|
|
2248
|
+
lines.push(`FORM${_formatAppendArgs([form.name, form.value])}`);
|
|
2230
2249
|
});
|
|
2231
2250
|
|
|
2232
2251
|
if (step.buttons && step.buttons.length > 0) {
|
|
@@ -2238,18 +2257,18 @@ const convoStepToLines$2 = step => {
|
|
|
2238
2257
|
}
|
|
2239
2258
|
|
|
2240
2259
|
step.userInputs && step.userInputs.forEach(userInput => {
|
|
2241
|
-
lines.push(userInput.name + (userInput.args
|
|
2260
|
+
lines.push(userInput.name + _formatAppendArgs(userInput.args));
|
|
2242
2261
|
});
|
|
2243
2262
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2244
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2263
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2245
2264
|
});
|
|
2246
2265
|
} else {
|
|
2247
2266
|
if (step.messageText) {
|
|
2248
2267
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
|
|
2249
2268
|
}
|
|
2250
2269
|
|
|
2251
|
-
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS
|
|
2252
|
-
if (step.media && step.media.length > 0) lines.push('MEDIA
|
|
2270
|
+
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2271
|
+
if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)));
|
|
2253
2272
|
|
|
2254
2273
|
if (step.cards && step.cards.length > 0) {
|
|
2255
2274
|
step.cards.forEach(c => {
|
|
@@ -2257,17 +2276,17 @@ const convoStepToLines$2 = step => {
|
|
|
2257
2276
|
if (c.text) cardTexts = cardTexts.concat(lodash.isArray(c.text) ? c.text : [c.text]);
|
|
2258
2277
|
if (c.subtext) cardTexts = cardTexts.concat(lodash.isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2259
2278
|
if (c.content) cardTexts = cardTexts.concat(lodash.isArray(c.content) ? c.content : [c.content]);
|
|
2260
|
-
if (cardTexts.length > 0) lines.push('CARDS
|
|
2261
|
-
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS
|
|
2279
|
+
if (cardTexts.length > 0) lines.push('CARDS' + _formatAppendArgs(cardTexts.map(c => flatString(c))));
|
|
2280
|
+
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(c.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2262
2281
|
if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
|
|
2263
2282
|
});
|
|
2264
2283
|
}
|
|
2265
2284
|
|
|
2266
2285
|
step.asserters && step.asserters.forEach(asserter => {
|
|
2267
|
-
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + (asserter.args
|
|
2286
|
+
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + _formatAppendArgs(asserter.args));
|
|
2268
2287
|
});
|
|
2269
2288
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2270
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2289
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2271
2290
|
});
|
|
2272
2291
|
}
|
|
2273
2292
|
|
|
@@ -2355,7 +2374,7 @@ var helper = {
|
|
|
2355
2374
|
linesToScriptingMemories: linesToScriptingMemories$2
|
|
2356
2375
|
};
|
|
2357
2376
|
|
|
2358
|
-
const debug$
|
|
2377
|
+
const debug$k = debug$m('botium-core-ScriptingMemory');
|
|
2359
2378
|
const {
|
|
2360
2379
|
v1: uuidv1
|
|
2361
2380
|
} = uuid;
|
|
@@ -2613,7 +2632,7 @@ const extractVarNames = text => {
|
|
|
2613
2632
|
};
|
|
2614
2633
|
|
|
2615
2634
|
const fill = (container, scriptingMemory, result, utterance, scriptingEvents) => {
|
|
2616
|
-
debug$
|
|
2635
|
+
debug$k(`fill start: ${util.inspect(scriptingMemory)}`);
|
|
2617
2636
|
let varRegex;
|
|
2618
2637
|
|
|
2619
2638
|
switch (container.caps[Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]) {
|
|
@@ -2657,14 +2676,14 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
|
|
|
2657
2676
|
const varName = varMatches[i - 1];
|
|
2658
2677
|
|
|
2659
2678
|
if (RESERVED_WORDS.indexOf(varName) >= 0) {
|
|
2660
|
-
debug$
|
|
2679
|
+
debug$k(`fill Variable "${varName}" is not overwritten, because it is reserved word. `);
|
|
2661
2680
|
} else {
|
|
2662
2681
|
scriptingMemory[varName] = resultMatches[i];
|
|
2663
2682
|
}
|
|
2664
2683
|
}
|
|
2665
2684
|
}
|
|
2666
2685
|
});
|
|
2667
|
-
debug$
|
|
2686
|
+
debug$k(`fill end: ${util.inspect(scriptingMemory)}`);
|
|
2668
2687
|
}
|
|
2669
2688
|
};
|
|
2670
2689
|
|
|
@@ -2683,7 +2702,48 @@ ScriptingMemory.extractVarNames;
|
|
|
2683
2702
|
ScriptingMemory.RESERVED_WORDS;
|
|
2684
2703
|
ScriptingMemory.SCRIPTING_FUNCTIONS;
|
|
2685
2704
|
|
|
2686
|
-
const debug$
|
|
2705
|
+
const debug$j = debug$m('botium-core-RetryHelper');
|
|
2706
|
+
var RetryHelper_1 = class RetryHelper {
|
|
2707
|
+
constructor(caps, section, options = {}) {
|
|
2708
|
+
this.retryErrorPatterns = [];
|
|
2709
|
+
const onErrorRegexp = caps[`RETRY_${section.toUpperCase()}_ONERROR_REGEXP`] || [];
|
|
2710
|
+
|
|
2711
|
+
if (onErrorRegexp) {
|
|
2712
|
+
if (lodash.isArray(onErrorRegexp)) {
|
|
2713
|
+
onErrorRegexp.forEach(r => {
|
|
2714
|
+
if (lodash.isString(r)) this.retryErrorPatterns.push(new RegExp(r, 'i'));else this.retryErrorPatterns.push(r);
|
|
2715
|
+
});
|
|
2716
|
+
} else if (lodash.isString(onErrorRegexp)) {
|
|
2717
|
+
this.retryErrorPatterns.push(new RegExp(onErrorRegexp, 'i'));
|
|
2718
|
+
} else {
|
|
2719
|
+
this.retryErrorPatterns.push(onErrorRegexp);
|
|
2720
|
+
}
|
|
2721
|
+
} // to turn on retries, NUMRETRIES or ONERROR_REGEXP has to be set
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
this.retrySettings = {
|
|
2725
|
+
retries: caps[`RETRY_${section.toUpperCase()}_NUMRETRIES`] || (!lodash.isNil(options.numRetries) ? options.numRetries : this.retryErrorPatterns.length === 0 ? 0 : 1),
|
|
2726
|
+
factor: caps[`RETRY_${section.toUpperCase()}_FACTOR`] || (lodash.isNil(options.factor) ? 1 : options.factor),
|
|
2727
|
+
minTimeout: caps[`RETRY_${section.toUpperCase()}_MINTIMEOUT`] || (lodash.isNil(options.minTimeout) ? 1000 : options.minTimeout)
|
|
2728
|
+
};
|
|
2729
|
+
debug$j(`Retry for ${section} is ${this.retrySettings.retries > 0 ? 'enabled' : 'disabled'}. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`);
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
shouldRetry(err) {
|
|
2733
|
+
if (!err) return false;
|
|
2734
|
+
if (this.retryErrorPatterns.length === 0) return true;
|
|
2735
|
+
const errString = util.inspect(err);
|
|
2736
|
+
|
|
2737
|
+
for (const re of this.retryErrorPatterns) {
|
|
2738
|
+
if (errString.match(re)) return true;
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
return false;
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
};
|
|
2745
|
+
|
|
2746
|
+
const debug$i = debug$m('botium-core-Convo');
|
|
2687
2747
|
const {
|
|
2688
2748
|
BotiumError: BotiumError$4,
|
|
2689
2749
|
botiumErrorFromErr: botiumErrorFromErr$1,
|
|
@@ -2908,6 +2968,26 @@ class Convo$6 {
|
|
|
2908
2968
|
}
|
|
2909
2969
|
|
|
2910
2970
|
async Run(container) {
|
|
2971
|
+
const retryHelper = new RetryHelper_1(container.caps, 'CONVO');
|
|
2972
|
+
return promiseRetry(async (retry, number) => {
|
|
2973
|
+
return this.RunImpl(container).catch(err => {
|
|
2974
|
+
const retryRemaining = retryHelper.retrySettings.retries - number + 1;
|
|
2975
|
+
|
|
2976
|
+
if (retryHelper.shouldRetry(err)) {
|
|
2977
|
+
debug$i(`Convo failed with error "${err.message || JSON.stringify(err)}". Retry ${retryRemaining > 0 ? 'enabled' : 'disabled'} (remaining #${retryRemaining}/${retryHelper.retrySettings.retries}, criterion matches)`);
|
|
2978
|
+
retry(err);
|
|
2979
|
+
} else {
|
|
2980
|
+
if (retryHelper.retryErrorPatterns.length > 0) {
|
|
2981
|
+
debug$i(`Convo failed with error "${err.message || JSON.stringify(err)}". Retry 'disabled' (remaining (#${retryRemaining}/${retryHelper.retrySettings.retries}), criterion does not match)`);
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
throw err;
|
|
2985
|
+
}
|
|
2986
|
+
});
|
|
2987
|
+
}, retryHelper.retrySettings);
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
async RunImpl(container) {
|
|
2911
2991
|
const transcript = new Transcript({
|
|
2912
2992
|
steps: [],
|
|
2913
2993
|
attachments: [],
|
|
@@ -3393,7 +3473,7 @@ class Convo$6 {
|
|
|
3393
3473
|
const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
|
|
3394
3474
|
|
|
3395
3475
|
if (transcriptStepErrs && transcriptStepErrs.length > 0) {
|
|
3396
|
-
transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
|
|
3476
|
+
transcript.err = botiumErrorFromList$1([...transcriptStepErrs.filter(err => err !== transcript.err), transcript.err].filter(e => e), {});
|
|
3397
3477
|
}
|
|
3398
3478
|
}
|
|
3399
3479
|
}
|
|
@@ -3579,42 +3659,6 @@ var Convo_1 = {
|
|
|
3579
3659
|
ConvoStep: ConvoStep$1
|
|
3580
3660
|
};
|
|
3581
3661
|
|
|
3582
|
-
var RetryHelper_1 = class RetryHelper {
|
|
3583
|
-
constructor(caps, section) {
|
|
3584
|
-
this.retrySettings = {
|
|
3585
|
-
retries: caps[`RETRY_${section.toUpperCase()}_NUMRETRIES`] || 1,
|
|
3586
|
-
factor: caps[`RETRY_${section.toUpperCase()}_FACTOR`] || 1,
|
|
3587
|
-
minTimeout: caps[`RETRY_${section.toUpperCase()}_MINTIMEOUT`] || 1000
|
|
3588
|
-
};
|
|
3589
|
-
this.retryErrorPatterns = [];
|
|
3590
|
-
const onErrorRegexp = caps[`RETRY_${section.toUpperCase()}_ONERROR_REGEXP`] || [];
|
|
3591
|
-
|
|
3592
|
-
if (onErrorRegexp) {
|
|
3593
|
-
if (lodash.isArray(onErrorRegexp)) {
|
|
3594
|
-
onErrorRegexp.forEach(r => {
|
|
3595
|
-
if (lodash.isString(r)) this.retryErrorPatterns.push(new RegExp(r, 'i'));else this.retryErrorPatterns.push(r);
|
|
3596
|
-
});
|
|
3597
|
-
} else if (lodash.isString(onErrorRegexp)) {
|
|
3598
|
-
this.retryErrorPatterns.push(new RegExp(onErrorRegexp, 'i'));
|
|
3599
|
-
} else {
|
|
3600
|
-
this.retryErrorPatterns.push(onErrorRegexp);
|
|
3601
|
-
}
|
|
3602
|
-
}
|
|
3603
|
-
}
|
|
3604
|
-
|
|
3605
|
-
shouldRetry(err) {
|
|
3606
|
-
if (!err || this.retryErrorPatterns.length === 0) return false;
|
|
3607
|
-
const errString = util.inspect(err);
|
|
3608
|
-
|
|
3609
|
-
for (const re of this.retryErrorPatterns) {
|
|
3610
|
-
if (errString.match(re)) return true;
|
|
3611
|
-
}
|
|
3612
|
-
|
|
3613
|
-
return false;
|
|
3614
|
-
}
|
|
3615
|
-
|
|
3616
|
-
};
|
|
3617
|
-
|
|
3618
3662
|
const {
|
|
3619
3663
|
toString,
|
|
3620
3664
|
quoteRegexpString
|
|
@@ -3937,7 +3981,7 @@ var JsonToJson = {
|
|
|
3937
3981
|
const {
|
|
3938
3982
|
NodeVM
|
|
3939
3983
|
} = vm2;
|
|
3940
|
-
const debug$h = debug$
|
|
3984
|
+
const debug$h = debug$m('botium-core-HookUtils');
|
|
3941
3985
|
const {
|
|
3942
3986
|
BotiumError: BotiumError$3
|
|
3943
3987
|
} = BotiumError_1;
|
|
@@ -4087,7 +4131,7 @@ var Script = {
|
|
|
4087
4131
|
precompile: precompile$1
|
|
4088
4132
|
};
|
|
4089
4133
|
|
|
4090
|
-
const debug$g = debug$
|
|
4134
|
+
const debug$g = debug$m('botium-core-PrecompilerMarkdownRasa');
|
|
4091
4135
|
const htmlCommentRegexp = /(<!--.*?-->)/g;
|
|
4092
4136
|
|
|
4093
4137
|
var precompile = (caps, scriptBuffer, options, filename) => {
|
|
@@ -4203,7 +4247,7 @@ var MarkdownRasa = {
|
|
|
4203
4247
|
precompile: precompile
|
|
4204
4248
|
};
|
|
4205
4249
|
|
|
4206
|
-
const debug$f = debug$
|
|
4250
|
+
const debug$f = debug$m('botium-core-CapabilitiesUtils');
|
|
4207
4251
|
const {
|
|
4208
4252
|
toJsonWeak
|
|
4209
4253
|
} = Utils;
|
|
@@ -4315,7 +4359,7 @@ var CapabilitiesUtils = {
|
|
|
4315
4359
|
flatCababilities: flatCababilities$1
|
|
4316
4360
|
};
|
|
4317
4361
|
|
|
4318
|
-
const debug$e = debug$
|
|
4362
|
+
const debug$e = debug$m('botium-core-Precompilers');
|
|
4319
4363
|
const {
|
|
4320
4364
|
isJsonObject
|
|
4321
4365
|
} = Utils;
|
|
@@ -4465,7 +4509,7 @@ var Utterance_1 = class Utterance {
|
|
|
4465
4509
|
|
|
4466
4510
|
};
|
|
4467
4511
|
|
|
4468
|
-
const debug$d = debug$
|
|
4512
|
+
const debug$d = debug$m('botium-core-CompilerXlsx');
|
|
4469
4513
|
const {
|
|
4470
4514
|
E_SCRIPTING_MEMORY_COLUMN_MODE
|
|
4471
4515
|
} = Enums;
|
|
@@ -5238,7 +5282,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
5238
5282
|
const {
|
|
5239
5283
|
parse
|
|
5240
5284
|
} = sync;
|
|
5241
|
-
const debug$c = debug$
|
|
5285
|
+
const debug$c = debug$m('botium-core-CompilerCsv');
|
|
5242
5286
|
const {
|
|
5243
5287
|
Convo: Convo$3
|
|
5244
5288
|
} = Convo_1;
|
|
@@ -5287,6 +5331,8 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5287
5331
|
return [];
|
|
5288
5332
|
}
|
|
5289
5333
|
|
|
5334
|
+
const legacyModeOn = !this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_LEGACY_MODE_OFF, false);
|
|
5335
|
+
|
|
5290
5336
|
let delimiter = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_DELIMITER);
|
|
5291
5337
|
|
|
5292
5338
|
if (!delimiter) {
|
|
@@ -5314,7 +5360,8 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5314
5360
|
delimiter,
|
|
5315
5361
|
escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
|
|
5316
5362
|
quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
|
|
5317
|
-
columns: false
|
|
5363
|
+
columns: false,
|
|
5364
|
+
relax_column_count: true
|
|
5318
5365
|
});
|
|
5319
5366
|
} catch (err) {
|
|
5320
5367
|
throw new Error(`Invalid CSV: ${err.message || err}`);
|
|
@@ -5324,126 +5371,181 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
|
|
|
5324
5371
|
return [];
|
|
5325
5372
|
}
|
|
5326
5373
|
|
|
5327
|
-
|
|
5328
|
-
|
|
5374
|
+
const columnCount = rows[0].length;
|
|
5375
|
+
debug$c(`Legacy mode ${legacyModeOn ? 'on' : 'off'} rows ${rows.length} columns ${columnCount}`);
|
|
5329
5376
|
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
utterances: rows.slice(1).map(r => r[0])
|
|
5334
|
-
}];
|
|
5335
|
-
this.context.AddUtterances(result);
|
|
5336
|
-
return result;
|
|
5337
|
-
} else {
|
|
5377
|
+
if (scriptType === Constants.SCRIPTING_TYPE_CONVO || scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
5378
|
+
if (columnCount === 1 || !legacyModeOn && columnCount > 3) {
|
|
5379
|
+
debug$c(`Invalid column count '${columnCount}' in convo mode`);
|
|
5338
5380
|
return [];
|
|
5339
5381
|
}
|
|
5340
|
-
}
|
|
5341
5382
|
|
|
5342
|
-
|
|
5343
|
-
return [];
|
|
5344
|
-
}
|
|
5383
|
+
let header = null;
|
|
5345
5384
|
|
|
5346
|
-
|
|
5385
|
+
if (rows.length > 0 && this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER]) {
|
|
5386
|
+
header = rows[0];
|
|
5387
|
+
rows = rows.slice(1);
|
|
5388
|
+
}
|
|
5347
5389
|
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5390
|
+
if (rows.length === 0) {
|
|
5391
|
+
debug$c('Datarows not found in convo mode');
|
|
5392
|
+
return [];
|
|
5393
|
+
}
|
|
5352
5394
|
|
|
5353
|
-
|
|
5354
|
-
return [];
|
|
5355
|
-
}
|
|
5395
|
+
const lineNumberBase = this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER] ? 2 : 1;
|
|
5356
5396
|
|
|
5357
|
-
|
|
5397
|
+
if (columnCount === 2) {
|
|
5398
|
+
let colQuestion = DEFAULT_QA_COLUMN_QUESTION;
|
|
5399
|
+
let colAnswer = DEFAULT_QA_COLUMN_ANSWER;
|
|
5358
5400
|
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5401
|
+
if (header) {
|
|
5402
|
+
if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION] !== undefined) {
|
|
5403
|
+
colQuestion = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION]);
|
|
5404
|
+
}
|
|
5363
5405
|
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5406
|
+
if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER] !== undefined) {
|
|
5407
|
+
colAnswer = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER]);
|
|
5408
|
+
}
|
|
5367
5409
|
}
|
|
5368
5410
|
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5411
|
+
const convos = rows.map((row, i) => new Convo$3(this.context, {
|
|
5412
|
+
header: {
|
|
5413
|
+
name: `L${i + lineNumberBase}`
|
|
5414
|
+
},
|
|
5415
|
+
conversation: [Object.assign({}, linesToConvoStep$2([row[colQuestion]], 'me', this.context, undefined, true), {
|
|
5416
|
+
stepTag: `L${i + lineNumberBase}-Question`
|
|
5417
|
+
}), Object.assign({}, linesToConvoStep$2([row[colAnswer]], 'bot', this.context, undefined, true), {
|
|
5418
|
+
stepTag: `L${i + lineNumberBase}-Answer`
|
|
5419
|
+
})]
|
|
5420
|
+
}));
|
|
5373
5421
|
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
stepTag: `L${i + lineNumberBase}-Question`
|
|
5380
|
-
}), Object.assign({}, linesToConvoStep$2([row[colAnswer]], 'bot', this.context, undefined, true), {
|
|
5381
|
-
stepTag: `L${i + lineNumberBase}-Answer`
|
|
5382
|
-
})]
|
|
5383
|
-
}));
|
|
5422
|
+
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
5423
|
+
this.context.AddConvos(convos);
|
|
5424
|
+
} else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
5425
|
+
this.context.AddPartialConvos(convos);
|
|
5426
|
+
}
|
|
5384
5427
|
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
} else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
5388
|
-
this.context.AddPartialConvos(convos);
|
|
5428
|
+
debug$c(`Found 2-column CSV file, treating it as question/answer file, extracted ${convos.length} convos`);
|
|
5429
|
+
return convos;
|
|
5389
5430
|
}
|
|
5390
5431
|
|
|
5391
|
-
|
|
5392
|
-
|
|
5432
|
+
if (columnCount >= 3) {
|
|
5433
|
+
let colConversationId = DEFAULT_MULTIROW_COLUMN_CONVERSATION;
|
|
5434
|
+
let colSender = DEFAULT_MULTIROW_COLUMN_SENDER;
|
|
5435
|
+
let colText = DEFAULT_MULTIROW_COLUMN_TEXT;
|
|
5393
5436
|
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
let colText = DEFAULT_MULTIROW_COLUMN_TEXT;
|
|
5437
|
+
if (header) {
|
|
5438
|
+
if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID] !== undefined) {
|
|
5439
|
+
colConversationId = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID]);
|
|
5440
|
+
}
|
|
5399
5441
|
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
}
|
|
5442
|
+
if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER] !== undefined) {
|
|
5443
|
+
colSender = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER]);
|
|
5444
|
+
}
|
|
5404
5445
|
|
|
5405
|
-
|
|
5406
|
-
|
|
5446
|
+
if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT] !== undefined) {
|
|
5447
|
+
colText = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT]);
|
|
5448
|
+
}
|
|
5407
5449
|
}
|
|
5408
5450
|
|
|
5409
|
-
|
|
5410
|
-
|
|
5451
|
+
const conversationIds = lodash.uniq(rows.map(r => r[colConversationId]));
|
|
5452
|
+
|
|
5453
|
+
const convos = conversationIds.map(conversationId => {
|
|
5454
|
+
const convoRows = rows.map((row, i) => {
|
|
5455
|
+
if (row[colConversationId] === conversationId) {
|
|
5456
|
+
return Object.assign({}, linesToConvoStep$2([row[colText]], row[colSender], this.context, undefined, true), {
|
|
5457
|
+
stepTag: `L${i + lineNumberBase}`
|
|
5458
|
+
});
|
|
5459
|
+
}
|
|
5460
|
+
|
|
5461
|
+
return null;
|
|
5462
|
+
}).filter(c => c);
|
|
5463
|
+
return new Convo$3(this.context, {
|
|
5464
|
+
header: {
|
|
5465
|
+
name: conversationId
|
|
5466
|
+
},
|
|
5467
|
+
conversation: convoRows
|
|
5468
|
+
});
|
|
5469
|
+
});
|
|
5470
|
+
|
|
5471
|
+
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
5472
|
+
this.context.AddConvos(convos);
|
|
5473
|
+
} else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
5474
|
+
this.context.AddPartialConvos(convos);
|
|
5411
5475
|
}
|
|
5476
|
+
|
|
5477
|
+
debug$c(`Found 3-column CSV file, treating it as multi-row conversation file, extracted ${convos.length} convos`);
|
|
5478
|
+
return convos;
|
|
5479
|
+
}
|
|
5480
|
+
} else if (scriptType === Constants.SCRIPTING_TYPE_UTTERANCES) {
|
|
5481
|
+
if (columnCount === 2 || columnCount === 3 || legacyModeOn && columnCount > 4) {
|
|
5482
|
+
debug$c(`Invalid column count '${columnCount}' in utterances mode`);
|
|
5483
|
+
return [];
|
|
5412
5484
|
}
|
|
5413
5485
|
|
|
5414
|
-
const
|
|
5486
|
+
const result = [];
|
|
5487
|
+
const startRow = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW, 2) - 1;
|
|
5415
5488
|
|
|
5416
|
-
const
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5489
|
+
const startRowHeader = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER);
|
|
5490
|
+
|
|
5491
|
+
const stopOnEmpty = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY);
|
|
5492
|
+
|
|
5493
|
+
for (let col = 0; col < columnCount; col++) {
|
|
5494
|
+
const name = rows[0][col];
|
|
5495
|
+
|
|
5496
|
+
if (!name || name.trim().length === 0) {
|
|
5497
|
+
debug$c(`Column ${col + 1} has no header, skipping`);
|
|
5498
|
+
continue;
|
|
5499
|
+
}
|
|
5500
|
+
|
|
5501
|
+
const uttStruct = {
|
|
5502
|
+
name,
|
|
5503
|
+
utterances: []
|
|
5504
|
+
};
|
|
5505
|
+
let skip = !!startRowHeader;
|
|
5506
|
+
|
|
5507
|
+
const getData = row => {
|
|
5508
|
+
return rows[row][col] ? rows[row][col].trim() : false;
|
|
5509
|
+
}; //
|
|
5510
|
+
|
|
5511
|
+
|
|
5512
|
+
for (let row = startRow; row < rows.length && (skip || !stopOnEmpty || !!getData(row)); row++) {
|
|
5513
|
+
// eslint-disable-line no-unmodified-loop-condition
|
|
5514
|
+
const data = getData(row);
|
|
5515
|
+
|
|
5516
|
+
if (!data) {
|
|
5517
|
+
continue;
|
|
5422
5518
|
}
|
|
5423
5519
|
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
}
|
|
5432
|
-
});
|
|
5520
|
+
if (!skip) {
|
|
5521
|
+
uttStruct.utterances.push(data);
|
|
5522
|
+
} else {
|
|
5523
|
+
if (startRowHeader === rows[row][col]) {
|
|
5524
|
+
skip = false;
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5433
5528
|
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5529
|
+
if (uttStruct.utterances.length === 0) {
|
|
5530
|
+
// liveperson, skipping meta intents
|
|
5531
|
+
debug$c(`Column ${col + 1} has no utterances, skipping`);
|
|
5532
|
+
continue;
|
|
5533
|
+
}
|
|
5534
|
+
|
|
5535
|
+
result.push(uttStruct);
|
|
5438
5536
|
}
|
|
5439
5537
|
|
|
5440
|
-
|
|
5538
|
+
debug$c(`Multi-column utterance file, extracted ${result.length} utterances`);
|
|
5539
|
+
this.context.AddUtterances(result);
|
|
5540
|
+
return result;
|
|
5541
|
+
} else {
|
|
5542
|
+
return [];
|
|
5441
5543
|
}
|
|
5442
5544
|
}
|
|
5443
5545
|
|
|
5444
5546
|
};
|
|
5445
5547
|
|
|
5446
|
-
const debug$b = debug$
|
|
5548
|
+
const debug$b = debug$m('botium-core-CompilerObject');
|
|
5447
5549
|
const {
|
|
5448
5550
|
Convo: Convo$2
|
|
5449
5551
|
} = Convo_1;
|
|
@@ -5620,7 +5722,7 @@ var CompilerJson_1 = class CompilerJson extends CompilerObjectBase_1 {
|
|
|
5620
5722
|
|
|
5621
5723
|
};
|
|
5622
5724
|
|
|
5623
|
-
const debug$a = debug$
|
|
5725
|
+
const debug$a = debug$m('botium-core-CompilerMarkdown');
|
|
5624
5726
|
const md = new markdownIt();
|
|
5625
5727
|
const {
|
|
5626
5728
|
Convo: Convo$1
|
|
@@ -5751,7 +5853,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5751
5853
|
};
|
|
5752
5854
|
|
|
5753
5855
|
promise.shim();
|
|
5754
|
-
const debug$9 = debug$
|
|
5856
|
+
const debug$9 = debug$m('botium-core-ScriptingProvider');
|
|
5755
5857
|
const {
|
|
5756
5858
|
Convo,
|
|
5757
5859
|
ConvoStep
|
|
@@ -5764,7 +5866,7 @@ const {
|
|
|
5764
5866
|
const {
|
|
5765
5867
|
getMatchFunction
|
|
5766
5868
|
} = MatchFunctions;
|
|
5767
|
-
const globPattern = '**/+(*.convo.txt|*.utterances.txt|*.pconvo.txt|*.scriptingmemory.txt|*.xlsx|*.xlsm|*.convo.csv|*.pconvo.csv|*.yaml|*.yml|*.json|*.md|*.markdown)';
|
|
5869
|
+
const globPattern = '**/+(*.convo.txt|*.utterances.txt|*.pconvo.txt|*.scriptingmemory.txt|*.xlsx|*.xlsm|*.convo.csv|*.pconvo.csv|*.utterances.csv|*.yaml|*.yml|*.json|*.md|*.markdown)';
|
|
5768
5870
|
const skipPattern = /^skip[.\-_]/i;
|
|
5769
5871
|
|
|
5770
5872
|
const p = (retryHelper, fn) => {
|
|
@@ -6459,6 +6561,10 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6459
6561
|
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_CONVO);
|
|
6460
6562
|
} else if (filename.endsWith('.pconvo.csv')) {
|
|
6461
6563
|
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6564
|
+
} else if (filename.endsWith('.pconvo.csv')) {
|
|
6565
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
|
|
6566
|
+
} else if (filename.endsWith('.utterance.csv')) {
|
|
6567
|
+
result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_UTTERANCES);
|
|
6462
6568
|
} else if (filename.endsWith('.yaml') || filename.endsWith('.yml')) {
|
|
6463
6569
|
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]);
|
|
6464
6570
|
} else if (filename.endsWith('.json')) {
|
|
@@ -7317,7 +7423,7 @@ var NoRepo_1 = class NoRepo extends BaseRepo_1 {
|
|
|
7317
7423
|
};
|
|
7318
7424
|
|
|
7319
7425
|
var ProcessUtils = createCommonjsModule(function (module) {
|
|
7320
|
-
const debug = debug$
|
|
7426
|
+
const debug = debug$m('botium-core-ProcessUtils');
|
|
7321
7427
|
module.exports = {
|
|
7322
7428
|
childCommandLineRun: (cmd, ignoreErrors = false, processOptions = {}) => {
|
|
7323
7429
|
const cmdOptions = cmd.split(' ');
|
|
@@ -7369,7 +7475,7 @@ var ProcessUtils = createCommonjsModule(function (module) {
|
|
|
7369
7475
|
ProcessUtils.childCommandLineRun;
|
|
7370
7476
|
ProcessUtils.childProcessRun;
|
|
7371
7477
|
|
|
7372
|
-
const debug$8 = debug$
|
|
7478
|
+
const debug$8 = debug$m('botium-core-GitRepo');
|
|
7373
7479
|
var GitRepo_1 = class GitRepo extends BaseRepo_1 {
|
|
7374
7480
|
Validate() {
|
|
7375
7481
|
return super.Validate().then(() => {
|
|
@@ -7540,7 +7646,7 @@ var Queue_1 = class Queue {
|
|
|
7540
7646
|
|
|
7541
7647
|
};
|
|
7542
7648
|
|
|
7543
|
-
const debug$7 = debug$
|
|
7649
|
+
const debug$7 = debug$m('botium-connector-BaseContainer');
|
|
7544
7650
|
const {
|
|
7545
7651
|
executeHook: executeHook$1,
|
|
7546
7652
|
getHook: getHook$1
|
|
@@ -7771,7 +7877,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7771
7877
|
|
|
7772
7878
|
};
|
|
7773
7879
|
|
|
7774
|
-
const debug$6 = debug$
|
|
7880
|
+
const debug$6 = debug$m('botium-connector-GridContainer');
|
|
7775
7881
|
var GridContainer_1 = class GridContainer extends BaseContainer_1 {
|
|
7776
7882
|
Validate() {
|
|
7777
7883
|
return super.Validate().then(() => {
|
|
@@ -7995,7 +8101,7 @@ var InProcessContainer_1 = class InProcessContainer extends BaseContainer_1 {
|
|
|
7995
8101
|
|
|
7996
8102
|
};
|
|
7997
8103
|
|
|
7998
|
-
const debug$5 = debug$
|
|
8104
|
+
const debug$5 = debug$m('botium-core-inbound-proxy');
|
|
7999
8105
|
|
|
8000
8106
|
const buildRedisHandler = (redisurl, topic) => {
|
|
8001
8107
|
const redis = new ioredis(redisurl);
|
|
@@ -8078,7 +8184,7 @@ proxy.startProxy;
|
|
|
8078
8184
|
const {
|
|
8079
8185
|
v4: uuidv4
|
|
8080
8186
|
} = uuid;
|
|
8081
|
-
const debug$4 = debug$
|
|
8187
|
+
const debug$4 = debug$m('botium-connector-simplerest');
|
|
8082
8188
|
const {
|
|
8083
8189
|
startProxy
|
|
8084
8190
|
} = proxy;
|
|
@@ -9108,7 +9214,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
9108
9214
|
|
|
9109
9215
|
};
|
|
9110
9216
|
|
|
9111
|
-
const debug$3 = debug$
|
|
9217
|
+
const debug$3 = debug$m('botium-connector-PluginConnectorContainer-helper');
|
|
9112
9218
|
const {
|
|
9113
9219
|
BotiumError
|
|
9114
9220
|
} = BotiumError_1;
|
|
@@ -9277,7 +9383,7 @@ var plugins = {
|
|
|
9277
9383
|
tryLoadPlugin: tryLoadPlugin$1
|
|
9278
9384
|
};
|
|
9279
9385
|
|
|
9280
|
-
const debug$2 = debug$
|
|
9386
|
+
const debug$2 = debug$m('botium-connector-PluginConnectorContainer');
|
|
9281
9387
|
const {
|
|
9282
9388
|
tryLoadPlugin
|
|
9283
9389
|
} = plugins;
|
|
@@ -9435,7 +9541,7 @@ var require$$2 = getCjsExportFromNamespace(_package$1);
|
|
|
9435
9541
|
const {
|
|
9436
9542
|
boolean
|
|
9437
9543
|
} = boolean$1;
|
|
9438
|
-
const debug$1 = debug$
|
|
9544
|
+
const debug$1 = debug$m('botium-core-BotDriver');
|
|
9439
9545
|
const {
|
|
9440
9546
|
version
|
|
9441
9547
|
} = require$$2;
|
|
@@ -9804,7 +9910,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9804
9910
|
|
|
9805
9911
|
};
|
|
9806
9912
|
|
|
9807
|
-
const debug = debug$
|
|
9913
|
+
const debug = debug$m('botium-core-Plugins');
|
|
9808
9914
|
const PLUGIN_TYPE_CONNECTOR = 'PLUGIN_TYPE_CONNECTOR';
|
|
9809
9915
|
const PLUGIN_TYPE_ASSERTER = 'PLUGIN_TYPE_ASSERTER';
|
|
9810
9916
|
const PLUGIN_TYPE_LOGICHOOK = 'PLUGIN_TYPE_LOGICHOOK';
|