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-cjs.js
CHANGED
|
@@ -77,7 +77,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
|
77
77
|
var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
|
|
78
78
|
|
|
79
79
|
var name = "botium-core";
|
|
80
|
-
var version$1 = "1.14.
|
|
80
|
+
var version$1 = "1.14.6";
|
|
81
81
|
var description = "The Selenium for Chatbots";
|
|
82
82
|
var main = "index.js";
|
|
83
83
|
var module$1 = "dist/botium-es.js";
|
|
@@ -95,7 +95,7 @@ var scripts = {
|
|
|
95
95
|
link: "npm link botium-connector-dialogflow botium-connector-webdriverio botium-connector-directline3 botium-connector-watson botium-connector-alexa-smapi botium-connector-echo",
|
|
96
96
|
test: "cross-env NODE_PATH=\"./test/plugins/plugindir/fromfolder:./test/plugins/plugindir/fromfile:./test/security/resources\" mocha \"./test/**/*.spec.js\"",
|
|
97
97
|
"coverage:report": "nyc report --reporter=lcov npm test",
|
|
98
|
-
"update-dependencies": "npm-check-updates --reject globby,rollup -u --timeout 120000"
|
|
98
|
+
"update-dependencies": "npm-check-updates --reject chai,globby,rollup -u --timeout 120000"
|
|
99
99
|
};
|
|
100
100
|
var repository = {
|
|
101
101
|
type: "git",
|
|
@@ -108,7 +108,7 @@ var bugs = {
|
|
|
108
108
|
};
|
|
109
109
|
var homepage = "https://www.botium.ai";
|
|
110
110
|
var dependencies = {
|
|
111
|
-
"@babel/runtime": "^7.23.
|
|
111
|
+
"@babel/runtime": "^7.23.9",
|
|
112
112
|
async: "^3.2.5",
|
|
113
113
|
"body-parser": "^1.20.2",
|
|
114
114
|
boolean: "^3.2.0",
|
|
@@ -125,8 +125,8 @@ var dependencies = {
|
|
|
125
125
|
"markdown-it": "^14.0.0",
|
|
126
126
|
"mime-types": "^2.1.35",
|
|
127
127
|
mkdirp: "^3.0.1",
|
|
128
|
-
moment: "^2.
|
|
129
|
-
"moment-timezone": "^0.5.
|
|
128
|
+
moment: "^2.30.1",
|
|
129
|
+
"moment-timezone": "^0.5.45",
|
|
130
130
|
mustache: "^4.2.0",
|
|
131
131
|
"promise-retry": "^2.0.1",
|
|
132
132
|
"promise.allsettled": "^1.0.7",
|
|
@@ -135,8 +135,8 @@ var dependencies = {
|
|
|
135
135
|
rimraf: "^5.0.5",
|
|
136
136
|
"sanitize-filename": "^1.6.3",
|
|
137
137
|
slugify: "^1.6.6",
|
|
138
|
-
"socket.io": "^4.7.
|
|
139
|
-
"socket.io-client": "^4.7.
|
|
138
|
+
"socket.io": "^4.7.4",
|
|
139
|
+
"socket.io-client": "^4.7.4",
|
|
140
140
|
"socketio-auth": "^0.1.1",
|
|
141
141
|
"swagger-jsdoc": "^6.2.8",
|
|
142
142
|
"swagger-ui-express": "^5.0.0",
|
|
@@ -148,23 +148,23 @@ var dependencies = {
|
|
|
148
148
|
yaml: "^2.3.4"
|
|
149
149
|
};
|
|
150
150
|
var devDependencies = {
|
|
151
|
-
"@babel/core": "^7.23.
|
|
152
|
-
"@babel/node": "^7.
|
|
153
|
-
"@babel/plugin-transform-runtime": "^7.23.
|
|
154
|
-
"@babel/preset-env": "^7.23.
|
|
155
|
-
chai: "
|
|
151
|
+
"@babel/core": "^7.23.9",
|
|
152
|
+
"@babel/node": "^7.23.9",
|
|
153
|
+
"@babel/plugin-transform-runtime": "^7.23.9",
|
|
154
|
+
"@babel/preset-env": "^7.23.9",
|
|
155
|
+
chai: "4.3.10",
|
|
156
156
|
"chai-as-promised": "^7.1.1",
|
|
157
157
|
"cross-env": "^7.0.3",
|
|
158
|
-
eslint: "^8.
|
|
158
|
+
eslint: "^8.56.0",
|
|
159
159
|
"eslint-config-standard": "^17.1.0",
|
|
160
|
-
"eslint-plugin-import": "^2.29.
|
|
160
|
+
"eslint-plugin-import": "^2.29.1",
|
|
161
161
|
"eslint-plugin-mocha": "^10.2.0",
|
|
162
|
-
"eslint-plugin-n": "^16.
|
|
162
|
+
"eslint-plugin-n": "^16.6.2",
|
|
163
163
|
"eslint-plugin-promise": "^6.1.1",
|
|
164
164
|
"eslint-plugin-standard": "^4.1.0",
|
|
165
|
-
mocha: "^10.
|
|
166
|
-
nock: "^13.
|
|
167
|
-
"npm-check-updates": "^16.14.
|
|
165
|
+
mocha: "^10.3.0",
|
|
166
|
+
nock: "^13.5.1",
|
|
167
|
+
"npm-check-updates": "^16.14.15",
|
|
168
168
|
nyc: "^15.1.0",
|
|
169
169
|
rollup: "2.79.1",
|
|
170
170
|
"rollup-plugin-babel": "^4.4.0",
|
|
@@ -594,7 +594,6 @@ var Defaults$1 = {
|
|
|
594
594
|
[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
|
|
595
595
|
[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
|
|
596
596
|
[Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
|
|
597
|
-
[Capabilities.SCRIPTING_TXT_EOL]: '\n',
|
|
598
597
|
[Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
|
|
599
598
|
[Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
|
|
600
599
|
[Capabilities.SCRIPTING_CSV_SKIP_HEADER]: true,
|
|
@@ -1647,7 +1646,7 @@ const _formatAppendArgs = args => {
|
|
|
1647
1646
|
const _parseArgs = str => {
|
|
1648
1647
|
return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
|
|
1649
1648
|
};
|
|
1650
|
-
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
1649
|
+
const linesToConvoStep$5 = (lines, sender, context, eol = '\n', singleLineMode = false) => {
|
|
1651
1650
|
if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
|
|
1652
1651
|
const convoStep = {
|
|
1653
1652
|
asserters: [],
|
|
@@ -1821,7 +1820,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1821
1820
|
if (eol === null) {
|
|
1822
1821
|
throw new Error('eol cant be null');
|
|
1823
1822
|
}
|
|
1824
|
-
convoStep.messageText = textLines.join(eol)
|
|
1823
|
+
convoStep.messageText = trimExceptSpaceEnd$1(textLines.join(eol));
|
|
1825
1824
|
}
|
|
1826
1825
|
}
|
|
1827
1826
|
} else {
|
|
@@ -1842,6 +1841,9 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1842
1841
|
}
|
|
1843
1842
|
return convoStep;
|
|
1844
1843
|
};
|
|
1844
|
+
const trimExceptSpaceEnd$1 = string => {
|
|
1845
|
+
return string?.replace(WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END, '');
|
|
1846
|
+
};
|
|
1845
1847
|
const convoStepToObject$1 = step => {
|
|
1846
1848
|
const result = [];
|
|
1847
1849
|
if (step.sender === 'me') {
|
|
@@ -2171,7 +2173,8 @@ var helper = {
|
|
|
2171
2173
|
validateConvo: validateConvo$2,
|
|
2172
2174
|
linesToScriptingMemories: linesToScriptingMemories$2,
|
|
2173
2175
|
calculateWer: calculateWer$2,
|
|
2174
|
-
toPercent: toPercent$1
|
|
2176
|
+
toPercent: toPercent$1,
|
|
2177
|
+
trimExceptSpaceEnd: trimExceptSpaceEnd$1
|
|
2175
2178
|
};
|
|
2176
2179
|
|
|
2177
2180
|
const BotiumError$4 = class BotiumError extends Error {
|
|
@@ -4867,21 +4870,22 @@ const {
|
|
|
4867
4870
|
convoStepToLines,
|
|
4868
4871
|
validateConvo,
|
|
4869
4872
|
validSenders: validSenders$2,
|
|
4870
|
-
linesToScriptingMemories: linesToScriptingMemories$1
|
|
4873
|
+
linesToScriptingMemories: linesToScriptingMemories$1,
|
|
4874
|
+
trimExceptSpaceEnd
|
|
4871
4875
|
} = helper;
|
|
4872
4876
|
var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
4873
4877
|
constructor(context, caps = {}) {
|
|
4874
4878
|
super(context, caps);
|
|
4875
|
-
this.
|
|
4879
|
+
this.eolRead = caps[Capabilities.SCRIPTING_TXT_EOL] || /\r\n|\r|\n/;
|
|
4880
|
+
this.eolWrite = caps[Capabilities.SCRIPTING_TXT_EOL] && !lodash__default["default"].isRegExp(caps[Capabilities.SCRIPTING_TXT_EOL]) ? caps[Capabilities.SCRIPTING_TXT_EOL] : '\n';
|
|
4876
4881
|
}
|
|
4877
4882
|
Validate() {
|
|
4878
4883
|
super.Validate();
|
|
4879
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
4880
4884
|
}
|
|
4881
4885
|
GetHeaders(scriptBuffer) {
|
|
4882
4886
|
let scriptData = scriptBuffer;
|
|
4883
4887
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4884
|
-
const lines = scriptData.split(this.
|
|
4888
|
+
const lines = scriptData.split(this.eolRead);
|
|
4885
4889
|
const header = {};
|
|
4886
4890
|
if (lines && !lines[0].startsWith('#')) {
|
|
4887
4891
|
header.name = lines[0];
|
|
@@ -4891,7 +4895,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4891
4895
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
4892
4896
|
let scriptData = scriptBuffer;
|
|
4893
4897
|
if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
|
|
4894
|
-
const lines = scriptData.split(this.
|
|
4898
|
+
const lines = scriptData.split(this.eolRead);
|
|
4895
4899
|
if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
|
|
4896
4900
|
return this._compileConvo(lines, false);
|
|
4897
4901
|
} else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
|
|
@@ -4916,7 +4920,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4916
4920
|
let convoStepLineIndex = null;
|
|
4917
4921
|
const parseMsg = lines => {
|
|
4918
4922
|
lines = lines || [];
|
|
4919
|
-
return linesToConvoStep$3(lines, convoStepSender, this.context
|
|
4923
|
+
return linesToConvoStep$3(lines, convoStepSender, this.context);
|
|
4920
4924
|
};
|
|
4921
4925
|
const pushPrev = () => {
|
|
4922
4926
|
if (convoStepSender && currentLines) {
|
|
@@ -4930,7 +4934,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4930
4934
|
} else if (!convoStepSender && currentLines) {
|
|
4931
4935
|
convo.header.name = currentLines[0];
|
|
4932
4936
|
if (currentLines.length > 1) {
|
|
4933
|
-
convo.header.description = currentLines.slice(1).join(this.
|
|
4937
|
+
convo.header.description = currentLines.slice(1).join(this.eolWrite);
|
|
4934
4938
|
}
|
|
4935
4939
|
}
|
|
4936
4940
|
};
|
|
@@ -4967,8 +4971,8 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4967
4971
|
_compileUtterances(lines) {
|
|
4968
4972
|
if (lines && lines.length > 0) {
|
|
4969
4973
|
const result = [new Utterance_1({
|
|
4970
|
-
name: lines[0],
|
|
4971
|
-
utterances: lines.length > 1 ? lines.slice(1) : []
|
|
4974
|
+
name: lines[0].trim(),
|
|
4975
|
+
utterances: lines.length > 1 ? lines.slice(1).map(line => trimExceptSpaceEnd(line)) : []
|
|
4972
4976
|
})];
|
|
4973
4977
|
this.context.AddUtterances(result);
|
|
4974
4978
|
return result;
|
|
@@ -4994,20 +4998,20 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
|
|
|
4994
4998
|
}
|
|
4995
4999
|
let script = '';
|
|
4996
5000
|
if (convo.header.name) {
|
|
4997
|
-
script += convo.header.name + this.
|
|
5001
|
+
script += convo.header.name + this.eolWrite;
|
|
4998
5002
|
}
|
|
4999
5003
|
if (convo.header.description) {
|
|
5000
|
-
script += convo.header.description + this.
|
|
5004
|
+
script += convo.header.description + this.eolWrite;
|
|
5001
5005
|
}
|
|
5002
5006
|
convo.conversation.forEach(step => {
|
|
5003
|
-
script += this.
|
|
5007
|
+
script += this.eolWrite;
|
|
5004
5008
|
script += '#' + step.sender;
|
|
5005
5009
|
if (step.channel && step.channel !== 'default') {
|
|
5006
5010
|
script += ' ' + step.channel;
|
|
5007
5011
|
}
|
|
5008
|
-
script += this.
|
|
5012
|
+
script += this.eolWrite;
|
|
5009
5013
|
const stepLines = convoStepToLines(step);
|
|
5010
|
-
if (stepLines && stepLines.length > 0) script += stepLines.join(this.
|
|
5014
|
+
if (stepLines && stepLines.length > 0) script += stepLines.join(this.eolWrite) + this.eolWrite;
|
|
5011
5015
|
});
|
|
5012
5016
|
return script;
|
|
5013
5017
|
}
|
|
@@ -5239,11 +5243,9 @@ const {
|
|
|
5239
5243
|
var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
5240
5244
|
constructor(context, caps = {}) {
|
|
5241
5245
|
super(context, caps);
|
|
5242
|
-
this.eol = caps[Capabilities.SCRIPTING_TXT_EOL];
|
|
5243
5246
|
}
|
|
5244
5247
|
Validate() {
|
|
5245
5248
|
super.Validate();
|
|
5246
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
5247
5249
|
}
|
|
5248
5250
|
GetHeaders(scriptBuffer) {
|
|
5249
5251
|
debug$b('GetHeaders is not implemented!');
|
|
@@ -5284,7 +5286,7 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
|
|
|
5284
5286
|
conversation.push(Object.assign({
|
|
5285
5287
|
sender: convoStepSender,
|
|
5286
5288
|
stepTag: 'Line ' + lineTag
|
|
5287
|
-
}, linesToConvoStep$1(convoStepObject, convoStepSender, this.context
|
|
5289
|
+
}, linesToConvoStep$1(convoStepObject, convoStepSender, this.context)));
|
|
5288
5290
|
}
|
|
5289
5291
|
const convo = {
|
|
5290
5292
|
header: {
|
|
@@ -5386,11 +5388,9 @@ const {
|
|
|
5386
5388
|
var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
5387
5389
|
constructor(context, caps = {}) {
|
|
5388
5390
|
super(context, caps);
|
|
5389
|
-
this.eol = caps[Capabilities.SCRIPTING_TXT_EOL];
|
|
5390
5391
|
}
|
|
5391
5392
|
Validate() {
|
|
5392
5393
|
super.Validate();
|
|
5393
|
-
this._AssertCapabilityExists(Capabilities.SCRIPTING_TXT_EOL);
|
|
5394
5394
|
}
|
|
5395
5395
|
Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
|
|
5396
5396
|
if (Buffer.isBuffer(scriptBuffer)) scriptBuffer = scriptBuffer.toString();
|
|
@@ -5452,7 +5452,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
|
|
|
5452
5452
|
conversation.push(Object.assign({
|
|
5453
5453
|
sender,
|
|
5454
5454
|
stepTag: 'Line ' + (step.map[0] + 1)
|
|
5455
|
-
}, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context
|
|
5455
|
+
}, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context)));
|
|
5456
5456
|
} else {
|
|
5457
5457
|
debug$a(`Expected sender ${validSenders.map(s => `'${s}'`).join(' or ')} but found ${sender}`);
|
|
5458
5458
|
}
|
|
@@ -6939,18 +6939,19 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6939
6939
|
}
|
|
6940
6940
|
if (utterances) {
|
|
6941
6941
|
lodash__default["default"].forEach(utterances, utt => {
|
|
6942
|
-
const
|
|
6942
|
+
const uttName = utt.name?.trim();
|
|
6943
|
+
const eu = this.utterances[uttName];
|
|
6943
6944
|
if (eu) {
|
|
6944
6945
|
eu.utterances = lodash__default["default"].uniq(lodash__default["default"].concat(eu.utterances, utt.utterances));
|
|
6945
6946
|
} else {
|
|
6946
|
-
this.utterances[
|
|
6947
|
+
this.utterances[uttName] = utt;
|
|
6947
6948
|
}
|
|
6948
6949
|
const {
|
|
6949
6950
|
ambiguous,
|
|
6950
6951
|
expected
|
|
6951
|
-
} = findAmbiguous(this.utterances[
|
|
6952
|
+
} = findAmbiguous(this.utterances[uttName].utterances);
|
|
6952
6953
|
if (ambiguous && ambiguous.length > 0) {
|
|
6953
|
-
debug$9(`Ambigous utterance "${
|
|
6954
|
+
debug$9(`Ambigous utterance "${uttName}", expecting exact ${expected.length ? '"' + expected.join(', ') + '"' : '<none>'} scripting memory variables in following user examples: ${ambiguous.map(d => `"${d}"`).join(', ')}`);
|
|
6954
6955
|
}
|
|
6955
6956
|
});
|
|
6956
6957
|
}
|