botium-core 1.13.0 → 1.13.1

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
@@ -10,7 +10,7 @@ import randomatic from 'randomatic';
10
10
  import lodash from 'lodash';
11
11
  import boolean$1 from 'boolean';
12
12
  import events from 'events';
13
- import debug$l from 'debug';
13
+ import debug$m from 'debug';
14
14
  import vm2 from 'vm2';
15
15
  import isClass from 'is-class';
16
16
  import crypto from 'crypto';
@@ -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.13.0";
39
+ var version$1 = "1.13.1";
40
40
  var description = "The Selenium for Chatbots";
41
41
  var main = "index.js";
42
42
  var module = "dist/botium-es.js";
@@ -68,17 +68,17 @@ var bugs = {
68
68
  };
69
69
  var homepage = "https://www.botium.ai";
70
70
  var dependencies = {
71
- "@babel/runtime": "^7.18.3",
71
+ "@babel/runtime": "^7.18.6",
72
72
  async: "^3.2.4",
73
73
  "body-parser": "^1.20.0",
74
74
  boolean: "^3.2.0",
75
75
  bottleneck: "^2.19.5",
76
- "csv-parse": "^5.2.0",
76
+ "csv-parse": "^5.3.0",
77
77
  debug: "^4.3.4",
78
78
  esprima: "^4.0.1",
79
79
  express: "^4.18.1",
80
80
  globby: "11.0.4",
81
- ioredis: "^5.0.6",
81
+ ioredis: "^5.1.0",
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": "^13.0.1",
87
87
  "mime-types": "^2.1.35",
88
88
  mkdirp: "^1.0.4",
89
- moment: "^2.29.3",
89
+ moment: "^2.29.4",
90
90
  mustache: "^4.2.0",
91
91
  "promise-retry": "^2.0.1",
92
92
  "promise.allsettled": "^1.0.5",
@@ -101,33 +101,33 @@ var dependencies = {
101
101
  "swagger-jsdoc": "^6.2.1",
102
102
  "swagger-ui-express": "^4.4.0",
103
103
  uuid: "^8.3.2",
104
- vm2: "^3.9.9",
104
+ vm2: "^3.9.10",
105
105
  "write-yaml": "^1.0.0",
106
106
  xlsx: "^0.18.5",
107
107
  xregexp: "^5.1.1",
108
108
  yaml: "^2.1.1"
109
109
  };
110
110
  var devDependencies = {
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",
111
+ "@babel/core": "^7.18.6",
112
+ "@babel/node": "^7.18.6",
113
+ "@babel/plugin-transform-runtime": "^7.18.6",
114
+ "@babel/preset-env": "^7.18.6",
115
115
  chai: "^4.3.6",
116
116
  "chai-as-promised": "^7.1.1",
117
117
  "cross-env": "^7.0.3",
118
- eslint: "^8.18.0",
118
+ eslint: "^8.19.0",
119
119
  "eslint-config-standard": "^17.0.0",
120
120
  "eslint-plugin-import": "^2.26.0",
121
- "eslint-plugin-n": "^15.2.3",
121
+ "eslint-plugin-n": "^15.2.4",
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: "^10.0.0",
127
- nock: "^13.2.7",
128
- "npm-check-updates": "^14.0.1",
127
+ nock: "^13.2.8",
128
+ "npm-check-updates": "^15.2.6",
129
129
  nyc: "^15.1.0",
130
- rollup: "^2.75.6",
130
+ rollup: "^2.76.0",
131
131
  "rollup-plugin-babel": "^4.4.0",
132
132
  "rollup-plugin-commonjs": "^10.1.0",
133
133
  "rollup-plugin-json": "^4.0.0",
@@ -1188,7 +1188,7 @@ LogicHookConsts.DEFAULT_USER_INPUTS;
1188
1188
  const {
1189
1189
  NodeVM: NodeVM$2
1190
1190
  } = vm2;
1191
- const debug$k = debug$l('botium-core-asserterUtils');
1191
+ const debug$l = debug$m('botium-core-asserterUtils');
1192
1192
  const {
1193
1193
  BotiumError: BotiumError$6
1194
1194
  } = BotiumError_1;
@@ -1253,7 +1253,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1253
1253
  _fetchAsserters() {
1254
1254
  this.caps[Capabilities.ASSERTERS].forEach(asserter => {
1255
1255
  if (this.asserters[asserter.ref]) {
1256
- debug$k(`${asserter.ref} asserter already exists, overwriting.`);
1256
+ debug$l(`${asserter.ref} asserter already exists, overwriting.`);
1257
1257
  }
1258
1258
 
1259
1259
  this.asserters[asserter.ref] = this._loadClass(asserter, 'asserter');
@@ -1267,7 +1267,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1267
1267
  _fetchLogicHooks() {
1268
1268
  this.caps[Capabilities.LOGIC_HOOKS].forEach(logicHook => {
1269
1269
  if (this.logicHooks[logicHook.ref]) {
1270
- debug$k(`${logicHook.ref} logic hook already exists, overwriting.`);
1270
+ debug$l(`${logicHook.ref} logic hook already exists, overwriting.`);
1271
1271
  }
1272
1272
 
1273
1273
  this.logicHooks[logicHook.ref] = this._loadClass(logicHook, 'logichook');
@@ -1281,7 +1281,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1281
1281
  _fetchUserInputs() {
1282
1282
  this.caps[Capabilities.USER_INPUTS].forEach(userInput => {
1283
1283
  if (this.userInputs[userInput.ref]) {
1284
- debug$k(`${userInput.ref} userinput already exists, overwriting.`);
1284
+ debug$l(`${userInput.ref} userinput already exists, overwriting.`);
1285
1285
  }
1286
1286
 
1287
1287
  this.userInputs[userInput.ref] = this._loadClass(userInput, 'userinput');
@@ -1424,7 +1424,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1424
1424
  });
1425
1425
  return vm.run(script);
1426
1426
  } catch (err) {
1427
- throw new Error(`${err.message || err}`);
1427
+ throw new Error(`Script ${key} is not valid - ${err.message || err}`);
1428
1428
  }
1429
1429
  } else {
1430
1430
  throw new Error(`Script "${key}" is not valid - only functions and javascript code accepted`);
@@ -1515,7 +1515,7 @@ var LogicHookUtils_1 = class LogicHookUtils {
1515
1515
  }
1516
1516
  }
1517
1517
 
1518
- loadErr.forEach(debug$k);
1518
+ loadErr.forEach(debug$l);
1519
1519
  }
1520
1520
 
1521
1521
  throw new Error(`Failed to fetch ${ref} ${hookType}, no idea how to load ...`);
@@ -2374,7 +2374,7 @@ var helper = {
2374
2374
  linesToScriptingMemories: linesToScriptingMemories$2
2375
2375
  };
2376
2376
 
2377
- const debug$j = debug$l('botium-core-ScriptingMemory');
2377
+ const debug$k = debug$m('botium-core-ScriptingMemory');
2378
2378
  const {
2379
2379
  v1: uuidv1
2380
2380
  } = uuid;
@@ -2632,7 +2632,7 @@ const extractVarNames = text => {
2632
2632
  };
2633
2633
 
2634
2634
  const fill = (container, scriptingMemory, result, utterance, scriptingEvents) => {
2635
- debug$j(`fill start: ${util.inspect(scriptingMemory)}`);
2635
+ debug$k(`fill start: ${util.inspect(scriptingMemory)}`);
2636
2636
  let varRegex;
2637
2637
 
2638
2638
  switch (container.caps[Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]) {
@@ -2676,14 +2676,14 @@ const fill = (container, scriptingMemory, result, utterance, scriptingEvents) =>
2676
2676
  const varName = varMatches[i - 1];
2677
2677
 
2678
2678
  if (RESERVED_WORDS.indexOf(varName) >= 0) {
2679
- debug$j(`fill Variable "${varName}" is not overwritten, because it is reserved word. `);
2679
+ debug$k(`fill Variable "${varName}" is not overwritten, because it is reserved word. `);
2680
2680
  } else {
2681
2681
  scriptingMemory[varName] = resultMatches[i];
2682
2682
  }
2683
2683
  }
2684
2684
  }
2685
2685
  });
2686
- debug$j(`fill end: ${util.inspect(scriptingMemory)}`);
2686
+ debug$k(`fill end: ${util.inspect(scriptingMemory)}`);
2687
2687
  }
2688
2688
  };
2689
2689
 
@@ -2702,7 +2702,48 @@ ScriptingMemory.extractVarNames;
2702
2702
  ScriptingMemory.RESERVED_WORDS;
2703
2703
  ScriptingMemory.SCRIPTING_FUNCTIONS;
2704
2704
 
2705
- const debug$i = debug$l('botium-core-Convo');
2705
+ const debug$j = debug$m('botium-core-RetryHelper');
2706
+ var RetryHelper_1 = class RetryHelper {
2707
+ constructor(caps, section, options = {}) {
2708
+ this.retryErrorPatterns = [];
2709
+ const onErrorRegexp = caps[`RETRY_${section.toUpperCase()}_ONERROR_REGEXP`] || [];
2710
+
2711
+ if (onErrorRegexp) {
2712
+ if (lodash.isArray(onErrorRegexp)) {
2713
+ onErrorRegexp.forEach(r => {
2714
+ if (lodash.isString(r)) this.retryErrorPatterns.push(new RegExp(r, 'i'));else this.retryErrorPatterns.push(r);
2715
+ });
2716
+ } else if (lodash.isString(onErrorRegexp)) {
2717
+ this.retryErrorPatterns.push(new RegExp(onErrorRegexp, 'i'));
2718
+ } else {
2719
+ this.retryErrorPatterns.push(onErrorRegexp);
2720
+ }
2721
+ } // to turn on retries, NUMRETRIES or ONERROR_REGEXP has to be set
2722
+
2723
+
2724
+ this.retrySettings = {
2725
+ retries: caps[`RETRY_${section.toUpperCase()}_NUMRETRIES`] || (!lodash.isNil(options.numRetries) ? options.numRetries : this.retryErrorPatterns.length === 0 ? 0 : 1),
2726
+ factor: caps[`RETRY_${section.toUpperCase()}_FACTOR`] || (lodash.isNil(options.factor) ? 1 : options.factor),
2727
+ minTimeout: caps[`RETRY_${section.toUpperCase()}_MINTIMEOUT`] || (lodash.isNil(options.minTimeout) ? 1000 : options.minTimeout)
2728
+ };
2729
+ debug$j(`Retry for ${section} is ${this.retrySettings.retries > 0 ? 'enabled' : 'disabled'}. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`);
2730
+ }
2731
+
2732
+ shouldRetry(err) {
2733
+ if (!err) return false;
2734
+ if (this.retryErrorPatterns.length === 0) return true;
2735
+ const errString = util.inspect(err);
2736
+
2737
+ for (const re of this.retryErrorPatterns) {
2738
+ if (errString.match(re)) return true;
2739
+ }
2740
+
2741
+ return false;
2742
+ }
2743
+
2744
+ };
2745
+
2746
+ const debug$i = debug$m('botium-core-Convo');
2706
2747
  const {
2707
2748
  BotiumError: BotiumError$4,
2708
2749
  botiumErrorFromErr: botiumErrorFromErr$1,
@@ -2927,6 +2968,26 @@ class Convo$6 {
2927
2968
  }
2928
2969
 
2929
2970
  async Run(container) {
2971
+ const retryHelper = new RetryHelper_1(container.caps, 'CONVO');
2972
+ return promiseRetry(async (retry, number) => {
2973
+ return this.RunImpl(container).catch(err => {
2974
+ const retryRemaining = retryHelper.retrySettings.retries - number + 1;
2975
+
2976
+ if (retryHelper.shouldRetry(err)) {
2977
+ debug$i(`Convo failed with error "${err.message || JSON.stringify(err)}". Retry ${retryRemaining > 0 ? 'enabled' : 'disabled'} (remaining #${retryRemaining}/${retryHelper.retrySettings.retries}, criterion matches)`);
2978
+ retry(err);
2979
+ } else {
2980
+ if (retryHelper.retryErrorPatterns.length > 0) {
2981
+ debug$i(`Convo failed with error "${err.message || JSON.stringify(err)}". Retry 'disabled' (remaining (#${retryRemaining}/${retryHelper.retrySettings.retries}), criterion does not match)`);
2982
+ }
2983
+
2984
+ throw err;
2985
+ }
2986
+ });
2987
+ }, retryHelper.retrySettings);
2988
+ }
2989
+
2990
+ async RunImpl(container) {
2930
2991
  const transcript = new Transcript({
2931
2992
  steps: [],
2932
2993
  attachments: [],
@@ -3598,42 +3659,6 @@ var Convo_1 = {
3598
3659
  ConvoStep: ConvoStep$1
3599
3660
  };
3600
3661
 
3601
- var RetryHelper_1 = class RetryHelper {
3602
- constructor(caps, section) {
3603
- this.retrySettings = {
3604
- retries: caps[`RETRY_${section.toUpperCase()}_NUMRETRIES`] || 1,
3605
- factor: caps[`RETRY_${section.toUpperCase()}_FACTOR`] || 1,
3606
- minTimeout: caps[`RETRY_${section.toUpperCase()}_MINTIMEOUT`] || 1000
3607
- };
3608
- this.retryErrorPatterns = [];
3609
- const onErrorRegexp = caps[`RETRY_${section.toUpperCase()}_ONERROR_REGEXP`] || [];
3610
-
3611
- if (onErrorRegexp) {
3612
- if (lodash.isArray(onErrorRegexp)) {
3613
- onErrorRegexp.forEach(r => {
3614
- if (lodash.isString(r)) this.retryErrorPatterns.push(new RegExp(r, 'i'));else this.retryErrorPatterns.push(r);
3615
- });
3616
- } else if (lodash.isString(onErrorRegexp)) {
3617
- this.retryErrorPatterns.push(new RegExp(onErrorRegexp, 'i'));
3618
- } else {
3619
- this.retryErrorPatterns.push(onErrorRegexp);
3620
- }
3621
- }
3622
- }
3623
-
3624
- shouldRetry(err) {
3625
- if (!err || this.retryErrorPatterns.length === 0) return false;
3626
- const errString = util.inspect(err);
3627
-
3628
- for (const re of this.retryErrorPatterns) {
3629
- if (errString.match(re)) return true;
3630
- }
3631
-
3632
- return false;
3633
- }
3634
-
3635
- };
3636
-
3637
3662
  const {
3638
3663
  toString,
3639
3664
  quoteRegexpString
@@ -3956,7 +3981,7 @@ var JsonToJson = {
3956
3981
  const {
3957
3982
  NodeVM
3958
3983
  } = vm2;
3959
- const debug$h = debug$l('botium-core-HookUtils');
3984
+ const debug$h = debug$m('botium-core-HookUtils');
3960
3985
  const {
3961
3986
  BotiumError: BotiumError$3
3962
3987
  } = BotiumError_1;
@@ -4106,7 +4131,7 @@ var Script = {
4106
4131
  precompile: precompile$1
4107
4132
  };
4108
4133
 
4109
- const debug$g = debug$l('botium-core-PrecompilerMarkdownRasa');
4134
+ const debug$g = debug$m('botium-core-PrecompilerMarkdownRasa');
4110
4135
  const htmlCommentRegexp = /(<!--.*?-->)/g;
4111
4136
 
4112
4137
  var precompile = (caps, scriptBuffer, options, filename) => {
@@ -4222,7 +4247,7 @@ var MarkdownRasa = {
4222
4247
  precompile: precompile
4223
4248
  };
4224
4249
 
4225
- const debug$f = debug$l('botium-core-CapabilitiesUtils');
4250
+ const debug$f = debug$m('botium-core-CapabilitiesUtils');
4226
4251
  const {
4227
4252
  toJsonWeak
4228
4253
  } = Utils;
@@ -4334,7 +4359,7 @@ var CapabilitiesUtils = {
4334
4359
  flatCababilities: flatCababilities$1
4335
4360
  };
4336
4361
 
4337
- const debug$e = debug$l('botium-core-Precompilers');
4362
+ const debug$e = debug$m('botium-core-Precompilers');
4338
4363
  const {
4339
4364
  isJsonObject
4340
4365
  } = Utils;
@@ -4484,7 +4509,7 @@ var Utterance_1 = class Utterance {
4484
4509
 
4485
4510
  };
4486
4511
 
4487
- const debug$d = debug$l('botium-core-CompilerXlsx');
4512
+ const debug$d = debug$m('botium-core-CompilerXlsx');
4488
4513
  const {
4489
4514
  E_SCRIPTING_MEMORY_COLUMN_MODE
4490
4515
  } = Enums;
@@ -5257,7 +5282,7 @@ var CompilerTxt_1 = class CompilerTxt extends CompilerBase_1 {
5257
5282
  const {
5258
5283
  parse
5259
5284
  } = sync;
5260
- const debug$c = debug$l('botium-core-CompilerCsv');
5285
+ const debug$c = debug$m('botium-core-CompilerCsv');
5261
5286
  const {
5262
5287
  Convo: Convo$3
5263
5288
  } = Convo_1;
@@ -5520,7 +5545,7 @@ var CompilerCsv_1 = class CompilerCsv extends CompilerBase_1 {
5520
5545
 
5521
5546
  };
5522
5547
 
5523
- const debug$b = debug$l('botium-core-CompilerObject');
5548
+ const debug$b = debug$m('botium-core-CompilerObject');
5524
5549
  const {
5525
5550
  Convo: Convo$2
5526
5551
  } = Convo_1;
@@ -5697,7 +5722,7 @@ var CompilerJson_1 = class CompilerJson extends CompilerObjectBase_1 {
5697
5722
 
5698
5723
  };
5699
5724
 
5700
- const debug$a = debug$l('botium-core-CompilerMarkdown');
5725
+ const debug$a = debug$m('botium-core-CompilerMarkdown');
5701
5726
  const md = new markdownIt();
5702
5727
  const {
5703
5728
  Convo: Convo$1
@@ -5828,7 +5853,7 @@ var CompilerMarkdown_1 = class CompilerMarkdown extends CompilerBase_1 {
5828
5853
  };
5829
5854
 
5830
5855
  promise.shim();
5831
- const debug$9 = debug$l('botium-core-ScriptingProvider');
5856
+ const debug$9 = debug$m('botium-core-ScriptingProvider');
5832
5857
  const {
5833
5858
  Convo,
5834
5859
  ConvoStep
@@ -7398,7 +7423,7 @@ var NoRepo_1 = class NoRepo extends BaseRepo_1 {
7398
7423
  };
7399
7424
 
7400
7425
  var ProcessUtils = createCommonjsModule(function (module) {
7401
- const debug = debug$l('botium-core-ProcessUtils');
7426
+ const debug = debug$m('botium-core-ProcessUtils');
7402
7427
  module.exports = {
7403
7428
  childCommandLineRun: (cmd, ignoreErrors = false, processOptions = {}) => {
7404
7429
  const cmdOptions = cmd.split(' ');
@@ -7450,7 +7475,7 @@ var ProcessUtils = createCommonjsModule(function (module) {
7450
7475
  ProcessUtils.childCommandLineRun;
7451
7476
  ProcessUtils.childProcessRun;
7452
7477
 
7453
- const debug$8 = debug$l('botium-core-GitRepo');
7478
+ const debug$8 = debug$m('botium-core-GitRepo');
7454
7479
  var GitRepo_1 = class GitRepo extends BaseRepo_1 {
7455
7480
  Validate() {
7456
7481
  return super.Validate().then(() => {
@@ -7621,7 +7646,7 @@ var Queue_1 = class Queue {
7621
7646
 
7622
7647
  };
7623
7648
 
7624
- const debug$7 = debug$l('botium-connector-BaseContainer');
7649
+ const debug$7 = debug$m('botium-connector-BaseContainer');
7625
7650
  const {
7626
7651
  executeHook: executeHook$1,
7627
7652
  getHook: getHook$1
@@ -7852,7 +7877,7 @@ var BaseContainer_1 = class BaseContainer {
7852
7877
 
7853
7878
  };
7854
7879
 
7855
- const debug$6 = debug$l('botium-connector-GridContainer');
7880
+ const debug$6 = debug$m('botium-connector-GridContainer');
7856
7881
  var GridContainer_1 = class GridContainer extends BaseContainer_1 {
7857
7882
  Validate() {
7858
7883
  return super.Validate().then(() => {
@@ -8076,7 +8101,7 @@ var InProcessContainer_1 = class InProcessContainer extends BaseContainer_1 {
8076
8101
 
8077
8102
  };
8078
8103
 
8079
- const debug$5 = debug$l('botium-core-inbound-proxy');
8104
+ const debug$5 = debug$m('botium-core-inbound-proxy');
8080
8105
 
8081
8106
  const buildRedisHandler = (redisurl, topic) => {
8082
8107
  const redis = new ioredis(redisurl);
@@ -8159,7 +8184,7 @@ proxy.startProxy;
8159
8184
  const {
8160
8185
  v4: uuidv4
8161
8186
  } = uuid;
8162
- const debug$4 = debug$l('botium-connector-simplerest');
8187
+ const debug$4 = debug$m('botium-connector-simplerest');
8163
8188
  const {
8164
8189
  startProxy
8165
8190
  } = proxy;
@@ -9189,7 +9214,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9189
9214
 
9190
9215
  };
9191
9216
 
9192
- const debug$3 = debug$l('botium-connector-PluginConnectorContainer-helper');
9217
+ const debug$3 = debug$m('botium-connector-PluginConnectorContainer-helper');
9193
9218
  const {
9194
9219
  BotiumError
9195
9220
  } = BotiumError_1;
@@ -9358,7 +9383,7 @@ var plugins = {
9358
9383
  tryLoadPlugin: tryLoadPlugin$1
9359
9384
  };
9360
9385
 
9361
- const debug$2 = debug$l('botium-connector-PluginConnectorContainer');
9386
+ const debug$2 = debug$m('botium-connector-PluginConnectorContainer');
9362
9387
  const {
9363
9388
  tryLoadPlugin
9364
9389
  } = plugins;
@@ -9516,7 +9541,7 @@ var require$$2 = getCjsExportFromNamespace(_package$1);
9516
9541
  const {
9517
9542
  boolean
9518
9543
  } = boolean$1;
9519
- const debug$1 = debug$l('botium-core-BotDriver');
9544
+ const debug$1 = debug$m('botium-core-BotDriver');
9520
9545
  const {
9521
9546
  version
9522
9547
  } = require$$2;
@@ -9885,7 +9910,7 @@ var BotDriver_1 = class BotDriver {
9885
9910
 
9886
9911
  };
9887
9912
 
9888
- const debug = debug$l('botium-core-Plugins');
9913
+ const debug = debug$m('botium-core-Plugins');
9889
9914
  const PLUGIN_TYPE_CONNECTOR = 'PLUGIN_TYPE_CONNECTOR';
9890
9915
  const PLUGIN_TYPE_ASSERTER = 'PLUGIN_TYPE_ASSERTER';
9891
9916
  const PLUGIN_TYPE_LOGICHOOK = 'PLUGIN_TYPE_LOGICHOOK';