botium-core 1.12.4 → 1.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/botium-es.js CHANGED
@@ -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.12.5";
40
40
  var description = "The Selenium for Chatbots";
41
41
  var main = "index.js";
42
42
  var module = "dist/botium-es.js";
@@ -68,9 +68,9 @@ var bugs = {
68
68
  };
69
69
  var homepage = "https://www.botium.ai";
70
70
  var dependencies = {
71
- "@babel/runtime": "^7.17.8",
71
+ "@babel/runtime": "^7.17.9",
72
72
  async: "^3.2.3",
73
- "body-parser": "^1.19.2",
73
+ "body-parser": "^1.20.0",
74
74
  boolean: "^3.2.0",
75
75
  bottleneck: "^2.19.5",
76
76
  "csv-parse": "^5.0.4",
@@ -78,7 +78,7 @@ var dependencies = {
78
78
  esprima: "^4.0.1",
79
79
  express: "^4.17.3",
80
80
  globby: "11.0.4",
81
- ioredis: "^4.28.5",
81
+ ioredis: "^5.0.4",
82
82
  "is-class": "^0.0.9",
83
83
  "is-json": "^2.0.1",
84
84
  jsonpath: "^1.1.1",
@@ -86,7 +86,7 @@ var dependencies = {
86
86
  "markdown-it": "^12.3.2",
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",
@@ -98,36 +98,36 @@ var dependencies = {
98
98
  "socket.io": "^4.4.1",
99
99
  "socket.io-client": "^4.4.1",
100
100
  "socketio-auth": "^0.1.1",
101
- "swagger-jsdoc": "^6.1.0",
101
+ "swagger-jsdoc": "^6.2.1",
102
102
  "swagger-ui-express": "^4.3.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",
106
+ xlsx: "^0.18.5",
107
107
  xregexp: "^5.1.0",
108
- yaml: "^1.10.2"
108
+ yaml: "^2.0.1"
109
109
  };
110
110
  var devDependencies = {
111
- "@babel/core": "^7.17.8",
111
+ "@babel/core": "^7.17.9",
112
112
  "@babel/node": "^7.16.8",
113
113
  "@babel/plugin-transform-runtime": "^7.17.0",
114
114
  "@babel/preset-env": "^7.16.11",
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.13.0",
119
+ "eslint-config-standard": "^17.0.0",
120
+ "eslint-plugin-import": "^2.26.0",
121
+ "eslint-plugin-n": "^15.1.0",
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
126
  mocha: "^9.2.2",
127
127
  nock: "^13.2.4",
128
- "npm-check-updates": "^12.5.4",
128
+ "npm-check-updates": "^12.5.9",
129
129
  nyc: "^15.1.0",
130
- rollup: "^2.70.1",
130
+ rollup: "^2.70.2",
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
@@ -413,6 +414,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
413
414
  Capabilities.SIMPLEREST_REDIS_TOPIC;
414
415
  Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
415
416
  Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
417
+ Capabilities.SIMPLEREST_COOKIE_REPLICATION;
416
418
  Capabilities.SCRIPTING_TXT_EOL;
417
419
  Capabilities.SCRIPTING_XLSX_MODE;
418
420
  Capabilities.SCRIPTING_XLSX_EOL_WRITE;
@@ -511,6 +513,7 @@ var Defaults$1 = {
511
513
  [Capabilities.SIMPLEREST_STRICT_SSL]: true,
512
514
  [Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
513
515
  [Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
516
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
514
517
  [Capabilities.SCRIPTING_TXT_EOL]: '\n',
515
518
  [Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
516
519
  [Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
@@ -2305,7 +2308,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
2305
2308
  header: {
2306
2309
  name: caseName
2307
2310
  },
2308
- values: values
2311
+ values
2309
2312
  };
2310
2313
  scriptingMemories.push(scriptingMemory);
2311
2314
  }
@@ -2955,7 +2958,7 @@ class Convo$6 {
2955
2958
  },
2956
2959
  container,
2957
2960
  transcript,
2958
- scriptingMemory: scriptingMemory
2961
+ scriptingMemory
2959
2962
  });
2960
2963
  } catch (err) {
2961
2964
  throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
@@ -2972,7 +2975,7 @@ class Convo$6 {
2972
2975
  },
2973
2976
  container,
2974
2977
  transcript,
2975
- scriptingMemory: scriptingMemory
2978
+ scriptingMemory
2976
2979
  });
2977
2980
  } catch (err) {
2978
2981
  assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -2998,7 +3001,7 @@ class Convo$6 {
2998
3001
  },
2999
3002
  container,
3000
3003
  transcript,
3001
- scriptingMemory: scriptingMemory
3004
+ scriptingMemory
3002
3005
  });
3003
3006
  } catch (err) {
3004
3007
  transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3776,7 +3779,7 @@ const optionalJson = json => {
3776
3779
  const body = isJson(json);
3777
3780
  return body ? {
3778
3781
  'content-type': 'application/json',
3779
- body: body
3782
+ body
3780
3783
  } : {
3781
3784
  'content-type': 'text/plain',
3782
3785
  body: json
@@ -4844,7 +4847,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4844
4847
  header: {
4845
4848
  name: caseName
4846
4849
  },
4847
- values: values
4850
+ values
4848
4851
  });
4849
4852
  }
