@upstash/redis 0.0.0-ci.e730ad54-20220901 → 0.0.0-ci.e9ff702fe7d2dd2495b4383b5432fe9b93f5a6e7-20250729064656

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