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/dist/botium-es.js
CHANGED
|
@@ -2,7 +2,7 @@ import util from 'util';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import async from 'async';
|
|
5
|
-
import rimraf$
|
|
5
|
+
import rimraf$1 from 'rimraf';
|
|
6
6
|
import mkdirp from 'mkdirp';
|
|
7
7
|
import sanitizeFilename from 'sanitize-filename';
|
|
8
8
|
import moment from 'moment';
|
|
@@ -37,7 +37,7 @@ import express from 'express';
|
|
|
37
37
|
import bodyParser from 'body-parser';
|
|
38
38
|
|
|
39
39
|
var name = "botium-core";
|
|
40
|
-
var version$1 = "1.13.
|
|
40
|
+
var version$1 = "1.13.18";
|
|
41
41
|
var description = "The Selenium for Chatbots";
|
|
42
42
|
var main = "index.js";
|
|
43
43
|
var module = "dist/botium-es.js";
|
|
@@ -242,6 +242,12 @@ var Capabilities = {
|
|
|
242
242
|
SIMPLEREST_POLL_INTERVAL: 'SIMPLEREST_POLL_INTERVAL',
|
|
243
243
|
SIMPLEREST_POLL_TIMEOUT: 'SIMPLEREST_PING_TIMEOUT',
|
|
244
244
|
SIMPLEREST_POLL_UPDATE_CONTEXT: 'SIMPLEREST_POLL_UPDATE_CONTEXT',
|
|
245
|
+
SIMPLEREST_CONTEXT_IGNORE_JSONPATH: 'SIMPLEREST_CONTEXT_IGNORE_JSONPATH',
|
|
246
|
+
SIMPLEREST_CONTEXT_IGNORE_MATCH: 'SIMPLEREST_CONTEXT_IGNORE_MATCH',
|
|
247
|
+
SIMPLEREST_CONTEXT_SKIP_JSONPATH: 'SIMPLEREST_CONTEXT_SKIP_JSONPATH',
|
|
248
|
+
SIMPLEREST_CONTEXT_SKIP_MATCH: 'SIMPLEREST_CONTEXT_SKIP_MATCH',
|
|
249
|
+
SIMPLEREST_CONTEXT_CONTINUE_JSONPATH: 'SIMPLEREST_CONTEXT_CONTINUE_JSONPATH',
|
|
250
|
+
SIMPLEREST_CONTEXT_CONTINUE_MATCH: 'SIMPLEREST_CONTEXT_CONTINUE_MATCH',
|
|
245
251
|
SIMPLEREST_BODY_JSONPATH: 'SIMPLEREST_BODY_JSONPATH',
|
|
246
252
|
SIMPLEREST_RESPONSE_JSONPATH: 'SIMPLEREST_RESPONSE_JSONPATH',
|
|
247
253
|
SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
|
|
@@ -408,6 +414,12 @@ Capabilities.SIMPLEREST_POLL_REQUEST_HOOK;
|
|
|
408
414
|
Capabilities.SIMPLEREST_POLL_INTERVAL;
|
|
409
415
|
Capabilities.SIMPLEREST_POLL_TIMEOUT;
|
|
410
416
|
Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT;
|
|
417
|
+
Capabilities.SIMPLEREST_CONTEXT_IGNORE_JSONPATH;
|
|
418
|
+
Capabilities.SIMPLEREST_CONTEXT_IGNORE_MATCH;
|
|
419
|
+
Capabilities.SIMPLEREST_CONTEXT_SKIP_JSONPATH;
|
|
420
|
+
Capabilities.SIMPLEREST_CONTEXT_SKIP_MATCH;
|
|
421
|
+
Capabilities.SIMPLEREST_CONTEXT_CONTINUE_JSONPATH;
|
|
422
|
+
Capabilities.SIMPLEREST_CONTEXT_CONTINUE_MATCH;
|
|
411
423
|
Capabilities.SIMPLEREST_BODY_JSONPATH;
|
|
412
424
|
Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
|
|
413
425
|
Capabilities.SIMPLEREST_RESPONSE_HOOK;
|
|
@@ -3077,6 +3089,14 @@ class Convo$6 {
|
|
|
3077
3089
|
} catch (failErr) {}
|
|
3078
3090
|
throw failErr;
|
|
3079
3091
|
}
|
|
3092
|
+
if (convoStep.skip === true) {
|
|
3093
|
+
skipTranscriptStep = true;
|
|
3094
|
+
const nextConvoStep = this.conversation[i + 1];
|
|
3095
|
+
if (nextConvoStep && nextConvoStep.sender === 'bot') {
|
|
3096
|
+
waitForBotSays = false;
|
|
3097
|
+
}
|
|
3098
|
+
continue;
|
|
3099
|
+
}
|
|
3080
3100
|
if (!botMsg || !botMsg.messageText && !botMsg.media && !botMsg.buttons && !botMsg.cards && !botMsg.sourceData && !botMsg.nlp) {
|
|
3081
3101
|
const failErr = new BotiumError$4(`${this.header.name}/${convoStep.stepTag}: bot says nothing`);
|
|
3082
3102
|
debug$j(failErr);
|
|
@@ -6371,10 +6391,16 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6371
6391
|
convoFilter: null
|
|
6372
6392
|
}, options);
|
|
6373
6393
|
const expandedConvos = [];
|
|
6394
|
+
// The globalContext is going to keep the data even if the Object.assign which happening to create the myContext in _expandConvo function
|
|
6395
|
+
const context = {
|
|
6396
|
+
globalContext: {
|
|
6397
|
+
totalConvoCount: 0
|
|
6398
|
+
}
|
|
6399
|
+
};
|
|
6374
6400
|
debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`);
|
|
6375
6401
|
this.convos.forEach(convo => {
|
|
6376
6402
|
convo.expandPartialConvos();
|
|
6377
|
-
for (const expanded of this._expandConvo(convo, options,
|
|
6403
|
+
for (const expanded of this._expandConvo(convo, options, context)) {
|
|
6378
6404
|
expanded.header.assertionCount = this.GetAssertionCount(expanded);
|
|
6379
6405
|
if (options.justHeader) {
|
|
6380
6406
|
const ConvoWithOnlyHeader = {
|
|
@@ -6390,6 +6416,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6390
6416
|
}
|
|
6391
6417
|
});
|
|
6392
6418
|
this.convos = expandedConvos;
|
|
6419
|
+
this.totalConvoCount = context.globalContext.totalConvoCount;
|
|
6393
6420
|
if (!options.justHeader) {
|
|
6394
6421
|
this._sortConvos();
|
|
6395
6422
|
} else {
|
|
@@ -6401,16 +6428,23 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6401
6428
|
// drop unwanted convos
|
|
6402
6429
|
convoFilter: null
|
|
6403
6430
|
}, options);
|
|
6431
|
+
// The globalContext is going to keep the data even if the Object.assign which happening to create the myContext in _expandConvo function
|
|
6432
|
+
const context = {
|
|
6433
|
+
globalContext: {
|
|
6434
|
+
totalConvoCount: 0
|
|
6435
|
+
}
|
|
6436
|
+
};
|
|
6404
6437
|
debug$9(`ExpandConvos - Using utterances expansion mode: ${this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE]}`);
|
|
6405
6438
|
// creating a nested generator, calling the other.
|
|
6406
6439
|
// We hope this.convos does not changes while this iterator is used
|
|
6407
6440
|
const _convosIterable = function* (options) {
|
|
6408
6441
|
for (const convo of this.convos) {
|
|
6409
6442
|
convo.expandPartialConvos();
|
|
6410
|
-
yield* this._expandConvo(convo, options,
|
|
6443
|
+
yield* this._expandConvo(convo, options, context);
|
|
6411
6444
|
}
|
|
6412
6445
|
}.bind(this);
|
|
6413
6446
|
this.convosIterable = _convosIterable(options);
|
|
6447
|
+
this.totalConvoCount = context.globalContext.totalConvoCount;
|
|
6414
6448
|
}
|
|
6415
6449
|
|
|
6416
6450
|
/**
|
|
@@ -6628,6 +6662,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
6628
6662
|
const expanded = Object.assign(lodash.cloneDeep(currentConvo), {
|
|
6629
6663
|
conversation: lodash.cloneDeep(convoStepsStack)
|
|
6630
6664
|
});
|
|
6665
|
+
if (!lodash.isNil(lodash.get(context, 'globalContext.totalConvoCount'))) {
|
|
6666
|
+
context.globalContext.totalConvoCount++;
|
|
6667
|
+
}
|
|
6631
6668
|
if (!options.convoFilter || options.convoFilter(expanded)) {
|
|
6632
6669
|
yield expanded;
|
|
6633
6670
|
}
|
|
@@ -7146,9 +7183,6 @@ var Queue_1 = class Queue {
|
|
|
7146
7183
|
}
|
|
7147
7184
|
};
|
|
7148
7185
|
|
|
7149
|
-
const {
|
|
7150
|
-
rimraf: rimraf$1
|
|
7151
|
-
} = rimraf$2;
|
|
7152
7186
|
const debug$7 = debug$n('botium-connector-BaseContainer');
|
|
7153
7187
|
const {
|
|
7154
7188
|
executeHook: executeHook$1,
|
|
@@ -7281,7 +7315,12 @@ var BaseContainer_1 = class BaseContainer {
|
|
|
7281
7315
|
}, rimraffed => {
|
|
7282
7316
|
if (this.caps[Capabilities.CLEANUPTEMPDIR]) {
|
|
7283
7317
|
debug$7(`Cleanup rimrafing temp dir ${this.tempDirectory}`);
|
|
7284
|
-
|
|
7318
|
+
try {
|
|
7319
|
+
rimraf$1.sync(this.tempDirectory);
|
|
7320
|
+
rimraffed();
|
|
7321
|
+
} catch (err) {
|
|
7322
|
+
rimraffed(new Error(`Cleanup temp directory ${this.tempDirectory} failed: ${util.inspect(err)}`));
|
|
7323
|
+
}
|
|
7285
7324
|
} else {
|
|
7286
7325
|
rimraffed();
|
|
7287
7326
|
}
|
|
@@ -7900,6 +7939,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
7900
7939
|
}
|
|
7901
7940
|
debug$4(`current session context: ${util.inspect(this.view.context)}`);
|
|
7902
7941
|
}
|
|
7942
|
+
const _isAnyContextJsonPathMatch = (capName, capNameMatch) => {
|
|
7943
|
+
const jsonPaths = getAllCapValues(capName, this.caps);
|
|
7944
|
+
if (jsonPaths.length > 0) {
|
|
7945
|
+
const jsonPathsMatch = getAllCapValues(capNameMatch, this.caps);
|
|
7946
|
+
for (const [index, jsonPath] of jsonPaths.entries()) {
|
|
7947
|
+
const contextNodes = jsonpath.query(this.view.context, jsonPath);
|
|
7948
|
+
if (lodash.isArray(contextNodes) && contextNodes.length > 0) {
|
|
7949
|
+
if (jsonPathsMatch[index]) {
|
|
7950
|
+
if (contextNodes[0] === jsonPathsMatch[index]) {
|
|
7951
|
+
return {
|
|
7952
|
+
jsonPath,
|
|
7953
|
+
match: contextNodes[0]
|
|
7954
|
+
};
|
|
7955
|
+
}
|
|
7956
|
+
} else {
|
|
7957
|
+
return {
|
|
7958
|
+
jsonPath
|
|
7959
|
+
};
|
|
7960
|
+
}
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7963
|
+
}
|
|
7964
|
+
return null;
|
|
7965
|
+
};
|
|
7966
|
+
const ignoreMatch = _isAnyContextJsonPathMatch(Capabilities.SIMPLEREST_CONTEXT_IGNORE_JSONPATH, Capabilities.SIMPLEREST_CONTEXT_IGNORE_MATCH);
|
|
7967
|
+
if (ignoreMatch) {
|
|
7968
|
+
if (ignoreMatch.match) debug$4(`ignoring response for context match: ${ignoreMatch.jsonPath} = ${ignoreMatch.match}`);else debug$4(`ignoring response for context: ${ignoreMatch.jsonPath}`);
|
|
7969
|
+
return;
|
|
7970
|
+
}
|
|
7971
|
+
const skipMatch = _isAnyContextJsonPathMatch(Capabilities.SIMPLEREST_CONTEXT_SKIP_JSONPATH, Capabilities.SIMPLEREST_CONTEXT_SKIP_MATCH);
|
|
7972
|
+
if (skipMatch) {
|
|
7973
|
+
if (skipMatch.match) debug$4(`skipping response for context match: ${skipMatch.jsonPath} = ${skipMatch.match}`);else debug$4(`skipping response for context: ${skipMatch.jsonPath}`);
|
|
7974
|
+
setTimeout(() => this._doRequest({
|
|
7975
|
+
messageText: ''
|
|
7976
|
+
}, true, true), 0);
|
|
7977
|
+
return;
|
|
7978
|
+
}
|
|
7903
7979
|
const result = [];
|
|
7904
7980
|
if (isFromUser) {
|
|
7905
7981
|
const _extractFrom = (root, jsonPaths) => {
|
|
@@ -8048,6 +8124,13 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8048
8124
|
}
|
|
8049
8125
|
}
|
|
8050
8126
|
}
|
|
8127
|
+
const continueMatch = _isAnyContextJsonPathMatch(Capabilities.SIMPLEREST_CONTEXT_CONTINUE_JSONPATH, Capabilities.SIMPLEREST_CONTEXT_CONTINUE_MATCH);
|
|
8128
|
+
if (continueMatch) {
|
|
8129
|
+
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}`);
|
|
8130
|
+
setTimeout(() => this._doRequest({
|
|
8131
|
+
messageText: ''
|
|
8132
|
+
}, true, true), 0);
|
|
8133
|
+
}
|
|
8051
8134
|
return result;
|
|
8052
8135
|
}
|
|
8053
8136
|
_doRequest(msg, isFromUser, updateContext) {
|
|
@@ -8805,21 +8888,18 @@ var PluginConnectorContainer_1 = class PluginConnectorContainer extends BaseCont
|
|
|
8805
8888
|
}
|
|
8806
8889
|
};
|
|
8807
8890
|
|
|
8808
|
-
var require$$
|
|
8891
|
+
var require$$3 = getCjsExportFromNamespace(_package$1);
|
|
8809
8892
|
|
|
8810
8893
|
const {
|
|
8811
8894
|
rimraf
|
|
8812
|
-
} = rimraf$
|
|
8813
|
-
const {
|
|
8814
|
-
mkdirpSync
|
|
8815
|
-
} = mkdirp;
|
|
8895
|
+
} = rimraf$1;
|
|
8816
8896
|
const {
|
|
8817
8897
|
boolean
|
|
8818
8898
|
} = boolean$1;
|
|
8819
8899
|
const debug$1 = debug$n('botium-core-BotDriver');
|
|
8820
8900
|
const {
|
|
8821
8901
|
version
|
|
8822
|
-
} = require$$
|
|
8902
|
+
} = require$$3;
|
|
8823
8903
|
var BotDriver_1 = class BotDriver {
|
|
8824
8904
|
constructor(caps = {}, sources = {}, envs = {}) {
|
|
8825
8905
|
this.eventEmitter = new events();
|
|
@@ -8909,7 +8989,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
8909
8989
|
}, tempDirectoryCreated => {
|
|
8910
8990
|
tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
|
|
8911
8991
|
try {
|
|
8912
|
-
|
|
8992
|
+
mkdirp.sync(tempDirectory);
|
|
8913
8993
|
tempDirectoryCreated();
|
|
8914
8994
|
} catch (err) {
|
|
8915
8995
|
tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
|