@upstash/redis 1.0.0-alpha.2 → 1.0.0-alpha.7

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 (268) hide show
  1. package/README.md +256 -0
  2. package/{dist/chunk-7YUZYRJS.mjs → chunk-7YUZYRJS.mjs} +0 -0
  3. package/{dist/chunk-FJSI5EBJ.mjs → chunk-AHCVU33N.mjs} +2 -2
  4. package/{dist/chunk-ZIB6XPPC.mjs → chunk-HGM7M7CJ.mjs} +9 -4
  5. package/{dist/chunk-U7OXAQMQ.mjs → chunk-HIDCSH5S.mjs} +0 -1
  6. package/{dist/chunk-Y5TC4HX2.mjs → chunk-T66TTHSV.mjs} +5 -5
  7. package/{dist/cloudflare.d.ts → cloudflare.d.ts} +2 -2
  8. package/{dist/cloudflare.js → cloudflare.js} +12 -9
  9. package/{dist/cloudflare.mjs → cloudflare.mjs} +3 -3
  10. package/{dist/commands.d.ts → commands.d.ts} +5 -3
  11. package/{dist/commands.js → commands.js} +10 -4
  12. package/{dist/commands.mjs → commands.mjs} +3 -1
  13. package/{dist/fastly.d.ts → fastly.d.ts} +2 -2
  14. package/{dist/fastly.js → fastly.js} +12 -9
  15. package/{dist/fastly.mjs → fastly.mjs} +3 -3
  16. package/{dist/http.d.ts → http.d.ts} +0 -0
  17. package/{dist/http.js → http.js} +0 -1
  18. package/{dist/http.mjs → http.mjs} +1 -1
  19. package/{dist/index.d.ts → index.d.ts} +2 -2
  20. package/{dist/index.js → index.js} +13 -10
  21. package/index.mjs +13 -0
  22. package/{dist/nodejs.d.ts → nodejs.d.ts} +2 -2
  23. package/{dist/nodejs.js → nodejs.js} +13 -10
  24. package/nodejs.mjs +10 -0
  25. package/package.json +1 -1
  26. package/{dist/redis-dd052782.d.ts → redis-71fa1ee6.d.ts} +7 -3
  27. package/{dist/zunionstore-dffa797d.d.ts → zunionstore-b38007ba.d.ts} +1 -1
  28. package/.eslintrc.js +0 -49
  29. package/.prettierrc.js +0 -7
  30. package/LICENSE +0 -21
  31. package/dist/index.mjs +0 -13
  32. package/dist/nodejs.mjs +0 -10
  33. package/dist/package.json +0 -1
  34. package/jest.config.js +0 -195
  35. package/pkg/cloudflare.ts +0 -77
  36. package/pkg/command.ts +0 -40
  37. package/pkg/commands/append.test.ts +0 -28
  38. package/pkg/commands/append.ts +0 -10
  39. package/pkg/commands/bitcount.test.ts +0 -36
  40. package/pkg/commands/bitcount.ts +0 -19
  41. package/pkg/commands/bitop.test.ts +0 -44
  42. package/pkg/commands/bitop.ts +0 -22
  43. package/pkg/commands/bitpos.test.ts +0 -26
  44. package/pkg/commands/bitpos.ts +0 -10
  45. package/pkg/commands/dbsize.test.ts +0 -17
  46. package/pkg/commands/dbsize.ts +0 -10
  47. package/pkg/commands/decr.test.ts +0 -22
  48. package/pkg/commands/decr.ts +0 -10
  49. package/pkg/commands/decrby.test.ts +0 -23
  50. package/pkg/commands/decrby.ts +0 -10
  51. package/pkg/commands/del.test.ts +0 -38
  52. package/pkg/commands/del.ts +0 -11
  53. package/pkg/commands/echo.test.ts +0 -11
  54. package/pkg/commands/echo.ts +0 -10
  55. package/pkg/commands/exists.test.ts +0 -37
  56. package/pkg/commands/exists.ts +0 -11
  57. package/pkg/commands/expire.test.ts +0 -22
  58. package/pkg/commands/expire.ts +0 -10
  59. package/pkg/commands/expireat.test.ts +0 -24
  60. package/pkg/commands/expireat.ts +0 -10
  61. package/pkg/commands/flushall.test.ts +0 -17
  62. package/pkg/commands/flushall.ts +0 -13
  63. package/pkg/commands/flushdb.test.ts +0 -17
  64. package/pkg/commands/flushdb.ts +0 -13
  65. package/pkg/commands/get.test.ts +0 -34
  66. package/pkg/commands/get.ts +0 -10
  67. package/pkg/commands/getbit.test.ts +0 -16
  68. package/pkg/commands/getbit.ts +0 -10
  69. package/pkg/commands/getrange.test.ts +0 -25
  70. package/pkg/commands/getrange.ts +0 -10
  71. package/pkg/commands/getset.test.ts +0 -33
  72. package/pkg/commands/getset.ts +0 -10
  73. package/pkg/commands/hdel.test.ts +0 -30
  74. package/pkg/commands/hdel.ts +0 -10
  75. package/pkg/commands/hexists.test.ts +0 -31
  76. package/pkg/commands/hexists.ts +0 -10
  77. package/pkg/commands/hget.test.ts +0 -47
  78. package/pkg/commands/hget.ts +0 -10
  79. package/pkg/commands/hgetall.test.ts +0 -32
  80. package/pkg/commands/hgetall.ts +0 -35
  81. package/pkg/commands/hincrby.test.ts +0 -27
  82. package/pkg/commands/hincrby.ts +0 -10
  83. package/pkg/commands/hincrbyfloat.test.ts +0 -25
  84. package/pkg/commands/hincrbyfloat.ts +0 -10
  85. package/pkg/commands/hkeys.test.ts +0 -22
  86. package/pkg/commands/hkeys.ts +0 -10
  87. package/pkg/commands/hlen.test.ts +0 -24
  88. package/pkg/commands/hlen.ts +0 -10
  89. package/pkg/commands/hmget.test.ts +0 -48
  90. package/pkg/commands/hmget.ts +0 -41
  91. package/pkg/commands/hmset.test.ts +0 -24
  92. package/pkg/commands/hmset.ts +0 -10
  93. package/pkg/commands/hscan.test.ts +0 -46
  94. package/pkg/commands/hscan.ts +0 -22
  95. package/pkg/commands/hset.test.ts +0 -21
  96. package/pkg/commands/hset.ts +0 -10
  97. package/pkg/commands/hsetnx.test.ts +0 -37
  98. package/pkg/commands/hsetnx.ts +0 -10
  99. package/pkg/commands/hstrlen.test.ts +0 -24
  100. package/pkg/commands/hstrlen.ts +0 -10
  101. package/pkg/commands/hvals.test.ts +0 -23
  102. package/pkg/commands/hvals.ts +0 -10
  103. package/pkg/commands/incr.test.ts +0 -23
  104. package/pkg/commands/incr.ts +0 -10
  105. package/pkg/commands/incrby.test.ts +0 -23
  106. package/pkg/commands/incrby.ts +0 -10
  107. package/pkg/commands/incrbyfloat.test.ts +0 -24
  108. package/pkg/commands/incrbyfloat.ts +0 -10
  109. package/pkg/commands/index.ts +0 -107
  110. package/pkg/commands/keys.test.ts +0 -17
  111. package/pkg/commands/keys.ts +0 -10
  112. package/pkg/commands/lindex.test.ts +0 -33
  113. package/pkg/commands/lindex.ts +0 -7
  114. package/pkg/commands/linsert.test.ts +0 -19
  115. package/pkg/commands/linsert.ts +0 -6
  116. package/pkg/commands/llen.test.ts +0 -26
  117. package/pkg/commands/llen.ts +0 -10
  118. package/pkg/commands/lpop.test.ts +0 -27
  119. package/pkg/commands/lpop.ts +0 -10
  120. package/pkg/commands/lpush.test.ts +0 -17
  121. package/pkg/commands/lpush.ts +0 -11
  122. package/pkg/commands/lpushx.test.ts +0 -29
  123. package/pkg/commands/lpushx.ts +0 -11
  124. package/pkg/commands/lrange.test.ts +0 -22
  125. package/pkg/commands/lrange.ts +0 -7
  126. package/pkg/commands/lrem.test.ts +0 -19
  127. package/pkg/commands/lrem.ts +0 -6
  128. package/pkg/commands/lset.test.ts +0 -40
  129. package/pkg/commands/lset.ts +0 -7
  130. package/pkg/commands/ltrim.test.ts +0 -29
  131. package/pkg/commands/ltrim.ts +0 -7
  132. package/pkg/commands/mget.test.ts +0 -44
  133. package/pkg/commands/mget.ts +0 -9
  134. package/pkg/commands/mset.test.ts +0 -24
  135. package/pkg/commands/mset.ts +0 -10
  136. package/pkg/commands/msetnx.test.ts +0 -46
  137. package/pkg/commands/msetnx.ts +0 -10
  138. package/pkg/commands/persist.test.ts +0 -22
  139. package/pkg/commands/persist.ts +0 -10
  140. package/pkg/commands/pexpire.test.ts +0 -24
  141. package/pkg/commands/pexpire.ts +0 -10
  142. package/pkg/commands/pexpireat.test.ts +0 -24
  143. package/pkg/commands/pexpireat.ts +0 -10
  144. package/pkg/commands/ping.test.ts +0 -19
  145. package/pkg/commands/ping.ts +0 -13
  146. package/pkg/commands/psetex.test.ts +0 -23
  147. package/pkg/commands/psetex.ts +0 -10
  148. package/pkg/commands/pttl.test.ts +0 -17
  149. package/pkg/commands/pttl.ts +0 -10
  150. package/pkg/commands/randomkey.test.ts +0 -17
  151. package/pkg/commands/randomkey.ts +0 -10
  152. package/pkg/commands/rename.test.ts +0 -18
  153. package/pkg/commands/rename.ts +0 -10
  154. package/pkg/commands/renamenx.test.ts +0 -32
  155. package/pkg/commands/renamenx.ts +0 -10
  156. package/pkg/commands/rpop.test.ts +0 -27
  157. package/pkg/commands/rpop.ts +0 -10
  158. package/pkg/commands/rpush.test.ts +0 -17
  159. package/pkg/commands/rpush.ts +0 -11
  160. package/pkg/commands/rpushx.test.ts +0 -29
  161. package/pkg/commands/rpushx.ts +0 -11
  162. package/pkg/commands/sadd.test.ts +0 -16
  163. package/pkg/commands/sadd.ts +0 -11
  164. package/pkg/commands/scan.test.ts +0 -50
  165. package/pkg/commands/scan.ts +0 -21
  166. package/pkg/commands/scard.test.ts +0 -15
  167. package/pkg/commands/scard.ts +0 -9
  168. package/pkg/commands/sdiff.test.ts +0 -20
  169. package/pkg/commands/sdiff.ts +0 -9
  170. package/pkg/commands/sdiffstore.test.ts +0 -21
  171. package/pkg/commands/sdiffstore.ts +0 -10
  172. package/pkg/commands/set.test.ts +0 -112
  173. package/pkg/commands/set.ts +0 -53
  174. package/pkg/commands/setbit.test.ts +0 -16
  175. package/pkg/commands/setbit.ts +0 -10
  176. package/pkg/commands/setex.test.ts +0 -22
  177. package/pkg/commands/setex.ts +0 -10
  178. package/pkg/commands/setnx.test.ts +0 -27
  179. package/pkg/commands/setnx.ts +0 -10
  180. package/pkg/commands/setrange.test.ts +0 -25
  181. package/pkg/commands/setrange.ts +0 -10
  182. package/pkg/commands/sinter.test.ts +0 -36
  183. package/pkg/commands/sinter.ts +0 -9
  184. package/pkg/commands/sinterstore.test.ts +0 -21
  185. package/pkg/commands/sinterstore.ts +0 -9
  186. package/pkg/commands/sismember.test.ts +0 -30
  187. package/pkg/commands/sismember.ts +0 -9
  188. package/pkg/commands/smembers.test.ts +0 -22
  189. package/pkg/commands/smembers.ts +0 -10
  190. package/pkg/commands/smove.test.ts +0 -18
  191. package/pkg/commands/smove.ts +0 -9
  192. package/pkg/commands/spop.test.ts +0 -35
  193. package/pkg/commands/spop.ts +0 -13
  194. package/pkg/commands/srandmember.test.ts +0 -32
  195. package/pkg/commands/srandmember.ts +0 -13
  196. package/pkg/commands/srem.test.ts +0 -18
  197. package/pkg/commands/srem.ts +0 -10
  198. package/pkg/commands/sscan.test.ts +0 -50
  199. package/pkg/commands/sscan.ts +0 -22
  200. package/pkg/commands/strlen.test.ts +0 -16
  201. package/pkg/commands/strlen.ts +0 -10
  202. package/pkg/commands/sunion.test.ts +0 -22
  203. package/pkg/commands/sunion.ts +0 -10
  204. package/pkg/commands/sunionstore.test.ts +0 -29
  205. package/pkg/commands/sunionstore.ts +0 -10
  206. package/pkg/commands/time.test.ts +0 -11
  207. package/pkg/commands/time.ts +0 -9
  208. package/pkg/commands/touch.test.ts +0 -20
  209. package/pkg/commands/touch.ts +0 -10
  210. package/pkg/commands/ttl.test.ts +0 -17
  211. package/pkg/commands/ttl.ts +0 -10
  212. package/pkg/commands/type.test.ts +0 -72
  213. package/pkg/commands/type.ts +0 -11
  214. package/pkg/commands/unlink.test.ts +0 -21
  215. package/pkg/commands/unlink.ts +0 -10
  216. package/pkg/commands/zadd.test.ts +0 -177
  217. package/pkg/commands/zadd.ts +0 -64
  218. package/pkg/commands/zcard.test.ts +0 -15
  219. package/pkg/commands/zcard.ts +0 -10
  220. package/pkg/commands/zcount.test.ts +0 -15
  221. package/pkg/commands/zcount.ts +0 -9
  222. package/pkg/commands/zincrby.test.ts +0 -20
  223. package/pkg/commands/zincrby.ts +0 -9
  224. package/pkg/commands/zinterstore.test.ts +0 -239
  225. package/pkg/commands/zinterstore.ts +0 -55
  226. package/pkg/commands/zlexcount.test.ts +0 -22
  227. package/pkg/commands/zlexcount.ts +0 -9
  228. package/pkg/commands/zpopmax.test.ts +0 -45
  229. package/pkg/commands/zpopmax.ts +0 -13
  230. package/pkg/commands/zpopmin.test.ts +0 -49
  231. package/pkg/commands/zpopmin.ts +0 -13
  232. package/pkg/commands/zrange.test.ts +0 -52
  233. package/pkg/commands/zrange.ts +0 -22
  234. package/pkg/commands/zrank.test.ts +0 -22
  235. package/pkg/commands/zrank.ts +0 -10
  236. package/pkg/commands/zrem.test.ts +0 -20
  237. package/pkg/commands/zrem.ts +0 -10
  238. package/pkg/commands/zremrangebylex.test.ts +0 -26
  239. package/pkg/commands/zremrangebylex.ts +0 -9
  240. package/pkg/commands/zremrangebyrank.test.ts +0 -27
  241. package/pkg/commands/zremrangebyrank.ts +0 -9
  242. package/pkg/commands/zremrangebyscore.test.ts +0 -24
  243. package/pkg/commands/zremrangebyscore.ts +0 -9
  244. package/pkg/commands/zrevrank.test.ts +0 -22
  245. package/pkg/commands/zrevrank.ts +0 -10
  246. package/pkg/commands/zscan.test.ts +0 -50
  247. package/pkg/commands/zscan.ts +0 -22
  248. package/pkg/commands/zscore.test.ts +0 -18
  249. package/pkg/commands/zscore.ts +0 -10
  250. package/pkg/commands/zunionstore.test.ts +0 -215
  251. package/pkg/commands/zunionstore.ts +0 -55
  252. package/pkg/commands/zz.ts +0 -1
  253. package/pkg/error.ts +0 -9
  254. package/pkg/fastly.ts +0 -54
  255. package/pkg/http.test.ts +0 -34
  256. package/pkg/http.ts +0 -62
  257. package/pkg/index.ts +0 -2
  258. package/pkg/nodejs.ts +0 -83
  259. package/pkg/pipeline.test.ts +0 -177
  260. package/pkg/pipeline.ts +0 -999
  261. package/pkg/redis.ts +0 -930
  262. package/pkg/test-utils.ts +0 -41
  263. package/pkg/types.ts +0 -4
  264. package/pkg/util.ts +0 -22
  265. package/pnpm-lock.yaml +0 -3940
  266. package/tsconfig.json +0 -100
  267. package/tsconfig.module.json +0 -8
  268. package/tsup.config.ts +0 -16
