bun-types-no-globals 1.2.23-canary.20250925T140721 → 1.2.23-canary.20250927T140547
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/lib/bun.d.ts +1 -0
- package/lib/redis.d.ts +218 -44
- package/lib/sql.d.ts +77 -0
- package/package.json +1 -1
package/lib/bun.d.ts
CHANGED
package/lib/redis.d.ts
CHANGED
|
@@ -52,21 +52,25 @@ declare module "bun" {
|
|
|
52
52
|
|
|
53
53
|
export namespace RedisClient {
|
|
54
54
|
type KeyLike = string | ArrayBufferView | Blob;
|
|
55
|
+
type StringPubSubListener = (message: string, channel: string) => void;
|
|
56
|
+
|
|
57
|
+
// Buffer subscriptions are not yet implemented
|
|
58
|
+
// type BufferPubSubListener = (message: Uint8Array<ArrayBuffer>, channel: string) => void;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export class RedisClient {
|
|
58
62
|
/**
|
|
59
63
|
* Creates a new Redis client
|
|
60
|
-
*
|
|
64
|
+
*
|
|
65
|
+
* @param url URL to connect to, defaults to `process.env.VALKEY_URL`,
|
|
66
|
+
* `process.env.REDIS_URL`, or `"valkey://localhost:6379"`
|
|
61
67
|
* @param options Additional options
|
|
62
68
|
*
|
|
63
69
|
* @example
|
|
64
70
|
* ```ts
|
|
65
|
-
* const
|
|
66
|
-
*
|
|
67
|
-
* await
|
|
68
|
-
*
|
|
69
|
-
* console.log(await valkey.get("hello"));
|
|
71
|
+
* const redis = new RedisClient();
|
|
72
|
+
* await redis.set("hello", "world");
|
|
73
|
+
* console.log(await redis.get("hello"));
|
|
70
74
|
* ```
|
|
71
75
|
*/
|
|
72
76
|
constructor(url?: string, options?: RedisOptions);
|
|
@@ -88,12 +92,14 @@ declare module "bun" {
|
|
|
88
92
|
|
|
89
93
|
/**
|
|
90
94
|
* Callback fired when the client disconnects from the Redis server
|
|
95
|
+
*
|
|
91
96
|
* @param error The error that caused the disconnection
|
|
92
97
|
*/
|
|
93
98
|
onclose: ((this: RedisClient, error: Error) => void) | null;
|
|
94
99
|
|
|
95
100
|
/**
|
|
96
101
|
* Connect to the Redis server
|
|
102
|
+
*
|
|
97
103
|
* @returns A promise that resolves when connected
|
|
98
104
|
*/
|
|
99
105
|
connect(): Promise<void>;
|
|
@@ -152,10 +158,12 @@ declare module "bun" {
|
|
|
152
158
|
set(key: RedisClient.KeyLike, value: RedisClient.KeyLike, px: "PX", milliseconds: number): Promise<"OK">;
|
|
153
159
|
|
|
154
160
|
/**
|
|
155
|
-
* Set key to hold the string value with expiration at a specific Unix
|
|
161
|
+
* Set key to hold the string value with expiration at a specific Unix
|
|
162
|
+
* timestamp
|
|
156
163
|
* @param key The key to set
|
|
157
164
|
* @param value The value to set
|
|
158
|
-
* @param exat Set the specified Unix time at which the key will expire, in
|
|
165
|
+
* @param exat Set the specified Unix time at which the key will expire, in
|
|
166
|
+
* seconds
|
|
159
167
|
* @returns Promise that resolves with "OK" on success
|
|
160
168
|
*/
|
|
161
169
|
set(key: RedisClient.KeyLike, value: RedisClient.KeyLike, exat: "EXAT", timestampSeconds: number): Promise<"OK">;
|
|
@@ -179,7 +187,8 @@ declare module "bun" {
|
|
|
179
187
|
* @param key The key to set
|
|
180
188
|
* @param value The value to set
|
|
181
189
|
* @param nx Only set the key if it does not already exist
|
|
182
|
-
* @returns Promise that resolves with "OK" on success, or null if the key
|
|
190
|
+
* @returns Promise that resolves with "OK" on success, or null if the key
|
|
191
|
+
* already exists
|
|
183
192
|
*/
|
|
184
193
|
set(key: RedisClient.KeyLike, value: RedisClient.KeyLike, nx: "NX"): Promise<"OK" | null>;
|
|
185
194
|
|
|
@@ -188,7 +197,8 @@ declare module "bun" {
|
|
|
188
197
|
* @param key The key to set
|
|
189
198
|
* @param value The value to set
|
|
190
199
|
* @param xx Only set the key if it already exists
|
|
191
|
-
* @returns Promise that resolves with "OK" on success, or null if the key
|
|
200
|
+
* @returns Promise that resolves with "OK" on success, or null if the key
|
|
201
|
+
* does not exist
|
|
192
202
|
*/
|
|
193
203
|
set(key: RedisClient.KeyLike, value: RedisClient.KeyLike, xx: "XX"): Promise<"OK" | null>;
|
|
194
204
|
|
|
@@ -196,8 +206,10 @@ declare module "bun" {
|
|
|
196
206
|
* Set key to hold the string value and return the old value
|
|
197
207
|
* @param key The key to set
|
|
198
208
|
* @param value The value to set
|
|
199
|
-
* @param get Return the old string stored at key, or null if key did not
|
|
200
|
-
*
|
|
209
|
+
* @param get Return the old string stored at key, or null if key did not
|
|
210
|
+
* exist
|
|
211
|
+
* @returns Promise that resolves with the old value, or null if key did not
|
|
212
|
+
* exist
|
|
201
213
|
*/
|
|
202
214
|
set(key: RedisClient.KeyLike, value: RedisClient.KeyLike, get: "GET"): Promise<string | null>;
|
|
203
215
|
|
|
@@ -243,7 +255,8 @@ declare module "bun" {
|
|
|
243
255
|
/**
|
|
244
256
|
* Determine if a key exists
|
|
245
257
|
* @param key The key to check
|
|
246
|
-
* @returns Promise that resolves with true if the key exists, false
|
|
258
|
+
* @returns Promise that resolves with true if the key exists, false
|
|
259
|
+
* otherwise
|
|
247
260
|
*/
|
|
248
261
|
exists(key: RedisClient.KeyLike): Promise<boolean>;
|
|
249
262
|
|
|
@@ -258,7 +271,8 @@ declare module "bun" {
|
|
|
258
271
|
/**
|
|
259
272
|
* Get the time to live for a key in seconds
|
|
260
273
|
* @param key The key to get the TTL for
|
|
261
|
-
* @returns Promise that resolves with the TTL, -1 if no expiry, or -2 if
|
|
274
|
+
* @returns Promise that resolves with the TTL, -1 if no expiry, or -2 if
|
|
275
|
+
* key doesn't exist
|
|
262
276
|
*/
|
|
263
277
|
ttl(key: RedisClient.KeyLike): Promise<number>;
|
|
264
278
|
|
|
@@ -290,7 +304,8 @@ declare module "bun" {
|
|
|
290
304
|
* Check if a value is a member of a set
|
|
291
305
|
* @param key The set key
|
|
292
306
|
* @param member The member to check
|
|
293
|
-
* @returns Promise that resolves with true if the member exists, false
|
|
307
|
+
* @returns Promise that resolves with true if the member exists, false
|
|
308
|
+
* otherwise
|
|
294
309
|
*/
|
|
295
310
|
sismember(key: RedisClient.KeyLike, member: string): Promise<boolean>;
|
|
296
311
|
|
|
@@ -298,7 +313,8 @@ declare module "bun" {
|
|
|
298
313
|
* Add a member to a set
|
|
299
314
|
* @param key The set key
|
|
300
315
|
* @param member The member to add
|
|
301
|
-
* @returns Promise that resolves with 1 if the member was added, 0 if it
|
|
316
|
+
* @returns Promise that resolves with 1 if the member was added, 0 if it
|
|
317
|
+
* already existed
|
|
302
318
|
*/
|
|
303
319
|
sadd(key: RedisClient.KeyLike, member: string): Promise<number>;
|
|
304
320
|
|
|
@@ -306,7 +322,8 @@ declare module "bun" {
|
|
|
306
322
|
* Remove a member from a set
|
|
307
323
|
* @param key The set key
|
|
308
324
|
* @param member The member to remove
|
|
309
|
-
* @returns Promise that resolves with 1 if the member was removed, 0 if it
|
|
325
|
+
* @returns Promise that resolves with 1 if the member was removed, 0 if it
|
|
326
|
+
* didn't exist
|
|
310
327
|
*/
|
|
311
328
|
srem(key: RedisClient.KeyLike, member: string): Promise<number>;
|
|
312
329
|
|
|
@@ -320,14 +337,16 @@ declare module "bun" {
|
|
|
320
337
|
/**
|
|
321
338
|
* Get a random member from a set
|
|
322
339
|
* @param key The set key
|
|
323
|
-
* @returns Promise that resolves with a random member, or null if the set
|
|
340
|
+
* @returns Promise that resolves with a random member, or null if the set
|
|
341
|
+
* is empty
|
|
324
342
|
*/
|
|
325
343
|
srandmember(key: RedisClient.KeyLike): Promise<string | null>;
|
|
326
344
|
|
|
327
345
|
/**
|
|
328
346
|
* Remove and return a random member from a set
|
|
329
347
|
* @param key The set key
|
|
330
|
-
* @returns Promise that resolves with the removed member, or null if the
|
|
348
|
+
* @returns Promise that resolves with the removed member, or null if the
|
|
349
|
+
* set is empty
|
|
331
350
|
*/
|
|
332
351
|
spop(key: RedisClient.KeyLike): Promise<string | null>;
|
|
333
352
|
|
|
@@ -394,28 +413,32 @@ declare module "bun" {
|
|
|
394
413
|
/**
|
|
395
414
|
* Remove and get the first element in a list
|
|
396
415
|
* @param key The list key
|
|
397
|
-
* @returns Promise that resolves with the first element, or null if the
|
|
416
|
+
* @returns Promise that resolves with the first element, or null if the
|
|
417
|
+
* list is empty
|
|
398
418
|
*/
|
|
399
419
|
lpop(key: RedisClient.KeyLike): Promise<string | null>;
|
|
400
420
|
|
|
401
421
|
/**
|
|
402
422
|
* Remove the expiration from a key
|
|
403
423
|
* @param key The key to persist
|
|
404
|
-
* @returns Promise that resolves with 1 if the timeout was removed, 0 if
|
|
424
|
+
* @returns Promise that resolves with 1 if the timeout was removed, 0 if
|
|
425
|
+
* the key doesn't exist or has no timeout
|
|
405
426
|
*/
|
|
406
427
|
persist(key: RedisClient.KeyLike): Promise<number>;
|
|
407
428
|
|
|
408
429
|
/**
|
|
409
430
|
* Get the expiration time of a key as a UNIX timestamp in milliseconds
|
|
410
431
|
* @param key The key to check
|
|
411
|
-
* @returns Promise that resolves with the timestamp, or -1 if the key has
|
|
432
|
+
* @returns Promise that resolves with the timestamp, or -1 if the key has
|
|
433
|
+
* no expiration, or -2 if the key doesn't exist
|
|
412
434
|
*/
|
|
413
435
|
pexpiretime(key: RedisClient.KeyLike): Promise<number>;
|
|
414
436
|
|
|
415
437
|
/**
|
|
416
438
|
* Get the time to live for a key in milliseconds
|
|
417
439
|
* @param key The key to check
|
|
418
|
-
* @returns Promise that resolves with the TTL in milliseconds, or -1 if the
|
|
440
|
+
* @returns Promise that resolves with the TTL in milliseconds, or -1 if the
|
|
441
|
+
* key has no expiration, or -2 if the key doesn't exist
|
|
419
442
|
*/
|
|
420
443
|
pttl(key: RedisClient.KeyLike): Promise<number>;
|
|
421
444
|
|
|
@@ -429,42 +452,48 @@ declare module "bun" {
|
|
|
429
452
|
/**
|
|
430
453
|
* Get the number of members in a set
|
|
431
454
|
* @param key The set key
|
|
432
|
-
* @returns Promise that resolves with the cardinality (number of elements)
|
|
455
|
+
* @returns Promise that resolves with the cardinality (number of elements)
|
|
456
|
+
* of the set
|
|
433
457
|
*/
|
|
434
458
|
scard(key: RedisClient.KeyLike): Promise<number>;
|
|
435
459
|
|
|
436
460
|
/**
|
|
437
461
|
* Get the length of the value stored in a key
|
|
438
462
|
* @param key The key to check
|
|
439
|
-
* @returns Promise that resolves with the length of the string value, or 0
|
|
463
|
+
* @returns Promise that resolves with the length of the string value, or 0
|
|
464
|
+
* if the key doesn't exist
|
|
440
465
|
*/
|
|
441
466
|
strlen(key: RedisClient.KeyLike): Promise<number>;
|
|
442
467
|
|
|
443
468
|
/**
|
|
444
469
|
* Get the number of members in a sorted set
|
|
445
470
|
* @param key The sorted set key
|
|
446
|
-
* @returns Promise that resolves with the cardinality (number of elements)
|
|
471
|
+
* @returns Promise that resolves with the cardinality (number of elements)
|
|
472
|
+
* of the sorted set
|
|
447
473
|
*/
|
|
448
474
|
zcard(key: RedisClient.KeyLike): Promise<number>;
|
|
449
475
|
|
|
450
476
|
/**
|
|
451
477
|
* Remove and return members with the highest scores in a sorted set
|
|
452
478
|
* @param key The sorted set key
|
|
453
|
-
* @returns Promise that resolves with the removed member and its score, or
|
|
479
|
+
* @returns Promise that resolves with the removed member and its score, or
|
|
480
|
+
* null if the set is empty
|
|
454
481
|
*/
|
|
455
482
|
zpopmax(key: RedisClient.KeyLike): Promise<string | null>;
|
|
456
483
|
|
|
457
484
|
/**
|
|
458
485
|
* Remove and return members with the lowest scores in a sorted set
|
|
459
486
|
* @param key The sorted set key
|
|
460
|
-
* @returns Promise that resolves with the removed member and its score, or
|
|
487
|
+
* @returns Promise that resolves with the removed member and its score, or
|
|
488
|
+
* null if the set is empty
|
|
461
489
|
*/
|
|
462
490
|
zpopmin(key: RedisClient.KeyLike): Promise<string | null>;
|
|
463
491
|
|
|
464
492
|
/**
|
|
465
493
|
* Get one or multiple random members from a sorted set
|
|
466
494
|
* @param key The sorted set key
|
|
467
|
-
* @returns Promise that resolves with a random member, or null if the set
|
|
495
|
+
* @returns Promise that resolves with a random member, or null if the set
|
|
496
|
+
* is empty
|
|
468
497
|
*/
|
|
469
498
|
zrandmember(key: RedisClient.KeyLike): Promise<string | null>;
|
|
470
499
|
|
|
@@ -472,7 +501,8 @@ declare module "bun" {
|
|
|
472
501
|
* Append a value to a key
|
|
473
502
|
* @param key The key to append to
|
|
474
503
|
* @param value The value to append
|
|
475
|
-
* @returns Promise that resolves with the length of the string after the
|
|
504
|
+
* @returns Promise that resolves with the length of the string after the
|
|
505
|
+
* append operation
|
|
476
506
|
*/
|
|
477
507
|
append(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
|
|
478
508
|
|
|
@@ -480,7 +510,8 @@ declare module "bun" {
|
|
|
480
510
|
* Set the value of a key and return its old value
|
|
481
511
|
* @param key The key to set
|
|
482
512
|
* @param value The value to set
|
|
483
|
-
* @returns Promise that resolves with the old value, or null if the key
|
|
513
|
+
* @returns Promise that resolves with the old value, or null if the key
|
|
514
|
+
* didn't exist
|
|
484
515
|
*/
|
|
485
516
|
getset(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<string | null>;
|
|
486
517
|
|
|
@@ -488,7 +519,8 @@ declare module "bun" {
|
|
|
488
519
|
* Prepend one or multiple values to a list
|
|
489
520
|
* @param key The list key
|
|
490
521
|
* @param value The value to prepend
|
|
491
|
-
* @returns Promise that resolves with the length of the list after the push
|
|
522
|
+
* @returns Promise that resolves with the length of the list after the push
|
|
523
|
+
* operation
|
|
492
524
|
*/
|
|
493
525
|
lpush(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
|
|
494
526
|
|
|
@@ -496,7 +528,8 @@ declare module "bun" {
|
|
|
496
528
|
* Prepend a value to a list, only if the list exists
|
|
497
529
|
* @param key The list key
|
|
498
530
|
* @param value The value to prepend
|
|
499
|
-
* @returns Promise that resolves with the length of the list after the push
|
|
531
|
+
* @returns Promise that resolves with the length of the list after the push
|
|
532
|
+
* operation, or 0 if the list doesn't exist
|
|
500
533
|
*/
|
|
501
534
|
lpushx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
|
|
502
535
|
|
|
@@ -504,7 +537,8 @@ declare module "bun" {
|
|
|
504
537
|
* Add one or more members to a HyperLogLog
|
|
505
538
|
* @param key The HyperLogLog key
|
|
506
539
|
* @param element The element to add
|
|
507
|
-
* @returns Promise that resolves with 1 if the HyperLogLog was altered, 0
|
|
540
|
+
* @returns Promise that resolves with 1 if the HyperLogLog was altered, 0
|
|
541
|
+
* otherwise
|
|
508
542
|
*/
|
|
509
543
|
pfadd(key: RedisClient.KeyLike, element: string): Promise<number>;
|
|
510
544
|
|
|
@@ -512,7 +546,8 @@ declare module "bun" {
|
|
|
512
546
|
* Append one or multiple values to a list
|
|
513
547
|
* @param key The list key
|
|
514
548
|
* @param value The value to append
|
|
515
|
-
* @returns Promise that resolves with the length of the list after the push
|
|
549
|
+
* @returns Promise that resolves with the length of the list after the push
|
|
550
|
+
* operation
|
|
516
551
|
*/
|
|
517
552
|
rpush(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
|
|
518
553
|
|
|
@@ -520,7 +555,8 @@ declare module "bun" {
|
|
|
520
555
|
* Append a value to a list, only if the list exists
|
|
521
556
|
* @param key The list key
|
|
522
557
|
* @param value The value to append
|
|
523
|
-
* @returns Promise that resolves with the length of the list after the push
|
|
558
|
+
* @returns Promise that resolves with the length of the list after the push
|
|
559
|
+
* operation, or 0 if the list doesn't exist
|
|
524
560
|
*/
|
|
525
561
|
rpushx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
|
|
526
562
|
|
|
@@ -528,7 +564,8 @@ declare module "bun" {
|
|
|
528
564
|
* Set the value of a key, only if the key does not exist
|
|
529
565
|
* @param key The key to set
|
|
530
566
|
* @param value The value to set
|
|
531
|
-
* @returns Promise that resolves with 1 if the key was set, 0 if the key
|
|
567
|
+
* @returns Promise that resolves with 1 if the key was set, 0 if the key
|
|
568
|
+
* was not set
|
|
532
569
|
*/
|
|
533
570
|
setnx(key: RedisClient.KeyLike, value: RedisClient.KeyLike): Promise<number>;
|
|
534
571
|
|
|
@@ -536,14 +573,16 @@ declare module "bun" {
|
|
|
536
573
|
* Get the score associated with the given member in a sorted set
|
|
537
574
|
* @param key The sorted set key
|
|
538
575
|
* @param member The member to get the score for
|
|
539
|
-
* @returns Promise that resolves with the score of the member as a string,
|
|
576
|
+
* @returns Promise that resolves with the score of the member as a string,
|
|
577
|
+
* or null if the member or key doesn't exist
|
|
540
578
|
*/
|
|
541
579
|
zscore(key: RedisClient.KeyLike, member: string): Promise<string | null>;
|
|
542
580
|
|
|
543
581
|
/**
|
|
544
582
|
* Get the values of all specified keys
|
|
545
583
|
* @param keys The keys to get
|
|
546
|
-
* @returns Promise that resolves with an array of values, with null for
|
|
584
|
+
* @returns Promise that resolves with an array of values, with null for
|
|
585
|
+
* keys that don't exist
|
|
547
586
|
*/
|
|
548
587
|
mget(...keys: RedisClient.KeyLike[]): Promise<(string | null)[]>;
|
|
549
588
|
|
|
@@ -557,37 +596,46 @@ declare module "bun" {
|
|
|
557
596
|
/**
|
|
558
597
|
* Return a serialized version of the value stored at the specified key
|
|
559
598
|
* @param key The key to dump
|
|
560
|
-
* @returns Promise that resolves with the serialized value, or null if the
|
|
599
|
+
* @returns Promise that resolves with the serialized value, or null if the
|
|
600
|
+
* key doesn't exist
|
|
561
601
|
*/
|
|
562
602
|
dump(key: RedisClient.KeyLike): Promise<string | null>;
|
|
563
603
|
|
|
564
604
|
/**
|
|
565
605
|
* Get the expiration time of a key as a UNIX timestamp in seconds
|
|
606
|
+
*
|
|
566
607
|
* @param key The key to check
|
|
567
|
-
* @returns Promise that resolves with the timestamp, or -1 if the key has
|
|
608
|
+
* @returns Promise that resolves with the timestamp, or -1 if the key has
|
|
609
|
+
* no expiration, or -2 if the key doesn't exist
|
|
568
610
|
*/
|
|
569
611
|
expiretime(key: RedisClient.KeyLike): Promise<number>;
|
|
570
612
|
|
|
571
613
|
/**
|
|
572
614
|
* Get the value of a key and delete the key
|
|
615
|
+
*
|
|
573
616
|
* @param key The key to get and delete
|
|
574
|
-
* @returns Promise that resolves with the value of the key, or null if the
|
|
617
|
+
* @returns Promise that resolves with the value of the key, or null if the
|
|
618
|
+
* key doesn't exist
|
|
575
619
|
*/
|
|
576
620
|
getdel(key: RedisClient.KeyLike): Promise<string | null>;
|
|
577
621
|
|
|
578
622
|
/**
|
|
579
623
|
* Get the value of a key and optionally set its expiration
|
|
624
|
+
*
|
|
580
625
|
* @param key The key to get
|
|
581
|
-
* @returns Promise that resolves with the value of the key, or null if the
|
|
626
|
+
* @returns Promise that resolves with the value of the key, or null if the
|
|
627
|
+
* key doesn't exist
|
|
582
628
|
*/
|
|
583
629
|
getex(key: RedisClient.KeyLike): Promise<string | null>;
|
|
584
630
|
|
|
585
631
|
/**
|
|
586
632
|
* Get the value of a key and set its expiration in seconds
|
|
633
|
+
*
|
|
587
634
|
* @param key The key to get
|
|
588
635
|
* @param ex Set the specified expire time, in seconds
|
|
589
636
|
* @param seconds The number of seconds until expiration
|
|
590
|
-
* @returns Promise that resolves with the value of the key, or null if the
|
|
637
|
+
* @returns Promise that resolves with the value of the key, or null if the
|
|
638
|
+
* key doesn't exist
|
|
591
639
|
*/
|
|
592
640
|
getex(key: RedisClient.KeyLike, ex: "EX", seconds: number): Promise<string | null>;
|
|
593
641
|
|
|
@@ -602,6 +650,7 @@ declare module "bun" {
|
|
|
602
650
|
|
|
603
651
|
/**
|
|
604
652
|
* Get the value of a key and set its expiration at a specific Unix timestamp in seconds
|
|
653
|
+
*
|
|
605
654
|
* @param key The key to get
|
|
606
655
|
* @param exat Set the specified Unix time at which the key will expire, in seconds
|
|
607
656
|
* @param timestampSeconds The Unix timestamp in seconds
|
|
@@ -611,6 +660,7 @@ declare module "bun" {
|
|
|
611
660
|
|
|
612
661
|
/**
|
|
613
662
|
* Get the value of a key and set its expiration at a specific Unix timestamp in milliseconds
|
|
663
|
+
*
|
|
614
664
|
* @param key The key to get
|
|
615
665
|
* @param pxat Set the specified Unix time at which the key will expire, in milliseconds
|
|
616
666
|
* @param timestampMilliseconds The Unix timestamp in milliseconds
|
|
@@ -620,6 +670,7 @@ declare module "bun" {
|
|
|
620
670
|
|
|
621
671
|
/**
|
|
622
672
|
* Get the value of a key and remove its expiration
|
|
673
|
+
*
|
|
623
674
|
* @param key The key to get
|
|
624
675
|
* @param persist Remove the expiration from the key
|
|
625
676
|
* @returns Promise that resolves with the value of the key, or null if the key doesn't exist
|
|
@@ -634,10 +685,133 @@ declare module "bun" {
|
|
|
634
685
|
|
|
635
686
|
/**
|
|
636
687
|
* Ping the server with a message
|
|
688
|
+
*
|
|
637
689
|
* @param message The message to send to the server
|
|
638
690
|
* @returns Promise that resolves with the message if the server is reachable, or throws an error if the server is not reachable
|
|
639
691
|
*/
|
|
640
692
|
ping(message: RedisClient.KeyLike): Promise<string>;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Publish a message to a Redis channel.
|
|
696
|
+
*
|
|
697
|
+
* @param channel The channel to publish to.
|
|
698
|
+
* @param message The message to publish.
|
|
699
|
+
*
|
|
700
|
+
* @returns The number of clients that received the message. Note that in a
|
|
701
|
+
* cluster this returns the total number of clients in the same node.
|
|
702
|
+
*/
|
|
703
|
+
publish(channel: string, message: string): Promise<number>;
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Subscribe to a Redis channel.
|
|
707
|
+
*
|
|
708
|
+
* Subscribing disables automatic pipelining, so all commands will be
|
|
709
|
+
* received immediately.
|
|
710
|
+
*
|
|
711
|
+
* Subscribing moves the channel to a dedicated subscription state which
|
|
712
|
+
* prevents most other commands from being executed until unsubscribed. Only
|
|
713
|
+
* {@link ping `.ping()`}, {@link subscribe `.subscribe()`}, and
|
|
714
|
+
* {@link unsubscribe `.unsubscribe()`} are legal to invoke in a subscribed
|
|
715
|
+
* upon channel.
|
|
716
|
+
*
|
|
717
|
+
* @param channel The channel to subscribe to.
|
|
718
|
+
* @param listener The listener to call when a message is received on the
|
|
719
|
+
* channel. The listener will receive the message as the first argument and
|
|
720
|
+
* the channel as the second argument.
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```ts
|
|
724
|
+
* await client.subscribe("my-channel", (message, channel) => {
|
|
725
|
+
* console.log(`Received message on ${channel}: ${message}`);
|
|
726
|
+
* });
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
subscribe(channel: string, listener: RedisClient.StringPubSubListener): Promise<number>;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Subscribe to multiple Redis channels.
|
|
733
|
+
*
|
|
734
|
+
* Subscribing disables automatic pipelining, so all commands will be
|
|
735
|
+
* received immediately.
|
|
736
|
+
*
|
|
737
|
+
* Subscribing moves the channels to a dedicated subscription state in which
|
|
738
|
+
* only a limited set of commands can be executed.
|
|
739
|
+
*
|
|
740
|
+
* @param channels An array of channels to subscribe to.
|
|
741
|
+
* @param listener The listener to call when a message is received on any of
|
|
742
|
+
* the subscribed channels. The listener will receive the message as the
|
|
743
|
+
* first argument and the channel as the second argument.
|
|
744
|
+
*/
|
|
745
|
+
subscribe(channels: string[], listener: RedisClient.StringPubSubListener): Promise<number>;
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Unsubscribe from a singular Redis channel.
|
|
749
|
+
*
|
|
750
|
+
* @param channel The channel to unsubscribe from.
|
|
751
|
+
*
|
|
752
|
+
* If there are no more channels subscribed to, the client automatically
|
|
753
|
+
* re-enables pipelining if it was previously enabled.
|
|
754
|
+
*
|
|
755
|
+
* Unsubscribing moves the channel back to a normal state out of the
|
|
756
|
+
* subscription state if all channels have been unsubscribed from. For
|
|
757
|
+
* further details on the subscription state, see
|
|
758
|
+
* {@link subscribe `.subscribe()`}.
|
|
759
|
+
*/
|
|
760
|
+
unsubscribe(channel: string): Promise<void>;
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Remove a listener from a given Redis channel.
|
|
764
|
+
*
|
|
765
|
+
* If there are no more channels subscribed to, the client automatically
|
|
766
|
+
* re-enables pipelining if it was previously enabled.
|
|
767
|
+
*
|
|
768
|
+
* Unsubscribing moves the channel back to a normal state out of the
|
|
769
|
+
* subscription state if all channels have been unsubscribed from. For
|
|
770
|
+
* further details on the subscription state, see
|
|
771
|
+
* {@link subscribe `.subscribe()`}.
|
|
772
|
+
*
|
|
773
|
+
* @param channel The channel to unsubscribe from.
|
|
774
|
+
* @param listener The listener to remove. This is tested against
|
|
775
|
+
* referential equality so you must pass the exact same listener instance as
|
|
776
|
+
* when subscribing.
|
|
777
|
+
*/
|
|
778
|
+
unsubscribe(channel: string, listener: RedisClient.StringPubSubListener): Promise<void>;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Unsubscribe from all registered Redis channels.
|
|
782
|
+
*
|
|
783
|
+
* The client will automatically re-enable pipelining if it was previously
|
|
784
|
+
* enabled.
|
|
785
|
+
*
|
|
786
|
+
* Unsubscribing moves the channel back to a normal state out of the
|
|
787
|
+
* subscription state if all channels have been unsubscribed from. For
|
|
788
|
+
* further details on the subscription state, see
|
|
789
|
+
* {@link subscribe `.subscribe()`}.
|
|
790
|
+
*/
|
|
791
|
+
unsubscribe(): Promise<void>;
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Unsubscribe from multiple Redis channels.
|
|
795
|
+
*
|
|
796
|
+
* @param channels An array of channels to unsubscribe from.
|
|
797
|
+
*
|
|
798
|
+
* If there are no more channels subscribed to, the client automatically
|
|
799
|
+
* re-enables pipelining if it was previously enabled.
|
|
800
|
+
*
|
|
801
|
+
* Unsubscribing moves the channel back to a normal state out of the
|
|
802
|
+
* subscription state if all channels have been unsubscribed from. For
|
|
803
|
+
* further details on the subscription state, see
|
|
804
|
+
* {@link subscribe `.subscribe()`}.
|
|
805
|
+
*/
|
|
806
|
+
unsubscribe(channels: string[]): Promise<void>;
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* @brief Create a new RedisClient instance with the same configuration as
|
|
810
|
+
* the current instance.
|
|
811
|
+
*
|
|
812
|
+
* This will open up a new connection to the Redis server.
|
|
813
|
+
*/
|
|
814
|
+
duplicate(): Promise<RedisClient>;
|
|
641
815
|
}
|
|
642
816
|
|
|
643
817
|
/**
|
package/lib/sql.d.ts
CHANGED
|
@@ -12,6 +12,68 @@ declare module "bun" {
|
|
|
12
12
|
release(): void;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
type ArrayType =
|
|
16
|
+
| "BOOLEAN"
|
|
17
|
+
| "BYTEA"
|
|
18
|
+
| "CHAR"
|
|
19
|
+
| "NAME"
|
|
20
|
+
| "TEXT"
|
|
21
|
+
| "CHAR"
|
|
22
|
+
| "VARCHAR"
|
|
23
|
+
| "SMALLINT"
|
|
24
|
+
| "INT2VECTOR"
|
|
25
|
+
| "INTEGER"
|
|
26
|
+
| "INT"
|
|
27
|
+
| "BIGINT"
|
|
28
|
+
| "REAL"
|
|
29
|
+
| "DOUBLE PRECISION"
|
|
30
|
+
| "NUMERIC"
|
|
31
|
+
| "MONEY"
|
|
32
|
+
| "OID"
|
|
33
|
+
| "TID"
|
|
34
|
+
| "XID"
|
|
35
|
+
| "CID"
|
|
36
|
+
| "JSON"
|
|
37
|
+
| "JSONB"
|
|
38
|
+
| "JSONPATH"
|
|
39
|
+
| "XML"
|
|
40
|
+
| "POINT"
|
|
41
|
+
| "LSEG"
|
|
42
|
+
| "PATH"
|
|
43
|
+
| "BOX"
|
|
44
|
+
| "POLYGON"
|
|
45
|
+
| "LINE"
|
|
46
|
+
| "CIRCLE"
|
|
47
|
+
| "CIDR"
|
|
48
|
+
| "MACADDR"
|
|
49
|
+
| "INET"
|
|
50
|
+
| "MACADDR8"
|
|
51
|
+
| "DATE"
|
|
52
|
+
| "TIME"
|
|
53
|
+
| "TIMESTAMP"
|
|
54
|
+
| "TIMESTAMPTZ"
|
|
55
|
+
| "INTERVAL"
|
|
56
|
+
| "TIMETZ"
|
|
57
|
+
| "BIT"
|
|
58
|
+
| "VARBIT"
|
|
59
|
+
| "ACLITEM"
|
|
60
|
+
| "PG_DATABASE"
|
|
61
|
+
| (string & {});
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Represents a SQL array parameter
|
|
65
|
+
*/
|
|
66
|
+
interface SQLArrayParameter {
|
|
67
|
+
/**
|
|
68
|
+
* The serialized values of the array parameter
|
|
69
|
+
*/
|
|
70
|
+
serializedValues: string;
|
|
71
|
+
/**
|
|
72
|
+
* The type of the array parameter
|
|
73
|
+
*/
|
|
74
|
+
arrayType: ArrayType;
|
|
75
|
+
}
|
|
76
|
+
|
|
15
77
|
/**
|
|
16
78
|
* Represents a client within a transaction context Extends SQL with savepoint
|
|
17
79
|
* functionality
|
|
@@ -630,6 +692,21 @@ declare module "bun" {
|
|
|
630
692
|
*/
|
|
631
693
|
reserve(): Promise<ReservedSQL>;
|
|
632
694
|
|
|
695
|
+
/**
|
|
696
|
+
* Creates a new SQL array parameter
|
|
697
|
+
* @param values - The values to create the array parameter from
|
|
698
|
+
* @param typeNameOrTypeID - The type name or type ID to create the array parameter from, if omitted it will default to JSON
|
|
699
|
+
* @returns A new SQL array parameter
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```ts
|
|
703
|
+
* const array = sql.array([1, 2, 3], "INT");
|
|
704
|
+
* await sql`CREATE TABLE users_posts (user_id INT, posts_id INT[])`;
|
|
705
|
+
* await sql`INSERT INTO users_posts (user_id, posts_id) VALUES (${user.id}, ${array})`;
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
array(values: any[], typeNameOrTypeID?: number | ArrayType): SQLArrayParameter;
|
|
709
|
+
|
|
633
710
|
/**
|
|
634
711
|
* Begins a new transaction.
|
|
635
712
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-types-no-globals",
|
|
3
|
-
"version": "1.2.23-canary.
|
|
3
|
+
"version": "1.2.23-canary.20250927T140547",
|
|
4
4
|
"main": "./generator/index.ts",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"description": "TypeScript type definitions for Bun without global types pollution",
|