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
@@ -79,7 +79,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
79
79
  var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
80
80
 
81
81
  var name = "botium-core";
82
- var version$1 = "1.12.4";
82
+ var version$1 = "1.13.0";
83
83
  var description = "The Selenium for Chatbots";
84
84
  var main = "index.js";
85
85
  var module$1 = "dist/botium-es.js";
@@ -111,25 +111,25 @@ var bugs = {
111
111
  };
112
112
  var homepage = "https://www.botium.ai";
113
113
  var dependencies = {
114
- "@babel/runtime": "^7.17.8",
115
- async: "^3.2.3",
116
- "body-parser": "^1.19.2",
114
+ "@babel/runtime": "^7.18.3",
115
+ async: "^3.2.4",
116
+ "body-parser": "^1.20.0",
117
117
  boolean: "^3.2.0",
118
118
  bottleneck: "^2.19.5",
119
- "csv-parse": "^5.0.4",
119
+ "csv-parse": "^5.2.0",
120
120
  debug: "^4.3.4",
121
121
  esprima: "^4.0.1",
122
- express: "^4.17.3",
122
+ express: "^4.18.1",
123
123
  globby: "11.0.4",
124
- ioredis: "^4.28.5",
124
+ ioredis: "^5.0.6",
125
125
  "is-class": "^0.0.9",
126
126
  "is-json": "^2.0.1",
127
127
  jsonpath: "^1.1.1",
128
128
  lodash: "^4.17.21",
129
- "markdown-it": "^12.3.2",
129
+ "markdown-it": "^13.0.1",
130
130
  "mime-types": "^2.1.35",
131
131
  mkdirp: "^1.0.4",
132
- moment: "^2.29.1",
132
+ moment: "^2.29.3",
133
133
  mustache: "^4.2.0",
134
134
  "promise-retry": "^2.0.1",
135
135
  "promise.allsettled": "^1.0.5",
@@ -138,39 +138,39 @@ var dependencies = {
138
138
  rimraf: "^3.0.2",
139
139
  "sanitize-filename": "^1.6.3",
140
140
  slugify: "^1.6.5",
141
- "socket.io": "^4.4.1",
142
- "socket.io-client": "^4.4.1",
141
+ "socket.io": "^4.5.1",
142
+ "socket.io-client": "^4.5.1",
143
143
  "socketio-auth": "^0.1.1",
144
- "swagger-jsdoc": "^6.1.0",
145
- "swagger-ui-express": "^4.3.0",
144
+ "swagger-jsdoc": "^6.2.1",
145
+ "swagger-ui-express": "^4.4.0",
146
146
  uuid: "^8.3.2",
147
147
  vm2: "^3.9.9",
148
148
  "write-yaml": "^1.0.0",
149
- xlsx: "^0.18.4",
150
- xregexp: "^5.1.0",
151
- yaml: "^1.10.2"
149
+ xlsx: "^0.18.5",
150
+ xregexp: "^5.1.1",
151
+ yaml: "^2.1.1"
152
152
  };
153
153
  var devDependencies = {
154
- "@babel/core": "^7.17.8",
155
- "@babel/node": "^7.16.8",
156
- "@babel/plugin-transform-runtime": "^7.17.0",
157
- "@babel/preset-env": "^7.16.11",
154
+ "@babel/core": "^7.18.5",
155
+ "@babel/node": "^7.18.5",
156
+ "@babel/plugin-transform-runtime": "^7.18.5",
157
+ "@babel/preset-env": "^7.18.2",
158
158
  chai: "^4.3.6",
159
159
  "chai-as-promised": "^7.1.1",
160
160
  "cross-env": "^7.0.3",
161
- eslint: "^8.11.0",
162
- "eslint-config-standard": "^16.0.3",
163
- "eslint-plugin-import": "^2.25.4",
164
- "eslint-plugin-node": "^11.1.0",
161
+ eslint: "^8.18.0",
162
+ "eslint-config-standard": "^17.0.0",
163
+ "eslint-plugin-import": "^2.26.0",
164
+ "eslint-plugin-n": "^15.2.3",
165
165
  "eslint-plugin-promise": "^6.0.0",
166
166
  "eslint-plugin-standard": "^4.1.0",
167
167
  "license-checker": "^25.0.1",
168
168
  "license-compatibility-checker": "^0.3.5",
169
- mocha: "^9.2.2",
170
- nock: "^13.2.4",
171
- "npm-check-updates": "^12.5.4",
169
+ mocha: "^10.0.0",
170
+ nock: "^13.2.7",
171
+ "npm-check-updates": "^14.0.1",
172
172
  nyc: "^15.1.0",
173
- rollup: "^2.70.1",
173
+ rollup: "^2.75.6",
174
174
  "rollup-plugin-babel": "^4.4.0",
175
175
  "rollup-plugin-commonjs": "^10.1.0",
176
176
  "rollup-plugin-json": "^4.0.0",
@@ -305,6 +305,7 @@ var Capabilities = {
305
305
  SIMPLEREST_REDIS_TOPIC: 'SIMPLEREST_REDIS_TOPIC',
306
306
  SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH: 'SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH',
307
307
  SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT: 'SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT',
308
+ SIMPLEREST_COOKIE_REPLICATION: 'SIMPLEREST_COOKIE_REPLICATION',
308
309
  // Script Compiler
309
310
  SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
310
311
  // ROW_PER_MESSAGE or QUESTION_ANSWER
@@ -318,6 +319,10 @@ var Capabilities = {
318
319
  SCRIPTING_XLSX_SHEETNAMES_PCONVOS: 'SCRIPTING_XLSX_SHEETNAMES_PCONVOS',
319
320
  SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'SCRIPTING_XLSX_SHEETNAMES_UTTERANCES',
320
321
  SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY: 'SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY',
322
+ // hidden capability. All newly in Box created testsets will have this as true. CsvCompiler
323
+ // - 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)
324
+ // 4 or more colums are compiled just as utterances.
325
+ SCRIPTING_CSV_LEGACY_MODE_OFF: 'SCRIPTING_CSV_LEGACY_MODE_OFF',
321
326
  SCRIPTING_CSV_DELIMITER: 'SCRIPTING_CSV_DELIMITER',
322
327
  SCRIPTING_CSV_SKIP_HEADER: 'SCRIPTING_CSV_SKIP_HEADER',
323
328
  SCRIPTING_CSV_QUOTE: 'SCRIPTING_CSV_QUOTE',
@@ -327,6 +332,9 @@ var Capabilities = {
327
332
  SCRIPTING_CSV_MULTIROW_COLUMN_TEXT: 'SCRIPTING_CSV_MULTIROW_COLUMN_TEXT',
328
333
  SCRIPTING_CSV_QA_COLUMN_QUESTION: 'SCRIPTING_CSV_QA_COLUMN_QUESTION',
329
334
  SCRIPTING_CSV_QA_COLUMN_ANSWER: 'SCRIPTING_CSV_QA_COLUMN_ANSWER',
335
+ SCRIPTING_CSV_UTTERANCE_STARTROW: 'SCRIPTING_CSV_UTTERANCE_STARTROW',
336
+ SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER: 'SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER',
337
+ SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY: 'SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY',
330
338
  SCRIPTING_NORMALIZE_TEXT: 'SCRIPTING_NORMALIZE_TEXT',
331
339
  SCRIPTING_ENABLE_MEMORY: 'SCRIPTING_ENABLE_MEMORY',
332
340
  SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
@@ -456,6 +464,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
456
464
  Capabilities.SIMPLEREST_REDIS_TOPIC;
457
465
  Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
458
466
  Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
467
+ Capabilities.SIMPLEREST_COOKIE_REPLICATION;
459
468
  Capabilities.SCRIPTING_TXT_EOL;
460
469
  Capabilities.SCRIPTING_XLSX_MODE;
461
470
  Capabilities.SCRIPTING_XLSX_EOL_WRITE;
@@ -467,6 +476,7 @@ Capabilities.SCRIPTING_XLSX_SHEETNAMES;
467
476
  Capabilities.SCRIPTING_XLSX_SHEETNAMES_PCONVOS;
468
477
  Capabilities.SCRIPTING_XLSX_SHEETNAMES_UTTERANCES;
469
478
  Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY;
479
+ Capabilities.SCRIPTING_CSV_LEGACY_MODE_OFF;
470
480
  Capabilities.SCRIPTING_CSV_DELIMITER;
471
481
  Capabilities.SCRIPTING_CSV_SKIP_HEADER;
472
482
  Capabilities.SCRIPTING_CSV_QUOTE;
@@ -476,6 +486,9 @@ Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER;
476
486
  Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT;
477
487
  Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION;
478
488
  Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER;
489
+ Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW;
490
+ Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER;
491
+ Capabilities.SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY;
479
492
  Capabilities.SCRIPTING_NORMALIZE_TEXT;
480
493
  Capabilities.SCRIPTING_ENABLE_MEMORY;
481
494
  Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS;
@@ -554,6 +567,7 @@ var Defaults$1 = {
554
567
  [Capabilities.SIMPLEREST_STRICT_SSL]: true,
555
568
  [Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
556
569
  [Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
570
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
557
571
  [Capabilities.SCRIPTING_TXT_EOL]: '\n',
558
572
  [Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
559
573
  [Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
@@ -1860,6 +1874,14 @@ const flatString = str => {
1860
1874
  return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
1861
1875
  };
1862
1876
 
1877
+ const _formatAppendArgs = args => {
1878
+ return args ? ` ${args.map(a => lodash__default["default"].isString(a) ? a.replace(/\|/g, '\\|') : `${a}`).join('|')}` : '';
1879
+ };
1880
+
1881
+ const _parseArgs = str => {
1882
+ return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
1883
+ };
1884
+
1863
1885
  const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
1864
1886
  if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
1865
1887
  const convoStep = {
@@ -1901,7 +1923,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1901
1923
  const name = logicLine.split(' ')[0];
1902
1924
 
1903
1925
  if (sender !== 'me' && context.IsAsserterValid(name)) {
1904
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1926
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1905
1927
  convoStep.asserters.push({
1906
1928
  name,
1907
1929
  args,
@@ -1909,14 +1931,14 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
1909
1931
  optional
1910
1932
  });
1911
1933
  } else if (sender === 'me' && context.IsUserInputValid(name)) {
1912
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1934
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1913
1935
  convoStep.userInputs.push({
1914
1936
  name,
1915
1937
  args
1916
1938
  });
1917
1939
  textLinesAccepted = false;
1918
1940
  } else if (context.IsLogicHookValid(name)) {
1919
- const args = logicLine.length > name.length ? logicLine.substr(name.length + 1).split('|').map(a => a.trim()) : [];
1941
+ const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
1920
1942
  convoStep.logicHooks.push({
1921
1943
  name,
1922
1944
  args
@@ -2266,7 +2288,7 @@ const convoStepToLines$2 = step => {
2266
2288
 
2267
2289
  if (step.sender === 'me') {
2268
2290
  step.forms && step.forms.filter(form => form.value).forEach(form => {
2269
- lines.push(`FORM ${form.name}|${form.value}`);
2291
+ lines.push(`FORM${_formatAppendArgs([form.name, form.value])}`);
2270
2292
  });
2271
2293
 
2272
2294
  if (step.buttons && step.buttons.length > 0) {
@@ -2278,18 +2300,18 @@ const convoStepToLines$2 = step => {
2278
2300
  }
2279
2301
 
2280
2302
  step.userInputs && step.userInputs.forEach(userInput => {
2281
- lines.push(userInput.name + (userInput.args ? ' ' + userInput.args.join('|') : ''));
2303
+ lines.push(userInput.name + _formatAppendArgs(userInput.args));
2282
2304
  });
2283
2305
  step.logicHooks && step.logicHooks.forEach(logicHook => {
2284
- lines.push(logicHook.name + (logicHook.args ? ' ' + logicHook.args.join('|') : ''));
2306
+ lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
2285
2307
  });
2286
2308
  } else {
2287
2309
  if (step.messageText) {
2288
2310
  lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
2289
2311
  }
2290
2312
 
2291
- if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS ' + step.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
2292
- if (step.media && step.media.length > 0) lines.push('MEDIA ' + step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri).join('|'));
2313
+ if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))));
2314
+ if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)));
2293
2315
 
2294
2316
  if (step.cards && step.cards.length > 0) {
2295
2317
  step.cards.forEach(c => {
@@ -2297,17 +2319,17 @@ const convoStepToLines$2 = step => {
2297
2319
  if (c.text) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.text) ? c.text : [c.text]);
2298
2320
  if (c.subtext) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.subtext) ? c.subtext : [c.subtext]);
2299
2321
  if (c.content) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.content) ? c.content : [c.content]);
2300
- if (cardTexts.length > 0) lines.push('CARDS ' + cardTexts.map(c => flatString(c)).join('|'));
2301
- if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS ' + c.buttons.filter(b => b.text).map(b => flatString(b.text)).join('|'));
2322
+ if (cardTexts.length > 0) lines.push('CARDS' + _formatAppendArgs(cardTexts.map(c => flatString(c))));
2323
+ if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(c.buttons.filter(b => b.text).map(b => flatString(b.text))));
2302
2324
  if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
2303
2325
  });
2304
2326
  }
2305
2327
 
2306
2328
  step.asserters && step.asserters.forEach(asserter => {
2307
- lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + (asserter.args ? ' ' + asserter.args.join('|') : ''));
2329
+ lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + _formatAppendArgs(asserter.args));
2308
2330
  });
2309
2331
  step.logicHooks && step.logicHooks.forEach(logicHook => {
2310
- lines.push(logicHook.name + (logicHook.args ? ' ' + logicHook.args.join('|') : ''));
2332
+ lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
2311
2333
  });
2312
2334
  }
