@upstash/redis 0.0.0-ci.e730ad54-20220901 → 0.0.0-ci.ed40a9ac-20230414

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.
Files changed (125) hide show
  1. package/README.md +20 -18
  2. package/esm/pkg/commands/command.js +12 -3
  3. package/esm/pkg/commands/getdel.js +9 -0
  4. package/esm/pkg/commands/hgetall.js +0 -4
  5. package/esm/pkg/commands/hrandfield.js +39 -0
  6. package/esm/pkg/commands/json_arrappend.js +9 -0
  7. package/esm/pkg/commands/json_arrindex.js +9 -0
  8. package/esm/pkg/commands/json_arrinsert.js +9 -0
  9. package/esm/pkg/commands/json_arrlen.js +9 -0
  10. package/esm/pkg/commands/json_arrpop.js +9 -0
  11. package/esm/pkg/commands/json_arrtrim.js +12 -0
  12. package/esm/pkg/commands/json_clear.js +9 -0
  13. package/esm/pkg/commands/json_del.js +9 -0
  14. package/esm/pkg/commands/json_forget.js +9 -0
  15. package/esm/pkg/commands/json_get.js +30 -0
  16. package/esm/pkg/commands/json_mget.js +9 -0
  17. package/esm/pkg/commands/json_numincrby.js +9 -0
  18. package/esm/pkg/commands/json_nummultby.js +9 -0
  19. package/esm/pkg/commands/json_objkeys.js +9 -0
  20. package/esm/pkg/commands/json_objlen.js +9 -0
  21. package/esm/pkg/commands/json_resp.js +9 -0
  22. package/esm/pkg/commands/json_set.js +18 -0
  23. package/esm/pkg/commands/json_strappend.js +9 -0
  24. package/esm/pkg/commands/json_strlen.js +9 -0
  25. package/esm/pkg/commands/json_toggle.js +9 -0
  26. package/esm/pkg/commands/json_type.js +9 -0
  27. package/esm/pkg/commands/lmove.js +9 -0
  28. package/esm/pkg/commands/mod.js +25 -0
  29. package/esm/pkg/commands/smismember.js +9 -0
  30. package/esm/pkg/commands/zdiffstore.js +9 -0
  31. package/esm/pkg/commands/zmscore.js +1 -2
  32. package/esm/pkg/http.js +92 -2
  33. package/esm/pkg/pipeline.js +153 -6
  34. package/esm/pkg/redis.js +188 -2
  35. package/esm/platforms/cloudflare.js +10 -2
  36. package/esm/platforms/fastly.js +6 -0
  37. package/esm/platforms/node_with_fetch.js +26 -1
  38. package/esm/platforms/nodejs.js +22 -1
  39. package/esm/version.js +1 -0
  40. package/package.json +41 -16
  41. package/script/pkg/commands/command.js +12 -3
  42. package/script/pkg/commands/getdel.js +13 -0
  43. package/script/pkg/commands/hgetall.js +0 -4
  44. package/script/pkg/commands/hrandfield.js +43 -0
  45. package/script/pkg/commands/json_arrappend.js +13 -0
  46. package/script/pkg/commands/json_arrindex.js +13 -0
  47. package/script/pkg/commands/json_arrinsert.js +13 -0
  48. package/script/pkg/commands/json_arrlen.js +13 -0
  49. package/script/pkg/commands/json_arrpop.js +13 -0
  50. package/script/pkg/commands/json_arrtrim.js +16 -0
  51. package/script/pkg/commands/json_clear.js +13 -0
  52. package/script/pkg/commands/json_del.js +13 -0
  53. package/script/pkg/commands/json_forget.js +13 -0
  54. package/script/pkg/commands/json_get.js +34 -0
  55. package/script/pkg/commands/json_mget.js +13 -0
  56. package/script/pkg/commands/json_numincrby.js +13 -0
  57. package/script/pkg/commands/json_nummultby.js +13 -0
  58. package/script/pkg/commands/json_objkeys.js +13 -0
  59. package/script/pkg/commands/json_objlen.js +13 -0
  60. package/script/pkg/commands/json_resp.js +13 -0
  61. package/script/pkg/commands/json_set.js +22 -0
  62. package/script/pkg/commands/json_strappend.js +13 -0
  63. package/script/pkg/commands/json_strlen.js +13 -0
  64. package/script/pkg/commands/json_toggle.js +13 -0
  65. package/script/pkg/commands/json_type.js +13 -0
  66. package/script/pkg/commands/lmove.js +13 -0
  67. package/script/pkg/commands/mod.js +25 -0
  68. package/script/pkg/commands/smismember.js +13 -0
  69. package/script/pkg/commands/zdiffstore.js +13 -0
  70. package/script/pkg/commands/zmscore.js +1 -2
  71. package/script/pkg/http.js +92 -2
  72. package/script/pkg/pipeline.js +152 -5
  73. package/script/pkg/redis.js +187 -1
  74. package/script/platforms/cloudflare.js +10 -2
  75. package/script/platforms/fastly.js +6 -0
  76. package/script/platforms/node_with_fetch.js +26 -1
  77. package/script/platforms/nodejs.js +22 -1
  78. package/script/version.js +4 -0
  79. package/types/pkg/commands/command.d.ts +5 -5
  80. package/types/pkg/commands/getdel.d.ts +7 -0
  81. package/types/pkg/commands/hrandfield.d.ts +9 -0
  82. package/types/pkg/commands/json_arrappend.d.ts +7 -0
  83. package/types/pkg/commands/json_arrindex.d.ts +13 -0
  84. package/types/pkg/commands/json_arrinsert.d.ts +7 -0
  85. package/types/pkg/commands/json_arrlen.d.ts +7 -0
  86. package/types/pkg/commands/json_arrpop.d.ts +7 -0
  87. package/types/pkg/commands/json_arrtrim.d.ts +7 -0
  88. package/types/pkg/commands/json_clear.d.ts +7 -0
  89. package/types/pkg/commands/json_del.d.ts +7 -0
  90. package/types/pkg/commands/json_forget.d.ts +7 -0
  91. package/types/pkg/commands/json_get.d.ts +15 -0
  92. package/types/pkg/commands/json_mget.d.ts +7 -0
  93. package/types/pkg/commands/json_numincrby.d.ts +7 -0
  94. package/types/pkg/commands/json_nummultby.d.ts +7 -0
  95. package/types/pkg/commands/json_objkeys.d.ts +7 -0
  96. package/types/pkg/commands/json_objlen.d.ts +7 -0
  97. package/types/pkg/commands/json_resp.d.ts +7 -0
  98. package/types/pkg/commands/json_set.d.ts +18 -0
  99. package/types/pkg/commands/json_strappend.d.ts +7 -0
  100. package/types/pkg/commands/json_strlen.d.ts +7 -0
  101. package/types/pkg/commands/json_toggle.d.ts +7 -0
  102. package/types/pkg/commands/json_type.d.ts +7 -0
  103. package/types/pkg/commands/lmove.d.ts +12 -0
  104. package/types/pkg/commands/mod.d.ts +25 -0
  105. package/types/pkg/commands/scan.d.ts +1 -1
  106. package/types/pkg/commands/script_flush.d.ts +1 -1
  107. package/types/pkg/commands/set.d.ts +1 -1
  108. package/types/pkg/commands/smembers.d.ts +2 -2
  109. package/types/pkg/commands/smismember.d.ts +7 -0
  110. package/types/pkg/commands/type.d.ts +1 -1
  111. package/types/pkg/commands/zadd.d.ts +3 -3
  112. package/types/pkg/commands/zdiffstore.d.ts +7 -0
  113. package/types/pkg/commands/zinterstore.d.ts +1 -1
  114. package/types/pkg/commands/zmscore.d.ts +1 -1
  115. package/types/pkg/commands/zrange.d.ts +1 -1
  116. package/types/pkg/commands/zunionstore.d.ts +1 -1
  117. package/types/pkg/http.d.ts +44 -7
  118. package/types/pkg/pipeline.d.ts +55 -4
  119. package/types/pkg/redis.d.ts +134 -10
  120. package/types/pkg/types.d.ts +27 -1
  121. package/types/platforms/cloudflare.d.ts +9 -8
  122. package/types/platforms/fastly.d.ts +3 -7
  123. package/types/platforms/node_with_fetch.d.ts +3 -22
  124. package/types/platforms/nodejs.d.ts +4 -7
  125. package/types/version.d.ts +1 -0
