bun-types 1.2.19-canary.20250707T140810 → 1.2.19-canary.20250709T140635
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 +354 -154
- package/deprecated.d.ts +18 -0
- package/docs/api/fetch.md +1 -1
- package/docs/api/spawn.md +1 -1
- package/docs/cli/pm.md +5 -4
- package/docs/cli/publish.md +1 -1
- package/docs/guides/ecosystem/nuxt.md +1 -1
- package/docs/guides/install/add-peer.md +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.md +1 -1
- package/docs/guides/test/run-tests.md +3 -3
- package/docs/guides/test/snapshot.md +3 -3
- package/docs/guides/test/update-snapshots.md +1 -1
- package/docs/guides/util/version.md +1 -1
- package/docs/installation.md +4 -4
- package/docs/runtime/debugger.md +3 -3
- package/docs/test/dom.md +1 -1
- package/overrides.d.ts +21 -0
- package/package.json +1 -1
package/bun.d.ts
CHANGED
|
@@ -347,17 +347,6 @@ declare module "bun" {
|
|
|
347
347
|
|
|
348
348
|
type WorkerType = "classic" | "module";
|
|
349
349
|
|
|
350
|
-
/**
|
|
351
|
-
* This type-only interface is identical at runtime to {@link ReadableStream},
|
|
352
|
-
* and exists to document types that do not exist yet in libdom.
|
|
353
|
-
*/
|
|
354
|
-
interface BunReadableStream<T = any> extends ReadableStream<T> {
|
|
355
|
-
text(): Promise<string>;
|
|
356
|
-
bytes(): Promise<Uint8Array>;
|
|
357
|
-
json(): Promise<any>;
|
|
358
|
-
blob(): Promise<Blob>;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
350
|
interface AbstractWorker {
|
|
362
351
|
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorker/error_event) */
|
|
363
352
|
onerror: ((this: AbstractWorker, ev: ErrorEvent) => any) | null;
|
|
@@ -864,6 +853,8 @@ declare module "bun" {
|
|
|
864
853
|
*
|
|
865
854
|
* @param stream The stream to consume.
|
|
866
855
|
* @returns A promise that resolves with the concatenated chunks or the concatenated chunks as a {@link Uint8Array}.
|
|
856
|
+
*
|
|
857
|
+
* @deprecated Use {@link ReadableStream.bytes}
|
|
867
858
|
*/
|
|
868
859
|
function readableStreamToBytes(
|
|
869
860
|
stream: ReadableStream<ArrayBufferView | ArrayBufferLike>,
|
|
@@ -876,6 +867,8 @@ declare module "bun" {
|
|
|
876
867
|
*
|
|
877
868
|
* @param stream The stream to consume.
|
|
878
869
|
* @returns A promise that resolves with the concatenated chunks as a {@link Blob}.
|
|
870
|
+
*
|
|
871
|
+
* @deprecated Use {@link ReadableStream.blob}
|
|
879
872
|
*/
|
|
880
873
|
function readableStreamToBlob(stream: ReadableStream): Promise<Blob>;
|
|
881
874
|
|
|
@@ -918,6 +911,8 @@ declare module "bun" {
|
|
|
918
911
|
*
|
|
919
912
|
* @param stream The stream to consume.
|
|
920
913
|
* @returns A promise that resolves with the concatenated chunks as a {@link String}.
|
|
914
|
+
*
|
|
915
|
+
* @deprecated Use {@link ReadableStream.text}
|
|
921
916
|
*/
|
|
922
917
|
function readableStreamToText(stream: ReadableStream): Promise<string>;
|
|
923
918
|
|
|
@@ -928,6 +923,8 @@ declare module "bun" {
|
|
|
928
923
|
*
|
|
929
924
|
* @param stream The stream to consume.
|
|
930
925
|
* @returns A promise that resolves with the concatenated chunks as a {@link String}.
|
|
926
|
+
*
|
|
927
|
+
* @deprecated Use {@link ReadableStream.json}
|
|
931
928
|
*/
|
|
932
929
|
function readableStreamToJSON(stream: ReadableStream): Promise<any>;
|
|
933
930
|
|
|
@@ -1254,9 +1251,9 @@ declare module "bun" {
|
|
|
1254
1251
|
*/
|
|
1255
1252
|
writer(options?: { highWaterMark?: number }): FileSink;
|
|
1256
1253
|
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
//
|
|
1254
|
+
// TODO
|
|
1255
|
+
// readonly readable: ReadableStream<Uint8Array>;
|
|
1256
|
+
// readonly writable: WritableStream<Uint8Array>;
|
|
1260
1257
|
|
|
1261
1258
|
/**
|
|
1262
1259
|
* A UNIX timestamp indicating when the file was last modified.
|
|
@@ -1315,116 +1312,285 @@ declare module "bun" {
|
|
|
1315
1312
|
stat(): Promise<import("node:fs").Stats>;
|
|
1316
1313
|
}
|
|
1317
1314
|
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
* host: 'localhost',
|
|
1323
|
-
* port: 5432,
|
|
1324
|
-
* user: 'dbuser',
|
|
1325
|
-
* password: 'secretpass',
|
|
1326
|
-
* database: 'myapp',
|
|
1327
|
-
* idleTimeout: 30,
|
|
1328
|
-
* max: 20,
|
|
1329
|
-
* onconnect: (client) => {
|
|
1330
|
-
* console.log('Connected to database');
|
|
1331
|
-
* }
|
|
1332
|
-
* };
|
|
1333
|
-
*/
|
|
1315
|
+
namespace SQL {
|
|
1316
|
+
type AwaitPromisesArray<T extends Array<PromiseLike<any>>> = {
|
|
1317
|
+
[K in keyof T]: Awaited<T[K]>;
|
|
1318
|
+
};
|
|
1334
1319
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
url?: URL | string;
|
|
1338
|
-
/** Database server hostname */
|
|
1339
|
-
host?: string;
|
|
1340
|
-
/** Database server hostname (alias for host) */
|
|
1341
|
-
hostname?: string;
|
|
1342
|
-
/** Database server port number */
|
|
1343
|
-
port?: number | string;
|
|
1344
|
-
/** Database user for authentication */
|
|
1345
|
-
username?: string;
|
|
1346
|
-
/** Database user for authentication (alias for username) */
|
|
1347
|
-
user?: string;
|
|
1348
|
-
/** Database password for authentication */
|
|
1349
|
-
password?: string | (() => Promise<string>);
|
|
1350
|
-
/** Database password for authentication (alias for password) */
|
|
1351
|
-
pass?: string | (() => Promise<string>);
|
|
1352
|
-
/** Name of the database to connect to */
|
|
1353
|
-
database?: string;
|
|
1354
|
-
/** Name of the database to connect to (alias for database) */
|
|
1355
|
-
db?: string;
|
|
1356
|
-
/** Database adapter/driver to use */
|
|
1357
|
-
adapter?: string;
|
|
1358
|
-
/** Maximum time in seconds to wait for connection to become available */
|
|
1359
|
-
idleTimeout?: number;
|
|
1360
|
-
/** Maximum time in seconds to wait for connection to become available (alias for idleTimeout) */
|
|
1361
|
-
idle_timeout?: number;
|
|
1362
|
-
/** Maximum time in seconds to wait when establishing a connection */
|
|
1363
|
-
connectionTimeout?: number;
|
|
1364
|
-
/** Maximum time in seconds to wait when establishing a connection (alias for connectionTimeout) */
|
|
1365
|
-
connection_timeout?: number;
|
|
1366
|
-
/** Maximum lifetime in seconds of a connection */
|
|
1367
|
-
maxLifetime?: number;
|
|
1368
|
-
/** Maximum lifetime in seconds of a connection (alias for maxLifetime) */
|
|
1369
|
-
max_lifetime?: number;
|
|
1370
|
-
/** Whether to use TLS/SSL for the connection */
|
|
1371
|
-
tls?: TLSOptions | boolean;
|
|
1372
|
-
/** Whether to use TLS/SSL for the connection (alias for tls) */
|
|
1373
|
-
ssl?: TLSOptions | boolean;
|
|
1374
|
-
/** Callback function executed when a connection is established */
|
|
1375
|
-
onconnect?: (client: SQL) => void;
|
|
1376
|
-
/** Callback function executed when a connection is closed */
|
|
1377
|
-
onclose?: (client: SQL) => void;
|
|
1378
|
-
/** Maximum number of connections in the pool */
|
|
1379
|
-
max?: number;
|
|
1380
|
-
/** By default values outside i32 range are returned as strings. If this is true, values outside i32 range are returned as BigInts. */
|
|
1381
|
-
bigint?: boolean;
|
|
1382
|
-
/** Automatic creation of prepared statements, defaults to true */
|
|
1383
|
-
prepare?: boolean;
|
|
1384
|
-
}
|
|
1320
|
+
type ContextCallbackResult<T> = T extends Array<PromiseLike<any>> ? AwaitPromisesArray<T> : Awaited<T>;
|
|
1321
|
+
type ContextCallback<T, SQL> = (sql: SQL) => Promise<T>;
|
|
1385
1322
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1323
|
+
/**
|
|
1324
|
+
* Configuration options for SQL client connection and behavior
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```ts
|
|
1328
|
+
* const config: Bun.SQL.Options = {
|
|
1329
|
+
* host: 'localhost',
|
|
1330
|
+
* port: 5432,
|
|
1331
|
+
* user: 'dbuser',
|
|
1332
|
+
* password: 'secretpass',
|
|
1333
|
+
* database: 'myapp',
|
|
1334
|
+
* idleTimeout: 30,
|
|
1335
|
+
* max: 20,
|
|
1336
|
+
* onconnect: (client) => {
|
|
1337
|
+
* console.log('Connected to database');
|
|
1338
|
+
* }
|
|
1339
|
+
* };
|
|
1340
|
+
* ```
|
|
1341
|
+
*/
|
|
1342
|
+
interface Options {
|
|
1343
|
+
/**
|
|
1344
|
+
* Connection URL (can be string or URL object)
|
|
1345
|
+
*/
|
|
1346
|
+
url?: URL | string | undefined;
|
|
1393
1347
|
|
|
1394
|
-
|
|
1395
|
-
|
|
1348
|
+
/**
|
|
1349
|
+
* Database server hostname
|
|
1350
|
+
* @default "localhost"
|
|
1351
|
+
*/
|
|
1352
|
+
host?: string | undefined;
|
|
1396
1353
|
|
|
1397
|
-
|
|
1398
|
-
|
|
1354
|
+
/**
|
|
1355
|
+
* Database server hostname (alias for host)
|
|
1356
|
+
* @deprecated Prefer {@link host}
|
|
1357
|
+
* @default "localhost"
|
|
1358
|
+
*/
|
|
1359
|
+
hostname?: string | undefined;
|
|
1399
1360
|
|
|
1400
|
-
|
|
1401
|
-
|
|
1361
|
+
/**
|
|
1362
|
+
* Database server port number
|
|
1363
|
+
* @default 5432
|
|
1364
|
+
*/
|
|
1365
|
+
port?: number | string | undefined;
|
|
1402
1366
|
|
|
1403
|
-
|
|
1404
|
-
|
|
1367
|
+
/**
|
|
1368
|
+
* Database user for authentication
|
|
1369
|
+
* @default "postgres"
|
|
1370
|
+
*/
|
|
1371
|
+
username?: string | undefined;
|
|
1405
1372
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1373
|
+
/**
|
|
1374
|
+
* Database user for authentication (alias for username)
|
|
1375
|
+
* @deprecated Prefer {@link username}
|
|
1376
|
+
* @default "postgres"
|
|
1377
|
+
*/
|
|
1378
|
+
user?: string | undefined;
|
|
1408
1379
|
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1380
|
+
/**
|
|
1381
|
+
* Database password for authentication
|
|
1382
|
+
* @default ""
|
|
1383
|
+
*/
|
|
1384
|
+
password?: string | (() => MaybePromise<string>) | undefined;
|
|
1412
1385
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1386
|
+
/**
|
|
1387
|
+
* Database password for authentication (alias for password)
|
|
1388
|
+
* @deprecated Prefer {@link password}
|
|
1389
|
+
* @default ""
|
|
1390
|
+
*/
|
|
1391
|
+
pass?: string | (() => MaybePromise<string>) | undefined;
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* Name of the database to connect to
|
|
1395
|
+
* @default The username value
|
|
1396
|
+
*/
|
|
1397
|
+
database?: string | undefined;
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Name of the database to connect to (alias for database)
|
|
1401
|
+
* @deprecated Prefer {@link database}
|
|
1402
|
+
* @default The username value
|
|
1403
|
+
*/
|
|
1404
|
+
db?: string | undefined;
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* Database adapter/driver to use
|
|
1408
|
+
* @default "postgres"
|
|
1409
|
+
*/
|
|
1410
|
+
adapter?: "postgres" /*| "sqlite" | "mysql"*/ | (string & {}) | undefined;
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Maximum time in seconds to wait for connection to become available
|
|
1414
|
+
* @default 0 (no timeout)
|
|
1415
|
+
*/
|
|
1416
|
+
idleTimeout?: number | undefined;
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* Maximum time in seconds to wait for connection to become available (alias for idleTimeout)
|
|
1420
|
+
* @deprecated Prefer {@link idleTimeout}
|
|
1421
|
+
* @default 0 (no timeout)
|
|
1422
|
+
*/
|
|
1423
|
+
idle_timeout?: number | undefined;
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Maximum time in seconds to wait when establishing a connection
|
|
1427
|
+
* @default 30
|
|
1428
|
+
*/
|
|
1429
|
+
connectionTimeout?: number | undefined;
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* Maximum time in seconds to wait when establishing a connection (alias for connectionTimeout)
|
|
1433
|
+
* @deprecated Prefer {@link connectionTimeout}
|
|
1434
|
+
* @default 30
|
|
1435
|
+
*/
|
|
1436
|
+
connection_timeout?: number | undefined;
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* Maximum time in seconds to wait when establishing a connection (alias for connectionTimeout)
|
|
1440
|
+
* @deprecated Prefer {@link connectionTimeout}
|
|
1441
|
+
* @default 30
|
|
1442
|
+
*/
|
|
1443
|
+
connectTimeout?: number | undefined;
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* Maximum time in seconds to wait when establishing a connection (alias for connectionTimeout)
|
|
1447
|
+
* @deprecated Prefer {@link connectionTimeout}
|
|
1448
|
+
* @default 30
|
|
1449
|
+
*/
|
|
1450
|
+
connect_timeout?: number | undefined;
|
|
1451
|
+
|
|
1452
|
+
/**
|
|
1453
|
+
* Maximum lifetime in seconds of a connection
|
|
1454
|
+
* @default 0 (no maximum lifetime)
|
|
1455
|
+
*/
|
|
1456
|
+
maxLifetime?: number | undefined;
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* Maximum lifetime in seconds of a connection (alias for maxLifetime)
|
|
1460
|
+
* @deprecated Prefer {@link maxLifetime}
|
|
1461
|
+
* @default 0 (no maximum lifetime)
|
|
1462
|
+
*/
|
|
1463
|
+
max_lifetime?: number | undefined;
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Whether to use TLS/SSL for the connection
|
|
1467
|
+
* @default false
|
|
1468
|
+
*/
|
|
1469
|
+
tls?: TLSOptions | boolean | undefined;
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* Whether to use TLS/SSL for the connection (alias for tls)
|
|
1473
|
+
* @default false
|
|
1474
|
+
*/
|
|
1475
|
+
ssl?: TLSOptions | boolean | undefined;
|
|
1476
|
+
|
|
1477
|
+
// `.path` is currently unsupported in Bun, the implementation is incomplete.
|
|
1478
|
+
//
|
|
1479
|
+
// /**
|
|
1480
|
+
// * Unix domain socket path for connection
|
|
1481
|
+
// * @default ""
|
|
1482
|
+
// */
|
|
1483
|
+
// path?: string | undefined;
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* Callback function executed when a connection is established
|
|
1487
|
+
*/
|
|
1488
|
+
onconnect?: ((client: SQL) => void) | undefined;
|
|
1489
|
+
|
|
1490
|
+
/**
|
|
1491
|
+
* Callback function executed when a connection is closed
|
|
1492
|
+
*/
|
|
1493
|
+
onclose?: ((client: SQL) => void) | undefined;
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Postgres client runtime configuration options
|
|
1497
|
+
*
|
|
1498
|
+
* @see https://www.postgresql.org/docs/current/runtime-config-client.html
|
|
1499
|
+
*/
|
|
1500
|
+
connection?: Record<string, string | boolean | number> | undefined;
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Maximum number of connections in the pool
|
|
1504
|
+
* @default 10
|
|
1505
|
+
*/
|
|
1506
|
+
max?: number | undefined;
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* By default values outside i32 range are returned as strings. If this is true, values outside i32 range are returned as BigInts.
|
|
1510
|
+
* @default false
|
|
1511
|
+
*/
|
|
1512
|
+
bigint?: boolean | undefined;
|
|
1513
|
+
|
|
1514
|
+
/**
|
|
1515
|
+
* Automatic creation of prepared statements
|
|
1516
|
+
* @default true
|
|
1517
|
+
*/
|
|
1518
|
+
prepare?: boolean | undefined;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* Represents a SQL query that can be executed, with additional control methods
|
|
1523
|
+
* Extends Promise to allow for async/await usage
|
|
1524
|
+
*/
|
|
1525
|
+
interface Query<T> extends Promise<T> {
|
|
1526
|
+
/**
|
|
1527
|
+
* Indicates if the query is currently executing
|
|
1528
|
+
*/
|
|
1529
|
+
active: boolean;
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* Indicates if the query has been cancelled
|
|
1533
|
+
*/
|
|
1534
|
+
cancelled: boolean;
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* Cancels the executing query
|
|
1538
|
+
*/
|
|
1539
|
+
cancel(): Query<T>;
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* Executes the query as a simple query, no parameters are allowed but can execute multiple commands separated by semicolons
|
|
1543
|
+
*/
|
|
1544
|
+
simple(): Query<T>;
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* Executes the query
|
|
1548
|
+
*/
|
|
1549
|
+
execute(): Query<T>;
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* Returns the raw query result
|
|
1553
|
+
*/
|
|
1554
|
+
raw(): Query<T>;
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* Returns only the values from the query result
|
|
1558
|
+
*/
|
|
1559
|
+
values(): Query<T>;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* Callback function type for transaction contexts
|
|
1564
|
+
* @param sql Function to execute SQL queries within the transaction
|
|
1565
|
+
*/
|
|
1566
|
+
type TransactionContextCallback<T> = ContextCallback<T, TransactionSQL>;
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* Callback function type for savepoint contexts
|
|
1570
|
+
* @param sql Function to execute SQL queries within the savepoint
|
|
1571
|
+
*/
|
|
1572
|
+
type SavepointContextCallback<T> = ContextCallback<T, SavepointSQL>;
|
|
1573
|
+
|
|
1574
|
+
/**
|
|
1575
|
+
* SQL.Helper represents a parameter or serializable
|
|
1576
|
+
* value inside of a query.
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* ```ts
|
|
1580
|
+
* const helper = sql(users, 'id');
|
|
1581
|
+
* await sql`insert into users ${helper}`;
|
|
1582
|
+
* ```
|
|
1583
|
+
*/
|
|
1584
|
+
interface Helper<T> {
|
|
1585
|
+
readonly value: T[];
|
|
1586
|
+
readonly columns: (keyof T)[];
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1423
1589
|
|
|
1424
1590
|
/**
|
|
1425
1591
|
* Main SQL client interface providing connection and transaction management
|
|
1426
1592
|
*/
|
|
1427
|
-
interface SQL {
|
|
1593
|
+
interface SQL extends AsyncDisposable {
|
|
1428
1594
|
/**
|
|
1429
1595
|
* Executes a SQL query using template literals
|
|
1430
1596
|
* @example
|
|
@@ -1432,7 +1598,12 @@ declare module "bun" {
|
|
|
1432
1598
|
* const [user] = await sql`select * from users where id = ${1}`;
|
|
1433
1599
|
* ```
|
|
1434
1600
|
*/
|
|
1435
|
-
(strings:
|
|
1601
|
+
<T = any>(strings: TemplateStringsArray, ...values: unknown[]): SQL.Query<T>;
|
|
1602
|
+
|
|
1603
|
+
/**
|
|
1604
|
+
* Execute a SQL query using a string
|
|
1605
|
+
*/
|
|
1606
|
+
<T = any>(string: string): SQL.Query<T>;
|
|
1436
1607
|
|
|
1437
1608
|
/**
|
|
1438
1609
|
* Helper function for inserting an object into a query
|
|
@@ -1440,16 +1611,19 @@ declare module "bun" {
|
|
|
1440
1611
|
* @example
|
|
1441
1612
|
* ```ts
|
|
1442
1613
|
* // Insert an object
|
|
1443
|
-
* const result = await sql`insert into users ${sql(users)}
|
|
1614
|
+
* const result = await sql`insert into users ${sql(users)} returning *`;
|
|
1444
1615
|
*
|
|
1445
1616
|
* // Or pick specific columns
|
|
1446
|
-
* const result = await sql`insert into users ${sql(users, "id", "name")}
|
|
1617
|
+
* const result = await sql`insert into users ${sql(users, "id", "name")} returning *`;
|
|
1447
1618
|
*
|
|
1448
1619
|
* // Or a single object
|
|
1449
|
-
* const result = await sql`insert into users ${sql(user)}
|
|
1620
|
+
* const result = await sql`insert into users ${sql(user)} returning *`;
|
|
1450
1621
|
* ```
|
|
1451
1622
|
*/
|
|
1452
|
-
<T extends { [Key in PropertyKey]: unknown }
|
|
1623
|
+
<T extends { [Key in PropertyKey]: unknown }, Keys extends keyof T = keyof T>(
|
|
1624
|
+
obj: T | T[] | readonly T[],
|
|
1625
|
+
...columns: readonly Keys[]
|
|
1626
|
+
): SQL.Helper<Pick<T, Keys>>;
|
|
1453
1627
|
|
|
1454
1628
|
/**
|
|
1455
1629
|
* Helper function for inserting any serializable value into a query
|
|
@@ -1459,7 +1633,7 @@ declare module "bun" {
|
|
|
1459
1633
|
* const result = await sql`SELECT * FROM users WHERE id IN ${sql([1, 2, 3])}`;
|
|
1460
1634
|
* ```
|
|
1461
1635
|
*/
|
|
1462
|
-
(
|
|
1636
|
+
<T>(value: T): SQL.Helper<T>;
|
|
1463
1637
|
|
|
1464
1638
|
/**
|
|
1465
1639
|
* Commits a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
|
|
@@ -1531,6 +1705,7 @@ declare module "bun" {
|
|
|
1531
1705
|
|
|
1532
1706
|
/**
|
|
1533
1707
|
* The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
|
|
1708
|
+
*
|
|
1534
1709
|
* This can be used for running queries on an isolated connection.
|
|
1535
1710
|
* Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
|
|
1536
1711
|
*
|
|
@@ -1556,7 +1731,10 @@ declare module "bun" {
|
|
|
1556
1731
|
* ```
|
|
1557
1732
|
*/
|
|
1558
1733
|
reserve(): Promise<ReservedSQL>;
|
|
1559
|
-
|
|
1734
|
+
|
|
1735
|
+
/**
|
|
1736
|
+
* Begins a new transaction.
|
|
1737
|
+
*
|
|
1560
1738
|
* 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.
|
|
1561
1739
|
* 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.
|
|
1562
1740
|
* @example
|
|
@@ -1580,8 +1758,11 @@ declare module "bun" {
|
|
|
1580
1758
|
* return [user, account]
|
|
1581
1759
|
* })
|
|
1582
1760
|
*/
|
|
1583
|
-
begin(fn:
|
|
1584
|
-
|
|
1761
|
+
begin<const T>(fn: SQL.TransactionContextCallback<T>): Promise<SQL.ContextCallbackResult<T>>;
|
|
1762
|
+
|
|
1763
|
+
/**
|
|
1764
|
+
* Begins a new transaction with options.
|
|
1765
|
+
*
|
|
1585
1766
|
* 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.
|
|
1586
1767
|
* 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.
|
|
1587
1768
|
* @example
|
|
@@ -1605,8 +1786,11 @@ declare module "bun" {
|
|
|
1605
1786
|
* return [user, account]
|
|
1606
1787
|
* })
|
|
1607
1788
|
*/
|
|
1608
|
-
begin(options: string, fn:
|
|
1609
|
-
|
|
1789
|
+
begin<const T>(options: string, fn: SQL.TransactionContextCallback<T>): Promise<SQL.ContextCallbackResult<T>>;
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* Alternative method to begin a transaction.
|
|
1793
|
+
*
|
|
1610
1794
|
* 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.
|
|
1611
1795
|
* 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.
|
|
1612
1796
|
* @alias begin
|
|
@@ -1631,11 +1815,15 @@ declare module "bun" {
|
|
|
1631
1815
|
* return [user, account]
|
|
1632
1816
|
* })
|
|
1633
1817
|
*/
|
|
1634
|
-
transaction(fn:
|
|
1635
|
-
|
|
1818
|
+
transaction<const T>(fn: SQL.TransactionContextCallback<T>): Promise<SQL.ContextCallbackResult<T>>;
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Alternative method to begin a transaction with options
|
|
1636
1822
|
* 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.
|
|
1637
1823
|
* 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.
|
|
1638
|
-
*
|
|
1824
|
+
*
|
|
1825
|
+
* @alias {@link begin}
|
|
1826
|
+
*
|
|
1639
1827
|
* @example
|
|
1640
1828
|
* const [user, account] = await sql.transaction("read write", async sql => {
|
|
1641
1829
|
* const [user] = await sql`
|
|
@@ -1655,15 +1843,18 @@ declare module "bun" {
|
|
|
1655
1843
|
* returning *
|
|
1656
1844
|
* `
|
|
1657
1845
|
* return [user, account]
|
|
1658
|
-
* })
|
|
1846
|
+
* });
|
|
1659
1847
|
*/
|
|
1660
|
-
transaction(options: string, fn:
|
|
1661
|
-
|
|
1848
|
+
transaction<const T>(options: string, fn: SQL.TransactionContextCallback<T>): Promise<SQL.ContextCallbackResult<T>>;
|
|
1849
|
+
|
|
1850
|
+
/**
|
|
1851
|
+
* Begins a distributed transaction
|
|
1662
1852
|
* 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.
|
|
1663
1853
|
* 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.
|
|
1664
1854
|
* beginDistributed will automatic rollback if any exception are not caught, and you can commit and rollback later if everything goes well.
|
|
1665
1855
|
* 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.
|
|
1666
1856
|
* 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.
|
|
1857
|
+
*
|
|
1667
1858
|
* @example
|
|
1668
1859
|
* await sql.beginDistributed("numbers", async sql => {
|
|
1669
1860
|
* await sql`create table if not exists numbers (a int)`;
|
|
@@ -1673,31 +1864,38 @@ declare module "bun" {
|
|
|
1673
1864
|
* await sql.commitDistributed("numbers");
|
|
1674
1865
|
* // or await sql.rollbackDistributed("numbers");
|
|
1675
1866
|
*/
|
|
1676
|
-
beginDistributed(
|
|
1867
|
+
beginDistributed<const T>(
|
|
1868
|
+
name: string,
|
|
1869
|
+
fn: SQL.TransactionContextCallback<T>,
|
|
1870
|
+
): Promise<SQL.ContextCallbackResult<T>>;
|
|
1871
|
+
|
|
1677
1872
|
/** Alternative method to begin a distributed transaction
|
|
1678
|
-
* @alias beginDistributed
|
|
1873
|
+
* @alias {@link beginDistributed}
|
|
1679
1874
|
*/
|
|
1680
|
-
distributed(name: string, fn:
|
|
1875
|
+
distributed<const T>(name: string, fn: SQL.TransactionContextCallback<T>): Promise<SQL.ContextCallbackResult<T>>;
|
|
1876
|
+
|
|
1681
1877
|
/**If you know what you're doing, you can use unsafe to pass any string you'd like.
|
|
1682
1878
|
* Please note that this can lead to SQL injection if you're not careful.
|
|
1683
1879
|
* You can also nest sql.unsafe within a safe sql expression. This is useful if only part of your fraction has unsafe elements.
|
|
1684
1880
|
* @example
|
|
1685
1881
|
* const result = await sql.unsafe(`select ${danger} from users where id = ${dragons}`)
|
|
1686
1882
|
*/
|
|
1687
|
-
unsafe(string: string, values?: any[]):
|
|
1883
|
+
unsafe<T = any>(string: string, values?: any[]): SQL.Query<T>;
|
|
1884
|
+
|
|
1688
1885
|
/**
|
|
1689
1886
|
* Reads a file and uses the contents as a query.
|
|
1690
1887
|
* Optional parameters can be used if the file includes $1, $2, etc
|
|
1691
1888
|
* @example
|
|
1692
1889
|
* const result = await sql.file("query.sql", [1, 2, 3]);
|
|
1693
1890
|
*/
|
|
1694
|
-
file(filename: string, values?: any[]):
|
|
1891
|
+
file<T = any>(filename: string, values?: any[]): SQL.Query<T>;
|
|
1695
1892
|
|
|
1696
|
-
/**
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1893
|
+
/**
|
|
1894
|
+
* Current client options
|
|
1895
|
+
*/
|
|
1896
|
+
options: SQL.Options;
|
|
1700
1897
|
}
|
|
1898
|
+
|
|
1701
1899
|
const SQL: {
|
|
1702
1900
|
/**
|
|
1703
1901
|
* Creates a new SQL client instance
|
|
@@ -1723,7 +1921,7 @@ declare module "bun" {
|
|
|
1723
1921
|
* const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
|
|
1724
1922
|
* ```
|
|
1725
1923
|
*/
|
|
1726
|
-
new (connectionString: string | URL, options: Omit<
|
|
1924
|
+
new (connectionString: string | URL, options: Omit<SQL.Options, "url">): SQL;
|
|
1727
1925
|
|
|
1728
1926
|
/**
|
|
1729
1927
|
* Creates a new SQL client instance with options
|
|
@@ -1735,17 +1933,18 @@ declare module "bun" {
|
|
|
1735
1933
|
* const sql = new SQL({ url: "postgres://localhost:5432/mydb", idleTimeout: 1000 });
|
|
1736
1934
|
* ```
|
|
1737
1935
|
*/
|
|
1738
|
-
new (options?:
|
|
1936
|
+
new (options?: SQL.Options): SQL;
|
|
1739
1937
|
};
|
|
1740
1938
|
|
|
1741
1939
|
/**
|
|
1742
1940
|
* Represents a reserved connection from the connection pool
|
|
1743
1941
|
* Extends SQL with additional release functionality
|
|
1744
1942
|
*/
|
|
1745
|
-
interface ReservedSQL extends SQL {
|
|
1746
|
-
/**
|
|
1943
|
+
interface ReservedSQL extends SQL, Disposable {
|
|
1944
|
+
/**
|
|
1945
|
+
* Releases the client back to the connection pool
|
|
1946
|
+
*/
|
|
1747
1947
|
release(): void;
|
|
1748
|
-
[Symbol.dispose](): void;
|
|
1749
1948
|
}
|
|
1750
1949
|
|
|
1751
1950
|
/**
|
|
@@ -1754,26 +1953,30 @@ declare module "bun" {
|
|
|
1754
1953
|
*/
|
|
1755
1954
|
interface TransactionSQL extends SQL {
|
|
1756
1955
|
/** Creates a savepoint within the current transaction */
|
|
1757
|
-
savepoint(name: string, fn: SQLSavepointContextCallback): Promise<
|
|
1758
|
-
savepoint(fn: SQLSavepointContextCallback): Promise<
|
|
1956
|
+
savepoint<T>(name: string, fn: SQLSavepointContextCallback<T>): Promise<T>;
|
|
1957
|
+
savepoint<T>(fn: SQLSavepointContextCallback<T>): Promise<T>;
|
|
1759
1958
|
}
|
|
1959
|
+
|
|
1760
1960
|
/**
|
|
1761
1961
|
* Represents a savepoint within a transaction
|
|
1762
1962
|
*/
|
|
1763
1963
|
interface SavepointSQL extends SQL {}
|
|
1764
1964
|
|
|
1765
1965
|
type CSRFAlgorithm = "blake2b256" | "blake2b512" | "sha256" | "sha384" | "sha512" | "sha512-256";
|
|
1966
|
+
|
|
1766
1967
|
interface CSRFGenerateOptions {
|
|
1767
1968
|
/**
|
|
1768
1969
|
* The number of milliseconds until the token expires. 0 means the token never expires.
|
|
1769
1970
|
* @default 24 * 60 * 60 * 1000 (24 hours)
|
|
1770
1971
|
*/
|
|
1771
1972
|
expiresIn?: number;
|
|
1973
|
+
|
|
1772
1974
|
/**
|
|
1773
1975
|
* The encoding of the token.
|
|
1774
1976
|
* @default "base64url"
|
|
1775
1977
|
*/
|
|
1776
1978
|
encoding?: "base64" | "base64url" | "hex";
|
|
1979
|
+
|
|
1777
1980
|
/**
|
|
1778
1981
|
* The algorithm to use for the token.
|
|
1779
1982
|
* @default "sha256"
|
|
@@ -1786,16 +1989,19 @@ declare module "bun" {
|
|
|
1786
1989
|
* The secret to use for the token. If not provided, a random default secret will be generated in memory and used.
|
|
1787
1990
|
*/
|
|
1788
1991
|
secret?: string;
|
|
1992
|
+
|
|
1789
1993
|
/**
|
|
1790
1994
|
* The encoding of the token.
|
|
1791
1995
|
* @default "base64url"
|
|
1792
1996
|
*/
|
|
1793
1997
|
encoding?: "base64" | "base64url" | "hex";
|
|
1998
|
+
|
|
1794
1999
|
/**
|
|
1795
2000
|
* The algorithm to use for the token.
|
|
1796
2001
|
* @default "sha256"
|
|
1797
2002
|
*/
|
|
1798
2003
|
algorithm?: CSRFAlgorithm;
|
|
2004
|
+
|
|
1799
2005
|
/**
|
|
1800
2006
|
* The number of milliseconds until the token expires. 0 means the token never expires.
|
|
1801
2007
|
* @default 24 * 60 * 60 * 1000 (24 hours)
|
|
@@ -1805,15 +2011,11 @@ declare module "bun" {
|
|
|
1805
2011
|
|
|
1806
2012
|
/**
|
|
1807
2013
|
* SQL client
|
|
1808
|
-
*
|
|
1809
|
-
* @category Database
|
|
1810
2014
|
*/
|
|
1811
2015
|
const sql: SQL;
|
|
1812
2016
|
|
|
1813
2017
|
/**
|
|
1814
2018
|
* SQL client for PostgreSQL
|
|
1815
|
-
*
|
|
1816
|
-
* @category Database
|
|
1817
2019
|
*/
|
|
1818
2020
|
const postgres: SQL;
|
|
1819
2021
|
|
|
@@ -6803,7 +7005,7 @@ declare module "bun" {
|
|
|
6803
7005
|
*
|
|
6804
7006
|
* For stdout and stdin you may pass:
|
|
6805
7007
|
*
|
|
6806
|
-
* - `"pipe"`, `undefined`: The process will have a {@link
|
|
7008
|
+
* - `"pipe"`, `undefined`: The process will have a {@link ReadableStream} for standard output/error
|
|
6807
7009
|
* - `"ignore"`, `null`: The process will have no standard output/error
|
|
6808
7010
|
* - `"inherit"`: The process will inherit the standard output/error of the current process
|
|
6809
7011
|
* - `ArrayBufferView`: The process write to the preallocated buffer. Not implemented.
|
|
@@ -6829,7 +7031,7 @@ declare module "bun" {
|
|
|
6829
7031
|
/**
|
|
6830
7032
|
* The file descriptor for the standard output. It may be:
|
|
6831
7033
|
*
|
|
6832
|
-
* - `"pipe"`, `undefined`: The process will have a {@link
|
|
7034
|
+
* - `"pipe"`, `undefined`: The process will have a {@link ReadableStream} for standard output/error
|
|
6833
7035
|
* - `"ignore"`, `null`: The process will have no standard output/error
|
|
6834
7036
|
* - `"inherit"`: The process will inherit the standard output/error of the current process
|
|
6835
7037
|
* - `ArrayBufferView`: The process write to the preallocated buffer. Not implemented.
|
|
@@ -6841,7 +7043,7 @@ declare module "bun" {
|
|
|
6841
7043
|
/**
|
|
6842
7044
|
* The file descriptor for the standard error. It may be:
|
|
6843
7045
|
*
|
|
6844
|
-
* - `"pipe"`, `undefined`: The process will have a {@link
|
|
7046
|
+
* - `"pipe"`, `undefined`: The process will have a {@link ReadableStream} for standard output/error
|
|
6845
7047
|
* - `"ignore"`, `null`: The process will have no standard output/error
|
|
6846
7048
|
* - `"inherit"`: The process will inherit the standard output/error of the current process
|
|
6847
7049
|
* - `ArrayBufferView`: The process write to the preallocated buffer. Not implemented.
|
|
@@ -7001,10 +7203,8 @@ declare module "bun" {
|
|
|
7001
7203
|
maxBuffer?: number;
|
|
7002
7204
|
}
|
|
7003
7205
|
|
|
7004
|
-
type ReadableIO = ReadableStream<Uint8Array> | number | undefined;
|
|
7005
|
-
|
|
7006
7206
|
type ReadableToIO<X extends Readable> = X extends "pipe" | undefined
|
|
7007
|
-
?
|
|
7207
|
+
? ReadableStream<Uint8Array>
|
|
7008
7208
|
: X extends BunFile | ArrayBufferView | number
|
|
7009
7209
|
? number
|
|
7010
7210
|
: undefined;
|
package/deprecated.d.ts
CHANGED
|
@@ -14,10 +14,23 @@ declare module "bun" {
|
|
|
14
14
|
): void;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** @deprecated Use {@link SQL.Query Bun.SQL.Query} */
|
|
18
|
+
type SQLQuery<T = any> = SQL.Query<T>;
|
|
19
|
+
|
|
20
|
+
/** @deprecated Use {@link SQL.TransactionContextCallback Bun.SQL.TransactionContextCallback} */
|
|
21
|
+
type SQLTransactionContextCallback<T> = SQL.TransactionContextCallback<T>;
|
|
22
|
+
|
|
23
|
+
/** @deprecated Use {@link SQL.SavepointContextCallback Bun.SQL.SavepointContextCallback} */
|
|
24
|
+
type SQLSavepointContextCallback<T> = SQL.SavepointContextCallback<T>;
|
|
25
|
+
|
|
26
|
+
/** @deprecated Use {@link SQL.Options Bun.SQL.Options} */
|
|
27
|
+
type SQLOptions = SQL.Options;
|
|
28
|
+
|
|
17
29
|
/**
|
|
18
30
|
* @deprecated Renamed to `ErrorLike`
|
|
19
31
|
*/
|
|
20
32
|
type Errorlike = ErrorLike;
|
|
33
|
+
|
|
21
34
|
interface TLSOptions {
|
|
22
35
|
/**
|
|
23
36
|
* File path to a TLS key
|
|
@@ -27,6 +40,7 @@ declare module "bun" {
|
|
|
27
40
|
* @deprecated since v0.6.3 - Use `key: Bun.file(path)` instead.
|
|
28
41
|
*/
|
|
29
42
|
keyFile?: string;
|
|
43
|
+
|
|
30
44
|
/**
|
|
31
45
|
* File path to a TLS certificate
|
|
32
46
|
*
|
|
@@ -35,6 +49,7 @@ declare module "bun" {
|
|
|
35
49
|
* @deprecated since v0.6.3 - Use `cert: Bun.file(path)` instead.
|
|
36
50
|
*/
|
|
37
51
|
certFile?: string;
|
|
52
|
+
|
|
38
53
|
/**
|
|
39
54
|
* File path to a .pem file for a custom root CA
|
|
40
55
|
*
|
|
@@ -42,6 +57,9 @@ declare module "bun" {
|
|
|
42
57
|
*/
|
|
43
58
|
caFile?: string;
|
|
44
59
|
}
|
|
60
|
+
|
|
61
|
+
/** @deprecated This type is unused in Bun's declarations and may be removed in the future */
|
|
62
|
+
type ReadableIO = ReadableStream<Uint8Array> | number | undefined;
|
|
45
63
|
}
|
|
46
64
|
|
|
47
65
|
declare namespace NodeJS {
|
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.19-canary.
|
|
340
|
+
[fetch] > User-Agent: Bun/1.2.19-canary.20250709T140635
|
|
341
341
|
[fetch] > Accept: */*
|
|
342
342
|
[fetch] > Host: example.com
|
|
343
343
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/api/spawn.md
CHANGED
|
@@ -140,7 +140,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
|
|
|
140
140
|
```ts
|
|
141
141
|
const proc = Bun.spawn(["bun", "--version"]);
|
|
142
142
|
const text = await proc.stdout.text();
|
|
143
|
-
console.log(text); // => "1.2.19-canary.
|
|
143
|
+
console.log(text); // => "1.2.19-canary.20250709T140635\n"
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
Configure the output stream by passing one of the following values to `stdout/stderr`:
|
package/docs/cli/pm.md
CHANGED
|
@@ -158,7 +158,7 @@ To display current package version and help:
|
|
|
158
158
|
|
|
159
159
|
```bash
|
|
160
160
|
$ bun pm version
|
|
161
|
-
bun pm version v1.2.19-canary.
|
|
161
|
+
bun pm version v1.2.19-canary.20250709T140635 (ca7428e9)
|
|
162
162
|
Current package version: v1.0.0
|
|
163
163
|
|
|
164
164
|
Increment:
|
|
@@ -175,13 +175,14 @@ Increment:
|
|
|
175
175
|
Options:
|
|
176
176
|
--no-git-tag-version Skip git operations
|
|
177
177
|
--allow-same-version Prevents throwing error if version is the same
|
|
178
|
-
--message=<val>, -m Custom commit message
|
|
179
|
-
--preid=<val> Prerelease identifier
|
|
178
|
+
--message=<val>, -m Custom commit message, use %s for version substitution
|
|
179
|
+
--preid=<val> Prerelease identifier (i.e beta → 1.0.1-beta.0)
|
|
180
|
+
--force, -f Bypass dirty git history check
|
|
180
181
|
|
|
181
182
|
Examples:
|
|
182
183
|
$ bun pm version patch
|
|
183
184
|
$ bun pm version 1.2.3 --no-git-tag-version
|
|
184
|
-
$ bun pm version prerelease --preid beta
|
|
185
|
+
$ bun pm version prerelease --preid beta --message "Release beta: %s"
|
|
185
186
|
```
|
|
186
187
|
|
|
187
188
|
To bump the version in `package.json`:
|
package/docs/cli/publish.md
CHANGED
|
@@ -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.19-canary.
|
|
12
|
+
bun install v1.2.19-canary.20250709T140635 (16b4bf34)
|
|
13
13
|
+ @nuxt/devtools@0.8.2
|
|
14
14
|
+ nuxt@3.7.0
|
|
15
15
|
785 packages installed [2.67s]
|
|
@@ -15,7 +15,7 @@ This will add the package to `peerDependencies` in `package.json`.
|
|
|
15
15
|
```json-diff
|
|
16
16
|
{
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
+ "@types/bun": "^1.2.19-canary.
|
|
18
|
+
+ "@types/bun": "^1.2.19-canary.20250709T140635"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
```
|
|
@@ -27,7 +27,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
27
27
|
```json-diff
|
|
28
28
|
{
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@types/bun": "^1.2.19-canary.
|
|
30
|
+
"@types/bun": "^1.2.19-canary.20250709T140635"
|
|
31
31
|
},
|
|
32
32
|
"peerDependenciesMeta": {
|
|
33
33
|
+ "@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.19-canary.
|
|
100
|
+
$ bun update @types/bun@1.2.19-canary.20250709T140635
|
|
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.19-canary.
|
|
24
|
+
bun test v1.2.19-canary.20250709T140635 (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.19-canary.
|
|
50
|
+
bun test v1.2.19-canary.20250709T140635 (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.19-canary.
|
|
88
|
+
bun test v1.2.19-canary.20250709T140635 (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.19-canary.
|
|
21
|
+
bun test v1.2.19-canary.20250709T140635 (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.19-canary.
|
|
64
|
+
bun test v1.2.19-canary.20250709T140635 (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.19-canary.
|
|
81
|
+
bun test v1.2.19-canary.20250709T140635 (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.19-canary.
|
|
32
|
+
bun test v1.2.19-canary.20250709T140635 (9c68abdb)
|
|
33
33
|
|
|
34
34
|
test/snap.test.ts:
|
|
35
35
|
✓ snapshot [0.86ms]
|
package/docs/installation.md
CHANGED
|
@@ -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.19-canary.
|
|
17
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.19-canary.20250709T140635"
|
|
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.19-canary.
|
|
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.19-canary.20250709T140635`.
|
|
193
193
|
|
|
194
194
|
```sh
|
|
195
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.19-canary.
|
|
195
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.19-canary.20250709T140635"
|
|
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.19-canary.
|
|
204
|
+
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.19-canary.20250709T140635"
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
## Downloading Bun binaries directly
|
package/docs/runtime/debugger.md
CHANGED
|
@@ -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.19-canary.
|
|
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.19-canary.20250709T140635" -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.19-canary.
|
|
131
|
+
[fetch] > User-Agent: Bun/1.2.19-canary.20250709T140635
|
|
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.19-canary.
|
|
173
|
+
[fetch] > User-Agent: Bun/1.2.19-canary.20250709T140635
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/test/dom.md
CHANGED
package/overrides.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
|
|
3
|
+
declare module "stream/web" {
|
|
4
|
+
interface ReadableStream {
|
|
5
|
+
/**
|
|
6
|
+
* Consume a ReadableStream as text
|
|
7
|
+
*/
|
|
8
|
+
text(): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Consume a ReadableStream as a Uint8Array
|
|
11
|
+
*/
|
|
12
|
+
bytes(): Promise<Uint8Array>;
|
|
13
|
+
/**
|
|
14
|
+
* Consume a ReadableStream as JSON
|
|
15
|
+
*/
|
|
16
|
+
json(): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Consume a ReadableStream as a Blob
|
|
19
|
+
*/
|
|
20
|
+
blob(): Promise<Blob>;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
3
24
|
declare global {
|
|
4
25
|
namespace NodeJS {
|
|
5
26
|
interface ProcessEnv extends Bun.Env, ImportMetaEnv {}
|
package/package.json
CHANGED