2313
2335
 
@@ -2348,7 +2370,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
2348
2370
  header: {
2349
2371
  name: caseName
2350
2372
  },
2351
- values: values
2373
+ values
2352
2374
  };
2353
2375
  scriptingMemories.push(scriptingMemory);
2354
2376
  }
@@ -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
  throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
@@ -3015,7 +3037,7 @@ class Convo$6 {
3015
3037
  },
3016
3038
  container,
3017
3039
  transcript,
3018
- scriptingMemory: scriptingMemory
3040
+ scriptingMemory
3019
3041
  });
3020
3042
  } catch (err) {
3021
3043
  assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3041,7 +3063,7 @@ class Convo$6 {
3041
3063
  },
3042
3064
  container,
3043
3065
  transcript,
3044
- scriptingMemory: scriptingMemory
3066
+ scriptingMemory
3045
3067
  });
3046
3068
  } catch (err) {
3047
3069
  transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3433,7 +3455,7 @@ class Convo$6 {
3433
3455
  const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
3434
3456
 
3435
3457
  if (transcriptStepErrs && transcriptStepErrs.length > 0) {
3436
- transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
3458
+ transcript.err = botiumErrorFromList$1([...transcriptStepErrs.filter(err => err !== transcript.err), transcript.err].filter(e => e), {});
3437
3459
  }
3438
3460
  }
3439
3461
  }
