@upstash/redis 0.0.0-ci.fb6b986f-20221006 → 0.0.0-ci.fc1b22d0-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 (421) hide show
  1. package/.npmrc +1 -0
  2. package/README.md +21 -19
  3. package/cloudflare.d.mts +45 -0
  4. package/{types/platforms/cloudflare.d.ts → cloudflare.d.ts} +14 -11
  5. package/cloudflare.js +3062 -0
  6. package/cloudflare.js.map +1 -0
  7. package/cloudflare.mjs +3025 -0
  8. package/cloudflare.mjs.map +1 -0
  9. package/fastly.d.mts +43 -0
  10. package/{types/platforms/fastly.d.ts → fastly.d.ts} +8 -10
  11. package/fastly.js +3037 -0
  12. package/fastly.js.map +1 -0
  13. package/fastly.mjs +3000 -0
  14. package/fastly.mjs.map +1 -0
  15. package/{types/platforms/node_with_fetch.d.ts → nodejs.d.mts} +9 -11
  16. package/{types/platforms/nodejs.d.ts → nodejs.d.ts} +9 -10
  17. package/nodejs.js +3063 -0
  18. package/nodejs.js.map +1 -0
  19. package/nodejs.mjs +3026 -0
  20. package/nodejs.mjs.map +1 -0
  21. package/package.json +29 -38
  22. package/redis-e3e8473f.d.ts +1795 -0
  23. package/.releaserc +0 -14
  24. package/LICENSE +0 -21
  25. package/esm/deps/deno.land/x/base64@v0.2.1/base.js +0 -100
  26. package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +0 -9
  27. package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +0 -1
  28. package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +0 -191
  29. package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +0 -50
  30. package/esm/package.json +0 -3
  31. package/esm/pkg/commands/append.js +0 -9
  32. package/esm/pkg/commands/bitcount.js +0 -16
  33. package/esm/pkg/commands/bitop.js +0 -9
  34. package/esm/pkg/commands/bitpos.js +0 -9
  35. package/esm/pkg/commands/command.js +0 -57
  36. package/esm/pkg/commands/dbsize.js +0 -9
  37. package/esm/pkg/commands/decr.js +0 -9
  38. package/esm/pkg/commands/decrby.js +0 -9
  39. package/esm/pkg/commands/del.js +0 -9
  40. package/esm/pkg/commands/echo.js +0 -9
  41. package/esm/pkg/commands/eval.js +0 -9
  42. package/esm/pkg/commands/evalsha.js +0 -9
  43. package/esm/pkg/commands/exists.js +0 -9
  44. package/esm/pkg/commands/expire.js +0 -9
  45. package/esm/pkg/commands/expireat.js +0 -9
  46. package/esm/pkg/commands/flushall.js +0 -13
  47. package/esm/pkg/commands/flushdb.js +0 -13
  48. package/esm/pkg/commands/get.js +0 -9
  49. package/esm/pkg/commands/getbit.js +0 -9
  50. package/esm/pkg/commands/getrange.js +0 -9
  51. package/esm/pkg/commands/getset.js +0 -9
  52. package/esm/pkg/commands/hdel.js +0 -9
  53. package/esm/pkg/commands/hexists.js +0 -9
  54. package/esm/pkg/commands/hget.js +0 -9
  55. package/esm/pkg/commands/hgetall.js +0 -33
  56. package/esm/pkg/commands/hincrby.js +0 -9
  57. package/esm/pkg/commands/hincrbyfloat.js +0 -9
  58. package/esm/pkg/commands/hkeys.js +0 -9
  59. package/esm/pkg/commands/hlen.js +0 -9
  60. package/esm/pkg/commands/hmget.js +0 -35
  61. package/esm/pkg/commands/hmset.js +0 -13
  62. package/esm/pkg/commands/hscan.js +0 -16
  63. package/esm/pkg/commands/hset.js +0 -13
  64. package/esm/pkg/commands/hsetnx.js +0 -9
  65. package/esm/pkg/commands/hstrlen.js +0 -9
  66. package/esm/pkg/commands/hvals.js +0 -9
  67. package/esm/pkg/commands/incr.js +0 -9
  68. package/esm/pkg/commands/incrby.js +0 -9
  69. package/esm/pkg/commands/incrbyfloat.js +0 -9
  70. package/esm/pkg/commands/keys.js +0 -9
  71. package/esm/pkg/commands/lindex.js +0 -6
  72. package/esm/pkg/commands/linsert.js +0 -6
  73. package/esm/pkg/commands/llen.js +0 -9
  74. package/esm/pkg/commands/lpop.js +0 -9
  75. package/esm/pkg/commands/lpos.js +0 -19
  76. package/esm/pkg/commands/lpush.js +0 -9
  77. package/esm/pkg/commands/lpushx.js +0 -9
  78. package/esm/pkg/commands/lrange.js +0 -6
  79. package/esm/pkg/commands/lrem.js +0 -6
  80. package/esm/pkg/commands/lset.js +0 -6
  81. package/esm/pkg/commands/ltrim.js +0 -6
  82. package/esm/pkg/commands/mget.js +0 -9
  83. package/esm/pkg/commands/mod.js +0 -115
  84. package/esm/pkg/commands/mset.js +0 -12
  85. package/esm/pkg/commands/msetnx.js +0 -9
  86. package/esm/pkg/commands/persist.js +0 -9
  87. package/esm/pkg/commands/pexpire.js +0 -9
  88. package/esm/pkg/commands/pexpireat.js +0 -9
  89. package/esm/pkg/commands/ping.js +0 -13
  90. package/esm/pkg/commands/psetex.js +0 -9
  91. package/esm/pkg/commands/pttl.js +0 -9
  92. package/esm/pkg/commands/publish.js +0 -9
  93. package/esm/pkg/commands/randomkey.js +0 -9
  94. package/esm/pkg/commands/rename.js +0 -9
  95. package/esm/pkg/commands/renamenx.js +0 -9
  96. package/esm/pkg/commands/rpop.js +0 -9
  97. package/esm/pkg/commands/rpush.js +0 -9
  98. package/esm/pkg/commands/rpushx.js +0 -9
  99. package/esm/pkg/commands/sadd.js +0 -9
  100. package/esm/pkg/commands/scan.js +0 -19
  101. package/esm/pkg/commands/scard.js +0 -9
  102. package/esm/pkg/commands/script_exists.js +0 -12
  103. package/esm/pkg/commands/script_flush.js +0 -16
  104. package/esm/pkg/commands/script_load.js +0 -9
  105. package/esm/pkg/commands/sdiff.js +0 -9
  106. package/esm/pkg/commands/sdiffstore.js +0 -9
  107. package/esm/pkg/commands/set.js +0 -36
  108. package/esm/pkg/commands/setbit.js +0 -9
  109. package/esm/pkg/commands/setex.js +0 -9
  110. package/esm/pkg/commands/setnx.js +0 -9
  111. package/esm/pkg/commands/setrange.js +0 -9
  112. package/esm/pkg/commands/sinter.js +0 -9
  113. package/esm/pkg/commands/sinterstore.js +0 -9
  114. package/esm/pkg/commands/sismember.js +0 -9
  115. package/esm/pkg/commands/smembers.js +0 -9
  116. package/esm/pkg/commands/smove.js +0 -9
  117. package/esm/pkg/commands/spop.js +0 -13
  118. package/esm/pkg/commands/srandmember.js +0 -13
  119. package/esm/pkg/commands/srem.js +0 -9
  120. package/esm/pkg/commands/sscan.js +0 -16
  121. package/esm/pkg/commands/strlen.js +0 -9
  122. package/esm/pkg/commands/sunion.js +0 -9
  123. package/esm/pkg/commands/sunionstore.js +0 -9
  124. package/esm/pkg/commands/time.js +0 -9
  125. package/esm/pkg/commands/touch.js +0 -9
  126. package/esm/pkg/commands/ttl.js +0 -9
  127. package/esm/pkg/commands/type.js +0 -9
  128. package/esm/pkg/commands/unlink.js +0 -9
  129. package/esm/pkg/commands/zadd.js +0 -26
  130. package/esm/pkg/commands/zcard.js +0 -9
  131. package/esm/pkg/commands/zcount.js +0 -9
  132. package/esm/pkg/commands/zincrby.js +0 -9
  133. package/esm/pkg/commands/zinterstore.js +0 -27
  134. package/esm/pkg/commands/zlexcount.js +0 -9
  135. package/esm/pkg/commands/zmscore.js +0 -10
  136. package/esm/pkg/commands/zpopmax.js +0 -13
  137. package/esm/pkg/commands/zpopmin.js +0 -13
  138. package/esm/pkg/commands/zrange.js +0 -26
  139. package/esm/pkg/commands/zrank.js +0 -9
  140. package/esm/pkg/commands/zrem.js +0 -9
  141. package/esm/pkg/commands/zremrangebylex.js +0 -9
  142. package/esm/pkg/commands/zremrangebyrank.js +0 -9
  143. package/esm/pkg/commands/zremrangebyscore.js +0 -9
  144. package/esm/pkg/commands/zrevrank.js +0 -9
  145. package/esm/pkg/commands/zscan.js +0 -16
  146. package/esm/pkg/commands/zscore.js +0 -9
  147. package/esm/pkg/commands/zunionstore.js +0 -27
  148. package/esm/pkg/error.js +0 -9
  149. package/esm/pkg/http.js +0 -128
  150. package/esm/pkg/pipeline.js +0 -1144
  151. package/esm/pkg/redis.js +0 -1102
  152. package/esm/pkg/script.js +0 -77
  153. package/esm/pkg/types.js +0 -1
  154. package/esm/pkg/util.js +0 -31
  155. package/esm/platforms/cloudflare.js +0 -62
  156. package/esm/platforms/fastly.js +0 -40
  157. package/esm/platforms/node_with_fetch.js +0 -60
  158. package/esm/platforms/nodejs.js +0 -59
  159. package/script/deps/deno.land/x/base64@v0.2.1/base.js +0 -104
  160. package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +0 -13
  161. package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +0 -6
  162. package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +0 -196
  163. package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +0 -55
  164. package/script/package.json +0 -3
  165. package/script/pkg/commands/append.js +0 -13
  166. package/script/pkg/commands/bitcount.js +0 -20
  167. package/script/pkg/commands/bitop.js +0 -13
  168. package/script/pkg/commands/bitpos.js +0 -13
  169. package/script/pkg/commands/command.js +0 -61
  170. package/script/pkg/commands/dbsize.js +0 -13
  171. package/script/pkg/commands/decr.js +0 -13
  172. package/script/pkg/commands/decrby.js +0 -13
  173. package/script/pkg/commands/del.js +0 -13
  174. package/script/pkg/commands/echo.js +0 -13
  175. package/script/pkg/commands/eval.js +0 -13
  176. package/script/pkg/commands/evalsha.js +0 -13
  177. package/script/pkg/commands/exists.js +0 -13
  178. package/script/pkg/commands/expire.js +0 -13
  179. package/script/pkg/commands/expireat.js +0 -13
  180. package/script/pkg/commands/flushall.js +0 -17
  181. package/script/pkg/commands/flushdb.js +0 -17
  182. package/script/pkg/commands/get.js +0 -13
  183. package/script/pkg/commands/getbit.js +0 -13
  184. package/script/pkg/commands/getrange.js +0 -13
  185. package/script/pkg/commands/getset.js +0 -13
  186. package/script/pkg/commands/hdel.js +0 -13
  187. package/script/pkg/commands/hexists.js +0 -13
  188. package/script/pkg/commands/hget.js +0 -13
  189. package/script/pkg/commands/hgetall.js +0 -37
  190. package/script/pkg/commands/hincrby.js +0 -13
  191. package/script/pkg/commands/hincrbyfloat.js +0 -13
  192. package/script/pkg/commands/hkeys.js +0 -13
  193. package/script/pkg/commands/hlen.js +0 -13
  194. package/script/pkg/commands/hmget.js +0 -39
  195. package/script/pkg/commands/hmset.js +0 -17
  196. package/script/pkg/commands/hscan.js +0 -20
  197. package/script/pkg/commands/hset.js +0 -17
  198. package/script/pkg/commands/hsetnx.js +0 -13
  199. package/script/pkg/commands/hstrlen.js +0 -13
  200. package/script/pkg/commands/hvals.js +0 -13
  201. package/script/pkg/commands/incr.js +0 -13
  202. package/script/pkg/commands/incrby.js +0 -13
  203. package/script/pkg/commands/incrbyfloat.js +0 -13
  204. package/script/pkg/commands/keys.js +0 -13
  205. package/script/pkg/commands/lindex.js +0 -10
  206. package/script/pkg/commands/linsert.js +0 -10
  207. package/script/pkg/commands/llen.js +0 -13
  208. package/script/pkg/commands/lpop.js +0 -13
  209. package/script/pkg/commands/lpos.js +0 -23
  210. package/script/pkg/commands/lpush.js +0 -13
  211. package/script/pkg/commands/lpushx.js +0 -13
  212. package/script/pkg/commands/lrange.js +0 -10
  213. package/script/pkg/commands/lrem.js +0 -10
  214. package/script/pkg/commands/lset.js +0 -10
  215. package/script/pkg/commands/ltrim.js +0 -10
  216. package/script/pkg/commands/mget.js +0 -13
  217. package/script/pkg/commands/mod.js +0 -131
  218. package/script/pkg/commands/mset.js +0 -16
  219. package/script/pkg/commands/msetnx.js +0 -13
  220. package/script/pkg/commands/persist.js +0 -13
  221. package/script/pkg/commands/pexpire.js +0 -13
  222. package/script/pkg/commands/pexpireat.js +0 -13
  223. package/script/pkg/commands/ping.js +0 -17
  224. package/script/pkg/commands/psetex.js +0 -13
  225. package/script/pkg/commands/pttl.js +0 -13
  226. package/script/pkg/commands/publish.js +0 -13
  227. package/script/pkg/commands/randomkey.js +0 -13
  228. package/script/pkg/commands/rename.js +0 -13
  229. package/script/pkg/commands/renamenx.js +0 -13
  230. package/script/pkg/commands/rpop.js +0 -13
  231. package/script/pkg/commands/rpush.js +0 -13
  232. package/script/pkg/commands/rpushx.js +0 -13
  233. package/script/pkg/commands/sadd.js +0 -13
  234. package/script/pkg/commands/scan.js +0 -23
  235. package/script/pkg/commands/scard.js +0 -13
  236. package/script/pkg/commands/script_exists.js +0 -16
  237. package/script/pkg/commands/script_flush.js +0 -20
  238. package/script/pkg/commands/script_load.js +0 -13
  239. package/script/pkg/commands/sdiff.js +0 -13
  240. package/script/pkg/commands/sdiffstore.js +0 -13
  241. package/script/pkg/commands/set.js +0 -40
  242. package/script/pkg/commands/setbit.js +0 -13
  243. package/script/pkg/commands/setex.js +0 -13
  244. package/script/pkg/commands/setnx.js +0 -13
  245. package/script/pkg/commands/setrange.js +0 -13
  246. package/script/pkg/commands/sinter.js +0 -13
  247. package/script/pkg/commands/sinterstore.js +0 -13
  248. package/script/pkg/commands/sismember.js +0 -13
  249. package/script/pkg/commands/smembers.js +0 -13
  250. package/script/pkg/commands/smove.js +0 -13
  251. package/script/pkg/commands/spop.js +0 -17
  252. package/script/pkg/commands/srandmember.js +0 -17
  253. package/script/pkg/commands/srem.js +0 -13
  254. package/script/pkg/commands/sscan.js +0 -20
  255. package/script/pkg/commands/strlen.js +0 -13
  256. package/script/pkg/commands/sunion.js +0 -13
  257. package/script/pkg/commands/sunionstore.js +0 -13
  258. package/script/pkg/commands/time.js +0 -13
  259. package/script/pkg/commands/touch.js +0 -13
  260. package/script/pkg/commands/ttl.js +0 -13
  261. package/script/pkg/commands/type.js +0 -13
  262. package/script/pkg/commands/unlink.js +0 -13
  263. package/script/pkg/commands/zadd.js +0 -30
  264. package/script/pkg/commands/zcard.js +0 -13
  265. package/script/pkg/commands/zcount.js +0 -13
  266. package/script/pkg/commands/zincrby.js +0 -13
  267. package/script/pkg/commands/zinterstore.js +0 -31
  268. package/script/pkg/commands/zlexcount.js +0 -13
  269. package/script/pkg/commands/zmscore.js +0 -14
  270. package/script/pkg/commands/zpopmax.js +0 -17
  271. package/script/pkg/commands/zpopmin.js +0 -17
  272. package/script/pkg/commands/zrange.js +0 -30
  273. package/script/pkg/commands/zrank.js +0 -13
  274. package/script/pkg/commands/zrem.js +0 -13
  275. package/script/pkg/commands/zremrangebylex.js +0 -13
  276. package/script/pkg/commands/zremrangebyrank.js +0 -13
  277. package/script/pkg/commands/zremrangebyscore.js +0 -13
  278. package/script/pkg/commands/zrevrank.js +0 -13
  279. package/script/pkg/commands/zscan.js +0 -20
  280. package/script/pkg/commands/zscore.js +0 -13
  281. package/script/pkg/commands/zunionstore.js +0 -31
  282. package/script/pkg/error.js +0 -13
  283. package/script/pkg/http.js +0 -132
  284. package/script/pkg/pipeline.js +0 -1148
  285. package/script/pkg/redis.js +0 -1106
  286. package/script/pkg/script.js +0 -81
  287. package/script/pkg/types.js +0 -2
  288. package/script/pkg/util.js +0 -35
  289. package/script/platforms/cloudflare.js +0 -89
  290. package/script/platforms/fastly.js +0 -67
  291. package/script/platforms/node_with_fetch.js +0 -87
  292. package/script/platforms/nodejs.js +0 -86
  293. package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +0 -5
  294. package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +0 -1
  295. package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +0 -1
  296. package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +0 -26
  297. package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +0 -3
  298. package/types/pkg/commands/append.d.ts +0 -7
  299. package/types/pkg/commands/bitcount.d.ts +0 -8
  300. package/types/pkg/commands/bitop.d.ts +0 -12
  301. package/types/pkg/commands/bitpos.d.ts +0 -7
  302. package/types/pkg/commands/command.d.ts +0 -37
  303. package/types/pkg/commands/dbsize.d.ts +0 -7
  304. package/types/pkg/commands/decr.d.ts +0 -7
  305. package/types/pkg/commands/decrby.d.ts +0 -7
  306. package/types/pkg/commands/del.d.ts +0 -7
  307. package/types/pkg/commands/echo.d.ts +0 -7
  308. package/types/pkg/commands/eval.d.ts +0 -7
  309. package/types/pkg/commands/evalsha.d.ts +0 -7
  310. package/types/pkg/commands/exists.d.ts +0 -7
  311. package/types/pkg/commands/expire.d.ts +0 -7
  312. package/types/pkg/commands/expireat.d.ts +0 -7
  313. package/types/pkg/commands/flushall.d.ts +0 -9
  314. package/types/pkg/commands/flushdb.d.ts +0 -9
  315. package/types/pkg/commands/get.d.ts +0 -7
  316. package/types/pkg/commands/getbit.d.ts +0 -7
  317. package/types/pkg/commands/getrange.d.ts +0 -7
  318. package/types/pkg/commands/getset.d.ts +0 -7
  319. package/types/pkg/commands/hdel.d.ts +0 -7
  320. package/types/pkg/commands/hexists.d.ts +0 -7
  321. package/types/pkg/commands/hget.d.ts +0 -7
  322. package/types/pkg/commands/hgetall.d.ts +0 -7
  323. package/types/pkg/commands/hincrby.d.ts +0 -7
  324. package/types/pkg/commands/hincrbyfloat.d.ts +0 -7
  325. package/types/pkg/commands/hkeys.d.ts +0 -7
  326. package/types/pkg/commands/hlen.d.ts +0 -7
  327. package/types/pkg/commands/hmget.d.ts +0 -15
  328. package/types/pkg/commands/hmset.d.ts +0 -9
  329. package/types/pkg/commands/hscan.d.ts +0 -24
  330. package/types/pkg/commands/hset.d.ts +0 -9
  331. package/types/pkg/commands/hsetnx.d.ts +0 -7
  332. package/types/pkg/commands/hstrlen.d.ts +0 -7
  333. package/types/pkg/commands/hvals.d.ts +0 -7
  334. package/types/pkg/commands/incr.d.ts +0 -7
  335. package/types/pkg/commands/incrby.d.ts +0 -7
  336. package/types/pkg/commands/incrbyfloat.d.ts +0 -7
  337. package/types/pkg/commands/keys.d.ts +0 -7
  338. package/types/pkg/commands/lindex.d.ts +0 -4
  339. package/types/pkg/commands/linsert.d.ts +0 -9
  340. package/types/pkg/commands/llen.d.ts +0 -7
  341. package/types/pkg/commands/lpop.d.ts +0 -7
  342. package/types/pkg/commands/lpos.d.ts +0 -15
  343. package/types/pkg/commands/lpush.d.ts +0 -7
  344. package/types/pkg/commands/lpushx.d.ts +0 -7
  345. package/types/pkg/commands/lrange.d.ts +0 -4
  346. package/types/pkg/commands/lrem.d.ts +0 -4
  347. package/types/pkg/commands/lset.d.ts +0 -4
  348. package/types/pkg/commands/ltrim.d.ts +0 -4
  349. package/types/pkg/commands/mget.d.ts +0 -7
  350. package/types/pkg/commands/mod.d.ts +0 -115
  351. package/types/pkg/commands/mset.d.ts +0 -9
  352. package/types/pkg/commands/msetnx.d.ts +0 -9
  353. package/types/pkg/commands/persist.d.ts +0 -7
  354. package/types/pkg/commands/pexpire.d.ts +0 -7
  355. package/types/pkg/commands/pexpireat.d.ts +0 -7
  356. package/types/pkg/commands/ping.d.ts +0 -7
  357. package/types/pkg/commands/psetex.d.ts +0 -7
  358. package/types/pkg/commands/pttl.d.ts +0 -7
  359. package/types/pkg/commands/publish.d.ts +0 -7
  360. package/types/pkg/commands/randomkey.d.ts +0 -7
  361. package/types/pkg/commands/rename.d.ts +0 -7
  362. package/types/pkg/commands/renamenx.d.ts +0 -7
  363. package/types/pkg/commands/rpop.d.ts +0 -7
  364. package/types/pkg/commands/rpush.d.ts +0 -7
  365. package/types/pkg/commands/rpushx.d.ts +0 -7
  366. package/types/pkg/commands/sadd.d.ts +0 -7
  367. package/types/pkg/commands/scan.d.ts +0 -18
  368. package/types/pkg/commands/scard.d.ts +0 -7
  369. package/types/pkg/commands/script_exists.d.ts +0 -7
  370. package/types/pkg/commands/script_flush.d.ts +0 -14
  371. package/types/pkg/commands/script_load.d.ts +0 -7
  372. package/types/pkg/commands/sdiff.d.ts +0 -7
  373. package/types/pkg/commands/sdiffstore.d.ts +0 -7
  374. package/types/pkg/commands/set.d.ts +0 -55
  375. package/types/pkg/commands/setbit.d.ts +0 -7
  376. package/types/pkg/commands/setex.d.ts +0 -7
  377. package/types/pkg/commands/setnx.d.ts +0 -7
  378. package/types/pkg/commands/setrange.d.ts +0 -7
  379. package/types/pkg/commands/sinter.d.ts +0 -7
  380. package/types/pkg/commands/sinterstore.d.ts +0 -7
  381. package/types/pkg/commands/sismember.d.ts +0 -7
  382. package/types/pkg/commands/smembers.d.ts +0 -7
  383. package/types/pkg/commands/smove.d.ts +0 -7
  384. package/types/pkg/commands/spop.d.ts +0 -7
  385. package/types/pkg/commands/srandmember.d.ts +0 -7
  386. package/types/pkg/commands/srem.d.ts +0 -7
  387. package/types/pkg/commands/sscan.d.ts +0 -24
  388. package/types/pkg/commands/strlen.d.ts +0 -7
  389. package/types/pkg/commands/sunion.d.ts +0 -7
  390. package/types/pkg/commands/sunionstore.d.ts +0 -7
  391. package/types/pkg/commands/time.d.ts +0 -7
  392. package/types/pkg/commands/touch.d.ts +0 -7
  393. package/types/pkg/commands/ttl.d.ts +0 -7
  394. package/types/pkg/commands/type.d.ts +0 -8
  395. package/types/pkg/commands/unlink.d.ts +0 -7
  396. package/types/pkg/commands/zadd.d.ts +0 -35
  397. package/types/pkg/commands/zcard.d.ts +0 -7
  398. package/types/pkg/commands/zcount.d.ts +0 -7
  399. package/types/pkg/commands/zincrby.d.ts +0 -7
  400. package/types/pkg/commands/zinterstore.d.ts +0 -30
  401. package/types/pkg/commands/zlexcount.d.ts +0 -7
  402. package/types/pkg/commands/zmscore.d.ts +0 -7
  403. package/types/pkg/commands/zpopmax.d.ts +0 -7
  404. package/types/pkg/commands/zpopmin.d.ts +0 -7
  405. package/types/pkg/commands/zrange.d.ts +0 -42
  406. package/types/pkg/commands/zrank.d.ts +0 -7
  407. package/types/pkg/commands/zrem.d.ts +0 -7
  408. package/types/pkg/commands/zremrangebylex.d.ts +0 -7
  409. package/types/pkg/commands/zremrangebyrank.d.ts +0 -7
  410. package/types/pkg/commands/zremrangebyscore.d.ts +0 -7
  411. package/types/pkg/commands/zrevrank.d.ts +0 -7
  412. package/types/pkg/commands/zscan.d.ts +0 -24
  413. package/types/pkg/commands/zscore.d.ts +0 -7
  414. package/types/pkg/commands/zunionstore.d.ts +0 -30
  415. package/types/pkg/error.d.ts +0 -6
  416. package/types/pkg/http.d.ts +0 -54
  417. package/types/pkg/pipeline.d.ts +0 -552
  418. package/types/pkg/redis.d.ts +0 -534
  419. package/types/pkg/script.d.ts +0 -42
  420. package/types/pkg/types.d.ts +0 -1
  421. package/types/pkg/util.d.ts +0 -1
