bun-types 1.2.13-canary.20250506T140621 → 1.2.13-canary.20250508T140628

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
@@ -991,11 +991,9 @@ declare module "bun" {
991
991
  function fileURLToPath(url: URL | string): string;
992
992
 
993
993
  /**
994
- * Fast incremental writer that becomes an `ArrayBuffer` on end().
994
+ * Fast incremental writer that becomes an {@link ArrayBuffer} on end().
995
995
  */
996
996
  class ArrayBufferSink {
997
- constructor();
998
-
999
997
  start(options?: {
1000
998
  asUint8Array?: boolean;
1001
999
  /**
@@ -1320,7 +1318,8 @@ declare module "bun" {
1320
1318
  * }
1321
1319
  * };
1322
1320
  */
1323
- type SQLOptions = {
1321
+
1322
+ interface SQLOptions {
1324
1323
  /** Connection URL (can be string or URL object) */
1325
1324
  url?: URL | string;
1326
1325
  /** Database server hostname */
@@ -1369,27 +1368,33 @@ declare module "bun" {
1369
1368
  bigint?: boolean;
1370
1369
  /** Automatic creation of prepared statements, defaults to true */
1371
1370
  prepare?: boolean;
1372
- };
1371
+ }
1373
1372
 
1374
1373
  /**
1375
1374
  * Represents a SQL query that can be executed, with additional control methods
1376
1375
  * Extends Promise to allow for async/await usage
1377
1376
  */
1378
- interface SQLQuery extends Promise<any> {
1377
+ interface SQLQuery<T = any> extends Promise<T> {
1379
1378
  /** Indicates if the query is currently executing */
1380
1379
  active: boolean;
1380
+
1381
1381
  /** Indicates if the query has been cancelled */
1382
1382
  cancelled: boolean;
1383
+
1383
1384
  /** Cancels the executing query */
1384
- cancel(): SQLQuery;
1385
+ cancel(): SQLQuery<T>;
1386
+
1385
1387
  /** Execute as a simple query, no parameters are allowed but can execute multiple commands separated by semicolons */
1386
- simple(): SQLQuery;
1388
+ simple(): SQLQuery<T>;
1389
+
1387
1390
  /** Executes the query */
1388
- execute(): SQLQuery;
1391
+ execute(): SQLQuery<T>;
1392
+
1389
1393
  /** Returns the raw query result */
1390
- raw(): SQLQuery;
1394
+ raw(): SQLQuery<T>;
1395
+
1391
1396
  /** Returns only the values from the query result */
1392
- values(): SQLQuery;
1397
+ values(): SQLQuery<T>;
1393
1398
  }
1394
1399
 
1395
1400
  /**
@@ -1407,65 +1412,117 @@ declare module "bun" {
1407
1412
  * Main SQL client interface providing connection and transaction management
1408
1413
  */
1409
1414
  interface SQL {
1410
- /** Creates a new SQL client instance
1411
- * @example
1412
- * const sql = new SQL("postgres://localhost:5432/mydb");
1413
- * const sql = new SQL(new URL("postgres://localhost:5432/mydb"));
1414
- */
1415
- new (connectionString: string | URL): SQL;
1416
- /** Creates a new SQL client instance with options
1417
- * @example
1418
- * const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
1419
- */
1420
- new (connectionString: string | URL, options: SQLOptions): SQL;
1421
- /** Creates a new SQL client instance with options
1422
- * @example
1423
- * const sql = new SQL({ url: "postgres://localhost:5432/mydb", idleTimeout: 1000 });
1424
- */
1425
- new (options?: SQLOptions): SQL;
1426
- /** Executes a SQL query using template literals
1415
+ /**
1416
+ * Executes a SQL query using template literals
1427
1417
  * @example
1418
+ * ```ts
1428
1419
  * const [user] = await sql`select * from users where id = ${1}`;
1420
+ * ```
1429
1421
  */
1430
- (strings: string | TemplateStringsArray, ...values: any[]): SQLQuery;
1422
+ (strings: string[] | TemplateStringsArray, ...values: any[]): SQLQuery;
1423
+
1431
1424
  /**
1432
- * Helper function to allow easy use to insert values into a query
1425
+ * Helper function for inserting an object into a query
1426
+ *
1433
1427
  * @example
1428
+ * ```ts
1429
+ * // Insert an object
1434
1430
  * const result = await sql`insert into users ${sql(users)} RETURNING *`;
1431
+ *
1432
+ * // Or pick specific columns
1433
+ * const result = await sql`insert into users ${sql(users, "id", "name")} RETURNING *`;
1434
+ *
1435
+ * // Or a single object
1436
+ * const result = await sql`insert into users ${sql(user)} RETURNING *`;
1437
+ * ```
1435
1438
  */
1436
- (obj: any): SQLQuery;
1437
- /** Commits a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
1439
+ <T extends { [Key in PropertyKey]: unknown }>(obj: T | T[] | readonly T[], ...columns: (keyof T)[]): SQLQuery;
1440
+
1441
+ /**
1442
+ * Helper function for inserting any serializable value into a query
1443
+ *
1438
1444
  * @example
1445
+ * ```ts
1446
+ * const result = await sql`SELECT * FROM users WHERE id IN ${sql([1, 2, 3])}`;
1447
+ * ```
1448
+ */
1449
+ (obj: unknown): SQLQuery;
1450
+
1451
+ /**
1452
+ * Commits a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
1453
+ *
1454
+ * @param name - The name of the distributed transaction
1455
+ *
1456
+ * @example
1457
+ * ```ts
1439
1458
  * await sql.commitDistributed("my_distributed_transaction");
1459
+ * ```
1440
1460
  */
1441
1461
  commitDistributed(name: string): Promise<void>;
1442
- /** Rolls back a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
1462
+
1463
+ /**
1464
+ * Rolls back a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
1465
+ *
1466
+ * @param name - The name of the distributed transaction
1467
+ *
1443
1468
  * @example
1469
+ * ```ts
1444
1470
  * await sql.rollbackDistributed("my_distributed_transaction");
1471
+ * ```
1445
1472
  */
1446
1473
  rollbackDistributed(name: string): Promise<void>;
1474
+
1447
1475
  /** Waits for the database connection to be established
1476
+ *
1448
1477
  * @example
1478
+ * ```ts
1449
1479
  * await sql.connect();
1480
+ * ```
1450
1481
  */
1451
1482
  connect(): Promise<SQL>;
1452
- /** 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.
1483
+
1484
+ /**
1485
+ * 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.
1486
+ *
1487
+ * @param options - The options for the close
1488
+ *
1453
1489
  * @example
1490
+ * ```ts
1454
1491
  * await sql.close({ timeout: 1 });
1492
+ * ```
1455
1493
  */
1456
1494
  close(options?: { timeout?: number }): Promise<void>;
1457
- /** 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.
1458
- * @alias close
1495
+
1496
+ /**
1497
+ * 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.
1498
+ * This is an alias of {@link SQL.close}
1499
+ *
1500
+ * @param options - The options for the close
1501
+ *
1459
1502
  * @example
1503
+ * ```ts
1460
1504
  * await sql.end({ timeout: 1 });
1505
+ * ```
1461
1506
  */
1462
1507
  end(options?: { timeout?: number }): Promise<void>;
1463
- /** Flushes any pending operations */
1508
+
1509
+ /**
1510
+ * Flushes any pending operations
1511
+ *
1512
+ * @example
1513
+ * ```ts
1514
+ * sql.flush();
1515
+ * ```
1516
+ */
1464
1517
  flush(): void;
1465
- /** The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
1466
- * This can be used for running queries on an isolated connection.
1467
- * Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
1518
+
1519
+ /**
1520
+ * The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
1521
+ * This can be used for running queries on an isolated connection.
1522
+ * Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
1523
+ *
1468
1524
  * @example
1525
+ * ```ts
1469
1526
  * const reserved = await sql.reserve();
1470
1527
  * await reserved`select * from users`;
1471
1528
  * await reserved.release();
@@ -1476,12 +1533,14 @@ declare module "bun" {
1476
1533
  * } finally {
1477
1534
  * await reserved.release();
1478
1535
  * }
1479
- * //To make it simpler bun supportsSymbol.dispose and Symbol.asyncDispose
1536
+ *
1537
+ * // Bun supports Symbol.dispose and Symbol.asyncDispose
1480
1538
  * {
1481
- * // always release after context (safer)
1482
- * using reserved = await sql.reserve()
1483
- * await reserved`select * from users`
1539
+ * // always release after context (safer)
1540
+ * using reserved = await sql.reserve()
1541
+ * await reserved`select * from users`
1484
1542
  * }
1543
+ * ```
1485
1544
  */
1486
1545
  reserve(): Promise<ReservedSQL>;
1487
1546
  /** Begins a new transaction
@@ -1626,6 +1685,45 @@ declare module "bun" {
1626
1685
 
1627
1686
  [Symbol.asyncDispose](): Promise<any>;
1628
1687
  }
1688
+ const SQL: {
1689
+ /**
1690
+ * Creates a new SQL client instance
1691
+ *
1692
+ * @param connectionString - The connection string for the SQL client
1693
+ *
1694
+ * @example
1695
+ * ```ts
1696
+ * const sql = new SQL("postgres://localhost:5432/mydb");
1697
+ * const sql = new SQL(new URL("postgres://localhost:5432/mydb"));
1698
+ * ```
1699
+ */
1700
+ new (connectionString: string | URL): SQL;
1701
+
1702
+ /**
1703
+ * Creates a new SQL client instance with options
1704
+ *
1705
+ * @param connectionString - The connection string for the SQL client
1706
+ * @param options - The options for the SQL client
1707
+ *
1708
+ * @example
1709
+ * ```ts
1710
+ * const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
1711
+ * ```
1712
+ */
1713
+ new (connectionString: string | URL, options: Omit<SQLOptions, "url">): SQL;
1714
+
1715
+ /**
1716
+ * Creates a new SQL client instance with options
1717
+ *
1718
+ * @param options - The options for the SQL client
1719
+ *
1720
+ * @example
1721
+ * ```ts
1722
+ * const sql = new SQL({ url: "postgres://localhost:5432/mydb", idleTimeout: 1000 });
1723
+ * ```
1724
+ */
1725
+ new (options?: SQLOptions): SQL;
1726
+ };
1629
1727
 
1630
1728
  /**
1631
1729
  * Represents a reserved connection from the connection pool
@@ -1697,21 +1795,14 @@ declare module "bun" {
1697
1795
  *
1698
1796
  * @category Database
1699
1797
  */
1700
- var sql: SQL;
1798
+ const sql: SQL;
1701
1799
 
1702
1800
  /**
1703
1801
  * SQL client for PostgreSQL
1704
1802
  *
1705
1803
  * @category Database
1706
1804
  */
1707
- var postgres: SQL;
1708
-
1709
- /**
1710
- * The SQL constructor
1711
- *
1712
- * @category Database
1713
- */
1714
- var SQL: SQL;
1805
+ const postgres: SQL;
1715
1806
 
1716
1807
  /**
1717
1808
  * Generate and verify CSRF tokens
@@ -6522,9 +6613,10 @@ declare module "bun" {
6522
6613
  ipc?(
6523
6614
  message: any,
6524
6615
  /**
6525
- * The {@link Subprocess} that sent the message
6616
+ * The {@link Subprocess} that received the message
6526
6617
  */
6527
6618
  subprocess: Subprocess<In, Out, Err>,
6619
+ handle?: unknown,
6528
6620
  ): void;
6529
6621
 
6530
6622
  /**
package/docs/api/fetch.md CHANGED
@@ -337,7 +337,7 @@ This will print the request and response headers to your terminal:
337
337
  ```sh
338
338
  [fetch] > HTTP/1.1 GET http://example.com/
339
339
  [fetch] > Connection: keep-alive
340
- [fetch] > User-Agent: Bun/1.2.13-canary.20250506T140621
340
+ [fetch] > User-Agent: Bun/1.2.13-canary.20250508T140628
341
341
  [fetch] > Accept: */*
342
342
  [fetch] > Host: example.com
343
343
  [fetch] > Accept-Encoding: gzip, deflate, br
package/docs/api/spawn.md CHANGED
@@ -120,7 +120,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
120
120
  ```ts
121
121
  const proc = Bun.spawn(["bun", "--version"]);
122
122
  const text = await new Response(proc.stdout).text();
123
- console.log(text); // => "1.2.13-canary.20250506T140621"
123
+ console.log(text); // => "1.2.13-canary.20250508T140628"
124
124
  ```
125
125
 
126
126
  Configure the output stream by passing one of the following values to `stdout/stderr`:
@@ -7,7 +7,7 @@ Use `bun publish` to publish a package to the npm registry.
7
7
  $ bun publish
8
8
 
9
9
  ## Output
10
- bun publish v1.2.13-canary.20250506T140621 (ca7428e9)
10
+ bun publish v1.2.13-canary.20250508T140628 (ca7428e9)
11
11
 
12
12
  packed 203B package.json
13
13
  packed 224B README.md
@@ -9,7 +9,7 @@ $ bunx nuxi init my-nuxt-app
9
9
  ✔ Which package manager would you like to use?
10
10
  bun
11
11
  ◐ Installing dependencies...
12
- bun install v1.2.13-canary.20250506T140621 (16b4bf34)
12
+ bun install v1.2.13-canary.20250508T140628 (16b4bf34)
13
13
  + @nuxt/devtools@0.8.2
14
14
  + nuxt@3.7.0
15
15
  785 packages installed [2.67s]
@@ -16,7 +16,7 @@ This will add the package to `peerDependencies` in `package.json`.
16
16
  ```json-diff
17
17
  {
18
18
  "peerDependencies": {
19
- + "@types/bun": "^1.2.13-canary.20250506T140621"
19
+ + "@types/bun": "^1.2.13-canary.20250508T140628"
20
20
  }
21
21
  }
22
22
  ```
@@ -28,7 +28,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
28
28
  ```json-diff
29
29
  {
30
30
  "peerDependencies": {
31
- "@types/bun": "^1.2.13-canary.20250506T140621"
31
+ "@types/bun": "^1.2.13-canary.20250508T140628"
32
32
  },
33
33
  "peerDependenciesMeta": {
34
34
  + "@types/bun": {
@@ -97,7 +97,7 @@ $ bun update
97
97
  $ bun update @types/bun --latest
98
98
 
99
99
  # Update a dependency to a specific version
100
- $ bun update @types/bun@1.2.13-canary.20250506T140621
100
+ $ bun update @types/bun@1.2.13-canary.20250508T140628
101
101
 
102
102
  # Update all dependencies to the latest versions
103
103
  $ bun update --latest
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
21
21
 
22
22
  ```sh
23
23
  $ bun test
24
- bun test v1.2.13-canary.20250506T140621 (9c68abdb)
24
+ bun test v1.2.13-canary.20250508T140628 (9c68abdb)
25
25
 
26
26
  test.test.js:
27
27
  ✓ add [0.87ms]
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
47
47
 
48
48
  ```sh
49
49
  $ bun test test3
50
- bun test v1.2.13-canary.20250506T140621 (9c68abdb)
50
+ bun test v1.2.13-canary.20250508T140628 (9c68abdb)
51
51
 
52
52
  test3.test.js:
53
53
  ✓ add [1.40ms]
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
85
85
 
86
86
  ```sh
87
87
  $ bun test -t add
88
- bun test v1.2.13-canary.20250506T140621 (9c68abdb)
88
+ bun test v1.2.13-canary.20250508T140628 (9c68abdb)
89
89
 
90
90
  test.test.js:
91
91
  ✓ add [1.79ms]
@@ -18,7 +18,7 @@ The first time this test is executed, Bun will evaluate the value passed into `e
18
18
 
19
19
  ```sh
20
20
  $ bun test test/snap
21
- bun test v1.2.13-canary.20250506T140621 (9c68abdb)
21
+ bun test v1.2.13-canary.20250508T140628 (9c68abdb)
22
22
 
23
23
  test/snap.test.ts:
24
24
  ✓ snapshot [1.48ms]
@@ -61,7 +61,7 @@ Later, when this test file is executed again, Bun will read the snapshot file an
61
61
 
62
62
  ```sh
63
63
  $ bun test
64
- bun test v1.2.13-canary.20250506T140621 (9c68abdb)
64
+ bun test v1.2.13-canary.20250508T140628 (9c68abdb)
65
65
 
66
66
  test/snap.test.ts:
67
67
  ✓ snapshot [1.05ms]
@@ -78,7 +78,7 @@ To update snapshots, use the `--update-snapshots` flag.
78
78
 
79
79
  ```sh
80
80
  $ bun test --update-snapshots
81
- bun test v1.2.13-canary.20250506T140621 (9c68abdb)
81
+ bun test v1.2.13-canary.20250508T140628 (9c68abdb)
82
82
 
83
83
  test/snap.test.ts:
84
84
  ✓ snapshot [0.86ms]
@@ -29,7 +29,7 @@ To regenerate snapshots, use the `--update-snapshots` flag.
29
29
 
30
30
  ```sh
31
31
  $ bun test --update-snapshots
32
- bun test v1.2.13-canary.20250506T140621 (9c68abdb)
32
+ bun test v1.2.13-canary.20250508T140628 (9c68abdb)
33
33
 
34
34
  test/snap.test.ts:
35
35
  ✓ snapshot [0.86ms]
@@ -5,7 +5,7 @@ name: Get the current Bun version
5
5
  Get the current version of Bun in a semver format.
6
6
 
7
7
  ```ts#index.ts
8
- Bun.version; // => "1.2.13-canary.20250506T140621"
8
+ Bun.version; // => "1.2.13-canary.20250508T140628"
9
9
  ```
10
10
 
11
11
  ---
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
14
14
  ```bash#macOS/Linux_(curl)
15
15
  $ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
16
16
  # to install a specific version
17
- $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.13-canary.20250506T140621"
17
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.13-canary.20250508T140628"
18
18
  ```
19
19
 
20
20
  ```bash#npm
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
189
189
 
190
190
  ### Installing a specific version of Bun on Linux/Mac
191
191
 
192
- To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.13-canary.20250506T140621`.
192
+ To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.13-canary.20250508T140628`.
193
193
 
194
194
  ```sh
195
- $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.13-canary.20250506T140621"
195
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.13-canary.20250508T140628"
196
196
  ```
197
197
 
198
198
  ### Installing a specific version of Bun on Windows
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
201
201
 
202
202
  ```sh
203
203
  # PowerShell:
204
- $ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.13-canary.20250506T140621"
204
+ $ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.13-canary.20250508T140628"
205
205
  ```
206
206
 
207
207
  ## Downloading Bun binaries directly
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
124
124
  This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
125
125
 
126
126
  ```sh
127
- [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.13-canary.20250506T140621" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
127
+ [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.13-canary.20250508T140628" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
128
128
  [fetch] > HTTP/1.1 POST https://example.com/
129
129
  [fetch] > content-type: application/json
130
130
  [fetch] > Connection: keep-alive
131
- [fetch] > User-Agent: Bun/1.2.13-canary.20250506T140621
131
+ [fetch] > User-Agent: Bun/1.2.13-canary.20250508T140628
132
132
  [fetch] > Accept: */*
133
133
  [fetch] > Host: example.com
134
134
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -170,7 +170,7 @@ This prints the following to the console:
170
170
  [fetch] > HTTP/1.1 POST https://example.com/
171
171
  [fetch] > content-type: application/json
172
172
  [fetch] > Connection: keep-alive
173
- [fetch] > User-Agent: Bun/1.2.13-canary.20250506T140621
173
+ [fetch] > User-Agent: Bun/1.2.13-canary.20250508T140628
174
174
  [fetch] > Accept: */*
175
175
  [fetch] > Host: example.com
176
176
  [fetch] > Accept-Encoding: gzip, deflate, br
package/docs/test/dom.md CHANGED
@@ -55,7 +55,7 @@ Let's run this test with `bun test`:
55
55
 
56
56
  ```bash
57
57
  $ bun test
58
- bun test v1.2.13-canary.20250506T140621
58
+ bun test v1.2.13-canary.20250508T140628
59
59
 
60
60
  dom.test.ts:
61
61
  ✓ dom test [0.82ms]
package/globals.d.ts CHANGED
@@ -954,13 +954,6 @@ interface ErrorConstructor {
954
954
  */
955
955
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
956
956
 
957
- /**
958
- * Optional override for formatting stack traces
959
- *
960
- * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
961
- */
962
- prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
963
-
964
957
  /**
965
958
  * The maximum number of stack frames to capture.
966
959
  */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.13-canary.20250506T140621",
2
+ "version": "1.2.13-canary.20250508T140628",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "types": "./index.d.ts",