@@ -3819,7 +3841,7 @@ const optionalJson = json => {
3819
3841
  const body = isJson(json);
3820
3842
  return body ? {
3821
3843
  'content-type': 'application/json',
3822
- body: body
3844
+ body
3823
3845
  } : {
3824
3846
  'content-type': 'text/plain',
3825
3847
  body: json
@@ -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
  }
4893
4915
  } else {
@@ -4930,7 +4952,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4930
4952
  header: {
4931
4953
  name: caseName
4932
4954
  },
4933
- values: values
4955
+ values
4934
4956
  });
4935
4957
  } else {
4936
4958
  break;
@@ -5327,6 +5349,8 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5327
5349
  return [];
5328
5350
  }
5329
5351
 
5352
+ const legacyModeOn = !this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_LEGACY_MODE_OFF, false);
5353
+
5330
5354
  let delimiter = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_DELIMITER);
5331
5355
 
5332
5356
  if (!delimiter) {
@@ -5354,7 +5378,8 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5354
5378
  delimiter,
5355
5379
  escape: this.caps[Capabilities.SCRIPTING_CSV_ESCAPE],
5356
5380
  quote: this.caps[Capabilities.SCRIPTING_CSV_QUOTE],
5357
- columns: false
5381
+ columns: false,
5382
+ relax_column_count: true
5358
5383
  });