4850
4853
  } else {
@@ -4887,7 +4890,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4887
4890
  header: {
4888
4891
  name: caseName
4889
4892
  },
4890
- values: values
4893
+ values
4891
4894
  });
4892
4895
  } else {
4893
4896
  break;
@@ -7233,7 +7236,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7233
7236
  const node = {
7234
7237
  sender: convoNode.sender,
7235
7238
  key: randomatic('0', 20),
7236
- hash: hash,
7239
+ hash,
7237
7240
  convoNodes: convoNodeValues,
7238
7241
  convos: [lodash.cloneDeep(convoNodeHeader)],
7239
7242
  childNodes: []
@@ -8112,6 +8115,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8112
8115
 
8113
8116
  this.processInbound = false;
8114
8117
  this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
8118
+ this.cookies = {};
8115
8119
 
8116
8120
  if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
8117
8121
  const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
@@ -8559,6 +8563,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8559
8563
  if (body) {
8560
8564
  debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8561
8565
 
8566
+ this._storeCookiesFromResponse(response);
8567
+
8562
8568
  try {
8563
8569
  body = await this._parseResponseBody(body);
8564
8570
  } catch (err) {
@@ -8681,6 +8687,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8681
8687
  await executeHook(this.caps, this.requestHook, Object.assign({
8682
8688
  requestOptions
8683
8689
  }, this.view));
8690
+
8691
+ this._addRequestCookies(requestOptions);
8692
+
8684
8693
  return requestOptions;
8685
8694
  }
8686
8695
 
@@ -8725,6 +8734,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8725
8734
  } else {
8726
8735
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8727
8736
 
8737
+ this._storeCookiesFromResponse(response);
8738
+
8728
8739
  if (debug$4.enabled && body) {
8729
8740
  debug$4(Utils.shortenJsonString(body));
8730
8741
  }
@@ -8909,9 +8920,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8909
8920
 
8910
8921
  const pollConfig = {
8911
8922
  method: verb,
8912
- uri: uri,
8923
+ uri,
8913
8924
  followAllRedirects: true,
8914
- timeout: timeout
8925
+ timeout
8915
8926
  };
8916
8927
 
8917
8928
  if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
@@ -8946,6 +8957,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8946
8957
  return;
8947
8958
  }
8948
8959
 
8960
+ this._addRequestCookies(pollConfig);
8961
+
8949
8962
  request(pollConfig, async (err, response, body) => {
8950
8963
  if (err) {
8951
8964
  debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
@@ -8959,6 +8972,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8959
8972
  } else if (body) {
8960
8973
  debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8961
8974
 
8975
+ this._storeCookiesFromResponse(response);
8976
+
8962
8977
  try {
8963
8978
  body = await this._parseResponseBody(body);
8964
8979
  } catch (err) {
@@ -9003,9 +9018,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9003
9018
 
9004
9019
  const httpConfig = {
9005
9020
  method: verb,
9006
- uri: uri,
9021
+ uri,
9007
9022
  followAllRedirects: true,
9008
- timeout: timeout
9023
+ timeout
9009
9024
  };
9010
9025
 
9011
9026
  if (this.caps[`${capPrefix}_HEADERS`]) {
@@ -9033,6 +9048,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9033
9048
  requestOptions: httpConfig
9034
9049
  }, this.view));
9035
9050
 
9051
+ this._addRequestCookies(httpConfig);
9052
+
9036
9053
  const retries = this._getCapValue(`${capPrefix}_RETRIES`);
9037
9054
 
9038
9055
  debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
@@ -9052,6 +9069,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9052
9069
  }
9053
9070
  }
9054
9071
 
9072
+ _addRequestCookies(requestOptions) {
9073
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
9074
+ return;
9075
+ }
9076
+
9077
+ const url = new URL(requestOptions.uri);
9078
+
9079
+ if (!requestOptions.headers) {
9080
+ requestOptions.headers = {};
9081
+ }
9082
+
9083
+ requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
9084
+ }
9085
+
9086
+ _storeCookiesFromResponse(response) {
9087
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
9088
+ return;
9089
+ }
9090
+
9091
+ const responseCookies = response.headers['set-cookie'];
9092
+
9093
+ if (!responseCookies) {
9094
+ return;
9095
+ }
9096
+
9097
+ const host = lodash.get(response, 'request.uri.host');
9098
+
9099
+ let cookie;
9100
+ responseCookies.forEach(cookieString => {
9101
+ cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
9102
+ });
9103
+
9104
+ if (cookie) {
9105
+ this.cookies[host] = cookie;
9106
+ }
9107
+ }
9108
+
9055
9109
  };
