@mablhq/mabl-cli 1.20.1 → 1.20.17
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/api/basicApiClient.js +7 -5
- package/api/mablApiClient.js +7 -3
- package/api/mablApiClientFactory.js +12 -11
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +12 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +2 -6
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +5 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +0 -2
- package/browserLauncher/types.js +1 -0
- package/execution/index.js +1 -1
- package/mablscript/diffing/diffingUtil.js +9 -9
- package/package.json +2 -3
- package/providers/cliConfigProvider.js +2 -1
- package/util/httpUtil.js +4 -7
package/api/basicApiClient.js
CHANGED
|
@@ -48,17 +48,19 @@ const RETRYABLE_NODEJS_ERRORS = [
|
|
|
48
48
|
'ENOTFOUND',
|
|
49
49
|
'ENETUNREACH',
|
|
50
50
|
'ETIMEOUT',
|
|
51
|
+
'ETIMEDOUT',
|
|
51
52
|
'ECONNABORTED',
|
|
52
53
|
];
|
|
54
|
+
const DEFAULT_SSL_VERIFY = false;
|
|
53
55
|
class BasicApiClient {
|
|
54
56
|
constructor(options) {
|
|
55
|
-
var _a, _b, _c, _d;
|
|
57
|
+
var _a, _b, _c, _d, _e;
|
|
56
58
|
const config = (0, httpUtil_1.axiosProxyConfig)({
|
|
57
|
-
sslVerify: options.sslVerify,
|
|
59
|
+
sslVerify: (_a = options.sslVerify) !== null && _a !== void 0 ? _a : DEFAULT_SSL_VERIFY,
|
|
58
60
|
proxyHost: options.proxyUrl,
|
|
59
61
|
});
|
|
60
62
|
config.timeout =
|
|
61
|
-
(
|
|
63
|
+
(_d = (_b = options.requestTimeoutMillis) !== null && _b !== void 0 ? _b : (_c = options.retryConfig) === null || _c === void 0 ? void 0 : _c.requestTimeoutMillis) !== null && _d !== void 0 ? _d : DEFAULT_RETRYABLE_REQUEST_TIMEOUT_MILLISECONDS;
|
|
62
64
|
switch (options.authType) {
|
|
63
65
|
case types_1.AuthType.ApiKey:
|
|
64
66
|
config.auth = {
|
|
@@ -86,7 +88,7 @@ class BasicApiClient {
|
|
|
86
88
|
this.httpRequestConfig = config;
|
|
87
89
|
this.httpClient = axios_1.default.create(config);
|
|
88
90
|
this.retryConfig = options.retryConfig;
|
|
89
|
-
this.debugLogger = (
|
|
91
|
+
this.debugLogger = (_e = options.debugLogger) !== null && _e !== void 0 ? _e : logUtils_1.logInternal;
|
|
90
92
|
}
|
|
91
93
|
getNonRetryableRequestConfig(override) {
|
|
92
94
|
const overrideWithTimeout = { ...(override !== null && override !== void 0 ? override : {}) };
|
|
@@ -145,7 +147,7 @@ class BasicApiClient {
|
|
|
145
147
|
return this.retryWrappedRequest(`makeDeleteRequest('${path}')`, () => this.deleteRequest(path, this.getRetryableRequestConfig(retryConfig)), retryConfig);
|
|
146
148
|
}
|
|
147
149
|
async deleteRequest(path, config) {
|
|
148
|
-
const response = await this.debugRequest('DELETE', path, () => this.
|
|
150
|
+
const response = await this.debugRequest('DELETE', path, () => this.httpClient.delete(path, config));
|
|
149
151
|
BasicApiClient.checkResponseStatusCode(response);
|
|
150
152
|
return response.data;
|
|
151
153
|
}
|
package/api/mablApiClient.js
CHANGED
|
@@ -31,6 +31,10 @@ const cliConfigProvider_1 = require("../providers/cliConfigProvider");
|
|
|
31
31
|
const basicApiClient_1 = require("./basicApiClient");
|
|
32
32
|
const queryString = __importStar(require("query-string"));
|
|
33
33
|
const featureSet_1 = require("./featureSet");
|
|
34
|
+
const DEPLOYMENT_EVENT_RETRY_CONFIG = {
|
|
35
|
+
requestTimeoutMillis: 0,
|
|
36
|
+
maxRetryTimeMillis: 1000 * 60 * 60,
|
|
37
|
+
};
|
|
34
38
|
class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
35
39
|
constructor(options) {
|
|
36
40
|
super(options);
|
|
@@ -129,7 +133,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
129
133
|
}
|
|
130
134
|
async createDeployment(deployment) {
|
|
131
135
|
try {
|
|
132
|
-
return await this.makePostRequest(`${env_1.BASE_API_URL}/deployments`, deployment
|
|
136
|
+
return await this.makePostRequest(`${env_1.BASE_API_URL}/deployments`, deployment);
|
|
133
137
|
}
|
|
134
138
|
catch (error) {
|
|
135
139
|
throw toApiError(`Failed to create deployment`, error);
|
|
@@ -231,7 +235,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
231
235
|
}
|
|
232
236
|
async getDeploymentResults(deploymentEventId) {
|
|
233
237
|
try {
|
|
234
|
-
return await this.makeGetRequest(`${env_1.BASE_API_URL}/execution/result/event/${deploymentEventId}`,
|
|
238
|
+
return await this.makeGetRequest(`${env_1.BASE_API_URL}/execution/result/event/${deploymentEventId}`, DEPLOYMENT_EVENT_RETRY_CONFIG);
|
|
235
239
|
}
|
|
236
240
|
catch (error) {
|
|
237
241
|
throw toApiError(`Failed to get deployment results`, error);
|
|
@@ -501,7 +505,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
501
505
|
async postDeploymentEvent(options) {
|
|
502
506
|
try {
|
|
503
507
|
const requestBody = this.buildDeploymentRequestBody(options);
|
|
504
|
-
return await this.
|
|
508
|
+
return await this.makePostRequestWithRetries(`${env_1.BASE_API_URL}/events/deployment/`, requestBody, DEPLOYMENT_EVENT_RETRY_CONFIG);
|
|
505
509
|
}
|
|
506
510
|
catch (error) {
|
|
507
511
|
throw toApiError(`Failed to create deployment`, error);
|
|
@@ -14,7 +14,7 @@ class MablApiClientFactory {
|
|
|
14
14
|
if (apiKey) {
|
|
15
15
|
return MablApiClientFactory.createApiClient({
|
|
16
16
|
authType: types_1.AuthType.ApiKey,
|
|
17
|
-
|
|
17
|
+
token: apiKey,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
return MablApiClientFactory.createApiClient();
|
|
@@ -22,34 +22,35 @@ class MablApiClientFactory {
|
|
|
22
22
|
static createApiClientFromApiKey(apiKey) {
|
|
23
23
|
return MablApiClientFactory.createApiClient({
|
|
24
24
|
authType: types_1.AuthType.ApiKey,
|
|
25
|
-
|
|
25
|
+
token: apiKey,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
static createApiClientFromBearerToken(bearerToken) {
|
|
29
29
|
return MablApiClientFactory.createApiClient({
|
|
30
30
|
authType: types_1.AuthType.Bearer,
|
|
31
|
-
|
|
31
|
+
token: bearerToken,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
static async createApiClient(opts) {
|
|
35
|
-
const
|
|
35
|
+
const { proxyHost, sslVerify } = (await cliConfigProvider_1.CliConfigProvider.getCliConfig())
|
|
36
|
+
.http;
|
|
37
|
+
const optsFromCliHttpConfig = {
|
|
38
|
+
proxyUrl: proxyHost,
|
|
39
|
+
sslVerify,
|
|
40
|
+
};
|
|
36
41
|
if (opts) {
|
|
37
42
|
return new mablApiClient_1.MablApiClient({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
proxyUrl: httpConfig.proxyHost,
|
|
41
|
-
sslVerify: httpConfig.sslVerify,
|
|
42
|
-
userAgentOverride: opts.userAgentOverride,
|
|
43
|
+
...optsFromCliHttpConfig,
|
|
44
|
+
...opts,
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
const authProvider = new authenticationProvider_1.AuthenticationProvider();
|
|
46
48
|
const authConfig = await authProvider.getAuthConfigWithAutoRenew();
|
|
47
49
|
if (authConfig === null || authConfig === void 0 ? void 0 : authConfig.accessToken) {
|
|
48
50
|
return new mablApiClient_1.MablApiClient({
|
|
51
|
+
...optsFromCliHttpConfig,
|
|
49
52
|
authType: authConfig.authType,
|
|
50
53
|
token: authConfig.accessToken,
|
|
51
|
-
proxyUrl: httpConfig.proxyHost,
|
|
52
|
-
sslVerify: httpConfig.sslVerify,
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
throw new Error('Please supply an API key or authenticate the mabl CLI tool');
|
|
@@ -54,6 +54,11 @@ class PlaywrightBrowser extends events_1.default {
|
|
|
54
54
|
fs_extra_1.default.mkdirSync(path_1.default.join(this.downloadDirectory));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
static async create(defaultContext, downloadDirectory, browserWSEndpoint) {
|
|
58
|
+
const browser = new PlaywrightBrowser(defaultContext, downloadDirectory, browserWSEndpoint);
|
|
59
|
+
await browser.setDownloadBehavior();
|
|
60
|
+
return browser;
|
|
61
|
+
}
|
|
57
62
|
getRunnerType() {
|
|
58
63
|
return runnerType_1.RunnerType.Playwright;
|
|
59
64
|
}
|
|
@@ -114,6 +119,13 @@ class PlaywrightBrowser extends events_1.default {
|
|
|
114
119
|
getDefaultContext() {
|
|
115
120
|
return this.defaultContext;
|
|
116
121
|
}
|
|
122
|
+
async setDownloadBehavior() {
|
|
123
|
+
await this.cdpSession.send('Browser.setDownloadBehavior', {
|
|
124
|
+
behavior: 'allow',
|
|
125
|
+
downloadPath: this.downloadDirectory,
|
|
126
|
+
eventsEnabled: true,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
117
129
|
onPageClose(page) {
|
|
118
130
|
this.playwrightPages.delete(page.getPageId());
|
|
119
131
|
this.emit(browserLauncher_1.BrowserEvent.PageDestroyed, page);
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.PlaywrightBrowserLauncher = void 0;
|
|
7
4
|
const test_1 = require("@playwright/test");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
5
|
const playwrightBrowser_1 = require("./playwrightBrowser");
|
|
10
6
|
const BROWSER_LAUNCH_TIMEOUT_MS = 60000;
|
|
11
7
|
class PlaywrightBrowserLauncher {
|
|
12
8
|
async connect(options, currentDownloadPath) {
|
|
13
9
|
const browser = await test_1.chromium.connect(options.browserWSEndpoint);
|
|
14
|
-
return
|
|
10
|
+
return playwrightBrowser_1.PlaywrightBrowser.create(browser.contexts()[0], currentDownloadPath, options.browserWSEndpoint);
|
|
15
11
|
}
|
|
16
12
|
async launch(options) {
|
|
17
13
|
var _a, _b, _c;
|
|
@@ -40,7 +36,7 @@ class PlaywrightBrowserLauncher {
|
|
|
40
36
|
userAgent: options.userAgent,
|
|
41
37
|
viewport,
|
|
42
38
|
});
|
|
43
|
-
return
|
|
39
|
+
return playwrightBrowser_1.PlaywrightBrowser.create(defaultContext, options.downloadPath, '');
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
exports.PlaywrightBrowserLauncher = PlaywrightBrowserLauncher;
|
|
@@ -194,8 +194,11 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
|
194
194
|
return this.element.selectOption(value);
|
|
195
195
|
}
|
|
196
196
|
async type(text, options) {
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
var _a;
|
|
198
|
+
const selectText = (_a = options === null || options === void 0 ? void 0 : options.selectText) !== null && _a !== void 0 ? _a : true;
|
|
199
|
+
if (selectText) {
|
|
200
|
+
await this.element.selectText({ force: true });
|
|
201
|
+
}
|
|
199
202
|
return this.element.type(text, {
|
|
200
203
|
delay: options === null || options === void 0 ? void 0 : options.delay,
|
|
201
204
|
timeout: 0,
|
|
@@ -129,7 +129,7 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
|
|
|
129
129
|
const response = await this.frame.goto(url, options);
|
|
130
130
|
if (waitForNetworkIdle) {
|
|
131
131
|
await this.frame.waitForLoadState('networkidle', {
|
|
132
|
-
timeout: types_1.DefaultTimeouts.
|
|
132
|
+
timeout: types_1.DefaultTimeouts.defaultWaitTimeoutMs,
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
return (0, utils_1.mapIfNotNull)(response, (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this.parentPage, response));
|
|
@@ -36,7 +36,6 @@ const playwrightFrame_1 = require("./playwrightFrame");
|
|
|
36
36
|
const playwrightDom_1 = require("./playwrightDom");
|
|
37
37
|
const utils_1 = require("../utils");
|
|
38
38
|
const wrappers_1 = require("./wrappers");
|
|
39
|
-
const path_1 = __importDefault(require("path"));
|
|
40
39
|
const logUtils_1 = require("../../util/logUtils");
|
|
41
40
|
const uuid = __importStar(require("uuid"));
|
|
42
41
|
class PlaywrightPage extends events_1.default {
|
|
@@ -57,7 +56,6 @@ class PlaywrightPage extends events_1.default {
|
|
|
57
56
|
var _a, _b;
|
|
58
57
|
const guid = uuid.v4();
|
|
59
58
|
const downloadSize = (_b = (_a = (await download.createReadStream())) === null || _a === void 0 ? void 0 : _a.readableLength) !== null && _b !== void 0 ? _b : 0;
|
|
60
|
-
await download.saveAs(path_1.default.join(this.browser.getDownloadDirectory(), download.suggestedFilename()));
|
|
61
59
|
browser.emit(browserLauncher_1.BrowserEvent.DownloadWillBegin, {
|
|
62
60
|
guid,
|
|
63
61
|
suggestedFilename: download.suggestedFilename(),
|
package/browserLauncher/types.js
CHANGED