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