@upstash/ratelimit 0.3.0-rc.1 → 0.3.1
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/index.d.ts +569 -0
- package/dist/index.js +736 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +707 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +23 -42
- package/.releaserc +0 -14
- package/esm/_dnt.shims.js +0 -62
- package/esm/analytics.js +0 -84
- package/esm/cache.js +0 -40
- package/esm/deps/deno.land/x/base64@v0.2.1/base.js +0 -100
- package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +0 -9
- package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +0 -1
- package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +0 -191
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/mod.js +0 -66
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/append.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitcount.js +0 -16
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitop.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitpos.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/command.js +0 -57
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/dbsize.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/decr.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/decrby.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/del.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/echo.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/eval.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/evalsha.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/exists.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/expire.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/expireat.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/flushall.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/flushdb.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/get.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getbit.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getdel.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getrange.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getset.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hdel.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hexists.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hget.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hgetall.js +0 -29
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hincrby.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hincrbyfloat.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hkeys.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hlen.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hmget.js +0 -35
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hmset.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hrandfield.js +0 -39
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hscan.js +0 -16
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hset.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hsetnx.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hstrlen.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hvals.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incr.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incrby.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incrbyfloat.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/keys.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lindex.js +0 -6
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/linsert.js +0 -6
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/llen.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lmove.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpop.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpos.js +0 -19
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpush.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpushx.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lrange.js +0 -6
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lrem.js +0 -6
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lset.js +0 -6
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ltrim.js +0 -6
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mget.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mod.js +0 -119
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mset.js +0 -12
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/msetnx.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/persist.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pexpire.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pexpireat.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ping.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/psetex.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pttl.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/publish.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/randomkey.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rename.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/renamenx.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpop.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpush.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpushx.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sadd.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/scan.js +0 -19
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/scard.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_exists.js +0 -12
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_flush.js +0 -16
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_load.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sdiff.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sdiffstore.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/set.js +0 -36
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setbit.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setex.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setnx.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setrange.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sinter.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sinterstore.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sismember.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smembers.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smismember.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smove.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/spop.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/srandmember.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/srem.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sscan.js +0 -16
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/strlen.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sunion.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sunionstore.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/time.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/touch.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ttl.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/type.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/unlink.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zadd.js +0 -26
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zcard.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zcount.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zdiffstore.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zincrby.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zinterstore.js +0 -27
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zlexcount.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zmscore.js +0 -10
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zpopmax.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zpopmin.js +0 -13
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrange.js +0 -26
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrank.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrem.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebylex.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebyrank.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebyscore.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrevrank.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zscan.js +0 -16
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zscore.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zunionstore.js +0 -27
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/error.js +0 -9
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/http.js +0 -165
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/pipeline.js +0 -1199
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/redis.js +0 -1200
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/script.js +0 -77
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/types.js +0 -1
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/pkg/util.js +0 -31
- package/esm/deps/deno.land/x/upstash_redis@v1.19.3/version.js +0 -1
- package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +0 -50
- package/esm/duration.js +0 -21
- package/esm/mod.js +0 -3
- package/esm/multi.js +0 -268
- package/esm/package.json +0 -3
- package/esm/ratelimit.js +0 -197
- package/esm/single.js +0 -376
- package/esm/types.js +0 -1
- package/script/_dnt.shims.js +0 -66
- package/script/analytics.js +0 -88
- package/script/cache.js +0 -44
- package/script/deps/deno.land/x/base64@v0.2.1/base.js +0 -104
- package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +0 -13
- package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +0 -6
- package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +0 -196
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/mod.js +0 -93
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/append.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitcount.js +0 -20
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitop.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitpos.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/command.js +0 -61
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/dbsize.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/decr.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/decrby.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/del.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/echo.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/eval.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/evalsha.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/exists.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/expire.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/expireat.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/flushall.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/flushdb.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/get.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getbit.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getdel.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getrange.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getset.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hdel.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hexists.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hget.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hgetall.js +0 -33
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hincrby.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hincrbyfloat.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hkeys.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hlen.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hmget.js +0 -39
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hmset.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hrandfield.js +0 -43
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hscan.js +0 -20
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hset.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hsetnx.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hstrlen.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hvals.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incr.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incrby.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incrbyfloat.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/keys.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lindex.js +0 -10
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/linsert.js +0 -10
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/llen.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lmove.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpop.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpos.js +0 -23
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpush.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpushx.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lrange.js +0 -10
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lrem.js +0 -10
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lset.js +0 -10
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ltrim.js +0 -10
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mget.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mod.js +0 -135
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mset.js +0 -16
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/msetnx.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/persist.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pexpire.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pexpireat.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ping.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/psetex.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pttl.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/publish.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/randomkey.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rename.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/renamenx.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpop.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpush.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpushx.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sadd.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/scan.js +0 -23
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/scard.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_exists.js +0 -16
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_flush.js +0 -20
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_load.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sdiff.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sdiffstore.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/set.js +0 -40
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setbit.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setex.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setnx.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setrange.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sinter.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sinterstore.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sismember.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smembers.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smismember.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smove.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/spop.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/srandmember.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/srem.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sscan.js +0 -20
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/strlen.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sunion.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sunionstore.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/time.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/touch.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ttl.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/type.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/unlink.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zadd.js +0 -30
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zcard.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zcount.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zdiffstore.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zincrby.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zinterstore.js +0 -31
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zlexcount.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zmscore.js +0 -14
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zpopmax.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zpopmin.js +0 -17
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrange.js +0 -30
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrank.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrem.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebylex.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebyrank.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebyscore.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrevrank.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zscan.js +0 -20
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zscore.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zunionstore.js +0 -31
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/error.js +0 -13
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/http.js +0 -169
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/pipeline.js +0 -1203
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/redis.js +0 -1204
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/script.js +0 -81
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/types.js +0 -2
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/pkg/util.js +0 -35
- package/script/deps/deno.land/x/upstash_redis@v1.19.3/version.js +0 -4
- package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +0 -55
- package/script/duration.js +0 -25
- package/script/mod.js +0 -22
- package/script/multi.js +0 -295
- package/script/package.json +0 -3
- package/script/ratelimit.js +0 -202
- package/script/single.js +0 -380
- package/script/types.js +0 -2
- package/types/_dnt.shims.d.ts +0 -5
- package/types/analytics.d.ts +0 -36
- package/types/cache.d.ts +0 -16
- package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +0 -5
- package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +0 -1
- package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +0 -1
- package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +0 -26
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/mod.d.ts +0 -41
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/append.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitcount.d.ts +0 -8
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitop.d.ts +0 -12
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/bitpos.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/command.d.ts +0 -37
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/dbsize.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/decr.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/decrby.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/del.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/echo.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/eval.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/evalsha.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/exists.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/expire.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/expireat.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/flushall.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/flushdb.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/get.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getbit.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getdel.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getrange.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/getset.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hdel.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hexists.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hget.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hgetall.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hincrby.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hincrbyfloat.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hkeys.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hlen.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hmget.d.ts +0 -15
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hmset.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hrandfield.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hscan.d.ts +0 -24
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hset.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hsetnx.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hstrlen.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/hvals.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incr.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incrby.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/incrbyfloat.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/keys.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lindex.d.ts +0 -4
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/linsert.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/llen.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lmove.d.ts +0 -12
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpop.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpos.d.ts +0 -15
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpush.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lpushx.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lrange.d.ts +0 -4
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lrem.d.ts +0 -4
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/lset.d.ts +0 -4
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ltrim.d.ts +0 -4
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mget.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mod.d.ts +0 -119
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/mset.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/msetnx.d.ts +0 -9
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/persist.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pexpire.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pexpireat.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ping.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/psetex.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/pttl.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/publish.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/randomkey.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rename.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/renamenx.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpop.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpush.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/rpushx.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sadd.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/scan.d.ts +0 -18
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/scard.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_exists.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_flush.d.ts +0 -14
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/script_load.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sdiff.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sdiffstore.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/set.d.ts +0 -55
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setbit.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setex.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setnx.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/setrange.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sinter.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sinterstore.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sismember.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smembers.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smismember.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/smove.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/spop.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/srandmember.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/srem.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sscan.d.ts +0 -24
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/strlen.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sunion.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/sunionstore.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/time.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/touch.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/ttl.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/type.d.ts +0 -8
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/unlink.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zadd.d.ts +0 -35
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zcard.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zcount.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zdiffstore.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zincrby.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zinterstore.d.ts +0 -30
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zlexcount.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zmscore.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zpopmax.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zpopmin.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrange.d.ts +0 -42
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrank.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrem.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebylex.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebyrank.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zremrangebyscore.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zrevrank.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zscan.d.ts +0 -24
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zscore.d.ts +0 -7
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/commands/zunionstore.d.ts +0 -30
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/error.d.ts +0 -6
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/http.d.ts +0 -87
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/pipeline.d.ts +0 -577
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/redis.d.ts +0 -575
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/script.d.ts +0 -42
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/types.d.ts +0 -18
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/pkg/util.d.ts +0 -1
- package/types/deps/deno.land/x/upstash_redis@v1.19.3/version.d.ts +0 -1
- package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +0 -3
- package/types/duration.d.ts +0 -7
- package/types/mod.d.ts +0 -6
- package/types/multi.d.ts +0 -128
- package/types/ratelimit.d.ts +0 -123
- package/types/single.d.ts +0 -194
- package/types/types.d.ts +0 -67
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Script = void 0;
|
|
4
|
-
const mod_js_1 = require("../../sha1@v1.0.3/mod.js");
|
|
5
|
-
/**
|
|
6
|
-
* Creates a new script.
|
|
7
|
-
*
|
|
8
|
-
* Scripts offer the ability to optimistically try to execute a script without having to send the
|
|
9
|
-
* entire script to the server. If the script is loaded on the server, it tries again by sending
|
|
10
|
-
* the entire script. Afterwards, the script is cached on the server.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* const redis = new Redis({...})
|
|
15
|
-
*
|
|
16
|
-
* const script = redis.createScript<string>("return ARGV[1];")
|
|
17
|
-
* const arg1 = await script.eval([], ["Hello World"])
|
|
18
|
-
* assertEquals(arg1, "Hello World")
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
class Script {
|
|
22
|
-
constructor(redis, script) {
|
|
23
|
-
Object.defineProperty(this, "script", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: void 0
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "sha1", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "redis", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
this.redis = redis;
|
|
42
|
-
this.sha1 = this.digest(script);
|
|
43
|
-
this.script = script;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Send an `EVAL` command to redis.
|
|
47
|
-
*/
|
|
48
|
-
async eval(keys, args) {
|
|
49
|
-
return await this.redis.eval(this.script, keys, args);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Calculates the sha1 hash of the script and then calls `EVALSHA`.
|
|
53
|
-
*/
|
|
54
|
-
async evalsha(keys, args) {
|
|
55
|
-
return await this.redis.evalsha(this.sha1, keys, args);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Optimistically try to run `EVALSHA` first.
|
|
59
|
-
* If the script is not loaded in redis, it will fall back and try again with `EVAL`.
|
|
60
|
-
*
|
|
61
|
-
* Following calls will be able to use the cached script
|
|
62
|
-
*/
|
|
63
|
-
async exec(keys, args) {
|
|
64
|
-
const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (err) => {
|
|
65
|
-
if (err instanceof Error &&
|
|
66
|
-
err.message.toLowerCase().includes("noscript")) {
|
|
67
|
-
return await this.redis.eval(this.script, keys, args);
|
|
68
|
-
}
|
|
69
|
-
throw err;
|
|
70
|
-
});
|
|
71
|
-
return res;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Compute the sha1 hash of the script and return its hex representation.
|
|
75
|
-
*/
|
|
76
|
-
digest(s) {
|
|
77
|
-
const hash = (0, mod_js_1.sha1)(s, "utf8", "hex");
|
|
78
|
-
return typeof hash === "string" ? hash : new TextDecoder().decode(hash);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.Script = Script;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseResponse = void 0;
|
|
4
|
-
function parseRecursive(obj) {
|
|
5
|
-
const parsed = Array.isArray(obj)
|
|
6
|
-
? obj.map((o) => {
|
|
7
|
-
try {
|
|
8
|
-
return parseRecursive(o);
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
return o;
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
: JSON.parse(obj);
|
|
15
|
-
/**
|
|
16
|
-
* Parsing very large numbers can result in MAX_SAFE_INTEGER
|
|
17
|
-
* overflow. In that case we return the number as string instead.
|
|
18
|
-
*/
|
|
19
|
-
if (typeof parsed === "number" && parsed.toString() != obj) {
|
|
20
|
-
return obj;
|
|
21
|
-
}
|
|
22
|
-
return parsed;
|
|
23
|
-
}
|
|
24
|
-
function parseResponse(result) {
|
|
25
|
-
try {
|
|
26
|
-
/**
|
|
27
|
-
* Try to parse the response if possible
|
|
28
|
-
*/
|
|
29
|
-
return parseRecursive(result);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.parseResponse = parseResponse;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encode = exports.decode = void 0;
|
|
4
|
-
const base64url_js_1 = require("../../../deno.land/x/base64@v0.2.1/base64url.js");
|
|
5
|
-
const decoder = new TextDecoder();
|
|
6
|
-
const encoder = new TextEncoder();
|
|
7
|
-
/** Serializes a Uint8Array to a hexadecimal string. */
|
|
8
|
-
function toHexString(buf) {
|
|
9
|
-
return buf.reduce((hex, byte) => `${hex}${byte < 16 ? "0" : ""}${byte.toString(16)}`, "");
|
|
10
|
-
}
|
|
11
|
-
/** Deserializes a Uint8Array from a hexadecimal string. */
|
|
12
|
-
function fromHexString(hex) {
|
|
13
|
-
const len = hex.length;
|
|
14
|
-
if (len % 2 || !/^[0-9a-fA-F]+$/.test(hex)) {
|
|
15
|
-
throw new TypeError("Invalid hex string.");
|
|
16
|
-
}
|
|
17
|
-
hex = hex.toLowerCase();
|
|
18
|
-
const buf = new Uint8Array(Math.floor(len / 2));
|
|
19
|
-
const end = len / 2;
|
|
20
|
-
for (let i = 0; i < end; ++i) {
|
|
21
|
-
buf[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
22
|
-
}
|
|
23
|
-
return buf;
|
|
24
|
-
}
|
|
25
|
-
/** Decodes a Uint8Array to utf8-, base64-, or hex-encoded string. */
|
|
26
|
-
function decode(buf, encoding = "utf8") {
|
|
27
|
-
if (/^utf-?8$/i.test(encoding)) {
|
|
28
|
-
return decoder.decode(buf);
|
|
29
|
-
}
|
|
30
|
-
else if (/^base64$/i.test(encoding)) {
|
|
31
|
-
return (0, base64url_js_1.fromUint8Array)(buf);
|
|
32
|
-
}
|
|
33
|
-
else if (/^hex(?:adecimal)?$/i.test(encoding)) {
|
|
34
|
-
return toHexString(buf);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
throw new TypeError("Unsupported string encoding.");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.decode = decode;
|
|
41
|
-
function encode(str, encoding = "utf8") {
|
|
42
|
-
if (/^utf-?8$/i.test(encoding)) {
|
|
43
|
-
return encoder.encode(str);
|
|
44
|
-
}
|
|
45
|
-
else if (/^base64$/i.test(encoding)) {
|
|
46
|
-
return (0, base64url_js_1.toUint8Array)(str);
|
|
47
|
-
}
|
|
48
|
-
else if (/^hex(?:adecimal)?$/i.test(encoding)) {
|
|
49
|
-
return fromHexString(str);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
throw new TypeError("Unsupported string encoding.");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.encode = encode;
|
package/script/duration.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ms = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Convert a human readable duration to milliseconds
|
|
6
|
-
*/
|
|
7
|
-
function ms(d) {
|
|
8
|
-
const [timeString, duration] = d.split(" ");
|
|
9
|
-
const time = parseFloat(timeString);
|
|
10
|
-
switch (duration) {
|
|
11
|
-
case "ms":
|
|
12
|
-
return time;
|
|
13
|
-
case "s":
|
|
14
|
-
return time * 1000;
|
|
15
|
-
case "m":
|
|
16
|
-
return time * 1000 * 60;
|
|
17
|
-
case "h":
|
|
18
|
-
return time * 1000 * 60 * 60;
|
|
19
|
-
case "d":
|
|
20
|
-
return time * 1000 * 60 * 60 * 24;
|
|
21
|
-
default:
|
|
22
|
-
throw new Error(`Unable to parse window size: ${d}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.ms = ms;
|
package/script/mod.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.MultiRegionRatelimit = exports.Ratelimit = void 0;
|
|
18
|
-
var single_js_1 = require("./single.js");
|
|
19
|
-
Object.defineProperty(exports, "Ratelimit", { enumerable: true, get: function () { return single_js_1.RegionRatelimit; } });
|
|
20
|
-
var multi_js_1 = require("./multi.js");
|
|
21
|
-
Object.defineProperty(exports, "MultiRegionRatelimit", { enumerable: true, get: function () { return multi_js_1.MultiRegionRatelimit; } });
|
|
22
|
-
__exportStar(require("./analytics.js"), exports);
|
package/script/multi.js
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.MultiRegionRatelimit = void 0;
|
|
27
|
-
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
28
|
-
const duration_js_1 = require("./duration.js");
|
|
29
|
-
const ratelimit_js_1 = require("./ratelimit.js");
|
|
30
|
-
const cache_js_1 = require("./cache.js");
|
|
31
|
-
/**
|
|
32
|
-
* Ratelimiter using serverless redis from https://upstash.com/
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* const { limit } = new MultiRegionRatelimit({
|
|
37
|
-
* redis: Redis.fromEnv(),
|
|
38
|
-
* limiter: MultiRegionRatelimit.fixedWindow(
|
|
39
|
-
* 10, // Allow 10 requests per window of 30 minutes
|
|
40
|
-
* "30 m", // interval of 30 minutes
|
|
41
|
-
* )
|
|
42
|
-
* })
|
|
43
|
-
*
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
class MultiRegionRatelimit extends ratelimit_js_1.Ratelimit {
|
|
47
|
-
/**
|
|
48
|
-
* Create a new Ratelimit instance by providing a `@upstash/redis` instance and the algorithn of your choice.
|
|
49
|
-
*/
|
|
50
|
-
constructor(config) {
|
|
51
|
-
super({
|
|
52
|
-
prefix: config.prefix,
|
|
53
|
-
limiter: config.limiter,
|
|
54
|
-
timeout: config.timeout,
|
|
55
|
-
analytics: config.analytics,
|
|
56
|
-
ctx: {
|
|
57
|
-
redis: config.redis,
|
|
58
|
-
cache: config.ephemeralCache
|
|
59
|
-
? new cache_js_1.Cache(config.ephemeralCache)
|
|
60
|
-
: undefined,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Each requests inside a fixed time increases a counter.
|
|
66
|
-
* Once the counter reaches a maxmimum allowed number, all further requests are
|
|
67
|
-
* rejected.
|
|
68
|
-
*
|
|
69
|
-
* **Pro:**
|
|
70
|
-
*
|
|
71
|
-
* - Newer requests are not starved by old ones.
|
|
72
|
-
* - Low storage cost.
|
|
73
|
-
*
|
|
74
|
-
* **Con:**
|
|
75
|
-
*
|
|
76
|
-
* A burst of requests near the boundary of a window can result in a very
|
|
77
|
-
* high request rate because two windows will be filled with requests quickly.
|
|
78
|
-
*
|
|
79
|
-
* @param tokens - How many requests a user can make in each time window.
|
|
80
|
-
* @param window - A fixed timeframe
|
|
81
|
-
*/
|
|
82
|
-
static fixedWindow(
|
|
83
|
-
/**
|
|
84
|
-
* How many requests are allowed per window.
|
|
85
|
-
*/
|
|
86
|
-
tokens,
|
|
87
|
-
/**
|
|
88
|
-
* The duration in which `tokens` requests are allowed.
|
|
89
|
-
*/
|
|
90
|
-
window) {
|
|
91
|
-
const windowDuration = (0, duration_js_1.ms)(window);
|
|
92
|
-
const script = `
|
|
93
|
-
local key = KEYS[1]
|
|
94
|
-
local id = ARGV[1]
|
|
95
|
-
local window = ARGV[2]
|
|
96
|
-
|
|
97
|
-
redis.call("SADD", key, id)
|
|
98
|
-
local members = redis.call("SMEMBERS", key)
|
|
99
|
-
if #members == 1 then
|
|
100
|
-
-- The first time this key is set, the value will be 1.
|
|
101
|
-
-- So we only need the expire command once
|
|
102
|
-
redis.call("PEXPIRE", key, window)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
return members
|
|
106
|
-
`;
|
|
107
|
-
return async function (ctx, identifier) {
|
|
108
|
-
if (ctx.cache) {
|
|
109
|
-
const { blocked, reset } = ctx.cache.isBlocked(identifier);
|
|
110
|
-
if (blocked) {
|
|
111
|
-
return {
|
|
112
|
-
success: false,
|
|
113
|
-
limit: tokens,
|
|
114
|
-
remaining: 0,
|
|
115
|
-
reset: reset,
|
|
116
|
-
pending: Promise.resolve(),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const requestID = dntShim.crypto.randomUUID();
|
|
121
|
-
const bucket = Math.floor(Date.now() / windowDuration);
|
|
122
|
-
const key = [identifier, bucket].join(":");
|
|
123
|
-
const dbs = ctx.redis.map((redis) => ({
|
|
124
|
-
redis,
|
|
125
|
-
request: redis.eval(script, [key], [requestID, windowDuration]),
|
|
126
|
-
}));
|
|
127
|
-
const firstResponse = await Promise.any(dbs.map((s) => s.request));
|
|
128
|
-
const usedTokens = firstResponse.length;
|
|
129
|
-
const remaining = tokens - usedTokens - 1;
|
|
130
|
-
/**
|
|
131
|
-
* If the length between two databases does not match, we sync the two databases
|
|
132
|
-
*/
|
|
133
|
-
async function sync() {
|
|
134
|
-
const individualIDs = await Promise.all(dbs.map((s) => s.request));
|
|
135
|
-
const allIDs = Array.from(new Set(individualIDs.flatMap((_) => _)).values());
|
|
136
|
-
for (const db of dbs) {
|
|
137
|
-
const ids = await db.request;
|
|
138
|
-
/**
|
|
139
|
-
* If the bucket in this db is already full, it doesn't matter which ids it contains.
|
|
140
|
-
* So we do not have to sync.
|
|
141
|
-
*/
|
|
142
|
-
if (ids.length >= tokens) {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
const diff = allIDs.filter((id) => !ids.includes(id));
|
|
146
|
-
/**
|
|
147
|
-
* Don't waste a request if there is nothing to send
|
|
148
|
-
*/
|
|
149
|
-
if (diff.length === 0) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
await db.redis.sadd(key, ...allIDs);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Do not await sync. This should not run in the critical path.
|
|
157
|
-
*/
|
|
158
|
-
const success = remaining > 0;
|
|
159
|
-
const reset = (bucket + 1) * windowDuration;
|
|
160
|
-
if (ctx.cache && !success) {
|
|
161
|
-
ctx.cache.blockUntil(identifier, reset);
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
success,
|
|
165
|
-
limit: tokens,
|
|
166
|
-
remaining,
|
|
167
|
-
reset,
|
|
168
|
-
pending: sync(),
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Combined approach of `slidingLogs` and `fixedWindow` with lower storage
|
|
174
|
-
* costs than `slidingLogs` and improved boundary behavior by calcualting a
|
|
175
|
-
* weighted score between two windows.
|
|
176
|
-
*
|
|
177
|
-
* **Pro:**
|
|
178
|
-
*
|
|
179
|
-
* Good performance allows this to scale to very high loads.
|
|
180
|
-
*
|
|
181
|
-
* **Con:**
|
|
182
|
-
*
|
|
183
|
-
* Nothing major.
|
|
184
|
-
*
|
|
185
|
-
* @param tokens - How many requests a user can make in each time window.
|
|
186
|
-
* @param window - The duration in which the user can max X requests.
|
|
187
|
-
*/
|
|
188
|
-
static slidingWindow(
|
|
189
|
-
/**
|
|
190
|
-
* How many requests are allowed per window.
|
|
191
|
-
*/
|
|
192
|
-
tokens,
|
|
193
|
-
/**
|
|
194
|
-
* The duration in which `tokens` requests are allowed.
|
|
195
|
-
*/
|
|
196
|
-
window) {
|
|
197
|
-
const windowSize = (0, duration_js_1.ms)(window);
|
|
198
|
-
const script = `
|
|
199
|
-
local currentKey = KEYS[1] -- identifier including prefixes
|
|
200
|
-
local previousKey = KEYS[2] -- key of the previous bucket
|
|
201
|
-
local tokens = tonumber(ARGV[1]) -- tokens per window
|
|
202
|
-
local now = ARGV[2] -- current timestamp in milliseconds
|
|
203
|
-
local window = ARGV[3] -- interval in milliseconds
|
|
204
|
-
local requestID = ARGV[4] -- uuid for this request
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
local currentMembers = redis.call("SMEMBERS", currentKey)
|
|
208
|
-
local requestsInCurrentWindow = #currentMembers
|
|
209
|
-
local previousMembers = redis.call("SMEMBERS", previousKey)
|
|
210
|
-
local requestsInPreviousWindow = #previousMembers
|
|
211
|
-
|
|
212
|
-
local percentageInCurrent = ( now % window) / window
|
|
213
|
-
if requestsInPreviousWindow * ( 1 - percentageInCurrent ) + requestsInCurrentWindow >= tokens then
|
|
214
|
-
return {currentMembers, previousMembers}
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
redis.call("SADD", currentKey, requestID)
|
|
218
|
-
table.insert(currentMembers, requestID)
|
|
219
|
-
if requestsInCurrentWindow == 0 then
|
|
220
|
-
-- The first time this key is set, the value will be 1.
|
|
221
|
-
-- So we only need the expire command once
|
|
222
|
-
redis.call("PEXPIRE", currentKey, window * 2 + 1000) -- Enough time to overlap with a new window + 1 second
|
|
223
|
-
end
|
|
224
|
-
return {currentMembers, previousMembers}
|
|
225
|
-
`;
|
|
226
|
-
const windowDuration = (0, duration_js_1.ms)(window);
|
|
227
|
-
return async function (ctx, identifier) {
|
|
228
|
-
if (ctx.cache) {
|
|
229
|
-
const { blocked, reset } = ctx.cache.isBlocked(identifier);
|
|
230
|
-
if (blocked) {
|
|
231
|
-
return {
|
|
232
|
-
success: false,
|
|
233
|
-
limit: tokens,
|
|
234
|
-
remaining: 0,
|
|
235
|
-
reset: reset,
|
|
236
|
-
pending: Promise.resolve(),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const requestID = dntShim.crypto.randomUUID();
|
|
241
|
-
const now = Date.now();
|
|
242
|
-
const currentWindow = Math.floor(now / windowSize);
|
|
243
|
-
const currentKey = [identifier, currentWindow].join(":");
|
|
244
|
-
const previousWindow = currentWindow - windowSize;
|
|
245
|
-
const previousKey = [identifier, previousWindow].join(":");
|
|
246
|
-
const dbs = ctx.redis.map((redis) => ({
|
|
247
|
-
redis,
|
|
248
|
-
request: redis.eval(script, [currentKey, previousKey], [tokens, now, windowDuration, requestID]),
|
|
249
|
-
}));
|
|
250
|
-
const percentageInCurrent = (now % windowDuration) / windowDuration;
|
|
251
|
-
const [current, previous] = await Promise.any(dbs.map((s) => s.request));
|
|
252
|
-
const usedTokens = previous.length * (1 - percentageInCurrent) +
|
|
253
|
-
current.length;
|
|
254
|
-
const remaining = tokens - usedTokens;
|
|
255
|
-
/**
|
|
256
|
-
* If a database differs from the consensus, we sync it
|
|
257
|
-
*/
|
|
258
|
-
async function sync() {
|
|
259
|
-
const [individualIDs] = await Promise.all(dbs.map((s) => s.request));
|
|
260
|
-
const allIDs = Array.from(new Set(individualIDs.flatMap((_) => _)).values());
|
|
261
|
-
for (const db of dbs) {
|
|
262
|
-
const [ids] = await db.request;
|
|
263
|
-
/**
|
|
264
|
-
* If the bucket in this db is already full, it doesn't matter which ids it contains.
|
|
265
|
-
* So we do not have to sync.
|
|
266
|
-
*/
|
|
267
|
-
if (ids.length >= tokens) {
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
const diff = allIDs.filter((id) => !ids.includes(id));
|
|
271
|
-
/**
|
|
272
|
-
* Don't waste a request if there is nothing to send
|
|
273
|
-
*/
|
|
274
|
-
if (diff.length === 0) {
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
await db.redis.sadd(currentKey, ...allIDs);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
const success = remaining > 0;
|
|
281
|
-
const reset = (currentWindow + 1) * windowDuration;
|
|
282
|
-
if (ctx.cache && !success) {
|
|
283
|
-
ctx.cache.blockUntil(identifier, reset);
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
success,
|
|
287
|
-
limit: tokens,
|
|
288
|
-
remaining,
|
|
289
|
-
reset,
|
|
290
|
-
pending: sync(),
|
|
291
|
-
};
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
exports.MultiRegionRatelimit = MultiRegionRatelimit;
|
package/script/package.json
DELETED