botium-core 1.12.2 → 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.
- package/LICENSES-3RDPARTY.txt +901 -751
- package/dist/botium-cjs.js +211 -90
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +211 -90
- package/dist/botium-es.js.map +1 -1
- package/package.json +24 -24
- package/src/BotDriver.js +27 -22
- package/src/Capabilities.js +6 -0
- package/src/Defaults.js +1 -1
- package/src/containers/plugins/SimpleRestContainer.js +117 -35
- package/src/containers/plugins/index.js +1 -1
- package/src/helpers/Utils.js +1 -1
- package/src/scripting/CompilerXlsx.js +2 -2
- package/src/scripting/Convo.js +6 -6
- package/src/scripting/ScriptingProvider.js +1 -1
- package/src/scripting/helper.js +1 -1
- package/src/scripting/logichook/asserter/BaseCountAsserter.js +1 -1
- package/test/connectors/simplerest.spec.js +113 -8
- package/test/logichooks/convos/WAITFORBOT_INFINITE.convo.txt +1 -1
- package/test/logichooks/hookfromsrc.spec.js +1 -1
- package/test/scripting/scriptingProvider.spec.js +1 -1
package/dist/botium-es.js
CHANGED
|
@@ -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.12.
|
|
39
|
+
var version$1 = "1.12.5";
|
|
40
40
|
var description = "The Selenium for Chatbots";
|
|
41
41
|
var main = "index.js";
|
|
42
42
|
var module = "dist/botium-es.js";
|
|
@@ -68,25 +68,25 @@ var bugs = {
|
|
|
68
68
|
};
|
|
69
69
|
var homepage = "https://www.botium.ai";
|
|
70
70
|
var dependencies = {
|
|
71
|
-
"@babel/runtime": "^7.
|
|
71
|
+
"@babel/runtime": "^7.17.9",
|
|
72
72
|
async: "^3.2.3",
|
|
73
|
-
"body-parser": "^1.
|
|
74
|
-
boolean: "^3.
|
|
73
|
+
"body-parser": "^1.20.0",
|
|
74
|
+
boolean: "^3.2.0",
|
|
75
75
|
bottleneck: "^2.19.5",
|
|
76
76
|
"csv-parse": "^5.0.4",
|
|
77
|
-
debug: "^4.3.
|
|
77
|
+
debug: "^4.3.4",
|
|
78
78
|
esprima: "^4.0.1",
|
|
79
|
-
express: "^4.17.
|
|
79
|
+
express: "^4.17.3",
|
|
80
80
|
globby: "11.0.4",
|
|
81
|
-
ioredis: "^
|
|
81
|
+
ioredis: "^5.0.4",
|
|
82
82
|
"is-class": "^0.0.9",
|
|
83
83
|
"is-json": "^2.0.1",
|
|
84
84
|
jsonpath: "^1.1.1",
|
|
85
85
|
lodash: "^4.17.21",
|
|
86
86
|
"markdown-it": "^12.3.2",
|
|
87
|
-
"mime-types": "^2.1.
|
|
87
|
+
"mime-types": "^2.1.35",
|
|
88
88
|
mkdirp: "^1.0.4",
|
|
89
|
-
moment: "^2.29.
|
|
89
|
+
moment: "^2.29.3",
|
|
90
90
|
mustache: "^4.2.0",
|
|
91
91
|
"promise-retry": "^2.0.1",
|
|
92
92
|
"promise.allsettled": "^1.0.5",
|
|
@@ -98,36 +98,36 @@ var dependencies = {
|
|
|
98
98
|
"socket.io": "^4.4.1",
|
|
99
99
|
"socket.io-client": "^4.4.1",
|
|
100
100
|
"socketio-auth": "^0.1.1",
|
|
101
|
-
"swagger-jsdoc": "^6.1
|
|
101
|
+
"swagger-jsdoc": "^6.2.1",
|
|
102
102
|
"swagger-ui-express": "^4.3.0",
|
|
103
103
|
uuid: "^8.3.2",
|
|
104
|
-
vm2: "^3.9.
|
|
104
|
+
vm2: "^3.9.9",
|
|
105
105
|
"write-yaml": "^1.0.0",
|
|
106
|
-
xlsx: "^0.
|
|
106
|
+
xlsx: "^0.18.5",
|
|
107
107
|
xregexp: "^5.1.0",
|
|
108
|
-
yaml: "^
|
|
108
|
+
yaml: "^2.0.1"
|
|
109
109
|
};
|
|
110
110
|
var devDependencies = {
|
|
111
|
-
"@babel/core": "^7.
|
|
111
|
+
"@babel/core": "^7.17.9",
|
|
112
112
|
"@babel/node": "^7.16.8",
|
|
113
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
113
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
114
114
|
"@babel/preset-env": "^7.16.11",
|
|
115
|
-
chai: "^4.3.
|
|
115
|
+
chai: "^4.3.6",
|
|
116
116
|
"chai-as-promised": "^7.1.1",
|
|
117
117
|
"cross-env": "^7.0.3",
|
|
118
|
-
eslint: "^8.
|
|
119
|
-
"eslint-config-standard": "^
|
|
120
|
-
"eslint-plugin-import": "^2.
|
|
121
|
-
"eslint-plugin-
|
|
118
|
+
eslint: "^8.13.0",
|
|
119
|
+
"eslint-config-standard": "^17.0.0",
|
|
120
|
+
"eslint-plugin-import": "^2.26.0",
|
|
121
|
+
"eslint-plugin-n": "^15.1.0",
|
|
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
|
-
mocha: "^9.2.
|
|
127
|
-
nock: "^13.2.
|
|
128
|
-
"npm-check-updates": "^12.
|
|
126
|
+
mocha: "^9.2.2",
|
|
127
|
+
nock: "^13.2.4",
|
|
128
|
+
"npm-check-updates": "^12.5.9",
|
|
129
129
|
nyc: "^15.1.0",
|
|
130
|
-
rollup: "^2.
|
|
130
|
+
rollup: "^2.70.2",
|
|
131
131
|
"rollup-plugin-babel": "^4.4.0",
|
|
132
132
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
133
133
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -244,6 +244,11 @@ var Capabilities = {
|
|
|
244
244
|
SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
|
|
245
245
|
SIMPLEREST_MEDIA_JSONPATH: 'SIMPLEREST_MEDIA_JSONPATH',
|
|
246
246
|
SIMPLEREST_BUTTONS_JSONPATH: 'SIMPLEREST_BUTTONS_JSONPATH',
|
|
247
|
+
SIMPLEREST_CARDS_JSONPATH: 'SIMPLEREST_CARDS_JSONPATH',
|
|
248
|
+
SIMPLEREST_CARD_TEXT_JSONPATH: 'SIMPLEREST_CARD_TEXT_JSONPATH',
|
|
249
|
+
SIMPLEREST_CARD_SUBTEXT_JSONPATH: 'SIMPLEREST_CARD_SUBTEXT_JSONPATH',
|
|
250
|
+
SIMPLEREST_CARD_BUTTONS_JSONPATH: 'SIMPLEREST_CARD_BUTTONS_JSONPATH',
|
|
251
|
+
SIMPLEREST_CARD_ATTACHMENTS_JSONPATH: 'SIMPLEREST_CARD_ATTACHMENTS_JSONPATH',
|
|
247
252
|
SIMPLEREST_CONTEXT_JSONPATH: 'SIMPLEREST_CONTEXT_JSONPATH',
|
|
248
253
|
SIMPLEREST_CONTEXT_MERGE_OR_REPLACE: 'SIMPLEREST_CONTEXT_MERGE_OR_REPLACE',
|
|
249
254
|
SIMPLEREST_CONVERSATION_ID_TEMPLATE: 'SIMPLEREST_CONVERSATION_ID_TEMPLATE',
|
|
@@ -257,6 +262,7 @@ var Capabilities = {
|
|
|
257
262
|
SIMPLEREST_REDIS_TOPIC: 'SIMPLEREST_REDIS_TOPIC',
|
|
258
263
|
SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH: 'SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH',
|
|
259
264
|
SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT: 'SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT',
|
|
265
|
+
SIMPLEREST_COOKIE_REPLICATION: 'SIMPLEREST_COOKIE_REPLICATION',
|
|
260
266
|
// Script Compiler
|
|
261
267
|
SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
|
|
262
268
|
// ROW_PER_MESSAGE or QUESTION_ANSWER
|
|
@@ -390,6 +396,11 @@ Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
|
|
|
390
396
|
Capabilities.SIMPLEREST_RESPONSE_HOOK;
|
|
391
397
|
Capabilities.SIMPLEREST_MEDIA_JSONPATH;
|
|
392
398
|
Capabilities.SIMPLEREST_BUTTONS_JSONPATH;
|
|
399
|
+
Capabilities.SIMPLEREST_CARDS_JSONPATH;
|
|
400
|
+
Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH;
|
|
401
|
+
Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH;
|
|
402
|
+
Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH;
|
|
403
|
+
Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH;
|
|
393
404
|
Capabilities.SIMPLEREST_CONTEXT_JSONPATH;
|
|
394
405
|
Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE;
|
|
395
406
|
Capabilities.SIMPLEREST_CONVERSATION_ID_TEMPLATE;
|
|
@@ -403,6 +414,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
|
|
|
403
414
|
Capabilities.SIMPLEREST_REDIS_TOPIC;
|
|
404
415
|
Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
|
|
405
416
|
Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
|
|
417
|
+
Capabilities.SIMPLEREST_COOKIE_REPLICATION;
|
|
406
418
|
Capabilities.SCRIPTING_TXT_EOL;
|
|
407
419
|
Capabilities.SCRIPTING_XLSX_MODE;
|
|
408
420
|
Capabilities.SCRIPTING_XLSX_EOL_WRITE;
|
|
@@ -498,10 +510,10 @@ var Defaults$1 = {
|
|
|
498
510
|
[Capabilities.SIMPLEREST_METHOD]: 'GET',
|
|
499
511
|
[Capabilities.SIMPLEREST_IGNORE_EMPTY]: true,
|
|
500
512
|
[Capabilities.SIMPLEREST_TIMEOUT]: 10000,
|
|
501
|
-
[Capabilities.SIMPLEREST_EXTRA_OPTIONS]: {},
|
|
502
513
|
[Capabilities.SIMPLEREST_STRICT_SSL]: true,
|
|
503
514
|
[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
|
|
504
515
|
[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
|
|
516
|
+
[Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
|
|
505
517
|
[Capabilities.SCRIPTING_TXT_EOL]: '\n',
|
|
506
518
|
[Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
|
|
507
519
|
[Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
|
|
@@ -2296,7 +2308,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
|
|
|
2296
2308
|
header: {
|
|
2297
2309
|
name: caseName
|
|
2298
2310
|
},
|
|
2299
|
-
values
|
|
2311
|
+
values
|
|
2300
2312
|
};
|
|
2301
2313
|
scriptingMemories.push(scriptingMemory);
|
|
2302
2314
|
}
|
|
@@ -2946,7 +2958,7 @@ class Convo$6 {
|
|
|
2946
2958
|
},
|
|
2947
2959
|
container,
|
|
2948
2960
|
transcript,
|
|
2949
|
-
scriptingMemory
|
|
2961
|
+
scriptingMemory
|
|
2950
2962
|
});
|
|
2951
2963
|
} catch (err) {
|
|
2952
2964
|
throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
|
|
@@ -2963,7 +2975,7 @@ class Convo$6 {
|
|
|
2963
2975
|
},
|
|
2964
2976
|
container,
|
|
2965
2977
|
transcript,
|
|
2966
|
-
scriptingMemory
|
|
2978
|
+
scriptingMemory
|
|
2967
2979
|
});
|
|
2968
2980
|
} catch (err) {
|
|
2969
2981
|
assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
|
|
@@ -2989,7 +3001,7 @@ class Convo$6 {
|
|
|
2989
3001
|
},
|
|
2990
3002
|
container,
|
|
2991
3003
|
transcript,
|
|
2992
|
-
scriptingMemory
|
|
3004
|
+
scriptingMemory
|
|
2993
3005
|
});
|
|
2994
3006
|
} catch (err) {
|
|
2995
3007
|
transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
|
|
@@ -3051,7 +3063,8 @@ class Convo$6 {
|
|
|
3051
3063
|
scriptingMemory,
|
|
3052
3064
|
meMsg,
|
|
3053
3065
|
transcript,
|
|
3054
|
-
transcriptStep
|
|
3066
|
+
transcriptStep,
|
|
3067
|
+
transcriptSteps
|
|
3055
3068
|
});
|
|
3056
3069
|
await this.scriptingEvents.onMeStart({
|
|
3057
3070
|
convo: this,
|
|
@@ -3060,7 +3073,8 @@ class Convo$6 {
|
|
|
3060
3073
|
scriptingMemory,
|
|
3061
3074
|
meMsg,
|
|
3062
3075
|
transcript,
|
|
3063
|
-
transcriptStep
|
|
3076
|
+
transcriptStep,
|
|
3077
|
+
transcriptSteps
|
|
3064
3078
|
});
|
|
3065
3079
|
await this.scriptingEvents.onMePrepare({
|
|
3066
3080
|
convo: this,
|
|
@@ -3069,7 +3083,8 @@ class Convo$6 {
|
|
|
3069
3083
|
scriptingMemory,
|
|
3070
3084
|
meMsg,
|
|
3071
3085
|
transcript,
|
|
3072
|
-
transcriptStep
|
|
3086
|
+
transcriptStep,
|
|
3087
|
+
transcriptSteps
|
|
3073
3088
|
});
|
|
3074
3089
|
await this._checkBotRepliesConsumed(container);
|
|
3075
3090
|
|
|
@@ -3764,7 +3779,7 @@ const optionalJson = json => {
|
|
|
3764
3779
|
const body = isJson(json);
|
|
3765
3780
|
return body ? {
|
|
3766
3781
|
'content-type': 'application/json',
|
|
3767
|
-
body
|
|
3782
|
+
body
|
|
3768
3783
|
} : {
|
|
3769
3784
|
'content-type': 'text/plain',
|
|
3770
3785
|
body: json
|
|
@@ -4832,7 +4847,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4832
4847
|
header: {
|
|
4833
4848
|
name: caseName
|
|
4834
4849
|
},
|
|
4835
|
-
values
|
|
4850
|
+
values
|
|
4836
4851
|
});
|
|
4837
4852
|
}
|
|
4838
4853
|
} else {
|
|
@@ -4875,7 +4890,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4875
4890
|
header: {
|
|
4876
4891
|
name: caseName
|
|
4877
4892
|
},
|
|
4878
|
-
values
|
|
4893
|
+
values
|
|
4879
4894
|
});
|
|
4880
4895
|
} else {
|
|
4881
4896
|
break;
|
|
@@ -7221,7 +7236,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7221
7236
|
const node = {
|
|
7222
7237
|
sender: convoNode.sender,
|
|
7223
7238
|
key: randomatic('0', 20),
|
|
7224
|
-
hash
|
|
7239
|
+
hash,
|
|
7225
7240
|
convoNodes: convoNodeValues,
|
|
7226
7241
|
convos: [lodash.cloneDeep(convoNodeHeader)],
|
|
7227
7242
|
childNodes: []
|
|
@@ -8100,6 +8115,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8100
8115
|
|
|
8101
8116
|
this.processInbound = false;
|
|
8102
8117
|
this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
|
|
8118
|
+
this.cookies = {};
|
|
8103
8119
|
|
|
8104
8120
|
if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
|
|
8105
8121
|
const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
|
|
@@ -8384,31 +8400,82 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8384
8400
|
}
|
|
8385
8401
|
|
|
8386
8402
|
for (const jsonPathRoot of jsonPathRoots) {
|
|
8387
|
-
const
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
}
|
|
8398
|
-
|
|
8403
|
+
const _retrieveMedia = (jsonPathMediaRoot, jsonPathsMedia) => {
|
|
8404
|
+
const retrievedMedia = [];
|
|
8405
|
+
jsonPathsMedia.forEach(jsonPath => {
|
|
8406
|
+
const responseMedia = jsonpath.query(jsonPathMediaRoot, jsonPath);
|
|
8407
|
+
|
|
8408
|
+
if (responseMedia) {
|
|
8409
|
+
(lodash.isArray(responseMedia) ? lodash.flattenDeep(responseMedia) : [responseMedia]).forEach(m => retrievedMedia.push({
|
|
8410
|
+
mediaUri: m,
|
|
8411
|
+
mimeType: mimeTypes.lookup(m) || 'application/unknown'
|
|
8412
|
+
}));
|
|
8413
|
+
}
|
|
8414
|
+
});
|
|
8415
|
+
return retrievedMedia;
|
|
8416
|
+
};
|
|
8417
|
+
|
|
8418
|
+
const _retrieveButtons = (jsonPathButtonRoot, jsonPathsButtons) => {
|
|
8419
|
+
const retrievedButtons = [];
|
|
8420
|
+
jsonPathsButtons.forEach(jsonPath => {
|
|
8421
|
+
const responseButtons = jsonpath.query(jsonPathButtonRoot, jsonPath);
|
|
8422
|
+
|
|
8423
|
+
if (responseButtons) {
|
|
8424
|
+
(lodash.isArray(responseButtons) ? lodash.flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
|
|
8425
|
+
text: b
|
|
8426
|
+
}));
|
|
8427
|
+
}
|
|
8428
|
+
});
|
|
8429
|
+
return retrievedButtons;
|
|
8430
|
+
};
|
|
8431
|
+
|
|
8432
|
+
const _getCardText = responseCardText => {
|
|
8433
|
+
if (responseCardText) {
|
|
8434
|
+
const texts = lodash.isArray(responseCardText) ? lodash.flattenDeep(responseCardText) : [responseCardText];
|
|
8435
|
+
|
|
8436
|
+
if (texts.length > 1) {
|
|
8437
|
+
debug$4(`more than one text found for card: ${util.inspect(texts)}`);
|
|
8438
|
+
}
|
|
8439
|
+
|
|
8440
|
+
if (texts.length > 0) {
|
|
8441
|
+
return texts[0];
|
|
8442
|
+
}
|
|
8399
8443
|
}
|
|
8400
|
-
}
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8444
|
+
};
|
|
8445
|
+
|
|
8446
|
+
const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
|
|
8447
|
+
|
|
8448
|
+
debug$4(`found response media: ${util.inspect(media)}`);
|
|
8449
|
+
|
|
8450
|
+
const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
|
|
8451
|
+
|
|
8452
|
+
debug$4(`found response buttons: ${util.inspect(buttons)}`);
|
|
8453
|
+
const cards = [];
|
|
8454
|
+
const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
|
|
8455
|
+
jsonPathsCards.forEach(jsonPath => {
|
|
8456
|
+
const responseCards = jsonpath.query(jsonPathRoot, jsonPath);
|
|
8457
|
+
|
|
8458
|
+
if (responseCards) {
|
|
8459
|
+
(lodash.isArray(responseCards) ? lodash.flattenDeep(responseCards) : [responseCards]).forEach(c => {
|
|
8460
|
+
const card = {};
|
|
8461
|
+
const jsonPathsCardText = getAllCapValues(Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH, this.caps);
|
|
8462
|
+
jsonPathsCardText.forEach(jsonPath => {
|
|
8463
|
+
card.text = _getCardText(jsonpath.query(c, jsonPath));
|
|
8464
|
+
});
|
|
8465
|
+
const jsonPathsCardSubText = getAllCapValues(Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH, this.caps);
|
|
8466
|
+
jsonPathsCardSubText.forEach(jsonPath => {
|
|
8467
|
+
card.subtext = _getCardText(jsonpath.query(c, jsonPath));
|
|
8468
|
+
});
|
|
8469
|
+
card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
|
|
8470
|
+
card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
|
|
8471
|
+
|
|
8472
|
+
if (lodash.keys(card).length > 0) {
|
|
8473
|
+
cards.push(card);
|
|
8474
|
+
}
|
|
8475
|
+
});
|
|
8410
8476
|
}
|
|
8411
8477
|
});
|
|
8478
|
+
debug$4(`found response cards: ${util.inspect(cards)}`);
|
|
8412
8479
|
let hasMessageText = false;
|
|
8413
8480
|
const jsonPathsTexts = getAllCapValues(Capabilities.SIMPLEREST_RESPONSE_JSONPATH, this.caps);
|
|
8414
8481
|
|
|
@@ -8425,7 +8492,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8425
8492
|
sourceData: body,
|
|
8426
8493
|
messageText,
|
|
8427
8494
|
media,
|
|
8428
|
-
buttons
|
|
8495
|
+
buttons,
|
|
8496
|
+
cards
|
|
8429
8497
|
};
|
|
8430
8498
|
await executeHook(this.caps, this.responseHook, Object.assign({
|
|
8431
8499
|
botMsg,
|
|
@@ -8441,7 +8509,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8441
8509
|
messageText: '',
|
|
8442
8510
|
sourceData: body,
|
|
8443
8511
|
media,
|
|
8444
|
-
buttons
|
|
8512
|
+
buttons,
|
|
8513
|
+
cards
|
|
8445
8514
|
};
|
|
8446
8515
|
const beforeHookKeys = Object.keys(botMsg);
|
|
8447
8516
|
await executeHook(this.caps, this.responseHook, Object.assign({
|
|
@@ -8450,7 +8519,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8450
8519
|
}, this.view));
|
|
8451
8520
|
const afterHookKeys = Object.keys(botMsg);
|
|
8452
8521
|
|
|
8453
|
-
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8522
|
+
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8454
8523
|
result.push(botMsg);
|
|
8455
8524
|
}
|
|
8456
8525
|
}
|
|
@@ -8494,6 +8563,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8494
8563
|
if (body) {
|
|
8495
8564
|
debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8496
8565
|
|
|
8566
|
+
this._storeCookiesFromResponse(response);
|
|
8567
|
+
|
|
8497
8568
|
try {
|
|
8498
8569
|
body = await this._parseResponseBody(body);
|
|
8499
8570
|
} catch (err) {
|
|
@@ -8616,6 +8687,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8616
8687
|
await executeHook(this.caps, this.requestHook, Object.assign({
|
|
8617
8688
|
requestOptions
|
|
8618
8689
|
}, this.view));
|
|
8690
|
+
|
|
8691
|
+
this._addRequestCookies(requestOptions);
|
|
8692
|
+
|
|
8619
8693
|
return requestOptions;
|
|
8620
8694
|
}
|
|
8621
8695
|
|
|
@@ -8660,6 +8734,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8660
8734
|
} else {
|
|
8661
8735
|
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
|
|
8662
8736
|
|
|
8737
|
+
this._storeCookiesFromResponse(response);
|
|
8738
|
+
|
|
8663
8739
|
if (debug$4.enabled && body) {
|
|
8664
8740
|
debug$4(Utils.shortenJsonString(body));
|
|
8665
8741
|
}
|
|
@@ -8844,9 +8920,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8844
8920
|
|
|
8845
8921
|
const pollConfig = {
|
|
8846
8922
|
method: verb,
|
|
8847
|
-
uri
|
|
8923
|
+
uri,
|
|
8848
8924
|
followAllRedirects: true,
|
|
8849
|
-
timeout
|
|
8925
|
+
timeout
|
|
8850
8926
|
};
|
|
8851
8927
|
|
|
8852
8928
|
if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
|
|
@@ -8881,6 +8957,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8881
8957
|
return;
|
|
8882
8958
|
}
|
|
8883
8959
|
|
|
8960
|
+
this._addRequestCookies(pollConfig);
|
|
8961
|
+
|
|
8884
8962
|
request(pollConfig, async (err, response, body) => {
|
|
8885
8963
|
if (err) {
|
|
8886
8964
|
debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
|
|
@@ -8894,6 +8972,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8894
8972
|
} else if (body) {
|
|
8895
8973
|
debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8896
8974
|
|
|
8975
|
+
this._storeCookiesFromResponse(response);
|
|
8976
|
+
|
|
8897
8977
|
try {
|
|
8898
8978
|
body = await this._parseResponseBody(body);
|
|
8899
8979
|
} catch (err) {
|
|
@@ -8938,9 +9018,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8938
9018
|
|
|
8939
9019
|
const httpConfig = {
|
|
8940
9020
|
method: verb,
|
|
8941
|
-
uri
|
|
9021
|
+
uri,
|
|
8942
9022
|
followAllRedirects: true,
|
|
8943
|
-
timeout
|
|
9023
|
+
timeout
|
|
8944
9024
|
};
|
|
8945
9025
|
|
|
8946
9026
|
if (this.caps[`${capPrefix}_HEADERS`]) {
|
|
@@ -8968,6 +9048,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8968
9048
|
requestOptions: httpConfig
|
|
8969
9049
|
}, this.view));
|
|
8970
9050
|
|
|
9051
|
+
this._addRequestCookies(httpConfig);
|
|
9052
|
+
|
|
8971
9053
|
const retries = this._getCapValue(`${capPrefix}_RETRIES`);
|
|
8972
9054
|
|
|
8973
9055
|
debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
|
|
@@ -8987,6 +9069,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8987
9069
|
}
|
|
8988
9070
|
}
|
|
8989
9071
|
|
|
9072
|
+
_addRequestCookies(requestOptions) {
|
|
9073
|
+
if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
|
|
9074
|
+
return;
|
|
9075
|
+
}
|
|
9076
|
+
|
|
9077
|
+
const url = new URL(requestOptions.uri);
|
|
9078
|
+
|
|
9079
|
+
if (!requestOptions.headers) {
|
|
9080
|
+
requestOptions.headers = {};
|
|
9081
|
+
}
|
|
9082
|
+
|
|
9083
|
+
requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
|
|
9084
|
+
}
|
|
9085
|
+
|
|
9086
|
+
_storeCookiesFromResponse(response) {
|
|
9087
|
+
if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
|
|
9088
|
+
return;
|
|
9089
|
+
}
|
|
9090
|
+
|
|
9091
|
+
const responseCookies = response.headers['set-cookie'];
|
|
9092
|
+
|
|
9093
|
+
if (!responseCookies) {
|
|
9094
|
+
return;
|
|
9095
|
+
}
|
|
9096
|
+
|
|
9097
|
+
const host = lodash.get(response, 'request.uri.host');
|
|
9098
|
+
|
|
9099
|
+
let cookie;
|
|
9100
|
+
responseCookies.forEach(cookieString => {
|
|
9101
|
+
cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
|
|
9102
|
+
});
|
|
9103
|
+
|
|
9104
|
+
if (cookie) {
|
|
9105
|
+
this.cookies[host] = cookie;
|
|
9106
|
+
}
|
|
9107
|
+
}
|
|
9108
|
+
|
|
8990
9109
|
};
|
|
8991
9110
|
|
|
8992
9111
|
const debug$3 = debug$l('botium-connector-PluginConnectorContainer-helper');
|
|
@@ -9061,7 +9180,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
|
|
|
9061
9180
|
source: 'src/containers/plugins/index.js',
|
|
9062
9181
|
cause: {
|
|
9063
9182
|
SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
|
|
9064
|
-
mode
|
|
9183
|
+
mode,
|
|
9065
9184
|
...cause
|
|
9066
9185
|
}
|
|
9067
9186
|
});
|
|
@@ -9416,18 +9535,28 @@ var BotDriver_1 = class BotDriver {
|
|
|
9416
9535
|
|
|
9417
9536
|
Build() {
|
|
9418
9537
|
debug$1(`Build - Botium Core Version: ${version}`);
|
|
9419
|
-
debug$1(`Build - Capabilites: ${
|
|
9420
|
-
debug$1(`Build - Sources
|
|
9421
|
-
debug$1(`Build - Envs
|
|
9538
|
+
debug$1(`Build - Capabilites: ${JSON.stringify(lodash.pickBy(this.caps, (value, key) => Defaults$1.Capabilities[key] !== value), null, 2)}`);
|
|
9539
|
+
debug$1(`Build - Sources: ${JSON.stringify(lodash.pickBy(this.sources, (value, key) => Defaults$1.Sources[key] !== value), null, 2)}`);
|
|
9540
|
+
debug$1(`Build - Envs: ${JSON.stringify(lodash.pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
|
|
9422
9541
|
this.eventEmitter.emit(Events.CONTAINER_BUILDING);
|
|
9423
9542
|
return new Promise((resolve, reject) => {
|
|
9543
|
+
let tempDirectory = null;
|
|
9424
9544
|
let repo = null;
|
|
9425
9545
|
let container = null;
|
|
9426
9546
|
async.series([driverValidated => {
|
|
9427
9547
|
this._validate().then(() => driverValidated()).catch(driverValidated);
|
|
9548
|
+
}, tempDirectoryCreated => {
|
|
9549
|
+
tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
|
|
9550
|
+
|
|
9551
|
+
try {
|
|
9552
|
+
mkdirp.sync(tempDirectory);
|
|
9553
|
+
tempDirectoryCreated();
|
|
9554
|
+
} catch (err) {
|
|
9555
|
+
tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
|
|
9556
|
+
}
|
|
9428
9557
|
}, repoValidated => {
|
|
9429
9558
|
try {
|
|
9430
|
-
repo = this._getRepo();
|
|
9559
|
+
repo = this._getRepo(tempDirectory);
|
|
9431
9560
|
} catch (err) {
|
|
9432
9561
|
return repoValidated(err);
|
|
9433
9562
|
}
|
|
@@ -9437,7 +9566,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9437
9566
|
repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
|
|
9438
9567
|
}, containerValidated => {
|
|
9439
9568
|
try {
|
|
9440
|
-
container = this._getContainer(repo);
|
|
9569
|
+
container = this._getContainer(tempDirectory, repo);
|
|
9441
9570
|
} catch (err) {
|
|
9442
9571
|
return containerValidated(err);
|
|
9443
9572
|
}
|
|
@@ -9450,9 +9579,9 @@ var BotDriver_1 = class BotDriver {
|
|
|
9450
9579
|
debug$1(`BotDriver Build error: ${err}`);
|
|
9451
9580
|
this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
|
|
9452
9581
|
|
|
9453
|
-
if (
|
|
9454
|
-
rimraf(
|
|
9455
|
-
if (err) debug$1(`Cleanup temp dir ${
|
|
9582
|
+
if (tempDirectory) {
|
|
9583
|
+
rimraf(tempDirectory, err => {
|
|
9584
|
+
if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util.inspect(err)}`);
|
|
9456
9585
|
});
|
|
9457
9586
|
}
|
|
9458
9587
|
|
|
@@ -9628,14 +9757,6 @@ var BotDriver_1 = class BotDriver {
|
|
|
9628
9757
|
throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
|
|
9629
9758
|
}
|
|
9630
9759
|
|
|
9631
|
-
this.tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
|
|
9632
|
-
|
|
9633
|
-
try {
|
|
9634
|
-
mkdirp.sync(this.tempDirectory);
|
|
9635
|
-
} catch (err) {
|
|
9636
|
-
throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
|
|
9637
|
-
}
|
|
9638
|
-
|
|
9639
9760
|
resolve(this);
|
|
9640
9761
|
} catch (err) {
|
|
9641
9762
|
reject(err);
|
|
@@ -9643,29 +9764,29 @@ var BotDriver_1 = class BotDriver {
|
|
|
9643
9764
|
});
|
|
9644
9765
|
}
|
|
9645
9766
|
|
|
9646
|
-
_getRepo() {
|
|
9767
|
+
_getRepo(tempDirectory) {
|
|
9647
9768
|
if (this.caps[Capabilities.BOTIUMGRIDURL]) {
|
|
9648
9769
|
const NoRepo = NoRepo_1;
|
|
9649
|
-
return new NoRepo(
|
|
9770
|
+
return new NoRepo(tempDirectory, this.sources);
|
|
9650
9771
|
}
|
|
9651
9772
|
|
|
9652
9773
|
if (this.sources[Source.GITURL]) {
|
|
9653
9774
|
const GitRepo = GitRepo_1;
|
|
9654
|
-
return new GitRepo(
|
|
9775
|
+
return new GitRepo(tempDirectory, this.sources);
|
|
9655
9776
|
}
|
|
9656
9777
|
|
|
9657
9778
|
if (this.sources[Source.LOCALPATH]) {
|
|
9658
9779
|
const LocalRepo = LocalRepo_1;
|
|
9659
|
-
return new LocalRepo(
|
|
9780
|
+
return new LocalRepo(tempDirectory, this.sources);
|
|
9660
9781
|
}
|
|
9661
9782
|
|
|
9662
9783
|
throw new Error(`No Repo provider found for Sources ${util.inspect(this.sources)}`);
|
|
9663
9784
|
}
|
|
9664
9785
|
|
|
9665
|
-
_getContainer(repo) {
|
|
9786
|
+
_getContainer(tempDirectory, repo) {
|
|
9666
9787
|
if (this.caps[Capabilities.BOTIUMGRIDURL]) {
|
|
9667
9788
|
const GridContainer = GridContainer_1;
|
|
9668
|
-
return new GridContainer(this.eventEmitter,
|
|
9789
|
+
return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9669
9790
|
}
|
|
9670
9791
|
|
|
9671
9792
|
if (!this.caps[Capabilities.CONTAINERMODE]) {
|
|
@@ -9674,11 +9795,11 @@ var BotDriver_1 = class BotDriver {
|
|
|
9674
9795
|
|
|
9675
9796
|
if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
|
|
9676
9797
|
const InProcessContainer = InProcessContainer_1;
|
|
9677
|
-
return new InProcessContainer(this.eventEmitter,
|
|
9798
|
+
return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9678
9799
|
}
|
|
9679
9800
|
|
|
9680
9801
|
const PluginConnectorContainer = PluginConnectorContainer_1;
|
|
9681
|
-
return new PluginConnectorContainer(this.eventEmitter,
|
|
9802
|
+
return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9682
9803
|
}
|
|
9683
9804
|
|
|
9684
9805
|
};
|