@windrun-huaiin/backend-core 12.0.0 → 13.0.0

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