@mablhq/mabl-cli 1.17.6 → 1.20.1

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.
Files changed (97) hide show
  1. package/api/basicApiClient.js +11 -9
  2. package/api/featureSet.js +1 -4
  3. package/api/mablApiClient.js +6 -6
  4. package/api/mablApiClientFactory.js +9 -9
  5. package/api/types.js +8 -0
  6. package/auth/AuthClient.js +1 -0
  7. package/auth/OktaClient.js +66 -21
  8. package/browserLauncher/browserLauncherFactory.js +2 -3
  9. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +3 -0
  10. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +12 -15
  11. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +19 -1
  12. package/browserLauncher/runnerType.js +0 -1
  13. package/browserLauncher/types.js +2 -2
  14. package/cli.js +1 -3
  15. package/commands/applications/applications_cmds/list.js +1 -1
  16. package/commands/auth/auth_cmds/activate-key.js +2 -2
  17. package/commands/auth/auth_cmds/clear.js +1 -1
  18. package/commands/auth/auth_cmds/info.js +1 -1
  19. package/commands/branches/branches_cmds/create.js +1 -1
  20. package/commands/branches/branches_cmds/describe.js +1 -1
  21. package/commands/branches/branches_cmds/list.js +1 -1
  22. package/commands/branches/branches_cmds/merge.js +1 -1
  23. package/commands/commandUtil/util.js +3 -3
  24. package/commands/config/config_cmds/configKeys.js +11 -0
  25. package/commands/config/config_cmds/delete.js +6 -5
  26. package/commands/config/config_cmds/get.js +6 -5
  27. package/commands/config/config_cmds/list.js +7 -7
  28. package/commands/config/config_cmds/set.js +14 -21
  29. package/commands/credentials/credentials_cmds/list.js +1 -1
  30. package/commands/deploy/deploy_cmds/create.js +2 -2
  31. package/commands/deploy/deploy_cmds/list.js +1 -1
  32. package/commands/environments/environments_cmds/create.js +8 -4
  33. package/commands/environments/environments_cmds/list.js +1 -1
  34. package/commands/flows/flows_cmds/list.js +1 -1
  35. package/commands/link-agents/link-agents_cmds/delete.js +1 -6
  36. package/commands/plans/plans_cmds/list.js +1 -1
  37. package/commands/tests/testsUtil.js +8 -8
  38. package/commands/tests/tests_cmds/create.js +1 -1
  39. package/commands/tests/tests_cmds/import.js +2 -2
  40. package/commands/tests/tests_cmds/list.js +1 -1
  41. package/commands/tests/tests_cmds/run-cloud.js +3 -7
  42. package/commands/tests/tests_cmds/run.js +8 -4
  43. package/commands/tests/tests_cmds/trainer_cmds/trainerUtil.js +2 -2
  44. package/execution/index.js +1 -1
  45. package/execution/index.js.LICENSE.txt +2 -0
  46. package/index.d.ts +0 -1
  47. package/mablscript/MablAction.js +1 -1
  48. package/mablscript/MablStep.js +21 -3
  49. package/mablscript/actions/AwaitPDFDownloadAction.js +2 -1
  50. package/mablscript/actions/ConditionAction.js +11 -3
  51. package/mablscript/actions/ExtractAction.js +16 -7
  52. package/mablscript/actions/FindAction.js +71 -40
  53. package/mablscript/actions/GenerateRandomStringAction.js +2 -1
  54. package/mablscript/actions/GetUrlAction.js +1 -1
  55. package/mablscript/actions/GetVariableValue.js +2 -2
  56. package/mablscript/diffing/diffingUtil.js +146 -0
  57. package/mablscript/importer.js +20 -2
  58. package/mablscript/steps/AssertStep.js +33 -19
  59. package/mablscript/steps/AssertStepOld.js +38 -20
  60. package/mablscript/steps/AwaitTabStep.js +7 -6
  61. package/mablscript/steps/ClickAndHoldStep.js +1 -1
  62. package/mablscript/steps/DownloadStep.js +3 -2
  63. package/mablscript/steps/EchoStep.js +3 -1
  64. package/mablscript/steps/ElseIfConditionStep.js +5 -2
  65. package/mablscript/steps/EnterTextStep.js +4 -1
  66. package/mablscript/steps/EvaluateFlowStep.js +40 -0
  67. package/mablscript/steps/ReleaseStep.js +2 -1
  68. package/mablscript/steps/RemoveCookieStep.js +2 -3
  69. package/mablscript/steps/SendHttpRequestStep.js +3 -3
  70. package/mablscript/steps/SendKeyStep.js +2 -2
  71. package/mablscript/steps/SetCookieStep.js +2 -4
  72. package/mablscript/steps/SetViewportStep.js +1 -1
  73. package/mablscript/steps/VisitUrlStep.js +2 -1
  74. package/mablscript/steps/WaitStep.js +1 -4
  75. package/{browserLauncher/puppeteerBrowserLauncher/internals.js → mablscript/types/EvaluateFlowStepDescriptor.js} +0 -0
  76. package/mablscript/types/GetCurrentLocationDescriptor.js +4 -3
  77. package/mablscriptFind/index.js +1 -1
  78. package/package.json +4 -3
  79. package/providers/authenticationProvider.js +106 -60
  80. package/providers/cliConfigProvider.js +159 -61
  81. package/providers/types.js +9 -0
  82. package/resources/mablFind.js +1 -1
  83. package/resources/pdf-viewer/index.js +1 -1
  84. package/resources/pdf-viewer/libEmbeddedPdfHandler.js +11 -2
  85. package/util/actionabilityUtil.js +1 -24
  86. package/util/analytics.js +8 -8
  87. package/util/httpUtil.js +2 -2
  88. package/utilities.js +7 -0
  89. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowser.js +0 -135
  90. package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowserLauncher.js +0 -45
  91. package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +0 -139
  92. package/browserLauncher/puppeteerBrowserLauncher/puppeteerFrame.js +0 -115
  93. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +0 -38
  94. package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpResponse.js +0 -27
  95. package/browserLauncher/puppeteerBrowserLauncher/puppeteerJsHandle.js +0 -36
  96. package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +0 -335
  97. package/browserLauncher/puppeteerBrowserLauncher/wrappers.js +0 -25
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.BasicApiClient = exports.AuthType = void 0;
29
+ exports.BasicApiClient = void 0;
30
30
  const ApiError_1 = require("./ApiError");
