@upstash/redis 0.0.0-ci.e730ad54-20220901 → 0.0.0-ci.ea9f0853d6a86e6b7809a21bff609de1b6e9291d-20250414063537

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