@objectstack/console 9.9.0 → 9.9.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.
- package/dist/assets/{ApiConsolePage-CPV6vWpt.js → ApiConsolePage-B6QExly9.js} +1 -1
- package/dist/assets/{AppDocsIndex-D4Y3i2rM.js → AppDocsIndex-S-ilhz4W.js} +1 -1
- package/dist/assets/{AppManagementPage-CLiHbNPr.js → AppManagementPage-JgLQ-wXj.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-CXwRB3yg.js → ConsoleFloatingChatbot-D13eK4M8.js} +1 -1
- package/dist/assets/{DashboardView-BF0o0wgx.js → DashboardView-P--eXDC-.js} +1 -1
- package/dist/assets/{DashboardWidgetInspector-DIMge0qc.js → DashboardWidgetInspector-VPDtQEP_.js} +1 -1
- package/dist/assets/{FlowRunsPage-CJDL4g0k.js → FlowRunsPage-CCS9xNVc.js} +1 -1
- package/dist/assets/{InterfaceListPage-DZpFSsQf.js → InterfaceListPage-B3jzgT27.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-BWCVUz3e.js → MarketplacePackagePage-DOZgrTZo.js} +1 -1
- package/dist/assets/{MetadataProvider-CEw2X-qL.js → MetadataProvider-Bja7m8Gt.js} +1 -1
- package/dist/assets/{PageView-CP-3dRzz.js → PageView-My4nP5w4.js} +1 -1
- package/dist/assets/{PublicFormsPage-D7D2WWL7.js → PublicFormsPage-CcRFrTQC.js} +1 -1
- package/dist/assets/{RecordDetailView-BdQK61l2.js → RecordDetailView-CMIRy42W.js} +1 -1
- package/dist/assets/{RecordFormPage-lFVOsTl0.js → RecordFormPage-BUfFijzM.js} +1 -1
- package/dist/assets/{ReportDefaultInspector-GD1EQSTh.js → ReportDefaultInspector-C8gR3RMr.js} +1 -1
- package/dist/assets/{ReportView-BHtzV5eK.js → ReportView-DSrtPxzA.js} +1 -1
- package/dist/assets/{RuntimeDraftBar-DXwH4Hvd.js → RuntimeDraftBar-B2fJIAhv.js} +1 -1
- package/dist/assets/{SearchResultsPage-CE_LTSSU.js → SearchResultsPage-C7i-b3gn.js} +1 -1
- package/dist/assets/{SystemHubPage-DjNBraYu.js → SystemHubPage-DWGnZfF0.js} +1 -1
- package/dist/assets/{index-DdQV1cqi.js → index-BgnAjV6_.js} +2 -2
- package/dist/assets/{mergeServerFields-djmY7AgR.js → mergeServerFields-zZ2r6yTA.js} +1 -1
- package/dist/assets/{metadata-admin-BbJpmVQm.js → metadata-admin-BgoJzjrj.js} +1 -1
- package/dist/assets/plugin-form-DXCdD2d-.js +1 -0
- package/dist/assets/{plugin-view-DhNkNfUe.js → plugin-view-D58aYgqA.js} +1 -1
- package/dist/assets/{resolveActionParams-C_x4GXvS.js → resolveActionParams-xmwfLvud.js} +1 -1
- package/dist/assets/{src-Bzm5L_v8.js → src-DXFkWHTV.js} +1 -1
- package/dist/assets/{useActionModal-DDu3wUOI.js → useActionModal-DsVCm46J.js} +1 -1
- package/dist/assets/{useReconcileOnError-Agbi2njU.js → useReconcileOnError-D6sIYKrb.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/plugin-form-gQDKenio.js +0 -1
|
@@ -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-BLEk-ou3.js";import{$n as i,Ds as a,Fi as o,Gi as s,Gn as c,Ma as l,Os as u,Si as d,Sr as f,Ts as p,Ui as m,Un as h,Vr as g,Wn as _,Yo as v,oo as y,rs as ee}from"./ui-components-CrPYFyEM.js";import"./src-Bzm5L_v8.js";var b=e(t(),1),x=[`plugin`,`plugins`,`kind`,`package`];function S(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 C={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 w(e,t){let n=C[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 te(){let e=r(),[t,n]=(0,b.useState)([]),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(null),u=(0,b.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(C)){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(...w(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=>!x.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,...S(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,b.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var T=n(),E={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`},ne={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`},re=[{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`}],D=1;function O(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:x}=te(),[S,C]=(0,b.useState)(``),[w,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(null),[ie,j]=(0,b.useState)(``),[ae,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(null),[V,H]=(0,b.useState)([]),[U,oe]=(0,b.useState)(null),[W,G]=(0,b.useState)(!1),K=(0,b.useMemo)(()=>{if(!S)return t;let e=S.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,S]),se=(0,b.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,b.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,b.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,b.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:D++,key:e,value:t,enabled:!0}])},[]),le=(0,b.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,b.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,b.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,b.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,b.useCallback)(e=>{j(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:D++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,b.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,T.jsx)(`button`,{onClick:x,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,T.jsx)(o,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(d,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(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,T.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(y,{className:`h-6 w-6 opacity-30 mb-2`}),(0,T.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,T.jsxs)(h,{open:t,onOpenChange:()=>se(e.key),children:[(0,T.jsx)(c,{asChild:!0,children:(0,T.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,T.jsx)(p,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,T.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,T.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,T.jsx)(_,{children:(0,T.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,T.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 ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,T.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,T.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(m,{className:`h-3 w-3`}),`Add`]})]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,T.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,T.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,T.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,T.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,T.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,T.jsx)(f,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`select`,{value:q,onChange:e=>j(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 ${E[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))}),(0,T.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,T.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,T.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,T.jsx)(s,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,T.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,T.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,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,T.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,T.jsx)(ee,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,T.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,T.jsx)(u,{className:`h-3 w-3`}):(0,T.jsx)(v,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,T.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,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,T.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,T.jsx)(y,{className:`h-10 w-10 mx-auto opacity-20`}),(0,T.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,T.jsx)(`strong`,{children:`Send`})]}),(0,T.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,T.jsxs)(`div`,{className:`border-t`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,T.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,T.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(g,{className:`h-3 w-3`}),`Clear`]})]}),(0,T.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,T.jsxs)(`div`,{className:`rounded border`,children:[(0,T.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,T.jsx)(a,{className:`h-3 w-3 shrink-0`}):(0,T.jsx)(p,{className:`h-3 w-3 shrink-0`}),(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,T.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,T.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,T.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,T.jsx)(s,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,T.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{O 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-BLEk-ou3.js";import{$n as i,Ds as a,Fi as o,Gi as s,Gn as c,Ma as l,Os as u,Si as d,Sr as f,Ts as p,Ui as m,Un as h,Vr as g,Wn as _,Yo as v,oo as y,rs as ee}from"./ui-components-CrPYFyEM.js";import"./src-DXFkWHTV.js";var b=e(t(),1),x=[`plugin`,`plugins`,`kind`,`package`];function S(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 C={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 w(e,t){let n=C[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 te(){let e=r(),[t,n]=(0,b.useState)([]),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(null),u=(0,b.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(C)){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(...w(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=>!x.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,...S(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,b.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var T=n(),E={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`},ne={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`},re=[{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`}],D=1;function O(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:x}=te(),[S,C]=(0,b.useState)(``),[w,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(null),[ie,j]=(0,b.useState)(``),[ae,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(null),[V,H]=(0,b.useState)([]),[U,oe]=(0,b.useState)(null),[W,G]=(0,b.useState)(!1),K=(0,b.useMemo)(()=>{if(!S)return t;let e=S.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,S]),se=(0,b.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,b.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,b.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,b.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:D++,key:e,value:t,enabled:!0}])},[]),le=(0,b.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,b.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,b.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,b.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,b.useCallback)(e=>{j(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:D++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,b.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,T.jsx)(`button`,{onClick:x,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,T.jsx)(o,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(d,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(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,T.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(y,{className:`h-6 w-6 opacity-30 mb-2`}),(0,T.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,T.jsxs)(h,{open:t,onOpenChange:()=>se(e.key),children:[(0,T.jsx)(c,{asChild:!0,children:(0,T.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,T.jsx)(p,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,T.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,T.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,T.jsx)(_,{children:(0,T.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,T.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 ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,T.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,T.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(m,{className:`h-3 w-3`}),`Add`]})]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,T.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,T.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,T.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,T.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,T.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,T.jsx)(f,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`select`,{value:q,onChange:e=>j(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 ${E[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))}),(0,T.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,T.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,T.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,T.jsx)(s,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,T.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,T.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,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,T.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,T.jsx)(ee,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,T.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,T.jsx)(u,{className:`h-3 w-3`}):(0,T.jsx)(v,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,T.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,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,T.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,T.jsx)(y,{className:`h-10 w-10 mx-auto opacity-20`}),(0,T.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,T.jsx)(`strong`,{children:`Send`})]}),(0,T.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,T.jsxs)(`div`,{className:`border-t`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,T.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,T.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(g,{className:`h-3 w-3`}),`Clear`]})]}),(0,T.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,T.jsxs)(`div`,{className:`rounded border`,children:[(0,T.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,T.jsx)(a,{className:`h-3 w-3 shrink-0`}):(0,T.jsx)(p,{className:`h-3 w-3 shrink-0`}),(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,T.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,T.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,T.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,T.jsx)(s,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,T.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{O as ApiConsolePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,a as n,f as r,r as i,t as a}from"./vendor-react-DR370ovB.js";import{Js as o,Ma as s}from"./ui-components-CrPYFyEM.js";import{a as c,i as l,n as u,r as d}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,a as n,f as r,r as i,t as a}from"./vendor-react-DR370ovB.js";import{Js as o,Ma as s}from"./ui-components-CrPYFyEM.js";import{a as c,i as l,n as u,r as d}from"./index-BgnAjV6_.js";var f=e(t(),1),p=a();function m(){let{appName:e}=r(),{books:t,docs:a,state:m}=u(),h=(0,f.useMemo)(()=>t.filter(t=>l(t)===e),[t,e]),g=(0,f.useMemo)(()=>d(h,a),[h,a]);return m===`loading`?(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,p.jsx)(s,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):g.length===1?(0,p.jsx)(n,{to:`/apps/${e}/docs/${g[0].slug}`,replace:!0}):(0,p.jsx)(c,{children:(0,p.jsx)(`div`,{className:`mx-auto max-w-3xl p-4 sm:p-6`,children:g.length===0?(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,p.jsx)(o,{className:`h-10 w-10`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`This app does not ship any documentation yet.`}),(0,p.jsx)(i,{to:`/docs`,className:`text-sm font-medium text-primary hover:underline`,children:`Browse all documentation`})]}):(0,p.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:g.map(t=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(i,{to:`/apps/${e}/docs/${t.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,p.jsx)(o,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold`,children:t.label}),t.description?(0,p.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:t.description}):t.subtitle?(0,p.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:t.subtitle}):null,(0,p.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[t.docCount,` `,t.docCount===1?`article`:`articles`]})]})]})},t.name))})})})}export{m as default};
|
|
@@ -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-BLEk-ou3.js";import{$n as o,Hr as s,Io as c,Jn as l,Kn as u,Si as d,Ui as f,Ur as p,Vr as m,Xi as h,hr as g,ni as _,nn as v,qn as y,za as b}from"./ui-components-CrPYFyEM.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./src-
|
|
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-BLEk-ou3.js";import{$n as o,Hr as s,Io as c,Jn as l,Kn as u,Si as d,Ui as f,Ur as p,Vr as m,Xi as h,hr as g,ni as _,nn as v,qn as y,za as b}from"./ui-components-CrPYFyEM.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./src-DXFkWHTV.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)(f,{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)(d,{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)(v,{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)(o,{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)(u,{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)(b,{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)(y,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,w.jsxs)(l,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,w.jsx)(u,{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)(b,{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)(o,{variant:`default`,className:`text-xs`,children:`Default`}),(0,w.jsx)(o,{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._packageId??t.name}`),children:(0,w.jsx)(c,{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)(h,{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)(s,{className:`h-4 w-4`}):(0,w.jsx)(p,{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)(_,{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};
|
package/dist/assets/{ConsoleFloatingChatbot-CXwRB3yg.js → ConsoleFloatingChatbot-D13eK4M8.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{r as a}from"./framework-BLEk-ou3.js";import{Bt as o,Ht as s,Ut as c,Vt as l,Wt as u,ai as d,hr as f,vi as p,w as m}from"./ui-components-CrPYFyEM.js";import{r as h}from"./vendor-ui-utils-rQOI1gAo.js";import{a as g,i as _,n as v}from"./MetadataProvider-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{r as a}from"./framework-BLEk-ou3.js";import{Bt as o,Ht as s,Ut as c,Vt as l,Wt as u,ai as d,hr as f,vi as p,w as m}from"./ui-components-CrPYFyEM.js";import{r as h}from"./vendor-ui-utils-rQOI1gAo.js";import{a as g,i as _,n as v}from"./MetadataProvider-Bja7m8Gt.js";import{a as y,i as b,n as ee,o as te,t as ne}from"./useReconcileOnError-D6sIYKrb.js";import{a as re,d as x,f as ie,h as ae,r as S,t as C,u as w}from"./plugin-chatbot-Ch8YIyYL.js";import{b as T,n as oe}from"./marketplaceApi-CucX7DD9.js";var E=e(t(),1),D=r(),O={data_chat:{zh:`智能助手`,en:`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 se(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`]}var N=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`,`metadata`]);function P(e){try{return decodeURIComponent(e)}catch{return e}}function ce(e,t){let n=e.split(`/`).filter(Boolean),r=n.indexOf(`apps`);if(r===-1||n.length<r+3)return{};let i=P(n[r+2]);if(N.has(i)||!t.some(e=>e.name===i))return{};let a=n[r+3]?P(n[r+3]):void 0,o=a&&a!==`new`?a:void 0;return{objectName:i,...o?{recordId:o}:{}}}function F({appLabel:e,appName:t,objects:r,agents:y,agentsLoading:x,activeAgent:w,onAgentChange:O,showAgentPicker:k,chatApi:j,apiBase:M,defaultOpen:N=!1,conversationId:P,initialMessages:F}){let{language:I}=a(),L=i(),R=n(),z=E.useMemo(()=>ce(R.pathname,r),[R.pathname,r]),{editor:B}=g(),V=E.useMemo(()=>!F||F.length===0?[]:ae(F),[F]),H=E.useMemo(()=>y.find(e=>e.name===w)?.label??w??e,[y,w,e]),U=E.useMemo(()=>A(I,e,w,H,r),[I,e,w,H,r]),W=E.useMemo(()=>se(B,I),[B,I]),{errorSuppressed:le,handleChatError:ue,setMessagesRef:de,resetSuppression:G}=ne({chatApi:j,conversationId:P}),{messages:K,isLoading:q,error:fe,sendMessage:J,stop:pe,reload:me,clear:Y,setMessages:X}=ie({api:j,conversationId:P,onError:ue,body:{context:{activeApp:e,appName:t,objects:r.map(e=>({name:e.name,label:e.label})),agentName:w,autoPublishAiBuilds:T().features.autoPublishAiBuilds,...z.objectName?{objectName:z.objectName}:{},...z.recordId?{recordId:z.recordId}:{},...B?{editing:B}:{}}},initialMessages:V,autoResponse:!j,autoResponseText:r.length>0?`I can help you work with ${r.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(()=>{de.current=X},[X]),E.useEffect(()=>{te(P,b(K))},[P,K]);let Z=C({messages:K,apiBase:M,continueConversation:e=>{G(),J(e)}}),Q=k&&y.length>1?(0,D.jsxs)(o,{value:w,onValueChange:O,disabled:x,children:[(0,D.jsx)(c,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,D.jsx)(u,{placeholder:`Choose agent...`})}),(0,D.jsx)(l,{align:`end`,children:y.map(e=>(0,D.jsxs)(s,{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,[he,$]=E.useState(!1),ge=E.useMemo(()=>M.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[M]),_e=(0,D.jsxs)(D.Fragment,{children:[K.length>0?(0,D.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.newChat,title:U.newChat,"data-testid":`floating-chatbot-new`,onClick:Y,children:(0,D.jsx)(d,{className:`h-4 w-4`})}):null,P?(0,D.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.share,title:U.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,D.jsx)(p,{className:`h-4 w-4`})}):null]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(S,{onUpgrade:()=>window.open(oe(),`_blank`,`noopener,noreferrer`),floatingConfig:{position:`bottom-right`,defaultOpen:N,panelWidth:420,panelHeight:560,title:U.title,triggerSize:56},headerExtra:Q,headerActions:_e,messages:K,labels:U.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:U.agentLabel,suggestions:K.length===0?W??U.suggestions:void 0,placeholder:w?U.placeholder:x?U.loadingPlaceholder:U.placeholder,onSendMessage:e=>{G(),J(e)},onClear:Y,onStop:q?pe:void 0,onReload:me,isLoading:q,error:le?void 0:fe,enableMarkdown:!0,onToolApprove:Z.decide,toolDecisions:Z.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&_(e[0])},toolReviewLabel:U.reviewDraft,onOpenBuiltApp:e=>L(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:U.openBuiltApp,onPreviewDraftApp:(e,t)=>L(t?.materialized?`/apps/${encodeURIComponent(e)}`:`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)v(t)},fetchPendingDraftCount:ee,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?h.warning(U.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):h.success(U.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&L(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:re(n)}}catch(e){return h.error(U.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:U.publishDrafts,publishedLabel:U.published,autoPublishDrafts:T().features.autoPublishAiBuilds}),P&&(0,D.jsx)(m,{open:he,onOpenChange:$,objectName:`ai_conversations`,recordId:P,recordLabel:`this conversation`,apiBase:ge})]})}function I({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=w(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:b}=y({userId:s,scope:h,apiBase:c});return(0,D.jsx)(F,{appLabel:e,appName:t,objects:n,agents:f,agentsLoading:p,agentsError:m,activeAgent:h,onAgentChange:g,showAgentPicker:d,chatApi:_,apiBase:c,defaultOpen:o,conversationId:v,initialMessages:b},`${_??`local`}:${v??`pending`}`)}export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i}from"./vendor-react-DR370ovB.js";import{f as a}from"./infrastructure-CJNwTVno.js";import{T as o,r as s,w as c}from"./framework-BLEk-ou3.js";import{As as l,Bn as u,Fs as d,H as f,Ha as p,Hn as m,Ln as h,Ps as g,Qr as _,R as v,Rn as y,Sr as b,Ui as x,Vn as S,Vr as C,Xi as w,gc as T,hr as E,sc as D,z as O,za as k,zn as ee,zr as A}from"./ui-components-CrPYFyEM.js";import{r as j}from"./vendor-ui-utils-rQOI1gAo.js";import"./AdapterProvider-DJb3ZVmJ.js";import{n as te}from"./plugin-form-gQDKenio.js";import"./MetadataProvider-CEw2X-qL.js";import{r as ne}from"./ExpressionProvider-DKFCgLsJ.js";import{C as re,r as M}from"./mergeServerFields-djmY7AgR.js";import{r as N}from"./utils-bipVuqQL.js";import{n as ie,r as ae,t as oe}from"./MetadataInspector-BRICMLXW.js";import{r as se,t as P}from"./RuntimeDraftBar-DXwH4Hvd.js";import{n as ce}from"./skeletons-B_SNEnMn.js";import{n as le}from"./plugin-dashboard-C7fxXXeO.js";import{n as F,t as I}from"./DashboardWidgetInspector-DIMge0qc.js";var L=e(n(),1),R=i();function ue({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:c,name:l,metadataClient:u,onAfterChange:d}){let{t:f}=s(),p=(0,L.useMemo)(()=>M(),[]),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(0),v=(0,L.useCallback)(e=>{h(!0),o({...n??{},...e})},[n,o]),y=(0,L.useCallback)(e=>{o(e),h(!1)},[o]),x=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),S=Array.isArray(n?.widgets)?n.widgets:[],w=r?S.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,O=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":O,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(D,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:O})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&c&&(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>c(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(b,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(I,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:v,onClearSelection:()=>i(null),onSelectionChange:x,readOnly:!1,locale:p}):(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},onPatch:v,onSelectionChange:x,readOnly:!1,locale:p})}),(0,R.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,R.jsx)(P,{type:`dashboard`,name:l||T||void 0,metadataClient:u,dirty:m,onResume:y,savedSignal:g,onAfterChange:d}),(0,R.jsx)(E,{size:`sm`,onClick:()=>{a(n??{}),h(!1),_(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:A},{type:`bar`,label:`Bar Chart`,Icon:d},{type:`line`,label:`Line Chart`,Icon:g},{type:`pie`,label:`Pie Chart`,Icon:l},{type:`table`,label:`Table`,Icon:_},{type:`pivot`,label:`Pivot`,Icon:k}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function de(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function fe(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let{dashboardName:t}=r(),{showDebug:n}=ie(),i=c(),l=re(),{t:d}=s(),{dashboardLabel:g,dashboardDescription:_}=T(),{user:b}=a(),C=b?.role===`admin`,[D,k]=(0,L.useState)(!0),[A,M]=(0,L.useState)(!1),[P,F]=(0,L.useState)(null),[I,z]=(0,L.useState)(null),V=(0,L.useCallback)(e=>{z(t=>(t&&t.resolve(e),null))},[]),U=(0,L.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;z({schema:n,resolve:t})}),[]),pe=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(d(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(d(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(d(`dashboardActions.forecastSoon`)),{success:!0})}),[d]);(0,L.useEffect)(()=>{k(!0),J(null),M(!1),F(null),queueMicrotask(()=>k(!1))},[t]);let{dashboards:me,objects:W,refresh:G}=o(),{app:he}=ne(),K=ae(me,t,he?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{A||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{l&&await se(`dashboard`,t,e,{metadataClient:l}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[l,t,G]),ge=(0,L.useCallback)(()=>{J(de(K)),M(!0)},[K]),_e=(0,L.useCallback)(()=>{M(!1),F(null)},[]),ve=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:fe(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),F(t)},[q,Y]),ye=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),P===e&&F(null)},[q,P,Y]),X=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),be=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.useMemo)(()=>{if(!Q||Z.size===0)return Q;let e=Q.widgets;if(!Array.isArray(e)||e.length===0)return Q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return t?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return D?(0,R.jsx)(ce,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=N(($||K).title,d),t=N(K.label,d),n=g({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=_({name:K.name,description:N(e,d)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[A&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>ve(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,R.jsx)(x,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),C&&(0,R.jsxs)(`button`,{type:`button`,onClick:ge,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,R.jsx)(w,{className:`h-3.5 w-3.5`}),d(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(le,{schema:$,dataSource:e,designMode:A,selectedWidgetId:P,onWidgetClick:F,onWidgetsReorder:X,modalHandler:U,scriptHandlers:pe,hideHeaderText:!0})}),(0,R.jsx)(ue,{open:A&&C,onClose:_e,schema:be,selectedWidgetId:P,onSelectWidget:F,onSave:Y,onChange:J,onRemoveWidget:ye,name:t,metadataClient:l,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(oe,{open:n,sections:[{title:`Dashboard Configuration`,data:$}]})]}),I&&I.schema?.objectName?(0,R.jsx)(te,{schema:{type:`object-form`,formType:`modal`,objectName:I.schema.objectName,mode:I.schema.mode||`create`,recordId:I.schema.recordId,title:I.schema.title,description:I.schema.description,fields:I.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:i}):I?(0,R.jsx)(h,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,R.jsxs)(y,{children:[(0,R.jsxs)(S,{children:[(0,R.jsx)(m,{children:I.schema?.title||d(`actionDialog.defaultActionTitle`)}),I.schema?.description&&(0,R.jsx)(ee,{children:I.schema.description})]}),(0,R.jsxs)(u,{children:[(0,R.jsx)(E,{variant:`outline`,onClick:()=>V({success:!1}),children:d(`actionDialog.cancel`)}),(0,R.jsx)(E,{onClick:()=>V({success:!0}),children:d(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(v,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(p,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(f,{children:d(`empty.dashboardNotFound`)}),(0,R.jsx)(O,{children:d(`empty.dashboardNotFoundDescription`,{name:t})})]})})}export{z as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i}from"./vendor-react-DR370ovB.js";import{f as a}from"./infrastructure-CJNwTVno.js";import{T as o,r as s,w as c}from"./framework-BLEk-ou3.js";import{As as l,Bn as u,Fs as d,H as f,Ha as p,Hn as m,Ln as h,Ps as g,Qr as _,R as v,Rn as y,Sr as b,Ui as x,Vn as S,Vr as C,Xi as w,gc as T,hr as E,sc as D,z as O,za as k,zn as ee,zr as A}from"./ui-components-CrPYFyEM.js";import{r as j}from"./vendor-ui-utils-rQOI1gAo.js";import"./AdapterProvider-DJb3ZVmJ.js";import{n as te}from"./plugin-form-DXCdD2d-.js";import"./MetadataProvider-Bja7m8Gt.js";import{r as ne}from"./ExpressionProvider-DKFCgLsJ.js";import{C as re,r as M}from"./mergeServerFields-zZ2r6yTA.js";import{r as N}from"./utils-bipVuqQL.js";import{n as ie,r as ae,t as oe}from"./MetadataInspector-BRICMLXW.js";import{r as se,t as P}from"./RuntimeDraftBar-B2fJIAhv.js";import{n as ce}from"./skeletons-B_SNEnMn.js";import{n as le}from"./plugin-dashboard-C7fxXXeO.js";import{n as F,t as I}from"./DashboardWidgetInspector-VPDtQEP_.js";var L=e(n(),1),R=i();function ue({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:c,name:l,metadataClient:u,onAfterChange:d}){let{t:f}=s(),p=(0,L.useMemo)(()=>M(),[]),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(0),v=(0,L.useCallback)(e=>{h(!0),o({...n??{},...e})},[n,o]),y=(0,L.useCallback)(e=>{o(e),h(!1)},[o]),x=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),S=Array.isArray(n?.widgets)?n.widgets:[],w=r?S.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,O=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":O,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(D,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:O})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&c&&(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>c(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(b,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(I,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:v,onClearSelection:()=>i(null),onSelectionChange:x,readOnly:!1,locale:p}):(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},onPatch:v,onSelectionChange:x,readOnly:!1,locale:p})}),(0,R.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,R.jsx)(P,{type:`dashboard`,name:l||T||void 0,metadataClient:u,dirty:m,onResume:y,savedSignal:g,onAfterChange:d}),(0,R.jsx)(E,{size:`sm`,onClick:()=>{a(n??{}),h(!1),_(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:A},{type:`bar`,label:`Bar Chart`,Icon:d},{type:`line`,label:`Line Chart`,Icon:g},{type:`pie`,label:`Pie Chart`,Icon:l},{type:`table`,label:`Table`,Icon:_},{type:`pivot`,label:`Pivot`,Icon:k}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function de(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function fe(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let{dashboardName:t}=r(),{showDebug:n}=ie(),i=c(),l=re(),{t:d}=s(),{dashboardLabel:g,dashboardDescription:_}=T(),{user:b}=a(),C=b?.role===`admin`,[D,k]=(0,L.useState)(!0),[A,M]=(0,L.useState)(!1),[P,F]=(0,L.useState)(null),[I,z]=(0,L.useState)(null),V=(0,L.useCallback)(e=>{z(t=>(t&&t.resolve(e),null))},[]),U=(0,L.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;z({schema:n,resolve:t})}),[]),pe=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(d(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(d(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(d(`dashboardActions.forecastSoon`)),{success:!0})}),[d]);(0,L.useEffect)(()=>{k(!0),J(null),M(!1),F(null),queueMicrotask(()=>k(!1))},[t]);let{dashboards:me,objects:W,refresh:G}=o(),{app:he}=ne(),K=ae(me,t,he?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{A||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{l&&await se(`dashboard`,t,e,{metadataClient:l}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[l,t,G]),ge=(0,L.useCallback)(()=>{J(de(K)),M(!0)},[K]),_e=(0,L.useCallback)(()=>{M(!1),F(null)},[]),ve=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:fe(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),F(t)},[q,Y]),ye=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),P===e&&F(null)},[q,P,Y]),X=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),be=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.useMemo)(()=>{if(!Q||Z.size===0)return Q;let e=Q.widgets;if(!Array.isArray(e)||e.length===0)return Q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return t?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return D?(0,R.jsx)(ce,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=N(($||K).title,d),t=N(K.label,d),n=g({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=_({name:K.name,description:N(e,d)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[A&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>ve(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,R.jsx)(x,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),C&&(0,R.jsxs)(`button`,{type:`button`,onClick:ge,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,R.jsx)(w,{className:`h-3.5 w-3.5`}),d(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(le,{schema:$,dataSource:e,designMode:A,selectedWidgetId:P,onWidgetClick:F,onWidgetsReorder:X,modalHandler:U,scriptHandlers:pe,hideHeaderText:!0})}),(0,R.jsx)(ue,{open:A&&C,onClose:_e,schema:be,selectedWidgetId:P,onSelectWidget:F,onSave:Y,onChange:J,onRemoveWidget:ye,name:t,metadataClient:l,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(oe,{open:n,sections:[{title:`Dashboard Configuration`,data:$}]})]}),I&&I.schema?.objectName?(0,R.jsx)(te,{schema:{type:`object-form`,formType:`modal`,objectName:I.schema.objectName,mode:I.schema.mode||`create`,recordId:I.schema.recordId,title:I.schema.title,description:I.schema.description,fields:I.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:i}):I?(0,R.jsx)(h,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,R.jsxs)(y,{children:[(0,R.jsxs)(S,{children:[(0,R.jsx)(m,{children:I.schema?.title||d(`actionDialog.defaultActionTitle`)}),I.schema?.description&&(0,R.jsx)(ee,{children:I.schema.description})]}),(0,R.jsxs)(u,{children:[(0,R.jsx)(E,{variant:`outline`,onClick:()=>V({success:!1}),children:d(`actionDialog.cancel`)}),(0,R.jsx)(E,{onClick:()=>V({success:!0}),children:d(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(v,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(p,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(f,{children:d(`empty.dashboardNotFound`)}),(0,R.jsx)(O,{children:d(`empty.dashboardNotFoundDescription`,{name:t})})]})})}export{z as t};
|
package/dist/assets/{DashboardWidgetInspector-DIMge0qc.js → DashboardWidgetInspector-VPDtQEP_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{R as r,l as i,m as a}from"./vendor-objectstack-BNd856rx.js";import{$n as o,$o as s,As as c,Br as l,Bt as u,Ht as d,Is as f,Ms as p,Na as m,Ns as h,Ps as g,Qr as _,Si as v,Sr as y,Ui as b,Ut as x,Vo as S,Vt as C,Wo as w,Wt as T,fc as E,hr as D,io as O,ks as ee,nn as k,on as A,to as j}from"./ui-components-CrPYFyEM.js";import{_ as M,b as N,g as P,h as F,i as I,n as te,p as ne,t as re,v as L,y as R}from"./mergeServerFields-djmY7AgR.js";var z=e(t(),1),B={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:j},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:p},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:h},line:{id:`line`,label:`Line chart`,category:`chart`,icon:g},area:{id:`area`,label:`Area chart`,category:`chart`,icon:f},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:c},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:S},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:ee},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:l},table:{id:`table`,label:`Data table`,category:`data`,icon:_},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:w},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:s}},V={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},H=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(B).filter(t=>t.category===e)})),U=E,W=n();function G({onAdd:e,label:t=`Add widget`}){let[n,r]=z.useState(!1),[i,a]=z.useState(``),o=z.useRef(null),s=z.useRef(null);z.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=z.useMemo(()=>{let e=i.trim().toLowerCase();return e?H.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):H},[i]);return(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,W.jsx)(b,{className:`h-3 w-3`}),t]}),n&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,W.jsx)(v,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,W.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,W.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:V[t.category]}),t.types.map(t=>(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,W.jsx)(B[t.id]?.icon??U,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,W.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var K={io:`input`,unrepresentable:`any`},q=new Set([`widgets`,`label`,`description`,`name`]),J,Y=!1;function ie(){if(J||Y)return J;try{J=r(i,K)}catch(e){Y=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return J}var X;function ae(){if(X)return X;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!q.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),X=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return X}}var oe=new Set([`name`,`label`,`description`,`widgets`]);function se({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let s=z.useCallback(e=>I(e,r),[r]),c=typeof e.label==`string`?e.label:``,l=typeof e.description==`string`?e.description:``,u=z.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),d=e=>{let n=N(`widget`,u.map(e=>e?.id).filter(Boolean)),r=B[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:M(u,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},f=e=>{t({widgets:R(u,e,null)})},p=(e,n)=>{e!==n&&t({widgets:L(u,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=z.useState(null),[_,v]=z.useState(null),{schema:b,form:x}=z.useMemo(()=>re({bundledSchema:ie(),bundledForm:ae(),serverSchema:a,excludeFields:oe,sectionTitle:I(`engine.inspector.moreFields`,r)}),[a,r]);return(0,W.jsxs)(F,{kindLabel:s(`engine.inspector.dashboard.kind`),title:String(c||e.name||s(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:s(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.label`),value:c,onCommit:e=>t({label:e}),placeholder:s(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.description`),value:l,onCommit:e=>t({description:e}),placeholder:s(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,W.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(A,{className:`text-xs text-muted-foreground`,children:s(`engine.inspector.dashboard.widgets`)}),(0,W.jsx)(o,{variant:`outline`,className:`text-[10px]`,children:u.length})]}),u.length===0?(0,W.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.widgetsEmpty`)}):(0,W.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>{let r=B[e?.type]?.icon??U;return(0,W.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,W.jsx)(O,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,W.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,W.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>f(t),title:s(`engine.inspector.dashboard.removeWidget`),"aria-label":s(`engine.inspector.dashboard.removeWidget`),children:(0,W.jsx)(y,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,W.jsx)(G,{onAdd:d,label:s(`engine.inspector.add.widget`)})]}),(0,W.jsx)(`div`,{className:`border-t pt-3`,children:b?(0,W.jsx)(te,{schema:b,form:x,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.noSchema`)})})]})}var ce=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Z=[`count`,`sum`,`avg`,`min`,`max`],le=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function ue(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function de({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){if(t.kind!==`widget`)return(0,W.jsx)($,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});let s=ue(e,t.id);if(!s)return(0,W.jsx)($,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:c,index:l}=s,f=Array.isArray(e.widgets)?e.widgets:[];function p(e){let t=[...f];t[l]={...t[l],...e},n({widgets:t})}let m=c,h=typeof m.dataset==`string`?m.dataset:``,g=Array.isArray(m.dimensions)?m.dimensions.join(`, `):``,_=Array.isArray(m.values)?m.values.join(`, `):``,v=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function b(e){n({widgets:L(f,l,e)}),c.id&&i?.({kind:`widget`,id:c.id,label:c.title??void 0})}return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:I(`engine.inspector.widget.kind`,o)}),(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:c.title||t.label||`Widget ${l+1}`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,W.jsx)(ne,{index:l,total:f.length,onMove:b,upLabel:I(`engine.inspector.reorder.up`,o),downLabel:I(`engine.inspector.reorder.down`,o),disabled:a}),(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:I(`engine.inspector.widget.close`,o),"aria-label":I(`engine.inspector.widget.close`,o),children:(0,W.jsx)(y,{className:`h-3.5 w-3.5`})})]})]}),(0,W.jsx)(Q,{id:`widget-title`,label:I(`engine.inspector.widget.title`,o),children:(0,W.jsx)(k,{id:`widget-title`,value:c.title??``,onChange:e=>p({title:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-type`,label:I(`engine.inspector.widget.type`,o),children:(0,W.jsxs)(u,{value:c.type??`metric`,onValueChange:e=>p({type:e}),disabled:a,children:[(0,W.jsx)(x,{id:`widget-type`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(C,{children:ce.map(e=>(0,W.jsx)(d,{value:e.value,children:e.label},e.value))})]})}),(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:I(`engine.inspector.widget.datasetSection`,o)}),(0,W.jsxs)(Q,{id:`widget-dataset`,label:I(`engine.inspector.widget.dataset`,o),children:[(0,W.jsx)(k,{id:`widget-dataset`,value:h,placeholder:I(`engine.inspector.widget.datasetPlaceholder`,o),onChange:e=>p({dataset:e.target.value||void 0}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.datasetHint`,o)})]}),h&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Q,{id:`widget-dimensions`,label:I(`engine.inspector.widget.dimensions`,o),children:[(0,W.jsx)(k,{id:`widget-dimensions`,value:g,placeholder:I(`engine.inspector.widget.dimensionsPlaceholder`,o),onChange:e=>p({dimensions:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.dimensionsHint`,o)})]}),(0,W.jsxs)(Q,{id:`widget-values`,label:I(`engine.inspector.widget.values`,o),children:[(0,W.jsx)(k,{id:`widget-values`,value:_,placeholder:I(`engine.inspector.widget.valuesPlaceholder`,o),onChange:e=>p({values:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.valuesHint`,o)})]})]})]}),(0,W.jsx)(Q,{id:`widget-object`,label:I(`engine.inspector.widget.object`,o),children:(0,W.jsx)(k,{id:`widget-object`,value:c.object??``,placeholder:`e.g. order`,onChange:e=>p({object:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-value-field`,label:I(`engine.inspector.widget.valueField`,o),children:(0,W.jsx)(k,{id:`widget-value-field`,value:c.valueField??``,placeholder:`e.g. amount`,onChange:e=>p({valueField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-category-field`,label:I(`engine.inspector.widget.categoryField`,o),children:(0,W.jsx)(k,{id:`widget-category-field`,value:c.categoryField??``,placeholder:`e.g. status`,onChange:e=>p({categoryField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-aggregate`,label:I(`engine.inspector.widget.aggregate`,o),children:(0,W.jsxs)(u,{value:c.aggregate??`count`,onValueChange:e=>p({aggregate:e}),disabled:a,children:[(0,W.jsx)(x,{id:`widget-aggregate`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(C,{children:Z.map(e=>(0,W.jsx)(d,{value:e,children:e},e))})]})}),(0,W.jsx)(Q,{id:`widget-color`,label:I(`engine.inspector.widget.color`,o),children:(0,W.jsxs)(u,{value:c.colorVariant??`default`,onValueChange:e=>p({colorVariant:e}),disabled:a,children:[(0,W.jsx)(x,{id:`widget-color`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(C,{children:le.map(e=>(0,W.jsx)(d,{value:e,children:e},e))})]})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsx)(Q,{id:`widget-w`,label:I(`engine.inspector.widget.width`,o),children:(0,W.jsx)(k,{id:`widget-w`,type:`number`,min:1,value:c.layout?.w??1,onChange:e=>p({layout:{...c.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-h`,label:I(`engine.inspector.widget.height`,o),children:(0,W.jsx)(k,{id:`widget-h`,type:`number`,min:1,value:c.layout?.h??1,onChange:e=>p({layout:{...c.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,W.jsx)(`div`,{className:`pt-2 border-t`,children:(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(l,1),n({widgets:t}),r()},children:I(`engine.inspector.widget.remove`,o)})})]})}function Q({id:e,label:t,children:n}){return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(A,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function $({message:e,onClose:t,locale:n}){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,W.jsx)(`p`,{children:e}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:I(`engine.inspector.widget.close`,n)})]})}export{B as i,se as n,G as r,de as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{R as r,l as i,m as a}from"./vendor-objectstack-BNd856rx.js";import{$n as o,$o as s,As as c,Br as l,Bt as u,Ht as d,Is as f,Ms as p,Na as m,Ns as h,Ps as g,Qr as _,Si as v,Sr as y,Ui as b,Ut as x,Vo as S,Vt as C,Wo as w,Wt as T,fc as E,hr as D,io as O,ks as ee,nn as k,on as A,to as j}from"./ui-components-CrPYFyEM.js";import{_ as M,b as N,g as P,h as F,i as I,n as te,p as ne,t as re,v as L,y as R}from"./mergeServerFields-zZ2r6yTA.js";var z=e(t(),1),B={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:j},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:p},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:h},line:{id:`line`,label:`Line chart`,category:`chart`,icon:g},area:{id:`area`,label:`Area chart`,category:`chart`,icon:f},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:c},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:S},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:ee},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:l},table:{id:`table`,label:`Data table`,category:`data`,icon:_},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:w},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:s}},V={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},H=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(B).filter(t=>t.category===e)})),U=E,W=n();function G({onAdd:e,label:t=`Add widget`}){let[n,r]=z.useState(!1),[i,a]=z.useState(``),o=z.useRef(null),s=z.useRef(null);z.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=z.useMemo(()=>{let e=i.trim().toLowerCase();return e?H.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):H},[i]);return(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,W.jsx)(b,{className:`h-3 w-3`}),t]}),n&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,W.jsx)(v,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,W.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,W.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:V[t.category]}),t.types.map(t=>(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,W.jsx)(B[t.id]?.icon??U,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,W.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var K={io:`input`,unrepresentable:`any`},q=new Set([`widgets`,`label`,`description`,`name`]),J,Y=!1;function ie(){if(J||Y)return J;try{J=r(i,K)}catch(e){Y=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return J}var X;function ae(){if(X)return X;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!q.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),X=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return X}}var oe=new Set([`name`,`label`,`description`,`widgets`]);function se({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let s=z.useCallback(e=>I(e,r),[r]),c=typeof e.label==`string`?e.label:``,l=typeof e.description==`string`?e.description:``,u=z.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),d=e=>{let n=N(`widget`,u.map(e=>e?.id).filter(Boolean)),r=B[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:M(u,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},f=e=>{t({widgets:R(u,e,null)})},p=(e,n)=>{e!==n&&t({widgets:L(u,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=z.useState(null),[_,v]=z.useState(null),{schema:b,form:x}=z.useMemo(()=>re({bundledSchema:ie(),bundledForm:ae(),serverSchema:a,excludeFields:oe,sectionTitle:I(`engine.inspector.moreFields`,r)}),[a,r]);return(0,W.jsxs)(F,{kindLabel:s(`engine.inspector.dashboard.kind`),title:String(c||e.name||s(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:s(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.label`),value:c,onCommit:e=>t({label:e}),placeholder:s(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,W.jsx)(P,{label:s(`engine.inspector.dashboard.description`),value:l,onCommit:e=>t({description:e}),placeholder:s(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,W.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(A,{className:`text-xs text-muted-foreground`,children:s(`engine.inspector.dashboard.widgets`)}),(0,W.jsx)(o,{variant:`outline`,className:`text-[10px]`,children:u.length})]}),u.length===0?(0,W.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.widgetsEmpty`)}):(0,W.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>{let r=B[e?.type]?.icon??U;return(0,W.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,W.jsx)(O,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,W.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,W.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>f(t),title:s(`engine.inspector.dashboard.removeWidget`),"aria-label":s(`engine.inspector.dashboard.removeWidget`),children:(0,W.jsx)(y,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,W.jsx)(G,{onAdd:d,label:s(`engine.inspector.add.widget`)})]}),(0,W.jsx)(`div`,{className:`border-t pt-3`,children:b?(0,W.jsx)(te,{schema:b,form:x,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s(`engine.inspector.dashboard.noSchema`)})})]})}var ce=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Z=[`count`,`sum`,`avg`,`min`,`max`],le=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function ue(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function de({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){if(t.kind!==`widget`)return(0,W.jsx)($,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});let s=ue(e,t.id);if(!s)return(0,W.jsx)($,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:c,index:l}=s,f=Array.isArray(e.widgets)?e.widgets:[];function p(e){let t=[...f];t[l]={...t[l],...e},n({widgets:t})}let m=c,h=typeof m.dataset==`string`?m.dataset:``,g=Array.isArray(m.dimensions)?m.dimensions.join(`, `):``,_=Array.isArray(m.values)?m.values.join(`, `):``,v=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function b(e){n({widgets:L(f,l,e)}),c.id&&i?.({kind:`widget`,id:c.id,label:c.title??void 0})}return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:I(`engine.inspector.widget.kind`,o)}),(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:c.title||t.label||`Widget ${l+1}`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,W.jsx)(ne,{index:l,total:f.length,onMove:b,upLabel:I(`engine.inspector.reorder.up`,o),downLabel:I(`engine.inspector.reorder.down`,o),disabled:a}),(0,W.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:I(`engine.inspector.widget.close`,o),"aria-label":I(`engine.inspector.widget.close`,o),children:(0,W.jsx)(y,{className:`h-3.5 w-3.5`})})]})]}),(0,W.jsx)(Q,{id:`widget-title`,label:I(`engine.inspector.widget.title`,o),children:(0,W.jsx)(k,{id:`widget-title`,value:c.title??``,onChange:e=>p({title:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-type`,label:I(`engine.inspector.widget.type`,o),children:(0,W.jsxs)(u,{value:c.type??`metric`,onValueChange:e=>p({type:e}),disabled:a,children:[(0,W.jsx)(x,{id:`widget-type`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(C,{children:ce.map(e=>(0,W.jsx)(d,{value:e.value,children:e.label},e.value))})]})}),(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:I(`engine.inspector.widget.datasetSection`,o)}),(0,W.jsxs)(Q,{id:`widget-dataset`,label:I(`engine.inspector.widget.dataset`,o),children:[(0,W.jsx)(k,{id:`widget-dataset`,value:h,placeholder:I(`engine.inspector.widget.datasetPlaceholder`,o),onChange:e=>p({dataset:e.target.value||void 0}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.datasetHint`,o)})]}),h&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Q,{id:`widget-dimensions`,label:I(`engine.inspector.widget.dimensions`,o),children:[(0,W.jsx)(k,{id:`widget-dimensions`,value:g,placeholder:I(`engine.inspector.widget.dimensionsPlaceholder`,o),onChange:e=>p({dimensions:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.dimensionsHint`,o)})]}),(0,W.jsxs)(Q,{id:`widget-values`,label:I(`engine.inspector.widget.values`,o),children:[(0,W.jsx)(k,{id:`widget-values`,value:_,placeholder:I(`engine.inspector.widget.valuesPlaceholder`,o),onChange:e=>p({values:v(e.target.value)}),disabled:a}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:I(`engine.inspector.widget.valuesHint`,o)})]})]})]}),(0,W.jsx)(Q,{id:`widget-object`,label:I(`engine.inspector.widget.object`,o),children:(0,W.jsx)(k,{id:`widget-object`,value:c.object??``,placeholder:`e.g. order`,onChange:e=>p({object:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-value-field`,label:I(`engine.inspector.widget.valueField`,o),children:(0,W.jsx)(k,{id:`widget-value-field`,value:c.valueField??``,placeholder:`e.g. amount`,onChange:e=>p({valueField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-category-field`,label:I(`engine.inspector.widget.categoryField`,o),children:(0,W.jsx)(k,{id:`widget-category-field`,value:c.categoryField??``,placeholder:`e.g. status`,onChange:e=>p({categoryField:e.target.value}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-aggregate`,label:I(`engine.inspector.widget.aggregate`,o),children:(0,W.jsxs)(u,{value:c.aggregate??`count`,onValueChange:e=>p({aggregate:e}),disabled:a,children:[(0,W.jsx)(x,{id:`widget-aggregate`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(C,{children:Z.map(e=>(0,W.jsx)(d,{value:e,children:e},e))})]})}),(0,W.jsx)(Q,{id:`widget-color`,label:I(`engine.inspector.widget.color`,o),children:(0,W.jsxs)(u,{value:c.colorVariant??`default`,onValueChange:e=>p({colorVariant:e}),disabled:a,children:[(0,W.jsx)(x,{id:`widget-color`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(C,{children:le.map(e=>(0,W.jsx)(d,{value:e,children:e},e))})]})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsx)(Q,{id:`widget-w`,label:I(`engine.inspector.widget.width`,o),children:(0,W.jsx)(k,{id:`widget-w`,type:`number`,min:1,value:c.layout?.w??1,onChange:e=>p({layout:{...c.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,W.jsx)(Q,{id:`widget-h`,label:I(`engine.inspector.widget.height`,o),children:(0,W.jsx)(k,{id:`widget-h`,type:`number`,min:1,value:c.layout?.h??1,onChange:e=>p({layout:{...c.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,W.jsx)(`div`,{className:`pt-2 border-t`,children:(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(l,1),n({widgets:t}),r()},children:I(`engine.inspector.widget.remove`,o)})})]})}function Q({id:e,label:t,children:n}){return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(A,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function $({message:e,onClose:t,locale:n}){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,W.jsx)(`p`,{children:e}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:I(`engine.inspector.widget.close`,n)})]})}export{B as i,se as n,G as r,de as t};
|
|
@@ -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-BLEk-ou3.js";import{$n as i,Fi as a,Ft as o,Gi as s,Gt as c,It as l,Jn as u,Lt as d,Ma as f,Mt as p,Pt as m,Rt as h,Xn as g,Yn as _,Zn as v,cs as y,ct as b,dt as x,ft as S,gs as C,hr as w,lt as T,nn as E,on as D,ot as O,qn as k,rs as A,st as j,tt as M,ut as N,wr as P,ys as F}from"./ui-components-CrPYFyEM.js";import"./src-Bzm5L_v8.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:C,cls:`text-emerald-600 border-emerald-300`},completed:{icon:C,cls:`text-emerald-600 border-emerald-300`},failed:{icon:y,cls:`text-red-600 border-red-300`},error:{icon:y,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:A,cls:`text-amber-600 border-amber-300`},skipped:{icon:F,cls:`text-muted-foreground`}}[e]??{icon:F,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(i,{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,o]=(0,I.useState)(!0),[s,c]=(0,I.useState)(null),[l,d]=(0,I.useState)(``),[f,m]=(0,I.useState)(0),h=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){c(`meta.getItems is not available on this client`),o(!1);return}o(!0),c(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),!l&&r.length>0&&d(r[0].name)}catch(e){c(e?.message??String(e))}finally{o(!1)}},[e,l]);(0,I.useEffect)(()=>{h()},[h]);let y=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);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)(P,{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)(k,{children:[(0,L.jsx)(g,{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)(v,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:h,disabled:i,children:[(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(u,{children:[i&&(0,L.jsx)(p,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>d(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))})]})]}),y&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:y.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:y.name,refreshKey:f})]})]})}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),[d,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),p(null),h(null)},[t?.name]);let b=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(k,{children:[(0,L.jsxs)(g,{className:`pb-3`,children:[(0,L.jsx)(v,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(u,{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)(D,{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)(i,{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)(S,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>b(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)(M,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>b(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(E,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>b(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(w,{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)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(d||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||d?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(y,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof d?.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[d.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),d&&(0,L.jsx)(V,{data:d})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,s]=(0,I.useState)([]),[y,S]=(0,I.useState)(!0),[C,E]=(0,I.useState)(null),[D,A]=(0,I.useState)(null),[M,P]=(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){E(`automation.listRuns is not available on this client`),S(!1);return}S(!0),E(null);try{let n=await e.automation.listRuns(t,{limit:20});s(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){E(e?.message??String(e))}finally{S(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),P(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);P(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(k,{children:[(0,L.jsx)(g,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:W,disabled:y,children:[y?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(u,{children:[y&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(p,{className:`h-8 w-full`}),(0,L.jsx)(p,{className:`h-8 w-full`}),(0,L.jsx)(p,{className:`h-8 w-full`})]}),!y&&C&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:C}),!y&&!C&&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.`}),!y&&!C&&r.length>0&&(0,L.jsxs)(O,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(x,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(x,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(b,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(b,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(b,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(b,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(m,{open:!!D,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(o,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(d,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,D]}),(0,L.jsx)(l,{children:M&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:M.status}),typeof M.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[M.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(M.startedAt)})]})})]}),(0,L.jsxs)(c,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(p,{className:`h-16 w-full`}),(0,L.jsx)(p,{className:`h-16 w-full`}),(0,L.jsx)(p,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&M&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(M.steps)&&M.steps.length>0?M.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)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(i,{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:M})]})})]})]})})]})}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-BLEk-ou3.js";import{$n as i,Fi as a,Ft as o,Gi as s,Gt as c,It as l,Jn as u,Lt as d,Ma as f,Mt as p,Pt as m,Rt as h,Xn as g,Yn as _,Zn as v,cs as y,ct as b,dt as x,ft as S,gs as C,hr as w,lt as T,nn as E,on as D,ot as O,qn as k,rs as A,st as j,tt as M,ut as N,wr as P,ys as F}from"./ui-components-CrPYFyEM.js";import"./src-DXFkWHTV.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:C,cls:`text-emerald-600 border-emerald-300`},completed:{icon:C,cls:`text-emerald-600 border-emerald-300`},failed:{icon:y,cls:`text-red-600 border-red-300`},error:{icon:y,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:A,cls:`text-amber-600 border-amber-300`},skipped:{icon:F,cls:`text-muted-foreground`}}[e]??{icon:F,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(i,{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,o]=(0,I.useState)(!0),[s,c]=(0,I.useState)(null),[l,d]=(0,I.useState)(``),[f,m]=(0,I.useState)(0),h=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){c(`meta.getItems is not available on this client`),o(!1);return}o(!0),c(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),!l&&r.length>0&&d(r[0].name)}catch(e){c(e?.message??String(e))}finally{o(!1)}},[e,l]);(0,I.useEffect)(()=>{h()},[h]);let y=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);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)(P,{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)(k,{children:[(0,L.jsx)(g,{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)(v,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:h,disabled:i,children:[(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(u,{children:[i&&(0,L.jsx)(p,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>d(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))})]})]}),y&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:y.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:y.name,refreshKey:f})]})]})}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),[d,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),p(null),h(null)},[t?.name]);let b=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(k,{children:[(0,L.jsxs)(g,{className:`pb-3`,children:[(0,L.jsx)(v,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(u,{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)(D,{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)(i,{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)(S,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>b(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)(M,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>b(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(E,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>b(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(w,{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)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(d||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||d?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(y,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof d?.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[d.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),d&&(0,L.jsx)(V,{data:d})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,s]=(0,I.useState)([]),[y,S]=(0,I.useState)(!0),[C,E]=(0,I.useState)(null),[D,A]=(0,I.useState)(null),[M,P]=(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){E(`automation.listRuns is not available on this client`),S(!1);return}S(!0),E(null);try{let n=await e.automation.listRuns(t,{limit:20});s(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){E(e?.message??String(e))}finally{S(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),P(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);P(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(k,{children:[(0,L.jsx)(g,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:W,disabled:y,children:[y?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(u,{children:[y&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(p,{className:`h-8 w-full`}),(0,L.jsx)(p,{className:`h-8 w-full`}),(0,L.jsx)(p,{className:`h-8 w-full`})]}),!y&&C&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:C}),!y&&!C&&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.`}),!y&&!C&&r.length>0&&(0,L.jsxs)(O,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(x,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(x,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(b,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(b,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(b,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(b,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(m,{open:!!D,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(o,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(d,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,D]}),(0,L.jsx)(l,{children:M&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:M.status}),typeof M.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[M.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(M.startedAt)})]})})]}),(0,L.jsxs)(c,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(p,{className:`h-16 w-full`}),(0,L.jsx)(p,{className:`h-16 w-full`}),(0,L.jsx)(p,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&M&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(M.steps)&&M.steps.length>0?M.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)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(i,{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:M})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,p as n,t as r}from"./vendor-react-DR370ovB.js";import{T as i,r as a,w as o}from"./framework-BLEk-ou3.js";import{H as s,R as c,Wo as l,z as u}from"./ui-components-CrPYFyEM.js";import"./MetadataProvider-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,p as n,t as r}from"./vendor-react-DR370ovB.js";import{T as i,r as a,w as o}from"./framework-BLEk-ou3.js";import{H as s,R as c,Wo as l,z as u}from"./ui-components-CrPYFyEM.js";import"./MetadataProvider-Bja7m8Gt.js";import{c as d}from"./plugins-views-DUKPQNs8.js";var f=e(t(),1),p=`uf_`;function m(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(p)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function h(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=p+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var g=r();function _(e){return Array.isArray(e?.columns)&&e.columns.length>0}function v(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(_)??r[0]}var y=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function b(e){if(Array.isArray(e?.compactLayout)&&e.compactLayout.length>0)return e.compactLayout.filter(t=>e.fields?.[t]);let t=e?.fields;return t&&typeof t==`object`?Object.entries(t).filter(([e,t])=>t&&!t.hidden&&!y.has(e)).map(([e])=>e).slice(0,6):[]}function x(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!y.has(e)&&t(e,n))?.[0]}var S=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),C=new Set([`date`,`datetime`,`time`]),w=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function T(e){let t=x(e,(e,t)=>S.has(t.type))??x(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function E(e){return x(e,(e,t)=>C.has(t.type))??x(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function D(e){let t=E(e);return t?{startDateField:t}:void 0}function O(e){let t=x(e,(e,t)=>w.has(t.type));return t?{coverField:t}:void 0}function k({page:e,className:t}){let{t:r}=a(),{objects:p}=i(),y=o(),[,x]=n(),[S]=f.useState(()=>m(new URLSearchParams(window.location.search))),C=f.useCallback(e=>{x(t=>h(t,e),{replace:!0})},[x]),w=e?.interfaceConfig||{},E=f.useMemo(()=>(p||[]).find(e=>e.name===w.source),[p,w.source]),k=f.useMemo(()=>v(E,w.sourceView),[E,w.sourceView]),A=E?.name,j=!!k&&!_(k),M=k?.name??(w.sourceView?`${w.source}.${w.sourceView}`:void 0),[N,P]=f.useState(null);f.useEffect(()=>{let e=!1;if(P(null),!(!A||!w.source||!j||!M))return(async()=>{try{let t=y,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(w.source))?.[M]??null),!_(n)&&typeof t?.getView==`function`&&(n=await t.getView(w.source,M)),!e&&n&&typeof n==`object`&&P(n)}catch{}})(),()=>{e=!0}},[A,w.source,w.sourceView,j,M,y]);let F=f.useMemo(()=>N?{...k,...N}:k,[k,N]),I=JSON.stringify(F??null),L=f.useMemo(()=>{if(!E)return;let e=F||{},t=w.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=w.userActions||{},a=e.kanban??(r.has(`kanban`)?T(E):void 0),o=e.calendar??(r.has(`calendar`)?D(E):void 0),s=e.timeline??(r.has(`timeline`)?D(E):void 0),c=e.gallery??(r.has(`gallery`)?O(E):void 0),l=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(w.filterBy)?w.filterBy:[]],u=_(e)?e.columns:b(E);return{type:`list-view`,objectName:E.name,viewType:n[0]??e.type??`grid`,fields:u,...l.length?{filters:l}:{},...e.sort?.length?{sort:e.sort}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:e.gantt,userFilters:w.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:w.showRecordCount,addRecord:w.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:!1}},[A,I,w]);return!E||!L?(0,g.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,g.jsxs)(c,{children:[(0,g.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,g.jsx)(l,{className:`h-6 w-6 text-muted-foreground`})}),(0,g.jsx)(s,{children:r(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,g.jsx)(u,{children:r(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:w.source||`?`})})]})}):(0,g.jsxs)(`div`,{className:t??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,g.jsxs)(`div`,{className:`px-4 pt-4 pb-2 shrink-0`,children:[(0,g.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),(0,g.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,g.jsx)(d,{schema:L,dataSource:y,userFilterSelections:S,onUserFilterSelectionsChange:C})})]})}export{h as n,m as r,k as t};
|
package/dist/assets/{MarketplacePackagePage-BWCVUz3e.js → MarketplacePackagePage-DOZgrTZo.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-CJNwTVno.js";import{T as te,r as ne}from"./framework-BLEk-ou3.js";import{$n as o,$o as s,Bn as re,Bo as ie,Bt as ae,Er as oe,Hn as se,Ht as ce,Io as le,Jn as ue,Kn as c,Ln as de,Lo as fe,Ma as l,Mt as u,Rn as pe,Ut as me,Vn as he,Vr as d,Vt as ge,Wo as _e,Ws as f,Wt as ve,Xn as ye,Zn as be,_i as p,cn as xe,fa as m,gi as Se,gn as Ce,gs as h,ho as we,hr as g,on as _,qn as Te,sc as Ee,sn as De,ua as Oe,un as v,vs as ke,ys as y,zn as Ae}from"./ui-components-CrPYFyEM.js";import"./MetadataProvider-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-CJNwTVno.js";import{T as te,r as ne}from"./framework-BLEk-ou3.js";import{$n as o,$o as s,Bn as re,Bo as ie,Bt as ae,Er as oe,Hn as se,Ht as ce,Io as le,Jn as ue,Kn as c,Ln as de,Lo as fe,Ma as l,Mt as u,Rn as pe,Ut as me,Vn as he,Vr as d,Vt as ge,Wo as _e,Ws as f,Wt as ve,Xn as ye,Zn as be,_i as p,cn as xe,fa as m,gi as Se,gn as Ce,gs as h,ho as we,hr as g,on as _,qn as Te,sc as Ee,sn as De,ua as Oe,un as v,vs as ke,ys as y,zn as Ae}from"./ui-components-CrPYFyEM.js";import"./MetadataProvider-Bja7m8Gt.js";import{_ as je,a as Me,b,c as Ne,g as Pe,h as Fe,i as Ie,m as Le,o as Re,p as ze,r as x,s as Be,t as Ve,u as He}from"./marketplaceApi-CucX7DD9.js";import{n as Ue,t as We}from"./usePackageL10n-shLsxEAx.js";import{t as Ge}from"./MarketplaceAccessDenied-CXUE33gy.js";var S=e(n(),1),C=i();function w(e){let t=e.replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.startsWith("```")){let i=e.slice(3).trim();r++;let a=[];for(;r<t.length&&!t[r].startsWith("```");)a.push(t[r]),r++;r++,n.push({type:`code`,text:a.join(`
|
|
4
4
|
`),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function T(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,C.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,C.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,C.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,C.jsx)(C.Fragment,{children:t.map((e,t)=>(0,C.jsx)(S.Fragment,{children:e},t))})}function Ke({source:e,className:t}){let n=w(e);return(0,C.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,C.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:T(e.text??``)},t);case`h2`:return(0,C.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:T(e.text??``)},t);case`h3`:return(0,C.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:T(e.text??``)},t);case`p`:return(0,C.jsx)(`p`,{children:T(e.text??``)},t);case`ul`:return(0,C.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,C.jsx)(`span`,{children:T(e)})]},t))},t);case`ol`:return(0,C.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,C.jsx)(`li`,{className:`pl-1`,children:T(e)},t))},t);case`code`:return(0,C.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,C.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var qe={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function E({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,C.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function Je({version:e}){let{t}=ne();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,C.jsx)(s,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,C.jsx)(o,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:qe[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(o,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(Se,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(o,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(p,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(o,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(h,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,C.jsx)(E,{icon:f,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(E,{icon:oe,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(E,{icon:m,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(E,{icon:we,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var D=t({MarketplacePackagePage:()=>O});function O(){let e=a(),{packageId:t,appName:n}=r(),i=ee(),{t:s,language:oe}=ne(),f=n?`/apps/${n}`:``,{refresh:p}=te(),[m,Se]=(0,S.useState)(null),[we,w]=(0,S.useState)(!0),[T,qe]=(0,S.useState)(null),[E,D]=(0,S.useState)(!1),[O,Ye]=(0,S.useState)([]),[Xe,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(null),[M,N]=(0,S.useState)(``),[Ze,Qe]=(0,S.useState)({}),[P,$e]=(0,S.useState)(!1),[et,tt]=(0,S.useState)(!1),[F,nt]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),[R,rt]=(0,S.useState)(null),[z,B]=(0,S.useState)(null),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[it,G]=(0,S.useState)([]),[K,q]=(0,S.useState)(!1),[J,Y]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!b().features.installLocal)return;let e=!1;return(async()=>{let t=await He();e||G(t)})(),()=>{e=!0}},[t,J]),(0,S.useEffect)(()=>{if(!t)return;let e=b().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await x(t,e);n||!r||(B(r),rt(r.version))})(),()=>{n=!0}},[t]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{if(t){w(!0),qe(null);try{let n=await Ie(t);e||Se(n)}catch(t){e||qe(t?.message??String(t))}finally{e||w(!1)}}})(),()=>{e=!0}},[t]);let at=async()=>{D(!0),L(null),j(null);let e=b().defaultEnvironmentId;if(e){k(!1),N(e),Ye([]);return}k(!0);try{let[e,n]=await Promise.all([Be(),Ne()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});Ye(r),Qe({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await x(i,e.id);return t?[e.id,t.version]:null}catch{return null}})).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);Qe(t)}),e.length>0&&r.length===0?j(s(`marketplace.install.noPermission`)):r.length===1&&N(r[0].id)}catch(e){let t=e?.status;j(t===401||t===403?s(`marketplace.install.signInFirst`):e?.message??String(e))}finally{k(!1)}},ot=async()=>{if(!(!t||!M)){nt(!0),L(null);try{rt(((await Re({packageId:t,environmentId:M,seedSampleData:P}))?.installation?.version??m?.package?.latest_version?.version??m?.versions?.[0]?.version??``)||`installed`);try{let e=b().defaultEnvironmentId||M;if(e){let n=await x(t,e);n&&B(n)}}catch{}let e=b().defaultEnvironmentId;if(!e||e===M)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await p()}catch{}L({ok:!0,message:s(`marketplace.install.success`)})}catch(e){L({ok:!1,message:e?.message??String(e)})}finally{nt(!1)}}},st=async()=>{if(t){q(!0),Y(null);try{let e=await Me({packageId:t});try{await p(`app`)}catch{}Y({ok:!0,message:s(`marketplace.install.localSuccess`,{version:e.version,name:m?.package?We(m.package,oe).displayName:e.manifestId})})}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=s(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=s(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=s(`marketplace.install.localMarketplaceUnavailable`)),Y({ok:!1,message:n})}finally{q(!1)}}},ct=async()=>{if($&&confirm(s(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){q(!0),Y(null);try{await je($.manifestId);try{await p(`app`)}catch{}Y({ok:!0,message:s(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){Y({ok:!1,message:e?.message??String(e)})}finally{q(!1)}}},lt=async()=>{if(z){H(`reseed`),W(null);try{let e=await Pe(z.installationId);e.ok?(B({...z,withSampleData:!0}),W({ok:!0,text:s(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):W({ok:!1,text:e.error||`Re-seed failed`})}finally{H(null)}}},ut=async()=>{if(z&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){H(`purge`),W(null);try{let e=await Le(z.installationId);if(e.ok){B({...z,withSampleData:!1});let t=e.deleted??0;W({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else W({ok:!1,text:e.error||`Purge failed`})}finally{H(null)}}},dt=async()=>{if($){H(`reseed`),W(null);try{let e=await Fe($.manifestId);G(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0;W({ok:!0,text:s(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`})}catch(e){W({ok:!1,text:e?.message||`Re-seed failed`})}finally{H(null)}}},ft=async()=>{if($&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){H(`purge`),W(null);try{let e=await ze($.manifestId);G(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;W({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){W({ok:!1,text:e?.message||`Purge failed`})}finally{H(null)}}};if(we)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsx)(u,{className:`h-8 w-32`}),(0,C.jsx)(u,{className:`h-16 w-full`}),(0,C.jsx)(u,{className:`h-64 w-full`})]});if(T||!m)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:()=>e(`${f}/system/marketplace`),children:[(0,C.jsx)(Ee,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,C.jsx)(y,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`font-medium text-destructive`,children:s(`marketplace.load.packageFailed`)}),(0,C.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:T??s(`marketplace.load.notFound`)})]})]})]});let X=m.package,Z=We(X,oe),Q=X.latest_version?.version??m.versions[0]?.version??null,$=it.find(e=>e.manifestId===X.manifest_id)??null,pt=!!X.latest_version?.contains_code,mt=!!R&&R!==`installed`&&!!Q&&R!==Q,ht=b().features.installLocal,gt=!Q||K||F||!ht&&!!R&&!mt,_t=ht?{label:s(K?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:st}:{label:F?s(`marketplace.action.installing`):R?mt?s(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Q}):s(`marketplace.action.installed`,{defaultValue:`Installed`}):s(`marketplace.action.installToCloud`),onClick:at},vt=X.category?s(`marketplace.category.${X.category}`,{defaultValue:X.category}):null;return i?(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(g,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${f}/system/marketplace`),children:[(0,C.jsx)(Ee,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,C.jsx)(Ue,{iconUrl:X.icon_url,displayName:Z.displayName,manifestId:X.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,C.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Z.displayName||X.manifest_id}),X.homepage_url&&(0,C.jsxs)(`a`,{href:X.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:s(`marketplace.detail.homepage`),children:[(0,C.jsx)(le,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:s(`marketplace.detail.homepage`)})]})]}),(0,C.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,C.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:X.manifest_id}),Q&&(0,C.jsx)(o,{variant:`outline`,children:s(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,C.jsx)(o,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),vt&&(0,C.jsx)(o,{variant:`outline`,children:vt}),X.license&&(0,C.jsx)(o,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,C.jsxs)(o,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(h,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:$.version})]}),!$&&R&&(0,C.jsxs)(o,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(h,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:R})]}),mt&&(0,C.jsxs)(o,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,C.jsx)(ke,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Q]})]}),Z.description&&(0,C.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Z.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,C.jsxs)(g,{onClick:_t.onClick,disabled:gt,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(ie,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),_t.label]}),$&&(0,C.jsxs)(De,{children:[(0,C.jsx)(Ce,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`),children:(0,C.jsx)(fe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(xe,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(v,{onSelect:dt,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(l,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(_e,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(v,{onSelect:ft,disabled:V!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(l,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(d,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(v,{onSelect:ct,disabled:K,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(d,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&z&&!b().cloudUrl&&(0,C.jsxs)(De,{children:[(0,C.jsx)(Ce,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`)||`More options`,children:(0,C.jsx)(fe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(xe,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(v,{onSelect:lt,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(l,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(_e,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),z.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(v,{onSelect:ut,disabled:V!==null||!z.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(l,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(d,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),U&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${U.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[U.ok?(0,C.jsx)(h,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(y,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:U.text}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>W(null),children:s(`marketplace.action.dismiss`)})]}),J&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${J.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[J.ok?(0,C.jsx)(h,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(y,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:J.message}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>Y(null),children:s(`marketplace.action.dismiss`)})]}),(0,C.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,C.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,C.jsxs)(Te,{children:[(0,C.jsx)(ye,{children:(0,C.jsx)(be,{className:`text-base`,children:s(`marketplace.detail.about`)})}),(0,C.jsx)(ue,{children:Z.readme?(0,C.jsx)(Ke,{source:Z.readme}):(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noReadme`)})})]})}),(0,C.jsx)(`div`,{className:`space-y-4`,children:(0,C.jsxs)(Te,{children:[(0,C.jsx)(ye,{children:(0,C.jsx)(be,{className:`text-base`,children:s(`marketplace.detail.versions`)})}),(0,C.jsx)(ue,{children:m.versions.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noApprovedVersions`)}):(0,C.jsx)(`ul`,{className:`space-y-3`,children:m.versions.map(e=>(0,C.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(Oe,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,C.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,C.jsx)(o,{variant:`outline`,className:`text-xs`,children:s(`marketplace.detail.prerelease`)})]}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString():`—`})]}),e.release_notes&&e.release_notes.trim()&&(0,C.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,C.jsx)(de,{open:E,onOpenChange:e=>{D(e),e||(L(null),tt(!1))},children:(0,C.jsxs)(pe,{children:[(0,C.jsxs)(he,{children:[(0,C.jsx)(se,{children:s(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,C.jsx)(Ae,{children:b().defaultEnvironmentId?s(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):s(`marketplace.install.dialogDescPicker`)})]}),Xe?(0,C.jsx)(u,{className:`h-10 w-full`}):A?(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(y,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:A})]}),(0,C.jsx)(`a`,{href:Ve(X.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,C.jsxs)(g,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(le,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.action.openOnCloud`)]})})]}):b().defaultEnvironmentId?(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(c,{id:`seed`,checked:P,onCheckedChange:e=>$e(e===!0)}),(0,C.jsx)(_,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]}):O.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.install.noEnvs`)}):(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(_,{htmlFor:`env-select`,children:s(`marketplace.install.environment`)}),(0,C.jsxs)(ae,{value:M,onValueChange:N,children:[(0,C.jsx)(me,{id:`env-select`,children:(0,C.jsx)(ve,{placeholder:s(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(ge,{children:O.map(e=>{let t=Ze[e.id],n=!!t&&!!Q&&t!==`installed`&&t!==Q;return(0,C.jsxs)(ce,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,C.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,s(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Q})]}):(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,s(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(c,{id:`seed`,checked:P,onCheckedChange:e=>$e(e===!0)}),(0,C.jsx)(_,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]})]}),pt&&!A&&(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(Je,{version:X.latest_version}),(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(c,{id:`ack-perms`,checked:et,onCheckedChange:e=>tt(e===!0)}),(0,C.jsx)(_,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:s(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),I&&(0,C.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${I.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:I.message}),(0,C.jsxs)(re,{children:[(0,C.jsx)(g,{variant:`outline`,onClick:()=>D(!1),children:s(`marketplace.action.close`)}),!A&&(0,C.jsx)(g,{onClick:ot,disabled:!M||F||I?.ok===!0||pt&&!et,children:s(F?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,C.jsx)(Ge,{})}export{D as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{C as a}from"./framework-BLEk-ou3.js";import{n as o}from"./data-adapter-CCidkDs3.js";import{i as s}from"./plugin-form-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{C as a}from"./framework-BLEk-ou3.js";import{n as o}from"./data-adapter-CCidkDs3.js";import{i as s}from"./plugin-form-DXCdD2d-.js";var c=e(t(),1),l=r(),u=(0,c.createContext)(!1),d=`preview`,f=`draft`;function p(e){return new URLSearchParams(e).get(d)===f}var m=!1;function h(){m=!0}function g({force:e,children:t}){let r=n(),a=i(),o=(0,c.useMemo)(()=>p(r.search),[r.search]),[s,h]=(0,c.useState)(o);return(0,c.useEffect)(()=>{if(o){h(!0),m=!1;return}if(!s)return;if(m){m=!1,h(!1);return}let e=new URLSearchParams(r.search);e.set(d,f),a(`${r.pathname}?${e.toString()}${r.hash}`,{replace:!0})},[o,s,r.pathname,r.search,r.hash,a]),(0,l.jsx)(u.Provider,{value:e??(o||s),children:t})}function _(){return(0,c.useContext)(u)}var v=null,y=0,b=0,x=null,S={editor:v,openSeq:y,reviewSeq:b,reviewTarget:x},C=new Set;function w(){S={editor:v,openSeq:y,reviewSeq:b,reviewTarget:x};for(let e of C)e()}function T(e,t){return e===t?!0:JSON.stringify(e)===JSON.stringify(t)}var E={subscribe(e){return C.add(e),()=>{C.delete(e)}},getSnapshot(){return S},setEditor(e){T(v,e)||(v=e,w())},requestOpen(){y+=1,w()},requestReview(e){b+=1,x=e,w()}},D=new Set;function O(e){for(let t of D)t(e)}function k(e){return D.add(e),()=>{D.delete(e)}}function A(){return(0,c.useSyncExternalStore)(E.subscribe,E.getSnapshot,E.getSnapshot)}function j(e){(0,c.useEffect)(()=>(E.setEditor(e),()=>E.setEditor(null)),[e?JSON.stringify(e):``])}function M(){E.requestOpen()}function N(e){E.requestReview(e)}var P=300*1e3,F=[`app`,`view`],I={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},L=`objectui:metadata:`;function R(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var z=R();function B(...e){z&&console.debug(`[MetadataProvider]`,...e)}function V(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function H(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function U(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function W(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function G(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)W(e)&&r.add(e.object);for(let e of t){if(W(e)){let t=n[e.object]||={listViews:{},formViews:{}},r=e.name||`${e.object}.${e.viewKind}`,i=e.config&&typeof e.config==`object`?e.config:{},a={...i,name:r,label:e.label??i.label,isDefault:!!e.isDefault};e.viewKind===`form`?(t.formViews[r]=a,(e.isDefault||!t.form)&&(t.form=a)):(t.listViews[r]=a,e.isDefault&&(t.primary=a));continue}let t=e?.name||e?.list?.data?.object||e?.form?.data?.object;if(!t||r.has(t))continue;let i=n[t]||={listViews:{},formViews:{}};if(e.list){i.primary=e.list;let t=e.list.name||`list`;i.listViews[t]=e.list}if(e.form&&(i.form=e.form),e.listViews&&typeof e.listViews==`object`)for(let[t,n]of Object.entries(e.listViews))i.listViews[t]=n;if(e.formViews&&typeof e.formViews==`object`)for(let[t,n]of Object.entries(e.formViews))i.formViews[t]=n}return e.map(e=>{let t=n[e.name];if(!t)return e;let r=e.listViews||e.list_views||{},i=e.formViews||e.form_views||{},a={...e,listViews:{...t.listViews,...r}};return(Object.keys(t.formViews).length||Object.keys(i).length)&&(a.formViews={...t.formViews,...i}),t.primary&&!e.list&&(a.list=t.primary),t.form&&!e.form&&(a.form=t.form),a})}function K(e){if(!e?.length)return e;let t={};for(let n of e){let e=n?.fields;if(!e)continue;let r=Array.isArray(e)?e.map(e=>[e?.name,e]):Object.entries(e);for(let[e,i]of r){let r=i;if(!e||!r?.inlineEdit||r.type!==`master_detail`&&r.type!==`lookup`)continue;let a=r.reference;a&&(t[a]||=[]).push({childObject:n.name,relationshipField:e,inlineMode:s(n,r.inlineEdit,{relationshipField:e}),...r.inlineTitle?{title:r.inlineTitle}:{},...Array.isArray(r.inlineColumns)?{columns:r.inlineColumns}:{},...typeof r.inlineAmountField==`string`?{amountField:r.inlineAmountField}:{}})}}return Object.keys(t).length?e.map(e=>{let n=t[e.name];if(!n?.length)return e;let r={...e.form||{type:`simple`}},i=Array.isArray(r.subforms)?r.subforms:[],a=new Set(i.map(e=>e.childObject));r.subforms=[...n.filter(e=>!a.has(e.childObject)),...i];let o={...e,form:r};return e.formViews?.default&&(o.formViews={...e.formViews,default:{...e.formViews.default,subforms:r.subforms}}),o}):e}function q(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function J(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(L+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function Y(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(L+e,JSON.stringify(t))}catch{}}function X({children:e,adapter:t,ttlMs:n=P}){let r=(0,c.useRef)(new Map),i=(0,c.useRef)(new Map),s=(0,c.useRef)(t);s.current=t;let u=_(),d=(0,c.useMemo)(()=>u?new o({baseUrl:``,previewDrafts:!0}):null,[u]),f=(0,c.useRef)(d);f.current=d;let[p,m]=(0,c.useState)(0),h=(0,c.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>m(e=>e+1)):Promise.resolve().then(()=>m(e=>e+1))},[]);(0,c.useEffect)(()=>{r.current.clear(),i.current.clear(),h()},[u,h]);let g=(0,c.useCallback)(e=>{let t=r.current.get(e);return t||(t=q(),r.current.set(e,t)),t},[]),v=(0,c.useCallback)(e=>{let t=g(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return B(`cache hit (fresh) type=${e} items=${t.items.length}`),Promise.resolve(t.items);let r=Date.now();t.status=`loading`,t.error=null;let i=f.current,a=(i?i.list(e):s.current.getClient().meta.getItems(e)).then(n=>{let a=V(n);t.items=a,t.status=`ready`,t.error=null,t.fetchedAt=Date.now(),t.promise=null,t.byName.clear();for(let e of a)U(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&Y(e,a),B(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),h(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,B(`fetch failed type=${e}`,r),h(),[]});return t.promise=a,a},[h,g,n]),y=(0,c.useCallback)((e,t)=>{let n=g(e);if(n.byName.has(t))return B(`item cache hit type=${e} name=${t}`),Promise.resolve(n.byName.get(t)??null);let r=i.current.get(e);r||(r=new Map,i.current.set(e,r));let a=r.get(t);if(a)return a;let o=Date.now(),c=f.current,l=(c?c.get(e,t):s.current.getClient().meta.getItem(e,t)).then(i=>{let a=H(i);return a&&n.byName.set(t,a),B(`fetched item type=${e} name=${t} in ${Date.now()-o}ms`),r.delete(t),a}).catch(n=>(r.delete(t),B(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[g]),b=(0,c.useCallback)(async e=>{if(e){let t=g(e);t.fetchedAt=0,t.byName.clear(),await v(e);return}let t=Array.from(r.current.keys()).filter(e=>r.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=r.current.get(e);return t.fetchedAt=0,t.byName.clear(),v(e)}))},[v,g]),x=(0,c.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),B(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,B(`invalidated type=${e}`)),h())},[h]);(0,c.useEffect)(()=>{if(u)return k(({type:e})=>{x(e)})},[u,x]);let[S,C]=(0,c.useState)(!0),[w,T]=(0,c.useState)(null);(0,c.useEffect)(()=>{let e=!1,t=u?null:J(`app`);if(t){let e=g(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)U(n)&&e.byName.set(n.name,n);h(),C(!1)}return(async()=>{for(let t of F)try{await v(t),e||T(null)}catch(t){e||T(t instanceof Error?t:Error(String(t)))}e||C(!1)})(),()=>{e=!0}},[t,v,g,h,u]);let E=(0,c.useMemo)(()=>{let e=e=>{let t=g(e);return t.status===`idle`&&v(e),t.items};return{apps:g(`app`).items,get objects(){let t=e(I.objects),n=e(`view`);return K(n.length?G(t,n):t)},get dashboards(){return e(I.dashboards)},get reports(){return e(I.reports)},get pages(){return e(I.pages)},loading:S,error:w??g(`app`).error,refresh:b,invalidate:x,ensureType:v,getItem:y,getItemsByType:t=>e(t),getTypeStatus:e=>g(e).status}},[p,S,w,v,y,g,b,x]);return(0,l.jsx)(a.Provider,{value:E,children:e})}export{A as a,g as c,N as i,h as l,O as n,j as o,M as r,d as s,X as t,_ as u};
|