@objectstack/console 14.8.0 → 15.0.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/.objectui-sha +1 -1
- package/dist/assets/{AdapterProvider-BzVT9qYv.js → AdapterProvider-CSP_T07G.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-B4I03oil.js → AiPendingActionsPage-BNh8Cf9P.js} +1 -1
- package/dist/assets/{ApiConsolePage-_wjPZg_8.js → ApiConsolePage-Btr9hRka.js} +1 -1
- package/dist/assets/{AppDocsIndex-B3Y96Lvd.js → AppDocsIndex-DFB1tmTx.js} +1 -1
- package/dist/assets/{AppManagementPage-DxZABvOm.js → AppManagementPage-D2jMv3L-.js} +1 -1
- package/dist/assets/{ApprovalsInboxPage-DAjFkDy9.js → ApprovalsInboxPage-CT4IXwpE.js} +1 -1
- package/dist/assets/{AuditLogPage-CuKdhFr9.js → AuditLogPage-BdYvwcAH.js} +1 -1
- package/dist/assets/{ComponentNavView-DebBry51.js → ComponentNavView-C8ngAwyN.js} +1 -1
- package/dist/assets/{CreateViewDialog-BCEk3ESW.js → CreateViewDialog-DcjN_AhY.js} +1 -1
- package/dist/assets/{DashboardView-Bi_ea9x6.js → DashboardView-CLJM8Cfl.js} +1 -1
- package/dist/assets/{DeveloperHubPage-CEFVU_4t.js → DeveloperHubPage-VBsID8Fk.js} +1 -1
- package/dist/assets/{DocShell-C09YMyAT.js → DocShell-ChTlUxMm.js} +1 -1
- package/dist/assets/{ExpressionProvider-gKUl8r3a.js → ExpressionProvider-CHaGm5wf.js} +1 -1
- package/dist/assets/{FlowRunsPage-Of98wriv.js → FlowRunsPage-DdOav-6T.js} +1 -1
- package/dist/assets/{IntegrationsPage-D2Eh-wKl.js → IntegrationsPage-BR2TkAoB.js} +1 -1
- package/dist/assets/{InterfaceListPage-BuAQSxuZ.js → InterfaceListPage-Ca4VNsGg.js} +1 -1
- package/dist/assets/{ManagedByBadge-3xVjmTY7.js → ManagedByBadge-Cdy82I7A.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-YG6RAG6U.js → MarketplaceAccessDenied-B6Tg5g6l.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-BFESaZWD.js → MarketplaceInstalledPage-DBmVXCVz.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-Vy7JiFQ0.js → MarketplacePackagePage-Mt1pHE8U.js} +1 -1
- package/dist/assets/{MarketplacePage-C9kQ9UzP.js → MarketplacePage-D9CLlhnk.js} +1 -1
- package/dist/assets/{MetadataInspector-Dc5CNMYV.js → MetadataInspector-Bqe7rY0S.js} +1 -1
- package/dist/assets/{MetadataProvider-Bkb-vkjJ.js → MetadataProvider-DqPZ6rV2.js} +1 -1
- package/dist/assets/{ObjectDataPage-B_qdf_tA.js → ObjectDataPage-Cz_pMsIv.js} +1 -1
- package/dist/assets/{PageView-CO7Yco3U.js → PageView-CLvQYEdi.js} +1 -1
- package/dist/assets/{ProfilePage--OycjBXX.js → ProfilePage-BDJLPRAf.js} +1 -1
- package/dist/assets/{PublicFormsPage-CI1LZQKt.js → PublicFormsPage-BRflG64R.js} +1 -1
- package/dist/assets/{RecordDetailView-BQzH8bIG.js → RecordDetailView-w6IBQ1cm.js} +1 -1
- package/dist/assets/{RecordFormPage-D3fuaSOR.js → RecordFormPage-inJKFR63.js} +1 -1
- package/dist/assets/{ReportDefaultInspector-DfAMgr8D.js → ReportDefaultInspector-BZaG6IPJ.js} +1 -1
- package/dist/assets/{ReportView-DyMm1CCA.js → ReportView-CSAIx2AR.js} +1 -1
- package/dist/assets/{SearchResultsPage-CVsVjc9k.js → SearchResultsPage-DsnzRV3B.js} +1 -1
- package/dist/assets/{SettingsHub-DTr02Vxf.js → SettingsHub-Begm6jy7.js} +1 -1
- package/dist/assets/{SettingsView-BN_M8m7j.js → SettingsView-C4UULiJk.js} +1 -1
- package/dist/assets/{SystemHubPage-DGggPmsC.js → SystemHubPage-C4J7Le-p.js} +1 -1
- package/dist/assets/data-adapter-Mo_lVy1U.js +7 -0
- package/dist/assets/{framework-DUXRLJaF.js → framework-BL3BtpKU.js} +2 -2
- package/dist/assets/{getIcon-PwXhgLNw.js → getIcon-BZsP3YSU.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-Cdc_XtSh.js → highlighted-body-OFNGDK62-BPN_aS-T.js} +1 -1
- package/dist/assets/i18n-BsjEVcp4.js +9 -0
- package/dist/assets/{index-C_G40cue.js → index-CRgNx-tU.js} +1 -1
- package/dist/assets/index-D1n9Ue1P.css +2 -0
- package/dist/assets/mermaid-GHXKKRXX-BBQimMyN.js +1 -0
- package/dist/assets/{metadata-admin-DYtDZDTS.js → metadata-admin-DHwo5kSi.js} +4 -4
- package/dist/assets/{plugin-calendar-C5OJe0lx.js → plugin-calendar-BTCkHFNk.js} +1 -1
- package/dist/assets/{plugin-charts-C4pZYso-.js → plugin-charts-DugftiGR.js} +1 -1
- package/dist/assets/{plugin-chatbot-B6HiHZjD.js → plugin-chatbot-Cq19aZcF.js} +44 -44
- package/dist/assets/{plugin-dashboard-BMm8A0um.js → plugin-dashboard-CaQs1s4M.js} +1 -1
- package/dist/assets/{plugin-form-zDPLpTAc.js → plugin-form-6ug8Woph.js} +1 -1
- package/dist/assets/{plugin-gantt-Bdm-Yvii.js → plugin-gantt-SwenNrGL.js} +1 -1
- package/dist/assets/{plugin-grid-BJGu5-41.js → plugin-grid-a0e-qAUn.js} +2 -2
- package/dist/assets/{plugin-kanban-BN37MzOm.js → plugin-kanban-B9xzSYs9.js} +1 -1
- package/dist/assets/{plugin-map-Bamjhlg6.js → plugin-map-DnfptTJp.js} +1 -1
- package/dist/assets/{plugin-markdown-Cg477jm9.js → plugin-markdown-DgBcCCgO.js} +1 -1
- package/dist/assets/{plugin-report-9ivqW5g0.js → plugin-report-Dny_M7U-.js} +1 -1
- package/dist/assets/{plugin-timeline-C9C1_Un7.js → plugin-timeline-8zgO0jxJ.js} +1 -1
- package/dist/assets/{plugin-tree-BDrBkDUi.js → plugin-tree-Bzgro7b4.js} +1 -1
- package/dist/assets/{plugin-view-YLoG5wfy.js → plugin-view-DfJ5SCdu.js} +1 -1
- package/dist/assets/{plugins-views-DyIUCjnC.js → plugins-views-CoobEMX4.js} +1 -1
- package/dist/assets/{skeletons-CnYUdj-X.js → skeletons-Bf9TL3pG.js} +1 -1
- package/dist/assets/{src-LTygtqhe.js → src-BMWmj9Zz.js} +1 -1
- package/dist/assets/{src--kVwJFRS.js → src-C6-lrmoQ.js} +1 -1
- package/dist/assets/src-CQwyy7m_.js +18 -0
- package/dist/assets/{types-KTMf42UB.js → types-033eBMjb.js} +1 -1
- package/dist/assets/{ui-components-t1CVb1Ox.js → ui-components-Y3D5-fgK.js} +1 -1
- package/dist/assets/{ui-layout-C7dEpbqb.js → ui-layout-FqyUicdD.js} +1 -1
- package/dist/assets/{use-book-data-Ddcv6p9p.js → use-book-data-BThfYUpK.js} +1 -1
- package/dist/assets/{useMetadata-Ca0oaT4_.js → useMetadata-D5f_5ULL.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/data-adapter-CCueB_gY.js +0 -7
- package/dist/assets/i18n-DALEd5g8.js +0 -9
- package/dist/assets/index-BCvtzf7n.css +0 -2
- package/dist/assets/mermaid-GHXKKRXX-D6paxo1u.js +0 -1
- package/dist/assets/src-DD4w6yW2.js +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{L as r}from"./framework-DUXRLJaF.js";import{$t as i,As as a,Bt as o,Cr as s,Gt as c,Ha as l,Ht as u,Kt as d,Mr as f,Ns as p,Ut as m,Wi as h,Wt as g,_t as _,ar as v,bt as y,ea as b,gt as x,hs as S,ht as C,ir as w,ln as T,lt as E,mt as D,nr as O,pn as k,rr as A,sr as j,tr as M,vt as N,xs as P,yt as F}from"./ui-components-t1CVb1Ox.js";import"./src-DD4w6yW2.js";var I=e(n(),1),L=t();function R({status:e}){let t={success:{icon:a,cls:`text-emerald-600 border-emerald-300`},completed:{icon:a,cls:`text-emerald-600 border-emerald-300`},failed:{icon:P,cls:`text-red-600 border-red-300`},error:{icon:P,cls:`text-red-600 border-red-300`},running:{icon:l,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:S,cls:`text-amber-600 border-amber-300`},skipped:{icon:p,cls:`text-muted-foreground`}}[e]??{icon:p,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(j,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(``),[p,m]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!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),!u&&r.length>0&&d(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{g()},[g]);let _=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);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)(f,{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)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Flow`}),(0,L.jsx)(A,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(s,{variant:`outline`,size:`sm`,onClick:g,disabled:i,children:[(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(O,{children:[i&&(0,L.jsx)(o,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!i&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),_&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:_.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:_.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,o]=(0,I.useState)({}),[c,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),f(null),m(null)},[t?.name]);let h=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(M,{children:[(0,L.jsxs)(w,{className:`pb-3`,children:[(0,L.jsx)(v,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(A,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(O,{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)(k,{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)(j,{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)(y,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>h(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)(E,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>h(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(T,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>h(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(s,{onClick:async()=>{if(!e?.automation?.execute){m(`automation.execute is not available on this client`);return}u(!0),m(null),f(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}let o=await e.automation.execute(t.name,{params:a});f(o),n?.()}catch(e){m(e?.message??String(e))}finally{u(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(b,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(d||p)&&(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:[p||d?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(P,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(a,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof d?.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[d.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),d&&(0,L.jsx)(V,{data:d})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,a]=(0,I.useState)([]),[f,p]=(0,I.useState)(!0),[y,b]=(0,I.useState)(null),[S,T]=(0,I.useState)(null),[E,k]=(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){b(`automation.listRuns is not available on this client`),p(!1);return}p(!0),b(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];a(r)}catch(e){b(e?.message??String(e))}finally{p(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{T(n),k(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);k(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(A,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(s,{variant:`outline`,size:`sm`,onClick:W,disabled:f,children:[f?(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(O,{children:[f&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`})]}),!f&&y&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:y}),!f&&!y&&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.`}),!f&&!y&&r.length>0&&(0,L.jsxs)(D,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(F,{children:[(0,L.jsx)(_,{children:`Run`}),(0,L.jsx)(_,{children:`Status`}),(0,L.jsx)(_,{children:`Started`}),(0,L.jsx)(_,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(C,{children:r.map(e=>(0,L.jsxs)(F,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(u,{open:!!S,onOpenChange:e=>{e||(T(null),k(null))},children:(0,L.jsxs)(m,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(c,{className:`p-4 border-b`,children:[(0,L.jsxs)(d,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(g,{children:E&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:E.status}),typeof E.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[E.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(E.startedAt)})]})})]}),(0,L.jsxs)(i,{className:`flex-1 p-4`,children:[P&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!P&&E&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(E.steps)&&E.steps.length>0?E.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(j,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:E})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{L as r}from"./framework-BL3BtpKU.js";import{$t as i,As as a,Bt as o,Cr as s,Gt as c,Ha as l,Ht as u,Kt as d,Mr as f,Ns as p,Ut as m,Wi as h,Wt as g,_t as _,ar as v,bt as y,ea as b,gt as x,hs as S,ht as C,ir as w,ln as T,lt as E,mt as D,nr as O,pn as k,rr as A,sr as j,tr as M,vt as N,xs as P,yt as F}from"./ui-components-Y3D5-fgK.js";import"./src-CQwyy7m_.js";var I=e(n(),1),L=t();function R({status:e}){let t={success:{icon:a,cls:`text-emerald-600 border-emerald-300`},completed:{icon:a,cls:`text-emerald-600 border-emerald-300`},failed:{icon:P,cls:`text-red-600 border-red-300`},error:{icon:P,cls:`text-red-600 border-red-300`},running:{icon:l,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:S,cls:`text-amber-600 border-amber-300`},skipped:{icon:p,cls:`text-muted-foreground`}}[e]??{icon:p,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(j,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(``),[p,m]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!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),!u&&r.length>0&&d(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{g()},[g]);let _=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);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)(f,{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)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Flow`}),(0,L.jsx)(A,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(s,{variant:`outline`,size:`sm`,onClick:g,disabled:i,children:[(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(O,{children:[i&&(0,L.jsx)(o,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!i&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),_&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:_.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:_.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,o]=(0,I.useState)({}),[c,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),f(null),m(null)},[t?.name]);let h=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(M,{children:[(0,L.jsxs)(w,{className:`pb-3`,children:[(0,L.jsx)(v,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(A,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(O,{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)(k,{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)(j,{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)(y,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>h(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)(E,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>h(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(T,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>h(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(s,{onClick:async()=>{if(!e?.automation?.execute){m(`automation.execute is not available on this client`);return}u(!0),m(null),f(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}let o=await e.automation.execute(t.name,{params:a});f(o),n?.()}catch(e){m(e?.message??String(e))}finally{u(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(b,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(d||p)&&(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:[p||d?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(P,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(a,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof d?.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[d.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),d&&(0,L.jsx)(V,{data:d})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,a]=(0,I.useState)([]),[f,p]=(0,I.useState)(!0),[y,b]=(0,I.useState)(null),[S,T]=(0,I.useState)(null),[E,k]=(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){b(`automation.listRuns is not available on this client`),p(!1);return}p(!0),b(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];a(r)}catch(e){b(e?.message??String(e))}finally{p(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{T(n),k(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);k(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(A,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(s,{variant:`outline`,size:`sm`,onClick:W,disabled:f,children:[f?(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(O,{children:[f&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`}),(0,L.jsx)(o,{className:`h-8 w-full`})]}),!f&&y&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:y}),!f&&!y&&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.`}),!f&&!y&&r.length>0&&(0,L.jsxs)(D,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(F,{children:[(0,L.jsx)(_,{children:`Run`}),(0,L.jsx)(_,{children:`Status`}),(0,L.jsx)(_,{children:`Started`}),(0,L.jsx)(_,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(C,{children:r.map(e=>(0,L.jsxs)(F,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(u,{open:!!S,onOpenChange:e=>{e||(T(null),k(null))},children:(0,L.jsxs)(m,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(c,{className:`p-4 border-b`,children:[(0,L.jsxs)(d,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(g,{children:E&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:E.status}),typeof E.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[E.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(E.startedAt)})]})})]}),(0,L.jsxs)(i,{className:`flex-1 p-4`,children:[P&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`}),(0,L.jsx)(o,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!P&&E&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(E.steps)&&E.steps.length>0?E.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(j,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:E})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,m as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{$i as a,$o as o,Cr as s,Ei as c,Gn as l,Hs as u,Jn as d,Kn as f,Xn as p,Yn as m,ar as h,dr as g,fr as _,io as v,ir as y,ln as b,ni as x,nr as S,pr as C,qn as w,rr as T,rs as E,sc as D,sr as O,ss as k,tr as A}from"./ui-components-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,m as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{$i as a,$o as o,Cr as s,Ei as c,Gn as l,Hs as u,Jn as d,Kn as f,Xn as p,Yn as m,ar as h,dr as g,fr as _,io as v,ir as y,ln as b,ni as x,nr as S,pr as C,qn as w,rr as T,rs as E,sc as D,sr as O,ss as k,tr as A}from"./ui-components-Y3D5-fgK.js";var j=e(i(),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{f as t,h as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{L as a,R as o,Y as s,l as c,q as l}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{L as a,R as o,Y as s,l as c,q as l}from"./framework-BL3BtpKU.js";import{K as u,U as d,X as f,q as p,rs as m}from"./ui-components-Y3D5-fgK.js";import"./MetadataProvider-DqPZ6rV2.js";import{t as h}from"./RecordDetailView-w6IBQ1cm.js";import{l as g}from"./plugins-views-CoobEMX4.js";var _=e(i(),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 T(e){let t=e?.highlightFields;if(Array.isArray(t)&&t.length>0)return t.filter(t=>e.fields?.[t]);let n=e?.fields;return n&&typeof n==`object`?Object.entries(n).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function E(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 D=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),O=new Set([`date`,`datetime`,`time`]),k=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function A(e){let t=E(e,(e,t)=>D.has(t.type))??E(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function j(e){return E(e,(e,t)=>O.has(t.type))??E(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function M(e){let t=j(e);return t?{startDateField:t}:void 0}function N(e){let t=E(e,(e,t)=>k.has(t.type));return t?{coverField:t}:void 0}var P=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function F(e){let t=E(e,(e,t)=>O.has(t.type)&&/start|begin|kickoff/i.test(e))??E(e,(e,t)=>O.has(t.type));if(!t)return;let n=E(e,(e,n)=>O.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??E(e,(e,n)=>O.has(n.type)&&e!==t);if(!n)return;let r=E(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function I(e){let t=E(e,(e,t)=>P.has(t.type))??E(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function L({page:e,className:r,onConfigChange:i,reserveEditAffordance:v}){let{t:w}=c(),{objects:E}=o(),D=a(),O=t(),[k,j]=n(),[P]=_.useState(()=>y(new URLSearchParams(window.location.search))),L=_.useCallback(e=>{j(t=>b(t,e),{replace:!0})},[j]),R=e?.interfaceConfig||{},z=_.useMemo(()=>(E||[]).find(e=>e.name===R.source),[E,R.source]),B=_.useMemo(()=>C(z,R.sourceView),[z,R.sourceView]),V=R.recordAction===`page`||R.recordAction===`modal`||R.recordAction===`none`?R.recordAction:`drawer`,H=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${R.source}/record/${encodeURIComponent(String(e))}`,[R.source]),U=l({navigation:{mode:V===`none`?`none`:V},objectName:R.source,onNavigate:e=>O(H(e))}),W=k.get(`recordId`),G=_.useCallback((e,t)=>{if(V===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(H(n),`_blank`);return}if((V===`drawer`||V===`modal`)&&n!=null){j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}U.handleClick(e,t)},[V,H,U,j]),ee=_.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);_.useEffect(()=>{W&&!U.isOpen?U.open({id:W}):!W&&U.isOpen&&U.close()},[W]);let K=z?.name,q=!!B&&!S(B),J=B?.name??(R.sourceView?`${R.source}.${R.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!R.source||!q||!J))return(async()=>{try{let t=D,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(R.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(R.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,R.source,R.sourceView,q,J,D]);let Z=_.useMemo(()=>Y?{...B,...Y}:B,[B,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!z)return;let e=Z||{},t=R.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=R.userActions||{},a=e.kanban??(r.has(`kanban`)?A(z):void 0),o=e.calendar??(r.has(`calendar`)?M(z):void 0),s=e.timeline??(r.has(`timeline`)?M(z):void 0),c=e.gallery??(r.has(`gallery`)?N(z):void 0),l=e.gantt??(r.has(`gantt`)?F(z):void 0),u=e.options?.map??(r.has(`map`)?I(z):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(R.filterBy)?R.filterBy:[]],f=S(R)?R.columns:S(e)?e.columns:T(z),p=Array.isArray(R.sort)&&R.sort.length?R.sort:e.sort;return{type:`list-view`,objectName:z.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:R.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:R.showRecordCount,addRecord:R.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,R]);if(!z||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(u,{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)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(f,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(p,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:R.source||`?`})})]})});let $=Array.isArray(R.buttons)&&R.buttons.length?R.buttons.map(e=>(z.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:r??`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)(s,{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:D,userFilterSelections:P,onUserFilterSelectionsChange:L,onSortChange:i?e=>i({sort:e}):void 0,onColumnStateChange:i?e=>{e?.order?.length&&i({columns:e.order})}:void 0,onRowClick:V===`none`?void 0:G})}),U.isOverlay&&(0,x.jsx)(d,{...U,setIsOpen:e=>{e||ee()},title:typeof e.label==`string`?e.label:R.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:R.source,recordIdOverride:String(e?.id??e?._id??W??``),embedded:!0,dataSource:D,objects:E,onEdit:()=>{}})})]})}export{A as a,N as i,M as n,b as o,T as r,y as s,L as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor-react-BKSb6vFP.js";import{l as t}from"./framework-
|
|
1
|
+
import{r as e}from"./vendor-react-BKSb6vFP.js";import{l as t}from"./framework-BL3BtpKU.js";import{Ei as n,It as r,Lt as i,Oc as a,Rt as o,Va as s,ki as c,sr as l,wc as u,zt as d}from"./ui-components-Y3D5-fgK.js";var f=e(),p={config:{icon:c,i18nKey:`config`,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:s,i18nKey:`system`,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:u,i18nKey:`appendOnly`,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:n,i18nKey:`betterAuth`,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 m({managedBy:e,label:n,className:s}){let{t:c}=t();if(!e||e===`platform`)return null;let u=p[e];if(!u)return null;let m=u.icon,h=n??`better-auth`,g=c(`managedByBadge.${u.i18nKey}.short`,{defaultValue:u.short}),_=c(`managedByBadge.${u.i18nKey}.title`,{defaultValue:u.title}),v=c(`managedByBadge.${u.i18nKey}.body`,{defaultValue:u.body(h),provider:h});return(0,f.jsx)(o,{delayDuration:200,children:(0,f.jsxs)(r,{children:[(0,f.jsx)(d,{asChild:!0,children:(0,f.jsxs)(l,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:a(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,u.tone,s),children:[(0,f.jsx)(m,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,f.jsx)(`span`,{children:g})]})}),(0,f.jsxs)(i,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,f.jsx)(`p`,{className:`font-semibold mb-1`,children:_}),(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:v})]})]})})}export{m as t};
|
package/dist/assets/{MarketplaceAccessDenied-YG6RAG6U.js → MarketplaceAccessDenied-B6Tg5g6l.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,m as t,r as n}from"./vendor-react-BKSb6vFP.js";import{g as r}from"./infrastructure-Bc4DRENl.js";import{l as i}from"./framework-DUXRLJaF.js";import{Cr as a,Va as o,nr as s,tr as c}from"./ui-components-t1CVb1Ox.js";var l={cloudUrl:``,singleEnvironment:!1,defaultOrgId:null,defaultEnvironmentId:null,features:{installLocal:!1,marketplace:!0,aiStudio:!0,autoPublishAiBuilds:!0,customDomain:!1,sso:!1},branding:{productName:`ObjectOS`,productShortName:`ObjectOS`,stage:`preview`,brandColor:`#4F46E5`,pwaThemeColor:`#4f46e5`}},u=[`preview`,`beta`,`ga`];function d(e){return typeof e==`string`&&u.includes(e)}var f={...l};function p(e){f={...f,...e,features:{...f.features,...e.features??{}},branding:{...f.branding,...e.branding??{}}}}async function m(e=``){let t=(e||``).replace(/\/+$/,``);try{let e=await fetch(`${t}/api/v1/runtime/config`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json();if(!n||typeof n!=`object`)return;p({cloudUrl:typeof n.cloudUrl==`string`?n.cloudUrl.replace(/\/+$/,``):f.cloudUrl,singleEnvironment:!!n.singleEnvironment,defaultOrgId:n.defaultOrgId??f.defaultOrgId??null,defaultEnvironmentId:n.defaultEnvironmentId??f.defaultEnvironmentId??null,features:n.features?{installLocal:!!n.features.installLocal,marketplace:n.features.marketplace!==!1,aiStudio:n.features.aiStudio!==!1,autoPublishAiBuilds:n.features.autoPublishAiBuilds!==!1,customDomain:n.features.customDomain===!0,sso:n.features.sso===!0}:f.features,branding:n.branding?{productName:typeof n.branding.productName==`string`&&n.branding.productName.trim()?n.branding.productName.trim():f.branding.productName,productShortName:typeof n.branding.productShortName==`string`&&n.branding.productShortName.trim()?n.branding.productShortName.trim():f.branding.productShortName,stage:d(n.branding.stage)?n.branding.stage:f.branding.stage,logoUrl:typeof n.branding.logoUrl==`string`&&n.branding.logoUrl.trim()?n.branding.logoUrl.trim():f.branding.logoUrl,faviconUrl:typeof n.branding.faviconUrl==`string`&&n.branding.faviconUrl.trim()?n.branding.faviconUrl.trim():f.branding.faviconUrl,brandColor:typeof n.branding.brandColor==`string`&&n.branding.brandColor.trim()?n.branding.brandColor.trim():f.branding.brandColor,pwaDescription:typeof n.branding.pwaDescription==`string`&&n.branding.pwaDescription.trim()?n.branding.pwaDescription.trim():f.branding.pwaDescription,pwaThemeColor:typeof n.branding.pwaThemeColor==`string`&&n.branding.pwaThemeColor.trim()?n.branding.pwaThemeColor.trim():f.branding.pwaThemeColor}:f.branding})}catch{}}function h(){return f}function g(){return f.branding?.productName||`ObjectOS`}function _(){return f.branding?.productShortName||g()}function v(){return f.branding?.stage??`preview`}function y(){return f.branding?.brandColor||`#4F46E5`}function b(){return f.branding?.logoUrl}function x(){return f.branding?.faviconUrl}function S(){return f.branding?.pwaDescription||`${g()} — runtime console`}function C(){return f.branding?.pwaThemeColor||y()}function w(){return f.cloudUrl??``}var T=``.replace(/\/$/,``),E=`${T}/api/v1/marketplace`;function D(e){let t=r.get();return t?{...e,Authorization:`Bearer ${t}`}:e}async function O(e,t){let n=await fetch(`${E}${e}`,{credentials:`omit`,headers:{Accept:`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.error?.code??r?.code??`HTTP_${n.status}`,t=r?.error?.message??r?.error??n.statusText,i=Error(typeof t==`string`?t:`${e}`);throw i.code=e,i.status=n.status,i}return r?.data??r}async function k(e={}){let t=new URLSearchParams;e.q&&t.set(`q`,e.q),e.category&&t.set(`category`,e.category),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return O(`/packages${n?`?${n}`:``}`)}async function A(e){return O(`/packages/${encodeURIComponent(e)}`)}async function j(e){if(w()){let t=await fetch(`/api/v1/cloud-connection/install`,{method:`POST`,credentials:`include`,headers:D({Accept:`application/json`,"Content-Type":`application/json`}),body:JSON.stringify({package_id:e.packageId,seed_sample_data:!!e.seedSampleData})}),n=null;try{n=await t.json()}catch{}if(!t.ok||n?.success===!1){let e=n?.error?.code??n?.code??`HTTP_${t.status}`,r=n?.error?.message??n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}let t=await fetch(`${T}/api/v1/actions/sys_package/install_package`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({recordId:e.packageId,params:{environment_id:e.environmentId,seed_sample_data:!!e.seedSampleData}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.code??n?.error?.code??`HTTP_${t.status}`,r=n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function M(){let e=w()||T,t=await fetch(`${e}/api/v1/data/sys_environment?limit=200`,{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=Error(`HTTP_${t.status}`);throw e.status=t.status,e}let n=await t.json().catch(()=>({})),r=n?.records??n?.data??n?.items??n??[];return Array.isArray(r)?r:[]}async function N(){let e=w()||T,t=null;try{let n=await fetch(`${e}/api/v1/auth/get-session`,{credentials:`include`,headers:{Accept:`application/json`}});n.ok&&(t=(await n.json().catch(()=>({})))?.user?.id??null)}catch{}if(!t)return new Set;let n=`${e}/api/v1/data/sys_member?limit=200`,r=null;try{let e=await fetch(n,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return new Set;r=await e.json().catch(()=>({}))}catch{return new Set}let i=r?.records??r?.data??r?.items??r??[];if(!Array.isArray(i))return new Set;let a=new Set;for(let e of i){if(String(e?.user_id??e?.userId??``)!==t)continue;let n=String(e?.role??``).toLowerCase(),r=e?.organization_id??e?.organizationId;r&&(n===`owner`||n===`admin`)&&a.add(String(r))}return a}function P(e){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_package/${encodeURIComponent(e)}`}function F(){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_environment`}async function I(e,t){if(!e)return null;if(w())try{let t=await fetch(`/api/v1/cloud-connection/installation?package_id=${encodeURIComponent(e)}`,{credentials:`include`,headers:D({Accept:`application/json`})});if(!t.ok)return null;let n=await t.json().catch(()=>({})),r=n?.data??n??{};return r.installed?{installationId:String(r.installationId??``),version:String(r.version??`installed`),withSampleData:r.withSampleData===!0}:null}catch{return null}if(!t)return null;let n=T;try{let r=await fetch(`${n}/api/v1/cloud/environments/${encodeURIComponent(t)}/installations/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`}});if(!r.ok)return null;let i=await r.json().catch(()=>({})),a=i?.data??i??{};return a.installed?{installationId:String(a.installationId??``),version:String(a.version??`installed`),withSampleData:a.withSampleData===!0}:null}catch{return null}}async function L(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/reseed-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function R(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/purge-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0,deleted:Number(r?.data?.deleted??0)}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function z(){try{let e=await fetch(`${T}/api/v1/cloud-connection/org-packages`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=Array.isArray(t.items)?t.items:[];return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function B(e){let t=await fetch(`${E}/install-local`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({packageId:e.packageId,...e.versionId?{versionId:e.versionId}:{}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.error?.code??`HTTP_${t.status}`,r=n?.error?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function V(){try{let e=await fetch(`${E}/install-local`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return[];let t=await e.json().catch(()=>({})),n=t?.data?.items??t?.items??[];return Array.isArray(n)?n:[]}catch{return[]}}async function H(){try{let e=await fetch(`${T}/api/v1/cloud-connection/installed`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=(Array.isArray(t.packages)?t.packages:[]).map(e=>{let t=String(e.packageId??e.package_id??``);return{packageId:t,versionId:String(e.package_version_id??``),manifestId:t,version:String(e.version??`installed`),installedAt:String(e.installed_at??e.installedAt??``),installedBy:e.installed_by??e.installedBy??null,withSampleData:e.with_sample_data===!0||e.withSampleData===!0}});return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function U(e){let t=await fetch(`${E}/install-local/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=(await t.json().catch(()=>({})))?.error?.message??t.statusText;throw Error(typeof e==`string`?e:`HTTP_${t.status}`)}}async function W(e,t){let n=await fetch(`${E}/install-local/${encodeURIComponent(e)}/${t===`reseed`?`reseed-sample-data`:`purge-sample-data`}`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`}}),r=await n.json().catch(()=>({}));if(!n.ok){let e=r?.error?.message??n.statusText,t=Error(typeof e==`string`?e:`HTTP_${n.status}`);throw t.code=r?.error?.code??`HTTP_${n.status}`,t}return r?.data??r}function G(e){return W(e,`reseed`)}function K(e){return W(e,`purge`)}var q=n();function J(){let n=e(),{appName:r}=t(),{t:l}=i(),u=r?`/apps/${r}`:`/`;return(0,q.jsx)(`div`,{className:`container mx-auto max-w-2xl px-6 py-16`,children:(0,q.jsx)(c,{children:(0,q.jsxs)(s,{className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,q.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,q.jsx)(o,{className:`h-6 w-6 text-muted-foreground`})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold`,children:l(`marketplace.accessDenied.title`)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l(`marketplace.accessDenied.description`)})]}),(0,q.jsx)(a,{variant:`outline`,onClick:()=>n(u),children:l(`marketplace.action.backHome`)})]})})})}export{g as C,h as D,C as E,m as O,v as S,S as T,L as _,A as a,x as b,M as c,V as d,k as f,G as g,R as h,I as i,N as l,K as m,P as n,B as o,z as p,F as r,j as s,J as t,H as u,U as v,_ as w,b as x,w as y};
|
|
1
|
+
import{f as e,m as t,r as n}from"./vendor-react-BKSb6vFP.js";import{g as r}from"./infrastructure-Bc4DRENl.js";import{l as i}from"./framework-BL3BtpKU.js";import{Cr as a,Va as o,nr as s,tr as c}from"./ui-components-Y3D5-fgK.js";var l={cloudUrl:``,singleEnvironment:!1,defaultOrgId:null,defaultEnvironmentId:null,features:{installLocal:!1,marketplace:!0,aiStudio:!0,autoPublishAiBuilds:!0,customDomain:!1,sso:!1},branding:{productName:`ObjectOS`,productShortName:`ObjectOS`,stage:`preview`,brandColor:`#4F46E5`,pwaThemeColor:`#4f46e5`}},u=[`preview`,`beta`,`ga`];function d(e){return typeof e==`string`&&u.includes(e)}var f={...l};function p(e){f={...f,...e,features:{...f.features,...e.features??{}},branding:{...f.branding,...e.branding??{}}}}async function m(e=``){let t=(e||``).replace(/\/+$/,``);try{let e=await fetch(`${t}/api/v1/runtime/config`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json();if(!n||typeof n!=`object`)return;p({cloudUrl:typeof n.cloudUrl==`string`?n.cloudUrl.replace(/\/+$/,``):f.cloudUrl,singleEnvironment:!!n.singleEnvironment,defaultOrgId:n.defaultOrgId??f.defaultOrgId??null,defaultEnvironmentId:n.defaultEnvironmentId??f.defaultEnvironmentId??null,features:n.features?{installLocal:!!n.features.installLocal,marketplace:n.features.marketplace!==!1,aiStudio:n.features.aiStudio!==!1,autoPublishAiBuilds:n.features.autoPublishAiBuilds!==!1,customDomain:n.features.customDomain===!0,sso:n.features.sso===!0}:f.features,branding:n.branding?{productName:typeof n.branding.productName==`string`&&n.branding.productName.trim()?n.branding.productName.trim():f.branding.productName,productShortName:typeof n.branding.productShortName==`string`&&n.branding.productShortName.trim()?n.branding.productShortName.trim():f.branding.productShortName,stage:d(n.branding.stage)?n.branding.stage:f.branding.stage,logoUrl:typeof n.branding.logoUrl==`string`&&n.branding.logoUrl.trim()?n.branding.logoUrl.trim():f.branding.logoUrl,faviconUrl:typeof n.branding.faviconUrl==`string`&&n.branding.faviconUrl.trim()?n.branding.faviconUrl.trim():f.branding.faviconUrl,brandColor:typeof n.branding.brandColor==`string`&&n.branding.brandColor.trim()?n.branding.brandColor.trim():f.branding.brandColor,pwaDescription:typeof n.branding.pwaDescription==`string`&&n.branding.pwaDescription.trim()?n.branding.pwaDescription.trim():f.branding.pwaDescription,pwaThemeColor:typeof n.branding.pwaThemeColor==`string`&&n.branding.pwaThemeColor.trim()?n.branding.pwaThemeColor.trim():f.branding.pwaThemeColor}:f.branding})}catch{}}function h(){return f}function g(){return f.branding?.productName||`ObjectOS`}function _(){return f.branding?.productShortName||g()}function v(){return f.branding?.stage??`preview`}function y(){return f.branding?.brandColor||`#4F46E5`}function b(){return f.branding?.logoUrl}function x(){return f.branding?.faviconUrl}function S(){return f.branding?.pwaDescription||`${g()} — runtime console`}function C(){return f.branding?.pwaThemeColor||y()}function w(){return f.cloudUrl??``}var T=``.replace(/\/$/,``),E=`${T}/api/v1/marketplace`;function D(e){let t=r.get();return t?{...e,Authorization:`Bearer ${t}`}:e}async function O(e,t){let n=await fetch(`${E}${e}`,{credentials:`omit`,headers:{Accept:`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.error?.code??r?.code??`HTTP_${n.status}`,t=r?.error?.message??r?.error??n.statusText,i=Error(typeof t==`string`?t:`${e}`);throw i.code=e,i.status=n.status,i}return r?.data??r}async function k(e={}){let t=new URLSearchParams;e.q&&t.set(`q`,e.q),e.category&&t.set(`category`,e.category),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return O(`/packages${n?`?${n}`:``}`)}async function A(e){return O(`/packages/${encodeURIComponent(e)}`)}async function j(e){if(w()){let t=await fetch(`/api/v1/cloud-connection/install`,{method:`POST`,credentials:`include`,headers:D({Accept:`application/json`,"Content-Type":`application/json`}),body:JSON.stringify({package_id:e.packageId,seed_sample_data:!!e.seedSampleData})}),n=null;try{n=await t.json()}catch{}if(!t.ok||n?.success===!1){let e=n?.error?.code??n?.code??`HTTP_${t.status}`,r=n?.error?.message??n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}let t=await fetch(`${T}/api/v1/actions/sys_package/install_package`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({recordId:e.packageId,params:{environment_id:e.environmentId,seed_sample_data:!!e.seedSampleData}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.code??n?.error?.code??`HTTP_${t.status}`,r=n?.error??n?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function M(){let e=w()||T,t=await fetch(`${e}/api/v1/data/sys_environment?limit=200`,{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=Error(`HTTP_${t.status}`);throw e.status=t.status,e}let n=await t.json().catch(()=>({})),r=n?.records??n?.data??n?.items??n??[];return Array.isArray(r)?r:[]}async function N(){let e=w()||T,t=null;try{let n=await fetch(`${e}/api/v1/auth/get-session`,{credentials:`include`,headers:{Accept:`application/json`}});n.ok&&(t=(await n.json().catch(()=>({})))?.user?.id??null)}catch{}if(!t)return new Set;let n=`${e}/api/v1/data/sys_member?limit=200`,r=null;try{let e=await fetch(n,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return new Set;r=await e.json().catch(()=>({}))}catch{return new Set}let i=r?.records??r?.data??r?.items??r??[];if(!Array.isArray(i))return new Set;let a=new Set;for(let e of i){if(String(e?.user_id??e?.userId??``)!==t)continue;let n=String(e?.role??``).toLowerCase(),r=e?.organization_id??e?.organizationId;r&&(n===`owner`||n===`admin`)&&a.add(String(r))}return a}function P(e){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_package/${encodeURIComponent(e)}`}function F(){return`${w()||`https://cloud.objectos.app`}/apps/cloud-control/sys_environment`}async function I(e,t){if(!e)return null;if(w())try{let t=await fetch(`/api/v1/cloud-connection/installation?package_id=${encodeURIComponent(e)}`,{credentials:`include`,headers:D({Accept:`application/json`})});if(!t.ok)return null;let n=await t.json().catch(()=>({})),r=n?.data??n??{};return r.installed?{installationId:String(r.installationId??``),version:String(r.version??`installed`),withSampleData:r.withSampleData===!0}:null}catch{return null}if(!t)return null;let n=T;try{let r=await fetch(`${n}/api/v1/cloud/environments/${encodeURIComponent(t)}/installations/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`}});if(!r.ok)return null;let i=await r.json().catch(()=>({})),a=i?.data??i??{};return a.installed?{installationId:String(a.installationId??``),version:String(a.version??`installed`),withSampleData:a.withSampleData===!0}:null}catch{return null}}async function L(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/reseed-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function R(e){if(!e)return{ok:!1,error:`installation id required`};let t=w()||T;try{let n=await fetch(`${t}/api/v1/cloud/installations/${encodeURIComponent(e)}/purge-sample-data`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:`{}`}),r=await n.json().catch(()=>({}));return!n.ok||r?.success===!1?{ok:!1,error:r?.error||`HTTP ${n.status}`}:{ok:!0,deleted:Number(r?.data?.deleted??0)}}catch(e){return{ok:!1,error:e?.message||`Network error`}}}async function z(){try{let e=await fetch(`${T}/api/v1/cloud-connection/org-packages`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=Array.isArray(t.items)?t.items:[];return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function B(e){let t=await fetch(`${E}/install-local`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({packageId:e.packageId,...e.versionId?{versionId:e.versionId}:{}})}),n=null;try{n=await t.json()}catch{}if(!t.ok){let e=n?.error?.code??`HTTP_${t.status}`,r=n?.error?.message??t.statusText,i=Error(typeof r==`string`?r:`${e}`);throw i.code=e,i.status=t.status,i}return n?.data??n}async function V(){try{let e=await fetch(`${E}/install-local`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return[];let t=await e.json().catch(()=>({})),n=t?.data?.items??t?.items??[];return Array.isArray(n)?n:[]}catch{return[]}}async function H(){try{let e=await fetch(`${T}/api/v1/cloud-connection/installed`,{credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return{connected:!1,items:[]};let t=(await e.json().catch(()=>({})))?.data??{},n=(Array.isArray(t.packages)?t.packages:[]).map(e=>{let t=String(e.packageId??e.package_id??``);return{packageId:t,versionId:String(e.package_version_id??``),manifestId:t,version:String(e.version??`installed`),installedAt:String(e.installed_at??e.installedAt??``),installedBy:e.installed_by??e.installedBy??null,withSampleData:e.with_sample_data===!0||e.withSampleData===!0}});return{connected:t.connected===!0,items:n}}catch{return{connected:!1,items:[]}}}async function U(e){let t=await fetch(`${E}/install-local/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok){let e=(await t.json().catch(()=>({})))?.error?.message??t.statusText;throw Error(typeof e==`string`?e:`HTTP_${t.status}`)}}async function W(e,t){let n=await fetch(`${E}/install-local/${encodeURIComponent(e)}/${t===`reseed`?`reseed-sample-data`:`purge-sample-data`}`,{method:`POST`,credentials:`include`,headers:{Accept:`application/json`}}),r=await n.json().catch(()=>({}));if(!n.ok){let e=r?.error?.message??n.statusText,t=Error(typeof e==`string`?e:`HTTP_${n.status}`);throw t.code=r?.error?.code??`HTTP_${n.status}`,t}return r?.data??r}function G(e){return W(e,`reseed`)}function K(e){return W(e,`purge`)}var q=n();function J(){let n=e(),{appName:r}=t(),{t:l}=i(),u=r?`/apps/${r}`:`/`;return(0,q.jsx)(`div`,{className:`container mx-auto max-w-2xl px-6 py-16`,children:(0,q.jsx)(c,{children:(0,q.jsxs)(s,{className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,q.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,q.jsx)(o,{className:`h-6 w-6 text-muted-foreground`})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-lg font-semibold`,children:l(`marketplace.accessDenied.title`)}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l(`marketplace.accessDenied.description`)})]}),(0,q.jsx)(a,{variant:`outline`,onClick:()=>n(u),children:l(`marketplace.action.backHome`)})]})})})}export{g as C,h as D,C as E,m as O,v as S,S as T,L as _,A as a,x as b,M as c,V as d,k as f,G as g,R as h,I as i,N as l,K as m,P as n,B as o,z as p,F as r,j as s,J as t,H as u,U as v,_ as w,b as x,w as y};
|
package/dist/assets/{MarketplaceInstalledPage-BFESaZWD.js → MarketplaceInstalledPage-DBmVXCVz.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o}from"./infrastructure-Bc4DRENl.js";import{Yt as s,l as c}from"./framework-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o}from"./infrastructure-Bc4DRENl.js";import{Yt as s,l as c}from"./framework-BL3BtpKU.js";import{Bt as l,Cr as u,Gi as d,Ns as f,Sc as p,Yo as m,Yr as h,ar as g,ci as _,ir as v,nr as y,sr as b,tr as x}from"./ui-components-Y3D5-fgK.js";import{d as S,t as C,u as w,v as T}from"./MarketplaceAccessDenied-B6Tg5g6l.js";var E=e(a(),1),D=i();function O(){let e=n(),{appName:t}=r(),i=o(),{t:a,language:s}=c(),p=t?`/apps/${t}`:``,[_,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 w();e.connected?(A(`cloud`),O(e.items)):(A(`local`),O(await S()))}finally{M(!1)}};(0,E.useEffect)(()=>{L()},[]);let R=async e=>{if(confirm(a(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await T(e.manifestId),I({ok:!0,message:a(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return i?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`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)(f,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&_.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(l,{className:`h-20 w-full`},t))}):_.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:a(`marketplace.installedEmpty`)}),(0,D.jsx)(u,{variant:`link`,className:`mt-2`,onClick:()=>e(`${p}/system/marketplace`),children:a(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:_.map(t=>(0,D.jsxs)(x,{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)(g,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(b,{variant:`outline`,children:a(`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:a(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:a(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[a(`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)(u,{variant:`ghost`,size:`sm`,onClick:()=>e(`${p}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(m,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(u,{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?a(`marketplace.action.uninstalling`):a(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(y,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:a(`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:a(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(C,{})}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=n(),{appName:t}=r(),{t:i}=c(),a=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)(u,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${a}/system/marketplace`),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(_,{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:i(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:i(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
|
package/dist/assets/{MarketplacePackagePage-Vy7JiFQ0.js → MarketplacePackagePage-Mt1pHE8U.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o,g as s}from"./infrastructure-Bc4DRENl.js";import{R as ee,l as c}from"./framework-
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o,g as s}from"./infrastructure-Bc4DRENl.js";import{R as ee,l as c}from"./framework-BL3BtpKU.js";import{$o as te,As as l,Bt as u,Cn as ne,Cr as d,Ei as re,Gn as ie,Ha as f,Jn as ae,Jt as oe,Kn as se,Ms as ce,Ns as p,Oc as m,Oo as h,Pr as g,Qt as le,Sc as ue,Ti as _,Xn as de,Xo as fe,Xt as pe,Yn as me,Yo as he,Yr as ge,Yt as _e,Zt as ve,_n as v,ac as ye,ar as be,ds as xe,er as Se,hn as Ce,ir as we,mn as Te,nr as Ee,pn as y,qn as De,rs as Oe,sr as b,tr as ke,wi as x,xa as Ae,ya as je}from"./ui-components-Y3D5-fgK.js";import{r as S}from"./vendor-ui-utils-D-WJ115h.js";import"./MetadataProvider-DqPZ6rV2.js";import{t as Me}from"./assistantBus-CbDb2Mju.js";import{D as C,_ as Ne,a as Pe,c as Fe,d as Ie,g as Le,h as Re,i as ze,l as Be,m as Ve,n as He,o as Ue,s as We,t as Ge,v as Ke}from"./MarketplaceAccessDenied-B6Tg5g6l.js";import{n as qe,t as Je}from"./usePackageL10n-DfeTyD2w.js";var w=e(a(),1),T=i();function Ye(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,T.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,T.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,T.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,T.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,T.jsx)(T.Fragment,{children:t.map((e,t)=>(0,T.jsx)(w.Fragment,{children:e},t))})}function Xe({source:e,className:t}){let n=Ye(e);return(0,T.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,T.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:E(e.text??``)},t);case`h2`:return(0,T.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:E(e.text??``)},t);case`h3`:return(0,T.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:E(e.text??``)},t);case`p`:return(0,T.jsx)(`p`,{children:E(e.text??``)},t);case`ul`:return(0,T.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,T.jsxs)(`li`,{className:`flex gap-2`,children:[(0,T.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,T.jsx)(`span`,{children:E(e)})]},t))},t);case`ol`:return(0,T.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,T.jsx)(`li`,{className:`pl-1`,children:E(e)},t))},t);case`code`:return(0,T.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,T.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var Ze={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function D({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,T.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}=c();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,T.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,T.jsx)(xe,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,T.jsx)(b,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:Ze[e.runtime]??e.runtime})}),e.platform_verified?(0,T.jsxs)(b,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,T.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,T.jsxs)(b,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,T.jsx)(re,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,T.jsxs)(b,{variant:`outline`,className:`gap-1`,children:[(0,T.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,T.jsx)(D,{icon:ye,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,T.jsx)(D,{icon:g,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,T.jsx)(D,{icon:Ae,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,T.jsx)(D,{icon:h,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var O=`${``.replace(/\/$/,``)}/api/v1/security/suggested-bindings`;function k(e={}){let t={Accept:`application/json`,...e},n=s.get();return n?{...t,Authorization:`Bearer ${n}`}:t}async function A(e){let t=null;try{t=await e.json()}catch{}if(!e.ok){let n=t?.error?.code??`HTTP_${e.status}`,r=t?.error?.message??t?.error??e.statusText,i=Error(typeof r==`string`?r:String(n));throw i.code=n,i.status=e.status,i}return t?.data??t}async function j(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.packageId&&t.set(`packageId`,e.packageId);let n=t.toString(),r=await A(await fetch(`${O}${n?`?${n}`:``}`,{credentials:`include`,headers:k()}));return Array.isArray(r?.suggestions)?r.suggestions:[]}async function M(e){return(await A(await fetch(`${O}/${encodeURIComponent(e)}/confirm`,{method:`POST`,credentials:`include`,headers:k({"Content-Type":`application/json`})})))?.suggestion}async function N(e){return(await A(await fetch(`${O}/${encodeURIComponent(e)}/dismiss`,{method:`POST`,credentials:`include`,headers:k({"Content-Type":`application/json`})})))?.suggestion}function P({packageId:e,strings:t,className:n,onResolved:r}){let[i,a]=(0,w.useState)([]),[o,s]=(0,w.useState)(null),ee=(0,w.useCallback)(()=>{let t=!1;return j({status:`pending`,...e?{packageId:e}:{}}).then(e=>{t||a(e)}).catch(()=>{}),()=>{t=!0}},[e]);(0,w.useEffect)(()=>ee(),[ee]);let c=async(e,n)=>{s(e.id);try{let i=n===`confirm`?await M(e.id):await N(e.id);a(t=>t.filter(t=>t.id!==e.id)),S.success(n===`confirm`?t.confirmedToast(e):t.dismissedToast(e)),r?.(i??e)}catch(e){S.error(e?.message??String(e))}finally{s(null)}};return i.length===0?null:(0,T.jsx)(`div`,{"data-testid":`suggested-bindings-panel`,className:m(`rounded-lg border border-amber-300/60 dark:border-amber-700/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2 space-y-2`,n),children:i.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(x,{className:`h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,T.jsx)(`p`,{className:`flex-1 min-w-0 text-sm text-amber-900 dark:text-amber-200`,children:t.describe(e)}),(0,T.jsx)(d,{size:`sm`,disabled:o===e.id,onClick:()=>c(e,`confirm`),"data-testid":`suggested-binding-confirm-${e.permission_set_name}`,children:o===e.id?t.confirming:t.confirm}),(0,T.jsx)(d,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>c(e,`dismiss`),"data-testid":`suggested-binding-dismiss-${e.permission_set_name}`,children:t.dismiss})]},e.id))})}var $e=t({MarketplacePackagePage:()=>F});function F(){let e=n(),{packageId:t,appName:i}=r(),a=o(),{t:s,language:re}=c(),m={describe:e=>s(e.anchor===`guest`?`marketplace.suggestedBindings.promptGuest`:`marketplace.suggestedBindings.promptEveryone`,{set:e.permission_set_name}),confirm:s(`marketplace.suggestedBindings.confirm`),confirming:s(`marketplace.suggestedBindings.confirming`),dismiss:s(`marketplace.suggestedBindings.dismiss`),confirmedToast:e=>s(`marketplace.suggestedBindings.confirmedToast`,{set:e.permission_set_name,anchor:e.anchor}),dismissedToast:e=>s(`marketplace.suggestedBindings.dismissedToast`,{set:e.permission_set_name})},h=i?`/apps/${i}`:``,{refresh:g}=ee(),[_,ye]=(0,w.useState)(null),[xe,x]=(0,w.useState)(!0),[Ae,S]=(0,w.useState)(null),[Ye,E]=(0,w.useState)(!1),[Ze,D]=(0,w.useState)([]),[O,k]=(0,w.useState)(!1),[A,j]=(0,w.useState)(null),[M,N]=(0,w.useState)(``),[$e,F]=(0,w.useState)({}),[I,et]=(0,w.useState)(!1),[tt,nt]=(0,w.useState)(!1),[L,rt]=(0,w.useState)(!1),[R,z]=(0,w.useState)(null),[B,it]=(0,w.useState)(null),[V,H]=(0,w.useState)(null),[U,W]=(0,w.useState)(null),[G,K]=(0,w.useState)(null),[at,ot]=(0,w.useState)([]),[st,q]=(0,w.useState)(!1),[J,Y]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!C().features.installLocal)return;let e=!1;return(async()=>{let t=await Ie();e||ot(t)})(),()=>{e=!0}},[t,J]),(0,w.useEffect)(()=>{if(!t)return;let e=C().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await ze(t,e);n||!r||(H(r),it(r.version))})(),()=>{n=!0}},[t]),(0,w.useEffect)(()=>{let e=!1;return(async()=>{if(t){x(!0),S(null);try{let n=await Pe(t);e||ye(n)}catch(t){e||S(t?.message??String(t))}finally{e||x(!1)}}})(),()=>{e=!0}},[t]);let ct=async()=>{E(!0),z(null),j(null);let e=C().defaultEnvironmentId;if(e){k(!1),N(e),D([]);return}k(!0);try{let[e,n]=await Promise.all([Fe(),Be()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});D(r),F({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await ze(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]);F(t)}),e.length>0&&r.length===0?j(s(`marketplace.install.noPermission`)):r.length===1&&N(r[0].id)}catch(e){let t=e?.status;j(t===401||t===403?s(`marketplace.install.signInFirst`):e?.message??String(e))}finally{k(!1)}},lt=async()=>{if(!(!t||!M)){rt(!0),z(null);try{let e=(await We({packageId:t,environmentId:M,seedSampleData:I}))?.installation?.version??_?.package?.latest_version?.version??_?.versions?.[0]?.version??``;it(e||`installed`);try{let e=C().defaultEnvironmentId||M;if(e){let n=await ze(t,e);n&&H(n)}}catch{}let n=C().defaultEnvironmentId;if(!n||n===M)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await g()}catch{}z({ok:!0,message:s(`marketplace.install.success`)}),Me()}catch(e){z({ok:!1,message:e?.message??String(e)})}finally{rt(!1)}}},ut=async()=>{if(t){q(!0),Y(null);try{let e=await Ue({packageId:t});try{await g(`app`)}catch{}Y({ok:!0,message:s(`marketplace.install.localSuccess`,{version:e.version,name:_?.package?Je(_.package,re).displayName:e.manifestId})}),Me()}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=s(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=s(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=s(`marketplace.install.localMarketplaceUnavailable`)),Y({ok:!1,message:n})}finally{q(!1)}}},dt=async()=>{if($&&confirm(s(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){q(!0),Y(null);try{await Ke($.manifestId);try{await g(`app`)}catch{}Y({ok:!0,message:s(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){Y({ok:!1,message:e?.message??String(e)})}finally{q(!1)}}},ft=async()=>{if(V){W(`reseed`),K(null);try{let e=await Ne(V.installationId);e.ok?(H({...V,withSampleData:!0}),K({ok:!0,text:s(`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)}}},pt=async()=>{if(V&&confirm(s(`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 Re(V.installationId);if(e.ok){H({...V,withSampleData:!1});let t=e.deleted??0;K({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else K({ok:!1,text:e.error||`Purge failed`})}finally{W(null)}}},mt=async()=>{if($){W(`reseed`),K(null);try{let e=await Le($.manifestId);ot(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=s(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`;K(r>0?{ok:!1,text:`${i} ${s(`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)}}},ht=async()=>{if($&&confirm(s(`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 Ve($.manifestId);ot(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;K({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){K({ok:!1,text:e?.message||`Purge failed`})}finally{W(null)}}};if(xe)return(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsx)(u,{className:`h-8 w-32`}),(0,T.jsx)(u,{className:`h-16 w-full`}),(0,T.jsx)(u,{className:`h-64 w-full`})]});if(Ae||!_)return(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>e(`${h}/system/marketplace`),children:[(0,T.jsx)(ue,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,T.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`font-medium text-destructive`,children:s(`marketplace.load.packageFailed`)}),(0,T.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:Ae??s(`marketplace.load.notFound`)})]})]})]});let X=_.package,Z=Je(X,re),Q=X.latest_version?.version??_.versions[0]?.version??null,$=at.find(e=>e.manifestId===X.manifest_id)??null,gt=!!X.latest_version?.contains_code,_t=!!B&&B!==`installed`&&!!Q&&B!==Q,vt=C().features.installLocal,yt=!Q||st||L||!vt&&!!B&&!_t,bt=vt?{label:s(st?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:ut}:{label:L?s(`marketplace.action.installing`):B?_t?s(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Q}):s(`marketplace.action.installed`,{defaultValue:`Installed`}):s(`marketplace.action.installToCloud`),onClick:ct},xt=X.category?s(`marketplace.category.${X.category}`,{defaultValue:X.category}):null;return a?(0,T.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,T.jsxs)(d,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${h}/system/marketplace`),children:[(0,T.jsx)(ue,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,T.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,T.jsx)(qe,{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,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,T.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Z.displayName||X.manifest_id}),X.homepage_url&&(0,T.jsxs)(`a`,{href:X.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:s(`marketplace.detail.homepage`),children:[(0,T.jsx)(he,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:s(`marketplace.detail.homepage`)})]})]}),(0,T.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,T.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:X.manifest_id}),Q&&(0,T.jsx)(b,{variant:`outline`,children:s(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,T.jsx)(b,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),xt&&(0,T.jsx)(b,{variant:`outline`,children:xt}),X.license&&(0,T.jsx)(b,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,T.jsxs)(b,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,T.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:$.version})]}),!$&&B&&(0,T.jsxs)(b,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,T.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:B})]}),_t&&(0,T.jsxs)(b,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,T.jsx)(ce,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Q]})]}),Z.description&&(0,T.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Z.description})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,T.jsxs)(d,{onClick:bt.onClick,disabled:yt,size:`lg`,className:`min-w-[8rem]`,children:[(0,T.jsx)(te,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),bt.label]}),$&&(0,T.jsxs)(Te,{children:[(0,T.jsx)(ne,{asChild:!0,children:(0,T.jsx)(d,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`),children:(0,T.jsx)(fe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,T.jsxs)(Ce,{align:`end`,className:`w-56`,children:[(0,T.jsxs)(v,{onSelect:mt,disabled:U!==null,children:[U===`reseed`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(Oe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,T.jsxs)(v,{onSelect:ht,disabled:U!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[U===`purge`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(ge,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,T.jsxs)(v,{onSelect:dt,disabled:st,className:`text-destructive focus:text-destructive`,children:[(0,T.jsx)(ge,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&V&&!C().cloudUrl&&(0,T.jsxs)(Te,{children:[(0,T.jsx)(ne,{asChild:!0,children:(0,T.jsx)(d,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`)||`More options`,children:(0,T.jsx)(fe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,T.jsxs)(Ce,{align:`end`,className:`w-56`,children:[(0,T.jsxs)(v,{onSelect:ft,disabled:U!==null,children:[U===`reseed`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(Oe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),V.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,T.jsxs)(v,{onSelect:pt,disabled:U!==null||!V.withSampleData,className:`text-destructive focus:text-destructive`,children:[U===`purge`?(0,T.jsx)(f,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,T.jsx)(ge,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),G&&(0,T.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,T.jsx)(l,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,T.jsx)(`div`,{className:`flex-1`,children:G.text}),(0,T.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>K(null),children:s(`marketplace.action.dismiss`)})]}),J&&(0,T.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,T.jsx)(l,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,T.jsxs)(`div`,{className:`flex-1`,children:[J.message,J.ok&&(0,T.jsx)(P,{packageId:X.manifest_id,strings:m,className:`mt-2`})]}),(0,T.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>Y(null),children:s(`marketplace.action.dismiss`)})]}),(0,T.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,T.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,T.jsxs)(ke,{children:[(0,T.jsx)(we,{children:(0,T.jsx)(be,{className:`text-base`,children:s(`marketplace.detail.about`)})}),(0,T.jsx)(Ee,{children:Z.readme?(0,T.jsx)(Xe,{source:Z.readme}):(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noReadme`)})})]})}),(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsxs)(ke,{children:[(0,T.jsx)(we,{children:(0,T.jsx)(be,{className:`text-base`,children:s(`marketplace.detail.versions`)})}),(0,T.jsx)(Ee,{children:_.versions.length===0?(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noApprovedVersions`)}):(0,T.jsx)(`ul`,{className:`space-y-3`,children:_.versions.map(e=>(0,T.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,T.jsx)(je,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,T.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,T.jsx)(b,{variant:`outline`,className:`text-xs`,children:s(`marketplace.detail.prerelease`)})]}),(0,T.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,T.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,T.jsx)(ie,{open:Ye,onOpenChange:e=>{E(e),e||(z(null),nt(!1))},children:(0,T.jsxs)(se,{children:[(0,T.jsxs)(me,{children:[(0,T.jsx)(de,{children:s(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,T.jsx)(De,{children:C().defaultEnvironmentId?s(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):s(`marketplace.install.dialogDescPicker`)})]}),O?(0,T.jsx)(u,{className:`h-10 w-full`}):A?(0,T.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(p,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,T.jsx)(`div`,{className:`flex-1`,children:A})]}),(0,T.jsx)(`a`,{href:He(X.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,T.jsxs)(d,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,T.jsx)(he,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.action.openOnCloud`)]})})]}):C().defaultEnvironmentId?(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Se,{id:`seed`,checked:I,onCheckedChange:e=>et(e===!0)}),(0,T.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]}):Ze.length===0?(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.install.noEnvs`)}):(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{htmlFor:`env-select`,children:s(`marketplace.install.environment`)}),(0,T.jsxs)(oe,{value:M,onValueChange:N,children:[(0,T.jsx)(ve,{id:`env-select`,children:(0,T.jsx)(le,{placeholder:s(`marketplace.install.environmentPlaceholder`)})}),(0,T.jsx)(_e,{children:Ze.map(e=>{let t=$e[e.id],n=!!t&&!!Q&&t!==`installed`&&t!==Q;return(0,T.jsxs)(pe,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,T.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,s(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Q})]}):(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,s(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(Se,{id:`seed`,checked:I,onCheckedChange:e=>et(e===!0)}),(0,T.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]})]}),gt&&!A&&(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(Qe,{version:X.latest_version}),(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(Se,{id:`ack-perms`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,T.jsx)(y,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:s(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),R&&(0,T.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}),R?.ok===!0&&C().defaultEnvironmentId&&C().defaultEnvironmentId===M&&(0,T.jsx)(P,{packageId:X.manifest_id,strings:m}),(0,T.jsxs)(ae,{children:[(0,T.jsx)(d,{variant:`outline`,onClick:()=>E(!1),children:s(`marketplace.action.close`)}),!A&&(0,T.jsx)(d,{onClick:lt,disabled:!M||L||R?.ok===!0||gt&&!tt,children:s(L?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,T.jsx)(Ge,{})}export{P as n,$e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o}from"./infrastructure-Bc4DRENl.js";import{l as s}from"./framework-DUXRLJaF.js";import{As as c,Bt as l,Cr as u,Gi as ee,Ns as te,Oi as d,ar as f,ci as p,ir as m,ji as ne,ln as h,nr as g,rr as _,sr as v,tr as y,ya as b}from"./ui-components-t1CVb1Ox.js";import{t as re}from"./assistantBus-CbDb2Mju.js";import{D as ie,d as x,f as ae,o as oe,p as S,s as C,t as se,u as ce}from"./MarketplaceAccessDenied-YG6RAG6U.js";import{n as w,t as T}from"./usePackageL10n-DfeTyD2w.js";var E=t({MarketplacePage:()=>A}),D=e(a(),1),O=i();function k(){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=n(),{appName:t}=r(),i=o(),{t:a,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[ue,Y]=(0,D.useState)(new Set),de=(0,D.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([ae({limit:100}),x(),S(),ce()]);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);Y(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{ie().features.installLocal?await oe({packageId:e.manifest_id||e.id,versionId:`latest`}):await C({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:a(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),re()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.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=a(t,{defaultValue:e});return n===t?e:n},$=(0,D.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,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return i?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:a(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:a(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?a(`marketplace.installedCount`,{count:H.length}):a(`marketplace.installed`)]}),(0,O.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(ne,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(h,{value:R,onChange:e=>z(e.target.value),placeholder:a(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":a(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(u,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:a(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(u,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(te,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:a(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:a(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:a(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(v,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.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,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=ue.has(e.manifest_id);return(0,O.jsxs)(y,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(_,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(v,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(g,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(c,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(u,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?a(`marketplace.org.installing`,{defaultValue:`Installing…`}):a(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(y,{children:[(0,O.jsxs)(m,{className:`pb-2`,children:[(0,O.jsx)(l,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(l,{className:`h-5 w-3/4`}),(0,O.jsx)(l,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(g,{children:(0,O.jsx)(l,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?a(`marketplace.noApprovedYet`):a(`marketplace.noMatchFilters`)}):(0,O.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,E);return(0,O.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,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(_,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(v,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(g,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(c,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(v,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(se,{})}export{E as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as o}from"./infrastructure-Bc4DRENl.js";import{l as s}from"./framework-BL3BtpKU.js";import{As as c,Bt as l,Cr as u,Gi as ee,Ns as te,Oi as d,ar as f,ci as p,ir as m,ji as ne,ln as h,nr as g,rr as _,sr as v,tr as y,ya as b}from"./ui-components-Y3D5-fgK.js";import{t as re}from"./assistantBus-CbDb2Mju.js";import{D as ie,d as x,f as ae,o as oe,p as S,s as C,t as se,u as ce}from"./MarketplaceAccessDenied-B6Tg5g6l.js";import{n as w,t as T}from"./usePackageL10n-DfeTyD2w.js";var E=t({MarketplacePage:()=>A}),D=e(a(),1),O=i();function k(){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=n(),{appName:t}=r(),i=o(),{t:a,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[ue,Y]=(0,D.useState)(new Set),de=(0,D.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([ae({limit:100}),x(),S(),ce()]);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);Y(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{ie().features.installLocal?await oe({packageId:e.manifest_id||e.id,versionId:`latest`}):await C({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:a(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),re()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.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=a(t,{defaultValue:e});return n===t?e:n},$=(0,D.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,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return i?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:a(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:a(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?a(`marketplace.installedCount`,{count:H.length}):a(`marketplace.installed`)]}),(0,O.jsxs)(u,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(ne,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(h,{value:R,onChange:e=>z(e.target.value),placeholder:a(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":a(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(u,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:a(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(u,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(te,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:a(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:a(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(p,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:a(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(v,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.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,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=ue.has(e.manifest_id);return(0,O.jsxs)(y,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(_,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(v,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(g,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(c,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(u,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?a(`marketplace.org.installing`,{defaultValue:`Installing…`}):a(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(y,{children:[(0,O.jsxs)(m,{className:`pb-2`,children:[(0,O.jsx)(l,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(l,{className:`h-5 w-3/4`}),(0,O.jsx)(l,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(g,{children:(0,O.jsx)(l,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?a(`marketplace.noApprovedYet`):a(`marketplace.noMatchFilters`)}):(0,O.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,E);return(0,O.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,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(f,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(_,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(v,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(g,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(c,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(v,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(se,{})}export{E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{kt as r,l as i}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{kt as r,l as i}from"./framework-BL3BtpKU.js";import{Bs as a,Hs as o,ss as s,zs as c}from"./ui-components-Y3D5-fgK.js";var l=e(n(),1),u=t();function d({sections:e,open:t}){if(!t)return null;let{t:n}=i(),[r,d]=(0,l.useState)([`0`]),[f,p]=(0,l.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=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,u.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,u.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,u.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,u.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let i=String(t),l=r.includes(i),d=f===t;return(0,u.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,u.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,u.jsxs)(`button`,{onClick:()=>h(i),className:`flex-1 flex items-center justify-between text-left`,children:[(0,u.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,u.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,u.jsx)(c,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,u.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:d?(0,u.jsx)(o,{className:`h-3 w-3 text-green-600`}):(0,u.jsx)(s,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,u.jsx)(`div`,{className:`px-4 pb-4`,children:(0,u.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,u.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 f(){let[e,t]=(0,l.useState)((0,l.useMemo)(()=>{try{return typeof window<`u`&&r(window.location.search).enabled}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{f as n,d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{d as t,f as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{h as a}from"./infrastructure-Bc4DRENl.js";import{I as o}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{d as t,f as n,r,y as i}from"./vendor-react-BKSb6vFP.js";import{h as a}from"./infrastructure-Bc4DRENl.js";import{I as o}from"./framework-BL3BtpKU.js";import{n as s}from"./data-adapter-Mo_lVy1U.js";import{i as c}from"./plugin-form-6ug8Woph.js";import{i as l,r as u}from"./assistantBus-CbDb2Mju.js";var d=e(i(),1),f=r(),p=(0,d.createContext)(!1),m=`preview`,h=`draft`;function g(e){return new URLSearchParams(e).get(m)===h}var _=!1;function v(){_=!0}function y({force:e,children:r}){let i=t(),a=n(),o=(0,d.useMemo)(()=>g(i.search),[i.search]),[s,c]=(0,d.useState)(o);return(0,d.useEffect)(()=>{if(o){c(!0),_=!1;return}if(!s)return;if(_){_=!1,c(!1);return}let e=new URLSearchParams(i.search);e.set(m,h),a(`${i.pathname}?${e.toString()}${i.hash}`,{replace:!0})},[o,s,i.pathname,i.search,i.hash,a]),(0,f.jsx)(p.Provider,{value:e??(o||s),children:r})}function b(){return(0,d.useContext)(p)}var x=a();function S(){return``}function C(e={}){let{previewDrafts:t=!1,environmentId:n}=e,r=new s({baseUrl:S(),previewDrafts:t,fetch:x});return n?r.withEnvironment(n):r}var w=300*1e3,T=[`app`,`view`],E={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},D=`objectui:metadata:`;function O(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var k=O();function A(...e){k&&console.debug(`[MetadataProvider]`,...e)}function j(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function M(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function N(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function P(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function F(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)P(e)&&r.add(e.object);for(let e of t){if(P(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 I(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:c(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 L(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function R(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(D+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function z(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(D+e,JSON.stringify(t))}catch{}}function B({children:e,adapter:t,ttlMs:n=w}){let r=(0,d.useRef)(new Map),i=(0,d.useRef)(new Map),a=(0,d.useRef)(t);a.current=t;let s=b(),c=(0,d.useMemo)(()=>s?C({previewDrafts:!0}):null,[s]),p=(0,d.useRef)(c);p.current=c;let[m,h]=(0,d.useState)(0),g=(0,d.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>h(e=>e+1)):Promise.resolve().then(()=>h(e=>e+1))},[]);(0,d.useEffect)(()=>{r.current.clear(),i.current.clear(),g()},[s,g]);let _=(0,d.useCallback)(e=>{let t=r.current.get(e);return t||(t=L(),r.current.set(e,t)),t},[]),v=(0,d.useCallback)(e=>{let t=_(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return A(`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=p.current,o=(i?i.list(e):a.current.getClient().meta.getItems(e)).then(n=>{let a=j(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)N(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&z(e,a),A(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),g(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,A(`fetch failed type=${e}`,r),g(),[]});return t.promise=o,o},[g,_,n]),y=(0,d.useCallback)((e,t)=>{let n=_(e);if(n.byName.has(t))return A(`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 o=r.get(t);if(o)return o;let s=Date.now(),c=p.current,l=(c?c.get(e,t):a.current.getClient().meta.getItem(e,t)).then(i=>{let a=M(i);return a&&n.byName.set(t,a),A(`fetched item type=${e} name=${t} in ${Date.now()-s}ms`),r.delete(t),a}).catch(n=>(r.delete(t),A(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[_]),x=(0,d.useCallback)(async e=>{if(e){let t=_(e);t.fetchedAt=0,t.byName.clear(),await v(e);return}let t=Array.from(r.current.keys()).filter(e=>r.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=r.current.get(e);return t.fetchedAt=0,t.byName.clear(),v(e)}))},[v,_]),S=(0,d.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),A(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,A(`invalidated type=${e}`)),g())},[g]);(0,d.useEffect)(()=>{if(s)return u(({type:e})=>{S(e)})},[s,S]),(0,d.useEffect)(()=>l(()=>{try{a.current?.clearCache?.()}catch{}x()}),[x]);let[D,O]=(0,d.useState)(!0),[k,P]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=!1,t=s?null:R(`app`);if(t){let e=_(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)N(n)&&e.byName.set(n.name,n);g(),O(!1)}return(async()=>{for(let t of T)try{await v(t),e||P(null)}catch(t){e||P(t instanceof Error?t:Error(String(t)))}e||O(!1)})(),()=>{e=!0}},[t,v,_,g,s]);let B=(0,d.useMemo)(()=>{let e=e=>{let t=_(e);return t.status===`idle`&&v(e),t.items};return{apps:_(`app`).items,get objects(){let t=e(E.objects),n=e(`view`);return I(n.length?F(t,n):t)},get dashboards(){return e(E.dashboards)},get reports(){return e(E.reports)},get pages(){return e(E.pages)},loading:D,error:k??_(`app`).error,refresh:x,invalidate:S,ensureType:v,getItem:y,getItemsByType:t=>e(t),getTypeStatus:e=>_(e).status}},[m,D,k,v,y,_,x,S]);return(0,f.jsx)(o.Provider,{value:B,children:e})}export{v as a,y as i,C as n,b as o,m as r,B as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as ee,n as o,p as s,t as c}from"./infrastructure-Bc4DRENl.js";import{l,q as u}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{f as ee,n as o,p as s,t as c}from"./infrastructure-Bc4DRENl.js";import{l,q as u}from"./framework-BL3BtpKU.js";import{Ar as te,Cr as d,K as f,Pc as p,Pi as ne,Qi as re,U as ie,Va as ae,X as m,q as h,rs as g}from"./ui-components-Y3D5-fgK.js";import{t as oe}from"./RecordDetailView-w6IBQ1cm.js";import{t as _}from"./getIcon-BZsP3YSU.js";import{r as v}from"./useMetadata-D5f_5ULL.js";import{n as y,t as b}from"./CreateViewDialog-DcjN_AhY.js";import{a as x,i as S,n as se,o as ce,r as le,s as ue}from"./InterfaceListPage-Ca4VNsGg.js";import{l as de}from"./plugins-views-CoobEMX4.js";import{t as fe}from"./runtime-metadata-persistence-D1KKivGr.js";var C=e(a(),1),w=i();function pe(e){let t=[];return e.forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.push([r[1],`=`,e])}),t}var T=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),E=4;function D({dataSource:e,objects:i}){let{appName:a,objectName:D}=r(),{t:O}=l(),{objectLabel:k,fieldLabel:A}=p(),j=t(),[M,N]=n(),{can:P}=o(),{canRead:F}=c(D??``),{user:I}=s(),L=ee(),R=v(),[z,B]=C.useState(!1),V=C.useMemo(()=>(i||[]).find(e=>e.name===D),[i,D]),[me]=C.useState(()=>ue(new URLSearchParams(window.location.search))),he=C.useCallback(e=>{N(t=>ce(t,e),{replace:!0})},[N]),H=Array.from(M.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),U=C.useMemo(()=>{let e=pe(new URLSearchParams(H)),t=e.filter(([e])=>F(e));if(t.length<e.length){let t=e.filter(([e])=>!F(e)).map(([e])=>e);console.warn(`[ObjectDataPage] Dropped URL filter(s) on unreadable field(s): ${t.join(`, `)}`)}return t.map(([e,t,n])=>n===`{current_user_id}`?[e,t,I?.id??n]:[e,t,n])},[H,F,I?.id]),ge=C.useCallback(e=>{N(t=>{let n=new URLSearchParams(t);return n.delete(`filter[${e}]`),n})},[N]),W=C.useMemo(()=>le(V).filter(e=>F(e)),[V,F]),G=C.useMemo(()=>{let e=V?.fields;if(!e||typeof e!=`object`)return;let t=Object.entries(e).filter(([e,t])=>t&&!t.hidden&&T.has(t.type)&&F(e)).slice(0,E).map(([e])=>({field:e}));return t.length>0?{element:`dropdown`,fields:t}:void 0},[V,F]),K=C.useCallback(e=>`/apps/${a}/${D}/record/${encodeURIComponent(String(e))}`,[a,D]),q=u({navigation:{mode:`drawer`},objectName:D??``,onNavigate:e=>j(K(e))}),J=M.get(`recordId`),_e=C.useCallback((e,t)=>{let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(K(n),`_blank`);return}n!=null&&N(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t})},[K,N]),ve=C.useCallback(()=>{N(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[N]);C.useEffect(()=>{J&&!q.isOpen?q.open({id:J}):!J&&q.isOpen&&q.close()},[J]);let Y=C.useMemo(()=>x(V),[V]),X=C.useMemo(()=>se(V),[V]),Z=C.useMemo(()=>S(V),[V]),Q=C.useMemo(()=>{let e=[`grid`];return Y&&e.push(`kanban`),X&&e.push(`calendar`),Z&&e.push(`gallery`),e},[Y,X,Z]),$=C.useMemo(()=>{if(V)return{type:`list-view`,objectName:V.name,viewType:`grid`,fields:W,...U.length?{filters:U}:{},kanban:Y,calendar:X,gallery:Z,userFilters:G,appearance:{allowedVisualizations:Q},showViewSwitcher:Q.length>1,showSearch:!0,showSort:!0,showFilters:!0,showGroup:!0,showHideFields:!0,showDensity:!0,showRecordCount:!0}},[V,W,U,Y,X,Z,G,Q]),ye=C.useCallback(async e=>{try{let t={...e,columns:Array.isArray(e.columns)&&e.columns.length>0?e.columns:W,...U.length?{filter:U}:{}},n=await fe(`view`,String(e?.name??e?.id??``),t,{metadataClient:R});n&&j(`../view/${n}`,{relative:`path`})}catch(e){console.error(`[ObjectDataPage] Failed to save view:`,e)}},[W,U,R,j]);return V?P(V.name,`read`)?(0,w.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,"data-testid":`object-data-page`,children:[(0,w.jsx)(`div`,{className:`hidden sm:block`,children:(0,w.jsx)(y,{title:(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:k(V)}),(0,w.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:O(`console.objectData.badge`,{defaultValue:`Data`})})]}),description:O(`console.objectData.description`,{defaultValue:`URL-defined data slice — not bound to any saved view.`}),icon:C.createElement(_(V?.icon),{className:`h-4 w-4`}),actions:(0,w.jsxs)(w.Fragment,{children:[P(V.name,`create`)&&(0,w.jsxs)(d,{size:`sm`,onClick:()=>j(`../new`,{relative:`path`}),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-new-button`,children:[(0,w.jsx)(re,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectView.new`)})]}),L&&(0,w.jsxs)(d,{size:`sm`,variant:`outline`,onClick:()=>B(!0),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-save-as-view`,children:[(0,w.jsx)(ne,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectData.saveAsView`,{defaultValue:`Save as view`})})]})]})})}),U.length>0&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b px-3 sm:px-4 py-2 shrink-0`,"data-testid":`object-data-filter-chips`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`console.objectData.filteredBy`,{defaultValue:`Filtered by`})}),U.map(([e,,t])=>(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-xs`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:A(V.name,e,e)}),(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[`= `,String(t)]}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>ge(e),className:`ml-0.5 rounded-full hover:bg-muted p-0.5`,"aria-label":O(`console.objectData.removeFilter`,{defaultValue:`Remove filter {{field}}`,field:e}),"data-testid":`object-data-remove-filter-${e}`,children:(0,w.jsx)(te,{className:`h-3 w-3`})})]},e))]}),(0,w.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:$&&(0,w.jsx)(de,{schema:$,dataSource:e,userFilterSelections:me,onUserFilterSelectionsChange:he,onRowClick:_e})}),q.isOverlay&&(0,w.jsx)(ie,{...q,setIsOpen:e=>{e||ve()},title:k(V),children:t=>(0,w.jsx)(oe,{objectNameOverride:V.name,recordIdOverride:String(t?.id??t?._id??J??``),embedded:!0,dataSource:e,objects:i,onEdit:()=>{}})}),L&&(0,w.jsx)(b,{open:z,onOpenChange:B,onCreate:ye,objectDef:V})]}):(0,w.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`object-data-403`,children:(0,w.jsxs)(f,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(ae,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(m,{children:O(`console.objectData.noAccessTitle`,{defaultValue:`Access denied`})}),(0,w.jsx)(h,{children:O(`console.objectData.noAccess`,{defaultValue:`You do not have permission to view this data.`})})]})}):(0,w.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,w.jsxs)(f,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(g,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(m,{children:O(`console.objectView.objectNotFound`)}),(0,w.jsx)(h,{children:O(`console.objectView.objectNotFoundDescription`,{objectName:D})})]})})}export{D as ObjectDataPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BKSb6vFP.js";import{f as c,h as l,n as u,p as d}from"./infrastructure-Bc4DRENl.js";import{H as f,L as p,R as m,Y as h,b as g,l as _}from"./framework-DUXRLJaF.js";import{Cr as v,H as y,Io as b,K as x,Pc as S,X as C,_r as w,aa as T,br as E,gr as D,mr as O,q as k,vr as A,xr as j,yr as M}from"./ui-components-t1CVb1Ox.js";import{r as N}from"./vendor-ui-utils-D-WJ115h.js";import"./MetadataProvider-Bkb-vkjJ.js";import{r as P}from"./ExpressionProvider-gKUl8r3a.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-BQzH8bIG.js";import{t as F}from"./preferLocal-CKqyhTP9.js";import{t as I}from"./InterfaceListPage-BuAQSxuZ.js";import{n as L,t as R}from"./MetadataInspector-Dc5CNMYV.js";var z=e(s(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(v,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(O,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(w,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(E,{children:[(0,B.jsx)(j,{children:r?.title}),(0,B.jsx)(A,{children:r?.message})]}),(0,B.jsxs)(M,{children:[(0,B.jsx)(D,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:c}=d(),{systemPermissions:f}=u(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=S(),y=(0,z.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),b=i||y?.name,x=(0,z.useCallback)(()=>{a?.()},[a]),C=g({dataSource:t,onUndo:()=>{x(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=typeof t?.objectName==`string`&&t.objectName?t.objectName:void 0,s=re(e,{objectName:o||i||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),c=o||i||y?.name,l=s.map(e=>({...e,label:h(c,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(c,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(c,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(c,t?.name,e.name,n.value,n.label)})):e.options}));D({open:!0,params:l,title:t?.label||t?.title,description:v(c,t?.name,t?.description),resolve:r})}),[i,y,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,z.useMemo)(()=>l(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&x(),{success:!0,data:g&&typeof g==`object`&&!Array.isArray(g)&&`data`in g?g.data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||b,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&x(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,b,W,c,x,G]),q=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||b,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&x(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,b,x]),J=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&x(),{success:!0}}let i=e.objectName||b||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&x();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,b,x]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[i,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),x()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=_(),{pageName:t}=a(),[o]=i(),{showDebug:s}=L(),l=r(),u=n(),d=c(),{pages:f,objects:g,getTypeStatus:v}=m(),{app:S}=P(),w=p(),[E,D]=(0,z.useState)(0),O=F(f,t,S?._packageId);if(!O){let n=v?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(y,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(x,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(b,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(C,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(k,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(o.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:w,objects:g,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,B.jsx)(T,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(I,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(h,{schema:{...O,type:O.type||`page`,context:{...O.context,params:A,refreshKey:E}}},E)]}),(0,B.jsx)(R,{open:s,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BKSb6vFP.js";import{f as c,h as l,n as u,p as d}from"./infrastructure-Bc4DRENl.js";import{H as f,L as p,R as m,Y as h,b as g,l as _}from"./framework-BL3BtpKU.js";import{Cr as v,H as y,Io as b,K as x,Pc as S,X as C,_r as w,aa as T,br as E,gr as D,mr as O,q as k,vr as A,xr as j,yr as M}from"./ui-components-Y3D5-fgK.js";import{r as N}from"./vendor-ui-utils-D-WJ115h.js";import"./MetadataProvider-DqPZ6rV2.js";import{r as P}from"./ExpressionProvider-CHaGm5wf.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-w6IBQ1cm.js";import{t as F}from"./preferLocal-CKqyhTP9.js";import{t as I}from"./InterfaceListPage-Ca4VNsGg.js";import{n as L,t as R}from"./MetadataInspector-Bqe7rY0S.js";var z=e(s(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(v,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(O,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(w,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(E,{children:[(0,B.jsx)(j,{children:r?.title}),(0,B.jsx)(A,{children:r?.message})]}),(0,B.jsxs)(M,{children:[(0,B.jsx)(D,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:c}=d(),{systemPermissions:f}=u(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=S(),y=(0,z.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),b=i||y?.name,x=(0,z.useCallback)(()=>{a?.()},[a]),C=g({dataSource:t,onUndo:()=>{x(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=typeof t?.objectName==`string`&&t.objectName?t.objectName:void 0,s=re(e,{objectName:o||i||y?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),c=o||i||y?.name,l=s.map(e=>({...e,label:h(c,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(c,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(c,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(c,t?.name,e.name,n.value,n.label)})):e.options}));D({open:!0,params:l,title:t?.label||t?.title,description:v(c,t?.name,t?.description),resolve:r})}),[i,y,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,z.useMemo)(()=>l(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&x(),{success:!0,data:g&&typeof g==`object`&&!Array.isArray(g)&&`data`in g?g.data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||b,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&x(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,b,W,c,x,G]),q=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||b,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&x(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,b,x]),J=(0,z.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&x(),{success:!0}}let i=e.objectName||b||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&x();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,b,x]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[i,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),x()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=_(),{pageName:t}=a(),[o]=i(),{showDebug:s}=L(),l=r(),u=n(),d=c(),{pages:f,objects:g,getTypeStatus:v}=m(),{app:S}=P(),w=p(),[E,D]=(0,z.useState)(0),O=F(f,t,S?._packageId);if(!O){let n=v?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(y,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(x,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(b,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(C,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(k,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(o.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:w,objects:g,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,B.jsx)(T,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(I,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(h,{schema:{...O,type:O.type||`page`,context:{...O.context,params:A,refreshKey:E}}},E)]}),(0,B.jsx)(R,{open:s,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{o as r,p as i}from"./infrastructure-Bc4DRENl.js";import{l as a}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{o as r,p as i}from"./infrastructure-Bc4DRENl.js";import{l as a}from"./framework-BL3BtpKU.js";import{Ar as o,As as s,Cr as c,Ha as l,Hr as u,Ns as d,Va as f,ar as p,cr as m,dr as h,fr as g,ir as _,ln as v,lr as y,nr as b,pn as x,rr as S,sr as C,tr as w,ur as T,w as E,zr as D}from"./ui-components-Y3D5-fgK.js";var O=e(n(),1),k=t();function A(){let{t:e}=a(),{user:t,updateUser:n,isLoading:f,changePassword:A,setInitialPassword:M,hasLocalPassword:N}=i(),{upload:P}=E(),[F,I]=(0,O.useState)(t?.name??``),[L,R]=(0,O.useState)(!1),[z,B]=(0,O.useState)(null),V=(0,O.useRef)(null),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(null);return(0,O.useEffect)(()=>{I(t?.name??``)},[t?.name]),t?(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:e(`profile.title`,{defaultValue:`Profile`})}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`profile.subtitle`,{defaultValue:`Manage your account settings`})})]}),(0,k.jsx)(w,{children:(0,k.jsxs)(b,{className:`pt-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,k.jsxs)(m,{className:`h-16 w-16`,children:[(0,k.jsx)(T,{src:t.image??void 0,alt:t.name??`User`}),(0,k.jsx)(y,{className:`text-lg bg-primary text-primary-foreground`,children:r(t)})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:t.name??`User`}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:t.email}),(0,k.jsx)(C,{variant:`secondary`,className:`mt-1`,children:t.role??`member`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,k.jsx)(`input`,{ref:V,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let t=e.target.files?.[0];if(V.current&&(V.current.value=``),t){U(!0),G(null);try{let e=await P(t);await n({image:e.url})}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}},"data-testid":`profile-avatar-file`}),(0,k.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,disabled:H,onClick:()=>V.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[H?(0,k.jsx)(l,{className:`mr-2 h-4 w-4 animate-spin`}):(0,k.jsx)(u,{className:`mr-2 h-4 w-4`}),t.image?e(`profile.avatar.replace`,{defaultValue:`Replace`}):e(`profile.avatar.upload`,{defaultValue:`Upload`})]}),t.image&&(0,k.jsxs)(c,{type:`button`,variant:`ghost`,size:`sm`,disabled:H,onClick:async()=>{U(!0),G(null);try{await n({image:null})}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,k.jsx)(o,{className:`mr-2 h-4 w-4`}),e(`profile.avatar.remove`,{defaultValue:`Remove`})]})]})]}),W&&(0,k.jsxs)(h,{variant:`destructive`,className:`mt-4`,children:[(0,k.jsx)(d,{className:`h-4 w-4`}),(0,k.jsx)(g,{children:W})]})]})}),(0,k.jsxs)(w,{children:[(0,k.jsxs)(_,{children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(D,{className:`h-4 w-4 text-muted-foreground`}),(0,k.jsx)(p,{className:`text-base sm:text-lg`,children:e(`profile.info.title`,{defaultValue:`Personal Information`})})]}),(0,k.jsx)(S,{children:e(`profile.info.description`,{defaultValue:`Update your name and view account details`})})]}),(0,k.jsx)(b,{children:(0,k.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),B(null),R(!1);try{await n({name:F}),R(!0)}catch(e){B(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[z&&(0,k.jsxs)(h,{variant:`destructive`,children:[(0,k.jsx)(d,{className:`h-4 w-4`}),(0,k.jsx)(g,{children:z})]}),L&&(0,k.jsxs)(h,{children:[(0,k.jsx)(s,{className:`h-4 w-4 text-green-600`}),(0,k.jsx)(g,{className:`text-green-800 dark:text-green-400`,children:e(`profile.info.saved`,{defaultValue:`Profile updated successfully.`})})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(x,{htmlFor:`profile-name`,children:e(`profile.info.name`,{defaultValue:`Name`})}),(0,k.jsx)(v,{id:`profile-name`,type:`text`,value:F,onChange:e=>I(e.target.value),required:!0,"aria-required":`true`,disabled:f})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(x,{htmlFor:`profile-email`,children:e(`profile.info.email`,{defaultValue:`Email`})}),(0,k.jsx)(v,{id:`profile-email`,type:`email`,value:t.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`profile.info.emailImmutable`,{defaultValue:`Email cannot be changed.`})})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(x,{children:e(`profile.info.role`,{defaultValue:`Role`})}),(0,k.jsx)(v,{type:`text`,value:t.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,k.jsx)(c,{type:`submit`,disabled:f,className:`w-full sm:w-auto`,children:f?e(`profile.saving`,{defaultValue:`Saving…`}):e(`profile.info.save`,{defaultValue:`Save Changes`})})]})})]}),(0,k.jsx)(j,{changePassword:A,setInitialPassword:M,hasLocalPassword:N})]}):null}function j({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let{t:o}=a(),[l,u]=(0,O.useState)(null),[m,y]=(0,O.useState)(``),[C,T]=(0,O.useState)(``),[E,D]=(0,O.useState)(``),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(null),[P,F]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=!1;return n().then(t=>{e||u(t)}).catch(()=>{e||u(!1)}),()=>{e=!0}},[n]);let I=()=>{y(``),T(``),D(``)},L=async n=>{if(n.preventDefault(),N(null),F(null),C.length<8){N(o(`profile.password.tooShort`,{defaultValue:`Password must be at least 8 characters`}));return}if(C!==E){N(o(`profile.password.mismatch`,{defaultValue:`Passwords do not match`}));return}j(!0);try{if(l){if(!m){N(o(`profile.password.enterCurrent`,{defaultValue:`Enter your current password`})),j(!1);return}await e(m,C),F(o(`profile.password.changed`,{defaultValue:`Password changed.`}))}else await t(C),F(o(`profile.password.localSet`,{defaultValue:`Local password set. You can now sign in with email and password on this environment.`})),u(!0),i?.();I()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},R=l===null;return(0,k.jsxs)(w,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,k.jsxs)(_,{children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(f,{className:`h-4 w-4 text-muted-foreground`}),(0,k.jsx)(p,{className:`text-base sm:text-lg`,children:l?o(`profile.password.changeTitle`,{defaultValue:`Change Password`}):o(`profile.password.setTitle`,{defaultValue:`Set Local Password`})})]}),(0,k.jsx)(S,{children:l?o(`profile.password.changeDescription`,{defaultValue:`Update the password you use to sign in to this environment.`}):o(`profile.password.setDescription`,{defaultValue:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})})]}),(0,k.jsx)(b,{children:(0,k.jsxs)(`form`,{onSubmit:L,className:`space-y-4 max-w-md`,children:[l&&(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(x,{htmlFor:`current-password`,children:o(`profile.password.current`,{defaultValue:`Current password`})}),(0,k.jsx)(v,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:m,onChange:e=>y(e.target.value),disabled:A||R,required:!0})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(x,{htmlFor:`new-password`,children:l?o(`profile.password.new`,{defaultValue:`New password`}):o(`profile.password.password`,{defaultValue:`Password`})}),(0,k.jsx)(v,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:C,onChange:e=>T(e.target.value),disabled:A||R,minLength:8,required:!0})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(x,{htmlFor:`confirm-password`,children:o(`profile.password.confirm`,{defaultValue:`Confirm password`})}),(0,k.jsx)(v,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:E,onChange:e=>D(e.target.value),disabled:A||R,minLength:8,required:!0})]}),M&&(0,k.jsxs)(h,{variant:`destructive`,children:[(0,k.jsx)(d,{className:`h-4 w-4`}),(0,k.jsx)(g,{children:M})]}),P&&(0,k.jsxs)(h,{children:[(0,k.jsx)(s,{className:`h-4 w-4`}),(0,k.jsx)(g,{children:P})]}),(0,k.jsx)(c,{type:`submit`,disabled:A||R,className:`w-full sm:w-auto`,children:A?o(`profile.saving`,{defaultValue:`Saving…`}):l?o(`profile.password.changeAction`,{defaultValue:`Change password`}):o(`profile.password.setAction`,{defaultValue:`Set password`})})]})})]})}export{A as ProfilePage};
|