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.
@@ -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.12.5";
83
83
  var description = "The Selenium for Chatbots";
84
84
  var main = "index.js";
85
85
  var module$1 = "dist/botium-es.js";
@@ -111,9 +111,9 @@ var bugs = {
111
111
  };
112
112
  var homepage = "https://www.botium.ai";
113
113
  var dependencies = {
114
- "@babel/runtime": "^7.17.8",
114
+ "@babel/runtime": "^7.17.9",
115
115
  async: "^3.2.3",
116
- "body-parser": "^1.19.2",
116
+ "body-parser": "^1.20.0",
117
117
  boolean: "^3.2.0",
118
118
  bottleneck: "^2.19.5",
119
119
  "csv-parse": "^5.0.4",
@@ -121,7 +121,7 @@ var dependencies = {
121
121
  esprima: "^4.0.1",
122
122
  express: "^4.17.3",
123
123
  globby: "11.0.4",
124
- ioredis: "^4.28.5",
124
+ ioredis: "^5.0.4",
125
125
  "is-class": "^0.0.9",
126
126
  "is-json": "^2.0.1",
127
127
  jsonpath: "^1.1.1",
@@ -129,7 +129,7 @@ var dependencies = {
129
129
  "markdown-it": "^12.3.2",
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",
@@ -141,36 +141,36 @@ var dependencies = {
141
141
  "socket.io": "^4.4.1",
142
142
  "socket.io-client": "^4.4.1",
143
143
  "socketio-auth": "^0.1.1",
144
- "swagger-jsdoc": "^6.1.0",
144
+ "swagger-jsdoc": "^6.2.1",
145
145
  "swagger-ui-express": "^4.3.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",
149
+ xlsx: "^0.18.5",
150
150
  xregexp: "^5.1.0",
151
- yaml: "^1.10.2"
151
+ yaml: "^2.0.1"
152
152
  };
153
153
  var devDependencies = {
154
- "@babel/core": "^7.17.8",
154
+ "@babel/core": "^7.17.9",
155
155
  "@babel/node": "^7.16.8",
156
156
  "@babel/plugin-transform-runtime": "^7.17.0",
157
157
  "@babel/preset-env": "^7.16.11",
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.13.0",
162
+ "eslint-config-standard": "^17.0.0",
163
+ "eslint-plugin-import": "^2.26.0",
164
+ "eslint-plugin-n": "^15.1.0",
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
169
  mocha: "^9.2.2",
170
170
  nock: "^13.2.4",
171
- "npm-check-updates": "^12.5.4",
171
+ "npm-check-updates": "^12.5.9",
172
172
  nyc: "^15.1.0",
173
- rollup: "^2.70.1",
173
+ rollup: "^2.70.2",
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
@@ -456,6 +457,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
456
457
  Capabilities.SIMPLEREST_REDIS_TOPIC;
457
458
  Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
458
459
  Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
460
+ Capabilities.SIMPLEREST_COOKIE_REPLICATION;
459
461
  Capabilities.SCRIPTING_TXT_EOL;
460
462
  Capabilities.SCRIPTING_XLSX_MODE;
461
463
  Capabilities.SCRIPTING_XLSX_EOL_WRITE;
@@ -554,6 +556,7 @@ var Defaults$1 = {
554
556
  [Capabilities.SIMPLEREST_STRICT_SSL]: true,
555
557
  [Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
556
558
  [Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
559
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
557
560
  [Capabilities.SCRIPTING_TXT_EOL]: '\n',
558
561
  [Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
559
562
  [Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
@@ -2348,7 +2351,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
2348
2351
  header: {
2349
2352
  name: caseName
2350
2353
  },
2351
- values: values
2354
+ values
2352
2355
  };
2353
2356
  scriptingMemories.push(scriptingMemory);
2354
2357
  }
@@ -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
  throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
@@ -3015,7 +3018,7 @@ class Convo$6 {
3015
3018
  },
3016
3019
  container,
3017
3020
  transcript,
3018
- scriptingMemory: scriptingMemory
3021
+ scriptingMemory
3019
3022
  });
3020
3023
  } catch (err) {
3021
3024
  assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3041,7 +3044,7 @@ class Convo$6 {
3041
3044
  },
3042
3045
  container,
3043
3046
  transcript,
3044
- scriptingMemory: scriptingMemory
3047
+ scriptingMemory
3045
3048
  });
3046
3049
  } catch (err) {
3047
3050
  transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3819,7 +3822,7 @@ const optionalJson = json => {
3819
3822
  const body = isJson(json);
3820
3823
  return body ? {
3821
3824
  'content-type': 'application/json',
3822
- body: body
3825
+ body
3823
3826
  } : {
3824
3827
  'content-type': 'text/plain',
3825
3828
  body: json
@@ -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
  }
4893
4896
  } else {
@@ -4930,7 +4933,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4930
4933
  header: {
4931
4934
  name: caseName
4932
4935
  },
4933
- values: values
4936
+ values
4934
4937
  });
4935
4938
  } else {
4936
4939
  break;
@@ -7276,7 +7279,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7276
7279
  const node = {
7277
7280
  sender: convoNode.sender,
7278
7281
  key: randomatic__default["default"]('0', 20),
7279
- hash: hash,
7282
+ hash,
7280
7283
  convoNodes: convoNodeValues,
7281
7284
  convos: [lodash__default["default"].cloneDeep(convoNodeHeader)],
7282
7285
  childNodes: []
@@ -8155,6 +8158,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8155
8158
 
8156
8159
  this.processInbound = false;
8157
8160
  this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
8161
+ this.cookies = {};
8158
8162
 
8159
8163
  if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
8160
8164
  const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
@@ -8602,6 +8606,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8602
8606
  if (body) {
8603
8607
  debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8604
8608
 
8609
+ this._storeCookiesFromResponse(response);
8610
+
8605
8611
  try {
8606
8612
  body = await this._parseResponseBody(body);
8607
8613
  } catch (err) {
@@ -8724,6 +8730,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8724
8730
  await executeHook(this.caps, this.requestHook, Object.assign({
8725
8731
  requestOptions
8726
8732
  }, this.view));
8733
+
8734
+ this._addRequestCookies(requestOptions);
8735
+
8727
8736
  return requestOptions;
8728
8737
  }
8729
8738
 
@@ -8768,6 +8777,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8768
8777
  } else {
8769
8778
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8770
8779
 
8780
+ this._storeCookiesFromResponse(response);
8781
+
8771
8782
  if (debug$4.enabled && body) {
8772
8783
  debug$4(Utils.shortenJsonString(body));
8773
8784
  }
@@ -8952,9 +8963,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8952
8963
 
8953
8964
  const pollConfig = {
8954
8965
  method: verb,
8955
- uri: uri,
8966
+ uri,
8956
8967
  followAllRedirects: true,
8957
- timeout: timeout
8968
+ timeout
8958
8969
  };
8959
8970
 
8960
8971
  if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
@@ -8989,6 +9000,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8989
9000
  return;
8990
9001
  }
8991
9002
 
9003
+ this._addRequestCookies(pollConfig);
9004
+
8992
9005
  request__default["default"](pollConfig, async (err, response, body) => {
8993
9006
  if (err) {
8994
9007
  debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
@@ -9002,6 +9015,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9002
9015
  } else if (body) {
9003
9016
  debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
9004
9017
 
9018
+ this._storeCookiesFromResponse(response);
9019
+
9005
9020
  try {
9006
9021
  body = await this._parseResponseBody(body);
9007
9022
  } catch (err) {
@@ -9046,9 +9061,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9046
9061
 
9047
9062
  const httpConfig = {
9048
9063
  method: verb,
9049
- uri: uri,
9064
+ uri,
9050
9065
  followAllRedirects: true,
9051
- timeout: timeout
9066
+ timeout
9052
9067
  };
9053
9068
 
9054
9069
  if (this.caps[`${capPrefix}_HEADERS`]) {
@@ -9076,6 +9091,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9076
9091
  requestOptions: httpConfig
9077
9092
  }, this.view));
9078
9093
 
9094
+ this._addRequestCookies(httpConfig);
9095
+
9079
9096
  const retries = this._getCapValue(`${capPrefix}_RETRIES`);
9080
9097
 
9081
9098
  debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
@@ -9095,6 +9112,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9095
9112
  }
9096
9113
  }
9097
9114
 
9115
+ _addRequestCookies(requestOptions) {
9116
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
9117
+ return;
9118
+ }
9119
+
9120
+ const url = new URL(requestOptions.uri);
9121
+
9122
+ if (!requestOptions.headers) {
9123
+ requestOptions.headers = {};
9124
+ }
9125
+
9126
+ requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
9127
+ }
9128
+
9129
+ _storeCookiesFromResponse(response) {
9130
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
9131
+ return;
9132
+ }
9133
+
9134
+ const responseCookies = response.headers['set-cookie'];
9135
+
9136
+ if (!responseCookies) {
9137
+ return;
9138
+ }
9139
+
9140
+ const host = lodash__default["default"].get(response, 'request.uri.host');
9141
+
9142
+ let cookie;
9143
+ responseCookies.forEach(cookieString => {
9144
+ cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
9145
+ });
9146
+
9147
+ if (cookie) {
9148
+ this.cookies[host] = cookie;
9149
+ }
9150
+ }
9151
+
9098
9152
  };
