botium-core 1.12.4 → 1.13.0

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 (36) hide show
  1. package/LICENSES-3RDPARTY.txt +390 -225
  2. package/dist/botium-cjs.js +298 -161
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +298 -161
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +28 -28
  7. package/src/BotDriver.js +24 -19
  8. package/src/Capabilities.js +8 -0
  9. package/src/Defaults.js +1 -0
  10. package/src/containers/plugins/SimpleRestContainer.js +42 -8
  11. package/src/containers/plugins/index.js +1 -1
  12. package/src/helpers/Utils.js +1 -1
  13. package/src/scripting/CompilerCsv.js +150 -102
  14. package/src/scripting/CompilerXlsx.js +2 -2
  15. package/src/scripting/Convo.js +4 -4
  16. package/src/scripting/ScriptingProvider.js +6 -2
  17. package/src/scripting/helper.js +20 -13
  18. package/src/scripting/logichook/asserter/BaseCountAsserter.js +1 -1
  19. package/src/scripting/logichook/asserter/ButtonsAsserter.js +4 -2
  20. package/src/scripting/logichook/asserter/CardsAsserter.js +4 -2
  21. package/test/compiler/compilercsv.spec.js +363 -12
  22. package/test/compiler/compilertxt.spec.js +13 -0
  23. package/test/compiler/convos/csv/utterances_liveperson.csv +108 -0
  24. package/test/compiler/convos/csv/utterances_multicolumn3col.csv +3 -0
  25. package/test/compiler/convos/csv/utterances_multicolumn5col.csv +3 -0
  26. package/test/compiler/convos/csv/utterances_singlecolumn.csv +3 -0
  27. package/test/compiler/convos/csv/utterances_variable_row_len.csv +3 -0
  28. package/test/compiler/convos/txt/convos_args_escape.convo.txt +2 -0
  29. package/test/connectors/simplerest.spec.js +49 -8
  30. package/test/convo/convos/continuefailing_timeout.convo.txt +16 -0
  31. package/test/convo/transcript.spec.js +18 -1
  32. package/test/logichooks/convos/WAITFORBOT_INFINITE.convo.txt +1 -1
  33. package/test/scripting/asserters/buttonsAsserter.spec.js +47 -0
  34. package/test/scripting/asserters/cardsAsserter.spec.js +39 -0
  35. package/test/scripting/scriptingProvider.spec.js +1 -1
  36. package/test/scripting/txt/decompile.spec.js +24 -0
package/dist/botium-es.js CHANGED
@@ -36,7 +36,7 @@ import express from 'express';
36
36
  import bodyParser from 'body-parser';
37
37
 
38
38
  var name = "botium-core";
39
- var version$1 = "1.12.4";
39
+ var version$1 = "1.13.0";
40
40
  var description = "The Selenium for Chatbots";
41
41
  var main = "index.js";
42
42
  var module = "dist/botium-es.js";
@@ -68,25 +68,25 @@ var bugs = {
68
68
  };
69
69
  var homepage = "https://www.botium.ai";
