botium-core 1.13.3 → 1.13.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
@@ -37,7 +37,7 @@ import express from 'express';
37
37
  import bodyParser from 'body-parser';
38
38
 
39
39
  var name = "botium-core";
40
- var version$1 = "1.13.3";
40
+ var version$1 = "1.13.5";
41
41
  var description = "The Selenium for Chatbots";
42
42
  var main = "index.js";
43
43
  var module = "dist/botium-es.js";
@@ -69,7 +69,7 @@ var bugs = {
69
69
  };
70
70
  var homepage = "https://www.botium.ai";
71
71
  var dependencies = {
72
- "@babel/runtime": "^7.18.6",
72
+ "@babel/runtime": "^7.19.0",
73
73
  async: "^3.2.4",
74
74
  "body-parser": "^1.20.0",
75
75
  boolean: "^3.2.0",
@@ -79,7 +79,7 @@ var dependencies = {
79
79
  esprima: "^4.0.1",
80
80
  express: "^4.18.1",
81
81
  globby: "11.0.4",
82
- ioredis: "^5.1.0",
82
+ ioredis: "^5.2.3",
83
83
  "is-class": "^0.0.9",
84
84
  "is-json": "^2.0.1",
85
85
  jsonpath: "^1.1.1",
@@ -96,13 +96,13 @@ var dependencies = {
96
96
  rimraf: "^3.0.2",
97
97
  "sanitize-filename": "^1.6.3",
98
98
  slugify: "^1.6.5",
99
- "socket.io": "^4.5.1",
100
- "socket.io-client": "^4.5.1",
99
+ "socket.io": "^4.5.2",
100
+ "socket.io-client": "^4.5.2",
101
101
  "socketio-auth": "^0.1.1",
102
- "swagger-jsdoc": "^6.2.1",
103
- "swagger-ui-express": "^4.4.0",
104
- uuid: "^8.3.2",
105
- vm2: "^3.9.10",
102
+ "swagger-jsdoc": "^6.2.5",
103
+ "swagger-ui-express": "^4.5.0",
104
+ uuid: "^9.0.0",
105
+ vm2: "^3.9.11",
106
106
  "word-error-rate": "0.0.7",
107
107
  "write-yaml": "^1.0.0",
108
108
  xlsx: "^0.18.5",
@@ -110,27 +110,27 @@ var dependencies = {
110
110
  yaml: "^2.1.1"
111
111
  };
112
112
  var devDependencies = {
113
- "@babel/core": "^7.18.6",
114
- "@babel/node": "^7.18.6",
115
- "@babel/plugin-transform-runtime": "^7.18.6",
116
- "@babel/preset-env": "^7.18.6",
113
+ "@babel/core": "^7.19.3",
114
+ "@babel/node": "^7.19.1",
115
+ "@babel/plugin-transform-runtime": "^7.19.1",
116
+ "@babel/preset-env": "^7.19.3",
117
117
  chai: "^4.3.6",
118
118
  "chai-as-promised": "^7.1.1",
119
119
  "cross-env": "^7.0.3",
120
- eslint: "^8.19.0",
120
+ eslint: "^8.24.0",
121
121
  "eslint-config-standard": "^17.0.0",
122
122
  "eslint-plugin-import": "^2.26.0",
123
123
  "eslint-plugin-mocha": "^10.1.0",
124
- "eslint-plugin-n": "^15.2.4",
125
- "eslint-plugin-promise": "^6.0.0",
124
+ "eslint-plugin-n": "^15.3.0",
125
+ "eslint-plugin-promise": "^6.0.1",
126
126
  "eslint-plugin-standard": "^4.1.0",
127
127
  "license-checker": "^25.0.1",
128
128
  "license-compatibility-checker": "^0.3.5",
129
129
  mocha: "^10.0.0",
130
- nock: "^13.2.8",
131
- "npm-check-updates": "^15.2.6",
130
+ nock: "^13.2.9",
131
+ "npm-check-updates": "^16.3.4",
132
132
  nyc: "^15.1.0",
133
- rollup: "^2.76.0",
133
+ rollup: "^2.79.1",
134
134
  "rollup-plugin-babel": "^4.4.0",
135
135
  "rollup-plugin-commonjs": "^10.1.0",
136
136
  "rollup-plugin-json": "^4.0.0",
@@ -307,6 +307,8 @@ var Capabilities = {
307
307
  SCRIPTING_UTTEXPANSION_MODE: 'SCRIPTING_UTTEXPANSION_MODE',
308
308
  SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 'SCRIPTING_UTTEXPANSION_RANDOM_COUNT',
309
309
  SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSION',
310
+ SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS',
311
+ SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS',
310
312
  SCRIPTING_UTTEXPANSION_USENAMEASINTENT: 'SCRIPTING_UTTEXPANSION_USENAMEASINTENT',
311
313
  // justLineTag, utterance
312
314
  SCRIPTING_UTTEXPANSION_NAMING_MODE: 'SCRIPTING_UTTEXPANSION_NAMING_MODE',
@@ -460,6 +462,8 @@ Capabilities.SCRIPTING_MATCHING_MODE_ARGS;
460
462
  Capabilities.SCRIPTING_UTTEXPANSION_MODE;
461
463
  Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT;
462
464
  Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION;
465
+ Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS;
466
+ Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS;
463
467
  Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT;
464
468
  Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE;
465
469
  Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX;
@@ -544,6 +548,10 @@ var Defaults$1 = {
544
548
  [Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]: 1,
545
549
  [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'justLineTag',
546
550
  [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: '16',
551
+ [Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION]: null,
552
+ [Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS]: [],
553
+ [Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS]: [],
554
+ [Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT]: false,
547
555
  [Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false,
548
556
  [Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: false,
549
557
  [Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: false,
@@ -1681,6 +1689,7 @@ class BotiumMockAsserter$1 {
1681
1689
  constructor(fromJson = {}) {
1682
1690
  this.name = fromJson.name;
1683
1691
  this.args = lodash.cloneDeep(fromJson.args);
1692
+ this.not = fromJson.not;
1684
1693
  }
1685
1694
 
1686
1695
  }
@@ -2262,6 +2271,8 @@ const convoStepToLines$2 = step => {
2262
2271
  lines.push('MEDIA ' + step.media[0].mediaUri);
2263
2272
  } else if (step.messageText) {
2264
2273
  lines.push(step.messageText);
2274
+ } else if (step.sourceData) {
2275
+ lines.push(JSON.stringify(step.sourceData, null, 2));
2265
2276
  }
2266
2277
 
2267
2278
  step.userInputs && step.userInputs.forEach(userInput => {
@@ -2454,6 +2465,34 @@ const SCRIPTING_FUNCTIONS_RAW = {
2454
2465
  $timestamp: () => {
2455
2466
  return Date.now();
2456
2467
  },
2468
+ $tomorrow: pattern => {
2469
+ if (pattern) {
2470
+ return moment().add(1, 'day').format(pattern);
2471
+ }
2472
+
2473
+ return moment().add(1, 'day').toDate().toLocaleDateString();
2474
+ },
2475
+ $yesterday: pattern => {
2476
+ if (pattern) {
2477
+ return moment().subtract(1, 'day').format(pattern);
2478
+ }
2479
+
2480
+ return moment().subtract(1, 'day').toDate().toLocaleDateString();
2481
+ },
2482
+ $date_add: (amount, unit, pattern) => {
2483
+ if (pattern) {
2484
+ return moment().add(amount, unit).format(pattern);
2485
+ }
2486
+
2487
+ return moment().add(amount, unit).toDate().toLocaleDateString();
2488
+ },
2489
+ $date_subtract: (amount, unit, pattern) => {
2490
+ if (pattern) {
2491
+ return moment().subtract(amount, unit).format(pattern);
2492
+ }
2493
+
2494
+ return moment().subtract(amount, unit).toDate().toLocaleDateString();
2495
+ },
2457
2496
  $year: () => {
2458
2497
  return new Date().getFullYear();
2459
2498
  },
@@ -2545,7 +2584,8 @@ const SCRIPTING_FUNCTIONS_RAW = {
2545
2584
  require: false,
2546
2585
  env: caps[Capabilities.SECURITY_ALLOW_UNSAFE] ? process.env : {},
2547
2586
  sandbox: {
2548
- caps
2587
+ caps,
2588
+ moment
2549
2589
  }
2550
2590
  });
2551
2591
  return vm.run(`module.exports = (${code})`);
@@ -2623,7 +2663,22 @@ const _apply = (scriptingMemory, str, caps, mockMsg) => {
2623
2663
  for (const match of matches) {
2624
2664
  if (match.indexOf('(') > 0) {
2625
2665
  const arg = match.substring(match.indexOf('(') + 1, match.lastIndexOf(')')).replace(/\\\)/g, ')');
2626
- str = str.replace(match, SCRIPTING_FUNCTIONS$1[key].handler(caps, arg, mockMsg));
2666
+ let args = [arg];
2667
+
2668
+ if (SCRIPTING_FUNCTIONS$1[key].numberOfArguments > 1) {
2669
+ args = arg.split(',');
2670
+ }
2671
+
2672
+ args = args.map(arg => {
2673
+ arg = arg.trim();
2674
+
2675
+ if (arg.startsWith('"') && arg.endsWith('"')) {
2676
+ return arg.substring(1, arg.length - 1);
2677
+ } else {
2678
+ return arg;
2679
+ }
2680
+ });
2681
+ str = str.replace(match, SCRIPTING_FUNCTIONS$1[key].handler(caps, ...args, mockMsg));
2627
2682
  } else {
2628
2683
  str = str.replace(match, SCRIPTING_FUNCTIONS$1[key].handler(caps));
2629
2684
  }
@@ -4822,7 +4877,8 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4822
4877
  convoResults.forEach(convo => {
4823
4878
  if (!convo.header.name) {
4824
4879
  convo.header.name = `${convo.header.sheetname}-${this.colnames[convo.header.colindex]}${formatRowIndex(convo.header.rowindex)}`;
4825
- }
4880
+ } // it is not used anymore?
4881
+
4826
4882
 
4827
4883
  convo.header.sort = convo.header.name;
4828
4884
  scriptResults.push(convo);
@@ -6888,6 +6944,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
6888
6944
 
6889
6945
  ExpandUtterancesToConvos({
6890
6946
  useNameAsIntent,
6947
+ incomprehensionIntents,
6948
+ incomprehensionUtts,
6891
6949
  incomprehensionUtt
6892
6950
  } = {}) {
6893
6951
  const expandedConvos = [];
@@ -6896,26 +6954,81 @@ var ScriptingProvider_1 = class ScriptingProvider {
6896
6954
  useNameAsIntent = !!this.caps[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT];
6897
6955
  }
6898
6956
 
6957
+ if (lodash.isUndefined(incomprehensionIntents)) {
6958
+ incomprehensionIntents = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS];
6959
+ }
6960
+
6961
+ if (lodash.isUndefined(incomprehensionUtts)) {
6962
+ incomprehensionUtts = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS];
6963
+ }
6964
+
6899
6965
  if (lodash.isUndefined(incomprehensionUtt)) {
6900
6966
  incomprehensionUtt = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION];
6901
6967
  }
6902
6968
 
6903
- if (useNameAsIntent && incomprehensionUtt) {
6904
- throw new Error('ExpandUtterancesToConvos - SCRIPTING_UTTEXPANSION_USENAMEASINTENT and SCRIPTING_UTTEXPANSION_INCOMPREHENSION are incompatible');
6969
+ if (incomprehensionUtt && (!incomprehensionUtts || incomprehensionUtts.length === 0) && !this.utterances[incomprehensionUtt]) {
6970
+ throw new Error(`ExpandUtterancesToConvos - incomprehension utterance '${incomprehensionUtt}' undefined (and no user examples given)`);
6905
6971
  }
6906
6972
 
6907
- if (incomprehensionUtt && !this.utterances[incomprehensionUtt]) {
6908
- throw new Error(`ExpandUtterancesToConvos - incomprehension utterance '${incomprehensionUtt}' undefined`);
6973
+ if (incomprehensionUtts && incomprehensionUtts.length > 0) {
6974
+ if (!incomprehensionUtt) {
6975
+ incomprehensionUtt = 'UTT_INCOMPREHENSION';
6976
+ }
6977
+
6978
+ if (this.utterances[incomprehensionUtt]) {
6979
+ this.utterances[incomprehensionUtt].utterances.push(...incomprehensionUtts);
6980
+ } else {
6981
+ this.utterances[incomprehensionUtt] = {
6982
+ name: incomprehensionUtt,
6983
+ utterances: [...incomprehensionUtts]
6984
+ };
6985
+ }
6909
6986
  }
6910
6987
 
6911
6988
  if (useNameAsIntent) {
6912
6989
  debug$9('ExpandUtterancesToConvos - Using utterance name as NLU intent');
6913
- } else if (incomprehensionUtt) {
6914
- debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}`);
6990
+ }
6991
+
6992
+ if (incomprehensionIntents && incomprehensionIntents.length > 0) {
6993
+ debug$9(`ExpandUtterancesToConvos - Using ${incomprehensionIntents.length} incomprehension NLU intent(s)`);
6994
+ }
6995
+
6996
+ if (incomprehensionUtt) {
6997
+ debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}, ${this.utterances[incomprehensionUtt].utterances.length} user example(s)`);
6915
6998
  }
6916
6999
 
6917
7000
  lodash.keys(this.utterances).filter(u => u !== incomprehensionUtt).forEach(uttName => {
6918
7001
  const utt = this.utterances[uttName];
7002
+ const responseStep = {
7003
+ sender: 'bot',
7004
+ messageText: '',
7005
+ asserters: [],
7006
+ stepTag: 'Step 2 - check bot response',
7007
+ not: false
7008
+ };
7009
+
7010
+ if (useNameAsIntent) {
7011
+ responseStep.asserters.push({
7012
+ name: 'INTENT',
7013
+ args: [utt.name]
7014
+ });
7015
+ }
7016
+
7017
+ if (incomprehensionIntents && incomprehensionIntents.length > 0) {
7018
+ incomprehensionIntents.forEach(ii => {
7019
+ responseStep.asserters.push({
7020
+ name: 'INTENT',
7021
+ args: [ii],
7022
+ not: true
7023
+ });
7024
+ });
7025
+ }
7026
+
7027
+ if (incomprehensionUtt) {
7028
+ responseStep.messageText = incomprehensionUtt;
7029
+ responseStep.not = true;
7030
+ }
7031
+
6919
7032
  expandedConvos.push(new Convo(this._buildScriptContext(), {
6920
7033
  header: {
6921
7034
  name: utt.name,
@@ -6928,25 +7041,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6928
7041
  }],
6929
7042
  messageText: utt.name,
6930
7043
  stepTag: 'Step 1 - tell utterance'
6931
- }, useNameAsIntent ? {
6932
- sender: 'bot',
6933
- asserters: [{
6934
- name: 'INTENT',
6935
- args: [utt.name]
6936
- }],
6937
- stepTag: 'Step 2 - check intent',
6938
- not: false
6939
- } : incomprehensionUtt ? {
6940
- sender: 'bot',
6941
- messageText: incomprehensionUtt,
6942
- stepTag: 'Step 2 - check incomprehension',
6943
- not: true
6944
- } : {
6945
- sender: 'bot',
6946
- messageText: '',
6947
- stepTag: 'Step 2 - check bot response',
6948
- not: false
6949
- }],
7044
+ }, responseStep],
6950
7045
  sourceTag: Object.assign({}, utt.sourceTag, {
6951
7046
  origUttName: utt.name
6952
7047
  })
@@ -6958,30 +7053,77 @@ var ScriptingProvider_1 = class ScriptingProvider {
6958
7053
  this._sortConvos();
6959
7054
  }
6960
7055
 
6961
- ExpandConvos() {
7056
+ ExpandConvos(options = {}) {
7057
+ options = Object.assign({
7058
+ // use skip and keep, or justHeader
7059
+ justHeader: false,
7060
+ // drop unwanted convos
7061
+ convoFilter: null
7062
+ }, options);
7063
+ const context = {
7064
+ count: 0
7065
+ };
6962
7066
  const expandedConvos = [];
6963
7067
  debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`);
6964
7068
  this.convos.forEach(convo => {
6965
7069
  convo.expandPartialConvos();
6966
7070
 
6967
- this._expandConvo(expandedConvos, convo);
7071
+ for (const expanded of this._expandConvo(convo, options, context)) {
7072
+ expanded.header.assertionCount = this.GetAssertionCount(expanded);
7073
+
7074
+ if (options.justHeader) {
7075
+ const ConvoWithOnlyHeader = {
7076
+ header: {
7077
+ name: expanded.header.name,
7078
+ assertionCount: expanded.header.assertionCount
7079
+ }
7080
+ };
7081
+ expandedConvos.push(ConvoWithOnlyHeader);
7082
+ } else {
7083
+ expandedConvos.push(expanded);
7084
+ }
7085
+ }
6968
7086
  });
6969
7087
  this.convos = expandedConvos;
6970
7088
 
6971
- this._sortConvos();
7089
+ if (!options.justHeader) {
7090
+ this._sortConvos();
7091
+ } else {
7092
+ this._updateConvos();
7093
+ }
7094
+ }
7095
+
7096
+ ExpandConvosIterable(options = {}) {
7097
+ options = Object.assign({
7098
+ // drop unwanted convos
7099
+ convoFilter: null
7100
+ }, options);
7101
+ debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`); // creating a nested generator, calling the other.
7102
+ // We hope this.convos does not changes while this iterator is used
7103
+
7104
+ const _convosIterable = function* (options) {
7105
+ const context = {
7106
+ count: 0
7107
+ };
7108
+
7109
+ for (const convo of this.convos) {
7110
+ convo.expandPartialConvos();
7111
+ yield* this._expandConvo(convo, options, context);
7112
+ }
7113
+ }.bind(this);
7114
+
7115
+ this.convosIterable = _convosIterable(options);
6972
7116
  }
6973
7117
  /**
6974
- *
6975
- * @param expandedConvos
7118
+ * This is a generator function with yield
6976
7119
  * @param currentConvo
6977
7120
  * @param convoStepIndex
6978
7121
  * @param convoStepsStack list of ConvoSteps
6979
- * @param context {width: }
6980
7122
  * @private
6981
7123
  */
6982
7124
 
6983
7125
 
6984
- _expandConvo(expandedConvos, currentConvo, convoStepIndex = 0, convoStepsStack = [], context = {}) {
7126
+ *_expandConvo(currentConvo, options, context, convoStepIndex = 0, convoStepsStack = []) {
6985
7127
  const utterancePostfix = (lineTag, uttOrUserInput) => {
6986
7128
  const naming = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE] || Defaults$1.capabilities[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE];
6987
7129
 
@@ -7007,8 +7149,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7007
7149
  if (currentStep.sender === 'bot' || currentStep.sender === 'begin' || currentStep.sender === 'end') {
7008
7150
  const currentStepsStack = convoStepsStack.slice();
7009
7151
  currentStepsStack.push(lodash.cloneDeep(currentStep));
7010
-
7011
- this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
7152
+ yield* this._expandConvo(currentConvo, options, context, convoStepIndex + 1, currentStepsStack);
7012
7153
  } else if (currentStep.sender === 'me') {
7013
7154
  let useUnexpanded = true;
7014
7155
 
@@ -7030,16 +7171,15 @@ var ScriptingProvider_1 = class ScriptingProvider {
7030
7171
  if (this.utterances[uttName]) {
7031
7172
  const allutterances = this.utterances[uttName].utterances;
7032
7173
 
7033
- const processSampleUtterances = (sampleutterances, myContext) => {
7034
- sampleutterances.forEach((utt, index) => {
7035
- processSampleUtterance(utt, sampleutterances.length, index, Object.assign({
7174
+ const processSampleUtterances = function* (sampleutterances, myContext) {
7175
+ for (let index = 0; index < sampleutterances.length; index++) {
7176
+ yield* processSampleUtterance(sampleutterances[index], sampleutterances.length, index, Object.assign({
7036
7177
  indexExpansionModeIndex: index
7037
7178
  }, myContext || context));
7038
- });
7179
+ }
7039
7180
  };
7040
7181
 
7041
- const processSampleUtterance = (sampleutterance, length, index, myContext) => {
7042
- const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7182
+ const processSampleUtterance = function* (sampleutterance, length, index, myContext) {
7043
7183
  const currentStepsStack = convoStepsStack.slice();
7044
7184
 
7045
7185
  if (uttArgs) {
@@ -7052,19 +7192,24 @@ var ScriptingProvider_1 = class ScriptingProvider {
7052
7192
 
7053
7193
  const currentConvoLabeled = lodash.cloneDeep(currentConvo);
7054
7194
 
7055
- Object.assign(currentConvoLabeled.header, {
7056
- name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, sampleutterance)}`
7057
- });
7195
+ if (length > 1) {
7196
+ const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7197
+ Object.assign(currentConvoLabeled.header, {
7198
+ name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, sampleutterance)}`
7199
+ });
7200
+ }
7201
+
7058
7202
  if (!currentConvoLabeled.sourceTag) currentConvoLabeled.sourceTag = {};
7059
7203
  if (!currentConvoLabeled.sourceTag.origConvoName) currentConvoLabeled.sourceTag.origConvoName = currentConvo.header.name;
7204
+ yield* this._expandConvo(currentConvoLabeled, options, myContext || context, convoStepIndex + 1, currentStepsStack);
7205
+ }.bind(this);
7060
7206
 
7061
- this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack, myContext || context);
7062
- };
7063
-
7064
- if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
7207
+ if (allutterances.length === 1) {
7208
+ yield* processSampleUtterances([allutterances[0]], context);
7209
+ } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
7065
7210
  if (lodash.isNil(context.indexExpansionModeWidth)) {
7066
7211
  // executed for the first found utterance
7067
- processSampleUtterances(allutterances, Object.assign({}, context, {
7212
+ yield* processSampleUtterances(allutterances, Object.assign({}, context, {
7068
7213
  indexExpansionModeWidth: allutterances.length
7069
7214
  }));
7070
7215
  } else {
@@ -7082,7 +7227,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7082
7227
  const myContext = Object.assign({}, context, {
7083
7228
  indexExpansionModeWidth: Math.max(allutterances.length, context.indexExpansionModeWidth)
7084
7229
  });
7085
- processSampleUtterance(allutterances[localIndex], allutterances.length, localIndex, myContext);
7230
+ yield* processSampleUtterance(allutterances[localIndex], allutterances.length, localIndex, myContext);
7086
7231
 
7087
7232
  if (allutterances.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
7088
7233
  debug$9(`While expanding convos by index found in utterance "${uttName}" more examples (${allutterances.length}) as expected (${context.indexExpansionModeWidth})`);
@@ -7093,20 +7238,20 @@ var ScriptingProvider_1 = class ScriptingProvider {
7093
7238
  indexExpansionModeWidth: allutterances.length,
7094
7239
  indexExpansionModeIndex: i
7095
7240
  });
7096
- processSampleUtterance(allutterances[i], allutterances.length, i, myContext);
7241
+ yield* processSampleUtterance(allutterances[i], allutterances.length, i, myContext);
7097
7242
  }
7098
7243
  }
7099
7244
  }
7100
7245
  } else {
7101
7246
  if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7102
- processSampleUtterances([allutterances[0]]);
7247
+ yield* processSampleUtterances([allutterances[0]], context);
7103
7248
  } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7104
- processSampleUtterances(allutterances.map(x => ({
7249
+ yield* processSampleUtterances(allutterances.map(x => ({
7105
7250
  x,
7106
7251
  r: Math.random()
7107
- })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]));
7252
+ })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]), context);
7108
7253
  } else {
7109
- processSampleUtterances(allutterances);
7254
+ yield* processSampleUtterances(allutterances, context);
7110
7255
  }
7111
7256
  }
7112
7257
 
@@ -7115,7 +7260,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
7115
7260
  }
7116
7261
 
7117
7262
  if (currentStep.userInputs && currentStep.userInputs.length > 0) {
7118
- currentStep.userInputs.forEach((ui, uiIndex) => {
7263
+ for (let uiIndex = 0; uiIndex < currentStep.userInputs.length; uiIndex++) {
7264
+ const ui = currentStep.userInputs[uiIndex];
7119
7265
  const userInput = this.userInputs[ui.name];
7120
7266
 
7121
7267
  if (userInput && userInput.expandConvo) {
@@ -7127,16 +7273,15 @@ var ScriptingProvider_1 = class ScriptingProvider {
7127
7273
 
7128
7274
  if (expandedUserInputs && expandedUserInputs.length > 0) {
7129
7275
  // let sampleinputs = expandedUserInputs
7130
- const processSampleInputs = (sampleinputs, myContext, uiIndex) => {
7131
- sampleinputs.forEach((input, index) => {
7132
- processSampleInput(input, sampleinputs.length, index, Object.assign({
7276
+ const processSampleInputs = function* (sampleinputs, myContext, uiIndex) {
7277
+ for (let index = 0; index < sampleinputs.length; index++) {
7278
+ yield* processSampleInput(sampleinputs[index], sampleinputs.length, index, Object.assign({
7133
7279
  indexExpansionModeIndex: index
7134
7280
  }, myContext || context), uiIndex);
7135
- });
7281
+ }
7136
7282
  };
7137
7283
 
7138
- const processSampleInput = (sampleinput, length, index, myContext, uiIndex) => {
7139
- const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7284
+ const processSampleInput = function* (sampleinput, length, index, myContext, uiIndex) {
7140
7285
  const currentStepsStack = convoStepsStack.slice();
7141
7286
 
7142
7287
  const currentStepMod = lodash.cloneDeep(currentStep);
@@ -7146,16 +7291,27 @@ var ScriptingProvider_1 = class ScriptingProvider {
7146
7291
 
7147
7292
  const currentConvoLabeled = lodash.cloneDeep(currentConvo);
7148
7293
 
7149
- Object.assign(currentConvoLabeled.header, {
7150
- name: `${currentConvo.header.name}/${ui.name}-${utterancePostfix(lineTag, sampleinput.args && sampleinput.args.length ? sampleinput.args.join(', ') : 'no-args')}`
7151
- });
7294
+ if (length > 1) {
7295
+ if (sampleinput.convoPostfix) {
7296
+ Object.assign(currentConvoLabeled.header, {
7297
+ name: `${currentConvo.header.name}/${ui.name}-${sampleinput.convoPostfix}`
7298
+ });
7299
+ } else {
7300
+ const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7301
+ Object.assign(currentConvoLabeled.header, {
7302
+ name: `${currentConvo.header.name}/${ui.name}-${utterancePostfix(lineTag, sampleinput.args && sampleinput.args.length ? sampleinput.args.join(', ') : 'no-args')}`
7303
+ });
7304
+ }
7305
+ }
7152
7306
 
7153
- this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack, myContext || context);
7154
- };
7307
+ yield* this._expandConvo(currentConvoLabeled, options, myContext || context, convoStepIndex + 1, currentStepsStack);
7308
+ }.bind(this);
7155
7309
 
7156
- if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
7310
+ if (expandedUserInputs.length === 1) {
7311
+ yield* processSampleInputs([expandedUserInputs[0]], context, uiIndex);
7312
+ } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
7157
7313
  if (lodash.isNil(context.indexExpansionModeWidth)) {
7158
- processSampleInputs(expandedUserInputs, Object.assign({}, context, {
7314
+ yield* processSampleInputs(expandedUserInputs, Object.assign({}, context, {
7159
7315
  indexExpansionModeWidth: expandedUserInputs.length
7160
7316
  }), uiIndex);
7161
7317
  } else {
@@ -7173,7 +7329,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7173
7329
  const myContext = Object.assign({}, context, {
7174
7330
  indexExpansionModeWidth: Math.max(expandedUserInputs.length, context.indexExpansionModeWidth)
7175
7331
  });
7176
- processSampleInput(expandedUserInputs[localIndex], expandedUserInputs.length, localIndex, myContext, uiIndex);
7332
+ yield* processSampleInput(expandedUserInputs[localIndex], expandedUserInputs.length, localIndex, myContext, uiIndex);
7177
7333
 
7178
7334
  if (expandedUserInputs.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
7179
7335
  debug$9(`While expanding convos by index found user input "${ui.name}, ${ui.args}" more examples (${expandedUserInputs.length}) as expected (${context.indexExpansionModeWidth})`);
@@ -7183,55 +7339,72 @@ var ScriptingProvider_1 = class ScriptingProvider {
7183
7339
  indexExpansionModeWidth: expandedUserInputs.length,
7184
7340
  indexExpansionModeIndex: i
7185
7341
  });
7186
- processSampleInput(expandedUserInputs[i], expandedUserInputs.length, i, myContext, uiIndex);
7342
+ yield* processSampleInput(expandedUserInputs[i], expandedUserInputs.length, i, myContext, uiIndex);
7187
7343
  }
7188
7344
  }
7189
7345
  }
7190
7346
  } else {
7191
7347
  if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7192
- processSampleInputs([expandedUserInputs[0]], context, uiIndex);
7348
+ yield* processSampleInputs([expandedUserInputs[0]], context, uiIndex);
7193
7349
  } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7194
- processSampleInputs(expandedUserInputs.map(x => ({
7350
+ yield* processSampleInputs(expandedUserInputs.map(x => ({
7195
7351
  x,
7196
7352
  r: Math.random()
7197
7353
  })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]), context, uiIndex);
7198
7354
  } else {
7199
- processSampleInputs(expandedUserInputs, context, uiIndex);
7355
+ yield* processSampleInputs(expandedUserInputs, context, uiIndex);
7200
7356
  }
7201
7357
  }
7202
7358
 
7203
7359
  useUnexpanded = false;
7204
7360
  }
7205
7361
  }
7206
- });
7362
+ }
7207
7363
  }
7208
7364
 
7209
7365
  if (useUnexpanded) {
7210
7366
  const currentStepsStack = convoStepsStack.slice();
7211
7367
  currentStepsStack.push(lodash.cloneDeep(currentStep));
7212
-
7213
- this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
7368
+ yield* this._expandConvo(currentConvo, options, context, convoStepIndex + 1, currentStepsStack);
7214
7369
  }
7215
7370
  }
7216
7371
  } else {
7217
- expandedConvos.push(Object.assign(lodash.cloneDeep(currentConvo), {
7372
+ const expanded = Object.assign(lodash.cloneDeep(currentConvo), {
7218
7373
  conversation: lodash.cloneDeep(convoStepsStack)
7219
- }));
7374
+ });
7375
+
7376
+ if (!options.convoFilter || options.convoFilter(expanded)) {
7377
+ context.count++;
7378
+ const logPerEntry = context.count < 10 ? 1 : context.count < 100 ? 10 : context.count < 1000 ? 100 : context.count < 10000 ? 1000 : 10000;
7379
+
7380
+ if (context.count % logPerEntry === 0) {
7381
+ debug$9(`Convo #${context.count} expanded (${expanded.header.name})`);
7382
+ }
7383
+
7384
+ yield expanded;
7385
+ }
7220
7386
  }
7221
7387
  }
7222
7388
 
7223
7389
  _sortConvos() {
7224
7390
  this.convos = lodash.sortBy(this.convos, [convo => convo.header.sort || convo.header.name]);
7391
+
7392
+ this._updateConvos();
7393
+ }
7394
+
7395
+ _updateConvos() {
7225
7396
  let i = 0;
7226
7397
  this.convos.forEach(convo => {
7227
- convo.header.order = ++i;
7398
+ if (convo) {
7399
+ convo.header.order = ++i;
7228
7400
 
7229
- if (!convo.header.projectname) {
7230
- convo.header.projectname = this.caps[Capabilities.PROJECTNAME];
7231
- }
7401
+ if (!convo.header.projectname) {
7402
+ convo.header.projectname = this.caps[Capabilities.PROJECTNAME];
7403
+ }
7232
7404
 
7233
- if (!convo.header.testsessionname) {
7234
- convo.header.testsessionname = this.caps[Capabilities.TESTSESSIONNAME];
7405
+ if (!convo.header.testsessionname) {
7406
+ convo.header.testsessionname = this.caps[Capabilities.TESTSESSIONNAME];
7407
+ }
7235
7408
  }
7236
7409
  });
7237
7410
  }
@@ -7243,7 +7416,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
7243
7416
  this.convos.push(convos);
7244
7417
  }
7245
7418
 
7246
- this._sortConvos();
7419
+ if (this.convos.filter(c => lodash.isNil(c))) {
7420
+ this._updateConvos();
7421
+ } else {
7422
+ this._sortConvos();
7423
+ }
7247
7424
  }
7248
7425
 
7249
7426
  AddUtterances(utterances) {
@@ -7519,6 +7696,37 @@ var ScriptingProvider_1 = class ScriptingProvider {
7519
7696
  return ['digraph {', ...nodes, ...lines, '}'].join('\r\n');
7520
7697
  }
7521
7698
 
7699
+ GetAssertionCount(convo) {
7700
+ if (!convo) {
7701
+ return 0;
7702
+ }
7703
+
7704
+ let counter = 0;
7705
+
7706
+ for (const step of convo.conversation) {
7707
+ if (step.sender === 'bot') {
7708
+ let stepCounter = step.asserters ? step.asserters.length : 0;
7709
+
7710
+ if (step.messageText) {
7711
+ stepCounter++;
7712
+ }
7713
+
7714
+ stepCounter = stepCounter === 0 ? 1 : stepCounter;
7715
+ counter += stepCounter;
7716
+ }
7717
+ }
7718
+
7719
+ if (convo.convoBegin && convo.convoBegin.asserters) {
7720
+ counter += convo.convoBegin.asserters.length;
7721
+ }
7722
+
7723
+ if (convo.convoEnd && convo.convoEnd.asserters) {
7724
+ counter += convo.convoEnd.asserters.length;
7725
+ }
7726
+
7727
+ return counter === 0 ? 1 : counter;
7728
+ }
7729
+
7522
7730
  };
7523
7731
 
7524
7732
  var BaseRepo_1 = class BaseRepo {