Comparing version 0.5.5 to 0.5.6
@@ -1,2 +0,2 @@ | ||
var N={default:new URL("https://db.fauna.com"),local:new URL("http://localhost:8443"),localhost:new URL("http://localhost:8443")};var F=class extends Error{constructor(...e){super(...e)}},i=class extends F{httpStatus;code;queryInfo;constraint_failures;constructor(e,r){super(e.error.message),Error.captureStackTrace&&Error.captureStackTrace(this,i),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}},b=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,b),this.name="QueryRuntimeError"}},x=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,x),this.name="QueryCheckError"}},Q=class extends i{stats;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,Q),this.name="QueryTimeoutError",this.stats=e.stats}},S=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,S),this.name="AuthenticationError"}},w=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,w),this.name="AuthorizationError"}},R=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,R),this.name="ThrottlingError"}},E=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,E),this.name="ServiceInternalError"}},q=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,q),this.name="ServiceTimeoutError"}},l=class extends F{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,l),this.name="ClientError"}},y=class extends F{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,y),this.name="NetworkError"}},m=class extends F{httpStatus;constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,m),this.name="ProtocolError",this.httpStatus=e.httpStatus}};var M=t=>t instanceof Object&&"data"in t,L=t=>t instanceof Object&&"error"in t&&t.error instanceof Object&&"code"in t.error&&"message"in t.error;var P=class{async request({data:e,headers:r,method:n,url:o}){let s=await fetch(o,{method:n,headers:{...r,"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(T=>{throw new y("The network connection encountered a problem.",{cause:T})}),a=s.status,c={};s.headers.forEach((T,j)=>c[j]=T);let d=await s.text();return{status:a,body:d,headers:c}}};import{NodeHTTP2Client as Y}from"../../src/http-client/node-http2-client";import{NodeHTTP2Client as K}from"../../src/http-client/node-http2-client";var U=()=>Z()?Y.getClient():new P,z=t=>t instanceof Object&&"body"in t&&"headers"in t&&"status"in t,Z=()=>process!==void 0&&process.release?.name==="node";var X=/(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/,v=/(?:0[1-9]|1[0-2])/,ee=/(?:0[1-9]|[12]\d|3[01])/,J=/(?:[01][0-9]|2[0-3])/,I=/(?:[0-5][0-9])/,te=/(?:\.\d+)/,$=new RegExp(`(${X.source}-(${v.source})-(${ee.source}))`),re=new RegExp(`(${J.source}:${I.source}:${I.source}${te.source}?)`),ne=new RegExp(`([zZ]|[+\u2212-]${J.source}(?::?${I.source}|:${I.source}:${I.source}))`),B=new RegExp(`^${$.source}$`),G=new RegExp(`^${$.source}`),W=new RegExp(`^${$.source}T${re.source}${ne.source}$`);var g=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(W.exec(e)===null)throw new RangeError(`(regex) Expected an ISO date string but received '${e}'`);return new g(e)}static fromDate(e){return new g(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}")`}},p=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=B.exec(e);if(r===null)throw new RangeError(`Expected a plain date string but received '${e}'`);return new p(r[0])}static fromDate(e){let r=e.toISOString(),n=G.exec(r);if(n===null)throw new l(`Failed to parse date '${e}'`);return new p(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 f=class{coll;id;constructor({coll:e,id:r}){this.id=r,typeof e=="string"?this.coll=new h(e):this.coll=e}},_=class extends f{ts;constructor(e){let{coll:r,id:n,ts:o,...s}=e;super({coll:r,id:n}),this.ts=o,Object.assign(this,s)}toObject(){return{...this}}},D=class{coll;name;constructor({coll:e,name:r}){this.name=r,typeof e=="string"?this.coll=new h(e):this.coll=e}},k=class extends D{ts;data;constructor(e){let{coll:r,name:n,ts:o,data:s,...a}=e;super({coll:r,name:n}),this.ts=o,this.data=s||{},Object.assign(this,a)}toObject(){return{...this}}},h=class{name;constructor(e){this.name=e}};var V=class{data;after;constructor({data:e,after:r}){this.data=e,this.after=r}};var C=class{static encode(e){return H(e)}static decode(e){return JSON.parse(e,(r,n)=>{if(n==null)return null;if(n["@mod"])return new h(n["@mod"]);if(n["@doc"]){if(typeof n["@doc"]=="string"){let[s,a]=n["@doc"].split(":");return new f({coll:s,id:a})}let o=n["@doc"];return o.id?new _(o):new k(o)}else if(n["@ref"]){let o=n["@ref"];return o.id?new f(o):new D(o)}else{if(n["@set"])return new V(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 p.from(n["@date"]);if(n["@time"])return g.from(n["@time"]);if(n["@object"])return n["@object"]}return n})}},se=BigInt("-9223372036854775808"),ae=BigInt("9223372036854775807"),u={bigint:t=>{if(t<se||t>ae)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]=H(t[n]));return e?{"@object":r}:r},array:t=>{let e=[];for(let r in t)e.push(H(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=>({data:u.array(t.data),after:t.after})},H=t=>{if(t===void 0)throw new TypeError("Passing undefined as a QueryValue is not supported");switch(typeof t){case"bigint":return u.bigint(t);case"string":return u.string(t);case"number":return u.number(t);case"boolean":return t;case"object":return t==null?null:Array.isArray(t)?u.array(t):t instanceof Date?u.date(t):t instanceof p?u.faunadate(t):t instanceof g?u.faunatime(t):t instanceof h?u.module(t):t instanceof _?u.document(t):t instanceof f?u.documentReference(t):t instanceof k?u.namedDocument(t):t instanceof D?u.namedDocumentReference(t):t instanceof V?u.set(t):u.object(t)}};var ie={endpoint:N.default,max_conns:10},A=class{#t;#r;#e;#n;constructor(e,r){this.#t={...ie,...e,secret:this.#s(e)},this.#n=new URL("/query/1",this.clientConfiguration.endpoint).toString(),r?this.#r=r:this.#r=U()}get lastTxnTs(){return this.#e}set lastTxnTs(e){this.#e=this.#e?Math.max(e,this.#e):e}get clientConfiguration(){let{secret:e,...r}=this.#t;return r}async query(e,r){return this.#i(e.toQuery(r))}#o(e){if(e instanceof l||e instanceof y||e instanceof m||e instanceof i)return e;if(z(e)){if(L(e.body)){let r=e.body,n=e.status;return this.#a(r,n)}return new m({message:`Response is in an unkown format: ${e.body}`,httpStatus:e.status})}return new l("A client level error occurred. Fauna was not called.",{cause:e})}#s(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}#a(e,r){switch(r){case 400:return r===400&&ce.includes(e.error.code)?new x(e,r):new b(e,r);case 401:return new S(e,r);case 403:return new w(e,r);case 429:return new R(e,r);case 440:return new Q(e,r);case 500:return new E(e,r);case 503:return new q(e,r);default:return new i(e,r)}}async#i(e){try{let r={Authorization:`Bearer ${this.#t.secret}`};this.#c({...this.clientConfiguration,...e},r);let n=(this.#t.format??"tagged")==="tagged"||e.format==="tagged",o=n?C.encode(e.arguments):e.arguments,s={query:e.query,arguments:o},a=await this.#r.request({url:this.#n,method:"POST",headers:r,data:s}),c;try{if(c={...a,body:n?C.decode(a.body):JSON.parse(a.body)},c.body.query_tags){let T=c.body.query_tags.split(",").map(j=>j.split("="));c.body.query_tags=Object.fromEntries(T)}}catch(T){throw new m({message:`Error parsing response as JSON: ${T}`,httpStatus:a.status})}if(!M(c.body))throw this.#o(c);let d=c.body.txn_ts;return(this.#e===void 0&&d!==void 0||d!==void 0&&this.#e!==void 0&&this.#e<d)&&(this.#e=d),c.body}catch(r){throw this.#o(r)}}#c(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 o,s=`x-${n[0].replaceAll("_","-")}`;n[0]==="query_tags"?o=Object.entries(n[1]).map(a=>a.join("=")).join(","):typeof n[1]=="string"?o=n[1]:o=String(n[1]),n[0]==="traceparent"&&(s=n[0]),r[s]=o}r["x-last-txn-ts"]===void 0&&this.#e!==void 0&&(r["x-last-txn-ts"]=this.#e)}},ce=["invalid_function_definition","invalid_identifier","invalid_query","invalid_syntax","invalid_type"];function ue(t,...e){return new O(t,...e)}var O=class{#t;#r;constructor(e,...r){if(e.length===0||e.length!==r.length+1)throw new Error("invalid query constructed");this.#t=e,this.#r=r}toQuery(e={}){return{...this.#e(e),...e}}#e(e){if(this.#t.length===1)return{query:{fql:[this.#t[0]]},arguments:{}};let r={};return{query:{fql:this.#t.flatMap((o,s)=>{if(s===this.#t.length-1)return o===""?[]:[o];let a=this.#r[s],c;if(a instanceof O){let d=a.toQuery(e);c=d.query,r={...r,...d.arguments}}else c={value:C.encode(a)};return[o,c].filter(d=>d!=="")})},arguments:r}}};export{S as AuthenticationError,w as AuthorizationError,A as Client,l as ClientError,p as DateStub,_ as Document,f as DocumentReference,P as FetchClient,h as Module,k as NamedDocument,D as NamedDocumentReference,y as NetworkError,K as NodeHTTP2Client,V as Page,m as ProtocolError,x as QueryCheckError,b as QueryRuntimeError,Q as QueryTimeoutError,i as ServiceError,E as ServiceInternalError,q as ServiceTimeoutError,R as ThrottlingError,g as TimeStub,N as endpoints,ue as fql}; | ||
var N={default:new URL("https://db.fauna.com"),local:new URL("http://localhost:8443"),localhost:new URL("http://localhost:8443")};var F=class extends Error{constructor(...e){super(...e)}},i=class extends F{httpStatus;code;queryInfo;constraint_failures;constructor(e,r){super(e.error.message),Error.captureStackTrace&&Error.captureStackTrace(this,i),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}},b=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,b),this.name="QueryRuntimeError"}},x=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,x),this.name="QueryCheckError"}},Q=class extends i{stats;constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,Q),this.name="QueryTimeoutError",this.stats=e.stats}},S=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,S),this.name="AuthenticationError"}},w=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,w),this.name="AuthorizationError"}},R=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,R),this.name="ThrottlingError"}},E=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,E),this.name="ServiceInternalError"}},q=class extends i{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,q),this.name="ServiceTimeoutError"}},l=class extends F{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,l),this.name="ClientError"}},y=class extends F{constructor(e,r){super(e,r),Error.captureStackTrace&&Error.captureStackTrace(this,y),this.name="NetworkError"}},m=class extends F{httpStatus;constructor(e){super(e.message),Error.captureStackTrace&&Error.captureStackTrace(this,m),this.name="ProtocolError",this.httpStatus=e.httpStatus}};var M=t=>t instanceof Object&&"data"in t,L=t=>t instanceof Object&&"error"in t&&t.error instanceof Object&&"code"in t.error&&"message"in t.error;var P=class{async request({data:e,headers:r,method:n,url:o}){let s=await fetch(o,{method:n,headers:{...r,"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(T=>{throw new y("The network connection encountered a problem.",{cause:T})}),a=s.status,c={};s.headers.forEach((T,j)=>c[j]=T);let d=await s.text();return{status:a,body:d,headers:c}}};import{NodeHTTP2Client as Y}from"../../src/http-client/node-http2-client";import{NodeHTTP2Client as K}from"../../src/http-client/node-http2-client";var U=()=>Z()?Y.getClient():new P,z=t=>t instanceof Object&&"body"in t&&"headers"in t&&"status"in t;function Z(){return typeof process<"u"?process.release?.name==="node":!1}var X=/(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/,v=/(?:0[1-9]|1[0-2])/,ee=/(?:0[1-9]|[12]\d|3[01])/,J=/(?:[01][0-9]|2[0-3])/,I=/(?:[0-5][0-9])/,te=/(?:\.\d+)/,$=new RegExp(`(${X.source}-(${v.source})-(${ee.source}))`),re=new RegExp(`(${J.source}:${I.source}:${I.source}${te.source}?)`),ne=new RegExp(`([zZ]|[+\u2212-]${J.source}(?::?${I.source}|:${I.source}:${I.source}))`),B=new RegExp(`^${$.source}$`),G=new RegExp(`^${$.source}`),W=new RegExp(`^${$.source}T${re.source}${ne.source}$`);var p=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(W.exec(e)===null)throw new RangeError(`(regex) Expected an ISO date string but received '${e}'`);return new p(e)}static fromDate(e){return new p(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}")`}},g=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=B.exec(e);if(r===null)throw new RangeError(`Expected a plain date string but received '${e}'`);return new g(r[0])}static fromDate(e){let r=e.toISOString(),n=G.exec(r);if(n===null)throw new l(`Failed to parse date '${e}'`);return new g(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 f=class{coll;id;constructor({coll:e,id:r}){this.id=r,typeof e=="string"?this.coll=new h(e):this.coll=e}},_=class extends f{ts;constructor(e){let{coll:r,id:n,ts:o,...s}=e;super({coll:r,id:n}),this.ts=o,Object.assign(this,s)}toObject(){return{...this}}},D=class{coll;name;constructor({coll:e,name:r}){this.name=r,typeof e=="string"?this.coll=new h(e):this.coll=e}},k=class extends D{ts;data;constructor(e){let{coll:r,name:n,ts:o,data:s,...a}=e;super({coll:r,name:n}),this.ts=o,this.data=s||{},Object.assign(this,a)}toObject(){return{...this}}},h=class{name;constructor(e){this.name=e}};var V=class{data;after;constructor({data:e,after:r}){this.data=e,this.after=r}};var C=class{static encode(e){return H(e)}static decode(e){return JSON.parse(e,(r,n)=>{if(n==null)return null;if(n["@mod"])return new h(n["@mod"]);if(n["@doc"]){if(typeof n["@doc"]=="string"){let[s,a]=n["@doc"].split(":");return new f({coll:s,id:a})}let o=n["@doc"];return o.id?new _(o):new k(o)}else if(n["@ref"]){let o=n["@ref"];return o.id?new f(o):new D(o)}else{if(n["@set"])return new V(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 g.from(n["@date"]);if(n["@time"])return p.from(n["@time"]);if(n["@object"])return n["@object"]}return n})}},se=BigInt("-9223372036854775808"),ae=BigInt("9223372036854775807"),u={bigint:t=>{if(t<se||t>ae)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]=H(t[n]));return e?{"@object":r}:r},array:t=>{let e=[];for(let r in t)e.push(H(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=>({data:u.array(t.data),after:t.after})},H=t=>{if(t===void 0)throw new TypeError("Passing undefined as a QueryValue is not supported");switch(typeof t){case"bigint":return u.bigint(t);case"string":return u.string(t);case"number":return u.number(t);case"boolean":return t;case"object":return t==null?null:Array.isArray(t)?u.array(t):t instanceof Date?u.date(t):t instanceof g?u.faunadate(t):t instanceof p?u.faunatime(t):t instanceof h?u.module(t):t instanceof _?u.document(t):t instanceof f?u.documentReference(t):t instanceof k?u.namedDocument(t):t instanceof D?u.namedDocumentReference(t):t instanceof V?u.set(t):u.object(t)}};var ie={endpoint:N.default,max_conns:10},A=class{#t;#r;#e;#n;constructor(e,r){this.#t={...ie,...e,secret:this.#s(e)},this.#n=new URL("/query/1",this.clientConfiguration.endpoint).toString(),r?this.#r=r:this.#r=U()}get lastTxnTs(){return this.#e}set lastTxnTs(e){this.#e=this.#e?Math.max(e,this.#e):e}get clientConfiguration(){let{secret:e,...r}=this.#t;return r}async query(e,r){return this.#i(e.toQuery(r))}#o(e){if(e instanceof l||e instanceof y||e instanceof m||e instanceof i)return e;if(z(e)){if(L(e.body)){let r=e.body,n=e.status;return this.#a(r,n)}return new m({message:`Response is in an unkown format: ${e.body}`,httpStatus:e.status})}return new l("A client level error occurred. Fauna was not called.",{cause:e})}#s(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}#a(e,r){switch(r){case 400:return r===400&&ce.includes(e.error.code)?new x(e,r):new b(e,r);case 401:return new S(e,r);case 403:return new w(e,r);case 429:return new R(e,r);case 440:return new Q(e,r);case 500:return new E(e,r);case 503:return new q(e,r);default:return new i(e,r)}}async#i(e){try{let r={Authorization:`Bearer ${this.#t.secret}`};this.#c({...this.clientConfiguration,...e},r);let n=(this.#t.format??"tagged")==="tagged"||e.format==="tagged",o=n?C.encode(e.arguments):e.arguments,s={query:e.query,arguments:o},a=await this.#r.request({url:this.#n,method:"POST",headers:r,data:s}),c;try{if(c={...a,body:n?C.decode(a.body):JSON.parse(a.body)},c.body.query_tags){let T=c.body.query_tags.split(",").map(j=>j.split("="));c.body.query_tags=Object.fromEntries(T)}}catch(T){throw new m({message:`Error parsing response as JSON: ${T}`,httpStatus:a.status})}if(!M(c.body))throw this.#o(c);let d=c.body.txn_ts;return(this.#e===void 0&&d!==void 0||d!==void 0&&this.#e!==void 0&&this.#e<d)&&(this.#e=d),c.body}catch(r){throw this.#o(r)}}#c(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 o,s=`x-${n[0].replaceAll("_","-")}`;n[0]==="query_tags"?o=Object.entries(n[1]).map(a=>a.join("=")).join(","):typeof n[1]=="string"?o=n[1]:o=String(n[1]),n[0]==="traceparent"&&(s=n[0]),r[s]=o}r["x-last-txn-ts"]===void 0&&this.#e!==void 0&&(r["x-last-txn-ts"]=this.#e)}},ce=["invalid_function_definition","invalid_identifier","invalid_query","invalid_syntax","invalid_type"];function ue(t,...e){return new O(t,...e)}var O=class{#t;#r;constructor(e,...r){if(e.length===0||e.length!==r.length+1)throw new Error("invalid query constructed");this.#t=e,this.#r=r}toQuery(e={}){return{...this.#e(e),...e}}#e(e){if(this.#t.length===1)return{query:{fql:[this.#t[0]]},arguments:{}};let r={};return{query:{fql:this.#t.flatMap((o,s)=>{if(s===this.#t.length-1)return o===""?[]:[o];let a=this.#r[s],c;if(a instanceof O){let d=a.toQuery(e);c=d.query,r={...r,...d.arguments}}else c={value:C.encode(a)};return[o,c].filter(d=>d!=="")})},arguments:r}}};export{S as AuthenticationError,w as AuthorizationError,A as Client,l as ClientError,g as DateStub,_ as Document,f as DocumentReference,P as FetchClient,h as Module,k as NamedDocument,D as NamedDocumentReference,y as NetworkError,K as NodeHTTP2Client,V as Page,m as ProtocolError,x as QueryCheckError,b as QueryRuntimeError,Q as QueryTimeoutError,i as ServiceError,E as ServiceInternalError,q as ServiceTimeoutError,R as ThrottlingError,p as TimeStub,N as endpoints,ue as fql}; | ||
//# sourceMappingURL=index.js.map |
@@ -370,3 +370,8 @@ "use strict"; | ||
var isHTTPResponse = (res) => res instanceof Object && "body" in res && "headers" in res && "status" in res; | ||
var isNode = () => process !== void 0 && process.release?.name === "node"; | ||
function isNode() { | ||
if (typeof process !== "undefined") { | ||
return process.release?.name === "node"; | ||
} | ||
return false; | ||
} | ||
@@ -373,0 +378,0 @@ // src/regex.ts |
{ | ||
"name": "fauna", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "A driver to query Fauna databases in browsers, Node.js, and other Javascript runtimes", | ||
@@ -5,0 +5,0 @@ "homepage": "https://fauna.com", |
@@ -53,2 +53,7 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const isNode = () => process !== undefined && process.release?.name === "node"; | ||
function isNode() { | ||
if (typeof process !== "undefined") { | ||
return process.release?.name === "node"; | ||
} | ||
return false; | ||
} |
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
306501
3824