botium-core 1.12.1 → 1.12.2
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-cjs.js +35 -13
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +35 -13
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/Capabilities.js +1 -0
- package/src/containers/BaseContainer.js +20 -10
- package/src/containers/PluginConnectorContainer.js +1 -0
- package/src/containers/plugins/SimpleRestContainer.js +4 -3
package/dist/botium-cjs.js
CHANGED
|
@@ -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.
|
|
82
|
+
var version$1 = "1.12.2";
|
|
83
83
|
var description = "The Selenium for Chatbots";
|
|
84
84
|
var main = "index.js";
|
|
85
85
|
var module$1 = "dist/botium-es.js";
|
|
@@ -357,6 +357,7 @@ var Capabilities = {
|
|
|
357
357
|
// API Calls Rate Limiting
|
|
358
358
|
RATELIMIT_USERSAYS_MAXCONCURRENT: 'RATELIMIT_USERSAYS_MAXCONCURRENT',
|
|
359
359
|
RATELIMIT_USERSAYS_MINTIME: 'RATELIMIT_USERSAYS_MINTIME',
|
|
360
|
+
RATELIMIT_BOTTLENECK_FN: 'RATELIMIT_BOTTLENECK_FN',
|
|
360
361
|
SECURITY_ALLOW_UNSAFE: 'SECURITY_ALLOW_UNSAFE',
|
|
361
362
|
PRECOMPILERS: 'PRECOMPILERS'
|
|
362
363
|
};
|
|
@@ -491,6 +492,7 @@ Capabilities.LOGIC_HOOKS;
|
|
|
491
492
|
Capabilities.USER_INPUTS;
|
|
492
493
|
Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT;
|
|
493
494
|
Capabilities.RATELIMIT_USERSAYS_MINTIME;
|
|
495
|
+
Capabilities.RATELIMIT_BOTTLENECK_FN;
|
|
494
496
|
Capabilities.SECURITY_ALLOW_UNSAFE;
|
|
495
497
|
Capabilities.PRECOMPILERS;
|
|
496
498
|
|
|
@@ -7580,7 +7582,7 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7580
7582
|
this.tempDirectory = tempDirectory;
|
|
7581
7583
|
this.cleanupTasks = [];
|
|
7582
7584
|
this.queues = {};
|
|
7583
|
-
this.
|
|
7585
|
+
this.bottleneck = null;
|
|
7584
7586
|
}
|
|
7585
7587
|
|
|
7586
7588
|
Validate() {
|
|
@@ -7590,18 +7592,33 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7590
7592
|
this.onBotResponseHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONBOTRESPONSE]);
|
|
7591
7593
|
this.onStopHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONSTOP]);
|
|
7592
7594
|
this.onCleanHook = getHook$1(this.caps, this.caps[Capabilities.CUSTOMHOOK_ONCLEAN]);
|
|
7593
|
-
return Promise.resolve();
|
|
7594
|
-
}
|
|
7595
7595
|
|
|
7596
|
-
|
|
7597
|
-
|
|
7596
|
+
if (this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN]) {
|
|
7597
|
+
if (lodash__default["default"].isFunction(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN])) {
|
|
7598
|
+
this.bottleneck = this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN];
|
|
7599
|
+
debug$7('Validate: Applying userSays rate limits from capability');
|
|
7600
|
+
} else {
|
|
7601
|
+
const limiter = new bottleneck__default["default"](this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN]);
|
|
7602
|
+
|
|
7603
|
+
this.bottleneck = fn => limiter.schedule(fn);
|
|
7604
|
+
|
|
7605
|
+
debug$7(`Validate: Applying userSays rate limits ${util__default["default"].inspect(this.caps[Capabilities.RATELIMIT_BOTTLENECK_FN])}`);
|
|
7606
|
+
}
|
|
7607
|
+
} else if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT] || this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) {
|
|
7598
7608
|
const opts = {};
|
|
7599
7609
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT]) opts.maxConcurrent = this.caps[Capabilities.RATELIMIT_USERSAYS_MAXCONCURRENT];
|
|
7600
7610
|
if (this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME]) opts.minTime = this.caps[Capabilities.RATELIMIT_USERSAYS_MINTIME];
|
|
7601
|
-
|
|
7602
|
-
|
|
7611
|
+
const limiter = new bottleneck__default["default"](opts);
|
|
7612
|
+
|
|
7613
|
+
this.bottleneck = fn => limiter.schedule(fn);
|
|
7614
|
+
|
|
7615
|
+
debug$7(`Validate: Applying userSays rate limits ${util__default["default"].inspect(opts)}`);
|
|
7603
7616
|
}
|
|
7604
7617
|
|
|
7618
|
+
return Promise.resolve();
|
|
7619
|
+
}
|
|
7620
|
+
|
|
7621
|
+
Build() {
|
|
7605
7622
|
return new Promise((resolve, reject) => {
|
|
7606
7623
|
this._RunCustomHook('onBuild', this.onBuildHook).then(() => resolve(this)).catch(err => reject(err));
|
|
7607
7624
|
});
|
|
@@ -7627,8 +7644,8 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7627
7644
|
meMsg
|
|
7628
7645
|
}).then(() => this.UserSaysImpl(meMsg));
|
|
7629
7646
|
|
|
7630
|
-
if (this.
|
|
7631
|
-
return this.
|
|
7647
|
+
if (this.bottleneck) {
|
|
7648
|
+
return this.bottleneck(run);
|
|
7632
7649
|
} else {
|
|
7633
7650
|
return run();
|
|
7634
7651
|
}
|
|
@@ -8116,10 +8133,14 @@ mustache__default["default"].escape = s => s;
|
|
|
8116
8133
|
var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
8117
8134
|
constructor({
|
|
8118
8135
|
queueBotSays,
|
|
8119
|
-
caps
|
|
8136
|
+
caps,
|
|
8137
|
+
bottleneck
|
|
8120
8138
|
}) {
|
|
8121
8139
|
this.queueBotSays = queueBotSays;
|
|
8122
8140
|
this.caps = Object.assign({}, Defaults, caps);
|
|
8141
|
+
|
|
8142
|
+
this.bottleneck = bottleneck || (fn => fn());
|
|
8143
|
+
|
|
8123
8144
|
this.processInbound = false;
|
|
8124
8145
|
this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
|
|
8125
8146
|
|
|
@@ -8658,7 +8679,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8658
8679
|
err,
|
|
8659
8680
|
response,
|
|
8660
8681
|
body
|
|
8661
|
-
} = await new Promise(resolve => {
|
|
8682
|
+
} = await this.bottleneck(() => new Promise(resolve => {
|
|
8662
8683
|
request__default["default"](pingConfig, (err, response, body) => {
|
|
8663
8684
|
resolve({
|
|
8664
8685
|
err,
|
|
@@ -8666,7 +8687,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8666
8687
|
body
|
|
8667
8688
|
});
|
|
8668
8689
|
});
|
|
8669
|
-
});
|
|
8690
|
+
}));
|
|
8670
8691
|
|
|
8671
8692
|
if (err) {
|
|
8672
8693
|
debug$4(`_waitForUrlResponse error on url check ${pingConfig.uri}: ${err}`);
|
|
@@ -9190,6 +9211,7 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
9190
9211
|
this.pluginInstance = tryLoadPlugin(this.caps[Capabilities.CONTAINERMODE], this.caps[Capabilities.PLUGINMODULEPATH], {
|
|
9191
9212
|
container: this,
|
|
9192
9213
|
queueBotSays: msg => this._QueueBotSays(msg),
|
|
9214
|
+
bottleneck: this.bottleneck,
|
|
9193
9215
|
eventEmitter: this.eventEmitter,
|
|
9194
9216
|
caps: this.caps,
|
|
9195
9217
|
sources: this.sources,
|