botium-core 1.12.3 → 1.12.6
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 +138 -71
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +138 -71
- package/dist/botium-es.js.map +1 -1
- package/package.json +21 -21
- package/src/BotDriver.js +24 -19
- package/src/Capabilities.js +1 -0
- package/src/Defaults.js +1 -0
- package/src/containers/plugins/SimpleRestContainer.js +42 -8
- 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 +7 -7
- package/src/scripting/ScriptingProvider.js +1 -1
- package/src/scripting/helper.js +20 -13
- package/src/scripting/logichook/asserter/BaseCountAsserter.js +1 -1
- package/src/scripting/logichook/asserter/ButtonsAsserter.js +4 -2
- package/src/scripting/logichook/asserter/CardsAsserter.js +4 -2
- package/test/compiler/compilertxt.spec.js +13 -0
- package/test/compiler/convos/txt/convos_args_escape.convo.txt +2 -0
- package/test/connectors/simplerest.spec.js +49 -8
- package/test/convo/convos/continuefailing_timeout.convo.txt +16 -0
- package/test/convo/transcript.spec.js +18 -1
- package/test/logichooks/convos/WAITFORBOT_INFINITE.convo.txt +1 -1
- package/test/logichooks/hookfromsrc.spec.js +1 -1
- package/test/scripting/asserters/buttonsAsserter.spec.js +47 -0
- package/test/scripting/asserters/cardsAsserter.spec.js +39 -0
- package/test/scripting/scriptingProvider.spec.js +1 -1
- package/test/scripting/txt/decompile.spec.js +24 -0
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.6";
|
|
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.17.
|
|
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.18.
|
|
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.17.
|
|
111
|
+
"@babel/core": "^7.17.9",
|
|
112
112
|
"@babel/node": "^7.16.8",
|
|
113
113
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
114
114
|
"@babel/preset-env": "^7.16.11",
|
|
115
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.
|
|
126
|
+
mocha: "^9.2.2",
|
|
127
127
|
nock: "^13.2.4",
|
|
128
|
-
"npm-check-updates": "^12.
|
|
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",
|
|
@@ -262,6 +262,7 @@ var Capabilities = {
|
|
|
262
262
|
SIMPLEREST_REDIS_TOPIC: 'SIMPLEREST_REDIS_TOPIC',
|
|
263
263
|
SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH: 'SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH',
|
|
264
264
|
SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT: 'SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT',
|
|
265
|
+
SIMPLEREST_COOKIE_REPLICATION: 'SIMPLEREST_COOKIE_REPLICATION',
|
|
265
266
|
// Script Compiler
|
|
266
267
|
SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
|
|
267
268
|
// ROW_PER_MESSAGE or QUESTION_ANSWER
|
|
@@ -413,6 +414,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
|
|
|
413
414
|
Capabilities.SIMPLEREST_REDIS_TOPIC;
|
|
414
415
|
Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
|
|
415
416
|
Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
|
|
417
|
+
Capabilities.SIMPLEREST_COOKIE_REPLICATION;
|
|
416
418
|
Capabilities.SCRIPTING_TXT_EOL;
|
|
417
419
|
Capabilities.SCRIPTING_XLSX_MODE;
|
|
418
420
|
Capabilities.SCRIPTING_XLSX_EOL_WRITE;
|
|
@@ -511,6 +513,7 @@ var Defaults$1 = {
|
|
|
511
513
|
[Capabilities.SIMPLEREST_STRICT_SSL]: true,
|
|
512
514
|
[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
|
|
513
515
|
[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
|
|
516
|
+
[Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
|
|
514
517
|
[Capabilities.SCRIPTING_TXT_EOL]: '\n',
|
|
515
518
|
[Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
|
|
516
519
|
[Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
|
|
@@ -1817,6 +1820,14 @@ const flatString = str => {
|
|
|
1817
1820
|
return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
|
|
1818
1821
|
};
|
|
1819
1822
|
|
|
1823
|
+
const _formatAppendArgs = args => {
|
|
1824
|
+
return args ? ` ${args.map(a => lodash.isString(a) ? a.replace(/\|/g, '\\|') : `${a}`).join('|')}` : '';
|
|
1825
|
+
};
|
|
1826
|
+
|
|
1827
|
+
const _parseArgs = str => {
|
|
1828
|
+
return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1820
1831
|
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
1821
1832
|
if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
|
|
1822
1833
|
const convoStep = {
|
|
@@ -1858,7 +1869,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1858
1869
|
const name = logicLine.split(' ')[0];
|
|
1859
1870
|
|
|
1860
1871
|
if (sender !== 'me' && context.IsAsserterValid(name)) {
|
|
1861
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1872
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1862
1873
|
convoStep.asserters.push({
|
|
1863
1874
|
name,
|
|
1864
1875
|
args,
|
|
@@ -1866,14 +1877,14 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1866
1877
|
optional
|
|
1867
1878
|
});
|
|
1868
1879
|
} else if (sender === 'me' && context.IsUserInputValid(name)) {
|
|
1869
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1880
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1870
1881
|
convoStep.userInputs.push({
|
|
1871
1882
|
name,
|
|
1872
1883
|
args
|
|
1873
1884
|
});
|
|
1874
1885
|
textLinesAccepted = false;
|
|
1875
1886
|
} else if (context.IsLogicHookValid(name)) {
|
|
1876
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1887
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1877
1888
|
convoStep.logicHooks.push({
|
|
1878
1889
|
name,
|
|
1879
1890
|
args
|
|
@@ -2223,7 +2234,7 @@ const convoStepToLines$2 = step => {
|
|
|
2223
2234
|
|
|
2224
2235
|
if (step.sender === 'me') {
|
|
2225
2236
|
step.forms && step.forms.filter(form => form.value).forEach(form => {
|
|
2226
|
-
lines.push(`FORM
|
|
2237
|
+
lines.push(`FORM${_formatAppendArgs([form.name, form.value])}`);
|
|
2227
2238
|
});
|
|
2228
2239
|
|
|
2229
2240
|
if (step.buttons && step.buttons.length > 0) {
|
|
@@ -2235,18 +2246,18 @@ const convoStepToLines$2 = step => {
|
|
|
2235
2246
|
}
|
|
2236
2247
|
|
|
2237
2248
|
step.userInputs && step.userInputs.forEach(userInput => {
|
|
2238
|
-
lines.push(userInput.name + (userInput.args
|
|
2249
|
+
lines.push(userInput.name + _formatAppendArgs(userInput.args));
|
|
2239
2250
|
});
|
|
2240
2251
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2241
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2252
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2242
2253
|
});
|
|
2243
2254
|
} else {
|
|
2244
2255
|
if (step.messageText) {
|
|
2245
2256
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
|
|
2246
2257
|
}
|
|
2247
2258
|
|
|
2248
|
-
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS
|
|
2249
|
-
if (step.media && step.media.length > 0) lines.push('MEDIA
|
|
2259
|
+
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2260
|
+
if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)));
|
|
2250
2261
|
|
|
2251
2262
|
if (step.cards && step.cards.length > 0) {
|
|
2252
2263
|
step.cards.forEach(c => {
|
|
@@ -2254,17 +2265,17 @@ const convoStepToLines$2 = step => {
|
|
|
2254
2265
|
if (c.text) cardTexts = cardTexts.concat(lodash.isArray(c.text) ? c.text : [c.text]);
|
|
2255
2266
|
if (c.subtext) cardTexts = cardTexts.concat(lodash.isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2256
2267
|
if (c.content) cardTexts = cardTexts.concat(lodash.isArray(c.content) ? c.content : [c.content]);
|
|
2257
|
-
if (cardTexts.length > 0) lines.push('CARDS
|
|
2258
|
-
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS
|
|
2268
|
+
if (cardTexts.length > 0) lines.push('CARDS' + _formatAppendArgs(cardTexts.map(c => flatString(c))));
|
|
2269
|
+
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(c.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2259
2270
|
if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
|
|
2260
2271
|
});
|
|
2261
2272
|
}
|
|
2262
2273
|
|
|
2263
2274
|
step.asserters && step.asserters.forEach(asserter => {
|
|
2264
|
-
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + (asserter.args
|
|
2275
|
+
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + _formatAppendArgs(asserter.args));
|
|
2265
2276
|
});
|
|
2266
2277
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2267
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2278
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2268
2279
|
});
|
|
2269
2280
|
}
|
|
2270
2281
|
|
|
@@ -2305,7 +2316,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
|
|
|
2305
2316
|
header: {
|
|
2306
2317
|
name: caseName
|
|
2307
2318
|
},
|
|
2308
|
-
values
|
|
2319
|
+
values
|
|
2309
2320
|
};
|
|
2310
2321
|
scriptingMemories.push(scriptingMemory);
|
|
2311
2322
|
}
|
|
@@ -2955,7 +2966,7 @@ class Convo$6 {
|
|
|
2955
2966
|
},
|
|
2956
2967
|
container,
|
|
2957
2968
|
transcript,
|
|
2958
|
-
scriptingMemory
|
|
2969
|
+
scriptingMemory
|
|
2959
2970
|
});
|
|
2960
2971
|
} catch (err) {
|
|
2961
2972
|
throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
|
|
@@ -2972,7 +2983,7 @@ class Convo$6 {
|
|
|
2972
2983
|
},
|
|
2973
2984
|
container,
|
|
2974
2985
|
transcript,
|
|
2975
|
-
scriptingMemory
|
|
2986
|
+
scriptingMemory
|
|
2976
2987
|
});
|
|
2977
2988
|
} catch (err) {
|
|
2978
2989
|
assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
|
|
@@ -2998,7 +3009,7 @@ class Convo$6 {
|
|
|
2998
3009
|
},
|
|
2999
3010
|
container,
|
|
3000
3011
|
transcript,
|
|
3001
|
-
scriptingMemory
|
|
3012
|
+
scriptingMemory
|
|
3002
3013
|
});
|
|
3003
3014
|
} catch (err) {
|
|
3004
3015
|
transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
|
|
@@ -3060,7 +3071,8 @@ class Convo$6 {
|
|
|
3060
3071
|
scriptingMemory,
|
|
3061
3072
|
meMsg,
|
|
3062
3073
|
transcript,
|
|
3063
|
-
transcriptStep
|
|
3074
|
+
transcriptStep,
|
|
3075
|
+
transcriptSteps
|
|
3064
3076
|
});
|
|
3065
3077
|
await this.scriptingEvents.onMeStart({
|
|
3066
3078
|
convo: this,
|
|
@@ -3069,7 +3081,8 @@ class Convo$6 {
|
|
|
3069
3081
|
scriptingMemory,
|
|
3070
3082
|
meMsg,
|
|
3071
3083
|
transcript,
|
|
3072
|
-
transcriptStep
|
|
3084
|
+
transcriptStep,
|
|
3085
|
+
transcriptSteps
|
|
3073
3086
|
});
|
|
3074
3087
|
await this.scriptingEvents.onMePrepare({
|
|
3075
3088
|
convo: this,
|
|
@@ -3078,7 +3091,8 @@ class Convo$6 {
|
|
|
3078
3091
|
scriptingMemory,
|
|
3079
3092
|
meMsg,
|
|
3080
3093
|
transcript,
|
|
3081
|
-
transcriptStep
|
|
3094
|
+
transcriptStep,
|
|
3095
|
+
transcriptSteps
|
|
3082
3096
|
});
|
|
3083
3097
|
await this._checkBotRepliesConsumed(container);
|
|
3084
3098
|
|
|
@@ -3387,7 +3401,7 @@ class Convo$6 {
|
|
|
3387
3401
|
const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
|
|
3388
3402
|
|
|
3389
3403
|
if (transcriptStepErrs && transcriptStepErrs.length > 0) {
|
|
3390
|
-
transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
|
|
3404
|
+
transcript.err = botiumErrorFromList$1([...transcriptStepErrs.filter(err => err !== transcript.err), transcript.err].filter(e => e), {});
|
|
3391
3405
|
}
|
|
3392
3406
|
}
|
|
3393
3407
|
}
|
|
@@ -3773,7 +3787,7 @@ const optionalJson = json => {
|
|
|
3773
3787
|
const body = isJson(json);
|
|
3774
3788
|
return body ? {
|
|
3775
3789
|
'content-type': 'application/json',
|
|
3776
|
-
body
|
|
3790
|
+
body
|
|
3777
3791
|
} : {
|
|
3778
3792
|
'content-type': 'text/plain',
|
|
3779
3793
|
body: json
|
|
@@ -4841,7 +4855,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4841
4855
|
header: {
|
|
4842
4856
|
name: caseName
|
|
4843
4857
|
},
|
|
4844
|
-
values
|
|
4858
|
+
values
|
|
4845
4859
|
});
|
|
4846
4860
|
}
|
|
4847
4861
|
} else {
|
|
@@ -4884,7 +4898,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4884
4898
|
header: {
|
|
4885
4899
|
name: caseName
|
|
4886
4900
|
},
|
|
4887
|
-
values
|
|
4901
|
+
values
|
|
4888
4902
|
});
|
|
4889
4903
|
} else {
|
|
4890
4904
|
break;
|
|
@@ -7230,7 +7244,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7230
7244
|
const node = {
|
|
7231
7245
|
sender: convoNode.sender,
|
|
7232
7246
|
key: randomatic('0', 20),
|
|
7233
|
-
hash
|
|
7247
|
+
hash,
|
|
7234
7248
|
convoNodes: convoNodeValues,
|
|
7235
7249
|
convos: [lodash.cloneDeep(convoNodeHeader)],
|
|
7236
7250
|
childNodes: []
|
|
@@ -8109,6 +8123,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8109
8123
|
|
|
8110
8124
|
this.processInbound = false;
|
|
8111
8125
|
this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
|
|
8126
|
+
this.cookies = {};
|
|
8112
8127
|
|
|
8113
8128
|
if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
|
|
8114
8129
|
const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
|
|
@@ -8556,6 +8571,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8556
8571
|
if (body) {
|
|
8557
8572
|
debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8558
8573
|
|
|
8574
|
+
this._storeCookiesFromResponse(response);
|
|
8575
|
+
|
|
8559
8576
|
try {
|
|
8560
8577
|
body = await this._parseResponseBody(body);
|
|
8561
8578
|
} catch (err) {
|
|
@@ -8678,6 +8695,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8678
8695
|
await executeHook(this.caps, this.requestHook, Object.assign({
|
|
8679
8696
|
requestOptions
|
|
8680
8697
|
}, this.view));
|
|
8698
|
+
|
|
8699
|
+
this._addRequestCookies(requestOptions);
|
|
8700
|
+
|
|
8681
8701
|
return requestOptions;
|
|
8682
8702
|
}
|
|
8683
8703
|
|
|
@@ -8722,6 +8742,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8722
8742
|
} else {
|
|
8723
8743
|
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
|
|
8724
8744
|
|
|
8745
|
+
this._storeCookiesFromResponse(response);
|
|
8746
|
+
|
|
8725
8747
|
if (debug$4.enabled && body) {
|
|
8726
8748
|
debug$4(Utils.shortenJsonString(body));
|
|
8727
8749
|
}
|
|
@@ -8906,9 +8928,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8906
8928
|
|
|
8907
8929
|
const pollConfig = {
|
|
8908
8930
|
method: verb,
|
|
8909
|
-
uri
|
|
8931
|
+
uri,
|
|
8910
8932
|
followAllRedirects: true,
|
|
8911
|
-
timeout
|
|
8933
|
+
timeout
|
|
8912
8934
|
};
|
|
8913
8935
|
|
|
8914
8936
|
if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
|
|
@@ -8943,6 +8965,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8943
8965
|
return;
|
|
8944
8966
|
}
|
|
8945
8967
|
|
|
8968
|
+
this._addRequestCookies(pollConfig);
|
|
8969
|
+
|
|
8946
8970
|
request(pollConfig, async (err, response, body) => {
|
|
8947
8971
|
if (err) {
|
|
8948
8972
|
debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
|
|
@@ -8956,6 +8980,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8956
8980
|
} else if (body) {
|
|
8957
8981
|
debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8958
8982
|
|
|
8983
|
+
this._storeCookiesFromResponse(response);
|
|
8984
|
+
|
|
8959
8985
|
try {
|
|
8960
8986
|
body = await this._parseResponseBody(body);
|
|
8961
8987
|
} catch (err) {
|
|
@@ -9000,9 +9026,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
9000
9026
|
|
|
9001
9027
|
const httpConfig = {
|
|
9002
9028
|
method: verb,
|
|
9003
|
-
uri
|
|
9029
|
+
uri,
|
|
9004
9030
|
followAllRedirects: true,
|
|
9005
|
-
timeout
|
|
9031
|
+
timeout
|
|
9006
9032
|
};
|
|
9007
9033
|
|
|
9008
9034
|
if (this.caps[`${capPrefix}_HEADERS`]) {
|
|
@@ -9030,6 +9056,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
9030
9056
|
requestOptions: httpConfig
|
|
9031
9057
|
}, this.view));
|
|
9032
9058
|
|
|
9059
|
+
this._addRequestCookies(httpConfig);
|
|
9060
|
+
|
|
9033
9061
|
const retries = this._getCapValue(`${capPrefix}_RETRIES`);
|
|
9034
9062
|
|
|
9035
9063
|
debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
|
|
@@ -9049,6 +9077,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
9049
9077
|
}
|
|
9050
9078
|
}
|
|
9051
9079
|
|
|
9080
|
+
_addRequestCookies(requestOptions) {
|
|
9081
|
+
if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
|
|
9082
|
+
return;
|
|
9083
|
+
}
|
|
9084
|
+
|
|
9085
|
+
const url = new URL(requestOptions.uri);
|
|
9086
|
+
|
|
9087
|
+
if (!requestOptions.headers) {
|
|
9088
|
+
requestOptions.headers = {};
|
|
9089
|
+
}
|
|
9090
|
+
|
|
9091
|
+
requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
|
|
9092
|
+
}
|
|
9093
|
+
|
|
9094
|
+
_storeCookiesFromResponse(response) {
|
|
9095
|
+
if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
|
|
9096
|
+
return;
|
|
9097
|
+
}
|
|
9098
|
+
|
|
9099
|
+
const responseCookies = response.headers['set-cookie'];
|
|
9100
|
+
|
|
9101
|
+
if (!responseCookies) {
|
|
9102
|
+
return;
|
|
9103
|
+
}
|
|
9104
|
+
|
|
9105
|
+
const host = lodash.get(response, 'request.uri.host');
|
|
9106
|
+
|
|
9107
|
+
let cookie;
|
|
9108
|
+
responseCookies.forEach(cookieString => {
|
|
9109
|
+
cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
|
|
9110
|
+
});
|
|
9111
|
+
|
|
9112
|
+
if (cookie) {
|
|
9113
|
+
this.cookies[host] = cookie;
|
|
9114
|
+
}
|
|
9115
|
+
}
|
|
9116
|
+
|
|
9052
9117
|
};
|
|
9053
9118
|
|
|
9054
9119
|
const debug$3 = debug$l('botium-connector-PluginConnectorContainer-helper');
|
|
@@ -9123,7 +9188,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
|
|
|
9123
9188
|
source: 'src/containers/plugins/index.js',
|
|
9124
9189
|
cause: {
|
|
9125
9190
|
SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
|
|
9126
|
-
mode
|
|
9191
|
+
mode,
|
|
9127
9192
|
...cause
|
|
9128
9193
|
}
|
|
9129
9194
|
});
|
|
@@ -9483,13 +9548,23 @@ var BotDriver_1 = class BotDriver {
|
|
|
9483
9548
|
debug$1(`Build - Envs: ${JSON.stringify(lodash.pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
|
|
9484
9549
|
this.eventEmitter.emit(Events.CONTAINER_BUILDING);
|
|
9485
9550
|
return new Promise((resolve, reject) => {
|
|
9551
|
+
let tempDirectory = null;
|
|
9486
9552
|
let repo = null;
|
|
9487
9553
|
let container = null;
|
|
9488
9554
|
async.series([driverValidated => {
|
|
9489
9555
|
this._validate().then(() => driverValidated()).catch(driverValidated);
|
|
9556
|
+
}, tempDirectoryCreated => {
|
|
9557
|
+
tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
|
|
9558
|
+
|
|
9559
|
+
try {
|
|
9560
|
+
mkdirp.sync(tempDirectory);
|
|
9561
|
+
tempDirectoryCreated();
|
|
9562
|
+
} catch (err) {
|
|
9563
|
+
tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
|
|
9564
|
+
}
|
|
9490
9565
|
}, repoValidated => {
|
|
9491
9566
|
try {
|
|
9492
|
-
repo = this._getRepo();
|
|
9567
|
+
repo = this._getRepo(tempDirectory);
|
|
9493
9568
|
} catch (err) {
|
|
9494
9569
|
return repoValidated(err);
|
|
9495
9570
|
}
|
|
@@ -9499,7 +9574,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9499
9574
|
repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
|
|
9500
9575
|
}, containerValidated => {
|
|
9501
9576
|
try {
|
|
9502
|
-
container = this._getContainer(repo);
|
|
9577
|
+
container = this._getContainer(tempDirectory, repo);
|
|
9503
9578
|
} catch (err) {
|
|
9504
9579
|
return containerValidated(err);
|
|
9505
9580
|
}
|
|
@@ -9512,9 +9587,9 @@ var BotDriver_1 = class BotDriver {
|
|
|
9512
9587
|
debug$1(`BotDriver Build error: ${err}`);
|
|
9513
9588
|
this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
|
|
9514
9589
|
|
|
9515
|
-
if (
|
|
9516
|
-
rimraf(
|
|
9517
|
-
if (err) debug$1(`Cleanup temp dir ${
|
|
9590
|
+
if (tempDirectory) {
|
|
9591
|
+
rimraf(tempDirectory, err => {
|
|
9592
|
+
if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util.inspect(err)}`);
|
|
9518
9593
|
});
|
|
9519
9594
|
}
|
|
9520
9595
|
|
|
@@ -9690,14 +9765,6 @@ var BotDriver_1 = class BotDriver {
|
|
|
9690
9765
|
throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
|
|
9691
9766
|
}
|
|
9692
9767
|
|
|
9693
|
-
this.tempDirectory = path.resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename(`${this.caps[Capabilities.PROJECTNAME]} ${moment().format('YYYYMMDD HHmmss')} ${randomatic('Aa0', 5)}`));
|
|
9694
|
-
|
|
9695
|
-
try {
|
|
9696
|
-
mkdirp.sync(this.tempDirectory);
|
|
9697
|
-
} catch (err) {
|
|
9698
|
-
throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
|
|
9699
|
-
}
|
|
9700
|
-
|
|
9701
9768
|
resolve(this);
|
|
9702
9769
|
} catch (err) {
|
|
9703
9770
|
reject(err);
|
|
@@ -9705,29 +9772,29 @@ var BotDriver_1 = class BotDriver {
|
|
|
9705
9772
|
});
|
|
9706
9773
|
}
|
|
9707
9774
|
|
|
9708
|
-
_getRepo() {
|
|
9775
|
+
_getRepo(tempDirectory) {
|
|
9709
9776
|
if (this.caps[Capabilities.BOTIUMGRIDURL]) {
|
|
9710
9777
|
const NoRepo = NoRepo_1;
|
|
9711
|
-
return new NoRepo(
|
|
9778
|
+
return new NoRepo(tempDirectory, this.sources);
|
|
9712
9779
|
}
|
|
9713
9780
|
|
|
9714
9781
|
if (this.sources[Source.GITURL]) {
|
|
9715
9782
|
const GitRepo = GitRepo_1;
|
|
9716
|
-
return new GitRepo(
|
|
9783
|
+
return new GitRepo(tempDirectory, this.sources);
|
|
9717
9784
|
}
|
|
9718
9785
|
|
|
9719
9786
|
if (this.sources[Source.LOCALPATH]) {
|
|
9720
9787
|
const LocalRepo = LocalRepo_1;
|
|
9721
|
-
return new LocalRepo(
|
|
9788
|
+
return new LocalRepo(tempDirectory, this.sources);
|
|
9722
9789
|
}
|
|
9723
9790
|
|
|
9724
9791
|
throw new Error(`No Repo provider found for Sources ${util.inspect(this.sources)}`);
|
|
9725
9792
|
}
|
|
9726
9793
|
|
|
9727
|
-
_getContainer(repo) {
|
|
9794
|
+
_getContainer(tempDirectory, repo) {
|
|
9728
9795
|
if (this.caps[Capabilities.BOTIUMGRIDURL]) {
|
|
9729
9796
|
const GridContainer = GridContainer_1;
|
|
9730
|
-
return new GridContainer(this.eventEmitter,
|
|
9797
|
+
return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9731
9798
|
}
|
|
9732
9799
|
|
|
9733
9800
|
if (!this.caps[Capabilities.CONTAINERMODE]) {
|
|
@@ -9736,11 +9803,11 @@ var BotDriver_1 = class BotDriver {
|
|
|
9736
9803
|
|
|
9737
9804
|
if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
|
|
9738
9805
|
const InProcessContainer = InProcessContainer_1;
|
|
9739
|
-
return new InProcessContainer(this.eventEmitter,
|
|
9806
|
+
return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9740
9807
|
}
|
|
9741
9808
|
|
|
9742
9809
|
const PluginConnectorContainer = PluginConnectorContainer_1;
|
|
9743
|
-
return new PluginConnectorContainer(this.eventEmitter,
|
|
9810
|
+
return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9744
9811
|
}
|
|
9745
9812
|
|
|
9746
9813
|
};
|