@upstash/redis 0.0.0-ci.acc0588e9e893d8bbe5651955e3fef342d078490 → 0.0.0-ci.ad5be1ba2d5a9fb932176239f1a30ecd48450c0a-20250220103021

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