@qwanyx/stack 0.2.0 → 0.2.2
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/index.cjs.js +1 -1
- package/dist/index.esm.js +82 -70
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var wt=Object.defineProperty;var _t=(f,t,r)=>t in f?wt(f,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):f[t]=r;var be=(f,t,r)=>_t(f,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react");class jt{constructor(t){be(this,"config");if(!t.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=t}async callGraph(t,r={}){const n={coprocessor:"graph",method:t,system_id:this.config.system_id,params:r};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o}catch(i){throw console.error("Graph API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(t){return(await this.callGraph("get_children",{parent_id:t})).result||[]}async getNode(t){return(await this.callGraph("get_node",{node_id:t})).result||null}async addNode(t){const r={...t,created:t.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",r);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(t,r){const n={node_id:t,updates:{...r,modified:new Date().toISOString()}},i=await this.callGraph("update_node",n);if(!i.result)throw new Error("Failed to update node");return i.result}async deleteNode(t,r=!1){return(await this.callGraph("delete_node",{node_id:t,cascade:r})).success===!0}async getChildrenWithEdges(t,r="children",n,i){return(await this.callGraph("get_children_with_edges",{node_id:t,display_mode:r,edge_type:n,node_type:i})).result||[]}async addEdge(t,r,n="link",i){return await this.callGraph("add_edge",{source_id:t,target_id:r,edge_type:n,data:i})}async deleteEdge(t,r,n){return await this.callGraph("delete_edge",{source_id:t,target_id:r,edge_type:n})}async getEdges(t,r){return(await this.callGraph("get_edges",{source_id:t,edge_type:r})).result||[]}async getAncestors(t){return(await this.callGraph("get_ancestors",{node_id:t})).ancestors||[]}async getTree(t,r=10){return(await this.callGraph("get_tree",{root_id:t,max_depth:r})).tree||[]}async moveNode(t,r){const n=await this.callGraph("move",{node_id:t,new_parent_id:r});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(t,r){return(await this.callGraph("search",{query:t,type:r})).nodes||[]}}class Qe{constructor(t){be(this,"config");if(!t.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=t}async callMail(t,r={}){const n={coprocessor:"mail",method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...r}};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("Mail API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(t){await this.callMail("save_email_settings",{accounts:t})}async listEmails(t,r=20){return this.callMail("list_emails",{account_id:t,limit:r})}async deleteEmails(t,r,n=!0){return this.callMail("delete_emails",{account_id:t,uids:r,expunge:n})}async imapExec(t,r){return this.callMail("imap_exec",{account_id:t,commands:r})}async trashEmails(t,r){const n=["SELECT INBOX",...r.map(l=>`UID MOVE ${l} [Gmail]/Trash`)],o=(await this.imapExec(t,n)).responses.filter(l=>l.ok&&l.command==="UID MOVE").length;return{success:o>0,moved:o}}async archiveEmails(t,r){const n=["SELECT INBOX",...r.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(t,n)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:o>0,archived:o}}async listFolders(t){const n=(await this.imapExec(t,['LIST "" *'])).responses.find(i=>i.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}}const Ae="qwanyx_auth_token",$e="qwanyx_refresh_token";class He{static setToken(t){typeof window<"u"&&localStorage.setItem(Ae,t)}static getToken(){return typeof window<"u"?localStorage.getItem(Ae):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Ae),localStorage.removeItem($e))}static setRefreshToken(t){typeof window<"u"&&localStorage.setItem($e,t)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem($e):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const t=this.getToken();return t?{Authorization:`Bearer ${t}`}:{}}}class Ze{constructor(t){be(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...t}}buildQueryString(t){if(!t||Object.keys(t).length===0)return"";const r=new URLSearchParams;Object.entries(t).forEach(([i,o])=>{o!=null&&r.append(i,String(o))});const n=r.toString();return n?`?${n}`:""}async request(t,r={}){const{method:n="GET",headers:i={},body:o,params:l}=r,v=`${this.config.baseUrl}/${t}${this.buildQueryString(l)}`,u={...this.config.headers,...He.getAuthHeader(),...i},h={method:n,headers:u};o&&n!=="GET"&&(h.body=JSON.stringify(o));try{const x=new AbortController,j=setTimeout(()=>x.abort(),this.config.timeout),O=await fetch(v,{...h,signal:x.signal});if(clearTimeout(j),!O.ok){const D=await O.json().catch(()=>({message:O.statusText}));throw new Error(D.message||`HTTP ${O.status}`)}return await O.json()}catch(x){throw x instanceof Error?x:new Error("An unexpected error occurred")}}async get(t,r){return this.request(t,{method:"GET",params:r})}async post(t,r,n){return this.request(t,{method:"POST",body:r,params:n})}async put(t,r,n){return this.request(t,{method:"PUT",body:r,params:n})}async patch(t,r,n){return this.request(t,{method:"PATCH",body:r,params:n})}async delete(t,r){return this.request(t,{method:"DELETE",params:r})}setBaseUrl(t){this.config.baseUrl=t}getBaseUrl(){return this.config.baseUrl}}let je=null;function Et(f){return je=new Ze(f),je}function Me(){if(!je)throw new Error("API client not initialized. Call initializeApiClient() first.");return je}function et(f,t,r={}){const{enabled:n=!0,refetchOnMount:i=!0,onSuccess:o,onError:l}=r,[v,u]=b.useState(null),[h,x]=b.useState(n),[j,O]=b.useState(null),D=b.useCallback(async()=>{if(n){x(!0),O(null);try{const C=await Me().get(f,t);u(C),o==null||o(C)}catch(P){const C=P instanceof Error?P:new Error("Unknown error");O(C),l==null||l(C)}finally{x(!1)}}},[f,JSON.stringify(t),n,o,l]);return b.useEffect(()=>{i&&D()},[D,i]),{data:v,loading:h,error:j,refetch:D}}function St(f,t="POST",r={}){const{onSuccess:n,onError:i}=r,[o,l]=b.useState(null),[v,u]=b.useState(!1),[h,x]=b.useState(null),j=b.useCallback(async D=>{u(!0),x(null);try{const P=Me();let C;switch(t){case"POST":C=await P.post(f,D);break;case"PUT":C=await P.put(f,D);break;case"PATCH":C=await P.patch(f,D);break;case"DELETE":C=await P.delete(f);break;default:throw new Error(`Unsupported method: ${t}`)}return l(C),n==null||n(C,D),C}catch(P){const C=P instanceof Error?P:new Error("Unknown error");return x(C),i==null||i(C,D),null}finally{u(!1)}},[f,t,n,i]),O=b.useCallback(()=>{l(null),x(null),u(!1)},[]);return{data:o,loading:v,error:h,mutate:j,reset:O}}var De={exports:{}},ce={};/**
|
|
1
|
+
"use strict";var wt=Object.defineProperty;var _t=(f,t,r)=>t in f?wt(f,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):f[t]=r;var be=(f,t,r)=>_t(f,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react");class jt{constructor(t){be(this,"config");if(!t.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=t}async callGraph(t,r={}){const n={coprocessor:"graph",method:t,system_id:this.config.system_id,params:r};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o}catch(i){throw console.error("Graph API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(t){return(await this.callGraph("get_children",{parent_id:t})).result||[]}async getNode(t){return(await this.callGraph("get_node",{node_id:t})).result||null}async addNode(t){const r={...t,created:t.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",r);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(t,r){const n={node_id:t,updates:{...r,modified:new Date().toISOString()}},i=await this.callGraph("update_node",n);if(!i.result)throw new Error("Failed to update node");return i.result}async deleteNode(t,r=!1){return(await this.callGraph("delete_node",{node_id:t,cascade:r})).success===!0}async getChildrenWithEdges(t,r="children",n,i){return(await this.callGraph("get_children_with_edges",{node_id:t,display_mode:r,edge_type:n,node_type:i})).result||[]}async addEdge(t,r,n="link",i){return await this.callGraph("add_edge",{source_id:t,target_id:r,edge_type:n,data:i})}async deleteEdge(t,r,n){return await this.callGraph("delete_edge",{source_id:t,target_id:r,edge_type:n})}async getEdges(t,r,n){return(await this.callGraph("get_edges",{source_id:t,edge_type:r,target_id:n})).result||[]}async getAncestors(t){return(await this.callGraph("get_ancestors",{node_id:t})).ancestors||[]}async getTree(t,r=10){return(await this.callGraph("get_tree",{root_id:t,max_depth:r})).tree||[]}async moveNode(t,r){const n=await this.callGraph("move",{node_id:t,new_parent_id:r});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(t,r){return(await this.callGraph("search",{query:t,type:r})).nodes||[]}async getNodesByType(t){return(await this.callGraph("get_nodes_by_type",{type:t})).result||[]}}class Qe{constructor(t){be(this,"config");if(!t.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=t}async callMail(t,r={}){const n={coprocessor:"mail",method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...r}};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("Mail API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(t){await this.callMail("save_email_settings",{accounts:t})}async listEmails(t,r=20){return this.callMail("list_emails",{account_id:t,limit:r})}async deleteEmails(t,r,n=!0){return this.callMail("delete_emails",{account_id:t,uids:r,expunge:n})}async imapExec(t,r){return this.callMail("imap_exec",{account_id:t,commands:r})}async trashEmails(t,r){const n=["SELECT INBOX",...r.map(l=>`UID MOVE ${l} [Gmail]/Trash`)],o=(await this.imapExec(t,n)).responses.filter(l=>l.ok&&l.command==="UID MOVE").length;return{success:o>0,moved:o}}async archiveEmails(t,r){const n=["SELECT INBOX",...r.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(t,n)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:o>0,archived:o}}async listFolders(t){const n=(await this.imapExec(t,['LIST "" *'])).responses.find(i=>i.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}}const Ae="qwanyx_auth_token",$e="qwanyx_refresh_token";class He{static setToken(t){typeof window<"u"&&localStorage.setItem(Ae,t)}static getToken(){return typeof window<"u"?localStorage.getItem(Ae):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Ae),localStorage.removeItem($e))}static setRefreshToken(t){typeof window<"u"&&localStorage.setItem($e,t)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem($e):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const t=this.getToken();return t?{Authorization:`Bearer ${t}`}:{}}}class Ze{constructor(t){be(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...t}}buildQueryString(t){if(!t||Object.keys(t).length===0)return"";const r=new URLSearchParams;Object.entries(t).forEach(([i,o])=>{o!=null&&r.append(i,String(o))});const n=r.toString();return n?`?${n}`:""}async request(t,r={}){const{method:n="GET",headers:i={},body:o,params:l}=r,v=`${this.config.baseUrl}/${t}${this.buildQueryString(l)}`,u={...this.config.headers,...He.getAuthHeader(),...i},h={method:n,headers:u};o&&n!=="GET"&&(h.body=JSON.stringify(o));try{const x=new AbortController,j=setTimeout(()=>x.abort(),this.config.timeout),O=await fetch(v,{...h,signal:x.signal});if(clearTimeout(j),!O.ok){const D=await O.json().catch(()=>({message:O.statusText}));throw new Error(D.message||`HTTP ${O.status}`)}return await O.json()}catch(x){throw x instanceof Error?x:new Error("An unexpected error occurred")}}async get(t,r){return this.request(t,{method:"GET",params:r})}async post(t,r,n){return this.request(t,{method:"POST",body:r,params:n})}async put(t,r,n){return this.request(t,{method:"PUT",body:r,params:n})}async patch(t,r,n){return this.request(t,{method:"PATCH",body:r,params:n})}async delete(t,r){return this.request(t,{method:"DELETE",params:r})}setBaseUrl(t){this.config.baseUrl=t}getBaseUrl(){return this.config.baseUrl}}let je=null;function Et(f){return je=new Ze(f),je}function Me(){if(!je)throw new Error("API client not initialized. Call initializeApiClient() first.");return je}function et(f,t,r={}){const{enabled:n=!0,refetchOnMount:i=!0,onSuccess:o,onError:l}=r,[v,u]=b.useState(null),[h,x]=b.useState(n),[j,O]=b.useState(null),D=b.useCallback(async()=>{if(n){x(!0),O(null);try{const C=await Me().get(f,t);u(C),o==null||o(C)}catch(P){const C=P instanceof Error?P:new Error("Unknown error");O(C),l==null||l(C)}finally{x(!1)}}},[f,JSON.stringify(t),n,o,l]);return b.useEffect(()=>{i&&D()},[D,i]),{data:v,loading:h,error:j,refetch:D}}function St(f,t="POST",r={}){const{onSuccess:n,onError:i}=r,[o,l]=b.useState(null),[v,u]=b.useState(!1),[h,x]=b.useState(null),j=b.useCallback(async D=>{u(!0),x(null);try{const P=Me();let C;switch(t){case"POST":C=await P.post(f,D);break;case"PUT":C=await P.put(f,D);break;case"PATCH":C=await P.patch(f,D);break;case"DELETE":C=await P.delete(f);break;default:throw new Error(`Unsupported method: ${t}`)}return l(C),n==null||n(C,D),C}catch(P){const C=P instanceof Error?P:new Error("Unknown error");return x(C),i==null||i(C,D),null}finally{u(!1)}},[f,t,n,i]),O=b.useCallback(()=>{l(null),x(null),u(!1)},[]);return{data:o,loading:v,error:h,mutate:j,reset:O}}var De={exports:{}},ce={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
package/dist/index.esm.js
CHANGED
|
@@ -135,11 +135,15 @@ class $t {
|
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Get edges from a source node
|
|
138
|
+
* @param sourceId - Source node ID (null for edges without source)
|
|
139
|
+
* @param edgeType - Optional edge type filter
|
|
140
|
+
* @param targetId - Optional target node ID for reverse lookups
|
|
138
141
|
*/
|
|
139
|
-
async getEdges(t, r) {
|
|
142
|
+
async getEdges(t, r, n) {
|
|
140
143
|
return (await this.callGraph("get_edges", {
|
|
141
144
|
source_id: t,
|
|
142
|
-
edge_type: r
|
|
145
|
+
edge_type: r,
|
|
146
|
+
target_id: n
|
|
143
147
|
})).result || [];
|
|
144
148
|
}
|
|
145
149
|
// ===== HIERARCHY OPERATIONS =====
|
|
@@ -182,6 +186,14 @@ class $t {
|
|
|
182
186
|
type: r
|
|
183
187
|
})).nodes || [];
|
|
184
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Get all nodes of a specific type
|
|
191
|
+
*/
|
|
192
|
+
async getNodesByType(t) {
|
|
193
|
+
return (await this.callGraph("get_nodes_by_type", {
|
|
194
|
+
type: t
|
|
195
|
+
})).result || [];
|
|
196
|
+
}
|
|
185
197
|
}
|
|
186
198
|
class Et {
|
|
187
199
|
constructor(t) {
|
|
@@ -353,7 +365,7 @@ class Rt {
|
|
|
353
365
|
return t ? { Authorization: `Bearer ${t}` } : {};
|
|
354
366
|
}
|
|
355
367
|
}
|
|
356
|
-
class
|
|
368
|
+
class Tt {
|
|
357
369
|
constructor(t) {
|
|
358
370
|
_e(this, "config");
|
|
359
371
|
this.config = {
|
|
@@ -456,14 +468,14 @@ class kt {
|
|
|
456
468
|
}
|
|
457
469
|
let Ee = null;
|
|
458
470
|
function Dt(f) {
|
|
459
|
-
return Ee = new
|
|
471
|
+
return Ee = new Tt(f), Ee;
|
|
460
472
|
}
|
|
461
473
|
function tt() {
|
|
462
474
|
if (!Ee)
|
|
463
475
|
throw new Error("API client not initialized. Call initializeApiClient() first.");
|
|
464
476
|
return Ee;
|
|
465
477
|
}
|
|
466
|
-
function
|
|
478
|
+
function kt(f, t, r = {}) {
|
|
467
479
|
const {
|
|
468
480
|
enabled: n = !0,
|
|
469
481
|
refetchOnMount: i = !0,
|
|
@@ -597,10 +609,10 @@ function Nt() {
|
|
|
597
609
|
A.unshift("Warning: " + a), Function.prototype.apply.call(console[e], console, A);
|
|
598
610
|
}
|
|
599
611
|
}
|
|
600
|
-
var V = !1, Q = !1, m = !1,
|
|
612
|
+
var V = !1, Q = !1, m = !1, k = !1, C = !1, p;
|
|
601
613
|
p = Symbol.for("react.module.reference");
|
|
602
|
-
function
|
|
603
|
-
return !!(typeof e == "string" || typeof e == "function" || e === n || e === o || C || e === i || e === h || e === x ||
|
|
614
|
+
function T(e) {
|
|
615
|
+
return !!(typeof e == "string" || typeof e == "function" || e === n || e === o || C || e === i || e === h || e === x || k || e === $ || V || Q || m || typeof e == "object" && e !== null && (e.$$typeof === S || e.$$typeof === _ || e.$$typeof === l || e.$$typeof === v || e.$$typeof === d || // This needs to include all possible module reference object
|
|
604
616
|
// types supported by any Flight configuration anywhere since
|
|
605
617
|
// we don't know which Flight build this will end up being used
|
|
606
618
|
// with.
|
|
@@ -688,7 +700,7 @@ function Nt() {
|
|
|
688
700
|
D++;
|
|
689
701
|
}
|
|
690
702
|
}
|
|
691
|
-
function
|
|
703
|
+
function Te() {
|
|
692
704
|
{
|
|
693
705
|
if (D--, D === 0) {
|
|
694
706
|
var e = {
|
|
@@ -739,8 +751,8 @@ function Nt() {
|
|
|
739
751
|
}
|
|
740
752
|
var le = !1, ne;
|
|
741
753
|
{
|
|
742
|
-
var
|
|
743
|
-
ne = new
|
|
754
|
+
var ke = typeof WeakMap == "function" ? WeakMap : Map;
|
|
755
|
+
ne = new ke();
|
|
744
756
|
}
|
|
745
757
|
function be(e, a) {
|
|
746
758
|
if (!e || le)
|
|
@@ -808,7 +820,7 @@ function Nt() {
|
|
|
808
820
|
}
|
|
809
821
|
}
|
|
810
822
|
} finally {
|
|
811
|
-
le = !1, ie.current = A,
|
|
823
|
+
le = !1, ie.current = A, Te(), Error.prepareStackTrace = O;
|
|
812
824
|
}
|
|
813
825
|
var ae = e ? e.displayName || e.name : "", te = ae ? re(ae) : "";
|
|
814
826
|
return typeof e == "function" && ne.set(e, te), te;
|
|
@@ -1107,7 +1119,7 @@ Check the top-level render call using <` + c + ">.");
|
|
|
1107
1119
|
var Je = {};
|
|
1108
1120
|
function Ke(e, a, c, y, O, A) {
|
|
1109
1121
|
{
|
|
1110
|
-
var R =
|
|
1122
|
+
var R = T(e);
|
|
1111
1123
|
if (!R) {
|
|
1112
1124
|
var w = "";
|
|
1113
1125
|
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (w += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
@@ -1263,15 +1275,15 @@ function It({
|
|
|
1263
1275
|
onRefresh: $,
|
|
1264
1276
|
theme: P = {}
|
|
1265
1277
|
}) {
|
|
1266
|
-
const { data: N, loading: H, error: z, refetch: g } =
|
|
1278
|
+
const { data: N, loading: H, error: z, refetch: g } = kt(f, t), [I, V] = L(""), [Q, m] = L({}), [k, C] = L(1), p = et(() => {
|
|
1267
1279
|
if (!N) return { data: [], total: 0, totalPages: 0 };
|
|
1268
1280
|
let E = N;
|
|
1269
|
-
return v && I && d.length > 0 && (E = Fe.search(E, I, d)), Object.keys(Q).length > 0 && (E = Fe.filterByFields(E, Q)), Fe.paginate(E,
|
|
1270
|
-
}, [N, I, Q,
|
|
1281
|
+
return v && I && d.length > 0 && (E = Fe.search(E, I, d)), Object.keys(Q).length > 0 && (E = Fe.filterByFields(E, Q)), Fe.paginate(E, k, _);
|
|
1282
|
+
}, [N, I, Q, k, _, v, d]);
|
|
1271
1283
|
fe(() => {
|
|
1272
1284
|
C(1);
|
|
1273
1285
|
}, [I, Q]);
|
|
1274
|
-
const
|
|
1286
|
+
const T = () => {
|
|
1275
1287
|
V(""), m({}), C(1), g(), $ == null || $();
|
|
1276
1288
|
}, j = {
|
|
1277
1289
|
background: P.background || "#ffffff",
|
|
@@ -1303,7 +1315,7 @@ function It({
|
|
|
1303
1315
|
/* @__PURE__ */ s.jsx(
|
|
1304
1316
|
"button",
|
|
1305
1317
|
{
|
|
1306
|
-
onClick:
|
|
1318
|
+
onClick: T,
|
|
1307
1319
|
style: {
|
|
1308
1320
|
marginTop: "16px",
|
|
1309
1321
|
padding: "8px 16px",
|
|
@@ -1340,7 +1352,7 @@ function It({
|
|
|
1340
1352
|
/* @__PURE__ */ s.jsx(
|
|
1341
1353
|
"button",
|
|
1342
1354
|
{
|
|
1343
|
-
onClick:
|
|
1355
|
+
onClick: T,
|
|
1344
1356
|
style: {
|
|
1345
1357
|
padding: "6px 12px",
|
|
1346
1358
|
background: "transparent",
|
|
@@ -1411,7 +1423,7 @@ function It({
|
|
|
1411
1423
|
}, children: [
|
|
1412
1424
|
/* @__PURE__ */ s.jsxs("div", { style: { fontSize: "13px", color: j.textSecondary }, children: [
|
|
1413
1425
|
"Page ",
|
|
1414
|
-
|
|
1426
|
+
k,
|
|
1415
1427
|
" of ",
|
|
1416
1428
|
p.totalPages
|
|
1417
1429
|
] }),
|
|
@@ -1420,14 +1432,14 @@ function It({
|
|
|
1420
1432
|
"button",
|
|
1421
1433
|
{
|
|
1422
1434
|
onClick: () => C((E) => Math.max(1, E - 1)),
|
|
1423
|
-
disabled:
|
|
1435
|
+
disabled: k === 1,
|
|
1424
1436
|
style: {
|
|
1425
1437
|
padding: "6px 12px",
|
|
1426
1438
|
border: `1px solid ${j.border}`,
|
|
1427
1439
|
borderRadius: "6px",
|
|
1428
1440
|
background: "white",
|
|
1429
|
-
cursor:
|
|
1430
|
-
opacity:
|
|
1441
|
+
cursor: k === 1 ? "not-allowed" : "pointer",
|
|
1442
|
+
opacity: k === 1 ? 0.5 : 1
|
|
1431
1443
|
},
|
|
1432
1444
|
children: "Previous"
|
|
1433
1445
|
}
|
|
@@ -1436,14 +1448,14 @@ function It({
|
|
|
1436
1448
|
"button",
|
|
1437
1449
|
{
|
|
1438
1450
|
onClick: () => C((E) => Math.min(p.totalPages, E + 1)),
|
|
1439
|
-
disabled:
|
|
1451
|
+
disabled: k === p.totalPages,
|
|
1440
1452
|
style: {
|
|
1441
1453
|
padding: "6px 12px",
|
|
1442
1454
|
border: `1px solid ${j.border}`,
|
|
1443
1455
|
borderRadius: "6px",
|
|
1444
1456
|
background: "white",
|
|
1445
|
-
cursor:
|
|
1446
|
-
opacity:
|
|
1457
|
+
cursor: k === p.totalPages ? "not-allowed" : "pointer",
|
|
1458
|
+
opacity: k === p.totalPages ? 0.5 : 1
|
|
1447
1459
|
},
|
|
1448
1460
|
children: "Next"
|
|
1449
1461
|
}
|
|
@@ -1555,49 +1567,49 @@ function Bt({
|
|
|
1555
1567
|
className: l = ""
|
|
1556
1568
|
}) {
|
|
1557
1569
|
const v = Math.min(Math.max(t, 1), 5), [d, h] = L([]), [x, _] = L([]), [S, $] = L(Array(v).fill(!1)), [P, N] = L(Array(v).fill(!1)), H = Xe([]), z = X((m) => {
|
|
1558
|
-
const
|
|
1559
|
-
if (
|
|
1560
|
-
const C = Math.floor(Math.random() *
|
|
1561
|
-
return
|
|
1570
|
+
const k = f.filter((p) => !m.includes(p._id));
|
|
1571
|
+
if (k.length === 0) return null;
|
|
1572
|
+
const C = Math.floor(Math.random() * k.length);
|
|
1573
|
+
return k[C];
|
|
1562
1574
|
}, [f]), g = X(() => Math.random() * (n - r) + r, [r, n]);
|
|
1563
1575
|
fe(() => {
|
|
1564
1576
|
if (f.length === 0) {
|
|
1565
1577
|
h([]), _([]);
|
|
1566
1578
|
return;
|
|
1567
1579
|
}
|
|
1568
|
-
const m = [],
|
|
1580
|
+
const m = [], k = [], C = [];
|
|
1569
1581
|
for (let p = 0; p < v && p < f.length; p++) {
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1582
|
+
const T = z(C);
|
|
1583
|
+
T && (m.push(T), C.push(T._id));
|
|
1572
1584
|
}
|
|
1573
1585
|
for (let p = 0; p < m.length; p++) {
|
|
1574
|
-
const
|
|
1586
|
+
const T = [
|
|
1575
1587
|
m[p]._id,
|
|
1576
1588
|
...m.filter((Z, U) => U !== p).map((Z) => Z._id)
|
|
1577
|
-
], j = z(
|
|
1578
|
-
j ?
|
|
1589
|
+
], j = z(T);
|
|
1590
|
+
j ? k.push(j) : k.push(m[p]);
|
|
1579
1591
|
}
|
|
1580
|
-
h(m), _(
|
|
1592
|
+
h(m), _(k);
|
|
1581
1593
|
}, [f, v, z]);
|
|
1582
1594
|
const I = X((m) => {
|
|
1583
|
-
const
|
|
1595
|
+
const k = g(), C = setTimeout(() => {
|
|
1584
1596
|
$((p) => {
|
|
1585
|
-
const
|
|
1586
|
-
return
|
|
1597
|
+
const T = [...p];
|
|
1598
|
+
return T[m] = !T[m], T;
|
|
1587
1599
|
}), setTimeout(() => {
|
|
1588
1600
|
N((p) => {
|
|
1589
|
-
const
|
|
1590
|
-
return
|
|
1601
|
+
const T = [...p];
|
|
1602
|
+
return T[m] = !T[m], T;
|
|
1591
1603
|
}), setTimeout(() => {
|
|
1592
1604
|
const p = !P[m];
|
|
1593
|
-
p && h((
|
|
1594
|
-
const j = [...
|
|
1605
|
+
p && h((T) => {
|
|
1606
|
+
const j = [...T];
|
|
1595
1607
|
return j[m] = x[m], j;
|
|
1596
|
-
}), _((
|
|
1597
|
-
const j = [...
|
|
1608
|
+
}), _((T) => {
|
|
1609
|
+
const j = [...T], U = [
|
|
1598
1610
|
(p ? x[m] : d[m])._id,
|
|
1599
1611
|
...d.filter((D, Y) => Y !== m).map((D) => D._id),
|
|
1600
|
-
...
|
|
1612
|
+
...T.filter((D, Y) => Y !== m).map((D) => D._id)
|
|
1601
1613
|
], E = z(U);
|
|
1602
1614
|
return E && (j[m] = E), j;
|
|
1603
1615
|
}), setTimeout(() => {
|
|
@@ -1605,7 +1617,7 @@ function Bt({
|
|
|
1605
1617
|
}, 150);
|
|
1606
1618
|
}, 200);
|
|
1607
1619
|
}, 150);
|
|
1608
|
-
},
|
|
1620
|
+
}, k);
|
|
1609
1621
|
H.current[m] = C;
|
|
1610
1622
|
}, [g, z, d, x, P]), V = Xe(!1);
|
|
1611
1623
|
fe(() => {
|
|
@@ -1621,8 +1633,8 @@ function Bt({
|
|
|
1621
1633
|
const Q = (m) => {
|
|
1622
1634
|
i && i(m);
|
|
1623
1635
|
};
|
|
1624
|
-
return f.length === 0 ? /* @__PURE__ */ s.jsx("div", { className: `flex items-center justify-center p-8 ${l}`, children: /* @__PURE__ */ s.jsx("p", { className: "text-gray-500", children: "No nodes available" }) }) : d.length === 0 ? /* @__PURE__ */ s.jsx("div", { className: `flex items-center justify-center p-8 ${l}`, children: /* @__PURE__ */ s.jsx("p", { className: "text-gray-500", children: "Loading..." }) }) : /* @__PURE__ */ s.jsx("div", { className: `flex gap-4 justify-center items-center flex-wrap ${l}`, children: d.map((m,
|
|
1625
|
-
const C = x[
|
|
1636
|
+
return f.length === 0 ? /* @__PURE__ */ s.jsx("div", { className: `flex items-center justify-center p-8 ${l}`, children: /* @__PURE__ */ s.jsx("p", { className: "text-gray-500", children: "No nodes available" }) }) : d.length === 0 ? /* @__PURE__ */ s.jsx("div", { className: `flex items-center justify-center p-8 ${l}`, children: /* @__PURE__ */ s.jsx("p", { className: "text-gray-500", children: "Loading..." }) }) : /* @__PURE__ */ s.jsx("div", { className: `flex gap-4 justify-center items-center flex-wrap ${l}`, children: d.map((m, k) => {
|
|
1637
|
+
const C = x[k], p = P[k];
|
|
1626
1638
|
return /* @__PURE__ */ s.jsx(
|
|
1627
1639
|
"div",
|
|
1628
1640
|
{
|
|
@@ -1634,7 +1646,7 @@ function Bt({
|
|
|
1634
1646
|
{
|
|
1635
1647
|
className: "w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",
|
|
1636
1648
|
style: {
|
|
1637
|
-
transform: `rotateY(${S[
|
|
1649
|
+
transform: `rotateY(${S[k] ? 180 : 0}deg)`,
|
|
1638
1650
|
transition: "transform 0.5s",
|
|
1639
1651
|
transformStyle: "preserve-3d"
|
|
1640
1652
|
},
|
|
@@ -1650,7 +1662,7 @@ function Bt({
|
|
|
1650
1662
|
"div",
|
|
1651
1663
|
{
|
|
1652
1664
|
style: {
|
|
1653
|
-
transform: S[
|
|
1665
|
+
transform: S[k] ? "scaleX(-1)" : "scaleX(1)",
|
|
1654
1666
|
width: "100%",
|
|
1655
1667
|
height: "100%"
|
|
1656
1668
|
},
|
|
@@ -1680,7 +1692,7 @@ function Bt({
|
|
|
1680
1692
|
"div",
|
|
1681
1693
|
{
|
|
1682
1694
|
style: {
|
|
1683
|
-
transform: S[
|
|
1695
|
+
transform: S[k] ? "scaleX(-1)" : "scaleX(1)",
|
|
1684
1696
|
width: "100%",
|
|
1685
1697
|
height: "100%"
|
|
1686
1698
|
},
|
|
@@ -1703,7 +1715,7 @@ function Bt({
|
|
|
1703
1715
|
}
|
|
1704
1716
|
)
|
|
1705
1717
|
},
|
|
1706
|
-
`slot-${
|
|
1718
|
+
`slot-${k}`
|
|
1707
1719
|
);
|
|
1708
1720
|
}) });
|
|
1709
1721
|
}
|
|
@@ -1759,7 +1771,7 @@ function Lt({
|
|
|
1759
1771
|
renderLoading: H,
|
|
1760
1772
|
theme: z = {}
|
|
1761
1773
|
}) {
|
|
1762
|
-
const g = { ...Pt, ...z }, [I, V] = L([]), [Q, m] = L(!1), [
|
|
1774
|
+
const g = { ...Pt, ...z }, [I, V] = L([]), [Q, m] = L(!1), [k, C] = L(null), [p, T] = L(/* @__PURE__ */ new Set()), [j, Z] = L(null), [U, E] = L(null), D = et(() => t ? new Et({ baseUrl: f, system_id: t }) : null, [f, t]), Y = X(async () => {
|
|
1763
1775
|
if (D) {
|
|
1764
1776
|
m(!0), C(null);
|
|
1765
1777
|
try {
|
|
@@ -1788,9 +1800,9 @@ function Lt({
|
|
|
1788
1800
|
const W = u.uid;
|
|
1789
1801
|
if (B.shiftKey && j !== null) {
|
|
1790
1802
|
const ee = Math.min(j, b), J = Math.max(j, b), Ne = I.slice(ee, J + 1).map((ce) => ce.uid), we = new Set(Ne);
|
|
1791
|
-
|
|
1803
|
+
T(we), h == null || h(Array.from(we));
|
|
1792
1804
|
} else if (B.ctrlKey || B.metaKey)
|
|
1793
|
-
|
|
1805
|
+
T((ee) => {
|
|
1794
1806
|
const J = new Set(ee);
|
|
1795
1807
|
return J.has(W) ? J.delete(W) : J.add(W), h == null || h(Array.from(J)), J;
|
|
1796
1808
|
}), Z(b);
|
|
@@ -1798,7 +1810,7 @@ function Lt({
|
|
|
1798
1810
|
d == null || d(u), o && E(u);
|
|
1799
1811
|
else {
|
|
1800
1812
|
const ee = /* @__PURE__ */ new Set([W]);
|
|
1801
|
-
|
|
1813
|
+
T(ee), Z(b), h == null || h(Array.from(ee));
|
|
1802
1814
|
}
|
|
1803
1815
|
}, [i, j, I, p, d, h, o]), he = X(async () => {
|
|
1804
1816
|
if (!(!D || p.size === 0))
|
|
@@ -1807,7 +1819,7 @@ function Lt({
|
|
|
1807
1819
|
if (console.log("Trash result:", u), u.success && u.moved > 0) {
|
|
1808
1820
|
V((B) => B.filter((W) => !p.has(W.uid)));
|
|
1809
1821
|
const b = Array.from(p);
|
|
1810
|
-
|
|
1822
|
+
T(/* @__PURE__ */ new Set()), x == null || x(b);
|
|
1811
1823
|
} else
|
|
1812
1824
|
C("Failed to move emails to trash");
|
|
1813
1825
|
} catch (u) {
|
|
@@ -1821,7 +1833,7 @@ function Lt({
|
|
|
1821
1833
|
if (console.log("Archive result:", u), u.success && u.archived > 0) {
|
|
1822
1834
|
V((B) => B.filter((W) => !p.has(W.uid)));
|
|
1823
1835
|
const b = Array.from(p);
|
|
1824
|
-
|
|
1836
|
+
T(/* @__PURE__ */ new Set()), x == null || x(b);
|
|
1825
1837
|
} else
|
|
1826
1838
|
C("Failed to archive emails");
|
|
1827
1839
|
} catch (u) {
|
|
@@ -1830,13 +1842,13 @@ function Lt({
|
|
|
1830
1842
|
}
|
|
1831
1843
|
}, [D, r, p, x, _]), ye = X(() => {
|
|
1832
1844
|
if (p.size === I.length)
|
|
1833
|
-
|
|
1845
|
+
T(/* @__PURE__ */ new Set()), h == null || h([]);
|
|
1834
1846
|
else {
|
|
1835
1847
|
const u = new Set(I.map((b) => b.uid));
|
|
1836
|
-
|
|
1848
|
+
T(u), h == null || h(Array.from(u));
|
|
1837
1849
|
}
|
|
1838
1850
|
}, [I, p.size, h]), xe = X(() => {
|
|
1839
|
-
|
|
1851
|
+
T(/* @__PURE__ */ new Set()), h == null || h([]);
|
|
1840
1852
|
}, [h]), me = {
|
|
1841
1853
|
delete: he,
|
|
1842
1854
|
archive: ge,
|
|
@@ -1878,7 +1890,7 @@ function Lt({
|
|
|
1878
1890
|
color: g.textSecondary,
|
|
1879
1891
|
flexShrink: 0
|
|
1880
1892
|
}, children: ve(u.date) })
|
|
1881
|
-
] }) }),
|
|
1893
|
+
] }) }), Te = (u) => /* @__PURE__ */ s.jsxs("div", { style: { padding: "24px" }, children: [
|
|
1882
1894
|
/* @__PURE__ */ s.jsx("h2", { style: { margin: "0 0 8px", fontSize: "20px", color: g.text }, children: je(u.subject) || "(No subject)" }),
|
|
1883
1895
|
/* @__PURE__ */ s.jsxs("div", { style: { fontSize: "14px", color: g.textSecondary, marginBottom: "16px" }, children: [
|
|
1884
1896
|
"From: ",
|
|
@@ -1986,7 +1998,7 @@ function Lt({
|
|
|
1986
1998
|
padding: "48px",
|
|
1987
1999
|
textAlign: "center",
|
|
1988
2000
|
color: g.textSecondary
|
|
1989
|
-
}, children: "Loading..." }), le = S || Re, ne = $ ||
|
|
2001
|
+
}, children: "Loading..." }), le = S || Re, ne = $ || Te, ke = P || ie, be = N || oe, Se = H || re;
|
|
1990
2002
|
return Q && I.length === 0 ? /* @__PURE__ */ s.jsx("div", { style: { background: g.background, width: "100%", height: "100%" }, children: Se() }) : /* @__PURE__ */ s.jsxs("div", { style: { display: "flex", background: g.background, width: "100%", height: "100%" }, children: [
|
|
1991
2003
|
/* @__PURE__ */ s.jsxs("div", { style: {
|
|
1992
2004
|
flex: o && U ? "0 0 50%" : "1",
|
|
@@ -1995,14 +2007,14 @@ function Lt({
|
|
|
1995
2007
|
borderRight: o && U ? `1px solid ${g.border}` : "none",
|
|
1996
2008
|
overflow: "hidden"
|
|
1997
2009
|
}, children: [
|
|
1998
|
-
i &&
|
|
1999
|
-
|
|
2010
|
+
i && ke(Array.from(p), me),
|
|
2011
|
+
k && /* @__PURE__ */ s.jsx("div", { style: {
|
|
2000
2012
|
padding: "12px 16px",
|
|
2001
2013
|
background: "#fef2f2",
|
|
2002
2014
|
color: g.danger,
|
|
2003
2015
|
fontSize: "14px",
|
|
2004
2016
|
borderBottom: `1px solid ${g.border}`
|
|
2005
|
-
}, children:
|
|
2017
|
+
}, children: k }),
|
|
2006
2018
|
/* @__PURE__ */ s.jsx("div", { style: { flex: 1, overflowY: "auto" }, children: I.length === 0 ? be() : I.map((u, b) => /* @__PURE__ */ s.jsx(
|
|
2007
2019
|
"div",
|
|
2008
2020
|
{
|
|
@@ -2017,7 +2029,7 @@ function Lt({
|
|
|
2017
2029
|
}
|
|
2018
2030
|
export {
|
|
2019
2031
|
Bt as AnimatedCardFlip,
|
|
2020
|
-
|
|
2032
|
+
Tt as ApiClient,
|
|
2021
2033
|
Rt as AuthManager,
|
|
2022
2034
|
Mt as Card,
|
|
2023
2035
|
Fe as DataOperations,
|
|
@@ -2029,5 +2041,5 @@ export {
|
|
|
2029
2041
|
tt as getApiClient,
|
|
2030
2042
|
Dt as initializeApiClient,
|
|
2031
2043
|
Ft as useMutation,
|
|
2032
|
-
|
|
2044
|
+
kt as useQuery
|
|
2033
2045
|
};
|
package/package.json
CHANGED