@upstash/redis 0.0.0-ci.af91db56 → 0.0.0-ci.b1b216d3-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 (161) hide show
  1. package/README.md +44 -280
  2. package/esm/deps/deno.land/x/base64@v0.2.1/base.js +100 -0
  3. package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +9 -0
  4. package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
  5. package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +191 -0
  6. package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +50 -0
  7. package/esm/pkg/commands/command.js +12 -3
  8. package/esm/pkg/commands/getdel.js +9 -0
  9. package/esm/pkg/commands/hgetall.js +0 -4
  10. package/esm/pkg/commands/hrandfield.js +39 -0
  11. package/esm/pkg/commands/json_arrappend.js +9 -0
  12. package/esm/pkg/commands/json_arrindex.js +9 -0
  13. package/esm/pkg/commands/json_arrinsert.js +9 -0
  14. package/esm/pkg/commands/json_arrlen.js +9 -0
  15. package/esm/pkg/commands/json_arrpop.js +9 -0
  16. package/esm/pkg/commands/json_arrtrim.js +12 -0
  17. package/esm/pkg/commands/json_clear.js +9 -0
  18. package/esm/pkg/commands/json_del.js +9 -0
  19. package/esm/pkg/commands/json_forget.js +9 -0
  20. package/esm/pkg/commands/json_get.js +30 -0
  21. package/esm/pkg/commands/json_mget.js +9 -0
  22. package/esm/pkg/commands/json_numincrby.js +9 -0
  23. package/esm/pkg/commands/json_nummultby.js +9 -0
  24. package/esm/pkg/commands/json_objkeys.js +9 -0
  25. package/esm/pkg/commands/json_objlen.js +9 -0
  26. package/esm/pkg/commands/json_resp.js +9 -0
  27. package/esm/pkg/commands/json_set.js +18 -0
  28. package/esm/pkg/commands/json_strappend.js +9 -0
  29. package/esm/pkg/commands/json_strlen.js +9 -0
  30. package/esm/pkg/commands/json_toggle.js +9 -0
  31. package/esm/pkg/commands/json_type.js +9 -0
  32. package/esm/pkg/commands/lmove.js +9 -0
  33. package/esm/pkg/commands/lpos.js +19 -0
  34. package/esm/pkg/commands/mod.js +26 -0
  35. package/esm/pkg/commands/scan.js +3 -0
  36. package/esm/pkg/commands/sdiffstore.js +1 -1
  37. package/esm/pkg/commands/set.js +16 -4
  38. package/esm/pkg/commands/smismember.js +9 -0
  39. package/esm/pkg/commands/zdiffstore.js +9 -0
  40. package/esm/pkg/commands/zmscore.js +10 -0
  41. package/esm/pkg/commands/zrange.js +6 -0
  42. package/esm/pkg/http.js +126 -8
  43. package/esm/pkg/pipeline.js +172 -6
  44. package/esm/pkg/redis.js +223 -2
  45. package/esm/pkg/script.js +77 -0
  46. package/esm/platforms/cloudflare.js +14 -26
  47. package/esm/platforms/fastly.js +10 -25
  48. package/esm/platforms/node_with_fetch.js +30 -26
  49. package/esm/platforms/nodejs.js +26 -26
  50. package/esm/version.js +1 -0
  51. package/package.json +41 -54
  52. package/script/deps/deno.land/x/base64@v0.2.1/base.js +104 -0
  53. package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +13 -0
  54. package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +6 -0
  55. package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +196 -0
  56. package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +55 -0
  57. package/script/pkg/commands/command.js +12 -3
  58. package/script/pkg/commands/getdel.js +13 -0
  59. package/script/pkg/commands/hgetall.js +0 -4
  60. package/script/pkg/commands/hrandfield.js +43 -0
  61. package/script/pkg/commands/json_arrappend.js +13 -0
  62. package/script/pkg/commands/json_arrindex.js +13 -0
  63. package/script/pkg/commands/json_arrinsert.js +13 -0
  64. package/script/pkg/commands/json_arrlen.js +13 -0
  65. package/script/pkg/commands/json_arrpop.js +13 -0
  66. package/script/pkg/commands/json_arrtrim.js +16 -0
  67. package/script/pkg/commands/json_clear.js +13 -0
  68. package/script/pkg/commands/json_del.js +13 -0
  69. package/script/pkg/commands/json_forget.js +13 -0
  70. package/script/pkg/commands/json_get.js +34 -0
  71. package/script/pkg/commands/json_mget.js +13 -0
  72. package/script/pkg/commands/json_numincrby.js +13 -0
  73. package/script/pkg/commands/json_nummultby.js +13 -0
  74. package/script/pkg/commands/json_objkeys.js +13 -0
  75. package/script/pkg/commands/json_objlen.js +13 -0
  76. package/script/pkg/commands/json_resp.js +13 -0
  77. package/script/pkg/commands/json_set.js +22 -0
  78. package/script/pkg/commands/json_strappend.js +13 -0
  79. package/script/pkg/commands/json_strlen.js +13 -0
  80. package/script/pkg/commands/json_toggle.js +13 -0
  81. package/script/pkg/commands/json_type.js +13 -0
  82. package/script/pkg/commands/lmove.js +13 -0
  83. package/script/pkg/commands/lpos.js +23 -0
  84. package/script/pkg/commands/mod.js +26 -0
  85. package/script/pkg/commands/scan.js +3 -0
  86. package/script/pkg/commands/sdiffstore.js +1 -1
  87. package/script/pkg/commands/set.js +16 -4
  88. package/script/pkg/commands/smismember.js +13 -0
  89. package/script/pkg/commands/zdiffstore.js +13 -0
  90. package/script/pkg/commands/zmscore.js +14 -0
  91. package/script/pkg/commands/zrange.js +6 -0
  92. package/script/pkg/http.js +126 -8
  93. package/script/pkg/pipeline.js +171 -5
  94. package/script/pkg/redis.js +222 -1
  95. package/script/pkg/script.js +81 -0
  96. package/script/platforms/cloudflare.js +14 -26
  97. package/script/platforms/fastly.js +10 -25
  98. package/script/platforms/node_with_fetch.js +30 -26
  99. package/script/platforms/nodejs.js +26 -26
  100. package/script/version.js +4 -0
  101. package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +5 -0
  102. package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +1 -0
  103. package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
  104. package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +26 -0
  105. package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +3 -0
  106. package/types/pkg/commands/bitop.d.ts +0 -1
  107. package/types/pkg/commands/bitpos.d.ts +1 -1
  108. package/types/pkg/commands/command.d.ts +5 -5
  109. package/types/pkg/commands/getdel.d.ts +7 -0
  110. package/types/pkg/commands/hrandfield.d.ts +9 -0
  111. package/types/pkg/commands/json_arrappend.d.ts +7 -0
  112. package/types/pkg/commands/json_arrindex.d.ts +13 -0
  113. package/types/pkg/commands/json_arrinsert.d.ts +7 -0
  114. package/types/pkg/commands/json_arrlen.d.ts +7 -0
  115. package/types/pkg/commands/json_arrpop.d.ts +7 -0
  116. package/types/pkg/commands/json_arrtrim.d.ts +7 -0
  117. package/types/pkg/commands/json_clear.d.ts +7 -0
  118. package/types/pkg/commands/json_del.d.ts +7 -0
  119. package/types/pkg/commands/json_forget.d.ts +7 -0
  120. package/types/pkg/commands/json_get.d.ts +15 -0
  121. package/types/pkg/commands/json_mget.d.ts +7 -0
  122. package/types/pkg/commands/json_numincrby.d.ts +7 -0
  123. package/types/pkg/commands/json_nummultby.d.ts +7 -0
  124. package/types/pkg/commands/json_objkeys.d.ts +7 -0
  125. package/types/pkg/commands/json_objlen.d.ts +7 -0
  126. package/types/pkg/commands/json_resp.d.ts +7 -0
  127. package/types/pkg/commands/json_set.d.ts +18 -0
  128. package/types/pkg/commands/json_strappend.d.ts +7 -0
  129. package/types/pkg/commands/json_strlen.d.ts +7 -0
  130. package/types/pkg/commands/json_toggle.d.ts +7 -0
  131. package/types/pkg/commands/json_type.d.ts +7 -0
  132. package/types/pkg/commands/lmove.d.ts +12 -0
  133. package/types/pkg/commands/lpop.d.ts +1 -1
  134. package/types/pkg/commands/lpos.d.ts +15 -0
  135. package/types/pkg/commands/mget.d.ts +1 -1
  136. package/types/pkg/commands/mod.d.ts +26 -0
  137. package/types/pkg/commands/rpop.d.ts +2 -2
  138. package/types/pkg/commands/scan.d.ts +2 -1
  139. package/types/pkg/commands/script_flush.d.ts +1 -1
  140. package/types/pkg/commands/sdiffstore.d.ts +1 -1
  141. package/types/pkg/commands/set.d.ts +31 -2
  142. package/types/pkg/commands/smembers.d.ts +2 -2
  143. package/types/pkg/commands/smismember.d.ts +7 -0
  144. package/types/pkg/commands/spop.d.ts +2 -2
  145. package/types/pkg/commands/type.d.ts +1 -1
  146. package/types/pkg/commands/zadd.d.ts +4 -4
  147. package/types/pkg/commands/zdiffstore.d.ts +7 -0
  148. package/types/pkg/commands/zinterstore.d.ts +1 -1
  149. package/types/pkg/commands/zmscore.d.ts +7 -0
  150. package/types/pkg/commands/zrange.d.ts +8 -1
  151. package/types/pkg/commands/zunionstore.d.ts +1 -1
  152. package/types/pkg/http.d.ts +69 -8
  153. package/types/pkg/pipeline.d.ts +72 -9
  154. package/types/pkg/redis.d.ts +159 -17
  155. package/types/pkg/script.d.ts +42 -0
  156. package/types/pkg/types.d.ts +27 -1
  157. package/types/platforms/cloudflare.d.ts +9 -4
  158. package/types/platforms/fastly.d.ts +3 -3
  159. package/types/platforms/node_with_fetch.d.ts +3 -3
  160. package/types/platforms/nodejs.d.ts +19 -3
  161. package/types/version.d.ts +1 -0