5359
5384
  } catch (err) {
5360
5385
  throw new Error(`Invalid CSV: ${err.message || err}`);
@@ -5364,120 +5389,175 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5364
5389
  return [];
5365
5390
  }
5366
5391
 
5367
- if (rows[0].length === 1) {
5368
- debug$c('Found 1-column CSV file, treating it as utterance file');
5392
+ const columnCount = rows[0].length;
5393
+ debug$c(`Legacy mode ${legacyModeOn ? 'on' : 'off'} rows ${rows.length} columns ${columnCount}`);
5369
5394
 
5370
- if (scriptType === Constants.SCRIPTING_TYPE_UTTERANCES) {
5371
- const result = [{
5372
- name: rows[0][0],
5373
- utterances: rows.slice(1).map(r => r[0])
5374
- }];
5375
- this.context.AddUtterances(result);
5376
- return result;
5377
- } else {
5395
+ if (scriptType === Constants.SCRIPTING_TYPE_CONVO || scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5396
+ if (columnCount === 1 || !legacyModeOn && columnCount > 3) {
5397
+ debug$c(`Invalid column count '${columnCount}' in convo mode`);
5378
5398
  return [];
5379
5399
  }
5380
- }
5381
5400
 
5382
- if (scriptType !== Constants.SCRIPTING_TYPE_CONVO && scriptType !== Constants.SCRIPTING_TYPE_PCONVO) {
5383
- return [];
5384
- }
5401
+ let header = null;
5385
5402
 
5386
- let header = null;
5403
+ if (rows.length > 0 && this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER]) {
5404
+ header = rows[0];
5405
+ rows = rows.slice(1);
5406
+ }
5387
5407
 
5388
- if (rows.length > 0 && this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER]) {
5389
- header = rows[0];
5390
- rows = rows.slice(1);
5391
- }
5408
+ if (rows.length === 0) {
5409
+ debug$c('Datarows not found in convo mode');
5410
+ return [];
5411
+ }
5392
5412
 
5393
- if (rows.length === 0) {
5394
- return [];
5395
- }
5413
+ const lineNumberBase = this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER] ? 2 : 1;
5396
5414
 
5397
- const lineNumberBase = this.caps[Capabilities.SCRIPTING_CSV_SKIP_HEADER] ? 2 : 1;
5415
+ if (columnCount === 2) {
5416
+ let colQuestion = DEFAULT_QA_COLUMN_QUESTION;
5417
+ let colAnswer = DEFAULT_QA_COLUMN_ANSWER;
5398
5418
 
5399
- if (rows[0].length === 2) {
5400
- debug$c('Found 2-column CSV file, treating it as question/answer file');
5401
- let colQuestion = DEFAULT_QA_COLUMN_QUESTION;
5402
- let colAnswer = DEFAULT_QA_COLUMN_ANSWER;
5419
+ if (header) {
5420
+ if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION] !== undefined) {
5421
+ colQuestion = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION]);
5422
+ }
5403
5423
 
5404
- if (header) {
5405
- if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION] !== undefined) {
5406
- colQuestion = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_QUESTION]);
5424
+ if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER] !== undefined) {
5425
+ colAnswer = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER]);
5426
+ }
5407
5427
  }
