@upstash/redis 0.0.0-ci.a094ea5b → 0.0.0-ci.a1eecf417a1944a8b82f402809dd438d52cdf64a-20250506071248

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