@@ -52,13 +52,17 @@ var UpstashError = class extends Error {
52
52
 
53
53
  // pkg/util.ts
54
54
  function parseRecursive(obj) {
55
- return Array.isArray(obj) ? obj.map((o) => {
55
+ const parsed = Array.isArray(obj) ? obj.map((o) => {
56
56
  try {
57
57
  return parseRecursive(o);
58
58
  } catch {
59
59
  return o;
60
60
  }
61
61
  }) : JSON.parse(obj);
62
+ if (typeof parsed === "number" && parsed.toString() != obj) {
63
+ return obj;
64
+ }
65
+ return parsed;
62
66
  }
63
67
  function parseResponse(result) {
64
68
  try {
@@ -68,7 +72,7 @@ function parseResponse(result) {
68
72
  }
69
73
  }
70
74
 
71
- // pkg/command.ts
75
+ // pkg/commands/command.ts
72
76
  var Command = class {
73
77
  constructor(command, opts) {
74
78
  var _a;
@@ -348,8 +352,8 @@ var HScanCommand = class extends Command {
348
352
 
349
353
  // pkg/commands/hset.ts
350
354
  var HSetCommand = class extends Command {
351
- constructor(key, field, value) {
352
- super(["hset", key, field, value]);
355
+ constructor(key, kv) {
356
+ super(["hset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])]);
353
357
  }
354
358
  };
355
359
 
@@ -1110,8 +1114,8 @@ var Pipeline = class {
1110
1114
  hscan(...args) {
1111
1115
  return this.chain(new HScanCommand(...args));
1112
1116
  }
1113
- hset(key, field, value) {
1114
- return this.chain(new HSetCommand(key, field, value));
1117
+ hset(key, kv) {
1118
+ return this.chain(new HSetCommand(key, kv));
1115
1119
  }
1116
1120
  hsetnx(key, field, value) {
1117
1121
  return this.chain(new HSetNXCommand(key, field, value));
@@ -1441,8 +1445,8 @@ var Redis = class {
1441
1445
  hscan(...args) {
1442
1446
  return new HScanCommand(...args).exec(this.client);
1443
1447
  }
1444
- hset(key, field, value) {
1445
- return new HSetCommand(key, field, value).exec(this.client);
1448
+ hset(key, kv) {
1449
+ return new HSetCommand(key, kv).exec(this.client);
1446
1450
  }
1447
1451
  hsetnx(key, field, value) {
1448
1452
  return new HSetNXCommand(key, field, value).exec(this.client);
@@ -1681,7 +1685,6 @@ var Redis = class {
1681
1685
  };
1682
1686
 
1683
1687
  // pkg/http.ts
1684
- var import_isomorphic_fetch = require("isomorphic-fetch");
1685
1688
  var HttpClient = class {
1686
1689
  constructor(config) {
1687
1690
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
@@ -1710,7 +1713,7 @@ var HttpClient = class {
1710
1713
  };
1711
1714
 
1712
1715
  // pkg/nodejs.ts
1713
- var import_isomorphic_fetch2 = require("isomorphic-fetch");
1716
+ var import_isomorphic_fetch = require("isomorphic-fetch");
1714
1717
  var Redis2 = class extends Redis {
1715
1718
  constructor(config) {
1716
1719
  const client = new HttpClient({
package/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ import {
2
+ Redis
3
+ } from "./chunk-AHCVU33N.mjs";
4
+ import "./chunk-T66TTHSV.mjs";
5
+ import "./chunk-HGM7M7CJ.mjs";
6
+ import "./chunk-HIDCSH5S.mjs";
7
+ import {
8
+ UpstashError
9
+ } from "./chunk-7YUZYRJS.mjs";
10
+ export {
11
+ Redis,
12
+ UpstashError
13
+ };
@@ -1,5 +1,5 @@
1
- import { R as Redis$1 } from './redis-dd052782';
2
- import './zunionstore-dffa797d';
1
+ import { R as Redis$1 } from './redis-71fa1ee6';
2
+ import './zunionstore-b38007ba';
3
3
  import './http';
4
4
 
5
5
  /**
@@ -51,13 +51,17 @@ var UpstashError = class extends Error {
51
51
 
52
52
  // pkg/util.ts
53
53
  function parseRecursive(obj) {
54
- return Array.isArray(obj) ? obj.map((o) => {
54
+ const parsed = Array.isArray(obj) ? obj.map((o) => {
55
55
  try {
56
56
  return parseRecursive(o);
57
57
  } catch {
58
58
  return o;
59
59
  }
60
60
  }) : JSON.parse(obj);
61
+ if (typeof parsed === "number" && parsed.toString() != obj) {
62
+ return obj;
63
+ }
64
+ return parsed;
61
65
  }
62
66
  function parseResponse(result) {
63
67
  try {
@@ -67,7 +71,7 @@ function parseResponse(result) {
67
71
  }
68
72
  }
69
73
 
70
- // pkg/command.ts
74
+ // pkg/commands/command.ts
71
75
  var Command = class {
72
76
  constructor(command, opts) {
73
77
  var _a;
@@ -347,8 +351,8 @@ var HScanCommand = class extends Command {
347
351
 
348
352
  // pkg/commands/hset.ts
349
353
  var HSetCommand = class extends Command {
350
- constructor(key, field, value) {
351
- super(["hset", key, field, value]);
354
+ constructor(key, kv) {
355
+ super(["hset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])]);
352
356
  }
353
357
  };
354
358
 
@@ -1109,8 +1113,8 @@ var Pipeline = class {
1109
1113
  hscan(...args) {
1110
1114
  return this.chain(new HScanCommand(...args));
1111
1115
  }
1112
- hset(key, field, value) {
1113
- return this.chain(new HSetCommand(key, field, value));
1116
+ hset(key, kv) {
1117
+ return this.chain(new HSetCommand(key, kv));
1114
1118
  }
1115
1119
  hsetnx(key, field, value) {
1116
1120
  return this.chain(new HSetNXCommand(key, field, value));
@@ -1440,8 +1444,8 @@ var Redis = class {
1440
1444
  hscan(...args) {
1441
1445
  return new HScanCommand(...args).exec(this.client);
1442
1446
  }
1443
- hset(key, field, value) {
1444
- return new HSetCommand(key, field, value).exec(this.client);
1447
+ hset(key, kv) {
1448
+ return new HSetCommand(key, kv).exec(this.client);
1445
1449
  }
1446
1450
  hsetnx(key, field, value) {
1447
1451
  return new HSetNXCommand(key, field, value).exec(this.client);
@@ -1680,7 +1684,6 @@ var Redis = class {
1680
1684
  };
1681
1685
 
1682
1686
  // pkg/http.ts
1683
- var import_isomorphic_fetch = require("isomorphic-fetch");
1684
1687
  var HttpClient = class {
1685
1688
  constructor(config) {
1686
1689
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
@@ -1709,7 +1712,7 @@ var HttpClient = class {
1709
1712
  };
1710
1713
 
1711
1714
  // pkg/nodejs.ts
1712
- var import_isomorphic_fetch2 = require("isomorphic-fetch");
1715
+ var import_isomorphic_fetch = require("isomorphic-fetch");
1713
1716
  var Redis2 = class extends Redis {
1714
1717
  constructor(config) {
1715
1718
  const client = new HttpClient({
package/nodejs.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ Redis
3
+ } from "./chunk-AHCVU33N.mjs";
4
+ import "./chunk-T66TTHSV.mjs";
5
+ import "./chunk-HGM7M7CJ.mjs";
6
+ import "./chunk-HIDCSH5S.mjs";
7
+ import "./chunk-7YUZYRJS.mjs";
8
+ export {
9
+ Redis
10
+ };
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/redis", "version": "v1.0.0-alpha.2", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" } ] }
1
+ { "name": "@upstash/redis", "version": "v1.0.0-alpha.7", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" }, { "path": "dist/cloudflare.js", "limit": "5 KB" }, { "path": "dist/cloudflare.mjs", "limit": "5 KB" }, { "path": "dist/nodejs.js", "limit": "5 KB" }, { "path": "dist/nodejs.mjs", "limit": "5 KB" }, { "path": "dist/fastly.js", "limit": "5 KB" }, { "path": "dist/fastly.mjs", "limit": "5 KB" } ] }
@@ -1,4 +1,4 @@
1
- import { C as CommandArgs, A as AppendCommand, B as BitCountCommand, a as BitPosCommand, D as DecrCommand, b as DecrByCommand, c as DelCommand, E as EchoCommand, d as ExistsCommand, e as ExpireCommand, f as ExpireAtCommand, F as FlushAllCommand, g as FlushDBCommand, G as GetCommand, h as GetBitCommand, i as GetRangeCommand, H as HDelCommand, j as HExistsCommand, k as HGetCommand, l as HGetAllCommand, m as HIncrByCommand, n as HIncrByFloatCommand, o as HKeysCommand, p as HLenCommand, q as HMGetCommand, r as HScanCommand, s as HStrLenCommand, t as HValsCommand, I as IncrCommand, u as IncrByCommand, v as IncrByFloatCommand, K as KeysCommand, L as LIndexCommand, w as LLenCommand, x as LPopCommand, N as NonEmptyArray, y as LRangeCommand, z as LTrimCommand, M as MGetCommand, P as PersistCommand, J as PExpireCommand, O as PExpireAtCommand, Q as PingCommand, R as PTtlCommand, S as RenameCommand, T as RenameNXCommand, U as RPopCommand, V as ScanCommand, W as SCardCommand, X as SDiffCommand, Y as SDiffStoreCommand, Z as SetCommandOptions, _ as SetBitCommand, $ as SetRangeCommand, a0 as SInterCommand, a1 as SInterStoreCommand, a2 as SMembersCommand, a3 as SPopCommand, a4 as SRandMemberCommand, a5 as SScanCommand, a6 as StrLenCommand, a7 as SUnionCommand, a8 as SUnionStoreCommand, a9 as TouchCommand, aa as TtlCommand, ab as TypeCommand, ac as UnlinkCommand, ad as ScoreMember, ae as ZAddCommandOptions, af as ZAddCommandOptionsWithIncr, ag as ZCardCommand, ah as ZCountCommand, ai as ZInterStoreCommand, aj as ZLexCountCommand, ak as ZPopMaxCommand, al as ZPopMinCommand, am as ZRangeCommand, an as ZRemRangeByLexCommand, ao as ZRemRangeByRankCommand, ap as ZRemRangeByScoreCommand, aq as ZScanCommand, ar as ZUnionStoreCommand, as as Type } from './zunionstore-dffa797d';
1
+ import { C as CommandArgs, A as AppendCommand, B as BitCountCommand, a as BitPosCommand, D as DecrCommand, b as DecrByCommand, c as DelCommand, E as EchoCommand, d as ExistsCommand, e as ExpireCommand, f as ExpireAtCommand, F as FlushAllCommand, g as FlushDBCommand, G as GetCommand, h as GetBitCommand, i as GetRangeCommand, H as HDelCommand, j as HExistsCommand, k as HGetCommand, l as HGetAllCommand, m as HIncrByCommand, n as HIncrByFloatCommand, o as HKeysCommand, p as HLenCommand, q as HMGetCommand, r as HScanCommand, s as HStrLenCommand, t as HValsCommand, I as IncrCommand, u as IncrByCommand, v as IncrByFloatCommand, K as KeysCommand, L as LIndexCommand, w as LLenCommand, x as LPopCommand, N as NonEmptyArray, y as LRangeCommand, z as LTrimCommand, M as MGetCommand, P as PersistCommand, J as PExpireCommand, O as PExpireAtCommand, Q as PingCommand, R as PTtlCommand, S as RenameCommand, T as RenameNXCommand, U as RPopCommand, V as ScanCommand, W as SCardCommand, X as SDiffCommand, Y as SDiffStoreCommand, Z as SetCommandOptions, _ as SetBitCommand, $ as SetRangeCommand, a0 as SInterCommand, a1 as SInterStoreCommand, a2 as SMembersCommand, a3 as SPopCommand, a4 as SRandMemberCommand, a5 as SScanCommand, a6 as StrLenCommand, a7 as SUnionCommand, a8 as SUnionStoreCommand, a9 as TouchCommand, aa as TtlCommand, ab as TypeCommand, ac as UnlinkCommand, ad as ScoreMember, ae as ZAddCommandOptions, af as ZAddCommandOptionsWithIncr, ag as ZCardCommand, ah as ZCountCommand, ai as ZInterStoreCommand, aj as ZLexCountCommand, ak as ZPopMaxCommand, al as ZPopMinCommand, am as ZRangeCommand, an as ZRemRangeByLexCommand, ao as ZRemRangeByRankCommand, ap as ZRemRangeByScoreCommand, aq as ZScanCommand, ar as ZUnionStoreCommand, as as Type } from './zunionstore-b38007ba';
2
2
  import { HttpClient } from './http';
3
3
 
4
4
  /**
@@ -182,7 +182,9 @@ declare class Pipeline {
182
182
  /**
183
183
  * @see https://redis.io/commands/hset
184
184
  */
185
- hset<TData>(key: string, field: string, value: TData): this;
185
+ hset<TData>(key: string, kv: {
186
+ [field: string]: TData;
187
+ }): this;
186
188
  /**
187
189
  * @see https://redis.io/commands/hsetnx
188
190
  */
@@ -643,7 +645,9 @@ declare class Redis {
643
645
  /**
644
646
  * @see https://redis.io/commands/hset
645
647
  */
646
- hset<TData>(key: string, field: string, value: TData): Promise<number>;
648
+ hset<TData>(key: string, kv: {
649
+ [field: string]: TData;
650
+ }): Promise<number>;
647
651
  /**
648
652
  * @see https://redis.io/commands/hsetnx
649
653
  */
@@ -6,7 +6,7 @@ import { HttpClient } from './http';
6
6
  * TData represents what the user will enter or receive,
7
7
  * TResult is the raw data returned from upstash, which may need to be transformed or parsed.
8
8
  */
9
- declare abstract class Command<TData, TResult> {
9
+ declare class Command<TData, TResult> {
10
10
  readonly command: string[];
11
11
  deserialize: (result: TResult) => TData;
12
12
  /**
package/.eslintrc.js DELETED
@@ -1,49 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- },
5
- root: true,
6
- parser: "@typescript-eslint/parser",
7
- parserOptions: {
8
- project: "./tsconfig.json",
9
- },
10
- plugins: ["@typescript-eslint", "prettier"],
11
- extends: [
12
- /*
13
- * Always a good idea to start with sane defaults
14
- */
15
- "eslint:recommended",
16
-
17
- /*
18
- * Required to integrate prettier into eslint
19
- */
20
- "plugin:prettier/recommended",
21
- ],
22
- rules: {
23
- semi: "off",
24
-
25
- /*
26
- * This reads all definitions from a local prettier config file and applies the correct
27
- * eslint rules automatically.
28
- */
29
- "prettier/prettier": ["error"],
30
-
31
- /*
32
- * Named exports are almost always better because they break when the imported module changes
33
- */
34
- "import/prefer-default-export": "off",
35
-
36
- "no-unused-vars": "off",
37
- "@typescript-eslint/no-unused-vars": ["error"],
38
- "object-curly-newline": "off",
39
- "max-len": [
40
- 2,
41
- {
42
- code: 100,
43
- ignoreUrls: true,
44
- ignoreStrings: true,
45
- ignoreTemplateLiterals: true,
46
- },
47
- ],
48
- },
49
- }
package/.prettierrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- trailingComma: "all",
3
- tabWidth: 2,
4
- semi: false,
5
- singleQuote: false,
6
- printWidth: 100,
7
- }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2021 Upstash, Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/index.mjs DELETED
@@ -1,13 +0,0 @@
1
- import {
2
- Redis
3
- } from "./chunk-FJSI5EBJ.mjs";
4
- import "./chunk-Y5TC4HX2.mjs";
5
- import "./chunk-ZIB6XPPC.mjs";
6
- import "./chunk-U7OXAQMQ.mjs";
7
- import {
8
- UpstashError
9
- } from "./chunk-7YUZYRJS.mjs";
10
- export {
11
- Redis,
12
- UpstashError
13
- };
package/dist/nodejs.mjs DELETED
@@ -1,10 +0,0 @@
1
- import {
2
- Redis
3
- } from "./chunk-FJSI5EBJ.mjs";
4
- import "./chunk-Y5TC4HX2.mjs";
5
- import "./chunk-ZIB6XPPC.mjs";
6
- import "./chunk-U7OXAQMQ.mjs";
7
- import "./chunk-7YUZYRJS.mjs";
8
- export {
9
- Redis
10
- };
package/dist/package.json DELETED
@@ -1 +0,0 @@
1
- { "name": "@upstash/redis", "version": "v1.0.0-alpha.2", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" } ] }
package/jest.config.js DELETED
@@ -1,195 +0,0 @@
1
- /*
2
- * For a detailed explanation regarding each configuration property and type check, visit:
3
- * https://jestjs.io/docs/configuration
4
- */
5
-
6
- module.exports = {
7
- // All imported modules in your tests should be mocked automatically
8
- // automock: false,
9
-
10
- // Stop running tests after `n` failures
11
- bail: true,
12
-
13
- // The directory where Jest should store its cached dependency information
14
- // cacheDirectory: "/tmp/jest_rs",
15
-
16
- // Automatically clear mock calls, instances and results before every test
17
- // clearMocks: false,
18
-
19
- // Indicates whether the coverage information should be collected while executing the test
20
- collectCoverage: true,
21
-
22
- // An array of glob patterns indicating a set of files for which coverage information should be collected
23
- // collectCoverageFrom: undefined,
24
-
25
- // The directory where Jest should output its coverage files
26
- coverageDirectory: "coverage",
27
-
28
- // An array of regexp pattern strings used to skip coverage collection
29
- coveragePathIgnorePatterns: ["/node_modules/", "/dist/", "pkg/test-utils.ts"],
30
-
31
- // Indicates which provider should be used to instrument code for coverage
32
- coverageProvider: "v8",
33
-
34
- // A list of reporter names that Jest uses when writing coverage reports
35
- // coverageReporters: [
36
- // "json",
37
- // "text",
38
- // "lcov",
39
- // "clover"
40
- // ],
41
-
42
- // An object that configures minimum threshold enforcement for coverage results
43
- // coverageThreshold: undefined,
44
-
45
- // A path to a custom dependency extractor
46
- // dependencyExtractor: undefined,
47
-
48
- // Make calling deprecated APIs throw helpful error messages
49
- errorOnDeprecated: false,
50
-
51
- // Force coverage collection from ignored files using an array of glob patterns
52
- // forceCoverageMatch: [],
53
-
54
- // A path to a module which exports an async function that is triggered once before all test suites
55
- // globalSetup: undefined,
56
-
57
- // A path to a module which exports an async function that is triggered once after all test suites
58
- // globalTeardown: "./pkg/test_teardown.ts",
59
-
60
- // A set of global variables that need to be available in all test environments
61
- // globals: {},
62
-
63
- // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
64
- // maxWorkers: "50%",
65
-
66
- // An array of directory names to be searched recursively up from the requiring module's location
67
- // moduleDirectories: [
68
- // "node_modules"
69
- // ],
70
-
71
- // An array of file extensions your modules use
72
- // moduleFileExtensions: [
73
- // "js",
74
- // "jsx",
75
- // "ts",
76
- // "tsx",
77
- // "json",
78
- // "node"
79
- // ],
80
-
81
- // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
82
- // moduleNameMapper: {},
83
-
84
- // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
85
- modulePathIgnorePatterns: ["dist/"],
86
-
87
- // Activates notifications for test results
88
- notify: false,
89
-
90
- // An enum that specifies notification mode. Requires { notify: true }
91
- // notifyMode: "failure-change",
92
-
93
- // A preset that is used as a base for Jest's configuration
94
- // preset: undefined,
95
-
96
- // Run tests from one or more projects
97
- // projects: undefined,
98
-
99
- // Use this configuration option to add custom reporters to Jest
100
- // reporters: undefined,
101
-
102
- // Automatically reset mock state before every test
103
- // resetMocks: false,
104
-
105
- // Reset the module registry before running each individual test
106
- // resetModules: false,
107
-
108
- // A path to a custom resolver
109
- // resolver: undefined,
110
-
111
- // Automatically restore mock state and implementation before every test
112
- // restoreMocks: false,
113
-
114
- // The root directory that Jest should scan for tests and modules within
115
- // rootDir: undefined,
116
-
117
- // A list of paths to directories that Jest should use to search for files in
118
- // roots: [
119
- // "<rootDir>"
120
- // ],
121
-
122
- // Allows you to use a custom runner instead of Jest's default test runner
123
- // runner: "jest-runner",
124
-
125
- // The paths to modules that run some code to configure or set up the testing environment before each test
126
- // setupFiles: [],
127
-
128
- // A list of paths to modules that run some code to configure or set up the testing framework before each test
129
- // setupFilesAfterEnv: [],
130
-
131
- // The number of seconds after which a test is considered as slow and reported as such in the results.
132
- // slowTestThreshold: 5,
133
-
134
- // A list of paths to snapshot serializer modules Jest should use for snapshot testing
135
- // snapshotSerializers: [],
136
-
137
- // The test environment that will be used for testing
138
- // testEnvironment: "jest-environment-node",
139
-
140
- // Options that will be passed to the testEnvironment
141
- // testEnvironmentOptions: {},
142
-
143
- // Adds a location field to test results
144
- // testLocationInResults: false,
145
-
146
- // The glob patterns Jest uses to detect test files
147
- // testMatch: [
148
- // "**/__tests__/**/*.[jt]s?(x)",
149
- // "**/?(*.)+(spec|test).[tj]s?(x)"
150
- // ],
151
-
152
- // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
153
- testPathIgnorePatterns: ["/node_modules/", "<rootDir>/pkg/test-utils.ts"],
154
-
155
- // The regexp pattern or array of patterns that Jest uses to detect test files
156
- // testRegex: [],
157
-
158
- // This option allows the use of a custom results processor
159
- // testResultsProcessor: undefined,
160
-
161
- // This option allows use of a custom test runner
162
- // testRunner: "jest-circus/runner",
163
-
164
- // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
165
- // testURL: "http://localhost",
166
-
167
- // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
168
- // timers: "real",
169
-
170
- // A map from regular expressions to paths to transformers
171
- transform: {
172
- "^.+\\.ts$": "ts-jest",
173
- },
174
-
175
- // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
176
- // transformIgnorePatterns: [
177
- // "/node_modules/",
178
- // "\\.pnp\\.[^\\/]+$"
179
- // ],
180
-
181
- // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
182
- // unmockedModulePathPatterns: undefined,
183
-
184
- // Indicates whether each individual test should be reported during the run
185
- verbose: true,
186
-
187
- // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
188
- // watchPathIgnorePatterns: [],
189
-
190
- // Whether to use watchman for file crawling
191
- // watchman: true,
192
-
193
- injectGlobals: false,
194
- testTimeout: 60_000,
195
- }
package/pkg/cloudflare.ts DELETED
@@ -1,77 +0,0 @@
1
- import * as core from "./redis"
2
- import { HttpClient } from "./http"
3
-
4
- /**
5
- * Connection credentials for upstash redis.
6
- * Get them from https://console.upstash.com/redis/<uuid>
7
- */
8
- export type RedisConfigCloudflare = {
9
- /**
10
- * UPSTASH_REDIS_REST_URL
11
- */
12
- url: string
13
-
14
- /**
15
- * UPSTASH_REDIS_REST_TOKEN
16
- */
17
- token: string
18
- }
19
-
20
- /**
21
- * Serverless redis client for upstash.
22
- */
23
- export class Redis extends core.Redis {
24
- /**
25
- * Create a new redis client
26
- *
27
- * @example
28
- * ```typescript
29
- * const redis = new Redis({
30
- * url: "<UPSTASH_REDIS_REST_URL>",
31
- * token: "<UPSTASH_REDIS_REST_TOKEN>",
32
- * });
33
- * ```
34
- */
35
- constructor(config: RedisConfigCloudflare) {
36
- const client = new HttpClient({
37
- baseUrl: config.url,
38
- headers: {
39
- authorization: `Bearer ${config.token}`,
40
- },
41
- })
42
-
43
- super(client)
44
- }
45
-
46
- /*
47
- * Create a new Upstash Redis instance from environment variables on cloudflare.
48
- *
49
- * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
50
- * the global namespace
51
- */
52
- static fromEnv(): Redis {
53
- /**
54
- * These should be injected by cloudflare.
55
- */
56
-
57
- // @ts-ignore
58
- // eslint-disable-next-line no-undef
59
- const url = UPSTASH_REDIS_REST_URL
60
-
61
- // @ts-ignore
62
- // eslint-disable-next-line no-undef
63
- const token = UPSTASH_REDIS_REST_TOKEN
64
-
65
- if (!url) {
66
- throw new Error(
67
- "Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`",
68
- )
69
- }
70
- if (!token) {
71
- throw new Error(
72
- "Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`",
73
- )
74
- }
75
- return new Redis({ url, token })
76
- }
77
- }
package/pkg/command.ts DELETED
@@ -1,40 +0,0 @@
1
- import { UpstashError } from "./error"
2
- import { HttpClient, UpstashResponse } from "./http"
3
- import { parseResponse } from "./util"
4
-
5
- /**
6
- * Command offers default (de)serialization and the exec method to all commands.
7
- *
8
- * TData represents what the user will enter or receive,
9
- * TResult is the raw data returned from upstash, which may need to be transformed or parsed.
10
- */
11
- export abstract class Command<TData, TResult> {
12
- public readonly command: string[]
13
- public deserialize: (result: TResult) => TData
14
- /**
15
- * Create a new command instance.
16
- *
17
- * You can define a custom `deserialize` function. By default we try to deserialize as json.
18
- */
19
- constructor(command: (string | unknown)[], opts?: { deserialize?: (result: TResult) => TData }) {
20
- this.command = command.map((c) => (typeof c === "string" ? c : JSON.stringify(c)))
21
- this.deserialize = opts?.deserialize ?? parseResponse
22
- }
23
-
24
- /**
25
- * Execute the command using a client.
26
- */
27
- public async exec(client: HttpClient): Promise<TData> {
28
- const { result, error } = await client.request<UpstashResponse<TResult>>({
29
- body: this.command,
30
- })
31
- if (error) {
32
- throw new UpstashError(error)
33
- }
34
- if (typeof result === "undefined") {
35
- throw new Error(`Request did not return a result`)
36
- }
37
-
38
- return this.deserialize(result)
39
- }
40
- }