9056
9110
 
9057
9111
  const debug$3 = debug$l('botium-connector-PluginConnectorContainer-helper');
@@ -9126,7 +9180,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
9126
9180
  source: 'src/containers/plugins/index.js',
9127
9181
  cause: {
9128
9182
  SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
9129
- mode: mode,
9183
+ mode,
9130
9184
  ...cause
9131
9185
  }
9132
9186
  });
@@ -9486,13 +9540,23 @@ var BotDriver_1 = class BotDriver {
9486
9540
  debug$1(`Build - Envs: ${JSON.stringify(lodash.pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
9487
9541
  this.eventEmitter.emit(Events.CONTAINER_BUILDING);
9488
9542
  return new Promise((resolve, reject) => {
9543
+ let tempDirectory = null;
9489
9544
  let repo = null;
9490
9545
  let container = null;
9491
9546
  async.series([driverValidated => {
9492
9547
  this._validate().then(() => driverValidated()).catch(driverValidated);
9548
+ }, tempDirectoryCreated => {
9549
+ tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
9550
+
9551
+ try {
9552
+ mkdirp.sync(tempDirectory);
9553
+ tempDirectoryCreated();
9554
+ } catch (err) {
9555
+ tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
9556
+ }
9493
9557
  }, repoValidated => {
9494
9558
  try {
9495
- repo = this._getRepo();
9559
+ repo = this._getRepo(tempDirectory);
9496
9560
  } catch (err) {
9497
9561
  return repoValidated(err);
9498
9562
  }
@@ -9502,7 +9566,7 @@ var BotDriver_1 = class BotDriver {
9502
9566
  repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
9503
9567
  }, containerValidated => {
9504
9568
  try {
9505
- container = this._getContainer(repo);
9569
+ container = this._getContainer(tempDirectory, repo);
9506
9570
  } catch (err) {
9507
9571
  return containerValidated(err);
9508
9572
  }
@@ -9515,9 +9579,9 @@ var BotDriver_1 = class BotDriver {
9515
9579
  debug$1(`BotDriver Build error: ${err}`);
9516
9580
  this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
9517
9581
 
9518
- if (this.tempDirectory) {
9519
- rimraf(this.tempDirectory, err => {
9520
- if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util.inspect(err)}`);
9582
+ if (tempDirectory) {
9583
+ rimraf(tempDirectory, err => {
9584
+ if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util.inspect(err)}`);
9521
9585
  });
9522
9586
  }
9523
9587
 
@@ -9693,14 +9757,6 @@ var BotDriver_1 = class BotDriver {
9693
9757
  throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
9694
9758
  }
9695
9759
 
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
9760
  resolve(this);
9705
9761
  } catch (err) {
9706
9762
  reject(err);
@@ -9708,29 +9764,29 @@ var BotDriver_1 = class BotDriver {
9708
9764
  });
9709
9765
  }
9710
9766
 
9711
- _getRepo() {
9767
+ _getRepo(tempDirectory) {
9712
9768
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9713
9769
  const NoRepo = NoRepo_1;
9714
- return new NoRepo(this.tempDirectory, this.sources);
9770
+ return new NoRepo(tempDirectory, this.sources);
9715
9771
  }
9716
9772
 
9717
9773
  if (this.sources[Source.GITURL]) {
9718
9774
  const GitRepo = GitRepo_1;
9719
- return new GitRepo(this.tempDirectory, this.sources);
9775
+ return new GitRepo(tempDirectory, this.sources);
9720
9776
  }
9721
9777
 
9722
9778
  if (this.sources[Source.LOCALPATH]) {
9723
9779
  const LocalRepo = LocalRepo_1;
9724
- return new LocalRepo(this.tempDirectory, this.sources);
9780
+ return new LocalRepo(tempDirectory, this.sources);
9725
9781
  }
9726
9782
 
9727
9783
  throw new Error(`No Repo provider found for Sources ${util.inspect(this.sources)}`);
9728
9784
  }
9729
9785
 
9730
- _getContainer(repo) {
9786
+ _getContainer(tempDirectory, repo) {
9731
9787
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9732
9788
  const GridContainer = GridContainer_1;
9733
- return new GridContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9789
+ return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9734
9790
  }
9735
9791
 
9736
9792
  if (!this.caps[Capabilities.CONTAINERMODE]) {
@@ -9739,11 +9795,11 @@ var BotDriver_1 = class BotDriver {
9739
9795
 
9740
9796
  if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
9741
9797
  const InProcessContainer = InProcessContainer_1;
9742
- return new InProcessContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9798
+ return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9743
9799
  }
9744
9800
 
9745
9801
  const PluginConnectorContainer = PluginConnectorContainer_1;
9746
- return new PluginConnectorContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9802
+ return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9747
9803
  }
9748
9804
 
9749
9805
  };