@objectstack/console 9.0.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DoGxClbR.js";import{Bo as i,Da as a,Hn as o,Ko as s,Qn as c,Rr as l,Un as u,Vi as d,Wn as f,ds as p,ji as m,ms as h,ps as g,to as _,xr as v,yi as ee,zi as te}from"./ui-components-DeXgqLMc.js";import"./index-DMV3FQgO.js";var y=e(t(),1),b=[`plugin`,`plugins`,`kind`,`package`];function x(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var S={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function C(e,t){let n=S[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function ne(){let e=r(),[t,n]=(0,y.useState)([]),[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)(!0),[c,l]=(0,y.useState)(null),u=(0,y.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(S)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...C(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),m=d.filter(e=>!b.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...x(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`];n(Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,y.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var w=n(),T={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},re={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},ie=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],E=1;function D(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:b}=ne(),[x,S]=(0,y.useState)(``),[C,D]=(0,y.useState)(new Set),[O,k]=(0,y.useState)(null),[ae,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(``),[F,I]=(0,y.useState)([]),[L,R]=(0,y.useState)(!1),[z,B]=(0,y.useState)(null),[V,H]=(0,y.useState)([]),[U,oe]=(0,y.useState)(null),[W,G]=(0,y.useState)(!1),K=(0,y.useMemo)(()=>{if(!x)return t;let e=x.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,x]),se=(0,y.useCallback)(e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,y.useCallback)(e=>{k(e),A(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ae||O?.method||`GET`,J=j||O?.path||``,Y=(0,y.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());return e.length===0?J:`${J}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[J,F]),X=(0,y.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:E++,key:e,value:t,enabled:!0}])},[]),le=(0,y.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,y.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,y.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,y.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();B({status:r.status,body:a,duration:i}),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,y.useCallback)(e=>{A(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:E++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),k(null)},[]),fe=(0,y.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>re[String(e)[0]]??`text-muted-foreground`;return(0,w.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,w.jsx)(`button`,{onClick:b,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,w.jsx)(m,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(ee,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,w.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,w.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,w.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(a,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(_,{className:`h-6 w-6 opacity-30 mb-2`}),(0,w.jsx)(`span`,{children:x?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=C.has(e.key)||!!x;return(0,w.jsxs)(o,{open:t,onOpenChange:()=>se(e.key),children:[(0,w.jsx)(f,{asChild:!0,children:(0,w.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,w.jsx)(p,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,w.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,w.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,w.jsx)(u,{children:(0,w.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,w.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${O===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,w.jsx)(c,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${T[e.method]||``}`,children:e.method}),(0,w.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,w.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,w.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(te,{className:`h-3 w-3`}),`Add`]})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ie.map(e=>(0,w.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,w.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,w.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,w.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,w.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,w.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,w.jsx)(v,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`select`,{value:q,onChange:e=>A(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${T[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,w.jsx)(`option`,{value:e,children:e},e))}),(0,w.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,w.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,w.jsx)(a,{className:`h-3.5 w-3.5 animate-spin`}):(0,w.jsx)(d,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,w.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,w.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,w.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(a,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,w.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,w.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,w.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,w.jsx)(s,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,w.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,w.jsx)(h,{className:`h-3 w-3`}):(0,w.jsx)(i,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,w.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,w.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,w.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,w.jsx)(_,{className:`h-10 w-10 mx-auto opacity-20`}),(0,w.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,w.jsx)(`strong`,{children:`Send`})]}),(0,w.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,w.jsxs)(`div`,{className:`border-t`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,w.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,w.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(l,{className:`h-3 w-3`}),`Clear`]})]}),(0,w.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,w.jsxs)(`div`,{className:`rounded border`,children:[(0,w.jsxs)(`button`,{onClick:()=>oe(U===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[U===e.id?(0,w.jsx)(g,{className:`h-3 w-3 shrink-0`}):(0,w.jsx)(p,{className:`h-3 w-3 shrink-0`}),(0,w.jsx)(c,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${T[e.method]||``}`,children:e.method}),(0,w.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,w.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,w.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,w.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,w.jsx)(d,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,w.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{D as ApiConsolePage};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DoGxClbR.js";import{Bo as i,Da as a,Hn as o,Ko as s,Qn as c,Rr as l,Un as u,Vi as d,Wn as f,ds as p,ji as m,ms as h,ps as g,to as _,xr as v,yi as ee,zi as te}from"./ui-components-DeXgqLMc.js";import"./index-Bt0jFx__.js";var y=e(t(),1),b=[`plugin`,`plugins`,`kind`,`package`];function x(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var S={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function C(e,t){let n=S[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function ne(){let e=r(),[t,n]=(0,y.useState)([]),[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)(!0),[c,l]=(0,y.useState)(null),u=(0,y.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(S)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...C(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),m=d.filter(e=>!b.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...x(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`];n(Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,y.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var w=n(),T={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},re={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},ie=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],E=1;function D(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:b}=ne(),[x,S]=(0,y.useState)(``),[C,D]=(0,y.useState)(new Set),[O,k]=(0,y.useState)(null),[ae,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(``),[F,I]=(0,y.useState)([]),[L,R]=(0,y.useState)(!1),[z,B]=(0,y.useState)(null),[V,H]=(0,y.useState)([]),[U,oe]=(0,y.useState)(null),[W,G]=(0,y.useState)(!1),K=(0,y.useMemo)(()=>{if(!x)return t;let e=x.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,x]),se=(0,y.useCallback)(e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,y.useCallback)(e=>{k(e),A(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ae||O?.method||`GET`,J=j||O?.path||``,Y=(0,y.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());return e.length===0?J:`${J}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[J,F]),X=(0,y.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:E++,key:e,value:t,enabled:!0}])},[]),le=(0,y.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,y.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,y.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,y.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();B({status:r.status,body:a,duration:i}),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,y.useCallback)(e=>{A(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:E++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),k(null)},[]),fe=(0,y.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>re[String(e)[0]]??`text-muted-foreground`;return(0,w.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,w.jsx)(`button`,{onClick:b,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,w.jsx)(m,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(ee,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,w.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,w.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,w.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(a,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(_,{className:`h-6 w-6 opacity-30 mb-2`}),(0,w.jsx)(`span`,{children:x?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=C.has(e.key)||!!x;return(0,w.jsxs)(o,{open:t,onOpenChange:()=>se(e.key),children:[(0,w.jsx)(f,{asChild:!0,children:(0,w.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,w.jsx)(p,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,w.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,w.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,w.jsx)(u,{children:(0,w.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,w.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${O===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,w.jsx)(c,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${T[e.method]||``}`,children:e.method}),(0,w.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,w.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,w.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(te,{className:`h-3 w-3`}),`Add`]})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ie.map(e=>(0,w.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,w.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,w.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,w.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,w.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,w.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,w.jsx)(v,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`select`,{value:q,onChange:e=>A(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${T[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,w.jsx)(`option`,{value:e,children:e},e))}),(0,w.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,w.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,w.jsx)(a,{className:`h-3.5 w-3.5 animate-spin`}):(0,w.jsx)(d,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,w.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,w.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,w.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,w.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,w.jsx)(a,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,w.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,w.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,w.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,w.jsx)(s,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,w.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,w.jsx)(h,{className:`h-3 w-3`}):(0,w.jsx)(i,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,w.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,w.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,w.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,w.jsx)(_,{className:`h-10 w-10 mx-auto opacity-20`}),(0,w.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,w.jsx)(`strong`,{children:`Send`})]}),(0,w.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,w.jsxs)(`div`,{className:`border-t`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,w.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,w.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(l,{className:`h-3 w-3`}),`Clear`]})]}),(0,w.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,w.jsxs)(`div`,{className:`rounded border`,children:[(0,w.jsxs)(`button`,{onClick:()=>oe(U===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[U===e.id?(0,w.jsx)(g,{className:`h-3 w-3 shrink-0`}):(0,w.jsx)(p,{className:`h-3 w-3 shrink-0`}),(0,w.jsx)(c,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${T[e.method]||``}`,children:e.method}),(0,w.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,w.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,w.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,w.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,w.jsx)(d,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,w.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{D as ApiConsolePage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{T as a}from"./framework-DoGxClbR.js";import{$r as o,Br as s,Fa as c,Gn as l,Ki as u,Kn as d,Oo as f,Qn as p,Rr as m,en as h,mr as g,qn as _,yi as v,zi as y,zr as b}from"./ui-components-DeXgqLMc.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-DMV3FQgO.js";var S=e(t(),1);function C(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var w=r();function T(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,{apps:T,refresh:E}=a(),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(new Set),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(!1),F=(T||[]).filter(e=>{if(!D)return!0;let t=D.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),I=(0,S.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=(0,S.useCallback)(()=>{k.size===F.length?A(new Set):A(new Set(F.map(e=>e.name)))},[k.size,F]),R=(0,S.useCallback)(async e=>{P(!0);try{let t=e.active===!1;x.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await E()}catch{x.error(`Failed to toggle app status`)}finally{P(!1)}},[E]),z=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${e.label||e.name} set as default`),await E()}catch{x.error(`Failed to set default app`)}finally{P(!1)}},[E]),B=(0,S.useCallback)(async e=>{if(j!==e.name){M(e.name);return}P(!0);try{x.success(`${e.label||e.name} deleted`),M(null),await E()}catch{x.error(`Failed to delete app`)}finally{P(!1)}},[j,E]),V=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${k.size} apps ${e?`enabled`:`disabled`}`),A(new Set),await E()}catch{x.error(`Bulk operation failed`)}finally{P(!1)}},[k,E]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,w.jsxs)(g,{onClick:()=>e(`${r}/create-app`),"data-testid":`create-app-btn`,children:[(0,w.jsx)(y,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,w.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,w.jsx)(v,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(h,{id:`app-search`,placeholder:`Search apps...`,value:D,onChange:e=>O(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),k.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(p,{variant:`secondary`,children:[k.size,` selected`]}),(0,w.jsx)(g,{variant:`outline`,size:`sm`,onClick:()=>V(!0),disabled:N,children:`Enable`}),(0,w.jsx)(g,{variant:`outline`,size:`sm`,onClick:()=>V(!1),disabled:N,children:`Disable`})]})]}),F.length>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(l,{id:`select-all-apps`,checked:k.size===F.length&&F.length>0,onCheckedChange:()=>L()}),(0,w.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,F.length,`)`]})]}),F.length===0?(0,w.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,w.jsx)(c,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{children:`No apps found.`})]}):(0,w.jsx)(`div`,{className:`grid gap-3`,children:F.map(t=>{let n=t.active!==!1,i=t.isDefault===!0,a=j===t.name;return(0,w.jsx)(d,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,w.jsxs)(_,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,w.jsx)(l,{id:`select-app-${t.name}`,checked:k.has(t.name),onCheckedChange:()=>I(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,w.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,w.jsx)(c,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`font-medium truncate`,children:C(t.label)||t.name}),i&&(0,w.jsx)(p,{variant:`default`,className:`text-xs`,children:`Default`}),(0,w.jsx)(p,{variant:n?`secondary`:`outline`,className:`text-xs`,children:n?`Active`:`Inactive`})]}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:C(t.description)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t.name}`),children:(0,w.jsx)(f,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${r}/edit-app/${t.name}`),children:(0,w.jsx)(u,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:n?`Disable app`:`Enable app`,"aria-label":n?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>R(t),disabled:N,children:n?(0,w.jsx)(b,{className:`h-4 w-4`}):(0,w.jsx)(s,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>z(t),disabled:N||i,children:(0,w.jsx)(o,{className:`h-4 w-4 ${i?`fill-current text-yellow-500`:``}`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:a?`Click again to confirm delete`:`Delete app`,"aria-label":a?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>B(t),disabled:N,className:a?`text-destructive`:``,children:(0,w.jsx)(m,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{T as AppManagementPage};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{T as a}from"./framework-DoGxClbR.js";import{$r as o,Br as s,Fa as c,Gn as l,Ki as u,Kn as d,Oo as f,Qn as p,Rr as m,en as h,mr as g,qn as _,yi as v,zi as y,zr as b}from"./ui-components-DeXgqLMc.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-Bt0jFx__.js";var S=e(t(),1);function C(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var w=r();function T(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,{apps:T,refresh:E}=a(),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(new Set),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(!1),F=(T||[]).filter(e=>{if(!D)return!0;let t=D.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),I=(0,S.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=(0,S.useCallback)(()=>{k.size===F.length?A(new Set):A(new Set(F.map(e=>e.name)))},[k.size,F]),R=(0,S.useCallback)(async e=>{P(!0);try{let t=e.active===!1;x.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await E()}catch{x.error(`Failed to toggle app status`)}finally{P(!1)}},[E]),z=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${e.label||e.name} set as default`),await E()}catch{x.error(`Failed to set default app`)}finally{P(!1)}},[E]),B=(0,S.useCallback)(async e=>{if(j!==e.name){M(e.name);return}P(!0);try{x.success(`${e.label||e.name} deleted`),M(null),await E()}catch{x.error(`Failed to delete app`)}finally{P(!1)}},[j,E]),V=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${k.size} apps ${e?`enabled`:`disabled`}`),A(new Set),await E()}catch{x.error(`Bulk operation failed`)}finally{P(!1)}},[k,E]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,w.jsxs)(g,{onClick:()=>e(`${r}/create-app`),"data-testid":`create-app-btn`,children:[(0,w.jsx)(y,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,w.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,w.jsx)(v,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(h,{id:`app-search`,placeholder:`Search apps...`,value:D,onChange:e=>O(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),k.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(p,{variant:`secondary`,children:[k.size,` selected`]}),(0,w.jsx)(g,{variant:`outline`,size:`sm`,onClick:()=>V(!0),disabled:N,children:`Enable`}),(0,w.jsx)(g,{variant:`outline`,size:`sm`,onClick:()=>V(!1),disabled:N,children:`Disable`})]})]}),F.length>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(l,{id:`select-all-apps`,checked:k.size===F.length&&F.length>0,onCheckedChange:()=>L()}),(0,w.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,F.length,`)`]})]}),F.length===0?(0,w.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,w.jsx)(c,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{children:`No apps found.`})]}):(0,w.jsx)(`div`,{className:`grid gap-3`,children:F.map(t=>{let n=t.active!==!1,i=t.isDefault===!0,a=j===t.name;return(0,w.jsx)(d,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,w.jsxs)(_,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,w.jsx)(l,{id:`select-app-${t.name}`,checked:k.has(t.name),onCheckedChange:()=>I(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,w.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,w.jsx)(c,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`font-medium truncate`,children:C(t.label)||t.name}),i&&(0,w.jsx)(p,{variant:`default`,className:`text-xs`,children:`Default`}),(0,w.jsx)(p,{variant:n?`secondary`:`outline`,className:`text-xs`,children:n?`Active`:`Inactive`})]}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:C(t.description)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t.name}`),children:(0,w.jsx)(f,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${r}/edit-app/${t.name}`),children:(0,w.jsx)(u,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:n?`Disable app`:`Enable app`,"aria-label":n?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>R(t),disabled:N,children:n?(0,w.jsx)(b,{className:`h-4 w-4`}):(0,w.jsx)(s,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>z(t),disabled:N||i,children:(0,w.jsx)(o,{className:`h-4 w-4 ${i?`fill-current text-yellow-500`:``}`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:a?`Click again to confirm delete`:`Delete app`,"aria-label":a?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>B(t),disabled:N,className:a?`text-destructive`:``,children:(0,w.jsx)(m,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{T as AppManagementPage};
@@ -1 +1 @@
1
- import"./rolldown-runtime-CMxvf4Kt.js";import{_ as e,f as t,p as n,t as r}from"./vendor-react-DR370ovB.js";import{B as i,I as a,L as o}from"./ui-components-DeXgqLMc.js";import{t as s}from"./index-DMV3FQgO.js";e();var c=r();function l({extraProps:e}={}){let r=t(),[l]=n(),u=r.ns,d=r.name,f=u&&d?`${u}:${d}`:u??``,p=s(f);if(!p)return(0,c.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,c.jsxs)(a,{children:[(0,c.jsx)(i,{children:`Component not registered`}),(0,c.jsxs)(o,{children:[`No component is registered for `,(0,c.jsx)(`code`,{className:`font-mono`,children:f||`(empty)`}),`. Ensure the plugin that provides this surface is installed and has called`,(0,c.jsx)(`code`,{className:`font-mono`,children:` registerAppComponent()`}),`.`]})]})});let m={};for(let[e,t]of l.entries())m[e]=t;let h=p.component;return(0,c.jsx)(h,{...m,...e??{}})}export{l as ComponentNavView,l as default};
1
+ import"./rolldown-runtime-CMxvf4Kt.js";import{_ as e,f as t,p as n,t as r}from"./vendor-react-DR370ovB.js";import{B as i,I as a,L as o}from"./ui-components-DeXgqLMc.js";import{t as s}from"./index-Bt0jFx__.js";e();var c=r();function l({extraProps:e}={}){let r=t(),[l]=n(),u=r.ns,d=r.name,f=u&&d?`${u}:${d}`:u??``,p=s(f);if(!p)return(0,c.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,c.jsxs)(a,{children:[(0,c.jsx)(i,{children:`Component not registered`}),(0,c.jsxs)(o,{children:[`No component is registered for `,(0,c.jsx)(`code`,{className:`font-mono`,children:f||`(empty)`}),`. Ensure the plugin that provides this surface is installed and has called`,(0,c.jsx)(`code`,{className:`font-mono`,children:` registerAppComponent()`}),`.`]})]})});let m={};for(let[e,t]of l.entries())m[e]=t;let h=p.component;return(0,c.jsx)(h,{...m,...e??{}})}export{l as ComponentNavView,l as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n,u as r}from"./vendor-react-DR370ovB.js";import{r as i}from"./framework-DoGxClbR.js";import{Bt as a,Ht as o,Rt as s,S as c,Vt as l,hi as u,mr as d,ni as f,zt as p}from"./ui-components-DeXgqLMc.js";import{r as m}from"./vendor-ui-utils-rQOI1gAo.js";import{i as h}from"./runtime-config-ir5bt3TX.js";import{d as g,f as _,l as v,r as y,t as b,u as x}from"./plugin-chatbot-DUla2_T9.js";import{a as ee,i as S,n as C,o as w,r as T}from"./index-DMV3FQgO.js";var E=e(t(),1),D=n(),O={data_chat:{zh:`数据助手`,en:`Data Assistant`},metadata_assistant:{zh:`元数据开发助手`,en:`Metadata Assistant`}};function k(e,t,n){let r=t?O[t]:void 0;return r?e?r.zh:r.en:n}function A(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=k(a,n,r),s=i.slice(0,2).map(e=>e.label||e.name);if(a){let e=[s[0]?`查询最近创建的${s[0]}`:`帮我查询最近的数据`,s[0]?`统计${s[0]}的总数量`:`统计各对象的记录数量`,s[1]?`${s[1]}有哪些字段?`:`当前应用里有哪些数据对象?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`你好,我是${o}`,emptyDescription:`随时帮你查询和分析「${t}」中的数据。试试下面的问题,或直接输入你的需求。`,clear:`清空对话`,sendHint:`发送`,agentActivity:`执行过程`,toolCompleted:`已完成`,toolRunning:`运行中`,toolAwaitingApproval:`等待确认`,toolFailed:`失败`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,publishOk:`已发布,对象已生效。`,publishFailed:`发布失败`,seedWarn:`已发布,但部分示例数据未能载入。`,openBuiltApp:`打开应用`,suggestions:e}}let c=[s[0]?`Show the latest ${s[0]}`:`Show my most recent records`,s[0]?`How many ${s[0]} are there?`:`Count records by status`,s[1]?`What fields does ${s[1]} have?`:`What data can I work with here?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`Hi, I'm ${o}`,emptyDescription:`I can help you query and analyze your ${t} data. Try a prompt below, or just type your question.`,clear:`Clear`,sendHint:`to send`,agentActivity:`Agent activity`,toolCompleted:`Completed`,toolRunning:`Running`,toolAwaitingApproval:`Awaiting approval`,toolFailed:`Failed`,toolDetailsHidden:`Tool inputs and raw results are hidden in this view.`,copy:`Copy`,copied:`Copied`,regenerate:`Regenerate`,model:`Model`,submit:`Submit`,uploadFiles:`Upload files`,stopResponse:`Stop response`,trace:`trace`,viewTrace:`View trace`},placeholder:`Ask ${o}...`,loadingPlaceholder:`Loading assistant...`,title:`${t} Assistant`,newChat:`New chat`,share:`Share conversation`,reviewDraft:e=>`Review ${e} change${e===1?``:`s`}`,publishDrafts:`Publish`,published:`Published`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var j=`/api/v1/ai`;function M(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${j}`}function N(e,t){if(!e||e.type!==`object`)return null;let n=e.label||e.name||`this object`;return(t??``).toLowerCase().startsWith(`zh`)?[`为「${n}」补充字段`,`为「${n}」建议校验规则`,`添加一个状态选项字段`]:[`Add fields to ${n}`,`Suggest validations for ${n}`,`Add a status picklist field`]}function P({appLabel:e,appName:t,objects:n,agents:v,agentsLoading:x,activeAgent:T,onAgentChange:O,showAgentPicker:k,chatApi:j,apiBase:M,defaultOpen:P=!1,conversationId:F,initialMessages:I}){let{language:L}=i(),R=r(),{editor:z}=w(),B=E.useMemo(()=>!I||I.length===0?[]:_(I),[I]),V=E.useMemo(()=>v.find(e=>e.name===T)?.label??T??e,[v,T,e]),H=E.useMemo(()=>A(L,e,T,V,n),[L,e,T,V,n]),U=E.useMemo(()=>N(z,L),[z,L]),{messages:W,isLoading:G,error:K,sendMessage:q,stop:J,reload:Y,clear:X}=g({api:j,conversationId:F,body:{context:{activeApp:e,appName:t,objects:n.map(e=>({name:e.name,label:e.label})),agentName:T,autoPublishAiBuilds:h().features.autoPublishAiBuilds,...z?{editing:z}:{}}},initialMessages:B,autoResponse:!j,autoResponseText:n.length>0?`I can help you work with ${n.map(e=>e.label||e.name).join(`, `)}. What would you like to do?`:`Thanks for your message! I'm here to help you navigate and manage your data.`,autoResponseDelay:600});E.useEffect(()=>{S(F,C(W))},[F,W]);let Z=b({messages:W,apiBase:M,continueConversation:e=>{q(e)}}),Q=k&&v.length>1?(0,D.jsxs)(s,{value:T,onValueChange:O,disabled:x,children:[(0,D.jsx)(l,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,D.jsx)(o,{placeholder:`Choose agent...`})}),(0,D.jsx)(p,{align:`end`,children:v.map(e=>(0,D.jsxs)(a,{value:e.name,className:`text-xs`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,D.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[te,$]=E.useState(!1),ne=E.useMemo(()=>M.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[M]),re=(0,D.jsxs)(D.Fragment,{children:[W.length>0?(0,D.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":H.newChat,title:H.newChat,"data-testid":`floating-chatbot-new`,onClick:X,children:(0,D.jsx)(f,{className:`h-4 w-4`})}):null,F?(0,D.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":H.share,title:H.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,D.jsx)(u,{className:`h-4 w-4`})}):null]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(y,{floatingConfig:{position:`bottom-right`,defaultOpen:P,panelWidth:420,panelHeight:560,title:H.title,triggerSize:56},headerExtra:Q,headerActions:re,messages:W,labels:H.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:H.agentLabel,suggestions:W.length===0?U??H.suggestions:void 0,placeholder:T?H.placeholder:x?H.loadingPlaceholder:H.placeholder,onSendMessage:e=>q(e),onClear:X,onStop:G?J:void 0,onReload:Y,isLoading:G,error:K,enableMarkdown:!0,onToolApprove:Z.decide,toolDecisions:Z.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&ee(e[0])},toolReviewLabel:H.reviewDraft,onOpenBuiltApp:e=>R(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:H.openBuiltApp,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;i&&i.success===!1?m.warning(H.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):m.success(H.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&R(`/apps/${encodeURIComponent(a.name)}`),!0}catch(e){return m.error(H.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:H.publishDrafts,publishedLabel:H.published,autoPublishDrafts:h().features.autoPublishAiBuilds}),F&&(0,D.jsx)(c,{open:te,onOpenChange:$,objectName:`ai_conversations`,recordId:F,recordLabel:`this conversation`,apiBase:ne})]})}function F({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=E.useMemo(()=>M(r),[r]),l={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},u=l.VITE_AI_DEFAULT_AGENT,d=a??l.VITE_AI_SHOW_AGENT_PICKER===`true`,{agents:f,isLoading:p,error:m}=x({apiBase:c}),[h,g]=E.useState(void 0);E.useEffect(()=>{if(!h&&f.length>0){let e=v(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:y,initialMessages:b}=T({userId:s,scope:h,apiBase:c});return(0,D.jsx)(P,{appLabel:e,appName:t,objects:n,agents:f,agentsLoading:p,agentsError:m,activeAgent:h,onAgentChange:g,showAgentPicker:d,chatApi:_,apiBase:c,defaultOpen:o,conversationId:y,initialMessages:b},`${_??`local`}:${y??`pending`}`)}export{F as default};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n,u as r}from"./vendor-react-DR370ovB.js";import{r as i}from"./framework-DoGxClbR.js";import{Bt as a,Ht as o,Rt as s,S as c,Vt as l,hi as u,mr as d,ni as f,zt as p}from"./ui-components-DeXgqLMc.js";import{r as m}from"./vendor-ui-utils-rQOI1gAo.js";import{i as h}from"./runtime-config-ir5bt3TX.js";import{d as g,f as _,l as v,r as y,t as b,u as x}from"./plugin-chatbot-DUla2_T9.js";import{a as ee,i as S,n as C,o as w,r as T}from"./index-Bt0jFx__.js";var E=e(t(),1),D=n(),O={data_chat:{zh:`数据助手`,en:`Data Assistant`},metadata_assistant:{zh:`元数据开发助手`,en:`Metadata Assistant`}};function k(e,t,n){let r=t?O[t]:void 0;return r?e?r.zh:r.en:n}function A(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=k(a,n,r),s=i.slice(0,2).map(e=>e.label||e.name);if(a){let e=[s[0]?`查询最近创建的${s[0]}`:`帮我查询最近的数据`,s[0]?`统计${s[0]}的总数量`:`统计各对象的记录数量`,s[1]?`${s[1]}有哪些字段?`:`当前应用里有哪些数据对象?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`你好,我是${o}`,emptyDescription:`随时帮你查询和分析「${t}」中的数据。试试下面的问题,或直接输入你的需求。`,clear:`清空对话`,sendHint:`发送`,agentActivity:`执行过程`,toolCompleted:`已完成`,toolRunning:`运行中`,toolAwaitingApproval:`等待确认`,toolFailed:`失败`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,publishOk:`已发布,对象已生效。`,publishFailed:`发布失败`,seedWarn:`已发布,但部分示例数据未能载入。`,openBuiltApp:`打开应用`,suggestions:e}}let c=[s[0]?`Show the latest ${s[0]}`:`Show my most recent records`,s[0]?`How many ${s[0]} are there?`:`Count records by status`,s[1]?`What fields does ${s[1]} have?`:`What data can I work with here?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`Hi, I'm ${o}`,emptyDescription:`I can help you query and analyze your ${t} data. Try a prompt below, or just type your question.`,clear:`Clear`,sendHint:`to send`,agentActivity:`Agent activity`,toolCompleted:`Completed`,toolRunning:`Running`,toolAwaitingApproval:`Awaiting approval`,toolFailed:`Failed`,toolDetailsHidden:`Tool inputs and raw results are hidden in this view.`,copy:`Copy`,copied:`Copied`,regenerate:`Regenerate`,model:`Model`,submit:`Submit`,uploadFiles:`Upload files`,stopResponse:`Stop response`,trace:`trace`,viewTrace:`View trace`},placeholder:`Ask ${o}...`,loadingPlaceholder:`Loading assistant...`,title:`${t} Assistant`,newChat:`New chat`,share:`Share conversation`,reviewDraft:e=>`Review ${e} change${e===1?``:`s`}`,publishDrafts:`Publish`,published:`Published`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var j=`/api/v1/ai`;function M(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${j}`}function N(e,t){if(!e||e.type!==`object`)return null;let n=e.label||e.name||`this object`;return(t??``).toLowerCase().startsWith(`zh`)?[`为「${n}」补充字段`,`为「${n}」建议校验规则`,`添加一个状态选项字段`]:[`Add fields to ${n}`,`Suggest validations for ${n}`,`Add a status picklist field`]}function P({appLabel:e,appName:t,objects:n,agents:v,agentsLoading:x,activeAgent:T,onAgentChange:O,showAgentPicker:k,chatApi:j,apiBase:M,defaultOpen:P=!1,conversationId:F,initialMessages:I}){let{language:L}=i(),R=r(),{editor:z}=w(),B=E.useMemo(()=>!I||I.length===0?[]:_(I),[I]),V=E.useMemo(()=>v.find(e=>e.name===T)?.label??T??e,[v,T,e]),H=E.useMemo(()=>A(L,e,T,V,n),[L,e,T,V,n]),U=E.useMemo(()=>N(z,L),[z,L]),{messages:W,isLoading:G,error:K,sendMessage:q,stop:J,reload:Y,clear:X}=g({api:j,conversationId:F,body:{context:{activeApp:e,appName:t,objects:n.map(e=>({name:e.name,label:e.label})),agentName:T,autoPublishAiBuilds:h().features.autoPublishAiBuilds,...z?{editing:z}:{}}},initialMessages:B,autoResponse:!j,autoResponseText:n.length>0?`I can help you work with ${n.map(e=>e.label||e.name).join(`, `)}. What would you like to do?`:`Thanks for your message! I'm here to help you navigate and manage your data.`,autoResponseDelay:600});E.useEffect(()=>{S(F,C(W))},[F,W]);let Z=b({messages:W,apiBase:M,continueConversation:e=>{q(e)}}),Q=k&&v.length>1?(0,D.jsxs)(s,{value:T,onValueChange:O,disabled:x,children:[(0,D.jsx)(l,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,D.jsx)(o,{placeholder:`Choose agent...`})}),(0,D.jsx)(p,{align:`end`,children:v.map(e=>(0,D.jsxs)(a,{value:e.name,className:`text-xs`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,D.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[te,$]=E.useState(!1),ne=E.useMemo(()=>M.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[M]),re=(0,D.jsxs)(D.Fragment,{children:[W.length>0?(0,D.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":H.newChat,title:H.newChat,"data-testid":`floating-chatbot-new`,onClick:X,children:(0,D.jsx)(f,{className:`h-4 w-4`})}):null,F?(0,D.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":H.share,title:H.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,D.jsx)(u,{className:`h-4 w-4`})}):null]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(y,{floatingConfig:{position:`bottom-right`,defaultOpen:P,panelWidth:420,panelHeight:560,title:H.title,triggerSize:56},headerExtra:Q,headerActions:re,messages:W,labels:H.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:H.agentLabel,suggestions:W.length===0?U??H.suggestions:void 0,placeholder:T?H.placeholder:x?H.loadingPlaceholder:H.placeholder,onSendMessage:e=>q(e),onClear:X,onStop:G?J:void 0,onReload:Y,isLoading:G,error:K,enableMarkdown:!0,onToolApprove:Z.decide,toolDecisions:Z.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&ee(e[0])},toolReviewLabel:H.reviewDraft,onOpenBuiltApp:e=>R(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:H.openBuiltApp,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;i&&i.success===!1?m.warning(H.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):m.success(H.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&R(`/apps/${encodeURIComponent(a.name)}`),!0}catch(e){return m.error(H.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:H.publishDrafts,publishedLabel:H.published,autoPublishDrafts:h().features.autoPublishAiBuilds}),F&&(0,D.jsx)(c,{open:te,onOpenChange:$,objectName:`ai_conversations`,recordId:F,recordLabel:`this conversation`,apiBase:ne})]})}function F({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=E.useMemo(()=>M(r),[r]),l={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},u=l.VITE_AI_DEFAULT_AGENT,d=a??l.VITE_AI_SHOW_AGENT_PICKER===`true`,{agents:f,isLoading:p,error:m}=x({apiBase:c}),[h,g]=E.useState(void 0);E.useEffect(()=>{if(!h&&f.length>0){let e=v(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:y,initialMessages:b}=T({userId:s,scope:h,apiBase:c});return(0,D.jsx)(P,{appLabel:e,appName:t,objects:n,agents:f,agentsLoading:p,agentsError:m,activeAgent:h,onAgentChange:g,showAgentPicker:d,chatApi:_,apiBase:c,defaultOpen:o,conversationId:y,initialMessages:b},`${_??`local`}:${y??`pending`}`)}export{F as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DoGxClbR.js";import{$ as i,At as a,Cr as o,Da as s,Ft as c,It as l,Jn as u,Kn as d,Ko as f,Mt as p,Nt as m,Pt as h,Qn as g,Ut as _,Vi as v,Xn as y,Yn as b,Zo as x,as as S,at as C,ct as w,en as T,in as E,it as D,ji as O,lt as k,mr as A,ot as j,qn as M,ss as N,st as P,ut as F}from"./ui-components-DeXgqLMc.js";import"./index-DMV3FQgO.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:S,cls:`text-emerald-600 border-emerald-300`},completed:{icon:S,cls:`text-emerald-600 border-emerald-300`},failed:{icon:x,cls:`text-red-600 border-red-300`},error:{icon:x,cls:`text-red-600 border-red-300`},running:{icon:s,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:f,cls:`text-amber-600 border-amber-300`},skipped:{icon:N,cls:`text-muted-foreground`}}[e]??{icon:N,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(g,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,s]=(0,I.useState)(!0),[c,l]=(0,I.useState)(null),[f,p]=(0,I.useState)(``),[m,h]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),s(!1);return}s(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!f&&r.length>0&&p(r[0].name)}catch(e){l(e?.message??String(e))}finally{s(!1)}},[e,f]);(0,I.useEffect)(()=>{g()},[g]);let _=(0,I.useMemo)(()=>t.find(e=>e.name===f)??null,[t,f]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(o,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(d,{children:[(0,L.jsx)(b,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(y,{className:`text-base`,children:`Flow`}),(0,L.jsx)(u,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:g,disabled:i,children:[(0,L.jsx)(O,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(M,{children:[i&&(0,L.jsx)(a,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!i&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:f,onChange:e=>p(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),_&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:_.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:_.name,refreshKey:m})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,o]=(0,I.useState)({}),[c,l]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),p(null),h(null)},[t?.name]);let _=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(d,{children:[(0,L.jsxs)(b,{className:`pb-3`,children:[(0,L.jsx)(y,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(u,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(M,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(E,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(g,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(F,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>_(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(i,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(T,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(A,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}l(!0),h(null),p(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}p(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){h(e?.message??String(e))}finally{l(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(v,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(f||m)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[m||f?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(x,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(S,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof f?.durationMs==`number`&&(0,L.jsxs)(g,{variant:`secondary`,className:`text-[10px] font-mono`,children:[f.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),f&&(0,L.jsx)(V,{data:f})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,I.useState)([]),[o,f]=(0,I.useState)(!0),[v,x]=(0,I.useState)(null),[S,T]=(0,I.useState)(null),[E,N]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){x(`automation.listRuns is not available on this client`),f(!1);return}f(!0),x(null);try{let n=await e.automation.listRuns(t,{limit:20});i(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){x(e?.message??String(e))}finally{f(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{T(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(b,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(y,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(u,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:W,disabled:o,children:[o?(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(O,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(M,{children:[o&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(a,{className:`h-8 w-full`}),(0,L.jsx)(a,{className:`h-8 w-full`}),(0,L.jsx)(a,{className:`h-8 w-full`})]}),!o&&v&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:v}),!o&&!v&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!o&&!v&&r.length>0&&(0,L.jsxs)(D,{children:[(0,L.jsx)(w,{children:(0,L.jsxs)(k,{children:[(0,L.jsx)(P,{children:`Run`}),(0,L.jsx)(P,{children:`Status`}),(0,L.jsx)(P,{children:`Started`}),(0,L.jsx)(P,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(C,{children:r.map(e=>(0,L.jsxs)(k,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(j,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(j,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(j,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(j,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!S,onOpenChange:e=>{e||(T(null),N(null))},children:(0,L.jsxs)(m,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(c,{className:`p-4 border-b`,children:[(0,L.jsxs)(l,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(h,{children:E&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:E.status}),typeof E.durationMs==`number`&&(0,L.jsxs)(g,{variant:`secondary`,className:`text-[10px] font-mono`,children:[E.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(E.startedAt)})]})})]}),(0,L.jsxs)(_,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(a,{className:`h-16 w-full`}),(0,L.jsx)(a,{className:`h-16 w-full`}),(0,L.jsx)(a,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&E&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(E.steps)&&E.steps.length>0?E.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(g,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(g,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:E})]})})]})]})})]})}export{H as FlowRunsPage};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DoGxClbR.js";import{$ as i,At as a,Cr as o,Da as s,Ft as c,It as l,Jn as u,Kn as d,Ko as f,Mt as p,Nt as m,Pt as h,Qn as g,Ut as _,Vi as v,Xn as y,Yn as b,Zo as x,as as S,at as C,ct as w,en as T,in as E,it as D,ji as O,lt as k,mr as A,ot as j,qn as M,ss as N,st as P,ut as F}from"./ui-components-DeXgqLMc.js";import"./index-Bt0jFx__.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:S,cls:`text-emerald-600 border-emerald-300`},completed:{icon:S,cls:`text-emerald-600 border-emerald-300`},failed:{icon:x,cls:`text-red-600 border-red-300`},error:{icon:x,cls:`text-red-600 border-red-300`},running:{icon:s,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:f,cls:`text-amber-600 border-amber-300`},skipped:{icon:N,cls:`text-muted-foreground`}}[e]??{icon:N,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(g,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,s]=(0,I.useState)(!0),[c,l]=(0,I.useState)(null),[f,p]=(0,I.useState)(``),[m,h]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),s(!1);return}s(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!f&&r.length>0&&p(r[0].name)}catch(e){l(e?.message??String(e))}finally{s(!1)}},[e,f]);(0,I.useEffect)(()=>{g()},[g]);let _=(0,I.useMemo)(()=>t.find(e=>e.name===f)??null,[t,f]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(o,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(d,{children:[(0,L.jsx)(b,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(y,{className:`text-base`,children:`Flow`}),(0,L.jsx)(u,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:g,disabled:i,children:[(0,L.jsx)(O,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(M,{children:[i&&(0,L.jsx)(a,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!i&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:f,onChange:e=>p(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),_&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:_.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:_.name,refreshKey:m})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,o]=(0,I.useState)({}),[c,l]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),p(null),h(null)},[t?.name]);let _=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(d,{children:[(0,L.jsxs)(b,{className:`pb-3`,children:[(0,L.jsx)(y,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(u,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(M,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(E,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(g,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(F,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>_(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(i,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(T,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(A,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}l(!0),h(null),p(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}p(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){h(e?.message??String(e))}finally{l(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(v,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(f||m)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[m||f?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(x,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(S,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof f?.durationMs==`number`&&(0,L.jsxs)(g,{variant:`secondary`,className:`text-[10px] font-mono`,children:[f.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),f&&(0,L.jsx)(V,{data:f})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,I.useState)([]),[o,f]=(0,I.useState)(!0),[v,x]=(0,I.useState)(null),[S,T]=(0,I.useState)(null),[E,N]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){x(`automation.listRuns is not available on this client`),f(!1);return}f(!0),x(null);try{let n=await e.automation.listRuns(t,{limit:20});i(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){x(e?.message??String(e))}finally{f(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{T(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(b,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(y,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(u,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:W,disabled:o,children:[o?(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(O,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(M,{children:[o&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(a,{className:`h-8 w-full`}),(0,L.jsx)(a,{className:`h-8 w-full`}),(0,L.jsx)(a,{className:`h-8 w-full`})]}),!o&&v&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:v}),!o&&!v&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!o&&!v&&r.length>0&&(0,L.jsxs)(D,{children:[(0,L.jsx)(w,{children:(0,L.jsxs)(k,{children:[(0,L.jsx)(P,{children:`Run`}),(0,L.jsx)(P,{children:`Status`}),(0,L.jsx)(P,{children:`Started`}),(0,L.jsx)(P,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(C,{children:r.map(e=>(0,L.jsxs)(k,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(j,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(j,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(j,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(j,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!S,onOpenChange:e=>{e||(T(null),N(null))},children:(0,L.jsxs)(m,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(c,{className:`p-4 border-b`,children:[(0,L.jsxs)(l,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(h,{children:E&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:E.status}),typeof E.durationMs==`number`&&(0,L.jsxs)(g,{variant:`secondary`,className:`text-[10px] font-mono`,children:[E.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(E.startedAt)})]})})]}),(0,L.jsxs)(_,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(a,{className:`h-16 w-full`}),(0,L.jsx)(a,{className:`h-16 w-full`}),(0,L.jsx)(a,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&E&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(E.steps)&&E.steps.length>0?E.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(g,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(g,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:E})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DoGxClbR.js";import{Bn as i,Bo as a,Fn as o,In as s,Jn as ee,Kn as te,Ln as c,Ma as ne,Oo as l,Pi as re,Qn as ie,Rn as u,Wo as ae,Xn as oe,Yn as se,_i as ce,at as le,ct as ue,en as d,in as f,it as de,ji as fe,lt as p,mr as m,ot as h,qn as pe,st as g,zi as me,zn as _}from"./ui-components-DeXgqLMc.js";import{r as v}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-DMV3FQgO.js";var y=e(t(),1),b=n();function x(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[C,he]=(0,y.useState)([]),[w,T]=(0,y.useState)(!0),[E,D]=(0,y.useState)(null),[ge,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(!1),[_e,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(`thank-you`),[H,U]=(0,y.useState)(``),[W,G]=(0,y.useState)(``),[K,q]=(0,y.useState)(``),[J,Y]=(0,y.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=x(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,y.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),v.success(`Copied ${e}`)}catch{v.error(`Clipboard unavailable`)}},xe=async()=>{if(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){v.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),v.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{Y(!1)}},$=t.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,b.jsxs)(te,{children:[(0,b.jsxs)(se,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(oe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(re,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(ee,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(m,{variant:`default`,size:`sm`,onClick:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(me,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(m,{variant:`outline`,size:`sm`,onClick:X,disabled:w,children:[(0,b.jsx)(fe,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(pe,{children:[E&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(de,{children:[(0,b.jsx)(ue,{children:(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:`Name`}),(0,b.jsx)(g,{children:`Object`}),(0,b.jsx)(g,{children:`Slug`}),(0,b.jsx)(g,{children:`Public URL`}),(0,b.jsx)(g,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(le,{children:t.map(e=>{let t=Z(e.slug);return(0,b.jsxs)(p,{children:[(0,b.jsx)(h,{children:(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,b.jsx)(h,{children:e.object?(0,b.jsx)(ie,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(h,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(h,{children:(0,b.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,b.jsx)(l,{className:`h-3 w-3`})]})}),(0,b.jsx)(h,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,b.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(ce,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(o,{open:ge,onOpenChange:O,children:(0,b.jsxs)(s,{className:`sm:max-w-md`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(i,{children:`Publish a FormView`}),(0,b.jsxs)(c,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,b.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,b.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:k,onChange:e=>A(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(d,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(m,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,b.jsx)(m,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(o,{open:_e,onOpenChange:F,children:(0,b.jsxs)(s,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(i,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,b.jsx)(c,{children:`Configure the public URL and what happens after submit.`})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(d,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:B,onChange:e=>V(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),B===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(d,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(d,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(d,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(m,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,b.jsx)(m,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DoGxClbR.js";import{Bn as i,Bo as a,Fn as o,In as s,Jn as ee,Kn as te,Ln as c,Ma as ne,Oo as l,Pi as re,Qn as ie,Rn as u,Wo as ae,Xn as oe,Yn as se,_i as ce,at as le,ct as ue,en as d,in as f,it as de,ji as fe,lt as p,mr as m,ot as h,qn as pe,st as g,zi as me,zn as _}from"./ui-components-DeXgqLMc.js";import{r as v}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-Bt0jFx__.js";var y=e(t(),1),b=n();function x(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[C,he]=(0,y.useState)([]),[w,T]=(0,y.useState)(!0),[E,D]=(0,y.useState)(null),[ge,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(!1),[_e,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(`thank-you`),[H,U]=(0,y.useState)(``),[W,G]=(0,y.useState)(``),[K,q]=(0,y.useState)(``),[J,Y]=(0,y.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=x(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,y.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),v.success(`Copied ${e}`)}catch{v.error(`Clipboard unavailable`)}},xe=async()=>{if(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){v.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),v.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{Y(!1)}},$=t.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,b.jsxs)(te,{children:[(0,b.jsxs)(se,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(oe,{className:`flex items-center gap-2`,children:[(0,b.jsx)(re,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(ee,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(m,{variant:`default`,size:`sm`,onClick:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(me,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(m,{variant:`outline`,size:`sm`,onClick:X,disabled:w,children:[(0,b.jsx)(fe,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(pe,{children:[E&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(de,{children:[(0,b.jsx)(ue,{children:(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:`Name`}),(0,b.jsx)(g,{children:`Object`}),(0,b.jsx)(g,{children:`Slug`}),(0,b.jsx)(g,{children:`Public URL`}),(0,b.jsx)(g,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(le,{children:t.map(e=>{let t=Z(e.slug);return(0,b.jsxs)(p,{children:[(0,b.jsx)(h,{children:(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,b.jsx)(h,{children:e.object?(0,b.jsx)(ie,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(h,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(h,{children:(0,b.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,b.jsx)(l,{className:`h-3 w-3`})]})}),(0,b.jsx)(h,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,b.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(m,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(ce,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(o,{open:ge,onOpenChange:O,children:(0,b.jsxs)(s,{className:`sm:max-w-md`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(i,{children:`Publish a FormView`}),(0,b.jsxs)(c,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,b.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,b.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:k,onChange:e=>A(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(d,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(m,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,b.jsx)(m,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(o,{open:_e,onOpenChange:F,children:(0,b.jsxs)(s,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(_,{children:[(0,b.jsx)(i,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,b.jsx)(c,{children:`Configure the public URL and what happens after submit.`})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(d,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:B,onChange:e=>V(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),B===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(d,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(d,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(f,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(d,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(m,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,b.jsx)(m,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{d as a}from"./infrastructure-CxityHZF.js";import{w as o}from"./framework-DoGxClbR.js";import{Ba as s,Da as c,Es as l,Fa as u,Gr as d,Io as f,Jn as p,Kn as m,Ms as h,Or as g,Qn as _,Xn as v,Yn as y,Zr as b,bi as x,fi as S,gi as C,kr as w,qn as T}from"./ui-components-DeXgqLMc.js";import"./index-DMV3FQgO.js";var E=e(t(),1),D=r();function O(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,O=o(),k=a(),[A,j]=(0,E.useState)({users:null,orgs:null,roles:null,permissions:null,auditLogs:null}),[M,N]=(0,E.useState)(!0),P=(0,E.useCallback)(async()=>{if(O){N(!0);try{let[e,t,n,r,i]=await Promise.all([O.find(`sys_user`).catch(()=>({data:[]})),O.find(`sys_org`).catch(()=>({data:[]})),O.find(`sys_role`).catch(()=>({data:[]})),O.find(`sys_permission`).catch(()=>({data:[]})),O.find(`sys_audit_log`).catch(()=>({data:[]}))]);j({users:e.data?.length??0,orgs:t.data?.length??0,roles:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0})}catch{}finally{N(!1)}}},[O]);(0,E.useEffect)(()=>{P()},[P]);let F=[{title:`Applications`,description:`Manage all configured applications`,icon:u,href:`${r}/system/apps`,countLabel:``,count:null},{title:`Metadata`,description:`Browse and edit every metadata type the platform exposes`,icon:f,href:`${r}/component/metadata/directory`,countLabel:``,count:null}],I=[{title:`Users`,description:`Manage system users and accounts`,icon:g,href:`${r}/system/users`,countLabel:`users`,count:A.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:l,href:`${r}/system/organizations`,countLabel:`organizations`,count:A.orgs},{title:`Roles`,description:`Configure roles and access levels`,icon:S,href:`${r}/system/roles`,countLabel:`roles`,count:A.roles},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:s,href:`${r}/system/permissions`,countLabel:`permissions`,count:A.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:x,href:`${r}/system/audit-log`,countLabel:`entries`,count:A.auditLogs},{title:`AI Approvals`,description:`Review actions AI agents propose before they execute`,icon:h,href:`${r}/system/ai-approvals`,countLabel:``,count:null},{title:`App Marketplace`,description:`Browse and install approved apps from the ObjectStack catalog`,icon:b,href:`${r}/system/marketplace`,countLabel:``,count:null,adminOnly:!0},{title:`Settings`,description:`Configure mail, branding, feature flags, and more`,icon:C,href:`${r}/system/settings`,countLabel:``,count:null},{title:`Developer`,description:`API console, flow runs, and public form management`,icon:d,href:`${r}/developer`,countLabel:``,count:null},{title:`Profile`,description:`View and edit your account settings`,icon:w,href:`${r}/system/profile`,countLabel:``,count:null}],L=[...F,...I].filter(e=>!e.adminOnly||k);return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, roles, permissions, and system configuration`})]}),M&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,D.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:L.map(t=>{let n=t.icon;return(0,D.jsxs)(m,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,D.jsxs)(y,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,D.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,D.jsx)(n,{className:`h-5 w-5`})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(v,{className:`text-base`,children:t.title}),(0,D.jsx)(p,{className:`text-xs`,children:t.description})]})]}),(0,D.jsx)(T,{className:`pt-0`,children:t.count!==null&&(0,D.jsxs)(_,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{O as SystemHubPage};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{d as a}from"./infrastructure-CxityHZF.js";import{w as o}from"./framework-DoGxClbR.js";import{Ba as s,Da as c,Es as l,Fa as u,Gr as d,Io as f,Jn as p,Kn as m,Ms as h,Or as g,Qn as _,Xn as v,Yn as y,Zr as b,bi as x,fi as S,gi as C,kr as w,qn as T}from"./ui-components-DeXgqLMc.js";import"./index-Bt0jFx__.js";var E=e(t(),1),D=r();function O(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,O=o(),k=a(),[A,j]=(0,E.useState)({users:null,orgs:null,roles:null,permissions:null,auditLogs:null}),[M,N]=(0,E.useState)(!0),P=(0,E.useCallback)(async()=>{if(O){N(!0);try{let[e,t,n,r,i]=await Promise.all([O.find(`sys_user`).catch(()=>({data:[]})),O.find(`sys_org`).catch(()=>({data:[]})),O.find(`sys_role`).catch(()=>({data:[]})),O.find(`sys_permission`).catch(()=>({data:[]})),O.find(`sys_audit_log`).catch(()=>({data:[]}))]);j({users:e.data?.length??0,orgs:t.data?.length??0,roles:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0})}catch{}finally{N(!1)}}},[O]);(0,E.useEffect)(()=>{P()},[P]);let F=[{title:`Applications`,description:`Manage all configured applications`,icon:u,href:`${r}/system/apps`,countLabel:``,count:null},{title:`Metadata`,description:`Browse and edit every metadata type the platform exposes`,icon:f,href:`${r}/component/metadata/directory`,countLabel:``,count:null}],I=[{title:`Users`,description:`Manage system users and accounts`,icon:g,href:`${r}/system/users`,countLabel:`users`,count:A.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:l,href:`${r}/system/organizations`,countLabel:`organizations`,count:A.orgs},{title:`Roles`,description:`Configure roles and access levels`,icon:S,href:`${r}/system/roles`,countLabel:`roles`,count:A.roles},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:s,href:`${r}/system/permissions`,countLabel:`permissions`,count:A.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:x,href:`${r}/system/audit-log`,countLabel:`entries`,count:A.auditLogs},{title:`AI Approvals`,description:`Review actions AI agents propose before they execute`,icon:h,href:`${r}/system/ai-approvals`,countLabel:``,count:null},{title:`App Marketplace`,description:`Browse and install approved apps from the ObjectStack catalog`,icon:b,href:`${r}/system/marketplace`,countLabel:``,count:null,adminOnly:!0},{title:`Settings`,description:`Configure mail, branding, feature flags, and more`,icon:C,href:`${r}/system/settings`,countLabel:``,count:null},{title:`Developer`,description:`API console, flow runs, and public form management`,icon:d,href:`${r}/developer`,countLabel:``,count:null},{title:`Profile`,description:`View and edit your account settings`,icon:w,href:`${r}/system/profile`,countLabel:``,count:null}],L=[...F,...I].filter(e=>!e.adminOnly||k);return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, roles, permissions, and system configuration`})]}),M&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,D.jsx)(c,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:L.map(t=>{let n=t.icon;return(0,D.jsxs)(m,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,D.jsxs)(y,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,D.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,D.jsx)(n,{className:`h-5 w-5`})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(v,{className:`text-base`,children:t.title}),(0,D.jsx)(p,{className:`text-xs`,children:t.description})]})]}),(0,D.jsx)(T,{className:`pt-0`,children:t.count!==null&&(0,D.jsxs)(_,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{O as SystemHubPage};