31
31
  const httpUtil_1 = require("../util/httpUtil");
32
32
  const axios_1 = __importDefault(require("axios"));
@@ -34,6 +34,7 @@ const os = __importStar(require("os"));
34
34
  const async_retry_1 = __importDefault(require("async-retry"));
35
35
  const logUtils_1 = require("../util/logUtils");
36
36
  const asyncUtil_1 = require("../util/asyncUtil");
37
+ const types_1 = require("./types");
37
38
  const MABL_ENTITY_VERSION_HEADER = 'x-mabl-entity-version';
38
39
  const DEFAULT_RETRYABLE_REQUEST_TIMEOUT_MILLISECONDS = 60000;
39
40
  const DEFAULT_RETRIES = 10;
@@ -49,11 +50,6 @@ const RETRYABLE_NODEJS_ERRORS = [
49
50
  'ETIMEOUT',
50
51
  'ECONNABORTED',
51
52
  ];
52
- var AuthType;
53
- (function (AuthType) {
54
- AuthType[AuthType["Bearer"] = 0] = "Bearer";
55
- AuthType[AuthType["ApiKey"] = 1] = "ApiKey";
56
- })(AuthType = exports.AuthType || (exports.AuthType = {}));
57
53
  class BasicApiClient {
58
54
  constructor(options) {
59
55
  var _a, _b, _c, _d;
@@ -64,13 +60,13 @@ class BasicApiClient {
64
60
  config.timeout =
65
61
  (_c = (_a = options.requestTimeoutMillis) !== null && _a !== void 0 ? _a : (_b = options.retryConfig) === null || _b === void 0 ? void 0 : _b.requestTimeoutMillis) !== null && _c !== void 0 ? _c : DEFAULT_RETRYABLE_REQUEST_TIMEOUT_MILLISECONDS;
66
62
  switch (options.authType) {
67
- case AuthType.ApiKey:
63
+ case types_1.AuthType.ApiKey:
68
64
  config.auth = {
69
65
  username: 'key',
70
66
  password: options.token,
71
67
  };
72
68
  break;
73
- case AuthType.Bearer:
69
+ case types_1.AuthType.Bearer:
74
70
  config.headers.authorization = `Bearer ${options.token}`;
75
71
  break;
76
72
  default:
@@ -130,7 +126,13 @@ class BasicApiClient {
130
126
  return { ...result, entity_version: versionHeader };
131
127
  }
132
128
  async makePostRequest(path, requestBody, requestConfig) {
133
- const response = await this.debugRequest('POST', path, () => this.httpClient.post(path, requestBody, this.getNonRetryableRequestConfig(requestConfig)));
129
+ return this.postRequest(path, requestBody, this.getNonRetryableRequestConfig(requestConfig));
130
+ }
131
+ async makePostRequestWithRetries(path, requestBody, config) {
132
+ return this.retryWrappedRequest(`makePostRequestWithRetries('${path}')`, () => this.postRequest(path, requestBody, this.getRetryableRequestConfig(config)), config);
133
+ }
134
+ async postRequest(path, requestBody, config) {
135
+ const response = await this.debugRequest('POST', path, () => this.httpClient.post(path, requestBody, config));
134
136
  BasicApiClient.checkResponseStatusCode(response);
135
137
  return response.data;
136
138
  }
package/api/featureSet.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FeatureSet = exports.FindImplementationVersion = void 0;
4
4
  const runnerType_1 = require("../browserLauncher/runnerType");
5
- const PLAYWRIGHT_FEATURE_FLAG = 'nodejs_execution_engine_playwright';
6
5
  const SMARTER_WAIT_FEATURE_FLAG = 'smarter_wait';
7
6
  var FindImplementationVersion;
8
7
  (function (FindImplementationVersion) {
@@ -14,9 +13,7 @@ class FeatureSet {
14
13
  this.featureFlags = featureFlags;
15
14
  }
16
15
  getRunnerType() {
17
- return this.featureFlags.has(PLAYWRIGHT_FEATURE_FLAG)
18
- ? runnerType_1.RunnerType.Playwright
19
- : runnerType_1.RunnerType.Puppeteer;
16
+ return runnerType_1.RunnerType.Playwright;
20
17
  }
21
18
  getFindImplementationVersion() {
22
19
  return this.featureFlags.has(SMARTER_WAIT_FEATURE_FLAG)
@@ -303,7 +303,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
303
303
  return await this.makeGetRequest(`${env_1.BASE_API_URL}/accounts/${accountId}`);
304
304
  }
305
305
  catch (error) {
306
- throw new ApiError_1.ApiError(`Failed to get account`, error, error.status);
306
+ throw toApiError(`Failed to get account`, error);
307
307
  }
308
308
  }
309
309
  async getApiKeyDetails() {
@@ -319,13 +319,13 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
319
319
  try {
320
320
  const selfInfo = await this.makeGetRequest(`${env_1.BASE_API_URL}/self`);
321
321
  if (((_a = selfInfo.preferences) === null || _a === void 0 ? void 0 : _a.default_workspace_id) &&
322
- !cliConfigProvider_1.CliConfigProvider.getWorkspace()) {
322
+ !(await cliConfigProvider_1.CliConfigProvider.getWorkspace())) {
323
323
  const workspace = await this.getWorkspace(selfInfo.preferences.default_workspace_id);
324
- cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
324
+ await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
325
325
  }
326
326
  else if (((_b = selfInfo.roles) === null || _b === void 0 ? void 0 : _b.length) === 1) {
327
327
  const workspace = await this.getWorkspace(selfInfo.roles[0].organization_id);
328
- cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
328
+ await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
329
329
  }
330
330
  return selfInfo;
331
331
  }
@@ -454,10 +454,10 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
454
454
  context_id: contextId,
455
455
  workspace_id: workspaceId,
456
456
  };
457
- return await this.makePostRequest(`${env_1.BASE_API_URL}/mailbox/address`, body);
457
+ return await this.makePostRequestWithRetries(`${env_1.BASE_API_URL}/mailbox/address`, body);
458
458
  }
459
459
  catch (error) {
460
- throw new ApiError_1.ApiError('Failed to create mailbox email address', error);
460
+ throw toApiError('Failed to create mailbox email address', error);
461
461
  }
462
462
  }
463
463
  async createBranch(workspaceId, branchName) {
@@ -7,13 +7,13 @@ exports.MablApiClientFactory = void 0;
7
7
  const mablApiClient_1 = require("./mablApiClient");
8
8
  const authenticationProvider_1 = require("../providers/authenticationProvider");
9
9
  const cliConfigProvider_1 = require("../providers/cliConfigProvider");
10
- const basicApiClient_1 = require("./basicApiClient");
10
+ const types_1 = require("./types");
11
11
  const chalk_1 = __importDefault(require("chalk"));
12
12
  class MablApiClientFactory {
13
13
  static createApiClientFromOptionalApiKey(apiKey) {
14
14
  if (apiKey) {
15
15
  return MablApiClientFactory.createApiClient({
16
- authType: basicApiClient_1.AuthType.ApiKey,
16
+ authType: types_1.AuthType.ApiKey,
17
17
  authToken: apiKey,
18
18
  });
19
19
  }
@@ -21,18 +21,18 @@ class MablApiClientFactory {
21
21
  }
22
22
  static createApiClientFromApiKey(apiKey) {
23
23
  return MablApiClientFactory.createApiClient({
24
- authType: basicApiClient_1.AuthType.ApiKey,
24
+ authType: types_1.AuthType.ApiKey,
25
25
  authToken: apiKey,
26
26
  });
27
27
  }
28
28
  static createApiClientFromBearerToken(bearerToken) {
29
29
  return MablApiClientFactory.createApiClient({
30
- authType: basicApiClient_1.AuthType.Bearer,
30
+ authType: types_1.AuthType.Bearer,
31
31
  authToken: bearerToken,
32
32
  });
33
33
  }
34
34
  static async createApiClient(opts) {
35
- const httpConfig = cliConfigProvider_1.CliConfigProvider.getCliConfig().http;
35
+ const httpConfig = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http;
36
36
  if (opts) {
37
37
  return new mablApiClient_1.MablApiClient({
38
38
  authType: opts.authType,
@@ -55,15 +55,15 @@ class MablApiClientFactory {
55
55
  throw new Error('Please supply an API key or authenticate the mabl CLI tool');
56
56
  }
57
57
  static async createUserApiClient() {
58
- if (authenticationProvider_1.AuthenticationProvider.getAuthType() !== basicApiClient_1.AuthType.Bearer) {
58
+ if ((await authenticationProvider_1.AuthenticationProvider.getAuthType()) !== types_1.AuthType.Bearer) {
59
59
  MablApiClientFactory.throwUserAuthTypeError();
60
60
  }
61
61
  return MablApiClientFactory.createApiClient();
62
62
  }
63
- static createApiClientForAccessToken(accessToken) {
64
- const httpConfig = cliConfigProvider_1.CliConfigProvider.getCliConfig().http;
63
+ static async createApiClientForAccessToken(accessToken) {
64
+ const httpConfig = (await cliConfigProvider_1.CliConfigProvider.getCliConfig()).http;
65
65
  return new mablApiClient_1.MablApiClient({
66
- authType: basicApiClient_1.AuthType.Bearer,
66
+ authType: types_1.AuthType.Bearer,
67
67
  token: accessToken,
68
68
  proxyUrl: httpConfig.proxyHost,
69
69
  sslVerify: httpConfig.sslVerify,
package/api/types.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthType = void 0;
4
+ var AuthType;
5
+ (function (AuthType) {
6
+ AuthType[AuthType["Bearer"] = 0] = "Bearer";
7
+ AuthType[AuthType["ApiKey"] = 1] = "ApiKey";
8
+ })(AuthType = exports.AuthType || (exports.AuthType = {}));
@@ -28,6 +28,7 @@ class AuthClient {
28
28
  const loginQueryString = query_string_1.default.stringify({
29
29
  codeChallenge,
30
30
  redirectUri,
31
+ includeRefreshToken: true,
31
32
  });
32
33
  return idpType
33
34
  ? `${env_1.BASE_APP_URL}/authorize/social/${idpType.toLowerCase()}?${loginQueryString}`
@@ -1,10 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.OktaClient = void 0;
4
7
  const env_1 = require("../env/env");
8
+ const axios_1 = __importDefault(require("axios"));
5
9
  const authenticationProvider_1 = require("../providers/authenticationProvider");
6
- const basicApiClient_1 = require("../api/basicApiClient");
10
+ const types_1 = require("../providers/types");
11
+ const types_2 = require("../api/types");
7
12
  const AuthClient_1 = require("./AuthClient");
13
+ const loggingProvider_1 = require("../providers/logging/loggingProvider");
8
14
  const queryString = require('query-string');
9
15
  class OktaClient extends AuthClient_1.AuthClient {
10
16
  constructor(httpClient) {
@@ -12,41 +18,80 @@ class OktaClient extends AuthClient_1.AuthClient {
12
18
  this.httpClient = httpClient;
13
19
  }
14
20
  async validateAuthCode(code, codeVerifier, redirectUri) {
15
- const url = `${env_1.OKTA_URL}/oauth2/default/v1/token`;
16
- const requestOptions = {
17
- method: 'POST',
18
- headers: { 'content-type': 'application/x-www-form-urlencoded' },
19
- };
20
- const data = queryString.stringify({
21
+ return this.getBearerAuthInfo(queryString.stringify({
21
22
  grant_type: 'authorization_code',
22
23
  client_id: env_1.OKTA_CLIENT_ID,
23
24
  code_verifier: codeVerifier,
24
25
  code,
25
26
  redirect_uri: redirectUri,
26
- });
27
- const response = await this.httpClient.post(url, data, requestOptions);
28
- const authInfo = response.data;
29
- authInfo.auth_provider = authenticationProvider_1.AuthProviderType.Okta;
30
- authInfo.auth_type = basicApiClient_1.AuthType.Bearer;
31
- return authInfo;
27
+ }));
32
28
  }
33
- async exchangeRefreshTokenForAccessToken(refreshToken) {
34
- const url = `${env_1.OKTA_URL}/oauth2/default/v1/token`;
29
+ async getRefreshTokenExpiration(refreshToken) {
30
+ if (!refreshToken) {
31
+ return;
32
+ }
33
+ const url = `${env_1.OKTA_URL}/oauth2/v1/introspect`;
35
34
  const requestOptions = {
36
35
  method: 'POST',
37
36
  headers: { 'content-type': 'application/x-www-form-urlencoded' },
38
37
  };
39
38
  const data = queryString.stringify({
40
- grant_type: 'refresh_token',
41
39
  client_id: env_1.OKTA_CLIENT_ID,
42
- refresh_token: refreshToken,
43
- scope: 'openid profile email offline_access',
40
+ token_type_hint: 'refresh_token',
41
+ token: refreshToken,
44
42
  });
45
- const response = await this.httpClient.post(url, data, requestOptions);
43
+ try {
44
+ const response = await this.httpClient.post(url, data, requestOptions);
45
+ return response.data.exp;
46
+ }
47
+ catch (error) {
48
+ loggingProvider_1.logger.info(`Couldn't get refresh token expiration. Will re-use previous lifetime.`);
49
+ return;
50
+ }
51
+ }
52
+ async getBearerAuthInfo(queryStringData) {
53
+ const url = `${env_1.OKTA_URL}/oauth2/default/v1/token`;
54
+ const requestOptions = {
55
+ method: 'POST',
56
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
57
+ };
58
+ const response = await this.httpClient.post(url, queryStringData, requestOptions);
46
59
  const authInfo = response.data;
47
- authInfo.auth_provider = authenticationProvider_1.AuthProviderType.Okta;
48
- authInfo.auth_type = basicApiClient_1.AuthType.Bearer;
60
+ const refreshTokenExpiresAt = await this.getRefreshTokenExpiration(authInfo.refresh_token);
61
+ authInfo.auth_provider = types_1.AuthProviderType.Okta;
62
+ authInfo.auth_type = types_2.AuthType.Bearer;
63
+ authInfo.refresh_token_expires_at = refreshTokenExpiresAt;
49
64
  return authInfo;
50
65
  }
66
+ exchangeRefreshTokenForAccessToken(refreshToken) {
67
+ var _a;
68
+ try {
69
+ return this.getBearerAuthInfo(queryString.stringify({
70
+ grant_type: 'refresh_token',
71
+ client_id: env_1.OKTA_CLIENT_ID,
72
+ refresh_token: refreshToken,
73
+ scope: 'openid profile email offline_access',
74
+ }));
75
+ }
76
+ catch (error) {
77
+ if (!axios_1.default.isAxiosError(error)) {
78
+ throw error;
79
+ }
80
+ const data = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
81
+ if (!(0, authenticationProvider_1.isOidcError)(data)) {
82
+ throw error;
83
+ }
84
+ return Promise.resolve({
85
+ auth_provider: types_1.AuthProviderType.Okta,
86
+ auth_type: types_2.AuthType.Bearer,
87
+ access_token: '',
88
+ id_token: '',
89
+ token_type: '',
90
+ expires_in: 0,
91
+ error: data.error,
92
+ error_description: data.error_description,
93
+ });
94
+ }
95
+ }
51
96
  }
52
97
  exports.OktaClient = OktaClient;
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BrowserLauncherFactory = void 0;
7
- const puppeteerBrowserLauncher_1 = require("./puppeteerBrowserLauncher/puppeteerBrowserLauncher");
8
7
  const playwrightBrowserLauncher_1 = require("./playwrightBrowserLauncher/playwrightBrowserLauncher");
9
8
  const runnerType_1 = require("./runnerType");
10
9
  const logUtils_1 = require("../util/logUtils");
@@ -24,8 +23,8 @@ class BrowserLauncherFactory {
24
23
  loggerFunc(chalk_1.default.cyan(`Browser launcher:`, chalk_1.default.magenta('Playwright')));
25
24
  return new playwrightBrowserLauncher_1.PlaywrightBrowserLauncher();
26
25
  }
27
- loggerFunc(chalk_1.default.cyan(`Browser launcher:`, chalk_1.default.magenta('Puppeteer')));
28
- return new puppeteerBrowserLauncher_1.PuppeteerBrowserLauncher();
26
+ loggerFunc(chalk_1.default.red.bold(`Unsupported runner type:`, runner));
27
+ throw new Error(`Unsupported runner type:[${runner}]`);
29
28
  }
30
29
  }
31
30
  exports.BrowserLauncherFactory = BrowserLauncherFactory;
@@ -128,5 +128,8 @@ class PlaywrightBrowser extends events_1.default {
128
128
  await playwrightPage.waitForInitialization();
129
129
  return playwrightPage;
130
130
  }
131
+ exposeFunction(name, callback) {
132
+ return this.defaultContext.exposeFunction(name, callback);
133
+ }
131
134
  }
132
135
  exports.PlaywrightBrowser = PlaywrightBrowser;
@@ -132,13 +132,13 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
132
132
  return (0, utils_1.mapIfNotNull)(await this.element.boundingBox(), (boundingBox) => boundingBox);
133
133
  }
134
134
  async click(options) {
135
- var _a, _b, _c, _d;
135
+ var _a, _b, _c;
136
136
  const trial = (_a = options === null || options === void 0 ? void 0 : options.trial) !== null && _a !== void 0 ? _a : false;
137
137
  try {
138
138
  await this.element.click({
139
139
  clickCount: (_b = options === null || options === void 0 ? void 0 : options.clickCount) !== null && _b !== void 0 ? _b : 1,
140
140
  force: (_c = options === null || options === void 0 ? void 0 : options.force) !== null && _c !== void 0 ? _c : !trial,
141
- timeout: (_d = options === null || options === void 0 ? void 0 : options.timeout) !== null && _d !== void 0 ? _d : types_1.DefaultTimeouts.quickActionTimeoutMs,
141
+ timeout: this.getActionTimeout(options),
142
142
  trial,
143
143
  });
144
144
  }
@@ -151,12 +151,12 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
151
151
  }
152
152
  }
153
153
  async doubleClick(options) {
154
- var _a, _b, _c;
154
+ var _a, _b;
155
155
  try {
156
156
  const trial = (_a = options === null || options === void 0 ? void 0 : options.trial) !== null && _a !== void 0 ? _a : false;
157
157
  return this.element.dblclick({
158
158
  force: (_b = options === null || options === void 0 ? void 0 : options.force) !== null && _b !== void 0 ? _b : !trial,
159
- timeout: (_c = options === null || options === void 0 ? void 0 : options.timeout) !== null && _c !== void 0 ? _c : types_1.DefaultTimeouts.quickActionTimeoutMs,
159
+ timeout: this.getActionTimeout(options),
160
160
  trial,
161
161
  });
162
162
  }
@@ -194,23 +194,13 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
194
194
  return this.element.selectOption(value);
195
195
  }
196
196
  async type(text, options) {
197
- const timeout = PlaywrightElementHandle.getTypeTimeout(text, options);
198
197
  await this.element.focus();
199
198
  await this.element.selectText({ force: true });
200
199
  return this.element.type(text, {
201
200
  delay: options === null || options === void 0 ? void 0 : options.delay,
202
- timeout,
201
+ timeout: 0,
203
202
  });
204
203
  }
205
- static getTypeTimeout(text, options) {
206
- var _a;
207
- let timeout;
208
- const newTimeout = text.length * ((_a = options === null || options === void 0 ? void 0 : options.delay) !== null && _a !== void 0 ? _a : 1) * 2;
209
- if (newTimeout > types_1.DefaultTimeouts.defaultTextInputTimeoutMs) {
210
- timeout = newTimeout;
211
- }
212
- return timeout;
213
- }
214
204
  press(key) {
215
205
  return this.element.press(key);
216
206
  }
@@ -283,5 +273,12 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
283
273
  const result = await this.element.evaluate((el) => el.innerText);
284
274
  return (0, pureUtil_1.isNullish)(result) ? undefined : result;
285
275
  }
276
+ getActionTimeout(options) {
277
+ var _a;
278
+ const defaultTimeout = (options === null || options === void 0 ? void 0 : options.trial)
279
+ ? types_1.DefaultTimeouts.defaultTrialTimeoutMs
280
+ : types_1.DefaultTimeouts.defaultActionTimeoutMs;
281
+ return (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : defaultTimeout;
282
+ }
286
283
  }
287
284
  exports.PlaywrightElementHandle = PlaywrightElementHandle;
@@ -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.quickActionTimeoutMs,
132
+ timeout: types_1.DefaultTimeouts.defaultActionTimeoutMs,
133
133
  });
134
134
  }
135
135
  return (0, utils_1.mapIfNotNull)(response, (response) => new playwrightHttpResponse_1.PlaywrightHttpResponse(this.parentPage, response));
@@ -178,5 +178,23 @@ class PlaywrightFrame extends browserLauncher_1.Frame {
178
178
  }
179
179
  return this.frameImpl;
180
180
  }
181
+ async initializeExposedFunctionInSecondaryWorld(functionName) {
182
+ var _a;
183
+ try {
184
+ const pageImpl = this.parentPage.getPageImpl();
185
+ if (!pageImpl) {
186
+ return false;
187
+ }
188
+ const binding = (_a = pageImpl._pageBindings.get(functionName)) !== null && _a !== void 0 ? _a : pageImpl._browserContext._pageBindings.get(functionName);
189
+ if (!binding) {
190
+ return false;
191
+ }
192
+ await this.evaluateCodeInSecondaryWorld(binding.source, {});
193
+ }
194
+ catch (e) {
195
+ return false;
196
+ }
197
+ return true;
198
+ }
181
199
  }
182
200
  exports.PlaywrightFrame = PlaywrightFrame;
@@ -4,5 +4,4 @@ exports.RunnerType = void 0;
4
4
  var RunnerType;
5
5
  (function (RunnerType) {
6
6
  RunnerType["Playwright"] = "playwright";
7
- RunnerType["Puppeteer"] = "puppeteer";
8
7
  })(RunnerType = exports.RunnerType || (exports.RunnerType = {}));
@@ -4,8 +4,8 @@ exports.WaitForOptions = exports.LifecycleEvent = exports.DefaultTimeouts = void
4
4
  class DefaultTimeouts {
5
5
  }
6
6
  exports.DefaultTimeouts = DefaultTimeouts;
7
- DefaultTimeouts.quickActionTimeoutMs = 5000;
8
- DefaultTimeouts.defaultTextInputTimeoutMs = 30000;
7
+ DefaultTimeouts.defaultTrialTimeoutMs = 5000;
8
+ DefaultTimeouts.defaultActionTimeoutMs = 0;
9
9
  var LifecycleEvent;
10
10
  (function (LifecycleEvent) {
11
11
  LifecycleEvent["DomContentLoaded"] = "domcontentloaded";
package/cli.js CHANGED
@@ -85,9 +85,7 @@ yargs
85
85
  catch (_) {
86
86
  }
87
87
  },
88
- (argv) => {
89
- (0, analytics_1.trackCliEvent)(argv._, (0, pureUtil_1.extractKeyCountsFromArgs)(argv));
90
- },
88
+ async (argv) => (0, analytics_1.trackCliEvent)(argv._, (0, pureUtil_1.extractKeyCountsFromArgs)(argv)),
91
89
  () => {
92
90
  updateNotifier({
93
91
  pkg: cliPackage,
@@ -18,7 +18,7 @@ exports.handler = (0, util_1.failWrapper)(listApplications);
18
18
  async function listApplications(parsed) {
19
19
  const output = parsed.output;
20
20
  const limit = parsed.limit;
21
- const workspaceId = (0, util_1.getWorkspaceId)(parsed);
21
+ const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
22
22
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
23
23
  const applications = await apiClient.getApplications(workspaceId, limit);
24
24
  printApplications(applications, output);
@@ -24,6 +24,6 @@ async function activateApiKey(parsed) {
24
24
  const mablApi = await mablApiClientFactory_1.MablApiClientFactory.createApiClientFromApiKey(cleanApiKey);
25
25
  const apiKeyDetails = await mablApi.getApiKeyDetails();
26
26
  const apiKeyWorkspace = await mablApi.getWorkspace(apiKeyDetails.workspace_id);
27
- cliConfigProvider_1.CliConfigProvider.setWorkspace(apiKeyWorkspace);
28
- auth.activateApiKey(cleanApiKey);
27
+ await cliConfigProvider_1.CliConfigProvider.setWorkspace(apiKeyWorkspace);
28
+ return auth.activateApiKey(cleanApiKey);
29
29
  }
@@ -6,5 +6,5 @@ exports.describe = 'Clear logged in user';
6
6
  exports.builder = {};
7
7
  exports.handler = exports.handler = () => {
8
8
  const auth = new authenticationProvider_1.AuthenticationProvider();
9
- auth.clearAuthentication();
9
+ return auth.clearAuthentication();
10
10
  };
@@ -6,5 +6,5 @@ exports.describe = 'Display logged in user';
6
6
  exports.builder = {};
7
7
  exports.handler = () => {
8
8
  const auth = new authenticationProvider_1.AuthenticationProvider();
9
- auth.displayInfo();
9
+ return auth.displayInfo();
10
10
  };
@@ -39,7 +39,7 @@ exports.builder = (yargs) => {
39
39
  exports.handler = (0, util_1.failWrapper)(createBranch);
40
40
  async function createBranch(parsed) {
41
41
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
42
- const workspaceId = (0, util_1.getWorkspaceId)(parsed);
42
+ const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
43
43
  const branchName = parsed.name;
44
44
  loggingProvider_1.logger.info(`Creating Branch [${branchName}]`);
45
45
  try {
@@ -39,7 +39,7 @@ async function getBranch(parsed) {
39
39
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
40
40
  let branch;
41
41
  if (lookupByName) {
42
- const workspaceId = (0, util_1.getWorkspaceId)(parsed);
42
+ const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
43
43
  branch = await apiClient.getBranchByName(workspaceId, branchIdentifier);
44
44
  }
45
45
  else {
@@ -43,7 +43,7 @@ async function listBranches(parsed) {
43
43
  const output = parsed.output;
44
44
  const limit = parsed.limit;
45
45
  const statusFilter = parsed.status;
46
- const workspaceId = (0, util_1.getWorkspaceId)(parsed);
46
+ const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
47
47
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
48
48
  const branches = await apiClient.getBranches(workspaceId, limit, statusFilter);
49
49
  printBranches(branches, output);
@@ -47,7 +47,7 @@ exports.builder = (yargs) => {
47
47
  exports.handler = (0, util_1.failWrapper)(mergeBranch);
48
48
  async function mergeBranch(parsed) {
49
49
  const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
50
- const workspaceId = (0, util_1.getWorkspaceId)(parsed);
50
+ const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
51
51
  const fromBranchName = parsed.from;
52
52
  const toBranchName = parsed.to;
53
53
  const branch = await apiClient.mergeBranch(workspaceId, fromBranchName, toBranchName);
@@ -24,12 +24,12 @@ function failWrapper(func, exitCodeOnError = 1) {
24
24
  });
25
25
  }
26
26
  exports.failWrapper = failWrapper;
27
- function getWorkspaceId(parsed) {
28
- const workspaceId = parsed['workspace-id'];
27
+ async function getWorkspaceId(parsed) {
28
+ const workspaceId = parsed[constants_1.CommandArgWorkspaceId];
29
29
  if (workspaceId) {
30
30
  return workspaceId;
31
31
  }
32
- const configuredWorkspace = cliConfigProvider_1.CliConfigProvider.getWorkspace();
32
+ const configuredWorkspace = await cliConfigProvider_1.CliConfigProvider.getWorkspace();
33
33
  if (configuredWorkspace === null || configuredWorkspace === void 0 ? void 0 : configuredWorkspace.id) {
34
34
  return configuredWorkspace.id;
35
35
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validConfigKeyChoices = exports.configKeys = void 0;
4
+ exports.configKeys = Object.freeze({
5
+ browserPath: 'browser.path',
6
+ enableSourceControlMetadataCollection: 'alpha.scm_metadata.enable',
7
+ defaultWorkspaceId: 'workspace',
8
+ proxy: 'http.proxy',
9
+ sslVerify: 'http.sslVerify',
10
+ });
11
+ exports.validConfigKeyChoices = Object.values(exports.configKeys);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cliConfigProvider_1 = require("../../../providers/cliConfigProvider");
4
4
  const set_1 = require("./set");
5
+ const configKeys_1 = require("./configKeys");
5
6
  const list_1 = require("./list");
6
7
  const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
7
8
  exports.command = `delete <${set_1.configKeyCommandArg}>`;
@@ -10,18 +11,18 @@ exports.builder = (yargs) => {
10
11
  yargs.positional(set_1.configKeyCommandArg, {
11
12
  describe: 'configuration key to delete',
12
13
  type: 'string',
13
- choices: set_1.validConfigKeyChoices,
14
+ choices: configKeys_1.validConfigKeyChoices,
14
15
  });
15
16
  };
16
17
  exports.handler = deleteConfig;
17
- function deleteConfig(parsed) {
18
+ async function deleteConfig(parsed) {
18
19
  const key = parsed['config-key'];
19
20
  switch (key) {
20
- case set_1.configKeys.defaultWorkspaceId:
21
- cliConfigProvider_1.CliConfigProvider.clearWorkspace();
21
+ case configKeys_1.configKeys.defaultWorkspaceId:
22
+ await cliConfigProvider_1.CliConfigProvider.clearWorkspace();
22
23
  break;
23
24
  default:
24
- cliConfigProvider_1.CliConfigProvider.clearConfigProperty(key);
25
+ await cliConfigProvider_1.CliConfigProvider.clearConfigProperty(key);
25
26
  }
26
27
  loggingProvider_1.logger.info(`Deleted config for [${key}]`);
27
28
  return (0, list_1.listConfig)();