@saas-support/react 0.7.5 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -490
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +23 -231
- package/dist/index.js +204 -288
- package/dist/react.cjs +386 -348
- package/dist/react.d.ts +41 -438
- package/dist/react.js +1133 -2075
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class d extends Error{constructor(t,e,s="unknown"){super(e),this.name="SaaSError",this.code=t,this.domain=s}get isNotFound(){return this.code===404}get isUnauthorized(){return this.code===401}get isForbidden(){return this.code===403}get isConflict(){return this.code===409}get isRateLimited(){return this.code===429}}class y{constructor(t,e){this.onUnauthorized=null,this.baseUrl=t,this.authMode=e}setUnauthorizedHandler(t){this.onUnauthorized=t}async request(t,e,s,r){try{return await this.doRequest(t,e,s,r)}catch(i){if(i instanceof d&&i.isUnauthorized&&this.onUnauthorized&&(r!=null&&r.Authorization)){const n=await this.onUnauthorized();if(n)return this.doRequest(t,e,s,{...r,Authorization:`Bearer ${n}`})}throw i}}async get(t,e){return this.request("GET",t,void 0,e)}async post(t,e,s){return this.request("POST",t,e,s)}async patch(t,e,s){return this.request("PATCH",t,e,s)}async del(t,e){return this.request("DELETE",t,void 0,e)}async uploadBinary(t,e,s){try{return await this.doUploadBinary(t,e,s)}catch(r){if(r instanceof d&&r.isUnauthorized&&this.onUnauthorized&&(s!=null&&s.Authorization)){const i=await this.onUnauthorized();if(i)return this.doUploadBinary(t,e,{...s,Authorization:`Bearer ${i}`})}throw r}}async doUploadBinary(t,e,s){const r={"Content-Type":"application/octet-stream",...this.getAuthHeaders(),...s},i=await fetch(`${this.baseUrl}${t}`,{method:"POST",headers:r,body:e}),n=await i.json();if(!i.ok||n.isOk===!1||n.code&&n.code>=400){const a=this.inferDomain(t),c=n.code||i.status;throw new d(c,n.message||"Upload failed",a)}return n.data}async doRequest(t,e,s,r){const i={"Content-Type":"application/json",...this.getAuthHeaders(),...r},n=await fetch(`${this.baseUrl}${e}`,{method:t,headers:i,body:s?JSON.stringify(s):void 0}),a=await n.json();if(!n.ok||a.isOk===!1||a.code&&a.code>=400){const c=this.inferDomain(e),h=a.code||n.status;throw new d(h,a.message||"Request failed",c)}return a.data}getAuthHeaders(){switch(this.authMode.type){case"publishableKey":case"apiKey":return{"X-API-Key":this.authMode.key};case"portalToken":case"embedToken":return{Authorization:`Bearer ${this.authMode.token}`}}}inferDomain(t){return t.startsWith("/auth")?"auth":t.startsWith("/billing")?"billing":t.startsWith("/report")?"report":"unknown"}}class ${constructor(t){this.accessToken=null,this.refreshToken=null,this.refreshTimer=null,this.refreshInFlight=null,this.onRefreshNeeded=null,this.onTokensChanged=null,this.boundHandleStorage=null,this.storageKey=`ss_rt_${t.slice(0,12)}`,this.refreshToken=this.loadRefreshToken(),typeof window<"u"&&(this.boundHandleStorage=this.handleStorageEvent.bind(this),window.addEventListener("storage",this.boundHandleStorage))}setRefreshCallback(t){this.onRefreshNeeded=t}setTokensChangedCallback(t){this.onTokensChanged=t}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}hasRefreshToken(){return this.refreshToken!==null}setTokens(t,e){this.accessToken=t,this.refreshToken=e,this.saveRefreshToken(e),this.scheduleRefresh(t)}clearTokens(){this.accessToken=null,this.refreshToken=null,this.removeRefreshToken(),this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null)}async refreshOnce(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.executeRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}destroy(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),typeof window<"u"&&this.boundHandleStorage&&(window.removeEventListener("storage",this.boundHandleStorage),this.boundHandleStorage=null)}async executeRefresh(){if(!this.onRefreshNeeded)throw new Error("No refresh callback configured");typeof navigator<"u"&&"locks"in navigator?await navigator.locks.request(`ss_refresh_lock_${this.storageKey}`,async()=>{const t=this.loadRefreshToken();t&&t!==this.refreshToken&&(this.refreshToken=t),await this.onRefreshNeeded()}):await this.onRefreshNeeded()}scheduleRefresh(t){this.refreshTimer&&clearTimeout(this.refreshTimer);const e=this.getTokenExpiry(t);if(!e)return;const s=e*1e3-Date.now()-6e4;if(s<=0){this.refreshOnce().catch(()=>{});return}this.refreshTimer=setTimeout(()=>{this.refreshOnce().catch(()=>{})},s)}handleStorageEvent(t){var e;if(t.key===this.storageKey){if(t.newValue===null){this.accessToken=null,this.refreshToken=null,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),(e=this.onTokensChanged)==null||e.call(this);return}t.newValue!==this.refreshToken&&(this.refreshToken=t.newValue,this.accessToken=null,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null))}}getTokenExpiry(t){try{const e=t.split(".")[1];return JSON.parse(atob(e)).exp??null}catch{return null}}loadRefreshToken(){try{return localStorage.getItem(this.storageKey)}catch{return null}}saveRefreshToken(t){try{localStorage.setItem(this.storageKey,t)}catch{}}removeRefreshToken(){try{localStorage.removeItem(this.storageKey)}catch{}}}class R{constructor(){this.listeners=new Map}on(t,e){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e),()=>{var s;(s=this.listeners.get(t))==null||s.delete(e)}}emit(t,e){var s;(s=this.listeners.get(t))==null||s.forEach(r=>r(e))}removeAll(){this.listeners.clear()}}const w=500,T=600,v=5*60*1e3;class b{constructor(t,e,s,r){this.cachedUser=null,this.cachedSettings=null,this.loaded=!1,this.loadPromise=null,this.transport=t,this.tokenManager=e,this.emitter=s,this.baseUrl=r}async load(){if(!this.loaded)return this.loadPromise?this.loadPromise:(this.loadPromise=this.doLoad().finally(()=>{this.loadPromise=null}),this.loadPromise)}async doLoad(){var t,e;try{this.cachedSettings=await this.transport.get("/auth/settings")}catch(s){console.warn("[SaaS Support] Failed to load project settings:",s)}if((t=this.tokenManager)!=null&&t.hasRefreshToken())try{await this.tokenManager.refreshOnce()}catch{(e=this.tokenManager)==null||e.clearTokens()}this.loaded=!0}async signIn(t,e){const s=await this.transport.post("/auth/login",{email:t,password:e});if("mfaRequired"in s&&s.mfaRequired)return s;const r=s;return this.setSession(r),r}async signUp(t,e){const s=await this.transport.post("/auth/register",{email:t,password:e});return this.setSession(s),s}async signOut(){var e;const t=(e=this.tokenManager)==null?void 0:e.getRefreshToken();if(t)try{await this.transport.post("/auth/logout",{refreshToken:t})}catch{}this.clearSession()}async signInWithOAuth(t){const e=`${this.baseUrl}/auth/oauth/${t}/popup-callback`,{authUrl:s,state:r}=await this.transport.get(`/auth/oauth/${t}?redirect_uri=${encodeURIComponent(e)}`),i=window.screenX+(window.innerWidth-w)/2,n=window.screenY+(window.innerHeight-T)/2,a=window.open(s,"saas-support-oauth",`width=${w},height=${T},left=${i},top=${n},toolbar=no,menubar=no`);return new Promise((c,h)=>{let u=!1;const g=async l=>{var k;if(((k=l.data)==null?void 0:k.type)==="saas-support:oauth-callback"&&!u){if(u=!0,window.removeEventListener("message",g),clearTimeout(m),clearInterval(f),a==null||a.close(),l.data.error){h(new Error(`OAuth error: ${l.data.error}`));return}try{const p=await this.transport.post(`/auth/oauth/${t}/callback`,{code:l.data.code,state:l.data.state||r});this.setSession(p),c(p)}catch(p){h(p)}}};window.addEventListener("message",g);const m=setTimeout(()=>{u||(u=!0,window.removeEventListener("message",g),clearInterval(f),a==null||a.close(),h(new Error("OAuth popup timed out")))},v),f=setInterval(()=>{a!=null&&a.closed&&!u&&(u=!0,clearInterval(f),clearTimeout(m),window.removeEventListener("message",g),h(new Error("OAuth popup was closed")))},500)})}async submitMfaCode(t,e){const s=await this.transport.post("/auth/login/mfa",{mfaToken:t,code:e});return this.setSession(s),s}async sendMagicLink(t,e){await this.transport.post("/auth/magic-link/send",{email:t,redirectUrl:e})}async verifyMagicLink(t){const e=await this.transport.post("/auth/magic-link/verify",{token:t});return this.setSession(e),e}async sendPasswordReset(t,e){await this.transport.post("/auth/password-reset/send",{email:t,redirectUrl:e})}async resetPassword(t,e){await this.transport.post("/auth/password-reset/verify",{token:t,newPassword:e})}async setupMfa(){return this.transport.post("/auth/mfa/setup",void 0,this.authHeaders())}async verifyMfa(t){return this.transport.post("/auth/mfa/verify",{code:t},this.authHeaders())}async disableMfa(t){await this.transport.post("/auth/mfa/disable",{code:t},this.authHeaders())}async getToken(){var e,s,r;const t=((e=this.tokenManager)==null?void 0:e.getAccessToken())??null;if(t)return t;if((s=this.tokenManager)!=null&&s.hasRefreshToken())try{return await this.tokenManager.refreshOnce(),((r=this.tokenManager)==null?void 0:r.getAccessToken())??null}catch{return this.clearSession(),null}return null}async getUser(){if(this.cachedUser)return this.cachedUser;const t=await this.getToken();if(!t)return null;try{return this.cachedUser=await this.transport.get("/auth/me",{Authorization:`Bearer ${t}`}),this.cachedUser}catch{return null}}async refreshUser(){const t=await this.getToken();if(!t)return this.cachedUser;try{return this.cachedUser=await this.transport.get("/auth/me",{Authorization:`Bearer ${t}`}),this.emitter.emit("authStateChange",this.cachedUser),this.cachedUser}catch{return this.cachedUser}}getUserSync(){return this.cachedUser}isLoaded(){return this.loaded}async getSettings(){if(this.cachedSettings)return this.cachedSettings;try{return this.cachedSettings=await this.transport.get("/auth/settings"),this.cachedSettings}catch{return null}}onAuthStateChange(t){return this.emitter.on("authStateChange",t)}async updateProfile(t){const e=await this.transport.patch("/auth/me",t,this.authHeaders());return this.cachedUser=e,this.emitter.emit("authStateChange",e),e}async uploadAvatar(t){const e=await this.transport.uploadBinary("/auth/avatar",t,this.authHeaders());return this.cachedUser&&(this.cachedUser={...this.cachedUser,avatarUrl:e.avatarUrl},this.emitter.emit("authStateChange",this.cachedUser)),e}async changePassword(t,e){await this.transport.post("/auth/change-password",{currentPassword:t,newPassword:e},this.authHeaders())}async listOrgs(){return this.transport.get("/auth/orgs",this.authHeaders())}async createOrg(t,e){return this.transport.post("/auth/orgs",{name:t,slug:e},this.authHeaders())}async getOrg(t){return this.transport.get(`/auth/orgs/${t}`,this.authHeaders())}async updateOrg(t,e){return this.transport.patch(`/auth/orgs/${t}`,e,this.authHeaders())}async deleteOrg(t){await this.transport.del(`/auth/orgs/${t}`,this.authHeaders())}async listMembers(t){return this.transport.get(`/auth/orgs/${t}/members`,this.authHeaders())}async sendInvite(t,e,s){return this.transport.post(`/auth/orgs/${t}/invites`,{email:e,role:s},this.authHeaders())}async updateMemberRole(t,e,s){await this.transport.patch(`/auth/orgs/${t}/members/${e}`,{role:s},this.authHeaders())}async removeMember(t,e){await this.transport.del(`/auth/orgs/${t}/members/${e}`,this.authHeaders())}async acceptInvite(t){return this.transport.post(`/auth/invites/${t}/accept`,void 0,this.authHeaders())}async listInvites(t){return this.transport.get(`/auth/orgs/${t}/invites`,this.authHeaders())}async revokeInvite(t,e){await this.transport.del(`/auth/orgs/${t}/invites/${e}`,this.authHeaders())}async deleteAccount(){await this.transport.del("/auth/account",this.authHeaders()),this.clearSession()}handleExternalLogout(){this.cachedUser=null,this.emitter.emit("authStateChange",null)}async performRefresh(){var s;const t=(s=this.tokenManager)==null?void 0:s.getRefreshToken();if(!t)throw new Error("No refresh token");const e=await this.transport.post("/auth/refresh",{refreshToken:t});if(this.tokenManager.setTokens(e.accessToken,e.refreshToken),!this.cachedUser)try{this.cachedUser=await this.transport.get("/auth/me",{Authorization:`Bearer ${e.accessToken}`}),this.emitter.emit("authStateChange",this.cachedUser)}catch{}}setSession(t){var e;(e=this.tokenManager)==null||e.setTokens(t.accessToken,t.refreshToken),this.cachedUser=t.user,this.emitter.emit("authStateChange",t.user),this.refreshUser()}clearSession(){var t;(t=this.tokenManager)==null||t.clearTokens(),this.cachedUser=null,this.emitter.emit("authStateChange",null)}authHeaders(){var e;const t=(e=this.tokenManager)==null?void 0:e.getAccessToken();return t?{Authorization:`Bearer ${t}`}:{}}}class S{constructor(t){this.transport=t}async createCustomer(t){return this.transport.post("/billing/customers",t)}async getCustomer(t){return this.transport.get(`/billing/customers/${t}`)}async updateCustomer(t,e){return this.transport.patch(`/billing/customers/${t}`,e)}async subscribe(t,e){return this.transport.post(`/billing/customers/${t}/subscribe`,{planId:e})}async changePlan(t,e){return this.transport.patch(`/billing/customers/${t}/subscription`,{planId:e})}async cancelSubscription(t){return this.transport.del(`/billing/customers/${t}/subscription`)}async getInvoices(t){return this.transport.get(`/billing/customers/${t}/invoices`)}async ingestUsageEvent(t){return this.transport.post("/billing/events",t)}async getCurrentUsage(t){return this.transport.get(`/billing/customers/${t}/usage`)}async createPortalToken(t,e){return this.transport.post("/billing/portal-tokens",{customerId:t,expiresIn:e})}async applyCoupon(t,e){return this.transport.post(`/billing/customers/${t}/coupon`,{code:e})}}class U{constructor(t){this.transport=t}async executeQuery(t){return this.transport.post("/report/query",t)}async listQueries(t){const e=t?this.toQueryString(t):"";return this.transport.get(`/report/queries${e}`)}async saveQuery(t){return this.transport.post("/report/queries",t)}async updateQuery(t,e){return this.transport.patch(`/report/queries/${t}`,e)}async deleteQuery(t){await this.transport.del(`/report/queries/${t}`)}async listDashboards(t){const e=t?this.toQueryString(t):"";return this.transport.get(`/report/dashboards${e}`)}async createDashboard(t){return this.transport.post("/report/dashboards",t)}async getDashboard(t){return this.transport.get(`/report/dashboards/${t}`)}async updateDashboard(t,e){return this.transport.patch(`/report/dashboards/${t}`,e)}async deleteDashboard(t){await this.transport.del(`/report/dashboards/${t}`)}async createEmbedToken(t){return this.transport.post("/report/embed-tokens",t)}async listEmbedTokens(){return this.transport.get("/report/embed-tokens")}async revokeEmbedToken(t){await this.transport.del(`/report/embed-tokens/${t}`)}toQueryString(t){const e=Object.entries(t).filter(([,s])=>s!=null&&s!=="");return e.length===0?"":"?"+e.map(([s,r])=>`${s}=${encodeURIComponent(String(r))}`).join("&")}}const M="https://api.saas-support.com/v1";class H{constructor(t){if(this.tokenManager=null,this.loaded=!1,this.loadPromise=null,!t.publishableKey&&!t.apiKey)throw new Error("SaaSSupport: either publishableKey or apiKey is required");const e=t.baseUrl??M;this.emitter=new R;const s=t.publishableKey?new y(e,{type:"publishableKey",key:t.publishableKey}):null,r=t.apiKey?new y(e,{type:"apiKey",key:t.apiKey}):null;t.publishableKey&&(this.tokenManager=new $(t.publishableKey)),this.auth=new b(s??r,this.tokenManager,this.emitter,e),this.billing=new S(r??s),this.report=new U(r??s),this.tokenManager&&(this.tokenManager.setRefreshCallback(()=>this.auth.performRefresh()),this.tokenManager.setTokensChangedCallback(()=>{this.tokenManager.hasRefreshToken()||this.auth.handleExternalLogout()})),this.tokenManager&&s&&s.setUnauthorizedHandler(async()=>{try{return await this.tokenManager.refreshOnce(),this.tokenManager.getAccessToken()}catch{return null}})}async load(){if(!this.loaded)return this.loadPromise?this.loadPromise:(this.loadPromise=this.auth.load().then(()=>{this.loaded=!0}).finally(()=>{this.loadPromise=null}),this.loadPromise)}isLoaded(){return this.loaded}onError(t){return this.emitter.on("error",t)}destroy(){var t;(t=this.tokenManager)==null||t.destroy(),this.emitter.removeAll()}}function C(o){return"mfaRequired"in o&&o.mfaRequired===!0}exports.AuthClient=b;exports.BillingClient=S;exports.ReportClient=U;exports.SaaSError=d;exports.SaaSSupport=H;exports.Transport=y;exports.isMfaRequired=C;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class d extends Error{constructor(e,t,s="unknown"){super(t),this.name="SaaSError",this.code=e,this.domain=s}get isNotFound(){return this.code===404}get isUnauthorized(){return this.code===401}get isForbidden(){return this.code===403}get isConflict(){return this.code===409}get isRateLimited(){return this.code===429}}class y{constructor(e,t){this.onUnauthorized=null,this.baseUrl=e,this.authMode=t}setUnauthorizedHandler(e){this.onUnauthorized=e}async request(e,t,s,r){try{return await this.doRequest(e,t,s,r)}catch(i){if(i instanceof d&&i.isUnauthorized&&this.onUnauthorized&&(r!=null&&r.Authorization)){const n=await this.onUnauthorized();if(n)return this.doRequest(e,t,s,{...r,Authorization:`Bearer ${n}`})}throw i}}async get(e,t){return this.request("GET",e,void 0,t)}async post(e,t,s){return this.request("POST",e,t,s)}async patch(e,t,s){return this.request("PATCH",e,t,s)}async del(e,t){return this.request("DELETE",e,void 0,t)}async uploadBinary(e,t,s){try{return await this.doUploadBinary(e,t,s)}catch(r){if(r instanceof d&&r.isUnauthorized&&this.onUnauthorized&&(s!=null&&s.Authorization)){const i=await this.onUnauthorized();if(i)return this.doUploadBinary(e,t,{...s,Authorization:`Bearer ${i}`})}throw r}}async doUploadBinary(e,t,s){const r={"Content-Type":"application/octet-stream",...this.getAuthHeaders(),...s},i=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:r,body:t}),n=await i.json();if(!i.ok||n.isOk===!1||n.code&&n.code>=400){const a=this.inferDomain(e),c=n.code||i.status;throw new d(c,n.message||"Upload failed",a)}return n.data}async doRequest(e,t,s,r){const i={"Content-Type":"application/json",...this.getAuthHeaders(),...r},n=await fetch(`${this.baseUrl}${t}`,{method:e,headers:i,body:s?JSON.stringify(s):void 0}),a=await n.json();if(!n.ok||a.isOk===!1||a.code&&a.code>=400){const c=this.inferDomain(t),o=a.code||n.status;throw new d(o,a.message||"Request failed",c)}return a.data}getAuthHeaders(){switch(this.authMode.type){case"publishableKey":case"apiKey":return{"X-API-Key":this.authMode.key};case"portalToken":case"embedToken":return{Authorization:`Bearer ${this.authMode.token}`}}}inferDomain(e){return e.startsWith("/auth")?"auth":e.startsWith("/billing")?"billing":e.startsWith("/report")?"report":"unknown"}}class U{constructor(e){this.accessToken=null,this.refreshToken=null,this.refreshTimer=null,this.refreshInFlight=null,this.onRefreshNeeded=null,this.onTokensChanged=null,this.boundHandleStorage=null,this.storageKey=`ss_rt_${e.slice(0,12)}`,this.refreshToken=this.loadRefreshToken(),typeof window<"u"&&(this.boundHandleStorage=this.handleStorageEvent.bind(this),window.addEventListener("storage",this.boundHandleStorage))}setRefreshCallback(e){this.onRefreshNeeded=e}setTokensChangedCallback(e){this.onTokensChanged=e}getAccessToken(){return this.accessToken}getRefreshToken(){return this.refreshToken}hasRefreshToken(){return this.refreshToken!==null}setTokens(e,t){this.accessToken=e,this.refreshToken=t,this.saveRefreshToken(t),this.scheduleRefresh(e)}clearTokens(){this.accessToken=null,this.refreshToken=null,this.removeRefreshToken(),this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null)}async refreshOnce(){return this.refreshInFlight?this.refreshInFlight:(this.refreshInFlight=this.executeRefresh().finally(()=>{this.refreshInFlight=null}),this.refreshInFlight)}destroy(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),typeof window<"u"&&this.boundHandleStorage&&(window.removeEventListener("storage",this.boundHandleStorage),this.boundHandleStorage=null)}async executeRefresh(){if(!this.onRefreshNeeded)throw new Error("No refresh callback configured");typeof navigator<"u"&&"locks"in navigator?await navigator.locks.request(`ss_refresh_lock_${this.storageKey}`,async()=>{const e=this.loadRefreshToken();e&&e!==this.refreshToken&&(this.refreshToken=e),await this.onRefreshNeeded()}):await this.onRefreshNeeded()}scheduleRefresh(e){this.refreshTimer&&clearTimeout(this.refreshTimer);const t=this.getTokenExpiry(e);if(!t)return;const s=t*1e3-Date.now()-6e4;if(s<=0){this.refreshOnce().catch(()=>{});return}this.refreshTimer=setTimeout(()=>{this.refreshOnce().catch(()=>{})},s)}handleStorageEvent(e){var t;if(e.key===this.storageKey){if(e.newValue===null){this.accessToken=null,this.refreshToken=null,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),(t=this.onTokensChanged)==null||t.call(this);return}e.newValue!==this.refreshToken&&(this.refreshToken=e.newValue,this.accessToken=null,this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=null))}}getTokenExpiry(e){try{const t=e.split(".")[1];return JSON.parse(atob(t)).exp??null}catch{return null}}loadRefreshToken(){try{return localStorage.getItem(this.storageKey)}catch{return null}}saveRefreshToken(e){try{localStorage.setItem(this.storageKey,e)}catch{}}removeRefreshToken(){try{localStorage.removeItem(this.storageKey)}catch{}}}class b{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{var s;(s=this.listeners.get(e))==null||s.delete(t)}}emit(e,t){var s;(s=this.listeners.get(e))==null||s.forEach(r=>r(t))}removeAll(){this.listeners.clear()}}const w=500,T=600,v=5*60*1e3;class S{constructor(e,t,s,r){this.cachedUser=null,this.cachedSettings=null,this.loaded=!1,this.loadPromise=null,this.transport=e,this.tokenManager=t,this.emitter=s,this.baseUrl=r}async load(){if(!this.loaded)return this.loadPromise?this.loadPromise:(this.loadPromise=this.doLoad().finally(()=>{this.loadPromise=null}),this.loadPromise)}async doLoad(){var e,t;try{this.cachedSettings=await this.transport.get("/auth/settings")}catch(s){console.warn("[SaaS Support] Failed to load project settings:",s)}if((e=this.tokenManager)!=null&&e.hasRefreshToken())try{await this.tokenManager.refreshOnce()}catch{(t=this.tokenManager)==null||t.clearTokens()}this.loaded=!0}async signIn(e,t){const s=await this.transport.post("/auth/login",{email:e,password:t});if("mfaRequired"in s&&s.mfaRequired)return s;const r=s;return this.setSession(r),r}async signUp(e,t){const s=await this.transport.post("/auth/register",{email:e,password:t});return this.setSession(s),s}async signOut(){var t;const e=(t=this.tokenManager)==null?void 0:t.getRefreshToken();if(e)try{await this.transport.post("/auth/logout",{refreshToken:e})}catch{}this.clearSession()}async signInWithOAuth(e){const t=`${this.baseUrl}/auth/oauth/${e}/popup-callback`,{authUrl:s,state:r}=await this.transport.get(`/auth/oauth/${e}?redirect_uri=${encodeURIComponent(t)}`),i=window.screenX+(window.innerWidth-w)/2,n=window.screenY+(window.innerHeight-T)/2,a=window.open(s,"saas-support-oauth",`width=${w},height=${T},left=${i},top=${n},toolbar=no,menubar=no`);return new Promise((c,o)=>{let u=!1;const f=async l=>{var k;if(((k=l.data)==null?void 0:k.type)==="saas-support:oauth-callback"&&!u){if(u=!0,window.removeEventListener("message",f),clearTimeout(m),clearInterval(p),a==null||a.close(),l.data.error){o(new Error(`OAuth error: ${l.data.error}`));return}try{const g=await this.transport.post(`/auth/oauth/${e}/callback`,{code:l.data.code,state:l.data.state||r});this.setSession(g),c(g)}catch(g){o(g)}}};window.addEventListener("message",f);const m=setTimeout(()=>{u||(u=!0,window.removeEventListener("message",f),clearInterval(p),a==null||a.close(),o(new Error("OAuth popup timed out")))},v),p=setInterval(()=>{a!=null&&a.closed&&!u&&(u=!0,clearInterval(p),clearTimeout(m),window.removeEventListener("message",f),o(new Error("OAuth popup was closed")))},500)})}async submitMfaCode(e,t){const s=await this.transport.post("/auth/login/mfa",{mfaToken:e,code:t});return this.setSession(s),s}async sendMagicLink(e,t){await this.transport.post("/auth/magic-link/send",{email:e,redirectUrl:t})}async verifyMagicLink(e){const t=await this.transport.post("/auth/magic-link/verify",{token:e});return this.setSession(t),t}async sendPasswordReset(e,t){await this.transport.post("/auth/password-reset/send",{email:e,redirectUrl:t})}async resetPassword(e,t){await this.transport.post("/auth/password-reset/verify",{token:e,newPassword:t})}async setupMfa(){return this.transport.post("/auth/mfa/setup",void 0,this.authHeaders())}async verifyMfa(e){return this.transport.post("/auth/mfa/verify",{code:e},this.authHeaders())}async disableMfa(e){await this.transport.post("/auth/mfa/disable",{code:e},this.authHeaders())}async getToken(){var t,s,r;const e=((t=this.tokenManager)==null?void 0:t.getAccessToken())??null;if(e)return e;if((s=this.tokenManager)!=null&&s.hasRefreshToken())try{return await this.tokenManager.refreshOnce(),((r=this.tokenManager)==null?void 0:r.getAccessToken())??null}catch{return this.clearSession(),null}return null}async getUser(){if(this.cachedUser)return this.cachedUser;const e=await this.getToken();if(!e)return null;try{return this.cachedUser=await this.transport.get("/auth/me",{Authorization:`Bearer ${e}`}),this.cachedUser}catch{return null}}async refreshUser(){const e=await this.getToken();if(!e)return this.cachedUser;try{return this.cachedUser=await this.transport.get("/auth/me",{Authorization:`Bearer ${e}`}),this.emitter.emit("authStateChange",this.cachedUser),this.cachedUser}catch{return this.cachedUser}}getUserSync(){return this.cachedUser}isLoaded(){return this.loaded}async getSettings(){if(this.cachedSettings)return this.cachedSettings;try{return this.cachedSettings=await this.transport.get("/auth/settings"),this.cachedSettings}catch{return null}}onAuthStateChange(e){return this.emitter.on("authStateChange",e)}async updateProfile(e){const t=await this.transport.patch("/auth/me",e,this.authHeaders());return this.cachedUser=t,this.emitter.emit("authStateChange",t),t}async uploadAvatar(e){const t=await this.transport.uploadBinary("/auth/avatar",e,this.authHeaders());return this.cachedUser&&(this.cachedUser={...this.cachedUser,avatarUrl:t.avatarUrl},this.emitter.emit("authStateChange",this.cachedUser)),t}async changePassword(e,t){await this.transport.post("/auth/change-password",{currentPassword:e,newPassword:t},this.authHeaders())}async listOrgs(){return this.transport.get("/auth/orgs",this.authHeaders())}async createOrg(e,t){return this.transport.post("/auth/orgs",{name:e,slug:t},this.authHeaders())}async getOrg(e){return this.transport.get(`/auth/orgs/${e}`,this.authHeaders())}async updateOrg(e,t){return this.transport.patch(`/auth/orgs/${e}`,t,this.authHeaders())}async deleteOrg(e){await this.transport.del(`/auth/orgs/${e}`,this.authHeaders())}async uploadOrgAvatar(e,t){return this.transport.uploadBinary(`/auth/orgs/${e}/avatar`,t,this.authHeaders())}async listMembers(e){return this.transport.get(`/auth/orgs/${e}/members`,this.authHeaders())}async sendInvite(e,t,s){return this.transport.post(`/auth/orgs/${e}/invites`,{email:t,role:s},this.authHeaders())}async updateMemberRole(e,t,s){await this.transport.patch(`/auth/orgs/${e}/members/${t}`,{role:s},this.authHeaders())}async removeMember(e,t){await this.transport.del(`/auth/orgs/${e}/members/${t}`,this.authHeaders())}async acceptInvite(e){return this.transport.post(`/auth/invites/${e}/accept`,void 0,this.authHeaders())}async listInvites(e){return this.transport.get(`/auth/orgs/${e}/invites`,this.authHeaders())}async revokeInvite(e,t){await this.transport.del(`/auth/orgs/${e}/invites/${t}`,this.authHeaders())}async listMyInvites(){return this.transport.get("/auth/invites/pending",this.authHeaders())}async acceptInviteById(e){return this.transport.post(`/auth/invites/${e}/accept-by-id`,void 0,this.authHeaders())}async declineInvite(e){await this.transport.del(`/auth/invites/${e}/decline`,this.authHeaders())}async deleteAccount(){await this.transport.del("/auth/account",this.authHeaders()),this.clearSession()}handleExternalLogout(){this.cachedUser=null,this.emitter.emit("authStateChange",null)}async performRefresh(){var s;const e=(s=this.tokenManager)==null?void 0:s.getRefreshToken();if(!e)throw new Error("No refresh token");const t=await this.transport.post("/auth/refresh",{refreshToken:e});if(this.tokenManager.setTokens(t.accessToken,t.refreshToken),!this.cachedUser)try{this.cachedUser=await this.transport.get("/auth/me",{Authorization:`Bearer ${t.accessToken}`}),this.emitter.emit("authStateChange",this.cachedUser)}catch{}}setSession(e){var t;(t=this.tokenManager)==null||t.setTokens(e.accessToken,e.refreshToken),this.cachedUser=e.user,this.emitter.emit("authStateChange",e.user),this.refreshUser()}clearSession(){var e;(e=this.tokenManager)==null||e.clearTokens(),this.cachedUser=null,this.emitter.emit("authStateChange",null)}authHeaders(){var t;const e=(t=this.tokenManager)==null?void 0:t.getAccessToken();return e?{Authorization:`Bearer ${e}`}:{}}}const M="https://api.saas-support.com/v1";class H{constructor(e){if(this.tokenManager=null,this.loaded=!1,this.loadPromise=null,!e.publishableKey&&!e.apiKey)throw new Error("SaaSSupport: either publishableKey or apiKey is required");const t=e.baseUrl??M;this.emitter=new b;const s=e.publishableKey?new y(t,{type:"publishableKey",key:e.publishableKey}):null,r=e.apiKey?new y(t,{type:"apiKey",key:e.apiKey}):null;e.publishableKey&&(this.tokenManager=new U(e.publishableKey)),this.auth=new S(s??r,this.tokenManager,this.emitter,t),this.tokenManager&&(this.tokenManager.setRefreshCallback(()=>this.auth.performRefresh()),this.tokenManager.setTokensChangedCallback(()=>{this.tokenManager.hasRefreshToken()||this.auth.handleExternalLogout()})),this.tokenManager&&s&&s.setUnauthorizedHandler(async()=>{try{return await this.tokenManager.refreshOnce(),this.tokenManager.getAccessToken()}catch{return null}})}async load(){if(!this.loaded)return this.loadPromise?this.loadPromise:(this.loadPromise=this.auth.load().then(()=>{this.loaded=!0}).finally(()=>{this.loadPromise=null}),this.loadPromise)}isLoaded(){return this.loaded}onError(e){return this.emitter.on("error",e)}destroy(){var e;(e=this.tokenManager)==null||e.destroy(),this.emitter.removeAll()}}function R(h){return"mfaRequired"in h&&h.mfaRequired===!0}exports.AuthClient=S;exports.SaaSError=d;exports.SaaSSupport=H;exports.Transport=y;exports.isMfaRequired=R;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,13 +6,6 @@ export declare interface Appearance {
|
|
|
6
6
|
fontUrl?: string | null;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export declare interface ApplyCouponResult {
|
|
10
|
-
applied: boolean;
|
|
11
|
-
discountType: string;
|
|
12
|
-
amount: number;
|
|
13
|
-
duration: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
export declare class AuthClient {
|
|
17
10
|
private transport;
|
|
18
11
|
private tokenManager;
|
|
@@ -64,6 +57,12 @@ export declare class AuthClient {
|
|
|
64
57
|
avatarUrl?: string;
|
|
65
58
|
}): Promise<Org>;
|
|
66
59
|
deleteOrg(orgId: string): Promise<void>;
|
|
60
|
+
uploadOrgAvatar(orgId: string, imageBlob: Blob): Promise<{
|
|
61
|
+
avatarUrl: string;
|
|
62
|
+
small: string;
|
|
63
|
+
medium: string;
|
|
64
|
+
original: string;
|
|
65
|
+
}>;
|
|
67
66
|
listMembers(orgId: string): Promise<Member[]>;
|
|
68
67
|
sendInvite(orgId: string, email: string, role: string): Promise<Invite>;
|
|
69
68
|
updateMemberRole(orgId: string, userId: string, role: string): Promise<void>;
|
|
@@ -74,6 +73,12 @@ export declare class AuthClient {
|
|
|
74
73
|
}>;
|
|
75
74
|
listInvites(orgId: string): Promise<PendingInvite[]>;
|
|
76
75
|
revokeInvite(orgId: string, inviteId: string): Promise<void>;
|
|
76
|
+
listMyInvites(): Promise<MyPendingInvite[]>;
|
|
77
|
+
acceptInviteById(inviteId: string): Promise<{
|
|
78
|
+
orgId: string;
|
|
79
|
+
role: string;
|
|
80
|
+
}>;
|
|
81
|
+
declineInvite(inviteId: string): Promise<void>;
|
|
77
82
|
deleteAccount(): Promise<void>;
|
|
78
83
|
/* Excluded from this release type: handleExternalLogout */
|
|
79
84
|
/* Excluded from this release type: performRefresh */
|
|
@@ -100,66 +105,6 @@ export declare type AuthResult = SignInResult | MfaRequiredResult;
|
|
|
100
105
|
|
|
101
106
|
export declare type AuthStateCallback = (user: User | null) => void;
|
|
102
107
|
|
|
103
|
-
export declare class BillingClient {
|
|
104
|
-
private transport;
|
|
105
|
-
constructor(transport: Transport);
|
|
106
|
-
createCustomer(params: {
|
|
107
|
-
email: string;
|
|
108
|
-
name?: string;
|
|
109
|
-
metadata?: string;
|
|
110
|
-
}): Promise<Customer>;
|
|
111
|
-
getCustomer(customerId: string): Promise<Customer>;
|
|
112
|
-
updateCustomer(customerId: string, params: {
|
|
113
|
-
email?: string;
|
|
114
|
-
name?: string;
|
|
115
|
-
metadata?: string;
|
|
116
|
-
}): Promise<Customer>;
|
|
117
|
-
subscribe(customerId: string, planId: string): Promise<Subscription>;
|
|
118
|
-
changePlan(customerId: string, planId: string): Promise<Subscription>;
|
|
119
|
-
cancelSubscription(customerId: string): Promise<{
|
|
120
|
-
canceledAtPeriodEnd: boolean;
|
|
121
|
-
}>;
|
|
122
|
-
getInvoices(customerId: string): Promise<Invoice[]>;
|
|
123
|
-
ingestUsageEvent(params: {
|
|
124
|
-
customerId: string;
|
|
125
|
-
metric: string;
|
|
126
|
-
quantity: number;
|
|
127
|
-
timestamp?: string;
|
|
128
|
-
idempotencyKey?: string;
|
|
129
|
-
}): Promise<{
|
|
130
|
-
id: string;
|
|
131
|
-
ingested: boolean;
|
|
132
|
-
}>;
|
|
133
|
-
getCurrentUsage(customerId: string): Promise<UsageSummary[]>;
|
|
134
|
-
createPortalToken(customerId: string, expiresIn?: number): Promise<PortalTokenResult>;
|
|
135
|
-
applyCoupon(customerId: string, code: string): Promise<ApplyCouponResult>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export declare interface Customer {
|
|
139
|
-
id: string;
|
|
140
|
-
projectId: string;
|
|
141
|
-
email: string;
|
|
142
|
-
name?: string;
|
|
143
|
-
stripeCustomerId?: string;
|
|
144
|
-
balanceCents: number;
|
|
145
|
-
metadata?: string;
|
|
146
|
-
taxExempt: boolean;
|
|
147
|
-
taxId?: string;
|
|
148
|
-
createdAt: string;
|
|
149
|
-
updatedAt: string;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export declare interface Dashboard {
|
|
153
|
-
id: string;
|
|
154
|
-
projectId: string;
|
|
155
|
-
name: string;
|
|
156
|
-
layoutJson: string;
|
|
157
|
-
isPublic: boolean;
|
|
158
|
-
refreshIntervalSeconds: number;
|
|
159
|
-
createdAt: string;
|
|
160
|
-
updatedAt: string;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
108
|
export declare interface ElementOverrides {
|
|
164
109
|
card?: React.CSSProperties;
|
|
165
110
|
headerTitle?: React.CSSProperties;
|
|
@@ -186,22 +131,6 @@ export declare interface ElementOverrides {
|
|
|
186
131
|
profileHeader?: React.CSSProperties;
|
|
187
132
|
}
|
|
188
133
|
|
|
189
|
-
export declare interface EmbedToken {
|
|
190
|
-
id: string;
|
|
191
|
-
projectId: string;
|
|
192
|
-
dashboardId?: string;
|
|
193
|
-
customerId?: string;
|
|
194
|
-
filterRules?: FilterRule[];
|
|
195
|
-
expiresAt: string;
|
|
196
|
-
createdAt: string;
|
|
197
|
-
revokedAt?: string;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export declare interface EmbedTokenResult {
|
|
201
|
-
embedToken: string;
|
|
202
|
-
expiresAt: string;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
134
|
declare class EventEmitter<Events extends Record<string, any>> {
|
|
206
135
|
private listeners;
|
|
207
136
|
on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): () => void;
|
|
@@ -209,13 +138,6 @@ declare class EventEmitter<Events extends Record<string, any>> {
|
|
|
209
138
|
removeAll(): void;
|
|
210
139
|
}
|
|
211
140
|
|
|
212
|
-
export declare interface FilterRule {
|
|
213
|
-
table?: string;
|
|
214
|
-
column: string;
|
|
215
|
-
op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'between';
|
|
216
|
-
value: string;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
141
|
export declare interface Invite {
|
|
220
142
|
inviteId: string;
|
|
221
143
|
email: string;
|
|
@@ -224,32 +146,10 @@ export declare interface Invite {
|
|
|
224
146
|
expiresAt: string;
|
|
225
147
|
}
|
|
226
148
|
|
|
227
|
-
export declare interface Invoice {
|
|
228
|
-
id: string;
|
|
229
|
-
projectId: string;
|
|
230
|
-
customerId: string;
|
|
231
|
-
subscriptionId?: string;
|
|
232
|
-
amountCents: number;
|
|
233
|
-
status: 'draft' | 'open' | 'paid' | 'void' | 'uncollectible';
|
|
234
|
-
stripeInvoiceId?: string;
|
|
235
|
-
pdfUrl?: string;
|
|
236
|
-
dueDate?: string;
|
|
237
|
-
paidAt?: string;
|
|
238
|
-
createdAt: string;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
149
|
export declare function isMfaRequired(result: AuthResult): result is MfaRequiredResult;
|
|
242
150
|
|
|
243
151
|
declare type Listener<T> = (data: T) => void;
|
|
244
152
|
|
|
245
|
-
export declare interface ListParams {
|
|
246
|
-
page?: number;
|
|
247
|
-
perPage?: number;
|
|
248
|
-
sort?: string;
|
|
249
|
-
order?: string;
|
|
250
|
-
search?: string;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
153
|
export declare interface Member {
|
|
254
154
|
userId: string;
|
|
255
155
|
email: string;
|
|
@@ -270,18 +170,17 @@ export declare interface MfaVerifyResult {
|
|
|
270
170
|
backupCodes: string[];
|
|
271
171
|
}
|
|
272
172
|
|
|
273
|
-
export declare
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
total: number;
|
|
281
|
-
totalPages: number;
|
|
282
|
-
};
|
|
173
|
+
export declare interface MyPendingInvite {
|
|
174
|
+
id: string;
|
|
175
|
+
orgId: string;
|
|
176
|
+
orgName: string;
|
|
177
|
+
role: string;
|
|
178
|
+
expiresAt: string;
|
|
179
|
+
createdAt: string;
|
|
283
180
|
}
|
|
284
181
|
|
|
182
|
+
export declare type OAuthProvider = 'google' | 'github';
|
|
183
|
+
|
|
285
184
|
export declare interface Org {
|
|
286
185
|
id: string;
|
|
287
186
|
projectId: string;
|
|
@@ -300,24 +199,6 @@ export declare interface PendingInvite {
|
|
|
300
199
|
createdAt: string;
|
|
301
200
|
}
|
|
302
201
|
|
|
303
|
-
export declare interface Plan {
|
|
304
|
-
id: string;
|
|
305
|
-
name: string;
|
|
306
|
-
description?: string;
|
|
307
|
-
amountCents: number;
|
|
308
|
-
interval: 'month' | 'year';
|
|
309
|
-
currency: string;
|
|
310
|
-
trialDays: number;
|
|
311
|
-
isFree: boolean;
|
|
312
|
-
features: string[];
|
|
313
|
-
isActive: boolean;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export declare interface PortalTokenResult {
|
|
317
|
-
portalToken: string;
|
|
318
|
-
expiresAt: string;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
202
|
export declare interface ProjectSettings {
|
|
322
203
|
googleEnabled: boolean;
|
|
323
204
|
githubEnabled: boolean;
|
|
@@ -325,64 +206,8 @@ export declare interface ProjectSettings {
|
|
|
325
206
|
mfaEnforced: boolean;
|
|
326
207
|
passwordMinLength: number;
|
|
327
208
|
emailVerification: boolean;
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
export declare interface QueryParams {
|
|
331
|
-
naturalLanguage?: string;
|
|
332
|
-
sql?: string;
|
|
333
|
-
filterRules?: FilterRule[];
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export declare interface QueryResult {
|
|
337
|
-
sql: string;
|
|
338
|
-
columns: string[];
|
|
339
|
-
rows: Record<string, unknown>[];
|
|
340
|
-
rowCount: number;
|
|
341
|
-
executionMs: number;
|
|
342
|
-
chartType: string;
|
|
343
|
-
cached: boolean;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export declare class ReportClient {
|
|
347
|
-
private transport;
|
|
348
|
-
constructor(transport: Transport);
|
|
349
|
-
executeQuery(params: QueryParams): Promise<QueryResult>;
|
|
350
|
-
listQueries(params?: ListParams): Promise<OffsetPage<SavedQuery>>;
|
|
351
|
-
saveQuery(params: {
|
|
352
|
-
name: string;
|
|
353
|
-
naturalLanguage?: string;
|
|
354
|
-
generatedSql?: string;
|
|
355
|
-
chartType?: string;
|
|
356
|
-
}): Promise<SavedQuery>;
|
|
357
|
-
updateQuery(queryId: string, params: {
|
|
358
|
-
name?: string;
|
|
359
|
-
chartType?: string;
|
|
360
|
-
}): Promise<SavedQuery>;
|
|
361
|
-
deleteQuery(queryId: string): Promise<void>;
|
|
362
|
-
listDashboards(params?: ListParams): Promise<OffsetPage<Dashboard>>;
|
|
363
|
-
createDashboard(params: {
|
|
364
|
-
name: string;
|
|
365
|
-
layoutJson?: string;
|
|
366
|
-
isPublic?: boolean;
|
|
367
|
-
refreshIntervalSeconds?: number;
|
|
368
|
-
}): Promise<Dashboard>;
|
|
369
|
-
getDashboard(dashboardId: string): Promise<Dashboard>;
|
|
370
|
-
updateDashboard(dashboardId: string, params: {
|
|
371
|
-
name?: string;
|
|
372
|
-
layoutJson?: string;
|
|
373
|
-
isPublic?: boolean;
|
|
374
|
-
refreshIntervalSeconds?: number;
|
|
375
|
-
}): Promise<Dashboard>;
|
|
376
|
-
deleteDashboard(dashboardId: string): Promise<void>;
|
|
377
|
-
createEmbedToken(params: {
|
|
378
|
-
dashboardId?: string;
|
|
379
|
-
customerId?: string;
|
|
380
|
-
expiresIn?: number;
|
|
381
|
-
filterRules?: FilterRule[];
|
|
382
|
-
}): Promise<EmbedTokenResult>;
|
|
383
|
-
listEmbedTokens(): Promise<EmbedToken[]>;
|
|
384
|
-
revokeEmbedToken(tokenId: string): Promise<void>;
|
|
385
|
-
private toQueryString;
|
|
209
|
+
privacyPolicyUrl?: string;
|
|
210
|
+
termsOfServiceUrl?: string;
|
|
386
211
|
}
|
|
387
212
|
|
|
388
213
|
export declare class SaaSError extends Error {
|
|
@@ -412,8 +237,6 @@ export declare interface SaaSOptions {
|
|
|
412
237
|
|
|
413
238
|
export declare class SaaSSupport {
|
|
414
239
|
readonly auth: AuthClient;
|
|
415
|
-
readonly billing: BillingClient;
|
|
416
|
-
readonly report: ReportClient;
|
|
417
240
|
private tokenManager;
|
|
418
241
|
private emitter;
|
|
419
242
|
private loaded;
|
|
@@ -425,17 +248,6 @@ export declare class SaaSSupport {
|
|
|
425
248
|
destroy(): void;
|
|
426
249
|
}
|
|
427
250
|
|
|
428
|
-
export declare interface SavedQuery {
|
|
429
|
-
id: string;
|
|
430
|
-
projectId: string;
|
|
431
|
-
name: string;
|
|
432
|
-
naturalLanguage?: string;
|
|
433
|
-
generatedSql?: string;
|
|
434
|
-
chartType: string;
|
|
435
|
-
createdAt: string;
|
|
436
|
-
updatedAt: string;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
251
|
export declare interface SignInResult {
|
|
440
252
|
user: User;
|
|
441
253
|
accessToken: string;
|
|
@@ -448,21 +260,6 @@ export declare interface SignUpResult {
|
|
|
448
260
|
refreshToken: string;
|
|
449
261
|
}
|
|
450
262
|
|
|
451
|
-
export declare interface Subscription {
|
|
452
|
-
id: string;
|
|
453
|
-
customerId: string;
|
|
454
|
-
planId: string;
|
|
455
|
-
projectId: string;
|
|
456
|
-
status: 'trialing' | 'active' | 'past_due' | 'paused' | 'canceled';
|
|
457
|
-
stripeSubscriptionId?: string;
|
|
458
|
-
cancelAtPeriodEnd: boolean;
|
|
459
|
-
trialEnd?: string;
|
|
460
|
-
currentPeriodStart: string;
|
|
461
|
-
currentPeriodEnd: string;
|
|
462
|
-
canceledAt?: string;
|
|
463
|
-
createdAt: string;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
263
|
export declare interface ThemeVariables {
|
|
467
264
|
colorPrimary?: string;
|
|
468
265
|
colorBackground?: string;
|
|
@@ -533,11 +330,6 @@ export declare class Transport {
|
|
|
533
330
|
private inferDomain;
|
|
534
331
|
}
|
|
535
332
|
|
|
536
|
-
export declare interface UsageSummary {
|
|
537
|
-
metric: string;
|
|
538
|
-
total: number;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
333
|
export declare interface User {
|
|
542
334
|
id: string;
|
|
543
335
|
email: string;
|