@@ -1,21 +1,16 @@
1
- import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
- import { Requester } from "./http.js";
1
+ import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, JsonGetCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
+ import { Requester, UpstashRequest, UpstashResponse } from "./http.js";
3
3
  import { Pipeline } from "./pipeline.js";
4
4
  import type { CommandArgs } from "./types.js";
5
- export declare type RedisOptions = {
6
- /**
7
- * Automatically try to deserialize the returned data from upstash using `JSON.deserialize`
8
- *
9
- * @default true
10
- */
11
- automaticDeserialization?: boolean;
12
- };
5
+ import { Script } from "./script.js";
6
+ import { RedisOptions, Telemetry } from "./types.js";
13
7
  /**
14
8
  * Serverless redis client for upstash.
15
9
  */
16
10
  export declare class Redis {
17
- protected readonly client: Requester;
11
+ protected client: Requester;
18
12
  protected opts?: CommandOptions<any, any>;
13
+ protected enableTelemetry: boolean;
19
14
  /**
20
15
  * Create a new redis client
21
16
  *
@@ -28,12 +23,123 @@ export declare class Redis {
28
23
  * ```
29
24
  */
30
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
+ };
118
+ /**
119
+ * Wrap a new middleware around the HTTP client.
120
+ */
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;
126
+ createScript(script: string): Script;
31
127
  /**
32
128
  * Create a new pipeline that allows you to send requests in bulk.
33
129
  *
34
130
  * @see {@link Pipeline}
35
131
  */
