bdy 1.16.30-dev → 1.16.32-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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.16.30-dev",
4
+ "version": "1.16.32-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -29,6 +29,10 @@
29
29
  "cookie": "1.0.2",
30
30
  "cross-spawn": "7.0.6",
31
31
  "eventsource": "4.0.0",
32
+ "@scalar/openapi-parser": "0.24.5",
33
+ "@scalar/json-magic": "0.9.4",
34
+ "@scalar/types": "0.5.10",
35
+ "@scalar/openapi-types": "0.5.3",
32
36
  "fastify": "4.28.1",
33
37
  "fdir": "6.5.0",
34
38
  "open": "11.0.0",
@@ -0,0 +1,268 @@
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 input_1 = __importDefault(require("../../input"));
9
+ const output_1 = __importDefault(require("../../output"));
10
+ var SCHEMA_TYPE;
11
+ (function (SCHEMA_TYPE) {
12
+ SCHEMA_TYPE["OBJECT"] = "object";
13
+ SCHEMA_TYPE["ARRAY"] = "array";
14
+ })(SCHEMA_TYPE || (SCHEMA_TYPE = {}));
15
+ const getRequiredScopes = (data) => {
16
+ if (data.security && data.security[0] && data.security[0].oauth2) {
17
+ return data.security[0].oauth2;
18
+ }
19
+ return [];
20
+ };
21
+ const getParameterType = (p) => {
22
+ if (p.schema && p.schema.type) {
23
+ return p.schema.type;
24
+ }
25
+ return 'string';
26
+ };
27
+ const outputParameters = (type, data, workspace, project) => {
28
+ const table = [];
29
+ (data.parameters || []).forEach((p) => {
30
+ if (p.in === type) {
31
+ let example = '-';
32
+ if (p.name === 'workspace_domain')
33
+ example = workspace;
34
+ else if (p.name === 'project_name' && project)
35
+ example = project;
36
+ else if (p.schema && p.schema.example)
37
+ example = p.schema.example;
38
+ table.push([
39
+ p.name || '-',
40
+ getParameterType(p),
41
+ example.toString(),
42
+ p.description || '-',
43
+ ]);
44
+ }
45
+ });
46
+ if (table.length > 0) {
47
+ table.unshift([
48
+ type === 'path' ? 'URL param' : 'Query param',
49
+ 'Type',
50
+ 'Example',
51
+ 'Description',
52
+ ]);
53
+ output_1.default.table(table);
54
+ output_1.default.normal('');
55
+ }
56
+ };
57
+ const outputTextWithPadding = (text, padding = 1, newLine = true) => {
58
+ let t = '';
59
+ for (let i = 0; i < padding; i += 1)
60
+ t += ' ';
61
+ t += text;
62
+ output_1.default.normal(t, newLine);
63
+ };
64
+ const outputSimpleProp = (name, type, description, enu, required, padding) => {
65
+ outputTextWithPadding(name, padding, false);
66
+ output_1.default.gray(`: ${type}`, false);
67
+ if (required)
68
+ output_1.default.gray(' (required)', false);
69
+ if (description)
70
+ output_1.default.gray(` - ${description}`, false);
71
+ if (enu && enu.length)
72
+ output_1.default.gray(` - ${enu.join(', ')}`, false);
73
+ output_1.default.normal('');
74
+ };
75
+ const outputJsonArrayProp = (data, padding, name, required) => {
76
+ if (name) {
77
+ outputTextWithPadding(name, padding, false);
78
+ output_1.default.gray(`: ${SCHEMA_TYPE.ARRAY}`, false);
79
+ if (required)
80
+ output_1.default.gray(' (required)', false);
81
+ if (data.description)
82
+ output_1.default.gray(` - ${data.description}`, false);
83
+ output_1.default.normal('');
84
+ }
85
+ outputTextWithPadding('[', padding);
86
+ if (data.items.type === SCHEMA_TYPE.OBJECT)
87
+ outputJsonObject(data.items, padding + 2);
88
+ else if (data.items.type === SCHEMA_TYPE.ARRAY)
89
+ outputJsonArrayProp(data.items, padding + 2);
90
+ else
91
+ outputSimpleProp('item', data.items.type, data.items.description, data.items.enum, false, padding + 2);
92
+ outputTextWithPadding(']', padding);
93
+ };
94
+ const outputJsonObject = (data, padding = 1, name, required) => {
95
+ const propsRequired = data.required || [];
96
+ const props = data.properties || {};
97
+ if (name) {
98
+ outputTextWithPadding(name, padding, false);
99
+ output_1.default.gray(` : ${SCHEMA_TYPE.OBJECT}`, false);
100
+ if (required)
101
+ output_1.default.gray(' (required)', false);
102
+ if (data.description)
103
+ output_1.default.gray(` - ${data.description}`, false);
104
+ output_1.default.normal('');
105
+ }
106
+ outputTextWithPadding('{', padding);
107
+ const keys = Object.keys(props);
108
+ if (keys.length > 0) {
109
+ keys.forEach((name) => {
110
+ const prop = props[name];
111
+ if (prop.type === SCHEMA_TYPE.ARRAY)
112
+ outputJsonArrayProp(prop, padding + 2, name, propsRequired.includes(name));
113
+ else if (prop.type === SCHEMA_TYPE.OBJECT)
114
+ outputJsonObject(prop, padding + 2, name, propsRequired.includes(name));
115
+ else
116
+ outputSimpleProp(name, prop.type, prop.description, prop.enum, propsRequired.includes(name), padding + 2);
117
+ });
118
+ }
119
+ else if (data.additionalProperties) {
120
+ outputTextWithPadding('key: value', padding + 2, false);
121
+ if (data.additionalProperties.description)
122
+ output_1.default.gray(` - ${data.additionalProperties.description}`, false);
123
+ output_1.default.normal('');
124
+ }
125
+ outputTextWithPadding('}', padding);
126
+ };
127
+ const outputMultipartBinary = (name, array, description, required, padding) => {
128
+ outputTextWithPadding(name, padding, false);
129
+ output_1.default.gray(array ? ': binary array' : ': binary', false);
130
+ if (required)
131
+ output_1.default.gray(' (required)', false);
132
+ if (description)
133
+ output_1.default.gray(` - ${description}`, false);
134
+ output_1.default.normal('');
135
+ };
136
+ const outputMultipartFormData = (data, padding = 1) => {
137
+ const propsRequired = data.required || [];
138
+ const props = data.properties || {};
139
+ const keys = Object.keys(props);
140
+ if (keys.length > 0) {
141
+ keys.forEach((name) => {
142
+ const prop = props[name];
143
+ if (prop.format === 'binary')
144
+ outputMultipartBinary(name, prop.type === 'array', prop.description, propsRequired.includes(name), padding);
145
+ else if (prop.type === SCHEMA_TYPE.ARRAY)
146
+ output_1.default.exitError(texts_1.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED);
147
+ else if (prop.type === SCHEMA_TYPE.OBJECT)
148
+ output_1.default.exitError(texts_1.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED);
149
+ else
150
+ outputSimpleProp(name, prop.type, prop.description, prop.enum, propsRequired.includes(name), padding);
151
+ });
152
+ }
153
+ };
154
+ const outputBodyObject = (mediaType, data) => {
155
+ if (mediaType === 'multipart/form-data') {
156
+ outputMultipartFormData(data);
157
+ }
158
+ else if (['application/json', 'application/jsonl'].includes(mediaType)) {
159
+ outputJsonObject(data);
160
+ }
161
+ else {
162
+ output_1.default.exitError((0, texts_1.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED)(mediaType));
163
+ }
164
+ };
165
+ const outputResponse = (response) => {
166
+ const content = response.content || {};
167
+ Object.keys(content).forEach((mediaType, index) => {
168
+ if (index > 0) {
169
+ output_1.default.gray(' ------- or content type -------');
170
+ }
171
+ outputMediaType(mediaType, content[mediaType]);
172
+ });
173
+ };
174
+ const outputResponsesBody = (responses) => {
175
+ const r = responses || {};
176
+ const codes = Object.keys(r);
177
+ if (codes.length > 0) {
178
+ output_1.default.blue(` Response body`);
179
+ codes.forEach((code, index) => {
180
+ if (index > 0) {
181
+ output_1.default.gray(' ------------');
182
+ }
183
+ output_1.default.gray(' http status: ', false);
184
+ output_1.default.normal(code);
185
+ outputResponse(r[code]);
186
+ });
187
+ }
188
+ };
189
+ const outputMediaType = (mediaType, mediaTypeObject) => {
190
+ output_1.default.gray(' content-type: ', false);
191
+ output_1.default.normal(mediaType);
192
+ if (mediaTypeObject.schema) {
193
+ if (mediaTypeObject.schema.oneOf) {
194
+ const mappings = Object.keys(mediaTypeObject.schema.discriminator?.mapping || {});
195
+ mediaTypeObject.schema.oneOf.forEach((schema, index) => {
196
+ if (mappings[index]) {
197
+ output_1.default.gray(` ${mappings[index]}:`);
198
+ }
199
+ else if (index > 0) {
200
+ output_1.default.gray(' ------------- or --------------');
201
+ }
202
+ outputBodyObject(mediaType, schema);
203
+ });
204
+ }
205
+ else {
206
+ outputBodyObject(mediaType, mediaTypeObject.schema);
207
+ }
208
+ }
209
+ };
210
+ const outputRequestBody = (data) => {
211
+ if (data) {
212
+ output_1.default.blue(` Request body`);
213
+ const content = data.content || {};
214
+ Object.keys(content).forEach((mediaType, index) => {
215
+ if (index > 0) {
216
+ output_1.default.gray(' ------- or content type -------');
217
+ }
218
+ outputMediaType(mediaType, content[mediaType]);
219
+ });
220
+ output_1.default.normal('');
221
+ }
222
+ };
223
+ const outputUrl = (url, method, data, workspace, project) => {
224
+ output_1.default.normal(`${method} ${url}`);
225
+ if (data.summary)
226
+ output_1.default.gray(data.summary, false);
227
+ const scopes = getRequiredScopes(data);
228
+ if (scopes.length > 0) {
229
+ if (data.summary)
230
+ output_1.default.gray('. ', false);
231
+ output_1.default.gray(`${texts_1.TXT_API_ENDPOINT_REQUIRED_SCOPES}: `, false);
232
+ output_1.default.gray(scopes.join(', '), false);
233
+ }
234
+ output_1.default.normal('\n');
235
+ outputParameters('path', data, workspace, project);
236
+ outputParameters('query', data, workspace, project);
237
+ outputRequestBody(data.requestBody);
238
+ outputResponsesBody(data.responses);
239
+ output_1.default.exitNormal();
240
+ };
241
+ const commandApiInfo = (0, utils_1.newCommand)('info', texts_1.DESC_COMMAND_API_INFO);
242
+ commandApiInfo.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
243
+ commandApiInfo.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
244
+ commandApiInfo.option('--region <region>', texts_1.OPTION_REST_API_REGION);
245
+ commandApiInfo.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
246
+ commandApiInfo.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
247
+ commandApiInfo.argument('<method>', texts_1.OPT_COMMAND_API_INFO_METHOD);
248
+ commandApiInfo.argument('<url>', texts_1.OPT_COMMAND_API_INFO_URL);
249
+ commandApiInfo.action(async (fm, filterUrl, options) => {
250
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
251
+ const project = input_1.default.restApiProject(options.project, true);
252
+ const filterMethod = input_1.default.restApiMethod(fm, false);
253
+ const client = input_1.default.restApiTokenClient(options.api, options.region, options.token);
254
+ const schema = await (0, utils_1.fetchOpenApiSchema)(client.baseUrl);
255
+ const paths = schema.paths || {};
256
+ Object.keys(paths).forEach((url) => {
257
+ const preparedUrl = (0, utils_1.openApiPrepareUrl)(url, workspace, project);
258
+ if (filterUrl === url || filterUrl === preparedUrl) {
259
+ const methods = paths[url] || {};
260
+ Object.entries(methods).forEach(([method, data]) => {
261
+ if (filterMethod === method)
262
+ outputUrl(preparedUrl, method, data, workspace, project);
263
+ });
264
+ }
265
+ });
266
+ output_1.default.exitError(texts_1.ERR_API_ENDPOINT_NOT_FOUND);
267
+ });
268
+ exports.default = commandApiInfo;
@@ -0,0 +1,43 @@
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 input_1 = __importDefault(require("../../input"));
9
+ const output_1 = __importDefault(require("../../output"));
10
+ const outputUrl = (url, method, data, workspace, project) => {
11
+ output_1.default.normal(`${method} ${(0, utils_1.openApiPrepareUrl)(url, workspace, project)}`);
12
+ if (data.summary)
13
+ output_1.default.gray(data.summary);
14
+ };
15
+ const commandApiList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_API_LIST);
16
+ commandApiList.alias('ls');
17
+ commandApiList.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
18
+ commandApiList.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
19
+ commandApiList.option('--region <region>', texts_1.OPTION_REST_API_REGION);
20
+ commandApiList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
21
+ commandApiList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
22
+ commandApiList.option('-m, --method <method>', texts_1.OPT_COMMAND_API_LIST_METHOD);
23
+ commandApiList.option('-s, --search <phrase>', texts_1.OPT_COMMAND_API_LIST_SEARCH);
24
+ commandApiList.action(async (options) => {
25
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
26
+ const project = input_1.default.restApiProject(options.project, true);
27
+ const filterMethod = input_1.default.restApiMethod(options.method);
28
+ const filter = options.search;
29
+ const client = input_1.default.restApiTokenClient(options.api, options.region, options.token);
30
+ const schema = await (0, utils_1.fetchOpenApiSchema)(client.baseUrl);
31
+ const paths = schema.paths || {};
32
+ Object.keys(paths).forEach((url) => {
33
+ if (!filter || url.includes(filter)) {
34
+ const methods = paths[url] || {};
35
+ Object.entries(methods).forEach(([method, data]) => {
36
+ if (!filterMethod || filterMethod === method)
37
+ outputUrl(url, method, data, workspace, project);
38
+ });
39
+ }
40
+ });
41
+ output_1.default.exitNormal();
42
+ });
43
+ exports.default = commandApiList;
@@ -0,0 +1,13 @@
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("./api/list"));
9
+ const info_1 = __importDefault(require("./api/info"));
10
+ const commandApi = (0, utils_1.newCommand)('api', texts_1.DESC_COMMAND_API);
11
+ commandApi.addCommand(list_1.default);
12
+ commandApi.addCommand(info_1.default);
13
+ exports.default = commandApi;
@@ -25,7 +25,7 @@ commandSandboxCp.argument('<destination>', texts_1.OPTION_SANDBOX_CP_DEST);
25
25
  commandSandboxCp.addHelpText('after', texts_1.EXAMPLE_SANDBOX_CP);
