botium-core 1.13.4 → 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.4";
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",
@@ -2271,6 +2271,8 @@ const convoStepToLines$2 = step => {
2271
2271
  lines.push('MEDIA ' + step.media[0].mediaUri);
2272
2272
  } else if (step.messageText) {
2273
2273
  lines.push(step.messageText);
2274
+ } else if (step.sourceData) {
2275
+ lines.push(JSON.stringify(step.sourceData, null, 2));
2274
2276
  }
2275
2277
 
2276
2278
  step.userInputs && step.userInputs.forEach(userInput => {
@@ -2463,6 +2465,34 @@ const SCRIPTING_FUNCTIONS_RAW = {
2463
2465
  $timestamp: () => {
2464
2466
  return Date.now();
2465
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
+ },
2466
2496
  $year: () => {
2467
2497
  return new Date().getFullYear();
2468
2498
  },
@@ -2554,7 +2584,8 @@ const SCRIPTING_FUNCTIONS_RAW = {
2554
2584
  require: false,
2555
2585
  env: caps[Capabilities.SECURITY_ALLOW_UNSAFE] ? process.env : {},
2556
2586
  sandbox: {
2557
- caps
2587
+ caps,
2588
+ moment
2558
2589
  }
2559
2590
  });
2560
2591
  return vm.run(`module.exports = (${code})`);
@@ -2632,7 +2663,22 @@ const _apply = (scriptingMemory, str, caps, mockMsg) => {
2632
2663
  for (const match of matches) {
2633
2664
  if (match.indexOf('(') > 0) {
2634
2665
  const arg = match.substring(match.indexOf('(') + 1, match.lastIndexOf(')')).replace(/\\\)/g, ')');
2635
- 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));
2636
2682
  } else {
2637
2683
  str = str.replace(match, SCRIPTING_FUNCTIONS$1[key].handler(caps));
2638
2684
  }
@@ -4831,7 +4877,8 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4831
4877
  convoResults.forEach(convo => {
4832
4878
  if (!convo.header.name) {
4833
4879
  convo.header.name = `${convo.header.sheetname}-${this.colnames[convo.header.colindex]}${formatRowIndex(convo.header.rowindex)}`;
4834
- }
4880
+ } // it is not used anymore?
4881
+
4835
4882
 
4836
4883
  convo.header.sort = convo.header.name;
4837
4884
  scriptResults.push(convo);
@@ -7006,30 +7053,77 @@ var ScriptingProvider_1 = class ScriptingProvider {
7006
7053
  this._sortConvos();
7007
7054
  }
7008
7055
 
7009
- 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
+ };
7010
7066
  const expandedConvos = [];
7011
7067
  debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`);
7012
7068
  this.convos.forEach(convo => {
7013
7069
  convo.expandPartialConvos();
7014
7070
 
7015
- 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
+ }
7016
7086
  });
7017
7087
  this.convos = expandedConvos;
7018
7088
 
7019
- 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);
7020
7116
  }
7021
7117
  /**
7022
- *
7023
- * @param expandedConvos
7118
+ * This is a generator function with yield
7024
7119
  * @param currentConvo
7025
7120
  * @param convoStepIndex
7026
7121
  * @param convoStepsStack list of ConvoSteps
7027
- * @param context {width: }
7028
7122
  * @private
7029
7123
  */
7030
7124
 
7031
7125
 
7032
- _expandConvo(expandedConvos, currentConvo, convoStepIndex = 0, convoStepsStack = [], context = {}) {
7126
+ *_expandConvo(currentConvo, options, context, convoStepIndex = 0, convoStepsStack = []) {
7033
7127
  const utterancePostfix = (lineTag, uttOrUserInput) => {
7034
7128
  const naming = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE] || Defaults$1.capabilities[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE];
7035
7129
 
@@ -7055,8 +7149,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7055
7149
  if (currentStep.sender === 'bot' || currentStep.sender === 'begin' || currentStep.sender === 'end') {
7056
7150
  const currentStepsStack = convoStepsStack.slice();
7057
7151
  currentStepsStack.push(lodash.cloneDeep(currentStep));
7058
-
7059
- this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
7152
+ yield* this._expandConvo(currentConvo, options, context, convoStepIndex + 1, currentStepsStack);
7060
7153
  } else if (currentStep.sender === 'me') {
7061
7154
  let useUnexpanded = true;
7062
7155
 
@@ -7078,16 +7171,15 @@ var ScriptingProvider_1 = class ScriptingProvider {
7078
7171
  if (this.utterances[uttName]) {
7079
7172
  const allutterances = this.utterances[uttName].utterances;
7080
7173
 
7081
- const processSampleUtterances = (sampleutterances, myContext) => {
7082
- sampleutterances.forEach((utt, index) => {
7083
- 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({
7084
7177
  indexExpansionModeIndex: index
7085
7178
  }, myContext || context));
7086
- });
7179
+ }
7087
7180
  };
7088
7181
 
7089
- const processSampleUtterance = (sampleutterance, length, index, myContext) => {
7090
- const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7182
+ const processSampleUtterance = function* (sampleutterance, length, index, myContext) {
7091
7183
  const currentStepsStack = convoStepsStack.slice();
7092
7184
 
7093
7185
  if (uttArgs) {
@@ -7100,19 +7192,24 @@ var ScriptingProvider_1 = class ScriptingProvider {
7100
7192
 
7101
7193
  const currentConvoLabeled = lodash.cloneDeep(currentConvo);
7102
7194
 
7103
- Object.assign(currentConvoLabeled.header, {
7104
- name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, sampleutterance)}`
7105
- });
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
+
7106
7202
  if (!currentConvoLabeled.sourceTag) currentConvoLabeled.sourceTag = {};
