@windrun-huaiin/backend-core 12.0.0 → 14.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.
- package/dist/_virtual/_commonjs-dynamic-modules.js +7 -0
- package/dist/_virtual/_commonjs-dynamic-modules.mjs +5 -0
- package/dist/_virtual/_commonjsHelpers.js +10 -0
- package/dist/_virtual/_commonjsHelpers.mjs +7 -0
- package/dist/_virtual/aes.js +5 -0
- package/dist/_virtual/aes.mjs +3 -0
- package/dist/_virtual/blowfish.js +5 -0
- package/dist/_virtual/blowfish.mjs +3 -0
- package/dist/_virtual/cipher-core.js +5 -0
- package/dist/_virtual/cipher-core.mjs +3 -0
- package/dist/_virtual/core.js +5 -0
- package/dist/_virtual/core.mjs +3 -0
- package/dist/_virtual/enc-base64.js +5 -0
- package/dist/_virtual/enc-base64.mjs +3 -0
- package/dist/_virtual/enc-base64url.js +5 -0
- package/dist/_virtual/enc-base64url.mjs +3 -0
- package/dist/_virtual/enc-utf16.js +5 -0
- package/dist/_virtual/enc-utf16.mjs +3 -0
- package/dist/_virtual/evpkdf.js +5 -0
- package/dist/_virtual/evpkdf.mjs +3 -0
- package/dist/_virtual/format-hex.js +5 -0
- package/dist/_virtual/format-hex.mjs +3 -0
- package/dist/_virtual/hmac.js +5 -0
- package/dist/_virtual/hmac.mjs +3 -0
- package/dist/_virtual/index.js +11 -0
- package/dist/_virtual/index.mjs +7 -0
- package/dist/_virtual/index2.js +5 -0
- package/dist/_virtual/index2.mjs +3 -0
- package/dist/_virtual/lib-typedarrays.js +5 -0
- package/dist/_virtual/lib-typedarrays.mjs +3 -0
- package/dist/_virtual/md5.js +5 -0
- package/dist/_virtual/md5.mjs +3 -0
- package/dist/_virtual/mode-cfb.js +5 -0
- package/dist/_virtual/mode-cfb.mjs +3 -0
- package/dist/_virtual/mode-ctr-gladman.js +5 -0
- package/dist/_virtual/mode-ctr-gladman.mjs +3 -0
- package/dist/_virtual/mode-ctr.js +5 -0
- package/dist/_virtual/mode-ctr.mjs +3 -0
- package/dist/_virtual/mode-ecb.js +5 -0
- package/dist/_virtual/mode-ecb.mjs +3 -0
- package/dist/_virtual/mode-ofb.js +5 -0
- package/dist/_virtual/mode-ofb.mjs +3 -0
- package/dist/_virtual/pad-ansix923.js +5 -0
- package/dist/_virtual/pad-ansix923.mjs +3 -0
- package/dist/_virtual/pad-iso10126.js +5 -0
- package/dist/_virtual/pad-iso10126.mjs +3 -0
- package/dist/_virtual/pad-iso97971.js +5 -0
- package/dist/_virtual/pad-iso97971.mjs +3 -0
- package/dist/_virtual/pad-nopadding.js +5 -0
- package/dist/_virtual/pad-nopadding.mjs +3 -0
- package/dist/_virtual/pad-zeropadding.js +5 -0
- package/dist/_virtual/pad-zeropadding.mjs +3 -0
- package/dist/_virtual/pbkdf2.js +5 -0
- package/dist/_virtual/pbkdf2.mjs +3 -0
- package/dist/_virtual/rabbit-legacy.js +5 -0
- package/dist/_virtual/rabbit-legacy.mjs +3 -0
- package/dist/_virtual/rabbit.js +5 -0
- package/dist/_virtual/rabbit.mjs +3 -0
- package/dist/_virtual/rc4.js +5 -0
- package/dist/_virtual/rc4.mjs +3 -0
- package/dist/_virtual/ripemd160.js +5 -0
- package/dist/_virtual/ripemd160.mjs +3 -0
- package/dist/_virtual/sha1.js +5 -0
- package/dist/_virtual/sha1.mjs +3 -0
- package/dist/_virtual/sha224.js +5 -0
- package/dist/_virtual/sha224.mjs +3 -0
- package/dist/_virtual/sha256.js +5 -0
- package/dist/_virtual/sha256.mjs +3 -0
- package/dist/_virtual/sha3.js +5 -0
- package/dist/_virtual/sha3.mjs +3 -0
- package/dist/_virtual/sha384.js +5 -0
- package/dist/_virtual/sha384.mjs +3 -0
- package/dist/_virtual/sha512.js +5 -0
- package/dist/_virtual/sha512.mjs +3 -0
- package/dist/_virtual/tripledes.js +5 -0
- package/dist/_virtual/tripledes.mjs +3 -0
- package/dist/_virtual/x64-core.js +5 -0
- package/dist/_virtual/x64-core.mjs +3 -0
- package/dist/index.js +48 -0
- package/dist/index.mjs +7 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +48 -0
- package/dist/lib/index.mjs +7 -0
- package/dist/lib/upstash/index.d.ts +7 -0
- package/dist/lib/upstash/index.d.ts.map +1 -0
- package/dist/lib/upstash/qstash.d.ts +36 -0
- package/dist/lib/upstash/qstash.d.ts.map +1 -0
- package/dist/lib/upstash/qstash.js +134 -0
- package/dist/lib/upstash/qstash.mjs +128 -0
- package/dist/lib/upstash/redis-counter.d.ts +17 -0
- package/dist/lib/upstash/redis-counter.d.ts.map +1 -0
- package/dist/lib/upstash/redis-counter.js +40 -0
- package/dist/lib/upstash/redis-counter.mjs +35 -0
- package/dist/lib/upstash/redis-favorite.d.ts +21 -0
- package/dist/lib/upstash/redis-favorite.d.ts.map +1 -0
- package/dist/lib/upstash/redis-favorite.js +60 -0
- package/dist/lib/upstash/redis-favorite.mjs +54 -0
- package/dist/lib/upstash/redis-like.d.ts +21 -0
- package/dist/lib/upstash/redis-like.d.ts.map +1 -0
- package/dist/lib/upstash/redis-like.js +60 -0
- package/dist/lib/upstash/redis-like.mjs +54 -0
- package/dist/lib/upstash/redis-lock.d.ts +13 -0
- package/dist/lib/upstash/redis-lock.d.ts.map +1 -0
- package/dist/lib/upstash/redis-lock.js +59 -0
- package/dist/lib/upstash/redis-lock.mjs +55 -0
- package/dist/lib/upstash/redis-structures.d.ts +63 -0
- package/dist/lib/upstash/redis-structures.d.ts.map +1 -0
- package/dist/lib/upstash/redis-structures.js +175 -0
- package/dist/lib/upstash/redis-structures.mjs +159 -0
- package/dist/lib/upstash-config.d.ts +19 -0
- package/dist/lib/upstash-config.d.ts.map +1 -0
- package/dist/lib/upstash-config.js +247 -0
- package/dist/lib/upstash-config.mjs +242 -0
- package/dist/node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js +1848 -0
- package/dist/node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs +1830 -0
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.js +5308 -0
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.mjs +5302 -0
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/nodejs.js +116 -0
- package/dist/node_modules/.pnpm/@upstash_redis@1.37.0/node_modules/@upstash/redis/nodejs.mjs +113 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js +248 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.mjs +246 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.js +485 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.mjs +483 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js +906 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.mjs +904 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js +818 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.mjs +816 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js +146 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.mjs +144 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.js +158 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.mjs +156 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.js +159 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.mjs +157 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js +146 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.mjs +144 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.js +77 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.mjs +75 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js +153 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.mjs +151 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js +62 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +60 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.js +86 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.mjs +84 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js +278 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.mjs +276 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.js +91 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.mjs +89 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.js +127 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.mjs +125 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.js +69 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.mjs +67 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js +51 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.mjs +49 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.js +65 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.mjs +63 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.js +60 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.mjs +58 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.js +55 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.mjs +53 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.js +51 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.mjs +49 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.js +41 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.mjs +39 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.js +58 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.mjs +56 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.js +157 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.mjs +155 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.js +204 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.mjs +202 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.js +206 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.mjs +204 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.js +153 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.mjs +151 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.js +277 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.mjs +275 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js +160 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.mjs +158 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.js +91 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.mjs +89 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.js +209 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.mjs +207 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.js +337 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.mjs +335 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.js +95 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.mjs +93 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.js +337 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.mjs +335 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.js +793 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.mjs +791 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.js +314 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.mjs +312 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/compact/verify.js +26 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/compact/verify.mjs +24 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js +127 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.mjs +125 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js +20 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.mjs +18 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js +31 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.mjs +29 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/buffer_utils.js +18 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/buffer_utils.mjs +14 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/check_key_type.js +82 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/check_key_type.mjs +80 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/crypto_key.js +103 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/crypto_key.mjs +101 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js +7 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.mjs +3 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/invalid_key_input.js +38 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/invalid_key_input.mjs +33 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js +27 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.mjs +23 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js +21 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.mjs +16 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js +22 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.mjs +18 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js +111 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.mjs +107 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js +61 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.mjs +57 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js +16 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.mjs +12 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js +40 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.mjs +36 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/base64url.js +15 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/base64url.mjs +13 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js +23 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.mjs +19 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js +30 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.mjs +26 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js +60 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.mjs +56 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js +35 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.mjs +31 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js +20 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.mjs +16 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js +15 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.mjs +10 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js +28 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.mjs +5 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js +14 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.mjs +10 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js +115 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.mjs +111 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js +42 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.mjs +19 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js +54 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.mjs +31 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/webcrypto.js +32 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/webcrypto.mjs +7 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/util/errors.js +69 -0
- package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/util/errors.mjs +60 -0
- package/dist/node_modules/.pnpm/neverthrow@7.2.0/node_modules/neverthrow/dist/index.es.js +422 -0
- package/dist/node_modules/.pnpm/neverthrow@7.2.0/node_modules/neverthrow/dist/index.es.mjs +415 -0
- package/dist/node_modules/.pnpm/uncrypto@0.1.3/node_modules/uncrypto/dist/crypto.web.js +6 -0
- package/dist/node_modules/.pnpm/uncrypto@0.1.3/node_modules/uncrypto/dist/crypto.web.mjs +4 -0
- package/dist/prisma/prisma.d.ts +1 -1
- package/dist/prisma/prisma.d.ts.map +1 -1
- package/package.json +14 -11
- package/src/lib/index.ts +2 -0
- package/src/lib/upstash/index.ts +6 -0
- package/src/lib/upstash/qstash.ts +159 -0
- package/src/lib/upstash/redis-counter.ts +35 -0
- package/src/lib/upstash/redis-favorite.ts +56 -0
- package/src/lib/upstash/redis-like.ts +56 -0
- package/src/lib/upstash/redis-lock.ts +59 -0
- package/src/lib/upstash/redis-structures.ts +200 -0
- package/src/lib/upstash-config.ts +261 -0
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +0 -54
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +0 -51
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +0 -44
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +0 -35
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +0 -31
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +0 -18
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +0 -587
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +0 -527
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +0 -447
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +0 -399
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +0 -245
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +0 -232
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +0 -68
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +0 -62
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +0 -39
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +0 -37
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +0 -80
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +0 -75
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +0 -101
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +0 -86
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +0 -102
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +0 -76
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +0 -56
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +0 -52
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +0 -1205
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +0 -1157
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +0 -407
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +0 -374
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +0 -7
package/dist/lib/index.js
CHANGED
|
@@ -6,6 +6,13 @@ var fingerprintConfig = require('./fingerprint-config.js');
|
|
|
6
6
|
var creditInit = require('./credit-init.js');
|
|
7
7
|
var stripeConfig = require('./stripe-config.js');
|
|
8
8
|
var authUtils = require('./auth-utils.js');
|
|
9
|
+
var upstashConfig = require('./upstash-config.js');
|
|
10
|
+
var redisLock = require('./upstash/redis-lock.js');
|
|
11
|
+
var redisLike = require('./upstash/redis-like.js');
|
|
12
|
+
var redisFavorite = require('./upstash/redis-favorite.js');
|
|
13
|
+
var redisCounter = require('./upstash/redis-counter.js');
|
|
14
|
+
var redisStructures = require('./upstash/redis-structures.js');
|
|
15
|
+
var qstash = require('./upstash/qstash.js');
|
|
9
16
|
|
|
10
17
|
|
|
11
18
|
|
|
@@ -33,3 +40,44 @@ exports.ApiAuthUtils = authUtils.ApiAuthUtils;
|
|
|
33
40
|
exports.getAuthenticatedUser = authUtils.getAuthenticatedUser;
|
|
34
41
|
exports.requireAuth = authUtils.requireAuth;
|
|
35
42
|
exports.requireAuthWithUser = authUtils.requireAuthWithUser;
|
|
43
|
+
exports.getQstash = upstashConfig.getQstash;
|
|
44
|
+
exports.getRedis = upstashConfig.getRedis;
|
|
45
|
+
exports.withQstash = upstashConfig.withQstash;
|
|
46
|
+
exports.withRedis = upstashConfig.withRedis;
|
|
47
|
+
exports.acquireLock = redisLock.acquireLock;
|
|
48
|
+
exports.releaseLock = redisLock.releaseLock;
|
|
49
|
+
exports.withLock = redisLock.withLock;
|
|
50
|
+
exports.getTargetLikeCount = redisLike.getTargetLikeCount;
|
|
51
|
+
exports.getUserLikedTargets = redisLike.getUserLikedTargets;
|
|
52
|
+
exports.isTargetLiked = redisLike.isTargetLiked;
|
|
53
|
+
exports.likeTarget = redisLike.likeTarget;
|
|
54
|
+
exports.unlikeTarget = redisLike.unlikeTarget;
|
|
55
|
+
exports.addFavorite = redisFavorite.addFavorite;
|
|
56
|
+
exports.getFavoriteCount = redisFavorite.getFavoriteCount;
|
|
57
|
+
exports.getUserFavorites = redisFavorite.getUserFavorites;
|
|
58
|
+
exports.isFavorited = redisFavorite.isFavorited;
|
|
59
|
+
exports.removeFavorite = redisFavorite.removeFavorite;
|
|
60
|
+
exports.getCounter = redisCounter.getCounter;
|
|
61
|
+
exports.getUniqueCounter = redisCounter.getUniqueCounter;
|
|
62
|
+
exports.incrCounter = redisCounter.incrCounter;
|
|
63
|
+
exports.incrUniqueCounter = redisCounter.incrUniqueCounter;
|
|
64
|
+
exports.deleteHashField = redisStructures.deleteHashField;
|
|
65
|
+
exports.deleteKey = redisStructures.deleteKey;
|
|
66
|
+
exports.getHashAll = redisStructures.getHashAll;
|
|
67
|
+
exports.getHashField = redisStructures.getHashField;
|
|
68
|
+
exports.getHashJson = redisStructures.getHashJson;
|
|
69
|
+
exports.getJson = redisStructures.getJson;
|
|
70
|
+
exports.getString = redisStructures.getString;
|
|
71
|
+
exports.listLength = redisStructures.listLength;
|
|
72
|
+
exports.popList = redisStructures.popList;
|
|
73
|
+
exports.pushList = redisStructures.pushList;
|
|
74
|
+
exports.rangeList = redisStructures.rangeList;
|
|
75
|
+
exports.setHashField = redisStructures.setHashField;
|
|
76
|
+
exports.setHashJson = redisStructures.setHashJson;
|
|
77
|
+
exports.setJson = redisStructures.setJson;
|
|
78
|
+
exports.setString = redisStructures.setString;
|
|
79
|
+
exports.cancelSchedule = qstash.cancelSchedule;
|
|
80
|
+
exports.publishDelayedMessage = qstash.publishDelayedMessage;
|
|
81
|
+
exports.publishMessage = qstash.publishMessage;
|
|
82
|
+
exports.scheduleMessage = qstash.scheduleMessage;
|
|
83
|
+
exports.verifyQstashSignature = qstash.verifyQstashSignature;
|
package/dist/lib/index.mjs
CHANGED
|
@@ -4,3 +4,10 @@ export { fingerprintConfig } from './fingerprint-config.mjs';
|
|
|
4
4
|
export { creditsConfig, freeAmount, freeExpiredDays, freeRegisterAmount, oneTimeExpiredDays } from './credit-init.mjs';
|
|
5
5
|
export { ActiveSubscriptionExistsError, cancelSubscription, createCheckoutSession, createCustomerPortalSession, createOrGetCustomer, fetchPaymentId, stripe, updateSubscription, validateStripeWebhook } from './stripe-config.mjs';
|
|
6
6
|
export { ApiAuthUtils, getAuthenticatedUser, requireAuth, requireAuthWithUser } from './auth-utils.mjs';
|
|
7
|
+
export { getQstash, getRedis, withQstash, withRedis } from './upstash-config.mjs';
|
|
8
|
+
export { acquireLock, releaseLock, withLock } from './upstash/redis-lock.mjs';
|
|
9
|
+
export { getTargetLikeCount, getUserLikedTargets, isTargetLiked, likeTarget, unlikeTarget } from './upstash/redis-like.mjs';
|
|
10
|
+
export { addFavorite, getFavoriteCount, getUserFavorites, isFavorited, removeFavorite } from './upstash/redis-favorite.mjs';
|
|
11
|
+
export { getCounter, getUniqueCounter, incrCounter, incrUniqueCounter } from './upstash/redis-counter.mjs';
|
|
12
|
+
export { deleteHashField, deleteKey, getHashAll, getHashField, getHashJson, getJson, getString, listLength, popList, pushList, rangeList, setHashField, setHashJson, setJson, setString } from './upstash/redis-structures.mjs';
|
|
13
|
+
export { cancelSchedule, publishDelayedMessage, publishMessage, scheduleMessage, verifyQstashSignature } from './upstash/qstash.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/upstash/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type PublishBody = Record<string, unknown> | string | number | boolean | null;
|
|
2
|
+
export interface PublishMessageOptions {
|
|
3
|
+
url: string;
|
|
4
|
+
body: PublishBody;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Publish a message. Returns message id or null if QStash is unavailable.
|
|
8
|
+
*/
|
|
9
|
+
export declare const publishMessage: (options: PublishMessageOptions) => Promise<string | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Publish a delayed message. Returns message id or null if QStash is unavailable.
|
|
12
|
+
*/
|
|
13
|
+
export declare const publishDelayedMessage: (options: PublishMessageOptions & {
|
|
14
|
+
delaySec: number;
|
|
15
|
+
}) => Promise<string | null>;
|
|
16
|
+
export interface ScheduleMessageOptions extends PublishMessageOptions {
|
|
17
|
+
cron: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Schedule a recurring message. Returns schedule id or null if QStash is unavailable.
|
|
21
|
+
*/
|
|
22
|
+
export declare const scheduleMessage: (options: ScheduleMessageOptions) => Promise<string | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Cancel a scheduled message. Returns false if QStash is unavailable.
|
|
25
|
+
*/
|
|
26
|
+
export declare const cancelSchedule: (scheduleId: string) => Promise<boolean>;
|
|
27
|
+
export interface VerifyQstashOptions {
|
|
28
|
+
signature: string;
|
|
29
|
+
body: string;
|
|
30
|
+
url: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Verify QStash signature. Throws on failure in non-dev environments.
|
|
34
|
+
*/
|
|
35
|
+
export declare const verifyQstashSignature: (options: VerifyQstashOptions) => Promise<boolean>;
|
|
36
|
+
//# sourceMappingURL=qstash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qstash.d.ts","sourceRoot":"","sources":["../../../src/lib/upstash/qstash.ts"],"names":[],"mappings":"AA8CA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,GAAU,SAAS,qBAAqB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAQ1F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,qBAAqB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,KACpD,OAAO,CAAC,MAAM,GAAG,IAAI,CASvB,CAAC;AAEF,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACnE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,sBAAsB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAiB5F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,OAAO,CAexE,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,SAAS,mBAAmB,KAAG,OAAO,CAAC,OAAO,CAqBzF,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
|
+
var chunk35B33QW3 = require('../../node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js');
|
|
5
|
+
var upstashConfig = require('../upstash-config.js');
|
|
6
|
+
|
|
7
|
+
let cachedReceiver = null;
|
|
8
|
+
let receiverWarnedMissingEnv = false;
|
|
9
|
+
let receiverWarnedInitError = false;
|
|
10
|
+
const isTruthy = (value) => value === '1' || value === 'true' || value === 'TRUE';
|
|
11
|
+
const shouldSkipVerify = () => process.env.NODE_ENV === 'development' && isTruthy(process.env.SKIP_UPSTASH_QSTASH_VERIFY);
|
|
12
|
+
const getReceiver = () => {
|
|
13
|
+
if (cachedReceiver) {
|
|
14
|
+
return cachedReceiver;
|
|
15
|
+
}
|
|
16
|
+
const currentSigningKey = process.env.QSTASH_CURRENT_SIGNING_KEY;
|
|
17
|
+
const nextSigningKey = process.env.QSTASH_NEXT_SIGNING_KEY;
|
|
18
|
+
if (!currentSigningKey || !nextSigningKey) {
|
|
19
|
+
if (!receiverWarnedMissingEnv) {
|
|
20
|
+
receiverWarnedMissingEnv = true;
|
|
21
|
+
console.warn('[Upstash Config] QStash Receiver disabled: missing QSTASH_CURRENT_SIGNING_KEY or QSTASH_NEXT_SIGNING_KEY');
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
cachedReceiver = new chunk35B33QW3.Receiver({
|
|
27
|
+
currentSigningKey,
|
|
28
|
+
nextSigningKey,
|
|
29
|
+
});
|
|
30
|
+
return cachedReceiver;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!receiverWarnedInitError) {
|
|
34
|
+
receiverWarnedInitError = true;
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
+
console.warn(`[Upstash Config] QStash Receiver init failed: ${message}`);
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Publish a message. Returns message id or null if QStash is unavailable.
|
|
43
|
+
*/
|
|
44
|
+
const publishMessage = (options) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
return upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
var _a;
|
|
47
|
+
const result = yield client.publishJSON({
|
|
48
|
+
url: options.url,
|
|
49
|
+
body: options.body,
|
|
50
|
+
});
|
|
51
|
+
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
52
|
+
}));
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Publish a delayed message. Returns message id or null if QStash is unavailable.
|
|
56
|
+
*/
|
|
57
|
+
const publishDelayedMessage = (options) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
return upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
var _a;
|
|
60
|
+
const result = yield client.publishJSON({
|
|
61
|
+
url: options.url,
|
|
62
|
+
body: options.body,
|
|
63
|
+
delay: options.delaySec,
|
|
64
|
+
});
|
|
65
|
+
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
66
|
+
}));
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Schedule a recurring message. Returns schedule id or null if QStash is unavailable.
|
|
70
|
+
*/
|
|
71
|
+
const scheduleMessage = (options) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
return upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
var _a, _b, _c, _d, _e, _f;
|
|
74
|
+
const anyClient = client;
|
|
75
|
+
const result = (_c = (yield ((_b = (_a = anyClient.schedules) === null || _a === void 0 ? void 0 : _a.create) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
76
|
+
url: options.url,
|
|
77
|
+
body: options.body,
|
|
78
|
+
cron: options.cron,
|
|
79
|
+
})))) !== null && _c !== void 0 ? _c : (yield ((_d = anyClient.publishJSON) === null || _d === void 0 ? void 0 : _d.call(anyClient, {
|
|
80
|
+
url: options.url,
|
|
81
|
+
body: options.body,
|
|
82
|
+
cron: options.cron,
|
|
83
|
+
})));
|
|
84
|
+
return typeof result === 'string' ? result : (_f = (_e = result === null || result === void 0 ? void 0 : result.scheduleId) !== null && _e !== void 0 ? _e : result === null || result === void 0 ? void 0 : result.id) !== null && _f !== void 0 ? _f : null;
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Cancel a scheduled message. Returns false if QStash is unavailable.
|
|
89
|
+
*/
|
|
90
|
+
const cancelSchedule = (scheduleId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
+
const result = yield upstashConfig.withQstash((client) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
const anyClient = client;
|
|
94
|
+
if ((_a = anyClient.schedules) === null || _a === void 0 ? void 0 : _a.delete) {
|
|
95
|
+
yield anyClient.schedules.delete(scheduleId);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if ((_b = anyClient.schedules) === null || _b === void 0 ? void 0 : _b.remove) {
|
|
99
|
+
yield anyClient.schedules.remove(scheduleId);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}));
|
|
104
|
+
return result !== null && result !== void 0 ? result : false;
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* Verify QStash signature. Throws on failure in non-dev environments.
|
|
108
|
+
*/
|
|
109
|
+
const verifyQstashSignature = (options) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
var _a;
|
|
111
|
+
if (shouldSkipVerify()) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const receiver = getReceiver();
|
|
115
|
+
if (!receiver) {
|
|
116
|
+
throw new Error('QStash signing keys are missing');
|
|
117
|
+
}
|
|
118
|
+
const verifier = (_a = receiver.verify) !== null && _a !== void 0 ? _a : receiver.verifySignature;
|
|
119
|
+
if (!verifier) {
|
|
120
|
+
throw new Error('QStash receiver verify method is unavailable');
|
|
121
|
+
}
|
|
122
|
+
yield verifier.call(receiver, {
|
|
123
|
+
signature: options.signature,
|
|
124
|
+
body: options.body,
|
|
125
|
+
url: options.url,
|
|
126
|
+
});
|
|
127
|
+
return true;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
exports.cancelSchedule = cancelSchedule;
|
|
131
|
+
exports.publishDelayedMessage = publishDelayedMessage;
|
|
132
|
+
exports.publishMessage = publishMessage;
|
|
133
|
+
exports.scheduleMessage = scheduleMessage;
|
|
134
|
+
exports.verifyQstashSignature = verifyQstashSignature;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { __awaiter } from '../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import { Receiver } from '../../node_modules/.pnpm/@upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs';
|
|
3
|
+
import { withQstash } from '../upstash-config.mjs';
|
|
4
|
+
|
|
5
|
+
let cachedReceiver = null;
|
|
6
|
+
let receiverWarnedMissingEnv = false;
|
|
7
|
+
let receiverWarnedInitError = false;
|
|
8
|
+
const isTruthy = (value) => value === '1' || value === 'true' || value === 'TRUE';
|
|
9
|
+
const shouldSkipVerify = () => process.env.NODE_ENV === 'development' && isTruthy(process.env.SKIP_UPSTASH_QSTASH_VERIFY);
|
|
10
|
+
const getReceiver = () => {
|
|
11
|
+
if (cachedReceiver) {
|
|
12
|
+
return cachedReceiver;
|
|
13
|
+
}
|
|
14
|
+
const currentSigningKey = process.env.QSTASH_CURRENT_SIGNING_KEY;
|
|
15
|
+
const nextSigningKey = process.env.QSTASH_NEXT_SIGNING_KEY;
|
|
16
|
+
if (!currentSigningKey || !nextSigningKey) {
|
|
17
|
+
if (!receiverWarnedMissingEnv) {
|
|
18
|
+
receiverWarnedMissingEnv = true;
|
|
19
|
+
console.warn('[Upstash Config] QStash Receiver disabled: missing QSTASH_CURRENT_SIGNING_KEY or QSTASH_NEXT_SIGNING_KEY');
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
cachedReceiver = new Receiver({
|
|
25
|
+
currentSigningKey,
|
|
26
|
+
nextSigningKey,
|
|
27
|
+
});
|
|
28
|
+
return cachedReceiver;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (!receiverWarnedInitError) {
|
|
32
|
+
receiverWarnedInitError = true;
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
console.warn(`[Upstash Config] QStash Receiver init failed: ${message}`);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Publish a message. Returns message id or null if QStash is unavailable.
|
|
41
|
+
*/
|
|
42
|
+
const publishMessage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
return withQstash((client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
var _a;
|
|
45
|
+
const result = yield client.publishJSON({
|
|
46
|
+
url: options.url,
|
|
47
|
+
body: options.body,
|
|
48
|
+
});
|
|
49
|
+
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
50
|
+
}));
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Publish a delayed message. Returns message id or null if QStash is unavailable.
|
|
54
|
+
*/
|
|
55
|
+
const publishDelayedMessage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
return withQstash((client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
const result = yield client.publishJSON({
|
|
59
|
+
url: options.url,
|
|
60
|
+
body: options.body,
|
|
61
|
+
delay: options.delaySec,
|
|
62
|
+
});
|
|
63
|
+
return typeof result === 'string' ? result : (_a = result === null || result === void 0 ? void 0 : result.messageId) !== null && _a !== void 0 ? _a : null;
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Schedule a recurring message. Returns schedule id or null if QStash is unavailable.
|
|
68
|
+
*/
|
|
69
|
+
const scheduleMessage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
return withQstash((client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
var _a, _b, _c, _d, _e, _f;
|
|
72
|
+
const anyClient = client;
|
|
73
|
+
const result = (_c = (yield ((_b = (_a = anyClient.schedules) === null || _a === void 0 ? void 0 : _a.create) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
74
|
+
url: options.url,
|
|
75
|
+
body: options.body,
|
|
76
|
+
cron: options.cron,
|
|
77
|
+
})))) !== null && _c !== void 0 ? _c : (yield ((_d = anyClient.publishJSON) === null || _d === void 0 ? void 0 : _d.call(anyClient, {
|
|
78
|
+
url: options.url,
|
|
79
|
+
body: options.body,
|
|
80
|
+
cron: options.cron,
|
|
81
|
+
})));
|
|
82
|
+
return typeof result === 'string' ? result : (_f = (_e = result === null || result === void 0 ? void 0 : result.scheduleId) !== null && _e !== void 0 ? _e : result === null || result === void 0 ? void 0 : result.id) !== null && _f !== void 0 ? _f : null;
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Cancel a scheduled message. Returns false if QStash is unavailable.
|
|
87
|
+
*/
|
|
88
|
+
const cancelSchedule = (scheduleId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
const result = yield withQstash((client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const anyClient = client;
|
|
92
|
+
if ((_a = anyClient.schedules) === null || _a === void 0 ? void 0 : _a.delete) {
|
|
93
|
+
yield anyClient.schedules.delete(scheduleId);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if ((_b = anyClient.schedules) === null || _b === void 0 ? void 0 : _b.remove) {
|
|
97
|
+
yield anyClient.schedules.remove(scheduleId);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}));
|
|
102
|
+
return result !== null && result !== void 0 ? result : false;
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Verify QStash signature. Throws on failure in non-dev environments.
|
|
106
|
+
*/
|
|
107
|
+
const verifyQstashSignature = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
var _a;
|
|
109
|
+
if (shouldSkipVerify()) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
const receiver = getReceiver();
|
|
113
|
+
if (!receiver) {
|
|
114
|
+
throw new Error('QStash signing keys are missing');
|
|
115
|
+
}
|
|
116
|
+
const verifier = (_a = receiver.verify) !== null && _a !== void 0 ? _a : receiver.verifySignature;
|
|
117
|
+
if (!verifier) {
|
|
118
|
+
throw new Error('QStash receiver verify method is unavailable');
|
|
119
|
+
}
|
|
120
|
+
yield verifier.call(receiver, {
|
|
121
|
+
signature: options.signature,
|
|
122
|
+
body: options.body,
|
|
123
|
+
url: options.url,
|
|
124
|
+
});
|
|
125
|
+
return true;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export { cancelSchedule, publishDelayedMessage, publishMessage, scheduleMessage, verifyQstashSignature };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Increment a counter (e.g. views, forwards). Returns null if Redis is unavailable.
|
|
3
|
+
*/
|
|
4
|
+
export declare const incrCounter: (key: string, delta?: number) => Promise<number | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Get a counter value. Returns null if Redis is unavailable.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getCounter: (key: string) => Promise<number | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Increment a unique counter via SET (e.g. unique views). Returns null if Redis is unavailable.
|
|
11
|
+
*/
|
|
12
|
+
export declare const incrUniqueCounter: (setKey: string, memberId: string) => Promise<number | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Get unique counter value (SET cardinality). Returns null if Redis is unavailable.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getUniqueCounter: (setKey: string) => Promise<number | null>;
|
|
17
|
+
//# sourceMappingURL=redis-counter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-counter.d.ts","sourceRoot":"","sources":["../../../src/lib/upstash/redis-counter.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,WAAW,GAAU,KAAK,MAAM,EAAE,cAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAE/E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAKnE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAU,QAAQ,MAAM,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAK/F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAE5E,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
|
+
var upstashConfig = require('../upstash-config.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Increment a counter (e.g. views, forwards). Returns null if Redis is unavailable.
|
|
8
|
+
*/
|
|
9
|
+
const incrCounter = (key_1, ...args_1) => tslib_es6.__awaiter(void 0, [key_1, ...args_1], void 0, function* (key, delta = 1) {
|
|
10
|
+
return upstashConfig.withRedis((redis) => redis.incrby(key, delta));
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Get a counter value. Returns null if Redis is unavailable.
|
|
14
|
+
*/
|
|
15
|
+
const getCounter = (key) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
return upstashConfig.withRedis((redis) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const value = yield redis.get(key);
|
|
18
|
+
return value !== null && value !== void 0 ? value : 0;
|
|
19
|
+
}));
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Increment a unique counter via SET (e.g. unique views). Returns null if Redis is unavailable.
|
|
23
|
+
*/
|
|
24
|
+
const incrUniqueCounter = (setKey, memberId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
return upstashConfig.withRedis((redis) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
yield redis.sadd(setKey, memberId);
|
|
27
|
+
return redis.scard(setKey);
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Get unique counter value (SET cardinality). Returns null if Redis is unavailable.
|
|
32
|
+
*/
|
|
33
|
+
const getUniqueCounter = (setKey) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
return upstashConfig.withRedis((redis) => redis.scard(setKey));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
exports.getCounter = getCounter;
|
|
38
|
+
exports.getUniqueCounter = getUniqueCounter;
|
|
39
|
+
exports.incrCounter = incrCounter;
|
|
40
|
+
exports.incrUniqueCounter = incrUniqueCounter;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { __awaiter } from '../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import { withRedis } from '../upstash-config.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Increment a counter (e.g. views, forwards). Returns null if Redis is unavailable.
|
|
6
|
+
*/
|
|
7
|
+
const incrCounter = (key_1, ...args_1) => __awaiter(void 0, [key_1, ...args_1], void 0, function* (key, delta = 1) {
|
|
8
|
+
return withRedis((redis) => redis.incrby(key, delta));
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Get a counter value. Returns null if Redis is unavailable.
|
|
12
|
+
*/
|
|
13
|
+
const getCounter = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
return withRedis((redis) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const value = yield redis.get(key);
|
|
16
|
+
return value !== null && value !== void 0 ? value : 0;
|
|
17
|
+
}));
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Increment a unique counter via SET (e.g. unique views). Returns null if Redis is unavailable.
|
|
21
|
+
*/
|
|
22
|
+
const incrUniqueCounter = (setKey, memberId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
return withRedis((redis) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
yield redis.sadd(setKey, memberId);
|
|
25
|
+
return redis.scard(setKey);
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Get unique counter value (SET cardinality). Returns null if Redis is unavailable.
|
|
30
|
+
*/
|
|
31
|
+
const getUniqueCounter = (setKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
return withRedis((redis) => redis.scard(setKey));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export { getCounter, getUniqueCounter, incrCounter, incrUniqueCounter };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Favorite a target. Returns true if added, false if already favorited, null if Redis is unavailable.
|
|
3
|
+
*/
|
|
4
|
+
export declare const addFavorite: (targetId: string, userId: string) => Promise<boolean | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Remove a favorite. Returns true if removed, false if not found, null if Redis is unavailable.
|
|
7
|
+
*/
|
|
8
|
+
export declare const removeFavorite: (targetId: string, userId: string) => Promise<boolean | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Check whether a user has favorited a target. Returns null if Redis is unavailable.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isFavorited: (targetId: string, userId: string) => Promise<boolean | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Get favorite count for a target. Returns null if Redis is unavailable.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getFavoriteCount: (targetId: string) => Promise<number | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Get target ids favorited by a user. Returns null if Redis is unavailable.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getUserFavorites: (userId: string) => Promise<string[] | null>;
|
|
21
|
+
//# sourceMappingURL=redis-favorite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-favorite.d.ts","sourceRoot":"","sources":["../../../src/lib/upstash/redis-favorite.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,WAAW,GAAU,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAS1F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAU,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAS7F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAU,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAK1F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAE9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAE9E,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
|
+
var upstashConfig = require('../upstash-config.js');
|
|
5
|
+
|
|
6
|
+
const favoriteTargetKey = (targetId) => `favorite:target:${targetId}`;
|
|
7
|
+
const favoriteUserKey = (userId) => `favorite:user:${userId}`;
|
|
8
|
+
/**
|
|
9
|
+
* Favorite a target. Returns true if added, false if already favorited, null if Redis is unavailable.
|
|
10
|
+
*/
|
|
11
|
+
const addFavorite = (targetId, userId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
return upstashConfig.withRedis((redis) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const added = yield redis.sadd(favoriteTargetKey(targetId), userId);
|
|
14
|
+
if (added === 1) {
|
|
15
|
+
yield redis.sadd(favoriteUserKey(userId), targetId);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}));
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Remove a favorite. Returns true if removed, false if not found, null if Redis is unavailable.
|
|
23
|
+
*/
|
|
24
|
+
const removeFavorite = (targetId, userId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
return upstashConfig.withRedis((redis) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const removed = yield redis.srem(favoriteTargetKey(targetId), userId);
|
|
27
|
+
if (removed === 1) {
|
|
28
|
+
yield redis.srem(favoriteUserKey(userId), targetId);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Check whether a user has favorited a target. Returns null if Redis is unavailable.
|
|
36
|
+
*/
|
|
37
|
+
const isFavorited = (targetId, userId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
return upstashConfig.withRedis((redis) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const result = yield redis.sismember(favoriteTargetKey(targetId), userId);
|
|
40
|
+
return result === 1;
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Get favorite count for a target. Returns null if Redis is unavailable.
|
|
45
|
+
*/
|
|
46
|
+
const getFavoriteCount = (targetId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
return upstashConfig.withRedis((redis) => redis.scard(favoriteTargetKey(targetId)));
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Get target ids favorited by a user. Returns null if Redis is unavailable.
|
|
51
|
+
*/
|
|
52
|
+
const getUserFavorites = (userId) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
return upstashConfig.withRedis((redis) => redis.smembers(favoriteUserKey(userId)));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
exports.addFavorite = addFavorite;
|
|
57
|
+
exports.getFavoriteCount = getFavoriteCount;
|
|
58
|
+
exports.getUserFavorites = getUserFavorites;
|
|
59
|
+
exports.isFavorited = isFavorited;
|
|
60
|
+
exports.removeFavorite = removeFavorite;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { __awaiter } from '../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import { withRedis } from '../upstash-config.mjs';
|
|
3
|
+
|
|
4
|
+
const favoriteTargetKey = (targetId) => `favorite:target:${targetId}`;
|
|
5
|
+
const favoriteUserKey = (userId) => `favorite:user:${userId}`;
|
|
6
|
+
/**
|
|
7
|
+
* Favorite a target. Returns true if added, false if already favorited, null if Redis is unavailable.
|
|
8
|
+
*/
|
|
9
|
+
const addFavorite = (targetId, userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
return withRedis((redis) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
const added = yield redis.sadd(favoriteTargetKey(targetId), userId);
|
|
12
|
+
if (added === 1) {
|
|
13
|
+
yield redis.sadd(favoriteUserKey(userId), targetId);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}));
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Remove a favorite. Returns true if removed, false if not found, null if Redis is unavailable.
|
|
21
|
+
*/
|
|
22
|
+
const removeFavorite = (targetId, userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
return withRedis((redis) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const removed = yield redis.srem(favoriteTargetKey(targetId), userId);
|
|
25
|
+
if (removed === 1) {
|
|
26
|
+
yield redis.srem(favoriteUserKey(userId), targetId);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}));
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Check whether a user has favorited a target. Returns null if Redis is unavailable.
|
|
34
|
+
*/
|
|
35
|
+
const isFavorited = (targetId, userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
return withRedis((redis) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const result = yield redis.sismember(favoriteTargetKey(targetId), userId);
|
|
38
|
+
return result === 1;
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Get favorite count for a target. Returns null if Redis is unavailable.
|
|
43
|
+
*/
|
|
44
|
+
const getFavoriteCount = (targetId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
return withRedis((redis) => redis.scard(favoriteTargetKey(targetId)));
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Get target ids favorited by a user. Returns null if Redis is unavailable.
|
|
49
|
+
*/
|
|
50
|
+
const getUserFavorites = (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
return withRedis((redis) => redis.smembers(favoriteUserKey(userId)));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export { addFavorite, getFavoriteCount, getUserFavorites, isFavorited, removeFavorite };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like a target. Returns true if the like was added, false if it already existed, null if Redis is unavailable.
|
|
3
|
+
*/
|
|
4
|
+
export declare const likeTarget: (targetId: string, userId: string) => Promise<boolean | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Unlike a target. Returns true if removed, false if it didn't exist, null if Redis is unavailable.
|
|
7
|
+
*/
|
|
8
|
+
export declare const unlikeTarget: (targetId: string, userId: string) => Promise<boolean | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Check whether a user liked a target. Returns null if Redis is unavailable.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isTargetLiked: (targetId: string, userId: string) => Promise<boolean | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Get like count for a target (unique by user). Returns null if Redis is unavailable.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getTargetLikeCount: (targetId: string) => Promise<number | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Get target ids liked by a user. Returns null if Redis is unavailable.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getUserLikedTargets: (userId: string) => Promise<string[] | null>;
|
|
21
|
+
//# sourceMappingURL=redis-like.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-like.d.ts","sourceRoot":"","sources":["../../../src/lib/upstash/redis-like.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CASzF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAU,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAS3F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAU,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAK5F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAEjF,CAAC"}
|