botium-core 1.13.17 → 1.13.18
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/README.md +0 -1
- package/dist/botium-cjs.js +95 -15
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +95 -15
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/BotDriver.js +2 -2
- package/src/Capabilities.js +6 -0
- package/src/containers/BaseContainer.js +7 -4
- package/src/containers/plugins/SimpleRestContainer.js +49 -0
- package/src/scripting/Convo.js +9 -0
- package/src/scripting/ScriptingProvider.js +19 -2
- package/src/scripting/logichook/asserter/ButtonsAsserter.js +21 -8
- package/src/scripting/logichook/logichooks/ClearQueueLogicHook.js +0 -1
- package/test/connectors/logicHook.js +0 -1
- package/test/connectors/simplerest.spec.js +79 -4
- package/test/scripting/asserters/buttonsAsserter.spec.js +84 -50
- package/test/scripting/logichooks/convos/custom_embedded_skip.convo.txt +11 -0
- package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_me.convo.txt +11 -0
- package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_nothing.convo.txt +8 -0
- package/test/scripting/logichooks/customEmbeddedSkip.json +14 -0
- package/test/scripting/logichooks/customEmbeddedSkip.spec.js +58 -0
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://nodei.co/npm/botium-core/)
|
|
6
6
|
|
|
7
|
-
[ ](https://app.codeship.com/projects/262204)
|
|
8
7
|
[](https://badge.fury.io/js/botium-core)
|
|
9
8
|
[]()
|
|
10
9
|
[](https://forum.botium.ai)
|
package/dist/botium-cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var util = require('util');
|
|
|
6
6
|
var fs = require('fs');
|
|
7
7
|
var path = require('path');
|
|
8
8
|
var async = require('async');
|
|
9
|
-
var rimraf$
|
|
9
|
+
var rimraf$1 = require('rimraf');
|
|
10
10
|
var mkdirp = require('mkdirp');
|
|
11
11
|
var sanitizeFilename = require('sanitize-filename');
|
|
12
12
|
var moment = require('moment');
|
|
@@ -46,7 +46,7 @@ var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
|
|
|
46
46
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
47
47
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
48
48
|
var async__default = /*#__PURE__*/_interopDefaultLegacy(async);
|
|
49
|
-
var rimraf__default = /*#__PURE__*/_interopDefaultLegacy(rimraf$
|
|
49
|
+
var rimraf__default = /*#__PURE__*/_interopDefaultLegacy(rimraf$1);
|
|
50
50
|
var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp);
|
|
51
51
|
var sanitizeFilename__default = /*#__PURE__*/_interopDefaultLegacy(sanitizeFilename);
|
|
52
52
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
@@ -81,7 +81,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
|
81
81
|
var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
|
|
82
82
|
|
|
83
83
|
var name = "botium-core";
|
|
84
|
-
var version$1 = "1.13.
|
|
84
|
+
var version$1 = "1.13.18";
|
|
85
85
|
var description = "The Selenium for Chatbots";
|
|
86
86
|
var main = "index.js";
|
|
87
87
|
var module$1 = "dist/botium-es.js";
|
|
@@ -286,6 +286,12 @@ var Capabilities = {
|
|
|
286
286
|
SIMPLEREST_POLL_INTERVAL: 'SIMPLEREST_POLL_INTERVAL',
|
|
287
287
|
SIMPLEREST_POLL_TIMEOUT: 'SIMPLEREST_PING_TIMEOUT',
|
|
288
288
|
SIMPLEREST_POLL_UPDATE_CONTEXT: 'SIMPLEREST_POLL_UPDATE_CONTEXT',
|
|
289
|
+
SIMPLEREST_CONTEXT_IGNORE_JSONPATH: 'SIMPLEREST_CONTEXT_IGNORE_JSONPATH',
|
|
290
|
+
SIMPLEREST_CONTEXT_IGNORE_MATCH: 'SIMPLEREST_CONTEXT_IGNORE_MATCH',
|
|
291
|
+
SIMPLEREST_CONTEXT_SKIP_JSONPATH: 'SIMPLEREST_CONTEXT_SKIP_JSONPATH',
|
|
292
|
+
SIMPLEREST_CONTEXT_SKIP_MATCH: 'SIMPLEREST_CONTEXT_SKIP_MATCH',
|
|
293
|
+
SIMPLEREST_CONTEXT_CONTINUE_JSONPATH: 'SIMPLEREST_CONTEXT_CONTINUE_JSONPATH',
|
|
294
|
+
SIMPLEREST_CONTEXT_CONTINUE_MATCH: 'SIMPLEREST_CONTEXT_CONTINUE_MATCH',
|
|
289
295
|
SIMPLEREST_BODY_JSONPATH: 'SIMPLEREST_BODY_JSONPATH',
|
|
290
296
|
SIMPLEREST_RESPONSE_JSONPATH: 'SIMPLEREST_RESPONSE_JSONPATH',
|
|
291
297
|
SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
|
|
@@ -452,6 +458,12 @@ Capabilities.SIMPLEREST_POLL_REQUEST_HOOK;
|
|
|
452
458
|
Capabilities.SIMPLEREST_POLL_INTERVAL;
|
|
453
459
|
Capabilities.SIMPLEREST_POLL_TIMEOUT;
|
|
454
460
|
Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT;
|
|
461
|
+
Capabilities.SIMPLEREST_CONTEXT_IGNORE_JSONPATH;
|
|
462
|
+
Capabilities.SIMPLEREST_CONTEXT_IGNORE_MATCH;
|
|
463
|
+
Capabilities.SIMPLEREST_CONTEXT_SKIP_JSONPATH;
|
|
464
|
+
Capabilities.SIMPLEREST_CONTEXT_SKIP_MATCH;
|
|
465
|
+
Capabilities.SIMPLEREST_CONTEXT_CONTINUE_JSONPATH;
|
|
466
|
+
Capabilities.SIMPLEREST_CONTEXT_CONTINUE_MATCH;
|
|
455
467
|
Capabilities.SIMPLEREST_BODY_JSONPATH;
|
|
456
468
|
Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
|
|
457
469
|
Capabilities.SIMPLEREST_RESPONSE_HOOK;
|
|
@@ -3121,6 +3133,14 @@ class Convo$6 {
|
|
|
3121
3133
|
} catch (failErr) {}
|
|
3122
3134
|
throw failErr;
|
|
3123
3135
|
}
|
|
3136
|
+
if (convoStep.skip === true) {
|
|
3137
|
+
skipTranscriptStep = true;
|
|
3138
|
+
const nextConvoStep = this.conversation[i + 1];
|
|
3139
|
+
if (nextConvoStep && nextConvoStep.sender === 'bot') {
|
|
3140
|
+
waitForBotSays = false;
|
|
3141
|
+
}
|
|
3142
|
+
continue;
|
|
3143
|
+
}
|
|
3124
3144
|
if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
|
|
3125
3145
|
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
|
|
3126
3146
|
debug$j(failErr);
|
|
@@ -6415,10 +6435,16 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6415
6435
|
convoFilter: null
|
|
6416
6436
|
}, options);
|
|
6417
6437
|
const expandedConvos = [];
|
|
6438
|
+
// The globalContext is going to keep the data even if the Object.assign which happening to create the myContext in _expandConvo function
|
|
6439
|
+
const context = {
|
|
6440
|
+
globalContext: {
|
|
6441
|
+
totalConvoCount: 0
|
|
6442
|
+
}
|
|
6443
|
+
};
|
|
6418
6444
|
debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`);
|
|
6419
6445
|
this.convos.forEach(convo => {
|
|
6420
6446
|
convo.expandPartialConvos();
|
|
6421
|
-
for (const expanded of this._expandConvo(convo, options,
|
|
6447
|
+
for (const expanded of this._expandConvo(convo, options, context)) {
|
|
6422
6448
|
expanded.header.assertionCount = this.GetAssertionCount(expanded);
|
|
6423
6449
|
if (options.justHeader) {
|
|
6424
6450
|
const ConvoWithOnlyHeader = {
|
|
@@ -6434,6 +6460,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6434
6460
|
}
|
|
6435
6461
|
});
|
|
6436
6462
|
this.convos = expandedConvos;
|
|
6463
|
+
this.totalConvoCount = context.globalContext.totalConvoCount;
|
|
6437
6464
|
if (!options.justHeader) {
|
|
6438
6465
|
this._sortConvos();
|
|
6439
6466
|
} else {
|
|
@@ -6445,16 +6472,23 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6445
6472
|
// drop unwanted convos
|
|
6446
6473
|
convoFilter: null
|
|
6447
6474
|
}, options);
|
|
6475
|
+
// The globalContext is going to keep the data even if the Object.assign which happening to create the myContext in _expandConvo function
|
|
6476
|
+
const context = {
|
|
6477
|
+
globalContext: {
|
|
6478
|
+
totalConvoCount: 0
|
|
6479
|
+
}
|
|
6480
|
+
};
|
|
6448
6481
|
debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`);
|
|
6449
6482
|
// creating a nested generator, calling the other.
|
|
6450
6483
|
// We hope this.convos does not changes while this iterator is used
|
|
6451
6484
|
const _convosIterable = function* (options) {
|
|
6452
6485
|
for (const convo of this.convos) {
|
|
6453
6486
|
convo.expandPartialConvos();
|
|
6454
|
-
yield* this._expandConvo(convo, options,
|
|
6487
|
+
yield* this._expandConvo(convo, options, context);
|
|
6455
6488
|
}
|
|
6456
6489
|
}.bind(this);
|
|
6457
6490
|
this.convosIterable = _convosIterable(options);
|
|
6491
|
+
this.totalConvoCount = context.globalContext.totalConvoCount;
|
|
6458
6492
|
}
|
|
6459
6493
|
|
|
6460
6494
|
/**
|
|
@@ -6672,6 +6706,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6672
6706
|
const expanded = Object.assign(lodash__default["default"].cloneDeep(currentConvo), {
|
|
6673
6707
|
conversation: lodash__default["default"].cloneDeep(convoStepsStack)
|
|
6674
6708
|
});
|
|
6709
|
+
if (!lodash__default["default"].isNil(lodash__default["default"].get(context, 'globalContext.totalConvoCount'))) {
|
|
6710
|
+
context.globalContext.totalConvoCount++;
|
|
6711
|
+
}
|
|
6675
6712
|
if (!options.convoFilter || options.convoFilter(expanded)) {
|
|
6676
6713
|
yield expanded;
|
|
6677
6714
|
}
|
|
@@ -7190,9 +7227,6 @@ var Queue_1 = class Queue {
|
|
|
7190
7227
|
}
|
|
7191
7228
|
};
|
|
7192
7229
|
|
|
7193
|
-
const {
|
|
7194
|
-
rimraf: rimraf$1
|
|
7195
|
-
} = rimraf__default["default"];
|
|
7196
7230
|
const debug$7 = debug__default["default"]('botium-connector-BaseContainer');
|
|
7197
7231
|
const {
|
|
7198
7232
|
executeHook: executeHook$1,
|
|
@@ -7325,7 +7359,12 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7325
7359
|
}, rimraffed => {
|
|
7326
7360
|
if (this.caps[Capabilities.CLEANUPTEMPDIR]) {
|
|
7327
7361
|
debug$7(`Cleanup rimrafing temp dir ${this.tempDirectory}`);
|
|
7328
|
-
|
|
7362
|
+
try {
|
|
7363
|
+
rimraf__default["default"].sync(this.tempDirectory);
|
|
7364
|
+
rimraffed();
|
|
7365
|
+
} catch (err) {
|
|
7366
|
+
rimraffed(new Error(`Cleanup temp directory ${this.tempDirectory} failed: ${util__default["default"].inspect(err)}`));
|
|
7367
|
+
}
|
|
7329
7368
|
} else {
|
|
7330
7369
|
rimraffed();
|
|
7331
7370
|
}
|
|
@@ -7944,6 +7983,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7944
7983
|
}
|
|
7945
7984
|
debug$4(`current session context: ${util__default["default"].inspect(this.view.context)}`);
|
|
7946
7985
|
}
|
|
7986
|
+
const _isAnyContextJsonPathMatch = (capName, capNameMatch) => {
|
|
7987
|
+
const jsonPaths = getAllCapValues(capName, this.caps);
|
|
7988
|
+
if (jsonPaths.length > 0) {
|
|
7989
|
+
const jsonPathsMatch = getAllCapValues(capNameMatch, this.caps);
|
|
7990
|
+
for (const [index, jsonPath] of jsonPaths.entries()) {
|
|
7991
|
+
const contextNodes = jsonpath__default["default"].query(this.view.context, jsonPath);
|
|
7992
|
+
if (lodash__default["default"].isArray(contextNodes) && contextNodes.length > 0) {
|
|
7993
|
+
if (jsonPathsMatch[index]) {
|
|
7994
|
+
if (contextNodes[0] === jsonPathsMatch[index]) {
|
|
7995
|
+
return {
|
|
7996
|
+
jsonPath,
|
|
7997
|
+
match: contextNodes[0]
|
|
7998
|
+
};
|
|
7999
|
+
}
|
|
8000
|
+
} else {
|
|
8001
|
+
return {
|
|
8002
|
+
jsonPath
|
|
8003
|
+
};
|
|
8004
|
+
}
|
|
8005
|
+
}
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
return null;
|
|
8009
|
+
};
|
|
8010
|
+
const ignoreMatch = _isAnyContextJsonPathMatch(Capabilities.SIMPLEREST_CONTEXT_IGNORE_JSONPATH, Capabilities.SIMPLEREST_CONTEXT_IGNORE_MATCH);
|
|
8011
|
+
if (ignoreMatch) {
|
|
8012
|
+
if (ignoreMatch.match) debug$4(`ignoring response for context match: ${ignoreMatch.jsonPath} = ${ignoreMatch.match}`);else debug$4(`ignoring response for context: ${ignoreMatch.jsonPath}`);
|
|
8013
|
+
return;
|
|
8014
|
+
}
|
|
8015
|
+
const skipMatch = _isAnyContextJsonPathMatch(Capabilities.SIMPLEREST_CONTEXT_SKIP_JSONPATH, Capabilities.SIMPLEREST_CONTEXT_SKIP_MATCH);
|
|
8016
|
+
if (skipMatch) {
|
|
8017
|
+
if (skipMatch.match) debug$4(`skipping response for context match: ${skipMatch.jsonPath} = ${skipMatch.match}`);else debug$4(`skipping response for context: ${skipMatch.jsonPath}`);
|
|
8018
|
+
setTimeout(() => this._doRequest({
|
|
8019
|
+
messageText: ''
|
|
8020
|
+
}, true, true), 0);
|
|
8021
|
+
return;
|
|
8022
|
+
}
|
|
7947
8023
|
const result = [];
|
|
7948
8024
|
if (isFromUser) {
|
|
7949
8025
|
const _extractFrom = (root, jsonPaths) => {
|
|
@@ -8092,6 +8168,13 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8092
8168
|
}
|
|
8093
8169
|
}
|
|
8094
8170
|
}
|
|
8171
|
+
const continueMatch = _isAnyContextJsonPathMatch(Capabilities.SIMPLEREST_CONTEXT_CONTINUE_JSONPATH, Capabilities.SIMPLEREST_CONTEXT_CONTINUE_MATCH);
|
|
8172
|
+
if (continueMatch) {
|
|
8173
|
+
if (continueMatch.match) debug$4(`continue with next response for context match: ${continueMatch.jsonPath} = ${continueMatch.match}`);else debug$4(`continue with next response for context: ${continueMatch.jsonPath}`);
|
|
8174
|
+
setTimeout(() => this._doRequest({
|
|
8175
|
+
messageText: ''
|
|
8176
|
+
}, true, true), 0);
|
|
8177
|
+
}
|
|
8095
8178
|
return result;
|
|
8096
8179
|
}
|
|
8097
8180
|
_doRequest(msg, isFromUser, updateContext) {
|
|
@@ -8849,21 +8932,18 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8849
8932
|
}
|
|
8850
8933
|
};
|
|
8851
8934
|
|
|
8852
|
-
var require$$
|
|
8935
|
+
var require$$3 = getCjsExportFromNamespace(_package$1);
|
|
8853
8936
|
|
|
8854
8937
|
const {
|
|
8855
8938
|
rimraf
|
|
8856
8939
|
} = rimraf__default["default"];
|
|
8857
|
-
const {
|
|
8858
|
-
mkdirpSync
|
|
8859
|
-
} = mkdirp__default["default"];
|
|
8860
8940
|
const {
|
|
8861
8941
|
boolean
|
|
8862
8942
|
} = boolean__default["default"];
|
|
8863
8943
|
const debug$1 = debug__default["default"]('botium-core-BotDriver');
|
|
8864
8944
|
const {
|
|
8865
8945
|
version
|
|
8866
|
-
} = require$$
|
|
8946
|
+
} = require$$3;
|
|
8867
8947
|
var BotDriver_1 = class BotDriver {
|
|
8868
8948
|
constructor(caps = {}, sources = {}, envs = {}) {
|
|
8869
8949
|
this.eventEmitter = new events__default["default"]();
|
|
@@ -8953,7 +9033,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
8953
9033
|
}, tempDirectoryCreated => {
|
|
8954
9034
|
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)}`));
|
|
8955
9035
|
try {
|
|
8956
|
-
|
|
9036
|
+
mkdirp__default["default"].sync(tempDirectory);
|
|
8957
9037
|
tempDirectoryCreated();
|
|
8958
9038
|
} catch (err) {
|
|
8959
9039
|
tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
|