@upstash/redis 0.0.0-ci.b3f07153-20231018 → 0.0.0-ci.b6d333f309706ca17ec4fa59fa7e5d9423259413-20250918142256

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