package/nodejs.mjs ADDED
@@ -0,0 +1,3026 @@
1
+ // pkg/error.ts
2
+ var UpstashError = class extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "UpstashError";
6
+ }
7
+ };
8
+
9
+ // pkg/http.ts
10
+ var HttpClient = class {
11
+ baseUrl;
12
+ headers;
13
+ options;
14
+ retry;
15
+ constructor(config) {
16
+ this.options = {
17
+ backend: config.options?.backend,
18
+ agent: config.agent,
19
+ responseEncoding: config.responseEncoding ?? "base64",
20
+ // default to base64
21
+ cache: config.cache
22
+ };
23
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
24
+ this.headers = {
25
+ "Content-Type": "application/json",
26
+ ...config.headers
27
+ };
28
+ if (this.options.responseEncoding === "base64") {
29
+ this.headers["Upstash-Encoding"] = "base64";
30
+ }
31
+ if (typeof config?.retry === "boolean" && config?.retry === false) {
32
+ this.retry = {
33
+ attempts: 1,
34
+ backoff: () => 0
35
+ };
36
+ } else {
37
+ this.retry = {
38
+ attempts: config?.retry?.retries ?? 5,
39
+ backoff: config?.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
40
+ };
41
+ }
42
+ }
43
+ mergeTelemetry(telemetry) {
44
+ function merge(obj, key, value) {
45
+ if (!value) {
46
+ return obj;
47
+ }
48
+ if (obj[key]) {
49
+ obj[key] = [obj[key], value].join(",");
50
+ } else {
51
+ obj[key] = value;
52
+ }
53
+ return obj;
54
+ }
55
+ this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
56
+ this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
57
+ this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
58
+ }
59
+ async request(req) {
60
+ const requestOptions = {
61
+ cache: this.options.cache,
62
+ method: "POST",
63
+ headers: this.headers,
64
+ body: JSON.stringify(req.body),
65
+ keepalive: true,
66
+ agent: this.options?.agent,
67
+ /**
68
+ * Fastly specific
69
+ */
70
+ backend: this.options?.backend
71
+ };
72
+ let res = null;
73
+ let error = null;
74
+ for (let i = 0; i <= this.retry.attempts; i++) {
75
+ try {
76
+ res = await fetch([this.baseUrl, ...req.path ?? []].join("/"), requestOptions);
77
+ break;
78
+ } catch (err) {
79
+ error = err;
80
+ await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
81
+ }
82
+ }
83
+ if (!res) {
84
+ throw error ?? new Error("Exhausted all retries");
85
+ }
86
+ const body = await res.json();
87
+ if (!res.ok) {
88
+ throw new UpstashError(`${body.error}, command was: ${JSON.stringify(req.body)}`);
89
+ }
90
+ if (this.options?.responseEncoding === "base64") {
91
+ if (Array.isArray(body)) {
92
+ return body.map(({ result: result2, error: error2 }) => ({
93
+ result: decode(result2),
94
+ error: error2
95
+ }));
96
+ }
97
+ const result = decode(body.result);
98
+ return { result, error: body.error };
99
+ }
100
+ return body;
101
+ }
102
+ };
103
+ function base64decode(b64) {
104
+ let dec = "";
105
+ try {
106
+ const binString = atob(b64);
107
+ const size = binString.length;
108
+ const bytes = new Uint8Array(size);
109
+ for (let i = 0; i < size; i++) {
110
+ bytes[i] = binString.charCodeAt(i);
111
+ }
112
+ dec = new TextDecoder().decode(bytes);
113
+ } catch {
114
+ dec = b64;
115
+ }
116
+ return dec;
117
+ }
118
+ function decode(raw) {
119
+ let result = void 0;
120
+ switch (typeof raw) {
121
+ case "undefined":
122
+ return raw;
123
+ case "number": {
124
+ result = raw;
125
+ break;
126
+ }
127
+ case "object": {
128
+ if (Array.isArray(raw)) {
129
+ result = raw.map(
130
+ (v) => typeof v === "string" ? base64decode(v) : Array.isArray(v) ? v.map(decode) : v
131
+ );
132
+ } else {
133
+ result = null;
134
+ }
135
+ break;
136
+ }
137
+ case "string": {
138
+ result = raw === "OK" ? "OK" : base64decode(raw);
139
+ break;
140
+ }
141
+ default:
142
+ break;
143
+ }
144
+ return result;
145
+ }
146
+
147
+ // pkg/util.ts
148
+ function parseRecursive(obj) {
149
+ const parsed = Array.isArray(obj) ? obj.map((o) => {
150
+ try {
151
+ return parseRecursive(o);
152
+ } catch {
153
+ return o;
154
+ }
155
+ }) : JSON.parse(obj);
156
+ if (typeof parsed === "number" && parsed.toString() !== obj) {
157
+ return obj;
158
+ }
159
+ return parsed;
160
+ }
161
+ function parseResponse(result) {
162
+ try {
163
+ return parseRecursive(result);
164
+ } catch {
165
+ return result;
166
+ }
167
+ }
168
+
169
+ // pkg/commands/command.ts
170
+ var defaultSerializer = (c) => {
171
+ switch (typeof c) {
172
+ case "string":
173
+ case "number":
174
+ case "boolean":
175
+ return c;
176
+ default:
177
+ return JSON.stringify(c);
178
+ }
179
+ };
180
+ var Command = class {
181
+ command;
182
+ serialize;
183
+ deserialize;
184
+ /**
185
+ * Create a new command instance.
186
+ *
187
+ * You can define a custom `deserialize` function. By default we try to deserialize as json.
188
+ */
189
+ constructor(command, opts) {
190
+ this.serialize = defaultSerializer;
191
+ this.deserialize = typeof opts?.automaticDeserialization === "undefined" || opts.automaticDeserialization ? opts?.deserialize ?? parseResponse : (x) => x;
192
+ this.command = command.map((c) => this.serialize(c));
193
+ }
194
+ /**
195
+ * Execute the command using a client.
196
+ */
197
+ async exec(client) {
198
+ const { result, error } = await client.request({
199
+ body: this.command
200
+ });
201
+ if (error) {
202
+ throw new UpstashError(error);
203
+ }
204
+ if (typeof result === "undefined") {
205
+ throw new Error("Request did not return a result");
206
+ }
207
+ return this.deserialize(result);
208
+ }
209
+ };
210
+
211
+ // pkg/commands/append.ts
212
+ var AppendCommand = class extends Command {
213
+ constructor(cmd, opts) {
214
+ super(["append", ...cmd], opts);
215
+ }
216
+ };
217
+
218
+ // pkg/commands/bitcount.ts
219
+ var BitCountCommand = class extends Command {
220
+ constructor([key, start, end], opts) {
221
+ const command = ["bitcount", key];
222
+ if (typeof start === "number") {
223
+ command.push(start);
224
+ }
225
+ if (typeof end === "number") {
226
+ command.push(end);
227
+ }
228
+ super(command, opts);
229
+ }
230
+ };
231
+
232
+ // pkg/commands/bitop.ts
233
+ var BitOpCommand = class extends Command {
234
+ constructor(cmd, opts) {
235
+ super(["bitop", ...cmd], opts);
236
+ }
237
+ };
238
+
239
+ // pkg/commands/bitpos.ts
240
+ var BitPosCommand = class extends Command {
241
+ constructor(cmd, opts) {
242
+ super(["bitpos", ...cmd], opts);
243
+ }
244
+ };
245
+
246
+ // pkg/commands/dbsize.ts
247
+ var DBSizeCommand = class extends Command {
248
+ constructor(opts) {
249
+ super(["dbsize"], opts);
250
+ }
251
+ };
252
+
253
+ // pkg/commands/decr.ts
254
+ var DecrCommand = class extends Command {
255
+ constructor(cmd, opts) {
256
+ super(["decr", ...cmd], opts);
257
+ }
258
+ };
259
+
260
+ // pkg/commands/decrby.ts
261
+ var DecrByCommand = class extends Command {
262
+ constructor(cmd, opts) {
263
+ super(["decrby", ...cmd], opts);
264
+ }
265
+ };
266
+
267
+ // pkg/commands/del.ts
268
+ var DelCommand = class extends Command {
269
+ constructor(cmd, opts) {
270
+ super(["del", ...cmd], opts);
271
+ }
272
+ };
273
+
274
+ // pkg/commands/echo.ts
275
+ var EchoCommand = class extends Command {
276
+ constructor(cmd, opts) {
277
+ super(["echo", ...cmd], opts);
278
+ }
279
+ };
280
+
281
+ // pkg/commands/eval.ts
282
+ var EvalCommand = class extends Command {
283
+ constructor([script, keys, args], opts) {
284
+ super(["eval", script, keys.length, ...keys, ...args ?? []], opts);
285
+ }
286
+ };
287
+
288
+ // pkg/commands/evalsha.ts
289
+ var EvalshaCommand = class extends Command {
290
+ constructor([sha, keys, args], opts) {
291
+ super(["evalsha", sha, keys.length, ...keys, ...args ?? []], opts);
292
+ }
293
+ };
294
+
295
+ // pkg/commands/exists.ts
296
+ var ExistsCommand = class extends Command {
297
+ constructor(cmd, opts) {
298
+ super(["exists", ...cmd], opts);
299
+ }
300
+ };
301
+
302
+ // pkg/commands/expire.ts
303
+ var ExpireCommand = class extends Command {
304
+ constructor(cmd, opts) {
305
+ super(["expire", ...cmd], opts);
306
+ }
307
+ };
308
+
309
+ // pkg/commands/expireat.ts
310
+ var ExpireAtCommand = class extends Command {
311
+ constructor(cmd, opts) {
312
+ super(["expireat", ...cmd], opts);
313
+ }
314
+ };
315
+
316
+ // pkg/commands/flushall.ts
317
+ var FlushAllCommand = class extends Command {
318
+ constructor(args, opts) {
319
+ const command = ["flushall"];
320
+ if (args && args.length > 0 && args[0].async) {
321
+ command.push("async");
322
+ }
323
+ super(command, opts);
324
+ }
325
+ };
326
+
327
+ // pkg/commands/flushdb.ts
328
+ var FlushDBCommand = class extends Command {
329
+ constructor([opts], cmdOpts) {
330
+ const command = ["flushdb"];
331
+ if (opts?.async) {
332
+ command.push("async");
333
+ }
334
+ super(command, cmdOpts);
335
+ }
336
+ };
337
+
338
+ // pkg/commands/geo_add.ts
339
+ var GeoAddCommand = class extends Command {
340
+ constructor([key, arg1, ...arg2], opts) {
341
+ const command = ["geoadd", key];
342
+ if ("nx" in arg1 && arg1.nx) {
343
+ command.push("nx");
344
+ } else if ("xx" in arg1 && arg1.xx) {
345
+ command.push("xx");
346
+ }
347
+ if ("ch" in arg1 && arg1.ch) {
348
+ command.push("ch");
349
+ }
350
+ if ("latitude" in arg1 && arg1.latitude) {
351
+ command.push(arg1.longitude, arg1.latitude, arg1.member);
352
+ }
353
+ command.push(
354
+ ...arg2.flatMap(({ latitude, longitude, member }) => [longitude, latitude, member])
355
+ );
356
+ super(command, opts);
357
+ }
358
+ };
359
+
360
+ // pkg/commands/geo_dist.ts
361
+ var GeoDistCommand = class extends Command {
362
+ constructor([key, member1, member2, unit = "M"], opts) {
363
+ super(["GEODIST", key, member1, member2, unit], opts);
364
+ }
365
+ };
366
+
367
+ // pkg/commands/get.ts
368
+ var GetCommand = class extends Command {
369
+ constructor(cmd, opts) {
370
+ super(["get", ...cmd], opts);
371
+ }
372
+ };
373
+
374
+ // pkg/commands/getbit.ts
375
+ var GetBitCommand = class extends Command {
376
+ constructor(cmd, opts) {
377
+ super(["getbit", ...cmd], opts);
378
+ }
379
+ };
380
+
381
+ // pkg/commands/getdel.ts
382
+ var GetDelCommand = class extends Command {
383
+ constructor(cmd, opts) {
384
+ super(["getdel", ...cmd], opts);
385
+ }
386
+ };
387
+
388
+ // pkg/commands/getrange.ts
389
+ var GetRangeCommand = class extends Command {
390
+ constructor(cmd, opts) {
391
+ super(["getrange", ...cmd], opts);
392
+ }
393
+ };
394
+
395
+ // pkg/commands/getset.ts
396
+ var GetSetCommand = class extends Command {
397
+ constructor(cmd, opts) {
398
+ super(["getset", ...cmd], opts);
399
+ }
400
+ };
401
+
402
+ // pkg/commands/hdel.ts
403
+ var HDelCommand = class extends Command {
404
+ constructor(cmd, opts) {
405
+ super(["hdel", ...cmd], opts);
406
+ }
407
+ };
408
+
409
+ // pkg/commands/hexists.ts
410
+ var HExistsCommand = class extends Command {
411
+ constructor(cmd, opts) {
412
+ super(["hexists", ...cmd], opts);
413
+ }
414
+ };
415
+
416
+ // pkg/commands/hget.ts
417
+ var HGetCommand = class extends Command {
418
+ constructor(cmd, opts) {
419
+ super(["hget", ...cmd], opts);
420
+ }
421
+ };
422
+
423
+ // pkg/commands/hgetall.ts
424
+ function deserialize(result) {
425
+ if (result.length === 0) {
426
+ return null;
427
+ }
428
+ const obj = {};
429
+ while (result.length >= 2) {
430
+ const key = result.shift();
431
+ const value = result.shift();
432
+ try {
433
+ const valueIsNumberAndNotSafeInteger = !Number.isNaN(Number(value)) && !Number.isSafeInteger(value);
434
+ if (valueIsNumberAndNotSafeInteger) {
435
+ obj[key] = value;
436
+ } else {
437
+ obj[key] = JSON.parse(value);
438
+ }
439
+ } catch {
440
+ obj[key] = value;
441
+ }
442
+ }
443
+ return obj;
444
+ }
445
+ var HGetAllCommand = class extends Command {
446
+ constructor(cmd, opts) {
447
+ super(["hgetall", ...cmd], {
448
+ deserialize: (result) => deserialize(result),
449
+ ...opts
450
+ });
451
+ }
452
+ };
453
+
454
+ // pkg/commands/hincrby.ts
455
+ var HIncrByCommand = class extends Command {
456
+ constructor(cmd, opts) {
457
+ super(["hincrby", ...cmd], opts);
458
+ }
459
+ };
460
+
461
+ // pkg/commands/hincrbyfloat.ts
462
+ var HIncrByFloatCommand = class extends Command {
463
+ constructor(cmd, opts) {
464
+ super(["hincrbyfloat", ...cmd], opts);
465
+ }
466
+ };
467
+
468
+ // pkg/commands/hkeys.ts
469
+ var HKeysCommand = class extends Command {
470
+ constructor([key], opts) {
471
+ super(["hkeys", key], opts);
472
+ }
473
+ };
474
+
475
+ // pkg/commands/hlen.ts
476
+ var HLenCommand = class extends Command {
477
+ constructor(cmd, opts) {
478
+ super(["hlen", ...cmd], opts);
479
+ }
480
+ };
481
+
482
+ // pkg/commands/hmget.ts
483
+ function deserialize2(fields, result) {
484
+ if (result.length === 0 || result.every((field) => field === null)) {
485
+ return null;
486
+ }
487
+ const obj = {};
488
+ for (let i = 0; i < fields.length; i++) {
489
+ try {
490
+ obj[fields[i]] = JSON.parse(result[i]);
491
+ } catch {
492
+ obj[fields[i]] = result[i];
493
+ }
494
+ }
495
+ return obj;
496
+ }
497
+ var HMGetCommand = class extends Command {
498
+ constructor([key, ...fields], opts) {
499
+ super(["hmget", key, ...fields], {
500
+ deserialize: (result) => deserialize2(fields, result),
501
+ ...opts
502
+ });
503
+ }
504
+ };
505
+
506
+ // pkg/commands/hmset.ts
507
+ var HMSetCommand = class extends Command {
508
+ constructor([key, kv], opts) {
509
+ super(["hmset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
510
+ }
511
+ };
512
+
513
+ // pkg/commands/hrandfield.ts
514
+ function deserialize3(result) {
515
+ if (result.length === 0) {
516
+ return null;
517
+ }
518
+ const obj = {};
519
+ while (result.length >= 2) {
520
+ const key = result.shift();
521
+ const value = result.shift();
522
+ try {
523
+ obj[key] = JSON.parse(value);
524
+ } catch {
525
+ obj[key] = value;
526
+ }
527
+ }
528
+ return obj;
529
+ }
530
+ var HRandFieldCommand = class extends Command {
531
+ constructor(cmd, opts) {
532
+ const command = ["hrandfield", cmd[0]];
533
+ if (typeof cmd[1] === "number") {
534
+ command.push(cmd[1]);
535
+ }
536
+ if (cmd[2]) {
537
+ command.push("WITHVALUES");
538
+ }
539
+ super(command, {
540
+ // @ts-ignore TODO:
541
+ deserialize: cmd[2] ? (result) => deserialize3(result) : opts?.deserialize,
542
+ ...opts
543
+ });
544
+ }
545
+ };
546
+
547
+ // pkg/commands/hscan.ts
548
+ var HScanCommand = class extends Command {
549
+ constructor([key, cursor, cmdOpts], opts) {
550
+ const command = ["hscan", key, cursor];
551
+ if (cmdOpts?.match) {
552
+ command.push("match", cmdOpts.match);
553
+ }
554
+ if (typeof cmdOpts?.count === "number") {
555
+ command.push("count", cmdOpts.count);
556
+ }
557
+ super(command, opts);
558
+ }
559
+ };
560
+
561
+ // pkg/commands/hset.ts
562
+ var HSetCommand = class extends Command {
563
+ constructor([key, kv], opts) {
564
+ super(["hset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
565
+ }
566
+ };
567
+
568
+ // pkg/commands/hsetnx.ts
569
+ var HSetNXCommand = class extends Command {
570
+ constructor(cmd, opts) {
571
+ super(["hsetnx", ...cmd], opts);
572
+ }
573
+ };
574
+
575
+ // pkg/commands/hstrlen.ts
576
+ var HStrLenCommand = class extends Command {
577
+ constructor(cmd, opts) {
578
+ super(["hstrlen", ...cmd], opts);
579
+ }
580
+ };
581
+
582
+ // pkg/commands/hvals.ts
583
+ var HValsCommand = class extends Command {
584
+ constructor(cmd, opts) {
585
+ super(["hvals", ...cmd], opts);
586
+ }
587
+ };
588
+
589
+ // pkg/commands/incr.ts
590
+ var IncrCommand = class extends Command {
591
+ constructor(cmd, opts) {
592
+ super(["incr", ...cmd], opts);
593
+ }
594
+ };
595
+
596
+ // pkg/commands/incrby.ts
597
+ var IncrByCommand = class extends Command {
598
+ constructor(cmd, opts) {
599
+ super(["incrby", ...cmd], opts);
600
+ }
601
+ };
602
+
603
+ // pkg/commands/incrbyfloat.ts
604
+ var IncrByFloatCommand = class extends Command {
605
+ constructor(cmd, opts) {
606
+ super(["incrbyfloat", ...cmd], opts);
607
+ }
608
+ };
609
+
610
+ // pkg/commands/json_arrappend.ts
611
+ var JsonArrAppendCommand = class extends Command {
612
+ constructor(cmd, opts) {
613
+ super(["JSON.ARRAPPEND", ...cmd], opts);
614
+ }
615
+ };
616
+
617
+ // pkg/commands/json_arrindex.ts
618
+ var JsonArrIndexCommand = class extends Command {
619
+ constructor(cmd, opts) {
620
+ super(["JSON.ARRINDEX", ...cmd], opts);
621
+ }
622
+ };
623
+
624
+ // pkg/commands/json_arrinsert.ts
625
+ var JsonArrInsertCommand = class extends Command {
626
+ constructor(cmd, opts) {
627
+ super(["JSON.ARRINSERT", ...cmd], opts);
628
+ }
629
+ };
630
+
631
+ // pkg/commands/json_arrlen.ts
632
+ var JsonArrLenCommand = class extends Command {
633
+ constructor(cmd, opts) {
634
+ super(["JSON.ARRLEN", cmd[0], cmd[1] ?? "$"], opts);
635
+ }
636
+ };
637
+
638
+ // pkg/commands/json_arrpop.ts
639
+ var JsonArrPopCommand = class extends Command {
640
+ constructor(cmd, opts) {
641
+ super(["JSON.ARRPOP", ...cmd], opts);
642
+ }
643
+ };
644
+
645
+ // pkg/commands/json_arrtrim.ts
646
+ var JsonArrTrimCommand = class extends Command {
647
+ constructor(cmd, opts) {
648
+ const path = cmd[1] ?? "$";
649
+ const start = cmd[2] ?? 0;
650
+ const stop = cmd[3] ?? 0;
651
+ super(["JSON.ARRTRIM", cmd[0], path, start, stop], opts);
652
+ }
653
+ };
654
+
655
+ // pkg/commands/json_clear.ts
656
+ var JsonClearCommand = class extends Command {
657
+ constructor(cmd, opts) {
658
+ super(["JSON.CLEAR", ...cmd], opts);
659
+ }
660
+ };
661
+
662
+ // pkg/commands/json_del.ts
663
+ var JsonDelCommand = class extends Command {
664
+ constructor(cmd, opts) {
665
+ super(["JSON.DEL", ...cmd], opts);
666
+ }
667
+ };
668
+
669
+ // pkg/commands/json_forget.ts
670
+ var JsonForgetCommand = class extends Command {
671
+ constructor(cmd, opts) {
672
+ super(["JSON.FORGET", ...cmd], opts);
673
+ }
674
+ };
675
+
676
+ // pkg/commands/json_get.ts
677
+ var JsonGetCommand = class extends Command {
678
+ constructor(cmd, opts) {
679
+ const command = ["JSON.GET"];
680
+ if (typeof cmd[1] === "string") {
681
+ command.push(...cmd);
682
+ } else {
683
+ command.push(cmd[0]);
684
+ if (cmd[1]) {
685
+ if (cmd[1].indent) {
686
+ command.push("INDENT", cmd[1].indent);
687
+ }
688
+ if (cmd[1].newline) {
689
+ command.push("NEWLINE", cmd[1].newline);
690
+ }
691
+ if (cmd[1].space) {
692
+ command.push("SPACE", cmd[1].space);
693
+ }
694
+ }
695
+ command.push(...cmd.slice(2));
696
+ }
697
+ super(command, opts);
698
+ }
699
+ };
700
+
701
+ // pkg/commands/json_mget.ts
702
+ var JsonMGetCommand = class extends Command {
703
+ constructor(cmd, opts) {
704
+ super(["JSON.MGET", ...cmd[0], cmd[1]], opts);
705
+ }
706
+ };
707
+
708
+ // pkg/commands/json_numincrby.ts
709
+ var JsonNumIncrByCommand = class extends Command {
710
+ constructor(cmd, opts) {
711
+ super(["JSON.NUMINCRBY", ...cmd], opts);
712
+ }
713
+ };
714
+
715
+ // pkg/commands/json_nummultby.ts
716
+ var JsonNumMultByCommand = class extends Command {
717
+ constructor(cmd, opts) {
718
+ super(["JSON.NUMMULTBY", ...cmd], opts);
719
+ }
720
+ };
721
+
722
+ // pkg/commands/json_objkeys.ts
723
+ var JsonObjKeysCommand = class extends Command {
724
+ constructor(cmd, opts) {
725
+ super(["JSON.OBJKEYS", ...cmd], opts);
726
+ }
727
+ };
728
+
729
+ // pkg/commands/json_objlen.ts
730
+ var JsonObjLenCommand = class extends Command {
731
+ constructor(cmd, opts) {
732
+ super(["JSON.OBJLEN", ...cmd], opts);
733
+ }
734
+ };
735
+
736
+ // pkg/commands/json_resp.ts
737
+ var JsonRespCommand = class extends Command {
738
+ constructor(cmd, opts) {
739
+ super(["JSON.RESP", ...cmd], opts);
740
+ }
741
+ };
742
+
743
+ // pkg/commands/json_set.ts
744
+ var JsonSetCommand = class extends Command {
745
+ constructor(cmd, opts) {
746
+ const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]];
747
+ if (cmd[3]) {
748
+ if (cmd[3].nx) {
749
+ command.push("NX");
750
+ } else if (cmd[3].xx) {
751
+ command.push("XX");
752
+ }
753
+ }
754
+ super(command, opts);
755
+ }
756
+ };
757
+
758
+ // pkg/commands/json_strappend.ts
759
+ var JsonStrAppendCommand = class extends Command {
760
+ constructor(cmd, opts) {
761
+ super(["JSON.STRAPPEND", ...cmd], opts);
762
+ }
763
+ };
764
+
765
+ // pkg/commands/json_strlen.ts
766
+ var JsonStrLenCommand = class extends Command {
767
+ constructor(cmd, opts) {
768
+ super(["JSON.STRLEN", ...cmd], opts);
769
+ }
770
+ };
771
+
772
+ // pkg/commands/json_toggle.ts
773
+ var JsonToggleCommand = class extends Command {
774
+ constructor(cmd, opts) {
775
+ super(["JSON.TOGGLE", ...cmd], opts);
776
+ }
777
+ };
778
+
779
+ // pkg/commands/json_type.ts
780
+ var JsonTypeCommand = class extends Command {
781
+ constructor(cmd, opts) {
782
+ super(["JSON.TYPE", ...cmd], opts);
783
+ }
784
+ };
785
+
786
+ // pkg/commands/keys.ts
787
+ var KeysCommand = class extends Command {
788
+ constructor(cmd, opts) {
789
+ super(["keys", ...cmd], opts);
790
+ }
791
+ };
792
+
793
+ // pkg/commands/lindex.ts
794
+ var LIndexCommand = class extends Command {
795
+ constructor(cmd, opts) {
796
+ super(["lindex", ...cmd], opts);
797
+ }
798
+ };
799
+
800
+ // pkg/commands/linsert.ts
801
+ var LInsertCommand = class extends Command {
802
+ constructor(cmd, opts) {
803
+ super(["linsert", ...cmd], opts);
804
+ }
805
+ };
806
+
807
+ // pkg/commands/llen.ts
808
+ var LLenCommand = class extends Command {
809
+ constructor(cmd, opts) {
810
+ super(["llen", ...cmd], opts);
811
+ }
812
+ };
813
+
814
+ // pkg/commands/lmove.ts
815
+ var LMoveCommand = class extends Command {
816
+ constructor(cmd, opts) {
817
+ super(["lmove", ...cmd], opts);
818
+ }
819
+ };
820
+
821
+ // pkg/commands/lpop.ts
822
+ var LPopCommand = class extends Command {
823
+ constructor(cmd, opts) {
824
+ super(["lpop", ...cmd], opts);
825
+ }
826
+ };
827
+
828
+ // pkg/commands/lpos.ts
829
+ var LPosCommand = class extends Command {
830
+ constructor(cmd, opts) {
831
+ const args = ["lpos", cmd[0], cmd[1]];
832
+ if (typeof cmd[2]?.rank === "number") {
833
+ args.push("rank", cmd[2].rank);
834
+ }
835
+ if (typeof cmd[2]?.count === "number") {
836
+ args.push("count", cmd[2].count);
837
+ }
838
+ if (typeof cmd[2]?.maxLen === "number") {
839
+ args.push("maxLen", cmd[2].maxLen);
840
+ }
841
+ super(args, opts);
842
+ }
843
+ };
844
+
845
+ // pkg/commands/lpush.ts
846
+ var LPushCommand = class extends Command {
847
+ constructor(cmd, opts) {
848
+ super(["lpush", ...cmd], opts);
849
+ }
850
+ };
851
+
852
+ // pkg/commands/lpushx.ts
853
+ var LPushXCommand = class extends Command {
854
+ constructor(cmd, opts) {
855
+ super(["lpushx", ...cmd], opts);
856
+ }
857
+ };
858
+
859
+ // pkg/commands/lrange.ts
860
+ var LRangeCommand = class extends Command {
861
+ constructor(cmd, opts) {
862
+ super(["lrange", ...cmd], opts);
863
+ }
864
+ };
865
+
866
+ // pkg/commands/lrem.ts
867
+ var LRemCommand = class extends Command {
868
+ constructor(cmd, opts) {
869
+ super(["lrem", ...cmd], opts);
870
+ }
871
+ };
872
+
873
+ // pkg/commands/lset.ts
874
+ var LSetCommand = class extends Command {
875
+ constructor(cmd, opts) {
876
+ super(["lset", ...cmd], opts);
877
+ }
878
+ };
879
+
880
+ // pkg/commands/ltrim.ts
881
+ var LTrimCommand = class extends Command {
882
+ constructor(cmd, opts) {
883
+ super(["ltrim", ...cmd], opts);
884
+ }
885
+ };
886
+
887
+ // pkg/commands/mget.ts
888
+ var MGetCommand = class extends Command {
889
+ constructor(cmd, opts) {
890
+ const keys = Array.isArray(cmd[0]) ? cmd[0] : cmd;
891
+ super(["mget", ...keys], opts);
892
+ }
893
+ };
894
+
895
+ // pkg/commands/mset.ts
896
+ var MSetCommand = class extends Command {
897
+ constructor([kv], opts) {
898
+ super(["mset", ...Object.entries(kv).flatMap(([key, value]) => [key, value])], opts);
899
+ }
900
+ };
901
+
902
+ // pkg/commands/msetnx.ts
903
+ var MSetNXCommand = class extends Command {
904
+ constructor([kv], opts) {
905
+ super(["msetnx", ...Object.entries(kv).flatMap((_) => _)], opts);
906
+ }
907
+ };
908
+
909
+ // pkg/commands/persist.ts
910
+ var PersistCommand = class extends Command {
911
+ constructor(cmd, opts) {
912
+ super(["persist", ...cmd], opts);
913
+ }
914
+ };
915
+
916
+ // pkg/commands/pexpire.ts
917
+ var PExpireCommand = class extends Command {
918
+ constructor(cmd, opts) {
919
+ super(["pexpire", ...cmd], opts);
920
+ }
921
+ };
922
+
923
+ // pkg/commands/pexpireat.ts
924
+ var PExpireAtCommand = class extends Command {
925
+ constructor(cmd, opts) {
926
+ super(["pexpireat", ...cmd], opts);
927
+ }
928
+ };
929
+
930
+ // pkg/commands/ping.ts
931
+ var PingCommand = class extends Command {
932
+ constructor(cmd, opts) {
933
+ const command = ["ping"];
934
+ if (typeof cmd !== "undefined" && typeof cmd[0] !== "undefined") {
935
+ command.push(cmd[0]);
936
+ }
937
+ super(command, opts);
938
+ }
939
+ };
940
+
941
+ // pkg/commands/psetex.ts
942
+ var PSetEXCommand = class extends Command {
943
+ constructor(cmd, opts) {
944
+ super(["psetex", ...cmd], opts);
945
+ }
946
+ };
947
+
948
+ // pkg/commands/pttl.ts
949
+ var PTtlCommand = class extends Command {
950
+ constructor(cmd, opts) {
951
+ super(["pttl", ...cmd], opts);
952
+ }
953
+ };
954
+
955
+ // pkg/commands/publish.ts
956
+ var PublishCommand = class extends Command {
957
+ constructor(cmd, opts) {
958
+ super(["publish", ...cmd], opts);
959
+ }
960
+ };
961
+
962
+ // pkg/commands/randomkey.ts
963
+ var RandomKeyCommand = class extends Command {
964
+ constructor(opts) {
965
+ super(["randomkey"], opts);
966
+ }
967
+ };
968
+
969
+ // pkg/commands/rename.ts
970
+ var RenameCommand = class extends Command {
971
+ constructor(cmd, opts) {
972
+ super(["rename", ...cmd], opts);
973
+ }
974
+ };
975
+
976
+ // pkg/commands/renamenx.ts
977
+ var RenameNXCommand = class extends Command {
978
+ constructor(cmd, opts) {
979
+ super(["renamenx", ...cmd], opts);
980
+ }
981
+ };
982
+
983
+ // pkg/commands/rpop.ts
984
+ var RPopCommand = class extends Command {
985
+ constructor(cmd, opts) {
986
+ super(["rpop", ...cmd], opts);
987
+ }
988
+ };
989
+
990
+ // pkg/commands/rpush.ts
991
+ var RPushCommand = class extends Command {
992
+ constructor(cmd, opts) {
993
+ super(["rpush", ...cmd], opts);
994
+ }
995
+ };
996
+
997
+ // pkg/commands/rpushx.ts
998
+ var RPushXCommand = class extends Command {
999
+ constructor(cmd, opts) {
1000
+ super(["rpushx", ...cmd], opts);
1001
+ }
1002
+ };
1003
+
1004
+ // pkg/commands/sadd.ts
1005
+ var SAddCommand = class extends Command {
1006
+ constructor(cmd, opts) {
1007
+ super(["sadd", ...cmd], opts);
1008
+ }
1009
+ };
1010
+
1011
+ // pkg/commands/scan.ts
1012
+ var ScanCommand = class extends Command {
1013
+ constructor([cursor, opts], cmdOpts) {
1014
+ const command = ["scan", cursor];
1015
+ if (opts?.match) {
1016
+ command.push("match", opts.match);
1017
+ }
1018
+ if (typeof opts?.count === "number") {
1019
+ command.push("count", opts.count);
1020
+ }
1021
+ if (opts?.type && opts.type.length > 0) {
1022
+ command.push("type", opts.type);
1023
+ }
1024
+ super(command, cmdOpts);
1025
+ }
1026
+ };
1027
+
1028
+ // pkg/commands/scard.ts
1029
+ var SCardCommand = class extends Command {
1030
+ constructor(cmd, opts) {
1031
+ super(["scard", ...cmd], opts);
1032
+ }
1033
+ };
1034
+
1035
+ // pkg/commands/script_exists.ts
1036
+ var ScriptExistsCommand = class extends Command {
1037
+ constructor(hashes, opts) {
1038
+ super(["script", "exists", ...hashes], {
1039
+ deserialize: (result) => result,
1040
+ ...opts
1041
+ });
1042
+ }
1043
+ };
1044
+
1045
+ // pkg/commands/script_flush.ts
1046
+ var ScriptFlushCommand = class extends Command {
1047
+ constructor([opts], cmdOpts) {
1048
+ const cmd = ["script", "flush"];
1049
+ if (opts?.sync) {
1050
+ cmd.push("sync");
1051
+ } else if (opts?.async) {
1052
+ cmd.push("async");
1053
+ }
1054
+ super(cmd, cmdOpts);
1055
+ }
1056
+ };
1057
+
1058
+ // pkg/commands/script_load.ts
1059
+ var ScriptLoadCommand = class extends Command {
1060
+ constructor(args, opts) {
1061
+ super(["script", "load", ...args], opts);
1062
+ }
1063
+ };
1064
+
1065
+ // pkg/commands/sdiff.ts
1066
+ var SDiffCommand = class extends Command {
1067
+ constructor(cmd, opts) {
1068
+ super(["sdiff", ...cmd], opts);
1069
+ }
1070
+ };
1071
+
1072
+ // pkg/commands/sdiffstore.ts
1073
+ var SDiffStoreCommand = class extends Command {
1074
+ constructor(cmd, opts) {
1075
+ super(["sdiffstore", ...cmd], opts);
1076
+ }
1077
+ };
1078
+
1079
+ // pkg/commands/set.ts
1080
+ var SetCommand = class extends Command {
1081
+ constructor([key, value, opts], cmdOpts) {
1082
+ const command = ["set", key, value];
1083
+ if (opts) {
1084
+ if ("nx" in opts && opts.nx) {
1085
+ command.push("nx");
1086
+ } else if ("xx" in opts && opts.xx) {
1087
+ command.push("xx");
1088
+ }
1089
+ if ("get" in opts && opts.get) {
1090
+ command.push("get");
1091
+ }
1092
+ if ("ex" in opts && typeof opts.ex === "number") {
1093
+ command.push("ex", opts.ex);
1094
+ } else if ("px" in opts && typeof opts.px === "number") {
1095
+ command.push("px", opts.px);
1096
+ } else if ("exat" in opts && typeof opts.exat === "number") {
1097
+ command.push("exat", opts.exat);
1098
+ } else if ("pxat" in opts && typeof opts.pxat === "number") {
1099
+ command.push("pxat", opts.pxat);
1100
+ } else if ("keepTtl" in opts && opts.keepTtl) {
1101
+ command.push("keepTtl");
1102
+ }
1103
+ }
1104
+ super(command, cmdOpts);
1105
+ }
1106
+ };
1107
+
1108
+ // pkg/commands/setbit.ts
1109
+ var SetBitCommand = class extends Command {
1110
+ constructor(cmd, opts) {
1111
+ super(["setbit", ...cmd], opts);
1112
+ }
1113
+ };
1114
+
1115
+ // pkg/commands/setex.ts
1116
+ var SetExCommand = class extends Command {
1117
+ constructor(cmd, opts) {
1118
+ super(["setex", ...cmd], opts);
1119
+ }
1120
+ };
1121
+
1122
+ // pkg/commands/setnx.ts
1123
+ var SetNxCommand = class extends Command {
1124
+ constructor(cmd, opts) {
1125
+ super(["setnx", ...cmd], opts);
1126
+ }
1127
+ };
1128
+
1129
+ // pkg/commands/setrange.ts
1130
+ var SetRangeCommand = class extends Command {
1131
+ constructor(cmd, opts) {
1132
+ super(["setrange", ...cmd], opts);
1133
+ }
1134
+ };
1135
+
1136
+ // pkg/commands/sinter.ts
1137
+ var SInterCommand = class extends Command {
1138
+ constructor(cmd, opts) {
1139
+ super(["sinter", ...cmd], opts);
1140
+ }
1141
+ };
1142
+
1143
+ // pkg/commands/sinterstore.ts
1144
+ var SInterStoreCommand = class extends Command {
1145
+ constructor(cmd, opts) {
1146
+ super(["sinterstore", ...cmd], opts);
1147
+ }
1148
+ };
1149
+
1150
+ // pkg/commands/sismember.ts
1151
+ var SIsMemberCommand = class extends Command {
1152
+ constructor(cmd, opts) {
1153
+ super(["sismember", ...cmd], opts);
1154
+ }
1155
+ };
1156
+
1157
+ // pkg/commands/smembers.ts
1158
+ var SMembersCommand = class extends Command {
1159
+ constructor(cmd, opts) {
1160
+ super(["smembers", ...cmd], opts);
1161
+ }
1162
+ };
1163
+
1164
+ // pkg/commands/smismember.ts
1165
+ var SMIsMemberCommand = class extends Command {
1166
+ constructor(cmd, opts) {
1167
+ super(["smismember", cmd[0], ...cmd[1]], opts);
1168
+ }
1169
+ };
1170
+
1171
+ // pkg/commands/smove.ts
1172
+ var SMoveCommand = class extends Command {
1173
+ constructor(cmd, opts) {
1174
+ super(["smove", ...cmd], opts);
1175
+ }
1176
+ };
1177
+
1178
+ // pkg/commands/spop.ts
1179
+ var SPopCommand = class extends Command {
1180
+ constructor([key, count], opts) {
1181
+ const command = ["spop", key];
1182
+ if (typeof count === "number") {
1183
+ command.push(count);
1184
+ }
1185
+ super(command, opts);
1186
+ }
1187
+ };
1188
+
1189
+ // pkg/commands/srandmember.ts
1190
+ var SRandMemberCommand = class extends Command {
1191
+ constructor([key, count], opts) {
1192
+ const command = ["srandmember", key];
1193
+ if (typeof count === "number") {
1194
+ command.push(count);
1195
+ }
1196
+ super(command, opts);
1197
+ }
1198
+ };
1199
+
1200
+ // pkg/commands/srem.ts
1201
+ var SRemCommand = class extends Command {
1202
+ constructor(cmd, opts) {
1203
+ super(["srem", ...cmd], opts);
1204
+ }
1205
+ };
1206
+
1207
+ // pkg/commands/sscan.ts
1208
+ var SScanCommand = class extends Command {
1209
+ constructor([key, cursor, opts], cmdOpts) {
1210
+ const command = ["sscan", key, cursor];
1211
+ if (opts?.match) {
1212
+ command.push("match", opts.match);
1213
+ }
1214
+ if (typeof opts?.count === "number") {
1215
+ command.push("count", opts.count);
1216
+ }
1217
+ super(command, cmdOpts);
1218
+ }
1219
+ };
1220
+
1221
+ // pkg/commands/strlen.ts
1222
+ var StrLenCommand = class extends Command {
1223
+ constructor(cmd, opts) {
1224
+ super(["strlen", ...cmd], opts);
1225
+ }
1226
+ };
1227
+
1228
+ // pkg/commands/sunion.ts
1229
+ var SUnionCommand = class extends Command {
1230
+ constructor(cmd, opts) {
1231
+ super(["sunion", ...cmd], opts);
1232
+ }
1233
+ };
1234
+
1235
+ // pkg/commands/sunionstore.ts
1236
+ var SUnionStoreCommand = class extends Command {
1237
+ constructor(cmd, opts) {
1238
+ super(["sunionstore", ...cmd], opts);
1239
+ }
1240
+ };
1241
+
1242
+ // pkg/commands/time.ts
1243
+ var TimeCommand = class extends Command {
1244
+ constructor(opts) {
1245
+ super(["time"], opts);
1246
+ }
1247
+ };
1248
+
1249
+ // pkg/commands/touch.ts
1250
+ var TouchCommand = class extends Command {
1251
+ constructor(cmd, opts) {
1252
+ super(["touch", ...cmd], opts);
1253
+ }
1254
+ };
1255
+
1256
+ // pkg/commands/ttl.ts
1257
+ var TtlCommand = class extends Command {
1258
+ constructor(cmd, opts) {
1259
+ super(["ttl", ...cmd], opts);
1260
+ }
1261
+ };
1262
+
1263
+ // pkg/commands/type.ts
1264
+ var TypeCommand = class extends Command {
1265
+ constructor(cmd, opts) {
1266
+ super(["type", ...cmd], opts);
1267
+ }
1268
+ };
1269
+
1270
+ // pkg/commands/unlink.ts
1271
+ var UnlinkCommand = class extends Command {
1272
+ constructor(cmd, opts) {
1273
+ super(["unlink", ...cmd], opts);
1274
+ }
1275
+ };
1276
+
1277
+ // pkg/commands/xadd.ts
1278
+ var XAddCommand = class extends Command {
1279
+ constructor([key, id, entries, opts], commandOptions) {
1280
+ const command = ["XADD", key];
1281
+ if (opts) {
1282
+ if (opts.nomkStream) {
1283
+ command.push("NOMKSTREAM");
1284
+ }
1285
+ if (opts.trim) {
1286
+ command.push(opts.trim.type, opts.trim.comparison, opts.trim.threshold);
1287
+ if (typeof opts.trim.limit !== "undefined") {
1288
+ command.push("LIMIT", opts.trim.limit);
1289
+ }
1290
+ }
1291
+ }
1292
+ command.push(id);
1293
+ for (const [k, v] of Object.entries(entries)) {
1294
+ command.push(k, v);
1295
+ }
1296
+ super(command, commandOptions);
1297
+ }
1298
+ };
1299
+
1300
+ // pkg/commands/xrange.ts
1301
+ function deserialize4(result) {
1302
+ const obj = {};
1303
+ for (const e of result) {
1304
+ while (e.length >= 2) {
1305
+ const streamId = e.shift();
1306
+ const entries = e.shift();
1307
+ if (!(streamId in obj)) {
1308
+ obj[streamId] = {};
1309
+ }
1310
+ while (entries.length >= 2) {
1311
+ const field = entries.shift();
1312
+ const value = entries.shift();
1313
+ try {
1314
+ obj[streamId][field] = JSON.parse(value);
1315
+ } catch {
1316
+ obj[streamId][field] = value;
1317
+ }
1318
+ }
1319
+ }
1320
+ }
1321
+ return obj;
1322
+ }
1323
+ var XRangeCommand = class extends Command {
1324
+ constructor([key, start, end, count], opts) {
1325
+ const command = ["XRANGE", key, start, end];
1326
+ if (typeof count === "number") {
1327
+ command.push("COUNT", count);
1328
+ }
1329
+ super(command, {
1330
+ deserialize: (result) => deserialize4(result),
1331
+ ...opts
1332
+ });
1333
+ }
1334
+ };
1335
+
1336
+ // pkg/commands/zadd.ts
1337
+ var ZAddCommand = class extends Command {
1338
+ constructor([key, arg1, ...arg2], opts) {
1339
+ const command = ["zadd", key];
1340
+ if ("nx" in arg1 && arg1.nx) {
1341
+ command.push("nx");
1342
+ } else if ("xx" in arg1 && arg1.xx) {
1343
+ command.push("xx");
1344
+ }
1345
+ if ("ch" in arg1 && arg1.ch) {
1346
+ command.push("ch");
1347
+ }
1348
+ if ("incr" in arg1 && arg1.incr) {
1349
+ command.push("incr");
1350
+ }
1351
+ if ("score" in arg1 && "member" in arg1) {
1352
+ command.push(arg1.score, arg1.member);
1353
+ }
1354
+ command.push(...arg2.flatMap(({ score, member }) => [score, member]));
1355
+ super(command, opts);
1356
+ }
1357
+ };
1358
+
1359
+ // pkg/commands/zcard.ts
1360
+ var ZCardCommand = class extends Command {
1361
+ constructor(cmd, opts) {
1362
+ super(["zcard", ...cmd], opts);
1363
+ }
1364
+ };
1365
+
1366
+ // pkg/commands/zcount.ts
1367
+ var ZCountCommand = class extends Command {
1368
+ constructor(cmd, opts) {
1369
+ super(["zcount", ...cmd], opts);
1370
+ }
1371
+ };
1372
+
1373
+ // pkg/commands/zincrby.ts
1374
+ var ZIncrByCommand = class extends Command {
1375
+ constructor(cmd, opts) {
1376
+ super(["zincrby", ...cmd], opts);
1377
+ }
1378
+ };
1379
+
1380
+ // pkg/commands/zinterstore.ts
1381
+ var ZInterStoreCommand = class extends Command {
1382
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
1383
+ const command = ["zinterstore", destination, numKeys];
1384
+ if (Array.isArray(keyOrKeys)) {
1385
+ command.push(...keyOrKeys);
1386
+ } else {
1387
+ command.push(keyOrKeys);
1388
+ }
1389
+ if (opts) {
1390
+ if ("weights" in opts && opts.weights) {
1391
+ command.push("weights", ...opts.weights);
1392
+ } else if ("weight" in opts && typeof opts.weight === "number") {
1393
+ command.push("weights", opts.weight);
1394
+ }
1395
+ if ("aggregate" in opts) {
1396
+ command.push("aggregate", opts.aggregate);
1397
+ }
1398
+ }
1399
+ super(command, cmdOpts);
1400
+ }
1401
+ };
1402
+
1403
+ // pkg/commands/zlexcount.ts
1404
+ var ZLexCountCommand = class extends Command {
1405
+ constructor(cmd, opts) {
1406
+ super(["zlexcount", ...cmd], opts);
1407
+ }
1408
+ };
1409
+
1410
+ // pkg/commands/zpopmax.ts
1411
+ var ZPopMaxCommand = class extends Command {
1412
+ constructor([key, count], opts) {
1413
+ const command = ["zpopmax", key];
1414
+ if (typeof count === "number") {
1415
+ command.push(count);
1416
+ }
1417
+ super(command, opts);
1418
+ }
1419
+ };
1420
+
1421
+ // pkg/commands/zpopmin.ts
1422
+ var ZPopMinCommand = class extends Command {
1423
+ constructor([key, count], opts) {
1424
+ const command = ["zpopmin", key];
1425
+ if (typeof count === "number") {
1426
+ command.push(count);
1427
+ }
1428
+ super(command, opts);
1429
+ }
1430
+ };
1431
+
1432
+ // pkg/commands/zrange.ts
1433
+ var ZRangeCommand = class extends Command {
1434
+ constructor([key, min, max, opts], cmdOpts) {
1435
+ const command = ["zrange", key, min, max];
1436
+ if (opts?.byScore) {
1437
+ command.push("byscore");
1438
+ }
1439
+ if (opts?.byLex) {
1440
+ command.push("bylex");
1441
+ }
1442
+ if (opts?.rev) {
1443
+ command.push("rev");
1444
+ }
1445
+ if (typeof opts?.count !== "undefined" && typeof opts?.offset !== "undefined") {
1446
+ command.push("limit", opts.offset, opts.count);
1447
+ }
1448
+ if (opts?.withScores) {
1449
+ command.push("withscores");
1450
+ }
1451
+ super(command, cmdOpts);
1452
+ }
1453
+ };
1454
+
1455
+ // pkg/commands/zrank.ts
1456
+ var ZRankCommand = class extends Command {
1457
+ constructor(cmd, opts) {
1458
+ super(["zrank", ...cmd], opts);
1459
+ }
1460
+ };
1461
+
1462
+ // pkg/commands/zrem.ts
1463
+ var ZRemCommand = class extends Command {
1464
+ constructor(cmd, opts) {
1465
+ super(["zrem", ...cmd], opts);
1466
+ }
1467
+ };
1468
+
1469
+ // pkg/commands/zremrangebylex.ts
1470
+ var ZRemRangeByLexCommand = class extends Command {
1471
+ constructor(cmd, opts) {
1472
+ super(["zremrangebylex", ...cmd], opts);
1473
+ }
1474
+ };
1475
+
1476
+ // pkg/commands/zremrangebyrank.ts
1477
+ var ZRemRangeByRankCommand = class extends Command {
1478
+ constructor(cmd, opts) {
1479
+ super(["zremrangebyrank", ...cmd], opts);
1480
+ }
1481
+ };
1482
+
1483
+ // pkg/commands/zremrangebyscore.ts
1484
+ var ZRemRangeByScoreCommand = class extends Command {
1485
+ constructor(cmd, opts) {
1486
+ super(["zremrangebyscore", ...cmd], opts);
1487
+ }
1488
+ };
1489
+
1490
+ // pkg/commands/zrevrank.ts
1491
+ var ZRevRankCommand = class extends Command {
1492
+ constructor(cmd, opts) {
1493
+ super(["zrevrank", ...cmd], opts);
1494
+ }
1495
+ };
1496
+
1497
+ // pkg/commands/zscan.ts
1498
+ var ZScanCommand = class extends Command {
1499
+ constructor([key, cursor, opts], cmdOpts) {
1500
+ const command = ["zscan", key, cursor];
1501
+ if (opts?.match) {
1502
+ command.push("match", opts.match);
1503
+ }
1504
+ if (typeof opts?.count === "number") {
1505
+ command.push("count", opts.count);
1506
+ }
1507
+ super(command, cmdOpts);
1508
+ }
1509
+ };
1510
+
1511
+ // pkg/commands/zscore.ts
1512
+ var ZScoreCommand = class extends Command {
1513
+ constructor(cmd, opts) {
1514
+ super(["zscore", ...cmd], opts);
1515
+ }
1516
+ };
1517
+
1518
+ // pkg/commands/zunion.ts
1519
+ var ZUnionCommand = class extends Command {
1520
+ constructor([numKeys, keyOrKeys, opts], cmdOpts) {
1521
+ const command = ["zunion", numKeys];
1522
+ if (Array.isArray(keyOrKeys)) {
1523
+ command.push(...keyOrKeys);
1524
+ } else {
1525
+ command.push(keyOrKeys);
1526
+ }
1527
+ if (opts) {
1528
+ if ("weights" in opts && opts.weights) {
1529
+ command.push("weights", ...opts.weights);
1530
+ } else if ("weight" in opts && typeof opts.weight === "number") {
1531
+ command.push("weights", opts.weight);
1532
+ }
1533
+ if ("aggregate" in opts) {
1534
+ command.push("aggregate", opts.aggregate);
1535
+ }
1536
+ if (opts?.withScores) {
1537
+ command.push("withscores");
1538
+ }
1539
+ }
1540
+ super(command, cmdOpts);
1541
+ }
1542
+ };
1543
+
1544
+ // pkg/commands/zunionstore.ts
1545
+ var ZUnionStoreCommand = class extends Command {
1546
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
1547
+ const command = ["zunionstore", destination, numKeys];
1548
+ if (Array.isArray(keyOrKeys)) {
1549
+ command.push(...keyOrKeys);
1550
+ } else {
1551
+ command.push(keyOrKeys);
1552
+ }
1553
+ if (opts) {
1554
+ if ("weights" in opts && opts.weights) {
1555
+ command.push("weights", ...opts.weights);
1556
+ } else if ("weight" in opts && typeof opts.weight === "number") {
1557
+ command.push("weights", opts.weight);
1558
+ }
1559
+ if ("aggregate" in opts) {
1560
+ command.push("aggregate", opts.aggregate);
1561
+ }
1562
+ }
1563
+ super(command, cmdOpts);
1564
+ }
1565
+ };
1566
+
1567
+ // pkg/commands/zdiffstore.ts
1568
+ var ZDiffStoreCommand = class extends Command {
1569
+ constructor(cmd, opts) {
1570
+ super(["zdiffstore", ...cmd], opts);
1571
+ }
1572
+ };
1573
+
1574
+ // pkg/commands/zmscore.ts
1575
+ var ZMScoreCommand = class extends Command {
1576
+ constructor(cmd, opts) {
1577
+ const [key, members] = cmd;
1578
+ super(["zmscore", key, ...members], opts);
1579
+ }
1580
+ };
1581
+
1582
+ // pkg/pipeline.ts
1583
+ var Pipeline = class {
1584
+ client;
1585
+ commands;
1586
+ commandOptions;
1587
+ multiExec;
1588
+ constructor(opts) {
1589
+ this.client = opts.client;
1590
+ this.commands = [];
1591
+ this.commandOptions = opts.commandOptions;
1592
+ this.multiExec = opts.multiExec ?? false;
1593
+ }
1594
+ /**
1595
+ * Send the pipeline request to upstash.
1596
+ *
1597
+ * Returns an array with the results of all pipelined commands.
1598
+ *
1599
+ * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
1600
+ * ```ts
1601
+ * const p = redis.pipeline()
1602
+ * p.get("key")
1603
+ * const result = p.exec<[{ greeting: string }]>()
1604
+ * ```
1605
+ */
1606
+ exec = async () => {
1607
+ if (this.commands.length === 0) {
1608
+ throw new Error("Pipeline is empty");
1609
+ }
1610
+ const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
1611
+ const res = await this.client.request({
1612
+ path,
1613
+ body: Object.values(this.commands).map((c) => c.command)
1614
+ });
1615
+ return res.map(({ error, result }, i) => {
1616
+ if (error) {
1617
+ throw new UpstashError(
1618
+ `Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
1619
+ );
1620
+ }
1621
+ return this.commands[i].deserialize(result);
1622
+ });
1623
+ };
1624
+ /**
1625
+ * Returns the length of pipeline before the execution
1626
+ */
1627
+ length() {
1628
+ return this.commands.length;
1629
+ }
1630
+ /**
1631
+ * Pushes a command into the pipeline and returns a chainable instance of the
1632
+ * pipeline
1633
+ */
1634
+ chain(command) {
1635
+ this.commands.push(command);
1636
+ return this;
1637
+ }
1638
+ /**
1639
+ * @see https://redis.io/commands/append
1640
+ */
1641
+ append = (...args) => this.chain(new AppendCommand(args, this.commandOptions));
1642
+ /**
1643
+ * @see https://redis.io/commands/bitcount
1644
+ */
1645
+ bitcount = (...args) => this.chain(new BitCountCommand(args, this.commandOptions));
1646
+ /**
1647
+ * @see https://redis.io/commands/bitop
1648
+ */
1649
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => this.chain(
1650
+ new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.commandOptions)
1651
+ );
1652
+ /**
1653
+ * @see https://redis.io/commands/bitpos
1654
+ */
1655
+ bitpos = (...args) => this.chain(new BitPosCommand(args, this.commandOptions));
1656
+ /**
1657
+ * @see https://redis.io/commands/zdiffstore
1658
+ */
1659
+ zdiffstore = (...args) => this.chain(new ZDiffStoreCommand(args, this.commandOptions));
1660
+ /**
1661
+ * @see https://redis.io/commands/dbsize
1662
+ */
1663
+ dbsize = () => this.chain(new DBSizeCommand(this.commandOptions));
1664
+ /**
1665
+ * @see https://redis.io/commands/decr
1666
+ */
1667
+ decr = (...args) => this.chain(new DecrCommand(args, this.commandOptions));
1668
+ /**
1669
+ * @see https://redis.io/commands/decrby
1670
+ */
1671
+ decrby = (...args) => this.chain(new DecrByCommand(args, this.commandOptions));
1672
+ /**
1673
+ * @see https://redis.io/commands/del
1674
+ */
1675
+ del = (...args) => this.chain(new DelCommand(args, this.commandOptions));
1676
+ /**
1677
+ * @see https://redis.io/commands/echo
1678
+ */
1679
+ echo = (...args) => this.chain(new EchoCommand(args, this.commandOptions));
1680
+ /**
1681
+ * @see https://redis.io/commands/eval
1682
+ */
1683
+ eval = (...args) => this.chain(new EvalCommand(args, this.commandOptions));
1684
+ /**
1685
+ * @see https://redis.io/commands/evalsha
1686
+ */
1687
+ evalsha = (...args) => this.chain(new EvalshaCommand(args, this.commandOptions));
1688
+ /**
1689
+ * @see https://redis.io/commands/exists
1690
+ */
1691
+ exists = (...args) => this.chain(new ExistsCommand(args, this.commandOptions));
1692
+ /**
1693
+ * @see https://redis.io/commands/expire
1694
+ */
1695
+ expire = (...args) => this.chain(new ExpireCommand(args, this.commandOptions));
1696
+ /**
1697
+ * @see https://redis.io/commands/expireat
1698
+ */
1699
+ expireat = (...args) => this.chain(new ExpireAtCommand(args, this.commandOptions));
1700
+ /**
1701
+ * @see https://redis.io/commands/flushall
1702
+ */
1703
+ flushall = (args) => this.chain(new FlushAllCommand(args, this.commandOptions));
1704
+ /**
1705
+ * @see https://redis.io/commands/flushdb
1706
+ */
1707
+ flushdb = (...args) => this.chain(new FlushDBCommand(args, this.commandOptions));
1708
+ /**
1709
+ * @see https://redis.io/commands/get
1710
+ */
1711
+ get = (...args) => this.chain(new GetCommand(args, this.commandOptions));
1712
+ /**
1713
+ * @see https://redis.io/commands/getbit
1714
+ */
1715
+ getbit = (...args) => this.chain(new GetBitCommand(args, this.commandOptions));
1716
+ /**
1717
+ * @see https://redis.io/commands/getdel
1718
+ */
1719
+ getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
1720
+ /**
1721
+ * @see https://redis.io/commands/getrange
1722
+ */
1723
+ getrange = (...args) => this.chain(new GetRangeCommand(args, this.commandOptions));
1724
+ /**
1725
+ * @see https://redis.io/commands/getset
1726
+ */
1727
+ getset = (key, value) => this.chain(new GetSetCommand([key, value], this.commandOptions));
1728
+ /**
1729
+ * @see https://redis.io/commands/hdel
1730
+ */
1731
+ hdel = (...args) => this.chain(new HDelCommand(args, this.commandOptions));
1732
+ /**
1733
+ * @see https://redis.io/commands/hexists
1734
+ */
1735
+ hexists = (...args) => this.chain(new HExistsCommand(args, this.commandOptions));
1736
+ /**
1737
+ * @see https://redis.io/commands/hget
1738
+ */
1739
+ hget = (...args) => this.chain(new HGetCommand(args, this.commandOptions));
1740
+ /**
1741
+ * @see https://redis.io/commands/hgetall
1742
+ */
1743
+ hgetall = (...args) => this.chain(new HGetAllCommand(args, this.commandOptions));
1744
+ /**
1745
+ * @see https://redis.io/commands/hincrby
1746
+ */
1747
+ hincrby = (...args) => this.chain(new HIncrByCommand(args, this.commandOptions));
1748
+ /**
1749
+ * @see https://redis.io/commands/hincrbyfloat
1750
+ */
1751
+ hincrbyfloat = (...args) => this.chain(new HIncrByFloatCommand(args, this.commandOptions));
1752
+ /**
1753
+ * @see https://redis.io/commands/hkeys
1754
+ */
1755
+ hkeys = (...args) => this.chain(new HKeysCommand(args, this.commandOptions));
1756
+ /**
1757
+ * @see https://redis.io/commands/hlen
1758
+ */
1759
+ hlen = (...args) => this.chain(new HLenCommand(args, this.commandOptions));
1760
+ /**
1761
+ * @see https://redis.io/commands/hmget
1762
+ */
1763
+ hmget = (...args) => this.chain(new HMGetCommand(args, this.commandOptions));
1764
+ /**
1765
+ * @see https://redis.io/commands/hmset
1766
+ */
1767
+ hmset = (key, kv) => this.chain(new HMSetCommand([key, kv], this.commandOptions));
1768
+ /**
1769
+ * @see https://redis.io/commands/hrandfield
1770
+ */
1771
+ hrandfield = (key, count, withValues) => this.chain(new HRandFieldCommand([key, count, withValues], this.commandOptions));
1772
+ /**
1773
+ * @see https://redis.io/commands/hscan
1774
+ */
1775
+ hscan = (...args) => this.chain(new HScanCommand(args, this.commandOptions));
1776
+ /**
1777
+ * @see https://redis.io/commands/hset
1778
+ */
1779
+ hset = (key, kv) => this.chain(new HSetCommand([key, kv], this.commandOptions));
1780
+ /**
1781
+ * @see https://redis.io/commands/hsetnx
1782
+ */
1783
+ hsetnx = (key, field, value) => this.chain(new HSetNXCommand([key, field, value], this.commandOptions));
1784
+ /**
1785
+ * @see https://redis.io/commands/hstrlen
1786
+ */
1787
+ hstrlen = (...args) => this.chain(new HStrLenCommand(args, this.commandOptions));
1788
+ /**
1789
+ * @see https://redis.io/commands/hvals
1790
+ */
1791
+ hvals = (...args) => this.chain(new HValsCommand(args, this.commandOptions));
1792
+ /**
1793
+ * @see https://redis.io/commands/incr
1794
+ */
1795
+ incr = (...args) => this.chain(new IncrCommand(args, this.commandOptions));
1796
+ /**
1797
+ * @see https://redis.io/commands/incrby
1798
+ */
1799
+ incrby = (...args) => this.chain(new IncrByCommand(args, this.commandOptions));
1800
+ /**
1801
+ * @see https://redis.io/commands/incrbyfloat
1802
+ */
1803
+ incrbyfloat = (...args) => this.chain(new IncrByFloatCommand(args, this.commandOptions));
1804
+ /**
1805
+ * @see https://redis.io/commands/keys
1806
+ */
1807
+ keys = (...args) => this.chain(new KeysCommand(args, this.commandOptions));
1808
+ /**
1809
+ * @see https://redis.io/commands/lindex
1810
+ */
1811
+ lindex = (...args) => this.chain(new LIndexCommand(args, this.commandOptions));
1812
+ /**
1813
+ * @see https://redis.io/commands/linsert
1814
+ */
1815
+ linsert = (key, direction, pivot, value) => this.chain(new LInsertCommand([key, direction, pivot, value], this.commandOptions));
1816
+ /**
1817
+ * @see https://redis.io/commands/llen
1818
+ */
1819
+ llen = (...args) => this.chain(new LLenCommand(args, this.commandOptions));
1820
+ /**
1821
+ * @see https://redis.io/commands/lmove
1822
+ */
1823
+ lmove = (...args) => this.chain(new LMoveCommand(args, this.commandOptions));
1824
+ /**
1825
+ * @see https://redis.io/commands/lpop
1826
+ */
1827
+ lpop = (...args) => this.chain(new LPopCommand(args, this.commandOptions));
1828
+ /**
1829
+ * @see https://redis.io/commands/lpos
1830
+ */
1831
+ lpos = (...args) => this.chain(new LPosCommand(args, this.commandOptions));
1832
+ /**
1833
+ * @see https://redis.io/commands/lpush
1834
+ */
1835
+ lpush = (key, ...elements) => this.chain(new LPushCommand([key, ...elements], this.commandOptions));
1836
+ /**
1837
+ * @see https://redis.io/commands/lpushx
1838
+ */
1839
+ lpushx = (key, ...elements) => this.chain(new LPushXCommand([key, ...elements], this.commandOptions));
1840
+ /**
1841
+ * @see https://redis.io/commands/lrange
1842
+ */
1843
+ lrange = (...args) => this.chain(new LRangeCommand(args, this.commandOptions));
1844
+ /**
1845
+ * @see https://redis.io/commands/lrem
1846
+ */
1847
+ lrem = (key, count, value) => this.chain(new LRemCommand([key, count, value], this.commandOptions));
1848
+ /**
1849
+ * @see https://redis.io/commands/lset
1850
+ */
1851
+ lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
1852
+ /**
1853
+ * @see https://redis.io/commands/ltrim
1854
+ */
1855
+ ltrim = (...args) => this.chain(new LTrimCommand(args, this.commandOptions));
1856
+ /**
1857
+ * @see https://redis.io/commands/mget
1858
+ */
1859
+ mget = (...args) => this.chain(new MGetCommand(args, this.commandOptions));
1860
+ /**
1861
+ * @see https://redis.io/commands/mset
1862
+ */
1863
+ mset = (kv) => this.chain(new MSetCommand([kv], this.commandOptions));
1864
+ /**
1865
+ * @see https://redis.io/commands/msetnx
1866
+ */
1867
+ msetnx = (kv) => this.chain(new MSetNXCommand([kv], this.commandOptions));
1868
+ /**
1869
+ * @see https://redis.io/commands/persist
1870
+ */
1871
+ persist = (...args) => this.chain(new PersistCommand(args, this.commandOptions));
1872
+ /**
1873
+ * @see https://redis.io/commands/pexpire
1874
+ */
1875
+ pexpire = (...args) => this.chain(new PExpireCommand(args, this.commandOptions));
1876
+ /**
1877
+ * @see https://redis.io/commands/pexpireat
1878
+ */
1879
+ pexpireat = (...args) => this.chain(new PExpireAtCommand(args, this.commandOptions));
1880
+ /**
1881
+ * @see https://redis.io/commands/ping
1882
+ */
1883
+ ping = (args) => this.chain(new PingCommand(args, this.commandOptions));
1884
+ /**
1885
+ * @see https://redis.io/commands/psetex
1886
+ */
1887
+ psetex = (key, ttl, value) => this.chain(new PSetEXCommand([key, ttl, value], this.commandOptions));
1888
+ /**
1889
+ * @see https://redis.io/commands/pttl
1890
+ */
1891
+ pttl = (...args) => this.chain(new PTtlCommand(args, this.commandOptions));
1892
+ /**
1893
+ * @see https://redis.io/commands/publish
1894
+ */
1895
+ publish = (...args) => this.chain(new PublishCommand(args, this.commandOptions));
1896
+ /**
1897
+ * @see https://redis.io/commands/randomkey
1898
+ */
1899
+ randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions));
1900
+ /**
1901
+ * @see https://redis.io/commands/rename
1902
+ */
1903
+ rename = (...args) => this.chain(new RenameCommand(args, this.commandOptions));
1904
+ /**
1905
+ * @see https://redis.io/commands/renamenx
1906
+ */
1907
+ renamenx = (...args) => this.chain(new RenameNXCommand(args, this.commandOptions));
1908
+ /**
1909
+ * @see https://redis.io/commands/rpop
1910
+ */
1911
+ rpop = (...args) => this.chain(new RPopCommand(args, this.commandOptions));
1912
+ /**
1913
+ * @see https://redis.io/commands/rpush
1914
+ */
1915
+ rpush = (key, ...elements) => this.chain(new RPushCommand([key, ...elements], this.commandOptions));
1916
+ /**
1917
+ * @see https://redis.io/commands/rpushx
1918
+ */
1919
+ rpushx = (key, ...elements) => this.chain(new RPushXCommand([key, ...elements], this.commandOptions));
1920
+ /**
1921
+ * @see https://redis.io/commands/sadd
1922
+ */
1923
+ sadd = (key, ...members) => this.chain(new SAddCommand([key, ...members], this.commandOptions));
1924
+ /**
1925
+ * @see https://redis.io/commands/scan
1926
+ */
1927
+ scan = (...args) => this.chain(new ScanCommand(args, this.commandOptions));
1928
+ /**
1929
+ * @see https://redis.io/commands/scard
1930
+ */
1931
+ scard = (...args) => this.chain(new SCardCommand(args, this.commandOptions));
1932
+ /**
1933
+ * @see https://redis.io/commands/script-exists
1934
+ */
1935
+ scriptExists = (...args) => this.chain(new ScriptExistsCommand(args, this.commandOptions));
1936
+ /**
1937
+ * @see https://redis.io/commands/script-flush
1938
+ */
1939
+ scriptFlush = (...args) => this.chain(new ScriptFlushCommand(args, this.commandOptions));
1940
+ /**
1941
+ * @see https://redis.io/commands/script-load
1942
+ */
1943
+ scriptLoad = (...args) => this.chain(new ScriptLoadCommand(args, this.commandOptions));
1944
+ /*)*
1945
+ * @see https://redis.io/commands/sdiff
1946
+ */
1947
+ sdiff = (...args) => this.chain(new SDiffCommand(args, this.commandOptions));
1948
+ /**
1949
+ * @see https://redis.io/commands/sdiffstore
1950
+ */
1951
+ sdiffstore = (...args) => this.chain(new SDiffStoreCommand(args, this.commandOptions));
1952
+ /**
1953
+ * @see https://redis.io/commands/set
1954
+ */
1955
+ set = (key, value, opts) => this.chain(new SetCommand([key, value, opts], this.commandOptions));
1956
+ /**
1957
+ * @see https://redis.io/commands/setbit
1958
+ */
1959
+ setbit = (...args) => this.chain(new SetBitCommand(args, this.commandOptions));
1960
+ /**
1961
+ * @see https://redis.io/commands/setex
1962
+ */
1963
+ setex = (key, ttl, value) => this.chain(new SetExCommand([key, ttl, value], this.commandOptions));
1964
+ /**
1965
+ * @see https://redis.io/commands/setnx
1966
+ */
1967
+ setnx = (key, value) => this.chain(new SetNxCommand([key, value], this.commandOptions));
1968
+ /**
1969
+ * @see https://redis.io/commands/setrange
1970
+ */
1971
+ setrange = (...args) => this.chain(new SetRangeCommand(args, this.commandOptions));
1972
+ /**
1973
+ * @see https://redis.io/commands/sinter
1974
+ */
1975
+ sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
1976
+ /**
1977
+ * @see https://redis.io/commands/sinterstore
1978
+ */
1979
+ sinterstore = (...args) => this.chain(new SInterStoreCommand(args, this.commandOptions));
1980
+ /**
1981
+ * @see https://redis.io/commands/sismember
1982
+ */
1983
+ sismember = (key, member) => this.chain(new SIsMemberCommand([key, member], this.commandOptions));
1984
+ /**
1985
+ * @see https://redis.io/commands/smembers
1986
+ */
1987
+ smembers = (...args) => this.chain(new SMembersCommand(args, this.commandOptions));
1988
+ /**
1989
+ * @see https://redis.io/commands/smismember
1990
+ */
1991
+ smismember = (key, members) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions));
1992
+ /**
1993
+ * @see https://redis.io/commands/smove
1994
+ */
1995
+ smove = (source, destination, member) => this.chain(new SMoveCommand([source, destination, member], this.commandOptions));
1996
+ /**
1997
+ * @see https://redis.io/commands/spop
1998
+ */
1999
+ spop = (...args) => this.chain(new SPopCommand(args, this.commandOptions));
2000
+ /**
2001
+ * @see https://redis.io/commands/srandmember
2002
+ */
2003
+ srandmember = (...args) => this.chain(new SRandMemberCommand(args, this.commandOptions));
2004
+ /**
2005
+ * @see https://redis.io/commands/srem
2006
+ */
2007
+ srem = (key, ...members) => this.chain(new SRemCommand([key, ...members], this.commandOptions));
2008
+ /**
2009
+ * @see https://redis.io/commands/sscan
2010
+ */
2011
+ sscan = (...args) => this.chain(new SScanCommand(args, this.commandOptions));
2012
+ /**
2013
+ * @see https://redis.io/commands/strlen
2014
+ */
2015
+ strlen = (...args) => this.chain(new StrLenCommand(args, this.commandOptions));
2016
+ /**
2017
+ * @see https://redis.io/commands/sunion
2018
+ */
2019
+ sunion = (...args) => this.chain(new SUnionCommand(args, this.commandOptions));
2020
+ /**
2021
+ * @see https://redis.io/commands/sunionstore
2022
+ */
2023
+ sunionstore = (...args) => this.chain(new SUnionStoreCommand(args, this.commandOptions));
2024
+ /**
2025
+ * @see https://redis.io/commands/time
2026
+ */
2027
+ time = () => this.chain(new TimeCommand(this.commandOptions));
2028
+ /**
2029
+ * @see https://redis.io/commands/touch
2030
+ */
2031
+ touch = (...args) => this.chain(new TouchCommand(args, this.commandOptions));
2032
+ /**
2033
+ * @see https://redis.io/commands/ttl
2034
+ */
2035
+ ttl = (...args) => this.chain(new TtlCommand(args, this.commandOptions));
2036
+ /**
2037
+ * @see https://redis.io/commands/type
2038
+ */
2039
+ type = (...args) => this.chain(new TypeCommand(args, this.commandOptions));
2040
+ /**
2041
+ * @see https://redis.io/commands/unlink
2042
+ */
2043
+ unlink = (...args) => this.chain(new UnlinkCommand(args, this.commandOptions));
2044
+ /**
2045
+ * @see https://redis.io/commands/zadd
2046
+ */
2047
+ zadd = (...args) => {
2048
+ if ("score" in args[1]) {
2049
+ return this.chain(
2050
+ new ZAddCommand(
2051
+ [args[0], args[1], ...args.slice(2)],
2052
+ this.commandOptions
2053
+ )
2054
+ );
2055
+ }
2056
+ return this.chain(
2057
+ new ZAddCommand(
2058
+ [args[0], args[1], ...args.slice(2)],
2059
+ this.commandOptions
2060
+ )
2061
+ );
2062
+ };
2063
+ /**
2064
+ * @see https://redis.io/commands/zcard
2065
+ */
2066
+ zcard = (...args) => this.chain(new ZCardCommand(args, this.commandOptions));
2067
+ /**
2068
+ * @see https://redis.io/commands/zcount
2069
+ */
2070
+ zcount = (...args) => this.chain(new ZCountCommand(args, this.commandOptions));
2071
+ /**
2072
+ * @see https://redis.io/commands/zincrby
2073
+ */
2074
+ zincrby = (key, increment, member) => this.chain(new ZIncrByCommand([key, increment, member], this.commandOptions));
2075
+ /**
2076
+ * @see https://redis.io/commands/zinterstore
2077
+ */
2078
+ zinterstore = (...args) => this.chain(new ZInterStoreCommand(args, this.commandOptions));
2079
+ /**
2080
+ * @see https://redis.io/commands/zlexcount
2081
+ */
2082
+ zlexcount = (...args) => this.chain(new ZLexCountCommand(args, this.commandOptions));
2083
+ /**
2084
+ * @see https://redis.io/commands/zmscore
2085
+ */
2086
+ zmscore = (...args) => this.chain(new ZMScoreCommand(args, this.commandOptions));
2087
+ /**
2088
+ * @see https://redis.io/commands/zpopmax
2089
+ */
2090
+ zpopmax = (...args) => this.chain(new ZPopMaxCommand(args, this.commandOptions));
2091
+ /**
2092
+ * @see https://redis.io/commands/zpopmin
2093
+ */
2094
+ zpopmin = (...args) => this.chain(new ZPopMinCommand(args, this.commandOptions));
2095
+ /**
2096
+ * @see https://redis.io/commands/zrange
2097
+ */
2098
+ zrange = (...args) => this.chain(new ZRangeCommand(args, this.commandOptions));
2099
+ /**
2100
+ * @see https://redis.io/commands/zrank
2101
+ */
2102
+ zrank = (key, member) => this.chain(new ZRankCommand([key, member], this.commandOptions));
2103
+ /**
2104
+ * @see https://redis.io/commands/zrem
2105
+ */
2106
+ zrem = (key, ...members) => this.chain(new ZRemCommand([key, ...members], this.commandOptions));
2107
+ /**
2108
+ * @see https://redis.io/commands/zremrangebylex
2109
+ */
2110
+ zremrangebylex = (...args) => this.chain(new ZRemRangeByLexCommand(args, this.commandOptions));
2111
+ /**
2112
+ * @see https://redis.io/commands/zremrangebyrank
2113
+ */
2114
+ zremrangebyrank = (...args) => this.chain(new ZRemRangeByRankCommand(args, this.commandOptions));
2115
+ /**
2116
+ * @see https://redis.io/commands/zremrangebyscore
2117
+ */
2118
+ zremrangebyscore = (...args) => this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions));
2119
+ /**
2120
+ * @see https://redis.io/commands/zrevrank
2121
+ */
2122
+ zrevrank = (key, member) => this.chain(new ZRevRankCommand([key, member], this.commandOptions));
2123
+ /**
2124
+ * @see https://redis.io/commands/zscan
2125
+ */
2126
+ zscan = (...args) => this.chain(new ZScanCommand(args, this.commandOptions));
2127
+ /**
2128
+ * @see https://redis.io/commands/zscore
2129
+ */
2130
+ zscore = (key, member) => this.chain(new ZScoreCommand([key, member], this.commandOptions));
2131
+ /**
2132
+ * @see https://redis.io/commands/zunionstore
2133
+ */
2134
+ zunionstore = (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions));
2135
+ /**
2136
+ * @see https://redis.io/commands/zunion
2137
+ */
2138
+ zunion = (...args) => this.chain(new ZUnionCommand(args, this.commandOptions));
2139
+ /**
2140
+ * @see https://redis.io/commands/?group=json
2141
+ */
2142
+ get json() {
2143
+ return {
2144
+ /**
2145
+ * @see https://redis.io/commands/json.arrappend
2146
+ */
2147
+ arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
2148
+ /**
2149
+ * @see https://redis.io/commands/json.arrindex
2150
+ */
2151
+ arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
2152
+ /**
2153
+ * @see https://redis.io/commands/json.arrinsert
2154
+ */
2155
+ arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
2156
+ /**
2157
+ * @see https://redis.io/commands/json.arrlen
2158
+ */
2159
+ arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
2160
+ /**
2161
+ * @see https://redis.io/commands/json.arrpop
2162
+ */
2163
+ arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
2164
+ /**
2165
+ * @see https://redis.io/commands/json.arrtrim
2166
+ */
2167
+ arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
2168
+ /**
2169
+ * @see https://redis.io/commands/json.clear
2170
+ */
2171
+ clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
2172
+ /**
2173
+ * @see https://redis.io/commands/json.del
2174
+ */
2175
+ del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
2176
+ /**
2177
+ * @see https://redis.io/commands/json.forget
2178
+ */
2179
+ forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
2180
+ /**
2181
+ * @see https://redis.io/commands/geoadd
2182
+ */
2183
+ geoadd: (...args) => new GeoAddCommand(args, this.commandOptions).exec(this.client),
2184
+ /**
2185
+ * @see https://redis.io/commands/geodist
2186
+ */
2187
+ geodist: (...args) => new GeoDistCommand(args, this.commandOptions).exec(this.client),
2188
+ /**
2189
+ * @see https://redis.io/commands/json.get
2190
+ */
2191
+ get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
2192
+ /**
2193
+ * @see https://redis.io/commands/json.mget
2194
+ */
2195
+ mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
2196
+ /**
2197
+ * @see https://redis.io/commands/json.numincrby
2198
+ */
2199
+ numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
2200
+ /**
2201
+ * @see https://redis.io/commands/json.nummultby
2202
+ */
2203
+ nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
2204
+ /**
2205
+ * @see https://redis.io/commands/json.objkeys
2206
+ */
2207
+ objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
2208
+ /**
2209
+ * @see https://redis.io/commands/json.objlen
2210
+ */
2211
+ objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
2212
+ /**
2213
+ * @see https://redis.io/commands/json.resp
2214
+ */
2215
+ resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
2216
+ /**
2217
+ * @see https://redis.io/commands/json.set
2218
+ */
2219
+ set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
2220
+ /**
2221
+ * @see https://redis.io/commands/json.strappend
2222
+ */
2223
+ strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
2224
+ /**
2225
+ * @see https://redis.io/commands/json.strlen
2226
+ */
2227
+ strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
2228
+ /**
2229
+ * @see https://redis.io/commands/json.toggle
2230
+ */
2231
+ toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
2232
+ /**
2233
+ * @see https://redis.io/commands/json.type
2234
+ */
2235
+ type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
2236
+ };
2237
+ }
2238
+ };
2239
+
2240
+ // pkg/script.ts
2241
+ import Hex from "crypto-js/enc-hex";
2242
+ import sha1 from "crypto-js/sha1";
2243
+ var Script = class {
2244
+ script;
2245
+ sha1;
2246
+ redis;
2247
+ constructor(redis, script) {
2248
+ this.redis = redis;
2249
+ this.sha1 = this.digest(script);
2250
+ this.script = script;
2251
+ }
2252
+ /**
2253
+ * Send an `EVAL` command to redis.
2254
+ */
2255
+ async eval(keys, args) {
2256
+ return await this.redis.eval(this.script, keys, args);
2257
+ }
2258
+ /**
2259
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
2260
+ */
2261
+ async evalsha(keys, args) {
2262
+ return await this.redis.evalsha(this.sha1, keys, args);
2263
+ }
2264
+ /**
2265
+ * Optimistically try to run `EVALSHA` first.
2266
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
2267
+ *
2268
+ * Following calls will be able to use the cached script
2269
+ */
2270
+ async exec(keys, args) {
2271
+ const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (err) => {
2272
+ if (err instanceof Error && err.message.toLowerCase().includes("noscript")) {
2273
+ return await this.redis.eval(this.script, keys, args);
2274
+ }
2275
+ throw err;
2276
+ });
2277
+ return res;
2278
+ }
2279
+ /**
2280
+ * Compute the sha1 hash of the script and return its hex representation.
2281
+ */
2282
+ digest(s) {
2283
+ return Hex.stringify(sha1(s));
2284
+ }
2285
+ };
2286
+
2287
+ // pkg/redis.ts
2288
+ var Redis = class {
2289
+ client;
2290
+ opts;
2291
+ enableTelemetry;
2292
+ /**
2293
+ * Create a new redis client
2294
+ *
2295
+ * @example
2296
+ * ```typescript
2297
+ * const redis = new Redis({
2298
+ * url: "<UPSTASH_REDIS_REST_URL>",
2299
+ * token: "<UPSTASH_REDIS_REST_TOKEN>",
2300
+ * });
2301
+ * ```
2302
+ */
2303
+ constructor(client, opts) {
2304
+ this.client = client;
2305
+ this.opts = opts;
2306
+ this.enableTelemetry = opts?.enableTelemetry ?? true;
2307
+ }
2308
+ get json() {
2309
+ return {
2310
+ /**
2311
+ * @see https://redis.io/commands/json.arrappend
2312
+ */
2313
+ arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
2314
+ /**
2315
+ * @see https://redis.io/commands/json.arrindex
2316
+ */
2317
+ arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
2318
+ /**
2319
+ * @see https://redis.io/commands/json.arrinsert
2320
+ */
2321
+ arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
2322
+ /**
2323
+ * @see https://redis.io/commands/json.arrlen
2324
+ */
2325
+ arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
2326
+ /**
2327
+ * @see https://redis.io/commands/json.arrpop
2328
+ */
2329
+ arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
2330
+ /**
2331
+ * @see https://redis.io/commands/json.arrtrim
2332
+ */
2333
+ arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
2334
+ /**
2335
+ * @see https://redis.io/commands/json.clear
2336
+ */
2337
+ clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
2338
+ /**
2339
+ * @see https://redis.io/commands/json.del
2340
+ */
2341
+ del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
2342
+ /**
2343
+ * @see https://redis.io/commands/json.forget
2344
+ */
2345
+ forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
2346
+ /**
2347
+ * @see https://redis.io/commands/geoadd
2348
+ */
2349
+ geoadd: (...args) => new GeoAddCommand(args, this.opts).exec(this.client),
2350
+ /**
2351
+ * @see https://redis.io/commands/geodist
2352
+ */
2353
+ geodist: (...args) => new GeoDistCommand(args, this.opts).exec(this.client),
2354
+ /**
2355
+ * @see https://redis.io/commands/json.get
2356
+ */
2357
+ get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
2358
+ /**
2359
+ * @see https://redis.io/commands/json.mget
2360
+ */
2361
+ mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
2362
+ /**
2363
+ * @see https://redis.io/commands/json.numincrby
2364
+ */
2365
+ numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
2366
+ /**
2367
+ * @see https://redis.io/commands/json.nummultby
2368
+ */
2369
+ nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
2370
+ /**
2371
+ * @see https://redis.io/commands/json.objkeys
2372
+ */
2373
+ objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
2374
+ /**
2375
+ * @see https://redis.io/commands/json.objlen
2376
+ */
2377
+ objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
2378
+ /**
2379
+ * @see https://redis.io/commands/json.resp
2380
+ */
2381
+ resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
2382
+ /**
2383
+ * @see https://redis.io/commands/json.set
2384
+ */
2385
+ set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
2386
+ /**
2387
+ * @see https://redis.io/commands/json.strappend
2388
+ */
2389
+ strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
2390
+ /**
2391
+ * @see https://redis.io/commands/json.strlen
2392
+ */
2393
+ strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
2394
+ /**
2395
+ * @see https://redis.io/commands/json.toggle
2396
+ */
2397
+ toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
2398
+ /**
2399
+ * @see https://redis.io/commands/json.type
2400
+ */
2401
+ type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
2402
+ };
2403
+ }
2404
+ /**
2405
+ * Wrap a new middleware around the HTTP client.
2406
+ */
2407
+ use = (middleware) => {
2408
+ const makeRequest = this.client.request.bind(this.client);
2409
+ this.client.request = (req) => middleware(req, makeRequest);
2410
+ };
2411
+ /**
2412
+ * Technically this is not private, we can hide it from intellisense by doing this
2413
+ */
2414
+ addTelemetry = (telemetry) => {
2415
+ if (!this.enableTelemetry) {
2416
+ return;
2417
+ }
2418
+ try {
2419
+ this.client.mergeTelemetry(telemetry);
2420
+ } catch {
2421
+ }
2422
+ };
2423
+ createScript(script) {
2424
+ return new Script(this, script);
2425
+ }
2426
+ /**
2427
+ * Create a new pipeline that allows you to send requests in bulk.
2428
+ *
2429
+ * @see {@link Pipeline}
2430
+ */
2431
+ pipeline = () => new Pipeline({
2432
+ client: this.client,
2433
+ commandOptions: this.opts,
2434
+ multiExec: false
2435
+ });
2436
+ /**
2437
+ * Create a new transaction to allow executing multiple steps atomically.
2438
+ *
2439
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
2440
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
2441
+ * guarantees that the commands are executed as a single isolated operation.
2442
+ *
2443
+ * @see {@link Pipeline}
2444
+ */
2445
+ multi = () => new Pipeline({
2446
+ client: this.client,
2447
+ commandOptions: this.opts,
2448
+ multiExec: true
2449
+ });
2450
+ /**
2451
+ * @see https://redis.io/commands/append
2452
+ */
2453
+ append = (...args) => new AppendCommand(args, this.opts).exec(this.client);
2454
+ /**
2455
+ * @see https://redis.io/commands/bitcount
2456
+ */
2457
+ bitcount = (...args) => new BitCountCommand(args, this.opts).exec(this.client);
2458
+ /**
2459
+ * @see https://redis.io/commands/bitop
2460
+ */
2461
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.opts).exec(
2462
+ this.client
2463
+ );
2464
+ /**
2465
+ * @see https://redis.io/commands/bitpos
2466
+ */
2467
+ bitpos = (...args) => new BitPosCommand(args, this.opts).exec(this.client);
2468
+ /**
2469
+ * @see https://redis.io/commands/dbsize
2470
+ */
2471
+ dbsize = () => new DBSizeCommand(this.opts).exec(this.client);
2472
+ /**
2473
+ * @see https://redis.io/commands/decr
2474
+ */
2475
+ decr = (...args) => new DecrCommand(args, this.opts).exec(this.client);
2476
+ /**
2477
+ * @see https://redis.io/commands/decrby
2478
+ */
2479
+ decrby = (...args) => new DecrByCommand(args, this.opts).exec(this.client);
2480
+ /**
2481
+ * @see https://redis.io/commands/del
2482
+ */
2483
+ del = (...args) => new DelCommand(args, this.opts).exec(this.client);
2484
+ /**
2485
+ * @see https://redis.io/commands/echo
2486
+ */
2487
+ echo = (...args) => new EchoCommand(args, this.opts).exec(this.client);
2488
+ /**
2489
+ * @see https://redis.io/commands/eval
2490
+ */
2491
+ eval = (...args) => new EvalCommand(args, this.opts).exec(this.client);
2492
+ /**
2493
+ * @see https://redis.io/commands/evalsha
2494
+ */
2495
+ evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
2496
+ /**
2497
+ * @see https://redis.io/commands/exists
2498
+ */
2499
+ exists = (...args) => new ExistsCommand(args, this.opts).exec(this.client);
2500
+ /**
2501
+ * @see https://redis.io/commands/expire
2502
+ */
2503
+ expire = (...args) => new ExpireCommand(args, this.opts).exec(this.client);
2504
+ /**
2505
+ * @see https://redis.io/commands/expireat
2506
+ */
2507
+ expireat = (...args) => new ExpireAtCommand(args, this.opts).exec(this.client);
2508
+ /**
2509
+ * @see https://redis.io/commands/flushall
2510
+ */
2511
+ flushall = (args) => new FlushAllCommand(args, this.opts).exec(this.client);
2512
+ /**
2513
+ * @see https://redis.io/commands/flushdb
2514
+ */
2515
+ flushdb = (...args) => new FlushDBCommand(args, this.opts).exec(this.client);
2516
+ /**
2517
+ * @see https://redis.io/commands/get
2518
+ */
2519
+ get = (...args) => new GetCommand(args, this.opts).exec(this.client);
2520
+ /**
2521
+ * @see https://redis.io/commands/getbit
2522
+ */
2523
+ getbit = (...args) => new GetBitCommand(args, this.opts).exec(this.client);
2524
+ /**
2525
+ * @see https://redis.io/commands/getdel
2526
+ */
2527
+ getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
2528
+ /**
2529
+ * @see https://redis.io/commands/getrange
2530
+ */
2531
+ getrange = (...args) => new GetRangeCommand(args, this.opts).exec(this.client);
2532
+ /**
2533
+ * @see https://redis.io/commands/getset
2534
+ */
2535
+ getset = (key, value) => new GetSetCommand([key, value], this.opts).exec(this.client);
2536
+ /**
2537
+ * @see https://redis.io/commands/hdel
2538
+ */
2539
+ hdel = (...args) => new HDelCommand(args, this.opts).exec(this.client);
2540
+ /**
2541
+ * @see https://redis.io/commands/hexists
2542
+ */
2543
+ hexists = (...args) => new HExistsCommand(args, this.opts).exec(this.client);
2544
+ /**
2545
+ * @see https://redis.io/commands/hget
2546
+ */
2547
+ hget = (...args) => new HGetCommand(args, this.opts).exec(this.client);
2548
+ /**
2549
+ * @see https://redis.io/commands/hgetall
2550
+ */
2551
+ hgetall = (...args) => new HGetAllCommand(args, this.opts).exec(this.client);
2552
+ /**
2553
+ * @see https://redis.io/commands/hincrby
2554
+ */
2555
+ hincrby = (...args) => new HIncrByCommand(args, this.opts).exec(this.client);
2556
+ /**
2557
+ * @see https://redis.io/commands/hincrbyfloat
2558
+ */
2559
+ hincrbyfloat = (...args) => new HIncrByFloatCommand(args, this.opts).exec(this.client);
2560
+ /**
2561
+ * @see https://redis.io/commands/hkeys
2562
+ */
2563
+ hkeys = (...args) => new HKeysCommand(args, this.opts).exec(this.client);
2564
+ /**
2565
+ * @see https://redis.io/commands/hlen
2566
+ */
2567
+ hlen = (...args) => new HLenCommand(args, this.opts).exec(this.client);
2568
+ /**
2569
+ * @see https://redis.io/commands/hmget
2570
+ */
2571
+ hmget = (...args) => new HMGetCommand(args, this.opts).exec(this.client);
2572
+ /**
2573
+ * @see https://redis.io/commands/hmset
2574
+ */
2575
+ hmset = (key, kv) => new HMSetCommand([key, kv], this.opts).exec(this.client);
2576
+ /**
2577
+ * @see https://redis.io/commands/hrandfield
2578
+ */
2579
+ hrandfield = (key, count, withValues) => new HRandFieldCommand([key, count, withValues], this.opts).exec(this.client);
2580
+ /**
2581
+ * @see https://redis.io/commands/hscan
2582
+ */
2583
+ hscan = (...args) => new HScanCommand(args, this.opts).exec(this.client);
2584
+ /**
2585
+ * @see https://redis.io/commands/hset
2586
+ */
2587
+ hset = (key, kv) => new HSetCommand([key, kv], this.opts).exec(this.client);
2588
+ /**
2589
+ * @see https://redis.io/commands/hsetnx
2590
+ */
2591
+ hsetnx = (key, field, value) => new HSetNXCommand([key, field, value], this.opts).exec(this.client);
2592
+ /**
2593
+ * @see https://redis.io/commands/hstrlen
2594
+ */
2595
+ hstrlen = (...args) => new HStrLenCommand(args, this.opts).exec(this.client);
2596
+ /**
2597
+ * @see https://redis.io/commands/hvals
2598
+ */
2599
+ hvals = (...args) => new HValsCommand(args, this.opts).exec(this.client);
2600
+ /**
2601
+ * @see https://redis.io/commands/incr
2602
+ */
2603
+ incr = (...args) => new IncrCommand(args, this.opts).exec(this.client);
2604
+ /**
2605
+ * @see https://redis.io/commands/incrby
2606
+ */
2607
+ incrby = (...args) => new IncrByCommand(args, this.opts).exec(this.client);
2608
+ /**
2609
+ * @see https://redis.io/commands/incrbyfloat
2610
+ */
2611
+ incrbyfloat = (...args) => new IncrByFloatCommand(args, this.opts).exec(this.client);
2612
+ /**
2613
+ * @see https://redis.io/commands/keys
2614
+ */
2615
+ keys = (...args) => new KeysCommand(args, this.opts).exec(this.client);
2616
+ /**
2617
+ * @see https://redis.io/commands/lindex
2618
+ */
2619
+ lindex = (...args) => new LIndexCommand(args, this.opts).exec(this.client);
2620
+ /**
2621
+ * @see https://redis.io/commands/linsert
2622
+ */
2623
+ linsert = (key, direction, pivot, value) => new LInsertCommand([key, direction, pivot, value], this.opts).exec(this.client);
2624
+ /**
2625
+ * @see https://redis.io/commands/llen
2626
+ */
2627
+ llen = (...args) => new LLenCommand(args, this.opts).exec(this.client);
2628
+ /**
2629
+ * @see https://redis.io/commands/lmove
2630
+ */
2631
+ lmove = (...args) => new LMoveCommand(args, this.opts).exec(this.client);
2632
+ /**
2633
+ * @see https://redis.io/commands/lpop
2634
+ */
2635
+ lpop = (...args) => new LPopCommand(args, this.opts).exec(this.client);
2636
+ /**
2637
+ * @see https://redis.io/commands/lpos
2638
+ */
2639
+ lpos = (...args) => new LPosCommand(args, this.opts).exec(this.client);
2640
+ /**
2641
+ * @see https://redis.io/commands/lpush
2642
+ */
2643
+ lpush = (key, ...elements) => new LPushCommand([key, ...elements], this.opts).exec(this.client);
2644
+ /**
2645
+ * @see https://redis.io/commands/lpushx
2646
+ */
2647
+ lpushx = (key, ...elements) => new LPushXCommand([key, ...elements], this.opts).exec(this.client);
2648
+ /**
2649
+ * @see https://redis.io/commands/lrange
2650
+ */
2651
+ lrange = (...args) => new LRangeCommand(args, this.opts).exec(this.client);
2652
+ /**
2653
+ * @see https://redis.io/commands/lrem
2654
+ */
2655
+ lrem = (key, count, value) => new LRemCommand([key, count, value], this.opts).exec(this.client);
2656
+ /**
2657
+ * @see https://redis.io/commands/lset
2658
+ */
2659
+ lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
2660
+ /**
2661
+ * @see https://redis.io/commands/ltrim
2662
+ */
2663
+ ltrim = (...args) => new LTrimCommand(args, this.opts).exec(this.client);
2664
+ /**
2665
+ * @see https://redis.io/commands/mget
2666
+ */
2667
+ mget = (...args) => new MGetCommand(args, this.opts).exec(this.client);
2668
+ /**
2669
+ * @see https://redis.io/commands/mset
2670
+ */
2671
+ mset = (kv) => new MSetCommand([kv], this.opts).exec(this.client);
2672
+ /**
2673
+ * @see https://redis.io/commands/msetnx
2674
+ */
2675
+ msetnx = (kv) => new MSetNXCommand([kv], this.opts).exec(this.client);
2676
+ /**
2677
+ * @see https://redis.io/commands/persist
2678
+ */
2679
+ persist = (...args) => new PersistCommand(args, this.opts).exec(this.client);
2680
+ /**
2681
+ * @see https://redis.io/commands/pexpire
2682
+ */
2683
+ pexpire = (...args) => new PExpireCommand(args, this.opts).exec(this.client);
2684
+ /**
2685
+ * @see https://redis.io/commands/pexpireat
2686
+ */
2687
+ pexpireat = (...args) => new PExpireAtCommand(args, this.opts).exec(this.client);
2688
+ /**
2689
+ * @see https://redis.io/commands/ping
2690
+ */
2691
+ ping = (args) => new PingCommand(args, this.opts).exec(this.client);
2692
+ /**
2693
+ * @see https://redis.io/commands/psetex
2694
+ */
2695
+ psetex = (key, ttl, value) => new PSetEXCommand([key, ttl, value], this.opts).exec(this.client);
2696
+ /**
2697
+ * @see https://redis.io/commands/pttl
2698
+ */
2699
+ pttl = (...args) => new PTtlCommand(args, this.opts).exec(this.client);
2700
+ /**
2701
+ * @see https://redis.io/commands/publish
2702
+ */
2703
+ publish = (...args) => new PublishCommand(args, this.opts).exec(this.client);
2704
+ /**
2705
+ * @see https://redis.io/commands/randomkey
2706
+ */
2707
+ randomkey = () => new RandomKeyCommand().exec(this.client);
2708
+ /**
2709
+ * @see https://redis.io/commands/rename
2710
+ */
2711
+ rename = (...args) => new RenameCommand(args, this.opts).exec(this.client);
2712
+ /**
2713
+ * @see https://redis.io/commands/renamenx
2714
+ */
2715
+ renamenx = (...args) => new RenameNXCommand(args, this.opts).exec(this.client);
2716
+ /**
2717
+ * @see https://redis.io/commands/rpop
2718
+ */
2719
+ rpop = (...args) => new RPopCommand(args, this.opts).exec(this.client);
2720
+ /**
2721
+ * @see https://redis.io/commands/rpush
2722
+ */
2723
+ rpush = (key, ...elements) => new RPushCommand([key, ...elements], this.opts).exec(this.client);
2724
+ /**
2725
+ * @see https://redis.io/commands/rpushx
2726
+ */
2727
+ rpushx = (key, ...elements) => new RPushXCommand([key, ...elements], this.opts).exec(this.client);
2728
+ /**
2729
+ * @see https://redis.io/commands/sadd
2730
+ */
2731
+ sadd = (key, ...members) => new SAddCommand([key, ...members], this.opts).exec(this.client);
2732
+ /**
2733
+ * @see https://redis.io/commands/scan
2734
+ */
2735
+ scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
2736
+ /**
2737
+ * @see https://redis.io/commands/scard
2738
+ */
2739
+ scard = (...args) => new SCardCommand(args, this.opts).exec(this.client);
2740
+ /**
2741
+ * @see https://redis.io/commands/script-exists
2742
+ */
2743
+ scriptExists = (...args) => new ScriptExistsCommand(args, this.opts).exec(this.client);
2744
+ /**
2745
+ * @see https://redis.io/commands/script-flush
2746
+ */
2747
+ scriptFlush = (...args) => new ScriptFlushCommand(args, this.opts).exec(this.client);
2748
+ /**
2749
+ * @see https://redis.io/commands/script-load
2750
+ */
2751
+ scriptLoad = (...args) => new ScriptLoadCommand(args, this.opts).exec(this.client);
2752
+ /**
2753
+ * @see https://redis.io/commands/sdiff
2754
+ */
2755
+ sdiff = (...args) => new SDiffCommand(args, this.opts).exec(this.client);
2756
+ /**
2757
+ * @see https://redis.io/commands/sdiffstore
2758
+ */
2759
+ sdiffstore = (...args) => new SDiffStoreCommand(args, this.opts).exec(this.client);
2760
+ /**
2761
+ * @see https://redis.io/commands/set
2762
+ */
2763
+ set = (key, value, opts) => new SetCommand([key, value, opts], this.opts).exec(this.client);
2764
+ /**
2765
+ * @see https://redis.io/commands/setbit
2766
+ */
2767
+ setbit = (...args) => new SetBitCommand(args, this.opts).exec(this.client);
2768
+ /**
2769
+ * @see https://redis.io/commands/setex
2770
+ */
2771
+ setex = (key, ttl, value) => new SetExCommand([key, ttl, value], this.opts).exec(this.client);
2772
+ /**
2773
+ * @see https://redis.io/commands/setnx
2774
+ */
2775
+ setnx = (key, value) => new SetNxCommand([key, value], this.opts).exec(this.client);
2776
+ /**
2777
+ * @see https://redis.io/commands/setrange
2778
+ */
2779
+ setrange = (...args) => new SetRangeCommand(args, this.opts).exec(this.client);
2780
+ /**
2781
+ * @see https://redis.io/commands/sinter
2782
+ */
2783
+ sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
2784
+ /**
2785
+ * @see https://redis.io/commands/sinterstore
2786
+ */
2787
+ sinterstore = (...args) => new SInterStoreCommand(args, this.opts).exec(this.client);
2788
+ /**
2789
+ * @see https://redis.io/commands/sismember
2790
+ */
2791
+ sismember = (key, member) => new SIsMemberCommand([key, member], this.opts).exec(this.client);
2792
+ /**
2793
+ * @see https://redis.io/commands/smismember
2794
+ */
2795
+ smismember = (key, members) => new SMIsMemberCommand([key, members], this.opts).exec(this.client);
2796
+ /**
2797
+ * @see https://redis.io/commands/smembers
2798
+ */
2799
+ smembers = (...args) => new SMembersCommand(args, this.opts).exec(this.client);
2800
+ /**
2801
+ * @see https://redis.io/commands/smove
2802
+ */
2803
+ smove = (source, destination, member) => new SMoveCommand([source, destination, member], this.opts).exec(this.client);
2804
+ /**
2805
+ * @see https://redis.io/commands/spop
2806
+ */
2807
+ spop = (...args) => new SPopCommand(args, this.opts).exec(this.client);
2808
+ /**
2809
+ * @see https://redis.io/commands/srandmember
2810
+ */
2811
+ srandmember = (...args) => new SRandMemberCommand(args, this.opts).exec(this.client);
2812
+ /**
2813
+ * @see https://redis.io/commands/srem
2814
+ */
2815
+ srem = (key, ...members) => new SRemCommand([key, ...members], this.opts).exec(this.client);
2816
+ /**
2817
+ * @see https://redis.io/commands/sscan
2818
+ */
2819
+ sscan = (...args) => new SScanCommand(args, this.opts).exec(this.client);
2820
+ /**
2821
+ * @see https://redis.io/commands/strlen
2822
+ */
2823
+ strlen = (...args) => new StrLenCommand(args, this.opts).exec(this.client);
2824
+ /**
2825
+ * @see https://redis.io/commands/sunion
2826
+ */
2827
+ sunion = (...args) => new SUnionCommand(args, this.opts).exec(this.client);
2828
+ /**
2829
+ * @see https://redis.io/commands/sunionstore
2830
+ */
2831
+ sunionstore = (...args) => new SUnionStoreCommand(args, this.opts).exec(this.client);
2832
+ /**
2833
+ * @see https://redis.io/commands/time
2834
+ */
2835
+ time = () => new TimeCommand().exec(this.client);
2836
+ /**
2837
+ * @see https://redis.io/commands/touch
2838
+ */
2839
+ touch = (...args) => new TouchCommand(args, this.opts).exec(this.client);
2840
+ /**
2841
+ * @see https://redis.io/commands/ttl
2842
+ */
2843
+ ttl = (...args) => new TtlCommand(args, this.opts).exec(this.client);
2844
+ /**
2845
+ * @see https://redis.io/commands/type
2846
+ */
2847
+ type = (...args) => new TypeCommand(args, this.opts).exec(this.client);
2848
+ /**
2849
+ * @see https://redis.io/commands/unlink
2850
+ */
2851
+ unlink = (...args) => new UnlinkCommand(args, this.opts).exec(this.client);
2852
+ /**
2853
+ * @see https://redis.io/commands/xadd
2854
+ */
2855
+ xadd = (...args) => new XAddCommand(args, this.opts).exec(this.client);
2856
+ /**
2857
+ * @see https://redis.io/commands/xrange
2858
+ */
2859
+ xrange = (...args) => new XRangeCommand(args, this.opts).exec(this.client);
2860
+ /**
2861
+ * @see https://redis.io/commands/zadd
2862
+ */
2863
+ zadd = (...args) => {
2864
+ if ("score" in args[1]) {
2865
+ return new ZAddCommand(
2866
+ [args[0], args[1], ...args.slice(2)],
2867
+ this.opts
2868
+ ).exec(this.client);
2869
+ }
2870
+ return new ZAddCommand(
2871
+ [args[0], args[1], ...args.slice(2)],
2872
+ this.opts
2873
+ ).exec(this.client);
2874
+ };
2875
+ /**
2876
+ * @see https://redis.io/commands/zcard
2877
+ */
2878
+ zcard = (...args) => new ZCardCommand(args, this.opts).exec(this.client);
2879
+ /**
2880
+ * @see https://redis.io/commands/zcount
2881
+ */
2882
+ zcount = (...args) => new ZCountCommand(args, this.opts).exec(this.client);
2883
+ /**
2884
+ * @see https://redis.io/commands/zdiffstore
2885
+ */
2886
+ zdiffstore = (...args) => new ZDiffStoreCommand(args, this.opts).exec(this.client);
2887
+ /**
2888
+ * @see https://redis.io/commands/zincrby
2889
+ */
2890
+ zincrby = (key, increment, member) => new ZIncrByCommand([key, increment, member], this.opts).exec(this.client);
2891
+ /**
2892
+ * @see https://redis.io/commands/zinterstore
2893
+ */
2894
+ zinterstore = (...args) => new ZInterStoreCommand(args, this.opts).exec(this.client);
2895
+ /**
2896
+ * @see https://redis.io/commands/zlexcount
2897
+ */
2898
+ zlexcount = (...args) => new ZLexCountCommand(args, this.opts).exec(this.client);
2899
+ /**
2900
+ * @see https://redis.io/commands/zmscore
2901
+ */
2902
+ zmscore = (...args) => new ZMScoreCommand(args, this.opts).exec(this.client);
2903
+ /**
2904
+ * @see https://redis.io/commands/zpopmax
2905
+ */
2906
+ zpopmax = (...args) => new ZPopMaxCommand(args, this.opts).exec(this.client);
2907
+ /**
2908
+ * @see https://redis.io/commands/zpopmin
2909
+ */
2910
+ zpopmin = (...args) => new ZPopMinCommand(args, this.opts).exec(this.client);
2911
+ /**
2912
+ * @see https://redis.io/commands/zrange
2913
+ */
2914
+ zrange = (...args) => new ZRangeCommand(args, this.opts).exec(this.client);
2915
+ /**
2916
+ * @see https://redis.io/commands/zrank
2917
+ */
2918
+ zrank = (key, member) => new ZRankCommand([key, member], this.opts).exec(this.client);
2919
+ /**
2920
+ * @see https://redis.io/commands/zrem
2921
+ */
2922
+ zrem = (key, ...members) => new ZRemCommand([key, ...members], this.opts).exec(this.client);
2923
+ /**
2924
+ * @see https://redis.io/commands/zremrangebylex
2925
+ */
2926
+ zremrangebylex = (...args) => new ZRemRangeByLexCommand(args, this.opts).exec(this.client);
2927
+ /**
2928
+ * @see https://redis.io/commands/zremrangebyrank
2929
+ */
2930
+ zremrangebyrank = (...args) => new ZRemRangeByRankCommand(args, this.opts).exec(this.client);
2931
+ /**
2932
+ * @see https://redis.io/commands/zremrangebyscore
2933
+ */
2934
+ zremrangebyscore = (...args) => new ZRemRangeByScoreCommand(args, this.opts).exec(this.client);
2935
+ /**
2936
+ * @see https://redis.io/commands/zrevrank
2937
+ */
2938
+ zrevrank = (key, member) => new ZRevRankCommand([key, member], this.opts).exec(this.client);
2939
+ /**
2940
+ * @see https://redis.io/commands/zscan
2941
+ */
2942
+ zscan = (...args) => new ZScanCommand(args, this.opts).exec(this.client);
2943
+ /**
2944
+ * @see https://redis.io/commands/zscore
2945
+ */
2946
+ zscore = (key, member) => new ZScoreCommand([key, member], this.opts).exec(this.client);
2947
+ /**
2948
+ * @see https://redis.io/commands/zunion
2949
+ */
2950
+ zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
2951
+ /**
2952
+ * @see https://redis.io/commands/zunionstore
2953
+ */
2954
+ zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
2955
+ };
2956
+
2957
+ // version.ts
2958
+ var VERSION = "v0.0.0-ci.fc1b22d0-20231019";
2959
+
2960
+ // platforms/nodejs.ts
2961
+ if (typeof atob === "undefined") {
2962
+ global.atob = function(b64) {
2963
+ return Buffer.from(b64, "base64").toString("utf-8");
2964
+ };
2965
+ }
2966
+ var Redis2 = class _Redis extends Redis {
2967
+ constructor(configOrRequester) {
2968
+ if ("request" in configOrRequester) {
2969
+ super(configOrRequester);
2970
+ return;
2971
+ }
2972
+ if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
2973
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
2974
+ }
2975
+ if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
2976
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
2977
+ }
2978
+ const client = new HttpClient({
2979
+ baseUrl: configOrRequester.url,
2980
+ retry: configOrRequester.retry,
2981
+ headers: { authorization: `Bearer ${configOrRequester.token}` },
2982
+ agent: configOrRequester.agent,
2983
+ responseEncoding: configOrRequester.responseEncoding,
2984
+ cache: configOrRequester.cache || "no-store"
2985
+ });
2986
+ super(client, {
2987
+ automaticDeserialization: configOrRequester.automaticDeserialization,
2988
+ enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY
2989
+ });
2990
+ this.addTelemetry({
2991
+ // @ts-ignore
2992
+ runtime: typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`,
2993
+ platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
2994
+ sdk: `@upstash/redis@${VERSION}`
2995
+ });
2996
+ }
2997
+ /**
2998
+ * Create a new Upstash Redis instance from environment variables.
2999
+ *
3000
+ * Use this to automatically load connection secrets from your environment
3001
+ * variables. For instance when using the Vercel integration.
3002
+ *
3003
+ * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
3004
+ * your environment using `process.env`.
3005
+ */
3006
+ static fromEnv(config) {
3007
+ if (typeof process?.env === "undefined") {
3008
+ throw new Error(
3009
+ 'Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
3010
+ );
3011
+ }
3012
+ const url = process?.env["UPSTASH_REDIS_REST_URL"];
3013
+ if (!url) {
3014
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
3015
+ }
3016
+ const token = process?.env["UPSTASH_REDIS_REST_TOKEN"];
3017
+ if (!token) {
3018
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
3019
+ }
3020
+ return new _Redis({ ...config, url, token });
3021
+ }
3022
+ };
3023
+ export {
3024
+ Redis2 as Redis
3025
+ };
3026
+ //# sourceMappingURL=nodejs.mjs.map