Comparing version 0.7.1 to 0.7.2
@@ -1,2 +0,2 @@ | ||
var be=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var de=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var u=(r,e,t)=>(de(r,e,"read from private field"),t?t.call(r):e.get(r)),g=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},I=(r,e,t,n)=>(de(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),le=(r,e,t,n)=>({set _(s){I(r,e,s,t)},get _(){return u(r,e,n)}}),k=(r,e,t)=>(de(r,e,"access private method"),t);var me={default:new URL("https://db.fauna.com"),local:new URL("http://localhost:8443"),localhost:new URL("http://localhost:8443")};var V=class extends Error{constructor(...e){super(...e)}},i=class extends V{httpStatus;code;queryInfo;constraint_failures;constructor(e,t){super(e.error.message),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="ServiceError",this.code=e.error.code,this.httpStatus=t;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}},F=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,F),this.name="QueryRuntimeError"}},Q=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,Q),this.name="QueryCheckError"}},R=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,R),this.name="InvalidRequestError"}},X=class extends i{abort;constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,Q),this.name="AbortError",this.abort=e.error.abort}},O=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,O),this.name="AuthenticationError"}},N=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,N),this.name="AuthorizationError"}},Z=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,R),this.name="ContendedTransactionError"}},A=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,A),this.name="ThrottlingError"}},$=class extends i{stats;constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,$),this.name="QueryTimeoutError",this.stats=e.stats}},j=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,j),this.name="ServiceInternalError"}},M=class extends i{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,M),this.name="ServiceTimeoutError"}},p=class extends V{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,p),this.name="ClientError"}},_=class extends V{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,_),this.name="ClientClosedError"}},f=class extends V{constructor(e,t){super(e,t),Error.captureStackTrace&&Error.captureStackTrace(this,f),this.name="NetworkError"}},h=class extends V{httpStatus;constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,h),this.name="ProtocolError",this.httpStatus=e.httpStatus}};var Ie=/(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/,ke=/(?:0[1-9]|1[0-2])/,Ve=/(?:0[1-9]|[12]\d|3[01])/,xe=/(?:[01][0-9]|2[0-3])/,ee=/(?:[0-5][0-9])/,Fe=/(?:\.\d+)/,ye=new RegExp(`(${Ie.source}-(${ke.source})-(${Ve.source}))`),Oe=new RegExp(`(${xe.source}:${ee.source}:${ee.source}${Fe.source}?)`),Ne=new RegExp(`([zZ]|[+\u2212-]${xe.source}(?::?${ee.source}|:${ee.source}:${ee.source}))`),Se=new RegExp(`^${ye.source}$`),we=new RegExp(`^${ye.source}`),Ee=new RegExp(`^${ye.source}T${Oe.source}${Ne.source}$`);var b=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(Ee.exec(e)===null)throw new RangeError(`(regex) Expected an ISO date string but received '${e}'`);return new b(e)}static fromDate(e){return new b(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}")`}},x=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 t=Se.exec(e);if(t===null)throw new RangeError(`Expected a plain date string but received '${e}'`);return new x(t[0])}static fromDate(e){let t=e.toISOString(),n=we.exec(t);if(n===null)throw new p(`Failed to parse date '${e}'`);return new x(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 P=class{coll;id;constructor({coll:e,id:t}){this.id=t,typeof e=="string"?this.coll=new C(e):this.coll=e}},Y=class extends P{ts;constructor(e){let{coll:t,id:n,ts:s,...o}=e;super({coll:t,id:n}),this.ts=s,Object.assign(this,o)}toObject(){return{...this}}},L=class{coll;name;constructor({coll:e,name:t}){this.name=t,typeof e=="string"?this.coll=new C(e):this.coll=e}},J=class extends L{ts;data;constructor(e){let{coll:t,name:n,ts:s,data:o,...c}=e;super({coll:t,name:n}),this.ts=s,this.data=o||{},Object.assign(this,c)}toObject(){return{...this}}},C=class{name;constructor(e){this.name=e}},B=class{ref;cause;constructor(e,t){this.ref=e,this.cause=t}};var S=class{data;after;constructor({data:e,after:t}){this.data=e,this.after=t}},H=class{after;constructor(e){this.after=e}},w=class{#e;constructor(e,t){if(t instanceof Function)this.#e=$e(e,t);else if(t instanceof S||t instanceof H)this.#e=Qe(e,t);else throw new TypeError(`Expected 'Page<T> | EmbeddedSet | (() => Promise<T | Page<T> | EmbeddedSet>)', but received ${JSON.stringify(t)}`)}static fromQuery(e,t){return new w(e,async()=>(await e.query(t)).data)}static fromPageable(e,t){return new w(e,t)}flatten(){return new pe(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}},pe=class{#e;constructor(e){this.#e=je(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*Qe(r,e){let t=e;for(t instanceof S&&(yield t.data);t.after;){let n=fe`Set.paginate(${t.after})`;t=(await r.query(n)).data,yield t.data}}async function*$e(r,e){let t=await e();if(t instanceof S||t instanceof H){for await(let n of Qe(r,t))yield n;return}yield[t]}async function*je(r){for await(let e of r)for(let t of e)yield t}var q=class{static encode(e){return se(e)}static decode(e){return JSON.parse(e,(t,n)=>{if(n==null)return null;if(n["@mod"])return new C(n["@mod"]);if(n["@doc"]){if(typeof n["@doc"]=="string"){let[o,c]=n["@doc"].split(":");return new P({coll:o,id:c})}let s=n["@doc"];return s.id?new Y(s):new J(s)}else if(n["@ref"]){let s=n["@ref"],o;return s.id?o=new P(s):o=new L(s),"exists"in s&&s.exists===!1?new B(o,s.cause):o}else{if(n["@set"])return typeof n["@set"]=="string"?new H(n["@set"]):new S(n["@set"]);if(n["@int"])return Number(n["@int"]);if(n["@long"])return BigInt(n["@long"]);if(n["@double"])return Number(n["@double"]);if(n["@date"])return x.from(n["@date"]);if(n["@time"])return b.from(n["@time"]);if(n["@object"])return n["@object"]}return n})}},Re=BigInt("-9223372036854775808"),_e=BigInt("9223372036854775807"),l={bigint:r=>{if(r<Re||r>_e)throw new RangeError("Precision loss when converting BigInt to Fauna type");return{"@long":r.toString()}},number:r=>{if(r===Number.POSITIVE_INFINITY||r===Number.NEGATIVE_INFINITY)throw new RangeError(`Cannot convert ${r} to a Fauna type.`);return`${r}`.includes(".")?{"@double":r.toString()}:r>=-(2**31)&&r<=2**31-1?{"@int":r.toString()}:Number.isSafeInteger(r)?{"@long":r.toString()}:{"@double":r.toString()}},string:r=>r,object:r=>{let e=!1,t={};for(let n in r)n.startsWith("@")&&(e=!0),r[n]!==void 0&&(t[n]=se(r[n]));return e?{"@object":t}:t},array:r=>{let e=[];for(let t in r)e.push(se(r[t]));return e},date:r=>({"@time":r.toISOString()}),faunadate:r=>({"@date":r.dateString}),faunatime:r=>({"@time":r.isoString}),module:r=>({"@mod":r.name}),documentReference:r=>({"@ref":{id:r.id,coll:{"@mod":r.coll.name}}}),document:r=>({"@ref":{id:r.id,coll:{"@mod":r.coll.name}}}),namedDocumentReference:r=>({"@ref":{name:r.name,coll:{"@mod":r.coll.name}}}),namedDocument:r=>({"@ref":{name:r.name,coll:{"@mod":r.coll.name}}}),set:r=>{throw new p("Page could not be encoded. Fauna does not accept encoded Set values, yet. Use Page.data and Page.after as arguments, instead.")}},se=r=>{if(r===void 0)throw new TypeError("Passing undefined as a QueryValue is not supported");switch(typeof r){case"bigint":return l.bigint(r);case"string":return l.string(r);case"number":return l.number(r);case"boolean":return r;case"object":return r==null?null:Array.isArray(r)?l.array(r):r instanceof Date?l.date(r):r instanceof x?l.faunadate(r):r instanceof b?l.faunatime(r):r instanceof C?l.module(r):r instanceof Y?l.document(r):r instanceof P?l.documentReference(r):r instanceof J?l.namedDocument(r):r instanceof L?l.namedDocumentReference(r):r instanceof B?se(r.ref):r instanceof S||r instanceof H?l.set(r):l.object(r)}};function fe(r,...e){return new U(r,...e)}var U=class{#e;#r;constructor(e,...t){if(e.length===0||e.length!==t.length+1)throw new Error("invalid query constructed");this.#e=e,this.#r=t}toQuery(e={}){return{...this.#t(e),...e}}#t(e){if(this.#e.length===1)return{query:{fql:[this.#e[0]]},arguments:{}};let t={};return{query:{fql:this.#e.flatMap((s,o)=>{if(o===this.#e.length-1)return s===""?[]:[s];let c=this.#r[o],d;if(c instanceof U){let y=c.toQuery(e);d=y.query,t={...t,...y.arguments}}else d={value:q.encode(c)};return[s,d].filter(y=>y!=="")})},arguments:t}}};var Pe=r=>r instanceof Object&&"data"in r,Ce=r=>r instanceof Object&&"error"in r&&r.error instanceof Object&&"code"in r.error&&"message"in r.error;var te=class{#e;constructor({url:e}){this.#e=new URL("/query/1",e).toString()}async request({data:e,headers:t,method:n,client_timeout_ms:s}){let o=await fetch(this.#e,{method:n,headers:{...t,"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(s)}).catch(a=>{throw new f("The network connection encountered a problem.",{cause:a})}),c=o.status,d={};o.headers.forEach((a,T)=>d[T]=a);let y=await o.text();return{status:c,body:y,headers:d}}close(){}};var v;try{v=be("node:http2")}catch{v=void 0}var K,re,ne,D,m,ae,He,W,oe,ie,qe,ue,De,G=class{constructor({http2_session_idle_ms:e,url:t}){g(this,W);g(this,ie);g(this,ue);g(this,re,void 0);g(this,ne,void 0);g(this,D,0);g(this,m,void 0);if(v===void 0)throw new Error("Your platform does not support Node's http2 library");I(this,re,e),I(this,ne,t),I(this,m,null)}static getClient(e){var s;let t=k(s=G,ae,He).call(s,e);u(G,K).has(t)||u(G,K).set(t,new G(e));let n=u(G,K).get(t);return le(n,D)._++,n}async request(e){let t=0,n;do try{return await k(this,ue,De).call(this,e)}catch(s){if(s?.code!=="ERR_HTTP2_GOAWAY_SESSION")throw new f("The network connection encountered a problem.",{cause:s});n=s,t++}while(t<3);throw new f("The network connection encountered a problem.",{cause:n})}close(){this.isClosed()||(le(this,D)._--,u(this,D)===0&&u(this,m)&&!u(this,m).closed&&u(this,m).close())}isClosed(){return u(this,D)===0}},z=G;K=new WeakMap,re=new WeakMap,ne=new WeakMap,D=new WeakMap,m=new WeakMap,ae=new WeakSet,He=function({http2_session_idle_ms:e,url:t}){return`${t}|${e}`},W=new WeakSet,oe=function(){I(this,D,0),u(this,m)&&!u(this,m).closed&&u(this,m).close()},ie=new WeakSet,qe=function(){if(!u(this,m)||u(this,m).closed){let e=v.connect(u(this,ne)).once("error",()=>k(this,W,oe).call(this)).once("goaway",()=>k(this,W,oe).call(this));e.setTimeout(u(this,re),()=>{k(this,W,oe).call(this)}),I(this,m,e)}return u(this,m)},ue=new WeakSet,De=function({client_timeout_ms:e,data:t,headers:n,method:s}){return new Promise((o,c)=>{let d,y=a=>{let T=Number(a[v.constants.HTTP2_HEADER_STATUS]),E="";d.on("data",ce=>{E+=ce}),d.on("end",()=>{o({status:T,body:E,headers:a})})};try{let a={...n,[v.constants.HTTP2_HEADER_PATH]:"/query/1",[v.constants.HTTP2_HEADER_METHOD]:s};d=k(this,ie,qe).call(this).request(a).setEncoding("utf8").on("error",E=>{c(E)}).on("response",y),d.write(JSON.stringify(t),"utf8"),d.setTimeout(e,()=>{d.destroy(new Error("Client timeout"))}),d.end()}catch(a){c(a)}})},g(z,ae),g(z,K,new Map);var ge=r=>Me()?z.getClient(r):new te(r),Te=r=>r instanceof Object&&"body"in r&&"headers"in r&&"status"in r,Me=()=>{if(typeof process<"u"&&process.release?.name==="node")try{return be("node:http2"),!0}catch{return!1}return!1};var Le={client_timeout_buffer_ms:5e3,endpoint:me.default,format:"tagged",http2_session_idle_ms:5e3,max_conns:10,query_timeout_ms:5e3},he=class{#e;#r;#t;#n=!1;constructor(e,t){this.#e={...Le,...e,secret:this.#o(e)},this.#c(),t?this.#r=t:this.#r=ge({url:this.#e.endpoint.toString(),http2_session_idle_ms:this.#e.http2_session_idle_ms})}get lastTxnTs(){return this.#t}set lastTxnTs(e){this.#t=this.#t?Math.max(e,this.#t):e}get clientConfiguration(){let{secret:e,...t}=this.#e;return t}close(){if(this.#n)throw new _("Your client is closed. You cannot close it again.");this.#r.close(),this.#n=!0}paginate(e){return e instanceof U?w.fromQuery(this,e):w.fromPageable(this,e)}async query(e,t){if(this.#n)throw new _("Your client is closed. No further requests can be issued.");return this.#i(e.toQuery(t))}#s(e){if(e instanceof p||e instanceof f||e instanceof h||e instanceof i)return e;if(Te(e)){if(Ce(e.body)){let t=e.body,n=e.status;return this.#a(t,n)}return new h({message:`Response is in an unkown format: ${e.body}`,httpStatus:e.status})}return new p("A client level error occurred. Fauna was not called.",{cause:e})}#o(e){let t;typeof process=="object"&&(t=process.env.FAUNA_SECRET);let n=e?.secret||t;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}#a(e,t){switch(t){case 400:return Ue.includes(e.error.code)?new Q(e,t):e.error.code==="invalid_request"?new R(e,t):e.error.code==="abort"&&e.error.abort!==void 0?new X(e,t):new F(e,t);case 401:return new O(e,t);case 403:return new N(e,t);case 409:return new Z(e,t);case 429:return new A(e,t);case 440:return new $(e,t);case 500:return new j(e,t);case 503:return new M(e,t);default:return new i(e,t)}}async#i(e){try{let t={Authorization:`Bearer ${this.#e.secret}`};this.#u({...this.clientConfiguration,...e},t);let n={...this.#e,...e},s=n.format==="tagged"||e.format==="tagged",o=s?q.encode(e.arguments):e.arguments,c={query:e.query,arguments:o},d=n.query_timeout_ms+this.#e.client_timeout_buffer_ms,y=await this.#r.request({data:c,headers:t,method:"POST",client_timeout_ms:d}),a;try{if(a={...y,body:s?q.decode(y.body):JSON.parse(y.body)},a.body.query_tags){let E=a.body.query_tags.split(",").map(ce=>ce.split("="));a.body.query_tags=Object.fromEntries(E)}}catch(E){throw new h({message:`Error parsing response as JSON: ${E}`,httpStatus:y.status})}if(!Pe(a.body))throw this.#s(a);let T=a.body.txn_ts;return(this.#t===void 0&&T!==void 0||T!==void 0&&this.#t!==void 0&&this.#t<T)&&(this.#t=T),a.body}catch(t){throw this.#s(t)}}#u(e,t){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(c=>c.join("=")).join(","):typeof n[1]=="string"?s=n[1]:s=String(n[1]),n[0]==="traceparent"&&(o=n[0]),t[o]=s}t["x-last-txn-ts"]===void 0&&this.#t!==void 0&&(t["x-last-txn-ts"]=this.#t)}#c(){let e=this.#e;if(["client_timeout_buffer_ms","endpoint","format","http2_session_idle_ms","max_conns","query_timeout_ms"].forEach(n=>{if(e[n]===void 0)throw new TypeError(`ClientConfiguration option '${n}' must be defined.`)}),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.")}},Ue=["invalid_function_definition","invalid_identifier","invalid_query","invalid_syntax","invalid_type"];export{X as AbortError,O as AuthenticationError,N as AuthorizationError,he as Client,_ as ClientClosedError,p as ClientError,Z as ContendedTransactionError,x as DateStub,Y as Document,P as DocumentReference,H as EmbeddedSet,te as FetchClient,R as InvalidRequestError,_e as LONG_MAX,Re as LONG_MIN,C as Module,J as NamedDocument,L as NamedDocumentReference,f as NetworkError,z as NodeHTTP2Client,B as NullDocument,S as Page,h as ProtocolError,Q as QueryCheckError,F as QueryRuntimeError,$ as QueryTimeoutError,i as ServiceError,j as ServiceInternalError,M as ServiceTimeoutError,w as SetIterator,q as TaggedTypeFormat,A as ThrottlingError,b as TimeStub,me as endpoints,fe as fql,ge as getDefaultHTTPClient,Te as isHTTPResponse}; | ||
var Ee=(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 o=(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)},p=(t,e,r,n)=>(Qe(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),_e=(t,e,r,n)=>({set _(s){p(t,e,s,r)},get _(){return o(t,e,n)}}),m=(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 V=class extends Error{constructor(...e){super(...e)}},u=class extends V{httpStatus;code;queryInfo;constraint_failures;constructor(e,r){super(e.error.message),Error.captureStackTrace&&Error.captureStackTrace(this,u),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}},q=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,q),this.name="QueryRuntimeError"}},C=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,C),this.name="QueryCheckError"}},O=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,O),this.name="InvalidRequestError"}},re=class extends u{abort;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,C),this.name="AbortError",this.abort=e.error.abort}},F=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,F),this.name="AuthenticationError"}},W=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,W),this.name="AuthorizationError"}},ne=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,O),this.name="ContendedTransactionError"}},M=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,M),this.name="ThrottlingError"}},j=class extends u{stats;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,j),this.name="QueryTimeoutError",this.stats=e.stats}},v=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="ServiceInternalError"}},$=class extends u{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,$),this.name="ServiceTimeoutError"}},h=class extends V{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,h),this.name="ClientError"}},k=class extends V{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,k),this.name="ClientClosedError"}},b=class extends V{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,b),this.name="NetworkError"}},x=class extends V{httpStatus;constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,x),this.name="ProtocolError",this.httpStatus=e.httpStatus}};var se=class{#e;constructor({url:e}){this.#e=new URL("/query/1",e).toString()}async request({data:e,headers:r,method:n,client_timeout_ms:s}){let i=await fetch(this.#e,{method:n,headers:{...r,"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(s)}).catch(c=>{throw new b("The network connection encountered a problem.",{cause:c})}),d=i.status,l={};i.headers.forEach((c,S)=>l[S]=c);let g=await i.text();return{status:d,body:g,headers:l}}close(){}};var L;try{L=Ee("node:http2")}catch{L=void 0}var z,oe,ie,A,y,de,De,J,ue,le,He,me,Ve,U=class{constructor({http2_session_idle_ms:e,url:r}){a(this,J);a(this,le);a(this,me);a(this,oe,void 0);a(this,ie,void 0);a(this,A,0);a(this,y,void 0);if(L===void 0)throw new Error("Your platform does not support Node's http2 library");p(this,oe,e),p(this,ie,r),p(this,y,null)}static getClient(e){var s;let r=m(s=U,de,De).call(s,e);o(U,z).has(r)||o(U,z).set(r,new U(e));let n=o(U,z).get(r);return _e(n,A)._++,n}async request(e){let r=0,n;do try{return await m(this,me,Ve).call(this,e)}catch(s){if(s?.code!=="ERR_HTTP2_GOAWAY_SESSION")throw new b("The network connection encountered a problem.",{cause:s});n=s,r++}while(r<3);throw new b("The network connection encountered a problem.",{cause:n})}close(){this.isClosed()||(_e(this,A)._--,o(this,A)===0&&o(this,y)&&!o(this,y).closed&&o(this,y).close())}isClosed(){return o(this,A)===0}},G=U;z=new WeakMap,oe=new WeakMap,ie=new WeakMap,A=new WeakMap,y=new WeakMap,de=new WeakSet,De=function({http2_session_idle_ms:e,url:r}){return`${r}|${e}`},J=new WeakSet,ue=function(){p(this,A,0),o(this,y)&&!o(this,y).closed&&o(this,y).close()},le=new WeakSet,He=function(){if(!o(this,y)||o(this,y).closed){let e=L.connect(o(this,ie)).once("error",()=>m(this,J,ue).call(this)).once("goaway",()=>m(this,J,ue).call(this));e.setTimeout(o(this,oe),()=>{m(this,J,ue).call(this)}),p(this,y,e)}return o(this,y)},me=new WeakSet,Ve=function({client_timeout_ms:e,data:r,headers:n,method:s}){return new Promise((i,d)=>{let l,g=c=>{let S=Number(c[L.constants.HTTP2_HEADER_STATUS]),P="";l.on("data",xe=>{P+=xe}),l.on("end",()=>{i({status:S,body:P,headers:c})})};try{let c={...n,[L.constants.HTTP2_HEADER_PATH]:"/query/1",[L.constants.HTTP2_HEADER_METHOD]:s};l=m(this,le,He).call(this).request(c).setEncoding("utf8").on("error",P=>{d(P)}).on("response",g),l.write(JSON.stringify(r),"utf8"),l.setTimeout(e,()=>{l.destroy(new Error("Client timeout"))}),l.end()}catch(c){d(c)}})},a(G,de),a(G,z,new Map);var Pe=t=>tt()?G.getClient(t):new se(t),Ce=t=>t instanceof Object&&"body"in t&&"headers"in t&&"status"in t,tt=()=>{if(typeof process<"u"&&process.release?.name==="node")try{return Ee("node:http2"),!0}catch{return!1}return!1};var rt=/(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/,nt=/(?:0[1-9]|1[0-2])/,st=/(?:0[1-9]|[12]\d|3[01])/,qe=/(?:[01][0-9]|2[0-3])/,ae=/(?:[0-5][0-9])/,ot=/(?:\.\d+)/,Oe=new RegExp(`(${rt.source}-(${nt.source})-(${st.source}))`),it=new RegExp(`(${qe.source}:${ae.source}:${ae.source}${ot.source}?)`),at=new RegExp(`([zZ]|[+\u2212-]${qe.source}(?::?${ae.source}|:${ae.source}:${ae.source}))`),Fe=new RegExp(`^${Oe.source}$`),We=new RegExp(`^${Oe.source}`),Me=new RegExp(`^${Oe.source}T${it.source}${at.source}$`);var E=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(Me.exec(e)===null)throw new RangeError(`(regex) Expected an ISO date string but received '${e}'`);return new E(e)}static fromDate(e){return new E(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=Fe.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 h(`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 N=class{coll;id;constructor({coll:e,id:r}){this.id=r,typeof e=="string"?this.coll=new I(e):this.coll=e}},K=class extends N{ts;constructor(e){let{coll:r,id:n,ts:s,...i}=e;super({coll:r,id:n}),this.ts=s,Object.assign(this,i)}toObject(){return{...this}}},B=class{coll;name;constructor({coll:e,name:r}){this.name=r,typeof e=="string"?this.coll=new I(e):this.coll=e}},Z=class extends B{ts;data;constructor(e){let{coll:r,name:n,ts:s,data:i,...d}=e;super({coll:r,name:n}),this.ts=s,this.data=i||{},Object.assign(this,d)}toObject(){return{...this}}},I=class{name;constructor(e){this.name=e}},ee=class{ref;cause;constructor(e,r){this.ref=e,this.cause=r}};var _=class{data;after;constructor({data:e,after:r}){this.data=e,this.after=r}},D=class{after;constructor(e){this.after=e}},R=class{#e;constructor(e,r){if(r instanceof Function)this.#e=ut(e,r);else if(r instanceof _||r instanceof D)this.#e=je(e,r);else throw new TypeError(`Expected 'Page<T> | EmbeddedSet | (() => Promise<T | Page<T> | EmbeddedSet>)', but received ${JSON.stringify(r)}`)}static fromQuery(e,r){return new R(e,async()=>(await e.query(r)).data)}static fromPageable(e,r){return new R(e,r)}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=dt(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){let r=e;for(r instanceof _&&(yield r.data);r.after;){let n=Ae`Set.paginate(${r.after})`;r=(await t.query(n)).data,yield r.data}}async function*ut(t,e){let r=await e();if(r instanceof _||r instanceof D){for await(let n of je(t,r))yield n;return}yield[r]}async function*dt(t){for await(let e of t)for(let r of e)yield r}var H=class{static encode(e){return fe(e)}static decode(e){return JSON.parse(e,(r,n)=>{if(n==null)return null;if(n["@mod"])return new I(n["@mod"]);if(n["@doc"]){if(typeof n["@doc"]=="string"){let[i,d]=n["@doc"].split(":");return new N({coll:i,id:d})}let s=n["@doc"];return s.id?new K(s):new Z(s)}else if(n["@ref"]){let s=n["@ref"],i;return s.id?i=new N(s):i=new B(s),"exists"in s&&s.exists===!1?new ee(i,s.cause):i}else{if(n["@set"])return typeof n["@set"]=="string"?new D(n["@set"]):new _(n["@set"]);if(n["@int"])return Number(n["@int"]);if(n["@long"])return BigInt(n["@long"]);if(n["@double"])return Number(n["@double"]);if(n["@date"])return Q.from(n["@date"]);if(n["@time"])return E.from(n["@time"]);if(n["@object"])return n["@object"]}return n})}},ve=BigInt("-9223372036854775808"),$e=BigInt("9223372036854775807"),f={bigint:t=>{if(t<ve||t>$e)throw new RangeError("Precision loss when converting BigInt to Fauna type");return{"@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`${t}`.includes(".")?{"@double":t.toString()}:t>=-(2**31)&&t<=2**31-1?{"@int":t.toString()}:Number.isSafeInteger(t)?{"@long":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]=fe(t[n]));return e?{"@object":r}:r},array:t=>{let e=[];for(let r in t)e.push(fe(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 h("Page could not be encoded. Fauna does not accept encoded Set values, yet. Use Page.data and Page.after as arguments, instead.")}},fe=t=>{if(t===void 0)throw new TypeError("Passing undefined as a QueryValue is not supported");switch(typeof t){case"bigint":return f.bigint(t);case"string":return f.string(t);case"number":return f.number(t);case"boolean":return t;case"object":return t==null?null:Array.isArray(t)?f.array(t):t instanceof Date?f.date(t):t instanceof Q?f.faunadate(t):t instanceof E?f.faunatime(t):t instanceof I?f.module(t):t instanceof K?f.document(t):t instanceof N?f.documentReference(t):t instanceof Z?f.namedDocument(t):t instanceof B?f.namedDocumentReference(t):t instanceof ee?fe(t.ref):t instanceof _||t instanceof D?f.set(t):f.object(t)}};function Ae(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,i)=>{if(i===this.#e.length-1)return s===""?[]:[s];let d=this.#t[i],l;if(d instanceof X){let g=d.toQuery(e);l=g.query,r={...r,...g.arguments}}else l={value:H.encode(d)};return[s,l].filter(g=>g!=="")})},arguments:r}}};var Le="0.7.2";var pe;try{pe=Ee("node:os")}catch{pe=void 0}var Be=()=>{let t={driver:["javascript",Le].join("-"),env:"unknown",os:"unknown",runtime:"unknown"},e=!1;try{e=global instanceof ServiceWorkerGlobalScope}catch{}return lt()?(t.runtime=["nodejs",process.version].join("-"),t.env=ft(),t.os=[pe.platform(),pe.release()].join("-")):e?(t.runtime=Ue(navigator),t.env="Service Worker",t.os=Ge(navigator)):(t.runtime=Ue(navigator),t.env="browser",t.os=Ge(navigator)),Object.entries(t).filter(([r,n])=>n!=="unknown").map(r=>r.join("=")).join("; ")},lt=()=>typeof window>"u"&&typeof process<"u"&&process.versions!=null&&process.versions.node!=null,Ue=t=>{let e=t.appName,r=""+parseFloat(t.appVersion),n,s,i;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)),(i=r.indexOf(";"))!=-1&&(r=r.substring(0,i)),(i=r.indexOf(" "))!=-1&&(r=r.substring(0,i)),(i=r.indexOf(")"))!=-1&&(r=r.substring(0,i)),[e,r].join("-")},Ge=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 i=r[s];if(i.r.test(t.userAgent)){e=i.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("-")},mt=typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof global<"u"?global:self,ft=()=>{if(!(typeof process<"u"&&process&&process.env))return"unkown";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 mt?.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 Xe=t=>t instanceof Object&&"data"in t,Ye=t=>t instanceof Object&&"error"in t&&t.error instanceof Object&&"code"in t.error&&"message"in t.error;var pt={client_timeout_buffer_ms:5e3,endpoint:Re.default,format:"tagged",http2_session_idle_ms:5e3,max_conns:10,query_timeout_ms:5e3},ge,w,Y,T,te,ce,Ne,Te,ze,he,Je,be,Ke,we,Ze,Se,et,Ie=class{constructor(e,r){a(this,ce);a(this,Te);a(this,he);a(this,be);a(this,we);a(this,Se);a(this,w,void 0);a(this,Y,void 0);a(this,T,void 0);a(this,te,!1);p(this,w,{...pt,...e,secret:m(this,Te,ze).call(this,e)}),m(this,Se,et).call(this),r?p(this,Y,r):p(this,Y,Pe({url:o(this,w).endpoint.toString(),http2_session_idle_ms:o(this,w).http2_session_idle_ms}))}get lastTxnTs(){return o(this,T)}set lastTxnTs(e){p(this,T,o(this,T)?Math.max(e,o(this,T)):e)}get clientConfiguration(){let{secret:e,...r}=o(this,w);return r}close(){if(o(this,te))throw new k("Your client is closed. You cannot close it again.");o(this,Y).close(),p(this,te,!0)}paginate(e){return e instanceof X?R.fromQuery(this,e):R.fromPageable(this,e)}async query(e,r){if(o(this,te))throw new k("Your client is closed. No further requests can be issued.");return m(this,be,Ke).call(this,e.toQuery(r))}},ye=Ie;ge=new WeakMap,w=new WeakMap,Y=new WeakMap,T=new WeakMap,te=new WeakMap,ce=new WeakSet,Ne=function(e){if(e instanceof h||e instanceof b||e instanceof x||e instanceof u)return e;if(Ce(e)){if(Ye(e.body)){let r=e.body,n=e.status;return m(this,he,Je).call(this,r,n)}return new x({message:`Response is in an unkown format: ${e.body}`,httpStatus:e.status})}return new h("A client level error occurred. Fauna was not called.",{cause:e})},Te=new WeakSet,ze=function(e){let r;typeof process=="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},he=new WeakSet,Je=function(e,r){switch(r){case 400:return yt.includes(e.error.code)?new C(e,r):e.error.code==="invalid_request"?new O(e,r):e.error.code==="abort"&&e.error.abort!==void 0?new re(e,r):new q(e,r);case 401:return new F(e,r);case 403:return new W(e,r);case 409:return new ne(e,r);case 429:return new M(e,r);case 440:return new j(e,r);case 500:return new v(e,r);case 503:return new $(e,r);default:return new u(e,r)}},be=new WeakSet,Ke=async function(e){try{let r={Authorization:`Bearer ${o(this,w).secret}`};m(this,we,Ze).call(this,{...this.clientConfiguration,...e},r);let n={...o(this,w),...e},s=n.format==="tagged"||e.format==="tagged",i=s?H.encode(e.arguments):e.arguments,d={query:e.query,arguments:i},l=n.query_timeout_ms+o(this,w).client_timeout_buffer_ms,g=await o(this,Y).request({data:d,headers:r,method:"POST",client_timeout_ms:l}),c;try{if(c={...g,body:s?H.decode(g.body):JSON.parse(g.body)},c.body.query_tags){let P=c.body.query_tags.split(",").map(xe=>xe.split("="));c.body.query_tags=Object.fromEntries(P)}}catch(P){throw new x({message:`Error parsing response as JSON: ${P}`,httpStatus:g.status})}if(!Xe(c.body))throw m(this,ce,Ne).call(this,c);let S=c.body.txn_ts;return(o(this,T)===void 0&&S!==void 0||S!==void 0&&o(this,T)!==void 0&&o(this,T)<S)&&p(this,T,S),c.body}catch(r){throw m(this,ce,Ne).call(this,r)}},we=new WeakSet,Ze=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,i=`x-${n[0].replaceAll("_","-")}`;n[0]==="query_tags"?s=Object.entries(n[1]).map(d=>d.join("=")).join(","):typeof n[1]=="string"?s=n[1]:s=String(n[1]),n[0]==="traceparent"&&(i=n[0]),r[i]=s}r["x-last-txn-ts"]===void 0&&o(this,T)!==void 0&&(r["x-last-txn-ts"]=o(this,T)),r["x-driver-env"]=o(Ie,ge)},Se=new WeakSet,et=function(){let e=o(this,w);if(["client_timeout_buffer_ms","endpoint","format","http2_session_idle_ms","max_conns","query_timeout_ms"].forEach(n=>{if(e[n]===void 0)throw new TypeError(`ClientConfiguration option '${n}' must be defined.`)}),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(ye,ge,Be());var yt=["invalid_function_definition","invalid_identifier","invalid_query","invalid_syntax","invalid_type"];export{re as AbortError,F as AuthenticationError,W as AuthorizationError,ye as Client,k as ClientClosedError,h as ClientError,ne as ContendedTransactionError,Q as DateStub,K as Document,N as DocumentReference,D as EmbeddedSet,se as FetchClient,O as InvalidRequestError,$e as LONG_MAX,ve as LONG_MIN,I as Module,Z as NamedDocument,B as NamedDocumentReference,b as NetworkError,G as NodeHTTP2Client,ee as NullDocument,_ as Page,x as ProtocolError,C as QueryCheckError,q as QueryRuntimeError,j as QueryTimeoutError,u as ServiceError,v as ServiceInternalError,$ as ServiceTimeoutError,R as SetIterator,H as TaggedTypeFormat,M as ThrottlingError,E as TimeStub,Re as endpoints,Ae as fql,Pe as getDefaultHTTPClient,Ce as isHTTPResponse}; | ||
//# sourceMappingURL=index.js.map |
import { ClientConfiguration } from "./client-configuration"; | ||
import { type HTTPClient } from "./http-client"; | ||
import { Query } from "./query-builder"; | ||
import { EmbeddedSet, Page, SetIterator } from "./values"; | ||
import { type QueryRequestHeaders, type QuerySuccess, type QueryValue } from "./wire-protocol"; | ||
import { type HTTPClient } from "./http-client"; | ||
import { EmbeddedSet, Page, SetIterator } from "./values"; | ||
export declare const DEFAULT_CLIENT_CONFIG: Omit<ClientConfiguration, "secret">; | ||
@@ -7,0 +7,0 @@ /** |
@@ -271,2 +271,202 @@ "use strict"; | ||
// src/http-client/fetch-client.ts | ||
var FetchClient = class { | ||
#url; | ||
constructor({ url }) { | ||
this.#url = new URL("/query/1", url).toString(); | ||
} | ||
async request({ | ||
data, | ||
headers: requestHeaders, | ||
method, | ||
client_timeout_ms | ||
}) { | ||
const response = await fetch(this.#url, { | ||
method, | ||
headers: { ...requestHeaders, "Content-Type": "application/json" }, | ||
body: JSON.stringify(data), | ||
signal: AbortSignal.timeout(client_timeout_ms) | ||
}).catch((error) => { | ||
throw new NetworkError("The network connection encountered a problem.", { | ||
cause: error | ||
}); | ||
}); | ||
const status = response.status; | ||
const responseHeaders = {}; | ||
response.headers.forEach((value, key) => responseHeaders[key] = value); | ||
const body = await response.text(); | ||
return { | ||
status, | ||
body, | ||
headers: responseHeaders | ||
}; | ||
} | ||
close() { | ||
} | ||
}; | ||
// src/http-client/node-http2-client.ts | ||
var http2; | ||
try { | ||
http2 = require("node:http2"); | ||
} catch (_) { | ||
http2 = void 0; | ||
} | ||
var _clients, _http2_session_idle_ms, _url, _numberOfUsers, _session, _getClientKey, getClientKey_fn, _closeForAll, closeForAll_fn, _connect, connect_fn, _doRequest, doRequest_fn; | ||
var _NodeHTTP2Client = class { | ||
constructor({ http2_session_idle_ms, url }) { | ||
__privateAdd(this, _closeForAll); | ||
__privateAdd(this, _connect); | ||
__privateAdd(this, _doRequest); | ||
__privateAdd(this, _http2_session_idle_ms, void 0); | ||
__privateAdd(this, _url, void 0); | ||
__privateAdd(this, _numberOfUsers, 0); | ||
__privateAdd(this, _session, void 0); | ||
if (http2 === void 0) { | ||
throw new Error("Your platform does not support Node's http2 library"); | ||
} | ||
__privateSet(this, _http2_session_idle_ms, http2_session_idle_ms); | ||
__privateSet(this, _url, url); | ||
__privateSet(this, _session, null); | ||
} | ||
static getClient(httpClientOptions) { | ||
var _a; | ||
const clientKey = __privateMethod(_a = _NodeHTTP2Client, _getClientKey, getClientKey_fn).call(_a, httpClientOptions); | ||
if (!__privateGet(_NodeHTTP2Client, _clients).has(clientKey)) { | ||
__privateGet(_NodeHTTP2Client, _clients).set( | ||
clientKey, | ||
new _NodeHTTP2Client(httpClientOptions) | ||
); | ||
} | ||
const client = __privateGet(_NodeHTTP2Client, _clients).get(clientKey); | ||
__privateWrapper(client, _numberOfUsers)._++; | ||
return client; | ||
} | ||
async request(req) { | ||
let retryCount = 0; | ||
let memoizedError; | ||
do { | ||
try { | ||
return await __privateMethod(this, _doRequest, doRequest_fn).call(this, req); | ||
} catch (error) { | ||
if (error?.code !== "ERR_HTTP2_GOAWAY_SESSION") { | ||
throw new NetworkError( | ||
"The network connection encountered a problem.", | ||
{ | ||
cause: error | ||
} | ||
); | ||
} | ||
memoizedError = error; | ||
retryCount++; | ||
} | ||
} while (retryCount < 3); | ||
throw new NetworkError("The network connection encountered a problem.", { | ||
cause: memoizedError | ||
}); | ||
} | ||
close() { | ||
if (this.isClosed()) { | ||
return; | ||
} | ||
__privateWrapper(this, _numberOfUsers)._--; | ||
if (__privateGet(this, _numberOfUsers) === 0 && __privateGet(this, _session) && !__privateGet(this, _session).closed) { | ||
__privateGet(this, _session).close(); | ||
} | ||
} | ||
isClosed() { | ||
return __privateGet(this, _numberOfUsers) === 0; | ||
} | ||
}; | ||
var NodeHTTP2Client = _NodeHTTP2Client; | ||
_clients = new WeakMap(); | ||
_http2_session_idle_ms = new WeakMap(); | ||
_url = new WeakMap(); | ||
_numberOfUsers = new WeakMap(); | ||
_session = new WeakMap(); | ||
_getClientKey = new WeakSet(); | ||
getClientKey_fn = function({ http2_session_idle_ms, url }) { | ||
return `${url}|${http2_session_idle_ms}`; | ||
}; | ||
_closeForAll = new WeakSet(); | ||
closeForAll_fn = function() { | ||
__privateSet(this, _numberOfUsers, 0); | ||
if (__privateGet(this, _session) && !__privateGet(this, _session).closed) { | ||
__privateGet(this, _session).close(); | ||
} | ||
}; | ||
_connect = new WeakSet(); | ||
connect_fn = function() { | ||
if (!__privateGet(this, _session) || __privateGet(this, _session).closed) { | ||
const new_session = http2.connect(__privateGet(this, _url)).once("error", () => __privateMethod(this, _closeForAll, closeForAll_fn).call(this)).once("goaway", () => __privateMethod(this, _closeForAll, closeForAll_fn).call(this)); | ||
new_session.setTimeout(__privateGet(this, _http2_session_idle_ms), () => { | ||
__privateMethod(this, _closeForAll, closeForAll_fn).call(this); | ||
}); | ||
__privateSet(this, _session, new_session); | ||
} | ||
return __privateGet(this, _session); | ||
}; | ||
_doRequest = new WeakSet(); | ||
doRequest_fn = function({ | ||
client_timeout_ms, | ||
data: requestData, | ||
headers: requestHeaders, | ||
method | ||
}) { | ||
return new Promise((resolvePromise, rejectPromise) => { | ||
let req; | ||
const onResponse = (http2ResponseHeaders) => { | ||
const status = Number( | ||
http2ResponseHeaders[http2.constants.HTTP2_HEADER_STATUS] | ||
); | ||
let responseData = ""; | ||
req.on("data", (chunk) => { | ||
responseData += chunk; | ||
}); | ||
req.on("end", () => { | ||
resolvePromise({ | ||
status, | ||
body: responseData, | ||
headers: http2ResponseHeaders | ||
}); | ||
}); | ||
}; | ||
try { | ||
const httpRequestHeaders = { | ||
...requestHeaders, | ||
[http2.constants.HTTP2_HEADER_PATH]: "/query/1", | ||
[http2.constants.HTTP2_HEADER_METHOD]: method | ||
}; | ||
const session = __privateMethod(this, _connect, connect_fn).call(this); | ||
req = session.request(httpRequestHeaders).setEncoding("utf8").on("error", (error) => { | ||
rejectPromise(error); | ||
}).on("response", onResponse); | ||
req.write(JSON.stringify(requestData), "utf8"); | ||
req.setTimeout(client_timeout_ms, () => { | ||
req.destroy(new Error(`Client timeout`)); | ||
}); | ||
req.end(); | ||
} catch (error) { | ||
rejectPromise(error); | ||
} | ||
}); | ||
}; | ||
__privateAdd(NodeHTTP2Client, _getClientKey); | ||
__privateAdd(NodeHTTP2Client, _clients, /* @__PURE__ */ new Map()); | ||
// src/http-client/index.ts | ||
var getDefaultHTTPClient = (options) => nodeHttp2IsSupported() ? NodeHTTP2Client.getClient(options) : new FetchClient(options); | ||
var isHTTPResponse = (res) => res instanceof Object && "body" in res && "headers" in res && "status" in res; | ||
var nodeHttp2IsSupported = () => { | ||
if (typeof process !== "undefined" && process.release?.name === "node") { | ||
try { | ||
require("node:http2"); | ||
return true; | ||
} catch (_) { | ||
return false; | ||
} | ||
} | ||
return false; | ||
}; | ||
// src/regex.ts | ||
@@ -766,205 +966,241 @@ var yearpart = /(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/; | ||
// src/wire-protocol.ts | ||
var isQuerySuccess = (res) => res instanceof Object && "data" in res; | ||
var isQueryFailure = (res) => res instanceof Object && "error" in res && res.error instanceof Object && "code" in res.error && "message" in res.error; | ||
// src/util/package-version.ts | ||
var packageVersion = "0.7.2"; | ||
// src/http-client/fetch-client.ts | ||
var FetchClient = class { | ||
#url; | ||
constructor({ url }) { | ||
this.#url = new URL("/query/1", url).toString(); | ||
// src/util/environment.ts | ||
var os; | ||
try { | ||
os = require("node:os"); | ||
} catch (_) { | ||
os = void 0; | ||
} | ||
var getDriverEnv = () => { | ||
const driverEnv = { | ||
driver: ["javascript", packageVersion].join("-"), | ||
env: "unknown", | ||
os: "unknown", | ||
runtime: "unknown" | ||
}; | ||
let isServiceWorker = false; | ||
try { | ||
isServiceWorker = global instanceof ServiceWorkerGlobalScope; | ||
} catch (_) { | ||
} | ||
async request({ | ||
data, | ||
headers: requestHeaders, | ||
method, | ||
client_timeout_ms | ||
}) { | ||
const response = await fetch(this.#url, { | ||
method, | ||
headers: { ...requestHeaders, "Content-Type": "application/json" }, | ||
body: JSON.stringify(data), | ||
signal: AbortSignal.timeout(client_timeout_ms) | ||
}).catch((error) => { | ||
throw new NetworkError("The network connection encountered a problem.", { | ||
cause: error | ||
}); | ||
}); | ||
const status = response.status; | ||
const responseHeaders = {}; | ||
response.headers.forEach((value, key) => responseHeaders[key] = value); | ||
const body = await response.text(); | ||
return { | ||
status, | ||
body, | ||
headers: responseHeaders | ||
}; | ||
if (isNode()) { | ||
driverEnv.runtime = ["nodejs", process.version].join("-"); | ||
driverEnv.env = getNodeRuntimeEnv(); | ||
driverEnv.os = [os.platform(), os.release()].join("-"); | ||
} else if (isServiceWorker) { | ||
driverEnv.runtime = getBrowserDetails(navigator); | ||
driverEnv.env = "Service Worker"; | ||
driverEnv.os = getBrowserOsDetails(navigator); | ||
} else { | ||
driverEnv.runtime = getBrowserDetails(navigator); | ||
driverEnv.env = "browser"; | ||
driverEnv.os = getBrowserOsDetails(navigator); | ||
} | ||
close() { | ||
return Object.entries(driverEnv).filter(([_, val]) => val !== "unknown").map((entry) => entry.join("=")).join("; "); | ||
}; | ||
var isNode = () => typeof window === "undefined" && typeof process !== "undefined" && process.versions != null && process.versions.node != null; | ||
var getBrowserDetails = (navigator2) => { | ||
let browser = navigator2.appName; | ||
let browserVersion = "" + parseFloat(navigator2.appVersion); | ||
let nameOffset, verOffset, ix; | ||
if ((verOffset = navigator2.userAgent.indexOf("Opera")) != -1) { | ||
browser = "Opera"; | ||
browserVersion = navigator2.userAgent.substring(verOffset + 6); | ||
if ((verOffset = navigator2.userAgent.indexOf("Version")) != -1) { | ||
browserVersion = navigator2.userAgent.substring(verOffset + 8); | ||
} | ||
} else if ((verOffset = navigator2.userAgent.indexOf("MSIE")) != -1) { | ||
browser = "Microsoft Internet Explorer"; | ||
browserVersion = navigator2.userAgent.substring(verOffset + 5); | ||
} else if (browser == "Netscape" && navigator2.userAgent.indexOf("Trident/") != -1) { | ||
browser = "Microsoft Internet Explorer"; | ||
browserVersion = navigator2.userAgent.substring(verOffset + 5); | ||
if ((verOffset = navigator2.userAgent.indexOf("rv:")) != -1) { | ||
browserVersion = navigator2.userAgent.substring(verOffset + 3); | ||
} | ||
} else if ((verOffset = navigator2.userAgent.indexOf("Chrome")) != -1) { | ||
browser = "Chrome"; | ||
browserVersion = navigator2.userAgent.substring(verOffset + 7); | ||
} else if ((verOffset = navigator2.userAgent.indexOf("Safari")) != -1) { | ||
browser = "Safari"; | ||
browserVersion = navigator2.userAgent.substring(verOffset + 7); | ||
if ((verOffset = navigator2.userAgent.indexOf("Version")) != -1) { | ||
browserVersion = navigator2.userAgent.substring(verOffset + 8); | ||
} | ||
if (navigator2.userAgent.indexOf("CriOS") != -1) { | ||
browser = "Chrome"; | ||
} | ||
} else if ((verOffset = navigator2.userAgent.indexOf("Firefox")) != -1) { | ||
browser = "Firefox"; | ||
browserVersion = navigator2.userAgent.substring(verOffset + 8); | ||
} else if ((nameOffset = navigator2.userAgent.lastIndexOf(" ") + 1) < (verOffset = navigator2.userAgent.lastIndexOf("/"))) { | ||
browser = navigator2.userAgent.substring(nameOffset, verOffset); | ||
browserVersion = navigator2.userAgent.substring(verOffset + 1); | ||
if (browser.toLowerCase() == browser.toUpperCase()) { | ||
browser = navigator2.appName; | ||
} | ||
} | ||
if ((ix = browserVersion.indexOf(";")) != -1) | ||
browserVersion = browserVersion.substring(0, ix); | ||
if ((ix = browserVersion.indexOf(" ")) != -1) | ||
browserVersion = browserVersion.substring(0, ix); | ||
if ((ix = browserVersion.indexOf(")")) != -1) | ||
browserVersion = browserVersion.substring(0, ix); | ||
return [browser, browserVersion].join("-"); | ||
}; | ||
// src/http-client/node-http2-client.ts | ||
var http2; | ||
try { | ||
http2 = require("node:http2"); | ||
} catch (_) { | ||
http2 = void 0; | ||
} | ||
var _clients, _http2_session_idle_ms, _url, _numberOfUsers, _session, _getClientKey, getClientKey_fn, _closeForAll, closeForAll_fn, _connect, connect_fn, _doRequest, doRequest_fn; | ||
var _NodeHTTP2Client = class { | ||
constructor({ http2_session_idle_ms, url }) { | ||
__privateAdd(this, _closeForAll); | ||
__privateAdd(this, _connect); | ||
__privateAdd(this, _doRequest); | ||
__privateAdd(this, _http2_session_idle_ms, void 0); | ||
__privateAdd(this, _url, void 0); | ||
__privateAdd(this, _numberOfUsers, 0); | ||
__privateAdd(this, _session, void 0); | ||
if (http2 === void 0) { | ||
throw new Error("Your platform does not support Node's http2 library"); | ||
var getBrowserOsDetails = (navigator2) => { | ||
let os2 = "unknown"; | ||
const clientStrings = [ | ||
{ 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)/ | ||
} | ||
__privateSet(this, _http2_session_idle_ms, http2_session_idle_ms); | ||
__privateSet(this, _url, url); | ||
__privateSet(this, _session, null); | ||
]; | ||
for (const id in clientStrings) { | ||
const cs = clientStrings[id]; | ||
if (cs.r.test(navigator2.userAgent)) { | ||
os2 = cs.s; | ||
break; | ||
} | ||
} | ||
static getClient(httpClientOptions) { | ||
var _a; | ||
const clientKey = __privateMethod(_a = _NodeHTTP2Client, _getClientKey, getClientKey_fn).call(_a, httpClientOptions); | ||
if (!__privateGet(_NodeHTTP2Client, _clients).has(clientKey)) { | ||
__privateGet(_NodeHTTP2Client, _clients).set( | ||
clientKey, | ||
new _NodeHTTP2Client(httpClientOptions) | ||
); | ||
let osVersion = "unknown"; | ||
if (/Windows/.test(os2)) { | ||
osVersion; | ||
const matches = /Windows (.*)/.exec(os2); | ||
if (matches) { | ||
osVersion = matches[1]; | ||
} | ||
const client = __privateGet(_NodeHTTP2Client, _clients).get(clientKey); | ||
__privateWrapper(client, _numberOfUsers)._++; | ||
return client; | ||
os2 = "Windows"; | ||
} | ||
async request(req) { | ||
let retryCount = 0; | ||
let memoizedError; | ||
do { | ||
try { | ||
return await __privateMethod(this, _doRequest, doRequest_fn).call(this, req); | ||
} catch (error) { | ||
if (error?.code !== "ERR_HTTP2_GOAWAY_SESSION") { | ||
throw new NetworkError( | ||
"The network connection encountered a problem.", | ||
{ | ||
cause: error | ||
} | ||
); | ||
} | ||
memoizedError = error; | ||
retryCount++; | ||
switch (os2) { | ||
case "Mac OS": | ||
case "Mac OS X": | ||
case "Android": { | ||
const matches = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec( | ||
navigator2.userAgent | ||
); | ||
if (matches) { | ||
osVersion = matches[1]; | ||
} | ||
} while (retryCount < 3); | ||
throw new NetworkError("The network connection encountered a problem.", { | ||
cause: memoizedError | ||
}); | ||
} | ||
close() { | ||
if (this.isClosed()) { | ||
return; | ||
break; | ||
} | ||
__privateWrapper(this, _numberOfUsers)._--; | ||
if (__privateGet(this, _numberOfUsers) === 0 && __privateGet(this, _session) && !__privateGet(this, _session).closed) { | ||
__privateGet(this, _session).close(); | ||
case "iOS": { | ||
const matches = /OS (\d+)_(\d+)_?(\d+)?/.exec(navigator2.appVersion); | ||
if (matches) { | ||
osVersion = matches[1] + "." + matches[2] + "." + (matches[3] ?? 0); | ||
} | ||
break; | ||
} | ||
} | ||
isClosed() { | ||
return __privateGet(this, _numberOfUsers) === 0; | ||
} | ||
return [os2, osVersion].join("-"); | ||
}; | ||
var NodeHTTP2Client = _NodeHTTP2Client; | ||
_clients = new WeakMap(); | ||
_http2_session_idle_ms = new WeakMap(); | ||
_url = new WeakMap(); | ||
_numberOfUsers = new WeakMap(); | ||
_session = new WeakMap(); | ||
_getClientKey = new WeakSet(); | ||
getClientKey_fn = function({ http2_session_idle_ms, url }) { | ||
return `${url}|${http2_session_idle_ms}`; | ||
}; | ||
_closeForAll = new WeakSet(); | ||
closeForAll_fn = function() { | ||
__privateSet(this, _numberOfUsers, 0); | ||
if (__privateGet(this, _session) && !__privateGet(this, _session).closed) { | ||
__privateGet(this, _session).close(); | ||
var crossGlobal = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : self; | ||
var getNodeRuntimeEnv = () => { | ||
if (!(typeof process !== "undefined" && process && process.env)) { | ||
return "unkown"; | ||
} | ||
}; | ||
_connect = new WeakSet(); | ||
connect_fn = function() { | ||
if (!__privateGet(this, _session) || __privateGet(this, _session).closed) { | ||
const new_session = http2.connect(__privateGet(this, _url)).once("error", () => __privateMethod(this, _closeForAll, closeForAll_fn).call(this)).once("goaway", () => __privateMethod(this, _closeForAll, closeForAll_fn).call(this)); | ||
new_session.setTimeout(__privateGet(this, _http2_session_idle_ms), () => { | ||
__privateMethod(this, _closeForAll, closeForAll_fn).call(this); | ||
}); | ||
__privateSet(this, _session, new_session); | ||
} | ||
return __privateGet(this, _session); | ||
}; | ||
_doRequest = new WeakSet(); | ||
doRequest_fn = function({ | ||
client_timeout_ms, | ||
data: requestData, | ||
headers: requestHeaders, | ||
method | ||
}) { | ||
return new Promise((resolvePromise, rejectPromise) => { | ||
let req; | ||
const onResponse = (http2ResponseHeaders) => { | ||
const status = Number( | ||
http2ResponseHeaders[http2.constants.HTTP2_HEADER_STATUS] | ||
); | ||
let responseData = ""; | ||
req.on("data", (chunk) => { | ||
responseData += chunk; | ||
}); | ||
req.on("end", () => { | ||
resolvePromise({ | ||
status, | ||
body: responseData, | ||
headers: http2ResponseHeaders | ||
}); | ||
}); | ||
}; | ||
try { | ||
const httpRequestHeaders = { | ||
...requestHeaders, | ||
[http2.constants.HTTP2_HEADER_PATH]: "/query/1", | ||
[http2.constants.HTTP2_HEADER_METHOD]: method | ||
}; | ||
const session = __privateMethod(this, _connect, connect_fn).call(this); | ||
req = session.request(httpRequestHeaders).setEncoding("utf8").on("error", (error) => { | ||
rejectPromise(error); | ||
}).on("response", onResponse); | ||
req.write(JSON.stringify(requestData), "utf8"); | ||
req.setTimeout(client_timeout_ms, () => { | ||
req.destroy(new Error(`Client timeout`)); | ||
}); | ||
req.end(); | ||
} catch (error) { | ||
rejectPromise(error); | ||
const runtimeEnvs = [ | ||
{ | ||
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 crossGlobal?.StitchError === "function"; | ||
} | ||
}, | ||
{ | ||
name: "Render", | ||
check: function() { | ||
return !!process.env["RENDER_SERVICE_ID"]; | ||
} | ||
}, | ||
{ | ||
name: "Begin", | ||
check: function() { | ||
return !!process.env["BEGIN_DATA_SCOPE_ID"]; | ||
} | ||
} | ||
}); | ||
]; | ||
const detectedEnv = runtimeEnvs.find((env) => env.check()); | ||
return detectedEnv ? detectedEnv.name : "unknown"; | ||
}; | ||
__privateAdd(NodeHTTP2Client, _getClientKey); | ||
__privateAdd(NodeHTTP2Client, _clients, /* @__PURE__ */ new Map()); | ||
// src/http-client/index.ts | ||
var getDefaultHTTPClient = (options) => isNode() ? NodeHTTP2Client.getClient(options) : new FetchClient(options); | ||
var isHTTPResponse = (res) => res instanceof Object && "body" in res && "headers" in res && "status" in res; | ||
var isNode = () => { | ||
if (typeof process !== "undefined" && process.release?.name === "node") { | ||
try { | ||
require("node:http2"); | ||
return true; | ||
} catch (_) { | ||
return false; | ||
} | ||
} | ||
return false; | ||
}; | ||
// src/wire-protocol.ts | ||
var isQuerySuccess = (res) => res instanceof Object && "data" in res; | ||
var isQueryFailure = (res) => res instanceof Object && "error" in res && res.error instanceof Object && "code" in res.error && "message" in res.error; | ||
@@ -980,35 +1216,42 @@ // src/client.ts | ||
}; | ||
var Client = class { | ||
#clientConfiguration; | ||
#httpClient; | ||
#lastTxnTs; | ||
#isClosed = false; | ||
var _driverEnvHeader, _clientConfiguration, _httpClient, _lastTxnTs, _isClosed, _getError, getError_fn, _getSecret, getSecret_fn, _getServiceError, getServiceError_fn, _query, query_fn, _setHeaders, setHeaders_fn, _validateConfiguration, validateConfiguration_fn; | ||
var _Client = class { | ||
constructor(clientConfiguration, httpClient) { | ||
this.#clientConfiguration = { | ||
__privateAdd(this, _getError); | ||
__privateAdd(this, _getSecret); | ||
__privateAdd(this, _getServiceError); | ||
__privateAdd(this, _query); | ||
__privateAdd(this, _setHeaders); | ||
__privateAdd(this, _validateConfiguration); | ||
__privateAdd(this, _clientConfiguration, void 0); | ||
__privateAdd(this, _httpClient, void 0); | ||
__privateAdd(this, _lastTxnTs, void 0); | ||
__privateAdd(this, _isClosed, false); | ||
__privateSet(this, _clientConfiguration, { | ||
...DEFAULT_CLIENT_CONFIG, | ||
...clientConfiguration, | ||
secret: this.#getSecret(clientConfiguration) | ||
}; | ||
this.#validateConfiguration(); | ||
secret: __privateMethod(this, _getSecret, getSecret_fn).call(this, clientConfiguration) | ||
}); | ||
__privateMethod(this, _validateConfiguration, validateConfiguration_fn).call(this); | ||
if (!httpClient) { | ||
this.#httpClient = getDefaultHTTPClient({ | ||
url: this.#clientConfiguration.endpoint.toString(), | ||
http2_session_idle_ms: this.#clientConfiguration.http2_session_idle_ms | ||
}); | ||
__privateSet(this, _httpClient, getDefaultHTTPClient({ | ||
url: __privateGet(this, _clientConfiguration).endpoint.toString(), | ||
http2_session_idle_ms: __privateGet(this, _clientConfiguration).http2_session_idle_ms | ||
})); | ||
} else { | ||
this.#httpClient = httpClient; | ||
__privateSet(this, _httpClient, httpClient); | ||
} | ||
} | ||
get lastTxnTs() { | ||
return this.#lastTxnTs; | ||
return __privateGet(this, _lastTxnTs); | ||
} | ||
set lastTxnTs(ts) { | ||
this.#lastTxnTs = this.#lastTxnTs ? Math.max(ts, this.#lastTxnTs) : ts; | ||
__privateSet(this, _lastTxnTs, __privateGet(this, _lastTxnTs) ? Math.max(ts, __privateGet(this, _lastTxnTs)) : ts); | ||
} | ||
get clientConfiguration() { | ||
const { secret, ...rest } = this.#clientConfiguration; | ||
const { secret, ...rest } = __privateGet(this, _clientConfiguration); | ||
return rest; | ||
} | ||
close() { | ||
if (this.#isClosed) { | ||
if (__privateGet(this, _isClosed)) { | ||
throw new ClientClosedError( | ||
@@ -1018,4 +1261,4 @@ "Your client is closed. You cannot close it again." | ||
} | ||
this.#httpClient.close(); | ||
this.#isClosed = true; | ||
__privateGet(this, _httpClient).close(); | ||
__privateSet(this, _isClosed, true); | ||
} | ||
@@ -1029,3 +1272,3 @@ paginate(iterable) { | ||
async query(request, headers) { | ||
if (this.#isClosed) { | ||
if (__privateGet(this, _isClosed)) { | ||
throw new ClientClosedError( | ||
@@ -1035,186 +1278,197 @@ "Your client is closed. No further requests can be issued." | ||
} | ||
return this.#query(request.toQuery(headers)); | ||
return __privateMethod(this, _query, query_fn).call(this, request.toQuery(headers)); | ||
} | ||
#getError(e) { | ||
if (e instanceof ClientError || e instanceof NetworkError || e instanceof ProtocolError || e instanceof ServiceError) { | ||
return e; | ||
}; | ||
var Client = _Client; | ||
_driverEnvHeader = new WeakMap(); | ||
_clientConfiguration = new WeakMap(); | ||
_httpClient = new WeakMap(); | ||
_lastTxnTs = new WeakMap(); | ||
_isClosed = new WeakMap(); | ||
_getError = new WeakSet(); | ||
getError_fn = function(e) { | ||
if (e instanceof ClientError || e instanceof NetworkError || e instanceof ProtocolError || e instanceof ServiceError) { | ||
return e; | ||
} | ||
if (isHTTPResponse(e)) { | ||
if (isQueryFailure(e.body)) { | ||
const failure = e.body; | ||
const status = e.status; | ||
return __privateMethod(this, _getServiceError, getServiceError_fn).call(this, failure, status); | ||
} | ||
if (isHTTPResponse(e)) { | ||
if (isQueryFailure(e.body)) { | ||
const failure = e.body; | ||
const status = e.status; | ||
return this.#getServiceError(failure, status); | ||
} | ||
return new ProtocolError({ | ||
message: `Response is in an unkown format: ${e.body}`, | ||
httpStatus: e.status | ||
}); | ||
return new ProtocolError({ | ||
message: `Response is in an unkown format: ${e.body}`, | ||
httpStatus: e.status | ||
}); | ||
} | ||
return new ClientError( | ||
"A client level error occurred. Fauna was not called.", | ||
{ | ||
cause: e | ||
} | ||
return new ClientError( | ||
"A client level error occurred. Fauna was not called.", | ||
{ | ||
cause: e | ||
} | ||
); | ||
}; | ||
_getSecret = new WeakSet(); | ||
getSecret_fn = function(partialClientConfig) { | ||
let fallback = void 0; | ||
if (typeof process === "object") { | ||
fallback = process.env["FAUNA_SECRET"]; | ||
} | ||
const maybeSecret = partialClientConfig?.secret || fallback; | ||
if (maybeSecret === 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." | ||
); | ||
} | ||
#getSecret(partialClientConfig) { | ||
let fallback = void 0; | ||
if (typeof process === "object") { | ||
fallback = process.env["FAUNA_SECRET"]; | ||
} | ||
const maybeSecret = partialClientConfig?.secret || fallback; | ||
if (maybeSecret === 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 maybeSecret; | ||
return maybeSecret; | ||
}; | ||
_getServiceError = new WeakSet(); | ||
getServiceError_fn = function(failure, httpStatus) { | ||
switch (httpStatus) { | ||
case 400: | ||
if (QUERY_CHECK_FAILURE_CODES.includes(failure.error.code)) { | ||
return new QueryCheckError(failure, httpStatus); | ||
} | ||
if (failure.error.code === "invalid_request") { | ||
return new InvalidRequestError(failure, httpStatus); | ||
} | ||
if (failure.error.code === "abort" && failure.error.abort !== void 0) { | ||
return new AbortError( | ||
failure, | ||
httpStatus | ||
); | ||
} | ||
return new QueryRuntimeError(failure, httpStatus); | ||
case 401: | ||
return new AuthenticationError(failure, httpStatus); | ||
case 403: | ||
return new AuthorizationError(failure, httpStatus); | ||
case 409: | ||
return new ContendedTransactionError(failure, httpStatus); | ||
case 429: | ||
return new ThrottlingError(failure, httpStatus); | ||
case 440: | ||
return new QueryTimeoutError(failure, httpStatus); | ||
case 500: | ||
return new ServiceInternalError(failure, httpStatus); | ||
case 503: | ||
return new ServiceTimeoutError(failure, httpStatus); | ||
default: | ||
return new ServiceError(failure, httpStatus); | ||
} | ||
#getServiceError(failure, httpStatus) { | ||
switch (httpStatus) { | ||
case 400: | ||
if (QUERY_CHECK_FAILURE_CODES.includes(failure.error.code)) { | ||
return new QueryCheckError(failure, httpStatus); | ||
} | ||
if (failure.error.code === "invalid_request") { | ||
return new InvalidRequestError(failure, httpStatus); | ||
} | ||
if (failure.error.code === "abort" && failure.error.abort !== void 0) { | ||
return new AbortError( | ||
failure, | ||
httpStatus | ||
); | ||
} | ||
return new QueryRuntimeError(failure, httpStatus); | ||
case 401: | ||
return new AuthenticationError(failure, httpStatus); | ||
case 403: | ||
return new AuthorizationError(failure, httpStatus); | ||
case 409: | ||
return new ContendedTransactionError(failure, httpStatus); | ||
case 429: | ||
return new ThrottlingError(failure, httpStatus); | ||
case 440: | ||
return new QueryTimeoutError(failure, httpStatus); | ||
case 500: | ||
return new ServiceInternalError(failure, httpStatus); | ||
case 503: | ||
return new ServiceTimeoutError(failure, httpStatus); | ||
default: | ||
return new ServiceError(failure, httpStatus); | ||
} | ||
} | ||
async #query(queryRequest) { | ||
}; | ||
_query = new WeakSet(); | ||
query_fn = async function(queryRequest) { | ||
try { | ||
const headers = { | ||
Authorization: `Bearer ${__privateGet(this, _clientConfiguration).secret}` | ||
}; | ||
__privateMethod(this, _setHeaders, setHeaders_fn).call(this, { ...this.clientConfiguration, ...queryRequest }, headers); | ||
const requestConfig = { | ||
...__privateGet(this, _clientConfiguration), | ||
...queryRequest | ||
}; | ||
const isTaggedFormat = requestConfig.format === "tagged" || queryRequest.format === "tagged"; | ||
const queryArgs = isTaggedFormat ? TaggedTypeFormat.encode(queryRequest.arguments) : queryRequest.arguments; | ||
const requestData = { | ||
query: queryRequest.query, | ||
arguments: queryArgs | ||
}; | ||
const client_timeout_ms = requestConfig.query_timeout_ms + __privateGet(this, _clientConfiguration).client_timeout_buffer_ms; | ||
const fetchResponse = await __privateGet(this, _httpClient).request({ | ||
data: requestData, | ||
headers, | ||
method: "POST", | ||
client_timeout_ms | ||
}); | ||
let parsedResponse; | ||
try { | ||
const headers = { | ||
Authorization: `Bearer ${this.#clientConfiguration.secret}` | ||
parsedResponse = { | ||
...fetchResponse, | ||
body: isTaggedFormat ? TaggedTypeFormat.decode(fetchResponse.body) : JSON.parse(fetchResponse.body) | ||
}; | ||
this.#setHeaders( | ||
{ ...this.clientConfiguration, ...queryRequest }, | ||
headers | ||
); | ||
const requestConfig = { | ||
...this.#clientConfiguration, | ||
...queryRequest | ||
}; | ||
const isTaggedFormat = requestConfig.format === "tagged" || queryRequest.format === "tagged"; | ||
const queryArgs = isTaggedFormat ? TaggedTypeFormat.encode(queryRequest.arguments) : queryRequest.arguments; | ||
const requestData = { | ||
query: queryRequest.query, | ||
arguments: queryArgs | ||
}; | ||
const client_timeout_ms = requestConfig.query_timeout_ms + this.#clientConfiguration.client_timeout_buffer_ms; | ||
const fetchResponse = await this.#httpClient.request({ | ||
data: requestData, | ||
headers, | ||
method: "POST", | ||
client_timeout_ms | ||
if (parsedResponse.body.query_tags) { | ||
const tags_array = parsedResponse.body.query_tags.split(",").map((tag) => tag.split("=")); | ||
parsedResponse.body.query_tags = Object.fromEntries(tags_array); | ||
} | ||
} catch (error) { | ||
throw new ProtocolError({ | ||
message: `Error parsing response as JSON: ${error}`, | ||
httpStatus: fetchResponse.status | ||
}); | ||
let parsedResponse; | ||
try { | ||
parsedResponse = { | ||
...fetchResponse, | ||
body: isTaggedFormat ? TaggedTypeFormat.decode(fetchResponse.body) : JSON.parse(fetchResponse.body) | ||
}; | ||
if (parsedResponse.body.query_tags) { | ||
const tags_array = parsedResponse.body.query_tags.split(",").map((tag) => tag.split("=")); | ||
parsedResponse.body.query_tags = Object.fromEntries(tags_array); | ||
} | ||
} catch (error) { | ||
throw new ProtocolError({ | ||
message: `Error parsing response as JSON: ${error}`, | ||
httpStatus: fetchResponse.status | ||
}); | ||
} | ||
if (!isQuerySuccess(parsedResponse.body)) { | ||
throw this.#getError(parsedResponse); | ||
} | ||
const txn_ts = parsedResponse.body.txn_ts; | ||
if (this.#lastTxnTs === void 0 && txn_ts !== void 0 || txn_ts !== void 0 && this.#lastTxnTs !== void 0 && this.#lastTxnTs < txn_ts) { | ||
this.#lastTxnTs = txn_ts; | ||
} | ||
return parsedResponse.body; | ||
} catch (e) { | ||
throw this.#getError(e); | ||
} | ||
if (!isQuerySuccess(parsedResponse.body)) { | ||
throw __privateMethod(this, _getError, getError_fn).call(this, parsedResponse); | ||
} | ||
const txn_ts = parsedResponse.body.txn_ts; | ||
if (__privateGet(this, _lastTxnTs) === void 0 && txn_ts !== void 0 || txn_ts !== void 0 && __privateGet(this, _lastTxnTs) !== void 0 && __privateGet(this, _lastTxnTs) < txn_ts) { | ||
__privateSet(this, _lastTxnTs, txn_ts); | ||
} | ||
return parsedResponse.body; | ||
} catch (e) { | ||
throw __privateMethod(this, _getError, getError_fn).call(this, e); | ||
} | ||
#setHeaders(fromObject, headerObject) { | ||
for (const entry of Object.entries(fromObject)) { | ||
if ([ | ||
"format", | ||
"query_timeout_ms", | ||
"linearized", | ||
"max_contention_retries", | ||
"traceparent", | ||
"typecheck", | ||
"query_tags" | ||
].includes(entry[0])) { | ||
let headerValue; | ||
let headerKey = `x-${entry[0].replaceAll("_", "-")}`; | ||
if ("query_tags" === entry[0]) { | ||
headerValue = Object.entries(entry[1]).map((tag) => tag.join("=")).join(","); | ||
}; | ||
_setHeaders = new WeakSet(); | ||
setHeaders_fn = function(fromObject, headerObject) { | ||
for (const entry of Object.entries(fromObject)) { | ||
if ([ | ||
"format", | ||
"query_timeout_ms", | ||
"linearized", | ||
"max_contention_retries", | ||
"traceparent", | ||
"typecheck", | ||
"query_tags" | ||
].includes(entry[0])) { | ||
let headerValue; | ||
let headerKey = `x-${entry[0].replaceAll("_", "-")}`; | ||
if ("query_tags" === entry[0]) { | ||
headerValue = Object.entries(entry[1]).map((tag) => tag.join("=")).join(","); | ||
} else { | ||
if (typeof entry[1] === "string") { | ||
headerValue = entry[1]; | ||
} else { | ||
if (typeof entry[1] === "string") { | ||
headerValue = entry[1]; | ||
} else { | ||
headerValue = String(entry[1]); | ||
} | ||
headerValue = String(entry[1]); | ||
} | ||
if ("traceparent" === entry[0]) { | ||
headerKey = entry[0]; | ||
} | ||
headerObject[headerKey] = headerValue; | ||
} | ||
if ("traceparent" === entry[0]) { | ||
headerKey = entry[0]; | ||
} | ||
headerObject[headerKey] = headerValue; | ||
} | ||
if (headerObject["x-last-txn-ts"] === void 0 && this.#lastTxnTs !== void 0) { | ||
headerObject["x-last-txn-ts"] = this.#lastTxnTs; | ||
} | ||
} | ||
#validateConfiguration() { | ||
const config = this.#clientConfiguration; | ||
const required_options = [ | ||
"client_timeout_buffer_ms", | ||
"endpoint", | ||
"format", | ||
"http2_session_idle_ms", | ||
"max_conns", | ||
"query_timeout_ms" | ||
]; | ||
required_options.forEach((option) => { | ||
if (config[option] === void 0) { | ||
throw new TypeError( | ||
`ClientConfiguration option '${option}' must be defined.` | ||
); | ||
} | ||
}); | ||
if (config.client_timeout_buffer_ms <= 0) { | ||
throw new RangeError( | ||
`'client_timeout_buffer_ms' must be greater than zero.` | ||
if (headerObject["x-last-txn-ts"] === void 0 && __privateGet(this, _lastTxnTs) !== void 0) { | ||
headerObject["x-last-txn-ts"] = __privateGet(this, _lastTxnTs); | ||
} | ||
headerObject["x-driver-env"] = __privateGet(_Client, _driverEnvHeader); | ||
}; | ||
_validateConfiguration = new WeakSet(); | ||
validateConfiguration_fn = function() { | ||
const config = __privateGet(this, _clientConfiguration); | ||
const required_options = [ | ||
"client_timeout_buffer_ms", | ||
"endpoint", | ||
"format", | ||
"http2_session_idle_ms", | ||
"max_conns", | ||
"query_timeout_ms" | ||
]; | ||
required_options.forEach((option) => { | ||
if (config[option] === void 0) { | ||
throw new TypeError( | ||
`ClientConfiguration option '${option}' must be defined.` | ||
); | ||
} | ||
if (config.query_timeout_ms <= 0) { | ||
throw new RangeError(`'query_timeout_ms' must be greater than zero.`); | ||
} | ||
}); | ||
if (config.client_timeout_buffer_ms <= 0) { | ||
throw new RangeError( | ||
`'client_timeout_buffer_ms' must be greater than zero.` | ||
); | ||
} | ||
if (config.query_timeout_ms <= 0) { | ||
throw new RangeError(`'query_timeout_ms' must be greater than zero.`); | ||
} | ||
}; | ||
__privateAdd(Client, _driverEnvHeader, getDriverEnv()); | ||
var QUERY_CHECK_FAILURE_CODES = [ | ||
@@ -1221,0 +1475,0 @@ "invalid_function_definition", |
{ | ||
"name": "fauna", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "A driver to query Fauna databases in browsers, Node.js, and other Javascript runtimes", | ||
@@ -23,2 +23,3 @@ "homepage": "https://fauna.com", | ||
"@types/node": "^18.13.0", | ||
"@types/serviceworker": "^0.0.67", | ||
"@typescript-eslint/eslint-plugin": "^5.52.0", | ||
@@ -25,0 +26,0 @@ "@typescript-eslint/parser": "^5.52.0", |
@@ -20,3 +20,11 @@ import { ClientConfiguration, endpoints } from "./client-configuration"; | ||
} from "./errors"; | ||
import { | ||
getDefaultHTTPClient, | ||
isHTTPResponse, | ||
type HTTPClient, | ||
} from "./http-client"; | ||
import { Query } from "./query-builder"; | ||
import { TaggedTypeFormat } from "./tagged-type"; | ||
import { getDriverEnv } from "./util/environment"; | ||
import { EmbeddedSet, Page, SetIterator } from "./values"; | ||
import { | ||
@@ -31,9 +39,2 @@ isQueryFailure, | ||
} from "./wire-protocol"; | ||
import { | ||
getDefaultHTTPClient, | ||
isHTTPResponse, | ||
type HTTPClient, | ||
} from "./http-client"; | ||
import { TaggedTypeFormat } from "./tagged-type"; | ||
import { EmbeddedSet, Page, SetIterator } from "./values"; | ||
@@ -53,2 +54,5 @@ export const DEFAULT_CLIENT_CONFIG: Omit<ClientConfiguration, "secret"> = { | ||
export class Client { | ||
/** A static copy of the driver env header to send with each request */ | ||
static readonly #driverEnvHeader = getDriverEnv(); | ||
/** The {@link ClientConfiguration} */ | ||
@@ -445,2 +449,4 @@ readonly #clientConfiguration: ClientConfiguration; | ||
} | ||
headerObject["x-driver-env"] = Client.#driverEnvHeader; | ||
} | ||
@@ -447,0 +453,0 @@ |
@@ -11,3 +11,5 @@ import { FetchClient } from "./fetch-client"; | ||
export const getDefaultHTTPClient = (options: HTTPClientOptions): HTTPClient => | ||
isNode() ? NodeHTTP2Client.getClient(options) : new FetchClient(options); | ||
nodeHttp2IsSupported() | ||
? NodeHTTP2Client.getClient(options) | ||
: new FetchClient(options); | ||
@@ -17,3 +19,3 @@ export const isHTTPResponse = (res: any): res is HTTPResponse => | ||
const isNode = () => { | ||
const nodeHttp2IsSupported = () => { | ||
if (typeof process !== "undefined" && process.release?.name === "node") { | ||
@@ -20,0 +22,0 @@ try { |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 12 instances 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
466927
43
5664
18
36