5408
5428
 
5409
- if (this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER] !== undefined) {
5410
- colAnswer = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_QA_COLUMN_ANSWER]);
5411
- }
5412
- }
5429
+ const convos = rows.map((row, i) => new Convo$3(this.context, {
5430
+ header: {
5431
+ name: `L${i + lineNumberBase}`
5432
+ },
5433
+ conversation: [Object.assign({}, linesToConvoStep$2([row[colQuestion]], 'me', this.context, undefined, true), {
5434
+ stepTag: `L${i + lineNumberBase}-Question`
5435
+ }), Object.assign({}, linesToConvoStep$2([row[colAnswer]], 'bot', this.context, undefined, true), {
5436
+ stepTag: `L${i + lineNumberBase}-Answer`
5437
+ })]
5438
+ }));
5413
5439
 
5414
- const convos = rows.map((row, i) => new Convo$3(this.context, {
5415
- header: {
5416
- name: `L${i + lineNumberBase}`
5417
- },
5418
- conversation: [Object.assign({}, linesToConvoStep$2([row[colQuestion]], 'me', this.context, undefined, true), {
5419
- stepTag: `L${i + lineNumberBase}-Question`
5420
- }), Object.assign({}, linesToConvoStep$2([row[colAnswer]], 'bot', this.context, undefined, true), {
5421
- stepTag: `L${i + lineNumberBase}-Answer`
5422
- })]
5423
- }));
5440
+ if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5441
+ this.context.AddConvos(convos);
5442
+ } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5443
+ this.context.AddPartialConvos(convos);
5444
+ }
5424
5445
 
5425
- if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5426
- this.context.AddConvos(convos);
5427
- } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5428
- this.context.AddPartialConvos(convos);
5446
+ debug$c(`Found 2-column CSV file, treating it as question/answer file, extracted ${convos.length} convos`);
5447
+ return convos;
5429
5448
  }
5430
5449
 
5431
- return convos;
5432
- }
5450
+ if (columnCount >= 3) {
5451
+ let colConversationId = DEFAULT_MULTIROW_COLUMN_CONVERSATION;
5452
+ let colSender = DEFAULT_MULTIROW_COLUMN_SENDER;
5453
+ let colText = DEFAULT_MULTIROW_COLUMN_TEXT;
5433
5454
 
5434
- if (rows[0].length >= 3) {
5435
- debug$c('Found 3-column CSV file, treating it as multi-row conversation file');
5436
- let colConversationId = DEFAULT_MULTIROW_COLUMN_CONVERSATION;
5437
- let colSender = DEFAULT_MULTIROW_COLUMN_SENDER;
5438
- let colText = DEFAULT_MULTIROW_COLUMN_TEXT;
5455
+ if (header) {
5456
+ if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID] !== undefined) {
5457
+ colConversationId = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID]);
5458
+ }
5439
5459
 
5440
- if (header) {
5441
- if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID] !== undefined) {
5442
- colConversationId = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID]);
5443
- }
5460
+ if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER] !== undefined) {
5461
+ colSender = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER]);
5462
+ }
5444
5463
 
5445
- if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER] !== undefined) {
5446
- colSender = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_SENDER]);
5464
+ if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT] !== undefined) {
5465
+ colText = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT]);
5466
+ }
5447
5467
  }
5448
5468
 
5449
- if (this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT] !== undefined) {
5450
- colText = _findColIndex(header, this.caps[Capabilities.SCRIPTING_CSV_MULTIROW_COLUMN_TEXT]);
5469
+ const conversationIds = lodash__default["default"].uniq(rows.map(r => r[colConversationId]));
5470
+
5471
+ const convos = conversationIds.map(conversationId => {
5472
+ const convoRows = rows.map((row, i) => {
5473
+ if (row[colConversationId] === conversationId) {
5474
+ return Object.assign({}, linesToConvoStep$2([row[colText]], row[colSender], this.context, undefined, true), {
5475
+ stepTag: `L${i + lineNumberBase}`
5476
+ });
5477
+ }
5478
+
5479
+ return null;
5480
+ }).filter(c => c);
5481
+ return new Convo$3(this.context, {
5482
+ header: {
5483
+ name: conversationId
5484
+ },
5485
+ conversation: convoRows
5486
+ });
5487
+ });
5488
+
5489
+ if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5490
+ this.context.AddConvos(convos);
5491
+ } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5492
+ this.context.AddPartialConvos(convos);
5451
5493
  }
5494
+
5495
+ debug$c(`Found 3-column CSV file, treating it as multi-row conversation file, extracted ${convos.length} convos`);
5496
+ return convos;
5497
+ }
5498
+ } else if (scriptType === Constants.SCRIPTING_TYPE_UTTERANCES) {
5499
+ if (columnCount === 2 || columnCount === 3 || legacyModeOn && columnCount > 4) {
5500
+ debug$c(`Invalid column count '${columnCount}' in utterances mode`);
5501
+ return [];
5452
5502
  }
5453
5503
 
5454
- const conversationIds = lodash__default["default"].uniq(rows.map(r => r[colConversationId]));
5504
+ const result = [];
5505
+ const startRow = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW, 2) - 1;
5506
+
5507
+ const startRowHeader = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STARTROW_HEADER);
5455
5508
 
