@nhost/nhost-js
Advanced tools
Comparing version 1.1.13 to 1.1.14
@@ -16,2 +16,3 @@ import { HasuraAuthClient, NhostAuthConstructorParams } from '@nhost/hasura-auth-js'; | ||
graphql: NhostGraphqlClient; | ||
readonly devTools?: boolean; | ||
/** | ||
@@ -25,4 +26,4 @@ * Nhost Client | ||
*/ | ||
constructor({ backendUrl, refreshIntervalTime, clientStorageGetter, clientStorageSetter, clientStorage, clientStorageType, autoRefreshToken, autoSignIn, start }: NhostClientConstructorParams); | ||
constructor({ backendUrl, refreshIntervalTime, clientStorageGetter, clientStorageSetter, clientStorage, clientStorageType, autoRefreshToken, autoSignIn, devTools, start }: NhostClientConstructorParams); | ||
} | ||
//# sourceMappingURL=nhost-client.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var v=Object.defineProperty,y=Object.defineProperties;var w=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var d=(r,e,t)=>e in r?v(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,o=(r,e)=>{for(var t in e||(e={}))C.call(e,t)&&d(r,t,e[t]);if(k)for(var t of k(e))N.call(e,t)&&d(r,t,e[t]);return r},l=(r,e)=>y(r,w(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var E=require("@nhost/hasura-auth-js"),S=require("@nhost/hasura-storage-js"),H=require("axios"),_=require("graphql/language/printer");function $(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var p=$(H);class A{constructor(e){const{url:t}=e;this.accessToken=null,this.instance=p.default.create({baseURL:t})}async call(e,t,s){const u=o(o({},this.generateAccessTokenHeaders()),s==null?void 0:s.headers);let a;try{a=await this.instance.post(e,t,l(o({},s),{headers:u}))}catch(i){if(i instanceof Error)return{res:null,error:i}}return a?{res:a,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}}class f{constructor(e){const{url:t}=e;this.url=t,this.accessToken=null,this.instance=p.default.create({baseURL:t})}async request(e,t,s){const u=o(o({},s==null?void 0:s.headers),this.generateAccessTokenHeaders());try{const a="",h=(await this.instance.post("",{operationName:a||void 0,query:typeof e=="string"?e:_.print(e),variables:t},l(o({},s),{headers:u}))).data,{data:c}=h;return h.errors?{data:null,error:h.errors}:typeof c!="object"||Array.isArray(c)||c===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:{data:c,error:null}}catch(a){return a instanceof Error?{data:null,error:a}:(console.error(a),{data:null,error:new Error("Unable to get do GraphQL request")})}}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}}class g{constructor({backendUrl:e,refreshIntervalTime:t,clientStorageGetter:s,clientStorageSetter:u,clientStorage:a,clientStorageType:i,autoRefreshToken:h,autoSignIn:c,start:q=!0}){var T;if(!e)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");this.auth=new E.HasuraAuthClient({url:`${e}/v1/auth`,refreshIntervalTime:t,clientStorageGetter:s,clientStorageSetter:u,clientStorage:a,clientStorageType:i,autoRefreshToken:h,autoSignIn:c,start:q}),this.storage=new S.HasuraStorageClient({url:`${e}/v1/storage`}),this.functions=new A({url:`${e}/v1/functions`}),this.graphql=new f({url:`${e}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),(T=this.auth.client)==null||T.onStart(()=>{this.auth.onAuthStateChanged((n,j)=>{n==="SIGNED_OUT"&&(this.storage.setAccessToken(void 0),this.functions.setAccessToken(void 0),this.graphql.setAccessToken(void 0))}),this.auth.onTokenChanged(n=>{this.storage.setAccessToken(n==null?void 0:n.accessToken),this.functions.setAccessToken(n==null?void 0:n.accessToken),this.graphql.setAccessToken(n==null?void 0:n.accessToken)})})}}const b=r=>new g(r);exports.NhostClient=g;exports.NhostFunctionsClient=A;exports.NhostGraphqlClient=f;exports.createClient=b; | ||
"use strict";var y=Object.defineProperty,w=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var d=(r,e,t)=>e in r?y(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,o=(r,e)=>{for(var t in e||(e={}))N.call(e,t)&&d(r,t,e[t]);if(k)for(var t of k(e))E.call(e,t)&&d(r,t,e[t]);return r},l=(r,e)=>w(r,C(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var S=require("@nhost/hasura-auth-js"),H=require("@nhost/hasura-storage-js"),_=require("axios"),$=require("graphql/language/printer");function b(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var p=b(_);class A{constructor(e){const{url:t}=e;this.accessToken=null,this.instance=p.default.create({baseURL:t})}async call(e,t,s){const u=o(o({},this.generateAccessTokenHeaders()),s==null?void 0:s.headers);let a;try{a=await this.instance.post(e,t,l(o({},s),{headers:u}))}catch(i){if(i instanceof Error)return{res:null,error:i}}return a?{res:a,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}}class f{constructor(e){const{url:t}=e;this.url=t,this.accessToken=null,this.instance=p.default.create({baseURL:t})}async request(e,t,s){const u=o(o({},s==null?void 0:s.headers),this.generateAccessTokenHeaders());try{const a="",h=(await this.instance.post("",{operationName:a||void 0,query:typeof e=="string"?e:$.print(e),variables:t},l(o({},s),{headers:u}))).data,{data:c}=h;return h.errors?{data:null,error:h.errors}:typeof c!="object"||Array.isArray(c)||c===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:{data:c,error:null}}catch(a){return a instanceof Error?{data:null,error:a}:(console.error(a),{data:null,error:new Error("Unable to get do GraphQL request")})}}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}}class g{constructor({backendUrl:e,refreshIntervalTime:t,clientStorageGetter:s,clientStorageSetter:u,clientStorage:a,clientStorageType:i,autoRefreshToken:h,autoSignIn:c,devTools:v,start:q=!0}){var T;if(!e)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");this.auth=new S.HasuraAuthClient({url:`${e}/v1/auth`,refreshIntervalTime:t,clientStorageGetter:s,clientStorageSetter:u,clientStorage:a,clientStorageType:i,autoRefreshToken:h,autoSignIn:c,start:q}),this.storage=new H.HasuraStorageClient({url:`${e}/v1/storage`}),this.functions=new A({url:`${e}/v1/functions`}),this.graphql=new f({url:`${e}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),(T=this.auth.client)==null||T.onStart(()=>{this.auth.onAuthStateChanged((n,G)=>{n==="SIGNED_OUT"&&(this.storage.setAccessToken(void 0),this.functions.setAccessToken(void 0),this.graphql.setAccessToken(void 0))}),this.auth.onTokenChanged(n=>{this.storage.setAccessToken(n==null?void 0:n.accessToken),this.functions.setAccessToken(n==null?void 0:n.accessToken),this.graphql.setAccessToken(n==null?void 0:n.accessToken)})}),this.devTools=v}}const j=r=>new g(r);exports.NhostClient=g;exports.NhostFunctionsClient=A;exports.NhostGraphqlClient=f;exports.createClient=j; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -139,2 +139,3 @@ var __defProp = Object.defineProperty; | ||
autoSignIn, | ||
devTools, | ||
start = true | ||
@@ -182,2 +183,3 @@ }) { | ||
}); | ||
this.devTools = devTools; | ||
} | ||
@@ -184,0 +186,0 @@ } |
{ | ||
"name": "@nhost/nhost-js", | ||
"version": "1.1.13", | ||
"version": "1.1.14", | ||
"description": "Nhost JavaScript SDK", | ||
@@ -42,3 +42,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@nhost/hasura-auth-js": "1.1.8", | ||
"@nhost/hasura-auth-js": "1.1.9", | ||
"@nhost/hasura-storage-js": "0.2.2", | ||
@@ -45,0 +45,0 @@ "axios": "^0.27.2", |
@@ -16,2 +16,3 @@ import { HasuraAuthClient, NhostAuthConstructorParams } from '@nhost/hasura-auth-js'; | ||
graphql: NhostGraphqlClient; | ||
readonly devTools?: boolean; | ||
/** | ||
@@ -25,4 +26,4 @@ * Nhost Client | ||
*/ | ||
constructor({ backendUrl, refreshIntervalTime, clientStorageGetter, clientStorageSetter, clientStorage, clientStorageType, autoRefreshToken, autoSignIn, start }: NhostClientConstructorParams); | ||
constructor({ backendUrl, refreshIntervalTime, clientStorageGetter, clientStorageSetter, clientStorage, clientStorageType, autoRefreshToken, autoSignIn, devTools, start }: NhostClientConstructorParams); | ||
} | ||
//# sourceMappingURL=nhost-client.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
619368
939
+ Added@nhost/core@0.6.0(transitive)
+ Added@nhost/hasura-auth-js@1.1.9(transitive)
- Removed@nhost/core@0.5.6(transitive)
- Removed@nhost/hasura-auth-js@1.1.8(transitive)
Updated@nhost/hasura-auth-js@1.1.9