Comparing version 0.5.4 to 0.5.5
@@ -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 V=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";var U=()=>Z()?Y.getClient():new V,z=t=>t instanceof Object&&"body"in t&&"headers"in t&&"status"in t,Z=()=>process!==void 0&&process.release?.name==="node";var K=/(?:\d{4}|[\u2212-]\d{4,}|\+\d{5,})/,X=/(?:0[1-9]|1[0-2])/,v=/(?:0[1-9]|[12]\d|3[01])/,J=/(?:[01][0-9]|2[0-3])/,I=/(?:[0-5][0-9])/,ee=/(?:\.\d+)/,$=new RegExp(`(${K.source}-(${X.source})-(${v.source}))`),te=new RegExp(`(${J.source}:${I.source}:${I.source}${ee.source}?)`),re=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${te.source}${re.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}},P=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 k=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 P(o)}else if(n["@ref"]){let o=n["@ref"];return o.id?new f(o):new D(o)}else{if(n["@set"])return new k(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})}},oe=BigInt("-9223372036854775808"),se=BigInt("9223372036854775807"),u={bigint:t=>{if(t<oe||t>se)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 P?u.namedDocument(t):t instanceof D?u.namedDocumentReference(t):t instanceof k?u.set(t):u.object(t)}};var ae={endpoint:N.default,max_conns:10},A=class{#t;#r;#e;#n;constructor(e,r){this.#t={...ae,...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&&ie.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)}},ie=["invalid_function_definition","invalid_identifier","invalid_query","invalid_syntax","invalid_type"];function ce(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,h as Module,P as NamedDocument,D as NamedDocumentReference,y as NetworkError,k 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,ce 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,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}; | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,3 @@ import { QueryRequest } from "../wire-protocol"; | ||
export { FetchClient } from "./fetch-client"; | ||
export { NodeHTTP2Client } from "./node-http2-client"; | ||
/** | ||
@@ -7,0 +8,0 @@ * An object representing an http request. |
@@ -7,1 +7,2 @@ export { Client } from "./client"; | ||
export { DateStub, Document, DocumentReference, type DocumentT, Module, NamedDocument, NamedDocumentReference, Page, TimeStub, } from "./values"; | ||
export { FetchClient, NodeHTTP2Client } from "./http-client"; |
@@ -58,2 +58,3 @@ "use strict"; | ||
DocumentReference: () => DocumentReference, | ||
FetchClient: () => FetchClient, | ||
Module: () => Module, | ||
@@ -63,2 +64,3 @@ NamedDocument: () => NamedDocument, | ||
NetworkError: () => NetworkError, | ||
NodeHTTP2Client: () => NodeHTTP2Client, | ||
Page: () => Page, | ||
@@ -254,3 +256,2 @@ ProtocolError: () => ProtocolError, | ||
var import_http2 = __toESM(require("http2")); | ||
var { HTTP2_HEADER_PATH, HTTP2_HEADER_METHOD, HTTP2_HEADER_STATUS } = import_http2.default.constants; | ||
var _client, _sessionMap, _getSession, getSession_fn; | ||
@@ -263,2 +264,5 @@ var _NodeHTTP2Client = class { | ||
static getClient() { | ||
if (import_http2.default === void 0) { | ||
throw new Error("Your platform does not support Node's http2 library"); | ||
} | ||
if (__privateGet(this, _client)) { | ||
@@ -336,3 +340,5 @@ return __privateGet(this, _client); | ||
const onResponse = (http2ResponseHeaders) => { | ||
const status = Number(http2ResponseHeaders[HTTP2_HEADER_STATUS]); | ||
const status = Number( | ||
http2ResponseHeaders[import_http2.default.constants.HTTP2_HEADER_STATUS] | ||
); | ||
let responseData = ""; | ||
@@ -353,4 +359,4 @@ req.on("data", (chunk) => { | ||
...requestHeaders, | ||
[HTTP2_HEADER_PATH]: this.#pathName, | ||
[HTTP2_HEADER_METHOD]: method | ||
[import_http2.default.constants.HTTP2_HEADER_PATH]: this.#pathName, | ||
[import_http2.default.constants.HTTP2_HEADER_METHOD]: method | ||
}; | ||
@@ -943,2 +949,3 @@ req = this.internal.request(httpRequestHeaders).setEncoding("utf8").on("error", (error) => rejectPromise(error)).on("response", onResponse); | ||
DocumentReference, | ||
FetchClient, | ||
Module, | ||
@@ -948,2 +955,3 @@ NamedDocument, | ||
NetworkError, | ||
NodeHTTP2Client, | ||
Page, | ||
@@ -950,0 +958,0 @@ ProtocolError, |
{ | ||
"name": "fauna", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "A driver to query Fauna databases in browsers, Node.js, and other Javascript runtimes", | ||
@@ -5,0 +5,0 @@ "homepage": "https://fauna.com", |
@@ -8,2 +8,3 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export { FetchClient } from "./fetch-client"; | ||
export { NodeHTTP2Client } from "./node-http2-client"; | ||
@@ -10,0 +11,0 @@ /** |
@@ -7,5 +7,2 @@ import http2 from "http2"; | ||
const { HTTP2_HEADER_PATH, HTTP2_HEADER_METHOD, HTTP2_HEADER_STATUS } = | ||
http2.constants; | ||
/** | ||
@@ -26,2 +23,5 @@ * An implementation for {@link HTTPClient} that uses the node http package | ||
static getClient() { | ||
if (http2 === undefined) { | ||
throw new Error("Your platform does not support Node's http2 library"); | ||
} | ||
if (this.#client) { | ||
@@ -133,3 +133,5 @@ return this.#client; | ||
) => { | ||
const status = Number(http2ResponseHeaders[HTTP2_HEADER_STATUS]); | ||
const status = Number( | ||
http2ResponseHeaders[http2.constants.HTTP2_HEADER_STATUS] | ||
); | ||
let responseData = ""; | ||
@@ -156,4 +158,4 @@ | ||
...requestHeaders, | ||
[HTTP2_HEADER_PATH]: this.#pathName, | ||
[HTTP2_HEADER_METHOD]: method, | ||
[http2.constants.HTTP2_HEADER_PATH]: this.#pathName, | ||
[http2.constants.HTTP2_HEADER_METHOD]: method, | ||
}; | ||
@@ -160,0 +162,0 @@ |
@@ -46,1 +46,2 @@ export { Client } from "./client"; | ||
} from "./values"; | ||
export { FetchClient, NodeHTTP2Client } from "./http-client"; |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
306203
3814