7107
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);
7108
7206
 
7109
- this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack, myContext || context);
7110
- };
7111
-
7112
- 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') {
7113
7210
  if (lodash.isNil(context.indexExpansionModeWidth)) {
7114
7211
  // executed for the first found utterance
7115
- processSampleUtterances(allutterances, Object.assign({}, context, {
7212
+ yield* processSampleUtterances(allutterances, Object.assign({}, context, {
7116
7213
  indexExpansionModeWidth: allutterances.length
7117
7214
  }));
7118
7215
  } else {
@@ -7130,7 +7227,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7130
7227
  const myContext = Object.assign({}, context, {
7131
7228
  indexExpansionModeWidth: Math.max(allutterances.length, context.indexExpansionModeWidth)
7132
7229
  });
7133
- processSampleUtterance(allutterances[localIndex], allutterances.length, localIndex, myContext);
7230
+ yield* processSampleUtterance(allutterances[localIndex], allutterances.length, localIndex, myContext);
7134
7231
 
7135
7232
  if (allutterances.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
7136
7233
  debug$9(`While expanding convos by index found in utterance "${uttName}" more examples (${allutterances.length}) as expected (${context.indexExpansionModeWidth})`);
@@ -7141,20 +7238,20 @@ var ScriptingProvider_1 = class ScriptingProvider {
7141
7238
  indexExpansionModeWidth: allutterances.length,
7142
7239
  indexExpansionModeIndex: i
7143
7240
  });
7144
- processSampleUtterance(allutterances[i], allutterances.length, i, myContext);
7241
+ yield* processSampleUtterance(allutterances[i], allutterances.length, i, myContext);
7145
7242
  }
7146
7243
  }
7147
7244
  }
7148
7245
  } else {
7149
7246
  if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7150
- processSampleUtterances([allutterances[0]]);
7247
+ yield* processSampleUtterances([allutterances[0]], context);
7151
7248
  } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7152
