@mablhq/mabl-cli 1.47.12 → 1.48.0

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 (36) hide show
  1. package/api/mablApiClient.js +20 -0
  2. package/browserEngines/chromiumBrowserEngine.js +16 -17
  3. package/browserEngines/firefoxBrowserEngine.js +44 -11
  4. package/browserEngines/unsupportedBrowserEngine.js +3 -4
  5. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +3 -0
  6. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +5 -2
  7. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +3 -0
  8. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +3 -0
  9. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +2 -2
  10. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +1 -1
  11. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +33 -1
  12. package/cli.js +1 -0
  13. package/commands/commandUtil/list.js +41 -1
  14. package/commands/datatables/datatables.js +5 -0
  15. package/commands/datatables/datatables_cmds/describe.js +17 -0
  16. package/commands/datatables/datatables_cmds/export.js +78 -0
  17. package/commands/datatables/datatables_cmds/list.js +18 -0
  18. package/commands/tests/testsUtil.js +23 -39
  19. package/execution/index.js +1 -1
  20. package/mablApi/index.js +1 -1
  21. package/mablscript/importer.js +3 -0
  22. package/mablscriptFind/index.js +1 -1
  23. package/package.json +5 -4
  24. package/proxy/index.js +1 -1
  25. package/resources/mablFind.js +1 -1
  26. package/resources/pdf-viewer/index.js +1 -1
  27. package/resources/pdf-viewer/libmablPdfViewer.js +117 -113
  28. package/resources/pdf-viewer/pdf.worker.0ceac9378bfc3bfcb634.js +81 -0
  29. package/resources/pdf-viewer/pdf.worker.df20a5600902b0735d4b.js +2 -0
  30. package/util/browserTestUtils.js +18 -0
  31. package/util/clickUtil.js +5 -0
  32. package/util/csvUtil.js +8 -0
  33. package/util/jestUtil.js +2 -2
  34. package/api/entities/Plan.js +0 -2
  35. package/resources/pdf-viewer/pdf.worker.5953c23fa7251d236190.js +0 -2
  36. package/resources/pdf-viewer/pdf.worker.5f2736435a8b46d97859.js +0 -81
@@ -461,6 +461,26 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
461
461
  throw toApiError(`Failed to get File Upload URL`, error);
462
462
  }
463
463
  }