70
70
  var dependencies = {
71
- "@babel/runtime": "^7.17.8",
72
- async: "^3.2.3",
73
- "body-parser": "^1.19.2",
71
+ "@babel/runtime": "^7.18.3",
72
+ async: "^3.2.4",
73
+ "body-parser": "^1.20.0",
74
74
  boolean: "^3.2.0",
75
75
  bottleneck: "^2.19.5",
76
- "csv-parse": "^5.0.4",
76
+ "csv-parse": "^5.2.0",
77
77
  debug: "^4.3.4",
78
78
  esprima: "^4.0.1",
79
- express: "^4.17.3",
79
+ express: "^4.18.1",
80
80
  globby: "11.0.4",
81
- ioredis: "^4.28.5",
81
+ ioredis: "^5.0.6",
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.3.2",
86
+ "markdown-it": "^13.0.1",
87
87
  "mime-types": "^2.1.35",
88
88
  mkdirp: "^1.0.4",
89
- moment: "^2.29.1",
89
+ moment: "^2.29.3",
90
90
  mustache: "^4.2.0",
91
91
  "promise-retry": "^2.0.1",
92
92
  "promise.allsettled": "^1.0.5",
@@ -95,39 +95,39 @@ var dependencies = {
95
95
  rimraf: "^3.0.2",
96
96
  "sanitize-filename": "^1.6.3",
97
97
  slugify: "^1.6.5",
98
- "socket.io": "^4.4.1",
99
- "socket.io-client": "^4.4.1",
98
+ "socket.io": "^4.5.1",
99
+ "socket.io-client": "^4.5.1",
100
100
  "socketio-auth": "^0.1.1",
101
- "swagger-jsdoc": "^6.1.0",
102
- "swagger-ui-express": "^4.3.0",
101
+ "swagger-jsdoc": "^6.2.1",
102
+ "swagger-ui-express": "^4.4.0",
103
103
  uuid: "^8.3.2",
104
104
  vm2: "^3.9.9",
105
105
  "write-yaml": "^1.0.0",
106
- xlsx: "^0.18.4",
107
- xregexp: "^5.1.0",
108
- yaml: "^1.10.2"
106
+ xlsx: "^0.18.5",
107
+ xregexp: "^5.1.1",
108
+ yaml: "^2.1.1"
109
109
  };
110
110
  var devDependencies = {
111
- "@babel/core": "^7.17.8",
112
- "@babel/node": "^7.16.8",
113
- "@babel/plugin-transform-runtime": "^7.17.0",
114
- "@babel/preset-env": "^7.16.11",
111
+ "@babel/core": "^7.18.5",
112
+ "@babel/node": "^7.18.5",
113
+ "@babel/plugin-transform-runtime": "^7.18.5",
114
+ "@babel/preset-env": "^7.18.2",
115
115
  chai: "^4.3.6",
116
116
  "chai-as-promised": "^7.1.1",
117
117
  "cross-env": "^7.0.3",
118
- eslint: "^8.11.0",
119
- "eslint-config-standard": "^16.0.3",
120
- "eslint-plugin-import": "^2.25.4",
121
- "eslint-plugin-node": "^11.1.0",
118
+ eslint: "^8.18.0",
119
+ "eslint-config-standard": "^17.0.0",
120
+ "eslint-plugin-import": "^2.26.0",
121
+ "eslint-plugin-n": "^15.2.3",
122
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.2.2",
127
- nock: "^13.2.4",
128
- "npm-check-updates": "^12.5.4",
126
+ mocha: "^10.0.0",
127
+ nock: "^13.2.7",
128
+ "npm-check-updates": "^14.0.1",
129
129
  nyc: "^15.1.0",
130
- rollup: "^2.70.1",
130
+ rollup: "^2.75.6",
131
131
  "rollup-plugin-babel": "^4.4.0",
132
132
  "rollup-plugin-commonjs": "^10.1.0",
133
133
  "rollup-plugin-json": "^4.0.0",
@@ -262,6 +262,7 @@ var Capabilities = {
262
262
  SIMPLEREST_REDIS_TOPIC: 'SIMPLEREST_REDIS_TOPIC',
263
263
  SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH: 'SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH',
264
264
  SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT: 'SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT',
265
+ SIMPLEREST_COOKIE_REPLICATION: 'SIMPLEREST_COOKIE_REPLICATION',
265
266
  // Script Compiler
266
267
  SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
267
268
  // ROW_PER_MESSAGE or QUESTION_ANSWER
@@ -275,6 +276,10 @@ var Capabilities = {
275
276
  SCRIPTING_XLSX_SHEETNAMES_PCONVOS: 'SCRIPTING_XLSX_SHEETNAMES_PCONVOS',
276
277
  SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'SCRIPTING_XLSX_SHEETNAMES_UTTERANCES',
277
278
  SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY: 'SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY',
279
+ // hidden capability. All newly in Box created testsets will have this as true. CsvCompiler
280
+ // - throws less error (Box reads csv files as utterances, and convo. Compiler cant throw exception if a file is correct, but box tries to load it with incorrect script type)
281
+ // 4 or more colums are compiled just as utterances.
282
+ SCRIPTING_CSV_LEGACY_MODE_OFF: 'SCRIPTING_CSV_LEGACY_MODE_OFF',
278
283
  SCRIPTING_CSV_DELIMITER: 'SCRIPTING_CSV_DELIMITER',
279
284
  SCRIPTING_CSV_SKIP_HEADER: 'SCRIPTING_CSV_SKIP_HEADER',
280
285
  SCRIPTING_CSV_QUOTE: 'SCRIPTING_CSV_QUOTE',
@@ -284,6 +289,9 @@ var Capabilities = {
284
289
  SCRIPTING_CSV_MULTIROW_COLUMN_TEXT: 'SCRIPTING_CSV_MULTIROW_COLUMN_TEXT',
285
290
  SCRIPTING_CSV_QA_COLUMN_QUESTION: 'SCRIPTING_CSV_QA_COLUMN_QUESTION',
286
291
  SCRIPTING_CSV_QA_COLUMN_ANSWER: 'SCRIPTING_CSV_QA_COLUMN_ANSWER',
292
+ SCRIPTING_CSV_UTTERANCE_STARTROW: 'SCRIPTING_CSV_UTTERANCE_STARTROW',
293
+ SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER: 'SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER',
294
+ SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY: 'SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY',
287
295
  SCRIPTING_NORMALIZE_TEXT: 'SCRIPTING_NORMALIZE_TEXT',
288
296
  SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
289
297
  SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
@@ -413,6 +421,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
413
421
  Capabilities.SIMPLEREST_REDIS_TOPIC;
414
422
  Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
415
423
  Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
424
+ Capabilities.SIMPLEREST_COOKIE_REPLICATION;
416
425
  Capabilities.SCRIPTING_TXT_EOL;
417
426
  Capabilities.SCRIPTING_XLSX_MODE;
418
427
  Capabilities.SCRIPTING_XLSX_EOL_WRITE;
@@ -424,6 +433,7 @@ Capabilities.SCRIPTING_XLSX_SHEETNAMES;
424
433
  Capabilities.SCRIPTING_XLSX_SHEETNAMES_PCONVOS;
425
434
  Capabilities.SCRIPTING_XLSX_SHEETNAMES_UTTERANCES;
426
435
  Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY;
436
+ Capabilities.SCRIPTING_CSV_LEGACY_MODE_OFF;
427
437
  Capabilities.SCRIPTING_CSV_DELIMITER;
428
438
  Capabilities.SCRIPTING_CSV_SKIP_HEADER;
429
439
  Capabilities.SCRIPTING_CSV_QUOTE;
@@ -433,6 +443,9 @@ Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER;
433
443
  Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT;
434
444
  Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION;
435
445
  Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER;
446
+ Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW;
447
+ Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER;
448
+ Capabilities.SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY;
436
449
  Capabilities.SCRIPTING_NORMALIZE_TEXT;
437
450
  Capabilities.SCRIPTING_ENABLE_MEMORY;
438
451
  Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS;
@@ -511,6 +524,7 @@ var Defaults$1 = {
511
524
  [Capabilities.SIMPLEREST_STRICT_SSL]: true,
512
525
  [Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
513
526
  [Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
527
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
514
528
  [Capabilities.SCRIPTING_TXT_EOL]: '\n',
515
529
  [Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
516
530
  [Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
@@ -1817,6 +1831,14 @@ const flatString = str => {
1817
1831
  return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
1818
1832
  };
1819
1833
 
1834
+ const _formatAppendArgs = args => {
1835
+ return args ? ` ${args.map(a => lodash.isString(a) ? a.replace(/\|/g, '\\|') : `${a}`).join('|')}` : '';
1836
+ };
1837
+
1838
+ const _parseArgs = str => {
1839
+ return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
1840
+ };
1841
+
1820
1842
  const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
1821
1843
  if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
1822
1844
  const convoStep = {
@@ -1858,7 +1880,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1858
1880
  const name = logicLine.split(' ')[0];
1859
1881
 
1860
1882
  if (sender !== 'me' && context.IsAsserterValid(name)) {
1861
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1883
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1862
1884
  convoStep.asserters.push({
1863
1885
  name,
1864
1886
  args,
@@ -1866,14 +1888,14 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1866
1888
  optional
1867
1889
  });
1868
1890
  } else if (sender === 'me' && context.IsUserInputValid(name)) {
1869
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1891
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1870
1892
  convoStep.userInputs.push({
1871
1893
  name,
1872
1894
  args
1873
1895
  });
1874
1896
  textLinesAccepted = false;
1875
1897
  } else if (context.IsLogicHookValid(name)) {
1876
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1898
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1877
1899
  convoStep.logicHooks.push({
1878
1900
  name,
1879
1901
  args
@@ -2223,7 +2245,7 @@ const convoStepToLines$2 = step => {
2223
2245
 
2224
2246
  if (step.sender === 'me') {
2225
2247
  step.forms && step.forms.filter(form => form.value).forEach(form => {
2226
- lines.push(`FORM ${form.name}|${form.value}`);
2248
+ lines.push(`FORM${_formatAppendArgs([form.name, form.value])}`);
2227
2249
  });
2228
2250
 
2229
2251
  if (step.buttons && step.buttons.length > 0) {
@@ -2235,18 +2257,18 @@ const convoStepToLines$2 = step => {
2235
2257
  }
2236
2258
 
2237
2259
  step.userInputs && step.userInputs.forEach(userInput => {
2238
- lines.push(userInput.name + (userInput.args ? ' ' + userInput.args.join('|') : ''));
2260
+ lines.push(userInput.name + _formatAppendArgs(userInput.args));
2239
2261
  });
2240
2262
  step.logicHooks && step.logicHooks.forEach(logicHook => {
2241
- lines.push(logicHook.name + (logicHook.args ? ' ' + logicHook.args.join('|') : ''));
2263
+ lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
2242
2264
  });
2243
2265
  } else {
2244
2266
  if (step.messageText) {
2245
2267
  lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
2246
2268
  }
2247
2269
 
2248
- if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
2249
- if (step.media && step.media.length > 0) lines.push('MEDIA ' + step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri).join('|'));
2270
+ if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))));
2271
+ if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)));
2250
2272
 
2251
2273
  if (step.cards && step.cards.length > 0) {
2252
2274
  step.cards.forEach(c => {
@@ -2254,17 +2276,17 @@ const convoStepToLines$2 = step => {
2254
2276
  if (c.text) cardTexts = cardTexts.concat(lodash.isArray(c.text) ? c.text : [c.text]);
2255
2277
  if (c.subtext) cardTexts = cardTexts.concat(lodash.isArray(c.subtext) ? c.subtext : [c.subtext]);
2256
2278
  if (c.content) cardTexts = cardTexts.concat(lodash.isArray(c.content) ? c.content : [c.content]);
2257
- if (cardTexts.length > 0) lines.push('CARDS ' + cardTexts.map(c => flatString(c)).join('|'));
2258
- if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
2279
+ if (cardTexts.length > 0) lines.push('CARDS' + _formatAppendArgs(cardTexts.map(c => flatString(c))));
2280
+ if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(c.buttons.filter(b => b.text).map(b => flatString(b.text))));
2259
2281
  if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
2260
2282
  });
2261
2283
  }
2262
2284
 
2263
2285
  step.asserters && step.asserters.forEach(asserter => {
2264
- lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + (asserter.args ? ' ' + asserter.args.join('|') : ''));
2286
+ lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + _formatAppendArgs(asserter.args));
2265
2287
  });
2266
2288
  step.logicHooks && step.logicHooks.forEach(logicHook => {
2267
- lines.push(logicHook.name + (logicHook.args ? ' ' + logicHook.args.join('|') : ''));
2289
+ lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
2268
2290
  });
2269
2291
  }
2270
2292
 
@@ -2305,7 +2327,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
2305
2327
  header: {
2306
2328
  name: caseName
2307
2329
  },
2308
- values: values
2330
+ values
2309
2331
  };
2310
2332
  scriptingMemories.push(scriptingMemory);
2311
2333
  }
@@ -2955,7 +2977,7 @@ class Convo$6 {
2955
2977
  },
2956
2978
  container,
2957
2979
  transcript,
2958
- scriptingMemory: scriptingMemory
2980
+ scriptingMemory
2959
2981
  });
2960
2982
  } catch (err) {
2961
2983
  throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
@@ -2972,7 +2994,7 @@ class Convo$6 {
2972
2994
  },
2973
2995
  container,
2974
2996
  transcript,
2975
- scriptingMemory: scriptingMemory
2997
+ scriptingMemory
2976
2998
  });
