@autonomys/auto-drive 1.1.3 → 1.2.0

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.
Files changed (84) hide show
  1. package/.env +6 -0
  2. package/LICENSE +18 -0
  3. package/README.md +42 -84
  4. package/dist/api/calls/download.d.ts +6 -0
  5. package/dist/api/calls/download.d.ts.map +1 -0
  6. package/dist/api/calls/download.js +25 -0
  7. package/dist/api/calls/index.d.ts +57 -0
  8. package/dist/api/calls/index.d.ts.map +1 -0
  9. package/dist/api/calls/index.js +41 -0
  10. package/dist/api/calls/read.d.ts +99 -0
  11. package/dist/api/calls/read.d.ts.map +1 -0
  12. package/dist/api/calls/read.js +159 -0
  13. package/dist/api/calls/upload.d.ts +93 -0
  14. package/dist/api/calls/upload.d.ts.map +1 -0
  15. package/dist/api/calls/upload.js +137 -0
  16. package/dist/api/calls/write.d.ts +49 -0
  17. package/dist/api/calls/write.d.ts.map +1 -0
  18. package/dist/api/calls/write.js +80 -0
  19. package/dist/api/connection.d.ts +15 -0
  20. package/dist/api/connection.d.ts.map +1 -0
  21. package/dist/api/connection.js +28 -0
  22. package/dist/api/index.d.ts +5 -0
  23. package/dist/api/index.d.ts.map +1 -0
  24. package/dist/api/index.js +20 -0
  25. package/dist/api/models/common.d.ts +5 -0
  26. package/dist/api/models/common.d.ts.map +1 -0
  27. package/dist/api/models/common.js +2 -0
  28. package/dist/api/models/file.d.ts +10 -0
  29. package/dist/api/models/file.d.ts.map +1 -0
  30. package/dist/api/models/file.js +2 -0
  31. package/dist/api/models/folderTree.d.ts +47 -0
  32. package/dist/api/models/folderTree.d.ts.map +1 -0
  33. package/dist/api/models/folderTree.js +105 -0
  34. package/dist/api/models/index.d.ts +3 -0
  35. package/dist/api/models/index.d.ts.map +1 -0
  36. package/dist/api/models/index.js +18 -0
  37. package/dist/api/models/objects.d.ts +72 -0
  38. package/dist/api/models/objects.d.ts.map +1 -0
  39. package/dist/api/models/objects.js +13 -0
  40. package/dist/api/models/uploads.d.ts +148 -0
  41. package/dist/api/models/uploads.d.ts.map +1 -0
  42. package/dist/api/models/uploads.js +51 -0
  43. package/dist/api/wrappers.d.ts +84 -0
  44. package/dist/api/wrappers.d.ts.map +1 -0
  45. package/dist/api/wrappers.js +287 -0
  46. package/dist/browser.d.ts +3 -0
  47. package/dist/browser.d.ts.map +1 -0
  48. package/dist/browser.js +18 -0
  49. package/dist/fs/index.d.ts +3 -0
  50. package/dist/fs/index.d.ts.map +1 -0
  51. package/dist/fs/index.js +18 -0
  52. package/dist/fs/utils.d.ts +6 -0
  53. package/dist/fs/utils.d.ts.map +1 -0
  54. package/dist/fs/utils.js +84 -0
  55. package/dist/fs/wrappers.d.ts +44 -0
  56. package/dist/fs/wrappers.d.ts.map +1 -0
  57. package/dist/fs/wrappers.js +124 -0
  58. package/dist/node.d.ts +3 -0
  59. package/dist/node.d.ts.map +1 -0
  60. package/dist/node.js +18 -0
  61. package/dist/utils/async.d.ts +5 -0
  62. package/dist/utils/async.d.ts.map +1 -0
  63. package/dist/utils/async.js +73 -0
  64. package/dist/utils/autohash.d.ts +17 -0
  65. package/dist/utils/autohash.d.ts.map +1 -0
  66. package/dist/utils/autohash.js +73 -0
  67. package/dist/utils/index.d.ts +4 -0
  68. package/dist/utils/index.d.ts.map +1 -0
  69. package/dist/utils/index.js +19 -0
  70. package/dist/utils/misc.d.ts +2 -0
  71. package/dist/utils/misc.d.ts.map +1 -0
  72. package/dist/utils/misc.js +5 -0
  73. package/dist/utils/observable.d.ts +2 -0
  74. package/dist/utils/observable.d.ts.map +1 -0
  75. package/dist/utils/observable.js +2 -0
  76. package/dist/utils/types.d.ts +6 -0
  77. package/dist/utils/types.d.ts.map +1 -0
  78. package/dist/utils/types.js +2 -0
  79. package/package.json +3 -4
  80. package/src/api/wrappers.ts +113 -112
  81. package/src/fs/wrappers.ts +44 -39
  82. package/src/utils/index.ts +0 -1
  83. package/tsconfig.json +3 -1
  84. package/src/utils/observable.ts +0 -19
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./objects"), exports);
18
+ __exportStar(require("./uploads"), exports);
@@ -0,0 +1,72 @@
1
+ import { FileUploadOptions } from './uploads';
2
+ export type OffchainMetadata = OffchainFileMetadata | OffchainFolderMetadata;
3
+ interface ChildrenMetadata {
4
+ type: 'folder' | 'file';
5
+ name?: string;
6
+ cid: string;
7
+ totalSize: bigint;
8
+ }
9
+ export type OffchainFolderMetadata = {
10
+ type: 'folder';
11
+ dataCid: string;
12
+ name?: string;
13
+ totalSize: bigint;
14
+ totalFiles: number;
15
+ children: ChildrenMetadata[];
16
+ uploadOptions: FileUploadOptions;
17
+ };
18
+ export type OffchainFileMetadata = {
19
+ type: 'file';
20
+ dataCid: string;
21
+ name?: string;
22
+ mimeType?: string;
23
+ totalSize: bigint;
24
+ totalChunks: number;
25
+ chunks: ChunkInfo[];
26
+ uploadOptions?: FileUploadOptions;
27
+ };
28
+ export interface ChunkInfo {
29
+ size: bigint;
30
+ cid: string;
31
+ }
32
+ export declare enum Scope {
33
+ Global = "global",
34
+ User = "user"
35
+ }
36
+ export interface Owner {
37
+ publicId: string;
38
+ role: OwnerRole;
39
+ }
40
+ export declare enum OwnerRole {
41
+ ADMIN = "admin",
42
+ VIEWER = "viewer"
43
+ }
44
+ export interface ObjectUploadStatus {
45
+ uploadedNodes: number | null;
46
+ totalNodes: number | null;
47
+ minimumBlockDepth: number | null;
48
+ maximumBlockDepth: number | null;
49
+ }
50
+ export type ObjectSummary = {
51
+ headCid: string;
52
+ name?: string;
53
+ size: number;
54
+ owners: Owner[];
55
+ uploadStatus: ObjectUploadStatus;
56
+ } & ({
57
+ type: 'file';
58
+ mimeType?: string;
59
+ } | {
60
+ type: 'folder';
61
+ children: (OffchainMetadata & {
62
+ type: 'folder';
63
+ })['children'];
64
+ });
65
+ export interface ObjectInformation {
66
+ cid: string;
67
+ metadata: OffchainMetadata;
68
+ uploadStatus: ObjectUploadStatus;
69
+ owners: Owner[];
70
+ }
71
+ export {};
72
+ //# sourceMappingURL=objects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/api/models/objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,sBAAsB,CAAA;AAC5E,UAAU,gBAAgB;IACxB,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,gBAAgB,EAAE,CAAA;IAC5B,aAAa,EAAE,iBAAiB,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,SAAS,EAAE,CAAA;IACnB,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAClC,CAAA;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,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"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OwnerRole = exports.Scope = void 0;
4
+ var Scope;
5
+ (function (Scope) {
6
+ Scope["Global"] = "global";
7
+ Scope["User"] = "user";
8
+ })(Scope || (exports.Scope = Scope = {}));
9
+ var OwnerRole;
10
+ (function (OwnerRole) {
11
+ OwnerRole["ADMIN"] = "admin";
12
+ OwnerRole["VIEWER"] = "viewer";
13
+ })(OwnerRole || (exports.OwnerRole = OwnerRole = {}));
@@ -0,0 +1,148 @@
1
+ import { z } from 'zod';
2
+ export declare enum UploadType {
3
+ FILE = "file",
4
+ FOLDER = "folder"
5
+ }
6
+ export declare enum UploadStatus {
7
+ PENDING = "pending",
8
+ COMPLETED = "completed",
9
+ MIGRATING = "migrating",
10
+ CANCELLED = "cancelled",
11
+ FAILED = "failed"
12
+ }
13
+ export declare const fileUploadSchema: z.ZodObject<{
14
+ id: z.ZodString;
15
+ rootId: z.ZodString;
16
+ relativeId: z.ZodNullable<z.ZodString>;
17
+ type: z.ZodNativeEnum<typeof UploadType>;
18
+ status: z.ZodNativeEnum<typeof UploadStatus>;
19
+ fileTree: z.ZodNull;
20
+ name: z.ZodString;
21
+ mimeType: z.ZodNullable<z.ZodString>;
22
+ oauthProvider: z.ZodString;
23
+ oauthUserId: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ name: string;
26
+ type: UploadType;
27
+ status: UploadStatus;
28
+ id: string;
29
+ rootId: string;
30
+ relativeId: string | null;
31
+ fileTree: null;
32
+ mimeType: string | null;
33
+ oauthProvider: string;
34
+ oauthUserId: string;
35
+ }, {
36
+ name: string;
37
+ type: UploadType;
38
+ status: UploadStatus;
39
+ id: string;
40
+ rootId: string;
41
+ relativeId: string | null;
42
+ fileTree: null;
43
+ mimeType: string | null;
44
+ oauthProvider: string;
45
+ oauthUserId: string;
46
+ }>;
47
+ export declare enum CompressionAlgorithm {
48
+ ZLIB = "ZLIB"
49
+ }
50
+ export interface CompressionOptions {
51
+ algorithm: CompressionAlgorithm;
52
+ level?: number;
53
+ chunkSize?: number;
54
+ }
55
+ export type FileUploadOptions = {
56
+ compression?: CompressionOptions;
57
+ encryption?: EncryptionOptions;
58
+ };
59
+ export declare enum EncryptionAlgorithm {
60
+ AES_256_GCM = "AES_256_GCM"
61
+ }
62
+ export interface EncryptionOptions {
63
+ algorithm: EncryptionAlgorithm;
64
+ chunkSize?: number;
65
+ }
66
+ export type FileUpload = z.infer<typeof fileUploadSchema> & {
67
+ uploadOptions: FileUploadOptions | null;
68
+ };
69
+ export declare const folderUploadSchema: z.ZodObject<{
70
+ id: z.ZodString;
71
+ rootId: z.ZodString;
72
+ relativeId: z.ZodNullable<z.ZodString>;
73
+ type: z.ZodNativeEnum<typeof UploadType>;
74
+ status: z.ZodNativeEnum<typeof UploadStatus>;
75
+ fileTree: z.ZodObject<{
76
+ name: z.ZodString;
77
+ type: z.ZodLiteral<"folder">;
78
+ children: z.ZodArray<z.ZodLazy<z.ZodType<import("./folderTree").FolderTree, z.ZodTypeDef, import("./folderTree").FolderTree>>, "many">;
79
+ id: z.ZodString;
80
+ }, "strip", z.ZodTypeAny, {
81
+ name: string;
82
+ type: "folder";
83
+ children: import("./folderTree").FolderTree[];
84
+ id: string;
85
+ }, {
86
+ name: string;
87
+ type: "folder";
88
+ children: import("./folderTree").FolderTree[];
89
+ id: string;
90
+ }>;
91
+ name: z.ZodString;
92
+ mimeType: z.ZodNull;
93
+ oauthProvider: z.ZodString;
94
+ oauthUserId: z.ZodString;
95
+ uploadOptions: z.ZodNull;
96
+ }, "strip", z.ZodTypeAny, {
97
+ name: string;
98
+ type: UploadType;
99
+ status: UploadStatus;
100
+ id: string;
101
+ rootId: string;
102
+ relativeId: string | null;
103
+ fileTree: {
104
+ name: string;
105
+ type: "folder";
106
+ children: import("./folderTree").FolderTree[];
107
+ id: string;
108
+ };
109
+ mimeType: null;
110
+ oauthProvider: string;
111
+ oauthUserId: string;
112
+ uploadOptions: null;
113
+ }, {
114
+ name: string;
115
+ type: UploadType;
116
+ status: UploadStatus;
117
+ id: string;
118
+ rootId: string;
119
+ relativeId: string | null;
120
+ fileTree: {
121
+ name: string;
122
+ type: "folder";
123
+ children: import("./folderTree").FolderTree[];
124
+ id: string;
125
+ };
126
+ mimeType: null;
127
+ oauthProvider: string;
128
+ oauthUserId: string;
129
+ uploadOptions: null;
130
+ }>;
131
+ export type FolderUpload = z.infer<typeof folderUploadSchema>;
132
+ export type CompleteUploadResponse = {
133
+ cid: string;
134
+ };
135
+ export type UploadFileStatus = {
136
+ type: 'file';
137
+ progress: number;
138
+ cid?: string;
139
+ };
140
+ export type UploadFolderStatus = {
141
+ type: 'folder';
142
+ progress: number;
143
+ cid?: string;
144
+ };
145
+ export type UploadChunksStatus = {
146
+ uploadBytes: number;
147
+ };
148
+ //# sourceMappingURL=uploads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../../src/api/models/uploads.ts"],"names":[],"mappings":"AAAA,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,oBAAY,oBAAoB;IAC9B,IAAI,SAAS;CACd;AACD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,oBAAoB,CAAA;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,UAAU,CAAC,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED,oBAAY,mBAAmB;IAC7B,WAAW,gBAAgB;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,mBAAmB,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,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;AAE7D,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.folderUploadSchema = exports.EncryptionAlgorithm = exports.CompressionAlgorithm = exports.fileUploadSchema = exports.UploadStatus = exports.UploadType = void 0;
4
+ const zod_1 = require("zod");
5
+ const folderTree_1 = require("./folderTree");
6
+ var UploadType;
7
+ (function (UploadType) {
8
+ UploadType["FILE"] = "file";
9
+ UploadType["FOLDER"] = "folder";
10
+ })(UploadType || (exports.UploadType = UploadType = {}));
11
+ var UploadStatus;
12
+ (function (UploadStatus) {
13
+ UploadStatus["PENDING"] = "pending";
14
+ UploadStatus["COMPLETED"] = "completed";
15
+ UploadStatus["MIGRATING"] = "migrating";
16
+ UploadStatus["CANCELLED"] = "cancelled";
17
+ UploadStatus["FAILED"] = "failed";
18
+ })(UploadStatus || (exports.UploadStatus = UploadStatus = {}));
19
+ exports.fileUploadSchema = zod_1.z.object({
20
+ id: zod_1.z.string(),
21
+ rootId: zod_1.z.string(),
22
+ relativeId: zod_1.z.string().nullable(),
23
+ type: zod_1.z.nativeEnum(UploadType),
24
+ status: zod_1.z.nativeEnum(UploadStatus),
25
+ fileTree: zod_1.z.null(),
26
+ name: zod_1.z.string(),
27
+ mimeType: zod_1.z.string().nullable(),
28
+ oauthProvider: zod_1.z.string(),
29
+ oauthUserId: zod_1.z.string(),
30
+ });
31
+ var CompressionAlgorithm;
32
+ (function (CompressionAlgorithm) {
33
+ CompressionAlgorithm["ZLIB"] = "ZLIB";
34
+ })(CompressionAlgorithm || (exports.CompressionAlgorithm = CompressionAlgorithm = {}));
35
+ var EncryptionAlgorithm;
36
+ (function (EncryptionAlgorithm) {
37
+ EncryptionAlgorithm["AES_256_GCM"] = "AES_256_GCM";
38
+ })(EncryptionAlgorithm || (exports.EncryptionAlgorithm = EncryptionAlgorithm = {}));
39
+ exports.folderUploadSchema = zod_1.z.object({
40
+ id: zod_1.z.string(),
41
+ rootId: zod_1.z.string(),
42
+ relativeId: zod_1.z.string().nullable(),
43
+ type: zod_1.z.nativeEnum(UploadType),
44
+ status: zod_1.z.nativeEnum(UploadStatus),
45
+ fileTree: folderTree_1.FolderTreeFolderSchema,
46
+ name: zod_1.z.string(),
47
+ mimeType: zod_1.z.null(),
48
+ oauthProvider: zod_1.z.string(),
49
+ oauthUserId: zod_1.z.string(),
50
+ uploadOptions: zod_1.z.null(),
51
+ });
@@ -0,0 +1,84 @@
1
+ import { AutoDriveApi } from './connection';
2
+ import { GenericFile, GenericFileWithinFolder } from './models/file';
3
+ export type UploadFileOptions = {
4
+ password?: string;
5
+ compression?: boolean;
6
+ onProgress?: (progress: number) => void;
7
+ };
8
+ /**
9
+ * Uploads a file to the server with optional encryption and compression.
10
+ *
11
+ * This function reads a file from the provided input, optionally encrypts it
12
+ * using the specified password, and compresses it using the specified algorithm if requested.
13
+ * It uploads the file in chunks to the server, creating an upload session and
14
+ * completing it once all chunks have been successfully uploaded.
15
+ *
16
+ * @param {AutoDriveApi} api - The API instance used to send requests.
17
+ * @param {File} file - The file to be uploaded.
18
+ * @param {UploadFileOptions} options - Options for the upload process.
19
+ * @param {string} [options.password] - The password for encryption (optional).
20
+ * @param {boolean} [options.compression=true] - Whether to compress the file (optional).
21
+ * @param {number} [uploadChunkSize] - The size of each chunk to upload (optional).
22
+ * @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
23
+ * @throws {Error} - Throws an error if the upload fails at any stage.
24
+ */
25
+ export declare const uploadFileFromInput: (api: AutoDriveApi, file: File, options?: UploadFileOptions, uploadChunkSize?: number) => Promise<string>;
26
+ /**
27
+ * Uploads a file to the server with optional encryption and compression.
28
+ *
29
+ * This function reads a file from the provided input, optionally encrypts it
30
+ * using the specified password, and compresses it using the specified algorithm if requested.
31
+ * It uploads the file in chunks to the server, creating an upload session and
32
+ * completing it once all chunks have been successfully uploaded.
33
+ *
34
+ * @param {AutoDriveApi} api - The API instance used to send requests.
35
+ * @param {File | GenericFile} file - The file to be uploaded, which can be a File or a GenericFile.
36
+ * @param {UploadFileOptions} options - Options for the upload process.
37
+ * @param {string} [options.password] - The password for encryption (optional).
38
+ * @param {boolean} [options.compression=true] - Whether to compress the file (optional).
39
+ * @param {number} [uploadChunkSize] - The size of each chunk to upload (optional).
40
+ * @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
41
+ * @throws {Error} - Throws an error if the upload fails at any stage.
42
+ */
43
+ export declare const uploadFile: (api: AutoDriveApi, file: GenericFile, options?: UploadFileOptions, uploadChunkSize?: number) => Promise<string>;
44
+ /**
45
+ * Uploads an entire folder to the server.
46
+ *
47
+ * This function retrieves all files within the specified folder,
48
+ * constructs a file tree representation, and initiates the upload
49
+ * process. It also handles optional compression of the files during
50
+ * the upload. If a password is provided, the files will be zipped
51
+ * before uploading.
52
+ *
53
+ * @param {AutoDriveApi} api - The API instance used to send requests.
54
+ * @param {FileList | File[]} fileList - The list of files to be uploaded.
55
+ * @param {Object} options - Options for the upload process.
56
+ * @param {number} [options.uploadChunkSize] - The size of each chunk to upload (optional).
57
+ * @param {string} [options.password] - The password for encryption (optional).
58
+ * @returns {PromisedObservable<UploadFileStatus | UploadFolderStatus>} - An observable that emits the upload status.
59
+ * @throws {Error} - Throws an error if the upload fails at any stage.
60
+ */
61
+ export declare const uploadFolderFromInput: (api: AutoDriveApi, fileList: FileList | File[], { uploadChunkSize, password, onProgress, }?: {
62
+ uploadChunkSize?: number;
63
+ password?: string;
64
+ onProgress?: (progress: number) => void;
65
+ }) => Promise<string>;
66
+ /**
67
+ * Uploads a file within an existing folder upload session.
68
+ *
69
+ * @param {AutoDriveApi} api - The API instance to interact with the AutoDrive service.
70
+ * @param {string} uploadId - The ID of the folder upload session to which the file will be added.
71
+ * @param {string} filepath - The path of the file to be uploaded.
72
+ *
73
+ * @returns {Promise<void>} A promise that resolves when the file upload is complete.
74
+ */
75
+ export declare const uploadFileWithinFolderUpload: (api: AutoDriveApi, uploadId: string, file: GenericFileWithinFolder, uploadChunkSize?: number, options?: Pick<UploadFileOptions, "onProgress">) => Promise<string>;
76
+ /**
77
+ * Downloads a file from the AutoDrive service.
78
+ *
79
+ * @param {AutoDriveApi} api - The API instance to interact with the AutoDrive service.
80
+ * @param {string} cid - The CID of the file to be downloaded.
81
+ * @returns {Promise<ReadableStream<Uint8Array>>} A promise that resolves to a ReadableStream of the downloaded file.
82
+ */
83
+ export declare const downloadFile: (api: AutoDriveApi, cid: string, password?: string) => Promise<AsyncIterable<Buffer>>;
84
+ //# sourceMappingURL=wrappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/api/wrappers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAGpE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC,CAAA;AA6BD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,QACzB,YAAY,QACX,IAAI,YACD,iBAAiB,oBACR,MAAM,KACvB,OAAO,CAAC,MAAM,CAgDhB,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,QAChB,YAAY,QACX,WAAW,YACR,iBAAiB,oBACR,MAAM,KACvB,OAAO,CAAC,MAAM,CA+ChB,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,QAC3B,YAAY,YACP,QAAQ,GAAG,IAAI,EAAE,+CAKxB;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,KAC1F,OAAO,CAAC,MAAM,CA2DhB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,QAClC,YAAY,YACP,MAAM,QACV,uBAAuB,oBACX,MAAM,YACf,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,KAC7C,OAAO,CAAC,MAAM,CAchB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,QAClB,YAAY,OACZ,MAAM,aACA,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAwB/B,CAAA"}