@objectstack/console 11.3.0 → 11.4.0
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/{AdapterProvider-BiTdGDAR.js → AdapterProvider-DPeLrdd0.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-pA6WQiJs.js → AiPendingActionsPage-CK0MN4fG.js} +1 -1
- package/dist/assets/{ApiConsolePage-C2RUq2a1.js → ApiConsolePage-BmQiYn3w.js} +1 -1
- package/dist/assets/{AppDocsIndex-4jDRVpod.js → AppDocsIndex-BZTtsBDk.js} +1 -1
- package/dist/assets/{AppManagementPage-D4Qdfc-k.js → AppManagementPage-JurgDSH0.js} +1 -1
- package/dist/assets/{ApprovalsInboxPage-97ofFRyB.js → ApprovalsInboxPage-C9iYBMLT.js} +1 -1
- package/dist/assets/{AuditLogPage-CE9VainX.js → AuditLogPage-DL7PJi-M.js} +1 -1
- package/dist/assets/{ComponentNavView-HWYwp2J3.js → ComponentNavView-DKxGXsn4.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-CYQ0DGQS.js → ConsoleFloatingChatbot-C2nsKCCe.js} +1 -1
- package/dist/assets/{DashboardView-_v1xyHY7.js → DashboardView-B7b14P2Q.js} +1 -1
- package/dist/assets/{DashboardWidgetInspector-CagpzDS6.js → DashboardWidgetInspector-C34BJd1Y.js} +1 -1
- package/dist/assets/{DeveloperHubPage-BSqHoM6g.js → DeveloperHubPage-L2d7wuq1.js} +1 -1
- package/dist/assets/{ExpressionProvider-BeRnSjp4.js → ExpressionProvider-1HR1mriH.js} +1 -1
- package/dist/assets/{FlowRunsPage-dzQVp59a.js → FlowRunsPage-BjOtW_pQ.js} +1 -1
- package/dist/assets/{IntegrationsPage-COUMVn63.js → IntegrationsPage-DAdLb-sn.js} +1 -1
- package/dist/assets/{InterfaceListPage-DyRkCp_l.js → InterfaceListPage-DqCSKUiZ.js} +1 -1
- package/dist/assets/{ManagedByBadge-CorAI3gR.js → ManagedByBadge-DbBdqwy6.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-BQ6-NcgV.js → MarketplaceAccessDenied-D5Q4tCaN.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-CUPRsl4f.js → MarketplaceInstalledPage-DVJsLTJz.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-CiSZE5lH.js → MarketplacePackagePage-BAmq5XCe.js} +1 -1
- package/dist/assets/{MarketplacePage-CzTXmemx.js → MarketplacePage-DEHHowk4.js} +1 -1
- package/dist/assets/MetadataInspector-B-6wYdsG.js +1 -0
- package/dist/assets/{MetadataProvider-CkIT9awy.js → MetadataProvider-BWz_wO6c.js} +1 -1
- package/dist/assets/{PageView-B82BdAMg.js → PageView-Cpr2xKrz.js} +1 -1
- package/dist/assets/{ProfilePage-BbTxTg63.js → ProfilePage-DqnQIsPE.js} +1 -1
- package/dist/assets/{PublicFormsPage-CHmoVuOC.js → PublicFormsPage-31yNJEQI.js} +1 -1
- package/dist/assets/{RecordDetailView-Bo53OY-a.js → RecordDetailView-BQ_3CT6r.js} +2 -2
- package/dist/assets/{RecordFormPage-BXLWOLOE.js → RecordFormPage-BlwecW-b.js} +1 -1
- package/dist/assets/{ReportDefaultInspector-BxP74HM2.js → ReportDefaultInspector-CN7-euct.js} +2 -2
- package/dist/assets/{ReportView-BWv6u_ys.js → ReportView-sIfQGnUd.js} +1 -1
- package/dist/assets/{SearchResultsPage-DvvT6E4h.js → SearchResultsPage-tqhQY_2e.js} +1 -1
- package/dist/assets/{SettingsHub-CDaz4A8F.js → SettingsHub-DxYP6XPZ.js} +1 -1
- package/dist/assets/{SettingsView-CkL3YJNr.js → SettingsView-BozW36Q1.js} +1 -1
- package/dist/assets/{SystemHubPage-DRMrwvla.js → SystemHubPage-BWj_QRhg.js} +1 -1
- package/dist/assets/{data-adapter-B9YoyoUW.js → data-adapter-ByjA1NUo.js} +1 -1
- package/dist/assets/{framework-BGQ7DoWM.js → framework-DxDZ_zWg.js} +7 -7
- package/dist/assets/{highlighted-body-OFNGDK62-D9Y-fWz-.js → highlighted-body-OFNGDK62-Dd_tKU0d.js} +1 -1
- package/dist/assets/{index-BzqR5LGR.js → index-BOAOy2Kf.js} +1 -1
- package/dist/assets/index-D77Ldu25.css +2 -0
- package/dist/assets/mermaid-GHXKKRXX-C3IUIOL6.js +1 -0
- package/dist/assets/{metadata-admin-CWGl9yQd.js → metadata-admin-D-7GOz4f.js} +5 -5
- package/dist/assets/{plugin-calendar-Bvz5MlbF.js → plugin-calendar-BcvpxKiE.js} +1 -1
- package/dist/assets/plugin-charts-CDte3Ehs.js +7 -0
- package/dist/assets/{plugin-chatbot-C7dKmmA6.js → plugin-chatbot-DniX3Bvt.js} +5 -5
- package/dist/assets/{plugin-dashboard-CWaZph1r.js → plugin-dashboard-o2MA7Ifu.js} +3 -3
- package/dist/assets/{plugin-form-B73E4Mbd.js → plugin-form-DZ4onNeM.js} +1 -1
- package/dist/assets/{plugin-gantt-Bf38rZLK.js → plugin-gantt-AilsJyD3.js} +2 -2
- package/dist/assets/{plugin-grid-a4T-OeTY.js → plugin-grid-3YqjO8MI.js} +4 -4
- package/dist/assets/{plugin-kanban-Co4jnw0I.js → plugin-kanban-CLMCf7aa.js} +1 -1
- package/dist/assets/{plugin-map-Cr2T-pjl.js → plugin-map-CWL5OAIS.js} +1 -1
- package/dist/assets/{plugin-markdown-PeIRJlRw.js → plugin-markdown-Bb6EtX1b.js} +1 -1
- package/dist/assets/{plugin-report-DacHRf4i.js → plugin-report-B8k3qnd6.js} +3 -3
- package/dist/assets/{plugin-timeline-ueCjCHSY.js → plugin-timeline-CHfJ8XYZ.js} +1 -1
- package/dist/assets/{plugin-tree-KBPNkKuR.js → plugin-tree-DabKEfvM.js} +1 -1
- package/dist/assets/{plugin-view-CbNN954o.js → plugin-view-c3Puf0-v.js} +1 -1
- package/dist/assets/plugins-views-BFmfVAkr.js +4 -0
- package/dist/assets/{skeletons-CZdepTdC.js → skeletons-Cct3--c-.js} +1 -1
- package/dist/assets/src-BM-XgFqH.js +2 -0
- package/dist/assets/src-BvIm_4jD.js +135 -0
- package/dist/assets/{src-DzNV76wU.js → src-f2cvKHyo.js} +1 -1
- package/dist/assets/{types-CoZkCf64.js → types-eEPSTWZr.js} +1 -1
- package/dist/assets/ui-components-BDy7soRa.js +42 -0
- package/dist/assets/{ui-layout-DQDnaREz.js → ui-layout-tBg9Ny6m.js} +1 -1
- package/dist/assets/{useActionModal-DI7oaRiK.js → useActionModal-Cd50Dc4Y.js} +1 -1
- package/dist/assets/{useOpenRecordList-pMYhKC_q.js → useOpenRecordList-CKVQ3oer.js} +1 -1
- package/dist/assets/{useReconcileOnError-p9SZCLMb.js → useReconcileOnError-D8Uet4j6.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/MetadataInspector-Ci4IEXl6.js +0 -1
- package/dist/assets/index-0xh0t0SY.css +0 -2
- package/dist/assets/mermaid-GHXKKRXX-DfINr0ix.js +0 -1
- package/dist/assets/plugin-charts-BQs_--tP.js +0 -7
- package/dist/assets/plugins-views-C-R-Gk81.js +0 -4
- package/dist/assets/src-DRWgP_lu.js +0 -2
- package/dist/assets/ui-components-J75dr3Ae.js +0 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i}from"./vendor-react-slxo-5GC.js";import{d as a}from"./infrastructure-BySW-NB0.js";import{A as o,i as s,j as c,y as l}from"./framework-BGQ7DoWM.js";import{$a as u,$i as d,$s as f,Ec as p,J as m,Jn as h,Mr as g,Qn as _,Rc as v,Tr as y,Xn as b,Yn as x,Yr as S,Ys as C,Z as w,Zn as T,Zr as E,ci as D,ec as O,eo as ee,oa as k,q as A,qn as te}from"./ui-components-J75dr3Ae.js";import{r as j}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-BiTdGDAR.js";import{n as ne}from"./plugin-form-B73E4Mbd.js";import"./MetadataProvider-CkIT9awy.js";import{r as re}from"./ExpressionProvider-BeRnSjp4.js";import{Q as ie,v as M}from"./ReportDefaultInspector-BxP74HM2.js";import{t as N}from"./utils-CFXe_XCU.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-Ci4IEXl6.js";import{n as P,t as F}from"./DashboardWidgetInspector-CagpzDS6.js";import{i as ce,n as I,t as le}from"./useOpenRecordList-pMYhKC_q.js";import{n as ue}from"./skeletons-CZdepTdC.js";import{n as de}from"./plugin-dashboard-CWaZph1r.js";var L=e(n(),1),R=i();function fe({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(),m=(0,L.useMemo)(()=>M(),[]),[h,_]=(0,L.useState)(!1),[v,b]=(0,L.useState)(0),x=(0,L.useCallback)(e=>{_(!0),o({...n??{},...e})},[n,o]),S=(0,L.useCallback)(e=>{o(e),_(!1)},[o]),C=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),w=Array.isArray(n?.widgets)?n.widgets:[],T=r?w.find(e=>e?.id===r):null;if(!e)return null;let D=typeof n?.name==`string`?n.name:``,O=T?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:[T&&(0,R.jsx)(y,{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)(p,{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:[T&&c&&(0,R.jsx)(y,{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)(E,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(y,{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)(g,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:T?(0,R.jsx)(F,{type:`dashboard`,name:D,draft:n??{},selection:{kind:`widget`,id:r},onPatch:x,onClearSelection:()=>i(null),onSelectionChange:C,readOnly:!1,locale:m}):(0,R.jsx)(P,{type:`dashboard`,name:D,draft:n??{},onPatch:x,onSelectionChange:C,readOnly:!1,locale:m})}),(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)(I,{type:`dashboard`,name:l||D||void 0,metadataClient:u,dirty:h,onResume:S,savedSignal:v,onAfterChange:d}),(0,R.jsx)(y,{size:`sm`,onClick:()=>{a(n??{}),_(!1),b(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:S},{type:`bar`,label:`Bar Chart`,Icon:O},{type:`line`,label:`Line Chart`,Icon:f},{type:`pie`,label:`Pie Chart`,Icon:C},{type:`table`,label:`Table`,Icon:D},{type:`pivot`,label:`Pivot`,Icon:u}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function pe(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 me(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let t=le(),{dashboardName:n}=r(),{showDebug:i}=ae(),u=o(),f=ie(),{t:p}=s(),{dashboardLabel:g,dashboardDescription:S}=v(),C=a(),[E,D]=(0,L.useState)(!0),[O,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})}),[]),he=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(p(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(p(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(p(`dashboardActions.forecastSoon`)),{success:!0})}),[p]);(0,L.useEffect)(()=>{D(!0),J(null),M(!1),F(null),queueMicrotask(()=>D(!1))},[n]);let{dashboards:ge,objects:W,refresh:G}=c(),{app:_e}=re(),K=oe(ge,n,_e?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{O||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{f&&await ce(`dashboard`,n,e,{metadataClient:f}),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}`)}},[f,n,G]),ve=(0,L.useCallback)(()=>{J(pe(K)),M(!0)},[K]),ye=(0,L.useCallback)(()=>{M(!1),F(null)},[]),X=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:me(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]),be=(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]),xe=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),Se=(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 E?(0,R.jsx)(ue,{}):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,p),t=N(K.label,p),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=S({name:K.name,description:N(e,p)});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:[O&&(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:()=>X(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)(d,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),C&&(0,R.jsxs)(`button`,{type:`button`,onClick:ve,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)(k,{className:`h-3.5 w-3.5`}),p(`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)(l,{value:{openRecordList:t},children:(0,R.jsx)(de,{schema:$,dataSource:e,designMode:O,selectedWidgetId:P,onWidgetClick:F,onWidgetsReorder:xe,modalHandler:U,scriptHandlers:he,hideHeaderText:!0})})}),(0,R.jsx)(fe,{open:O&&C,onClose:ye,schema:Se,selectedWidgetId:P,onSelectWidget:F,onSave:Y,onChange:J,onRemoveWidget:be,name:n,metadataClient:f,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),I&&I.schema?.objectName?(0,R.jsx)(ne,{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:u}):I?(0,R.jsx)(te,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,R.jsxs)(h,{children:[(0,R.jsxs)(T,{children:[(0,R.jsx)(_,{children:I.schema?.title||p(`actionDialog.defaultActionTitle`)}),I.schema?.description&&(0,R.jsx)(x,{children:I.schema.description})]}),(0,R.jsxs)(b,{children:[(0,R.jsx)(y,{variant:`outline`,onClick:()=>V({success:!1}),children:p(`actionDialog.cancel`)}),(0,R.jsx)(y,{onClick:()=>V({success:!0}),children:p(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(A,{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)(ee,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(w,{children:p(`empty.dashboardNotFound`)}),(0,R.jsx)(m,{children:p(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{z as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i}from"./vendor-react-slxo-5GC.js";import{d as a}from"./infrastructure-BySW-NB0.js";import{A as o,i as s,j as c,y as l}from"./framework-DxDZ_zWg.js";import{$a as u,$i as d,$s as f,Ec as p,J as m,Jn as h,Mr as g,Qn as _,Rc as v,Tr as y,Xn as b,Yn as x,Yr as S,Ys as C,Z as w,Zn as T,Zr as E,ci as D,ec as O,eo as ee,oa as k,q as A,qn as te}from"./ui-components-BDy7soRa.js";import{r as j}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-DPeLrdd0.js";import{n as ne}from"./plugin-form-DZ4onNeM.js";import"./MetadataProvider-BWz_wO6c.js";import{r as re}from"./ExpressionProvider-1HR1mriH.js";import{Q as ie,v as M}from"./ReportDefaultInspector-CN7-euct.js";import{t as N}from"./utils-CFXe_XCU.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-B-6wYdsG.js";import{n as P,t as F}from"./DashboardWidgetInspector-C34BJd1Y.js";import{i as ce,n as I,t as le}from"./useOpenRecordList-CKVQ3oer.js";import{n as ue}from"./skeletons-Cct3--c-.js";import{n as de}from"./plugin-dashboard-o2MA7Ifu.js";var L=e(n(),1),R=i();function fe({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(),m=(0,L.useMemo)(()=>M(),[]),[h,_]=(0,L.useState)(!1),[v,b]=(0,L.useState)(0),x=(0,L.useCallback)(e=>{_(!0),o({...n??{},...e})},[n,o]),S=(0,L.useCallback)(e=>{o(e),_(!1)},[o]),C=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),w=Array.isArray(n?.widgets)?n.widgets:[],T=r?w.find(e=>e?.id===r):null;if(!e)return null;let D=typeof n?.name==`string`?n.name:``,O=T?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:[T&&(0,R.jsx)(y,{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)(p,{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:[T&&c&&(0,R.jsx)(y,{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)(E,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(y,{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)(g,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:T?(0,R.jsx)(F,{type:`dashboard`,name:D,draft:n??{},selection:{kind:`widget`,id:r},onPatch:x,onClearSelection:()=>i(null),onSelectionChange:C,readOnly:!1,locale:m}):(0,R.jsx)(P,{type:`dashboard`,name:D,draft:n??{},onPatch:x,onSelectionChange:C,readOnly:!1,locale:m})}),(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)(I,{type:`dashboard`,name:l||D||void 0,metadataClient:u,dirty:h,onResume:S,savedSignal:v,onAfterChange:d}),(0,R.jsx)(y,{size:`sm`,onClick:()=>{a(n??{}),_(!1),b(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:S},{type:`bar`,label:`Bar Chart`,Icon:O},{type:`line`,label:`Line Chart`,Icon:f},{type:`pie`,label:`Pie Chart`,Icon:C},{type:`table`,label:`Table`,Icon:D},{type:`pivot`,label:`Pivot`,Icon:u}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function pe(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 me(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let t=le(),{dashboardName:n}=r(),{showDebug:i}=ae(),u=o(),f=ie(),{t:p}=s(),{dashboardLabel:g,dashboardDescription:S}=v(),C=a(),[E,D]=(0,L.useState)(!0),[O,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})}),[]),he=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(p(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(p(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(p(`dashboardActions.forecastSoon`)),{success:!0})}),[p]);(0,L.useEffect)(()=>{D(!0),J(null),M(!1),F(null),queueMicrotask(()=>D(!1))},[n]);let{dashboards:ge,objects:W,refresh:G}=c(),{app:_e}=re(),K=oe(ge,n,_e?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{O||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{f&&await ce(`dashboard`,n,e,{metadataClient:f}),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}`)}},[f,n,G]),ve=(0,L.useCallback)(()=>{J(pe(K)),M(!0)},[K]),ye=(0,L.useCallback)(()=>{M(!1),F(null)},[]),X=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:me(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]),be=(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]),xe=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),Se=(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 E?(0,R.jsx)(ue,{}):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,p),t=N(K.label,p),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=S({name:K.name,description:N(e,p)});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:[O&&(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:()=>X(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)(d,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),C&&(0,R.jsxs)(`button`,{type:`button`,onClick:ve,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)(k,{className:`h-3.5 w-3.5`}),p(`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)(l,{value:{openRecordList:t},children:(0,R.jsx)(de,{schema:$,dataSource:e,designMode:O,selectedWidgetId:P,onWidgetClick:F,onWidgetsReorder:xe,modalHandler:U,scriptHandlers:he,hideHeaderText:!0})})}),(0,R.jsx)(fe,{open:O&&C,onClose:ye,schema:Se,selectedWidgetId:P,onSelectWidget:F,onSave:Y,onChange:J,onRemoveWidget:be,name:n,metadataClient:f,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),I&&I.schema?.objectName?(0,R.jsx)(ne,{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:u}):I?(0,R.jsx)(te,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,R.jsxs)(h,{children:[(0,R.jsxs)(T,{children:[(0,R.jsx)(_,{children:I.schema?.title||p(`actionDialog.defaultActionTitle`)}),I.schema?.description&&(0,R.jsx)(x,{children:I.schema.description})]}),(0,R.jsxs)(b,{children:[(0,R.jsx)(y,{variant:`outline`,onClick:()=>V({success:!1}),children:p(`actionDialog.cancel`)}),(0,R.jsx)(y,{onClick:()=>V({success:!0}),children:p(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(A,{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)(ee,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(w,{children:p(`empty.dashboardNotFound`)}),(0,R.jsx)(m,{children:p(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{z as t};
|
package/dist/assets/{DashboardWidgetInspector-CagpzDS6.js → DashboardWidgetInspector-C34BJd1Y.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{R as r,l as i,m as a}from"./vendor-objectstack-AFc_0VfZ.js";import{$i as o,$s as s,$t as c,Gn as l,Hn as u,Js as d,Ks as f,Mc as p,Mi as m,Mr as h,Qs as g,Qt as _,Tr as v,Un as y,Vn as b,Wa as x,Wn as S,Xr as C,Xt as w,Ys as T,Yt as E,Zs as D,Zt as O,as as k,ci as A,cn as j,dn as M,go as N,hn as P,jc as F,ln as I,lr as ee,ms as te,ns as ne,tc as re,un as ie,yo as ae,zn as oe,zs as se}from"./ui-components-J75dr3Ae.js";import{G as L,H as ce,J as le,K as ue,Q as R,W as de,Y as fe,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as z,r as ye,t as B,y as V}from"./ReportDefaultInspector-BxP74HM2.js";var H=e(t(),1),U=n();function be(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function W({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:s,loading:c,allowCustom:d=!0,mono:m,className:h}){let[g,_]=H.useState(!1),[x,C]=H.useState(``),w=r.find(e=>e.value===t),T=w?w.label:t||(c?`Loading…`:i),E=H.useMemo(()=>r.filter(e=>be(e,x)),[r,x]),D=H.useMemo(()=>{let e=[],t=new Map;for(let n of E){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[E]),O=x.trim(),k=d&&!!O&&!r.some(e=>e.value===O),A=e=>{n(e),_(!1),C(``)},M=(0,U.jsxs)(j,{open:g,onOpenChange:e=>{_(e),e||C(``)},children:[(0,U.jsx)(ie,{asChild:!0,children:(0,U.jsxs)(v,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:s,className:p(`h-8 w-full justify-between px-2 text-sm font-normal`,h),children:[(0,U.jsx)(`span`,{className:p(`truncate`,m&&`font-mono`,!w&&!t&&`text-muted-foreground`),children:T}),(0,U.jsx)(se,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,U.jsx)(I,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,U.jsxs)(oe,{shouldFilter:!1,children:[(0,U.jsx)(y,{value:x,onValueChange:C,placeholder:a}),(0,U.jsxs)(l,{children:[!k&&E.length===0&&(0,U.jsx)(b,{children:o}),k&&(0,U.jsx)(u,{children:(0,U.jsx)(S,{value:`__custom__${O}`,onSelect:()=>A(O),children:(0,U.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,U.jsxs)(`span`,{className:`font-mono`,children:[`“`,O,`”`]})]})})}),D.map((e,n)=>(0,U.jsx)(u,{heading:e.heading||void 0,children:e.items.map(e=>(0,U.jsxs)(S,{value:e.value,onSelect:()=>A(e.value),children:[(0,U.jsx)(f,{className:p(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,U.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,U.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(P,{className:`text-xs text-muted-foreground`,children:e}),M]}):M}var xe=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function G(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function Se(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Ce(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function K(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=G(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:G(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&xe.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:Se(e.def)}))}}function q(e,t,n){let r=e,i=[];for(let e of t.split(`.`)){let t=r.relationships.find(t=>t.name===e);if(!t?.referenceTo)return;let a=n[t.referenceTo];if(!a)return;i.push(t.label),r=a}return{target:r,labels:i}}function we(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=q(e,i,n);if(!t)continue;let a=[...t.labels,t.target.label].join(` → `);for(let e of t.target.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:a})}return r}function J(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>J(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&J(e,t))}function Y(){let e=R(),[t,n]=H.useState({options:[],loading:!0});return H.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:G(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function Te(e,t){let n=R(),r=t.join(`\0`),[i,a]=H.useState({relationships:[],fieldOptions:[],loading:!!e});return H.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=K(i,e),s=r?r.split(`\0`):[],c={[e]:o},l=async e=>{if(c[e])return c[e];let t;try{t=K(await n.get(`object`,e),e)}catch{t=K(null,e)}return c[e]=t,t};for(let e of s){let t=o;for(let n of e.split(`.`)){let e=t.relationships.find(e=>e.name===n);if(!e?.referenceTo)break;t=await l(e.referenceTo)}}if(t)return;let u=[...o.relationships];for(let e of s){if(e.split(`.`).length>=3)continue;let t=q(o,e,c);if(t)for(let n of t.target.relationships)u.push({name:`${e}.${n.name}`,label:`${e}.${n.name}`,referenceTo:n.referenceTo})}a({relationships:u,fieldOptions:we(o,s,c),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Ee(e){let t=R(),[n,r]=H.useState({reports:0,dashboards:0,loading:!!e});return H.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>J(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>J(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var X={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:N},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:g},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:D},line:{id:`line`,label:`Line chart`,category:`chart`,icon:s},area:{id:`area`,label:`Area chart`,category:`chart`,icon:re},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:T},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:ne},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:d},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:C},table:{id:`table`,label:`Data table`,category:`data`,icon:A},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:k},list:{id:`list`,label:`Record list`,category:`data`,icon:x},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:te}},De={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},Oe=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(X).filter(t=>t.category===e)})),ke=F;function Ae({onAdd:e,label:t=`Add widget`}){let[n,r]=H.useState(!1),[i,a]=H.useState(``),s=H.useRef(null),c=H.useRef(null);H.useEffect(()=>{if(!n){a(``);return}let e=e=>{s.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>c.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let l=H.useMemo(()=>{let e=i.trim().toLowerCase();return e?Oe.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):Oe},[i]);return(0,U.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,U.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,U.jsx)(o,{className:`h-3 w-3`}),t]}),n&&(0,U.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,U.jsx)(m,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,U.jsx)(`input`,{ref:c,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,U.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:l.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):l.map(t=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:De[t.category]}),t.types.map(t=>(0,U.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,U.jsx)(X[t.id]?.icon??ke,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,U.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var je={io:`input`,unrepresentable:`any`},Me=new Set([`widgets`,`label`,`description`,`name`]),Z,Ne=!1;function Pe(){if(Z||Ne)return Z;try{Z=r(i,je)}catch(e){Ne=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Fe(){if(Q)return Q;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!Me.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Ie=new Set([`name`,`label`,`description`,`widgets`]);function Le({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=H.useCallback(e=>V(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=H.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=fe(`widget`,l.map(e=>e?.id).filter(Boolean)),r=X[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ue(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:le(l,e,null)})},f=(e,n)=>{e!==n&&t({widgets:z(l,e,n)})},p=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[m,g]=H.useState(null),[_,y]=H.useState(null),{schema:b,form:x}=H.useMemo(()=>me({bundledSchema:Pe(),bundledForm:Fe(),serverSchema:a,excludeFields:Ie,sectionTitle:V(`engine.inspector.moreFields`,r)}),[a,r]);return(0,U.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,U.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(P,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,U.jsx)(ee,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,U.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,U.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=X[e?.type]?.icon??ke;return(0,U.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),y(null)},onDragOver:e=>{e.preventDefault(),y(t)},onDrop:()=>{m!=null&&m!==t&&f(m,t),g(null),y(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&m!==null&&m!==t?` border-primary`:``),children:[!n&&(0,U.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,U.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>p(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,U.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,U.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,U.jsx)(h,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,U.jsx)(Ae,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,U.jsx)(`div`,{className:`border-t pt-3`,children:b?(0,U.jsx)(ve,{schema:b,form:x,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,U.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Re=[{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`}],ze=[`count`,`sum`,`avg`,`min`,`max`],Be=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Ve(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 He({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],l=t.kind===`widget`?t.id:void 0,u=l?Ve(e,l):null,d=u?.widget??{},f=typeof d.dataset==`string`?d.dataset:``,p=typeof d.object==`string`?d.object:``,m=Array.isArray(d.dimensions)?d.dimensions.filter(e=>typeof e==`string`):[],g=Array.isArray(d.values)?d.values.filter(e=>typeof e==`string`):[],y=ye(),b=ge(f||void 0,y),{options:x,loading:S}=Y(),{fields:C}=he(p||void 0),T=H.useMemo(()=>{let e=y.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return f&&!e.some(e=>e.value===f)&&e.push({value:f,label:f}),e},[y.datasets,f]),D=H.useMemo(()=>x.map(e=>({value:e.name,label:e.label})),[x]),k=H.useMemo(()=>C.map(e=>({value:e.name,label:e.label,hint:e.type})),[C]),A=H.useMemo(()=>b.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[b.measures]),j=H.useMemo(()=>b.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[b.dimensions]);if(t.kind!==`widget`)return(0,U.jsx)(Ue,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!u)return(0,U.jsx)(Ue,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:N,index:P}=u;function F(e){let t=[...s];t[P]={...t[P],...e},n({widgets:t})}function I(e){n({widgets:z(s,P,e)}),N.id&&i?.({kind:`widget`,id:N.id,label:N.title??void 0})}return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:V(`engine.inspector.widget.kind`,o)}),(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:N.title||t.label||`Widget ${P+1}`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,U.jsx)(ce,{index:P,total:s.length,onMove:I,upLabel:V(`engine.inspector.reorder.up`,o),downLabel:V(`engine.inspector.reorder.down`,o),disabled:a}),(0,U.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:V(`engine.inspector.widget.close`,o),"aria-label":V(`engine.inspector.widget.close`,o),children:(0,U.jsx)(h,{className:`h-3.5 w-3.5`})})]})]}),(0,U.jsx)($,{id:`widget-title`,label:V(`engine.inspector.widget.title`,o),children:(0,U.jsx)(M,{id:`widget-title`,value:N.title??``,onChange:e=>F({title:e.target.value}),disabled:a})}),(0,U.jsx)($,{id:`widget-type`,label:V(`engine.inspector.widget.type`,o),children:(0,U.jsxs)(E,{value:N.type??`metric`,onValueChange:e=>F({type:e}),disabled:a,children:[(0,U.jsx)(_,{id:`widget-type`,children:(0,U.jsx)(c,{})}),(0,U.jsx)(w,{children:Re.map(e=>(0,U.jsx)(O,{value:e.value,children:e.label},e.value))})]})}),(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:V(`engine.inspector.widget.datasetSection`,o)}),(0,U.jsxs)($,{id:`widget-dataset`,label:V(`engine.inspector.widget.dataset`,o),children:[(0,U.jsx)(W,{value:f,onCommit:e=>F({dataset:e||void 0}),options:T,loading:y.loading,placeholder:V(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:V(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,U.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:V(`engine.inspector.widget.datasetHint`,o)})]}),f&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(B,{label:V(`engine.inspector.widget.dimensions`,o),emptyText:V(`engine.inspector.widget.dimensionsHint`,o),names:m,options:j,loading:b.loading,error:b.error,readOnly:a,onCommit:e=>F({dimensions:e})}),(0,U.jsx)(B,{label:V(`engine.inspector.widget.values`,o),emptyText:V(`engine.inspector.widget.valuesHint`,o),names:g,options:A,loading:b.loading,error:b.error,readOnly:a,onCommit:e=>F({values:e})})]})]}),(0,U.jsx)($,{id:`widget-object`,label:V(`engine.inspector.widget.object`,o),children:(0,U.jsx)(W,{value:N.object??``,onCommit:e=>F({object:e||void 0}),options:D,loading:S,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-value-field`,label:V(`engine.inspector.widget.valueField`,o),children:(0,U.jsx)(W,{value:N.valueField??``,onCommit:e=>F({valueField:e||void 0}),options:k,placeholder:N.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-category-field`,label:V(`engine.inspector.widget.categoryField`,o),children:(0,U.jsx)(W,{value:N.categoryField??``,onCommit:e=>F({categoryField:e||void 0}),options:k,placeholder:N.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-aggregate`,label:V(`engine.inspector.widget.aggregate`,o),children:(0,U.jsxs)(E,{value:N.aggregate??`count`,onValueChange:e=>F({aggregate:e}),disabled:a,children:[(0,U.jsx)(_,{id:`widget-aggregate`,children:(0,U.jsx)(c,{})}),(0,U.jsx)(w,{children:ze.map(e=>(0,U.jsx)(O,{value:e,children:e},e))})]})}),(0,U.jsx)($,{id:`widget-color`,label:V(`engine.inspector.widget.color`,o),children:(0,U.jsx)(pe,{value:N.colorVariant??`default`,onChange:e=>F({colorVariant:e}),disabled:a,options:Be.map(e=>({value:e}))})}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsx)($,{id:`widget-w`,label:V(`engine.inspector.widget.width`,o),children:(0,U.jsx)(M,{id:`widget-w`,type:`number`,min:1,value:N.layout?.w??1,onChange:e=>F({layout:{...N.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,U.jsx)($,{id:`widget-h`,label:V(`engine.inspector.widget.height`,o),children:(0,U.jsx)(M,{id:`widget-h`,type:`number`,min:1,value:N.layout?.h??1,onChange:e=>F({layout:{...N.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,U.jsx)(`div`,{className:`pt-2 border-t`,children:(0,U.jsx)(v,{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(P,1),n({widgets:t}),r()},children:V(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(P,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function Ue({message:e,onClose:t,locale:n}){return(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,U.jsx)(`p`,{children:e}),(0,U.jsx)(v,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:V(`engine.inspector.widget.close`,n)})]})}export{Ce as a,Y as c,X as i,W as l,Le as n,Te as o,Ae as r,Ee as s,He as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{R as r,l as i,m as a}from"./vendor-objectstack-AFc_0VfZ.js";import{$i as o,$s as s,$t as c,Gn as l,Hn as u,Js as d,Ks as f,Mc as p,Mi as m,Mr as h,Qs as g,Qt as _,Tr as v,Un as y,Vn as b,Wa as x,Wn as S,Xr as C,Xt as w,Ys as T,Yt as E,Zs as D,Zt as O,as as k,ci as A,cn as j,dn as M,go as N,hn as P,jc as F,ln as I,lr as ee,ms as te,ns as ne,tc as re,un as ie,yo as ae,zn as oe,zs as se}from"./ui-components-BDy7soRa.js";import{G as L,H as ce,J as le,K as ue,Q as R,W as de,Y as fe,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as z,r as ye,t as B,y as V}from"./ReportDefaultInspector-CN7-euct.js";var H=e(t(),1),U=n();function be(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function W({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:s,loading:c,allowCustom:d=!0,mono:m,className:h}){let[g,_]=H.useState(!1),[x,C]=H.useState(``),w=r.find(e=>e.value===t),T=w?w.label:t||(c?`Loading…`:i),E=H.useMemo(()=>r.filter(e=>be(e,x)),[r,x]),D=H.useMemo(()=>{let e=[],t=new Map;for(let n of E){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[E]),O=x.trim(),k=d&&!!O&&!r.some(e=>e.value===O),A=e=>{n(e),_(!1),C(``)},M=(0,U.jsxs)(j,{open:g,onOpenChange:e=>{_(e),e||C(``)},children:[(0,U.jsx)(ie,{asChild:!0,children:(0,U.jsxs)(v,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:s,className:p(`h-8 w-full justify-between px-2 text-sm font-normal`,h),children:[(0,U.jsx)(`span`,{className:p(`truncate`,m&&`font-mono`,!w&&!t&&`text-muted-foreground`),children:T}),(0,U.jsx)(se,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,U.jsx)(I,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,U.jsxs)(oe,{shouldFilter:!1,children:[(0,U.jsx)(y,{value:x,onValueChange:C,placeholder:a}),(0,U.jsxs)(l,{children:[!k&&E.length===0&&(0,U.jsx)(b,{children:o}),k&&(0,U.jsx)(u,{children:(0,U.jsx)(S,{value:`__custom__${O}`,onSelect:()=>A(O),children:(0,U.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,U.jsxs)(`span`,{className:`font-mono`,children:[`“`,O,`”`]})]})})}),D.map((e,n)=>(0,U.jsx)(u,{heading:e.heading||void 0,children:e.items.map(e=>(0,U.jsxs)(S,{value:e.value,onSelect:()=>A(e.value),children:[(0,U.jsx)(f,{className:p(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,U.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,U.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(P,{className:`text-xs text-muted-foreground`,children:e}),M]}):M}var xe=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function G(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function Se(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Ce(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function K(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=G(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:G(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&xe.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:Se(e.def)}))}}function q(e,t,n){let r=e,i=[];for(let e of t.split(`.`)){let t=r.relationships.find(t=>t.name===e);if(!t?.referenceTo)return;let a=n[t.referenceTo];if(!a)return;i.push(t.label),r=a}return{target:r,labels:i}}function we(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=q(e,i,n);if(!t)continue;let a=[...t.labels,t.target.label].join(` → `);for(let e of t.target.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:a})}return r}function J(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>J(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&J(e,t))}function Y(){let e=R(),[t,n]=H.useState({options:[],loading:!0});return H.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:G(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function Te(e,t){let n=R(),r=t.join(`\0`),[i,a]=H.useState({relationships:[],fieldOptions:[],loading:!!e});return H.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=K(i,e),s=r?r.split(`\0`):[],c={[e]:o},l=async e=>{if(c[e])return c[e];let t;try{t=K(await n.get(`object`,e),e)}catch{t=K(null,e)}return c[e]=t,t};for(let e of s){let t=o;for(let n of e.split(`.`)){let e=t.relationships.find(e=>e.name===n);if(!e?.referenceTo)break;t=await l(e.referenceTo)}}if(t)return;let u=[...o.relationships];for(let e of s){if(e.split(`.`).length>=3)continue;let t=q(o,e,c);if(t)for(let n of t.target.relationships)u.push({name:`${e}.${n.name}`,label:`${e}.${n.name}`,referenceTo:n.referenceTo})}a({relationships:u,fieldOptions:we(o,s,c),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Ee(e){let t=R(),[n,r]=H.useState({reports:0,dashboards:0,loading:!!e});return H.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>J(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>J(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var X={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:N},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:g},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:D},line:{id:`line`,label:`Line chart`,category:`chart`,icon:s},area:{id:`area`,label:`Area chart`,category:`chart`,icon:re},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:T},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:ne},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:d},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:C},table:{id:`table`,label:`Data table`,category:`data`,icon:A},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:k},list:{id:`list`,label:`Record list`,category:`data`,icon:x},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:te}},De={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},Oe=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(X).filter(t=>t.category===e)})),ke=F;function Ae({onAdd:e,label:t=`Add widget`}){let[n,r]=H.useState(!1),[i,a]=H.useState(``),s=H.useRef(null),c=H.useRef(null);H.useEffect(()=>{if(!n){a(``);return}let e=e=>{s.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>c.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let l=H.useMemo(()=>{let e=i.trim().toLowerCase();return e?Oe.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):Oe},[i]);return(0,U.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,U.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,U.jsx)(o,{className:`h-3 w-3`}),t]}),n&&(0,U.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,U.jsx)(m,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,U.jsx)(`input`,{ref:c,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,U.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:l.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):l.map(t=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:De[t.category]}),t.types.map(t=>(0,U.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,U.jsx)(X[t.id]?.icon??ke,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,U.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var je={io:`input`,unrepresentable:`any`},Me=new Set([`widgets`,`label`,`description`,`name`]),Z,Ne=!1;function Pe(){if(Z||Ne)return Z;try{Z=r(i,je)}catch(e){Ne=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Fe(){if(Q)return Q;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!Me.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Ie=new Set([`name`,`label`,`description`,`widgets`]);function Le({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=H.useCallback(e=>V(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=H.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=fe(`widget`,l.map(e=>e?.id).filter(Boolean)),r=X[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ue(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:le(l,e,null)})},f=(e,n)=>{e!==n&&t({widgets:z(l,e,n)})},p=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[m,g]=H.useState(null),[_,y]=H.useState(null),{schema:b,form:x}=H.useMemo(()=>me({bundledSchema:Pe(),bundledForm:Fe(),serverSchema:a,excludeFields:Ie,sectionTitle:V(`engine.inspector.moreFields`,r)}),[a,r]);return(0,U.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,U.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(P,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,U.jsx)(ee,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,U.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,U.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=X[e?.type]?.icon??ke;return(0,U.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),y(null)},onDragOver:e=>{e.preventDefault(),y(t)},onDrop:()=>{m!=null&&m!==t&&f(m,t),g(null),y(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&m!==null&&m!==t?` border-primary`:``),children:[!n&&(0,U.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,U.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>p(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,U.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,U.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,U.jsx)(h,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,U.jsx)(Ae,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,U.jsx)(`div`,{className:`border-t pt-3`,children:b?(0,U.jsx)(ve,{schema:b,form:x,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,U.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Re=[{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`}],ze=[`count`,`sum`,`avg`,`min`,`max`],Be=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Ve(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 He({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],l=t.kind===`widget`?t.id:void 0,u=l?Ve(e,l):null,d=u?.widget??{},f=typeof d.dataset==`string`?d.dataset:``,p=typeof d.object==`string`?d.object:``,m=Array.isArray(d.dimensions)?d.dimensions.filter(e=>typeof e==`string`):[],g=Array.isArray(d.values)?d.values.filter(e=>typeof e==`string`):[],y=ye(),b=ge(f||void 0,y),{options:x,loading:S}=Y(),{fields:C}=he(p||void 0),T=H.useMemo(()=>{let e=y.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return f&&!e.some(e=>e.value===f)&&e.push({value:f,label:f}),e},[y.datasets,f]),D=H.useMemo(()=>x.map(e=>({value:e.name,label:e.label})),[x]),k=H.useMemo(()=>C.map(e=>({value:e.name,label:e.label,hint:e.type})),[C]),A=H.useMemo(()=>b.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[b.measures]),j=H.useMemo(()=>b.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[b.dimensions]);if(t.kind!==`widget`)return(0,U.jsx)(Ue,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!u)return(0,U.jsx)(Ue,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:N,index:P}=u;function F(e){let t=[...s];t[P]={...t[P],...e},n({widgets:t})}function I(e){n({widgets:z(s,P,e)}),N.id&&i?.({kind:`widget`,id:N.id,label:N.title??void 0})}return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:V(`engine.inspector.widget.kind`,o)}),(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:N.title||t.label||`Widget ${P+1}`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,U.jsx)(ce,{index:P,total:s.length,onMove:I,upLabel:V(`engine.inspector.reorder.up`,o),downLabel:V(`engine.inspector.reorder.down`,o),disabled:a}),(0,U.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:V(`engine.inspector.widget.close`,o),"aria-label":V(`engine.inspector.widget.close`,o),children:(0,U.jsx)(h,{className:`h-3.5 w-3.5`})})]})]}),(0,U.jsx)($,{id:`widget-title`,label:V(`engine.inspector.widget.title`,o),children:(0,U.jsx)(M,{id:`widget-title`,value:N.title??``,onChange:e=>F({title:e.target.value}),disabled:a})}),(0,U.jsx)($,{id:`widget-type`,label:V(`engine.inspector.widget.type`,o),children:(0,U.jsxs)(E,{value:N.type??`metric`,onValueChange:e=>F({type:e}),disabled:a,children:[(0,U.jsx)(_,{id:`widget-type`,children:(0,U.jsx)(c,{})}),(0,U.jsx)(w,{children:Re.map(e=>(0,U.jsx)(O,{value:e.value,children:e.label},e.value))})]})}),(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:V(`engine.inspector.widget.datasetSection`,o)}),(0,U.jsxs)($,{id:`widget-dataset`,label:V(`engine.inspector.widget.dataset`,o),children:[(0,U.jsx)(W,{value:f,onCommit:e=>F({dataset:e||void 0}),options:T,loading:y.loading,placeholder:V(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:V(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,U.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:V(`engine.inspector.widget.datasetHint`,o)})]}),f&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(B,{label:V(`engine.inspector.widget.dimensions`,o),emptyText:V(`engine.inspector.widget.dimensionsHint`,o),names:m,options:j,loading:b.loading,error:b.error,readOnly:a,onCommit:e=>F({dimensions:e})}),(0,U.jsx)(B,{label:V(`engine.inspector.widget.values`,o),emptyText:V(`engine.inspector.widget.valuesHint`,o),names:g,options:A,loading:b.loading,error:b.error,readOnly:a,onCommit:e=>F({values:e})})]})]}),(0,U.jsx)($,{id:`widget-object`,label:V(`engine.inspector.widget.object`,o),children:(0,U.jsx)(W,{value:N.object??``,onCommit:e=>F({object:e||void 0}),options:D,loading:S,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-value-field`,label:V(`engine.inspector.widget.valueField`,o),children:(0,U.jsx)(W,{value:N.valueField??``,onCommit:e=>F({valueField:e||void 0}),options:k,placeholder:N.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-category-field`,label:V(`engine.inspector.widget.categoryField`,o),children:(0,U.jsx)(W,{value:N.categoryField??``,onCommit:e=>F({categoryField:e||void 0}),options:k,placeholder:N.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-aggregate`,label:V(`engine.inspector.widget.aggregate`,o),children:(0,U.jsxs)(E,{value:N.aggregate??`count`,onValueChange:e=>F({aggregate:e}),disabled:a,children:[(0,U.jsx)(_,{id:`widget-aggregate`,children:(0,U.jsx)(c,{})}),(0,U.jsx)(w,{children:ze.map(e=>(0,U.jsx)(O,{value:e,children:e},e))})]})}),(0,U.jsx)($,{id:`widget-color`,label:V(`engine.inspector.widget.color`,o),children:(0,U.jsx)(pe,{value:N.colorVariant??`default`,onChange:e=>F({colorVariant:e}),disabled:a,options:Be.map(e=>({value:e}))})}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsx)($,{id:`widget-w`,label:V(`engine.inspector.widget.width`,o),children:(0,U.jsx)(M,{id:`widget-w`,type:`number`,min:1,value:N.layout?.w??1,onChange:e=>F({layout:{...N.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,U.jsx)($,{id:`widget-h`,label:V(`engine.inspector.widget.height`,o),children:(0,U.jsx)(M,{id:`widget-h`,type:`number`,min:1,value:N.layout?.h??1,onChange:e=>F({layout:{...N.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,U.jsx)(`div`,{className:`pt-2 border-t`,children:(0,U.jsx)(v,{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(P,1),n({widgets:t}),r()},children:V(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(P,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function Ue({message:e,onClose:t,locale:n}){return(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,U.jsx)(`p`,{children:e}),(0,U.jsx)(v,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:V(`engine.inspector.widget.close`,n)})]})}export{Ce as a,Y as c,X as i,W as l,Le as n,Te as o,Ae as r,Ee as s,He as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,t,u as n}from"./vendor-react-slxo-5GC.js";import{Pr as r,Ro as i,ar as a,ea as o,ii as s,ir as c,or as l,rr as u,sr as d}from"./ui-components-
|
|
1
|
+
import{f as e,t,u as n}from"./vendor-react-slxo-5GC.js";import{Pr as r,Ro as i,ar as a,ea as o,ii as s,ir as c,or as l,rr as u,sr as d}from"./ui-components-BDy7soRa.js";var f=t();function p(){let t=n(),{appName:p}=e(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:o,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:s,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:r,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:i,href:`${m}/developer/public-forms`}];return(0,f.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Developer`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Tools for building, debugging, and sharing ObjectStack apps`})]}),(0,f.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:h.map(e=>{let n=e.icon;return(0,f.jsxs)(u,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>t(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:[(0,f.jsxs)(l,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(n,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(d,{className:`text-base`,children:e.title}),(0,f.jsx)(a,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(c,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{G as r,Ot as i}from"./framework-DxDZ_zWg.js";var a=e(t(),1),o=n(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}},t={current_user:{},ctx:{user:{}},...e};return{...e,evaluator:new i(t)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{A as r}from"./framework-BGQ7DoWM.js";import{Gi as i,Gt as a,Kt as o,Ls as s,Pr as c,Ps as l,Tr as u,Ts as d,Ua as f,Ut as p,Vt as m,Wt as h,_t as g,ar as _,bt as v,dn as y,en as b,gt as x,hn as S,ht as C,ir as w,lr as T,or as E,qt as D,rr as O,sr as k,ta as A,ut as j,vt as M,xt as N,ys as P,yt as F}from"./ui-components-J75dr3Ae.js";import"./src-DRWgP_lu.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:l,cls:`text-emerald-600 border-emerald-300`},completed:{icon:l,cls:`text-emerald-600 border-emerald-300`},failed:{icon:d,cls:`text-red-600 border-red-300`},error:{icon:d,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:P,cls:`text-amber-600 border-amber-300`},skipped:{icon:s,cls:`text-muted-foreground`}}[e]??{icon:s,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(T,{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)([]),[a,o]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[d,f]=(0,I.useState)(``),[p,h]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),o(!1);return}o(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!d&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{o(!1)}},[e,d]);(0,I.useEffect)(()=>{g()},[g]);let v=(0,I.useMemo)(()=>t.find(e=>e.name===d)??null,[t,d]);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)(c,{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)(O,{children:[(0,L.jsx)(E,{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)(k,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(u,{variant:`outline`,size:`sm`,onClick:g,disabled:a,children:[(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2 ${a?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(w,{children:[a&&(0,L.jsx)(m,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!a&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!a&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:d,onChange:e=>f(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))})]})]}),v&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:v.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:v.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(!1),[c,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),p(null),h(null)},[t?.name]);let g=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(O,{children:[(0,L.jsxs)(E,{className:`pb-3`,children:[(0,L.jsx)(k,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(w,{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)(S,{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)(T,{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)(N,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>g(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(j,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(y,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(u,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}s(!0),h(null),p(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}p(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{s(!1)}},disabled:o,size:`sm`,children:[o?(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`}),o?`Running…`:`Run Flow`]})}),(c||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||c?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(d,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(l,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof c?.durationMs==`number`&&(0,L.jsxs)(T,{variant:`secondary`,className:`text-[10px] font-mono`,children:[c.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),c&&(0,L.jsx)(V,{data:c})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,s]=(0,I.useState)([]),[c,l]=(0,I.useState)(!0),[d,y]=(0,I.useState)(null),[S,A]=(0,I.useState)(null),[j,N]=(0,I.useState)(null),[P,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){y(`automation.listRuns is not available on this client`),l(!1);return}l(!0),y(null);try{let n=await e.automation.listRuns(t,{limit:20});s(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){y(e?.message??String(e))}finally{l(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{children:[(0,L.jsx)(E,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(k,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(u,{variant:`outline`,size:`sm`,onClick:W,disabled:c,children:[c?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(w,{children:[c&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(m,{className:`h-8 w-full`}),(0,L.jsx)(m,{className:`h-8 w-full`}),(0,L.jsx)(m,{className:`h-8 w-full`})]}),!c&&d&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:d}),!c&&!d&&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.`}),!c&&!d&&r.length>0&&(0,L.jsxs)(C,{children:[(0,L.jsx)(F,{children:(0,L.jsxs)(v,{children:[(0,L.jsx)(M,{children:`Run`}),(0,L.jsx)(M,{children:`Status`}),(0,L.jsx)(M,{children:`Started`}),(0,L.jsx)(M,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(x,{children:r.map(e=>(0,L.jsxs)(v,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(g,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(g,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(g,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(g,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!S,onOpenChange:e=>{e||(A(null),N(null))},children:(0,L.jsxs)(h,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(o,{className:`p-4 border-b`,children:[(0,L.jsxs)(D,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(a,{children:j&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:j.status}),typeof j.durationMs==`number`&&(0,L.jsxs)(T,{variant:`secondary`,className:`text-[10px] font-mono`,children:[j.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(j.startedAt)})]})})]}),(0,L.jsxs)(b,{className:`flex-1 p-4`,children:[P&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(m,{className:`h-16 w-full`}),(0,L.jsx)(m,{className:`h-16 w-full`}),(0,L.jsx)(m,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!P&&j&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(j.steps)&&j.steps.length>0?j.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)(T,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(T,{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:j})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{A as r}from"./framework-DxDZ_zWg.js";import{Gi as i,Gt as a,Kt as o,Ls as s,Pr as c,Ps as l,Tr as u,Ts as d,Ua as f,Ut as p,Vt as m,Wt as h,_t as g,ar as _,bt as v,dn as y,en as b,gt as x,hn as S,ht as C,ir as w,lr as T,or as E,qt as D,rr as O,sr as k,ta as A,ut as j,vt as M,xt as N,ys as P,yt as F}from"./ui-components-BDy7soRa.js";import"./src-BM-XgFqH.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:l,cls:`text-emerald-600 border-emerald-300`},completed:{icon:l,cls:`text-emerald-600 border-emerald-300`},failed:{icon:d,cls:`text-red-600 border-red-300`},error:{icon:d,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:P,cls:`text-amber-600 border-amber-300`},skipped:{icon:s,cls:`text-muted-foreground`}}[e]??{icon:s,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(T,{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)([]),[a,o]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[d,f]=(0,I.useState)(``),[p,h]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),o(!1);return}o(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!d&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{o(!1)}},[e,d]);(0,I.useEffect)(()=>{g()},[g]);let v=(0,I.useMemo)(()=>t.find(e=>e.name===d)??null,[t,d]);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)(c,{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)(O,{children:[(0,L.jsx)(E,{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)(k,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(u,{variant:`outline`,size:`sm`,onClick:g,disabled:a,children:[(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2 ${a?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(w,{children:[a&&(0,L.jsx)(m,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!a&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!a&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:d,onChange:e=>f(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))})]})]}),v&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:v.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:v.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(!1),[c,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),p(null),h(null)},[t?.name]);let g=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(O,{children:[(0,L.jsxs)(E,{className:`pb-3`,children:[(0,L.jsx)(k,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(w,{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)(S,{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)(T,{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)(N,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>g(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(j,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(y,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(u,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}s(!0),h(null),p(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}p(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{s(!1)}},disabled:o,size:`sm`,children:[o?(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`}),o?`Running…`:`Run Flow`]})}),(c||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||c?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(d,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(l,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof c?.durationMs==`number`&&(0,L.jsxs)(T,{variant:`secondary`,className:`text-[10px] font-mono`,children:[c.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),c&&(0,L.jsx)(V,{data:c})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,s]=(0,I.useState)([]),[c,l]=(0,I.useState)(!0),[d,y]=(0,I.useState)(null),[S,A]=(0,I.useState)(null),[j,N]=(0,I.useState)(null),[P,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){y(`automation.listRuns is not available on this client`),l(!1);return}l(!0),y(null);try{let n=await e.automation.listRuns(t,{limit:20});s(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){y(e?.message??String(e))}finally{l(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{children:[(0,L.jsx)(E,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(k,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(u,{variant:`outline`,size:`sm`,onClick:W,disabled:c,children:[c?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(w,{children:[c&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(m,{className:`h-8 w-full`}),(0,L.jsx)(m,{className:`h-8 w-full`}),(0,L.jsx)(m,{className:`h-8 w-full`})]}),!c&&d&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:d}),!c&&!d&&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.`}),!c&&!d&&r.length>0&&(0,L.jsxs)(C,{children:[(0,L.jsx)(F,{children:(0,L.jsxs)(v,{children:[(0,L.jsx)(M,{children:`Run`}),(0,L.jsx)(M,{children:`Status`}),(0,L.jsx)(M,{children:`Started`}),(0,L.jsx)(M,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(x,{children:r.map(e=>(0,L.jsxs)(v,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(g,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(g,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(g,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(g,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!S,onOpenChange:e=>{e||(A(null),N(null))},children:(0,L.jsxs)(h,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(o,{className:`p-4 border-b`,children:[(0,L.jsxs)(D,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(a,{children:j&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:j.status}),typeof j.durationMs==`number`&&(0,L.jsxs)(T,{variant:`secondary`,className:`text-[10px] font-mono`,children:[j.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(j.startedAt)})]})})]}),(0,L.jsxs)(b,{className:`flex-1 p-4`,children:[P&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(m,{className:`h-16 w-full`}),(0,L.jsx)(m,{className:`h-16 w-full`}),(0,L.jsx)(m,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!P&&j&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(j.steps)&&j.steps.length>0?j.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)(T,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(T,{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:j})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{Di as a,Jn as o,Ks as s,Qn as c,Tr as l,Xn as u,Yn as d,Zn as f,ao as p,ar as m,as as h,dc as g,dn as _,ds as v,ea as y,hr as b,ii as x,ir as S,lr as C,mr as w,or as T,pr as E,qn as D,rr as O,sr as k,ts as A}from"./ui-components-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{Di as a,Jn as o,Ks as s,Qn as c,Tr as l,Xn as u,Yn as d,Zn as f,ao as p,ar as m,as as h,dc as g,dn as _,ds as v,ea as y,hr as b,ii as x,ir as S,lr as C,mr as w,or as T,pr as E,qn as D,rr as O,sr as k,ts as A}from"./ui-components-BDy7soRa.js";var j=e(t(),1),M=`objectstack`,N=`Query and modify data in an ObjectStack app over MCP — discover objects, read and filter records, and create/update/delete under your own permissions and row-level security. Use when the user wants to inspect or change data in their ObjectStack environment.`,P=`<YOUR_ENV_MCP_URL>`;function F(e={}){let t=e.mcpUrl?.trim()||P,n=e.envName?.trim();return`---
|
|
2
2
|
name: ${M}
|
|
3
3
|
description: ${N}
|
|
4
4
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,p as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{A as a,V as o,i as s,j as c,z as l}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,p as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{A as a,V as o,i as s,j as c,z as l}from"./framework-DxDZ_zWg.js";import{G as u,J as d,Z as f,as as p,q as m}from"./ui-components-BDy7soRa.js";import"./MetadataProvider-BWz_wO6c.js";import{t as h}from"./RecordDetailView-BQ_3CT6r.js";import{c as g}from"./plugins-views-BFmfVAkr.js";var _=e(t(),1),v=`uf_`;function y(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(v)&&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 b(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=v+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var x=r();function S(e){return Array.isArray(e?.columns)&&e.columns.length>0}function C(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(S)??r[0]}var w=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function ee(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&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function T(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var E=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),D=new Set([`date`,`datetime`,`time`]),O=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function k(e){let t=T(e,(e,t)=>E.has(t.type))??T(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function A(e){return T(e,(e,t)=>D.has(t.type))??T(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function j(e){let t=A(e);return t?{startDateField:t}:void 0}function M(e){let t=T(e,(e,t)=>O.has(t.type));return t?{coverField:t}:void 0}var N=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function P(e){let t=T(e,(e,t)=>D.has(t.type)&&/start|begin|kickoff/i.test(e))??T(e,(e,t)=>D.has(t.type));if(!t)return;let n=T(e,(e,n)=>D.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??T(e,(e,n)=>D.has(n.type)&&e!==t);if(!n)return;let r=T(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function F(e){let t=T(e,(e,t)=>N.has(t.type))??T(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function I({page:e,className:t,onConfigChange:r,reserveEditAffordance:v}){let{t:w}=s(),{objects:T}=c(),E=a(),D=i(),[O,A]=n(),[N]=_.useState(()=>y(new URLSearchParams(window.location.search))),I=_.useCallback(e=>{A(t=>b(t,e),{replace:!0})},[A]),L=e?.interfaceConfig||{},R=_.useMemo(()=>(T||[]).find(e=>e.name===L.source),[T,L.source]),z=_.useMemo(()=>C(R,L.sourceView),[R,L.sourceView]),B=L.recordAction===`page`||L.recordAction===`modal`||L.recordAction===`none`?L.recordAction:`drawer`,V=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${L.source}/record/${encodeURIComponent(String(e))}`,[L.source]),H=l({navigation:{mode:B===`none`?`none`:B},objectName:L.source,onNavigate:e=>D(V(e))}),U=O.get(`recordId`),W=_.useCallback((e,t)=>{if(B===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(V(n),`_blank`);return}if((B===`drawer`||B===`modal`)&&n!=null){A(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}H.handleClick(e,t)},[B,V,H,A]),G=_.useCallback(()=>{A(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[A]);_.useEffect(()=>{U&&!H.isOpen?H.open({id:U}):!U&&H.isOpen&&H.close()},[U]);let K=R?.name,q=!!z&&!S(z),J=z?.name??(L.sourceView?`${L.source}.${L.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!L.source||!q||!J))return(async()=>{try{let t=E,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(L.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(L.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,L.source,L.sourceView,q,J,E]);let Z=_.useMemo(()=>Y?{...z,...Y}:z,[z,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!R)return;let e=Z||{},t=L.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=L.userActions||{},a=e.kanban??(r.has(`kanban`)?k(R):void 0),o=e.calendar??(r.has(`calendar`)?j(R):void 0),s=e.timeline??(r.has(`timeline`)?j(R):void 0),c=e.gallery??(r.has(`gallery`)?M(R):void 0),l=e.gantt??(r.has(`gantt`)?P(R):void 0),u=e.options?.map??(r.has(`map`)?F(R):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(L.filterBy)?L.filterBy:[]],f=S(L)?L.columns:S(e)?e.columns:ee(R),p=Array.isArray(L.sort)&&L.sort.length?L.sort:e.sort;return{type:`list-view`,objectName:R.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:L.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:L.showRecordCount,addRecord:L.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:i.editInline===!0}},[K,te,L]);if(!R||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(m,{children:[(0,x.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,x.jsx)(p,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(f,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(d,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:L.source||`?`})})]})});let $=Array.isArray(L.buttons)&&L.buttons.length?L.buttons.map(e=>(R.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:t??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,x.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${v?`pr-12`:`pr-4`}`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.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,x.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,x.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,x.jsx)(o,{schema:{type:`action:bar`,location:`list_toolbar`,actions:$,size:`sm`,variant:`outline`}})})]}),(0,x.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,x.jsx)(g,{schema:Q,dataSource:E,userFilterSelections:N,onUserFilterSelectionsChange:I,onSortChange:r?e=>r({sort:e}):void 0,onColumnStateChange:r?e=>{e?.order?.length&&r({columns:e.order})}:void 0,onRowClick:B===`none`?void 0:W})}),H.isOverlay&&(0,x.jsx)(u,{...H,setIsOpen:e=>{e||G()},title:typeof e.label==`string`?e.label:L.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:L.source,recordIdOverride:String(e?.id??e?._id??U??``),embedded:!0,dataSource:E,objects:T,onEdit:()=>{}})})]})}export{b as n,y as r,I as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./vendor-react-slxo-5GC.js";import{Ai as t,Bt as n,Di as r,Ha as i,Lt as a,Mc as o,Oc as s,Rt as c,lr as l,zt as u}from"./ui-components-
|
|
1
|
+
import{t as e}from"./vendor-react-slxo-5GC.js";import{Ai as t,Bt as n,Di as r,Ha as i,Lt as a,Mc as o,Oc as s,Rt as c,lr as l,zt as u}from"./ui-components-BDy7soRa.js";var d=e(),f={config:{icon:t,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:i,short:`System-managed`,title:`Managed by the platform`,body:()=>`Rows here are created automatically when actions run on the source record. The list below is a read-only monitoring surface — row-level actions (Approve, Recall, Resend, …) live on each row.`,tone:`border-slate-300/60 bg-slate-50 text-slate-900 hover:bg-slate-100 dark:border-slate-500/40 dark:bg-slate-950/40 dark:text-slate-100`},"append-only":{icon:s,short:`Read-only · Audit log`,title:`Read-only historical record`,body:()=>`Immutable audit log. Rows cannot be created, edited, or deleted from the UI — they're written by the platform when events occur. Use Export to download for compliance review.`,tone:`border-zinc-300/60 bg-zinc-50 text-zinc-900 hover:bg-zinc-100 dark:border-zinc-500/40 dark:bg-zinc-950/40 dark:text-zinc-100`},"better-auth":{icon:r,short:`Identity`,title:`Managed by the identity provider`,body:e=>`This object's schema is owned by ${e}. Direct edits bypass password hashing, session validation, two-factor checks, and audit hooks. Manage these records through your authentication provider's sign-in, invitation, and security flows instead.`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function p({managedBy:e,label:t,className:r}){if(!e||e===`platform`)return null;let i=f[e];if(!i)return null;let s=i.icon,p=t??`better-auth`;return(0,d.jsx)(u,{delayDuration:200,children:(0,d.jsxs)(a,{children:[(0,d.jsx)(n,{asChild:!0,children:(0,d.jsxs)(l,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:o(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,i.tone,r),children:[(0,d.jsx)(s,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:i.short})]})}),(0,d.jsxs)(c,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:i.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:i.body(p)})]})]})})}export{p as t};
|
package/dist/assets/{MarketplaceAccessDenied-BQ6-NcgV.js → MarketplaceAccessDenied-D5Q4tCaN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,t,u as n}from"./vendor-react-slxo-5GC.js";import{i as r}from"./framework-
|
|
1
|
+
import{f as e,t,u as n}from"./vendor-react-slxo-5GC.js";import{i as r}from"./framework-DxDZ_zWg.js";import{Ha as i,Tr as a,ir as o,rr as s}from"./ui-components-BDy7soRa.js";var c=t();function l(){let t=n(),{appName:l}=e(),{t:u}=r(),d=l?`/apps/${l}`:`/`;return(0,c.jsx)(`div`,{className:`container mx-auto max-w-2xl px-6 py-16`,children:(0,c.jsx)(s,{children:(0,c.jsxs)(o,{className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,c.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,c.jsx)(i,{className:`h-6 w-6 text-muted-foreground`})}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h2`,{className:`text-lg font-semibold`,children:u(`marketplace.accessDenied.title`)}),(0,c.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:u(`marketplace.accessDenied.description`)})]}),(0,c.jsx)(a,{variant:`outline`,onClick:()=>t(d),children:u(`marketplace.action.backHome`)})]})})})}export{l as t};
|
package/dist/assets/{MarketplaceInstalledPage-CUPRsl4f.js → MarketplaceInstalledPage-DVJsLTJz.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BySW-NB0.js";import{
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BySW-NB0.js";import{Nt as s,i as c}from"./framework-DxDZ_zWg.js";import{Ec as l,Ki as u,Ls as d,Tr as f,Vt as p,Zo as m,Zr as h,ir as g,lr as _,or as v,rr as y,sr as b,ui as x}from"./ui-components-BDy7soRa.js";import{_ as S,l as C,u as w}from"./marketplaceApi-2fWjbQI7.js";import{t as T}from"./MarketplaceAccessDenied-D5Q4tCaN.js";var E=e(n(),1),D=i();function O(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:s}=c(),l=t?`/apps/${t}`:``,[x,O]=(0,E.useState)([]),[k,A]=(0,E.useState)(`local`),[j,M]=(0,E.useState)(!0),[N,P]=(0,E.useState)(null),[F,I]=(0,E.useState)(null),L=async()=>{M(!0);try{let e=await C();e.connected?(A(`cloud`),O(e.items)):(A(`local`),O(await w()))}finally{M(!1)}};(0,E.useEffect)(()=>{L()},[]);let R=async e=>{if(confirm(i(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await S(e.manifestId),I({ok:!0,message:i(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(f,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(u,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})}),F&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${F.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:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(d,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&x.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(p,{className:`h-20 w-full`},t))}):x.length===0?(0,D.jsxs)(`div`,{className:`text-center py-12 text-sm text-muted-foreground border rounded-md`,children:[(0,D.jsx)(`p`,{children:i(`marketplace.installedEmpty`)}),(0,D.jsx)(f,{variant:`link`,className:`mt-2`,onClick:()=>e(`${l}/system/marketplace`),children:i(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:x.map(t=>(0,D.jsxs)(y,{children:[(0,D.jsxs)(v,{className:`flex flex-row items-start justify-between gap-3 pb-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(b,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(_,{variant:`outline`,children:i(`marketplace.versionBadge`,{version:t.version})})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap gap-x-3 gap-y-1`,children:[(0,D.jsx)(`span`,{children:i(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:i(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[i(`marketplace.installedPackageId`),` `,(0,D.jsx)(`code`,{className:`font-mono`,children:t.packageId})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(f,{variant:`ghost`,size:`sm`,onClick:()=>e(`${l}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(m,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(f,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(h,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?i(`marketplace.action.uninstalling`):i(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(g,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:i(`marketplace.cachedAs`,{path:`.objectstack/installed-packages/${t.manifestId.replace(/[^a-zA-Z0-9._-]/g,`_`)}.json`})}})]},t.manifestId))}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground border-t pt-4`,dangerouslySetInnerHTML:{__html:i(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(T,{})}s.register(`marketplace:installed-list`,()=>(0,D.jsx)(O,{}),{namespace:`app-shell`,label:`Installed Marketplace Packages`,category:`plugin`,inputs:[]});var k=t({MarketplaceInstalledPage:()=>A});function A(){let e=a(),{appName:t}=r(),{t:n}=c(),i=t?`/apps/${t}`:``;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-5xl`,children:[(0,D.jsxs)(f,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${i}/system/marketplace`),children:[(0,D.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),n(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(x,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:n(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:n(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
|
package/dist/assets/{MarketplacePackagePage-CiSZE5lH.js → MarketplacePackagePage-BAmq5XCe.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as ee}from"./infrastructure-BySW-NB0.js";import{i as te,j as ne}from"./framework-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as ee}from"./infrastructure-BySW-NB0.js";import{i as te,j as ne}from"./framework-DxDZ_zWg.js";import{$t as re,Ao as o,Di as s,Ec as ie,Ei as c,Ir as l,Is as ae,Jn as oe,Ls as u,Ps as d,Qn as se,Qo as ce,Qt as le,Sa as f,Tn as ue,Tr as p,Ua as m,Vt as h,Xn as de,Xt as fe,Yn as pe,Yt as me,Zn as he,Zo as ge,Zr as g,Zt as _e,_n as ve,as as ye,ba as be,gn as xe,hn as _,ir as Se,lc as Ce,lr as v,ms as we,nr as y,or as Te,qn as Ee,rr as De,sr as Oe,ts as ke,yn as b}from"./ui-components-BDy7soRa.js";import"./MetadataProvider-BWz_wO6c.js";import{n as Ae}from"./assistantBus-DosfPCbN.js";import{_ as je,a as Me,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,x as S}from"./marketplaceApi-2fWjbQI7.js";import{n as Ue,t as We}from"./usePackageL10n-CasuagU5.js";import{t as Ge}from"./MarketplaceAccessDenied-D5Q4tCaN.js";var C=e(n(),1),w=i();function T(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 E(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,w.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,w.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,w.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,w.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,w.jsx)(w.Fragment,{children:t.map((e,t)=>(0,w.jsx)(C.Fragment,{children:e},t))})}function Ke({source:e,className:t}){let n=T(e);return(0,w.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,w.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:E(e.text??``)},t);case`h2`:return(0,w.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:E(e.text??``)},t);case`h3`:return(0,w.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:E(e.text??``)},t);case`p`:return(0,w.jsx)(`p`,{children:E(e.text??``)},t);case`ul`:return(0,w.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.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,w.jsx)(`span`,{children:E(e)})]},t))},t);case`ol`:return(0,w.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,w.jsx)(`li`,{className:`pl-1`,children:E(e)},t))},t);case`code`:return(0,w.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,w.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var D={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function O({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,w.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,w.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function qe({version:e}){let{t}=te();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,w.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,w.jsx)(we,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,w.jsx)(v,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:D[e.runtime]??e.runtime})}),e.platform_verified?(0,w.jsxs)(v,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,w.jsx)(c,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,w.jsxs)(v,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,w.jsx)(s,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,w.jsxs)(v,{variant:`outline`,className:`gap-1`,children:[(0,w.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,w.jsx)(O,{icon:Ce,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,w.jsx)(O,{icon:l,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,w.jsx)(O,{icon:f,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,w.jsx)(O,{icon:o,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var k=t({MarketplacePackagePage:()=>A});function A(){let e=a(),{packageId:t,appName:n}=r(),i=ee(),{t:o,language:s}=te(),c=n?`/apps/${n}`:``,{refresh:l}=ne(),[f,Ce]=(0,C.useState)(null),[we,T]=(0,C.useState)(!0),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(!1),[A,Je]=(0,C.useState)([]),[Ye,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(``),[Xe,Ze]=(0,C.useState)({}),[I,Qe]=(0,C.useState)(!1),[$e,et]=(0,C.useState)(!1),[L,tt]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[B,nt]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(null),[G,K]=(0,C.useState)(null),[rt,it]=(0,C.useState)([]),[at,q]=(0,C.useState)(!1),[J,Y]=(0,C.useState)(null);(0,C.useEffect)(()=>{if(!S().features.installLocal)return;let e=!1;return(async()=>{let t=await He();e||it(t)})(),()=>{e=!0}},[t,J]),(0,C.useEffect)(()=>{if(!t)return;let e=S().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await x(t,e);n||!r||(H(r),nt(r.version))})(),()=>{n=!0}},[t]),(0,C.useEffect)(()=>{let e=!1;return(async()=>{if(t){T(!0),D(null);try{let n=await Ie(t);e||Ce(n)}catch(t){e||D(t?.message??String(t))}finally{e||T(!1)}}})(),()=>{e=!0}},[t]);let ot=async()=>{k(!0),z(null),N(null);let e=S().defaultEnvironmentId;if(e){j(!1),F(e),Je([]);return}j(!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});Je(r),Ze({});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]);Ze(t)}),e.length>0&&r.length===0?N(o(`marketplace.install.noPermission`)):r.length===1&&F(r[0].id)}catch(e){let t=e?.status;N(t===401||t===403?o(`marketplace.install.signInFirst`):e?.message??String(e))}finally{j(!1)}},st=async()=>{if(!(!t||!P)){tt(!0),z(null);try{nt(((await Re({packageId:t,environmentId:P,seedSampleData:I}))?.installation?.version??f?.package?.latest_version?.version??f?.versions?.[0]?.version??``)||`installed`);try{let e=S().defaultEnvironmentId||P;if(e){let n=await x(t,e);n&&H(n)}}catch{}let e=S().defaultEnvironmentId;if(!e||e===P)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await l()}catch{}z({ok:!0,message:o(`marketplace.install.success`)}),Ae()}catch(e){z({ok:!1,message:e?.message??String(e)})}finally{tt(!1)}}},ct=async()=>{if(t){q(!0),Y(null);try{let e=await Me({packageId:t});try{await l(`app`)}catch{}Y({ok:!0,message:o(`marketplace.install.localSuccess`,{version:e.version,name:f?.package?We(f.package,s).displayName:e.manifestId})}),Ae()}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=o(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=o(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=o(`marketplace.install.localMarketplaceUnavailable`)),Y({ok:!1,message:n})}finally{q(!1)}}},lt=async()=>{if($&&confirm(o(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){q(!0),Y(null);try{await je($.manifestId);try{await l(`app`)}catch{}Y({ok:!0,message:o(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){Y({ok:!1,message:e?.message??String(e)})}finally{q(!1)}}},ut=async()=>{if(V){W(`reseed`),K(null);try{let e=await Pe(V.installationId);e.ok?(H({...V,withSampleData:!0}),K({ok:!0,text:o(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):K({ok:!1,text:e.error||`Re-seed failed`})}finally{W(null)}}},dt=async()=>{if(V&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){W(`purge`),K(null);try{let e=await Le(V.installationId);if(e.ok){H({...V,withSampleData:!1});let t=e.deleted??0;K({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else K({ok:!1,text:e.error||`Purge failed`})}finally{W(null)}}},ft=async()=>{if($){W(`reseed`),K(null);try{let e=await Fe($.manifestId);it(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0,r=e.errors??0,i=o(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`;K(r>0?{ok:!1,text:`${i} ${o(`marketplace.detail.reseedPartialErrors`,{count:r})||`(${r} record(s) failed to write)`}`}:{ok:!0,text:i})}catch(e){K({ok:!1,text:e?.message||`Re-seed failed`})}finally{W(null)}}},pt=async()=>{if($&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){W(`purge`),K(null);try{let e=await ze($.manifestId);it(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;K({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){K({ok:!1,text:e?.message||`Purge failed`})}finally{W(null)}}};if(we)return(0,w.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,w.jsx)(h,{className:`h-8 w-32`}),(0,w.jsx)(h,{className:`h-16 w-full`}),(0,w.jsx)(h,{className:`h-64 w-full`})]});if(E||!f)return(0,w.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,w.jsxs)(p,{variant:`ghost`,size:`sm`,onClick:()=>e(`${c}/system/marketplace`),children:[(0,w.jsx)(ie,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,w.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,w.jsx)(u,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`font-medium text-destructive`,children:o(`marketplace.load.packageFailed`)}),(0,w.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:E??o(`marketplace.load.notFound`)})]})]})]});let X=f.package,Z=We(X,s),Q=X.latest_version?.version??f.versions[0]?.version??null,$=rt.find(e=>e.manifestId===X.manifest_id)??null,mt=!!X.latest_version?.contains_code,ht=!!B&&B!==`installed`&&!!Q&&B!==Q,gt=S().features.installLocal,_t=!Q||at||L||!gt&&!!B&&!ht,vt=gt?{label:o(at?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:ct}:{label:L?o(`marketplace.action.installing`):B?ht?o(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Q}):o(`marketplace.action.installed`,{defaultValue:`Installed`}):o(`marketplace.action.installToCloud`),onClick:ot},yt=X.category?o(`marketplace.category.${X.category}`,{defaultValue:X.category}):null;return i?(0,w.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,w.jsxs)(p,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${c}/system/marketplace`),children:[(0,w.jsx)(ie,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,w.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,w.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,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,w.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Z.displayName||X.manifest_id}),X.homepage_url&&(0,w.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:o(`marketplace.detail.homepage`),children:[(0,w.jsx)(ge,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,w.jsx)(`span`,{className:`hidden sm:inline`,children:o(`marketplace.detail.homepage`)})]})]}),(0,w.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,w.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:X.manifest_id}),Q&&(0,w.jsx)(v,{variant:`outline`,children:o(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,w.jsx)(v,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),yt&&(0,w.jsx)(v,{variant:`outline`,children:yt}),X.license&&(0,w.jsx)(v,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,w.jsxs)(v,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,w.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:$.version})]}),!$&&B&&(0,w.jsxs)(v,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,w.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:B})]}),ht&&(0,w.jsxs)(v,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,w.jsx)(ae,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Q]})]}),Z.description&&(0,w.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Z.description})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,w.jsxs)(p,{onClick:vt.onClick,disabled:_t,size:`lg`,className:`min-w-[8rem]`,children:[(0,w.jsx)(ke,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),vt.label]}),$&&(0,w.jsxs)(xe,{children:[(0,w.jsx)(ue,{asChild:!0,children:(0,w.jsx)(p,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`),children:(0,w.jsx)(ce,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,w.jsxs)(ve,{align:`end`,className:`w-56`,children:[(0,w.jsxs)(b,{onSelect:ft,disabled:U!==null,children:[U===`reseed`?(0,w.jsx)(m,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,w.jsx)(ye,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,w.jsxs)(b,{onSelect:pt,disabled:U!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[U===`purge`?(0,w.jsx)(m,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,w.jsx)(g,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,w.jsxs)(b,{onSelect:lt,disabled:at,className:`text-destructive focus:text-destructive`,children:[(0,w.jsx)(g,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&V&&!S().cloudUrl&&(0,w.jsxs)(xe,{children:[(0,w.jsx)(ue,{asChild:!0,children:(0,w.jsx)(p,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`)||`More options`,children:(0,w.jsx)(ce,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,w.jsxs)(ve,{align:`end`,className:`w-56`,children:[(0,w.jsxs)(b,{onSelect:ut,disabled:U!==null,children:[U===`reseed`?(0,w.jsx)(m,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,w.jsx)(ye,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),V.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,w.jsxs)(b,{onSelect:dt,disabled:U!==null||!V.withSampleData,className:`text-destructive focus:text-destructive`,children:[U===`purge`?(0,w.jsx)(m,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,w.jsx)(g,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),G&&(0,w.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${G.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:[G.ok?(0,w.jsx)(d,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,w.jsx)(u,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,w.jsx)(`div`,{className:`flex-1`,children:G.text}),(0,w.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>K(null),children:o(`marketplace.action.dismiss`)})]}),J&&(0,w.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,w.jsx)(d,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,w.jsx)(u,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,w.jsx)(`div`,{className:`flex-1`,children:J.message}),(0,w.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>Y(null),children:o(`marketplace.action.dismiss`)})]}),(0,w.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,w.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,w.jsxs)(De,{children:[(0,w.jsx)(Te,{children:(0,w.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.about`)})}),(0,w.jsx)(Se,{children:Z.readme?(0,w.jsx)(Ke,{source:Z.readme}):(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noReadme`)})})]})}),(0,w.jsx)(`div`,{className:`space-y-4`,children:(0,w.jsxs)(De,{children:[(0,w.jsx)(Te,{children:(0,w.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.versions`)})}),(0,w.jsx)(Se,{children:f.versions.length===0?(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noApprovedVersions`)}):(0,w.jsx)(`ul`,{className:`space-y-3`,children:f.versions.map(e=>(0,w.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,w.jsx)(be,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,w.jsx)(v,{variant:`outline`,className:`text-xs`,children:o(`marketplace.detail.prerelease`)})]}),(0,w.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,w.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,w.jsx)(Ee,{open:O,onOpenChange:e=>{k(e),e||(z(null),et(!1))},children:(0,w.jsxs)(oe,{children:[(0,w.jsxs)(he,{children:[(0,w.jsx)(se,{children:o(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,w.jsx)(pe,{children:S().defaultEnvironmentId?o(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):o(`marketplace.install.dialogDescPicker`)})]}),Ye?(0,w.jsx)(h,{className:`h-10 w-full`}):M?(0,w.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(u,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,w.jsx)(`div`,{className:`flex-1`,children:M})]}),(0,w.jsx)(`a`,{href:Ve(X.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,w.jsxs)(p,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,w.jsx)(ge,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.action.openOnCloud`)]})})]}):S().defaultEnvironmentId?(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(y,{id:`seed`,checked:I,onCheckedChange:e=>Qe(e===!0)}),(0,w.jsx)(_,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]}):A.length===0?(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.install.noEnvs`)}):(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,w.jsx)(_,{htmlFor:`env-select`,children:o(`marketplace.install.environment`)}),(0,w.jsxs)(me,{value:P,onValueChange:F,children:[(0,w.jsx)(le,{id:`env-select`,children:(0,w.jsx)(re,{placeholder:o(`marketplace.install.environmentPlaceholder`)})}),(0,w.jsx)(fe,{children:A.map(e=>{let t=Xe[e.id],n=!!t&&!!Q&&t!==`installed`&&t!==Q;return(0,w.jsxs)(_e,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,w.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,o(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Q})]}):(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,o(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(y,{id:`seed`,checked:I,onCheckedChange:e=>Qe(e===!0)}),(0,w.jsx)(_,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]})]}),mt&&!M&&(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(qe,{version:X.latest_version}),(0,w.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(y,{id:`ack-perms`,checked:$e,onCheckedChange:e=>et(e===!0)}),(0,w.jsx)(_,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:o(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),R&&(0,w.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${R.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:R.message}),(0,w.jsxs)(de,{children:[(0,w.jsx)(p,{variant:`outline`,onClick:()=>k(!1),children:o(`marketplace.action.close`)}),!M&&(0,w.jsx)(p,{onClick:st,disabled:!P||L||R?.ok===!0||mt&&!$e,children:o(L?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,w.jsx)(Ge,{})}export{k as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BySW-NB0.js";import{i as s}from"./framework-BGQ7DoWM.js";import{Ki as c,Ls as l,Mi as ee,Ps as u,Tr as d,Vt as f,ar as p,ba as m,dn as te,ir as h,ki as g,lr as _,or as v,rr as y,sr as b,ui as x}from"./ui-components-J75dr3Ae.js";import{n as ne}from"./assistantBus-DosfPCbN.js";import{a as S,d as re,f as ie,l as C,o as ae,u as oe,x as se}from"./marketplaceApi-2fWjbQI7.js";import{n as w,t as T}from"./usePackageL10n-CasuagU5.js";import{t as E}from"./MarketplaceAccessDenied-BQ6-NcgV.js";var D=t({MarketplacePage:()=>A}),O=e(n(),1),k=i();function ce(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:D}=s(),A=ce(),j=t?`/apps/${t}`:``,[M,N]=(0,O.useState)([]),[P,F]=(0,O.useState)(!0),[I,L]=(0,O.useState)(null),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(``),[H,U]=(0,O.useState)([]),[W,le]=(0,O.useState)([]),[G,K]=(0,O.useState)(null),[q,J]=(0,O.useState)(null),[Y,ue]=(0,O.useState)(new Set),de=(0,O.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([re({limit:100}),oe(),ie(),C()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);ue(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,O.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{se().features.installLocal?await S({packageId:e.manifest_id||e.id,versionId:`latest`}):await ae({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),ne()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,O.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,O.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,D);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,D]);return n?(0,k.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(x,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,k.jsx)(g,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?i(`marketplace.installedCount`,{count:H.length}):i(`marketplace.installed`)]}),(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,k.jsx)(c,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,k.jsx)(te,{value:R,onChange:e=>z(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,k.jsx)(d,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:i(`marketplace.all`)}),Z.map(e=>(0,k.jsx)(d,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,k.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,k.jsx)(l,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,k.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,k.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,k.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(x,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,k.jsx)(_,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,k.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.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:q.text}),(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=Y.has(e.manifest_id);return(0,k.jsxs)(y,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,k.jsxs)(v,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(b,{className:`text-base truncate`,children:e.display_name}),(0,k.jsx)(p,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,k.jsx)(_,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,k.jsxs)(h,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,k.jsxs)(_,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(m,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,k.jsx)(`div`,{className:`ml-auto`,children:t?(0,k.jsxs)(_,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(u,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,k.jsx)(d,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,k.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,k.jsxs)(y,{children:[(0,k.jsxs)(v,{className:`pb-2`,children:[(0,k.jsx)(f,{className:`h-10 w-10 rounded-lg mb-2`}),(0,k.jsx)(f,{className:`h-5 w-3/4`}),(0,k.jsx)(f,{className:`h-4 w-1/2 mt-1`})]}),(0,k.jsx)(h,{children:(0,k.jsx)(f,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,k.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,D);return(0,k.jsxs)(y,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,k.jsxs)(v,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(b,{className:`text-base truncate`,children:r.displayName}),(0,k.jsx)(p,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,k.jsx)(_,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,k.jsxs)(h,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,k.jsxs)(_,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(u,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,k.jsxs)(_,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(m,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,k.jsx)(_,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,k.jsx)(E,{})}export{D as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BySW-NB0.js";import{i as s}from"./framework-DxDZ_zWg.js";import{Ki as c,Ls as l,Mi as ee,Ps as u,Tr as d,Vt as f,ar as p,ba as m,dn as te,ir as h,ki as g,lr as _,or as v,rr as y,sr as b,ui as x}from"./ui-components-BDy7soRa.js";import{n as ne}from"./assistantBus-DosfPCbN.js";import{a as S,d as re,f as ie,l as C,o as ae,u as oe,x as se}from"./marketplaceApi-2fWjbQI7.js";import{n as w,t as T}from"./usePackageL10n-CasuagU5.js";import{t as E}from"./MarketplaceAccessDenied-D5Q4tCaN.js";var D=t({MarketplacePage:()=>A}),O=e(n(),1),k=i();function ce(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:D}=s(),A=ce(),j=t?`/apps/${t}`:``,[M,N]=(0,O.useState)([]),[P,F]=(0,O.useState)(!0),[I,L]=(0,O.useState)(null),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(``),[H,U]=(0,O.useState)([]),[W,le]=(0,O.useState)([]),[G,K]=(0,O.useState)(null),[q,J]=(0,O.useState)(null),[Y,ue]=(0,O.useState)(new Set),de=(0,O.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([re({limit:100}),oe(),ie(),C()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);ue(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,O.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{se().features.installLocal?await S({packageId:e.manifest_id||e.id,versionId:`latest`}):await ae({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),ne()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,O.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,O.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,D);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,D]);return n?(0,k.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(x,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,k.jsx)(g,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?i(`marketplace.installedCount`,{count:H.length}):i(`marketplace.installed`)]}),(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,k.jsx)(c,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,k.jsx)(te,{value:R,onChange:e=>z(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,k.jsx)(d,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:i(`marketplace.all`)}),Z.map(e=>(0,k.jsx)(d,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,k.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,k.jsx)(l,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,k.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,k.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,k.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(x,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,k.jsx)(_,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,k.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.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:q.text}),(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=Y.has(e.manifest_id);return(0,k.jsxs)(y,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,k.jsxs)(v,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(b,{className:`text-base truncate`,children:e.display_name}),(0,k.jsx)(p,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,k.jsx)(_,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,k.jsxs)(h,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,k.jsxs)(_,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(m,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,k.jsx)(`div`,{className:`ml-auto`,children:t?(0,k.jsxs)(_,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(u,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,k.jsx)(d,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,k.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,k.jsxs)(y,{children:[(0,k.jsxs)(v,{className:`pb-2`,children:[(0,k.jsx)(f,{className:`h-10 w-10 rounded-lg mb-2`}),(0,k.jsx)(f,{className:`h-5 w-3/4`}),(0,k.jsx)(f,{className:`h-4 w-1/2 mt-1`})]}),(0,k.jsx)(h,{children:(0,k.jsx)(f,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,k.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,D);return(0,k.jsxs)(y,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,k.jsxs)(v,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(b,{className:`text-base truncate`,children:r.displayName}),(0,k.jsx)(p,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,k.jsx)(_,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,k.jsxs)(h,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,k.jsxs)(_,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(u,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,k.jsxs)(_,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(m,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,k.jsx)(_,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,k.jsx)(E,{})}export{D as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{i as r,yt as i}from"./framework-DxDZ_zWg.js";import{Gs as a,Ks as o,Us as s,ds as c}from"./ui-components-BDy7soRa.js";function l(e,t,n){if(!(!e||t==null)){if(n){let r=e.find(e=>e.name===t&&e._packageId===n);if(r)return r}return e.find(e=>e.name===t)}}var u=e(t(),1),d=n();function f({sections:e,open:t}){if(!t)return null;let{t:n}=r(),[i,l]=(0,u.useState)([`0`]),[f,p]=(0,u.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,d.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,d.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let r=String(t),l=i.includes(r),u=f===t;return(0,d.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,d.jsxs)(`button`,{onClick:()=>h(r),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,d.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(s,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:u?(0,d.jsx)(o,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(c,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,d.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function p(){let[e,t]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?i(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{p as n,l as r,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{k as a}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{k as a}from"./framework-DxDZ_zWg.js";import{n as o}from"./data-adapter-ByjA1NUo.js";import{i as s}from"./plugin-form-DZ4onNeM.js";import{a as c,o as l}from"./assistantBus-DosfPCbN.js";var u=e(t(),1),d=r(),f=(0,u.createContext)(!1),p=`preview`,m=`draft`;function h(e){return new URLSearchParams(e).get(p)===m}var g=!1;function _(){g=!0}function v({force:e,children:t}){let r=n(),a=i(),o=(0,u.useMemo)(()=>h(r.search),[r.search]),[s,c]=(0,u.useState)(o);return(0,u.useEffect)(()=>{if(o){c(!0),g=!1;return}if(!s)return;if(g){g=!1,c(!1);return}let e=new URLSearchParams(r.search);e.set(p,m),a(`${r.pathname}?${e.toString()}${r.hash}`,{replace:!0})},[o,s,r.pathname,r.search,r.hash,a]),(0,d.jsx)(f.Provider,{value:e??(o||s),children:t})}function y(){return(0,u.useContext)(f)}var b=300*1e3,x=[`app`,`view`],S={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},C=`objectui:metadata:`;function w(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var T=w();function E(...e){T&&console.debug(`[MetadataProvider]`,...e)}function D(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function O(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function k(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function A(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function j(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)A(e)&&r.add(e.object);for(let e of t){if(A(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 M(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 N(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function P(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(C+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function F(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(C+e,JSON.stringify(t))}catch{}}function I({children:e,adapter:t,ttlMs:n=b}){let r=(0,u.useRef)(new Map),i=(0,u.useRef)(new Map),s=(0,u.useRef)(t);s.current=t;let f=y(),p=(0,u.useMemo)(()=>f?new o({baseUrl:``,previewDrafts:!0}):null,[f]),m=(0,u.useRef)(p);m.current=p;let[h,g]=(0,u.useState)(0),_=(0,u.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>g(e=>e+1)):Promise.resolve().then(()=>g(e=>e+1))},[]);(0,u.useEffect)(()=>{r.current.clear(),i.current.clear(),_()},[f,_]);let v=(0,u.useCallback)(e=>{let t=r.current.get(e);return t||(t=N(),r.current.set(e,t)),t},[]),C=(0,u.useCallback)(e=>{let t=v(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return E(`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=m.current,a=(i?i.list(e):s.current.getClient().meta.getItems(e)).then(n=>{let a=D(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)k(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&F(e,a),E(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),_(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,E(`fetch failed type=${e}`,r),_(),[]});return t.promise=a,a},[_,v,n]),w=(0,u.useCallback)((e,t)=>{let n=v(e);if(n.byName.has(t))return E(`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=m.current,l=(c?c.get(e,t):s.current.getClient().meta.getItem(e,t)).then(i=>{let a=O(i);return a&&n.byName.set(t,a),E(`fetched item type=${e} name=${t} in ${Date.now()-o}ms`),r.delete(t),a}).catch(n=>(r.delete(t),E(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[v]),T=(0,u.useCallback)(async e=>{if(e){let t=v(e);t.fetchedAt=0,t.byName.clear(),await C(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(),C(e)}))},[C,v]),A=(0,u.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),E(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,E(`invalidated type=${e}`)),_())},[_]);(0,u.useEffect)(()=>{if(f)return c(({type:e})=>{A(e)})},[f,A]),(0,u.useEffect)(()=>l(()=>{try{s.current?.clearCache?.()}catch{}T()}),[T]);let[I,L]=(0,u.useState)(!0),[R,z]=(0,u.useState)(null);(0,u.useEffect)(()=>{let e=!1,t=f?null:P(`app`);if(t){let e=v(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)k(n)&&e.byName.set(n.name,n);_(),L(!1)}return(async()=>{for(let t of x)try{await C(t),e||z(null)}catch(t){e||z(t instanceof Error?t:Error(String(t)))}e||L(!1)})(),()=>{e=!0}},[t,C,v,_,f]);let B=(0,u.useMemo)(()=>{let e=e=>{let t=v(e);return t.status===`idle`&&C(e),t.items};return{apps:v(`app`).items,get objects(){let t=e(S.objects),n=e(`view`);return M(n.length?j(t,n):t)},get dashboards(){return e(S.dashboards)},get reports(){return e(S.reports)},get pages(){return e(S.pages)},loading:I,error:R??v(`app`).error,refresh:T,invalidate:A,ensureType:C,getItem:w,getItemsByType:t=>e(t),getTypeStatus:e=>v(e).status}},[h,I,R,C,w,v,T,A]);return(0,d.jsx)(a.Provider,{value:B,children:e})}export{y as a,_ as i,p as n,v as r,I as t};
|