this.me 3.0.24 → 3.0.25
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";class o{constructor(t="http://localhost:7777/graphql"){this.endpoint=t,this.state={status:{active:!1,error:!1,loading:!0,data:null},listUs:[]},this.subscribers=new Set,this.socket=null}async status(){const t=`
|
|
2
2
|
query {
|
|
3
3
|
monadStatus {
|
|
4
4
|
active
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
timestamp
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
`;try{return(await this.#e(r,{username:t,password:s,filter:e})).get||[]}catch{return[]}}async#t(t,s,e,r,a
|
|
30
|
+
`;try{return(await this.#e(r,{username:t,password:s,filter:e})).get||[]}catch{return[]}}async#t(t,s,e,r,n,a=null){const c=`
|
|
31
31
|
mutation($username: String!, $password: String!, $key: String!, $value: String!, $context_id: String) {
|
|
32
32
|
${t}(username: $username, password: $password, key: $key, value: $value, context_id: $context_id)
|
|
33
33
|
}
|
|
34
|
-
`;try{return!!(await this.#e(c,{username:s,password:e,key:r,value:
|
|
34
|
+
`;try{return!!(await this.#e(c,{username:s,password:e,key:r,value:n,context_id:a}))[t]}catch{return!1}}async be(t,s,e,r,n=null){return this.#t("be",t,s,e,r,n)}async have(t,s,e,r,n=null){return this.#t("have",t,s,e,r,n)}async do(t,s,e,r,n=null){return this.#t("do",t,s,e,r,n)}async at(t,s,e,r,n=null){return this.#t("at",t,s,e,r,n)}async relate(t,s,e,r,n=null){return this.#t("relate",t,s,e,r,n)}async react(t,s,e,r,n=null){return this.#t("react",t,s,e,r,n)}async communicate(t,s,e,r,n=null){return this.#t("communicate",t,s,e,r,n)}setEndpoint(t){t.trim()&&(this.endpoint=t)}getState(){return this.state}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}#s(t){this.state={...this.state,...t},this.subscribers.forEach(s=>s(this.state))}async#e(t,s={}){const e=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,variables:s})});if(!e.ok)throw new Error(`GraphQL error: ${e.status}`);const{data:r,errors:n}=await e.json();if(n)throw new Error(n.map(a=>a.message).join(", "));return r}}const l=new o,u=new Proxy(l,{get(i,t,s){const e=Reflect.get(i,t,s);return typeof e!="function"?e:(...r)=>{const n=e.apply(i,r);return n instanceof Promise&&n.then(a=>console.log(`[this.me] ${String(t)} ✓`,a)).catch(a=>console.error(`[this.me] ${String(t)} ✗`,a)),n}}});typeof window<"u"&&(window.me=u,u.help=()=>console.table(Object.getOwnPropertyNames(o.prototype)));module.exports=u;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(i,u){typeof exports=="object"&&typeof module<"u"?module.exports=u():typeof define=="function"&&define.amd?define(u):(i=typeof globalThis<"u"?globalThis:i||self,i.Me=u())})(this,(function(){"use strict";class i{constructor(t="http://localhost:7777/graphql"){this.endpoint=t,this.state={status:{active:!1,error:!1,loading:!0,data:null},listUs:[]},this.subscribers=new Set,this.socket=null}async status(){const t=`
|
|
2
2
|
query {
|
|
3
3
|
monadStatus {
|
|
4
4
|
active
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
timestamp
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
`;try{return(await this.#e(n,{username:t,password:s,filter:e})).get||[]}catch{return[]}}async#t(t,s,e,n,r,
|
|
30
|
+
`;try{return(await this.#e(n,{username:t,password:s,filter:e})).get||[]}catch{return[]}}async#t(t,s,e,n,r,a=null){const l=`
|
|
31
31
|
mutation($username: String!, $password: String!, $key: String!, $value: String!, $context_id: String) {
|
|
32
32
|
${t}(username: $username, password: $password, key: $key, value: $value, context_id: $context_id)
|
|
33
33
|
}
|
|
34
|
-
`;try{return!!(await this.#e(
|
|
34
|
+
`;try{return!!(await this.#e(l,{username:s,password:e,key:n,value:r,context_id:a}))[t]}catch{return!1}}async be(t,s,e,n,r=null){return this.#t("be",t,s,e,n,r)}async have(t,s,e,n,r=null){return this.#t("have",t,s,e,n,r)}async do(t,s,e,n,r=null){return this.#t("do",t,s,e,n,r)}async at(t,s,e,n,r=null){return this.#t("at",t,s,e,n,r)}async relate(t,s,e,n,r=null){return this.#t("relate",t,s,e,n,r)}async react(t,s,e,n,r=null){return this.#t("react",t,s,e,n,r)}async communicate(t,s,e,n,r=null){return this.#t("communicate",t,s,e,n,r)}setEndpoint(t){t.trim()&&(this.endpoint=t)}getState(){return this.state}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}#s(t){this.state={...this.state,...t},this.subscribers.forEach(s=>s(this.state))}async#e(t,s={}){const e=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,variables:s})});if(!e.ok)throw new Error(`GraphQL error: ${e.status}`);const{data:n,errors:r}=await e.json();if(r)throw new Error(r.map(a=>a.message).join(", "));return n}}const u=new i,o=new Proxy(u,{get(c,t,s){const e=Reflect.get(c,t,s);return typeof e!="function"?e:(...n)=>{const r=e.apply(c,n);return r instanceof Promise&&r.then(a=>console.log(`[this.me] ${String(t)} ✓`,a)).catch(a=>console.error(`[this.me] ${String(t)} ✗`,a)),r}}});return typeof window<"u"&&(window.me=o,o.help=()=>console.table(Object.getOwnPropertyNames(i.prototype))),o}));
|