botium-core 1.11.15 → 1.12.2

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.
Files changed (41) hide show
  1. package/dist/botium-cjs.js +420 -172
  2. package/dist/botium-cjs.js.map +1 -1
  3. package/dist/botium-es.js +411 -164
  4. package/dist/botium-es.js.map +1 -1
  5. package/index.js +1 -0
  6. package/package.json +27 -27
  7. package/samples/connectors/custom/botium-connector-myapi.js +3 -3
  8. package/samples/extensions/asserterHooks/DummyAsserter.js +3 -3
  9. package/src/Capabilities.js +4 -0
  10. package/src/Defaults.js +1 -0
  11. package/src/Enums.js +6 -0
  12. package/src/containers/BaseContainer.js +20 -10
  13. package/src/containers/PluginConnectorContainer.js +1 -0
  14. package/src/containers/plugins/SimpleRestContainer.js +36 -4
  15. package/src/scripting/BotiumError.js +21 -0
  16. package/src/scripting/CompilerCsv.js +1 -1
  17. package/src/scripting/CompilerObjectBase.js +4 -14
  18. package/src/scripting/CompilerTxt.js +4 -15
  19. package/src/scripting/CompilerXlsx.js +81 -25
  20. package/src/scripting/Convo.js +16 -4
  21. package/src/scripting/ScriptingProvider.js +6 -0
  22. package/src/scripting/helper.js +54 -1
  23. package/src/scripting/logichook/LogicHookUtils.js +2 -0
  24. package/src/scripting/logichook/asserter/JsonPathAsserter.js +1 -1
  25. package/src/scripting/logichook/logichooks/ClearQueueLogicHook.js +1 -1
  26. package/src/scripting/logichook/userinput/MediaInput.js +14 -2
  27. package/test/connectors/convos/hello.convo.txt +6 -0
  28. package/test/connectors/simplerest.spec.js +42 -2
  29. package/test/convo/convos/continuefailing.convo.txt +19 -0
  30. package/test/convo/transcript.spec.js +34 -0
  31. package/test/scripting/scriptingProvider.spec.js +4 -4
  32. package/test/scripting/scriptingmemory/convosMultiMemorySameCols/buy.convo.txt +6 -0
  33. package/test/scripting/scriptingmemory/convosMultiMemorySameCols/products1.scriptingmemory.txt +2 -0
  34. package/test/scripting/scriptingmemory/convosMultiMemorySameCols/products2.scriptingmemory.txt +2 -0
  35. package/test/scripting/scriptingmemory/convosSimpleCols/buy.convo.txt +8 -0
  36. package/test/scripting/scriptingmemory/convosSimpleCols/product.scriptingmemory.txt +3 -0
  37. package/test/scripting/scriptingmemory/convosTwoTablesCols/buy.convo.txt +6 -0
  38. package/test/scripting/scriptingmemory/convosTwoTablesCols/customer.xlsx +0 -0
  39. package/test/scripting/scriptingmemory/convosTwoTablesCols/product.xlsx +0 -0
  40. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +45 -0
  41. package/test/scripting/userinputs/mediaInputConvos.spec.js +53 -2
package/dist/botium-es.js CHANGED
@@ -23,7 +23,7 @@ import isJson$1 from 'is-json';
23
23
  import esprima from 'esprima';
24
24
  import markdownIt from 'markdown-it';
25
25
  import xlsx from 'xlsx';
26
- import sync from 'csv-parse/lib/sync';
26
+ import sync from 'csv-parse/sync';
27
27
  import yaml from 'yaml';
28
28
  import child_process from 'child_process';
29
29
  import socket from 'socket.io-client';
@@ -36,12 +36,12 @@ import express from 'express';
36
36
  import bodyParser from 'body-parser';
37
37
 
38
38
  var name = "botium-core";
39
- var version$1 = "1.11.15";
39
+ var version$1 = "1.12.2";
40
40
  var description = "The Selenium for Chatbots";
41
41
  var main = "index.js";
42
42
  var module = "dist/botium-es.js";
43
43
  var engines = {
44
- node: ">=10.0.0"
44
+ node: ">=14.0.0"
45
45
  };
