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