@visulima/storage 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/adapter/nuxt/module.d.ts +8 -8
- package/dist/ai/ai-sdk/index.d.ts +51 -59
- package/dist/ai/claude/index.d.ts +104 -119
- package/dist/ai/openai/index.d.ts +86 -99
- package/dist/ai/tanstack/index.d.ts +53 -61
- package/dist/handler/http/fetch/index.d.ts +201 -201
- package/dist/handler/http/hono/index.d.ts +59 -59
- package/dist/handler/http/nextjs/index.d.ts +54 -54
- package/dist/handler/http/node/index.d.ts +233 -246
- package/dist/handler/http/solid-start/index.d.ts +54 -54
- package/dist/index.d.ts +70 -70
- package/dist/index.js +1 -1
- package/dist/packem_shared/{AwsLightStorage-BK-WPL0h.js → AwsLightStorage-EsqkAtU5.js} +1 -1
- package/dist/packem_shared/{AzureStorage-1UvDIQZd.js → AzureStorage-DL-U7qFG.js} +1 -1
- package/dist/packem_shared/BoxMetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{BoxStorage-DbGqBLux.js → BoxStorage-B8_oCz27.js} +1 -1
- package/dist/packem_shared/BunS3MetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{BunS3Storage-DNvimm9e.js → BunS3Storage-_PVXu_na.js} +1 -1
- package/dist/packem_shared/BunnyMetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{BunnyStorage-C7d0opLL.js → BunnyStorage-BsoWjScH.js} +1 -1
- package/dist/packem_shared/CloudinaryMetaStorage-BI9YXcwU.js +1 -0
- package/dist/packem_shared/{CloudinaryStorage-Dc3XA2lP.js → CloudinaryStorage-BNwiLF9V.js} +1 -1
- package/dist/packem_shared/{DiskStorage-CI07TVNu.js → DiskStorage-D-NtQDms.js} +1 -1
- package/dist/packem_shared/{DiskStorageWithChecksum-vFCubS6K.js → DiskStorageWithChecksum-UnCtyEvs.js} +1 -1
- package/dist/packem_shared/DropboxMetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{DropboxStorage-CY9Ggu3m.js → DropboxStorage-BS9kj0nH.js} +1 -1
- package/dist/packem_shared/FirebaseMetaStorage-BI9YXcwU.js +1 -0
- package/dist/packem_shared/{FirebaseStorage-D6O9CJXN.js → FirebaseStorage-DNquii2p.js} +1 -1
- package/dist/packem_shared/FtpMetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{FtpStorage-DbEjbq8z.js → FtpStorage-Bd004--s.js} +1 -1
- package/dist/packem_shared/{GCSMetaStorage-DT8K6zdm.js → GCSMetaStorage-Bf4qDFB1.js} +1 -1
- package/dist/packem_shared/{GCStorage-6BHkFlEs.js → GCStorage-ChqEpgqR.js} +1 -1
- package/dist/packem_shared/GoogleDriveMetaStorage-xlHfKwmR.js +1 -0
- package/dist/packem_shared/{GoogleDriveStorage-Bklsz7Bh.js → GoogleDriveStorage-v1glykjd.js} +1 -1
- package/dist/packem_shared/{LocalMetaStorage-BhicZnNl.js → LocalMetaStorage-YWPBYEe7.js} +1 -1
- package/dist/packem_shared/NetlifyBlobMetaStorage-BI9YXcwU.js +1 -0
- package/dist/packem_shared/{NetlifyBlobStorage-CkpCCoN1.js → NetlifyBlobStorage-BPyEWSnx.js} +1 -1
- package/dist/packem_shared/OneDriveMetaStorage-xlHfKwmR.js +1 -0
- package/dist/packem_shared/{OneDriveStorage-CP6MvGAa.js → OneDriveStorage-BJ3Kzxc5.js} +1 -1
- package/dist/packem_shared/PocketBaseMetaStorage-DnrxOQhO.js +1 -0
- package/dist/packem_shared/{PocketBaseStorage-2qhbI2PW.js → PocketBaseStorage-DqKHbbvn.js} +1 -1
- package/dist/packem_shared/{S3Storage-YGeNk3Tt.js → S3Storage-BiI2k6d1.js} +1 -1
- package/dist/packem_shared/SftpMetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{SftpStorage-2Hz396Xr.js → SftpStorage-w8XdtZtw.js} +1 -1
- package/dist/packem_shared/SharePointMetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{SharePointStorage-CrX2Pk6C.js → SharePointStorage-DpDpI7Ln.js} +1 -1
- package/dist/packem_shared/SupabaseMetaStorage-xlHfKwmR.js +1 -0
- package/dist/packem_shared/{SupabaseStorage-Dc_DBX29.js → SupabaseStorage-B_ugUCs7.js} +1 -1
- package/dist/packem_shared/UploadThingMetaStorage-BI9YXcwU.js +1 -0
- package/dist/packem_shared/{UploadThingStorage-BChykYSe.js → UploadThingStorage-_H45IVqX.js} +1 -1
- package/dist/packem_shared/VercelBlobMetaStorage-CHWrhgg2.js +1 -0
- package/dist/packem_shared/{VercelBlobStorage-CsRyPfw3.js → VercelBlobStorage-U1YMKeHs.js} +1 -1
- package/dist/packem_shared/{approval.d-CMAYH9GF.d.ts → approval.d-C-d-t94D.d.ts} +6 -6
- package/dist/packem_shared/disk-storage-BwPk2IRa.js +1 -0
- package/dist/packem_shared/disk-storage-with-checksum.d-CQucFacO.d.ts +146 -0
- package/dist/packem_shared/{executors.d-BZP2rWo3.d.ts → executors.d-DeDH3Ilt.d.ts} +2 -2
- package/dist/packem_shared/files.d-D8H_ge9Y.d.ts +655 -0
- package/dist/packem_shared/{gcs-meta-storage-B7BnctnV.js → gcs-meta-storage-DQGu_cHq.js} +1 -1
- package/dist/packem_shared/local-meta-storage-DJDcuxf1.js +11 -0
- package/dist/packem_shared/{local-meta-storage.d-D9PBfkn6.d.ts → local-meta-storage.d-DuTEzyii.d.ts} +7 -7
- package/dist/packem_shared/media-transformer.d-CvMFjINm.d.ts +331 -0
- package/dist/packem_shared/{memory-storage.d-4EU1cMt1.d.ts → memory-storage.d-BRdTiY8y.d.ts} +32 -40
- package/dist/packem_shared/{s3-base-storage-BoTyhuzO.js → s3-base-storage-CMUui93V.js} +1 -1
- package/dist/packem_shared/{s3-base-storage.d-BQgP5B-t.d.ts → s3-base-storage.d-Cg7m4FuH.d.ts} +64 -70
- package/dist/packem_shared/storage.d-DIav_lF1.d.ts +1163 -0
- package/dist/packem_shared/tus-base.d-BiEg5t4t.d.ts +102 -0
- package/dist/packem_shared/{types.d-CrUWY4On.d.ts → types.d-CAAzKiI6.d.ts} +134 -134
- package/dist/packem_shared/types.d-DgHhkCAl.d.ts +104 -0
- package/dist/packem_shared/{types.d-CggTCgXr.d.ts → types.d-jAs_Rp_v.d.ts} +3 -3
- package/dist/storage/aws/clients/index.d.ts +388 -388
- package/dist/storage/aws/index.d.ts +109 -113
- package/dist/storage/aws/index.js +1 -1
- package/dist/storage/aws-light/index.d.ts +63 -67
- package/dist/storage/aws-light/index.js +1 -1
- package/dist/storage/azure/index.d.ts +133 -139
- package/dist/storage/azure/index.js +1 -1
- package/dist/storage/box/index.d.ts +88 -92
- package/dist/storage/box/index.js +1 -1
- package/dist/storage/bun-s3/index.d.ts +70 -76
- package/dist/storage/bun-s3/index.js +1 -1
- package/dist/storage/bunny/index.d.ts +51 -55
- package/dist/storage/bunny/index.js +1 -1
- package/dist/storage/cloudinary/index.d.ts +53 -59
- package/dist/storage/cloudinary/index.js +1 -1
- package/dist/storage/dropbox/index.d.ts +58 -62
- package/dist/storage/dropbox/index.js +1 -1
- package/dist/storage/firebase/index.d.ts +73 -79
- package/dist/storage/firebase/index.js +1 -1
- package/dist/storage/ftp/index.d.ts +37 -43
- package/dist/storage/ftp/index.js +1 -1
- package/dist/storage/gcs/index.d.ts +89 -95
- package/dist/storage/gcs/index.js +1 -1
- package/dist/storage/google-drive/index.d.ts +68 -72
- package/dist/storage/google-drive/index.js +1 -1
- package/dist/storage/local/index.d.ts +3 -3
- package/dist/storage/local/index.js +1 -1
- package/dist/storage/memory/index.d.ts +2 -2
- package/dist/storage/netlify-blob/index.d.ts +85 -93
- package/dist/storage/netlify-blob/index.js +1 -1
- package/dist/storage/onedrive/index.d.ts +43 -53
- package/dist/storage/onedrive/index.js +1 -1
- package/dist/storage/pocketbase/index.d.ts +66 -72
- package/dist/storage/pocketbase/index.js +1 -1
- package/dist/storage/sftp/index.d.ts +39 -45
- package/dist/storage/sftp/index.js +1 -1
- package/dist/storage/sharepoint/index.d.ts +95 -95
- package/dist/storage/sharepoint/index.js +1 -1
- package/dist/storage/supabase/index.d.ts +49 -55
- package/dist/storage/supabase/index.js +1 -1
- package/dist/storage/uploadthing/index.d.ts +33 -37
- package/dist/storage/uploadthing/index.js +1 -1
- package/dist/storage/vercel-blob/index.d.ts +109 -115
- package/dist/storage/vercel-blob/index.js +1 -1
- package/dist/transformer/audio-transformer.d.ts +96 -96
- package/dist/transformer/image-transformer.d.ts +422 -422
- package/dist/transformer/index.d.ts +34 -34
- package/dist/transformer/video-transformer.d.ts +111 -111
- package/package.json +1 -1
- package/dist/packem_shared/BoxMetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/BunS3MetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/BunnyMetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/CloudinaryMetaStorage-DPVnmNe5.js +0 -1
- package/dist/packem_shared/DropboxMetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/FirebaseMetaStorage-DPVnmNe5.js +0 -1
- package/dist/packem_shared/FtpMetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/GoogleDriveMetaStorage-Cbwa1CHV.js +0 -1
- package/dist/packem_shared/NetlifyBlobMetaStorage-DPVnmNe5.js +0 -1
- package/dist/packem_shared/OneDriveMetaStorage-Cbwa1CHV.js +0 -1
- package/dist/packem_shared/PocketBaseMetaStorage-DOTLwVE7.js +0 -1
- package/dist/packem_shared/SftpMetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/SharePointMetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/SupabaseMetaStorage-Cbwa1CHV.js +0 -1
- package/dist/packem_shared/UploadThingMetaStorage-DPVnmNe5.js +0 -1
- package/dist/packem_shared/VercelBlobMetaStorage-BSn6Qfnf.js +0 -1
- package/dist/packem_shared/disk-storage-CsQcYW3s.js +0 -1
- package/dist/packem_shared/disk-storage-with-checksum.d-B-VGEsfl.d.ts +0 -156
- package/dist/packem_shared/files.d-CH0iLBNC.d.ts +0 -655
- package/dist/packem_shared/local-meta-storage-iuJnu90B.js +0 -11
- package/dist/packem_shared/media-transformer.d-Quf4ai47.d.ts +0 -331
- package/dist/packem_shared/storage.d-CEM1upWM.d.ts +0 -1176
- package/dist/packem_shared/tus-base.d-DLzKE54M.d.ts +0 -106
- package/dist/packem_shared/types.d-Bon9GVVe.d.ts +0 -104
|
@@ -1,655 +0,0 @@
|
|
|
1
|
-
import { B as BaseStorage, O as OperationOptions } from "./storage.d-CEM1upWM.js";
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
3
|
-
/**
|
|
4
|
-
* Pause / resume / abort handle threaded into {@link Files.upload} via {@link UploadOptions.control}.
|
|
5
|
-
*
|
|
6
|
-
* `pause()` applies backpressure to the body stream; `resume()` releases it. This is effective for
|
|
7
|
-
* streaming bodies feeding streaming adapters (S3, GCS, Azure, FTP/SFTP). Buffered adapters
|
|
8
|
-
* (memory, disk) read the whole body in one shot and cannot be paused mid-transfer.
|
|
9
|
-
* `abort()` cancels the operation through the merged {@link OperationOptions.signal}.
|
|
10
|
-
* `serialize()` / {@link UploadControl.from} round-trip the key + bytes observed for UI continuity.
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const control = new UploadControl();
|
|
14
|
-
* const promise = files.upload("big.bin", stream, { size, control });
|
|
15
|
-
* pauseButton.onclick = () => control.pause();
|
|
16
|
-
* resumeButton.onclick = () => control.resume();
|
|
17
|
-
* cancelButton.onclick = () => control.abort();
|
|
18
|
-
* await promise;
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
declare class UploadControl {
|
|
22
|
-
/** Caller-facing key being uploaded; populated once the upload starts. */
|
|
23
|
-
key?: string;
|
|
24
|
-
private readonly controller;
|
|
25
|
-
private internalState;
|
|
26
|
-
private loadedBytes;
|
|
27
|
-
private startPaused;
|
|
28
|
-
private boundStream?;
|
|
29
|
-
constructor(initial?: {
|
|
30
|
-
key?: string;
|
|
31
|
-
loaded?: number;
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* Rehydrate a control from a {@link serialize} token (object or JSON string). The returned
|
|
35
|
-
* control is `idle` with its `loaded` counter pre-seeded for progress display.
|
|
36
|
-
*/
|
|
37
|
-
static from(token: UploadControlToken | string): UploadControl;
|
|
38
|
-
/** Abort signal merged into the upload operation. */
|
|
39
|
-
get signal(): AbortSignal;
|
|
40
|
-
get state(): UploadControlState;
|
|
41
|
-
/** Bytes observed leaving the facade so far. */
|
|
42
|
-
get loaded(): number;
|
|
43
|
-
pause(): void;
|
|
44
|
-
resume(): void;
|
|
45
|
-
abort(reason?: unknown): void;
|
|
46
|
-
serialize(): UploadControlToken;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Web-standard and Node-native body types accepted by {@link Files.upload}.
|
|
50
|
-
*/
|
|
51
|
-
type FileBody = ArrayBuffer | ArrayBufferView | Blob | Buffer | NodeJS.ReadableStream | ReadableStream<Uint8Array> | string;
|
|
52
|
-
/**
|
|
53
|
-
* Byte range for {@link Files.download}. Both bounds are 0-based and `end` is
|
|
54
|
-
* **inclusive**, mirroring the HTTP `Range: bytes=start-end` header. Omit `end`
|
|
55
|
-
* to read from `start` to EOF (e.g. resume an interrupted download).
|
|
56
|
-
*/
|
|
57
|
-
interface DownloadRange {
|
|
58
|
-
end?: number;
|
|
59
|
-
start: number;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Realtime upload progress report. `total` is omitted for streaming bodies of
|
|
63
|
-
* unknown length. The optional `key` is set on the bulk array form so a single
|
|
64
|
-
* callback can drive a multi-row UI.
|
|
65
|
-
*/
|
|
66
|
-
interface UploadProgress {
|
|
67
|
-
key?: string;
|
|
68
|
-
loaded: number;
|
|
69
|
-
total?: number;
|
|
70
|
-
}
|
|
71
|
-
type UploadProgressCallback = (event: UploadProgress) => void;
|
|
72
|
-
/** Lifecycle state of an {@link UploadControl}. */
|
|
73
|
-
type UploadControlState = "aborted" | "completed" | "idle" | "paused" | "uploading";
|
|
74
|
-
/**
|
|
75
|
-
* Serializable snapshot of an {@link UploadControl}, returned by {@link UploadControl.serialize}
|
|
76
|
-
* and accepted by {@link UploadControl.from}. Captures the key and bytes observed so a UI can
|
|
77
|
-
* restore progress display across reloads. Note: byte-accurate *resume* of the transfer itself is
|
|
78
|
-
* a protocol concern handled by the TUS / multipart handlers and `@visulima/storage-client`; a
|
|
79
|
-
* rehydrated control restarts the body from the beginning.
|
|
80
|
-
*/
|
|
81
|
-
interface UploadControlToken {
|
|
82
|
-
key?: string;
|
|
83
|
-
loaded: number;
|
|
84
|
-
version: 1;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Multipart tuning for {@link Files.upload}. `true` enables multipart with
|
|
88
|
-
* adapter defaults; an object lets the caller tune the per-part size and the
|
|
89
|
-
* number of parts uploaded in parallel.
|
|
90
|
-
*/
|
|
91
|
-
interface MultipartOptions {
|
|
92
|
-
/** In-flight parts. Adapter-defined default. */
|
|
93
|
-
concurrency?: number;
|
|
94
|
-
/** Per-part size in bytes. Adapter-defined default. */
|
|
95
|
-
partSize?: number;
|
|
96
|
-
}
|
|
97
|
-
interface UploadOptions {
|
|
98
|
-
/**
|
|
99
|
-
* Pre-computed content integrity checksum for end-to-end verification. Adapters that verify
|
|
100
|
-
* checksums on write (e.g. DiskStorage, TUS) reject the upload when the stored bytes don't
|
|
101
|
-
* match. Pair with {@link UploadOptions.checksumAlgorithm} to select the digest; defaults to
|
|
102
|
-
* the adapter's preferred algorithm when omitted. Ignored by adapters without checksum support.
|
|
103
|
-
*/
|
|
104
|
-
checksum?: string;
|
|
105
|
-
/**
|
|
106
|
-
* Digest algorithm for {@link UploadOptions.checksum} (e.g. `"sha256"`, `"md5"`, `"crc32c"`).
|
|
107
|
-
* Adapter-dependent; ignored when no `checksum` is supplied.
|
|
108
|
-
*/
|
|
109
|
-
checksumAlgorithm?: string;
|
|
110
|
-
contentType?: string;
|
|
111
|
-
/**
|
|
112
|
-
* Pause / resume / abort handle for this upload. Pausing applies backpressure to the body
|
|
113
|
-
* stream (effective for streaming bodies and streaming adapters; buffered adapters consume the
|
|
114
|
-
* whole body at once and cannot be paused mid-flight); aborting cancels the operation via the
|
|
115
|
-
* merged {@link OperationOptions.signal}. See {@link UploadControl}.
|
|
116
|
-
*/
|
|
117
|
-
control?: UploadControl;
|
|
118
|
-
metadata?: Record<string, unknown>;
|
|
119
|
-
/**
|
|
120
|
-
* Enable multipart/chunked upload for large bodies. `true` uses the
|
|
121
|
-
* adapter's defaults; pass an object to tune. Adapters that don't have a
|
|
122
|
-
* multipart primitive ignore this option.
|
|
123
|
-
*/
|
|
124
|
-
multipart?: MultipartOptions | boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Realtime progress reporter. For buffered bodies a coarse start/done pair
|
|
127
|
-
* is emitted. For streaming bodies each chunk is reported as it leaves the
|
|
128
|
-
* facade. Adapters that report progress natively (`reportsUploadProgress`)
|
|
129
|
-
* supersede this with byte-accurate events. A throwing callback can never
|
|
130
|
-
* fail the upload — exceptions are swallowed.
|
|
131
|
-
*/
|
|
132
|
-
onProgress?: UploadProgressCallback;
|
|
133
|
-
/**
|
|
134
|
-
* Explicit byte length. Required for {@link NodeJS.ReadableStream} and Web `ReadableStream`
|
|
135
|
-
* inputs because their length is not derivable from the value itself; ignored otherwise.
|
|
136
|
-
*/
|
|
137
|
-
size?: number;
|
|
138
|
-
storageClass?: string;
|
|
139
|
-
}
|
|
140
|
-
interface SignedReadUrlOptions {
|
|
141
|
-
expiresIn?: number;
|
|
142
|
-
responseContentDisposition?: string;
|
|
143
|
-
responseContentType?: string;
|
|
144
|
-
}
|
|
145
|
-
interface SignedUploadUrlOptions {
|
|
146
|
-
contentLength?: number;
|
|
147
|
-
contentType?: string;
|
|
148
|
-
expiresIn?: number;
|
|
149
|
-
}
|
|
150
|
-
interface ListOptions {
|
|
151
|
-
/**
|
|
152
|
-
* Collapse keys that share a path segment into S3-style common prefixes ("directories").
|
|
153
|
-
* When set, {@link Files.list} returns a {@link ListDirectoryResult} (`{ files, prefixes }`)
|
|
154
|
-
* instead of a flat array: keys with no further `delimiter` after the listing prefix come back
|
|
155
|
-
* as `files`, and everything below a shared boundary is folded into a single `prefixes` entry.
|
|
156
|
-
* Pass `"/"` for conventional folder semantics.
|
|
157
|
-
*/
|
|
158
|
-
delimiter?: string;
|
|
159
|
-
limit?: number;
|
|
160
|
-
prefix?: string;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Directory-style listing returned by {@link Files.list} when a `delimiter` is supplied.
|
|
164
|
-
*/
|
|
165
|
-
interface ListDirectoryResult {
|
|
166
|
-
/** Objects that live directly under the listing prefix (no further delimiter). */
|
|
167
|
-
files: FileObject[];
|
|
168
|
-
/** Common prefixes ("subdirectories") one delimiter level below the listing prefix. */
|
|
169
|
-
prefixes: string[];
|
|
170
|
-
}
|
|
171
|
-
interface ListAllOptions {
|
|
172
|
-
/** Per-page size requested from the adapter. */
|
|
173
|
-
limit?: number;
|
|
174
|
-
prefix?: string;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Capability snapshot for the adapter behind a {@link Files} instance, surfaced so callers can
|
|
178
|
-
* branch (or fail fast) instead of discovering an unsupported operation mid-flight.
|
|
179
|
-
*/
|
|
180
|
-
interface StorageCapabilities {
|
|
181
|
-
/** The adapter honours an object `cacheControl` directive on write. */
|
|
182
|
-
cacheControl: boolean;
|
|
183
|
-
/** The adapter persists and returns user-supplied key/value metadata. */
|
|
184
|
-
metadata: boolean;
|
|
185
|
-
/** The adapter honours byte-range downloads (`download({ range })`). */
|
|
186
|
-
range: boolean;
|
|
187
|
-
/** This `Files` view rejects every mutating operation. */
|
|
188
|
-
readonly: boolean;
|
|
189
|
-
}
|
|
190
|
-
interface DownloadOptions extends OperationOptions {
|
|
191
|
-
/**
|
|
192
|
-
* Fetch a contiguous byte slice instead of the whole object. Throws
|
|
193
|
-
* `METHOD_NOT_ALLOWED` when the underlying adapter has `supportsRange =
|
|
194
|
-
* false`, so the bandwidth saving is never silently lost client-side.
|
|
195
|
-
*/
|
|
196
|
-
range?: DownloadRange;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Provider-agnostic metadata-only view of an object.
|
|
200
|
-
*/
|
|
201
|
-
interface FileObject {
|
|
202
|
-
contentType: string;
|
|
203
|
-
etag?: string;
|
|
204
|
-
key: string;
|
|
205
|
-
lastModified?: Date | number | string;
|
|
206
|
-
metadata?: Record<string, unknown>;
|
|
207
|
-
size?: number;
|
|
208
|
-
}
|
|
209
|
-
interface DownloadResult extends FileObject {
|
|
210
|
-
body: Buffer;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Streaming variant of {@link DownloadResult} returned by {@link Files.downloadStream}. The object
|
|
214
|
-
* body is exposed as a Node {@link NodeJS.ReadableStream} instead of a fully-buffered `Buffer`, so
|
|
215
|
-
* serving a large object never allocates the whole payload in memory. Backed by the adapter's
|
|
216
|
-
* native `getStream()`.
|
|
217
|
-
*/
|
|
218
|
-
interface DownloadStreamResult extends FileObject {
|
|
219
|
-
body: Readable;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Caller-facing event for {@link FilesOptions.hooks}. Mirrors what runs through
|
|
223
|
-
* the facade (the public `key`/`keys` and the operation type) without leaking
|
|
224
|
-
* adapter internals.
|
|
225
|
-
*/
|
|
226
|
-
interface HookEvent {
|
|
227
|
-
durationMs?: number;
|
|
228
|
-
error?: Error;
|
|
229
|
-
/** Source key for `copy`/`move`. */
|
|
230
|
-
from?: string;
|
|
231
|
-
key?: string;
|
|
232
|
-
keys?: string[];
|
|
233
|
-
/** Destination key for `copy`/`move`. */
|
|
234
|
-
to?: string;
|
|
235
|
-
type: HookActionType;
|
|
236
|
-
}
|
|
237
|
-
type HookActionType = "copy" | "delete" | "download" | "exists" | "head" | "list" | "listAll" | "move" | "signedUploadUrl" | "transfer" | "upload" | "url";
|
|
238
|
-
/**
|
|
239
|
-
* Lifecycle hooks observed by the Files facade. Every hook is fire-and-forget —
|
|
240
|
-
* called, not awaited — and exceptions are swallowed so a hook can never fail
|
|
241
|
-
* the operation it observes.
|
|
242
|
-
*/
|
|
243
|
-
interface FilesHooks {
|
|
244
|
-
/** Called once per successful operation, with timing and result keys. */
|
|
245
|
-
onAction?: (event: HookEvent) => void;
|
|
246
|
-
/** Called once per failed operation, with the error attached. */
|
|
247
|
-
onError?: (event: HookEvent & {
|
|
248
|
-
error: Error;
|
|
249
|
-
}) => void;
|
|
250
|
-
/**
|
|
251
|
-
* Called when the underlying adapter retries an operation. Receives the
|
|
252
|
-
* attempt number (1-based) and the error that triggered the retry.
|
|
253
|
-
*/
|
|
254
|
-
onRetry?: (event: HookEvent & {
|
|
255
|
-
attempt: number;
|
|
256
|
-
error: Error;
|
|
257
|
-
}) => void;
|
|
258
|
-
}
|
|
259
|
-
interface FilesOptions<TStorage extends BaseStorage = BaseStorage> {
|
|
260
|
-
adapter: TStorage;
|
|
261
|
-
/**
|
|
262
|
-
* Default {@link OperationOptions} (`signal`, `timeout`, `retries`) merged into every call.
|
|
263
|
-
* Per-call overrides win. The `signal` is combined with any per-call `signal` via
|
|
264
|
-
* `AbortSignal.any`, so either one aborts the operation.
|
|
265
|
-
*/
|
|
266
|
-
defaults?: OperationOptions;
|
|
267
|
-
/**
|
|
268
|
-
* Lifecycle hooks observed by every operation. Fire-and-forget — a throwing
|
|
269
|
-
* hook is silently swallowed and never fails the call it observes.
|
|
270
|
-
*/
|
|
271
|
-
hooks?: FilesHooks;
|
|
272
|
-
/**
|
|
273
|
-
* Namespace every key under this prefix. Reads, writes, copies, listings, URLs, and signed
|
|
274
|
-
* uploads all resolve keys as `${prefix}/${key}`; returned keys (including from `list()`) have
|
|
275
|
-
* the prefix stripped back off. Leading/trailing slashes are normalized so `"/users/"` and
|
|
276
|
-
* `"users"` behave identically.
|
|
277
|
-
*
|
|
278
|
-
* `list()` scopes results on a path boundary, so `prefix: "users"` never matches the sibling
|
|
279
|
-
* `users-archive/`.
|
|
280
|
-
*/
|
|
281
|
-
prefix?: string;
|
|
282
|
-
/**
|
|
283
|
-
* When `true`, every mutating operation (`upload`, `delete`, `copy`, `move`, `signedUploadUrl`)
|
|
284
|
-
* fails immediately with `FilesError { code: "ReadOnly" }` before the adapter is touched; reads
|
|
285
|
-
* (`download`, `head`, `exists`, `list`, `listAll`, `url`) pass through. Derive a locked view of
|
|
286
|
-
* an existing client with {@link Files.readonly} instead of threading the flag manually.
|
|
287
|
-
* @default false
|
|
288
|
-
*/
|
|
289
|
-
readonly?: boolean;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* One item in a bulk upload call.
|
|
293
|
-
*/
|
|
294
|
-
interface BulkUploadItem extends UploadOptions {
|
|
295
|
-
body: FileBody;
|
|
296
|
-
key: string;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Per-call options shared by every bulk method (`upload`, `download`, `head`, `exists`, `delete`).
|
|
300
|
-
*/
|
|
301
|
-
interface BulkOptions extends OperationOptions {
|
|
302
|
-
/**
|
|
303
|
-
* Maximum number of in-flight operations.
|
|
304
|
-
* @default 8
|
|
305
|
-
*/
|
|
306
|
-
concurrency?: number;
|
|
307
|
-
/**
|
|
308
|
-
* When `true`, stop dispatching new operations as soon as one fails. The already-issued
|
|
309
|
-
* operations still complete. Defaults to `false`: every key is attempted and per-key failures
|
|
310
|
-
* are collected in `errors`.
|
|
311
|
-
* @default false
|
|
312
|
-
*/
|
|
313
|
-
stopOnError?: boolean;
|
|
314
|
-
}
|
|
315
|
-
interface BulkDownloadOptions extends BulkOptions {
|
|
316
|
-
range?: DownloadRange;
|
|
317
|
-
}
|
|
318
|
-
interface BulkUploadOptions extends BulkOptions {
|
|
319
|
-
multipart?: MultipartOptions | boolean;
|
|
320
|
-
onProgress?: UploadProgressCallback;
|
|
321
|
-
}
|
|
322
|
-
interface BulkError {
|
|
323
|
-
error: Error;
|
|
324
|
-
key: string;
|
|
325
|
-
}
|
|
326
|
-
interface BulkUploadResult {
|
|
327
|
-
errors?: BulkError[];
|
|
328
|
-
uploaded: FileObject[];
|
|
329
|
-
}
|
|
330
|
-
interface BulkDownloadResult {
|
|
331
|
-
downloaded: DownloadResult[];
|
|
332
|
-
errors?: BulkError[];
|
|
333
|
-
}
|
|
334
|
-
interface BulkHeadResult {
|
|
335
|
-
errors?: BulkError[];
|
|
336
|
-
files: FileObject[];
|
|
337
|
-
}
|
|
338
|
-
interface BulkExistsResult {
|
|
339
|
-
errors?: BulkError[];
|
|
340
|
-
existing: string[];
|
|
341
|
-
missing: string[];
|
|
342
|
-
}
|
|
343
|
-
interface BulkDeleteResult {
|
|
344
|
-
deleted: string[];
|
|
345
|
-
errors?: BulkError[];
|
|
346
|
-
}
|
|
347
|
-
interface BulkMoveItem {
|
|
348
|
-
from: string;
|
|
349
|
-
to: string;
|
|
350
|
-
}
|
|
351
|
-
interface BulkMoveResult {
|
|
352
|
-
errors?: BulkError[];
|
|
353
|
-
moved: FileObject[];
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Per-key event reported to {@link TransferOptions.onProgress}.
|
|
357
|
-
*/
|
|
358
|
-
interface TransferProgress {
|
|
359
|
-
/** 1-based index of the current key in walk order. */
|
|
360
|
-
done: number;
|
|
361
|
-
error?: Error;
|
|
362
|
-
key: string;
|
|
363
|
-
status: "errored" | "skipped" | "transferred";
|
|
364
|
-
}
|
|
365
|
-
interface TransferOptions extends OperationOptions {
|
|
366
|
-
/**
|
|
367
|
-
* In-flight key transfers.
|
|
368
|
-
* @default 8
|
|
369
|
-
*/
|
|
370
|
-
concurrency?: number;
|
|
371
|
-
/** Per-page size requested from the source adapter while walking. */
|
|
372
|
-
limit?: number;
|
|
373
|
-
/** Fire-and-forget progress reporter. Throws are swallowed. */
|
|
374
|
-
onProgress?: (event: TransferProgress) => void;
|
|
375
|
-
/**
|
|
376
|
-
* When `false`, skip keys that already exist at the destination. When `true`, always upload.
|
|
377
|
-
* @default false
|
|
378
|
-
*/
|
|
379
|
-
overwrite?: boolean;
|
|
380
|
-
/** Restrict the walk to this prefix on the source. */
|
|
381
|
-
prefix?: string;
|
|
382
|
-
/**
|
|
383
|
-
* When `true`, the first failing transfer rejects {@link transfer} instead of being
|
|
384
|
-
* collected in `errors`.
|
|
385
|
-
* @default false
|
|
386
|
-
*/
|
|
387
|
-
stopOnError?: boolean;
|
|
388
|
-
/** Transform each source key into the destination key. Defaults to identity. */
|
|
389
|
-
transformKey?: (key: string) => string;
|
|
390
|
-
}
|
|
391
|
-
interface TransferResult {
|
|
392
|
-
errors?: BulkError[];
|
|
393
|
-
skipped: string[];
|
|
394
|
-
transferred: string[];
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Per-key event reported to {@link SyncOptions.onProgress}.
|
|
398
|
-
*/
|
|
399
|
-
interface SyncProgress {
|
|
400
|
-
/** 1-based index of the current key in walk order. */
|
|
401
|
-
done: number;
|
|
402
|
-
error?: Error;
|
|
403
|
-
key: string;
|
|
404
|
-
status: "deleted" | "errored" | "skipped" | "unchanged" | "updated" | "uploaded";
|
|
405
|
-
}
|
|
406
|
-
interface SyncOptions extends OperationOptions {
|
|
407
|
-
/**
|
|
408
|
-
* In-flight key operations.
|
|
409
|
-
* @default 8
|
|
410
|
-
*/
|
|
411
|
-
concurrency?: number;
|
|
412
|
-
/**
|
|
413
|
-
* Compute the plan without writing anything. The returned `uploaded`/`updated`/`deleted` lists
|
|
414
|
-
* describe what *would* happen; the destination is left untouched.
|
|
415
|
-
* @default false
|
|
416
|
-
*/
|
|
417
|
-
dryRun?: boolean;
|
|
418
|
-
/** Per-page size requested from the source adapter while walking. */
|
|
419
|
-
limit?: number;
|
|
420
|
-
/** Fire-and-forget progress reporter. Throws are swallowed. */
|
|
421
|
-
onProgress?: (event: SyncProgress) => void;
|
|
422
|
-
/** Restrict the sync to this prefix on both source and destination. */
|
|
423
|
-
prefix?: string;
|
|
424
|
-
/**
|
|
425
|
-
* Delete destination keys that no longer exist on the source (mirror semantics). Pruning runs
|
|
426
|
-
* after the copy pass so a failed upload never triggers a delete of its counterpart.
|
|
427
|
-
* @default false
|
|
428
|
-
*/
|
|
429
|
-
prune?: boolean;
|
|
430
|
-
/**
|
|
431
|
-
* When `true`, the first failing operation rejects {@link sync} instead of being collected in
|
|
432
|
-
* `errors`. Pruning is skipped when a copy-phase error stops the run.
|
|
433
|
-
* @default false
|
|
434
|
-
*/
|
|
435
|
-
stopOnError?: boolean;
|
|
436
|
-
/** Transform each source key into the destination key. Defaults to identity. */
|
|
437
|
-
transformKey?: (key: string) => string;
|
|
438
|
-
}
|
|
439
|
-
interface SyncResult {
|
|
440
|
-
/** Destination keys removed because they were absent from the source (only when `prune`). */
|
|
441
|
-
deleted: string[];
|
|
442
|
-
errors?: BulkError[];
|
|
443
|
-
/** Source keys whose destination copy already matched and was left untouched. */
|
|
444
|
-
unchanged: string[];
|
|
445
|
-
/** Source keys re-uploaded because the destination copy differed. */
|
|
446
|
-
updated: string[];
|
|
447
|
-
/** Source keys newly created at the destination. */
|
|
448
|
-
uploaded: string[];
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Provider-agnostic facade over a {@link BaseStorage} instance.
|
|
452
|
-
*
|
|
453
|
-
* Provides a small, consistent surface (`upload`, `download`, `head`, `exists`, `delete`, `copy`,
|
|
454
|
-
* `move`, `list`, `listAll`, `url`, `signedUploadUrl`) and a `raw` escape hatch to the adapter's native
|
|
455
|
-
* client. A separate {@link transfer} top-level export streams every object from one Files instance
|
|
456
|
-
* to another for cross-provider migration.
|
|
457
|
-
*
|
|
458
|
-
* Each operation accepts per-call `signal`, `timeout`, and `retries` via {@link OperationOptions};
|
|
459
|
-
* defaults set on the constructor are merged in (per-call wins). Single-key methods also accept an
|
|
460
|
-
* array of keys (or {@link BulkUploadItem}s for `upload`) to run a bounded-concurrency batch and
|
|
461
|
-
* return a structured `{ ..., errors? }` result instead of throwing on partial failure.
|
|
462
|
-
*
|
|
463
|
-
* When constructed with a `prefix`, every key is resolved relative to the prefix and the prefix is
|
|
464
|
-
* stripped back off the keys returned in results — application code works in its own namespace.
|
|
465
|
-
*
|
|
466
|
-
* Pass `hooks: { onAction, onError, onRetry }` to observe activity. Hooks are fire-and-forget and
|
|
467
|
-
* never fail the operation they observe.
|
|
468
|
-
* @example
|
|
469
|
-
* ```ts
|
|
470
|
-
* import { Files, S3Storage } from "@visulima/storage";
|
|
471
|
-
*
|
|
472
|
-
* const files = new Files({
|
|
473
|
-
* adapter: new S3Storage({ bucket: "uploads", region: "us-east-1" }),
|
|
474
|
-
* prefix: "users",
|
|
475
|
-
* defaults: { timeout: 30_000 },
|
|
476
|
-
* hooks: { onAction: (event) => console.log(event.type, event.key) },
|
|
477
|
-
* });
|
|
478
|
-
*
|
|
479
|
-
* await files.upload("123/avatar.png", buffer, { contentType: "image/png" });
|
|
480
|
-
* const head = await files.head("123/avatar.png");
|
|
481
|
-
* for await (const file of files.listAll({ prefix: "123/" })) {
|
|
482
|
-
* console.log(file.key, file.size);
|
|
483
|
-
* }
|
|
484
|
-
* ```
|
|
485
|
-
*/
|
|
486
|
-
declare class Files<TStorage extends BaseStorage = BaseStorage> {
|
|
487
|
-
readonly adapter: TStorage;
|
|
488
|
-
private readonly defaults;
|
|
489
|
-
private readonly hooks;
|
|
490
|
-
private readonly prefix;
|
|
491
|
-
private readonly readonlyMode;
|
|
492
|
-
constructor(options: FilesOptions<TStorage>);
|
|
493
|
-
/**
|
|
494
|
-
* Adapter capability + mode snapshot. Read before relying on an optional operation
|
|
495
|
-
* (`range` downloads, custom `metadata`, `cacheControl`) so callers can branch instead of
|
|
496
|
-
* hitting a `MethodNotAllowed` mid-flight. `readonly` reflects this view, not the adapter.
|
|
497
|
-
*/
|
|
498
|
-
get capabilities(): StorageCapabilities;
|
|
499
|
-
/**
|
|
500
|
-
* Derive a read-only view sharing this instance's adapter, prefix, defaults, and hooks. Every
|
|
501
|
-
* mutating call on the returned client fails with `FilesError { code: "ReadOnly" }` before the
|
|
502
|
-
* adapter is touched. Cheaper and safer than handing a writable client to code that should only
|
|
503
|
-
* read.
|
|
504
|
-
* @example
|
|
505
|
-
* ```ts
|
|
506
|
-
* const ro = files.readonly();
|
|
507
|
-
* await ro.download("a.txt"); // ok
|
|
508
|
-
* await ro.delete("a.txt"); // throws ReadOnly
|
|
509
|
-
* ```
|
|
510
|
-
*/
|
|
511
|
-
readonly(): Files<TStorage>;
|
|
512
|
-
/** Fail closed before any adapter mutation when this view is read-only. */
|
|
513
|
-
private assertWritable;
|
|
514
|
-
/**
|
|
515
|
-
* Escape hatch to the adapter's native client (S3Client, BlobServiceClient, ...).
|
|
516
|
-
* Typed via the `TStorage` parameter, so pinning the adapter type at construction yields a
|
|
517
|
-
* typed view of the native client. Returns `undefined` when the adapter has no native client
|
|
518
|
-
* (e.g. DiskStorage).
|
|
519
|
-
*/
|
|
520
|
-
get raw(): TStorage["raw"];
|
|
521
|
-
/** Resolve a caller-supplied key into the underlying storage key. */
|
|
522
|
-
private resolveKey;
|
|
523
|
-
/**
|
|
524
|
-
* Strip the constructor prefix off a key returned by the adapter. Returns `null` when the key
|
|
525
|
-
* is outside the prefix or is the bare prefix itself (used to filter `list()` results on a path
|
|
526
|
-
* boundary and drop any synthetic directory entry the adapter may emit).
|
|
527
|
-
*/
|
|
528
|
-
private stripPrefix;
|
|
529
|
-
/**
|
|
530
|
-
* Merge constructor defaults with per-call options. When `hooks.onRetry` is configured,
|
|
531
|
-
* fold a wrapped `onRetry` into the per-call retry config so the hook fires with
|
|
532
|
-
* facade-level context (type, key, from/to) for each retry attempt the adapter performs.
|
|
533
|
-
*/
|
|
534
|
-
private mergeOptions;
|
|
535
|
-
private emitAction;
|
|
536
|
-
private emitError;
|
|
537
|
-
private withHooks;
|
|
538
|
-
/**
|
|
539
|
-
* Upload a single object, or — when passed an array of {@link BulkUploadItem}s — bulk-upload
|
|
540
|
-
* many in one call with bounded concurrency.
|
|
541
|
-
*/
|
|
542
|
-
upload(key: string, body: FileBody, options?: OperationOptions & UploadOptions): Promise<FileObject>;
|
|
543
|
-
upload(items: BulkUploadItem[], options?: BulkUploadOptions): Promise<BulkUploadResult>;
|
|
544
|
-
private uploadOne;
|
|
545
|
-
private uploadMany;
|
|
546
|
-
/**
|
|
547
|
-
* Download a single object, or — when passed an array of keys — bulk-download many in one
|
|
548
|
-
* call with bounded concurrency.
|
|
549
|
-
*/
|
|
550
|
-
download(key: string, options?: DownloadOptions): Promise<DownloadResult>;
|
|
551
|
-
download(keys: string[], options?: BulkDownloadOptions): Promise<BulkDownloadResult>;
|
|
552
|
-
private assertRangeSupported;
|
|
553
|
-
private downloadOne;
|
|
554
|
-
private downloadMany;
|
|
555
|
-
/**
|
|
556
|
-
* Download a single object as a readable stream instead of a buffered {@link DownloadResult}.
|
|
557
|
-
* Backed by the adapter's native `getStream()`, this never allocates the whole payload in memory,
|
|
558
|
-
* making it the right choice for serving large objects without the `.raw` escape hatch. Object
|
|
559
|
-
* metadata (size, content-type, etag, last-modified) is fetched alongside the stream.
|
|
560
|
-
*/
|
|
561
|
-
downloadStream(key: string, options?: OperationOptions): Promise<DownloadStreamResult>;
|
|
562
|
-
/**
|
|
563
|
-
* Fetch metadata for a single object, or — when passed an array of keys — bulk-head many in
|
|
564
|
-
* one call with bounded concurrency.
|
|
565
|
-
*/
|
|
566
|
-
head(key: string, options?: OperationOptions): Promise<FileObject>;
|
|
567
|
-
head(keys: string[], options?: BulkOptions): Promise<BulkHeadResult>;
|
|
568
|
-
private headOne;
|
|
569
|
-
private headMany;
|
|
570
|
-
/**
|
|
571
|
-
* Resolves to `true`/`false` for a single key, or — when passed an array — splits the keys
|
|
572
|
-
* into `existing` and `missing` arrays. Hard errors (auth, transport) are reported in
|
|
573
|
-
* `errors`. Never throws for a missing object.
|
|
574
|
-
*/
|
|
575
|
-
exists(key: string, options?: OperationOptions): Promise<boolean>;
|
|
576
|
-
exists(keys: string[], options?: BulkOptions): Promise<BulkExistsResult>;
|
|
577
|
-
private existsOne;
|
|
578
|
-
private existsMany;
|
|
579
|
-
/**
|
|
580
|
-
* Delete a single object (resolves to `void`, throws on failure), or — when passed an array
|
|
581
|
-
* of keys — delete many in one call. Adapters with a native bulk-delete primitive (S3's
|
|
582
|
-
* `DeleteObjects`, Supabase's `remove`, UploadThing's `deleteFiles`) use it via
|
|
583
|
-
* {@link BaseStorage.deleteBatch}; otherwise the keys are fanned out with bounded concurrency.
|
|
584
|
-
*/
|
|
585
|
-
delete(key: string, options?: OperationOptions): Promise<void>;
|
|
586
|
-
delete(keys: string[], options?: BulkOptions): Promise<BulkDeleteResult>;
|
|
587
|
-
private deleteOne;
|
|
588
|
-
private deleteMany;
|
|
589
|
-
/**
|
|
590
|
-
* Copy `source` to `destination` (both resolved under any constructor prefix). Returns the
|
|
591
|
-
* destination object's metadata with the caller-facing (un-prefixed) key.
|
|
592
|
-
*/
|
|
593
|
-
copy(source: string, destination: string, options?: OperationOptions & {
|
|
594
|
-
storageClass?: string;
|
|
595
|
-
}): Promise<FileObject>;
|
|
596
|
-
/**
|
|
597
|
-
* Rename `source` to `destination`. Uses the adapter's native rename where one exists
|
|
598
|
-
* (DiskStorage atomic move, Cloudinary server-side rename) and falls back to
|
|
599
|
-
* `copy` + `delete` otherwise. Moving a key onto itself is a no-op. Also accepts an array of
|
|
600
|
-
* `{ from, to }` items for bounded-concurrency bulk moves; per-item failures land in `errors`.
|
|
601
|
-
*/
|
|
602
|
-
move(from: string, to: string, options?: OperationOptions & {
|
|
603
|
-
storageClass?: string;
|
|
604
|
-
}): Promise<FileObject>;
|
|
605
|
-
move(items: BulkMoveItem[], options?: BulkOptions): Promise<BulkMoveResult>;
|
|
606
|
-
private moveOne;
|
|
607
|
-
private moveMany;
|
|
608
|
-
/**
|
|
609
|
-
* List objects in the bucket. Returned keys have any constructor prefix stripped off, and
|
|
610
|
-
* keys outside the prefix namespace (e.g. `users-archive/` when prefix is `users`) are filtered
|
|
611
|
-
* out. The optional `prefix` filter is interpreted *relative to the constructor prefix*.
|
|
612
|
-
*
|
|
613
|
-
* Pass `delimiter` for directory-style listing: keys are collapsed into S3-style common
|
|
614
|
-
* prefixes and the call returns `{ files, prefixes }` instead of a flat array (see
|
|
615
|
-
* {@link ListDirectoryResult}). Objects with no further delimiter after the listing prefix come
|
|
616
|
-
* back as `files`; everything below a shared boundary folds into a single `prefixes` entry.
|
|
617
|
-
*
|
|
618
|
-
* **Caveat with constructor prefix**: `limit` is applied by the underlying adapter *before*
|
|
619
|
-
* the path-boundary filter runs, so the returned array may contain fewer than `limit` items
|
|
620
|
-
* even when more in-namespace objects exist. Use {@link Files.listAll} when you need every
|
|
621
|
-
* in-namespace object.
|
|
622
|
-
*/
|
|
623
|
-
list(options?: Omit<ListOptions, "delimiter"> & OperationOptions): Promise<FileObject[]>;
|
|
624
|
-
list(options: ListOptions & OperationOptions & {
|
|
625
|
-
delimiter: string;
|
|
626
|
-
}): Promise<ListDirectoryResult>;
|
|
627
|
-
/**
|
|
628
|
-
* Native directory listing: push the `delimiter` down to an adapter that collapses common
|
|
629
|
-
* prefixes server-side ({@link BaseStorage.supportsDelimiter}). Resolves the listing prefix
|
|
630
|
-
* against the constructor prefix, then strips it back off the returned keys and prefixes so the
|
|
631
|
-
* result matches the facade-synthesized shape.
|
|
632
|
-
*/
|
|
633
|
-
private listDirectoryNative;
|
|
634
|
-
/**
|
|
635
|
-
* Walk every object in the bucket. Yields one {@link FileObject} at a time as an async
|
|
636
|
-
* iterable; pages internally so callers don't have to thread a cursor. Returned keys have any
|
|
637
|
-
* constructor prefix stripped off and out-of-namespace keys are filtered out, just like
|
|
638
|
-
* {@link Files.list}.
|
|
639
|
-
*
|
|
640
|
-
* Most adapters return all objects in a single `list()` call (the default `limit` is 1000),
|
|
641
|
-
* so this is effectively `list` + iteration for them. Adapters that paginate natively can
|
|
642
|
-
* override `list` to honour the per-page `limit` and `listAll` will keep pulling pages until
|
|
643
|
-
* the page is short.
|
|
644
|
-
* @example
|
|
645
|
-
* ```ts
|
|
646
|
-
* for await (const file of files.listAll({ prefix: "avatars/" })) {
|
|
647
|
-
* console.log(file.key, file.size);
|
|
648
|
-
* }
|
|
649
|
-
* ```
|
|
650
|
-
*/
|
|
651
|
-
listAll(options?: ListAllOptions & OperationOptions): AsyncGenerator<FileObject, void, void>;
|
|
652
|
-
url(key: string, options?: OperationOptions & SignedReadUrlOptions): Promise<string>;
|
|
653
|
-
signedUploadUrl(key: string, options?: OperationOptions & SignedUploadUrlOptions): Promise<string>;
|
|
654
|
-
}
|
|
655
|
-
export { SyncProgress as A, BulkDeleteResult as B, TransferProgress as C, DownloadOptions as D, UploadControlState as E, Files as F, UploadControlToken as G, HookActionType as H, UploadOptions as I, UploadProgress as J, UploadProgressCallback as K, ListAllOptions as L, MultipartOptions as M, SyncOptions as S, TransferOptions as T, UploadControl as U, SyncResult as a, TransferResult as b, BulkDownloadOptions as c, BulkDownloadResult as d, BulkError as e, BulkExistsResult as f, BulkHeadResult as g, BulkMoveItem as h, BulkMoveResult as i, BulkOptions as j, BulkUploadItem as k, BulkUploadOptions as l, BulkUploadResult as m, DownloadRange as n, DownloadResult as o, DownloadStreamResult as p, FileBody as q, FileObject as r, FilesHooks as s, FilesOptions as t, HookEvent as u, ListDirectoryResult as v, ListOptions as w, SignedReadUrlOptions as x, SignedUploadUrlOptions as y, StorageCapabilities as z };
|