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