26
26
  const upload = async (client, workspace, project, source, destination) => {
27
27
  const { sourcePath, sourceStats } = input_1.default.restApiSandboxUploadSourcePath(source);
28
- const { identifier, remotePath } = input_1.default.restApiSandboxUploadDestinationPath(destination);
28
+ const { identifier, remotePath, isRemoteDir } = input_1.default.restApiSandboxUploadDestinationPath(destination);
29
29
  const result = await client.listSandboxes(workspace, project);
30
30
  const sandboxes = result.sandboxes || [];
31
31
  const found = sandboxes.find((s) => s.identifier === identifier);
@@ -36,7 +36,7 @@ const upload = async (client, workspace, project, source, destination) => {
36
36
  // Single file copy
37
37
  const name = (0, path_1.basename)(sourcePath);
38
38
  output_1.default.normal((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(1, 1, name));
39
- const remoteFile = (0, path_1.join)(remotePath, name);
39
+ const remoteFile = isRemoteDir ? (0, path_1.join)(remotePath, name) : remotePath;
40
40
  await client.sandboxUploadFile(workspace, found.id, remoteFile, sourcePath);
41
41
  output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(1));
42
42
  }
@@ -49,11 +49,12 @@ const upload = async (client, workspace, project, source, destination) => {
49
49
  if (files.length === 0) {
50
50
  output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(0));
51
51
  }
52
- output_1.default.normal('\n', false);
52
+ output_1.default.normal('');
53
+ const baseRemoteDir = isRemoteDir ? (0, path_1.join)(remotePath, (0, path_1.basename)(sourcePath)) : remotePath;
53
54
  for (let i = 0; i < files.length; i++) {
54
55
  const localFile = files[i];
55
56
  const relativePath = (0, path_1.relative)(sourcePath, localFile);
56
- const remoteFile = (0, path_1.join)(remotePath, relativePath).replace(/\\/g, '/');
57
+ const remoteFile = (0, path_1.join)(baseRemoteDir, relativePath).replace(/\\/g, '/');
57
58
  output_1.default.clearPreviousLine();
58
59
  output_1.default.normal((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(i + 1, files.length, relativePath));
59
60
  await client.sandboxUploadFile(workspace, found.id, remoteFile, localFile);
@@ -65,7 +66,7 @@ const upload = async (client, workspace, project, source, destination) => {
65
66
  }
66
67
  };
67
68
  const download = async (client, workspace, project, source, destination, merge, replace) => {
68
- const destPath = input_1.default.restApiSandboxDownloadDestinationPath(destination, merge, replace);
69
+ const { destPath, isDestPathDir } = input_1.default.restApiSandboxDownloadDestinationPath(destination, merge, replace);
69
70
  const { sourcePath, identifier } = input_1.default.restApiSandboxDownloadSourcePath(source);
70
71
  const result = await client.listSandboxes(workspace, project);
71
72
  const sandboxes = result.sandboxes || [];
@@ -76,14 +77,16 @@ const download = async (client, workspace, project, source, destination, merge,
76
77
  output_1.default.normal(texts_1.TXT_SANDBOX_CP_DOWNLOAD, false);
77
78
  const { body, headers } = await client.sandboxDownloadFile(workspace, found.id, sourcePath);
78
79
  const isFile = headers['content-type'] === 'application/octet-stream';
80
+ const name = (0, path_1.basename)(sourcePath);
79
81
  if (isFile) {
80
- const name = (0, path_1.basename)(sourcePath);
81
- await node_fs_1.default.promises.writeFile((0, path_1.join)(destPath, name), body);
82
+ const destFilePath = isDestPathDir ? (0, path_1.join)(destPath, name) : destPath;
83
+ await node_fs_1.default.promises.writeFile(destFilePath, body);
82
84
  output_1.default.clearPreviousLine();
83
85
  output_1.default.normal(texts_1.TXT_SANDBOX_CP_DOWNLOAD_DONE);
84
86
  output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(1));
85
87
  }
86
88
  else {
89
+ const destDirPath = isDestPathDir ? (0, path_1.join)(destPath, name) : destPath;
87
90
  const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${(0, uuid_1.v4)()}.tar.gz`);
88
91
  const clearZip = () => {
89
92
  try {
@@ -99,7 +102,7 @@ const download = async (client, workspace, project, source, destination, merge,
99
102
  output_1.default.normal(texts_1.TXT_SANDBOX_CP_DOWNLOAD_DONE);
100
103
  output_1.default.normal(texts_1.TXT_SANDBOX_UNZIP);
101
104
  let count = 0;
102
- await (0, utils_1.untarGz)(destPath, zipPath, () => {
105
+ await (0, utils_1.untarGz)(destDirPath, zipPath, () => {
103
106
  count += 1;
104
107
  output_1.default.clearPreviousLine();
105
108
  output_1.default.normal((0, texts_1.TXT_SANDBOX_UNZIPPING_COUNT)(count));
@@ -22,6 +22,7 @@ const workspace_1 = __importDefault(require("./command/workspace"));
22
22
  const project_1 = __importDefault(require("./command/project"));
23
23
  const whoami_1 = __importDefault(require("./command/whoami"));
24
24
  const package_1 = __importDefault(require("./command/package"));
25
+ const api_1 = __importDefault(require("./command/api"));
25
26
  stream_1.default.setDefaultHighWaterMark(false, 67108864);
26
27
  process.title = 'bdy';
27
28
  process.on('uncaughtException', (err) => {
@@ -47,4 +48,5 @@ program.addCommand(whoami_1.default);
47
48
  program.addCommand(logout_1.default);
48
49
  program.addCommand(workspace_1.default);
49
50
  program.addCommand(project_1.default);
51
+ program.addCommand(api_1.default);
50
52
  program.parse();
@@ -527,59 +527,89 @@ class Input {
527
527
  if (!remotePath.startsWith('/')) {
528
528
  remotePath = `/${remotePath}`;
529
529
  }
530
+ const isRemoteDir = remotePath.endsWith('/');
530
531
  return {
531
532
  identifier,
532
533
  remotePath,
534
+ isRemoteDir,
533
535
  };
534
536
  }
535
- static restApiSandboxDownloadDestinationPath(destPath, merge, replace) {
536
- const dirPath = node_path_1.default.resolve(destPath);
537
- const exists = node_fs_1.default.existsSync(dirPath);
538
- if (!exists) {
537
+ static restApiSandboxDownloadDestinationPath(destination, merge, replace) {
538
+ const isDestPathDir = destination.endsWith('/');
539
+ const destPath = node_path_1.default.resolve(destination);
540
+ const exists = node_fs_1.default.existsSync(destPath);
541
+ if (isDestPathDir) {
542
+ if (!exists) {
543
+ try {
544
+ node_fs_1.default.mkdirSync(destPath, {
545
+ recursive: true,
546
+ });
547
+ }
548
+ catch {
549
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_MKDIR)(destPath));
550
+ }
551
+ }
552
+ else if (replace) {
553
+ try {
554
+ node_fs_1.default.rmSync(destPath, {
555
+ recursive: true,
556
+ force: true,
557
+ });
558
+ node_fs_1.default.mkdirSync(destPath, {
559
+ recursive: true,
560
+ });
561
+ }
562
+ catch {
563
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_REPLACE)(destPath));
564
+ }
565
+ }
539
566
  try {
540
- node_fs_1.default.mkdirSync(dirPath, {
541
- recursive: true,
542
- });
567
+ const stats = node_fs_1.default.statSync(destPath);
568
+ if (!stats.isDirectory()) {
569
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_DEST_NOT_FOLDER)(destination));
570
+ }
571
+ }
572
+ catch {
573
+ output_1.default.exitError(texts_1.ERR_SWW);
574
+ }
575
+ let empty = true;
576
+ try {
577
+ const entries = node_fs_1.default.readdirSync(destPath);
578
+ empty = !entries.length;
543
579
  }
544
580
  catch {
545
- output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_MKDIR)(dirPath));
581
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_READDIR)(destPath));
582
+ }
583
+ if (!empty && !merge) {
584
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_NOT_EMPTY_DIR)(destPath));
546
585
  }
547
586
  }
548
- else if (replace) {
587
+ else {
588
+ if (exists) {
589
+ if (!replace) {
590
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_PATH_EXISTS)(destPath));
591
+ }
592
+ try {
593
+ node_fs_1.default.rmSync(destPath, {
594
+ recursive: true,
595
+ force: true,
596
+ });
597
+ }
598
+ catch {
599
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_REPLACE)(destPath));
600
+ }
601
+ }
602
+ const basePath = (0, node_path_1.resolve)(destPath, '..');
549
603
  try {
550
- node_fs_1.default.rmSync(dirPath, {
551
- recursive: true,
552
- force: true,
553
- });
554
- node_fs_1.default.mkdirSync(dirPath, {
604
+ node_fs_1.default.mkdirSync(basePath, {
555
605
  recursive: true,
556
606
  });
557
607
  }
558
608
  catch {
559
- output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_REPLACE)(dirPath));
560
- }
561
- }
562
- try {
563
- const stats = node_fs_1.default.statSync(dirPath);
564
- if (!stats.isDirectory()) {
565
- output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_DEST_NOT_FOLDER)(destPath));
609
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_MKDIR)(basePath));
566
610
  }
567
611
  }
568
- catch {
569
- output_1.default.exitError(texts_1.ERR_SWW);
570
- }
571
- let empty = true;
572
- try {
573
- const entries = node_fs_1.default.readdirSync(dirPath);
574
- empty = !entries.length;
575
- }
576
- catch {
577
- output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_READDIR)(dirPath));
578
- }
579
- if (!empty && !merge) {
580
- output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_NOT_EMPTY_DIR)(dirPath));
581
- }
582
- return dirPath;
612
+ return { destPath, isDestPathDir };
583
613
  }
584
614
  static restApiSandboxUploadSourcePath(sourcePath) {
585
615
  const s = node_path_1.default.resolve(sourcePath);
@@ -592,6 +622,19 @@ class Input {
592
622
  }
593
623
  return { sourceStats, sourcePath: s };
594
624
  }
625
+ static restApiMethod(method, allowNull = true) {
626
+ if (!method) {
627
+ if (!allowNull)
628
+ output_1.default.exitError(texts_1.ERR_API_WRONG_METHOD);
629
+ return null;
630
+ }
631
+ const m = method.toLowerCase();
632
+ if (['get', 'post', 'put', 'patch', 'delete'].includes(m))
633
+ return m;
634
+ if (!allowNull)
635
+ output_1.default.exitError(texts_1.ERR_API_WRONG_METHOD);
636
+ return null;
637
+ }
595
638
  static restApiProject(project, allowNull) {
596
639
  let p = process.env.BUDDY_PROJECT;
597
640
  if (project)
@@ -9,9 +9,9 @@ exports.OPTION_COMPARE_URLS_FILE = exports.OPTION_COMPARE_SITEMAP = exports.OPTI
9
9
  exports.LOG_TUNNEL_REGISTERED = exports.LOG_ERROR_WHILE_REFRESHING_AGENT = exports.LOG_REGISTERING_TUNNEL = exports.LOG_GETTING_AGENT = exports.LOG_UNREGISTERING_AGENT = exports.LOG_REGION_DETECTED = exports.LOG_AGENT_REGISTERED = exports.LOG_SOCKET_DISCONNECTED = exports.LOG_SOCKET_CONNECTED = exports.LOG_AGENT_NSSM_CLEARING = exports.LOG_AGENT_NSSM_EXTRACTING = exports.LOG_AGENT_NSSM_DOWNLOADING = exports.LOG_AGENT_ENABLED = exports.LOG_AGENT_STARTING_SYSTEM = exports.LOG_AGENT_STOPPING_SYSTEM = exports.LOG_AGENT_ENABLING_SYSTEM = exports.LOG_AGENT_SYSTEM_SERVICE_CONFIG = exports.LOG_AGENT_EXTRACTING_ARCHIVE = exports.LOG_AGENT_DOWNLOADING_ARCHIVE = exports.LOG_AGENT_SYSTEM_DIR = exports.LOG_ERROR_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_ERROR_REMOVING_AGENT_STANDALONE_LOCK_FILE = exports.LOG_ERROR_SAVING_AGENT_STANDALONE_CONFIG = exports.LOG_ERROR_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_REMOVING_AGENT_PROC_ID = exports.LOG_SAVING_AGENT_PROC_ID = exports.LOG_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_REGISTERING_AGENT = exports.OPTION_SCRAPE_OUTPUT_DIR = exports.OPTION_SCRAPE_DELAY = exports.OPTION_SCRAPE_DARK_MODE = exports.OPTION_SCRAPE_WAIT_FOR_ELEMENT = exports.OPTION_SCRAPE_DEVICE_PIXEL_RATIO = exports.OPTION_SCRAPE_VIEWPORT = exports.OPTION_SCRAPE_BROWSER = exports.OPTION_SCRAPE_XPATH_SELECTOR = exports.OPTION_SCRAPE_CSS_SELECTOR = exports.OPTION_SCRAPE_FULL_PAGE = exports.OPTION_SCRAPE_QUALITY = exports.OPTION_SCRAPE_OUTPUT_TYPE = exports.OPTION_SCRAPE_FOLLOW = exports.OPTION_SCRAPE_URL = exports.OPTION_COMPARE_WAIT_FOR = exports.OPTION_COMPARE_DELAY = exports.OPTION_COMPARE_HEADER = exports.OPTION_COMPARE_COOKIE = exports.OPTION_COMPARE_IGNORE = exports.OPTION_COMPARE_IGNORE_URLS = exports.OPTION_COMPARE_DRY_RUN = void 0;
10
10
  exports.DESC_COMMAND_SANDBOX_LIST = exports.DESC_COMMAND_SANDBOX_CREATE = exports.DESC_COMMAND_SANDBOX = exports.DEBUG_WAIT_FOR_IDLE_TIMEOUT = exports.DEBUG_WAIT_FOR_IDLE = exports.DEBUG_RESOURCE_DISCOVERY_TIMEOUT = exports.DEBUG_AUTO_WIDTH = exports.DEBUG_AUTO_SCROLL = exports.DEBUG_RESOURCE_SCRAPPING_URL = exports.DEBUG_SNAPSHOT_PROCESSING = exports.DEBUG_SNAPSHOTS_PROCESSING = exports.DEBUG_EXEC_COMMAND = exports.DEBUG_EXEC_TEST_COMMAND = exports.LOG_INSTALLED_BROWSER = exports.LOG_SESSION_LINK = exports.LOG_SENDING_DATA = exports.LOG_SENDING_REQUEST = exports.LOG_PROCESSING_SNAPSHOTS = exports.LOG_RUNNING_EXEC_COMMAND = exports.LOG_TUNNEL_SSH_STREAM = exports.LOG_TUNNEL_TLS_AGENT_STREAM = exports.LOG_TUNNEL_TLS_REGION_STREAM = exports.LOG_TUNNEL_TLS_TARGET_STREAM = exports.LOG_TUNNEL_HTTP2_STREAM = exports.LOG_TUNNEL_HTTP1_STREAM = exports.LOG_TUNNEL_TCP_STREAM = exports.LOG_TUNNEL_HTTP_WRONG_USER_AGENTS = exports.LOG_TUNNEL_HTTP_CIRCUIT_BREAKER_OPEN = exports.LOG_TUNNEL_HTTP_RATE_LIMIT = exports.LOG_TUNNEL_HTTP_WRON_AUTH = exports.LOG_TUNNEL_IDENTIFIED = exports.LOG_TUNNEL_DISCONNECTED = exports.LOG_TUNNEL_FAILED = exports.LOG_TUNNEL_CONNECTED = exports.LOG_AGENT_STARTED = exports.LOG_AGENT_SERVER_STARTED = exports.LOG_ERROR_STARTING_AGENT_SERVER = exports.LOG_SSH_CONNECTION = exports.LOG_WRONG_STREAM = exports.LOG_DETECTED_STREAM = exports.LOG_HTTP2_REQUEST = exports.LOG_HTTP2_CONNECTION = exports.LOG_HTTP1_REQUEST = exports.LOG_HTTP1_CONNECTION = exports.LOG_ERROR = exports.LOG_STOPPING_TUNNEL = exports.LOG_STARTING_TUNNEL = exports.LOG_ENABLING_AGENT_TARGET = exports.LOG_DISABLING_AGENT_TARGET = exports.LOG_REMOVING_TUNNEL = void 0;
11
11
  exports.DESC_COMMAND_SANDBOX_SNAPSHOT_CREATE = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_LIST = exports.DESC_COMMAND_SANDBOX_SNAPSHOT = exports.TXT_SANDBOX_COMMAND_KILLED = exports.OPTION_SANDBOX_COMMAND_KILL_CONFIRM = exports.OPTION_SANDBOX_COMMAND_ID = exports.DESC_COMMAND_SANDBOX_EXEC_KILL = exports.DESC_COMMAND_SANDBOX_EXEC_LOGS = exports.DESC_COMMAND_SANDBOX_EXEC_STATUS = exports.DESC_COMMAND_SANDBOX_EXEC_LIST = exports.TXT_SANDBOX_WAITING_START = exports.TXT_SANDBOX_WAITING_STOP = exports.TXT_SANDBOX_WAITING_SETUP = exports.TXT_SANDBOX_WAITING_RUNNING = exports.TXT_SANDBOX_STOPPED = exports.TXT_SANDBOX_STARTED = exports.TXT_SANDBOX_DESTROYED = exports.TXT_SANDBOX_DESTROY_CONFIRM = exports.TXT_SANDBOX_CREATED = exports.TXT_SANDBOX_CREATING = exports.OPTION_SANDBOX_WAIT = exports.OPTION_SANDBOX_WAIT_CONFIGURED = exports.OPTION_SANDBOX_WAIT_RUNNING = exports.ERR_SANDBOX_STOP_FAILED = exports.ERR_SANDBOX_NO_COMMANDS = exports.ERR_SANDBOX_RUNNING_FAILED = exports.ERR_SANDBOX_STOP_TIMEOUT = exports.ERR_SANDBOX_SNAPSHOT_TIMEOUT = exports.ERR_SANDBOX_RUNNING_TIMEOUT = exports.ERR_SANDBOX_SETUP_TIMEOUT = exports.ERR_SANDBOX_SETUP_FAILED = exports.ERR_SANDBOX_INVALID_RESOURCES = exports.ERR_SANDBOX_NOT_FOUND = exports.OPTION_SANDBOX_RUNTIME = exports.OPTION_SANDBOX_APP_TYPE = exports.OPTION_SANDBOX_APP_DIR = exports.OPTION_SANDBOX_RUN_COMMAND = exports.OPTION_SANDBOX_TAGS = exports.OPTION_SANDBOX_INSTALL_COMMANDS = exports.OPTION_SANDBOX_RESOURCES = exports.OPTION_SANDBOX_OS = exports.OPTION_SANDBOX_NAME = exports.OPTION_SANDBOX_IDENTIFIER = exports.DESC_COMMAND_SANDBOX_EXEC = exports.DESC_COMMAND_SANDBOX_STATUS = exports.DESC_COMMAND_SANDBOX_RESTART = exports.DESC_COMMAND_SANDBOX_STOP = exports.DESC_COMMAND_SANDBOX_START = exports.DESC_COMMAND_SANDBOX_DESTROY = exports.DESC_COMMAND_SANDBOX_GET = void 0;
12
- exports.TXT_SANDBOX_EXEC_SUCCESS = exports.TXT_SANDBOX_EXEC_BACKGROUND = exports.TXT_SANDBOX_EXEC_ID = exports.ERR_SANDBOX_CP_INVALID_SOURCE = exports.ERR_SANDBOX_CP_INVALID_DEST = exports.ERR_SANDBOX_CP_REPLACE = exports.ERR_SANDBOX_CP_MKDIR = exports.ERR_SANDBOX_CP_NOT_EMPTY_DIR = exports.ERR_SANDBOX_CP_READDIR = exports.ERR_SANDBOX_CP_DEST_NOT_FOLDER = exports.ERR_SANDBOX_CP_SOURCE_NOT_FOUND = exports.TXT_SANDBOX_CP_DONE = exports.TXT_SANDBOX_CP_PROGRESS = exports.TXT_SANDBOX_UNZIPPING_COUNT = exports.TXT_SANDBOX_UNZIP_DONE = exports.TXT_SANDBOX_UNZIP = exports.TXT_SANDBOX_CP_DOWNLOAD_DONE = exports.TXT_SANDBOX_CP_DOWNLOAD = exports.OPTION_SANDBOX_CP_DOWNLOAD_REPLACE = exports.OPTION_SANDBOX_CP_DOWNLOAD_MERGE = exports.OPTION_SANDBOX_CP_DEST = exports.OPTION_SANDBOX_CP_SOURCE = exports.DESC_COMMAND_SANDBOX_CP = exports.ERR_SANDBOX_ENDPOINTS_NOT_FOUND = exports.ERR_SANDBOX_ENDPOINT_NOT_FOUND = exports.ERR_SANDBOX_ENDPOINT_EXISTS = exports.TXT_SANDBOX_ENDPOINT_DELETED = exports.TXT_SANDBOX_ENDPOINT_DELETE_CONFIRM = exports.TXT_SANDBOX_ENDPOINT_ADDED = exports.OPTION_SANDBOX_ENDPOINT_TYPE = exports.OPTION_SANDBOX_ENDPOINT_PORT = exports.OPTION_SANDBOX_ENDPOINT_NAME_ARG = exports.OPTION_SANDBOX_ENDPOINT_NAME = exports.DESC_COMMAND_SANDBOX_ENDPOINT_DELETE = exports.DESC_COMMAND_SANDBOX_ENDPOINT_ADD = exports.DESC_COMMAND_SANDBOX_ENDPOINT_GET = exports.DESC_COMMAND_SANDBOX_ENDPOINT_LIST = exports.DESC_COMMAND_SANDBOX_ENDPOINT = exports.ERR_SANDBOX_SNAPSHOTS_NOT_FOUND = exports.ERR_SANDBOX_SNAPSHOT_NOT_FOUND = exports.ERR_SANDBOX_SNAPSHOT_FAILED = exports.TXT_SANDBOX_SNAPSHOT_WAITING = exports.TXT_SANDBOX_SNAPSHOT_DELETE_CONFIRM = exports.TXT_SANDBOX_SNAPSHOT_DELETED = exports.TXT_SANDBOX_SNAPSHOT_CREATED = exports.OPTION_SANDBOX_FROM_SNAPSHOT = exports.OPTION_SANDBOX_SNAPSHOT_NAME_ARG = exports.OPTION_SANDBOX_SNAPSHOT_NAME = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_DELETE = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_GET = void 0;
13
- exports.TXT_PACKAGE_DELETED = exports.ERR_COMMAND_PACKAGE_TYPE = exports.OPT_COMMAND_PACKAGE_VERSION = exports.OPT_COMMAND_PACKAGE_IDENTIFIER = exports.OPT_COMMAND_PACKAGE_CREATE_IDENTIFIER = exports.OPT_COMMAND_PACKAGE_NAME = exports.OPT_COMMAND_PACKAGE_TYPE = exports.DESC_COMMAND_PACKAGE_CREATE = exports.DESC_COMMAND_PACKAGE_GET = exports.TXT_PACKAGE_DOCKER_LOGIN_FAILED = exports.TXT_PACKAGE_DOCKER_LOGIN_SUCCESS = exports.TXT_PACKAGE_VERSION_DELETE_CONFIRM = exports.TXT_PACKAGE_DELETE_CONFIRM = exports.DESC_COMMAND_PACKAGE_DELETE = exports.ERR_COMMAND_PACKAGE_NO_PROJECTS = exports.DESC_COMMAND_PACKAGE_VERSION_GET = exports.DESC_COMMAND_PACKAGE_VERSION_LIST = exports.DESC_COMMAND_PACKAGE_VERSION_DELETE = exports.DESC_COMMAND_PACKAGE_DOCKER_LOGIN = exports.DESC_COMMAND_PACKAGE_LIST = exports.DESC_COMMAND_PACKAGE_VERSION = exports.ERR_API_MESSAGE_REPLACER = exports.ERR_LOGIN_INVALID_BASE_URL = exports.ERR_LOGIN_NO_PROJECT_FOUND = exports.ERR_LOGIN_NO_WORKSPACE_FOUND = exports.ERR_LOGIN_NO_WORKSPACES = exports.ERR_LOGIN_HTTP_SUCCESS = exports.ERR_LOGIN_HTTP_FAILED = exports.TXT_LOGIN_OAUTH = exports.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN = exports.TXT_LOGIN_SUCCESS = exports.TXT_LOGIN_SELECT_WORKSPACE = exports.TXT_LOGIN_ENTER_BASE_URL = exports.TXT_LOGIN_SELECT_REGION = exports.TXT_WORKSPACE_NONE = exports.TXT_WORKSPACE_SET_SUCCESS = exports.ARG_COMMAND_WORKSPACE = exports.DESC_COMMAND_WORKSPACE_GET = exports.DESC_COMMAND_WORKSPACE_SET = exports.DESC_COMMAND_WORKSPACE_LIST = exports.DESC_COMMAND_WORKSPACE = exports.TXT_LOGOUT_SUCCESS = exports.DESC_COMMAND_LOGOUT = exports.DESC_COMMAND_LOGIN = exports.ERR_WHOAMI_LOGOUT = exports.TXT_WHOAMI_NO_PROJECT = exports.TXT_WHOAMI_NO_WORKSPACE = exports.DESC_COMMAND_WHOAMI = exports.TXT_SANDBOX_EXEC_FAILED = exports.TXT_SANDBOX_EXEC_INPROGRESS = void 0;
14
- exports.EXAMPLE_PACKAGE_VERSION_DELETE = exports.EXAMPLE_PACKAGE_VERSION_GET = exports.EXAMPLE_PACKAGE_VERSION_LIST = exports.EXAMPLE_PACKAGE_CREATE = exports.EXAMPLE_PACKAGE_DELETE = exports.EXAMPLE_PACKAGE_DOWNLOAD = exports.EXAMPLE_PACKAGE_PUBLISH = exports.EXAMPLE_PIPELINE_RUN = exports.EXAMPLE_SANDBOX_ENDPOINT_LIST = exports.EXAMPLE_SANDBOX_ENDPOINT_GET = exports.EXAMPLE_SANDBOX_ENDPOINT_DELETE = exports.EXAMPLE_SANDBOX_ENDPOINT_CREATE = exports.EXAMPLE_SANDBOX_SNAPSHOT_LIST = exports.EXAMPLE_SANDBOX_SNAPSHOT_GET = exports.EXAMPLE_SANDBOX_SNAPSHOT_DELETE = exports.EXAMPLE_SANDBOX_SNAPSHOT_CREATE = exports.EXAMPLE_SANDBOX_EXEC_STATUS = exports.EXAMPLE_SANDBOX_EXEC_LOGS = exports.EXAMPLE_SANDBOX_EXEC_LIST = exports.EXAMPLE_SANDBOX_EXEC_KILL = exports.EXAMPLE_SANDBOX_EXEC_COMMAND = exports.EXAMPLE_SANDBOX_CREATE = exports.EXAMPLE_SANDBOX_CP = exports.TXT_PROJECT_NONE = exports.ERR_PROJECT_NO_PROJECTS = exports.TXT_LOGIN_SELECT_PROJECT = exports.TXT_PROJECT_SET_CLEARED = exports.TXT_PROJECT_SET_SUCCESS = exports.DESC_COMMAND_PROJECT_GET = exports.ARG_COMMAND_PROJECT_NAME = exports.DESC_COMMAND_PROJECT_SET = exports.DESC_COMMAND_PROJECT_LIST = exports.DESC_COMMAND_PROJECT = exports.TXT_PACKAGE_VERSION_DOWNLOAD = exports.TXT_PACKAGE_PUBLISH = exports.TXT_PACKAGE_CREATED = exports.TXT_PACKAGE_VERSION_DELETED = void 0;
12
+ exports.TXT_SANDBOX_EXEC_BACKGROUND = exports.TXT_SANDBOX_EXEC_ID = exports.ERR_SANDBOX_CP_INVALID_SOURCE = exports.ERR_SANDBOX_CP_INVALID_DEST = exports.ERR_SANDBOX_CP_REPLACE = exports.ERR_SANDBOX_CP_MKDIR = exports.ERR_SANDBOX_CP_PATH_EXISTS = exports.ERR_SANDBOX_CP_NOT_EMPTY_DIR = exports.ERR_SANDBOX_CP_READDIR = exports.ERR_SANDBOX_CP_DEST_NOT_FOLDER = exports.ERR_SANDBOX_CP_SOURCE_NOT_FOUND = exports.TXT_SANDBOX_CP_DONE = exports.TXT_SANDBOX_CP_PROGRESS = exports.TXT_SANDBOX_UNZIPPING_COUNT = exports.TXT_SANDBOX_UNZIP_DONE = exports.TXT_SANDBOX_UNZIP = exports.TXT_SANDBOX_CP_DOWNLOAD_DONE = exports.TXT_SANDBOX_CP_DOWNLOAD = exports.OPTION_SANDBOX_CP_DOWNLOAD_REPLACE = exports.OPTION_SANDBOX_CP_DOWNLOAD_MERGE = exports.OPTION_SANDBOX_CP_DEST = exports.OPTION_SANDBOX_CP_SOURCE = exports.DESC_COMMAND_SANDBOX_CP = exports.ERR_SANDBOX_ENDPOINTS_NOT_FOUND = exports.ERR_SANDBOX_ENDPOINT_NOT_FOUND = exports.ERR_SANDBOX_ENDPOINT_EXISTS = exports.TXT_SANDBOX_ENDPOINT_DELETED = exports.TXT_SANDBOX_ENDPOINT_DELETE_CONFIRM = exports.TXT_SANDBOX_ENDPOINT_ADDED = exports.OPTION_SANDBOX_ENDPOINT_TYPE = exports.OPTION_SANDBOX_ENDPOINT_PORT = exports.OPTION_SANDBOX_ENDPOINT_NAME_ARG = exports.OPTION_SANDBOX_ENDPOINT_NAME = exports.DESC_COMMAND_SANDBOX_ENDPOINT_DELETE = exports.DESC_COMMAND_SANDBOX_ENDPOINT_ADD = exports.DESC_COMMAND_SANDBOX_ENDPOINT_GET = exports.DESC_COMMAND_SANDBOX_ENDPOINT_LIST = exports.DESC_COMMAND_SANDBOX_ENDPOINT = exports.ERR_SANDBOX_SNAPSHOTS_NOT_FOUND = exports.ERR_SANDBOX_SNAPSHOT_NOT_FOUND = exports.ERR_SANDBOX_SNAPSHOT_FAILED = exports.TXT_SANDBOX_SNAPSHOT_WAITING = exports.TXT_SANDBOX_SNAPSHOT_DELETE_CONFIRM = exports.TXT_SANDBOX_SNAPSHOT_DELETED = exports.TXT_SANDBOX_SNAPSHOT_CREATED = exports.OPTION_SANDBOX_FROM_SNAPSHOT = exports.OPTION_SANDBOX_SNAPSHOT_NAME_ARG = exports.OPTION_SANDBOX_SNAPSHOT_NAME = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_DELETE = exports.DESC_COMMAND_SANDBOX_SNAPSHOT_GET = void 0;
13
+ exports.DESC_COMMAND_PACKAGE_DELETE = exports.ERR_COMMAND_PACKAGE_NO_PROJECTS = exports.DESC_COMMAND_PACKAGE_VERSION_GET = exports.DESC_COMMAND_PACKAGE_VERSION_LIST = exports.DESC_COMMAND_PACKAGE_VERSION_DELETE = exports.DESC_COMMAND_PACKAGE_DOCKER_LOGIN = exports.DESC_COMMAND_PACKAGE_LIST = exports.DESC_COMMAND_PACKAGE_VERSION = exports.ERR_API_MESSAGE_REPLACER = exports.ERR_LOGIN_INVALID_BASE_URL = exports.ERR_LOGIN_NO_PROJECT_FOUND = exports.ERR_LOGIN_NO_WORKSPACE_FOUND = exports.ERR_LOGIN_NO_WORKSPACES = exports.ERR_LOGIN_HTTP_SUCCESS = exports.ERR_LOGIN_HTTP_FAILED = exports.TXT_LOGIN_OAUTH = exports.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN = exports.TXT_LOGIN_SUCCESS = exports.TXT_LOGIN_SELECT_WORKSPACE = exports.TXT_LOGIN_ENTER_BASE_URL = exports.TXT_LOGIN_SELECT_REGION = exports.TXT_WORKSPACE_NONE = exports.TXT_WORKSPACE_SET_SUCCESS = exports.ARG_COMMAND_WORKSPACE = exports.DESC_COMMAND_WORKSPACE_GET = exports.DESC_COMMAND_WORKSPACE_SET = exports.DESC_COMMAND_WORKSPACE_LIST = exports.DESC_COMMAND_WORKSPACE = exports.TXT_LOGOUT_SUCCESS = exports.DESC_COMMAND_LOGOUT = exports.DESC_COMMAND_LOGIN = exports.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = exports.TXT_API_ENDPOINT_REQUIRED_SCOPES = exports.ERR_API_ENDPOINT_NOT_FOUND = exports.ERR_API_WRONG_METHOD = exports.ERR_SCHEMA_FETCH_FAILED = exports.OPT_COMMAND_API_INFO_URL = exports.OPT_COMMAND_API_INFO_METHOD = exports.OPT_COMMAND_API_LIST_SEARCH = exports.OPT_COMMAND_API_LIST_METHOD = exports.DESC_COMMAND_API_INFO = exports.DESC_COMMAND_API_LIST = exports.DESC_COMMAND_API = exports.ERR_WHOAMI_LOGOUT = exports.TXT_WHOAMI_NO_PROJECT = exports.TXT_WHOAMI_NO_WORKSPACE = exports.DESC_COMMAND_WHOAMI = exports.TXT_SANDBOX_EXEC_FAILED = exports.TXT_SANDBOX_EXEC_INPROGRESS = exports.TXT_SANDBOX_EXEC_SUCCESS = void 0;
14
+ exports.EXAMPLE_PACKAGE_VERSION_DELETE = exports.EXAMPLE_PACKAGE_VERSION_GET = exports.EXAMPLE_PACKAGE_VERSION_LIST = exports.EXAMPLE_PACKAGE_CREATE = exports.EXAMPLE_PACKAGE_DELETE = exports.EXAMPLE_PACKAGE_DOWNLOAD = exports.EXAMPLE_PACKAGE_PUBLISH = exports.EXAMPLE_PIPELINE_RUN = exports.EXAMPLE_SANDBOX_ENDPOINT_LIST = exports.EXAMPLE_SANDBOX_ENDPOINT_GET = exports.EXAMPLE_SANDBOX_ENDPOINT_DELETE = exports.EXAMPLE_SANDBOX_ENDPOINT_CREATE = exports.EXAMPLE_SANDBOX_SNAPSHOT_LIST = exports.EXAMPLE_SANDBOX_SNAPSHOT_GET = exports.EXAMPLE_SANDBOX_SNAPSHOT_DELETE = exports.EXAMPLE_SANDBOX_SNAPSHOT_CREATE = exports.EXAMPLE_SANDBOX_EXEC_STATUS = exports.EXAMPLE_SANDBOX_EXEC_LOGS = exports.EXAMPLE_SANDBOX_EXEC_LIST = exports.EXAMPLE_SANDBOX_EXEC_KILL = exports.EXAMPLE_SANDBOX_EXEC_COMMAND = exports.EXAMPLE_SANDBOX_CREATE = exports.EXAMPLE_SANDBOX_CP = exports.TXT_PROJECT_NONE = exports.ERR_PROJECT_NO_PROJECTS = exports.TXT_LOGIN_SELECT_PROJECT = exports.TXT_PROJECT_SET_CLEARED = exports.TXT_PROJECT_SET_SUCCESS = exports.DESC_COMMAND_PROJECT_GET = exports.ARG_COMMAND_PROJECT_NAME = exports.DESC_COMMAND_PROJECT_SET = exports.DESC_COMMAND_PROJECT_LIST = exports.DESC_COMMAND_PROJECT = exports.TXT_PACKAGE_VERSION_DOWNLOAD = exports.TXT_PACKAGE_PUBLISH = exports.TXT_PACKAGE_CREATED = exports.TXT_PACKAGE_VERSION_DELETED = exports.TXT_PACKAGE_DELETED = exports.ERR_COMMAND_PACKAGE_TYPE = exports.OPT_COMMAND_PACKAGE_VERSION = exports.OPT_COMMAND_PACKAGE_IDENTIFIER = exports.OPT_COMMAND_PACKAGE_CREATE_IDENTIFIER = exports.OPT_COMMAND_PACKAGE_NAME = exports.OPT_COMMAND_PACKAGE_TYPE = exports.DESC_COMMAND_PACKAGE_CREATE = exports.DESC_COMMAND_PACKAGE_GET = exports.TXT_PACKAGE_DOCKER_LOGIN_FAILED = exports.TXT_PACKAGE_DOCKER_LOGIN_SUCCESS = exports.TXT_PACKAGE_VERSION_DELETE_CONFIRM = exports.TXT_PACKAGE_DELETE_CONFIRM = void 0;
15
15
  const utils_1 = require("./utils");
16
16
  exports.ERR_REST_API_GENERAL_ERROR = 'Something went wrong';
17
17
  exports.ERR_REST_API_NOT_RESPONDING = 'Api endpoint not responding. Try again later...';
@@ -604,8 +604,8 @@ exports.ERR_SANDBOX_ENDPOINT_NOT_FOUND = 'Endpoint not found';
604
604
  exports.ERR_SANDBOX_ENDPOINTS_NOT_FOUND = 'No endpoints found';
605
605
  // Sandbox cp command
606
606
  exports.DESC_COMMAND_SANDBOX_CP = 'Copy files/directories to sandbox';
607
- exports.OPTION_SANDBOX_CP_SOURCE = 'Upload: local file (directory) path to upload. Download: sandbox remote file (directory): sandbox-id:/path to download';
608
- exports.OPTION_SANDBOX_CP_DEST = 'Upload: Sandbox remote directory: sandbox-id:/path to upload to. Download: local directory path to download to';
607
+ exports.OPTION_SANDBOX_CP_SOURCE = 'Local path or sandbox path (sandbox-id:/path)';
608
+ exports.OPTION_SANDBOX_CP_DEST = 'Local path or sandbox path (sandbox-id:/path)';
609
609
  exports.OPTION_SANDBOX_CP_DOWNLOAD_MERGE = 'Merge contents of the destination directory with sandbox content';
610
610
  exports.OPTION_SANDBOX_CP_DOWNLOAD_REPLACE = 'Replace contents of the destination directory with sandbox content';
611
611
  exports.TXT_SANDBOX_CP_DOWNLOAD = 'Downloading...';
@@ -626,9 +626,11 @@ const ERR_SANDBOX_CP_READDIR = (dirPath) => `Error while reading directory ${dir
626
626
  exports.ERR_SANDBOX_CP_READDIR = ERR_SANDBOX_CP_READDIR;
627
627
  const ERR_SANDBOX_CP_NOT_EMPTY_DIR = (dirPath) => `Directory ${dirPath} is not empty. Use --merge or --replace flags`;
628
628
  exports.ERR_SANDBOX_CP_NOT_EMPTY_DIR = ERR_SANDBOX_CP_NOT_EMPTY_DIR;
629
+ const ERR_SANDBOX_CP_PATH_EXISTS = (path) => `Path ${path} exists. Use --replace flags`;
630
+ exports.ERR_SANDBOX_CP_PATH_EXISTS = ERR_SANDBOX_CP_PATH_EXISTS;
629
631
  const ERR_SANDBOX_CP_MKDIR = (dirPath) => `Error while creating directory ${dirPath}`;
630
632
  exports.ERR_SANDBOX_CP_MKDIR = ERR_SANDBOX_CP_MKDIR;
631
- const ERR_SANDBOX_CP_REPLACE = (dirPath) => `Error while replacing directory ${dirPath}`;
633
+ const ERR_SANDBOX_CP_REPLACE = (dirPath) => `Error while replacing path ${dirPath}`;
632
634
  exports.ERR_SANDBOX_CP_REPLACE = ERR_SANDBOX_CP_REPLACE;
633
635
  exports.ERR_SANDBOX_CP_INVALID_DEST = 'Invalid destination format. Use: sandbox-identifier:/path';
634
636
  exports.ERR_SANDBOX_CP_INVALID_SOURCE = 'Invalid source format. Use: sandbox-identifier:/path';
@@ -648,6 +650,20 @@ exports.DESC_COMMAND_WHOAMI = 'Check login information';
648
650
  exports.TXT_WHOAMI_NO_WORKSPACE = 'Not set. Run `bdy ws set` to set a workspace';
649
651
  exports.TXT_WHOAMI_NO_PROJECT = 'Not set. Run `bdy proj set` to set a project';
650
652
  exports.ERR_WHOAMI_LOGOUT = 'Not logged in. Run `bdy login` to authenticate.';
653
+ // api command
654
+ exports.DESC_COMMAND_API = 'Contact Buddy API directly';
655
+ exports.DESC_COMMAND_API_LIST = 'List Buddy API endpoints';
656
+ exports.DESC_COMMAND_API_INFO = 'Show info about API endpoint';
657
+ exports.OPT_COMMAND_API_LIST_METHOD = 'Filter endpoints by method (all, get, post, put, patch, delete). Default: all';
658
+ exports.OPT_COMMAND_API_LIST_SEARCH = 'Filter endpoints by phrase';
659
+ exports.OPT_COMMAND_API_INFO_METHOD = 'Endpoint method (get, post, put, patch, delete)';
660
+ exports.OPT_COMMAND_API_INFO_URL = 'Endpoint url';
661
+ exports.ERR_SCHEMA_FETCH_FAILED = 'Failed to fetch api schema';
662
+ exports.ERR_API_WRONG_METHOD = 'Wrong method value';
663
+ exports.ERR_API_ENDPOINT_NOT_FOUND = 'Endpoint not found';
664
+ exports.TXT_API_ENDPOINT_REQUIRED_SCOPES = 'Required scopes';
665
+ const ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = (type) => `Media type not implemented (${type})`;
666
+ exports.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED;
651
667
  // Login command
652
668
  exports.DESC_COMMAND_LOGIN = 'Log in to Buddy';
653
669
  exports.DESC_COMMAND_LOGOUT = 'Log out from Buddy';
@@ -769,20 +785,43 @@ exports.TXT_PROJECT_NONE = 'No project configured. Run "bdy login" or "bdy proje
769
785
  // Examples
770
786
  exports.EXAMPLE_SANDBOX_CP = `
771
787
  EXAMPLES:
772
- # copy file from sandbox to new local directory:
773
- bdy sb cp sandbox-identifier:/path/to/file /path/to/dir
788
+ # copy file from sandbox to local directory with a new name:
789
+ bdy sb cp sandbox-identifier:/path/to/file /path/to/dir/name
774
790
 
775
- # copy contents of directory from sandbox to existing local directory merging it contents:
776
- bdy sb cp sandbox-identifier:/path/to/dir /path/to/dir --merge
791
+ # if local path file already exists you must replace it:
792
+ bdy sb cp sandbox-identifier:/path/to/file /path/to/dir/name --replace
777
793
 
778
- # copy contents of directory from sandbox to existing local directory replacing it contents:
779
- bdy sb co sandbox-identifier:/path/to/dir /path/to/dir --replace
794
+ # copy file from sandbox INTO local directory:
795
+ bdy sb cp sandbox-identifier:/path/to/file /path/to/dir/
780
796
 
781
- # copy local file to sandbox directory:
782
- bdy sb cp /path/to/file sandbox-identifier:/path/to/dir
797
+ # if local directory already exists you must merge it or replace it:
798
+ bdy sb cp sandbox-identifier:/path/to/file /path/to/dir/ --merge
799
+ bdy sb cp sandbox-identifier:/path/to/file /path/to/dir/ --replace
800
+
801
+ # copy directory from sandbox to local directory with a new name
802
+ bdy sb cp sandbox-identifier:/path/to/dir /path/to/dir
803
+
804
+ # if local directory already exists you must replace it:
805
+ bdy sb cp sandbox-identifier:/path/to/dir /path/to/dir --replace
806
+
807
+ # copy directory from sandbox INTO local directory
808
+ bdy sb cp sandbox-identifier:/path/to/dir /path/to/dir/
809
+
810
+ # if local directory already exists you must merge it or replace it:
811
+ bdy sb cp sandbox-identifier:/path/to/dir /path/to/dir/ --merge
812
+ bdy sb cp sandbox-identifier:/path/to/dir /path/to/dir/ --replace
813
+
814
+ # copy local file to sandbox with a new name:
815
+ bdy sb cp /path/to/file sandbox-identifier:/path/to/dir/name
816
+
817
+ # copy local file into sandbox directory
818
+ bdy sb cp /path/to/file sandbox-identifier:/path/to/dir/
783
819
 
784
820
  # copy contents of local directory to sandbox directory:
785
- bdy sb cp /path/to/dir sandbox-identifier:/path/to/dir`;
821
+ bdy sb cp /path/to/dir sandbox-identifier:/path/to/dir
822
+
823
+ # copy local directory into sandbox directory:
824
+ bdy sb cp /path/to/dir sandbox-identifier:/path/to/dir/`;
786
825
  exports.EXAMPLE_SANDBOX_CREATE = `
787
826
  EXAMPLES:
788
827
  # create ubuntu 22.04 sandbox with name and wait for start:
@@ -36,8 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getLatestVersion = exports.getVersionEnv = exports.getCurrentVersionWithoutEnv = exports.getVersionWithoutEnv = exports.getVersion = exports.isInstalledByChoco = exports.isInstalledByApt = exports.isInstalledByBrew = exports.isInstalledByNpm = exports.execLocally = exports.getHomeDirectory = exports.newCommand = exports.formatBytes = exports.formatHelp = exports.getPlatform = exports.getHostname = exports.isStringRegExp = exports.getRootDir = exports.TARGET_ONLY_PORT_REGEX = exports.TARGET_HTTP_REGEX = exports.TARGET_TCP_TLS_REGEX = exports.ApiErrorTunnelsDisabled = exports.ApiErrorWorkspaceFlagged = exports.ApiErrorTunnelLimitReached = exports.ApiErrorAgentLimitReached = exports.ApiErrorDomainRestricted = exports.ApiErrorTargetInvalid = exports.ApiErrorWrongToken = exports.ApiErrorFailedToConnect = exports.ApiErrorAgentNotFound = exports.PACKAGE_AUTH_TYPE = exports.PACKAGE_SCOPE = exports.PACKAGE_TYPE = exports.SANDBOX_APP_STATUS = exports.SANDBOX_SNAPSHOT_STATUS = exports.SANDBOX_SETUP_STATUS = exports.SANDBOX_EXEC_STATUS = exports.SANDBOX_EXEC_RUNTIME = exports.SANDBOX_STATUS = exports.REST_API_ENDPOINT = exports.REST_API_REGION = exports.SUGGESTED_BROWSER_VERSION = exports.DEFAULT_TIMEOUT = exports.TUNNEL_HTTP_CB_MIN_REQUESTS = exports.TUNNEL_HTTP_CB_WINDOW = exports.TUNNEL_MAX_REQUEST_SIZE_TO_SYNC = exports.TUNNEL_HTTP_LOG_MAX_REQUESTS = exports.TUNNEL_HTTP_LOG_MAX_BODY = exports.TUNNEL_HTTP_RATE_WINDOW = exports.TUNNEL_HTTP_RATE_LIMIT = void 0;
40
- exports.getBasicCommandTls = exports.getBasicCommandHttp = exports.getBasicCommandSandboxEndpoint = exports.getBasicCommandTcp = exports.createSshHostKey = exports.getRealTargetHost = exports.isWindows = exports.isLinux = exports.isOsx = exports.isDocker = exports.sleep = void 0;
39
+ exports.sleep = exports.getLatestVersion = exports.getVersionEnv = exports.getCurrentVersionWithoutEnv = exports.getVersionWithoutEnv = exports.getVersion = exports.isInstalledByChoco = exports.isInstalledByApt = exports.isInstalledByBrew = exports.isInstalledByNpm = exports.execLocally = exports.getHomeDirectory = exports.newCommand = exports.formatBytes = exports.formatHelp = exports.getPlatform = exports.getHostname = exports.isStringRegExp = exports.getRootDir = exports.TARGET_ONLY_PORT_REGEX = exports.TARGET_HTTP_REGEX = exports.TARGET_TCP_TLS_REGEX = exports.ApiErrorTunnelsDisabled = exports.ApiErrorWorkspaceFlagged = exports.ApiErrorTunnelLimitReached = exports.ApiErrorAgentLimitReached = exports.ApiErrorDomainRestricted = exports.ApiErrorTargetInvalid = exports.ApiErrorWrongToken = exports.ApiErrorFailedToConnect = exports.ApiErrorAgentNotFound = exports.PACKAGE_AUTH_TYPE = exports.PACKAGE_SCOPE = exports.PACKAGE_TYPE = exports.SANDBOX_SNAPSHOT_STATUS = exports.SANDBOX_SETUP_STATUS = exports.SANDBOX_EXEC_STATUS = exports.SANDBOX_EXEC_RUNTIME = exports.SANDBOX_STATUS = exports.REST_API_ENDPOINT = exports.REST_API_REGION = exports.SUGGESTED_BROWSER_VERSION = exports.DEFAULT_TIMEOUT = exports.TUNNEL_HTTP_CB_MIN_REQUESTS = exports.TUNNEL_HTTP_CB_WINDOW = exports.TUNNEL_MAX_REQUEST_SIZE_TO_SYNC = exports.TUNNEL_HTTP_LOG_MAX_REQUESTS = exports.TUNNEL_HTTP_LOG_MAX_BODY = exports.TUNNEL_HTTP_RATE_WINDOW = exports.TUNNEL_HTTP_RATE_LIMIT = void 0;
40
+ exports.getBasicCommandTls = exports.getBasicCommandHttp = exports.getBasicCommandSandboxEndpoint = exports.getBasicCommandTcp = exports.createSshHostKey = exports.getRealTargetHost = exports.isWindows = exports.isLinux = exports.isOsx = exports.isDocker = void 0;
41
41
  exports.apiErrorCodeToClass = apiErrorCodeToClass;
42
42
  exports.isFile = isFile;
43
43
  exports.getAppWorkspaceUrl = getAppWorkspaceUrl;
@@ -46,6 +46,9 @@ exports.getAppUrl = getAppUrl;
46
46
  exports.untarGz = untarGz;
47
47
  exports.unzipFile = unzipFile;
48
48
  exports.getDockerRegistryHostByApiBaseUrl = getDockerRegistryHostByApiBaseUrl;
49
+ exports.fetchOpenApiSchema = fetchOpenApiSchema;
50
+ exports.openApiPrepareUrl = openApiPrepareUrl;
51
+ exports.getOpenApiEndpointByApiBaseUrl = getOpenApiEndpointByApiBaseUrl;
49
52
  exports.getAppHostByApiBaseUrl = getAppHostByApiBaseUrl;
50
53
  const node_path_1 = __importDefault(require("node:path"));
51
54
  const node_fs_1 = __importStar(require("node:fs"));
@@ -57,6 +60,9 @@ const node_os_1 = __importStar(require("node:os"));
57
60
  const node_child_process_1 = require("node:child_process");
58
61
  const fflate_1 = require("fflate");
59
62
  const tar_stream_1 = __importDefault(require("tar-stream"));
63
+ const bundle_1 = require("@scalar/json-magic/bundle");
64
+ const node_1 = require("@scalar/json-magic/bundle/plugins/node");
65
+ const openapi_parser_1 = require("@scalar/openapi-parser");
60
66
  exports.TUNNEL_HTTP_RATE_LIMIT = 2000;
61
67
  exports.TUNNEL_HTTP_RATE_WINDOW = 60000;
62
68
  exports.TUNNEL_HTTP_LOG_MAX_BODY = 5242880; // 5MB
@@ -114,13 +120,6 @@ var SANDBOX_SNAPSHOT_STATUS;
114
120
  SANDBOX_SNAPSHOT_STATUS["DELETING"] = "DELETING";
115
121
  SANDBOX_SNAPSHOT_STATUS["FAILED"] = "FAILED";
116
122
  })(SANDBOX_SNAPSHOT_STATUS || (exports.SANDBOX_SNAPSHOT_STATUS = SANDBOX_SNAPSHOT_STATUS = {}));
117
- var SANDBOX_APP_STATUS;
118
- (function (SANDBOX_APP_STATUS) {
119
- SANDBOX_APP_STATUS["NONE"] = "NONE";
120
- SANDBOX_APP_STATUS["ENDED"] = "ENDED";
121
- SANDBOX_APP_STATUS["RUNNING"] = "RUNNING";
122
- SANDBOX_APP_STATUS["FAILED"] = "FAILED";
123
- })(SANDBOX_APP_STATUS || (exports.SANDBOX_APP_STATUS = SANDBOX_APP_STATUS = {}));
124
123
  var PACKAGE_TYPE;
125
124
  (function (PACKAGE_TYPE) {
126
125
  PACKAGE_TYPE["FILE"] = "FILE";
@@ -915,6 +914,46 @@ function getDockerRegistryHostByApiBaseUrl(baseUrl) {
915
914
  return baseUrl.hostname;
916
915
  }
917
916
  }
917
+ async function fetchOpenApiSchema(baseUrl) {
918
+ try {
919
+ const url = getOpenApiEndpointByApiBaseUrl(baseUrl);
920
+ const data = await (0, bundle_1.bundle)(url, {
921
+ plugins: [(0, node_1.readFiles)(), (0, node_1.fetchUrls)(), (0, node_1.parseYaml)(), (0, node_1.parseJson)()],
922
+ treeShake: true,
923
+ });
924
+ const { schema } = await (0, openapi_parser_1.dereference)(data);
925
+ if (schema)
926
+ return schema;
927
+ }
928
+ catch {
929
+ // do nothing
930
+ }
931
+ throw new Error(texts_1.ERR_SCHEMA_FETCH_FAILED);
932
+ }
933
+ function openApiPrepareUrl(url, workspace, project) {
934
+ let preparedUrl = url.replaceAll('{workspace_domain}', workspace);
935
+ if (project)
936
+ preparedUrl = preparedUrl.replaceAll('{project_name}', project);
937
+ return preparedUrl;
938
+ }
939
+ function getOpenApiEndpointByApiBaseUrl(baseUrl) {
940
+ if (baseUrl.hostname.includes('api.buddy.works') ||
941
+ baseUrl.hostname.includes('api.eu.buddy.works') ||
942
+ baseUrl.hostname.includes('api.as.buddy.works')) {
943
+ return 'https://es.buddy.works/openapi/production/restapi.json';
944
+ }
945
+ else if (baseUrl.hostname.includes('api.awsstage.net') ||
946
+ baseUrl.hostname.includes('api.eu.awsstage.net') ||
947
+ baseUrl.hostname.includes('api.buddy.mom')) {
948
+ return 'https://es.buddy.works/openapi/stage/restapi.json';
949
+ }
950
+ else if (baseUrl.hostname.includes('api.awsmaster.net')) {
951
+ return 'https://es.buddy.works/openapi/master/restapi.json';
952
+ }
953
+ else {
954
+ return 'https://es.buddy.works/openapi/dev/restapi.json';
955
+ }
956
+ }
918
957
  function getAppHostByApiBaseUrl(baseUrl) {
919
958
  if (baseUrl.hostname.includes('api.buddy.works')) {
920
959
  return 'app.buddy.works';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.16.30-dev",
4
+ "version": "1.16.32-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -29,6 +29,10 @@
29
29
  "cookie": "1.0.2",
30
30
  "cross-spawn": "7.0.6",
31
31
  "eventsource": "4.0.0",
32
+ "@scalar/openapi-parser": "0.24.5",
33
+ "@scalar/json-magic": "0.9.4",
34
+ "@scalar/types": "0.5.10",
35
+ "@scalar/openapi-types": "0.5.3",
32
36
  "fastify": "4.28.1",
33
37
  "fdir": "6.5.0",
34
38
  "open": "11.0.0",