botium-core 1.14.5 → 1.14.7
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 +42 -45
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +42 -45
- package/dist/botium-es.js.map +1 -1
- package/package.json +18 -18
- package/src/Defaults.js +0 -1
- package/src/containers/PluginConnectorContainer.js +5 -5
- package/src/helpers/RetryHelper.js +3 -1
- package/src/scripting/CompilerMarkdown.js +1 -5
- package/src/scripting/CompilerObjectBase.js +1 -4
- package/src/scripting/CompilerTxt.js +13 -11
- package/src/scripting/ScriptingProvider.js +2 -2
- package/src/scripting/helper.js +1 -1
- package/test/compiler/compilertxt.spec.js +13 -0
- package/test/compiler/convos/txt/convos_mixed_new_line_characters.convo.txt +10 -0
package/dist/botium-es.js
CHANGED
|
@@ -35,7 +35,7 @@ import express from 'express';
|
|
|
35
35
|
import bodyParser from 'body-parser';
|
|
36
36
|
|
|
37
37
|
var name = "botium-core";
|
|
38
|
-
var version$1 = "1.14.
|
|
38
|
+
var version$1 = "1.14.7";
|
|
39
39
|
var description = "The Selenium for Chatbots";
|
|
40
40
|
var main = "index.js";
|
|
41
41
|
var module = "dist/botium-es.js";
|
|
@@ -53,7 +53,7 @@ var scripts = {
|
|
|
53
53
|
link: "npm link botium-connector-dialogflow botium-connector-webdriverio botium-connector-directline3 botium-connector-watson botium-connector-alexa-smapi botium-connector-echo",
|
|
54
54
|
test: "cross-env NODE_PATH=\"./test/plugins/plugindir/fromfolder:./test/plugins/plugindir/fromfile:./test/security/resources\" mocha \"./test/**/*.spec.js\"",
|
|
55
55
|
"coverage:report": "nyc report --reporter=lcov npm test",
|
|
56
|
-
"update-dependencies": "npm-check-updates --reject globby,rollup -u --timeout 120000"
|
|
56
|
+
"update-dependencies": "npm-check-updates --reject chai,globby,rollup -u --timeout 120000"
|
|
57
57
|
};
|
|
58
58
|
var repository = {
|
|
59
59
|
type: "git",
|
|
@@ -66,7 +66,7 @@ var bugs = {
|
|
|
66
66
|
};
|
|
67
67
|
var homepage = "https://www.botium.ai";
|
|
68
68
|
var dependencies = {
|
|
69
|
-
"@babel/runtime": "^7.23.
|
|
69
|
+
"@babel/runtime": "^7.23.9",
|
|
70
70
|
async: "^3.2.5",
|
|
71
71
|
"body-parser": "^1.20.2",
|
|
72
72
|
boolean: "^3.2.0",
|
|
@@ -83,8 +83,8 @@ var dependencies = {
|
|
|
83
83
|
"markdown-it": "^14.0.0",
|
|
84
84
|
"mime-types": "^2.1.35",
|
|
85
85
|
mkdirp: "^3.0.1",
|
|
86
|
-
moment: "^2.
|
|
87
|
-
"moment-timezone": "^0.5.
|
|
86
|
+
moment: "^2.30.1",
|
|
87
|
+
"moment-timezone": "^0.5.45",
|
|
88
88
|
mustache: "^4.2.0",
|
|
89
89
|
"promise-retry": "^2.0.1",
|
|
90
90
|
"promise.allsettled": "^1.0.7",
|
|
@@ -93,8 +93,8 @@ var dependencies = {
|
|
|
93
93
|
rimraf: "^5.0.5",
|
|
94
94
|
"sanitize-filename": "^1.6.3",
|
|
95
95
|
slugify: "^1.6.6",
|
|
96
|
-
"socket.io": "^4.7.
|
|
97
|
-
"socket.io-client": "^4.7.
|
|
96
|
+
"socket.io": "^4.7.4",
|
|
97
|
+
"socket.io-client": "^4.7.4",
|
|
98
98
|
"socketio-auth": "^0.1.1",
|
|
99
99
|
"swagger-jsdoc": "^6.2.8",
|
|
100
100
|
"swagger-ui-express": "^5.0.0",
|
|
@@ -106,23 +106,23 @@ var dependencies = {
|
|
|
106
106
|
yaml: "^2.3.4"
|
|
107
107
|
};
|
|
108
108
|
var devDependencies = {
|
|
109
|
-
"@babel/core": "^7.23.
|
|
110
|
-
"@babel/node": "^7.
|
|
111
|
-
"@babel/plugin-transform-runtime": "^7.23.
|
|
112
|
-
"@babel/preset-env": "^7.23.
|
|
113
|
-
chai: "
|
|
109
|
+
"@babel/core": "^7.23.9",
|
|
110
|
+
"@babel/node": "^7.23.9",
|
|
111
|
+
"@babel/plugin-transform-runtime": "^7.23.9",
|
|
112
|
+
"@babel/preset-env": "^7.23.9",
|
|
113
|
+
chai: "4.3.10",
|
|
114
114
|
"chai-as-promised": "^7.1.1",
|
|
115
115
|
"cross-env": "^7.0.3",
|
|
116
|
-
eslint: "^8.
|
|
116
|
+
eslint: "^8.56.0",
|
|
117
117
|
"eslint-config-standard": "^17.1.0",
|
|
118
|
-
"eslint-plugin-import": "^2.29.
|
|
118
|
+
"eslint-plugin-import": "^2.29.1",
|
|
119
119
|
"eslint-plugin-mocha": "^10.2.0",
|
|
120
|
-
"eslint-plugin-n": "^16.
|
|
120
|
+
"eslint-plugin-n": "^16.6.2",
|
|
121
121
|
"eslint-plugin-promise": "^6.1.1",
|
|
122
122
|
"eslint-plugin-standard": "^4.1.0",
|
|
123
|
-
mocha: "^10.
|
|
124
|
-
nock: "^13.
|
|
125
|
-
"npm-check-updates": "^16.14.
|
|
123
|
+
mocha: "^10.3.0",
|
|
124
|
+
nock: "^13.5.1",
|
|
125
|
+
"npm-check-updates": "^16.14.15",
|
|
126
126
|
nyc: "^15.1.0",
|
|
127
127
|
rollup: "2.79.1",
|
|
128
128
|
"rollup-plugin-babel": "^4.4.0",
|
|
@@ -552,7 +552,6 @@ var Defaults$1 = {
|
|
|
552
552
|
[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
|
|
553
553
|
[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
|
|
554
554
|
[Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
|
|
555
|
-
[Capabilities.SCRIPTING_TXT_EOL]: '\n',
|
|
556
555
|
[Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
|
|
557
556
|
[Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
|
|
558
557
|
[Capabilities.SCRIPTING_CSV_SKIP_HEADER]: true,
|
|
@@ -1605,7 +1604,7 @@ const _formatAppendArgs = args => {
|
|
|
1605
1604
|
const _parseArgs = str => {
|
|
1606
1605
|
return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
|
|
1607
1606
|
};
|
|
1608
|
-
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
1607
|
+
const linesToConvoStep$5 = (lines, sender, context, eol = '\n', singleLineMode = false) => {
|
|
1609
1608
|
if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
|
|
1610
1609
|
const convoStep = {
|
|
1611
1610
|
asserters: [],
|
|
@@ -3591,8 +3590,10 @@ var RetryHelper_1 = class RetryHelper {
|
|
|
3591
3590
|
debug$j(`Retry for ${section} is enabled. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`);
|
|
3592
3591
|
}
|
|
3593
3592
|
}
|
|
3594
|
-
shouldRetry(err) {
|
|
3593
|
+
shouldRetry(err, currentRetryCount) {
|
|
3595
3594
|
if (!err) return false;
|
|
3595
|
+
if (!this.retrySettings.retries) return false;
|
|
3596
|
+
if (this.retrySettings.retries < currentRetryCount) return false;
|
|
3596
3597
|
if (this.retryErrorPatterns.length === 0) return true;
|
|
3597
3598
|
const errString = util.inspect(err);
|
|
3598
3599
|
for (const re of this.retryErrorPatterns) {
|
|
@@ -4835,16 +4836,16 @@ const {
|
|
|
4835
4836
|
var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
4836
4837
|
constructor(context, caps = {}) {
|
|
4837
4838
|
super(context, caps);
|
|
4838
|
-
this.
|
|
4839
|
+
this.eolRead = caps[Capabilities.SCRIPTING_TXT_EOL] || /\r\n|\r|\n/;
|
|
4840
|
+
this.eolWrite = caps[Capabilities.SCRIPTING_TXT_EOL] && !lodash.isRegExp(caps[Capabilities.SCRIPTING_TXT_EOL]) ? caps[Capabilities.SCRIPTING_TXT_EOL] : '\n';
|
|
4839
4841
|
}
|
|
4840
4842
|
Validate() {
|
|
4841
4843
|
super.Validate();
|
|
4842
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
4843
4844
|
}
|
|
4844
4845
|
GetHeaders(scriptBuffer) {
|
|
4845
4846
|
let scriptData = scriptBuffer;
|
|
4846
4847
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4847
|
-
const lines = scriptData.split(this.
|
|
4848
|
+
const lines = scriptData.split(this.eolRead);
|
|
4848
4849
|
const header = {};
|
|
4849
4850
|
if (lines && !lines[0].startsWith('#')) {
|
|
4850
4851
|
header.name = lines[0];
|
|
@@ -4854,7 +4855,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4854
4855
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
4855
4856
|
let scriptData = scriptBuffer;
|
|
4856
4857
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4857
|
-
const lines = scriptData.split(this.
|
|
4858
|
+
const lines = scriptData.split(this.eolRead);
|
|
4858
4859
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
4859
4860
|
return this._compileConvo(lines, false);
|
|
4860
4861
|
} else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
@@ -4879,7 +4880,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4879
4880
|
let convoStepLineIndex = null;
|
|
4880
4881
|
const parseMsg = lines => {
|
|
4881
4882
|
lines = lines || [];
|
|
4882
|
-
return linesToConvoStep$3(lines, convoStepSender, this.context
|
|
4883
|
+
return linesToConvoStep$3(lines, convoStepSender, this.context);
|
|
4883
4884
|
};
|
|
4884
4885
|
const pushPrev = () => {
|
|
4885
4886
|
if (convoStepSender && currentLines) {
|
|
@@ -4893,7 +4894,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4893
4894
|
} else if (!convoStepSender && currentLines) {
|
|
4894
4895
|
convo.header.name = currentLines[0];
|
|
4895
4896
|
if (currentLines.length > 1) {
|
|
4896
|
-
convo.header.description = currentLines.slice(1).join(this.
|
|
4897
|
+
convo.header.description = currentLines.slice(1).join(this.eolWrite);
|
|
4897
4898
|
}
|
|
4898
4899
|
}
|
|
4899
4900
|
};
|
|
@@ -4957,20 +4958,20 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4957
4958
|
}
|
|
4958
4959
|
let script = '';
|
|
4959
4960
|
if (convo.header.name) {
|
|
4960
|
-
script += convo.header.name + this.
|
|
4961
|
+
script += convo.header.name + this.eolWrite;
|
|
4961
4962
|
}
|
|
4962
4963
|
if (convo.header.description) {
|
|
4963
|
-
script += convo.header.description + this.
|
|
4964
|
+
script += convo.header.description + this.eolWrite;
|
|
4964
4965
|
}
|
|
4965
4966
|
convo.conversation.forEach(step => {
|
|
4966
|
-
script += this.
|
|
4967
|
+
script += this.eolWrite;
|
|
4967
4968
|
script += '#' + step.sender;
|
|
4968
4969
|
if (step.channel && step.channel !== 'default') {
|
|
4969
4970
|
script += ' ' + step.channel;
|
|
4970
4971
|
}
|
|
4971
|
-
script += this.
|
|
4972
|
+
script += this.eolWrite;
|
|
4972
4973
|
const stepLines = convoStepToLines(step);
|
|
4973
|
-
if (stepLines && stepLines.length > 0) script += stepLines.join(this.
|
|
4974
|
+
if (stepLines && stepLines.length > 0) script += stepLines.join(this.eolWrite) + this.eolWrite;
|
|
4974
4975
|
});
|
|
4975
4976
|
return script;
|
|
4976
4977
|
}
|
|
@@ -5202,11 +5203,9 @@ const {
|
|
|
5202
5203
|
var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
5203
5204
|
constructor(context, caps = {}) {
|
|
5204
5205
|
super(context, caps);
|
|
5205
|
-
this.eol = caps[Capabilities.SCRIPTING_TXT_EOL];
|
|
5206
5206
|
}
|
|
5207
5207
|
Validate() {
|
|
5208
5208
|
super.Validate();
|
|
5209
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
5210
5209
|
}
|
|
5211
5210
|
GetHeaders(scriptBuffer) {
|
|
5212
5211
|
debug$b('GetHeaders is not implemented!');
|
|
@@ -5247,7 +5246,7 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5247
5246
|
conversation.push(Object.assign({
|
|
5248
5247
|
sender: convoStepSender,
|
|
5249
5248
|
stepTag: 'Line ' + lineTag
|
|
5250
|
-
}, linesToConvoStep$1(convoStepObject, convoStepSender, this.context
|
|
5249
|
+
}, linesToConvoStep$1(convoStepObject, convoStepSender, this.context)));
|
|
5251
5250
|
}
|
|
5252
5251
|
const convo = {
|
|
5253
5252
|
header: {
|
|
@@ -5349,11 +5348,9 @@ const {
|
|
|
5349
5348
|
var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
5350
5349
|
constructor(context, caps = {}) {
|
|
5351
5350
|
super(context, caps);
|
|
5352
|
-
this.eol = caps[Capabilities.SCRIPTING_TXT_EOL];
|
|
5353
5351
|
}
|
|
5354
5352
|
Validate() {
|
|
5355
5353
|
super.Validate();
|
|
5356
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
5357
5354
|
}
|
|
5358
5355
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
5359
5356
|
if (Buffer.isBuffer(scriptBuffer)) scriptBuffer = scriptBuffer.toString();
|
|
@@ -5415,7 +5412,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5415
5412
|
conversation.push(Object.assign({
|
|
5416
5413
|
sender,
|
|
5417
5414
|
stepTag: 'Line ' + (step.map[0] + 1)
|
|
5418
|
-
}, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context
|
|
5415
|
+
}, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context)));
|
|
5419
5416
|
} else {
|
|
5420
5417
|
debug$a(`Expected sender ${validSenders.map(s => `'${s}'`).join(' or ')} but found ${sender}`);
|
|
5421
5418
|
}
|
|
@@ -5477,7 +5474,7 @@ const p = (retryHelper, fn) => {
|
|
|
5477
5474
|
if (retryHelper) {
|
|
5478
5475
|
return promiseRetry((retry, number) => {
|
|
5479
5476
|
return promise().catch(err => {
|
|
5480
|
-
if (retryHelper.shouldRetry(err)) {
|
|
5477
|
+
if (retryHelper.shouldRetry(err, number)) {
|
|
5481
5478
|
debug$9(`Asserter trial #${number} failed, retry activated`);
|
|
5482
5479
|
retry(err);
|
|
5483
5480
|
} else {
|
|
@@ -5502,7 +5499,7 @@ const pnot = (retryHelper, fn, errTemplate) => {
|
|
|
5502
5499
|
if (retryHelper) {
|
|
5503
5500
|
return promiseRetry((retry, number) => {
|
|
5504
5501
|
return promise().catch(() => {
|
|
5505
|
-
if (retryHelper.shouldRetry(errTemplate)) {
|
|
5502
|
+
if (retryHelper.shouldRetry(errTemplate, number)) {
|
|
5506
5503
|
debug$9(`Asserter trial #${number} failed, !retry activated`);
|
|
5507
5504
|
retry(errTemplate);
|
|
5508
5505
|
} else {
|
|
@@ -8955,7 +8952,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8955
8952
|
try {
|
|
8956
8953
|
return super.Build().then(() => promiseRetry((retry, number) => {
|
|
8957
8954
|
return (this.pluginInstance.Build ? this.pluginInstance.Build() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8958
|
-
if (this.retryHelperBuild.shouldRetry(err)) {
|
|
8955
|
+
if (this.retryHelperBuild.shouldRetry(err, number)) {
|
|
8959
8956
|
debug$2(`Build trial #${number} failed, retry activated`);
|
|
8960
8957
|
retry(err);
|
|
8961
8958
|
} else {
|
|
@@ -8972,7 +8969,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8972
8969
|
try {
|
|
8973
8970
|
return super.Start().then(() => promiseRetry((retry, number) => {
|
|
8974
8971
|
return (this.pluginInstance.Start ? this.pluginInstance.Start() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
8975
|
-
if (this.retryHelperStart.shouldRetry(err)) {
|
|
8972
|
+
if (this.retryHelperStart.shouldRetry(err, number)) {
|
|
8976
8973
|
debug$2(`Start trial #${number} failed, retry activated`);
|
|
8977
8974
|
retry(err);
|
|
8978
8975
|
} else {
|
|
@@ -8995,7 +8992,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8995
8992
|
try {
|
|
8996
8993
|
return promiseRetry((retry, number) => {
|
|
8997
8994
|
return (this.pluginInstance.UserSays(mockMsg) || Promise.resolve()).catch(err => {
|
|
8998
|
-
if (this.retryHelperUserSays.shouldRetry(err)) {
|
|
8995
|
+
if (this.retryHelperUserSays.shouldRetry(err, number)) {
|
|
8999
8996
|
debug$2(`UserSays trial #${number} failed, retry activated`);
|
|
9000
8997
|
retry(err);
|
|
9001
8998
|
} else {
|
|
@@ -9015,7 +9012,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9015
9012
|
try {
|
|
9016
9013
|
return super.Stop().then(() => promiseRetry((retry, number) => {
|
|
9017
9014
|
return (this.pluginInstance.Stop ? this.pluginInstance.Stop() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
9018
|
-
if (this.retryHelperStop.shouldRetry(err)) {
|
|
9015
|
+
if (this.retryHelperStop.shouldRetry(err, number)) {
|
|
9019
9016
|
debug$2(`Stop trial #${number} failed, retry activated`);
|
|
9020
9017
|
retry(err);
|
|
9021
9018
|
} else {
|
|
@@ -9039,7 +9036,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9039
9036
|
try {
|
|
9040
9037
|
return promiseRetry((retry, number) => {
|
|
9041
9038
|
return (this.pluginInstance.Clean ? this.pluginInstance.Clean() || Promise.resolve() : Promise.resolve()).catch(err => {
|
|
9042
|
-
if (this.retryHelperClean.shouldRetry(err)) {
|
|
9039
|
+
if (this.retryHelperClean.shouldRetry(err, number)) {
|
|
9043
9040
|
debug$2(`Clean trial #${number} failed, retry activated`);
|
|
9044
9041
|
retry(err);
|
|
9045
9042
|
} else {
|