5456
- const convos = conversationIds.map(conversationId => {
5457
- const convoRows = rows.map((row, i) => {
5458
- if (row[colConversationId] === conversationId) {
5459
- return Object.assign({}, linesToConvoStep$2([row[colText]], row[colSender], this.context, undefined, true), {
5460
- stepTag: `L${i + lineNumberBase}`
5461
- });
5509
+ const stopOnEmpty = this._GetOptionalCapability(Capabilities.SCRIPTING_CSV_UTTERANCE_STOP_ON_EMPTY);
5510
+
5511
+ for (let col = 0; col < columnCount; col++) {
5512
+ const name = rows[0][col];
5513
+
5514
+ if (!name || name.trim().length === 0) {
5515
+ debug$c(`Column ${col + 1} has no header, skipping`);
5516
+ continue;
5517
+ }
5518
+
5519
+ const uttStruct = {
5520
+ name,
5521
+ utterances: []
5522
+ };
5523
+ let skip = !!startRowHeader;
5524
+
5525
+ const getData = row => {
5526
+ return rows[row][col] ? rows[row][col].trim() : false;
5527
+ }; //
5528
+
5529
+
5530
+ for (let row = startRow; row < rows.length && (skip || !stopOnEmpty || !!getData(row)); row++) {
5531
+ // eslint-disable-line no-unmodified-loop-condition
5532
+ const data = getData(row);
5533
+
5534
+ if (!data) {
5535
+ continue;
5462
5536
  }
5463
5537
 
5464
- return null;
5465
- }).filter(c => c);
5466
- return new Convo$3(this.context, {
5467
- header: {
5468
- name: conversationId
5469
- },
5470
- conversation: convoRows
5471
- });
5472
- });
5538
+ if (!skip) {
5539
+ uttStruct.utterances.push(data);
5540
+ } else {
5541
+ if (startRowHeader === rows[row][col]) {
5542
+ skip = false;
5543
+ }
5544
+ }
5545
+ }
5473
5546
 
5474
- if (scriptType === Constants.SCRIPTING_TYPE_CONVO) {
5475
- this.context.AddConvos(convos);
5476
- } else if (scriptType === Constants.SCRIPTING_TYPE_PCONVO) {
5477
- this.context.AddPartialConvos(convos);
5547
+ if (uttStruct.utterances.length === 0) {
5548
+ // liveperson, skipping meta intents
5549
+ debug$c(`Column ${col + 1} has no utterances, skipping`);
5550
+ continue;
5551
+ }
5552
+
5553
+ result.push(uttStruct);
5478
5554
  }
5479
5555
 
5480
- return convos;
5556
+ debug$c(`Multi-column utterance file, extracted ${result.length} utterances`);
5557
+ this.context.AddUtterances(result);
5558
+ return result;
5559
+ } else {
5560
+ return [];
5481
5561
  }
5482
5562
  }
5483
5563
 
@@ -5804,7 +5884,7 @@ const {
5804
5884
  const {
5805
5885
  getMatchFunction
5806
5886
  } = MatchFunctions;
5807
- const globPattern = '**/+(*.convo.txt|*.utterances.txt|*.pconvo.txt|*.scriptingmemory.txt|*.xlsx|*.xlsm|*.convo.csv|*.pconvo.csv|*.yaml|*.yml|*.json|*.md|*.markdown)';
5887
+ const globPattern = '**/+(*.convo.txt|*.utterances.txt|*.pconvo.txt|*.scriptingmemory.txt|*.xlsx|*.xlsm|*.convo.csv|*.pconvo.csv|*.utterances.csv|*.yaml|*.yml|*.json|*.md|*.markdown)';
5808
5888
  const skipPattern = /^skip[.\-_]/i;
5809
5889
 
5810
5890
  const p = (retryHelper, fn) => {
@@ -6499,6 +6579,10 @@ var ScriptingProvider_1 = class ScriptingProvider {
6499
6579
  result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_CONVO);
6500
6580
  } else if (filename.endsWith('.pconvo.csv')) {
6501
6581
  result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
6582
+ } else if (filename.endsWith('.pconvo.csv')) {
6583
+ result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_PCONVO);
6584
+ } else if (filename.endsWith('.utterance.csv')) {
6585
+ result = this.ReadScriptFromBuffer(scriptBuffer, Constants.SCRIPTING_FORMAT_CSV, Constants.SCRIPTING_TYPE_UTTERANCES);
6502
6586
  } else if (filename.endsWith('.yaml') || filename.endsWith('.yml')) {
6503
6587
  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]);
