bdy 1.16.38-dev → 1.17.3-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.38-dev",
4
+ "version": "1.17.3-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -39,7 +39,7 @@
39
39
  "fflate": "0.8.2",
40
40
  "human-id": "^4.1.3",
41
41
  "isbinaryfile": "5.0.2",
42
- "jsonwebtoken": "9.0.2",
42
+ "jsonwebtoken": "9.0.3",
43
43
  "mime-db": "1.52.0",
44
44
  "mime-types": "2.1.35",
45
45
  "netmask": "2.0.2",
@@ -54,6 +54,7 @@
54
54
  "socket.io-client": "4.7.5",
55
55
  "ssh2": "1.15.0",
56
56
  "tar-stream": "3.1.7",
57
+ "unzipper": "0.12.3",
57
58
  "terminal-kit": "3.1.1",
58
59
  "undici": "6.23.0",
59
60
  "uuid": "10.0.0",
@@ -62,16 +63,15 @@
62
63
  "zod": "3.24.2"
63
64
  },
64
65
  "devDependencies": {
65
- "@eslint/js": "9.13.0",
66
+ "@eslint/js": "9.39.2",
66
67
  "@rollup/plugin-commonjs": "28.0.1",
67
68
  "@rollup/plugin-json": "6.1.0",
68
69
  "@rollup/plugin-node-resolve": "15.3.0",
69
70
  "@rollup/plugin-replace": "6.0.1",
70
- "@stylistic/eslint-plugin-js": "2.9.0",
71
+ "@stylistic/eslint-plugin": "4.4.1",
71
72
  "@types/basic-auth": "1.1.8",
72
73
  "@types/content-disposition": "0.5.4",
73
74
  "@types/cross-spawn": "6.0.6",
74
- "@types/eslint__js": "8.42.3",
75
75
  "@types/jsonwebtoken": "9.0.2",
76
76
  "@types/mime-db": "1.43.6",
77
77
  "@types/mime-types": "2.1.4",
@@ -82,18 +82,19 @@
82
82
  "@types/punycode": "2.1.4",
83
83
  "@types/range-parser": "1.2.1",
84
84
  "@types/ssh2": "1.15.5",
85
- "@types/tar-stream": "3.1.3",
85
+ "@types/tar-stream": "3.1.4",
86
86
  "@types/terminal-kit": "2.5.6",
87
87
  "@types/uuid": "10.0.0",
88
88
  "@types/which": "3.0.4",
89
89
  "@types/ws": "8.18.0",
90
- "eslint": "9.13.0",
91
- "eslint-config-prettier": "9.1.0",
90
+ "@types/unzipper": "0.10.11",
91
+ "eslint": "9.39.2",
92
+ "eslint-config-prettier": "9.1.2",
92
93
  "globals": "15.11.0",
93
94
  "prettier": "3.3.3",
94
95
  "rollup": "4.24.2",
95
96
  "rollup-plugin-natives": "0.7.8",
96
97
  "typescript": "5.9.3",
97
- "typescript-eslint": "8.11.0"
98
+ "typescript-eslint": "8.54.0"
98
99
  }
99
100
  }
@@ -7,6 +7,7 @@ const utils_1 = require("../../utils");
7
7
  const texts_1 = require("../../texts");
8
8
  const input_1 = __importDefault(require("../../input"));
9
9
  const output_1 = __importDefault(require("../../output"));
10
+ const logger_1 = __importDefault(require("../../logger"));
10
11
  var SCHEMA_TYPE;
