bdy 1.22.43-dev → 1.22.44-dev

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 (39) hide show
  1. package/distTs/package.json +3 -2
  2. package/distTs/src/api/client.js +73 -2
  3. package/distTs/src/cliIndex.js +2 -0
  4. package/distTs/src/command/artifact/get.js +16 -9
  5. package/distTs/src/command/artifact/list.js +23 -8
  6. package/distTs/src/command/artifact/version/get.js +20 -13
  7. package/distTs/src/command/artifact/version/list.js +19 -12
  8. package/distTs/src/command/distro/create.js +40 -0
  9. package/distTs/src/command/distro/delete.js +38 -0
  10. package/distTs/src/command/distro/list.js +42 -0
  11. package/distTs/src/command/distro/route/create.js +50 -0
  12. package/distTs/src/command/distro/route/delete.js +39 -0
  13. package/distTs/src/command/distro/route/list.js +54 -0
  14. package/distTs/src/command/distro/route.js +18 -0
  15. package/distTs/src/command/distro.js +23 -0
  16. package/distTs/src/command/domain/buy.js +27 -8
  17. package/distTs/src/command/domain/get.js +17 -11
  18. package/distTs/src/command/domain/list.js +13 -6
  19. package/distTs/src/command/login.js +1 -0
  20. package/distTs/src/command/pipeline/list.js +1 -1
  21. package/distTs/src/command/project/list.js +13 -6
  22. package/distTs/src/command/sandbox/app/list.js +13 -7
  23. package/distTs/src/command/sandbox/app/status.js +10 -4
  24. package/distTs/src/command/sandbox/endpoint/get.js +61 -52
  25. package/distTs/src/command/sandbox/endpoint/list.js +18 -12
  26. package/distTs/src/command/sandbox/exec/list.js +22 -16
  27. package/distTs/src/command/sandbox/exec/status.js +18 -9
  28. package/distTs/src/command/sandbox/get.js +26 -18
  29. package/distTs/src/command/sandbox/list.js +21 -15
  30. package/distTs/src/command/sandbox/snapshot/get.js +19 -13
  31. package/distTs/src/command/sandbox/snapshot/list.js +17 -11
  32. package/distTs/src/command/sandbox/status.js +11 -5
  33. package/distTs/src/command/whoami.js +17 -8
  34. package/distTs/src/command/workspace/list.js +14 -8
  35. package/distTs/src/input.js +180 -1
  36. package/distTs/src/output.js +16 -6
  37. package/distTs/src/texts.js +86 -6
  38. package/distTs/src/types/distro.js +232 -0
  39. package/package.json +3 -2
@@ -11,29 +11,35 @@ const commandSandboxList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_
11
11
  commandSandboxList.alias('ls');
12
12
  commandSandboxList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
13
  commandSandboxList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandSandboxList.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