2977
2999
  } catch (err) {
2978
3000
  assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -2998,7 +3020,7 @@ class Convo$6 {
2998
3020
  },
2999
3021
  container,
3000
3022
  transcript,
3001
- scriptingMemory: scriptingMemory
3023
+ scriptingMemory
3002
3024
  });
3003
3025
  } catch (err) {
3004
3026
  transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3390,7 +3412,7 @@ class Convo$6 {
3390
3412
  const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
3391
3413
 
3392
3414
  if (transcriptStepErrs && transcriptStepErrs.length > 0) {
3393
- transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
3415
+ transcript.err = botiumErrorFromList$1([...transcriptStepErrs.filter(err => err !== transcript.err), transcript.err].filter(e => e), {});
3394
3416
  }
3395
3417
  }
3396
3418
  }
@@ -3776,7 +3798,7 @@ const optionalJson = json => {
3776
3798
  const body = isJson(json);
3777
3799
  return body ? {
3778
3800
  'content-type': 'application/json',
3779
- body: body
3801
+ body
3780
3802
  } : {
3781
3803
  'content-type': 'text/plain',
3782
3804
  body: json
@@ -4844,7 +4866,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4844
4866
  header: {
4845
4867
  name: caseName
4846
4868
  },
4847
- values: values
4869
+ values
4848
4870
  });
