@upstash/redis 0.0.0-ci.a031d478-20221013 → 0.0.0-ci.a08f1ca1ac3e3818ac32fe7e8306468d98e05e0e-20250131161917

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