@upstash/redis 0.0.0-ci.d2ee3690 → 0.0.0-ci.d3985e1d3f7f296ee10dff2746b51fa88dddc9a9-20251222113217

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