4849
4871
  }
4850
4872
  } else {
@@ -4887,7 +4909,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4887
4909
  header: {
4888
4910
  name: caseName
4889
4911
  },
4890
- values: values
4912
+ values
4891
4913
  });
4892
4914
  } else {
4893
4915
  break;
@@ -5284,6 +5306,8 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5284
5306
  return [];
5285
5307
  }
5286
5308
 
5309
+ const legacyModeOn = !this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_LEGACY_MODE_OFF, false);
5310
+
5287
5311
  let delimiter = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_DELIMITER);
5288
5312
 
5289
5313
  if (!delimiter) {
@@ -5311,7 +5335,8 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5311
5335
  delimiter,
5312
5336
  escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
5313
5337
  quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
5314
- columns: false
5338
+ columns: false,
5339
+ relax_column_count: true
5315
5340
  });
5316
5341
  } catch (err) {
5317
5342
  throw new Error(`Invalid CSV: ${err.message || err}`);
@@ -5321,120 +5346,175 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5321
5346
  return [];
5322
5347
  }
5323
5348
 
5324
- if (rows[0].length === 1) {
5325
- debug$c('Found 1-column CSV file, treating it as utterance file');
5349
+ const columnCount = rows[0].length;
5350
+ debug$c(`Legacy mode ${legacyModeOn ? 'on' : 'off'} rows ${rows.length} columns ${columnCount}`);
5326
5351
 
5327
- if (scriptType === Constants.SCRIPTING_TYPE_UTTERANCES) {
5328
- const result = [{
5329
- name: rows[0][0],
5330
- utterances: rows.slice(1).map(r => r[0])
5331
- }];
5332
- this.context.AddUtterances(result);
5333
- return result;
5334
- } else {
5352
+ if (scriptType === Constants.SCRIPTING_TYPE_CONVO || scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5353
+ if (columnCount === 1 || !legacyModeOn && columnCount > 3) {
5354
+ debug$c(`Invalid column count '${columnCount}' in convo mode`);
5335
5355
  return [];
5336
5356
  }
5337
- }
5338
5357
 
5339
- if (scriptType !== Constants.SCRIPTING_TYPE_CONVO && scriptType !== Constants.SCRIPTING_TYPE_PCONVO) {
5340
- return [];
5341
- }
5358
+ let header = null;
5342
5359
 
5343
- let header = null;
5360
+ if (rows.length > 0 && this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER]) {
5361
+ header = rows[0];
5362
+ rows = rows.slice(1);
5363
+ }
5344
5364
 
5345
- if (rows.length > 0 && this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER]) {
5346
- header = rows[0];
5347
- rows = rows.slice(1);
5348
- }
5365
+ if (rows.length === 0) {
5366
+ debug$c('Datarows not found in convo mode');
5367
+ return [];
5368
+ }
5349
5369
 
