bun-types 1.1.45 → 1.2.0-canary.20250123T140603

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
@@ -1300,33 +1300,7 @@ declare module "bun" {
1300
1300
  }
1301
1301
 
1302
1302
  var S3Client: S3Client;
1303
-
1304
- /**
1305
- * Creates a new S3File instance for working with a single file.
1306
- *
1307
- * @param path The path or key of the file
1308
- * @param options S3 configuration options
1309
- * @returns `S3File` instance for the specified path
1310
- *
1311
- * @example
1312
- * import { s3 } from "bun";
1313
- * const file = s3("my-file.txt", {
1314
- * bucket: "my-bucket",
1315
- * accessKeyId: "your-access-key",
1316
- * secretAccessKey: "your-secret-key"
1317
- * });
1318
- *
1319
- * // Read the file
1320
- * const content = await file.text();
1321
- *
1322
- * @example
1323
- * // Using s3:// protocol
1324
- * const file = s3("s3://my-bucket/my-file.txt", {
1325
- * accessKeyId: "your-access-key",
1326
- * secretAccessKey: "your-secret-key"
1327
- * });
1328
- */
1329
- function s3(path: string | URL, options?: S3Options): S3File;
1303
+ var s3: S3Client;
1330
1304
 
1331
1305
  /**
1332
1306
  * Configuration options for S3 operations
@@ -1494,6 +1468,28 @@ declare module "bun" {
1494
1468
  */
1495
1469
  type?: string;
1496
1470
 
1471
+ /**
1472
+ * By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects.
1473
+ *
1474
+ * @example
1475
+ * // Setting explicit Storage class
1476
+ * const file = s3("my-file.json", {
1477
+ * storageClass: "STANDARD_IA"
1478
+ * });
1479
+ */
1480
+ storageClass?:
1481
+ | "STANDARD"
1482
+ | "DEEP_ARCHIVE"
1483
+ | "EXPRESS_ONEZONE"
1484
+ | "GLACIER"
1485
+ | "GLACIER_IR"
1486
+ | "INTELLIGENT_TIERING"
1487
+ | "ONEZONE_IA"
1488
+ | "OUTPOSTS"
1489
+ | "REDUCED_REDUNDANCY"
1490
+ | "SNOW"
1491
+ | "STANDARD_IA";
1492
+
1497
1493
  /**
1498
1494
  * @deprecated The size of the internal buffer in bytes. Defaults to 5 MiB. use `partSize` and `queueSize` instead.
1499
1495
  */
