Comparing version 0.9.4 to 1.0.0
@@ -1,2 +0,2 @@ | ||
var _e=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Qe=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var i=(t,e,r)=>(Qe(t,e,"read from private field"),r?r.call(t):e.get(t)),a=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},m=(t,e,r,n)=>(Qe(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Oe=(t,e,r,n)=>({set _(s){m(t,e,s,r)},get _(){return i(t,e,n)}}),p=(t,e,r)=>(Qe(t,e,"access private method"),r);var Re={default:new URL("https://db.fauna.com"),local:new URL("http://localhost:8443"),localhost:new URL("http://localhost:8443")};var C=class extends Error{constructor(...e){super(...e)}},c=class extends C{httpStatus;code;queryInfo;constraint_failures;constructor(e,r){super(e.error.message),Error.captureStackTrace&&Error.captureStackTrace(this,c),this.name="ServiceError",this.code=e.error.code,this.httpStatus=r;let n={txn_ts:e.txn_ts,summary:e.summary,query_tags:e.query_tags,stats:e.stats};this.queryInfo=n,this.constraint_failures=e.error.constraint_failures}},H=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,H),this.name="QueryRuntimeError"}},P=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,P),this.name="QueryCheckError"}},N=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,N),this.name="InvalidRequestError"}},ne=class extends c{abort;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,P),this.name="AbortError",this.abort=e.error.abort}},F=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,F),this.name="AuthenticationError"}},M=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,M),this.name="AuthorizationError"}},se=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,N),this.name="ContendedTransactionError"}},W=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,W),this.name="ThrottlingError"}},v=class extends c{stats;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="QueryTimeoutError",this.stats=e.stats}},j=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,j),this.name="ServiceInternalError"}},$=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,$),this.name="ServiceTimeoutError"}},b=class extends C{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,b),this.name="ClientError"}},k=class extends C{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,k),this.name="ClientClosedError"}},w=class extends C{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,w),this.name="NetworkError"}},E=class extends C{httpStatus;constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,E),this.name="ProtocolError",this.httpStatus=e.httpStatus}};var oe=class{#e;#t;constructor({url:e,fetch_keepalive:r}){this.#e=new URL("/query/1",e).toString(),this.#t=r}async request({data:e,headers:r,method:n,client_timeout_ms:s}){let o=await fetch(this.#e,{method:n,headers:{...r,"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(s),keepalive:this.#t}).catch(l=>{throw new w("The network connection encountered a problem.",{cause:l})}),u=o.status,d={};o.headers.forEach((l,g)=>d[g]=l);let S=await o.text();return{status:u,body:S,headers:d}}close(){}};var L;try{L=_e("node:http2")}catch{L=void 0}var z,ie,ae,ue,I,f,me,Ve,J,le,pe,qe,fe,He,U=class{constructor({http2_session_idle_ms:e,url:r,http2_max_streams:n}){a(this,J);a(this,pe);a(this,fe);a(this,ie,void 0);a(this,ae,void 0);a(this,ue,void 0);a(this,I,0);a(this,f,void 0);if(L===void 0)throw new Error("Your platform does not support Node's http2 library");m(this,ie,e),m(this,ae,n),m(this,ue,r),m(this,f,null)}static getClient(e){var s;let r=p(s=U,me,Ve).call(s,e);i(U,z).has(r)||i(U,z).set(r,new U(e));let n=i(U,z).get(r);return Oe(n,I)._++,n}async request(e){let r=0,n;do try{return await p(this,fe,He).call(this,e)}catch(s){if(s?.code!=="ERR_HTTP2_GOAWAY_SESSION")throw new w("The network connection encountered a problem.",{cause:s});n=s,r++}while(r<3);throw new w("The network connection encountered a problem.",{cause:n})}close(){this.isClosed()||(Oe(this,I)._--,i(this,I)===0&&i(this,f)&&!i(this,f).closed&&i(this,f).close())}isClosed(){return i(this,I)===0}},G=U;z=new WeakMap,ie=new WeakMap,ae=new WeakMap,ue=new WeakMap,I=new WeakMap,f=new WeakMap,me=new WeakSet,Ve=function({http2_session_idle_ms:e,url:r}){return`${r}|${e}`},J=new WeakSet,le=function(){m(this,I,0),i(this,f)&&!i(this,f).closed&&i(this,f).close()},pe=new WeakSet,qe=function(){if(!i(this,f)||i(this,f).closed||i(this,f).destroyed){let e=L.connect(i(this,ue),{peerMaxConcurrentStreams:i(this,ae)}).once("error",()=>p(this,J,le).call(this)).once("goaway",()=>p(this,J,le).call(this));e.setTimeout(i(this,ie),()=>{p(this,J,le).call(this)}),m(this,f,e)}return i(this,f)},fe=new WeakSet,He=function({client_timeout_ms:e,data:r,headers:n,method:s}){return new Promise((o,u)=>{let d,S=l=>{let g=Number(l[L.constants.HTTP2_HEADER_STATUS]),x="";d.on("data",re=>{x+=re}),d.on("end",()=>{o({status:g,body:x,headers:l})})};try{let l={...n,[L.constants.HTTP2_HEADER_PATH]:"/query/1",[L.constants.HTTP2_HEADER_METHOD]:s};d=p(this,pe,qe).call(this).request(l).setEncoding("utf8").on("error",x=>{u(x)}).on("response",S),d.write(JSON.stringify(r),"utf8"),d.setTimeout(e,()=>{d.destroy(new Error("Client timeout"))}),d.end()}catch(l){u(l)}})},a(G,me),a(G,z,new Map);var Ce=t=>ot()?G.getClient(t):new oe(t),Pe=t=>t instanceof Object&&"body"in t&&"headers"in t&&"status"in t,ot=()=>{if(typeof process<"u"&&process&&process.release?.name==="node")try{return _e("node:http2"),!0}catch{return!1}return!1};var it=/(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/,at=/(?:0[1-9]|1[0-2])/,ut=/(?:0[1-9]|[12]\d|3[01])/,Fe=/(?:[01][0-9]|2[0-3])/,ce=/(?:[0-5][0-9])/,ct=/(?:\.\d+)/,Ne=new RegExp(`(${it.source}-(${at.source})-(${ut.source}))`),dt=new RegExp(`(${Fe.source}:${ce.source}:${ce.source}${ct.source}?)`),lt=new RegExp(`([zZ]|[+\u2212-]${Fe.source}(?::?${ce.source}|:${ce.source}:${ce.source}))`),Me=new RegExp(`^${Ne.source}$`),We=new RegExp(`^${Ne.source}`),ve=new RegExp(`^${Ne.source}T${dt.source}${lt.source}$`);var _=class{isoString;constructor(e){this.isoString=e}static from(e){if(typeof e!="string")throw new TypeError(`Expected string but received ${typeof e}: ${e}`);if(ve.exec(e)===null)throw new RangeError(`(regex) Expected an ISO date string but received '${e}'`);return new _(e)}static fromDate(e){return new _(e.toISOString())}toDate(){let e=new Date(this.isoString);if(e.toString()==="Invalid Date")throw new RangeError("Fauna Date could not be converted to Javascript Date");return e}toString(){return`TimeStub("${this.isoString}")`}},Q=class{dateString;constructor(e){this.dateString=e}static from(e){if(typeof e!="string")throw new TypeError(`Expected string but received ${typeof e}: ${e}`);let r=Me.exec(e);if(r===null)throw new RangeError(`Expected a plain date string but received '${e}'`);return new Q(r[0])}static fromDate(e){let r=e.toISOString(),n=We.exec(r);if(n===null)throw new b(`Failed to parse date '${e}'`);return new Q(n[0])}toDate(){let e=new Date(this.dateString+"T00:00:00Z");if(e.toString()==="Invalid Date")throw new RangeError("Fauna Date could not be converted to Javascript Date");return e}toString(){return`DateStub("${this.dateString}")`}};var A=class{coll;id;constructor({coll:e,id:r}){this.id=r,typeof e=="string"?this.coll=new D(e):this.coll=e}},K=class extends A{ts;constructor(e){let{coll:r,id:n,ts:s,...o}=e;super({coll:r,id:n}),this.ts=s,Object.assign(this,o)}toObject(){return{...this}}},B=class{coll;name;constructor({coll:e,name:r}){this.name=r,typeof e=="string"?this.coll=new D(e):this.coll=e}},Z=class extends B{ts;data;constructor(e){let{coll:r,name:n,ts:s,data:o,...u}=e;super({coll:r,name:n}),this.ts=s,this.data=o||{},Object.assign(this,u)}toObject(){return{...this}}},D=class{name;constructor(e){this.name=e}},ee=class{ref;cause;constructor(e,r){this.ref=e,this.cause=r}};var O=class{data;after;constructor({data:e,after:r}){this.data=e,this.after=r}},V=class{after;constructor(e){this.after=e}},R=class{#e;constructor(e,r,n){if(n=n??{},r instanceof Function)this.#e=pt(e,r,n);else if(r instanceof O||r instanceof V)this.#e=je(e,r,n);else throw new TypeError(`Expected 'Page<T> | EmbeddedSet | (() => Promise<T | Page<T> | EmbeddedSet>)', but received ${JSON.stringify(r)}`)}static fromQuery(e,r,n){return new R(e,async()=>(await e.query(r,n)).data,n)}static fromPageable(e,r,n){return new R(e,r,n)}flatten(){return new ke(this)}async next(){return this.#e.next()}async return(){return this.#e.return()}async throw(e){return this.#e.throw(e)}[Symbol.asyncIterator](){return this}},ke=class{#e;constructor(e){this.#e=ft(e)}async next(){return this.#e.next()}async return(){return this.#e.return()}async throw(e){return this.#e.throw(e)}[Symbol.asyncIterator](){return this}};async function*je(t,e,r){let n=e;for(n instanceof O&&(yield n.data);n.after;){let s=Ie`Set.paginate(${n.after})`;n=(await t.query(s,r)).data,yield n.data}}async function*pt(t,e,r){let n=await e();if(n instanceof O||n instanceof V){for await(let s of je(t,n,r))yield s;return}yield[n]}async function*ft(t){for await(let e of t)for(let r of e)yield r}var q=class{static encode(e){return ye(e)}static decode(e,r){return JSON.parse(e,(n,s)=>{if(s==null)return null;if(s["@mod"])return new D(s["@mod"]);if(s["@doc"]){if(typeof s["@doc"]=="string"){let[u,d]=s["@doc"].split(":");return new A({coll:u,id:d})}let o=s["@doc"];return o.id?new K(o):new Z(o)}else if(s["@ref"]){let o=s["@ref"],u;return o.id?u=new A(o):u=new B(o),"exists"in o&&o.exists===!1?new ee(u,o.cause):u}else{if(s["@set"])return typeof s["@set"]=="string"?new V(s["@set"]):new O(s["@set"]);if(s["@int"])return Number(s["@int"]);if(s["@long"]){let o=BigInt(s["@long"]);return r.long_type==="number"?((o>Number.MAX_SAFE_INTEGER||o<Number.MIN_SAFE_INTEGER)&&console.warn("Value is too large to be represented as a number. Returning as Number with loss of precision. Use long_type 'bigint' instead."),Number(o)):o}else{if(s["@double"])return Number(s["@double"]);if(s["@date"])return Q.from(s["@date"]);if(s["@time"])return _.from(s["@time"]);if(s["@object"])return s["@object"]}}return s})}},Ue=BigInt("-9223372036854775808"),Ge=BigInt("9223372036854775807"),$e=-(2**31),Le=2**31-1,y={bigint:t=>{if(t<Ue||t>Ge)throw new RangeError("BigInt value exceeds max magnitude for a 64-bit Fauna long. Use a 'number' to represent doubles beyond that limit.");return t>=$e&&t<=Le?{"@int":t.toString()}:{"@long":t.toString()}},number:t=>{if(t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY)throw new RangeError(`Cannot convert ${t} to a Fauna type.`);return Number.isInteger(t)?t>=$e&&t<=Le?{"@int":t.toString()}:Number.isSafeInteger(t)?{"@long":t.toString()}:{"@double":t.toString()}:{"@double":t.toString()}},string:t=>t,object:t=>{let e=!1,r={};for(let n in t)n.startsWith("@")&&(e=!0),t[n]!==void 0&&(r[n]=ye(t[n]));return e?{"@object":r}:r},array:t=>{let e=[];for(let r in t)e.push(ye(t[r]));return e},date:t=>({"@time":t.toISOString()}),faunadate:t=>({"@date":t.dateString}),faunatime:t=>({"@time":t.isoString}),module:t=>({"@mod":t.name}),documentReference:t=>({"@ref":{id:t.id,coll:{"@mod":t.coll.name}}}),document:t=>({"@ref":{id:t.id,coll:{"@mod":t.coll.name}}}),namedDocumentReference:t=>({"@ref":{name:t.name,coll:{"@mod":t.coll.name}}}),namedDocument:t=>({"@ref":{name:t.name,coll:{"@mod":t.coll.name}}}),set:t=>{throw new b("Page could not be encoded. Fauna does not accept encoded Set values, yet. Use Page.data and Page.after as arguments, instead.")}},ye=t=>{if(t===void 0)throw new TypeError("Passing undefined as a QueryValue is not supported");switch(typeof t){case"bigint":return y.bigint(t);case"string":return y.string(t);case"number":return y.number(t);case"boolean":return t;case"object":return t==null?null:Array.isArray(t)?y.array(t):t instanceof Date?y.date(t):t instanceof Q?y.faunadate(t):t instanceof _?y.faunatime(t):t instanceof D?y.module(t):t instanceof K?y.document(t):t instanceof A?y.documentReference(t):t instanceof Z?y.namedDocument(t):t instanceof B?y.namedDocumentReference(t):t instanceof ee?ye(t.ref):t instanceof O||t instanceof V?y.set(t):y.object(t)}};function Ie(t,...e){return new X(t,...e)}var X=class{#e;#t;constructor(e,...r){if(e.length===0||e.length!==r.length+1)throw new Error("invalid query constructed");this.#e=e,this.#t=r}toQuery(e={}){return{...this.#r(e),...e}}#r(e){if(this.#e.length===1)return{query:{fql:[this.#e[0]]},arguments:{}};let r={};return{query:{fql:this.#e.flatMap((s,o)=>{if(o===this.#e.length-1)return s===""?[]:[s];let u=this.#t[o],d;if(u instanceof X){let S=u.toQuery(e);d=S.query,r={...r,...S.arguments}}else d={value:q.encode(u)};return[s,d].filter(S=>S!=="")})},arguments:r}}};var Be="0.9.4";var ge;try{ge=_e("node:os")}catch{ge=void 0}var ze=()=>{let t={driver:["javascript",Be].join("-"),env:"unknown",os:"unknown",runtime:"unknown"};try{let e=typeof window>"u"&&typeof process<"u"&&process.versions!=null&&process.versions.node!=null,r=typeof window<"u"&&typeof window.document<"u",n=typeof self=="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope";e?(t.runtime=["nodejs",process.version].join("-"),t.env=gt(),t.os=[ge.platform(),ge.release()].join("-")):n?(t.runtime=Xe(navigator),t.env="Service Worker",t.os=Ye(navigator)):r?(t.runtime=Xe(navigator),t.env="browser",t.os=Ye(navigator)):typeof EdgeRuntime!="string"&&(t.runtime="Vercel Edge Runtime",t.env="edge")}catch{}return Object.entries(t).filter(([e,r])=>r!=="unknown").map(e=>e.join("=")).join("; ")},Xe=t=>{let e=t.appName,r=""+parseFloat(t.appVersion),n,s,o;return(s=t.userAgent.indexOf("Opera"))!=-1?(e="Opera",r=t.userAgent.substring(s+6),(s=t.userAgent.indexOf("Version"))!=-1&&(r=t.userAgent.substring(s+8))):(s=t.userAgent.indexOf("MSIE"))!=-1?(e="Microsoft Internet Explorer",r=t.userAgent.substring(s+5)):e=="Netscape"&&t.userAgent.indexOf("Trident/")!=-1?(e="Microsoft Internet Explorer",r=t.userAgent.substring(s+5),(s=t.userAgent.indexOf("rv:"))!=-1&&(r=t.userAgent.substring(s+3))):(s=t.userAgent.indexOf("Chrome"))!=-1?(e="Chrome",r=t.userAgent.substring(s+7)):(s=t.userAgent.indexOf("Safari"))!=-1?(e="Safari",r=t.userAgent.substring(s+7),(s=t.userAgent.indexOf("Version"))!=-1&&(r=t.userAgent.substring(s+8)),t.userAgent.indexOf("CriOS")!=-1&&(e="Chrome")):(s=t.userAgent.indexOf("Firefox"))!=-1?(e="Firefox",r=t.userAgent.substring(s+8)):(n=t.userAgent.lastIndexOf(" ")+1)<(s=t.userAgent.lastIndexOf("/"))&&(e=t.userAgent.substring(n,s),r=t.userAgent.substring(s+1),e.toLowerCase()==e.toUpperCase()&&(e=t.appName)),(o=r.indexOf(";"))!=-1&&(r=r.substring(0,o)),(o=r.indexOf(" "))!=-1&&(r=r.substring(0,o)),(o=r.indexOf(")"))!=-1&&(r=r.substring(0,o)),[e,r].join("-")},Ye=t=>{let e="unknown",r=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Chrome OS",r:/CrOS/},{s:"Linux",r:/(Linux|X11(?!.*CrOS))/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(let s in r){let o=r[s];if(o.r.test(t.userAgent)){e=o.s;break}}let n="unknown";if(/Windows/.test(e)){let s=/Windows (.*)/.exec(e);s&&(n=s[1]),e="Windows"}switch(e){case"Mac OS":case"Mac OS X":case"Android":{let s=/(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(t.userAgent);s&&(n=s[1]);break}case"iOS":{let s=/OS (\d+)_(\d+)_?(\d+)?/.exec(t.appVersion);s&&(n=s[1]+"."+s[2]+"."+(s[3]??0));break}}return[e,n].join("-")},yt=typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof global<"u"?global:self,gt=()=>{if(!(typeof process<"u"&&process&&process.env&&typeof process.env=="object"))return"unknown";let e=[{name:"Netlify",check:function(){return!!process.env.NETLIFY_IMAGES_CDN_DOMAIN}},{name:"Vercel",check:function(){return!!process.env.VERCEL}},{name:"Heroku",check:function(){return!!process.env.PATH&&process.env.PATH.indexOf(".heroku")!==-1}},{name:"AWS Lambda",check:function(){return!!process.env.AWS_LAMBDA_FUNCTION_VERSION}},{name:"GCP Cloud Functions",check:function(){return!!process.env._&&process.env._.indexOf("google")!==-1}},{name:"GCP Compute Instances",check:function(){return!!process.env.GOOGLE_CLOUD_PROJECT}},{name:"Azure Cloud Functions",check:function(){return!!process.env.WEBSITE_FUNCTIONS_AZUREMONITOR_CATEGORIES}},{name:"Azure Compute",check:function(){return!!process.env.ORYX_ENV_TYPE&&!!process.env.WEBSITE_INSTANCE_ID&&process.env.ORYX_ENV_TYPE==="AppService"}},{name:"Mongo Stitch",check:function(){return typeof yt?.StitchError=="function"}},{name:"Render",check:function(){return!!process.env.RENDER_SERVICE_ID}},{name:"Begin",check:function(){return!!process.env.BEGIN_DATA_SCOPE_ID}}].find(r=>r.check());return e?e.name:"unknown"};var Je=t=>t instanceof Object&&"data"in t,Ke=t=>t instanceof Object&&"error"in t&&t.error instanceof Object&&"code"in t.error&&"message"in t.error;var Tt={client_timeout_buffer_ms:5e3,endpoint:Re.default,format:"tagged",http2_session_idle_ms:5e3,http2_max_streams:100,long_type:"number",fetch_keepalive:!1,query_timeout_ms:5e3},he,T,Y,h,te,de,Ae,be,Ze,we,et,Se,tt,xe,rt,Ee,nt,De=class{constructor(e,r){a(this,de);a(this,be);a(this,we);a(this,Se);a(this,xe);a(this,Ee);a(this,T,void 0);a(this,Y,void 0);a(this,h,void 0);a(this,te,!1);m(this,T,{...Tt,...e,secret:p(this,be,Ze).call(this,e)}),p(this,Ee,nt).call(this),r?m(this,Y,r):m(this,Y,Ce({url:i(this,T).endpoint.toString(),http2_session_idle_ms:i(this,T).http2_session_idle_ms,http2_max_streams:i(this,T).http2_max_streams,fetch_keepalive:i(this,T).fetch_keepalive}))}get lastTxnTs(){return i(this,h)}set lastTxnTs(e){m(this,h,i(this,h)?Math.max(e,i(this,h)):e)}get clientConfiguration(){let{secret:e,...r}=i(this,T);return r}close(){if(i(this,te))throw new k("Your client is closed. You cannot close it again.");i(this,Y).close(),m(this,te,!0)}paginate(e,r){return e instanceof X?R.fromQuery(this,e,r):R.fromPageable(this,e,r)}async query(e,r){if(i(this,te))throw new k("Your client is closed. No further requests can be issued.");let n=e.toQuery(r).query;return p(this,Se,tt).call(this,n,r)}},Te=De;he=new WeakMap,T=new WeakMap,Y=new WeakMap,h=new WeakMap,te=new WeakMap,de=new WeakSet,Ae=function(e){if(e instanceof b||e instanceof w||e instanceof E||e instanceof c)return e;if(Pe(e)){if(Ke(e.body)){let r=e.body,n=e.status;return p(this,we,et).call(this,r,n)}return new E({message:`Response is in an unkown format: ${e.body}`,httpStatus:e.status})}return new b("A client level error occurred. Fauna was not called.",{cause:e})},be=new WeakSet,Ze=function(e){let r;typeof process<"u"&&process&&typeof process=="object"&&process.env&&typeof process.env=="object"&&(r=process.env.FAUNA_SECRET);let n=e?.secret||r;if(n===void 0)throw new Error("You must provide a secret to the driver. Set it in an environmental variable named FAUNA_SECRET or pass it to the Client constructor.");return n},we=new WeakSet,et=function(e,r){switch(r){case 400:return ht.includes(e.error.code)?new P(e,r):e.error.code==="invalid_request"?new N(e,r):e.error.code==="abort"&&e.error.abort!==void 0?new ne(e,r):new H(e,r);case 401:return new F(e,r);case 403:return new M(e,r);case 409:return new se(e,r);case 429:return new W(e,r);case 440:return new v(e,r);case 500:return new j(e,r);case 503:return new $(e,r);default:return new c(e,r)}},Se=new WeakSet,tt=async function(e,r){try{let n={...i(this,T),...r},s={Authorization:`Bearer ${i(this,T).secret}`};p(this,xe,rt).call(this,n,s);let o=n.format==="tagged",u=n.arguments?o?q.encode(n.arguments):n.arguments:void 0,d={query:e,arguments:u},S=n.query_timeout_ms+i(this,T).client_timeout_buffer_ms,l=await i(this,Y).request({client_timeout_ms:S,data:d,headers:s,method:"POST"}),g;try{if(g={...l,body:o?q.decode(l.body,{long_type:n.long_type}):JSON.parse(l.body)},g.body.query_tags){let re=g.body.query_tags.split(",").map(st=>st.split("="));g.body.query_tags=Object.fromEntries(re)}}catch(re){throw new E({message:`Error parsing response as JSON: ${re}`,httpStatus:l.status})}if(!Je(g.body))throw p(this,de,Ae).call(this,g);let x=g.body.txn_ts;return(i(this,h)===void 0&&x!==void 0||x!==void 0&&i(this,h)!==void 0&&i(this,h)<x)&&m(this,h,x),g.body}catch(n){throw p(this,de,Ae).call(this,n)}},xe=new WeakSet,rt=function(e,r){for(let n of Object.entries(e))if(["format","query_timeout_ms","linearized","max_contention_retries","traceparent","typecheck","query_tags"].includes(n[0])){let s,o=`x-${n[0].replaceAll("_","-")}`;n[0]==="query_tags"?s=Object.entries(n[1]).map(u=>u.join("=")).join(","):typeof n[1]=="string"?s=n[1]:s=String(n[1]),n[0]==="traceparent"&&(o=n[0]),r[o]=s}r["x-last-txn-ts"]===void 0&&i(this,h)!==void 0&&(r["x-last-txn-ts"]=i(this,h)),r["x-driver-env"]=i(De,he)},Ee=new WeakSet,nt=function(){let e=i(this,T);if(["client_timeout_buffer_ms","endpoint","format","http2_session_idle_ms","long_type","query_timeout_ms","fetch_keepalive","http2_max_streams"].forEach(n=>{if(e[n]===void 0)throw new TypeError(`ClientConfiguration option '${n}' must be defined.`)}),e.http2_max_streams<=0)throw new RangeError("'http2_max_streams' must be greater than zero.");if(e.client_timeout_buffer_ms<=0)throw new RangeError("'client_timeout_buffer_ms' must be greater than zero.");if(e.query_timeout_ms<=0)throw new RangeError("'query_timeout_ms' must be greater than zero.")},a(Te,he,ze());var ht=["invalid_function_definition","invalid_identifier","invalid_query","invalid_syntax","invalid_type"];export{ne as AbortError,F as AuthenticationError,M as AuthorizationError,Te as Client,k as ClientClosedError,b as ClientError,se as ContendedTransactionError,Q as DateStub,K as Document,A as DocumentReference,V as EmbeddedSet,C as FaunaError,oe as FetchClient,N as InvalidRequestError,Ge as LONG_MAX,Ue as LONG_MIN,D as Module,Z as NamedDocument,B as NamedDocumentReference,w as NetworkError,G as NodeHTTP2Client,ee as NullDocument,O as Page,E as ProtocolError,P as QueryCheckError,H as QueryRuntimeError,v as QueryTimeoutError,c as ServiceError,j as ServiceInternalError,$ as ServiceTimeoutError,R as SetIterator,q as TaggedTypeFormat,W as ThrottlingError,_ as TimeStub,Re as endpoints,Ie as fql,Ce as getDefaultHTTPClient,Pe as isHTTPResponse}; | ||
var _e=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Qe=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var i=(t,e,r)=>(Qe(t,e,"read from private field"),r?r.call(t):e.get(t)),a=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},m=(t,e,r,n)=>(Qe(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Oe=(t,e,r,n)=>({set _(s){m(t,e,s,r)},get _(){return i(t,e,n)}}),p=(t,e,r)=>(Qe(t,e,"access private method"),r);var Re={default:new URL("https://db.fauna.com"),local:new URL("http://localhost:8443"),localhost:new URL("http://localhost:8443")};var C=class extends Error{constructor(...e){super(...e)}},c=class extends C{httpStatus;code;queryInfo;constraint_failures;constructor(e,r){super(e.error.message),Error.captureStackTrace&&Error.captureStackTrace(this,c),this.name="ServiceError",this.code=e.error.code,this.httpStatus=r;let n={txn_ts:e.txn_ts,summary:e.summary,query_tags:e.query_tags,stats:e.stats};this.queryInfo=n,this.constraint_failures=e.error.constraint_failures}},H=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,H),this.name="QueryRuntimeError"}},P=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,P),this.name="QueryCheckError"}},N=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,N),this.name="InvalidRequestError"}},ne=class extends c{abort;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,P),this.name="AbortError",this.abort=e.error.abort}},F=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,F),this.name="AuthenticationError"}},M=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,M),this.name="AuthorizationError"}},se=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,N),this.name="ContendedTransactionError"}},W=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,W),this.name="ThrottlingError"}},v=class extends c{stats;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="QueryTimeoutError",this.stats=e.stats}},j=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,j),this.name="ServiceInternalError"}},$=class extends c{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,$),this.name="ServiceTimeoutError"}},b=class extends C{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,b),this.name="ClientError"}},k=class extends C{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,k),this.name="ClientClosedError"}},w=class extends C{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,w),this.name="NetworkError"}},E=class extends C{httpStatus;constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,E),this.name="ProtocolError",this.httpStatus=e.httpStatus}};var oe=class{#e;#t;constructor({url:e,fetch_keepalive:r}){this.#e=new URL("/query/1",e).toString(),this.#t=r}async request({data:e,headers:r,method:n,client_timeout_ms:s}){let o=await fetch(this.#e,{method:n,headers:{...r,"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(s),keepalive:this.#t}).catch(l=>{throw new w("The network connection encountered a problem.",{cause:l})}),u=o.status,d={};o.headers.forEach((l,g)=>d[g]=l);let S=await o.text();return{status:u,body:S,headers:d}}close(){}};var L;try{L=_e("node:http2")}catch{L=void 0}var z,ie,ae,ue,I,f,me,Ve,J,le,pe,qe,fe,He,U=class{constructor({http2_session_idle_ms:e,url:r,http2_max_streams:n}){a(this,J);a(this,pe);a(this,fe);a(this,ie,void 0);a(this,ae,void 0);a(this,ue,void 0);a(this,I,0);a(this,f,void 0);if(L===void 0)throw new Error("Your platform does not support Node's http2 library");m(this,ie,e),m(this,ae,n),m(this,ue,r),m(this,f,null)}static getClient(e){var s;let r=p(s=U,me,Ve).call(s,e);i(U,z).has(r)||i(U,z).set(r,new U(e));let n=i(U,z).get(r);return Oe(n,I)._++,n}async request(e){let r=0,n;do try{return await p(this,fe,He).call(this,e)}catch(s){if(s?.code!=="ERR_HTTP2_GOAWAY_SESSION")throw new w("The network connection encountered a problem.",{cause:s});n=s,r++}while(r<3);throw new w("The network connection encountered a problem.",{cause:n})}close(){this.isClosed()||(Oe(this,I)._--,i(this,I)===0&&i(this,f)&&!i(this,f).closed&&i(this,f).close())}isClosed(){return i(this,I)===0}},G=U;z=new WeakMap,ie=new WeakMap,ae=new WeakMap,ue=new WeakMap,I=new WeakMap,f=new WeakMap,me=new WeakSet,Ve=function({http2_session_idle_ms:e,url:r}){return`${r}|${e}`},J=new WeakSet,le=function(){m(this,I,0),i(this,f)&&!i(this,f).closed&&i(this,f).close()},pe=new WeakSet,qe=function(){if(!i(this,f)||i(this,f).closed||i(this,f).destroyed){let e=L.connect(i(this,ue),{peerMaxConcurrentStreams:i(this,ae)}).once("error",()=>p(this,J,le).call(this)).once("goaway",()=>p(this,J,le).call(this));e.setTimeout(i(this,ie),()=>{p(this,J,le).call(this)}),m(this,f,e)}return i(this,f)},fe=new WeakSet,He=function({client_timeout_ms:e,data:r,headers:n,method:s}){return new Promise((o,u)=>{let d,S=l=>{let g=Number(l[L.constants.HTTP2_HEADER_STATUS]),x="";d.on("data",re=>{x+=re}),d.on("end",()=>{o({status:g,body:x,headers:l})})};try{let l={...n,[L.constants.HTTP2_HEADER_PATH]:"/query/1",[L.constants.HTTP2_HEADER_METHOD]:s};d=p(this,pe,qe).call(this).request(l).setEncoding("utf8").on("error",x=>{u(x)}).on("response",S),d.write(JSON.stringify(r),"utf8"),d.setTimeout(e,()=>{d.destroy(new Error("Client timeout"))}),d.end()}catch(l){u(l)}})},a(G,me),a(G,z,new Map);var Ce=t=>ot()?G.getClient(t):new oe(t),Pe=t=>t instanceof Object&&"body"in t&&"headers"in t&&"status"in t,ot=()=>{if(typeof process<"u"&&process&&process.release?.name==="node")try{return _e("node:http2"),!0}catch{return!1}return!1};var it=/(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/,at=/(?:0[1-9]|1[0-2])/,ut=/(?:0[1-9]|[12]\d|3[01])/,Fe=/(?:[01][0-9]|2[0-3])/,ce=/(?:[0-5][0-9])/,ct=/(?:\.\d+)/,Ne=new RegExp(`(${it.source}-(${at.source})-(${ut.source}))`),dt=new RegExp(`(${Fe.source}:${ce.source}:${ce.source}${ct.source}?)`),lt=new RegExp(`([zZ]|[+\u2212-]${Fe.source}(?::?${ce.source}|:${ce.source}:${ce.source}))`),Me=new RegExp(`^${Ne.source}$`),We=new RegExp(`^${Ne.source}`),ve=new RegExp(`^${Ne.source}T${dt.source}${lt.source}$`);var _=class{isoString;constructor(e){this.isoString=e}static from(e){if(typeof e!="string")throw new TypeError(`Expected string but received ${typeof e}: ${e}`);if(ve.exec(e)===null)throw new RangeError(`(regex) Expected an ISO date string but received '${e}'`);return new _(e)}static fromDate(e){return new _(e.toISOString())}toDate(){let e=new Date(this.isoString);if(e.toString()==="Invalid Date")throw new RangeError("Fauna Date could not be converted to Javascript Date");return e}toString(){return`TimeStub("${this.isoString}")`}},Q=class{dateString;constructor(e){this.dateString=e}static from(e){if(typeof e!="string")throw new TypeError(`Expected string but received ${typeof e}: ${e}`);let r=Me.exec(e);if(r===null)throw new RangeError(`Expected a plain date string but received '${e}'`);return new Q(r[0])}static fromDate(e){let r=e.toISOString(),n=We.exec(r);if(n===null)throw new b(`Failed to parse date '${e}'`);return new Q(n[0])}toDate(){let e=new Date(this.dateString+"T00:00:00Z");if(e.toString()==="Invalid Date")throw new RangeError("Fauna Date could not be converted to Javascript Date");return e}toString(){return`DateStub("${this.dateString}")`}};var A=class{coll;id;constructor({coll:e,id:r}){this.id=r,typeof e=="string"?this.coll=new D(e):this.coll=e}},K=class extends A{ts;constructor(e){let{coll:r,id:n,ts:s,...o}=e;super({coll:r,id:n}),this.ts=s,Object.assign(this,o)}toObject(){return{...this}}},B=class{coll;name;constructor({coll:e,name:r}){this.name=r,typeof e=="string"?this.coll=new D(e):this.coll=e}},Z=class extends B{ts;data;constructor(e){let{coll:r,name:n,ts:s,data:o,...u}=e;super({coll:r,name:n}),this.ts=s,this.data=o||{},Object.assign(this,u)}toObject(){return{...this}}},D=class{name;constructor(e){this.name=e}},ee=class{ref;cause;constructor(e,r){this.ref=e,this.cause=r}};var O=class{data;after;constructor({data:e,after:r}){this.data=e,this.after=r}},V=class{after;constructor(e){this.after=e}},R=class{#e;constructor(e,r,n){if(n=n??{},r instanceof Function)this.#e=pt(e,r,n);else if(r instanceof O||r instanceof V)this.#e=je(e,r,n);else throw new TypeError(`Expected 'Page<T> | EmbeddedSet | (() => Promise<T | Page<T> | EmbeddedSet>)', but received ${JSON.stringify(r)}`)}static fromQuery(e,r,n){return new R(e,async()=>(await e.query(r,n)).data,n)}static fromPageable(e,r,n){return new R(e,r,n)}flatten(){return new ke(this)}async next(){return this.#e.next()}async return(){return this.#e.return()}async throw(e){return this.#e.throw(e)}[Symbol.asyncIterator](){return this}},ke=class{#e;constructor(e){this.#e=ft(e)}async next(){return this.#e.next()}async return(){return this.#e.return()}async throw(e){return this.#e.throw(e)}[Symbol.asyncIterator](){return this}};async function*je(t,e,r){let n=e;for(n instanceof O&&(yield n.data);n.after;){let s=Ie`Set.paginate(${n.after})`;n=(await t.query(s,r)).data,yield n.data}}async function*pt(t,e,r){let n=await e();if(n instanceof O||n instanceof V){for await(let s of je(t,n,r))yield s;return}yield[n]}async function*ft(t){for await(let e of t)for(let r of e)yield r}var q=class{static encode(e){return ye(e)}static decode(e,r){return JSON.parse(e,(n,s)=>{if(s==null)return null;if(s["@mod"])return new D(s["@mod"]);if(s["@doc"]){if(typeof s["@doc"]=="string"){let[u,d]=s["@doc"].split(":");return new A({coll:u,id:d})}let o=s["@doc"];return o.id?new K(o):new Z(o)}else if(s["@ref"]){let o=s["@ref"],u;return o.id?u=new A(o):u=new B(o),"exists"in o&&o.exists===!1?new ee(u,o.cause):u}else{if(s["@set"])return typeof s["@set"]=="string"?new V(s["@set"]):new O(s["@set"]);if(s["@int"])return Number(s["@int"]);if(s["@long"]){let o=BigInt(s["@long"]);return r.long_type==="number"?((o>Number.MAX_SAFE_INTEGER||o<Number.MIN_SAFE_INTEGER)&&console.warn("Value is too large to be represented as a number. Returning as Number with loss of precision. Use long_type 'bigint' instead."),Number(o)):o}else{if(s["@double"])return Number(s["@double"]);if(s["@date"])return Q.from(s["@date"]);if(s["@time"])return _.from(s["@time"]);if(s["@object"])return s["@object"]}}return s})}},Ue=BigInt("-9223372036854775808"),Ge=BigInt("9223372036854775807"),$e=-(2**31),Le=2**31-1,y={bigint:t=>{if(t<Ue||t>Ge)throw new RangeError("BigInt value exceeds max magnitude for a 64-bit Fauna long. Use a 'number' to represent doubles beyond that limit.");return t>=$e&&t<=Le?{"@int":t.toString()}:{"@long":t.toString()}},number:t=>{if(t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY)throw new RangeError(`Cannot convert ${t} to a Fauna type.`);return Number.isInteger(t)?t>=$e&&t<=Le?{"@int":t.toString()}:Number.isSafeInteger(t)?{"@long":t.toString()}:{"@double":t.toString()}:{"@double":t.toString()}},string:t=>t,object:t=>{let e=!1,r={};for(let n in t)n.startsWith("@")&&(e=!0),t[n]!==void 0&&(r[n]=ye(t[n]));return e?{"@object":r}:r},array:t=>{let e=[];for(let r in t)e.push(ye(t[r]));return e},date:t=>({"@time":t.toISOString()}),faunadate:t=>({"@date":t.dateString}),faunatime:t=>({"@time":t.isoString}),module:t=>({"@mod":t.name}),documentReference:t=>({"@ref":{id:t.id,coll:{"@mod":t.coll.name}}}),document:t=>({"@ref":{id:t.id,coll:{"@mod":t.coll.name}}}),namedDocumentReference:t=>({"@ref":{name:t.name,coll:{"@mod":t.coll.name}}}),namedDocument:t=>({"@ref":{name:t.name,coll:{"@mod":t.coll.name}}}),set:t=>{throw new b("Page could not be encoded. Fauna does not accept encoded Set values, yet. Use Page.data and Page.after as arguments, instead.")}},ye=t=>{if(t===void 0)throw new TypeError("Passing undefined as a QueryValue is not supported");switch(typeof t){case"bigint":return y.bigint(t);case"string":return y.string(t);case"number":return y.number(t);case"boolean":return t;case"object":return t==null?null:Array.isArray(t)?y.array(t):t instanceof Date?y.date(t):t instanceof Q?y.faunadate(t):t instanceof _?y.faunatime(t):t instanceof D?y.module(t):t instanceof K?y.document(t):t instanceof A?y.documentReference(t):t instanceof Z?y.namedDocument(t):t instanceof B?y.namedDocumentReference(t):t instanceof ee?ye(t.ref):t instanceof O||t instanceof V?y.set(t):y.object(t)}};function Ie(t,...e){return new X(t,...e)}var X=class{#e;#t;constructor(e,...r){if(e.length===0||e.length!==r.length+1)throw new Error("invalid query constructed");this.#e=e,this.#t=r}toQuery(e={}){return{...this.#r(e),...e}}#r(e){if(this.#e.length===1)return{query:{fql:[this.#e[0]]},arguments:{}};let r={};return{query:{fql:this.#e.flatMap((s,o)=>{if(o===this.#e.length-1)return s===""?[]:[s];let u=this.#t[o],d;if(u instanceof X){let S=u.toQuery(e);d=S.query,r={...r,...S.arguments}}else d={value:q.encode(u)};return[s,d].filter(S=>S!=="")})},arguments:r}}};var Be="1.0.0";var ge;try{ge=_e("node:os")}catch{ge=void 0}var ze=()=>{let t={driver:["javascript",Be].join("-"),env:"unknown",os:"unknown",runtime:"unknown"};try{let e=typeof window>"u"&&typeof process<"u"&&process.versions!=null&&process.versions.node!=null,r=typeof window<"u"&&typeof window.document<"u",n=typeof self=="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope";e?(t.runtime=["nodejs",process.version].join("-"),t.env=gt(),t.os=[ge.platform(),ge.release()].join("-")):n?(t.runtime=Xe(navigator),t.env="Service Worker",t.os=Ye(navigator)):r?(t.runtime=Xe(navigator),t.env="browser",t.os=Ye(navigator)):typeof EdgeRuntime!="string"&&(t.runtime="Vercel Edge Runtime",t.env="edge")}catch{}return Object.entries(t).filter(([e,r])=>r!=="unknown").map(e=>e.join("=")).join("; ")},Xe=t=>{let e=t.appName,r=""+parseFloat(t.appVersion),n,s,o;return(s=t.userAgent.indexOf("Opera"))!=-1?(e="Opera",r=t.userAgent.substring(s+6),(s=t.userAgent.indexOf("Version"))!=-1&&(r=t.userAgent.substring(s+8))):(s=t.userAgent.indexOf("MSIE"))!=-1?(e="Microsoft Internet Explorer",r=t.userAgent.substring(s+5)):e=="Netscape"&&t.userAgent.indexOf("Trident/")!=-1?(e="Microsoft Internet Explorer",r=t.userAgent.substring(s+5),(s=t.userAgent.indexOf("rv:"))!=-1&&(r=t.userAgent.substring(s+3))):(s=t.userAgent.indexOf("Chrome"))!=-1?(e="Chrome",r=t.userAgent.substring(s+7)):(s=t.userAgent.indexOf("Safari"))!=-1?(e="Safari",r=t.userAgent.substring(s+7),(s=t.userAgent.indexOf("Version"))!=-1&&(r=t.userAgent.substring(s+8)),t.userAgent.indexOf("CriOS")!=-1&&(e="Chrome")):(s=t.userAgent.indexOf("Firefox"))!=-1?(e="Firefox",r=t.userAgent.substring(s+8)):(n=t.userAgent.lastIndexOf(" ")+1)<(s=t.userAgent.lastIndexOf("/"))&&(e=t.userAgent.substring(n,s),r=t.userAgent.substring(s+1),e.toLowerCase()==e.toUpperCase()&&(e=t.appName)),(o=r.indexOf(";"))!=-1&&(r=r.substring(0,o)),(o=r.indexOf(" "))!=-1&&(r=r.substring(0,o)),(o=r.indexOf(")"))!=-1&&(r=r.substring(0,o)),[e,r].join("-")},Ye=t=>{let e="unknown",r=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Chrome OS",r:/CrOS/},{s:"Linux",r:/(Linux|X11(?!.*CrOS))/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(let s in r){let o=r[s];if(o.r.test(t.userAgent)){e=o.s;break}}let n="unknown";if(/Windows/.test(e)){let s=/Windows (.*)/.exec(e);s&&(n=s[1]),e="Windows"}switch(e){case"Mac OS":case"Mac OS X":case"Android":{let s=/(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(t.userAgent);s&&(n=s[1]);break}case"iOS":{let s=/OS (\d+)_(\d+)_?(\d+)?/.exec(t.appVersion);s&&(n=s[1]+"."+s[2]+"."+(s[3]??0));break}}return[e,n].join("-")},yt=typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof global<"u"?global:self,gt=()=>{if(!(typeof process<"u"&&process&&process.env&&typeof process.env=="object"))return"unknown";let e=[{name:"Netlify",check:function(){return!!process.env.NETLIFY_IMAGES_CDN_DOMAIN}},{name:"Vercel",check:function(){return!!process.env.VERCEL}},{name:"Heroku",check:function(){return!!process.env.PATH&&process.env.PATH.indexOf(".heroku")!==-1}},{name:"AWS Lambda",check:function(){return!!process.env.AWS_LAMBDA_FUNCTION_VERSION}},{name:"GCP Cloud Functions",check:function(){return!!process.env._&&process.env._.indexOf("google")!==-1}},{name:"GCP Compute Instances",check:function(){return!!process.env.GOOGLE_CLOUD_PROJECT}},{name:"Azure Cloud Functions",check:function(){return!!process.env.WEBSITE_FUNCTIONS_AZUREMONITOR_CATEGORIES}},{name:"Azure Compute",check:function(){return!!process.env.ORYX_ENV_TYPE&&!!process.env.WEBSITE_INSTANCE_ID&&process.env.ORYX_ENV_TYPE==="AppService"}},{name:"Mongo Stitch",check:function(){return typeof yt?.StitchError=="function"}},{name:"Render",check:function(){return!!process.env.RENDER_SERVICE_ID}},{name:"Begin",check:function(){return!!process.env.BEGIN_DATA_SCOPE_ID}}].find(r=>r.check());return e?e.name:"unknown"};var Je=t=>t instanceof Object&&"data"in t,Ke=t=>t instanceof Object&&"error"in t&&t.error instanceof Object&&"code"in t.error&&"message"in t.error;var Tt={client_timeout_buffer_ms:5e3,endpoint:Re.default,format:"tagged",http2_session_idle_ms:5e3,http2_max_streams:100,long_type:"number",fetch_keepalive:!1,query_timeout_ms:5e3},he,T,Y,h,te,de,Ae,be,Ze,we,et,Se,tt,xe,rt,Ee,nt,De=class{constructor(e,r){a(this,de);a(this,be);a(this,we);a(this,Se);a(this,xe);a(this,Ee);a(this,T,void 0);a(this,Y,void 0);a(this,h,void 0);a(this,te,!1);m(this,T,{...Tt,...e,secret:p(this,be,Ze).call(this,e)}),p(this,Ee,nt).call(this),r?m(this,Y,r):m(this,Y,Ce({url:i(this,T).endpoint.toString(),http2_session_idle_ms:i(this,T).http2_session_idle_ms,http2_max_streams:i(this,T).http2_max_streams,fetch_keepalive:i(this,T).fetch_keepalive}))}get lastTxnTs(){return i(this,h)}set lastTxnTs(e){m(this,h,i(this,h)?Math.max(e,i(this,h)):e)}get clientConfiguration(){let{secret:e,...r}=i(this,T);return r}close(){if(i(this,te))throw new k("Your client is closed. You cannot close it again.");i(this,Y).close(),m(this,te,!0)}paginate(e,r){return e instanceof X?R.fromQuery(this,e,r):R.fromPageable(this,e,r)}async query(e,r){if(i(this,te))throw new k("Your client is closed. No further requests can be issued.");let n=e.toQuery(r).query;return p(this,Se,tt).call(this,n,r)}},Te=De;he=new WeakMap,T=new WeakMap,Y=new WeakMap,h=new WeakMap,te=new WeakMap,de=new WeakSet,Ae=function(e){if(e instanceof b||e instanceof w||e instanceof E||e instanceof c)return e;if(Pe(e)){if(Ke(e.body)){let r=e.body,n=e.status;return p(this,we,et).call(this,r,n)}return new E({message:`Response is in an unkown format: ${e.body}`,httpStatus:e.status})}return new b("A client level error occurred. Fauna was not called.",{cause:e})},be=new WeakSet,Ze=function(e){let r;typeof process<"u"&&process&&typeof process=="object"&&process.env&&typeof process.env=="object"&&(r=process.env.FAUNA_SECRET);let n=e?.secret||r;if(n===void 0)throw new Error("You must provide a secret to the driver. Set it in an environmental variable named FAUNA_SECRET or pass it to the Client constructor.");return n},we=new WeakSet,et=function(e,r){switch(r){case 400:return ht.includes(e.error.code)?new P(e,r):e.error.code==="invalid_request"?new N(e,r):e.error.code==="abort"&&e.error.abort!==void 0?new ne(e,r):new H(e,r);case 401:return new F(e,r);case 403:return new M(e,r);case 409:return new se(e,r);case 429:return new W(e,r);case 440:return new v(e,r);case 500:return new j(e,r);case 503:return new $(e,r);default:return new c(e,r)}},Se=new WeakSet,tt=async function(e,r){try{let n={...i(this,T),...r},s={Authorization:`Bearer ${i(this,T).secret}`};p(this,xe,rt).call(this,n,s);let o=n.format==="tagged",u=n.arguments?o?q.encode(n.arguments):n.arguments:void 0,d={query:e,arguments:u},S=n.query_timeout_ms+i(this,T).client_timeout_buffer_ms,l=await i(this,Y).request({client_timeout_ms:S,data:d,headers:s,method:"POST"}),g;try{if(g={...l,body:o?q.decode(l.body,{long_type:n.long_type}):JSON.parse(l.body)},g.body.query_tags){let re=g.body.query_tags.split(",").map(st=>st.split("="));g.body.query_tags=Object.fromEntries(re)}}catch(re){throw new E({message:`Error parsing response as JSON: ${re}`,httpStatus:l.status})}if(!Je(g.body))throw p(this,de,Ae).call(this,g);let x=g.body.txn_ts;return(i(this,h)===void 0&&x!==void 0||x!==void 0&&i(this,h)!==void 0&&i(this,h)<x)&&m(this,h,x),g.body}catch(n){throw p(this,de,Ae).call(this,n)}},xe=new WeakSet,rt=function(e,r){for(let n of Object.entries(e))if(["format","query_timeout_ms","linearized","max_contention_retries","traceparent","typecheck","query_tags"].includes(n[0])){let s,o=`x-${n[0].replaceAll("_","-")}`;n[0]==="query_tags"?s=Object.entries(n[1]).map(u=>u.join("=")).join(","):typeof n[1]=="string"?s=n[1]:s=String(n[1]),n[0]==="traceparent"&&(o=n[0]),r[o]=s}r["x-last-txn-ts"]===void 0&&i(this,h)!==void 0&&(r["x-last-txn-ts"]=i(this,h)),r["x-driver-env"]=i(De,he)},Ee=new WeakSet,nt=function(){let e=i(this,T);if(["client_timeout_buffer_ms","endpoint","format","http2_session_idle_ms","long_type","query_timeout_ms","fetch_keepalive","http2_max_streams"].forEach(n=>{if(e[n]===void 0)throw new TypeError(`ClientConfiguration option '${n}' must be defined.`)}),e.http2_max_streams<=0)throw new RangeError("'http2_max_streams' must be greater than zero.");if(e.client_timeout_buffer_ms<=0)throw new RangeError("'client_timeout_buffer_ms' must be greater than zero.");if(e.query_timeout_ms<=0)throw new RangeError("'query_timeout_ms' must be greater than zero.")},a(Te,he,ze());var ht=["invalid_function_definition","invalid_identifier","invalid_query","invalid_syntax","invalid_type"];export{ne as AbortError,F as AuthenticationError,M as AuthorizationError,Te as Client,k as ClientClosedError,b as ClientError,se as ContendedTransactionError,Q as DateStub,K as Document,A as DocumentReference,V as EmbeddedSet,C as FaunaError,oe as FetchClient,N as InvalidRequestError,Ge as LONG_MAX,Ue as LONG_MIN,D as Module,Z as NamedDocument,B as NamedDocumentReference,w as NetworkError,G as NodeHTTP2Client,ee as NullDocument,O as Page,E as ProtocolError,P as QueryCheckError,H as QueryRuntimeError,v as QueryTimeoutError,c as ServiceError,j as ServiceInternalError,$ as ServiceTimeoutError,R as SetIterator,q as TaggedTypeFormat,W as ThrottlingError,_ as TimeStub,Re as endpoints,Ie as fql,Ce as getDefaultHTTPClient,Pe as isHTTPResponse}; | ||
//# sourceMappingURL=index.js.map |
@@ -68,5 +68,3 @@ import type { ValueFormat } from "./wire-protocol"; | ||
* The timeout of each query, in milliseconds. This controls the maximum amount of | ||
* time Fauna will execute your query before marking it failed. | ||
* Default is undefined which let's Fauna determine the query timeout to apply. This | ||
* is recommended for most queries. The default is 5000 ms. | ||
* time Fauna will execute your query before marking it failed. The default is 5000 ms. | ||
*/ | ||
@@ -73,0 +71,0 @@ query_timeout_ms?: number; |
@@ -1000,3 +1000,3 @@ "use strict"; | ||
// src/util/package-version.ts | ||
var packageVersion = "0.9.4"; | ||
var packageVersion = "1.0.0"; | ||
@@ -1003,0 +1003,0 @@ // src/util/environment.ts |
/** The current package version. */ | ||
export declare const packageVersion = "0.9.4"; | ||
export declare const packageVersion = "1.0.0"; |
{ | ||
"name": "fauna", | ||
"version": "0.9.4", | ||
"version": "1.0.0", | ||
"description": "A driver to query Fauna databases in browsers, Node.js, and other Javascript runtimes", | ||
@@ -5,0 +5,0 @@ "homepage": "https://fauna.com", |
@@ -1,13 +0,10 @@ | ||
> **WARNING** | ||
> This driver is in beta release and not recommended for production use. It operates with the Fauna database service via an API which is also in beta release, and is not recommended for production use. This driver is not compatible with v4 or earlier versions of Fauna. Please feel free to contact product@fauna.com to learn about our special Early Access program for FQL v10. | ||
# The Official Javascript Driver for [Fauna](https://fauna.com). | ||
# A JavaScript driver for [Fauna](https://fauna.com). | ||
[![Npm Version](https://img.shields.io/npm/v/fauna.svg?maxAge=21600)](https://www.npmjs.com/package/fauna) | ||
[![License](https://img.shields.io/badge/license-MPL_2.0-blue.svg?maxAge=2592000)](https://raw.githubusercontent.com/fauna/fauna-js/main/LICENSE) | ||
See the [Fauna Documentation](https://fqlx-beta--fauna-docs.netlify.app/fqlx/beta/) for additional information how to configure and query your databases. | ||
This driver can only be used with FQL v10, and is not compatible with earlier versions of FQL. To query your databases with earlier API versions, see the [faunadb](https://www.npmjs.com/package/faunadb) package. | ||
See the [Fauna Documentation](https://docs.fauna.com/fauna/current/) for additional information how to configure and query your databases. | ||
<details> | ||
@@ -19,3 +16,3 @@ <summary>Table of Contents</summary> | ||
- [Supported Runtimes](#supported-runtimes) | ||
- [Installing](#installing) | ||
- [Installation](#installation) | ||
- [Package Manager](#package-manager) | ||
@@ -101,3 +98,3 @@ - [Via CDN](#via-cdn) | ||
# Installing | ||
# Installation | ||
@@ -104,0 +101,0 @@ ## Package Manager |
@@ -78,5 +78,3 @@ import type { ValueFormat } from "./wire-protocol"; | ||
* The timeout of each query, in milliseconds. This controls the maximum amount of | ||
* time Fauna will execute your query before marking it failed. | ||
* Default is undefined which let's Fauna determine the query timeout to apply. This | ||
* is recommended for most queries. The default is 5000 ms. | ||
* time Fauna will execute your query before marking it failed. The default is 5000 ms. | ||
*/ | ||
@@ -83,0 +81,0 @@ query_timeout_ms?: number; |
//THIS FILE IS AUTOGENERATED. DO NOT EDIT. SEE .husky/pre-commit | ||
/** The current package version. */ | ||
export const packageVersion = "0.9.4"; | ||
export const packageVersion = "1.0.0"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
497722
5932
418