- processSampleUtterances(allutterances.map(x => ({
7249
+ yield* processSampleUtterances(allutterances.map(x => ({
7153
7250
  x,
7154
7251
  r: Math.random()
7155
- })).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);
7156
7253
  } else {
7157
- processSampleUtterances(allutterances);
7254
+ yield* processSampleUtterances(allutterances, context);
7158
7255
  }
7159
7256
  }
7160
7257
 
@@ -7163,7 +7260,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
7163
7260
  }
7164
7261
 
7165
7262
  if (currentStep.userInputs && currentStep.userInputs.length > 0) {
7166
- currentStep.userInputs.forEach((ui, uiIndex) => {
7263
+ for (let uiIndex = 0; uiIndex < currentStep.userInputs.length; uiIndex++) {
7264
+ const ui = currentStep.userInputs[uiIndex];
7167
7265
  const userInput = this.userInputs[ui.name];
7168
7266
 
7169
7267
  if (userInput && userInput.expandConvo) {
@@ -7175,16 +7273,15 @@ var ScriptingProvider_1 = class ScriptingProvider {
7175
7273
 
7176
7274
  if (expandedUserInputs && expandedUserInputs.length > 0) {
7177
7275
  // let sampleinputs = expandedUserInputs
7178
- const processSampleInputs = (sampleinputs, myContext, uiIndex) => {
7179
- sampleinputs.forEach((input, index) => {
7180
- 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({
7181
7279
  indexExpansionModeIndex: index
7182
7280
  }, myContext || context), uiIndex);
7183
- });
7281
+ }
7184
7282
  };
7185
7283
 
7186
- const processSampleInput = (sampleinput, length, index, myContext, uiIndex) => {
7187
- const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7284
+ const processSampleInput = function* (sampleinput, length, index, myContext, uiIndex) {
7188
7285
  const currentStepsStack = convoStepsStack.slice();
7189
7286
 
7190
7287
  const currentStepMod = lodash.cloneDeep(currentStep);
@@ -7194,16 +7291,27 @@ var ScriptingProvider_1 = class ScriptingProvider {
7194
7291
 
7195
7292
  const currentConvoLabeled = lodash.cloneDeep(currentConvo);
7196
7293
 
7197
- Object.assign(currentConvoLabeled.header, {
7198
- name: `${currentConvo.header.name}/${ui.name}-${utterancePostfix(lineTag, sampleinput.args && sampleinput.args.length ? sampleinput.args.join(', ') : 'no-args')}`
7199
- });
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
+ }
7200
7306
 
7201
- this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack, myContext || context);
7202
- };
7307
+ yield* this._expandConvo(currentConvoLabeled, options, myContext || context, convoStepIndex + 1, currentStepsStack);
7308
+ }.bind(this);
7203
7309
 
7204
- 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') {
7205
7313
  if (lodash.isNil(context.indexExpansionModeWidth)) {
7206
- processSampleInputs(expandedUserInputs, Object.assign({}, context, {
7314
+ yield* processSampleInputs(expandedUserInputs, Object.assign({}, context, {
7207
7315
  indexExpansionModeWidth: expandedUserInputs.length
7208
7316
  }), uiIndex);
7209
7317
  } else {
@@ -7221,7 +7329,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7221
7329
  const myContext = Object.assign({}, context, {
7222
7330
  indexExpansionModeWidth: Math.max(expandedUserInputs.length, context.indexExpansionModeWidth)
7223
7331
  });
7224
- processSampleInput(expandedUserInputs[localIndex], expandedUserInputs.length, localIndex, myContext, uiIndex);
7332
+ yield* processSampleInput(expandedUserInputs[localIndex], expandedUserInputs.length, localIndex, myContext, uiIndex);
7225
7333
 
7226
7334
  if (expandedUserInputs.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
7227
7335
  debug$9(`While expanding convos by index found user input "${ui.name}, ${ui.args}" more examples (${expandedUserInputs.length}) as expected (${context.indexExpansionModeWidth})`);
@@ -7231,55 +7339,72 @@ var ScriptingProvider_1 = class ScriptingProvider {
7231
7339
  indexExpansionModeWidth: expandedUserInputs.length,
7232
7340
  indexExpansionModeIndex: i
7233
7341
  });
7234
- processSampleInput(expandedUserInputs[i], expandedUserInputs.length, i, myContext, uiIndex);
7342
+ yield* processSampleInput(expandedUserInputs[i], expandedUserInputs.length, i, myContext, uiIndex);
7235
7343
  }
7236
7344
  }
7237
7345
  }
7238
7346
  } else {
7239
7347
  if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7240
- processSampleInputs([expandedUserInputs[0]], context, uiIndex);
7348
+ yield* processSampleInputs([expandedUserInputs[0]], context, uiIndex);
7241
7349
  } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7242
- processSampleInputs(expandedUserInputs.map(x => ({
7350
+ yield* processSampleInputs(expandedUserInputs.map(x => ({
7243
7351
  x,
7244
7352
  r: Math.random()
7245
7353
  })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]), context, uiIndex);
7246
7354
  } else {
7247
- processSampleInputs(expandedUserInputs, context, uiIndex);
7355
+ yield* processSampleInputs(expandedUserInputs, context, uiIndex);
7248
7356
  }
7249
7357
  }
7250
7358
 
7251
7359
  useUnexpanded = false;
7252
7360
  }
7253
7361
  }
7254
- });
7362
+ }
7255
7363
  }
