@blaxel/core 0.2.49-dev.210 → 0.2.49-dev.211
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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/sandbox/filesystem/filesystem.js +4 -15
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/sandbox/filesystem/filesystem.js +4 -15
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/filesystem/filesystem.js +4 -15
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/sandbox/filesystem/filesystem.js +4 -15
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import { deleteFilesystemByPath, getFilesystemByPath, getWatchFilesystemByPath,
|
|
|
5
5
|
// Multipart upload constants
|
|
6
6
|
const MULTIPART_THRESHOLD = 5 * 1024 * 1024; // 5MB
|
|
7
7
|
const CHUNK_SIZE = 5 * 1024 * 1024; // 5MB per part
|
|
8
|
-
const MAX_PARALLEL_UPLOADS =
|
|
8
|
+
const MAX_PARALLEL_UPLOADS = 20; // Number of parallel part uploads
|
|
9
9
|
export class SandboxFileSystem extends SandboxAction {
|
|
10
10
|
process;
|
|
11
11
|
constructor(sandbox, process) {
|
|
@@ -301,7 +301,6 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
301
301
|
// Multipart upload helper methods
|
|
302
302
|
async initiateMultipartUpload(path, permissions = "0644") {
|
|
303
303
|
path = this.formatPath(path);
|
|
304
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
305
304
|
const { data } = await postFilesystemMultipartInitiateByPath({
|
|
306
305
|
path: { path },
|
|
307
306
|
body: { permissions },
|
|
@@ -312,7 +311,6 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
312
311
|
return data;
|
|
313
312
|
}
|
|
314
313
|
async uploadPart(uploadId, partNumber, fileBlob) {
|
|
315
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
316
314
|
const { data } = await putFilesystemMultipartByUploadIdPart({
|
|
317
315
|
path: { uploadId },
|
|
318
316
|
query: { partNumber },
|
|
@@ -324,7 +322,6 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
324
322
|
return data;
|
|
325
323
|
}
|
|
326
324
|
async completeMultipartUpload(uploadId, parts) {
|
|
327
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
328
325
|
const { data } = await postFilesystemMultipartByUploadIdComplete({
|
|
329
326
|
path: { uploadId },
|
|
330
327
|
body: { parts },
|
|
@@ -335,19 +332,17 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
335
332
|
return data;
|
|
336
333
|
}
|
|
337
334
|
async abortMultipartUpload(uploadId) {
|
|
338
|
-
|
|
339
|
-
await deleteFilesystemMultipartByUploadIdAbort({
|
|
335
|
+
const { data } = await deleteFilesystemMultipartByUploadIdAbort({
|
|
340
336
|
path: { uploadId },
|
|
341
337
|
baseUrl: this.url,
|
|
342
338
|
client: this.client,
|
|
343
339
|
throwOnError: true,
|
|
344
340
|
});
|
|
341
|
+
return data;
|
|
345
342
|
}
|
|
346
343
|
async uploadWithMultipart(path, blob, permissions = "0644") {
|
|
347
344
|
// Initiate multipart upload
|
|
348
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
349
345
|
const initResponse = await this.initiateMultipartUpload(path, permissions);
|
|
350
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
351
346
|
const uploadId = initResponse.uploadId;
|
|
352
347
|
if (!uploadId) {
|
|
353
348
|
throw new Error("Failed to get upload ID from initiate response");
|
|
@@ -364,26 +359,20 @@ export class SandboxFileSystem extends SandboxAction {
|
|
|
364
359
|
const start = (partNumber - 1) * CHUNK_SIZE;
|
|
365
360
|
const end = Math.min(start + CHUNK_SIZE, size);
|
|
366
361
|
const chunk = blob.slice(start, end);
|
|
367
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
368
362
|
batch.push(this.uploadPart(uploadId, partNumber, chunk));
|
|
369
363
|
}
|
|
370
364
|
// Wait for batch to complete
|
|
371
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
372
365
|
const batchResults = await Promise.all(batch);
|
|
373
|
-
|
|
374
|
-
parts.push(...batchResults.map((r) => ({ partNumber: r.partNumber, etag: r.etag })));
|
|
366
|
+
parts.push(...batchResults);
|
|
375
367
|
}
|
|
376
368
|
// Sort parts by partNumber to ensure correct order
|
|
377
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
378
369
|
parts.sort((a, b) => (a.partNumber ?? 0) - (b.partNumber ?? 0));
|
|
379
370
|
// Complete the upload
|
|
380
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
381
371
|
return await this.completeMultipartUpload(uploadId, parts);
|
|
382
372
|
}
|
|
383
373
|
catch (error) {
|
|
384
374
|
// Abort the upload on failure
|
|
385
375
|
try {
|
|
386
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
387
376
|
await this.abortMultipartUpload(uploadId);
|
|
388
377
|
}
|
|
389
378
|
catch (abortError) {
|