@upstash/redis 1.0.0 → 1.0.3

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.
@@ -1,670 +0,0 @@
1
- import { HttpClient } from './http';
2
-
3
- /**
4
- * Command offers default (de)serialization and the exec method to all commands.
5
- *
6
- * TData represents what the user will enter or receive,
7
- * TResult is the raw data returned from upstash, which may need to be transformed or parsed.
8
- */
9
- declare class Command<TData, TResult> {
10
- readonly command: string[];
11
- deserialize: (result: TResult) => TData;
12
- /**
13
- * Create a new command instance.
14
- *
15
- * You can define a custom `deserialize` function. By default we try to deserialize as json.
16
- */
17
- constructor(command: (string | unknown)[], opts?: {
18
- deserialize?: (result: TResult) => TData;
19
- });
20
- /**
21
- * Execute the command using a client.
22
- */
23
- exec(client: HttpClient): Promise<TData>;
24
- }
25
-
26
- /**
27
- * @see https://redis.io/commands/append
28
- */
29
- declare class AppendCommand extends Command<number, number> {
30
- constructor(key: string, value: string);
31
- }
32
-
33
- /**
34
- * @see https://redis.io/commands/bitcount
35
- */
36
- declare class BitCountCommand extends Command<number, number> {
37
- constructor(key: string, start?: never, end?: never);
38
- constructor(key: string, start: number, end: number);
39
- }
40
-
41
- /**
42
- * @see https://redis.io/commands/bitpos
43
- */
44
- declare class BitPosCommand extends Command<number, number> {
45
- constructor(key: string, start: number, end: number);
46
- }
47
-
48
- /**
49
- * @see https://redis.io/commands/decr
50
- */
51
- declare class DecrCommand extends Command<number, number> {
52
- constructor(key: string);
53
- }
54
-
55
- /**
56
- * @see https://redis.io/commands/decrby
57
- */
58
- declare class DecrByCommand extends Command<number, number> {
59
- constructor(key: string, decrement: number);
60
- }
61
-
62
- declare type NonEmptyArray<T> = [T, ...T[]];
63
- declare type CommandArgs<TCommand extends new (...args: any) => any> = ConstructorParameters<TCommand>;
64
-
65
- /**
66
- * @see https://redis.io/commands/del
67
- */
68
- declare class DelCommand extends Command<number, number> {
69
- constructor(...keys: NonEmptyArray<string>);
70
- }
71
-
72
- /**
73
- * @see https://redis.io/commands/echo
74
- */
75
- declare class EchoCommand extends Command<string, string> {
76
- constructor(message: string);
77
- }
78
-
79
- /**
80
- * @see https://redis.io/commands/exists
81
- */
82
- declare class ExistsCommand extends Command<0 | 1, "0" | "1"> {
83
- constructor(...keys: NonEmptyArray<string>);
84
- }
85
-
86
- /**
87
- * @see https://redis.io/commands/expire
88
- */
89
- declare class ExpireCommand extends Command<0 | 1, "0" | "1"> {
90
- constructor(key: string, seconds: number);
91
- }
92
-
93
- /**
94
- * @see https://redis.io/commands/expireat
95
- */
96
- declare class ExpireAtCommand extends Command<0 | 1, "0" | "1"> {
97
- constructor(key: string, unix: number);
98
- }
99
-
100
- /**
101
- * @see https://redis.io/commands/flushall
102
- */
103
- declare class FlushAllCommand extends Command<"OK", "OK"> {
104
- constructor(opts?: {
105
- async?: boolean;
106
- });
107
- }
108
-
109
- /**
110
- * @see https://redis.io/commands/flushdb
111
- */
112
- declare class FlushDBCommand extends Command<"OK", "OK"> {
113
- constructor(opts?: {
114
- async?: boolean;
115
- });
116
- }
117
-
118
- /**
119
- * @see https://redis.io/commands/get
120
- */
121
- declare class GetCommand<TData = string> extends Command<TData | null, unknown | null> {
122
- constructor(key: string);
123
- }
124
-
125
- /**
126
- * @see https://redis.io/commands/getbit
127
- */
128
- declare class GetBitCommand extends Command<0 | 1, "0" | "1"> {
129
- constructor(key: string, offset: number);
130
- }
131
-
132
- /**
133
- * @see https://redis.io/commands/getrange
134
- */
135
- declare class GetRangeCommand extends Command<string, string> {
136
- constructor(key: string, start: number, end: number);
137
- }
138
-
139
- /**
140
- * @see https://redis.io/commands/hdel
141
- */
142
- declare class HDelCommand extends Command<0 | 1, "0" | "1"> {
143
- constructor(key: string, field: string);
144
- }
145
-
146
- /**
147
- * @see https://redis.io/commands/hexists
148
- */
149
- declare class HExistsCommand extends Command<number, number> {
150
- constructor(key: string, field: string);
151
- }
152
-
153
- /**
154
- * @see https://redis.io/commands/hget
155
- */
156
- declare class HGetCommand<TData> extends Command<TData | null, unknown | null> {
157
- constructor(key: string, field: string);
158
- }
159
-
160
- /**
161
- * @see https://redis.io/commands/hgetall
162
- */
163
- declare class HGetAllCommand<TData extends Record<string, unknown>> extends Command<TData | null, unknown | null> {
164
- constructor(key: string);
165
- }
166
-
167
- /**
168
- * @see https://redis.io/commands/hincrby
169
- */
170
- declare class HIncrByCommand extends Command<number, number> {
171
- constructor(key: string, field: string, increment: number);
172
- }
173
-
174
- /**
175
- * @see https://redis.io/commands/hincrbyfloat
176
- */
177
- declare class HIncrByFloatCommand extends Command<number, number> {
178
- constructor(key: string, field: string, increment: number);
179
- }
180
-
181
- /**
182
- * @see https://redis.io/commands/hkeys
183
- */
184
- declare class HKeysCommand extends Command<string[], string[]> {
185
- constructor(key: string);
186
- }
187
-
188
- /**
189
- * @see https://redis.io/commands/hlen
190
- */
191
- declare class HLenCommand extends Command<number, number> {
192
- constructor(key: string);
193
- }
194
-
195
- /**
196
- * hmget returns an object of all requested fields from a hash
197
- * The field values are returned as an object like this:
198
- * ```ts
199
- * {[fieldName: string]: T | null}
200
- * ```
201
- *
202
- * In case the hash does not exist or all fields are empty `null` is returned
203
- *
204
- * @see https://redis.io/commands/hmget
205
- */
206
- declare class HMGetCommand<TData extends Record<string, unknown>> extends Command<TData | null, (string | null)[]> {
207
- constructor(key: string, ...fields: string[]);
208
- }
209
-
210
- declare type ScanCommandOptions = {
211
- match?: string;
212
- count?: number;
213
- };
214
- /**
215
- * @see https://redis.io/commands/scan
216
- */
217
- declare class ScanCommand extends Command<[number, string[]], [number, string[]]> {
218
- constructor(cursor: number, opts?: ScanCommandOptions);
219
- }
220
-
221
- /**
222
- * @see https://redis.io/commands/hscan
223
- */
224
- declare class HScanCommand extends Command<[
225
- number,
226
- (string | number)[]
227
- ], [
228
- number,
229
- (string | number)[]
230
- ]> {
231
- constructor(key: string, cursor: number, opts?: ScanCommandOptions);
232
- }
233
-
234
- /**
235
- * @see https://redis.io/commands/hstrlen
236
- */
237
- declare class HStrLenCommand extends Command<number, number> {
238
- constructor(key: string, field: string);
239
- }
240
-
241
- /**
242
- * @see https://redis.io/commands/hvals
243
- */
244
- declare class HValsCommand<TData extends unknown[]> extends Command<TData, unknown[]> {
245
- constructor(key: string);
246
- }
247
-
248
- /**
249
- * @see https://redis.io/commands/incr
250
- */
251
- declare class IncrCommand extends Command<number, number> {
252
- constructor(key: string);
253
- }
254
-
255
- /**
256
- * @see https://redis.io/commands/incrby
257
- */
258
- declare class IncrByCommand extends Command<number, number> {
259
- constructor(key: string, value: number);
260
- }
261
-
262
- /**
263
- * @see https://redis.io/commands/incrbyfloat
264
- */
265
- declare class IncrByFloatCommand extends Command<number, number> {
266
- constructor(key: string, value: number);
267
- }
268
-
269
- /**
270
- * @see https://redis.io/commands/keys
271
- */
272
- declare class KeysCommand extends Command<string[], string[]> {
273
- constructor(pattern: string);
274
- }
275
-
276
- declare class LIndexCommand<TData = string> extends Command<TData | null, unknown | null> {
277
- constructor(key: string, index: number);
278
- }
279
-
280
- /**
281
- * @see https://redis.io/commands/llen
282
- */
283
- declare class LLenCommand extends Command<number, number> {
284
- constructor(key: string);
285
- }
286
-
287
- /**
288
- * @see https://redis.io/commands/lpop
289
- */
290
- declare class LPopCommand<TData = string> extends Command<TData | null, unknown | null> {
291
- constructor(key: string);
292
- }
293
-
294
- declare class LRangeCommand<TData = string> extends Command<TData[], unknown[]> {
295
- constructor(key: string, start: number, end: number);
296
- }
297
-
298
- declare class LTrimCommand extends Command<"OK", "OK"> {
299
- constructor(key: string, start: number, end: number);
300
- }
301
-
302
- /**
303
- * @see https://redis.io/commands/mget
304
- */
305
- declare class MGetCommand<TData extends unknown[]> extends Command<TData, (string | null)[]> {
306
- constructor(...keys: [string, ...string[]]);
307
- }
308
-
309
- /**
310
- * @see https://redis.io/commands/persist
311
- */
312
- declare class PersistCommand extends Command<0 | 1, "0" | "1"> {
313
- constructor(key: string);
314
- }
315
-
316
- /**
317
- * @see https://redis.io/commands/pexpire
318
- */
319
- declare class PExpireCommand extends Command<0 | 1, "0" | "1"> {
320
- constructor(key: string, milliseconds: number);
321
- }
322
-
323
- /**
324
- * @see https://redis.io/commands/pexpireat
325
- */
326
- declare class PExpireAtCommand extends Command<0 | 1, "0" | "1"> {
327
- constructor(key: string, unix: number);
328
- }
329
-
330
- /**
331
- * @see https://redis.io/commands/ping
332
- */
333
- declare class PingCommand extends Command<string | "PONG", string | "PONG"> {
334
- constructor(message?: string);
335
- }
336
-
337
- /**
338
- * @see https://redis.io/commands/pttl
339
- */
340
- declare class PTtlCommand extends Command<number, number> {
341
- constructor(key: string);
342
- }
343
-
344
- /**
345
- * @see https://redis.io/commands/rename
346
- */
347
- declare class RenameCommand extends Command<"OK", "OK"> {
348
- constructor(source: string, destination: string);
349
- }
350
-
351
- /**
352
- * @see https://redis.io/commands/renamenx
353
- */
354
- declare class RenameNXCommand extends Command<0 | 1, "0" | "1"> {
355
- constructor(source: string, destination: string);
356
- }
357
-
358
- /**
359
- * @see https://redis.io/commands/rpop
360
- */
361
- declare class RPopCommand<TData = string> extends Command<TData | null, unknown | null> {
362
- constructor(key: string);
363
- }
364
-
365
- /**
366
- * @see https://redis.io/commands/scard
367
- */
368
- declare class SCardCommand extends Command<number, number> {
369
- constructor(key: string);
370
- }
371
-
372
- /**
373
- * @see https://redis.io/commands/sdiff
374
- */
375
- declare class SDiffCommand<TData> extends Command<TData[], unknown[]> {
376
- constructor(key: string, ...keys: string[]);
377
- }
378
-
379
- /**
380
- * @see https://redis.io/commands/sdiffstpre
381
- */
382
- declare class SDiffStoreCommand extends Command<number, number> {
383
- constructor(destination: string, ...keys: NonEmptyArray<string>);
384
- }
385
-
386
- declare type SetCommandOptions = ({
387
- ex: number;
388
- px?: never;
389
- } | {
390
- ex?: never;
391
- px: number;
392
- } | {
393
- ex?: never;
394
- px?: never;
395
- }) & ({
396
- nx: true;
397
- xx?: never;
398
- } | {
399
- xx: true;
400
- nx?: never;
401
- } | {
402
- xx?: never;
403
- nx?: never;
404
- });
405
- /**
406
- * @see https://redis.io/commands/set
407
- */
408
- declare class SetCommand<TData, TResult = "OK"> extends Command<TData, TResult> {
409
- constructor(key: string, value: TData, opts?: SetCommandOptions);
410
- }
411
-
412
- /**
413
- * @see https://redis.io/commands/setbit
414
- */
415
- declare class SetBitCommand extends Command<0 | 1, "0" | "1"> {
416
- constructor(key: string, offset: number, value: 0 | 1);
417
- }
418
-
419
- /**
420
- * @see https://redis.io/commands/setrange
421
- */
422
- declare class SetRangeCommand extends Command<number, number> {
423
- constructor(key: string, offset: number, value: string);
424
- }
425
-
426
- /**
427
- * @see https://redis.io/commands/sinter
428
- */
429
- declare class SInterCommand<TData = string> extends Command<TData[], unknown[]> {
430
- constructor(key: string, ...keys: string[]);
431
- }
432
-
433
- /**
434
- * @see https://redis.io/commands/sinterstore
435
- */
436
- declare class SInterStoreCommand<TData = string> extends Command<TData[], unknown[]> {
437
- constructor(destination: string, key: string, ...keys: string[]);
438
- }
439
-
440
- /**
441
- * @see https://redis.io/commands/smembers
442
- */
443
- declare class SMembersCommand<TData = string> extends Command<TData[], unknown[]> {
444
- constructor(key: string);
445
- }
446
-
447
- /**
448
- * @see https://redis.io/commands/spop
449
- */
450
- declare class SPopCommand<TData = number> extends Command<TData | null, string | null> {
451
- constructor(key: string, count?: number);
452
- }
453
-
454
- /**
455
- * @see https://redis.io/commands/srandmember
456
- */
457
- declare class SRandMemberCommand<TData> extends Command<TData | null, string | null> {
458
- constructor(key: string, count?: number);
459
- }
460
-
461
- /**
462
- * @see https://redis.io/commands/sscan
463
- */
464
- declare class SScanCommand extends Command<[
465
- number,
466
- (string | number)[]
467
- ], [
468
- number,
469
- (string | number)[]
470
- ]> {
471
- constructor(key: string, cursor: number, opts?: ScanCommandOptions);
472
- }
473
-
474
- /**
475
- * @see https://redis.io/commands/strlen
476
- */
477
- declare class StrLenCommand extends Command<number, number> {
478
- constructor(key: string);
479
- }
480
-
481
- /**
482
- * @see https://redis.io/commands/sunion
483
- */
484
- declare class SUnionCommand<TData> extends Command<TData[], string[]> {
485
- constructor(key: string, ...keys: string[]);
486
- }
487
-
488
- /**
489
- * @see https://redis.io/commands/sunionstore
490
- */
491
- declare class SUnionStoreCommand extends Command<number, number> {
492
- constructor(destination: string, key: string, ...keys: string[]);
493
- }
494
-
495
- /**
496
- * @see https://redis.io/commands/touch
497
- */
498
- declare class TouchCommand extends Command<number, number> {
499
- constructor(...keys: string[]);
500
- }
501
-
502
- /**
503
- * @see https://redis.io/commands/ttl
504
- */
505
- declare class TtlCommand extends Command<number, number> {
506
- constructor(key: string);
507
- }
508
-
509
- declare type Type = "string" | "list" | "set" | "zset" | "hash" | "none";
510
- /**
511
- * @see https://redis.io/commands/type
512
- */
513
- declare class TypeCommand extends Command<Type, Type> {
514
- constructor(key: string);
515
- }
516
-
517
- /**
518
- * @see https://redis.io/commands/unlink
519
- */
520
- declare class UnlinkCommand extends Command<number, number> {
521
- constructor(...keys: string[]);
522
- }
523
-
524
- declare type ZAddCommandOptions = ({
525
- nx: true;
526
- xx?: never;
527
- } | {
528
- nx?: never;
529
- xx: true;
530
- } | {
531
- nx?: never;
532
- xx?: never;
533
- }) & {
534
- ch?: true;
535
- };
536
- declare type ZAddCommandOptionsWithIncr = ZAddCommandOptions & {
537
- incr: true;
538
- };
539
- declare type ScoreMember<TData> = {
540
- score: number;
541
- member: TData;
542
- };
543
- /**
544
- * @see https://redis.io/commands/zadd
545
- */
546
- declare class ZAddCommand<TData = string> extends Command<number | null, number | null> {
547
- constructor(key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]);
548
- constructor(key: string, opts: ZAddCommandOptions | ZAddCommandOptionsWithIncr, ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]);
549
- }
550
-
551
- /**
552
- * @see https://redis.io/commands/zcard
553
- */
554
- declare class ZCardCommand extends Command<number, number> {
555
- constructor(key: string);
556
- }
557
-
558
- /**
559
- * @see https://redis.io/commands/zcount
560
- */
561
- declare class ZCountCommand extends Command<number, number> {
562
- constructor(key: string, min: number | string, max: number | string);
563
- }
564
-
565
- declare type ZInterStoreCommandOptions = {
566
- aggregate?: "sum" | "min" | "max";
567
- } & ({
568
- weight: number;
569
- weights?: never;
570
- } | {
571
- weight?: never;
572
- weights: number[];
573
- } | {
574
- weight?: never;
575
- weights?: never;
576
- });
577
- /**
578
- * @see https://redis.io/commands/zInterstore
579
- */
580
- declare class ZInterStoreCommand extends Command<number, number> {
581
- constructor(destination: string, numKeys: 1, key: string, opts?: ZInterStoreCommandOptions);
582
- constructor(destination: string, numKeys: number, keys: string[], opts?: ZInterStoreCommandOptions);
583
- }
584
-
585
- /**
586
- * @see https://redis.io/commands/zlexcount
587
- */
588
- declare class ZLexCountCommand extends Command<number, number> {
589
- constructor(key: string, min: string, max: string);
590
- }
591
-
592
- /**
593
- * @see https://redis.io/commands/zpopmax
594
- */
595
- declare class ZPopMaxCommand<TData> extends Command<TData[], string[]> {
596
- constructor(key: string, count?: number);
597
- }
598
-
599
- /**
600
- * @see https://redis.io/commands/zpopmin
601
- */
602
- declare class ZPopMinCommand<TData> extends Command<TData[], string[]> {
603
- constructor(key: string, count?: number);
604
- }
605
-
606
- declare type ZRangeCommandOptions = {
607
- withScores?: boolean;
608
- };
609
- /**
610
- * @see https://redis.io/commands/zrange
611
- */
612
- declare class ZRangeCommand<TData extends unknown[]> extends Command<TData, string[]> {
613
- constructor(key: string, min: number | `(${number}`, max: number | `(${number}`, opts?: ZRangeCommandOptions);
614
- }
615
-
616
- /**
617
- * @see https://redis.io/commands/zremrangebylex
618
- */
619
- declare class ZRemRangeByLexCommand extends Command<number, number> {
620
- constructor(key: string, min: string, max: string);
621
- }
622
-
623
- /**
624
- * @see https://redis.io/commands/zremrangebyrank
625
- */
626
- declare class ZRemRangeByRankCommand extends Command<number, number> {
627
- constructor(key: string, start: number, stop: number);
628
- }
629
-
630
- /**
631
- * @see https://redis.io/commands/zremrangebyscore
632
- */
633
- declare class ZRemRangeByScoreCommand extends Command<number, number> {
634
- constructor(key: string, min: number, max: number);
635
- }
636
-
637
- /**
638
- * @see https://redis.io/commands/zscan
639
- */
640
- declare class ZScanCommand extends Command<[
641
- number,
642
- (string | number)[]
643
- ], [
644
- number,
645
- (string | number)[]
646
- ]> {
647
- constructor(key: string, cursor: number, opts?: ScanCommandOptions);
648
- }
649
-
650
- declare type ZUnionStoreCommandOptions = {
651
- aggregate?: "sum" | "min" | "max";
652
- } & ({
653
- weight: number;
654
- weights?: never;
655
- } | {
656
- weight?: never;
657
- weights: number[];
658
- } | {
659
- weight?: never;
660
- weights?: never;
661
- });
662
- /**
663
- * @see https://redis.io/commands/zunionstore
664
- */
665
- declare class ZUnionStoreCommand extends Command<number, number> {
666
- constructor(destination: string, numKeys: 1, key: string, opts?: ZUnionStoreCommandOptions);
667
- constructor(destination: string, numKeys: number, keys: string[], opts?: ZUnionStoreCommandOptions);
668
- }
669
-
670
- export { SetRangeCommand as $, AppendCommand as A, BitCountCommand as B, CommandArgs as C, DecrCommand as D, EchoCommand as E, FlushAllCommand as F, GetCommand as G, HDelCommand as H, IncrCommand as I, PExpireCommand as J, KeysCommand as K, LIndexCommand as L, MGetCommand as M, NonEmptyArray as N, PExpireAtCommand as O, PersistCommand as P, PingCommand as Q, PTtlCommand as R, RenameCommand as S, RenameNXCommand as T, RPopCommand as U, ScanCommand as V, SCardCommand as W, SDiffCommand as X, SDiffStoreCommand as Y, SetCommandOptions as Z, SetBitCommand as _, BitPosCommand as a, SInterCommand as a0, SInterStoreCommand as a1, SMembersCommand as a2, SPopCommand as a3, SRandMemberCommand as a4, SScanCommand as a5, StrLenCommand as a6, SUnionCommand as a7, SUnionStoreCommand as a8, TouchCommand as a9, TtlCommand as aa, TypeCommand as ab, UnlinkCommand as ac, ScoreMember as ad, ZAddCommandOptions as ae, ZAddCommandOptionsWithIncr as af, ZCardCommand as ag, ZCountCommand as ah, ZInterStoreCommand as ai, ZLexCountCommand as aj, ZPopMaxCommand as ak, ZPopMinCommand as al, ZRangeCommand as am, ZRemRangeByLexCommand as an, ZRemRangeByRankCommand as ao, ZRemRangeByScoreCommand as ap, ZScanCommand as aq, ZUnionStoreCommand as ar, Type as as, Command as at, ScanCommandOptions as au, SetCommand as av, ZAddCommand as aw, ZInterStoreCommandOptions as ax, ZRangeCommandOptions as ay, ZUnionStoreCommandOptions as az, DecrByCommand as b, DelCommand as c, ExistsCommand as d, ExpireCommand as e, ExpireAtCommand as f, FlushDBCommand as g, GetBitCommand as h, GetRangeCommand as i, HExistsCommand as j, HGetCommand as k, HGetAllCommand as l, HIncrByCommand as m, HIncrByFloatCommand as n, HKeysCommand as o, HLenCommand as p, HMGetCommand as q, HScanCommand as r, HStrLenCommand as s, HValsCommand as t, IncrByCommand as u, IncrByFloatCommand as v, LLenCommand as w, LPopCommand as x, LRangeCommand as y, LTrimCommand as z };