@upstash/redis 0.0.0-ci.bc3aba1f-20221124 → 0.0.0-ci.bc4f4560-20231018

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 (134) hide show
  1. package/README.md +8 -1
  2. package/esm/pkg/commands/command.js +12 -3
  3. package/esm/pkg/commands/geo_add.js +27 -0
  4. package/esm/pkg/commands/geo_hash.js +14 -0
  5. package/esm/pkg/commands/hgetall.js +9 -1
  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 +28 -0
  29. package/esm/pkg/commands/set.js +1 -1
  30. package/esm/pkg/commands/smismember.js +9 -0
  31. package/esm/pkg/commands/xadd.js +26 -0
  32. package/esm/pkg/commands/xrange.js +36 -0
  33. package/esm/pkg/commands/zdiffstore.js +9 -0
  34. package/esm/pkg/commands/zunion.js +30 -0
  35. package/esm/pkg/http.js +42 -25
  36. package/esm/pkg/pipeline.js +147 -7
  37. package/esm/pkg/redis.js +181 -1
  38. package/esm/platforms/cloudflare.js +6 -6
  39. package/esm/platforms/fastly.js +5 -0
  40. package/esm/platforms/node_with_fetch.js +23 -11
  41. package/esm/platforms/nodejs.js +21 -11
  42. package/esm/version.js +1 -1
  43. package/package.json +53 -20
  44. package/script/pkg/commands/command.js +12 -3
  45. package/script/pkg/commands/geo_add.js +31 -0
  46. package/script/pkg/commands/geo_hash.js +18 -0
  47. package/script/pkg/commands/hgetall.js +9 -1
  48. package/script/pkg/commands/json_arrappend.js +13 -0
  49. package/script/pkg/commands/json_arrindex.js +13 -0
  50. package/script/pkg/commands/json_arrinsert.js +13 -0
  51. package/script/pkg/commands/json_arrlen.js +13 -0
  52. package/script/pkg/commands/json_arrpop.js +13 -0
  53. package/script/pkg/commands/json_arrtrim.js +16 -0
  54. package/script/pkg/commands/json_clear.js +13 -0
  55. package/script/pkg/commands/json_del.js +13 -0
  56. package/script/pkg/commands/json_forget.js +13 -0
  57. package/script/pkg/commands/json_get.js +34 -0
  58. package/script/pkg/commands/json_mget.js +13 -0
  59. package/script/pkg/commands/json_numincrby.js +13 -0
  60. package/script/pkg/commands/json_nummultby.js +13 -0
  61. package/script/pkg/commands/json_objkeys.js +13 -0
  62. package/script/pkg/commands/json_objlen.js +13 -0
  63. package/script/pkg/commands/json_resp.js +13 -0
  64. package/script/pkg/commands/json_set.js +22 -0
  65. package/script/pkg/commands/json_strappend.js +13 -0
  66. package/script/pkg/commands/json_strlen.js +13 -0
  67. package/script/pkg/commands/json_toggle.js +13 -0
  68. package/script/pkg/commands/json_type.js +13 -0
  69. package/script/pkg/commands/lmove.js +13 -0
  70. package/script/pkg/commands/mod.js +28 -0
  71. package/script/pkg/commands/set.js +1 -1
  72. package/script/pkg/commands/smismember.js +13 -0
  73. package/script/pkg/commands/xadd.js +30 -0
  74. package/script/pkg/commands/xrange.js +40 -0
  75. package/script/pkg/commands/zdiffstore.js +13 -0
  76. package/script/pkg/commands/zunion.js +34 -0
  77. package/script/pkg/http.js +42 -25
  78. package/script/pkg/pipeline.js +146 -6
  79. package/script/pkg/redis.js +180 -0
  80. package/script/platforms/cloudflare.js +6 -6
  81. package/script/platforms/fastly.js +5 -0
  82. package/script/platforms/node_with_fetch.js +23 -11
  83. package/script/platforms/nodejs.js +21 -11
  84. package/script/version.js +1 -1
  85. package/types/pkg/commands/command.d.ts +5 -5
  86. package/types/pkg/commands/geo_add.d.ts +25 -0
  87. package/types/pkg/commands/geo_hash.d.ts +7 -0
  88. package/types/pkg/commands/hdel.d.ts +1 -1
  89. package/types/pkg/commands/json_arrappend.d.ts +7 -0
  90. package/types/pkg/commands/json_arrindex.d.ts +13 -0
  91. package/types/pkg/commands/json_arrinsert.d.ts +7 -0
  92. package/types/pkg/commands/json_arrlen.d.ts +7 -0
  93. package/types/pkg/commands/json_arrpop.d.ts +7 -0
  94. package/types/pkg/commands/json_arrtrim.d.ts +7 -0
  95. package/types/pkg/commands/json_clear.d.ts +7 -0
  96. package/types/pkg/commands/json_del.d.ts +7 -0
  97. package/types/pkg/commands/json_forget.d.ts +7 -0
  98. package/types/pkg/commands/json_get.d.ts +15 -0
  99. package/types/pkg/commands/json_mget.d.ts +7 -0
  100. package/types/pkg/commands/json_numincrby.d.ts +7 -0
  101. package/types/pkg/commands/json_nummultby.d.ts +7 -0
  102. package/types/pkg/commands/json_objkeys.d.ts +7 -0
  103. package/types/pkg/commands/json_objlen.d.ts +7 -0
  104. package/types/pkg/commands/json_resp.d.ts +7 -0
  105. package/types/pkg/commands/json_set.d.ts +18 -0
  106. package/types/pkg/commands/json_strappend.d.ts +7 -0
  107. package/types/pkg/commands/json_strlen.d.ts +7 -0
  108. package/types/pkg/commands/json_toggle.d.ts +7 -0
  109. package/types/pkg/commands/json_type.d.ts +7 -0
  110. package/types/pkg/commands/lmove.d.ts +12 -0
  111. package/types/pkg/commands/mod.d.ts +28 -0
  112. package/types/pkg/commands/scan.d.ts +1 -1
  113. package/types/pkg/commands/script_flush.d.ts +1 -1
  114. package/types/pkg/commands/set.d.ts +3 -3
  115. package/types/pkg/commands/smembers.d.ts +2 -2
  116. package/types/pkg/commands/smismember.d.ts +7 -0
  117. package/types/pkg/commands/type.d.ts +1 -1
  118. package/types/pkg/commands/xadd.d.ts +31 -0
  119. package/types/pkg/commands/xrange.d.ts +9 -0
  120. package/types/pkg/commands/zadd.d.ts +3 -3
  121. package/types/pkg/commands/zdiffstore.d.ts +7 -0
  122. package/types/pkg/commands/zinterstore.d.ts +1 -1
  123. package/types/pkg/commands/zrange.d.ts +1 -1
  124. package/types/pkg/commands/zunion.d.ts +29 -0
  125. package/types/pkg/commands/zunionstore.d.ts +1 -1
  126. package/types/pkg/http.d.ts +16 -23
  127. package/types/pkg/pipeline.d.ts +251 -126
  128. package/types/pkg/redis.d.ts +154 -13
  129. package/types/pkg/types.d.ts +27 -1
  130. package/types/platforms/cloudflare.d.ts +2 -2
  131. package/types/platforms/fastly.d.ts +1 -1
  132. package/types/platforms/node_with_fetch.d.ts +1 -1
  133. package/types/platforms/nodejs.d.ts +1 -1
  134. package/types/version.d.ts +1 -1
