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.
@@ -79,7 +79,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
79
79
  var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
80
80
 
81
81
  var name = "botium-core";
82
- var version$1 = "1.12.5";
82
+ var version$1 = "1.12.6";
83
83
  var description = "The Selenium for Chatbots";
84
84
  var main = "index.js";
85
85
  var module$1 = "dist/botium-es.js";
@@ -1863,6 +1863,14 @@ const flatString = str => {
1863
1863
  return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
1864
1864
  };
1865
1865
 
1866
+ const _formatAppendArgs = args => {
1867
+ return args ? ` ${args.map(a => lodash__default["default"].isString(a) ? a.replace(/\|/g, '\\|') : `${a}`).join('|')}` : '';
1868
+ };
1869
+
1870
+ const _parseArgs = str => {
1871
+ return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
1872
+ };
1873
+
1866
1874
  const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
1867
1875
  if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
1868
1876
  const convoStep = {
@@ -1904,7 +1912,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1904
1912
  const name = logicLine.split(' ')[0];
1905
1913
 
1906
1914
  if (sender !== 'me' && context.IsAsserterValid(name)) {
1907
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1915
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1908
1916
  convoStep.asserters.push({
1909
1917
  name,
1910
1918
  args,
@@ -1912,14 +1920,14 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1912
1920
  optional
1913
1921
  });
1914
1922
  } else if (sender === 'me' && context.IsUserInputValid(name)) {
1915
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1923
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1916
1924
  convoStep.userInputs.push({
1917
1925
  name,
1918
1926
  args
1919
1927
  });
1920
1928
  textLinesAccepted = false;
1921
1929
  } else if (context.IsLogicHookValid(name)) {
1922
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1930
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1923
1931
  convoStep.logicHooks.push({
1924
1932
  name,
1925
1933
  args
@@ -2269,7 +2277,7 @@ const convoStepToLines$2 = step => {
2269
2277
 
2270
2278
  if (step.sender === 'me') {
2271
2279
  step.forms && step.forms.filter(form => form.value).forEach(form => {
2272
- lines.push(`FORM ${form.name}|${form.value}`);
2280
+ lines.push(`FORM${_formatAppendArgs([form.name, form.value])}`);
2273
2281
  });
2274
2282
 
2275
2283
  if (step.buttons && step.buttons.length > 0) {
@@ -2281,18 +2289,18 @@ const convoStepToLines$2 = step => {
2281
2289
  }
2282
2290
 
2283
2291
  step.userInputs && step.userInputs.forEach(userInput => {
2284
- lines.push(userInput.name + (userInput.args ? ' ' + userInput.args.join('|') : ''));
2292
+ lines.push(userInput.name + _formatAppendArgs(userInput.args));
2285
2293
  });
2286
2294
  step.logicHooks && step.logicHooks.forEach(logicHook => {
2287
- lines.push(logicHook.name + (logicHook.args ? ' ' + logicHook.args.join('|') : ''));
2295
+ lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
2288
2296
  });
2289
2297
  } else {
2290
2298
  if (step.messageText) {
2291
2299
  lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
2292
2300
  }
2293
2301
 
2294
- if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
2295
- if (step.media && step.media.length > 0) lines.push('MEDIA ' + step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri).join('|'));
2302
+ if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))));
2303
+ if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)));
2296
2304
 
2297
2305
  if (step.cards && step.cards.length > 0) {
2298
2306
  step.cards.forEach(c => {
@@ -2300,17 +2308,17 @@ const convoStepToLines$2 = step => {
2300
2308
  if (c.text) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.text) ? c.text : [c.text]);
2301
2309
  if (c.subtext) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.subtext) ? c.subtext : [c.subtext]);
2302
2310
  if (c.content) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.content) ? c.content : [c.content]);
2303
- if (cardTexts.length > 0) lines.push('CARDS ' + cardTexts.map(c => flatString(c)).join('|'));
2304
- if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
2311
+ if (cardTexts.length > 0) lines.push('CARDS' + _formatAppendArgs(cardTexts.map(c => flatString(c))));
2312
+ if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(c.buttons.filter(b => b.text).map(b => flatString(b.text))));
2305
2313
  if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
2306
2314
  });
2307
2315
  }
2308
2316
 
2309
2317
  step.asserters && step.asserters.forEach(asserter => {
2310
- lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + (asserter.args ? ' ' + asserter.args.join('|') : ''));
2318
+ lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + _formatAppendArgs(asserter.args));
2311
2319
  });
2312
2320
  step.logicHooks && step.logicHooks.forEach(logicHook => {
2313
- lines.push(logicHook.name + (logicHook.args ? ' ' + logicHook.args.join('|') : ''));
2321
+ lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
2314
2322
  });
2315
2323
  }
2316
2324
 
@@ -3436,7 +3444,7 @@ class Convo$6 {
3436
3444
  const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
3437
3445
 
3438
3446
  if (transcriptStepErrs && transcriptStepErrs.length > 0) {
3439
- transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
3447
+ transcript.err = botiumErrorFromList$1([...transcriptStepErrs.filter(err => err !== transcript.err), transcript.err].filter(e => e), {});
3440
3448
  }
3441
3449
  }
3442
3450
  }