@@ -1630,7 +1626,7 @@ declare module "bun" {
1630
1626
  *
1631
1627
  * // Write large chunks of data efficiently
1632
1628
  * for (const chunk of largeDataChunks) {
1633
- * await writer.write(chunk);
1629
+ * writer.write(chunk);
1634
1630
  * }
1635
1631
  * await writer.end();
1636
1632
  *
@@ -1638,7 +1634,7 @@ declare module "bun" {
1638
1634
  * // Error handling
1639
1635
  * const writer = file.writer();
1640
1636
  * try {
1641
- * await writer.write(data);
1637
+ * writer.write(data);
1642
1638
  * await writer.end();
1643
1639
  * } catch (err) {
1644
1640
  * console.error('Upload failed:', err);
@@ -2037,6 +2033,339 @@ declare module "bun" {
2037
2033
  */
2038
2034
  stat(path: string, options?: S3Options): Promise<S3Stats>;
2039
2035
  };
2036
+ /**
2037
+ * Configuration options for SQL client connection and behavior
2038
+ * @example
2039
+ * const config: SQLOptions = {
2040
+ * host: 'localhost',
2041
+ * port: 5432,
2042
+ * user: 'dbuser',
2043
+ * password: 'secretpass',
2044
+ * database: 'myapp',
2045
+ * idleTimeout: 30000,
2046
+ * max: 20,
2047
+ * onconnect: (client) => {
2048
+ * console.log('Connected to database');
2049
+ * }
2050
+ * };
2051
+ */
2052
+ type SQLOptions = {
2053
+ /** Connection URL (can be string or URL object) */
2054
+ url: URL | string;
2055
+ /** Database server hostname */
2056
+ host: string;
2057
+ /** Database server port number */
2058
+ port: number | string;
2059
+ /** Database user for authentication */
2060
+ username: string;
2061
+ /** Database password for authentication */
2062
+ password: string;
2063
+ /** Name of the database to connect to */
2064
+ database: string;
2065
+ /** Database adapter/driver to use */
2066
+ adapter: string;
2067
+ /** Maximum time in milliseconds to wait for connection to become available */
2068
+ idleTimeout: number;
2069
+ /** Maximum time in milliseconds to wait when establishing a connection */
2070
+ connectionTimeout: number;
2071
+ /** Maximum lifetime in milliseconds of a connection */
2072
+ maxLifetime: number;
2073
+ /** Whether to use TLS/SSL for the connection */
2074
+ tls: boolean;
2075
+ /** Callback function executed when a connection is established */
2076
+ onconnect: (client: SQL) => void;
2077
+ /** Callback function executed when a connection is closed */
2078
+ onclose: (client: SQL) => void;
2079
+ /** Maximum number of connections in the pool */
2080
+ max: number;
2081
+ /** By default values outside i32 range are returned as strings. If this is true, values outside i32 range are returned as BigInts. */
2082
+ bigint: boolean;
2083
+ };
2084
+
2085
+ /**
2086
+ * Represents a SQL query that can be executed, with additional control methods
2087
+ * Extends Promise to allow for async/await usage
2088
+ */
2089
+ interface SQLQuery extends Promise<any> {
2090
+ /** Indicates if the query is currently executing */
2091
+ active: boolean;
2092
+ /** Indicates if the query has been cancelled */
2093
+ cancelled: boolean;
2094
+ /** Cancels the executing query */
2095
+ cancel(): SQLQuery;
2096
+ /** Executes the query */
2097
+ execute(): SQLQuery;
2098
+ /** Returns the raw query result */
2099
+ raw(): SQLQuery;
2100
+ /** Returns only the values from the query result */
2101
+ values(): SQLQuery;
2102
+ }
2103
+
2104
+ /**
2105
+ * Callback function type for transaction contexts
2106
+ * @param sql Function to execute SQL queries within the transaction
2107
+ */
2108
+ type SQLTransactionContextCallback = (
2109
+ sql: TransactionSQL,
2110
+ ) => Promise<any> | Array<SQLQuery>;
2111
+ /**
2112
+ * Callback function type for savepoint contexts
2113
+ * @param sql Function to execute SQL queries within the savepoint
2114
+ */
2115
+ type SQLSavepointContextCallback = (
2116
+ sql: SavepointSQL,
2117
+ ) => Promise<any> | Array<SQLQuery>;
2118
+
2119
+ /**
2120
+ * Main SQL client interface providing connection and transaction management
2121
+ */
2122
+ interface SQL {
2123
+ /** Creates a new SQL client instance
2124
+ * @example
2125
+ * const sql = new SQL("postgres://localhost:5432/mydb");
2126
+ * const sql = new SQL(new URL("postgres://localhost:5432/mydb"));
2127
+ */
2128
+ new (connectionString: string | URL): SQL;
2129
+ /** Creates a new SQL client instance with options
2130
+ * @example
2131
+ * const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
2132
+ */
2133
+ new (connectionString: string | URL, options: SQLOptions): SQL;
2134
+ /** Creates a new SQL client instance with options
2135
+ * @example
2136
+ * const sql = new SQL({ url: "postgres://localhost:5432/mydb", idleTimeout: 1000 });
2137
+ */
2138
+ new (options?: SQLOptions): SQL;
2139
+ /** Executes a SQL query using template literals
2140
+ * @example
2141
+ * const [user] = await sql`select * from users where id = ${1}`;
2142
+ */
2143
+ (strings: string | TemplateStringsArray, ...values: any[]): SQLQuery;
2144
+ /**
2145
+ * Helper function to allow easy use to insert values into a query
2146
+ * @example
2147
+ * const result = await sql`insert into users ${sql(users)} RETURNING *`;
2148
+ */
2149
+ (obj: any): SQLQuery;
2150
+ /** Commits a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
2151
+ * @example
2152
+ * await sql.commitDistributed("my_distributed_transaction");
2153
+ */
2154
+ commitDistributed(name: string): Promise<undefined>;
2155
+ /** Rolls back a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
2156
+ * @example
2157
+ * await sql.rollbackDistributed("my_distributed_transaction");
2158
+ */
2159
+ rollbackDistributed(name: string): Promise<undefined>;
2160
+ /** Waits for the database connection to be established
2161
+ * @example
2162
+ * await sql.connect();
2163
+ */
2164
+ connect(): Promise<SQL>;
2165
+ /** Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
2166
+ * @example
2167
+ * await sql.close({ timeout: 1 });
2168
+ */
2169
+ close(options?: { timeout?: number }): Promise<undefined>;
2170
+ /** Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
2171
+ * @alias close
2172
+ * @example
2173
+ * await sql.end({ timeout: 1 });
2174
+ */
2175
+ end(options?: { timeout?: number }): Promise<undefined>;
2176
+ /** Flushes any pending operations */
2177
+ flush(): void;
2178
+ /** The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
2179
+ * This can be used for running queries on an isolated connection.
2180
+ * Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
2181
+ * @example
2182
+ * const reserved = await sql.reserve();
2183
+ * await reserved`select * from users`;
2184
+ * await reserved.release();
2185
+ * // with in a production scenario would be something more like
2186
+ * const reserved = await sql.reserve();
2187
+ * try {
2188
+ * // ... queries
2189
+ * } finally {
2190
+ * await reserved.release();
2191
+ * }
2192
+ * //To make it simpler bun supportsSymbol.dispose and Symbol.asyncDispose
2193
+ * {
2194
+ * // always release after context (safer)
2195
+ * using reserved = await sql.reserve()
2196
+ * await reserved`select * from users`
2197
+ * }
2198
+ */
2199
+ reserve(): Promise<ReservedSQL>;
2200
+ /** Begins a new transaction
2201
+ * Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.begin will resolve with the returned value from the callback function.
2202
+ * BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
2203
+ * @example
2204
+ * const [user, account] = await sql.begin(async sql => {
2205
+ * const [user] = await sql`
2206
+ * insert into users (
2207
+ * name
2208
+ * ) values (
2209
+ * 'Murray'
2210
+ * )
2211
+ * returning *
2212
+ * `
2213
+ * const [account] = await sql`
2214
+ * insert into accounts (
2215
+ * user_id
2216
+ * ) values (
2217
+ * ${ user.user_id }
2218
+ * )
2219
+ * returning *
2220
+ * `
2221
+ * return [user, account]
2222
+ * })
2223
+ */
2224
+ begin(fn: SQLTransactionContextCallback): Promise<any>;
2225
+ /** Begins a new transaction with options
2226
+ * Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.begin will resolve with the returned value from the callback function.
2227
+ * BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
2228
+ * @example
2229
+ * const [user, account] = await sql.begin("read write", async sql => {
2230
+ * const [user] = await sql`
2231
+ * insert into users (
2232
+ * name
2233
+ * ) values (
2234
+ * 'Murray'
2235
+ * )
2236
+ * returning *
2237
+ * `
2238
+ * const [account] = await sql`
2239
+ * insert into accounts (
2240
+ * user_id
2241
+ * ) values (
2242
+ * ${ user.user_id }
2243
+ * )
2244
+ * returning *
2245
+ * `
2246
+ * return [user, account]
2247
+ * })
2248
+ */
2249
+ begin(options: string, fn: SQLTransactionContextCallback): Promise<any>;
2250
+ /** Alternative method to begin a transaction
2251
+ * Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.transaction will resolve with the returned value from the callback function.
2252
+ * BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
2253
+ * @alias begin
2254
+ * @example
2255
+ * const [user, account] = await sql.transaction(async sql => {
2256
+ * const [user] = await sql`
2257
+ * insert into users (
2258
+ * name
2259
+ * ) values (
2260
+ * 'Murray'
2261
+ * )
2262
+ * returning *
2263
+ * `
2264
+ * const [account] = await sql`
2265
+ * insert into accounts (
2266
+ * user_id
2267
+ * ) values (
2268
+ * ${ user.user_id }
2269
+ * )
2270
+ * returning *
2271
+ * `
2272
+ * return [user, account]
2273
+ * })
2274
+ */
2275
+ transaction(fn: SQLTransactionContextCallback): Promise<any>;
2276
+ /** Alternative method to begin a transaction with options
2277
+ * Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.transaction will resolve with the returned value from the callback function.
2278
+ * BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
2279
+ * @alias begin
2280
+ * @example
2281
+ * const [user, account] = await sql.transaction("read write", async sql => {
2282
+ * const [user] = await sql`
2283
+ * insert into users (
2284
+ * name
2285
+ * ) values (
2286
+ * 'Murray'
2287
+ * )
2288
+ * returning *
2289
+ * `
2290
+ * const [account] = await sql`
2291
+ * insert into accounts (
2292
+ * user_id
2293
+ * ) values (
2294
+ * ${ user.user_id }
2295
+ * )
2296
+ * returning *
2297
+ * `
2298
+ * return [user, account]
2299
+ * })
2300
+ */
2301
+ transaction(
2302
+ options: string,
2303
+ fn: SQLTransactionContextCallback,
2304
+ ): Promise<any>;
2305
+ /** Begins a distributed transaction
2306
+ * Also know as Two-Phase Commit, in a distributed transaction, Phase 1 involves the coordinator preparing nodes by ensuring data is written and ready to commit, while Phase 2 finalizes with nodes committing or rolling back based on the coordinator's decision, ensuring durability and releasing locks.
2307
+ * In PostgreSQL and MySQL distributed transactions persist beyond the original session, allowing privileged users or coordinators to commit/rollback them, ensuring support for distributed transactions, recovery, and administrative tasks.
2308
+ * beginDistributed will automatic rollback if any exception are not caught, and you can commit and rollback later if everything goes well.
2309
+ * PostgreSQL natively supports distributed transactions using PREPARE TRANSACTION, while MySQL uses XA Transactions, and MSSQL also supports distributed/XA transactions. However, in MSSQL, distributed transactions are tied to the original session, the DTC coordinator, and the specific connection.
2310
+ * These transactions are automatically committed or rolled back following the same rules as regular transactions, with no option for manual intervention from other sessions, in MSSQL distributed transactions are used to coordinate transactions using Linked Servers.
2311
+ * @example
2312
+ * await sql.beginDistributed("numbers", async sql => {
2313
+ * await sql`create table if not exists numbers (a int)`;
2314
+ * await sql`insert into numbers values(1)`;
2315
+ * });
2316
+ * // later you can call
2317
+ * await sql.commitDistributed("numbers");
2318
+ * // or await sql.rollbackDistributed("numbers");
2319
+ */
2320
+ beginDistributed(
2321
+ name: string,
2322
+ fn: SQLTransactionContextCallback,
2323
+ ): Promise<any>;
2324
+ /** Alternative method to begin a distributed transaction
2325
+ * @alias beginDistributed
2326
+ */
2327
+ distributed(name: string, fn: SQLTransactionContextCallback): Promise<any>;
2328
+ /**If you know what you're doing, you can use unsafe to pass any string you'd like.
2329
+ * Please note that this can lead to SQL injection if you're not careful.
2330
+ * You can also nest sql.unsafe within a safe sql expression. This is useful if only part of your fraction has unsafe elements.
2331
+ * @example
2332
+ * const result = await sql.unsafe(`select ${danger} from users where id = ${dragons}`)
2333
+ */
2334
+ unsafe(string: string, values?: any[]): SQLQuery;
2335
+
2336
+ /** Current client options */
2337
+ options: SQLOptions;
2338
+
2339
+ [Symbol.asyncDispose](): Promise<any>;
2340
+ }
2341
+
2342
+ /**
2343
+ * Represents a reserved connection from the connection pool
2344
+ * Extends SQL with additional release functionality
2345
+ */
2346
+ interface ReservedSQL extends SQL {
2347
+ /** Releases the client back to the connection pool */
2348
+ release(): void;
2349
+ [Symbol.dispose](): void;
2350
+ }
2351
+
2352
+ /**
2353
+ * Represents a client within a transaction context
2354
+ * Extends SQL with savepoint functionality
2355
+ */
2356
+ interface TransactionSQL extends SQL {
2357
+ /** Creates a savepoint within the current transaction */
2358
+ savepoint(name: string, fn: SQLSavepointContextCallback): Promise<any>;
2359
+ savepoint(fn: SQLSavepointContextCallback): Promise<any>;
2360
+ }
2361
+ /**
2362
+ * Represents a savepoint within a transaction
2363
+ */
2364
+ interface SavepointSQL extends SQL {}
2365
+
2366
+ var sql: SQL;
2367
+ var postgres: SQL;
2368
+ var SQL: SQL;
2040
2369
 
2041
2370
  /**
2042
2371
  * This lets you use macros as regular imports
@@ -2357,7 +2686,8 @@ declare module "bun" {
2357
2686
  | "import-rule"
2358
2687
  | "url-token"
2359
2688
  | "internal"
2360
- | "entry-point";
2689
+ | "entry-point-run"
2690
+ | "entry-point-build";
2361
2691
 
2362
2692
  interface Import {
2363
2693
  path: string;
@@ -2493,31 +2823,6 @@ declare module "bun" {
2493
2823
  */
2494
2824
  footer?: string;
2495
2825
 
2496
- /**
2497
- * **Experimental**
2498
- *
2499
- * Bundle CSS files.
2500
- *
2501
- * This will be enabled by default in Bun v1.2.
2502
- *
2503
- * @default false (until Bunv 1.2)
2504
- */
2505
- experimentalCss?: boolean;
2506
-
2507
- /**
2508
- * **Experimental**
2509
- *
2510
- * Bundle JavaScript & CSS files from HTML files. JavaScript & CSS files
2511
- * from non-external <script> or <link> tags will be bundled.
2512
- *
2513
- * Underneath, this works similarly to HTMLRewriter.
2514
- *
2515
- * This will be enabled by default in Bun v1.2.
2516
- *
2517
- * @default false (until Bun v1.2)
2518
- */
2519
- html?: boolean;
2520
-
2521
2826
  /**
2522
2827
  * Drop function calls to matching property accesses.
2523
2828
  */
@@ -2526,9 +2831,7 @@ declare module "bun" {
2526
2831
  /**
2527
2832
  * When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
2528
2833
  * When set to `false`, the `success` property of the returned object will be `false` when a build failure happens.
2529
- *
2530
- * This defaults to `false` in Bun 1.1 and will change to `true` in Bun 1.2
2531
- * as most usage of `Bun.build` forgets to check for errors.
2834
+ * This defaults to `true`.
2532
2835
  */
2533
2836
  throw?: boolean;
2534
2837
  }
@@ -2773,7 +3076,7 @@ declare module "bun" {
2773
3076
  * @param {Object} config - Build configuration options
2774
3077
  * @returns {Promise<BuildOutput>} Promise that resolves to build output containing generated artifacts and build status
2775
3078
  * @throws {AggregateError} When build fails and config.throw is true (default in Bun 1.2+)
2776
- *
3079
+ *
2777
3080
  * @example Basic usage - Bundle a single entrypoint and check results
2778
3081
  ```ts
2779
3082
  const result = await Bun.build({
@@ -2786,7 +3089,7 @@ declare module "bun" {
2786
3089
  process.exit(1);
2787
3090
  }
2788
3091
  ```
2789
- *
3092
+ *
2790
3093
  * @example Set up multiple entrypoints with code splitting enabled
2791
3094
  ```ts
2792
3095
  await Bun.build({
@@ -2796,7 +3099,7 @@ declare module "bun" {
2796
3099
  sourcemap: "external"
2797
3100
  });
2798
3101
  ```
2799
- *
3102
+ *
2800
3103
  * @example Configure minification and optimization settings
2801
3104
  ```ts
2802
3105
  await Bun.build({
@@ -2875,7 +3178,6 @@ declare module "bun" {
2875
3178
  try {
2876
3179
  const result = await Bun.build({
2877
3180
  entrypoints: ['./src/index.tsx'],
2878
- throw: true
2879
3181
  });
2880
3182
  } catch (e) {
2881
3183
  const error = e as AggregateError;
@@ -2913,7 +3215,6 @@ declare module "bun" {
2913
3215
  './src/themes/light.css'
2914
3216
  ],
2915
3217
  outdir: './dist/css',
2916
- experimentalCss: true
2917
3218
  });
2918
3219
  ```
2919
3220
  @example Define compile-time constants and version information
package/docs/api/fetch.md CHANGED
@@ -195,7 +195,7 @@ This will print the request and response headers to your terminal:
195
195
  ```sh
196
196
  [fetch] > HTTP/1.1 GET http://example.com/
197
197
  [fetch] > Connection: keep-alive
198
- [fetch] > User-Agent: Bun/bun-v1.1.45
198
+ [fetch] > User-Agent: Bun/1.2.0-canary.20250123T140603
199
199
  [fetch] > Accept: */*
200
200
  [fetch] > Host: example.com
201
201
  [fetch] > Accept-Encoding: gzip, deflate, br
package/docs/api/s3.md CHANGED
@@ -68,7 +68,6 @@ const client = new S3Client({
68
68
  });
69
69
 
70
70
  // Bun.s3 is a global singleton that is equivalent to `new Bun.S3Client()`
71
- Bun.s3 = client;
72
71
  ```
73
72
 
74
73
  ### Working with S3 Files
@@ -172,11 +171,24 @@ When your production service needs to let users upload files to your server, it'
172
171
 
173
172
  To facilitate this, you can presign URLs for S3 files. This generates a URL with a signature that allows a user to securely upload that specific file to S3, without exposing your credentials or granting them unnecessary access to your bucket.
174
173
 
174
+ The default behaviour is to generate a `GET` URL that expires in 24 hours. Bun attempts to infer the content type from the file extension. If inference is not possible, it will default to `application/octet-stream`.
175
+
175
176
  ```ts
176
177
  import { s3 } from "bun";
177
178
 
178
179
  // Generate a presigned URL that expires in 24 hours (default)
179
- const url = s3.presign("my-file.txt", {
180
+ const download = s3.presign("my-file.txt"); // GET, text/plain, expires in 24 hours
181
+
182
+ const upload = s3.presign("my-file", {
183
+ expiresIn: 3600, // 1 hour
184
+ method: 'PUT',
185
+ type: 'application/json', // No extension for inferring, so we can specify the content type to be JSON
186
+ });
187
+
188
+ // You can call .presign() if on a file reference, but avoid doing so
189
+ // unless you already have a reference (to avoid memory usage).
190
+ const myFile = s3.file("my-file.txt");
191
+ const presignedFile = myFile.presign({
180
192
  expiresIn: 3600, // 1 hour
181
193
  });
182
194
  ```
@@ -375,7 +387,7 @@ If the `S3_*` environment variable is not set, Bun will also check for the `AWS_
375
387
 
376
388
  These environment variables are read from [`.env` files](/docs/runtime/env) or from the process environment at initialization time (`process.env` is not used for this).
377
389
 
378
- These defaults are overridden by the options you pass to `s3(credentials)`, `new Bun.S3Client(credentials)`, or any of the methods that accept credentials. So if, for example, you use the same credentials for different buckets, you can set the credentials once in your `.env` file and then pass `bucket: "my-bucket"` to the `s3()` helper function without having to specify all the credentials again.
390
+ These defaults are overridden by the options you pass to `s3.file(credentials)`, `new Bun.S3Client(credentials)`, or any of the methods that accept credentials. So if, for example, you use the same credentials for different buckets, you can set the credentials once in your `.env` file and then pass `bucket: "my-bucket"` to the `s3.file()` function without having to specify all the credentials again.
379
391
 
380
392
  ### `S3Client` objects
381
393
 
@@ -459,7 +471,7 @@ const exists = await client.exists("my-file.txt");
459
471
 
460
472
  ## `S3File`
461
473
 
462
- `S3File` instances are created by calling the `S3` instance method or the `s3()` helper function. Like `Bun.file()`, `S3File` instances are lazy. They don't refer to something that necessarily exists at the time of creation. That's why all the methods that don't involve network requests are fully synchronous.
474
+ `S3File` instances are created by calling the `S3Client` instance method or the `s3.file()` function. Like `Bun.file()`, `S3File` instances are lazy. They don't refer to something that necessarily exists at the time of creation. That's why all the methods that don't involve network requests are fully synchronous.
463
475
 
464
476
  ```ts
465
477
  interface S3File extends Blob {
@@ -482,7 +494,7 @@ interface S3File extends Blob {
482
494
  | Response
483
495
  | Request,
484
496
  options?: BlobPropertyBag,
485
- ): Promise<void>;
497
+ ): Promise<number>;
486
498
 
487
499
  exists(options?: S3Options): Promise<boolean>;
488
500
  unlink(options?: S3Options): Promise<void>;
@@ -600,7 +612,9 @@ const exists = await S3Client.exists("my-file.txt", credentials);
600
612
  The same method also works on `S3File` instances.
601
613
 
602
614
  ```ts
603
- const s3file = Bun.s3("my-file.txt", {
615
+ import { s3 } from "bun";
616
+
617
+ const s3file = s3.file("my-file.txt", {
604
618
  ...credentials,
605
619
  });
606
620
  const exists = await s3file.exists();
package/docs/api/spawn.md CHANGED
@@ -110,7 +110,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
110
110
  ```ts
111
111
  const proc = Bun.spawn(["bun", "--version"]);
112
112
  const text = await new Response(proc.stdout).text();
113
- console.log(text); // => "bun-v1.1.45"
113
+ console.log(text); // => "1.2.0-canary.20250123T140603"
114
114
  ```
115
115
 
116
116
  Configure the output stream by passing one of the following values to `stdout/stderr`: