minerva-plexus-csd 1.0.1 → 1.0.3
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.
|
@@ -677,7 +677,7 @@ const EM = (e) => {
|
|
|
677
677
|
headers: a
|
|
678
678
|
});
|
|
679
679
|
if (o.status === 401) {
|
|
680
|
-
console.warn("Token expired or invalid. Redirecting to login..."), Oe.remove("access_token", { path: "/" })
|
|
680
|
+
console.warn("Token expired or invalid. Redirecting to login..."), Oe.remove("access_token", { path: "/" });
|
|
681
681
|
return;
|
|
682
682
|
}
|
|
683
683
|
if (!o.ok)
|
|
@@ -27,7 +27,7 @@ Check the top-level render call using <`+J+">.")}return j}}function YS(_,j){{if(
|
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,Rd,fn,U6,fn),ZS[fn+Rd]=!0}}return _===a?L6(Oe):O6(Oe),Oe}}function D6(_,j,J){return JS(_,j,J,!0)}function M6(_,j,J){return JS(_,j,J,!1)}var P6=M6,F6=D6;Vn.Fragment=a,Vn.jsx=P6,Vn.jsxs=F6}(),Vn}var a1={};a1.NODE_ENV==="production"?pa.exports=n1():pa.exports=r1();var f=pa.exports;const mn={LOGIN_EMAIL:"formLabels.loginEmail",LOGIN_PASSWORD:"formLabels.loginPassword",LOGIN_SEND:"formLabels.loginSend"},Od={API_URL:"https://develop.minervadev.es/genai-manager",API_KEY:"ai"};let Ld="/assets",Zt={apiUrl:"",apiKey:""};const i1=e=>{Zt={...Zt,...e}},ct=()=>(Zt.apiUrl||(console.warn("[Minerva] apiUrl no configurado. Usando valor por defecto."),Zt.apiUrl=Od.API_URL),Zt.apiKey||(console.warn("[Minerva] apiKey no configurado. Usando valor por defecto."),Zt.apiKey=Od.API_KEY),Zt),o1=e=>{Ld=e},Dd=()=>Ld,qe=async(e,t={})=>{const{apiUrl:n}=ct(),r=fe.get("access_token"),a={"Content-Type":"application/json",...t.headers||{}};r&&(a.Authorization=`Bearer ${r}`);const i=e.startsWith("http")?e:`${n.replace(/\/$/,"")}/${e.replace(/^\//,"")}`;try{const o=await fetch(i,{...t,headers:a});if(o.status===401){console.warn("Token expired or invalid. Redirecting to login..."),fe.remove("access_token",{path:"/"}),window.location.href="/minerva/login";return}if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o}catch(o){throw console.error("Fetch failed:",o),o}},dt={LOGIN:"/auth/login",USER:"/users/",CONVERSATIONS_CREATE:"/conversations",USER_CONVERSATIONS:"/conversations/user",CONVERSATION_MESSAGES:"/messages/conversation",DELETE_CONVERSATION:"/conversations/delete/",GET_MESSAGES_BY_CONVERSATION_ID:"/messages/conversation",SEND_MESSAGE:"/bot/user_request_stream",BEARERLOGIN:"secret-token",SERVICESENDPOINT:"/services/get_services_user"},Md={login:async(e,t)=>{fe.remove("access_token",{path:"/"});const n=await qe(dt.LOGIN,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${dt.BEARERLOGIN}`},body:new URLSearchParams({username:e,password:t}).toString()});if(!n)throw new Error("Login failed: No response from server (possible redirection).");const r=await n.json();if(r.detail||r.error)throw new Error(r.detail||r.error);if(!r.access_token)throw new Error("No access token found in response");return r},getUser:async()=>{const e=await qe(dt.USER,{method:"GET"});if(!e)throw new Error("Failed to fetch user data: No response from server (possible redirection).");if(!e.ok)throw new Error(`Failed to fetch user data: ${e.status}`);return await e.json()},logout:async()=>{fe.remove("access_token",{path:"/"})}},fa={createConversation:async(e,t)=>{if(!t)throw new Error("Service is required to create a conversation.");const{apiUrl:n}=ct(),r=`${n}${dt.CONVERSATIONS_CREATE}/?service=${encodeURIComponent(t)}${e?`&title=${encodeURIComponent(e)}`:""}`,a=await qe(r,{method:"POST",mode:"cors",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!a)throw new Error("Failed to create conversation: No response from server.");if(!a.ok)throw new Error(`Failed to create conversation. Status: ${a.status}`);return await a.json()},getUserConversations:async e=>{const{apiUrl:t}=ct(),n=await qe(`${t}${dt.USER_CONVERSATIONS}?service=${e}`,{method:"GET"});if(!n)throw new Error("Failed to fetch user conversations: No response from server.");if(!n.ok)throw new Error(`Failed to fetch user conversations. Status: ${n.status}`);return await n.json()},getConversationById:async(e,t)=>{const{apiUrl:n}=ct(),r=await qe(`${n}${dt.CONVERSATION_MESSAGES}/${e}?service=${t}`,{method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!r)throw new Error("Failed to fetch conversation by ID: No response from server.");if(!r.ok)throw new Error(`Failed to fetch conversation by ID. Status: ${r.status}`);return await r.json()},deleteConversationById:async(e,t)=>{const{apiUrl:n}=ct(),r=await qe(`${n}${dt.DELETE_CONVERSATION}${e}?conversation_id=${e}&service=${t}`,{method:"POST"});if(!r)throw new Error("Failed to delete conversation: No response from server.");if(!r.ok)throw new Error(`Failed to delete conversation with ID: ${e}. Status: ${r.status}`)}},s1={getUserServices:async()=>{try{const e=await qe(dt.SERVICESENDPOINT,{method:"GET"});if(!e)throw console.error(" No se recibió respuesta de fetchWithAuth"),new Error("No se recibió respuesta de fetchWithAuth");if(!e.ok)throw console.error(` Error HTTP: ${e.status}`),new Error(`Error al obtener servicios. Estado: ${e.status}`);const t=await e.json();if(Array.isArray(t))return t;if(t.services&&Array.isArray(t.services))return t.services;throw console.error(" Formato de respuesta incorrecto",t),new Error("Formato de respuesta incorrecto. No se encontraron servicios.")}catch(e){throw console.error(" Error al obtener servicios:",e),e}}},l1=async(e,t)=>{try{return await fa.createConversation(e,t)}catch(n){throw console.error("Error creating conversation:",n),n}},u1=async e=>await fa.getUserConversations(e),c1=async(e,t)=>await fa.deleteConversationById(e,t),Pd=R.createContext(void 0),d1=({children:e,usedService:t})=>{const{services:n,isAuthenticated:r,loadingServices:a}=At();r&&!a&&(n===void 0?(console.error(" Services es undefined en ServiceProvider"),gn.fire({icon:"error",title:"Error",text:"No se pudieron cargar los servicios. Por favor, intenta nuevamente."})):n.length===0&&(console.warn("⚠️ No hay servicios disponibles."),gn.fire({icon:"info",title:"Sin servicios",text:"No hay servicios disponibles en este momento."})));const[i,o]=R.useState(t??((n==null?void 0:n.length)>0?n[0].service:"PlexusGpt")),s=R.useMemo(()=>({service:i,setService:o,availableServices:n||[]}),[i,n]);return f.jsx(Pd.Provider,{value:s,children:e})},ga=()=>{const e=R.useContext(Pd);if(!e)throw new Error("useService must be used within ServiceProvider");return e},kr={getMessagesByConversationId:async e=>{const{apiUrl:t}=ct(),n=await qe(`${t}${dt.GET_MESSAGES_BY_CONVERSATION_ID}/${e}?conversation_id=${e}`,{method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!n)throw new Error("Failed to fetch messages: No response from server (possible redirection).");if(!n.ok)throw new Error(`Failed to fetch messages. Status: ${n.status}`);return await n.json()},sendMessage:async(e,t)=>{const{apiUrl:n}=ct(),r=await qe(`${n}${dt.SEND_MESSAGE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversation:{id:e},text:t})});if(!r)throw new Error("Failed to send message: No response from server.");if(!r.ok)throw new Error(`Failed to send message. Status: ${r.status}`);return await r.json()},stopBotStream:async e=>{const{apiUrl:t}=ct(),n=`${t}/bot/stop_request_stream?conversation_id=${e}`;console.log("Enviando petición para detener el stream al endpoint:",n),console.log("Conversación ID:",e);try{const r=await qe(n,{method:"POST",headers:{"Content-Type":"application/json"}});if(!r)throw console.error("No se recibió respuesta del servidor"),new Error("No se recibió respuesta del servidor al intentar detener el stream");if(!r.ok){const a=await r.text().catch(()=>"No se pudo leer el error");throw console.error(`Error del servidor (${r.status}):`,a),new Error(`Error al detener el stream: ${r.status}`)}console.log("Backend confirmó detención del stream");return}catch(r){throw console.error("Error al detener el stream:",r),r}},sendMessageStreaming:async(e,t,n,r)=>{const{apiUrl:a}=ct(),i={conversation:{id:e},text:t,service:n},o=await qe(`${a}${dt.SEND_MESSAGE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:r});if(!o)throw new Error("Failed to send message streaming: No response from server.");if(!o.ok){let s;try{s=await o.json()}catch{s="No JSON response available"}throw console.error("Error details from server:",s),new Error(`Failed to send message streaming. Status: ${o.status}`)}if(!o.body)throw new Error(" No body in response");return o.body},editMessageAndResend:async({conversationId:e,messageId:t,text:n})=>{const a=await qe("/bot/edit_request_stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversation:{id:e},message_id:t,text:n})});if(!a)throw new Error("Failed to send message streaming: No response from server.");if(!a.ok){let i;try{i=await a.json()}catch{i="No JSON response available"}throw console.error("Error details from server:",i),new Error(`Failed to send message streaming. Status: ${a.status}`)}if(!a.body)throw new Error(" No body in response");return a.body}},p1=async e=>(await kr.getMessagesByConversationId(e)).map(a=>({...a,conversation_id:e})).slice().sort((a,i)=>new Date(a.created_at).getTime()-new Date(i.created_at).getTime()),f1=async(e,t,n,r)=>await kr.sendMessageStreaming(e,t,n),Fd=async e=>{console.log(`Solicitando detener el stream para la conversación: ${e}`);try{console.log("Enviando solicitud para detener el stream al backend..."),await kr.stopBotStream(e),console.log(`✅ Solicitud de detención enviada correctamente para conversación: ${e}`)}catch(t){throw console.error(`❌ Error al solicitar detención del stream para conversación ${e}:`,t),t}},g1=async(e,t,n)=>await kr.editMessageAndResend({conversationId:e,messageId:t,text:n}),Ud=R.createContext(void 0),m1=({children:e,enableAutoCreate:t=!1,enableAutoCreateCsd:n=!1})=>{const{isAuthenticated:r,loadingData:a}=At(),{service:i}=ga(),[o,s]=R.useState({}),[l,u]=R.useState(null),c=async()=>{if(!(!r||!i))try{const T=await u1(i);s(E=>({...E,[i]:T})),!l&&T.length>0&&!n&&u(T[T.length-1])}catch(T){console.error("❌ Error al obtener conversaciones:",T)}};R.useEffect(()=>{!a&&r&&i&&c()},[a,r,i]);const d=async(T,E)=>{try{const m=await l1(T,E);return s(x=>({...x,[E]:[...x[E]||[],m]})),u(m),m}catch(m){throw console.error("Failed to create conversation:",m),m}},g=async(T,E)=>{if(E)try{await c1(T,E),s(m=>({...m,[E]:(m[E]||[]).filter(x=>x.id!==T)})),u(null)}catch(m){console.error("Failed to delete conversation:",m)}},p=async(T,E)=>{const x=(o[E??""]||[]).find(b=>b.id===T);x&&(l!=null&&l.id&&await Fd(l==null?void 0:l.id),u(x))},{autoCreateConversation:h,autoCreateConversationCsd:y}=gd({enableAutoCreate:t,enableAutoCreateCsd:n,addConversation:d,selectConversation:p,service:i,conversations:o[i]||[]});R.useEffect(()=>{r&&!a&&t&&!n&&h()},[r,a,h]),R.useEffect(()=>{r&&!a&&n&&y()},[r,y]);const A=R.useMemo(()=>({conversations:o[i]||[],fetchConversations:c,addConversation:d,removeConversation:g,selectConversation:p,selectedConversation:l,selectedConversationId:(l==null?void 0:l.id)??null,service:i}),[o,l,i]);return f.jsx(Ud.Provider,{value:A,children:e})},hn=()=>{const e=R.useContext(Ud);if(!e)throw new Error("useConversation must be used within a ConversationProvider");return e},Bd=(e,t,n)=>new Promise(r=>{let a=0;const i=1,o=setInterval(()=>{if(a<e.length){const s=e.slice(a,a+i);n(s),a+=i}else clearInterval(o),r()},t)});N.div.attrs({className:"row"})`
|
|
30
|
+
<%s key={someKey} {...props} />`,Rd,fn,U6,fn),ZS[fn+Rd]=!0}}return _===a?L6(Oe):O6(Oe),Oe}}function D6(_,j,J){return JS(_,j,J,!0)}function M6(_,j,J){return JS(_,j,J,!1)}var P6=M6,F6=D6;Vn.Fragment=a,Vn.jsx=P6,Vn.jsxs=F6}(),Vn}var a1={};a1.NODE_ENV==="production"?pa.exports=n1():pa.exports=r1();var f=pa.exports;const mn={LOGIN_EMAIL:"formLabels.loginEmail",LOGIN_PASSWORD:"formLabels.loginPassword",LOGIN_SEND:"formLabels.loginSend"},Od={API_URL:"https://develop.minervadev.es/genai-manager",API_KEY:"ai"};let Ld="/assets",Zt={apiUrl:"",apiKey:""};const i1=e=>{Zt={...Zt,...e}},ct=()=>(Zt.apiUrl||(console.warn("[Minerva] apiUrl no configurado. Usando valor por defecto."),Zt.apiUrl=Od.API_URL),Zt.apiKey||(console.warn("[Minerva] apiKey no configurado. Usando valor por defecto."),Zt.apiKey=Od.API_KEY),Zt),o1=e=>{Ld=e},Dd=()=>Ld,qe=async(e,t={})=>{const{apiUrl:n}=ct(),r=fe.get("access_token"),a={"Content-Type":"application/json",...t.headers||{}};r&&(a.Authorization=`Bearer ${r}`);const i=e.startsWith("http")?e:`${n.replace(/\/$/,"")}/${e.replace(/^\//,"")}`;try{const o=await fetch(i,{...t,headers:a});if(o.status===401){console.warn("Token expired or invalid. Redirecting to login..."),fe.remove("access_token",{path:"/"});return}if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o}catch(o){throw console.error("Fetch failed:",o),o}},dt={LOGIN:"/auth/login",USER:"/users/",CONVERSATIONS_CREATE:"/conversations",USER_CONVERSATIONS:"/conversations/user",CONVERSATION_MESSAGES:"/messages/conversation",DELETE_CONVERSATION:"/conversations/delete/",GET_MESSAGES_BY_CONVERSATION_ID:"/messages/conversation",SEND_MESSAGE:"/bot/user_request_stream",BEARERLOGIN:"secret-token",SERVICESENDPOINT:"/services/get_services_user"},Md={login:async(e,t)=>{fe.remove("access_token",{path:"/"});const n=await qe(dt.LOGIN,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${dt.BEARERLOGIN}`},body:new URLSearchParams({username:e,password:t}).toString()});if(!n)throw new Error("Login failed: No response from server (possible redirection).");const r=await n.json();if(r.detail||r.error)throw new Error(r.detail||r.error);if(!r.access_token)throw new Error("No access token found in response");return r},getUser:async()=>{const e=await qe(dt.USER,{method:"GET"});if(!e)throw new Error("Failed to fetch user data: No response from server (possible redirection).");if(!e.ok)throw new Error(`Failed to fetch user data: ${e.status}`);return await e.json()},logout:async()=>{fe.remove("access_token",{path:"/"})}},fa={createConversation:async(e,t)=>{if(!t)throw new Error("Service is required to create a conversation.");const{apiUrl:n}=ct(),r=`${n}${dt.CONVERSATIONS_CREATE}/?service=${encodeURIComponent(t)}${e?`&title=${encodeURIComponent(e)}`:""}`,a=await qe(r,{method:"POST",mode:"cors",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!a)throw new Error("Failed to create conversation: No response from server.");if(!a.ok)throw new Error(`Failed to create conversation. Status: ${a.status}`);return await a.json()},getUserConversations:async e=>{const{apiUrl:t}=ct(),n=await qe(`${t}${dt.USER_CONVERSATIONS}?service=${e}`,{method:"GET"});if(!n)throw new Error("Failed to fetch user conversations: No response from server.");if(!n.ok)throw new Error(`Failed to fetch user conversations. Status: ${n.status}`);return await n.json()},getConversationById:async(e,t)=>{const{apiUrl:n}=ct(),r=await qe(`${n}${dt.CONVERSATION_MESSAGES}/${e}?service=${t}`,{method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!r)throw new Error("Failed to fetch conversation by ID: No response from server.");if(!r.ok)throw new Error(`Failed to fetch conversation by ID. Status: ${r.status}`);return await r.json()},deleteConversationById:async(e,t)=>{const{apiUrl:n}=ct(),r=await qe(`${n}${dt.DELETE_CONVERSATION}${e}?conversation_id=${e}&service=${t}`,{method:"POST"});if(!r)throw new Error("Failed to delete conversation: No response from server.");if(!r.ok)throw new Error(`Failed to delete conversation with ID: ${e}. Status: ${r.status}`)}},s1={getUserServices:async()=>{try{const e=await qe(dt.SERVICESENDPOINT,{method:"GET"});if(!e)throw console.error(" No se recibió respuesta de fetchWithAuth"),new Error("No se recibió respuesta de fetchWithAuth");if(!e.ok)throw console.error(` Error HTTP: ${e.status}`),new Error(`Error al obtener servicios. Estado: ${e.status}`);const t=await e.json();if(Array.isArray(t))return t;if(t.services&&Array.isArray(t.services))return t.services;throw console.error(" Formato de respuesta incorrecto",t),new Error("Formato de respuesta incorrecto. No se encontraron servicios.")}catch(e){throw console.error(" Error al obtener servicios:",e),e}}},l1=async(e,t)=>{try{return await fa.createConversation(e,t)}catch(n){throw console.error("Error creating conversation:",n),n}},u1=async e=>await fa.getUserConversations(e),c1=async(e,t)=>await fa.deleteConversationById(e,t),Pd=R.createContext(void 0),d1=({children:e,usedService:t})=>{const{services:n,isAuthenticated:r,loadingServices:a}=At();r&&!a&&(n===void 0?(console.error(" Services es undefined en ServiceProvider"),gn.fire({icon:"error",title:"Error",text:"No se pudieron cargar los servicios. Por favor, intenta nuevamente."})):n.length===0&&(console.warn("⚠️ No hay servicios disponibles."),gn.fire({icon:"info",title:"Sin servicios",text:"No hay servicios disponibles en este momento."})));const[i,o]=R.useState(t??((n==null?void 0:n.length)>0?n[0].service:"PlexusGpt")),s=R.useMemo(()=>({service:i,setService:o,availableServices:n||[]}),[i,n]);return f.jsx(Pd.Provider,{value:s,children:e})},ga=()=>{const e=R.useContext(Pd);if(!e)throw new Error("useService must be used within ServiceProvider");return e},kr={getMessagesByConversationId:async e=>{const{apiUrl:t}=ct(),n=await qe(`${t}${dt.GET_MESSAGES_BY_CONVERSATION_ID}/${e}?conversation_id=${e}`,{method:"GET",headers:{"Content-Type":"application/x-www-form-urlencoded"}});if(!n)throw new Error("Failed to fetch messages: No response from server (possible redirection).");if(!n.ok)throw new Error(`Failed to fetch messages. Status: ${n.status}`);return await n.json()},sendMessage:async(e,t)=>{const{apiUrl:n}=ct(),r=await qe(`${n}${dt.SEND_MESSAGE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversation:{id:e},text:t})});if(!r)throw new Error("Failed to send message: No response from server.");if(!r.ok)throw new Error(`Failed to send message. Status: ${r.status}`);return await r.json()},stopBotStream:async e=>{const{apiUrl:t}=ct(),n=`${t}/bot/stop_request_stream?conversation_id=${e}`;console.log("Enviando petición para detener el stream al endpoint:",n),console.log("Conversación ID:",e);try{const r=await qe(n,{method:"POST",headers:{"Content-Type":"application/json"}});if(!r)throw console.error("No se recibió respuesta del servidor"),new Error("No se recibió respuesta del servidor al intentar detener el stream");if(!r.ok){const a=await r.text().catch(()=>"No se pudo leer el error");throw console.error(`Error del servidor (${r.status}):`,a),new Error(`Error al detener el stream: ${r.status}`)}console.log("Backend confirmó detención del stream");return}catch(r){throw console.error("Error al detener el stream:",r),r}},sendMessageStreaming:async(e,t,n,r)=>{const{apiUrl:a}=ct(),i={conversation:{id:e},text:t,service:n},o=await qe(`${a}${dt.SEND_MESSAGE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:r});if(!o)throw new Error("Failed to send message streaming: No response from server.");if(!o.ok){let s;try{s=await o.json()}catch{s="No JSON response available"}throw console.error("Error details from server:",s),new Error(`Failed to send message streaming. Status: ${o.status}`)}if(!o.body)throw new Error(" No body in response");return o.body},editMessageAndResend:async({conversationId:e,messageId:t,text:n})=>{const a=await qe("/bot/edit_request_stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversation:{id:e},message_id:t,text:n})});if(!a)throw new Error("Failed to send message streaming: No response from server.");if(!a.ok){let i;try{i=await a.json()}catch{i="No JSON response available"}throw console.error("Error details from server:",i),new Error(`Failed to send message streaming. Status: ${a.status}`)}if(!a.body)throw new Error(" No body in response");return a.body}},p1=async e=>(await kr.getMessagesByConversationId(e)).map(a=>({...a,conversation_id:e})).slice().sort((a,i)=>new Date(a.created_at).getTime()-new Date(i.created_at).getTime()),f1=async(e,t,n,r)=>await kr.sendMessageStreaming(e,t,n),Fd=async e=>{console.log(`Solicitando detener el stream para la conversación: ${e}`);try{console.log("Enviando solicitud para detener el stream al backend..."),await kr.stopBotStream(e),console.log(`✅ Solicitud de detención enviada correctamente para conversación: ${e}`)}catch(t){throw console.error(`❌ Error al solicitar detención del stream para conversación ${e}:`,t),t}},g1=async(e,t,n)=>await kr.editMessageAndResend({conversationId:e,messageId:t,text:n}),Ud=R.createContext(void 0),m1=({children:e,enableAutoCreate:t=!1,enableAutoCreateCsd:n=!1})=>{const{isAuthenticated:r,loadingData:a}=At(),{service:i}=ga(),[o,s]=R.useState({}),[l,u]=R.useState(null),c=async()=>{if(!(!r||!i))try{const T=await u1(i);s(E=>({...E,[i]:T})),!l&&T.length>0&&!n&&u(T[T.length-1])}catch(T){console.error("❌ Error al obtener conversaciones:",T)}};R.useEffect(()=>{!a&&r&&i&&c()},[a,r,i]);const d=async(T,E)=>{try{const m=await l1(T,E);return s(x=>({...x,[E]:[...x[E]||[],m]})),u(m),m}catch(m){throw console.error("Failed to create conversation:",m),m}},g=async(T,E)=>{if(E)try{await c1(T,E),s(m=>({...m,[E]:(m[E]||[]).filter(x=>x.id!==T)})),u(null)}catch(m){console.error("Failed to delete conversation:",m)}},p=async(T,E)=>{const x=(o[E??""]||[]).find(b=>b.id===T);x&&(l!=null&&l.id&&await Fd(l==null?void 0:l.id),u(x))},{autoCreateConversation:h,autoCreateConversationCsd:y}=gd({enableAutoCreate:t,enableAutoCreateCsd:n,addConversation:d,selectConversation:p,service:i,conversations:o[i]||[]});R.useEffect(()=>{r&&!a&&t&&!n&&h()},[r,a,h]),R.useEffect(()=>{r&&!a&&n&&y()},[r,y]);const A=R.useMemo(()=>({conversations:o[i]||[],fetchConversations:c,addConversation:d,removeConversation:g,selectConversation:p,selectedConversation:l,selectedConversationId:(l==null?void 0:l.id)??null,service:i}),[o,l,i]);return f.jsx(Ud.Provider,{value:A,children:e})},hn=()=>{const e=R.useContext(Ud);if(!e)throw new Error("useConversation must be used within a ConversationProvider");return e},Bd=(e,t,n)=>new Promise(r=>{let a=0;const i=1,o=setInterval(()=>{if(a<e.length){const s=e.slice(a,a+i);n(s),a+=i}else clearInterval(o),r()},t)});N.div.attrs({className:"row"})`
|
|
31
31
|
display: flex;
|
|
32
32
|
flex-wrap: wrap;
|
|
33
33
|
margin-right: -8px;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "minerva-plexus-csd",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "A reusable chat logic library for React applications",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.3",
|
|
6
6
|
"main": "dist/minerva-plexus-csd.umd.js",
|
|
7
7
|
"module": "dist/minerva-plexus-csd.es.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|