9099
9153
 
9100
9154
  const debug$3 = debug__default["default"]('botium-connector-PluginConnectorContainer-helper');
@@ -9169,7 +9223,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
9169
9223
  source: 'src/containers/plugins/index.js',
9170
9224
  cause: {
9171
9225
  SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
9172
- mode: mode,
9226
+ mode,
9173
9227
  ...cause
9174
9228
  }
9175
9229
  });
@@ -9529,13 +9583,23 @@ var BotDriver_1 = class BotDriver {
9529
9583
  debug$1(`Build - Envs: ${JSON.stringify(lodash__default["default"].pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
9530
9584
  this.eventEmitter.emit(Events.CONTAINER_BUILDING);
9531
9585
  return new Promise((resolve, reject) => {
9586
+ let tempDirectory = null;
9532
9587
  let repo = null;
9533
9588
  let container = null;
9534
9589
  async__default["default"].series([driverValidated => {
9535
9590
  this._validate().then(() => driverValidated()).catch(driverValidated);
9591
+ }, tempDirectoryCreated => {
9592
+ 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)}`));
9593
+
9594
+ try {
9595
+ mkdirp__default["default"].sync(tempDirectory);
9596
+ tempDirectoryCreated();
9597
+ } catch (err) {
9598
+ tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
9599
+ }
9536
9600
  }, repoValidated => {
9537
9601
  try {
9538
- repo = this._getRepo();
9602
+ repo = this._getRepo(tempDirectory);
9539
9603
  } catch (err) {
9540
9604
  return repoValidated(err);
9541
9605
  }
@@ -9545,7 +9609,7 @@ var BotDriver_1 = class BotDriver {
9545
9609
  repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
9546
9610
  }, containerValidated => {
9547
9611
  try {
9548
- container = this._getContainer(repo);
9612
+ container = this._getContainer(tempDirectory, repo);
9549
9613
  } catch (err) {
9550
9614
  return containerValidated(err);
9551
9615
  }
@@ -9558,9 +9622,9 @@ var BotDriver_1 = class BotDriver {
9558
9622
  debug$1(`BotDriver Build error: ${err}`);
9559
9623
  this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
9560
9624
 
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)}`);
9625
+ if (tempDirectory) {
9626
+ rimraf__default["default"](tempDirectory, err => {
9627
+ if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util__default["default"].inspect(err)}`);
9564
9628
  });
