@autonomys/auto-drive 1.1.2 → 1.1.4

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.
@@ -1,5 +1,57 @@
1
- export * from './download';
2
- export * from './read';
3
- export * from './upload';
4
- export * from './write';
1
+ export declare const apiCalls: {
2
+ shareObject: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
3
+ cid: string;
4
+ publicId: string;
5
+ }>) => Promise<any>;
6
+ markObjectAsDeleted: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
7
+ cid: string;
8
+ }>) => Promise<void>;
9
+ restoreObject: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
10
+ cid: string;
11
+ }>) => Promise<void>;
12
+ createFileUpload: (api: import("..").AutoDriveApi, { mimeType, filename, uploadOptions, }: import("../../utils").ArgsWithoutPagination<{
13
+ mimeType?: string;
14
+ filename: string;
15
+ uploadOptions: import("..").FileUploadOptions | null;
16
+ }>) => Promise<import("..").FileUpload>;
17
+ createFolderUpload: (api: import("..").AutoDriveApi, { fileTree, uploadOptions, }: import("../../utils").ArgsWithoutPagination<{
18
+ fileTree: import("../models/folderTree").FolderTree;
19
+ uploadOptions?: import("..").FileUploadOptions;
20
+ }>) => Promise<import("..").FolderUpload>;
21
+ createFileUploadWithinFolderUpload: (api: import("..").AutoDriveApi, { uploadId, name, mimeType, relativeId, uploadOptions, }: import("../../utils").ArgsWithoutPagination<{
22
+ uploadId: string;
23
+ name: string;
24
+ mimeType?: string;
25
+ relativeId: string;
26
+ uploadOptions: import("..").FileUploadOptions;
27
+ }>) => Promise<import("..").FileUpload>;
28
+ uploadFileChunk: (api: import("..").AutoDriveApi, { uploadId, chunk, index, }: import("../../utils").ArgsWithoutPagination<{
29
+ uploadId: string;
30
+ chunk: Buffer;
31
+ index: number;
32
+ }>) => Promise<void>;
33
+ completeUpload: (api: import("..").AutoDriveApi, { uploadId }: import("../../utils").ArgsWithoutPagination<{
34
+ uploadId: string;
35
+ }>) => Promise<import("..").CompleteUploadResponse>;
36
+ getRoots: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithPagination<{
37
+ scope: import("..").Scope;
38
+ }>) => Promise<import("../models/common").PaginatedResult<import("..").ObjectSummary>>;
39
+ getSharedWithMe: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithPagination) => Promise<import("../models/common").PaginatedResult<import("..").ObjectSummary>>;
40
+ getDeleted: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithPagination) => Promise<import("../models/common").PaginatedResult<import("..").ObjectSummary>>;
41
+ getObject: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
42
+ cid: string;
43
+ }>) => Promise<import("..").ObjectInformation>;
44
+ getObjectUploadStatus: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
45
+ cid: string;
46
+ }>) => Promise<import("..").ObjectInformation["uploadStatus"]>;
47
+ getObjectOwners: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
48
+ cid: string;
49
+ }>) => Promise<import("..").ObjectInformation["owners"]>;
50
+ getObjectMetadata: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
51
+ cid: string;
52
+ }>) => Promise<import("..").ObjectInformation["metadata"]>;
53
+ downloadObject: (api: import("..").AutoDriveApi, query: import("../../utils").ArgsWithoutPagination<{
54
+ cid: string;
55
+ }>) => Promise<ReadableStream<Uint8Array>>;
56
+ };
5
57
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/calls/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/calls/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ;;;;;;;;;;;;gBAMg0B,CAAC;;;;;;qBAAgvC,CAAC;;;;;gBAAkiD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CADzmH,CAAA"}
@@ -10,11 +10,32 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
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
- };
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
16
35
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./download"), exports);
18
- __exportStar(require("./read"), exports);
19
- __exportStar(require("./upload"), exports);
20
- __exportStar(require("./write"), exports);
36
+ exports.apiCalls = void 0;
37
+ const downloadCalls = __importStar(require("./download"));
38
+ const readCalls = __importStar(require("./read"));
39
+ const uploadCalls = __importStar(require("./upload"));
40
+ const writeCalls = __importStar(require("./write"));
41
+ exports.apiCalls = Object.assign(Object.assign(Object.assign(Object.assign({}, downloadCalls), readCalls), uploadCalls), writeCalls);
@@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Y,OACZ,MAAM,aACA,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAwB/B,CAAA"}
@@ -1,4 +1,37 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -37,7 +70,7 @@ const uploadFileChunks = (api, fileUploadId, asyncIterable, uploadChunkSize = UP
37
70
  _c = _f.value;
38
71
  _d = false;
39
72
  const chunk = _c;
40
- yield (0, index_1.uploadFileChunk)(api, { uploadId: fileUploadId, chunk, index });
73
+ yield index_1.apiCalls.uploadFileChunk(api, { uploadId: fileUploadId, chunk, index });
41
74
  uploadBytes += chunk.length;
42
75
  subscriber.next({ uploadBytes });
43
76
  index++;
@@ -73,7 +106,7 @@ const uploadFileChunks = (api, fileUploadId, asyncIterable, uploadChunkSize = UP
73
106
  const uploadFileFromInput = (api, file, options = {}, uploadChunkSize) => {
74
107
  const { password = undefined, compression = true } = options;
75
108
  return new observable_1.PromisedObservable((subscriber) => __awaiter(void 0, void 0, void 0, function* () {
76
- const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } = yield import('@autonomys/auto-dag-data');
109
+ const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } = yield Promise.resolve().then(() => __importStar(require('@autonomys/auto-dag-data')));
77
110
  let asyncIterable = (0, async_1.fileToIterable)(file);
78
111
  if (compression) {
79
112
  asyncIterable = compressFile(asyncIterable, {
@@ -99,13 +132,13 @@ const uploadFileFromInput = (api, file, options = {}, uploadChunkSize) => {
99
132
  }
100
133
  : undefined,
101
134
  };
102
- const fileUpload = yield (0, index_1.createFileUpload)(api, {
135
+ const fileUpload = yield index_1.apiCalls.createFileUpload(api, {
103
136
  mimeType: mime_types_1.default.lookup(file.name) || undefined,
104
137
  filename: file.name,
105
138
  uploadOptions,
106
139
  });
107
140
  yield uploadFileChunks(api, fileUpload.id, asyncIterable, uploadChunkSize).forEach((e) => subscriber.next({ type: 'file', progress: (0, misc_1.progressToPercentage)(e.uploadBytes, file.size) }));
108
- const result = yield (0, index_1.completeUpload)(api, { uploadId: fileUpload.id });
141
+ const result = yield index_1.apiCalls.completeUpload(api, { uploadId: fileUpload.id });
109
142
  subscriber.next({ type: 'file', progress: 100, cid: result.cid });
110
143
  subscriber.complete();
111
144
  }));
@@ -131,7 +164,7 @@ exports.uploadFileFromInput = uploadFileFromInput;
131
164
  const uploadFile = (api, file, options = {}, uploadChunkSize) => {
132
165
  const { password = undefined, compression = true } = options;
133
166
  return new observable_1.PromisedObservable((subscriber) => __awaiter(void 0, void 0, void 0, function* () {
134
- const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } = yield import('@autonomys/auto-dag-data');
167
+ const { stringToCid, compressFile, CompressionAlgorithm, encryptFile, EncryptionAlgorithm } = yield Promise.resolve().then(() => __importStar(require('@autonomys/auto-dag-data')));
135
168
  let asyncIterable = file.read();
136
169
  if (compression) {
137
170
  asyncIterable = compressFile(asyncIterable, {
@@ -157,13 +190,13 @@ const uploadFile = (api, file, options = {}, uploadChunkSize) => {
157
190
  }
158
191
  : undefined,
159
192
  };
160
- const fileUpload = yield (0, index_1.createFileUpload)(api, {
193
+ const fileUpload = yield index_1.apiCalls.createFileUpload(api, {
161
194
  mimeType: mime_types_1.default.lookup(file.name) || undefined,
162
195
  filename: file.name,
163
196
  uploadOptions,
164
197
  });
165
198
  yield uploadFileChunks(api, fileUpload.id, asyncIterable, uploadChunkSize).forEach((e) => subscriber.next({ type: 'file', progress: (0, misc_1.progressToPercentage)(e.uploadBytes, file.size) }));
166
- const result = yield (0, index_1.completeUpload)(api, { uploadId: fileUpload.id });
199
+ const result = yield index_1.apiCalls.completeUpload(api, { uploadId: fileUpload.id });
167
200
  subscriber.next({ type: 'file', progress: 100, cid: result.cid });
168
201
  subscriber.complete();
169
202
  }));
@@ -206,7 +239,7 @@ const uploadFolderFromInput = (api_1, fileList_1, ...args_1) => __awaiter(void 0
206
239
  }
207
240
  return new observable_1.PromisedObservable((subscriber) => __awaiter(void 0, void 0, void 0, function* () {
208
241
  // Otherwise, we upload the files as a folder w/o compression or encryption
209
- const folderUpload = yield (0, index_1.createFolderUpload)(api, {
242
+ const folderUpload = yield index_1.apiCalls.createFolderUpload(api, {
210
243
  fileTree,
211
244
  });
212
245
  let currentBytesUploaded = 0;
@@ -226,7 +259,7 @@ const uploadFolderFromInput = (api_1, fileList_1, ...args_1) => __awaiter(void 0
226
259
  });
227
260
  currentBytesUploaded += file.size;
228
261
  }
229
- const result = yield (0, index_1.completeUpload)(api, { uploadId: folderUpload.id });
262
+ const result = yield index_1.apiCalls.completeUpload(api, { uploadId: folderUpload.id });
230
263
  subscriber.next({ type: 'folder', progress: 100, cid: result.cid });
231
264
  subscriber.complete();
232
265
  }));
@@ -243,7 +276,7 @@ exports.uploadFolderFromInput = uploadFolderFromInput;
243
276
  */
244
277
  const uploadFileWithinFolderUpload = (api, uploadId, file, uploadChunkSize) => {
245
278
  return new observable_1.PromisedObservable((subscriber) => __awaiter(void 0, void 0, void 0, function* () {
246
- const fileUpload = yield (0, index_1.createFileUploadWithinFolderUpload)(api, {
279
+ const fileUpload = yield index_1.apiCalls.createFileUploadWithinFolderUpload(api, {
247
280
  uploadId,
248
281
  name: file.name,
249
282
  mimeType: file.mimeType,
@@ -251,7 +284,7 @@ const uploadFileWithinFolderUpload = (api, uploadId, file, uploadChunkSize) => {
251
284
  uploadOptions: {},
252
285
  });
253
286
  yield uploadFileChunks(api, fileUpload.id, file.read(), uploadChunkSize).forEach((e) => subscriber.next({ uploadBytes: e.uploadBytes }));
254
- yield (0, index_1.completeUpload)(api, { uploadId: fileUpload.id });
287
+ yield index_1.apiCalls.completeUpload(api, { uploadId: fileUpload.id });
255
288
  subscriber.complete();
256
289
  }));
257
290
  };
@@ -265,9 +298,9 @@ exports.uploadFileWithinFolderUpload = uploadFileWithinFolderUpload;
265
298
  */
266
299
  const downloadFile = (api, cid, password) => __awaiter(void 0, void 0, void 0, function* () {
267
300
  var _a, _b;
268
- const { decompressFile, CompressionAlgorithm, EncryptionAlgorithm, decryptFile } = yield import('@autonomys/auto-dag-data');
269
- const metadata = yield (0, index_1.getObjectMetadata)(api, { cid });
270
- let iterable = (0, async_1.asyncFromStream)(yield (0, index_1.downloadObject)(api, { cid }));
301
+ const { decompressFile, CompressionAlgorithm, EncryptionAlgorithm, decryptFile } = yield Promise.resolve().then(() => __importStar(require('@autonomys/auto-dag-data')));
302
+ const metadata = yield index_1.apiCalls.getObjectMetadata(api, { cid });
303
+ let iterable = (0, async_1.asyncFromStream)(yield index_1.apiCalls.downloadObject(api, { cid }));
271
304
  if ((_a = metadata.uploadOptions) === null || _a === void 0 ? void 0 : _a.encryption) {
272
305
  if (!password) {
273
306
  throw new Error('Password is required to decrypt the file');
@@ -1,4 +1,37 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -89,8 +122,8 @@ const uploadFolderFromFolderPath = (api_1, folderPath_1, ...args_1) => __awaiter
89
122
  });
90
123
  }
91
124
  return new observable_js_1.PromisedObservable((subscriber) => __awaiter(void 0, void 0, void 0, function* () {
92
- const { CompressionAlgorithm } = yield import('@autonomys/auto-dag-data');
93
- const folderUpload = yield (0, index_js_1.createFolderUpload)(api, {
125
+ const { CompressionAlgorithm } = yield Promise.resolve().then(() => __importStar(require('@autonomys/auto-dag-data')));
126
+ const folderUpload = yield index_js_1.apiCalls.createFolderUpload(api, {
94
127
  fileTree,
95
128
  uploadOptions: {
96
129
  compression: {
@@ -115,7 +148,7 @@ const uploadFolderFromFolderPath = (api_1, folderPath_1, ...args_1) => __awaiter
115
148
  }));
116
149
  progress += file.size;
117
150
  }
118
- const result = yield (0, index_js_1.completeUpload)(api, { uploadId: folderUpload.id });
151
+ const result = yield index_js_1.apiCalls.completeUpload(api, { uploadId: folderUpload.id });
119
152
  subscriber.next({ type: 'folder', progress: 100, cid: result.cid });
120
153
  subscriber.complete();
121
154
  }));
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.2",
4
+ "version": "1.1.4",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -20,6 +20,8 @@
20
20
  "scripts": {
21
21
  "build": "yarn tsc"
22
22
  },
23
+ "main": "./dist/node.js",
24
+ "types": "./dist/node.d.ts",
23
25
  "exports": {
24
26
  ".": {
25
27
  "browser": "./dist/browser.js",
@@ -40,7 +42,7 @@
40
42
  "typescript": "^5.6.3"
41
43
  },
42
44
  "dependencies": {
43
- "@autonomys/auto-dag-data": "^1.1.2",
45
+ "@autonomys/auto-dag-data": "^1.1.4",
44
46
  "jszip": "^3.10.1",
45
47
  "mime-types": "^2.1.35",
46
48
  "process": "^0.11.10",
@@ -48,5 +50,5 @@
48
50
  "stream": "^0.0.3",
49
51
  "zod": "^3.23.8"
50
52
  },
51
- "gitHead": "e84f9598911e27aec4de31fbd6a7663f8e364a20"
53
+ "gitHead": "8e804316b27de8568cf5a71d3ec2500f6e262d3c"
52
54
  }
@@ -1,4 +1,11 @@
1
- export * from './download'
2
- export * from './read'
3
- export * from './upload'
4
- export * from './write'
1
+ import * as downloadCalls from './download'
2
+ import * as readCalls from './read'
3
+ import * as uploadCalls from './upload'
4
+ import * as writeCalls from './write'
5
+
6
+ export const apiCalls = {
7
+ ...downloadCalls,
8
+ ...readCalls,
9
+ ...uploadCalls,
10
+ ...writeCalls,
11
+ }
@@ -1,18 +1,8 @@
1
- import fs from 'fs'
2
1
  import mime from 'mime-types'
3
2
  import { asyncByChunk, asyncFromStream, fileToIterable } from '../utils/async'
4
3
  import { progressToPercentage } from '../utils/misc'
5
4
  import { PromisedObservable } from '../utils/observable'
6
-
7
- import {
8
- completeUpload,
9
- createFileUpload,
10
- createFileUploadWithinFolderUpload,
11
- createFolderUpload,
12
- downloadObject,
13
- getObjectMetadata,
14
- uploadFileChunk,
15
- } from './calls/index'
5
+ import { apiCalls } from './calls/index'
16
6
  import { AutoDriveApi } from './connection'
17
7
  import { GenericFile, GenericFileWithinFolder } from './models/file'
18
8
  import { constructFromInput, constructZipBlobFromTreeAndPaths } from './models/folderTree'
@@ -35,7 +25,7 @@ const uploadFileChunks = (
35
25
  let index = 0
36
26
  let uploadBytes = 0
37
27
  for await (const chunk of asyncByChunk(asyncIterable, uploadChunkSize)) {
38
- await uploadFileChunk(api, { uploadId: fileUploadId, chunk, index })
28
+ await apiCalls.uploadFileChunk(api, { uploadId: fileUploadId, chunk, index })
39
29
  uploadBytes += chunk.length
40
30
  subscriber.next({ uploadBytes })
41
31
  index++
@@ -99,7 +89,7 @@ export const uploadFileFromInput = (
99
89
  }
100
90
  : undefined,
101
91
  }
102
- const fileUpload = await createFileUpload(api, {
92
+ const fileUpload = await apiCalls.createFileUpload(api, {
103
93
  mimeType: mime.lookup(file.name) || undefined,
104
94
  filename: file.name,
105
95
  uploadOptions,
@@ -109,7 +99,7 @@ export const uploadFileFromInput = (
109
99
  subscriber.next({ type: 'file', progress: progressToPercentage(e.uploadBytes, file.size) }),
110
100
  )
111
101
 
112
- const result = await completeUpload(api, { uploadId: fileUpload.id })
102
+ const result = await apiCalls.completeUpload(api, { uploadId: fileUpload.id })
113
103
 
114
104
  subscriber.next({ type: 'file', progress: 100, cid: result.cid })
115
105
  subscriber.complete()
@@ -172,7 +162,7 @@ export const uploadFile = (
172
162
  }
173
163
  : undefined,
174
164
  }
175
- const fileUpload = await createFileUpload(api, {
165
+ const fileUpload = await apiCalls.createFileUpload(api, {
176
166
  mimeType: mime.lookup(file.name) || undefined,
177
167
  filename: file.name,
178
168
  uploadOptions,
@@ -182,7 +172,7 @@ export const uploadFile = (
182
172
  subscriber.next({ type: 'file', progress: progressToPercentage(e.uploadBytes, file.size) }),
183
173
  )
184
174
 
185
- const result = await completeUpload(api, { uploadId: fileUpload.id })
175
+ const result = await apiCalls.completeUpload(api, { uploadId: fileUpload.id })
186
176
 
187
177
  subscriber.next({ type: 'file', progress: 100, cid: result.cid })
188
178
  subscriber.complete()
@@ -239,7 +229,7 @@ export const uploadFolderFromInput = async (
239
229
 
240
230
  return new PromisedObservable<UploadFolderStatus>(async (subscriber) => {
241
231
  // Otherwise, we upload the files as a folder w/o compression or encryption
242
- const folderUpload = await createFolderUpload(api, {
232
+ const folderUpload = await apiCalls.createFolderUpload(api, {
243
233
  fileTree,
244
234
  })
245
235
 
@@ -267,7 +257,7 @@ export const uploadFolderFromInput = async (
267
257
  currentBytesUploaded += file.size
268
258
  }
269
259
 
270
- const result = await completeUpload(api, { uploadId: folderUpload.id })
260
+ const result = await apiCalls.completeUpload(api, { uploadId: folderUpload.id })
271
261
 
272
262
  subscriber.next({ type: 'folder', progress: 100, cid: result.cid })
273
263
  subscriber.complete()
@@ -290,7 +280,7 @@ export const uploadFileWithinFolderUpload = (
290
280
  uploadChunkSize?: number,
291
281
  ): PromisedObservable<UploadChunksStatus> => {
292
282
  return new PromisedObservable<UploadChunksStatus>(async (subscriber) => {
293
- const fileUpload = await createFileUploadWithinFolderUpload(api, {
283
+ const fileUpload = await apiCalls.createFileUploadWithinFolderUpload(api, {
294
284
  uploadId,
295
285
  name: file.name,
296
286
  mimeType: file.mimeType,
@@ -302,7 +292,7 @@ export const uploadFileWithinFolderUpload = (
302
292
  subscriber.next({ uploadBytes: e.uploadBytes }),
303
293
  )
304
294
 
305
- await completeUpload(api, { uploadId: fileUpload.id })
295
+ await apiCalls.completeUpload(api, { uploadId: fileUpload.id })
306
296
 
307
297
  subscriber.complete()
308
298
  })
@@ -324,9 +314,9 @@ export const downloadFile = async (
324
314
  '@autonomys/auto-dag-data'
325
315
  )
326
316
 
327
- const metadata = await getObjectMetadata(api, { cid })
317
+ const metadata = await apiCalls.getObjectMetadata(api, { cid })
328
318
 
329
- let iterable = asyncFromStream(await downloadObject(api, { cid }))
319
+ let iterable = asyncFromStream(await apiCalls.downloadObject(api, { cid }))
330
320
  if (metadata.uploadOptions?.encryption) {
331
321
  if (!password) {
332
322
  throw new Error('Password is required to decrypt the file')
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs'
2
2
  import mime from 'mime-types'
3
3
  import { AutoDriveApi } from '../api/connection.js'
4
- import { completeUpload, createFolderUpload } from '../api/index.js'
4
+ import { apiCalls } from '../api/index.js'
5
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'
@@ -100,7 +100,7 @@ export const uploadFolderFromFolderPath = async (
100
100
 
101
101
  return new PromisedObservable<UploadFolderStatus>(async (subscriber) => {
102
102
  const { CompressionAlgorithm } = await import('@autonomys/auto-dag-data')
103
- const folderUpload = await createFolderUpload(api, {
103
+ const folderUpload = await apiCalls.createFolderUpload(api, {
104
104
  fileTree,
105
105
  uploadOptions: {
106
106
  compression: {
@@ -131,7 +131,7 @@ export const uploadFolderFromFolderPath = async (
131
131
  progress += file.size
132
132
  }
133
133
 
134
- const result = await completeUpload(api, { uploadId: folderUpload.id })
134
+ const result = await apiCalls.completeUpload(api, { uploadId: folderUpload.id })
135
135
 
136
136
  subscriber.next({ type: 'folder', progress: 100, cid: result.cid })
137
137
  subscriber.complete()
package/tsconfig.json CHANGED
@@ -2,14 +2,7 @@
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "./dist",
5
- "rootDir": "./src/",
6
- "moduleResolution": "node16",
7
- "module": "Node16",
8
- "target": "es6",
9
- "forceConsistentCasingInFileNames": true,
10
- "skipLibCheck": true,
11
- "stripInternal": true,
12
- "resolveJsonModule": true
5
+ "rootDir": "./src"
13
6
  },
14
7
  "include": ["src"]
15
8
  }