@autonomys/auto-drive 1.1.2 → 1.1.3

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 (79) hide show
  1. package/package.json +5 -3
  2. package/src/api/calls/index.ts +11 -4
  3. package/src/api/wrappers.ts +12 -22
  4. package/src/fs/wrappers.ts +3 -3
  5. package/tsconfig.json +1 -8
  6. package/.env +0 -6
  7. package/LICENSE +0 -18
  8. package/dist/api/calls/download.d.ts +0 -6
  9. package/dist/api/calls/download.d.ts.map +0 -1
  10. package/dist/api/calls/download.js +0 -25
  11. package/dist/api/calls/index.d.ts +0 -5
  12. package/dist/api/calls/index.d.ts.map +0 -1
  13. package/dist/api/calls/index.js +0 -20
  14. package/dist/api/calls/read.d.ts +0 -99
  15. package/dist/api/calls/read.d.ts.map +0 -1
  16. package/dist/api/calls/read.js +0 -159
  17. package/dist/api/calls/upload.d.ts +0 -93
  18. package/dist/api/calls/upload.d.ts.map +0 -1
  19. package/dist/api/calls/upload.js +0 -137
  20. package/dist/api/calls/write.d.ts +0 -49
  21. package/dist/api/calls/write.d.ts.map +0 -1
  22. package/dist/api/calls/write.js +0 -80
  23. package/dist/api/connection.d.ts +0 -15
  24. package/dist/api/connection.d.ts.map +0 -1
  25. package/dist/api/connection.js +0 -28
  26. package/dist/api/index.d.ts +0 -5
  27. package/dist/api/index.d.ts.map +0 -1
  28. package/dist/api/index.js +0 -20
  29. package/dist/api/models/common.d.ts +0 -5
  30. package/dist/api/models/common.d.ts.map +0 -1
  31. package/dist/api/models/common.js +0 -2
  32. package/dist/api/models/file.d.ts +0 -10
  33. package/dist/api/models/file.d.ts.map +0 -1
  34. package/dist/api/models/file.js +0 -2
  35. package/dist/api/models/folderTree.d.ts +0 -47
  36. package/dist/api/models/folderTree.d.ts.map +0 -1
  37. package/dist/api/models/folderTree.js +0 -105
  38. package/dist/api/models/index.d.ts +0 -3
  39. package/dist/api/models/index.d.ts.map +0 -1
  40. package/dist/api/models/index.js +0 -18
  41. package/dist/api/models/objects.d.ts +0 -72
  42. package/dist/api/models/objects.d.ts.map +0 -1
  43. package/dist/api/models/objects.js +0 -13
  44. package/dist/api/models/uploads.d.ts +0 -148
  45. package/dist/api/models/uploads.d.ts.map +0 -1
  46. package/dist/api/models/uploads.js +0 -51
  47. package/dist/api/wrappers.d.ts +0 -84
  48. package/dist/api/wrappers.d.ts.map +0 -1
  49. package/dist/api/wrappers.js +0 -286
  50. package/dist/browser.d.ts +0 -3
  51. package/dist/browser.d.ts.map +0 -1
  52. package/dist/browser.js +0 -18
  53. package/dist/fs/index.d.ts +0 -3
  54. package/dist/fs/index.d.ts.map +0 -1
  55. package/dist/fs/index.js +0 -18
  56. package/dist/fs/utils.d.ts +0 -6
  57. package/dist/fs/utils.d.ts.map +0 -1
  58. package/dist/fs/utils.js +0 -84
  59. package/dist/fs/wrappers.d.ts +0 -45
  60. package/dist/fs/wrappers.d.ts.map +0 -1
  61. package/dist/fs/wrappers.js +0 -123
  62. package/dist/node.d.ts +0 -3
  63. package/dist/node.d.ts.map +0 -1
  64. package/dist/node.js +0 -18
  65. package/dist/utils/async.d.ts +0 -5
  66. package/dist/utils/async.d.ts.map +0 -1
  67. package/dist/utils/async.js +0 -73
  68. package/dist/utils/index.d.ts +0 -5
  69. package/dist/utils/index.d.ts.map +0 -1
  70. package/dist/utils/index.js +0 -20
  71. package/dist/utils/misc.d.ts +0 -2
  72. package/dist/utils/misc.d.ts.map +0 -1
  73. package/dist/utils/misc.js +0 -5
  74. package/dist/utils/observable.d.ts +0 -7
  75. package/dist/utils/observable.d.ts.map +0 -1
  76. package/dist/utils/observable.js +0 -52
  77. package/dist/utils/types.d.ts +0 -6
  78. package/dist/utils/types.d.ts.map +0 -1
  79. package/dist/utils/types.js +0 -2
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.3",
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.3",
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": "5c34ad5b044d34e99a57f0fbf96f95e78e25c4f9"
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
  }
