bun-types 1.1.42-canary.20241228T140509 → 1.1.42-canary.20241229T140500

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/bun.d.ts CHANGED
@@ -539,7 +539,7 @@ declare module "bun" {
539
539
  */
540
540
  // tslint:disable-next-line:unified-signatures
541
541
  function write(
542
- destination: BunFile | Bun.PathLike,
542
+ destination: BunFile | S3File | Bun.PathLike,
543
543
  input: Blob | NodeJS.TypedArray | ArrayBufferLike | string | Bun.BlobPart[],
544
544
  options?: {
545
545
  /** If writing to a PathLike, set the permissions of the file. */
@@ -1234,6 +1234,243 @@ declare module "bun" {
1234
1234
  * For empty Blob, this always returns true.
1235
1235
  */
1236
1236
  exists(): Promise<boolean>;
1237
+
1238
+ /**
1239
+ * Write data to the file. This is equivalent to using {@link Bun.write} with a {@link BunFile}.
1240
+ * @param data - The data to write.
1241
+ * @param options - The options to use for the write.
1242
+ */
1243
+ write(
1244
+ data:
1245
+ | string
1246
+ | ArrayBufferView
1247
+ | ArrayBuffer
1248
+ | SharedArrayBuffer
1249
+ | Request
1250
+ | Response
1251
+ | BunFile,
1252
+ options?: { highWaterMark?: number },
1253
+ ): Promise<number>;
1254
+
1255
+ /**
1256
+ * Deletes the file.
1257
+ */
1258
+ unlink(): Promise<void>;
1259
+ }
1260
+
1261
+ interface S3FileOptions extends BlobPropertyBag {
1262
+ /**
1263
+ * The bucket to use for the S3 client. by default will use the `S3_BUCKET` and `AWS_BUCKET` environment variable, or deduce as first part of the path.
1264
+ */
1265
+ bucket?: string;
1266
+ /**
1267
+ * The region to use for the S3 client. By default, it will use the `S3_REGION` and `AWS_REGION` environment variable.
1268
+ */
1269
+ region?: string;
1270
+ /**
1271
+ * The access key ID to use for the S3 client. By default, it will use the `S3_ACCESS_KEY_ID` and `AWS_ACCESS_KEY_ID` environment variable.
1272
+ */
1273
+ accessKeyId?: string;
1274
+ /**
1275
+ * The secret access key to use for the S3 client. By default, it will use the `S3_SECRET_ACCESS_KEY and `AWS_SECRET_ACCESS_KEY` environment variable.
1276
+ */
1277
+ secretAccessKey?: string;
1278
+
1279
+ /**
1280
+ * The endpoint to use for the S3 client. Defaults to `https://s3.{region}.amazonaws.com`, it will also use the `S3_ENDPOINT` and `AWS_ENDPOINT` environment variable.
1281
+ */
1282
+ endpoint?: string;
1283
+
1284
+ /**
1285
+ * The size of each part in MiB. Minimum and Default is 5 MiB and maximum is 5120 MiB.
1286
+ */
1287
+ partSize?: number;
1288
+ /**
1289
+ * The number of parts to upload in parallel. Default is 5 and maximum is 255. This can speed up the upload of large files but will also use more memory.
1290
+ */
1291
+ queueSize?: number;
1292
+ /**
1293
+ * The number of times to retry the upload if it fails. Default is 3 and maximum is 255.
1294
+ */
1295
+ retry?: number;
1296
+
1297
+ /**
1298
+ * The Content-Type of the file. If not provided, it is automatically set based on the file extension when possible.
1299
+ */
1300
+ type?: string;
1301
+
1302
+ /**
1303
+ * @deprecated The size of the internal buffer in bytes. Defaults to 5 MiB. use `partSize` and `queueSize` instead.
1304
+ */
1305
+ highWaterMark?: number;
1306
+ }
1307
+
1308
+ interface S3FilePresignOptions extends S3FileOptions {
1309
+ /**
1310
+ * The number of seconds the presigned URL will be valid for. Defaults to 86400 (1 day).
1311
+ */
1312
+ expiresIn?: number;
1313
+ /**
1314
+ * The HTTP method to use for the presigned URL. Defaults to GET.
1315
+ */
1316
+ method?: string;
1317
+ }
1318
+
1319
+ interface S3File extends BunFile {
1320
+ /**
1321
+ * @param path - The path to the file. If bucket options is not provided or set in the path, it will be deduced from the path.
1322
+ * @param options - The options to use for the S3 client.
1323
+ */
1324
+ new (path: string | URL, options?: S3FileOptions): S3File;
1325
+ /**
1326
+ * The size of the file in bytes.
1327
+ */
1328
+ size: Promise<number>;
1329
+ /**
1330
+ * Offset any operation on the file starting at `begin` and ending at `end`. `end` is relative to 0
1331
+ *
1332
+ * Similar to [`TypedArray.subarray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray). Does not copy the file, open the file, or modify the file.
1333
+ *
1334
+ * It will use [`range`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range) to download only the bytes you need.
1335
+ *
1336
+ * @param begin - start offset in bytes
1337
+ * @param end - absolute offset in bytes (relative to 0)
1338
+ * @param contentType - MIME type for the new S3File
1339
+ */
1340
+ slice(begin?: number, end?: number, contentType?: string): S3File;
1341
+
1342
+ /** */
1343
+ /**
1344
+ * Offset any operation on the file starting at `begin`
1345
+ *
1346
+ * Similar to [`TypedArray.subarray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray). Does not copy the file, open the file, or modify the file.
1347
+ *
1348
+ * It will use [`range`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range) to download only the bytes you need.
1349
+ *
1350
+ * @param begin - start offset in bytes
1351
+ * @param contentType - MIME type for the new S3File
1352
+ */
1353
+ slice(begin?: number, contentType?: string): S3File;
1354
+
1355
+ /**
1356
+ * @param contentType - MIME type for the new S3File
1357
+ */
1358
+ slice(contentType?: string): S3File;
1359
+
1360
+ /**
1361
+ * Incremental writer to stream writes to S3, this is equivalent of using MultipartUpload and is suitable for large files.
1362
+ */
1363
+ writer(options?: S3FileOptions): FileSink;
1364
+
1365
+ /**
1366
+ * The readable stream of the file.
1367
+ */
1368
+ readonly readable: ReadableStream;
1369
+
1370
+ /**
1371
+ * Get a readable stream of the file.
1372
+ */
1373
+ stream(): ReadableStream;
1374
+
1375
+ /**
1376
+ * The name or path of the file, as specified in the constructor.
1377
+ */
1378
+ readonly name?: string;
1379
+
1380
+ /**
1381
+ * The bucket name of the file.
1382
+ */
1383
+ readonly bucket?: string;
1384
+
1385
+ /**
1386
+ * Does the file exist?
1387
+ * It will use [`head`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) to check if the file exists.
1388
+ */
1389
+ exists(): Promise<boolean>;
1390
+
1391
+ /**
1392
+ * Uploads the data to S3. This is equivalent of using {@link S3File.upload} with a {@link S3File}.
1393
+ * @param data - The data to write.
1394
+ * @param options - The options to use for the S3 client.
1395
+ */
1396
+ write(
1397
+ data:
1398
+ | string
1399
+ | ArrayBufferView
1400
+ | ArrayBuffer
1401
+ | SharedArrayBuffer
1402
+ | Request
1403
+ | Response
1404
+ | BunFile
1405
+ | S3File
1406
+ | Blob,
1407
+ options?: S3FileOptions,
1408
+ ): Promise<number>;
1409
+
1410
+ /**
1411
+ * Returns a presigned URL for the file.
1412
+ * @param options - The options to use for the presigned URL.
1413
+ */
1414
+ presign(options?: S3FilePresignOptions): string;
1415
+
1416
+ /**
1417
+ * Deletes the file from S3.
1418
+ */
1419
+ unlink(): Promise<void>;
1420
+ }
1421
+
1422
+ namespace S3File {
1423
+ /**
1424
+ * Uploads the data to S3.
1425
+ * @param data - The data to write.
1426
+ * @param options - The options to use for the S3 client.
1427
+ */
1428
+ function upload(
1429
+ path: string | S3File,
1430
+ data:
1431
+ | string
1432
+ | ArrayBufferView
1433
+ | ArrayBuffer
1434
+ | SharedArrayBuffer
1435
+ | Request
1436
+ | Response
1437
+ | BunFile
1438
+ | S3File,
1439
+ options?: S3FileOptions,
1440
+ ): Promise<number>;
1441
+
1442
+ /**
1443
+ * Returns a presigned URL for the file.
1444
+ * @param options - The options to use for the presigned URL.
1445
+ */
1446
+ function presign(
1447
+ path: string | S3File,
1448
+ options?: S3FilePresignOptions,
1449
+ ): string;
1450
+
1451
+ /**
1452
+ * Deletes the file from S3.
1453
+ */
1454
+ function unlink(
1455
+ path: string | S3File,
1456
+ options?: S3FileOptions,
1457
+ ): Promise<void>;
1458
+
1459
+ /**
1460
+ * The size of the file in bytes.
1461
+ */
1462
+ function size(
1463
+ path: string | S3File,
1464
+ options?: S3FileOptions,
1465
+ ): Promise<number>;
1466
+
1467
+ /**
1468
+ * The size of the file in bytes.
1469
+ */
1470
+ function exists(
1471
+ path: string | S3File,
1472
+ options?: S3FileOptions,
1473
+ ): Promise<boolean>;
1237
1474
  }
1238
1475
 
1239
1476
  /**
@@ -3129,7 +3366,7 @@ declare module "bun" {
3129
3366
  * "Hello, world!"
3130
3367
  * );
3131
3368
  * ```
3132
- * @param path The path to the file (lazily loaded)
3369
+ * @param path The path to the file (lazily loaded) if the path starts with `s3://` it will behave like {@link S3File}
3133
3370
  */
3134
3371
  // tslint:disable-next-line:unified-signatures
3135
3372
  function file(path: string | URL, options?: BlobPropertyBag): BunFile;
@@ -3155,7 +3392,7 @@ declare module "bun" {
3155
3392
  * console.log(file.type); // "application/json"
3156
3393
  * ```
3157
3394
  *
3158
- * @param path The path to the file as a byte buffer (the buffer is copied)
3395
+ * @param path The path to the file as a byte buffer (the buffer is copied) if the path starts with `s3://` it will behave like {@link S3File}
3159
3396
  */
3160
3397
  // tslint:disable-next-line:unified-signatures
3161
3398
  function file(
@@ -3180,6 +3417,17 @@ declare module "bun" {
3180
3417
  // tslint:disable-next-line:unified-signatures
3181
3418
  function file(fileDescriptor: number, options?: BlobPropertyBag): BunFile;
3182
3419
 
3420
+ /**
3421
+ * Lazily load/upload a file from S3.
3422
+ * @param path - The path to the file. If bucket options is not provided or set in the path, it will be deduced from the path.
3423
+ * @param options - The options to use for the S3 client.
3424
+ */
3425
+ function s3(path: string | URL, options?: S3FileOptions): S3File;
3426
+ /**
3427
+ * The S3 file class.
3428
+ */
3429
+ const S3: typeof S3File;
3430
+
3183
3431
  /**
3184
3432
  * Allocate a new [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) without zeroing the bytes.
3185
3433
  *
package/globals.d.ts CHANGED
@@ -137,6 +137,7 @@ type _Body = typeof globalThis extends { onerror: any }
137
137
  readonly text: () => Promise<string>;
138
138
  };
139
139
 
140
+ import { S3FileOptions } from "bun";
140
141
  import type {
141
142
  TextDecoder as NodeTextDecoder,
142
143
  TextEncoder as NodeTextEncoder,
@@ -896,6 +897,11 @@ declare global {
896
897
  rejectUnauthorized?: boolean | undefined; // Defaults to true
897
898
  checkServerIdentity?: any; // TODO: change `any` to `checkServerIdentity`
898
899
  };
900
+
901
+ /**
902
+ * Override the default S3 options
903
+ */
904
+ s3?: S3FileOptions;
899
905
  }
900
906
 
901
907
  /**
@@ -26,6 +26,8 @@ declare namespace HTMLRewriterTypes {
26
26
  readonly name: string | null;
27
27
  readonly publicId: string | null;
28
28
  readonly systemId: string | null;
29
+ readonly removed: boolean;
30
+ remove(): Doctype;
29
31
  }
30
32
 
31
33
  interface DocumentEnd {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.42-canary.20241228T140509",
2
+ "version": "1.1.42-canary.20241229T140500",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "main": "",