5350
- if (rows.length === 0) {
5351
- return [];
5352
- }
5370
+ const lineNumberBase = this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER] ? 2 : 1;
5353
5371
 
5354
- const lineNumberBase = this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER] ? 2 : 1;
5372
+ if (columnCount === 2) {
5373
+ let colQuestion = DEFAULT_QA_COLUMN_QUESTION;
5374
+ let colAnswer = DEFAULT_QA_COLUMN_ANSWER;
5355
5375
 
5356
- if (rows[0].length === 2) {
5357
- debug$c('Found 2-column CSV file, treating it as question/answer file');
5358
- let colQuestion = DEFAULT_QA_COLUMN_QUESTION;
5359
- let colAnswer = DEFAULT_QA_COLUMN_ANSWER;
5376
+ if (header) {
5377
+ if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION] !== undefined) {
5378
+ colQuestion = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION]);
5379
+ }
5360
5380
 
5361
- if (header) {
5362
- if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION] !== undefined) {
5363
- colQuestion = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION]);
5381
+ if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER] !== undefined) {
5382
+ colAnswer = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER]);
5383
+ }
5364
5384
  }
5365
5385
 
5366
- if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER] !== undefined) {
5367
- colAnswer = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER]);
5368
- }
5369
- }
5386
+ const convos = rows.map((row, i) => new Convo$3(this.context, {
5387
+ header: {
5388
+ name: `L${i + lineNumberBase}`
5389
+ },
5390
+ conversation: [Object.assign({}, linesToConvoStep$2([row[colQuestion]], 'me', this.context, undefined, true), {
5391
+ stepTag: `L${i + lineNumberBase}-Question`
5392
+ }), Object.assign({}, linesToConvoStep$2([row[colAnswer]], 'bot', this.context, undefined, true), {
5393
+ stepTag: `L${i + lineNumberBase}-Answer`
5394
+ })]
5395
+ }));
5370
5396
 
5371
- const convos = rows.map((row, i) => new Convo$3(this.context, {
5372
- header: {
5373
- name: `L${i + lineNumberBase}`
5374
- },
5375
- conversation: [Object.assign({}, linesToConvoStep$2([row[colQuestion]], 'me', this.context, undefined, true), {
5376
- stepTag: `L${i + lineNumberBase}-Question`
5377
- }), Object.assign({}, linesToConvoStep$2([row[colAnswer]], 'bot', this.context, undefined, true), {
5378
- stepTag: `L${i + lineNumberBase}-Answer`
5379
- })]
5380
- }));
5397
+ if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5398
+ this.context.AddConvos(convos);
5399
+ } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5400
+ this.context.AddPartialConvos(convos);
5401
+ }
5381
5402
 
5382
- if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5383
- this.context.AddConvos(convos);
5384
- } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5385
- this.context.AddPartialConvos(convos);
5403
+ debug$c(`Found 2-column CSV file, treating it as question/answer file, extracted ${convos.length} convos`);
5404
+ return convos;
5386
5405
  }
5387
5406
 
5388
- return convos;
5389
- }
5407
+ if (columnCount >= 3) {
5408
+ let colConversationId = DEFAULT_MULTIROW_COLUMN_CONVERSATION;
5409
+ let colSender = DEFAULT_MULTIROW_COLUMN_SENDER;
5410
+ let colText = DEFAULT_MULTIROW_COLUMN_TEXT;
5390
5411
 
5391
- if (rows[0].length >= 3) {
5392
- debug$c('Found 3-column CSV file, treating it as multi-row conversation file');
5393
- let colConversationId = DEFAULT_MULTIROW_COLUMN_CONVERSATION;
5394
- let colSender = DEFAULT_MULTIROW_COLUMN_SENDER;
5395
- let colText = DEFAULT_MULTIROW_COLUMN_TEXT;
5412
+ if (header) {
5413
+ if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID] !== undefined) {
5414
+ colConversationId = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID]);
5415
+ }
5396
5416
 
5397
- if (header) {
5398
- if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID] !== undefined) {
5399
- colConversationId = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID]);
5400
- }
5417
+ if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER] !== undefined) {
5418
+ colSender = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER]);
5419
+ }
5401
5420
 
5402
- if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER] !== undefined) {
5403
- colSender = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER]);
5421
+ if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT] !== undefined) {
5422
+ colText = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT]);
5423
+ }
5404
5424
  }
5405
5425
 
