@upstash/redis 0.0.0-ci.8500f14d-20221123 → 0.0.0-ci.8ec4f1e1-20230418

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 (119) hide show
  1. package/README.md +8 -1
  2. package/esm/pkg/commands/command.js +12 -3
  3. package/esm/pkg/commands/hgetall.js +0 -4
  4. package/esm/pkg/commands/hrandfield.js +39 -0
  5. package/esm/pkg/commands/json_arrappend.js +9 -0
  6. package/esm/pkg/commands/json_arrindex.js +9 -0
  7. package/esm/pkg/commands/json_arrinsert.js +9 -0
  8. package/esm/pkg/commands/json_arrlen.js +9 -0
  9. package/esm/pkg/commands/json_arrpop.js +9 -0
  10. package/esm/pkg/commands/json_arrtrim.js +12 -0
  11. package/esm/pkg/commands/json_clear.js +9 -0
  12. package/esm/pkg/commands/json_del.js +9 -0
  13. package/esm/pkg/commands/json_forget.js +9 -0
  14. package/esm/pkg/commands/json_get.js +30 -0
  15. package/esm/pkg/commands/json_mget.js +9 -0
  16. package/esm/pkg/commands/json_numincrby.js +9 -0
  17. package/esm/pkg/commands/json_nummultby.js +9 -0
  18. package/esm/pkg/commands/json_objkeys.js +9 -0
  19. package/esm/pkg/commands/json_objlen.js +9 -0
  20. package/esm/pkg/commands/json_resp.js +9 -0
  21. package/esm/pkg/commands/json_set.js +18 -0
  22. package/esm/pkg/commands/json_strappend.js +9 -0
  23. package/esm/pkg/commands/json_strlen.js +9 -0
  24. package/esm/pkg/commands/json_toggle.js +9 -0
  25. package/esm/pkg/commands/json_type.js +9 -0
  26. package/esm/pkg/commands/lmove.js +9 -0
  27. package/esm/pkg/commands/mod.js +25 -1
  28. package/esm/pkg/commands/smismember.js +9 -0
  29. package/esm/pkg/commands/zdiffstore.js +9 -0
  30. package/esm/pkg/http.js +26 -16
  31. package/esm/pkg/pipeline.js +131 -1
  32. package/esm/pkg/redis.js +155 -1
  33. package/esm/platforms/cloudflare.js +6 -6
  34. package/esm/platforms/fastly.js +5 -0
  35. package/esm/platforms/node_with_fetch.js +23 -11
  36. package/esm/platforms/nodejs.js +19 -11
  37. package/esm/version.js +1 -1
  38. package/package.json +41 -16
  39. package/script/pkg/commands/command.js +12 -3
  40. package/script/pkg/commands/hgetall.js +0 -4
  41. package/script/pkg/commands/hrandfield.js +43 -0
  42. package/script/pkg/commands/json_arrappend.js +13 -0
  43. package/script/pkg/commands/json_arrindex.js +13 -0
  44. package/script/pkg/commands/json_arrinsert.js +13 -0
  45. package/script/pkg/commands/json_arrlen.js +13 -0
  46. package/script/pkg/commands/json_arrpop.js +13 -0
  47. package/script/pkg/commands/json_arrtrim.js +16 -0
  48. package/script/pkg/commands/json_clear.js +13 -0
  49. package/script/pkg/commands/json_del.js +13 -0
  50. package/script/pkg/commands/json_forget.js +13 -0
  51. package/script/pkg/commands/json_get.js +34 -0
  52. package/script/pkg/commands/json_mget.js +13 -0
  53. package/script/pkg/commands/json_numincrby.js +13 -0
  54. package/script/pkg/commands/json_nummultby.js +13 -0
  55. package/script/pkg/commands/json_objkeys.js +13 -0
  56. package/script/pkg/commands/json_objlen.js +13 -0
  57. package/script/pkg/commands/json_resp.js +13 -0
  58. package/script/pkg/commands/json_set.js +22 -0
  59. package/script/pkg/commands/json_strappend.js +13 -0
  60. package/script/pkg/commands/json_strlen.js +13 -0
  61. package/script/pkg/commands/json_toggle.js +13 -0
  62. package/script/pkg/commands/json_type.js +13 -0
  63. package/script/pkg/commands/lmove.js +13 -0
  64. package/script/pkg/commands/mod.js +25 -1
  65. package/script/pkg/commands/smismember.js +13 -0
  66. package/script/pkg/commands/zdiffstore.js +13 -0
  67. package/script/pkg/http.js +26 -16
  68. package/script/pkg/pipeline.js +130 -0
  69. package/script/pkg/redis.js +154 -0
  70. package/script/platforms/cloudflare.js +6 -6
  71. package/script/platforms/fastly.js +5 -0
  72. package/script/platforms/node_with_fetch.js +23 -11
  73. package/script/platforms/nodejs.js +19 -11
  74. package/script/version.js +1 -1
  75. package/types/pkg/commands/command.d.ts +5 -5
  76. package/types/pkg/commands/hrandfield.d.ts +9 -0
  77. package/types/pkg/commands/json_arrappend.d.ts +7 -0
  78. package/types/pkg/commands/json_arrindex.d.ts +13 -0
  79. package/types/pkg/commands/json_arrinsert.d.ts +7 -0
  80. package/types/pkg/commands/json_arrlen.d.ts +7 -0
  81. package/types/pkg/commands/json_arrpop.d.ts +7 -0
  82. package/types/pkg/commands/json_arrtrim.d.ts +7 -0
  83. package/types/pkg/commands/json_clear.d.ts +7 -0
  84. package/types/pkg/commands/json_del.d.ts +7 -0
  85. package/types/pkg/commands/json_forget.d.ts +7 -0
  86. package/types/pkg/commands/json_get.d.ts +15 -0
  87. package/types/pkg/commands/json_mget.d.ts +7 -0
  88. package/types/pkg/commands/json_numincrby.d.ts +7 -0
  89. package/types/pkg/commands/json_nummultby.d.ts +7 -0
  90. package/types/pkg/commands/json_objkeys.d.ts +7 -0
  91. package/types/pkg/commands/json_objlen.d.ts +7 -0
  92. package/types/pkg/commands/json_resp.d.ts +7 -0
  93. package/types/pkg/commands/json_set.d.ts +18 -0
  94. package/types/pkg/commands/json_strappend.d.ts +7 -0
  95. package/types/pkg/commands/json_strlen.d.ts +7 -0
  96. package/types/pkg/commands/json_toggle.d.ts +7 -0
  97. package/types/pkg/commands/json_type.d.ts +7 -0
  98. package/types/pkg/commands/lmove.d.ts +12 -0
  99. package/types/pkg/commands/mod.d.ts +25 -1
  100. package/types/pkg/commands/scan.d.ts +1 -1
  101. package/types/pkg/commands/script_flush.d.ts +1 -1
  102. package/types/pkg/commands/set.d.ts +1 -1
  103. package/types/pkg/commands/smembers.d.ts +2 -2
  104. package/types/pkg/commands/smismember.d.ts +7 -0
  105. package/types/pkg/commands/type.d.ts +1 -1
  106. package/types/pkg/commands/zadd.d.ts +3 -3
  107. package/types/pkg/commands/zdiffstore.d.ts +7 -0
  108. package/types/pkg/commands/zinterstore.d.ts +1 -1
  109. package/types/pkg/commands/zrange.d.ts +1 -1
  110. package/types/pkg/commands/zunionstore.d.ts +1 -1
  111. package/types/pkg/http.d.ts +12 -23
  112. package/types/pkg/pipeline.d.ts +44 -2
  113. package/types/pkg/redis.d.ts +121 -10
  114. package/types/pkg/types.d.ts +27 -1
  115. package/types/platforms/cloudflare.d.ts +2 -2
  116. package/types/platforms/fastly.d.ts +1 -1
  117. package/types/platforms/node_with_fetch.d.ts +1 -1
  118. package/types/platforms/nodejs.d.ts +1 -1
  119. package/types/version.d.ts +1 -1