6504
6588
  } else if (filename.endsWith('.json')) {
@@ -7276,7 +7360,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7276
7360
  const node = {
7277
7361
  sender: convoNode.sender,
7278
7362
  key: randomatic__default["default"]('0', 20),
7279
- hash: hash,
7363
+ hash,
7280
7364
  convoNodes: convoNodeValues,
7281
7365
  convos: [lodash__default["default"].cloneDeep(convoNodeHeader)],
7282
7366
  childNodes: []
@@ -8155,6 +8239,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8155
8239
 
8156
8240
  this.processInbound = false;
8157
8241
  this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
8242
+ this.cookies = {};
8158
8243
 
8159
8244
  if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
8160
8245
  const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
@@ -8602,6 +8687,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8602
8687
  if (body) {
8603
8688
  debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8604
8689
 
8690
+ this._storeCookiesFromResponse(response);
8691
+
8605
8692
  try {
8606
8693
  body = await this._parseResponseBody(body);
8607
8694
  } catch (err) {
@@ -8724,6 +8811,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8724
8811
  await executeHook(this.caps, this.requestHook, Object.assign({
8725
8812
  requestOptions
8726
8813
  }, this.view));
8814
+
8815
+ this._addRequestCookies(requestOptions);
8816
+
8727
8817
  return requestOptions;
8728
8818
  }
8729
8819
 
@@ -8768,6 +8858,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8768
8858
  } else {
8769
8859
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8770
8860
 
8861
+ this._storeCookiesFromResponse(response);
8862
+
8771
8863
  if (debug$4.enabled && body) {
8772
8864
  debug$4(Utils.shortenJsonString(body));
8773
8865
  }
@@ -8952,9 +9044,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8952
9044
 
8953
9045
  const pollConfig = {
8954
9046
  method: verb,
8955
- uri: uri,
9047
+ uri,
8956
9048
  followAllRedirects: true,
8957
- timeout: timeout
9049
+ timeout
8958
9050
  };
8959
9051
 
8960
9052
  if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
@@ -8989,6 +9081,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8989
9081
  return;
8990
9082
  }
8991
9083
 
9084
+ this._addRequestCookies(pollConfig);
9085
+
8992
9086
  request__default["default"](pollConfig, async (err, response, body) => {
8993
9087
  if (err) {
8994
9088
  debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
@@ -9002,6 +9096,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9002
9096
  } else if (body) {
9003
9097
  debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
9004
9098
 
9099
+ this._storeCookiesFromResponse(response);
9100
+
9005
9101
  try {
9006
9102
  body = await this._parseResponseBody(body);
9007
9103
  } catch (err) {
@@ -9046,9 +9142,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9046
9142
 
9047
9143
  const httpConfig = {
9048
9144
  method: verb,
9049
- uri: uri,
9145
+ uri,
9050
9146
  followAllRedirects: true,
9051
- timeout: timeout
9147
+ timeout
9052
9148
  };
9053
9149
 
9054
9150
  if (this.caps[`${capPrefix}_HEADERS`]) {
@@ -9076,6 +9172,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9076
9172
  requestOptions: httpConfig
9077
9173
  }, this.view));
9078
9174
 
9175
+ this._addRequestCookies(httpConfig);
9176
+
9079
9177
  const retries = this._getCapValue(`${capPrefix}_RETRIES`);
9080
9178
 
9081
9179
  debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
@@ -9095,6 +9193,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9095
9193
  }
9096
9194
  }
9097
9195
 
9196
+ _addRequestCookies(requestOptions) {
9197
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
9198
+ return;
9199
+ }
9200
+
9201
+ const url = new URL(requestOptions.uri);
9202
+
9203
+ if (!requestOptions.headers) {
9204
+ requestOptions.headers = {};
9205
+ }
9206
+
9207
+ requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
9208
+ }
9209
+
9210
+ _storeCookiesFromResponse(response) {
9211
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
9212
+ return;
9213
+ }
9214
+
9215
+ const responseCookies = response.headers['set-cookie'];
9216
+
9217
+ if (!responseCookies) {
9218
+ return;
9219
+ }
9220
+
9221
+ const host = lodash__default["default"].get(response, 'request.uri.host');
9222
+
9223
+ let cookie;
9224
+ responseCookies.forEach(cookieString => {
9225
+ cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
9226
+ });
9227
+
9228
+ if (cookie) {
9229
+ this.cookies[host] = cookie;
9230
+ }
9231
+ }
9232
+
9098
9233
  };
9099
9234
 
9100
9235
  const debug$3 = debug__default["default"]('botium-connector-PluginConnectorContainer-helper');
@@ -9169,7 +9304,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
9169
9304
  source: 'src/containers/plugins/index.js',
9170
9305
  cause: {
9171
9306
  SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
9172
- mode: mode,
9307
+ mode,
9173
9308
  ...cause
9174
9309
  }
9175
9310
  });