5406
- if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT] !== undefined) {
5407
- colText = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT]);
5426
+ const conversationIds = lodash.uniq(rows.map(r => r[colConversationId]));
5427
+
5428
+ const convos = conversationIds.map(conversationId => {
5429
+ const convoRows = rows.map((row, i) => {
5430
+ if (row[colConversationId] === conversationId) {
5431
+ return Object.assign({}, linesToConvoStep$2([row[colText]], row[colSender], this.context, undefined, true), {
5432
+ stepTag: `L${i + lineNumberBase}`
5433
+ });
5434
+ }
5435
+
5436
+ return null;
5437
+ }).filter(c => c);
5438
+ return new Convo$3(this.context, {
5439
+ header: {
5440
+ name: conversationId
5441
+ },
5442
+ conversation: convoRows
5443
+ });
5444
+ });
5445
+
5446
+ if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5447
+ this.context.AddConvos(convos);
5448
+ } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5449
+ this.context.AddPartialConvos(convos);
5408
5450
  }
5451
+
5452
+ debug$c(`Found 3-column CSV file, treating it as multi-row conversation file, extracted ${convos.length} convos`);
5453
+ return convos;
5454
+ }
5455
+ } else if (scriptType === Constants.SCRIPTING_TYPE_UTTERANCES) {
5456
+ if (columnCount === 2 || columnCount === 3 || legacyModeOn && columnCount > 4) {
5457
+ debug$c(`Invalid column count '${columnCount}' in utterances mode`);
5458
+ return [];
5409
5459
  }
5410
5460
 
5411
- const conversationIds = lodash.uniq(rows.map(r => r[colConversationId]));
5461
+ const result = [];
5462
+ const startRow = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW, 2) - 1;
5463
+
5464
+ const startRowHeader = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER);
5412
5465
 
5413
- const convos = conversationIds.map(conversationId => {
5414
- const convoRows = rows.map((row, i) => {
5415
- if (row[colConversationId] === conversationId) {
5416
- return Object.assign({}, linesToConvoStep$2([row[colText]], row[colSender], this.context, undefined, true), {
5417
- stepTag: `L${i + lineNumberBase}`
5418
- });
5466
+ const stopOnEmpty = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY);
5467
+
5468
+ for (let col = 0; col < columnCount; col++) {
5469
+ const name = rows[0][col];
5470
+
5471
+ if (!name || name.trim().length === 0) {
5472
+ debug$c(`Column ${col + 1} has no header, skipping`);
5473
+ continue;
5474
+ }
5475
+
5476
+ const uttStruct = {
5477
+ name,
5478
+ utterances: []
5479
+ };
5480
+ let skip = !!startRowHeader;
5481
+
5482
+ const getData = row => {
5483
+ return rows[row][col] ? rows[row][col].trim() : false;
5484
+ }; //
5485
+
5486
+
5487
+ for (let row = startRow; row < rows.length && (skip || !stopOnEmpty || !!getData(row)); row++) {
5488
+ // eslint-disable-line no-unmodified-loop-condition
5489
+ const data = getData(row);
5490
+
5491
+ if (!data) {
5492
+ continue;
5419
5493
  }
5420
5494
 
5421
- return null;
5422
- }).filter(c => c);
5423
- return new Convo$3(this.context, {
5424
- header: {
5425
- name: conversationId
5426
- },
5427
- conversation: convoRows
5428
- });
5429
- });
5495
+ if (!skip) {
5496
+ uttStruct.utterances.push(data);
5497
+ } else {
5498
+ if (startRowHeader === rows[row][col]) {
5499
+ skip = false;
5500
+ }
5501
+ }
5502
+ }
5430
5503
 
5431
- if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5432
- this.context.AddConvos(convos);
5433
- } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5434
- this.context.AddPartialConvos(convos);
5504
+ if (uttStruct.utterances.length === 0) {
5505
+ // liveperson, skipping meta intents
5506
+ debug$c(`Column ${col + 1} has no utterances, skipping`);
5507
+ continue;
5508
+ }
5509
+
5510
+ result.push(uttStruct);
5435
5511
  }
5436
5512
 
5437
- return convos;
5513
+ debug$c(`Multi-column utterance file, extracted ${result.length} utterances`);
5514
+ this.context.AddUtterances(result);
5515
+ return result;
5516
+ } else {
5517
+ return [];
5438
5518
  }
5439
5519
  }
5440
5520
 
@@ -5761,7 +5841,7 @@ const {
5761
5841
  const {
5762
5842
  getMatchFunction
5763
5843
  } = MatchFunctions;
5764
- const globPattern = '**/+(*.convo.txt|*.utterances.txt|*.pconvo.txt|*.scriptingmemory.txt|*.xlsx|*.xlsm|*.convo.csv|*.pconvo.csv|*.yaml|*.yml|*.json|*.md|*.markdown)';
5844
+ const globPattern = '**/+(*.convo.txt|*.utterances.txt|*.pconvo.txt|*.scriptingmemory.txt|*.xlsx|*.xlsm|*.convo.csv|*.pconvo.csv|*.utterances.csv|*.yaml|*.yml|*.json|*.md|*.markdown)';
5765
5845
  const skipPattern = /^skip[.\-_]/i;
5766
5846
 
5767
5847
  const p = (retryHelper, fn) => {
@@ -6456,6 +6536,10 @@ var ScriptingProvider_1 = class ScriptingProvider {
6456
6536
  result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_CONVO);
6457
6537
  } else if (filename.endsWith('.pconvo.csv')) {
6458
6538
  result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
6539
+ } else if (filename.endsWith('.pconvo.csv')) {
6540
+ result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
6541
+ } else if (filename.endsWith('.utterance.csv')) {
6542
+ result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_UTTERANCES);
6459
6543
  } else if (filename.endsWith('.yaml') || filename.endsWith('.yml')) {
6460
6544
  result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_YAML, [Constants.SCRIPTING_TYPE_UTTERANCES, Constants.SCRIPTING_TYPE_PCONVO, Constants.SCRIPTING_TYPE_CONVO, Constants.SCRIPTING_TYPE_SCRIPTING_MEMORY]);
