@upstash/redis 0.0.0-ci.c37cc01e → 0.0.0-ci.c437cd1c22b89176b5ffe4b92611049333c93ef5-20250220102555

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