botium-core 1.12.5 → 1.12.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 +22 -14
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +22 -14
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/scripting/Convo.js +1 -1
- package/src/scripting/helper.js +19 -12
- package/src/scripting/logichook/asserter/ButtonsAsserter.js +4 -2
- package/src/scripting/logichook/asserter/CardsAsserter.js +4 -2
- package/test/compiler/compilertxt.spec.js +13 -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/transcript.spec.js +18 -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
|
@@ -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.12.
|
|
39
|
+
var version$1 = "1.12.6";
|
|
40
40
|
var description = "The Selenium for Chatbots";
|
|
41
41
|
var main = "index.js";
|
|
42
42
|
var module = "dist/botium-es.js";
|
|
@@ -1820,6 +1820,14 @@ const flatString = str => {
|
|
|
1820
1820
|
return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
|
|
1821
1821
|
};
|
|
1822
1822
|
|
|
1823
|
+
const _formatAppendArgs = args => {
|
|
1824
|
+
return args ? ` ${args.map(a => lodash.isString(a) ? a.replace(/\|/g, '\\|') : `${a}`).join('|')}` : '';
|
|
1825
|
+
};
|
|
1826
|
+
|
|
1827
|
+
const _parseArgs = str => {
|
|
1828
|
+
return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1823
1831
|
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
1824
1832
|
if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
|
|
1825
1833
|
const convoStep = {
|
|
@@ -1861,7 +1869,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1861
1869
|
const name = logicLine.split(' ')[0];
|
|
1862
1870
|
|
|
1863
1871
|
if (sender !== 'me' && context.IsAsserterValid(name)) {
|
|
1864
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1872
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1865
1873
|
convoStep.asserters.push({
|
|
1866
1874
|
name,
|
|
1867
1875
|
args,
|
|
@@ -1869,14 +1877,14 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1869
1877
|
optional
|
|
1870
1878
|
});
|
|
1871
1879
|
} else if (sender === 'me' && context.IsUserInputValid(name)) {
|
|
1872
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1880
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1873
1881
|
convoStep.userInputs.push({
|
|
1874
1882
|
name,
|
|
1875
1883
|
args
|
|
1876
1884
|
});
|
|
1877
1885
|
textLinesAccepted = false;
|
|
1878
1886
|
} else if (context.IsLogicHookValid(name)) {
|
|
1879
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1887
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1880
1888
|
convoStep.logicHooks.push({
|
|
1881
1889
|
name,
|
|
1882
1890
|
args
|
|
@@ -2226,7 +2234,7 @@ const convoStepToLines$2 = step => {
|
|
|
2226
2234
|
|
|
2227
2235
|
if (step.sender === 'me') {
|
|
2228
2236
|
step.forms && step.forms.filter(form => form.value).forEach(form => {
|
|
2229
|
-
lines.push(`FORM
|
|
2237
|
+
lines.push(`FORM${_formatAppendArgs([form.name, form.value])}`);
|
|
2230
2238
|
});
|
|
2231
2239
|
|
|
2232
2240
|
if (step.buttons && step.buttons.length > 0) {
|
|
@@ -2238,18 +2246,18 @@ const convoStepToLines$2 = step => {
|
|
|
2238
2246
|
}
|
|
2239
2247
|
|
|
2240
2248
|
step.userInputs && step.userInputs.forEach(userInput => {
|
|
2241
|
-
lines.push(userInput.name + (userInput.args
|
|
2249
|
+
lines.push(userInput.name + _formatAppendArgs(userInput.args));
|
|
2242
2250
|
});
|
|
2243
2251
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2244
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2252
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2245
2253
|
});
|
|
2246
2254
|
} else {
|
|
2247
2255
|
if (step.messageText) {
|
|
2248
2256
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
|
|
2249
2257
|
}
|
|
2250
2258
|
|
|
2251
|
-
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS
|
|
2252
|
-
if (step.media && step.media.length > 0) lines.push('MEDIA
|
|
2259
|
+
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2260
|
+
if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)));
|
|
2253
2261
|
|
|
2254
2262
|
if (step.cards && step.cards.length > 0) {
|
|
2255
2263
|
step.cards.forEach(c => {
|
|
@@ -2257,17 +2265,17 @@ const convoStepToLines$2 = step => {
|
|
|
2257
2265
|
if (c.text) cardTexts = cardTexts.concat(lodash.isArray(c.text) ? c.text : [c.text]);
|
|
2258
2266
|
if (c.subtext) cardTexts = cardTexts.concat(lodash.isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2259
2267
|
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
|
|
2268
|
+
if (cardTexts.length > 0) lines.push('CARDS' + _formatAppendArgs(cardTexts.map(c => flatString(c))));
|
|
2269
|
+
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(c.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2262
2270
|
if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
|
|
2263
2271
|
});
|
|
2264
2272
|
}
|
|
2265
2273
|
|
|
2266
2274
|
step.asserters && step.asserters.forEach(asserter => {
|
|
2267
|
-
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + (asserter.args
|
|
2275
|
+
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + _formatAppendArgs(asserter.args));
|
|
2268
2276
|
});
|
|
2269
2277
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2270
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2278
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2271
2279
|
});
|
|
2272
2280
|
}
|
|
2273
2281
|
|
|
@@ -3393,7 +3401,7 @@ class Convo$6 {
|
|
|
3393
3401
|
const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
|
|
3394
3402
|
|
|
3395
3403
|
if (transcriptStepErrs && transcriptStepErrs.length > 0) {
|
|
3396
|
-
transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
|
|
3404
|
+
transcript.err = botiumErrorFromList$1([...transcriptStepErrs.filter(err => err !== transcript.err), transcript.err].filter(e => e), {});
|
|
3397
3405
|
}
|
|
3398
3406
|
}
|
|
3399
3407
|
}
|