@based/client 2.6.1 → 2.7.0
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/dist/Client.d.ts +0 -0
- package/dist/Client.js +2 -3
- package/dist/Client.js.map +1 -1
- package/dist/Emitter.d.ts +0 -0
- package/dist/Emitter.js +0 -0
- package/dist/Emitter.js.map +0 -0
- package/dist/auth.d.ts +0 -0
- package/dist/auth.js +0 -0
- package/dist/auth.js.map +0 -0
- package/dist/createError.d.ts +0 -0
- package/dist/createError.js +0 -0
- package/dist/createError.js.map +0 -0
- package/dist/file/fetch.d.ts +0 -0
- package/dist/file/fetch.js +0 -0
- package/dist/file/fetch.js.map +0 -0
- package/dist/file/getUrl.d.ts +0 -0
- package/dist/file/getUrl.js +0 -0
- package/dist/file/getUrl.js.map +0 -0
- package/dist/file/index.d.ts +0 -0
- package/dist/file/index.js +0 -0
- package/dist/file/index.js.map +0 -0
- package/dist/file/stream/browser.d.ts +0 -0
- package/dist/file/stream/browser.js +0 -0
- package/dist/file/stream/browser.js.map +0 -0
- package/dist/file/stream/index.d.ts +0 -0
- package/dist/file/stream/index.js +0 -0
- package/dist/file/stream/index.js.map +0 -0
- package/dist/file/uploadFileBrowser.d.ts +0 -0
- package/dist/file/uploadFileBrowser.js +0 -0
- package/dist/file/uploadFileBrowser.js.map +0 -0
- package/dist/findPrefix.d.ts +0 -0
- package/dist/findPrefix.js +0 -0
- package/dist/findPrefix.js.map +0 -0
- package/dist/idleTimeout.d.ts +0 -0
- package/dist/idleTimeout.js +0 -0
- package/dist/idleTimeout.js.map +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +0 -0
- package/dist/observable/index.d.ts +0 -0
- package/dist/observable/index.js +0 -0
- package/dist/observable/index.js.map +0 -0
- package/dist/printBasedObject.d.ts +0 -0
- package/dist/printBasedObject.js +0 -0
- package/dist/printBasedObject.js.map +0 -0
- package/dist/queue.d.ts +0 -0
- package/dist/queue.js +0 -0
- package/dist/queue.js.map +0 -0
- package/dist/request.d.ts +0 -0
- package/dist/request.js +0 -0
- package/dist/request.js.map +0 -0
- package/dist/selvaTypes/get.d.ts +0 -0
- package/dist/selvaTypes/get.js +0 -0
- package/dist/selvaTypes/get.js.map +0 -0
- package/dist/selvaTypes/schema.d.ts +0 -0
- package/dist/selvaTypes/schema.js +0 -0
- package/dist/selvaTypes/schema.js.map +0 -0
- package/dist/selvaTypes/set.d.ts +0 -0
- package/dist/selvaTypes/set.js +0 -0
- package/dist/selvaTypes/set.js.map +0 -0
- package/dist/subscriptions/addGetSubscriber.d.ts +0 -0
- package/dist/subscriptions/addGetSubscriber.js +0 -0
- package/dist/subscriptions/addGetSubscriber.js.map +0 -0
- package/dist/subscriptions/addSubscriber.d.ts +0 -0
- package/dist/subscriptions/addSubscriber.js +0 -0
- package/dist/subscriptions/addSubscriber.js.map +0 -0
- package/dist/subscriptions/generateId.d.ts +0 -0
- package/dist/subscriptions/generateId.js +0 -0
- package/dist/subscriptions/generateId.js.map +0 -0
- package/dist/subscriptions/incomingSubscription.d.ts +0 -0
- package/dist/subscriptions/incomingSubscription.js +0 -0
- package/dist/subscriptions/incomingSubscription.js.map +0 -0
- package/dist/subscriptions/incomingSubscriptionDiff.d.ts +0 -0
- package/dist/subscriptions/incomingSubscriptionDiff.js +0 -0
- package/dist/subscriptions/incomingSubscriptionDiff.js.map +0 -0
- package/dist/subscriptions/index.d.ts +0 -0
- package/dist/subscriptions/index.js +0 -0
- package/dist/subscriptions/index.js.map +0 -0
- package/dist/subscriptions/logoutSubscriptions.d.ts +0 -0
- package/dist/subscriptions/logoutSubscriptions.js +0 -0
- package/dist/subscriptions/logoutSubscriptions.js.map +0 -0
- package/dist/subscriptions/removeSendSubscriptionDataFromQueue.d.ts +0 -0
- package/dist/subscriptions/removeSendSubscriptionDataFromQueue.js +0 -0
- package/dist/subscriptions/removeSendSubscriptionDataFromQueue.js.map +0 -0
- package/dist/subscriptions/removeSubscriber.d.ts +0 -0
- package/dist/subscriptions/removeSubscriber.js +0 -0
- package/dist/subscriptions/removeSubscriber.js.map +0 -0
- package/dist/subscriptions/removeUnsubscribesFromQueue.d.ts +0 -0
- package/dist/subscriptions/removeUnsubscribesFromQueue.js +0 -0
- package/dist/subscriptions/removeUnsubscribesFromQueue.js.map +0 -0
- package/dist/subscriptions/sendAllSubscriptions.d.ts +0 -0
- package/dist/subscriptions/sendAllSubscriptions.js +0 -0
- package/dist/subscriptions/sendAllSubscriptions.js.map +0 -0
- package/dist/token.d.ts +0 -0
- package/dist/token.js +0 -0
- package/dist/token.js.map +0 -0
- package/dist/track.d.ts +0 -0
- package/dist/track.js +0 -0
- package/dist/track.js.map +0 -0
- package/dist/websocket/index.d.ts +0 -0
- package/dist/websocket/index.js +0 -0
- package/dist/websocket/index.js.map +0 -0
- package/dist/websocket/types.d.ts +0 -0
- package/dist/websocket/types.js +0 -0
- package/dist/websocket/types.js.map +0 -0
- package/dist/websocket/urlLoader.d.ts +0 -0
- package/dist/websocket/urlLoader.js +0 -0
- package/dist/websocket/urlLoader.js.map +0 -0
- package/package.json +1 -2
- package/dist/types.d.ts +0 -253
- package/dist/types.js +0 -58
- package/dist/types.js.map +0 -1
package/dist/Client.d.ts
CHANGED
|
File without changes
|
package/dist/Client.js
CHANGED
|
@@ -24,7 +24,6 @@ const queue_1 = require("./queue");
|
|
|
24
24
|
const request_1 = require("./request");
|
|
25
25
|
const token_1 = __importDefault(require("./token"));
|
|
26
26
|
const auth_1 = require("./auth");
|
|
27
|
-
const auth_2 = require("./auth");
|
|
28
27
|
__exportStar(require("@based/types"), exports);
|
|
29
28
|
class BasedClient {
|
|
30
29
|
constructor(based) {
|
|
@@ -95,7 +94,7 @@ class BasedClient {
|
|
|
95
94
|
!this.retryingRenewToken) {
|
|
96
95
|
this.retryingRenewToken = true;
|
|
97
96
|
const refreshToken = this.sendTokenOptions?.refreshToken;
|
|
98
|
-
(0,
|
|
97
|
+
(0, auth_1.renewToken)(this, {
|
|
99
98
|
refreshToken,
|
|
100
99
|
})
|
|
101
100
|
.then((result) => {
|
|
@@ -131,10 +130,10 @@ class BasedClient {
|
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
catch (err) {
|
|
133
|
+
console.log(err);
|
|
134
134
|
console.error('Received incorrect data ', d);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
exports.BasedClient = BasedClient;
|
|
139
|
-
console.log('???');
|
|
140
139
|
//# sourceMappingURL=Client.js.map
|
package/dist/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,wCAcqB;AACrB,mDAOwB;AAExB,mCAAgE;AAChE,uCAAuD;AACvD,oDAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":"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"}
|
package/dist/Emitter.d.ts
CHANGED
|
File without changes
|
package/dist/Emitter.js
CHANGED
|
File without changes
|
package/dist/Emitter.js.map
CHANGED
|
File without changes
|
package/dist/auth.d.ts
CHANGED
|
File without changes
|
package/dist/auth.js
CHANGED
|
File without changes
|
package/dist/auth.js.map
CHANGED
|
File without changes
|
package/dist/createError.d.ts
CHANGED
|
File without changes
|
package/dist/createError.js
CHANGED
|
File without changes
|
package/dist/createError.js.map
CHANGED
|
File without changes
|
package/dist/file/fetch.d.ts
CHANGED
|
File without changes
|
package/dist/file/fetch.js
CHANGED
|
File without changes
|
package/dist/file/fetch.js.map
CHANGED
|
File without changes
|
package/dist/file/getUrl.d.ts
CHANGED
|
File without changes
|
package/dist/file/getUrl.js
CHANGED
|
File without changes
|
package/dist/file/getUrl.js.map
CHANGED
|
File without changes
|
package/dist/file/index.d.ts
CHANGED
|
File without changes
|
package/dist/file/index.js
CHANGED
|
File without changes
|
package/dist/file/index.js.map
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/findPrefix.d.ts
CHANGED
|
File without changes
|
package/dist/findPrefix.js
CHANGED
|
File without changes
|
package/dist/findPrefix.js.map
CHANGED
|
File without changes
|
package/dist/idleTimeout.d.ts
CHANGED
|
File without changes
|
package/dist/idleTimeout.js
CHANGED
|
File without changes
|
package/dist/idleTimeout.js.map
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -12,4 +12,4 @@ Found corrupt data while applying diff to subscription need to re-fetch
|
|
|
12
12
|
`),console.warn(W(o.query,2,!1,"Query").join(`
|
|
13
13
|
`)+`
|
|
14
14
|
|
|
15
|
-
`),delete e.cache[t],f(e,[V.RequestTypes.SendSubscriptionData,t]);else{c.checksum=n;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 i=e.subscriptions[t];if(i){let r={type:"AuthorizationError",name:i.name?`observe "${i.name}"`:"observe",message:"Unauthorized request",payload:i.query,auth:!0},n=C(r);i.authError={token:e.token,error:n};for(let o in i.subscribers){let c=i.subscribers[o];c.onError&&c.onError(n)}}}};var je=require("@based/types");var ot=0,k=(e,s,t,i,r,n,o)=>{let c=++ot;e.requestCallbacks[c]={resolve:i,reject:r,type:s,payload:t,name:n,isRetry:o},s===je.RequestTypes.Call?f(e,[s,n,c,t]):f(e,[s,c,t])};var $e=(e,s)=>{let[,t,i,r]=s,n=e.requestCallbacks[t];n&&(delete e.requestCallbacks[t],r?n.reject(C(r)):n.resolve(i))};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 i in e.cache)e.subscriptions[i]||delete e.cache[i];delete e.token,delete e.sendTokenOptions}if(e.connected){let i=s?[le.RequestTypes.Token,s,t].filter(at):[le.RequestTypes.Token];e.connection.ws.send(JSON.stringify(i)),_(e),J(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((i,r)=>{e.authCallbacks[t]={resolve:n=>{w(e,n.token,{refreshToken:n.refreshToken}),i(n)},reject:r}})},Ne=(e,s)=>{let t=++pe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.RenewToken,t,s]),new Promise((i,r)=>{e.authCallbacks[t]={resolve:n=>{w(e,n.token),i(n)},reject:r}})},Le=(e,s)=>{let[,t,i,r]=s,n=e.authCallbacks[t];n&&(delete e.authCallbacks[t],r?n.reject(C(r)):n.resolve(i))},He=e=>{let s=++pe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.Logout,s]),new Promise((t,i)=>{e.authCallbacks[s]={resolve:r=>{w(e),t(r)},reject:i}})};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,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),J(this),ae(this)}onData(s){var t;try{let i=JSON.parse(s.data),[r,n,o,c]=i;if(r===g.RequestTypes.Token){this.retryingRenewToken=!1,n.length&&Ge(this,i);for(let a of this.auth)a(!o);this.beingAuth=!1,this.auth=[]}else if(r===g.RequestTypes.Auth)Le(this,i);else if((c==null?void 0:c.code)===g.BasedErrorCodes.TokenExpired&&!this.retryingRenewToken){this.retryingRenewToken=!0;let a=(t=this.sendTokenOptions)==null?void 0:t.refreshToken;Ne(this,{refreshToken:a}).then(u=>{w(this,u.token,this.sendTokenOptions),k(this,r,c==null?void 0:c.payload,this.requestCallbacks[n].resolve,this.requestCallbacks[n].reject)}).catch(u=>{this.requestCallbacks[n].reject(u)})}else 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?$e(this,i):r===g.RequestTypes.Subscription?De(this,i):r===g.RequestTypes.SubscriptionDiff&&Ue(this,i)}catch(i){console.error("Received incorrect data ",s)}}};console.log("???");var de=(e,s)=>{let t;if(e.configuration&&e.configuration.schema)for(let i in e.configuration.schema){let r=e.configuration.schema[i];if(r.prefixToTypeMapping){for(let n in r.prefixToTypeMapping)if(r.prefixToTypeMapping[n]===s){t=n;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}`,i=Object.keys(s).sort();for(let r of i)t+="_"+r+"_"+s[r];return t}else return e},M=(e,s,t,i,r,n,o)=>{let c=be(s,t),a={t:c};o&&(a.r=1),r&&(a.e=1,n&&(a.o=n)),i?(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,i){this.closed=!1;this.client=s,this.subId=i,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,i){let r={data:{}},n=[];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);n.push(a)}return new me(this.client,n)}},P=class{constructor(s,t,i){this.client=s,this.subId=typeof t=="string"?q(i,t):q(t),this.name=typeof t=="string"?t:null,this.payload=typeof t=="string"?i:t}subscribe(s,t,i){let[,r]=E(this.client,this.payload,s,n=>{n&&(console.error(n),t&&t(n))},t,this.subId,this.name);return new fe(this.client,r,this.subId)}};var he={},N={},lt=(e,s)=>{he[e]||(he[e]=!0,setTimeout(()=>{console.info("Drain file q"),he[e]=!1;let t=N[e];N[e]=[];let i=new global.FormData;for(let r of t){let{raw:n,name:o,id:c,file:a,functionName:u}=r,l=`${u||""}|${n?1:0}|${c}|${a.size}${o?`|${o}`:""}`;i.append(l,a)}try{let r=new global.XMLHttpRequest;r.upload.onprogress=n=>{let o=100*(n.loaded||n.position)/(n.totalSize||n.total);console.info(o,"upload...")},r.onerror=n=>{console.error("error!",n,"flap",r.responseText)},r.timeout=1e3*60*60*24,r.onabort=n=>{console.error("abort",n)},r.ontimeout=n=>{console.error("on timeout",n)},r.onload=()=>{let n={};try{n=JSON.parse(r.response),console.info("SUCCESS",n)}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(i)}catch(r){console.error("Something wrong with xhr upload",r)}},500))},Ke=async(e,s,t,i,r,n,o)=>{N[t]||(N[t]=[]),N[t].push({file:s,id:i,url:t,raw:r,name:n,functionName:o}),lt(t,e.getToken())};var We=H(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:i,org:r}=e.opts,n=t+"/"+i+"/"+r+"/"+e.opts.cluster;if(Y[n])return Y[n];if(Z[n])return(await Z[n]).url;let o=await(Z[n]=(0,We.default)({env:t,project:i,org:r,name:"@based/hub",key:"file-upload",optionalKey:!0},0,e.opts.cluster));return delete Z[n],setTimeout(()=>{delete Y[n]},2e3),Y[n]=o.url},Ve=pt;var Xe=H(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(i=>{}).catch(i=>{console.error("Error while uploading file",i)}),{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 i=(await Ve(e,s)).replace(/^ws/,"http");if(bt(s))return(0,I.uploadFilePath)(e,i,s),{id:t};if(ft(s))return(0,I.uploadFileStream)(e,i,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,i+"/file",s);if(te&&s.contents instanceof global.Blob)return s.mimeType||(s.mimeType=s.contents.type),ee(e,i+"/file",s);if(typeof s.contents=="string"||!te&&s.contents instanceof global.Buffer)return ee(e,i+"/file",s);if(te&&s.contents instanceof File)return Ke(e,s.contents,i,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=H(require("@based/get-service")),ye=require("@saulx/utils"),S=require("@based/graphql");d(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,i,r){return new Promise((n,o)=>{let c,a=!1;this.observe(t,(u,l)=>{r&&r(u,l),i(u,l)&&(a=!0,c&&c(),n(u))}).then(u=>{a?c():c=u}).catch(u=>{o(u)})})}gql(t,...i){typeof t=="string"&&(t=[t]);let r=t[0];return i.forEach((n,o)=>{n&&n.kind==="Document"?r+=n.loc.source.body:r+=n,r+=t[o+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema},(0,S.parseGraphql)(r))}gqlDb(t="default"){return(i,...r)=>{typeof i=="string"&&(i=[i]);let n=i[0];return r.forEach((o,c)=>{o&&o.kind==="Document"?n+=o.loc.source.body:n+=o,n+=i[c+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema,db:t},(0,S.parseGraphql)(n))}}observe(t,i,r,n){return typeof t=="string"?new Promise((o,c)=>{let a=typeof i=="function",u=a?i:r,l=a?r:n;E(this.client,a?void 0:i,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,i,(a,u,l,p,b)=>{a&&!b?c(a):o(()=>{y(this.client,u,l)})},r)})}createObservable(t,i){return typeof t=="string"?new P(this.client,t,i):new P(this.client,t)}observeSchema(t,i,r){return new Promise((n,o)=>{let c=typeof t=="string"?t:"default",a=typeof t=="string"?i:t,u=typeof t=="string"?r:i;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):n(()=>{y(this.client,p,b)})},u)})}get(t,i){return typeof t=="string"?new Promise((r,n)=>{z(this.client,i,(o,c,a,u)=>{o?n(o):r(u)},0,t)}):new Promise((r,n)=>{k(this.client,v.RequestTypes.Get,t,r,n)})}file(t){return global.File&&t instanceof File&&(t={contents:t}),Ye(this,t)}call(t,i){return new Promise((r,n)=>{k(this.client,v.RequestTypes.Call,i,r,n,t)})}async id(t,i){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:i?{type:t,opts:i}:{type:t}});if(i){let n=(0,ge.hashCompact)(i,8,!0);return r+n}else return r+(0,ge.hashCompact)(Math.floor(Math.random()*99999999999)+""+Date.now())}digest(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Digest,t,i,r)})}set(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Set,t,i,r)})}copy(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Copy,t,i,r)})}async gqlQuery(t,i={}){let r;typeof t=="string"?r=this.gql(t):r=t;try{if(r=(0,S.handleGraphqlVariables)(r,r,i),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 n={};return await Promise.all(Object.entries(r.ops).map(async([o,c])=>{var p,b,h,T,R;if(c.delete){n[o]=await this.delete(c.delete);return}else if(c.fnCall){n[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=(b=(p=this.client)==null?void 0:p.configuration)==null?void 0:b.schema)==null?void 0:h[r.db])==null?void 0:T.prefixToTypeMapping)==null?void 0:R[a.slice(0,2)];ve&&(A.type=ve),n[o]=A;return}let u=(0,ye.deepCopy)(c.get);u.$id=a;let l=await this.get(u);n[o]=l})),{data:n}}catch(n){return{errors:[{message:n.message,locations:n.locations}]}}}async gqlLive(t,i={}){let r;if(typeof t=="string"?r=this.gql(t):r=t,r=(0,S.handleGraphqlVariables)(r,r,i),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 n={};return await Promise.all(Object.entries(r.ops).map(async([o,c])=>{if(c.delete){n[o]=await this.delete(c.delete);return}else if(c.fnCall){n[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,n[o]=u})),new P(this.client,{$db:r.db,data:n})}analytics(t,i){return new Promise((r,n)=>{i?E(this.client,t,i,(o,c,a,u,l)=>{o&&!l?n(o):r(()=>{y(this.client,c,a)})},o=>console.error(o),void 0,"analytics"):z(this.client,t,(o,c,a,u)=>{o?n(o):((0,v.isAnalyticsHistoryOpts)(t)||(0,v.isAnalyticsTypesOpts)(t),r(u))},0,"analytics")})}track(t,i){M(this.client,t,i)}clearAnalytics(t,i){M(this.client,t,i,!1,!1,void 0,!0)}untrack(t,i){M(this.client,t,i,!0)}event(t,i,r){M(this.client,t,i,!1,!0,r)}delete(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Delete,t,i,r)})}schema(){return new Promise((t,i)=>{let r=n=>{this.client.configuration=n,t(n)};k(this.client,v.RequestTypes.GetConfiguration,0,r,i)})}removeType(t,i="default"){return new Promise((r,n)=>{k(this.client,v.RequestTypes.RemoveType,{type:t,db:i},r,n)})}removeField(t,i,r="default"){return new Promise((n,o)=>{!i||i.length===0?o(new Error("Path cannot be empty")):(Array.isArray(i)||(i=[i]),k(this.client,v.RequestTypes.RemoveField,{type:t,db:r,path:i},n,o))})}updateSchema(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Configuration,t,i,r)})}getToken(){return this.client.token}auth(t,i){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,i):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 i in s){let r=s[i];e+=t?`&${i}=${r}`:`${i}=${r}`,t=!0}}return e},ht=(e,s=se)=>{let{env:t,project:i,org:r,url:n,key:o,name:c="@based/hub",cluster:a,params:u}=e;if(n||(a=e.cluster=(0,re.getClusterUrl)(a),n=async()=>{let{url:l}=await(0,re.default)({env:t,project:i,org:r,key:o,name:c},0,a);return mt(l,u)}),n){let l=new s;return l.opts=e,l.connect(n),l}},gt=ht;0&&(module.exports={Based,BasedClient,BasedGraphQL,Observable,addGetSubscriber,addRequest,addSubscriber,createGraphqlOperations,generateSubscriptionId,generateTrackingKey,handleGraphqlVariables,parseGraphql,removeSubscriber});
|
|
15
|
+
`),delete e.cache[t],f(e,[V.RequestTypes.SendSubscriptionData,t]);else{c.checksum=n;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 i=e.subscriptions[t];if(i){let r={type:"AuthorizationError",name:i.name?`observe "${i.name}"`:"observe",message:"Unauthorized request",payload:i.query,auth:!0},n=C(r);i.authError={token:e.token,error:n};for(let o in i.subscribers){let c=i.subscribers[o];c.onError&&c.onError(n)}}}};var je=require("@based/types");var ot=0,k=(e,s,t,i,r,n,o)=>{let c=++ot;e.requestCallbacks[c]={resolve:i,reject:r,type:s,payload:t,name:n,isRetry:o},s===je.RequestTypes.Call?f(e,[s,n,c,t]):f(e,[s,c,t])};var $e=(e,s)=>{let[,t,i,r]=s,n=e.requestCallbacks[t];n&&(delete e.requestCallbacks[t],r?n.reject(C(r)):n.resolve(i))};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 i in e.cache)e.subscriptions[i]||delete e.cache[i];delete e.token,delete e.sendTokenOptions}if(e.connected){let i=s?[le.RequestTypes.Token,s,t].filter(at):[le.RequestTypes.Token];e.connection.ws.send(JSON.stringify(i)),_(e),J(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((i,r)=>{e.authCallbacks[t]={resolve:n=>{w(e,n.token,{refreshToken:n.refreshToken}),i(n)},reject:r}})},Ne=(e,s)=>{let t=++pe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.RenewToken,t,s]),new Promise((i,r)=>{e.authCallbacks[t]={resolve:n=>{w(e,n.token),i(n)},reject:r}})},Le=(e,s)=>{let[,t,i,r]=s,n=e.authCallbacks[t];n&&(delete e.authCallbacks[t],r?n.reject(C(r)):n.resolve(i))},He=e=>{let s=++pe;return f(e,[F.RequestTypes.Auth,F.AuthRequestTypes.Logout,s]),new Promise((t,i)=>{e.authCallbacks[s]={resolve:r=>{w(e),t(r)},reject:i}})};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,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),J(this),ae(this)}onData(s){var t;try{let i=JSON.parse(s.data),[r,n,o,c]=i;if(r===g.RequestTypes.Token){this.retryingRenewToken=!1,n.length&&Ge(this,i);for(let a of this.auth)a(!o);this.beingAuth=!1,this.auth=[]}else if(r===g.RequestTypes.Auth)Le(this,i);else if((c==null?void 0:c.code)===g.BasedErrorCodes.TokenExpired&&!this.retryingRenewToken){this.retryingRenewToken=!0;let a=(t=this.sendTokenOptions)==null?void 0:t.refreshToken;Ne(this,{refreshToken:a}).then(u=>{w(this,u.token,this.sendTokenOptions),k(this,r,c==null?void 0:c.payload,this.requestCallbacks[n].resolve,this.requestCallbacks[n].reject)}).catch(u=>{this.requestCallbacks[n].reject(u)})}else 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?$e(this,i):r===g.RequestTypes.Subscription?De(this,i):r===g.RequestTypes.SubscriptionDiff&&Ue(this,i)}catch(i){console.log(i),console.error("Received incorrect data ",s)}}};var de=(e,s)=>{let t;if(e.configuration&&e.configuration.schema)for(let i in e.configuration.schema){let r=e.configuration.schema[i];if(r.prefixToTypeMapping){for(let n in r.prefixToTypeMapping)if(r.prefixToTypeMapping[n]===s){t=n;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}`,i=Object.keys(s).sort();for(let r of i)t+="_"+r+"_"+s[r];return t}else return e},M=(e,s,t,i,r,n,o)=>{let c=be(s,t),a={t:c};o&&(a.r=1),r&&(a.e=1,n&&(a.o=n)),i?(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,i){this.closed=!1;this.client=s,this.subId=i,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,i){let r={data:{}},n=[];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);n.push(a)}return new me(this.client,n)}},P=class{constructor(s,t,i){this.client=s,this.subId=typeof t=="string"?q(i,t):q(t),this.name=typeof t=="string"?t:null,this.payload=typeof t=="string"?i:t}subscribe(s,t,i){let[,r]=E(this.client,this.payload,s,n=>{n&&(console.error(n),t&&t(n))},t,this.subId,this.name);return new fe(this.client,r,this.subId)}};var he={},N={},lt=(e,s)=>{he[e]||(he[e]=!0,setTimeout(()=>{console.info("Drain file q"),he[e]=!1;let t=N[e];N[e]=[];let i=new global.FormData;for(let r of t){let{raw:n,name:o,id:c,file:a,functionName:u}=r,l=`${u||""}|${n?1:0}|${c}|${a.size}${o?`|${o}`:""}`;i.append(l,a)}try{let r=new global.XMLHttpRequest;r.upload.onprogress=n=>{let o=100*(n.loaded||n.position)/(n.totalSize||n.total);console.info(o,"upload...")},r.onerror=n=>{console.error("error!",n,"flap",r.responseText)},r.timeout=1e3*60*60*24,r.onabort=n=>{console.error("abort",n)},r.ontimeout=n=>{console.error("on timeout",n)},r.onload=()=>{let n={};try{n=JSON.parse(r.response),console.info("SUCCESS",n)}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(i)}catch(r){console.error("Something wrong with xhr upload",r)}},500))},Ke=async(e,s,t,i,r,n,o)=>{N[t]||(N[t]=[]),N[t].push({file:s,id:i,url:t,raw:r,name:n,functionName:o}),lt(t,e.getToken())};var We=H(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:i,org:r}=e.opts,n=t+"/"+i+"/"+r+"/"+e.opts.cluster;if(Y[n])return Y[n];if(Z[n])return(await Z[n]).url;let o=await(Z[n]=(0,We.default)({env:t,project:i,org:r,name:"@based/hub",key:"file-upload",optionalKey:!0},0,e.opts.cluster));return delete Z[n],setTimeout(()=>{delete Y[n]},2e3),Y[n]=o.url},Ve=pt;var Xe=H(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(i=>{}).catch(i=>{console.error("Error while uploading file",i)}),{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 i=(await Ve(e,s)).replace(/^ws/,"http");if(bt(s))return(0,I.uploadFilePath)(e,i,s),{id:t};if(ft(s))return(0,I.uploadFileStream)(e,i,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,i+"/file",s);if(te&&s.contents instanceof global.Blob)return s.mimeType||(s.mimeType=s.contents.type),ee(e,i+"/file",s);if(typeof s.contents=="string"||!te&&s.contents instanceof global.Buffer)return ee(e,i+"/file",s);if(te&&s.contents instanceof File)return Ke(e,s.contents,i,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=H(require("@based/get-service")),ye=require("@saulx/utils"),S=require("@based/graphql");d(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,i,r){return new Promise((n,o)=>{let c,a=!1;this.observe(t,(u,l)=>{r&&r(u,l),i(u,l)&&(a=!0,c&&c(),n(u))}).then(u=>{a?c():c=u}).catch(u=>{o(u)})})}gql(t,...i){typeof t=="string"&&(t=[t]);let r=t[0];return i.forEach((n,o)=>{n&&n.kind==="Document"?r+=n.loc.source.body:r+=n,r+=t[o+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema},(0,S.parseGraphql)(r))}gqlDb(t="default"){return(i,...r)=>{typeof i=="string"&&(i=[i]);let n=i[0];return r.forEach((o,c)=>{o&&o.kind==="Document"?n+=o.loc.source.body:n+=o,n+=i[c+1]}),(0,S.createOperations)({schemas:this.client.configuration.schema,db:t},(0,S.parseGraphql)(n))}}observe(t,i,r,n){return typeof t=="string"?new Promise((o,c)=>{let a=typeof i=="function",u=a?i:r,l=a?r:n;E(this.client,a?void 0:i,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,i,(a,u,l,p,b)=>{a&&!b?c(a):o(()=>{y(this.client,u,l)})},r)})}createObservable(t,i){return typeof t=="string"?new P(this.client,t,i):new P(this.client,t)}observeSchema(t,i,r){return new Promise((n,o)=>{let c=typeof t=="string"?t:"default",a=typeof t=="string"?i:t,u=typeof t=="string"?r:i;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):n(()=>{y(this.client,p,b)})},u)})}get(t,i){return typeof t=="string"?new Promise((r,n)=>{z(this.client,i,(o,c,a,u)=>{o?n(o):r(u)},0,t)}):new Promise((r,n)=>{k(this.client,v.RequestTypes.Get,t,r,n)})}file(t){return global.File&&t instanceof File&&(t={contents:t}),Ye(this,t)}call(t,i){return new Promise((r,n)=>{k(this.client,v.RequestTypes.Call,i,r,n,t)})}async id(t,i){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:i?{type:t,opts:i}:{type:t}});if(i){let n=(0,ge.hashCompact)(i,8,!0);return r+n}else return r+(0,ge.hashCompact)(Math.floor(Math.random()*99999999999)+""+Date.now())}digest(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Digest,t,i,r)})}set(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Set,t,i,r)})}copy(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Copy,t,i,r)})}async gqlQuery(t,i={}){let r;typeof t=="string"?r=this.gql(t):r=t;try{if(r=(0,S.handleGraphqlVariables)(r,r,i),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 n={};return await Promise.all(Object.entries(r.ops).map(async([o,c])=>{var p,b,h,T,R;if(c.delete){n[o]=await this.delete(c.delete);return}else if(c.fnCall){n[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=(b=(p=this.client)==null?void 0:p.configuration)==null?void 0:b.schema)==null?void 0:h[r.db])==null?void 0:T.prefixToTypeMapping)==null?void 0:R[a.slice(0,2)];ve&&(A.type=ve),n[o]=A;return}let u=(0,ye.deepCopy)(c.get);u.$id=a;let l=await this.get(u);n[o]=l})),{data:n}}catch(n){return{errors:[{message:n.message,locations:n.locations}]}}}async gqlLive(t,i={}){let r;if(typeof t=="string"?r=this.gql(t):r=t,r=(0,S.handleGraphqlVariables)(r,r,i),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 n={};return await Promise.all(Object.entries(r.ops).map(async([o,c])=>{if(c.delete){n[o]=await this.delete(c.delete);return}else if(c.fnCall){n[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,n[o]=u})),new P(this.client,{$db:r.db,data:n})}analytics(t,i){return new Promise((r,n)=>{i?E(this.client,t,i,(o,c,a,u,l)=>{o&&!l?n(o):r(()=>{y(this.client,c,a)})},o=>console.error(o),void 0,"analytics"):z(this.client,t,(o,c,a,u)=>{o?n(o):((0,v.isAnalyticsHistoryOpts)(t)||(0,v.isAnalyticsTypesOpts)(t),r(u))},0,"analytics")})}track(t,i){M(this.client,t,i)}clearAnalytics(t,i){M(this.client,t,i,!1,!1,void 0,!0)}untrack(t,i){M(this.client,t,i,!0)}event(t,i,r){M(this.client,t,i,!1,!0,r)}delete(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Delete,t,i,r)})}schema(){return new Promise((t,i)=>{let r=n=>{this.client.configuration=n,t(n)};k(this.client,v.RequestTypes.GetConfiguration,0,r,i)})}removeType(t,i="default"){return new Promise((r,n)=>{k(this.client,v.RequestTypes.RemoveType,{type:t,db:i},r,n)})}removeField(t,i,r="default"){return new Promise((n,o)=>{!i||i.length===0?o(new Error("Path cannot be empty")):(Array.isArray(i)||(i=[i]),k(this.client,v.RequestTypes.RemoveField,{type:t,db:r,path:i},n,o))})}updateSchema(t){return new Promise((i,r)=>{k(this.client,v.RequestTypes.Configuration,t,i,r)})}getToken(){return this.client.token}auth(t,i){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,i):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 i in s){let r=s[i];e+=t?`&${i}=${r}`:`${i}=${r}`,t=!0}}return e},ht=(e,s=se)=>{let{env:t,project:i,org:r,url:n,key:o,name:c="@based/hub",cluster:a,params:u}=e;if(n||(a=e.cluster=(0,re.getClusterUrl)(a),n=async()=>{let{url:l}=await(0,re.default)({env:t,project:i,org:r,key:o,name:c},0,a);return mt(l,u)}),n){let l=new s;return l.opts=e,l.connect(n),l}},gt=ht;0&&(module.exports={Based,BasedClient,BasedGraphQL,Observable,addGetSubscriber,addRequest,addSubscriber,createGraphqlOperations,generateSubscriptionId,generateTrackingKey,handleGraphqlVariables,parseGraphql,removeSubscriber});
|
package/dist/index.js.map
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/observable/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/printBasedObject.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/queue.d.ts
CHANGED
|
File without changes
|
package/dist/queue.js
CHANGED
|
File without changes
|
package/dist/queue.js.map
CHANGED
|
File without changes
|
package/dist/request.d.ts
CHANGED
|
File without changes
|
package/dist/request.js
CHANGED
|
File without changes
|
package/dist/request.js.map
CHANGED
|
File without changes
|
package/dist/selvaTypes/get.d.ts
CHANGED
|
File without changes
|
package/dist/selvaTypes/get.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/selvaTypes/set.d.ts
CHANGED
|
File without changes
|
package/dist/selvaTypes/set.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/token.d.ts
CHANGED
|
File without changes
|
package/dist/token.js
CHANGED
|
File without changes
|
package/dist/token.js.map
CHANGED
|
File without changes
|
package/dist/track.d.ts
CHANGED
|
File without changes
|
package/dist/track.js
CHANGED
|
File without changes
|
package/dist/track.js.map
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/websocket/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/websocket/types.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"concurrently": "^7.1.0",
|
|
43
43
|
"esbuild": "^0.14.29",
|
|
44
44
|
"@saulx/hash": "^1.1.0",
|
|
45
|
-
"@based/server": "^2.6.0",
|
|
46
45
|
"@saulx/selva": "^11.0.0",
|
|
47
46
|
"@saulx/utils": "^2.2.1",
|
|
48
47
|
"@saulx/selva-server": "11.0.0",
|
package/dist/types.d.ts
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { GetOptions } from './selvaTypes/get';
|
|
3
|
-
import type { SetOptions } from './selvaTypes/set';
|
|
4
|
-
import type { Schema } from './selvaTypes/schema';
|
|
5
|
-
import { Readable } from 'stream';
|
|
6
|
-
export { GetOptions, SetOptions, Schema };
|
|
7
|
-
export declare type DigestOptions = string;
|
|
8
|
-
export declare enum RequestTypes {
|
|
9
|
-
Subscription = 1,
|
|
10
|
-
SubscriptionDiff = 2,
|
|
11
|
-
SendSubscriptionData = 3,
|
|
12
|
-
Unsubscribe = 4,
|
|
13
|
-
Set = 5,
|
|
14
|
-
Get = 6,
|
|
15
|
-
Configuration = 7,
|
|
16
|
-
GetConfiguration = 8,
|
|
17
|
-
Call = 9,
|
|
18
|
-
GetSubscription = 10,
|
|
19
|
-
Delete = 11,
|
|
20
|
-
Copy = 12,
|
|
21
|
-
Digest = 13,
|
|
22
|
-
Token = 14,
|
|
23
|
-
Track = 15,
|
|
24
|
-
Auth = 16
|
|
25
|
-
}
|
|
26
|
-
export declare enum AuthRequestTypes {
|
|
27
|
-
Login = 1,
|
|
28
|
-
Logout = 2,
|
|
29
|
-
RenewToken = 3
|
|
30
|
-
}
|
|
31
|
-
export declare type Configuration = {
|
|
32
|
-
schema: {
|
|
33
|
-
[db: string]: Schema;
|
|
34
|
-
};
|
|
35
|
-
dbs: string[];
|
|
36
|
-
};
|
|
37
|
-
export declare type Query = GetOptions;
|
|
38
|
-
export declare type GenericObject = {
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
};
|
|
41
|
-
export declare type Copy = {
|
|
42
|
-
$id: string;
|
|
43
|
-
db?: string;
|
|
44
|
-
deep?: boolean;
|
|
45
|
-
parents?: string[];
|
|
46
|
-
excludeFields?: string[];
|
|
47
|
-
};
|
|
48
|
-
export declare type ErrorObject = {
|
|
49
|
-
type: string;
|
|
50
|
-
message: string;
|
|
51
|
-
name?: string;
|
|
52
|
-
query?: GenericObject;
|
|
53
|
-
payload?: any;
|
|
54
|
-
auth?: boolean;
|
|
55
|
-
code?: string;
|
|
56
|
-
};
|
|
57
|
-
export declare type FunctionCallMessage = [RequestTypes.Call, string, number, any?];
|
|
58
|
-
export declare type TrackMessage = [RequestTypes.Track, TrackPayload];
|
|
59
|
-
export declare type RequestMessage<T = GenericObject> = [
|
|
60
|
-
(RequestTypes.Set | RequestTypes.Get | RequestTypes.Configuration | RequestTypes.GetConfiguration | RequestTypes.Delete | RequestTypes.Copy | RequestTypes.Digest),
|
|
61
|
-
number,
|
|
62
|
-
T
|
|
63
|
-
];
|
|
64
|
-
export declare type TokenMessage = [RequestTypes.Token, string?, boolean?];
|
|
65
|
-
export declare type AuthMessage = [
|
|
66
|
-
RequestTypes.Auth,
|
|
67
|
-
AuthRequestTypes,
|
|
68
|
-
number,
|
|
69
|
-
GenericObject?
|
|
70
|
-
];
|
|
71
|
-
export declare type SubscribeMessage = [
|
|
72
|
-
RequestTypes.Subscription,
|
|
73
|
-
number,
|
|
74
|
-
GenericObject?,
|
|
75
|
-
number?,
|
|
76
|
-
(2 | 1 | 0)?,
|
|
77
|
-
string?
|
|
78
|
-
];
|
|
79
|
-
export declare type SendSubscriptionDataMessage = [
|
|
80
|
-
RequestTypes.SendSubscriptionData,
|
|
81
|
-
number,
|
|
82
|
-
number?
|
|
83
|
-
];
|
|
84
|
-
export declare type SendSubscriptionGetDataMessage = [
|
|
85
|
-
RequestTypes.GetSubscription,
|
|
86
|
-
number,
|
|
87
|
-
GenericObject?,
|
|
88
|
-
number?,
|
|
89
|
-
string?
|
|
90
|
-
];
|
|
91
|
-
export declare type UnsubscribeMessage = [
|
|
92
|
-
RequestTypes.Unsubscribe,
|
|
93
|
-
number
|
|
94
|
-
];
|
|
95
|
-
export declare type SubscriptionMessage = SubscribeMessage | SendSubscriptionDataMessage | UnsubscribeMessage | SendSubscriptionGetDataMessage;
|
|
96
|
-
export declare type Message = RequestMessage | SubscriptionMessage | FunctionCallMessage | AuthMessage;
|
|
97
|
-
export declare type SubscriptionDiffData = [
|
|
98
|
-
RequestTypes.SubscriptionDiff,
|
|
99
|
-
number,
|
|
100
|
-
GenericObject,
|
|
101
|
-
[
|
|
102
|
-
number,
|
|
103
|
-
number
|
|
104
|
-
]
|
|
105
|
-
];
|
|
106
|
-
export declare type SubscriptionData = [
|
|
107
|
-
RequestTypes.Subscription,
|
|
108
|
-
number,
|
|
109
|
-
GenericObject,
|
|
110
|
-
number?,
|
|
111
|
-
ErrorObject?
|
|
112
|
-
];
|
|
113
|
-
export declare type RequestData = [
|
|
114
|
-
(RequestTypes.Set | RequestTypes.Get | RequestTypes.Configuration | RequestTypes.GetConfiguration | RequestTypes.Call | RequestTypes.Delete | RequestTypes.Copy | RequestTypes.Digest),
|
|
115
|
-
number,
|
|
116
|
-
any,
|
|
117
|
-
ErrorObject?
|
|
118
|
-
];
|
|
119
|
-
export declare type AuthorizedData = [RequestTypes.Token, number[], boolean?];
|
|
120
|
-
export declare type AuthData = [
|
|
121
|
-
RequestTypes.Auth,
|
|
122
|
-
number,
|
|
123
|
-
GenericObject,
|
|
124
|
-
ErrorObject?
|
|
125
|
-
];
|
|
126
|
-
export declare type ResponseData = SubscriptionDiffData | SubscriptionData | RequestData | AuthorizedData | AuthData;
|
|
127
|
-
export declare type TrackPayload = {
|
|
128
|
-
t: string;
|
|
129
|
-
u?: 1;
|
|
130
|
-
s?: 1;
|
|
131
|
-
e?: 1;
|
|
132
|
-
r?: 1;
|
|
133
|
-
o?: TrackOpts;
|
|
134
|
-
};
|
|
135
|
-
export declare type TrackOpts = {
|
|
136
|
-
amount?: number;
|
|
137
|
-
};
|
|
138
|
-
export declare type SendTokenOptions = {
|
|
139
|
-
isBasedUser?: boolean;
|
|
140
|
-
isApiKey?: boolean;
|
|
141
|
-
refreshToken?: string;
|
|
142
|
-
};
|
|
143
|
-
export declare type AnalyticsResult = {
|
|
144
|
-
all: {
|
|
145
|
-
total: number;
|
|
146
|
-
geo?: {
|
|
147
|
-
[isoCode: string]: number;
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
unique: {
|
|
151
|
-
total: number;
|
|
152
|
-
geo?: {
|
|
153
|
-
[isoCode: string]: number;
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
active: {
|
|
157
|
-
total: number;
|
|
158
|
-
max: number;
|
|
159
|
-
geo?: {
|
|
160
|
-
[isoCode: string]: number;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
export declare type AnalyticsHistoryResult = {
|
|
165
|
-
all: {
|
|
166
|
-
total: [number, number][];
|
|
167
|
-
geo?: {
|
|
168
|
-
[isoCode: string]: [number, number][];
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
unique: {
|
|
172
|
-
total: [number, number][];
|
|
173
|
-
geo?: {
|
|
174
|
-
[isoCode: string]: [number, number][];
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
active: {
|
|
178
|
-
total: [number, number][];
|
|
179
|
-
geo?: {
|
|
180
|
-
[isoCode: string]: [number, number][];
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
export declare type AnalyticsTypes = string[];
|
|
185
|
-
export declare type AnalyticsTypesOpts = {
|
|
186
|
-
type?: string;
|
|
187
|
-
$types: true;
|
|
188
|
-
};
|
|
189
|
-
export declare function isAnalyticsTypesOpts(opts: AnalyticsOpts | AnalyticsTypesOpts): opts is AnalyticsTypesOpts;
|
|
190
|
-
export declare function isAnalyticsHistoryOpts(opts: AnalyticsOpts | AnalyticsTypesOpts): opts is AnalyticsHistoryOpts;
|
|
191
|
-
export declare type AnalyticsOpts = {
|
|
192
|
-
type: string;
|
|
193
|
-
params?: {
|
|
194
|
-
[key: string]: number | string | boolean;
|
|
195
|
-
};
|
|
196
|
-
$geo?: string[] | boolean;
|
|
197
|
-
};
|
|
198
|
-
export declare type AnalyticsHistoryOpts = {
|
|
199
|
-
type: string;
|
|
200
|
-
params?: {
|
|
201
|
-
[key: string]: number | string | boolean;
|
|
202
|
-
};
|
|
203
|
-
$geo?: string[] | boolean;
|
|
204
|
-
$history: boolean | number;
|
|
205
|
-
};
|
|
206
|
-
export declare type LoginOpts = {
|
|
207
|
-
email: string;
|
|
208
|
-
password: string;
|
|
209
|
-
};
|
|
210
|
-
export declare type RenewTokenOpts = {
|
|
211
|
-
refreshToken: string;
|
|
212
|
-
};
|
|
213
|
-
export declare type FileUploadOptions = {
|
|
214
|
-
contents: Buffer | ArrayBuffer | string | File | Blob;
|
|
215
|
-
mimeType?: string;
|
|
216
|
-
name?: string;
|
|
217
|
-
url?: string | (() => Promise<string>);
|
|
218
|
-
id?: string;
|
|
219
|
-
raw?: boolean;
|
|
220
|
-
parents?: string[];
|
|
221
|
-
functionName?: string;
|
|
222
|
-
};
|
|
223
|
-
export declare type FileUploadStream = {
|
|
224
|
-
contents: Readable;
|
|
225
|
-
mimeType?: string;
|
|
226
|
-
extension?: string;
|
|
227
|
-
size: number;
|
|
228
|
-
name?: string;
|
|
229
|
-
url?: string | (() => Promise<string>);
|
|
230
|
-
id?: string;
|
|
231
|
-
raw?: boolean;
|
|
232
|
-
parents?: string[];
|
|
233
|
-
functionName?: string;
|
|
234
|
-
};
|
|
235
|
-
export declare type FileUploadPath = {
|
|
236
|
-
path: string;
|
|
237
|
-
mimeType?: string;
|
|
238
|
-
extension?: string;
|
|
239
|
-
name?: string;
|
|
240
|
-
url?: string | (() => Promise<string>);
|
|
241
|
-
id?: string;
|
|
242
|
-
raw?: boolean;
|
|
243
|
-
parents?: string[];
|
|
244
|
-
functionName?: string;
|
|
245
|
-
};
|
|
246
|
-
export declare type FileUploadSrc = {
|
|
247
|
-
src: string;
|
|
248
|
-
mimeType?: string;
|
|
249
|
-
name?: string;
|
|
250
|
-
id?: string;
|
|
251
|
-
parents?: string[];
|
|
252
|
-
size?: number;
|
|
253
|
-
};
|
package/dist/types.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAnalyticsHistoryOpts = exports.isAnalyticsTypesOpts = exports.AuthRequestTypes = exports.RequestTypes = void 0;
|
|
4
|
-
// eslint-disable-next-line
|
|
5
|
-
var RequestTypes;
|
|
6
|
-
(function (RequestTypes) {
|
|
7
|
-
// eslint-disable-next-line
|
|
8
|
-
RequestTypes[RequestTypes["Subscription"] = 1] = "Subscription";
|
|
9
|
-
// eslint-disable-next-line
|
|
10
|
-
RequestTypes[RequestTypes["SubscriptionDiff"] = 2] = "SubscriptionDiff";
|
|
11
|
-
// eslint-disable-next-line
|
|
12
|
-
RequestTypes[RequestTypes["SendSubscriptionData"] = 3] = "SendSubscriptionData";
|
|
13
|
-
// eslint-disable-next-line
|
|
14
|
-
RequestTypes[RequestTypes["Unsubscribe"] = 4] = "Unsubscribe";
|
|
15
|
-
// eslint-disable-next-line
|
|
16
|
-
RequestTypes[RequestTypes["Set"] = 5] = "Set";
|
|
17
|
-
// eslint-disable-next-line
|
|
18
|
-
RequestTypes[RequestTypes["Get"] = 6] = "Get";
|
|
19
|
-
// eslint-disable-next-line
|
|
20
|
-
RequestTypes[RequestTypes["Configuration"] = 7] = "Configuration";
|
|
21
|
-
// eslint-disable-next-line
|
|
22
|
-
RequestTypes[RequestTypes["GetConfiguration"] = 8] = "GetConfiguration";
|
|
23
|
-
// eslint-disable-next-line
|
|
24
|
-
RequestTypes[RequestTypes["Call"] = 9] = "Call";
|
|
25
|
-
// eslint-disable-next-line
|
|
26
|
-
RequestTypes[RequestTypes["GetSubscription"] = 10] = "GetSubscription";
|
|
27
|
-
// eslint-disable-next-line
|
|
28
|
-
RequestTypes[RequestTypes["Delete"] = 11] = "Delete";
|
|
29
|
-
// eslint-disable-next-line
|
|
30
|
-
RequestTypes[RequestTypes["Copy"] = 12] = "Copy";
|
|
31
|
-
// eslint-disable-next-line
|
|
32
|
-
RequestTypes[RequestTypes["Digest"] = 13] = "Digest";
|
|
33
|
-
// eslint-disable-next-line
|
|
34
|
-
RequestTypes[RequestTypes["Token"] = 14] = "Token";
|
|
35
|
-
// eslint-disable-next-line
|
|
36
|
-
RequestTypes[RequestTypes["Track"] = 15] = "Track";
|
|
37
|
-
// eslint-disable-next-line
|
|
38
|
-
RequestTypes[RequestTypes["Auth"] = 16] = "Auth";
|
|
39
|
-
})(RequestTypes = exports.RequestTypes || (exports.RequestTypes = {}));
|
|
40
|
-
var AuthRequestTypes;
|
|
41
|
-
(function (AuthRequestTypes) {
|
|
42
|
-
// eslint-disable-next-line
|
|
43
|
-
AuthRequestTypes[AuthRequestTypes["Login"] = 1] = "Login";
|
|
44
|
-
// eslint-disable-next-line
|
|
45
|
-
AuthRequestTypes[AuthRequestTypes["Logout"] = 2] = "Logout";
|
|
46
|
-
// eslint-disable-next-line
|
|
47
|
-
AuthRequestTypes[AuthRequestTypes["RenewToken"] = 3] = "RenewToken";
|
|
48
|
-
})(AuthRequestTypes = exports.AuthRequestTypes || (exports.AuthRequestTypes = {}));
|
|
49
|
-
function isAnalyticsTypesOpts(opts) {
|
|
50
|
-
return opts.$types === true;
|
|
51
|
-
}
|
|
52
|
-
exports.isAnalyticsTypesOpts = isAnalyticsTypesOpts;
|
|
53
|
-
function isAnalyticsHistoryOpts(opts) {
|
|
54
|
-
const hasHistory = opts.$history;
|
|
55
|
-
return !!hasHistory;
|
|
56
|
-
}
|
|
57
|
-
exports.isAnalyticsHistoryOpts = isAnalyticsHistoryOpts;
|
|
58
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AASA,2BAA2B;AAC3B,IAAY,YAiCX;AAjCD,WAAY,YAAY;IACtB,2BAA2B;IAC3B,+DAAgB,CAAA;IAChB,2BAA2B;IAC3B,uEAAoB,CAAA;IACpB,2BAA2B;IAC3B,+EAAwB,CAAA;IACxB,2BAA2B;IAC3B,6DAAe,CAAA;IACf,2BAA2B;IAC3B,6CAAO,CAAA;IACP,2BAA2B;IAC3B,6CAAO,CAAA;IACP,2BAA2B;IAC3B,iEAAiB,CAAA;IACjB,2BAA2B;IAC3B,uEAAoB,CAAA;IACpB,2BAA2B;IAC3B,+CAAQ,CAAA;IACR,2BAA2B;IAC3B,sEAAoB,CAAA;IACpB,2BAA2B;IAC3B,oDAAW,CAAA;IACX,2BAA2B;IAC3B,gDAAS,CAAA;IACT,2BAA2B;IAC3B,oDAAW,CAAA;IACX,2BAA2B;IAC3B,kDAAU,CAAA;IACV,2BAA2B;IAC3B,kDAAU,CAAA;IACV,2BAA2B;IAC3B,gDAAS,CAAA;AACX,CAAC,EAjCW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAiCvB;AAED,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,2BAA2B;IAC3B,yDAAS,CAAA;IACT,2BAA2B;IAC3B,2DAAU,CAAA;IACV,2BAA2B;IAC3B,mEAAc,CAAA;AAChB,CAAC,EAPW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAO3B;AA2OD,SAAgB,oBAAoB,CAClC,IAAwC;IAExC,OAAQ,IAA2B,CAAC,MAAM,KAAK,IAAI,CAAA;AACrD,CAAC;AAJD,oDAIC;AAED,SAAgB,sBAAsB,CACpC,IAAwC;IAExC,MAAM,UAAU,GAAI,IAA6B,CAAC,QAAQ,CAAA;IAC1D,OAAO,CAAC,CAAC,UAAU,CAAA;AACrB,CAAC;AALD,wDAKC"}
|