stabilize-orm 1.3.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1097 -561
- package/dist/auto-migrate.d.ts +34 -0
- package/dist/auto-migrate.d.ts.map +1 -0
- package/dist/auto-migrate.js +3003 -0
- package/dist/auto-migrate.js.map +163 -0
- package/dist/cache.d.ts +90 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +166 -0
- package/dist/cache.js.map +64 -0
- package/dist/client.d.ts +73 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2997 -0
- package/dist/client.js.map +162 -0
- package/dist/hooks.d.ts +31 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +4 -0
- package/dist/hooks.js.map +11 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3183 -0
- package/dist/index.js.map +222 -0
- package/dist/logger.d.ts +40 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +11 -0
- package/dist/migrations.d.ts +31 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +3009 -0
- package/dist/migrations.js.map +164 -0
- package/{model.ts → dist/model.d.ts} +124 -189
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +4 -0
- package/dist/model.js.map +10 -0
- package/dist/query-builder.d.ts +91 -0
- package/dist/query-builder.d.ts.map +1 -0
- package/dist/query-builder.js +14 -0
- package/dist/query-builder.js.map +12 -0
- package/dist/repository.d.ts +165 -0
- package/dist/repository.d.ts.map +1 -0
- package/dist/repository.js +176 -0
- package/dist/repository.js.map +69 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +110 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +10 -0
- package/dist/utils/encryption.d.ts +13 -0
- package/dist/utils/encryption.d.ts.map +1 -0
- package/dist/utils/encryption.js +4 -0
- package/dist/utils/encryption.js.map +10 -0
- package/package.json +96 -17
- package/.eslintrc.json +0 -10
- package/.github/ISSUE_TEMPLATE/PULL_REQUEST_TEMPLATE.md +0 -23
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -25
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
- package/.github/workflows/ci-cd.yml +0 -22
- package/CHANGELOG.md +0 -75
- package/CODE_OF_CONDUCT.md +0 -87
- package/CONTRIBUTING.md +0 -48
- package/FUNDING.md +0 -14
- package/SECURITY.md +0 -35
- package/SUPPORT.md +0 -18
- package/bun.lock +0 -667
- package/cache.ts +0 -181
- package/client.ts +0 -249
- package/docker-compose.yml +0 -22
- package/hooks.ts +0 -76
- package/index.ts +0 -158
- package/logger.ts +0 -127
- package/migrations.ts +0 -318
- package/public/logo_both-transparent.png +0 -0
- package/public/logo_iamge-transparent.png +0 -0
- package/public/logo_text-transparent.png +0 -0
- package/query-builder.ts +0 -209
- package/repository.ts +0 -1096
- package/tests/migrations.test.ts +0 -141
- package/tsconfig.json +0 -32
- package/types.ts +0 -106
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var W4=Object.create;var{getPrototypeOf:G4,defineProperty:p0,getOwnPropertyNames:Q4}=Object;var H4=Object.prototype.hasOwnProperty;var V4=(S,w,$)=>{$=S!=null?W4(G4(S)):{};let Z=w||!S||!S.__esModule?p0($,"default",{value:S,enumerable:!0}):$;for(let J of Q4(S))if(!H4.call(Z,J))p0(Z,J,{get:()=>S[J],enumerable:!0});return Z};var M=(S,w)=>()=>(w||S((w={exports:{}}).exports,w),w.exports);var E=import.meta.require;var m0=M((kZ,M4)=>{M4.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 Y1=M((x)=>{var y4=x&&x.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(x,"__esModule",{value:!0});x.getKeyIndexes=x.hasFlag=x.exists=x.list=void 0;var D1=y4(m0());x.list=Object.keys(D1.default);var a1={};x.list.forEach((S)=>{a1[S]=D1.default[S].flags.reduce(function(w,$){return w[$]=!0,w},{})});function z4(S){return Boolean(D1.default[S])}x.exists=z4;function I4(S,w){if(!a1[S])throw Error("Unknown command "+S);return Boolean(a1[S][w])}x.hasFlag=I4;function O4(S,w,$){let Z=D1.default[S];if(!Z)throw Error("Unknown command "+S);if(!Array.isArray(w))throw Error("Expect args to be an array");let J=[],Y=Boolean($&&$.parseExternalKey),X=(W,H)=>{let G=[],Q=Number(W[H]);for(let V=0;V<Q;V++)G.push(V+H+1);return G},U=(W,H,G)=>{for(let Q=H;Q<W.length-1;Q+=1)if(String(W[Q]).toLowerCase()===G.toLowerCase())return Q+1;return null};switch(S){case"zunionstore":case"zinterstore":case"zdiffstore":J.push(0,...X(w,1));break;case"eval":case"evalsha":case"eval_ro":case"evalsha_ro":case"fcall":case"fcall_ro":case"blmpop":case"bzmpop":J.push(...X(w,1));break;case"sintercard":case"lmpop":case"zunion":case"zinter":case"zmpop":case"zintercard":case"zdiff":{J.push(...X(w,0));break}case"georadius":{J.push(0);let W=U(w,5,"STORE");if(W)J.push(W);let H=U(w,5,"STOREDIST");if(H)J.push(H);break}case"georadiusbymember":{J.push(0);let W=U(w,4,"STORE");if(W)J.push(W);let H=U(w,4,"STOREDIST");if(H)J.push(H);break}case"sort":case"sort_ro":J.push(0);for(let W=1;W<w.length-1;W++){let H=w[W];if(typeof H!=="string")continue;let G=H.toUpperCase();if(G==="GET"){if(W+=1,H=w[W],H!=="#")if(Y)J.push([W,c0(H)]);else J.push(W)}else if(G==="BY")if(W+=1,Y)J.push([W,c0(w[W])]);else J.push(W);else if(G==="STORE")W+=1,J.push(W)}break;case"migrate":if(w[2]==="")for(let W=5;W<w.length-1;W++){let H=w[W];if(typeof H==="string"&&H.toUpperCase()==="KEYS"){for(let G=W+1;G<w.length;G++)J.push(G);break}}else J.push(2);break;case"xreadgroup":case"xread":for(let W=S==="xread"?0:3;W<w.length-1;W++)if(String(w[W]).toUpperCase()==="STREAMS"){for(let H=W+1;H<=W+(w.length-1-W)/2;H++)J.push(H);break}break;default:if(Z.step>0){let W=Z.keyStart-1,H=Z.keyStop>0?Z.keyStop:w.length+Z.keyStop+1;for(let G=W;G<H;G+=Z.step)J.push(G)}break}return J}x.getKeyIndexes=O4;function c0(S){if(typeof S!=="string")S=String(S);let w=S.indexOf("->");return w===-1?S.length:w}});var l0=M((t0)=>{Object.defineProperty(t0,"__esModule",{value:!0});t0.tryCatch=t0.errorObj=void 0;t0.errorObj={e:{}};var n1;function L4(S,w){try{let $=n1;return n1=null,$.apply(this,arguments)}catch($){return t0.errorObj.e=$,t0.errorObj}}function B4(S){return n1=S,L4}t0.tryCatch=B4});var m=M((a0)=>{Object.defineProperty(a0,"__esModule",{value:!0});var X1=l0();function o0(S){setTimeout(function(){throw S},0)}function E4(S,w,$){if(typeof w==="function")S.then((Z)=>{let J;if($!==void 0&&Object($).spread&&Array.isArray(Z))J=X1.tryCatch(w).apply(void 0,[null].concat(Z));else J=Z===void 0?X1.tryCatch(w)(null):X1.tryCatch(w)(null,Z);if(J===X1.errorObj)o0(J.e)},(Z)=>{if(!Z){let Y=Error(Z+"");Object.assign(Y,{cause:Z}),Z=Y}let J=X1.tryCatch(w)(Z);if(J===X1.errorObj)o0(J.e)});return S}a0.default=E4});var r0=M((TZ,s0)=>{var n0=E("assert"),y1=E("util");function U1(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}y1.inherits(U1,Error);Object.defineProperty(U1.prototype,"name",{value:"RedisError",configurable:!0,writable:!0});function r1(S,w,$){n0(w),n0.strictEqual(typeof $,"number"),Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0});let Z=Error.stackTraceLimit;Error.stackTraceLimit=2,Error.captureStackTrace(this,this.constructor),Error.stackTraceLimit=Z,this.offset=$,this.buffer=w}y1.inherits(r1,U1);Object.defineProperty(r1.prototype,"name",{value:"ParserError",configurable:!0,writable:!0});function e1(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}y1.inherits(e1,U1);Object.defineProperty(e1.prototype,"name",{value:"ReplyError",configurable:!0,writable:!0});function q1(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}y1.inherits(q1,U1);Object.defineProperty(q1.prototype,"name",{value:"AbortError",configurable:!0,writable:!0});function S0(S){Object.defineProperty(this,"message",{value:S||"",configurable:!0,writable:!0}),Error.captureStackTrace(this,this.constructor)}y1.inherits(S0,q1);Object.defineProperty(S0.prototype,"name",{value:"InterruptError",configurable:!0,writable:!0});s0.exports={RedisError:U1,ParserError:r1,ReplyError:e1,AbortError:q1,InterruptError:S0}});var JS=M((xZ,ZS)=>{var e0=E("assert");class z1 extends Error{get name(){return this.constructor.name}}class SS extends z1{constructor(S,w,$){e0(w),e0.strictEqual(typeof $,"number");let Z=Error.stackTraceLimit;Error.stackTraceLimit=2;super(S);Error.stackTraceLimit=Z,this.offset=$,this.buffer=w}get name(){return this.constructor.name}}class wS extends z1{constructor(S){let w=Error.stackTraceLimit;Error.stackTraceLimit=2;super(S);Error.stackTraceLimit=w}get name(){return this.constructor.name}}class w0 extends z1{get name(){return this.constructor.name}}class $S extends w0{get name(){return this.constructor.name}}ZS.exports={RedisError:z1,ParserError:SS,ReplyError:wS,AbortError:w0,InterruptError:$S}});var e=M((CZ,YS)=>{var K4=process.version.charCodeAt(1)<55&&process.version.charCodeAt(2)===46?r0():JS();YS.exports=K4});var I1=M((_Z,$0)=>{var XS=[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],P4=function(w){var $,Z=0,J=0,Y=[],X=w.length;for(;Z<X;Z++)if($=w.charCodeAt(Z),$<128)Y[J++]=$;else if($<2048)Y[J++]=$>>6|192,Y[J++]=$&63|128;else if(($&64512)===55296&&Z+1<w.length&&(w.charCodeAt(Z+1)&64512)===56320)$=65536+(($&1023)<<10)+(w.charCodeAt(++Z)&1023),Y[J++]=$>>18|240,Y[J++]=$>>12&63|128,Y[J++]=$>>6&63|128,Y[J++]=$&63|128;else Y[J++]=$>>12|224,Y[J++]=$>>6&63|128,Y[J++]=$&63|128;return Y},US=$0.exports=function(w){var $,Z=0,J=-1,Y=0,X=0,U=typeof w==="string"?P4(w):w,W=U.length;while(Z<W){if($=U[Z++],J===-1){if($===123)J=Z}else if($!==125)X=XS[($^X>>8)&255]^X<<8;else if(Z-1!==J)return X&16383;Y=XS[($^Y>>8)&255]^Y<<8}return Y&16383};$0.exports.generateMulti=function(w){var $=1,Z=w.length,J=US(w[0]);while($<Z)if(US(w[$++])!==J)return-1;return J}});var yS=M((fZ,MS)=>{var GS=9007199254740991,R4="[object Arguments]",j4="[object Function]",k4="[object GeneratorFunction]",D4=/^(?:0|[1-9]\d*)$/;function QS(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 q4(S,w){var $=-1,Z=Array(S);while(++$<S)Z[$]=w($);return Z}var O1=Object.prototype,L1=O1.hasOwnProperty,HS=O1.toString,N4=O1.propertyIsEnumerable,WS=Math.max;function T4(S,w){var $=u4(S)||p4(S)?q4(S.length,String):[],Z=$.length,J=!!Z;for(var Y in S)if((w||L1.call(S,Y))&&!(J&&(Y=="length"||FS(Y,Z))))$.push(Y);return $}function x4(S,w,$,Z){if(S===void 0||Z0(S,O1[$])&&!L1.call(Z,$))return w;return S}function C4(S,w,$){var Z=S[w];if(!(L1.call(S,w)&&Z0(Z,$))||$===void 0&&!(w in S))S[w]=$}function _4(S){if(!Y0(S))return b4(S);var w=g4(S),$=[];for(var Z in S)if(!(Z=="constructor"&&(w||!L1.call(S,Z))))$.push(Z);return $}function VS(S,w){return w=WS(w===void 0?S.length-1:w,0),function(){var $=arguments,Z=-1,J=WS($.length-w,0),Y=Array(J);while(++Z<J)Y[Z]=$[w+Z];Z=-1;var X=Array(w+1);while(++Z<w)X[Z]=$[Z];return X[w]=Y,QS(S,this,X)}}function f4(S,w,$,Z){$||($={});var J=-1,Y=w.length;while(++J<Y){var X=w[J],U=Z?Z($[X],S[X],X,$,S):void 0;C4($,X,U===void 0?S[X]:U)}return $}function v4(S){return VS(function(w,$){var Z=-1,J=$.length,Y=J>1?$[J-1]:void 0,X=J>2?$[2]:void 0;if(Y=S.length>3&&typeof Y=="function"?(J--,Y):void 0,X&&h4($[0],$[1],X))Y=J<3?void 0:Y,J=1;w=Object(w);while(++Z<J){var U=$[Z];if(U)S(w,U,Z,Y)}return w})}function FS(S,w){return w=w==null?GS:w,!!w&&(typeof S=="number"||D4.test(S))&&(S>-1&&S%1==0&&S<w)}function h4(S,w,$){if(!Y0($))return!1;var Z=typeof w;if(Z=="number"?J0($)&&FS(w,$.length):Z=="string"&&(w in $))return Z0($[w],S);return!1}function g4(S){var w=S&&S.constructor,$=typeof w=="function"&&w.prototype||O1;return S===$}function b4(S){var w=[];if(S!=null)for(var $ in Object(S))w.push($);return w}function Z0(S,w){return S===w||S!==S&&w!==w}function p4(S){return d4(S)&&L1.call(S,"callee")&&(!N4.call(S,"callee")||HS.call(S)==R4)}var u4=Array.isArray;function J0(S){return S!=null&&c4(S.length)&&!m4(S)}function d4(S){return t4(S)&&J0(S)}function m4(S){var w=Y0(S)?HS.call(S):"";return w==j4||w==k4}function c4(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=GS}function Y0(S){var w=typeof S;return!!S&&(w=="object"||w=="function")}function t4(S){return!!S&&typeof S=="object"}var i4=v4(function(S,w,$,Z){f4(w,o4(w),S,Z)}),l4=VS(function(S){return S.push(void 0,x4),QS(i4,void 0,S)});function o4(S){return J0(S)?T4(S,!0):_4(S)}MS.exports=l4});var OS=M((vZ,IS)=>{var a4=9007199254740991,n4="[object Arguments]",s4="[object Function]",r4="[object GeneratorFunction]",X0=Object.prototype,e4=X0.hasOwnProperty,zS=X0.toString,S5=X0.propertyIsEnumerable;function w5(S){return Z5(S)&&e4.call(S,"callee")&&(!S5.call(S,"callee")||zS.call(S)==n4)}function $5(S){return S!=null&&Y5(S.length)&&!J5(S)}function Z5(S){return U5(S)&&$5(S)}function J5(S){var w=X5(S)?zS.call(S):"";return w==s4||w==r4}function Y5(S){return typeof S=="number"&&S>-1&&S%1==0&&S<=a4}function X5(S){var w=typeof S;return!!S&&(w=="object"||w=="function")}function U5(S){return!!S&&typeof S=="object"}IS.exports=w5});var N1=M((LS)=>{Object.defineProperty(LS,"__esModule",{value:!0});LS.isArguments=LS.defaults=LS.noop=void 0;var W5=yS();LS.defaults=W5;var G5=OS();LS.isArguments=G5;function Q5(){}LS.noop=Q5});var AS=M((gZ,ES)=>{var W1=1000,G1=W1*60,Q1=G1*60,S1=Q1*24,F5=S1*7,M5=S1*365.25;ES.exports=function(S,w){w=w||{};var $=typeof S;if($==="string"&&S.length>0)return y5(S);else if($==="number"&&isFinite(S))return w.long?I5(S):z5(S);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(S))};function y5(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]),Z=(w[2]||"ms").toLowerCase();switch(Z){case"years":case"year":case"yrs":case"yr":case"y":return $*M5;case"weeks":case"week":case"w":return $*F5;case"days":case"day":case"d":return $*S1;case"hours":case"hour":case"hrs":case"hr":case"h":return $*Q1;case"minutes":case"minute":case"mins":case"min":case"m":return $*G1;case"seconds":case"second":case"secs":case"sec":case"s":return $*W1;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return $;default:return}}function z5(S){var w=Math.abs(S);if(w>=S1)return Math.round(S/S1)+"d";if(w>=Q1)return Math.round(S/Q1)+"h";if(w>=G1)return Math.round(S/G1)+"m";if(w>=W1)return Math.round(S/W1)+"s";return S+"ms"}function I5(S){var w=Math.abs(S);if(w>=S1)return T1(S,w,S1,"day");if(w>=Q1)return T1(S,w,Q1,"hour");if(w>=G1)return T1(S,w,G1,"minute");if(w>=W1)return T1(S,w,W1,"second");return S+" ms"}function T1(S,w,$,Z){var J=w>=$*1.5;return Math.round(S/$)+" "+Z+(J?"s":"")}});var U0=M((bZ,KS)=>{function O5(S){$.debug=$,$.default=$,$.coerce=W,$.disable=X,$.enable=J,$.enabled=U,$.humanize=AS(),$.destroy=H,Object.keys(S).forEach((G)=>{$[G]=S[G]}),$.names=[],$.skips=[],$.formatters={};function w(G){let Q=0;for(let V=0;V<G.length;V++)Q=(Q<<5)-Q+G.charCodeAt(V),Q|=0;return $.colors[Math.abs(Q)%$.colors.length]}$.selectColor=w;function $(G){let Q,V=null,F,I;function z(...y){if(!z.enabled)return;let L=z,A=Number(new Date),B=A-(Q||A);if(L.diff=B,L.prev=Q,L.curr=A,Q=A,y[0]=$.coerce(y[0]),typeof y[0]!=="string")y.unshift("%O");let T=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(r,X4)=>{if(r==="%%")return"%";T++;let b0=$.formatters[X4];if(typeof b0==="function"){let U4=y[T];r=b0.call(L,U4),y.splice(T,1),T--}return r}),$.formatArgs.call(L,y),(L.log||$.log).apply(L,y)}if(z.namespace=G,z.useColors=$.useColors(),z.color=$.selectColor(G),z.extend=Z,z.destroy=$.destroy,Object.defineProperty(z,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(V!==null)return V;if(F!==$.namespaces)F=$.namespaces,I=$.enabled(G);return I},set:(y)=>{V=y}}),typeof $.init==="function")$.init(z);return z}function Z(G,Q){let V=$(this.namespace+(typeof Q>"u"?":":Q)+G);return V.log=this.log,V}function J(G){$.save(G),$.namespaces=G,$.names=[],$.skips=[];let Q=(typeof G==="string"?G:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let V of Q)if(V[0]==="-")$.skips.push(V.slice(1));else $.names.push(V)}function Y(G,Q){let V=0,F=0,I=-1,z=0;while(V<G.length)if(F<Q.length&&(Q[F]===G[V]||Q[F]==="*"))if(Q[F]==="*")I=F,z=V,F++;else V++,F++;else if(I!==-1)F=I+1,z++,V=z;else return!1;while(F<Q.length&&Q[F]==="*")F++;return F===Q.length}function X(){let G=[...$.names,...$.skips.map((Q)=>"-"+Q)].join(",");return $.enable(""),G}function U(G){for(let Q of $.skips)if(Y(G,Q))return!1;for(let Q of $.names)if(Y(G,Q))return!0;return!1}function W(G){if(G instanceof Error)return G.stack||G.message;return G}function H(){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()),$}KS.exports=O5});var RS=M((PS,x1)=>{PS.formatArgs=B5;PS.save=E5;PS.load=A5;PS.useColors=L5;PS.storage=K5();PS.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`.")}})();PS.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 L5(){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 B5(S){if(S[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+S[0]+(this.useColors?"%c ":" ")+"+"+x1.exports.humanize(this.diff),!this.useColors)return;let w="color: "+this.color;S.splice(1,0,w,"color: inherit");let $=0,Z=0;S[0].replace(/%[a-zA-Z%]/g,(J)=>{if(J==="%%")return;if($++,J==="%c")Z=$}),S.splice(Z,0,w)}PS.log=console.debug||console.log||(()=>{});function E5(S){try{if(S)PS.storage.setItem("debug",S);else PS.storage.removeItem("debug")}catch(w){}}function A5(){let S;try{S=PS.storage.getItem("debug")||PS.storage.getItem("DEBUG")}catch(w){}if(!S&&typeof process<"u"&&"env"in process)S=process.env.DEBUG;return S}function K5(){try{return localStorage}catch(S){}}x1.exports=U0()(PS);var{formatters:P5}=x1.exports;P5.j=function(S){try{return JSON.stringify(S)}catch(w){return"[UnexpectedJSONParseError]: "+w.message}}});var kS=M((uZ,jS)=>{jS.exports=(S,w=process.argv)=>{let $=S.startsWith("-")?"":S.length===1?"-":"--",Z=w.indexOf($+S),J=w.indexOf("--");return Z!==-1&&(J===-1||Z<J)}});var NS=M((dZ,qS)=>{var x5=E("os"),DS=E("tty"),v=kS(),{env:j}=process,c;if(v("no-color")||v("no-colors")||v("color=false")||v("color=never"))c=0;else if(v("color")||v("colors")||v("color=true")||v("color=always"))c=1;if("FORCE_COLOR"in j)if(j.FORCE_COLOR==="true")c=1;else if(j.FORCE_COLOR==="false")c=0;else c=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3);function W0(S){if(S===0)return!1;return{level:S,hasBasic:!0,has256:S>=2,has16m:S>=3}}function G0(S,w){if(c===0)return 0;if(v("color=16m")||v("color=full")||v("color=truecolor"))return 3;if(v("color=256"))return 2;if(S&&!w&&c===void 0)return 0;let $=c||0;if(j.TERM==="dumb")return $;if(process.platform==="win32"){let Z=x5.release().split(".");if(Number(Z[0])>=10&&Number(Z[2])>=10586)return Number(Z[2])>=14931?3:2;return 1}if("CI"in j){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((Z)=>(Z in j))||j.CI_NAME==="codeship")return 1;return $}if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let Z=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return Z>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(j.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM))return 1;if("COLORTERM"in j)return 1;return $}function C5(S){let w=G0(S,S&&S.isTTY);return W0(w)}qS.exports={supportsColor:C5,stdout:W0(G0(!0,DS.isatty(1))),stderr:W0(G0(!0,DS.isatty(2)))}});var _S=M((xS,_1)=>{var _5=E("tty"),C1=E("util");xS.init=u5;xS.log=g5;xS.formatArgs=v5;xS.save=b5;xS.load=p5;xS.useColors=f5;xS.destroy=C1.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");xS.colors=[6,2,3,4,5,1];try{let S=NS();if(S&&(S.stderr||S).level>=2)xS.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){}xS.inspectOpts=Object.keys(process.env).filter((S)=>{return/^debug_/i.test(S)}).reduce((S,w)=>{let $=w.substring(6).toLowerCase().replace(/_([a-z])/g,(J,Y)=>{return Y.toUpperCase()}),Z=process.env[w];if(/^(yes|on|true|enabled)$/i.test(Z))Z=!0;else if(/^(no|off|false|disabled)$/i.test(Z))Z=!1;else if(Z==="null")Z=null;else Z=Number(Z);return S[$]=Z,S},{});function f5(){return"colors"in xS.inspectOpts?Boolean(xS.inspectOpts.colors):_5.isatty(process.stderr.fd)}function v5(S){let{namespace:w,useColors:$}=this;if($){let Z=this.color,J="\x1B[3"+(Z<8?Z:"8;5;"+Z),Y=` ${J};1m${w} \x1B[0m`;S[0]=Y+S[0].split(`
|
|
3
|
+
`).join(`
|
|
4
|
+
`+Y),S.push(J+"m+"+_1.exports.humanize(this.diff)+"\x1B[0m")}else S[0]=h5()+w+" "+S[0]}function h5(){if(xS.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function g5(...S){return process.stderr.write(C1.formatWithOptions(xS.inspectOpts,...S)+`
|
|
5
|
+
`)}function b5(S){if(S)process.env.DEBUG=S;else delete process.env.DEBUG}function p5(){return process.env.DEBUG}function u5(S){S.inspectOpts={};let w=Object.keys(xS.inspectOpts);for(let $=0;$<w.length;$++)S.inspectOpts[w[$]]=xS.inspectOpts[w[$]]}_1.exports=U0()(xS);var{formatters:TS}=_1.exports;TS.o=function(S){return this.inspectOpts.colors=this.useColors,C1.inspect(S,this.inspectOpts).split(`
|
|
6
|
+
`).map((w)=>w.trim()).join(" ")};TS.O=function(S){return this.inspectOpts.colors=this.useColors,C1.inspect(S,this.inspectOpts)}});var fS=M((cZ,Q0)=>{if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)Q0.exports=RS();else Q0.exports=_S()});var pS=M((gS)=>{Object.defineProperty(gS,"__esModule",{value:!0});gS.genRedactedString=gS.getStringValue=gS.MAX_ARGUMENT_LENGTH=void 0;var a5=fS(),H0=200;gS.MAX_ARGUMENT_LENGTH=H0;var n5="ioredis";function vS(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}}gS.getStringValue=vS;function hS(S,w){let{length:$}=S;return $<=w?S:S.slice(0,w)+' ... <REDACTED full-length="'+$+'">'}gS.genRedactedString=hS;function s5(S){let w=(0,a5.default)(`${n5}:${S}`);function $(...Z){if(!w.enabled)return;for(let J=1;J<Z.length;J++){let Y=vS(Z[J]);if(typeof Y==="string"&&Y.length>H0)Z[J]=hS(Y,H0)}return w.apply(null,Z)}return Object.defineProperties($,{namespace:{get(){return w.namespace}},enabled:{get(){return w.enabled}},destroy:{get(){return w.destroy}},log:{get(){return w.log},set(Z){w.log=Z}}}),$}gS.default=s5});var mS=M((dS)=>{Object.defineProperty(dS,"__esModule",{value:!0});var uS=`-----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-----`,w6={RedisCloudFixed:{ca:uS},RedisCloudFlexible:{ca:uS}};dS.default=w6});var k=M((f1)=>{var __dirname="C:\\Users\\offby\\Documents\\Research\\stabilize\\node_modules\\ioredis\\built\\utils";Object.defineProperty(f1,"__esModule",{value:!0});f1.noop=f1.defaults=f1.Debug=f1.getPackageMeta=f1.zipMap=f1.CONNECTION_CLOSED_ERROR_MSG=f1.shuffle=f1.sample=f1.resolveTLSProfile=f1.parseURL=f1.optimizeErrorStack=f1.toArg=f1.convertMapToArray=f1.convertObjectToArray=f1.timeout=f1.packObject=f1.isInt=f1.wrapMultiResult=f1.convertBufferToString=void 0;var Z6=E("fs"),J6=E("path"),cS=E("url"),V0=N1();Object.defineProperty(f1,"defaults",{enumerable:!0,get:function(){return V0.defaults}});Object.defineProperty(f1,"noop",{enumerable:!0,get:function(){return V0.noop}});var Y6=pS();f1.Debug=Y6.default;var X6=mS();function tS(S,w){if(S instanceof Buffer)return S.toString(w);if(Array.isArray(S)){let $=S.length,Z=Array($);for(let J=0;J<$;++J)Z[J]=S[J]instanceof Buffer&&w==="utf8"?S[J].toString():tS(S[J],w);return Z}return S}f1.convertBufferToString=tS;function U6(S){if(!S)return null;let w=[],$=S.length;for(let Z=0;Z<$;++Z){let J=S[Z];if(J instanceof Error)w.push([J]);else w.push([null,J])}return w}f1.wrapMultiResult=U6;function iS(S){let w=parseFloat(S);return!isNaN(S)&&(w|0)===w}f1.isInt=iS;function W6(S){let w={},$=S.length;for(let Z=1;Z<$;Z+=2)w[S[Z-1]]=S[Z];return w}f1.packObject=W6;function G6(S,w){let $=null,Z=function(){if($)clearTimeout($),$=null,S.apply(this,arguments)};return $=setTimeout(Z,w,Error("timeout")),Z}f1.timeout=G6;function Q6(S){let w=[],$=Object.keys(S);for(let Z=0,J=$.length;Z<J;Z++)w.push($[Z],S[$[Z]]);return w}f1.convertObjectToArray=Q6;function H6(S){let w=[],$=0;return S.forEach(function(Z,J){w[$]=J,w[$+1]=Z,$+=2}),w}f1.convertMapToArray=H6;function V6(S){if(S===null||typeof S>"u")return"";return String(S)}f1.toArg=V6;function F6(S,w,$){let Z=w.split(`
|
|
145
|
+
`),J="",Y;for(Y=1;Y<Z.length;++Y)if(Z[Y].indexOf($)===-1)break;for(let X=Y;X<Z.length;++X)J+=`
|
|
146
|
+
`+Z[X];if(S.stack){let X=S.stack.indexOf(`
|
|
147
|
+
`);S.stack=S.stack.slice(0,X)+J}return S}f1.optimizeErrorStack=F6;function M6(S){if(iS(S))return{port:S};let w=(0,cS.parse)(S,!0,!0);if(!w.slashes&&S[0]!=="/")S="//"+S,w=(0,cS.parse)(S,!0,!0);let $=w.query||{},Z={};if(w.auth){let J=w.auth.indexOf(":");Z.username=J===-1?w.auth:w.auth.slice(0,J),Z.password=J===-1?"":w.auth.slice(J+1)}if(w.pathname)if(w.protocol==="redis:"||w.protocol==="rediss:"){if(w.pathname.length>1)Z.db=w.pathname.slice(1)}else Z.path=w.pathname;if(w.host)Z.host=w.hostname;if(w.port)Z.port=w.port;if(typeof $.family==="string"){let J=Number.parseInt($.family,10);if(!Number.isNaN(J))Z.family=J}return(0,V0.defaults)(Z,$),Z}f1.parseURL=M6;function y6(S){let w=S===null||S===void 0?void 0:S.tls;if(typeof w==="string")w={profile:w};let $=X6.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}f1.resolveTLSProfile=y6;function z6(S,w=0){let $=S.length;if(w>=$)return null;return S[w+Math.floor(Math.random()*($-w))]}f1.sample=z6;function I6(S){let w=S.length;while(w>0){let $=Math.floor(Math.random()*w);w--,[S[w],S[$]]=[S[$],S[w]]}return S}f1.shuffle=I6;f1.CONNECTION_CLOSED_ERROR_MSG="Connection is closed.";function O6(S,w){let $=new Map;return S.forEach((Z,J)=>{$.set(Z,w[J])}),$}f1.zipMap=O6;var H1=null;async function L6(){if(H1)return H1;try{let S=(0,J6.resolve)(__dirname,"..","..","package.json"),w=await Z6.promises.readFile(S,"utf8");return H1={version:JSON.parse(w).version},H1}catch(S){return H1={version:"error-fetching-version"},H1}}f1.getPackageMeta=L6});var u=M((sS)=>{var __dirname="C:\\Users\\offby\\Documents\\Research\\stabilize\\node_modules\\ioredis\\built";Object.defineProperty(sS,"__esModule",{value:!0});var lS=Y1(),g6=I1(),b6=m(),$1=k();class C{constructor(S,w=[],$={},Z){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=Z,this.initPromise(),$.keyPrefix){let J=$.keyPrefix instanceof Buffer,Y=J?$.keyPrefix:null;this._iterateKeys((X)=>{if(X instanceof Buffer){if(Y===null)Y=Buffer.from($.keyPrefix);return Buffer.concat([Y,X])}else if(J)return Buffer.concat([$.keyPrefix,Buffer.from(String(X))]);return $.keyPrefix+X})}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(C.FLAGS).reduce((S,w)=>{return S[w]={},C.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:g6(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 Z=new nS;Z.push($);for(let J=0;J<this.args.length;++J){let Y=this.args[J];if(Y instanceof Buffer)if(Y.length===0)Z.push(`$0\r
|
|
151
|
+
\r
|
|
152
|
+
`);else Z.push("$"+Y.length+`\r
|
|
153
|
+
`),Z.push(Y),Z.push(`\r
|
|
154
|
+
`);else Z.push("$"+Buffer.byteLength(Y)+`\r
|
|
155
|
+
`+Y+`\r
|
|
156
|
+
`)}w=Z.toBuffer()}else{w=$;for(let Z=0;Z<this.args.length;++Z){let J=this.args[Z];w+="$"+Buffer.byteLength(J)+`\r
|
|
157
|
+
`+J+`\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,$1.toArg)(w)}}transformReply(S){if(this.replyEncoding)S=(0,$1.convertBufferToString)(S,this.replyEncoding);let w=C._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 Z=C._transformer.argument[this.name];if(Z)this.args=Z(this.args);this.stringifyArguments()}if(this.resolve=this._convertValue(w),this.errorStack)this.reject=(Z)=>{$((0,$1.optimizeErrorStack)(Z,this.errorStack.stack,__dirname))};else this.reject=$});this.promise=(0,b6.default)(S,this.callback)}_iterateKeys(S=(w)=>w){if(typeof this.keys>"u"){if(this.keys=[],(0,lS.exists)(this.name)){let w=(0,lS.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}}}sS.default=C;C.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"]};C._transformer={argument:{},reply:{}};var oS=function(S){if(S.length===1){if(S[0]instanceof Map)return(0,$1.convertMapToArray)(S[0]);if(typeof S[0]==="object"&&S[0]!==null)return(0,$1.convertObjectToArray)(S[0])}return S},aS=function(S){if(S.length===2){if(S[1]instanceof Map)return[S[0]].concat((0,$1.convertMapToArray)(S[1]));if(typeof S[1]==="object"&&S[1]!==null)return[S[0]].concat((0,$1.convertObjectToArray)(S[1]))}return S};C.setArgumentTransformer("mset",oS);C.setArgumentTransformer("msetnx",oS);C.setArgumentTransformer("hset",aS);C.setArgumentTransformer("hmset",aS);C.setReplyTransformer("hgetall",function(S){if(Array.isArray(S)){let w={};for(let $=0;$<S.length;$+=2){let Z=S[$],J=S[$+1];if(Z in w)Object.defineProperty(w,Z,{value:J,configurable:!0,enumerable:!0,writable:!0});else w[Z]=J}return w}return S});class nS{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 Z=Buffer.byteLength($);Buffer.isBuffer($)?$.copy(S,w):S.write($,w,Z),w+=Z}return S}}});var eS=M((rS)=>{Object.defineProperty(rS,"__esModule",{value:!0});var u6=e();class F0 extends u6.RedisError{constructor(S,w){super(S);this.lastNodeError=w,Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}rS.default=F0;F0.defaultMessage="Failed to refresh slots cache."});var v1=M((w3)=>{Object.defineProperty(w3,"__esModule",{value:!0});var m6=E("stream");class S3 extends m6.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}}w3.default=S3});var Q3=M((U3)=>{Object.defineProperty(U3,"__esModule",{value:!0});U3.executeWithAutoPipelining=U3.getFirstValueInFlattenedArray=U3.shouldUseAutoPipelining=U3.notAllowedAutoPipelineCommands=U3.kCallbacks=U3.kExec=void 0;var Z3=N1(),t6=I1(),$3=m();U3.kExec=Symbol("exec");U3.kCallbacks=Symbol("callbacks");U3.notAllowedAutoPipelineCommands=["auth","info","script","quit","cluster","pipeline","multi","subscribe","psubscribe","unsubscribe","unpsubscribe","select"];function J3(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 Z=$[U3.kCallbacks];$[U3.kCallbacks]=null,$.exec(function(J,Y){if(S._runningAutoPipelines.delete(w),J)for(let X=0;X<Z.length;X++)process.nextTick(Z[X],J);else for(let X=0;X<Z.length;X++)process.nextTick(Z[X],...Y[X]);if(S._autoPipelines.has(w))J3(S,w)})}function i6(S,w,$){return w&&S.options.enableAutoPipelining&&!S.isPipeline&&!U3.notAllowedAutoPipelineCommands.includes($)&&!S.options.autoPipeliningIgnoredCommands.includes($)}U3.shouldUseAutoPipelining=i6;function Y3(S){for(let w=0;w<S.length;w++){let $=S[w];if(typeof $==="string")return $;else if(Array.isArray($)||(0,Z3.isArguments)($)){if($.length===0)continue;return $[0]}let Z=[$].flat();if(Z.length>0)return Z[0]}return}U3.getFirstValueInFlattenedArray=Y3;function X3(S,w,$,Z,J){if(S.isCluster&&!S.slots.length){if(S.status==="wait")S.connect().catch(Z3.noop);return(0,$3.default)(new Promise(function(H,G){S.delayUntilReady((Q)=>{if(Q){G(Q);return}X3(S,w,$,Z,null).then(H,G)})}),J)}let Y=S.options.keyPrefix||"",X=S.isCluster?S.slots[t6(`${Y}${Y3(Z)}`)].join(","):"main";if(!S._autoPipelines.has(X)){let H=S.pipeline();H[U3.kExec]=!1,H[U3.kCallbacks]=[],S._autoPipelines.set(X,H)}let U=S._autoPipelines.get(X);if(!U[U3.kExec])U[U3.kExec]=!0,setImmediate(J3,S,X);let W=new Promise(function(H,G){if(U[U3.kCallbacks].push(function(Q,V){if(Q){G(Q);return}H(V)}),w==="call")Z.unshift($);U[w](...Z)});return(0,$3.default)(W,J)}U3.executeWithAutoPipelining=X3});var F3=M((V3)=>{Object.defineProperty(V3,"__esModule",{value:!0});var a6=E("crypto"),n6=u(),s6=m();class H3{constructor(S,w=null,$="",Z=!1){this.lua=S,this.numberOfKeys=w,this.keyPrefix=$,this.readOnly=Z,this.sha=(0,a6.createHash)("sha1").update(S).digest("hex");let J=this.sha,Y=new WeakSet;this.Command=class extends n6.default{toWritable(U){let W=this.reject;if(this.reject=(H)=>{if(H.message.indexOf("NOSCRIPT")!==-1)Y.delete(U);W.call(this,H)},!Y.has(U))Y.add(U),this.name="eval",this.args[0]=S;else if(this.name==="eval")this.name="evalsha",this.args[0]=J;return super.toWritable(U)}}}execute(S,w,$,Z){if(typeof this.numberOfKeys==="number")w.unshift(this.numberOfKeys);if(this.keyPrefix)$.keyPrefix=this.keyPrefix;if(this.readOnly)$.readOnly=!0;let J=new this.Command("evalsha",[this.sha,...w],$);return J.promise=J.promise.catch((Y)=>{if(Y.message.indexOf("NOSCRIPT")===-1)throw Y;let X=new this.Command("evalsha",[this.sha,...w],$);return(S.isPipeline?S.redis:S).sendCommand(X)}),(0,s6.default)(J.promise,Z),S.sendCommand(J)}}V3.default=H3});var b1=M((y3)=>{Object.defineProperty(y3,"__esModule",{value:!0});var e6=Y1(),g1=Q3(),S7=u(),w7=F3();class i{constructor(){this.options={},this.scriptsSet={},this.addedBuiltinSet=new Set}getBuiltinCommands(){return M0.slice(0)}createBuiltinCommand(S){return{string:t(null,S,"utf8"),buffer:t(null,S,null)}}addBuiltinCommand(S){this.addedBuiltinSet.add(S),this[S]=t(S,S,"utf8"),this[S+"Buffer"]=t(S+"Buffer",S,null)}defineCommand(S,w){let $=new w7.default(w.lua,w.numberOfKeys,this.options.keyPrefix,w.readOnly);this.scriptsSet[S]=$,this[S]=M3(S,S,$,"utf8"),this[S+"Buffer"]=M3(S+"Buffer",S,$,null)}sendCommand(S,w,$){throw Error('"sendCommand" is not implemented')}}var M0=e6.list.filter((S)=>S!=="monitor");M0.push("sentinel");M0.forEach(function(S){i.prototype[S]=t(S,S,"utf8"),i.prototype[S+"Buffer"]=t(S+"Buffer",S,null)});i.prototype.call=t("call","utf8");i.prototype.callBuffer=t("callBuffer",null);i.prototype.send_command=i.prototype.call;function t(S,w,$){if(typeof $>"u")$=w,w=null;return function(...Z){let J=w||Z.shift(),Y=Z[Z.length-1];if(typeof Y==="function")Z.pop();else Y=void 0;let X={errorStack:this.options.showFriendlyErrorStack?Error():void 0,keyPrefix:this.options.keyPrefix,replyEncoding:$};if(!(0,g1.shouldUseAutoPipelining)(this,S,J))return this.sendCommand(new S7.default(J,Z,X,Y));return(0,g1.executeWithAutoPipelining)(this,S,J,Z,Y)}}function M3(S,w,$,Z){return function(...J){let Y=typeof J[J.length-1]==="function"?J.pop():void 0,X={replyEncoding:Z};if(this.options.showFriendlyErrorStack)X.errorStack=Error();if(!(0,g1.shouldUseAutoPipelining)(this,S,w))return $.execute(this,J,X,Y);return(0,g1.executeWithAutoPipelining)(this,S,w,J,Y)}}y3.default=i});var z0=M((L3)=>{Object.defineProperty(L3,"__esModule",{value:!0});var y0=I1(),z3=Y1(),I3=m(),Z7=E("util"),J7=u(),Y7=k(),X7=b1();function U7(S,w){let $=y0(w[0]),Z=S._groupsBySlot[$];for(let J=1;J<w.length;J++)if(S._groupsBySlot[y0(w[J])]!==Z)return-1;return $}class Z1 extends X7.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 Z=S.scriptsSet[$];this._shaToScript[Z.sha]=Z,this[$]=S[$],this[$+"Buffer"]=S[$+"Buffer"]}),S.addedBuiltinSet.forEach(($)=>{this[$]=S[$],this[$+"Buffer"]=S[$+"Buffer"]}),this.promise=new Promise(($,Z)=>{this.resolve=$,this.reject=Z});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 Z=S[1].length;for(let J=0;J<Z;J++){if(S[1][J]instanceof Error)continue;let Y=this._queue[w-(Z-J)];try{S[1][J]=Y.transformReply(S[1][J])}catch(X){S[1][J]=X}}}if(this._result[w]=S,--this.replyPending)return;if(this.isCluster){let Z=!0,J;for(let Y=0;Y<this._result.length;++Y){let X=this._result[Y][0],U=this._queue[Y];if(X){if(U.name==="exec"&&X.message==="EXECABORT Transaction discarded because of previous errors.")continue;if(!J)J={name:X.name,message:X.message};else if(J.name!==X.name||J.message!==X.message){Z=!1;break}}else if(!U.inTransaction){if(!((0,z3.exists)(U.name)&&(0,z3.hasFlag)(U.name,"readonly"))){Z=!1;break}}}if(J&&Z){let Y=this,X=J.message.split(" "),U=this._queue,W=!1;this._queue=[];for(let V=0;V<U.length;++V){if(X[0]==="ASK"&&!W&&U[V].name!=="asking"&&(!U[V-1]||U[V-1].name!=="asking")){let F=new J7.default("asking");F.ignore=!0,this.sendCommand(F)}U[V].initPromise(),this.sendCommand(U[V]),W=U[V].inTransaction}let H=!0;if(typeof this.leftRedirections>"u")this.leftRedirections={};let G=function(){Y.exec()},Q=this.redis;if(Q.handleError(J,this.leftRedirections,{moved:function(V,F){Y.preferKey=F,Q.slots[X[1]]=[F],Q._groupsBySlot[X[1]]=Q._groupsIds[Q.slots[X[1]].join(";")],Q.refreshSlotsCache(),Y.exec()},ask:function(V,F){Y.preferKey=F,Y.exec()},tryagain:G,clusterDown:G,connectionClosed:G,maxRedirections:()=>{H=!1},defaults:()=>{H=!1}}),H)return}}let $=0;for(let Z=0;Z<this._queue.length-$;++Z){if(this._queue[Z+$].ignore)$+=1;this._result[Z]=this._result[Z+$]}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,$,Z;for(let J=0;J<S.length;++J)w=S[J],$=w[0],Z=w.slice(1),this[$].apply(this,Z);return this}}L3.default=Z1;var W7=Z1.prototype.multi;Z1.prototype.multi=function(){return this._transactions+=1,W7.apply(this,arguments)};var O3=Z1.prototype.execBuffer;Z1.prototype.execBuffer=(0,Z7.deprecate)(function(){if(this._transactions>0)this._transactions-=1;return O3.apply(this,arguments)},"Pipeline#execBuffer: Use Pipeline#exec instead");Z1.prototype.exec=function(S){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(Y7.noop);if(S&&!this.nodeifiedPromise)this.nodeifiedPromise=!0,(0,I3.default)(this.promise,S);return this.redis.delayUntilReady((J)=>{if(J){this.reject(J);return}this.exec(S)}),this.promise}if(this._transactions>0)return this._transactions-=1,O3.apply(this,arguments);if(!this.nodeifiedPromise)this.nodeifiedPromise=!0,(0,I3.default)(this.promise,S);if(!this._queue.length)this.resolve([]);let w;if(this.isCluster){let J=[];for(let Y=0;Y<this._queue.length;Y++){let X=this._queue[Y].getKeys();if(X.length)J.push(X[0]);if(X.length&&y0.generateMulti(X)<0)return this.reject(Error("All the keys in a pipeline command should belong to the same slot")),this.promise}if(J.length){if(w=U7(this.redis,J),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 Z(),this.promise;function Z(){let J=$.replyPending=$._queue.length,Y;if($.isCluster)Y={slot:w,redis:$.redis.connectionPool.nodes.all[$.preferKey]};let X="",U,W={isPipeline:!0,destination:$.isCluster?Y:{redis:$.redis},write(H){if(typeof H!=="string"){if(!U)U=[];if(X)U.push(Buffer.from(X,"utf8")),X="";U.push(H)}else X+=H;if(!--J){if(U){if(X)U.push(Buffer.from(X,"utf8"));W.destination.redis.stream.write(Buffer.concat(U))}else W.destination.redis.stream.write(X);J=$._queue.length,X="",U=void 0}}};for(let H=0;H<$._queue.length;++H)$.redis.sendCommand($._queue[H],W,Y);return $.promise}}});var L0=M((E3)=>{Object.defineProperty(E3,"__esModule",{value:!0});E3.addTransactionSupport=void 0;var I0=k(),O0=m(),B3=z0();function Q7(S){S.pipeline=function(Z){let J=new B3.default(this);if(Array.isArray(Z))J.addBatch(Z);return J};let{multi:w}=S;S.multi=function(Z,J){if(typeof J>"u"&&!Array.isArray(Z))J=Z,Z=null;if(J&&J.pipeline===!1)return w.call(this);let Y=new B3.default(this);if(Y.multi(),Array.isArray(Z))Y.addBatch(Z);let X=Y.exec;Y.exec=function(W){if(this.isCluster&&!this.redis.slots.length){if(this.redis.status==="wait")this.redis.connect().catch(I0.noop);return(0,O0.default)(new Promise((G,Q)=>{this.redis.delayUntilReady((V)=>{if(V){Q(V);return}this.exec(Y).then(G,Q)})}),W)}if(this._transactions>0)X.call(Y);if(this.nodeifiedPromise)return X.call(Y);let H=X.call(Y);return(0,O0.default)(H.then(function(G){let Q=G[G.length-1];if(typeof Q>"u")throw Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.");if(Q[0]){Q[0].previousErrors=[];for(let V=0;V<G.length-1;++V)if(G[V][0])Q[0].previousErrors.push(G[V][0]);throw Q[0]}return(0,I0.wrapMultiResult)(Q[1])}),W)};let{execBuffer:U}=Y;return Y.execBuffer=function(W){if(this._transactions>0)U.call(Y);return Y.exec(W)},Y};let{exec:$}=S;S.exec=function(Z){return(0,O0.default)($.call(this).then(function(J){if(Array.isArray(J))J=(0,I0.wrapMultiResult)(J);return J}),Z)}}E3.addTransactionSupport=Q7});var B0=M((K3)=>{Object.defineProperty(K3,"__esModule",{value:!0});function H7(S,w){Object.getOwnPropertyNames(w.prototype).forEach(($)=>{Object.defineProperty(S.prototype,$,Object.getOwnPropertyDescriptor(w.prototype,$))})}K3.default=H7});var k3=M((R3)=>{Object.defineProperty(R3,"__esModule",{value:!0});R3.DEFAULT_CLUSTER_OPTIONS=void 0;var P3=E("dns");R3.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:P3.resolveSrv,dnsLookup:P3.lookup,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],shardedSubscribers:!1}});var A1=M((q3)=>{Object.defineProperty(q3,"__esModule",{value:!0});q3.getConnectionName=q3.weightSrvRecords=q3.groupSrvRecords=q3.getUniqueHostnamesFromOptions=q3.normalizeNodeOptions=q3.nodeKeyToRedisOptions=q3.getNodeKey=void 0;var D3=k(),F7=E("net");function M7(S){return S.port=S.port||6379,S.host=S.host||"127.0.0.1",S.host+":"+S.port}q3.getNodeKey=M7;function y7(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))}}q3.nodeKeyToRedisOptions=y7;function z7(S){return S.map((w)=>{let $={};if(typeof w==="object")Object.assign($,w);else if(typeof w==="string")Object.assign($,(0,D3.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,D3.resolveTLSProfile)($)})}q3.normalizeNodeOptions=z7;function I7(S){let w={};return S.forEach(($)=>{w[$.host]=!0}),Object.keys(w).filter(($)=>!(0,F7.isIP)($))}q3.getUniqueHostnamesFromOptions=I7;function O7(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}q3.groupSrvRecords=O7;function L7(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[Z,J]of S.records.entries())if($+=1+J.weight,$>w)return S.totalWeight-=J.weight,S.records.splice(Z,1),J}q3.weightSrvRecords=L7;function B7(S,w){let $=`ioredis-cluster(${S})`;return w?`${$}:${w}`:$}q3.getConnectionName=B7});var A0=M((C3)=>{Object.defineProperty(C3,"__esModule",{value:!0});var T3=A1(),E0=k(),k7=l(),b=(0,E0.Debug)("cluster:subscriber");class x3{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){b("subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.");return}b("subscriber has disconnected, selecting a new one..."),this.selectSubscriber()},this.connectionPool.on("-node",(Z,J)=>{if(!this.started||!this.subscriber)return;if((0,T3.getNodeKey)(this.subscriber.options)===J)b("subscriber has left, selecting a new one..."),this.selectSubscriber()}),this.connectionPool.on("+node",()=>{if(!this.started||this.subscriber)return;b("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(),b("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,E0.sample)(this.connectionPool.getNodes());if(!w){b("selecting subscriber failed since there is no node discovered in the cluster yet"),this.subscriber=null;return}let{options:$}=w;b("selected a subscriber %s:%s",$.host,$.port);let Z="subscriber";if(this.isSharded)Z="ssubscriber";this.subscriber=new k7.default({port:$.port,host:$.host,username:$.username,password:$.password,enableReadyCheck:!0,connectionName:(0,T3.getConnectionName)(Z,$.connectionName),lazyConnect:!0,tls:$.tls,retryStrategy:null}),this.subscriber.on("error",E0.noop),this.subscriber.on("moved",()=>{this.emitter.emit("forceRefresh")}),this.subscriber.once("end",this.onSubscriberEnd);let J={subscribe:[],psubscribe:[],ssubscribe:[]};if(S){let Y=S.condition||S.prevCondition;if(Y&&Y.subscriber)J.subscribe=Y.subscriber.channels("subscribe"),J.psubscribe=Y.subscriber.channels("psubscribe"),J.ssubscribe=Y.subscriber.channels("ssubscribe")}if(J.subscribe.length||J.psubscribe.length||J.ssubscribe.length){let Y=0;for(let X of["subscribe","psubscribe","ssubscribe"]){let U=J[X];if(U.length==0)continue;if(b("%s %d channels",X,U.length),X==="ssubscribe")for(let W of U)Y+=1,this.subscriber[X](W).then(()=>{if(!--Y)this.lastActiveSubscriber=this.subscriber}).catch(()=>{b("failed to ssubscribe to channel: %s",W)});else Y+=1,this.subscriber[X](U).then(()=>{if(!--Y)this.lastActiveSubscriber=this.subscriber}).catch(()=>{b("failed to %s %d channels",X,U.length)})}}else this.lastActiveSubscriber=this.subscriber;for(let Y of["message","messageBuffer"])this.subscriber.on(Y,(X,U)=>{this.emitter.emit(Y,X,U)});for(let Y of["pmessage","pmessageBuffer"])this.subscriber.on(Y,(X,U,W)=>{this.emitter.emit(Y,X,U,W)});if(this.isSharded==!0)for(let Y of["smessage","smessageBuffer"])this.subscriber.on(Y,(X,U)=>{this.emitter.emit(Y,X,U)})}}C3.default=x3});var P0=M((f3)=>{Object.defineProperty(f3,"__esModule",{value:!0});var q7=E("events"),p1=k(),K0=A1(),N7=l(),K1=(0,p1.Debug)("cluster:connectionPool");class _3 extends q7.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,p1.sample)(w);return this.nodes[S][$]}addMasterNode(S){let w=(0,K0.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 N7.default((0,p1.defaults)({retryStrategy:null,enableOfflineQueue:!0,readOnly:w},S,this.redisOptions,{lazyConnect:!0}))}findOrCreate(S,w=!1){let $=(0,K0.getNodeKey)(S);if(w=Boolean(w),this.specifiedOptions[$])Object.assign(S,this.specifiedOptions[$]);else this.specifiedOptions[$]=S;let Z;if(this.nodes.all[$]){if(Z=this.nodes.all[$],Z.options.readOnly!==w)if(Z.options.readOnly=w,K1("Change role of %s to %s",$,w?"slave":"master"),Z[w?"readonly":"readwrite"]().catch(p1.noop),w)delete this.nodes.master[$],this.nodes.slave[$]=Z;else delete this.nodes.slave[$],this.nodes.master[$]=Z}else K1("Connecting to %s as %s",$,w?"slave":"master"),Z=this.createRedisFromOptions(S,w),this.nodes.all[$]=Z,this.nodes[w?"slave":"master"][$]=Z,Z.once("end",()=>{if(this.removeNode($),this.emit("-node",Z,$),!Object.keys(this.nodes.all).length)this.emit("drain")}),this.emit("+node",Z,$),Z.on("error",function(J){this.emit("nodeError",J,$)});return Z}reset(S){K1("Reset with %O",S);let w={};S.forEach(($)=>{let Z=(0,K0.getNodeKey)($);if(!($.readOnly&&w[Z]))w[Z]=$}),Object.keys(this.nodes.all).forEach(($)=>{if(!w[$])K1("Disconnect %s because the node does not hold any slot",$),this.nodes.all[$].disconnect(),this.removeNode($)}),Object.keys(w).forEach(($)=>{let Z=w[$];this.findOrCreate(Z,Z.readOnly)})}removeNode(S){let{nodes:w}=this;if(w.all[S])K1("Remove %s from the pool",S),delete w.all[S];delete w.master[S],delete w.slave[S]}}f3.default=_3});var u1=M((W8,v3)=>{function K(S,$){var $=$||{};if(this._capacity=$.capacity,this._head=0,this._tail=0,Array.isArray(S))this._fromArray(S);else this._capacityMask=3,this._list=[,,,,]}K.prototype.peekAt=function(w){var $=w;if($!==($|0))return;var Z=this.size();if($>=Z||$<-Z)return;if($<0)$+=Z;return $=this._head+$&this._capacityMask,this._list[$]};K.prototype.get=function(w){return this.peekAt(w)};K.prototype.peek=function(){if(this._head===this._tail)return;return this._list[this._head]};K.prototype.peekFront=function(){return this.peek()};K.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(K.prototype,"length",{get:function(){return this.size()}});K.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)};K.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)};K.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 $};K.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)};K.prototype.pop=function(){var w=this._tail;if(w===this._head)return;var $=this._list.length;this._tail=w-1+$&this._capacityMask;var Z=this._list[this._tail];if(this._list[this._tail]=void 0,this._head<2&&w>1e4&&w<=$>>>2)this._shrinkArray();return Z};K.prototype.removeOne=function(w){var $=w;if($!==($|0))return;if(this._head===this._tail)return;var Z=this.size(),J=this._list.length;if($>=Z||$<-Z)return;if($<0)$+=Z;$=this._head+$&this._capacityMask;var Y=this._list[$],X;if(w<Z/2){for(X=w;X>0;X--)this._list[$]=this._list[$=$-1+J&this._capacityMask];this._list[$]=void 0,this._head=this._head+1+J&this._capacityMask}else{for(X=Z-1-w;X>0;X--)this._list[$]=this._list[$=$+1+J&this._capacityMask];this._list[$]=void 0,this._tail=this._tail-1+J&this._capacityMask}return Y};K.prototype.remove=function(w,$){var Z=w,J,Y=$;if(Z!==(Z|0))return;if(this._head===this._tail)return;var X=this.size(),U=this._list.length;if(Z>=X||Z<-X||$<1)return;if(Z<0)Z+=X;if($===1||!$)return J=[,],J[0]=this.removeOne(Z),J;if(Z===0&&Z+$>=X)return J=this.toArray(),this.clear(),J;if(Z+$>X)$=X-Z;var W;J=Array($);for(W=0;W<$;W++)J[W]=this._list[this._head+Z+W&this._capacityMask];if(Z=this._head+Z&this._capacityMask,w+$===X){this._tail=this._tail-$+U&this._capacityMask;for(W=$;W>0;W--)this._list[Z=Z+1+U&this._capacityMask]=void 0;return J}if(w===0){this._head=this._head+$+U&this._capacityMask;for(W=$-1;W>0;W--)this._list[Z=Z+1+U&this._capacityMask]=void 0;return J}if(Z<X/2){this._head=this._head+w+$+U&this._capacityMask;for(W=w;W>0;W--)this.unshift(this._list[Z=Z-1+U&this._capacityMask]);Z=this._head-1+U&this._capacityMask;while(Y>0)this._list[Z=Z-1+U&this._capacityMask]=void 0,Y--;if(w<0)this._tail=Z}else{this._tail=Z,Z=Z+$+U&this._capacityMask;for(W=X-($+w);W>0;W--)this.push(this._list[Z++]);Z=this._tail;while(Y>0)this._list[Z=Z+1+U&this._capacityMask]=void 0,Y--}if(this._head<2&&this._tail>1e4&&this._tail<=U>>>2)this._shrinkArray();return J};K.prototype.splice=function(w,$){var Z=w;if(Z!==(Z|0))return;var J=this.size();if(Z<0)Z+=J;if(Z>J)return;if(arguments.length>2){var Y,X,U,W=arguments.length,H=this._list.length,G=2;if(!J||Z<J/2){X=Array(Z);for(Y=0;Y<Z;Y++)X[Y]=this._list[this._head+Y&this._capacityMask];if($===0){if(U=[],Z>0)this._head=this._head+Z+H&this._capacityMask}else U=this.remove(Z,$),this._head=this._head+Z+H&this._capacityMask;while(W>G)this.unshift(arguments[--W]);for(Y=Z;Y>0;Y--)this.unshift(X[Y-1])}else{X=Array(J-(Z+$));var Q=X.length;for(Y=0;Y<Q;Y++)X[Y]=this._list[this._head+Z+$+Y&this._capacityMask];if($===0){if(U=[],Z!=J)this._tail=this._head+Z+H&this._capacityMask}else U=this.remove(Z,$),this._tail=this._tail-Q+H&this._capacityMask;while(G<W)this.push(arguments[G++]);for(Y=0;Y<Q;Y++)this.push(X[Y])}return U}else return this.remove(Z,$)};K.prototype.clear=function(){this._list=Array(this._list.length),this._head=0,this._tail=0};K.prototype.isEmpty=function(){return this._head===this._tail};K.prototype.toArray=function(){return this._copyArray(!1)};K.prototype._fromArray=function(w){var $=w.length,Z=this._nextPowerOf2($);this._list=Array(Z),this._capacityMask=Z-1,this._tail=$;for(var J=0;J<$;J++)this._list[J]=w[J]};K.prototype._copyArray=function(w,$){var Z=this._list,J=Z.length,Y=this.length;if($=$|Y,$==Y&&this._head<this._tail)return this._list.slice(this._head,this._tail);var X=Array($),U=0,W;if(w||this._head>this._tail){for(W=this._head;W<J;W++)X[U++]=Z[W];for(W=0;W<this._tail;W++)X[U++]=Z[W]}else for(W=this._head;W<this._tail;W++)X[U++]=Z[W];return X};K.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};K.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};K.prototype._nextPowerOf2=function(w){var $=Math.log(w)/Math.log(2),Z=1<<$+1;return Math.max(Z,4)};v3.exports=K});var b3=M((g3)=>{Object.defineProperty(g3,"__esModule",{value:!0});var x7=k(),C7=u1(),_7=(0,x7.Debug)("delayqueue");class h3{constructor(){this.queues={},this.timeouts={}}push(S,w,$){let Z=$.callback||process.nextTick;if(!this.queues[S])this.queues[S]=new C7;if(this.queues[S].push(w),!this.timeouts[S])this.timeouts[S]=setTimeout(()=>{Z(()=>{this.timeouts[S]=null,this.execute(S)})},$.timeout)}execute(S){let w=this.queues[S];if(!w)return;let{length:$}=w;if(!$)return;_7("send %d commands in %s queue",$,S),this.queues[S]=null;while(w.length>0)w.shift()()}}g3.default=h3});var c3=M((m3)=>{Object.defineProperty(m3,"__esModule",{value:!0});var v7=k(),h7=A0(),g7=P0(),p3=A1(),d1=I1(),u3=(0,v7.Debug)("cluster:subscriberGroup");class d3{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=d1(S[0]);S.forEach((Z)=>{if(d1(Z)!=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((Z)=>Z).length}removeChannels(S){let w=d1(S[0]);S.forEach((Z)=>{if(d1(Z)!=w)return-1});let $=this.channels.get(w);if($){let Z=$.filter((J)=>!S.includes(J));this.channels.set(w,Z)}return[...this.channels.values()].flatMap((Z)=>Z).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 g7.default(S.options);if(w.addMasterNode(S)){let $=new h7.default(w,this.cluster,!0),Z=(0,p3.getNodeKey)(S.options);return this.shardedSubscribers.set(Z,$),$.start(),this._resubscribe(),this.cluster.emit("+subscriber"),$}return null}_removeSubscriber(S){let w=(0,p3.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))u3("Nothing to refresh because the new cluster map is equal to the previous one.");else{u3("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((Z)=>{let J=S.getInstance(),Y=this.channels.get(Z);if(Y&&Y.length>0){if(J)J.ssubscribe(Y),J.on("ready",()=>{J.ssubscribe(Y)})}})})}_slotsAreEqual(S){if(this.clusterSlots===void 0)return!1;else return JSON.stringify(this.clusterSlots)===JSON.stringify(S)}}m3.default=d3});var j0=M((s3)=>{Object.defineProperty(s3,"__esModule",{value:!0});var t3=Y1(),n3=E("events"),P1=e(),i3=m(),l3=u(),R0=eS(),p7=l(),u7=v1(),d7=L0(),_=k(),m7=B0(),c7=b1(),t7=k3(),i7=A0(),l7=P0(),o7=b3(),V1=A1(),o3=u1(),a7=c3(),P=(0,_.Debug)("cluster"),a3=new WeakSet;class R1 extends c7.default{constructor(S,w={}){super();if(this.slots=[],this._groupsIds={},this._groupsBySlot=Array(16384),this.isCluster=!0,this.retryAttempts=0,this.delayQueue=new o7.default,this.offlineQueue=new o3,this.isRefreshing=!1,this._refreshSlotsCacheCallbacks=[],this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this._readyDelayedCallbacks=[],this.connectionEpoch=0,n3.EventEmitter.call(this),this.startupNodes=S,this.options=(0,_.defaults)({},w,t7.DEFAULT_CLUSTER_OPTIONS,this.options),this.options.shardedSubscribers==!0)this.shardedSubscribers=new a7.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 l7.default(this.options.redisOptions),this.connectionPool.on("-node",($,Z)=>{this.emit("-node",$)}),this.connectionPool.on("+node",($)=>{this.emit("+node",$)}),this.connectionPool.on("drain",()=>{this.setStatus("close")}),this.connectionPool.on("nodeError",($,Z)=>{this.emit("node error",$,Z)}),this.subscriber=new i7.default(this.connectionPool,this),this.options.scripts)Object.entries(this.options.scripts).forEach(([$,Z])=>{this.defineCommand($,Z)});if(this.options.lazyConnect)this.setStatus("wait");else this.connect().catch(($)=>{P("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((Z)=>{if(this.connectionEpoch!==$){P("discard connecting after resolving startup nodes because epoch not match: %d != %d",$,this.connectionEpoch),w(new P1.RedisError("Connection is discarded because a new connection is made"));return}if(this.status!=="connecting"){P("discard connecting after resolving startup nodes because the status changed to %s",this.status),w(new P1.RedisError("Connection is aborted"));return}this.connectionPool.reset(Z);let J=()=>{this.setStatus("ready"),this.retryAttempts=0,this.executeOfflineCommands(),this.resetNodesRefreshInterval(),S()},Y=void 0,X=()=>{if(this.invokeReadyDelayedCallbacks(void 0),this.removeListener("close",Y),this.manuallyClosing=!1,this.setStatus("connect"),this.options.enableReadyCheck)this.readyCheck((U,W)=>{if(U||W){if(P("Ready check failed (%s). Reconnecting...",U||W),this.status==="connect")this.disconnect(!0)}else J()});else J()};if(Y=()=>{let U=Error("None of startup nodes is available");this.removeListener("refresh",X),this.invokeReadyDelayedCallbacks(U),w(U)},this.once("refresh",X),this.once("close",Y),this.once("close",this.handleCloseEvent.bind(this)),this.refreshSlotsCache((U)=>{if(U&&U.message===R0.default.defaultMessage)p7.default.prototype.silentEmit.call(this,"error",U),this.connectionPool.reset([])}),this.subscriber.start(),this.options.shardedSubscribers)this.shardedSubscribers.start()}).catch((Z)=>{this.setStatus("close"),this.handleCloseEvent(Z),this.invokeReadyDelayedCallbacks(Z),w(Z)})})}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,P("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,i3.default)(Promise.resolve("OK"),S);return setImmediate(function(){this.setStatus("close"),this.handleCloseEvent()}.bind(this)),$}return(0,i3.default)(Promise.all(this.nodes().map(($)=>$.quit().catch((Z)=>{if(Z.message===_.CONNECTION_CLOSED_ERROR_MSG)return"OK";throw Z}))).then(()=>"OK"),S)}duplicate(S=[],w={}){let $=S.length>0?S:this.startupNodes.slice(0),Z=Object.assign({},this.options,w);return new R1($,Z)}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,$=(X)=>{this.isRefreshing=!1;for(let U of this._refreshSlotsCacheCallbacks)U(X);this._refreshSlotsCacheCallbacks=[]},Z=(0,_.shuffle)(this.connectionPool.getNodes()),J=null;function Y(X){if(X===Z.length){let H=new R0.default(R0.default.defaultMessage,J);return $(H)}let U=Z[X],W=`${U.options.host}:${U.options.port}`;P("getting slot cache from %s",W),w.getInfoFromNode(U,function(H){switch(w.status){case"close":case"end":return $(Error("Cluster is disconnected."));case"disconnecting":return $(Error("Cluster is disconnecting."))}if(H)w.emit("node error",H,W),J=H,Y(X+1);else w.emit("refresh"),$()})}Y(0)}sendCommand(S,w,$){if(this.status==="wait")this.connect().catch(_.noop);if(this.status==="end")return S.reject(Error(_.CONNECTION_CLOSED_ERROR_MSG)),S.promise;let Z=this.options.scaleReads;if(Z!=="master"){if(!(S.isReadOnly||(0,t3.exists)(S.name)&&(0,t3.hasFlag)(S.name,"readonly")))Z="master"}let J=$?$.slot:S.getSlot(),Y={},X=this;if(!$&&!a3.has(S)){a3.add(S);let W=S.reject;S.reject=function(H){let G=U.bind(null,!0);X.handleError(H,Y,{moved:function(Q,V){if(P("command %s is moved to %s",S.name,V),J=Number(Q),X.slots[Q])X.slots[Q][0]=V;else X.slots[Q]=[V];X._groupsBySlot[Q]=X._groupsIds[X.slots[Q].join(";")],X.connectionPool.findOrCreate(X.natMapper(V)),U(),P("refreshing slot caches... (triggered by MOVED error)"),X.refreshSlotsCache()},ask:function(Q,V){P("command %s is required to ask %s:%s",S.name,V);let F=X.natMapper(V);X.connectionPool.findOrCreate(F),U(!1,`${F.host}:${F.port}`)},tryagain:G,clusterDown:G,connectionClosed:G,maxRedirections:function(Q){W.call(S,Q)},defaults:function(){W.call(S,H)}})}}U();function U(W,H){if(X.status==="end"){S.reject(new P1.AbortError("Cluster is ended."));return}let G;if(X.status==="ready"||S.name==="cluster"){if($&&$.redis)G=$.redis;else if(l3.default.checkFlag("ENTER_SUBSCRIBER_MODE",S.name)||l3.default.checkFlag("EXIT_SUBSCRIBER_MODE",S.name)){if(X.options.shardedSubscribers==!0&&(S.name=="ssubscribe"||S.name=="sunsubscribe")){let Q=X.shardedSubscribers.getResponsibleSubscriber(J),V=-1;if(S.name=="ssubscribe")V=X.shardedSubscribers.addChannels(S.getKeys());if(S.name=="sunsubscribe")V=X.shardedSubscribers.removeChannels(S.getKeys());if(V!==-1)G=Q.getInstance();else S.reject(new P1.AbortError("Can't add or remove the given channels. Are they in the same slot?"))}else G=X.subscriber.getInstance();if(!G){S.reject(new P1.AbortError("No subscriber for the cluster"));return}}else{if(!W){if(typeof J==="number"&&X.slots[J]){let Q=X.slots[J];if(typeof Z==="function"){let V=Q.map(function(F){return X.connectionPool.getInstanceByKey(F)});if(G=Z(V,S),Array.isArray(G))G=(0,_.sample)(G);if(!G)G=V[0]}else{let V;if(Z==="all")V=(0,_.sample)(Q);else if(Z==="slave"&&Q.length>1)V=(0,_.sample)(Q,1);else V=Q[0];G=X.connectionPool.getInstanceByKey(V)}}if(H)G=X.connectionPool.getInstanceByKey(H),G.asking()}if(!G)G=(typeof Z==="function"?null:X.connectionPool.getSampleInstance(Z))||X.connectionPool.getSampleInstance("all")}if($&&!$.redis)$.redis=G}if(G)G.sendCommand(S,w);else if(X.options.enableOfflineQueue)X.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 Z=S.message.split(" ");if(Z[0]==="MOVED"){let J=this.options.retryDelayOnMoved;if(J&&typeof J==="number")this.delayQueue.push("moved",$.moved.bind(null,Z[1],Z[2]),{timeout:J});else $.moved(Z[1],Z[2])}else if(Z[0]==="ASK")$.ask(Z[1],Z[2]);else if(Z[0]==="TRYAGAIN")this.delayQueue.push("tryagain",$.tryagain,{timeout:this.options.retryDelayOnTryAgain});else if(Z[0]==="CLUSTERDOWN"&&this.options.retryDelayOnClusterDown>0)this.delayQueue.push("clusterdown",$.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)});else if(S.message===_.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 o3}clearNodesRefreshInterval(){if(this.slotsTimer)clearTimeout(this.slotsTimer),this.slotsTimer=null}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval)return;let S=()=>{this.slotsTimer=setTimeout(()=>{P('refreshing slot caches... (triggered by "slotsRefreshInterval" option)'),this.refreshSlotsCache(()=>{S()})},this.options.slotsRefreshInterval)};S()}setStatus(S){P("status: %s -> %s",this.status||"[empty]",S),this.status=S,process.nextTick(()=>{this.emit(S)})}handleCloseEvent(S){if(S)P("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,P("Cluster is disconnected. Retrying after %dms",w),this.connect().catch(function($){P("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){P("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 P("NAT mapping %s -> %O",w,$),Object.assign({},$);return typeof S==="string"?(0,V1.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,V1.getConnectionName)("refresher",this.options.redisOptions&&this.options.redisOptions.connectionName)});$.on("error",_.noop),$.cluster("SLOTS",(0,_.timeout)((Z,J)=>{if($.disconnect(),Z)return P("error encountered running CLUSTER.SLOTS: %s",Z),w(Z);if(this.status==="disconnecting"||this.status==="close"||this.status==="end"){P("ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s",J.length,this.status),w();return}let Y=[];P("cluster slots result count: %d",J.length);for(let U=0;U<J.length;++U){let W=J[U],H=W[0],G=W[1],Q=[];for(let V=2;V<W.length;V++){if(!W[V][0])continue;let F=this.natMapper({host:W[V][0],port:W[V][1]});F.readOnly=V!==2,Y.push(F),Q.push(F.host+":"+F.port)}P("cluster slots result [%d]: slots %d~%d served by %s",U,H,G,Q);for(let V=H;V<=G;V++)this.slots[V]=Q}this._groupsIds=Object.create(null);let X=0;for(let U=0;U<16384;U++){let W=(this.slots[U]||[]).join(";");if(!W.length){this._groupsBySlot[U]=void 0;continue}if(!this._groupsIds[W])this._groupsIds[W]=++X;this._groupsBySlot[U]=this._groupsIds[W]}this.connectionPool.reset(Y),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 Z,J=$.split(`\r
|
|
159
|
+
`);for(let Y=0;Y<J.length;++Y){let X=J[Y].split(":");if(X[0]==="cluster_state"){Z=X[1];break}}if(Z==="fail")P("cluster state not ok (%s)",Z),S(null,Z);else S()})}resolveSrv(S){return new Promise((w,$)=>{this.options.resolveSrv(S,(Z,J)=>{if(Z)return $(Z);let Y=this,X=(0,V1.groupSrvRecords)(J),U=Object.keys(X).sort((H,G)=>parseInt(H)-parseInt(G));function W(H){if(!U.length)return $(H);let G=U[0],Q=X[G],V=(0,V1.weightSrvRecords)(Q);if(!Q.records.length)U.shift();Y.dnsLookup(V.name).then((F)=>w({host:F,port:V.port}),W)}W()})})}dnsLookup(S){return new Promise((w,$)=>{this.options.dnsLookup(S,(Z,J)=>{if(Z)P("failed to resolve hostname %s to IP: %s",S,Z.message),$(Z);else P("resolved hostname %s to IP %s",S,J),w(J)})})}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0)throw Error("`startupNodes` should contain at least one node.");let S=(0,V1.normalizeNodeOptions)(this.startupNodes),w=(0,V1.getUniqueHostnamesFromOptions)(S);if(w.length===0)return S;let $=await Promise.all(w.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this))),Z=(0,_.zipMap)(w,$);return S.map((J)=>{let Y=Z.get(J.host);if(!Y)return J;if(this.options.useSRVRecords)return Object.assign({},J,Y);return Object.assign({},J,{host:Y})})}createScanStream(S,{key:w,options:$={}}){return new u7.default({objectMode:!0,key:w,redis:this,command:S,...$})}}(0,m7.default)(R1,n3.EventEmitter);(0,d7.addTransactionSupport)(R1.prototype);s3.default=R1});var m1=M((e3)=>{Object.defineProperty(e3,"__esModule",{value:!0});var s7=k(),r7=(0,s7.Debug)("AbstractConnector");class r3{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(()=>{r7("stream %s:%s still open, destroying it",S.remoteAddress,S.remotePort),S.destroy()},this.disconnectTimeout);S.on("close",()=>clearTimeout(w)),S.end()}}}e3.default=r3});var $w=M((ww)=>{Object.defineProperty(ww,"__esModule",{value:!0});var S$=E("net"),w$=E("tls"),$$=k(),Z$=m1();class Sw extends Z$.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((Z,J)=>{process.nextTick(()=>{if(!this.connecting){J(Error($$.CONNECTION_CLOSED_ERROR_MSG));return}try{if(w.tls)this.stream=(0,w$.connect)($);else this.stream=(0,S$.createConnection)($)}catch(Y){J(Y);return}this.stream.once("error",(Y)=>{this.firstError=Y}),Z(this.stream)})})}}ww.default=Sw});var Yw=M((Jw)=>{Object.defineProperty(Jw,"__esModule",{value:!0});function Y$(S,w){return(S.host||"127.0.0.1")===(w.host||"127.0.0.1")&&(S.port||26379)===(w.port||26379)}class Zw{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(Y$(S,this.sentinels[w]))return!1;return this.sentinels.push(S),!0}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}}Jw.default=Zw});var Qw=M((Ww)=>{Object.defineProperty(Ww,"__esModule",{value:!0});Ww.FailoverDetector=void 0;var U$=k(),k0=(0,U$.Debug)("FailoverDetector"),Xw="+switch-master";class Uw{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(){k0("Starting FailoverDetector");let S=[];for(let w of this.sentinels){let $=w.client.subscribe(Xw).catch((Z)=>{k0("Failed to subscribe to failover messages on sentinel %s:%s (%s)",w.address.host||"127.0.0.1",w.address.port||26739,Z.message)});S.push($),w.client.on("message",(Z)=>{if(!this.isDisconnected&&Z===Xw)this.disconnect()})}await Promise.all(S)}disconnect(){this.isDisconnected=!0,k0("Failover detected, disconnecting"),this.connector.disconnect()}}Ww.FailoverDetector=Uw});var c1=M((Mw)=>{Object.defineProperty(Mw,"__esModule",{value:!0});Mw.SentinelIterator=void 0;var W$=E("net"),j1=k(),G$=E("tls"),Hw=Yw();Mw.SentinelIterator=Hw.default;var Q$=m1(),H$=l(),V$=Qw(),F1=(0,j1.Debug)("SentinelConnector");class Vw extends Q$.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 Hw.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 Z=this.sentinelIterator.next();if(Z.done){this.sentinelIterator.reset(!1);let U=typeof this.options.sentinelRetryStrategy==="function"?this.options.sentinelRetryStrategy(++this.retryAttempts):null,W=typeof U!=="number"?"All sentinels are unreachable and retry is disabled.":`All sentinels are unreachable. Retrying from scratch after ${U}ms.`;if(w)W+=` Last error: ${w.message}`;F1(W);let H=Error(W);if(typeof U==="number")return S("error",H),await new Promise((G)=>setTimeout(G,U)),$();else throw H}let J=null,Y=null;try{J=await this.resolve(Z.value)}catch(U){Y=U}if(!this.connecting)throw Error(j1.CONNECTION_CLOSED_ERROR_MSG);let X=Z.value.host+":"+Z.value.port;if(J){if(F1("resolved: %s:%s from sentinel %s",J.host,J.port,X),this.options.enableTLSForSentinelMode&&this.options.tls)Object.assign(J,this.options.tls),this.stream=(0,G$.connect)(J),this.stream.once("secureConnect",this.initFailoverDetector.bind(this));else this.stream=(0,W$.createConnection)(J),this.stream.once("connect",this.initFailoverDetector.bind(this));return this.stream.once("error",(U)=>{this.firstError=U}),this.stream}else{let U=Y?"failed to connect to sentinel "+X+" because "+Y.message:"connected to sentinel "+X+" successfully, but got an invalid reply: "+J;if(F1(U),S("sentinelError",Error(U)),Y)w=Y;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(j1.packObject).forEach(($)=>{if(($.flags?$.flags.split(","):[]).indexOf("disconnected")===-1&&$.ip&&$.port){let J=this.sentinelNatResolve(Fw($));if(this.sentinelIterator.add(J))F1("adding sentinel %s:%s",J.host,J.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(j1.packObject).filter((Z)=>Z.flags&&!Z.flags.match(/(disconnected|s_down|o_down)/));return this.sentinelNatResolve(F$($,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 H$.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",M$);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:Z}=this.sentinelIterator.next();if($)break;let J=this.connectToSentinel(Z,{lazyConnect:!0,retryStrategy:this.options.sentinelReconnectStrategy});J.on("reconnecting",()=>{var Y;(Y=this.emitter)===null||Y===void 0||Y.emit("sentinelReconnecting")}),w.push({address:Z,client:J})}if(this.sentinelIterator.reset(!1),this.failoverDetector)this.failoverDetector.cleanup();this.failoverDetector=new V$.FailoverDetector(this,w),await this.failoverDetector.subscribe(),(S=this.emitter)===null||S===void 0||S.emit("failoverSubscribed")}}Mw.default=Vw;function F$(S,w){if(S.length===0)return null;let $;if(typeof w==="function")$=w(S);else if(w!==null&&typeof w==="object"){let Z=Array.isArray(w)?w:[w];Z.sort((J,Y)=>{if(!J.prio)J.prio=1;if(!Y.prio)Y.prio=1;if(J.prio<Y.prio)return-1;if(J.prio>Y.prio)return 1;return 0});for(let J=0;J<Z.length;J++){for(let Y=0;Y<S.length;Y++){let X=S[Y];if(X.ip===Z[J].ip){if(X.port===Z[J].port){$=X;break}}}if($)break}}if(!$)$=(0,j1.sample)(S);return Fw($)}function Fw(S){return{host:S.ip,port:Number(S.port)}}function M$(){}});var Ow=M((zw)=>{Object.defineProperty(zw,"__esModule",{value:!0});zw.SentinelConnector=zw.StandaloneConnector=void 0;var z$=$w();zw.StandaloneConnector=z$.default;var I$=c1();zw.SentinelConnector=I$.default});var Ew=M((Bw)=>{Object.defineProperty(Bw,"__esModule",{value:!0});var L$=e();class Lw extends L$.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}}Bw.default=Lw});var Pw=M((Aw)=>{Object.defineProperty(Aw,"__esModule",{value:!0});Aw.MaxRetriesPerRequestError=void 0;var E$=Ew();Aw.MaxRetriesPerRequestError=E$.default});var xw=M((B8,Tw)=>{var x0=E("buffer").Buffer,A$=E("string_decoder").StringDecoder,D0=new A$,Rw=e(),K$=Rw.ReplyError,P$=Rw.ParserError,h=x0.allocUnsafe(32768),q=0,t1=null,k1=0,q0=0;function R$(S){let w=S.buffer.length-1;var $=S.offset,Z=0,J=1;if(S.buffer[$]===45)J=-1,$++;while($<w){let Y=S.buffer[$++];if(Y===13)return S.offset=$+1,J*Z;Z=Z*10+(Y-48)}}function j$(S){let w=S.buffer.length-1;var $=S.offset,Z=0,J="";if(S.buffer[$]===45)J+="-",$++;while($<w){var Y=S.buffer[$++];if(Y===13){if(S.offset=$+1,Z!==0)J+=Z;return J}else if(Z>429496728)J+=Z*10+(Y-48),Z=0;else if(Y===48&&Z===0)J+=0;else Z=Z*10+(Y-48)}}function jw(S){let{offset:w,buffer:$}=S,Z=$.length-1;var J=w;while(J<Z)if($[J++]===13){if(S.offset=J+1,S.optionReturnBuffers===!0)return S.buffer.slice(w,J-1);return S.buffer.toString("utf8",w,J-1)}}function kw(S){let w=S.buffer.length-1;var $=S.offset,Z=0;while($<w){let J=S.buffer[$++];if(J===13)return S.offset=$+1,Z;Z=Z*10+(J-48)}}function k$(S){if(S.optionStringNumbers===!0)return j$(S);return R$(S)}function D$(S){let w=kw(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 Z=S.offset;if(S.offset=$+2,S.optionReturnBuffers===!0)return S.buffer.slice(Z,$);return S.buffer.toString("utf8",Z,$)}function q$(S){var w=jw(S);if(w!==void 0){if(S.optionReturnBuffers===!0)w=w.toString();return new K$(w)}}function N$(S,w){let $=new P$("Protocol error, got "+JSON.stringify(String.fromCharCode(w))+" as reply type byte",JSON.stringify(S.buffer),S.offset);S.buffer=null,S.returnFatalError($)}function T$(S){let w=kw(S);if(w===void 0)return;if(w<0)return null;let $=Array(w);return Dw(S,$,0)}function N0(S,w,$){S.arrayCache.push(w),S.arrayPos.push($)}function T0(S){let w=S.arrayCache.pop();var $=S.arrayPos.pop();if(S.arrayCache.length){let Z=T0(S);if(Z===void 0){N0(S,w,$);return}w[$++]=Z}return Dw(S,w,$)}function Dw(S,w,$){let Z=S.buffer.length;while($<w.length){let J=S.offset;if(S.offset>=Z){N0(S,w,$);return}let Y=qw(S,S.buffer[S.offset++]);if(Y===void 0){if(!(S.arrayCache.length||S.bufferCache.length))S.offset=J;N0(S,w,$);return}w[$]=Y,$++}return w}function qw(S,w){switch(w){case 36:return D$(S);case 43:return jw(S);case 42:return T$(S);case 58:return k$(S);case 45:return q$(S);default:return N$(S,w)}}function x$(){if(h.length>51200)if(k1===1||q0>k1*2){let S=Math.floor(h.length/10),w=S<q?q:S;q=0,h=h.slice(w,h.length)}else q0++,k1--;else clearInterval(t1),k1=0,q0=0,t1=null}function C$(S){if(h.length<S+q){let w=S>78643200?2:3;if(q>116391936)q=52428800;if(h=x0.allocUnsafe(S*w+q),q=0,k1++,t1===null)t1=setInterval(x$,50)}}function _$(S){let{bufferCache:w,offset:$}=S;var Z=w.length,J=S.bigStrSize-S.totalChunkSize;if(S.offset=J,J<=2){if(Z===2)return w[0].toString("utf8",$,w[0].length+J-2);Z--,J=w[w.length-2].length+J}var Y=D0.write(w[0].slice($));for(var X=1;X<Z-1;X++)Y+=D0.write(w[X]);return Y+=D0.end(w[X].slice(0,J-2)),Y}function f$(S){let{bufferCache:w,offset:$}=S,Z=S.bigStrSize-$-2;var J=w.length,Y=S.bigStrSize-S.totalChunkSize;if(S.offset=Y,Y<=2){if(J===2)return w[0].slice($,w[0].length+Y-2);J--,Y=w[w.length-2].length+Y}C$(Z);let X=q;w[0].copy(h,X,$,w[0].length),q+=w[0].length-$;for(var U=1;U<J-1;U++)w[U].copy(h,q),q+=w[U].length;return w[U].copy(h,q,0,Y-2),q+=Y-2,h.slice(X,q)}class Nw{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,Z=$-this.offset,J=x0.allocUnsafe(Z+S.length);if(this.buffer.copy(J,0,this.offset,$),S.copy(J,Z,0,S.length),this.buffer=J,this.offset=0,this.arrayCache.length){let Y=T0(this);if(Y===void 0)return;this.returnReply(Y)}}else if(this.totalChunkSize+S.length>=this.bigStrSize){this.bufferCache.push(S);var w=this.optionReturnBuffers?f$(this):_$(this);if(this.bigStrSize=0,this.bufferCache=[],this.buffer=S,this.arrayCache.length){if(this.arrayCache[0][this.arrayPos[0]++]=w,w=T0(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,Z=this.buffer[this.offset++],J=qw(this,Z);if(J===void 0){if(!(this.arrayCache.length||this.bufferCache.length))this.offset=$;return}if(Z===45)this.returnError(J);else this.returnReply(J)}this.buffer=null}}Tw.exports=Nw});var fw=M((_w)=>{Object.defineProperty(_w,"__esModule",{value:!0});class Cw{constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(S,w){this.set[C0(S)][w]=!0}del(S,w){delete this.set[C0(S)][w]}channels(S){return Object.keys(this.set[C0(S)])}isEmpty(){return this.channels("subscribe").length===0&&this.channels("psubscribe").length===0&&this.channels("ssubscribe").length===0}}_w.default=Cw;function C0(S){if(S==="unsubscribe")return"subscribe";if(S==="punsubscribe")return"psubscribe";if(S==="sunsubscribe")return"ssubscribe";return S}});var uw=M((pw)=>{Object.defineProperty(pw,"__esModule",{value:!0});var vw=u(),h$=k(),g$=xw(),b$=fw(),p$=(0,h$.Debug)("dataHandler");class bw{constructor(S,w){this.redis=S;let $=new g$({stringNumbers:w.stringNumbers,returnBuffers:!0,returnError:(Z)=>{this.returnError(Z)},returnFatalError:(Z)=>{this.returnFatalError(Z)},returnReply:(Z)=>{this.returnReply(Z)}});S.stream.prependListener("data",(Z)=>{$.execute(Z)}),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(vw.default.checkFlag("ENTER_SUBSCRIBER_MODE",w.command.name)){if(this.redis.condition.subscriber=new b$.default,this.redis.condition.subscriber.add(w.command.name,S[1].toString()),!hw(w.command,S[2]))this.redis.commandQueue.unshift(w)}else if(vw.default.checkFlag("EXIT_SUBSCRIBER_MODE",w.command.name)){if(!gw(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(p$('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 Z=this.shiftCommand(S);if(!Z)return;if(!hw(Z.command,S[2]))this.redis.commandQueue.unshift(Z);break}case"sunsubscribe":case"unsubscribe":case"punsubscribe":{let $=S[1]?S[1].toString():null;if($)this.redis.condition.subscriber.del(w,$);let Z=S[2];if(Number(Z)===0)this.redis.condition.subscriber=!1;let J=this.shiftCommand(S);if(!J)return;if(!gw(J.command,Z))this.redis.commandQueue.unshift(J);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(" "),Z=w.slice(0,$),J=w.indexOf('"'),Y=w.slice(J+1,-1).split('" "').map((U)=>U.replace(/\\"/g,'"')),X=w.slice($+2,J-2).split(" ");return this.redis.emit("monitor",Z,Y,X[1],X[0]),!0}shiftCommand(S){let w=this.redis.commandQueue.shift();if(!w){let Z=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",Z),null}return w}}pw.default=bw;var o=new WeakMap;function hw(S,w){let $=o.has(S)?o.get(S):S.args.length;if($-=1,$<=0)return S.resolve(w),o.delete(S),!0;return o.set(S,$),!1}function gw(S,w){let $=o.has(S)?o.get(S):S.args.length;if($===0){if(Number(w)===0)return o.delete(S),S.resolve(w),!0;return!1}if($-=1,$<=0)return S.resolve(w),!0;return o.set(S,$),!1}});var mw=M((dw)=>{Object.defineProperty(dw,"__esModule",{value:!0});dw.readyHandler=dw.errorHandler=dw.closeHandler=dw.connectHandler=void 0;var d$=e(),m$=u(),c$=Pw(),d=k(),t$=uw(),D=(0,d.Debug)("connection");function i$(S){return function(){S.setStatus("connect"),S.resetCommandQueue();let w=!1,{connectionEpoch:$}=S;if(S.condition.auth)S.auth(S.condition.auth,function(Z){if($!==S.connectionEpoch)return;if(Z)if(Z.message.indexOf("no password is set")!==-1)console.warn("[WARN] Redis server does not require a password, but a password was supplied.");else if(Z.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(Z.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(Z,Z)});if(S.condition.select)S.select(S.condition.select).catch((Z)=>{S.silentEmit("error",Z)});if(!S.options.enableReadyCheck)dw.readyHandler(S)();if(new t$.default(S,{stringNumbers:S.options.stringNumbers}),S.options.enableReadyCheck)S._readyCheck(function(Z,J){if($!==S.connectionEpoch)return;if(Z){if(!w)S.recoverFromFatalError(Error("Ready check failed: "+Z.message),Z)}else if(S.connector.check(J))dw.readyHandler(S)();else S.disconnect(!0)})}}dw.connectHandler=i$;function _0(S){let w=new d$.AbortError("Command aborted due to connection close");return w.command={name:S.name,args:S.args},w}function l$(S){var w;let $=0;for(let Z=0;Z<S.length;){let J=(w=S.peekAt(Z))===null||w===void 0?void 0:w.command,Y=J.pipelineIndex;if(Y===void 0||Y===0)$=0;if(Y!==void 0&&Y!==$++){S.remove(Z,1),J.reject(_0(J));continue}Z++}}function o$(S){var w;for(let $=0;$<S.length;){let Z=(w=S.peekAt($))===null||w===void 0?void 0:w.command;if(Z.name==="multi")break;if(Z.name==="exec"){S.remove($,1),Z.reject(_0(Z));break}if(Z.inTransaction)S.remove($,1),Z.reject(_0(Z));else $++}}function a$(S){return function(){let $=S.status;if(S.setStatus("close"),S.commandQueue.length)l$(S.commandQueue);if(S.offlineQueue.length)o$(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,D("skip reconnecting since the connection is manually closed."),w();if(typeof S.options.retryStrategy!=="function")return D("skip reconnecting because `retryStrategy` is not a function"),w();let Z=S.options.retryStrategy(++S.retryAttempts);if(typeof Z!=="number")return D("skip reconnecting because `retryStrategy` doesn't return a number"),w();D("reconnect in %sms",Z),S.setStatus("reconnecting",Z),S.reconnectTimeout=setTimeout(function(){S.reconnectTimeout=null,S.connect().catch(d.noop)},Z);let{maxRetriesPerRequest:J}=S.options;if(typeof J==="number"){if(J<0)D("maxRetriesPerRequest is negative, ignoring...");else if(S.retryAttempts%(J+1)===0)D("reach maxRetriesPerRequest limitation, flushing command queue..."),S.flushQueue(new c$.MaxRetriesPerRequestError(J))}};function w(){S.setStatus("end"),S.flushQueue(Error(d.CONNECTION_CLOSED_ERROR_MSG))}}dw.closeHandler=a$;function n$(S){return function(w){D("error: %s",w),S.silentEmit("error",w)}}dw.errorHandler=n$;function s$(S){return function(){var w,$;if(S.setStatus("ready"),S.retryAttempts=0,S.options.monitor){S.call("monitor").then(()=>S.setStatus("monitoring"),(Y)=>S.emit("error",Y));let{sendCommand:J}=S;S.sendCommand=function(Y){if(m$.default.checkFlag("VALID_IN_MONITOR_MODE",Y.name))return J.call(S,Y);return Y.reject(Error("Connection is in monitoring mode, can't process commands.")),Y.promise},S.once("close",function(){delete S.sendCommand});return}let Z=S.prevCondition?S.prevCondition.select:S.condition.select;if(S.options.connectionName)D("set the connection name [%s]",S.options.connectionName),S.client("setname",S.options.connectionName).catch(d.noop);if(!((w=S.options)===null||w===void 0?void 0:w.disableClientInfo)){D("set the client info");let J=null;(0,d.getPackageMeta)().then((Y)=>{J=Y===null||Y===void 0?void 0:Y.version}).catch(d.noop).finally(()=>{S.client("SETINFO","LIB-VER",J).catch(d.noop)}),S.client("SETINFO","LIB-NAME",(($=S.options)===null||$===void 0?void 0:$.clientInfoTag)?`ioredis(${S.options.clientInfoTag})`:"ioredis").catch(d.noop)}if(S.options.readOnly)D("set the connection to readonly mode"),S.readonly().catch(d.noop);if(S.prevCondition){let J=S.prevCondition;if(S.prevCondition=null,J.subscriber&&S.options.autoResubscribe){if(S.condition.select!==Z)D("connect to db [%d]",Z),S.select(Z);let Y=J.subscriber.channels("subscribe");if(Y.length)D("subscribe %d channels",Y.length),S.subscribe(Y);let X=J.subscriber.channels("psubscribe");if(X.length)D("psubscribe %d channels",X.length),S.psubscribe(X);let U=J.subscriber.channels("ssubscribe");if(U.length){D("ssubscribe %s",U.length);for(let W of U)S.ssubscribe(W)}}}if(S.prevCommandQueue)if(S.options.autoResendUnfulfilledCommands){D("resend %d unfulfilled commands",S.prevCommandQueue.length);while(S.prevCommandQueue.length>0){let J=S.prevCommandQueue.shift();if(J.select!==S.condition.select&&J.command.name!=="select")S.select(J.select);S.sendCommand(J.command,J.stream)}}else S.prevCommandQueue=null;if(S.offlineQueue.length){D("send %d commands in offline queue",S.offlineQueue.length);let J=S.offlineQueue;S.resetOfflineQueue();while(J.length>0){let Y=J.shift();if(Y.select!==S.condition.select&&Y.command.name!=="select")S.select(Y.select);S.sendCommand(Y.command,Y.stream)}}if(S.condition.select!==Z)D("connect to db [%d]",Z),S.select(Z)}}dw.readyHandler=s$});var iw=M((cw)=>{Object.defineProperty(cw,"__esModule",{value:!0});cw.DEFAULT_REDIS_OPTIONS=void 0;cw.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 l=M((nw)=>{Object.defineProperty(nw,"__esModule",{value:!0});var lw=Y1(),aw=E("events"),f0=m(),wZ=j0(),v0=u(),$Z=Ow(),ZZ=c1(),a=mw(),JZ=iw(),YZ=v1(),XZ=L0(),J1=k(),UZ=B0(),WZ=b1(),n=N1(),ow=u1(),s=(0,J1.Debug)("redis");class p extends WZ.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,$),aw.EventEmitter.call(this),this.resetCommandQueue(),this.resetOfflineQueue(),this.options.Connector)this.connector=new this.options.Connector(this.options);else if(this.options.sentinels){let Z=new ZZ.default(this.options);Z.emitter=this,this.connector=Z}else this.connector=new $Z.StandaloneConnector(this.options);if(this.options.scripts)Object.entries(this.options.scripts).forEach(([Z,J])=>{this.defineCommand(Z,J)});if(this.options.lazyConnect)this.setStatus("wait");else this.connect().catch(n.noop)}static createClient(...S){return new p(...S)}get autoPipelineQueueSize(){let S=0;for(let w of this._autoPipelines.values())S+=w.length;return S}connect(S){let w=new Promise(($,Z)=>{if(this.status==="connecting"||this.status==="connect"||this.status==="ready"){Z(Error("Redis is already connecting/connected"));return}this.connectionEpoch+=1,this.setStatus("connecting");let{options:J}=this;this.condition={select:J.db,auth:J.username?[J.username,J.password]:J.password,subscriber:!1};let Y=this;(0,f0.default)(this.connector.connect(function(X,U){Y.silentEmit(X,U)}),function(X,U){if(X){Y.flushQueue(X),Y.silentEmit("error",X),Z(X),Y.setStatus("end");return}let W=J.tls?"secureConnect":"connect";if("sentinels"in J&&J.sentinels&&!J.enableTLSForSentinelMode)W="connect";if(Y.stream=U,J.noDelay)U.setNoDelay(!0);if(typeof J.keepAlive==="number")if(U.connecting)U.once(W,()=>{U.setKeepAlive(!0,J.keepAlive)});else U.setKeepAlive(!0,J.keepAlive);if(U.connecting){if(U.once(W,a.connectHandler(Y)),J.connectTimeout){let Q=!1;U.setTimeout(J.connectTimeout,function(){if(Q)return;U.setTimeout(0),U.destroy();let V=Error("connect ETIMEDOUT");V.errorno="ETIMEDOUT",V.code="ETIMEDOUT",V.syscall="connect",a.errorHandler(Y)(V)}),U.once(W,function(){Q=!0,U.setTimeout(0)})}}else if(U.destroyed){let Q=Y.connector.firstError;if(Q)process.nextTick(()=>{a.errorHandler(Y)(Q)});process.nextTick(a.closeHandler(Y))}else process.nextTick(a.connectHandler(Y));if(!U.destroyed)U.once("error",a.errorHandler(Y)),U.once("close",a.closeHandler(Y));let H=function(){Y.removeListener("close",G),$()};var G=function(){Y.removeListener("ready",H),Z(Error(J1.CONNECTION_CLOSED_ERROR_MSG))};Y.once("ready",H),Y.once("close",G)})});return(0,f0.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")a.closeHandler(this)();else this.connector.disconnect()}end(){this.disconnect()}duplicate(S){return new p({...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,f0.default)(new Promise(function($,Z){w.once("error",Z),w.once("monitoring",function(){$(w)})}),S)}sendCommand(S,w){var $,Z;if(this.status==="wait")this.connect().catch(n.noop);if(this.status==="end")return S.reject(Error(J1.CONNECTION_CLOSED_ERROR_MSG)),S.promise;if((($=this.condition)===null||$===void 0?void 0:$.subscriber)&&!v0.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 J=this.status==="ready"||!w&&this.status==="connect"&&(0,lw.exists)(S.name)&&(0,lw.hasFlag)(S.name,"loading");if(!this.stream)J=!1;else if(!this.stream.writable)J=!1;else if(this.stream._writableState&&this.stream._writableState.ended)J=!1;if(!J){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(s.enabled)s("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(s.enabled)s("write command[%s]: %d -> %s(%o)",this._getDescription(),(Z=this.condition)===null||Z===void 0?void 0:Z.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}),v0.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,J1.isInt)(S.args[0])){let Y=parseInt(S.args[0],10);if(this.condition.select!==Y)this.condition.select=Y,this.emit("select",Y),s("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===J1.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 Z=!1;if(this.options.reconnectOnError)Z=this.options.reconnectOnError(S);switch(Z){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 ow}resetOfflineQueue(){this.offlineQueue=new ow}parseOptions(...S){let w={},$=!1;for(let Z=0;Z<S.length;++Z){let J=S[Z];if(J===null||typeof J>"u")continue;if(typeof J==="object")(0,n.defaults)(w,J);else if(typeof J==="string"){if((0,n.defaults)(w,(0,J1.parseURL)(J)),J.startsWith("rediss://"))$=!0}else if(typeof J==="number")w.port=J;else throw Error("Invalid argument "+J)}if($)(0,n.defaults)(w,{tls:!0});if((0,n.defaults)(w,p.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,J1.resolveTLSProfile)(w)}setStatus(S,w){if(s.enabled)s("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 YZ.default({objectMode:!0,key:w,redis:this,command:S,...$})}flushQueue(S,w){w=(0,n.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($,Z){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 Z!=="string")return S(null,Z);let J={},Y=Z.split(`\r
|
|
160
|
+
`);for(let X=0;X<Y.length;++X){let[U,...W]=Y[X].split(":"),H=W.join(":");if(H)J[U]=H}if(!J.loading||J.loading==="0")S(null,J);else{let X=(J.loading_eta_seconds||1)*1000,U=w.options.maxLoadingRetryTime&&w.options.maxLoadingRetryTime<X?w.options.maxLoadingRetryTime:X;s("Redis server still loading, trying again in "+U+"ms"),setTimeout(function(){w._readyCheck(S)},U)}}).catch(n.noop)}}p.Cluster=wZ.default;p.Command=v0.default;p.defaultOptions=JZ.DEFAULT_REDIS_OPTIONS;(0,UZ.default)(p,aw.EventEmitter);(0,XZ.addTransactionSupport)(p.prototype);nw.default=p});var ew=M((N,rw)=>{Object.defineProperty(N,"__esModule",{value:!0});N.print=N.ReplyError=N.SentinelIterator=N.SentinelConnector=N.AbstractConnector=N.Pipeline=N.ScanStream=N.Command=N.Cluster=N.Redis=N.default=void 0;N=rw.exports=l().default;var QZ=l();Object.defineProperty(N,"default",{enumerable:!0,get:function(){return QZ.default}});var HZ=l();Object.defineProperty(N,"Redis",{enumerable:!0,get:function(){return HZ.default}});var VZ=j0();Object.defineProperty(N,"Cluster",{enumerable:!0,get:function(){return VZ.default}});var FZ=u();Object.defineProperty(N,"Command",{enumerable:!0,get:function(){return FZ.default}});var MZ=v1();Object.defineProperty(N,"ScanStream",{enumerable:!0,get:function(){return MZ.default}});var yZ=z0();Object.defineProperty(N,"Pipeline",{enumerable:!0,get:function(){return yZ.default}});var zZ=m1();Object.defineProperty(N,"AbstractConnector",{enumerable:!0,get:function(){return zZ.default}});var sw=c1();Object.defineProperty(N,"SentinelConnector",{enumerable:!0,get:function(){return sw.default}});Object.defineProperty(N,"SentinelIterator",{enumerable:!0,get:function(){return sw.SentinelIterator}});N.ReplyError=e().ReplyError;Object.defineProperty(N,"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 IZ(S,w){if(S)console.log("Error: "+S);else console.log("Reply: "+w)}N.print=IZ});var u0;((Z)=>{Z.Postgres="postgres";Z.MySQL="mysql";Z.SQLite="sqlite"})(u0||={});var l1;((J)=>{J[J.Debug=0]="Debug";J[J.Info=1]="Info";J[J.Warn=2]="Warn";J[J.Error=3]="Error"})(l1||={});var d0;((J)=>{J[J.OneToOne=0]="OneToOne";J[J.OneToMany=1]="OneToMany";J[J.ManyToOne=2]="ManyToOne";J[J.ManyToMany=3]="ManyToMany"})(d0||={});var o1;((F)=>{F[F.STRING=0]="STRING";F[F.TEXT=1]="TEXT";F[F.INTEGER=2]="INTEGER";F[F.BIGINT=3]="BIGINT";F[F.FLOAT=4]="FLOAT";F[F.DOUBLE=5]="DOUBLE";F[F.DECIMAL=6]="DECIMAL";F[F.BOOLEAN=7]="BOOLEAN";F[F.DATE=8]="DATE";F[F.DATETIME=9]="DATETIME";F[F.JSON=10]="JSON";F[F.UUID=11]="UUID";F[F.BLOB=12]="BLOB"})(o1||={});class O extends Error{code;originalError;constructor(S,w,$){super(S);this.code=w;this.originalError=$;this.name="StabilizeError"}}function AZ(S){return{sql:S}}class F4{listeners=new Map;on(S,w){if(!this.listeners.has(S))this.listeners.set(S,[]);this.listeners.get(S).push(w)}off(S,w){let $=this.listeners.get(S);if($){let Z=$.indexOf(w);if(Z!==-1)$.splice(Z,1)}}emit(S,...w){let $=this.listeners.get(S);if($)for(let Z of $)try{Z(...w)}catch{}}}function KZ(){return crypto.randomUUID()}import*as g from"fs/promises";class M1{level;filePath;maxFileSize;maxFiles;constructor(S={}){this.level=S.level??1,this.filePath=S.filePath||null,this.maxFileSize=S.maxFileSize||1048576,this.maxFiles=S.maxFiles||3}shouldLog(S){return S<=this.level}async rotateLogFile(){if(!this.filePath)return;try{let S=await g.stat(this.filePath).catch(()=>null);if(!S||S.size<this.maxFileSize)return;let w=`${this.filePath}.${this.maxFiles}`;await g.unlink(w).catch(()=>{});for(let $=this.maxFiles-1;$>=1;$--){let Z=`${this.filePath}.${$}`,J=`${this.filePath}.${$+1}`;if(await g.stat(Z).catch(()=>null))await g.rename(Z,J)}await g.rename(this.filePath,`${this.filePath}.1`)}catch(S){let w=new O("Log rotation failed","LOG_ROTATION_ERROR",S);console.error(`[LOGGER_ERROR] ${w.message}
|
|
161
|
+
${w.stack}`)}}async log(S,w){if(!this.shouldLog(S))return;let Z=`[${l1[S].toUpperCase()}] ${new Date().toISOString()} - ${w}`;switch(S){case 3:console.error(Z);break;case 2:console.warn(Z);break;default:console.log(Z);break}if(this.filePath)try{await this.rotateLogFile(),await g.appendFile(this.filePath,Z+`
|
|
162
|
+
`)}catch(J){let Y=new O("Failed to write to log file","LOG_WRITE_ERROR",J);console.error(`[LOGGER_ERROR] ${Y.message}
|
|
163
|
+
${Y.stack}`)}}logQuery(S,w,$){let Z=$?`${$.toFixed(2)}ms`:"N/A";this.log(0,`Query: ${S} | Params: ${JSON.stringify(w)} | Time: ${Z}`)}logError(S){let w=`${S.message}${S.stack?`
|
|
164
|
+
${S.stack}`:""}`;this.log(3,w)}logMetrics(S){let w=`Pool Metrics: Active=${S.activeConnections}, Idle=${S.idleConnections}, Total=${S.totalConnections}`;this.log(1,w)}logInfo(S){this.log(1,S)}logWarn(S){this.log(2,S)}logDebug(S){this.log(0,S)}}var S4=V4(ew(),1);class h0{redis=null;logger;hits=0;misses=0;config;constructor(S,w=new M1){if(this.config={...S,cachePrefix:S.cachePrefix||""},this.logger=w,this.config.enabled&&this.config.redisUrl)this.redis=new S4.default(this.config.redisUrl,{lazyConnect:!0}),this.redis.on("error",($)=>this.logger.logError($))}getStrategy(){return this.config.strategy||"cache-aside"}async get(S){if(!this.redis)return null;try{let w=await this.redis.get(this.config.cachePrefix+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,$){if(!this.redis)return;try{let Z=$??this.config.ttl;await this.redis.set(this.config.cachePrefix+S,JSON.stringify(w),"EX",Z),this.logger.logDebug(`Cache set for key: ${S}`)}catch(Z){this.logger.logError(Z)}}async invalidate(S){if(!this.redis)return;try{let w=this.redis.pipeline();for(let $ of S)w.del(this.config.cachePrefix+$),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.config.cachePrefix+S);if(w.length>0){let $=this.redis.pipeline();for(let Z of w)$.del(Z);await $.exec(),this.logger.logDebug(`Cache invalidated for pattern: ${S} (${w.length} keys)`)}}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.config.cachePrefix+"*");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")}}class R{static models=new Map;static setModelMetadata(S,w){this.models.set(S,w)}static getModelMetadata(S){return this.models.get(S)}static getTableName(S){return this.getModelMetadata(S)?.tableName||""}static getColumns(S){return this.getModelMetadata(S)?.columns||{}}static getValidators(S){let w=this.getModelMetadata(S)?.columns||{},$={};for(let[Z,J]of Object.entries(w)){let Y=[];if(J.required)Y.push("required");if(J.unique)Y.push("unique");$[Z]=Y}return $}static getRelations(S){let w=this.getModelMetadata(S)?.relations||[],$={};for(let Z of w)$[Z.property]=Z;return $}static getSoftDeleteField(S){let w=this.getModelMetadata(S)?.columns||{};for(let[$,Z]of Object.entries(w))if(Z.softDelete)return $;return null}static isVersioned(S){return!!this.getModelMetadata(S)?.versioned}static getScopes(S){return this.getModelMetadata(S)?.scopes||{}}static getModelByTableName(S){for(let[w,$]of this.models)if($.tableName===S)return w;return}static getTimestamps(S){return this.getModelMetadata(S)?.timestamps||{}}}function g8(S){class w{constructor($){Object.assign(this,$)}}return R.setModelMetadata(w,{tableName:S.tableName,versioned:S.versioned||!1,softDelete:S.softDelete||!1,columns:S.columns,relations:S.relations||[],scopes:S.scopes||{},timestamps:S.timestamps||{}}),w}class f{table;tableAlias=null;selectFields=["*"];isDistinct=!1;joins=[];whereConditions=[];whereParams=[];orderByClauses=[];limitValue=null;offsetValue=null;groupByClauses=[];havingConditions=[];havingParams=[];lockMode=null;eagerRelations=[];unions=[];ctas=[];constructor(S){this.table=S}select(...S){return this.selectFields=S.length>0?S:["*"],this}selectRaw(S,...w){return this.selectFields.push(S),this.whereParams.push(...w),this}distinct(){return this.isDistinct=!0,this}as(S){return this.tableAlias=S,this}count(S="*",w="count"){return this.selectFields=[`COUNT(${S}) AS ${w}`],this}sum(S,w="sum"){return this.selectFields=[`SUM(${S}) AS ${w}`],this}avg(S,w="avg"){return this.selectFields=[`AVG(${S}) AS ${w}`],this}min(S,w="min"){return this.selectFields=[`MIN(${S}) AS ${w}`],this}max(S,w="max"){return this.selectFields=[`MAX(${S}) AS ${w}`],this}where(S,...w){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S}`);else this.whereConditions.push(S);return this.whereParams.push(...w),this}orWhere(S,...w){if(this.whereConditions.length===0)this.whereConditions.push(S);else this.whereConditions.push(`OR (${S})`);return this.whereParams.push(...w),this}whereNot(S,...w){if(this.whereConditions.length>0)this.whereConditions.push(`AND NOT (${S})`);else this.whereConditions.push(`NOT (${S})`);return this.whereParams.push(...w),this}whereIn(S,w){if(w.length===0){if(this.whereConditions.length>0)this.whereConditions.push("AND 1 = 0");else this.whereConditions.push("1 = 0");return this}let $=w.map(()=>"?").join(", ");if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} IN (${$})`);else this.whereConditions.push(`${S} IN (${$})`);return this.whereParams.push(...w),this}whereNotIn(S,w){if(w.length===0)return this;let $=w.map(()=>"?").join(", ");if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} NOT IN (${$})`);else this.whereConditions.push(`${S} NOT IN (${$})`);return this.whereParams.push(...w),this}whereNull(S){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} IS NULL`);else this.whereConditions.push(`${S} IS NULL`);return this}whereNotNull(S){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} IS NOT NULL`);else this.whereConditions.push(`${S} IS NOT NULL`);return this}whereBetween(S,w,$){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} BETWEEN ? AND ?`);else this.whereConditions.push(`${S} BETWEEN ? AND ?`);return this.whereParams.push(w,$),this}whereNotBetween(S,w,$){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} NOT BETWEEN ? AND ?`);else this.whereConditions.push(`${S} NOT BETWEEN ? AND ?`);return this.whereParams.push(w,$),this}whereLike(S,w){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} LIKE ?`);else this.whereConditions.push(`${S} LIKE ?`);return this.whereParams.push(w),this}whereILike(S,w){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S} ILIKE ?`);else this.whereConditions.push(`${S} ILIKE ?`);return this.whereParams.push(w),this}whereExists(S){let w=typeof S==="string"?S:S.build().query;if(this.whereConditions.length>0)this.whereConditions.push(`AND EXISTS (${w})`);else this.whereConditions.push(`EXISTS (${w})`);if(typeof S!=="string")this.whereParams.push(...S.build().params);return this}whereNotExists(S){let w=typeof S==="string"?S:S.build().query;if(this.whereConditions.length>0)this.whereConditions.push(`AND NOT EXISTS (${w})`);else this.whereConditions.push(`NOT EXISTS (${w})`);if(typeof S!=="string")this.whereParams.push(...S.build().params);return this}whereRaw(S,...w){if(this.whereConditions.length>0)this.whereConditions.push(`AND ${S}`);else this.whereConditions.push(S);return this.whereParams.push(...w),this}whereRef(S,w,$){return this.whereConditions.push(`${S} ${w} ${$}`),this}addJoin(S,w,$){return this.joins.push(`${S} JOIN ${w} ON ${$}`),this}join(S,w){return this.addJoin("LEFT",S,w)}innerJoin(S,w){return this.addJoin("INNER",S,w)}leftJoin(S,w){return this.addJoin("LEFT",S,w)}rightJoin(S,w){return this.addJoin("RIGHT",S,w)}fullJoin(S,w){return this.addJoin("FULL",S,w)}crossJoin(S){return this.joins.push(`CROSS JOIN ${S}`),this}orderBy(S,w="ASC"){return this.orderByClauses.push(`${S} ${w}`),this}groupBy(...S){return this.groupByClauses.push(...S),this}having(S,...w){return this.havingConditions.push(S),this.havingParams.push(...w),this}limit(S){return this.limitValue=S,this}offset(S){return this.offsetValue=S,this}take(S){return this.limit(S)}skip(S){return this.offset(S)}first(){return this.limitValue=1,this}paginate(S,w){return this.limitValue=w,this.offsetValue=(S-1)*w,this}lock(S="FOR UPDATE"){return this.lockMode=S,this}forUpdate(){return this.lockMode="FOR UPDATE",this}forShare(){return this.lockMode="FOR SHARE",this}union(S){return this.unions.push({query:S.build().query,params:S.build().params,all:!1}),this}unionAll(S){return this.unions.push({query:S.build().query,params:S.build().params,all:!0}),this}with(S,w){return this.ctas.push({name:S,query:w.build().query,params:w.build().params,recursive:!1}),this}withRecursive(S,w){return this.ctas.push({name:S,query:w.build().query,params:w.build().params,recursive:!0}),this}scope(S,...w){let $=R.getModelByTableName(this.table);if(!$)throw new O(`Model for table ${this.table} not found`,"SCOPE_ERROR");let J=R.getScopes($)[S];if(!J)throw new O(`Scope ${S} not found`,"SCOPE_ERROR");return J(this,...w)}clone(){let S=new f(this.table);return S.tableAlias=this.tableAlias,S.selectFields=[...this.selectFields],S.isDistinct=this.isDistinct,S.joins=[...this.joins],S.whereConditions=[...this.whereConditions],S.whereParams=[...this.whereParams],S.orderByClauses=[...this.orderByClauses],S.limitValue=this.limitValue,S.offsetValue=this.offsetValue,S.groupByClauses=[...this.groupByClauses],S.havingConditions=[...this.havingConditions],S.havingParams=[...this.havingParams],S.lockMode=this.lockMode,S.eagerRelations=[...this.eagerRelations],S.unions=[...this.unions],S.ctas=[...this.ctas],S}build(){let S=[],w="";if(this.ctas.length>0){let Y=this.ctas.some((U)=>U.recursive)?"RECURSIVE ":"",X=this.ctas.map((U)=>{return S.push(...U.params),`${U.name} AS (${U.query})`}).join(", ");w=`WITH ${Y}${X}
|
|
165
|
+
`}let $=this.tableAlias?`${this.table} AS ${this.tableAlias}`:this.table,Z=this.isDistinct?" DISTINCT":"",J=`${w}SELECT${Z} ${this.selectFields.join(", ")} FROM ${$}`;if(this.joins.length>0)J+=`
|
|
166
|
+
`+this.joins.join(`
|
|
167
|
+
`);if(S.push(...this.whereParams),this.whereConditions.length>0)J+=`
|
|
168
|
+
WHERE `+this.whereConditions.join(" ");if(this.groupByClauses.length>0)J+=`
|
|
169
|
+
GROUP BY `+this.groupByClauses.join(", ");if(S.push(...this.havingParams),this.havingConditions.length>0)J+=`
|
|
170
|
+
HAVING `+this.havingConditions.join(" ");if(this.orderByClauses.length>0)J+=`
|
|
171
|
+
ORDER BY `+this.orderByClauses.join(", ");if(this.limitValue!==null)J+=`
|
|
172
|
+
LIMIT ${this.limitValue}`;if(this.offsetValue!==null)J+=` OFFSET ${this.offsetValue}`;if(this.lockMode)J+=` ${this.lockMode}`;for(let Y of this.unions)J+=Y.all?`
|
|
173
|
+
UNION ALL (${Y.query})`:`
|
|
174
|
+
UNION (${Y.query})`,S.push(...Y.params);return{query:J,params:S}}toSQL(){return this.build()}async execute(S,w,$){let{query:Z,params:J}=this.build();if(w&&$){let X=await w.get($);if(X)return X}let Y=await S.query(Z,J);if(w&&$&&Y.length>0)await w.set($,Y,60);return Y}async countExec(S){let w=this.clone();w.selectFields=["COUNT(*) AS __cnt"],w.orderByClauses=[],w.limitValue=null,w.offsetValue=null;let $=await S.query(w.build().query,w.build().params);return Number($[0]?.__cnt??0)}async existsExec(S){let w=this.clone();return w.selectFields=["1"],w.orderByClauses=[],w.limitValue=1,w.offsetValue=null,(await S.query(w.build().query,w.build().params)).length>0}}function c8(S,w){let $=R.getModelMetadata(S)||{tableName:"",columns:{}};$.hooks={...$.hooks,...w},R.setModelMetadata(S,$)}function w4(S,w){let $=[];if(!S)return $;let Z=Object.getPrototypeOf(S);if(!Z)return $;let J=Z.constructor,Y=R.getModelMetadata(J);if(Y?.hooks?.[w]){let X=Array.isArray(Y.hooks[w])?Y.hooks[w]:[Y.hooks[w]];$.push(...X.map((U)=>({type:w,callback:()=>U(S)})))}if(typeof S[w]==="function")$.push({type:w,callback:()=>S[w]()});return $}import g0 from"crypto";var $4=process.env.ORM_ENCRYPTION_KEY||"f71a3c8e9b12d5a49c0a3f98b1f2e46d",LZ=16;function Z4(S){let w=Buffer.from($4,"utf8");if(w.length!==32)throw Error("ENCRYPTION_KEY must be 32 bytes (256 bits) long for AES-256");let $=g0.randomBytes(LZ),Z=g0.createCipheriv("aes-256-cbc",w,$),J=Buffer.concat([Z.update(S,"utf8"),Z.final()]);return`${$.toString("base64")}:${J.toString("base64")}`}function J4(S){let[w,$]=S.split(":");if(!w||!$)throw Error("Invalid encrypted text format. Expected 'iv:encrypted'.");let Z=Buffer.from(w,"base64"),J=Buffer.from($,"base64"),Y=Buffer.from($4,"utf8");if(Y.length!==32)throw Error("ENCRYPTION_KEY must be 32 bytes (256 bits) long for AES-256");let X=g0.createDecipheriv("aes-256-cbc",Y,Z);return Buffer.concat([X.update(J),X.final()]).toString("utf8")}class BZ{client;cache;table;columns;validators;relations;softDeleteField;logger;versioned;historyTable;model;optimisticLockField;timestampsConfig;constructor(S,w,$={enabled:!1,ttl:60},Z=new M1){this.client=S,this.cache=$.enabled?new h0($,Z):null,this.table=R.getTableName(w),this.columns=Object.fromEntries(Object.entries(R.getColumns(w)).map(([J,Y])=>[J,{name:Y.name??J,type:typeof Y.type==="string"?Y.type:o1[Y.type]}])),this.relations=Object.fromEntries(Object.entries(R.getRelations(w)).map(([J,Y])=>[J,{type:Y.type,targetModel:Y.target,foreignKey:Y.foreignKey,inverseKey:Y.inverseKey,joinTable:Y.joinTable}])),this.validators=R.getValidators(w),this.softDeleteField=R.getSoftDeleteField(w),this.optimisticLockField=this.getOptimisticLockField(w),this.timestampsConfig=R.getTimestamps(w),this.logger=Z,this.versioned=R.isVersioned(w),this.historyTable=`${this.table}_history`,this.model=w}getOptimisticLockField(S){let w=R.getColumns(S);for(let[$,Z]of Object.entries(w))if(Z.optimisticLock)return $;return null}getDBType(S){return(S||this.client).config.type}validate(S,w=!1){for(let[$,Z]of Object.entries(this.validators)){let J=S[$];if(!w&&Z.includes("required")&&(J===void 0||J===null))throw new O(`Field ${$} is required`,"VALIDATION_ERROR");if(J===void 0||J===null)continue;let Y=this.columns?.[$];if(!Y)continue;if(Y.minLength&&typeof J==="string"&&J.length<Y.minLength)throw new O(`Field ${$} too short`,"VALIDATION_ERROR");if(Y.maxLength&&typeof J==="string"&&J.length>Y.maxLength)throw new O(`Field ${$} too long`,"VALIDATION_ERROR");if(Y.pattern&&typeof J==="string"&&!Y.pattern.test(J))throw new O(`Field ${$} does not match pattern`,"VALIDATION_ERROR");if(typeof Y.customValidator==="function"){let X=Y.customValidator(J);if(X!==!0)throw new O(X,"VALIDATION_ERROR")}}}async runHooks(S,w){for(let $ of w4(S,w))await $.callback(S)}find(){let S=new f(this.table);if(this.softDeleteField)S.where(`${this.table}.${this.softDeleteField} IS NULL`);return S}scope(S,...w){return this.logger.logDebug(`Applying scope ${S} to ${this.table}`),this.find().scope(S,...w)}async findOne(S,w={},$){let Z=$||this.client,J=performance.now();this.logger.logDebug(`Finding one ${this.table} with ID ${S}`);let Y=this.find().where(`${this.table}.id = ?`,S).limit(1);if(w.relations){for(let H of w.relations)if(H.includes("."))await this.loadNestedRelations(Y,H);else await this.loadRelation(Y,H);Y.select(`${this.table}.*`)}let X=`findOne:${this.table}:${S}:${w.relations?.join(",")}`,U=await Y.execute(Z,this.cache,X),W=this.processForLoad(U);return this.logger.logDebug(`Found ${this.table} with ID ${S} in ${(performance.now()-J).toFixed(2)}ms`),W[0]||null}async asOf(S,w,$){if(!this.versioned)throw new O("Model is not versioned","VERSIONING_ERROR");return(await($||this.client).query(`SELECT * FROM ${this.historyTable} WHERE id = ? AND valid_from <= ? AND (valid_to IS NULL OR valid_to > ?) ORDER BY version DESC LIMIT 1`,[S,w,w]))[0]||null}async history(S,w){if(!this.versioned)throw new O("Model is not versioned","VERSIONING_ERROR");return(w||this.client).query(`SELECT * FROM ${this.historyTable} WHERE id = ? ORDER BY version ASC`,[S])}async rollback(S,w,$){if(!this.versioned)throw new O("Model is not versioned","VERSIONING_ERROR");return($||this.client).transaction(async(J)=>{let Y=await J.query(`SELECT * FROM ${this.historyTable} WHERE id = ? AND version = ? LIMIT 1`,[S,w]);if(!Y.length)throw new O("Version not found","ROLLBACK_ERROR");let X=Y[0],U=Object.keys(this.columns).filter((G)=>G!=="id"),W=U.map((G)=>`${this.columns[G].name} = ?`).join(", "),H=U.map((G)=>X[G]);return await J.query(`UPDATE ${this.table} SET ${W} WHERE id = ?`,[...H,S]),await this.writeHistory({...X,version:w+1},"update",J),this.findOne(S,{},J)})}async writeHistory(S,w,$,Z){if(!this.versioned)return;let J=Object.keys(this.columns),X=[...J.map((V)=>this.columns[V].name),"operation","version","valid_from","valid_to","modified_by","modified_at"];function U(V,F){if(V===void 0)return null;if(V instanceof Date){if(F==="mysql")return V.toISOString().slice(0,19).replace("T"," ");return V.toISOString()}if(typeof V==="boolean")return V?1:0;if(typeof V==="string"||typeof V==="number"||typeof V==="bigint")return V;return null}let W=$.config.type,G=[...J.map((V)=>U(S?.[V],W)),U(w,W),U(S.version||1,W),U(new Date,W),U(null,W),U(Z||"system",W),U(new Date,W)],Q;if($.config.type==="postgres")Q=G.map((V,F)=>`$${F+1}`).join(", ");else Q=G.map(()=>"?").join(", ");await $.query(`INSERT INTO ${this.historyTable} (${X.join(", ")}) VALUES (${Q})`,G)}async create(S,w={}){return this.client.transaction(async($)=>{let Z=new this.model;Object.assign(Z,S),await this.runHooks(Z,"beforeCreate"),await this.runHooks(Z,"beforeSave");let J=await this._create(S,w,$);return await this.runHooks(J,"afterCreate"),await this.runHooks(J,"afterSave"),await this.writeHistory(J,"insert",$),J})}async _create(S,w,$){let Z=performance.now();this.logger.logDebug(`Creating ${this.table} with data: ${JSON.stringify(S)}`),this.validate(S);let J=this.processForSave(S),Y=this.timestampsConfig,X={...J};if(Y?.createdAt&&!X[Y.createdAt])X[Y.createdAt]=new Date;if(Y?.updatedAt&&!X[Y.updatedAt])X[Y.updatedAt]=new Date;let U=Object.keys(X).filter((y)=>this.columns[y]),W=U.map((y)=>this.columns[y]?.name).join(", "),H=U.map(()=>"?").join(", "),G=U.map((y)=>X[y]),Q=`INSERT INTO ${this.table} (${W}) VALUES (${H})`,V,F,I=this.getDBType($);if(I==="postgres")Q+=" RETURNING *",V=await $.query(Q,G),F=V?.[0]?.id;else{await $.query(Q,G);let y=X.id;if(y!==void 0&&y!==null)F=y;else if(I==="sqlite")F=(await $.query("SELECT last_insert_rowid() as id"))[0]?.id;else if(I==="mysql")F=(await $.query("SELECT LAST_INSERT_ID()"))[0]?.["LAST_INSERT_ID()"]}if(!F)throw new O("Failed to retrieve inserted ID","INSERT_ERROR");let z=V?.[0]??await this.findOne(F,w,$);if(this.cache){let y=[`find:${this.table}`,`findOne:${this.table}:${F}`];if(await this.cache.invalidate(y),this.cache.getStrategy()==="write-through")await this.cache.set(`findOne:${this.table}:${F}`,[z],60)}return this.logger.logDebug(`Created ${this.table} with ID ${F} in ${(performance.now()-Z).toFixed(2)}ms`),z}async bulkCreate(S,w={}){return this.client.transaction(async($)=>{let Z=S.map((Y)=>{let X=new this.model;return Object.assign(X,Y),X});for(let Y of Z)await this.runHooks(Y,"beforeCreate"),await this.runHooks(Y,"beforeSave");let J=await this._bulkCreate(S,w,$);for(let Y of J)if(await this.runHooks(Y,"afterCreate"),await this.runHooks(Y,"afterSave"),this.versioned)await this.writeHistory(Y,"insert",$);return J})}async _bulkCreate(S,w,$){let Z=performance.now();if(this.logger.logDebug(`Bulk creating ${S.length} ${this.table} entities`),!S.length)return[];let J=w.batchSize||1000;S.forEach((H)=>this.validate(H));let Y=this.timestampsConfig,X=S.map((H)=>({...H,...Y?.createdAt&&!H[Y.createdAt]?{[Y.createdAt]:new Date}:{},...Y?.updatedAt&&!H[Y.updatedAt]?{[Y.updatedAt]:new Date}:{}})),U=this.getDBType($),W=[];for(let H=0;H<X.length;H+=J){let G=X.slice(H,H+J),Q=Object.keys(G[0]).filter((z)=>this.columns[z]),V=Q.map((z)=>this.columns[z]?.name).join(", "),F,I=G.flatMap((z)=>Q.map((y)=>z[y]));if(U==="postgres"){let z=1,y=G.map(()=>`(${Q.map(()=>`$${z++}`).join(", ")})`).join(", ");F=`INSERT INTO ${this.table} (${V}) VALUES ${y} RETURNING *`;let L=await $.query(F,I);W.push(...L)}else{let z=`(${Q.map(()=>"?").join(", ")})`;F=`INSERT INTO ${this.table} (${V}) VALUES ${G.map(()=>z).join(", ")}`,await $.query(F,I);let y=(await $.query(`SELECT id FROM ${this.table} ORDER BY id DESC LIMIT ?`,[G.length])).map((A)=>A.id),L=[];if(y.length>0){let A=this.find().where(`id IN (${y.map(()=>"?").join(", ")})`,...y);if(w.relations)for(let B of w.relations)await this.loadRelation(A,B);L=await A.execute($)}W.push(...L)}}if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);return this.logger.logDebug(`Bulk created ${W.length} ${this.table} entities in ${(performance.now()-Z).toFixed(2)}ms`),W}async update(S,w){return this.client.transaction(async($)=>{let Z=await this.findOne(S,{},$);if(!Z)throw new O("Not found","UPDATE_ERROR");let J=new this.model;Object.assign(J,Z,w),await this.runHooks(J,"beforeUpdate"),await this.runHooks(J,"beforeSave");let Y=await this._update(S,w,Z,$);return await this.runHooks(Y,"afterUpdate"),await this.runHooks(Y,"afterSave"),await this.writeHistory({...Z,...w,version:Z.version?Z.version+1:1},"update",$),Y})}async _update(S,w,$,Z){let J=performance.now();this.logger.logDebug(`Updating ${this.table} with ID ${S}`),this.validate(w,!0);let Y=this.timestampsConfig,X={...w};if(Y?.updatedAt&&!X[Y.updatedAt])X[Y.updatedAt]=new Date;let U=Object.keys(X).filter((I)=>this.columns[I]),W=U.map((I)=>`${this.columns[I]?.name} = ?`).join(", "),H=["id = ?"],G=[...U.map((I)=>w[I]),S];if(this.optimisticLockField){let I=$[this.optimisticLockField];if(I!==void 0){H.push(`${this.optimisticLockField} = ?`),G.push(I);let z=typeof I==="number"?I+1:I;X[this.optimisticLockField]=z;let y=U.findIndex((L)=>L===this.optimisticLockField);if(y!==-1)G[y]=z}}if(this.softDeleteField)H.push(`${this.softDeleteField} IS NULL`);let Q=`UPDATE ${this.table} SET ${W} WHERE ${H.join(" AND ")}`,{affectedRows:V}=await Z.queryExec(Q,G);if(this.optimisticLockField&&$[this.optimisticLockField]!==void 0){if(V===0)throw new O(`Record was modified by another transaction (optimistic lock conflict on ${this.optimisticLockField})`,"CONCURRENT_MODIFICATION")}let F=await this.findOne(S,{},Z);if(this.cache){let I=[`find:${this.table}`,`findOne:${this.table}:${S}`];if(await this.cache.invalidate(I),this.cache.getStrategy()==="write-through")await this.cache.set(`findOne:${this.table}:${S}`,[F],60)}return this.logger.logDebug(`Updated ${this.table} with ID ${S} in ${(performance.now()-J).toFixed(2)}ms`),F}async bulkUpdate(S,w={}){return this.client.transaction(($)=>this._bulkUpdate(S,w,$))}async _bulkUpdate(S,w,$){let Z=performance.now();if(this.logger.logDebug(`Bulk updating ${S.length} ${this.table} entities`),!S.length)return;let J=w.batchSize||1000;S.forEach((X)=>this.validate(X.set));let Y=this.timestampsConfig;for(let X=0;X<S.length;X+=J){let U=S.slice(X,X+J);for(let W of U){let H=await $.query(`SELECT id FROM ${this.table} WHERE ${W.where.condition}${this.softDeleteField?` AND ${this.softDeleteField} IS NULL`:""}`,W.where.params);for(let{id:G}of H){let Q=await this.findOne(G,{},$);if(!Q)continue;let V={...W.set,...Y?.updatedAt&&!W.set[Y.updatedAt]?{[Y.updatedAt]:new Date}:{}},F=Object.keys(V).filter((A)=>this.columns[A]),I=F.map((A)=>`${this.columns[A]?.name} = ?`).join(", "),z=`UPDATE ${this.table} SET ${I} WHERE id = ?${this.softDeleteField?` AND ${this.softDeleteField} IS NULL`:""}`,y=[...F.map((A)=>V[A]),G];await $.query(z,y);let L=await this.findOne(G,{},$);if(L){if(await this.runHooks(L,"afterUpdate"),await this.runHooks(L,"afterSave"),this.versioned)await this.writeHistory({...L,version:Q.version?Q.version+1:1},"update",$)}}}}if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);this.logger.logDebug(`Bulk updated ${S.length} ${this.table} entities in ${(performance.now()-Z).toFixed(2)}ms`)}async upsert(S,w){return this.client.transaction(($)=>this._upsert(S,w,$))}async _upsert(S,w,$){let Z=performance.now();this.logger.logDebug(`Upserting ${this.table} with keys: ${w.join(", ")}`),this.validate(S);let J=this.getDBType($),Y=Object.keys(S).filter((B)=>this.columns[B]),X=Y.map((B)=>this.columns[B]?.name).join(", "),U=Y.map(()=>"?").join(", "),W=Y.filter((B)=>!w.includes(B)).map((B)=>`${this.columns[B]?.name} = ?`).join(", "),H,G=Y.filter((B)=>!w.includes(B)).map((B)=>S[B]),Q=Y.map((B)=>S[B]),V=[...Q,...G],F=null,I=!1;if(this.versioned&&w.length>0){let B=w.map((r)=>`${this.columns[r]?.name} = ?`).join(" AND "),T=w.map((r)=>S[r]);F=(await $.query(`SELECT * FROM ${this.table} WHERE ${B} LIMIT 1`,T))[0]||null,I=!!F}let z=new this.model;if(Object.assign(z,F||{},S),I)await this.runHooks(z,"beforeUpdate"),await this.runHooks(z,"beforeSave");else await this.runHooks(z,"beforeCreate"),await this.runHooks(z,"beforeSave");if(J==="sqlite")H=`INSERT INTO ${this.table} (${X}) VALUES (${U}) ON CONFLICT(${w.map((B)=>this.columns[B].name).join(", ")}) DO UPDATE SET ${W}`;else if(J==="mysql")H=`INSERT INTO ${this.table} (${X}) VALUES (${U}) ON DUPLICATE KEY UPDATE ${W}`;else{let B=Y.filter((T)=>!w.includes(T)).map((T)=>`${this.columns[T]?.name} = EXCLUDED.${this.columns[T]?.name}`).join(", ");H=`INSERT INTO ${this.table} (${X}) VALUES (${U}) ON CONFLICT (${w.map((T)=>this.columns[T].name).join(", ")}) DO UPDATE SET ${B} RETURNING *`,V=Q}let y=await $.query(H,V),L=y[0]?.id||S.id;if(!L&&J!=="postgres"){if(J==="sqlite")L=(await $.query("SELECT last_insert_rowid() as id"))[0]?.id;else if(J==="mysql")L=(await $.query("SELECT LAST_INSERT_ID()"))[0]?.["LAST_INSERT_ID()"]}if(!L)throw new O("Failed to retrieve upserted ID","UPSERT_ERROR");let A=y[0]??await this.findOne(L,{},$);if(I)await this.runHooks(A,"afterUpdate"),await this.runHooks(A,"afterSave");else await this.runHooks(A,"afterCreate"),await this.runHooks(A,"afterSave");if(this.versioned)await this.writeHistory({...A,version:F?F.version?F.version+1:1:1},F?"update":"insert",$);if(this.cache){if(await this.cache.invalidatePattern(`find:${this.table}:*`),this.cache.getStrategy()==="write-through")await this.cache.set(`findOne:${this.table}:${L}`,[A],60)}return this.logger.logDebug(`Upserted ${this.table} with ID ${L} in ${(performance.now()-Z).toFixed(2)}ms`),A}async delete(S){return this.client.transaction(async(w)=>{let $=await this.findOne(S,{},w);if(!$)throw new O("Not found","DELETE_ERROR");await this.runHooks($,"beforeDelete"),await this._delete(S,w),await this.runHooks($,"afterDelete"),await this.writeHistory($,"delete",w)})}async _delete(S,w){let $=performance.now();this.logger.logDebug(`Deleting ${this.table} with ID ${S}`);let Z=this.softDeleteField?`UPDATE ${this.table} SET ${this.softDeleteField} = ? WHERE id = ?`:`DELETE FROM ${this.table} WHERE id = ?`,J=this.softDeleteField?[new Date().toISOString(),S]:[S];if(await w.query(Z,J),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()-$).toFixed(2)}ms`)}async bulkDelete(S,w={}){return this.client.transaction(($)=>this._bulkDelete(S,w,$))}async _bulkDelete(S,w,$){let Z=performance.now();if(this.logger.logDebug(`Bulk deleting ${S.length} ${this.table} entities`),!S.length)return;let J=w.batchSize||1000;for(let Y=0;Y<S.length;Y+=J){let X=S.slice(Y,Y+J);for(let U of X){let W=await this.findOne(U,{},$);if(!W)continue;await this.runHooks(W,"beforeDelete");let H=this.softDeleteField?`UPDATE ${this.table} SET ${this.softDeleteField} = ? WHERE id = ?`:`DELETE FROM ${this.table} WHERE id = ?`,G=this.softDeleteField?[new Date().toISOString(),U]:[U];if(await $.query(H,G),await this.runHooks(W,"afterDelete"),this.versioned)await this.writeHistory(W,"delete",$)}}if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);this.logger.logDebug(`Bulk deleted ${S.length} ${this.table} entities in ${(performance.now()-Z).toFixed(2)}ms`)}async recover(S){return this.client.transaction((w)=>this._recover(S,w))}async _recover(S,w){let $=performance.now();if(this.logger.logDebug(`Recovering ${this.table} with ID ${S}`),!this.softDeleteField)throw new O("Soft delete not enabled for this model","RECOVER_ERROR");await w.query(`UPDATE ${this.table} SET ${this.softDeleteField} = NULL WHERE id = ?`,[S]);let Z=await this.findOne(S,{},w);if(!Z)throw new O("Failed to find recovered record.","RECOVER_ERROR");if(this.cache)await this.cache.invalidate([`find:${this.table}`,`findOne:${this.table}:${S}`]);return this.logger.logDebug(`Recovered ${this.table} with ID ${S} in ${(performance.now()-$).toFixed(2)}ms`),Z}async rawQuery(S,w=[]){let $=performance.now();this.logger.logDebug(`Executing raw query: ${S}`);let Z=await this.client.query(S,w);return this.logger.logDebug(`Raw query completed in ${(performance.now()-$).toFixed(2)}ms`),Z}async loadRelation(S,w){this.logger.logDebug(`Loading relation ${w} for ${this.table}`);let $=this.relations[w];if(!$)throw new O(`Relation ${w} not found`,"RELATION_ERROR");let Z=R.getTableName($.targetModel());if($.type===0||$.type===2)S.join(Z,`${this.table}.${$.foreignKey} = ${Z}.id`);else if($.type===1)S.join(Z,`${Z}.${$.inverseKey} = ${this.table}.id`);else if($.type===3)S.join($.joinTable,`${$.joinTable}.${$.foreignKey} = ${this.table}.id`).join(Z,`${Z}.id = ${$.joinTable}.${$.inverseKey}`)}async loadNestedRelations(S,w){let $=w.split("."),Z=this.table,J=this.relations;for(let Y=0;Y<$.length;Y++){let X=$[Y],U=J[X];if(!U)throw new O(`Relation ${X} not found on ${Z}`,"RELATION_ERROR");let W=R.getTableName(U.targetModel());if(U.type===0||U.type===2)S.join(W,`${Z}.${U.foreignKey} = ${W}.id`);else if(U.type===1)S.join(W,`${W}.${U.inverseKey} = ${Z}.id`);else if(U.type===3)S.join(U.joinTable,`${U.joinTable}.${U.foreignKey} = ${Z}.id`).join(W,`${W}.id = ${U.joinTable}.${U.inverseKey}`);if(Y<$.length-1){let H=U.targetModel();J=R.getRelations(H),Z=W}}}async paginate(S,w,$={}){let J=await this.find().paginate(S,w).execute(this.client),Y=`SELECT COUNT(*) as count FROM ${this.table}`,X=[];if(this.softDeleteField)Y+=` WHERE ${this.table}.${this.softDeleteField} IS NULL`;let W=(await this.client.query(Y,X))?.[0]?.count??0;return{data:J,total:Number(W),page:S,pageSize:w}}processForSave(S){let w={...S};for(let[$,Z]of Object.entries(this.columns))if(Z.encrypted&&w[$])w[$]=Z4(w[$]);return w}processForLoad(S){let w={...S};for(let[$,Z]of Object.entries(this.columns))if(Z.encrypted&&w[$])try{w[$]=J4(w[$])}catch{w[$]=null}return w}async findAndCount(S={}){let w=this.find();if(S.relations)for(let J of S.relations)await this.loadRelation(w,J);let $=await w.execute(this.client),Z=await w.clone().countExec(this.client);return{data:$,total:Z}}async findOneBy(S,w={},$){let Z=$||this.client,J=this.find();for(let[X,U]of Object.entries(S))if(U===null)J.whereNull(X);else J.where(`${this.columns[X]?.name} = ?`,U);if(w.relations)for(let X of w.relations)await this.loadRelation(J,X);return(await J.limit(1).execute(Z))[0]??null}async findBy(S,w={}){let $=this.find();for(let[Z,J]of Object.entries(S))if(J===null)$.whereNull(Z);else $.where(`${this.columns[Z]?.name} = ?`,J);if(w.relations)for(let Z of w.relations)await this.loadRelation($,Z);if(w.limit)$.limit(w.limit);if(w.orderBy)$.orderBy(w.orderBy);return $.execute(this.client)}async count(S){let w=new f(this.table);if(this.softDeleteField)w.where(`${this.softDeleteField} IS NULL`);if(S){for(let[$,Z]of Object.entries(S))if(Z!==void 0&&Z!==null)w.where(`${this.columns[$]?.name} = ?`,Z)}return w.countExec(this.client)}async findAndCountAll(S){let w=S?.page||1,$=S?.pageSize||20,Z=S?.conditions,J=new f(this.table);if(this.softDeleteField)J.where(`${this.softDeleteField} IS NULL`);if(Z){for(let[U,W]of Object.entries(Z))if(W!==void 0&&W!==null)J.where(`${this.columns[U]?.name} = ?`,W)}let Y=await J.limit($).offset((w-1)*$).execute(this.client),X=await this.count(Z);return{data:Y,total:X}}toJSON(S){let w={};for(let $ of Object.keys(this.columns)){if(this.softDeleteField&&$===this.softDeleteField)continue;w[$]=S[$]}return w}async aggregate(S){let w=[];if(S.count){let J=Array.isArray(S.count)?S.count:[S.count];for(let Y of J){let X=Y==="*"?"count_all":`count_${Y}`;w.push(`COUNT(${Y==="*"?"*":this.columns[Y]?.name||Y}) AS ${X}`)}}if(S.sum)for(let J of S.sum)w.push(`SUM(${this.columns[J]?.name||J}) AS sum_${J}`);if(S.avg)for(let J of S.avg)w.push(`AVG(${this.columns[J]?.name||J}) AS avg_${J}`);if(S.min)for(let J of S.min)w.push(`MIN(${this.columns[J]?.name||J}) AS min_${J}`);if(S.max)for(let J of S.max)w.push(`MAX(${this.columns[J]?.name||J}) AS max_${J}`);if(w.length===0)return{};let $=new f(this.table);if(this.softDeleteField)$.where(`${this.softDeleteField} IS NULL`);return $.select(...w),(await $.execute(this.client))[0]??{}}async findMany(S={}){let w=this.find();if(S.where)for(let[$,Z]of Object.entries(S.where))if(Z===null)w.whereNull($);else w.where(`${this.columns[$]?.name} = ?`,Z);if(S.cursor){let{field:$,value:Z,direction:J="forward"}=S.cursor,Y=this.columns[$]?.name||$,X=S.orderBy?.direction||"ASC";if(J==="forward")w.where(`${Y} ${X==="ASC"?">":"<"} ?`,Z);else w.where(`${Y} ${X==="ASC"?"<":">"} ?`,Z);if(S.orderBy)w.orderBy(Y,S.orderBy.direction)}else if(S.orderBy)w.orderBy(this.columns[S.orderBy.field]?.name||S.orderBy.field,S.orderBy.direction);if(S.take)w.take(S.take);if(S.skip)w.skip(S.skip);if(S.relations)for(let $ of S.relations)await this.loadRelation(w,$);return w.execute(this.client)}async bulkUpsert(S,w){return this.client.transaction(async($)=>{let Z=[];for(let J of S)Z.push(await this._upsert(J,w,$));return Z})}async exists(S){let w=new f(this.table);if(this.softDeleteField)w.where(`${this.softDeleteField} IS NULL`);if(S){for(let[$,Z]of Object.entries(S))if(Z!==void 0&&Z!==null)w.where(`${this.columns[$]?.name} = ?`,Z)}return w.existsExec(this.client)}async recoverAll(){if(!this.softDeleteField)throw new O("Soft delete not enabled for this model","RECOVER_ERROR");return(await this.client.queryExec(`UPDATE ${this.table} SET ${this.softDeleteField} = NULL WHERE ${this.softDeleteField} IS NOT NULL`)).affectedRows}async truncate(){if(await this.client.queryExec(`DELETE FROM ${this.table}`),this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`)}async seed(S,w={}){if(S.length===0)return[];let $=await this.find().execute(this.client);if($.length>0&&w.ignoreDuplicates)return $;return this.bulkCreate(S)}async healthCheck(){let S=performance.now();try{let w=await this.count();return{status:"healthy",table:this.table,rows:w,latencyMs:Number((performance.now()-S).toFixed(2))}}catch(w){return{status:"unhealthy",table:this.table,rows:-1,latencyMs:Number((performance.now()-S).toFixed(2))}}}async countDistinct(S){let w=this.columns[S]?.name||S,$=new f(this.table);if(this.softDeleteField)$.where(`${this.softDeleteField} IS NULL`);$.select(`COUNT(DISTINCT ${w}) AS __cnt`);let Z=await $.execute(this.client);return Number(Z[0]?.__cnt??0)}async increment(S,w,$=1){let Z=this.columns[w]?.name||w,J=`UPDATE ${this.table} SET ${Z} = ${Z} + ? WHERE id = ?`;if(this.softDeleteField)J+=` AND ${this.softDeleteField} IS NULL`;return await this.client.queryExec(J,[$,S]),await this.findOne(S)}async decrement(S,w,$=1){let Z=this.columns[w]?.name||w,J=`UPDATE ${this.table} SET ${Z} = ${Z} - ? WHERE id = ?`;if(this.softDeleteField)J+=` AND ${this.softDeleteField} IS NULL`;return await this.client.queryExec(J,[$,S]),await this.findOne(S)}async pluck(S){let w=this.columns[S]?.name||S,$=new f(this.table);if($.select(w),this.softDeleteField)$.where(`${this.softDeleteField} IS NULL`);return(await $.execute(this.client)).map((J)=>J[w])}async selectColumns(...S){let w=S.map((J)=>this.columns[J]?.name||J),$=new f(this.table);if($.select(...w),this.softDeleteField)$.where(`${this.softDeleteField} IS NULL`);return await $.execute(this.client)}async toggle(S,w){let $=this.columns[w]?.name||w,Z=this.getDBType(),J=Z==="postgres"?`NOT ${$}`:Z==="mysql"?`NOT ${$}`:`CASE WHEN ${$} = 1 THEN 0 ELSE 1 END`,Y=`UPDATE ${this.table} SET ${$} = ${J} WHERE id = ?`;if(this.softDeleteField)Y+=` AND ${this.softDeleteField} IS NULL`;return await this.client.queryExec(Y,[S]),await this.findOne(S)}async updateBy(S,w){let $=Object.keys(w).filter((Q)=>this.columns[Q]);if($.length===0)return 0;let Z=this.timestampsConfig;if(Z?.updatedAt)w[Z.updatedAt]=new Date;let J=$.map((Q)=>`${this.columns[Q]?.name} = ?`).join(", "),Y=$.map((Q)=>w[Q]),X=[],U=[];for(let[Q,V]of Object.entries(S))if(V===null)X.push(`${this.columns[Q]?.name} IS NULL`);else X.push(`${this.columns[Q]?.name} = ?`),U.push(V);if(this.softDeleteField)X.push(`${this.softDeleteField} IS NULL`);let W=X.length>0?` WHERE ${X.join(" AND ")}`:"",H=`UPDATE ${this.table} SET ${J}${W}`,G=await this.client.queryExec(H,[...Y,...U]);if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);return G.affectedRows}async deleteBy(S){let w=[],$=[];for(let[Y,X]of Object.entries(S))if(X===null)w.push(`${this.columns[Y]?.name} IS NULL`);else w.push(`${this.columns[Y]?.name} = ?`),$.push(X);if(this.softDeleteField){w.push(`${this.softDeleteField} IS NULL`);let Y=w.length>0?` WHERE ${w.join(" AND ")}`:"",X=`UPDATE ${this.table} SET ${this.softDeleteField} = ?${Y}`,U=await this.client.queryExec(X,[new Date().toISOString(),...$]);if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);return U.affectedRows}let Z=w.length>0?` WHERE ${w.join(" AND ")}`:"",J=await this.client.queryExec(`DELETE FROM ${this.table}${Z}`,$);if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);return J.affectedRows}async restoreBy(S){if(!this.softDeleteField)throw new O("Soft delete not enabled","RECOVER_ERROR");let w=[`${this.softDeleteField} IS NOT NULL`],$=[];for(let[Y,X]of Object.entries(S))if(X!==void 0&&X!==null)w.push(`${this.columns[Y]?.name} = ?`),$.push(X);let Z=`UPDATE ${this.table} SET ${this.softDeleteField} = NULL WHERE ${w.join(" AND ")}`,J=await this.client.queryExec(Z,$);if(this.cache)await this.cache.invalidatePattern(`find:${this.table}:*`);return J.affectedRows}findDeleted(){if(!this.softDeleteField)throw new O("Soft delete not enabled","QUERY_ERROR");let S=new f(this.table);return S.whereNotNull(this.softDeleteField),S}withTrashed(){return new f(this.table)}async upsertMany(S,w,$=100){let Z=[];for(let J=0;J<S.length;J+=$){let Y=S.slice(J,J+$),X=await this.bulkUpsert(Y,w);Z.push(...X)}return Z}async map(S,w){return(await S.execute(this.client)).map(w)}async each(S,w,$=100){let Z=0,J=!0;while(J){let Y=await S.clone().offset(Z).limit($).execute(this.client);for(let X=0;X<Y.length;X++)await w(Y[X],Z+X);J=Y.length===$,Z+=$}}async eachBatch(S,w,$=100){let Z=0,J=!0;while(J){let Y=await S.clone().offset(Z).limit($).execute(this.client);await w(Y),J=Y.length===$,Z+=$}}async lockForUpdate(S,w){let $=w||this.client,Z=this.getDBType($),J=this.find().where("id = ?",S).limit(1);if(Z!=="sqlite")J.lock("FOR UPDATE");return(await J.execute($))[0]??null}async firstOrCreate(S,w={}){let $=await this.findOneBy(S);if($)return $;return this.create({...S,...w})}async updateOrCreate(S,w){let $=await this.findOneBy(S);if($)return this.update($.id,w);return this.create({...S,...w})}async first(S){let w=this.find();if(S)for(let[Z,J]of Object.entries(S))if(J===null)w.whereNull(Z);else w.where(`${this.columns[Z]?.name} = ?`,J);return w.limit(1),(await w.execute(this.client))[0]??null}async last(S="id"){let w=this.columns[S]?.name||S;return(await this.find().orderBy(`${w}`,"DESC").limit(1).execute(this.client))[0]??null}async random(){let S=this.getDBType(),w;if(S==="mysql")w="RAND()";else if(S==="sqlite")w="RANDOM()";else w="RANDOM()";return(await this.find().orderBy(w).limit(1).execute(this.client))[0]??null}hasColumn(S){return!!this.columns[S]}getTableName(){return this.table}getSoftDeleteField(){return this.softDeleteField}getIsVersioned(){return this.versioned}}export{BZ as Repository};
|
|
175
|
+
|
|
176
|
+
//# debugId=C318FD6C4360ED9564756E2164756E21
|