botium-core 1.14.3 → 1.14.5

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-es.js CHANGED
@@ -10,7 +10,7 @@ import randomatic from 'randomatic';
10
10
  import lodash from 'lodash';
11
11
  import boolean$1 from 'boolean';
12
12
  import events from 'events';
13
- import debug$n from 'debug';
13
+ import debug$o from 'debug';
14
14
  import isClass from 'is-class';
15
15
  import crypto from 'crypto';
16
16
  import globby from 'globby';
@@ -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.3";
38
+ var version$1 = "1.14.5";
39
39
  var description = "The Selenium for Chatbots";
40
40
  var main = "index.js";
41
41
  var module = "dist/botium-es.js";
@@ -1062,7 +1062,7 @@ LogicHookConsts.DEFAULT_LOGIC_HOOKS;
1062
1062
  LogicHookConsts.DEFAULT_USER_INPUTS;
1063
1063
  LogicHookConsts.LOGIC_HOOK_EVENTS;
1064
1064
 
1065
- const debug$m = debug$n('botium-core-asserterUtils');
1065
+ const debug$n = debug$o('botium-core-asserterUtils');
1066
1066
  const {
1067
1067
  DEFAULT_ASSERTERS,
1068
1068
  DEFAULT_LOGIC_HOOKS,
@@ -1114,7 +1114,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1114
1114
  _fetchAsserters() {
1115
1115
  this.caps[Capabilities.ASSERTERS].forEach(asserter => {
1116
1116
  if (this.asserters[asserter.ref]) {
1117
- debug$m(`${asserter.ref} asserter already exists, overwriting.`);
1117
+ debug$n(`${asserter.ref} asserter already exists, overwriting.`);
1118
1118
  }
1119
1119
  this.asserters[asserter.ref] = this._loadClass(asserter, 'asserter');
1120
1120
  if (asserter.global) {
@@ -1125,7 +1125,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1125
1125
  _fetchLogicHooks() {
1126
1126
  this.caps[Capabilities.LOGIC_HOOKS].forEach(logicHook => {
1127
1127
  if (this.logicHooks[logicHook.ref]) {
1128
- debug$m(`${logicHook.ref} logic hook already exists, overwriting.`);
1128
+ debug$n(`${logicHook.ref} logic hook already exists, overwriting.`);
1129
1129
  }
1130
1130
  this.logicHooks[logicHook.ref] = this._loadClass(logicHook, 'logichook');
1131
1131
  if (logicHook.global) {
@@ -1136,7 +1136,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1136
1136
  _fetchUserInputs() {
1137
1137
  this.caps[Capabilities.USER_INPUTS].forEach(userInput => {
1138
1138
  if (this.userInputs[userInput.ref]) {
1139
- debug$m(`${userInput.ref} userinput already exists, overwriting.`);
1139
+ debug$n(`${userInput.ref} userinput already exists, overwriting.`);
1140
1140
  }
1141
1141
  this.userInputs[userInput.ref] = this._loadClass(userInput, 'userinput');
1142
1142
  });
@@ -1322,7 +1322,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1322
1322
  }
1323
1323
  }
1324
1324
  }
1325
- loadErr.forEach(debug$m);
1325
+ loadErr.forEach(debug$n);
1326
1326
  }
1327
1327
  throw new Error(`${typeAsText} specification ${ref} ${hookType} from "${util.inspect(src)}" invalid : no loader available`);
1328
1328
  }
@@ -1533,10 +1533,11 @@ var Enums = {
1533
1533
  };
1534
1534
  Enums.E_SCRIPTING_MEMORY_COLUMN_MODE;
1535
1535
 
1536
- const debug$l = debug$n('botium-core-scripting-helper');
1536
+ const debug$m = debug$o('botium-core-scripting-helper');
1537
1537
  const {
1538
1538
  E_SCRIPTING_MEMORY_COLUMN_MODE: E_SCRIPTING_MEMORY_COLUMN_MODE$1
1539
1539
  } = Enums;
1540
+ const WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END = /[\n\t\r]+$/;
1540
1541
  const normalizeText$1 = (str, doCleanup) => {
1541
1542
  if (str && lodash.isArray(str)) {
1542
1543
  str = str.join(' ');
@@ -1778,7 +1779,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1778
1779
  if (eol === null) {
1779
1780
  throw new Error('eol cant be null');
1780
1781
  }
1781
- convoStep.messageText = textLines.join(eol).trim();
1782
+ convoStep.messageText = trimExceptSpaceEnd$1(textLines.join(eol));
1782
1783
  }
1783
1784
  }
1784
1785
  } else {
@@ -1799,6 +1800,9 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1799
1800
  }
1800
1801
  return convoStep;
1801
1802
  };
1803
+ const trimExceptSpaceEnd$1 = string => {
1804
+ return string?.replace(WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END, '');
1805
+ };
1802
1806
  const convoStepToObject$1 = step => {
1803
1807
  const result = [];
1804
1808
  if (step.sender === 'me') {
@@ -1995,7 +1999,7 @@ const convoStepToLines$2 = step => {
1995
1999
  lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
1996
2000
  });
1997
2001
  }
1998
- return lines.map(l => l.trim());
2002
+ return lines;
1999
2003
  };
2000
2004
  const linesToScriptingMemories$2 = (lines, columnMode = null) => {
2001
2005
  const guessScriptingMemoryColumnMode = lines => {
@@ -2109,7 +2113,7 @@ const calculateWer$2 = (str, pattern) => {
2109
2113
  errCount += err.filter(err => err === true).length;
2110
2114
  allCount += err.length;
2111
2115
  }
2112
- debug$l(`Word Error Rate Asserter - Compared Bot Message '${botMessage}' / '${utt}': ${(errCount / allCount).toFixed(2)}`);
2116
+ debug$m(`Word Error Rate Asserter - Compared Bot Message '${botMessage}' / '${utt}': ${(errCount / allCount).toFixed(2)}`);
2113
2117
  return (errCount / allCount).toFixed(2);
2114
2118
  };
2115
2119
  const toPercent$1 = s => `${(s * 100).toFixed(0)}%`;
@@ -2128,7 +2132,8 @@ var helper = {
2128
2132
  validateConvo: validateConvo$2,
2129
2133
  linesToScriptingMemories: linesToScriptingMemories$2,
2130
2134
  calculateWer: calculateWer$2,
2131
- toPercent: toPercent$1
2135
+ toPercent: toPercent$1,
2136
+ trimExceptSpaceEnd: trimExceptSpaceEnd$1
2132
2137
  };
2133
2138
 
2134
2139
  const BotiumError$4 = class BotiumError extends Error {
@@ -2307,7 +2312,7 @@ var BotiumError_1 = {
2307
2312
  botiumErrorFromList: botiumErrorFromList$2
2308
2313
  };
2309
2314
 
2310
- const debug$k = debug$n('botium-core-ScriptingMemory');
2315
+ const debug$l = debug$o('botium-core-ScriptingMemory');
2311
2316
  const {
2312
2317
  v1: uuidv1
2313
2318
  } = uuid;
@@ -2567,7 +2572,7 @@ const extractVarNames = text => {
2567
2572
  return (lodash.isString(text) ? text.match(/\$[A-Za-z]\w+/g) : false) || [];
2568
2573
  };
2569
2574
  const fill = (container, scriptingMemory, result, utterance, scriptingEvents) => {
2570
- debug$k(`fill start: ${util.inspect(scriptingMemory)}`);
2575
+ debug$l(`fill start: ${util.inspect(scriptingMemory)}`);
2571
2576
  let varRegex;
2572
2577
  switch (container.caps[Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]) {
2573
2578
  case 'word':
@@ -2601,14 +2606,14 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
2601
2606
  if (i <= varMatches.length) {
2602
2607
  const varName = varMatches[i - 1];
2603
2608
  if (RESERVED_WORDS.indexOf(varName) >= 0) {
2604
- debug$k(`fill Variable "${varName}" is not overwritten, because it is reserved word. `);
2609
+ debug$l(`fill Variable "${varName}" is not overwritten, because it is reserved word. `);
2605
2610
  } else {
2606
2611
  scriptingMemory[varName] = resultMatches[i];
2607
2612
  }
2608
2613
  }
2609
2614
  }
2610
2615
  });
2611
- debug$k(`fill end: ${util.inspect(scriptingMemory)}`);
2616
+ debug$l(`fill end: ${util.inspect(scriptingMemory)}`);
2612
2617
  }
2613
2618
  };
2614
2619
  var ScriptingMemory = {
@@ -2626,7 +2631,7 @@ ScriptingMemory.extractVarNames;
2626
2631
  ScriptingMemory.RESERVED_WORDS;
2627
2632
  ScriptingMemory.SCRIPTING_FUNCTIONS;
2628
2633
 
2629
- const debug$j = debug$n('botium-core-Convo');
2634
+ const debug$k = debug$o('botium-core-Convo');
2630
2635
  const {
2631
2636
  BotiumError: BotiumError$2,
2632
2637
  botiumErrorFromErr: botiumErrorFromErr$1,
@@ -2780,10 +2785,10 @@ class TranscriptError extends Error {
2780
2785
  class Convo$6 {
2781
2786
  constructor(context, fromJson = {}) {
2782
2787
  if (fromJson instanceof Convo$6) {
2783
- debug$j('Illegal state!!! Parameter should be a JSON, but it is a Convo');
2788
+ debug$k('Illegal state!!! Parameter should be a JSON, but it is a Convo');
2784
2789
  } else if (fromJson.beginAsserter) {
2785
2790
  // beginAsserter is one of the fields which are lost
2786
- debug$j('Illegal state!!! Parameter should be a native JSON, but looks as a Convo converted to JSON');
2791
+ debug$k('Illegal state!!! Parameter should be a native JSON, but looks as a Convo converted to JSON');
2787
2792
  }
2788
2793
  this.scriptingEvents = context.scriptingEvents;
2789
2794
  this.context = context;
@@ -2947,7 +2952,7 @@ class Convo$6 {
2947
2952
  try {
2948
2953
  params = JSON.parse(rawConvoStepParameters[0]);
2949
2954
  } catch (e) {
2950
- debug$j(`${this.header.name}/${convoStep.stepTag}: Failed to parse convo step parameters from JSON ${rawConvoStepParameters[0]}`);
2955
+ debug$k(`${this.header.name}/${convoStep.stepTag}: Failed to parse convo step parameters from JSON ${rawConvoStepParameters[0]}`);
2951
2956
  }
2952
2957
  }
2953
2958
  if (!params || !Object.keys(params).length) {
@@ -2960,7 +2965,7 @@ class Convo$6 {
2960
2965
  const value = param.substring(semicolon + 1);
2961
2966
  params[name] = value;
2962
2967
  } catch (e) {
2963
- debug$j(`${this.header.name}/${convoStep.stepTag}: Failed to parse convo step parameter from arg ${param}`);
2968
+ debug$k(`${this.header.name}/${convoStep.stepTag}: Failed to parse convo step parameter from arg ${param}`);
2964
2969
  }
2965
2970
  }
2966
2971
  }
@@ -2976,7 +2981,7 @@ class Convo$6 {
2976
2981
  }
2977
2982
  }
2978
2983
  if (Object.keys(convoStepParameters).length) {
2979
- debug$j(`${this.header.name}: using convo step parameters ${JSON.stringify(convoStepParameters)}`);
2984
+ debug$k(`${this.header.name}: using convo step parameters ${JSON.stringify(convoStepParameters)}`);
2980
2985
  }
2981
2986
  const currentStepIndex = i;
2982
2987
  container.eventEmitter.emit(Events.CONVO_STEP_NEXT, container, convoStep, i);
@@ -3039,7 +3044,7 @@ class Convo$6 {
3039
3044
  });
3040
3045
  await this._checkBotRepliesConsumed(container);
3041
3046
  const coreMsg = lodash.omit(removeBuffers(meMsg), ['sourceData']);
3042
- debug$j(`${this.header.name}/${convoStep.stepTag}: user says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
3047
+ debug$k(`${this.header.name}/${convoStep.stepTag}: user says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
3043
3048
  await new Promise(resolve => {
3044
3049
  if (container.caps[Capabilities.SIMULATE_WRITING_SPEED] && meMsg.messageText && meMsg.messageText.length) {
3045
3050
  setTimeout(() => resolve(), container.caps[Capabilities.SIMULATE_WRITING_SPEED] * meMsg.messageText.length);
@@ -3075,7 +3080,7 @@ class Convo$6 {
3075
3080
  });
3076
3081
  continue;
3077
3082
  } else {
3078
- debug$j(`${this.header.name}/${convoStep.stepTag}: message not found in #me section, message not sent to container ${util.inspect(convoStep)}`);
3083
+ debug$k(`${this.header.name}/${convoStep.stepTag}: message not found in #me section, message not sent to container ${util.inspect(convoStep)}`);
3079
3084
  transcriptStep.botEnd = new Date();
3080
3085
  await this.scriptingEvents.onMeEnd({
3081
3086
  convo: this,
@@ -3091,7 +3096,7 @@ class Convo$6 {
3091
3096
  } catch (err) {
3092
3097
  transcriptStep.botEnd = new Date();
3093
3098
  const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: error sending to bot - ${err.message || err}`, err);
3094
- debug$j(failErr);
3099
+ debug$k(failErr);
3095
3100
  try {
3096
3101
  this.scriptingEvents.fail && this.scriptingEvents.fail(failErr);
3097
3102
  } catch (failErr) {}
@@ -3104,7 +3109,7 @@ class Convo$6 {
3104
3109
  waitForBotSays = true;
3105
3110
  }
3106
3111
  try {
3107
- debug$j(`${this.header.name} wait for bot ${convoStep.channel || ''}`);
3112
+ debug$k(`${this.header.name} wait for bot ${convoStep.channel || ''}`);
3108
3113
  await this.scriptingEvents.onBotStart({
3109
3114
  convo: this,
3110
3115
  convoStep,
@@ -3120,11 +3125,11 @@ class Convo$6 {
3120
3125
  transcriptStep.botEnd = new Date();
3121
3126
  transcriptStep.actual = new BotiumMockMessage_1(botMsg);
3122
3127
  const coreMsg = lodash.omit(removeBuffers(botMsg), ['sourceData']);
3123
- debug$j(`${this.header.name}: bot says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
3128
+ debug$k(`${this.header.name}: bot says (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
3124
3129
  } catch (err) {
3125
3130
  transcriptStep.botEnd = new Date();
3126
3131
  const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: error waiting for bot - ${err.message}`, err);
3127
- debug$j(failErr);
3132
+ debug$k(failErr);
3128
3133
  try {
3129
3134
  this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
3130
3135
  } catch (failErr) {}
@@ -3143,11 +3148,11 @@ class Convo$6 {
3143
3148
  if (prepared) {
3144
3149
  transcriptStep.actual = new BotiumMockMessage_1(botMsg);
3145
3150
  const coreMsg = lodash.omit(removeBuffers(botMsg), ['sourceData']);
3146
- debug$j(`${this.header.name}: onBotPrepare (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
3151
+ debug$k(`${this.header.name}: onBotPrepare (cleaned by binary and base64 data and sourceData) ${JSON.stringify(coreMsg, null, 2)}`);
3147
3152
  }
3148
3153
  } catch (err) {
3149
3154
  const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: onBotPrepare error - ${err.message || err}`, err);
3150
- debug$j(failErr);
3155
+ debug$k(failErr);
3151
3156
  try {
3152
3157
  this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
3153
3158
  } catch (failErr) {}
@@ -3168,7 +3173,7 @@ class Convo$6 {
3168
3173
  skipTranscriptStep = true;
3169
3174
  if (endOfConditionalGroup && !conditionMetInGroup && !convoStep.optional) {
3170
3175
  const failErr = new BotiumError$2(`${this.header.name}/${convoStep.stepTag}: Non of the conditions are met in ${conditionalGroupId ? `'${conditionalGroupId}' ` : ''}condition group`);
3171
- debug$j(failErr);
3176
+ debug$k(failErr);
3172
3177
  throw failErr;
3173
3178
  }
3174
3179
  if (endOfConditionalGroup) {
@@ -3188,7 +3193,7 @@ class Convo$6 {
3188
3193
  }
3189
3194
  if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
3190
3195
  const failErr = new BotiumError$2(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
3191
- debug$j(failErr);
3196
+ debug$k(failErr);
3192
3197
  try {
3193
3198
  this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
3194
3199
  } catch (failErr) {}
@@ -3200,7 +3205,7 @@ class Convo$6 {
3200
3205
  const retryOn = convoStep.sender === 'bot' && retryConfig && retryConfig.timeout && retryConfig.mainAsserter;
3201
3206
  if (convoStep.optional && nextConvoStep && nextConvoStep.sender === 'bot') {
3202
3207
  if (retryOn) {
3203
- debug$j(`${this.header.name}/${convoStep.stepTag}: Retry failed asserter is ignored on optional convo`);
3208
+ debug$k(`${this.header.name}/${convoStep.stepTag}: Retry failed asserter is ignored on optional convo`);
3204
3209
  }
3205
3210
  waitForBotSays = false;
3206
3211
  skipTranscriptStep = true;
@@ -3213,11 +3218,11 @@ class Convo$6 {
3213
3218
  const now = new Date().getTime();
3214
3219
  const timeoutRemaining = retryBotMessageTimeoutEnd - now;
3215
3220
  if (timeoutRemaining > 0) {
3216
- debug$j(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, timeout remaining: ${timeoutRemaining}, error: "${err.message}"`);
3221
+ debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, timeout remaining: ${timeoutRemaining}, error: "${err.message}"`);
3217
3222
  retryBotMessageDropBotResponse = true;
3218
3223
  return false;
3219
3224
  } else {
3220
- debug$j(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, but timeout is over. error: "${err.message}"`);
3225
+ debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, but timeout is over. error: "${err.message}"`);
3221
3226
  }
3222
3227
  }
3223
3228
  if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS]) {
@@ -3301,14 +3306,14 @@ class Convo$6 {
3301
3306
  const now = new Date().getTime();
3302
3307
  const timeoutRemaining = retryOn && retryBotMessageTimeoutEnd - now;
3303
3308
  if (retryOn && timeoutRemaining > 0) {
3304
- debug$j(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, timeout remaining: ${timeoutRemaining}, error: "${err.message}"`);
3309
+ debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, timeout remaining: ${timeoutRemaining}, error: "${err.message}"`);
3305
3310
  retryBotMessageDropBotResponse = true;
3306
3311
  } else {
3307
3312
  if (retryOn && timeoutRemaining <= 0) {
3308
- debug$j(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, but timeout is over. error: "${err.message}"`);
3313
+ debug$k(`${this.header.name}/${convoStep.stepTag}: Convo step retry on, but timeout is over. error: "${err.message}"`);
3309
3314
  }
3310
3315
  const failErr = botiumErrorFromErr$1(`${this.header.name}/${convoStep.stepTag}: assertion error - ${err.message || err}`, err);
3311
- debug$j(failErr);
3316
+ debug$k(failErr);
3312
3317
  try {
3313
3318
  this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
3314
3319
  } catch (failErr) {}
@@ -3332,7 +3337,7 @@ class Convo$6 {
3332
3337
  }
3333
3338
  } else {
3334
3339
  const failErr = new BotiumError$2(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util.inspect(convoStep.sender)}`);
3335
- debug$j(failErr);
3340
+ debug$k(failErr);
3336
3341
  try {
3337
3342
  this.scriptingEvents.fail && this.scriptingEvents.fail(failErr);
3338
3343
  } catch (failErr) {}
@@ -3538,7 +3543,7 @@ class Convo$6 {
3538
3543
  throw new BotiumError$2(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
3539
3544
  }
3540
3545
  _getEffectiveConversationRecursive(partialConvo.conversation, [...parentPConvos, includeLogicHook], result, true);
3541
- debug$j(`Partial convo ${includeLogicHook} included`);
3546
+ debug$k(`Partial convo ${includeLogicHook} included`);
3542
3547
  });
3543
3548
  });
3544
3549
  return result;
@@ -3559,7 +3564,7 @@ var Convo_1 = {
3559
3564
  TranscriptError
3560
3565
  };
3561
3566
 
3562
- const debug$i = debug$n('botium-core-RetryHelper');
3567
+ const debug$j = debug$o('botium-core-RetryHelper');
3563
3568
  var RetryHelper_1 = class RetryHelper {
3564
3569
  constructor(caps, section, options = {}) {
3565
3570
  this.retryErrorPatterns = [];
@@ -3583,7 +3588,7 @@ var RetryHelper_1 = class RetryHelper {
3583
3588
  minTimeout: caps[`RETRY_${section.toUpperCase()}_MINTIMEOUT`] || (lodash.isNil(options.minTimeout) ? 1000 : options.minTimeout)
3584
3589
  };
3585
3590
  if (this.retrySettings.retries > 0) {
3586
- debug$i(`Retry for ${section} is enabled. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`);
3591
+ debug$j(`Retry for ${section} is enabled. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`);
3587
3592
  }
3588
3593
  }
3589
3594
  shouldRetry(err) {
@@ -3597,26 +3602,36 @@ var RetryHelper_1 = class RetryHelper {
3597
3602
  }
3598
3603
  };
3599
3604
 
3605
+ const debug$i = debug$o('botium-core-MatchFunctions');
3600
3606
  const {
3601
3607
  toString,
3602
3608
  quoteRegexpString,
3603
3609
  calculateWer: calculateWer$1
3604
3610
  } = helper;
3605
- const _normalize = botresponse => {
3611
+ const _normalize = (botresponse, args, convoStepParameters) => {
3612
+ if (!convoStepParameters) {
3613
+ debug$i('Convo step parameters might be missing!');
3614
+ }
3606
3615
  if (lodash.isUndefined(botresponse) || lodash.isNil(botresponse)) return '';
3607
3616
  if (lodash.isObject(botresponse) && lodash.has(botresponse, 'messageText')) {
3608
3617
  return toString(botresponse.messageText) || '';
3609
3618
  }
3610
3619
  return toString(botresponse);
3611
3620
  };
3612
- const regexp = ignoreCase => (botresponse, utterance) => {
3621
+ const regexp = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
3622
+ if (!convoStepParameters) {
3623
+ debug$i('Convo step parameters might be missing!');
3624
+ }
3613
3625
  if (lodash.isUndefined(botresponse)) return false;
3614
3626
  utterance = toString(utterance);
3615
3627
  botresponse = _normalize(botresponse);
3616
3628
  const regexp = ignoreCase ? new RegExp(utterance, 'i') : new RegExp(utterance, '');
3617
3629
  return regexp.test(botresponse);
3618
3630
  };
3619
- const wildcard = ignoreCase => (botresponse, utterance) => {
3631
+ const wildcard = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
3632
+ if (!convoStepParameters) {
3633
+ debug$i('Convo step parameters might be missing!');
3634
+ }
3620
3635
  if (lodash.isUndefined(botresponse)) {
3621
3636
  if (utterance.trim() === '*') return true;else return false;
3622
3637
  }
@@ -3630,7 +3645,10 @@ const wildcard = ignoreCase => (botresponse, utterance) => {
3630
3645
  const regexp = ignoreCase ? new RegExp(utteranceRe, 'i') : new RegExp(utteranceRe, '');
3631
3646
  return regexp.test(botresponse);
3632
3647
  };
3633
- const wildcardExact = ignoreCase => (botresponse, utterance) => {
3648
+ const wildcardExact = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
3649
+ if (!convoStepParameters) {
3650
+ debug$i('Convo step parameters might be missing!');
3651
+ }
3634
3652
  if (lodash.isUndefined(botresponse)) {
3635
3653
  if (utterance.trim() === '*') return true;else return false;
3636
3654
  }
@@ -3644,7 +3662,10 @@ const wildcardExact = ignoreCase => (botresponse, utterance) => {
3644
3662
  const regexp = ignoreCase ? new RegExp(utteranceRe, 'i') : new RegExp(utteranceRe, '');
3645
3663
  return regexp.test(botresponse);
3646
3664
  };
3647
- const include = ignoreCase => (botresponse, utterance) => {
3665
+ const include = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
3666
+ if (!convoStepParameters) {
3667
+ debug$i('Convo step parameters might be missing!');
3668
+ }
3648
3669
  if (lodash.isUndefined(botresponse)) return false;
3649
3670
  utterance = toString(utterance);
3650
3671
  botresponse = _normalize(botresponse);
@@ -3654,7 +3675,10 @@ const include = ignoreCase => (botresponse, utterance) => {
3654
3675
  }
3655
3676
  return botresponse.indexOf(utterance) >= 0;
3656
3677
  };
3657
- const equals = ignoreCase => (botresponse, utterance) => {
3678
+ const equals = ignoreCase => (botresponse, utterance, args, convoStepParameters) => {
3679
+ if (!convoStepParameters) {
3680
+ debug$i('Convo step parameters might be missing!');
3681
+ }
3658
3682
  if (lodash.isUndefined(botresponse)) return false;
3659
3683
  utterance = toString(utterance);
3660
3684
  botresponse = _normalize(botresponse);
@@ -3664,10 +3688,13 @@ const equals = ignoreCase => (botresponse, utterance) => {
3664
3688
  }
3665
3689
  return botresponse === utterance;
3666
3690
  };
3667
- const wer = () => (botresponse, utterance, args) => {
3691
+ const wer = () => (botresponse, utterance, args, convoStepParameters) => {
3692
+ if (!convoStepParameters) {
3693
+ debug$i('Convo step parameters might be missing!');
3694
+ }
3668
3695
  botresponse = _normalize(botresponse || '');
3669
3696
  utterance = toString(utterance || '');
3670
- const threshold = [',', '.'].find(p => `${args[0]}`.includes(p)) ? parseFloat(args[0]) : parseInt(args[0]) / 100;
3697
+ const threshold = !lodash.isNil(convoStepParameters?.matchingModeWer) ? convoStepParameters?.matchingModeWer / 100 : [',', '.'].find(p => `${args[0]}`.includes(p)) ? parseFloat(args[0]) : parseInt(args[0]) / 100;
3671
3698
  return calculateWer$1(botresponse, utterance) <= threshold;
3672
3699
  };
3673
3700
  const getMatchFunction$1 = matchingMode => {
@@ -3870,7 +3897,7 @@ var JsonToJson = {
3870
3897
  precompile: precompile$2
3871
3898
  };
3872
3899
 
3873
- const debug$h = debug$n('botium-core-HookUtils');
3900
+ const debug$h = debug$o('botium-core-HookUtils');
3874
3901
  const executeHook$2 = async (caps, hook, ...args) => {
3875
3902
  return executeHookSync$1(caps, hook, ...args);
3876
3903
  };
@@ -3970,7 +3997,7 @@ var Script = {
3970
3997
  precompile: precompile$1
3971
3998
  };
3972
3999
 
3973
- const debug$g = debug$n('botium-core-PrecompilerMarkdownRasa');
4000
+ const debug$g = debug$o('botium-core-PrecompilerMarkdownRasa');
3974
4001
  const htmlCommentRegexp = /(<!--.*?-->)/g;
3975
4002
  var precompile = (caps, scriptBuffer, options, filename) => {
3976
4003
  if (!filename.endsWith('.md')) {
@@ -4071,7 +4098,7 @@ var MarkdownRasa = {
4071
4098
  precompile: precompile
4072
4099
  };
4073
4100
 
4074
- const debug$f = debug$n('botium-core-CapabilitiesUtils');
4101
+ const debug$f = debug$o('botium-core-CapabilitiesUtils');
4075
4102
  const {
4076
4103
  toJsonWeak
4077
4104
  } = Utils;
@@ -4162,7 +4189,7 @@ var CapabilitiesUtils = {
4162
4189
  flatCababilities: flatCababilities$1
4163
4190
  };
4164
4191
 
4165
- const debug$e = debug$n('botium-core-Precompilers');
4192
+ const debug$e = debug$o('botium-core-Precompilers');
4166
4193
  const {
4167
4194
  isJsonObject
4168
4195
  } = Utils;
@@ -4289,7 +4316,7 @@ var Utterance_1 = class Utterance {
4289
4316
  }
4290
4317
  };
4291
4318
 
4292
- const debug$d = debug$n('botium-core-CompilerXlsx');
4319
+ const debug$d = debug$o('botium-core-CompilerXlsx');
4293
4320
  const {
4294
4321
  E_SCRIPTING_MEMORY_COLUMN_MODE
4295
4322
  } = Enums;
@@ -4802,7 +4829,8 @@ const {
4802
4829
  convoStepToLines,
4803
4830
  validateConvo,
4804
4831
  validSenders: validSenders$2,
4805
- linesToScriptingMemories: linesToScriptingMemories$1
4832
+ linesToScriptingMemories: linesToScriptingMemories$1,
4833
+ trimExceptSpaceEnd
4806
4834
  } = helper;
4807
4835
  var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
4808
4836
  constructor(context, caps = {}) {
@@ -4826,7 +4854,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
4826
4854
  Compile(scriptBuffer, scriptType = Constants.SCRIPTING_TYPE_CONVO) {
4827
4855
  let scriptData = scriptBuffer;
4828
4856
  if (Buffer.isBuffer(scriptBuffer)) scriptData = scriptData.toString();
4829
- const lines = lodash.map(scriptData.split(this.eol), line => line.trim());
4857
+ const lines = scriptData.split(this.eol);
4830
4858
  if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
4831
4859
  return this._compileConvo(lines, false);
4832
4860
  } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
@@ -4876,7 +4904,6 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
4876
4904
  };
4877
4905
  lines.forEach(line => {
4878
4906
  currentLineIndex++;
4879
- line = line.trim();
4880
4907
  if (isValidTagLine(line)) {
4881
4908
  pushPrev();
4882
4909
  convoStepSender = line.substr(1).trim();
@@ -4903,8 +4930,8 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
4903
4930
  _compileUtterances(lines) {
4904
4931
  if (lines && lines.length > 0) {
4905
4932
  const result = [new Utterance_1({
4906
- name: lines[0],
4907
- utterances: lines.length > 1 ? lines.slice(1) : []
4933
+ name: lines[0].trim(),
4934
+ utterances: lines.length > 1 ? lines.slice(1).map(line => trimExceptSpaceEnd(line)) : []
4908
4935
  })];
4909
4936
  this.context.AddUtterances(result);
4910
4937
  return result;
@@ -4952,7 +4979,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
4952
4979
  const {
4953
4980
  parse
4954
4981
  } = sync;
4955
- const debug$c = debug$n('botium-core-CompilerCsv');
4982
+ const debug$c = debug$o('botium-core-CompilerCsv');
4956
4983
  const {
4957
4984
  Convo: Convo$3
4958
4985
  } = Convo_1;
@@ -5163,7 +5190,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5163
5190
  }
5164
5191
  };
5165
5192
 
5166
- const debug$b = debug$n('botium-core-CompilerObject');
5193
+ const debug$b = debug$o('botium-core-CompilerObject');
5167
5194
  const {
5168
5195
  Convo: Convo$2
5169
5196
  } = Convo_1;
@@ -5309,7 +5336,7 @@ var CompilerJson_1 = class CompilerJson extends CompilerObjectBase_1 {
5309
5336
  }
5310
5337
  };
5311
5338
 
5312
- const debug$a = debug$n('botium-core-CompilerMarkdown');
5339
+ const debug$a = debug$o('botium-core-CompilerMarkdown');
5313
5340
  const md = new markdownIt();
5314
5341
  const {
5315
5342
  Convo: Convo$1
@@ -5388,7 +5415,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
5388
5415
  conversation.push(Object.assign({
5389
5416
  sender,
5390
5417
  stepTag: 'Line ' + (step.map[0] + 1)
5391
- }, linesToConvoStep(step.children.map(child => child.content + (child.children ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context, this.eol)));
5418
+ }, linesToConvoStep(step.children.map(child => child.content + (child.children && child.children.length > 0 ? ' ' + child.children.map(child => child.content).join('|') : '')), sender, this.context, this.eol)));
5392
5419
  } else {
5393
5420
  debug$a(`Expected sender ${validSenders.map(s => `'${s}'`).join(' or ')} but found ${sender}`);
5394
5421
  }
@@ -5420,7 +5447,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
5420
5447
  };
5421
5448
 
5422
5449
  promise.shim();
5423
- const debug$9 = debug$n('botium-core-ScriptingProvider');
5450
+ const debug$9 = debug$o('botium-core-ScriptingProvider');
5424
5451
  const {
5425
5452
  Convo,
5426
5453
  ConvoStep
@@ -5689,25 +5716,26 @@ var ScriptingProvider_1 = class ScriptingProvider {
5689
5716
  resolveEmptyIfUnknown
5690
5717
  });
5691
5718
  },
5692
- assertBotResponse: (botresponse, tomatch, stepTag, meMsg, convoStepParameters) => {
5719
+ assertBotResponse: (botresponse, tomatch, stepTag, meMsg, convoStepParameters = {}) => {
5693
5720
  if (!lodash.isArray(tomatch)) {
5694
5721
  tomatch = [tomatch];
5695
5722
  }
5696
5723
  debug$9(`assertBotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} = ${tomatch} ...`);
5697
5724
  const matchFn = convoStepParameters.matchingMode ? getMatchFunction(convoStepParameters.matchingMode) || this.matchFn : this.matchFn;
5698
- const found = lodash.find(tomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]));
5725
+ const found = lodash.find(tomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS], convoStepParameters));
5699
5726
  const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'Word Error Rate Asserter' : 'Text Match Asserter';
5700
5727
  if (lodash.isNil(found)) {
5701
- if (this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer') {
5728
+ const matchingMode = convoStepParameters.matchingMode || this.caps[Capabilities.SCRIPTING_MATCHING_MODE];
5729
+ if (matchingMode === 'wer') {
5702
5730
  const wer = calculateWer(botresponse, tomatch[0]);
5703
5731
  const werArgs = this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS];
5704
- const threshold = [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
5732
+ const threshold = !lodash.isNil(convoStepParameters.matchingModeWer) ? convoStepParameters.matchingModeWer / 100 : [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
5705
5733
  const message = `${stepTag}: Word Error Rate (${toPercent(wer)}) higher than accepted (${toPercent(threshold)})`;
5706
5734
  throw new BotiumError$1(message, {
5707
5735
  type: 'asserter',
5708
5736
  source: asserterType,
5709
5737
  params: {
5710
- matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE],
5738
+ matchingMode,
5711
5739
  args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
5712
5740
  },
5713
5741
  context: {
@@ -5745,25 +5773,26 @@ var ScriptingProvider_1 = class ScriptingProvider {
5745
5773
  }
5746
5774
  }
5747
5775
  },
5748
- assertBotNotResponse: (botresponse, nottomatch, stepTag, meMsg, convoStepParameters) => {
5776
+ assertBotNotResponse: (botresponse, nottomatch, stepTag, meMsg, convoStepParameters = {}) => {
5749
5777
  if (!lodash.isArray(nottomatch)) {
5750
5778
  nottomatch = [nottomatch];
5751
5779
  }
5752
5780
  debug$9(`assertBotNotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} != ${nottomatch} ...`);
5753
5781
  const matchFn = convoStepParameters.matchingMode ? getMatchFunction(convoStepParameters.matchingMode) || this.matchFn : this.matchFn;
5754
- const found = lodash.find(nottomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]));
5782
+ const found = lodash.find(nottomatch, utt => matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS], convoStepParameters));
5755
5783
  const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'Word Error Rate Asserter' : 'Text Match Asserter';
5756
5784
  if (!lodash.isNil(found)) {
5757
- if (this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer') {
5785
+ const matchingMode = convoStepParameters.matchingMode || this.caps[Capabilities.SCRIPTING_MATCHING_MODE];
5786
+ if (matchingMode === 'wer') {
5758
5787
  const wer = calculateWer(botresponse, nottomatch[0]);
5759
5788
  const werArgs = this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS];
5760
- const threshold = [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
5789
+ const threshold = !lodash.isNil(convoStepParameters.matchingModeWer) ? convoStepParameters.matchingModeWer / 100 : [',', '.'].find(p => `${werArgs[0]}`.includes(p)) ? parseFloat(werArgs[0]) : parseInt(werArgs[0]) / 100;
5761
5790
  const message = `${stepTag}: Word Error Rate (${toPercent(wer)}) lower than accepted (${toPercent(threshold)})`;
5762
5791
  throw new BotiumError$1(message, {
5763
5792
  type: 'asserter',
5764
5793
  source: asserterType,
5765
5794
  params: {
5766
- matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE],
5795
+ matchingMode,
5767
5796
  args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
5768
5797
  },
5769
5798
  context: {
@@ -6873,18 +6902,19 @@ var ScriptingProvider_1 = class ScriptingProvider {
6873
6902
  }
6874
6903
  if (utterances) {
6875
6904
  lodash.forEach(utterances, utt => {
6876
- const eu = this.utterances[utt.name];
6905
+ const uttName = utt.name?.trim();
6906
+ const eu = this.utterances[uttName];
6877
6907
  if (eu) {
6878
6908
  eu.utterances = lodash.uniq(lodash.concat(eu.utterances, utt.utterances));
6879
6909
  } else {
6880
- this.utterances[utt.name] = utt;
6910
+ this.utterances[uttName] = utt;
6881
6911
  }
6882
6912
  const {
6883
6913
  ambiguous,
6884
6914
  expected
6885
- } = findAmbiguous(this.utterances[utt.name].utterances);
6915
+ } = findAmbiguous(this.utterances[uttName].utterances);
6886
6916
  if (ambiguous && ambiguous.length > 0) {
6887
- debug$9(`Ambigous utterance "${utt.name}", expecting exact ${expected.length ? '"' + expected.join(', ') + '"' : '<none>'} scripting memory variables in following user examples: ${ambiguous.map(d => `"${d}"`).join(', ')}`);
6917
+ debug$9(`Ambigous utterance "${uttName}", expecting exact ${expected.length ? '"' + expected.join(', ') + '"' : '<none>'} scripting memory variables in following user examples: ${ambiguous.map(d => `"${d}"`).join(', ')}`);
6888
6918
  }
6889
6919
  });
6890
6920
  }
@@ -7129,7 +7159,7 @@ var NoRepo_1 = class NoRepo extends BaseRepo_1 {
7129
7159
  };
7130
7160
 
7131
7161
  var ProcessUtils = createCommonjsModule(function (module) {
7132
- const debug = debug$n('botium-core-ProcessUtils');
7162
+ const debug = debug$o('botium-core-ProcessUtils');
7133
7163
  module.exports = {
7134
7164
  childCommandLineRun: (cmd, ignoreErrors = false, processOptions = {}) => {
7135
7165
  const cmdOptions = cmd.split(' ');
@@ -7180,7 +7210,7 @@ var ProcessUtils = createCommonjsModule(function (module) {
7180
7210
  ProcessUtils.childCommandLineRun;
7181
7211
  ProcessUtils.childProcessRun;
7182
7212
 
7183
- const debug$8 = debug$n('botium-core-GitRepo');
7213
+ const debug$8 = debug$o('botium-core-GitRepo');
7184
7214
  var GitRepo_1 = class GitRepo extends BaseRepo_1 {
7185
7215
  Validate() {
7186
7216
  return super.Validate().then(() => {
@@ -7329,7 +7359,7 @@ var Queue_1 = class Queue {
7329
7359
  }
7330
7360
  };
7331
7361
 
7332
- const debug$7 = debug$n('botium-connector-BaseContainer');
7362
+ const debug$7 = debug$o('botium-connector-BaseContainer');
7333
7363
  const {
7334
7364
  executeHook: executeHook$1,
7335
7365
  getHook: getHook$1
@@ -7530,7 +7560,7 @@ var BaseContainer_1 = class BaseContainer {
7530
7560
  }
7531
7561
  };
7532
7562
 
7533
- const debug$6 = debug$n('botium-connector-GridContainer');
7563
+ const debug$6 = debug$o('botium-connector-GridContainer');
7534
7564
  var GridContainer_1 = class GridContainer extends BaseContainer_1 {
7535
7565
  Validate() {
7536
7566
  return super.Validate().then(() => {
@@ -7730,7 +7760,7 @@ var InProcessContainer_1 = class InProcessContainer extends BaseContainer_1 {
7730
7760
  }
7731
7761
  };
7732
7762
 
7733
- const debug$5 = debug$n('botium-core-inbound-proxy');
7763
+ const debug$5 = debug$o('botium-core-inbound-proxy');
7734
7764
  const buildRedisHandler = (redisurl, topic) => {
7735
7765
  const redis = new ioredis(redisurl);
7736
7766
  redis.on('connect', () => {
@@ -7808,7 +7838,7 @@ proxy.startProxy;
7808
7838
  const {
7809
7839
  v4: uuidv4
7810
7840
  } = uuid;
7811
- const debug$4 = debug$n('botium-connector-simplerest');
7841
+ const debug$4 = debug$o('botium-connector-simplerest');
7812
7842
  const {
7813
7843
  startProxy
7814
7844
  } = proxy;
@@ -8762,7 +8792,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8762
8792
  }
8763
8793
  };
8764
8794
 
8765
- const debug$3 = debug$n('botium-connector-PluginConnectorContainer-helper');
8795
+ const debug$3 = debug$o('botium-connector-PluginConnectorContainer-helper');
8766
8796
  const pluginResolver = containermode => {
8767
8797
  if (containermode === 'simplerest') {
8768
8798
  return SimpleRestContainer_1;
@@ -8890,7 +8920,7 @@ var plugins = {
8890
8920
  tryLoadPlugin: tryLoadPlugin$1
8891
8921
  };
8892
8922
 
8893
- const debug$2 = debug$n('botium-connector-PluginConnectorContainer');
8923
+ const debug$2 = debug$o('botium-connector-PluginConnectorContainer');
8894
8924
  const {
8895
8925
  tryLoadPlugin
8896
8926
  } = plugins;
@@ -9045,7 +9075,7 @@ const {
9045
9075
  const {
9046
9076
  boolean
9047
9077
  } = boolean$1;
9048
- const debug$1 = debug$n('botium-core-BotDriver');
9078
+ const debug$1 = debug$o('botium-core-BotDriver');
9049
9079
  const {
9050
9080
  version
9051
9081
  } = require$$3;
@@ -9348,7 +9378,7 @@ var BotDriver_1 = class BotDriver {
9348
9378
  }
9349
9379
  };
9350
9380
 
9351
- const debug = debug$n('botium-core-Plugins');
9381
+ const debug = debug$o('botium-core-Plugins');
9352
9382
  const PLUGIN_TYPE_CONNECTOR = 'PLUGIN_TYPE_CONNECTOR';
9353
9383
  const PLUGIN_TYPE_ASSERTER = 'PLUGIN_TYPE_ASSERTER';
9354
9384
  const PLUGIN_TYPE_LOGICHOOK = 'PLUGIN_TYPE_LOGICHOOK';