1var j=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},A=class{constructor(t){var e,s,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(r=t.urlLengthLimit)!==null&&r!==void 0?r:8e3,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){var s=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const r=this.fetch;let l=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{let h=null,n=null,o=null,u=i.status,a=i.statusText;if(i.ok){var d,f;if(s.method!=="HEAD"){var c;const m=await i.text();m===""||(s.headers.get("Accept")==="text/csv"||s.headers.get("Accept")&&(!((c=s.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text"))?n=m:n=JSON.parse(m))}const p=(d=s.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),g=(f=i.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");p&&g&&g.length>1&&(o=parseInt(g[1])),s.isMaybeSingle&&Array.isArray(n)&&(n.length>1?(h={code:"PGRST116",details:`Results contain ${n.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},n=null,o=null,u=406,a="Not Acceptable"):n.length===1?n=n[0]:n=null)}else{const p=await i.text();try{h=JSON.parse(p),Array.isArray(h)&&i.status===404&&(n=[],h=null,u=200,a="OK")}catch{i.status===404&&p===""?(u=204,a="No Content"):h={message:p}}if(h&&s.shouldThrowOnError)throw new j(h)}return{error:h,data:n,count:o,status:u,statusText:a}});return this.shouldThrowOnError||(l=l.catch(i=>{var h;let n="",o="",u="";const a=i?.cause;if(a){var d,f,c,p;const O=(d=a?.message)!==null&&d!==void 0?d:"",b=(f=a?.code)!==null&&f!==void 0?f:"";n=`${(c=i?.name)!==null&&c!==void 0?c:"FetchError"}: ${i?.message}`,n+=` 2 3Caused by: ${(p=a?.name)!==null&&p!==void 0?p:"Error"}: ${O}`,b&&(n+=` (${b})`),a?.stack&&(n+=` 4${a.stack}`)}else{var g;n=(g=i?.stack)!==null&&g!==void 0?g:""}const m=this.url.toString().length;return i?.name==="AbortError"||i?.code==="ABORT_ERR"?(u="",o="Request was aborted (timeout or manual cancellation)",m>this.urlLengthLimit&&(o+=`. Note: Your request URL is ${m} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(a?.name==="HeadersOverflowError"||a?.code==="UND_ERR_HEADERS_OVERFLOW")&&(u="",o="HTTP headers exceeded server limits (typically 16KB)",m>this.urlLengthLimit&&(o+=`. Your request URL is ${m} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(h=i?.name)!==null&&h!==void 0?h:"FetchError"}: ${i?.message}`,details:n,hint:o,code:u},data:null,count:null,status:0,statusText:""}})),l.then(t,e)}returns(){return this}overrideTypes(){return this}},S=class extends A{select(t){let e=!1;const s=(t??"*").split("").map(r=>/\s/.test(r)&&!e?"":(r==='"'&&(e=!e),r)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:r,referencedTable:l=r}={}){const i=l?`${l}.order`:"order",h=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${h?`${h},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){const r=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:r=s}={}){const l=typeof r>"u"?"offset":`${r}.offset`,i=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(l,`${t}`),this.url.searchParams.set(i,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}
4explain({analyze:t=!1,verbose:e=!1,settings:s=!1,buffers:r=!1,wal:l=!1,format:i="text"}={}){var h;const n=[t?"analyze":null,e?"verbose":null,s?"settings":null,r?"buffers":null,l?"wal":null].filter(Boolean).join("|"),o=(h=this.headers.get("Accept"))!==null&&h!==void 0?h:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${o}"; options=${n};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const $=new RegExp("[,()]");var y=class extends S{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&$.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){const s=Array.from(new Set(e)).map(r=>typeof r=="string"&&$.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:s,type:r}={}){let l="";r==="plain"?l="pl":r==="phrase"?l="ph":r==="websearch"&&(l="w");const i=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${l}fts${i}.${e}`),this}match(t){return Object.entries(t).filter(([e,s])=>s!==void 0).forEach(([e,s])=>{this.url.searchParams.append(e,`eq.${s}`)}),this}not(t,e,s){return this.url.searchParams.append(t,`not.${e}.${s}`),this}or(t,{foreignTable:e,referencedTable:s=e}={}){const r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},T=class{constructor(t,{headers:e={},schema:s,fetch:r,urlLengthLimit:l=8e3}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=r,this.urlLengthLimit=l}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:s=!1,count:r}=e??{},l=s?"HEAD":"GET";let i=!1;const h=(t??"*").split("").map(u=>/\s/.test(u)&&!i?"":(u==='"'&&(i=!i),u)).join(""),{url:n,headers:o}=this.cloneRequestState();return n.searchParams.set("select",h),r&&o.append("Prefer",`count=${r}`),new y({method:l,url:n,headers:o,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(t,{count:e,defaultToNull:s=!0}={}){var r;const l="POST",{url:i,headers:h}=this.cloneRequestState();if(e&&h.append("Prefer",`count=${e}`),s||h.append("Prefer","missing=default"),Array.isArray(t)){const n=t.reduce((o,u)=>o.concat(Object.keys(u)),[]);if(n.length>0){const o=[...new Set(n)].map(u=>`"${u}"`);i.searchParams.set("columns",o.join(","))}}return new y({method:l,url:i,headers:h,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:r,defaultToNull:l=!0}={}){var i;const h="POST",{url:n,headers:o}=this.cloneRequestState();if(o.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&n.searchParams.set("on_conflict",e),r&&o.append("Prefer",`count=${r}`),l||o.append("Prefer","missing=default"),Array.isArray(t)){const u=t.reduce((a,d)=>a.concat(Object.keys(d)),[]);if(u.length>0){const a=[...new Set(u)].map(d=>`"${d}"`);n.searchParams.set("columns",a.join(","))}}return new y({method:h,url:n,headers:o,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit})}update(t,{count:e}={}){var s;const r="PATCH",{url:l,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new y({method:r,url:l,headers:i,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:t}={}){var e;const s="DELETE",{url:r,headers:l}=this.cloneRequestState();return t&&l.append("Prefer",`count=${t}`),new y({method:s,url:r,headers:l,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function v(t){"@babel/helpers - typeof";return v=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(t)}function R(t,e){if(v(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e||"default");if(v(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function x(t){var e=R(t,"string");return v(e)=="symbol"?e:e+""}function k(t,e,s){return(e=x(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function w(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,r)}return s}function P(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};
4e%2?w(Object(s),!0).forEach(function(r){k(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):w(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var q=class L{constructor(e,{headers:s={},schema:r,fetch:l,timeout:i,urlLengthLimit:h=8e3}={}){this.url=e,this.headers=new Headers(s),this.schemaName=r,this.urlLengthLimit=h;const n=l??globalThis.fetch;i!==void 0&&i>0?this.fetch=(o,u)=>{const a=new AbortController,d=setTimeout(()=>a.abort(),i),f=u?.signal;if(f){if(f.aborted)return clearTimeout(d),n(o,u);const c=()=>{clearTimeout(d),a.abort()};return f.addEventListener("abort",c,{once:!0}),n(o,P(P({},u),{},{signal:a.signal})).finally(()=>{clearTimeout(d),f.removeEventListener("abort",c)})}return n(o,P(P({},u),{},{signal:a.signal})).finally(()=>clearTimeout(d))}:this.fetch=n}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new T(new
4URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new L(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,s={},{head:r=!1,get:l=!1,count:i}={}){var h;let n;const o=new URL(`${this.url}/rpc/${e}`);let u;const a=c=>c!==null&&typeof c=="object"&&(!Array.isArray(c)||c.some(a)),d=r&&Object.values(s).some(a);d?(n="POST",u=s):r||l?(n=r?"HEAD":"GET",Object.entries(s).filter(([c,p])=>p!==void 0).map(([c,p])=>[c,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([c,p])=>{o.searchParams.append(c,p)})):(n="POST",u=s);const f=new Headers(this.headers);return d?f.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&f.set("Prefer",`count=${i}`),new y({method:n,url:o,headers:f,schema:this.schemaName,body:u,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch,urlLengthLimit:this.urlLengthLimit})}};export{q as P};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.