6461
6545
  } else if (filename.endsWith('.json')) {
@@ -7233,7 +7317,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7233
7317
  const node = {
7234
7318
  sender: convoNode.sender,
7235
7319
  key: randomatic('0', 20),
7236
- hash: hash,
7320
+ hash,
7237
7321
  convoNodes: convoNodeValues,
7238
7322
  convos: [lodash.cloneDeep(convoNodeHeader)],
7239
7323
  childNodes: []
@@ -8112,6 +8196,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8112
8196
 
8113
8197
  this.processInbound = false;
8114
8198
  this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
8199
+ this.cookies = {};
8115
8200
 
8116
8201
  if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
8117
8202
  const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
@@ -8559,6 +8644,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8559
8644
  if (body) {
8560
8645
  debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8561
8646
 
8647
+ this._storeCookiesFromResponse(response);
8648
+
8562
8649
  try {
8563
8650
  body = await this._parseResponseBody(body);
8564
8651
  } catch (err) {
@@ -8681,6 +8768,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8681
8768
  await executeHook(this.caps, this.requestHook, Object.assign({
8682
8769
  requestOptions
8683
8770
  }, this.view));
8771
+
8772
+ this._addRequestCookies(requestOptions);
8773
+
8684
8774
  return requestOptions;
8685
8775
  }
8686
8776
 
@@ -8725,6 +8815,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8725
8815
  } else {
8726
8816
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8727
8817
 
8818
+ this._storeCookiesFromResponse(response);
8819
+
8728
8820
  if (debug$4.enabled && body) {
8729
8821
  debug$4(Utils.shortenJsonString(body));
8730
8822
  }
@@ -8909,9 +9001,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8909
9001
 
8910
9002
  const pollConfig = {
8911
9003
  method: verb,
8912
- uri: uri,
9004
+ uri,
8913
9005
  followAllRedirects: true,
8914
- timeout: timeout
9006
+ timeout
8915
9007
  };
8916
9008
 
8917
9009
  if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
@@ -8946,6 +9038,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8946
9038
  return;
8947
9039
  }
8948
9040
 
9041
+ this._addRequestCookies(pollConfig);
9042
+
8949
9043
  request(pollConfig, async (err, response, body) => {
8950
9044
  if (err) {
8951
9045
  debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
@@ -8959,6 +9053,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8959
9053
  } else if (body) {
8960
9054
  debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8961
9055
 
9056
+ this._storeCookiesFromResponse(response);
9057
+
8962
9058
  try {
8963
9059
  body = await this._parseResponseBody(body);
8964
9060
  } catch (err) {
@@ -9003,9 +9099,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9003
9099
 
9004
9100
  const httpConfig = {
9005
9101
  method: verb,
9006
- uri: uri,
9102
+ uri,
9007
9103
  followAllRedirects: true,
9008
- timeout: timeout
9104
+ timeout
9009
9105
  };
9010
9106
 
9011
9107
  if (this.caps[`${capPrefix}_HEADERS`]) {
@@ -9033,6 +9129,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9033
9129
  requestOptions: httpConfig
9034
9130
  }, this.view));
9035
9131
 
9132
+ this._addRequestCookies(httpConfig);
9133
+
9036
9134
  const retries = this._getCapValue(`${capPrefix}_RETRIES`);
9037
9135
 
9038
9136
  debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
@@ -9052,6 +9150,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9052
9150
  }
9053
9151
  }
9054
9152
 
9153
+ _addRequestCookies(requestOptions) {
9154
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
9155
+ return;
9156
+ }
9157
+
9158
+ const url = new URL(requestOptions.uri);
9159
+
9160
+ if (!requestOptions.headers) {
9161
+ requestOptions.headers = {};
9162
+ }
9163
+
9164
+ requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
9165
+ }
9166
+
9167
+ _storeCookiesFromResponse(response) {
9168
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
9169
+ return;
9170
+ }
9171
+
9172
+ const responseCookies = response.headers['set-cookie'];
9173
+
9174
+ if (!responseCookies) {
9175
+ return;
9176
+ }
9177
+
9178
+ const host = lodash.get(response, 'request.uri.host');
9179
+
9180
+ let cookie;
9181
+ responseCookies.forEach(cookieString => {
9182
+ cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
9183
+ });
9184
+
9185
+ if (cookie) {
9186
+ this.cookies[host] = cookie;
9187
+ }
9188
+ }
9189
+
9055
9190
  };
