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-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.6";
|
|
83
83
|
var description = "The Selenium for Chatbots";
|
|
84
84
|
var main = "index.js";
|
|
85
85
|
var module$1 = "dist/botium-es.js";
|
|
@@ -111,25 +111,25 @@ var bugs = {
|
|
|
111
111
|
};
|
|
112
112
|
var homepage = "https://www.botium.ai";
|
|
113
113
|
var dependencies = {
|
|
114
|
-
"@babel/runtime": "^7.17.
|
|
114
|
+
"@babel/runtime": "^7.17.9",
|
|
115
115
|
async: "^3.2.3",
|
|
116
|
-
"body-parser": "^1.
|
|
117
|
-
boolean: "^3.
|
|
116
|
+
"body-parser": "^1.20.0",
|
|
117
|
+
boolean: "^3.2.0",
|
|
118
118
|
bottleneck: "^2.19.5",
|
|
119
119
|
"csv-parse": "^5.0.4",
|
|
120
|
-
debug: "^4.3.
|
|
120
|
+
debug: "^4.3.4",
|
|
121
121
|
esprima: "^4.0.1",
|
|
122
|
-
express: "^4.17.
|
|
122
|
+
express: "^4.17.3",
|
|
123
123
|
globby: "11.0.4",
|
|
124
|
-
ioredis: "^
|
|
124
|
+
ioredis: "^5.0.4",
|
|
125
125
|
"is-class": "^0.0.9",
|
|
126
126
|
"is-json": "^2.0.1",
|
|
127
127
|
jsonpath: "^1.1.1",
|
|
128
128
|
lodash: "^4.17.21",
|
|
129
129
|
"markdown-it": "^12.3.2",
|
|
130
|
-
"mime-types": "^2.1.
|
|
130
|
+
"mime-types": "^2.1.35",
|
|
131
131
|
mkdirp: "^1.0.4",
|
|
132
|
-
moment: "^2.29.
|
|
132
|
+
moment: "^2.29.3",
|
|
133
133
|
mustache: "^4.2.0",
|
|
134
134
|
"promise-retry": "^2.0.1",
|
|
135
135
|
"promise.allsettled": "^1.0.5",
|
|
@@ -141,36 +141,36 @@ var dependencies = {
|
|
|
141
141
|
"socket.io": "^4.4.1",
|
|
142
142
|
"socket.io-client": "^4.4.1",
|
|
143
143
|
"socketio-auth": "^0.1.1",
|
|
144
|
-
"swagger-jsdoc": "^6.1
|
|
144
|
+
"swagger-jsdoc": "^6.2.1",
|
|
145
145
|
"swagger-ui-express": "^4.3.0",
|
|
146
146
|
uuid: "^8.3.2",
|
|
147
|
-
vm2: "^3.9.
|
|
147
|
+
vm2: "^3.9.9",
|
|
148
148
|
"write-yaml": "^1.0.0",
|
|
149
|
-
xlsx: "^0.18.
|
|
149
|
+
xlsx: "^0.18.5",
|
|
150
150
|
xregexp: "^5.1.0",
|
|
151
|
-
yaml: "^
|
|
151
|
+
yaml: "^2.0.1"
|
|
152
152
|
};
|
|
153
153
|
var devDependencies = {
|
|
154
|
-
"@babel/core": "^7.17.
|
|
154
|
+
"@babel/core": "^7.17.9",
|
|
155
155
|
"@babel/node": "^7.16.8",
|
|
156
156
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
157
157
|
"@babel/preset-env": "^7.16.11",
|
|
158
158
|
chai: "^4.3.6",
|
|
159
159
|
"chai-as-promised": "^7.1.1",
|
|
160
160
|
"cross-env": "^7.0.3",
|
|
161
|
-
eslint: "^8.
|
|
162
|
-
"eslint-config-standard": "^
|
|
163
|
-
"eslint-plugin-import": "^2.
|
|
164
|
-
"eslint-plugin-
|
|
161
|
+
eslint: "^8.13.0",
|
|
162
|
+
"eslint-config-standard": "^17.0.0",
|
|
163
|
+
"eslint-plugin-import": "^2.26.0",
|
|
164
|
+
"eslint-plugin-n": "^15.1.0",
|
|
165
165
|
"eslint-plugin-promise": "^6.0.0",
|
|
166
166
|
"eslint-plugin-standard": "^4.1.0",
|
|
167
167
|
"license-checker": "^25.0.1",
|
|
168
168
|
"license-compatibility-checker": "^0.3.5",
|
|
169
|
-
mocha: "^9.2.
|
|
169
|
+
mocha: "^9.2.2",
|
|
170
170
|
nock: "^13.2.4",
|
|
171
|
-
"npm-check-updates": "^12.
|
|
171
|
+
"npm-check-updates": "^12.5.9",
|
|
172
172
|
nyc: "^15.1.0",
|
|
173
|
-
rollup: "^2.
|
|
173
|
+
rollup: "^2.70.2",
|
|
174
174
|
"rollup-plugin-babel": "^4.4.0",
|
|
175
175
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
176
176
|
"rollup-plugin-json": "^4.0.0",
|
|
@@ -305,6 +305,7 @@ var Capabilities = {
|
|
|
305
305
|
SIMPLEREST_REDIS_TOPIC: 'SIMPLEREST_REDIS_TOPIC',
|
|
306
306
|
SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH: 'SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH',
|
|
307
307
|
SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT: 'SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT',
|
|
308
|
+
SIMPLEREST_COOKIE_REPLICATION: 'SIMPLEREST_COOKIE_REPLICATION',
|
|
308
309
|
// Script Compiler
|
|
309
310
|
SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
|
|
310
311
|
// ROW_PER_MESSAGE or QUESTION_ANSWER
|
|
@@ -456,6 +457,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
|
|
|
456
457
|
Capabilities.SIMPLEREST_REDIS_TOPIC;
|
|
457
458
|
Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
|
|
458
459
|
Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
|
|
460
|
+
Capabilities.SIMPLEREST_COOKIE_REPLICATION;
|
|
459
461
|
Capabilities.SCRIPTING_TXT_EOL;
|
|
460
462
|
Capabilities.SCRIPTING_XLSX_MODE;
|
|
461
463
|
Capabilities.SCRIPTING_XLSX_EOL_WRITE;
|
|
@@ -554,6 +556,7 @@ var Defaults$1 = {
|
|
|
554
556
|
[Capabilities.SIMPLEREST_STRICT_SSL]: true,
|
|
555
557
|
[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
|
|
556
558
|
[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
|
|
559
|
+
[Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
|
|
557
560
|
[Capabilities.SCRIPTING_TXT_EOL]: '\n',
|
|
558
561
|
[Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
|
|
559
562
|
[Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
|
|
@@ -1860,6 +1863,14 @@ const flatString = str => {
|
|
|
1860
1863
|
return str ? str.split('\n').map(s => s.trim()).join(' ') : '';
|
|
1861
1864
|
};
|
|
1862
1865
|
|
|
1866
|
+
const _formatAppendArgs = args => {
|
|
1867
|
+
return args ? ` ${args.map(a => lodash__default["default"].isString(a) ? a.replace(/\|/g, '\\|') : `${a}`).join('|')}` : '';
|
|
1868
|
+
};
|
|
1869
|
+
|
|
1870
|
+
const _parseArgs = str => {
|
|
1871
|
+
return str && str.length > 0 && str.replace(/\\\|/g, '###ESCAPESPLIT###').split('|').map(s => s.replace(/###ESCAPESPLIT###/g, '|').trim()) || [];
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1863
1874
|
const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false) => {
|
|
1864
1875
|
if (!validateSender$1(sender)) throw new Error(`Failed to parse conversation. Section "${sender}" unknown.`);
|
|
1865
1876
|
const convoStep = {
|
|
@@ -1901,7 +1912,7 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1901
1912
|
const name = logicLine.split(' ')[0];
|
|
1902
1913
|
|
|
1903
1914
|
if (sender !== 'me' && context.IsAsserterValid(name)) {
|
|
1904
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1915
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1905
1916
|
convoStep.asserters.push({
|
|
1906
1917
|
name,
|
|
1907
1918
|
args,
|
|
@@ -1909,14 +1920,14 @@ const linesToConvoStep$5 = (lines, sender, context, eol, singleLineMode = false)
|
|
|
1909
1920
|
optional
|
|
1910
1921
|
});
|
|
1911
1922
|
} else if (sender === 'me' && context.IsUserInputValid(name)) {
|
|
1912
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1923
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1913
1924
|
convoStep.userInputs.push({
|
|
1914
1925
|
name,
|
|
1915
1926
|
args
|
|
1916
1927
|
});
|
|
1917
1928
|
textLinesAccepted = false;
|
|
1918
1929
|
} else if (context.IsLogicHookValid(name)) {
|
|
1919
|
-
const args = logicLine.length > name.length ? logicLine.substr(name.length + 1)
|
|
1930
|
+
const args = logicLine.length > name.length ? _parseArgs(logicLine.substr(name.length + 1)) : [];
|
|
1920
1931
|
convoStep.logicHooks.push({
|
|
1921
1932
|
name,
|
|
1922
1933
|
args
|
|
@@ -2266,7 +2277,7 @@ const convoStepToLines$2 = step => {
|
|
|
2266
2277
|
|
|
2267
2278
|
if (step.sender === 'me') {
|
|
2268
2279
|
step.forms && step.forms.filter(form => form.value).forEach(form => {
|
|
2269
|
-
lines.push(`FORM
|
|
2280
|
+
lines.push(`FORM${_formatAppendArgs([form.name, form.value])}`);
|
|
2270
2281
|
});
|
|
2271
2282
|
|
|
2272
2283
|
if (step.buttons && step.buttons.length > 0) {
|
|
@@ -2278,18 +2289,18 @@ const convoStepToLines$2 = step => {
|
|
|
2278
2289
|
}
|
|
2279
2290
|
|
|
2280
2291
|
step.userInputs && step.userInputs.forEach(userInput => {
|
|
2281
|
-
lines.push(userInput.name + (userInput.args
|
|
2292
|
+
lines.push(userInput.name + _formatAppendArgs(userInput.args));
|
|
2282
2293
|
});
|
|
2283
2294
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2284
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2295
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2285
2296
|
});
|
|
2286
2297
|
} else {
|
|
2287
2298
|
if (step.messageText) {
|
|
2288
2299
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText);
|
|
2289
2300
|
}
|
|
2290
2301
|
|
|
2291
|
-
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS
|
|
2292
|
-
if (step.media && step.media.length > 0) lines.push('MEDIA
|
|
2302
|
+
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2303
|
+
if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)));
|
|
2293
2304
|
|
|
2294
2305
|
if (step.cards && step.cards.length > 0) {
|
|
2295
2306
|
step.cards.forEach(c => {
|
|
@@ -2297,17 +2308,17 @@ const convoStepToLines$2 = step => {
|
|
|
2297
2308
|
if (c.text) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.text) ? c.text : [c.text]);
|
|
2298
2309
|
if (c.subtext) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.subtext) ? c.subtext : [c.subtext]);
|
|
2299
2310
|
if (c.content) cardTexts = cardTexts.concat(lodash__default["default"].isArray(c.content) ? c.content : [c.content]);
|
|
2300
|
-
if (cardTexts.length > 0) lines.push('CARDS
|
|
2301
|
-
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS
|
|
2311
|
+
if (cardTexts.length > 0) lines.push('CARDS' + _formatAppendArgs(cardTexts.map(c => flatString(c))));
|
|
2312
|
+
if (c.buttons && c.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(c.buttons.filter(b => b.text).map(b => flatString(b.text))));
|
|
2302
2313
|
if (c.image && !c.image.buffer && c.image.mediaUri) lines.push('MEDIA ' + c.image.mediaUri);
|
|
2303
2314
|
});
|
|
2304
2315
|
}
|
|
2305
2316
|
|
|
2306
2317
|
step.asserters && step.asserters.forEach(asserter => {
|
|
2307
|
-
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + (asserter.args
|
|
2318
|
+
lines.push((asserter.optional ? '?' : '') + (asserter.not ? '!' : '') + asserter.name + _formatAppendArgs(asserter.args));
|
|
2308
2319
|
});
|
|
2309
2320
|
step.logicHooks && step.logicHooks.forEach(logicHook => {
|
|
2310
|
-
lines.push(logicHook.name + (logicHook.args
|
|
2321
|
+
lines.push(logicHook.name + _formatAppendArgs(logicHook.args));
|
|
2311
2322
|
});
|
|
2312
2323
|
}
|
|
2313
2324
|
|
|
@@ -2348,7 +2359,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
|
|
|
2348
2359
|
header: {
|
|
2349
2360
|
name: caseName
|
|
2350
2361
|
},
|
|
2351
|
-
values
|
|
2362
|
+
values
|
|
2352
2363
|
};
|
|
2353
2364
|
scriptingMemories.push(scriptingMemory);
|
|
2354
2365
|
}
|
|
@@ -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
|
throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
|
|
@@ -3015,7 +3026,7 @@ class Convo$6 {
|
|
|
3015
3026
|
},
|
|
3016
3027
|
container,
|
|
3017
3028
|
transcript,
|
|
3018
|
-
scriptingMemory
|
|
3029
|
+
scriptingMemory
|
|
3019
3030
|
});
|
|
3020
3031
|
} catch (err) {
|
|
3021
3032
|
assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
|
|
@@ -3041,7 +3052,7 @@ class Convo$6 {
|
|
|
3041
3052
|
},
|
|
3042
3053
|
container,
|
|
3043
3054
|
transcript,
|
|
3044
|
-
scriptingMemory
|
|
3055
|
+
scriptingMemory
|
|
3045
3056
|
});
|
|
3046
3057
|
} catch (err) {
|
|
3047
3058
|
transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
|
|
@@ -3103,7 +3114,8 @@ class Convo$6 {
|
|
|
3103
3114
|
scriptingMemory,
|
|
3104
3115
|
meMsg,
|
|
3105
3116
|
transcript,
|
|
3106
|
-
transcriptStep
|
|
3117
|
+
transcriptStep,
|
|
3118
|
+
transcriptSteps
|
|
3107
3119
|
});
|
|
3108
3120
|
await this.scriptingEvents.onMeStart({
|
|
3109
3121
|
convo: this,
|
|
@@ -3112,7 +3124,8 @@ class Convo$6 {
|
|
|
3112
3124
|
scriptingMemory,
|
|
3113
3125
|
meMsg,
|
|
3114
3126
|
transcript,
|
|
3115
|
-
transcriptStep
|
|
3127
|
+
transcriptStep,
|
|
3128
|
+
transcriptSteps
|
|
3116
3129
|
});
|
|
3117
3130
|
await this.scriptingEvents.onMePrepare({
|
|
3118
3131
|
convo: this,
|
|
@@ -3121,7 +3134,8 @@ class Convo$6 {
|
|
|
3121
3134
|
scriptingMemory,
|
|
3122
3135
|
meMsg,
|
|
3123
3136
|
transcript,
|
|
3124
|
-
transcriptStep
|
|
3137
|
+
transcriptStep,
|
|
3138
|
+
transcriptSteps
|
|
3125
3139
|
});
|
|
3126
3140
|
await this._checkBotRepliesConsumed(container);
|
|
3127
3141
|
|
|
@@ -3430,7 +3444,7 @@ class Convo$6 {
|
|
|
3430
3444
|
const transcriptStepErrs = transcript.steps.filter(s => s.err).map(s => s.err);
|
|
3431
3445
|
|
|
3432
3446
|
if (transcriptStepErrs && transcriptStepErrs.length > 0) {
|
|
3433
|
-
transcript.err = botiumErrorFromList$1([transcriptStepErrs, transcript.err].filter(e => e), {});
|
|
3447
|
+
transcript.err = botiumErrorFromList$1([...transcriptStepErrs.filter(err => err !== transcript.err), transcript.err].filter(e => e), {});
|
|
3434
3448
|
}
|
|
3435
3449
|
}
|
|
3436
3450
|
}
|
|
@@ -3816,7 +3830,7 @@ const optionalJson = json => {
|
|
|
3816
3830
|
const body = isJson(json);
|
|
3817
3831
|
return body ? {
|
|
3818
3832
|
'content-type': 'application/json',
|
|
3819
|
-
body
|
|
3833
|
+
body
|
|
3820
3834
|
} : {
|
|
3821
3835
|
'content-type': 'text/plain',
|
|
3822
3836
|
body: json
|
|
@@ -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
|
}
|
|
4890
4904
|
} else {
|
|
@@ -4927,7 +4941,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
|
|
|
4927
4941
|
header: {
|
|
4928
4942
|
name: caseName
|
|
4929
4943
|
},
|
|
4930
|
-
values
|
|
4944
|
+
values
|
|
4931
4945
|
});
|
|
4932
4946
|
} else {
|
|
4933
4947
|
break;
|
|
@@ -7273,7 +7287,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
|
|
|
7273
7287
|
const node = {
|
|
7274
7288
|
sender: convoNode.sender,
|
|
7275
7289
|
key: randomatic__default["default"]('0', 20),
|
|
7276
|
-
hash
|
|
7290
|
+
hash,
|
|
7277
7291
|
convoNodes: convoNodeValues,
|
|
7278
7292
|
convos: [lodash__default["default"].cloneDeep(convoNodeHeader)],
|
|
7279
7293
|
childNodes: []
|
|
@@ -8152,6 +8166,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8152
8166
|
|
|
8153
8167
|
this.processInbound = false;
|
|
8154
8168
|
this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
|
|
8169
|
+
this.cookies = {};
|
|
8155
8170
|
|
|
8156
8171
|
if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
|
|
8157
8172
|
const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
|
|
@@ -8599,6 +8614,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8599
8614
|
if (body) {
|
|
8600
8615
|
debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
8601
8616
|
|
|
8617
|
+
this._storeCookiesFromResponse(response);
|
|
8618
|
+
|
|
8602
8619
|
try {
|
|
8603
8620
|
body = await this._parseResponseBody(body);
|
|
8604
8621
|
} catch (err) {
|
|
@@ -8721,6 +8738,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8721
8738
|
await executeHook(this.caps, this.requestHook, Object.assign({
|
|
8722
8739
|
requestOptions
|
|
8723
8740
|
}, this.view));
|
|
8741
|
+
|
|
8742
|
+
this._addRequestCookies(requestOptions);
|
|
8743
|
+
|
|
8724
8744
|
return requestOptions;
|
|
8725
8745
|
}
|
|
8726
8746
|
|
|
@@ -8765,6 +8785,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8765
8785
|
} else {
|
|
8766
8786
|
debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
|
|
8767
8787
|
|
|
8788
|
+
this._storeCookiesFromResponse(response);
|
|
8789
|
+
|
|
8768
8790
|
if (debug$4.enabled && body) {
|
|
8769
8791
|
debug$4(Utils.shortenJsonString(body));
|
|
8770
8792
|
}
|
|
@@ -8949,9 +8971,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8949
8971
|
|
|
8950
8972
|
const pollConfig = {
|
|
8951
8973
|
method: verb,
|
|
8952
|
-
uri
|
|
8974
|
+
uri,
|
|
8953
8975
|
followAllRedirects: true,
|
|
8954
|
-
timeout
|
|
8976
|
+
timeout
|
|
8955
8977
|
};
|
|
8956
8978
|
|
|
8957
8979
|
if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
|
|
@@ -8986,6 +9008,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8986
9008
|
return;
|
|
8987
9009
|
}
|
|
8988
9010
|
|
|
9011
|
+
this._addRequestCookies(pollConfig);
|
|
9012
|
+
|
|
8989
9013
|
request__default["default"](pollConfig, async (err, response, body) => {
|
|
8990
9014
|
if (err) {
|
|
8991
9015
|
debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
|
|
@@ -8999,6 +9023,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8999
9023
|
} else if (body) {
|
|
9000
9024
|
debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
|
|
9001
9025
|
|
|
9026
|
+
this._storeCookiesFromResponse(response);
|
|
9027
|
+
|
|
9002
9028
|
try {
|
|
9003
9029
|
body = await this._parseResponseBody(body);
|
|
9004
9030
|
} catch (err) {
|
|
@@ -9043,9 +9069,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
9043
9069
|
|
|
9044
9070
|
const httpConfig = {
|
|
9045
9071
|
method: verb,
|
|
9046
|
-
uri
|
|
9072
|
+
uri,
|
|
9047
9073
|
followAllRedirects: true,
|
|
9048
|
-
timeout
|
|
9074
|
+
timeout
|
|
9049
9075
|
};
|
|
9050
9076
|
|
|
9051
9077
|
if (this.caps[`${capPrefix}_HEADERS`]) {
|
|
@@ -9073,6 +9099,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
9073
9099
|
requestOptions: httpConfig
|
|
9074
9100
|
}, this.view));
|
|
9075
9101
|
|
|
9102
|
+
this._addRequestCookies(httpConfig);
|
|
9103
|
+
|
|
9076
9104
|
const retries = this._getCapValue(`${capPrefix}_RETRIES`);
|
|
9077
9105
|
|
|
9078
9106
|
debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
|
|
@@ -9092,6 +9120,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
9092
9120
|
}
|
|
9093
9121
|
}
|
|
9094
9122
|
|
|
9123
|
+
_addRequestCookies(requestOptions) {
|
|
9124
|
+
if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
|
|
9125
|
+
return;
|
|
9126
|
+
}
|
|
9127
|
+
|
|
9128
|
+
const url = new URL(requestOptions.uri);
|
|
9129
|
+
|
|
9130
|
+
if (!requestOptions.headers) {
|
|
9131
|
+
requestOptions.headers = {};
|
|
9132
|
+
}
|
|
9133
|
+
|
|
9134
|
+
requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
|
|
9135
|
+
}
|
|
9136
|
+
|
|
9137
|
+
_storeCookiesFromResponse(response) {
|
|
9138
|
+
if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
|
|
9139
|
+
return;
|
|
9140
|
+
}
|
|
9141
|
+
|
|
9142
|
+
const responseCookies = response.headers['set-cookie'];
|
|
9143
|
+
|
|
9144
|
+
if (!responseCookies) {
|
|
9145
|
+
return;
|
|
9146
|
+
}
|
|
9147
|
+
|
|
9148
|
+
const host = lodash__default["default"].get(response, 'request.uri.host');
|
|
9149
|
+
|
|
9150
|
+
let cookie;
|
|
9151
|
+
responseCookies.forEach(cookieString => {
|
|
9152
|
+
cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
|
|
9153
|
+
});
|
|
9154
|
+
|
|
9155
|
+
if (cookie) {
|
|
9156
|
+
this.cookies[host] = cookie;
|
|
9157
|
+
}
|
|
9158
|
+
}
|
|
9159
|
+
|
|
9095
9160
|
};
|
|
9096
9161
|
|
|
9097
9162
|
const debug$3 = debug__default["default"]('botium-connector-PluginConnectorContainer-helper');
|
|
@@ -9166,7 +9231,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
|
|
|
9166
9231
|
source: 'src/containers/plugins/index.js',
|
|
9167
9232
|
cause: {
|
|
9168
9233
|
SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
|
|
9169
|
-
mode
|
|
9234
|
+
mode,
|
|
9170
9235
|
...cause
|
|
9171
9236
|
}
|
|
9172
9237
|
});
|
|
@@ -9526,13 +9591,23 @@ var BotDriver_1 = class BotDriver {
|
|
|
9526
9591
|
debug$1(`Build - Envs: ${JSON.stringify(lodash__default["default"].pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
|
|
9527
9592
|
this.eventEmitter.emit(Events.CONTAINER_BUILDING);
|
|
9528
9593
|
return new Promise((resolve, reject) => {
|
|
9594
|
+
let tempDirectory = null;
|
|
9529
9595
|
let repo = null;
|
|
9530
9596
|
let container = null;
|
|
9531
9597
|
async__default["default"].series([driverValidated => {
|
|
9532
9598
|
this._validate().then(() => driverValidated()).catch(driverValidated);
|
|
9599
|
+
}, tempDirectoryCreated => {
|
|
9600
|
+
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)}`));
|
|
9601
|
+
|
|
9602
|
+
try {
|
|
9603
|
+
mkdirp__default["default"].sync(tempDirectory);
|
|
9604
|
+
tempDirectoryCreated();
|
|
9605
|
+
} catch (err) {
|
|
9606
|
+
tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
|
|
9607
|
+
}
|
|
9533
9608
|
}, repoValidated => {
|
|
9534
9609
|
try {
|
|
9535
|
-
repo = this._getRepo();
|
|
9610
|
+
repo = this._getRepo(tempDirectory);
|
|
9536
9611
|
} catch (err) {
|
|
9537
9612
|
return repoValidated(err);
|
|
9538
9613
|
}
|
|
@@ -9542,7 +9617,7 @@ var BotDriver_1 = class BotDriver {
|
|
|
9542
9617
|
repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
|
|
9543
9618
|
}, containerValidated => {
|
|
9544
9619
|
try {
|
|
9545
|
-
container = this._getContainer(repo);
|
|
9620
|
+
container = this._getContainer(tempDirectory, repo);
|
|
9546
9621
|
} catch (err) {
|
|
9547
9622
|
return containerValidated(err);
|
|
9548
9623
|
}
|
|
@@ -9555,9 +9630,9 @@ var BotDriver_1 = class BotDriver {
|
|
|
9555
9630
|
debug$1(`BotDriver Build error: ${err}`);
|
|
9556
9631
|
this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
|
|
9557
9632
|
|
|
9558
|
-
if (
|
|
9559
|
-
rimraf__default["default"](
|
|
9560
|
-
if (err) debug$1(`Cleanup temp dir ${
|
|
9633
|
+
if (tempDirectory) {
|
|
9634
|
+
rimraf__default["default"](tempDirectory, err => {
|
|
9635
|
+
if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util__default["default"].inspect(err)}`);
|
|
9561
9636
|
});
|
|
9562
9637
|
}
|
|
9563
9638
|
|
|
@@ -9733,14 +9808,6 @@ var BotDriver_1 = class BotDriver {
|
|
|
9733
9808
|
throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
|
|
9734
9809
|
}
|
|
9735
9810
|
|
|
9736
|
-
this.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)}`));
|
|
9737
|
-
|
|
9738
|
-
try {
|
|
9739
|
-
mkdirp__default["default"].sync(this.tempDirectory);
|
|
9740
|
-
} catch (err) {
|
|
9741
|
-
throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
|
|
9742
|
-
}
|
|
9743
|
-
|
|
9744
9811
|
resolve(this);
|
|
9745
9812
|
} catch (err) {
|
|
9746
9813
|
reject(err);
|
|
@@ -9748,29 +9815,29 @@ var BotDriver_1 = class BotDriver {
|
|
|
9748
9815
|
});
|
|
9749
9816
|
}
|
|
9750
9817
|
|
|
9751
|
-
_getRepo() {
|
|
9818
|
+
_getRepo(tempDirectory) {
|
|
9752
9819
|
if (this.caps[Capabilities.BOTIUMGRIDURL]) {
|
|
9753
9820
|
const NoRepo = NoRepo_1;
|
|
9754
|
-
return new NoRepo(
|
|
9821
|
+
return new NoRepo(tempDirectory, this.sources);
|
|
9755
9822
|
}
|
|
9756
9823
|
|
|
9757
9824
|
if (this.sources[Source.GITURL]) {
|
|
9758
9825
|
const GitRepo = GitRepo_1;
|
|
9759
|
-
return new GitRepo(
|
|
9826
|
+
return new GitRepo(tempDirectory, this.sources);
|
|
9760
9827
|
}
|
|
9761
9828
|
|
|
9762
9829
|
if (this.sources[Source.LOCALPATH]) {
|
|
9763
9830
|
const LocalRepo = LocalRepo_1;
|
|
9764
|
-
return new LocalRepo(
|
|
9831
|
+
return new LocalRepo(tempDirectory, this.sources);
|
|
9765
9832
|
}
|
|
9766
9833
|
|
|
9767
9834
|
throw new Error(`No Repo provider found for Sources ${util__default["default"].inspect(this.sources)}`);
|
|
9768
9835
|
}
|
|
9769
9836
|
|
|
9770
|
-
_getContainer(repo) {
|
|
9837
|
+
_getContainer(tempDirectory, repo) {
|
|
9771
9838
|
if (this.caps[Capabilities.BOTIUMGRIDURL]) {
|
|
9772
9839
|
const GridContainer = GridContainer_1;
|
|
9773
|
-
return new GridContainer(this.eventEmitter,
|
|
9840
|
+
return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9774
9841
|
}
|
|
9775
9842
|
|
|
9776
9843
|
if (!this.caps[Capabilities.CONTAINERMODE]) {
|
|
@@ -9779,11 +9846,11 @@ var BotDriver_1 = class BotDriver {
|
|
|
9779
9846
|
|
|
9780
9847
|
if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
|
|
9781
9848
|
const InProcessContainer = InProcessContainer_1;
|
|
9782
|
-
return new InProcessContainer(this.eventEmitter,
|
|
9849
|
+
return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9783
9850
|
}
|
|
9784
9851
|
|
|
9785
9852
|
const PluginConnectorContainer = PluginConnectorContainer_1;
|
|
9786
|
-
return new PluginConnectorContainer(this.eventEmitter,
|
|
9853
|
+
return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
|
|
9787
9854
|
}
|
|
9788
9855
|
|
|
9789
9856
|
};
|