morpheus-cli 0.9.9 → 0.9.11
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/http/api.js +1 -0
- package/dist/http/routers/link.js +25 -4
- package/dist/runtime/link-worker.js +49 -0
- package/dist/runtime/memory/sqlite.js +89 -6
- package/dist/runtime/oracle.js +7 -0
- package/dist/runtime/webhooks/dispatcher.js +24 -1
- package/dist/ui/assets/{AuditDashboard-ZPJ5Pfwi.js → AuditDashboard-CM1YN1uk.js} +1 -1
- package/dist/ui/assets/Chat-D4y-g6Tw.js +41 -0
- package/dist/ui/assets/{Chronos-buCS0uuh.js → Chronos-D1yAb4M5.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-Bud3Ur7D.js → ConfirmationModal-DxUHZgTy.js} +1 -1
- package/dist/ui/assets/{Dashboard-CR6pBg6o.js → Dashboard-BzxmcHaS.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-Cz1jfXgq.js → DeleteConfirmationModal-CqNXT_YQ.js} +1 -1
- package/dist/ui/assets/Documents-DLFZdmim.js +7 -0
- package/dist/ui/assets/{Logs-BgDEdckr.js → Logs-B1Bpy9dB.js} +1 -1
- package/dist/ui/assets/{MCPManager-yupmREOG.js → MCPManager-BbUDMh5Q.js} +1 -1
- package/dist/ui/assets/{ModelPricing-CbKHyj9P.js → ModelPricing-DCl-2_eJ.js} +1 -1
- package/dist/ui/assets/{Notifications-DpabYsn5.js → Notifications-8Cqj-mNp.js} +1 -1
- package/dist/ui/assets/{SatiMemories-D75MAyPU.js → SatiMemories-CdHUe6di.js} +1 -1
- package/dist/ui/assets/{SessionAudit-B3N9C1NR.js → SessionAudit-CtVHK_IH.js} +1 -1
- package/dist/ui/assets/{Settings-B1qZ-teD.js → Settings-Clge45Z0.js} +1 -1
- package/dist/ui/assets/{Skills-BmqC0xkq.js → Skills-0k7A2T5_.js} +1 -1
- package/dist/ui/assets/{Smiths-DdAcvxg6.js → Smiths-gjgBMN1F.js} +1 -1
- package/dist/ui/assets/{Tasks-D7SrOMOn.js → Tasks-AQ3MrrMp.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-cyhanIXu.js → TrinityDatabases-CGna6IMX.js} +1 -1
- package/dist/ui/assets/{UsageStats-DOgOQ4YN.js → UsageStats-B7EzZlZe.js} +1 -1
- package/dist/ui/assets/{WebhookManager-D2TdZ5kD.js → WebhookManager-Bb7KiucS.js} +1 -1
- package/dist/ui/assets/{audit-CZVCVFw_.js → audit-CJ2Ms81U.js} +1 -1
- package/dist/ui/assets/{chronos-DWSd5JMm.js → chronos-Bm68OSy4.js} +1 -1
- package/dist/ui/assets/{config-C2GB18ML.js → config-C88yQ_CP.js} +1 -1
- package/dist/ui/assets/{index-BiMscUrn.js → index-BxN2w9sY.js} +6 -6
- package/dist/ui/assets/index-C3Ff736M.css +1 -0
- package/dist/ui/assets/{mcp-JmpcV6nl.js → mcp-BE_OVkBe.js} +1 -1
- package/dist/ui/assets/{skills-D2stQj7i.js → skills-Dt0qU4gH.js} +1 -1
- package/dist/ui/assets/{stats-cDmpngPQ.js → stats-Bmdps1LR.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/Chat-BAivCJ5N.js +0 -41
- package/dist/ui/assets/Documents-CYW79d8T.js +0 -7
- package/dist/ui/assets/index-U7hzqcK_.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as l}from"./vendor-react-DikRIOlj.js";import{u as ne,m as C}from"./vendor-utils-D4NnWbOU.js";import{h as u}from"./index-BiMscUrn.js";import{C as oe}from"./ConfirmationModal-Bud3Ur7D.js";import{D as S,a6 as de,ac as D,ad as ce,h as B,Q as me,z as xe,I as he,o as pe,X as ue}from"./vendor-icons-NHF9HNeN.js";const T={postgresql:5432,mysql:3306,mongodb:27017,sqlite:0},H={name:"",type:"postgresql",host:"",port:"",database_name:"",username:"",password:"",connection_string:"",allow_read:!0,allow_insert:!1,allow_update:!1,allow_delete:!1,allow_ddl:!1},ge={postgresql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mysql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],sqlite:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mongodb:[{key:"allow_read",label:"find / aggregate",description:"Permite consultas e agregações"},{key:"allow_insert",label:"insertOne / insertMany",description:"Permite inserir documentos"},{key:"allow_update",label:"updateOne / updateMany",description:"Permite atualizar documentos"},{key:"allow_delete",label:"deleteOne / deleteMany",description:"Permite excluir documentos"},{key:"allow_ddl",label:"Schema changes",description:"createCollection / dropCollection / createIndex"}]};async function be(){return u.get("/trinity/databases")}function we(){const{data:v,error:R}=ne("/trinity/databases",be,{refreshInterval:3e4}),[Q,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[W,G]=l.useState({}),[$,q]=l.useState(null),[J,M]=l.useState({}),[I,O]=l.useState(null),[X,A]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),Y=()=>{P(null),n(H),y(!1),g(null),h(!0)},K=a=>{P(a),n({name:a.name,type:a.type,host:a.host||"",port:a.port?String(a.port):"",database_name:a.database_name||"",username:a.username||"",password:"",connection_string:"",allow_read:a.allow_read,allow_insert:a.allow_insert,allow_update:a.allow_update,allow_delete:a.allow_delete,allow_ddl:a.allow_ddl}),y(!!a.connection_string),g(null),h(!0)},V=async()=>{if(w(!0),g(null),!b&&!r.database_name.trim()){g(r.type==="sqlite"?"File path is required.":"Database name is required."),w(!1);return}try{const a={name:r.name,type:r.type,allow_read:r.allow_read,allow_insert:r.allow_insert,allow_update:r.allow_update,allow_delete:r.allow_delete,allow_ddl:r.allow_ddl};b?(!o||r.connection_string)&&(a.connection_string=r.connection_string||null):(a.host=r.host||null,a.port=r.port?parseInt(r.port):null,a.database_name=r.database_name||null,a.username=r.username||null,(!o||r.password)&&(a.password=r.password||null)),o?await u.put(`/trinity/databases/${o.id}`,a):await u.post("/trinity/databases",a),await C("/trinity/databases"),h(!1)}catch(a){g(a.message||"Failed to save database")}finally{w(!1)}},Z=a=>{_(a)},ee=async()=>{if(!f)return;const a=f.id;A(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{A(null),_(null)}},ae=async a=>{q(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{q(null)}},te=async a=>{O(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{O(null)}},re=a=>{G(t=>({...t,[a]:!t[a]}))},se=a=>{a!=="mongodb"&&y(!1),n(t=>({...t,type:a,port:T[a]?String(T[a]):""}))},ie=a=>{n(t=>({...t,[a]:!t[a]}))};if(R)return e.jsxs("div",{className:"p-8 text-red-500",children:["Failed to load databases: ",R.message]});const x="w-full px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",m="block text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",le=a=>[{key:"allow_read",badge:"R"},{key:"allow_insert",badge:"I"},{key:"allow_update",badge:"U"},{key:"allow_delete",badge:"D"},{key:"allow_ddl",badge:"DDL"}].filter(i=>a[i.key]).map(i=>i.badge);return e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Trinity Databases"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Register databases for Trinity to access and query."})]})]}),e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 px-4 py-2 bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors text-sm font-medium",children:[e.jsx(de,{className:"w-4 h-4"}),"Register Database"]})]}),v?v.length===0?e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded p-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(S,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"font-medium",children:"No databases registered"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:'Click "Register Database" to add your first database.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(a=>{const t=a.schema_json?JSON.parse(a.schema_json):null,i=!!t?.databases,c=i?t.databases.reduce((s,d)=>s+d.tables.length,0):t?.tables?.length??0,j=i?t.databases.length:0,k=a.type==="mongodb"?"collection":"table",p=a.type==="mongodb"?"collections":"tables",U=J[a.id],E=W[a.id],F=le(a);return e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-azure-surface dark:bg-black/50 px-4 py-3 flex items-center gap-3",children:[e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold text-azure-text-primary dark:text-matrix-highlight truncate",children:a.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary uppercase flex-shrink-0",children:a.type}),U===!0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-500",children:[e.jsx(D,{className:"w-3 h-3"})," Connected"]}),U===!1&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"})," Failed"]}),F.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-azure-text-secondary dark:text-matrix-secondary opacity-60"}),F.map(s=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight font-mono",children:s},s))]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary truncate mt-0.5",children:[a.host?`${a.host}:${a.port}${a.database_name?`/${a.database_name}`:""}`:a.database_name||"connection string configured",i&&j>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",j," database",j!==1?"s":""," · ",c," ",c!==1?p:k]}),!i&&c>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",c," ",c!==1?p:k]}),a.schema_updated_at&&e.jsxs("span",{className:"ml-2 opacity-50",children:["· schema ",new Date(a.schema_updated_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ae(a.id),disabled:$===a.id,title:"Test connection",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:$===a.id?e.jsx(D,{className:"w-4 h-4 animate-pulse"}):e.jsx(D,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(a.id),disabled:I===a.id,title:"Refresh schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:e.jsx(me,{className:`w-4 h-4 ${I===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>K(a),title:"Edit",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors text-xs font-medium px-2",children:"Edit"}),e.jsx("button",{onClick:()=>Z(a),disabled:X===a.id,title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-red-500 transition-colors",children:e.jsx(xe,{className:"w-4 h-4"})}),t&&e.jsx("button",{onClick:()=>re(a.id),title:E?"Hide schema":"Show schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:E?e.jsx(he,{className:"w-4 h-4"}):e.jsx(pe,{className:"w-4 h-4"})})]})]}),E&&t&&e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary px-4 py-3 bg-azure-bg dark:bg-black/20",children:[e.jsx("div",{className:"text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:i?`${j} database${j!==1?"s":""} — ${c} ${c!==1?p:k} total`:`Schema — ${c} ${c!==1?p:k}`}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:i?t.databases?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"font-bold text-azure-primary dark:text-matrix-highlight",children:s.name}),e.jsxs("span",{className:"opacity-40 text-azure-text-secondary dark:text-matrix-secondary",children:["(",s.tables.length," ",s.tables.length!==1?p:k,")"]})]}),e.jsxs("div",{className:"pl-3 space-y-1.5 border-l border-azure-border dark:border-matrix-primary/40 ml-1",children:[s.tables.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-azure-text-primary dark:text-matrix-secondary mb-0.5",children:d.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:d.columns?.map(N=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{children:N.name}),e.jsx("span",{className:"opacity-50 ml-2",children:N.type}),N.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40",children:"NOT NULL"})]},N.name))})]},d.name)),s.tables.length===0&&e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-50 italic",children:["no ",p]})]})]},s.name)):t.tables?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsx("div",{className:"font-bold text-azure-primary dark:text-matrix-highlight mb-1",children:s.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:s.columns?.map(d=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{className:"text-azure-text-primary dark:text-matrix-secondary",children:d.name}),e.jsx("span",{className:"opacity-50 ml-2",children:d.type}),d.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40 text-xs",children:"NOT NULL"})]},d.name))})]},s.name))})]})]},a.id)})}):e.jsx("div",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:"Loading..."}),e.jsx(oe,{isOpen:!!f,onClose:()=>_(null),onConfirm:ee,title:"Delete database",description:`Remove "${f?.name}" from Trinity? The database itself won't be affected — only this registration will be deleted.`,confirmJson:"Delete",variant:"destructive"}),Q&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>h(!1)}),e.jsxs("div",{className:"relative bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight",children:o?"Edit Database":"Register Database"}),e.jsx("button",{onClick:()=>h(!1),className:"text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx(ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Name *"}),e.jsx("input",{className:x,value:r.name,onChange:a=>n(t=>({...t,name:a.target.value})),placeholder:"My Production DB"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Type *"}),e.jsxs("select",{className:x,value:r.type,onChange:a=>se(a.target.value),children:[e.jsx("option",{value:"postgresql",children:"PostgreSQL"}),e.jsx("option",{value:"mysql",children:"MySQL / MariaDB"}),e.jsx("option",{value:"sqlite",children:"SQLite"}),e.jsx("option",{value:"mongodb",children:"MongoDB"})]})]}),r.type==="mongodb"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>y(!1),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary":"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight"}`,children:"Individual fields"}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary"}`,children:"Connection string"})]}),r.type==="mongodb"&&b?e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Connection String ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.connection_string,onChange:a=>n(t=>({...t,connection_string:a.target.value})),placeholder:o?"unchanged":"mongodb://user:pass@host:27017/dbname"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]}):e.jsxs(e.Fragment,{children:[r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Host"}),e.jsx("input",{className:x,value:r.host,onChange:a=>n(t=>({...t,host:a.target.value})),placeholder:"localhost"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Port"}),e.jsx("input",{className:x,type:"number",value:r.port,onChange:a=>n(t=>({...t,port:a.target.value})),placeholder:String(T[r.type]||"")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:[r.type==="sqlite"?"File Path":"Database Name"," *"]}),e.jsx("input",{className:`w-full px-3 py-2 bg-azure-surface dark:bg-black border rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none ${z&&!r.database_name.trim()?"border-red-500 dark:border-red-500":"border-azure-border dark:border-matrix-primary focus:border-azure-primary dark:focus:border-matrix-highlight"}`,value:r.database_name,onChange:a=>n(t=>({...t,database_name:a.target.value})),placeholder:r.type==="sqlite"?"/path/to/database.db":"mydb"})]}),r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Username"}),e.jsx("input",{className:x,value:r.username,onChange:a=>n(t=>({...t,username:a.target.value})),placeholder:"postgres"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Password ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.password,onChange:a=>n(t=>({...t,password:a.target.value})),placeholder:o?"unchanged":"••••••••"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]})]})]}),e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(B,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight",children:"Permissões"})]}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mb-3",children:"Defina quais operações Trinity pode executar neste banco. Operações não permitidas retornarão erro de permissão."}),e.jsx("div",{className:"space-y-2",children:ge[r.type]?.map(({key:a,label:t,description:i})=>e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsxs("div",{className:"relative mt-0.5 flex-shrink-0",children:[e.jsx("input",{type:"checkbox",checked:!!r[a],onChange:()=>ie(a),className:"sr-only"}),e.jsx("div",{className:`w-4 h-4 rounded border transition-colors flex items-center justify-center ${r[a]?"bg-azure-primary dark:bg-matrix-highlight border-azure-primary dark:border-matrix-highlight":"border-azure-border dark:border-matrix-primary bg-transparent"}`,children:r[a]&&e.jsx("svg",{className:"w-2.5 h-2.5 text-white dark:text-black",fill:"none",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M1.5 5l2.5 2.5L8.5 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary font-mono",children:t}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70",children:i})]})]},a))})]}),z&&e.jsx("div",{className:"text-sm text-red-500 border border-red-500/30 bg-red-500/10 rounded px-3 py-2",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:()=>h(!1),className:"px-4 py-2 text-sm text-azure-text-secondary dark:text-matrix-secondary border border-azure-border dark:border-matrix-primary rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:V,disabled:L||!r.name,className:"px-4 py-2 text-sm font-medium bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors disabled:opacity-50",children:L?"Saving...":o?"Update":"Register"})]})]})]})]})}export{we as TrinityDatabases};
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as l}from"./vendor-react-DikRIOlj.js";import{u as ne,m as C}from"./vendor-utils-D4NnWbOU.js";import{h as u}from"./index-BxN2w9sY.js";import{C as oe}from"./ConfirmationModal-DxUHZgTy.js";import{D as S,a6 as de,ac as D,ad as ce,h as B,Q as me,z as xe,I as he,o as pe,X as ue}from"./vendor-icons-NHF9HNeN.js";const T={postgresql:5432,mysql:3306,mongodb:27017,sqlite:0},H={name:"",type:"postgresql",host:"",port:"",database_name:"",username:"",password:"",connection_string:"",allow_read:!0,allow_insert:!1,allow_update:!1,allow_delete:!1,allow_ddl:!1},ge={postgresql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mysql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],sqlite:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mongodb:[{key:"allow_read",label:"find / aggregate",description:"Permite consultas e agregações"},{key:"allow_insert",label:"insertOne / insertMany",description:"Permite inserir documentos"},{key:"allow_update",label:"updateOne / updateMany",description:"Permite atualizar documentos"},{key:"allow_delete",label:"deleteOne / deleteMany",description:"Permite excluir documentos"},{key:"allow_ddl",label:"Schema changes",description:"createCollection / dropCollection / createIndex"}]};async function be(){return u.get("/trinity/databases")}function we(){const{data:v,error:R}=ne("/trinity/databases",be,{refreshInterval:3e4}),[Q,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[W,G]=l.useState({}),[$,q]=l.useState(null),[J,M]=l.useState({}),[I,O]=l.useState(null),[X,A]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),Y=()=>{P(null),n(H),y(!1),g(null),h(!0)},K=a=>{P(a),n({name:a.name,type:a.type,host:a.host||"",port:a.port?String(a.port):"",database_name:a.database_name||"",username:a.username||"",password:"",connection_string:"",allow_read:a.allow_read,allow_insert:a.allow_insert,allow_update:a.allow_update,allow_delete:a.allow_delete,allow_ddl:a.allow_ddl}),y(!!a.connection_string),g(null),h(!0)},V=async()=>{if(w(!0),g(null),!b&&!r.database_name.trim()){g(r.type==="sqlite"?"File path is required.":"Database name is required."),w(!1);return}try{const a={name:r.name,type:r.type,allow_read:r.allow_read,allow_insert:r.allow_insert,allow_update:r.allow_update,allow_delete:r.allow_delete,allow_ddl:r.allow_ddl};b?(!o||r.connection_string)&&(a.connection_string=r.connection_string||null):(a.host=r.host||null,a.port=r.port?parseInt(r.port):null,a.database_name=r.database_name||null,a.username=r.username||null,(!o||r.password)&&(a.password=r.password||null)),o?await u.put(`/trinity/databases/${o.id}`,a):await u.post("/trinity/databases",a),await C("/trinity/databases"),h(!1)}catch(a){g(a.message||"Failed to save database")}finally{w(!1)}},Z=a=>{_(a)},ee=async()=>{if(!f)return;const a=f.id;A(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{A(null),_(null)}},ae=async a=>{q(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{q(null)}},te=async a=>{O(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{O(null)}},re=a=>{G(t=>({...t,[a]:!t[a]}))},se=a=>{a!=="mongodb"&&y(!1),n(t=>({...t,type:a,port:T[a]?String(T[a]):""}))},ie=a=>{n(t=>({...t,[a]:!t[a]}))};if(R)return e.jsxs("div",{className:"p-8 text-red-500",children:["Failed to load databases: ",R.message]});const x="w-full px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",m="block text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",le=a=>[{key:"allow_read",badge:"R"},{key:"allow_insert",badge:"I"},{key:"allow_update",badge:"U"},{key:"allow_delete",badge:"D"},{key:"allow_ddl",badge:"DDL"}].filter(i=>a[i.key]).map(i=>i.badge);return e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Trinity Databases"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Register databases for Trinity to access and query."})]})]}),e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 px-4 py-2 bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors text-sm font-medium",children:[e.jsx(de,{className:"w-4 h-4"}),"Register Database"]})]}),v?v.length===0?e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded p-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(S,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"font-medium",children:"No databases registered"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:'Click "Register Database" to add your first database.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(a=>{const t=a.schema_json?JSON.parse(a.schema_json):null,i=!!t?.databases,c=i?t.databases.reduce((s,d)=>s+d.tables.length,0):t?.tables?.length??0,j=i?t.databases.length:0,k=a.type==="mongodb"?"collection":"table",p=a.type==="mongodb"?"collections":"tables",U=J[a.id],E=W[a.id],F=le(a);return e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-azure-surface dark:bg-black/50 px-4 py-3 flex items-center gap-3",children:[e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold text-azure-text-primary dark:text-matrix-highlight truncate",children:a.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary uppercase flex-shrink-0",children:a.type}),U===!0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-500",children:[e.jsx(D,{className:"w-3 h-3"})," Connected"]}),U===!1&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"})," Failed"]}),F.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-azure-text-secondary dark:text-matrix-secondary opacity-60"}),F.map(s=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight font-mono",children:s},s))]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary truncate mt-0.5",children:[a.host?`${a.host}:${a.port}${a.database_name?`/${a.database_name}`:""}`:a.database_name||"connection string configured",i&&j>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",j," database",j!==1?"s":""," · ",c," ",c!==1?p:k]}),!i&&c>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",c," ",c!==1?p:k]}),a.schema_updated_at&&e.jsxs("span",{className:"ml-2 opacity-50",children:["· schema ",new Date(a.schema_updated_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ae(a.id),disabled:$===a.id,title:"Test connection",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:$===a.id?e.jsx(D,{className:"w-4 h-4 animate-pulse"}):e.jsx(D,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(a.id),disabled:I===a.id,title:"Refresh schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:e.jsx(me,{className:`w-4 h-4 ${I===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>K(a),title:"Edit",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors text-xs font-medium px-2",children:"Edit"}),e.jsx("button",{onClick:()=>Z(a),disabled:X===a.id,title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-red-500 transition-colors",children:e.jsx(xe,{className:"w-4 h-4"})}),t&&e.jsx("button",{onClick:()=>re(a.id),title:E?"Hide schema":"Show schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:E?e.jsx(he,{className:"w-4 h-4"}):e.jsx(pe,{className:"w-4 h-4"})})]})]}),E&&t&&e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary px-4 py-3 bg-azure-bg dark:bg-black/20",children:[e.jsx("div",{className:"text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:i?`${j} database${j!==1?"s":""} — ${c} ${c!==1?p:k} total`:`Schema — ${c} ${c!==1?p:k}`}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:i?t.databases?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"font-bold text-azure-primary dark:text-matrix-highlight",children:s.name}),e.jsxs("span",{className:"opacity-40 text-azure-text-secondary dark:text-matrix-secondary",children:["(",s.tables.length," ",s.tables.length!==1?p:k,")"]})]}),e.jsxs("div",{className:"pl-3 space-y-1.5 border-l border-azure-border dark:border-matrix-primary/40 ml-1",children:[s.tables.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-azure-text-primary dark:text-matrix-secondary mb-0.5",children:d.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:d.columns?.map(N=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{children:N.name}),e.jsx("span",{className:"opacity-50 ml-2",children:N.type}),N.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40",children:"NOT NULL"})]},N.name))})]},d.name)),s.tables.length===0&&e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-50 italic",children:["no ",p]})]})]},s.name)):t.tables?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsx("div",{className:"font-bold text-azure-primary dark:text-matrix-highlight mb-1",children:s.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:s.columns?.map(d=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{className:"text-azure-text-primary dark:text-matrix-secondary",children:d.name}),e.jsx("span",{className:"opacity-50 ml-2",children:d.type}),d.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40 text-xs",children:"NOT NULL"})]},d.name))})]},s.name))})]})]},a.id)})}):e.jsx("div",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:"Loading..."}),e.jsx(oe,{isOpen:!!f,onClose:()=>_(null),onConfirm:ee,title:"Delete database",description:`Remove "${f?.name}" from Trinity? The database itself won't be affected — only this registration will be deleted.`,confirmJson:"Delete",variant:"destructive"}),Q&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>h(!1)}),e.jsxs("div",{className:"relative bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight",children:o?"Edit Database":"Register Database"}),e.jsx("button",{onClick:()=>h(!1),className:"text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx(ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Name *"}),e.jsx("input",{className:x,value:r.name,onChange:a=>n(t=>({...t,name:a.target.value})),placeholder:"My Production DB"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Type *"}),e.jsxs("select",{className:x,value:r.type,onChange:a=>se(a.target.value),children:[e.jsx("option",{value:"postgresql",children:"PostgreSQL"}),e.jsx("option",{value:"mysql",children:"MySQL / MariaDB"}),e.jsx("option",{value:"sqlite",children:"SQLite"}),e.jsx("option",{value:"mongodb",children:"MongoDB"})]})]}),r.type==="mongodb"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>y(!1),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary":"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight"}`,children:"Individual fields"}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary"}`,children:"Connection string"})]}),r.type==="mongodb"&&b?e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Connection String ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.connection_string,onChange:a=>n(t=>({...t,connection_string:a.target.value})),placeholder:o?"unchanged":"mongodb://user:pass@host:27017/dbname"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]}):e.jsxs(e.Fragment,{children:[r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Host"}),e.jsx("input",{className:x,value:r.host,onChange:a=>n(t=>({...t,host:a.target.value})),placeholder:"localhost"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Port"}),e.jsx("input",{className:x,type:"number",value:r.port,onChange:a=>n(t=>({...t,port:a.target.value})),placeholder:String(T[r.type]||"")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:[r.type==="sqlite"?"File Path":"Database Name"," *"]}),e.jsx("input",{className:`w-full px-3 py-2 bg-azure-surface dark:bg-black border rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none ${z&&!r.database_name.trim()?"border-red-500 dark:border-red-500":"border-azure-border dark:border-matrix-primary focus:border-azure-primary dark:focus:border-matrix-highlight"}`,value:r.database_name,onChange:a=>n(t=>({...t,database_name:a.target.value})),placeholder:r.type==="sqlite"?"/path/to/database.db":"mydb"})]}),r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Username"}),e.jsx("input",{className:x,value:r.username,onChange:a=>n(t=>({...t,username:a.target.value})),placeholder:"postgres"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Password ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.password,onChange:a=>n(t=>({...t,password:a.target.value})),placeholder:o?"unchanged":"••••••••"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]})]})]}),e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(B,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight",children:"Permissões"})]}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mb-3",children:"Defina quais operações Trinity pode executar neste banco. Operações não permitidas retornarão erro de permissão."}),e.jsx("div",{className:"space-y-2",children:ge[r.type]?.map(({key:a,label:t,description:i})=>e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsxs("div",{className:"relative mt-0.5 flex-shrink-0",children:[e.jsx("input",{type:"checkbox",checked:!!r[a],onChange:()=>ie(a),className:"sr-only"}),e.jsx("div",{className:`w-4 h-4 rounded border transition-colors flex items-center justify-center ${r[a]?"bg-azure-primary dark:bg-matrix-highlight border-azure-primary dark:border-matrix-highlight":"border-azure-border dark:border-matrix-primary bg-transparent"}`,children:r[a]&&e.jsx("svg",{className:"w-2.5 h-2.5 text-white dark:text-black",fill:"none",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M1.5 5l2.5 2.5L8.5 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary font-mono",children:t}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70",children:i})]})]},a))})]}),z&&e.jsx("div",{className:"text-sm text-red-500 border border-red-500/30 bg-red-500/10 rounded px-3 py-2",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:()=>h(!1),className:"px-4 py-2 text-sm text-azure-text-secondary dark:text-matrix-secondary border border-azure-border dark:border-matrix-primary rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:V,disabled:L||!r.name,className:"px-4 py-2 text-sm font-medium bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors disabled:opacity-50",children:L?"Saving...":o?"Update":"Register"})]})]})]})]})}export{we as TrinityDatabases};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,m as r}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{s as n}from"./stats-
|
|
1
|
+
import{j as e,m as r}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{s as n}from"./stats-Bmdps1LR.js";import{k as b,c as k,D as j,i as N}from"./vendor-icons-NHF9HNeN.js";import"./index-BxN2w9sY.js";import"./vendor-utils-D4NnWbOU.js";function w(){const[o,c]=d.useState(null),[i,x]=d.useState([]),[m,h]=d.useState(!0),[l,u]=d.useState("");if(d.useEffect(()=>{async function t(){try{const[s,p]=await Promise.all([n.fetchUsageStats(),n.fetchGroupedUsageStats()]);c(s),x(p)}catch(s){u("Failed to load usage statistics"),console.error(s)}finally{h(!1)}}t()},[]),m)return e.jsx("div",{className:"flex items-center justify-center h-64 text-azure-accent dark:text-matrix-highlight font-mono animate-pulse",children:"LOADING_DATA_STREAM..."});if(l)return e.jsxs("div",{className:"p-4 bg-red-900/20 border border-red-500/50 text-red-500 font-mono rounded",children:["ERROR_ACCESSING_DATABASE: ",l]});const g={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.1}}},a={hidden:{y:20,opacity:0},show:{y:0,opacity:1}};return e.jsxs(r.div,{variants:g,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(r.div,{variants:a,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(b,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Usage Stats"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Resource consumption tracking and cost metrics."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(k,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Input Tokens"})]}),e.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:o?.totalInputTokens.toLocaleString()??0})]}),e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(j,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Output Tokens"})]}),e.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:o?.totalOutputTokens.toLocaleString()??0})]}),e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(N,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Est. Total Cost"})]}),e.jsx("p",{className:"text-3xl font-bold text-green-600 dark:text-green-400 font-mono",children:o?.totalEstimatedCostUsd!=null?`$${o.totalEstimatedCostUsd.toFixed(4)}`:"—"})]})]}),e.jsxs(r.div,{variants:a,className:"bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden backdrop-blur-sm",children:[e.jsx("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary bg-azure-bg dark:bg-zinc-900/50",children:e.jsx("h3",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono uppercase",children:"Usage Breakdown by Model"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left font-mono text-sm",children:[e.jsx("thead",{className:"bg-azure-bg dark:bg-zinc-900/50 text-azure-text-secondary dark:text-matrix-secondary border-b border-azure-border dark:border-matrix-primary",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4",children:"Provider"}),e.jsx("th",{className:"p-4",children:"Model"}),e.jsx("th",{className:"p-4 text-right",children:"Messages"}),e.jsx("th",{className:"p-4 text-right",children:"Input Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Output Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Total Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Audio (s)"}),e.jsx("th",{className:"p-4 text-right",children:"Est. Cost (USD)"})]})}),e.jsx("tbody",{className:"divide-y divide-azure-border dark:divide-matrix-primary/30",children:i.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"p-8 text-center text-azure-text-muted dark:text-matrix-secondary italic",children:"NO_DATA_AVAILABLE"})}):i.map((t,s)=>e.jsxs("tr",{className:"hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx("td",{className:"p-4 font-bold text-azure-text-primary dark:text-matrix-highlight",children:t.provider}),e.jsx("td",{className:"p-4 text-azure-text-secondary dark:text-matrix-secondary",children:t.model}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.messageCount.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalInputTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalOutputTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right font-bold text-azure-text-primary dark:text-matrix-highlight",children:t.totalTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalAudioSeconds>0?t.totalAudioSeconds.toLocaleString():"—"}),e.jsx("td",{className:"p-4 text-right font-bold text-green-600 dark:text-green-400",children:t.estimatedCostUsd!=null?`$${t.estimatedCostUsd.toFixed(4)}`:"—"})]},`${t.provider}-${t.model}-${s}`))})]})})]})]})}export{w as UsageStats};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,m as h}from"./vendor-motion-C3CZ8ZlO.js";import{r as s,L as U}from"./vendor-react-DikRIOlj.js";import{u as M}from"./vendor-utils-D4NnWbOU.js";import{w as c,D as C,e as T,j as S}from"./index-
|
|
1
|
+
import{j as e,m as h}from"./vendor-motion-C3CZ8ZlO.js";import{r as s,L as U}from"./vendor-react-DikRIOlj.js";import{u as M}from"./vendor-utils-D4NnWbOU.js";import{w as c,D as C,e as T,j as S}from"./index-BxN2w9sY.js";import{e as B,B as K,a6 as X,v as _,T as q,a7 as G,a3 as J,a4 as Q,w as V,z as Y}from"./vendor-icons-NHF9HNeN.js";const Z={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},D={hidden:{opacity:0,y:10},show:{opacity:1,y:0}},ee=["ui","telegram","discord"],E=()=>({name:"",prompt:"",notification_channels:["ui"]}),ne=()=>{const{data:g=[],mutate:u}=M("/webhooks",()=>c.list(),{refreshInterval:1e4}),[W,n]=s.useState(!1),[o,b]=s.useState(null),[a,d]=s.useState(E()),[x,m]=s.useState(null),[p,y]=s.useState(null),[k,f]=s.useState(!1),[j,N]=s.useState(null),[z,i]=s.useState(null),l=(r,t)=>{y({type:r,message:t}),setTimeout(()=>y(null),3500)},v=()=>{b(null),d(E()),i(null),n(!0)},$=r=>{b(r),d({name:r.name,prompt:r.prompt,notification_channels:r.notification_channels}),i(null),n(!0)},F=r=>/^[a-z0-9-_]+$/.test(r),L=async()=>{if(!(!a.name.trim()||!a.prompt.trim())){if(!F(a.name)){i("Name must only contain lowercase letters, numbers, hyphens (-) and underscores (_).");return}if(a.notification_channels.length===0){i("Select at least one notification channel.");return}i(null),f(!0);try{o?(await c.update(o.id,a),l("success","Webhook updated.")):(await c.create(a),l("success","Webhook created.")),await u(),n(!1)}catch(r){const t=r?.message||"Failed to save webhook.";i(t)}finally{f(!1)}}},O=async r=>{try{await c.update(r.id,{enabled:!r.enabled}),await u()}catch{l("error","Failed to toggle webhook.")}},P=async()=>{if(x)try{await c.delete(x.id),await u(),m(null),l("success","Webhook deleted.")}catch{l("error","Failed to delete webhook.")}},A=r=>`${window.location.origin}/api/webhooks/trigger/${r}`,I=r=>`curl -X POST ${A(r.name)} \\
|
|
2
2
|
-H "x-api-key: ${r.api_key}" \\
|
|
3
3
|
-H "Content-Type: application/json" \\
|
|
4
4
|
-d '{"event":"your_payload"}'`,w=async(r,t)=>{await navigator.clipboard.writeText(r),N(t),setTimeout(()=>N(null),2e3)},R=r=>{const t=a.notification_channels.includes(r);d({...a,notification_channels:t?a.notification_channels.filter(H=>H!==r):[...a.notification_channels,r]})};return e.jsxs(h.div,{variants:Z,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(h.div,{variants:D,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(B,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Webhooks"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Trigger Oracle agent tasks from external events."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(U,{to:"/notifications",className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-sm text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:[e.jsx(K,{className:"w-4 h-4"}),"Notifications"]}),e.jsxs("button",{onClick:v,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 transition-opacity",children:[e.jsx(X,{className:"w-4 h-4"}),"New Webhook"]})]})]}),p&&e.jsx(h.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:`px-4 py-3 rounded-lg text-sm font-medium border ${p.type==="success"?"bg-green-50 dark:bg-green-900/20 border-green-300 dark:border-green-700 text-green-800 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 border-red-300 dark:border-red-700 text-red-800 dark:text-red-400"}`,children:p.message}),e.jsx(h.div,{variants:D,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:["Name","API Key","Channels","Triggers","Status","Actions"].map(r=>e.jsx("th",{className:"px-4 py-3 text-left font-semibold text-azure-text-secondary dark:text-matrix-secondary",children:r},r))})}),e.jsx("tbody",{children:g.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:6,className:"px-4 py-10 text-center text-azure-text-secondary dark:text-matrix-secondary",children:["No webhooks yet."," ",e.jsx("button",{onClick:v,className:"underline text-azure-primary dark:text-matrix-highlight",children:"Create one"})]})}):g.map(r=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/50 dark:hover:bg-zinc-800/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"font-mono text-azure-text-primary dark:text-matrix-secondary font-medium",children:r.name})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"text-xs font-mono text-azure-text-secondary dark:text-matrix-secondary truncate max-w-[140px]",children:[r.api_key.slice(0,16),"…"]}),e.jsx("button",{onClick:()=>w(I(r),`curl-${r.id}`),className:"p-1 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary",title:"Copy curl example",children:j===`curl-${r.id}`?e.jsx(_,{className:"w-3.5 h-3.5 text-green-500"}):e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>w(r.api_key,`key-${r.id}`),className:"p-1 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary",title:"Copy API key",children:j===`key-${r.id}`?e.jsx(_,{className:"w-3.5 h-3.5 text-green-500"}):e.jsx(G,{className:"w-3.5 h-3.5"})})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.notification_channels.map(t=>e.jsx("span",{className:"px-2 py-0.5 text-xs rounded bg-azure-border dark:bg-matrix-primary/20 text-azure-text-secondary dark:text-matrix-secondary capitalize",children:t},t))})}),e.jsx("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-secondary",children:r.trigger_count}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>O(r),className:`flex items-center gap-1.5 text-xs px-2 py-1 rounded transition-colors ${r.enabled?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400 hover:bg-green-100 dark:hover:bg-green-900/30":"bg-zinc-100 dark:bg-zinc-800 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-200 dark:hover:bg-zinc-700"}`,children:r.enabled?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3.5 h-3.5"})," Enabled"]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"w-3.5 h-3.5"})," Disabled"]})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>$(r),title:"Edit",className:"p-1.5 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(V,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>m(r),title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-azure-text-secondary dark:text-matrix-secondary hover:text-red-600 dark:hover:text-red-400 transition-colors",children:e.jsx(Y,{className:"w-4 h-4"})})]})})]},r.id))})]})})}),e.jsxs(C,{open:W,onOpenChange:n,children:[e.jsx(T,{children:e.jsx(S,{className:"text-azure-text-primary dark:text-matrix-highlight",children:o?"Edit Webhook":"New Webhook"})}),e.jsxs("div",{className:"p-6 space-y-4 overflow-y-auto",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:["Name ",e.jsx("span",{className:"text-azure-text-muted dark:text-matrix-secondary/60 font-normal",children:"(slug — used in URL)"})]}),e.jsx("input",{type:"text",value:a.name,onChange:r=>{d({...a,name:r.target.value.toLowerCase().replace(/\s+/g,"-")}),i(null)},placeholder:"e.g. deploy-done, github-issue-opened",disabled:!!o,className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight disabled:opacity-50 disabled:cursor-not-allowed"}),a.name&&e.jsxs("p",{className:"mt-1 text-xs text-azure-text-secondary dark:text-matrix-secondary",children:["Trigger URL:"," ",e.jsxs("code",{className:"font-mono text-azure-primary dark:text-matrix-highlight",children:["POST /api/webhooks/trigger/",a.name]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Agent Prompt"}),e.jsx("textarea",{rows:5,value:a.prompt,onChange:r=>d({...a,prompt:r.target.value}),placeholder:"Describe what Apoc should do when this webhook fires. The received payload will be appended automatically.",className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:"Notification Channels"}),e.jsx("div",{className:"flex gap-4",children:ee.map(r=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a.notification_channels.includes(r),onChange:()=>R(r),className:"rounded border-azure-border dark:border-matrix-primary accent-azure-primary dark:accent-matrix-highlight"}),e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary capitalize",children:r})]},r))})]}),z&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded px-3 py-2",children:z}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>n(!1),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:L,disabled:k||!a.name.trim()||!a.prompt.trim()||a.notification_channels.length===0,className:"px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 disabled:opacity-50 transition-opacity",children:k?"Saving…":o?"Update":"Create"})]})]})]}),e.jsxs(C,{open:!!x,onOpenChange:r=>!r&&m(null),children:[e.jsx(T,{children:e.jsx(S,{className:"text-azure-text-primary dark:text-matrix-highlight",children:"Delete Webhook"})}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("p",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Delete"," ",e.jsx("span",{className:"font-semibold font-mono dark:text-matrix-highlight",children:x?.name}),"? This also removes all associated notifications and cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>m(null),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:P,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition-colors",children:"Delete"})]})]})]})]})};export{ne as WebhookManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as r}from"./vendor-utils-D4NnWbOU.js";import{h as i}from"./index-
|
|
1
|
+
import{u as r}from"./vendor-utils-D4NnWbOU.js";import{h as i}from"./index-BxN2w9sY.js";function m(){const{data:t,error:s,isLoading:e,mutate:a}=r("/audit/global",o=>i.get(o),{revalidateOnFocus:!1,refreshInterval:3e4});return{data:t,error:s,isLoading:e,mutate:a}}function g(t,s=0,e=100){const a=e,o=s*e,{data:n,error:u,isLoading:l}=r(t?`/sessions/${t}/audit?limit=${a}&offset=${o}`:null,f=>i.get(f),{revalidateOnFocus:!1});return{data:n,error:u,isLoading:l}}export{m as a,g as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as t}from"./vendor-utils-D4NnWbOU.js";import{h as n}from"./index-
|
|
1
|
+
import{u as t}from"./vendor-utils-D4NnWbOU.js";import{h as n}from"./index-BxN2w9sY.js";function a(o){const e=new URLSearchParams;o?.enabled!==void 0&&e.set("enabled",String(o.enabled)),o?.created_by&&e.set("created_by",o.created_by),o?.page!==void 0&&e.set("page",String(o.page)),o?.per_page!==void 0&&e.set("per_page",String(o.per_page));const s=e.toString()?`?${e}`:"";return t(`/chronos${s}`,()=>n.get(`/chronos${s}`))}function i(o,e=50){return t(o?`/chronos/${o}/executions?limit=${e}`:null,()=>n.get(`/chronos/${o}/executions?limit=${e}`))}function h(){return t("/config/chronos",()=>n.get("/config/chronos"))}const p={createJob:o=>n.post("/chronos",o),updateJob:(o,e)=>n.put(`/chronos/${o}`,e),deleteJob:o=>n.delete(`/chronos/${o}`),enableJob:o=>n.patch(`/chronos/${o}/enable`,{}),disableJob:o=>n.patch(`/chronos/${o}/disable`,{}),getConfig:()=>n.get("/config/chronos"),updateConfig:o=>n.post("/config/chronos",o),preview:(o,e,s)=>n.post("/chronos/preview",{expression:o,schedule_type:e,timezone:s})};export{i as a,a as b,p as c,h as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{t as o}from"./vendor-utils-D4NnWbOU.js";import{h as t}from"./index-
|
|
1
|
+
import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{t as o}from"./vendor-utils-D4NnWbOU.js";import{h as t}from"./index-BxN2w9sY.js";function d({label:e,error:n,helperText:a,className:s,...i}){return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),r.jsx("input",{type:"number",className:o("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors",n&&"border-red-500 focus:border-red-500 focus:ring-red-500",s),...i}),a&&!n&&r.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:a}),n&&r.jsx("p",{className:"text-xs text-red-500",children:n})]})}function l({label:e,checked:n,onChange:a,helperText:s,disabled:i}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:o("text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",i&&"opacity-50"),children:e}),s&&r.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:s})]}),r.jsx("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>!i&&a(!n),className:o("relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:ring-offset-2 focus:ring-offset-azure-bg dark:focus:ring-offset-black",n?"bg-azure-primary dark:bg-matrix-highlight":"bg-slate-300 dark:bg-matrix-primary",i&&"opacity-50 cursor-not-allowed"),children:r.jsx("span",{className:o("inline-block h-4 w-4 transform rounded-full bg-white dark:bg-black transition-transform",n?"translate-x-6":"translate-x-1")})})]})}const m={fetchConfig:async()=>t.get("/config"),updateConfig:async e=>t.post("/config",e),getSatiConfig:async()=>t.get("/config/sati"),updateSatiConfig:async e=>t.post("/config/sati",e),deleteSatiConfig:async()=>t.delete("/config/sati"),getApocConfig:async()=>t.get("/config/apoc"),updateApocConfig:async e=>t.post("/config/apoc",e),deleteApocConfig:async()=>t.delete("/config/apoc"),getNeoConfig:async()=>t.get("/config/neo"),updateNeoConfig:async e=>t.post("/config/neo",e),deleteNeoConfig:async()=>t.delete("/config/neo"),getTrinityConfig:async()=>t.get("/config/trinity"),updateTrinityConfig:async e=>t.post("/config/trinity",e),deleteTrinityConfig:async()=>t.delete("/config/trinity"),getEncryptionStatus:async()=>t.get("/config/encryption-status"),getEnvOverrides:async()=>t.get("/config/env-overrides"),getSmithsConfig:async()=>await t.get("/smiths/config"),updateSmithsConfig:async e=>t.put("/smiths/config",e),getSmithsList:async()=>t.get("/smiths"),pingSmith:async e=>t.post(`/smiths/${e}/ping`,{}),removeSmith:async e=>t.delete(`/smiths/${e}`)};export{d as N,l as S,m as c};
|