@autonomys/auto-drive 0.8.2 → 1.0.1
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/LICENSE +18 -0
- package/package.json +3 -3
- package/dist/api/calls/download.d.ts +0 -6
- package/dist/api/calls/download.d.ts.map +0 -1
- package/dist/api/calls/download.js +0 -12
- package/dist/api/calls/index.d.ts +0 -5
- package/dist/api/calls/index.d.ts.map +0 -1
- package/dist/api/calls/index.js +0 -4
- package/dist/api/calls/read.d.ts +0 -98
- package/dist/api/calls/read.d.ts.map +0 -1
- package/dist/api/calls/read.js +0 -140
- package/dist/api/calls/upload.d.ts +0 -94
- package/dist/api/calls/upload.d.ts.map +0 -1
- package/dist/api/calls/upload.js +0 -120
- package/dist/api/calls/write.d.ts +0 -49
- package/dist/api/calls/write.d.ts.map +0 -1
- package/dist/api/calls/write.js +0 -65
- package/dist/api/connection.d.ts +0 -8
- package/dist/api/connection.d.ts.map +0 -1
- package/dist/api/connection.js +0 -17
- package/dist/api/index.d.ts +0 -5
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -4
- package/dist/api/models/folderTree.d.ts +0 -45
- package/dist/api/models/folderTree.d.ts.map +0 -1
- package/dist/api/models/folderTree.js +0 -56
- package/dist/api/models/index.d.ts +0 -3
- package/dist/api/models/index.d.ts.map +0 -1
- package/dist/api/models/index.js +0 -2
- package/dist/api/models/objects.d.ts +0 -41
- package/dist/api/models/objects.d.ts.map +0 -1
- package/dist/api/models/objects.js +0 -10
- package/dist/api/models/uploads.d.ts +0 -114
- package/dist/api/models/uploads.d.ts.map +0 -1
- package/dist/api/models/uploads.js +0 -40
- package/dist/api/wrappers.d.ts +0 -67
- package/dist/api/wrappers.d.ts.map +0 -1
- package/dist/api/wrappers.js +0 -158
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/utils/async.d.ts +0 -3
- package/dist/utils/async.d.ts.map +0 -1
- package/dist/utils/async.js +0 -21
- package/dist/utils/folder.d.ts +0 -2
- package/dist/utils/folder.d.ts.map +0 -1
- package/dist/utils/folder.js +0 -14
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -4
- package/dist/utils/stream.d.ts +0 -3
- package/dist/utils/stream.d.ts.map +0 -1
- package/dist/utils/stream.js +0 -22
- package/dist/utils/types.d.ts +0 -6
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -1
package/dist/api/calls/write.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shares an object with a specified public ID.
|
|
3
|
-
*
|
|
4
|
-
* This function sends a request to the server to share an object identified
|
|
5
|
-
* by its CID. The object will be shared with the provided public ID, allowing
|
|
6
|
-
* access to the object for users with that ID.
|
|
7
|
-
*
|
|
8
|
-
* @param {AutoDriveApi} api - The API instance used to send requests.
|
|
9
|
-
* @param {ArgsWithoutPagination<{ cid: string; publicId: string }>} query - The query parameters containing the CID of the object to share and the public ID to share it with.
|
|
10
|
-
* @returns {Promise<any>} - A promise that resolves to the response from the server.
|
|
11
|
-
* @throws {Error} - Throws an error if the sharing process fails.
|
|
12
|
-
*/
|
|
13
|
-
export const shareObject = async (api, query) => {
|
|
14
|
-
const response = await api.sendRequest(`/objects/${query.cid}/share`, {
|
|
15
|
-
method: 'POST',
|
|
16
|
-
headers: new Headers({
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
}),
|
|
19
|
-
}, JSON.stringify({ publicId: query.publicId }));
|
|
20
|
-
if (!response.ok) {
|
|
21
|
-
throw new Error(`Failed to share object: ${response.statusText}`);
|
|
22
|
-
}
|
|
23
|
-
return response.json();
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Marks an object as deleted by sending a request to the server.
|
|
27
|
-
*
|
|
28
|
-
* This function sends a request to the server to mark an object identified
|
|
29
|
-
* by its CID as deleted. This action is typically irreversible and should
|
|
30
|
-
* be used with caution.
|
|
31
|
-
*
|
|
32
|
-
* @param {AutoDriveApi} api - The API instance used to send requests.
|
|
33
|
-
* @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object to mark as deleted.
|
|
34
|
-
* @returns {Promise<void>} - A promise that resolves when the object has been marked as deleted.
|
|
35
|
-
* @throws {Error} - Throws an error if the marking process fails.
|
|
36
|
-
*/
|
|
37
|
-
export const markObjectAsDeleted = async (api, query) => {
|
|
38
|
-
const response = await api.sendRequest(`/objects/${query.cid}/delete`, {
|
|
39
|
-
method: 'POST',
|
|
40
|
-
});
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
throw new Error(`Failed to mark object as deleted: ${response.statusText}`);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Restores an object that has been marked as deleted by sending a request to the server.
|
|
47
|
-
*
|
|
48
|
-
* This function sends a request to the server to restore an object identified
|
|
49
|
-
* by its CID. The restoration process may depend on the server's implementation
|
|
50
|
-
* and the object's current state.
|
|
51
|
-
*
|
|
52
|
-
* @param {AutoDriveApi} api - The API instance used to send requests.
|
|
53
|
-
* @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object to restore.
|
|
54
|
-
* @returns {Promise<void>} - A promise that resolves when the object has been successfully restored.
|
|
55
|
-
* @throws {Error} - Throws an error if the restoration process fails.
|
|
56
|
-
*/
|
|
57
|
-
export const restoreObject = async (api, query) => {
|
|
58
|
-
const response = await api.sendRequest(`/objects/${query.cid}/restore`, {
|
|
59
|
-
method: 'POST',
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
throw new Error(`Failed to restore object: ${response.statusText}`);
|
|
63
|
-
}
|
|
64
|
-
return response.json();
|
|
65
|
-
};
|
package/dist/api/connection.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface AutoDriveApi {
|
|
2
|
-
sendRequest: (relativeUrl: string, request: Partial<Request>, body?: BodyInit) => Promise<Response>;
|
|
3
|
-
}
|
|
4
|
-
export declare const createAutoDriveApi: ({ apiKey, url, }: {
|
|
5
|
-
apiKey: string;
|
|
6
|
-
url?: string;
|
|
7
|
-
}) => AutoDriveApi;
|
|
8
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/api/connection.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,CACX,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EACzB,IAAI,CAAC,EAAE,QAAQ,KACZ,OAAO,CAAC,QAAQ,CAAC,CAAA;CACvB;AAED,eAAO,MAAM,kBAAkB,qBAG5B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,KAAG,YAiBH,CAAA"}
|
package/dist/api/connection.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const createAutoDriveApi = ({ apiKey, url = 'https://demo.auto-drive.autonomys.xyz', }) => {
|
|
2
|
-
return {
|
|
3
|
-
sendRequest: async (relativeUrl, request, body) => {
|
|
4
|
-
const headers = new Headers({
|
|
5
|
-
...Object.fromEntries(request.headers?.entries() || []),
|
|
6
|
-
'x-auth-provider': 'apikey',
|
|
7
|
-
Authorization: `Bearer ${apiKey}`,
|
|
8
|
-
});
|
|
9
|
-
const fullRequest = {
|
|
10
|
-
...request,
|
|
11
|
-
headers: new Headers(headers),
|
|
12
|
-
body,
|
|
13
|
-
};
|
|
14
|
-
return fetch(`${url}${relativeUrl}`, fullRequest);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
};
|
package/dist/api/index.d.ts
DELETED
package/dist/api/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA"}
|
package/dist/api/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export type FolderTreeFolder = {
|
|
3
|
-
name: string;
|
|
4
|
-
type: 'folder';
|
|
5
|
-
children: FolderTree[];
|
|
6
|
-
id: string;
|
|
7
|
-
};
|
|
8
|
-
export type FolderTreeFile = {
|
|
9
|
-
name: string;
|
|
10
|
-
type: 'file';
|
|
11
|
-
id: string;
|
|
12
|
-
};
|
|
13
|
-
export type FolderTree = FolderTreeFolder | FolderTreeFile;
|
|
14
|
-
export declare const FolderTreeFolderSchema: z.ZodObject<{
|
|
15
|
-
name: z.ZodString;
|
|
16
|
-
type: z.ZodLiteral<"folder">;
|
|
17
|
-
children: z.ZodArray<z.ZodLazy<z.ZodType<FolderTree, z.ZodTypeDef, FolderTree>>, "many">;
|
|
18
|
-
id: z.ZodString;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
children: FolderTree[];
|
|
21
|
-
name: string;
|
|
22
|
-
type: "folder";
|
|
23
|
-
id: string;
|
|
24
|
-
}, {
|
|
25
|
-
children: FolderTree[];
|
|
26
|
-
name: string;
|
|
27
|
-
type: "folder";
|
|
28
|
-
id: string;
|
|
29
|
-
}>;
|
|
30
|
-
export declare const FolderTreeFileSchema: z.ZodObject<{
|
|
31
|
-
name: z.ZodString;
|
|
32
|
-
type: z.ZodLiteral<"file">;
|
|
33
|
-
id: z.ZodString;
|
|
34
|
-
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
name: string;
|
|
36
|
-
type: "file";
|
|
37
|
-
id: string;
|
|
38
|
-
}, {
|
|
39
|
-
name: string;
|
|
40
|
-
type: "file";
|
|
41
|
-
id: string;
|
|
42
|
-
}>;
|
|
43
|
-
export declare const FolderTreeSchema: z.ZodType<FolderTree>;
|
|
44
|
-
export declare const constructFromFileSystemEntries: (entries: string[]) => FolderTree;
|
|
45
|
-
//# sourceMappingURL=folderTree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"folderTree.d.ts","sourceRoot":"","sources":["../../../src/api/models/folderTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,UAAU,EAAE,CAAA;IACtB,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAA;AAE1D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;EAKjC,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAI/B,CAAA;AAEF,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAGjD,CAAA;AAEF,eAAO,MAAM,8BAA8B,YAAa,MAAM,EAAE,KAAG,UA0ClE,CAAA"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export const FolderTreeFolderSchema = z.object({
|
|
3
|
-
name: z.string(),
|
|
4
|
-
type: z.literal('folder'),
|
|
5
|
-
children: z.array(z.lazy(() => FolderTreeSchema)),
|
|
6
|
-
id: z.string(),
|
|
7
|
-
});
|
|
8
|
-
export const FolderTreeFileSchema = z.object({
|
|
9
|
-
name: z.string(),
|
|
10
|
-
type: z.literal('file'),
|
|
11
|
-
id: z.string(),
|
|
12
|
-
});
|
|
13
|
-
export const FolderTreeSchema = z.discriminatedUnion('type', [
|
|
14
|
-
FolderTreeFolderSchema,
|
|
15
|
-
FolderTreeFileSchema,
|
|
16
|
-
]);
|
|
17
|
-
export const constructFromFileSystemEntries = (entries) => {
|
|
18
|
-
const root = {
|
|
19
|
-
name: 'root',
|
|
20
|
-
type: 'folder',
|
|
21
|
-
children: [],
|
|
22
|
-
id: 'root',
|
|
23
|
-
};
|
|
24
|
-
for (const entry of entries) {
|
|
25
|
-
const pathParts = entry.split('/').filter(Boolean);
|
|
26
|
-
let currentFolder = root;
|
|
27
|
-
for (const [index, part] of Array.from(pathParts.entries())) {
|
|
28
|
-
// Check if the part already exists in the current folder's children
|
|
29
|
-
let existingFolder = currentFolder.children.find((child) => child.name === part);
|
|
30
|
-
if (!existingFolder) {
|
|
31
|
-
// If it's the last part, create a file node
|
|
32
|
-
if (index === pathParts.length - 1) {
|
|
33
|
-
const fileNode = {
|
|
34
|
-
name: part,
|
|
35
|
-
type: 'file',
|
|
36
|
-
id: entry,
|
|
37
|
-
};
|
|
38
|
-
currentFolder.children.push(fileNode);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Create a new folder node
|
|
42
|
-
const folderNode = {
|
|
43
|
-
name: part,
|
|
44
|
-
type: 'folder',
|
|
45
|
-
children: [],
|
|
46
|
-
id: `${currentFolder.id.split('/').slice(1).join('/')}/${part}`,
|
|
47
|
-
};
|
|
48
|
-
currentFolder.children.push(folderNode);
|
|
49
|
-
existingFolder = folderNode;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
currentFolder = existingFolder; // Move to the next folder
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return root.children.length === 1 ? root.children[0] : root;
|
|
56
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
|
package/dist/api/models/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { OffchainMetadata } from '@autonomys/auto-dag-data';
|
|
2
|
-
export declare enum Scope {
|
|
3
|
-
Global = "global",
|
|
4
|
-
User = "user"
|
|
5
|
-
}
|
|
6
|
-
export interface Owner {
|
|
7
|
-
publicId: string;
|
|
8
|
-
role: OwnerRole;
|
|
9
|
-
}
|
|
10
|
-
export declare enum OwnerRole {
|
|
11
|
-
ADMIN = "admin",
|
|
12
|
-
VIEWER = "viewer"
|
|
13
|
-
}
|
|
14
|
-
export interface ObjectUploadStatus {
|
|
15
|
-
uploadedNodes: number | null;
|
|
16
|
-
totalNodes: number | null;
|
|
17
|
-
minimumBlockDepth: number | null;
|
|
18
|
-
maximumBlockDepth: number | null;
|
|
19
|
-
}
|
|
20
|
-
export type ObjectSummary = {
|
|
21
|
-
headCid: string;
|
|
22
|
-
name?: string;
|
|
23
|
-
size: number;
|
|
24
|
-
owners: Owner[];
|
|
25
|
-
uploadStatus: ObjectUploadStatus;
|
|
26
|
-
} & ({
|
|
27
|
-
type: 'file';
|
|
28
|
-
mimeType?: string;
|
|
29
|
-
} | {
|
|
30
|
-
type: 'folder';
|
|
31
|
-
children: (OffchainMetadata & {
|
|
32
|
-
type: 'folder';
|
|
33
|
-
})['children'];
|
|
34
|
-
});
|
|
35
|
-
export interface ObjectInformation {
|
|
36
|
-
cid: string;
|
|
37
|
-
metadata: OffchainMetadata;
|
|
38
|
-
uploadStatus: ObjectUploadStatus;
|
|
39
|
-
owners: Owner[];
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/api/models/objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,oBAAY,KAAK;IACf,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,YAAY,EAAE,kBAAkB,CAAA;CACjC,GAAG,CACA;IACE,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,CAAC,gBAAgB,GAAG;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC,UAAU,CAAC,CAAA;CAC9D,CACJ,CAAA;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,YAAY,EAAE,kBAAkB,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export var Scope;
|
|
2
|
-
(function (Scope) {
|
|
3
|
-
Scope["Global"] = "global";
|
|
4
|
-
Scope["User"] = "user";
|
|
5
|
-
})(Scope || (Scope = {}));
|
|
6
|
-
export var OwnerRole;
|
|
7
|
-
(function (OwnerRole) {
|
|
8
|
-
OwnerRole["ADMIN"] = "admin";
|
|
9
|
-
OwnerRole["VIEWER"] = "viewer";
|
|
10
|
-
})(OwnerRole || (OwnerRole = {}));
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { FileUploadOptions } from '@autonomys/auto-dag-data';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export declare enum UploadType {
|
|
4
|
-
FILE = "file",
|
|
5
|
-
FOLDER = "folder"
|
|
6
|
-
}
|
|
7
|
-
export declare enum UploadStatus {
|
|
8
|
-
PENDING = "pending",
|
|
9
|
-
COMPLETED = "completed",
|
|
10
|
-
MIGRATING = "migrating",
|
|
11
|
-
CANCELLED = "cancelled",
|
|
12
|
-
FAILED = "failed"
|
|
13
|
-
}
|
|
14
|
-
export declare const fileUploadSchema: z.ZodObject<{
|
|
15
|
-
id: z.ZodString;
|
|
16
|
-
rootId: z.ZodString;
|
|
17
|
-
relativeId: z.ZodNullable<z.ZodString>;
|
|
18
|
-
type: z.ZodNativeEnum<typeof UploadType>;
|
|
19
|
-
status: z.ZodNativeEnum<typeof UploadStatus>;
|
|
20
|
-
fileTree: z.ZodNull;
|
|
21
|
-
name: z.ZodString;
|
|
22
|
-
mimeType: z.ZodNullable<z.ZodString>;
|
|
23
|
-
oauthProvider: z.ZodString;
|
|
24
|
-
oauthUserId: z.ZodString;
|
|
25
|
-
}, "strip", z.ZodTypeAny, {
|
|
26
|
-
name: string;
|
|
27
|
-
type: UploadType;
|
|
28
|
-
status: UploadStatus;
|
|
29
|
-
id: string;
|
|
30
|
-
rootId: string;
|
|
31
|
-
relativeId: string | null;
|
|
32
|
-
fileTree: null;
|
|
33
|
-
mimeType: string | null;
|
|
34
|
-
oauthProvider: string;
|
|
35
|
-
oauthUserId: string;
|
|
36
|
-
}, {
|
|
37
|
-
name: string;
|
|
38
|
-
type: UploadType;
|
|
39
|
-
status: UploadStatus;
|
|
40
|
-
id: string;
|
|
41
|
-
rootId: string;
|
|
42
|
-
relativeId: string | null;
|
|
43
|
-
fileTree: null;
|
|
44
|
-
mimeType: string | null;
|
|
45
|
-
oauthProvider: string;
|
|
46
|
-
oauthUserId: string;
|
|
47
|
-
}>;
|
|
48
|
-
export type FileUpload = z.infer<typeof fileUploadSchema> & {
|
|
49
|
-
uploadOptions: FileUploadOptions | null;
|
|
50
|
-
};
|
|
51
|
-
export declare const folderUploadSchema: z.ZodObject<{
|
|
52
|
-
id: z.ZodString;
|
|
53
|
-
rootId: z.ZodString;
|
|
54
|
-
relativeId: z.ZodNullable<z.ZodString>;
|
|
55
|
-
type: z.ZodNativeEnum<typeof UploadType>;
|
|
56
|
-
status: z.ZodNativeEnum<typeof UploadStatus>;
|
|
57
|
-
fileTree: z.ZodObject<{
|
|
58
|
-
name: z.ZodString;
|
|
59
|
-
type: z.ZodLiteral<"folder">;
|
|
60
|
-
children: z.ZodArray<z.ZodLazy<z.ZodType<import("./folderTree.js").FolderTree, z.ZodTypeDef, import("./folderTree.js").FolderTree>>, "many">;
|
|
61
|
-
id: z.ZodString;
|
|
62
|
-
}, "strip", z.ZodTypeAny, {
|
|
63
|
-
children: import("./folderTree.js").FolderTree[];
|
|
64
|
-
name: string;
|
|
65
|
-
type: "folder";
|
|
66
|
-
id: string;
|
|
67
|
-
}, {
|
|
68
|
-
children: import("./folderTree.js").FolderTree[];
|
|
69
|
-
name: string;
|
|
70
|
-
type: "folder";
|
|
71
|
-
id: string;
|
|
72
|
-
}>;
|
|
73
|
-
name: z.ZodString;
|
|
74
|
-
mimeType: z.ZodNull;
|
|
75
|
-
oauthProvider: z.ZodString;
|
|
76
|
-
oauthUserId: z.ZodString;
|
|
77
|
-
uploadOptions: z.ZodNull;
|
|
78
|
-
}, "strip", z.ZodTypeAny, {
|
|
79
|
-
name: string;
|
|
80
|
-
type: UploadType;
|
|
81
|
-
status: UploadStatus;
|
|
82
|
-
id: string;
|
|
83
|
-
rootId: string;
|
|
84
|
-
relativeId: string | null;
|
|
85
|
-
fileTree: {
|
|
86
|
-
children: import("./folderTree.js").FolderTree[];
|
|
87
|
-
name: string;
|
|
88
|
-
type: "folder";
|
|
89
|
-
id: string;
|
|
90
|
-
};
|
|
91
|
-
mimeType: null;
|
|
92
|
-
oauthProvider: string;
|
|
93
|
-
oauthUserId: string;
|
|
94
|
-
uploadOptions: null;
|
|
95
|
-
}, {
|
|
96
|
-
name: string;
|
|
97
|
-
type: UploadType;
|
|
98
|
-
status: UploadStatus;
|
|
99
|
-
id: string;
|
|
100
|
-
rootId: string;
|
|
101
|
-
relativeId: string | null;
|
|
102
|
-
fileTree: {
|
|
103
|
-
children: import("./folderTree.js").FolderTree[];
|
|
104
|
-
name: string;
|
|
105
|
-
type: "folder";
|
|
106
|
-
id: string;
|
|
107
|
-
};
|
|
108
|
-
mimeType: null;
|
|
109
|
-
oauthProvider: string;
|
|
110
|
-
oauthUserId: string;
|
|
111
|
-
uploadOptions: null;
|
|
112
|
-
}>;
|
|
113
|
-
export type FolderUpload = z.infer<typeof folderUploadSchema>;
|
|
114
|
-
//# sourceMappingURL=uploads.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../../src/api/models/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAED,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW3B,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,GAAG;IAC1D,aAAa,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY7B,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { FolderTreeFolderSchema } from './folderTree.js';
|
|
3
|
-
export var UploadType;
|
|
4
|
-
(function (UploadType) {
|
|
5
|
-
UploadType["FILE"] = "file";
|
|
6
|
-
UploadType["FOLDER"] = "folder";
|
|
7
|
-
})(UploadType || (UploadType = {}));
|
|
8
|
-
export var UploadStatus;
|
|
9
|
-
(function (UploadStatus) {
|
|
10
|
-
UploadStatus["PENDING"] = "pending";
|
|
11
|
-
UploadStatus["COMPLETED"] = "completed";
|
|
12
|
-
UploadStatus["MIGRATING"] = "migrating";
|
|
13
|
-
UploadStatus["CANCELLED"] = "cancelled";
|
|
14
|
-
UploadStatus["FAILED"] = "failed";
|
|
15
|
-
})(UploadStatus || (UploadStatus = {}));
|
|
16
|
-
export const fileUploadSchema = z.object({
|
|
17
|
-
id: z.string(),
|
|
18
|
-
rootId: z.string(),
|
|
19
|
-
relativeId: z.string().nullable(),
|
|
20
|
-
type: z.nativeEnum(UploadType),
|
|
21
|
-
status: z.nativeEnum(UploadStatus),
|
|
22
|
-
fileTree: z.null(),
|
|
23
|
-
name: z.string(),
|
|
24
|
-
mimeType: z.string().nullable(),
|
|
25
|
-
oauthProvider: z.string(),
|
|
26
|
-
oauthUserId: z.string(),
|
|
27
|
-
});
|
|
28
|
-
export const folderUploadSchema = z.object({
|
|
29
|
-
id: z.string(),
|
|
30
|
-
rootId: z.string(),
|
|
31
|
-
relativeId: z.string().nullable(),
|
|
32
|
-
type: z.nativeEnum(UploadType),
|
|
33
|
-
status: z.nativeEnum(UploadStatus),
|
|
34
|
-
fileTree: FolderTreeFolderSchema,
|
|
35
|
-
name: z.string(),
|
|
36
|
-
mimeType: z.null(),
|
|
37
|
-
oauthProvider: z.string(),
|
|
38
|
-
oauthUserId: z.string(),
|
|
39
|
-
uploadOptions: z.null(),
|
|
40
|
-
});
|
package/dist/api/wrappers.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { AutoDriveApi } from './connection.js';
|
|
2
|
-
type UploadFileOptions = {
|
|
3
|
-
password?: string;
|
|
4
|
-
compression?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Uploads a file to the server with optional encryption and compression.
|
|
8
|
-
*
|
|
9
|
-
* This function reads a file from the specified file path, optionally encrypts it
|
|
10
|
-
* using the provided password, and compresses it using the ZLIB algorithm if specified.
|
|
11
|
-
* It then uploads the file in chunks to the server, creating an upload session and
|
|
12
|
-
* completing it once all chunks have been uploaded.
|
|
13
|
-
*
|
|
14
|
-
* @param {AutoDriveApi} api - The API instance used to send requests.
|
|
15
|
-
* @param {string} filePath - The path to the file to be uploaded.
|
|
16
|
-
* @param {UploadFileOptions} options - Options for the upload process.
|
|
17
|
-
* @param {string} [options.password] - The password for encryption (optional).
|
|
18
|
-
* @param {boolean} [options.compression=true] - Whether to compress the file (optional).
|
|
19
|
-
* @returns {Promise<void>} - A promise that resolves when the upload is complete.
|
|
20
|
-
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
21
|
-
*/
|
|
22
|
-
export declare const uploadFile: (api: AutoDriveApi, filePath: string, { password, compression }: UploadFileOptions, uploadChunkSize?: number) => Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Uploads an entire folder to the server.
|
|
25
|
-
*
|
|
26
|
-
* This function retrieves all files within the specified folder,
|
|
27
|
-
* constructs a file tree representation, and initiates the upload
|
|
28
|
-
* process. It also handles optional compression of the files during
|
|
29
|
-
* the upload.
|
|
30
|
-
*
|
|
31
|
-
* @param {AutoDriveApi} api - The API instance used to send requests.
|
|
32
|
-
* @param {string} folderPath - The path of the folder to be uploaded.
|
|
33
|
-
* @returns {Promise<void>} - A promise that resolves when the folder upload is complete.
|
|
34
|
-
* @throws {Error} - Throws an error if the upload fails at any stage.
|
|
35
|
-
*/
|
|
36
|
-
export declare const uploadFolder: (api: AutoDriveApi, folderPath: string, uploadChunkSize?: number) => Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Uploads a file within an existing folder upload session.
|
|
39
|
-
*
|
|
40
|
-
* @param {AutoDriveApi} api - The API instance to interact with the AutoDrive service.
|
|
41
|
-
* @param {string} uploadId - The ID of the folder upload session to which the file will be added.
|
|
42
|
-
* @param {string} filepath - The path of the file to be uploaded.
|
|
43
|
-
*
|
|
44
|
-
* @returns {Promise<void>} A promise that resolves when the file upload is complete.
|
|
45
|
-
*/
|
|
46
|
-
export declare const uploadFileWithinFolderUpload: (api: AutoDriveApi, uploadId: string, filepath: string, uploadChunkSize?: number) => Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Downloads a file from the AutoDrive service.
|
|
49
|
-
*
|
|
50
|
-
* @param {AutoDriveApi} api - The API instance to interact with the AutoDrive service.
|
|
51
|
-
* @param {string} cid - The CID of the file to be downloaded.
|
|
52
|
-
* @returns {Promise<ReadableStream<Uint8Array>>} A promise that resolves to a ReadableStream of the downloaded file.
|
|
53
|
-
*/
|
|
54
|
-
export declare const downloadFile: (api: AutoDriveApi, cid: string, password?: string) => Promise<AsyncIterable<Buffer>>;
|
|
55
|
-
/**
|
|
56
|
-
* Downloads a folder from the AutoDrive service without encryption.
|
|
57
|
-
*
|
|
58
|
-
* @param {AutoDriveApi} api - The API instance to interact with the AutoDrive service.
|
|
59
|
-
* @param {string} cid - The CID of the folder to be downloaded.
|
|
60
|
-
*
|
|
61
|
-
* @returns {Promise<ReadableStream<Uint8Array>>} A promise that resolves to a ReadableStream of the downloaded folder.
|
|
62
|
-
*
|
|
63
|
-
* @warning If the folder is encrypted, a warning will be logged, but the download will proceed without decryption.
|
|
64
|
-
*/
|
|
65
|
-
export declare const downloadFolderWithoutEncryption: (api: AutoDriveApi, cid: string) => Promise<ReadableStream<Uint8Array>>;
|
|
66
|
-
export {};
|
|
67
|
-
//# sourceMappingURL=wrappers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/api/wrappers.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG9C,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAiBD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,QAChB,YAAY,YACP,MAAM,6BACkB,iBAAiB,oBACjC,MAAM,kBAuCzB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,QAClB,YAAY,cACL,MAAM,oBACA,MAAM,kBAqBzB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,QAClC,YAAY,YACP,MAAM,YACN,MAAM,oBACE,MAAM,kBAczB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAClB,YAAY,OACZ,MAAM,aACA,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAoB/B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,QACrC,YAAY,OACZ,MAAM,KACV,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CASpC,CAAA"}
|