@@ -9529,13 +9664,23 @@ var BotDriver_1 = class BotDriver {
9529
9664
  debug$1(`Build - Envs: ${JSON.stringify(lodash__default["default"].pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
9530
9665
  this.eventEmitter.emit(Events.CONTAINER_BUILDING);
9531
9666
  return new Promise((resolve, reject) => {
9667
+ let tempDirectory = null;
9532
9668
  let repo = null;
9533
9669
  let container = null;
9534
9670
  async__default["default"].series([driverValidated => {
9535
9671
  this._validate().then(() => driverValidated()).catch(driverValidated);
9672
+ }, tempDirectoryCreated => {
9673
+ tempDirectory = path__default["default"].resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename__default["default"](`${this.caps[Capabilities.PROJECTNAME]} ${moment__default["default"]().format('YYYYMMDD HHmmss')} ${randomatic__default["default"]('Aa0', 5)}`));
9674
+
9675
+ try {
9676
+ mkdirp__default["default"].sync(tempDirectory);
9677
+ tempDirectoryCreated();
9678
+ } catch (err) {
9679
+ tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
9680
+ }
9536
9681
  }, repoValidated => {
9537
9682
  try {
9538
- repo = this._getRepo();
9683
+ repo = this._getRepo(tempDirectory);
9539
9684
  } catch (err) {
9540
9685
  return repoValidated(err);
9541
9686
  }
@@ -9545,7 +9690,7 @@ var BotDriver_1 = class BotDriver {
9545
9690
  repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
9546
9691
  }, containerValidated => {
9547
9692
  try {
9548
- container = this._getContainer(repo);
9693
+ container = this._getContainer(tempDirectory, repo);
9549
9694
  } catch (err) {
9550
9695
  return containerValidated(err);
9551
9696
  }
@@ -9558,9 +9703,9 @@ var BotDriver_1 = class BotDriver {
9558
9703
  debug$1(`BotDriver Build error: ${err}`);
9559
9704
  this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
9560
9705
 
9561
- if (this.tempDirectory) {
9562
- rimraf__default["default"](this.tempDirectory, err => {
9563
- if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default["default"].inspect(err)}`);
9706
+ if (tempDirectory) {
9707
+ rimraf__default["default"](tempDirectory, err => {
9708
+ if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util__default["default"].inspect(err)}`);
9564
9709
  });
9565
9710
  }
9566
9711
 
@@ -9736,14 +9881,6 @@ var BotDriver_1 = class BotDriver {
9736
9881
  throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
9737
9882
  }
9738
9883
 
9739
- this.tempDirectory = path__default["default"].resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename__default["default"](`${this.caps[Capabilities.PROJECTNAME]} ${moment__default["default"]().format('YYYYMMDD HHmmss')} ${randomatic__default["default"]('Aa0', 5)}`));
9740
-
9741
- try {
9742
- mkdirp__default["default"].sync(this.tempDirectory);
9743
- } catch (err) {
9744
- throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
9745
- }
9746
-
9747
9884
  resolve(this);
9748
9885
  } catch (err) {
9749
9886
  reject(err);
@@ -9751,29 +9888,29 @@ var BotDriver_1 = class BotDriver {
9751
9888
  });
9752
9889
  }
9753
9890
 
9754
- _getRepo() {
9891
+ _getRepo(tempDirectory) {
9755
9892
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9756
9893
  const NoRepo = NoRepo_1;
9757
- return new NoRepo(this.tempDirectory, this.sources);
9894
+ return new NoRepo(tempDirectory, this.sources);
9758
9895
  }
9759
9896
 
9760
9897
  if (this.sources[Source.GITURL]) {
9761
9898
  const GitRepo = GitRepo_1;
9762
- return new GitRepo(this.tempDirectory, this.sources);
9899
+ return new GitRepo(tempDirectory, this.sources);
9763
9900
  }
9764
9901
 
9765
9902
  if (this.sources[Source.LOCALPATH]) {
9766
9903
  const LocalRepo = LocalRepo_1;
9767
- return new LocalRepo(this.tempDirectory, this.sources);
9904
+ return new LocalRepo(tempDirectory, this.sources);
9768
9905
  }
9769
9906
 
9770
9907
  throw new Error(`No Repo provider found for Sources ${util__default["default"].inspect(this.sources)}`);
9771
9908
  }
9772
9909
 
9773
- _getContainer(repo) {
9910
+ _getContainer(tempDirectory, repo) {
9774
9911
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9775
9912
  const GridContainer = GridContainer_1;
9776
- return new GridContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9913
+ return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9777
9914
  }
9778
9915
 
9779
9916
  if (!this.caps[Capabilities.CONTAINERMODE]) {
@@ -9782,11 +9919,11 @@ var BotDriver_1 = class BotDriver {
9782
9919
 
9783
9920
  if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
9784
9921
  const InProcessContainer = InProcessContainer_1;
9785
- return new InProcessContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9922
+ return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9786
9923
  }
9787
9924
 
9788
9925
  const PluginConnectorContainer = PluginConnectorContainer_1;
9789
- return new PluginConnectorContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9926
+ return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9790
9927
  }
9791
9928
 
9792
9929
  };