stabilize-orm 1.0.5
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/.eslintrc.json +10 -0
- package/.github/workflows/ci-cd.yml +73 -0
- package/README.md +9 -0
- package/bun.lock +605 -0
- package/cli/stabilize-cli.ts +401 -0
- package/dist/cli/stabilize-cli.js +251 -0
- package/dist/index.js +181 -0
- package/examples/config/dataase.ts +8 -0
- package/examples/migrations/20251013_seed_history.ts +0 -0
- package/examples/models/Role.ts +11 -0
- package/examples/models/User.ts +22 -0
- package/examples/seeds/20251013_additional_seed.ts +29 -0
- package/examples/seeds/20251013_initial_seed.ts +33 -0
- package/package.json +59 -0
- package/src/LICENSE +21 -0
- package/src/cache.ts +110 -0
- package/src/client.ts +258 -0
- package/src/decorators.ts +99 -0
- package/src/index.ts +143 -0
- package/src/logger.ts +126 -0
- package/src/migrations.ts +81 -0
- package/src/query-builder.ts +96 -0
- package/src/repository.ts +565 -0
- package/src/types.ts +76 -0
- package/tests/migrations.test.ts +141 -0
- package/tsconfig.json +32 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var G4=Object.create;var{getPrototypeOf:R4,defineProperty:v0,getOwnPropertyNames:y4}=Object;var T4=Object.prototype.hasOwnProperty;var b0=(S,w,$)=>{$=S!=null?G4(R4(S)):{};let E=w||!S||!S.__esModule?v0($,"default",{value:S,enumerable:!0}):$;for(let Y of y4(S))if(!T4.call(E,Y))v0(E,Y,{get:()=>S[Y],enumerable:!0});return E};var D=(S,w)=>()=>(w||S((w={exports:{}}).exports,w),w.exports);var j=import.meta.require;var p0=D((iY,A4)=>{A4.exports={acl:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},append:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},asking:{arity:1,flags:["fast"],keyStart:0,keyStop:0,step:0},auth:{arity:-2,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},bgrewriteaof:{arity:1,flags:["admin","noscript","no_async_loading"],keyStart:0,keyStop:0,step:0},bgsave:{arity:-1,flags:["admin","noscript","no_async_loading"],keyStart:0,keyStop:0,step:0},bitcount:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},bitfield:{arity:-2,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},bitfield_ro:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},bitop:{arity:-4,flags:["write","denyoom"],keyStart:2,keyStop:-1,step:1},bitpos:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},blmove:{arity:6,flags:["write","denyoom","noscript","blocking"],keyStart:1,keyStop:2,step:1},blmpop:{arity:-5,flags:["write","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},blpop:{arity:-3,flags:["write","noscript","blocking"],keyStart:1,keyStop:-2,step:1},brpop:{arity:-3,flags:["write","noscript","blocking"],keyStart:1,keyStop:-2,step:1},brpoplpush:{arity:4,flags:["write","denyoom","noscript","blocking"],keyStart:1,keyStop:2,step:1},bzmpop:{arity:-5,flags:["write","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},bzpopmax:{arity:-3,flags:["write","noscript","blocking","fast"],keyStart:1,keyStop:-2,step:1},bzpopmin:{arity:-3,flags:["write","noscript","blocking","fast"],keyStart:1,keyStop:-2,step:1},client:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},cluster:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},command:{arity:-1,flags:["loading","stale"],keyStart:0,keyStop:0,step:0},config:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},copy:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},dbsize:{arity:1,flags:["readonly","fast"],keyStart:0,keyStop:0,step:0},debug:{arity:-2,flags:["admin","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},decr:{arity:2,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},decrby:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},del:{arity:-2,flags:["write"],keyStart:1,keyStop:-1,step:1},discard:{arity:1,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:0,keyStop:0,step:0},dump:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},echo:{arity:2,flags:["fast"],keyStart:0,keyStop:0,step:0},eval:{arity:-3,flags:["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},eval_ro:{arity:-3,flags:["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},evalsha:{arity:-3,flags:["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},evalsha_ro:{arity:-3,flags:["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},exec:{arity:1,flags:["noscript","loading","stale","skip_slowlog"],keyStart:0,keyStop:0,step:0},exists:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:-1,step:1},expire:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},expireat:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},expiretime:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},failover:{arity:-1,flags:["admin","noscript","stale"],keyStart:0,keyStop:0,step:0},fcall:{arity:-3,flags:["noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},fcall_ro:{arity:-3,flags:["readonly","noscript","stale","skip_monitor","no_mandatory_keys","movablekeys"],keyStart:0,keyStop:0,step:0},flushall:{arity:-1,flags:["write"],keyStart:0,keyStop:0,step:0},flushdb:{arity:-1,flags:["write"],keyStart:0,keyStop:0,step:0},function:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},geoadd:{arity:-5,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},geodist:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},geohash:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},geopos:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},georadius:{arity:-6,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},georadius_ro:{arity:-6,flags:["readonly"],keyStart:1,keyStop:1,step:1},georadiusbymember:{arity:-5,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},georadiusbymember_ro:{arity:-5,flags:["readonly"],keyStart:1,keyStop:1,step:1},geosearch:{arity:-7,flags:["readonly"],keyStart:1,keyStop:1,step:1},geosearchstore:{arity:-8,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},get:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},getbit:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},getdel:{arity:2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},getex:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},getrange:{arity:4,flags:["readonly"],keyStart:1,keyStop:1,step:1},getset:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hdel:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hello:{arity:-1,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},hexists:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hexpire:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hpexpire:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},hget:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hgetall:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},hincrby:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hincrbyfloat:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hkeys:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},hlen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hmget:{arity:-3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hmset:{arity:-4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hrandfield:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},hscan:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},hset:{arity:-4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hsetnx:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},hstrlen:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},hvals:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},incr:{arity:2,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},incrby:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},incrbyfloat:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},info:{arity:-1,flags:["loading","stale"],keyStart:0,keyStop:0,step:0},keys:{arity:2,flags:["readonly"],keyStart:0,keyStop:0,step:0},lastsave:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},latency:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},lcs:{arity:-3,flags:["readonly"],keyStart:1,keyStop:2,step:1},lindex:{arity:3,flags:["readonly"],keyStart:1,keyStop:1,step:1},linsert:{arity:5,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},llen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},lmove:{arity:5,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},lmpop:{arity:-4,flags:["write","movablekeys"],keyStart:0,keyStop:0,step:0},lolwut:{arity:-1,flags:["readonly","fast"],keyStart:0,keyStop:0,step:0},lpop:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},lpos:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},lpush:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},lpushx:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},lrange:{arity:4,flags:["readonly"],keyStart:1,keyStop:1,step:1},lrem:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},lset:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},ltrim:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},memory:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},mget:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:-1,step:1},migrate:{arity:-6,flags:["write","movablekeys"],keyStart:3,keyStop:3,step:1},module:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},monitor:{arity:1,flags:["admin","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},move:{arity:3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},mset:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:2},msetnx:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:2},multi:{arity:1,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:0,keyStop:0,step:0},object:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},persist:{arity:2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},pexpire:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},pexpireat:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},pexpiretime:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},pfadd:{arity:-2,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},pfcount:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},pfdebug:{arity:3,flags:["write","denyoom","admin"],keyStart:2,keyStop:2,step:1},pfmerge:{arity:-2,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},pfselftest:{arity:1,flags:["admin"],keyStart:0,keyStop:0,step:0},ping:{arity:-1,flags:["fast"],keyStart:0,keyStop:0,step:0},psetex:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},psubscribe:{arity:-2,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},psync:{arity:-3,flags:["admin","noscript","no_async_loading","no_multi"],keyStart:0,keyStop:0,step:0},pttl:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},publish:{arity:3,flags:["pubsub","loading","stale","fast"],keyStart:0,keyStop:0,step:0},pubsub:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},punsubscribe:{arity:-1,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},quit:{arity:-1,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},randomkey:{arity:1,flags:["readonly"],keyStart:0,keyStop:0,step:0},readonly:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},readwrite:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},rename:{arity:3,flags:["write"],keyStart:1,keyStop:2,step:1},renamenx:{arity:3,flags:["write","fast"],keyStart:1,keyStop:2,step:1},replconf:{arity:-1,flags:["admin","noscript","loading","stale","allow_busy"],keyStart:0,keyStop:0,step:0},replicaof:{arity:3,flags:["admin","noscript","stale","no_async_loading"],keyStart:0,keyStop:0,step:0},reset:{arity:1,flags:["noscript","loading","stale","fast","no_auth","allow_busy"],keyStart:0,keyStop:0,step:0},restore:{arity:-4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},"restore-asking":{arity:-4,flags:["write","denyoom","asking"],keyStart:1,keyStop:1,step:1},role:{arity:1,flags:["noscript","loading","stale","fast"],keyStart:0,keyStop:0,step:0},rpop:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},rpoplpush:{arity:3,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},rpush:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},rpushx:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},sadd:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},save:{arity:1,flags:["admin","noscript","no_async_loading","no_multi"],keyStart:0,keyStop:0,step:0},scan:{arity:-2,flags:["readonly"],keyStart:0,keyStop:0,step:0},scard:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},script:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},sdiff:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},sdiffstore:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},select:{arity:2,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},set:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},setbit:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},setex:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},setnx:{arity:3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},setrange:{arity:4,flags:["write","denyoom"],keyStart:1,keyStop:1,step:1},shutdown:{arity:-1,flags:["admin","noscript","loading","stale","no_multi","allow_busy"],keyStart:0,keyStop:0,step:0},sinter:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},sintercard:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},sinterstore:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},sismember:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},slaveof:{arity:3,flags:["admin","noscript","stale","no_async_loading"],keyStart:0,keyStop:0,step:0},slowlog:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},smembers:{arity:2,flags:["readonly"],keyStart:1,keyStop:1,step:1},smismember:{arity:-3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},smove:{arity:4,flags:["write","fast"],keyStart:1,keyStop:2,step:1},sort:{arity:-2,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},sort_ro:{arity:-2,flags:["readonly","movablekeys"],keyStart:1,keyStop:1,step:1},spop:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},spublish:{arity:3,flags:["pubsub","loading","stale","fast"],keyStart:1,keyStop:1,step:1},srandmember:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},srem:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},sscan:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},ssubscribe:{arity:-2,flags:["pubsub","noscript","loading","stale"],keyStart:1,keyStop:-1,step:1},strlen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},subscribe:{arity:-2,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},substr:{arity:4,flags:["readonly"],keyStart:1,keyStop:1,step:1},sunion:{arity:-2,flags:["readonly"],keyStart:1,keyStop:-1,step:1},sunionstore:{arity:-3,flags:["write","denyoom"],keyStart:1,keyStop:-1,step:1},sunsubscribe:{arity:-1,flags:["pubsub","noscript","loading","stale"],keyStart:1,keyStop:-1,step:1},swapdb:{arity:3,flags:["write","fast"],keyStart:0,keyStop:0,step:0},sync:{arity:1,flags:["admin","noscript","no_async_loading","no_multi"],keyStart:0,keyStop:0,step:0},time:{arity:1,flags:["loading","stale","fast"],keyStart:0,keyStop:0,step:0},touch:{arity:-2,flags:["readonly","fast"],keyStart:1,keyStop:-1,step:1},ttl:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},type:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},unlink:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:-1,step:1},unsubscribe:{arity:-1,flags:["pubsub","noscript","loading","stale"],keyStart:0,keyStop:0,step:0},unwatch:{arity:1,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:0,keyStop:0,step:0},wait:{arity:3,flags:["noscript"],keyStart:0,keyStop:0,step:0},watch:{arity:-2,flags:["noscript","loading","stale","fast","allow_busy"],keyStart:1,keyStop:-1,step:1},xack:{arity:-4,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xadd:{arity:-5,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},xautoclaim:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xclaim:{arity:-6,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xdel:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xdelex:{arity:-5,flags:["write","fast"],keyStart:1,keyStop:1,step:1},xgroup:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},xinfo:{arity:-2,flags:[],keyStart:0,keyStop:0,step:0},xlen:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},xpending:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},xrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},xread:{arity:-4,flags:["readonly","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},xreadgroup:{arity:-7,flags:["write","blocking","movablekeys"],keyStart:0,keyStop:0,step:0},xrevrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},xsetid:{arity:-3,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},xtrim:{arity:-4,flags:["write"],keyStart:1,keyStop:1,step:1},zadd:{arity:-4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},zcard:{arity:2,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zcount:{arity:4,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zdiff:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zdiffstore:{arity:-4,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},zincrby:{arity:4,flags:["write","denyoom","fast"],keyStart:1,keyStop:1,step:1},zinter:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zintercard:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zinterstore:{arity:-4,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1},zlexcount:{arity:4,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zmpop:{arity:-4,flags:["write","movablekeys"],keyStart:0,keyStop:0,step:0},zmscore:{arity:-3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zpopmax:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},zpopmin:{arity:-2,flags:["write","fast"],keyStart:1,keyStop:1,step:1},zrandmember:{arity:-2,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrangebylex:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrangebyscore:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrangestore:{arity:-5,flags:["write","denyoom"],keyStart:1,keyStop:2,step:1},zrank:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zrem:{arity:-3,flags:["write","fast"],keyStart:1,keyStop:1,step:1},zremrangebylex:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},zremrangebyrank:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},zremrangebyscore:{arity:4,flags:["write"],keyStart:1,keyStop:1,step:1},zrevrange:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrevrangebylex:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrevrangebyscore:{arity:-4,flags:["readonly"],keyStart:1,keyStop:1,step:1},zrevrank:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zscan:{arity:-3,flags:["readonly"],keyStart:1,keyStop:1,step:1},zscore:{arity:3,flags:["readonly","fast"],keyStart:1,keyStop:1,step:1},zunion:{arity:-3,flags:["readonly","movablekeys"],keyStart:0,keyStop:0,step:0},zunionstore:{arity:-4,flags:["write","denyoom","movablekeys"],keyStart:1,keyStop:1,step:1}}});var N1=D((m)=>{var D4=m&&m.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(m,"__esModule",{value:!0});m.getKeyIndexes=m.hasFlag=m.exists=m.list=void 0;var $S=D4(p0());m.list=Object.keys($S.default);var xS={};m.list.forEach((S)=>{xS[S]=$S.default[S].flags.reduce(function(w,$){return w[$]=!0,w},{})});function k4(S){return Boolean($S.default[S])}m.exists=k4;function I4(S,w){if(!xS[S])throw Error("Unknown command "+S);return Boolean(xS[S][w])}m.hasFlag=I4;function M4(S,w,$){let E=$S.default[S];if(!E)throw Error("Unknown command "+S);if(!Array.isArray(w))throw Error("Expect args to be an array");let Y=[],J=Boolean($&&$.parseExternalKey),Q=(Z,B)=>{let z=[],W=Number(Z[B]);for(let H=0;H<W;H++)z.push(H+B+1);return z},X=(Z,B,z)=>{for(let W=B;W<Z.length-1;W+=1)if(String(Z[W]).toLowerCase()===z.toLowerCase())return W+1;return null};switch(S){case"zunionstore":case"zinterstore":case"zdiffstore":Y.push(0,...Q(w,1));break;case"eval":case"evalsha":case"eval_ro":case"evalsha_ro":case"fcall":case"fcall_ro":case"blmpop":case"bzmpop":Y.push(...Q(w,1));break;case"sintercard":case"lmpop":case"zunion":case"zinter":case"zmpop":case"zintercard":case"zdiff":{Y.push(...Q(w,0));break}case"georadius":{Y.push(0);let Z=X(w,5,"STORE");if(Z)Y.push(Z);let B=X(w,5,"STOREDIST");if(B)Y.push(B);break}case"georadiusbymember":{Y.push(0);let Z=X(w,4,"STORE");if(Z)Y.push(Z);let B=X(w,4,"STOREDIST");if(B)Y.push(B);break}case"sort":case"sort_ro":Y.push(0);for(let Z=1;Z<w.length-1;Z++){let B=w[Z];if(typeof B!=="string")continue;let z=B.toUpperCase();if(z==="GET"){if(Z+=1,B=w[Z],B!=="#")if(J)Y.push([Z,u0(B)]);else Y.push(Z)}else if(z==="BY")if(Z+=1,J)Y.push([Z,u0(w[Z])]);else Y.push(Z);else if(z==="STORE")Z+=1,Y.push(Z)}break;case"migrate":if(w[2]==="")for(let Z=5;Z<w.length-1;Z++){let B=w[Z];if(typeof B==="string"&&B.toUpperCase()==="KEYS"){for(let z=Z+1;z<w.length;z++)Y.push(z);break}}else Y.push(2);break;case"xreadgroup":case"xread":for(let Z=S==="xread"?0:3;Z<w.length-1;Z++)if(String(w[Z]).toUpperCase()==="STREAMS"){for(let B=Z+1;B<=Z+(w.length-1-Z)/2;B++)Y.push(B);break}break;default:if(E.step>0){let Z=E.keyStart-1,B=E.keyStop>0?E.keyStop:w.length+E.keyStop+1;for(let z=Z;z<B;z+=E.step)Y.push(z)}break}return Y}m.getKeyIndexes=M4;function u0(S){if(typeof S!=="string")S=String(S);let w=S.indexOf("->");return w===-1?S.length:w}});var c0=D((i0)=>{Object.defineProperty(i0,"__esModule",{value:!0});i0.tryCatch=i0.errorObj=void 0;i0.errorObj={e:{}};var OS;function N4(S,w){try{let $=OS;return OS=null,$.apply(this,arguments)}catch($){return i0.errorObj.e=$,i0.errorObj}}function P4(S){return OS=S,N4}i0.tryCatch=P4});var Q1=D((l0)=>{Object.defineProperty(l0,"__esModule",{value:!0});var P1=c0();function m0(S){setTimeout(function(){throw S},0)}function C4(S,w,$){if(typeof w==="function")S.then((E)=>{let Y;if($!==void 0&&Object($).spread&&Array.isArray(E))Y=P1.tryCatch(w).apply(void 0,[null].concat(E));else Y=E===void 0?P1.tryCatch(w)(null):P1.tryCatch(w)(null,E);if(Y===P1.errorObj)m0(Y.e)},(E)=>{if(!E){let J=Error(E+"");Object.assign(J,{cause:E}),E=J}let Y=P1.tryCatch(w)(E);if(Y===P1.errorObj)m0(Y.e)});return S}l0.default=C4});var n0=D((lY,o0)=>{var d0=j("assert"),b1=j("util");function C1(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}b1.inherits(C1,Error);Object.defineProperty(C1.prototype,"name",{value:"RedisError",configurable:!0,writable:!0});function fS(S,w,$){d0(w),d0.strictEqual(typeof $,"number"),Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0});let E=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=E,this.offset=$,this.buffer=w}b1.inherits(fS,C1);Object.defineProperty(fS.prototype,"name",{value:"ParserError",configurable:!0,writable:!0});function _S(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0});let w=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=w}b1.inherits(_S,C1);Object.defineProperty(_S.prototype,"name",{value:"ReplyError",configurable:!0,writable:!0});function ES(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}b1.inherits(ES,C1);Object.defineProperty(ES.prototype,"name",{value:"AbortError",configurable:!0,writable:!0});function gS(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}b1.inherits(gS,ES);Object.defineProperty(gS.prototype,"name",{value:"InterruptError",configurable:!0,writable:!0});o0.exports={RedisError:C1,ParserError:fS,ReplyError:_S,AbortError:ES,InterruptError:gS}});var ww=D((dY,Sw)=>{var s0=j("assert");class p1 extends Error{get name(){return this.constructor.name}}class a0 extends p1{constructor(S,w,$){s0(w),s0.strictEqual(typeof $,"number");let E=Error.stackTraceLimit;Error.stackTraceLimit=2;super(S);Error.stackTraceLimit=E,this.offset=$,this.buffer=w}get name(){return this.constructor.name}}class r0 extends p1{constructor(S){let w=Error.stackTraceLimit;Error.stackTraceLimit=2;super(S);Error.stackTraceLimit=w}get name(){return this.constructor.name}}class vS extends p1{get name(){return this.constructor.name}}class e0 extends vS{get name(){return this.constructor.name}}Sw.exports={RedisError:p1,ParserError:a0,ReplyError:r0,AbortError:vS,InterruptError:e0}});var H1=D((oY,$w)=>{var h4=process.version.charCodeAt(1)<55&&process.version.charCodeAt(2)===46?n0():ww();$w.exports=h4});var u1=D((nY,bS)=>{var Ew=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920],x4=function(w){var $,E=0,Y=0,J=[],Q=w.length;for(;E<Q;E++)if($=w.charCodeAt(E),$<128)J[Y++]=$;else if($<2048)J[Y++]=$>>6|192,J[Y++]=$&63|128;else if(($&64512)===55296&&E+1<w.length&&(w.charCodeAt(E+1)&64512)===56320)$=65536+(($&1023)<<10)+(w.charCodeAt(++E)&1023),J[Y++]=$>>18|240,J[Y++]=$>>12&63|128,J[Y++]=$>>6&63|128,J[Y++]=$&63|128;else J[Y++]=$>>12|224,J[Y++]=$>>6&63|128,J[Y++]=$&63|128;return J},Yw=bS.exports=function(w){var $,E=0,Y=-1,J=0,Q=0,X=typeof w==="string"?x4(w):w,Z=X.length;while(E<Z){if($=X[E++],Y===-1){if($===123)Y=E}else if($!==125)Q=Ew[($^Q>>8)&255]^Q<<8;else if(E-1!==Y)return Q&16383;J=Ew[($^J>>8)&255]^J<<8}return J&16383};bS.exports.generateMulti=function(w){var $=1,E=w.length,Y=Yw(w[0]);while($<E)if(Yw(w[$++])!==Y)return-1;return Y}});var zw=D((sY,Ww)=>{var Qw=9007199254740991,O4="[object Arguments]",K4="[object Function]",f4="[object GeneratorFunction]",_4=/^(?:0|[1-9]\d*)$/;function Xw(S,w,$){switch($.length){case 0:return S.call(w);case 1:return S.call(w,$[0]);case 2:return S.call(w,$[0],$[1]);case 3:return S.call(w,$[0],$[1],$[2])}return S.apply(w,$)}function g4(S,w){var $=-1,E=Array(S);while(++$<S)E[$]=w($);return E}var i1=Object.prototype,t1=i1.hasOwnProperty,Zw=i1.toString,v4=i1.propertyIsEnumerable,Jw=Math.max;function b4(S,w){var $=n4(S)||o4(S)?g4(S.length,String):[],E=$.length,Y=!!E;for(var J in S)if((w||t1.call(S,J))&&!(Y&&(J=="length"||Lw(J,E))))$.push(J);return $}function p4(S,w,$,E){if(S===void 0||pS(S,i1[$])&&!t1.call(E,$))return w;return S}function u4(S,w,$){var E=S[w];if(!(t1.call(S,w)&&pS(E,$))||$===void 0&&!(w in S))S[w]=$}function i4(S){if(!iS(S))return d4(S);var w=l4(S),$=[];for(var E in S)if(!(E=="constructor"&&(w||!t1.call(S,E))))$.push(E);return $}function Fw(S,w){return w=Jw(w===void 0?S.length-1:w,0),function(){var $=arguments,E=-1,Y=Jw($.length-w,0),J=Array(Y);while(++E<Y)J[E]=$[w+E];E=-1;var Q=Array(w+1);while(++E<w)Q[E]=$[E];return Q[w]=J,Xw(S,this,Q)}}function t4(S,w,$,E){$||($={});var Y=-1,J=w.length;while(++Y<J){var Q=w[Y],X=E?E($[Q],S[Q],Q,$,S):void 0;u4($,Q,X===void 0?S[Q]:X)}return $}function c4(S){return Fw(function(w,$){var E=-1,Y=$.length,J=Y>1?$[Y-1]:void 0,Q=Y>2?$[2]:void 0;if(J=S.length>3&&typeof J=="function"?(Y--,J):void 0,Q&&m4($[0],$[1],Q))J=Y<3?void 0:J,Y=1;w=Object(w);while(++E<Y){var X=$[E];if(X)S(w,X,E,J)}return w})}function Lw(S,w){return w=w==null?Qw:w,!!w&&(typeof S=="number"||_4.test(S))&&(S>-1&&S%1==0&&S<w)}function m4(S,w,$){if(!iS($))return!1;var E=typeof w;if(E=="number"?uS($)&&Lw(w,$.length):E=="string"&&(w in $))return pS($[w],S);return!1}function l4(S){var w=S&&S.constructor,$=typeof w=="function"&&w.prototype||i1;return S===$}function d4(S){var w=[];if(S!=null)for(var $ in Object(S))w.push($);return w}function pS(S,w){return S===w||S!==S&&w!==w}function o4(S){return s4(S)&&t1.call(S,"callee")&&(!v4.call(S,"callee")||Zw.call(S)==O4)}var n4=Array.isArray;function uS(S){return S!=null&&r4(S.length)&&!a4(S)}function s4(S){return e4(S)&&uS(S)}function a4(S){var w=iS(S)?Zw.call(S):"";return w==K4||w==f4}function r4(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=Qw}function iS(S){var w=typeof S;return!!S&&(w=="object"||w=="function")}function e4(S){return!!S&&typeof S=="object"}var S5=c4(function(S,w,$,E){t4(w,$5(w),S,E)}),w5=Fw(function(S){return S.push(void 0,p4),Xw(S5,void 0,S)});function $5(S){return uS(S)?b4(S,!0):i4(S)}Ww.exports=w5});var Hw=D((aY,Vw)=>{var E5=9007199254740991,Y5="[object Arguments]",J5="[object Function]",Q5="[object GeneratorFunction]",tS=Object.prototype,X5=tS.hasOwnProperty,Bw=tS.toString,Z5=tS.propertyIsEnumerable;function F5(S){return W5(S)&&X5.call(S,"callee")&&(!Z5.call(S,"callee")||Bw.call(S)==Y5)}function L5(S){return S!=null&&B5(S.length)&&!z5(S)}function W5(S){return H5(S)&&L5(S)}function z5(S){var w=V5(S)?Bw.call(S):"";return w==J5||w==Q5}function B5(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=E5}function V5(S){var w=typeof S;return!!S&&(w=="object"||w=="function")}function H5(S){return!!S&&typeof S=="object"}Vw.exports=F5});var YS=D((Uw)=>{Object.defineProperty(Uw,"__esModule",{value:!0});Uw.isArguments=Uw.defaults=Uw.noop=void 0;var U5=zw();Uw.defaults=U5;var q5=Hw();Uw.isArguments=q5;function G5(){}Uw.noop=G5});var Rw=D((eY,Gw)=>{var j1=1000,h1=j1*60,x1=h1*60,U1=x1*24,T5=U1*7,A5=U1*365.25;Gw.exports=function(S,w){w=w||{};var $=typeof S;if($==="string"&&S.length>0)return D5(S);else if($==="number"&&isFinite(S))return w.long?I5(S):k5(S);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(S))};function D5(S){if(S=String(S),S.length>100)return;var w=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(S);if(!w)return;var $=parseFloat(w[1]),E=(w[2]||"ms").toLowerCase();switch(E){case"years":case"year":case"yrs":case"yr":case"y":return $*A5;case"weeks":case"week":case"w":return $*T5;case"days":case"day":case"d":return $*U1;case"hours":case"hour":case"hrs":case"hr":case"h":return $*x1;case"minutes":case"minute":case"mins":case"min":case"m":return $*h1;case"seconds":case"second":case"secs":case"sec":case"s":return $*j1;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return $;default:return}}function k5(S){var w=Math.abs(S);if(w>=U1)return Math.round(S/U1)+"d";if(w>=x1)return Math.round(S/x1)+"h";if(w>=h1)return Math.round(S/h1)+"m";if(w>=j1)return Math.round(S/j1)+"s";return S+"ms"}function I5(S){var w=Math.abs(S);if(w>=U1)return JS(S,w,U1,"day");if(w>=x1)return JS(S,w,x1,"hour");if(w>=h1)return JS(S,w,h1,"minute");if(w>=j1)return JS(S,w,j1,"second");return S+" ms"}function JS(S,w,$,E){var Y=w>=$*1.5;return Math.round(S/$)+" "+E+(Y?"s":"")}});var cS=D((SJ,yw)=>{function M5(S){$.debug=$,$.default=$,$.coerce=Z,$.disable=Q,$.enable=Y,$.enabled=X,$.humanize=Rw(),$.destroy=B,Object.keys(S).forEach((z)=>{$[z]=S[z]}),$.names=[],$.skips=[],$.formatters={};function w(z){let W=0;for(let H=0;H<z.length;H++)W=(W<<5)-W+z.charCodeAt(H),W|=0;return $.colors[Math.abs(W)%$.colors.length]}$.selectColor=w;function $(z){let W,H=null,G,N;function h(...P){if(!h.enabled)return;let c=h,D1=Number(new Date),IS=D1-(W||D1);if(c.diff=IS,c.prev=W,c.curr=D1,W=D1,P[0]=$.coerce(P[0]),typeof P[0]!=="string")P.unshift("%O");let k1=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(g1,MS)=>{if(g1==="%%")return"%";k1++;let wS=$.formatters[MS];if(typeof wS==="function"){let NS=P[k1];g1=wS.call(c,NS),P.splice(k1,1),k1--}return g1}),$.formatArgs.call(c,P),(c.log||$.log).apply(c,P)}if(h.namespace=z,h.useColors=$.useColors(),h.color=$.selectColor(z),h.extend=E,h.destroy=$.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(H!==null)return H;if(G!==$.namespaces)G=$.namespaces,N=$.enabled(z);return N},set:(P)=>{H=P}}),typeof $.init==="function")$.init(h);return h}function E(z,W){let H=$(this.namespace+(typeof W>"u"?":":W)+z);return H.log=this.log,H}function Y(z){$.save(z),$.namespaces=z,$.names=[],$.skips=[];let W=(typeof z==="string"?z:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let H of W)if(H[0]==="-")$.skips.push(H.slice(1));else $.names.push(H)}function J(z,W){let H=0,G=0,N=-1,h=0;while(H<z.length)if(G<W.length&&(W[G]===z[H]||W[G]==="*"))if(W[G]==="*")N=G,h=H,G++;else H++,G++;else if(N!==-1)G=N+1,h++,H=h;else return!1;while(G<W.length&&W[G]==="*")G++;return G===W.length}function Q(){let z=[...$.names,...$.skips.map((W)=>"-"+W)].join(",");return $.enable(""),z}function X(z){for(let W of $.skips)if(J(z,W))return!1;for(let W of $.names)if(J(z,W))return!0;return!1}function Z(z){if(z instanceof Error)return z.stack||z.message;return z}function B(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return $.enable($.load()),$}yw.exports=M5});var Aw=D((Tw,QS)=>{Tw.formatArgs=P5;Tw.save=C5;Tw.load=j5;Tw.useColors=N5;Tw.storage=h5();Tw.destroy=(()=>{let S=!1;return()=>{if(!S)S=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();Tw.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function N5(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let S;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(S=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(S[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function P5(S){if(S[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+S[0]+(this.useColors?"%c ":" ")+"+"+QS.exports.humanize(this.diff),!this.useColors)return;let w="color: "+this.color;S.splice(1,0,w,"color: inherit");let $=0,E=0;S[0].replace(/%[a-zA-Z%]/g,(Y)=>{if(Y==="%%")return;if($++,Y==="%c")E=$}),S.splice(E,0,w)}Tw.log=console.debug||console.log||(()=>{});function C5(S){try{if(S)Tw.storage.setItem("debug",S);else Tw.storage.removeItem("debug")}catch(w){}}function j5(){let S;try{S=Tw.storage.getItem("debug")||Tw.storage.getItem("DEBUG")}catch(w){}if(!S&&typeof process<"u"&&"env"in process)S=process.env.DEBUG;return S}function h5(){try{return localStorage}catch(S){}}QS.exports=cS()(Tw);var{formatters:x5}=QS.exports;x5.j=function(S){try{return JSON.stringify(S)}catch(w){return"[UnexpectedJSONParseError]: "+w.message}}});var kw=D(($J,Dw)=>{Dw.exports=(S,w=process.argv)=>{let $=S.startsWith("-")?"":S.length===1?"-":"--",E=w.indexOf($+S),Y=w.indexOf("--");return E!==-1&&(Y===-1||E<Y)}});var Nw=D((EJ,Mw)=>{var p5=j("os"),Iw=j("tty"),o=kw(),{env:v}=process,X1;if(o("no-color")||o("no-colors")||o("color=false")||o("color=never"))X1=0;else if(o("color")||o("colors")||o("color=true")||o("color=always"))X1=1;if("FORCE_COLOR"in v)if(v.FORCE_COLOR==="true")X1=1;else if(v.FORCE_COLOR==="false")X1=0;else X1=v.FORCE_COLOR.length===0?1:Math.min(parseInt(v.FORCE_COLOR,10),3);function mS(S){if(S===0)return!1;return{level:S,hasBasic:!0,has256:S>=2,has16m:S>=3}}function lS(S,w){if(X1===0)return 0;if(o("color=16m")||o("color=full")||o("color=truecolor"))return 3;if(o("color=256"))return 2;if(S&&!w&&X1===void 0)return 0;let $=X1||0;if(v.TERM==="dumb")return $;if(process.platform==="win32"){let E=p5.release().split(".");if(Number(E[0])>=10&&Number(E[2])>=10586)return Number(E[2])>=14931?3:2;return 1}if("CI"in v){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((E)=>(E in v))||v.CI_NAME==="codeship")return 1;return $}if("TEAMCITY_VERSION"in v)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(v.TEAMCITY_VERSION)?1:0;if(v.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in v){let E=parseInt((v.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(v.TERM_PROGRAM){case"iTerm.app":return E>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(v.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(v.TERM))return 1;if("COLORTERM"in v)return 1;return $}function u5(S){let w=lS(S,S&&S.isTTY);return mS(w)}Mw.exports={supportsColor:u5,stdout:mS(lS(!0,Iw.isatty(1))),stderr:mS(lS(!0,Iw.isatty(2)))}});var hw=D((Cw,ZS)=>{var i5=j("tty"),XS=j("util");Cw.init=n5;Cw.log=l5;Cw.formatArgs=c5;Cw.save=d5;Cw.load=o5;Cw.useColors=t5;Cw.destroy=XS.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Cw.colors=[6,2,3,4,5,1];try{let S=Nw();if(S&&(S.stderr||S).level>=2)Cw.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(S){}Cw.inspectOpts=Object.keys(process.env).filter((S)=>{return/^debug_/i.test(S)}).reduce((S,w)=>{let $=w.substring(6).toLowerCase().replace(/_([a-z])/g,(Y,J)=>{return J.toUpperCase()}),E=process.env[w];if(/^(yes|on|true|enabled)$/i.test(E))E=!0;else if(/^(no|off|false|disabled)$/i.test(E))E=!1;else if(E==="null")E=null;else E=Number(E);return S[$]=E,S},{});function t5(){return"colors"in Cw.inspectOpts?Boolean(Cw.inspectOpts.colors):i5.isatty(process.stderr.fd)}function c5(S){let{namespace:w,useColors:$}=this;if($){let E=this.color,Y="\x1B[3"+(E<8?E:"8;5;"+E),J=` ${Y};1m${w} \x1B[0m`;S[0]=J+S[0].split(`
|
|
3
|
+
`).join(`
|
|
4
|
+
`+J),S.push(Y+"m+"+ZS.exports.humanize(this.diff)+"\x1B[0m")}else S[0]=m5()+w+" "+S[0]}function m5(){if(Cw.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function l5(...S){return process.stderr.write(XS.formatWithOptions(Cw.inspectOpts,...S)+`
|
|
5
|
+
`)}function d5(S){if(S)process.env.DEBUG=S;else delete process.env.DEBUG}function o5(){return process.env.DEBUG}function n5(S){S.inspectOpts={};let w=Object.keys(Cw.inspectOpts);for(let $=0;$<w.length;$++)S.inspectOpts[w[$]]=Cw.inspectOpts[w[$]]}ZS.exports=cS()(Cw);var{formatters:Pw}=ZS.exports;Pw.o=function(S){return this.inspectOpts.colors=this.useColors,XS.inspect(S,this.inspectOpts).split(`
|
|
6
|
+
`).map((w)=>w.trim()).join(" ")};Pw.O=function(S){return this.inspectOpts.colors=this.useColors,XS.inspect(S,this.inspectOpts)}});var xw=D((JJ,dS)=>{if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)dS.exports=Aw();else dS.exports=hw()});var gw=D((fw)=>{Object.defineProperty(fw,"__esModule",{value:!0});fw.genRedactedString=fw.getStringValue=fw.MAX_ARGUMENT_LENGTH=void 0;var EE=xw(),oS=200;fw.MAX_ARGUMENT_LENGTH=oS;var YE="ioredis";function Ow(S){if(S===null)return;switch(typeof S){case"boolean":return;case"number":return;case"object":if(Buffer.isBuffer(S))return S.toString("hex");if(Array.isArray(S))return S.join(",");try{return JSON.stringify(S)}catch(w){return}case"string":return S}}fw.getStringValue=Ow;function Kw(S,w){let{length:$}=S;return $<=w?S:S.slice(0,w)+' ... <REDACTED full-length="'+$+'">'}fw.genRedactedString=Kw;function JE(S){let w=(0,EE.default)(`${YE}:${S}`);function $(...E){if(!w.enabled)return;for(let Y=1;Y<E.length;Y++){let J=Ow(E[Y]);if(typeof J==="string"&&J.length>oS)E[Y]=Kw(J,oS)}return w.apply(null,E)}return Object.defineProperties($,{namespace:{get(){return w.namespace}},enabled:{get(){return w.enabled}},destroy:{get(){return w.destroy}},log:{get(){return w.log},set(E){w.log=E}}}),$}fw.default=JE});var pw=D((bw)=>{Object.defineProperty(bw,"__esModule",{value:!0});var vw=`-----BEGIN CERTIFICATE-----
|
|
7
|
+
MIIDTzCCAjegAwIBAgIJAKSVpiDswLcwMA0GCSqGSIb3DQEBBQUAMD4xFjAUBgNV
|
|
8
|
+
BAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1
|
|
9
|
+
dGhvcml0eTAeFw0xMzEwMDExMjE0NTVaFw0yMzA5MjkxMjE0NTVaMD4xFjAUBgNV
|
|
10
|
+
BAoMDUdhcmFudGlhIERhdGExJDAiBgNVBAMMG1NTTCBDZXJ0aWZpY2F0aW9uIEF1
|
|
11
|
+
dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALZqkh/DczWP
|
|
12
|
+
JnxnHLQ7QL0T4B4CDKWBKCcisriGbA6ZePWVNo4hfKQC6JrzfR+081NeD6VcWUiz
|
|
13
|
+
rmd+jtPhIY4c+WVQYm5PKaN6DT1imYdxQw7aqO5j2KUCEh/cznpLxeSHoTxlR34E
|
|
14
|
+
QwF28Wl3eg2vc5ct8LjU3eozWVk3gb7alx9mSA2SgmuX5lEQawl++rSjsBStemY2
|
|
15
|
+
BDwOpAMXIrdEyP/cVn8mkvi/BDs5M5G+09j0gfhyCzRWMQ7Hn71u1eolRxwVxgi3
|
|
16
|
+
TMn+/vTaFSqxKjgck6zuAYjBRPaHe7qLxHNr1So/Mc9nPy+3wHebFwbIcnUojwbp
|
|
17
|
+
4nctkWbjb2cCAwEAAaNQME4wHQYDVR0OBBYEFP1whtcrydmW3ZJeuSoKZIKjze3w
|
|
18
|
+
MB8GA1UdIwQYMBaAFP1whtcrydmW3ZJeuSoKZIKjze3wMAwGA1UdEwQFMAMBAf8w
|
|
19
|
+
DQYJKoZIhvcNAQEFBQADggEBAG2erXhwRAa7+ZOBs0B6X57Hwyd1R4kfmXcs0rta
|
|
20
|
+
lbPpvgULSiB+TCbf3EbhJnHGyvdCY1tvlffLjdA7HJ0PCOn+YYLBA0pTU/dyvrN6
|
|
21
|
+
Su8NuS5yubnt9mb13nDGYo1rnt0YRfxN+8DM3fXIVr038A30UlPX2Ou1ExFJT0MZ
|
|
22
|
+
uFKY6ZvLdI6/1cbgmguMlAhM+DhKyV6Sr5699LM3zqeI816pZmlREETYkGr91q7k
|
|
23
|
+
BpXJu/dtHaGxg1ZGu6w/PCsYGUcECWENYD4VQPd8N32JjOfu6vEgoEAwfPP+3oGp
|
|
24
|
+
Z4m3ewACcWOAenqflb+cQYC4PsF7qbXDmRaWrbKntOlZ3n0=
|
|
25
|
+
-----END CERTIFICATE-----
|
|
26
|
+
-----BEGIN CERTIFICATE-----
|
|
27
|
+
MIIGMTCCBBmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwajELMAkGA1UEBhMCVVMx
|
|
28
|
+
CzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJzMS0w
|
|
29
|
+
KwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN
|
|
30
|
+
MTgwMjI1MTUzNzM3WhcNMjgwMjIzMTUzNzM3WjBfMQswCQYDVQQGEwJVUzELMAkG
|
|
31
|
+
A1UECAwCQ0ExEjAQBgNVBAoMCVJlZGlzTGFiczEvMC0GA1UEAwwmUkNQIEludGVy
|
|
32
|
+
bWVkaWF0ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA
|
|
33
|
+
A4ICDwAwggIKAoICAQDf9dqbxc8Bq7Ctq9rWcxrGNKKHivqLAFpPq02yLPx6fsOv
|
|
34
|
+
Tq7GsDChAYBBc4v7Y2Ap9RD5Vs3dIhEANcnolf27QwrG9RMnnvzk8pCvp1o6zSU4
|
|
35
|
+
VuOE1W66/O1/7e2rVxyrnTcP7UgK43zNIXu7+tiAqWsO92uSnuMoGPGpeaUm1jym
|
|
36
|
+
hjWKtkAwDFSqvHY+XL5qDVBEjeUe+WHkYUg40cAXjusAqgm2hZt29c2wnVrxW25W
|
|
37
|
+
P0meNlzHGFdA2AC5z54iRiqj57dTfBTkHoBczQxcyw6hhzxZQ4e5I5zOKjXXEhZN
|
|
38
|
+
r0tA3YC14CTabKRus/JmZieyZzRgEy2oti64tmLYTqSlAD78pRL40VNoaSYetXLw
|
|
39
|
+
hhNsXCHgWaY6d5bLOc/aIQMAV5oLvZQKvuXAF1IDmhPA+bZbpWipp0zagf1P1H3s
|
|
40
|
+
UzsMdn2KM0ejzgotbtNlj5TcrVwpmvE3ktvUAuA+hi3FkVx1US+2Gsp5x4YOzJ7u
|
|
41
|
+
P1WPk6ShF0JgnJH2ILdj6kttTWwFzH17keSFICWDfH/+kM+k7Y1v3EXMQXE7y0T9
|
|
42
|
+
MjvJskz6d/nv+sQhY04xt64xFMGTnZjlJMzfQNi7zWFLTZnDD0lPowq7l3YiPoTT
|
|
43
|
+
t5Xky83lu0KZsZBo0WlWaDG00gLVdtRgVbcuSWxpi5BdLb1kRab66JptWjxwXQID
|
|
44
|
+
AQABo4HrMIHoMDoGA1UdHwQzMDEwL6AtoCuGKWh0dHBzOi8vcmwtY2Etc2VydmVy
|
|
45
|
+
LnJlZGlzbGFicy5jb20vdjEvY3JsMEYGCCsGAQUFBwEBBDowODA2BggrBgEFBQcw
|
|
46
|
+
AYYqaHR0cHM6Ly9ybC1jYS1zZXJ2ZXIucmVkaXNsYWJzLmNvbS92MS9vY3NwMB0G
|
|
47
|
+
A1UdDgQWBBQHar5OKvQUpP2qWt6mckzToeCOHDAfBgNVHSMEGDAWgBQi42wH6hM4
|
|
48
|
+
L2sujEvLM0/u8lRXTzASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIB
|
|
49
|
+
hjANBgkqhkiG9w0BAQsFAAOCAgEAirEn/iTsAKyhd+pu2W3Z5NjCko4NPU0EYUbr
|
|
50
|
+
AP7+POK2rzjIrJO3nFYQ/LLuC7KCXG+2qwan2SAOGmqWst13Y+WHp44Kae0kaChW
|
|
51
|
+
vcYLXXSoGQGC8QuFSNUdaeg3RbMDYFT04dOkqufeWVccoHVxyTSg9eD8LZuHn5jw
|
|
52
|
+
7QDLiEECBmIJHk5Eeo2TAZrx4Yx6ufSUX5HeVjlAzqwtAqdt99uCJ/EL8bgpWbe+
|
|
53
|
+
XoSpvUv0SEC1I1dCAhCKAvRlIOA6VBcmzg5Am12KzkqTul12/VEFIgzqu0Zy2Jbc
|
|
54
|
+
AUPrYVu/+tOGXQaijy7YgwH8P8n3s7ZeUa1VABJHcxrxYduDDJBLZi+MjheUDaZ1
|
|
55
|
+
jQRHYevI2tlqeSBqdPKG4zBY5lS0GiAlmuze5oENt0P3XboHoZPHiqcK3VECgTVh
|
|
56
|
+
/BkJcuudETSJcZDmQ8YfoKfBzRQNg2sv/hwvUv73Ss51Sco8GEt2lD8uEdib1Q6z
|
|
57
|
+
zDT5lXJowSzOD5ZA9OGDjnSRL+2riNtKWKEqvtEG3VBJoBzu9GoxbAc7wIZLxmli
|
|
58
|
+
iF5a/Zf5X+UXD3s4TMmy6C4QZJpAA2egsSQCnraWO2ULhh7iXMysSkF/nzVfZn43
|
|
59
|
+
iqpaB8++9a37hWq14ZmOv0TJIDz//b2+KC4VFXWQ5W5QC6whsjT+OlG4p5ZYG0jo
|
|
60
|
+
616pxqo=
|
|
61
|
+
-----END CERTIFICATE-----
|
|
62
|
+
-----BEGIN CERTIFICATE-----
|
|
63
|
+
MIIFujCCA6KgAwIBAgIJAJ1aTT1lu2ScMA0GCSqGSIb3DQEBCwUAMGoxCzAJBgNV
|
|
64
|
+
BAYTAlVTMQswCQYDVQQIDAJDQTELMAkGA1UEBwwCQ0ExEjAQBgNVBAoMCVJlZGlz
|
|
65
|
+
TGFiczEtMCsGA1UEAwwkUmVkaXNMYWJzIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9y
|
|
66
|
+
aXR5MB4XDTE4MDIyNTE1MjA0MloXDTM4MDIyMDE1MjA0MlowajELMAkGA1UEBhMC
|
|
67
|
+
VVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJDQTESMBAGA1UECgwJUmVkaXNMYWJz
|
|
68
|
+
MS0wKwYDVQQDDCRSZWRpc0xhYnMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkw
|
|
69
|
+
ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDLEjXy7YrbN5Waau5cd6g1
|
|
70
|
+
G5C2tMmeTpZ0duFAPxNU4oE3RHS5gGiok346fUXuUxbZ6QkuzeN2/2Z+RmRcJhQY
|
|
71
|
+
Dm0ZgdG4x59An1TJfnzKKoWj8ISmoHS/TGNBdFzXV7FYNLBuqZouqePI6ReC6Qhl
|
|
72
|
+
pp45huV32Q3a6IDrrvx7Wo5ZczEQeFNbCeCOQYNDdTmCyEkHqc2AGo8eoIlSTutT
|
|
73
|
+
ULOC7R5gzJVTS0e1hesQ7jmqHjbO+VQS1NAL4/5K6cuTEqUl+XhVhPdLWBXJQ5ag
|
|
74
|
+
54qhX4v+ojLzeU1R/Vc6NjMvVtptWY6JihpgplprN0Yh2556ewcXMeturcKgXfGJ
|
|
75
|
+
xeYzsjzXerEjrVocX5V8BNrg64NlifzTMKNOOv4fVZszq1SIHR8F9ROrqiOdh8iC
|
|
76
|
+
JpUbLpXH9hWCSEO6VRMB2xJoKu3cgl63kF30s77x7wLFMEHiwsQRKxooE1UhgS9K
|
|
77
|
+
2sO4TlQ1eWUvFvHSTVDQDlGQ6zu4qjbOpb3Q8bQwoK+ai2alkXVR4Ltxe9QlgYK3
|
|
78
|
+
StsnPhruzZGA0wbXdpw0bnM+YdlEm5ffSTpNIfgHeaa7Dtb801FtA71ZlH7A6TaI
|
|
79
|
+
SIQuUST9EKmv7xrJyx0W1pGoPOLw5T029aTjnICSLdtV9bLwysrLhIYG5bnPq78B
|
|
80
|
+
cS+jZHFGzD7PUVGQD01nOQIDAQABo2MwYTAdBgNVHQ4EFgQUIuNsB+oTOC9rLoxL
|
|
81
|
+
yzNP7vJUV08wHwYDVR0jBBgwFoAUIuNsB+oTOC9rLoxLyzNP7vJUV08wDwYDVR0T
|
|
82
|
+
AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAHfg
|
|
83
|
+
z5pMNUAKdMzK1aS1EDdK9yKz4qicILz5czSLj1mC7HKDRy8cVADUxEICis++CsCu
|
|
84
|
+
rYOvyCVergHQLREcxPq4rc5Nq1uj6J6649NEeh4WazOOjL4ZfQ1jVznMbGy+fJm3
|
|
85
|
+
3Hoelv6jWRG9iqeJZja7/1s6YC6bWymI/OY1e4wUKeNHAo+Vger7MlHV+RuabaX+
|
|
86
|
+
hSJ8bJAM59NCM7AgMTQpJCncrcdLeceYniGy5Q/qt2b5mJkQVkIdy4TPGGB+AXDJ
|
|
87
|
+
D0q3I/JDRkDUFNFdeW0js7fHdsvCR7O3tJy5zIgEV/o/BCkmJVtuwPYOrw/yOlKj
|
|
88
|
+
TY/U7ATAx9VFF6/vYEOMYSmrZlFX+98L6nJtwDqfLB5VTltqZ4H/KBxGE3IRSt9l
|
|
89
|
+
FXy40U+LnXzhhW+7VBAvyYX8GEXhHkKU8Gqk1xitrqfBXY74xKgyUSTolFSfFVgj
|
|
90
|
+
mcM/X4K45bka+qpkj7Kfv/8D4j6aZekwhN2ly6hhC1SmQ8qjMjpG/mrWOSSHZFmf
|
|
91
|
+
ybu9iD2AYHeIOkshIl6xYIa++Q/00/vs46IzAbQyriOi0XxlSMMVtPx0Q3isp+ji
|
|
92
|
+
n8Mq9eOuxYOEQ4of8twUkUDd528iwGtEdwf0Q01UyT84S62N8AySl1ZBKXJz6W4F
|
|
93
|
+
UhWfa/HQYOAPDdEjNgnVwLI23b8t0TozyCWw7q8h
|
|
94
|
+
-----END CERTIFICATE-----
|
|
95
|
+
|
|
96
|
+
-----BEGIN CERTIFICATE-----
|
|
97
|
+
MIIEjzCCA3egAwIBAgIQe55B/ALCKJDZtdNT8kD6hTANBgkqhkiG9w0BAQsFADBM
|
|
98
|
+
MSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xv
|
|
99
|
+
YmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjAeFw0yMjAxMjYxMjAwMDBaFw0y
|
|
100
|
+
NTAxMjYwMDAwMDBaMFgxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWdu
|
|
101
|
+
IG52LXNhMS4wLAYDVQQDEyVHbG9iYWxTaWduIEF0bGFzIFIzIE9WIFRMUyBDQSAy
|
|
102
|
+
MDIyIFEyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmGmg1LW9b7Lf
|
|
103
|
+
8zDD83yBDTEkt+FOxKJZqF4veWc5KZsQj9HfnUS2e5nj/E+JImlGPsQuoiosLuXD
|
|
104
|
+
BVBNAMcUFa11buFMGMeEMwiTmCXoXRrXQmH0qjpOfKgYc5gHG3BsRGaRrf7VR4eg
|
|
105
|
+
ofNMG9wUBw4/g/TT7+bQJdA4NfE7Y4d5gEryZiBGB/swaX6Jp/8MF4TgUmOWmalK
|
|
106
|
+
dZCKyb4sPGQFRTtElk67F7vU+wdGcrcOx1tDcIB0ncjLPMnaFicagl+daWGsKqTh
|
|
107
|
+
counQb6QJtYHa91KvCfKWocMxQ7OIbB5UARLPmC4CJ1/f8YFm35ebfzAeULYdGXu
|
|
108
|
+
jE9CLor0OwIDAQABo4IBXzCCAVswDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQG
|
|
109
|
+
CCsGAQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQW
|
|
110
|
+
BBSH5Zq7a7B/t95GfJWkDBpA8HHqdjAfBgNVHSMEGDAWgBSP8Et/qC5FJK5NUPpj
|
|
111
|
+
move4t0bvDB7BggrBgEFBQcBAQRvMG0wLgYIKwYBBQUHMAGGImh0dHA6Ly9vY3Nw
|
|
112
|
+
Mi5nbG9iYWxzaWduLmNvbS9yb290cjMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9zZWN1
|
|
113
|
+
cmUuZ2xvYmFsc2lnbi5jb20vY2FjZXJ0L3Jvb3QtcjMuY3J0MDYGA1UdHwQvMC0w
|
|
114
|
+
K6ApoCeGJWh0dHA6Ly9jcmwuZ2xvYmFsc2lnbi5jb20vcm9vdC1yMy5jcmwwIQYD
|
|
115
|
+
VR0gBBowGDAIBgZngQwBAgIwDAYKKwYBBAGgMgoBAjANBgkqhkiG9w0BAQsFAAOC
|
|
116
|
+
AQEAKRic9/f+nmhQU/wz04APZLjgG5OgsuUOyUEZjKVhNGDwxGTvKhyXGGAMW2B/
|
|
117
|
+
3bRi+aElpXwoxu3pL6fkElbX3B0BeS5LoDtxkyiVEBMZ8m+sXbocwlPyxrPbX6mY
|
|
118
|
+
0rVIvnuUeBH8X0L5IwfpNVvKnBIilTbcebfHyXkPezGwz7E1yhUULjJFm2bt0SdX
|
|
119
|
+
y+4X/WeiiYIv+fTVgZZgl+/2MKIsu/qdBJc3f3TvJ8nz+Eax1zgZmww+RSQWeOj3
|
|
120
|
+
15Iw6Z5FX+NwzY/Ab+9PosR5UosSeq+9HhtaxZttXG1nVh+avYPGYddWmiMT90J5
|
|
121
|
+
ZgKnO/Fx2hBgTxhOTMYaD312kg==
|
|
122
|
+
-----END CERTIFICATE-----
|
|
123
|
+
|
|
124
|
+
-----BEGIN CERTIFICATE-----
|
|
125
|
+
MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G
|
|
126
|
+
A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp
|
|
127
|
+
Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4
|
|
128
|
+
MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG
|
|
129
|
+
A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI
|
|
130
|
+
hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8
|
|
131
|
+
RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT
|
|
132
|
+
gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm
|
|
133
|
+
KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd
|
|
134
|
+
QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ
|
|
135
|
+
XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw
|
|
136
|
+
DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o
|
|
137
|
+
LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU
|
|
138
|
+
RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp
|
|
139
|
+
jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK
|
|
140
|
+
6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX
|
|
141
|
+
mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs
|
|
142
|
+
Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH
|
|
143
|
+
WD9f
|
|
144
|
+
-----END CERTIFICATE-----`,FE={RedisCloudFixed:{ca:vw},RedisCloudFlexible:{ca:vw}};bw.default=FE});var p=D((FS)=>{var __dirname="C:\\Users\\offby\\Documents\\Research\\stabilize\\node_modules\\ioredis\\built\\utils";Object.defineProperty(FS,"__esModule",{value:!0});FS.noop=FS.defaults=FS.Debug=FS.getPackageMeta=FS.zipMap=FS.CONNECTION_CLOSED_ERROR_MSG=FS.shuffle=FS.sample=FS.resolveTLSProfile=FS.parseURL=FS.optimizeErrorStack=FS.toArg=FS.convertMapToArray=FS.convertObjectToArray=FS.timeout=FS.packObject=FS.isInt=FS.wrapMultiResult=FS.convertBufferToString=void 0;var WE=j("fs"),zE=j("path"),uw=j("url"),nS=YS();Object.defineProperty(FS,"defaults",{enumerable:!0,get:function(){return nS.defaults}});Object.defineProperty(FS,"noop",{enumerable:!0,get:function(){return nS.noop}});var BE=gw();FS.Debug=BE.default;var VE=pw();function iw(S,w){if(S instanceof Buffer)return S.toString(w);if(Array.isArray(S)){let $=S.length,E=Array($);for(let Y=0;Y<$;++Y)E[Y]=S[Y]instanceof Buffer&&w==="utf8"?S[Y].toString():iw(S[Y],w);return E}return S}FS.convertBufferToString=iw;function HE(S){if(!S)return null;let w=[],$=S.length;for(let E=0;E<$;++E){let Y=S[E];if(Y instanceof Error)w.push([Y]);else w.push([null,Y])}return w}FS.wrapMultiResult=HE;function tw(S){let w=parseFloat(S);return!isNaN(S)&&(w|0)===w}FS.isInt=tw;function UE(S){let w={},$=S.length;for(let E=1;E<$;E+=2)w[S[E-1]]=S[E];return w}FS.packObject=UE;function qE(S,w){let $=null,E=function(){if($)clearTimeout($),$=null,S.apply(this,arguments)};return $=setTimeout(E,w,Error("timeout")),E}FS.timeout=qE;function GE(S){let w=[],$=Object.keys(S);for(let E=0,Y=$.length;E<Y;E++)w.push($[E],S[$[E]]);return w}FS.convertObjectToArray=GE;function RE(S){let w=[],$=0;return S.forEach(function(E,Y){w[$]=Y,w[$+1]=E,$+=2}),w}FS.convertMapToArray=RE;function yE(S){if(S===null||typeof S>"u")return"";return String(S)}FS.toArg=yE;function TE(S,w,$){let E=w.split(`
|
|
145
|
+
`),Y="",J;for(J=1;J<E.length;++J)if(E[J].indexOf($)===-1)break;for(let Q=J;Q<E.length;++Q)Y+=`
|
|
146
|
+
`+E[Q];if(S.stack){let Q=S.stack.indexOf(`
|
|
147
|
+
`);S.stack=S.stack.slice(0,Q)+Y}return S}FS.optimizeErrorStack=TE;function AE(S){if(tw(S))return{port:S};let w=(0,uw.parse)(S,!0,!0);if(!w.slashes&&S[0]!=="/")S="//"+S,w=(0,uw.parse)(S,!0,!0);let $=w.query||{},E={};if(w.auth){let Y=w.auth.indexOf(":");E.username=Y===-1?w.auth:w.auth.slice(0,Y),E.password=Y===-1?"":w.auth.slice(Y+1)}if(w.pathname)if(w.protocol==="redis:"||w.protocol==="rediss:"){if(w.pathname.length>1)E.db=w.pathname.slice(1)}else E.path=w.pathname;if(w.host)E.host=w.hostname;if(w.port)E.port=w.port;if(typeof $.family==="string"){let Y=Number.parseInt($.family,10);if(!Number.isNaN(Y))E.family=Y}return(0,nS.defaults)(E,$),E}FS.parseURL=AE;function DE(S){let w=S===null||S===void 0?void 0:S.tls;if(typeof w==="string")w={profile:w};let $=VE.default[w===null||w===void 0?void 0:w.profile];if($)w=Object.assign({},$,w),delete w.profile,S=Object.assign({},S,{tls:w});return S}FS.resolveTLSProfile=DE;function kE(S,w=0){let $=S.length;if(w>=$)return null;return S[w+Math.floor(Math.random()*($-w))]}FS.sample=kE;function IE(S){let w=S.length;while(w>0){let $=Math.floor(Math.random()*w);w--,[S[w],S[$]]=[S[$],S[w]]}return S}FS.shuffle=IE;FS.CONNECTION_CLOSED_ERROR_MSG="Connection is closed.";function ME(S,w){let $=new Map;return S.forEach((E,Y)=>{$.set(E,w[Y])}),$}FS.zipMap=ME;var O1=null;async function NE(){if(O1)return O1;try{let S=(0,zE.resolve)(__dirname,"..","..","package.json"),w=await WE.promises.readFile(S,"utf8");return O1={version:JSON.parse(w).version},O1}catch(S){return O1={version:"error-fetching-version"},O1}}FS.getPackageMeta=NE});var w1=D((ow)=>{var __dirname="C:\\Users\\offby\\Documents\\Research\\stabilize\\node_modules\\ioredis\\built";Object.defineProperty(ow,"__esModule",{value:!0});var cw=N1(),lE=u1(),dE=Q1(),G1=p();class l{constructor(S,w=[],$={},E){if(this.name=S,this.inTransaction=!1,this.isResolved=!1,this.transformed=!1,this.replyEncoding=$.replyEncoding,this.errorStack=$.errorStack,this.args=w.flat(),this.callback=E,this.initPromise(),$.keyPrefix){let Y=$.keyPrefix instanceof Buffer,J=Y?$.keyPrefix:null;this._iterateKeys((Q)=>{if(Q instanceof Buffer){if(J===null)J=Buffer.from($.keyPrefix);return Buffer.concat([J,Q])}else if(Y)return Buffer.concat([$.keyPrefix,Buffer.from(String(Q))]);return $.keyPrefix+Q})}if($.readOnly)this.isReadOnly=!0}static checkFlag(S,w){return!!this.getFlagMap()[S][w]}static setArgumentTransformer(S,w){this._transformer.argument[S]=w}static setReplyTransformer(S,w){this._transformer.reply[S]=w}static getFlagMap(){if(!this.flagMap)this.flagMap=Object.keys(l.FLAGS).reduce((S,w)=>{return S[w]={},l.FLAGS[w].forEach(($)=>{S[w][$]=!0}),S},{});return this.flagMap}getSlot(){if(typeof this.slot>"u"){let S=this.getKeys()[0];this.slot=S==null?null:lE(S)}return this.slot}getKeys(){return this._iterateKeys()}toWritable(S){let w,$="*"+(this.args.length+1)+`\r
|
|
148
|
+
$`+Buffer.byteLength(this.name)+`\r
|
|
149
|
+
`+this.name+`\r
|
|
150
|
+
`;if(this.bufferMode){let E=new dw;E.push($);for(let Y=0;Y<this.args.length;++Y){let J=this.args[Y];if(J instanceof Buffer)if(J.length===0)E.push(`$0\r
|
|
151
|
+
\r
|
|
152
|
+
`);else E.push("$"+J.length+`\r
|
|
153
|
+
`),E.push(J),E.push(`\r
|
|
154
|
+
`);else E.push("$"+Buffer.byteLength(J)+`\r
|
|
155
|
+
`+J+`\r
|
|
156
|
+
`)}w=E.toBuffer()}else{w=$;for(let E=0;E<this.args.length;++E){let Y=this.args[E];w+="$"+Buffer.byteLength(Y)+`\r
|
|
157
|
+
`+Y+`\r
|
|
158
|
+
`}}return w}stringifyArguments(){for(let S=0;S<this.args.length;++S){let w=this.args[S];if(typeof w==="string");else if(w instanceof Buffer)this.bufferMode=!0;else this.args[S]=(0,G1.toArg)(w)}}transformReply(S){if(this.replyEncoding)S=(0,G1.convertBufferToString)(S,this.replyEncoding);let w=l._transformer.reply[this.name];if(w)S=w(S);return S}setTimeout(S){if(!this._commandTimeoutTimer)this._commandTimeoutTimer=setTimeout(()=>{if(!this.isResolved)this.reject(Error("Command timed out"))},S)}initPromise(){let S=new Promise((w,$)=>{if(!this.transformed){this.transformed=!0;let E=l._transformer.argument[this.name];if(E)this.args=E(this.args);this.stringifyArguments()}if(this.resolve=this._convertValue(w),this.errorStack)this.reject=(E)=>{$((0,G1.optimizeErrorStack)(E,this.errorStack.stack,__dirname))};else this.reject=$});this.promise=(0,dE.default)(S,this.callback)}_iterateKeys(S=(w)=>w){if(typeof this.keys>"u"){if(this.keys=[],(0,cw.exists)(this.name)){let w=(0,cw.getKeyIndexes)(this.name,this.args);for(let $ of w)this.args[$]=S(this.args[$]),this.keys.push(this.args[$])}}return this.keys}_convertValue(S){return(w)=>{try{let $=this._commandTimeoutTimer;if($)clearTimeout($),delete this._commandTimeoutTimer;S(this.transformReply(w)),this.isResolved=!0}catch($){this.reject($)}return this.promise}}}ow.default=l;l.FLAGS={VALID_IN_SUBSCRIBER_MODE:["subscribe","psubscribe","unsubscribe","punsubscribe","ssubscribe","sunsubscribe","ping","quit"],VALID_IN_MONITOR_MODE:["monitor","auth"],ENTER_SUBSCRIBER_MODE:["subscribe","psubscribe","ssubscribe"],EXIT_SUBSCRIBER_MODE:["unsubscribe","punsubscribe","sunsubscribe"],WILL_DISCONNECT:["quit"]};l._transformer={argument:{},reply:{}};var mw=function(S){if(S.length===1){if(S[0]instanceof Map)return(0,G1.convertMapToArray)(S[0]);if(typeof S[0]==="object"&&S[0]!==null)return(0,G1.convertObjectToArray)(S[0])}return S},lw=function(S){if(S.length===2){if(S[1]instanceof Map)return[S[0]].concat((0,G1.convertMapToArray)(S[1]));if(typeof S[1]==="object"&&S[1]!==null)return[S[0]].concat((0,G1.convertObjectToArray)(S[1]))}return S};l.setArgumentTransformer("mset",mw);l.setArgumentTransformer("msetnx",mw);l.setArgumentTransformer("hset",lw);l.setArgumentTransformer("hmset",lw);l.setReplyTransformer("hgetall",function(S){if(Array.isArray(S)){let w={};for(let $=0;$<S.length;$+=2){let E=S[$],Y=S[$+1];if(E in w)Object.defineProperty(w,E,{value:Y,configurable:!0,enumerable:!0,writable:!0});else w[E]=Y}return w}return S});class dw{constructor(){this.length=0,this.items=[]}push(S){this.length+=Buffer.byteLength(S),this.items.push(S)}toBuffer(){let S=Buffer.allocUnsafe(this.length),w=0;for(let $ of this.items){let E=Buffer.byteLength($);Buffer.isBuffer($)?$.copy(S,w):S.write($,w,E),w+=E}return S}}});var sw=D((nw)=>{Object.defineProperty(nw,"__esModule",{value:!0});var nE=H1();class sS extends nE.RedisError{constructor(S,w){super(S);this.lastNodeError=w,Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}nw.default=sS;sS.defaultMessage="Failed to refresh slots cache."});var LS=D((rw)=>{Object.defineProperty(rw,"__esModule",{value:!0});var aE=j("stream");class aw extends aE.Readable{constructor(S){super(S);this.opt=S,this._redisCursor="0",this._redisDrained=!1}_read(){if(this._redisDrained){this.push(null);return}let S=[this._redisCursor];if(this.opt.key)S.unshift(this.opt.key);if(this.opt.match)S.push("MATCH",this.opt.match);if(this.opt.type)S.push("TYPE",this.opt.type);if(this.opt.count)S.push("COUNT",String(this.opt.count));if(this.opt.noValues)S.push("NOVALUES");this.opt.redis[this.opt.command](S,(w,$)=>{if(w){this.emit("error",w);return}if(this._redisCursor=$[0]instanceof Buffer?$[0].toString():$[0],this._redisCursor==="0")this._redisDrained=!0;this.push($[1])})}close(){this._redisDrained=!0}}rw.default=aw});var X3=D((Y3)=>{Object.defineProperty(Y3,"__esModule",{value:!0});Y3.executeWithAutoPipelining=Y3.getFirstValueInFlattenedArray=Y3.shouldUseAutoPipelining=Y3.notAllowedAutoPipelineCommands=Y3.kCallbacks=Y3.kExec=void 0;var S3=YS(),eE=u1(),ew=Q1();Y3.kExec=Symbol("exec");Y3.kCallbacks=Symbol("callbacks");Y3.notAllowedAutoPipelineCommands=["auth","info","script","quit","cluster","pipeline","multi","subscribe","psubscribe","unsubscribe","unpsubscribe","select"];function w3(S,w){if(S._runningAutoPipelines.has(w))return;if(!S._autoPipelines.has(w))return;S._runningAutoPipelines.add(w);let $=S._autoPipelines.get(w);S._autoPipelines.delete(w);let E=$[Y3.kCallbacks];$[Y3.kCallbacks]=null,$.exec(function(Y,J){if(S._runningAutoPipelines.delete(w),Y)for(let Q=0;Q<E.length;Q++)process.nextTick(E[Q],Y);else for(let Q=0;Q<E.length;Q++)process.nextTick(E[Q],...J[Q]);if(S._autoPipelines.has(w))w3(S,w)})}function S6(S,w,$){return w&&S.options.enableAutoPipelining&&!S.isPipeline&&!Y3.notAllowedAutoPipelineCommands.includes($)&&!S.options.autoPipeliningIgnoredCommands.includes($)}Y3.shouldUseAutoPipelining=S6;function $3(S){for(let w=0;w<S.length;w++){let $=S[w];if(typeof $==="string")return $;else if(Array.isArray($)||(0,S3.isArguments)($)){if($.length===0)continue;return $[0]}let E=[$].flat();if(E.length>0)return E[0]}return}Y3.getFirstValueInFlattenedArray=$3;function E3(S,w,$,E,Y){if(S.isCluster&&!S.slots.length){if(S.status==="wait")S.connect().catch(S3.noop);return(0,ew.default)(new Promise(function(B,z){S.delayUntilReady((W)=>{if(W){z(W);return}E3(S,w,$,E,null).then(B,z)})}),Y)}let J=S.options.keyPrefix||"",Q=S.isCluster?S.slots[eE(`${J}${$3(E)}`)].join(","):"main";if(!S._autoPipelines.has(Q)){let B=S.pipeline();B[Y3.kExec]=!1,B[Y3.kCallbacks]=[],S._autoPipelines.set(Q,B)}let X=S._autoPipelines.get(Q);if(!X[Y3.kExec])X[Y3.kExec]=!0,setImmediate(w3,S,Q);let Z=new Promise(function(B,z){if(X[Y3.kCallbacks].push(function(W,H){if(W){z(W);return}B(H)}),w==="call")E.unshift($);X[w](...E)});return(0,ew.default)(Z,Y)}Y3.executeWithAutoPipelining=E3});var L3=D((F3)=>{Object.defineProperty(F3,"__esModule",{value:!0});var E6=j("crypto"),Y6=w1(),J6=Q1();class Z3{constructor(S,w=null,$="",E=!1){this.lua=S,this.numberOfKeys=w,this.keyPrefix=$,this.readOnly=E,this.sha=(0,E6.createHash)("sha1").update(S).digest("hex");let Y=this.sha,J=new WeakSet;this.Command=class extends Y6.default{toWritable(X){let Z=this.reject;if(this.reject=(B)=>{if(B.message.indexOf("NOSCRIPT")!==-1)J.delete(X);Z.call(this,B)},!J.has(X))J.add(X),this.name="eval",this.args[0]=S;else if(this.name==="eval")this.name="evalsha",this.args[0]=Y;return super.toWritable(X)}}}execute(S,w,$,E){if(typeof this.numberOfKeys==="number")w.unshift(this.numberOfKeys);if(this.keyPrefix)$.keyPrefix=this.keyPrefix;if(this.readOnly)$.readOnly=!0;let Y=new this.Command("evalsha",[this.sha,...w],$);return Y.promise=Y.promise.catch((J)=>{if(J.message.indexOf("NOSCRIPT")===-1)throw J;let Q=new this.Command("evalsha",[this.sha,...w],$);return(S.isPipeline?S.redis:S).sendCommand(Q)}),(0,J6.default)(Y.promise,E),S.sendCommand(Y)}}F3.default=Z3});var BS=D((z3)=>{Object.defineProperty(z3,"__esModule",{value:!0});var X6=N1(),zS=X3(),Z6=w1(),F6=L3();class F1{constructor(){this.options={},this.scriptsSet={},this.addedBuiltinSet=new Set}getBuiltinCommands(){return aS.slice(0)}createBuiltinCommand(S){return{string:Z1(null,S,"utf8"),buffer:Z1(null,S,null)}}addBuiltinCommand(S){this.addedBuiltinSet.add(S),this[S]=Z1(S,S,"utf8"),this[S+"Buffer"]=Z1(S+"Buffer",S,null)}defineCommand(S,w){let $=new F6.default(w.lua,w.numberOfKeys,this.options.keyPrefix,w.readOnly);this.scriptsSet[S]=$,this[S]=W3(S,S,$,"utf8"),this[S+"Buffer"]=W3(S+"Buffer",S,$,null)}sendCommand(S,w,$){throw Error('"sendCommand" is not implemented')}}var aS=X6.list.filter((S)=>S!=="monitor");aS.push("sentinel");aS.forEach(function(S){F1.prototype[S]=Z1(S,S,"utf8"),F1.prototype[S+"Buffer"]=Z1(S+"Buffer",S,null)});F1.prototype.call=Z1("call","utf8");F1.prototype.callBuffer=Z1("callBuffer",null);F1.prototype.send_command=F1.prototype.call;function Z1(S,w,$){if(typeof $>"u")$=w,w=null;return function(...E){let Y=w||E.shift(),J=E[E.length-1];if(typeof J==="function")E.pop();else J=void 0;let Q={errorStack:this.options.showFriendlyErrorStack?Error():void 0,keyPrefix:this.options.keyPrefix,replyEncoding:$};if(!(0,zS.shouldUseAutoPipelining)(this,S,Y))return this.sendCommand(new Z6.default(Y,E,Q,J));return(0,zS.executeWithAutoPipelining)(this,S,Y,E,J)}}function W3(S,w,$,E){return function(...Y){let J=typeof Y[Y.length-1]==="function"?Y.pop():void 0,Q={replyEncoding:E};if(this.options.showFriendlyErrorStack)Q.errorStack=Error();if(!(0,zS.shouldUseAutoPipelining)(this,S,w))return $.execute(this,Y,Q,J);return(0,zS.executeWithAutoPipelining)(this,S,w,Y,J)}}z3.default=F1});var eS=D((U3)=>{Object.defineProperty(U3,"__esModule",{value:!0});var rS=u1(),B3=N1(),V3=Q1(),W6=j("util"),z6=w1(),B6=p(),V6=BS();function H6(S,w){let $=rS(w[0]),E=S._groupsBySlot[$];for(let Y=1;Y<w.length;Y++)if(S._groupsBySlot[rS(w[Y])]!==E)return-1;return $}class R1 extends V6.default{constructor(S){super();this.redis=S,this.isPipeline=!0,this.replyPending=0,this._queue=[],this._result=[],this._transactions=0,this._shaToScript={},this.isCluster=this.redis.constructor.name==="Cluster"||this.redis.isCluster,this.options=S.options,Object.keys(S.scriptsSet).forEach(($)=>{let E=S.scriptsSet[$];this._shaToScript[E.sha]=E,this[$]=S[$],this[$+"Buffer"]=S[$+"Buffer"]}),S.addedBuiltinSet.forEach(($)=>{this[$]=S[$],this[$+"Buffer"]=S[$+"Buffer"]}),this.promise=new Promise(($,E)=>{this.resolve=$,this.reject=E});let w=this;Object.defineProperty(this,"length",{get:function(){return w._queue.length}})}fillResult(S,w){if(this._queue[w].name==="exec"&&Array.isArray(S[1])){let E=S[1].length;for(let Y=0;Y<E;Y++){if(S[1][Y]instanceof Error)continue;let J=this._queue[w-(E-Y)];try{S[1][Y]=J.transformReply(S[1][Y])}catch(Q){S[1][Y]=Q}}}if(this._result[w]=S,--this.replyPending)return;if(this.isCluster){let E=!0,Y;for(let J=0;J<this._result.length;++J){let Q=this._result[J][0],X=this._queue[J];if(Q){if(X.name==="exec"&&Q.message==="EXECABORT Transaction discarded because of previous errors.")continue;if(!Y)Y={name:Q.name,message:Q.message};else if(Y.name!==Q.name||Y.message!==Q.message){E=!1;break}}else if(!X.inTransaction){if(!((0,B3.exists)(X.name)&&(0,B3.hasFlag)(X.name,"readonly"))){E=!1;break}}}if(Y&&E){let J=this,Q=Y.message.split(" "),X=this._queue,Z=!1;this._queue=[];for(let H=0;H<X.length;++H){if(Q[0]==="ASK"&&!Z&&X[H].name!=="asking"&&(!X[H-1]||X[H-1].name!=="asking")){let G=new z6.default("asking");G.ignore=!0,this.sendCommand(G)}X[H].initPromise(),this.sendCommand(X[H]),Z=X[H].inTransaction}let B=!0;if(typeof this.leftRedirections>"u")this.leftRedirections={};let z=function(){J.exec()},W=this.redis;if(W.handleError(Y,this.leftRedirections,{moved:function(H,G){J.preferKey=G,W.slots[Q[1]]=[G],W._groupsBySlot[Q[1]]=W._groupsIds[W.slots[Q[1]].join(";")],W.refreshSlotsCache(),J.exec()},ask:function(H,G){J.preferKey=G,J.exec()},tryagain:z,clusterDown:z,connectionClosed:z,maxRedirections:()=>{B=!1},defaults:()=>{B=!1}}),B)return}}let $=0;for(let E=0;E<this._queue.length-$;++E){if(this._queue[E+$].ignore)$+=1;this._result[E]=this._result[E+$]}this.resolve(this._result.slice(0,this._result.length-$))}sendCommand(S){if(this._transactions>0)S.inTransaction=!0;let w=this._queue.length;return S.pipelineIndex=w,S.promise.then(($)=>{this.fillResult([null,$],w)}).catch(($)=>{this.fillResult([$],w)}),this._queue.push(S),this}addBatch(S){let w,$,E;for(let Y=0;Y<S.length;++Y)w=S[Y],$=w[0],E=w.slice(1),this[$].apply(this,E);return this}}U3.default=R1;var U6=R1.prototype.multi;R1.prototype.multi=function(){return this._transactions+=1,U6.apply(this,arguments)};var H3=R1.prototype.execBuffer;R1.prototype.execBuffer=(0,W6.deprecate)(function(){if(this._transactions>0)this._transactions-=1;return H3.apply(this,arguments)},"Pipeline#execBuffer: Use Pipeline#exec instead");R1.prototype.exec=function(S){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(B6.noop);if(S&&!this.nodeifiedPromise)this.nodeifiedPromise=!0,(0,V3.default)(this.promise,S);return this.redis.delayUntilReady((Y)=>{if(Y){this.reject(Y);return}this.exec(S)}),this.promise}if(this._transactions>0)return this._transactions-=1,H3.apply(this,arguments);if(!this.nodeifiedPromise)this.nodeifiedPromise=!0,(0,V3.default)(this.promise,S);if(!this._queue.length)this.resolve([]);let w;if(this.isCluster){let Y=[];for(let J=0;J<this._queue.length;J++){let Q=this._queue[J].getKeys();if(Q.length)Y.push(Q[0]);if(Q.length&&rS.generateMulti(Q)<0)return this.reject(Error("All the keys in a pipeline command should belong to the same slot")),this.promise}if(Y.length){if(w=H6(this.redis,Y),w<0)return this.reject(Error("All keys in the pipeline should belong to the same slots allocation group")),this.promise}else w=Math.random()*16384|0}let $=this;return E(),this.promise;function E(){let Y=$.replyPending=$._queue.length,J;if($.isCluster)J={slot:w,redis:$.redis.connectionPool.nodes.all[$.preferKey]};let Q="",X,Z={isPipeline:!0,destination:$.isCluster?J:{redis:$.redis},write(B){if(typeof B!=="string"){if(!X)X=[];if(Q)X.push(Buffer.from(Q,"utf8")),Q="";X.push(B)}else Q+=B;if(!--Y){if(X){if(Q)X.push(Buffer.from(Q,"utf8"));Z.destination.redis.stream.write(Buffer.concat(X))}else Z.destination.redis.stream.write(Q);Y=$._queue.length,Q="",X=void 0}}};for(let B=0;B<$._queue.length;++B)$.redis.sendCommand($._queue[B],Z,J);return $.promise}}});var $0=D((G3)=>{Object.defineProperty(G3,"__esModule",{value:!0});G3.addTransactionSupport=void 0;var S0=p(),w0=Q1(),q3=eS();function G6(S){S.pipeline=function(E){let Y=new q3.default(this);if(Array.isArray(E))Y.addBatch(E);return Y};let{multi:w}=S;S.multi=function(E,Y){if(typeof Y>"u"&&!Array.isArray(E))Y=E,E=null;if(Y&&Y.pipeline===!1)return w.call(this);let J=new q3.default(this);if(J.multi(),Array.isArray(E))J.addBatch(E);let Q=J.exec;J.exec=function(Z){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(S0.noop);return(0,w0.default)(new Promise((z,W)=>{this.redis.delayUntilReady((H)=>{if(H){W(H);return}this.exec(J).then(z,W)})}),Z)}if(this._transactions>0)Q.call(J);if(this.nodeifiedPromise)return Q.call(J);let B=Q.call(J);return(0,w0.default)(B.then(function(z){let W=z[z.length-1];if(typeof W>"u")throw Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.");if(W[0]){W[0].previousErrors=[];for(let H=0;H<z.length-1;++H)if(z[H][0])W[0].previousErrors.push(z[H][0]);throw W[0]}return(0,S0.wrapMultiResult)(W[1])}),Z)};let{execBuffer:X}=J;return J.execBuffer=function(Z){if(this._transactions>0)X.call(J);return J.exec(Z)},J};let{exec:$}=S;S.exec=function(E){return(0,w0.default)($.call(this).then(function(Y){if(Array.isArray(Y))Y=(0,S0.wrapMultiResult)(Y);return Y}),E)}}G3.addTransactionSupport=G6});var E0=D((y3)=>{Object.defineProperty(y3,"__esModule",{value:!0});function R6(S,w){Object.getOwnPropertyNames(w.prototype).forEach(($)=>{Object.defineProperty(S.prototype,$,Object.getOwnPropertyDescriptor(w.prototype,$))})}y3.default=R6});var k3=D((A3)=>{Object.defineProperty(A3,"__esModule",{value:!0});A3.DEFAULT_CLUSTER_OPTIONS=void 0;var T3=j("dns");A3.DEFAULT_CLUSTER_OPTIONS={clusterRetryStrategy:(S)=>Math.min(100+S*2,2000),enableOfflineQueue:!0,enableReadyCheck:!0,scaleReads:"master",maxRedirections:16,retryDelayOnMoved:0,retryDelayOnFailover:100,retryDelayOnClusterDown:100,retryDelayOnTryAgain:100,slotsRefreshTimeout:1000,useSRVRecords:!1,resolveSrv:T3.resolveSrv,dnsLookup:T3.lookup,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],shardedSubscribers:!1}});var l1=D((M3)=>{Object.defineProperty(M3,"__esModule",{value:!0});M3.getConnectionName=M3.weightSrvRecords=M3.groupSrvRecords=M3.getUniqueHostnamesFromOptions=M3.normalizeNodeOptions=M3.nodeKeyToRedisOptions=M3.getNodeKey=void 0;var I3=p(),T6=j("net");function A6(S){return S.port=S.port||6379,S.host=S.host||"127.0.0.1",S.host+":"+S.port}M3.getNodeKey=A6;function D6(S){let w=S.lastIndexOf(":");if(w===-1)throw Error(`Invalid node key ${S}`);return{host:S.slice(0,w),port:Number(S.slice(w+1))}}M3.nodeKeyToRedisOptions=D6;function k6(S){return S.map((w)=>{let $={};if(typeof w==="object")Object.assign($,w);else if(typeof w==="string")Object.assign($,(0,I3.parseURL)(w));else if(typeof w==="number")$.port=w;else throw Error("Invalid argument "+w);if(typeof $.port==="string")$.port=parseInt($.port,10);if(delete $.db,!$.port)$.port=6379;if(!$.host)$.host="127.0.0.1";return(0,I3.resolveTLSProfile)($)})}M3.normalizeNodeOptions=k6;function I6(S){let w={};return S.forEach(($)=>{w[$.host]=!0}),Object.keys(w).filter(($)=>!(0,T6.isIP)($))}M3.getUniqueHostnamesFromOptions=I6;function M6(S){let w={};for(let $ of S)if(!w.hasOwnProperty($.priority))w[$.priority]={totalWeight:$.weight,records:[$]};else w[$.priority].totalWeight+=$.weight,w[$.priority].records.push($);return w}M3.groupSrvRecords=M6;function N6(S){if(S.records.length===1)return S.totalWeight=0,S.records.shift();let w=Math.floor(Math.random()*(S.totalWeight+S.records.length)),$=0;for(let[E,Y]of S.records.entries())if($+=1+Y.weight,$>w)return S.totalWeight-=Y.weight,S.records.splice(E,1),Y}M3.weightSrvRecords=N6;function P6(S,w){let $=`ioredis-cluster(${S})`;return w?`${$}:${w}`:$}M3.getConnectionName=P6});var J0=D((j3)=>{Object.defineProperty(j3,"__esModule",{value:!0});var P3=l1(),Y0=p(),f6=L1(),e=(0,Y0.Debug)("cluster:subscriber");class C3{constructor(S,w,$=!1){this.connectionPool=S,this.emitter=w,this.isSharded=$,this.started=!1,this.subscriber=null,this.slotRange=[],this.onSubscriberEnd=()=>{if(!this.started){e("subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.");return}e("subscriber has disconnected, selecting a new one..."),this.selectSubscriber()},this.connectionPool.on("-node",(E,Y)=>{if(!this.started||!this.subscriber)return;if((0,P3.getNodeKey)(this.subscriber.options)===Y)e("subscriber has left, selecting a new one..."),this.selectSubscriber()}),this.connectionPool.on("+node",()=>{if(!this.started||this.subscriber)return;e("a new node is discovered and there is no subscriber, selecting a new one..."),this.selectSubscriber()})}getInstance(){return this.subscriber}associateSlotRange(S){if(this.isSharded)this.slotRange=S;return this.slotRange}start(){this.started=!0,this.selectSubscriber(),e("started")}stop(){if(this.started=!1,this.subscriber)this.subscriber.disconnect(),this.subscriber=null}isStarted(){return this.started}selectSubscriber(){let S=this.lastActiveSubscriber;if(S)S.off("end",this.onSubscriberEnd),S.disconnect();if(this.subscriber)this.subscriber.off("end",this.onSubscriberEnd),this.subscriber.disconnect();let w=(0,Y0.sample)(this.connectionPool.getNodes());if(!w){e("selecting subscriber failed since there is no node discovered in the cluster yet"),this.subscriber=null;return}let{options:$}=w;e("selected a subscriber %s:%s",$.host,$.port);let E="subscriber";if(this.isSharded)E="ssubscriber";this.subscriber=new f6.default({port:$.port,host:$.host,username:$.username,password:$.password,enableReadyCheck:!0,connectionName:(0,P3.getConnectionName)(E,$.connectionName),lazyConnect:!0,tls:$.tls,retryStrategy:null}),this.subscriber.on("error",Y0.noop),this.subscriber.on("moved",()=>{this.emitter.emit("forceRefresh")}),this.subscriber.once("end",this.onSubscriberEnd);let Y={subscribe:[],psubscribe:[],ssubscribe:[]};if(S){let J=S.condition||S.prevCondition;if(J&&J.subscriber)Y.subscribe=J.subscriber.channels("subscribe"),Y.psubscribe=J.subscriber.channels("psubscribe"),Y.ssubscribe=J.subscriber.channels("ssubscribe")}if(Y.subscribe.length||Y.psubscribe.length||Y.ssubscribe.length){let J=0;for(let Q of["subscribe","psubscribe","ssubscribe"]){let X=Y[Q];if(X.length==0)continue;if(e("%s %d channels",Q,X.length),Q==="ssubscribe")for(let Z of X)J+=1,this.subscriber[Q](Z).then(()=>{if(!--J)this.lastActiveSubscriber=this.subscriber}).catch(()=>{e("failed to ssubscribe to channel: %s",Z)});else J+=1,this.subscriber[Q](X).then(()=>{if(!--J)this.lastActiveSubscriber=this.subscriber}).catch(()=>{e("failed to %s %d channels",Q,X.length)})}}else this.lastActiveSubscriber=this.subscriber;for(let J of["message","messageBuffer"])this.subscriber.on(J,(Q,X)=>{this.emitter.emit(J,Q,X)});for(let J of["pmessage","pmessageBuffer"])this.subscriber.on(J,(Q,X,Z)=>{this.emitter.emit(J,Q,X,Z)});if(this.isSharded==!0)for(let J of["smessage","smessageBuffer"])this.subscriber.on(J,(Q,X)=>{this.emitter.emit(J,Q,X)})}}j3.default=C3});var X0=D((x3)=>{Object.defineProperty(x3,"__esModule",{value:!0});var g6=j("events"),VS=p(),Q0=l1(),v6=L1(),d1=(0,VS.Debug)("cluster:connectionPool");class h3 extends g6.EventEmitter{constructor(S){super();this.redisOptions=S,this.nodes={all:{},master:{},slave:{}},this.specifiedOptions={}}getNodes(S="all"){let w=this.nodes[S];return Object.keys(w).map(($)=>w[$])}getInstanceByKey(S){return this.nodes.all[S]}getSampleInstance(S){let w=Object.keys(this.nodes[S]),$=(0,VS.sample)(w);return this.nodes[S][$]}addMasterNode(S){let w=(0,Q0.getNodeKey)(S.options),$=this.createRedisFromOptions(S,S.options.readOnly);if(!S.options.readOnly)return this.nodes.all[w]=$,this.nodes.master[w]=$,!0;return!1}createRedisFromOptions(S,w){return new v6.default((0,VS.defaults)({retryStrategy:null,enableOfflineQueue:!0,readOnly:w},S,this.redisOptions,{lazyConnect:!0}))}findOrCreate(S,w=!1){let $=(0,Q0.getNodeKey)(S);if(w=Boolean(w),this.specifiedOptions[$])Object.assign(S,this.specifiedOptions[$]);else this.specifiedOptions[$]=S;let E;if(this.nodes.all[$]){if(E=this.nodes.all[$],E.options.readOnly!==w)if(E.options.readOnly=w,d1("Change role of %s to %s",$,w?"slave":"master"),E[w?"readonly":"readwrite"]().catch(VS.noop),w)delete this.nodes.master[$],this.nodes.slave[$]=E;else delete this.nodes.slave[$],this.nodes.master[$]=E}else d1("Connecting to %s as %s",$,w?"slave":"master"),E=this.createRedisFromOptions(S,w),this.nodes.all[$]=E,this.nodes[w?"slave":"master"][$]=E,E.once("end",()=>{if(this.removeNode($),this.emit("-node",E,$),!Object.keys(this.nodes.all).length)this.emit("drain")}),this.emit("+node",E,$),E.on("error",function(Y){this.emit("nodeError",Y,$)});return E}reset(S){d1("Reset with %O",S);let w={};S.forEach(($)=>{let E=(0,Q0.getNodeKey)($);if(!($.readOnly&&w[E]))w[E]=$}),Object.keys(this.nodes.all).forEach(($)=>{if(!w[$])d1("Disconnect %s because the node does not hold any slot",$),this.nodes.all[$].disconnect(),this.removeNode($)}),Object.keys(w).forEach(($)=>{let E=w[$];this.findOrCreate(E,E.readOnly)})}removeNode(S){let{nodes:w}=this;if(w.all[S])d1("Remove %s from the pool",S),delete w.all[S];delete w.master[S],delete w.slave[S]}}x3.default=h3});var HS=D((DJ,O3)=>{function x(S,$){var $=$||{};if(this._capacity=$.capacity,this._head=0,this._tail=0,Array.isArray(S))this._fromArray(S);else this._capacityMask=3,this._list=[,,,,]}x.prototype.peekAt=function(w){var $=w;if($!==($|0))return;var E=this.size();if($>=E||$<-E)return;if($<0)$+=E;return $=this._head+$&this._capacityMask,this._list[$]};x.prototype.get=function(w){return this.peekAt(w)};x.prototype.peek=function(){if(this._head===this._tail)return;return this._list[this._head]};x.prototype.peekFront=function(){return this.peek()};x.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(x.prototype,"length",{get:function(){return this.size()}});x.prototype.size=function(){if(this._head===this._tail)return 0;if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};x.prototype.unshift=function(w){if(arguments.length===0)return this.size();var $=this._list.length;if(this._head=this._head-1+$&this._capacityMask,this._list[this._head]=w,this._tail===this._head)this._growArray();if(this._capacity&&this.size()>this._capacity)this.pop();if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};x.prototype.shift=function(){var w=this._head;if(w===this._tail)return;var $=this._list[w];if(this._list[w]=void 0,this._head=w+1&this._capacityMask,w<2&&this._tail>1e4&&this._tail<=this._list.length>>>2)this._shrinkArray();return $};x.prototype.push=function(w){if(arguments.length===0)return this.size();var $=this._tail;if(this._list[$]=w,this._tail=$+1&this._capacityMask,this._tail===this._head)this._growArray();if(this._capacity&&this.size()>this._capacity)this.shift();if(this._head<this._tail)return this._tail-this._head;else return this._capacityMask+1-(this._head-this._tail)};x.prototype.pop=function(){var w=this._tail;if(w===this._head)return;var $=this._list.length;this._tail=w-1+$&this._capacityMask;var E=this._list[this._tail];if(this._list[this._tail]=void 0,this._head<2&&w>1e4&&w<=$>>>2)this._shrinkArray();return E};x.prototype.removeOne=function(w){var $=w;if($!==($|0))return;if(this._head===this._tail)return;var E=this.size(),Y=this._list.length;if($>=E||$<-E)return;if($<0)$+=E;$=this._head+$&this._capacityMask;var J=this._list[$],Q;if(w<E/2){for(Q=w;Q>0;Q--)this._list[$]=this._list[$=$-1+Y&this._capacityMask];this._list[$]=void 0,this._head=this._head+1+Y&this._capacityMask}else{for(Q=E-1-w;Q>0;Q--)this._list[$]=this._list[$=$+1+Y&this._capacityMask];this._list[$]=void 0,this._tail=this._tail-1+Y&this._capacityMask}return J};x.prototype.remove=function(w,$){var E=w,Y,J=$;if(E!==(E|0))return;if(this._head===this._tail)return;var Q=this.size(),X=this._list.length;if(E>=Q||E<-Q||$<1)return;if(E<0)E+=Q;if($===1||!$)return Y=[,],Y[0]=this.removeOne(E),Y;if(E===0&&E+$>=Q)return Y=this.toArray(),this.clear(),Y;if(E+$>Q)$=Q-E;var Z;Y=Array($);for(Z=0;Z<$;Z++)Y[Z]=this._list[this._head+E+Z&this._capacityMask];if(E=this._head+E&this._capacityMask,w+$===Q){this._tail=this._tail-$+X&this._capacityMask;for(Z=$;Z>0;Z--)this._list[E=E+1+X&this._capacityMask]=void 0;return Y}if(w===0){this._head=this._head+$+X&this._capacityMask;for(Z=$-1;Z>0;Z--)this._list[E=E+1+X&this._capacityMask]=void 0;return Y}if(E<Q/2){this._head=this._head+w+$+X&this._capacityMask;for(Z=w;Z>0;Z--)this.unshift(this._list[E=E-1+X&this._capacityMask]);E=this._head-1+X&this._capacityMask;while(J>0)this._list[E=E-1+X&this._capacityMask]=void 0,J--;if(w<0)this._tail=E}else{this._tail=E,E=E+$+X&this._capacityMask;for(Z=Q-($+w);Z>0;Z--)this.push(this._list[E++]);E=this._tail;while(J>0)this._list[E=E+1+X&this._capacityMask]=void 0,J--}if(this._head<2&&this._tail>1e4&&this._tail<=X>>>2)this._shrinkArray();return Y};x.prototype.splice=function(w,$){var E=w;if(E!==(E|0))return;var Y=this.size();if(E<0)E+=Y;if(E>Y)return;if(arguments.length>2){var J,Q,X,Z=arguments.length,B=this._list.length,z=2;if(!Y||E<Y/2){Q=Array(E);for(J=0;J<E;J++)Q[J]=this._list[this._head+J&this._capacityMask];if($===0){if(X=[],E>0)this._head=this._head+E+B&this._capacityMask}else X=this.remove(E,$),this._head=this._head+E+B&this._capacityMask;while(Z>z)this.unshift(arguments[--Z]);for(J=E;J>0;J--)this.unshift(Q[J-1])}else{Q=Array(Y-(E+$));var W=Q.length;for(J=0;J<W;J++)Q[J]=this._list[this._head+E+$+J&this._capacityMask];if($===0){if(X=[],E!=Y)this._tail=this._head+E+B&this._capacityMask}else X=this.remove(E,$),this._tail=this._tail-W+B&this._capacityMask;while(z<Z)this.push(arguments[z++]);for(J=0;J<W;J++)this.push(Q[J])}return X}else return this.remove(E,$)};x.prototype.clear=function(){this._list=Array(this._list.length),this._head=0,this._tail=0};x.prototype.isEmpty=function(){return this._head===this._tail};x.prototype.toArray=function(){return this._copyArray(!1)};x.prototype._fromArray=function(w){var $=w.length,E=this._nextPowerOf2($);this._list=Array(E),this._capacityMask=E-1,this._tail=$;for(var Y=0;Y<$;Y++)this._list[Y]=w[Y]};x.prototype._copyArray=function(w,$){var E=this._list,Y=E.length,J=this.length;if($=$|J,$==J&&this._head<this._tail)return this._list.slice(this._head,this._tail);var Q=Array($),X=0,Z;if(w||this._head>this._tail){for(Z=this._head;Z<Y;Z++)Q[X++]=E[Z];for(Z=0;Z<this._tail;Z++)Q[X++]=E[Z]}else for(Z=this._head;Z<this._tail;Z++)Q[X++]=E[Z];return Q};x.prototype._growArray=function(){if(this._head!=0){var w=this._copyArray(!0,this._list.length<<1);this._tail=this._list.length,this._head=0,this._list=w}else this._tail=this._list.length,this._list.length<<=1;this._capacityMask=this._capacityMask<<1|1};x.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};x.prototype._nextPowerOf2=function(w){var $=Math.log(w)/Math.log(2),E=1<<$+1;return Math.max(E,4)};O3.exports=x});var _3=D((f3)=>{Object.defineProperty(f3,"__esModule",{value:!0});var p6=p(),u6=HS(),i6=(0,p6.Debug)("delayqueue");class K3{constructor(){this.queues={},this.timeouts={}}push(S,w,$){let E=$.callback||process.nextTick;if(!this.queues[S])this.queues[S]=new u6;if(this.queues[S].push(w),!this.timeouts[S])this.timeouts[S]=setTimeout(()=>{E(()=>{this.timeouts[S]=null,this.execute(S)})},$.timeout)}execute(S){let w=this.queues[S];if(!w)return;let{length:$}=w;if(!$)return;i6("send %d commands in %s queue",$,S),this.queues[S]=null;while(w.length>0)w.shift()()}}f3.default=K3});var u3=D((p3)=>{Object.defineProperty(p3,"__esModule",{value:!0});var c6=p(),m6=J0(),l6=X0(),g3=l1(),US=u1(),v3=(0,c6.Debug)("cluster:subscriberGroup");class b3{constructor(S,w){this.cluster=S,this.shardedSubscribers=new Map,this.clusterSlots=[],this.subscriberToSlotsIndex=new Map,this.channels=new Map,S.on("+node",($)=>{this._addSubscriber($)}),S.on("-node",($)=>{this._removeSubscriber($)}),S.on("refresh",()=>{this._refreshSlots(S)}),S.on("forceRefresh",()=>{w()})}getResponsibleSubscriber(S){let w=this.clusterSlots[S][0];return this.shardedSubscribers.get(w)}addChannels(S){let w=US(S[0]);S.forEach((E)=>{if(US(E)!=w)return-1});let $=this.channels.get(w);if(!$)this.channels.set(w,S);else this.channels.set(w,$.concat(S));return[...this.channels.values()].flatMap((E)=>E).length}removeChannels(S){let w=US(S[0]);S.forEach((E)=>{if(US(E)!=w)return-1});let $=this.channels.get(w);if($){let E=$.filter((Y)=>!S.includes(Y));this.channels.set(w,E)}return[...this.channels.values()].flatMap((E)=>E).length}stop(){for(let S of this.shardedSubscribers.values())S.stop()}start(){for(let S of this.shardedSubscribers.values())if(!S.isStarted())S.start()}_addSubscriber(S){let w=new l6.default(S.options);if(w.addMasterNode(S)){let $=new m6.default(w,this.cluster,!0),E=(0,g3.getNodeKey)(S.options);return this.shardedSubscribers.set(E,$),$.start(),this._resubscribe(),this.cluster.emit("+subscriber"),$}return null}_removeSubscriber(S){let w=(0,g3.getNodeKey)(S.options),$=this.shardedSubscribers.get(w);if($)$.stop(),this.shardedSubscribers.delete(w),this._resubscribe(),this.cluster.emit("-subscriber");return this.shardedSubscribers}_refreshSlots(S){if(this._slotsAreEqual(S.slots))v3("Nothing to refresh because the new cluster map is equal to the previous one.");else{v3("Refreshing the slots of the subscriber group."),this.subscriberToSlotsIndex=new Map;for(let w=0;w<S.slots.length;w++){let $=S.slots[w][0];if(!this.subscriberToSlotsIndex.has($))this.subscriberToSlotsIndex.set($,[]);this.subscriberToSlotsIndex.get($).push(Number(w))}return this._resubscribe(),this.clusterSlots=JSON.parse(JSON.stringify(S.slots)),this.cluster.emit("subscribersReady"),!0}return!1}_resubscribe(){if(this.shardedSubscribers)this.shardedSubscribers.forEach((S,w)=>{let $=this.subscriberToSlotsIndex.get(w);if($)S.associateSlotRange($),$.forEach((E)=>{let Y=S.getInstance(),J=this.channels.get(E);if(J&&J.length>0){if(Y)Y.ssubscribe(J),Y.on("ready",()=>{Y.ssubscribe(J)})}})})}_slotsAreEqual(S){if(this.clusterSlots===void 0)return!1;else return JSON.stringify(this.clusterSlots)===JSON.stringify(S)}}p3.default=b3});var F0=D((o3)=>{Object.defineProperty(o3,"__esModule",{value:!0});var i3=N1(),d3=j("events"),o1=H1(),t3=Q1(),c3=w1(),Z0=sw(),o6=L1(),n6=LS(),s6=$0(),d=p(),a6=E0(),r6=BS(),e6=k3(),S7=J0(),w7=X0(),$7=_3(),K1=l1(),m3=HS(),E7=u3(),O=(0,d.Debug)("cluster"),l3=new WeakSet;class n1 extends r6.default{constructor(S,w={}){super();if(this.slots=[],this._groupsIds={},this._groupsBySlot=Array(16384),this.isCluster=!0,this.retryAttempts=0,this.delayQueue=new $7.default,this.offlineQueue=new m3,this.isRefreshing=!1,this._refreshSlotsCacheCallbacks=[],this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this._readyDelayedCallbacks=[],this.connectionEpoch=0,d3.EventEmitter.call(this),this.startupNodes=S,this.options=(0,d.defaults)({},w,e6.DEFAULT_CLUSTER_OPTIONS,this.options),this.options.shardedSubscribers==!0)this.shardedSubscribers=new E7.default(this,this.refreshSlotsCache.bind(this));if(this.options.redisOptions&&this.options.redisOptions.keyPrefix&&!this.options.keyPrefix)this.options.keyPrefix=this.options.redisOptions.keyPrefix;if(typeof this.options.scaleReads!=="function"&&["all","master","slave"].indexOf(this.options.scaleReads)===-1)throw Error('Invalid option scaleReads "'+this.options.scaleReads+'". Expected "all", "master", "slave" or a custom function');if(this.connectionPool=new w7.default(this.options.redisOptions),this.connectionPool.on("-node",($,E)=>{this.emit("-node",$)}),this.connectionPool.on("+node",($)=>{this.emit("+node",$)}),this.connectionPool.on("drain",()=>{this.setStatus("close")}),this.connectionPool.on("nodeError",($,E)=>{this.emit("node error",$,E)}),this.subscriber=new S7.default(this.connectionPool,this),this.options.scripts)Object.entries(this.options.scripts).forEach(([$,E])=>{this.defineCommand($,E)});if(this.options.lazyConnect)this.setStatus("wait");else this.connect().catch(($)=>{O("connecting failed: %s",$)})}connect(){return new Promise((S,w)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){w(Error("Redis is already connecting/connected"));return}let $=++this.connectionEpoch;this.setStatus("connecting"),this.resolveStartupNodeHostnames().then((E)=>{if(this.connectionEpoch!==$){O("discard connecting after resolving startup nodes because epoch not match: %d != %d",$,this.connectionEpoch),w(new o1.RedisError("Connection is discarded because a new connection is made"));return}if(this.status!=="connecting"){O("discard connecting after resolving startup nodes because the status changed to %s",this.status),w(new o1.RedisError("Connection is aborted"));return}this.connectionPool.reset(E);let Y=()=>{this.setStatus("ready"),this.retryAttempts=0,this.executeOfflineCommands(),this.resetNodesRefreshInterval(),S()},J=void 0,Q=()=>{if(this.invokeReadyDelayedCallbacks(void 0),this.removeListener("close",J),this.manuallyClosing=!1,this.setStatus("connect"),this.options.enableReadyCheck)this.readyCheck((X,Z)=>{if(X||Z){if(O("Ready check failed (%s). Reconnecting...",X||Z),this.status==="connect")this.disconnect(!0)}else Y()});else Y()};if(J=()=>{let X=Error("None of startup nodes is available");this.removeListener("refresh",Q),this.invokeReadyDelayedCallbacks(X),w(X)},this.once("refresh",Q),this.once("close",J),this.once("close",this.handleCloseEvent.bind(this)),this.refreshSlotsCache((X)=>{if(X&&X.message===Z0.default.defaultMessage)o6.default.prototype.silentEmit.call(this,"error",X),this.connectionPool.reset([])}),this.subscriber.start(),this.options.shardedSubscribers)this.shardedSubscribers.start()}).catch((E)=>{this.setStatus("close"),this.handleCloseEvent(E),this.invokeReadyDelayedCallbacks(E),w(E)})})}disconnect(S=!1){let w=this.status;if(this.setStatus("disconnecting"),!S)this.manuallyClosing=!0;if(this.reconnectTimeout&&!S)clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null,O("Canceled reconnecting attempts");if(this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers)this.shardedSubscribers.stop();if(w==="wait")this.setStatus("close"),this.handleCloseEvent();else this.connectionPool.reset([])}quit(S){let w=this.status;if(this.setStatus("disconnecting"),this.manuallyClosing=!0,this.reconnectTimeout)clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null;if(this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers)this.shardedSubscribers.stop();if(w==="wait"){let $=(0,t3.default)(Promise.resolve("OK"),S);return setImmediate(function(){this.setStatus("close"),this.handleCloseEvent()}.bind(this)),$}return(0,t3.default)(Promise.all(this.nodes().map(($)=>$.quit().catch((E)=>{if(E.message===d.CONNECTION_CLOSED_ERROR_MSG)return"OK";throw E}))).then(()=>"OK"),S)}duplicate(S=[],w={}){let $=S.length>0?S:this.startupNodes.slice(0),E=Object.assign({},this.options,w);return new n1($,E)}nodes(S="all"){if(S!=="all"&&S!=="master"&&S!=="slave")throw Error('Invalid role "'+S+'". Expected "all", "master" or "slave"');return this.connectionPool.getNodes(S)}delayUntilReady(S){this._readyDelayedCallbacks.push(S)}get autoPipelineQueueSize(){let S=0;for(let w of this._autoPipelines.values())S+=w.length;return S}refreshSlotsCache(S){if(S)this._refreshSlotsCacheCallbacks.push(S);if(this.isRefreshing)return;this.isRefreshing=!0;let w=this,$=(Q)=>{this.isRefreshing=!1;for(let X of this._refreshSlotsCacheCallbacks)X(Q);this._refreshSlotsCacheCallbacks=[]},E=(0,d.shuffle)(this.connectionPool.getNodes()),Y=null;function J(Q){if(Q===E.length){let B=new Z0.default(Z0.default.defaultMessage,Y);return $(B)}let X=E[Q],Z=`${X.options.host}:${X.options.port}`;O("getting slot cache from %s",Z),w.getInfoFromNode(X,function(B){switch(w.status){case"close":case"end":return $(Error("Cluster is disconnected."));case"disconnecting":return $(Error("Cluster is disconnecting."))}if(B)w.emit("node error",B,Z),Y=B,J(Q+1);else w.emit("refresh"),$()})}J(0)}sendCommand(S,w,$){if(this.status==="wait")this.connect().catch(d.noop);if(this.status==="end")return S.reject(Error(d.CONNECTION_CLOSED_ERROR_MSG)),S.promise;let E=this.options.scaleReads;if(E!=="master"){if(!(S.isReadOnly||(0,i3.exists)(S.name)&&(0,i3.hasFlag)(S.name,"readonly")))E="master"}let Y=$?$.slot:S.getSlot(),J={},Q=this;if(!$&&!l3.has(S)){l3.add(S);let Z=S.reject;S.reject=function(B){let z=X.bind(null,!0);Q.handleError(B,J,{moved:function(W,H){if(O("command %s is moved to %s",S.name,H),Y=Number(W),Q.slots[W])Q.slots[W][0]=H;else Q.slots[W]=[H];Q._groupsBySlot[W]=Q._groupsIds[Q.slots[W].join(";")],Q.connectionPool.findOrCreate(Q.natMapper(H)),X(),O("refreshing slot caches... (triggered by MOVED error)"),Q.refreshSlotsCache()},ask:function(W,H){O("command %s is required to ask %s:%s",S.name,H);let G=Q.natMapper(H);Q.connectionPool.findOrCreate(G),X(!1,`${G.host}:${G.port}`)},tryagain:z,clusterDown:z,connectionClosed:z,maxRedirections:function(W){Z.call(S,W)},defaults:function(){Z.call(S,B)}})}}X();function X(Z,B){if(Q.status==="end"){S.reject(new o1.AbortError("Cluster is ended."));return}let z;if(Q.status==="ready"||S.name==="cluster"){if($&&$.redis)z=$.redis;else if(c3.default.checkFlag("ENTER_SUBSCRIBER_MODE",S.name)||c3.default.checkFlag("EXIT_SUBSCRIBER_MODE",S.name)){if(Q.options.shardedSubscribers==!0&&(S.name=="ssubscribe"||S.name=="sunsubscribe")){let W=Q.shardedSubscribers.getResponsibleSubscriber(Y),H=-1;if(S.name=="ssubscribe")H=Q.shardedSubscribers.addChannels(S.getKeys());if(S.name=="sunsubscribe")H=Q.shardedSubscribers.removeChannels(S.getKeys());if(H!==-1)z=W.getInstance();else S.reject(new o1.AbortError("Can't add or remove the given channels. Are they in the same slot?"))}else z=Q.subscriber.getInstance();if(!z){S.reject(new o1.AbortError("No subscriber for the cluster"));return}}else{if(!Z){if(typeof Y==="number"&&Q.slots[Y]){let W=Q.slots[Y];if(typeof E==="function"){let H=W.map(function(G){return Q.connectionPool.getInstanceByKey(G)});if(z=E(H,S),Array.isArray(z))z=(0,d.sample)(z);if(!z)z=H[0]}else{let H;if(E==="all")H=(0,d.sample)(W);else if(E==="slave"&&W.length>1)H=(0,d.sample)(W,1);else H=W[0];z=Q.connectionPool.getInstanceByKey(H)}}if(B)z=Q.connectionPool.getInstanceByKey(B),z.asking()}if(!z)z=(typeof E==="function"?null:Q.connectionPool.getSampleInstance(E))||Q.connectionPool.getSampleInstance("all")}if($&&!$.redis)$.redis=z}if(z)z.sendCommand(S,w);else if(Q.options.enableOfflineQueue)Q.offlineQueue.push({command:S,stream:w,node:$});else S.reject(Error("Cluster isn't ready and enableOfflineQueue options is false"))}return S.promise}sscanStream(S,w){return this.createScanStream("sscan",{key:S,options:w})}sscanBufferStream(S,w){return this.createScanStream("sscanBuffer",{key:S,options:w})}hscanStream(S,w){return this.createScanStream("hscan",{key:S,options:w})}hscanBufferStream(S,w){return this.createScanStream("hscanBuffer",{key:S,options:w})}zscanStream(S,w){return this.createScanStream("zscan",{key:S,options:w})}zscanBufferStream(S,w){return this.createScanStream("zscanBuffer",{key:S,options:w})}handleError(S,w,$){if(typeof w.value>"u")w.value=this.options.maxRedirections;else w.value-=1;if(w.value<=0){$.maxRedirections(Error("Too many Cluster redirections. Last error: "+S));return}let E=S.message.split(" ");if(E[0]==="MOVED"){let Y=this.options.retryDelayOnMoved;if(Y&&typeof Y==="number")this.delayQueue.push("moved",$.moved.bind(null,E[1],E[2]),{timeout:Y});else $.moved(E[1],E[2])}else if(E[0]==="ASK")$.ask(E[1],E[2]);else if(E[0]==="TRYAGAIN")this.delayQueue.push("tryagain",$.tryagain,{timeout:this.options.retryDelayOnTryAgain});else if(E[0]==="CLUSTERDOWN"&&this.options.retryDelayOnClusterDown>0)this.delayQueue.push("clusterdown",$.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)});else if(S.message===d.CONNECTION_CLOSED_ERROR_MSG&&this.options.retryDelayOnFailover>0&&this.status==="ready")this.delayQueue.push("failover",$.connectionClosed,{timeout:this.options.retryDelayOnFailover,callback:this.refreshSlotsCache.bind(this)});else $.defaults()}resetOfflineQueue(){this.offlineQueue=new m3}clearNodesRefreshInterval(){if(this.slotsTimer)clearTimeout(this.slotsTimer),this.slotsTimer=null}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval)return;let S=()=>{this.slotsTimer=setTimeout(()=>{O('refreshing slot caches... (triggered by "slotsRefreshInterval" option)'),this.refreshSlotsCache(()=>{S()})},this.options.slotsRefreshInterval)};S()}setStatus(S){O("status: %s -> %s",this.status||"[empty]",S),this.status=S,process.nextTick(()=>{this.emit(S)})}handleCloseEvent(S){if(S)O("closed because %s",S);let w;if(!this.manuallyClosing&&typeof this.options.clusterRetryStrategy==="function")w=this.options.clusterRetryStrategy.call(this,++this.retryAttempts,S);if(typeof w==="number")this.setStatus("reconnecting"),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,O("Cluster is disconnected. Retrying after %dms",w),this.connect().catch(function($){O("Got error %s when reconnecting. Ignoring...",$)})},w);else this.setStatus("end"),this.flushQueue(Error("None of startup nodes is available"))}flushQueue(S){let w;while(w=this.offlineQueue.shift())w.command.reject(S)}executeOfflineCommands(){if(this.offlineQueue.length){O("send %d commands in offline queue",this.offlineQueue.length);let S=this.offlineQueue;this.resetOfflineQueue();let w;while(w=S.shift())this.sendCommand(w.command,w.stream,w.node)}}natMapper(S){let w=typeof S==="string"?S:`${S.host}:${S.port}`,$=null;if(this.options.natMap&&typeof this.options.natMap==="function")$=this.options.natMap(w);else if(this.options.natMap&&typeof this.options.natMap==="object")$=this.options.natMap[w];if($)return O("NAT mapping %s -> %O",w,$),Object.assign({},$);return typeof S==="string"?(0,K1.nodeKeyToRedisOptions)(S):S}getInfoFromNode(S,w){if(!S)return w(Error("Node is disconnected"));let $=S.duplicate({enableOfflineQueue:!0,enableReadyCheck:!1,retryStrategy:null,connectionName:(0,K1.getConnectionName)("refresher",this.options.redisOptions&&this.options.redisOptions.connectionName)});$.on("error",d.noop),$.cluster("SLOTS",(0,d.timeout)((E,Y)=>{if($.disconnect(),E)return O("error encountered running CLUSTER.SLOTS: %s",E),w(E);if(this.status==="disconnecting"||this.status==="close"||this.status==="end"){O("ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s",Y.length,this.status),w();return}let J=[];O("cluster slots result count: %d",Y.length);for(let X=0;X<Y.length;++X){let Z=Y[X],B=Z[0],z=Z[1],W=[];for(let H=2;H<Z.length;H++){if(!Z[H][0])continue;let G=this.natMapper({host:Z[H][0],port:Z[H][1]});G.readOnly=H!==2,J.push(G),W.push(G.host+":"+G.port)}O("cluster slots result [%d]: slots %d~%d served by %s",X,B,z,W);for(let H=B;H<=z;H++)this.slots[H]=W}this._groupsIds=Object.create(null);let Q=0;for(let X=0;X<16384;X++){let Z=(this.slots[X]||[]).join(";");if(!Z.length){this._groupsBySlot[X]=void 0;continue}if(!this._groupsIds[Z])this._groupsIds[Z]=++Q;this._groupsBySlot[X]=this._groupsIds[Z]}this.connectionPool.reset(J),w()},this.options.slotsRefreshTimeout))}invokeReadyDelayedCallbacks(S){for(let w of this._readyDelayedCallbacks)process.nextTick(w,S);this._readyDelayedCallbacks=[]}readyCheck(S){this.cluster("INFO",(w,$)=>{if(w)return S(w);if(typeof $!=="string")return S();let E,Y=$.split(`\r
|
|
159
|
+
`);for(let J=0;J<Y.length;++J){let Q=Y[J].split(":");if(Q[0]==="cluster_state"){E=Q[1];break}}if(E==="fail")O("cluster state not ok (%s)",E),S(null,E);else S()})}resolveSrv(S){return new Promise((w,$)=>{this.options.resolveSrv(S,(E,Y)=>{if(E)return $(E);let J=this,Q=(0,K1.groupSrvRecords)(Y),X=Object.keys(Q).sort((B,z)=>parseInt(B)-parseInt(z));function Z(B){if(!X.length)return $(B);let z=X[0],W=Q[z],H=(0,K1.weightSrvRecords)(W);if(!W.records.length)X.shift();J.dnsLookup(H.name).then((G)=>w({host:G,port:H.port}),Z)}Z()})})}dnsLookup(S){return new Promise((w,$)=>{this.options.dnsLookup(S,(E,Y)=>{if(E)O("failed to resolve hostname %s to IP: %s",S,E.message),$(E);else O("resolved hostname %s to IP %s",S,Y),w(Y)})})}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0)throw Error("`startupNodes` should contain at least one node.");let S=(0,K1.normalizeNodeOptions)(this.startupNodes),w=(0,K1.getUniqueHostnamesFromOptions)(S);if(w.length===0)return S;let $=await Promise.all(w.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this))),E=(0,d.zipMap)(w,$);return S.map((Y)=>{let J=E.get(Y.host);if(!J)return Y;if(this.options.useSRVRecords)return Object.assign({},Y,J);return Object.assign({},Y,{host:J})})}createScanStream(S,{key:w,options:$={}}){return new n6.default({objectMode:!0,key:w,redis:this,command:S,...$})}}(0,a6.default)(n1,d3.EventEmitter);(0,s6.addTransactionSupport)(n1.prototype);o3.default=n1});var qS=D((s3)=>{Object.defineProperty(s3,"__esModule",{value:!0});var J7=p(),Q7=(0,J7.Debug)("AbstractConnector");class n3{constructor(S){this.connecting=!1,this.disconnectTimeout=S}check(S){return!0}disconnect(){if(this.connecting=!1,this.stream){let S=this.stream,w=setTimeout(()=>{Q7("stream %s:%s still open, destroying it",S.remoteAddress,S.remotePort),S.destroy()},this.disconnectTimeout);S.on("close",()=>clearTimeout(w)),S.end()}}}s3.default=n3});var e3=D((r3)=>{Object.defineProperty(r3,"__esModule",{value:!0});var Z7=j("net"),F7=j("tls"),L7=p(),W7=qS();class a3 extends W7.default{constructor(S){super(S.disconnectTimeout);this.options=S}connect(S){let{options:w}=this;this.connecting=!0;let $;if("path"in w&&w.path)$={path:w.path};else{if($={},"port"in w&&w.port!=null)$.port=w.port;if("host"in w&&w.host!=null)$.host=w.host;if("family"in w&&w.family!=null)$.family=w.family}if(w.tls)Object.assign($,w.tls);return new Promise((E,Y)=>{process.nextTick(()=>{if(!this.connecting){Y(Error(L7.CONNECTION_CLOSED_ERROR_MSG));return}try{if(w.tls)this.stream=(0,F7.connect)($);else this.stream=(0,Z7.createConnection)($)}catch(J){Y(J);return}this.stream.once("error",(J)=>{this.firstError=J}),E(this.stream)})})}}r3.default=a3});var $$=D((w$)=>{Object.defineProperty(w$,"__esModule",{value:!0});function B7(S,w){return(S.host||"127.0.0.1")===(w.host||"127.0.0.1")&&(S.port||26379)===(w.port||26379)}class S${constructor(S){this.cursor=0,this.sentinels=S.slice(0)}next(){let S=this.cursor>=this.sentinels.length;return{done:S,value:S?void 0:this.sentinels[this.cursor++]}}reset(S){if(S&&this.sentinels.length>1&&this.cursor!==1)this.sentinels.unshift(...this.sentinels.splice(this.cursor-1));this.cursor=0}add(S){for(let w=0;w<this.sentinels.length;w++)if(B7(S,this.sentinels[w]))return!1;return this.sentinels.push(S),!0}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}}w$.default=S$});var X$=D((J$)=>{Object.defineProperty(J$,"__esModule",{value:!0});J$.FailoverDetector=void 0;var H7=p(),L0=(0,H7.Debug)("FailoverDetector"),E$="+switch-master";class Y${constructor(S,w){this.isDisconnected=!1,this.connector=S,this.sentinels=w}cleanup(){this.isDisconnected=!0;for(let S of this.sentinels)S.client.disconnect()}async subscribe(){L0("Starting FailoverDetector");let S=[];for(let w of this.sentinels){let $=w.client.subscribe(E$).catch((E)=>{L0("Failed to subscribe to failover messages on sentinel %s:%s (%s)",w.address.host||"127.0.0.1",w.address.port||26739,E.message)});S.push($),w.client.on("message",(E)=>{if(!this.isDisconnected&&E===E$)this.disconnect()})}await Promise.all(S)}disconnect(){this.isDisconnected=!0,L0("Failover detected, disconnecting"),this.connector.disconnect()}}J$.FailoverDetector=Y$});var GS=D((W$)=>{Object.defineProperty(W$,"__esModule",{value:!0});W$.SentinelIterator=void 0;var U7=j("net"),s1=p(),q7=j("tls"),Z$=$$();W$.SentinelIterator=Z$.default;var G7=qS(),R7=L1(),y7=X$(),f1=(0,s1.Debug)("SentinelConnector");class F$ extends G7.default{constructor(S){super(S.disconnectTimeout);if(this.options=S,this.emitter=null,this.failoverDetector=null,!this.options.sentinels.length)throw Error("Requires at least one sentinel to connect to.");if(!this.options.name)throw Error("Requires the name of master.");this.sentinelIterator=new Z$.default(this.options.sentinels)}check(S){let w=!S.role||this.options.role===S.role;if(!w)f1("role invalid, expected %s, but got %s",this.options.role,S.role),this.sentinelIterator.next(),this.sentinelIterator.next(),this.sentinelIterator.reset(!0);return w}disconnect(){if(super.disconnect(),this.failoverDetector)this.failoverDetector.cleanup()}connect(S){this.connecting=!0,this.retryAttempts=0;let w,$=async()=>{let E=this.sentinelIterator.next();if(E.done){this.sentinelIterator.reset(!1);let X=typeof this.options.sentinelRetryStrategy==="function"?this.options.sentinelRetryStrategy(++this.retryAttempts):null,Z=typeof X!=="number"?"All sentinels are unreachable and retry is disabled.":`All sentinels are unreachable. Retrying from scratch after ${X}ms.`;if(w)Z+=` Last error: ${w.message}`;f1(Z);let B=Error(Z);if(typeof X==="number")return S("error",B),await new Promise((z)=>setTimeout(z,X)),$();else throw B}let Y=null,J=null;try{Y=await this.resolve(E.value)}catch(X){J=X}if(!this.connecting)throw Error(s1.CONNECTION_CLOSED_ERROR_MSG);let Q=E.value.host+":"+E.value.port;if(Y){if(f1("resolved: %s:%s from sentinel %s",Y.host,Y.port,Q),this.options.enableTLSForSentinelMode&&this.options.tls)Object.assign(Y,this.options.tls),this.stream=(0,q7.connect)(Y),this.stream.once("secureConnect",this.initFailoverDetector.bind(this));else this.stream=(0,U7.createConnection)(Y),this.stream.once("connect",this.initFailoverDetector.bind(this));return this.stream.once("error",(X)=>{this.firstError=X}),this.stream}else{let X=J?"failed to connect to sentinel "+Q+" because "+J.message:"connected to sentinel "+Q+" successfully, but got an invalid reply: "+Y;if(f1(X),S("sentinelError",Error(X)),J)w=J;return $()}};return $()}async updateSentinels(S){if(!this.options.updateSentinels)return;let w=await S.sentinel("sentinels",this.options.name);if(!Array.isArray(w))return;w.map(s1.packObject).forEach(($)=>{if(($.flags?$.flags.split(","):[]).indexOf("disconnected")===-1&&$.ip&&$.port){let Y=this.sentinelNatResolve(L$($));if(this.sentinelIterator.add(Y))f1("adding sentinel %s:%s",Y.host,Y.port)}}),f1("Updated internal sentinels: %s",this.sentinelIterator)}async resolveMaster(S){let w=await S.sentinel("get-master-addr-by-name",this.options.name);return await this.updateSentinels(S),this.sentinelNatResolve(Array.isArray(w)?{host:w[0],port:Number(w[1])}:null)}async resolveSlave(S){let w=await S.sentinel("slaves",this.options.name);if(!Array.isArray(w))return null;let $=w.map(s1.packObject).filter((E)=>E.flags&&!E.flags.match(/(disconnected|s_down|o_down)/));return this.sentinelNatResolve(T7($,this.options.preferredSlaves))}sentinelNatResolve(S){if(!S||!this.options.natMap)return S;let w=`${S.host}:${S.port}`,$=S;if(typeof this.options.natMap==="function")$=this.options.natMap(w)||S;else if(typeof this.options.natMap==="object")$=this.options.natMap[w]||S;return $}connectToSentinel(S,w){return new R7.default({port:S.port||26379,host:S.host,username:this.options.sentinelUsername||null,password:this.options.sentinelPassword||null,family:S.family||("path"in this.options&&this.options.path?void 0:this.options.family),tls:this.options.sentinelTLS,retryStrategy:null,enableReadyCheck:!1,connectTimeout:this.options.connectTimeout,commandTimeout:this.options.sentinelCommandTimeout,...w})}async resolve(S){let w=this.connectToSentinel(S);w.on("error",A7);try{if(this.options.role==="slave")return await this.resolveSlave(w);else return await this.resolveMaster(w)}finally{w.disconnect()}}async initFailoverDetector(){var S;if(!this.options.failoverDetector)return;this.sentinelIterator.reset(!0);let w=[];while(w.length<this.options.sentinelMaxConnections){let{done:$,value:E}=this.sentinelIterator.next();if($)break;let Y=this.connectToSentinel(E,{lazyConnect:!0,retryStrategy:this.options.sentinelReconnectStrategy});Y.on("reconnecting",()=>{var J;(J=this.emitter)===null||J===void 0||J.emit("sentinelReconnecting")}),w.push({address:E,client:Y})}if(this.sentinelIterator.reset(!1),this.failoverDetector)this.failoverDetector.cleanup();this.failoverDetector=new y7.FailoverDetector(this,w),await this.failoverDetector.subscribe(),(S=this.emitter)===null||S===void 0||S.emit("failoverSubscribed")}}W$.default=F$;function T7(S,w){if(S.length===0)return null;let $;if(typeof w==="function")$=w(S);else if(w!==null&&typeof w==="object"){let E=Array.isArray(w)?w:[w];E.sort((Y,J)=>{if(!Y.prio)Y.prio=1;if(!J.prio)J.prio=1;if(Y.prio<J.prio)return-1;if(Y.prio>J.prio)return 1;return 0});for(let Y=0;Y<E.length;Y++){for(let J=0;J<S.length;J++){let Q=S[J];if(Q.ip===E[Y].ip){if(Q.port===E[Y].port){$=Q;break}}}if($)break}}if(!$)$=(0,s1.sample)(S);return L$($)}function L$(S){return{host:S.ip,port:Number(S.port)}}function A7(){}});var H$=D((B$)=>{Object.defineProperty(B$,"__esModule",{value:!0});B$.SentinelConnector=B$.StandaloneConnector=void 0;var k7=e3();B$.StandaloneConnector=k7.default;var I7=GS();B$.SentinelConnector=I7.default});var G$=D((q$)=>{Object.defineProperty(q$,"__esModule",{value:!0});var N7=H1();class U$ extends N7.AbortError{constructor(S){let w=`Reached the max retries per request limit (which is ${S}). Refer to "maxRetriesPerRequest" option for details.`;super(w);Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}q$.default=U$});var T$=D((R$)=>{Object.defineProperty(R$,"__esModule",{value:!0});R$.MaxRetriesPerRequestError=void 0;var C7=G$();R$.MaxRetriesPerRequestError=C7.default});var C$=D((fJ,P$)=>{var H0=j("buffer").Buffer,j7=j("string_decoder").StringDecoder,W0=new j7,A$=H1(),h7=A$.ReplyError,x7=A$.ParserError,s=H0.allocUnsafe(32768),i=0,RS=null,a1=0,z0=0;function O7(S){let w=S.buffer.length-1;var $=S.offset,E=0,Y=1;if(S.buffer[$]===45)Y=-1,$++;while($<w){let J=S.buffer[$++];if(J===13)return S.offset=$+1,Y*E;E=E*10+(J-48)}}function K7(S){let w=S.buffer.length-1;var $=S.offset,E=0,Y="";if(S.buffer[$]===45)Y+="-",$++;while($<w){var J=S.buffer[$++];if(J===13){if(S.offset=$+1,E!==0)Y+=E;return Y}else if(E>429496728)Y+=E*10+(J-48),E=0;else if(J===48&&E===0)Y+=0;else E=E*10+(J-48)}}function D$(S){let{offset:w,buffer:$}=S,E=$.length-1;var Y=w;while(Y<E)if($[Y++]===13){if(S.offset=Y+1,S.optionReturnBuffers===!0)return S.buffer.slice(w,Y-1);return S.buffer.toString("utf8",w,Y-1)}}function k$(S){let w=S.buffer.length-1;var $=S.offset,E=0;while($<w){let Y=S.buffer[$++];if(Y===13)return S.offset=$+1,E;E=E*10+(Y-48)}}function f7(S){if(S.optionStringNumbers===!0)return K7(S);return O7(S)}function _7(S){let w=k$(S);if(w===void 0)return;if(w<0)return null;let $=S.offset+w;if($+2>S.buffer.length){S.bigStrSize=$+2,S.totalChunkSize=S.buffer.length,S.bufferCache.push(S.buffer);return}let E=S.offset;if(S.offset=$+2,S.optionReturnBuffers===!0)return S.buffer.slice(E,$);return S.buffer.toString("utf8",E,$)}function g7(S){var w=D$(S);if(w!==void 0){if(S.optionReturnBuffers===!0)w=w.toString();return new h7(w)}}function v7(S,w){let $=new x7("Protocol error, got "+JSON.stringify(String.fromCharCode(w))+" as reply type byte",JSON.stringify(S.buffer),S.offset);S.buffer=null,S.returnFatalError($)}function b7(S){let w=k$(S);if(w===void 0)return;if(w<0)return null;let $=Array(w);return I$(S,$,0)}function B0(S,w,$){S.arrayCache.push(w),S.arrayPos.push($)}function V0(S){let w=S.arrayCache.pop();var $=S.arrayPos.pop();if(S.arrayCache.length){let E=V0(S);if(E===void 0){B0(S,w,$);return}w[$++]=E}return I$(S,w,$)}function I$(S,w,$){let E=S.buffer.length;while($<w.length){let Y=S.offset;if(S.offset>=E){B0(S,w,$);return}let J=M$(S,S.buffer[S.offset++]);if(J===void 0){if(!(S.arrayCache.length||S.bufferCache.length))S.offset=Y;B0(S,w,$);return}w[$]=J,$++}return w}function M$(S,w){switch(w){case 36:return _7(S);case 43:return D$(S);case 42:return b7(S);case 58:return f7(S);case 45:return g7(S);default:return v7(S,w)}}function p7(){if(s.length>51200)if(a1===1||z0>a1*2){let S=Math.floor(s.length/10),w=S<i?i:S;i=0,s=s.slice(w,s.length)}else z0++,a1--;else clearInterval(RS),a1=0,z0=0,RS=null}function u7(S){if(s.length<S+i){let w=S>78643200?2:3;if(i>116391936)i=52428800;if(s=H0.allocUnsafe(S*w+i),i=0,a1++,RS===null)RS=setInterval(p7,50)}}function i7(S){let{bufferCache:w,offset:$}=S;var E=w.length,Y=S.bigStrSize-S.totalChunkSize;if(S.offset=Y,Y<=2){if(E===2)return w[0].toString("utf8",$,w[0].length+Y-2);E--,Y=w[w.length-2].length+Y}var J=W0.write(w[0].slice($));for(var Q=1;Q<E-1;Q++)J+=W0.write(w[Q]);return J+=W0.end(w[Q].slice(0,Y-2)),J}function t7(S){let{bufferCache:w,offset:$}=S,E=S.bigStrSize-$-2;var Y=w.length,J=S.bigStrSize-S.totalChunkSize;if(S.offset=J,J<=2){if(Y===2)return w[0].slice($,w[0].length+J-2);Y--,J=w[w.length-2].length+J}u7(E);let Q=i;w[0].copy(s,Q,$,w[0].length),i+=w[0].length-$;for(var X=1;X<Y-1;X++)w[X].copy(s,i),i+=w[X].length;return w[X].copy(s,i,0,J-2),i+=J-2,s.slice(Q,i)}class N${constructor(S){if(!S)throw TypeError("Options are mandatory.");if(typeof S.returnError!=="function"||typeof S.returnReply!=="function")throw TypeError("The returnReply and returnError options have to be functions.");this.setReturnBuffers(!!S.returnBuffers),this.setStringNumbers(!!S.stringNumbers),this.returnError=S.returnError,this.returnFatalError=S.returnFatalError||S.returnError,this.returnReply=S.returnReply,this.reset()}reset(){this.offset=0,this.buffer=null,this.bigStrSize=0,this.totalChunkSize=0,this.bufferCache=[],this.arrayCache=[],this.arrayPos=[]}setReturnBuffers(S){if(typeof S!=="boolean")throw TypeError("The returnBuffers argument has to be a boolean");this.optionReturnBuffers=S}setStringNumbers(S){if(typeof S!=="boolean")throw TypeError("The stringNumbers argument has to be a boolean");this.optionStringNumbers=S}execute(S){if(this.buffer===null)this.buffer=S,this.offset=0;else if(this.bigStrSize===0){let $=this.buffer.length,E=$-this.offset,Y=H0.allocUnsafe(E+S.length);if(this.buffer.copy(Y,0,this.offset,$),S.copy(Y,E,0,S.length),this.buffer=Y,this.offset=0,this.arrayCache.length){let J=V0(this);if(J===void 0)return;this.returnReply(J)}}else if(this.totalChunkSize+S.length>=this.bigStrSize){this.bufferCache.push(S);var w=this.optionReturnBuffers?t7(this):i7(this);if(this.bigStrSize=0,this.bufferCache=[],this.buffer=S,this.arrayCache.length){if(this.arrayCache[0][this.arrayPos[0]++]=w,w=V0(this),w===void 0)return}this.returnReply(w)}else{this.bufferCache.push(S),this.totalChunkSize+=S.length;return}while(this.offset<this.buffer.length){let $=this.offset,E=this.buffer[this.offset++],Y=M$(this,E);if(Y===void 0){if(!(this.arrayCache.length||this.bufferCache.length))this.offset=$;return}if(E===45)this.returnError(Y);else this.returnReply(Y)}this.buffer=null}}P$.exports=N$});var x$=D((h$)=>{Object.defineProperty(h$,"__esModule",{value:!0});class j${constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(S,w){this.set[U0(S)][w]=!0}del(S,w){delete this.set[U0(S)][w]}channels(S){return Object.keys(this.set[U0(S)])}isEmpty(){return this.channels("subscribe").length===0&&this.channels("psubscribe").length===0&&this.channels("ssubscribe").length===0}}h$.default=j$;function U0(S){if(S==="unsubscribe")return"subscribe";if(S==="punsubscribe")return"psubscribe";if(S==="sunsubscribe")return"ssubscribe";return S}});var v$=D((g$)=>{Object.defineProperty(g$,"__esModule",{value:!0});var O$=w1(),m7=p(),l7=C$(),d7=x$(),o7=(0,m7.Debug)("dataHandler");class _${constructor(S,w){this.redis=S;let $=new l7({stringNumbers:w.stringNumbers,returnBuffers:!0,returnError:(E)=>{this.returnError(E)},returnFatalError:(E)=>{this.returnFatalError(E)},returnReply:(E)=>{this.returnReply(E)}});S.stream.prependListener("data",(E)=>{$.execute(E)}),S.stream.resume()}returnFatalError(S){S.message+=". Please report this.",this.redis.recoverFromFatalError(S,S,{offlineQueue:!1})}returnError(S){let w=this.shiftCommand(S);if(!w)return;if(S.command={name:w.command.name,args:w.command.args},w.command.name=="ssubscribe"&&S.message.includes("MOVED")){this.redis.emit("moved");return}this.redis.handleReconnection(S,w)}returnReply(S){if(this.handleMonitorReply(S))return;if(this.handleSubscriberReply(S))return;let w=this.shiftCommand(S);if(!w)return;if(O$.default.checkFlag("ENTER_SUBSCRIBER_MODE",w.command.name)){if(this.redis.condition.subscriber=new d7.default,this.redis.condition.subscriber.add(w.command.name,S[1].toString()),!K$(w.command,S[2]))this.redis.commandQueue.unshift(w)}else if(O$.default.checkFlag("EXIT_SUBSCRIBER_MODE",w.command.name)){if(!f$(w.command,S[2]))this.redis.commandQueue.unshift(w)}else w.command.resolve(S)}handleSubscriberReply(S){if(!this.redis.condition.subscriber)return!1;let w=Array.isArray(S)?S[0].toString():null;switch(o7('receive reply "%s" in subscriber mode',w),w){case"message":if(this.redis.listeners("message").length>0)this.redis.emit("message",S[1].toString(),S[2]?S[2].toString():"");this.redis.emit("messageBuffer",S[1],S[2]);break;case"pmessage":{let $=S[1].toString();if(this.redis.listeners("pmessage").length>0)this.redis.emit("pmessage",$,S[2].toString(),S[3].toString());this.redis.emit("pmessageBuffer",$,S[2],S[3]);break}case"smessage":{if(this.redis.listeners("smessage").length>0)this.redis.emit("smessage",S[1].toString(),S[2]?S[2].toString():"");this.redis.emit("smessageBuffer",S[1],S[2]);break}case"ssubscribe":case"subscribe":case"psubscribe":{let $=S[1].toString();this.redis.condition.subscriber.add(w,$);let E=this.shiftCommand(S);if(!E)return;if(!K$(E.command,S[2]))this.redis.commandQueue.unshift(E);break}case"sunsubscribe":case"unsubscribe":case"punsubscribe":{let $=S[1]?S[1].toString():null;if($)this.redis.condition.subscriber.del(w,$);let E=S[2];if(Number(E)===0)this.redis.condition.subscriber=!1;let Y=this.shiftCommand(S);if(!Y)return;if(!f$(Y.command,E))this.redis.commandQueue.unshift(Y);break}default:{let $=this.shiftCommand(S);if(!$)return;$.command.resolve(S)}}return!0}handleMonitorReply(S){if(this.redis.status!=="monitoring")return!1;let w=S.toString();if(w==="OK")return!1;let $=w.indexOf(" "),E=w.slice(0,$),Y=w.indexOf('"'),J=w.slice(Y+1,-1).split('" "').map((X)=>X.replace(/\\"/g,'"')),Q=w.slice($+2,Y-2).split(" ");return this.redis.emit("monitor",E,J,Q[1],Q[0]),!0}shiftCommand(S){let w=this.redis.commandQueue.shift();if(!w){let E=Error("Command queue state error. If you can reproduce this, please report it."+(S instanceof Error?` Last error: ${S.message}`:` Last reply: ${S.toString()}`));return this.redis.emit("error",E),null}return w}}g$.default=_$;var W1=new WeakMap;function K$(S,w){let $=W1.has(S)?W1.get(S):S.args.length;if($-=1,$<=0)return S.resolve(w),W1.delete(S),!0;return W1.set(S,$),!1}function f$(S,w){let $=W1.has(S)?W1.get(S):S.args.length;if($===0){if(Number(w)===0)return W1.delete(S),S.resolve(w),!0;return!1}if($-=1,$<=0)return S.resolve(w),!0;return W1.set(S,$),!1}});var p$=D((b$)=>{Object.defineProperty(b$,"__esModule",{value:!0});b$.readyHandler=b$.errorHandler=b$.closeHandler=b$.connectHandler=void 0;var s7=H1(),a7=w1(),r7=T$(),$1=p(),e7=v$(),u=(0,$1.Debug)("connection");function SY(S){return function(){S.setStatus("connect"),S.resetCommandQueue();let w=!1,{connectionEpoch:$}=S;if(S.condition.auth)S.auth(S.condition.auth,function(E){if($!==S.connectionEpoch)return;if(E)if(E.message.indexOf("no password is set")!==-1)console.warn("[WARN] Redis server does not require a password, but a password was supplied.");else if(E.message.indexOf("without any password configured for the default user")!==-1)console.warn("[WARN] This Redis server's `default` user does not require a password, but a password was supplied");else if(E.message.indexOf("wrong number of arguments for 'auth' command")!==-1)console.warn(`[ERROR] The server returned "wrong number of arguments for 'auth' command". You are probably passing both username and password to Redis version 5 or below. You should only pass the 'password' option for Redis version 5 and under.`);else w=!0,S.recoverFromFatalError(E,E)});if(S.condition.select)S.select(S.condition.select).catch((E)=>{S.silentEmit("error",E)});if(!S.options.enableReadyCheck)b$.readyHandler(S)();if(new e7.default(S,{stringNumbers:S.options.stringNumbers}),S.options.enableReadyCheck)S._readyCheck(function(E,Y){if($!==S.connectionEpoch)return;if(E){if(!w)S.recoverFromFatalError(Error("Ready check failed: "+E.message),E)}else if(S.connector.check(Y))b$.readyHandler(S)();else S.disconnect(!0)})}}b$.connectHandler=SY;function q0(S){let w=new s7.AbortError("Command aborted due to connection close");return w.command={name:S.name,args:S.args},w}function wY(S){var w;let $=0;for(let E=0;E<S.length;){let Y=(w=S.peekAt(E))===null||w===void 0?void 0:w.command,J=Y.pipelineIndex;if(J===void 0||J===0)$=0;if(J!==void 0&&J!==$++){S.remove(E,1),Y.reject(q0(Y));continue}E++}}function $Y(S){var w;for(let $=0;$<S.length;){let E=(w=S.peekAt($))===null||w===void 0?void 0:w.command;if(E.name==="multi")break;if(E.name==="exec"){S.remove($,1),E.reject(q0(E));break}if(E.inTransaction)S.remove($,1),E.reject(q0(E));else $++}}function EY(S){return function(){let $=S.status;if(S.setStatus("close"),S.commandQueue.length)wY(S.commandQueue);if(S.offlineQueue.length)$Y(S.offlineQueue);if($==="ready"){if(!S.prevCondition)S.prevCondition=S.condition;if(S.commandQueue.length)S.prevCommandQueue=S.commandQueue}if(S.manuallyClosing)return S.manuallyClosing=!1,u("skip reconnecting since the connection is manually closed."),w();if(typeof S.options.retryStrategy!=="function")return u("skip reconnecting because `retryStrategy` is not a function"),w();let E=S.options.retryStrategy(++S.retryAttempts);if(typeof E!=="number")return u("skip reconnecting because `retryStrategy` doesn't return a number"),w();u("reconnect in %sms",E),S.setStatus("reconnecting",E),S.reconnectTimeout=setTimeout(function(){S.reconnectTimeout=null,S.connect().catch($1.noop)},E);let{maxRetriesPerRequest:Y}=S.options;if(typeof Y==="number"){if(Y<0)u("maxRetriesPerRequest is negative, ignoring...");else if(S.retryAttempts%(Y+1)===0)u("reach maxRetriesPerRequest limitation, flushing command queue..."),S.flushQueue(new r7.MaxRetriesPerRequestError(Y))}};function w(){S.setStatus("end"),S.flushQueue(Error($1.CONNECTION_CLOSED_ERROR_MSG))}}b$.closeHandler=EY;function YY(S){return function(w){u("error: %s",w),S.silentEmit("error",w)}}b$.errorHandler=YY;function JY(S){return function(){var w,$;if(S.setStatus("ready"),S.retryAttempts=0,S.options.monitor){S.call("monitor").then(()=>S.setStatus("monitoring"),(J)=>S.emit("error",J));let{sendCommand:Y}=S;S.sendCommand=function(J){if(a7.default.checkFlag("VALID_IN_MONITOR_MODE",J.name))return Y.call(S,J);return J.reject(Error("Connection is in monitoring mode, can't process commands.")),J.promise},S.once("close",function(){delete S.sendCommand});return}let E=S.prevCondition?S.prevCondition.select:S.condition.select;if(S.options.connectionName)u("set the connection name [%s]",S.options.connectionName),S.client("setname",S.options.connectionName).catch($1.noop);if(!((w=S.options)===null||w===void 0?void 0:w.disableClientInfo)){u("set the client info");let Y=null;(0,$1.getPackageMeta)().then((J)=>{Y=J===null||J===void 0?void 0:J.version}).catch($1.noop).finally(()=>{S.client("SETINFO","LIB-VER",Y).catch($1.noop)}),S.client("SETINFO","LIB-NAME",(($=S.options)===null||$===void 0?void 0:$.clientInfoTag)?`ioredis(${S.options.clientInfoTag})`:"ioredis").catch($1.noop)}if(S.options.readOnly)u("set the connection to readonly mode"),S.readonly().catch($1.noop);if(S.prevCondition){let Y=S.prevCondition;if(S.prevCondition=null,Y.subscriber&&S.options.autoResubscribe){if(S.condition.select!==E)u("connect to db [%d]",E),S.select(E);let J=Y.subscriber.channels("subscribe");if(J.length)u("subscribe %d channels",J.length),S.subscribe(J);let Q=Y.subscriber.channels("psubscribe");if(Q.length)u("psubscribe %d channels",Q.length),S.psubscribe(Q);let X=Y.subscriber.channels("ssubscribe");if(X.length){u("ssubscribe %s",X.length);for(let Z of X)S.ssubscribe(Z)}}}if(S.prevCommandQueue)if(S.options.autoResendUnfulfilledCommands){u("resend %d unfulfilled commands",S.prevCommandQueue.length);while(S.prevCommandQueue.length>0){let Y=S.prevCommandQueue.shift();if(Y.select!==S.condition.select&&Y.command.name!=="select")S.select(Y.select);S.sendCommand(Y.command,Y.stream)}}else S.prevCommandQueue=null;if(S.offlineQueue.length){u("send %d commands in offline queue",S.offlineQueue.length);let Y=S.offlineQueue;S.resetOfflineQueue();while(Y.length>0){let J=Y.shift();if(J.select!==S.condition.select&&J.command.name!=="select")S.select(J.select);S.sendCommand(J.command,J.stream)}}if(S.condition.select!==E)u("connect to db [%d]",E),S.select(E)}}b$.readyHandler=JY});var t$=D((u$)=>{Object.defineProperty(u$,"__esModule",{value:!0});u$.DEFAULT_REDIS_OPTIONS=void 0;u$.DEFAULT_REDIS_OPTIONS={port:6379,host:"localhost",family:4,connectTimeout:1e4,disconnectTimeout:2000,retryStrategy:function(S){return Math.min(S*50,2000)},keepAlive:0,noDelay:!0,connectionName:null,disableClientInfo:!1,clientInfoTag:void 0,sentinels:null,name:null,role:"master",sentinelRetryStrategy:function(S){return Math.min(S*10,1000)},sentinelReconnectStrategy:function(){return 60000},natMap:null,enableTLSForSentinelMode:!1,updateSentinels:!0,failoverDetector:!1,username:null,password:null,db:0,enableOfflineQueue:!0,enableReadyCheck:!0,autoResubscribe:!0,autoResendUnfulfilledCommands:!0,lazyConnect:!1,keyPrefix:"",reconnectOnError:null,readOnly:!1,stringNumbers:!1,maxRetriesPerRequest:20,maxLoadingRetryTime:1e4,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],sentinelMaxConnections:10}});var L1=D((d$)=>{Object.defineProperty(d$,"__esModule",{value:!0});var c$=N1(),l$=j("events"),G0=Q1(),FY=F0(),R0=w1(),LY=H$(),WY=GS(),z1=p$(),zY=t$(),BY=LS(),VY=$0(),y1=p(),HY=E0(),UY=BS(),B1=YS(),m$=HS(),V1=(0,y1.Debug)("redis");class S1 extends UY.default{constructor(S,w,$){super();if(this.status="wait",this.isCluster=!1,this.reconnectTimeout=null,this.connectionEpoch=0,this.retryAttempts=0,this.manuallyClosing=!1,this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this.parseOptions(S,w,$),l$.EventEmitter.call(this),this.resetCommandQueue(),this.resetOfflineQueue(),this.options.Connector)this.connector=new this.options.Connector(this.options);else if(this.options.sentinels){let E=new WY.default(this.options);E.emitter=this,this.connector=E}else this.connector=new LY.StandaloneConnector(this.options);if(this.options.scripts)Object.entries(this.options.scripts).forEach(([E,Y])=>{this.defineCommand(E,Y)});if(this.options.lazyConnect)this.setStatus("wait");else this.connect().catch(B1.noop)}static createClient(...S){return new S1(...S)}get autoPipelineQueueSize(){let S=0;for(let w of this._autoPipelines.values())S+=w.length;return S}connect(S){let w=new Promise(($,E)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){E(Error("Redis is already connecting/connected"));return}this.connectionEpoch+=1,this.setStatus("connecting");let{options:Y}=this;this.condition={select:Y.db,auth:Y.username?[Y.username,Y.password]:Y.password,subscriber:!1};let J=this;(0,G0.default)(this.connector.connect(function(Q,X){J.silentEmit(Q,X)}),function(Q,X){if(Q){J.flushQueue(Q),J.silentEmit("error",Q),E(Q),J.setStatus("end");return}let Z=Y.tls?"secureConnect":"connect";if("sentinels"in Y&&Y.sentinels&&!Y.enableTLSForSentinelMode)Z="connect";if(J.stream=X,Y.noDelay)X.setNoDelay(!0);if(typeof Y.keepAlive==="number")if(X.connecting)X.once(Z,()=>{X.setKeepAlive(!0,Y.keepAlive)});else X.setKeepAlive(!0,Y.keepAlive);if(X.connecting){if(X.once(Z,z1.connectHandler(J)),Y.connectTimeout){let W=!1;X.setTimeout(Y.connectTimeout,function(){if(W)return;X.setTimeout(0),X.destroy();let H=Error("connect ETIMEDOUT");H.errorno="ETIMEDOUT",H.code="ETIMEDOUT",H.syscall="connect",z1.errorHandler(J)(H)}),X.once(Z,function(){W=!0,X.setTimeout(0)})}}else if(X.destroyed){let W=J.connector.firstError;if(W)process.nextTick(()=>{z1.errorHandler(J)(W)});process.nextTick(z1.closeHandler(J))}else process.nextTick(z1.connectHandler(J));if(!X.destroyed)X.once("error",z1.errorHandler(J)),X.once("close",z1.closeHandler(J));let B=function(){J.removeListener("close",z),$()};var z=function(){J.removeListener("ready",B),E(Error(y1.CONNECTION_CLOSED_ERROR_MSG))};J.once("ready",B),J.once("close",z)})});return(0,G0.default)(w,S)}disconnect(S=!1){if(!S)this.manuallyClosing=!0;if(this.reconnectTimeout&&!S)clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null;if(this.status==="wait")z1.closeHandler(this)();else this.connector.disconnect()}end(){this.disconnect()}duplicate(S){return new S1({...this.options,...S})}get mode(){var S;return this.options.monitor?"monitor":((S=this.condition)===null||S===void 0?void 0:S.subscriber)?"subscriber":"normal"}monitor(S){let w=this.duplicate({monitor:!0,lazyConnect:!1});return(0,G0.default)(new Promise(function($,E){w.once("error",E),w.once("monitoring",function(){$(w)})}),S)}sendCommand(S,w){var $,E;if(this.status==="wait")this.connect().catch(B1.noop);if(this.status==="end")return S.reject(Error(y1.CONNECTION_CLOSED_ERROR_MSG)),S.promise;if((($=this.condition)===null||$===void 0?void 0:$.subscriber)&&!R0.default.checkFlag("VALID_IN_SUBSCRIBER_MODE",S.name))return S.reject(Error("Connection in subscriber mode, only subscriber commands may be used")),S.promise;if(typeof this.options.commandTimeout==="number")S.setTimeout(this.options.commandTimeout);let Y=this.status==="ready"||!w&&this.status==="connect"&&(0,c$.exists)(S.name)&&(0,c$.hasFlag)(S.name,"loading");if(!this.stream)Y=!1;else if(!this.stream.writable)Y=!1;else if(this.stream._writableState&&this.stream._writableState.ended)Y=!1;if(!Y){if(!this.options.enableOfflineQueue)return S.reject(Error("Stream isn't writeable and enableOfflineQueue options is false")),S.promise;if(S.name==="quit"&&this.offlineQueue.length===0)return this.disconnect(),S.resolve(Buffer.from("OK")),S.promise;if(V1.enabled)V1("queue command[%s]: %d -> %s(%o)",this._getDescription(),this.condition.select,S.name,S.args);this.offlineQueue.push({command:S,stream:w,select:this.condition.select})}else{if(V1.enabled)V1("write command[%s]: %d -> %s(%o)",this._getDescription(),(E=this.condition)===null||E===void 0?void 0:E.select,S.name,S.args);if(w)if("isPipeline"in w&&w.isPipeline)w.write(S.toWritable(w.destination.redis.stream));else w.write(S.toWritable(w));else this.stream.write(S.toWritable(this.stream));if(this.commandQueue.push({command:S,stream:w,select:this.condition.select}),R0.default.checkFlag("WILL_DISCONNECT",S.name))this.manuallyClosing=!0;if(this.options.socketTimeout!==void 0&&this.socketTimeoutTimer===void 0)this.setSocketTimeout()}if(S.name==="select"&&(0,y1.isInt)(S.args[0])){let J=parseInt(S.args[0],10);if(this.condition.select!==J)this.condition.select=J,this.emit("select",J),V1("switch to db [%d]",this.condition.select)}return S.promise}setSocketTimeout(){this.socketTimeoutTimer=setTimeout(()=>{this.stream.destroy(Error(`Socket timeout. Expecting data, but didn't receive any in ${this.options.socketTimeout}ms.`)),this.socketTimeoutTimer=void 0},this.options.socketTimeout),this.stream.once("data",()=>{if(clearTimeout(this.socketTimeoutTimer),this.socketTimeoutTimer=void 0,this.commandQueue.length===0)return;this.setSocketTimeout()})}scanStream(S){return this.createScanStream("scan",{options:S})}scanBufferStream(S){return this.createScanStream("scanBuffer",{options:S})}sscanStream(S,w){return this.createScanStream("sscan",{key:S,options:w})}sscanBufferStream(S,w){return this.createScanStream("sscanBuffer",{key:S,options:w})}hscanStream(S,w){return this.createScanStream("hscan",{key:S,options:w})}hscanBufferStream(S,w){return this.createScanStream("hscanBuffer",{key:S,options:w})}zscanStream(S,w){return this.createScanStream("zscan",{key:S,options:w})}zscanBufferStream(S,w){return this.createScanStream("zscanBuffer",{key:S,options:w})}silentEmit(S,w){let $;if(S==="error"){if($=w,this.status==="end")return;if(this.manuallyClosing){if($ instanceof Error&&($.message===y1.CONNECTION_CLOSED_ERROR_MSG||$.syscall==="connect"||$.syscall==="read"))return}}if(this.listeners(S).length>0)return this.emit.apply(this,arguments);if($&&$ instanceof Error)console.error("[ioredis] Unhandled error event:",$.stack);return!1}recoverFromFatalError(S,w,$){this.flushQueue(w,$),this.silentEmit("error",w),this.disconnect(!0)}handleReconnection(S,w){var $;let E=!1;if(this.options.reconnectOnError)E=this.options.reconnectOnError(S);switch(E){case 1:case!0:if(this.status!=="reconnecting")this.disconnect(!0);w.command.reject(S);break;case 2:if(this.status!=="reconnecting")this.disconnect(!0);if((($=this.condition)===null||$===void 0?void 0:$.select)!==w.select&&w.command.name!=="select")this.select(w.select);this.sendCommand(w.command);break;default:w.command.reject(S)}}_getDescription(){let S;if("path"in this.options&&this.options.path)S=this.options.path;else if(this.stream&&this.stream.remoteAddress&&this.stream.remotePort)S=this.stream.remoteAddress+":"+this.stream.remotePort;else if("host"in this.options&&this.options.host)S=this.options.host+":"+this.options.port;else S="";if(this.options.connectionName)S+=` (${this.options.connectionName})`;return S}resetCommandQueue(){this.commandQueue=new m$}resetOfflineQueue(){this.offlineQueue=new m$}parseOptions(...S){let w={},$=!1;for(let E=0;E<S.length;++E){let Y=S[E];if(Y===null||typeof Y>"u")continue;if(typeof Y==="object")(0,B1.defaults)(w,Y);else if(typeof Y==="string"){if((0,B1.defaults)(w,(0,y1.parseURL)(Y)),Y.startsWith("rediss://"))$=!0}else if(typeof Y==="number")w.port=Y;else throw Error("Invalid argument "+Y)}if($)(0,B1.defaults)(w,{tls:!0});if((0,B1.defaults)(w,S1.defaultOptions),typeof w.port==="string")w.port=parseInt(w.port,10);if(typeof w.db==="string")w.db=parseInt(w.db,10);this.options=(0,y1.resolveTLSProfile)(w)}setStatus(S,w){if(V1.enabled)V1("status[%s]: %s -> %s",this._getDescription(),this.status||"[empty]",S);this.status=S,process.nextTick(this.emit.bind(this,S,w))}createScanStream(S,{key:w,options:$={}}){return new BY.default({objectMode:!0,key:w,redis:this,command:S,...$})}flushQueue(S,w){w=(0,B1.defaults)({},w,{offlineQueue:!0,commandQueue:!0});let $;if(w.offlineQueue)while($=this.offlineQueue.shift())$.command.reject(S);if(w.commandQueue){if(this.commandQueue.length>0){if(this.stream)this.stream.removeAllListeners("data");while($=this.commandQueue.shift())$.command.reject(S)}}}_readyCheck(S){let w=this;this.info(function($,E){if($){if($.message&&$.message.includes("NOPERM"))return console.warn(`Skipping the ready check because INFO command fails: "${$.message}". You can disable ready check with "enableReadyCheck". More: https://github.com/luin/ioredis/wiki/Disable-ready-check.`),S(null,{});return S($)}if(typeof E!=="string")return S(null,E);let Y={},J=E.split(`\r
|
|
160
|
+
`);for(let Q=0;Q<J.length;++Q){let[X,...Z]=J[Q].split(":"),B=Z.join(":");if(B)Y[X]=B}if(!Y.loading||Y.loading==="0")S(null,Y);else{let Q=(Y.loading_eta_seconds||1)*1000,X=w.options.maxLoadingRetryTime&&w.options.maxLoadingRetryTime<Q?w.options.maxLoadingRetryTime:Q;V1("Redis server still loading, trying again in "+X+"ms"),setTimeout(function(){w._readyCheck(S)},X)}}).catch(B1.noop)}}S1.Cluster=FY.default;S1.Command=R0.default;S1.defaultOptions=zY.DEFAULT_REDIS_OPTIONS;(0,HY.default)(S1,l$.EventEmitter);(0,VY.addTransactionSupport)(S1.prototype);d$.default=S1});var s$=D((t,n$)=>{Object.defineProperty(t,"__esModule",{value:!0});t.print=t.ReplyError=t.SentinelIterator=t.SentinelConnector=t.AbstractConnector=t.Pipeline=t.ScanStream=t.Command=t.Cluster=t.Redis=t.default=void 0;t=n$.exports=L1().default;var GY=L1();Object.defineProperty(t,"default",{enumerable:!0,get:function(){return GY.default}});var RY=L1();Object.defineProperty(t,"Redis",{enumerable:!0,get:function(){return RY.default}});var yY=F0();Object.defineProperty(t,"Cluster",{enumerable:!0,get:function(){return yY.default}});var TY=w1();Object.defineProperty(t,"Command",{enumerable:!0,get:function(){return TY.default}});var AY=LS();Object.defineProperty(t,"ScanStream",{enumerable:!0,get:function(){return AY.default}});var DY=eS();Object.defineProperty(t,"Pipeline",{enumerable:!0,get:function(){return DY.default}});var kY=qS();Object.defineProperty(t,"AbstractConnector",{enumerable:!0,get:function(){return kY.default}});var o$=GS();Object.defineProperty(t,"SentinelConnector",{enumerable:!0,get:function(){return o$.default}});Object.defineProperty(t,"SentinelIterator",{enumerable:!0,get:function(){return o$.SentinelIterator}});t.ReplyError=H1().ReplyError;Object.defineProperty(t,"Promise",{get(){return console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used."),Promise},set(S){console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.")}});function IY(S,w){if(S)console.log("Error: "+S);else console.log("Reply: "+w)}t.print=IY});var e$=D(()=>{/*! *****************************************************************************
|
|
161
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
162
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
163
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
164
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
165
|
+
|
|
166
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
167
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
168
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
169
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
170
|
+
|
|
171
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
172
|
+
and limitations under the License.
|
|
173
|
+
***************************************************************************** */var r$;(function(S){(function(w){var $=typeof globalThis==="object"?globalThis:typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:X(),E=Y(S);if(typeof $.Reflect<"u")E=Y($.Reflect,E);if(w(E,$),typeof $.Reflect>"u")$.Reflect=S;function Y(Z,B){return function(z,W){if(Object.defineProperty(Z,z,{configurable:!0,writable:!0,value:W}),B)B(z,W)}}function J(){try{return Function("return this;")()}catch(Z){}}function Q(){try{return(0,eval)("(function() { return this; })()")}catch(Z){}}function X(){return J()||Q()}})(function(w,$){var E=Object.prototype.hasOwnProperty,Y=typeof Symbol==="function",J=Y&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",Q=Y&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",X=typeof Object.create==="function",Z={__proto__:[]}instanceof Array,B=!X&&!Z,z={create:X?function(){return hS(Object.create(null))}:Z?function(){return hS({__proto__:null})}:function(){return hS({})},has:B?function(F,L){return E.call(F,L)}:function(F,L){return L in F},get:B?function(F,L){return E.call(F,L)?F[L]:void 0}:function(F,L){return F[L]}},W=Object.getPrototypeOf(Function),H=typeof Map==="function"&&typeof Map.prototype.entries==="function"?Map:B4(),G=typeof Set==="function"&&typeof Set.prototype.entries==="function"?Set:V4(),N=typeof WeakMap==="function"?WeakMap:H4(),h=Y?Symbol.for("@reflect-metadata:registry"):void 0,P=L4(),c=W4(P);function D1(F,L,V,U){if(!k(V)){if(!j0(F))throw TypeError();if(!K(L))throw TypeError();if(!K(U)&&!k(U)&&!I1(U))throw TypeError();if(I1(U))U=void 0;return V=r(V),E4(F,L,V,U)}else{if(!j0(F))throw TypeError();if(!h0(L))throw TypeError();return $4(F,L)}}w("decorate",D1);function IS(F,L){function V(U,A){if(!K(U))throw TypeError();if(!k(A)&&!Z4(A))throw TypeError();I0(F,L,U,A)}return V}w("metadata",IS);function k1(F,L,V,U){if(!K(V))throw TypeError();if(!k(U))U=r(U);return I0(F,L,V,U)}w("defineMetadata",k1);function T0(F,L,V){if(!K(L))throw TypeError();if(!k(V))V=r(V);return A0(F,L,V)}w("hasMetadata",T0);function g1(F,L,V){if(!K(L))throw TypeError();if(!k(V))V=r(V);return PS(F,L,V)}w("hasOwnMetadata",g1);function MS(F,L,V){if(!K(L))throw TypeError();if(!k(V))V=r(V);return D0(F,L,V)}w("getMetadata",MS);function wS(F,L,V){if(!K(L))throw TypeError();if(!k(V))V=r(V);return k0(F,L,V)}w("getOwnMetadata",wS);function NS(F,L){if(!K(F))throw TypeError();if(!k(L))L=r(L);return M0(F,L)}w("getMetadataKeys",NS);function S4(F,L){if(!K(F))throw TypeError();if(!k(L))L=r(L);return N0(F,L)}w("getOwnMetadataKeys",S4);function w4(F,L,V){if(!K(L))throw TypeError();if(!k(V))V=r(V);if(!K(L))throw TypeError();if(!k(V))V=r(V);var U=v1(L,V,!1);if(k(U))return!1;return U.OrdinaryDeleteMetadata(F,L,V)}w("deleteMetadata",w4);function $4(F,L){for(var V=F.length-1;V>=0;--V){var U=F[V],A=U(L);if(!k(A)&&!I1(A)){if(!h0(A))throw TypeError();L=A}}return L}function E4(F,L,V,U){for(var A=F.length-1;A>=0;--A){var f=F[A],g=f(L,V,U);if(!k(g)&&!I1(g)){if(!K(g))throw TypeError();U=g}}return U}function A0(F,L,V){var U=PS(F,L,V);if(U)return!0;var A=jS(L);if(!I1(A))return A0(F,A,V);return!1}function PS(F,L,V){var U=v1(L,V,!1);if(k(U))return!1;return C0(U.OrdinaryHasOwnMetadata(F,L,V))}function D0(F,L,V){var U=PS(F,L,V);if(U)return k0(F,L,V);var A=jS(L);if(!I1(A))return D0(F,A,V);return}function k0(F,L,V){var U=v1(L,V,!1);if(k(U))return;return U.OrdinaryGetOwnMetadata(F,L,V)}function I0(F,L,V,U){var A=v1(V,U,!0);A.OrdinaryDefineOwnMetadata(F,L,V,U)}function M0(F,L){var V=N0(F,L),U=jS(F);if(U===null)return V;var A=M0(U,L);if(A.length<=0)return V;if(V.length<=0)return A;var f=new G,g=[];for(var I=0,q=V;I<q.length;I++){var R=q[I],y=f.has(R);if(!y)f.add(R),g.push(R)}for(var T=0,M=A;T<M.length;T++){var R=M[T],y=f.has(R);if(!y)f.add(R),g.push(R)}return g}function N0(F,L){var V=v1(F,L,!1);if(!V)return[];return V.OrdinaryOwnMetadataKeys(F,L)}function P0(F){if(F===null)return 1;switch(typeof F){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return F===null?1:6;default:return 6}}function k(F){return F===void 0}function I1(F){return F===null}function Y4(F){return typeof F==="symbol"}function K(F){return typeof F==="object"?F!==null:typeof F==="function"}function J4(F,L){switch(P0(F)){case 0:return F;case 1:return F;case 2:return F;case 3:return F;case 4:return F;case 5:return F}var V=L===3?"string":L===5?"number":"default",U=x0(F,J);if(U!==void 0){var A=U.call(F,V);if(K(A))throw TypeError();return A}return Q4(F,V==="default"?"number":V)}function Q4(F,L){if(L==="string"){var V=F.toString;if(M1(V)){var U=V.call(F);if(!K(U))return U}var A=F.valueOf;if(M1(A)){var U=A.call(F);if(!K(U))return U}}else{var A=F.valueOf;if(M1(A)){var U=A.call(F);if(!K(U))return U}var f=F.toString;if(M1(f)){var U=f.call(F);if(!K(U))return U}}throw TypeError()}function C0(F){return!!F}function X4(F){return""+F}function r(F){var L=J4(F,3);if(Y4(L))return L;return X4(L)}function j0(F){return Array.isArray?Array.isArray(F):F instanceof Object?F instanceof Array:Object.prototype.toString.call(F)==="[object Array]"}function M1(F){return typeof F==="function"}function h0(F){return typeof F==="function"}function Z4(F){switch(P0(F)){case 3:return!0;case 4:return!0;default:return!1}}function CS(F,L){return F===L||F!==F&&L!==L}function x0(F,L){var V=F[L];if(V===void 0||V===null)return;if(!M1(V))throw TypeError();return V}function O0(F){var L=x0(F,Q);if(!M1(L))throw TypeError();var V=L.call(F);if(!K(V))throw TypeError();return V}function K0(F){return F.value}function f0(F){var L=F.next();return L.done?!1:L}function _0(F){var L=F.return;if(L)L.call(F)}function jS(F){var L=Object.getPrototypeOf(F);if(typeof F!=="function"||F===W)return L;if(L!==W)return L;var V=F.prototype,U=V&&Object.getPrototypeOf(V);if(U==null||U===Object.prototype)return L;var A=U.constructor;if(typeof A!=="function")return L;if(A===F)return L;return A}function F4(){var F;if(!k(h)&&typeof $.Reflect<"u"&&!(h in $.Reflect)&&typeof $.Reflect.defineMetadata==="function")F=z4($.Reflect);var L,V,U,A=new N,f={registerProvider:g,getProvider:q,setProvider:y};return f;function g(T){if(!Object.isExtensible(f))throw Error("Cannot add provider to a frozen registry.");switch(!0){case F===T:break;case k(L):L=T;break;case L===T:break;case k(V):V=T;break;case V===T:break;default:if(U===void 0)U=new G;U.add(T);break}}function I(T,M){if(!k(L)){if(L.isProviderFor(T,M))return L;if(!k(V)){if(V.isProviderFor(T,M))return L;if(!k(U)){var C=O0(U);while(!0){var _=f0(C);if(!_)return;var n=K0(_);if(n.isProviderFor(T,M))return _0(C),n}}}}if(!k(F)&&F.isProviderFor(T,M))return F;return}function q(T,M){var C=A.get(T),_;if(!k(C))_=C.get(M);if(!k(_))return _;if(_=I(T,M),!k(_)){if(k(C))C=new H,A.set(T,C);C.set(M,_)}return _}function R(T){if(k(T))throw TypeError();return L===T||V===T||!k(U)&&U.has(T)}function y(T,M,C){if(!R(C))throw Error("Metadata provider not registered.");var _=q(T,M);if(_!==C){if(!k(_))return!1;var n=A.get(T);if(k(n))n=new H,A.set(T,n);n.set(M,C)}return!0}}function L4(){var F;if(!k(h)&&K($.Reflect)&&Object.isExtensible($.Reflect))F=$.Reflect[h];if(k(F))F=F4();if(!k(h)&&K($.Reflect)&&Object.isExtensible($.Reflect))Object.defineProperty($.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:F});return F}function W4(F){var L=new N,V={isProviderFor:function(R,y){var T=L.get(R);if(k(T))return!1;return T.has(y)},OrdinaryDefineOwnMetadata:g,OrdinaryHasOwnMetadata:A,OrdinaryGetOwnMetadata:f,OrdinaryOwnMetadataKeys:I,OrdinaryDeleteMetadata:q};return P.registerProvider(V),V;function U(R,y,T){var M=L.get(R),C=!1;if(k(M)){if(!T)return;M=new H,L.set(R,M),C=!0}var _=M.get(y);if(k(_)){if(!T)return;if(_=new H,M.set(y,_),!F.setProvider(R,y,V)){if(M.delete(y),C)L.delete(R);throw Error("Wrong provider for target.")}}return _}function A(R,y,T){var M=U(y,T,!1);if(k(M))return!1;return C0(M.has(R))}function f(R,y,T){var M=U(y,T,!1);if(k(M))return;return M.get(R)}function g(R,y,T,M){var C=U(T,M,!0);C.set(R,y)}function I(R,y){var T=[],M=U(R,y,!1);if(k(M))return T;var C=M.keys(),_=O0(C),n=0;while(!0){var g0=f0(_);if(!g0)return T.length=n,T;var U4=K0(g0);try{T[n]=U4}catch(q4){try{_0(_)}finally{throw q4}}n++}}function q(R,y,T){var M=U(y,T,!1);if(k(M))return!1;if(!M.delete(R))return!1;if(M.size===0){var C=L.get(y);if(!k(C)){if(C.delete(T),C.size===0)L.delete(C)}}return!0}}function z4(F){var{defineMetadata:L,hasOwnMetadata:V,getOwnMetadata:U,getOwnMetadataKeys:A,deleteMetadata:f}=F,g=new N,I={isProviderFor:function(q,R){var y=g.get(q);if(!k(y)&&y.has(R))return!0;if(A(q,R).length){if(k(y))y=new G,g.set(q,y);return y.add(R),!0}return!1},OrdinaryDefineOwnMetadata:L,OrdinaryHasOwnMetadata:V,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:A,OrdinaryDeleteMetadata:f};return I}function v1(F,L,V){var U=P.getProvider(F,L);if(!k(U))return U;if(V){if(P.setProvider(F,L,c))return c;throw Error("Illegal state.")}return}function B4(){var F={},L=[],V=function(){function I(q,R,y){this._index=0,this._keys=q,this._values=R,this._selector=y}return I.prototype["@@iterator"]=function(){return this},I.prototype[Q]=function(){return this},I.prototype.next=function(){var q=this._index;if(q>=0&&q<this._keys.length){var R=this._selector(this._keys[q],this._values[q]);if(q+1>=this._keys.length)this._index=-1,this._keys=L,this._values=L;else this._index++;return{value:R,done:!1}}return{value:void 0,done:!0}},I.prototype.throw=function(q){if(this._index>=0)this._index=-1,this._keys=L,this._values=L;throw q},I.prototype.return=function(q){if(this._index>=0)this._index=-1,this._keys=L,this._values=L;return{value:q,done:!0}},I}(),U=function(){function I(){this._keys=[],this._values=[],this._cacheKey=F,this._cacheIndex=-2}return Object.defineProperty(I.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),I.prototype.has=function(q){return this._find(q,!1)>=0},I.prototype.get=function(q){var R=this._find(q,!1);return R>=0?this._values[R]:void 0},I.prototype.set=function(q,R){var y=this._find(q,!0);return this._values[y]=R,this},I.prototype.delete=function(q){var R=this._find(q,!1);if(R>=0){var y=this._keys.length;for(var T=R+1;T<y;T++)this._keys[T-1]=this._keys[T],this._values[T-1]=this._values[T];if(this._keys.length--,this._values.length--,CS(q,this._cacheKey))this._cacheKey=F,this._cacheIndex=-2;return!0}return!1},I.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=F,this._cacheIndex=-2},I.prototype.keys=function(){return new V(this._keys,this._values,A)},I.prototype.values=function(){return new V(this._keys,this._values,f)},I.prototype.entries=function(){return new V(this._keys,this._values,g)},I.prototype["@@iterator"]=function(){return this.entries()},I.prototype[Q]=function(){return this.entries()},I.prototype._find=function(q,R){if(!CS(this._cacheKey,q)){this._cacheIndex=-1;for(var y=0;y<this._keys.length;y++)if(CS(this._keys[y],q)){this._cacheIndex=y;break}}if(this._cacheIndex<0&&R)this._cacheIndex=this._keys.length,this._keys.push(q),this._values.push(void 0);return this._cacheIndex},I}();return U;function A(I,q){return I}function f(I,q){return q}function g(I,q){return[I,q]}}function V4(){var F=function(){function L(){this._map=new H}return Object.defineProperty(L.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),L.prototype.has=function(V){return this._map.has(V)},L.prototype.add=function(V){return this._map.set(V,V),this},L.prototype.delete=function(V){return this._map.delete(V)},L.prototype.clear=function(){this._map.clear()},L.prototype.keys=function(){return this._map.keys()},L.prototype.values=function(){return this._map.keys()},L.prototype.entries=function(){return this._map.entries()},L.prototype["@@iterator"]=function(){return this.keys()},L.prototype[Q]=function(){return this.keys()},L}();return F}function H4(){var F=16,L=z.create(),V=U();return function(){function q(){this._key=U()}return q.prototype.has=function(R){var y=A(R,!1);return y!==void 0?z.has(y,this._key):!1},q.prototype.get=function(R){var y=A(R,!1);return y!==void 0?z.get(y,this._key):void 0},q.prototype.set=function(R,y){var T=A(R,!0);return T[this._key]=y,this},q.prototype.delete=function(R){var y=A(R,!1);return y!==void 0?delete y[this._key]:!1},q.prototype.clear=function(){this._key=U()},q}();function U(){var q;do q="@@WeakMap@@"+I();while(z.has(L,q));return L[q]=!0,q}function A(q,R){if(!E.call(q,V)){if(!R)return;Object.defineProperty(q,V,{value:z.create()})}return q[V]}function f(q,R){for(var y=0;y<R;++y)q[y]=Math.random()*255|0;return q}function g(q){if(typeof Uint8Array==="function"){var R=new Uint8Array(q);if(typeof crypto<"u")crypto.getRandomValues(R);else if(typeof msCrypto<"u")msCrypto.getRandomValues(R);else f(R,q);return R}return f(Array(q),q)}function I(){var q=g(F);q[6]=q[6]&79|64,q[8]=q[8]&191|128;var R="";for(var y=0;y<F;++y){var T=q[y];if(y===4||y===6||y===8)R+="-";if(T<16)R+="0";R+=T.toString(16).toLowerCase()}return R}}function hS(F){return F.__=void 0,delete F.__,F}})})(r$||(r$={}))});var a$=b0(s$(),1);import*as E1 from"fs/promises";var TS;((E)=>{E.SQLite="sqlite";E.MySQL="mysql";E.Postgres="postgres"})(TS||={});var y0;((Y)=>{Y.ERROR="error";Y.WARN="warn";Y.INFO="info";Y.DEBUG="debug"})(y0||={});var AS;((Y)=>{Y.OneToOne="one-to-one";Y.OneToMany="one-to-many";Y.ManyToOne="many-to-one";Y.ManyToMany="many-to-many"})(AS||={});class b extends Error{code;constructor(S,w){super(S);this.code=w;this.name="StabilizeError"}}class Y1{level;filePath;maxFileSize;maxFiles;currentFileSize=0;constructor(S={}){this.level=S.level||"info",this.filePath=S.filePath||null,this.maxFileSize=S.maxFileSize||1048576,this.maxFiles=S.maxFiles||3}shouldLog(S){let w=["error","warn","info","debug"];return w.indexOf(S)<=w.indexOf(this.level)}async rotateLogFile(){if(!this.filePath)return;try{let S=await E1.stat(this.filePath).catch(()=>null);if(S&&S.size>=this.maxFileSize){for(let w=this.maxFiles-1;w>0;w--){let $=w===1?this.filePath:`${this.filePath}.${w-1}`,E=`${this.filePath}.${w}`;if(await E1.stat($).catch(()=>null))await E1.rename($,E).catch(()=>{})}await E1.writeFile(this.filePath,""),this.currentFileSize=0}}catch(S){console.error("Log rotation failed:",S)}}async writeToFile(S){if(!this.filePath)return;try{await this.rotateLogFile();let w=`${new Date().toISOString()} ${S}
|
|
174
|
+
`;await E1.appendFile(this.filePath,w),this.currentFileSize+=Buffer.byteLength(w)}catch(w){console.error("Failed to write to log file:",w)}}logQuery(S,w,$){if(this.shouldLog("debug")){let E=`[DEBUG] Query: ${S} | Params: ${JSON.stringify(w)} | Time: ${$?`${$.toFixed(2)}ms`:"N/A"}`;if(console.log(E),this.filePath)this.writeToFile(E)}}logError(S){if(this.shouldLog("error")){let w=`[ERROR] ${S.message}${S.stack?`
|
|
175
|
+
${S.stack}`:""}`;if(console.error(w),this.filePath)this.writeToFile(w)}}logMetrics(S){if(this.shouldLog("info")){let w=`[INFO] Pool Metrics: Active=${S.activeConnections}, Idle=${S.idleConnections}, Total=${S.totalConnections}`;if(console.log(w),this.filePath)this.writeToFile(w)}}logInfo(S){if(this.shouldLog("info")){let w=`[INFO] ${S}`;if(console.log(w),this.filePath)this.writeToFile(w)}}logDebug(S){if(this.shouldLog("debug")){let w=`[DEBUG] ${S}`;if(console.log(w),this.filePath)this.writeToFile(w)}}}class r1{redis=null;ttl;prefix;strategy;logger;hits=0;misses=0;constructor(S,w=new Y1){if(this.ttl=S.ttl,this.prefix=S.cachePrefix||"cache:",this.strategy=S.strategy||"cache-aside",this.logger=w,S.enabled&&S.redisUrl)this.redis=new a$.default(S.redisUrl,{lazyConnect:!0}),this.redis.on("error",($)=>this.logger.logError($))}getStrategy(){return this.strategy}async get(S){if(!this.redis)return null;try{let w=await this.redis.get(this.prefix+S);if(w)return this.hits++,this.logger.logDebug(`Cache hit for key: ${S}`),JSON.parse(w);return this.misses++,this.logger.logDebug(`Cache miss for key: ${S}`),null}catch(w){return this.logger.logError(w),null}}async set(S,w,$=this.ttl){if(!this.redis)return;try{await this.redis.set(this.prefix+S,JSON.stringify(w),"EX",$),this.logger.logDebug(`Cache set for key: ${S}`)}catch(E){this.logger.logError(E)}}async invalidate(S){if(!this.redis)return;try{let w=this.redis.pipeline();for(let $ of S)w.del(this.prefix+$),this.logger.logDebug(`Cache invalidated for key: ${$}`);await w.exec()}catch(w){this.logger.logError(w)}}async invalidatePattern(S){if(!this.redis)return;try{let w=await this.redis.keys(this.prefix+S);if(w.length>0){let $=this.redis.pipeline();for(let E of w)$.del(E),this.logger.logDebug(`Cache invalidated for pattern: ${S}`);await $.exec()}}catch(w){this.logger.logError(w)}}async getStats(){if(!this.redis)return{hits:0,misses:0,keys:0};try{let S=await this.redis.keys(this.prefix+"*");return{hits:this.hits,misses:this.misses,keys:S.length}}catch(S){return this.logger.logError(S),{hits:this.hits,misses:this.misses,keys:0}}}async disconnect(){if(this.redis)await this.redis.quit(),this.logger.logInfo("Redis connection closed")}}var{SQL:NY}=globalThis.Bun;import{Database as e1}from"bun:sqlite";function PY(S){return S.type==="sqlite"||S.connectionString.includes("sqlite")}class SS{client=null;logger;retryAttempts;retryDelay;maxJitter;preparedStatements=new Map;config;constructor(S,w=new Y1){this.config=S,this.logger=w,this.retryAttempts=S.retryAttempts||3,this.retryDelay=S.retryDelay||1000,this.maxJitter=S.maxJitter||100,this.initializeClient(S)}initializeClient(S){if(PY(S))try{this.client=new e1(S.connectionString,{create:!0}),this.logger.logDebug(`Initialized Bun SQLite client for: ${S.connectionString}`)}catch(w){throw this.logger.logError(w),new b(`Failed to initialize SQLite database: ${w.message}`,"INIT_ERROR")}else this.client=new NY(S.connectionString),this.logger.logDebug(`Initialized Bun SQL client for: ${S.connectionString}`)}getJitter(){return Math.random()*this.maxJitter}getPoolMetrics(){return{activeConnections:0,idleConnections:0,totalConnections:this.client instanceof e1?1:0}}async switchConnection(S){await this.close(),this.config=S,this.preparedStatements.clear(),this.retryAttempts=S.retryAttempts||3,this.retryDelay=S.retryDelay||1000,this.maxJitter=S.maxJitter||100,this.initializeClient(S)}async query(S,w=[]){let $=Date.now();this.logger.logQuery(S,w),this.logger.logMetrics(this.getPoolMetrics());let E;if(this.client instanceof e1){let Y=S;if(!this.preparedStatements.has(Y))this.preparedStatements.set(Y,this.client.prepare(S));E=this.preparedStatements.get(Y)}for(let Y=1;Y<=this.retryAttempts;Y++)try{let J;if(E)J=E.all(...w);else if(this.client)J=await this.client.unsafe(S,w);else throw new b("Database client is not initialized or does not support query execution.","INIT_ERROR");let Q=Date.now()-$;return this.logger.logQuery(S,w,Q),J}catch(J){if(this.logger.logError(J),Y===this.retryAttempts)throw new b(`Query failed after ${this.retryAttempts} attempts: ${J.message}`,"QUERY_ERROR");await new Promise((Q)=>setTimeout(Q,this.retryDelay*Math.pow(2,Y-1)+this.getJitter()))}throw new b("Query failed: no attempts made","QUERY_ERROR")}async transaction(S){if(this.client instanceof e1){let $=Date.now();this.logger.logDebug("Starting native SQLite transaction");let E=this.client.transaction(async()=>{return S()});try{let Y=await E();return this.logger.logDebug(`Native transaction committed in ${Date.now()-$}ms`),Y}catch(Y){throw this.logger.logError(Y),new b(`Native transaction failed: ${Y.message}`,"TX_ERROR")}}let w=Date.now();this.logger.logDebug("Starting manual transaction (non-SQLite)");for(let $=1;$<=this.retryAttempts;$++)try{await this.query("BEGIN",[]);let E=await S();return await this.query("COMMIT",[]),this.logger.logDebug(`Manual transaction committed in ${Date.now()-w}ms`),E}catch(E){if(await this.query("ROLLBACK",[]).catch(()=>{this.logger.logDebug("Rollback failed. Connection may be invalid.")}),this.logger.logError(E),$===this.retryAttempts)throw new b(`Manual transaction failed after ${this.retryAttempts} attempts: ${E.message}`,"TX_ERROR");await new Promise((Y)=>setTimeout(Y,this.retryDelay*Math.pow(2,$-1)+this.getJitter()))}throw new b("Transaction failed: no attempts made","TX_ERROR")}async savepoint(S,w){let $=Date.now();this.logger.logDebug(`Starting savepoint ${S}`),await this.query(`SAVEPOINT ${S}`,[]);try{let E=await w();return await this.query(`RELEASE SAVEPOINT ${S}`,[]),this.logger.logDebug(`Savepoint ${S} released in ${Date.now()-$}ms`),E}catch(E){throw await this.query(`ROLLBACK TO SAVEPOINT ${S}`,[]).catch(()=>{this.logger.logDebug(`Rollback to savepoint ${S} failed. Connection may be invalid.`)}),this.logger.logError(E),E}}async close(){if(this.preparedStatements.clear(),this.client instanceof e1)this.client.close(),this.client=null;else if(this.client&&typeof this.client.close==="function")await this.client.close(),this.client=null;this.logger.logInfo("Database connection closed")}}class DS{table;selectFields=["*"];joins=[];whereConditions=[];whereParams=[];orderByClause=null;limitValue=null;offsetValue=null;hints=[];constructor(S){this.table=S}select(...S){return this.selectFields=S.length>0?S:["*"],this}where(S,...w){return this.whereConditions.push(S),this.whereParams.push(...w),this}join(S,w){return this.joins.push(`LEFT JOIN ${S} ON ${w}`),this}orderBy(S){return this.orderByClause=S,this}limit(S){return this.limitValue=S,this}offset(S){return this.offsetValue=S,this}hint(S){return this.hints.push(S),this}build(){let S=`SELECT ${this.selectFields.join(", ")} FROM ${this.table}`;if(this.hints.length>0)S=`SELECT ${this.hints.map(($)=>`${$.type}(${$.value})`).join(" ")} ${this.selectFields.join(", ")} FROM ${this.table}`;if(this.joins.length>0)S+=" "+this.joins.join(" ");if(this.whereConditions.length>0)S+=" WHERE "+this.whereConditions.join(" AND ");if(this.orderByClause)S+=` ORDER BY ${this.orderByClause}`;if(this.limitValue!==null)S+=` LIMIT ${this.limitValue}`;if(this.offsetValue!==null)S+=` OFFSET ${this.offsetValue}`;return{query:S,params:this.whereParams}}async execute(S,w,$){let{query:E,params:Y}=this.build();if(w&&$){let Q=await w.get($);if(Q)return Q}let J=await S.query(E,Y);if(w&&$&&J.length>0)await w.set($,J);return J}}var B8=b0(e$(),1);var A1=Symbol("model"),T1=Symbol("column"),J1=Symbol("validator"),a=Symbol("relation"),_1=Symbol("softDelete");function CY(S){return function(w){Reflect.defineMetadata(A1,S,w)}}function jY(S,w){return function($,E){let Y=Reflect.getMetadata(T1,$)||{};Y[E]={name:S,type:w},Reflect.defineMetadata(T1,Y,$)}}function hY(){return function(S,w){let $=Reflect.getMetadata(J1,S)||{};$[w]=[...$[w]||[],"required"],Reflect.defineMetadata(J1,$,S)}}function xY(){return function(S,w){let $=Reflect.getMetadata(J1,S)||{};$[w]=[...$[w]||[],"unique"],Reflect.defineMetadata(J1,$,S)}}function OY(){return function(S,w){Reflect.defineMetadata(_1,w,S)}}function KY(S,w){return function($,E){let Y=Reflect.getMetadata(a,$)||{};Y[E]={type:"one-to-one",targetModel:S,foreignKey:w},Reflect.defineMetadata(a,Y,$)}}function fY(S,w){return function($,E){let Y=Reflect.getMetadata(a,$)||{};Y[E]={type:"many-to-one",targetModel:S,foreignKey:w},Reflect.defineMetadata(a,Y,$)}}function _Y(S,w){return function($,E){let Y=Reflect.getMetadata(a,$)||{};Y[E]={type:"one-to-many",targetModel:S,inverseKey:w},Reflect.defineMetadata(a,Y,$)}}function gY(S,w,$,E){return function(Y,J){let Q=Reflect.getMetadata(a,Y)||{};Q[J]={type:"many-to-many",targetModel:S,joinTable:w,foreignKey:$,inverseKey:E},Reflect.defineMetadata(a,Q,Y)}}class kS{client;cache;table;columns;validators;relations;softDeleteField;logger;constructor(S,w,$={enabled:!1,ttl:60},E=new Y1){this.client=S,this.cache=$.enabled?new r1($,E):null,this.table=Reflect.getMetadata(A1,w)||"",this.columns=Reflect.getMetadata(T1,w.prototype)||{},this.validators=Reflect.getMetadata(J1,w.prototype)||{},this.relations=Reflect.getMetadata(a,w.prototype)||{},this.softDeleteField=Reflect.getMetadata(_1,w.prototype)||null,this.logger=E}getDBType(){return this.client.config.type}validate(S){for(let[w,$]of Object.entries(this.validators)){let E=S[w];if($.includes("required")&&(E===void 0||E===null))throw new b(`Field ${w} is required`,"VALIDATION_ERROR");if($.includes("unique"));}}find(){let S=new DS(this.table);if(this.softDeleteField)S.where(`${this.softDeleteField} IS NULL`);return S}async findOne(S,w={}){let $=performance.now();this.logger.logDebug(`Finding one ${this.table} with ID ${S}`);let E=this.find().where("id = ?",S).limit(1);if(w.relations)for(let Q of w.relations)await this.loadRelation(E,Q);let Y=w.relations?`findOne:${this.table}:${S}:${w.relations.join(",")}`:`findOne:${this.table}:${S}`,J=await E.execute(this.client,this.cache,Y);return this.logger.logDebug(`Found ${this.table} with ID ${S} in ${(performance.now()-$).toFixed(2)}ms`),J[0]||null}async create(S,w={}){let $=performance.now();return this.logger.logDebug(`Creating ${this.table} with data: ${JSON.stringify(S)}`),this.validate(S),await this.client.transaction(async()=>{let E=Object.keys(S).filter((N)=>this.columns[N]),Y=E.map((N)=>this.columns[N]?.name).join(", "),J=E.map(()=>"?").join(", "),Q=E.map((N)=>S[N]),X=`INSERT INTO ${this.table} (${Y}) VALUES (${J})`,Z,B,z=this.getDBType();if(z==="postgres")X+=" RETURNING *",Z=await this.client.query(X,Q),B=Z?.[0]?.id;else if(await this.client.query(X,Q),z==="sqlite")B=(await this.client.query("SELECT last_insert_rowid() as id",[]))[0]?.id;else if(z==="mysql")B=(await this.client.query("SELECT LAST_INSERT_ID() as id",[]))[0]?.id;if(!B)throw new b("Failed to retrieve inserted ID","INSERT_ERROR");let W=[`find:${this.table}`,`findOne:${this.table}:${B}`],H=this.find().where("id = ?",B);if(w.relations)for(let N of w.relations)await this.loadRelation(H,N);if(this.cache){if(await this.cache.invalidate(W),this.cache.getStrategy()==="write-through"){let N=Z?.[0]||(await H.execute(this.client))[0];return await this.cache.set(`findOne:${this.table}:${B}`,[N],60),this.logger.logDebug(`Created ${this.table} with ID ${B} in ${(performance.now()-$).toFixed(2)}ms`),N}}let G=Z?.[0]||(await H.execute(this.client))[0];return this.logger.logDebug(`Created ${this.table} with ID ${B} in ${(performance.now()-$).toFixed(2)}ms`),G})}async bulkCreate(S,w={}){let $=performance.now();if(this.logger.logDebug(`Bulk creating ${S.length} ${this.table} entities`),!S.length)return[];let E=w.batchSize||1000;S.forEach((Q)=>this.validate(Q));let Y=this.getDBType(),J=[];for(let Q=0;Q<S.length;Q+=E){let X=S.slice(Q,Q+E);await this.client.transaction(async()=>{let Z=Object.keys(X[0]).filter((P)=>this.columns[P]),B=Z.map((P)=>this.columns[P]?.name).join(", "),z=`(${Z.map(()=>"?").join(", ")})`,W=`INSERT INTO ${this.table} (${B}) VALUES ${X.map(()=>z).join(", ")}`,H=X.flatMap((P)=>Z.map((c)=>P[c])),G=[],N=[];if(Y==="postgres")W+=" RETURNING *",G=await this.client.query(W,H),N=G.map((P)=>P.id);else await this.client.query(W,H),N=(await this.client.query(`SELECT id FROM ${this.table} ORDER BY id DESC LIMIT ?`,[X.length])).map((P)=>P.id);let h=N.map((P)=>`findOne:${this.table}:${P}`).concat(`find:${this.table}`);if(N.length>0&&G.length===0){let P=this.find().where(`id IN (${N.map(()=>"?").join(", ")})`,...N);if(w.relations)for(let c of w.relations)await this.loadRelation(P,c);G=await P.execute(this.client)}if(this.cache){if(await this.cache.invalidate(h),this.cache.getStrategy()==="write-through")await this.cache.set(`bulkCreate:${this.table}:${N.join(",")}`,G,60)}J.push(...G)})}return this.logger.logDebug(`Bulk created ${J.length} ${this.table} entities in ${(performance.now()-$).toFixed(2)}ms`),J}async update(S,w){let $=performance.now();return this.logger.logDebug(`Updating ${this.table} with ID ${S}`),this.validate(w),await this.client.transaction(async()=>{let E=Object.keys(w).filter((B)=>this.columns[B]),Y=E.map((B)=>`${this.columns[B]?.name} = ?`).join(", "),J=`UPDATE ${this.table} SET ${Y} WHERE id = ?${this.softDeleteField?` AND ${this.softDeleteField} IS NULL`:""}`,Q=[...E.map((B)=>w[B]),S];await this.client.query(J,Q);let X,Z=[`find:${this.table}`,`findOne:${this.table}:${S}`];if(this.cache){if(await this.cache.invalidate(Z),this.cache.getStrategy()==="write-through")return X=(await this.find().where("id = ?",S).execute(this.client))[0],await this.cache.set(`findOne:${this.table}:${S}`,[X],60),this.logger.logDebug(`Updated ${this.table} with ID ${S} in ${(performance.now()-$).toFixed(2)}ms`),X}return X=await this.findOne(S),this.logger.logDebug(`Updated ${this.table} with ID ${S} in ${(performance.now()-$).toFixed(2)}ms`),X})}async bulkUpdate(S,w={}){let $=performance.now();if(this.logger.logDebug(`Bulk updating ${S.length} ${this.table} entities`),!S.length)return;let E=w.batchSize||1000;S.forEach((Y)=>this.validate(Y.set));for(let Y=0;Y<S.length;Y+=E){let J=S.slice(Y,Y+E);await this.client.transaction(async()=>{for(let Q of J){let X=Object.keys(Q.set).filter((W)=>this.columns[W]),Z=X.map((W)=>`${this.columns[W]?.name} = ?`).join(", "),B=`UPDATE ${this.table} SET ${Z} WHERE ${Q.where.condition}${this.softDeleteField?` AND ${this.softDeleteField} IS NULL`:""}`,z=[...X.map((W)=>Q.set[W]),...Q.where.params];await this.client.query(B,z)}if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`)})}this.logger.logDebug(`Bulk updated ${S.length} ${this.table} entities in ${(performance.now()-$).toFixed(2)}ms`)}async upsert(S,w){let $=performance.now();return this.logger.logDebug(`Upserting ${this.table} with keys: ${w.join(", ")}`),this.validate(S),await this.client.transaction(async()=>{let E=this.getDBType(),Y=Object.keys(S).filter((G)=>this.columns[G]),J=Y.map((G)=>this.columns[G]?.name).join(", "),Q=Y.map(()=>"?").join(", "),X=Y.filter((G)=>!w.includes(G)).map((G)=>`${this.columns[G]?.name} = ?`).join(", "),Z;if(E==="sqlite")Z=`INSERT INTO ${this.table} (${J}) VALUES (${Q}) ON CONFLICT(${w.map((G)=>this.columns[G].name).join(", ")}) DO UPDATE SET ${X}`;else if(E==="mysql")Z=`INSERT INTO ${this.table} (${J}) VALUES (${Q}) ON DUPLICATE KEY UPDATE ${X}`;else Z=`INSERT INTO ${this.table} (${J}) VALUES (${Q}) ON CONFLICT (${w.map((G)=>this.columns[G].name).join(", ")}) DO UPDATE SET ${X} RETURNING *`;let B=[...Y.map((G)=>S[G]),...Y.filter((G)=>!w.includes(G)).map((G)=>S[G])],W=(await this.client.query(Z,B))[0]?.id||S.id;if(!W&&E==="sqlite")W=(await this.client.query("SELECT last_insert_rowid() as id",[]))[0]?.id;else if(!W&&E==="mysql")W=(await this.client.query("SELECT LAST_INSERT_ID() as id",[]))[0]?.id;if(!W)throw new b("Failed to retrieve upserted ID","UPSERT_ERROR");if(this.cache){if(await this.cache.invalidatePattern(`find:${this.table}:*`),this.cache.getStrategy()==="write-through"){let N=(await this.find().where("id = ?",W).execute(this.client))[0];return await this.cache.set(`findOne:${this.table}:${W}`,[N],60),this.logger.logDebug(`Upserted ${this.table} with ID ${W} in ${(performance.now()-$).toFixed(2)}ms`),N}}let H=await this.findOne(W);return this.logger.logDebug(`Upserted ${this.table} with ID ${W} in ${(performance.now()-$).toFixed(2)}ms`),H})}async delete(S){let w=performance.now();if(this.logger.logDebug(`Deleting ${this.table} with ID ${S}`),this.softDeleteField)await this.client.query(`UPDATE ${this.table} SET ${this.softDeleteField} = ? WHERE id = ?`,[new Date().toISOString(),S]);else await this.client.query(`DELETE FROM ${this.table} WHERE id = ?`,[S]);if(this.cache)await this.cache.invalidate([`find:${this.table}`,`findOne:${this.table}:${S}`]);this.logger.logDebug(`Deleted ${this.table} with ID ${S} in ${(performance.now()-w).toFixed(2)}ms`)}async bulkDelete(S,w={}){let $=performance.now();if(this.logger.logDebug(`Bulk deleting ${S.length} ${this.table} entities`),!S.length)return;let E=w.batchSize||1000;for(let Y=0;Y<S.length;Y+=E){let J=S.slice(Y,Y+E);await this.client.transaction(async()=>{let Q=J.map(()=>"?").join(", "),X=this.softDeleteField?`UPDATE ${this.table} SET ${this.softDeleteField} = ? WHERE id IN (${Q})`:`DELETE FROM ${this.table} WHERE id IN (${Q})`,Z=this.softDeleteField?[new Date().toISOString(),...J]:J;await this.client.query(X,Z)})}if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);this.logger.logDebug(`Bulk deleted ${S.length} ${this.table} entities in ${(performance.now()-$).toFixed(2)}ms`)}async recover(S){let w=performance.now();if(this.logger.logDebug(`Recovering ${this.table} with ID ${S}`),!this.softDeleteField)throw new b("Soft delete not enabled for this model","RECOVER_ERROR");return await this.client.transaction(async()=>{if(await this.client.query(`UPDATE ${this.table} SET ${this.softDeleteField} = NULL WHERE id = ?`,[S]),this.cache)await this.cache.invalidate([`find:${this.table}`,`findOne:${this.table}:${S}`]);let $=await this.findOne(S);return this.logger.logDebug(`Recovered ${this.table} with ID ${S} in ${(performance.now()-w).toFixed(2)}ms`),$})}async rawQuery(S,w=[]){let $=performance.now();this.logger.logDebug(`Executing raw query: ${S}`);let E=await this.client.query(S,w);return this.logger.logDebug(`Raw query completed in ${(performance.now()-$).toFixed(2)}ms`),E}async loadRelation(S,w){this.logger.logDebug(`Loading relation ${w} for ${this.table}`);let $=this.relations[w];if(!$)throw new b(`Relation ${w} not found`,"RELATION_ERROR");let E=Reflect.getMetadata(A1,$.targetModel());if($.type==="one-to-one"||$.type==="many-to-one")S.join(E,`${this.table}.${$.foreignKey} = ${E}.id`);else if($.type==="one-to-many")S.join(E,`${E}.${$.inverseKey} = ${this.table}.id`);else if($.type==="many-to-many")S.join($.joinTable,`${$.joinTable}.${$.foreignKey} = ${this.table}.id`).join(E,`${E}.id = ${$.joinTable}.${$.inverseKey}`)}}async function vY(S,w){let $=Reflect.getMetadata(A1,S);if(!$)throw new b("Model not decorated with @Model","MIGRATION_ERROR");let E=Reflect.getMetadata(T1,S.prototype)||{},Y=Reflect.getMetadata(J1,S.prototype)||{},J=Reflect.getMetadata(_1,S.prototype),Q=Object.entries(E).map(([B,z])=>{let W=`${z.name} ${z.type}`;if(z.name==="id")W+=" PRIMARY KEY AUTOINCREMENT";if(Y[B]?.includes("required"))W+=" NOT NULL";if(Y[B]?.includes("unique"))W+=" UNIQUE";return W});if(J&&E[J])Q.push(`${E[J].name} ${E[J].type}`);let X=[`CREATE TABLE IF NOT EXISTS ${$} (${Q.join(", ")})`],Z=[`DROP TABLE IF EXISTS ${$}`];return{up:X,down:Z}}async function bY(S,w){let $=new SS(S);try{await $.query(`
|
|
176
|
+
CREATE TABLE IF NOT EXISTS migrations (
|
|
177
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
178
|
+
name TEXT NOT NULL,
|
|
179
|
+
applied_at TEXT NOT NULL
|
|
180
|
+
)
|
|
181
|
+
`);for(let[E,Y]of w.entries()){let J=`migration_${E}_${new Date().toISOString().replace(/[-:T.]/g,"")}`;if((await $.query("SELECT id FROM migrations WHERE name = ?",[J])).length===0){for(let X of Y.up)await $.query(X,[]);await $.query("INSERT INTO migrations (name, applied_at) VALUES (?, ?)",[J,new Date().toISOString()])}}}finally{await $.close()}}class pY{client;cache;logger;constructor(S,w={enabled:!1,ttl:60},$={}){this.logger=new Y1($),this.client=new SS(S,this.logger),this.cache=w.enabled?new r1(w,this.logger):null}getRepository(S){if(this.cache){let w=this.cache,$={enabled:!0,ttl:60,redisUrl:w.redisUrl,cachePrefix:w.prefix,strategy:this.cache.getStrategy()};return new kS(this.client,S,$,this.logger)}return new kS(this.client,S,{enabled:!1,ttl:60},this.logger)}async transaction(S){return await this.client.transaction(S)}async savepoint(S,w){return await this.client.savepoint(S,w)}async switchConnection(S){await this.client.switchConnection(S)}async getCacheStats(){return this.cache?await this.cache.getStats():{hits:0,misses:0,keys:0}}getPoolMetrics(){return this.client.getPoolMetrics()}async close(){if(await this.client.close(),this.cache)await this.cache.disconnect()}}export{bY as runMigrations,vY as generateMigration,J1 as ValidatorKey,xY as Unique,b as StabilizeError,pY as Stabilize,_1 as SoftDeleteKey,OY as SoftDelete,hY as Required,kS as Repository,AS as RelationType,a as RelationKey,DS as QueryBuilder,KY as OneToOne,_Y as OneToMany,A1 as ModelKey,CY as Model,fY as ManyToOne,gY as ManyToMany,y0 as LogLevel,TS as DBType,SS as DBClient,Y1 as ConsoleLogger,T1 as ColumnKey,jY as Column,r1 as Cache};
|