7256
7364
 
7257
7365
  if (useUnexpanded) {
7258
7366
  const currentStepsStack = convoStepsStack.slice();
7259
7367
  currentStepsStack.push(lodash.cloneDeep(currentStep));
7260
-
7261
- this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
7368
+ yield* this._expandConvo(currentConvo, options, context, convoStepIndex + 1, currentStepsStack);
7262
7369
  }
7263
7370
  }
7264
7371
  } else {
7265
- expandedConvos.push(Object.assign(lodash.cloneDeep(currentConvo), {
7372
+ const expanded = Object.assign(lodash.cloneDeep(currentConvo), {
7266
7373
  conversation: lodash.cloneDeep(convoStepsStack)
7267
- }));
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
+ }
7268
7386
  }
7269
7387
  }
7270
7388
 
7271
7389
  _sortConvos() {
7272
7390
  this.convos = lodash.sortBy(this.convos, [convo => convo.header.sort || convo.header.name]);
7391
+
7392
+ this._updateConvos();
7393
+ }
7394
+
7395
+ _updateConvos() {
7273
7396
  let i = 0;
7274
7397
  this.convos.forEach(convo => {
7275
- convo.header.order = ++i;
7398
+ if (convo) {
7399
+ convo.header.order = ++i;
7276
7400
 
7277
- if (!convo.header.projectname) {
7278
- convo.header.projectname = this.caps[Capabilities.PROJECTNAME];
7279
- }
7401
+ if (!convo.header.projectname) {
7402
+ convo.header.projectname = this.caps[Capabilities.PROJECTNAME];
7403
+ }
7280
7404
 
7281
- if (!convo.header.testsessionname) {
7282
- convo.header.testsessionname = this.caps[Capabilities.TESTSESSIONNAME];
7405
+ if (!convo.header.testsessionname) {
7406
+ convo.header.testsessionname = this.caps[Capabilities.TESTSESSIONNAME];
7407
+ }
7283
7408
  }
7284
7409
  });
7285
7410
  }
@@ -7291,7 +7416,11 @@ var ScriptingProvider_1 = class ScriptingProvider {
7291
7416
  this.convos.push(convos);
7292
7417
  }
7293
7418
 
7294
- this._sortConvos();
7419
+ if (this.convos.filter(c => lodash.isNil(c))) {
7420
+ this._updateConvos();
7421
+ } else {
7422
+ this._sortConvos();
7423
+ }
7295
7424
  }
7296
7425
 
7297
7426
  AddUtterances(utterances) {
@@ -7567,6 +7696,37 @@ var ScriptingProvider_1 = class ScriptingProvider {
7567
7696
  return ['digraph {', ...nodes, ...lines, '}'].join('\r\n');
7568
7697
  }
7569
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
+
7570
7730
  };
7571
7731
 
7572
7732
  var BaseRepo_1 = class BaseRepo {