@upstash/redis 0.0.0-ci.ee21c87148cceb1a3548ec2eaef164f04178a10f → 0.0.0-ci.ef1ca9829e359ba31196db06ff1da80cd201974b-20241009150255

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/nodejs.js CHANGED
@@ -1 +1,3928 @@
1
- "use strict";var be=Object.create;var oe=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var ke=(s,n)=>{for(var t in n)oe(s,t,{get:n[t],enumerable:!0})},ue=(s,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let m of Te(n))!De.call(s,m)&&m!==t&&oe(s,m,{get:()=>n[m],enumerable:!(o=Oe(n,m))||o.enumerable});return s};var he=(s,n,t)=>(t=s!=null?be(we(s)):{},ue(n||!s||!s.__esModule?oe(t,"default",{value:s,enumerable:!0}):t,s)),Ae=s=>ue(oe({},"__esModule",{value:!0}),s);var Pe={};ke(Pe,{Redis:()=>de});module.exports=Ae(Pe);var c=class extends Error{constructor(n){super(n),this.name="UpstashError"}};var se=class{baseUrl;headers;options;retry;constructor(n){this.options={backend:n.options?.backend,agent:n.agent,responseEncoding:n.responseEncoding??"base64",cache:n.cache},this.baseUrl=n.baseUrl.replace(/\/$/,""),this.headers={"Content-Type":"application/json",...n.headers},this.options.responseEncoding==="base64"&&(this.headers["Upstash-Encoding"]="base64"),typeof n?.retry=="boolean"&&n?.retry===!1?this.retry={attempts:1,backoff:()=>0}:this.retry={attempts:n?.retry?.retries??5,backoff:n?.retry?.backoff??(t=>Math.exp(t)*50)}}mergeTelemetry(n){function t(o,m,r){return r&&(o[m]?o[m]=[o[m],r].join(","):o[m]=r),o}this.headers=t(this.headers,"Upstash-Telemetry-Runtime",n.runtime),this.headers=t(this.headers,"Upstash-Telemetry-Platform",n.platform),this.headers=t(this.headers,"Upstash-Telemetry-Sdk",n.sdk)}async request(n){let t={cache:this.options.cache,method:"POST",headers:this.headers,body:JSON.stringify(n.body),keepalive:!0,agent:this.options?.agent,backend:this.options?.backend},o=null,m=null;for(let a=0;a<=this.retry.attempts;a++)try{o=await fetch([this.baseUrl,...n.path??[]].join("/"),t);break}catch(i){m=i,await new Promise(p=>setTimeout(p,this.retry.backoff(a)))}if(!o)throw m??new Error("Exhausted all retries");let r=await o.json();if(!o.ok)throw new c(`${r.error}, command was: ${JSON.stringify(n.body)}`);return this.options?.responseEncoding==="base64"?Array.isArray(r)?r.map(({result:i,error:p})=>({result:pe(i),error:p})):{result:pe(r.result),error:r.error}:r}};function le(s){let n="";try{let t=atob(s),o=t.length,m=new Uint8Array(o);for(let r=0;r<o;r++)m[r]=t.charCodeAt(r);n=new TextDecoder().decode(m)}catch{n=s}return n}function pe(s){let n;switch(typeof s){case"undefined":return s;case"number":{n=s;break}case"object":{Array.isArray(s)?n=s.map(t=>typeof t=="string"?le(t):Array.isArray(t)?t.map(pe):t):n=null;break}case"string":{n=s==="OK"?"OK":le(s);break}default:break}return n}function Ce(s){let n=Array.isArray(s)?s.map(t=>{try{return Ce(t)}catch{return t}}):JSON.parse(s);return typeof n=="number"&&n.toString()!==s?s:n}function ge(s){try{return Ce(s)}catch{return s}}var Se=s=>{switch(typeof s){case"string":case"number":case"boolean":return s;default:return JSON.stringify(s)}},e=class{command;serialize;deserialize;constructor(n,t){this.serialize=Se,this.deserialize=typeof t?.automaticDeserialization>"u"||t.automaticDeserialization?t?.deserialize??ge:o=>o,this.command=n.map(o=>this.serialize(o))}async exec(n){let{result:t,error:o}=await n.request({body:this.command});if(o)throw new c(o);if(typeof t>"u")throw new Error("Request did not return a result");return this.deserialize(t)}};var l=class extends e{constructor(n,t){super(["append",...n],t)}};var C=class extends e{constructor([n,t,o],m){let r=["bitcount",n];typeof t=="number"&&r.push(t),typeof o=="number"&&r.push(o),super(r,m)}};var g=class extends e{constructor(n,t){super(["bitop",...n],t)}};var x=class extends e{constructor(n,t){super(["bitpos",...n],t)}};var f=class extends e{constructor([n,t,o],m){super(["COPY",n,t,...o?.replace?["REPLACE"]:[]],{...m,deserialize(r){return r>0?"COPIED":"NOT_COPIED"}})}};var y=class extends e{constructor(n){super(["dbsize"],n)}};var b=class extends e{constructor(n,t){super(["decr",...n],t)}};var O=class extends e{constructor(n,t){super(["decrby",...n],t)}};var T=class extends e{constructor(n,t){super(["del",...n],t)}};var w=class extends e{constructor(n,t){super(["echo",...n],t)}};var D=class extends e{constructor([n,t,o],m){super(["eval",n,t.length,...t,...o??[]],m)}};var k=class extends e{constructor([n,t,o],m){super(["evalsha",n,t.length,...t,...o??[]],m)}};var A=class extends e{constructor(n,t){super(["exists",...n],t)}};var S=class extends e{constructor(n,t){super(["expire",...n],t)}};var R=class extends e{constructor(n,t){super(["expireat",...n],t)}};var v=class extends e{constructor(n,t){let o=["flushall"];n&&n.length>0&&n[0].async&&o.push("async"),super(o,t)}};var M=class extends e{constructor([n],t){let o=["flushdb"];n?.async&&o.push("async"),super(o,t)}};var E=class extends e{constructor([n,t,...o],m){let r=["geoadd",n];"nx"in t&&t.nx?r.push("nx"):"xx"in t&&t.xx&&r.push("xx"),"ch"in t&&t.ch&&r.push("ch"),"latitude"in t&&t.latitude&&r.push(t.longitude,t.latitude,t.member),r.push(...o.flatMap(({latitude:a,longitude:i,member:p})=>[i,a,p])),super(r,m)}};var z=class extends e{constructor([n,t,o,m="M"],r){super(["GEODIST",n,t,o,m],r)}};var I=class extends e{constructor(n,t){let[o]=n,m=Array.isArray(n[1])?n[1]:n.slice(1);super(["GEOPOS",o,...m],{deserialize:r=>Re(r),...t})}};function Re(s){let n=[];for(let t of s)!t?.[0]||!t?.[1]||n.push({lng:parseFloat(t[0]),lat:parseFloat(t[1])});return n}var P=class extends e{constructor(n,t){let[o]=n,m=Array.isArray(n[1])?n[1]:n.slice(1);super(["GEOHASH",o,...m],t)}};var J=class extends e{constructor([n,t,o,m,r],a){let i=["GEOSEARCH",n];(t.type==="FROMMEMBER"||t.type==="frommember")&&i.push(t.type,t.member),(t.type==="FROMLONLAT"||t.type==="fromlonlat")&&i.push(t.type,t.coordinate.lon,t.coordinate.lat),(o.type==="BYRADIUS"||o.type==="byradius")&&i.push(o.type,o.radius,o.radiusType),(o.type==="BYBOX"||o.type==="bybox")&&i.push(o.type,o.rect.width,o.rect.height,o.rectType),i.push(m),r?.count&&i.push(r.count.limit,...r.count.any?["ANY"]:[]);let p=ce=>!r?.withCoord&&!r?.withDist&&!r?.withHash?ce.map(d=>{try{return{member:JSON.parse(d)}}catch{return{member:d}}}):ce.map(d=>{let ee=1,h={};try{h.member=JSON.parse(d[0])}catch{h.member=d[0]}return r.withDist&&(h.dist=parseFloat(d[ee++])),r.withHash&&(h.hash=d[ee++].toString()),r.withCoord&&(h.coord={long:parseFloat(d[ee][0]),lat:parseFloat(d[ee][1])}),h});super([...i,...r?.withCoord?["WITHCOORD"]:[],...r?.withDist?["WITHDIST"]:[],...r?.withHash?["WITHHASH"]:[]],{...a,deserialize:p})}};var L=class extends e{constructor([n,t,o,m,r,a],i){let p=["GEOSEARCHSTORE",n,t];(o.type==="FROMMEMBER"||o.type==="frommember")&&p.push(o.type,o.member),(o.type==="FROMLONLAT"||o.type==="fromlonlat")&&p.push(o.type,o.coordinate.lon,o.coordinate.lat),(m.type==="BYRADIUS"||m.type==="byradius")&&p.push(m.type,m.radius,m.radiusType),(m.type==="BYBOX"||m.type==="bybox")&&p.push(m.type,m.rect.width,m.rect.height,m.rectType),p.push(r),a?.count&&p.push(a.count.limit,...a.count.any?["ANY"]:[]),super([...p,...a?.storeDist?["STOREDIST"]:[]],i)}};var N=class extends e{constructor(n,t){super(["get",...n],t)}};var K=class extends e{constructor(n,t){super(["getbit",...n],t)}};var Z=class extends e{constructor(n,t){super(["getdel",...n],t)}};var G=class extends e{constructor(n,t){super(["getrange",...n],t)}};var U=class extends e{constructor(n,t){super(["getset",...n],t)}};var B=class extends e{constructor(n,t){super(["hdel",...n],t)}};var H=class extends e{constructor(n,t){super(["hexists",...n],t)}};var F=class extends e{constructor(n,t){super(["hget",...n],t)}};function ve(s){if(s.length===0)return null;let n={};for(;s.length>=2;){let t=s.shift(),o=s.shift();try{!Number.isNaN(Number(o))&&!Number.isSafeInteger(o)?n[t]=o:n[t]=JSON.parse(o)}catch{n[t]=o}}return n}var $=class extends e{constructor(n,t){super(["hgetall",...n],{deserialize:o=>ve(o),...t})}};var q=class extends e{constructor(n,t){super(["hincrby",...n],t)}};var j=class extends e{constructor(n,t){super(["hincrbyfloat",...n],t)}};var X=class extends e{constructor([n],t){super(["hkeys",n],t)}};var W=class extends e{constructor(n,t){super(["hlen",...n],t)}};function Me(s,n){if(n.length===0||n.every(o=>o===null))return null;let t={};for(let o=0;o<s.length;o++)try{t[s[o]]=JSON.parse(n[o])}catch{t[s[o]]=n[o]}return t}var _=class extends e{constructor([n,...t],o){super(["hmget",n,...t],{deserialize:m=>Me(t,m),...o})}};var Y=class extends e{constructor([n,t],o){super(["hmset",n,...Object.entries(t).flatMap(([m,r])=>[m,r])],o)}};function Ee(s){if(s.length===0)return null;let n={};for(;s.length>=2;){let t=s.shift(),o=s.shift();try{n[t]=JSON.parse(o)}catch{n[t]=o}}return n}var V=class extends e{constructor(n,t){let o=["hrandfield",n[0]];typeof n[1]=="number"&&o.push(n[1]),n[2]&&o.push("WITHVALUES"),super(o,{deserialize:n[2]?m=>Ee(m):t?.deserialize,...t})}};var Q=class extends e{constructor([n,t,o],m){let r=["hscan",n,t];o?.match&&r.push("match",o.match),typeof o?.count=="number"&&r.push("count",o.count),super(r,m)}};var nn=class extends e{constructor([n,t],o){super(["hset",n,...Object.entries(t).flatMap(([m,r])=>[m,r])],o)}};var tn=class extends e{constructor(n,t){super(["hsetnx",...n],t)}};var en=class extends e{constructor(n,t){super(["hstrlen",...n],t)}};var on=class extends e{constructor(n,t){super(["hvals",...n],t)}};var sn=class extends e{constructor(n,t){super(["incr",...n],t)}};var mn=class extends e{constructor(n,t){super(["incrby",...n],t)}};var rn=class extends e{constructor(n,t){super(["incrbyfloat",...n],t)}};var an=class extends e{constructor(n,t){super(["JSON.ARRAPPEND",...n],t)}};var pn=class extends e{constructor(n,t){super(["JSON.ARRINDEX",...n],t)}};var dn=class extends e{constructor(n,t){super(["JSON.ARRINSERT",...n],t)}};var cn=class extends e{constructor(n,t){super(["JSON.ARRLEN",n[0],n[1]??"$"],t)}};var un=class extends e{constructor(n,t){super(["JSON.ARRPOP",...n],t)}};var hn=class extends e{constructor(n,t){let o=n[1]??"$",m=n[2]??0,r=n[3]??0;super(["JSON.ARRTRIM",n[0],o,m,r],t)}};var ln=class extends e{constructor(n,t){super(["JSON.CLEAR",...n],t)}};var Cn=class extends e{constructor(n,t){super(["JSON.DEL",...n],t)}};var gn=class extends e{constructor(n,t){super(["JSON.FORGET",...n],t)}};var xn=class extends e{constructor(n,t){let o=["JSON.GET"];typeof n[1]=="string"?o.push(...n):(o.push(n[0]),n[1]&&(n[1].indent&&o.push("INDENT",n[1].indent),n[1].newline&&o.push("NEWLINE",n[1].newline),n[1].space&&o.push("SPACE",n[1].space)),o.push(...n.slice(2))),super(o,t)}};var fn=class extends e{constructor(n,t){super(["JSON.MGET",...n[0],n[1]],t)}};var yn=class extends e{constructor(n,t){super(["JSON.NUMINCRBY",...n],t)}};var bn=class extends e{constructor(n,t){super(["JSON.NUMMULTBY",...n],t)}};var On=class extends e{constructor(n,t){super(["JSON.OBJKEYS",...n],t)}};var Tn=class extends e{constructor(n,t){super(["JSON.OBJLEN",...n],t)}};var wn=class extends e{constructor(n,t){super(["JSON.RESP",...n],t)}};var Dn=class extends e{constructor(n,t){let o=["JSON.SET",n[0],n[1],n[2]];n[3]&&(n[3].nx?o.push("NX"):n[3].xx&&o.push("XX")),super(o,t)}};var kn=class extends e{constructor(n,t){super(["JSON.STRAPPEND",...n],t)}};var An=class extends e{constructor(n,t){super(["JSON.STRLEN",...n],t)}};var Sn=class extends e{constructor(n,t){super(["JSON.TOGGLE",...n],t)}};var Rn=class extends e{constructor(n,t){super(["JSON.TYPE",...n],t)}};var vn=class extends e{constructor(n,t){super(["keys",...n],t)}};var Mn=class extends e{constructor(n,t){super(["lindex",...n],t)}};var En=class extends e{constructor(n,t){super(["linsert",...n],t)}};var zn=class extends e{constructor(n,t){super(["llen",...n],t)}};var In=class extends e{constructor(n,t){super(["lmove",...n],t)}};var Pn=class extends e{constructor(n,t){super(["lpop",...n],t)}};var Jn=class extends e{constructor(n,t){let o=["lpos",n[0],n[1]];typeof n[2]?.rank=="number"&&o.push("rank",n[2].rank),typeof n[2]?.count=="number"&&o.push("count",n[2].count),typeof n[2]?.maxLen=="number"&&o.push("maxLen",n[2].maxLen),super(o,t)}};var Ln=class extends e{constructor(n,t){super(["lpush",...n],t)}};var Nn=class extends e{constructor(n,t){super(["lpushx",...n],t)}};var Kn=class extends e{constructor(n,t){super(["lrange",...n],t)}};var Zn=class extends e{constructor(n,t){super(["lrem",...n],t)}};var Gn=class extends e{constructor(n,t){super(["lset",...n],t)}};var Un=class extends e{constructor(n,t){super(["ltrim",...n],t)}};var Bn=class extends e{constructor(n,t){let o=Array.isArray(n[0])?n[0]:n;super(["mget",...o],t)}};var Hn=class extends e{constructor([n],t){super(["mset",...Object.entries(n).flatMap(([o,m])=>[o,m])],t)}};var Fn=class extends e{constructor([n],t){super(["msetnx",...Object.entries(n).flatMap(o=>o)],t)}};var $n=class extends e{constructor(n,t){super(["persist",...n],t)}};var qn=class extends e{constructor(n,t){super(["pexpire",...n],t)}};var jn=class extends e{constructor(n,t){super(["pexpireat",...n],t)}};var Xn=class extends e{constructor(n,t){let o=["ping"];typeof n<"u"&&typeof n[0]<"u"&&o.push(n[0]),super(o,t)}};var Wn=class extends e{constructor(n,t){super(["psetex",...n],t)}};var _n=class extends e{constructor(n,t){super(["pttl",...n],t)}};var Yn=class extends e{constructor(n,t){super(["publish",...n],t)}};var Vn=class extends e{constructor(n){super(["randomkey"],n)}};var Qn=class extends e{constructor(n,t){super(["rename",...n],t)}};var nt=class extends e{constructor(n,t){super(["renamenx",...n],t)}};var tt=class extends e{constructor(n,t){super(["rpop",...n],t)}};var et=class extends e{constructor(n,t){super(["rpush",...n],t)}};var ot=class extends e{constructor(n,t){super(["rpushx",...n],t)}};var st=class extends e{constructor(n,t){super(["sadd",...n],t)}};var mt=class extends e{constructor([n,t],o){let m=["scan",n];t?.match&&m.push("match",t.match),typeof t?.count=="number"&&m.push("count",t.count),t?.type&&t.type.length>0&&m.push("type",t.type),super(m,o)}};var rt=class extends e{constructor(n,t){super(["scard",...n],t)}};var at=class extends e{constructor(n,t){super(["script","exists",...n],{deserialize:o=>o,...t})}};var it=class extends e{constructor([n],t){let o=["script","flush"];n?.sync?o.push("sync"):n?.async&&o.push("async"),super(o,t)}};var pt=class extends e{constructor(n,t){super(["script","load",...n],t)}};var dt=class extends e{constructor(n,t){super(["sdiff",...n],t)}};var ct=class extends e{constructor(n,t){super(["sdiffstore",...n],t)}};var ut=class extends e{constructor([n,t,o],m){let r=["set",n,t];o&&("nx"in o&&o.nx?r.push("nx"):"xx"in o&&o.xx&&r.push("xx"),"get"in o&&o.get&&r.push("get"),"ex"in o&&typeof o.ex=="number"?r.push("ex",o.ex):"px"in o&&typeof o.px=="number"?r.push("px",o.px):"exat"in o&&typeof o.exat=="number"?r.push("exat",o.exat):"pxat"in o&&typeof o.pxat=="number"?r.push("pxat",o.pxat):"keepTtl"in o&&o.keepTtl&&r.push("keepTtl")),super(r,m)}};var ht=class extends e{constructor(n,t){super(["setbit",...n],t)}};var lt=class extends e{constructor(n,t){super(["setex",...n],t)}};var Ct=class extends e{constructor(n,t){super(["setnx",...n],t)}};var gt=class extends e{constructor(n,t){super(["setrange",...n],t)}};var xt=class extends e{constructor(n,t){super(["sinter",...n],t)}};var ft=class extends e{constructor(n,t){super(["sinterstore",...n],t)}};var yt=class extends e{constructor(n,t){super(["sismember",...n],t)}};var bt=class extends e{constructor(n,t){super(["smembers",...n],t)}};var Ot=class extends e{constructor(n,t){super(["smismember",n[0],...n[1]],t)}};var Tt=class extends e{constructor(n,t){super(["smove",...n],t)}};var wt=class extends e{constructor([n,t],o){let m=["spop",n];typeof t=="number"&&m.push(t),super(m,o)}};var Dt=class extends e{constructor([n,t],o){let m=["srandmember",n];typeof t=="number"&&m.push(t),super(m,o)}};var kt=class extends e{constructor(n,t){super(["srem",...n],t)}};var At=class extends e{constructor([n,t,o],m){let r=["sscan",n,t];o?.match&&r.push("match",o.match),typeof o?.count=="number"&&r.push("count",o.count),super(r,m)}};var St=class extends e{constructor(n,t){super(["strlen",...n],t)}};var Rt=class extends e{constructor(n,t){super(["sunion",...n],t)}};var vt=class extends e{constructor(n,t){super(["sunionstore",...n],t)}};var Mt=class extends e{constructor(n){super(["time"],n)}};var Et=class extends e{constructor(n,t){super(["touch",...n],t)}};var zt=class extends e{constructor(n,t){super(["ttl",...n],t)}};var It=class extends e{constructor(n,t){super(["type",...n],t)}};var Pt=class extends e{constructor(n,t){super(["unlink",...n],t)}};var me=class extends e{constructor([n,t,o,m],r){let a=["XADD",n];m&&(m.nomkStream&&a.push("NOMKSTREAM"),m.trim&&(a.push(m.trim.type,m.trim.comparison,m.trim.threshold),typeof m.trim.limit<"u"&&a.push("LIMIT",m.trim.limit))),a.push(t);for(let[i,p]of Object.entries(o))a.push(i,p);super(a,r)}};function ze(s){let n={};for(let t of s)for(;t.length>=2;){let o=t.shift(),m=t.shift();for((o in n)||(n[o]={});m.length>=2;){let r=m.shift(),a=m.shift();try{n[o][r]=JSON.parse(a)}catch{n[o][r]=a}}}return n}var re=class extends e{constructor([n,t,o,m],r){let a=["XRANGE",n,t,o];typeof m=="number"&&a.push("COUNT",m),super(a,{deserialize:i=>ze(i),...r})}};var u=class extends e{constructor([n,t,...o],m){let r=["zadd",n];"nx"in t&&t.nx?r.push("nx"):"xx"in t&&t.xx&&r.push("xx"),"ch"in t&&t.ch&&r.push("ch"),"incr"in t&&t.incr&&r.push("incr"),"score"in t&&"member"in t&&r.push(t.score,t.member),r.push(...o.flatMap(({score:a,member:i})=>[a,i])),super(r,m)}};var Jt=class extends e{constructor(n,t){super(["zcard",...n],t)}};var Lt=class extends e{constructor(n,t){super(["zcount",...n],t)}};var Nt=class extends e{constructor(n,t){super(["zincrby",...n],t)}};var Kt=class extends e{constructor([n,t,o,m],r){let a=["zinterstore",n,t];Array.isArray(o)?a.push(...o):a.push(o),m&&("weights"in m&&m.weights?a.push("weights",...m.weights):"weight"in m&&typeof m.weight=="number"&&a.push("weights",m.weight),"aggregate"in m&&a.push("aggregate",m.aggregate)),super(a,r)}};var Zt=class extends e{constructor(n,t){super(["zlexcount",...n],t)}};var Gt=class extends e{constructor([n,t],o){let m=["zpopmax",n];typeof t=="number"&&m.push(t),super(m,o)}};var Ut=class extends e{constructor([n,t],o){let m=["zpopmin",n];typeof t=="number"&&m.push(t),super(m,o)}};var Bt=class extends e{constructor([n,t,o,m],r){let a=["zrange",n,t,o];m?.byScore&&a.push("byscore"),m?.byLex&&a.push("bylex"),m?.rev&&a.push("rev"),typeof m?.count<"u"&&typeof m?.offset<"u"&&a.push("limit",m.offset,m.count),m?.withScores&&a.push("withscores"),super(a,r)}};var Ht=class extends e{constructor(n,t){super(["zrank",...n],t)}};var Ft=class extends e{constructor(n,t){super(["zrem",...n],t)}};var $t=class extends e{constructor(n,t){super(["zremrangebylex",...n],t)}};var qt=class extends e{constructor(n,t){super(["zremrangebyrank",...n],t)}};var jt=class extends e{constructor(n,t){super(["zremrangebyscore",...n],t)}};var Xt=class extends e{constructor(n,t){super(["zrevrank",...n],t)}};var Wt=class extends e{constructor([n,t,o],m){let r=["zscan",n,t];o?.match&&r.push("match",o.match),typeof o?.count=="number"&&r.push("count",o.count),super(r,m)}};var _t=class extends e{constructor(n,t){super(["zscore",...n],t)}};var Yt=class extends e{constructor([n,t,o],m){let r=["zunion",n];Array.isArray(t)?r.push(...t):r.push(t),o&&("weights"in o&&o.weights?r.push("weights",...o.weights):"weight"in o&&typeof o.weight=="number"&&r.push("weights",o.weight),"aggregate"in o&&r.push("aggregate",o.aggregate),o?.withScores&&r.push("withscores")),super(r,m)}};var Vt=class extends e{constructor([n,t,o,m],r){let a=["zunionstore",n,t];Array.isArray(o)?a.push(...o):a.push(o),m&&("weights"in m&&m.weights?a.push("weights",...m.weights):"weight"in m&&typeof m.weight=="number"&&a.push("weights",m.weight),"aggregate"in m&&a.push("aggregate",m.aggregate)),super(a,r)}};var Qt=class extends e{constructor(n,t){super(["zdiffstore",...n],t)}};var ne=class extends e{constructor(n,t){let[o,m]=n;super(["zmscore",o,...m],t)}};var te=class{client;commands;commandOptions;multiExec;constructor(n){this.client=n.client,this.commands=[],this.commandOptions=n.commandOptions,this.multiExec=n.multiExec??!1}exec=async()=>{if(this.commands.length===0)throw new Error("Pipeline is empty");let n=this.multiExec?["multi-exec"]:["pipeline"];return(await this.client.request({path:n,body:Object.values(this.commands).map(o=>o.command)})).map(({error:o,result:m},r)=>{if(o)throw new c(`Command ${r+1} [ ${this.commands[r].command[0]} ] failed: ${o}`);return this.commands[r].deserialize(m)})};length(){return this.commands.length}chain(n){return this.commands.push(n),this}append=(...n)=>this.chain(new l(n,this.commandOptions));bitcount=(...n)=>this.chain(new C(n,this.commandOptions));bitop=(n,t,o,...m)=>this.chain(new g([n,t,o,...m],this.commandOptions));bitpos=(...n)=>this.chain(new x(n,this.commandOptions));copy=(...n)=>this.chain(new f(n,this.commandOptions));zdiffstore=(...n)=>this.chain(new Qt(n,this.commandOptions));dbsize=()=>this.chain(new y(this.commandOptions));decr=(...n)=>this.chain(new b(n,this.commandOptions));decrby=(...n)=>this.chain(new O(n,this.commandOptions));del=(...n)=>this.chain(new T(n,this.commandOptions));echo=(...n)=>this.chain(new w(n,this.commandOptions));eval=(...n)=>this.chain(new D(n,this.commandOptions));evalsha=(...n)=>this.chain(new k(n,this.commandOptions));exists=(...n)=>this.chain(new A(n,this.commandOptions));expire=(...n)=>this.chain(new S(n,this.commandOptions));expireat=(...n)=>this.chain(new R(n,this.commandOptions));flushall=n=>this.chain(new v(n,this.commandOptions));flushdb=(...n)=>this.chain(new M(n,this.commandOptions));get=(...n)=>this.chain(new N(n,this.commandOptions));getbit=(...n)=>this.chain(new K(n,this.commandOptions));getdel=(...n)=>this.chain(new Z(n,this.commandOptions));getrange=(...n)=>this.chain(new G(n,this.commandOptions));getset=(n,t)=>this.chain(new U([n,t],this.commandOptions));hdel=(...n)=>this.chain(new B(n,this.commandOptions));hexists=(...n)=>this.chain(new H(n,this.commandOptions));hget=(...n)=>this.chain(new F(n,this.commandOptions));hgetall=(...n)=>this.chain(new $(n,this.commandOptions));hincrby=(...n)=>this.chain(new q(n,this.commandOptions));hincrbyfloat=(...n)=>this.chain(new j(n,this.commandOptions));hkeys=(...n)=>this.chain(new X(n,this.commandOptions));hlen=(...n)=>this.chain(new W(n,this.commandOptions));hmget=(...n)=>this.chain(new _(n,this.commandOptions));hmset=(n,t)=>this.chain(new Y([n,t],this.commandOptions));hrandfield=(n,t,o)=>this.chain(new V([n,t,o],this.commandOptions));hscan=(...n)=>this.chain(new Q(n,this.commandOptions));hset=(n,t)=>this.chain(new nn([n,t],this.commandOptions));hsetnx=(n,t,o)=>this.chain(new tn([n,t,o],this.commandOptions));hstrlen=(...n)=>this.chain(new en(n,this.commandOptions));hvals=(...n)=>this.chain(new on(n,this.commandOptions));incr=(...n)=>this.chain(new sn(n,this.commandOptions));incrby=(...n)=>this.chain(new mn(n,this.commandOptions));incrbyfloat=(...n)=>this.chain(new rn(n,this.commandOptions));keys=(...n)=>this.chain(new vn(n,this.commandOptions));lindex=(...n)=>this.chain(new Mn(n,this.commandOptions));linsert=(n,t,o,m)=>this.chain(new En([n,t,o,m],this.commandOptions));llen=(...n)=>this.chain(new zn(n,this.commandOptions));lmove=(...n)=>this.chain(new In(n,this.commandOptions));lpop=(...n)=>this.chain(new Pn(n,this.commandOptions));lpos=(...n)=>this.chain(new Jn(n,this.commandOptions));lpush=(n,...t)=>this.chain(new Ln([n,...t],this.commandOptions));lpushx=(n,...t)=>this.chain(new Nn([n,...t],this.commandOptions));lrange=(...n)=>this.chain(new Kn(n,this.commandOptions));lrem=(n,t,o)=>this.chain(new Zn([n,t,o],this.commandOptions));lset=(n,t,o)=>this.chain(new Gn([n,t,o],this.commandOptions));ltrim=(...n)=>this.chain(new Un(n,this.commandOptions));mget=(...n)=>this.chain(new Bn(n,this.commandOptions));mset=n=>this.chain(new Hn([n],this.commandOptions));msetnx=n=>this.chain(new Fn([n],this.commandOptions));persist=(...n)=>this.chain(new $n(n,this.commandOptions));pexpire=(...n)=>this.chain(new qn(n,this.commandOptions));pexpireat=(...n)=>this.chain(new jn(n,this.commandOptions));ping=n=>this.chain(new Xn(n,this.commandOptions));psetex=(n,t,o)=>this.chain(new Wn([n,t,o],this.commandOptions));pttl=(...n)=>this.chain(new _n(n,this.commandOptions));publish=(...n)=>this.chain(new Yn(n,this.commandOptions));randomkey=()=>this.chain(new Vn(this.commandOptions));rename=(...n)=>this.chain(new Qn(n,this.commandOptions));renamenx=(...n)=>this.chain(new nt(n,this.commandOptions));rpop=(...n)=>this.chain(new tt(n,this.commandOptions));rpush=(n,...t)=>this.chain(new et([n,...t],this.commandOptions));rpushx=(n,...t)=>this.chain(new ot([n,...t],this.commandOptions));sadd=(n,...t)=>this.chain(new st([n,...t],this.commandOptions));scan=(...n)=>this.chain(new mt(n,this.commandOptions));scard=(...n)=>this.chain(new rt(n,this.commandOptions));scriptExists=(...n)=>this.chain(new at(n,this.commandOptions));scriptFlush=(...n)=>this.chain(new it(n,this.commandOptions));scriptLoad=(...n)=>this.chain(new pt(n,this.commandOptions));sdiff=(...n)=>this.chain(new dt(n,this.commandOptions));sdiffstore=(...n)=>this.chain(new ct(n,this.commandOptions));set=(n,t,o)=>this.chain(new ut([n,t,o],this.commandOptions));setbit=(...n)=>this.chain(new ht(n,this.commandOptions));setex=(n,t,o)=>this.chain(new lt([n,t,o],this.commandOptions));setnx=(n,t)=>this.chain(new Ct([n,t],this.commandOptions));setrange=(...n)=>this.chain(new gt(n,this.commandOptions));sinter=(...n)=>this.chain(new xt(n,this.commandOptions));sinterstore=(...n)=>this.chain(new ft(n,this.commandOptions));sismember=(n,t)=>this.chain(new yt([n,t],this.commandOptions));smembers=(...n)=>this.chain(new bt(n,this.commandOptions));smismember=(n,t)=>this.chain(new Ot([n,t],this.commandOptions));smove=(n,t,o)=>this.chain(new Tt([n,t,o],this.commandOptions));spop=(...n)=>this.chain(new wt(n,this.commandOptions));srandmember=(...n)=>this.chain(new Dt(n,this.commandOptions));srem=(n,...t)=>this.chain(new kt([n,...t],this.commandOptions));sscan=(...n)=>this.chain(new At(n,this.commandOptions));strlen=(...n)=>this.chain(new St(n,this.commandOptions));sunion=(...n)=>this.chain(new Rt(n,this.commandOptions));sunionstore=(...n)=>this.chain(new vt(n,this.commandOptions));time=()=>this.chain(new Mt(this.commandOptions));touch=(...n)=>this.chain(new Et(n,this.commandOptions));ttl=(...n)=>this.chain(new zt(n,this.commandOptions));type=(...n)=>this.chain(new It(n,this.commandOptions));unlink=(...n)=>this.chain(new Pt(n,this.commandOptions));zadd=(...n)=>"score"in n[1]?this.chain(new u([n[0],n[1],...n.slice(2)],this.commandOptions)):this.chain(new u([n[0],n[1],...n.slice(2)],this.commandOptions));zcard=(...n)=>this.chain(new Jt(n,this.commandOptions));zcount=(...n)=>this.chain(new Lt(n,this.commandOptions));zincrby=(n,t,o)=>this.chain(new Nt([n,t,o],this.commandOptions));zinterstore=(...n)=>this.chain(new Kt(n,this.commandOptions));zlexcount=(...n)=>this.chain(new Zt(n,this.commandOptions));zmscore=(...n)=>this.chain(new ne(n,this.commandOptions));zpopmax=(...n)=>this.chain(new Gt(n,this.commandOptions));zpopmin=(...n)=>this.chain(new Ut(n,this.commandOptions));zrange=(...n)=>this.chain(new Bt(n,this.commandOptions));zrank=(n,t)=>this.chain(new Ht([n,t],this.commandOptions));zrem=(n,...t)=>this.chain(new Ft([n,...t],this.commandOptions));zremrangebylex=(...n)=>this.chain(new $t(n,this.commandOptions));zremrangebyrank=(...n)=>this.chain(new qt(n,this.commandOptions));zremrangebyscore=(...n)=>this.chain(new jt(n,this.commandOptions));zrevrank=(n,t)=>this.chain(new Xt([n,t],this.commandOptions));zscan=(...n)=>this.chain(new Wt(n,this.commandOptions));zscore=(n,t)=>this.chain(new _t([n,t],this.commandOptions));zunionstore=(...n)=>this.chain(new Vt(n,this.commandOptions));zunion=(...n)=>this.chain(new Yt(n,this.commandOptions));get json(){return{arrappend:(...n)=>this.chain(new an(n,this.commandOptions)),arrindex:(...n)=>this.chain(new pn(n,this.commandOptions)),arrinsert:(...n)=>this.chain(new dn(n,this.commandOptions)),arrlen:(...n)=>this.chain(new cn(n,this.commandOptions)),arrpop:(...n)=>this.chain(new un(n,this.commandOptions)),arrtrim:(...n)=>this.chain(new hn(n,this.commandOptions)),clear:(...n)=>this.chain(new ln(n,this.commandOptions)),del:(...n)=>this.chain(new Cn(n,this.commandOptions)),forget:(...n)=>this.chain(new gn(n,this.commandOptions)),geoadd:(...n)=>this.chain(new E(n,this.commandOptions)),geodist:(...n)=>this.chain(new z(n,this.commandOptions)),geopos:(...n)=>this.chain(new I(n,this.commandOptions)),geohash:(...n)=>this.chain(new P(n,this.commandOptions)),geosearch:(...n)=>this.chain(new J(n,this.commandOptions)),geosearchstore:(...n)=>this.chain(new L(n,this.commandOptions)),get:(...n)=>this.chain(new xn(n,this.commandOptions)),mget:(...n)=>this.chain(new fn(n,this.commandOptions)),numincrby:(...n)=>this.chain(new yn(n,this.commandOptions)),nummultby:(...n)=>this.chain(new bn(n,this.commandOptions)),objkeys:(...n)=>this.chain(new On(n,this.commandOptions)),objlen:(...n)=>this.chain(new Tn(n,this.commandOptions)),resp:(...n)=>this.chain(new wn(n,this.commandOptions)),set:(...n)=>this.chain(new Dn(n,this.commandOptions)),strappend:(...n)=>this.chain(new kn(n,this.commandOptions)),strlen:(...n)=>this.chain(new An(n,this.commandOptions)),toggle:(...n)=>this.chain(new Sn(n,this.commandOptions)),type:(...n)=>this.chain(new Rn(n,this.commandOptions))}}};var xe=he(require("crypto-js/enc-hex")),fe=he(require("crypto-js/sha1")),ae=class{script;sha1;redis;constructor(n,t){this.redis=n,this.sha1=this.digest(t),this.script=t}async eval(n,t){return await this.redis.eval(this.script,n,t)}async evalsha(n,t){return await this.redis.evalsha(this.sha1,n,t)}async exec(n,t){return await this.redis.evalsha(this.sha1,n,t).catch(async m=>{if(m instanceof Error&&m.message.toLowerCase().includes("noscript"))return await this.redis.eval(this.script,n,t);throw m})}digest(n){return xe.default.stringify((0,fe.default)(n))}};var ie=class{client;opts;enableTelemetry;constructor(n,t){this.client=n,this.opts=t,this.enableTelemetry=t?.enableTelemetry??!0}get json(){return{arrappend:(...n)=>new an(n,this.opts).exec(this.client),arrindex:(...n)=>new pn(n,this.opts).exec(this.client),arrinsert:(...n)=>new dn(n,this.opts).exec(this.client),arrlen:(...n)=>new cn(n,this.opts).exec(this.client),arrpop:(...n)=>new un(n,this.opts).exec(this.client),arrtrim:(...n)=>new hn(n,this.opts).exec(this.client),clear:(...n)=>new ln(n,this.opts).exec(this.client),del:(...n)=>new Cn(n,this.opts).exec(this.client),forget:(...n)=>new gn(n,this.opts).exec(this.client),geoadd:(...n)=>new E(n,this.opts).exec(this.client),geopos:(...n)=>new I(n,this.opts).exec(this.client),geodist:(...n)=>new z(n,this.opts).exec(this.client),geohash:(...n)=>new P(n,this.opts).exec(this.client),geosearch:(...n)=>new J(n,this.opts).exec(this.client),geosearchstore:(...n)=>new L(n,this.opts).exec(this.client),get:(...n)=>new xn(n,this.opts).exec(this.client),mget:(...n)=>new fn(n,this.opts).exec(this.client),numincrby:(...n)=>new yn(n,this.opts).exec(this.client),nummultby:(...n)=>new bn(n,this.opts).exec(this.client),objkeys:(...n)=>new On(n,this.opts).exec(this.client),objlen:(...n)=>new Tn(n,this.opts).exec(this.client),resp:(...n)=>new wn(n,this.opts).exec(this.client),set:(...n)=>new Dn(n,this.opts).exec(this.client),strappend:(...n)=>new kn(n,this.opts).exec(this.client),strlen:(...n)=>new An(n,this.opts).exec(this.client),toggle:(...n)=>new Sn(n,this.opts).exec(this.client),type:(...n)=>new Rn(n,this.opts).exec(this.client)}}use=n=>{let t=this.client.request.bind(this.client);this.client.request=o=>n(o,t)};addTelemetry=n=>{if(this.enableTelemetry)try{this.client.mergeTelemetry(n)}catch{}};createScript(n){return new ae(this,n)}pipeline=()=>new te({client:this.client,commandOptions:this.opts,multiExec:!1});multi=()=>new te({client:this.client,commandOptions:this.opts,multiExec:!0});append=(...n)=>new l(n,this.opts).exec(this.client);bitcount=(...n)=>new C(n,this.opts).exec(this.client);bitop=(n,t,o,...m)=>new g([n,t,o,...m],this.opts).exec(this.client);bitpos=(...n)=>new x(n,this.opts).exec(this.client);copy=(...n)=>new f(n,this.opts).exec(this.client);dbsize=()=>new y(this.opts).exec(this.client);decr=(...n)=>new b(n,this.opts).exec(this.client);decrby=(...n)=>new O(n,this.opts).exec(this.client);del=(...n)=>new T(n,this.opts).exec(this.client);echo=(...n)=>new w(n,this.opts).exec(this.client);eval=(...n)=>new D(n,this.opts).exec(this.client);evalsha=(...n)=>new k(n,this.opts).exec(this.client);exists=(...n)=>new A(n,this.opts).exec(this.client);expire=(...n)=>new S(n,this.opts).exec(this.client);expireat=(...n)=>new R(n,this.opts).exec(this.client);flushall=n=>new v(n,this.opts).exec(this.client);flushdb=(...n)=>new M(n,this.opts).exec(this.client);get=(...n)=>new N(n,this.opts).exec(this.client);getbit=(...n)=>new K(n,this.opts).exec(this.client);getdel=(...n)=>new Z(n,this.opts).exec(this.client);getrange=(...n)=>new G(n,this.opts).exec(this.client);getset=(n,t)=>new U([n,t],this.opts).exec(this.client);hdel=(...n)=>new B(n,this.opts).exec(this.client);hexists=(...n)=>new H(n,this.opts).exec(this.client);hget=(...n)=>new F(n,this.opts).exec(this.client);hgetall=(...n)=>new $(n,this.opts).exec(this.client);hincrby=(...n)=>new q(n,this.opts).exec(this.client);hincrbyfloat=(...n)=>new j(n,this.opts).exec(this.client);hkeys=(...n)=>new X(n,this.opts).exec(this.client);hlen=(...n)=>new W(n,this.opts).exec(this.client);hmget=(...n)=>new _(n,this.opts).exec(this.client);hmset=(n,t)=>new Y([n,t],this.opts).exec(this.client);hrandfield=(n,t,o)=>new V([n,t,o],this.opts).exec(this.client);hscan=(...n)=>new Q(n,this.opts).exec(this.client);hset=(n,t)=>new nn([n,t],this.opts).exec(this.client);hsetnx=(n,t,o)=>new tn([n,t,o],this.opts).exec(this.client);hstrlen=(...n)=>new en(n,this.opts).exec(this.client);hvals=(...n)=>new on(n,this.opts).exec(this.client);incr=(...n)=>new sn(n,this.opts).exec(this.client);incrby=(...n)=>new mn(n,this.opts).exec(this.client);incrbyfloat=(...n)=>new rn(n,this.opts).exec(this.client);keys=(...n)=>new vn(n,this.opts).exec(this.client);lindex=(...n)=>new Mn(n,this.opts).exec(this.client);linsert=(n,t,o,m)=>new En([n,t,o,m],this.opts).exec(this.client);llen=(...n)=>new zn(n,this.opts).exec(this.client);lmove=(...n)=>new In(n,this.opts).exec(this.client);lpop=(...n)=>new Pn(n,this.opts).exec(this.client);lpos=(...n)=>new Jn(n,this.opts).exec(this.client);lpush=(n,...t)=>new Ln([n,...t],this.opts).exec(this.client);lpushx=(n,...t)=>new Nn([n,...t],this.opts).exec(this.client);lrange=(...n)=>new Kn(n,this.opts).exec(this.client);lrem=(n,t,o)=>new Zn([n,t,o],this.opts).exec(this.client);lset=(n,t,o)=>new Gn([n,t,o],this.opts).exec(this.client);ltrim=(...n)=>new Un(n,this.opts).exec(this.client);mget=(...n)=>new Bn(n,this.opts).exec(this.client);mset=n=>new Hn([n],this.opts).exec(this.client);msetnx=n=>new Fn([n],this.opts).exec(this.client);persist=(...n)=>new $n(n,this.opts).exec(this.client);pexpire=(...n)=>new qn(n,this.opts).exec(this.client);pexpireat=(...n)=>new jn(n,this.opts).exec(this.client);ping=n=>new Xn(n,this.opts).exec(this.client);psetex=(n,t,o)=>new Wn([n,t,o],this.opts).exec(this.client);pttl=(...n)=>new _n(n,this.opts).exec(this.client);publish=(...n)=>new Yn(n,this.opts).exec(this.client);randomkey=()=>new Vn().exec(this.client);rename=(...n)=>new Qn(n,this.opts).exec(this.client);renamenx=(...n)=>new nt(n,this.opts).exec(this.client);rpop=(...n)=>new tt(n,this.opts).exec(this.client);rpush=(n,...t)=>new et([n,...t],this.opts).exec(this.client);rpushx=(n,...t)=>new ot([n,...t],this.opts).exec(this.client);sadd=(n,...t)=>new st([n,...t],this.opts).exec(this.client);scan=(...n)=>new mt(n,this.opts).exec(this.client);scard=(...n)=>new rt(n,this.opts).exec(this.client);scriptExists=(...n)=>new at(n,this.opts).exec(this.client);scriptFlush=(...n)=>new it(n,this.opts).exec(this.client);scriptLoad=(...n)=>new pt(n,this.opts).exec(this.client);sdiff=(...n)=>new dt(n,this.opts).exec(this.client);sdiffstore=(...n)=>new ct(n,this.opts).exec(this.client);set=(n,t,o)=>new ut([n,t,o],this.opts).exec(this.client);setbit=(...n)=>new ht(n,this.opts).exec(this.client);setex=(n,t,o)=>new lt([n,t,o],this.opts).exec(this.client);setnx=(n,t)=>new Ct([n,t],this.opts).exec(this.client);setrange=(...n)=>new gt(n,this.opts).exec(this.client);sinter=(...n)=>new xt(n,this.opts).exec(this.client);sinterstore=(...n)=>new ft(n,this.opts).exec(this.client);sismember=(n,t)=>new yt([n,t],this.opts).exec(this.client);smismember=(n,t)=>new Ot([n,t],this.opts).exec(this.client);smembers=(...n)=>new bt(n,this.opts).exec(this.client);smove=(n,t,o)=>new Tt([n,t,o],this.opts).exec(this.client);spop=(...n)=>new wt(n,this.opts).exec(this.client);srandmember=(...n)=>new Dt(n,this.opts).exec(this.client);srem=(n,...t)=>new kt([n,...t],this.opts).exec(this.client);sscan=(...n)=>new At(n,this.opts).exec(this.client);strlen=(...n)=>new St(n,this.opts).exec(this.client);sunion=(...n)=>new Rt(n,this.opts).exec(this.client);sunionstore=(...n)=>new vt(n,this.opts).exec(this.client);time=()=>new Mt().exec(this.client);touch=(...n)=>new Et(n,this.opts).exec(this.client);ttl=(...n)=>new zt(n,this.opts).exec(this.client);type=(...n)=>new It(n,this.opts).exec(this.client);unlink=(...n)=>new Pt(n,this.opts).exec(this.client);xadd=(...n)=>new me(n,this.opts).exec(this.client);xrange=(...n)=>new re(n,this.opts).exec(this.client);zadd=(...n)=>"score"in n[1]?new u([n[0],n[1],...n.slice(2)],this.opts).exec(this.client):new u([n[0],n[1],...n.slice(2)],this.opts).exec(this.client);zcard=(...n)=>new Jt(n,this.opts).exec(this.client);zcount=(...n)=>new Lt(n,this.opts).exec(this.client);zdiffstore=(...n)=>new Qt(n,this.opts).exec(this.client);zincrby=(n,t,o)=>new Nt([n,t,o],this.opts).exec(this.client);zinterstore=(...n)=>new Kt(n,this.opts).exec(this.client);zlexcount=(...n)=>new Zt(n,this.opts).exec(this.client);zmscore=(...n)=>new ne(n,this.opts).exec(this.client);zpopmax=(...n)=>new Gt(n,this.opts).exec(this.client);zpopmin=(...n)=>new Ut(n,this.opts).exec(this.client);zrange=(...n)=>new Bt(n,this.opts).exec(this.client);zrank=(n,t)=>new Ht([n,t],this.opts).exec(this.client);zrem=(n,...t)=>new Ft([n,...t],this.opts).exec(this.client);zremrangebylex=(...n)=>new $t(n,this.opts).exec(this.client);zremrangebyrank=(...n)=>new qt(n,this.opts).exec(this.client);zremrangebyscore=(...n)=>new jt(n,this.opts).exec(this.client);zrevrank=(n,t)=>new Xt([n,t],this.opts).exec(this.client);zscan=(...n)=>new Wt(n,this.opts).exec(this.client);zscore=(n,t)=>new _t([n,t],this.opts).exec(this.client);zunion=(...n)=>new Yt(n,this.opts).exec(this.client);zunionstore=(...n)=>new Vt(n,this.opts).exec(this.client)};var ye="v0.0.0-ci.ee21c87148cceb1a3548ec2eaef164f04178a10f";typeof atob>"u"&&(global.atob=function(s){return Buffer.from(s,"base64").toString("utf-8")});var de=class s extends ie{constructor(n){if("request"in n){super(n);return}(n.url.startsWith(" ")||n.url.endsWith(" ")||/\r|\n/.test(n.url))&&console.warn("The redis url contains whitespace or newline, which can cause errors!"),(n.token.startsWith(" ")||n.token.endsWith(" ")||/\r|\n/.test(n.token))&&console.warn("The redis token contains whitespace or newline, which can cause errors!");let t=new se({baseUrl:n.url,retry:n.retry,headers:{authorization:`Bearer ${n.token}`},agent:n.agent,responseEncoding:n.responseEncoding,cache:n.cache||"no-store"});super(t,{automaticDeserialization:n.automaticDeserialization,enableTelemetry:!process.env.UPSTASH_DISABLE_TELEMETRY}),this.addTelemetry({runtime:typeof EdgeRuntime=="string"?"edge-light":`node@${process.version}`,platform:process.env.VERCEL?"vercel":process.env.AWS_REGION?"aws":"unknown",sdk:`@upstash/redis@${ye}`})}static fromEnv(n){if(typeof process?.env>"u")throw new Error('Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead');let t=process?.env.UPSTASH_REDIS_REST_URL;if(!t)throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");let o=process?.env.UPSTASH_REDIS_REST_TOKEN;if(!o)throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");return new s({...n,url:t,token:o})}};0&&(module.exports={Redis});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // platforms/nodejs.ts
31
+ var nodejs_exports = {};
32
+ __export(nodejs_exports, {
33
+ Redis: () => Redis2,
34
+ errors: () => error_exports
35
+ });
36
+ module.exports = __toCommonJS(nodejs_exports);
37
+
38
+ // pkg/error.ts
39
+ var error_exports = {};
40
+ __export(error_exports, {
41
+ UpstashError: () => UpstashError,
42
+ UrlError: () => UrlError
43
+ });
44
+ var UpstashError = class extends Error {
45
+ constructor(message) {
46
+ super(message);
47
+ this.name = "UpstashError";
48
+ }
49
+ };
50
+ var UrlError = class extends Error {
51
+ constructor(url) {
52
+ super(
53
+ `Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
54
+ );
55
+ this.name = "UrlError";
56
+ }
57
+ };
58
+
59
+ // pkg/http.ts
60
+ var HttpClient = class {
61
+ baseUrl;
62
+ headers;
63
+ options;
64
+ readYourWrites;
65
+ upstashSyncToken = "";
66
+ retry;
67
+ constructor(config) {
68
+ this.options = {
69
+ backend: config.options?.backend,
70
+ agent: config.agent,
71
+ responseEncoding: config.responseEncoding ?? "base64",
72
+ // default to base64
73
+ cache: config.cache,
74
+ signal: config.signal,
75
+ keepAlive: config.keepAlive ?? true
76
+ };
77
+ this.upstashSyncToken = "";
78
+ this.readYourWrites = config.readYourWrites ?? true;
79
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
80
+ const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
81
+ if (!urlRegex.test(this.baseUrl)) {
82
+ throw new UrlError(this.baseUrl);
83
+ }
84
+ this.headers = {
85
+ "Content-Type": "application/json",
86
+ ...config.headers
87
+ };
88
+ if (this.options.responseEncoding === "base64") {
89
+ this.headers["Upstash-Encoding"] = "base64";
90
+ }
91
+ this.retry = typeof config.retry === "boolean" && !config.retry ? {
92
+ attempts: 1,
93
+ backoff: () => 0
94
+ } : {
95
+ attempts: config.retry?.retries ?? 5,
96
+ backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
97
+ };
98
+ }
99
+ mergeTelemetry(telemetry) {
100
+ this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
101
+ this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
102
+ this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
103
+ }
104
+ async request(req) {
105
+ const requestOptions = {
106
+ //@ts-expect-error this should throw due to bun regression
107
+ cache: this.options.cache,
108
+ method: "POST",
109
+ headers: this.headers,
110
+ body: JSON.stringify(req.body),
111
+ keepalive: this.options.keepAlive,
112
+ agent: this.options.agent,
113
+ signal: this.options.signal,
114
+ /**
115
+ * Fastly specific
116
+ */
117
+ backend: this.options.backend
118
+ };
119
+ if (this.readYourWrites) {
120
+ const newHeader = this.upstashSyncToken;
121
+ this.headers["upstash-sync-token"] = newHeader;
122
+ }
123
+ let res = null;
124
+ let error = null;
125
+ for (let i = 0; i <= this.retry.attempts; i++) {
126
+ try {
127
+ res = await fetch([this.baseUrl, ...req.path ?? []].join("/"), requestOptions);
128
+ break;
129
+ } catch (error_) {
130
+ if (this.options.signal?.aborted) {
131
+ const myBlob = new Blob([
132
+ JSON.stringify({ result: this.options.signal.reason ?? "Aborted" })
133
+ ]);
134
+ const myOptions = {
135
+ status: 200,
136
+ statusText: this.options.signal.reason ?? "Aborted"
137
+ };
138
+ res = new Response(myBlob, myOptions);
139
+ break;
140
+ }
141
+ error = error_;
142
+ await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
143
+ }
144
+ }
145
+ if (!res) {
146
+ throw error ?? new Error("Exhausted all retries");
147
+ }
148
+ const body = await res.json();
149
+ if (!res.ok) {
150
+ throw new UpstashError(`${body.error}, command was: ${JSON.stringify(req.body)}`);
151
+ }
152
+ if (this.readYourWrites) {
153
+ const headers = res.headers;
154
+ this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
155
+ }
156
+ if (this.readYourWrites) {
157
+ const headers = res.headers;
158
+ this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
159
+ }
160
+ if (this.options.responseEncoding === "base64") {
161
+ if (Array.isArray(body)) {
162
+ return body.map(({ result: result2, error: error2 }) => ({
163
+ result: decode(result2),
164
+ error: error2
165
+ }));
166
+ }
167
+ const result = decode(body.result);
168
+ return { result, error: body.error };
169
+ }
170
+ return body;
171
+ }
172
+ };
173
+ function base64decode(b64) {
174
+ let dec = "";
175
+ try {
176
+ const binString = atob(b64);
177
+ const size = binString.length;
178
+ const bytes = new Uint8Array(size);
179
+ for (let i = 0; i < size; i++) {
180
+ bytes[i] = binString.charCodeAt(i);
181
+ }
182
+ dec = new TextDecoder().decode(bytes);
183
+ } catch {
184
+ dec = b64;
185
+ }
186
+ return dec;
187
+ }
188
+ function decode(raw) {
189
+ let result = void 0;
190
+ switch (typeof raw) {
191
+ case "undefined": {
192
+ return raw;
193
+ }
194
+ case "number": {
195
+ result = raw;
196
+ break;
197
+ }
198
+ case "object": {
199
+ if (Array.isArray(raw)) {
200
+ result = raw.map(
201
+ (v) => typeof v === "string" ? base64decode(v) : Array.isArray(v) ? v.map((element) => decode(element)) : v
202
+ );
203
+ } else {
204
+ result = null;
205
+ }
206
+ break;
207
+ }
208
+ case "string": {
209
+ result = raw === "OK" ? "OK" : base64decode(raw);
210
+ break;
211
+ }
212
+ default: {
213
+ break;
214
+ }
215
+ }
216
+ return result;
217
+ }
218
+ function merge(obj, key, value) {
219
+ if (!value) {
220
+ return obj;
221
+ }
222
+ obj[key] = obj[key] ? [obj[key], value].join(",") : value;
223
+ return obj;
224
+ }
225
+
226
+ // pkg/auto-pipeline.ts
227
+ function createAutoPipelineProxy(_redis, json) {
228
+ const redis = _redis;
229
+ if (!redis.autoPipelineExecutor) {
230
+ redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
231
+ }
232
+ return new Proxy(redis, {
233
+ get: (redis2, command) => {
234
+ if (command === "pipelineCounter") {
235
+ return redis2.autoPipelineExecutor.pipelineCounter;
236
+ }
237
+ if (command === "json") {
238
+ return createAutoPipelineProxy(redis2, true);
239
+ }
240
+ const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
241
+ if (commandInRedisButNotPipeline) {
242
+ return redis2[command];
243
+ }
244
+ const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
245
+ if (isFunction) {
246
+ return (...args) => {
247
+ return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
248
+ if (json) {
249
+ pipeline.json[command](
250
+ ...args
251
+ );
252
+ } else {
253
+ pipeline[command](...args);
254
+ }
255
+ });
256
+ };
257
+ }
258
+ return redis2.autoPipelineExecutor.pipeline[command];
259
+ }
260
+ });
261
+ }
262
+ var AutoPipelineExecutor = class {
263
+ pipelinePromises = /* @__PURE__ */ new WeakMap();
264
+ activePipeline = null;
265
+ indexInCurrentPipeline = 0;
266
+ redis;
267
+ pipeline;
268
+ // only to make sure that proxy can work
269
+ pipelineCounter = 0;
270
+ // to keep track of how many times a pipeline was executed
271
+ constructor(redis) {
272
+ this.redis = redis;
273
+ this.pipeline = redis.pipeline();
274
+ }
275
+ async withAutoPipeline(executeWithPipeline) {
276
+ const pipeline = this.activePipeline ?? this.redis.pipeline();
277
+ if (!this.activePipeline) {
278
+ this.activePipeline = pipeline;
279
+ this.indexInCurrentPipeline = 0;
280
+ }
281
+ const index = this.indexInCurrentPipeline++;
282
+ executeWithPipeline(pipeline);
283
+ const pipelineDone = this.deferExecution().then(() => {
284
+ if (!this.pipelinePromises.has(pipeline)) {
285
+ const pipelinePromise = pipeline.exec({ keepErrors: true });
286
+ this.pipelineCounter += 1;
287
+ this.pipelinePromises.set(pipeline, pipelinePromise);
288
+ this.activePipeline = null;
289
+ }
290
+ return this.pipelinePromises.get(pipeline);
291
+ });
292
+ const results = await pipelineDone;
293
+ const commandResult = results[index];
294
+ if (commandResult.error) {
295
+ throw new UpstashError(`Command failed: ${commandResult.error}`);
296
+ }
297
+ return commandResult.result;
298
+ }
299
+ async deferExecution() {
300
+ await Promise.resolve();
301
+ await Promise.resolve();
302
+ }
303
+ };
304
+
305
+ // pkg/util.ts
306
+ function parseRecursive(obj) {
307
+ const parsed = Array.isArray(obj) ? obj.map((o) => {
308
+ try {
309
+ return parseRecursive(o);
310
+ } catch {
311
+ return o;
312
+ }
313
+ }) : JSON.parse(obj);
314
+ if (typeof parsed === "number" && parsed.toString() !== obj) {
315
+ return obj;
316
+ }
317
+ return parsed;
318
+ }
319
+ function parseResponse(result) {
320
+ try {
321
+ return parseRecursive(result);
322
+ } catch {
323
+ return result;
324
+ }
325
+ }
326
+ function deserializeScanResponse(result) {
327
+ return [result[0], ...parseResponse(result.slice(1))];
328
+ }
329
+
330
+ // pkg/commands/command.ts
331
+ var defaultSerializer = (c) => {
332
+ switch (typeof c) {
333
+ case "string":
334
+ case "number":
335
+ case "boolean": {
336
+ return c;
337
+ }
338
+ default: {
339
+ return JSON.stringify(c);
340
+ }
341
+ }
342
+ };
343
+ var Command = class {
344
+ command;
345
+ serialize;
346
+ deserialize;
347
+ /**
348
+ * Create a new command instance.
349
+ *
350
+ * You can define a custom `deserialize` function. By default we try to deserialize as json.
351
+ */
352
+ constructor(command, opts) {
353
+ this.serialize = defaultSerializer;
354
+ this.deserialize = opts?.automaticDeserialization === void 0 || opts.automaticDeserialization ? opts?.deserialize ?? parseResponse : (x) => x;
355
+ this.command = command.map((c) => this.serialize(c));
356
+ if (opts?.latencyLogging) {
357
+ const originalExec = this.exec.bind(this);
358
+ this.exec = async (client) => {
359
+ const start = performance.now();
360
+ const result = await originalExec(client);
361
+ const end = performance.now();
362
+ const loggerResult = (end - start).toFixed(2);
363
+ console.log(
364
+ `Latency for \x1B[38;2;19;185;39m${this.command[0].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
365
+ );
366
+ return result;
367
+ };
368
+ }
369
+ }
370
+ /**
371
+ * Execute the command using a client.
372
+ */
373
+ async exec(client) {
374
+ const { result, error } = await client.request({
375
+ body: this.command,
376
+ upstashSyncToken: client.upstashSyncToken
377
+ });
378
+ if (error) {
379
+ throw new UpstashError(error);
380
+ }
381
+ if (result === void 0) {
382
+ throw new TypeError("Request did not return a result");
383
+ }
384
+ return this.deserialize(result);
385
+ }
386
+ };
387
+
388
+ // pkg/commands/append.ts
389
+ var AppendCommand = class extends Command {
390
+ constructor(cmd, opts) {
391
+ super(["append", ...cmd], opts);
392
+ }
393
+ };
394
+
395
+ // pkg/commands/bitcount.ts
396
+ var BitCountCommand = class extends Command {
397
+ constructor([key, start, end], opts) {
398
+ const command = ["bitcount", key];
399
+ if (typeof start === "number") {
400
+ command.push(start);
401
+ }
402
+ if (typeof end === "number") {
403
+ command.push(end);
404
+ }
405
+ super(command, opts);
406
+ }
407
+ };
408
+
409
+ // pkg/commands/bitfield.ts
410
+ var BitFieldCommand = class {
411
+ constructor(args, client, opts, execOperation = (command) => command.exec(this.client)) {
412
+ this.client = client;
413
+ this.opts = opts;
414
+ this.execOperation = execOperation;
415
+ this.command = ["bitfield", ...args];
416
+ }
417
+ command;
418
+ chain(...args) {
419
+ this.command.push(...args);
420
+ return this;
421
+ }
422
+ get(...args) {
423
+ return this.chain("get", ...args);
424
+ }
425
+ set(...args) {
426
+ return this.chain("set", ...args);
427
+ }
428
+ incrby(...args) {
429
+ return this.chain("incrby", ...args);
430
+ }
431
+ overflow(overflow) {
432
+ return this.chain("overflow", overflow);
433
+ }
434
+ exec() {
435
+ const command = new Command(this.command, this.opts);
436
+ return this.execOperation(command);
437
+ }
438
+ };
439
+
440
+ // pkg/commands/bitop.ts
441
+ var BitOpCommand = class extends Command {
442
+ constructor(cmd, opts) {
443
+ super(["bitop", ...cmd], opts);
444
+ }
445
+ };
446
+
447
+ // pkg/commands/bitpos.ts
448
+ var BitPosCommand = class extends Command {
449
+ constructor(cmd, opts) {
450
+ super(["bitpos", ...cmd], opts);
451
+ }
452
+ };
453
+
454
+ // pkg/commands/copy.ts
455
+ var CopyCommand = class extends Command {
456
+ constructor([key, destinationKey, opts], commandOptions) {
457
+ super(["COPY", key, destinationKey, ...opts?.replace ? ["REPLACE"] : []], {
458
+ ...commandOptions,
459
+ deserialize(result) {
460
+ if (result > 0) {
461
+ return "COPIED";
462
+ }
463
+ return "NOT_COPIED";
464
+ }
465
+ });
466
+ }
467
+ };
468
+
469
+ // pkg/commands/dbsize.ts
470
+ var DBSizeCommand = class extends Command {
471
+ constructor(opts) {
472
+ super(["dbsize"], opts);
473
+ }
474
+ };
475
+
476
+ // pkg/commands/decr.ts
477
+ var DecrCommand = class extends Command {
478
+ constructor(cmd, opts) {
479
+ super(["decr", ...cmd], opts);
480
+ }
481
+ };
482
+
483
+ // pkg/commands/decrby.ts
484
+ var DecrByCommand = class extends Command {
485
+ constructor(cmd, opts) {
486
+ super(["decrby", ...cmd], opts);
487
+ }
488
+ };
489
+
490
+ // pkg/commands/del.ts
491
+ var DelCommand = class extends Command {
492
+ constructor(cmd, opts) {
493
+ super(["del", ...cmd], opts);
494
+ }
495
+ };
496
+
497
+ // pkg/commands/echo.ts
498
+ var EchoCommand = class extends Command {
499
+ constructor(cmd, opts) {
500
+ super(["echo", ...cmd], opts);
501
+ }
502
+ };
503
+
504
+ // pkg/commands/eval.ts
505
+ var EvalCommand = class extends Command {
506
+ constructor([script, keys, args], opts) {
507
+ super(["eval", script, keys.length, ...keys, ...args ?? []], opts);
508
+ }
509
+ };
510
+
511
+ // pkg/commands/evalsha.ts
512
+ var EvalshaCommand = class extends Command {
513
+ constructor([sha, keys, args], opts) {
514
+ super(["evalsha", sha, keys.length, ...keys, ...args ?? []], opts);
515
+ }
516
+ };
517
+
518
+ // pkg/commands/exists.ts
519
+ var ExistsCommand = class extends Command {
520
+ constructor(cmd, opts) {
521
+ super(["exists", ...cmd], opts);
522
+ }
523
+ };
524
+
525
+ // pkg/commands/expire.ts
526
+ var ExpireCommand = class extends Command {
527
+ constructor(cmd, opts) {
528
+ super(["expire", ...cmd.filter(Boolean)], opts);
529
+ }
530
+ };
531
+
532
+ // pkg/commands/expireat.ts
533
+ var ExpireAtCommand = class extends Command {
534
+ constructor(cmd, opts) {
535
+ super(["expireat", ...cmd], opts);
536
+ }
537
+ };
538
+
539
+ // pkg/commands/flushall.ts
540
+ var FlushAllCommand = class extends Command {
541
+ constructor(args, opts) {
542
+ const command = ["flushall"];
543
+ if (args && args.length > 0 && args[0].async) {
544
+ command.push("async");
545
+ }
546
+ super(command, opts);
547
+ }
548
+ };
549
+
550
+ // pkg/commands/flushdb.ts
551
+ var FlushDBCommand = class extends Command {
552
+ constructor([opts], cmdOpts) {
553
+ const command = ["flushdb"];
554
+ if (opts?.async) {
555
+ command.push("async");
556
+ }
557
+ super(command, cmdOpts);
558
+ }
559
+ };
560
+
561
+ // pkg/commands/geo_add.ts
562
+ var GeoAddCommand = class extends Command {
563
+ constructor([key, arg1, ...arg2], opts) {
564
+ const command = ["geoadd", key];
565
+ if ("nx" in arg1 && arg1.nx) {
566
+ command.push("nx");
567
+ } else if ("xx" in arg1 && arg1.xx) {
568
+ command.push("xx");
569
+ }
570
+ if ("ch" in arg1 && arg1.ch) {
571
+ command.push("ch");
572
+ }
573
+ if ("latitude" in arg1 && arg1.latitude) {
574
+ command.push(arg1.longitude, arg1.latitude, arg1.member);
575
+ }
576
+ command.push(
577
+ ...arg2.flatMap(({ latitude, longitude, member }) => [longitude, latitude, member])
578
+ );
579
+ super(command, opts);
580
+ }
581
+ };
582
+
583
+ // pkg/commands/geo_dist.ts
584
+ var GeoDistCommand = class extends Command {
585
+ constructor([key, member1, member2, unit = "M"], opts) {
586
+ super(["GEODIST", key, member1, member2, unit], opts);
587
+ }
588
+ };
589
+
590
+ // pkg/commands/geo_hash.ts
591
+ var GeoHashCommand = class extends Command {
592
+ constructor(cmd, opts) {
593
+ const [key] = cmd;
594
+ const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
595
+ super(["GEOHASH", key, ...members], opts);
596
+ }
597
+ };
598
+
599
+ // pkg/commands/geo_pos.ts
600
+ var GeoPosCommand = class extends Command {
601
+ constructor(cmd, opts) {
602
+ const [key] = cmd;
603
+ const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
604
+ super(["GEOPOS", key, ...members], {
605
+ deserialize: (result) => transform(result),
606
+ ...opts
607
+ });
608
+ }
609
+ };
610
+ function transform(result) {
611
+ const final = [];
612
+ for (const pos of result) {
613
+ if (!pos?.[0] || !pos?.[1]) {
614
+ continue;
615
+ }
616
+ final.push({ lng: Number.parseFloat(pos[0]), lat: Number.parseFloat(pos[1]) });
617
+ }
618
+ return final;
619
+ }
620
+
621
+ // pkg/commands/geo_search.ts
622
+ var GeoSearchCommand = class extends Command {
623
+ constructor([key, centerPoint, shape, order, opts], commandOptions) {
624
+ const command = ["GEOSEARCH", key];
625
+ if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
626
+ command.push(centerPoint.type, centerPoint.member);
627
+ }
628
+ if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
629
+ command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
630
+ }
631
+ if (shape.type === "BYRADIUS" || shape.type === "byradius") {
632
+ command.push(shape.type, shape.radius, shape.radiusType);
633
+ }
634
+ if (shape.type === "BYBOX" || shape.type === "bybox") {
635
+ command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
636
+ }
637
+ command.push(order);
638
+ if (opts?.count) {
639
+ command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
640
+ }
641
+ const transform2 = (result) => {
642
+ if (!opts?.withCoord && !opts?.withDist && !opts?.withHash) {
643
+ return result.map((member) => {
644
+ try {
645
+ return { member: JSON.parse(member) };
646
+ } catch {
647
+ return { member };
648
+ }
649
+ });
650
+ }
651
+ return result.map((members) => {
652
+ let counter = 1;
653
+ const obj = {};
654
+ try {
655
+ obj.member = JSON.parse(members[0]);
656
+ } catch {
657
+ obj.member = members[0];
658
+ }
659
+ if (opts.withDist) {
660
+ obj.dist = Number.parseFloat(members[counter++]);
661
+ }
662
+ if (opts.withHash) {
663
+ obj.hash = members[counter++].toString();
664
+ }
665
+ if (opts.withCoord) {
666
+ obj.coord = {
667
+ long: Number.parseFloat(members[counter][0]),
668
+ lat: Number.parseFloat(members[counter][1])
669
+ };
670
+ }
671
+ return obj;
672
+ });
673
+ };
674
+ super(
675
+ [
676
+ ...command,
677
+ ...opts?.withCoord ? ["WITHCOORD"] : [],
678
+ ...opts?.withDist ? ["WITHDIST"] : [],
679
+ ...opts?.withHash ? ["WITHHASH"] : []
680
+ ],
681
+ {
682
+ deserialize: transform2,
683
+ ...commandOptions
684
+ }
685
+ );
686
+ }
687
+ };
688
+
689
+ // pkg/commands/geo_search_store.ts
690
+ var GeoSearchStoreCommand = class extends Command {
691
+ constructor([destination, key, centerPoint, shape, order, opts], commandOptions) {
692
+ const command = ["GEOSEARCHSTORE", destination, key];
693
+ if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
694
+ command.push(centerPoint.type, centerPoint.member);
695
+ }
696
+ if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
697
+ command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
698
+ }
699
+ if (shape.type === "BYRADIUS" || shape.type === "byradius") {
700
+ command.push(shape.type, shape.radius, shape.radiusType);
701
+ }
702
+ if (shape.type === "BYBOX" || shape.type === "bybox") {
703
+ command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
704
+ }
705
+ command.push(order);
706
+ if (opts?.count) {
707
+ command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
708
+ }
709
+ super([...command, ...opts?.storeDist ? ["STOREDIST"] : []], commandOptions);
710
+ }
711
+ };
712
+
713
+ // pkg/commands/get.ts
714
+ var GetCommand = class extends Command {
715
+ constructor(cmd, opts) {
716
+ super(["get", ...cmd], opts);
717
+ }
718
+ };
719
+
720
+ // pkg/commands/getbit.ts
721
+ var GetBitCommand = class extends Command {
722
+ constructor(cmd, opts) {
723
+ super(["getbit", ...cmd], opts);
724
+ }
725
+ };
726
+
727
+ // pkg/commands/getdel.ts
728
+ var GetDelCommand = class extends Command {
729
+ constructor(cmd, opts) {
730
+ super(["getdel", ...cmd], opts);
731
+ }
732
+ };
733
+
734
+ // pkg/commands/getrange.ts
735
+ var GetRangeCommand = class extends Command {
736
+ constructor(cmd, opts) {
737
+ super(["getrange", ...cmd], opts);
738
+ }
739
+ };
740
+
741
+ // pkg/commands/getset.ts
742
+ var GetSetCommand = class extends Command {
743
+ constructor(cmd, opts) {
744
+ super(["getset", ...cmd], opts);
745
+ }
746
+ };
747
+
748
+ // pkg/commands/hdel.ts
749
+ var HDelCommand = class extends Command {
750
+ constructor(cmd, opts) {
751
+ super(["hdel", ...cmd], opts);
752
+ }
753
+ };
754
+
755
+ // pkg/commands/hexists.ts
756
+ var HExistsCommand = class extends Command {
757
+ constructor(cmd, opts) {
758
+ super(["hexists", ...cmd], opts);
759
+ }
760
+ };
761
+
762
+ // pkg/commands/hget.ts
763
+ var HGetCommand = class extends Command {
764
+ constructor(cmd, opts) {
765
+ super(["hget", ...cmd], opts);
766
+ }
767
+ };
768
+
769
+ // pkg/commands/hgetall.ts
770
+ function deserialize(result) {
771
+ if (result.length === 0) {
772
+ return null;
773
+ }
774
+ const obj = {};
775
+ while (result.length >= 2) {
776
+ const key = result.shift();
777
+ const value = result.shift();
778
+ try {
779
+ const valueIsNumberAndNotSafeInteger = !Number.isNaN(Number(value)) && !Number.isSafeInteger(Number(value));
780
+ obj[key] = valueIsNumberAndNotSafeInteger ? value : JSON.parse(value);
781
+ } catch {
782
+ obj[key] = value;
783
+ }
784
+ }
785
+ return obj;
786
+ }
787
+ var HGetAllCommand = class extends Command {
788
+ constructor(cmd, opts) {
789
+ super(["hgetall", ...cmd], {
790
+ deserialize: (result) => deserialize(result),
791
+ ...opts
792
+ });
793
+ }
794
+ };
795
+
796
+ // pkg/commands/hincrby.ts
797
+ var HIncrByCommand = class extends Command {
798
+ constructor(cmd, opts) {
799
+ super(["hincrby", ...cmd], opts);
800
+ }
801
+ };
802
+
803
+ // pkg/commands/hincrbyfloat.ts
804
+ var HIncrByFloatCommand = class extends Command {
805
+ constructor(cmd, opts) {
806
+ super(["hincrbyfloat", ...cmd], opts);
807
+ }
808
+ };
809
+
810
+ // pkg/commands/hkeys.ts
811
+ var HKeysCommand = class extends Command {
812
+ constructor([key], opts) {
813
+ super(["hkeys", key], opts);
814
+ }
815
+ };
816
+
817
+ // pkg/commands/hlen.ts
818
+ var HLenCommand = class extends Command {
819
+ constructor(cmd, opts) {
820
+ super(["hlen", ...cmd], opts);
821
+ }
822
+ };
823
+
824
+ // pkg/commands/hmget.ts
825
+ function deserialize2(fields, result) {
826
+ if (result.every((field) => field === null)) {
827
+ return null;
828
+ }
829
+ const obj = {};
830
+ for (const [i, field] of fields.entries()) {
831
+ try {
832
+ obj[field] = JSON.parse(result[i]);
833
+ } catch {
834
+ obj[field] = result[i];
835
+ }
836
+ }
837
+ return obj;
838
+ }
839
+ var HMGetCommand = class extends Command {
840
+ constructor([key, ...fields], opts) {
841
+ super(["hmget", key, ...fields], {
842
+ deserialize: (result) => deserialize2(fields, result),
843
+ ...opts
844
+ });
845
+ }
846
+ };
847
+
848
+ // pkg/commands/hmset.ts
849
+ var HMSetCommand = class extends Command {
850
+ constructor([key, kv], opts) {
851
+ super(["hmset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
852
+ }
853
+ };
854
+
855
+ // pkg/commands/hrandfield.ts
856
+ function deserialize3(result) {
857
+ if (result.length === 0) {
858
+ return null;
859
+ }
860
+ const obj = {};
861
+ while (result.length >= 2) {
862
+ const key = result.shift();
863
+ const value = result.shift();
864
+ try {
865
+ obj[key] = JSON.parse(value);
866
+ } catch {
867
+ obj[key] = value;
868
+ }
869
+ }
870
+ return obj;
871
+ }
872
+ var HRandFieldCommand = class extends Command {
873
+ constructor(cmd, opts) {
874
+ const command = ["hrandfield", cmd[0]];
875
+ if (typeof cmd[1] === "number") {
876
+ command.push(cmd[1]);
877
+ }
878
+ if (cmd[2]) {
879
+ command.push("WITHVALUES");
880
+ }
881
+ super(command, {
882
+ // @ts-expect-error to silence compiler
883
+ deserialize: cmd[2] ? (result) => deserialize3(result) : opts?.deserialize,
884
+ ...opts
885
+ });
886
+ }
887
+ };
888
+
889
+ // pkg/commands/hscan.ts
890
+ var HScanCommand = class extends Command {
891
+ constructor([key, cursor, cmdOpts], opts) {
892
+ const command = ["hscan", key, cursor];
893
+ if (cmdOpts?.match) {
894
+ command.push("match", cmdOpts.match);
895
+ }
896
+ if (typeof cmdOpts?.count === "number") {
897
+ command.push("count", cmdOpts.count);
898
+ }
899
+ super(command, {
900
+ deserialize: deserializeScanResponse,
901
+ ...opts
902
+ });
903
+ }
904
+ };
905
+
906
+ // pkg/commands/hset.ts
907
+ var HSetCommand = class extends Command {
908
+ constructor([key, kv], opts) {
909
+ super(["hset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
910
+ }
911
+ };
912
+
913
+ // pkg/commands/hsetnx.ts
914
+ var HSetNXCommand = class extends Command {
915
+ constructor(cmd, opts) {
916
+ super(["hsetnx", ...cmd], opts);
917
+ }
918
+ };
919
+
920
+ // pkg/commands/hstrlen.ts
921
+ var HStrLenCommand = class extends Command {
922
+ constructor(cmd, opts) {
923
+ super(["hstrlen", ...cmd], opts);
924
+ }
925
+ };
926
+
927
+ // pkg/commands/hvals.ts
928
+ var HValsCommand = class extends Command {
929
+ constructor(cmd, opts) {
930
+ super(["hvals", ...cmd], opts);
931
+ }
932
+ };
933
+
934
+ // pkg/commands/incr.ts
935
+ var IncrCommand = class extends Command {
936
+ constructor(cmd, opts) {
937
+ super(["incr", ...cmd], opts);
938
+ }
939
+ };
940
+
941
+ // pkg/commands/incrby.ts
942
+ var IncrByCommand = class extends Command {
943
+ constructor(cmd, opts) {
944
+ super(["incrby", ...cmd], opts);
945
+ }
946
+ };
947
+
948
+ // pkg/commands/incrbyfloat.ts
949
+ var IncrByFloatCommand = class extends Command {
950
+ constructor(cmd, opts) {
951
+ super(["incrbyfloat", ...cmd], opts);
952
+ }
953
+ };
954
+
955
+ // pkg/commands/json_arrappend.ts
956
+ var JsonArrAppendCommand = class extends Command {
957
+ constructor(cmd, opts) {
958
+ super(["JSON.ARRAPPEND", ...cmd], opts);
959
+ }
960
+ };
961
+
962
+ // pkg/commands/json_arrindex.ts
963
+ var JsonArrIndexCommand = class extends Command {
964
+ constructor(cmd, opts) {
965
+ super(["JSON.ARRINDEX", ...cmd], opts);
966
+ }
967
+ };
968
+
969
+ // pkg/commands/json_arrinsert.ts
970
+ var JsonArrInsertCommand = class extends Command {
971
+ constructor(cmd, opts) {
972
+ super(["JSON.ARRINSERT", ...cmd], opts);
973
+ }
974
+ };
975
+
976
+ // pkg/commands/json_arrlen.ts
977
+ var JsonArrLenCommand = class extends Command {
978
+ constructor(cmd, opts) {
979
+ super(["JSON.ARRLEN", cmd[0], cmd[1] ?? "$"], opts);
980
+ }
981
+ };
982
+
983
+ // pkg/commands/json_arrpop.ts
984
+ var JsonArrPopCommand = class extends Command {
985
+ constructor(cmd, opts) {
986
+ super(["JSON.ARRPOP", ...cmd], opts);
987
+ }
988
+ };
989
+
990
+ // pkg/commands/json_arrtrim.ts
991
+ var JsonArrTrimCommand = class extends Command {
992
+ constructor(cmd, opts) {
993
+ const path = cmd[1] ?? "$";
994
+ const start = cmd[2] ?? 0;
995
+ const stop = cmd[3] ?? 0;
996
+ super(["JSON.ARRTRIM", cmd[0], path, start, stop], opts);
997
+ }
998
+ };
999
+
1000
+ // pkg/commands/json_clear.ts
1001
+ var JsonClearCommand = class extends Command {
1002
+ constructor(cmd, opts) {
1003
+ super(["JSON.CLEAR", ...cmd], opts);
1004
+ }
1005
+ };
1006
+
1007
+ // pkg/commands/json_del.ts
1008
+ var JsonDelCommand = class extends Command {
1009
+ constructor(cmd, opts) {
1010
+ super(["JSON.DEL", ...cmd], opts);
1011
+ }
1012
+ };
1013
+
1014
+ // pkg/commands/json_forget.ts
1015
+ var JsonForgetCommand = class extends Command {
1016
+ constructor(cmd, opts) {
1017
+ super(["JSON.FORGET", ...cmd], opts);
1018
+ }
1019
+ };
1020
+
1021
+ // pkg/commands/json_get.ts
1022
+ var JsonGetCommand = class extends Command {
1023
+ constructor(cmd, opts) {
1024
+ const command = ["JSON.GET"];
1025
+ if (typeof cmd[1] === "string") {
1026
+ command.push(...cmd);
1027
+ } else {
1028
+ command.push(cmd[0]);
1029
+ if (cmd[1]) {
1030
+ if (cmd[1].indent) {
1031
+ command.push("INDENT", cmd[1].indent);
1032
+ }
1033
+ if (cmd[1].newline) {
1034
+ command.push("NEWLINE", cmd[1].newline);
1035
+ }
1036
+ if (cmd[1].space) {
1037
+ command.push("SPACE", cmd[1].space);
1038
+ }
1039
+ }
1040
+ command.push(...cmd.slice(2));
1041
+ }
1042
+ super(command, opts);
1043
+ }
1044
+ };
1045
+
1046
+ // pkg/commands/json_mget.ts
1047
+ var JsonMGetCommand = class extends Command {
1048
+ constructor(cmd, opts) {
1049
+ super(["JSON.MGET", ...cmd[0], cmd[1]], opts);
1050
+ }
1051
+ };
1052
+
1053
+ // pkg/commands/json_mset.ts
1054
+ var JsonMSetCommand = class extends Command {
1055
+ constructor(cmd, opts) {
1056
+ const command = ["JSON.MSET"];
1057
+ for (const c of cmd) {
1058
+ command.push(c.key, c.path, c.value);
1059
+ }
1060
+ super(command, opts);
1061
+ }
1062
+ };
1063
+
1064
+ // pkg/commands/json_numincrby.ts
1065
+ var JsonNumIncrByCommand = class extends Command {
1066
+ constructor(cmd, opts) {
1067
+ super(["JSON.NUMINCRBY", ...cmd], opts);
1068
+ }
1069
+ };
1070
+
1071
+ // pkg/commands/json_nummultby.ts
1072
+ var JsonNumMultByCommand = class extends Command {
1073
+ constructor(cmd, opts) {
1074
+ super(["JSON.NUMMULTBY", ...cmd], opts);
1075
+ }
1076
+ };
1077
+
1078
+ // pkg/commands/json_objkeys.ts
1079
+ var JsonObjKeysCommand = class extends Command {
1080
+ constructor(cmd, opts) {
1081
+ super(["JSON.OBJKEYS", ...cmd], opts);
1082
+ }
1083
+ };
1084
+
1085
+ // pkg/commands/json_objlen.ts
1086
+ var JsonObjLenCommand = class extends Command {
1087
+ constructor(cmd, opts) {
1088
+ super(["JSON.OBJLEN", ...cmd], opts);
1089
+ }
1090
+ };
1091
+
1092
+ // pkg/commands/json_resp.ts
1093
+ var JsonRespCommand = class extends Command {
1094
+ constructor(cmd, opts) {
1095
+ super(["JSON.RESP", ...cmd], opts);
1096
+ }
1097
+ };
1098
+
1099
+ // pkg/commands/json_set.ts
1100
+ var JsonSetCommand = class extends Command {
1101
+ constructor(cmd, opts) {
1102
+ const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]];
1103
+ if (cmd[3]) {
1104
+ if (cmd[3].nx) {
1105
+ command.push("NX");
1106
+ } else if (cmd[3].xx) {
1107
+ command.push("XX");
1108
+ }
1109
+ }
1110
+ super(command, opts);
1111
+ }
1112
+ };
1113
+
1114
+ // pkg/commands/json_strappend.ts
1115
+ var JsonStrAppendCommand = class extends Command {
1116
+ constructor(cmd, opts) {
1117
+ super(["JSON.STRAPPEND", ...cmd], opts);
1118
+ }
1119
+ };
1120
+
1121
+ // pkg/commands/json_strlen.ts
1122
+ var JsonStrLenCommand = class extends Command {
1123
+ constructor(cmd, opts) {
1124
+ super(["JSON.STRLEN", ...cmd], opts);
1125
+ }
1126
+ };
1127
+
1128
+ // pkg/commands/json_toggle.ts
1129
+ var JsonToggleCommand = class extends Command {
1130
+ constructor(cmd, opts) {
1131
+ super(["JSON.TOGGLE", ...cmd], opts);
1132
+ }
1133
+ };
1134
+
1135
+ // pkg/commands/json_type.ts
1136
+ var JsonTypeCommand = class extends Command {
1137
+ constructor(cmd, opts) {
1138
+ super(["JSON.TYPE", ...cmd], opts);
1139
+ }
1140
+ };
1141
+
1142
+ // pkg/commands/keys.ts
1143
+ var KeysCommand = class extends Command {
1144
+ constructor(cmd, opts) {
1145
+ super(["keys", ...cmd], opts);
1146
+ }
1147
+ };
1148
+
1149
+ // pkg/commands/lindex.ts
1150
+ var LIndexCommand = class extends Command {
1151
+ constructor(cmd, opts) {
1152
+ super(["lindex", ...cmd], opts);
1153
+ }
1154
+ };
1155
+
1156
+ // pkg/commands/linsert.ts
1157
+ var LInsertCommand = class extends Command {
1158
+ constructor(cmd, opts) {
1159
+ super(["linsert", ...cmd], opts);
1160
+ }
1161
+ };
1162
+
1163
+ // pkg/commands/llen.ts
1164
+ var LLenCommand = class extends Command {
1165
+ constructor(cmd, opts) {
1166
+ super(["llen", ...cmd], opts);
1167
+ }
1168
+ };
1169
+
1170
+ // pkg/commands/lmove.ts
1171
+ var LMoveCommand = class extends Command {
1172
+ constructor(cmd, opts) {
1173
+ super(["lmove", ...cmd], opts);
1174
+ }
1175
+ };
1176
+
1177
+ // pkg/commands/lmpop.ts
1178
+ var LmPopCommand = class extends Command {
1179
+ constructor(cmd, opts) {
1180
+ const [numkeys, keys, direction, count] = cmd;
1181
+ super(["LMPOP", numkeys, ...keys, direction, ...count ? ["COUNT", count] : []], opts);
1182
+ }
1183
+ };
1184
+
1185
+ // pkg/commands/lpop.ts
1186
+ var LPopCommand = class extends Command {
1187
+ constructor(cmd, opts) {
1188
+ super(["lpop", ...cmd], opts);
1189
+ }
1190
+ };
1191
+
1192
+ // pkg/commands/lpos.ts
1193
+ var LPosCommand = class extends Command {
1194
+ constructor(cmd, opts) {
1195
+ const args = ["lpos", cmd[0], cmd[1]];
1196
+ if (typeof cmd[2]?.rank === "number") {
1197
+ args.push("rank", cmd[2].rank);
1198
+ }
1199
+ if (typeof cmd[2]?.count === "number") {
1200
+ args.push("count", cmd[2].count);
1201
+ }
1202
+ if (typeof cmd[2]?.maxLen === "number") {
1203
+ args.push("maxLen", cmd[2].maxLen);
1204
+ }
1205
+ super(args, opts);
1206
+ }
1207
+ };
1208
+
1209
+ // pkg/commands/lpush.ts
1210
+ var LPushCommand = class extends Command {
1211
+ constructor(cmd, opts) {
1212
+ super(["lpush", ...cmd], opts);
1213
+ }
1214
+ };
1215
+
1216
+ // pkg/commands/lpushx.ts
1217
+ var LPushXCommand = class extends Command {
1218
+ constructor(cmd, opts) {
1219
+ super(["lpushx", ...cmd], opts);
1220
+ }
1221
+ };
1222
+
1223
+ // pkg/commands/lrange.ts
1224
+ var LRangeCommand = class extends Command {
1225
+ constructor(cmd, opts) {
1226
+ super(["lrange", ...cmd], opts);
1227
+ }
1228
+ };
1229
+
1230
+ // pkg/commands/lrem.ts
1231
+ var LRemCommand = class extends Command {
1232
+ constructor(cmd, opts) {
1233
+ super(["lrem", ...cmd], opts);
1234
+ }
1235
+ };
1236
+
1237
+ // pkg/commands/lset.ts
1238
+ var LSetCommand = class extends Command {
1239
+ constructor(cmd, opts) {
1240
+ super(["lset", ...cmd], opts);
1241
+ }
1242
+ };
1243
+
1244
+ // pkg/commands/ltrim.ts
1245
+ var LTrimCommand = class extends Command {
1246
+ constructor(cmd, opts) {
1247
+ super(["ltrim", ...cmd], opts);
1248
+ }
1249
+ };
1250
+
1251
+ // pkg/commands/mget.ts
1252
+ var MGetCommand = class extends Command {
1253
+ constructor(cmd, opts) {
1254
+ const keys = Array.isArray(cmd[0]) ? cmd[0] : cmd;
1255
+ super(["mget", ...keys], opts);
1256
+ }
1257
+ };
1258
+
1259
+ // pkg/commands/mset.ts
1260
+ var MSetCommand = class extends Command {
1261
+ constructor([kv], opts) {
1262
+ super(["mset", ...Object.entries(kv).flatMap(([key, value]) => [key, value])], opts);
1263
+ }
1264
+ };
1265
+
1266
+ // pkg/commands/msetnx.ts
1267
+ var MSetNXCommand = class extends Command {
1268
+ constructor([kv], opts) {
1269
+ super(["msetnx", ...Object.entries(kv).flat()], opts);
1270
+ }
1271
+ };
1272
+
1273
+ // pkg/commands/persist.ts
1274
+ var PersistCommand = class extends Command {
1275
+ constructor(cmd, opts) {
1276
+ super(["persist", ...cmd], opts);
1277
+ }
1278
+ };
1279
+
1280
+ // pkg/commands/pexpire.ts
1281
+ var PExpireCommand = class extends Command {
1282
+ constructor(cmd, opts) {
1283
+ super(["pexpire", ...cmd], opts);
1284
+ }
1285
+ };
1286
+
1287
+ // pkg/commands/pexpireat.ts
1288
+ var PExpireAtCommand = class extends Command {
1289
+ constructor(cmd, opts) {
1290
+ super(["pexpireat", ...cmd], opts);
1291
+ }
1292
+ };
1293
+
1294
+ // pkg/commands/pfadd.ts
1295
+ var PfAddCommand = class extends Command {
1296
+ constructor(cmd, opts) {
1297
+ super(["pfadd", ...cmd], opts);
1298
+ }
1299
+ };
1300
+
1301
+ // pkg/commands/pfcount.ts
1302
+ var PfCountCommand = class extends Command {
1303
+ constructor(cmd, opts) {
1304
+ super(["pfcount", ...cmd], opts);
1305
+ }
1306
+ };
1307
+
1308
+ // pkg/commands/pfmerge.ts
1309
+ var PfMergeCommand = class extends Command {
1310
+ constructor(cmd, opts) {
1311
+ super(["pfmerge", ...cmd], opts);
1312
+ }
1313
+ };
1314
+
1315
+ // pkg/commands/ping.ts
1316
+ var PingCommand = class extends Command {
1317
+ constructor(cmd, opts) {
1318
+ const command = ["ping"];
1319
+ if (cmd?.[0] !== void 0) {
1320
+ command.push(cmd[0]);
1321
+ }
1322
+ super(command, opts);
1323
+ }
1324
+ };
1325
+
1326
+ // pkg/commands/psetex.ts
1327
+ var PSetEXCommand = class extends Command {
1328
+ constructor(cmd, opts) {
1329
+ super(["psetex", ...cmd], opts);
1330
+ }
1331
+ };
1332
+
1333
+ // pkg/commands/pttl.ts
1334
+ var PTtlCommand = class extends Command {
1335
+ constructor(cmd, opts) {
1336
+ super(["pttl", ...cmd], opts);
1337
+ }
1338
+ };
1339
+
1340
+ // pkg/commands/publish.ts
1341
+ var PublishCommand = class extends Command {
1342
+ constructor(cmd, opts) {
1343
+ super(["publish", ...cmd], opts);
1344
+ }
1345
+ };
1346
+
1347
+ // pkg/commands/randomkey.ts
1348
+ var RandomKeyCommand = class extends Command {
1349
+ constructor(opts) {
1350
+ super(["randomkey"], opts);
1351
+ }
1352
+ };
1353
+
1354
+ // pkg/commands/rename.ts
1355
+ var RenameCommand = class extends Command {
1356
+ constructor(cmd, opts) {
1357
+ super(["rename", ...cmd], opts);
1358
+ }
1359
+ };
1360
+
1361
+ // pkg/commands/renamenx.ts
1362
+ var RenameNXCommand = class extends Command {
1363
+ constructor(cmd, opts) {
1364
+ super(["renamenx", ...cmd], opts);
1365
+ }
1366
+ };
1367
+
1368
+ // pkg/commands/rpop.ts
1369
+ var RPopCommand = class extends Command {
1370
+ constructor(cmd, opts) {
1371
+ super(["rpop", ...cmd], opts);
1372
+ }
1373
+ };
1374
+
1375
+ // pkg/commands/rpush.ts
1376
+ var RPushCommand = class extends Command {
1377
+ constructor(cmd, opts) {
1378
+ super(["rpush", ...cmd], opts);
1379
+ }
1380
+ };
1381
+
1382
+ // pkg/commands/rpushx.ts
1383
+ var RPushXCommand = class extends Command {
1384
+ constructor(cmd, opts) {
1385
+ super(["rpushx", ...cmd], opts);
1386
+ }
1387
+ };
1388
+
1389
+ // pkg/commands/sadd.ts
1390
+ var SAddCommand = class extends Command {
1391
+ constructor(cmd, opts) {
1392
+ super(["sadd", ...cmd], opts);
1393
+ }
1394
+ };
1395
+
1396
+ // pkg/commands/scan.ts
1397
+ var ScanCommand = class extends Command {
1398
+ constructor([cursor, opts], cmdOpts) {
1399
+ const command = ["scan", cursor];
1400
+ if (opts?.match) {
1401
+ command.push("match", opts.match);
1402
+ }
1403
+ if (typeof opts?.count === "number") {
1404
+ command.push("count", opts.count);
1405
+ }
1406
+ if (opts?.type && opts.type.length > 0) {
1407
+ command.push("type", opts.type);
1408
+ }
1409
+ super(command, {
1410
+ deserialize: deserializeScanResponse,
1411
+ ...cmdOpts
1412
+ });
1413
+ }
1414
+ };
1415
+
1416
+ // pkg/commands/scard.ts
1417
+ var SCardCommand = class extends Command {
1418
+ constructor(cmd, opts) {
1419
+ super(["scard", ...cmd], opts);
1420
+ }
1421
+ };
1422
+
1423
+ // pkg/commands/script_exists.ts
1424
+ var ScriptExistsCommand = class extends Command {
1425
+ constructor(hashes, opts) {
1426
+ super(["script", "exists", ...hashes], {
1427
+ deserialize: (result) => result,
1428
+ ...opts
1429
+ });
1430
+ }
1431
+ };
1432
+
1433
+ // pkg/commands/script_flush.ts
1434
+ var ScriptFlushCommand = class extends Command {
1435
+ constructor([opts], cmdOpts) {
1436
+ const cmd = ["script", "flush"];
1437
+ if (opts?.sync) {
1438
+ cmd.push("sync");
1439
+ } else if (opts?.async) {
1440
+ cmd.push("async");
1441
+ }
1442
+ super(cmd, cmdOpts);
1443
+ }
1444
+ };
1445
+
1446
+ // pkg/commands/script_load.ts
1447
+ var ScriptLoadCommand = class extends Command {
1448
+ constructor(args, opts) {
1449
+ super(["script", "load", ...args], opts);
1450
+ }
1451
+ };
1452
+
1453
+ // pkg/commands/sdiff.ts
1454
+ var SDiffCommand = class extends Command {
1455
+ constructor(cmd, opts) {
1456
+ super(["sdiff", ...cmd], opts);
1457
+ }
1458
+ };
1459
+
1460
+ // pkg/commands/sdiffstore.ts
1461
+ var SDiffStoreCommand = class extends Command {
1462
+ constructor(cmd, opts) {
1463
+ super(["sdiffstore", ...cmd], opts);
1464
+ }
1465
+ };
1466
+
1467
+ // pkg/commands/set.ts
1468
+ var SetCommand = class extends Command {
1469
+ constructor([key, value, opts], cmdOpts) {
1470
+ const command = ["set", key, value];
1471
+ if (opts) {
1472
+ if ("nx" in opts && opts.nx) {
1473
+ command.push("nx");
1474
+ } else if ("xx" in opts && opts.xx) {
1475
+ command.push("xx");
1476
+ }
1477
+ if ("get" in opts && opts.get) {
1478
+ command.push("get");
1479
+ }
1480
+ if ("ex" in opts && typeof opts.ex === "number") {
1481
+ command.push("ex", opts.ex);
1482
+ } else if ("px" in opts && typeof opts.px === "number") {
1483
+ command.push("px", opts.px);
1484
+ } else if ("exat" in opts && typeof opts.exat === "number") {
1485
+ command.push("exat", opts.exat);
1486
+ } else if ("pxat" in opts && typeof opts.pxat === "number") {
1487
+ command.push("pxat", opts.pxat);
1488
+ } else if ("keepTtl" in opts && opts.keepTtl) {
1489
+ command.push("keepTtl");
1490
+ }
1491
+ }
1492
+ super(command, cmdOpts);
1493
+ }
1494
+ };
1495
+
1496
+ // pkg/commands/setbit.ts
1497
+ var SetBitCommand = class extends Command {
1498
+ constructor(cmd, opts) {
1499
+ super(["setbit", ...cmd], opts);
1500
+ }
1501
+ };
1502
+
1503
+ // pkg/commands/setex.ts
1504
+ var SetExCommand = class extends Command {
1505
+ constructor(cmd, opts) {
1506
+ super(["setex", ...cmd], opts);
1507
+ }
1508
+ };
1509
+
1510
+ // pkg/commands/setnx.ts
1511
+ var SetNxCommand = class extends Command {
1512
+ constructor(cmd, opts) {
1513
+ super(["setnx", ...cmd], opts);
1514
+ }
1515
+ };
1516
+
1517
+ // pkg/commands/setrange.ts
1518
+ var SetRangeCommand = class extends Command {
1519
+ constructor(cmd, opts) {
1520
+ super(["setrange", ...cmd], opts);
1521
+ }
1522
+ };
1523
+
1524
+ // pkg/commands/sinter.ts
1525
+ var SInterCommand = class extends Command {
1526
+ constructor(cmd, opts) {
1527
+ super(["sinter", ...cmd], opts);
1528
+ }
1529
+ };
1530
+
1531
+ // pkg/commands/sinterstore.ts
1532
+ var SInterStoreCommand = class extends Command {
1533
+ constructor(cmd, opts) {
1534
+ super(["sinterstore", ...cmd], opts);
1535
+ }
1536
+ };
1537
+
1538
+ // pkg/commands/sismember.ts
1539
+ var SIsMemberCommand = class extends Command {
1540
+ constructor(cmd, opts) {
1541
+ super(["sismember", ...cmd], opts);
1542
+ }
1543
+ };
1544
+
1545
+ // pkg/commands/smembers.ts
1546
+ var SMembersCommand = class extends Command {
1547
+ constructor(cmd, opts) {
1548
+ super(["smembers", ...cmd], opts);
1549
+ }
1550
+ };
1551
+
1552
+ // pkg/commands/smismember.ts
1553
+ var SMIsMemberCommand = class extends Command {
1554
+ constructor(cmd, opts) {
1555
+ super(["smismember", cmd[0], ...cmd[1]], opts);
1556
+ }
1557
+ };
1558
+
1559
+ // pkg/commands/smove.ts
1560
+ var SMoveCommand = class extends Command {
1561
+ constructor(cmd, opts) {
1562
+ super(["smove", ...cmd], opts);
1563
+ }
1564
+ };
1565
+
1566
+ // pkg/commands/spop.ts
1567
+ var SPopCommand = class extends Command {
1568
+ constructor([key, count], opts) {
1569
+ const command = ["spop", key];
1570
+ if (typeof count === "number") {
1571
+ command.push(count);
1572
+ }
1573
+ super(command, opts);
1574
+ }
1575
+ };
1576
+
1577
+ // pkg/commands/srandmember.ts
1578
+ var SRandMemberCommand = class extends Command {
1579
+ constructor([key, count], opts) {
1580
+ const command = ["srandmember", key];
1581
+ if (typeof count === "number") {
1582
+ command.push(count);
1583
+ }
1584
+ super(command, opts);
1585
+ }
1586
+ };
1587
+
1588
+ // pkg/commands/srem.ts
1589
+ var SRemCommand = class extends Command {
1590
+ constructor(cmd, opts) {
1591
+ super(["srem", ...cmd], opts);
1592
+ }
1593
+ };
1594
+
1595
+ // pkg/commands/sscan.ts
1596
+ var SScanCommand = class extends Command {
1597
+ constructor([key, cursor, opts], cmdOpts) {
1598
+ const command = ["sscan", key, cursor];
1599
+ if (opts?.match) {
1600
+ command.push("match", opts.match);
1601
+ }
1602
+ if (typeof opts?.count === "number") {
1603
+ command.push("count", opts.count);
1604
+ }
1605
+ super(command, {
1606
+ deserialize: deserializeScanResponse,
1607
+ ...cmdOpts
1608
+ });
1609
+ }
1610
+ };
1611
+
1612
+ // pkg/commands/strlen.ts
1613
+ var StrLenCommand = class extends Command {
1614
+ constructor(cmd, opts) {
1615
+ super(["strlen", ...cmd], opts);
1616
+ }
1617
+ };
1618
+
1619
+ // pkg/commands/sunion.ts
1620
+ var SUnionCommand = class extends Command {
1621
+ constructor(cmd, opts) {
1622
+ super(["sunion", ...cmd], opts);
1623
+ }
1624
+ };
1625
+
1626
+ // pkg/commands/sunionstore.ts
1627
+ var SUnionStoreCommand = class extends Command {
1628
+ constructor(cmd, opts) {
1629
+ super(["sunionstore", ...cmd], opts);
1630
+ }
1631
+ };
1632
+
1633
+ // pkg/commands/time.ts
1634
+ var TimeCommand = class extends Command {
1635
+ constructor(opts) {
1636
+ super(["time"], opts);
1637
+ }
1638
+ };
1639
+
1640
+ // pkg/commands/touch.ts
1641
+ var TouchCommand = class extends Command {
1642
+ constructor(cmd, opts) {
1643
+ super(["touch", ...cmd], opts);
1644
+ }
1645
+ };
1646
+
1647
+ // pkg/commands/ttl.ts
1648
+ var TtlCommand = class extends Command {
1649
+ constructor(cmd, opts) {
1650
+ super(["ttl", ...cmd], opts);
1651
+ }
1652
+ };
1653
+
1654
+ // pkg/commands/type.ts
1655
+ var TypeCommand = class extends Command {
1656
+ constructor(cmd, opts) {
1657
+ super(["type", ...cmd], opts);
1658
+ }
1659
+ };
1660
+
1661
+ // pkg/commands/unlink.ts
1662
+ var UnlinkCommand = class extends Command {
1663
+ constructor(cmd, opts) {
1664
+ super(["unlink", ...cmd], opts);
1665
+ }
1666
+ };
1667
+
1668
+ // pkg/commands/xack.ts
1669
+ var XAckCommand = class extends Command {
1670
+ constructor([key, group, id], opts) {
1671
+ const ids = Array.isArray(id) ? [...id] : [id];
1672
+ super(["XACK", key, group, ...ids], opts);
1673
+ }
1674
+ };
1675
+
1676
+ // pkg/commands/xadd.ts
1677
+ var XAddCommand = class extends Command {
1678
+ constructor([key, id, entries, opts], commandOptions) {
1679
+ const command = ["XADD", key];
1680
+ if (opts) {
1681
+ if (opts.nomkStream) {
1682
+ command.push("NOMKSTREAM");
1683
+ }
1684
+ if (opts.trim) {
1685
+ command.push(opts.trim.type, opts.trim.comparison, opts.trim.threshold);
1686
+ if (opts.trim.limit !== void 0) {
1687
+ command.push("LIMIT", opts.trim.limit);
1688
+ }
1689
+ }
1690
+ }
1691
+ command.push(id);
1692
+ for (const [k, v] of Object.entries(entries)) {
1693
+ command.push(k, v);
1694
+ }
1695
+ super(command, commandOptions);
1696
+ }
1697
+ };
1698
+
1699
+ // pkg/commands/xautoclaim.ts
1700
+ var XAutoClaim = class extends Command {
1701
+ constructor([key, group, consumer, minIdleTime, start, options], opts) {
1702
+ const commands = [];
1703
+ if (options?.count) {
1704
+ commands.push("COUNT", options.count);
1705
+ }
1706
+ if (options?.justId) {
1707
+ commands.push("JUSTID");
1708
+ }
1709
+ super(["XAUTOCLAIM", key, group, consumer, minIdleTime, start, ...commands], opts);
1710
+ }
1711
+ };
1712
+
1713
+ // pkg/commands/xclaim.ts
1714
+ var XClaimCommand = class extends Command {
1715
+ constructor([key, group, consumer, minIdleTime, id, options], opts) {
1716
+ const ids = Array.isArray(id) ? [...id] : [id];
1717
+ const commands = [];
1718
+ if (options?.idleMS) {
1719
+ commands.push("IDLE", options.idleMS);
1720
+ }
1721
+ if (options?.idleMS) {
1722
+ commands.push("TIME", options.timeMS);
1723
+ }
1724
+ if (options?.retryCount) {
1725
+ commands.push("RETRYCOUNT", options.retryCount);
1726
+ }
1727
+ if (options?.force) {
1728
+ commands.push("FORCE");
1729
+ }
1730
+ if (options?.justId) {
1731
+ commands.push("JUSTID");
1732
+ }
1733
+ if (options?.lastId) {
1734
+ commands.push("LASTID", options.lastId);
1735
+ }
1736
+ super(["XCLAIM", key, group, consumer, minIdleTime, ...ids, ...commands], opts);
1737
+ }
1738
+ };
1739
+
1740
+ // pkg/commands/xdel.ts
1741
+ var XDelCommand = class extends Command {
1742
+ constructor([key, ids], opts) {
1743
+ const cmds = Array.isArray(ids) ? [...ids] : [ids];
1744
+ super(["XDEL", key, ...cmds], opts);
1745
+ }
1746
+ };
1747
+
1748
+ // pkg/commands/xgroup.ts
1749
+ var XGroupCommand = class extends Command {
1750
+ constructor([key, opts], commandOptions) {
1751
+ const command = ["XGROUP"];
1752
+ switch (opts.type) {
1753
+ case "CREATE": {
1754
+ command.push("CREATE", key, opts.group, opts.id);
1755
+ if (opts.options) {
1756
+ if (opts.options.MKSTREAM) {
1757
+ command.push("MKSTREAM");
1758
+ }
1759
+ if (opts.options.ENTRIESREAD !== void 0) {
1760
+ command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
1761
+ }
1762
+ }
1763
+ break;
1764
+ }
1765
+ case "CREATECONSUMER": {
1766
+ command.push("CREATECONSUMER", key, opts.group, opts.consumer);
1767
+ break;
1768
+ }
1769
+ case "DELCONSUMER": {
1770
+ command.push("DELCONSUMER", key, opts.group, opts.consumer);
1771
+ break;
1772
+ }
1773
+ case "DESTROY": {
1774
+ command.push("DESTROY", key, opts.group);
1775
+ break;
1776
+ }
1777
+ case "SETID": {
1778
+ command.push("SETID", key, opts.group, opts.id);
1779
+ if (opts.options?.ENTRIESREAD !== void 0) {
1780
+ command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
1781
+ }
1782
+ break;
1783
+ }
1784
+ default: {
1785
+ throw new Error("Invalid XGROUP");
1786
+ }
1787
+ }
1788
+ super(command, commandOptions);
1789
+ }
1790
+ };
1791
+
1792
+ // pkg/commands/xinfo.ts
1793
+ var XInfoCommand = class extends Command {
1794
+ constructor([key, options], opts) {
1795
+ const cmds = [];
1796
+ if (options.type === "CONSUMERS") {
1797
+ cmds.push("CONSUMERS", key, options.group);
1798
+ } else {
1799
+ cmds.push("GROUPS", key);
1800
+ }
1801
+ super(["XINFO", ...cmds], opts);
1802
+ }
1803
+ };
1804
+
1805
+ // pkg/commands/xlen.ts
1806
+ var XLenCommand = class extends Command {
1807
+ constructor(cmd, opts) {
1808
+ super(["XLEN", ...cmd], opts);
1809
+ }
1810
+ };
1811
+
1812
+ // pkg/commands/xpending.ts
1813
+ var XPendingCommand = class extends Command {
1814
+ constructor([key, group, start, end, count, options], opts) {
1815
+ const consumers = options?.consumer === void 0 ? [] : Array.isArray(options.consumer) ? [...options.consumer] : [options.consumer];
1816
+ super(
1817
+ [
1818
+ "XPENDING",
1819
+ key,
1820
+ group,
1821
+ ...options?.idleTime ? ["IDLE", options.idleTime] : [],
1822
+ start,
1823
+ end,
1824
+ count,
1825
+ ...consumers
1826
+ ],
1827
+ opts
1828
+ );
1829
+ }
1830
+ };
1831
+
1832
+ // pkg/commands/xrange.ts
1833
+ function deserialize4(result) {
1834
+ const obj = {};
1835
+ for (const e of result) {
1836
+ while (e.length >= 2) {
1837
+ const streamId = e.shift();
1838
+ const entries = e.shift();
1839
+ if (!(streamId in obj)) {
1840
+ obj[streamId] = {};
1841
+ }
1842
+ while (entries.length >= 2) {
1843
+ const field = entries.shift();
1844
+ const value = entries.shift();
1845
+ try {
1846
+ obj[streamId][field] = JSON.parse(value);
1847
+ } catch {
1848
+ obj[streamId][field] = value;
1849
+ }
1850
+ }
1851
+ }
1852
+ }
1853
+ return obj;
1854
+ }
1855
+ var XRangeCommand = class extends Command {
1856
+ constructor([key, start, end, count], opts) {
1857
+ const command = ["XRANGE", key, start, end];
1858
+ if (typeof count === "number") {
1859
+ command.push("COUNT", count);
1860
+ }
1861
+ super(command, {
1862
+ deserialize: (result) => deserialize4(result),
1863
+ ...opts
1864
+ });
1865
+ }
1866
+ };
1867
+
1868
+ // pkg/commands/xread.ts
1869
+ var UNBALANCED_XREAD_ERR = "ERR Unbalanced XREAD list of streams: for each stream key an ID or '$' must be specified";
1870
+ var XReadCommand = class extends Command {
1871
+ constructor([key, id, options], opts) {
1872
+ if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
1873
+ throw new Error(UNBALANCED_XREAD_ERR);
1874
+ }
1875
+ const commands = [];
1876
+ if (typeof options?.count === "number") {
1877
+ commands.push("COUNT", options.count);
1878
+ }
1879
+ if (typeof options?.blockMS === "number") {
1880
+ commands.push("BLOCK", options.blockMS);
1881
+ }
1882
+ commands.push(
1883
+ "STREAMS",
1884
+ ...Array.isArray(key) ? [...key] : [key],
1885
+ ...Array.isArray(id) ? [...id] : [id]
1886
+ );
1887
+ super(["XREAD", ...commands], opts);
1888
+ }
1889
+ };
1890
+
1891
+ // pkg/commands/xreadgroup.ts
1892
+ var UNBALANCED_XREADGROUP_ERR = "ERR Unbalanced XREADGROUP list of streams: for each stream key an ID or '$' must be specified";
1893
+ var XReadGroupCommand = class extends Command {
1894
+ constructor([group, consumer, key, id, options], opts) {
1895
+ if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
1896
+ throw new Error(UNBALANCED_XREADGROUP_ERR);
1897
+ }
1898
+ const commands = [];
1899
+ if (typeof options?.count === "number") {
1900
+ commands.push("COUNT", options.count);
1901
+ }
1902
+ if (typeof options?.blockMS === "number") {
1903
+ commands.push("BLOCK", options.blockMS);
1904
+ }
1905
+ if (typeof options?.NOACK === "boolean" && options.NOACK) {
1906
+ commands.push("NOACK");
1907
+ }
1908
+ commands.push(
1909
+ "STREAMS",
1910
+ ...Array.isArray(key) ? [...key] : [key],
1911
+ ...Array.isArray(id) ? [...id] : [id]
1912
+ );
1913
+ super(["XREADGROUP", "GROUP", group, consumer, ...commands], opts);
1914
+ }
1915
+ };
1916
+
1917
+ // pkg/commands/xrevrange.ts
1918
+ var XRevRangeCommand = class extends Command {
1919
+ constructor([key, end, start, count], opts) {
1920
+ const command = ["XREVRANGE", key, end, start];
1921
+ if (typeof count === "number") {
1922
+ command.push("COUNT", count);
1923
+ }
1924
+ super(command, {
1925
+ deserialize: (result) => deserialize5(result),
1926
+ ...opts
1927
+ });
1928
+ }
1929
+ };
1930
+ function deserialize5(result) {
1931
+ const obj = {};
1932
+ for (const e of result) {
1933
+ while (e.length >= 2) {
1934
+ const streamId = e.shift();
1935
+ const entries = e.shift();
1936
+ if (!(streamId in obj)) {
1937
+ obj[streamId] = {};
1938
+ }
1939
+ while (entries.length >= 2) {
1940
+ const field = entries.shift();
1941
+ const value = entries.shift();
1942
+ try {
1943
+ obj[streamId][field] = JSON.parse(value);
1944
+ } catch {
1945
+ obj[streamId][field] = value;
1946
+ }
1947
+ }
1948
+ }
1949
+ }
1950
+ return obj;
1951
+ }
1952
+
1953
+ // pkg/commands/xtrim.ts
1954
+ var XTrimCommand = class extends Command {
1955
+ constructor([key, options], opts) {
1956
+ const { limit, strategy, threshold, exactness = "~" } = options;
1957
+ super(["XTRIM", key, strategy, exactness, threshold, ...limit ? ["LIMIT", limit] : []], opts);
1958
+ }
1959
+ };
1960
+
1961
+ // pkg/commands/zadd.ts
1962
+ var ZAddCommand = class extends Command {
1963
+ constructor([key, arg1, ...arg2], opts) {
1964
+ const command = ["zadd", key];
1965
+ if ("nx" in arg1 && arg1.nx) {
1966
+ command.push("nx");
1967
+ } else if ("xx" in arg1 && arg1.xx) {
1968
+ command.push("xx");
1969
+ }
1970
+ if ("ch" in arg1 && arg1.ch) {
1971
+ command.push("ch");
1972
+ }
1973
+ if ("incr" in arg1 && arg1.incr) {
1974
+ command.push("incr");
1975
+ }
1976
+ if ("lt" in arg1 && arg1.lt) {
1977
+ command.push("lt");
1978
+ } else if ("gt" in arg1 && arg1.gt) {
1979
+ command.push("gt");
1980
+ }
1981
+ if ("score" in arg1 && "member" in arg1) {
1982
+ command.push(arg1.score, arg1.member);
1983
+ }
1984
+ command.push(...arg2.flatMap(({ score, member }) => [score, member]));
1985
+ super(command, opts);
1986
+ }
1987
+ };
1988
+
1989
+ // pkg/commands/zcard.ts
1990
+ var ZCardCommand = class extends Command {
1991
+ constructor(cmd, opts) {
1992
+ super(["zcard", ...cmd], opts);
1993
+ }
1994
+ };
1995
+
1996
+ // pkg/commands/zcount.ts
1997
+ var ZCountCommand = class extends Command {
1998
+ constructor(cmd, opts) {
1999
+ super(["zcount", ...cmd], opts);
2000
+ }
2001
+ };
2002
+
2003
+ // pkg/commands/zincrby.ts
2004
+ var ZIncrByCommand = class extends Command {
2005
+ constructor(cmd, opts) {
2006
+ super(["zincrby", ...cmd], opts);
2007
+ }
2008
+ };
2009
+
2010
+ // pkg/commands/zinterstore.ts
2011
+ var ZInterStoreCommand = class extends Command {
2012
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
2013
+ const command = ["zinterstore", destination, numKeys];
2014
+ if (Array.isArray(keyOrKeys)) {
2015
+ command.push(...keyOrKeys);
2016
+ } else {
2017
+ command.push(keyOrKeys);
2018
+ }
2019
+ if (opts) {
2020
+ if ("weights" in opts && opts.weights) {
2021
+ command.push("weights", ...opts.weights);
2022
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2023
+ command.push("weights", opts.weight);
2024
+ }
2025
+ if ("aggregate" in opts) {
2026
+ command.push("aggregate", opts.aggregate);
2027
+ }
2028
+ }
2029
+ super(command, cmdOpts);
2030
+ }
2031
+ };
2032
+
2033
+ // pkg/commands/zlexcount.ts
2034
+ var ZLexCountCommand = class extends Command {
2035
+ constructor(cmd, opts) {
2036
+ super(["zlexcount", ...cmd], opts);
2037
+ }
2038
+ };
2039
+
2040
+ // pkg/commands/zpopmax.ts
2041
+ var ZPopMaxCommand = class extends Command {
2042
+ constructor([key, count], opts) {
2043
+ const command = ["zpopmax", key];
2044
+ if (typeof count === "number") {
2045
+ command.push(count);
2046
+ }
2047
+ super(command, opts);
2048
+ }
2049
+ };
2050
+
2051
+ // pkg/commands/zpopmin.ts
2052
+ var ZPopMinCommand = class extends Command {
2053
+ constructor([key, count], opts) {
2054
+ const command = ["zpopmin", key];
2055
+ if (typeof count === "number") {
2056
+ command.push(count);
2057
+ }
2058
+ super(command, opts);
2059
+ }
2060
+ };
2061
+
2062
+ // pkg/commands/zrange.ts
2063
+ var ZRangeCommand = class extends Command {
2064
+ constructor([key, min, max, opts], cmdOpts) {
2065
+ const command = ["zrange", key, min, max];
2066
+ if (opts?.byScore) {
2067
+ command.push("byscore");
2068
+ }
2069
+ if (opts?.byLex) {
2070
+ command.push("bylex");
2071
+ }
2072
+ if (opts?.rev) {
2073
+ command.push("rev");
2074
+ }
2075
+ if (opts?.count !== void 0 && opts.offset !== void 0) {
2076
+ command.push("limit", opts.offset, opts.count);
2077
+ }
2078
+ if (opts?.withScores) {
2079
+ command.push("withscores");
2080
+ }
2081
+ super(command, cmdOpts);
2082
+ }
2083
+ };
2084
+
2085
+ // pkg/commands/zrank.ts
2086
+ var ZRankCommand = class extends Command {
2087
+ constructor(cmd, opts) {
2088
+ super(["zrank", ...cmd], opts);
2089
+ }
2090
+ };
2091
+
2092
+ // pkg/commands/zrem.ts
2093
+ var ZRemCommand = class extends Command {
2094
+ constructor(cmd, opts) {
2095
+ super(["zrem", ...cmd], opts);
2096
+ }
2097
+ };
2098
+
2099
+ // pkg/commands/zremrangebylex.ts
2100
+ var ZRemRangeByLexCommand = class extends Command {
2101
+ constructor(cmd, opts) {
2102
+ super(["zremrangebylex", ...cmd], opts);
2103
+ }
2104
+ };
2105
+
2106
+ // pkg/commands/zremrangebyrank.ts
2107
+ var ZRemRangeByRankCommand = class extends Command {
2108
+ constructor(cmd, opts) {
2109
+ super(["zremrangebyrank", ...cmd], opts);
2110
+ }
2111
+ };
2112
+
2113
+ // pkg/commands/zremrangebyscore.ts
2114
+ var ZRemRangeByScoreCommand = class extends Command {
2115
+ constructor(cmd, opts) {
2116
+ super(["zremrangebyscore", ...cmd], opts);
2117
+ }
2118
+ };
2119
+
2120
+ // pkg/commands/zrevrank.ts
2121
+ var ZRevRankCommand = class extends Command {
2122
+ constructor(cmd, opts) {
2123
+ super(["zrevrank", ...cmd], opts);
2124
+ }
2125
+ };
2126
+
2127
+ // pkg/commands/zscan.ts
2128
+ var ZScanCommand = class extends Command {
2129
+ constructor([key, cursor, opts], cmdOpts) {
2130
+ const command = ["zscan", key, cursor];
2131
+ if (opts?.match) {
2132
+ command.push("match", opts.match);
2133
+ }
2134
+ if (typeof opts?.count === "number") {
2135
+ command.push("count", opts.count);
2136
+ }
2137
+ super(command, {
2138
+ deserialize: deserializeScanResponse,
2139
+ ...cmdOpts
2140
+ });
2141
+ }
2142
+ };
2143
+
2144
+ // pkg/commands/zscore.ts
2145
+ var ZScoreCommand = class extends Command {
2146
+ constructor(cmd, opts) {
2147
+ super(["zscore", ...cmd], opts);
2148
+ }
2149
+ };
2150
+
2151
+ // pkg/commands/zunion.ts
2152
+ var ZUnionCommand = class extends Command {
2153
+ constructor([numKeys, keyOrKeys, opts], cmdOpts) {
2154
+ const command = ["zunion", numKeys];
2155
+ if (Array.isArray(keyOrKeys)) {
2156
+ command.push(...keyOrKeys);
2157
+ } else {
2158
+ command.push(keyOrKeys);
2159
+ }
2160
+ if (opts) {
2161
+ if ("weights" in opts && opts.weights) {
2162
+ command.push("weights", ...opts.weights);
2163
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2164
+ command.push("weights", opts.weight);
2165
+ }
2166
+ if ("aggregate" in opts) {
2167
+ command.push("aggregate", opts.aggregate);
2168
+ }
2169
+ if (opts.withScores) {
2170
+ command.push("withscores");
2171
+ }
2172
+ }
2173
+ super(command, cmdOpts);
2174
+ }
2175
+ };
2176
+
2177
+ // pkg/commands/zunionstore.ts
2178
+ var ZUnionStoreCommand = class extends Command {
2179
+ constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
2180
+ const command = ["zunionstore", destination, numKeys];
2181
+ if (Array.isArray(keyOrKeys)) {
2182
+ command.push(...keyOrKeys);
2183
+ } else {
2184
+ command.push(keyOrKeys);
2185
+ }
2186
+ if (opts) {
2187
+ if ("weights" in opts && opts.weights) {
2188
+ command.push("weights", ...opts.weights);
2189
+ } else if ("weight" in opts && typeof opts.weight === "number") {
2190
+ command.push("weights", opts.weight);
2191
+ }
2192
+ if ("aggregate" in opts) {
2193
+ command.push("aggregate", opts.aggregate);
2194
+ }
2195
+ }
2196
+ super(command, cmdOpts);
2197
+ }
2198
+ };
2199
+
2200
+ // pkg/commands/zdiffstore.ts
2201
+ var ZDiffStoreCommand = class extends Command {
2202
+ constructor(cmd, opts) {
2203
+ super(["zdiffstore", ...cmd], opts);
2204
+ }
2205
+ };
2206
+
2207
+ // pkg/commands/zmscore.ts
2208
+ var ZMScoreCommand = class extends Command {
2209
+ constructor(cmd, opts) {
2210
+ const [key, members] = cmd;
2211
+ super(["zmscore", key, ...members], opts);
2212
+ }
2213
+ };
2214
+
2215
+ // pkg/pipeline.ts
2216
+ var Pipeline = class {
2217
+ client;
2218
+ commands;
2219
+ commandOptions;
2220
+ multiExec;
2221
+ constructor(opts) {
2222
+ this.client = opts.client;
2223
+ this.commands = [];
2224
+ this.commandOptions = opts.commandOptions;
2225
+ this.multiExec = opts.multiExec ?? false;
2226
+ if (this.commandOptions?.latencyLogging) {
2227
+ const originalExec = this.exec.bind(this);
2228
+ this.exec = async (options) => {
2229
+ const start = performance.now();
2230
+ const result = await (options ? originalExec(options) : originalExec());
2231
+ const end = performance.now();
2232
+ const loggerResult = (end - start).toFixed(2);
2233
+ console.log(
2234
+ `Latency for \x1B[38;2;19;185;39m${this.multiExec ? ["MULTI-EXEC"] : ["PIPELINE"].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
2235
+ );
2236
+ return result;
2237
+ };
2238
+ }
2239
+ }
2240
+ exec = async (options) => {
2241
+ if (this.commands.length === 0) {
2242
+ throw new Error("Pipeline is empty");
2243
+ }
2244
+ const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
2245
+ const res = await this.client.request({
2246
+ path,
2247
+ body: Object.values(this.commands).map((c) => c.command)
2248
+ });
2249
+ return options?.keepErrors ? res.map(({ error, result }, i) => {
2250
+ return {
2251
+ error,
2252
+ result: this.commands[i].deserialize(result)
2253
+ };
2254
+ }) : res.map(({ error, result }, i) => {
2255
+ if (error) {
2256
+ throw new UpstashError(
2257
+ `Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
2258
+ );
2259
+ }
2260
+ return this.commands[i].deserialize(result);
2261
+ });
2262
+ };
2263
+ /**
2264
+ * Returns the length of pipeline before the execution
2265
+ */
2266
+ length() {
2267
+ return this.commands.length;
2268
+ }
2269
+ /**
2270
+ * Pushes a command into the pipeline and returns a chainable instance of the
2271
+ * pipeline
2272
+ */
2273
+ chain(command) {
2274
+ this.commands.push(command);
2275
+ return this;
2276
+ }
2277
+ /**
2278
+ * @see https://redis.io/commands/append
2279
+ */
2280
+ append = (...args) => this.chain(new AppendCommand(args, this.commandOptions));
2281
+ /**
2282
+ * @see https://redis.io/commands/bitcount
2283
+ */
2284
+ bitcount = (...args) => this.chain(new BitCountCommand(args, this.commandOptions));
2285
+ /**
2286
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
2287
+ *
2288
+ * @example
2289
+ * ```typescript
2290
+ * redis.set("mykey", 0);
2291
+ * const result = await redis.pipeline()
2292
+ * .bitfield("mykey")
2293
+ * .set("u4", 0, 16)
2294
+ * .incr("u4", "#1", 1)
2295
+ * .exec();
2296
+ * console.log(result); // [[0, 1]]
2297
+ * ```
2298
+ *
2299
+ * @see https://redis.io/commands/bitfield
2300
+ */
2301
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.commandOptions, this.chain.bind(this));
2302
+ /**
2303
+ * @see https://redis.io/commands/bitop
2304
+ */
2305
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => this.chain(
2306
+ new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.commandOptions)
2307
+ );
2308
+ /**
2309
+ * @see https://redis.io/commands/bitpos
2310
+ */
2311
+ bitpos = (...args) => this.chain(new BitPosCommand(args, this.commandOptions));
2312
+ /**
2313
+ * @see https://redis.io/commands/copy
2314
+ */
2315
+ copy = (...args) => this.chain(new CopyCommand(args, this.commandOptions));
2316
+ /**
2317
+ * @see https://redis.io/commands/zdiffstore
2318
+ */
2319
+ zdiffstore = (...args) => this.chain(new ZDiffStoreCommand(args, this.commandOptions));
2320
+ /**
2321
+ * @see https://redis.io/commands/dbsize
2322
+ */
2323
+ dbsize = () => this.chain(new DBSizeCommand(this.commandOptions));
2324
+ /**
2325
+ * @see https://redis.io/commands/decr
2326
+ */
2327
+ decr = (...args) => this.chain(new DecrCommand(args, this.commandOptions));
2328
+ /**
2329
+ * @see https://redis.io/commands/decrby
2330
+ */
2331
+ decrby = (...args) => this.chain(new DecrByCommand(args, this.commandOptions));
2332
+ /**
2333
+ * @see https://redis.io/commands/del
2334
+ */
2335
+ del = (...args) => this.chain(new DelCommand(args, this.commandOptions));
2336
+ /**
2337
+ * @see https://redis.io/commands/echo
2338
+ */
2339
+ echo = (...args) => this.chain(new EchoCommand(args, this.commandOptions));
2340
+ /**
2341
+ * @see https://redis.io/commands/eval
2342
+ */
2343
+ eval = (...args) => this.chain(new EvalCommand(args, this.commandOptions));
2344
+ /**
2345
+ * @see https://redis.io/commands/evalsha
2346
+ */
2347
+ evalsha = (...args) => this.chain(new EvalshaCommand(args, this.commandOptions));
2348
+ /**
2349
+ * @see https://redis.io/commands/exists
2350
+ */
2351
+ exists = (...args) => this.chain(new ExistsCommand(args, this.commandOptions));
2352
+ /**
2353
+ * @see https://redis.io/commands/expire
2354
+ */
2355
+ expire = (...args) => this.chain(new ExpireCommand(args, this.commandOptions));
2356
+ /**
2357
+ * @see https://redis.io/commands/expireat
2358
+ */
2359
+ expireat = (...args) => this.chain(new ExpireAtCommand(args, this.commandOptions));
2360
+ /**
2361
+ * @see https://redis.io/commands/flushall
2362
+ */
2363
+ flushall = (args) => this.chain(new FlushAllCommand(args, this.commandOptions));
2364
+ /**
2365
+ * @see https://redis.io/commands/flushdb
2366
+ */
2367
+ flushdb = (...args) => this.chain(new FlushDBCommand(args, this.commandOptions));
2368
+ /**
2369
+ * @see https://redis.io/commands/geoadd
2370
+ */
2371
+ geoadd = (...args) => this.chain(new GeoAddCommand(args, this.commandOptions));
2372
+ /**
2373
+ * @see https://redis.io/commands/geodist
2374
+ */
2375
+ geodist = (...args) => this.chain(new GeoDistCommand(args, this.commandOptions));
2376
+ /**
2377
+ * @see https://redis.io/commands/geopos
2378
+ */
2379
+ geopos = (...args) => this.chain(new GeoPosCommand(args, this.commandOptions));
2380
+ /**
2381
+ * @see https://redis.io/commands/geohash
2382
+ */
2383
+ geohash = (...args) => this.chain(new GeoHashCommand(args, this.commandOptions));
2384
+ /**
2385
+ * @see https://redis.io/commands/geosearch
2386
+ */
2387
+ geosearch = (...args) => this.chain(new GeoSearchCommand(args, this.commandOptions));
2388
+ /**
2389
+ * @see https://redis.io/commands/geosearchstore
2390
+ */
2391
+ geosearchstore = (...args) => this.chain(new GeoSearchStoreCommand(args, this.commandOptions));
2392
+ /**
2393
+ * @see https://redis.io/commands/get
2394
+ */
2395
+ get = (...args) => this.chain(new GetCommand(args, this.commandOptions));
2396
+ /**
2397
+ * @see https://redis.io/commands/getbit
2398
+ */
2399
+ getbit = (...args) => this.chain(new GetBitCommand(args, this.commandOptions));
2400
+ /**
2401
+ * @see https://redis.io/commands/getdel
2402
+ */
2403
+ getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
2404
+ /**
2405
+ * @see https://redis.io/commands/getrange
2406
+ */
2407
+ getrange = (...args) => this.chain(new GetRangeCommand(args, this.commandOptions));
2408
+ /**
2409
+ * @see https://redis.io/commands/getset
2410
+ */
2411
+ getset = (key, value) => this.chain(new GetSetCommand([key, value], this.commandOptions));
2412
+ /**
2413
+ * @see https://redis.io/commands/hdel
2414
+ */
2415
+ hdel = (...args) => this.chain(new HDelCommand(args, this.commandOptions));
2416
+ /**
2417
+ * @see https://redis.io/commands/hexists
2418
+ */
2419
+ hexists = (...args) => this.chain(new HExistsCommand(args, this.commandOptions));
2420
+ /**
2421
+ * @see https://redis.io/commands/hget
2422
+ */
2423
+ hget = (...args) => this.chain(new HGetCommand(args, this.commandOptions));
2424
+ /**
2425
+ * @see https://redis.io/commands/hgetall
2426
+ */
2427
+ hgetall = (...args) => this.chain(new HGetAllCommand(args, this.commandOptions));
2428
+ /**
2429
+ * @see https://redis.io/commands/hincrby
2430
+ */
2431
+ hincrby = (...args) => this.chain(new HIncrByCommand(args, this.commandOptions));
2432
+ /**
2433
+ * @see https://redis.io/commands/hincrbyfloat
2434
+ */
2435
+ hincrbyfloat = (...args) => this.chain(new HIncrByFloatCommand(args, this.commandOptions));
2436
+ /**
2437
+ * @see https://redis.io/commands/hkeys
2438
+ */
2439
+ hkeys = (...args) => this.chain(new HKeysCommand(args, this.commandOptions));
2440
+ /**
2441
+ * @see https://redis.io/commands/hlen
2442
+ */
2443
+ hlen = (...args) => this.chain(new HLenCommand(args, this.commandOptions));
2444
+ /**
2445
+ * @see https://redis.io/commands/hmget
2446
+ */
2447
+ hmget = (...args) => this.chain(new HMGetCommand(args, this.commandOptions));
2448
+ /**
2449
+ * @see https://redis.io/commands/hmset
2450
+ */
2451
+ hmset = (key, kv) => this.chain(new HMSetCommand([key, kv], this.commandOptions));
2452
+ /**
2453
+ * @see https://redis.io/commands/hrandfield
2454
+ */
2455
+ hrandfield = (key, count, withValues) => this.chain(new HRandFieldCommand([key, count, withValues], this.commandOptions));
2456
+ /**
2457
+ * @see https://redis.io/commands/hscan
2458
+ */
2459
+ hscan = (...args) => this.chain(new HScanCommand(args, this.commandOptions));
2460
+ /**
2461
+ * @see https://redis.io/commands/hset
2462
+ */
2463
+ hset = (key, kv) => this.chain(new HSetCommand([key, kv], this.commandOptions));
2464
+ /**
2465
+ * @see https://redis.io/commands/hsetnx
2466
+ */
2467
+ hsetnx = (key, field, value) => this.chain(new HSetNXCommand([key, field, value], this.commandOptions));
2468
+ /**
2469
+ * @see https://redis.io/commands/hstrlen
2470
+ */
2471
+ hstrlen = (...args) => this.chain(new HStrLenCommand(args, this.commandOptions));
2472
+ /**
2473
+ * @see https://redis.io/commands/hvals
2474
+ */
2475
+ hvals = (...args) => this.chain(new HValsCommand(args, this.commandOptions));
2476
+ /**
2477
+ * @see https://redis.io/commands/incr
2478
+ */
2479
+ incr = (...args) => this.chain(new IncrCommand(args, this.commandOptions));
2480
+ /**
2481
+ * @see https://redis.io/commands/incrby
2482
+ */
2483
+ incrby = (...args) => this.chain(new IncrByCommand(args, this.commandOptions));
2484
+ /**
2485
+ * @see https://redis.io/commands/incrbyfloat
2486
+ */
2487
+ incrbyfloat = (...args) => this.chain(new IncrByFloatCommand(args, this.commandOptions));
2488
+ /**
2489
+ * @see https://redis.io/commands/keys
2490
+ */
2491
+ keys = (...args) => this.chain(new KeysCommand(args, this.commandOptions));
2492
+ /**
2493
+ * @see https://redis.io/commands/lindex
2494
+ */
2495
+ lindex = (...args) => this.chain(new LIndexCommand(args, this.commandOptions));
2496
+ /**
2497
+ * @see https://redis.io/commands/linsert
2498
+ */
2499
+ linsert = (key, direction, pivot, value) => this.chain(new LInsertCommand([key, direction, pivot, value], this.commandOptions));
2500
+ /**
2501
+ * @see https://redis.io/commands/llen
2502
+ */
2503
+ llen = (...args) => this.chain(new LLenCommand(args, this.commandOptions));
2504
+ /**
2505
+ * @see https://redis.io/commands/lmove
2506
+ */
2507
+ lmove = (...args) => this.chain(new LMoveCommand(args, this.commandOptions));
2508
+ /**
2509
+ * @see https://redis.io/commands/lpop
2510
+ */
2511
+ lpop = (...args) => this.chain(new LPopCommand(args, this.commandOptions));
2512
+ /**
2513
+ * @see https://redis.io/commands/lmpop
2514
+ */
2515
+ lmpop = (...args) => this.chain(new LmPopCommand(args, this.commandOptions));
2516
+ /**
2517
+ * @see https://redis.io/commands/lpos
2518
+ */
2519
+ lpos = (...args) => this.chain(new LPosCommand(args, this.commandOptions));
2520
+ /**
2521
+ * @see https://redis.io/commands/lpush
2522
+ */
2523
+ lpush = (key, ...elements) => this.chain(new LPushCommand([key, ...elements], this.commandOptions));
2524
+ /**
2525
+ * @see https://redis.io/commands/lpushx
2526
+ */
2527
+ lpushx = (key, ...elements) => this.chain(new LPushXCommand([key, ...elements], this.commandOptions));
2528
+ /**
2529
+ * @see https://redis.io/commands/lrange
2530
+ */
2531
+ lrange = (...args) => this.chain(new LRangeCommand(args, this.commandOptions));
2532
+ /**
2533
+ * @see https://redis.io/commands/lrem
2534
+ */
2535
+ lrem = (key, count, value) => this.chain(new LRemCommand([key, count, value], this.commandOptions));
2536
+ /**
2537
+ * @see https://redis.io/commands/lset
2538
+ */
2539
+ lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
2540
+ /**
2541
+ * @see https://redis.io/commands/ltrim
2542
+ */
2543
+ ltrim = (...args) => this.chain(new LTrimCommand(args, this.commandOptions));
2544
+ /**
2545
+ * @see https://redis.io/commands/mget
2546
+ */
2547
+ mget = (...args) => this.chain(new MGetCommand(args, this.commandOptions));
2548
+ /**
2549
+ * @see https://redis.io/commands/mset
2550
+ */
2551
+ mset = (kv) => this.chain(new MSetCommand([kv], this.commandOptions));
2552
+ /**
2553
+ * @see https://redis.io/commands/msetnx
2554
+ */
2555
+ msetnx = (kv) => this.chain(new MSetNXCommand([kv], this.commandOptions));
2556
+ /**
2557
+ * @see https://redis.io/commands/persist
2558
+ */
2559
+ persist = (...args) => this.chain(new PersistCommand(args, this.commandOptions));
2560
+ /**
2561
+ * @see https://redis.io/commands/pexpire
2562
+ */
2563
+ pexpire = (...args) => this.chain(new PExpireCommand(args, this.commandOptions));
2564
+ /**
2565
+ * @see https://redis.io/commands/pexpireat
2566
+ */
2567
+ pexpireat = (...args) => this.chain(new PExpireAtCommand(args, this.commandOptions));
2568
+ /**
2569
+ * @see https://redis.io/commands/pfadd
2570
+ */
2571
+ pfadd = (...args) => this.chain(new PfAddCommand(args, this.commandOptions));
2572
+ /**
2573
+ * @see https://redis.io/commands/pfcount
2574
+ */
2575
+ pfcount = (...args) => this.chain(new PfCountCommand(args, this.commandOptions));
2576
+ /**
2577
+ * @see https://redis.io/commands/pfmerge
2578
+ */
2579
+ pfmerge = (...args) => this.chain(new PfMergeCommand(args, this.commandOptions));
2580
+ /**
2581
+ * @see https://redis.io/commands/ping
2582
+ */
2583
+ ping = (args) => this.chain(new PingCommand(args, this.commandOptions));
2584
+ /**
2585
+ * @see https://redis.io/commands/psetex
2586
+ */
2587
+ psetex = (key, ttl, value) => this.chain(new PSetEXCommand([key, ttl, value], this.commandOptions));
2588
+ /**
2589
+ * @see https://redis.io/commands/pttl
2590
+ */
2591
+ pttl = (...args) => this.chain(new PTtlCommand(args, this.commandOptions));
2592
+ /**
2593
+ * @see https://redis.io/commands/publish
2594
+ */
2595
+ publish = (...args) => this.chain(new PublishCommand(args, this.commandOptions));
2596
+ /**
2597
+ * @see https://redis.io/commands/randomkey
2598
+ */
2599
+ randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions));
2600
+ /**
2601
+ * @see https://redis.io/commands/rename
2602
+ */
2603
+ rename = (...args) => this.chain(new RenameCommand(args, this.commandOptions));
2604
+ /**
2605
+ * @see https://redis.io/commands/renamenx
2606
+ */
2607
+ renamenx = (...args) => this.chain(new RenameNXCommand(args, this.commandOptions));
2608
+ /**
2609
+ * @see https://redis.io/commands/rpop
2610
+ */
2611
+ rpop = (...args) => this.chain(new RPopCommand(args, this.commandOptions));
2612
+ /**
2613
+ * @see https://redis.io/commands/rpush
2614
+ */
2615
+ rpush = (key, ...elements) => this.chain(new RPushCommand([key, ...elements], this.commandOptions));
2616
+ /**
2617
+ * @see https://redis.io/commands/rpushx
2618
+ */
2619
+ rpushx = (key, ...elements) => this.chain(new RPushXCommand([key, ...elements], this.commandOptions));
2620
+ /**
2621
+ * @see https://redis.io/commands/sadd
2622
+ */
2623
+ sadd = (key, member, ...members) => this.chain(new SAddCommand([key, member, ...members], this.commandOptions));
2624
+ /**
2625
+ * @see https://redis.io/commands/scan
2626
+ */
2627
+ scan = (...args) => this.chain(new ScanCommand(args, this.commandOptions));
2628
+ /**
2629
+ * @see https://redis.io/commands/scard
2630
+ */
2631
+ scard = (...args) => this.chain(new SCardCommand(args, this.commandOptions));
2632
+ /**
2633
+ * @see https://redis.io/commands/script-exists
2634
+ */
2635
+ scriptExists = (...args) => this.chain(new ScriptExistsCommand(args, this.commandOptions));
2636
+ /**
2637
+ * @see https://redis.io/commands/script-flush
2638
+ */
2639
+ scriptFlush = (...args) => this.chain(new ScriptFlushCommand(args, this.commandOptions));
2640
+ /**
2641
+ * @see https://redis.io/commands/script-load
2642
+ */
2643
+ scriptLoad = (...args) => this.chain(new ScriptLoadCommand(args, this.commandOptions));
2644
+ /*)*
2645
+ * @see https://redis.io/commands/sdiff
2646
+ */
2647
+ sdiff = (...args) => this.chain(new SDiffCommand(args, this.commandOptions));
2648
+ /**
2649
+ * @see https://redis.io/commands/sdiffstore
2650
+ */
2651
+ sdiffstore = (...args) => this.chain(new SDiffStoreCommand(args, this.commandOptions));
2652
+ /**
2653
+ * @see https://redis.io/commands/set
2654
+ */
2655
+ set = (key, value, opts) => this.chain(new SetCommand([key, value, opts], this.commandOptions));
2656
+ /**
2657
+ * @see https://redis.io/commands/setbit
2658
+ */
2659
+ setbit = (...args) => this.chain(new SetBitCommand(args, this.commandOptions));
2660
+ /**
2661
+ * @see https://redis.io/commands/setex
2662
+ */
2663
+ setex = (key, ttl, value) => this.chain(new SetExCommand([key, ttl, value], this.commandOptions));
2664
+ /**
2665
+ * @see https://redis.io/commands/setnx
2666
+ */
2667
+ setnx = (key, value) => this.chain(new SetNxCommand([key, value], this.commandOptions));
2668
+ /**
2669
+ * @see https://redis.io/commands/setrange
2670
+ */
2671
+ setrange = (...args) => this.chain(new SetRangeCommand(args, this.commandOptions));
2672
+ /**
2673
+ * @see https://redis.io/commands/sinter
2674
+ */
2675
+ sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
2676
+ /**
2677
+ * @see https://redis.io/commands/sinterstore
2678
+ */
2679
+ sinterstore = (...args) => this.chain(new SInterStoreCommand(args, this.commandOptions));
2680
+ /**
2681
+ * @see https://redis.io/commands/sismember
2682
+ */
2683
+ sismember = (key, member) => this.chain(new SIsMemberCommand([key, member], this.commandOptions));
2684
+ /**
2685
+ * @see https://redis.io/commands/smembers
2686
+ */
2687
+ smembers = (...args) => this.chain(new SMembersCommand(args, this.commandOptions));
2688
+ /**
2689
+ * @see https://redis.io/commands/smismember
2690
+ */
2691
+ smismember = (key, members) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions));
2692
+ /**
2693
+ * @see https://redis.io/commands/smove
2694
+ */
2695
+ smove = (source, destination, member) => this.chain(new SMoveCommand([source, destination, member], this.commandOptions));
2696
+ /**
2697
+ * @see https://redis.io/commands/spop
2698
+ */
2699
+ spop = (...args) => this.chain(new SPopCommand(args, this.commandOptions));
2700
+ /**
2701
+ * @see https://redis.io/commands/srandmember
2702
+ */
2703
+ srandmember = (...args) => this.chain(new SRandMemberCommand(args, this.commandOptions));
2704
+ /**
2705
+ * @see https://redis.io/commands/srem
2706
+ */
2707
+ srem = (key, ...members) => this.chain(new SRemCommand([key, ...members], this.commandOptions));
2708
+ /**
2709
+ * @see https://redis.io/commands/sscan
2710
+ */
2711
+ sscan = (...args) => this.chain(new SScanCommand(args, this.commandOptions));
2712
+ /**
2713
+ * @see https://redis.io/commands/strlen
2714
+ */
2715
+ strlen = (...args) => this.chain(new StrLenCommand(args, this.commandOptions));
2716
+ /**
2717
+ * @see https://redis.io/commands/sunion
2718
+ */
2719
+ sunion = (...args) => this.chain(new SUnionCommand(args, this.commandOptions));
2720
+ /**
2721
+ * @see https://redis.io/commands/sunionstore
2722
+ */
2723
+ sunionstore = (...args) => this.chain(new SUnionStoreCommand(args, this.commandOptions));
2724
+ /**
2725
+ * @see https://redis.io/commands/time
2726
+ */
2727
+ time = () => this.chain(new TimeCommand(this.commandOptions));
2728
+ /**
2729
+ * @see https://redis.io/commands/touch
2730
+ */
2731
+ touch = (...args) => this.chain(new TouchCommand(args, this.commandOptions));
2732
+ /**
2733
+ * @see https://redis.io/commands/ttl
2734
+ */
2735
+ ttl = (...args) => this.chain(new TtlCommand(args, this.commandOptions));
2736
+ /**
2737
+ * @see https://redis.io/commands/type
2738
+ */
2739
+ type = (...args) => this.chain(new TypeCommand(args, this.commandOptions));
2740
+ /**
2741
+ * @see https://redis.io/commands/unlink
2742
+ */
2743
+ unlink = (...args) => this.chain(new UnlinkCommand(args, this.commandOptions));
2744
+ /**
2745
+ * @see https://redis.io/commands/zadd
2746
+ */
2747
+ zadd = (...args) => {
2748
+ if ("score" in args[1]) {
2749
+ return this.chain(
2750
+ new ZAddCommand([args[0], args[1], ...args.slice(2)], this.commandOptions)
2751
+ );
2752
+ }
2753
+ return this.chain(
2754
+ new ZAddCommand(
2755
+ [args[0], args[1], ...args.slice(2)],
2756
+ this.commandOptions
2757
+ )
2758
+ );
2759
+ };
2760
+ /**
2761
+ * @see https://redis.io/commands/xadd
2762
+ */
2763
+ xadd = (...args) => this.chain(new XAddCommand(args, this.commandOptions));
2764
+ /**
2765
+ * @see https://redis.io/commands/xack
2766
+ */
2767
+ xack = (...args) => this.chain(new XAckCommand(args, this.commandOptions));
2768
+ /**
2769
+ * @see https://redis.io/commands/xdel
2770
+ */
2771
+ xdel = (...args) => this.chain(new XDelCommand(args, this.commandOptions));
2772
+ /**
2773
+ * @see https://redis.io/commands/xgroup
2774
+ */
2775
+ xgroup = (...args) => this.chain(new XGroupCommand(args, this.commandOptions));
2776
+ /**
2777
+ * @see https://redis.io/commands/xread
2778
+ */
2779
+ xread = (...args) => this.chain(new XReadCommand(args, this.commandOptions));
2780
+ /**
2781
+ * @see https://redis.io/commands/xreadgroup
2782
+ */
2783
+ xreadgroup = (...args) => this.chain(new XReadGroupCommand(args, this.commandOptions));
2784
+ /**
2785
+ * @see https://redis.io/commands/xinfo
2786
+ */
2787
+ xinfo = (...args) => this.chain(new XInfoCommand(args, this.commandOptions));
2788
+ /**
2789
+ * @see https://redis.io/commands/xlen
2790
+ */
2791
+ xlen = (...args) => this.chain(new XLenCommand(args, this.commandOptions));
2792
+ /**
2793
+ * @see https://redis.io/commands/xpending
2794
+ */
2795
+ xpending = (...args) => this.chain(new XPendingCommand(args, this.commandOptions));
2796
+ /**
2797
+ * @see https://redis.io/commands/xclaim
2798
+ */
2799
+ xclaim = (...args) => this.chain(new XClaimCommand(args, this.commandOptions));
2800
+ /**
2801
+ * @see https://redis.io/commands/xautoclaim
2802
+ */
2803
+ xautoclaim = (...args) => this.chain(new XAutoClaim(args, this.commandOptions));
2804
+ /**
2805
+ * @see https://redis.io/commands/xtrim
2806
+ */
2807
+ xtrim = (...args) => this.chain(new XTrimCommand(args, this.commandOptions));
2808
+ /**
2809
+ * @see https://redis.io/commands/xrange
2810
+ */
2811
+ xrange = (...args) => this.chain(new XRangeCommand(args, this.commandOptions));
2812
+ /**
2813
+ * @see https://redis.io/commands/xrevrange
2814
+ */
2815
+ xrevrange = (...args) => this.chain(new XRevRangeCommand(args, this.commandOptions));
2816
+ /**
2817
+ * @see https://redis.io/commands/zcard
2818
+ */
2819
+ zcard = (...args) => this.chain(new ZCardCommand(args, this.commandOptions));
2820
+ /**
2821
+ * @see https://redis.io/commands/zcount
2822
+ */
2823
+ zcount = (...args) => this.chain(new ZCountCommand(args, this.commandOptions));
2824
+ /**
2825
+ * @see https://redis.io/commands/zincrby
2826
+ */
2827
+ zincrby = (key, increment, member) => this.chain(new ZIncrByCommand([key, increment, member], this.commandOptions));
2828
+ /**
2829
+ * @see https://redis.io/commands/zinterstore
2830
+ */
2831
+ zinterstore = (...args) => this.chain(new ZInterStoreCommand(args, this.commandOptions));
2832
+ /**
2833
+ * @see https://redis.io/commands/zlexcount
2834
+ */
2835
+ zlexcount = (...args) => this.chain(new ZLexCountCommand(args, this.commandOptions));
2836
+ /**
2837
+ * @see https://redis.io/commands/zmscore
2838
+ */
2839
+ zmscore = (...args) => this.chain(new ZMScoreCommand(args, this.commandOptions));
2840
+ /**
2841
+ * @see https://redis.io/commands/zpopmax
2842
+ */
2843
+ zpopmax = (...args) => this.chain(new ZPopMaxCommand(args, this.commandOptions));
2844
+ /**
2845
+ * @see https://redis.io/commands/zpopmin
2846
+ */
2847
+ zpopmin = (...args) => this.chain(new ZPopMinCommand(args, this.commandOptions));
2848
+ /**
2849
+ * @see https://redis.io/commands/zrange
2850
+ */
2851
+ zrange = (...args) => this.chain(new ZRangeCommand(args, this.commandOptions));
2852
+ /**
2853
+ * @see https://redis.io/commands/zrank
2854
+ */
2855
+ zrank = (key, member) => this.chain(new ZRankCommand([key, member], this.commandOptions));
2856
+ /**
2857
+ * @see https://redis.io/commands/zrem
2858
+ */
2859
+ zrem = (key, ...members) => this.chain(new ZRemCommand([key, ...members], this.commandOptions));
2860
+ /**
2861
+ * @see https://redis.io/commands/zremrangebylex
2862
+ */
2863
+ zremrangebylex = (...args) => this.chain(new ZRemRangeByLexCommand(args, this.commandOptions));
2864
+ /**
2865
+ * @see https://redis.io/commands/zremrangebyrank
2866
+ */
2867
+ zremrangebyrank = (...args) => this.chain(new ZRemRangeByRankCommand(args, this.commandOptions));
2868
+ /**
2869
+ * @see https://redis.io/commands/zremrangebyscore
2870
+ */
2871
+ zremrangebyscore = (...args) => this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions));
2872
+ /**
2873
+ * @see https://redis.io/commands/zrevrank
2874
+ */
2875
+ zrevrank = (key, member) => this.chain(new ZRevRankCommand([key, member], this.commandOptions));
2876
+ /**
2877
+ * @see https://redis.io/commands/zscan
2878
+ */
2879
+ zscan = (...args) => this.chain(new ZScanCommand(args, this.commandOptions));
2880
+ /**
2881
+ * @see https://redis.io/commands/zscore
2882
+ */
2883
+ zscore = (key, member) => this.chain(new ZScoreCommand([key, member], this.commandOptions));
2884
+ /**
2885
+ * @see https://redis.io/commands/zunionstore
2886
+ */
2887
+ zunionstore = (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions));
2888
+ /**
2889
+ * @see https://redis.io/commands/zunion
2890
+ */
2891
+ zunion = (...args) => this.chain(new ZUnionCommand(args, this.commandOptions));
2892
+ /**
2893
+ * @see https://redis.io/commands/?group=json
2894
+ */
2895
+ get json() {
2896
+ return {
2897
+ /**
2898
+ * @see https://redis.io/commands/json.arrappend
2899
+ */
2900
+ arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
2901
+ /**
2902
+ * @see https://redis.io/commands/json.arrindex
2903
+ */
2904
+ arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
2905
+ /**
2906
+ * @see https://redis.io/commands/json.arrinsert
2907
+ */
2908
+ arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
2909
+ /**
2910
+ * @see https://redis.io/commands/json.arrlen
2911
+ */
2912
+ arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
2913
+ /**
2914
+ * @see https://redis.io/commands/json.arrpop
2915
+ */
2916
+ arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
2917
+ /**
2918
+ * @see https://redis.io/commands/json.arrtrim
2919
+ */
2920
+ arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
2921
+ /**
2922
+ * @see https://redis.io/commands/json.clear
2923
+ */
2924
+ clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
2925
+ /**
2926
+ * @see https://redis.io/commands/json.del
2927
+ */
2928
+ del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
2929
+ /**
2930
+ * @see https://redis.io/commands/json.forget
2931
+ */
2932
+ forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
2933
+ /**
2934
+ * @see https://redis.io/commands/json.get
2935
+ */
2936
+ get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
2937
+ /**
2938
+ * @see https://redis.io/commands/json.mget
2939
+ */
2940
+ mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
2941
+ /**
2942
+ * @see https://redis.io/commands/json.mset
2943
+ */
2944
+ mset: (...args) => this.chain(new JsonMSetCommand(args, this.commandOptions)),
2945
+ /**
2946
+ * @see https://redis.io/commands/json.numincrby
2947
+ */
2948
+ numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
2949
+ /**
2950
+ * @see https://redis.io/commands/json.nummultby
2951
+ */
2952
+ nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
2953
+ /**
2954
+ * @see https://redis.io/commands/json.objkeys
2955
+ */
2956
+ objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
2957
+ /**
2958
+ * @see https://redis.io/commands/json.objlen
2959
+ */
2960
+ objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
2961
+ /**
2962
+ * @see https://redis.io/commands/json.resp
2963
+ */
2964
+ resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
2965
+ /**
2966
+ * @see https://redis.io/commands/json.set
2967
+ */
2968
+ set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
2969
+ /**
2970
+ * @see https://redis.io/commands/json.strappend
2971
+ */
2972
+ strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
2973
+ /**
2974
+ * @see https://redis.io/commands/json.strlen
2975
+ */
2976
+ strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
2977
+ /**
2978
+ * @see https://redis.io/commands/json.toggle
2979
+ */
2980
+ toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
2981
+ /**
2982
+ * @see https://redis.io/commands/json.type
2983
+ */
2984
+ type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
2985
+ };
2986
+ }
2987
+ };
2988
+
2989
+ // pkg/script.ts
2990
+ var import_enc_hex = __toESM(require("crypto-js/enc-hex.js"));
2991
+ var import_sha1 = __toESM(require("crypto-js/sha1.js"));
2992
+ var Script = class {
2993
+ script;
2994
+ sha1;
2995
+ redis;
2996
+ constructor(redis, script) {
2997
+ this.redis = redis;
2998
+ this.sha1 = this.digest(script);
2999
+ this.script = script;
3000
+ }
3001
+ /**
3002
+ * Send an `EVAL` command to redis.
3003
+ */
3004
+ async eval(keys, args) {
3005
+ return await this.redis.eval(this.script, keys, args);
3006
+ }
3007
+ /**
3008
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
3009
+ */
3010
+ async evalsha(keys, args) {
3011
+ return await this.redis.evalsha(this.sha1, keys, args);
3012
+ }
3013
+ /**
3014
+ * Optimistically try to run `EVALSHA` first.
3015
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
3016
+ *
3017
+ * Following calls will be able to use the cached script
3018
+ */
3019
+ async exec(keys, args) {
3020
+ const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
3021
+ if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
3022
+ return await this.redis.eval(this.script, keys, args);
3023
+ }
3024
+ throw error;
3025
+ });
3026
+ return res;
3027
+ }
3028
+ /**
3029
+ * Compute the sha1 hash of the script and return its hex representation.
3030
+ */
3031
+ digest(s) {
3032
+ return import_enc_hex.default.stringify((0, import_sha1.default)(s));
3033
+ }
3034
+ };
3035
+
3036
+ // pkg/redis.ts
3037
+ var Redis = class {
3038
+ client;
3039
+ opts;
3040
+ enableTelemetry;
3041
+ enableAutoPipelining;
3042
+ /**
3043
+ * Create a new redis client
3044
+ *
3045
+ * @example
3046
+ * ```typescript
3047
+ * const redis = new Redis({
3048
+ * url: "<UPSTASH_REDIS_REST_URL>",
3049
+ * token: "<UPSTASH_REDIS_REST_TOKEN>",
3050
+ * });
3051
+ * ```
3052
+ */
3053
+ constructor(client, opts) {
3054
+ this.client = client;
3055
+ this.opts = opts;
3056
+ this.enableTelemetry = opts?.enableTelemetry ?? true;
3057
+ if (opts?.readYourWrites === false) {
3058
+ this.client.readYourWrites = false;
3059
+ }
3060
+ this.enableAutoPipelining = opts?.enableAutoPipelining ?? true;
3061
+ }
3062
+ get readYourWritesSyncToken() {
3063
+ return this.client.upstashSyncToken;
3064
+ }
3065
+ set readYourWritesSyncToken(session) {
3066
+ this.client.upstashSyncToken = session;
3067
+ }
3068
+ get json() {
3069
+ return {
3070
+ /**
3071
+ * @see https://redis.io/commands/json.arrappend
3072
+ */
3073
+ arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
3074
+ /**
3075
+ * @see https://redis.io/commands/json.arrindex
3076
+ */
3077
+ arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
3078
+ /**
3079
+ * @see https://redis.io/commands/json.arrinsert
3080
+ */
3081
+ arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
3082
+ /**
3083
+ * @see https://redis.io/commands/json.arrlen
3084
+ */
3085
+ arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
3086
+ /**
3087
+ * @see https://redis.io/commands/json.arrpop
3088
+ */
3089
+ arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
3090
+ /**
3091
+ * @see https://redis.io/commands/json.arrtrim
3092
+ */
3093
+ arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
3094
+ /**
3095
+ * @see https://redis.io/commands/json.clear
3096
+ */
3097
+ clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
3098
+ /**
3099
+ * @see https://redis.io/commands/json.del
3100
+ */
3101
+ del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
3102
+ /**
3103
+ * @see https://redis.io/commands/json.forget
3104
+ */
3105
+ forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
3106
+ /**
3107
+ * @see https://redis.io/commands/json.get
3108
+ */
3109
+ get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
3110
+ /**
3111
+ * @see https://redis.io/commands/json.mget
3112
+ */
3113
+ mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
3114
+ /**
3115
+ * @see https://redis.io/commands/json.mset
3116
+ */
3117
+ mset: (...args) => new JsonMSetCommand(args, this.opts).exec(this.client),
3118
+ /**
3119
+ * @see https://redis.io/commands/json.numincrby
3120
+ */
3121
+ numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
3122
+ /**
3123
+ * @see https://redis.io/commands/json.nummultby
3124
+ */
3125
+ nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
3126
+ /**
3127
+ * @see https://redis.io/commands/json.objkeys
3128
+ */
3129
+ objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
3130
+ /**
3131
+ * @see https://redis.io/commands/json.objlen
3132
+ */
3133
+ objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
3134
+ /**
3135
+ * @see https://redis.io/commands/json.resp
3136
+ */
3137
+ resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
3138
+ /**
3139
+ * @see https://redis.io/commands/json.set
3140
+ */
3141
+ set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
3142
+ /**
3143
+ * @see https://redis.io/commands/json.strappend
3144
+ */
3145
+ strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
3146
+ /**
3147
+ * @see https://redis.io/commands/json.strlen
3148
+ */
3149
+ strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
3150
+ /**
3151
+ * @see https://redis.io/commands/json.toggle
3152
+ */
3153
+ toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
3154
+ /**
3155
+ * @see https://redis.io/commands/json.type
3156
+ */
3157
+ type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
3158
+ };
3159
+ }
3160
+ /**
3161
+ * Wrap a new middleware around the HTTP client.
3162
+ */
3163
+ use = (middleware) => {
3164
+ const makeRequest = this.client.request.bind(this.client);
3165
+ this.client.request = (req) => middleware(req, makeRequest);
3166
+ };
3167
+ /**
3168
+ * Technically this is not private, we can hide it from intellisense by doing this
3169
+ */
3170
+ addTelemetry = (telemetry) => {
3171
+ if (!this.enableTelemetry) {
3172
+ return;
3173
+ }
3174
+ try {
3175
+ this.client.mergeTelemetry(telemetry);
3176
+ } catch {
3177
+ }
3178
+ };
3179
+ createScript(script) {
3180
+ return new Script(this, script);
3181
+ }
3182
+ /**
3183
+ * Create a new pipeline that allows you to send requests in bulk.
3184
+ *
3185
+ * @see {@link Pipeline}
3186
+ */
3187
+ pipeline = () => new Pipeline({
3188
+ client: this.client,
3189
+ commandOptions: this.opts,
3190
+ multiExec: false
3191
+ });
3192
+ autoPipeline = () => {
3193
+ return createAutoPipelineProxy(this);
3194
+ };
3195
+ /**
3196
+ * Create a new transaction to allow executing multiple steps atomically.
3197
+ *
3198
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
3199
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
3200
+ * guarantees that the commands are executed as a single isolated operation.
3201
+ *
3202
+ * @see {@link Pipeline}
3203
+ */
3204
+ multi = () => new Pipeline({
3205
+ client: this.client,
3206
+ commandOptions: this.opts,
3207
+ multiExec: true
3208
+ });
3209
+ /**
3210
+ * Returns an instance that can be used to execute `BITFIELD` commands on one key.
3211
+ *
3212
+ * @example
3213
+ * ```typescript
3214
+ * redis.set("mykey", 0);
3215
+ * const result = await redis.bitfield("mykey")
3216
+ * .set("u4", 0, 16)
3217
+ * .incr("u4", "#1", 1)
3218
+ * .exec();
3219
+ * console.log(result); // [0, 1]
3220
+ * ```
3221
+ *
3222
+ * @see https://redis.io/commands/bitfield
3223
+ */
3224
+ bitfield = (...args) => new BitFieldCommand(args, this.client, this.opts);
3225
+ /**
3226
+ * @see https://redis.io/commands/append
3227
+ */
3228
+ append = (...args) => new AppendCommand(args, this.opts).exec(this.client);
3229
+ /**
3230
+ * @see https://redis.io/commands/bitcount
3231
+ */
3232
+ bitcount = (...args) => new BitCountCommand(args, this.opts).exec(this.client);
3233
+ /**
3234
+ * @see https://redis.io/commands/bitop
3235
+ */
3236
+ bitop = (op, destinationKey, sourceKey, ...sourceKeys) => new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.opts).exec(
3237
+ this.client
3238
+ );
3239
+ /**
3240
+ * @see https://redis.io/commands/bitpos
3241
+ */
3242
+ bitpos = (...args) => new BitPosCommand(args, this.opts).exec(this.client);
3243
+ /**
3244
+ * @see https://redis.io/commands/copy
3245
+ */
3246
+ copy = (...args) => new CopyCommand(args, this.opts).exec(this.client);
3247
+ /**
3248
+ * @see https://redis.io/commands/dbsize
3249
+ */
3250
+ dbsize = () => new DBSizeCommand(this.opts).exec(this.client);
3251
+ /**
3252
+ * @see https://redis.io/commands/decr
3253
+ */
3254
+ decr = (...args) => new DecrCommand(args, this.opts).exec(this.client);
3255
+ /**
3256
+ * @see https://redis.io/commands/decrby
3257
+ */
3258
+ decrby = (...args) => new DecrByCommand(args, this.opts).exec(this.client);
3259
+ /**
3260
+ * @see https://redis.io/commands/del
3261
+ */
3262
+ del = (...args) => new DelCommand(args, this.opts).exec(this.client);
3263
+ /**
3264
+ * @see https://redis.io/commands/echo
3265
+ */
3266
+ echo = (...args) => new EchoCommand(args, this.opts).exec(this.client);
3267
+ /**
3268
+ * @see https://redis.io/commands/eval
3269
+ */
3270
+ eval = (...args) => new EvalCommand(args, this.opts).exec(this.client);
3271
+ /**
3272
+ * @see https://redis.io/commands/evalsha
3273
+ */
3274
+ evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
3275
+ /**
3276
+ * @see https://redis.io/commands/exists
3277
+ */
3278
+ exists = (...args) => new ExistsCommand(args, this.opts).exec(this.client);
3279
+ /**
3280
+ * @see https://redis.io/commands/expire
3281
+ */
3282
+ expire = (...args) => new ExpireCommand(args, this.opts).exec(this.client);
3283
+ /**
3284
+ * @see https://redis.io/commands/expireat
3285
+ */
3286
+ expireat = (...args) => new ExpireAtCommand(args, this.opts).exec(this.client);
3287
+ /**
3288
+ * @see https://redis.io/commands/flushall
3289
+ */
3290
+ flushall = (args) => new FlushAllCommand(args, this.opts).exec(this.client);
3291
+ /**
3292
+ * @see https://redis.io/commands/flushdb
3293
+ */
3294
+ flushdb = (...args) => new FlushDBCommand(args, this.opts).exec(this.client);
3295
+ /**
3296
+ * @see https://redis.io/commands/geoadd
3297
+ */
3298
+ geoadd = (...args) => new GeoAddCommand(args, this.opts).exec(this.client);
3299
+ /**
3300
+ * @see https://redis.io/commands/geopos
3301
+ */
3302
+ geopos = (...args) => new GeoPosCommand(args, this.opts).exec(this.client);
3303
+ /**
3304
+ * @see https://redis.io/commands/geodist
3305
+ */
3306
+ geodist = (...args) => new GeoDistCommand(args, this.opts).exec(this.client);
3307
+ /**
3308
+ * @see https://redis.io/commands/geohash
3309
+ */
3310
+ geohash = (...args) => new GeoHashCommand(args, this.opts).exec(this.client);
3311
+ /**
3312
+ * @see https://redis.io/commands/geosearch
3313
+ */
3314
+ geosearch = (...args) => new GeoSearchCommand(args, this.opts).exec(this.client);
3315
+ /**
3316
+ * @see https://redis.io/commands/geosearchstore
3317
+ */
3318
+ geosearchstore = (...args) => new GeoSearchStoreCommand(args, this.opts).exec(this.client);
3319
+ /**
3320
+ * @see https://redis.io/commands/get
3321
+ */
3322
+ get = (...args) => new GetCommand(args, this.opts).exec(this.client);
3323
+ /**
3324
+ * @see https://redis.io/commands/getbit
3325
+ */
3326
+ getbit = (...args) => new GetBitCommand(args, this.opts).exec(this.client);
3327
+ /**
3328
+ * @see https://redis.io/commands/getdel
3329
+ */
3330
+ getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
3331
+ /**
3332
+ * @see https://redis.io/commands/getrange
3333
+ */
3334
+ getrange = (...args) => new GetRangeCommand(args, this.opts).exec(this.client);
3335
+ /**
3336
+ * @see https://redis.io/commands/getset
3337
+ */
3338
+ getset = (key, value) => new GetSetCommand([key, value], this.opts).exec(this.client);
3339
+ /**
3340
+ * @see https://redis.io/commands/hdel
3341
+ */
3342
+ hdel = (...args) => new HDelCommand(args, this.opts).exec(this.client);
3343
+ /**
3344
+ * @see https://redis.io/commands/hexists
3345
+ */
3346
+ hexists = (...args) => new HExistsCommand(args, this.opts).exec(this.client);
3347
+ /**
3348
+ * @see https://redis.io/commands/hget
3349
+ */
3350
+ hget = (...args) => new HGetCommand(args, this.opts).exec(this.client);
3351
+ /**
3352
+ * @see https://redis.io/commands/hgetall
3353
+ */
3354
+ hgetall = (...args) => new HGetAllCommand(args, this.opts).exec(this.client);
3355
+ /**
3356
+ * @see https://redis.io/commands/hincrby
3357
+ */
3358
+ hincrby = (...args) => new HIncrByCommand(args, this.opts).exec(this.client);
3359
+ /**
3360
+ * @see https://redis.io/commands/hincrbyfloat
3361
+ */
3362
+ hincrbyfloat = (...args) => new HIncrByFloatCommand(args, this.opts).exec(this.client);
3363
+ /**
3364
+ * @see https://redis.io/commands/hkeys
3365
+ */
3366
+ hkeys = (...args) => new HKeysCommand(args, this.opts).exec(this.client);
3367
+ /**
3368
+ * @see https://redis.io/commands/hlen
3369
+ */
3370
+ hlen = (...args) => new HLenCommand(args, this.opts).exec(this.client);
3371
+ /**
3372
+ * @see https://redis.io/commands/hmget
3373
+ */
3374
+ hmget = (...args) => new HMGetCommand(args, this.opts).exec(this.client);
3375
+ /**
3376
+ * @see https://redis.io/commands/hmset
3377
+ */
3378
+ hmset = (key, kv) => new HMSetCommand([key, kv], this.opts).exec(this.client);
3379
+ /**
3380
+ * @see https://redis.io/commands/hrandfield
3381
+ */
3382
+ hrandfield = (key, count, withValues) => new HRandFieldCommand([key, count, withValues], this.opts).exec(this.client);
3383
+ /**
3384
+ * @see https://redis.io/commands/hscan
3385
+ */
3386
+ hscan = (...args) => new HScanCommand(args, this.opts).exec(this.client);
3387
+ /**
3388
+ * @see https://redis.io/commands/hset
3389
+ */
3390
+ hset = (key, kv) => new HSetCommand([key, kv], this.opts).exec(this.client);
3391
+ /**
3392
+ * @see https://redis.io/commands/hsetnx
3393
+ */
3394
+ hsetnx = (key, field, value) => new HSetNXCommand([key, field, value], this.opts).exec(this.client);
3395
+ /**
3396
+ * @see https://redis.io/commands/hstrlen
3397
+ */
3398
+ hstrlen = (...args) => new HStrLenCommand(args, this.opts).exec(this.client);
3399
+ /**
3400
+ * @see https://redis.io/commands/hvals
3401
+ */
3402
+ hvals = (...args) => new HValsCommand(args, this.opts).exec(this.client);
3403
+ /**
3404
+ * @see https://redis.io/commands/incr
3405
+ */
3406
+ incr = (...args) => new IncrCommand(args, this.opts).exec(this.client);
3407
+ /**
3408
+ * @see https://redis.io/commands/incrby
3409
+ */
3410
+ incrby = (...args) => new IncrByCommand(args, this.opts).exec(this.client);
3411
+ /**
3412
+ * @see https://redis.io/commands/incrbyfloat
3413
+ */
3414
+ incrbyfloat = (...args) => new IncrByFloatCommand(args, this.opts).exec(this.client);
3415
+ /**
3416
+ * @see https://redis.io/commands/keys
3417
+ */
3418
+ keys = (...args) => new KeysCommand(args, this.opts).exec(this.client);
3419
+ /**
3420
+ * @see https://redis.io/commands/lindex
3421
+ */
3422
+ lindex = (...args) => new LIndexCommand(args, this.opts).exec(this.client);
3423
+ /**
3424
+ * @see https://redis.io/commands/linsert
3425
+ */
3426
+ linsert = (key, direction, pivot, value) => new LInsertCommand([key, direction, pivot, value], this.opts).exec(this.client);
3427
+ /**
3428
+ * @see https://redis.io/commands/llen
3429
+ */
3430
+ llen = (...args) => new LLenCommand(args, this.opts).exec(this.client);
3431
+ /**
3432
+ * @see https://redis.io/commands/lmove
3433
+ */
3434
+ lmove = (...args) => new LMoveCommand(args, this.opts).exec(this.client);
3435
+ /**
3436
+ * @see https://redis.io/commands/lpop
3437
+ */
3438
+ lpop = (...args) => new LPopCommand(args, this.opts).exec(this.client);
3439
+ /**
3440
+ * @see https://redis.io/commands/lmpop
3441
+ */
3442
+ lmpop = (...args) => new LmPopCommand(args, this.opts).exec(this.client);
3443
+ /**
3444
+ * @see https://redis.io/commands/lpos
3445
+ */
3446
+ lpos = (...args) => new LPosCommand(args, this.opts).exec(this.client);
3447
+ /**
3448
+ * @see https://redis.io/commands/lpush
3449
+ */
3450
+ lpush = (key, ...elements) => new LPushCommand([key, ...elements], this.opts).exec(this.client);
3451
+ /**
3452
+ * @see https://redis.io/commands/lpushx
3453
+ */
3454
+ lpushx = (key, ...elements) => new LPushXCommand([key, ...elements], this.opts).exec(this.client);
3455
+ /**
3456
+ * @see https://redis.io/commands/lrange
3457
+ */
3458
+ lrange = (...args) => new LRangeCommand(args, this.opts).exec(this.client);
3459
+ /**
3460
+ * @see https://redis.io/commands/lrem
3461
+ */
3462
+ lrem = (key, count, value) => new LRemCommand([key, count, value], this.opts).exec(this.client);
3463
+ /**
3464
+ * @see https://redis.io/commands/lset
3465
+ */
3466
+ lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
3467
+ /**
3468
+ * @see https://redis.io/commands/ltrim
3469
+ */
3470
+ ltrim = (...args) => new LTrimCommand(args, this.opts).exec(this.client);
3471
+ /**
3472
+ * @see https://redis.io/commands/mget
3473
+ */
3474
+ mget = (...args) => new MGetCommand(args, this.opts).exec(this.client);
3475
+ /**
3476
+ * @see https://redis.io/commands/mset
3477
+ */
3478
+ mset = (kv) => new MSetCommand([kv], this.opts).exec(this.client);
3479
+ /**
3480
+ * @see https://redis.io/commands/msetnx
3481
+ */
3482
+ msetnx = (kv) => new MSetNXCommand([kv], this.opts).exec(this.client);
3483
+ /**
3484
+ * @see https://redis.io/commands/persist
3485
+ */
3486
+ persist = (...args) => new PersistCommand(args, this.opts).exec(this.client);
3487
+ /**
3488
+ * @see https://redis.io/commands/pexpire
3489
+ */
3490
+ pexpire = (...args) => new PExpireCommand(args, this.opts).exec(this.client);
3491
+ /**
3492
+ * @see https://redis.io/commands/pexpireat
3493
+ */
3494
+ pexpireat = (...args) => new PExpireAtCommand(args, this.opts).exec(this.client);
3495
+ /**
3496
+ * @see https://redis.io/commands/pfadd
3497
+ */
3498
+ pfadd = (...args) => new PfAddCommand(args, this.opts).exec(this.client);
3499
+ /**
3500
+ * @see https://redis.io/commands/pfcount
3501
+ */
3502
+ pfcount = (...args) => new PfCountCommand(args, this.opts).exec(this.client);
3503
+ /**
3504
+ * @see https://redis.io/commands/pfmerge
3505
+ */
3506
+ pfmerge = (...args) => new PfMergeCommand(args, this.opts).exec(this.client);
3507
+ /**
3508
+ * @see https://redis.io/commands/ping
3509
+ */
3510
+ ping = (args) => new PingCommand(args, this.opts).exec(this.client);
3511
+ /**
3512
+ * @see https://redis.io/commands/psetex
3513
+ */
3514
+ psetex = (key, ttl, value) => new PSetEXCommand([key, ttl, value], this.opts).exec(this.client);
3515
+ /**
3516
+ * @see https://redis.io/commands/pttl
3517
+ */
3518
+ pttl = (...args) => new PTtlCommand(args, this.opts).exec(this.client);
3519
+ /**
3520
+ * @see https://redis.io/commands/publish
3521
+ */
3522
+ publish = (...args) => new PublishCommand(args, this.opts).exec(this.client);
3523
+ /**
3524
+ * @see https://redis.io/commands/randomkey
3525
+ */
3526
+ randomkey = () => new RandomKeyCommand().exec(this.client);
3527
+ /**
3528
+ * @see https://redis.io/commands/rename
3529
+ */
3530
+ rename = (...args) => new RenameCommand(args, this.opts).exec(this.client);
3531
+ /**
3532
+ * @see https://redis.io/commands/renamenx
3533
+ */
3534
+ renamenx = (...args) => new RenameNXCommand(args, this.opts).exec(this.client);
3535
+ /**
3536
+ * @see https://redis.io/commands/rpop
3537
+ */
3538
+ rpop = (...args) => new RPopCommand(args, this.opts).exec(this.client);
3539
+ /**
3540
+ * @see https://redis.io/commands/rpush
3541
+ */
3542
+ rpush = (key, ...elements) => new RPushCommand([key, ...elements], this.opts).exec(this.client);
3543
+ /**
3544
+ * @see https://redis.io/commands/rpushx
3545
+ */
3546
+ rpushx = (key, ...elements) => new RPushXCommand([key, ...elements], this.opts).exec(this.client);
3547
+ /**
3548
+ * @see https://redis.io/commands/sadd
3549
+ */
3550
+ sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
3551
+ /**
3552
+ * @see https://redis.io/commands/scan
3553
+ */
3554
+ scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
3555
+ /**
3556
+ * @see https://redis.io/commands/scard
3557
+ */
3558
+ scard = (...args) => new SCardCommand(args, this.opts).exec(this.client);
3559
+ /**
3560
+ * @see https://redis.io/commands/script-exists
3561
+ */
3562
+ scriptExists = (...args) => new ScriptExistsCommand(args, this.opts).exec(this.client);
3563
+ /**
3564
+ * @see https://redis.io/commands/script-flush
3565
+ */
3566
+ scriptFlush = (...args) => new ScriptFlushCommand(args, this.opts).exec(this.client);
3567
+ /**
3568
+ * @see https://redis.io/commands/script-load
3569
+ */
3570
+ scriptLoad = (...args) => new ScriptLoadCommand(args, this.opts).exec(this.client);
3571
+ /**
3572
+ * @see https://redis.io/commands/sdiff
3573
+ */
3574
+ sdiff = (...args) => new SDiffCommand(args, this.opts).exec(this.client);
3575
+ /**
3576
+ * @see https://redis.io/commands/sdiffstore
3577
+ */
3578
+ sdiffstore = (...args) => new SDiffStoreCommand(args, this.opts).exec(this.client);
3579
+ /**
3580
+ * @see https://redis.io/commands/set
3581
+ */
3582
+ set = (key, value, opts) => new SetCommand([key, value, opts], this.opts).exec(this.client);
3583
+ /**
3584
+ * @see https://redis.io/commands/setbit
3585
+ */
3586
+ setbit = (...args) => new SetBitCommand(args, this.opts).exec(this.client);
3587
+ /**
3588
+ * @see https://redis.io/commands/setex
3589
+ */
3590
+ setex = (key, ttl, value) => new SetExCommand([key, ttl, value], this.opts).exec(this.client);
3591
+ /**
3592
+ * @see https://redis.io/commands/setnx
3593
+ */
3594
+ setnx = (key, value) => new SetNxCommand([key, value], this.opts).exec(this.client);
3595
+ /**
3596
+ * @see https://redis.io/commands/setrange
3597
+ */
3598
+ setrange = (...args) => new SetRangeCommand(args, this.opts).exec(this.client);
3599
+ /**
3600
+ * @see https://redis.io/commands/sinter
3601
+ */
3602
+ sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
3603
+ /**
3604
+ * @see https://redis.io/commands/sinterstore
3605
+ */
3606
+ sinterstore = (...args) => new SInterStoreCommand(args, this.opts).exec(this.client);
3607
+ /**
3608
+ * @see https://redis.io/commands/sismember
3609
+ */
3610
+ sismember = (key, member) => new SIsMemberCommand([key, member], this.opts).exec(this.client);
3611
+ /**
3612
+ * @see https://redis.io/commands/smismember
3613
+ */
3614
+ smismember = (key, members) => new SMIsMemberCommand([key, members], this.opts).exec(this.client);
3615
+ /**
3616
+ * @see https://redis.io/commands/smembers
3617
+ */
3618
+ smembers = (...args) => new SMembersCommand(args, this.opts).exec(this.client);
3619
+ /**
3620
+ * @see https://redis.io/commands/smove
3621
+ */
3622
+ smove = (source, destination, member) => new SMoveCommand([source, destination, member], this.opts).exec(this.client);
3623
+ /**
3624
+ * @see https://redis.io/commands/spop
3625
+ */
3626
+ spop = (...args) => new SPopCommand(args, this.opts).exec(this.client);
3627
+ /**
3628
+ * @see https://redis.io/commands/srandmember
3629
+ */
3630
+ srandmember = (...args) => new SRandMemberCommand(args, this.opts).exec(this.client);
3631
+ /**
3632
+ * @see https://redis.io/commands/srem
3633
+ */
3634
+ srem = (key, ...members) => new SRemCommand([key, ...members], this.opts).exec(this.client);
3635
+ /**
3636
+ * @see https://redis.io/commands/sscan
3637
+ */
3638
+ sscan = (...args) => new SScanCommand(args, this.opts).exec(this.client);
3639
+ /**
3640
+ * @see https://redis.io/commands/strlen
3641
+ */
3642
+ strlen = (...args) => new StrLenCommand(args, this.opts).exec(this.client);
3643
+ /**
3644
+ * @see https://redis.io/commands/sunion
3645
+ */
3646
+ sunion = (...args) => new SUnionCommand(args, this.opts).exec(this.client);
3647
+ /**
3648
+ * @see https://redis.io/commands/sunionstore
3649
+ */
3650
+ sunionstore = (...args) => new SUnionStoreCommand(args, this.opts).exec(this.client);
3651
+ /**
3652
+ * @see https://redis.io/commands/time
3653
+ */
3654
+ time = () => new TimeCommand().exec(this.client);
3655
+ /**
3656
+ * @see https://redis.io/commands/touch
3657
+ */
3658
+ touch = (...args) => new TouchCommand(args, this.opts).exec(this.client);
3659
+ /**
3660
+ * @see https://redis.io/commands/ttl
3661
+ */
3662
+ ttl = (...args) => new TtlCommand(args, this.opts).exec(this.client);
3663
+ /**
3664
+ * @see https://redis.io/commands/type
3665
+ */
3666
+ type = (...args) => new TypeCommand(args, this.opts).exec(this.client);
3667
+ /**
3668
+ * @see https://redis.io/commands/unlink
3669
+ */
3670
+ unlink = (...args) => new UnlinkCommand(args, this.opts).exec(this.client);
3671
+ /**
3672
+ * @see https://redis.io/commands/xadd
3673
+ */
3674
+ xadd = (...args) => new XAddCommand(args, this.opts).exec(this.client);
3675
+ /**
3676
+ * @see https://redis.io/commands/xack
3677
+ */
3678
+ xack = (...args) => new XAckCommand(args, this.opts).exec(this.client);
3679
+ /**
3680
+ * @see https://redis.io/commands/xdel
3681
+ */
3682
+ xdel = (...args) => new XDelCommand(args, this.opts).exec(this.client);
3683
+ /**
3684
+ * @see https://redis.io/commands/xgroup
3685
+ */
3686
+ xgroup = (...args) => new XGroupCommand(args, this.opts).exec(this.client);
3687
+ /**
3688
+ * @see https://redis.io/commands/xread
3689
+ */
3690
+ xread = (...args) => new XReadCommand(args, this.opts).exec(this.client);
3691
+ /**
3692
+ * @see https://redis.io/commands/xreadgroup
3693
+ */
3694
+ xreadgroup = (...args) => new XReadGroupCommand(args, this.opts).exec(this.client);
3695
+ /**
3696
+ * @see https://redis.io/commands/xinfo
3697
+ */
3698
+ xinfo = (...args) => new XInfoCommand(args, this.opts).exec(this.client);
3699
+ /**
3700
+ * @see https://redis.io/commands/xlen
3701
+ */
3702
+ xlen = (...args) => new XLenCommand(args, this.opts).exec(this.client);
3703
+ /**
3704
+ * @see https://redis.io/commands/xpending
3705
+ */
3706
+ xpending = (...args) => new XPendingCommand(args, this.opts).exec(this.client);
3707
+ /**
3708
+ * @see https://redis.io/commands/xclaim
3709
+ */
3710
+ xclaim = (...args) => new XClaimCommand(args, this.opts).exec(this.client);
3711
+ /**
3712
+ * @see https://redis.io/commands/xautoclaim
3713
+ */
3714
+ xautoclaim = (...args) => new XAutoClaim(args, this.opts).exec(this.client);
3715
+ /**
3716
+ * @see https://redis.io/commands/xtrim
3717
+ */
3718
+ xtrim = (...args) => new XTrimCommand(args, this.opts).exec(this.client);
3719
+ /**
3720
+ * @see https://redis.io/commands/xrange
3721
+ */
3722
+ xrange = (...args) => new XRangeCommand(args, this.opts).exec(this.client);
3723
+ /**
3724
+ * @see https://redis.io/commands/xrevrange
3725
+ */
3726
+ xrevrange = (...args) => new XRevRangeCommand(args, this.opts).exec(this.client);
3727
+ /**
3728
+ * @see https://redis.io/commands/zadd
3729
+ */
3730
+ zadd = (...args) => {
3731
+ if ("score" in args[1]) {
3732
+ return new ZAddCommand([args[0], args[1], ...args.slice(2)], this.opts).exec(
3733
+ this.client
3734
+ );
3735
+ }
3736
+ return new ZAddCommand(
3737
+ [args[0], args[1], ...args.slice(2)],
3738
+ this.opts
3739
+ ).exec(this.client);
3740
+ };
3741
+ /**
3742
+ * @see https://redis.io/commands/zcard
3743
+ */
3744
+ zcard = (...args) => new ZCardCommand(args, this.opts).exec(this.client);
3745
+ /**
3746
+ * @see https://redis.io/commands/zcount
3747
+ */
3748
+ zcount = (...args) => new ZCountCommand(args, this.opts).exec(this.client);
3749
+ /**
3750
+ * @see https://redis.io/commands/zdiffstore
3751
+ */
3752
+ zdiffstore = (...args) => new ZDiffStoreCommand(args, this.opts).exec(this.client);
3753
+ /**
3754
+ * @see https://redis.io/commands/zincrby
3755
+ */
3756
+ zincrby = (key, increment, member) => new ZIncrByCommand([key, increment, member], this.opts).exec(this.client);
3757
+ /**
3758
+ * @see https://redis.io/commands/zinterstore
3759
+ */
3760
+ zinterstore = (...args) => new ZInterStoreCommand(args, this.opts).exec(this.client);
3761
+ /**
3762
+ * @see https://redis.io/commands/zlexcount
3763
+ */
3764
+ zlexcount = (...args) => new ZLexCountCommand(args, this.opts).exec(this.client);
3765
+ /**
3766
+ * @see https://redis.io/commands/zmscore
3767
+ */
3768
+ zmscore = (...args) => new ZMScoreCommand(args, this.opts).exec(this.client);
3769
+ /**
3770
+ * @see https://redis.io/commands/zpopmax
3771
+ */
3772
+ zpopmax = (...args) => new ZPopMaxCommand(args, this.opts).exec(this.client);
3773
+ /**
3774
+ * @see https://redis.io/commands/zpopmin
3775
+ */
3776
+ zpopmin = (...args) => new ZPopMinCommand(args, this.opts).exec(this.client);
3777
+ /**
3778
+ * @see https://redis.io/commands/zrange
3779
+ */
3780
+ zrange = (...args) => new ZRangeCommand(args, this.opts).exec(this.client);
3781
+ /**
3782
+ * @see https://redis.io/commands/zrank
3783
+ */
3784
+ zrank = (key, member) => new ZRankCommand([key, member], this.opts).exec(this.client);
3785
+ /**
3786
+ * @see https://redis.io/commands/zrem
3787
+ */
3788
+ zrem = (key, ...members) => new ZRemCommand([key, ...members], this.opts).exec(this.client);
3789
+ /**
3790
+ * @see https://redis.io/commands/zremrangebylex
3791
+ */
3792
+ zremrangebylex = (...args) => new ZRemRangeByLexCommand(args, this.opts).exec(this.client);
3793
+ /**
3794
+ * @see https://redis.io/commands/zremrangebyrank
3795
+ */
3796
+ zremrangebyrank = (...args) => new ZRemRangeByRankCommand(args, this.opts).exec(this.client);
3797
+ /**
3798
+ * @see https://redis.io/commands/zremrangebyscore
3799
+ */
3800
+ zremrangebyscore = (...args) => new ZRemRangeByScoreCommand(args, this.opts).exec(this.client);
3801
+ /**
3802
+ * @see https://redis.io/commands/zrevrank
3803
+ */
3804
+ zrevrank = (key, member) => new ZRevRankCommand([key, member], this.opts).exec(this.client);
3805
+ /**
3806
+ * @see https://redis.io/commands/zscan
3807
+ */
3808
+ zscan = (...args) => new ZScanCommand(args, this.opts).exec(this.client);
3809
+ /**
3810
+ * @see https://redis.io/commands/zscore
3811
+ */
3812
+ zscore = (key, member) => new ZScoreCommand([key, member], this.opts).exec(this.client);
3813
+ /**
3814
+ * @see https://redis.io/commands/zunion
3815
+ */
3816
+ zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
3817
+ /**
3818
+ * @see https://redis.io/commands/zunionstore
3819
+ */
3820
+ zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
3821
+ };
3822
+
3823
+ // version.ts
3824
+ var VERSION = "v1.30.2";
3825
+
3826
+ // platforms/nodejs.ts
3827
+ if (typeof atob === "undefined") {
3828
+ global.atob = (b64) => Buffer.from(b64, "base64").toString("utf8");
3829
+ }
3830
+ var Redis2 = class _Redis extends Redis {
3831
+ /**
3832
+ * Create a new redis client by providing a custom `Requester` implementation
3833
+ *
3834
+ * @example
3835
+ * ```ts
3836
+ *
3837
+ * import { UpstashRequest, Requester, UpstashResponse, Redis } from "@upstash/redis"
3838
+ *
3839
+ * const requester: Requester = {
3840
+ * request: <TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> => {
3841
+ * // ...
3842
+ * }
3843
+ * }
3844
+ *
3845
+ * const redis = new Redis(requester)
3846
+ * ```
3847
+ */
3848
+ constructor(configOrRequester) {
3849
+ if ("request" in configOrRequester) {
3850
+ super(configOrRequester);
3851
+ return;
3852
+ }
3853
+ if (!configOrRequester.url) {
3854
+ throw new Error(
3855
+ `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
3856
+ );
3857
+ }
3858
+ if (!configOrRequester.token) {
3859
+ throw new Error(
3860
+ `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
3861
+ );
3862
+ }
3863
+ if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
3864
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
3865
+ }
3866
+ if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
3867
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
3868
+ }
3869
+ const client = new HttpClient({
3870
+ baseUrl: configOrRequester.url,
3871
+ retry: configOrRequester.retry,
3872
+ headers: { authorization: `Bearer ${configOrRequester.token}` },
3873
+ agent: configOrRequester.agent,
3874
+ responseEncoding: configOrRequester.responseEncoding,
3875
+ cache: configOrRequester.cache ?? "no-store",
3876
+ signal: configOrRequester.signal,
3877
+ keepAlive: configOrRequester.keepAlive,
3878
+ readYourWrites: configOrRequester.readYourWrites
3879
+ });
3880
+ super(client, {
3881
+ automaticDeserialization: configOrRequester.automaticDeserialization,
3882
+ enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
3883
+ latencyLogging: configOrRequester.latencyLogging,
3884
+ enableAutoPipelining: configOrRequester.enableAutoPipelining
3885
+ });
3886
+ this.addTelemetry({
3887
+ runtime: (
3888
+ // @ts-expect-error to silence compiler
3889
+ typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
3890
+ ),
3891
+ platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
3892
+ sdk: `@upstash/redis@${VERSION}`
3893
+ });
3894
+ if (this.enableAutoPipelining) {
3895
+ return this.autoPipeline();
3896
+ }
3897
+ }
3898
+ /**
3899
+ * Create a new Upstash Redis instance from environment variables.
3900
+ *
3901
+ * Use this to automatically load connection secrets from your environment
3902
+ * variables. For instance when using the Vercel integration.
3903
+ *
3904
+ * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
3905
+ * your environment using `process.env`.
3906
+ */
3907
+ static fromEnv(config) {
3908
+ if (process.env === void 0) {
3909
+ throw new TypeError(
3910
+ 'Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
3911
+ );
3912
+ }
3913
+ const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
3914
+ if (!url) {
3915
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
3916
+ }
3917
+ const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
3918
+ if (!token) {
3919
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
3920
+ }
3921
+ return new _Redis({ ...config, url, token });
3922
+ }
3923
+ };
3924
+ // Annotate the CommonJS export names for ESM import in node:
3925
+ 0 && (module.exports = {
3926
+ Redis,
3927
+ errors
3928
+ });