15
  commandSandboxList.action(async (options) => {
15
16
  const workspace = input_1.default.restApiWorkspace(options.workspace);
16
17
  const project = input_1.default.restApiProject(options.project);
17
18
  const client = input_1.default.restApiTokenClient();
18
19
  const result = await client.listSandboxes(workspace, project);
19
20
  const sandboxes = result.sandboxes || [];
20
- if (sandboxes.length === 0) {
21
- output_1.default.exitNormal('No sandboxes found');
21
+ if (options.format === 'json') {
22
+ output_1.default.json(sandboxes);
22
23
  }
23
- const data = [
24
- ['NAME', 'STATUS', 'SETUP_STATUS', 'ID', 'IDENTIFIER', 'URL'],
25
- ];
26
- for (const sandbox of sandboxes) {
27
- data.push([
28
- sandbox.name || '-',
29
- sandbox.status || '-',
30
- sandbox.setup_status || '-',
31
- sandbox.id || '-',
32
- sandbox.identifier || '-',
33
- sandbox.html_url || '-',
34
- ]);
24
+ else {
25
+ if (sandboxes.length === 0) {
26
+ output_1.default.exitNormal('No sandboxes found');
27
+ }
28
+ const data = [
29
+ ['NAME', 'STATUS', 'SETUP_STATUS', 'ID', 'IDENTIFIER', 'URL'],
30
+ ];
31
+ for (const sandbox of sandboxes) {
32
+ data.push([
33
+ sandbox.name || '-',
34
+ sandbox.status || '-',
35
+ sandbox.setup_status || '-',
36
+ sandbox.id || '-',
37
+ sandbox.identifier || '-',
38
+ sandbox.html_url || '-',
39
+ ]);
40
+ }
41
+ output_1.default.table(data);
35
42
  }
36
- output_1.default.table(data);
37
43
  output_1.default.exitNormal();
38
44
  });
39
45
  exports.default = commandSandboxList;
@@ -10,6 +10,7 @@ const input_1 = __importDefault(require("../../../input"));
10
10
  const commandSandboxSnapshotGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_GET);
11
11
  commandSandboxSnapshotGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
12
  commandSandboxSnapshotGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandSandboxSnapshotGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandSandboxSnapshotGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
15
  commandSandboxSnapshotGet.argument('<snapshot-name>', texts_1.OPTION_SANDBOX_SNAPSHOT_NAME_ARG);
15
16
  commandSandboxSnapshotGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_SNAPSHOT_GET}`);
@@ -28,20 +29,25 @@ commandSandboxSnapshotGet.action(async (identifier, snapshotName, options) => {
28
29
  output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
29
30
  }
30
31
  const snapshot = await client.getSandboxSnapshot(workspace, sandbox_id, foundSnapshot.id);
31
- const data = [
32
- ['Field', 'Value'],
33
- ['Name', snapshot.name || '-'],
34
- ['Status', snapshot.status || '-'],
35
- ['Created', snapshot.create_date || '-'],
36
- ];
37
- if (snapshot.creator) {
38
- data.push([
39
- 'Creator',
40
- snapshot.creator.name || snapshot.creator.email || '-',
41
- ]);
32
+ if (options.format === 'json') {
33
+ output_1.default.json(snapshot);
34
+ }
35
+ else {
36
+ const data = [
37
+ ['Field', 'Value'],
38
+ ['Name', snapshot.name || '-'],
39
+ ['Status', snapshot.status || '-'],
40
+ ['Created', snapshot.create_date || '-'],
41
+ ];
42
+ if (snapshot.creator) {
43
+ data.push([
44
+ 'Creator',
45
+ snapshot.creator.name || snapshot.creator.email || '-',
46
+ ]);
47
+ }
48
+ data.push(['URL', snapshot.html_url]);
49
+ output_1.default.table(data);
42
50
  }
43
- data.push(['URL', snapshot.html_url]);
44
- output_1.default.table(data);
45
51
  output_1.default.exitNormal();
46
52
  });
47
53
  exports.default = commandSandboxSnapshotGet;
@@ -11,6 +11,7 @@ const commandSandboxSnapshotList = (0, utils_1.newCommand)('list', texts_1.DESC_
11
11
  commandSandboxSnapshotList.alias('ls');
12
12
  commandSandboxSnapshotList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
13
  commandSandboxSnapshotList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandSandboxSnapshotList.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
15
  commandSandboxSnapshotList.argument('[identifier]', texts_1.OPTION_SANDBOX_IDENTIFIER);
15
16
  commandSandboxSnapshotList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_SNAPSHOT_LIST}`);
16
17
  commandSandboxSnapshotList.action(async (identifier, options) => {
@@ -30,19 +31,24 @@ commandSandboxSnapshotList.action(async (identifier, options) => {
30
31
  const result = await client.listProjectSnapshots(workspace, project);
31
32
  snapshots = result.snapshots || [];
32
33
  }
33
- if (snapshots.length === 0) {
34
- output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOTS_NOT_FOUND);
34
+ if (options.format === 'json') {
35
+ output_1.default.json(snapshots);
35
36
  }
36
- const data = [['Name', 'Status', 'Created', 'URL']];
37
- for (const snapshot of snapshots) {
38
- data.push([
39
- snapshot.name || '-',
40
- snapshot.status || '-',
41
- snapshot.create_date || '-',
42
- snapshot.html_url || '-',
43
- ]);
37
+ else {
38
+ if (snapshots.length === 0) {
39
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOTS_NOT_FOUND);
40
+ }
41
+ const data = [['Name', 'Status', 'Created', 'URL']];
42
+ for (const snapshot of snapshots) {
43
+ data.push([
44
+ snapshot.name || '-',
45
+ snapshot.status || '-',
46
+ snapshot.create_date || '-',
47
+ snapshot.html_url || '-',
48
+ ]);
49
+ }
50
+ output_1.default.table(data);
44
51
  }
45
- output_1.default.table(data);
46
52
  output_1.default.exitNormal();
47
53
  });
48
54
  exports.default = commandSandboxSnapshotList;
@@ -10,6 +10,7 @@ const input_1 = __importDefault(require("../../input"));
10
10
  const commandSandboxStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_STATUS);
