@upstash/redis 0.0.0-ci.608697de-20221215 → 0.0.0-ci.62b04fa8-20231019

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_dist.js +9 -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 +151 -7
  37. package/esm/pkg/redis.js +180 -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_dist.js +13 -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 +150 -6
  79. package/script/pkg/redis.js +179 -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_dist.d.ts +12 -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 +255 -126
  128. package/types/pkg/redis.d.ts +153 -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,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,17 +24,121 @@ 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/geoadd
66
+ */
67
+ 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>;
68
+ /**
69
+ * @see https://redis.io/commands/geodist
70
+ */
71
+ geodist: (key: string, member1: unknown, member2: unknown, unit?: "M" | "KM" | "FT" | "MI" | undefined) => Promise<number | null>;
72
+ /**
73
+ * @see https://redis.io/commands/json.get
74
+ */
75
+ get: (...args: CommandArgs<typeof JsonGetCommand>) => Promise<any>;
76
+ /**
77
+ * @see https://redis.io/commands/json.mget
78
+ */
79
+ mget: (keys: string[], path: string) => Promise<any>;
80
+ /**
81
+ * @see https://redis.io/commands/json.numincrby
82
+ */
83
+ numincrby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
84
+ /**
85
+ * @see https://redis.io/commands/json.nummultby
86
+ */
87
+ nummultby: (key: string, path: string, value: number) => Promise<(number | null)[]>;
88
+ /**
89
+ * @see https://redis.io/commands/json.objkeys
90
+ */
91
+ objkeys: (key: string, path?: string | undefined) => Promise<(string[] | null)[]>;
92
+ /**
93
+ * @see https://redis.io/commands/json.objlen
94
+ */
95
+ objlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
96
+ /**
97
+ * @see https://redis.io/commands/json.resp
98
+ */
99
+ resp: (key: string, path?: string | undefined) => Promise<any>;
100
+ /**
101
+ * @see https://redis.io/commands/json.set
102
+ */
103
+ set: (key: string, path: string, value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[], opts?: {
104
+ nx: true;
105
+ xx?: undefined;
106
+ } | {
107
+ nx?: undefined;
108
+ xx: true;
109
+ } | undefined) => Promise<"OK" | null>;
110
+ /**
111
+ * @see https://redis.io/commands/json.strappend
112
+ */
113
+ strappend: (key: string, path: string, value: string) => Promise<(number | null)[]>;
114
+ /**
115
+ * @see https://redis.io/commands/json.strlen
116
+ */
117
+ strlen: (key: string, path?: string | undefined) => Promise<(number | null)[]>;
118
+ /**
119
+ * @see https://redis.io/commands/json.toggle
120
+ */
121
+ toggle: (key: string, path: string) => Promise<number[]>;
122
+ /**
123
+ * @see https://redis.io/commands/json.type
124
+ */
125
+ type: (key: string, path?: string | undefined) => Promise<string[]>;
126
+ };
32
127
  /**
33
128
  * Wrap a new middleware around the HTTP client.
34
129
  */
35
130
  use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
131
+ /**
132
+ * Technically this is not private, we can hide it from intellisense by doing this
133
+ */
134
+ protected addTelemetry: (telemetry: Telemetry) => void;
36
135
  createScript(script: string): Script;
37
136
  /**
38
137
  * Create a new pipeline that allows you to send requests in bulk.
39
138
  *
40
139
  * @see {@link Pipeline}
41
140
  */
42
- pipeline: () => Pipeline;
141
+ pipeline: () => Pipeline<[]>;
43
142
  /**
44
143
  * Create a new transaction to allow executing multiple steps atomically.
45
144
  *
@@ -49,7 +148,7 @@ export declare class Redis {
49
148
  *
50
149
  * @see {@link Pipeline}
51
150
  */
52
- multi: () => Pipeline;
151
+ multi: () => Pipeline<[]>;
53
152
  /**
54
153
  * @see https://redis.io/commands/append
55
154
  */