46
46
  var scripts = {
47
47
  postinstall: "node ./report.js",
@@ -68,23 +68,23 @@ var bugs = {
68
68
  };
69
69
  var homepage = "https://www.botium.ai";
70
70
  var dependencies = {
71
- "@babel/runtime": "^7.16.0",
72
- async: "^3.2.2",
73
- "body-parser": "^1.19.0",
71
+ "@babel/runtime": "^7.16.7",
72
+ async: "^3.2.3",
73
+ "body-parser": "^1.19.1",
74
74
  boolean: "^3.1.4",
75
75
  bottleneck: "^2.19.5",
76
- "csv-parse": "^4.16.3",
77
- debug: "^4.3.2",
76
+ "csv-parse": "^5.0.4",
77
+ debug: "^4.3.3",
78
78
  esprima: "^4.0.1",
79
- express: "^4.17.1",
79
+ express: "^4.17.2",
80
80
  globby: "11.0.4",
81
- ioredis: "^4.28.0",
81
+ ioredis: "^4.28.3",
82
82
  "is-class": "^0.0.9",
83
83
  "is-json": "^2.0.1",
84
84
  jsonpath: "^1.1.1",
85
85
  lodash: "^4.17.21",
86
- "markdown-it": "^12.2.0",
87
- "mime-types": "^2.1.33",
86
+ "markdown-it": "^12.3.2",
87
+ "mime-types": "^2.1.34",
88
88
  mkdirp: "^1.0.4",
89
89
  moment: "^2.29.1",
90
90
  mustache: "^4.2.0",
@@ -94,40 +94,40 @@ var dependencies = {
94
94
  request: "^2.88.2",
95
95
  rimraf: "^3.0.2",
96
96
  "sanitize-filename": "^1.6.3",
97
- slugify: "^1.6.1",
98
- "socket.io": "^4.3.1",
99
- "socket.io-client": "^4.3.2",
97
+ slugify: "^1.6.5",
98
+ "socket.io": "^4.4.1",
99
+ "socket.io-client": "^4.4.1",
100
100
  "socketio-auth": "^0.1.1",
101
101
  "swagger-jsdoc": "^6.1.0",
102
- "swagger-ui-express": "^4.1.6",
102
+ "swagger-ui-express": "^4.3.0",
103
103
  uuid: "^8.3.2",
104
104
  vm2: "^3.9.5",
105
105
  "write-yaml": "^1.0.0",
106
- xlsx: "^0.17.3",
106
+ xlsx: "^0.17.5",
107
107
  xregexp: "^5.1.0",
108
108
  yaml: "^1.10.2"
109
109
  };
110
110
  var devDependencies = {
111
- "@babel/core": "^7.16.0",
112
- "@babel/node": "^7.16.0",
113
- "@babel/plugin-transform-runtime": "^7.16.0",
114
- "@babel/preset-env": "^7.16.0",
111
+ "@babel/core": "^7.16.12",
112
+ "@babel/node": "^7.16.8",
113
+ "@babel/plugin-transform-runtime": "^7.16.10",
114
+ "@babel/preset-env": "^7.16.11",
115
115
  chai: "^4.3.4",
116
116
  "chai-as-promised": "^7.1.1",
117
117
  "cross-env": "^7.0.3",
118
- eslint: "^8.1.0",
118
+ eslint: "^8.7.0",
119
119
  "eslint-config-standard": "^16.0.3",
120
- "eslint-plugin-import": "^2.25.2",
120
+ "eslint-plugin-import": "^2.25.4",
121
121
  "eslint-plugin-node": "^11.1.0",
122
- "eslint-plugin-promise": "^5.1.1",
122
+ "eslint-plugin-promise": "^6.0.0",
123
123
  "eslint-plugin-standard": "^4.1.0",
124
124
  "license-checker": "^25.0.1",
125
125
  "license-compatibility-checker": "^0.3.5",
126
- mocha: "^9.1.3",
127
- nock: "^13.1.4",
128
- "npm-check-updates": "^12.0.0",
126
+ mocha: "^9.2.0",
127
+ nock: "^13.2.2",
128
+ "npm-check-updates": "^12.2.1",
129
129
  nyc: "^15.1.0",
130
- rollup: "^2.59.0",
130
+ rollup: "^2.66.0",
131
131
  "rollup-plugin-babel": "^4.4.0",
132
132
  "rollup-plugin-commonjs": "^10.1.0",
133
133
  "rollup-plugin-json": "^4.0.0",
@@ -282,6 +282,7 @@ var Capabilities = {
282
282
  SCRIPTING_NORMALIZE_TEXT: 'SCRIPTING_NORMALIZE_TEXT',
283
283
  SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
284
284
  SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
285
+ SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS: 'SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS',
285
286
  SCRIPTING_FORCE_BOT_CONSUMED: 'SCRIPTING_FORCE_BOT_CONSUMED',
286
287
  // regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, wildcardExact, wildcardExactIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
287
288
  SCRIPTING_MATCHING_MODE: 'SCRIPTING_MATCHING_MODE',
@@ -297,6 +298,8 @@ var Capabilities = {
297
298
  SCRIPTING_MEMORYEXPANSION_KEEP_ORIG: 'SCRIPTING_MEMORYEXPANSION_KEEP_ORIG',
298
299
  // word, non_whitespace, joker
299
300
  SCRIPTING_MEMORY_MATCHING_MODE: 'SCRIPTING_MEMORY_MATCHING_MODE',
301
+ // varnames, testcasenames
302
+ SCRIPTING_MEMORY_COLUMN_MODE: 'SCRIPTING_MEMORY_COLUMN_MODE',
300
303
  // Botium Lifecycle Hooks
301
304
  CUSTOMHOOK_ONBUILD: 'CUSTOMHOOK_ONBUILD',
302
305
  CUSTOMHOOK_ONSTART: 'CUSTOMHOOK_ONSTART',
@@ -311,6 +314,7 @@ var Capabilities = {
311
314
  // API Calls Rate Limiting
312
315
  RATELIMIT_USERSAYS_MAXCONCURRENT: 'RATELIMIT_USERSAYS_MAXCONCURRENT',
313
316
  RATELIMIT_USERSAYS_MINTIME: 'RATELIMIT_USERSAYS_MINTIME',
317
+ RATELIMIT_BOTTLENECK_FN: 'RATELIMIT_BOTTLENECK_FN',
314
318
  SECURITY_ALLOW_UNSAFE: 'SECURITY_ALLOW_UNSAFE',
315
319
  PRECOMPILERS: 'PRECOMPILERS'
316
320
  };
@@ -422,6 +426,7 @@ Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER;
422
426
  Capabilities.SCRIPTING_NORMALIZE_TEXT;
423
427
  Capabilities.SCRIPTING_ENABLE_MEMORY;
424
428
  Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS;
429
+ Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS;
425
430
  Capabilities.SCRIPTING_FORCE_BOT_CONSUMED;
426
431
  Capabilities.SCRIPTING_MATCHING_MODE;
427
432
  Capabilities.SCRIPTING_UTTEXPANSION_MODE;
@@ -432,6 +437,7 @@ Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE;
432
437
  Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX;
433
438
  Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG;
434
439
  Capabilities.SCRIPTING_MEMORY_MATCHING_MODE;
440
+ Capabilities.SCRIPTING_MEMORY_COLUMN_MODE;
435
441
  Capabilities.CUSTOMHOOK_ONBUILD;
436
442
  Capabilities.CUSTOMHOOK_ONSTART;
437
443
  Capabilities.CUSTOMHOOK_ONUSERSAYS;
@@ -443,6 +449,7 @@ Capabilities.LOGIC_HOOKS;
443
449
  Capabilities.USER_INPUTS;
444
450
  Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT;
445
451
  Capabilities.RATELIMIT_USERSAYS_MINTIME;
452
+ Capabilities.RATELIMIT_BOTTLENECK_FN;
446
453
  Capabilities.SECURITY_ALLOW_UNSAFE;
447
454
  Capabilities.PRECOMPILERS;
448
455
 
@@ -510,6 +517,7 @@ var Defaults$1 = {
510
517
  [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'justLineTag',
511
518
  [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: '16',
512
519
  [Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false,
520
+ [Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: false,
513
521
  [Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: false,
514
522
  [Capabilities.ASSERTERS]: [],
515
523
  [Capabilities.LOGIC_HOOKS]: [],
@@ -831,7 +839,7 @@ function getCjsExportFromNamespace (n) {
831
839
  return n && n['default'] || n;
832
840
  }
833
841
 
834
- const BotiumError$6 = class BotiumError extends Error {
842
+ const BotiumError$7 = class BotiumError extends Error {
835
843
  /**
836
844
  *
837
845
  * @param message
@@ -856,6 +864,27 @@ const BotiumError$6 = class BotiumError extends Error {
856
864
  this.context.message = message.message || message;
857
865
  }
858
866
 
867
+ isAsserterError() {
868
+ if (this.context) {
869
+ const errArr = lodash.isArray(this.context) ? this.context : [this.context];
870
+ const hasNotAsserterError = errArr.findIndex(errDetail => {
871
+ if (errDetail.type === 'list') {
872
+ if (errDetail.errors) {
873
+ return errDetail.errors.findIndex(e => e.type !== 'asserter') >= 0;
874
+ } else {
875
+ return true;
876
+ }
877
+ } else {
878
+ return errDetail.type !== 'asserter';
879
+ }
880
+ }) >= 0;
881
+ if (hasNotAsserterError) return false;
882
+ return true;
883
+ } else {
884
+ return false;
885
+ }
886
+ }
887
+
859
888
  prettify(includeJson) {
860
889
  const lines = [];
861
890
 
@@ -917,10 +946,10 @@ const _getChildErrorsFromContext = context => {
917
946
  };
918
947
 
919
948
  const botiumErrorFromErr$2 = (message, err) => {
920
- if (err instanceof BotiumError$6) {
921
- return new BotiumError$6(message, err.context, true);
949
+ if (err instanceof BotiumError$7) {
950
+ return new BotiumError$7(message, err.context, true);
922
951
  } else {
923
- return new BotiumError$6(message, {
952
+ return new BotiumError$7(message, {
924
953
  err
925
954
  }, true);
926
955
  }
@@ -935,7 +964,7 @@ const botiumErrorFromList$2 = (errors, {
935
964
  let children = [];
936
965
 
937
966
  for (const error of errors) {
938
- if (error instanceof BotiumError$6) {
967
+ if (error instanceof BotiumError$7) {
939
968
  const childErrors = flat && _getChildErrorsFromContext(error.context);
940
969
 
941
970
  if (childErrors && childErrors.length) {
@@ -948,7 +977,7 @@ const botiumErrorFromList$2 = (errors, {
948
977
  }
949
978
  }
950
979
 
951
- const result = new BotiumError$6(message, {
980
+ const result = new BotiumError$7(message, {
952
981
  errors: children,
953
982
  type,
954
983
  source
@@ -957,7 +986,7 @@ const botiumErrorFromList$2 = (errors, {
957
986
  };
958
987
 
959
988
  var BotiumError_1 = {
960
- BotiumError: BotiumError$6,
989
+ BotiumError: BotiumError$7,
961
990
  botiumErrorFromErr: botiumErrorFromErr$2,
962
991
  botiumErrorFromList: botiumErrorFromList$2
963
992
  };
@@ -1138,7 +1167,7 @@ const {
1138
1167
  } = vm2;
1139
1168
  const debug$k = debug$l('botium-core-asserterUtils');
1140
1169
  const {
1141
- BotiumError: BotiumError$5
1170
+ BotiumError: BotiumError$6
1142
1171
  } = BotiumError_1;
1143
1172
  const {
1144
1173
  DEFAULT_ASSERTERS,
@@ -1289,7 +1318,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1289
1318
 
1290
1319
  const _checkUnsafe = () => {
1291
1320
  if (!this.caps[Capabilities.SECURITY_ALLOW_UNSAFE]) {
1292
- throw new BotiumError$5('Security Error. Using unsafe component is not allowed', {
1321
+ throw new BotiumError$6('Security Error. Using unsafe component is not allowed', {
1293
1322
  type: 'security',
1294
1323
  subtype: 'allow unsafe',
1295
1324
  source: path.basename(__filename),
@@ -1433,6 +1462,11 @@ var LogicHookUtils_1 = class LogicHookUtils {
1433
1462
  ref,
1434
1463
  ...this.buildScriptContext
1435
1464
  }, this.caps, args);
1465
+ } else if (lodash.isFunction(CheckClass.PluginClass)) {
1466
+ return CheckClass.PluginClass({
1467
+ ref,
1468
+ ...this.buildScriptContext
1469
+ }, this.caps, args);
1436
1470
  } else {
1437
1471
  throw new Error(`${src} class or function expected`);
1438
1472
  }
@@ -1688,6 +1722,18 @@ var BotiumMockMessage_1 = class BotiumMockMessage {
1688
1722
 
1689
1723
  };
1690
1724
 
1725
+ var Enums = {
1726
+ E_SCRIPTING_MEMORY_COLUMN_MODE: {
1727
+ VARNAMES: 'varnames',
1728
+ TESTCASENAMES: 'testcasenames'
1729
+ }
1730
+ };
1731
+ Enums.E_SCRIPTING_MEMORY_COLUMN_MODE;
1732
+
1733
+ const {
1734
+ E_SCRIPTING_MEMORY_COLUMN_MODE: E_SCRIPTING_MEMORY_COLUMN_MODE$1
1735
+ } = Enums;
1736
+
1691
1737
  const normalizeText$1 = (str, doCleanup) => {
1692
1738
  if (str && lodash.isArray(str)) {
1693
1739
  str = str.join(' ');
@@ -2216,6 +2262,71 @@ const convoStepToLines$2 = step => {
2216
2262
  return lines.map(l => l.trim());
2217
2263
  };
2218
2264
 
2265
+ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
2266
+ const guessScriptingMemoryColumnMode = lines => {
2267
+ if (lines && lines.length > 1) {
2268
+ if (lines[1].trim().startsWith('$')) return E_SCRIPTING_MEMORY_COLUMN_MODE$1.TESTCASENAMES;
2269
+ }
2270
+
2271
+ return E_SCRIPTING_MEMORY_COLUMN_MODE$1.VARNAMES;
2272
+ };
2273
+
2274
+ columnMode = columnMode || guessScriptingMemoryColumnMode(lines);
2275
+ const scriptingMemories = [];
2276
+
2277
+ if (columnMode === E_SCRIPTING_MEMORY_COLUMN_MODE$1.TESTCASENAMES) {
2278
+ const caseNames = lines[0].split('|').map(name => name.trim()).slice(1);
2279
+ const varNames = [];
2280
+ const varValues = [];
2281
+
2282
+ for (let row = 1; row < lines.length; row++) {
2283
+ if (!lines[row] || lines[row].length === 0) continue;
2284
+ const rawRow = lines[row].split('|').map(name => name.trim());
2285
+ varNames.push(rawRow[0]);
2286
+ varValues.push(rawRow.slice(1));
2287
+ }
2288
+
2289
+ for (let caseIndex = 0; caseIndex < caseNames.length; caseIndex++) {
2290
+ const caseName = caseNames[caseIndex];
2291
+ const values = varNames.reduce((agg, varName, varIndex) => {
2292
+ agg[varName] = varValues[varIndex][caseIndex] || null;
2293
+ return agg;
2294
+ }, {});
2295
+ const scriptingMemory = {
2296
+ header: {
2297
+ name: caseName
2298
+ },
2299
+ values: values
2300
+ };
2301
+ scriptingMemories.push(scriptingMemory);
2302
+ }
2303
+ } else {
2304
+ const varNames = lines[0].split('|').map(name => name.trim()).slice(1);
2305
+
2306
+ for (let row = 1; row < lines.length; row++) {
2307
+ if (!lines[row] || lines[row].length === 0) continue;
2308
+ const rawRow = lines[row].split('|').map(name => name.trim());
2309
+ const caseName = rawRow[0];
2310
+ const values = rawRow.slice(1);
2311
+ const varValues = {};
2312
+
2313
+ for (let varIndex = 0; varIndex < varNames.length; varIndex++) {
2314
+ varValues[varNames[varIndex]] = values[varIndex];
2315
+ }
2316
+
2317
+ const scriptingMemory = {
2318
+ header: {
2319
+ name: caseName
2320
+ },
2321
+ values: varValues
2322
+ };
2323
+ scriptingMemories.push(scriptingMemory);
2324
+ }
2325
+ }
2326
+
2327
+ return scriptingMemories;
2328
+ };
2329
+
2219
2330
  var helper = {
2220
2331
  normalizeText: normalizeText$1,
2221
2332
  splitStringInNonEmptyLines: splitStringInNonEmptyLines$1,
@@ -2228,7 +2339,8 @@ var helper = {
2228
2339
  convoStepToObject: convoStepToObject$1,
2229
2340
  validSenders: validSenders$3,
2230
2341
  validateSender: validateSender$1,
2231
- validateConvo: validateConvo$2
2342
+ validateConvo: validateConvo$2,
2343
+ linesToScriptingMemories: linesToScriptingMemories$2
2232
2344
  };
2233
2345
 
2234
2346
  const debug$j = debug$l('botium-core-ScriptingMemory');
@@ -2243,7 +2355,7 @@ const {
2243
2355
  toString: toString$2
2244
2356
  } = helper;
2245
2357
  const {
2246
- BotiumError: BotiumError$4
2358
+ BotiumError: BotiumError$5
2247
2359
  } = BotiumError_1; // If they got parameter, then it will be a string always.
2248
2360
  // the receiver can decide what to do with it,
2249
2361
  // convert to int,
@@ -2412,7 +2524,7 @@ const SCRIPTING_FUNCTIONS$1 = lodash.mapValues(SCRIPTING_FUNCTIONS_RAW, (funcOrS
2412
2524
  return {
2413
2525
  handler: (caps, ...rest) => {
2414
2526
  if (!caps[Capabilities.SECURITY_ALLOW_UNSAFE] && funcOrStruct.unsafe) {
2415
- throw new BotiumError$4(`Security Error. Using unsafe scripting memory function ${name} is not allowed`, {
2527
+ throw new BotiumError$5(`Security Error. Using unsafe scripting memory function ${name} is not allowed`, {
2416
2528
  type: 'security',
2417
2529
  subtype: 'allow unsafe',
2418
2530
  source: path.basename(__filename),
@@ -2561,7 +2673,7 @@ ScriptingMemory.SCRIPTING_FUNCTIONS;
2561
2673
 
2562
2674
  const debug$i = debug$l('botium-core-Convo');
2563
2675
  const {
2564
- BotiumError: BotiumError$3,
2676
+ BotiumError: BotiumError$4,
2565
2677
  botiumErrorFromErr: botiumErrorFromErr$1,
2566
2678
  botiumErrorFromList: botiumErrorFromList$1
2567
2679
  } = BotiumError_1;
@@ -2601,7 +2713,9 @@ class ConvoStepAssert {
2601
2713
  }
2602
2714
 
2603
2715
  toString() {
2604
- return (this.optional ? '?' : '') + (this.not ? '!' : '') + this.name + '(' + (this.args ? this.args.join(',') : 'no args') + ')';
2716
+ return (this.optional ? '?' : '') + (this.not ? '!' : '') + this.name + '(' + (this.args ? this.args.map(a => lodash.truncate(a, {
2717
+ length: 200
2718
+ })).join(',') : 'no args') + ')';
2605
2719
  }
2606
2720
 
2607
2721
  }
@@ -2613,7 +2727,9 @@ class ConvoStepLogicHook {
2613
2727
  }
2614
2728
 
2615
2729
  toString() {
2616
- return this.name + '(' + (this.args ? this.args.join(',') : 'no args') + ')';
2730
+ return this.name + '(' + (this.args ? this.args.map(a => lodash.truncate(a, {
2731
+ length: 200
2732
+ })).join(',') : 'no args') + ')';
2617
2733
  }
2618
2734
 
2619
2735
  }
@@ -2625,7 +2741,9 @@ class ConvoStepUserInput {
2625
2741
  }
2626
2742
 
2627
2743
  toString() {
2628
- return this.name + '(' + (this.args ? this.args.join(',') : 'no args') + ')';
2744
+ return this.name + '(' + (this.args ? this.args.map(a => lodash.truncate(a, {
2745
+ length: 200
2746
+ })).join(',') : 'no args') + ')';
2629
2747
  }
2630
2748
 
2631
2749
  }
@@ -3090,7 +3208,7 @@ class Convo$6 {
3090
3208
  }
3091
3209
 
3092
3210
  if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
3093
- const failErr = new BotiumError$3(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
3211
+ const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
3094
3212
  debug$i(failErr);
3095
3213
 
3096
3214
  try {
@@ -3193,7 +3311,7 @@ class Convo$6 {
3193
3311
  this.scriptingEvents.fail && this.scriptingEvents.fail(failErr, lastMeConvoStep);
3194
3312
  } catch (failErr) {}
3195
3313
 
3196
- if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$3) {
3314
+ if (container.caps[Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS] && err instanceof BotiumError$4) {
3197
3315
  assertErrors.push(err);
3198
3316
  } else {
3199
3317
  throw failErr;
@@ -3210,7 +3328,7 @@ class Convo$6 {
3210
3328
  }
3211
3329
  }
3212
3330
  } else {
3213
- const failErr = new BotiumError$3(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util.inspect(convoStep.sender)}`);
3331
+ const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: invalid sender - ${util.inspect(convoStep.sender)}`);
3214
3332
  debug$i(failErr);
3215
3333
 
3216
3334
  try {
@@ -3221,7 +3339,7 @@ class Convo$6 {
3221
3339
  }
3222
3340
  } catch (err) {
3223
3341
  if (lastMeConvoStep) {
3224
- if (err instanceof BotiumError$3 && err.context) {
3342
+ if (err instanceof BotiumError$4 && err.context) {
3225
3343
  err.context.input = new ConvoStep$1(lastMeConvoStep);
3226
3344
  err.context.transcript = [...transcriptSteps, { ...transcriptStep
3227
3345
  }];
@@ -3233,7 +3351,14 @@ class Convo$6 {
3233
3351
  }
3234
3352
 
3235
3353
  transcriptStep.err = err;
3236
- throw err;
3354
+
3355
+ if (err instanceof BotiumError$4 && container.caps[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]) {
3356
+ if (!err.isAsserterError()) {
3357
+ throw err;
3358
+ }
3359
+ } else {
3360
+ throw err;
3361
+ }
3237
3362
  } finally {
3238
3363
  if (convoStep.sender !== 'begin' && convoStep.sender !== 'end' && !skipTranscriptStep) {
3239
3364
  transcriptStep.scriptingMemory = Object.assign({}, scriptingMemory);
@@ -3248,6 +3373,14 @@ class Convo$6 {
3248
3373
  transcript.steps = transcriptSteps.filter(s => s);
3249
3374
  transcript.scriptingMemory = scriptingMemory;
3250
3375
  transcript.convoEnd = new Date();
3376
+
3377
+ if (container.caps[Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]) {
3378
+ const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
3379
+
3380
+ if (transcriptStepErrs && transcriptStepErrs.length > 0) {
3381
+ transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
3382
+ }
3383
+ }
3251
3384
  }
3252
3385
  }
3253
3386
 
@@ -3256,11 +3389,11 @@ class Convo$6 {
3256
3389
 
3257
3390
  if (lodash.isArray(expected)) {
3258
3391
  if (!lodash.isArray(result)) {
3259
- throw new BotiumError$3(`${this.header.name}/${convoStep.stepTag}: bot response expected array, got "${result}"`);
3392
+ throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array, got "${result}"`);
3260
3393
  }
3261
3394
 
3262
3395
  if (expected.length !== result.length) {
3263
- throw new BotiumError$3(`${this.header.name}/${convoStep.stepTag}: bot response expected array length ${expected.length}, got ${result.length}`);
3396
+ throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response expected array length ${expected.length}, got ${result.length}`);
3264
3397
  }
3265
3398
 
3266
3399
  for (let i = 0; i < expected.length; i++) {
@@ -3271,7 +3404,7 @@ class Convo$6 {
3271
3404
  if (Object.prototype.hasOwnProperty.call(result, key)) {
3272
3405
  this._compareObject(container, scriptingMemory, convoStep, result[key], expected[key]);
3273
3406
  } else {
3274
- throw new BotiumError$3(`${this.header.name}/${convoStep.stepTag}: bot response "${result}" missing expected property: ${key}`);
3407
+ throw new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot response "${result}" missing expected property: ${key}`);
3275
3408
  }
3276
3409
  });
3277
3410
  } else {
@@ -3399,17 +3532,17 @@ class Convo$6 {
3399
3532
  const alreadyThereAt = parentPConvos.indexOf(includeLogicHook);
3400
3533
 
3401
3534
  if (alreadyThereAt >= 0) {
3402
- throw new BotiumError$3(`Partial convos are included circular. "${includeLogicHook}" is referenced by "/${parentPConvos.slice(0, alreadyThereAt).join('/')}" and by "/${parentPConvos.join('/')}" `);
3535
+ throw new BotiumError$4(`Partial convos are included circular. "${includeLogicHook}" is referenced by "/${parentPConvos.slice(0, alreadyThereAt).join('/')}" and by "/${parentPConvos.join('/')}" `);
3403
3536
  }
3404
3537
 
3405
3538
  if (!partialConvos || Object.keys(partialConvos).length === 0) {
3406
- throw new BotiumError$3(`Cant find partial convo with name ${includeLogicHook} (There are no partial convos)`);
3539
+ throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (There are no partial convos)`);
3407
3540
  }
3408
3541
 
3409
3542
  const partialConvo = partialConvos[includeLogicHook];
3410
3543
 
3411
3544
  if (!partialConvo) {
3412
- throw new BotiumError$3(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
3545
+ throw new BotiumError$4(`Cant find partial convo with name ${includeLogicHook} (available partial convos: ${Object.keys(partialConvos).join(',')})`);
3413
3546
  }
3414
3547
 
3415
3548
  _getEffectiveConversationRecursive(partialConvo.conversation, [...parentPConvos, includeLogicHook], result, true);
@@ -3791,7 +3924,7 @@ const {
3791
3924
  } = vm2;
3792
3925
  const debug$h = debug$l('botium-core-HookUtils');
3793
3926
  const {
3794
- BotiumError: BotiumError$2
3927
+ BotiumError: BotiumError$3
3795
3928
  } = BotiumError_1;
3796
3929
 
3797
3930
  const executeHook$2 = async (caps, hook, args) => {
@@ -3863,7 +3996,7 @@ const getHook$3 = (caps, data) => {
3863
3996
 
3864
3997
  if (resultWithRequire) {
3865
3998
  if (!allowUnsafe) {
3866
- throw new BotiumError$2('Security Error. Using unsafe custom hook with require is not allowed', {
3999
+ throw new BotiumError$3('Security Error. Using unsafe custom hook with require is not allowed', {
3867
4000
  type: 'security',
3868
4001
  subtype: 'allow unsafe',
3869
4002
  source: path.basename(__filename),
@@ -4318,6 +4451,9 @@ var Utterance_1 = class Utterance {
4318
4451
  };
4319
4452
 
4320
4453
  const debug$d = debug$l('botium-core-CompilerXlsx');
4454
+ const {
4455
+ E_SCRIPTING_MEMORY_COLUMN_MODE
4456
+ } = Enums;
4321
4457
  const {
4322
4458
  Convo: Convo$5
4323
4459
  } = Convo_1;
@@ -4630,49 +4766,120 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4630
4766
  }
4631
4767
 
4632
4768
  if (scriptType === Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY) {
4633
- const variableNames = [];
4634
- let colindexTemp = colindex + 1;
4635
-
4636
- while (true) {
4637
- const variableNameCell = this.colnames[colindexTemp] + rowindex;
4769
+ const guessScriptingMemoryColumnMode = () => {
4770
+ const line1Cell = this.colnames[colindex] + (rowindex + 1);
4638
4771
 
4639
- if (sheet[variableNameCell] && sheet[variableNameCell].v) {
4640
- variableNames.push(sheet[variableNameCell].v);
4641
- } else {
4642
- break;
4772
+ if (sheet[line1Cell] && sheet[line1Cell].v) {
4773
+ if (sheet[line1Cell].v.startsWith('$')) return E_SCRIPTING_MEMORY_COLUMN_MODE.TESTCASENAMES;
4643
4774
  }
4644
4775
 
4645
- colindexTemp++;
4646
- }
4776
+ return E_SCRIPTING_MEMORY_COLUMN_MODE.VARNAMES;
4777
+ };
4647
4778
 
4648
- rowindex += 1;
4779
+ const columnMode = this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE] || guessScriptingMemoryColumnMode();
4649
4780
 
4650
- while (true) {
4651
- const caseNameCell = this.colnames[colindex] + rowindex;
4781
+ if (columnMode === E_SCRIPTING_MEMORY_COLUMN_MODE.TESTCASENAMES) {
4782
+ const caseNames = [];
4783
+ let colindexTemp = colindex + 1;
4652
4784
 
4653
- if (sheet[caseNameCell] && sheet[caseNameCell].v) {
4654
- const caseName = sheet[caseNameCell].v;
4655
- const values = {};
4785
+ while (true) {
4786
+ const caseNameCell = this.colnames[colindexTemp] + rowindex;
4656
4787
 
4657
- for (let i = 0; i < variableNames.length; i++) {
4658
- const variableValueCell = this.colnames[colindex + 1 + i] + rowindex;
4788
+ if (sheet[caseNameCell] && sheet[caseNameCell].v) {
4789
+ caseNames.push(sheet[caseNameCell].v);
4790
+ } else {
4791
+ break;
4792
+ }
4659
4793
 
4660
- if (sheet[variableValueCell] && sheet[variableValueCell].v) {
4661
- values[variableNames[i]] = sheet[variableValueCell].v.toString();
4662
- } else {
4663
- values[variableNames[i]] = null;
4794
+ colindexTemp++;
4795
+ }
4796
+
4797
+ const varNames = [];
4798
+ const varValues = [];
4799
+ rowindex += 1;
4800
+
4801
+ while (true) {
4802
+ const varNameCell = this.colnames[colindex] + rowindex;
4803
+
4804
+ if (sheet[varNameCell] && sheet[varNameCell].v) {
4805
+ varNames.push(sheet[varNameCell].v);
4806
+ const values = [];
4807
+
4808
+ for (let i = 0; i < caseNames.length; i++) {
4809
+ const variableValueCell = this.colnames[colindex + 1 + i] + rowindex;
4810
+
4811
+ if (sheet[variableValueCell] && sheet[variableValueCell].v) {
4812
+ values.push(sheet[variableValueCell].v.toString());
4813
+ } else {
4814
+ values.push(null);
4815
+ }
4664
4816
  }
4817
+
4818
+ varValues.push(values);
4819
+ rowindex += 1;
4820
+ } else {
4821
+ break;
4665
4822
  }
4823
+ }
4666
4824
 
4667
- rowindex += 1;
4825
+ for (let caseIndex = 0; caseIndex < caseNames.length; caseIndex++) {
4826
+ const caseName = caseNames[caseIndex];
4827
+ const values = varNames.reduce((agg, varName, varIndex) => {
4828
+ agg[varName] = varValues[varIndex][caseIndex] || null;
4829
+ return agg;
4830
+ }, {});
4668
4831
  scriptResults.push({
4669
4832
  header: {
4670
4833
  name: caseName
4671
4834
  },
4672
4835
  values: values
4673
4836
  });
4674
- } else {
4675
- break;
4837
+ }
4838
+ } else {
4839
+ const variableNames = [];
4840
+ let colindexTemp = colindex + 1;
4841
+
4842
+ while (true) {
4843
+ const variableNameCell = this.colnames[colindexTemp] + rowindex;
4844
+
4845
+ if (sheet[variableNameCell] && sheet[variableNameCell].v) {
4846
+ variableNames.push(sheet[variableNameCell].v);
4847
+ } else {
4848
+ break;
4849
+ }
4850
+
4851
+ colindexTemp++;
4852
+ }
4853
+
4854
+ rowindex += 1;
4855
+
4856
+ while (true) {
4857
+ const caseNameCell = this.colnames[colindex] + rowindex;
4858
+
4859
+ if (sheet[caseNameCell] && sheet[caseNameCell].v) {
4860
+ const caseName = sheet[caseNameCell].v;
4861
+ const values = {};
4862
+
4863
+ for (let i = 0; i < variableNames.length; i++) {
4864
+ const variableValueCell = this.colnames[colindex + 1 + i] + rowindex;
4865
+
4866
+ if (sheet[variableValueCell] && sheet[variableValueCell].v) {
4867
+ values[variableNames[i]] = sheet[variableValueCell].v.toString();
4868
+ } else {
4869
+ values[variableNames[i]] = null;
4870
+ }
4871
+ }
4872
+
4873
+ rowindex += 1;
4874
+ scriptResults.push({
4875
+ header: {
4876
+ name: caseName
4877
+ },
4878
+ values: values
4879
+ });
4880
+ } else {
4881
+ break;
4882
+ }
4676
4883
  }
4677
4884
  }
4678
4885
  }
@@ -4832,7 +5039,8 @@ const {
4832
5039
  linesToConvoStep: linesToConvoStep$3,
4833
5040
  convoStepToLines,
4834
5041
  validateConvo,
4835
- validSenders: validSenders$2
5042
+ validSenders: validSenders$2,
5043
+ linesToScriptingMemories: linesToScriptingMemories$1
4836
5044
  } = helper;
4837
5045
  var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
4838
5046
  constructor(context, caps = {}) {
@@ -4963,30 +5171,12 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
4963
5171
 
4964
5172
  _compileScriptingMemory(lines) {
4965
5173
  if (lines && lines.length > 1) {
4966
- const names = lines[0].split('|').map(name => name.trim()).slice(1);
4967
- const scriptingMemories = [];
4968
-
4969
- for (let row = 1; row < lines.length; row++) {
4970
- if (!lines[row] || lines[row].length === 0) continue;
4971
- const rawRow = lines[row].split('|').map(name => name.trim());
4972
- const caseName = rawRow[0];
4973
- const values = rawRow.slice(1);
4974
- const json = {};
5174
+ const scriptingMemories = linesToScriptingMemories$1(lines, this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE]);
4975
5175
 
4976
- for (let col = 0; col < names.length; col++) {
4977
- json[names[col]] = values[col];
4978
- }
4979
-
4980
- const scriptingMemory = {
4981
- header: {
4982
- name: caseName
4983
- },
4984
- values: json
4985
- };
4986
- scriptingMemories.push(scriptingMemory);
5176
+ if (scriptingMemories && scriptingMemories.length > 0) {
5177
+ this.context.AddScriptingMemories(scriptingMemories);
4987
5178
  }
4988
5179
 
4989
- this.context.AddScriptingMemories(scriptingMemories);
4990
5180
  return scriptingMemories;
4991
5181
  }
4992
5182
  }
@@ -5030,6 +5220,9 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
5030
5220
 
5031
5221
  };
5032
5222
 
5223
+ const {
5224
+ parse
5225
+ } = sync;
5033
5226
  const debug$c = debug$l('botium-core-CompilerCsv');
5034
5227
  const {
5035
5228
  Convo: Convo$3
@@ -5102,7 +5295,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5102
5295
  let rows;
5103
5296
 
5104
5297
  try {
5105
- rows = sync(scriptData, {
5298
+ rows = parse(scriptData, {
5106
5299
  delimiter,
5107
5300
  escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
5108
5301
  quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
@@ -5241,7 +5434,8 @@ const {
5241
5434
  } = Convo_1;
5242
5435
  const {
5243
5436
  linesToConvoStep: linesToConvoStep$1,
5244
- validSenders: validSenders$1
5437
+ validSenders: validSenders$1,
5438
+ linesToScriptingMemories
5245
5439
  } = helper;
5246
5440
  var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
5247
5441
  constructor(context, caps = {}) {
@@ -5350,29 +5544,12 @@ var CompilerObjectBase_1 = class CompilerObjectBase extends CompilerBase_1 {
5350
5544
  if (lines && lines.length > 0) {
5351
5545
  if (lodash.isString(lines[0])) {
5352
5546
  if (lines.length > 1) {
5353
- const names = lines[0].split('|').map(name => name.trim()).slice(1);
5354
- const scriptingMemories = [];
5547
+ const scriptingMemories = linesToScriptingMemories(lines, this.caps[Capabilities.SCRIPTING_MEMORY_COLUMN_MODE]);
5355
5548
 
5356
- for (let row = 1; row < lines.length; row++) {
5357
- const rawRow = lines[row].split('|').map(name => name.trim());
5358
- const caseName = rawRow[0];
5359
- const values = rawRow.slice(1);
5360
- const json = {};
5361
-
5362
- for (let col = 0; col < names.length; col++) {
5363
- json[names[col]] = values[col];
5364
- }
5365
-
5366
- const scriptingMemory = {
5367
- header: {
5368
- name: caseName
5369
- },
5370
- values: json
5371
- };
5372
- scriptingMemories.push(scriptingMemory);
5549
+ if (scriptingMemories && scriptingMemories.length > 0) {
5550
+ this.context.AddScriptingMemories(scriptingMemories);
5373
5551
  }
5374
5552
 
5375
- this.context.AddScriptingMemories(scriptingMemories);
5376
5553
  return scriptingMemories;
5377
5554
  }
5378
5555
  } else {
@@ -5565,7 +5742,7 @@ const {
5565
5742
  ConvoStep
5566
5743
  } = Convo_1;
5567
5744
  const {
5568
- BotiumError: BotiumError$1,
5745
+ BotiumError: BotiumError$2,
5569
5746
  botiumErrorFromList,
5570
5747
  botiumErrorFromErr
5571
5748
  } = BotiumError_1;
@@ -5845,7 +6022,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
5845
6022
  message += ' expected to match ';
5846
6023
  message += tomatch && tomatch.length > 1 ? 'one of ' : '';
5847
6024
  message += `${tomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
5848
- throw new BotiumError$1(message, {
6025
+ throw new BotiumError$2(message, {
5849
6026
  type: 'asserter',
5850
6027
  source: 'TextMatchAsserter',
5851
6028
  context: {
@@ -5875,7 +6052,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
5875
6052
  message += ' expected NOT to match ';
5876
6053
  message += nottomatch && nottomatch.length > 1 ? 'one of ' : '';
5877
6054
  message += `${nottomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
5878
- throw new BotiumError$1(message, {
6055
+ throw new BotiumError$2(message, {
5879
6056
  type: 'asserter',
5880
6057
  source: 'TextMatchAsserter',
5881
6058
  context: {
@@ -5922,7 +6099,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
5922
6099
  if (asserter[notAsserterType]) {
5923
6100
  return p(this.retryHelperAsserter, () => asserter[notAsserterType](params));
5924
6101
  } else {
5925
- return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$1(`${convoStep.stepTag}: Expected asserter ${asserter.name || asserterSpec.name} with args "${params.args}" to fail`, {
6102
+ return pnot(this.retryHelperAsserter, () => asserter[asserterType](params), new BotiumError$2(`${convoStep.stepTag}: Expected asserter ${asserter.name || asserterSpec.name} with args "${params.args}" to fail`, {
5926
6103
  type: 'asserter',
5927
6104
  source: asserter.name || asserterSpec.name,
5928
6105
  params: {
@@ -6356,7 +6533,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6356
6533
  });
6357
6534
 
6358
6535
  if (aggregatedNoNames.length) {
6359
- throw new BotiumError$1('Scripting Memory Definition(s) without name', {
6536
+ throw new BotiumError$2('Scripting Memory Definition(s) without name', {
6360
6537
  type: 'Scripting Memory',
6361
6538
  subtype: 'Scripting Memory without name',
6362
6539
  source: 'ScriptingProvider',
@@ -6372,7 +6549,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6372
6549
  });
6373
6550
 
6374
6551
  if (aggregatedNoVariables.length) {
6375
- throw new BotiumError$1(`Scripting Memory Definition(s) ${aggregatedNoVariables.map(e => e.header.name).join(', ')} without variable`, {
6552
+ throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariables.map(e => e.header.name).join(', ')} without variable`, {
6376
6553
  type: 'Scripting Memory',
6377
6554
  subtype: 'Scripting Memory without variable',
6378
6555
  source: 'ScriptingProvider',
@@ -6388,7 +6565,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6388
6565
  });
6389
6566
 
6390
6567
  if (aggregatedNoVariableNames.length) {
6391
- throw new BotiumError$1(`Scripting Memory Definition(s) ${aggregatedNoVariableNames.map(e => e.header.name).join(', ')} without variable name`, {
6568
+ throw new BotiumError$2(`Scripting Memory Definition(s) ${aggregatedNoVariableNames.map(e => e.header.name).join(', ')} without variable name`, {
6392
6569
  type: 'Scripting Memory',
6393
6570
  subtype: 'Scripting Memory without variable name',
6394
6571
  source: 'ScriptingProvider',
@@ -6420,7 +6597,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6420
6597
  }
6421
6598
 
6422
6599
  if (aggregatedDuplicates.length) {
6423
- throw new BotiumError$1(`Scripting Memory Definition name(s) "${lodash.uniq(aggregatedDuplicates.map(d => d.scriptingMemory.header.name)).join(', ')}" are not unique`, {
6600
+ throw new BotiumError$2(`Scripting Memory Definition name(s) "${lodash.uniq(aggregatedDuplicates.map(d => d.scriptingMemory.header.name)).join(', ')}" are not unique`, {
6424
6601
  type: 'Scripting Memory',
6425
6602
  subtype: 'Scripting Memory name collision',
6426
6603
  source: 'ScriptingProvider',
@@ -6457,7 +6634,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6457
6634
  }
6458
6635
 
6459
6636
  if (aggregatedIntersections.length) {
6460
- throw new BotiumError$1(`Scripting Memory Definitions "${aggregatedIntersections.map(i => i.scriptingMemory.header.name).join(', ')}" are invalid because variable name collision"`, {
6637
+ throw new BotiumError$2(`Scripting Memory Definitions "${aggregatedIntersections.map(i => i.scriptingMemory.header.name).join(', ')}" are invalid because variable name collision"`, {
6461
6638
  type: 'Scripting Memory',
6462
6639
  subtype: 'Scripting Memory variable name collision',
6463
6640
  source: 'ScriptingProvider',
@@ -6546,6 +6723,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
6546
6723
 
6547
6724
  debug$9(`ExpandScriptingMemoryToConvos - ${convosExpandedAll.length} convo expanded, added to convos (${this.convos.length}). Result ${convosExpandedAll.length + this.convos.length} convo`);
6548
6725
  this.convos = this.convos.concat(convosExpandedAll);
6726
+
6727
+ this._sortConvos();
6549
6728
  }
6550
6729
 
6551
6730
  ExpandUtterancesToConvos({
@@ -6585,6 +6764,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
6585
6764
  },
6586
6765
  conversation: [{
6587
6766
  sender: 'me',
6767
+ logicHooks: [{
6768
+ name: 'SKIP_BOT_UNCONSUMED'
6769
+ }],
6588
6770
  messageText: utt.name,
6589
6771
  stepTag: 'Step 1 - tell utterance'
6590
6772
  }, useNameAsIntent ? {
@@ -6900,7 +7082,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6900
7082
  }
6901
7083
  } else if (scriptingMemories) {
6902
7084
  if (!scriptingMemories.header || !scriptingMemories.header.name) {
6903
- throw new BotiumError$1('Scripting Memory Definition has no name', {
7085
+ throw new BotiumError$2('Scripting Memory Definition has no name', {
6904
7086
  type: 'Compiler',
6905
7087
  subtype: 'Scripting memory without name',
6906
7088
  source: 'ScriptingProvider',
@@ -6911,7 +7093,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6911
7093
  }
6912
7094
 
6913
7095
  if (!scriptingMemories.values || !Object.keys(scriptingMemories.values).length) {
6914
- throw new BotiumError$1('Scripting Memory Definition has no variables', {
7096
+ throw new BotiumError$2('Scripting Memory Definition has no variables', {
6915
7097
  type: 'Compiler',
6916
7098
  subtype: 'Scripting memory without variable',
6917
7099
  source: 'ScriptingProvider',
@@ -6922,7 +7104,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6922
7104
  }
6923
7105
 
6924
7106
  if (scriptingMemories.values && !lodash.isUndefined(scriptingMemories.values[''])) {
6925
- throw new BotiumError$1('Scripting Memory Definition variable has no name', {
7107
+ throw new BotiumError$2('Scripting Memory Definition variable has no name', {
6926
7108
  type: 'Compiler',
6927
7109
  subtype: 'Scripting memory without variable name',
6928
7110
  source: 'ScriptingProvider',
@@ -7357,7 +7539,7 @@ var BaseContainer_1 = class BaseContainer {
7357
7539
  this.tempDirectory = tempDirectory;
7358
7540
  this.cleanupTasks = [];
7359
7541
  this.queues = {};
7360
- this.userSaysLimiter = null;
7542
+ this.bottleneck = null;
7361
7543
  }
7362
7544
 
7363
7545
  Validate() {
@@ -7367,18 +7549,33 @@ var BaseContainer_1 = class BaseContainer {
7367
7549
  this.onBotResponseHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONBOTRESPONSE]);
7368
7550
  this.onStopHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONSTOP]);
7369
7551
  this.onCleanHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONCLEAN]);
7370
- return Promise.resolve();
7371
- }
7372
7552
 
7373
- Build() {
7374
- if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT] || this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) {
7553
+ if (this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN]) {
7554
+ if (lodash.isFunction(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN])) {
7555
+ this.bottleneck = this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN];
7556
+ debug$7('Validate: Applying userSays rate limits from capability');
7557
+ } else {
7558
+ const limiter = new bottleneck(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN]);
7559
+
7560
+ this.bottleneck = fn => limiter.schedule(fn);
7561
+
7562
+ debug$7(`Validate: Applying userSays rate limits ${util.inspect(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN])}`);
7563
+ }
7564
+ } else if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT] || this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) {
7375
7565
  const opts = {};
7376
7566
  if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT]) opts.maxConcurrent = this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT];
7377
7567
  if (this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) opts.minTime = this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME];
7378
- this.userSaysLimiter = new bottleneck(opts);
7379
- debug$7(`Build: Applying userSays rate limits ${util.inspect(opts)}`);
7568
+ const limiter = new bottleneck(opts);
7569
+
7570
+ this.bottleneck = fn => limiter.schedule(fn);
7571
+
7572
+ debug$7(`Validate: Applying userSays rate limits ${util.inspect(opts)}`);
7380
7573
  }
7381
7574
 
7575
+ return Promise.resolve();
7576
+ }
7577
+
7578
+ Build() {
7382
7579
  return new Promise((resolve, reject) => {
7383
7580
  this._RunCustomHook('onBuild', this.onBuildHook).then(() => resolve(this)).catch(err => reject(err));
7384
7581
  });
@@ -7404,8 +7601,8 @@ var BaseContainer_1 = class BaseContainer {
7404
7601
  meMsg
7405
7602
  }).then(() => this.UserSaysImpl(meMsg));
7406
7603
 
7407
- if (this.userSaysLimiter) {
7408
- return this.userSaysLimiter.schedule(run);
7604
+ if (this.bottleneck) {
7605
+ return this.bottleneck(run);
7409
7606
  } else {
7410
7607
  return run();
7411
7608
  }
@@ -7884,16 +8081,23 @@ const {
7884
8081
  const {
7885
8082
  escapeJSONString
7886
8083
  } = Utils;
8084
+ const {
8085
+ BotiumError: BotiumError$1
8086
+ } = BotiumError_1;
7887
8087
 
7888
8088
  mustache.escape = s => s;
7889
8089
 
7890
8090
  var SimpleRestContainer_1 = class SimpleRestContainer {
7891
8091
  constructor({
7892
8092
  queueBotSays,
7893
- caps
8093
+ caps,
8094
+ bottleneck
7894
8095
  }) {
7895
8096
  this.queueBotSays = queueBotSays;
7896
8097
  this.caps = Object.assign({}, Defaults, caps);
8098
+
8099
+ this.bottleneck = bottleneck || (fn => fn());
8100
+
7897
8101
  this.processInbound = false;
7898
8102
  this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
7899
8103
 
@@ -8268,6 +8472,22 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8268
8472
  } else {
8269
8473
  if (response.statusCode >= 400) {
8270
8474
  debug$4(`got error response: ${response.statusCode}/${response.statusMessage}`);
8475
+
8476
+ if (debug$4.enabled && body) {
8477
+ debug$4(Utils.shortenJsonString(body));
8478
+ }
8479
+
8480
+ if (body) {
8481
+ const jsonBody = Utils.toJsonWeak(body);
8482
+ const errKey = Object.keys(jsonBody).find(k => k.startsWith('err') || k.startsWith('fail'));
8483
+
8484
+ if (errKey) {
8485
+ return reject(new BotiumError$1(`got error response: ${response.statusCode}/${response.statusMessage} - ${jsonBody[errKey]}`, {
8486
+ message: Utils.shortenJsonString(body)
8487
+ }));
8488
+ }
8489
+ }
8490
+
8271
8491
  return reject(new Error(`got error response: ${response.statusCode}/${response.statusMessage}`));
8272
8492
  }
8273
8493
 
@@ -8365,6 +8585,16 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8365
8585
  }
8366
8586
  }
8367
8587
 
8588
+ if (msg.ADD_FORM_PARAM && Object.keys(msg.ADD_FORM_PARAM).length > 0) {
8589
+ requestOptions.form = {};
8590
+
8591
+ for (const formKey of Object.keys(msg.ADD_FORM_PARAM)) {
8592
+ const formValue = this._getMustachedVal(lodash.isString(msg.ADD_FORM_PARAM[formKey]) ? msg.ADD_FORM_PARAM[formKey] : JSON.stringify(msg.ADD_FORM_PARAM[formKey]), false);
8593
+
8594
+ requestOptions.form[formKey] = formValue;
8595
+ }
8596
+ }
8597
+
8368
8598
  if (msg.ADD_HEADER && Object.keys(msg.ADD_HEADER).length > 0) {
8369
8599
  requestOptions.headers = requestOptions.headers || {};
8370
8600
 
@@ -8406,7 +8636,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8406
8636
  err,
8407
8637
  response,
8408
8638
  body
8409
- } = await new Promise(resolve => {
8639
+ } = await this.bottleneck(() => new Promise(resolve => {
8410
8640
  request(pingConfig, (err, response, body) => {
8411
8641
  resolve({
8412
8642
  err,
@@ -8414,16 +8644,26 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8414
8644
  body
8415
8645
  });
8416
8646
  });
8417
- });
8647
+ }));
8418
8648
 
8419
8649
  if (err) {
8420
8650
  debug$4(`_waitForUrlResponse error on url check ${pingConfig.uri}: ${err}`);
8421
8651
  await timeout(pingConfig.timeout);
8422
8652
  } else if (response.statusCode >= 400) {
8423
8653
  debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
8654
+
8655
+ if (debug$4.enabled && body) {
8656
+ debug$4(Utils.shortenJsonString(body));
8657
+ }
8658
+
8424
8659
  await timeout(pingConfig.timeout);
8425
8660
  } else {
8426
- debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}`);
8661
+ debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8662
+
8663
+ if (debug$4.enabled && body) {
8664
+ debug$4(Utils.shortenJsonString(body));
8665
+ }
8666
+
8427
8667
  return body;
8428
8668
  }
8429
8669
  }
@@ -8647,6 +8887,10 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8647
8887
  } else {
8648
8888
  if (response.statusCode >= 400) {
8649
8889
  debug$4(`_runPolling: got error response: ${response.statusCode}/${response.statusMessage}, request: ${JSON.stringify(pollConfig)}`);
8890
+
8891
+ if (debug$4.enabled && body) {
8892
+ debug$4(Utils.shortenJsonString(body));
8893
+ }
8650
8894
  } else if (body) {
8651
8895
  debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8652
8896
 
@@ -8924,6 +9168,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
8924
9168
  this.pluginInstance = tryLoadPlugin(this.caps[Capabilities.CONTAINERMODE], this.caps[Capabilities.PLUGINMODULEPATH], {
8925
9169
  container: this,
8926
9170
  queueBotSays: msg => this._QueueBotSays(msg),
9171
+ bottleneck: this.bottleneck,
8927
9172
  eventEmitter: this.eventEmitter,
8928
9173
  caps: this.caps,
8929
9174
  sources: this.sources,
@@ -9621,6 +9866,7 @@ var botiumCore = {
9621
9866
  ScriptingConstants: Constants,
9622
9867
  Capabilities: Capabilities,
9623
9868
  Defaults: Defaults$1,
9869
+ Enums: Enums,
9624
9870
  Source: Source,
9625
9871
  Events: Events,
9626
9872
  Plugins: Plugins,
@@ -9640,16 +9886,17 @@ var botiumCore_2 = botiumCore.ScriptingProvider;
9640
9886
  var botiumCore_3 = botiumCore.ScriptingConstants;
9641
9887
  var botiumCore_4 = botiumCore.Capabilities;
9642
9888
  var botiumCore_5 = botiumCore.Defaults;
9643
- var botiumCore_6 = botiumCore.Source;
9644
- var botiumCore_7 = botiumCore.Events;
9645
- var botiumCore_8 = botiumCore.Plugins;
9646
- var botiumCore_9 = botiumCore.BotiumError;
9647
- var botiumCore_10 = botiumCore.ScriptingMemory;
9648
- var botiumCore_11 = botiumCore.HookUtils;
9649
- var botiumCore_12 = botiumCore.LogicHookConstants;
9650
- var botiumCore_13 = botiumCore.Lib;
9651
- var botiumCore_14 = botiumCore.InboundProxy;
9652
- var botiumCore_15 = botiumCore.BotiumMockRichMessageTypes;
9653
-
9654
- export { botiumCore_1 as BotDriver, botiumCore_9 as BotiumError, botiumCore_15 as BotiumMockRichMessageTypes, botiumCore_4 as Capabilities, botiumCore_5 as Defaults, botiumCore_7 as Events, botiumCore_11 as HookUtils, botiumCore_14 as InboundProxy, botiumCore_13 as Lib, botiumCore_12 as LogicHookConstants, botiumCore_8 as Plugins, botiumCore_3 as ScriptingConstants, botiumCore_10 as ScriptingMemory, botiumCore_2 as ScriptingProvider, botiumCore_6 as Source, botiumCore as default };
9889
+ var botiumCore_6 = botiumCore.Enums;
9890
+ var botiumCore_7 = botiumCore.Source;
9891
+ var botiumCore_8 = botiumCore.Events;
9892
+ var botiumCore_9 = botiumCore.Plugins;
9893
+ var botiumCore_10 = botiumCore.BotiumError;
9894
+ var botiumCore_11 = botiumCore.ScriptingMemory;
9895
+ var botiumCore_12 = botiumCore.HookUtils;
9896
+ var botiumCore_13 = botiumCore.LogicHookConstants;
9897
+ var botiumCore_14 = botiumCore.Lib;
9898
+ var botiumCore_15 = botiumCore.InboundProxy;
9899
+ var botiumCore_16 = botiumCore.BotiumMockRichMessageTypes;
9900
+
9901
+ export { botiumCore_1 as BotDriver, botiumCore_10 as BotiumError, botiumCore_16 as BotiumMockRichMessageTypes, botiumCore_4 as Capabilities, botiumCore_5 as Defaults, botiumCore_6 as Enums, botiumCore_8 as Events, botiumCore_12 as HookUtils, botiumCore_15 as InboundProxy, botiumCore_14 as Lib, botiumCore_13 as LogicHookConstants, botiumCore_9 as Plugins, botiumCore_3 as ScriptingConstants, botiumCore_11 as ScriptingMemory, botiumCore_2 as ScriptingProvider, botiumCore_7 as Source, botiumCore as default };
9655
9902
  //# sourceMappingURL=botium-es.js.map