@@ -1,22 +1,18 @@
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
+ import { GeoHashCommand } from "./commands/geo_hash.js";
8
+ export type { RedisOptions } from "./types.js";
14
9
  /**
15
10
  * Serverless redis client for upstash.
16
11
  */
17
12
  export declare class Redis {
18
13
  protected client: Requester;
19
14
  protected opts?: CommandOptions<any, any>;
15
+ protected enableTelemetry: boolean;
20
16
  /**
21
17
  * Create a new redis client
22
18
  *
@@ -29,17 +25,121 @@ export declare class Redis {
29
25
  * ```
30
26
  */
31
27
  constructor(client: Requester, opts?: RedisOptions);
28
+ get json(): {
29
+ /**
30
+ * @see https://redis.io/commands/json.arrappend
31
+ */
32
+ arrappend: (key: string, path: string, ...values: unknown[]) => Promise<(number | null)[]>;
33
+ /**
34
+ * @see https://redis.io/commands/json.arrindex
35
+ */
36
+ arrindex: (key: string, path: string, value: unknown, start?: number | undefined, stop?: number | undefined) => Promise<(number | null)[]>;
37
+ /**
38
+ * @see https://redis.io/commands/json.arrinsert
39
+ */
40
+ arrinsert: (key: string, path: string, index: number, ...values: unknown[]) => Promise<(number | null)[]>;
41
+ /**
42
+ * @see https://redis.io/commands/json.arrlen
43
+ */
44
+ arrlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
45
+ /**
46
+ * @see https://redis.io/commands/json.arrpop
47
+ */
48
+ arrpop: (key: string, path?: string | undefined, index?: number | undefined) => Promise<unknown[]>;
49
+ /**
50
+ * @see https://redis.io/commands/json.arrtrim
51
+ */
52
+ arrtrim: (key: string, path?: string | undefined, start?: number | undefined, stop?: number | undefined) => Promise<(number | null)[]>;
53
+ /**
54
+ * @see https://redis.io/commands/json.clear
55
+ */
56
+ clear: (key: string, path?: string | undefined) => Promise<number>;
57
+ /**
58
+ * @see https://redis.io/commands/json.del
59
+ */
60
+ del: (key: string, path?: string | undefined) => Promise<number>;
61
+ /**
62
+ * @see https://redis.io/commands/json.forget
63
+ */
64
+ forget: (key: string, path?: string | undefined) => Promise<number>;
65
+ /**
66
+ * @see https://redis.io/commands/geoadd
67
+ */
68
+ geoadd: (args_0: string, args_1: import("./commands/geo_add.js").GeoAddCommandOptions | import("./commands/geo_add.js").GeoMember<unknown>, ...args_2: import("./commands/geo_add.js").GeoMember<unknown>[]) => Promise<number | null>;
69
+ /**
70
+ * @see https://redis.io/commands/geohash
71
+ */
72
+ geohash: (...args: CommandArgs<typeof GeoHashCommand>) => Promise<any>;
73
+ /**
74
+ * @see https://redis.io/commands/json.get
75
+ */
76
+ get: (...args: CommandArgs<typeof JsonGetCommand>) => Promise<any>;
77
+ /**
78
+ * @see https://redis.io/commands/json.mget
79
+ */
80
+ mget: (keys: string[], path: string) => Promise<any>;
81
+ /**
82
+ * @see https://redis.io/commands/json.numincrby
83
+ */
84
+ numincrby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
85
+ /**
86
+ * @see https://redis.io/commands/json.nummultby
87
+ */
88
+ nummultby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
89
+ /**
90
+ * @see https://redis.io/commands/json.objkeys
91
+ */
92
+ objkeys: (key: string, path?: string | undefined) => Promise<(string[] | null)[]>;
93
+ /**
94
+ * @see https://redis.io/commands/json.objlen
95
+ */
96
+ objlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
97
+ /**
98
+ * @see https://redis.io/commands/json.resp
99
+ */
100
+ resp: (key: string, path?: string | undefined) => Promise<any>;
101
+ /**
102
+ * @see https://redis.io/commands/json.set
103
+ */
104
+ set: (key: string, path: string, value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[], opts?: {
105
+ nx: true;
106
+ xx?: undefined;
107
+ } | {
108
+ nx?: undefined;
109
+ xx: true;
110
+ } | undefined) => Promise<"OK" | null>;
111
+ /**
112
+ * @see https://redis.io/commands/json.strappend
113
+ */
114
+ strappend: (key: string, path: string, value: string) => Promise<(number | null)[]>;
115
+ /**
116
+ * @see https://redis.io/commands/json.strlen
117
+ */
118
+ strlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
119
+ /**
120
+ * @see https://redis.io/commands/json.toggle
121
+ */
122
+ toggle: (key: string, path: string) => Promise<number[]>;
123
+ /**
124
+ * @see https://redis.io/commands/json.type
125
+ */
126
+ type: (key: string, path?: string | undefined) => Promise<string[]>;
127
+ };
32
128
  /**
33
129
  * Wrap a new middleware around the HTTP client.
34
130
  */
35
131
  use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
132
+ /**
133
+ * Technically this is not private, we can hide it from intellisense by doing this
134
+ */
135
+ protected addTelemetry: (telemetry: Telemetry) => void;
36
136
  createScript(script: string): Script;
37
137
  /**
38
138
  * Create a new pipeline that allows you to send requests in bulk.
39
139
  *
40
140
  * @see {@link Pipeline}
41
141
  */
42
- pipeline: () => Pipeline;
142
+ pipeline: () => Pipeline<[]>;
43
143
  /**
44
144
  * Create a new transaction to allow executing multiple steps atomically.
45
145
  *
@@ -49,7 +149,7 @@ export declare class Redis {
49
149
  *
50
150
  * @see {@link Pipeline}
51
151
  */
52
- multi: () => Pipeline;
152
+ multi: () => Pipeline<[]>;
53
153
  /**
54
154
  * @see https://redis.io/commands/append
55
155
  */
@@ -142,7 +242,7 @@ export declare class Redis {
142
242
  /**
143
243
  * @see https://redis.io/commands/hdel
144
244
  */
145
- hdel: (key: string, field: string) => Promise<0 | 1>;
245
+ hdel: (key: string, ...fields: string[]) => Promise<0 | 1>;
146
246
  /**
147
247
  * @see https://redis.io/commands/hexists
148
248
  */
@@ -239,6 +339,10 @@ export declare class Redis {
239
339
  * @see https://redis.io/commands/llen
240
340
  */
241
341
  llen: (key: string) => Promise<number>;
342
+ /**
343
+ * @see https://redis.io/commands/lmove
344
+ */
345
+ lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => Promise<TData>;
242
346
  /**
243
347
  * @see https://redis.io/commands/lpop
244
348
  */
@@ -407,10 +511,14 @@ export declare class Redis {
407
511
  * @see https://redis.io/commands/sismember
408
512
  */
409
513
  sismember: <TData>(key: string, member: TData) => Promise<0 | 1>;
514
+ /**
515
+ * @see https://redis.io/commands/smismember
516
+ */
517
+ smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => Promise<(0 | 1)[]>;
410
518
  /**
411
519
  * @see https://redis.io/commands/smembers
412
520
  */
413
- smembers: (key: string) => Promise<string[]>;
521
+ smembers: <TData extends unknown[] = string[]>(key: string) => Promise<TData>;
414
522
  /**
415
523
  * @see https://redis.io/commands/smove
416
524
  */
@@ -463,6 +571,31 @@ export declare class Redis {
463
571
  * @see https://redis.io/commands/unlink
464
572
  */
465
573
  unlink: (...args: CommandArgs<typeof UnlinkCommand>) => Promise<number>;
574
+ /**
575
+ * @see https://redis.io/commands/xadd
576
+ */
577
+ xadd: (key: string, id: string, entries: {
578
+ [field: string]: unknown;
579
+ }, opts?: {
580
+ nomkStream?: boolean | undefined;
581
+ trim?: (({
582
+ type: "MAXLEN" | "maxlen";
583
+ threshold: number;
584
+ } | {
585
+ type: "MINID" | "minid";
586
+ threshold: string;
587
+ }) & ({
588
+ comparison: "~";
589
+ limit?: number | undefined;
590
+ } | {
591
+ comparison: "=";
592
+ limit?: undefined;
593
+ })) | undefined;
594
+ } | undefined) => Promise<string>;
595
+ /**
596
+ * @see https://redis.io/commands/xrange
597
+ */
598
+ xrange: (key: string, start: string, end: string, count?: number | undefined) => Promise<Record<string, Record<string, unknown>>>;
466
599
  /**
467
600
  * @see https://redis.io/commands/zadd
468
601
  */
@@ -475,6 +608,10 @@ export declare class Redis {
475
608
  * @see https://redis.io/commands/zcount
476
609
  */
477
610
  zcount: (key: string, min: string | number, max: string | number) => Promise<number>;
611
+ /**
612
+ * @see https://redis.io/commands/zdiffstore
613
+ */
614
+ zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => Promise<number>;
478
615
  /**
479
616
  * @see https://redis.io/commands/zincrby
480
617
  */
@@ -549,6 +686,10 @@ export declare class Redis {
549
686
  * @see https://redis.io/commands/zscore
550
687
  */
551
688
  zscore: <TData>(key: string, member: TData) => Promise<number | null>;
689
+ /**
690
+ * @see https://redis.io/commands/zunion
691
+ */
692
+ zunion: (numKeys: number, keys: string[], opts?: import("./commands/zunion.js").ZUnionCommandOptions | undefined) => Promise<any>;
552
693
  /**
553
694
  * @see https://redis.io/commands/zunionstore
554
695
  */
@@ -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,7 +1,7 @@
1
1
  import * as core from "../pkg/redis.js";
2
2
  import type { Requester, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  import { RequesterConfig } from "../pkg/http.js";
4
- declare type Env = {
4
+ type Env = {
5
5
  UPSTASH_DISABLE_TELEMETRY?: string;
6
6
  };
7
7
  export type { Requester, UpstashRequest, UpstashResponse };
@@ -9,7 +9,7 @@ export type { Requester, UpstashRequest, UpstashResponse };
9
9
  * Connection credentials for upstash redis.
10
10
  * Get them from https://console.upstash.com/redis/<uuid>
11
11
  */
12
- export declare type RedisConfigCloudflare = {
12
+ export type RedisConfigCloudflare = {
13
13
  /**
14
14
  * UPSTASH_REDIS_REST_URL
15
15
  */
@@ -5,7 +5,7 @@ export type { Requester, UpstashRequest, UpstashResponse };
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
  */
@@ -6,7 +6,7 @@ export type { Requester, UpstashRequest, UpstashResponse };
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
  */
@@ -5,7 +5,7 @@ export type { Requester, UpstashRequest, UpstashResponse };
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
  */
@@ -1 +1 @@
1
- export declare const VERSION = "v0.0.0-ci.bc3aba1f-20221124";
1
+ export declare const VERSION = "v0.0.0-ci.bc4f4560-20231018";