bdy 1.16.11-dev → 1.16.11-sbs-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 (48) hide show
  1. package/distTs/package.json +4 -3
  2. package/distTs/src/api/client.js +78 -2
  3. package/distTs/src/command/login.js +280 -0
  4. package/distTs/src/command/logout.js +15 -0
  5. package/distTs/src/command/package/download.js +259 -0
  6. package/distTs/src/command/package/publish.js +231 -0
  7. package/distTs/src/command/package.js +14 -0
  8. package/distTs/src/command/project/list.js +61 -0
  9. package/distTs/src/command/project/set.js +85 -0
  10. package/distTs/src/command/project.js +14 -0
  11. package/distTs/src/command/sandbox/command/kill.js +35 -0
  12. package/distTs/src/command/sandbox/command/list.js +54 -0
  13. package/distTs/src/command/sandbox/command/logs.js +133 -0
  14. package/distTs/src/command/sandbox/command/status.js +44 -0
  15. package/distTs/src/command/sandbox/command.js +18 -0
  16. package/distTs/src/command/sandbox/cp.js +123 -0
  17. package/distTs/src/command/sandbox/create.js +99 -0
  18. package/distTs/src/command/sandbox/destroy.js +35 -0
  19. package/distTs/src/command/sandbox/endpoint/add.js +91 -0
  20. package/distTs/src/command/sandbox/endpoint/delete.js +46 -0
  21. package/distTs/src/command/sandbox/endpoint/get.js +58 -0
  22. package/distTs/src/command/sandbox/endpoint/list.js +51 -0
  23. package/distTs/src/command/sandbox/endpoint/update.js +85 -0
  24. package/distTs/src/command/sandbox/endpoint.js +20 -0
  25. package/distTs/src/command/sandbox/exec.js +127 -0
  26. package/distTs/src/command/sandbox/get.js +51 -0
  27. package/distTs/src/command/sandbox/list.js +41 -0
  28. package/distTs/src/command/sandbox/restart.js +49 -0
  29. package/distTs/src/command/sandbox/snapshot/create.js +68 -0
  30. package/distTs/src/command/sandbox/snapshot/delete.js +42 -0
  31. package/distTs/src/command/sandbox/snapshot/get.js +54 -0
  32. package/distTs/src/command/sandbox/snapshot/list.js +48 -0
  33. package/distTs/src/command/sandbox/snapshot.js +18 -0
  34. package/distTs/src/command/sandbox/start.js +49 -0
  35. package/distTs/src/command/sandbox/status.js +35 -0
  36. package/distTs/src/command/sandbox/stop.js +49 -0
  37. package/distTs/src/command/sandbox.js +36 -0
  38. package/distTs/src/command/workspace/list.js +57 -0
  39. package/distTs/src/command/workspace/set.js +81 -0
  40. package/distTs/src/command/workspace.js +14 -0
  41. package/distTs/src/index.js +10 -0
  42. package/distTs/src/input.js +15 -4
  43. package/distTs/src/texts.js +155 -1
  44. package/distTs/src/tunnel/cfg.js +38 -0
  45. package/package.json +4 -3
  46. package/distTs/src/command/agent/standalone/kill.js +0 -22
  47. package/distTs/src/command/agent/standalone.js +0 -136
  48. package/distTs/src/command/vt/scrap.js +0 -193
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const list_1 = __importDefault(require("./command/list"));
9
+ const status_1 = __importDefault(require("./command/status"));
10
+ const logs_1 = __importDefault(require("./command/logs"));
11
+ const kill_1 = __importDefault(require("./command/kill"));
12
+ const commandSandboxCommand = (0, utils_1.newCommand)('command', texts_1.DESC_COMMAND_SANDBOX_COMMAND);
13
+ commandSandboxCommand.alias('cmd');
14
+ commandSandboxCommand.addCommand(list_1.default);
15
+ commandSandboxCommand.addCommand(status_1.default);
16
+ commandSandboxCommand.addCommand(logs_1.default);
17
+ commandSandboxCommand.addCommand(kill_1.default);
18
+ exports.default = commandSandboxCommand;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const fdir_1 = require("fdir");
12
+ const fs_1 = require("fs");
13
+ const path_1 = require("path");
14
+ const commandSandboxCp = (0, utils_1.newCommand)('cp', texts_1.DESC_COMMAND_SANDBOX_CP);
15
+ commandSandboxCp.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
16
+ commandSandboxCp.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
17
+ commandSandboxCp.option('--region <region>', texts_1.OPTION_REST_API_REGION);
18
+ commandSandboxCp.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
19
+ commandSandboxCp.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
20
+ commandSandboxCp.option('-s, --silent', texts_1.OPTION_SANDBOX_CP_SILENT);
21
+ commandSandboxCp.argument('<source>', texts_1.OPTION_SANDBOX_CP_SOURCE);
22
+ commandSandboxCp.argument('<destination>', texts_1.OPTION_SANDBOX_CP_DEST);
23
+ function parseDestination(dest) {
24
+ const colonIndex = dest.indexOf(':');
25
+ if (colonIndex === -1 || colonIndex === 0) {
26
+ return null;
27
+ }
28
+ const identifier = dest.substring(0, colonIndex);
29
+ let remotePath = dest.substring(colonIndex + 1);
30
+ // Ensure remote path starts with /
31
+ if (!remotePath.startsWith('/')) {
32
+ remotePath = '/' + remotePath;
33
+ }
34
+ return { identifier, remotePath };
35
+ }
36
+ async function copyFileToSandbox(client, workspace, sandboxId, localPath, remotePath) {
37
+ const content = (0, fs_1.readFileSync)(localPath);
38
+ const base64 = content.toString('base64');
39
+ // Create parent directory if needed
40
+ const parentDir = (0, path_1.dirname)(remotePath);
41
+ if (parentDir !== '/') {
42
+ await client.executeSandboxCommand(workspace, sandboxId, {
43
+ command: `mkdir -p '${parentDir}'`,
44
+ });
45
+ }
46
+ // Transfer file using base64
47
+ // For files up to ~48KB encoded (fits in typical command line)
48
+ if (base64.length <= 65536) {
49
+ await client.executeSandboxCommand(workspace, sandboxId, {
50
+ command: `echo '${base64}' | base64 -d > '${remotePath}'`,
51
+ });
52
+ }
53
+ else {
54
+ // For larger files, use heredoc approach
55
+ await client.executeSandboxCommand(workspace, sandboxId, {
56
+ command: `base64 -d > '${remotePath}' << 'EOFBASE64'\n${base64}\nEOFBASE64`,
57
+ });
58
+ }
59
+ }
60
+ commandSandboxCp.action(async (source, destination, options) => {
61
+ const token = input_1.default.restApiToken(options.token);
62
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
63
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
64
+ const project = input_1.default.restApiProject(options.project);
65
+ const client = new client_1.default(baseUrl, token);
66
+ // Parse destination
67
+ const parsed = parseDestination(destination);
68
+ if (!parsed) {
69
+ output_1.default.exitError(texts_1.ERR_SANDBOX_CP_INVALID_DEST);
70
+ }
71
+ const { identifier, remotePath } = parsed;
72
+ // Validate source exists
73
+ const sourcePath = (0, path_1.resolve)(source);
74
+ if (!(0, fs_1.existsSync)(sourcePath)) {
75
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_SOURCE_NOT_FOUND)(source));
76
+ }
77
+ // Find sandbox by identifier
78
+ const result = await client.listSandboxes(workspace, project);
79
+ const sandboxes = result.sandboxes || [];
80
+ const found = sandboxes.find((s) => s.identifier === identifier);
81
+ if (!found) {
82
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
83
+ }
84
+ const stats = (0, fs_1.statSync)(sourcePath);
85
+ const silent = options.silent;
86
+ if (stats.isFile()) {
87
+ // Single file copy
88
+ if (!silent)
89
+ output_1.default.gray((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(1, 1, (0, path_1.basename)(sourcePath)));
90
+ await copyFileToSandbox(client, workspace, found.id, sourcePath, remotePath);
91
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(1));
92
+ }
93
+ else if (stats.isDirectory()) {
94
+ // Directory copy - get all files recursively
95
+ const files = new fdir_1.fdir()
96
+ .withFullPaths()
97
+ .crawl(sourcePath)
98
+ .sync();
99
+ if (files.length === 0) {
100
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(0));
101
+ }
102
+ if (!silent)
103
+ output_1.default.normal(`Copying ${files.length} file(s)...`);
104
+ for (let i = 0; i < files.length; i++) {
105
+ const localFile = files[i];
106
+ const relativePath = (0, path_1.relative)(sourcePath, localFile);
107
+ const remoteFile = (0, path_1.join)(remotePath, relativePath).replace(/\\/g, '/');
108
+ if (!silent)
109
+ output_1.default.gray((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(i + 1, files.length, relativePath));
110
+ try {
111
+ await copyFileToSandbox(client, workspace, found.id, localFile, remoteFile);
112
+ }
113
+ catch (err) {
114
+ output_1.default.error(`Failed to copy ${relativePath}: ${err.message || err}`);
115
+ }
116
+ }
117
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(files.length));
118
+ }
119
+ else {
120
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_SOURCE_NOT_FOUND)(source));
121
+ }
122
+ });
123
+ exports.default = commandSandboxCp;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const human_id_1 = __importDefault(require("human-id"));
12
+ const VALID_RESOURCES = ['1x2', '2x4', '3x6', '4x8', '5x10', '6x12', '7x14', '8x16', '9x18', '10x20', '11x22', '12x24', 'CUSTOM'];
13
+ const commandSandboxCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_SANDBOX_CREATE);
14
+ commandSandboxCreate.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
15
+ commandSandboxCreate.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
16
+ commandSandboxCreate.option('--region <region>', texts_1.OPTION_REST_API_REGION);
17
+ commandSandboxCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
18
+ commandSandboxCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
19
+ commandSandboxCreate.option('-n, --name <name>', texts_1.OPTION_SANDBOX_NAME);
20
+ commandSandboxCreate.option('-i, --identifier <identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
21
+ commandSandboxCreate.option('--os <image>', texts_1.OPTION_SANDBOX_OS);
22
+ commandSandboxCreate.option('--snapshot <snapshot-name>', texts_1.OPTION_SANDBOX_FROM_SNAPSHOT);
23
+ commandSandboxCreate.option('--resources <spec>', texts_1.OPTION_SANDBOX_RESOURCES);
24
+ commandSandboxCreate.option('--install-commands <commands...>', texts_1.OPTION_SANDBOX_INSTALL_COMMANDS);
25
+ commandSandboxCreate.option('--run-command <command>', texts_1.OPTION_SANDBOX_RUN_COMMAND);
26
+ commandSandboxCreate.action(async (options) => {
27
+ const token = input_1.default.restApiToken(options.token);
28
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
29
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
30
+ const project = input_1.default.restApiProject(options.project);
31
+ const client = new client_1.default(baseUrl, token);
32
+ // Validate resources if provided
33
+ if (options.resources && !VALID_RESOURCES.includes(options.resources)) {
34
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_INVALID_RESOURCES)(options.resources));
35
+ }
36
+ const defaultName = (0, human_id_1.default)({ separator: '-', capitalize: false });
37
+ const body = {
38
+ name: options.name || defaultName,
39
+ identifier: options.identifier || defaultName,
40
+ };
41
+ // Use snapshot_id if provided, otherwise use os
42
+ if (options.snapshot) {
43
+ // Find snapshot by name across all sandboxes
44
+ const sandboxesResult = await client.listSandboxes(workspace, project);
45
+ const sandboxes = sandboxesResult.sandboxes || [];
46
+ let foundSnapshotId = null;
47
+ for (const sandbox of sandboxes) {
48
+ const snapshotsResult = await client.listSandboxSnapshots(workspace, sandbox.id);
49
+ const snapshots = snapshotsResult.snapshots || [];
50
+ const foundSnapshot = snapshots.find((s) => s.name === options.snapshot);
51
+ if (foundSnapshot) {
52
+ foundSnapshotId = foundSnapshot.id;
53
+ break;
54
+ }
55
+ }
56
+ if (!foundSnapshotId) {
57
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
58
+ }
59
+ body.snapshot_id = foundSnapshotId;
60
+ }
61
+ else {
62
+ body.os = options.os || 'ubuntu:24.04';
63
+ }
64
+ if (options.resources) {
65
+ body.resources = options.resources;
66
+ }
67
+ if (options.installCommands) {
68
+ body.install_commands = options.installCommands.join('\n');
69
+ }
70
+ if (options.runCommand) {
71
+ body.run_command = options.runCommand;
72
+ }
73
+ output_1.default.normal(`Creating sandbox: ${body.name}`);
74
+ const result = await client.createSandbox(workspace, project, body);
75
+ const sandboxId = result.id;
76
+ // If already ready, exit immediately
77
+ if (result.setup_status === 'SUCCESS' || result.setup_status === 'DONE') {
78
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CREATED)(result.name, `${result.html_url}/terminal`));
79
+ }
80
+ // Wait for sandbox to be ready
81
+ output_1.default.normal(texts_1.TXT_SANDBOX_WAITING);
82
+ // Poll until setup_status is SUCCESS or FAILED (max 5 minutes)
83
+ const maxWaitMs = 5 * 60 * 1000;
84
+ const startTime = Date.now();
85
+ while (true) {
86
+ const sandbox = await client.getSandbox(workspace, sandboxId);
87
+ if (sandbox.setup_status === 'SUCCESS' || sandbox.setup_status === 'DONE') {
88
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CREATED)(sandbox.name, `${sandbox.html_url}/terminal`));
89
+ }
90
+ if (sandbox.setup_status === 'FAILED') {
91
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SETUP_FAILED);
92
+ }
93
+ if (Date.now() - startTime > maxWaitMs) {
94
+ output_1.default.exitError('Timeout waiting for sandbox setup');
95
+ }
96
+ await new Promise((resolve) => setTimeout(resolve, 2000));
97
+ }
98
+ });
99
+ exports.default = commandSandboxCreate;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxDestroy = (0, utils_1.newCommand)('destroy', texts_1.DESC_COMMAND_SANDBOX_DESTROY);
12
+ commandSandboxDestroy.alias('rm');
13
+ commandSandboxDestroy.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
14
+ commandSandboxDestroy.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
15
+ commandSandboxDestroy.option('--region <region>', texts_1.OPTION_REST_API_REGION);
16
+ commandSandboxDestroy.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
+ commandSandboxDestroy.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
+ commandSandboxDestroy.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
19
+ commandSandboxDestroy.action(async (identifier, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ // First list sandboxes to find by identifier
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ await client.deleteSandbox(workspace, found.id);
33
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_DESTROYED)(identifier));
34
+ });
35
+ exports.default = commandSandboxDestroy;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointAdd = (0, utils_1.newCommand)('add', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_ADD);
12
+ commandSandboxEndpointAdd.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointAdd.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointAdd.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointAdd.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointAdd.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointAdd.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointAdd.requiredOption('-n, --name <name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME);
19
+ commandSandboxEndpointAdd.requiredOption('--port <port>', texts_1.OPTION_SANDBOX_ENDPOINT_PORT);
20
+ commandSandboxEndpointAdd.option('-t, --type <type>', texts_1.OPTION_SANDBOX_ENDPOINT_TYPE, 'HTTP');
21
+ commandSandboxEndpointAdd.option('--ep-region <region>', texts_1.OPTION_SANDBOX_ENDPOINT_REGION);
22
+ commandSandboxEndpointAdd.option('--whitelist <cidrs...>', texts_1.OPTION_SANDBOX_ENDPOINT_WHITELIST);
23
+ commandSandboxEndpointAdd.option('--auth <type>', texts_1.OPTION_SANDBOX_ENDPOINT_AUTH);
24
+ commandSandboxEndpointAdd.option('--username <username>', texts_1.OPTION_SANDBOX_ENDPOINT_USERNAME);
25
+ commandSandboxEndpointAdd.option('--password <password>', texts_1.OPTION_SANDBOX_ENDPOINT_PASSWORD);
26
+ commandSandboxEndpointAdd.action(async (identifier, options) => {
27
+ const token = input_1.default.restApiToken(options.token);
28
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
29
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
30
+ const project = input_1.default.restApiProject(options.project);
31
+ const client = new client_1.default(baseUrl, token);
32
+ // Find sandbox by identifier
33
+ const result = await client.listSandboxes(workspace, project);
34
+ const sandboxes = result.sandboxes || [];
35
+ const found = sandboxes.find((s) => s.identifier === identifier);
36
+ if (!found) {
37
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
38
+ }
39
+ // Get current sandbox to get existing endpoints
40
+ const sandbox = await client.getSandbox(workspace, found.id);
41
+ const endpoints = sandbox.endpoints || [];
42
+ // Check if endpoint with this name already exists
43
+ const existing = endpoints.find((ep) => ep.name === options.name);
44
+ if (existing) {
45
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_ENDPOINT_EXISTS)(options.name));
46
+ }
47
+ // Create new endpoint
48
+ const newEndpoint = {
49
+ name: options.name,
50
+ endpoint: options.port,
51
+ type: options.type.toUpperCase(),
52
+ };
53
+ // Add optional fields only if provided
54
+ if (options.epRegion) {
55
+ newEndpoint.region = options.epRegion.toUpperCase();
56
+ }
57
+ if (options.whitelist) {
58
+ newEndpoint.whitelist = options.whitelist;
59
+ }
60
+ // Add HTTP-specific options (auth)
61
+ if (options.auth || options.username || options.password) {
62
+ newEndpoint.http = newEndpoint.http || {};
63
+ // Auto-set BASIC auth if username/password provided
64
+ if (options.username || options.password) {
65
+ newEndpoint.http.auth_type = 'BASIC';
66
+ if (options.username) {
67
+ newEndpoint.http.login = options.username;
68
+ }
69
+ if (options.password) {
70
+ newEndpoint.http.password = options.password;
71
+ }
72
+ }
73
+ else if (options.auth) {
74
+ newEndpoint.http.auth_type = options.auth.toUpperCase();
75
+ }
76
+ }
77
+ // Add the new endpoint to the list
78
+ const updatedEndpoints = [...endpoints, newEndpoint];
79
+ // Update sandbox with new endpoints list
80
+ const updatedSandbox = await client.updateSandbox(workspace, found.id, { endpoints: updatedEndpoints });
81
+ // Find the added endpoint to get its URL
82
+ const addedEndpoint = (updatedSandbox.endpoints || []).find((ep) => ep.name === options.name);
83
+ const url = addedEndpoint?.url;
84
+ if (url) {
85
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_ENDPOINT_ADDED)(options.name, url));
86
+ }
87
+ else {
88
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_ENDPOINT_ADDED)(options.name));
89
+ }
90
+ });
91
+ exports.default = commandSandboxEndpointAdd;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_DELETE);
12
+ commandSandboxEndpointDelete.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointDelete.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointDelete.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointDelete.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointDelete.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
19
+ commandSandboxEndpointDelete.action(async (identifier, endpointName, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ // Find sandbox by identifier
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ // Get current sandbox to get existing endpoints
33
+ const sandbox = await client.getSandbox(workspace, found.id);
34
+ const endpoints = sandbox.endpoints || [];
35
+ // Find endpoint by name
36
+ const endpointIndex = endpoints.findIndex((ep) => ep.name === endpointName);
37
+ if (endpointIndex === -1) {
38
+ output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
39
+ }
40
+ // Remove the endpoint from the list
41
+ const updatedEndpoints = endpoints.filter((ep) => ep.name !== endpointName);
42
+ // Update sandbox with new endpoints list
43
+ await client.updateSandbox(workspace, found.id, { endpoints: updatedEndpoints });
44
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_ENDPOINT_DELETED)(endpointName));
45
+ });
46
+ exports.default = commandSandboxEndpointDelete;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_GET);
12
+ commandSandboxEndpointGet.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointGet.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointGet.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointGet.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
19
+ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ // Find sandbox by identifier
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ // Get sandbox to find endpoint
33
+ const sandbox = await client.getSandbox(workspace, found.id);
34
+ const endpoints = sandbox.endpoints || [];
35
+ const endpoint = endpoints.find((ep) => ep.name === endpointName);
36
+ if (!endpoint) {
37
+ output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
38
+ }
39
+ const url = endpoint.url || '-';
40
+ const whitelist = endpoint.whitelist?.join(', ') || '-';
41
+ const authType = endpoint.http?.auth_type || '-';
42
+ const authLogin = endpoint.http?.login || '-';
43
+ const data = [
44
+ ['Property', 'Value'],
45
+ ['Name', endpoint.name || '-'],
46
+ ['Port', endpoint.endpoint || '-'],
47
+ ['Type', endpoint.type || '-'],
48
+ ['Region', endpoint.region || '-'],
49
+ ['URL', url],
50
+ ['Whitelist', whitelist],
51
+ ['Timeout', endpoint.timeout?.toString() || '-'],
52
+ ['Auth Type', authType],
53
+ ['Auth Login', authLogin],
54
+ ];
55
+ output_1.default.table(data);
56
+ output_1.default.exitNormal();
57
+ });
58
+ exports.default = commandSandboxEndpointGet;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_LIST);
12
+ commandSandboxEndpointList.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointList.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointList.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointList.action(async (identifier, options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ // Find sandbox by identifier
25
+ const result = await client.listSandboxes(workspace, project);
26
+ const sandboxes = result.sandboxes || [];
27
+ const found = sandboxes.find((s) => s.identifier === identifier);
28
+ if (!found) {
29
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
30
+ }
31
+ const sandbox = await client.getSandbox(workspace, found.id);
32
+ const endpoints = sandbox.endpoints || [];
33
+ if (endpoints.length === 0) {
34
+ output_1.default.normal('No endpoints found');
35
+ output_1.default.exitNormal();
36
+ }
37
+ const data = [['Name', 'Port', 'Type', 'Region', 'URL']];
38
+ for (const ep of endpoints) {
39
+ const url = ep.url || '-';
40
+ data.push([
41
+ ep.name || '-',
42
+ ep.endpoint || '-',
43
+ ep.type || '-',
44
+ ep.region || '-',
45
+ url,
46
+ ]);
47
+ }
48
+ output_1.default.table(data);
49
+ output_1.default.exitNormal();
50
+ });
51
+ exports.default = commandSandboxEndpointList;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_UPDATE);
12
+ commandSandboxEndpointUpdate.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointUpdate.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointUpdate.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointUpdate.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointUpdate.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
19
+ commandSandboxEndpointUpdate.option('--port <port>', texts_1.OPTION_SANDBOX_ENDPOINT_PORT);
20
+ commandSandboxEndpointUpdate.option('-t, --type <type>', texts_1.OPTION_SANDBOX_ENDPOINT_TYPE);
21
+ commandSandboxEndpointUpdate.option('--ep-region <region>', texts_1.OPTION_SANDBOX_ENDPOINT_REGION);
22
+ commandSandboxEndpointUpdate.option('--whitelist <cidrs...>', texts_1.OPTION_SANDBOX_ENDPOINT_WHITELIST);
23
+ commandSandboxEndpointUpdate.option('--auth <type>', texts_1.OPTION_SANDBOX_ENDPOINT_AUTH);
24
+ commandSandboxEndpointUpdate.option('--username <username>', texts_1.OPTION_SANDBOX_ENDPOINT_USERNAME);
25
+ commandSandboxEndpointUpdate.option('--password <password>', texts_1.OPTION_SANDBOX_ENDPOINT_PASSWORD);
26
+ commandSandboxEndpointUpdate.action(async (identifier, endpointName, options) => {
27
+ const token = input_1.default.restApiToken(options.token);
28
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
29
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
30
+ const project = input_1.default.restApiProject(options.project);
31
+ const client = new client_1.default(baseUrl, token);
32
+ // Find sandbox by identifier
33
+ const result = await client.listSandboxes(workspace, project);
34
+ const sandboxes = result.sandboxes || [];
35
+ const found = sandboxes.find((s) => s.identifier === identifier);
36
+ if (!found) {
37
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
38
+ }
39
+ // Get current sandbox to get existing endpoints
40
+ const sandbox = await client.getSandbox(workspace, found.id);
41
+ const endpoints = sandbox.endpoints || [];
42
+ // Find endpoint by name
43
+ const endpointIndex = endpoints.findIndex((ep) => ep.name === endpointName);
44
+ if (endpointIndex === -1) {
45
+ output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
46
+ }
47
+ // Update endpoint with provided values
48
+ const endpoint = { ...endpoints[endpointIndex] };
49
+ if (options.port) {
50
+ endpoint.endpoint = options.port;
51
+ }
52
+ if (options.type) {
53
+ endpoint.type = options.type.toUpperCase();
54
+ }
55
+ if (options.epRegion) {
56
+ endpoint.region = options.epRegion.toUpperCase();
57
+ }
58
+ if (options.whitelist) {
59
+ endpoint.whitelist = options.whitelist;
60
+ }
61
+ // Update HTTP-specific options (auth)
62
+ if (options.auth || options.username || options.password) {
63
+ endpoint.http = endpoint.http || {};
64
+ // Auto-set BASIC auth if username/password provided
65
+ if (options.username || options.password) {
66
+ endpoint.http.auth_type = 'BASIC';
67
+ if (options.username) {
68
+ endpoint.http.login = options.username;
69
+ }
70
+ if (options.password) {
71
+ endpoint.http.password = options.password;
72
+ }
73
+ }
74
+ else if (options.auth) {
75
+ endpoint.http.auth_type = options.auth.toUpperCase();
76
+ }
77
+ }
78
+ // Replace endpoint in the list
79
+ const updatedEndpoints = [...endpoints];
80
+ updatedEndpoints[endpointIndex] = endpoint;
81
+ // Update sandbox with new endpoints list
82
+ await client.updateSandbox(workspace, found.id, { endpoints: updatedEndpoints });
83
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_ENDPOINT_UPDATED)(endpointName));
84
+ });
85
+ exports.default = commandSandboxEndpointUpdate;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const list_1 = __importDefault(require("./endpoint/list"));
9
+ const get_1 = __importDefault(require("./endpoint/get"));
10
+ const add_1 = __importDefault(require("./endpoint/add"));
11
+ const update_1 = __importDefault(require("./endpoint/update"));
12
+ const delete_1 = __importDefault(require("./endpoint/delete"));
13
+ const commandSandboxEndpoint = (0, utils_1.newCommand)('endpoint', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT);
14
+ commandSandboxEndpoint.alias('ep');
15
+ commandSandboxEndpoint.addCommand(list_1.default);
16
+ commandSandboxEndpoint.addCommand(get_1.default);
17
+ commandSandboxEndpoint.addCommand(add_1.default);
18
+ commandSandboxEndpoint.addCommand(update_1.default);
19
+ commandSandboxEndpoint.addCommand(delete_1.default);
20
+ exports.default = commandSandboxEndpoint;