lean-s3 0.8.10 → 0.8.12

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/dist/index.d.ts CHANGED
@@ -1,235 +1,286 @@
1
- import { Readable } from 'node:stream';
2
- import { Dispatcher } from 'undici';
1
+ import { Readable } from "node:stream";
2
+ import { Dispatcher } from "undici";
3
3
 
4
+ //#region src/S3BucketEntry.d.ts
4
5
  /**
5
6
  * @internal Normally, we'd use an interface for that, but having a class with pre-defined fields makes it easier for V8 top optimize hidden classes.
6
7
  */
7
8
  declare class S3BucketEntry {
8
- readonly key: string;
9
- readonly size: number;
10
- readonly lastModified: Date;
11
- readonly etag: string;
12
- readonly storageClass: StorageClass;
13
- readonly checksumAlgorithm: ChecksumAlgorithm | undefined;
14
- readonly checksumType: ChecksumType | undefined;
15
- constructor(key: string, size: number, lastModified: Date, etag: string, storageClass: StorageClass, checksumAlgorithm: ChecksumAlgorithm | undefined, checksumType: ChecksumType | undefined);
16
- /**
17
- * @internal
18
- */
19
- static parse(source: any): S3BucketEntry;
9
+ readonly key: string;
10
+ readonly size: number;
11
+ readonly lastModified: Date;
12
+ readonly etag: string;
13
+ readonly storageClass: StorageClass;
14
+ readonly checksumAlgorithm: ChecksumAlgorithm | undefined;
15
+ readonly checksumType: ChecksumType | undefined;
16
+ constructor(key: string, size: number, lastModified: Date, etag: string, storageClass: StorageClass, checksumAlgorithm: ChecksumAlgorithm | undefined, checksumType: ChecksumType | undefined);
17
+ /**
18
+ * @internal
19
+ */
20
+ static parse(source: any): S3BucketEntry;
20
21
  }
21
-
22
+ //#endregion
23
+ //#region src/branded.d.ts
22
24
  declare const __brand: unique symbol;
23
25
  type Brand<B> = {
24
- [__brand]: B;
26
+ [__brand]: B;
25
27
  };
26
28
  type Branded<T, B> = T & Brand<B>;
27
29
  type BucketName = Branded<string, "BucketName">;
28
30
  type ObjectKey = Branded<string, "ObjectKey">;
29
31
  type Endpoint = Branded<string, "Endpoint">;
30
32
  type Region = Branded<string, "Region">;
31
-
33
+ //#endregion
34
+ //#region src/S3Client.d.ts
32
35
  declare const kWrite: unique symbol;
33
36
  declare const kStream: unique symbol;
34
37
  declare const kSignedRequest: unique symbol;
35
38
  declare const kGetEffectiveParams: unique symbol;
36
39
  interface S3ClientOptions {
37
- /**
38
- * The name of the bucket to operate on.
39
- * Different S3 providers have different limitations here. All of them require:
40
- * - Must be at least 3 characters long
41
- * - Must be at most 63 characters long
42
- * - Must not start or end with a period (.)
43
- * - Must not contain two adjacent periods (..)
44
- * - Must only contain lowercase letters, numbers, periods (.), and hyphens (-).
45
- */
46
- bucket: string;
47
- /**
48
- * The region of the S3 bucket.
49
- * This value is required for all S3 proviers. However, some providers don't care about its actual value.
50
- */
51
- region: string;
52
- /**
53
- * The endpoint of the S3 service.
54
- * This is required for all S3 providers.
55
- *
56
- * The endpoint may contain placeholders for region and bucket, which will be replaced internally with the actual values on use.
57
- *
58
- * For example, `https://{bucket}.s3.{region}.example.com` will be replaced with `https://my-bucket.s3.us-west-2.example.com` if the bucket is `my-bucket` and the region is `us-west-2`.
59
- *
60
- * If the endpoint does not contain a placeholder for the bucket, it will be appended to the path of the endpoint.
61
- */
62
- endpoint: string;
63
- /**
64
- * The access key ID to use for authentication.
65
- * This is required for all S3 providers.
66
- */
67
- accessKeyId: string;
68
- /**
69
- * The secret access key to use for authentication.
70
- * This is required for all S3 providers.
71
- */
72
- secretAccessKey: string;
73
- sessionToken?: string;
40
+ /**
41
+ * The name of the bucket to operate on.
42
+ * Different S3 providers have different limitations here. All of them require:
43
+ * - Must be at least 3 characters long
44
+ * - Must be at most 63 characters long
45
+ * - Must not start or end with a period (.)
46
+ * - Must not contain two adjacent periods (..)
47
+ * - Must only contain lowercase letters, numbers, periods (.), and hyphens (-).
48
+ */
49
+ bucket: string;
50
+ /**
51
+ * The region of the S3 bucket.
52
+ * This value is required for all S3 proviers. However, some providers don't care about its actual value.
53
+ */
54
+ region: string;
55
+ /**
56
+ * The endpoint of the S3 service.
57
+ * This is required for all S3 providers.
58
+ *
59
+ * The endpoint may contain placeholders for region and bucket, which will be replaced internally with the actual values on use.
60
+ *
61
+ * For example, `https://{bucket}.s3.{region}.example.com` will be replaced with `https://my-bucket.s3.us-west-2.example.com` if the bucket is `my-bucket` and the region is `us-west-2`.
62
+ *
63
+ * If the endpoint does not contain a placeholder for the bucket, it will be appended to the path of the endpoint.
64
+ */
65
+ endpoint: string;
66
+ /**
67
+ * The access key ID to use for authentication.
68
+ * This is required for all S3 providers.
69
+ */
70
+ accessKeyId: string;
71
+ /**
72
+ * The secret access key to use for authentication.
73
+ * This is required for all S3 providers.
74
+ */
75
+ secretAccessKey: string;
76
+ sessionToken?: string;
74
77
  }
75
78
  type OverridableS3ClientOptions = Partial<Pick<S3ClientOptions, "region" | "bucket" | "endpoint">>;
76
79
  type CreateFileInstanceOptions = {
77
- /** Content-Type of the file. */
78
- type?: string;
80
+ /** Content-Type of the file. */
81
+ type?: string;
79
82
  };
80
83
  type DeleteObjectsOptions = {
81
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
82
- bucket?: string;
83
- /** Signal to abort the request. */
84
- signal?: AbortSignal;
84
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
85
+ bucket?: string;
86
+ /** Signal to abort the request. */
87
+ signal?: AbortSignal;
85
88
  };
86
89
  type DeleteObjectsResult = {
87
- errors: DeleteObjectsError[];
90
+ errors: DeleteObjectsError[];
88
91
  };
89
92
  type DeleteObjectsError = {
90
- code: string;
91
- key: string;
92
- message: string;
93
- versionId: string;
93
+ code: string;
94
+ key: string;
95
+ message: string;
96
+ versionId: string;
94
97
  };
