@upstash/redis 0.0.0-ci.d1b181cb-20230414 → 0.0.0-ci.d3170677a5859e31d40407781286bdf17d64ca72-20250220114636

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 (500) hide show
  1. package/README.md +17 -6
  2. package/chunk-AQ2U77ZI.mjs +4097 -0
  3. package/cloudflare.d.mts +55 -0
  4. package/cloudflare.d.ts +55 -0
  5. package/cloudflare.js +4209 -0
  6. package/cloudflare.mjs +93 -0
  7. package/fastly.d.mts +48 -0
  8. package/fastly.d.ts +48 -0
  9. package/fastly.js +4182 -0
  10. package/fastly.mjs +66 -0
  11. package/nodejs.d.mts +73 -0
  12. package/nodejs.d.ts +73 -0
  13. package/nodejs.js +4229 -0
  14. package/nodejs.mjs +113 -0
  15. package/package.json +1 -88
  16. package/zmscore-BnJuTB6j.d.mts +3710 -0
  17. package/zmscore-BnJuTB6j.d.ts +3710 -0
  18. package/.releaserc +0 -14
  19. package/esm/deps/deno.land/x/base64@v0.2.1/base.js +0 -100
  20. package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +0 -9
  21. package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +0 -1
  22. package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +0 -191
  23. package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +0 -50
  24. package/esm/package.json +0 -3
  25. package/esm/pkg/commands/append.js +0 -9
  26. package/esm/pkg/commands/bitcount.js +0 -16
  27. package/esm/pkg/commands/bitop.js +0 -9
  28. package/esm/pkg/commands/bitpos.js +0 -9
  29. package/esm/pkg/commands/command.js +0 -66
  30. package/esm/pkg/commands/dbsize.js +0 -9
  31. package/esm/pkg/commands/decr.js +0 -9
  32. package/esm/pkg/commands/decrby.js +0 -9
  33. package/esm/pkg/commands/del.js +0 -9
  34. package/esm/pkg/commands/echo.js +0 -9
  35. package/esm/pkg/commands/eval.js +0 -9
  36. package/esm/pkg/commands/evalsha.js +0 -9
  37. package/esm/pkg/commands/exists.js +0 -9
  38. package/esm/pkg/commands/expire.js +0 -9
  39. package/esm/pkg/commands/expireat.js +0 -9
  40. package/esm/pkg/commands/flushall.js +0 -13
  41. package/esm/pkg/commands/flushdb.js +0 -13
  42. package/esm/pkg/commands/get.js +0 -9
  43. package/esm/pkg/commands/getbit.js +0 -9
  44. package/esm/pkg/commands/getdel.js +0 -9
  45. package/esm/pkg/commands/getrange.js +0 -9
  46. package/esm/pkg/commands/getset.js +0 -9
  47. package/esm/pkg/commands/hdel.js +0 -9
  48. package/esm/pkg/commands/hexists.js +0 -9
  49. package/esm/pkg/commands/hget.js +0 -9
  50. package/esm/pkg/commands/hgetall.js +0 -29
  51. package/esm/pkg/commands/hincrby.js +0 -9
  52. package/esm/pkg/commands/hincrbyfloat.js +0 -9
  53. package/esm/pkg/commands/hkeys.js +0 -9
  54. package/esm/pkg/commands/hlen.js +0 -9
  55. package/esm/pkg/commands/hmget.js +0 -35
  56. package/esm/pkg/commands/hmset.js +0 -13
  57. package/esm/pkg/commands/hrandfield.js +0 -39
  58. package/esm/pkg/commands/hscan.js +0 -16
  59. package/esm/pkg/commands/hset.js +0 -13
  60. package/esm/pkg/commands/hsetnx.js +0 -9
  61. package/esm/pkg/commands/hstrlen.js +0 -9
  62. package/esm/pkg/commands/hvals.js +0 -9
  63. package/esm/pkg/commands/incr.js +0 -9
  64. package/esm/pkg/commands/incrby.js +0 -9
  65. package/esm/pkg/commands/incrbyfloat.js +0 -9
  66. package/esm/pkg/commands/json_arrappend.js +0 -9
  67. package/esm/pkg/commands/json_arrindex.js +0 -9
  68. package/esm/pkg/commands/json_arrinsert.js +0 -9
  69. package/esm/pkg/commands/json_arrlen.js +0 -9
  70. package/esm/pkg/commands/json_arrpop.js +0 -9
  71. package/esm/pkg/commands/json_arrtrim.js +0 -12
  72. package/esm/pkg/commands/json_clear.js +0 -9
  73. package/esm/pkg/commands/json_del.js +0 -9
  74. package/esm/pkg/commands/json_forget.js +0 -9
  75. package/esm/pkg/commands/json_get.js +0 -30
  76. package/esm/pkg/commands/json_mget.js +0 -9
  77. package/esm/pkg/commands/json_numincrby.js +0 -9
  78. package/esm/pkg/commands/json_nummultby.js +0 -9
  79. package/esm/pkg/commands/json_objkeys.js +0 -9
  80. package/esm/pkg/commands/json_objlen.js +0 -9
  81. package/esm/pkg/commands/json_resp.js +0 -9
  82. package/esm/pkg/commands/json_set.js +0 -18
  83. package/esm/pkg/commands/json_strappend.js +0 -9
  84. package/esm/pkg/commands/json_strlen.js +0 -9
  85. package/esm/pkg/commands/json_toggle.js +0 -9
  86. package/esm/pkg/commands/json_type.js +0 -9
  87. package/esm/pkg/commands/keys.js +0 -9
  88. package/esm/pkg/commands/lindex.js +0 -6
  89. package/esm/pkg/commands/linsert.js +0 -6
  90. package/esm/pkg/commands/llen.js +0 -9
  91. package/esm/pkg/commands/lmove.js +0 -9
  92. package/esm/pkg/commands/lpop.js +0 -9
  93. package/esm/pkg/commands/lpos.js +0 -19
  94. package/esm/pkg/commands/lpush.js +0 -9
  95. package/esm/pkg/commands/lpushx.js +0 -9
  96. package/esm/pkg/commands/lrange.js +0 -6
  97. package/esm/pkg/commands/lrem.js +0 -6
  98. package/esm/pkg/commands/lset.js +0 -6
  99. package/esm/pkg/commands/ltrim.js +0 -6
  100. package/esm/pkg/commands/mget.js +0 -9
  101. package/esm/pkg/commands/mod.js +0 -140
  102. package/esm/pkg/commands/mset.js +0 -12
  103. package/esm/pkg/commands/msetnx.js +0 -9
  104. package/esm/pkg/commands/persist.js +0 -9
  105. package/esm/pkg/commands/pexpire.js +0 -9
  106. package/esm/pkg/commands/pexpireat.js +0 -9
  107. package/esm/pkg/commands/ping.js +0 -13
  108. package/esm/pkg/commands/psetex.js +0 -9
  109. package/esm/pkg/commands/pttl.js +0 -9
  110. package/esm/pkg/commands/publish.js +0 -9
  111. package/esm/pkg/commands/randomkey.js +0 -9
  112. package/esm/pkg/commands/rename.js +0 -9
  113. package/esm/pkg/commands/renamenx.js +0 -9
  114. package/esm/pkg/commands/rpop.js +0 -9
  115. package/esm/pkg/commands/rpush.js +0 -9
  116. package/esm/pkg/commands/rpushx.js +0 -9
  117. package/esm/pkg/commands/sadd.js +0 -9
  118. package/esm/pkg/commands/scan.js +0 -19
  119. package/esm/pkg/commands/scard.js +0 -9
  120. package/esm/pkg/commands/script_exists.js +0 -12
  121. package/esm/pkg/commands/script_flush.js +0 -16
  122. package/esm/pkg/commands/script_load.js +0 -9
  123. package/esm/pkg/commands/sdiff.js +0 -9
  124. package/esm/pkg/commands/sdiffstore.js +0 -9
  125. package/esm/pkg/commands/set.js +0 -36
  126. package/esm/pkg/commands/setbit.js +0 -9
  127. package/esm/pkg/commands/setex.js +0 -9
  128. package/esm/pkg/commands/setnx.js +0 -9
  129. package/esm/pkg/commands/setrange.js +0 -9
  130. package/esm/pkg/commands/sinter.js +0 -9
  131. package/esm/pkg/commands/sinterstore.js +0 -9
  132. package/esm/pkg/commands/sismember.js +0 -9
  133. package/esm/pkg/commands/smembers.js +0 -9
  134. package/esm/pkg/commands/smismember.js +0 -9
  135. package/esm/pkg/commands/smove.js +0 -9
  136. package/esm/pkg/commands/spop.js +0 -13
  137. package/esm/pkg/commands/srandmember.js +0 -13
  138. package/esm/pkg/commands/srem.js +0 -9
  139. package/esm/pkg/commands/sscan.js +0 -16
  140. package/esm/pkg/commands/strlen.js +0 -9
  141. package/esm/pkg/commands/sunion.js +0 -9
  142. package/esm/pkg/commands/sunionstore.js +0 -9
  143. package/esm/pkg/commands/time.js +0 -9
  144. package/esm/pkg/commands/touch.js +0 -9
  145. package/esm/pkg/commands/ttl.js +0 -9
  146. package/esm/pkg/commands/type.js +0 -9
  147. package/esm/pkg/commands/unlink.js +0 -9
  148. package/esm/pkg/commands/zadd.js +0 -26
  149. package/esm/pkg/commands/zcard.js +0 -9
  150. package/esm/pkg/commands/zcount.js +0 -9
  151. package/esm/pkg/commands/zdiffstore.js +0 -9
  152. package/esm/pkg/commands/zincrby.js +0 -9
  153. package/esm/pkg/commands/zinterstore.js +0 -27
  154. package/esm/pkg/commands/zlexcount.js +0 -9
  155. package/esm/pkg/commands/zmscore.js +0 -10
  156. package/esm/pkg/commands/zpopmax.js +0 -13
  157. package/esm/pkg/commands/zpopmin.js +0 -13
  158. package/esm/pkg/commands/zrange.js +0 -26
  159. package/esm/pkg/commands/zrank.js +0 -9
  160. package/esm/pkg/commands/zrem.js +0 -9
  161. package/esm/pkg/commands/zremrangebylex.js +0 -9
  162. package/esm/pkg/commands/zremrangebyrank.js +0 -9
  163. package/esm/pkg/commands/zremrangebyscore.js +0 -9
  164. package/esm/pkg/commands/zrevrank.js +0 -9
  165. package/esm/pkg/commands/zscan.js +0 -16
  166. package/esm/pkg/commands/zscore.js +0 -9
  167. package/esm/pkg/commands/zunionstore.js +0 -27
  168. package/esm/pkg/error.js +0 -9
  169. package/esm/pkg/http.js +0 -167
  170. package/esm/pkg/pipeline.js +0 -1291
  171. package/esm/pkg/redis.js +0 -1288
  172. package/esm/pkg/script.js +0 -77
  173. package/esm/pkg/types.js +0 -1
  174. package/esm/pkg/util.js +0 -31
  175. package/esm/platforms/cloudflare.js +0 -70
  176. package/esm/platforms/fastly.js +0 -46
  177. package/esm/platforms/node_with_fetch.js +0 -85
  178. package/esm/platforms/nodejs.js +0 -80
  179. package/esm/version.js +0 -1
  180. package/script/deps/deno.land/x/base64@v0.2.1/base.js +0 -104
  181. package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +0 -13
  182. package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +0 -6
  183. package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +0 -196
  184. package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +0 -55
  185. package/script/package.json +0 -3
  186. package/script/pkg/commands/append.js +0 -13
  187. package/script/pkg/commands/bitcount.js +0 -20
  188. package/script/pkg/commands/bitop.js +0 -13
  189. package/script/pkg/commands/bitpos.js +0 -13
  190. package/script/pkg/commands/command.js +0 -70
  191. package/script/pkg/commands/dbsize.js +0 -13
  192. package/script/pkg/commands/decr.js +0 -13
  193. package/script/pkg/commands/decrby.js +0 -13
  194. package/script/pkg/commands/del.js +0 -13
  195. package/script/pkg/commands/echo.js +0 -13
  196. package/script/pkg/commands/eval.js +0 -13
  197. package/script/pkg/commands/evalsha.js +0 -13
  198. package/script/pkg/commands/exists.js +0 -13
  199. package/script/pkg/commands/expire.js +0 -13
  200. package/script/pkg/commands/expireat.js +0 -13
  201. package/script/pkg/commands/flushall.js +0 -17
  202. package/script/pkg/commands/flushdb.js +0 -17
  203. package/script/pkg/commands/get.js +0 -13
  204. package/script/pkg/commands/getbit.js +0 -13
  205. package/script/pkg/commands/getdel.js +0 -13
  206. package/script/pkg/commands/getrange.js +0 -13
  207. package/script/pkg/commands/getset.js +0 -13
  208. package/script/pkg/commands/hdel.js +0 -13
  209. package/script/pkg/commands/hexists.js +0 -13
  210. package/script/pkg/commands/hget.js +0 -13
  211. package/script/pkg/commands/hgetall.js +0 -33
  212. package/script/pkg/commands/hincrby.js +0 -13
  213. package/script/pkg/commands/hincrbyfloat.js +0 -13
  214. package/script/pkg/commands/hkeys.js +0 -13
  215. package/script/pkg/commands/hlen.js +0 -13
  216. package/script/pkg/commands/hmget.js +0 -39
  217. package/script/pkg/commands/hmset.js +0 -17
  218. package/script/pkg/commands/hrandfield.js +0 -43
  219. package/script/pkg/commands/hscan.js +0 -20
  220. package/script/pkg/commands/hset.js +0 -17
  221. package/script/pkg/commands/hsetnx.js +0 -13
  222. package/script/pkg/commands/hstrlen.js +0 -13
  223. package/script/pkg/commands/hvals.js +0 -13
  224. package/script/pkg/commands/incr.js +0 -13
  225. package/script/pkg/commands/incrby.js +0 -13
  226. package/script/pkg/commands/incrbyfloat.js +0 -13
  227. package/script/pkg/commands/json_arrappend.js +0 -13
  228. package/script/pkg/commands/json_arrindex.js +0 -13
  229. package/script/pkg/commands/json_arrinsert.js +0 -13
  230. package/script/pkg/commands/json_arrlen.js +0 -13
  231. package/script/pkg/commands/json_arrpop.js +0 -13
  232. package/script/pkg/commands/json_arrtrim.js +0 -16
  233. package/script/pkg/commands/json_clear.js +0 -13
  234. package/script/pkg/commands/json_del.js +0 -13
  235. package/script/pkg/commands/json_forget.js +0 -13
  236. package/script/pkg/commands/json_get.js +0 -34
  237. package/script/pkg/commands/json_mget.js +0 -13
  238. package/script/pkg/commands/json_numincrby.js +0 -13
  239. package/script/pkg/commands/json_nummultby.js +0 -13
  240. package/script/pkg/commands/json_objkeys.js +0 -13
  241. package/script/pkg/commands/json_objlen.js +0 -13
  242. package/script/pkg/commands/json_resp.js +0 -13
  243. package/script/pkg/commands/json_set.js +0 -22
  244. package/script/pkg/commands/json_strappend.js +0 -13
  245. package/script/pkg/commands/json_strlen.js +0 -13
  246. package/script/pkg/commands/json_toggle.js +0 -13
  247. package/script/pkg/commands/json_type.js +0 -13
  248. package/script/pkg/commands/keys.js +0 -13
  249. package/script/pkg/commands/lindex.js +0 -10
  250. package/script/pkg/commands/linsert.js +0 -10
  251. package/script/pkg/commands/llen.js +0 -13
  252. package/script/pkg/commands/lmove.js +0 -13
  253. package/script/pkg/commands/lpop.js +0 -13
  254. package/script/pkg/commands/lpos.js +0 -23
  255. package/script/pkg/commands/lpush.js +0 -13
  256. package/script/pkg/commands/lpushx.js +0 -13
  257. package/script/pkg/commands/lrange.js +0 -10
  258. package/script/pkg/commands/lrem.js +0 -10
  259. package/script/pkg/commands/lset.js +0 -10
  260. package/script/pkg/commands/ltrim.js +0 -10
  261. package/script/pkg/commands/mget.js +0 -13
  262. package/script/pkg/commands/mod.js +0 -156
  263. package/script/pkg/commands/mset.js +0 -16
  264. package/script/pkg/commands/msetnx.js +0 -13
  265. package/script/pkg/commands/persist.js +0 -13
  266. package/script/pkg/commands/pexpire.js +0 -13
  267. package/script/pkg/commands/pexpireat.js +0 -13
  268. package/script/pkg/commands/ping.js +0 -17
  269. package/script/pkg/commands/psetex.js +0 -13
  270. package/script/pkg/commands/pttl.js +0 -13
  271. package/script/pkg/commands/publish.js +0 -13
  272. package/script/pkg/commands/randomkey.js +0 -13
  273. package/script/pkg/commands/rename.js +0 -13
  274. package/script/pkg/commands/renamenx.js +0 -13
  275. package/script/pkg/commands/rpop.js +0 -13
  276. package/script/pkg/commands/rpush.js +0 -13
  277. package/script/pkg/commands/rpushx.js +0 -13
  278. package/script/pkg/commands/sadd.js +0 -13
  279. package/script/pkg/commands/scan.js +0 -23
  280. package/script/pkg/commands/scard.js +0 -13
  281. package/script/pkg/commands/script_exists.js +0 -16
  282. package/script/pkg/commands/script_flush.js +0 -20
  283. package/script/pkg/commands/script_load.js +0 -13
  284. package/script/pkg/commands/sdiff.js +0 -13
  285. package/script/pkg/commands/sdiffstore.js +0 -13
  286. package/script/pkg/commands/set.js +0 -40
  287. package/script/pkg/commands/setbit.js +0 -13
  288. package/script/pkg/commands/setex.js +0 -13
  289. package/script/pkg/commands/setnx.js +0 -13
  290. package/script/pkg/commands/setrange.js +0 -13
  291. package/script/pkg/commands/sinter.js +0 -13
  292. package/script/pkg/commands/sinterstore.js +0 -13
  293. package/script/pkg/commands/sismember.js +0 -13
  294. package/script/pkg/commands/smembers.js +0 -13
  295. package/script/pkg/commands/smismember.js +0 -13
  296. package/script/pkg/commands/smove.js +0 -13
  297. package/script/pkg/commands/spop.js +0 -17
  298. package/script/pkg/commands/srandmember.js +0 -17
  299. package/script/pkg/commands/srem.js +0 -13
  300. package/script/pkg/commands/sscan.js +0 -20
  301. package/script/pkg/commands/strlen.js +0 -13
  302. package/script/pkg/commands/sunion.js +0 -13
  303. package/script/pkg/commands/sunionstore.js +0 -13
  304. package/script/pkg/commands/time.js +0 -13
  305. package/script/pkg/commands/touch.js +0 -13
  306. package/script/pkg/commands/ttl.js +0 -13
  307. package/script/pkg/commands/type.js +0 -13
  308. package/script/pkg/commands/unlink.js +0 -13
  309. package/script/pkg/commands/zadd.js +0 -30
  310. package/script/pkg/commands/zcard.js +0 -13
  311. package/script/pkg/commands/zcount.js +0 -13
  312. package/script/pkg/commands/zdiffstore.js +0 -13
  313. package/script/pkg/commands/zincrby.js +0 -13
  314. package/script/pkg/commands/zinterstore.js +0 -31
  315. package/script/pkg/commands/zlexcount.js +0 -13
  316. package/script/pkg/commands/zmscore.js +0 -14
  317. package/script/pkg/commands/zpopmax.js +0 -17
  318. package/script/pkg/commands/zpopmin.js +0 -17
  319. package/script/pkg/commands/zrange.js +0 -30
  320. package/script/pkg/commands/zrank.js +0 -13
  321. package/script/pkg/commands/zrem.js +0 -13
  322. package/script/pkg/commands/zremrangebylex.js +0 -13
  323. package/script/pkg/commands/zremrangebyrank.js +0 -13
  324. package/script/pkg/commands/zremrangebyscore.js +0 -13
  325. package/script/pkg/commands/zrevrank.js +0 -13
  326. package/script/pkg/commands/zscan.js +0 -20
  327. package/script/pkg/commands/zscore.js +0 -13
  328. package/script/pkg/commands/zunionstore.js +0 -31
  329. package/script/pkg/error.js +0 -13
  330. package/script/pkg/http.js +0 -171
  331. package/script/pkg/pipeline.js +0 -1295
  332. package/script/pkg/redis.js +0 -1292
  333. package/script/pkg/script.js +0 -81
  334. package/script/pkg/types.js +0 -2
  335. package/script/pkg/util.js +0 -35
  336. package/script/platforms/cloudflare.js +0 -97
  337. package/script/platforms/fastly.js +0 -73
  338. package/script/platforms/node_with_fetch.js +0 -112
  339. package/script/platforms/nodejs.js +0 -107
  340. package/script/version.js +0 -4
  341. package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +0 -5
  342. package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +0 -1
  343. package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +0 -1
  344. package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +0 -26
  345. package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +0 -3
  346. package/types/pkg/commands/append.d.ts +0 -7
  347. package/types/pkg/commands/bitcount.d.ts +0 -8
  348. package/types/pkg/commands/bitop.d.ts +0 -12
  349. package/types/pkg/commands/bitpos.d.ts +0 -7
  350. package/types/pkg/commands/command.d.ts +0 -37
  351. package/types/pkg/commands/dbsize.d.ts +0 -7
  352. package/types/pkg/commands/decr.d.ts +0 -7
  353. package/types/pkg/commands/decrby.d.ts +0 -7
  354. package/types/pkg/commands/del.d.ts +0 -7
  355. package/types/pkg/commands/echo.d.ts +0 -7
  356. package/types/pkg/commands/eval.d.ts +0 -7
  357. package/types/pkg/commands/evalsha.d.ts +0 -7
  358. package/types/pkg/commands/exists.d.ts +0 -7
  359. package/types/pkg/commands/expire.d.ts +0 -7
  360. package/types/pkg/commands/expireat.d.ts +0 -7
  361. package/types/pkg/commands/flushall.d.ts +0 -9
  362. package/types/pkg/commands/flushdb.d.ts +0 -9
  363. package/types/pkg/commands/get.d.ts +0 -7
  364. package/types/pkg/commands/getbit.d.ts +0 -7
  365. package/types/pkg/commands/getdel.d.ts +0 -7
  366. package/types/pkg/commands/getrange.d.ts +0 -7
  367. package/types/pkg/commands/getset.d.ts +0 -7
  368. package/types/pkg/commands/hdel.d.ts +0 -7
  369. package/types/pkg/commands/hexists.d.ts +0 -7
  370. package/types/pkg/commands/hget.d.ts +0 -7
  371. package/types/pkg/commands/hgetall.d.ts +0 -7
  372. package/types/pkg/commands/hincrby.d.ts +0 -7
  373. package/types/pkg/commands/hincrbyfloat.d.ts +0 -7
  374. package/types/pkg/commands/hkeys.d.ts +0 -7
  375. package/types/pkg/commands/hlen.d.ts +0 -7
  376. package/types/pkg/commands/hmget.d.ts +0 -15
  377. package/types/pkg/commands/hmset.d.ts +0 -9
  378. package/types/pkg/commands/hrandfield.d.ts +0 -9
  379. package/types/pkg/commands/hscan.d.ts +0 -24
  380. package/types/pkg/commands/hset.d.ts +0 -9
  381. package/types/pkg/commands/hsetnx.d.ts +0 -7
  382. package/types/pkg/commands/hstrlen.d.ts +0 -7
  383. package/types/pkg/commands/hvals.d.ts +0 -7
  384. package/types/pkg/commands/incr.d.ts +0 -7
  385. package/types/pkg/commands/incrby.d.ts +0 -7
  386. package/types/pkg/commands/incrbyfloat.d.ts +0 -7
  387. package/types/pkg/commands/json_arrappend.d.ts +0 -7
  388. package/types/pkg/commands/json_arrindex.d.ts +0 -13
  389. package/types/pkg/commands/json_arrinsert.d.ts +0 -7
  390. package/types/pkg/commands/json_arrlen.d.ts +0 -7
  391. package/types/pkg/commands/json_arrpop.d.ts +0 -7
  392. package/types/pkg/commands/json_arrtrim.d.ts +0 -7
  393. package/types/pkg/commands/json_clear.d.ts +0 -7
  394. package/types/pkg/commands/json_del.d.ts +0 -7
  395. package/types/pkg/commands/json_forget.d.ts +0 -7
  396. package/types/pkg/commands/json_get.d.ts +0 -15
  397. package/types/pkg/commands/json_mget.d.ts +0 -7
  398. package/types/pkg/commands/json_numincrby.d.ts +0 -7
  399. package/types/pkg/commands/json_nummultby.d.ts +0 -7
  400. package/types/pkg/commands/json_objkeys.d.ts +0 -7
  401. package/types/pkg/commands/json_objlen.d.ts +0 -7
  402. package/types/pkg/commands/json_resp.d.ts +0 -7
  403. package/types/pkg/commands/json_set.d.ts +0 -18
  404. package/types/pkg/commands/json_strappend.d.ts +0 -7
  405. package/types/pkg/commands/json_strlen.d.ts +0 -7
  406. package/types/pkg/commands/json_toggle.d.ts +0 -7
  407. package/types/pkg/commands/json_type.d.ts +0 -7
  408. package/types/pkg/commands/keys.d.ts +0 -7
  409. package/types/pkg/commands/lindex.d.ts +0 -4
  410. package/types/pkg/commands/linsert.d.ts +0 -9
  411. package/types/pkg/commands/llen.d.ts +0 -7
  412. package/types/pkg/commands/lmove.d.ts +0 -12
  413. package/types/pkg/commands/lpop.d.ts +0 -7
  414. package/types/pkg/commands/lpos.d.ts +0 -15
  415. package/types/pkg/commands/lpush.d.ts +0 -7
  416. package/types/pkg/commands/lpushx.d.ts +0 -7
  417. package/types/pkg/commands/lrange.d.ts +0 -4
  418. package/types/pkg/commands/lrem.d.ts +0 -4
  419. package/types/pkg/commands/lset.d.ts +0 -4
  420. package/types/pkg/commands/ltrim.d.ts +0 -4
  421. package/types/pkg/commands/mget.d.ts +0 -7
  422. package/types/pkg/commands/mod.d.ts +0 -140
  423. package/types/pkg/commands/mset.d.ts +0 -9
  424. package/types/pkg/commands/msetnx.d.ts +0 -9
  425. package/types/pkg/commands/persist.d.ts +0 -7
  426. package/types/pkg/commands/pexpire.d.ts +0 -7
  427. package/types/pkg/commands/pexpireat.d.ts +0 -7
  428. package/types/pkg/commands/ping.d.ts +0 -7
  429. package/types/pkg/commands/psetex.d.ts +0 -7
  430. package/types/pkg/commands/pttl.d.ts +0 -7
  431. package/types/pkg/commands/publish.d.ts +0 -7
  432. package/types/pkg/commands/randomkey.d.ts +0 -7
  433. package/types/pkg/commands/rename.d.ts +0 -7
  434. package/types/pkg/commands/renamenx.d.ts +0 -7
  435. package/types/pkg/commands/rpop.d.ts +0 -7
  436. package/types/pkg/commands/rpush.d.ts +0 -7
  437. package/types/pkg/commands/rpushx.d.ts +0 -7
  438. package/types/pkg/commands/sadd.d.ts +0 -7
  439. package/types/pkg/commands/scan.d.ts +0 -18
  440. package/types/pkg/commands/scard.d.ts +0 -7
  441. package/types/pkg/commands/script_exists.d.ts +0 -7
  442. package/types/pkg/commands/script_flush.d.ts +0 -14
  443. package/types/pkg/commands/script_load.d.ts +0 -7
  444. package/types/pkg/commands/sdiff.d.ts +0 -7
  445. package/types/pkg/commands/sdiffstore.d.ts +0 -7
  446. package/types/pkg/commands/set.d.ts +0 -55
  447. package/types/pkg/commands/setbit.d.ts +0 -7
  448. package/types/pkg/commands/setex.d.ts +0 -7
  449. package/types/pkg/commands/setnx.d.ts +0 -7
  450. package/types/pkg/commands/setrange.d.ts +0 -7
  451. package/types/pkg/commands/sinter.d.ts +0 -7
  452. package/types/pkg/commands/sinterstore.d.ts +0 -7
  453. package/types/pkg/commands/sismember.d.ts +0 -7
  454. package/types/pkg/commands/smembers.d.ts +0 -7
  455. package/types/pkg/commands/smismember.d.ts +0 -7
  456. package/types/pkg/commands/smove.d.ts +0 -7
  457. package/types/pkg/commands/spop.d.ts +0 -7
  458. package/types/pkg/commands/srandmember.d.ts +0 -7
  459. package/types/pkg/commands/srem.d.ts +0 -7
  460. package/types/pkg/commands/sscan.d.ts +0 -24
  461. package/types/pkg/commands/strlen.d.ts +0 -7
  462. package/types/pkg/commands/sunion.d.ts +0 -7
  463. package/types/pkg/commands/sunionstore.d.ts +0 -7
  464. package/types/pkg/commands/time.d.ts +0 -7
  465. package/types/pkg/commands/touch.d.ts +0 -7
  466. package/types/pkg/commands/ttl.d.ts +0 -7
  467. package/types/pkg/commands/type.d.ts +0 -8
  468. package/types/pkg/commands/unlink.d.ts +0 -7
  469. package/types/pkg/commands/zadd.d.ts +0 -35
  470. package/types/pkg/commands/zcard.d.ts +0 -7
  471. package/types/pkg/commands/zcount.d.ts +0 -7
  472. package/types/pkg/commands/zdiffstore.d.ts +0 -7
  473. package/types/pkg/commands/zincrby.d.ts +0 -7
  474. package/types/pkg/commands/zinterstore.d.ts +0 -30
  475. package/types/pkg/commands/zlexcount.d.ts +0 -7
  476. package/types/pkg/commands/zmscore.d.ts +0 -7
  477. package/types/pkg/commands/zpopmax.d.ts +0 -7
  478. package/types/pkg/commands/zpopmin.d.ts +0 -7
  479. package/types/pkg/commands/zrange.d.ts +0 -42
  480. package/types/pkg/commands/zrank.d.ts +0 -7
  481. package/types/pkg/commands/zrem.d.ts +0 -7
  482. package/types/pkg/commands/zremrangebylex.d.ts +0 -7
  483. package/types/pkg/commands/zremrangebyrank.d.ts +0 -7
  484. package/types/pkg/commands/zremrangebyscore.d.ts +0 -7
  485. package/types/pkg/commands/zrevrank.d.ts +0 -7
  486. package/types/pkg/commands/zscan.d.ts +0 -24
  487. package/types/pkg/commands/zscore.d.ts +0 -7
  488. package/types/pkg/commands/zunionstore.d.ts +0 -30
  489. package/types/pkg/error.d.ts +0 -6
  490. package/types/pkg/http.d.ts +0 -91
  491. package/types/pkg/pipeline.d.ts +0 -603
  492. package/types/pkg/redis.d.ts +0 -658
  493. package/types/pkg/script.d.ts +0 -42
  494. package/types/pkg/types.d.ts +0 -27
  495. package/types/pkg/util.d.ts +0 -1
  496. package/types/platforms/cloudflare.d.ts +0 -43
  497. package/types/platforms/fastly.d.ts +0 -41
  498. package/types/platforms/node_with_fetch.d.ts +0 -63
  499. package/types/platforms/nodejs.d.ts +0 -78
  500. package/types/version.d.ts +0 -1