@@ -1,4 +1,4 @@
1
- import { DelCommand, ExistsCommand, FlushAllCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
1
+ import { DelCommand, ExistsCommand, FlushAllCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
2
  import { CommandOptions } from "./commands/command.js";
3
3
  import { Requester } from "./http.js";
4
4
  import { CommandArgs } from "./types.js";
@@ -18,7 +18,7 @@ import { CommandArgs } from "./types.js";
18
18
  * **Examples:**
19
19
  *
20
20
  * ```ts
21
- * const p = redis.pipeline()
21
+ * const p = redis.pipeline() // or redis.multi()
22
22
  * p.set("key","value")
23
23
  * p.get("key")
24
24
  * const res = await p.exec()
@@ -44,7 +44,12 @@ export declare class Pipeline {
44
44
  private client;
45
45
  private commands;
46
46
  private commandOptions?;
47
- constructor(client: Requester, commandOptions?: CommandOptions<any, any>);
47
+ private multiExec;
48
+ constructor(opts: {
49
+ client: Requester;
50
+ commandOptions?: CommandOptions<any, any>;
51
+ multiExec?: boolean;
52
+ });
48
53
  /**
49
54
  * Send the pipeline request to upstash.
50
55
  *
@@ -80,6 +85,10 @@ export declare class Pipeline {
80
85
  * @see https://redis.io/commands/bitpos
81
86
  */
82
87
  bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => this;
88
+ /**
89
+ * @see https://redis.io/commands/zdiffstore
90
+ */
91
+ zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => this;
83
92
  /**
84
93
  * @see https://redis.io/commands/dbsize
85
94
  */
@@ -138,6 +147,10 @@ export declare class Pipeline {
138
147
  * @see https://redis.io/commands/getbit
139
148
  */
140
149
  getbit: (key: string, offset: number) => this;
150
+ /**
151
+ * @see https://redis.io/commands/getdel
152
+ */
153
+ getdel: <TData>(key: string) => this;
141
154
  /**
142
155
  * @see https://redis.io/commands/getrange
143
156
  */
@@ -188,6 +201,10 @@ export declare class Pipeline {
188
201
  hmset: <TData>(key: string, kv: {
189
202
  [field: string]: TData;
190
203
  }) => this;
204
+ /**
205
+ * @see https://redis.io/commands/hrandfield
206
+ */
207
+ hrandfield: <TData extends string | string[] | Record<string, unknown>>(key: string, count?: number, withValues?: boolean) => this;
191
208
  /**
192
209
  * @see https://redis.io/commands/hscan
193
210
  */
@@ -238,6 +255,10 @@ export declare class Pipeline {
238
255
  * @see https://redis.io/commands/llen
239
256
  */
240
257
  llen: (key: string) => this;
258
+ /**
259
+ * @see https://redis.io/commands/lmove
260
+ */
261
+ lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => this;
241
262
  /**
242
263
  * @see https://redis.io/commands/lpop
243
264
  */
@@ -406,7 +427,11 @@ export declare class Pipeline {
406
427
  /**
407
428
  * @see https://redis.io/commands/smembers
408
429
  */
409
- smembers: (key: string) => this;
430
+ smembers: <TData extends unknown[] = string[]>(key: string) => this;
431
+ /**
432
+ * @see https://redis.io/commands/smismember
433
+ */
434
+ smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => this;
410
435
  /**
411
436
  * @see https://redis.io/commands/smove
412
437
  */
@@ -549,4 +574,30 @@ export declare class Pipeline {
549
574
  * @see https://redis.io/commands/zunionstore
550
575
  */
551
576
  zunionstore: (destination: string, numKeys: number, keys: string[], opts?: import("./commands/zunionstore.js").ZUnionStoreCommandOptions | undefined) => this;
577
+ /**
578
+ * @see https://redis.io/commands/?group=json
579
+ */
580
+ get json(): {
581
+ arrappend: (...args: CommandArgs<typeof JsonArrAppendCommand>) => Pipeline;
582
+ arrindex: (...args: CommandArgs<typeof JsonArrIndexCommand>) => Pipeline;
583
+ arrinsert: (...args: CommandArgs<typeof JsonArrInsertCommand>) => Pipeline;
584
+ arrlen: (...args: CommandArgs<typeof JsonArrLenCommand>) => Pipeline;
585
+ arrpop: (...args: CommandArgs<typeof JsonArrPopCommand>) => Pipeline;
586
+ arrtrim: (...args: CommandArgs<typeof JsonArrTrimCommand>) => Pipeline;
587
+ clear: (...args: CommandArgs<typeof JsonClearCommand>) => Pipeline;
588
+ del: (...args: CommandArgs<typeof JsonDelCommand>) => Pipeline;
589
+ forget: (...args: CommandArgs<typeof JsonForgetCommand>) => Pipeline;
590
+ get: (...args: CommandArgs<typeof JsonGetCommand>) => Pipeline;
591
+ mget: (...args: CommandArgs<typeof JsonMGetCommand>) => Pipeline;
592
+ numincrby: (...args: CommandArgs<typeof JsonNumIncrByCommand>) => Pipeline;
593
+ nummultby: (...args: CommandArgs<typeof JsonNumMultByCommand>) => Pipeline;
594
+ objkeys: (...args: CommandArgs<typeof JsonObjKeysCommand>) => Pipeline;
595
+ objlen: (...args: CommandArgs<typeof JsonObjLenCommand>) => Pipeline;
596
+ resp: (...args: CommandArgs<typeof JsonRespCommand>) => Pipeline;
597
+ set: (...args: CommandArgs<typeof JsonSetCommand>) => Pipeline;
598
+ strappend: (...args: CommandArgs<typeof JsonStrAppendCommand>) => Pipeline;
599
+ strlen: (...args: CommandArgs<typeof JsonStrLenCommand>) => Pipeline;
600
+ toggle: (...args: CommandArgs<typeof JsonToggleCommand>) => Pipeline;
601
+ type: (...args: CommandArgs<typeof JsonTypeCommand>) => Pipeline;
602
+ };
552
603
  }
@@ -1,22 +1,16 @@
1
- import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
1
+ import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, JsonGetCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
2
  import { Requester, UpstashRequest, UpstashResponse } from "./http.js";
3
3
  import { Pipeline } from "./pipeline.js";
4
4
  import type { CommandArgs } from "./types.js";
5
5
  import { Script } from "./script.js";
6
- export declare type RedisOptions = {
7
- /**
8
- * Automatically try to deserialize the returned data from upstash using `JSON.deserialize`
9
- *
10
- * @default true
11
- */
12
- automaticDeserialization?: boolean;
13
- };
6
+ import { RedisOptions, Telemetry } from "./types.js";
14
7
  /**
15
8
  * Serverless redis client for upstash.
16
9
  */
17
10
  export declare class Redis {
18
11
  protected client: Requester;
19
12
  protected opts?: CommandOptions<any, any>;
13
+ protected enableTelemetry: boolean;
20
14
  /**
21
15
  * Create a new redis client
22
16
  *
@@ -29,10 +23,106 @@ export declare class Redis {
29
23
  * ```
30
24
  */
31
25
  constructor(client: Requester, opts?: RedisOptions);
26
+ get json(): {
27
+ /**
28
+ * @see https://redis.io/commands/json.arrappend
29
+ */
30
+ arrappend: (key: string, path: string, ...values: unknown[]) => Promise<(number | null)[]>;
31
+ /**
32
+ * @see https://redis.io/commands/json.arrindex
33
+ */
34
+ arrindex: (key: string, path: string, value: unknown, start?: number | undefined, stop?: number | undefined) => Promise<(number | null)[]>;
35
+ /**
36
+ * @see https://redis.io/commands/json.arrinsert
37
+ */
38
+ arrinsert: (key: string, path: string, index: number, ...values: unknown[]) => Promise<(number | null)[]>;
39
+ /**
40
+ * @see https://redis.io/commands/json.arrlen
41
+ */
42
+ arrlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
43
+ /**
44
+ * @see https://redis.io/commands/json.arrpop
45
+ */
46
+ arrpop: (key: string, path?: string | undefined, index?: number | undefined) => Promise<unknown[]>;
47
+ /**
48
+ * @see https://redis.io/commands/json.arrtrim
49
+ */
50
+ arrtrim: (key: string, path?: string | undefined, start?: number | undefined, stop?: number | undefined) => Promise<(number | null)[]>;
51
+ /**
52
+ * @see https://redis.io/commands/json.clear
53
+ */
54
+ clear: (key: string, path?: string | undefined) => Promise<number>;
55
+ /**
56
+ * @see https://redis.io/commands/json.del
57
+ */
58
+ del: (key: string, path?: string | undefined) => Promise<number>;
59
+ /**
60
+ * @see https://redis.io/commands/json.forget
61
+ */
62
+ forget: (key: string, path?: string | undefined) => Promise<number>;
63
+ /**
64
+ * @see https://redis.io/commands/json.get
65
+ */
66
+ get: (...args: CommandArgs<typeof JsonGetCommand>) => Promise<any>;
67
+ /**
68
+ * @see https://redis.io/commands/json.mget
69
+ */
70
+ mget: (keys: string[], path: string) => Promise<any>;
71
+ /**
72
+ * @see https://redis.io/commands/json.numincrby
73
+ */
74
+ numincrby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
75
+ /**
76
+ * @see https://redis.io/commands/json.nummultby
77
+ */
78
+ nummultby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
79
+ /**
80
+ * @see https://redis.io/commands/json.objkeys
81
+ */
82
+ objkeys: (key: string, path?: string | undefined) => Promise<(string[] | null)[]>;
83
+ /**
84
+ * @see https://redis.io/commands/json.objlen
85
+ */
86
+ objlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
87
+ /**
88
+ * @see https://redis.io/commands/json.resp
89
+ */
90
+ resp: (key: string, path?: string | undefined) => Promise<any>;
91
+ /**
92
+ * @see https://redis.io/commands/json.set
93
+ */
94
+ set: (key: string, path: string, value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[], opts?: {
95
+ nx: true;
96
+ xx?: undefined;
97
+ } | {
98
+ nx?: undefined;
99
+ xx: true;
100
+ } | undefined) => Promise<"OK" | null>;
101
+ /**
102
+ * @see https://redis.io/commands/json.strappend
103
+ */
104
+ strappend: (key: string, path: string, value: string) => Promise<(number | null)[]>;
105
+ /**
106
+ * @see https://redis.io/commands/json.strlen
107
+ */
108
+ strlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
109
+ /**
110
+ * @see https://redis.io/commands/json.toggle
111
+ */
112
+ toggle: (key: string, path: string) => Promise<number[]>;
113
+ /**
114
+ * @see https://redis.io/commands/json.type
115
+ */
116
+ type: (key: string, path?: string | undefined) => Promise<string[]>;
117
+ };
32
118
  /**
33
119
  * Wrap a new middleware around the HTTP client.
34
120
  */
35
121
  use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
122
+ /**
123
+ * Technically this is not private, we can hide it from intellisense by doing this
124
+ */
125
+ protected addTelemetry: (telemetry: Telemetry) => void;
36
126
  createScript(script: string): Script;
37
127
  /**
38
128
  * Create a new pipeline that allows you to send requests in bulk.
@@ -40,6 +130,16 @@ export declare class Redis {
40
130
  * @see {@link Pipeline}
41
131
  */
42
132
  pipeline: () => Pipeline;
133
+ /**
134
+ * Create a new transaction to allow executing multiple steps atomically.
135
+ *
136
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
137
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
138
+ * guarantees that the commands are executed as a single isolated operation.
139
+ *
140
+ * @see {@link Pipeline}
141
+ */
142
+ multi: () => Pipeline;
43
143
  /**
44
144
  * @see https://redis.io/commands/append
45
145
  */
@@ -117,6 +217,10 @@ export declare class Redis {
117
217
  * @see https://redis.io/commands/getbit
118
218
  */
119
219
  getbit: (key: string, offset: number) => Promise<0 | 1>;
220
+ /**
221
+ * @see https://redis.io/commands/getdel
222
+ */
223
+ getdel: <TData>(key: string) => Promise<TData | null>;
120
224
  /**
121
225
  * @see https://redis.io/commands/getrange
122
226
  */
@@ -167,6 +271,14 @@ export declare class Redis {
167
271
  hmset: <TData>(key: string, kv: {
168
272
  [field: string]: TData;
169
273
  }) => Promise<"OK">;
274
+ /**
275
+ * @see https://redis.io/commands/hrandfield
276
+ */
277
+ hrandfield: {
278
+ (key: string): Promise<string>;
279
+ (key: string, count: number): Promise<string[]>;
280
+ <TData extends Record<string, unknown>>(key: string, count: number, withValues: boolean): Promise<Partial<TData>>;
281
+ };
170
282
  /**
171
283
  * @see https://redis.io/commands/hscan
172
284
  */
@@ -217,6 +329,10 @@ export declare class Redis {
217
329
  * @see https://redis.io/commands/llen
218
330
  */
219
331
  llen: (key: string) => Promise<number>;
332
+ /**
333
+ * @see https://redis.io/commands/lmove
334
+ */
335
+ lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => Promise<TData>;
220
336
  /**
221
337
  * @see https://redis.io/commands/lpop
222
338
  */
@@ -385,10 +501,14 @@ export declare class Redis {
385
501
  * @see https://redis.io/commands/sismember
386
502
  */
387
503
  sismember: <TData>(key: string, member: TData) => Promise<0 | 1>;
504
+ /**
505
+ * @see https://redis.io/commands/smismember
506
+ */
507
+ smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => Promise<(0 | 1)[]>;
388
508
  /**
389
509
  * @see https://redis.io/commands/smembers
390
510
  */
391
- smembers: (key: string) => Promise<string[]>;
511
+ smembers: <TData extends unknown[] = string[]>(key: string) => Promise<TData>;
392
512
  /**
393
513
  * @see https://redis.io/commands/smove
394
514
  */
@@ -453,6 +573,10 @@ export declare class Redis {
453
573
  * @see https://redis.io/commands/zcount
454
574
  */
455
575
  zcount: (key: string, min: string | number, max: string | number) => Promise<number>;
576
+ /**
577
+ * @see https://redis.io/commands/zdiffstore
578
+ */
579
+ zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => Promise<number>;
456
580
  /**
457
581
  * @see https://redis.io/commands/zincrby
458
582
  */
@@ -1 +1,27 @@
1
- export declare type CommandArgs<TCommand extends new (...args: any) => any> = ConstructorParameters<TCommand>[0];
1
+ export type CommandArgs<TCommand extends new (...args: any) => any> = ConstructorParameters<TCommand>[0];
2
+ export type Telemetry = {
3
+ /**
4
+ * Upstash-Telemetry-Sdk
5
+ * @example @upstash/redis@v1.1.1
6
+ */
7
+ sdk?: string;
8
+ /**
9
+ * Upstash-Telemetry-Platform
10
+ * @example cloudflare
11
+ */
12
+ platform?: string;
13
+ /**
14
+ * Upstash-Telemetry-Runtime
15
+ * @example node@v18
16
+ */
17
+ runtime?: string;
18
+ };
19
+ export type RedisOptions = {
20
+ /**
21
+ * Automatically try to deserialize the returned data from upstash using `JSON.deserialize`
22
+ *
23
+ * @default true
24
+ */
25
+ automaticDeserialization?: boolean;
26
+ enableTelemetry?: boolean;
27
+ };
@@ -1,11 +1,15 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import type { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import type { Requester, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
+ import { RequesterConfig } from "../pkg/http.js";
4
+ type Env = {
5
+ UPSTASH_DISABLE_TELEMETRY?: string;
6
+ };
3
7
  export type { Requester, UpstashRequest, UpstashResponse };
4
8
  /**
5
9
  * Connection credentials for upstash redis.
6
10
  * Get them from https://console.upstash.com/redis/<uuid>
7
11
  */
8
- export declare type RedisConfigCloudflare = {
12
+ export type RedisConfigCloudflare = {
9
13
  /**
10
14
  * UPSTASH_REDIS_REST_URL
11
15
  */
@@ -14,11 +18,7 @@ export declare type RedisConfigCloudflare = {
14
18
  * UPSTASH_REDIS_REST_TOKEN
15
19
  */
16
20
  token: string;
17
- /**
18
- * Configure the retry behaviour in case of network errors
19
- */
20
- retry?: RetryConfig;
21
- } & core.RedisOptions;
21
+ } & core.RedisOptions & RequesterConfig & Env;
22
22
  /**
23
23
  * Serverless redis client for upstash.
24
24
  */
@@ -34,9 +34,10 @@ export declare class Redis extends core.Redis {
34
34
  * });
35
35
  * ```
36
36
  */
37
- constructor(config: RedisConfigCloudflare);
37
+ constructor(config: RedisConfigCloudflare, env?: Env);
38
38
  static fromEnv(env?: {
39
39
  UPSTASH_REDIS_REST_URL: string;
40
40
  UPSTASH_REDIS_REST_TOKEN: string;
41
+ UPSTASH_DISABLE_TELEMETRY?: string;
41
42
  }, opts?: Omit<RedisConfigCloudflare, "url" | "token">): Redis;
42
43
  }
@@ -1,11 +1,11 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import type { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import type { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  export type { Requester, UpstashRequest, UpstashResponse };
4
4
  /**
5
5
  * Connection credentials for upstash redis.
6
6
  * Get them from https://console.upstash.com/redis/<uuid>
7
7
  */
8
- export declare type RedisConfigFastly = {
8
+ export type RedisConfigFastly = {
9
9
  /**
10
10
  * UPSTASH_REDIS_REST_URL
11
11
  */
@@ -20,11 +20,7 @@ export declare type RedisConfigFastly = {
20
20
  * referenced by name.
21
21
  */
22
22
  backend: string;
23
- /**
24
- * Configure the retry behaviour in case of network errors
25
- */
26
- retry?: RetryConfig;
27
- } & core.RedisOptions;
23
+ } & core.RedisOptions & RequesterConfig;
28
24
  /**
29
25
  * Serverless redis client for upstash.
30
26
  */
@@ -1,12 +1,12 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  import "isomorphic-fetch";
4
4
  export type { Requester, UpstashRequest, UpstashResponse };
5
5
  /**
6
6
  * Connection credentials for upstash redis.
7
7
  * Get them from https://console.upstash.com/redis/<uuid>
8
8
  */
9
- export declare type RedisConfigNodejs = {
9
+ export type RedisConfigNodejs = {
10
10
  /**
11
11
  * UPSTASH_REDIS_REST_URL
12
12
  */
@@ -15,26 +15,7 @@ export declare type RedisConfigNodejs = {
15
15
  * UPSTASH_REDIS_REST_TOKEN
16
16
  */
17
17
  token: string;
18
- /**
19
- * An agent allows you to reuse connections to reduce latency for multiple sequential requests.
20
- *
21
- * This is a node specific implementation and is not supported in various runtimes like Vercel
22
- * edge functions.
23
- *
24
- * @example
25
- * ```ts
26
- * import https from "https"
27
- *
28
- * const options: RedisConfigNodejs = {
29
- * agent: new https.Agent({ keepAlive: true })
30
- * }
31
- * ```
32
- */
33
- /**
34
- * Configure the retry behaviour in case of network errors
35
- */
36
- retry?: RetryConfig;
37
- } & core.RedisOptions;
18
+ } & core.RedisOptions & RequesterConfig;
38
19
  /**
39
20
  * Serverless redis client for upstash.
40
21
  */
@@ -1,11 +1,11 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  export type { Requester, UpstashRequest, UpstashResponse };
4
4
  /**
5
5
  * Connection credentials for upstash redis.
6
6
  * Get them from https://console.upstash.com/redis/<uuid>
7
7
  */
8
- export declare type RedisConfigNodejs = {
8
+ export type RedisConfigNodejs = {
9
9
  /**
10
10
  * UPSTASH_REDIS_REST_URL
11
11
  */
@@ -29,11 +29,8 @@ export declare type RedisConfigNodejs = {
29
29
  * }
30
30
  * ```
31
31
  */
32
- /**
33
- * Configure the retry behaviour in case of network errors
34
- */
35
- retry?: RetryConfig;
36
- } & core.RedisOptions;
32
+ agent?: any;
33
+ } & core.RedisOptions & RequesterConfig;
37
34
  /**
38
35
  * Serverless redis client for upstash.
39
36
  */
@@ -0,0 +1 @@
1
+ export declare const VERSION = "v0.0.0-ci.ed40a9ac-20230414";