11
12
  (function (SCHEMA_TYPE) {
12
13
  SCHEMA_TYPE["OBJECT"] = "object";
@@ -167,16 +168,16 @@ const outputBodyObject = (mediaType, data) => {
167
168
  output_1.default.exitError((0, texts_1.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED)(mediaType));
168
169
  }
169
170
  };
170
- const outputResponse = (response) => {
171
+ const outputResponse = (response, schema) => {
171
172
  const content = response.content || {};
172
173
  Object.keys(content).forEach((mediaType, index) => {
173
174
  if (index > 0) {
174
175
  output_1.default.gray(' ------- or content type -------');
175
176
  }
176
- outputMediaType(mediaType, content[mediaType]);
177
+ outputMediaType(mediaType, content[mediaType], 'response-schema', schema);
177
178
  });
178
179
  };
179
- const outputResponsesBody = (responses) => {
180
+ const outputResponsesBody = (responses, schema) => {
180
181
  const r = responses || {};
181
182
  const codes = Object.keys(r);
182
183
  if (codes.length > 0) {
@@ -187,32 +188,64 @@ const outputResponsesBody = (responses) => {
187
188
  }
188
189
  output_1.default.gray(' http status: ', false);
189
190
  output_1.default.normal(code);
190
- outputResponse(r[code]);
191
+ outputResponse(r[code], schema);
191
192
  });
192
193
  }
193
194
  };
194
- const outputMediaType = (mediaType, mediaTypeObject) => {
195
+ const outputMediaType = (mediaType, mediaTypeObject, schemaParamName, userSchema) => {
195
196
  output_1.default.gray(' content-type: ', false);
196
197
  output_1.default.normal(mediaType);
197
198
  if (mediaTypeObject.schema) {
198
199
  if (mediaTypeObject.schema.oneOf) {
199
- const mappings = Object.keys(mediaTypeObject.schema.discriminator?.mapping || {});
200
- mediaTypeObject.schema.oneOf.forEach((schema, index) => {
201
- if (mappings[index]) {
202
- output_1.default.gray(` ${mappings[index]}:`);
200
+ const schemas = mediaTypeObject.schema.oneOf;
201
+ if (!schemas.length) {
202
+ output_1.default.exitError(' media type does not contain any schemas');
203
+ }
204
+ else if (schemas.length === 1) {
205
+ outputBodyObject(mediaType, schemas[0]);
206
+ }
207
+ else {
208
+ const mappings = Object.keys(mediaTypeObject.schema.discriminator?.mapping || {});
209
+ for (let i = 1; i <= schemas.length; i += 1) {
210
+ if (i.toString() === userSchema) {
211
+ outputBodyObject(mediaType, schemas[i]);
212
+ return;
213
+ }
203
214
  }
204
- else if (index > 0) {
205
- output_1.default.gray(' ------------- or --------------');
215
+ for (let i = 0; i < mappings.length; i += 1) {
216
+ if (mappings[i] === userSchema) {
217
+ const schema = schemas[i];
218
+ if (schema) {
219
+ outputBodyObject(mediaType, schema);
220
+ return;
221
+ }
222
+ }
206
223
  }
207
- outputBodyObject(mediaType, schema);
208
- });
224
+ output_1.default.gray(` media type contains ${schemas.length} schemas:`);
225
+ for (let i = 1; i <= schemas.length; i += 1) {
226
+ const mapping = mappings[i - 1];
227
+ const name = mapping ? `${i}: ${mapping}` : `${i}`;
228
+ outputTextWithPadding(name, 1, false);
229
+ const schema = schemas[i - 1];
230
+ logger_1.default.info(schema);
231
+ if (schema) {
232
+ if (schema.deprecated)
233
+ output_1.default.gray(` (deprecated)`, false);
234
+ const desc = schema['x-name'] || schema.title || schema.description;
235
+ if (desc)
236
+ output_1.default.gray(` - ${desc}`, false);
237
+ }
238
+ output_1.default.normal('');
239
+ }
240
+ outputTextWithPadding(`pass --${schemaParamName} with number or type to view it`);
241
+ }
209
242
  }
210
243
  else {
211
244
  outputBodyObject(mediaType, mediaTypeObject.schema);
212
245
  }
213
246
  }
214
247
  };
215
- const outputRequestBody = (data) => {
248
+ const outputRequestBody = (data, schema) => {
216
249
  if (data) {
217
250
  output_1.default.blue(` Request body`);
218
251
  const content = data.content || {};
@@ -220,12 +253,12 @@ const outputRequestBody = (data) => {
220
253
  if (index > 0) {
221
254
  output_1.default.gray(' ------- or content type -------');
222
255
  }
223
- outputMediaType(mediaType, content[mediaType]);
256
+ outputMediaType(mediaType, content[mediaType], 'request-schema', schema);
224
257
  });
225
258
  output_1.default.normal('');
226
259
  }
227
260
  };
228
- const outputUrl = (url, method, data, workspace, project) => {
261
+ const outputUrl = (url, method, data, workspace, project, requestSchema, responseSchema) => {
229
262
  output_1.default.normal(`${method} ${url}`);
230
263
  if (data.summary)
231
264
  output_1.default.gray(data.summary, false);
@@ -239,8 +272,8 @@ const outputUrl = (url, method, data, workspace, project) => {
239
272
  output_1.default.normal('\n');
240
273
  outputParameters('path', data, workspace, project);
241
274
  outputParameters('query', data, workspace, project);
242
- outputRequestBody(data.requestBody);
243
- outputResponsesBody(data.responses);
275
+ outputRequestBody(data.requestBody, requestSchema);
276
+ outputResponsesBody(data.responses, responseSchema);
244
277
  output_1.default.exitNormal();
245
278
  };
246
279
  const commandApiInfo = (0, utils_1.newCommand)('info', texts_1.DESC_COMMAND_API_INFO);
@@ -249,6 +282,8 @@ commandApiInfo.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
249
282
  commandApiInfo.option('--region <region>', texts_1.OPTION_REST_API_REGION);
250
283
  commandApiInfo.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
251
284
  commandApiInfo.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
285
+ commandApiInfo.option('--request-schema <schema>', texts_1.OPT_COMMAND_API_INFO_SCHEMA);
286
+ commandApiInfo.option('--response-schema <schema>', texts_1.OPT_COMMAND_API_INFO_SCHEMA);
252
287
  commandApiInfo.argument('<method>', texts_1.OPT_COMMAND_API_INFO_METHOD);
253
288
  commandApiInfo.argument('<url>', texts_1.OPT_COMMAND_API_INFO_URL);
254
289
  commandApiInfo.action(async (fm, filterUrl, options) => {
@@ -264,7 +299,7 @@ commandApiInfo.action(async (fm, filterUrl, options) => {
264
299
  const methods = paths[url] || {};
265
300
  Object.entries(methods).forEach(([method, data]) => {
266
301
  if (filterMethod === method)
267
- outputUrl(preparedUrl, method, data, workspace, project);
302
+ outputUrl(preparedUrl, method, data, workspace, project, options.requestSchema, options.responseSchema);
268
303
  });
269
304
  }
270
305
  });
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -12,6 +45,7 @@ const path_1 = require("path");
12
45
  const uuid_1 = require("uuid");
13
46
  const fs_1 = __importDefault(require("fs"));
14
47
  const promises_1 = __importDefault(require("node:stream/promises"));
48
+ const unzipper_1 = __importStar(require("../../unzipper"));
15
49
  const commandPackageDownload = (0, utils_1.newCommand)('download', texts_1.DESC_COMMAND_PACKAGE_DOWNLOAD);
16
50
  commandPackageDownload.alias('dd');
17
51
  commandPackageDownload.option('-t, --token <token>', texts_1.OPTION_REST_API_TOKEN);
@@ -120,7 +154,7 @@ commandPackageDownload.action(async (id, path, options) => {
120
154
  output_1.default.normal(texts_1.TXT_PACKAGE_DOWNLOADED_ZIP);
121
155
  output_1.default.normal(texts_1.TXT_PACKAGE_UNZIPPING);
122
156
  let count = 0;
123
- await (0, utils_1.unzipFile)(dirPath, zipPath, () => {
157
+ await unzipper_1.default.extract(unzipper_1.UNZIPPER_FORMAT.ZIP, zipPath, dirPath, async () => {
124
158
  count += 1;
125
159
  output_1.default.clearPreviousLine();
126
160
  output_1.default.normal((0, texts_1.TXT_PACKAGE_UNZIPPING_COUNT)(count));
@@ -101,7 +101,6 @@ commandPackagePublish.action(async (id, path, options) => {
101
101
  isSymbolicLink: () => stat.isSymbolicLink(),
102
102
  name: (0, path_1.basename)(dirPath),
103
103
  parentPath,
104
- path: parentPath,
105
104
  },
106
105
  ];
107
106
  dirPath = parentPath;
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -12,6 +45,7 @@ const path_1 = require("path");
12
45
  const node_fs_1 = __importDefault(require("node:fs"));
13
46
  const uuid_1 = require("uuid");
14
47
  const promises_1 = __importDefault(require("node:stream/promises"));
48
+ const unzipper_1 = __importStar(require("../../unzipper"));
15
49
  const commandSandboxCp = (0, utils_1.newCommand)('cp', texts_1.DESC_COMMAND_SANDBOX_CP);
16
50
  commandSandboxCp.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
17
51
  commandSandboxCp.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
@@ -50,7 +84,9 @@ const upload = async (client, workspace, project, source, destination) => {
50
84
  output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(0));
51
85
  }
52
86
  output_1.default.normal('');
53
- const baseRemoteDir = isRemoteDir ? (0, path_1.join)(remotePath, (0, path_1.basename)(sourcePath)) : remotePath;
87
+ const baseRemoteDir = isRemoteDir
88
+ ? (0, path_1.join)(remotePath, (0, path_1.basename)(sourcePath))
89
+ : remotePath;
54
90
  for (let i = 0; i < files.length; i++) {
55
91
  const localFile = files[i];
56
92
  const relativePath = (0, path_1.relative)(sourcePath, localFile);
@@ -102,7 +138,7 @@ const download = async (client, workspace, project, source, destination, merge,
102
138
  output_1.default.normal(texts_1.TXT_SANDBOX_CP_DOWNLOAD_DONE);
103
139
  output_1.default.normal(texts_1.TXT_SANDBOX_UNZIP);
104
140
  let count = 0;
105
- await (0, utils_1.untarGz)(destDirPath, zipPath, () => {
141
+ await unzipper_1.default.extract(unzipper_1.UNZIPPER_FORMAT.TAR_GZ, zipPath, destDirPath, async () => {
106
142
  count += 1;
107
143
  output_1.default.clearPreviousLine();
108
144
  output_1.default.normal((0, texts_1.TXT_SANDBOX_UNZIPPING_COUNT)(count));
@@ -10,9 +10,9 @@ exports.LOG_SOCKET_CONNECTED = exports.LOG_AGENT_NSSM_CLEARING = exports.LOG_AGE
10
10
  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 = 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 = void 0;
11
11
  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 = 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 = void 0;
12
12
  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 = 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 = void 0;
13
- exports.DESC_COMMAND_WORKSPACE = exports.TXT_LOGOUT_SUCCESS = exports.DESC_COMMAND_LOGOUT = exports.DESC_COMMAND_LOGIN = exports.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = exports.ERR_API_PARAMETER_NOT_REPLACED = 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.ERR_API_REQUEST_BODY_VALUE = exports.ERR_API_REQUEST_QUERY_VALUE = exports.ERR_API_REQUEST_INVALID_JSON = exports.ERR_API_REQUEST_FILE_ERROR = exports.ERR_API_REQUEST_OUTPUT_EXISTS = exports.DESC_COMMAND_API_INFO = exports.DESC_COMMAND_API_FORM = exports.DESC_COMMAND_API_JSON = exports.DESC_COMMAND_API_DATA = exports.DESC_COMMAND_API_OUTPUT = exports.DESC_COMMAND_API_REQUEST_QUERY = exports.DESC_COMMAND_API_PROJECT = exports.DESC_COMMAND_API_WORKSPACE = exports.DESC_COMMAND_API_REQUEST_URL = exports.DESC_COMMAND_API_GET = exports.DESC_COMMAND_API_PATCH = exports.DESC_COMMAND_API_DELETE = exports.DESC_COMMAND_API_PUT = exports.DESC_COMMAND_API_POST = 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 = 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 = void 0;
14
- 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 = 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 = void 0;
15
- 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_TUNNEL_START = exports.EXAMPLE_TUNNEL_TCP = exports.EXAMPLE_TUNNEL_TLS = exports.EXAMPLE_AGENT_TUNNEL_START = exports.EXAMPLE_AGENT_TUNNEL_STATUS = exports.EXAMPLE_AGENT_TUNNEL_REMOVE = exports.EXAMPLE_AGENT_TUNNEL_LIST = exports.EXAMPLE_TUNNEL_HTTP = 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 = void 0;
13
+ exports.TXT_LOGOUT_SUCCESS = exports.DESC_COMMAND_LOGOUT = exports.DESC_COMMAND_LOGIN = exports.ERR_API_MEDIA_TYPE_NOT_IMPLEMENTED = exports.ERR_API_PARAMETER_NOT_REPLACED = 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_SCHEMA = exports.OPT_COMMAND_API_INFO_METHOD = exports.OPT_COMMAND_API_LIST_SEARCH = exports.OPT_COMMAND_API_LIST_METHOD = exports.ERR_API_REQUEST_BODY_VALUE = exports.ERR_API_REQUEST_QUERY_VALUE = exports.ERR_API_REQUEST_INVALID_JSON = exports.ERR_API_REQUEST_FILE_ERROR = exports.ERR_API_REQUEST_OUTPUT_EXISTS = exports.DESC_COMMAND_API_INFO = exports.DESC_COMMAND_API_FORM = exports.DESC_COMMAND_API_JSON = exports.DESC_COMMAND_API_DATA = exports.DESC_COMMAND_API_OUTPUT = exports.DESC_COMMAND_API_REQUEST_QUERY = exports.DESC_COMMAND_API_PROJECT = exports.DESC_COMMAND_API_WORKSPACE = exports.DESC_COMMAND_API_REQUEST_URL = exports.DESC_COMMAND_API_GET = exports.DESC_COMMAND_API_PATCH = exports.DESC_COMMAND_API_DELETE = exports.DESC_COMMAND_API_PUT = exports.DESC_COMMAND_API_POST = 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 = 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 = void 0;
14
+ 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 = 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 = void 0;
15
+ 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_TUNNEL_START = exports.EXAMPLE_TUNNEL_TCP = exports.EXAMPLE_TUNNEL_TLS = exports.EXAMPLE_AGENT_TUNNEL_START = exports.EXAMPLE_AGENT_TUNNEL_STATUS = exports.EXAMPLE_AGENT_TUNNEL_REMOVE = exports.EXAMPLE_AGENT_TUNNEL_LIST = exports.EXAMPLE_TUNNEL_HTTP = 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 = void 0;
16
16
  const utils_1 = require("./utils");
17
17
  exports.ERR_REST_API_GENERAL_ERROR = 'Something went wrong';
18
18
  exports.ERR_REST_API_NOT_RESPONDING = 'Api endpoint not responding. Try again later...';
@@ -687,6 +687,7 @@ exports.ERR_API_REQUEST_BODY_VALUE = ERR_API_REQUEST_BODY_VALUE;
687
687
  exports.OPT_COMMAND_API_LIST_METHOD = 'Filter endpoints by method (all, get, post, put, patch, delete). Default: all';
688
688
  exports.OPT_COMMAND_API_LIST_SEARCH = 'Filter endpoints by phrase';
689
689
  exports.OPT_COMMAND_API_INFO_METHOD = 'Endpoint method (get, post, put, patch, delete)';
690
+ exports.OPT_COMMAND_API_INFO_SCHEMA = 'Pass schema name or index to view it';
690
691
  exports.OPT_COMMAND_API_INFO_URL = 'Endpoint url';
691
692
  exports.ERR_SCHEMA_FETCH_FAILED = 'Failed to fetch api schema';
692
693
  exports.ERR_API_WRONG_METHOD = 'Wrong method value';
@@ -342,8 +342,9 @@ class ServerSftp {
342
342
  async rmdir(reqId, path) {
343
343
  const s = this.debugStart(`SFTP want to remove directory ${path}`);
344
344
  try {
345
- await promises_1.default.rmdir(path, {
345
+ await promises_1.default.rm(path, {
346
346
  recursive: true,
347
+ force: true
347
348
  });
348
349
  this.sftp.status(reqId, STATUS_CODE.OK);
349
350
  this.debugEnd('SFTP remove directory succeed', s);
@@ -0,0 +1,182 @@
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
+ exports.UNZIPPER_FORMAT = exports.UNZIPPER_ENTRY_TYPE = void 0;
7
+ const unzipper_1 = __importDefault(require("unzipper"));
8
+ const tar_stream_1 = __importDefault(require("tar-stream"));
9
+ const node_zlib_1 = __importDefault(require("node:zlib"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const node_stream_1 = require("node:stream");
12
+ const node_fs_1 = __importDefault(require("node:fs"));
13
+ var UNZIPPER_ENTRY_TYPE;
14
+ (function (UNZIPPER_ENTRY_TYPE) {
15
+ UNZIPPER_ENTRY_TYPE["DIRECTORY"] = "Directory";
16
+ UNZIPPER_ENTRY_TYPE["FILE"] = "File";
17
+ })(UNZIPPER_ENTRY_TYPE || (exports.UNZIPPER_ENTRY_TYPE = UNZIPPER_ENTRY_TYPE = {}));
18
+ var UNZIPPER_FORMAT;
19
+ (function (UNZIPPER_FORMAT) {
20
+ UNZIPPER_FORMAT["ZIP"] = "ZIP";
21
+ UNZIPPER_FORMAT["TAR_GZ"] = "TAR.GZ";
22
+ UNZIPPER_FORMAT["TAR_BR"] = "TAR.BR";
23
+ })(UNZIPPER_FORMAT || (exports.UNZIPPER_FORMAT = UNZIPPER_FORMAT = {}));
24
+ const extractZipPathEntry = async (inPath, outPath, onEntry) => {
25
+ const dir = await unzipper_1.default.Open.file(inPath);
26
+ for (let i = 0; i < dir.files.length; i += 1) {
27
+ const entry = dir.files[i];
28
+ const name = entry.path;
29
+ const type = entry.type;
30
+ if (onEntry) {
31
+ await onEntry(name, type);
32
+ }
33
+ const fullPath = node_path_1.default.join(outPath, name);
34
+ if (type === UNZIPPER_ENTRY_TYPE.DIRECTORY) {
35
+ await removePath(fullPath);
36
+ await createDirectory(fullPath);
37
+ }
38
+ else if (type === UNZIPPER_ENTRY_TYPE.FILE) {
39
+ const parentPath = node_path_1.default.resolve(fullPath, '..');
40
+ await createDirectory(parentPath);
41
+ await removePath(fullPath);
42
+ await writeStream(fullPath, entry.stream());
43
+ }
44
+ }
45
+ };
46
+ const streamFromString = (str) => {
47
+ const s = new node_stream_1.Readable();
48
+ s.push(str);
49
+ s.push(null);
50
+ return s;
51
+ };
52
+ const writeStream = async (fullPath, stream) => {
53
+ await node_fs_1.default.promises.writeFile(fullPath, stream);
54
+ };
55
+ const removePath = async (fullPath) => {
56
+ await node_fs_1.default.promises.rm(fullPath, {
57
+ recursive: true,
58
+ force: true,
59
+ });
60
+ };
61
+ const createDirectory = async (fullPath) => {
62
+ await node_fs_1.default.promises.mkdir(fullPath, {
63
+ recursive: true,
64
+ });
65
+ };
66
+ const extractTarStream = (stream, middle, outPath, onEntry) => {
67
+ return new Promise((resolve, reject) => {
68
+ const extract = tar_stream_1.default.extract();
69
+ const closeStream = (err) => {
70
+ if (err)
71
+ reject(err);
72
+ else
73
+ resolve();
74
+ resolve = () => {
75
+ };
76
+ reject = () => {
77
+ };
78
+ if (stream) {
79
+ try {
80
+ stream.removeAllListeners();
81
+ stream.destroy();
82
+ }
83
+ catch {
84
+ // do nothing
85
+ }
86
+ }
87
+ if (middle) {
88
+ try {
89
+ middle.removeAllListeners();
90
+ middle.close();
91
+ }
92
+ catch {
93
+ // do nothing
94
+ }
95
+ }
96
+ if (extract) {
97
+ try {
98
+ extract.removeAllListeners();
99
+ extract.destroy();
100
+ }
101
+ catch {
102
+ // do nothing
103
+ }
104
+ }
105
+ };
106
+ extract.on('entry', async (header, stream, next) => {
107
+ let name;
108
+ let type;
109
+ let str;
110
+ if (header && header.type === 'directory') {
111
+ type = UNZIPPER_ENTRY_TYPE.DIRECTORY;
112
+ name = header.name;
113
+ stream.resume();
114
+ }
115
+ else if (header && header.type === 'file') {
116
+ type = UNZIPPER_ENTRY_TYPE.FILE;
117
+ name = header.name;
118
+ str = stream;
119
+ }
120
+ else if (header && header.type === 'symlink' && header.linkname) {
121
+ type = UNZIPPER_ENTRY_TYPE.FILE;
122
+ name = header.name;
123
+ stream.resume();
124
+ str = streamFromString(header.linkname);
125
+ }
126
+ else {
127
+ stream.resume();
128
+ next();
129
+ return;
130
+ }
131
+ if (onEntry) {
132
+ await onEntry(name, type);
133
+ }
134
+ const fullPath = node_path_1.default.join(outPath, name);
135
+ if (type === UNZIPPER_ENTRY_TYPE.DIRECTORY) {
136
+ await removePath(fullPath);
137
+ await createDirectory(fullPath);
138
+ }
139
+ else if (type === UNZIPPER_ENTRY_TYPE.FILE && str) {
140
+ const parentPath = node_path_1.default.resolve(fullPath, '..');
141
+ await createDirectory(parentPath);
142
+ await removePath(fullPath);
143
+ await writeStream(fullPath, stream);
144
+ }
145
+ next();
146
+ });
147
+ extract.on('error', (err) => {
148
+ closeStream(err);
149
+ });
150
+ extract.on('finish', () => {
151
+ closeStream();
152
+ });
153
+ middle.on('error', (err) => {
154
+ extract.emit('error', err);
155
+ });
156
+ stream.on('error', (err) => {
157
+ extract.emit('error', err);
158
+ });
159
+ stream.pipe(middle).pipe(extract);
160
+ });
161
+ };
162
+ const extractTarGzPathEntry = async (inPath, outPath, onEntry) => {
163
+ return await extractTarStream(node_fs_1.default.createReadStream(inPath), node_zlib_1.default.createGunzip(), outPath, onEntry);
164
+ };
165
+ const extractTarBrPathEntry = async (inPath, outPath, onEntry) => {
166
+ return await extractTarStream(node_fs_1.default.createReadStream(inPath), node_zlib_1.default.createBrotliDecompress(), outPath, onEntry);
167
+ };
168
+ class ArchiverExtract {
169
+ static async extract(format, inPath, outPath, onEntry) {
170
+ if (format === UNZIPPER_FORMAT.ZIP) {
171
+ return await extractZipPathEntry(inPath, outPath, onEntry);
172
+ }
173
+ if (format === UNZIPPER_FORMAT.TAR_GZ) {
174
+ return await extractTarGzPathEntry(inPath, outPath, onEntry);
175
+ }
176
+ if (format === UNZIPPER_FORMAT.TAR_BR) {
177
+ return await extractTarBrPathEntry(inPath, outPath, onEntry);
178
+ }
179
+ throw new Error('Wrong extract format');
180
+ }
181
+ }
182
+ exports.default = ArchiverExtract;
@@ -43,23 +43,19 @@ exports.isFile = isFile;
43
43
  exports.getAppWorkspaceUrl = getAppWorkspaceUrl;
44
44
  exports.getAppWorkspaceSettingsUrl = getAppWorkspaceSettingsUrl;
45
45
  exports.getAppUrl = getAppUrl;
46
- exports.untarGz = untarGz;
47
- exports.unzipFile = unzipFile;
48
46
  exports.getDockerRegistryHostByApiBaseUrl = getDockerRegistryHostByApiBaseUrl;
49
47
  exports.fetchOpenApiSchema = fetchOpenApiSchema;
50
48
  exports.openApiPrepareUrl = openApiPrepareUrl;
51
49
  exports.getOpenApiEndpointByApiBaseUrl = getOpenApiEndpointByApiBaseUrl;
52
50
  exports.getAppHostByApiBaseUrl = getAppHostByApiBaseUrl;
53
51
  const node_path_1 = __importDefault(require("node:path"));
54
- const node_fs_1 = __importStar(require("node:fs"));
52
+ const node_fs_1 = require("node:fs");
55
53
  const texts_1 = require("./texts");
56
54
  const ssh2_1 = __importDefault(require("ssh2"));
57
55
  const node_sea_1 = require("node:sea");
58
56
  const commander_1 = require("commander");
59
57
  const node_os_1 = __importStar(require("node:os"));
60
58
  const node_child_process_1 = require("node:child_process");
61
- const fflate_1 = require("fflate");
62
- const tar_stream_1 = __importDefault(require("tar-stream"));
63
59
  const bundle_1 = require("@scalar/json-magic/bundle");
64
60
  const node_1 = require("@scalar/json-magic/bundle/plugins/node");
65
61
  const openapi_parser_1 = require("@scalar/openapi-parser");
@@ -580,278 +576,6 @@ function getAppWorkspaceSettingsUrl(baseUrl, workspace) {
580
576
  function getAppUrl(baseUrl, path) {
581
577
  return `https://${getAppHostByApiBaseUrl(baseUrl)}${path}`;
582
578
  }
583
- function untarGz(dirPath, tarGzPath, onFile) {
584
- return new Promise((resolve, reject) => {
585
- let _startedFiles = 0;
586
- let _finishedFiles = 0;
587
- let _finishedStream = false;
588
- let _finishedError = null;
589
- let _calledResolve = false;
590
- const rs = node_fs_1.default.createReadStream(tarGzPath);
591
- const extract = tar_stream_1.default.extract();
592
- const _finish = () => {
593
- if (_finishedError || _finishedStream) {
594
- try {
595
- rs.removeAllListeners();
596
- rs.close();
597
- }
598
- catch {
599
- // do nothing
600
- }
601
- }
602
- if (_calledResolve)
603
- return;
604
- if (_finishedError) {
605
- _calledResolve = true;
606
- reject(_finishedError);
607
- return;
608
- }
609
- if (_finishedStream && _startedFiles === _finishedFiles) {
610
- _calledResolve = true;
611
- resolve();
612
- }
613
- };
614
- const finishFile = (err, fws) => {
615
- if (!_finishedError && err)
616
- _finishedError = err;
617
- const complete = () => {
618
- _finishedFiles += 1;
619
- onFile();
620
- _finish();
621
- };
622
- if (fws) {
623
- fws.once('finish', () => {
624
- fws.removeAllListeners();
625
- complete();
626
- });
627
- fws.end();
628
- }
629
- else {
630
- complete();
631
- }
632
- };
633
- const finishStream = (err) => {
634
- if (!_finishedError && err)
635
- _finishedError = err;
636
- _finishedStream = true;
637
- _finish();
638
- };
639
- extract.on('entry', async (header, stream, next) => {
640
- if (_finishedError) {
641
- stream.resume();
642
- next();
643
- return;
644
- }
645
- _startedFiles += 1;
646
- const fullPath = node_path_1.default.join(dirPath, header.name);
647
- const parentPath = node_path_1.default.dirname(fullPath);
648
- let fws;
649
- try {
650
- await node_fs_1.default.promises.rm(fullPath, {
651
- recursive: true,
652
- force: true,
653
- });
654
- }
655
- catch {
656
- // do nothing
657
- }
658
- try {
659
- if (header.type === 'directory') {
660
- await node_fs_1.default.promises.mkdir(fullPath, {
661
- recursive: true,
662
- });
663
- stream.resume();
664
- finishFile();
665
- next();
666
- return;
667
- }
668
- await node_fs_1.default.promises.mkdir(parentPath, {
669
- recursive: true,
670
- });
671
- fws = node_fs_1.default.createWriteStream(fullPath, {
672
- flags: 'w',
673
- });
674
- fws.on('error', (err) => {
675
- finishFile(err, fws);
676
- });
677
- }
678
- catch (err) {
679
- stream.resume();
680
- finishFile(err, fws);
681
- next();
682
- return;
683
- }
684
- stream.on('data', (chunk) => {
685
- if (_finishedError)
686
- return;
687
- if (fws) {
688
- fws.write(chunk);
689
- }
690
- });
691
- stream.on('end', () => {
692
- finishFile(null, fws);
693
- next();
694
- });
695
- stream.on('error', (err) => {
696
- finishFile(err, fws);
697
- next();
698
- });
699
- });
700
- extract.on('finish', () => {
701
- finishStream();
702
- });
703
- extract.on('error', (err) => {
704
- finishStream(err);
705
- });
706
- const gunzip = new fflate_1.Gunzip((data, final) => {
707
- if (_finishedError)
708
- return;
709
- extract.write(Buffer.from(data));
710
- if (final) {
711
- extract.end();
712
- }
713
- });
714
- rs.on('data', (chunk) => {
715
- try {
716
- gunzip.push(chunk, false);
717
- }
718
- catch (err) {
719
- finishStream(err);
720
- }
721
- });
722
- rs.on('error', (err) => {
723
- finishStream(err);
724
- });
725
- rs.on('end', () => {
726
- try {
727
- gunzip.push(new Uint8Array(0), true);
728
- }
729
- catch (err) {
730
- finishStream(err);
731
- }
732
- });
733
- });
734
- }
735
- function unzipFile(dirPath, zipPath, onFile) {
736
- return new Promise((resolve, reject) => {
737
- let _startedFiles = 0;
738
- let _finishedFiles = 0;
739
- let _finishedStream = false;
740
- let _finishedError = null;
741
- let _calledResolve = false;
742
- const rs = node_fs_1.default.createReadStream(zipPath);
743
- const _finish = () => {
744
- if (_finishedError || _finishedStream) {
745
- try {
746
- rs.removeAllListeners();
747
- rs.close();
748
- }
749
- catch {
750
- // do nothing
751
- }
752
- }
753
- if (_calledResolve)
754
- return;
755
- if (_finishedError) {
756
- _calledResolve = true;
757
- reject(_finishedError);
758
- return;
759
- }
760
- if (_finishedStream && _startedFiles === _finishedFiles) {
761
- _calledResolve = true;
762
- resolve();
763
- }
764
- };
765
- const finishFile = (err, fws) => {
766
- if (!_finishedError && err)
767
- _finishedError = err;
768
- const complete = () => {
769
- _finishedFiles += 1;
770
- onFile();
771
- _finish();
772
- };
773
- if (fws) {
774
- fws.once('finish', () => {
775
- fws.removeAllListeners();
776
- complete();
777
- });
778
- fws.end();
779
- }
780
- else {
781
- complete();
782
- }
783
- };
784
- const finishStream = (err) => {
785
- if (!_finishedError && err)
786
- _finishedError = err;
787
- _finishedStream = true;
788
- _finish();
789
- };
790
- const unzip = new fflate_1.Unzip(async (file) => {
791
- if (_finishedError)
792
- return;
793
- _startedFiles += 1;
794
- const fullPath = node_path_1.default.join(dirPath, file.name);
795
- const parentPath = node_path_1.default.dirname(fullPath);
796
- let fws;
797
- try {
798
- await node_fs_1.default.promises.rm(fullPath, {
799
- recursive: true,
800
- force: true,
801
- });
802
- }
803
- catch {
804
- // do nothing
805
- }
806
- try {
807
- if (fullPath.endsWith('/')) {
808
- await node_fs_1.default.promises.mkdir(fullPath, {
809
- recursive: true,
810
- });
811
- finishFile();
812
- return;
813
- }
814
- await node_fs_1.default.promises.mkdir(parentPath, {
815
- recursive: true,
816
- });
817
- fws = node_fs_1.default.createWriteStream(fullPath, {
818
- flags: 'w',
819
- });
820
- fws.on('error', (err) => {
821
- finishFile(err, fws);
822
- });
823
- }
824
- catch (err) {
825
- finishFile(err, fws);
826
- return;
827
- }
828
- file.ondata = (err, data, final) => {
829
- if (_finishedError)
830
- return;
831
- if (err)
832
- finishFile(err, fws);
833
- else {
834
- if (fws)
835
- fws.write(data);
836
- if (final)
837
- finishFile(null, fws);
838
- }
839
- };
840
- file.start();
841
- });
842
- unzip.register(fflate_1.AsyncUnzipInflate);
843
- rs.on('data', (chunk) => {
844
- unzip.push(chunk, false);
845
- });
846
- rs.on('error', (err) => {
847
- finishStream(err);
848
- });
849
- rs.on('end', () => {
850
- unzip.push(new Uint8Array(0), true);
851
- finishStream();
852
- });
853
- });
854
- }
855
579
  function getDockerRegistryHostByApiBaseUrl(baseUrl) {
856
580
  if (baseUrl.hostname.includes('api.buddy.works')) {
857
581
  return 'container-pkg.buddy.works';
@@ -38,7 +38,12 @@ function setCiAndCommitInfo(ciInfo) {
38
38
  exports.pullRequestNumber = ciInfo.pullRequestNumber;
39
39
  exports.commit = ciInfo.commit;
40
40
  exports.baseCommit = ciInfo.baseCommit;
41
- exports.commitDetails = ciInfo.commitDetails;
41
+ exports.commitDetails = ciInfo.commitDetails
42
+ ? {
43
+ ...ciInfo.commitDetails,
44
+ message: ciInfo.commitDetails.message?.slice(0, 250),
45
+ }
46
+ : undefined;
42
47
  if (ciInfo.ci === ci_info_1.CI.BUDDY) {
43
48
  exports.pipelineId = ciInfo.pipelineId;
44
49
  exports.actionId = ciInfo.actionId;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.16.38-dev",
4
+ "version": "1.17.3-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -39,7 +39,7 @@
39
39
  "fflate": "0.8.2",
40
40
  "human-id": "^4.1.3",
41
41
  "isbinaryfile": "5.0.2",
42
- "jsonwebtoken": "9.0.2",
42
+ "jsonwebtoken": "9.0.3",
43
43
  "mime-db": "1.52.0",
44
44
  "mime-types": "2.1.35",
45
45
  "netmask": "2.0.2",
@@ -54,6 +54,7 @@
54
54
  "socket.io-client": "4.7.5",
55
55
  "ssh2": "1.15.0",
56
56
  "tar-stream": "3.1.7",
57
+ "unzipper": "0.12.3",
57
58
  "terminal-kit": "3.1.1",
58
59
  "undici": "6.23.0",
59
60
  "uuid": "10.0.0",
@@ -62,16 +63,15 @@
62
63
  "zod": "3.24.2"
63
64
  },
64
65
  "devDependencies": {
65
- "@eslint/js": "9.13.0",
66
+ "@eslint/js": "9.39.2",
66
67
  "@rollup/plugin-commonjs": "28.0.1",
67
68
  "@rollup/plugin-json": "6.1.0",
68
69
  "@rollup/plugin-node-resolve": "15.3.0",
69
70
  "@rollup/plugin-replace": "6.0.1",
70
- "@stylistic/eslint-plugin-js": "2.9.0",
71
+ "@stylistic/eslint-plugin": "4.4.1",
71
72
  "@types/basic-auth": "1.1.8",
72
73
  "@types/content-disposition": "0.5.4",
73
74
  "@types/cross-spawn": "6.0.6",
74
- "@types/eslint__js": "8.42.3",
75
75
  "@types/jsonwebtoken": "9.0.2",
76
76
  "@types/mime-db": "1.43.6",
77
77
  "@types/mime-types": "2.1.4",
@@ -82,18 +82,19 @@
82
82
  "@types/punycode": "2.1.4",
83
83
  "@types/range-parser": "1.2.1",
84
84
  "@types/ssh2": "1.15.5",
85
- "@types/tar-stream": "3.1.3",
85
+ "@types/tar-stream": "3.1.4",
86
86
  "@types/terminal-kit": "2.5.6",
87
87
  "@types/uuid": "10.0.0",
88
88
  "@types/which": "3.0.4",
89
89
  "@types/ws": "8.18.0",
90
- "eslint": "9.13.0",
91
- "eslint-config-prettier": "9.1.0",
90
+ "@types/unzipper": "0.10.11",
91
+ "eslint": "9.39.2",
92
+ "eslint-config-prettier": "9.1.2",
92
93
  "globals": "15.11.0",
93
94
  "prettier": "3.3.3",
94
95
  "rollup": "4.24.2",
95
96
  "rollup-plugin-natives": "0.7.8",
96
97
  "typescript": "5.9.3",
97
- "typescript-eslint": "8.11.0"
98
+ "typescript-eslint": "8.54.0"
98
99
  }
99
100
  }