9565
9629
  }
9566
9630
 
@@ -9736,14 +9800,6 @@ var BotDriver_1 = class BotDriver {
9736
9800
  throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
9737
9801
  }
9738
9802
 
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
9803
  resolve(this);
9748
9804
  } catch (err) {
9749
9805
  reject(err);
@@ -9751,29 +9807,29 @@ var BotDriver_1 = class BotDriver {
9751
9807
  });
9752
9808
  }
9753
9809
 
9754
- _getRepo() {
9810
+ _getRepo(tempDirectory) {
9755
9811
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9756
9812
  const NoRepo = NoRepo_1;
9757
- return new NoRepo(this.tempDirectory, this.sources);
9813
+ return new NoRepo(tempDirectory, this.sources);
9758
9814
  }
9759
9815
 
9760
9816
  if (this.sources[Source.GITURL]) {
9761
9817
  const GitRepo = GitRepo_1;
9762
- return new GitRepo(this.tempDirectory, this.sources);
9818
+ return new GitRepo(tempDirectory, this.sources);
9763
9819
  }
9764
9820
 
9765
9821
  if (this.sources[Source.LOCALPATH]) {
9766
9822
  const LocalRepo = LocalRepo_1;
9767
- return new LocalRepo(this.tempDirectory, this.sources);
9823
+ return new LocalRepo(tempDirectory, this.sources);
9768
9824
  }
9769
9825
 
9770
9826
  throw new Error(`No Repo provider found for Sources ${util__default["default"].inspect(this.sources)}`);
9771
9827
  }
9772
9828
 
9773
- _getContainer(repo) {
9829
+ _getContainer(tempDirectory, repo) {
9774
9830
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9775
9831
  const GridContainer = GridContainer_1;
9776
- return new GridContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9832
+ return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9777
9833
  }
9778
9834
 
9779
9835
  if (!this.caps[Capabilities.CONTAINERMODE]) {
@@ -9782,11 +9838,11 @@ var BotDriver_1 = class BotDriver {
9782
9838
 
9783
9839
  if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
9784
9840
  const InProcessContainer = InProcessContainer_1;
9785
- return new InProcessContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9841
+ return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9786
9842
  }
9787
9843
 
9788
9844
  const PluginConnectorContainer = PluginConnectorContainer_1;
9789
- return new PluginConnectorContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9845
+ return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9790
9846
  }
9791
9847
 
9792
9848
  };