95
98
  interface S3FilePresignOptions extends OverridableS3ClientOptions {
96
- contentHash?: Buffer;
97
- /** Seconds. */
98
- expiresIn?: number;
99
- method?: PresignableHttpMethod;
100
- contentLength?: number;
101
- storageClass?: StorageClass;
102
- acl?: Acl;
103
- /** `Content-Type` of the file. */
104
- type?: string;
105
- /**
106
- * Headers to set on the response of the S3 service.
99
+ contentHash?: Buffer;
100
+ /** Seconds. */
101
+ expiresIn?: number;
102
+ method?: PresignableHttpMethod;
103
+ contentLength?: number;
104
+ storageClass?: StorageClass;
105
+ acl?: Acl;
106
+ /** `Content-Type` of the file. */
107
+ type?: string;
108
+ /**
109
+ * Headers to set on the response of the S3 service.
110
+ */
111
+ response?: {
112
+ /**
113
+ * Used to set the file name that browsers display when downloading the file.
114
+ *
115
+ * @example
116
+ * ```js
117
+ * client.presign("foo.jpg", {
118
+ * response: {
119
+ * contentDisposition: {
120
+ * type: "attachment",
121
+ * filename: "download.jpg",
122
+ * },
123
+ * },
124
+ * });
125
+ * ```
107
126
  */
108
- response?: {
109
- /**
110
- * Used to set the file name that browsers display when downloading the file.
111
- *
112
- * @example
113
- * ```js
114
- * client.presign("foo.jpg", {
115
- * response: {
116
- * contentDisposition: {
117
- * type: "attachment",
118
- * filename: "download.jpg",
119
- * },
120
- * },
121
- * });
122
- * ```
123
- */
124
- contentDisposition?: ContentDisposition;
125
- };
127
+ contentDisposition?: ContentDisposition;
128
+ };
126
129
  }
127
130
  type CopyObjectOptions = {
128
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
129
- sourceBucket?: string;
130
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
131
- destinationBucket?: string;
132
- /** Signal to abort the request. */
133
- signal?: AbortSignal;
131
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
132
+ sourceBucket?: string;
133
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
134
+ destinationBucket?: string;
135
+ /** Signal to abort the request. */
136
+ signal?: AbortSignal;
134
137
  };
135
138
  type CopyObjectResult = {
136
- etag?: string;
137
- lastModified?: Date;
138
- checksumCRC32?: string;
139
- checksumCRC32C?: string;
140
- checksumSHA1?: string;
141
- checksumSHA256?: string;
139
+ etag?: string;
140
+ lastModified?: Date;
141
+ checksumCRC32?: string;
142
+ checksumCRC32C?: string;
143
+ checksumSHA1?: string;
144
+ checksumSHA256?: string;
142
145
  };
143
146
  type ListObjectsOptions = {
144
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
145
- bucket?: string;
146
- prefix?: string;
147
- maxKeys?: number;
148
- delimiter?: string;
149
- startAfter?: string;
150
- continuationToken?: string;
151
- /** Signal to abort the request. */
152
- signal?: AbortSignal;
147
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
148
+ bucket?: string;
149
+ prefix?: string;
150
+ maxKeys?: number;
151
+ delimiter?: string;
152
+ startAfter?: string;
153
+ continuationToken?: string;
154
+ /** Signal to abort the request. */
155
+ signal?: AbortSignal;
153
156
  };
154
157
  type ListObjectsIteratingOptions = {
155
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
156
- bucket?: string;
157
- prefix?: string;
158
- startAfter?: string;
159
- /** Signal to abort the request. */
160
- signal?: AbortSignal;
161
- internalPageSize?: number;
158
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
159
+ bucket?: string;
160
+ prefix?: string;
161
+ startAfter?: string;
162
+ /** Signal to abort the request. */
163
+ signal?: AbortSignal;
164
+ internalPageSize?: number;
162
165
  };
163
166
  type ListMultipartUploadsOptions = {
164
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
165
- bucket?: string;
166
- delimiter?: string;
167
- keyMarker?: string;
168
- maxUploads?: number;
169
- prefix?: string;
170
- uploadIdMarker?: string;
171
- /** Signal to abort the request. */
172
- signal?: AbortSignal;
167
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
168
+ bucket?: string;
169
+ delimiter?: string;
170
+ keyMarker?: string;
171
+ maxUploads?: number;
172
+ prefix?: string;
173
+ uploadIdMarker?: string;
174
+ /** Signal to abort the request. */
175
+ signal?: AbortSignal;
173
176
  };
174
177
  type ListMultipartUploadsResult = {
175
- /** Name of the bucket the operation was used upon. */
176
- bucket?: string;
177
- keyMarker?: string;
178
- uploadIdMarker?: string;
179
- nextKeyMarker?: string;
180
- prefix?: string;
181
- delimiter?: string;
182
- nextUploadIdMarker?: string;
183
- maxUploads?: number;
184
- isTruncated?: boolean;
185
- uploads: MultipartUpload[];
178
+ /** Name of the bucket the operation was used upon. */
179
+ bucket?: string;
180
+ keyMarker?: string;
181
+ uploadIdMarker?: string;
182
+ nextKeyMarker?: string;
183
+ prefix?: string;
184
+ delimiter?: string;
185
+ nextUploadIdMarker?: string;
186
+ maxUploads?: number;
187
+ isTruncated?: boolean;
188
+ uploads: MultipartUpload[];
186
189
  };
187
190
  type MultipartUpload = {
188
- checksumAlgorithm?: ChecksumAlgorithm;
189
- checksumType?: ChecksumType;
190
- initiated?: Date;
191
- /**
192
- * Key of the object for which the multipart upload was initiated.
193
- * Length Constraints: Minimum length of 1.
194
- */
195
- key?: string;
196
- storageClass?: StorageClass;
197
- /**
198
- * Upload ID identifying the multipart upload.
199
- */
200
- uploadId?: string;
191
+ checksumAlgorithm?: ChecksumAlgorithm;
192
+ checksumType?: ChecksumType;
193
+ initiated?: Date;
194
+ /**
195
+ * Key of the object for which the multipart upload was initiated.
196
+ * Length Constraints: Minimum length of 1.
197
+ */
198
+ key?: string;
199
+ storageClass?: StorageClass;
200
+ /**
201
+ * Upload ID identifying the multipart upload.
202
+ */
203
+ uploadId?: string;
201
204
  };
202
205
  type CreateMultipartUploadOptions = {
203
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
204
- bucket?: string;
205
- /** Signal to abort the request. */
206
- signal?: AbortSignal;
206
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
207
+ bucket?: string;
208
+ /** Signal to abort the request. */
209
+ signal?: AbortSignal;
207
210
  };
208
211
  type CreateMultipartUploadResult = {
209
- /** Name of the bucket the multipart upload was created in. */
210
- bucket: string;
211
- key: string;
212
- uploadId: string;
212
+ /** Name of the bucket the multipart upload was created in. */
213
+ bucket: string;
214
+ key: string;
215
+ uploadId: string;
213
216
  };
214
217
  type AbortMultipartUploadOptions = {
215
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
216
- bucket?: string;
217
- /** Signal to abort the request. */
218
- signal?: AbortSignal;
218
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
219
+ bucket?: string;
220
+ /** Signal to abort the request. */
221
+ signal?: AbortSignal;
219
222
  };
