@based/client
Advanced tools
Comparing version 2.7.3 to 2.7.4
@@ -9,2 +9,7 @@ import { Connection } from './websocket/types'; | ||
token: string; | ||
renewOptions: { | ||
refreshToken?: string; | ||
} & { | ||
[key: string]: any; | ||
}; | ||
sendTokenOptions: SendTokenOptions; | ||
@@ -11,0 +16,0 @@ retryingRenewToken: boolean; |
@@ -101,6 +101,3 @@ "use strict"; | ||
this.retryingRenewToken = true; | ||
const refreshToken = this.sendTokenOptions?.refreshToken; | ||
(0, auth_1.renewToken)(this, { | ||
refreshToken, | ||
}) | ||
(0, auth_1.renewToken)(this, this.renewOptions) | ||
.then((result) => { | ||
@@ -122,3 +119,3 @@ (0, token_1.default)(this, result.token, this.sendTokenOptions); | ||
.catch((err) => { | ||
this.requestCallbacks[reqId].reject(err); | ||
this.requestCallbacks[reqId]?.reject(err); | ||
}); | ||
@@ -125,0 +122,0 @@ } |
@@ -1,5 +0,5 @@ | ||
var Ze=Object.create;var U=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames,ke=Object.getOwnPropertySymbols,st=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var Se=(e,s,t)=>s in e?U(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Oe=(e,s)=>{for(var t in s||(s={}))Te.call(s,t)&&Se(e,t,s[t]);if(ke)for(var t of ke(s))rt.call(s,t)&&Se(e,t,s[t]);return e};var Ce=(e,s)=>{for(var t in s)U(e,t,{get:s[t],enumerable:!0})},H=(e,s,t,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of tt(s))!Te.call(e,r)&&r!==t&&U(e,r,{get:()=>s[r],enumerable:!(n=et(s,r))||n.enumerable});return e},b=(e,s,t)=>(H(e,s,"default"),t&&H(t,s,"default")),_=(e,s,t)=>(t=e!=null?Ze(st(e)):{},H(s||!e||!e.__esModule?U(t,"default",{value:e,enumerable:!0}):t,e)),it=e=>H(U({},"__esModule",{value:!0}),e);var m={};Ce(m,{Based:()=>se,BasedClient:()=>D,BasedGraphQL:()=>S.BasedGraphQL,Observable:()=>P,addGetSubscriber:()=>J,addRequest:()=>k,addSubscriber:()=>E,createGraphqlOperations:()=>S.createOperations,default:()=>gt,generateSubscriptionId:()=>q,generateTrackingKey:()=>be,handleGraphqlVariables:()=>S.handleGraphqlVariables,parseGraphql:()=>S.parseGraphql,removeSubscriber:()=>y});module.exports=it(m);var ie=class{constructor(){this.listeners={};Object.defineProperty(this,"listeners",{enumerable:!1,writable:!0})}emit(s,t){this.listeners[s]&&this.listeners[s].forEach(n=>n(t))}on(s,t){this.listeners[s]||(this.listeners[s]=[]),this.listeners[s].push(t)}removeAllListeners(){this.listeners={}}once(s,t){this.on(s,n=>{t(n),this.removeListener(s,t)})}removeListener(s,t){let n=this.listeners[s];if(n){if(!t)delete this.listeners[s];else for(let r=0,i=n.length;r<i;r++)if(n[r]===t){n.splice(r,1);break}}}},we=ie;var Pe=(e,s)=>{typeof e=="function"?e().then(t=>{s(t)}):s(e)};var Be=_(require("isomorphic-ws")),G=new Map,qe;typeof window!="undefined"&&document.addEventListener("visibilitychange",function(){clearTimeout(qe),document.hidden?qe=setTimeout(()=>{G.forEach(e=>{e(!1)})},3e4):G.forEach(e=>{e(!0)})});var ne=(e,s,t={destroy:()=>{G.delete(t)}},n=0,r=!1)=>(Pe(s,i=>{setTimeout(()=>{if(t.disconnected)return;let o=!0;G.set(t,a=>{t.disconnected||(!a&&o?(console.warn("Send to background - close connection"),o=!1,e.onClose(),c.close()):!o&&a&&(G.delete(t),ne(e,s,t,0,!0)))});let c=t.ws=new Be.default(i);c.onerror=()=>{},c.onmessage=a=>e.onData(a),c.onopen=()=>{if(o){if(t.disconnected)return;n=100,r&&e.onReconnect(),e.onOpen()}},c.onclose=()=>{if(o){if(t.disconnected)return;e.onClose(),ne(e,s,t,Math.min(1250,Math.min(n+500)),!0)}}},n)}),t),oe=ne;var v=require("@based/types");var Q=require("@based/types");var j=require("@based/types");var nt=e=>{clearTimeout(e.idlePing),e.idlePing=setTimeout(()=>{e.connection&&e.connected&&!e.connection.disconnected&&e.connection.ws.send("1")},6e4)},z=nt;var f=(e,s)=>{s[0]===j.RequestTypes.Unsubscribe||s[0]===j.RequestTypes.Subscription||s[0]===j.RequestTypes.SendSubscriptionData||s[0]===j.RequestTypes.GetSubscription?e.subscriptionQueue.push(s):e.queue.push(s),e.connected&&!e.drainInProgress&&ae(e)},ae=e=>{e.connected&&!e.drainInProgress&&(e.queue.length||e.subscriptionQueue.length)&&!e.isLogginIn&&(e.drainInProgress=!0,e.drainTimeout=setTimeout(()=>{if(e.drainInProgress=!1,e.queue.length||e.subscriptionQueue.length){let s=[...e.queue,...e.subscriptionQueue];e.queue=[],e.subscriptionQueue=[],e.connection.ws.send(JSON.stringify(s)),z(e)}},0))},Re=e=>{e.drainInProgress&&(clearTimeout(e.drainTimeout),e.drainInProgress=!1)};var ce=require("@saulx/hash"),q=(e,s)=>s?(0,ce.hashObjectIgnoreKeyOrder)([s,e]):(0,ce.hashObjectIgnoreKeyOrder)(e);var J=(e,s,t,n,r)=>{n||(n=q(s,r));let i=e.subscriptions[n],o=e.cache[n];if(i)if(i.authError)if(!e.beingAuth)t(i.authError.error,n,0);else{let c=++i.cnt;i.subscribers[c]={onInitial:t}}else if(o)t(null,n,0,o.value);else{let c=++i.cnt;i.subscribers[c]={onInitial:t}}else{i=e.subscriptions[n]={query:s,cnt:1,name:r,subscribers:{1:{onInitial:t}}};let c;for(let a=0;a<e.subscriptionQueue.length;a++){let[u,l,,p]=e.subscriptionQueue[a];(u===Q.RequestTypes.Unsubscribe||u===Q.RequestTypes.SendSubscriptionData)&&l===n?(e.subscriptionQueue.splice(a,1),a--):(u===Q.RequestTypes.Subscription||u===Q.RequestTypes.GetSubscription)&&l===n&&(c=!0,u===Q.RequestTypes.Subscription&&(p!==o.checksum&&(e.subscriptionQueue[a][3]=o.checksum),e.subscriptionQueue[a][4]=2))}if(!c){let a=[Q.RequestTypes.GetSubscription,n,s];o&&a.push(o.checksum),r&&(o||a.push(0),a.push(r)),f(e,a)}}};var B=require("@based/types");var E=(e,s,t,n,r,i,o)=>{i||(i=q(s,o));let c=e.subscriptions[i],a=e.cache[i],u;if(c){u=++c.cnt;let l=!0;for(let p in c.subscribers)if(c.subscribers[p].onData){l=!1;break}if(c.subscribers[u]={onError:r,onData:t,onInitial:n},l){for(let d=0;d<e.subscriptionQueue.length;d++){let[h,T]=e.subscriptionQueue[d];h===B.RequestTypes.GetSubscription&&T===i&&(e.subscriptionQueue.splice(d,1),d--)}let p=[B.RequestTypes.Subscription,i,s];a&&(p.push(a.checksum),p.push(2)),o&&(a||p.push(0,2),p.push(o)),f(e,p)}}else{u=1,c=e.subscriptions[i]={query:s,cnt:1,name:o,subscribers:{1:{onError:r,onData:t,onInitial:n}}};let l=!1,p=!1,d;for(let h=0;h<e.subscriptionQueue.length;h++){let[T,R,,A]=e.subscriptionQueue[h];(T===B.RequestTypes.Unsubscribe||T===B.RequestTypes.SendSubscriptionData||T===B.RequestTypes.GetSubscription)&&R===i?(T===B.RequestTypes.GetSubscription&&(p=!0),d&&(d[4]=2),e.subscriptionQueue.splice(h,1),h--):T===B.RequestTypes.Subscription&&R===i&&(l=!0,d=e.subscriptionQueue[h],A!==a.checksum&&(d[3]=a.checksum),!d[4]&&p&&(d[4]=2))}if(!l){let h=[B.RequestTypes.Subscription,i,s];a&&(h.push(a.checksum),p&&h.push(2)),o&&(a?!p&&a&&h.push(2):h.push(0,0),h.push(o)),f(e,h)}}return a&&(n&&(n(null,i,u),delete c.subscribers[u].onInitial),t&&t(a.value,a.checksum)),[i,u]};var $=require("@based/types");var y=(e,s,t)=>{let n=e.subscriptions[s];if(n){let r=!1;if(t?n.subscribers[t]&&(delete n.subscribers[t],n.cnt--,n.cnt===0&&(r=!0)):r=!0,r){delete e.subscriptions[s];let i=!1;for(let o=0;o<e.subscriptionQueue.length;o++){let[c,a]=e.subscriptionQueue[o];c===$.RequestTypes.Unsubscribe&&a===s?i=!0:(c===$.RequestTypes.Subscription||c===$.RequestTypes.SendSubscriptionData)&&a===s&&(e.subscriptionQueue.splice(o,1),o--)}i||f(e,[$.RequestTypes.Unsubscribe,s])}}};var Ee=require("@based/types"),Fe=e=>{for(let s=0;s<e.subscriptionQueue.length;s++)e.subscriptionQueue[s][0]===Ee.RequestTypes.Unsubscribe&&(e.subscriptionQueue.splice(s,1),s--)};var Qe=require("@based/types"),xe=e=>{for(let s=0;s<e.subscriptionQueue.length;s++)e.subscriptionQueue[s][0]===Qe.RequestTypes.SendSubscriptionData&&(e.subscriptionQueue.splice(s,1),s--)};var x=require("@based/types");var M=(e,s=!1)=>{for(let t in e.subscriptions){let n=Number(t),r=e.subscriptions[t];if(s&&!r.authError)continue;let i,o,c;for(let l=0;l<e.subscriptionQueue.length;l++){let[p,d]=e.subscriptionQueue[l];d===n&&(p===x.RequestTypes.GetSubscription?(c=l,i=e.subscriptionQueue[l]):p===x.RequestTypes.Subscription&&(o=e.subscriptionQueue[l]))}i&&o&&console.error("GET IN Q AND SUB IN Q SHOULD BE IMPOSSIBLE");let a=e.cache[n],u=!1;if(i){let l=!0;for(let p in r.subscribers)if(r.subscribers[p].onData){l=!1;break}l?u=!0:(console.info("not only gets remove get"),e.subscriptionQueue.splice(c,1)),a&&i[3]!==a.checksum&&(i[3]=a.checksum)}if(!u)if(o)a&&o[3]!==a.checksum&&(o[3]=a.checksum,i&&(o[4]=2));else{let{name:l,query:p}=e.subscriptions[n];l?a?f(e,[x.RequestTypes.Subscription,n,p,a.checksum,i?2:0,l]):f(e,[x.RequestTypes.Subscription,n,p,0,i?2:0,l]):a?f(e,[x.RequestTypes.Subscription,n,p,a.checksum,i?2:0]):f(e,[x.RequestTypes.Subscription,n,p,0,i?2:0])}}};var Ae=require("@based/types");var K=(e,s)=>{if(typeof window!="undefined")return e;let t={white:"\x1B[37;1m",reset:"\x1B[0m",blue:"\x1B[34m",red:"\x1B[31m",green:"\x1B[32m",brightBlue:"\x1B[34;1m",brightRed:"\x1B[31;1m"};return`${t[s]}${e}${t.reset}`},ue=(e,s=0,t=!1,n="",r=!1)=>{let i="";for(let a=0;a<s;a++)i+=" ";let o=t?[]:n?[i+`${K(n,r?"brightRed":"white")} {`]:[i+"{"],c=!1;t||(i+=" ",s+=1);for(let a in e){let u=e[a],l=a[0]==="$"?K(a,"white"):a;if(c&&(o[o.length-1]+=","),Array.isArray(u)){o.push(`${i} ${l}: [`);for(let p=0;p<u.length;p++){let d=u[p];o.push(...d&&typeof d=="object"?ue(d,s+4):[`${i} ${d}`]),p!==u.length-1&&(o[o.length-1]+=",")}o.push(`${i} ]`)}else u&&typeof u=="object"?(o.push(`${i} ${l}: {`),o.push(...ue(u,s+2,!0)),o.push(`${i} }`)):o.push(`${i} ${l}: ${u}`);c=!0}return t||o.push(i.slice(0,-1)+"}"),o},W=ue;var C=e=>{let s=new Ae.BasedError(e.message);if(s.name=e.name?`${e.type} from ${e.name}`:e.type,s.stack=null,e.query||e.payload){let t=s.message.split(` | ||
`),n=0;t[0]===""&&t.shift();let r=t[0];for(let i=0;i<r.length;i++)if(r[i]!==" "){n=i-2;break}n>0?t=t.map(i=>i.slice(n)):t=t.map(i=>" "+i),e.code&&(s.code=e.code),s.message=` | ||
var st=Object.create;var U=Object.defineProperty,rt=Object.defineProperties,it=Object.getOwnPropertyDescriptor,nt=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertyNames,H=Object.getOwnPropertySymbols,at=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var Oe=(e,s,t)=>s in e?U(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,oe=(e,s)=>{for(var t in s||(s={}))ne.call(s,t)&&Oe(e,t,s[t]);if(H)for(var t of H(s))Ce.call(s,t)&&Oe(e,t,s[t]);return e},we=(e,s)=>rt(e,nt(s));var Pe=(e,s)=>{var t={};for(var n in e)ne.call(e,n)&&s.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&H)for(var n of H(e))s.indexOf(n)<0&&Ce.call(e,n)&&(t[n]=e[n]);return t};var qe=(e,s)=>{for(var t in s)U(e,t,{get:s[t],enumerable:!0})},_=(e,s,t,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of ot(s))!ne.call(e,i)&&i!==t&&U(e,i,{get:()=>s[i],enumerable:!(n=it(s,i))||n.enumerable});return e},d=(e,s,t)=>(_(e,s,"default"),t&&_(t,s,"default")),z=(e,s,t)=>(t=e!=null?st(at(e)):{},_(s||!e||!e.__esModule?U(t,"default",{value:e,enumerable:!0}):t,e)),ct=e=>_(U({},"__esModule",{value:!0}),e);var m={};qe(m,{Based:()=>re,BasedClient:()=>D,BasedGraphQL:()=>S.BasedGraphQL,Observable:()=>P,addGetSubscriber:()=>K,addRequest:()=>k,addSubscriber:()=>E,createGraphqlOperations:()=>S.createOperations,default:()=>St,generateSubscriptionId:()=>q,generateTrackingKey:()=>he,handleGraphqlVariables:()=>S.handleGraphqlVariables,parseGraphql:()=>S.parseGraphql,removeSubscriber:()=>y});module.exports=ct(m);var ae=class{constructor(){this.listeners={};Object.defineProperty(this,"listeners",{enumerable:!1,writable:!0})}emit(s,t){this.listeners[s]&&this.listeners[s].forEach(n=>n(t))}on(s,t){this.listeners[s]||(this.listeners[s]=[]),this.listeners[s].push(t)}removeAllListeners(){this.listeners={}}once(s,t){this.on(s,n=>{t(n),this.removeListener(s,t)})}removeListener(s,t){let n=this.listeners[s];if(n){if(!t)delete this.listeners[s];else for(let i=0,r=n.length;i<r;i++)if(n[i]===t){n.splice(i,1);break}}}},Be=ae;var Re=(e,s)=>{typeof e=="function"?e().then(t=>{s(t)}):s(e)};var Fe=z(require("isomorphic-ws")),G=new Map,Ee;typeof window!="undefined"&&document.addEventListener("visibilitychange",function(){clearTimeout(Ee),document.hidden?Ee=setTimeout(()=>{G.forEach(e=>{e(!1)})},3e4):G.forEach(e=>{e(!0)})});var ce=(e,s,t={destroy:()=>{G.delete(t)}},n=0,i=!1)=>(Re(s,r=>{setTimeout(()=>{if(t.disconnected)return;let o=!0;G.set(t,a=>{t.disconnected||(!a&&o?(console.warn("Send to background - close connection"),o=!1,e.onClose(),c.close()):!o&&a&&(G.delete(t),ce(e,s,t,0,!0)))});let c=t.ws=new Fe.default(r);c.onerror=()=>{},c.onmessage=a=>e.onData(a),c.onopen=()=>{if(o){if(t.disconnected)return;n=100,i&&e.onReconnect(),e.onOpen()}},c.onclose=()=>{if(o){if(t.disconnected)return;e.onClose(),ce(e,s,t,Math.min(1250,Math.min(n+500)),!0)}}},n)}),t),ue=ce;var v=require("@based/types");var Q=require("@based/types");var j=require("@based/types");var ut=e=>{clearTimeout(e.idlePing),e.idlePing=setTimeout(()=>{e.connection&&e.connected&&!e.connection.disconnected&&e.connection.ws.send("1")},6e4)},J=ut;var f=(e,s)=>{s[0]===j.RequestTypes.Unsubscribe||s[0]===j.RequestTypes.Subscription||s[0]===j.RequestTypes.SendSubscriptionData||s[0]===j.RequestTypes.GetSubscription?e.subscriptionQueue.push(s):e.queue.push(s),e.connected&&!e.drainInProgress&&le(e)},le=e=>{e.connected&&!e.drainInProgress&&(e.queue.length||e.subscriptionQueue.length)&&!e.isLogginIn&&(e.drainInProgress=!0,e.drainTimeout=setTimeout(()=>{if(e.drainInProgress=!1,e.queue.length||e.subscriptionQueue.length){let s=[...e.queue,...e.subscriptionQueue];e.queue=[],e.subscriptionQueue=[],e.connection.ws.send(JSON.stringify(s)),J(e)}},0))},Qe=e=>{e.drainInProgress&&(clearTimeout(e.drainTimeout),e.drainInProgress=!1)};var pe=require("@saulx/hash"),q=(e,s)=>s?(0,pe.hashObjectIgnoreKeyOrder)([s,e]):(0,pe.hashObjectIgnoreKeyOrder)(e);var K=(e,s,t,n,i)=>{n||(n=q(s,i));let r=e.subscriptions[n],o=e.cache[n];if(r)if(r.authError)if(!e.beingAuth)t(r.authError.error,n,0);else{let c=++r.cnt;r.subscribers[c]={onInitial:t}}else if(o)t(null,n,0,o.value);else{let c=++r.cnt;r.subscribers[c]={onInitial:t}}else{r=e.subscriptions[n]={query:s,cnt:1,name:i,subscribers:{1:{onInitial:t}}};let c;for(let a=0;a<e.subscriptionQueue.length;a++){let[u,l,,p]=e.subscriptionQueue[a];(u===Q.RequestTypes.Unsubscribe||u===Q.RequestTypes.SendSubscriptionData)&&l===n?(e.subscriptionQueue.splice(a,1),a--):(u===Q.RequestTypes.Subscription||u===Q.RequestTypes.GetSubscription)&&l===n&&(c=!0,u===Q.RequestTypes.Subscription&&(p!==o.checksum&&(e.subscriptionQueue[a][3]=o.checksum),e.subscriptionQueue[a][4]=2))}if(!c){let a=[Q.RequestTypes.GetSubscription,n,s];o&&a.push(o.checksum),i&&(o||a.push(0),a.push(i)),f(e,a)}}};var B=require("@based/types");var E=(e,s,t,n,i,r,o)=>{r||(r=q(s,o));let c=e.subscriptions[r],a=e.cache[r],u;if(c){u=++c.cnt;let l=!0;for(let p in c.subscribers)if(c.subscribers[p].onData){l=!1;break}if(c.subscribers[u]={onError:i,onData:t,onInitial:n},l){for(let b=0;b<e.subscriptionQueue.length;b++){let[h,T]=e.subscriptionQueue[b];h===B.RequestTypes.GetSubscription&&T===r&&(e.subscriptionQueue.splice(b,1),b--)}let p=[B.RequestTypes.Subscription,r,s];a&&(p.push(a.checksum),p.push(2)),o&&(a||p.push(0,2),p.push(o)),f(e,p)}}else{u=1,c=e.subscriptions[r]={query:s,cnt:1,name:o,subscribers:{1:{onError:i,onData:t,onInitial:n}}};let l=!1,p=!1,b;for(let h=0;h<e.subscriptionQueue.length;h++){let[T,R,,A]=e.subscriptionQueue[h];(T===B.RequestTypes.Unsubscribe||T===B.RequestTypes.SendSubscriptionData||T===B.RequestTypes.GetSubscription)&&R===r?(T===B.RequestTypes.GetSubscription&&(p=!0),b&&(b[4]=2),e.subscriptionQueue.splice(h,1),h--):T===B.RequestTypes.Subscription&&R===r&&(l=!0,b=e.subscriptionQueue[h],A!==a.checksum&&(b[3]=a.checksum),!b[4]&&p&&(b[4]=2))}if(!l){let h=[B.RequestTypes.Subscription,r,s];a&&(h.push(a.checksum),p&&h.push(2)),o&&(a?!p&&a&&h.push(2):h.push(0,0),h.push(o)),f(e,h)}}return a&&(n&&(n(null,r,u),delete c.subscribers[u].onInitial),t&&t(a.value,a.checksum)),[r,u]};var $=require("@based/types");var y=(e,s,t)=>{let n=e.subscriptions[s];if(n){let i=!1;if(t?n.subscribers[t]&&(delete n.subscribers[t],n.cnt--,n.cnt===0&&(i=!0)):i=!0,i){delete e.subscriptions[s];let r=!1;for(let o=0;o<e.subscriptionQueue.length;o++){let[c,a]=e.subscriptionQueue[o];c===$.RequestTypes.Unsubscribe&&a===s?r=!0:(c===$.RequestTypes.Subscription||c===$.RequestTypes.SendSubscriptionData)&&a===s&&(e.subscriptionQueue.splice(o,1),o--)}r||f(e,[$.RequestTypes.Unsubscribe,s])}}};var xe=require("@based/types"),Ae=e=>{for(let s=0;s<e.subscriptionQueue.length;s++)e.subscriptionQueue[s][0]===xe.RequestTypes.Unsubscribe&&(e.subscriptionQueue.splice(s,1),s--)};var De=require("@based/types"),Ie=e=>{for(let s=0;s<e.subscriptionQueue.length;s++)e.subscriptionQueue[s][0]===De.RequestTypes.SendSubscriptionData&&(e.subscriptionQueue.splice(s,1),s--)};var x=require("@based/types");var M=(e,s=!1)=>{for(let t in e.subscriptions){let n=Number(t),i=e.subscriptions[t];if(s&&!i.authError)continue;let r,o,c;for(let l=0;l<e.subscriptionQueue.length;l++){let[p,b]=e.subscriptionQueue[l];b===n&&(p===x.RequestTypes.GetSubscription?(c=l,r=e.subscriptionQueue[l]):p===x.RequestTypes.Subscription&&(o=e.subscriptionQueue[l]))}r&&o&&console.error("GET IN Q AND SUB IN Q SHOULD BE IMPOSSIBLE");let a=e.cache[n],u=!1;if(r){let l=!0;for(let p in i.subscribers)if(i.subscribers[p].onData){l=!1;break}l?u=!0:(console.info("not only gets remove get"),e.subscriptionQueue.splice(c,1)),a&&r[3]!==a.checksum&&(r[3]=a.checksum)}if(!u)if(o)a&&o[3]!==a.checksum&&(o[3]=a.checksum,r&&(o[4]=2));else{let{name:l,query:p}=e.subscriptions[n];l?a?f(e,[x.RequestTypes.Subscription,n,p,a.checksum,r?2:0,l]):f(e,[x.RequestTypes.Subscription,n,p,0,r?2:0,l]):a?f(e,[x.RequestTypes.Subscription,n,p,a.checksum,r?2:0]):f(e,[x.RequestTypes.Subscription,n,p,0,r?2:0])}}};var Ue=require("@based/types");var W=(e,s)=>{if(typeof window!="undefined")return e;let t={white:"\x1B[37;1m",reset:"\x1B[0m",blue:"\x1B[34m",red:"\x1B[31m",green:"\x1B[32m",brightBlue:"\x1B[34;1m",brightRed:"\x1B[31;1m"};return`${t[s]}${e}${t.reset}`},de=(e,s=0,t=!1,n="",i=!1)=>{let r="";for(let a=0;a<s;a++)r+=" ";let o=t?[]:n?[r+`${W(n,i?"brightRed":"white")} {`]:[r+"{"],c=!1;t||(r+=" ",s+=1);for(let a in e){let u=e[a],l=a[0]==="$"?W(a,"white"):a;if(c&&(o[o.length-1]+=","),Array.isArray(u)){o.push(`${r} ${l}: [`);for(let p=0;p<u.length;p++){let b=u[p];o.push(...b&&typeof b=="object"?de(b,s+4):[`${r} ${b}`]),p!==u.length-1&&(o[o.length-1]+=",")}o.push(`${r} ]`)}else u&&typeof u=="object"?(o.push(`${r} ${l}: {`),o.push(...de(u,s+2,!0)),o.push(`${r} }`)):o.push(`${r} ${l}: ${u}`);c=!0}return t||o.push(r.slice(0,-1)+"}"),o},V=de;var C=e=>{let s=new Ue.BasedError(e.message);if(s.name=e.name?`${e.type} from ${e.name}`:e.type,s.stack=null,e.query||e.payload){let t=s.message.split(` | ||
`),n=0;t[0]===""&&t.shift();let i=t[0];for(let r=0;r<i.length;r++)if(i[r]!==" "){n=r-2;break}n>0?t=t.map(r=>r.slice(n)):t=t.map(r=>" "+r),e.code&&(s.code=e.code),s.message=` | ||
`+(e.payload&&typeof e.payload!="object"?` ${K("Payload","brightRed")} ${e.payload}`:W(e.payload||e.query,0,!1,e.payload?"Payload":"Query",!0).map(i=>" "+i).join(` | ||
`+(e.payload&&typeof e.payload!="object"?` ${W("Payload","brightRed")} ${e.payload}`:V(e.payload||e.query,0,!1,e.payload?"Payload":"Query",!0).map(r=>" "+r).join(` | ||
`))+` | ||
@@ -10,7 +10,7 @@ | ||
`}return s};var De=(e,s)=>{let[,t,n,r,i]=s,o=e.subscriptions[t];if(o){let c=e.cache[t]&&e.cache[t].checksum;if(i){let a=C(i);i.auth&&(o.authError={token:e.token,error:a});for(let u in o.subscribers){let l=o.subscribers[u];l.onInitial?i.auth?(l.onError&&l.onError(a),l.onInitial(a,Number(t),Number(u),void 0,!0),delete l.onInitial):(l.onInitial(a,Number(t),Number(u)),delete l.onInitial,y(e,t,Number(u))):l.onError&&l.onError(a)}}else if(c===r){o.authError&&delete o.authError;for(let a in o.subscribers){let u=o.subscribers[a];u.onInitial&&(u.onInitial(null,Number(t),Number(a),e.cache[t].value),delete u.onInitial,u.onData||y(e,t,Number(a)))}}else{o.authError&&delete o.authError,e.cache[t]={value:n,checksum:r};for(let a in o.subscribers){let u=o.subscribers[a];u.onInitial&&(u.onInitial(null,Number(t),Number(a),n),delete u.onInitial,u.onData||y(e,t,Number(a))),u.onData&&u.onData(n,r)}}}};var Ie=require("@saulx/diff"),V=require("@based/types");var Ue=(e,s)=>{let[,t,n,[r,i]]=s,o=e.subscriptions[t];if(o){let c=e.cache[t];if(!c||c.checksum!==r)if(c)if(c.checksum===i)for(let a in o.subscribers){let u=o.subscribers[a];u.onInitial&&(u.onInitial(null,Number(t),Number(a),c.value),delete u.onInitial,u.onData||y(e,t,Number(a)))}else f(e,[V.RequestTypes.SendSubscriptionData,t]);else f(e,[V.RequestTypes.SendSubscriptionData,t]);else{let a=!1;try{c.value=(0,Ie.applyPatch)(c.value,n),c.value===null&&(a=!0)}catch(u){a=!0}if(a)console.warn(` | ||
`}return s};var Ge=(e,s)=>{let[,t,n,i,r]=s,o=e.subscriptions[t];if(o){let c=e.cache[t]&&e.cache[t].checksum;if(r){let a=C(r);r.auth&&(o.authError={token:e.token,error:a});for(let u in o.subscribers){let l=o.subscribers[u];l.onInitial?r.auth?(l.onError&&l.onError(a),l.onInitial(a,Number(t),Number(u),void 0,!0),delete l.onInitial):(l.onInitial(a,Number(t),Number(u)),delete l.onInitial,y(e,t,Number(u))):l.onError&&l.onError(a)}}else if(c===i){o.authError&&delete o.authError;for(let a in o.subscribers){let u=o.subscribers[a];u.onInitial&&(u.onInitial(null,Number(t),Number(a),e.cache[t].value),delete u.onInitial,u.onData||y(e,t,Number(a)))}}else{o.authError&&delete o.authError,e.cache[t]={value:n,checksum:i};for(let a in o.subscribers){let u=o.subscribers[a];u.onInitial&&(u.onInitial(null,Number(t),Number(a),n),delete u.onInitial,u.onData||y(e,t,Number(a))),u.onData&&u.onData(n,i)}}}};var je=require("@saulx/diff"),X=require("@based/types");var $e=(e,s)=>{let[,t,n,[i,r]]=s,o=e.subscriptions[t];if(o){let c=e.cache[t];if(!c||c.checksum!==i)if(c)if(c.checksum===r)for(let a in o.subscribers){let u=o.subscribers[a];u.onInitial&&(u.onInitial(null,Number(t),Number(a),c.value),delete u.onInitial,u.onData||y(e,t,Number(a)))}else f(e,[X.RequestTypes.SendSubscriptionData,t]);else f(e,[X.RequestTypes.SendSubscriptionData,t]);else{let a=!1;try{c.value=(0,je.applyPatch)(c.value,n),c.value===null&&(a=!0)}catch(u){a=!0}if(a)console.warn(` | ||
Found corrupt data while applying diff to subscription need to re-fetch | ||
`),console.warn(W(o.query,2,!1,"Query").join(` | ||
`),console.warn(V(o.query,2,!1,"Query").join(` | ||
`)+` | ||
`),delete e.cache[t],f(e,[V.RequestTypes.SendSubscriptionData,t]);else{c.checksum=i;for(let u in o.subscribers){let l=o.subscribers[u];l.onInitial&&(l.onInitial(null,Number(t),Number(u),c.value),delete l.onInitial,l.onData||y(e,t,Number(u))),l.onData&&l.onData(c.value,c.checksum)}}}}};var Ge=(e,s)=>{for(let t of s[1]){delete e.cache[t];let n=e.subscriptions[t];if(n){let r={type:"AuthorizationError",name:n.name?`observe "${n.name}"`:"observe",message:"Unauthorized request",payload:n.query,auth:!0},i=C(r);n.authError={token:e.token,error:i};for(let o in n.subscribers){let c=n.subscribers[o];c.onError&&c.onError(i)}}}};var je=require("@based/types");var ot=0,k=(e,s,t,n,r,i,o)=>{let c=++ot;e.requestCallbacks[c]={resolve:n,reject:r,type:s,payload:t,name:i,isRetry:o},s===je.RequestTypes.Call?f(e,[s,i,c,t]):f(e,[s,c,t])};var $e=(e,s)=>{let[,t,n,r]=s,i=e.requestCallbacks[t];i&&(delete e.requestCallbacks[t],r?i.reject(C(r)):i.resolve(n))};var O={};Ce(O,{BasedClient:()=>D});var g=require("@based/types");var le=require("@based/types");var at=e=>typeof e!="undefined"&&e!==null,ct=(e,s,t)=>{if(e.beingAuth=!0,s)e.token=s,e.sendTokenOptions=t;else{for(let n in e.cache)e.subscriptions[n]||delete e.cache[n];delete e.token,delete e.sendTokenOptions}if(e.connected){let n=s?[le.RequestTypes.Token,s,t].filter(at):[le.RequestTypes.Token];e.connection.ws.send(JSON.stringify(n)),z(e),M(e,!0)}},w=ct;var F=require("@based/types");var pe=0,Me=(e,s)=>{let t=++pe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.Login,t,s]),new Promise((n,r)=>{e.authCallbacks[t]={resolve:i=>{w(e,i.token,{refreshToken:i.refreshToken}),n(i)},reject:r}})},Ne=(e,s)=>{let t=++pe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.RenewToken,t,s]),new Promise((n,r)=>{e.authCallbacks[t]={resolve:i=>{w(e,i.token),n(i)},reject:r}})},Le=(e,s)=>{let[,t,n,r]=s,i=e.authCallbacks[t];i&&(delete e.authCallbacks[t],r?i.reject(C(r)):i.resolve(n))},He=e=>{let s=++pe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.Logout,s]),new Promise((t,n)=>{e.authCallbacks[s]={resolve:r=>{w(e),t(r)},reject:n}})};b(O,require("@based/types"));var D=class{constructor(s){this.auth=[];this.subscriptions={};this.cache={};this.requestCallbacks={};this.authCallbacks={};this.connected=!1;this.subscriptionQueue=[];this.queue=[];this.drainInProgress=!1;this.based=s}onClose(){this.connected=!1,Re(this),Fe(this),xe(this),this.based.listeners.disconnect&&this.based.listeners.disconnect.forEach(s=>s())}onReconnect(){if(this.based.listeners.reconnect&&this.based.listeners.reconnect.forEach(s=>s()),this.tracking)for(let s of this.tracking)f(this,[g.RequestTypes.Track,{t:s}])}onOpen(){this.connected=!0,this.based.listeners.connect&&this.based.listeners.connect.forEach(s=>s()),this.token&&w(this,this.token,this.sendTokenOptions),M(this),ae(this)}onData(s){var t,n,r;try{let i=JSON.parse(s.data),[o,c,a,u,l]=i;if(o===g.RequestTypes.Token){this.retryingRenewToken=!1,c.length&&Ge(this,i);for(let p of this.auth)p(!a);this.beingAuth=!1,this.auth=[]}else if(o===g.RequestTypes.Auth)Le(this,i);else if((((t=l||u)==null?void 0:t.code)===g.BasedErrorCodes.TokenExpired||((n=l||u)==null?void 0:n.message)==="Token expired")&&!this.retryingRenewToken){this.retryingRenewToken=!0;let p=(r=this.sendTokenOptions)==null?void 0:r.refreshToken;Ne(this,{refreshToken:p}).then(d=>{w(this,d.token,this.sendTokenOptions),o===g.RequestTypes.Subscription||o===g.RequestTypes.SubscriptionDiff?M(this):k(this,o,u==null?void 0:u.payload,this.requestCallbacks[c].resolve,this.requestCallbacks[c].reject),this.based.emit("renewToken",d)}).catch(d=>{this.requestCallbacks[c].reject(d)})}else o===g.RequestTypes.Set||o===g.RequestTypes.Get||o===g.RequestTypes.Configuration||o===g.RequestTypes.GetConfiguration||o===g.RequestTypes.Call||o===g.RequestTypes.Delete||o===g.RequestTypes.Copy||o===g.RequestTypes.Digest||o===g.RequestTypes.RemoveType||o===g.RequestTypes.RemoveField?$e(this,i):o===g.RequestTypes.Subscription?De(this,i):o===g.RequestTypes.SubscriptionDiff&&Ue(this,i)}catch(i){console.error("Received incorrect data ",s)}}};var de=(e,s)=>{let t;if(e.configuration&&e.configuration.schema)for(let n in e.configuration.schema){let r=e.configuration.schema[n];if(r.prefixToTypeMapping){for(let i in r.prefixToTypeMapping)if(r.prefixToTypeMapping[i]===s){t=i;break}}}return t};var ge=require("@saulx/hash");var ze=require("@based/types"),Je=require("@saulx/hash"),_e=new Set,ut=e=>{if(typeof window!="undefined"){if(_e.has(e))return!1;_e.add(e);try{let s="_ba:"+(0,Je.hashCompact)(e);return localStorage.getItem(s)?!1:(localStorage.setItem(s,"1"),!0)}catch(s){return!1}}return!1},be=(e,s)=>{if(s){let t=`${e}`,n=Object.keys(s).sort();for(let r of n)t+="_"+r+"_"+s[r];return t}else return e},N=(e,s,t,n,r,i,o)=>{let c=be(s,t),a={t:c};o&&(a.r=1),r&&(a.e=1,i&&(a.o=i)),n?(a.s=1,e.tracking.delete(c)):o||(r||(e.tracking||(e.tracking=new Set),e.tracking.add(c)),ut(c)&&(a.u=1)),f(e,[ze.RequestTypes.Track,a])};var fe=class{constructor(s,t,n){this.closed=!1;this.client=s,this.subId=n,this.subscriberId=t}unsubscribe(){this.closed=!0,y(this.client,this.subId,this.subscriberId)}},me=class{constructor(s,t){this.closed=!1;this.client=s,this.subs=t}unsubscribe(){if(!this.closed){this.closed=!0;for(let s of this.subs)s.unsubscribe()}}},X=class{constructor(s,t){this.client=s,this.components=t}subscribe(s,t,n){let r={data:{}},i=[];for(let{key:o,obs:c}of this.components){let a=c.subscribe(u=>{if(o===""){Object.assign(r.data,u),s(r);return}r.data[o]=u,s(r)},t);i.push(a)}return new me(this.client,i)}},P=class{constructor(s,t,n){this.client=s,this.subId=typeof t=="string"?q(n,t):q(t),this.name=typeof t=="string"?t:null,this.payload=typeof t=="string"?n:t}subscribe(s,t,n){let[,r]=E(this.client,this.payload,s,i=>{i&&(console.error(i),t&&t(i))},t,this.subId,this.name);return new fe(this.client,r,this.subId)}};var he={},L={},lt=(e,s)=>{he[e]||(he[e]=!0,setTimeout(()=>{console.info("Drain file q"),he[e]=!1;let t=L[e];L[e]=[];let n=new global.FormData;for(let r of t){let{raw:i,name:o,id:c,file:a,functionName:u}=r,l=`${u||""}|${i?1:0}|${c}|${a.size}${o?`|${o}`:""}`;n.append(l,a)}try{let r=new global.XMLHttpRequest;r.upload.onprogress=i=>{let o=100*(i.loaded||i.position)/(i.totalSize||i.total);console.info(o,"upload...")},r.onerror=i=>{console.error("error!",i,"flap",r.responseText)},r.timeout=1e3*60*60*24,r.onabort=i=>{console.error("abort",i)},r.ontimeout=i=>{console.error("on timeout",i)},r.onload=()=>{let i={};try{i=JSON.parse(r.response),console.info("SUCCESS",i)}catch(o){console.error("something wrong with file upload",o)}},r.open("POST",e+"/file"),r.setRequestHeader("Content-Type","multipart/form-data"),r.setRequestHeader("Authorization",s),r.send(n)}catch(r){console.error("Something wrong with xhr upload",r)}},500))},Ke=async(e,s,t,n,r,i,o)=>{L[t]||(L[t]=[]),L[t].push({file:s,id:n,url:t,raw:r,name:i,functionName:o}),lt(t,e.getToken())};var We=_(require("@based/get-service")),Y={},Z={},pt=async(e,s)=>{if(s.url)return typeof s.url=="string"?s.url:await s.url();if(!e.opts.env&&e.opts.url)return typeof e.opts.url=="string"?e.opts.url:await e.opts.url();let{env:t,project:n,org:r}=e.opts,i=t+"/"+n+"/"+r+"/"+e.opts.cluster;if(Y[i])return Y[i];if(Z[i])return(await Z[i]).url;let o=await(Z[i]=(0,We.default)({env:t,project:n,org:r,name:"@based/hub",key:"file-upload",optionalKey:!0},0,e.opts.cluster));return delete Z[i],setTimeout(()=>{delete Y[i]},2e3),Y[i]=o.url},Ve=pt;var Xe=_(require("cross-fetch")),ee=(e,s,t)=>((0,Xe.default)(s,{method:"POST",cache:"no-cache",headers:{"Content-Type":t.mimeType||"text/plain","File-Id":t.id,"File-Is-Raw":t.raw?"1":"0","File-Name":t.name||"","Function-Name":t.functionName||"",Authorization:e.getToken()},body:t.contents}).then(n=>{}).catch(n=>{console.error("Error while uploading file",n)}),{id:t.id});var I=require("./file/stream"),te=typeof window!="undefined",dt=e=>"src"in e&&typeof e.src=="string",bt=e=>"path"in e&&typeof e.path=="string",ft=e=>"contents"in e&&(0,I.isStream)(e.contents),Ye=async(e,s)=>{if(dt(s)){let r=s.id?{$id:s.id}:{type:"file"};return s.src?(r.src=s.src,r.origin=s.src,s.size&&(r.size=s.size),s.name&&(r.name=s.name),s.parents&&(r.parents=s.parents),await e.set(r)):void 0}let t=s.id;if(!t){let r={type:"file",progress:0};s.name?r.name=s.name:global.File&&"contents"in s&&s.contents instanceof global.File&&(r.name=s.contents.name),s.parents&&(r.parents=s.parents),t=(await e.set(r)).id}s.id=t;let n=(await Ve(e,s)).replace(/^ws/,"http");if(bt(s))return(0,I.uploadFilePath)(e,n,s),{id:t};if(ft(s))return(0,I.uploadFileStream)(e,n,s),{id:t};if(s.contents instanceof ArrayBuffer)return s.contents=te?new global.Blob([s.contents],{type:s.mimeType||"text/plain"}):global.Buffer.from(s.contents),ee(e,n+"/file",s);if(te&&s.contents instanceof global.Blob)return s.mimeType||(s.mimeType=s.contents.type),ee(e,n+"/file",s);if(typeof s.contents=="string"||!te&&s.contents instanceof global.Buffer)return ee(e,n+"/file",s);if(te&&s.contents instanceof File)return Ke(e,s.contents,n,s.id,s.raw||!1,s.name,s.functionName),{id:t};throw s.id||await e.delete({$id:t}),new Error(`Invalid contents for file api ${JSON.stringify(s,null,2)}`)};var re=_(require("@based/get-service")),ye=require("@saulx/utils"),S=require("@based/graphql");b(m,require("@based/types"),module.exports);var se=class extends we{constructor(t){super();this.client=new D(this),Object.defineProperty(this,"client",{enumerable:!1,writable:!0}),t&&t.url&&this.connect(t.url),this.graphql={query:this.gqlQuery.bind(this),live:this.gqlLive.bind(this)}}connect(t){!t&&this._url?this.client.connection||(this.client.connection=oe(this.client,this._url)):(this._url=t,this.client.connection=oe(this.client,t))}disconnect(){this.client.connection&&(this.client.connection.disconnected=!0,this.client.connection.destroy(),this.client.connection.ws&&this.client.connection.ws.close(),this.client.connected&&this.client.onClose(),delete this.client.connection),this.client.connected=!1}observeUntil(t,n,r){return new Promise((i,o)=>{let c,a=!1;this.observe(t,(u,l)=>{r&&r(u,l),n(u,l)&&(a=!0,c&&c(),i(u))}).then(u=>{a?c():c=u}).catch(u=>{o(u)})})}gql(t,...n){typeof t=="string"&&(t=[t]);let r=t[0];return n.forEach((i,o)=>{i&&i.kind==="Document"?r+=i.loc.source.body:r+=i,r+=t[o+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema},(0,S.parseGraphql)(r))}gqlDb(t="default"){return(n,...r)=>{typeof n=="string"&&(n=[n]);let i=n[0];return r.forEach((o,c)=>{o&&o.kind==="Document"?i+=o.loc.source.body:i+=o,i+=n[c+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema,db:t},(0,S.parseGraphql)(i))}}observe(t,n,r,i){return typeof t=="string"?new Promise((o,c)=>{let a=typeof n=="function",u=a?n:r,l=a?r:i;E(this.client,a?void 0:n,u,(p,d,h,T,R)=>{p&&!R?c(p):o(()=>{y(this.client,d,h)})},l,void 0,t)}):new Promise((o,c)=>{E(this.client,t,n,(a,u,l,p,d)=>{a&&!d?c(a):o(()=>{y(this.client,u,l)})},r)})}createObservable(t,n){return typeof t=="string"?new P(this.client,t,n):new P(this.client,t)}observeSchema(t,n,r){return new Promise((i,o)=>{let c=typeof t=="string"?t:"default",a=typeof t=="string"?n:t,u=typeof t=="string"?r:n;E(this.client,{$subscribe_schema:c},(l,p)=>{this.client.configuration||(this.client.configuration={dbs:[],schema:{},functions:{}}),this.client.configuration.schema[c]=l,a(l,p)},(l,p,d,h,T)=>{l&&!T?o(l):i(()=>{y(this.client,p,d)})},u)})}get(t,n){return typeof t=="string"?new Promise((r,i)=>{J(this.client,n,(o,c,a,u)=>{o?i(o):r(u)},0,t)}):new Promise((r,i)=>{k(this.client,v.RequestTypes.Get,t,r,i)})}file(t){return global.File&&t instanceof File&&(t={contents:t}),Ye(this,t)}call(t,n){return new Promise((r,i)=>{k(this.client,v.RequestTypes.Call,n,r,i,t)})}async id(t,n){let r=de(this.client,t);if(r||(await this.schema(),r=de(this.client,t)),!r)throw C({message:`Type does not exist ${t}`,type:"Invalid type",payload:n?{type:t,opts:n}:{type:t}});if(n){let i=(0,ge.hashCompact)(n,8,!0);return r+i}else return r+(0,ge.hashCompact)(Math.floor(Math.random()*99999999999)+""+Date.now())}digest(t){return new Promise((n,r)=>{k(this.client,v.RequestTypes.Digest,t,n,r)})}set(t){return new Promise((n,r)=>{k(this.client,v.RequestTypes.Set,t,n,r)})}copy(t){return new Promise((n,r)=>{k(this.client,v.RequestTypes.Copy,t,n,r)})}async gqlQuery(t,n={}){let r;typeof t=="string"?r=this.gql(t):r=t;try{if(r=(0,S.handleGraphqlVariables)(r,r,n),r.opType==="GET"){let o={$db:r.db},c=[];for(let u in r.ops){if(r.ops[u].fnObserve){let l=await this.get(r.ops[u].fnObserve.name,r.ops[u].fnObserve.payload);c.push({key:u,reply:l});continue}r.ops[u].get&&(o[u]=r.ops[u].get)}let a=await this.get(o);for(let{key:u,reply:l}of c)a[u]=l;return{data:a}}let i={};return await Promise.all(Object.entries(r.ops).map(async([o,c])=>{var p,d,h,T,R;if(c.delete){i[o]=await this.delete(c.delete);return}else if(c.fnCall){i[o]=await this.call(c.fnCall.name,c.fnCall.payload);return}let{id:a}=await this.set(c.set);if(!c.get){let A={};A.id=a;let ve=(R=(T=(h=(d=(p=this.client)==null?void 0:p.configuration)==null?void 0:d.schema)==null?void 0:h[r.db])==null?void 0:T.prefixToTypeMapping)==null?void 0:R[a.slice(0,2)];ve&&(A.type=ve),i[o]=A;return}let u=(0,ye.deepCopy)(c.get);u.$id=a;let l=await this.get(u);i[o]=l})),{data:i}}catch(i){return{errors:[{message:i.message,locations:i.locations}]}}}async gqlLive(t,n={}){let r;if(typeof t=="string"?r=this.gql(t):r=t,r=(0,S.handleGraphqlVariables)(r,r,n),r.opType==="GET"){let o=[],c={};for(let a in r.ops){if(r.ops[a].fnObserve){let{name:u,payload:l}=r.ops[a].fnObserve;o.push({key:a,fn:{name:u,payload:l}});continue}c[a]=r.ops[a].get}if(o!=null&&o.length){let a=o.map(l=>({obs:new P(this.client,l.fn.name,l.fn.payload),key:l.key})),u=new P(this.client,Oe({$db:r.db},c));return a.push({key:"",obs:u}),new X(this.client,a)}return new P(this.client,{$db:r.db,data:c})}let i={};return await Promise.all(Object.entries(r.ops).map(async([o,c])=>{if(c.delete){i[o]=await this.delete(c.delete);return}else if(c.fnCall){i[o]=await this.call(c.fnCall.name,c.fnCall.payload);return}let{id:a}=await this.set(c.set),u=(0,ye.deepCopy)(c.get);u.$id=a,i[o]=u})),new P(this.client,{$db:r.db,data:i})}analytics(t,n){return new Promise((r,i)=>{n?E(this.client,t,n,(o,c,a,u,l)=>{o&&!l?i(o):r(()=>{y(this.client,c,a)})},o=>console.error(o),void 0,"analytics"):J(this.client,t,(o,c,a,u)=>{o?i(o):((0,v.isAnalyticsHistoryOpts)(t)||(0,v.isAnalyticsTypesOpts)(t),r(u))},0,"analytics")})}track(t,n){N(this.client,t,n)}clearAnalytics(t,n){N(this.client,t,n,!1,!1,void 0,!0)}untrack(t,n){N(this.client,t,n,!0)}event(t,n,r){N(this.client,t,n,!1,!0,r)}delete(t){return new Promise((n,r)=>{k(this.client,v.RequestTypes.Delete,t,n,r)})}schema(){return new Promise((t,n)=>{let r=i=>{this.client.configuration=i,t(i)};k(this.client,v.RequestTypes.GetConfiguration,0,r,n)})}removeType(t,n="default"){return new Promise((r,i)=>{k(this.client,v.RequestTypes.RemoveType,{type:t,db:n},r,i)})}removeField(t,n,r="default"){return new Promise((i,o)=>{!n||n.length===0?o(new Error("Path cannot be empty")):(Array.isArray(n)||(n=[n]),k(this.client,v.RequestTypes.RemoveField,{type:t,db:r,path:n},i,o))})}updateSchema(t){return new Promise((n,r)=>{k(this.client,v.RequestTypes.Configuration,t,n,r)})}getToken(){return this.client.token}auth(t,n){return new Promise(r=>{this.client.auth.push(r),(t&&t!==this.client.token||t===!1&&this.client.token)&&(typeof t=="string"?w(this.client,t,n):w(this.client),this.emit("auth",t))})}async login(t){return Me(this.client,t)}logout(){return He(this.client)}},mt=(e,s)=>{if(s){let t;e+=/\?/.test(e)?"&":"?";for(let n in s){let r=s[n];e+=t?`&${n}=${r}`:`${n}=${r}`,t=!0}}return e},ht=(e,s=se)=>{let{env:t,project:n,org:r,url:i,key:o,name:c="@based/hub",cluster:a,params:u}=e;if(i||(a=e.cluster=(0,re.getClusterUrl)(a),i=async()=>{let{url:l}=await(0,re.default)({env:t,project:n,org:r,key:o,name:c},0,a);return mt(l,u)}),i){let l=new s;return l.opts=e,l.connect(i),l}},gt=ht;0&&(module.exports={Based,BasedClient,BasedGraphQL,Observable,addGetSubscriber,addRequest,addSubscriber,createGraphqlOperations,generateSubscriptionId,generateTrackingKey,handleGraphqlVariables,parseGraphql,removeSubscriber}); | ||
`),delete e.cache[t],f(e,[X.RequestTypes.SendSubscriptionData,t]);else{c.checksum=r;for(let u in o.subscribers){let l=o.subscribers[u];l.onInitial&&(l.onInitial(null,Number(t),Number(u),c.value),delete l.onInitial,l.onData||y(e,t,Number(u))),l.onData&&l.onData(c.value,c.checksum)}}}}};var Me=(e,s)=>{for(let t of s[1]){delete e.cache[t];let n=e.subscriptions[t];if(n){let i={type:"AuthorizationError",name:n.name?`observe "${n.name}"`:"observe",message:"Unauthorized request",payload:n.query,auth:!0},r=C(i);n.authError={token:e.token,error:r};for(let o in n.subscribers){let c=n.subscribers[o];c.onError&&c.onError(r)}}}};var Ne=require("@based/types");var lt=0,k=(e,s,t,n,i,r,o)=>{let c=++lt;e.requestCallbacks[c]={resolve:n,reject:i,type:s,payload:t,name:r,isRetry:o},s===Ne.RequestTypes.Call?f(e,[s,r,c,t]):f(e,[s,c,t])};var Le=(e,s)=>{let[,t,n,i]=s,r=e.requestCallbacks[t];r&&(delete e.requestCallbacks[t],i?r.reject(C(i)):r.resolve(n))};var O={};qe(O,{BasedClient:()=>D});var g=require("@based/types");var be=require("@based/types");var pt=e=>typeof e!="undefined"&&e!==null,dt=(e,s,t)=>{if(e.beingAuth=!0,s)e.token=s,e.sendTokenOptions=t;else{for(let n in e.cache)e.subscriptions[n]||delete e.cache[n];delete e.token,delete e.sendTokenOptions}if(e.connected){let n=s?[be.RequestTypes.Token,s,t].filter(pt):[be.RequestTypes.Token];e.connection.ws.send(JSON.stringify(n)),J(e),M(e,!0)}},w=dt;var F=require("@based/types");var fe=0,He=(e,s)=>{let t=++fe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.Login,t,s]),new Promise((n,i)=>{e.authCallbacks[t]={resolve:r=>{w(e,r.token,{refreshToken:r.refreshToken}),n(r)},reject:i}})},_e=(e,s)=>{let t=++fe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.RenewToken,t,s]),new Promise((n,i)=>{e.authCallbacks[t]={resolve:r=>{w(e,r.token),n(r)},reject:i}})},ze=(e,s)=>{let[,t,n,i]=s,r=e.authCallbacks[t];r&&(delete e.authCallbacks[t],i?r.reject(C(i)):r.resolve(n))},Je=e=>{let s=++fe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.Logout,s]),new Promise((t,n)=>{e.authCallbacks[s]={resolve:i=>{w(e),t(i)},reject:n}})};d(O,require("@based/types"));var D=class{constructor(s){this.auth=[];this.subscriptions={};this.cache={};this.requestCallbacks={};this.authCallbacks={};this.connected=!1;this.subscriptionQueue=[];this.queue=[];this.drainInProgress=!1;this.based=s}onClose(){this.connected=!1,Qe(this),Ae(this),Ie(this),this.based.listeners.disconnect&&this.based.listeners.disconnect.forEach(s=>s())}onReconnect(){if(this.based.listeners.reconnect&&this.based.listeners.reconnect.forEach(s=>s()),this.tracking)for(let s of this.tracking)f(this,[g.RequestTypes.Track,{t:s}])}onOpen(){this.connected=!0,this.based.listeners.connect&&this.based.listeners.connect.forEach(s=>s()),this.token&&w(this,this.token,this.sendTokenOptions),M(this),le(this)}onData(s){var t,n;try{let i=JSON.parse(s.data),[r,o,c,a,u]=i;if(r===g.RequestTypes.Token){this.retryingRenewToken=!1,o.length&&Me(this,i);for(let l of this.auth)l(!c);this.beingAuth=!1,this.auth=[]}else r===g.RequestTypes.Auth?ze(this,i):(((t=u||a)==null?void 0:t.code)===g.BasedErrorCodes.TokenExpired||((n=u||a)==null?void 0:n.message)==="Token expired")&&!this.retryingRenewToken?(this.retryingRenewToken=!0,_e(this,this.renewOptions).then(l=>{w(this,l.token,this.sendTokenOptions),r===g.RequestTypes.Subscription||r===g.RequestTypes.SubscriptionDiff?M(this):k(this,r,a==null?void 0:a.payload,this.requestCallbacks[o].resolve,this.requestCallbacks[o].reject),this.based.emit("renewToken",l)}).catch(l=>{var p;(p=this.requestCallbacks[o])==null||p.reject(l)})):r===g.RequestTypes.Set||r===g.RequestTypes.Get||r===g.RequestTypes.Configuration||r===g.RequestTypes.GetConfiguration||r===g.RequestTypes.Call||r===g.RequestTypes.Delete||r===g.RequestTypes.Copy||r===g.RequestTypes.Digest||r===g.RequestTypes.RemoveType||r===g.RequestTypes.RemoveField?Le(this,i):r===g.RequestTypes.Subscription?Ge(this,i):r===g.RequestTypes.SubscriptionDiff&&$e(this,i)}catch(i){console.error("Received incorrect data ",s)}}};var me=(e,s)=>{let t;if(e.configuration&&e.configuration.schema)for(let n in e.configuration.schema){let i=e.configuration.schema[n];if(i.prefixToTypeMapping){for(let r in i.prefixToTypeMapping)if(i.prefixToTypeMapping[r]===s){t=r;break}}}return t};var ke=require("@saulx/hash");var We=require("@based/types"),Ve=require("@saulx/hash"),Ke=new Set,bt=e=>{if(typeof window!="undefined"){if(Ke.has(e))return!1;Ke.add(e);try{let s="_ba:"+(0,Ve.hashCompact)(e);return localStorage.getItem(s)?!1:(localStorage.setItem(s,"1"),!0)}catch(s){return!1}}return!1},he=(e,s)=>{if(s){let t=`${e}`,n=Object.keys(s).sort();for(let i of n)t+="_"+i+"_"+s[i];return t}else return e},N=(e,s,t,n,i,r,o)=>{let c=he(s,t),a={t:c};o&&(a.r=1),i&&(a.e=1,r&&(a.o=r)),n?(a.s=1,e.tracking.delete(c)):o||(i||(e.tracking||(e.tracking=new Set),e.tracking.add(c)),bt(c)&&(a.u=1)),f(e,[We.RequestTypes.Track,a])};var ge=class{constructor(s,t,n){this.closed=!1;this.client=s,this.subId=n,this.subscriberId=t}unsubscribe(){this.closed=!0,y(this.client,this.subId,this.subscriberId)}},ye=class{constructor(s,t){this.closed=!1;this.client=s,this.subs=t}unsubscribe(){if(!this.closed){this.closed=!0;for(let s of this.subs)s.unsubscribe()}}},Y=class{constructor(s,t){this.client=s,this.components=t}subscribe(s,t,n){let i={data:{}},r=[];for(let{key:o,obs:c}of this.components){let a=c.subscribe(u=>{if(o===""){Object.assign(i.data,u),s(i);return}i.data[o]=u,s(i)},t);r.push(a)}return new ye(this.client,r)}},P=class{constructor(s,t,n){this.client=s,this.subId=typeof t=="string"?q(n,t):q(t),this.name=typeof t=="string"?t:null,this.payload=typeof t=="string"?n:t}subscribe(s,t,n){let[,i]=E(this.client,this.payload,s,r=>{r&&(console.error(r),t&&t(r))},t,this.subId,this.name);return new ge(this.client,i,this.subId)}};var ve={},L={},ft=(e,s)=>{ve[e]||(ve[e]=!0,setTimeout(()=>{console.info("Drain file q"),ve[e]=!1;let t=L[e];L[e]=[];let n=new global.FormData;for(let i of t){let{raw:r,name:o,id:c,file:a,functionName:u}=i,l=`${u||""}|${r?1:0}|${c}|${a.size}${o?`|${o}`:""}`;n.append(l,a)}try{let i=new global.XMLHttpRequest;i.upload.onprogress=r=>{let o=100*(r.loaded||r.position)/(r.totalSize||r.total);console.info(o,"upload...")},i.onerror=r=>{console.error("error!",r,"flap",i.responseText)},i.timeout=1e3*60*60*24,i.onabort=r=>{console.error("abort",r)},i.ontimeout=r=>{console.error("on timeout",r)},i.onload=()=>{let r={};try{r=JSON.parse(i.response),console.info("SUCCESS",r)}catch(o){console.error("something wrong with file upload",o)}},i.open("POST",e+"/file"),i.setRequestHeader("Content-Type","multipart/form-data"),i.setRequestHeader("Authorization",s),i.send(n)}catch(i){console.error("Something wrong with xhr upload",i)}},500))},Xe=async(e,s,t,n,i,r,o)=>{L[t]||(L[t]=[]),L[t].push({file:s,id:n,url:t,raw:i,name:r,functionName:o}),ft(t,e.getToken())};var Ye=z(require("@based/get-service")),Z={},ee={},mt=async(e,s)=>{if(s.url)return typeof s.url=="string"?s.url:await s.url();if(!e.opts.env&&e.opts.url)return typeof e.opts.url=="string"?e.opts.url:await e.opts.url();let{env:t,project:n,org:i}=e.opts,r=t+"/"+n+"/"+i+"/"+e.opts.cluster;if(Z[r])return Z[r];if(ee[r])return(await ee[r]).url;let o=await(ee[r]=(0,Ye.default)({env:t,project:n,org:i,name:"@based/hub",key:"file-upload",optionalKey:!0},0,e.opts.cluster));return delete ee[r],setTimeout(()=>{delete Z[r]},2e3),Z[r]=o.url},Ze=mt;var et=z(require("cross-fetch")),te=(e,s,t)=>((0,et.default)(s,{method:"POST",cache:"no-cache",headers:{"Content-Type":t.mimeType||"text/plain","File-Id":t.id,"File-Is-Raw":t.raw?"1":"0","File-Name":t.name||"","Function-Name":t.functionName||"",Authorization:e.getToken()},body:t.contents}).then(n=>{}).catch(n=>{console.error("Error while uploading file",n)}),{id:t.id});var I=require("./file/stream"),se=typeof window!="undefined",ht=e=>"src"in e&&typeof e.src=="string",gt=e=>"path"in e&&typeof e.path=="string",yt=e=>"contents"in e&&(0,I.isStream)(e.contents),tt=async(e,s)=>{if(ht(s)){let i=s.id?{$id:s.id}:{type:"file"};return s.src?(i.src=s.src,i.origin=s.src,s.size&&(i.size=s.size),s.name&&(i.name=s.name),s.parents&&(i.parents=s.parents),await e.set(i)):void 0}let t=s.id;if(!t){let i={type:"file",progress:0};s.name?i.name=s.name:global.File&&"contents"in s&&s.contents instanceof global.File&&(i.name=s.contents.name),s.parents&&(i.parents=s.parents),t=(await e.set(i)).id}s.id=t;let n=(await Ze(e,s)).replace(/^ws/,"http");if(gt(s))return(0,I.uploadFilePath)(e,n,s),{id:t};if(yt(s))return(0,I.uploadFileStream)(e,n,s),{id:t};if(s.contents instanceof ArrayBuffer)return s.contents=se?new global.Blob([s.contents],{type:s.mimeType||"text/plain"}):global.Buffer.from(s.contents),te(e,n+"/file",s);if(se&&s.contents instanceof global.Blob)return s.mimeType||(s.mimeType=s.contents.type),te(e,n+"/file",s);if(typeof s.contents=="string"||!se&&s.contents instanceof global.Buffer)return te(e,n+"/file",s);if(se&&s.contents instanceof File)return Xe(e,s.contents,n,s.id,s.raw||!1,s.name,s.functionName),{id:t};throw s.id||await e.delete({$id:t}),new Error(`Invalid contents for file api ${JSON.stringify(s,null,2)}`)};var ie=z(require("@based/get-service")),Se=require("@saulx/utils"),S=require("@based/graphql");d(m,require("@based/types"),module.exports);var re=class extends Be{constructor(t){super();this.client=new D(this),Object.defineProperty(this,"client",{enumerable:!1,writable:!0}),t&&t.url&&this.connect(t.url),this.graphql={query:this.gqlQuery.bind(this),live:this.gqlLive.bind(this)}}connect(t){!t&&this._url?this.client.connection||(this.client.connection=ue(this.client,this._url)):(this._url=t,this.client.connection=ue(this.client,t))}disconnect(){this.client.connection&&(this.client.connection.disconnected=!0,this.client.connection.destroy(),this.client.connection.ws&&this.client.connection.ws.close(),this.client.connected&&this.client.onClose(),delete this.client.connection),this.client.connected=!1}observeUntil(t,n,i){return new Promise((r,o)=>{let c,a=!1;this.observe(t,(u,l)=>{i&&i(u,l),n(u,l)&&(a=!0,c&&c(),r(u))}).then(u=>{a?c():c=u}).catch(u=>{o(u)})})}gql(t,...n){typeof t=="string"&&(t=[t]);let i=t[0];return n.forEach((r,o)=>{r&&r.kind==="Document"?i+=r.loc.source.body:i+=r,i+=t[o+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema},(0,S.parseGraphql)(i))}gqlDb(t="default"){return(n,...i)=>{typeof n=="string"&&(n=[n]);let r=n[0];return i.forEach((o,c)=>{o&&o.kind==="Document"?r+=o.loc.source.body:r+=o,r+=n[c+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema,db:t},(0,S.parseGraphql)(r))}}observe(t,n,i,r){return typeof t=="string"?new Promise((o,c)=>{let a=typeof n=="function",u=a?n:i,l=a?i:r;E(this.client,a?void 0:n,u,(p,b,h,T,R)=>{p&&!R?c(p):o(()=>{y(this.client,b,h)})},l,void 0,t)}):new Promise((o,c)=>{E(this.client,t,n,(a,u,l,p,b)=>{a&&!b?c(a):o(()=>{y(this.client,u,l)})},i)})}createObservable(t,n){return typeof t=="string"?new P(this.client,t,n):new P(this.client,t)}observeSchema(t,n,i){return new Promise((r,o)=>{let c=typeof t=="string"?t:"default",a=typeof t=="string"?n:t,u=typeof t=="string"?i:n;E(this.client,{$subscribe_schema:c},(l,p)=>{this.client.configuration||(this.client.configuration={dbs:[],schema:{},functions:{}}),this.client.configuration.schema[c]=l,a(l,p)},(l,p,b,h,T)=>{l&&!T?o(l):r(()=>{y(this.client,p,b)})},u)})}get(t,n){return typeof t=="string"?new Promise((i,r)=>{K(this.client,n,(o,c,a,u)=>{o?r(o):i(u)},0,t)}):new Promise((i,r)=>{k(this.client,v.RequestTypes.Get,t,i,r)})}file(t){return global.File&&t instanceof File&&(t={contents:t}),tt(this,t)}call(t,n){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Call,n,i,r,t)})}async id(t,n){let i=me(this.client,t);if(i||(await this.schema(),i=me(this.client,t)),!i)throw C({message:`Type does not exist ${t}`,type:"Invalid type",payload:n?{type:t,opts:n}:{type:t}});if(n){let r=(0,ke.hashCompact)(n,8,!0);return i+r}else return i+(0,ke.hashCompact)(Math.floor(Math.random()*99999999999)+""+Date.now())}digest(t){return new Promise((n,i)=>{k(this.client,v.RequestTypes.Digest,t,n,i)})}set(t){return new Promise((n,i)=>{k(this.client,v.RequestTypes.Set,t,n,i)})}copy(t){return new Promise((n,i)=>{k(this.client,v.RequestTypes.Copy,t,n,i)})}async gqlQuery(t,n={}){let i;typeof t=="string"?i=this.gql(t):i=t;try{if(i=(0,S.handleGraphqlVariables)(i,i,n),i.opType==="GET"){let o={$db:i.db},c=[];for(let u in i.ops){if(i.ops[u].fnObserve){let l=await this.get(i.ops[u].fnObserve.name,i.ops[u].fnObserve.payload);c.push({key:u,reply:l});continue}i.ops[u].get&&(o[u]=i.ops[u].get)}let a=await this.get(o);for(let{key:u,reply:l}of c)a[u]=l;return{data:a}}let r={};return await Promise.all(Object.entries(i.ops).map(async([o,c])=>{var p,b,h,T,R;if(c.delete){r[o]=await this.delete(c.delete);return}else if(c.fnCall){r[o]=await this.call(c.fnCall.name,c.fnCall.payload);return}let{id:a}=await this.set(c.set);if(!c.get){let A={};A.id=a;let Te=(R=(T=(h=(b=(p=this.client)==null?void 0:p.configuration)==null?void 0:b.schema)==null?void 0:h[i.db])==null?void 0:T.prefixToTypeMapping)==null?void 0:R[a.slice(0,2)];Te&&(A.type=Te),r[o]=A;return}let u=(0,Se.deepCopy)(c.get);u.$id=a;let l=await this.get(u);r[o]=l})),{data:r}}catch(r){return{errors:[{message:r.message,locations:r.locations}]}}}async gqlLive(t,n={}){let i;if(typeof t=="string"?i=this.gql(t):i=t,i=(0,S.handleGraphqlVariables)(i,i,n),i.opType==="GET"){let o=[],c={};for(let a in i.ops){if(i.ops[a].fnObserve){let{name:u,payload:l}=i.ops[a].fnObserve;o.push({key:a,fn:{name:u,payload:l}});continue}c[a]=i.ops[a].get}if(o!=null&&o.length){let a=o.map(l=>({obs:new P(this.client,l.fn.name,l.fn.payload),key:l.key})),u=new P(this.client,oe({$db:i.db},c));return a.push({key:"",obs:u}),new Y(this.client,a)}return new P(this.client,{$db:i.db,data:c})}let r={};return await Promise.all(Object.entries(i.ops).map(async([o,c])=>{if(c.delete){r[o]=await this.delete(c.delete);return}else if(c.fnCall){r[o]=await this.call(c.fnCall.name,c.fnCall.payload);return}let{id:a}=await this.set(c.set),u=(0,Se.deepCopy)(c.get);u.$id=a,r[o]=u})),new P(this.client,{$db:i.db,data:r})}analytics(t,n){return new Promise((i,r)=>{n?E(this.client,t,n,(o,c,a,u,l)=>{o&&!l?r(o):i(()=>{y(this.client,c,a)})},o=>console.error(o),void 0,"analytics"):K(this.client,t,(o,c,a,u)=>{o?r(o):((0,v.isAnalyticsHistoryOpts)(t)||(0,v.isAnalyticsTypesOpts)(t),i(u))},0,"analytics")})}track(t,n){N(this.client,t,n)}clearAnalytics(t,n){N(this.client,t,n,!1,!1,void 0,!0)}untrack(t,n){N(this.client,t,n,!0)}event(t,n,i){N(this.client,t,n,!1,!0,i)}delete(t){return new Promise((n,i)=>{k(this.client,v.RequestTypes.Delete,t,n,i)})}schema(){return new Promise((t,n)=>{let i=r=>{this.client.configuration=r,t(r)};k(this.client,v.RequestTypes.GetConfiguration,0,i,n)})}removeType(t,n="default"){return new Promise((i,r)=>{k(this.client,v.RequestTypes.RemoveType,{type:t,db:n},i,r)})}removeField(t,n,i="default"){return new Promise((r,o)=>{!n||n.length===0?o(new Error("Path cannot be empty")):(Array.isArray(n)||(n=[n]),k(this.client,v.RequestTypes.RemoveField,{type:t,db:i,path:n},r,o))})}updateSchema(t){return new Promise((n,i)=>{k(this.client,v.RequestTypes.Configuration,t,n,i)})}getToken(){return this.client.token}auth(t,n){return new Promise(i=>{if(this.client.auth.push(i),t&&t!==this.client.token||t===!1&&this.client.token){if(typeof t=="string"){let r=n||{},{renewOptions:o,refreshToken:c}=r,a=Pe(r,["renewOptions","refreshToken"]);o&&(this.client.renewOptions=o),c&&(this.client.renewOptions=we(oe({},this.client.renewOptions),{refreshToken:c})),w(this.client,t,a)}else w(this.client);this.emit("auth",t)}})}async login(t){return He(this.client,t)}logout(){return Je(this.client)}},vt=(e,s)=>{if(s){let t;e+=/\?/.test(e)?"&":"?";for(let n in s){let i=s[n];e+=t?`&${n}=${i}`:`${n}=${i}`,t=!0}}return e},kt=(e,s=re)=>{let{env:t,project:n,org:i,url:r,key:o,name:c="@based/hub",cluster:a,params:u}=e;if(r||(a=e.cluster=(0,ie.getClusterUrl)(a),r=async()=>{let{url:l}=await(0,ie.default)({env:t,project:n,org:i,key:o,name:c},0,a);return vt(l,u)}),r){let l=new s;return l.opts=e,l.connect(r),l}},St=kt;0&&(module.exports={Based,BasedClient,BasedGraphQL,Observable,addGetSubscriber,addRequest,addSubscriber,createGraphqlOperations,generateSubscriptionId,generateTrackingKey,handleGraphqlVariables,parseGraphql,removeSubscriber}); |
{ | ||
"name": "@based/client", | ||
"version": "2.7.3", | ||
"version": "2.7.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
261723
2559