package/.env DELETED
@@ -1,6 +0,0 @@
1
- OBJECT_MAPPING_ARCHIVER_URL=ws://127.0.0.1:1234
2
- RPC_ENDPOINT=ws://127.0.0.1:1234
3
- PRIVATE_KEYS_PATH=//Alice
4
- CORS_ALLOW_ORIGINS=*
5
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
6
- MAX_CACHE_SIZE=1073741824
package/LICENSE DELETED
@@ -1,18 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Autonomys Network (autonomys.xyz)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- 1. **Attribution**: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
-
14
- 2. **No Warranty**: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15
-
16
- 3. **Limitation of Liability**: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
-
18
- ---
@@ -1,6 +0,0 @@
1
- import { ArgsWithoutPagination } from '../../utils/types';
2
- import { AutoDriveApi } from '../connection';
3
- export declare const downloadObject: (api: AutoDriveApi, query: ArgsWithoutPagination<{
4
- cid: string;
5
- }>) => Promise<ReadableStream<Uint8Array>>;
6
- //# sourceMappingURL=download.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/api/calls/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,eAAO,MAAM,cAAc,QACpB,YAAY,SACV,qBAAqB,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,KAC5C,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAcpC,CAAA"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.downloadObject = void 0;
13
- const downloadObject = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
14
- const response = yield api.sendRequest(`/objects/${query.cid}/download`, {
15
- method: 'GET',
16
- });
17
- if (!response.ok) {
18
- throw new Error(`Failed to download file: ${response.statusText}`);
19
- }
20
- if (!response.body) {
21
- throw new Error('No body returned from download request');
22
- }
23
- return response.body;
24
- });
25
- exports.downloadObject = downloadObject;
@@ -1,5 +0,0 @@
1
- export * from './download';
2
- export * from './read';
3
- export * from './upload';
4
- export * from './write';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,20 +0,0 @@
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("./download"), exports);
18
- __exportStar(require("./read"), exports);
19
- __exportStar(require("./upload"), exports);
20
- __exportStar(require("./write"), exports);
@@ -1,99 +0,0 @@
1
- import { ArgsWithoutPagination, ArgsWithPagination } from '../../utils/types';
2
- import { AutoDriveApi } from '../connection';
3
- import { PaginatedResult } from '../models/common';
4
- import { ObjectInformation, ObjectSummary, Scope } from '../models/objects';
5
- /**
6
- * Retrieves the root objects based on the specified scope.
7
- *
8
- * @param {AutoDriveApi} api - The API instance used to send requests.
9
- * @param {ArgsWithPagination<{ scope: Scope }>} query - The query parameters including scope, limit, and offset.
10
- * @returns {Promise<ObjectSummary[]>} - A promise that resolves to an array of ObjectSummary representing the root objects.
11
- * @throws {Error} - Throws an error if the request fails.
12
- */
13
- export declare const getRoots: (api: AutoDriveApi, query: ArgsWithPagination<{
14
- scope: Scope;
15
- }>) => Promise<PaginatedResult<ObjectSummary>>;
16
- /**
17
- * Retrieves the objects that have been shared with the authenticated user.
18
- *
19
- * This method sends a request to the server to fetch a list of objects
20
- * that are shared with the user, based on the specified pagination parameters.
21
- *
22
- * @param {AutoDriveApi} api - The API instance used to send requests.
23
- * @param {ArgsWithPagination} query - The query parameters including limit and offset for pagination.
24
- * @returns {Promise<ObjectSummary[]>} - A promise that resolves to an array of ObjectSummary representing the shared objects.
25
- * @throws {Error} - Throws an error if the request fails.
26
- */
27
- export declare const getSharedWithMe: (api: AutoDriveApi, query: ArgsWithPagination) => Promise<PaginatedResult<ObjectSummary>>;
28
- /**
29
- * Retrieves the objects that have been marked as deleted.
30
- *
31
- * This method sends a request to the server to fetch a list of objects
32
- * that have been deleted, based on the specified pagination parameters.
33
- *
34
- * @param {AutoDriveApi} api - The API instance used to send requests.
35
- * @param {ArgsWithPagination} query - The query parameters including limit and offset for pagination.
36
- * @returns {Promise<ObjectSummary[]>} - A promise that resolves to an array of ObjectSummary representing the deleted objects.
37
- * @throws {Error} - Throws an error if the request fails.
38
- */
39
- export declare const getDeleted: (api: AutoDriveApi, query: ArgsWithPagination) => Promise<PaginatedResult<ObjectSummary>>;
40
- /**
41
- * Retrieves the aggregated information of a specific object identified by its CID.
42
- *
43
- * This method sends a request to the server to fetch details about the
44
- * object, including its metadata and other relevant information.
45
- *
46
- * @param {AutoDriveApi} api - The API instance used to send requests.
47
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object to retrieve.
48
- * @returns {Promise<ObjectInformation>} - A promise that resolves to the information of the requested object.
49
- * @throws {Error} - Throws an error if the request fails.
50
- */
51
- export declare const getObject: (api: AutoDriveApi, query: ArgsWithoutPagination<{
52
- cid: string;
53
- }>) => Promise<ObjectInformation>;
54
- /**
55
- * Retrieves the upload status of a specific object identified by its CID.
56
- *
57
- * This method sends a request to the server to fetch the current upload status
58
- * of the object, which can indicate whether the upload is pending, completed,
59
- * or failed.
60
- *
61
- * @param {AutoDriveApi} api - The API instance used to send requests.
62
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object whose upload status is to be retrieved.
63
- * @returns {Promise<ObjectInformation['uploadStatus']>} - A promise that resolves to the upload status of the requested object.
64
- * @throws {Error} - Throws an error if the request fails.
65
- */
66
- export declare const getObjectUploadStatus: (api: AutoDriveApi, query: ArgsWithoutPagination<{
67
- cid: string;
68
- }>) => Promise<ObjectInformation["uploadStatus"]>;
69
- /**
70
- * Retrieves the owners of a specific object identified by its CID.
71
- *
72
- * This method sends a request to the server to fetch the list of owners
73
- * associated with the object. The owners can provide insights into who
74
- * has access to or control over the object.
75
- *
76
- * @param {AutoDriveApi} api - The API instance used to send requests.
77
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object whose owners are to be retrieved.
78
- * @returns {Promise<ObjectInformation['owners']>} - A promise that resolves to the list of owners of the requested object.
79
- * @throws {Error} - Throws an error if the request fails.
80
- */
81
- export declare const getObjectOwners: (api: AutoDriveApi, query: ArgsWithoutPagination<{
82
- cid: string;
83
- }>) => Promise<ObjectInformation["owners"]>;
84
- /**
85
- * Retrieves the metadata of a specific object identified by its CID.
86
- *
87
- * This method sends a request to the server to fetch the metadata associated
88
- * with the object. The metadata can include various details about the object,
89
- * such as its name, type, size, and other relevant information.
90
- *
91
- * @param {AutoDriveApi} api - The API instance used to send requests.
92
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object whose metadata is to be retrieved.
93
- * @returns {Promise<ObjectInformation['metadata']>} - A promise that resolves to the metadata of the requested object.
94
- * @throws {Error} - Throws an error if the request fails.
95
- */
96
- export declare const getObjectMetadata: (api: AutoDriveApi, query: ArgsWithoutPagination<{
97
- cid: string;
98
- }>) => Promise<ObjectInformation["metadata"]>;
99
- //# sourceMappingURL=read.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/api/calls/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,QACd,YAAY,SACV,kBAAkB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,KAC1C,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAaxC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,QACrB,YAAY,SACV,kBAAkB,KACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAaxC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,QAChB,YAAY,SACV,kBAAkB,KACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAaxC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,QACf,YAAY,SACV,qBAAqB,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,KAC5C,OAAO,CAAC,iBAAiB,CAU3B,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,QAC3B,YAAY,SACV,qBAAqB,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,KAC5C,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAU3C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,QACrB,YAAY,SACV,qBAAqB,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,KAC5C,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAUrC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,QACvB,YAAY,SACV,qBAAqB,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,KAC5C,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAUvC,CAAA"}
@@ -1,159 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getObjectMetadata = exports.getObjectOwners = exports.getObjectUploadStatus = exports.getObject = exports.getDeleted = exports.getSharedWithMe = exports.getRoots = void 0;
13
- /**
14
- * Retrieves the root objects based on the specified scope.
15
- *
16
- * @param {AutoDriveApi} api - The API instance used to send requests.
17
- * @param {ArgsWithPagination<{ scope: Scope }>} query - The query parameters including scope, limit, and offset.
18
- * @returns {Promise<ObjectSummary[]>} - A promise that resolves to an array of ObjectSummary representing the root objects.
19
- * @throws {Error} - Throws an error if the request fails.
20
- */
21
- const getRoots = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
22
- const response = yield api.sendRequest(`/objects/roots?scope=${query.scope}&limit=${query.limit}&offset=${query.offset}`, {
23
- method: 'GET',
24
- });
25
- if (!response.ok) {
26
- throw new Error(`Failed to get roots: ${response.statusText}`);
27
- }
28
- return response.json();
29
- });
30
- exports.getRoots = getRoots;
31
- /**
32
- * Retrieves the objects that have been shared with the authenticated user.
33
- *
34
- * This method sends a request to the server to fetch a list of objects
35
- * that are shared with the user, based on the specified pagination parameters.
36
- *
37
- * @param {AutoDriveApi} api - The API instance used to send requests.
38
- * @param {ArgsWithPagination} query - The query parameters including limit and offset for pagination.
39
- * @returns {Promise<ObjectSummary[]>} - A promise that resolves to an array of ObjectSummary representing the shared objects.
40
- * @throws {Error} - Throws an error if the request fails.
41
- */
42
- const getSharedWithMe = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
43
- const response = yield api.sendRequest(`/objects/roots/shared?limit=${query.limit}&offset=${query.offset}`, {
44
- method: 'GET',
45
- });
46
- if (!response.ok) {
47
- throw new Error(`Failed to get shared with me: ${response.statusText}`);
48
- }
49
- return response.json();
50
- });
51
- exports.getSharedWithMe = getSharedWithMe;
52
- /**
53
- * Retrieves the objects that have been marked as deleted.
54
- *
55
- * This method sends a request to the server to fetch a list of objects
56
- * that have been deleted, based on the specified pagination parameters.
57
- *
58
- * @param {AutoDriveApi} api - The API instance used to send requests.
59
- * @param {ArgsWithPagination} query - The query parameters including limit and offset for pagination.
60
- * @returns {Promise<ObjectSummary[]>} - A promise that resolves to an array of ObjectSummary representing the deleted objects.
61
- * @throws {Error} - Throws an error if the request fails.
62
- */
63
- const getDeleted = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
64
- const response = yield api.sendRequest(`/objects/roots/deleted?limit=${query.limit}&offset=${query.offset}`, {
65
- method: 'GET',
66
- });
67
- if (!response.ok) {
68
- throw new Error(`Failed to get deleted: ${response.statusText}`);
69
- }
70
- return response.json();
71
- });
72
- exports.getDeleted = getDeleted;
73
- /**
74
- * Retrieves the aggregated information of a specific object identified by its CID.
75
- *
76
- * This method sends a request to the server to fetch details about the
77
- * object, including its metadata and other relevant information.
78
- *
79
- * @param {AutoDriveApi} api - The API instance used to send requests.
80
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object to retrieve.
81
- * @returns {Promise<ObjectInformation>} - A promise that resolves to the information of the requested object.
82
- * @throws {Error} - Throws an error if the request fails.
83
- */
84
- const getObject = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
85
- const response = yield api.sendRequest(`/objects/${query.cid}`, {
86
- method: 'GET',
87
- });
88
- if (!response.ok) {
89
- throw new Error(`Failed to get object: ${response.statusText}`);
90
- }
91
- return response.json();
92
- });
93
- exports.getObject = getObject;
94
- /**
95
- * Retrieves the upload status of a specific object identified by its CID.
96
- *
97
- * This method sends a request to the server to fetch the current upload status
98
- * of the object, which can indicate whether the upload is pending, completed,
99
- * or failed.
100
- *
101
- * @param {AutoDriveApi} api - The API instance used to send requests.
102
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object whose upload status is to be retrieved.
103
- * @returns {Promise<ObjectInformation['uploadStatus']>} - A promise that resolves to the upload status of the requested object.
104
- * @throws {Error} - Throws an error if the request fails.
105
- */
106
- const getObjectUploadStatus = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
107
- const response = yield api.sendRequest(`/objects/${query.cid}/status`, {
108
- method: 'GET',
109
- });
110
- if (!response.ok) {
111
- throw new Error(`Failed to get object: ${response.statusText}`);
112
- }
113
- return response.json();
114
- });
115
- exports.getObjectUploadStatus = getObjectUploadStatus;
116
- /**
117
- * Retrieves the owners of a specific object identified by its CID.
118
- *
119
- * This method sends a request to the server to fetch the list of owners
120
- * associated with the object. The owners can provide insights into who
121
- * has access to or control over the object.
122
- *
123
- * @param {AutoDriveApi} api - The API instance used to send requests.
124
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object whose owners are to be retrieved.
125
- * @returns {Promise<ObjectInformation['owners']>} - A promise that resolves to the list of owners of the requested object.
126
- * @throws {Error} - Throws an error if the request fails.
127
- */
128
- const getObjectOwners = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
129
- const response = yield api.sendRequest(`/objects/${query.cid}/owners`, {
130
- method: 'GET',
131
- });
132
- if (!response.ok) {
133
- throw new Error(`Failed to get object: ${response.statusText}`);
134
- }
135
- return response.json();
136
- });
137
- exports.getObjectOwners = getObjectOwners;
138
- /**
139
- * Retrieves the metadata of a specific object identified by its CID.
140
- *
141
- * This method sends a request to the server to fetch the metadata associated
142
- * with the object. The metadata can include various details about the object,
143
- * such as its name, type, size, and other relevant information.
144
- *
145
- * @param {AutoDriveApi} api - The API instance used to send requests.
146
- * @param {ArgsWithoutPagination<{ cid: string }>} query - The query parameters containing the CID of the object whose metadata is to be retrieved.
147
- * @returns {Promise<ObjectInformation['metadata']>} - A promise that resolves to the metadata of the requested object.
148
- * @throws {Error} - Throws an error if the request fails.
149
- */
150
- const getObjectMetadata = (api, query) => __awaiter(void 0, void 0, void 0, function* () {
151
- const response = yield api.sendRequest(`/objects/${query.cid}/metadata`, {
152
- method: 'GET',
153
- });
154
- if (!response.ok) {
155
- throw new Error(`Failed to get object: ${response.statusText}`);
156
- }
157
- return response.json();
158
- });
159
- exports.getObjectMetadata = getObjectMetadata;
@@ -1,93 +0,0 @@
1
- import { ArgsWithoutPagination } from '../../utils/types';
2
- import { AutoDriveApi } from '../connection';
3
- import { FolderTree } from '../models/folderTree';
4
- import { CompleteUploadResponse, FileUpload, FileUploadOptions, FolderUpload } from '../models/uploads';
5
- /**
6
- * Initiates a file upload to the server.
7
- *
8
- * @param {AutoDriveApi} api - The API instance used to send requests.
9
- * @param {ArgsWithoutPagination<{ mimeType?: string; filename: string; uploadOptions: FileUploadOptions | null }>} args - The arguments for the file upload.
10
- * @param {string} args.mimeType - The MIME type of the file (optional).
11
- * @param {string} args.filename - The name of the file to be uploaded.
12
- * @param {FileUploadOptions | null} args.uploadOptions - Additional options for the file upload (optional).
13
- * @returns {Promise<FileUpload>} - A promise that resolves to the file upload information.
14
- * @throws {Error} - Throws an error if the upload fails.
15
- */
16
- export declare const createFileUpload: (api: AutoDriveApi, { mimeType, filename, uploadOptions, }: ArgsWithoutPagination<{
17
- mimeType?: string;
18
- filename: string;
19
- uploadOptions: FileUploadOptions | null;
20
- }>) => Promise<FileUpload>;
21
- /**
22
- * Initiates a folder upload to the server.
23
- *
24
- * @param {AutoDriveApi} api - The API instance used to send requests.
25
- * @param {ArgsWithoutPagination<{ fileTree: FolderTree; uploadOptions: FileUploadOptions }>} args - The arguments for the folder upload.
26
- * @param {FolderTree} args.fileTree - The structure of the folder and its contents to be uploaded.
27
- * @param {FileUploadOptions} args.uploadOptions - Additional options for the folder upload.
28
- * @returns {Promise<FolderUpload>} - A promise that resolves to the folder upload information.
29
- * @throws {Error} - Throws an error if the upload fails.
30
- */
31
- export declare const createFolderUpload: (api: AutoDriveApi, { fileTree, uploadOptions, }: ArgsWithoutPagination<{
32
- fileTree: FolderTree;
33
- uploadOptions?: FileUploadOptions;
34
- }>) => Promise<FolderUpload>;
35
- /**
36
- * Creates a file upload within an existing folder upload.
37
- *
38
- * @param {AutoDriveApi} api - The API instance used to send requests.
39
- * @param {ArgsWithoutPagination<{ uploadId: string; name: string; mimeType: string; relativeId: string; uploadOptions: FileUploadOptions }>} args - The arguments for the file upload.
40
- * @param {string} args.uploadId - The ID of the folder upload to which the file will be added.
41
- * @param {string} args.name - The name of the file to be uploaded.
42
- * @param {string} args.mimeType - The MIME type of the file being uploaded.
43
- * @param {string} args.relativeId - The relative ID of the file within the folder structure.
44
- * @param {FileUploadOptions} [args.uploadOptions={}] - Additional options for the file upload.
45
- * @returns {Promise<FileUpload>} - A promise that resolves to the file upload information.
46
- * @throws {Error} - Throws an error if the upload fails.
47
- */
48
- export declare const createFileUploadWithinFolderUpload: (api: AutoDriveApi, { uploadId, name, mimeType, relativeId, uploadOptions, }: ArgsWithoutPagination<{
49
- uploadId: string;
50
- name: string;
51
- mimeType?: string;
52
- relativeId: string;
53
- uploadOptions: FileUploadOptions;
54
- }>) => Promise<FileUpload>;
55
- /**
56
- * Uploads a chunk of a file to the server.
57
- *
58
- * This function allows for the uploading of a specific chunk of a file
59
- * during a multi-part upload process. It sends the chunk along with its
60
- * index to the server, which can be used to reconstruct the file on the
61
- * server side.
62
- *
63
- * @param {AutoDriveApi} api - The API instance used to send requests.
64
- * @param {ArgsWithoutPagination<{ uploadId: string; chunk: Buffer; index: number }>} args - The arguments for the file chunk upload.
65
- * @param {string} args.uploadId - The ID of the upload session.
66
- * @param {Buffer} args.chunk - The chunk of the file to be uploaded.
67
- * @param {number} args.index - The index of the chunk in the overall file.
68
- * @returns {Promise<void>} - A promise that resolves when the chunk is uploaded successfully.
69
- * @throws {Error} - Throws an error if the upload fails.
70
- */
71
- export declare const uploadFileChunk: (api: AutoDriveApi, { uploadId, chunk, index, }: ArgsWithoutPagination<{
72
- uploadId: string;
73
- chunk: Buffer;
74
- index: number;
75
- }>) => Promise<void>;
76
- /**
77
- * Completes a file or folder upload session on the server.
78
- *
79
- * This function sends a request to the server to finalize the upload
80
- * process for a given upload session identified by the upload ID. It is
81
- * typically called after all file chunks have been uploaded. This method
82
- * can be used to complete both file and folder uploads.
83
- *
84
- * @param {AutoDriveApi} api - The API instance used to send requests.
85
- * @param {ArgsWithoutPagination<{ uploadId: string }>} args - The arguments for completing the upload.
86
- * @param {string} args.uploadId - The ID of the upload session to complete.
87
- * @returns {Promise<any>} - A promise that resolves to the response from the server.
88
- * @throws {Error} - Throws an error if the completion of the upload fails.
89
- */
90
- export declare const completeUpload: (api: AutoDriveApi, { uploadId }: ArgsWithoutPagination<{
91
- uploadId: string;
92
- }>) => Promise<CompleteUploadResponse>;
93
- //# sourceMappingURL=upload.d.ts.map