9056
9191
 
9057
9192
  const debug$3 = debug$l('botium-connector-PluginConnectorContainer-helper');
@@ -9126,7 +9261,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
9126
9261
  source: 'src/containers/plugins/index.js',
9127
9262
  cause: {
9128
9263
  SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
9129
- mode: mode,
9264
+ mode,
9130
9265
  ...cause
9131
9266
  }
9132
9267
  });
@@ -9486,13 +9621,23 @@ var BotDriver_1 = class BotDriver {
9486
9621
  debug$1(`Build - Envs: ${JSON.stringify(lodash.pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
9487
9622
  this.eventEmitter.emit(Events.CONTAINER_BUILDING);
9488
9623
  return new Promise((resolve, reject) => {
9624
+ let tempDirectory = null;
9489
9625
  let repo = null;
9490
9626
  let container = null;
9491
9627
  async.series([driverValidated => {
9492
9628
  this._validate().then(() => driverValidated()).catch(driverValidated);
9629
+ }, tempDirectoryCreated => {
9630
+ tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
9631
+
9632
+ try {
9633
+ mkdirp.sync(tempDirectory);
9634
+ tempDirectoryCreated();
9635
+ } catch (err) {
9636
+ tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
9637
+ }
9493
9638
  }, repoValidated => {
9494
9639
  try {
9495
- repo = this._getRepo();
9640
+ repo = this._getRepo(tempDirectory);
9496
9641
  } catch (err) {
9497
9642
  return repoValidated(err);
9498
9643
  }
@@ -9502,7 +9647,7 @@ var BotDriver_1 = class BotDriver {
9502
9647
  repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
9503
9648
  }, containerValidated => {
9504
9649
  try {
9505
- container = this._getContainer(repo);
9650
+ container = this._getContainer(tempDirectory, repo);
9506
9651
  } catch (err) {
9507
9652
  return containerValidated(err);
9508
9653
  }
@@ -9515,9 +9660,9 @@ var BotDriver_1 = class BotDriver {
9515
9660
  debug$1(`BotDriver Build error: ${err}`);
9516
9661
  this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
9517
9662
 
9518
- if (this.tempDirectory) {
9519
- rimraf(this.tempDirectory, err => {
9520
- if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util.inspect(err)}`);
9663
+ if (tempDirectory) {
9664
+ rimraf(tempDirectory, err => {
9665
+ if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util.inspect(err)}`);
9521
9666
  });
9522
9667
  }
9523
9668
 
@@ -9693,14 +9838,6 @@ var BotDriver_1 = class BotDriver {
9693
9838
  throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
9694
9839
  }
9695
9840
 
9696
- this.tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
9697
-
9698
- try {
9699
- mkdirp.sync(this.tempDirectory);
9700
- } catch (err) {
9701
- throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
9702
- }
9703
-
9704
9841
  resolve(this);
9705
9842
  } catch (err) {
9706
9843
  reject(err);
@@ -9708,29 +9845,29 @@ var BotDriver_1 = class BotDriver {
9708
9845
  });
9709
9846
  }
9710
9847
 
9711
- _getRepo() {
9848
+ _getRepo(tempDirectory) {
9712
9849
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9713
9850
  const NoRepo = NoRepo_1;
9714
- return new NoRepo(this.tempDirectory, this.sources);
9851
+ return new NoRepo(tempDirectory, this.sources);
9715
9852
  }
9716
9853
 
9717
9854
  if (this.sources[Source.GITURL]) {
9718
9855
  const GitRepo = GitRepo_1;
9719
- return new GitRepo(this.tempDirectory, this.sources);
9856
+ return new GitRepo(tempDirectory, this.sources);
9720
9857
  }
9721
9858
 
9722
9859
  if (this.sources[Source.LOCALPATH]) {
9723
9860
  const LocalRepo = LocalRepo_1;
9724
- return new LocalRepo(this.tempDirectory, this.sources);
9861
+ return new LocalRepo(tempDirectory, this.sources);
9725
9862
  }
9726
9863
 
9727
9864
  throw new Error(`No Repo provider found for Sources ${util.inspect(this.sources)}`);
9728
9865
  }
9729
9866
 
9730
- _getContainer(repo) {
9867
+ _getContainer(tempDirectory, repo) {
9731
9868
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9732
9869
  const GridContainer = GridContainer_1;
9733
- return new GridContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9870
+ return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9734
9871
  }
9735
9872
 
9736
9873
  if (!this.caps[Capabilities.CONTAINERMODE]) {
@@ -9739,11 +9876,11 @@ var BotDriver_1 = class BotDriver {
9739
9876
 
9740
9877
  if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
9741
9878
  const InProcessContainer = InProcessContainer_1;
9742
- return new InProcessContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9879
+ return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9743
9880
  }
9744
9881
 
9745
9882
  const PluginConnectorContainer = PluginConnectorContainer_1;
9746
- return new PluginConnectorContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9883
+ return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9747
9884
  }
9748
9885
 
9749
9886
  };