11
11
  commandSandboxStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
12
  commandSandboxStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandSandboxStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandSandboxStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
15
  commandSandboxStatus.action(async (identifier, options) => {
15
16
  const workspace = input_1.default.restApiWorkspace(options.workspace);
@@ -20,11 +21,16 @@ commandSandboxStatus.action(async (identifier, options) => {
20
21
  output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
21
22
  }
22
23
  const sandbox = await client.getSandbox(workspace, sandbox_id);
23
- output_1.default.table([
24
- ['Type', 'Status'],
25
- ['Status', sandbox.status || 'UNKNOWN'],
26
- ['Setup', sandbox.setup_status || 'UNKNOWN'],
27
- ]);
24
+ if (options.format === 'json') {
25
+ output_1.default.json(sandbox);
26
+ }
27
+ else {
28
+ output_1.default.table([
29
+ ['Type', 'Status'],
30
+ ['Status', sandbox.status || 'UNKNOWN'],
31
+ ['Setup', sandbox.setup_status || 'UNKNOWN'],
32
+ ]);
33
+ }
28
34
  output_1.default.exitNormal();
29
35
  });
30
36
  exports.default = commandSandboxStatus;
@@ -10,7 +10,8 @@ const output_1 = __importDefault(require("../output"));
10
10
  const input_1 = __importDefault(require("../input"));
11
11
  const cfg_2 = __importDefault(require("../project/cfg"));
12
12
  const commandWhoami = (0, utils_1.newCommand)('whoami', texts_1.DESC_COMMAND_WHOAMI);
13
- commandWhoami.action(async () => {
13
+ commandWhoami.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
+ commandWhoami.action(async (options) => {
14
15
  const workspace = cfg_1.default.getWorkspace();
15
16
  const localWorkspace = cfg_2.default.getWorkspace();
16
17
  const localProject = cfg_2.default.getProject();
@@ -20,27 +21,35 @@ commandWhoami.action(async () => {
20
21
  output_1.default.exitError(texts_1.ERR_WHOAMI_LOGOUT);
21
22
  }
22
23
  const email = await (0, utils_1.tryGetEmail)(client);
23
- output_1.default.normal(`User: ${user.name}${email ? ` (${email})` : ''}`);
24
+ const obj = {
25
+ 'User': `${user.name}${email ? ` (${email})` : ''}`
26
+ };
24
27
  if (localWorkspace) {
25
- output_1.default.normal(`Workspace: ${localWorkspace}`);
28
+ obj.Workspace = localWorkspace;
26
29
  }
27
30
  else {
28
- output_1.default.normal(`Workspace: ${!workspace ? texts_1.TXT_WHOAMI_NO_WORKSPACE : workspace}`);
31
+ obj.Workspace = !workspace ? texts_1.TXT_WHOAMI_NO_WORKSPACE : workspace;
29
32
  }
30
33
  if (localProject) {
31
- output_1.default.normal(`Project: ${localProject}`);
34
+ obj.Project = localProject;
32
35
  }
33
36
  const vtSuite = cfg_2.default.getVtSuite();
34
37
  const utSuite = cfg_2.default.getUtSuite();
35
38
  const crawlSuite = cfg_2.default.getCrawlSuite();
36
39
  if (vtSuite) {
37
- output_1.default.normal(`Visual test suite: ${vtSuite}`);
40
+ obj['Visual test suite'] = vtSuite;
38
41
  }
39
42
  if (utSuite) {
40
- output_1.default.normal(`Unit test suite: ${utSuite}`);
43
+ obj['Unit test suite'] = utSuite;
41
44
  }
42
45
  if (crawlSuite) {
43
- output_1.default.normal(`Crawl suite: ${crawlSuite}`);
46
+ obj['Crawl suite'] = crawlSuite;
47
+ }
48
+ if (options.format === 'json') {
49
+ output_1.default.json(obj);
50
+ }
51
+ else {
52
+ output_1.default.object(obj);
44
53
  }
45
54
  output_1.default.exitNormal();
46
55
  });
@@ -9,18 +9,24 @@ const utils_1 = require("../../utils");
9
9
  const input_1 = __importDefault(require("../../input"));
10
10
  const commandWorkspaceList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_WORKSPACE_LIST);
11
11
  commandWorkspaceList.alias('ls');
12
- commandWorkspaceList.action(async () => {
12
+ commandWorkspaceList.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
+ commandWorkspaceList.action(async (options) => {
13
14
  const client = input_1.default.restApiTokenClient();
14
15
  const response = await client.getWorkspaces();
15
- if (!response.workspaces || response.workspaces.length === 0) {
16
- output_1.default.normal('No workspaces found.');
17
- output_1.default.exitNormal();
16
+ if (options.format === 'json') {
17
+ output_1.default.json(response.workspaces || []);
18
18
  }
19
- const data = [['NAME', 'DOMAIN', 'URL']];
20
- for (const ws of response.workspaces) {
21
- data.push([ws.name, ws.domain, ws.html_url]);
19
+ else {
20
+ if (!response.workspaces || response.workspaces.length === 0) {
21
+ output_1.default.normal('No workspaces found.');
22
+ output_1.default.exitNormal();
23
+ }
24
+ const data = [['NAME', 'DOMAIN', 'URL']];
25
+ for (const ws of response.workspaces) {
26
+ data.push([ws.name, ws.domain, ws.html_url]);
27
+ }
28
+ output_1.default.table(data);
22
29
  }
23
- output_1.default.table(data);
24
30
  output_1.default.exitNormal();
25
31
  });
26
32
  exports.default = commandWorkspaceList;
@@ -50,6 +50,7 @@ const node_path_1 = __importStar(require("node:path"));
50
50
  const cfg_1 = __importDefault(require("./tunnel/cfg"));
51
51
  const uuid_1 = require("uuid");
52
52
  const sandbox_1 = require("./types/sandbox");
53
+ const distro_1 = require("./types/distro");
53
54
  class Input {
54
55
  static timeout(timeout) {
55
56
  const t = parseInt(timeout, 10);
@@ -341,11 +342,25 @@ class Input {
341
342
  const baseUrl = this.restApiBaseUrl(api, region, t);
342
343
  return new ApiClient(baseUrl, t, refreshToken, clientId, clientSecret, clientToken);
343
344
  }
345
+ static routeType(type) {
346
+ if (!type)
347
+ return distro_1.ROUTE_TYPE.PROXY;
348
+ if (Object.values(distro_1.ROUTE_TYPE).includes(type)) {
349
+ return type;
350
+ }
351
+ output_1.default.exitError(texts_1.ERR_COMMAND_ROUTE_TYPE);
352
+ }
353
+ static routePath(path) {
354
+ if (!path)
355
+ return '';
356
+ return path.replace(/^\/+/, '');
357
+ }
344
358
  static artifactType(type) {
345
359
  if (!type)
346
360
  return utils_1.ARTIFACT_TYPE.BUCKET;
347
- if (Object.values(utils_1.ARTIFACT_TYPE).includes(type))
361
+ if (Object.values(utils_1.ARTIFACT_TYPE).includes(type)) {
348
362
  return type;
363
+ }
349
364
  output_1.default.exitError(texts_1.ERR_COMMAND_ARTIFACT_TYPE);
350
365
  }
351
366
  static artifactScope(project) {
@@ -489,6 +504,154 @@ class Input {
489
504
  });
490
505
  return list;
491
506
  }
507
+ static async routeTarget(client, workspace, project, targetList) {
508
+ if (!targetList || !Array.isArray(targetList) || !targetList.length) {
509
+ output_1.default.exitError(texts_1.ERR_COMMAND_ROUTE_NO_TARGET);
510
+ }
511
+ const targets = {};
512
+ const SEP = '\x00';
513
+ for (let j = 0; j < targetList.length; j += 1) {
514
+ const str = targetList[j];
515
+ let type = null;
516
+ let url = '';
517
+ let artifact = '';
518
+ let sandbox = '';
519
+ let region = null;
520
+ const parts = str
521
+ .replace(/\\,/g, SEP)
522
+ .split(',')
523
+ .map((p) => p.split(SEP).join(','));
524
+ for (let i = 0; i < parts.length; i += 1) {
525
+ const p = parts[i];
526
+ const idx = p.indexOf('=');
527
+ if (idx < 0) {
528
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'No key=val delimiter'));
529
+ }
530
+ const key = p.substring(0, idx).trim();
531
+ const val = p.substring(idx + 1).trim();
532
+ if (key === 'url' && val) {
533
+ if (url || type !== null) {
534
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Param url defined twice'));
535
+ }
536
+ type = distro_1.ROUTE_TARGET_TYPE.EXTERNAL;
537
+ url = val;
538
+ }
539
+ else if (key === 'artifact' && val) {
540
+ if (artifact || type !== null) {
541
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Param artifact defined twice'));
542
+ }
543
+ type = distro_1.ROUTE_TARGET_TYPE.ARTIFACT;
544
+ artifact = val;
545
+ }
546
+ else if (key === 'sandbox' && val) {
547
+ if (sandbox || type !== null) {
548
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Param sandbox defined twice'));
549
+ }
550
+ type = distro_1.ROUTE_TARGET_TYPE.SANDBOX;
551
+ sandbox = val;
552
+ }
553
+ else if (key === 'region' && val) {
554
+ if (region) {
555
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Param region defined twice'));
556
+ }
557
+ const match = Object.values(distro_1.ROUTE_REGION).find((r) => r.toLowerCase() === val.toLowerCase());
558
+ if (match) {
559
+ region = match;
560
+ }
561
+ else {
562
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Wrong value of region'));
563
+ }
564
+ }
565
+ else {
566
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Unknown param'));
567
+ }
568
+ }
569
+ if (!type) {
570
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Unrecognized type'));
571
+ }
572
+ if (!region) {
573
+ region = distro_1.ROUTE_REGION.Default;
574
+ }
575
+ if (targets[region]) {
576
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Region already used by another target'));
577
+ }
578
+ let target;
579
+ if (type === distro_1.ROUTE_TARGET_TYPE.EXTERNAL) {
580
+ target = {
581
+ type,
582
+ external_url: url,
583
+ };
584
+ }
585
+ else if (type === distro_1.ROUTE_TARGET_TYPE.ARTIFACT) {
586
+ const idx = artifact.indexOf(':');
587
+ if (idx < 0) {
588
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'artifact wrong format (identifier:version)'));
589
+ }
590
+ const identifier = artifact.substring(0, idx).trim();
591
+ const version = artifact.substring(idx + 1).trim();
592
+ if (!identifier || !version) {
593
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'artifact wrong format (identifier:version)'));
594
+ }
595
+ let result = await client.getArtifactVersionByIdentifier(workspace, project, identifier, version);
596
+ if (!result.artifact_id && project) {
597
+ // try in workspace scope
598
+ result = await client.getArtifactVersionByIdentifier(workspace, null, identifier, version);
599
+ }
600
+ if (!result.domain) {
601
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, texts_1.ERR_WORKSPACE_NOT_FOUND));
602
+ }
603
+ if (!result.artifact_id) {
604
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, texts_1.ERR_ARTIFACT_NOT_FOUND));
605
+ }
606
+ if (!result.artifact_version_id) {
607
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, texts_1.ERR_ARTIFACT_VERSION_NOT_FOUND));
608
+ }
609
+ target = {
610
+ type,
611
+ artifact: {
612
+ id: result.artifact_id,
613
+ version_id: result.artifact_version_id,
614
+ },
615
+ };
616
+ }
617
+ else if (type === distro_1.ROUTE_TARGET_TYPE.SANDBOX) {
618
+ const idx = sandbox.indexOf(':');
619
+ if (idx < 0) {
620
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'sandbox wrong format (identifier:endpoint)'));
621
+ }
622
+ const identifier = sandbox.substring(0, idx).trim();
623
+ const endpoint = sandbox.substring(idx + 1).trim();
624
+ if (!identifier || !endpoint) {
625
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'sandbox wrong format (identifier:endpoint)'));
626
+ }
627
+ if (!project) {
628
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'sandbox target can be used only in project'));
629
+ }
630
+ const result = await client.getSandboxByIdentifier(workspace, project, identifier);
631
+ if (!result.domain) {
632
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, texts_1.ERR_WORKSPACE_NOT_FOUND));
633
+ }
634
+ if (!result.sandbox_id) {
635
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, texts_1.ERR_SANDBOX_NOT_FOUND));
636
+ }
637
+ target = {
638
+ type,
639
+ sandbox: {
640
+ id: result.sandbox_id,
641
+ endpoint: endpoint,
642
+ },
643
+ };
644
+ }
645
+ else {
646
+ output_1.default.exitError((0, texts_1.ERR_WRONG_ROUTE_TARGET)(str, 'Unknown target type'));
647
+ }
648
+ targets[region] = target;
649
+ }
650
+ if (!targets[distro_1.ROUTE_REGION.Default]) {
651
+ output_1.default.exitError(texts_1.ERR_ROUTE_NO_DEFAULT);
652
+ }
653
+ return targets;
654
+ }
492
655
  static sandboxFetch(fetchList) {
493
656
  const fetch = [];
494
657
  const SEP = '\x00';
@@ -872,6 +1035,22 @@ class Input {
872
1035
  output_1.default.exitError(texts_1.ERR_API_WRONG_METHOD);
873
1036
  return null;
874
1037
  }
1038
+ static distroScope(project, scope) {
1039
+ if (scope) {
1040
+ if (scope === distro_1.DISTRO_SCOPE.WORKSPACE) {
1041
+ return scope;
1042
+ }
1043
+ if (scope === distro_1.DISTRO_SCOPE.PROJECT) {
1044
+ if (!project)
1045
+ output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NO_PROJECT);
1046
+ return scope;
1047
+ }
1048
+ return output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_SCOPE);
1049
+ }
1050
+ if (project)
1051
+ return distro_1.DISTRO_SCOPE.PROJECT;
1052
+ return distro_1.DISTRO_SCOPE.WORKSPACE;
1053
+ }
875
1054
  static restApiProject(project, allowNull) {
876
1055
  const ProjectCfg = require('./project/cfg').default;
877
1056
  let p = process.env.BUDDY_PROJECT;
@@ -158,6 +158,14 @@ class Output {
158
158
  static cyan(txt, newLine = true) {
159
159
  this.normal(this.getCyanColor(txt), newLine);
160
160
  }
161
+ static identifier(identifier) {
162
+ Output.dim('Identifier: ', false);
163
+ Output.cyan(identifier);
164
+ }
165
+ static id(id) {
166
+ Output.dim('Id: ', false);
167
+ Output.cyan(id);
168
+ }
161
169
  static debug(txt) {
162
170
  const { debug } = require('./visualTest/context');
163
171
  if (debug) {
@@ -243,10 +251,10 @@ class Output {
243
251
  this.tunnelNonInteractive(tunnel);
244
252
  }
245
253
  static object(data) {
246
- const table = [['Field', 'Value'], ...Object.entries(data)];
247
- this.table(table);
254
+ const table = [...Object.entries(data)];
255
+ this.table(table, false);
248
256
  }
249
- static table(data) {
257
+ static table(data, firstRowBlue = true) {
250
258
  // apply padding
251
259
  for (let i = 0; i < data.length; i += 1) {
252
260
  for (let j = 0; j < data[i].length; j += 1) {
@@ -258,11 +266,13 @@ class Output {
258
266
  data[i][j] = tmp.join('\n');
259
267
  }
260
268
  }
261
- getTerminal().table(data, {
269
+ const opts = {
262
270
  fit: false,
263
271
  hasBorder: false,
264
- firstRowTextAttr: { color: 'blue' },
265
- });
272
+ };
273
+ if (firstRowBlue)
274
+ opts.firstRowTextAttr = { color: 'blue' };
275
+ getTerminal().table(data, opts);
266
276
  }
267
277
  static configTunnels(tunnels) {
268
278
  const OutputNoninteractiveConfigTunnels = require('./tunnel/output/noninteractive/config/tunnels').default;