@upstash/redis 0.0.0-ci.ca4b4d16-20230531 → 0.0.0-ci.ca5982e89397ec0e15a62a419e36ec87ddf3439e-20250221122936

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