botium-core 1.14.4 → 1.14.6
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 +47 -46
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +47 -46
- package/dist/botium-es.js.map +1 -1
- package/package.json +18 -18
- package/src/Defaults.js +0 -1
- package/src/scripting/CompilerMarkdown.js +1 -5
- package/src/scripting/CompilerObjectBase.js +1 -4
- package/src/scripting/CompilerTxt.js +15 -13
- package/src/scripting/ScriptingProvider.js +5 -4
- package/src/scripting/helper.js +8 -3
- 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.6";
|
|
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: [],
|
|
@@ -1779,7 +1778,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1779
1778
|
if (eol === null) {
|
|
1780
1779
|
throw new Error('eol cant be null');
|
|
1781
1780
|
}
|
|
1782
|
-
convoStep.messageText = textLines.join(eol)
|
|
1781
|
+
convoStep.messageText = trimExceptSpaceEnd$1(textLines.join(eol));
|
|
1783
1782
|
}
|
|
1784
1783
|
}
|
|
1785
1784
|
} else {
|
|
@@ -1800,6 +1799,9 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1800
1799
|
}
|
|
1801
1800
|
return convoStep;
|
|
1802
1801
|
};
|
|
1802
|
+
const trimExceptSpaceEnd$1 = string => {
|
|
1803
|
+
return string?.replace(WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END, '');
|
|
1804
|
+
};
|
|
1803
1805
|
const convoStepToObject$1 = step => {
|
|
1804
1806
|
const result = [];
|
|
1805
1807
|
if (step.sender === 'me') {
|
|
@@ -2129,7 +2131,8 @@ var helper = {
|
|
|
2129
2131
|
validateConvo: validateConvo$2,
|
|
2130
2132
|
linesToScriptingMemories: linesToScriptingMemories$2,
|
|
2131
2133
|
calculateWer: calculateWer$2,
|
|
2132
|
-
toPercent: toPercent$1
|
|
2134
|
+
toPercent: toPercent$1,
|
|
2135
|
+
trimExceptSpaceEnd: trimExceptSpaceEnd$1
|
|
2133
2136
|
};
|
|
2134
2137
|
|
|
2135
2138
|
const BotiumError$4 = class BotiumError extends Error {
|
|
@@ -4825,21 +4828,22 @@ const {
|
|
|
4825
4828
|
convoStepToLines,
|
|
4826
4829
|
validateConvo,
|
|
4827
4830
|
validSenders: validSenders$2,
|
|
4828
|
-
linesToScriptingMemories: linesToScriptingMemories$1
|
|
4831
|
+
linesToScriptingMemories: linesToScriptingMemories$1,
|
|
4832
|
+
trimExceptSpaceEnd
|
|
4829
4833
|
} = helper;
|
|
4830
4834
|
var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
4831
4835
|
constructor(context, caps = {}) {
|
|
4832
4836
|
super(context, caps);
|
|
4833
|
-
this.
|
|
4837
|
+
this.eolRead = caps[Capabilities.SCRIPTING_TXT_EOL] || /\r\n|\r|\n/;
|
|
4838
|
+
this.eolWrite = caps[Capabilities.SCRIPTING_TXT_EOL] && !lodash.isRegExp(caps[Capabilities.SCRIPTING_TXT_EOL]) ? caps[Capabilities.SCRIPTING_TXT_EOL] : '\n';
|
|
4834
4839
|
}
|
|
4835
4840
|
Validate() {
|
|
4836
4841
|
super.Validate();
|
|
4837
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
4838
4842
|
}
|
|
4839
4843
|
GetHeaders(scriptBuffer) {
|
|
4840
4844
|
let scriptData = scriptBuffer;
|
|
4841
4845
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4842
|
-
const lines = scriptData.split(this.
|
|
4846
|
+
const lines = scriptData.split(this.eolRead);
|
|
4843
4847
|
const header = {};
|
|
4844
4848
|
if (lines && !lines[0].startsWith('#')) {
|
|
4845
4849
|
header.name = lines[0];
|
|
@@ -4849,7 +4853,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4849
4853
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
4850
4854
|
let scriptData = scriptBuffer;
|
|
4851
4855
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4852
|
-
const lines = scriptData.split(this.
|
|
4856
|
+
const lines = scriptData.split(this.eolRead);
|
|
4853
4857
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
4854
4858
|
return this._compileConvo(lines, false);
|
|
4855
4859
|
} else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
@@ -4874,7 +4878,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4874
4878
|
let convoStepLineIndex = null;
|
|
4875
4879
|
const parseMsg = lines => {
|
|
4876
4880
|
lines = lines || [];
|
|
4877
|
-
return linesToConvoStep$3(lines, convoStepSender, this.context
|
|
4881
|
+
return linesToConvoStep$3(lines, convoStepSender, this.context);
|
|
4878
4882
|
};
|
|
4879
4883
|
const pushPrev = () => {
|
|
4880
4884
|
if (convoStepSender && currentLines) {
|
|
@@ -4888,7 +4892,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4888
4892
|
} else if (!convoStepSender && currentLines) {
|
|
4889
4893
|
convo.header.name = currentLines[0];
|
|
4890
4894
|
if (currentLines.length > 1) {
|
|
4891
|
-
convo.header.description = currentLines.slice(1).join(this.
|
|
4895
|
+
convo.header.description = currentLines.slice(1).join(this.eolWrite);
|
|
4892
4896
|
}
|
|
4893
4897
|
}
|
|
4894
4898
|
};
|
|
@@ -4925,8 +4929,8 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4925
4929
|
_compileUtterances(lines) {
|
|
4926
4930
|
if (lines && lines.length > 0) {
|
|
4927
4931
|
const result = [new Utterance_1({
|
|
4928
|
-
name: lines[0],
|
|
4929
|
-
utterances: lines.length > 1 ? lines.slice(1) : []
|
|
4932
|
+
name: lines[0].trim(),
|
|
4933
|
+
utterances: lines.length > 1 ? lines.slice(1).map(line => trimExceptSpaceEnd(line)) : []
|
|
4930
4934
|
})];
|
|
4931
4935
|
this.context.AddUtterances(result);
|
|
4932
4936
|
return result;
|
|
@@ -4952,20 +4956,20 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4952
4956
|
}
|
|
4953
4957
|
let script = '';
|
|
4954
4958
|
if (convo.header.name) {
|
|
4955
|
-
script += convo.header.name + this.
|
|
4959
|
+
script += convo.header.name + this.eolWrite;
|
|
4956
4960
|
}
|
|
4957
4961
|
if (convo.header.description) {
|
|
4958
|
-
script += convo.header.description + this.
|
|
4962
|
+
script += convo.header.description + this.eolWrite;
|
|
4959
4963
|
}
|
|
4960
4964
|
convo.conversation.forEach(step => {
|
|
4961
|
-
script += this.
|
|
4965
|
+
script += this.eolWrite;
|
|
4962
4966
|
script += '#' + step.sender;
|
|
4963
4967
|
if (step.channel && step.channel !== 'default') {
|
|
4964
4968
|
script += ' ' + step.channel;
|
|
4965
4969
|
}
|
|
4966
|
-
script += this.
|
|
4970
|
+
script += this.eolWrite;
|
|
4967
4971
|
const stepLines = convoStepToLines(step);
|
|
4968
|
-
if (stepLines && stepLines.length > 0) script += stepLines.join(this.
|
|
4972
|
+
if (stepLines && stepLines.length > 0) script += stepLines.join(this.eolWrite) + this.eolWrite;
|
|
4969
4973
|
});
|
|
4970
4974
|
return script;
|
|
4971
4975
|
}
|
|
@@ -5197,11 +5201,9 @@ const {
|
|
|
5197
5201
|
var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
5198
5202
|
constructor(context, caps = {}) {
|
|
5199
5203
|
super(context, caps);
|
|
5200
|
-
this.eol = caps[Capabilities.SCRIPTING_TXT_EOL];
|
|
5201
5204
|
}
|
|
5202
5205
|
Validate() {
|
|
5203
5206
|
super.Validate();
|
|
5204
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
5205
5207
|
}
|
|
5206
5208
|
GetHeaders(scriptBuffer) {
|
|
5207
5209
|
debug$b('GetHeaders is not implemented!');
|
|
@@ -5242,7 +5244,7 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5242
5244
|
conversation.push(Object.assign({
|
|
5243
5245
|
sender: convoStepSender,
|
|
5244
5246
|
stepTag: 'Line ' + lineTag
|
|
5245
|
-
}, linesToConvoStep$1(convoStepObject, convoStepSender, this.context
|
|
5247
|
+
}, linesToConvoStep$1(convoStepObject, convoStepSender, this.context)));
|
|
5246
5248
|
}
|
|
5247
5249
|
const convo = {
|
|
5248
5250
|
header: {
|
|
@@ -5344,11 +5346,9 @@ const {
|
|
|
5344
5346
|
var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
5345
5347
|
constructor(context, caps = {}) {
|
|
5346
5348
|
super(context, caps);
|
|
5347
|
-
this.eol = caps[Capabilities.SCRIPTING_TXT_EOL];
|
|
5348
5349
|
}
|
|
5349
5350
|
Validate() {
|
|
5350
5351
|
super.Validate();
|
|
5351
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
5352
5352
|
}
|
|
5353
5353
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
5354
5354
|
if (Buffer.isBuffer(scriptBuffer)) scriptBuffer = scriptBuffer.toString();
|
|
@@ -5410,7 +5410,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5410
5410
|
conversation.push(Object.assign({
|
|
5411
5411
|
sender,
|
|
5412
5412
|
stepTag: 'Line ' + (step.map[0] + 1)
|
|
5413
|
-
}, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context
|
|
5413
|
+
}, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context)));
|
|
5414
5414
|
} else {
|
|
5415
5415
|
debug$a(`Expected sender ${validSenders.map(s => `'${s}'`).join(' or ')} but found ${sender}`);
|
|
5416
5416
|
}
|
|
@@ -6897,18 +6897,19 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6897
6897
|
}
|
|
6898
6898
|
if (utterances) {
|
|
6899
6899
|
lodash.forEach(utterances, utt => {
|
|
6900
|
-
const
|
|
6900
|
+
const uttName = utt.name?.trim();
|
|
6901
|
+
const eu = this.utterances[uttName];
|
|
6901
6902
|
if (eu) {
|
|
6902
6903
|
eu.utterances = lodash.uniq(lodash.concat(eu.utterances, utt.utterances));
|
|
6903
6904
|
} else {
|
|
6904
|
-
this.utterances[
|
|
6905
|
+
this.utterances[uttName] = utt;
|
|
6905
6906
|
}
|
|
6906
6907
|
const {
|
|
6907
6908
|
ambiguous,
|
|
6908
6909
|
expected
|
|
6909
|
-
} = findAmbiguous(this.utterances[
|
|
6910
|
+
} = findAmbiguous(this.utterances[uttName].utterances);
|
|
6910
6911
|
if (ambiguous && ambiguous.length > 0) {
|
|
6911
|
-
debug$9(`Ambigous utterance "${
|
|
6912
|
+
debug$9(`Ambigous utterance "${uttName}", expecting exact ${expected.length ? '"' + expected.join(', ') + '"' : '<none>'} scripting memory variables in following user examples: ${ambiguous.map(d => `"${d}"`).join(', ')}`);
|
|
6912
6913
|
}
|
|
6913
6914
|
});
|
|
6914
6915
|
}
|