@autonomys/auto-drive 1.1.0 → 1.1.2
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/api/models/file.d.ts +2 -0
- package/dist/api/models/file.d.ts.map +1 -1
- package/dist/api/wrappers.d.ts +4 -4
- package/dist/api/wrappers.d.ts.map +1 -1
- package/dist/api/wrappers.js +4 -3
- package/dist/fs/wrappers.d.ts +1 -1
- package/dist/fs/wrappers.d.ts.map +1 -1
- package/dist/fs/wrappers.js +2 -3
- package/package.json +4 -4
- package/src/api/models/file.ts +3 -0
- package/src/api/wrappers.ts +7 -5
- package/src/fs/wrappers.ts +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/api/models/file.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/api/models/file.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,IAAI,EAAE,MAAM,CAAA;CACb"}
|
package/dist/api/wrappers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PromisedObservable } from '../utils/observable';
|
|
2
2
|
import { AutoDriveApi } from './connection';
|
|
3
|
-
import { GenericFile } from './models/file';
|
|
3
|
+
import { GenericFile, GenericFileWithinFolder } from './models/file';
|
|
4
4
|
import { UploadChunksStatus, UploadFileStatus, UploadFolderStatus } from './models/uploads';
|
|
5
5
|
export type UploadFileOptions = {
|
|
6
6
|
password?: string;
|
|
@@ -23,7 +23,7 @@ export type UploadFileOptions = {
|
|
|
23
23
|
* @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
|
|
24
24
|
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
25
25
|
*/
|
|
26
|
-
export declare const uploadFileFromInput: (api: AutoDriveApi, file: File,
|
|
26
|
+
export declare const uploadFileFromInput: (api: AutoDriveApi, file: File, options?: UploadFileOptions, uploadChunkSize?: number) => PromisedObservable<UploadFileStatus>;
|
|
27
27
|
/**
|
|
28
28
|
* Uploads a file to the server with optional encryption and compression.
|
|
29
29
|
*
|
|
@@ -41,7 +41,7 @@ export declare const uploadFileFromInput: (api: AutoDriveApi, file: File, { pass
|
|
|
41
41
|
* @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
|
|
42
42
|
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
43
43
|
*/
|
|
44
|
-
export declare const uploadFile: (api: AutoDriveApi, file: GenericFile,
|
|
44
|
+
export declare const uploadFile: (api: AutoDriveApi, file: GenericFile, options?: UploadFileOptions, uploadChunkSize?: number) => PromisedObservable<UploadFileStatus>;
|
|
45
45
|
/**
|
|
46
46
|
* Uploads an entire folder to the server.
|
|
47
47
|
*
|
|
@@ -72,7 +72,7 @@ export declare const uploadFolderFromInput: (api: AutoDriveApi, fileList: FileLi
|
|
|
72
72
|
*
|
|
73
73
|
* @returns {Promise<void>} A promise that resolves when the file upload is complete.
|
|
74
74
|
*/
|
|
75
|
-
export declare const uploadFileWithinFolderUpload: (api: AutoDriveApi, uploadId: string, file:
|
|
75
|
+
export declare const uploadFileWithinFolderUpload: (api: AutoDriveApi, uploadId: string, file: GenericFileWithinFolder, uploadChunkSize?: number) => PromisedObservable<UploadChunksStatus>;
|
|
76
76
|
/**
|
|
77
77
|
* Downloads a file from the AutoDrive service.
|
|
78
78
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/api/wrappers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAWxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/api/wrappers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAWxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAEpE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAE3F,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAuBD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,QACzB,YAAY,QACX,IAAI,YACD,iBAAiB,oBACR,MAAM,KACvB,kBAAkB,CAAC,gBAAgB,CAgDrC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,QAChB,YAAY,QACX,WAAW,YACR,iBAAiB,oBACR,MAAM,KACvB,kBAAkB,CAAC,gBAAgB,CAiDrC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,QAC3B,YAAY,YACP,QAAQ,GAAG,IAAI,EAAE,kCACI;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC7E,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,CA8DnE,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,QAClC,YAAY,YACP,MAAM,QACV,uBAAuB,oBACX,MAAM,KACvB,kBAAkB,CAAC,kBAAkB,CAkBvC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAClB,YAAY,OACZ,MAAM,aACA,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAwB/B,CAAA"}
|
package/dist/api/wrappers.js
CHANGED
|
@@ -70,7 +70,8 @@ const uploadFileChunks = (api, fileUploadId, asyncIterable, uploadChunkSize = UP
|
|
|
70
70
|
* @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
|
|
71
71
|
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
72
72
|
*/
|
|
73
|
-
const uploadFileFromInput = (api, file,
|
|
73
|
+
const uploadFileFromInput = (api, file, options = {}, uploadChunkSize) => {
|
|
74
|
+
const { password = undefined, compression = true } = options;
|
|
74
75
|
return new observable_1.PromisedObservable((subscriber) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
76
|
const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } = yield import('@autonomys/auto-dag-data');
|
|
76
77
|
let asyncIterable = (0, async_1.fileToIterable)(file);
|
|
@@ -127,7 +128,8 @@ exports.uploadFileFromInput = uploadFileFromInput;
|
|
|
127
128
|
* @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
|
|
128
129
|
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
129
130
|
*/
|
|
130
|
-
const uploadFile = (api, file,
|
|
131
|
+
const uploadFile = (api, file, options = {}, uploadChunkSize) => {
|
|
132
|
+
const { password = undefined, compression = true } = options;
|
|
131
133
|
return new observable_1.PromisedObservable((subscriber) => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
134
|
const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } = yield import('@autonomys/auto-dag-data');
|
|
133
135
|
let asyncIterable = file.read();
|
|
@@ -197,7 +199,6 @@ const uploadFolderFromInput = (api_1, fileList_1, ...args_1) => __awaiter(void 0
|
|
|
197
199
|
name: `${name}.zip`,
|
|
198
200
|
mimeType: 'application/zip',
|
|
199
201
|
size: zipBlob.size,
|
|
200
|
-
path: name,
|
|
201
202
|
}, {
|
|
202
203
|
password,
|
|
203
204
|
compression: true,
|
package/dist/fs/wrappers.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { PromisedObservable } from '../utils/observable.js';
|
|
|
19
19
|
* @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
|
|
20
20
|
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
21
21
|
*/
|
|
22
|
-
export declare const uploadFileFromFilepath: (api: AutoDriveApi, filePath: string,
|
|
22
|
+
export declare const uploadFileFromFilepath: (api: AutoDriveApi, filePath: string, options?: UploadFileOptions, uploadChunkSize?: number) => PromisedObservable<UploadFileStatus>;
|
|
23
23
|
/**
|
|
24
24
|
* Uploads an entire folder to the server.
|
|
25
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/fs/wrappers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAInD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAAc,iBAAiB,EAAgC,MAAM,oBAAoB,CAAA;AAGhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAG3D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,QAC5B,YAAY,YACP,MAAM,
|
|
1
|
+
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/fs/wrappers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAInD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAAc,iBAAiB,EAAgC,MAAM,oBAAoB,CAAA;AAGhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAG3D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,QAC5B,YAAY,YACP,MAAM,YACP,iBAAiB,oBACR,MAAM,KACvB,kBAAkB,CAAC,gBAAgB,CAkBrC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,0BAA0B,QAChC,YAAY,cACL,MAAM,kCACa;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC7E,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,CA6DnE,CAAA"}
|
package/dist/fs/wrappers.js
CHANGED
|
@@ -39,14 +39,14 @@ const utils_js_1 = require("./utils.js");
|
|
|
39
39
|
* @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
|
|
40
40
|
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
41
41
|
*/
|
|
42
|
-
const uploadFileFromFilepath = (api, filePath,
|
|
42
|
+
const uploadFileFromFilepath = (api, filePath, options = {}, uploadChunkSize) => {
|
|
43
|
+
const { password = undefined, compression = true } = options;
|
|
43
44
|
const name = filePath.split('/').pop();
|
|
44
45
|
return (0, wrappers_js_1.uploadFile)(api, {
|
|
45
46
|
read: () => fs_1.default.createReadStream(filePath),
|
|
46
47
|
name,
|
|
47
48
|
mimeType: mime_types_1.default.lookup(name) || undefined,
|
|
48
49
|
size: fs_1.default.statSync(filePath).size,
|
|
49
|
-
path: filePath,
|
|
50
50
|
}, {
|
|
51
51
|
password,
|
|
52
52
|
compression,
|
|
@@ -83,7 +83,6 @@ const uploadFolderFromFolderPath = (api_1, folderPath_1, ...args_1) => __awaiter
|
|
|
83
83
|
name: `${name}.zip`,
|
|
84
84
|
mimeType: 'application/zip',
|
|
85
85
|
size: zipBlob.size,
|
|
86
|
-
path: name,
|
|
87
86
|
}, {
|
|
88
87
|
password,
|
|
89
88
|
compression: true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-drive",
|
|
3
3
|
"packageManager": "yarn@4.2.2",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
".": {
|
|
25
25
|
"browser": "./dist/browser.js",
|
|
26
26
|
"node": "./dist/node.js",
|
|
27
|
-
"types": "./dist/
|
|
27
|
+
"types": "./dist/node.d.ts"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"typescript": "^5.6.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@autonomys/auto-dag-data": "^1.1.
|
|
43
|
+
"@autonomys/auto-dag-data": "^1.1.2",
|
|
44
44
|
"jszip": "^3.10.1",
|
|
45
45
|
"mime-types": "^2.1.35",
|
|
46
46
|
"process": "^0.11.10",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"stream": "^0.0.3",
|
|
49
49
|
"zod": "^3.23.8"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "e84f9598911e27aec4de31fbd6a7663f8e364a20"
|
|
52
52
|
}
|
package/src/api/models/file.ts
CHANGED
package/src/api/wrappers.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
uploadFileChunk,
|
|
15
15
|
} from './calls/index'
|
|
16
16
|
import { AutoDriveApi } from './connection'
|
|
17
|
-
import { GenericFile } from './models/file'
|
|
17
|
+
import { GenericFile, GenericFileWithinFolder } from './models/file'
|
|
18
18
|
import { constructFromInput, constructZipBlobFromTreeAndPaths } from './models/folderTree'
|
|
19
19
|
import { UploadChunksStatus, UploadFileStatus, UploadFolderStatus } from './models/uploads'
|
|
20
20
|
|
|
@@ -64,9 +64,10 @@ const uploadFileChunks = (
|
|
|
64
64
|
export const uploadFileFromInput = (
|
|
65
65
|
api: AutoDriveApi,
|
|
66
66
|
file: File,
|
|
67
|
-
|
|
67
|
+
options: UploadFileOptions = {},
|
|
68
68
|
uploadChunkSize?: number,
|
|
69
69
|
): PromisedObservable<UploadFileStatus> => {
|
|
70
|
+
const { password = undefined, compression = true } = options
|
|
70
71
|
return new PromisedObservable<UploadFileStatus>(async (subscriber) => {
|
|
71
72
|
const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } =
|
|
72
73
|
await import('@autonomys/auto-dag-data')
|
|
@@ -135,9 +136,11 @@ export const uploadFileFromInput = (
|
|
|
135
136
|
export const uploadFile = (
|
|
136
137
|
api: AutoDriveApi,
|
|
137
138
|
file: GenericFile,
|
|
138
|
-
|
|
139
|
+
options: UploadFileOptions = {},
|
|
139
140
|
uploadChunkSize?: number,
|
|
140
141
|
): PromisedObservable<UploadFileStatus> => {
|
|
142
|
+
const { password = undefined, compression = true } = options
|
|
143
|
+
|
|
141
144
|
return new PromisedObservable<UploadFileStatus>(async (subscriber) => {
|
|
142
145
|
const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } =
|
|
143
146
|
await import('@autonomys/auto-dag-data')
|
|
@@ -226,7 +229,6 @@ export const uploadFolderFromInput = async (
|
|
|
226
229
|
name: `${name}.zip`,
|
|
227
230
|
mimeType: 'application/zip',
|
|
228
231
|
size: zipBlob.size,
|
|
229
|
-
path: name,
|
|
230
232
|
},
|
|
231
233
|
{
|
|
232
234
|
password,
|
|
@@ -284,7 +286,7 @@ export const uploadFolderFromInput = async (
|
|
|
284
286
|
export const uploadFileWithinFolderUpload = (
|
|
285
287
|
api: AutoDriveApi,
|
|
286
288
|
uploadId: string,
|
|
287
|
-
file:
|
|
289
|
+
file: GenericFileWithinFolder,
|
|
288
290
|
uploadChunkSize?: number,
|
|
289
291
|
): PromisedObservable<UploadChunksStatus> => {
|
|
290
292
|
return new PromisedObservable<UploadChunksStatus>(async (subscriber) => {
|
package/src/fs/wrappers.ts
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs'
|
|
|
2
2
|
import mime from 'mime-types'
|
|
3
3
|
import { AutoDriveApi } from '../api/connection.js'
|
|
4
4
|
import { completeUpload, createFolderUpload } from '../api/index.js'
|
|
5
|
-
import {
|
|
5
|
+
import { GenericFileWithinFolder } from '../api/models/file.js'
|
|
6
6
|
import { constructFromFileSystemEntries } from '../api/models/folderTree.js'
|
|
7
7
|
import { UploadFileStatus, UploadFolderStatus } from '../api/models/uploads.js'
|
|
8
8
|
import { uploadFile, UploadFileOptions, uploadFileWithinFolderUpload } from '../api/wrappers.js'
|
|
@@ -31,9 +31,10 @@ import { constructZipFromTreeAndFileSystemPaths, getFiles } from './utils.js'
|
|
|
31
31
|
export const uploadFileFromFilepath = (
|
|
32
32
|
api: AutoDriveApi,
|
|
33
33
|
filePath: string,
|
|
34
|
-
|
|
34
|
+
options: UploadFileOptions = {},
|
|
35
35
|
uploadChunkSize?: number,
|
|
36
36
|
): PromisedObservable<UploadFileStatus> => {
|
|
37
|
+
const { password = undefined, compression = true } = options
|
|
37
38
|
const name = filePath.split('/').pop()!
|
|
38
39
|
|
|
39
40
|
return uploadFile(
|
|
@@ -43,7 +44,6 @@ export const uploadFileFromFilepath = (
|
|
|
43
44
|
name,
|
|
44
45
|
mimeType: mime.lookup(name) || undefined,
|
|
45
46
|
size: fs.statSync(filePath).size,
|
|
46
|
-
path: filePath,
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
password,
|
|
@@ -90,7 +90,6 @@ export const uploadFolderFromFolderPath = async (
|
|
|
90
90
|
name: `${name}.zip`,
|
|
91
91
|
mimeType: 'application/zip',
|
|
92
92
|
size: zipBlob.size,
|
|
93
|
-
path: name,
|
|
94
93
|
},
|
|
95
94
|
{
|
|
96
95
|
password,
|
|
@@ -111,7 +110,7 @@ export const uploadFolderFromFolderPath = async (
|
|
|
111
110
|
},
|
|
112
111
|
})
|
|
113
112
|
|
|
114
|
-
const genericFiles:
|
|
113
|
+
const genericFiles: GenericFileWithinFolder[] = files.map((file) => ({
|
|
115
114
|
read: () => fs.createReadStream(file),
|
|
116
115
|
name: file.split('/').pop()!,
|
|
117
116
|
mimeType: mime.lookup(file.split('/').pop()!) || undefined,
|