@@ -0,0 +1,15 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.get
4
+ */
5
+ export declare class JsonGetCommand<TData extends (unknown | Record<string, unknown>) | (unknown | Record<string, unknown>)[]> extends Command<TData | null, TData | null> {
6
+ constructor(cmd: [
7
+ key: string,
8
+ opts?: {
9
+ indent?: string;
10
+ newline?: string;
11
+ space?: string;
12
+ },
13
+ ...path: string[]
14
+ ] | [key: string, ...path: string[]], opts?: CommandOptions<TData | null, TData | null>);
15
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.mget
4
+ */
5
+ export declare class JsonMGetCommand<TData extends (unknown | Record<string, unknown>)[]> extends Command<TData, TData> {
6
+ constructor(cmd: [keys: string[], path: string], opts?: CommandOptions<TData, TData>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.numincrby
4
+ */
5
+ export declare class JsonNumIncrByCommand extends Command<(null | string)[], (null | number)[]> {
6
+ constructor(cmd: [key: string, path: string, value: number], opts?: CommandOptions<(null | string)[], (null | number)[]>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.nummultby
4
+ */
5
+ export declare class JsonNumMultByCommand extends Command<(null | string)[], (null | number)[]> {
6
+ constructor(cmd: [key: string, path: string, value: number], opts?: CommandOptions<(null | string)[], (null | number)[]>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.objkeys
4
+ */
5
+ export declare class JsonObjKeysCommand extends Command<(string[] | null)[], (string[] | null)[]> {
6
+ constructor(cmd: [key: string, path?: string], opts?: CommandOptions<(string[] | null)[], (string[] | null)[]>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.objlen
4
+ */
5
+ export declare class JsonObjLenCommand extends Command<(number | null)[], (number | null)[]> {
6
+ constructor(cmd: [key: string, path?: string], opts?: CommandOptions<(number | null)[], (number | null)[]>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.resp
4
+ */
5
+ export declare class JsonRespCommand<TData extends unknown[]> extends Command<TData, TData> {
6
+ constructor(cmd: [key: string, path?: string], opts?: CommandOptions<TData, TData>);
7
+ }
@@ -0,0 +1,18 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.set
4
+ */
5
+ export declare class JsonSetCommand<TData extends number | string | boolean | Record<string, unknown> | (number | string | boolean | Record<string, unknown>)[]> extends Command<"OK" | null, "OK" | null> {
6
+ constructor(cmd: [
7
+ key: string,
8
+ path: string,
9
+ value: TData,
10
+ opts?: {
11
+ nx: true;
12
+ xx?: never;
13
+ } | {
14
+ nx?: never;
15
+ xx: true;
16
+ }
17
+ ], opts?: CommandOptions<"OK" | null, "OK" | null>);
18
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.strappend
4
+ */
5
+ export declare class JsonStrAppendCommand<TData extends unknown[]> extends Command<(null | string)[], (null | number)[]> {
6
+ constructor(cmd: [key: string, path: string, value: string], opts?: CommandOptions<(null | string)[], (null | number)[]>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.strlen
4
+ */
5
+ export declare class JsonStrLenCommand extends Command<(number | null)[], (number | null)[]> {
6
+ constructor(cmd: [key: string, path?: string], opts?: CommandOptions<(number | null)[], (number | null)[]>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.toggle
4
+ */
5
+ export declare class JsonToggleCommand extends Command<number[], number[]> {
6
+ constructor(cmd: [key: string, path: string], opts?: CommandOptions<number[], number[]>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/json.type
4
+ */
5
+ export declare class JsonTypeCommand extends Command<string[], string[]> {
6
+ constructor(cmd: [key: string, path?: string], opts?: CommandOptions<string[], string[]>);
7
+ }
@@ -0,0 +1,12 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/lmove
4
+ */
5
+ export declare class LMoveCommand<TData = string> extends Command<TData, TData> {
6
+ constructor(cmd: [
7
+ source: string,
8
+ destination: string,
9
+ whereFrom: "left" | "right",
10
+ whereTo: "left" | "right"
11
+ ], opts?: CommandOptions<TData, TData>);
12
+ }
@@ -17,9 +17,9 @@ export * from "./flushall.js";
17
17
  export * from "./flushdb.js";
18
18
  export * from "./get.js";
19
19
  export * from "./getbit.js";
20
+ export * from "./getdel.js";
20
21
  export * from "./getrange.js";
21
22
  export * from "./getset.js";
22
- export * from "./getdel.js";
23
23
  export * from "./hdel.js";
24
24
  export * from "./hexists.js";
25
25
  export * from "./hget.js";
@@ -30,6 +30,7 @@ export * from "./hkeys.js";
30
30
  export * from "./hlen.js";
31
31
  export * from "./hmget.js";
32
32
  export * from "./hmset.js";
33
+ export * from "./hrandfield.js";
33
34
  export * from "./hscan.js";
34
35
  export * from "./hset.js";
35
36
  export * from "./hsetnx.js";
@@ -38,10 +39,32 @@ export * from "./hvals.js";
38
39
  export * from "./incr.js";
39
40
  export * from "./incrby.js";
40
41
  export * from "./incrbyfloat.js";
42
+ export * from "./json_arrappend.js";
43
+ export * from "./json_arrindex.js";
44
+ export * from "./json_arrinsert.js";
45
+ export * from "./json_arrlen.js";
46
+ export * from "./json_arrpop.js";
47
+ export * from "./json_arrtrim.js";
48
+ export * from "./json_clear.js";
49
+ export * from "./json_del.js";
50
+ export * from "./json_forget.js";
51
+ export * from "./json_get.js";
52
+ export * from "./json_mget.js";
53
+ export * from "./json_numincrby.js";
54
+ export * from "./json_nummultby.js";
55
+ export * from "./json_objkeys.js";
56
+ export * from "./json_objlen.js";
57
+ export * from "./json_resp.js";
58
+ export * from "./json_set.js";
59
+ export * from "./json_strappend.js";
60
+ export * from "./json_strlen.js";
61
+ export * from "./json_toggle.js";
62
+ export * from "./json_type.js";
41
63
  export * from "./keys.js";
42
64
  export * from "./lindex.js";
43
65
  export * from "./linsert.js";
44
66
  export * from "./llen.js";
67
+ export * from "./lmove.js";
45
68
  export * from "./lpop.js";
46
69
  export * from "./lpos.js";
47
70
  export * from "./lpush.js";
@@ -83,6 +106,7 @@ export * from "./sinter.js";
83
106
  export * from "./sinterstore.js";
84
107
  export * from "./sismember.js";
85
108
  export * from "./smembers.js";
109
+ export * from "./smismember.js";
86
110
  export * from "./smove.js";
87
111
  export * from "./spop.js";
88
112
  export * from "./srandmember.js";
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type ScanCommandOptions = {
2
+ export type ScanCommandOptions = {
3
3
  match?: string;
4
4
  count?: number;
5
5
  type?: string;
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type ScriptFlushCommandOptions = {
2
+ export type ScriptFlushCommandOptions = {
3
3
  sync: true;
4
4
  async?: never;
5
5
  } | {
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type SetCommandOptions = {
2
+ export type SetCommandOptions = {
3
3
  get: boolean;
4
4
  } | ({
5
5
  ex: number;
@@ -2,6 +2,6 @@ import { Command, CommandOptions } from "./command.js";
2
2
  /**
3
3
  * @see https://redis.io/commands/smembers
4
4
  */
5
- export declare class SMembersCommand<TData = string> extends Command<unknown[], TData[]> {
6
- constructor(cmd: [key: string], opts?: CommandOptions<unknown[], TData[]>);
5
+ export declare class SMembersCommand<TData extends unknown[] = string[]> extends Command<unknown[], TData> {
6
+ constructor(cmd: [key: string], opts?: CommandOptions<unknown[], TData>);
7
7
  }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/smismember
4
+ */
5
+ export declare class SMIsMemberCommand<TMembers extends unknown[]> extends Command<("0" | "1")[], (0 | 1)[]> {
6
+ constructor(cmd: [key: string, members: TMembers], opts?: CommandOptions<("0" | "1")[], (0 | 1)[]>);
7
+ }
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type Type = "string" | "list" | "set" | "zset" | "hash" | "none";
2
+ export type Type = "string" | "list" | "set" | "zset" | "hash" | "none";
3
3
  /**
4
4
  * @see https://redis.io/commands/type
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type ZAddCommandOptions = ({
2
+ export type ZAddCommandOptions = ({
3
3
  nx: true;
4
4
  xx?: never;
5
5
  } | {
@@ -11,10 +11,10 @@ export declare type ZAddCommandOptions = ({
11
11
  }) & {
12
12
  ch?: true;
13
13
  };
14
- export declare type ZAddCommandOptionsWithIncr = ZAddCommandOptions & {
14
+ export type ZAddCommandOptionsWithIncr = ZAddCommandOptions & {
15
15
  incr: true;
16
16
  };
17
- export declare type ScoreMember<TData> = {
17
+ export type ScoreMember<TData> = {
18
18
  score: number;
19
19
  member: TData;
20
20
  };
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/zdiffstore
4
+ */
5
+ export declare class ZDiffStoreCommand extends Command<number, number> {
6
+ constructor(cmd: [destination: string, numkeys: number, ...keys: string[]], opts?: CommandOptions<number, number>);
7
+ }
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type ZInterStoreCommandOptions = {
2
+ export type ZInterStoreCommandOptions = {
3
3
  aggregate?: "sum" | "min" | "max";
4
4
  } & ({
5
5
  weight: number;
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type ZRangeCommandOptions = {
2
+ export type ZRangeCommandOptions = {
3
3
  withScores?: boolean;
4
4
  rev?: boolean;
5
5
  } & ({
@@ -1,5 +1,5 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type ZUnionStoreCommandOptions = {
2
+ export type ZUnionStoreCommandOptions = {
3
3
  aggregate?: "sum" | "min" | "max";
4
4
  } & ({
5
5
  weight: number;
@@ -1,18 +1,20 @@
1
- export declare type UpstashRequest = {
1
+ import { Telemetry } from "./types.js";
2
+ type CacheSetting = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
3
+ export type UpstashRequest = {
2
4
  path?: string[];
3
5
  /**
4
6
  * Request body will be serialized to json
5
7
  */
6
8
  body?: unknown;
7
9
  };
8
- export declare type UpstashResponse<TResult> = {
10
+ export type UpstashResponse<TResult> = {
9
11
  result?: TResult;
10
12
  error?: string;
11
13
  };
12
14
  export interface Requester {
13
15
  request: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>;
14
16
  }
15
- export declare type RetryConfig = false | {
17
+ export type RetryConfig = false | {
16
18
  /**
17
19
  * The number of retries to attempt before giving up.
18
20
  *
@@ -29,10 +31,10 @@ export declare type RetryConfig = false | {
29
31
  */
30
32
  backoff?: (retryCount: number) => number;
31
33
  };
32
- export declare type Options = {
34
+ export type Options = {
33
35
  backend?: string;
34
36
  };
35
- export declare type RequesterConfig = {
37
+ export type RequesterConfig = {
36
38
  /**
37
39
  * Configure the retry behaviour in case of network errors
38
40
  */
@@ -61,29 +63,13 @@ export declare type RequesterConfig = {
61
63
  */
62
64
  responseEncoding?: false | "base64";
63
65
  };
64
- export declare type HttpClientConfig = {
66
+ export type HttpClientConfig = {
65
67
  headers?: Record<string, string>;
66
68
  baseUrl: string;
67
69
  options?: Options;
68
70
  retry?: RetryConfig;
69
71
  agent?: any;
70
- telemetry?: {
71
- /**
72
- * Upstash-Telemetry-Sdk
73
- * @example @upstash/redis@v1.1.1
74
- */
75
- sdk?: string;
76
- /**
77
- * Upstash-Telemetry-Platform
78
- * @example cloudflare
79
- */
80
- platform?: string;
81
- /**
82
- * Upstash-Telemetry-Runtime
83
- * @example node@v18
84
- */
85
- runtime?: string;
86
- };
72
+ cache?: CacheSetting;
87
73
  } & RequesterConfig;
88
74
  export declare class HttpClient implements Requester {
89
75
  baseUrl: string;
@@ -92,11 +78,14 @@ export declare class HttpClient implements Requester {
92
78
  backend?: string;
93
79
  agent: any;
94
80
  responseEncoding?: false | "base64";
81
+ cache?: CacheSetting;
95
82
  };
96
83
  readonly retry: {
97
84
  attempts: number;
98
85
  backoff: (retryCount: number) => number;
99
86
  };
100
87
  constructor(config: HttpClientConfig);
88
+ mergeTelemetry(telemetry: Telemetry): void;
101
89
  request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
102
90
  }
91
+ export {};
@@ -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";
@@ -85,6 +85,10 @@ export declare class Pipeline {
85
85
  * @see https://redis.io/commands/bitpos
86
86
  */
87
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;
88
92
  /**
89
93
  * @see https://redis.io/commands/dbsize
90
94
  */
@@ -197,6 +201,10 @@ export declare class Pipeline {
197
201
  hmset: <TData>(key: string, kv: {
198
202
  [field: string]: TData;
199
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;
200
208
  /**
201
209
  * @see https://redis.io/commands/hscan
202
210
  */
@@ -247,6 +255,10 @@ export declare class Pipeline {
247
255
  * @see https://redis.io/commands/llen
248
256
  */
249
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;
250
262
  /**
251
263
  * @see https://redis.io/commands/lpop
252
264
  */
@@ -415,7 +427,11 @@ export declare class Pipeline {
415
427
  /**
416
428
  * @see https://redis.io/commands/smembers
417
429
  */
418
- 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;
419
435
  /**
420
436
  * @see https://redis.io/commands/smove
421
437
  */
@@ -558,4 +574,30 @@ export declare class Pipeline {
558
574
  * @see https://redis.io/commands/zunionstore
559
575
  */
560
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
+ };
561
603
  }
@@ -1,22 +1,17 @@
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 type { RedisOptions, Telemetry } from "./types.js";
7
+ export type { RedisOptions } from "./types.js";
14
8
  /**
15
9
  * Serverless redis client for upstash.
16
10
  */
17
11
  export declare class Redis {
18
12
  protected client: Requester;
19
13
  protected opts?: CommandOptions<any, any>;
14
+ protected enableTelemetry: boolean;
20
15
  /**
21
16
  * Create a new redis client
22
17
  *
@@ -29,10 +24,106 @@ export declare class Redis {
29
24
  * ```
30
25
  */
31
26
  constructor(client: Requester, opts?: RedisOptions);
27
+ get json(): {
28
+ /**
29
+ * @see https://redis.io/commands/json.arrappend
30
+ */
31
+ arrappend: (key: string, path: string, ...values: unknown[]) => Promise<(number | null)[]>;
32
+ /**
33
+ * @see https://redis.io/commands/json.arrindex
34
+ */
35
+ arrindex: (key: string, path: string, value: unknown, start?: number | undefined, stop?: number | undefined) => Promise<(number | null)[]>;
36
+ /**
37
+ * @see https://redis.io/commands/json.arrinsert
38
+ */
39
+ arrinsert: (key: string, path: string, index: number, ...values: unknown[]) => Promise<(number | null)[]>;
40
+ /**
41
+ * @see https://redis.io/commands/json.arrlen
42
+ */
43
+ arrlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
44
+ /**
45
+ * @see https://redis.io/commands/json.arrpop
46
+ */
47
+ arrpop: (key: string, path?: string | undefined, index?: number | undefined) => Promise<unknown[]>;
48
+ /**
49
+ * @see https://redis.io/commands/json.arrtrim
50
+ */
51
+ arrtrim: (key: string, path?: string | undefined, start?: number | undefined, stop?: number | undefined) => Promise<(number | null)[]>;
52
+ /**
53
+ * @see https://redis.io/commands/json.clear
54
+ */
55
+ clear: (key: string, path?: string | undefined) => Promise<number>;
56
+ /**
57
+ * @see https://redis.io/commands/json.del
58
+ */
59
+ del: (key: string, path?: string | undefined) => Promise<number>;
60
+ /**
61
+ * @see https://redis.io/commands/json.forget
62
+ */
63
+ forget: (key: string, path?: string | undefined) => Promise<number>;
64
+ /**
65
+ * @see https://redis.io/commands/json.get
66
+ */
67
+ get: (...args: CommandArgs<typeof JsonGetCommand>) => Promise<any>;
68
+ /**
69
+ * @see https://redis.io/commands/json.mget
70
+ */
71
+ mget: (keys: string[], path: string) => Promise<any>;
72
+ /**
73
+ * @see https://redis.io/commands/json.numincrby
74
+ */
75
+ numincrby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
76
+ /**
77
+ * @see https://redis.io/commands/json.nummultby
78
+ */
79
+ nummultby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
80
+ /**
81
+ * @see https://redis.io/commands/json.objkeys
82
+ */
83
+ objkeys: (key: string, path?: string | undefined) => Promise<(string[] | null)[]>;
84
+ /**
85
+ * @see https://redis.io/commands/json.objlen
86
+ */
87
+ objlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
88
+ /**
89
+ * @see https://redis.io/commands/json.resp
90
+ */
91
+ resp: (key: string, path?: string | undefined) => Promise<any>;
92
+ /**
93
+ * @see https://redis.io/commands/json.set
94
+ */
95
+ set: (key: string, path: string, value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[], opts?: {
96
+ nx: true;
97
+ xx?: undefined;
98
+ } | {
99
+ nx?: undefined;
100
+ xx: true;
101
+ } | undefined) => Promise<"OK" | null>;
102
+ /**
103
+ * @see https://redis.io/commands/json.strappend
104
+ */
105
+ strappend: (key: string, path: string, value: string) => Promise<(number | null)[]>;
106
+ /**
107
+ * @see https://redis.io/commands/json.strlen
108
+ */
109
+ strlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
110
+ /**
111
+ * @see https://redis.io/commands/json.toggle
112
+ */
113
+ toggle: (key: string, path: string) => Promise<number[]>;
114
+ /**
115
+ * @see https://redis.io/commands/json.type
116
+ */
117
+ type: (key: string, path?: string | undefined) => Promise<string[]>;
118
+ };
32
119
  /**
33
120
  * Wrap a new middleware around the HTTP client.
34
121
  */
35
122
  use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
123
+ /**
124
+ * Technically this is not private, we can hide it from intellisense by doing this
125
+ */
126
+ protected addTelemetry: (telemetry: Telemetry) => void;
36
127
  createScript(script: string): Script;
37
128
  /**
38
129
  * Create a new pipeline that allows you to send requests in bulk.
@@ -181,6 +272,14 @@ export declare class Redis {
181
272
  hmset: <TData>(key: string, kv: {
182
273
  [field: string]: TData;
183
274
  }) => Promise<"OK">;
275
+ /**
276
+ * @see https://redis.io/commands/hrandfield
277
+ */
278
+ hrandfield: {
279
+ (key: string): Promise<string>;
280
+ (key: string, count: number): Promise<string[]>;
281
+ <TData extends Record<string, unknown>>(key: string, count: number, withValues: boolean): Promise<Partial<TData>>;
282
+ };
184
283
  /**
185
284
  * @see https://redis.io/commands/hscan
186
285
  */
@@ -231,6 +330,10 @@ export declare class Redis {
231
330
  * @see https://redis.io/commands/llen
232
331
  */
233
332
  llen: (key: string) => Promise<number>;
333
+ /**
334
+ * @see https://redis.io/commands/lmove
335
+ */
336
+ lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => Promise<TData>;
234
337
  /**
235
338
  * @see https://redis.io/commands/lpop
236
339
  */
@@ -399,10 +502,14 @@ export declare class Redis {
399
502
  * @see https://redis.io/commands/sismember
400
503
  */
401
504
  sismember: <TData>(key: string, member: TData) => Promise<0 | 1>;
505
+ /**
506
+ * @see https://redis.io/commands/smismember
507
+ */
508
+ smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => Promise<(0 | 1)[]>;
402
509
  /**
403
510
  * @see https://redis.io/commands/smembers
404
511
  */
405
- smembers: (key: string) => Promise<string[]>;
512
+ smembers: <TData extends unknown[] = string[]>(key: string) => Promise<TData>;
406
513
  /**
407
514
  * @see https://redis.io/commands/smove
408
515
  */
@@ -467,6 +574,10 @@ export declare class Redis {
467
574
  * @see https://redis.io/commands/zcount
468
575
  */
469
576
  zcount: (key: string, min: string | number, max: string | number) => Promise<number>;
577
+ /**
578
+ * @see https://redis.io/commands/zdiffstore
579
+ */
580
+ zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => Promise<number>;
470
581
  /**
471
582
  * @see https://redis.io/commands/zincrby
472
583
  */