464
+ async getDatatables(workspaceId, limit) {
465
+ try {
466
+ const datatablesQueryString = queryString.stringify({
467
+ organization_id: workspaceId,
468
+ limit,
469
+ });
470
+ return await this.makeGetRequest(`${this.baseApiUrl}/variables/tables?${datatablesQueryString}`).then((result) => { var _a; return (_a = result.variableTables) !== null && _a !== void 0 ? _a : []; });
471
+ }
472
+ catch (error) {
473
+ throw toApiError(`Failed to retrieve datatables`, error);
474
+ }
475
+ }
476
+ async getDatatable(datatableId) {
477
+ try {
478
+ return await this.makeGetRequest(`${this.baseApiUrl}/variables/tables/${datatableId}`);
479
+ }
480
+ catch (error) {
481
+ throw toApiError(`Failed to get datatable`, error);
482
+ }
483
+ }
464
484
  async getDatatableRows(datatableId) {
465
485
  try {
466
486
  return await this.makeGetRequest(`${this.baseApiUrl}/variables/tables/${datatableId}/rows`).then((result) => { var _a; return (_a = result.variableRows) !== null && _a !== void 0 ? _a : []; });
@@ -56,14 +56,14 @@ class ChromiumBrowserEngine {
56
56
  name() {
57
57
  return 'chromium';
58
58
  }
59
- getBrowserLaunchOptions(containerTesting, options, browserWidth, browserHeight, ignoreCertificateErrors, emulationConfig, enableExtensions, disableIsolation, resourcesDirectoryOverride) {
59
+ getBrowserLaunchOptions(options) {
60
60
  const commandLineArgs = [];
61
61
  const ignoreCommandLineDefaultArgs = [];
62
62
  const disableFeaturesFlags = [];
63
- if (containerTesting) {
63
+ if (options.containerTesting) {
64
64
  commandLineArgs.push('--no-sandbox');
65
65
  }
66
- if (disableIsolation) {
66
+ if (options.disableIsolation) {
67
67
  disableFeaturesFlags.push('IsolateOrigins');
68
68
  }
69
69
  disableFeaturesFlags.push('site-per-process');
@@ -71,35 +71,34 @@ class ChromiumBrowserEngine {
71
71
  if (options.autoOpenDevtoolsForTabs) {
72
72
  commandLineArgs.push('--auto-open-devtools-for-tabs');
73
73
  }
74
- const fakeMicrophoneMedia = (0, resourceUtil_1.findResource)('media/mabl_test_audio.wav', resourcesDirectoryOverride);
75
- const fakeWebcamMedia = (0, resourceUtil_1.findResource)('media/mabl_test_pattern.y4m', resourcesDirectoryOverride);
76
- const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig);
77
- this.addBasicLaunchArgs(commandLineArgs, browserWidth, browserHeight, fakeMicrophoneMedia, fakeWebcamMedia, ignoreCertificateErrors, defaultDeviceDescriptor);
78
- if (enableExtensions) {
74
+ const fakeMicrophoneMedia = (0, resourceUtil_1.findResource)('media/mabl_test_audio.wav', options.resourcesDirectoryOverride);
75
+ const fakeWebcamMedia = (0, resourceUtil_1.findResource)('media/mabl_test_pattern.y4m', options.resourcesDirectoryOverride);
76
+ const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig);
77
+ this.addBasicLaunchArgs(commandLineArgs, options.browserWidth, options.browserHeight, fakeMicrophoneMedia, fakeWebcamMedia, options.ignoreCertificateErrors, defaultDeviceDescriptor);
78
+ if (options.enableExtensions) {
79
79
  ignoreCommandLineDefaultArgs.push('--disable-extensions');
80
80
  }
81
81
  return {
82
82
  commandLineArgs,
83
- engineSpecificOptions: undefined,
84
83
  ignoreCommandLineDefaultArgs,
85
84
  defaultDeviceDescriptor,
86
85
  };
87
86
  }
88
- getExecutionEngineBrowserLaunchOptions(browserWidth, browserHeight, proxyInfo, emulationConfig) {
89
- const launchArgs = [...baseExecutionEngineLaunchArgs];
87
+ getExecutionEngineBrowserLaunchOptions(options, proxyInfo) {
88
+ const commandLineArgs = [...baseExecutionEngineLaunchArgs];
90
89
  if (proxyInfo.pacProxy) {
91
- launchArgs.push(`--proxy-pac-url=${proxyInfo.pacProxy}`);
90
+ commandLineArgs.push(`--proxy-pac-url=${proxyInfo.pacProxy}`);
92
91
  }
93
92
  else if (proxyInfo.socksProxy) {
94
- launchArgs.push(`--proxy-server=socks=${proxyInfo.socksProxy}`);
93
+ commandLineArgs.push(`--proxy-server=socks=${proxyInfo.socksProxy}`);
95
94
  }
96
95
  else {
97
96
  throw new Error('no proxy provided for cloud run');
98
97
  }
99
- const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig);
100
- this.addBasicLaunchArgs(launchArgs, browserWidth, browserHeight, ExecutionEngineFakeAudioFilePath, ExecutionEngineFakeVideoFilePath, true, defaultDeviceDescriptor);
101
- loggingProvider_1.logger.debug(`launchArgs: ${JSON.stringify(launchArgs)}`);
102
- return { defaultDeviceDescriptor, launchArgs };
98
+ const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig);
99
+ this.addBasicLaunchArgs(commandLineArgs, options.browserWidth, options.browserHeight, ExecutionEngineFakeAudioFilePath, ExecutionEngineFakeVideoFilePath, true, defaultDeviceDescriptor);
100
+ loggingProvider_1.logger.debug(`launchArgs: ${JSON.stringify(commandLineArgs)}`);
101
+ return { commandLineArgs, defaultDeviceDescriptor };
103
102
  }
104
103
  addBasicLaunchArgs(launchArgs, browserWidth, browserHeight, fakeMicrophoneMediaPath, fakeWebcamMediaPath, ignoreCertificateErrors, deviceDescriptor) {
105
104
  var _a, _b;
@@ -1,42 +1,75 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.FirefoxBrowserEngine = void 0;
7
30
  const mobileEmulationUtil_1 = require("../commands/tests/mobileEmulationUtil");
31
+ const path_1 = __importDefault(require("path"));
32
+ const fs = __importStar(require("fs-extra"));
8
33
  const browserEngine_1 = require("./browserEngine");
9
34
  const async_retry_1 = __importDefault(require("async-retry"));
10
- const browserTypes_1 = require("../commands/browserTypes");
11
35
  class FirefoxBrowserEngine {
12
36
  name() {
13
37
  return 'firefox';
14
38
  }
15
- getBrowserLaunchOptions(_containerTesting, _options, _browserWidth, _browserHeight, _ignoreCertificateErrors, emulationConfig, _enableExtensions, _disableIsolation, _resourcesDirectoryOverride) {
39
+ getBrowserLaunchOptions(options) {
16
40
  return {
17
41
  commandLineArgs: [],
18
- engineSpecificOptions: {
19
- browserType: browserTypes_1.BrowserType.Firefox,
20
- firefoxUserPrefs: this.getFirefoxUserPrefs(),
21
- },
22
42
  ignoreCommandLineDefaultArgs: [],
23
- defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig),
43
+ defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
24
44
  };
25
45
  }
26
- getExecutionEngineBrowserLaunchOptions(_browserWidth, _browserHeight, _proxyInfo, emulationConfig) {
46
+ getExecutionEngineBrowserLaunchOptions(options, _proxyInfo) {
27
47
  return {
28
- defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig),
29
- launchArgs: [],
48
+ commandLineArgs: [],
49
+ defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
30
50
  };
31
51
  }
32
52
  prepareBrowserPreferencesDirectory(_windowPlacement) {
33
- return (0, async_retry_1.default)(() => (0, browserEngine_1.getTempBrowserPrefDirectory)(this.name()), {
53
+ return (0, async_retry_1.default)(() => {
54
+ const preferenceFileName = 'user.js';
55
+ const tempBrowserPreferencesDirectory = (0, browserEngine_1.getTempBrowserPrefDirectory)(this.name());
56
+ const prefFilePath = path_1.default.normalize(`${tempBrowserPreferencesDirectory}/${preferenceFileName}`);
57
+ fs.writeFileSync(prefFilePath, this.generatePreferencesInfo());
58
+ return tempBrowserPreferencesDirectory;
59
+ }, {
34
60
  retries: 5,
35
61
  });
36
62
  }
37
63
  findBrowserExecutable() {
38
64
  return Promise.resolve('');
39
65
  }
66
+ generatePreferencesInfo() {
67
+ const lines = [];
68
+ for (const [name, value] of Object.entries(this.getFirefoxUserPrefs())) {
69
+ lines.push(`user_pref(${JSON.stringify(name)}, ${JSON.stringify(value)});`);
70
+ }
71
+ return lines.join('\n');
72
+ }
40
73
  getFirefoxUserPrefs() {
41
74
  return {
42
75
  'xpinstall.signatures.required': false,
@@ -6,15 +6,14 @@ class UnsupportedBrowserEngine {
6
6
  name() {
7
7
  throw new Error('Unsupported browser engine');
8
8
  }
9
- getBrowserLaunchOptions(_containerTesting, _options, _browserWidth, _browserHeight, _ignoreCertificateErrors, emulationConfig, _enableExtensions, _disableIsolation, _resourcesDirectoryOverride) {
9
+ getBrowserLaunchOptions(options) {
10
10
  return {
11
11
  commandLineArgs: [],
12
- engineSpecificOptions: undefined,
13
12
  ignoreCommandLineDefaultArgs: [],
14
- defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig),
13
+ defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
15
14
  };
16
15
  }
17
- getExecutionEngineBrowserLaunchOptions(_browserWidth, _browserHeight, _proxyInfo, _emulationConfig) {
16
+ getExecutionEngineBrowserLaunchOptions(_options, _proxyInfo) {
18
17
  throw new Error('Unsupported browser engine');
19
18
  }
20
19
  prepareBrowserPreferencesDirectory(_windowPlacement) {
@@ -51,5 +51,8 @@ class ChromiumBrowserDelegate {
51
51
  downloadsUsingGuids() {
52
52
  return false;
53
53
  }
54
+ supportsTracing() {
55
+ return true;
56
+ }
54
57
  }
55
58
  exports.ChromiumBrowserDelegate = ChromiumBrowserDelegate;
@@ -44,7 +44,7 @@ class ChromiumElementHandleDelegate {
44
44
  if (this.elementImpl === undefined) {
45
45
  (0, logUtils_1.logInternal)(`Unable to get the Element's internal implementation. Some functionality, such as getting the clickable point or element highlighting might not work.`);
46
46
  }
47
- else if (this.getCDPSession() === undefined) {
47
+ else if (this.getInternalCDPSession() === undefined) {
48
48
  const undefinedField = ((_b = (_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._context) === null || _b === void 0 ? void 0 : _b._delegate) !== undefined
49
49
  ? '_client'
50
50
  : ((_c = this.elementImpl) === null || _c === void 0 ? void 0 : _c._context) !== undefined
@@ -54,8 +54,11 @@ class ChromiumElementHandleDelegate {
54
54
  }
55
55
  }
56
56
  getCDPSession() {
57
- var _a, _b, _c;
58
57
  this.checkCDPSession();
58
+ return this.getInternalCDPSession();
59
+ }
60
+ getInternalCDPSession() {
61
+ var _a, _b, _c;
59
62
  return (_c = (_b = (_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._context) === null || _b === void 0 ? void 0 : _b._delegate) === null || _c === void 0 ? void 0 : _c._client;
60
63
  }
61
64
  }
@@ -47,5 +47,8 @@ class FirefoxBrowserDelegate {
47
47
  downloadsUsingGuids() {
48
48
  return true;
49
49
  }
50
+ supportsTracing() {
51
+ return false;
52
+ }
50
53
  }
51
54
  exports.FirefoxBrowserDelegate = FirefoxBrowserDelegate;
@@ -157,6 +157,9 @@ class PlaywrightBrowser extends events_1.default {
157
157
  exposeFunction(name, callback) {
158
158
  return this.defaultContext.exposeFunction(name, callback);
159
159
  }
160
+ supportsTracing() {
161
+ return this.browserDelegate.supportsTracing();
162
+ }
160
163
  }
161
164
  exports.PlaywrightBrowser = PlaywrightBrowser;
162
165
  function getBrowserDelegate(browserType, browserContext) {
@@ -35,7 +35,7 @@ class PlaywrightBrowserLauncher {
35
35
  const playwrightBrowserType = getPlaywrightBrowserType(options.browserType);
36
36
  const defaultContext = await playwrightBrowserType.launchPersistentContext(options.userDataDir, {
37
37
  acceptDownloads: true,
38
- args: options.args,
38
+ args: options.commandLineArgs,
39
39
  bypassCSP: options.bypassContentSecurityPolicy,
40
40
  channel: browserTypes_1.SupportedBrowserTypeProperties[options.browserType]
41
41
  .browserReleaseChannel,
@@ -46,7 +46,7 @@ class PlaywrightBrowserLauncher {
46
46
  hasTouch: (_b = options.defaultDeviceDescriptor) === null || _b === void 0 ? void 0 : _b.hasTouch,
47
47
  headless: options.headless,
48
48
  httpCredentials: options.credentials,
49
- ignoreDefaultArgs: options.ignoreDefaultArgs,
49
+ ignoreDefaultArgs: options.ignoreCommandLineDefaultArgs,
50
50
  ignoreHTTPSErrors: true,
51
51
  isMobile: (_c = options.defaultDeviceDescriptor) === null || _c === void 0 ? void 0 : _c.isMobile,
52
52
  logger: playwrightLogger,
@@ -77,7 +77,7 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
77
77
  this.cdpSession = delegate.getCDPSession();
78
78
  }
79
79
  catch (e) {
80
- (0, logUtils_1.logInternal)(`Unable to get the element handle's implementation. Error: ${e}`);
80
+ (0, logUtils_1.logInternal)(`Unable to get a CDP session for the element handle. Error: ${e}`);
81
81
  }
82
82
  }
83
83
  uploadFile(filePath) {
@@ -1,12 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.PlaywrightHttpRequest = void 0;
27
+ const playwright = __importStar(require("@playwright/test"));
28
+ const logUtils_1 = require("../../util/logUtils");
4
29
  class PlaywrightHttpRequest {
5
30
  constructor(page, request, route) {
31
+ var _a;
6
32
  this.page = page;
7
33
  this.request = request;
8
34
  this.route = route;
9
- this.documentId = this.request._guid;
35
+ try {
36
+ this.documentId = playwright._toImpl(this.request)._documentId;
37
+ }
38
+ catch (e) {
39
+ (0, logUtils_1.logInternal)(`Unable to get documentId from request: ${e.message}`);
40
+ }
41
+ (_a = this.documentId) !== null && _a !== void 0 ? _a : (this.documentId = this.request._guid);
10
42
  }
11
43
  abort() {
12
44
  var _a;
package/cli.js CHANGED
@@ -38,6 +38,7 @@ yargs
38
38
  .commandDir('./commands/branches')
39
39
  .commandDir('./commands/config')
40
40
  .commandDir('./commands/credentials')
41
+ .commandDir('./commands/datatables')
41
42
  .commandDir('./commands/deploy')
42
43
  .commandDir('./commands/environments')
43
44
  .commandDir('./commands/flows')
@@ -1,8 +1,15 @@
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
- exports.getListBuilderOptions = void 0;
6
+ exports.outputEntities = exports.getListBuilderOptions = void 0;
4
7
  const interfaces_1 = require("./interfaces");
5
8
  const constants_1 = require("../constants");
9
+ const loggingProvider_1 = require("../../providers/logging/loggingProvider");
10
+ const js_yaml_1 = require("js-yaml");
11
+ const cli_table3_1 = __importDefault(require("cli-table3"));
12
+ const moment = require("moment");
6
13
  function getListBuilderOptions(pluralEntityName) {
7
14
  return (yargs) => {
8
15
  yargs
@@ -28,3 +35,36 @@ function getListBuilderOptions(pluralEntityName) {
28
35
  };
29
36
  }
30
37
  exports.getListBuilderOptions = getListBuilderOptions;
38
+ function outputEntities(entities, outputMode) {
39
+ loggingProvider_1.logger.logNewLine();
40
+ let content;
41
+ switch (outputMode) {
42
+ case constants_1.OutputFormats.Json:
43
+ content = JSON.stringify(entities, null, 2);
44
+ break;
45
+ case constants_1.OutputFormats.Yaml:
46
+ content = (0, js_yaml_1.dump)(entities);
47
+ break;
48
+ default:
49
+ const table = new cli_table3_1.default({
50
+ head: ['ID', 'Name', 'Created time'],
51
+ wordWrap: true,
52
+ });
53
+ entities.forEach((entity) => {
54
+ table.push([
55
+ { rowSpan: 1, content: entity.id, vAlign: 'center' },
56
+ { rowSpan: 1, content: entity.name, vAlign: 'center' },
57
+ {
58
+ rowSpan: 1,
59
+ content: moment.utc(entity.created_time).format(constants_1.ListTimeFormat),
60
+ vAlign: 'center',
61
+ },
62
+ ]);
63
+ });
64
+ content = table.toString();
65
+ break;
66
+ }
67
+ loggingProvider_1.logger.info(content);
68
+ return content;
69
+ }
70
+ exports.outputEntities = outputEntities;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = 'datatables <command>';
4
+ exports.describe = 'Manage mabl datatables';
5
+ exports.builder = (yargs) => yargs.commandDir('datatables_cmds').demandCommand();
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
4
+ const constants_1 = require("../../constants");
5
+ const util_1 = require("../../commandUtil/util");
6
+ const describe_1 = require("../../commandUtil/describe");
7
+ exports.command = `describe <${constants_1.CommandArgId}>`;
8
+ exports.describe = 'Describe a specific mabl datatable';
9
+ exports.builder = (0, describe_1.getDescribeBuilderOptions)();
10
+ exports.handler = (0, util_1.failWrapper)(getDatatable);
11
+ async function getDatatable(parsed) {
12
+ const output = parsed.output;
13
+ const datatableId = parsed.id;
14
+ const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
15
+ const datatable = await apiClient.getDatatable(datatableId);
16
+ (0, describe_1.outputEntity)(datatable, output);
17
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dumpToCsv = void 0;
4
+ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
5
+ const util_1 = require("../../commandUtil/util");
6
+ const constants_1 = require("../../constants");
7
+ const fileUtil_1 = require("../../commandUtil/fileUtil");
8
+ const js_yaml_1 = require("js-yaml");
9
+ const csvUtil_1 = require("../../../util/csvUtil");
10
+ const sync_1 = require("csv-stringify/sync");
11
+ const SCENARIO_NAME_HEADER = 'Scenario name';
12
+ exports.command = `export <${constants_1.CommandArgId}>`;
13
+ exports.describe = 'Export a mabl test in a specified file format';
14
+ exports.builder = (yargs) => {
15
+ yargs
16
+ .positional(constants_1.CommandArgId, {
17
+ describe: 'Datatable id to export',
18
+ type: 'string',
19
+ })
20
+ .option(constants_1.CommandArgFormat, {
21
+ alias: 'fmt',
22
+ default: constants_1.OutputFormats.Yaml,
23
+ describe: `Specify a format for the datatable export`,
24
+ choices: [constants_1.OutputFormats.Json, constants_1.OutputFormats.Yaml, constants_1.OutputFormats.Csv],
25
+ });
26
+ };
27
+ exports.handler = (0, util_1.failWrapper)(exportDatatable);
28
+ async function exportDatatable(parsed) {
29
+ const datatableId = parsed.id;
30
+ const format = parsed.format;
31
+ const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
32
+ const datatableRows = await apiClient.getDatatableRows(datatableId);
33
+ let output = '';
34
+ switch (format) {
35
+ case constants_1.OutputFormats.Json:
36
+ output = dumpToJson(datatableRows);
37
+ break;
38
+ case constants_1.OutputFormats.Yaml:
39
+ output = dumpToYaml(datatableRows);
40
+ break;
41
+ case constants_1.OutputFormats.Csv:
42
+ output = dumpToCsv(datatableRows);
43
+ break;
44
+ }
45
+ (0, fileUtil_1.writeExportedEntityToFile)(output, format, datatableId);
46
+ }
47
+ function stripDatatableRows(datatableRows) {
48
+ return datatableRows.map((variableRow) => ({
49
+ scenario: variableRow.scenario_id,
50
+ columns: variableRow.row,
51
+ }));
52
+ }
53
+ function dumpToJson(datatableRows) {
54
+ return JSON.stringify(stripDatatableRows(datatableRows), null, 2);
55
+ }
56
+ function dumpToYaml(datatableRows) {
57
+ return (0, js_yaml_1.dump)(stripDatatableRows(datatableRows));
58
+ }
59
+ function dumpToCsv(datatableRows) {
60
+ const output = [];
61
+ if (datatableRows.length === 0) {
62
+ return '';
63
+ }
64
+ const headers = [
65
+ SCENARIO_NAME_HEADER,
66
+ ...(datatableRows[0].row || []).map((variable) => (0, csvUtil_1.sanitizeCellInput)(variable.name || '')),
67
+ ];
68
+ output.push(headers);
69
+ datatableRows.forEach(({ scenario_id = '', row = [] }) => {
70
+ const sanitizedRowValues = [
71
+ scenario_id,
72
+ ...row.map((variable) => variable.value || ''),
73
+ ].map(csvUtil_1.sanitizeCellInput);
74
+ output.push(sanitizedRowValues);
75
+ });
76
+ return (0, sync_1.stringify)(output);
77
+ }
78
+ exports.dumpToCsv = dumpToCsv;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
4
+ const util_1 = require("../../commandUtil/util");
5
+ const list_1 = require("../../commandUtil/list");
6
+ exports.command = 'list';
7
+ exports.describe = 'List your datatables';
8
+ exports.builder = (0, list_1.getListBuilderOptions)('datatables');
9
+ exports.handler = (0, util_1.failWrapper)(listDatatables);
10
+ async function listDatatables(parsed) {
11
+ const output = parsed.output;
12
+ const limit = parsed.limit;
13
+ const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
14
+ const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
15
+ const datatables = await apiClient.getDatatables(workspaceId, limit);
16
+ (0, list_1.outputEntities)(datatables, output);
17
+ return datatables.length;
18
+ }
@@ -51,8 +51,8 @@ function getFinalUrl(test, parsedUrl) {
51
51
  return finalUrl;
52
52
  }
53
53
  exports.getFinalUrl = getFinalUrl;
54
- async function launchBrowserInstance(engine, launchArgs, headless, credentials, options) {
55
- const userDataDir = await engine.prepareBrowserPreferencesDirectory(options.windowPlacement);
54
+ async function launchBrowserInstance(options) {
55
+ var _a;
56
56
  const optionsProxy = await maybeGetProxyOptions(options);
57
57
  if (optionsProxy) {
58
58
  options = {
@@ -62,13 +62,13 @@ async function launchBrowserInstance(engine, launchArgs, headless, credentials,
62
62
  }
63
63
  let browser;
64
64
  try {
65
- browser = await maybeLaunchBrowser(launchArgs, userDataDir, headless, credentials, options);
65
+ browser = await maybeLaunchBrowser(options);
66
66
  }
67
67
  catch (error) {
68
68
  if (error.message.includes('Running as root without --no-sandbox is not supported')) {
69
- launchArgs.push('--no-sandbox');
69
+ (_a = options.commandLineArgs) === null || _a === void 0 ? void 0 : _a.push('--no-sandbox');
70
70
  messaging_1.mablEventEmitter.log('Unable to initialize browser with standard settings, attempting to run with --no-sandbox setting', Date.now(), logLineMessaging_1.LogLineColor.yellow);
71
- return maybeLaunchBrowser(launchArgs, userDataDir, headless, credentials, options).catch((error) => {
71
+ return maybeLaunchBrowser(options).catch((error) => {
72
72
  messaging_1.mablEventEmitter.log('Browser launch failed', Date.now(), logLineMessaging_1.LogLineColor.red);
73
73
  messaging_1.mablEventEmitter.log(error.message);
74
74
  });
@@ -98,15 +98,8 @@ async function maybeGetProxyOptions(options) {
98
98
  }
99
99
  return optionsProxy;
100
100
  }
101
- function maybeLaunchBrowser(launchArgs, userDataDir, headless, credentials, options) {
102
- return browserLauncher_1.BrowserLauncherFactory.createRunner(options === null || options === void 0 ? void 0 : options.runnerType, options === null || options === void 0 ? void 0 : options.loggerFunc).launch({
103
- ...options,
104
- headless,
105
- args: launchArgs,
106
- userDataDir,
107
- downloadPath: createDownloadDirectory(),
108
- credentials,
109
- });
101
+ function maybeLaunchBrowser(options) {
102
+ return browserLauncher_1.BrowserLauncherFactory.createRunner(options === null || options === void 0 ? void 0 : options.runnerType, options === null || options === void 0 ? void 0 : options.loggerFunc).launch(options);
110
103
  }
111
104
  function removeTempBrowserPreferencesDirectory(tempDirPath) {
112
105
  try {
@@ -115,18 +108,14 @@ function removeTempBrowserPreferencesDirectory(tempDirPath) {
115
108
  catch (error) {
116
109
  }
117
110
  }
118
- async function createBrowser(engine, browserWidth, browserHeight, headless, containerTesting, options) {
119
- var _a;
120
- const { credentials, disableIsolation, ignoreCertificateErrors, emulationConfig, enableExtensions, resourcesDirectoryOverride, } = options || {};
121
- const { commandLineArgs: launchArgs, ignoreCommandLineDefaultArgs: ignoreDefaultArgs, defaultDeviceDescriptor, engineSpecificOptions, } = engine.getBrowserLaunchOptions(containerTesting, options, browserWidth, browserHeight, ignoreCertificateErrors, emulationConfig, enableExtensions, disableIsolation, resourcesDirectoryOverride);
122
- const maybeBrowser = await launchBrowserInstance(engine, launchArgs, headless, credentials, {
111
+ async function createBrowser(engine, options) {
112
+ const userDataDir = await engine.prepareBrowserPreferencesDirectory(options.windowPlacement);
113
+ const browserEngineLaunchOptions = engine.getBrowserLaunchOptions(options);
114
+ const maybeBrowser = await launchBrowserInstance({
123
115
  ...options,
124
- ...engineSpecificOptions,
125
- defaultDeviceDescriptor,
126
- ignoreDefaultArgs,
127
- userAgent: (_a = options === null || options === void 0 ? void 0 : options.userAgent) !== null && _a !== void 0 ? _a : emulationConfig === null || emulationConfig === void 0 ? void 0 : emulationConfig.device_config.user_agent,
128
- defaultUserAgent: options === null || options === void 0 ? void 0 : options.defaultUserAgent,
129
- windowPlacement: options.windowPlacement,
116
+ ...browserEngineLaunchOptions,
117
+ downloadPath: createDownloadDirectory(),
118
+ userDataDir,
130
119
  });
131
120
  if (!maybeBrowser) {
132
121
  throw new Error('Unable to start browser session');
@@ -135,20 +124,15 @@ async function createBrowser(engine, browserWidth, browserHeight, headless, cont
135
124
  return maybeBrowser;
136
125
  }
137
126
  exports.createBrowser = createBrowser;
138
- async function createBrowserForExecutionEngine(engine, browserWidth, browserHeight, headless, proxyInfo, options) {
139
- const tempBrowserPreferencesDirectory = await engine.prepareBrowserPreferencesDirectory();
140
- const { credentials, deviceEmulationConfig, userAgent } = options;
141
- if (deviceEmulationConfig && !userAgent) {
142
- options = {
143
- ...options,
144
- userAgent: deviceEmulationConfig.device_config.user_agent,
145
- };
146
- }
147
- const { launchArgs, defaultDeviceDescriptor } = engine.getExecutionEngineBrowserLaunchOptions(browserWidth, browserHeight, proxyInfo, deviceEmulationConfig);
148
- if (defaultDeviceDescriptor) {
149
- options = { ...options, defaultDeviceDescriptor };
150
- }
151
- const maybeBrowser = await maybeLaunchBrowser(launchArgs, tempBrowserPreferencesDirectory, headless, credentials, options);
127
+ async function createBrowserForExecutionEngine(engine, proxyInfo, options) {
128
+ const userDataDir = await engine.prepareBrowserPreferencesDirectory();
129
+ const launchOptions = engine.getExecutionEngineBrowserLaunchOptions(options, proxyInfo);
130
+ const maybeBrowser = await maybeLaunchBrowser({
131
+ ...options,
132
+ ...launchOptions,
133
+ downloadPath: createDownloadDirectory(),
134
+ userDataDir,
135
+ });
152
136
  if (!maybeBrowser) {
153
137
  throw new Error('Unable to start browser session');
154
138
  }