bun-types 1.2.21-canary.20250819T140628 → 1.2.21-canary.20250821T140634
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 +87 -718
- package/deprecated.d.ts +31 -0
- package/docs/api/fetch.md +1 -1
- package/docs/api/spawn.md +1 -1
- package/docs/api/sql.md +348 -21
- package/docs/cli/pm.md +1 -1
- 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/index.d.ts +1 -0
- package/overrides.d.ts +6 -0
- package/package.json +1 -1
- package/sql.d.ts +805 -0
- package/sqlite.d.ts +104 -86
package/sqlite.d.ts
CHANGED
|
@@ -24,6 +24,66 @@
|
|
|
24
24
|
* | `null` | `NULL` |
|
|
25
25
|
*/
|
|
26
26
|
declare module "bun:sqlite" {
|
|
27
|
+
/**
|
|
28
|
+
* Options for {@link Database}
|
|
29
|
+
*/
|
|
30
|
+
export interface DatabaseOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Open the database as read-only (no write operations, no create).
|
|
33
|
+
*
|
|
34
|
+
* Equivalent to {@link constants.SQLITE_OPEN_READONLY}
|
|
35
|
+
*/
|
|
36
|
+
readonly?: boolean;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Allow creating a new database
|
|
40
|
+
*
|
|
41
|
+
* Equivalent to {@link constants.SQLITE_OPEN_CREATE}
|
|
42
|
+
*/
|
|
43
|
+
create?: boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Open the database as read-write
|
|
47
|
+
*
|
|
48
|
+
* Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
|
|
49
|
+
*/
|
|
50
|
+
readwrite?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* When set to `true`, integers are returned as `bigint` types.
|
|
54
|
+
*
|
|
55
|
+
* When set to `false`, integers are returned as `number` types and truncated to 52 bits.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
* @since v1.1.14
|
|
59
|
+
*/
|
|
60
|
+
safeIntegers?: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* When set to `false` or `undefined`:
|
|
64
|
+
* - Queries missing bound parameters will NOT throw an error
|
|
65
|
+
* - Bound named parameters in JavaScript need to exactly match the SQL query.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const db = new Database(":memory:", { strict: false });
|
|
70
|
+
* db.run("INSERT INTO foo (name) VALUES ($name)", { $name: "foo" });
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* When set to `true`:
|
|
74
|
+
* - Queries missing bound parameters will throw an error
|
|
75
|
+
* - Bound named parameters in JavaScript no longer need to be `$`, `:`, or `@`. The SQL query will remain prefixed.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const db = new Database(":memory:", { strict: true });
|
|
80
|
+
* db.run("INSERT INTO foo (name) VALUES ($name)", { name: "foo" });
|
|
81
|
+
* ```
|
|
82
|
+
* @since v1.1.14
|
|
83
|
+
*/
|
|
84
|
+
strict?: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
27
87
|
/**
|
|
28
88
|
* A SQLite3 database
|
|
29
89
|
*
|
|
@@ -53,8 +113,6 @@ declare module "bun:sqlite" {
|
|
|
53
113
|
* ```ts
|
|
54
114
|
* const db = new Database("mydb.sqlite", {readonly: true});
|
|
55
115
|
* ```
|
|
56
|
-
*
|
|
57
|
-
* @category Database
|
|
58
116
|
*/
|
|
59
117
|
export class Database implements Disposable {
|
|
60
118
|
/**
|
|
@@ -63,96 +121,19 @@ declare module "bun:sqlite" {
|
|
|
63
121
|
* @param filename The filename of the database to open. Pass an empty string (`""`) or `":memory:"` or undefined for an in-memory database.
|
|
64
122
|
* @param options defaults to `{readwrite: true, create: true}`. If a number, then it's treated as `SQLITE_OPEN_*` constant flags.
|
|
65
123
|
*/
|
|
66
|
-
constructor(
|
|
67
|
-
filename?: string,
|
|
68
|
-
options?:
|
|
69
|
-
| number
|
|
70
|
-
| {
|
|
71
|
-
/**
|
|
72
|
-
* Open the database as read-only (no write operations, no create).
|
|
73
|
-
*
|
|
74
|
-
* Equivalent to {@link constants.SQLITE_OPEN_READONLY}
|
|
75
|
-
*/
|
|
76
|
-
readonly?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Allow creating a new database
|
|
79
|
-
*
|
|
80
|
-
* Equivalent to {@link constants.SQLITE_OPEN_CREATE}
|
|
81
|
-
*/
|
|
82
|
-
create?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Open the database as read-write
|
|
85
|
-
*
|
|
86
|
-
* Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
|
|
87
|
-
*/
|
|
88
|
-
readwrite?: boolean;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* When set to `true`, integers are returned as `bigint` types.
|
|
92
|
-
*
|
|
93
|
-
* When set to `false`, integers are returned as `number` types and truncated to 52 bits.
|
|
94
|
-
*
|
|
95
|
-
* @default false
|
|
96
|
-
* @since v1.1.14
|
|
97
|
-
*/
|
|
98
|
-
safeIntegers?: boolean;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* When set to `false` or `undefined`:
|
|
102
|
-
* - Queries missing bound parameters will NOT throw an error
|
|
103
|
-
* - Bound named parameters in JavaScript need to exactly match the SQL query.
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* const db = new Database(":memory:", { strict: false });
|
|
108
|
-
* db.run("INSERT INTO foo (name) VALUES ($name)", { $name: "foo" });
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* When set to `true`:
|
|
112
|
-
* - Queries missing bound parameters will throw an error
|
|
113
|
-
* - Bound named parameters in JavaScript no longer need to be `$`, `:`, or `@`. The SQL query will remain prefixed.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```ts
|
|
117
|
-
* const db = new Database(":memory:", { strict: true });
|
|
118
|
-
* db.run("INSERT INTO foo (name) VALUES ($name)", { name: "foo" });
|
|
119
|
-
* ```
|
|
120
|
-
* @since v1.1.14
|
|
121
|
-
*/
|
|
122
|
-
strict?: boolean;
|
|
123
|
-
},
|
|
124
|
-
);
|
|
124
|
+
constructor(filename?: string, options?: number | DatabaseOptions);
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
+
* Open or create a SQLite3 databases
|
|
128
|
+
*
|
|
129
|
+
* @param filename The filename of the database to open. Pass an empty string (`""`) or `":memory:"` or undefined for an in-memory database.
|
|
130
|
+
* @param options defaults to `{readwrite: true, create: true}`. If a number, then it's treated as `SQLITE_OPEN_*` constant flags.
|
|
131
|
+
*
|
|
127
132
|
* This is an alias of `new Database()`
|
|
128
133
|
*
|
|
129
134
|
* See {@link Database}
|
|
130
135
|
*/
|
|
131
|
-
static open(
|
|
132
|
-
filename: string,
|
|
133
|
-
options?:
|
|
134
|
-
| number
|
|
135
|
-
| {
|
|
136
|
-
/**
|
|
137
|
-
* Open the database as read-only (no write operations, no create).
|
|
138
|
-
*
|
|
139
|
-
* Equivalent to {@link constants.SQLITE_OPEN_READONLY}
|
|
140
|
-
*/
|
|
141
|
-
readonly?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Allow creating a new database
|
|
144
|
-
*
|
|
145
|
-
* Equivalent to {@link constants.SQLITE_OPEN_CREATE}
|
|
146
|
-
*/
|
|
147
|
-
create?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Open the database as read-write
|
|
150
|
-
*
|
|
151
|
-
* Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
|
|
152
|
-
*/
|
|
153
|
-
readwrite?: boolean;
|
|
154
|
-
},
|
|
155
|
-
): Database;
|
|
136
|
+
static open(filename: string, options?: number | DatabaseOptions): Database;
|
|
156
137
|
|
|
157
138
|
/**
|
|
158
139
|
* Execute a SQL query **without returning any results**.
|
|
@@ -203,8 +184,11 @@ declare module "bun:sqlite" {
|
|
|
203
184
|
* @returns `Database` instance
|
|
204
185
|
*/
|
|
205
186
|
run<ParamsType extends SQLQueryBindings[]>(sql: string, ...bindings: ParamsType[]): Changes;
|
|
187
|
+
|
|
206
188
|
/**
|
|
207
189
|
* This is an alias of {@link Database.run}
|
|
190
|
+
*
|
|
191
|
+
* @deprecated Prefer {@link Database.run}
|
|
208
192
|
*/
|
|
209
193
|
exec<ParamsType extends SQLQueryBindings[]>(sql: string, ...bindings: ParamsType[]): Changes;
|
|
210
194
|
|
|
@@ -351,6 +335,16 @@ declare module "bun:sqlite" {
|
|
|
351
335
|
*/
|
|
352
336
|
static setCustomSQLite(path: string): boolean;
|
|
353
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Closes the database when using the async resource proposal
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```
|
|
343
|
+
* using db = new Database("myapp.db");
|
|
344
|
+
* doSomethingWithDatabase(db);
|
|
345
|
+
* // Automatically closed when `db` goes out of scope
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
354
348
|
[Symbol.dispose](): void;
|
|
355
349
|
|
|
356
350
|
/**
|
|
@@ -744,6 +738,30 @@ declare module "bun:sqlite" {
|
|
|
744
738
|
*/
|
|
745
739
|
values(...params: ParamsType): Array<Array<string | bigint | number | boolean | Uint8Array>>;
|
|
746
740
|
|
|
741
|
+
/**
|
|
742
|
+
* Execute the prepared statement and return all results as arrays of
|
|
743
|
+
* `Uint8Array`s.
|
|
744
|
+
*
|
|
745
|
+
* This is similar to `values()` but returns all values as Uint8Array
|
|
746
|
+
* objects, regardless of their original SQLite type.
|
|
747
|
+
*
|
|
748
|
+
* @param params optional values to bind to the statement. If omitted, the
|
|
749
|
+
* statement is run with the last bound values or no parameters if there are
|
|
750
|
+
* none.
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* ```ts
|
|
754
|
+
* const stmt = db.prepare("SELECT * FROM foo WHERE bar = ?");
|
|
755
|
+
*
|
|
756
|
+
* stmt.raw("baz");
|
|
757
|
+
* // => [[Uint8Array(24)]]
|
|
758
|
+
*
|
|
759
|
+
* stmt.raw();
|
|
760
|
+
* // => [[Uint8Array(24)]]
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
raw(...params: ParamsType): Array<Array<Uint8Array | null>>;
|
|
764
|
+
|
|
747
765
|
/**
|
|
748
766
|
* The names of the columns returned by the prepared statement.
|
|
749
767
|
* @example
|