220
223
  type CompleteMultipartUploadOptions = {
221
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
222
- bucket?: string;
223
- /** Signal to abort the request. */
224
- signal?: AbortSignal;
224
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
225
+ bucket?: string;
226
+ /** Signal to abort the request. */
227
+ signal?: AbortSignal;
225
228
  };
226
229
  type CompleteMultipartUploadResult = {
227
- /** The URI that identifies the newly created object. */
228
- location?: string;
229
- /** Name of the bucket the multipart upload was created in. */
230
- bucket?: string;
231
- key?: string;
232
- etag?: string;
230
+ /** The URI that identifies the newly created object. */
231
+ location?: string;
232
+ /** Name of the bucket the multipart upload was created in. */
233
+ bucket?: string;
234
+ key?: string;
235
+ etag?: string;
236
+ /** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
237
+ checksumCRC32?: string;
238
+ /** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
239
+ checksumCRC32C?: string;
240
+ /** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
241
+ checksumCRC64NVME?: string;
242
+ /** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
243
+ checksumSHA1?: string;
244
+ /** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
245
+ checksumSHA256?: string;
246
+ /**
247
+ * The checksum type, which determines how part-level checksums are combined to create an object-level checksum for multipart objects.
248
+ * You can use this header as a data integrity check to verify that the checksum type that is received is the same checksum type that was specified during the `CreateMultipartUpload` request.
249
+ */
250
+ checksumType?: ChecksumType;
251
+ };
252
+ type MultipartUploadPart = {
253
+ partNumber: number;
254
+ etag: string;
255
+ };
256
+ type UploadPartOptions = {
257
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
258
+ bucket?: string;
259
+ /** Signal to abort the request. */
260
+ signal?: AbortSignal;
261
+ };
262
+ type UploadPartResult = {
263
+ partNumber: number;
264
+ etag: string;
265
+ };
266
+ type ListPartsOptions = {
267
+ maxParts?: number;
268
+ partNumberMarker?: string;
269
+ /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
270
+ bucket?: string;
271
+ /** Signal to abort the request. */
272
+ signal?: AbortSignal;
273
+ };
274
+ type ListPartsResult = {
275
+ /** Name of the bucket. */
276
+ bucket: string;
277
+ key: string;
278
+ uploadId: string;
279
+ partNumberMarker?: string;
280
+ nextPartNumberMarker?: string;
281
+ maxParts?: number;
282
+ isTruncated: boolean;
283
+ parts: Array<{
233
284
  /** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
234
285
  checksumCRC32?: string;
235
286
  /** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
@@ -240,127 +291,79 @@ type CompleteMultipartUploadResult = {
240
291
  checksumSHA1?: string;
241
292
  /** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
242
293
  checksumSHA256?: string;
243
- /**
244
- * The checksum type, which determines how part-level checksums are combined to create an object-level checksum for multipart objects.
245
- * You can use this header as a data integrity check to verify that the checksum type that is received is the same checksum type that was specified during the `CreateMultipartUpload` request.
246
- */
247
- checksumType?: ChecksumType;
248
- };
249
- type MultipartUploadPart = {
250
- partNumber: number;
251
294
  etag: string;
252
- };
253
- type UploadPartOptions = {
254
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
255
- bucket?: string;
256
- /** Signal to abort the request. */
257
- signal?: AbortSignal;
258
- };
259
- type UploadPartResult = {
295
+ lastModified: Date;
260
296
  partNumber: number;
261
- etag: string;
262
- };
263
- type ListPartsOptions = {
264
- maxParts?: number;
265
- partNumberMarker?: string;
266
- /** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
267
- bucket?: string;
268
- /** Signal to abort the request. */
269
- signal?: AbortSignal;
270
- };
271
- type ListPartsResult = {
272
- /** Name of the bucket. */
273
- bucket: string;
274
- key: string;
275
- uploadId: string;
276
- partNumberMarker?: string;
277
- nextPartNumberMarker?: string;
278
- maxParts?: number;
279
- isTruncated: boolean;
280
- parts: Array<{
281
- /** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
282
- checksumCRC32?: string;
283
- /** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
284
- checksumCRC32C?: string;
285
- /** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
286
- checksumCRC64NVME?: string;
287
- /** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
288
- checksumSHA1?: string;
289
- /** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
290
- checksumSHA256?: string;
291
- etag: string;
292
- lastModified: Date;
293
- partNumber: number;
294
- size: number;
295
- }>;
296
- storageClass?: StorageClass;
297
- checksumAlgorithm?: ChecksumAlgorithm;
298
- checksumType?: ChecksumType;
297
+ size: number;
298
+ }>;
299
+ storageClass?: StorageClass;
300
+ checksumAlgorithm?: ChecksumAlgorithm;
301
+ checksumType?: ChecksumType;
299
302
  };
300
303
  type ListObjectsResult = {
301
- name: string;
302
- prefix: string | undefined;
303
- startAfter: string | undefined;
304
- isTruncated: boolean;
305
- continuationToken: string | undefined;
306
- maxKeys: number;
307
- keyCount: number;
308
- nextContinuationToken: string | undefined;
309
- contents: readonly S3BucketEntry[];
304
+ name: string;
305
+ prefix: string | undefined;
306
+ startAfter: string | undefined;
307
+ isTruncated: boolean;
308
+ continuationToken: string | undefined;
309
+ maxKeys: number;
310
+ keyCount: number;
311
+ nextContinuationToken: string | undefined;
312
+ contents: readonly S3BucketEntry[];
310
313
  };
311
314
  type BucketCreationOptions = {
312
- /** Set this to override the {@link S3ClientOptions#endpoint} that was passed on creation of the {@link S3Client}. */
313
- endpoint?: string;
314
- /** Set this to override the {@link S3ClientOptions#region} that was passed on creation of the {@link S3Client}. */
315
- region?: string;
316
- locationConstraint?: string;
317
- location?: BucketLocationInfo;
318
- info?: BucketInfo;
319
- /** Signal to abort the request. */
320
- signal?: AbortSignal;
315
+ /** Set this to override the {@link S3ClientOptions#endpoint} that was passed on creation of the {@link S3Client}. */
316
+ endpoint?: string;
317
+ /** Set this to override the {@link S3ClientOptions#region} that was passed on creation of the {@link S3Client}. */
318
+ region?: string;
319
+ locationConstraint?: string;
320
+ location?: BucketLocationInfo;
321
+ info?: BucketInfo;
322
+ /** Signal to abort the request. */
323
+ signal?: AbortSignal;
321
324
  };
322
325
  type BucketDeletionOptions = {
323
- /** Signal to abort the request. */
324
- signal?: AbortSignal;
326
+ /** Signal to abort the request. */
327
+ signal?: AbortSignal;
325
328
  };
326
329
  type BucketExistsOptions = {
327
- /** Signal to abort the request. */
328
- signal?: AbortSignal;
330
+ /** Signal to abort the request. */
331
+ signal?: AbortSignal;
329
332
  };
330
333
  type BucketCorsRules = readonly BucketCorsRule[];
331
334
  type BucketCorsRule = {
332
- allowedMethods: readonly HttpMethod[];
333
- /** One or more origins you want customers to be able to access the bucket from. */
334
- allowedOrigins: readonly string[];
335
- /** Headers that are specified in the `Access-Control-Request-Headers` header. These headers are allowed in a preflight `OPTIONS` request. */
336
- allowedHeaders?: readonly string[];
337
- /** One or more headers in the response that you want customers to be able to access from their applications. */
338
- exposeHeaders?: readonly string[];
339
- /** Unique identifier for the rule. The value cannot be longer than 255 characters. */
340
- id?: string;
341
- /** The time in seconds that your browser is to cache the preflight response for the specified resource. */
342
- maxAgeSeconds?: number;
335
+ allowedMethods: readonly HttpMethod[];
336
+ /** One or more origins you want customers to be able to access the bucket from. */
337
+ allowedOrigins: readonly string[];
338
+ /** Headers that are specified in the `Access-Control-Request-Headers` header. These headers are allowed in a preflight `OPTIONS` request. */
339
+ allowedHeaders?: readonly string[];
340
+ /** One or more headers in the response that you want customers to be able to access from their applications. */
341
+ exposeHeaders?: readonly string[];
342
+ /** Unique identifier for the rule. The value cannot be longer than 255 characters. */
343
+ id?: string;
344
+ /** The time in seconds that your browser is to cache the preflight response for the specified resource. */
345
+ maxAgeSeconds?: number;
343
346
  };
344
347
  type PutBucketCorsOptions = {
345
- /** The CORS rules to set on the bucket. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
346
- bucket?: string;
347
- /** Signal to abort the request. */
348
- signal?: AbortSignal;
348
+ /** The CORS rules to set on the bucket. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
349
+ bucket?: string;
350
+ /** Signal to abort the request. */
351
+ signal?: AbortSignal;
349
352
  };
350
353
  type DeleteBucketCorsOptions = {
351
- /** The name of the bucket to delete the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
352
- bucket?: string;
353
- /** Signal to abort the request. */
354
- signal?: AbortSignal;
354
+ /** The name of the bucket to delete the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
355
+ bucket?: string;
356
+ /** Signal to abort the request. */
357
+ signal?: AbortSignal;
355
358
  };
356
359
  type GetBucketCorsOptions = {
357
- /** The name of the bucket to get the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
358
- bucket?: string;
359
- /** Signal to abort the request. */
360
- signal?: AbortSignal;
360
+ /** The name of the bucket to get the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
361
+ bucket?: string;
362
+ /** Signal to abort the request. */
363
+ signal?: AbortSignal;
361
364
  };
362
365
  type GetBucketCorsResult = {
363
- rules: BucketCorsRule[];
366
+ rules: BucketCorsRule[];
364
367
  };
365
368
  /**
366
369
  * A configured S3 bucket instance for managing files.
@@ -379,300 +382,309 @@ type GetBucketCorsResult = {
379
382
  * ```
380
383
  */
381
384
  declare class S3Client {
382
- #private;
383
- /**
384
- * Create a new instance of an S3 bucket so that credentials can be managed from a single instance instead of being passed to every method.
385
- *
386
- * @param options The default options to use for the S3 client.
387
- */
388
- constructor(options: S3ClientOptions);
389
- /** @internal */
390
- [kGetEffectiveParams](options: OverridableS3ClientOptions): [region: Region, endpoint: Endpoint, bucket: BucketName];
391
- /**
392
- * Creates an S3File instance for the given path.
393
- *
394
- * @param {string} path The path to the object in the bucket. Also known as [object key](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html).
395
- * We recommend not using the following characters in a key name because of significant special character handling, which isn't consistent across all applications (see [AWS docs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html)):
396
- * - Backslash (`\\`)
397
- * - Left brace (`{`)
398
- * - Non-printable ASCII characters (128–255 decimal characters)
399
- * - Caret or circumflex (`^`)
400
- * - Right brace (`}`)
401
- * - Percent character (`%`)
402
- * - Grave accent or backtick (`\``)
403
- * - Right bracket (`]`)
404
- * - Quotation mark (`"`)
405
- * - Greater than sign (`>`)
406
- * - Left bracket (`[`)
407
- * - Tilde (`~`)
408
- * - Less than sign (`<`)
409
- * - Pound sign (`#`)
410
- * - Vertical bar or pipe (`|`)
411
- *
412
- * lean-s3 does not enforce these restrictions.
413
- *
414
- * @example
415
- * ```js
416
- * const file = client.file("image.jpg");
417
- * await file.write(imageData);
418
- *
419
- * const configFile = client.file("config.json", {
420
- * type: "application/json",
421
- * });
422
- * ```
423
- */
424
- file(path: string, options?: CreateFileInstanceOptions): S3File;
425
- /**
426
- * Generate a presigned URL for temporary access to a file.
427
- * Useful for generating upload/download URLs without exposing credentials.
428
- * @returns The operation on {@link S3Client#presign.path} as a pre-signed URL.
429
- *
430
- * @example
431
- * ```js
432
- * const downloadUrl = client.presign("file.pdf", {
433
- * expiresIn: 3600 // 1 hour
434
- * });
435
- * ```
436
- *
437
- * @example
438
- * ```js
439
- * client.presign("foo.jpg", {
440
- * expiresIn: 3600 // 1 hour
441
- * response: {
442
- * contentDisposition: {
443
- * type: "attachment",
444
- * filename: "download.jpg",
445
- * },
446
- * },
447
- * });
448
- * ```
449
- */
450
- presign(path: string, options?: S3FilePresignOptions): string;
451
- /**
452
- * Copies an object from a source to a destination.
453
- * @remarks Uses [`CopyObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html).
454
- */
455
- copyObject(sourceKey: string, destinationKey: string, options?: CopyObjectOptions): Promise<CopyObjectResult>;
456
- createMultipartUpload(key: string, options?: CreateMultipartUploadOptions): Promise<CreateMultipartUploadResult>;
457
- /**
458
- * @remarks Uses [`ListMultipartUploads`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html).
459
- * @throws {RangeError} If `options.maxKeys` is not between `1` and `1000`.
460
- */
461
- listMultipartUploads(options?: ListMultipartUploadsOptions): Promise<ListMultipartUploadsResult>;
462
- /**
463
- * @remarks Uses [`AbortMultipartUpload`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html).
464
- * @throws {RangeError} If `key` is not at least 1 character long.
465
- * @throws {Error} If `uploadId` is not provided.
466
- */
467
- abortMultipartUpload(path: string, uploadId: string, options?: AbortMultipartUploadOptions): Promise<void>;
468
- /**
469
- * @remarks Uses [`CompleteMultipartUpload`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html).
470
- * @throws {RangeError} If `key` is not at least 1 character long.
471
- * @throws {Error} If `uploadId` is not provided.
472
- */
473
- completeMultipartUpload(path: string, uploadId: string, parts: readonly MultipartUploadPart[], options?: CompleteMultipartUploadOptions): Promise<CompleteMultipartUploadResult>;
474
- /**
475
- * @remarks Uses [`UploadPart`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html).
476
- * @throws {RangeError} If `key` is not at least 1 character long.
477
- * @throws {Error} If `uploadId` is not provided.
478
- */
479
- uploadPart(path: string, uploadId: string, data: string | Buffer | Uint8Array | Readable, partNumber: number, options?: UploadPartOptions): Promise<UploadPartResult>;
480
- /**
481
- * @remarks Uses [`ListParts`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html).
482
- * @throws {RangeError} If `key` is not at least 1 character long.
483
- * @throws {Error} If `uploadId` is not provided.
484
- * @throws {TypeError} If `options.maxParts` is not a `number`.
485
- * @throws {RangeError} If `options.maxParts` is <= 0.
486
- * @throws {TypeError} If `options.partNumberMarker` is not a `string`.
487
- */
488
- listParts(path: string, uploadId: string, options?: ListPartsOptions): Promise<ListPartsResult>;
489
- /**
490
- * Creates a new bucket on the S3 server.
491
- *
492
- * @param name The name of the bucket to create. AWS the name according to [some rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html). The most important ones are:
493
- * - Bucket names must be between `3` (min) and `63` (max) characters long.
494
- * - Bucket names can consist only of lowercase letters, numbers, periods (`.`), and hyphens (`-`).
495
- * - Bucket names must begin and end with a letter or number.
496
- * - Bucket names must not contain two adjacent periods.
497
- * - Bucket names must not be formatted as an IP address (for example, `192.168.5.4`).
498
- *
499
- * @throws {Error} If the bucket name is invalid.
500
- * @throws {S3Error} If the bucket could not be created, e.g. if it already exists.
501
- * @remarks Uses [`CreateBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html)
502
- */
503
- createBucket(name: string, options?: BucketCreationOptions): Promise<void>;
504
- /**
505
- * Deletes a bucket from the S3 server.
506
- * @param name The name of the bucket to delete. Same restrictions as in {@link S3Client#createBucket}.
507
- * @throws {Error} If the bucket name is invalid.
508
- * @throws {S3Error} If the bucket could not be deleted, e.g. if it is not empty.
509
- * @remarks Uses [`DeleteBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html).
510
- */
511
- deleteBucket(name: string, options?: BucketDeletionOptions): Promise<void>;
512
- /**
513
- * Checks if a bucket exists.
514
- * @param name The name of the bucket to delete. Same restrictions as in {@link S3Client#createBucket}.
515
- * @throws {Error} If the bucket name is invalid.
516
- * @remarks Uses [`HeadBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html).
517
- */
518
- bucketExists(name: string, options?: BucketExistsOptions): Promise<boolean>;
519
- /**
520
- * @remarks Uses [`PutBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html).
521
- */
522
- putBucketCors(rules: BucketCorsRules, options?: PutBucketCorsOptions): Promise<void>;
523
- /**
524
- * @remarks Uses [`GetBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketCors.html).
525
- */
526
- getBucketCors(options?: GetBucketCorsOptions): Promise<GetBucketCorsResult>;
527
- /**
528
- * @remarks Uses [`DeleteBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html).
529
- */
530
- deleteBucketCors(options?: DeleteBucketCorsOptions): Promise<void>;
531
- /**
532
- * Uses [`ListObjectsV2`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) to iterate over all keys. Pagination and continuation is handled internally.
533
- */
534
- listIterating(options: ListObjectsIteratingOptions): AsyncGenerator<S3BucketEntry>;
535
- /**
536
- * Implements [`ListObjectsV2`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) to iterate over all keys.
537
- *
538
- * @throws {RangeError} If `maxKeys` is not between `1` and `1000`.
539
- */
540
- list(options?: ListObjectsOptions): Promise<ListObjectsResult>;
541
- /**
542
- * Uses [`DeleteObjects`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html) to delete multiple objects in a single request.
543
- */
544
- deleteObjects(objects: readonly S3BucketEntry[] | readonly string[], options?: DeleteObjectsOptions): Promise<DeleteObjectsResult>;
545
- /**
546
- * Do not use this. This is an internal method.
547
- * TODO: Maybe move this into a separate free function?
548
- * @internal
549
- */
550
- [kSignedRequest](region: Region, endpoint: Endpoint, bucket: BucketName, method: HttpMethod, pathWithoutBucket: ObjectKey, query: string | undefined, body: string | Buffer | Uint8Array | Readable | undefined, additionalSignedHeaders: Record<string, string> | undefined, additionalUnsignedHeaders: Record<string, string> | undefined, contentHash: Buffer | undefined, signal: AbortSignal | undefined): Promise<Dispatcher.ResponseData<null>>;
551
- /** @internal */
552
- [kWrite](path: ObjectKey, data: string | Buffer | Uint8Array | Readable, contentType: string, contentLength: number | undefined, contentHash: Buffer | undefined, rageStart: number | undefined, rangeEndExclusive: number | undefined, signal?: AbortSignal | undefined): Promise<void>;
553
- /**
554
- * @internal
555
- */
556
- [kStream](path: ObjectKey, contentHash: Buffer | undefined, rageStart: number | undefined, rangeEndExclusive: number | undefined): ReadableStream<Uint8Array>;
385
+ #private;
386
+ /**
387
+ * Create a new instance of an S3 bucket so that credentials can be managed from a single instance instead of being passed to every method.
388
+ *
389
+ * @param options The default options to use for the S3 client.
390
+ */
391
+ constructor(options: S3ClientOptions);
392
+ /** @internal */
393
+ [kGetEffectiveParams](options: OverridableS3ClientOptions): [region: Region, endpoint: Endpoint, bucket: BucketName];
394
+ /**
395
+ * Creates an S3File instance for the given path.
396
+ *
397
+ * @param {string} path The path to the object in the bucket. Also known as [object key](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html).
398
+ * We recommend not using the following characters in a key name because of significant special character handling, which isn't consistent across all applications (see [AWS docs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html)):
399
+ * - Backslash (`\\`)
400
+ * - Left brace (`{`)
401
+ * - Non-printable ASCII characters (128–255 decimal characters)
402
+ * - Caret or circumflex (`^`)
403
+ * - Right brace (`}`)
404
+ * - Percent character (`%`)
405
+ * - Grave accent or backtick (`\``)
406
+ * - Right bracket (`]`)
407
+ * - Quotation mark (`"`)
408
+ * - Greater than sign (`>`)
409
+ * - Left bracket (`[`)
410
+ * - Tilde (`~`)
411
+ * - Less than sign (`<`)
412
+ * - Pound sign (`#`)
413
+ * - Vertical bar or pipe (`|`)
414
+ *
415
+ * lean-s3 does not enforce these restrictions.
416
+ *
417
+ * @example
418
+ * ```js
419
+ * const file = client.file("image.jpg");
420
+ * await file.write(imageData);
421
+ *
422
+ * const configFile = client.file("config.json", {
423
+ * type: "application/json",
424
+ * });
425
+ * ```
426
+ */
427
+ file(path: string, options?: CreateFileInstanceOptions): S3File;
428
+ /**
429
+ * Generate a presigned URL for temporary access to a file.
430
+ * Useful for generating upload/download URLs without exposing credentials.
431
+ * @returns The operation on {@link S3Client#presign.path} as a pre-signed URL.
432
+ *
433
+ * @example
434
+ * ```js
435
+ * const downloadUrl = client.presign("file.pdf", {
436
+ * expiresIn: 3600 // 1 hour
437
+ * });
438
+ * ```
439
+ *
440
+ * @example
441
+ * ```js
442
+ * client.presign("foo.jpg", {
443
+ * expiresIn: 3600 // 1 hour
444
+ * response: {
445
+ * contentDisposition: {
446
+ * type: "attachment",
447
+ * filename: "download.jpg",
448
+ * },
449
+ * },
450
+ * });
451
+ * ```
452
+ */
453
+ presign(path: string, options?: S3FilePresignOptions): string;
454
+ /**
455
+ * Copies an object from a source to a destination.
456
+ * @remarks Uses [`CopyObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html).
457
+ */
458
+ copyObject(sourceKey: string, destinationKey: string, options?: CopyObjectOptions): Promise<CopyObjectResult>;
459
+ createMultipartUpload(key: string, options?: CreateMultipartUploadOptions): Promise<CreateMultipartUploadResult>;
460
+ /**
461
+ * @remarks Uses [`ListMultipartUploads`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html).
462
+ * @throws {RangeError} If `options.maxKeys` is not between `1` and `1000`.
463
+ */
464
+ listMultipartUploads(options?: ListMultipartUploadsOptions): Promise<ListMultipartUploadsResult>;
465
+ /**
466
+ * @remarks Uses [`AbortMultipartUpload`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html).
467
+ * @throws {RangeError} If `key` is not at least 1 character long.
468
+ * @throws {Error} If `uploadId` is not provided.
469
+ */
470
+ abortMultipartUpload(path: string, uploadId: string, options?: AbortMultipartUploadOptions): Promise<void>;
471
+ /**
472
+ * @remarks Uses [`CompleteMultipartUpload`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html).
473
+ * @throws {RangeError} If `key` is not at least 1 character long.
474
+ * @throws {Error} If `uploadId` is not provided.
475
+ */
476
+ completeMultipartUpload(path: string, uploadId: string, parts: readonly MultipartUploadPart[], options?: CompleteMultipartUploadOptions): Promise<CompleteMultipartUploadResult>;
477
+ /**
478
+ * @remarks Uses [`UploadPart`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html).
479
+ * @throws {RangeError} If `key` is not at least 1 character long.
480
+ * @throws {Error} If `uploadId` is not provided.
481
+ */
482
+ uploadPart(path: string, uploadId: string, data: string | Buffer | Uint8Array | Readable, partNumber: number, options?: UploadPartOptions): Promise<UploadPartResult>;
483
+ /**
484
+ * @remarks Uses [`ListParts`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html).
485
+ * @throws {RangeError} If `key` is not at least 1 character long.
486
+ * @throws {Error} If `uploadId` is not provided.
487
+ * @throws {TypeError} If `options.maxParts` is not a `number`.
488
+ * @throws {RangeError} If `options.maxParts` is <= 0.
489
+ * @throws {TypeError} If `options.partNumberMarker` is not a `string`.
490
+ */
491
+ listParts(path: string, uploadId: string, options?: ListPartsOptions): Promise<ListPartsResult>;
492
+ /**
493
+ * Creates a new bucket on the S3 server.
494
+ *
495
+ * @param name The name of the bucket to create. AWS the name according to [some rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html). The most important ones are:
496
+ * - Bucket names must be between `3` (min) and `63` (max) characters long.
497
+ * - Bucket names can consist only of lowercase letters, numbers, periods (`.`), and hyphens (`-`).
498
+ * - Bucket names must begin and end with a letter or number.
499
+ * - Bucket names must not contain two adjacent periods.
500
+ * - Bucket names must not be formatted as an IP address (for example, `192.168.5.4`).
501
+ *
502
+ * @throws {Error} If the bucket name is invalid.
503
+ * @throws {S3Error} If the bucket could not be created, e.g. if it already exists.
504
+ * @remarks Uses [`CreateBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html)
505
+ */
506
+ createBucket(name: string, options?: BucketCreationOptions): Promise<void>;
507
+ /**
508
+ * Deletes a bucket from the S3 server.
509
+ * @param name The name of the bucket to delete. Same restrictions as in {@link S3Client#createBucket}.
510
+ * @throws {Error} If the bucket name is invalid.
511
+ * @throws {S3Error} If the bucket could not be deleted, e.g. if it is not empty.
512
+ * @remarks Uses [`DeleteBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html).
513
+ */
514
+ deleteBucket(name: string, options?: BucketDeletionOptions): Promise<void>;
515
+ /**
516
+ * Checks if a bucket exists.
517
+ * @param name The name of the bucket to delete. Same restrictions as in {@link S3Client#createBucket}.
518
+ * @throws {Error} If the bucket name is invalid.
519
+ * @remarks Uses [`HeadBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html).
520
+ */
521
+ bucketExists(name: string, options?: BucketExistsOptions): Promise<boolean>;
522
+ /**
523
+ * @remarks Uses [`PutBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html).
524
+ */
525
+ putBucketCors(rules: BucketCorsRules, options?: PutBucketCorsOptions): Promise<void>;
526
+ /**
527
+ * @remarks Uses [`GetBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketCors.html).
528
+ */
529
+ getBucketCors(options?: GetBucketCorsOptions): Promise<GetBucketCorsResult>;
530
+ /**
531
+ * @remarks Uses [`DeleteBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html).
532
+ */
533
+ deleteBucketCors(options?: DeleteBucketCorsOptions): Promise<void>;
534
+ /**
535
+ * Uses [`ListObjectsV2`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) to iterate over all keys. Pagination and continuation is handled internally.
536
+ */
537
+ listIterating(options: ListObjectsIteratingOptions): AsyncGenerator<S3BucketEntry>;
538
+ /**
539
+ * Implements [`ListObjectsV2`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) to iterate over all keys.
540
+ *
541
+ * @throws {RangeError} If `maxKeys` is not between `1` and `1000`.
542
+ */
543
+ list(options?: ListObjectsOptions): Promise<ListObjectsResult>;
544
+ /**
545
+ * Uses [`DeleteObjects`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html) to delete multiple objects in a single request.
546
+ */
547
+ deleteObjects(objects: readonly S3BucketEntry[] | readonly string[], options?: DeleteObjectsOptions): Promise<DeleteObjectsResult>;
548
+ /**
549
+ * Do not use this. This is an internal method.
550
+ * TODO: Maybe move this into a separate free function?
551
+ * @internal
552
+ */
553
+ [kSignedRequest](region: Region, endpoint: Endpoint, bucket: BucketName, method: HttpMethod, pathWithoutBucket: ObjectKey, query: string | undefined, body: string | Buffer | Uint8Array | Readable | undefined, additionalSignedHeaders: Record<string, string> | undefined, additionalUnsignedHeaders: Record<string, string> | undefined, contentHash: Buffer | undefined, signal: AbortSignal | undefined): Promise<Dispatcher.ResponseData<null>>;
554
+ /** @internal */
555
+ [kWrite](path: ObjectKey, data: string | Buffer | Uint8Array | Readable, contentType: string, contentLength: number | undefined, contentHash: Buffer | undefined, rageStart: number | undefined, rangeEndExclusive: number | undefined, signal?: AbortSignal | undefined): Promise<void>;
556
+ /**
557
+ * @internal
558
+ */
559
+ [kStream](path: ObjectKey, contentHash: Buffer | undefined, rageStart: number | undefined, rangeEndExclusive: number | undefined): ReadableStream<Uint8Array>;
557
560
  }
558
-
561
+ //#endregion
562
+ //#region src/S3Stat.d.ts
559
563
  declare class S3Stat {
560
- readonly etag: string;
561
- readonly lastModified: Date;
562
- readonly size: number;
563
- readonly type: string;
564
- constructor(etag: string, lastModified: Date, size: number, type: string);
565
- static tryParseFromHeaders(headers: Record<string, string | string[] | undefined>): S3Stat | undefined;
564
+ readonly etag: string;
565
+ readonly lastModified: Date;
566
+ readonly size: number;
567
+ readonly type: string;
568
+ constructor(etag: string, lastModified: Date, size: number, type: string);
569
+ static tryParseFromHeaders(headers: Record<string, string | string[] | undefined>): S3Stat | undefined;
566
570
  }
567
-
571
+ //#endregion
572
+ //#region src/S3File.d.ts
568
573
  declare class S3File {
569
- #private;
570
- /** @internal */
571
- constructor(client: S3Client, path: ObjectKey, start: number | undefined, end: number | undefined, contentType: string | undefined);
572
- /**
573
- * Creates and returns a new {@link S3File} containing a subset of this {@link S3File} data.
574
- * @param start The starting index.
575
- * @param end The ending index, exclusive.
576
- */
577
- slice(start?: number, end?: number): S3File;
578
- /**
579
- * Creates and returns a new {@link S3File} containing a subset of this {@link S3File} data.
580
- * @param start The starting index.
581
- * @param end The ending index, exclusive.
582
- * @param contentType The content-type for the new {@link S3File}.
583
- */
584
- slice(start?: number, end?: number, contentType?: string): S3File;
585
- /**
586
- * Get the stat of a file in the bucket. Uses `HEAD` request to check existence.
587
- *
588
- * @remarks Uses [`HeadObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html).
589
- * @throws {S3Error} If the file does not exist or the server has some other issues.
590
- * @throws {Error} If the server returns an invalid response.
591
- */
592
- stat(options?: S3StatOptions): Promise<S3Stat>;
593
- /**
594
- * Check if a file exists in the bucket. Uses `HEAD` request to check existence.
595
- *
596
- * @remarks Uses [`HeadObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html).
597
- */
598
- exists(options?: S3FileExistsOptions): Promise<boolean>;
599
- /**
600
- * Delete a file from the bucket.
601
- *
602
- * @remarks - Uses [`DeleteObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html).
603
- * - `versionId` not supported.
604
- *
605
- * @param {S3FileDeleteOptions} [options]
606
- *
607
- * @example
608
- * ```js
609
- * // Simple delete
610
- * await client.delete("old-file.txt");
611
- *
612
- * // With error handling
613
- * try {
614
- * await client.delete("file.dat");
615
- * console.log("File deleted");
616
- * } catch (err) {
617
- * console.error("Delete failed:", err);
618
- * }
619
- * ```
620
- */
621
- delete(options?: S3FileDeleteOptions): Promise<void>;
622
- toString(): string;
623
- json(): Promise<unknown>;
624
- bytes(): Promise<Uint8Array>;
625
- arrayBuffer(): Promise<ArrayBuffer>;
626
- text(): Promise<string>;
627
- blob(): Promise<Blob>;
628
- stream(): ReadableStream<Uint8Array>;
629
- /**
630
- * @param {ByteSource} data
631
- * @param {S3FileWriteOptions} [options.type] Defaults to the Content-Type that was used to create the {@link S3File} instance.
632
- * @returns {Promise<void>}
633
- */
634
- write(data: ByteSource, options?: S3FileWriteOptions): Promise<void>;
635
- /**
636
- * Copies this file to a new destination.
637
- * @param destination The destination path.
638
- * @param options Options for the copy operation.
639
- */
640
- copyTo(destination: string, options?: CopyObjectOptions): Promise<void>;
574
+ #private;
575
+ /** @internal */
576
+ constructor(client: S3Client, path: ObjectKey, start: number | undefined, end: number | undefined, contentType: string | undefined);
577
+ /**
578
+ * Creates and returns a new {@link S3File} containing a subset of this {@link S3File} data.
579
+ * @param start The starting index.
580
+ * @param end The ending index, exclusive.
581
+ */
582
+ slice(start?: number, end?: number): S3File;
583
+ /**
584
+ * Creates and returns a new {@link S3File} containing a subset of this {@link S3File} data.
585
+ * @param start The starting index.
586
+ * @param end The ending index, exclusive.
587
+ * @param contentType The content-type for the new {@link S3File}.
588
+ */
589
+ slice(start?: number, end?: number, contentType?: string): S3File;
590
+ /**
591
+ * Get the stat of a file in the bucket. Uses `HEAD` request to check existence.
592
+ *
593
+ * @remarks Uses [`HeadObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html).
594
+ * @throws {S3Error} If the file does not exist or the server has some other issues.
595
+ * @throws {Error} If the server returns an invalid response.
596
+ */
597
+ stat(options?: S3StatOptions): Promise<S3Stat>;
598
+ /**
599
+ * Check if a file exists in the bucket. Uses `HEAD` request to check existence.
600
+ *
601
+ * @remarks Uses [`HeadObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html).
602
+ */
603
+ exists(options?: S3FileExistsOptions): Promise<boolean>;
604
+ /**
605
+ * Delete a file from the bucket.
606
+ *
607
+ * @remarks - Uses [`DeleteObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html).
608
+ * - `versionId` not supported.
609
+ *
610
+ * @param {S3FileDeleteOptions} [options]
611
+ *
612
+ * @example
613
+ * ```js
614
+ * // Simple delete
615
+ * await client.delete("old-file.txt");
616
+ *
617
+ * // With error handling
618
+ * try {
619
+ * await client.delete("file.dat");
620
+ * console.log("File deleted");
621
+ * } catch (err) {
622
+ * console.error("Delete failed:", err);
623
+ * }
624
+ * ```
625
+ */
626
+ delete(options?: S3FileDeleteOptions): Promise<void>;
627
+ toString(): string;
628
+ json(): Promise<unknown>;
629
+ bytes(): Promise<Uint8Array>;
630
+ arrayBuffer(): Promise<ArrayBuffer>;
631
+ text(): Promise<string>;
632
+ blob(): Promise<Blob>;
633
+ stream(): ReadableStream<Uint8Array>;
634
+ /**
635
+ * @param {ByteSource} data
636
+ * @param {S3FileWriteOptions} [options.type] Defaults to the Content-Type that was used to create the {@link S3File} instance.
637
+ * @returns {Promise<void>}
638
+ */
639
+ write(data: ByteSource, options?: S3FileWriteOptions): Promise<void>;
640
+ /**
641
+ * Copies this file to a new destination.
642
+ * @param destination The destination path.
643
+ * @param options Options for the copy operation.
644
+ */
645
+ copyTo(destination: string, options?: CopyObjectOptions): Promise<void>;
641
646
  }
642
647
  interface S3FileDeleteOptions extends OverridableS3ClientOptions {
643
- /** Signal to abort the request. */
644
- signal?: AbortSignal;
648
+ /** Signal to abort the request. */
649
+ signal?: AbortSignal;
645
650
  }
646
651
  interface S3StatOptions extends OverridableS3ClientOptions {
647
- /** Signal to abort the request. */
648
- signal?: AbortSignal;
652
+ /** Signal to abort the request. */
653
+ signal?: AbortSignal;
649
654
  }
650
655
  interface S3FileExistsOptions extends OverridableS3ClientOptions {
651
- /** Signal to abort the request. */
652
- signal?: AbortSignal;
656
+ /** Signal to abort the request. */
657
+ signal?: AbortSignal;
653
658
  }
654
659
  type S3FileWriteOptions = {
655
- /** Content-Type of the file. */
656
- type?: string;
657
- /** Signal to abort the request. */
658
- signal?: AbortSignal;
660
+ /** Content-Type of the file. */
661
+ type?: string;
662
+ /** Signal to abort the request. */
663
+ signal?: AbortSignal;
659
664
  };
660
-
665
+ //#endregion
666
+ //#region src/S3Error.d.ts
661
667
  declare class S3Error extends Error {
662
- readonly code: string;
663
- readonly path: string;
664
- readonly message: string;
665
- readonly requestId: string | undefined;
666
- readonly hostId: string | undefined;
667
- constructor(code: string, path: string, { message, requestId, hostId, cause, }?: S3ErrorOptions);
668
+ readonly code: string;
669
+ readonly path: string;
670
+ readonly message: string;
671
+ readonly requestId: string | undefined;
672
+ readonly hostId: string | undefined;
673
+ constructor(code: string, path: string, {
674
+ message,
675
+ requestId,
676
+ hostId,
677
+ cause
678
+ }?: S3ErrorOptions);
668
679
  }
669
680
  type S3ErrorOptions = {
670
- message?: string | undefined;
671
- requestId?: string | undefined;
672
- hostId?: string | undefined;
673
- cause?: unknown;
681
+ message?: string | undefined;
682
+ requestId?: string | undefined;
683
+ hostId?: string | undefined;
684
+ cause?: unknown;
674
685
  };
675
-
686
+ //#endregion
687
+ //#region src/index.d.ts
676
688
  type Acl = "private" | "public-read" | "public-read-write" | "aws-exec-read" | "authenticated-read" | "bucket-owner-read" | "bucket-owner-full-control" | "log-delivery-write";
677
689
  type StorageClass = "STANDARD" | "DEEP_ARCHIVE" | "EXPRESS_ONEZONE" | "GLACIER" | "GLACIER_IR" | "INTELLIGENT_TIERING" | "ONEZONE_IA" | "OUTPOSTS" | "REDUCED_REDUNDANCY" | "SNOW" | "STANDARD_IA";
678
690
  type ChecksumAlgorithm = "CRC32" | "CRC32C" | "CRC64NVME" | "SHA1" | "SHA256";
@@ -684,26 +696,26 @@ type ByteSource = string | Buffer | Uint8Array | Readable | Blob;
684
696
  * Implements [LocationInfo](https://docs.aws.amazon.com/AmazonS3/latest/API/API_LocationInfo.html)
685
697
  */
686
698
  type BucketLocationInfo = {
687
- name?: string;
688
- type?: string;
699
+ name?: string;
700
+ type?: string;
689
701
  };
690
702
  /**
691
703
  * Implements [BucketInfo](https://docs.aws.amazon.com/AmazonS3/latest/API/API_BucketInfo.html)
692
704
  */
693
705
  type BucketInfo = {
694
- dataRedundancy?: string;
695
- type?: string;
706
+ dataRedundancy?: string;
707
+ type?: string;
696
708
  };
697
709
  /**
698
710
  * Represents valid values for the [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition) header.
699
711
  */
700
712
  type ContentDisposition = AttachmentContentDisposition | InlineContentDisposition;
701
713
  type InlineContentDisposition = {
702
- type: "inline";
714
+ type: "inline";
703
715
  };
704
716
  type AttachmentContentDisposition = {
705
- type: "attachment";
706
- filename?: string;
717
+ type: "attachment";
718
+ filename?: string;
707
719
  };
708
-
709
- export { type AbortMultipartUploadOptions, type Acl, type AttachmentContentDisposition, type BucketCorsRule, type BucketCorsRules, type BucketCreationOptions, type BucketDeletionOptions, type BucketExistsOptions, type BucketInfo, type BucketLocationInfo, type ByteSource, type ChecksumAlgorithm, type ChecksumType, type CompleteMultipartUploadOptions, type CompleteMultipartUploadResult, type ContentDisposition, type CreateFileInstanceOptions, type CreateMultipartUploadOptions, type CreateMultipartUploadResult, type DeleteBucketCorsOptions, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, type GetBucketCorsOptions, type GetBucketCorsResult, type HttpMethod, type InlineContentDisposition, type ListMultipartUploadsOptions, type ListMultipartUploadsResult, type ListObjectsIteratingOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListPartsResult, type MultipartUpload, type MultipartUploadPart, type OverridableS3ClientOptions, type PresignableHttpMethod, type PutBucketCorsOptions, S3BucketEntry, S3Client, type S3ClientOptions, S3Error, type S3ErrorOptions, S3File, type S3FileDeleteOptions, type S3FileExistsOptions, type S3FilePresignOptions, type S3FileWriteOptions, S3Stat, type S3StatOptions, type StorageClass, type UploadPartOptions, type UploadPartResult };
720
+ //#endregion
721
+ export { type AbortMultipartUploadOptions, Acl, AttachmentContentDisposition, type BucketCorsRule, type BucketCorsRules, type BucketCreationOptions, type BucketDeletionOptions, type BucketExistsOptions, BucketInfo, BucketLocationInfo, ByteSource, ChecksumAlgorithm, ChecksumType, type CompleteMultipartUploadOptions, type CompleteMultipartUploadResult, ContentDisposition, type CreateFileInstanceOptions, type CreateMultipartUploadOptions, type CreateMultipartUploadResult, type DeleteBucketCorsOptions, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, type GetBucketCorsOptions, type GetBucketCorsResult, HttpMethod, InlineContentDisposition, type ListMultipartUploadsOptions, type ListMultipartUploadsResult, type ListObjectsIteratingOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListPartsResult, type MultipartUpload, type MultipartUploadPart, type OverridableS3ClientOptions, PresignableHttpMethod, type PutBucketCorsOptions, S3BucketEntry, S3Client, type S3ClientOptions, S3Error, type S3ErrorOptions, S3File, type S3FileDeleteOptions, type S3FileExistsOptions, type S3FilePresignOptions, type S3FileWriteOptions, S3Stat, type S3StatOptions, StorageClass, type UploadPartOptions, type UploadPartResult };