@@ -142,7 +241,7 @@ export declare class Redis {
142
241
  /**
143
242
  * @see https://redis.io/commands/hdel
144
243
  */
145
- hdel: (key: string, field: string) => Promise<0 | 1>;
244
+ hdel: (key: string, ...fields: string[]) => Promise<0 | 1>;
146
245
  /**
147
246
  * @see https://redis.io/commands/hexists
148
247
  */
@@ -239,6 +338,10 @@ export declare class Redis {
239
338
  * @see https://redis.io/commands/llen
240
339
  */
241
340
  llen: (key: string) => Promise<number>;
341
+ /**
342
+ * @see https://redis.io/commands/lmove
343
+ */
344
+ lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => Promise<TData>;
242
345
  /**
243
346
  * @see https://redis.io/commands/lpop
244
347
  */
@@ -407,10 +510,14 @@ export declare class Redis {
407
510
  * @see https://redis.io/commands/sismember
408
511
  */
409
512
  sismember: <TData>(key: string, member: TData) => Promise<0 | 1>;
513
+ /**
514
+ * @see https://redis.io/commands/smismember
515
+ */
516
+ smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => Promise<(0 | 1)[]>;
410
517
  /**
411
518
  * @see https://redis.io/commands/smembers
412
519
  */
413
- smembers: (key: string) => Promise<string[]>;
520
+ smembers: <TData extends unknown[] = string[]>(key: string) => Promise<TData>;
414
521
  /**
415
522
  * @see https://redis.io/commands/smove
416
523
  */
@@ -463,6 +570,31 @@ export declare class Redis {
463
570
  * @see https://redis.io/commands/unlink
464
571
  */
465
572
  unlink: (...args: CommandArgs<typeof UnlinkCommand>) => Promise<number>;
573
+ /**
574
+ * @see https://redis.io/commands/xadd
575
+ */
576
+ xadd: (key: string, id: string, entries: {
577
+ [field: string]: unknown;
578
+ }, opts?: {
579
+ nomkStream?: boolean | undefined;
580
+ trim?: (({
581
+ type: "MAXLEN" | "maxlen";
582
+ threshold: number;
583
+ } | {
584
+ type: "MINID" | "minid";
585
+ threshold: string;
586
+ }) & ({
587
+ comparison: "~";
588
+ limit?: number | undefined;
589
+ } | {
590
+ comparison: "=";
591
+ limit?: undefined;
592
+ })) | undefined;
593
+ } | undefined) => Promise<string>;
594
+ /**
595
+ * @see https://redis.io/commands/xrange
596
+ */
597
+ xrange: (key: string, start: string, end: string, count?: number | undefined) => Promise<Record<string, Record<string, unknown>>>;
466
598
  /**
467
599
  * @see https://redis.io/commands/zadd
468
600
  */
@@ -475,6 +607,10 @@ export declare class Redis {
475
607
  * @see https://redis.io/commands/zcount
476
608
  */
477
609
  zcount: (key: string, min: string | number, max: string | number) => Promise<number>;
610
+ /**
611
+ * @see https://redis.io/commands/zdiffstore
612
+ */
613
+ zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => Promise<number>;
478
614
  /**
479
615
  * @see https://redis.io/commands/zincrby
480
616
  */
@@ -549,6 +685,10 @@ export declare class Redis {
549
685
  * @see https://redis.io/commands/zscore
550
686
  */
551
687
  zscore: <TData>(key: string, member: TData) => Promise<number | null>;
688
+ /**
689
+ * @see https://redis.io/commands/zunion
690
+ */
691
+ zunion: (numKeys: number, keys: string[], opts?: import("./commands/zunion.js").ZUnionCommandOptions | undefined) => Promise<any>;
552
692
  /**
553
693
  * @see https://redis.io/commands/zunionstore
554
694
  */
@@ -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.608697de-20221215";
1
+ export declare const VERSION = "v0.0.0-ci.62b04fa8-20231019";