@autonomys/auto-drive 1.0.4 → 1.0.6

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.
@@ -31,7 +31,7 @@ export declare const createFileUpload: (api: AutoDriveApi, { mimeType, filename,
31
31
  */
32
32
  export declare const createFolderUpload: (api: AutoDriveApi, { fileTree, uploadOptions, }: ArgsWithoutPagination<{
33
33
  fileTree: FolderTree;
34
- uploadOptions: FileUploadOptions;
34
+ uploadOptions?: FileUploadOptions;
35
35
  }>) => Promise<FolderUpload>;
36
36
  /**
37
37
  * Creates a file upload within an existing folder upload.
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/api/calls/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEvF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,QACtB,YAAY,0CAKd,qBAAqB,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACxC,CAAC,KACD,OAAO,CAAC,UAAU,CAiBpB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,QACxB,YAAY,gCAId,qBAAqB,CAAC;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,iBAAiB,CAAA;CAAE,CAAC,KACnF,OAAO,CAAC,YAAY,CAiBtB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO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,CAAC,UAAU,CAiBpB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,QACxB,YAAY,gCAId,qBAAqB,CAAC;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAAE,CAAC,KACpF,OAAO,CAAC,YAAY,CAiBtB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kCAAkC,QACxC,YAAY,4DAOd,qBAAqB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,iBAAiB,CAAA;CACjC,CAAC,KACD,OAAO,CAAC,UAAU,CAiBpB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,QACrB,YAAY,+BAKd,qBAAqB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,KAC3E,OAAO,CAAC,IAAI,CAgBd,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,QACpB,YAAY,gBACH,qBAAqB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,KACxD,OAAO,CAAC,sBAAsB,CAUhC,CAAA"}
@@ -40,7 +40,7 @@ export const createFileUpload = (api_1, _a) => __awaiter(void 0, [api_1, _a], vo
40
40
  * @returns {Promise<FolderUpload>} - A promise that resolves to the folder upload information.
41
41
  * @throws {Error} - Throws an error if the upload fails.
42
42
  */
43
- export const createFolderUpload = (api_1, _a) => __awaiter(void 0, [api_1, _a], void 0, function* (api, { fileTree, uploadOptions, }) {
43
+ export const createFolderUpload = (api_1, _a) => __awaiter(void 0, [api_1, _a], void 0, function* (api, { fileTree, uploadOptions = {}, }) {
44
44
  const response = yield api.sendRequest(`/uploads/folder`, {
45
45
  method: 'POST',
46
46
  headers: new Headers({
@@ -8,7 +8,7 @@ export declare enum OAuthProvider {
8
8
  export type ApiKeyAuthProvider = 'apikey';
9
9
  export type AuthProvider = ApiKeyAuthProvider | 'oauth';
10
10
  export declare const createAutoDriveApi: ({ provider, apiKey, url, }: {
11
- provider: AuthProvider;
11
+ provider?: AuthProvider;
12
12
  apiKey: string;
13
13
  url?: string;
14
14
  }) => AutoDriveApi;
@@ -1 +1 @@
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,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AACzC,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,OAAO,CAAA;AAEvD,eAAO,MAAM,kBAAkB,+BAI5B;IACD,QAAQ,EAAE,YAAY,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,KAAG,YAiBH,CAAA"}
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,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AACzC,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,OAAO,CAAA;AAEvD,eAAO,MAAM,kBAAkB,+BAI5B;IACD,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,KAAG,YAiBH,CAAA"}
@@ -0,0 +1,8 @@
1
+ export interface GenericFile {
2
+ read(): AsyncIterable<Buffer>;
3
+ name: string;
4
+ mimeType?: string;
5
+ size: number;
6
+ path: string;
7
+ }
8
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/api/models/file.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb"}
@@ -0,0 +1 @@
1
+ export {};
@@ -42,4 +42,6 @@ export declare const FolderTreeFileSchema: z.ZodObject<{
42
42
  }>;
43
43
  export declare const FolderTreeSchema: z.ZodType<FolderTree>;
44
44
  export declare const constructFromFileSystemEntries: (entries: string[]) => FolderTree;
45
+ export declare const constructFromInput: (input: File[]) => FolderTree;
46
+ export declare const constructZipBlobFromTreeAndPaths: (tree: FolderTree, files: Record<string, File | string>) => Promise<Blob>;
45
47
  //# sourceMappingURL=folderTree.d.ts.map
@@ -1 +1 @@
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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AAE,KAAG,UA0ClE,CAAA;AAED,eAAO,MAAM,kBAAkB,UAAW,IAAI,EAAE,KAAG,UASlD,CAAA;AAyBD,eAAO,MAAM,gCAAgC,SACrC,UAAU,SACT,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,kBAUrC,CAAA"}
@@ -1,3 +1,14 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import fs from 'fs';
11
+ import JSZip from 'jszip';
1
12
  import { z } from 'zod';
2
13
  export const FolderTreeFolderSchema = z.object({
3
14
  name: z.string(),
@@ -54,3 +65,39 @@ export const constructFromFileSystemEntries = (entries) => {
54
65
  }
55
66
  return root.children.length === 1 ? root.children[0] : root;
56
67
  };
68
+ export const constructFromInput = (input) => {
69
+ return constructFromFileSystemEntries(Array.from(input).map((file) => {
70
+ if (!file.webkitRelativePath) {
71
+ throw new Error('webkitRelativePath is not supported');
72
+ }
73
+ return file.webkitRelativePath;
74
+ }));
75
+ };
76
+ const addFilesToZip = (folder, folderNode, files) => {
77
+ folderNode.children.forEach((child) => {
78
+ if (child.type === 'file') {
79
+ const file = files[child.id];
80
+ if (typeof file === 'string') {
81
+ folder.file(child.name, fs.createReadStream(file));
82
+ }
83
+ else {
84
+ folder.file(child.name, file);
85
+ }
86
+ }
87
+ else if (child.type === 'folder') {
88
+ const subFolder = folder.folder(child.name);
89
+ if (!subFolder) {
90
+ throw new Error('Failed to create folder in zip');
91
+ }
92
+ addFilesToZip(subFolder, child, files);
93
+ }
94
+ });
95
+ };
96
+ export const constructZipBlobFromTreeAndPaths = (tree, files) => __awaiter(void 0, void 0, void 0, function* () {
97
+ if (tree.type === 'file') {
98
+ throw new Error('Cannot construct zip from file');
99
+ }
100
+ const zip = new JSZip();
101
+ addFilesToZip(zip, tree, files);
102
+ return zip.generateAsync({ type: 'blob' });
103
+ });
@@ -1,4 +1,4 @@
1
- import { FileUploadOptions } from '@autonomys/auto-dag-data';
1
+ import { CID, FileUploadOptions } from '@autonomys/auto-dag-data';
2
2
  import { z } from 'zod';
3
3
  export declare enum UploadType {
4
4
  FILE = "file",
@@ -114,4 +114,17 @@ export type FolderUpload = z.infer<typeof folderUploadSchema>;
114
114
  export type CompleteUploadResponse = {
115
115
  cid: string;
116
116
  };
117
+ export type UploadFileStatus = {
118
+ type: 'file';
119
+ progress: number;
120
+ cid?: CID;
121
+ };
122
+ export type UploadFolderStatus = {
123
+ type: 'folder';
124
+ progress: number;
125
+ cid?: CID;
126
+ };
127
+ export type UploadChunksStatus = {
128
+ uploadBytes: number;
129
+ };
117
130
  //# sourceMappingURL=uploads.d.ts.map
@@ -1 +1 @@
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,iBA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E,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA"}
@@ -1,5 +1,7 @@
1
- import { CID } from '@autonomys/auto-dag-data';
1
+ import { PromisedObservable } from '../utils/observable.js';
2
2
  import { AutoDriveApi } from './connection.js';
3
+ import { GenericFile } from './models/file.js';
4
+ import { UploadChunksStatus, UploadFileStatus, UploadFolderStatus } from './models/uploads.js';
3
5
  type UploadFileOptions = {
4
6
  password?: string;
5
7
  compression?: boolean;
@@ -8,33 +10,99 @@ type UploadFileOptions = {
8
10
  * Uploads a file to the server with optional encryption and compression.
9
11
  *
10
12
  * This function reads a file from the specified file path, optionally encrypts it
11
- * using the provided password, and compresses it using the ZLIB algorithm if specified.
13
+ * using the provided password, and compresses it using the specified algorithm if requested.
12
14
  * It then uploads the file in chunks to the server, creating an upload session and
13
- * completing it once all chunks have been uploaded.
15
+ * completing it once all chunks have been successfully uploaded.
14
16
  *
15
17
  * @param {AutoDriveApi} api - The API instance used to send requests.
16
18
  * @param {string} filePath - The path to the file to be uploaded.
17
19
  * @param {UploadFileOptions} options - Options for the upload process.
18
20
  * @param {string} [options.password] - The password for encryption (optional).
19
21
  * @param {boolean} [options.compression=true] - Whether to compress the file (optional).
20
- * @returns {Promise<void>} - A promise that resolves when the upload is complete.
22
+ * @param {number} [uploadChunkSize] - The size of each chunk to upload (optional).
23
+ * @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
21
24
  * @throws {Error} - Throws an error if the upload fails at any stage.
22
25
  */
23
- export declare const uploadFile: (api: AutoDriveApi, filePath: string, { password, compression }: UploadFileOptions, uploadChunkSize?: number) => Promise<CID>;
26
+ export declare const uploadFileFromFilepath: (api: AutoDriveApi, filePath: string, { password, compression }: UploadFileOptions, uploadChunkSize?: number) => PromisedObservable<UploadFileStatus>;
27
+ /**
28
+ * Uploads a file to the server with optional encryption and compression.
29
+ *
30
+ * This function reads a file from the provided input, optionally encrypts it
31
+ * using the specified password, and compresses it using the specified algorithm if requested.
32
+ * It uploads the file in chunks to the server, creating an upload session and
33
+ * completing it once all chunks have been successfully uploaded.
34
+ *
35
+ * @param {AutoDriveApi} api - The API instance used to send requests.
36
+ * @param {File} file - The file to be uploaded.
37
+ * @param {UploadFileOptions} options - Options for the upload process.
38
+ * @param {string} [options.password] - The password for encryption (optional).
39
+ * @param {boolean} [options.compression=true] - Whether to compress the file (optional).
40
+ * @param {number} [uploadChunkSize] - The size of each chunk to upload (optional).
41
+ * @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
42
+ * @throws {Error} - Throws an error if the upload fails at any stage.
43
+ */
44
+ export declare const uploadFileFromInput: (api: AutoDriveApi, file: File, { password, compression }: UploadFileOptions, uploadChunkSize?: number) => PromisedObservable<UploadFileStatus>;
45
+ /**
46
+ * Uploads a file to the server with optional encryption and compression.
47
+ *
48
+ * This function reads a file from the provided input, optionally encrypts it
49
+ * using the specified password, and compresses it using the specified algorithm if requested.
50
+ * It uploads the file in chunks to the server, creating an upload session and
51
+ * completing it once all chunks have been successfully uploaded.
52
+ *
53
+ * @param {AutoDriveApi} api - The API instance used to send requests.
54
+ * @param {File | GenericFile} file - The file to be uploaded, which can be a File or a GenericFile.
55
+ * @param {UploadFileOptions} options - Options for the upload process.
56
+ * @param {string} [options.password] - The password for encryption (optional).
57
+ * @param {boolean} [options.compression=true] - Whether to compress the file (optional).
58
+ * @param {number} [uploadChunkSize] - The size of each chunk to upload (optional).
59
+ * @returns {PromisedObservable<UploadFileStatus>} - An observable that emits the upload status.
60
+ * @throws {Error} - Throws an error if the upload fails at any stage.
61
+ */
62
+ export declare const uploadFile: (api: AutoDriveApi, file: GenericFile, { password, compression }: UploadFileOptions, uploadChunkSize?: number) => PromisedObservable<UploadFileStatus>;
24
63
  /**
25
64
  * Uploads an entire folder to the server.
26
65
  *
27
66
  * This function retrieves all files within the specified folder,
28
67
  * constructs a file tree representation, and initiates the upload
29
- * process. It also handles optional compression of the files during
68
+ * process. It also handles optional compression and encryption of the files during
30
69
  * the upload.
31
70
  *
71
+ * If a password is provided, the files will be zipped before uploading.
72
+ *
32
73
  * @param {AutoDriveApi} api - The API instance used to send requests.
33
74
  * @param {string} folderPath - The path of the folder to be uploaded.
34
- * @returns {Promise<void>} - A promise that resolves when the folder upload is complete.
75
+ * @param {Object} options - Optional parameters for the upload.
76
+ * @param {number} [options.uploadChunkSize] - The size of each chunk to be uploaded.
77
+ * @param {string} [options.password] - An optional password for encrypting the files.
78
+ * @returns {Promise<PromisedObservable<UploadFileStatus | UploadFolderStatus>>} - A promise that resolves to an observable that tracks the upload progress.
79
+ * @throws {Error} - Throws an error if the upload fails at any stage.
80
+ */
81
+ export declare const uploadFolderFromFolderPath: (api: AutoDriveApi, folderPath: string, { uploadChunkSize, password }?: {
82
+ uploadChunkSize?: number;
83
+ password?: string;
84
+ }) => Promise<PromisedObservable<UploadFileStatus | UploadFolderStatus>>;
85
+ /**
86
+ * Uploads an entire folder to the server.
87
+ *
88
+ * This function retrieves all files within the specified folder,
89
+ * constructs a file tree representation, and initiates the upload
90
+ * process. It also handles optional compression of the files during
91
+ * the upload. If a password is provided, the files will be zipped
92
+ * before uploading.
93
+ *
94
+ * @param {AutoDriveApi} api - The API instance used to send requests.
95
+ * @param {FileList | File[]} fileList - The list of files to be uploaded.
96
+ * @param {Object} options - Options for the upload process.
97
+ * @param {number} [options.uploadChunkSize] - The size of each chunk to upload (optional).
98
+ * @param {string} [options.password] - The password for encryption (optional).
99
+ * @returns {PromisedObservable<UploadFileStatus | UploadFolderStatus>} - An observable that emits the upload status.
35
100
  * @throws {Error} - Throws an error if the upload fails at any stage.
36
101
  */
37
- export declare const uploadFolder: (api: AutoDriveApi, folderPath: string, uploadChunkSize?: number) => Promise<CID>;
102
+ export declare const uploadFolderFromInput: (api: AutoDriveApi, fileList: FileList | File[], { uploadChunkSize, password }?: {
103
+ uploadChunkSize?: number;
104
+ password?: string;
105
+ }) => Promise<PromisedObservable<UploadFileStatus | UploadFolderStatus>>;
38
106
  /**
39
107
  * Uploads a file within an existing folder upload session.
40
108
  *
@@ -44,7 +112,7 @@ export declare const uploadFolder: (api: AutoDriveApi, folderPath: string, uploa
44
112
  *
45
113
  * @returns {Promise<void>} A promise that resolves when the file upload is complete.
46
114
  */
47
- export declare const uploadFileWithinFolderUpload: (api: AutoDriveApi, uploadId: string, filepath: string, uploadChunkSize?: number) => Promise<CID>;
115
+ export declare const uploadFileWithinFolderUpload: (api: AutoDriveApi, uploadId: string, file: GenericFile, uploadChunkSize?: number) => PromisedObservable<UploadChunksStatus>;
48
116
  /**
49
117
  * Downloads a file from the AutoDrive service.
50
118
  *
@@ -53,16 +121,5 @@ export declare const uploadFileWithinFolderUpload: (api: AutoDriveApi, uploadId:
53
121
  * @returns {Promise<ReadableStream<Uint8Array>>} A promise that resolves to a ReadableStream of the downloaded file.
54
122
  */
55
123
  export declare const downloadFile: (api: AutoDriveApi, cid: string, password?: string) => Promise<AsyncIterable<Buffer>>;
56
- /**
57
- * Downloads a folder from the AutoDrive service without encryption.
58
- *
59
- * @param {AutoDriveApi} api - The API instance to interact with the AutoDrive service.
60
- * @param {string} cid - The CID of the folder to be downloaded.
61
- *
62
- * @returns {Promise<ReadableStream<Uint8Array>>} A promise that resolves to a ReadableStream of the downloaded folder.
63
- *
64
- * @warning If the folder is encrypted, a warning will be logged, but the download will proceed without decryption.
65
- */
66
- export declare const downloadFolderWithoutEncryption: (api: AutoDriveApi, cid: string) => Promise<ReadableStream<Uint8Array>>;
67
124
  export {};
68
125
  //# sourceMappingURL=wrappers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/api/wrappers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAQJ,MAAM,0BAA0B,CAAA;AAcjC,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,KACvB,OAAO,CAAC,GAAG,CAwCb,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,QAClB,YAAY,cACL,MAAM,oBACA,MAAM,KACvB,OAAO,CAAC,GAAG,CAsBb,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,QAClC,YAAY,YACP,MAAM,YACN,MAAM,oBACE,MAAM,KACvB,OAAO,CAAC,GAAG,CAeb,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"}
1
+ {"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src/api/wrappers.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAU3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAM9C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAE9F,KAAK,iBAAiB,GAAG;IACv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