36
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;
37
143
  /**
38
144
  * @see https://redis.io/commands/append
39
145
  */
@@ -52,7 +158,7 @@ export declare class Redis {
52
158
  /**
53
159
  * @see https://redis.io/commands/bitpos
54
160
  */
55
- bitpos: (key: string, start: number, end: number) => Promise<number>;
161
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => Promise<number>;
56
162
  /**
57
163
  * @see https://redis.io/commands/dbsize
58
164
  */
@@ -111,6 +217,10 @@ export declare class Redis {
111
217
  * @see https://redis.io/commands/getbit
112
218
  */
113
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>;
114
224
  /**
115
225
  * @see https://redis.io/commands/getrange
116
226
  */
@@ -161,6 +271,14 @@ export declare class Redis {
161
271
  hmset: <TData>(key: string, kv: {
162
272
  [field: string]: TData;
163
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
+ };
164
282
  /**
165
283
  * @see https://redis.io/commands/hscan
166
284
  */
@@ -211,10 +329,22 @@ export declare class Redis {
211
329
  * @see https://redis.io/commands/llen
212
330
  */
213
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>;
214
336
  /**
215
337
  * @see https://redis.io/commands/lpop
216
338
  */
217
- lpop: <TData>(key: string) => Promise<TData | null>;
339
+ lpop: <TData>(key: string, count?: number | undefined) => Promise<TData | null>;
340
+ /**
341
+ * @see https://redis.io/commands/lpos
342
+ */
343
+ lpos: <TData = number>(key: string, element: unknown, opts?: {
344
+ rank?: number | undefined;
345
+ count?: number | undefined;
346
+ maxLen?: number | undefined;
347
+ } | undefined) => Promise<TData>;
218
348
  /**
219
349
  * @see https://redis.io/commands/lpush
220
350
  */
@@ -242,7 +372,7 @@ export declare class Redis {
242
372
  /**
243
373
  * @see https://redis.io/commands/mget
244
374
  */
245
- mget: <TData extends unknown[]>(args_0: string, ...args_1: string[]) => Promise<TData>;
375
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => Promise<TData>;
246
376
  /**
247
377
  * @see https://redis.io/commands/mset
248
378
  */
@@ -298,7 +428,7 @@ export declare class Redis {
298
428
  /**
299
429
  * @see https://redis.io/commands/rpop
300
430
  */
301
- rpop: <TData = string>(key: string) => Promise<TData | null>;
431
+ rpop: <TData = string>(key: string, count?: number | undefined) => Promise<TData | null>;
302
432
  /**
303
433
  * @see https://redis.io/commands/rpush
304
434
  */
@@ -342,7 +472,7 @@ export declare class Redis {
342
472
  /**
343
473
  * @see https://redis.io/commands/set
344
474
  */
345
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => Promise<TData>;
475
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => Promise<"OK" | TData | null>;
346
476
  /**
347
477
  * @see https://redis.io/commands/setbit
348
478
  */
@@ -371,10 +501,14 @@ export declare class Redis {
371
501
  * @see https://redis.io/commands/sismember
372
502
  */
373
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)[]>;
374
508
  /**
375
509
  * @see https://redis.io/commands/smembers
376
510
  */
377
- smembers: (key: string) => Promise<string[]>;
511
+ smembers: <TData extends unknown[] = string[]>(key: string) => Promise<TData>;
378
512
  /**
379
513
  * @see https://redis.io/commands/smove
380
514
  */
@@ -439,6 +573,10 @@ export declare class Redis {
439
573
  * @see https://redis.io/commands/zcount
440
574
  */
441
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>;
442
580
  /**
443
581
  * @see https://redis.io/commands/zincrby
444
582
  */
@@ -451,6 +589,10 @@ export declare class Redis {
451
589
  * @see https://redis.io/commands/zlexcount
452
590
  */
453
591
  zlexcount: (key: string, min: string, max: string) => Promise<number>;
592
+ /**
593
+ * @see https://redis.io/commands/zmscore
594
+ */
595
+ zmscore: (key: string, members: unknown[]) => Promise<number[] | null>;
454
596
  /**
455
597
  * @see https://redis.io/commands/zpopmax
456
598
  */
@@ -0,0 +1,42 @@
1
+ import { Redis } from "./redis.js";
2
+ /**
3
+ * Creates a new script.
4
+ *
5
+ * Scripts offer the ability to optimistically try to execute a script without having to send the
6
+ * entire script to the server. If the script is loaded on the server, it tries again by sending
7
+ * the entire script. Afterwards, the script is cached on the server.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const redis = new Redis({...})
12
+ *
13
+ * const script = redis.createScript<string>("return ARGV[1];")
14
+ * const arg1 = await script.eval([], ["Hello World"])
15
+ * assertEquals(arg1, "Hello World")
16
+ * ```
17
+ */
18
+ export declare class Script<TResult = unknown> {
19
+ readonly script: string;
20
+ readonly sha1: string;
21
+ private readonly redis;
22
+ constructor(redis: Redis, script: string);
23
+ /**
24
+ * Send an `EVAL` command to redis.
25
+ */
26
+ eval(keys: string[], args: string[]): Promise<TResult>;
27
+ /**
28
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
29
+ */
30
+ evalsha(keys: string[], args: string[]): Promise<TResult>;
31
+ /**
32
+ * Optimistically try to run `EVALSHA` first.
33
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
34
+ *
35
+ * Following calls will be able to use the cached script
36
+ */
37
+ exec(keys: string[], args: string[]): Promise<TResult>;
38
+ /**
39
+ * Compute the sha1 hash of the script and return its hex representation.
40
+ */
41
+ private digest;
42
+ }
@@ -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
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,7 +18,7 @@ export declare type RedisConfigCloudflare = {
14
18
  * UPSTASH_REDIS_REST_TOKEN
15
19
  */
16
20
  token: string;
17
- } & core.RedisOptions;
21
+ } & core.RedisOptions & RequesterConfig & Env;
18
22
  /**
19
23
  * Serverless redis client for upstash.
20
24
  */
@@ -30,9 +34,10 @@ export declare class Redis extends core.Redis {
30
34
  * });
31
35
  * ```
32
36
  */
33
- constructor(config: RedisConfigCloudflare);
37
+ constructor(config: RedisConfigCloudflare, env?: Env);
34
38
  static fromEnv(env?: {
35
39
  UPSTASH_REDIS_REST_URL: string;
36
40
  UPSTASH_REDIS_REST_TOKEN: string;
37
- }): Redis;
41
+ UPSTASH_DISABLE_TELEMETRY?: string;
42
+ }, opts?: Omit<RedisConfigCloudflare, "url" | "token">): Redis;
38
43
  }
@@ -1,11 +1,11 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import type { Requester, 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,7 +20,7 @@ export declare type RedisConfigFastly = {
20
20
  * referenced by name.
21
21
  */
22
22
  backend: string;
23
- } & core.RedisOptions;
23
+ } & core.RedisOptions & RequesterConfig;
24
24
  /**
25
25
  * Serverless redis client for upstash.
26
26
  */
@@ -1,12 +1,12 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, 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,7 +15,7 @@ export declare type RedisConfigNodejs = {
15
15
  * UPSTASH_REDIS_REST_TOKEN
16
16
  */
17
17
  token: string;
18
- } & core.RedisOptions;
18
+ } & core.RedisOptions & RequesterConfig;
19
19
  /**
20
20
  * Serverless redis client for upstash.
21
21
  */
@@ -1,11 +1,11 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, 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
  */
@@ -14,7 +14,23 @@ export declare type RedisConfigNodejs = {
14
14
  * UPSTASH_REDIS_REST_TOKEN
15
15
  */
16
16
  token: string;
17
- } & core.RedisOptions;
17
+ /**
18
+ * An agent allows you to reuse connections to reduce latency for multiple sequential requests.
19
+ *
20
+ * This is a node specific implementation and is not supported in various runtimes like Vercel
21
+ * edge functions.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import https from "https"
26
+ *
27
+ * const options: RedisConfigNodejs = {
28
+ * agent: new https.Agent({ keepAlive: true })
29
+ * }
30
+ * ```
31
+ */
32
+ agent?: any;
33
+ } & core.RedisOptions & RequesterConfig;
18
34
  /**
19
35
  * Serverless redis client for upstash.
20
36
  */
@@ -0,0 +1 @@
1
+ export declare const VERSION = "v0.0.0-ci.b1b216d3-20230414";