package/nodejs.js ADDED
@@ -0,0 +1,4229 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // platforms/nodejs.ts
31
+ var nodejs_exports = {};
32
+ __export(nodejs_exports, {
33
+ Redis: () => Redis2,
34
+ errors: () => error_exports
35
+ });
36
+ module.exports = __toCommonJS(nodejs_exports);
37
+
38
+ // pkg/error.ts
39
+ var error_exports = {};
40
+ __export(error_exports, {
41
+ UpstashError: () => UpstashError,
42
+ UrlError: () => UrlError
43
+ });
44
+ var UpstashError = class extends Error {
45
+ constructor(message) {
46
+ super(message);
47
+ this.name = "UpstashError";
48
+ }
49
+ };
50
+ var UrlError = class extends Error {
51
+ constructor(url) {
52
+ super(
53
+ `Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${url}". `
54
+ );
55
+ this.name = "UrlError";
56
+ }
57
+ };
58
+
59
+ // pkg/util.ts
60
+ function parseRecursive(obj) {
61
+ const parsed = Array.isArray(obj) ? obj.map((o) => {
62
+ try {
63
+ return parseRecursive(o);
64
+ } catch {
65
+ return o;
66
+ }
67
+ }) : JSON.parse(obj);
68
+ if (typeof parsed === "number" && parsed.toString() !== obj) {
69
+ return obj;
70
+ }
71
+ return parsed;
72
+ }
73
+ function parseResponse(result) {
74
+ try {
75
+ return parseRecursive(result);
76
+ } catch {
77
+ return result;
78
+ }
79
+ }
80
+ function deserializeScanResponse(result) {
81
+ return [result[0], ...parseResponse(result.slice(1))];
82
+ }
83
+ function mergeHeaders(...headers) {
84
+ const merged = {};
85
+ for (const header of headers) {
86
+ if (!header) continue;
87
+ for (const [key, value] of Object.entries(header)) {
88
+ if (value !== void 0 && value !== null) {
89
+ merged[key] = value;
90
+ }
91
+ }
92
+ }
93
+ return merged;
94
+ }
95
+
96
+ // pkg/http.ts
97
+ var HttpClient = class {
98
+ baseUrl;
99
+ headers;
100
+ options;
101
+ readYourWrites;
102
+ upstashSyncToken = "";
103
+ hasCredentials;
104
+ retry;
105
+ constructor(config) {
106
+ this.options = {
107
+ backend: config.options?.backend,
108
+ agent: config.agent,
109
+ responseEncoding: config.responseEncoding ?? "base64",
110
+ // default to base64
111
+ cache: config.cache,
112
+ signal: config.signal,
113
+ keepAlive: config.keepAlive ?? true
114
+ };
115
+ this.upstashSyncToken = "";
116
+ this.readYourWrites = config.readYourWrites ?? true;
117
+ this.baseUrl = (config.baseUrl || "").replace(/\/$/, "");
118
+ const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
119
+ if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
120
+ throw new UrlError(this.baseUrl);
121
+ }
122
+ this.headers = {
123
+ "Content-Type": "application/json",
124
+ ...config.headers
125
+ };
126
+ this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
127
+ if (this.options.responseEncoding === "base64") {
128
+ this.headers["Upstash-Encoding"] = "base64";
129
+ }
130
+ this.retry = typeof config.retry === "boolean" && !config.retry ? {
131
+ attempts: 1,
132
+ backoff: () => 0
133
+ } : {
134
+ attempts: config.retry?.retries ?? 5,
135
+ backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
136
+ };
137
+ }
138
+ mergeTelemetry(telemetry) {
139
+ this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
140
+ this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
141
+ this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
142
+ }
143
+ async request(req) {
144
+ const requestHeaders = mergeHeaders(this.headers, req.headers ?? {});
145
+ const requestUrl = [this.baseUrl, ...req.path ?? []].join("/");
146
+ const isEventStream = requestHeaders.Accept === "text/event-stream";
147
+ const requestOptions = {
148
+ //@ts-expect-error this should throw due to bun regression
149
+ cache: this.options.cache,
150
+ method: "POST",
151
+ headers: requestHeaders,
152
+ body: JSON.stringify(req.body),
153
+ keepalive: this.options.keepAlive,
154
+ agent: this.options.agent,
155
+ signal: req.signal ?? this.options.signal,
156
+ /**
157
+ * Fastly specific
158
+ */
159
+ backend: this.options.backend
160
+ };
161
+ if (!this.hasCredentials) {
162
+ console.warn(
163
+ "[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
164
+ );
165
+ }
166
+ if (this.readYourWrites) {
167
+ const newHeader = this.upstashSyncToken;
168
+ this.headers["upstash-sync-token"] = newHeader;
169
+ }
170
+ let res = null;
171
+ let error = null;
172
+ for (let i = 0; i <= this.retry.attempts; i++) {
173
+ try {
174
+ res = await fetch(requestUrl, requestOptions);
175
+ break;
176
+ } catch (error_) {
177
+ if (this.options.signal?.aborted) {
178
+ const myBlob = new Blob([
179
+ JSON.stringify({ result: this.options.signal.reason ?? "Aborted" })
180
+ ]);
181
+ const myOptions = {
182
+ status: 200,
183
+ statusText: this.options.signal.reason ?? "Aborted"
184
+ };
185
+ res = new Response(myBlob, myOptions);
186
+ break;
187
+ }
188
+ error = error_;
189
+ if (i < this.retry.attempts) {
190
+ await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
191
+ }
192
+ }
193
+ }
194
+ if (!res) {
195
+ throw error ?? new Error("Exhausted all retries");
196
+ }
197
+ if (!res.ok) {
198
+ const body2 = await res.json();
199
+ throw new UpstashError(`${body2.error}, command was: ${JSON.stringify(req.body)}`);
200
+ }
201
+ if (this.readYourWrites) {
202
+ const headers = res.headers;
203
+ this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
204
+ }
205
+ if (isEventStream && req && req.onMessage && res.body) {
206
+ const reader = res.body.getReader();
207
+ const decoder = new TextDecoder();
208
+ (async () => {
209
+ try {
210
+ while (true) {
211
+ const { value, done } = await reader.read();
212
+ if (done) break;
213
+ const chunk = decoder.decode(value);
214
+ const lines = chunk.split("\n");
215
+ for (const line of lines) {
216
+ if (line.startsWith("data: ")) {
217
+ const data = line.slice(6);
218
+ req.onMessage?.(data);
219
+ }
220
+ }
221
+ }
222
+ } catch (error2) {
223
+ if (error2 instanceof Error && error2.name === "AbortError") {
224
+ } else {
225
+ console.error("Stream reading error:", error2);
226
+ }
227
+ } finally {
228
+ try {
229
+ await reader.cancel();
230
+ } catch {
231
+ }
232
+ }
233
+ })();
234
+ return { result: 1 };
235
+ }
236
+ const body = await res.json();
237
+ if (this.readYourWrites) {
238
+ const headers = res.headers;
239
+ this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
240
+ }
241
+ if (this.options.responseEncoding === "base64") {
242
+ if (Array.isArray(body)) {
243
+ return body.map(({ result: result2, error: error2 }) => ({
244
+ result: decode(result2),
245
+ error: error2
246
+ }));
247
+ }
248
+ const result = decode(body.result);
249
+ return { result, error: body.error };
250
+ }
251
+ return body;
252
+ }
253
+ };
254
+ function base64decode(b64) {
255
+ let dec = "";
256
+ try {
257
+ const binString = atob(b64);
258
+ const size = binString.length;
259
+ const bytes = new Uint8Array(size);
260
+ for (let i = 0; i < size; i++) {
261
+ bytes[i] = binString.charCodeAt(i);
262
+ }
263
+ dec = new TextDecoder().decode(bytes);
264
+ } catch {
265
+ dec = b64;
266
+ }
267
+ return dec;
268
+ }
269
+ function decode(raw) {
270
+ let result = void 0;
271
+ switch (typeof raw) {
272
+ case "undefined": {
273
+ return raw;
274
+ }
275
+ case "number": {
276
+ result = raw;
277
+ break;
278
+ }
279
+ case "object": {
280
+ if (Array.isArray(raw)) {
281
+ result = raw.map(
282
+ (v) => typeof v === "string" ? base64decode(v) : Array.isArray(v) ? v.map((element) => decode(element)) : v
283
+ );
284
+ } else {
285
+ result = null;
286
+ }
287
+ break;
288
+ }
289
+ case "string": {
290
+ result = raw === "OK" ? "OK" : base64decode(raw);
291
+ break;
292
+ }
293
+ default: {
294
+ break;
295
+ }
296
+ }
297
+ return result;
298
+ }
299
+ function merge(obj, key, value) {
300
+ if (!value) {
301
+ return obj;
302
+ }
303
+ obj[key] = obj[key] ? [obj[key], value].join(",") : value;
304
+ return obj;
305
+ }
306
+
307
+ // pkg/auto-pipeline.ts
308
+ function createAutoPipelineProxy(_redis, json) {
309
+ const redis = _redis;
310
+ if (!redis.autoPipelineExecutor) {
311
+ redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
312
+ }
313
+ return new Proxy(redis, {
314
+ get: (redis2, command) => {
315
+ if (command === "pipelineCounter") {
316
+ return redis2.autoPipelineExecutor.pipelineCounter;
317
+ }
318
+ if (command === "json") {
319
+ return createAutoPipelineProxy(redis2, true);
320
+ }
321
+ const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
322
+ if (commandInRedisButNotPipeline) {
323
+ return redis2[command];
324
+ }
325
+ const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
326
+ if (isFunction) {
327
+ return (...args) => {
328
+ return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
329
+ if (json) {
330
+ pipeline.json[command](
331
+ ...args
332
+ );
333
+ } else {
334
+ pipeline[command](...args);
335
+ }
336
+ });
337
+ };
338
+ }
339
+ return redis2.autoPipelineExecutor.pipeline[command];
340
+ }
341
+ });
342
+ }
343
+ var AutoPipelineExecutor = class {
344
+ pipelinePromises = /* @__PURE__ */ new WeakMap();
345
+ activePipeline = null;
346
+ indexInCurrentPipeline = 0;
347
+ redis;
348
+ pipeline;
349
+ // only to make sure that proxy can work
350
+ pipelineCounter = 0;
351
+ // to keep track of how many times a pipeline was executed
352
+ constructor(redis) {
353
+ this.redis = redis;
354
+ this.pipeline = redis.pipeline();
355
+ }
356
+ async withAutoPipeline(executeWithPipeline) {
357
+ const pipeline = this.activePipeline ?? this.redis.pipeline();
358
+ if (!this.activePipeline) {
359
+ this.activePipeline = pipeline;
360
+ this.indexInCurrentPipeline = 0;
361
+ }
362
+ const index = this.indexInCurrentPipeline++;
363
+ executeWithPipeline(pipeline);
364
+ const pipelineDone = this.deferExecution().then(() => {
365
+ if (!this.pipelinePromises.has(pipeline)) {
366
+ const pipelinePromise = pipeline.exec({ keepErrors: true });
367
+ this.pipelineCounter += 1;
368
+ this.pipelinePromises.set(pipeline, pipelinePromise);
369
+ this.activePipeline = null;
370
+ }
371
+ return this.pipelinePromises.get(pipeline);
372
+ });
373
+ const results = await pipelineDone;
374
+ const commandResult = results[index];
375
+ if (commandResult.error) {
376
+ throw new UpstashError(`Command failed: ${commandResult.error}`);
377
+ }
378
+ return commandResult.result;
379
+ }
380
+ async deferExecution() {
381
+ await Promise.resolve();
382
+ await Promise.resolve();
383
+ }
384
+ };
385
+
386
+ // pkg/commands/command.ts
387
+ var defaultSerializer = (c) => {
388
+ switch (typeof c) {
389
+ case "string":
390
+ case "number":
391
+ case "boolean": {
392
+ return c;
393
+ }
394
+ default: {
395
+ return JSON.stringify(c);
396
+ }
397
+ }
398
+ };
399
+ var Command = class {
400
+ command;
401
+ serialize;
402
+ deserialize;
403
+ headers;
404
+ path;
405
+ onMessage;
406
+ isStreaming;
407
+ signal;
408
+ /**
409
+ * Create a new command instance.
410
+ *
411
+ * You can define a custom `deserialize` function. By default we try to deserialize as json.
412
+ */
413
+ constructor(command, opts) {
414
+ this.serialize = defaultSerializer;
415
+ this.deserialize = opts?.automaticDeserialization === void 0 || opts.automaticDeserialization ? opts?.deserialize ?? parseResponse : (x) => x;
416
+ this.command = command.map((c) => this.serialize(c));
417
+ this.headers = opts?.headers;
418
+ this.path = opts?.path;
419
+ this.onMessage = opts?.streamOptions?.onMessage;
420
+ this.isStreaming = opts?.streamOptions?.isStreaming ?? false;
421
+ this.signal = opts?.streamOptions?.signal;
422
+ if (opts?.latencyLogging) {
423
+ const originalExec = this.exec.bind(this);
424
+ this.exec = async (client) => {
425
+ const start = performance.now();
426
+ const result = await originalExec(client);
427
+ const end = performance.now();
428
+ const loggerResult = (end - start).toFixed(2);
429
+ console.log(
430
+ `Latency for \x1B[38;2;19;185;39m${this.command[0].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
431
+ );
432
+ return result;
433
+ };
434
+ }
435
+ }
436
+ /**
437
+ * Execute the command using a client.
438
+ */
439
+ async exec(client) {
440
+ const { result, error } = await client.request({
441
+ body: this.command,
442
+ path: this.path,
443
+ upstashSyncToken: client.upstashSyncToken,
444
+ headers: this.headers,
445
+ onMessage: this.onMessage,
446
+ isStreaming: this.isStreaming,
447
+ signal: this.signal
448
+ });
449
+ if (error) {
450
+ throw new UpstashError(error);
451
+ }
452
+ if (result === void 0) {
453
+ throw new TypeError("Request did not return a result");
454
+ }
455
+ return this.deserialize(result);
456
+ }
457
+ };
458
+
459
+ // pkg/commands/append.ts
460
+ var AppendCommand = class extends Command {
461
+ constructor(cmd, opts) {
462
+ super(["append", ...cmd], opts);
463
+ }
464
+ };
465
+
466
+ // pkg/commands/bitcount.ts
467
+ var BitCountCommand = class extends Command {
468
+ constructor([key, start, end], opts) {
469
+ const command = ["bitcount", key];
470
+ if (typeof start === "number") {
471
+ command.push(start);
472
+ }
473
+ if (typeof end === "number") {
474
+ command.push(end);
475
+ }
476
+ super(command, opts);
477
+ }
478
+ };
479
+
480
+ // pkg/commands/bitfield.ts
481
+ var BitFieldCommand = class {
482
+ constructor(args, client, opts, execOperation = (command) => command.exec(this.client)) {
483
+ this.client = client;
484
+ this.opts = opts;
485
+ this.execOperation = execOperation;
486
+ this.command = ["bitfield", ...args];
487
+ }
488
+ command;
489
+ chain(...args) {
490
+ this.command.push(...args);
491
+ return this;
492
+ }
493
+ get(...args) {
494
+ return this.chain("get", ...args);
495
+ }
496
+ set(...args) {
497
+ return this.chain("set", ...args);
498
+ }
499
+ incrby(...args) {
500
+ return this.chain("incrby", ...args);
501
+ }
502
+ overflow(overflow) {
503
+ return this.chain("overflow", overflow);
504
+ }
505
+ exec() {
506
+ const command = new Command(this.command, this.opts);
507
+ return this.execOperation(command);
508
+ }
509
+ };
510
+
511
+ // pkg/commands/bitop.ts
512
+ var BitOpCommand = class extends Command {
513
+ constructor(cmd, opts) {
514
+ super(["bitop", ...cmd], opts);
515
+ }
516
+ };
517
+
518
+ // pkg/commands/bitpos.ts
519
+ var BitPosCommand = class extends Command {
520
+ constructor(cmd, opts) {
521
+ super(["bitpos", ...cmd], opts);
522
+ }
523
+ };
524
+
525
+ // pkg/commands/copy.ts
526
+ var CopyCommand = class extends Command {
527
+ constructor([key, destinationKey, opts], commandOptions) {
528
+ super(["COPY", key, destinationKey, ...opts?.replace ? ["REPLACE"] : []], {
529
+ ...commandOptions,
530
+ deserialize(result) {
531
+ if (result > 0) {
532
+ return "COPIED";
533
+ }
534
+ return "NOT_COPIED";
535
+ }
536
+ });
537
+ }
538
+ };
539
+
540
+ // pkg/commands/dbsize.ts
541
+ var DBSizeCommand = class extends Command {
542
+ constructor(opts) {
543
+ super(["dbsize"], opts);
544
+ }
545
+ };
546
+
547
+ // pkg/commands/decr.ts
548
+ var DecrCommand = class extends Command {
549
+ constructor(cmd, opts) {
550
+ super(["decr", ...cmd], opts);
551
+ }
552
+ };
553
+
554
+ // pkg/commands/decrby.ts
555
+ var DecrByCommand = class extends Command {
556
+ constructor(cmd, opts) {
557
+ super(["decrby", ...cmd], opts);
558
+ }
559
+ };
560
+
561
+ // pkg/commands/del.ts
562
+ var DelCommand = class extends Command {
563
+ constructor(cmd, opts) {
564
+ super(["del", ...cmd], opts);
565
+ }
566
+ };
567
+
568
+ // pkg/commands/echo.ts
569
+ var EchoCommand = class extends Command {
570
+ constructor(cmd, opts) {
571
+ super(["echo", ...cmd], opts);
572
+ }
573
+ };
574
+
575
+ // pkg/commands/eval.ts
576
+ var EvalCommand = class extends Command {
577
+ constructor([script, keys, args], opts) {
578
+ super(["eval", script, keys.length, ...keys, ...args ?? []], opts);
579
+ }
580
+ };
581
+
582
+ // pkg/commands/evalsha.ts
583
+ var EvalshaCommand = class extends Command {
584
+ constructor([sha, keys, args], opts) {
585
+ super(["evalsha", sha, keys.length, ...keys, ...args ?? []], opts);
586
+ }
587
+ };
588
+
589
+ // pkg/commands/exec.ts
590
+ var ExecCommand = class extends Command {
591
+ constructor(cmd, opts) {
592
+ const normalizedCmd = cmd.map((arg) => typeof arg === "string" ? arg : String(arg));
593
+ super(normalizedCmd, opts);
594
+ }
595
+ };
596
+
597
+ // pkg/commands/exists.ts
598
+ var ExistsCommand = class extends Command {
599
+ constructor(cmd, opts) {
600
+ super(["exists", ...cmd], opts);
601
+ }
602
+ };
603
+
604
+ // pkg/commands/expire.ts
605
+ var ExpireCommand = class extends Command {
606
+ constructor(cmd, opts) {
607
+ super(["expire", ...cmd.filter(Boolean)], opts);
608
+ }
609
+ };
610
+
611
+ // pkg/commands/expireat.ts
612
+ var ExpireAtCommand = class extends Command {
613
+ constructor(cmd, opts) {
614
+ super(["expireat", ...cmd], opts);
615
+ }
616
+ };
617
+
618
+ // pkg/commands/flushall.ts
619
+ var FlushAllCommand = class extends Command {
620
+ constructor(args, opts) {
621
+ const command = ["flushall"];
622
+ if (args && args.length > 0 && args[0].async) {
623
+ command.push("async");
624
+ }
625
+ super(command, opts);
626
+ }
627
+ };
628
+
629
+ // pkg/commands/flushdb.ts
630
+ var FlushDBCommand = class extends Command {
631
+ constructor([opts], cmdOpts) {
632
+ const command = ["flushdb"];
633
+ if (opts?.async) {
634
+ command.push("async");
635
+ }
636
+ super(command, cmdOpts);
637
+ }
638
+ };
639
+
640
+ // pkg/commands/geo_add.ts
641
+ var GeoAddCommand = class extends Command {
642
+ constructor([key, arg1, ...arg2], opts) {
643
+ const command = ["geoadd", key];
644
+ if ("nx" in arg1 && arg1.nx) {
645
+ command.push("nx");
646
+ } else if ("xx" in arg1 && arg1.xx) {
647
+ command.push("xx");
648
+ }
649
+ if ("ch" in arg1 && arg1.ch) {
650
+ command.push("ch");
651
+ }
652
+ if ("latitude" in arg1 && arg1.latitude) {
653
+ command.push(arg1.longitude, arg1.latitude, arg1.member);
654
+ }
655
+ command.push(
656
+ ...arg2.flatMap(({ latitude, longitude, member }) => [longitude, latitude, member])
657
+ );
658
+ super(command, opts);
659
+ }
660
+ };
661
+
662
+ // pkg/commands/geo_dist.ts
663
+ var GeoDistCommand = class extends Command {
664
+ constructor([key, member1, member2, unit = "M"], opts) {
665
+ super(["GEODIST", key, member1, member2, unit], opts);
666
+ }
667
+ };
668
+
669
+ // pkg/commands/geo_hash.ts
670
+ var GeoHashCommand = class extends Command {
671
+ constructor(cmd, opts) {
672
+ const [key] = cmd;
673
+ const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
674
+ super(["GEOHASH", key, ...members], opts);
675
+ }
676
+ };
677
+
678
+ // pkg/commands/geo_pos.ts
679
+ var GeoPosCommand = class extends Command {
680
+ constructor(cmd, opts) {
681
+ const [key] = cmd;
682
+ const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
683
+ super(["GEOPOS", key, ...members], {
684
+ deserialize: (result) => transform(result),
685
+ ...opts
686
+ });
687
+ }
688
+ };
689
+ function transform(result) {
690
+ const final = [];
691
+ for (const pos of result) {
692
+ if (!pos?.[0] || !pos?.[1]) {
693
+ continue;
694
+ }
695
+ final.push({ lng: Number.parseFloat(pos[0]), lat: Number.parseFloat(pos[1]) });
696
+ }
697
+ return final;
698
+ }
699
+
700
+ // pkg/commands/geo_search.ts
701
+ var GeoSearchCommand = class extends Command {
702
+ constructor([key, centerPoint, shape, order, opts], commandOptions) {
703
+ const command = ["GEOSEARCH", key];
704
+ if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
705
+ command.push(centerPoint.type, centerPoint.member);
706
+ }
707
+ if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
708
+ command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
709
+ }
710
+ if (shape.type === "BYRADIUS" || shape.type === "byradius") {
711
+ command.push(shape.type, shape.radius, shape.radiusType);
712
+ }
713
+ if (shape.type === "BYBOX" || shape.type === "bybox") {
714
+ command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
715
+ }
716
+ command.push(order);
717
+ if (opts?.count) {
718
+ command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
719
+ }
720
+ const transform2 = (result) => {
721
+ if (!opts?.withCoord && !opts?.withDist && !opts?.withHash) {
722
+ return result.map((member) => {
723
+ try {
724
+ return { member: JSON.parse(member) };
725
+ } catch {
726
+ return { member };
727
+ }
728
+ });
729
+ }
730
+ return result.map((members) => {
731
+ let counter = 1;
732
+ const obj = {};
733
+ try {
734
+ obj.member = JSON.parse(members[0]);
735
+ } catch {
736
+ obj.member = members[0];
737
+ }
738
+ if (opts.withDist) {
739
+ obj.dist = Number.parseFloat(members[counter++]);
740
+ }
741
+ if (opts.withHash) {
742
+ obj.hash = members[counter++].toString();
743
+ }
744
+ if (opts.withCoord) {
745
+ obj.coord = {
746
+ long: Number.parseFloat(members[counter][0]),
747
+ lat: Number.parseFloat(members[counter][1])
748
+ };
749
+ }
750
+ return obj;
751
+ });
752
+ };
753
+ super(
754
+ [
755
+ ...command,
756
+ ...opts?.withCoord ? ["WITHCOORD"] : [],
757
+ ...opts?.withDist ? ["WITHDIST"] : [],
758
+ ...opts?.withHash ? ["WITHHASH"] : []
759
+ ],
760
+ {
761
+ deserialize: transform2,
762
+ ...commandOptions
763
+ }
764
+ );
765
+ }
766
+ };
767
+
768
+ // pkg/commands/geo_search_store.ts
769
+ var GeoSearchStoreCommand = class extends Command {
770
+ constructor([destination, key, centerPoint, shape, order, opts], commandOptions) {
771
+ const command = ["GEOSEARCHSTORE", destination, key];
772
+ if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
773
+ command.push(centerPoint.type, centerPoint.member);
774
+ }
775
+ if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
776
+ command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
777
+ }
778
+ if (shape.type === "BYRADIUS" || shape.type === "byradius") {
779
+ command.push(shape.type, shape.radius, shape.radiusType);
780
+ }
781
+ if (shape.type === "BYBOX" || shape.type === "bybox") {
782
+ command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
783
+ }
784
+ command.push(order);
785
+ if (opts?.count) {
786
+ command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
787
+ }
788
+ super([...command, ...opts?.storeDist ? ["STOREDIST"] : []], commandOptions);
789
+ }
790
+ };
791
+
792
+ // pkg/commands/get.ts
793
+ var GetCommand = class extends Command {
794
+ constructor(cmd, opts) {
795
+ super(["get", ...cmd], opts);
796
+ }
797
+ };
798
+
799
+ // pkg/commands/getbit.ts
800
+ var GetBitCommand = class extends Command {
801
+ constructor(cmd, opts) {
802
+ super(["getbit", ...cmd], opts);
803
+ }
804
+ };
805
+
806
+ // pkg/commands/getdel.ts
807
+ var GetDelCommand = class extends Command {
808
+ constructor(cmd, opts) {
809
+ super(["getdel", ...cmd], opts);
810
+ }
811
+ };
812
+
813
+ // pkg/commands/getex.ts
814
+ var GetExCommand = class extends Command {
815
+ constructor([key, opts], cmdOpts) {
816
+ const command = ["getex", key];
817
+ if (opts) {
818
+ if ("ex" in opts && typeof opts.ex === "number") {
819
+ command.push("ex", opts.ex);
820
+ } else if ("px" in opts && typeof opts.px === "number") {
821
+ command.push("px", opts.px);
822
+ } else if ("exat" in opts && typeof opts.exat === "number") {
823
+ command.push("exat", opts.exat);
824
+ } else if ("pxat" in opts && typeof opts.pxat === "number") {
825
+ command.push("pxat", opts.pxat);
826
+ } else if ("persist" in opts && opts.persist) {
827
+ command.push("persist");
828
+ }
829
+ }
830
+ super(command, cmdOpts);
831
+ }
832
+ };
833
+
834
+ // pkg/commands/getrange.ts
835
+ var GetRangeCommand = class extends Command {
836
+ constructor(cmd, opts) {
837
+ super(["getrange", ...cmd], opts);
838
+ }
839
+ };
840
+
841
+ // pkg/commands/getset.ts
842
+ var GetSetCommand = class extends Command {
843
+ constructor(cmd, opts) {
844
+ super(["getset", ...cmd], opts);
845
+ }
846
+ };
847
+
848
+ // pkg/commands/hdel.ts
849
+ var HDelCommand = class extends Command {
850
+ constructor(cmd, opts) {
851
+ super(["hdel", ...cmd], opts);
852
+ }
853
+ };
854
+
855
+ // pkg/commands/hexists.ts
856
+ var HExistsCommand = class extends Command {
857
+ constructor(cmd, opts) {
858
+ super(["hexists", ...cmd], opts);
859
+ }
860
+ };
861
+
862
+ // pkg/commands/hget.ts
863
+ var HGetCommand = class extends Command {
864
+ constructor(cmd, opts) {
865
+ super(["hget", ...cmd], opts);
866
+ }
867
+ };
868
+
869
+ // pkg/commands/hgetall.ts
870
+ function deserialize(result) {
871
+ if (result.length === 0) {
872
+ return null;
873
+ }
874
+ const obj = {};
875
+ while (result.length >= 2) {
876
+ const key = result.shift();
877
+ const value = result.shift();
878
+ try {
879
+ const valueIsNumberAndNotSafeInteger = !Number.isNaN(Number(value)) && !Number.isSafeInteger(Number(value));
880
+ obj[key] = valueIsNumberAndNotSafeInteger ? value : JSON.parse(value);
881
+ } catch {
882
+ obj[key] = value;
883
+ }
884
+ }
885
+ return obj;
886
+ }
887
+ var HGetAllCommand = class extends Command {
888
+ constructor(cmd, opts) {
889
+ super(["hgetall", ...cmd], {
890
+ deserialize: (result) => deserialize(result),
891
+ ...opts
892
+ });
893
+ }
894
+ };
895
+
896
+ // pkg/commands/hincrby.ts
897
+ var HIncrByCommand = class extends Command {
898
+ constructor(cmd, opts) {
899
+ super(["hincrby", ...cmd], opts);
900
+ }
901
+ };
902
+
903
+ // pkg/commands/hincrbyfloat.ts
904
+ var HIncrByFloatCommand = class extends Command {
905
+ constructor(cmd, opts) {
906
+ super(["hincrbyfloat", ...cmd], opts);
907
+ }
908
+ };
909
+
910
+ // pkg/commands/hkeys.ts
911
+ var HKeysCommand = class extends Command {
912
+ constructor([key], opts) {
913
+ super(["hkeys", key], opts);
914
+ }
915
+ };
916
+
917
+ // pkg/commands/hlen.ts
918
+ var HLenCommand = class extends Command {
919
+ constructor(cmd, opts) {
920
+ super(["hlen", ...cmd], opts);
921
+ }
922
+ };
923
+
924
+ // pkg/commands/hmget.ts
925
+ function deserialize2(fields, result) {
926
+ if (result.every((field) => field === null)) {
927
+ return null;
928
+ }
929
+ const obj = {};
930
+ for (const [i, field] of fields.entries()) {
931
+ try {
932
+ obj[field] = JSON.parse(result[i]);
933
+ } catch {
934
+ obj[field] = result[i];
935
+ }
936
+ }
937
+ return obj;
938
+ }
939
+ var HMGetCommand = class extends Command {
940
+ constructor([key, ...fields], opts) {
941
+ super(["hmget", key, ...fields], {
942
+ deserialize: (result) => deserialize2(fields, result),
943
+ ...opts
944
+ });
945
+ }
946
+ };
947
+
948
+ // pkg/commands/hmset.ts
949
+ var HMSetCommand = class extends Command {
950
+ constructor([key, kv], opts) {
951
+ super(["hmset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
952
+ }
953
+ };
954
+
955
+ // pkg/commands/hrandfield.ts
956
+ function deserialize3(result) {
957
+ if (result.length === 0) {
958
+ return null;
959
+ }
960
+ const obj = {};
961
+ while (result.length >= 2) {
962
+ const key = result.shift();
963
+ const value = result.shift();
964
+ try {
965
+ obj[key] = JSON.parse(value);
966
+ } catch {
967
+ obj[key] = value;
968
+ }
969
+ }
970
+ return obj;
971
+ }
972
+ var HRandFieldCommand = class extends Command {
973
+ constructor(cmd, opts) {
974
+ const command = ["hrandfield", cmd[0]];
975
+ if (typeof cmd[1] === "number") {
976
+ command.push(cmd[1]);
977
+ }
978
+ if (cmd[2]) {
979
+ command.push("WITHVALUES");
980
+ }
981
+ super(command, {
982
+ // @ts-expect-error to silence compiler
983
+ deserialize: cmd[2] ? (result) => deserialize3(result) : opts?.deserialize,
984
+ ...opts
985
+ });
986
+ }
987
+ };
988
+
989
+ // pkg/commands/hscan.ts
990
+ var HScanCommand = class extends Command {
991
+ constructor([key, cursor, cmdOpts], opts) {
992
+ const command = ["hscan", key, cursor];
993
+ if (cmdOpts?.match) {
994
+ command.push("match", cmdOpts.match);
995
+ }
996
+ if (typeof cmdOpts?.count === "number") {
997
+ command.push("count", cmdOpts.count);
998
+ }
999
+ super(command, {
1000
+ deserialize: deserializeScanResponse,
1001
+ ...opts
1002
+ });
1003
+ }
1004
+ };
1005
+
1006
+ // pkg/commands/hset.ts
1007
+ var HSetCommand = class extends Command {
1008
+ constructor([key, kv], opts) {
1009
+ super(["hset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
1010
+ }
1011
+ };
1012
+
1013
+ // pkg/commands/hsetnx.ts
1014
+ var HSetNXCommand = class extends Command {
1015
+ constructor(cmd, opts) {
1016
+ super(["hsetnx", ...cmd], opts);
1017
+ }
1018
+ };
1019
+
1020
+ // pkg/commands/hstrlen.ts
1021
+ var HStrLenCommand = class extends Command {
1022
+ constructor(cmd, opts) {
1023
+ super(["hstrlen", ...cmd], opts);
1024
+ }
1025
+ };
1026
+
1027
+ // pkg/commands/hvals.ts
1028
+ var HValsCommand = class extends Command {
1029
+ constructor(cmd, opts) {
1030
+ super(["hvals", ...cmd], opts);
1031
+ }
1032
+ };
1033
+
1034
+ // pkg/commands/incr.ts
1035
+ var IncrCommand = class extends Command {
1036
+ constructor(cmd, opts) {
1037
+ super(["incr", ...cmd], opts);
1038
+ }
1039
+ };
1040
+
1041
+ // pkg/commands/incrby.ts
1042
+ var IncrByCommand = class extends Command {
1043
+ constructor(cmd, opts) {
1044
+ super(["incrby", ...cmd], opts);
1045
+ }
1046
+ };
1047
+
1048
+ // pkg/commands/incrbyfloat.ts
1049
+ var IncrByFloatCommand = class extends Command {
1050
+ constructor(cmd, opts) {
1051
+ super(["incrbyfloat", ...cmd], opts);
1052
+ }
1053
+ };
1054
+
1055
+ // pkg/commands/json_arrappend.ts
1056
+ var JsonArrAppendCommand = class extends Command {
1057
+ constructor(cmd, opts) {
1058
+ super(["JSON.ARRAPPEND", ...cmd], opts);
1059
+ }
1060
+ };
1061
+
1062
+ // pkg/commands/json_arrindex.ts
1063
+ var JsonArrIndexCommand = class extends Command {
1064
+ constructor(cmd, opts) {
1065
+ super(["JSON.ARRINDEX", ...cmd], opts);
1066
+ }
1067
+ };
1068
+
1069
+ // pkg/commands/json_arrinsert.ts
1070
+ var JsonArrInsertCommand = class extends Command {
1071
+ constructor(cmd, opts) {
1072
+ super(["JSON.ARRINSERT", ...cmd], opts);
1073
+ }
1074
+ };
1075
+
1076
+ // pkg/commands/json_arrlen.ts
1077
+ var JsonArrLenCommand = class extends Command {
1078
+ constructor(cmd, opts) {
1079
+ super(["JSON.ARRLEN", cmd[0], cmd[1] ?? "$"], opts);
1080
+ }
1081
+ };
1082
+
1083
+ // pkg/commands/json_arrpop.ts
1084
+ var JsonArrPopCommand = class extends Command {
1085
+ constructor(cmd, opts) {
1086
+ super(["JSON.ARRPOP", ...cmd], opts);
1087
+ }
1088
+ };
1089
+
1090
+ // pkg/commands/json_arrtrim.ts
1091
+ var JsonArrTrimCommand = class extends Command {
1092
+ constructor(cmd, opts) {
1093
+ const path = cmd[1] ?? "$";
1094
+ const start = cmd[2] ?? 0;
1095
+ const stop = cmd[3] ?? 0;
1096
+ super(["JSON.ARRTRIM", cmd[0], path, start, stop], opts);
1097
+ }
1098
+ };
1099
+
1100
+ // pkg/commands/json_clear.ts
1101
+ var JsonClearCommand = class extends Command {
1102
+ constructor(cmd, opts) {
1103
+ super(["JSON.CLEAR", ...cmd], opts);
1104
+ }
1105
+ };
1106
+
1107
+ // pkg/commands/json_del.ts
1108
+ var JsonDelCommand = class extends Command {
1109
+ constructor(cmd, opts) {
1110
+ super(["JSON.DEL", ...cmd], opts);
1111
+ }
1112
+ };
1113
+
1114
+ // pkg/commands/json_forget.ts
1115
+ var JsonForgetCommand = class extends Command {
1116
+ constructor(cmd, opts) {
1117
+ super(["JSON.FORGET", ...cmd], opts);
1118
+ }
1119
+ };
1120
+
1121
+ // pkg/commands/json_get.ts
1122
+ var JsonGetCommand = class extends Command {
1123
+ constructor(cmd, opts) {
1124
+ const command = ["JSON.GET"];
1125
+ if (typeof cmd[1] === "string") {
1126
+ command.push(...cmd);
1127
+ } else {
1128
+ command.push(cmd[0]);
1129
+ if (cmd[1]) {
1130
+ if (cmd[1].indent) {
1131
+ command.push("INDENT", cmd[1].indent);
1132
+ }
1133
+ if (cmd[1].newline) {
1134
+ command.push("NEWLINE", cmd[1].newline);
1135
+ }
1136
+ if (cmd[1].space) {
1137
+ command.push("SPACE", cmd[1].space);
1138
+ }
1139
+ }
1140
+ command.push(...cmd.slice(2));
1141
+ }
1142
+ super(command, opts);
1143
+ }
1144
+ };
1145
+
1146
+ // pkg/commands/json_mget.ts
1147
+ var JsonMGetCommand = class extends Command {
1148
+ constructor(cmd, opts) {
1149
+ super(["JSON.MGET", ...cmd[0], cmd[1]], opts);
1150
+ }
1151
+ };
1152
+
1153
+ // pkg/commands/json_mset.ts
1154
+ var JsonMSetCommand = class extends Command {
1155
+ constructor(cmd, opts) {
1156
+ const command = ["JSON.MSET"];
1157
+ for (const c of cmd) {
1158
+ command.push(c.key, c.path, c.value);
1159
+ }
1160
+ super(command, opts);
1161
+ }
1162
+ };
1163
+
1164
+ // pkg/commands/json_numincrby.ts
1165
+ var JsonNumIncrByCommand = class extends Command {
1166
+ constructor(cmd, opts) {
1167
+ super(["JSON.NUMINCRBY", ...cmd], opts);
1168
+ }
1169
+ };
1170
+
1171
+ // pkg/commands/json_nummultby.ts
1172
+ var JsonNumMultByCommand = class extends Command {
1173
+ constructor(cmd, opts) {
1174
+ super(["JSON.NUMMULTBY", ...cmd], opts);
1175
+ }
1176
+ };
1177
+
1178
+ // pkg/commands/json_objkeys.ts
1179
+ var JsonObjKeysCommand = class extends Command {
1180
+ constructor(cmd, opts) {
1181
+ super(["JSON.OBJKEYS", ...cmd], opts);
1182
+ }
1183
+ };
1184
+
1185
+ // pkg/commands/json_objlen.ts
1186
+ var JsonObjLenCommand = class extends Command {
1187
+ constructor(cmd, opts) {
1188
+ super(["JSON.OBJLEN", ...cmd], opts);
1189
+ }
1190
+ };
1191
+
1192
+ // pkg/commands/json_resp.ts
1193
+ var JsonRespCommand = class extends Command {
1194
+ constructor(cmd, opts) {
1195
+ super(["JSON.RESP", ...cmd], opts);
1196
+ }
1197
+ };
1198
+
1199
+ // pkg/commands/json_set.ts
1200
+ var JsonSetCommand = class extends Command {
1201
+ constructor(cmd, opts) {
1202
+ const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]];
1203
+ if (cmd[3]) {
1204
+ if (cmd[3].nx) {
1205
+ command.push("NX");
1206
+ } else if (cmd[3].xx) {
1207
+ command.push("XX");
1208
+ }
1209
+ }
1210
+ super(command, opts);
1211
+ }
1212
+ };
1213
+
1214
+ // pkg/commands/json_strappend.ts
1215
+ var JsonStrAppendCommand = class extends Command {
1216
+ constructor(cmd, opts) {
1217
+ super(["JSON.STRAPPEND", ...cmd], opts);
1218
+ }
1219
+ };
1220
+
1221
+ // pkg/commands/json_strlen.ts
1222
+ var JsonStrLenCommand = class extends Command {
1223
+ constructor(cmd, opts) {
1224
+ super(["JSON.STRLEN", ...cmd], opts);
1225
+ }
1226
+ };
1227
+
1228
+ // pkg/commands/json_toggle.ts
1229
+ var JsonToggleCommand = class extends Command {
1230
+ constructor(cmd, opts) {
1231
+ super(["JSON.TOGGLE", ...cmd], opts);
1232
+ }
1233
+ };
1234
+
1235
+ // pkg/commands/json_type.ts
1236
+ var JsonTypeCommand = class extends Command {
1237
+ constructor(cmd, opts) {
1238
+ super(["JSON.TYPE", ...cmd], opts);
1239
+ }
1240
+ };
1241
+
1242
+ // pkg/commands/keys.ts
1243
+ var KeysCommand = class extends Command {
1244
+ constructor(cmd, opts) {
1245
+ super(["keys", ...cmd], opts);
1246
+ }
1247
+ };
1248
+
1249
+ // pkg/commands/lindex.ts
1250
+ var LIndexCommand = class extends Command {
1251
+ constructor(cmd, opts) {
1252
+ super(["lindex", ...cmd], opts);
1253
+ }
1254
+ };
1255
+
1256
+ // pkg/commands/linsert.ts
1257
+ var LInsertCommand = class extends Command {
1258
+ constructor(cmd, opts) {
1259
+ super(["linsert", ...cmd], opts);
1260
+ }
1261
+ };
1262
+
1263
+ // pkg/commands/llen.ts
1264
+ var LLenCommand = class extends Command {
1265
+ constructor(cmd, opts) {
1266
+ super(["llen", ...cmd], opts);
1267
+ }
1268
+ };
1269
+
1270
+ // pkg/commands/lmove.ts
1271
+ var LMoveCommand = class extends Command {
1272
+ constructor(cmd, opts) {
1273
+ super(["lmove", ...cmd], opts);
1274
+ }
1275
+ };
1276
+
1277
+ // pkg/commands/lmpop.ts
1278
+ var LmPopCommand = class extends Command {
1279
+ constructor(cmd, opts) {
1280
+ const [numkeys, keys, direction, count] = cmd;
1281
+ super(["LMPOP", numkeys, ...keys, direction, ...count ? ["COUNT", count] : []], opts);
1282
+ }
1283
+ };
1284
+
1285
+ // pkg/commands/lpop.ts
1286
+ var LPopCommand = class extends Command {
1287
+ constructor(cmd, opts) {
1288
+ super(["lpop", ...cmd], opts);
1289
+ }
1290
+ };
1291
+
1292
+ // pkg/commands/lpos.ts
1293
+ var LPosCommand = class extends Command {
1294
+ constructor(cmd, opts) {
1295
+ const args = ["lpos", cmd[0], cmd[1]];
1296
+ if (typeof cmd[2]?.rank === "number") {
1297
+ args.push("rank", cmd[2].rank);
1298
+ }
1299
+ if (typeof cmd[2]?.count === "number") {
1300
+ args.push("count", cmd[2].count);
1301
+ }
1302
+ if (typeof cmd[2]?.maxLen === "number") {
1303
+ args.push("maxLen", cmd[2].maxLen);
1304
+ }
1305
+ super(args, opts);
1306
+ }
1307
+ };
1308
+
1309
+ // pkg/commands/lpush.ts
1310
+ var LPushCommand = class extends Command {
1311
+ constructor(cmd, opts) {
1312
+ super(["lpush", ...cmd], opts);
1313
+ }
1314
+ };
1315
+
1316
+ // pkg/commands/lpushx.ts
1317
+ var LPushXCommand = class extends Command {
1318
+ constructor(cmd, opts) {
1319
+ super(["lpushx", ...cmd], opts);
1320
+ }
1321
+ };
1322
+
1323
+ // pkg/commands/lrange.ts
1324
+ var LRangeCommand = class extends Command {
1325
+ constructor(cmd, opts) {
1326
+ super(["lrange", ...cmd], opts);
1327
+ }
1328
+ };
1329
+
1330
+ // pkg/commands/lrem.ts
1331
+ var LRemCommand = class extends Command {
1332
+ constructor(cmd, opts) {
1333
+ super(["lrem", ...cmd], opts);
1334
+ }
1335
+ };
1336
+
1337
+ // pkg/commands/lset.ts
1338
+ var LSetCommand = class extends Command {
1339
+ constructor(cmd, opts) {
1340
+ super(["lset", ...cmd], opts);
1341
+ }
1342
+ };
1343
+
1344
+ // pkg/commands/ltrim.ts
1345
+ var LTrimCommand = class extends Command {
1346
+ constructor(cmd, opts) {
1347
+ super(["ltrim", ...cmd], opts);
1348
+ }
1349
+ };
1350
+
1351
+ // pkg/commands/mget.ts
1352
+ var MGetCommand = class extends Command {
1353
+ constructor(cmd, opts) {
1354
+ const keys = Array.isArray(cmd[0]) ? cmd[0] : cmd;
1355
+ super(["mget", ...keys], opts);
1356
+ }
1357
+ };
1358
+
1359
+ // pkg/commands/mset.ts
1360
+ var MSetCommand = class extends Command {
1361
+ constructor([kv], opts) {
1362
+ super(["mset", ...Object.entries(kv).flatMap(([key, value]) => [key, value])], opts);
1363
+ }
1364
+ };
1365
+
1366
+ // pkg/commands/msetnx.ts
1367
+ var MSetNXCommand = class extends Command {
1368
+ constructor([kv], opts) {
1369
+ super(["msetnx", ...Object.entries(kv).flat()], opts);
1370
+ }
1371
+ };
1372
+
1373
+ // pkg/commands/persist.ts
1374
+ var PersistCommand = class extends Command {
1375
+ constructor(cmd, opts) {
1376
+ super(["persist", ...cmd], opts);
1377
+ }
1378
+ };
1379
+
1380
+ // pkg/commands/pexpire.ts
1381
+ var PExpireCommand = class extends Command {
1382
+ constructor(cmd, opts) {
1383
+ super(["pexpire", ...cmd], opts);
1384
+ }
1385
+ };
1386
+
1387
+ // pkg/commands/pexpireat.ts
1388
+ var PExpireAtCommand = class extends Command {
1389
+ constructor(cmd, opts) {
1390
+ super(["pexpireat", ...cmd], opts);
1391
+ }
1392
+ };
1393
+
1394
+ // pkg/commands/pfadd.ts
1395
+ var PfAddCommand = class extends Command {
1396
+ constructor(cmd, opts) {
1397
+ super(["pfadd", ...cmd], opts);
1398
+ }
1399
+ };
1400
+
1401
+ // pkg/commands/pfcount.ts
1402
+ var PfCountCommand = class extends Command {
1403
+ constructor(cmd, opts) {
1404
+ super(["pfcount", ...cmd], opts);
1405
+ }
1406
+ };
1407
+
1408
+ // pkg/commands/pfmerge.ts
1409
+ var PfMergeCommand = class extends Command {
1410
+ constructor(cmd, opts) {
1411
+ super(["pfmerge", ...cmd], opts);
1412
+ }
1413
+ };
1414
+
1415
+ // pkg/commands/ping.ts
1416
+ var PingCommand = class extends Command {
1417
+ constructor(cmd, opts) {
1418
+ const command = ["ping"];
1419
+ if (cmd?.[0] !== void 0) {
1420
+ command.push(cmd[0]);
1421
+ }
1422
+ super(command, opts);
1423
+ }
1424
+ };
1425
+
1426
+ // pkg/commands/psetex.ts
1427
+ var PSetEXCommand = class extends Command {
1428
+ constructor(cmd, opts) {
1429
+ super(["psetex", ...cmd], opts);
1430
+ }
1431
+ };
1432
+
1433
+ // pkg/commands/pttl.ts
1434
+ var PTtlCommand = class extends Command {
1435
+ constructor(cmd, opts) {
1436
+ super(["pttl", ...cmd], opts);
1437
+ }
1438
+ };
1439
+
1440
+ // pkg/commands/publish.ts
1441
+ var PublishCommand = class extends Command {
1442
+ constructor(cmd, opts) {
1443
+ super(["publish", ...cmd], opts);
1444
+ }
1445
+ };
1446
+
1447
+ // pkg/commands/randomkey.ts
1448
+ var RandomKeyCommand = class extends Command {
1449
+ constructor(opts) {
1450
+ super(["randomkey"], opts);
1451
+ }
1452
+ };
1453
+
1454
+ // pkg/commands/rename.ts
1455
+ var RenameCommand = class extends Command {
1456
+ constructor(cmd, opts) {
1457
+ super(["rename", ...cmd], opts);
1458
+ }
1459
+ };
1460
+
1461
+ // pkg/commands/renamenx.ts
1462
+ var RenameNXCommand = class extends Command {
1463
+ constructor(cmd, opts) {
1464
+ super(["renamenx", ...cmd], opts);
1465
+ }
1466
+ };
1467
+
1468
+ // pkg/commands/rpop.ts
1469
+ var RPopCommand = class extends Command {
1470
+ constructor(cmd, opts) {
1471
+ super(["rpop", ...cmd], opts);
1472
+ }
1473
+ };
1474
+
1475
+ // pkg/commands/rpush.ts
1476
+ var RPushCommand = class extends Command {
1477
+ constructor(cmd, opts) {
1478
+ super(["rpush", ...cmd], opts);
1479
+ }
1480
+ };
1481
+
1482
+ // pkg/commands/rpushx.ts
1483
+ var RPushXCommand = class extends Command {
1484
+ constructor(cmd, opts) {
1485
+ super(["rpushx", ...cmd], opts);
1486
+ }
1487
+ };
1488
+
1489
+ // pkg/commands/sadd.ts
1490
+ var SAddCommand = class extends Command {
1491
+ constructor(cmd, opts) {
1492
+ super(["sadd", ...cmd], opts);
1493
+ }
1494
+ };
1495
+
1496
+ // pkg/commands/scan.ts
1497
+ var ScanCommand = class extends Command {
1498
+ constructor([cursor, opts], cmdOpts) {
1499
+ const command = ["scan", cursor];
1500
+ if (opts?.match) {
1501
+ command.push("match", opts.match);
1502
+ }
1503
+ if (typeof opts?.count === "number") {
1504
+ command.push("count", opts.count);
1505
+ }
1506
+ if (opts?.type && opts.type.length > 0) {
1507
+ command.push("type", opts.type);
1508
+ }
1509
+ super(command, {
1510
+ deserialize: deserializeScanResponse,
1511
+ ...cmdOpts
1512
+ });
1513
+ }
1514
+ };
1515
+
1516
+ // pkg/commands/scard.ts
1517
+ var SCardCommand = class extends Command {
1518
+ constructor(cmd, opts) {
1519
+ super(["scard", ...cmd], opts);
1520
+ }
1521
+ };
1522
+
1523
+ // pkg/commands/script_exists.ts
1524
+ var ScriptExistsCommand = class extends Command {
1525
+ constructor(hashes, opts) {
1526
+ super(["script", "exists", ...hashes], {
1527
+ deserialize: (result) => result,
1528
+ ...opts
1529
+ });
1530
+ }
1531
+ };
1532
+
1533
+ // pkg/commands/script_flush.ts
1534
+ var ScriptFlushCommand = class extends Command {
1535
+ constructor([opts], cmdOpts) {
1536
+ const cmd = ["script", "flush"];
1537
+ if (opts?.sync) {
1538
+ cmd.push("sync");
1539
+ } else if (opts?.async) {
1540
+ cmd.push("async");
1541
+ }
1542
+ super(cmd, cmdOpts);
1543
+ }
1544
+ };
1545
+
1546
+ // pkg/commands/script_load.ts
1547
+ var ScriptLoadCommand = class extends Command {
1548
+ constructor(args, opts) {
1549
+ super(["script", "load", ...args], opts);
1550
+ }
1551
+ };
1552
+
1553
+ // pkg/commands/sdiff.ts
1554
+ var SDiffCommand = class extends Command {
1555
+ constructor(cmd, opts) {
1556
+ super(["sdiff", ...cmd], opts);
1557
+ }
1558
+ };
1559
+
1560
+ // pkg/commands/sdiffstore.ts
1561
+ var SDiffStoreCommand = class extends Command {
1562
+ constructor(cmd, opts) {
1563
+ super(["sdiffstore", ...cmd], opts);
1564
+ }
1565
+ };
1566
+
1567
+ // pkg/commands/set.ts
1568
+ var SetCommand = class extends Command {
1569
+ constructor([key, value, opts], cmdOpts) {
1570
+ const command = ["set", key, value];
1571
+ if (opts) {
1572
+ if ("nx" in opts && opts.nx) {
1573
+ command.push("nx");
1574
+ } else if ("xx" in opts && opts.xx) {
1575
+ command.push("xx");
1576
+ }
1577
+ if ("get" in opts && opts.get) {
1578
+ command.push("get");
1579
+ }
1580
+ if ("ex" in opts && typeof opts.ex === "number") {
1581
+ command.push("ex", opts.ex);
1582
+ } else if ("px" in opts && typeof opts.px === "number") {
1583
+ command.push("px", opts.px);
1584
+ } else if ("exat" in opts && typeof opts.exat === "number") {
1585
+ command.push("exat", opts.exat);
1586
+ } else if ("pxat" in opts && typeof opts.pxat === "number") {
1587
+ command.push("pxat", opts.pxat);
1588
+ } else if ("keepTtl" in opts && opts.keepTtl) {
1589
+ command.push("keepTtl");
1590
+ }
1591
+ }
1592
+ super(command, cmdOpts);
1593
+ }
1594
+ };
1595
+
1596
+ // pkg/commands/setbit.ts
1597
+ var SetBitCommand = class extends Command {
1598
+ constructor(cmd, opts) {
1599
+ super(["setbit", ...cmd], opts);
1600
+ }
1601
+ };
1602
+
1603
+ // pkg/commands/setex.ts
1604
+ var SetExCommand = class extends Command {
1605
+ constructor(cmd, opts) {
1606
+ super(["setex", ...cmd], opts);
1607
+ }
1608
+ };
1609
+
1610
+ // pkg/commands/setnx.ts
1611
+ var SetNxCommand = class extends Command {
1612
+ constructor(cmd, opts) {
1613
+ super(["setnx", ...cmd], opts);
1614
+ }
1615
+ };
1616
+
1617
+ // pkg/commands/setrange.ts
1618
+ var SetRangeCommand = class extends Command {
1619
+ constructor(cmd, opts) {
1620
+ super(["setrange", ...cmd], opts);
1621
+ }
1622
+ };
1623
+
1624
+ // pkg/commands/sinter.ts
1625
+ var SInterCommand = class extends Command {
1626
+ constructor(cmd, opts) {
1627
+ super(["sinter", ...cmd], opts);
1628
+ }
1629
+ };
1630
+
1631
+ // pkg/commands/sinterstore.ts
1632
+ var SInterStoreCommand = class extends Command {
1633
+ constructor(cmd, opts) {
1634
+ super(["sinterstore", ...cmd], opts);
1635
+ }
1636
+ };
1637
+
1638
+ // pkg/commands/sismember.ts
1639
+ var SIsMemberCommand = class extends Command {
1640
+ constructor(cmd, opts) {
1641
+ super(["sismember", ...cmd], opts);
1642
+ }
1643
+ };
1644
+
1645
+ // pkg/commands/smembers.ts
1646
+ var SMembersCommand = class extends Command {
1647
+ constructor(cmd, opts) {
1648
+ super(["smembers", ...cmd], opts);
1649
+ }
1650
+ };
1651
+
1652
+ // pkg/commands/smismember.ts
1653
+ var SMIsMemberCommand = class extends Command {
1654
+ constructor(cmd, opts) {
1655
+ super(["smismember", cmd[0], ...cmd[1]], opts);
1656
+ }
1657
+ };
1658
+
1659
+ // pkg/commands/smove.ts
1660
+ var SMoveCommand = class extends Command {
1661
+ constructor(cmd, opts) {
1662
+ super(["smove", ...cmd], opts);
1663
+ }
1664
+ };
1665
+
1666
+ // pkg/commands/spop.ts
1667
+ var SPopCommand = class extends Command {
1668
+ constructor([key, count], opts) {
1669
+ const command = ["spop", key];
1670
+ if (typeof count === "number") {
1671
+ command.push(count);
1672
+ }
1673
+ super(command, opts);
1674
+ }
1675
+ };
1676
+
1677
+ // pkg/commands/srandmember.ts
1678
+ var SRandMemberCommand = class extends Command {
1679
+ constructor([key, count], opts) {
1680
+ const command = ["srandmember", key];
1681
+ if (typeof count === "number") {
1682
+ command.push(count);
1683
+ }
1684
+ super(command, opts);
1685
+ }
1686
+ };
1687
+
1688
+ // pkg/commands/srem.ts
1689
+ var SRemCommand = class extends Command {
1690
+ constructor(cmd, opts) {
1691
+ super(["srem", ...cmd], opts);
1692
+ }
1693
+ };
1694
+
1695
+ // pkg/commands/sscan.ts
1696
+ var SScanCommand = class extends Command {
1697
+ constructor([key, cursor, opts], cmdOpts) {
1698
+ const command = ["sscan", key, cursor];
1699
+ if (opts?.match) {
1700
+ command.push("match", opts.match);
1701
+ }
1702
+ if (typeof opts?.count === "number") {
1703
+ command.push("count", opts.count);
1704
+ }
1705
+ super(command, {
1706
+ deserialize: deserializeScanResponse,
1707
+ ...cmdOpts
1708
+ });
1709
+ }
1710
+ };
1711
+
1712
+ // pkg/commands/strlen.ts
1713
+ var StrLenCommand = class extends Command {
1714
+ constructor(cmd, opts) {
1715
+ super(["strlen", ...cmd], opts);
1716
+ }
1717
+ };
1718
+
1719
+ // pkg/commands/sunion.ts
1720
+ var SUnionCommand = class extends Command {
1721
+ constructor(cmd, opts) {
1722
+ super(["sunion", ...cmd], opts);
1723
+ }
1724
+ };
1725
+
1726
+ // pkg/commands/sunionstore.ts
1727
+ var SUnionStoreCommand = class extends Command {
1728
+ constructor(cmd, opts) {
1729
+ super(["sunionstore", ...cmd], opts);
1730
+ }
1731
+ };
1732
+
1733
+ // pkg/commands/time.ts
1734
+ var TimeCommand = class extends Command {
1735
+ constructor(opts) {
1736
+ super(["time"], opts);
1737
+ }
1738
+ };
1739
+
1740
+ // pkg/commands/touch.ts
1741
+ var TouchCommand = class extends Command {
1742
+ constructor(cmd, opts) {
1743
+ super(["touch", ...cmd], opts);
1744
+ }
1745
+ };
1746
+
1747
+ // pkg/commands/ttl.ts
1748
+ var TtlCommand = class extends Command {
1749
+ constructor(cmd, opts) {
1750
+ super(["ttl", ...cmd], opts);
1751
+ }
1752
+ };
1753
+
1754
+ // pkg/commands/type.ts
1755
+ var TypeCommand = class extends Command {
1756
+ constructor(cmd, opts) {
1757
+ super(["type", ...cmd], opts);
1758
+ }
1759
+ };
1760
+
1761
+ // pkg/commands/unlink.ts
1762
+ var UnlinkCommand = class extends Command {
1763
+ constructor(cmd, opts) {
1764
+ super(["unlink", ...cmd], opts);
1765
+ }
1766
+ };
1767
+
1768
+ // pkg/commands/xack.ts
1769
+ var XAckCommand = class extends Command {
1770
+ constructor([key, group, id], opts) {
1771
+ const ids = Array.isArray(id) ? [...id] : [id];
1772
+ super(["XACK", key, group, ...ids], opts);
1773
+ }
1774
+ };
1775
+
1776
+ // pkg/commands/xadd.ts
1777
+ var XAddCommand = class extends Command {
1778
+ constructor([key, id, entries, opts], commandOptions) {
1779
+ const command = ["XADD", key];
1780
+ if (opts) {
1781
+ if (opts.nomkStream) {
1782
+ command.push("NOMKSTREAM");
1783
+ }
1784
+ if (opts.trim) {
1785
+ command.push(opts.trim.type, opts.trim.comparison, opts.trim.threshold);
1786
+ if (opts.trim.limit !== void 0) {
1787
+ command.push("LIMIT", opts.trim.limit);
1788
+ }
1789
+ }
1790
+ }
1791
+ command.push(id);
1792
+ for (const [k, v] of Object.entries(entries)) {
1793
+ command.push(k, v);
1794
+ }
1795
+ super(command, commandOptions);
1796
+ }
1797
+ };
1798
+
1799
+ // pkg/commands/xautoclaim.ts
1800
+ var XAutoClaim = class extends Command {
1801
+ constructor([key, group, consumer, minIdleTime, start, options], opts) {
1802
+ const commands = [];
1803
+ if (options?.count) {
1804
+ commands.push("COUNT", options.count);
1805
+ }
1806
+ if (options?.justId) {
1807
+ commands.push("JUSTID");
1808
+ }
1809
+ super(["XAUTOCLAIM", key, group, consumer, minIdleTime, start, ...commands], opts);
1810
+ }
1811
+ };
1812
+
1813
+ // pkg/commands/xclaim.ts
1814
+ var XClaimCommand = class extends Command {
1815
+ constructor([key, group, consumer, minIdleTime, id, options], opts) {
1816
+ const ids = Array.isArray(id) ? [...id] : [id];
1817
+ const commands = [];
1818
+ if (options?.idleMS) {
1819
+ commands.push("IDLE", options.idleMS);
1820
+ }
1821
+ if (options?.idleMS) {
1822
+ commands.push("TIME", options.timeMS);
1823
+ }
1824
+ if (options?.retryCount) {
1825
+ commands.push("RETRYCOUNT", options.retryCount);
1826
+ }
1827
+ if (options?.force) {
1828
+ commands.push("FORCE");
1829
+ }
1830
+ if (options?.justId) {
1831
+ commands.push("JUSTID");
1832
+ }
1833
+ if (options?.lastId) {
1834
+ commands.push("LASTID", options.lastId);
1835
+ }
1836
+ super(["XCLAIM", key, group, consumer, minIdleTime, ...ids, ...commands], opts);
1837
+ }
1838
+ };
1839
+
1840
+ // pkg/commands/xdel.ts
1841
+ var XDelCommand = class extends Command {
1842
+ constructor([key, ids], opts) {
1843
+ const cmds = Array.isArray(ids) ? [...ids] : [ids];
1844
+ super(["XDEL", key, ...cmds], opts);
1845
+ }
1846
+ };
1847
+
1848
+ // pkg/commands/xgroup.ts
1849
+ var XGroupCommand = class extends Command {
1850
+ constructor([key, opts], commandOptions) {
1851
+ const command = ["XGROUP"];
1852
+ switch (opts.type) {
1853
+ case "CREATE": {
1854
+ command.push("CREATE", key, opts.group, opts.id);
1855
+ if (opts.options) {
1856
+ if (opts.options.MKSTREAM) {
1857
+ command.push("MKSTREAM");
1858
+ }
1859
+ if (opts.options.ENTRIESREAD !== void 0) {
1860
+ command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
1861
+ }
1862
+ }
1863
+ break;
1864
+ }
1865
+ case "CREATECONSUMER": {
1866
+ command.push("CREATECONSUMER", key, opts.group, opts.consumer);
1867
+ break;
1868
+ }
1869
+ case "DELCONSUMER": {
1870
+ command.push("DELCONSUMER", key, opts.group, opts.consumer);
1871
+ break;
1872
+ }
1873
+ case "DESTROY": {
1874
+ command.push("DESTROY", key, opts.group);
1875
+ break;
1876
+ }
1877
+ case "SETID": {
1878
+ command.push("SETID", key, opts.group, opts.id);
1879
+ if (opts.options?.ENTRIESREAD !== void 0) {
1880
+ command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
1881
+ }
1882
+ break;
1883
+ }
1884
+ default: {
1885
+ throw new Error("Invalid XGROUP");
1886
+ }
1887
+ }
1888
+ super(command, commandOptions);
1889
+ }
1890
+ };
1891
+
1892
+ // pkg/commands/xinfo.ts
1893
+ var XInfoCommand = class extends Command {
1894
+ constructor([key, options], opts) {
1895
+ const cmds = [];
1896
+ if (options.type === "CONSUMERS") {
1897
+ cmds.push("CONSUMERS", key, options.group);
1898
+ } else {
1899
+ cmds.push("GROUPS", key);
1900
+ }
1901
+ super(["XINFO", ...cmds], opts);
1902
+ }
1903
+ };
1904
+
1905
+ // pkg/commands/xlen.ts
1906
+ var XLenCommand = class extends Command {
1907
+ constructor(cmd, opts) {
1908
+ super(["XLEN", ...cmd], opts);
1909
+ }
1910
+ };
1911
+
1912
+ // pkg/commands/xpending.ts
1913
+ var XPendingCommand = class extends Command {
1914
+ constructor([key, group, start, end, count, options], opts) {
1915
+ const consumers = options?.consumer === void 0 ? [] : Array.isArray(options.consumer) ? [...options.consumer] : [options.consumer];
1916
+ super(
1917
+ [
1918
+ "XPENDING",
1919
+ key,
1920
+ group,
1921
+ ...options?.idleTime ? ["IDLE", options.idleTime] : [],
1922
+ start,
1923
+ end,
1924
+ count,
1925
+ ...consumers
1926
+ ],
1927
+ opts
1928
+ );
1929
+ }
1930
+ };
1931
+
1932
+ // pkg/commands/xrange.ts
1933
+ function deserialize4(result) {
1934
+ const obj = {};
1935
+ for (const e of result) {
1936
+ while (e.length >= 2) {
1937
+ const streamId = e.shift();
1938
+ const entries = e.shift();
1939
+ if (!(streamId in obj)) {
1940
+ obj[streamId] = {};
1941
+ }
1942
+ while (entries.length >= 2) {
1943
+ const field = entries.shift();
1944
+ const value = entries.shift();
1945
+ try {
1946
+ obj[streamId][field] = JSON.parse(value);
1947
+ } catch {
1948
+ obj[streamId][field] = value;
1949
+ }
1950
+ }
1951
+ }
1952
+ }
1953
+ return obj;
1954
+ }
1955
+ var XRangeCommand = class extends Command {
1956
+ constructor([key, start, end, count], opts) {
1957
+ const command = ["XRANGE", key, start, end];
1958
+ if (typeof count === "number") {
1959
+ command.push("COUNT", count);
1960
+ }
1961
+ super(command, {
1962
+ deserialize: (result) => deserialize4(result),
1963
+ ...opts
1964
+ });
1965
+ }
1966
+ };
1967
+
1968
+ // pkg/commands/xread.ts
1969
+ var UNBALANCED_XREAD_ERR = "ERR Unbalanced XREAD list of streams: for each stream key an ID or '$' must be specified";
1970
+ var XReadCommand = class extends Command {
1971
+ constructor([key, id, options], opts) {
1972
+ if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
1973
+ throw new Error(UNBALANCED_XREAD_ERR);
1974
+ }
1975
+ const commands = [];
1976
+ if (typeof options?.count === "number") {
1977
+ commands.push("COUNT", options.count);
1978
+ }
1979
+ if (typeof options?.blockMS === "number") {
1980
+ commands.push("BLOCK", options.blockMS);
1981
+ }
1982
+ commands.push(
1983
+ "STREAMS",
1984
+ ...Array.isArray(key) ? [...key] : [key],
1985
+ ...Array.isArray(id) ? [...id] : [id]
1986
+ );
1987
+ super(["XREAD", ...commands], opts);
1988
+ }
1989
+ };
1990
+
1991
+ // pkg/commands/xreadgroup.ts
1992
+ var UNBALANCED_XREADGROUP_ERR = "ERR Unbalanced XREADGROUP list of streams: for each stream key an ID or '$' must be specified";
1993
+ var XReadGroupCommand = class extends Command {
1994
+ constructor([group, consumer, key, id, options], opts) {
1995
+ if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
1996
+ throw new Error(UNBALANCED_XREADGROUP_ERR);
1997
+ }
1998
+ const commands = [];
1999
+ if (typeof options?.count === "number") {
2000
+ commands.push("COUNT", options.count);
2001
+ }
2002
+ if (typeof options?.blockMS === "number") {
2003
+ commands.push("BLOCK", options.blockMS);
2004
+ }
2005
+ if (typeof options?.NOACK === "boolean" && options.NOACK) {
2006
+ commands.push("NOACK");
2007
+ }
2008
+ commands.push(
2009
+ "STREAMS",
2010
+ ...Array.isArray(key) ? [...key] : [key],
2011
+ ...Array.isArray(id) ? [...id] : [id]
2012
+ );
2013
+ super(["XREADGROUP", "GROUP", group, consumer, ...commands], opts);
2014
+ }
2015
+ };
2016
+
2017
+ // pkg/commands/xrevrange.ts
2018
+ var XRevRangeCommand = class extends Command {
2019
+ constructor([key, end, start, count], opts) {
2020
+ const command = ["XREVRANGE", key, end, start];
2021
+ if (typeof count === "number") {
2022
+ command.push("COUNT", count);
2023
+ }
2024
+ super(command, {
2025
+ deserialize: (result) => deserialize5(result),
2026
+ ...opts
2027
+ });
2028
+ }
2029
+ };
2030
+ function deserialize5(result) {
2031
+ const obj = {};
2032
+ for (const e of result) {
2033
+ while (e.length >= 2) {
2034
+ const streamId = e.shift();
2035
+ const entries = e.shift();
2036
+ if (!(streamId in obj)) {
2037
+ obj[streamId] = {};
2038
+ }
2039
+ while (entries.length >= 2) {
2040
+ const field = entries.shift();
2041
+ const value = entries.shift();
2042
+ try {
2043
+ obj[streamId][field] = JSON.parse(value);
2044
+ } catch {
2045
+ obj[streamId][field] = value;
2046
+ }
2047
+ }
2048
+ }
2049
+ }
2050
+ return obj;
2051
+ }
2052
+
2053
+ // pkg/commands/xtrim.ts
2054
+ var XTrimCommand = class extends Command {
2055
+ constructor([key, options], opts) {
2056
+ const { limit, strategy, threshold, exactness = "~" } = options;
2057
+ super(["XTRIM", key, strategy, exactness, threshold, ...limit ? ["LIMIT", limit] : []], opts);
2058
+ }
2059
+ };
2060
+
2061
+ // pkg/commands/zadd.ts
2062
+ var ZAddCommand = class extends Command {
2063
+ constructor([key, arg1, ...arg2], opts) {
2064
+ const command = ["zadd", key];
2065
+ if ("nx" in arg1 && arg1.nx) {
2066
+ command.push("nx");
2067
+ } else if ("xx" in arg1 && arg1.xx) {
2068
+ command.push("xx");
2069
+ }
2070
+ if ("ch" in arg1 && arg1.ch) {
2071
+ command.push("ch");
2072
+ }
2073
+ if ("incr" in arg1 && arg1.incr) {
2074
+ command.push("incr");
2075
+ }
2076
+ if ("lt" in arg1 && arg1.lt) {
2077
+ command.push("lt");
2078
+ } else if ("gt" in arg1 && arg1.gt) {
2079
+ command.push("gt");
2080
+ }
2081
+ if ("score" in arg1 && "member" in arg1) {
2082
+ command.push(arg1.score, arg1.member);
2083
+ }
2084
+ command.push(...arg2.flatMap(({ score, member }) => [score, member]));
2085
+ super(command, opts);
2086
+ }
2087
+ };
2088
+
2089
+ // pkg/commands/zcard.ts
2090
+ var ZCardCommand = class extends Command {
2091
+ constructor(cmd, opts) {
2092
+ super(["zcard", ...cmd], opts);
2093
+ }
2094
+ };
2095
+
2096
+ // pkg/commands/zcount.ts
2097
+ var ZCountCommand = class extends Command {
2098
+ constructor(cmd, opts) {
2099
+ super(["zcount", ...cmd], opts);
2100
+ }
2101
+ };
2102
+
2103
+ // pkg/commands/zincrby.ts
2104
+ var ZIncrByCommand = class extends Command {
2105
+ constructor(cmd, opts) {
2106
+ super(["zincrby", ...cmd], opts);
2107
+ }
2108
+ };
2109
+
2110
+ // pkg/commands/zinterstore.ts
2111
+ var ZInterStoreCommand = class extends Command {
2112
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
2113
+ const command = ["zinterstore", destination, numKeys];
2114
+ if (Array.isArray(keyOrKeys)) {
2115
+ command.push(...keyOrKeys);
2116
+ } else {
2117
+ command.push(keyOrKeys);
2118
+ }
2119
+ if (opts) {
2120
+ if ("weights" in opts && opts.weights) {
2121
+ command.push("weights", ...opts.weights);
2122
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2123
+ command.push("weights", opts.weight);
2124
+ }
2125
+ if ("aggregate" in opts) {
2126
+ command.push("aggregate", opts.aggregate);
2127
+ }
2128
+ }
2129
+ super(command, cmdOpts);
2130
+ }
2131
+ };
2132
+
2133
+ // pkg/commands/zlexcount.ts
2134
+ var ZLexCountCommand = class extends Command {
2135
+ constructor(cmd, opts) {
2136
+ super(["zlexcount", ...cmd], opts);
2137
+ }
2138
+ };
2139
+
2140
+ // pkg/commands/zpopmax.ts
2141
+ var ZPopMaxCommand = class extends Command {
2142
+ constructor([key, count], opts) {
2143
+ const command = ["zpopmax", key];
2144
+ if (typeof count === "number") {
2145
+ command.push(count);
2146
+ }
2147
+ super(command, opts);
2148
+ }
2149
+ };
2150
+
2151
+ // pkg/commands/zpopmin.ts
2152
+ var ZPopMinCommand = class extends Command {
2153
+ constructor([key, count], opts) {
2154
+ const command = ["zpopmin", key];
2155
+ if (typeof count === "number") {
2156
+ command.push(count);
2157
+ }
2158
+ super(command, opts);
2159
+ }
2160
+ };
2161
+
2162
+ // pkg/commands/zrange.ts
2163
+ var ZRangeCommand = class extends Command {
2164
+ constructor([key, min, max, opts], cmdOpts) {
2165
+ const command = ["zrange", key, min, max];
2166
+ if (opts?.byScore) {
2167
+ command.push("byscore");
2168
+ }
2169
+ if (opts?.byLex) {
2170
+ command.push("bylex");
2171
+ }
2172
+ if (opts?.rev) {
2173
+ command.push("rev");
2174
+ }
2175
+ if (opts?.count !== void 0 && opts.offset !== void 0) {
2176
+ command.push("limit", opts.offset, opts.count);
2177
+ }
2178
+ if (opts?.withScores) {
2179
+ command.push("withscores");
2180
+ }
2181
+ super(command, cmdOpts);
2182
+ }
2183
+ };
2184
+
2185
+ // pkg/commands/zrank.ts
2186
+ var ZRankCommand = class extends Command {
2187
+ constructor(cmd, opts) {
2188
+ super(["zrank", ...cmd], opts);
2189
+ }
2190
+ };
2191
+
2192
+ // pkg/commands/zrem.ts
2193
+ var ZRemCommand = class extends Command {
2194
+ constructor(cmd, opts) {
2195
+ super(["zrem", ...cmd], opts);
2196
+ }
2197
+ };
2198
+
2199
+ // pkg/commands/zremrangebylex.ts
2200
+ var ZRemRangeByLexCommand = class extends Command {
2201
+ constructor(cmd, opts) {
2202
+ super(["zremrangebylex", ...cmd], opts);
2203
+ }
2204
+ };
2205
+
2206
+ // pkg/commands/zremrangebyrank.ts
2207
+ var ZRemRangeByRankCommand = class extends Command {
2208
+ constructor(cmd, opts) {
2209
+ super(["zremrangebyrank", ...cmd], opts);
2210
+ }
2211
+ };
2212
+
2213
+ // pkg/commands/zremrangebyscore.ts
2214
+ var ZRemRangeByScoreCommand = class extends Command {
2215
+ constructor(cmd, opts) {
2216
+ super(["zremrangebyscore", ...cmd], opts);
2217
+ }
2218
+ };
2219
+
2220
+ // pkg/commands/zrevrank.ts
2221
+ var ZRevRankCommand = class extends Command {
2222
+ constructor(cmd, opts) {
2223
+ super(["zrevrank", ...cmd], opts);
2224
+ }
2225
+ };
2226
+
2227
+ // pkg/commands/zscan.ts
2228
+ var ZScanCommand = class extends Command {
2229
+ constructor([key, cursor, opts], cmdOpts) {
2230
+ const command = ["zscan", key, cursor];
2231
+ if (opts?.match) {
2232
+ command.push("match", opts.match);
2233
+ }
2234
+ if (typeof opts?.count === "number") {
2235
+ command.push("count", opts.count);
2236
+ }
2237
+ super(command, {
2238
+ deserialize: deserializeScanResponse,
2239
+ ...cmdOpts
2240
+ });
2241
+ }
2242
+ };
2243
+
2244
+ // pkg/commands/zscore.ts
2245
+ var ZScoreCommand = class extends Command {
2246
+ constructor(cmd, opts) {
2247
+ super(["zscore", ...cmd], opts);
2248
+ }
2249
+ };
2250
+
2251
+ // pkg/commands/zunion.ts
2252
+ var ZUnionCommand = class extends Command {
2253
+ constructor([numKeys, keyOrKeys, opts], cmdOpts) {
2254
+ const command = ["zunion", numKeys];
2255
+ if (Array.isArray(keyOrKeys)) {
2256
+ command.push(...keyOrKeys);
2257
+ } else {
2258
+ command.push(keyOrKeys);
2259
+ }
2260
+ if (opts) {
2261
+ if ("weights" in opts && opts.weights) {
2262
+ command.push("weights", ...opts.weights);
2263
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2264
+ command.push("weights", opts.weight);
2265
+ }
2266
+ if ("aggregate" in opts) {
2267
+ command.push("aggregate", opts.aggregate);
2268
+ }
2269
+ if (opts.withScores) {
2270
+ command.push("withscores");
2271
+ }
2272
+ }
2273
+ super(command, cmdOpts);
2274
+ }
2275
+ };
2276
+
2277
+ // pkg/commands/zunionstore.ts
2278
+ var ZUnionStoreCommand = class extends Command {
2279
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
2280
+ const command = ["zunionstore", destination, numKeys];
2281
+ if (Array.isArray(keyOrKeys)) {
2282
+ command.push(...keyOrKeys);
2283
+ } else {
2284
+ command.push(keyOrKeys);
2285
+ }
2286
+ if (opts) {
2287
+ if ("weights" in opts && opts.weights) {
2288
+ command.push("weights", ...opts.weights);
2289
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2290
+ command.push("weights", opts.weight);
2291
+ }
2292
+ if ("aggregate" in opts) {
2293
+ command.push("aggregate", opts.aggregate);
2294
+ }
2295
+ }
2296
+ super(command, cmdOpts);
2297
+ }
2298
+ };
2299
+
2300
+ // pkg/commands/psubscribe.ts
2301
+ var PSubscribeCommand = class extends Command {
2302
+ constructor(cmd, opts) {
2303
+ const sseHeaders = {
2304
+ Accept: "text/event-stream",
2305
+ "Cache-Control": "no-cache",
2306
+ Connection: "keep-alive"
2307
+ };
2308
+ super([], {
2309
+ ...opts,
2310
+ headers: sseHeaders,
2311
+ path: ["psubscribe", ...cmd],
2312
+ streamOptions: {
2313
+ isStreaming: true,
2314
+ onMessage: opts?.streamOptions?.onMessage,
2315
+ signal: opts?.streamOptions?.signal
2316
+ }
2317
+ });
2318
+ }
2319
+ };
2320
+
2321
+ // pkg/commands/subscribe.ts
2322
+ var Subscriber = class extends EventTarget {
2323
+ subscriptions;
2324
+ client;
2325
+ listeners;
2326
+ constructor(client, channels, isPattern = false) {
2327
+ super();
2328
+ this.client = client;
2329
+ this.subscriptions = /* @__PURE__ */ new Map();
2330
+ this.listeners = /* @__PURE__ */ new Map();
2331
+ for (const channel of channels) {
2332
+ if (isPattern) {
2333
+ this.subscribeToPattern(channel);
2334
+ } else {
2335
+ this.subscribeToChannel(channel);
2336
+ }
2337
+ }
2338
+ }
2339
+ subscribeToChannel(channel) {
2340
+ const controller = new AbortController();
2341
+ const command = new SubscribeCommand([channel], {
2342
+ streamOptions: {
2343
+ signal: controller.signal,
2344
+ onMessage: (data) => this.handleMessage(data, false)
2345
+ }
2346
+ });
2347
+ command.exec(this.client).catch((error) => {
2348
+ if (error.name !== "AbortError") {
2349
+ this.dispatchToListeners("error", error);
2350
+ }
2351
+ });
2352
+ this.subscriptions.set(channel, {
2353
+ command,
2354
+ controller,
2355
+ isPattern: false
2356
+ });
2357
+ }
2358
+ subscribeToPattern(pattern) {
2359
+ const controller = new AbortController();
2360
+ const command = new PSubscribeCommand([pattern], {
2361
+ streamOptions: {
2362
+ signal: controller.signal,
2363
+ onMessage: (data) => this.handleMessage(data, true)
2364
+ }
2365
+ });
2366
+ command.exec(this.client).catch((error) => {
2367
+ if (error.name !== "AbortError") {
2368
+ this.dispatchToListeners("error", error);
2369
+ }
2370
+ });
2371
+ this.subscriptions.set(pattern, {
2372
+ command,
2373
+ controller,
2374
+ isPattern: true
2375
+ });
2376
+ }
2377
+ handleMessage(data, isPattern) {
2378
+ const messageData = data.replace(/^data:\s*/, "");
2379
+ const firstCommaIndex = messageData.indexOf(",");
2380
+ const secondCommaIndex = messageData.indexOf(",", firstCommaIndex + 1);
2381
+ const thirdCommaIndex = isPattern ? messageData.indexOf(",", secondCommaIndex + 1) : -1;
2382
+ if (firstCommaIndex !== -1 && secondCommaIndex !== -1) {
2383
+ const type = messageData.slice(0, firstCommaIndex);
2384
+ if (isPattern && type === "pmessage" && thirdCommaIndex !== -1) {
2385
+ const pattern = messageData.slice(firstCommaIndex + 1, secondCommaIndex);
2386
+ const channel = messageData.slice(secondCommaIndex + 1, thirdCommaIndex);
2387
+ const messageStr = messageData.slice(thirdCommaIndex + 1);
2388
+ try {
2389
+ const message = JSON.parse(messageStr);
2390
+ this.dispatchToListeners("pmessage", message);
2391
+ this.dispatchToListeners(`pmessageBuffer`, { pattern, channel, message });
2392
+ this.dispatchToListeners(`pmessage:${pattern}`, { channel, message });
2393
+ } catch (error) {
2394
+ this.dispatchToListeners("error", new Error(`Failed to parse message: ${error}`));
2395
+ }
2396
+ } else {
2397
+ const channel = messageData.slice(firstCommaIndex + 1, secondCommaIndex);
2398
+ const messageStr = messageData.slice(secondCommaIndex + 1);
2399
+ try {
2400
+ const message = type === "subscribe" || type === "psubscribe" ? Number.parseInt(messageStr) : JSON.parse(messageStr);
2401
+ this.dispatchToListeners(type, message);
2402
+ this.dispatchToListeners(`${type}Buffer`, { channel, message });
2403
+ this.dispatchToListeners(`${type}:${channel}`, message);
2404
+ } catch (error) {
2405
+ this.dispatchToListeners("error", new Error(`Failed to parse message: ${error}`));
2406
+ }
2407
+ }
2408
+ }
2409
+ }
2410
+ dispatchToListeners(type, data) {
2411
+ const listeners = this.listeners.get(type);
2412
+ if (listeners) {
2413
+ for (const listener of listeners) {
2414
+ listener(data);
2415
+ }
2416
+ }
2417
+ }
2418
+ on(type, listener) {
2419
+ if (!this.listeners.has(type)) {
2420
+ this.listeners.set(type, /* @__PURE__ */ new Set());
2421
+ }
2422
+ this.listeners.get(type)?.add(listener);
2423
+ }
2424
+ removeAllListeners() {
2425
+ this.listeners.clear();
2426
+ }
2427
+ async unsubscribe(channels) {
2428
+ if (channels) {
2429
+ for (const channel of channels) {
2430
+ const subscription = this.subscriptions.get(channel);
2431
+ if (subscription) {
2432
+ try {
2433
+ subscription.controller.abort();
2434
+ } catch {
2435
+ }
2436
+ this.subscriptions.delete(channel);
2437
+ }
2438
+ }
2439
+ } else {
2440
+ for (const subscription of this.subscriptions.values()) {
2441
+ try {
2442
+ subscription.controller.abort();
2443
+ } catch {
2444
+ }
2445
+ }
2446
+ this.subscriptions.clear();
2447
+ this.removeAllListeners();
2448
+ }
2449
+ }
2450
+ getSubscribedChannels() {
2451
+ return [...this.subscriptions.keys()];
2452
+ }
2453
+ };
2454
+ var SubscribeCommand = class extends Command {
2455
+ constructor(cmd, opts) {
2456
+ const sseHeaders = {
2457
+ Accept: "text/event-stream",
2458
+ "Cache-Control": "no-cache",
2459
+ Connection: "keep-alive"
2460
+ };
2461
+ super([], {
2462
+ ...opts,
2463
+ headers: sseHeaders,
2464
+ path: ["subscribe", ...cmd],
2465
+ streamOptions: {
2466
+ isStreaming: true,
2467
+ onMessage: opts?.streamOptions?.onMessage,
2468
+ signal: opts?.streamOptions?.signal
2469
+ }
2470
+ });
2471
+ }
2472
+ };
2473
+
2474
+ // pkg/commands/zdiffstore.ts
2475
+ var ZDiffStoreCommand = class extends Command {
2476
+ constructor(cmd, opts) {
2477
+ super(["zdiffstore", ...cmd], opts);
2478
+ }
2479
+ };
2480
+
2481
+ // pkg/commands/zmscore.ts
2482
+ var ZMScoreCommand = class extends Command {
2483
+ constructor(cmd, opts) {
2484
+ const [key, members] = cmd;
2485
+ super(["zmscore", key, ...members], opts);
2486
+ }
2487
+ };
2488
+
2489
+ // pkg/pipeline.ts
2490
+ var Pipeline = class {
2491
+ client;
2492
+ commands;
2493
+ commandOptions;
2494
+ multiExec;
2495
+ constructor(opts) {
2496
+ this.client = opts.client;
2497
+ this.commands = [];
2498
+ this.commandOptions = opts.commandOptions;
2499
+ this.multiExec = opts.multiExec ?? false;
2500
+ if (this.commandOptions?.latencyLogging) {
2501
+ const originalExec = this.exec.bind(this);
2502
+ this.exec = async (options) => {
2503
+ const start = performance.now();
2504
+ const result = await (options ? originalExec(options) : originalExec());
2505
+ const end = performance.now();
2506
+ const loggerResult = (end - start).toFixed(2);
2507
+ console.log(
2508
+ `Latency for \x1B[38;2;19;185;39m${this.multiExec ? ["MULTI-EXEC"] : ["PIPELINE"].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
2509
+ );
2510
+ return result;
2511
+ };
2512
+ }
2513
+ }
2514
+ exec = async (options) => {
2515
+ if (this.commands.length === 0) {
2516
+ throw new Error("Pipeline is empty");
2517
+ }
2518
+ const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
2519
+ const res = await this.client.request({
2520
+ path,
2521
+ body: Object.values(this.commands).map((c) => c.command)
2522
+ });
2523
+ return options?.keepErrors ? res.map(({ error, result }, i) => {
2524
+ return {
2525
+ error,
2526
+ result: this.commands[i].deserialize(result)
2527
+ };
2528
+ }) : res.map(({ error, result }, i) => {
2529
+ if (error) {
2530
+ throw new UpstashError(
2531
+ `Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
2532
+ );
2533
+ }
2534
+ return this.commands[i].deserialize(result);
2535
+ });
2536
+ };
2537
+ /**
2538
+ * Returns the length of pipeline before the execution
2539
+ */
2540
+ length() {
2541
+ return this.commands.length;
2542
+ }
2543
+ /**
2544
+ * Pushes a command into the pipeline and returns a chainable instance of the
2545
+ * pipeline
2546
+ */
2547
+ chain(command) {
2548
+ this.commands.push(command);
2549
+ return this;
2550
+ }
2551
+ /**
2552
+ * @see https://redis.io/commands/append
2553
+ */
2554
+ append = (...args) => this.chain(new AppendCommand(args, this.commandOptions));
2555
+ /**
2556
+ * @see https://redis.io/commands/bitcount
2557
+ */
2558
+ bitcount = (...args) => this.chain(new BitCountCommand(args, this.commandOptions));
2559
+ /**
2560
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
2561
+ *
2562
+ * @example
2563
+ * ```typescript
2564
+ * redis.set("mykey", 0);
2565
+ * const result = await redis.pipeline()
2566
+ * .bitfield("mykey")
2567
+ * .set("u4", 0, 16)
2568
+ * .incr("u4", "#1", 1)
2569
+ * .exec();
2570
+ * console.log(result); // [[0, 1]]
2571
+ * ```
2572
+ *
2573
+ * @see https://redis.io/commands/bitfield
2574
+ */
2575
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.commandOptions, this.chain.bind(this));
2576
+ /**
2577
+ * @see https://redis.io/commands/bitop
2578
+ */
2579
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => this.chain(
2580
+ new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.commandOptions)
2581
+ );
2582
+ /**
2583
+ * @see https://redis.io/commands/bitpos
2584
+ */
2585
+ bitpos = (...args) => this.chain(new BitPosCommand(args, this.commandOptions));
2586
+ /**
2587
+ * @see https://redis.io/commands/copy
2588
+ */
2589
+ copy = (...args) => this.chain(new CopyCommand(args, this.commandOptions));
2590
+ /**
2591
+ * @see https://redis.io/commands/zdiffstore
2592
+ */
2593
+ zdiffstore = (...args) => this.chain(new ZDiffStoreCommand(args, this.commandOptions));
2594
+ /**
2595
+ * @see https://redis.io/commands/dbsize
2596
+ */
2597
+ dbsize = () => this.chain(new DBSizeCommand(this.commandOptions));
2598
+ /**
2599
+ * @see https://redis.io/commands/decr
2600
+ */
2601
+ decr = (...args) => this.chain(new DecrCommand(args, this.commandOptions));
2602
+ /**
2603
+ * @see https://redis.io/commands/decrby
2604
+ */
2605
+ decrby = (...args) => this.chain(new DecrByCommand(args, this.commandOptions));
2606
+ /**
2607
+ * @see https://redis.io/commands/del
2608
+ */
2609
+ del = (...args) => this.chain(new DelCommand(args, this.commandOptions));
2610
+ /**
2611
+ * @see https://redis.io/commands/echo
2612
+ */
2613
+ echo = (...args) => this.chain(new EchoCommand(args, this.commandOptions));
2614
+ /**
2615
+ * @see https://redis.io/commands/eval
2616
+ */
2617
+ eval = (...args) => this.chain(new EvalCommand(args, this.commandOptions));
2618
+ /**
2619
+ * @see https://redis.io/commands/evalsha
2620
+ */
2621
+ evalsha = (...args) => this.chain(new EvalshaCommand(args, this.commandOptions));
2622
+ /**
2623
+ * @see https://redis.io/commands/exists
2624
+ */
2625
+ exists = (...args) => this.chain(new ExistsCommand(args, this.commandOptions));
2626
+ /**
2627
+ * @see https://redis.io/commands/expire
2628
+ */
2629
+ expire = (...args) => this.chain(new ExpireCommand(args, this.commandOptions));
2630
+ /**
2631
+ * @see https://redis.io/commands/expireat
2632
+ */
2633
+ expireat = (...args) => this.chain(new ExpireAtCommand(args, this.commandOptions));
2634
+ /**
2635
+ * @see https://redis.io/commands/flushall
2636
+ */
2637
+ flushall = (args) => this.chain(new FlushAllCommand(args, this.commandOptions));
2638
+ /**
2639
+ * @see https://redis.io/commands/flushdb
2640
+ */
2641
+ flushdb = (...args) => this.chain(new FlushDBCommand(args, this.commandOptions));
2642
+ /**
2643
+ * @see https://redis.io/commands/geoadd
2644
+ */
2645
+ geoadd = (...args) => this.chain(new GeoAddCommand(args, this.commandOptions));
2646
+ /**
2647
+ * @see https://redis.io/commands/geodist
2648
+ */
2649
+ geodist = (...args) => this.chain(new GeoDistCommand(args, this.commandOptions));
2650
+ /**
2651
+ * @see https://redis.io/commands/geopos
2652
+ */
2653
+ geopos = (...args) => this.chain(new GeoPosCommand(args, this.commandOptions));
2654
+ /**
2655
+ * @see https://redis.io/commands/geohash
2656
+ */
2657
+ geohash = (...args) => this.chain(new GeoHashCommand(args, this.commandOptions));
2658
+ /**
2659
+ * @see https://redis.io/commands/geosearch
2660
+ */
2661
+ geosearch = (...args) => this.chain(new GeoSearchCommand(args, this.commandOptions));
2662
+ /**
2663
+ * @see https://redis.io/commands/geosearchstore
2664
+ */
2665
+ geosearchstore = (...args) => this.chain(new GeoSearchStoreCommand(args, this.commandOptions));
2666
+ /**
2667
+ * @see https://redis.io/commands/get
2668
+ */
2669
+ get = (...args) => this.chain(new GetCommand(args, this.commandOptions));
2670
+ /**
2671
+ * @see https://redis.io/commands/getbit
2672
+ */
2673
+ getbit = (...args) => this.chain(new GetBitCommand(args, this.commandOptions));
2674
+ /**
2675
+ * @see https://redis.io/commands/getdel
2676
+ */
2677
+ getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
2678
+ /**
2679
+ * @see https://redis.io/commands/getex
2680
+ */
2681
+ getex = (...args) => this.chain(new GetExCommand(args, this.commandOptions));
2682
+ /**
2683
+ * @see https://redis.io/commands/getrange
2684
+ */
2685
+ getrange = (...args) => this.chain(new GetRangeCommand(args, this.commandOptions));
2686
+ /**
2687
+ * @see https://redis.io/commands/getset
2688
+ */
2689
+ getset = (key, value) => this.chain(new GetSetCommand([key, value], this.commandOptions));
2690
+ /**
2691
+ * @see https://redis.io/commands/hdel
2692
+ */
2693
+ hdel = (...args) => this.chain(new HDelCommand(args, this.commandOptions));
2694
+ /**
2695
+ * @see https://redis.io/commands/hexists
2696
+ */
2697
+ hexists = (...args) => this.chain(new HExistsCommand(args, this.commandOptions));
2698
+ /**
2699
+ * @see https://redis.io/commands/hget
2700
+ */
2701
+ hget = (...args) => this.chain(new HGetCommand(args, this.commandOptions));
2702
+ /**
2703
+ * @see https://redis.io/commands/hgetall
2704
+ */
2705
+ hgetall = (...args) => this.chain(new HGetAllCommand(args, this.commandOptions));
2706
+ /**
2707
+ * @see https://redis.io/commands/hincrby
2708
+ */
2709
+ hincrby = (...args) => this.chain(new HIncrByCommand(args, this.commandOptions));
2710
+ /**
2711
+ * @see https://redis.io/commands/hincrbyfloat
2712
+ */
2713
+ hincrbyfloat = (...args) => this.chain(new HIncrByFloatCommand(args, this.commandOptions));
2714
+ /**
2715
+ * @see https://redis.io/commands/hkeys
2716
+ */
2717
+ hkeys = (...args) => this.chain(new HKeysCommand(args, this.commandOptions));
2718
+ /**
2719
+ * @see https://redis.io/commands/hlen
2720
+ */
2721
+ hlen = (...args) => this.chain(new HLenCommand(args, this.commandOptions));
2722
+ /**
2723
+ * @see https://redis.io/commands/hmget
2724
+ */
2725
+ hmget = (...args) => this.chain(new HMGetCommand(args, this.commandOptions));
2726
+ /**
2727
+ * @see https://redis.io/commands/hmset
2728
+ */
2729
+ hmset = (key, kv) => this.chain(new HMSetCommand([key, kv], this.commandOptions));
2730
+ /**
2731
+ * @see https://redis.io/commands/hrandfield
2732
+ */
2733
+ hrandfield = (key, count, withValues) => this.chain(new HRandFieldCommand([key, count, withValues], this.commandOptions));
2734
+ /**
2735
+ * @see https://redis.io/commands/hscan
2736
+ */
2737
+ hscan = (...args) => this.chain(new HScanCommand(args, this.commandOptions));
2738
+ /**
2739
+ * @see https://redis.io/commands/hset
2740
+ */
2741
+ hset = (key, kv) => this.chain(new HSetCommand([key, kv], this.commandOptions));
2742
+ /**
2743
+ * @see https://redis.io/commands/hsetnx
2744
+ */
2745
+ hsetnx = (key, field, value) => this.chain(new HSetNXCommand([key, field, value], this.commandOptions));
2746
+ /**
2747
+ * @see https://redis.io/commands/hstrlen
2748
+ */
2749
+ hstrlen = (...args) => this.chain(new HStrLenCommand(args, this.commandOptions));
2750
+ /**
2751
+ * @see https://redis.io/commands/hvals
2752
+ */
2753
+ hvals = (...args) => this.chain(new HValsCommand(args, this.commandOptions));
2754
+ /**
2755
+ * @see https://redis.io/commands/incr
2756
+ */
2757
+ incr = (...args) => this.chain(new IncrCommand(args, this.commandOptions));
2758
+ /**
2759
+ * @see https://redis.io/commands/incrby
2760
+ */
2761
+ incrby = (...args) => this.chain(new IncrByCommand(args, this.commandOptions));
2762
+ /**
2763
+ * @see https://redis.io/commands/incrbyfloat
2764
+ */
2765
+ incrbyfloat = (...args) => this.chain(new IncrByFloatCommand(args, this.commandOptions));
2766
+ /**
2767
+ * @see https://redis.io/commands/keys
2768
+ */
2769
+ keys = (...args) => this.chain(new KeysCommand(args, this.commandOptions));
2770
+ /**
2771
+ * @see https://redis.io/commands/lindex
2772
+ */
2773
+ lindex = (...args) => this.chain(new LIndexCommand(args, this.commandOptions));
2774
+ /**
2775
+ * @see https://redis.io/commands/linsert
2776
+ */
2777
+ linsert = (key, direction, pivot, value) => this.chain(new LInsertCommand([key, direction, pivot, value], this.commandOptions));
2778
+ /**
2779
+ * @see https://redis.io/commands/llen
2780
+ */
2781
+ llen = (...args) => this.chain(new LLenCommand(args, this.commandOptions));
2782
+ /**
2783
+ * @see https://redis.io/commands/lmove
2784
+ */
2785
+ lmove = (...args) => this.chain(new LMoveCommand(args, this.commandOptions));
2786
+ /**
2787
+ * @see https://redis.io/commands/lpop
2788
+ */
2789
+ lpop = (...args) => this.chain(new LPopCommand(args, this.commandOptions));
2790
+ /**
2791
+ * @see https://redis.io/commands/lmpop
2792
+ */
2793
+ lmpop = (...args) => this.chain(new LmPopCommand(args, this.commandOptions));
2794
+ /**
2795
+ * @see https://redis.io/commands/lpos
2796
+ */
2797
+ lpos = (...args) => this.chain(new LPosCommand(args, this.commandOptions));
2798
+ /**
2799
+ * @see https://redis.io/commands/lpush
2800
+ */
2801
+ lpush = (key, ...elements) => this.chain(new LPushCommand([key, ...elements], this.commandOptions));
2802
+ /**
2803
+ * @see https://redis.io/commands/lpushx
2804
+ */
2805
+ lpushx = (key, ...elements) => this.chain(new LPushXCommand([key, ...elements], this.commandOptions));
2806
+ /**
2807
+ * @see https://redis.io/commands/lrange
2808
+ */
2809
+ lrange = (...args) => this.chain(new LRangeCommand(args, this.commandOptions));
2810
+ /**
2811
+ * @see https://redis.io/commands/lrem
2812
+ */
2813
+ lrem = (key, count, value) => this.chain(new LRemCommand([key, count, value], this.commandOptions));
2814
+ /**
2815
+ * @see https://redis.io/commands/lset
2816
+ */
2817
+ lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
2818
+ /**
2819
+ * @see https://redis.io/commands/ltrim
2820
+ */
2821
+ ltrim = (...args) => this.chain(new LTrimCommand(args, this.commandOptions));
2822
+ /**
2823
+ * @see https://redis.io/commands/mget
2824
+ */
2825
+ mget = (...args) => this.chain(new MGetCommand(args, this.commandOptions));
2826
+ /**
2827
+ * @see https://redis.io/commands/mset
2828
+ */
2829
+ mset = (kv) => this.chain(new MSetCommand([kv], this.commandOptions));
2830
+ /**
2831
+ * @see https://redis.io/commands/msetnx
2832
+ */
2833
+ msetnx = (kv) => this.chain(new MSetNXCommand([kv], this.commandOptions));
2834
+ /**
2835
+ * @see https://redis.io/commands/persist
2836
+ */
2837
+ persist = (...args) => this.chain(new PersistCommand(args, this.commandOptions));
2838
+ /**
2839
+ * @see https://redis.io/commands/pexpire
2840
+ */
2841
+ pexpire = (...args) => this.chain(new PExpireCommand(args, this.commandOptions));
2842
+ /**
2843
+ * @see https://redis.io/commands/pexpireat
2844
+ */
2845
+ pexpireat = (...args) => this.chain(new PExpireAtCommand(args, this.commandOptions));
2846
+ /**
2847
+ * @see https://redis.io/commands/pfadd
2848
+ */
2849
+ pfadd = (...args) => this.chain(new PfAddCommand(args, this.commandOptions));
2850
+ /**
2851
+ * @see https://redis.io/commands/pfcount
2852
+ */
2853
+ pfcount = (...args) => this.chain(new PfCountCommand(args, this.commandOptions));
2854
+ /**
2855
+ * @see https://redis.io/commands/pfmerge
2856
+ */
2857
+ pfmerge = (...args) => this.chain(new PfMergeCommand(args, this.commandOptions));
2858
+ /**
2859
+ * @see https://redis.io/commands/ping
2860
+ */
2861
+ ping = (args) => this.chain(new PingCommand(args, this.commandOptions));
2862
+ /**
2863
+ * @see https://redis.io/commands/psetex
2864
+ */
2865
+ psetex = (key, ttl, value) => this.chain(new PSetEXCommand([key, ttl, value], this.commandOptions));
2866
+ /**
2867
+ * @see https://redis.io/commands/pttl
2868
+ */
2869
+ pttl = (...args) => this.chain(new PTtlCommand(args, this.commandOptions));
2870
+ /**
2871
+ * @see https://redis.io/commands/publish
2872
+ */
2873
+ publish = (...args) => this.chain(new PublishCommand(args, this.commandOptions));
2874
+ /**
2875
+ * @see https://redis.io/commands/randomkey
2876
+ */
2877
+ randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions));
2878
+ /**
2879
+ * @see https://redis.io/commands/rename
2880
+ */
2881
+ rename = (...args) => this.chain(new RenameCommand(args, this.commandOptions));
2882
+ /**
2883
+ * @see https://redis.io/commands/renamenx
2884
+ */
2885
+ renamenx = (...args) => this.chain(new RenameNXCommand(args, this.commandOptions));
2886
+ /**
2887
+ * @see https://redis.io/commands/rpop
2888
+ */
2889
+ rpop = (...args) => this.chain(new RPopCommand(args, this.commandOptions));
2890
+ /**
2891
+ * @see https://redis.io/commands/rpush
2892
+ */
2893
+ rpush = (key, ...elements) => this.chain(new RPushCommand([key, ...elements], this.commandOptions));
2894
+ /**
2895
+ * @see https://redis.io/commands/rpushx
2896
+ */
2897
+ rpushx = (key, ...elements) => this.chain(new RPushXCommand([key, ...elements], this.commandOptions));
2898
+ /**
2899
+ * @see https://redis.io/commands/sadd
2900
+ */
2901
+ sadd = (key, member, ...members) => this.chain(new SAddCommand([key, member, ...members], this.commandOptions));
2902
+ /**
2903
+ * @see https://redis.io/commands/scan
2904
+ */
2905
+ scan = (...args) => this.chain(new ScanCommand(args, this.commandOptions));
2906
+ /**
2907
+ * @see https://redis.io/commands/scard
2908
+ */
2909
+ scard = (...args) => this.chain(new SCardCommand(args, this.commandOptions));
2910
+ /**
2911
+ * @see https://redis.io/commands/script-exists
2912
+ */
2913
+ scriptExists = (...args) => this.chain(new ScriptExistsCommand(args, this.commandOptions));
2914
+ /**
2915
+ * @see https://redis.io/commands/script-flush
2916
+ */
2917
+ scriptFlush = (...args) => this.chain(new ScriptFlushCommand(args, this.commandOptions));
2918
+ /**
2919
+ * @see https://redis.io/commands/script-load
2920
+ */
2921
+ scriptLoad = (...args) => this.chain(new ScriptLoadCommand(args, this.commandOptions));
2922
+ /*)*
2923
+ * @see https://redis.io/commands/sdiff
2924
+ */
2925
+ sdiff = (...args) => this.chain(new SDiffCommand(args, this.commandOptions));
2926
+ /**
2927
+ * @see https://redis.io/commands/sdiffstore
2928
+ */
2929
+ sdiffstore = (...args) => this.chain(new SDiffStoreCommand(args, this.commandOptions));
2930
+ /**
2931
+ * @see https://redis.io/commands/set
2932
+ */
2933
+ set = (key, value, opts) => this.chain(new SetCommand([key, value, opts], this.commandOptions));
2934
+ /**
2935
+ * @see https://redis.io/commands/setbit
2936
+ */
2937
+ setbit = (...args) => this.chain(new SetBitCommand(args, this.commandOptions));
2938
+ /**
2939
+ * @see https://redis.io/commands/setex
2940
+ */
2941
+ setex = (key, ttl, value) => this.chain(new SetExCommand([key, ttl, value], this.commandOptions));
2942
+ /**
2943
+ * @see https://redis.io/commands/setnx
2944
+ */
2945
+ setnx = (key, value) => this.chain(new SetNxCommand([key, value], this.commandOptions));
2946
+ /**
2947
+ * @see https://redis.io/commands/setrange
2948
+ */
2949
+ setrange = (...args) => this.chain(new SetRangeCommand(args, this.commandOptions));
2950
+ /**
2951
+ * @see https://redis.io/commands/sinter
2952
+ */
2953
+ sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
2954
+ /**
2955
+ * @see https://redis.io/commands/sinterstore
2956
+ */
2957
+ sinterstore = (...args) => this.chain(new SInterStoreCommand(args, this.commandOptions));
2958
+ /**
2959
+ * @see https://redis.io/commands/sismember
2960
+ */
2961
+ sismember = (key, member) => this.chain(new SIsMemberCommand([key, member], this.commandOptions));
2962
+ /**
2963
+ * @see https://redis.io/commands/smembers
2964
+ */
2965
+ smembers = (...args) => this.chain(new SMembersCommand(args, this.commandOptions));
2966
+ /**
2967
+ * @see https://redis.io/commands/smismember
2968
+ */
2969
+ smismember = (key, members) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions));
2970
+ /**
2971
+ * @see https://redis.io/commands/smove
2972
+ */
2973
+ smove = (source, destination, member) => this.chain(new SMoveCommand([source, destination, member], this.commandOptions));
2974
+ /**
2975
+ * @see https://redis.io/commands/spop
2976
+ */
2977
+ spop = (...args) => this.chain(new SPopCommand(args, this.commandOptions));
2978
+ /**
2979
+ * @see https://redis.io/commands/srandmember
2980
+ */
2981
+ srandmember = (...args) => this.chain(new SRandMemberCommand(args, this.commandOptions));
2982
+ /**
2983
+ * @see https://redis.io/commands/srem
2984
+ */
2985
+ srem = (key, ...members) => this.chain(new SRemCommand([key, ...members], this.commandOptions));
2986
+ /**
2987
+ * @see https://redis.io/commands/sscan
2988
+ */
2989
+ sscan = (...args) => this.chain(new SScanCommand(args, this.commandOptions));
2990
+ /**
2991
+ * @see https://redis.io/commands/strlen
2992
+ */
2993
+ strlen = (...args) => this.chain(new StrLenCommand(args, this.commandOptions));
2994
+ /**
2995
+ * @see https://redis.io/commands/sunion
2996
+ */
2997
+ sunion = (...args) => this.chain(new SUnionCommand(args, this.commandOptions));
2998
+ /**
2999
+ * @see https://redis.io/commands/sunionstore
3000
+ */
3001
+ sunionstore = (...args) => this.chain(new SUnionStoreCommand(args, this.commandOptions));
3002
+ /**
3003
+ * @see https://redis.io/commands/time
3004
+ */
3005
+ time = () => this.chain(new TimeCommand(this.commandOptions));
3006
+ /**
3007
+ * @see https://redis.io/commands/touch
3008
+ */
3009
+ touch = (...args) => this.chain(new TouchCommand(args, this.commandOptions));
3010
+ /**
3011
+ * @see https://redis.io/commands/ttl
3012
+ */
3013
+ ttl = (...args) => this.chain(new TtlCommand(args, this.commandOptions));
3014
+ /**
3015
+ * @see https://redis.io/commands/type
3016
+ */
3017
+ type = (...args) => this.chain(new TypeCommand(args, this.commandOptions));
3018
+ /**
3019
+ * @see https://redis.io/commands/unlink
3020
+ */
3021
+ unlink = (...args) => this.chain(new UnlinkCommand(args, this.commandOptions));
3022
+ /**
3023
+ * @see https://redis.io/commands/zadd
3024
+ */
3025
+ zadd = (...args) => {
3026
+ if ("score" in args[1]) {
3027
+ return this.chain(
3028
+ new ZAddCommand([args[0], args[1], ...args.slice(2)], this.commandOptions)
3029
+ );
3030
+ }
3031
+ return this.chain(
3032
+ new ZAddCommand(
3033
+ [args[0], args[1], ...args.slice(2)],
3034
+ this.commandOptions
3035
+ )
3036
+ );
3037
+ };
3038
+ /**
3039
+ * @see https://redis.io/commands/xadd
3040
+ */
3041
+ xadd = (...args) => this.chain(new XAddCommand(args, this.commandOptions));
3042
+ /**
3043
+ * @see https://redis.io/commands/xack
3044
+ */
3045
+ xack = (...args) => this.chain(new XAckCommand(args, this.commandOptions));
3046
+ /**
3047
+ * @see https://redis.io/commands/xdel
3048
+ */
3049
+ xdel = (...args) => this.chain(new XDelCommand(args, this.commandOptions));
3050
+ /**
3051
+ * @see https://redis.io/commands/xgroup
3052
+ */
3053
+ xgroup = (...args) => this.chain(new XGroupCommand(args, this.commandOptions));
3054
+ /**
3055
+ * @see https://redis.io/commands/xread
3056
+ */
3057
+ xread = (...args) => this.chain(new XReadCommand(args, this.commandOptions));
3058
+ /**
3059
+ * @see https://redis.io/commands/xreadgroup
3060
+ */
3061
+ xreadgroup = (...args) => this.chain(new XReadGroupCommand(args, this.commandOptions));
3062
+ /**
3063
+ * @see https://redis.io/commands/xinfo
3064
+ */
3065
+ xinfo = (...args) => this.chain(new XInfoCommand(args, this.commandOptions));
3066
+ /**
3067
+ * @see https://redis.io/commands/xlen
3068
+ */
3069
+ xlen = (...args) => this.chain(new XLenCommand(args, this.commandOptions));
3070
+ /**
3071
+ * @see https://redis.io/commands/xpending
3072
+ */
3073
+ xpending = (...args) => this.chain(new XPendingCommand(args, this.commandOptions));
3074
+ /**
3075
+ * @see https://redis.io/commands/xclaim
3076
+ */
3077
+ xclaim = (...args) => this.chain(new XClaimCommand(args, this.commandOptions));
3078
+ /**
3079
+ * @see https://redis.io/commands/xautoclaim
3080
+ */
3081
+ xautoclaim = (...args) => this.chain(new XAutoClaim(args, this.commandOptions));
3082
+ /**
3083
+ * @see https://redis.io/commands/xtrim
3084
+ */
3085
+ xtrim = (...args) => this.chain(new XTrimCommand(args, this.commandOptions));
3086
+ /**
3087
+ * @see https://redis.io/commands/xrange
3088
+ */
3089
+ xrange = (...args) => this.chain(new XRangeCommand(args, this.commandOptions));
3090
+ /**
3091
+ * @see https://redis.io/commands/xrevrange
3092
+ */
3093
+ xrevrange = (...args) => this.chain(new XRevRangeCommand(args, this.commandOptions));
3094
+ /**
3095
+ * @see https://redis.io/commands/zcard
3096
+ */
3097
+ zcard = (...args) => this.chain(new ZCardCommand(args, this.commandOptions));
3098
+ /**
3099
+ * @see https://redis.io/commands/zcount
3100
+ */
3101
+ zcount = (...args) => this.chain(new ZCountCommand(args, this.commandOptions));
3102
+ /**
3103
+ * @see https://redis.io/commands/zincrby
3104
+ */
3105
+ zincrby = (key, increment, member) => this.chain(new ZIncrByCommand([key, increment, member], this.commandOptions));
3106
+ /**
3107
+ * @see https://redis.io/commands/zinterstore
3108
+ */
3109
+ zinterstore = (...args) => this.chain(new ZInterStoreCommand(args, this.commandOptions));
3110
+ /**
3111
+ * @see https://redis.io/commands/zlexcount
3112
+ */
3113
+ zlexcount = (...args) => this.chain(new ZLexCountCommand(args, this.commandOptions));
3114
+ /**
3115
+ * @see https://redis.io/commands/zmscore
3116
+ */
3117
+ zmscore = (...args) => this.chain(new ZMScoreCommand(args, this.commandOptions));
3118
+ /**
3119
+ * @see https://redis.io/commands/zpopmax
3120
+ */
3121
+ zpopmax = (...args) => this.chain(new ZPopMaxCommand(args, this.commandOptions));
3122
+ /**
3123
+ * @see https://redis.io/commands/zpopmin
3124
+ */
3125
+ zpopmin = (...args) => this.chain(new ZPopMinCommand(args, this.commandOptions));
3126
+ /**
3127
+ * @see https://redis.io/commands/zrange
3128
+ */
3129
+ zrange = (...args) => this.chain(new ZRangeCommand(args, this.commandOptions));
3130
+ /**
3131
+ * @see https://redis.io/commands/zrank
3132
+ */
3133
+ zrank = (key, member) => this.chain(new ZRankCommand([key, member], this.commandOptions));
3134
+ /**
3135
+ * @see https://redis.io/commands/zrem
3136
+ */
3137
+ zrem = (key, ...members) => this.chain(new ZRemCommand([key, ...members], this.commandOptions));
3138
+ /**
3139
+ * @see https://redis.io/commands/zremrangebylex
3140
+ */
3141
+ zremrangebylex = (...args) => this.chain(new ZRemRangeByLexCommand(args, this.commandOptions));
3142
+ /**
3143
+ * @see https://redis.io/commands/zremrangebyrank
3144
+ */
3145
+ zremrangebyrank = (...args) => this.chain(new ZRemRangeByRankCommand(args, this.commandOptions));
3146
+ /**
3147
+ * @see https://redis.io/commands/zremrangebyscore
3148
+ */
3149
+ zremrangebyscore = (...args) => this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions));
3150
+ /**
3151
+ * @see https://redis.io/commands/zrevrank
3152
+ */
3153
+ zrevrank = (key, member) => this.chain(new ZRevRankCommand([key, member], this.commandOptions));
3154
+ /**
3155
+ * @see https://redis.io/commands/zscan
3156
+ */
3157
+ zscan = (...args) => this.chain(new ZScanCommand(args, this.commandOptions));
3158
+ /**
3159
+ * @see https://redis.io/commands/zscore
3160
+ */
3161
+ zscore = (key, member) => this.chain(new ZScoreCommand([key, member], this.commandOptions));
3162
+ /**
3163
+ * @see https://redis.io/commands/zunionstore
3164
+ */
3165
+ zunionstore = (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions));
3166
+ /**
3167
+ * @see https://redis.io/commands/zunion
3168
+ */
3169
+ zunion = (...args) => this.chain(new ZUnionCommand(args, this.commandOptions));
3170
+ /**
3171
+ * @see https://redis.io/commands/?group=json
3172
+ */
3173
+ get json() {
3174
+ return {
3175
+ /**
3176
+ * @see https://redis.io/commands/json.arrappend
3177
+ */
3178
+ arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
3179
+ /**
3180
+ * @see https://redis.io/commands/json.arrindex
3181
+ */
3182
+ arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
3183
+ /**
3184
+ * @see https://redis.io/commands/json.arrinsert
3185
+ */
3186
+ arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
3187
+ /**
3188
+ * @see https://redis.io/commands/json.arrlen
3189
+ */
3190
+ arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
3191
+ /**
3192
+ * @see https://redis.io/commands/json.arrpop
3193
+ */
3194
+ arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
3195
+ /**
3196
+ * @see https://redis.io/commands/json.arrtrim
3197
+ */
3198
+ arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
3199
+ /**
3200
+ * @see https://redis.io/commands/json.clear
3201
+ */
3202
+ clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
3203
+ /**
3204
+ * @see https://redis.io/commands/json.del
3205
+ */
3206
+ del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
3207
+ /**
3208
+ * @see https://redis.io/commands/json.forget
3209
+ */
3210
+ forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
3211
+ /**
3212
+ * @see https://redis.io/commands/json.get
3213
+ */
3214
+ get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
3215
+ /**
3216
+ * @see https://redis.io/commands/json.mget
3217
+ */
3218
+ mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
3219
+ /**
3220
+ * @see https://redis.io/commands/json.mset
3221
+ */
3222
+ mset: (...args) => this.chain(new JsonMSetCommand(args, this.commandOptions)),
3223
+ /**
3224
+ * @see https://redis.io/commands/json.numincrby
3225
+ */
3226
+ numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
3227
+ /**
3228
+ * @see https://redis.io/commands/json.nummultby
3229
+ */
3230
+ nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
3231
+ /**
3232
+ * @see https://redis.io/commands/json.objkeys
3233
+ */
3234
+ objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
3235
+ /**
3236
+ * @see https://redis.io/commands/json.objlen
3237
+ */
3238
+ objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
3239
+ /**
3240
+ * @see https://redis.io/commands/json.resp
3241
+ */
3242
+ resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
3243
+ /**
3244
+ * @see https://redis.io/commands/json.set
3245
+ */
3246
+ set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
3247
+ /**
3248
+ * @see https://redis.io/commands/json.strappend
3249
+ */
3250
+ strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
3251
+ /**
3252
+ * @see https://redis.io/commands/json.strlen
3253
+ */
3254
+ strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
3255
+ /**
3256
+ * @see https://redis.io/commands/json.toggle
3257
+ */
3258
+ toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
3259
+ /**
3260
+ * @see https://redis.io/commands/json.type
3261
+ */
3262
+ type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
3263
+ };
3264
+ }
3265
+ };
3266
+
3267
+ // pkg/script.ts
3268
+ var import_enc_hex = __toESM(require("crypto-js/enc-hex.js"));
3269
+ var import_sha1 = __toESM(require("crypto-js/sha1.js"));
3270
+ var Script = class {
3271
+ script;
3272
+ sha1;
3273
+ redis;
3274
+ constructor(redis, script) {
3275
+ this.redis = redis;
3276
+ this.sha1 = this.digest(script);
3277
+ this.script = script;
3278
+ }
3279
+ /**
3280
+ * Send an `EVAL` command to redis.
3281
+ */
3282
+ async eval(keys, args) {
3283
+ return await this.redis.eval(this.script, keys, args);
3284
+ }
3285
+ /**
3286
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
3287
+ */
3288
+ async evalsha(keys, args) {
3289
+ return await this.redis.evalsha(this.sha1, keys, args);
3290
+ }
3291
+ /**
3292
+ * Optimistically try to run `EVALSHA` first.
3293
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
3294
+ *
3295
+ * Following calls will be able to use the cached script
3296
+ */
3297
+ async exec(keys, args) {
3298
+ const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
3299
+ if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3300
+ return await this.redis.eval(this.script, keys, args);
3301
+ }
3302
+ throw error;
3303
+ });
3304
+ return res;
3305
+ }
3306
+ /**
3307
+ * Compute the sha1 hash of the script and return its hex representation.
3308
+ */
3309
+ digest(s) {
3310
+ return import_enc_hex.default.stringify((0, import_sha1.default)(s));
3311
+ }
3312
+ };
3313
+
3314
+ // pkg/redis.ts
3315
+ var Redis = class {
3316
+ client;
3317
+ opts;
3318
+ enableTelemetry;
3319
+ enableAutoPipelining;
3320
+ /**
3321
+ * Create a new redis client
3322
+ *
3323
+ * @example
3324
+ * ```typescript
3325
+ * const redis = new Redis({
3326
+ * url: "<UPSTASH_REDIS_REST_URL>",
3327
+ * token: "<UPSTASH_REDIS_REST_TOKEN>",
3328
+ * });
3329
+ * ```
3330
+ */
3331
+ constructor(client, opts) {
3332
+ this.client = client;
3333
+ this.opts = opts;
3334
+ this.enableTelemetry = opts?.enableTelemetry ?? true;
3335
+ if (opts?.readYourWrites === false) {
3336
+ this.client.readYourWrites = false;
3337
+ }
3338
+ this.enableAutoPipelining = opts?.enableAutoPipelining ?? true;
3339
+ }
3340
+ get readYourWritesSyncToken() {
3341
+ return this.client.upstashSyncToken;
3342
+ }
3343
+ set readYourWritesSyncToken(session) {
3344
+ this.client.upstashSyncToken = session;
3345
+ }
3346
+ get json() {
3347
+ return {
3348
+ /**
3349
+ * @see https://redis.io/commands/json.arrappend
3350
+ */
3351
+ arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
3352
+ /**
3353
+ * @see https://redis.io/commands/json.arrindex
3354
+ */
3355
+ arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
3356
+ /**
3357
+ * @see https://redis.io/commands/json.arrinsert
3358
+ */
3359
+ arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
3360
+ /**
3361
+ * @see https://redis.io/commands/json.arrlen
3362
+ */
3363
+ arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
3364
+ /**
3365
+ * @see https://redis.io/commands/json.arrpop
3366
+ */
3367
+ arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
3368
+ /**
3369
+ * @see https://redis.io/commands/json.arrtrim
3370
+ */
3371
+ arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
3372
+ /**
3373
+ * @see https://redis.io/commands/json.clear
3374
+ */
3375
+ clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
3376
+ /**
3377
+ * @see https://redis.io/commands/json.del
3378
+ */
3379
+ del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
3380
+ /**
3381
+ * @see https://redis.io/commands/json.forget
3382
+ */
3383
+ forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
3384
+ /**
3385
+ * @see https://redis.io/commands/json.get
3386
+ */
3387
+ get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
3388
+ /**
3389
+ * @see https://redis.io/commands/json.mget
3390
+ */
3391
+ mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
3392
+ /**
3393
+ * @see https://redis.io/commands/json.mset
3394
+ */
3395
+ mset: (...args) => new JsonMSetCommand(args, this.opts).exec(this.client),
3396
+ /**
3397
+ * @see https://redis.io/commands/json.numincrby
3398
+ */
3399
+ numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
3400
+ /**
3401
+ * @see https://redis.io/commands/json.nummultby
3402
+ */
3403
+ nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
3404
+ /**
3405
+ * @see https://redis.io/commands/json.objkeys
3406
+ */
3407
+ objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
3408
+ /**
3409
+ * @see https://redis.io/commands/json.objlen
3410
+ */
3411
+ objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
3412
+ /**
3413
+ * @see https://redis.io/commands/json.resp
3414
+ */
3415
+ resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
3416
+ /**
3417
+ * @see https://redis.io/commands/json.set
3418
+ */
3419
+ set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
3420
+ /**
3421
+ * @see https://redis.io/commands/json.strappend
3422
+ */
3423
+ strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
3424
+ /**
3425
+ * @see https://redis.io/commands/json.strlen
3426
+ */
3427
+ strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
3428
+ /**
3429
+ * @see https://redis.io/commands/json.toggle
3430
+ */
3431
+ toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
3432
+ /**
3433
+ * @see https://redis.io/commands/json.type
3434
+ */
3435
+ type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
3436
+ };
3437
+ }
3438
+ /**
3439
+ * Wrap a new middleware around the HTTP client.
3440
+ */
3441
+ use = (middleware) => {
3442
+ const makeRequest = this.client.request.bind(this.client);
3443
+ this.client.request = (req) => middleware(req, makeRequest);
3444
+ };
3445
+ /**
3446
+ * Technically this is not private, we can hide it from intellisense by doing this
3447
+ */
3448
+ addTelemetry = (telemetry) => {
3449
+ if (!this.enableTelemetry) {
3450
+ return;
3451
+ }
3452
+ try {
3453
+ this.client.mergeTelemetry(telemetry);
3454
+ } catch {
3455
+ }
3456
+ };
3457
+ createScript(script) {
3458
+ return new Script(this, script);
3459
+ }
3460
+ /**
3461
+ * Create a new pipeline that allows you to send requests in bulk.
3462
+ *
3463
+ * @see {@link Pipeline}
3464
+ */
3465
+ pipeline = () => new Pipeline({
3466
+ client: this.client,
3467
+ commandOptions: this.opts,
3468
+ multiExec: false
3469
+ });
3470
+ autoPipeline = () => {
3471
+ return createAutoPipelineProxy(this);
3472
+ };
3473
+ /**
3474
+ * Create a new transaction to allow executing multiple steps atomically.
3475
+ *
3476
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
3477
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
3478
+ * guarantees that the commands are executed as a single isolated operation.
3479
+ *
3480
+ * @see {@link Pipeline}
3481
+ */
3482
+ multi = () => new Pipeline({
3483
+ client: this.client,
3484
+ commandOptions: this.opts,
3485
+ multiExec: true
3486
+ });
3487
+ /**
3488
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
3489
+ *
3490
+ * @example
3491
+ * ```typescript
3492
+ * redis.set("mykey", 0);
3493
+ * const result = await redis.bitfield("mykey")
3494
+ * .set("u4", 0, 16)
3495
+ * .incr("u4", "#1", 1)
3496
+ * .exec();
3497
+ * console.log(result); // [0, 1]
3498
+ * ```
3499
+ *
3500
+ * @see https://redis.io/commands/bitfield
3501
+ */
3502
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.opts);
3503
+ /**
3504
+ * @see https://redis.io/commands/append
3505
+ */
3506
+ append = (...args) => new AppendCommand(args, this.opts).exec(this.client);
3507
+ /**
3508
+ * @see https://redis.io/commands/bitcount
3509
+ */
3510
+ bitcount = (...args) => new BitCountCommand(args, this.opts).exec(this.client);
3511
+ /**
3512
+ * @see https://redis.io/commands/bitop
3513
+ */
3514
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.opts).exec(
3515
+ this.client
3516
+ );
3517
+ /**
3518
+ * @see https://redis.io/commands/bitpos
3519
+ */
3520
+ bitpos = (...args) => new BitPosCommand(args, this.opts).exec(this.client);
3521
+ /**
3522
+ * @see https://redis.io/commands/copy
3523
+ */
3524
+ copy = (...args) => new CopyCommand(args, this.opts).exec(this.client);
3525
+ /**
3526
+ * @see https://redis.io/commands/dbsize
3527
+ */
3528
+ dbsize = () => new DBSizeCommand(this.opts).exec(this.client);
3529
+ /**
3530
+ * @see https://redis.io/commands/decr
3531
+ */
3532
+ decr = (...args) => new DecrCommand(args, this.opts).exec(this.client);
3533
+ /**
3534
+ * @see https://redis.io/commands/decrby
3535
+ */
3536
+ decrby = (...args) => new DecrByCommand(args, this.opts).exec(this.client);
3537
+ /**
3538
+ * @see https://redis.io/commands/del
3539
+ */
3540
+ del = (...args) => new DelCommand(args, this.opts).exec(this.client);
3541
+ /**
3542
+ * @see https://redis.io/commands/echo
3543
+ */
3544
+ echo = (...args) => new EchoCommand(args, this.opts).exec(this.client);
3545
+ /**
3546
+ * @see https://redis.io/commands/eval
3547
+ */
3548
+ eval = (...args) => new EvalCommand(args, this.opts).exec(this.client);
3549
+ /**
3550
+ * @see https://redis.io/commands/evalsha
3551
+ */
3552
+ evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
3553
+ /**
3554
+ * Generic method to execute any Redis command.
3555
+ */
3556
+ exec = (args) => new ExecCommand(args, this.opts).exec(this.client);
3557
+ /**
3558
+ * @see https://redis.io/commands/exists
3559
+ */
3560
+ exists = (...args) => new ExistsCommand(args, this.opts).exec(this.client);
3561
+ /**
3562
+ * @see https://redis.io/commands/expire
3563
+ */
3564
+ expire = (...args) => new ExpireCommand(args, this.opts).exec(this.client);
3565
+ /**
3566
+ * @see https://redis.io/commands/expireat
3567
+ */
3568
+ expireat = (...args) => new ExpireAtCommand(args, this.opts).exec(this.client);
3569
+ /**
3570
+ * @see https://redis.io/commands/flushall
3571
+ */
3572
+ flushall = (args) => new FlushAllCommand(args, this.opts).exec(this.client);
3573
+ /**
3574
+ * @see https://redis.io/commands/flushdb
3575
+ */
3576
+ flushdb = (...args) => new FlushDBCommand(args, this.opts).exec(this.client);
3577
+ /**
3578
+ * @see https://redis.io/commands/geoadd
3579
+ */
3580
+ geoadd = (...args) => new GeoAddCommand(args, this.opts).exec(this.client);
3581
+ /**
3582
+ * @see https://redis.io/commands/geopos
3583
+ */
3584
+ geopos = (...args) => new GeoPosCommand(args, this.opts).exec(this.client);
3585
+ /**
3586
+ * @see https://redis.io/commands/geodist
3587
+ */
3588
+ geodist = (...args) => new GeoDistCommand(args, this.opts).exec(this.client);
3589
+ /**
3590
+ * @see https://redis.io/commands/geohash
3591
+ */
3592
+ geohash = (...args) => new GeoHashCommand(args, this.opts).exec(this.client);
3593
+ /**
3594
+ * @see https://redis.io/commands/geosearch
3595
+ */
3596
+ geosearch = (...args) => new GeoSearchCommand(args, this.opts).exec(this.client);
3597
+ /**
3598
+ * @see https://redis.io/commands/geosearchstore
3599
+ */
3600
+ geosearchstore = (...args) => new GeoSearchStoreCommand(args, this.opts).exec(this.client);
3601
+ /**
3602
+ * @see https://redis.io/commands/get
3603
+ */
3604
+ get = (...args) => new GetCommand(args, this.opts).exec(this.client);
3605
+ /**
3606
+ * @see https://redis.io/commands/getbit
3607
+ */
3608
+ getbit = (...args) => new GetBitCommand(args, this.opts).exec(this.client);
3609
+ /**
3610
+ * @see https://redis.io/commands/getdel
3611
+ */
3612
+ getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
3613
+ /**
3614
+ * @see https://redis.io/commands/getex
3615
+ */
3616
+ getex = (...args) => new GetExCommand(args, this.opts).exec(this.client);
3617
+ /**
3618
+ * @see https://redis.io/commands/getrange
3619
+ */
3620
+ getrange = (...args) => new GetRangeCommand(args, this.opts).exec(this.client);
3621
+ /**
3622
+ * @see https://redis.io/commands/getset
3623
+ */
3624
+ getset = (key, value) => new GetSetCommand([key, value], this.opts).exec(this.client);
3625
+ /**
3626
+ * @see https://redis.io/commands/hdel
3627
+ */
3628
+ hdel = (...args) => new HDelCommand(args, this.opts).exec(this.client);
3629
+ /**
3630
+ * @see https://redis.io/commands/hexists
3631
+ */
3632
+ hexists = (...args) => new HExistsCommand(args, this.opts).exec(this.client);
3633
+ /**
3634
+ * @see https://redis.io/commands/hget
3635
+ */
3636
+ hget = (...args) => new HGetCommand(args, this.opts).exec(this.client);
3637
+ /**
3638
+ * @see https://redis.io/commands/hgetall
3639
+ */
3640
+ hgetall = (...args) => new HGetAllCommand(args, this.opts).exec(this.client);
3641
+ /**
3642
+ * @see https://redis.io/commands/hincrby
3643
+ */
3644
+ hincrby = (...args) => new HIncrByCommand(args, this.opts).exec(this.client);
3645
+ /**
3646
+ * @see https://redis.io/commands/hincrbyfloat
3647
+ */
3648
+ hincrbyfloat = (...args) => new HIncrByFloatCommand(args, this.opts).exec(this.client);
3649
+ /**
3650
+ * @see https://redis.io/commands/hkeys
3651
+ */
3652
+ hkeys = (...args) => new HKeysCommand(args, this.opts).exec(this.client);
3653
+ /**
3654
+ * @see https://redis.io/commands/hlen
3655
+ */
3656
+ hlen = (...args) => new HLenCommand(args, this.opts).exec(this.client);
3657
+ /**
3658
+ * @see https://redis.io/commands/hmget
3659
+ */
3660
+ hmget = (...args) => new HMGetCommand(args, this.opts).exec(this.client);
3661
+ /**
3662
+ * @see https://redis.io/commands/hmset
3663
+ */
3664
+ hmset = (key, kv) => new HMSetCommand([key, kv], this.opts).exec(this.client);
3665
+ /**
3666
+ * @see https://redis.io/commands/hrandfield
3667
+ */
3668
+ hrandfield = (key, count, withValues) => new HRandFieldCommand([key, count, withValues], this.opts).exec(this.client);
3669
+ /**
3670
+ * @see https://redis.io/commands/hscan
3671
+ */
3672
+ hscan = (...args) => new HScanCommand(args, this.opts).exec(this.client);
3673
+ /**
3674
+ * @see https://redis.io/commands/hset
3675
+ */
3676
+ hset = (key, kv) => new HSetCommand([key, kv], this.opts).exec(this.client);
3677
+ /**
3678
+ * @see https://redis.io/commands/hsetnx
3679
+ */
3680
+ hsetnx = (key, field, value) => new HSetNXCommand([key, field, value], this.opts).exec(this.client);
3681
+ /**
3682
+ * @see https://redis.io/commands/hstrlen
3683
+ */
3684
+ hstrlen = (...args) => new HStrLenCommand(args, this.opts).exec(this.client);
3685
+ /**
3686
+ * @see https://redis.io/commands/hvals
3687
+ */
3688
+ hvals = (...args) => new HValsCommand(args, this.opts).exec(this.client);
3689
+ /**
3690
+ * @see https://redis.io/commands/incr
3691
+ */
3692
+ incr = (...args) => new IncrCommand(args, this.opts).exec(this.client);
3693
+ /**
3694
+ * @see https://redis.io/commands/incrby
3695
+ */
3696
+ incrby = (...args) => new IncrByCommand(args, this.opts).exec(this.client);
3697
+ /**
3698
+ * @see https://redis.io/commands/incrbyfloat
3699
+ */
3700
+ incrbyfloat = (...args) => new IncrByFloatCommand(args, this.opts).exec(this.client);
3701
+ /**
3702
+ * @see https://redis.io/commands/keys
3703
+ */
3704
+ keys = (...args) => new KeysCommand(args, this.opts).exec(this.client);
3705
+ /**
3706
+ * @see https://redis.io/commands/lindex
3707
+ */
3708
+ lindex = (...args) => new LIndexCommand(args, this.opts).exec(this.client);
3709
+ /**
3710
+ * @see https://redis.io/commands/linsert
3711
+ */
3712
+ linsert = (key, direction, pivot, value) => new LInsertCommand([key, direction, pivot, value], this.opts).exec(this.client);
3713
+ /**
3714
+ * @see https://redis.io/commands/llen
3715
+ */
3716
+ llen = (...args) => new LLenCommand(args, this.opts).exec(this.client);
3717
+ /**
3718
+ * @see https://redis.io/commands/lmove
3719
+ */
3720
+ lmove = (...args) => new LMoveCommand(args, this.opts).exec(this.client);
3721
+ /**
3722
+ * @see https://redis.io/commands/lpop
3723
+ */
3724
+ lpop = (...args) => new LPopCommand(args, this.opts).exec(this.client);
3725
+ /**
3726
+ * @see https://redis.io/commands/lmpop
3727
+ */
3728
+ lmpop = (...args) => new LmPopCommand(args, this.opts).exec(this.client);
3729
+ /**
3730
+ * @see https://redis.io/commands/lpos
3731
+ */
3732
+ lpos = (...args) => new LPosCommand(args, this.opts).exec(this.client);
3733
+ /**
3734
+ * @see https://redis.io/commands/lpush
3735
+ */
3736
+ lpush = (key, ...elements) => new LPushCommand([key, ...elements], this.opts).exec(this.client);
3737
+ /**
3738
+ * @see https://redis.io/commands/lpushx
3739
+ */
3740
+ lpushx = (key, ...elements) => new LPushXCommand([key, ...elements], this.opts).exec(this.client);
3741
+ /**
3742
+ * @see https://redis.io/commands/lrange
3743
+ */
3744
+ lrange = (...args) => new LRangeCommand(args, this.opts).exec(this.client);
3745
+ /**
3746
+ * @see https://redis.io/commands/lrem
3747
+ */
3748
+ lrem = (key, count, value) => new LRemCommand([key, count, value], this.opts).exec(this.client);
3749
+ /**
3750
+ * @see https://redis.io/commands/lset
3751
+ */
3752
+ lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
3753
+ /**
3754
+ * @see https://redis.io/commands/ltrim
3755
+ */
3756
+ ltrim = (...args) => new LTrimCommand(args, this.opts).exec(this.client);
3757
+ /**
3758
+ * @see https://redis.io/commands/mget
3759
+ */
3760
+ mget = (...args) => new MGetCommand(args, this.opts).exec(this.client);
3761
+ /**
3762
+ * @see https://redis.io/commands/mset
3763
+ */
3764
+ mset = (kv) => new MSetCommand([kv], this.opts).exec(this.client);
3765
+ /**
3766
+ * @see https://redis.io/commands/msetnx
3767
+ */
3768
+ msetnx = (kv) => new MSetNXCommand([kv], this.opts).exec(this.client);
3769
+ /**
3770
+ * @see https://redis.io/commands/persist
3771
+ */
3772
+ persist = (...args) => new PersistCommand(args, this.opts).exec(this.client);
3773
+ /**
3774
+ * @see https://redis.io/commands/pexpire
3775
+ */
3776
+ pexpire = (...args) => new PExpireCommand(args, this.opts).exec(this.client);
3777
+ /**
3778
+ * @see https://redis.io/commands/pexpireat
3779
+ */
3780
+ pexpireat = (...args) => new PExpireAtCommand(args, this.opts).exec(this.client);
3781
+ /**
3782
+ * @see https://redis.io/commands/pfadd
3783
+ */
3784
+ pfadd = (...args) => new PfAddCommand(args, this.opts).exec(this.client);
3785
+ /**
3786
+ * @see https://redis.io/commands/pfcount
3787
+ */
3788
+ pfcount = (...args) => new PfCountCommand(args, this.opts).exec(this.client);
3789
+ /**
3790
+ * @see https://redis.io/commands/pfmerge
3791
+ */
3792
+ pfmerge = (...args) => new PfMergeCommand(args, this.opts).exec(this.client);
3793
+ /**
3794
+ * @see https://redis.io/commands/ping
3795
+ */
3796
+ ping = (args) => new PingCommand(args, this.opts).exec(this.client);
3797
+ /**
3798
+ * @see https://redis.io/commands/psetex
3799
+ */
3800
+ psetex = (key, ttl, value) => new PSetEXCommand([key, ttl, value], this.opts).exec(this.client);
3801
+ psubscribe = (patterns) => {
3802
+ const patternArray = Array.isArray(patterns) ? patterns : [patterns];
3803
+ return new Subscriber(this.client, patternArray, true);
3804
+ };
3805
+ /**
3806
+ * @see https://redis.io/commands/pttl
3807
+ */
3808
+ pttl = (...args) => new PTtlCommand(args, this.opts).exec(this.client);
3809
+ /**
3810
+ * @see https://redis.io/commands/publish
3811
+ */
3812
+ publish = (...args) => new PublishCommand(args, this.opts).exec(this.client);
3813
+ /**
3814
+ * @see https://redis.io/commands/randomkey
3815
+ */
3816
+ randomkey = () => new RandomKeyCommand().exec(this.client);
3817
+ /**
3818
+ * @see https://redis.io/commands/rename
3819
+ */
3820
+ rename = (...args) => new RenameCommand(args, this.opts).exec(this.client);
3821
+ /**
3822
+ * @see https://redis.io/commands/renamenx
3823
+ */
3824
+ renamenx = (...args) => new RenameNXCommand(args, this.opts).exec(this.client);
3825
+ /**
3826
+ * @see https://redis.io/commands/rpop
3827
+ */
3828
+ rpop = (...args) => new RPopCommand(args, this.opts).exec(this.client);
3829
+ /**
3830
+ * @see https://redis.io/commands/rpush
3831
+ */
3832
+ rpush = (key, ...elements) => new RPushCommand([key, ...elements], this.opts).exec(this.client);
3833
+ /**
3834
+ * @see https://redis.io/commands/rpushx
3835
+ */
3836
+ rpushx = (key, ...elements) => new RPushXCommand([key, ...elements], this.opts).exec(this.client);
3837
+ /**
3838
+ * @see https://redis.io/commands/sadd
3839
+ */
3840
+ sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
3841
+ /**
3842
+ * @see https://redis.io/commands/scan
3843
+ */
3844
+ scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
3845
+ /**
3846
+ * @see https://redis.io/commands/scard
3847
+ */
3848
+ scard = (...args) => new SCardCommand(args, this.opts).exec(this.client);
3849
+ /**
3850
+ * @see https://redis.io/commands/script-exists
3851
+ */
3852
+ scriptExists = (...args) => new ScriptExistsCommand(args, this.opts).exec(this.client);
3853
+ /**
3854
+ * @see https://redis.io/commands/script-flush
3855
+ */
3856
+ scriptFlush = (...args) => new ScriptFlushCommand(args, this.opts).exec(this.client);
3857
+ /**
3858
+ * @see https://redis.io/commands/script-load
3859
+ */
3860
+ scriptLoad = (...args) => new ScriptLoadCommand(args, this.opts).exec(this.client);
3861
+ /**
3862
+ * @see https://redis.io/commands/sdiff
3863
+ */
3864
+ sdiff = (...args) => new SDiffCommand(args, this.opts).exec(this.client);
3865
+ /**
3866
+ * @see https://redis.io/commands/sdiffstore
3867
+ */
3868
+ sdiffstore = (...args) => new SDiffStoreCommand(args, this.opts).exec(this.client);
3869
+ /**
3870
+ * @see https://redis.io/commands/set
3871
+ */
3872
+ set = (key, value, opts) => new SetCommand([key, value, opts], this.opts).exec(this.client);
3873
+ /**
3874
+ * @see https://redis.io/commands/setbit
3875
+ */
3876
+ setbit = (...args) => new SetBitCommand(args, this.opts).exec(this.client);
3877
+ /**
3878
+ * @see https://redis.io/commands/setex
3879
+ */
3880
+ setex = (key, ttl, value) => new SetExCommand([key, ttl, value], this.opts).exec(this.client);
3881
+ /**
3882
+ * @see https://redis.io/commands/setnx
3883
+ */
3884
+ setnx = (key, value) => new SetNxCommand([key, value], this.opts).exec(this.client);
3885
+ /**
3886
+ * @see https://redis.io/commands/setrange
3887
+ */
3888
+ setrange = (...args) => new SetRangeCommand(args, this.opts).exec(this.client);
3889
+ /**
3890
+ * @see https://redis.io/commands/sinter
3891
+ */
3892
+ sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
3893
+ /**
3894
+ * @see https://redis.io/commands/sinterstore
3895
+ */
3896
+ sinterstore = (...args) => new SInterStoreCommand(args, this.opts).exec(this.client);
3897
+ /**
3898
+ * @see https://redis.io/commands/sismember
3899
+ */
3900
+ sismember = (key, member) => new SIsMemberCommand([key, member], this.opts).exec(this.client);
3901
+ /**
3902
+ * @see https://redis.io/commands/smismember
3903
+ */
3904
+ smismember = (key, members) => new SMIsMemberCommand([key, members], this.opts).exec(this.client);
3905
+ /**
3906
+ * @see https://redis.io/commands/smembers
3907
+ */
3908
+ smembers = (...args) => new SMembersCommand(args, this.opts).exec(this.client);
3909
+ /**
3910
+ * @see https://redis.io/commands/smove
3911
+ */
3912
+ smove = (source, destination, member) => new SMoveCommand([source, destination, member], this.opts).exec(this.client);
3913
+ /**
3914
+ * @see https://redis.io/commands/spop
3915
+ */
3916
+ spop = (...args) => new SPopCommand(args, this.opts).exec(this.client);
3917
+ /**
3918
+ * @see https://redis.io/commands/srandmember
3919
+ */
3920
+ srandmember = (...args) => new SRandMemberCommand(args, this.opts).exec(this.client);
3921
+ /**
3922
+ * @see https://redis.io/commands/srem
3923
+ */
3924
+ srem = (key, ...members) => new SRemCommand([key, ...members], this.opts).exec(this.client);
3925
+ /**
3926
+ * @see https://redis.io/commands/sscan
3927
+ */
3928
+ sscan = (...args) => new SScanCommand(args, this.opts).exec(this.client);
3929
+ /**
3930
+ * @see https://redis.io/commands/strlen
3931
+ */
3932
+ strlen = (...args) => new StrLenCommand(args, this.opts).exec(this.client);
3933
+ /**
3934
+ * @see https://redis.io/commands/subscribe
3935
+ */
3936
+ subscribe = (channels) => {
3937
+ const channelArray = Array.isArray(channels) ? channels : [channels];
3938
+ return new Subscriber(this.client, channelArray);
3939
+ };
3940
+ /**
3941
+ * @see https://redis.io/commands/sunion
3942
+ */
3943
+ sunion = (...args) => new SUnionCommand(args, this.opts).exec(this.client);
3944
+ /**
3945
+ * @see https://redis.io/commands/sunionstore
3946
+ */
3947
+ sunionstore = (...args) => new SUnionStoreCommand(args, this.opts).exec(this.client);
3948
+ /**
3949
+ * @see https://redis.io/commands/time
3950
+ */
3951
+ time = () => new TimeCommand().exec(this.client);
3952
+ /**
3953
+ * @see https://redis.io/commands/touch
3954
+ */
3955
+ touch = (...args) => new TouchCommand(args, this.opts).exec(this.client);
3956
+ /**
3957
+ * @see https://redis.io/commands/ttl
3958
+ */
3959
+ ttl = (...args) => new TtlCommand(args, this.opts).exec(this.client);
3960
+ /**
3961
+ * @see https://redis.io/commands/type
3962
+ */
3963
+ type = (...args) => new TypeCommand(args, this.opts).exec(this.client);
3964
+ /**
3965
+ * @see https://redis.io/commands/unlink
3966
+ */
3967
+ unlink = (...args) => new UnlinkCommand(args, this.opts).exec(this.client);
3968
+ /**
3969
+ * @see https://redis.io/commands/xadd
3970
+ */
3971
+ xadd = (...args) => new XAddCommand(args, this.opts).exec(this.client);
3972
+ /**
3973
+ * @see https://redis.io/commands/xack
3974
+ */
3975
+ xack = (...args) => new XAckCommand(args, this.opts).exec(this.client);
3976
+ /**
3977
+ * @see https://redis.io/commands/xdel
3978
+ */
3979
+ xdel = (...args) => new XDelCommand(args, this.opts).exec(this.client);
3980
+ /**
3981
+ * @see https://redis.io/commands/xgroup
3982
+ */
3983
+ xgroup = (...args) => new XGroupCommand(args, this.opts).exec(this.client);
3984
+ /**
3985
+ * @see https://redis.io/commands/xread
3986
+ */
3987
+ xread = (...args) => new XReadCommand(args, this.opts).exec(this.client);
3988
+ /**
3989
+ * @see https://redis.io/commands/xreadgroup
3990
+ */
3991
+ xreadgroup = (...args) => new XReadGroupCommand(args, this.opts).exec(this.client);
3992
+ /**
3993
+ * @see https://redis.io/commands/xinfo
3994
+ */
3995
+ xinfo = (...args) => new XInfoCommand(args, this.opts).exec(this.client);
3996
+ /**
3997
+ * @see https://redis.io/commands/xlen
3998
+ */
3999
+ xlen = (...args) => new XLenCommand(args, this.opts).exec(this.client);
4000
+ /**
4001
+ * @see https://redis.io/commands/xpending
4002
+ */
4003
+ xpending = (...args) => new XPendingCommand(args, this.opts).exec(this.client);
4004
+ /**
4005
+ * @see https://redis.io/commands/xclaim
4006
+ */
4007
+ xclaim = (...args) => new XClaimCommand(args, this.opts).exec(this.client);
4008
+ /**
4009
+ * @see https://redis.io/commands/xautoclaim
4010
+ */
4011
+ xautoclaim = (...args) => new XAutoClaim(args, this.opts).exec(this.client);
4012
+ /**
4013
+ * @see https://redis.io/commands/xtrim
4014
+ */
4015
+ xtrim = (...args) => new XTrimCommand(args, this.opts).exec(this.client);
4016
+ /**
4017
+ * @see https://redis.io/commands/xrange
4018
+ */
4019
+ xrange = (...args) => new XRangeCommand(args, this.opts).exec(this.client);
4020
+ /**
4021
+ * @see https://redis.io/commands/xrevrange
4022
+ */
4023
+ xrevrange = (...args) => new XRevRangeCommand(args, this.opts).exec(this.client);
4024
+ /**
4025
+ * @see https://redis.io/commands/zadd
4026
+ */
4027
+ zadd = (...args) => {
4028
+ if ("score" in args[1]) {
4029
+ return new ZAddCommand([args[0], args[1], ...args.slice(2)], this.opts).exec(
4030
+ this.client
4031
+ );
4032
+ }
4033
+ return new ZAddCommand(
4034
+ [args[0], args[1], ...args.slice(2)],
4035
+ this.opts
4036
+ ).exec(this.client);
4037
+ };
4038
+ /**
4039
+ * @see https://redis.io/commands/zcard
4040
+ */
4041
+ zcard = (...args) => new ZCardCommand(args, this.opts).exec(this.client);
4042
+ /**
4043
+ * @see https://redis.io/commands/zcount
4044
+ */
4045
+ zcount = (...args) => new ZCountCommand(args, this.opts).exec(this.client);
4046
+ /**
4047
+ * @see https://redis.io/commands/zdiffstore
4048
+ */
4049
+ zdiffstore = (...args) => new ZDiffStoreCommand(args, this.opts).exec(this.client);
4050
+ /**
4051
+ * @see https://redis.io/commands/zincrby
4052
+ */
4053
+ zincrby = (key, increment, member) => new ZIncrByCommand([key, increment, member], this.opts).exec(this.client);
4054
+ /**
4055
+ * @see https://redis.io/commands/zinterstore
4056
+ */
4057
+ zinterstore = (...args) => new ZInterStoreCommand(args, this.opts).exec(this.client);
4058
+ /**
4059
+ * @see https://redis.io/commands/zlexcount
4060
+ */
4061
+ zlexcount = (...args) => new ZLexCountCommand(args, this.opts).exec(this.client);
4062
+ /**
4063
+ * @see https://redis.io/commands/zmscore
4064
+ */
4065
+ zmscore = (...args) => new ZMScoreCommand(args, this.opts).exec(this.client);
4066
+ /**
4067
+ * @see https://redis.io/commands/zpopmax
4068
+ */
4069
+ zpopmax = (...args) => new ZPopMaxCommand(args, this.opts).exec(this.client);
4070
+ /**
4071
+ * @see https://redis.io/commands/zpopmin
4072
+ */
4073
+ zpopmin = (...args) => new ZPopMinCommand(args, this.opts).exec(this.client);
4074
+ /**
4075
+ * @see https://redis.io/commands/zrange
4076
+ */
4077
+ zrange = (...args) => new ZRangeCommand(args, this.opts).exec(this.client);
4078
+ /**
4079
+ * @see https://redis.io/commands/zrank
4080
+ */
4081
+ zrank = (key, member) => new ZRankCommand([key, member], this.opts).exec(this.client);
4082
+ /**
4083
+ * @see https://redis.io/commands/zrem
4084
+ */
4085
+ zrem = (key, ...members) => new ZRemCommand([key, ...members], this.opts).exec(this.client);
4086
+ /**
4087
+ * @see https://redis.io/commands/zremrangebylex
4088
+ */
4089
+ zremrangebylex = (...args) => new ZRemRangeByLexCommand(args, this.opts).exec(this.client);
4090
+ /**
4091
+ * @see https://redis.io/commands/zremrangebyrank
4092
+ */
4093
+ zremrangebyrank = (...args) => new ZRemRangeByRankCommand(args, this.opts).exec(this.client);
4094
+ /**
4095
+ * @see https://redis.io/commands/zremrangebyscore
4096
+ */
4097
+ zremrangebyscore = (...args) => new ZRemRangeByScoreCommand(args, this.opts).exec(this.client);
4098
+ /**
4099
+ * @see https://redis.io/commands/zrevrank
4100
+ */
4101
+ zrevrank = (key, member) => new ZRevRankCommand([key, member], this.opts).exec(this.client);
4102
+ /**
4103
+ * @see https://redis.io/commands/zscan
4104
+ */
4105
+ zscan = (...args) => new ZScanCommand(args, this.opts).exec(this.client);
4106
+ /**
4107
+ * @see https://redis.io/commands/zscore
4108
+ */
4109
+ zscore = (key, member) => new ZScoreCommand([key, member], this.opts).exec(this.client);
4110
+ /**
4111
+ * @see https://redis.io/commands/zunion
4112
+ */
4113
+ zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
4114
+ /**
4115
+ * @see https://redis.io/commands/zunionstore
4116
+ */
4117
+ zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
4118
+ };
4119
+
4120
+ // version.ts
4121
+ var VERSION = "v1.30.2";
4122
+
4123
+ // platforms/nodejs.ts
4124
+ if (typeof atob === "undefined") {
4125
+ global.atob = (b64) => Buffer.from(b64, "base64").toString("utf8");
4126
+ }
4127
+ var Redis2 = class _Redis extends Redis {
4128
+ /**
4129
+ * Create a new redis client by providing a custom `Requester` implementation
4130
+ *
4131
+ * @example
4132
+ * ```ts
4133
+ *
4134
+ * import { UpstashRequest, Requester, UpstashResponse, Redis } from "@upstash/redis"
4135
+ *
4136
+ * const requester: Requester = {
4137
+ * request: <TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> => {
4138
+ * // ...
4139
+ * }
4140
+ * }
4141
+ *
4142
+ * const redis = new Redis(requester)
4143
+ * ```
4144
+ */
4145
+ constructor(configOrRequester) {
4146
+ if ("request" in configOrRequester) {
4147
+ super(configOrRequester);
4148
+ return;
4149
+ }
4150
+ if (!configOrRequester.url) {
4151
+ console.warn(
4152
+ `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
4153
+ );
4154
+ } else if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
4155
+ console.warn(
4156
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
4157
+ );
4158
+ }
4159
+ if (!configOrRequester.token) {
4160
+ console.warn(
4161
+ `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
4162
+ );
4163
+ } else if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
4164
+ console.warn(
4165
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
4166
+ );
4167
+ }
4168
+ const client = new HttpClient({
4169
+ baseUrl: configOrRequester.url,
4170
+ retry: configOrRequester.retry,
4171
+ headers: { authorization: `Bearer ${configOrRequester.token}` },
4172
+ agent: configOrRequester.agent,
4173
+ responseEncoding: configOrRequester.responseEncoding,
4174
+ cache: configOrRequester.cache ?? "no-store",
4175
+ signal: configOrRequester.signal,
4176
+ keepAlive: configOrRequester.keepAlive,
4177
+ readYourWrites: configOrRequester.readYourWrites
4178
+ });
4179
+ super(client, {
4180
+ automaticDeserialization: configOrRequester.automaticDeserialization,
4181
+ enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
4182
+ latencyLogging: configOrRequester.latencyLogging,
4183
+ enableAutoPipelining: configOrRequester.enableAutoPipelining
4184
+ });
4185
+ this.addTelemetry({
4186
+ runtime: (
4187
+ // @ts-expect-error to silence compiler
4188
+ typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
4189
+ ),
4190
+ platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
4191
+ sdk: `@upstash/redis@${VERSION}`
4192
+ });
4193
+ if (this.enableAutoPipelining) {
4194
+ return this.autoPipeline();
4195
+ }
4196
+ }
4197
+ /**
4198
+ * Create a new Upstash Redis instance from environment variables.
4199
+ *
4200
+ * Use this to automatically load connection secrets from your environment
4201
+ * variables. For instance when using the Vercel integration.
4202
+ *
4203
+ * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
4204
+ * your environment using `process.env`.
4205
+ */
4206
+ static fromEnv(config) {
4207
+ if (process.env === void 0) {
4208
+ throw new TypeError(
4209
+ '[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
4210
+ );
4211
+ }
4212
+ const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
4213
+ if (!url) {
4214
+ console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
4215
+ }
4216
+ const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
4217
+ if (!token) {
4218
+ console.warn(
4219
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
4220
+ );
4221
+ }
4222
+ return new _Redis({ ...config, url, token });
4223
+ }
4224
+ };
4225
+ // Annotate the CommonJS export names for ESM import in node:
4226
+ 0 && (module.exports = {
4227
+ Redis,
4228
+ errors
4229
+ });