@objectstack/console 10.2.0 → 11.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/assets/{AdapterProvider-CJjaoZJR.js → AdapterProvider-BieqtbDy.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-B4OLmiXS.js → AiPendingActionsPage-_rod9OeO.js} +1 -1
- package/dist/assets/ApiConsolePage-WCI3DIIi.js +1 -0
- package/dist/assets/{AppDocsIndex-ChEbT5sV.js → AppDocsIndex-0yBeTLFW.js} +1 -1
- package/dist/assets/AppManagementPage-jXBjId07.js +1 -0
- package/dist/assets/ApprovalsInboxPage-BYHBBA9y.js +1 -0
- package/dist/assets/{AuditLogPage-BtNmxWyG.js → AuditLogPage-CO0HOjCA.js} +1 -1
- package/dist/assets/{ComponentNavView-naLkSvjF.js → ComponentNavView-DmByVW8F.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-C_BlXoV1.js +1 -0
- package/dist/assets/DashboardView-Cs-MC_5A.js +1 -0
- package/dist/assets/DashboardWidgetInspector-ce9fT5XA.js +1 -0
- package/dist/assets/{DeveloperHubPage-COHQrdbV.js → DeveloperHubPage-DN8UdQMr.js} +1 -1
- package/dist/assets/ExpressionProvider-CT3sX7xF.js +1 -0
- package/dist/assets/FlowRunsPage-DPj0zPLk.js +1 -0
- package/dist/assets/{IntegrationsPage-Bu6X6rLQ.js → IntegrationsPage-CqLzZMOK.js} +2 -2
- package/dist/assets/{InterfaceListPage-Cfv6Lkis.js → InterfaceListPage-GcApvEz0.js} +1 -1
- package/dist/assets/{ManagedByBadge-DDil8sjK.js → ManagedByBadge-5eJy46Si.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-C3bv4Vmg.js → MarketplaceAccessDenied-BGBYYv_M.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-C-saIRJu.js → MarketplaceInstalledPage-Fa8EY_5o.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-CcpJSBrF.js → MarketplacePackagePage-DC6zA893.js} +2 -2
- package/dist/assets/MarketplacePage-nv-oKrlO.js +1 -0
- package/dist/assets/{MetadataInspector-D9KL7Kgi.js → MetadataInspector-XbWYccBm.js} +1 -1
- package/dist/assets/{MetadataProvider-BO_KcC86.js → MetadataProvider-fKK6GbWD.js} +1 -1
- package/dist/assets/PageView-C9b2DYFF.js +1 -0
- package/dist/assets/ProfilePage-D7Ie0WN7.js +1 -0
- package/dist/assets/PublicFormsPage-BaKsA3Eo.js +1 -0
- package/dist/assets/RecordDetailView-CfCIFeA9.js +9 -0
- package/dist/assets/{RecordFormPage-BYeWa90w.js → RecordFormPage-Bkn_bUyo.js} +1 -1
- package/dist/assets/ReportDefaultInspector-CoxrLLKh.js +11 -0
- package/dist/assets/{ReportView-uPqsauzE.js → ReportView-Gq01PZlc.js} +1 -1
- package/dist/assets/{SearchResultsPage-DraOSIqg.js → SearchResultsPage-C3SyFv3R.js} +1 -1
- package/dist/assets/{SettingsHub-CzOLpvoR.js → SettingsHub-BLCpGzj-.js} +1 -1
- package/dist/assets/{SettingsView-BJnPeWpq.js → SettingsView-Cd6iNy3t.js} +1 -1
- package/dist/assets/{SystemHubPage-CeKubn-w.js → SystemHubPage-DBdBlyat.js} +1 -1
- package/dist/assets/{data-adapter-QvY0S7Jg.js → data-adapter-C8ELgvKP.js} +1 -1
- package/dist/assets/exceljs.min-HZhgX9lC.js +28 -0
- package/dist/assets/framework-CQlIjbCT.js +35 -0
- package/dist/assets/{highlighted-body-OFNGDK62-DH1qH6jn.js → highlighted-body-OFNGDK62-02fX_5a1.js} +1 -1
- package/dist/assets/index-Vh0-yrfs.js +2 -0
- package/dist/assets/index-_u4ypVlX.css +2 -0
- package/dist/assets/infrastructure-BtLHjSlJ.js +3 -0
- package/dist/assets/{marketplaceApi-DL8PegzV.js → marketplaceApi-D36MnuCE.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-BeAYGylq.js +1 -0
- package/dist/assets/metadata-admin-mBijR3yo.js +22 -0
- package/dist/assets/plugin-calendar-BdTHA4Ee.js +1 -0
- package/dist/assets/plugin-charts-DoMMZZk8.js +7 -0
- package/dist/assets/plugin-chatbot-CumNGrh8.js +120 -0
- package/dist/assets/plugin-dashboard-Bl7wuG9f.js +6 -0
- package/dist/assets/plugin-form-hyYQoCHc.js +1 -0
- package/dist/assets/plugin-gantt-BsnXplf2.js +93 -0
- package/dist/assets/plugin-grid-DvI8i3CO.js +6 -0
- package/dist/assets/plugin-kanban-DmKa19Zc.js +1 -0
- package/dist/assets/plugin-map-CIN-oBC5.js +1 -0
- package/dist/assets/{plugin-markdown-Fz2pgiZT.js → plugin-markdown-DU8O5B7L.js} +1 -1
- package/dist/assets/plugin-report-JWTVyA2R.js +59 -0
- package/dist/assets/{plugin-timeline-BEk5SlxQ.js → plugin-timeline-BMM7P_hx.js} +1 -1
- package/dist/assets/plugin-tree-CErRKxCG.js +1 -0
- package/dist/assets/plugin-view-BMfFD77p.js +1 -0
- package/dist/assets/plugins-views-iYrs182B.js +4 -0
- package/dist/assets/recordFormNavigation-CXt3jCB4.js +1 -0
- package/dist/assets/{skeletons-DZWz9Ill.js → skeletons-k9g6qZSy.js} +1 -1
- package/dist/assets/{src-CpvBTq6C.js → src-BcFufHSl.js} +1 -1
- package/dist/assets/src-Dnw5qGGv.js +2 -0
- package/dist/assets/types-DXihP4sI.js +1 -0
- package/dist/assets/ui-components-CgiD1ql5.js +42 -0
- package/dist/assets/ui-layout-C9ykUXmg.js +1 -0
- package/dist/assets/useActionModal-DJG5Babl.js +1 -0
- package/dist/assets/{useOpenRecordList-CwVRoKH4.js → useOpenRecordList-D-g511Jw.js} +1 -1
- package/dist/assets/{useReconcileOnError-BXVpquqp.js → useReconcileOnError-QYVPx52o.js} +1 -1
- package/dist/assets/utils-6HhVlFkm.js +1 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/LICENSE.apache +0 -202
- package/dist/assets/ApiConsolePage-D9A9ewr3.js +0 -1
- package/dist/assets/AppManagementPage-DwyKF7UE.js +0 -1
- package/dist/assets/ApprovalsInboxPage-Ca5Bb0JN.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-1MfhDZaK.js +0 -1
- package/dist/assets/DashboardView-Ccnc4ERO.js +0 -1
- package/dist/assets/DashboardWidgetInspector-DQvlAqdm.js +0 -1
- package/dist/assets/ExpressionProvider-C2XzKImE.js +0 -1
- package/dist/assets/FlowRunsPage-DIO45X3A.js +0 -1
- package/dist/assets/MarketplacePage-B0zIXkwO.js +0 -1
- package/dist/assets/PageView-gzbH9RTq.js +0 -1
- package/dist/assets/ProfilePage-BXz0C-TJ.js +0 -1
- package/dist/assets/PublicFormsPage-D5-EASU8.js +0 -1
- package/dist/assets/RecordDetailView-ANMXqsUj.js +0 -9
- package/dist/assets/ReportDefaultInspector-B6X1lhzs.js +0 -7
- package/dist/assets/framework-CsYa1Kaj.js +0 -34
- package/dist/assets/index-Bx77jcFN.js +0 -4
- package/dist/assets/index-CYLGNLiD.css +0 -2
- package/dist/assets/infrastructure-BsIvKvpW.js +0 -3
- package/dist/assets/mermaid-GHXKKRXX-DlOIGBXr.js +0 -1
- package/dist/assets/metadata-admin--twLAcNF.js +0 -21
- package/dist/assets/plugin-calendar-HZM7PnuZ.js +0 -1
- package/dist/assets/plugin-charts-CHVu5fbZ.js +0 -7
- package/dist/assets/plugin-chatbot-B25XBELF.js +0 -120
- package/dist/assets/plugin-dashboard-C8TbFk_D.js +0 -6
- package/dist/assets/plugin-form-sm04IEZv.js +0 -1
- package/dist/assets/plugin-gantt-BAbv_iPP.js +0 -93
- package/dist/assets/plugin-grid-pjPmzTDb.js +0 -6
- package/dist/assets/plugin-kanban-CFOumo0N.js +0 -1
- package/dist/assets/plugin-map-DD4Y0TfP.js +0 -1
- package/dist/assets/plugin-report-DidhEKAB.js +0 -59
- package/dist/assets/plugin-tree-uFJca_YQ.js +0 -1
- package/dist/assets/plugin-view-CDxJidrj.js +0 -1
- package/dist/assets/plugins-views-BpKTWXXa.js +0 -4
- package/dist/assets/src-ZyouQodC.js +0 -2
- package/dist/assets/types-IRCvjK2K.js +0 -1
- package/dist/assets/ui-components-DXl7VfQF.js +0 -42
- package/dist/assets/ui-layout-BwKCXo1Z.js +0 -1
- package/dist/assets/useActionModal-CYfSmVlP.js +0 -1
- package/dist/assets/utils-29quoGQV.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,r,t as i}from"./vendor-react-ClIa1CJA.js";import{Dt as a,Et as o,Ht as s,Is as c,It as l,Jn as u,Ot as d,St as f,Tc as p,Tt as m,Xi as h,Yn as g,Zi as _,bt as v,et as y,fo as b,jo as x,kt as S,oi as C,qn as w,rr as T,wt as E,xt as D}from"./ui-components-CgiD1ql5.js";import{_ as O,c as k,d as A,g as j,h as M,n as N,o as P,p as F,s as I,t as L,u as R}from"./vendor-dndkit-CJ-mJJuO.js";var z=e(t(),1),B=i();function V(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function H(e){let t=V(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function U(e){let t=V(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function W(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function ee(e,t){(0,z.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=H(e.primaryColor),i=U(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:W(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=H(e.accentColor),i=U(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:W(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function G({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return ee(a,a?.title),(0,B.jsxs)(S,{defaultOpen:i,className:`!flex-col h-svh overflow-hidden`,children:[(0,B.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,B.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,B.jsx)(E,{className:`min-w-0`,children:(0,B.jsx)(`main`,{className:p(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,r),children:n})})]})]})}function te(e){return e?y(e):x}function K(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function ne(e,t,n,r,i,a,o){let s=K(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var q=e=>!(e===!1||e===`false`),re=()=>!0,J=()=>!0,ie=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function Y(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(ie,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function X(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=Y(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=Y(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=Y(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function ae(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function Z(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=Z(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return K(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var Q=5;function oe({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=P({id:e.id,disabled:!c});return(0,B.jsx)(`div`,{ref:v,style:{transform:O.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,B.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?_:void 0,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h})})}function $({item:e,basePath:t,evalVis:i,checkPerm:y,checkCap:x,onAction:S,enablePinning:C,onPinToggle:E,dragListeners:O,resolveObjectLabel:k,resolveDashboardLabel:A,resolveGroupLabel:j,resolveViewLabel:M,resolveItemLabel:N,t:P,templateContext:F}){let I=n(),L=l(),R=L?`min-h-[44px] text-[15px] gap-3 rounded-xl`:void 0,V=p(`shrink-0`,L?`h-5 w-5`:`h-4 w-4`),H=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),U=e.type===`group`?e.children?.length??0:0,[W,ee]=(0,z.useState)(z.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=X(r,t,F);if(ae(r,e,I.pathname))return!0}return!1};return n(e.children)},[e,t,I.pathname])?!0:H??!(U>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!y(e.requiredPermissions))return null;let G=e.requiresObject,q=e.requiresService;if(G&&!x(`object`,G)||q&&!x(`service`,q))return null;if(e.type===`separator`)return(0,B.jsx)(s,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0)),r=ne(e,k,P,A,j,M,N);return(0,B.jsx)(w,{open:W,onOpenChange:ee,children:(0,B.jsxs)(v,{children:[(0,B.jsx)(f,{asChild:!0,children:(0,B.jsxs)(g,{className:p(`flex w-full items-center justify-between`,L&&`min-h-[44px] text-[15px] rounded-xl`),children:[r,(0,B.jsx)(c,{className:p(`ml-auto transition-transform`,L?`h-5 w-5`:`h-4 w-4`,W&&`rotate-90`)})]})}),(0,B.jsx)(u,{children:(0,B.jsx)(D,{children:(0,B.jsx)(m,{children:n.map(e=>(0,B.jsx)($,{item:e,basePath:t,evalVis:i,checkPerm:y,checkCap:x,onAction:S,enablePinning:C,onPinToggle:E,resolveObjectLabel:k,resolveDashboardLabel:A,resolveGroupLabel:j,resolveViewLabel:M,resolveItemLabel:N,t:P,templateContext:F},e.id))})})})]})})}if(e.type===`action`){let n=te(e.icon),r=K(e.label,P);return(0,B.jsxs)(d,{children:[O&&(0,B.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":P?P(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...O,children:(0,B.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,B.jsxs)(a,{tooltip:r,onClick:()=>S?.(e),className:R,children:[(0,B.jsx)(n,{className:V}),(0,B.jsx)(`span`,{children:r}),e.badge!=null&&(0,B.jsx)(T,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),C&&E&&(0,B.jsx)(o,{showOnHover:!0,onClick:()=>E(e.id,!e.pinned,e,t),"aria-label":P?P(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${r}`:`Pin ${r}`,name:r}):e.pinned?`Unpin ${r}`:`Pin ${r}`,children:e.pinned?(0,B.jsx)(h,{className:`h-3.5 w-3.5`}):(0,B.jsx)(_,{className:`h-3.5 w-3.5`})})]})}let re=te(e.icon),{href:J,external:ie}=X(e,t,F),Y=ae(e,J,I.pathname),Z=ne(e,k,P,A,j,M,N),Q=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(re,{className:V}),(0,B.jsx)(`span`,{children:Z}),e.badge!=null&&(0,B.jsx)(T,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,B.jsxs)(d,{children:[O&&(0,B.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":P?P(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...O,children:(0,B.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(a,{asChild:!0,isActive:Y,tooltip:Z,className:R,children:ie?(0,B.jsx)(`a`,{href:J,target:`_blank`,rel:`noopener noreferrer`,children:Q}):(0,B.jsx)(r,{to:J,children:Q})}),C&&E&&(0,B.jsx)(o,{showOnHover:!0,onClick:()=>E(e.id,!e.pinned,e,t),"aria-label":P?P(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${Z}`:`Pin ${Z}`,name:Z}):e.pinned?`Unpin ${Z}`:`Pin ${Z}`,children:e.pinned?(0,B.jsx)(h,{className:`h-3.5 w-3.5`}):(0,B.jsx)(_,{className:`h-3.5 w-3.5`})})]})}function se({items:e,basePath:t=``,evaluateVisibility:n=q,checkPermission:r=re,checkCapability:i=J,onAction:a,searchQuery:o,enablePinning:s,onPinToggle:c,enableReorder:l,onReorder:u,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:h,resolveViewLabel:g,resolveItemLabel:_,t:y,templateContext:b}){let x=(0,z.useMemo)(()=>o?Z(e,o):e,[e,o]),S=(0,z.useMemo)(()=>ce(x),[x]),w=x.slice().sort((e,t)=>(e.order??0)-(t.order??0)),T=j(M(A,{activationConstraint:{distance:Q}}),M(R)),E=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!u)return;let r=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||u(N(w,r,i).map((e,t)=>({...e,order:t})))},O={basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:h,resolveViewLabel:g,resolveItemLabel:_,t:y,templateContext:b},P=w.some(e=>e.type===`group`),V=S.length>0&&s?(0,B.jsxs)(v,{children:[(0,B.jsxs)(f,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(C,{className:`h-3.5 w-3.5`}),y?y(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,B.jsx)(D,{children:(0,B.jsx)(m,{children:S.map(e=>(0,B.jsx)($,{item:e,...O},`fav-${e.id}`))})})]}):null;if(!P){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,B.jsxs)(B.Fragment,{children:[V,(0,B.jsx)(v,{children:(0,B.jsx)(D,{children:l?(0,B.jsx)(k,{sensors:T,collisionDetection:F,onDragEnd:E,children:(0,B.jsx)(L,{items:e,strategy:I,children:(0,B.jsx)(m,{children:w.map(e=>(0,B.jsx)(oe,{item:e,enableReorder:l,...O},e.id))})})}):(0,B.jsx)(m,{children:w.map(e=>(0,B.jsx)($,{item:e,...O},e.id))})})})]})}let H=[],U=[],W=e=>{if(U.length===0)return;let t=U;U=[],H.push((0,B.jsx)(v,{children:(0,B.jsx)(D,{children:(0,B.jsx)(m,{children:t.map(e=>(0,B.jsx)($,{item:e,...O},e.id))})})},e))};return w.forEach((e,t)=>{e.type===`group`?(W(`leaf-${t}`),H.push((0,B.jsx)($,{item:e,...O},e.id))):U.push(e)}),W(`leaf-end`),(0,B.jsxs)(B.Fragment,{children:[V,H]})}function ce(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...ce(n.children));return t}export{X as n,G as r,se as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{f as r}from"./infrastructure-BtLHjSlJ.js";import{V as i,j as a}from"./framework-CQlIjbCT.js";import{Bt as o,Cn as s,Gn as c,Hn as l,Kn as u,Lt as d,Rt as f,Sn as p,Tc as m,Un as h,Vn as g,Vt as _,bn as v,wn as ee,xn as y,yr as b,zt as x}from"./ui-components-CgiD1ql5.js";import{n as S}from"./plugin-form-hyYQoCHc.js";import{t as C}from"./recordFormNavigation-CXt3jCB4.js";var w=e(t(),1),T=n(),E=(0,w.createContext)({favorites:null,recent:null}),D=(0,w.createContext)(null);function O({children:e}){let[t,n]=(0,w.useState)({favorites:null,recent:null}),r=(0,w.useRef)({attach:(e,t)=>{n(n=>n[e]===t?n:{...n,[e]:t})}});return(0,T.jsx)(D.Provider,{value:r.current,children:(0,T.jsx)(E.Provider,{value:t,children:e})})}function k(e){return(0,w.useContext)(E)[e]}function A(){let e=(0,w.useContext)(D);return(0,w.useCallback)((t,n)=>{e?.attach(t,n)},[e])}function j(e,t){return t?`${e}:u:${t}`:e}function M(e,t){let n=(0,w.useRef)(t);n.current=t,(0,w.useEffect)(()=>{if(typeof window>`u`)return;let t=t=>{if(!(t.key!==e||t.storageArea!==localStorage)){if(t.newValue==null){n.current(null);return}try{n.current(JSON.parse(t.newValue))}catch{n.current(null)}}};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e])}function N(e,t=500){let n=null,r=null,i=!1,a=async()=>{if(n&&=(clearTimeout(n),null),!i)return;let t=r;i=!1,r=null;try{await e(t)}catch{}};return{schedule:e=>{r=e,i=!0,n&&clearTimeout(n),n=setTimeout(()=>{n=null,a()},t)},flush:a,cancel:()=>{n&&clearTimeout(n),n=null,i=!1,r=null}}}var P=`objectui-recent-items`,F=8;function I(e){try{let t=localStorage.getItem(j(P,e));return t?JSON.parse(t):[]}catch{return[]}}function L(e,t){try{localStorage.setItem(j(P,t),JSON.stringify(e))}catch{}}var R=(0,w.createContext)(null);function z({children:e}){let{user:t}=r(),n=t?.id??null,i=k(`recent`),[a,o]=(0,w.useState)(()=>I(n));(0,w.useEffect)(()=>{o(I(n))},[n]),M(j(P,n),e=>{o(Array.isArray(e)?e.filter(e=>e&&typeof e.id==`string`).slice(0,F):[])});let s=(0,w.useRef)(0);(0,w.useEffect)(()=>{if(!i)return;let e=++s.current,t=!1;return(async()=>{try{let r=await i.load();if(t||e!==s.current)return;let a=(Array.isArray(r)?r:[]).filter(e=>e&&typeof e.id==`string`).slice(0,F);o(a),L(a,n)}catch{}})(),()=>{t=!0}},[i,n]);let c=(0,w.useMemo)(()=>N(async e=>{i&&await i.save(e)},500),[i]);(0,w.useEffect)(()=>()=>{c.flush()},[c]);let l=(0,w.useCallback)(e=>{L(e,n),i&&c.schedule(e)},[n,i,c]),u=(0,w.useCallback)(e=>{o(t=>{let n=t.filter(t=>t.id!==e.id),r=[{...e,visitedAt:new Date().toISOString()},...n].slice(0,F);return l(r),r})},[l]),d=(0,w.useCallback)(()=>{o([]),l([])},[l]),f=(0,w.useMemo)(()=>({recentItems:a,addRecentItem:u,clearRecentItems:d}),[a,u,d]);return(0,T.jsx)(R.Provider,{value:f,children:e})}function B(){return(0,w.useContext)(R)||{recentItems:[],addRecentItem:()=>{},clearRecentItems:()=>{}}}var V=`objectui-favorites`,H=`objectui-nav-pins`,U=20,W=20;function G(e){let t=0,n=0,r=!1;for(let i of e)i.type===`nav`?(n++,n>W&&(r=!0)):(t++,t>U&&(r=!0));if(!r)return e;let i=[],a=0,o=0;for(let t of e)t.type===`nav`?o<W&&(i.push(t),o++):a<U&&(i.push(t),a++);return i}function K(e){try{let t=localStorage.getItem(j(V,e));return t?JSON.parse(t):[]}catch{return[]}}function q(e,t){try{localStorage.setItem(j(V,t),JSON.stringify(e))}catch{}}function J(e){let t;try{t=localStorage.getItem(H)}catch{return{migrated:e,didMigrate:!1}}if(!t)return{migrated:e,didMigrate:!1};let n=[];try{let e=JSON.parse(t);Array.isArray(e)&&(n=e.filter(e=>typeof e==`string`))}catch{}try{localStorage.removeItem(H)}catch{}if(n.length===0)return{migrated:e,didMigrate:!1};let r=new Set(e.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),i=new Date().toISOString(),a=[];for(let e of n)r.has(e)||a.push({id:`nav:${e}`,label:e,href:``,type:`nav`,navId:e,pinned:!0,favoritedAt:i});return a.length===0?{migrated:e,didMigrate:!0}:{migrated:[...e,...a],didMigrate:!0}}var Y=(0,w.createContext)(null);function X({children:e}){let{user:t}=r(),n=t?.id??null,i=k(`favorites`),[a,o]=(0,w.useState)(()=>K(n));(0,w.useEffect)(()=>{o(K(n))},[n]),M(j(V,n),e=>{o(Array.isArray(e)?G(e.filter(e=>e&&typeof e.id==`string`)):[])});let s=(0,w.useRef)(0);(0,w.useEffect)(()=>{if(!i)return;let e=++s.current,t=!1;return(async()=>{try{let r=await i.load();if(t||e!==s.current)return;let a=G((Array.isArray(r)?r:[]).filter(e=>e&&typeof e.id==`string`)),l=K(n),u=new Set(a.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),d=l.filter(e=>e.type===`nav`&&e.navId&&!u.has(e.navId)),f=a,p=!1;d.length>0&&(f=G([...a,...d]),p=!0);let{migrated:m,didMigrate:h}=J(f);h&&(f=G(m),p=!0),o(f),q(f,n),p&&c.schedule(f)}catch{}})(),()=>{t=!0}},[i,n]),(0,w.useEffect)(()=>{i||o(e=>{let{migrated:t,didMigrate:r}=J(e);if(!r)return e;let i=G(t);return q(i,n),i})},[i,n]);let c=(0,w.useMemo)(()=>N(async e=>{i&&await i.save(e)},500),[i]);(0,w.useEffect)(()=>()=>{c.flush()},[c]);let l=(0,w.useCallback)(e=>{q(e,n),i&&c.schedule(e)},[n,i,c]),u=(0,w.useCallback)(e=>{o(t=>{if(t.some(t=>t.id===e.id))return t;let n=G([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),d=(0,w.useCallback)(e=>{o(t=>{let n=t.filter(t=>t.id!==e);return l(n),n})},[l]),f=(0,w.useCallback)(e=>{o(t=>{let n=t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):G([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),p=(0,w.useCallback)(()=>{o([]),l([])},[l]),m=(0,w.useCallback)((e,t)=>{!e||!t||o(n=>{let r=!1,i=n.map(n=>n.id===e&&n.label!==t?(r=!0,{...n,label:t}):n);return r?(l(i),i):n})},[l]),h=(0,w.useCallback)((e,t)=>{o(n=>{let r=!1,i=n.map(n=>n.id!==e||!!n.pinned===t?n:(r=!0,{...n,pinned:t}));return r?(l(i),i):n})},[l]),g=(0,w.useMemo)(()=>{let e=new Set;for(let t of a)t.pinned&&t.type===`nav`&&t.navId&&e.add(t.navId);return{favorites:a,addFavorite:u,removeFavorite:d,toggleFavorite:f,isFavorite:e=>a.some(t=>t.id===e),clearFavorites:p,refreshLabel:m,setPinned:h,isPinned:e=>a.some(t=>t.id===e&&!!t.pinned),pinnedNavIds:e}},[a,u,d,f,p,m,h]);return(0,T.jsx)(Y.Provider,{value:g,children:e})}function Z(){return(0,w.useContext)(Y)||{favorites:[],addFavorite:()=>{},removeFavorite:()=>{},toggleFavorite:()=>{},isFavorite:()=>!1,clearFavorites:()=>{},refreshLabel:()=>{},setPinned:()=>{},isPinned:()=>!1,pinnedNavIds:new Set}}function Q(){return`${``.replace(/\/$/,``)}/api/v1`}async function $(e,t){let n=await fetch(`${Q()}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=Error(r?.error||`HTTP ${n.status}`);throw e.code=r?.code??`HTTP_${n.status}`,e.status=n.status,e}return r}function te(e,t,n){let[r,i]=(0,w.useState)(!1),[a,o]=(0,w.useState)(!0),[s,c]=(0,w.useState)([]),l=(0,w.useRef)(!1),u=(0,w.useCallback)(async()=>{if(!(!e||!t)&&!l.current){i(!0);try{c((await $(`/approvals/requests?object=${encodeURIComponent(e)}&recordId=${encodeURIComponent(t)}`))?.data??[]),o(!0)}catch(e){(e?.status===404||e?.status===501)&&(l.current=!0,o(!1))}finally{i(!1)}}},[e,t]);(0,w.useEffect)(()=>{if(!e||!t){c([]);return}u()},[e,t,u]);let d=(0,w.useMemo)(()=>s.find(e=>e.status===`pending`)??null,[s]),f=(0,w.useMemo)(()=>s.length===0?null:[...s].sort((e,t)=>{let n=e.submitted_at||e.completed_at||``;return(t.submitted_at||t.completed_at||``).localeCompare(n)})[0]??null,[s]),p=!!d&&!!n&&(d.pending_approvers??[]).includes(n),m=(0,w.useCallback)(async(e,t)=>{if(!d)throw Error(`No pending request`);let r=await $(`/approvals/requests/${encodeURIComponent(d.id)}/${e}`,{method:`POST`,body:JSON.stringify({...n?{actorId:n}:{},...t?.comment?{comment:t.comment}:{}})});return await u(),r?.request},[d,n,u]);return{loading:r,available:a,pendingRequest:d,latestRequest:f,canDecide:p,approve:(0,w.useCallback)(e=>m(`approve`,e),[m]),reject:(0,w.useCallback)(e=>m(`reject`,e),[m]),refresh:u}}var ne={sm:`sm:max-w-sm`,default:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-5xl`,full:`sm:max-w-[95vw] sm:w-full`},re={lg:`sm:max-w-2xl`,xl:`sm:max-w-3xl`,full:`sm:max-w-[95vw]`};function ie(e){if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);return t?{objectName:t[2],mode:t[1]===`edit`||t[1]===`update`?`edit`:`create`}:{objectName:e,mode:`create`}}return e&&typeof e==`object`?e.type&&!e.content&&!e.objectName&&!e.placement?{content:e}:e:{}}function ae(e){let[t,n]=(0,w.useState)(null),{objects:r}=a(),E=(0,w.useCallback)(e=>{n(t=>(t?.resolve(e),null))},[]),D=(0,w.useCallback)(e=>new Promise(t=>{n({d:ie(e),resolve:t})}),[]),O=null;if(t){let n=t.d,a=e=>{e||E({success:!1})};if(n.objectName&&!n.content){let t=n.fields||n.sections?{}:C(r.find(e=>e?.name===n.objectName));O=(0,T.jsx)(S,{schema:{type:`object-form`,formType:`modal`,objectName:n.objectName,mode:n.mode||`create`,recordId:n.recordId,title:n.title,description:n.description,fields:n.fields,...t,modalSize:n.size,open:!0,onOpenChange:a,onSuccess:e=>E({success:!0,reload:!0,data:e}),onCancel:()=>E({success:!1}),showSubmit:!0,showCancel:!0},dataSource:e})}else{let e=n.placement||`center`,t=n.content?(0,T.jsx)(i,{schema:n.content}):n.description?(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}):null;O=e===`side`?(0,T.jsx)(d,{open:!0,onOpenChange:a,children:(0,T.jsxs)(f,{side:n.side||`right`,className:m(`w-full overflow-y-auto`,re[n.size||`default`]),children:[n.title&&(0,T.jsxs)(o,{children:[(0,T.jsx)(_,{children:n.title}),n.description&&(0,T.jsx)(x,{children:n.description})]}),(0,T.jsx)(`div`,{className:`py-3`,children:t})]})}):e===`bottom`?(0,T.jsx)(v,{open:!0,onOpenChange:a,children:(0,T.jsxs)(y,{children:[n.title&&(0,T.jsxs)(s,{children:[(0,T.jsx)(ee,{children:n.title}),n.description&&(0,T.jsx)(p,{children:n.description})]}),(0,T.jsx)(`div`,{className:`max-h-[75vh] overflow-y-auto px-4 pb-6`,children:t})]})}):(0,T.jsx)(g,{open:!0,onOpenChange:a,children:(0,T.jsxs)(l,{className:m(e===`fullscreen`?`h-[95vh] w-full max-w-[98vw] overflow-y-auto`:ne[n.size||`default`]),children:[n.title&&(0,T.jsxs)(c,{children:[(0,T.jsx)(u,{children:n.title}),n.description&&(0,T.jsx)(h,{children:n.description})]}),(0,T.jsx)(`div`,{children:t}),!n.content&&(0,T.jsx)(`div`,{className:`flex justify-end`,children:(0,T.jsx)(b,{onClick:()=>E({success:!0}),children:`OK`})})]})})}}return{modalHandler:D,modalElement:O,closeModal:E}}export{z as a,A as c,Z as i,te as n,B as o,X as r,O as s,ae as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{Br as a,La as o,Ti as s,yr as c}from"./ui-components-CgiD1ql5.js";import{b as l,v as u,y as d}from"./ReportDefaultInspector-CoxrLLKh.js";var f=e(t(),1);function p(e){if(!e||typeof e!=`object`)return null;let t=e;if(`item`in t){let e=t.item;return!e||typeof e!=`object`?null:Object.keys(e).length>0?e:null}return Object.keys(t).length>0?t:null}async function m(e,t,n,r){await r.metadataClient.save(e,t,n,{mode:`draft`})}async function h(e,t,n,r){return await r.metadataClient.save(e,t,n,{mode:`draft`}),t}async function g(e,t,n){return p(await n.metadataClient.get(e,t,{state:`draft`}))}async function _(e,t,n){await n.metadataClient.reset(e,t,{state:`draft`})}async function v(e,t,n){await n.metadataClient.publish(e,t)}var y=r();function b({type:e,name:t,metadataClient:n,dirty:r,onResume:i,onAfterChange:p,savedSignal:m}){let h=u(),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(!1),w=(0,f.useRef)(null),T=(0,f.useCallback)(async()=>{if(!t||!n){x(!1);return}let r;try{r=await g(e,t,{metadataClient:n})}catch{x(!1);return}if(x(!!r),r&&i&&w.current!==t){w.current=t;try{i(r)}catch(e){console.error(`[RuntimeDraftBar] Resume draft failed:`,e)}}},[e,t,n,i]);(0,f.useEffect)(()=>{T()},[T]);let E=(0,f.useRef)(m);(0,f.useEffect)(()=>{m!==E.current&&(E.current=m,m&&x(!0))},[m]);let D=(0,f.useCallback)(async()=>{if(t){C(!0);try{await v(e,t,{metadataClient:n}),x(!1),p?.()}catch(e){console.error(`[RuntimeDraftBar] Publish failed:`,e)}finally{C(!1)}}},[e,t,n,p]),O=(0,f.useCallback)(async()=>{if(t&&!(typeof confirm==`function`&&!confirm(l(`engine.edit.discardDraftConfirm`,h,{type:e,name:t})))){C(!0);try{await _(e,t,{metadataClient:n}),x(!1),p?.()}catch(e){console.error(`[RuntimeDraftBar] Discard draft failed:`,e)}finally{C(!1)}}},[e,t,n,p,h]);return b?(0,y.jsxs)(`div`,{className:`mr-auto flex items-center gap-2`,"data-testid":`runtime-draft-bar`,children:[(0,y.jsxs)(`span`,{className:`text-xs text-amber-700 dark:text-amber-400`,title:d(`engine.edit.draftPending`,h),"data-testid":`runtime-draft-indicator`,children:[`● `,d(`engine.edit.draftPending`,h)]}),(0,y.jsx)(c,{variant:`ghost`,size:`sm`,onClick:O,disabled:S,className:`h-7 w-7 p-0 text-muted-foreground`,title:d(`engine.edit.discardDraft`,h),"aria-label":d(`engine.edit.discardDraft`,h),"data-testid":`runtime-draft-discard`,children:(0,y.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,y.jsx)(c,{size:`sm`,onClick:D,disabled:S||r,className:`h-7 px-2 bg-emerald-600 hover:bg-emerald-700 text-emerald-50`,title:d(r?`engine.edit.publishBlockedDirty`:`engine.edit.publish`,h),"data-testid":`runtime-draft-publish`,children:S?(0,y.jsx)(o,{className:`h-3.5 w-3.5 animate-spin`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}),d(`engine.edit.publish`,h)]})})]}):null}function x(){let e=i(),{appName:t}=n();return(0,f.useCallback)((n,r)=>{let i=new URLSearchParams;if(r)for(let[e,t]of Object.entries(r))t!=null&&i.set(`filter[${e}]`,String(t));let a=i.toString();e(`${t?`/apps/${t}`:``}/${n}${a?`?${a}`:``}`)},[e,t])}export{m as i,b as n,h as r,x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,p as r,u as i}from"./vendor-react-ClIa1CJA.js";import{A as a,V as o,i as s,k as c}from"./framework-CsYa1Kaj.js";import{Dt as l}from"./ui-components-DXl7VfQF.js";import{r as u}from"./vendor-ui-utils-C92Fl7BT.js";import"./AdapterProvider-CJjaoZJR.js";import{a as d}from"./MetadataProvider-BO_KcC86.js";import{i as f,o as p}from"./useActionModal-CYfSmVlP.js";import{n as m}from"./ui-layout-BwKCXo1Z.js";import{n as h}from"./appRoute-D5vwtoc_.js";var g=e(t(),1);function _({objectName:e,objectLabel:t,dataSource:r,onEdit:a,onRefresh:c,onConfirm:l,onToast:d}){let f=i(),{appName:p}=n(),{t:m}=s(),h=`/apps/${p}`,{execute:_,loading:v,error:y,runner:b}=o({context:{objectName:e,objectLabel:t||e,baseUrl:h},onConfirm:l,onToast:d});return(0,g.useEffect)(()=>{b.registerHandler(`create`,async()=>(a?.(null),{success:!0})),b.registerHandler(`delete`,async n=>{let i=Array.isArray(n.params?.records)?n.params.records.filter(e=>e?.id!=null):null;if(i&&i.length>1){let n=await Promise.allSettled(i.map(t=>r.delete(e,t.id))),a=n.filter(e=>e.status===`rejected`).length,o=n.length-a;return c?.(),a===0?(u.success(m(`objectActions.bulkDeleteSuccess`,{count:o,label:t||e,defaultValue:`Deleted ${o} ${t||e} records`})),{success:!0,reload:!0}):(u.error(m(`objectActions.bulkDeletePartial`,{succeeded:o,failed:a,defaultValue:`${o} deleted, ${a} failed`})),{success:!1,error:`${a} failed`})}let a=n.params?.recordId??n.params?.record?.id??i?.[0]?.id??n.recordId;if(!a)return{success:!1,error:m(`objectActions.noRecordId`)};try{return await r.delete(e,a),c?.(),u.success(m(`objectActions.deleteSuccess`,{label:t||e})),{success:!0,reload:!0}}catch(n){return u.error(m(`objectActions.deleteFailed`,{label:t||e}),{description:n.message}),{success:!1,error:n.message}}}),b.registerHandler(`navigate`,async e=>{let t=e.params?.url||e.url;return t&&f(t.startsWith(`/`)?t:`${h}/${t}`),{success:!0}}),b.registerHandler(`refresh`,async()=>(c?.(),{success:!0,reload:!0}))},[b,e,r,a,c,f,h,m,t]),{execute:_,create:(0,g.useCallback)(()=>{a?.(null)},[a]),deleteRecord:(0,g.useCallback)(async e=>_({type:`delete`,confirmText:m(`objectActions.deleteConfirm`),params:{recordId:e}}),[_,m]),navigateToView:(0,g.useCallback)(t=>{f(`${h}/${e}/view/${t}`)},[f,h,e]),navigateToRecord:(0,g.useCallback)(t=>{f(`${h}/${e}/record/${encodeURIComponent(t)}`)},[f,h,e]),loading:v,error:y}}function v(e){return e==null?[]:Array.isArray(e)?e:[e]}function y(e,t){let{alias:n,value:i=`1`,replace:a=!0}=t??{},[o,s]=r(),c=(0,g.useMemo)(()=>v(n),[n]),l=(0,g.useCallback)(t=>t.get(e)===i||c.some(e=>t.get(e)===i),[e,i,c]),u=l(o),d=(0,g.useCallback)(t=>{if(t===l(o))return;let n=new URLSearchParams(o);if(t){n.set(e,i);for(let e of c)n.delete(e)}else{n.delete(e);for(let e of c)n.delete(e)}s(n,{replace:a})},[l,o,s,e,i,c,a]);return{open:u,setOpen:d,openOverlay:(0,g.useCallback)(()=>d(!0),[d]),closeOverlay:(0,g.useCallback)(()=>d(!1),[d]),toggleOverlay:(0,g.useCallback)(()=>{s(t=>{let n=new URLSearchParams(t);if(l(n)){n.delete(e);for(let e of c)n.delete(e)}else{n.set(e,i);for(let e of c)n.delete(e)}return n},{replace:a})},[s,l,e,i,c,a])}}var b=20;function x(e,t=``){let{href:n,external:r}=m(e,t);return r?n:!n||n===`#`?``:n}function S(e){return`nav:${e}`}function C(){let{favorites:e,addFavorite:t,removeFavorite:n,setPinned:r,pinnedNavIds:i}=f(),a=(0,g.useCallback)((e,i,a,o)=>{let s=S(e);i?(a&&t({id:s,label:a.label,href:x(a,o??``),type:`nav`,navId:e,pinned:!0}),r(s,!0)):n(s)},[t,n,r]),o=(0,g.useCallback)(e=>i.has(e),[i]),s=(0,g.useCallback)(e=>{if(i.size===0){let t=!1;for(let n of e)if(n.pinned){t=!0;break}if(!t)return e}let t=0,n=e=>e.map(e=>{let r=i.has(e.id)&&t<b;r&&t++;let a=e.children?.length?n(e.children):e.children;return r!==(e.pinned??!1)||a!==e.children?{...e,pinned:r,children:a}:e});return n(e)},[i]),c=(0,g.useCallback)(()=>{for(let t of e)t.type===`nav`&&n(t.id)},[e,n]);return{pinnedIds:(0,g.useMemo)(()=>Array.from(i),[i]),togglePin:a,isPinned:o,applyPins:s,clearPins:c}}var w=768,T=1024;function ee(){let{setOpen:e,isMobile:t}=l(),n=(0,g.useRef)(e);(0,g.useEffect)(()=>{n.current=e},[e]),(0,g.useEffect)(()=>{if(t)return;let e=!1;function r(){let t=window.innerWidth,r=t>=w&&t<T;r&&!e&&n.current(!1),e=r}return r(),window.addEventListener(`resize`,r),()=>window.removeEventListener(`resize`,r)},[t])}function te(e,t){return{name:e.name,label:e.label,pluralLabel:e.pluralLabel,description:e.description,icon:e.icon,group:e.group,sortOrder:e.sortOrder,enabled:e.enabled,fields:t,relationships:e.relationships}}function ne(e){return{name:e.name,label:e.label,type:e.type,group:e.group,description:e.description,required:e.required,unique:e.unique,readonly:e.readonly,hidden:e.hidden,defaultValue:e.defaultValue,placeholder:e.placeholder,options:e.options,externalId:e.externalId,trackHistory:e.trackHistory,indexed:e.indexed,referenceTo:e.referenceTo,formula:e.formula,sortOrder:e.sortOrder}}var re=class{adapter;constructor(e){this.adapter=e}async getItems(e){let t=await this.adapter.getClient().meta.getItems(e);return t&&typeof t==`object`&&`items`in t&&Array.isArray(t.items)?t.items:[]}async saveMetadataItem(e,t,n){await this.adapter.getClient().meta.saveItem(e,t,n),this.adapter.invalidateCache(`${e}:${t}`)}async deleteMetadataItem(e,t){await this.adapter.getClient().meta.saveItem(e,t,{name:t,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`${e}:${t}`)}async saveObject(e,t){let n=this.adapter.getClient(),r=te(e,t);await n.meta.saveItem(`object`,e.name,r),this.adapter.invalidateCache(`object:${e.name}`)}async deleteObject(e){await this.adapter.getClient().meta.saveItem(`object`,e,{name:e,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`object:${e}`)}async saveFields(e,t){let n=this.adapter.getClient(),r={};try{let t=await n.meta.getItem(`object`,e);r=t?.item??t??{}}catch{}let i={...r,name:e,fields:t.map(ne)};await n.meta.saveItem(`object`,e,i),this.adapter.invalidateCache(`object:${e}`)}static diffObjects(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,object:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,object:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,object:t}}return null}static diffFields(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,field:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,field:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,field:t}}return null}};function ie(){let e=c();return(0,g.useMemo)(()=>e?new re(e):null,[e])}var E=0;function D(e=`nav`){return`${e}_${Date.now()}_${++E}`}function O(e,t){return[...e,t]}function k(e,t,n){return e.filter(e=>!(e.type===t&&(t===`page`&&e.pageName===n||t===`dashboard`&&e.dashboardName===n))).map(e=>e.children&&e.children.length>0?{...e,children:k(e.children,t,n)}:e)}function A(e,t,n,r){return e.map(e=>{let i=e;return t===`page`&&e.type===`page`&&e.pageName===n?i={...e,pageName:r}:t===`dashboard`&&e.type===`dashboard`&&e.dashboardName===n&&(i={...e,dashboardName:r}),i.children&&i.children.length>0?{...i,children:A(i.children,t,n,r)}:i})}function j(e,t){return e.length===t.length?e===t?!0:JSON.stringify(e)===JSON.stringify(t):!1}function ae(e){return typeof e==`string`&&e.startsWith(`sys_`)}function oe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t._packageId!=null||t._provenance===`package`?!0:ae(t.name)}function M(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t._lock??t.protection?.lock;return n!==`full`&&n!==`no-overlay`}function N(){let e=c(),{apps:t,refresh:n}=a(),{t:r}=s(),i=(0,g.useRef)(e);i.current=e;let o=(0,g.useRef)(n);o.current=n;let l=(0,g.useCallback)(async(e,t)=>{let n=i.current?.getClient();n&&await n.meta.saveItem(`app`,e,t),await o.current?.()},[]),d=(0,g.useCallback)(e=>h(t,e),[t]),f=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=O(a,{id:D(`nav_page`),type:`page`,label:n||t,pageName:t,icon:`FileText`}),s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.addedPage`,{name:n||t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),p=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=O(a,{id:D(`nav_dash`),type:`dashboard`,label:n||t,dashboardName:t,icon:`LayoutDashboard`}),s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.addedDashboard`,{name:n||t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),m=(0,g.useCallback)(async(e,t)=>{let n=d(e);if(!n)return;let i=n.navigation??[],a=k(i,`page`,t);if(j(a,i))return;let o={...n,navigation:a};try{await l(e,o),u.success(r(`navigationSync.removedPage`,{name:t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...n,navigation:i}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),_=(0,g.useCallback)(async(e,t)=>{let n=d(e);if(!n)return;let i=n.navigation??[],a=k(i,`dashboard`,t);if(j(a,i))return;let o={...n,navigation:a};try{await l(e,o),u.success(r(`navigationSync.removedDashboard`,{name:t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...n,navigation:i}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),v=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=A(a,`page`,t,n);if(j(o,a))return;let s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.renamedPage`,{oldName:t,newName:n}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),y=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=A(a,`dashboard`,t,n);if(j(o,a))return;let s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.renamedDashboard`,{oldName:t,newName:n}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),b=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return{syncPageCreated:f,syncDashboardCreated:p,syncPageDeleted:m,syncDashboardDeleted:_,syncPageRenamed:v,syncDashboardRenamed:y,syncPageCreatedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await f(t,e,n)}},[t,f]),syncDashboardCreatedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await p(t,e,n)}},[t,p]),syncPageDeletedAllApps:(0,g.useCallback)(async e=>{for(let n of t){let t=b(n);!t||!M(n)||await m(t,e)}},[t,m]),syncDashboardDeletedAllApps:(0,g.useCallback)(async e=>{for(let n of t){let t=b(n);!t||!M(n)||await _(t,e)}},[t,_]),syncPageRenamedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await v(t,e,n)}},[t,v]),syncDashboardRenamedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await y(t,e,n)}},[t,y])}}function P(){let{pages:e,dashboards:t,apps:n,getTypeStatus:r}=a(),i=c(),o=(0,g.useRef)(i);o.current=i;let s=d(),{syncPageCreated:l,syncDashboardCreated:u,syncPageDeleted:f,syncDashboardDeleted:p}=N(),m=(0,g.useRef)(null),h=(0,g.useRef)(null),_=(0,g.useRef)(0),v=(0,g.useRef)(!1),y=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return(0,g.useEffect)(()=>{if(v.current)return;if(s){m.current=null,h.current=null;return}if(r&&(r(`page`)!==`ready`||r(`dashboard`)!==`ready`))return;let i=e=>new Set(e.filter(e=>!oe(e)).map(e=>e?.name).filter(e=>typeof e==`string`&&e.length>0)),a=i(e??[]),o=i(t??[]),c=m.current,d=h.current;if(c===null||d===null){m.current=a,h.current=o;return}let g=[...a].filter(e=>!c.has(e)),b=[...c].filter(e=>!a.has(e)),x=[...o].filter(e=>!d.has(e)),S=[...d].filter(e=>!o.has(e));if(g.length===0&&b.length===0&&x.length===0&&S.length===0){m.current=a,h.current=o;return}let C=++_.current;v.current=!0;let w=!1;return(async()=>{try{for(let e of n){if(w||_.current!==C)break;let t=y(e);if(!(!t||!M(e))){for(let e of g){if(w)break;await l(t,e)}for(let e of b){if(w)break;await f(t,e)}for(let e of x){if(w)break;await u(t,e)}for(let e of S){if(w)break;await p(t,e)}}}}finally{_.current===C&&(m.current=a,h.current=o,v.current=!1)}})(),()=>{w=!0}},[e,t,n,s,r,l,u,f,p]),null}var F=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`]);function I(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function L(e){try{return decodeURIComponent(e)}catch{return e}}function se({pathname:e,appName:t,objects:n=[],basePathSegment:r=`apps`,disabled:i=!1}){let{addRecentItem:a}=p(),o=(0,g.useRef)(n);o.current=n,(0,g.useEffect)(()=>{if(i||!t)return;let n=e.split(`/`).filter(Boolean);if(n[0]!==r||n[1]!==t)return;let s=n[2],c=n[3],l=`/${r}/${t}`;if(s===`metadata`){let e=n[3],t=n[4];e&&t&&t!==`new`&&a({id:`metadata:${e}:${L(t)}`,label:L(t),href:`${l}/metadata/${e}/${t}`,type:`metadata`});return}if(s&&!F.has(s)){let e=o.current.find(e=>e.name===s);e&&a({id:`object:${e.name}`,label:e.label||e.name,href:`${l}/${e.name}`,type:`object`});return}if(c)switch(s){case`dashboard`:a({id:`dashboard:${c}`,label:I(c),href:`${l}/dashboard/${c}`,type:`dashboard`});break;case`page`:a({id:`page:${c}`,label:I(c),href:`${l}/page/${c}`,type:`page`});break;case`report`:a({id:`report:${c}`,label:I(c),href:`${l}/report/${c}`,type:`report`});break;default:break}},[e,t,r,i])}function ce(e){return{status:`drafted`,drafted:e.items,...e.summary?{summary:e.summary}:{},...e.packageId?{packageId:e.packageId}:{},...e.autoPublishable?{autoPublishable:!0}:{},...e.failedCount?{failed:Array.from({length:e.failedCount},()=>null)}:{},...e.materialized?{materialized:!0}:{},...e.verification?{verification:e.verification}:{},...e.issues&&e.issues.length?{issues:e.issues}:{},...e.nextSteps&&e.nextSteps.length?{nextSteps:e.nextSteps}:{}}}function R(e){return{status:`blueprint_proposed`,...e.summary?{summary:e.summary}:{},counts:e.counts,questions:e.questions,...e.targetApp?{targetApp:e.targetApp}:{},blueprint:{objects:e.objects.map(e=>({name:e.name,...e.label?{label:e.label}:{},fields:Array.from({length:e.fieldCount},()=>null)})),assumptions:e.assumptions}}}var z=`objectstack:ai-chat-conversation-id`,B=`objectstack:ai-chat-messages`;function V(e,t){return t?`${z}:${e}:${t}`:`${z}:${e}`}function H(e){try{return localStorage.getItem(e)??void 0}catch{return}}function U(e,t){try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}}function W(e){return`${B}:${e}`}function G(e){try{let t=localStorage.getItem(W(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`&&(e.role===`user`||e.role===`assistant`||e.role===`system`)&&Array.isArray(e.parts)):[]}catch{return[]}}function K(e,t){if(e)try{if(t.length===0){localStorage.removeItem(W(e));return}localStorage.setItem(W(e),JSON.stringify(t))}catch{}}function le(e){return e.map(e=>{let t=[];if(e.content&&t.push({type:`text`,text:e.content}),e.role===`assistant`)for(let n of e.toolInvocations??[]){let e=n.draftReview?ce(n.draftReview):n.proposedPlan?R(n.proposedPlan):void 0;t.push({type:`tool-${n.toolName}`,toolCallId:n.toolCallId,toolName:n.toolName,state:n.state??(n.errorText?`output-error`:`output-available`),...n.errorText?{errorText:n.errorText}:{},...e===void 0?{}:{output:e}})}if(t.length!==0)return{id:e.id,role:e.role,parts:t}}).filter(e=>!!e)}function q(e){return typeof e==`string`?e?[{type:`text`,text:e}]:[]:Array.isArray(e)?e.map(e=>{if(typeof e==`string`)return e?{type:`text`,text:e}:void 0;if(e&&typeof e==`object`&&`type`in e&&typeof e.type==`string`)return e;if(e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`)return{type:`text`,text:e.text}}).filter(e=>!!e):e&&typeof e==`object`&&`parts`in e&&Array.isArray(e.parts)?q(e.parts):[]}function ue(e,t){for(let n of q(e)){let e=typeof n.toolCallId==`string`?n.toolCallId:void 0;if(!e)continue;let r=t.get(e);if(!r)continue;let i=n.output??n.result;if(i===void 0)continue;r.output=i;let a=n.errorText;r.state=n.isError||typeof a==`string`?`output-error`:`output-available`,typeof a==`string`&&(r.errorText=a)}}function J(e){if(!e)return[];let t=[],n=new Map;return e.forEach((e,r)=>{let i=e.role;if(i===`tool`){ue(e.content,n);return}if(i!==`user`&&i!==`assistant`&&i!==`system`)return;let a=q(e.content);if(a.length!==0){if(i===`assistant`)for(let e of a){e.type===`tool-call`&&typeof e.toolName==`string`&&e.toolName&&(e.type=`tool-${e.toolName}`);let t=typeof e.toolCallId==`string`?e.toolCallId:void 0;t&&(e.type===`tool-call`||e.type.startsWith(`tool-`))&&n.set(t,e)}t.push({id:e.id??`msg-${r}`,role:i,parts:a})}}),t}async function Y(e,t){let n=await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{credentials:`include`});if(n.status===404||n.status===403)return null;if(!n.ok)throw Error(`GET conversation failed: ${n.status}`);return await n.json()}async function X(e){let t=await fetch(`${e}/conversations`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok)throw Error(`POST conversation failed: ${t.status}`);return await t.json()}async function de(e,t){await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`include`}).catch(()=>{})}function fe(e){let{userId:t,scope:n,apiBase:r,activeId:i,forceNew:a}=e,[o,s]=(0,g.useState)(void 0),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(!!t),f=(0,g.useRef)(!0),p=(0,g.useRef)(void 0),m=(0,g.useRef)(void 0);(0,g.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]),(0,g.useEffect)(()=>{if(!t){s(void 0),l([]),d(!1),p.current=void 0,m.current=void 0;return}let e=m.current!==n;if(!i&&!a&&!e&&p.current===t&&o)return;let c=!1,u=V(t,n);return!i&&(a||e&&p.current===t)&&(s(void 0),l([])),d(!0),(async()=>{try{if(i){let e=await Y(r,i);if(c)return;if(e){U(u,e.id),s(e.id);let r=J(e.messages);l(r.length>0?r:G(e.id)),p.current=t,m.current=n;return}U(u,void 0),K(i,[])}else if(!a){let e=H(u);if(e){let i=await Y(r,e);if(c)return;if(i){s(i.id);let e=J(i.messages);l(e.length>0?e:G(i.id)),p.current=t,m.current=n;return}U(u,void 0),K(e,[])}}let e=await X(r);if(c)return;U(u,e.id),s(e.id),l(J(e.messages)),p.current=t,m.current=n}catch{c||(s(void 0),l([]))}finally{c||d(!1)}})(),()=>{c=!0}},[t,n,r,i,a]);let h=(0,g.useCallback)(async()=>{if(!t)return;let e=V(t,n);d(!0);try{o&&await de(r,o),K(o,[]),U(e,void 0);let t=await X(r);if(U(e,t.id),K(t.id,[]),!f.current)return;s(t.id),l([])}catch{f.current&&(s(void 0),l([]))}finally{f.current&&d(!1)}},[o,t,n,r]);return{conversationId:o,conversationScope:m.current,initialMessages:c,isLoading:u,reset:h}}var pe=new Set([`new chat`,`new conversation`,`untitled`,`新对话`]);function Z(e){let t=e?.trim().toLowerCase();return!t||pe.has(t)}function me(e){let t=e.messages;if(!t||t.length===0)return;for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.role===`user`){let e=Q(n.content);if(e)return e}}let n=t[t.length-1];return Q(n?.content)}function Q(e){if(typeof e==`string`)return e.slice(0,140);if(e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`)return e.text.slice(0,140);if(e&&typeof e==`object`&&`parts`in e&&Array.isArray(e.parts))return Q(e.parts);if(Array.isArray(e)){let t=e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).join(``);return t?t.slice(0,140):void 0}}function $(e){let t=e.title?.trim(),n=me(e)??Q(e.preview);return{id:e.id,title:Z(t)?void 0:t,agentId:e.agentId,createdAt:e.createdAt,updatedAt:e.updatedAt,preview:n}}async function he(e,t){let n=await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{credentials:`include`});if(!n.ok)return;let r=await n.json();return $(`conversation`in r&&r.conversation?r.conversation:r)}function ge(e){let{userId:t,apiBase:n,limit:r=50,refreshKey:i}=e,[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(!!t),[l,u]=(0,g.useState)(void 0),[d,f]=(0,g.useState)(0),p=(0,g.useCallback)(async()=>{f(e=>e+1)},[]),m=(0,g.useCallback)(async e=>{try{await fetch(`${n}/conversations/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`})}finally{o(t=>t.filter(t=>t.id!==e))}},[n]),h=(0,g.useCallback)(async(e,t)=>{let r=t.trim();o(t=>t.map(t=>t.id===e?{...t,title:r||void 0}:t));let i=await fetch(`${n}/conversations/${encodeURIComponent(e)}`,{method:`PATCH`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:r})});if(!i.ok)throw f(e=>e+1),Error(`PATCH conversation failed: ${i.status}`)},[n]);return(0,g.useEffect)(()=>{if(!t){o([]),c(!1),u(void 0);return}let e=!1;return c(!0),u(void 0),(async()=>{try{let t=await fetch(`${n}/conversations?limit=${encodeURIComponent(String(r))}`,{credentials:`include`});if(!t.ok)throw Error(`GET conversations failed: ${t.status}`);let i=await t.json(),a=Array.isArray(i)?i:i.conversations??i.items??[];if(e)return;let s=a.map($).sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));o(s);let c=s.filter(e=>!e.title&&!e.preview).slice(0,20);if(c.length>0){let t=await Promise.all(c.map(e=>he(n,e.id).catch(()=>void 0)));if(e)return;let r=new Map(t.filter(e=>!!(e?.preview||e?.title)).map(e=>[e.id,e]));r.size>0&&o(e=>e.map(e=>{let t=r.get(e.id);return t?{...e,title:e.title??t.title,preview:e.preview??t.preview}:e}))}}catch(t){if(e)return;u(t instanceof Error?t:Error(String(t))),o([])}finally{e||c(!1)}})(),()=>{e=!0}},[t,n,r,d,i]),{conversations:a,isLoading:s,error:l,refetch:p,remove:m,rename:h}}async function _e(e){let t=await fetch(`/api/v1/meta/_drafts?packageId=${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok)throw Error(`_drafts HTTP ${t.status}`);let n=await t.json(),r=Array.isArray(n)?n:n?.drafts??n?.data?.drafts??[];return Array.isArray(r)?r.length:0}function ve(e){if(!e||e.length===0)return!1;let t=e[e.length-1];return!t||t.role!==`assistant`?!1:t.parts.some(e=>e.type===`text`&&String(e.text??``).trim().length>0)}function ye(e){let{chatApi:t,conversationId:n}=e,[r,i]=(0,g.useState)(!1),a=(0,g.useRef)(void 0);return{errorSuppressed:r,handleChatError:(0,g.useCallback)(async e=>{let r=t?.replace(/\/agents\/[^/]+\/chat$/,``);if(!n||!r){i(!1);return}try{let e=J((await Y(r,n))?.messages);if(ve(e)&&a.current){a.current(e),i(!0);return}}catch{}i(!1)},[n,t]),setMessagesRef:a,resetSuppression:(0,g.useCallback)(()=>i(!1),[])}}export{le as a,se as c,ee as d,C as f,Y as i,P as l,_ as m,_e as n,fe as o,y as p,ge as r,K as s,ye as t,ie as u};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,p as r,u as i}from"./vendor-react-ClIa1CJA.js";import{A as a,B as o,i as s,j as c}from"./framework-CQlIjbCT.js";import{At as l}from"./ui-components-CgiD1ql5.js";import{r as u}from"./vendor-ui-utils-C92Fl7BT.js";import"./AdapterProvider-BieqtbDy.js";import{a as d}from"./MetadataProvider-fKK6GbWD.js";import{i as f,o as p}from"./useActionModal-DJG5Babl.js";import{n as m}from"./ui-layout-C9ykUXmg.js";import{n as h}from"./appRoute-D5vwtoc_.js";var g=e(t(),1);function _({objectName:e,objectLabel:t,dataSource:r,onEdit:a,onRefresh:c,onConfirm:l,onToast:d}){let f=i(),{appName:p}=n(),{t:m}=s(),h=`/apps/${p}`,{execute:_,loading:v,error:y,runner:b}=o({context:{objectName:e,objectLabel:t||e,baseUrl:h},onConfirm:l,onToast:d});return(0,g.useEffect)(()=>{b.registerHandler(`create`,async()=>(a?.(null),{success:!0})),b.registerHandler(`delete`,async n=>{let i=Array.isArray(n.params?.records)?n.params.records.filter(e=>e?.id!=null):null;if(i&&i.length>1){let n=await Promise.allSettled(i.map(t=>r.delete(e,t.id))),a=n.filter(e=>e.status===`rejected`).length,o=n.length-a;return c?.(),a===0?(u.success(m(`objectActions.bulkDeleteSuccess`,{count:o,label:t||e,defaultValue:`Deleted ${o} ${t||e} records`})),{success:!0,reload:!0}):(u.error(m(`objectActions.bulkDeletePartial`,{succeeded:o,failed:a,defaultValue:`${o} deleted, ${a} failed`})),{success:!1,error:`${a} failed`})}let a=n.params?.recordId??n.params?.record?.id??i?.[0]?.id??n.recordId;if(!a)return{success:!1,error:m(`objectActions.noRecordId`)};try{return await r.delete(e,a),c?.(),u.success(m(`objectActions.deleteSuccess`,{label:t||e})),{success:!0,reload:!0}}catch(n){return u.error(m(`objectActions.deleteFailed`,{label:t||e}),{description:n.message}),{success:!1,error:n.message}}}),b.registerHandler(`navigate`,async e=>{let t=e.params?.url||e.url;return t&&f(t.startsWith(`/`)?t:`${h}/${t}`),{success:!0}}),b.registerHandler(`refresh`,async()=>(c?.(),{success:!0,reload:!0}))},[b,e,r,a,c,f,h,m,t]),{execute:_,create:(0,g.useCallback)(()=>{a?.(null)},[a]),deleteRecord:(0,g.useCallback)(async e=>_({type:`delete`,confirmText:m(`objectActions.deleteConfirm`),params:{recordId:e}}),[_,m]),navigateToView:(0,g.useCallback)(t=>{f(`${h}/${e}/view/${t}`)},[f,h,e]),navigateToRecord:(0,g.useCallback)(t=>{f(`${h}/${e}/record/${encodeURIComponent(t)}`)},[f,h,e]),loading:v,error:y}}function v(e){return e==null?[]:Array.isArray(e)?e:[e]}function y(e,t){let{alias:n,value:i=`1`,replace:a=!0}=t??{},[o,s]=r(),c=(0,g.useMemo)(()=>v(n),[n]),l=(0,g.useCallback)(t=>t.get(e)===i||c.some(e=>t.get(e)===i),[e,i,c]),u=l(o),d=(0,g.useCallback)(t=>{if(t===l(o))return;let n=new URLSearchParams(o);if(t){n.set(e,i);for(let e of c)n.delete(e)}else{n.delete(e);for(let e of c)n.delete(e)}s(n,{replace:a})},[l,o,s,e,i,c,a]);return{open:u,setOpen:d,openOverlay:(0,g.useCallback)(()=>d(!0),[d]),closeOverlay:(0,g.useCallback)(()=>d(!1),[d]),toggleOverlay:(0,g.useCallback)(()=>{s(t=>{let n=new URLSearchParams(t);if(l(n)){n.delete(e);for(let e of c)n.delete(e)}else{n.set(e,i);for(let e of c)n.delete(e)}return n},{replace:a})},[s,l,e,i,c,a])}}var b=20;function x(e,t=``){let{href:n,external:r}=m(e,t);return r?n:!n||n===`#`?``:n}function S(e){return`nav:${e}`}function C(){let{favorites:e,addFavorite:t,removeFavorite:n,setPinned:r,pinnedNavIds:i}=f(),a=(0,g.useCallback)((e,i,a,o)=>{let s=S(e);i?(a&&t({id:s,label:a.label,href:x(a,o??``),type:`nav`,navId:e,pinned:!0}),r(s,!0)):n(s)},[t,n,r]),o=(0,g.useCallback)(e=>i.has(e),[i]),s=(0,g.useCallback)(e=>{if(i.size===0){let t=!1;for(let n of e)if(n.pinned){t=!0;break}if(!t)return e}let t=0,n=e=>e.map(e=>{let r=i.has(e.id)&&t<b;r&&t++;let a=e.children?.length?n(e.children):e.children;return r!==(e.pinned??!1)||a!==e.children?{...e,pinned:r,children:a}:e});return n(e)},[i]),c=(0,g.useCallback)(()=>{for(let t of e)t.type===`nav`&&n(t.id)},[e,n]);return{pinnedIds:(0,g.useMemo)(()=>Array.from(i),[i]),togglePin:a,isPinned:o,applyPins:s,clearPins:c}}var w=768,T=1024;function ee(){let{setOpen:e,isMobile:t}=l(),n=(0,g.useRef)(e);(0,g.useEffect)(()=>{n.current=e},[e]),(0,g.useEffect)(()=>{if(t)return;let e=!1;function r(){let t=window.innerWidth,r=t>=w&&t<T;r&&!e&&n.current(!1),e=r}return r(),window.addEventListener(`resize`,r),()=>window.removeEventListener(`resize`,r)},[t])}function te(e,t){return{name:e.name,label:e.label,pluralLabel:e.pluralLabel,description:e.description,icon:e.icon,group:e.group,sortOrder:e.sortOrder,enabled:e.enabled,fields:t,relationships:e.relationships}}function ne(e){return{name:e.name,label:e.label,type:e.type,group:e.group,description:e.description,required:e.required,unique:e.unique,readonly:e.readonly,hidden:e.hidden,defaultValue:e.defaultValue,placeholder:e.placeholder,options:e.options,externalId:e.externalId,trackHistory:e.trackHistory,indexed:e.indexed,referenceTo:e.referenceTo,formula:e.formula,sortOrder:e.sortOrder}}var re=class{adapter;constructor(e){this.adapter=e}async getItems(e){let t=await this.adapter.getClient().meta.getItems(e);return t&&typeof t==`object`&&`items`in t&&Array.isArray(t.items)?t.items:[]}async saveMetadataItem(e,t,n){await this.adapter.getClient().meta.saveItem(e,t,n),this.adapter.invalidateCache(`${e}:${t}`)}async deleteMetadataItem(e,t){await this.adapter.getClient().meta.saveItem(e,t,{name:t,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`${e}:${t}`)}async saveObject(e,t){let n=this.adapter.getClient(),r=te(e,t);await n.meta.saveItem(`object`,e.name,r),this.adapter.invalidateCache(`object:${e.name}`)}async deleteObject(e){await this.adapter.getClient().meta.saveItem(`object`,e,{name:e,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`object:${e}`)}async saveFields(e,t){let n=this.adapter.getClient(),r={};try{let t=await n.meta.getItem(`object`,e);r=t?.item??t??{}}catch{}let i={...r,name:e,fields:t.map(ne)};await n.meta.saveItem(`object`,e,i),this.adapter.invalidateCache(`object:${e}`)}static diffObjects(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,object:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,object:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,object:t}}return null}static diffFields(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,field:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,field:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,field:t}}return null}};function ie(){let e=a();return(0,g.useMemo)(()=>e?new re(e):null,[e])}var E=0;function D(e=`nav`){return`${e}_${Date.now()}_${++E}`}function O(e,t){return[...e,t]}function k(e,t,n){return e.filter(e=>!(e.type===t&&(t===`page`&&e.pageName===n||t===`dashboard`&&e.dashboardName===n))).map(e=>e.children&&e.children.length>0?{...e,children:k(e.children,t,n)}:e)}function A(e,t,n,r){return e.map(e=>{let i=e;return t===`page`&&e.type===`page`&&e.pageName===n?i={...e,pageName:r}:t===`dashboard`&&e.type===`dashboard`&&e.dashboardName===n&&(i={...e,dashboardName:r}),i.children&&i.children.length>0?{...i,children:A(i.children,t,n,r)}:i})}function j(e,t){return e.length===t.length?e===t?!0:JSON.stringify(e)===JSON.stringify(t):!1}function ae(e){return typeof e==`string`&&e.startsWith(`sys_`)}function oe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t._packageId!=null||t._provenance===`package`?!0:ae(t.name)}function M(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t._lock??t.protection?.lock;return n!==`full`&&n!==`no-overlay`}function N(){let e=a(),{apps:t,refresh:n}=c(),{t:r}=s(),i=(0,g.useRef)(e);i.current=e;let o=(0,g.useRef)(n);o.current=n;let l=(0,g.useCallback)(async(e,t)=>{let n=i.current?.getClient();n&&await n.meta.saveItem(`app`,e,t),await o.current?.()},[]),d=(0,g.useCallback)(e=>h(t,e),[t]),f=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=O(a,{id:D(`nav_page`),type:`page`,label:n||t,pageName:t,icon:`FileText`}),s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.addedPage`,{name:n||t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),p=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=O(a,{id:D(`nav_dash`),type:`dashboard`,label:n||t,dashboardName:t,icon:`LayoutDashboard`}),s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.addedDashboard`,{name:n||t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),m=(0,g.useCallback)(async(e,t)=>{let n=d(e);if(!n)return;let i=n.navigation??[],a=k(i,`page`,t);if(j(a,i))return;let o={...n,navigation:a};try{await l(e,o),u.success(r(`navigationSync.removedPage`,{name:t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...n,navigation:i}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),_=(0,g.useCallback)(async(e,t)=>{let n=d(e);if(!n)return;let i=n.navigation??[],a=k(i,`dashboard`,t);if(j(a,i))return;let o={...n,navigation:a};try{await l(e,o),u.success(r(`navigationSync.removedDashboard`,{name:t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...n,navigation:i}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),v=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=A(a,`page`,t,n);if(j(o,a))return;let s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.renamedPage`,{oldName:t,newName:n}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),y=(0,g.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=A(a,`dashboard`,t,n);if(j(o,a))return;let s={...i,navigation:o};try{await l(e,s),u.success(r(`navigationSync.renamedDashboard`,{oldName:t,newName:n}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await l(e,{...i,navigation:a}),u.info(r(`navigationSync.undone`))}catch{u.error(r(`navigationSync.undoFailed`))}}}})}catch{u.error(r(`navigationSync.updateFailed`))}},[d,l,r]),b=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return{syncPageCreated:f,syncDashboardCreated:p,syncPageDeleted:m,syncDashboardDeleted:_,syncPageRenamed:v,syncDashboardRenamed:y,syncPageCreatedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await f(t,e,n)}},[t,f]),syncDashboardCreatedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await p(t,e,n)}},[t,p]),syncPageDeletedAllApps:(0,g.useCallback)(async e=>{for(let n of t){let t=b(n);!t||!M(n)||await m(t,e)}},[t,m]),syncDashboardDeletedAllApps:(0,g.useCallback)(async e=>{for(let n of t){let t=b(n);!t||!M(n)||await _(t,e)}},[t,_]),syncPageRenamedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await v(t,e,n)}},[t,v]),syncDashboardRenamedAllApps:(0,g.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!M(r)||await y(t,e,n)}},[t,y])}}function P(){let{pages:e,dashboards:t,apps:n,getTypeStatus:r}=c(),i=a(),o=(0,g.useRef)(i);o.current=i;let s=d(),{syncPageCreated:l,syncDashboardCreated:u,syncPageDeleted:f,syncDashboardDeleted:p}=N(),m=(0,g.useRef)(null),h=(0,g.useRef)(null),_=(0,g.useRef)(0),v=(0,g.useRef)(!1),y=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return(0,g.useEffect)(()=>{if(v.current)return;if(s){m.current=null,h.current=null;return}if(r&&(r(`page`)!==`ready`||r(`dashboard`)!==`ready`))return;let i=e=>new Set(e.filter(e=>!oe(e)).map(e=>e?.name).filter(e=>typeof e==`string`&&e.length>0)),a=i(e??[]),o=i(t??[]),c=m.current,d=h.current;if(c===null||d===null){m.current=a,h.current=o;return}let g=[...a].filter(e=>!c.has(e)),b=[...c].filter(e=>!a.has(e)),x=[...o].filter(e=>!d.has(e)),S=[...d].filter(e=>!o.has(e));if(g.length===0&&b.length===0&&x.length===0&&S.length===0){m.current=a,h.current=o;return}let C=++_.current;v.current=!0;let w=!1;return(async()=>{try{for(let e of n){if(w||_.current!==C)break;let t=y(e);if(!(!t||!M(e))){for(let e of g){if(w)break;await l(t,e)}for(let e of b){if(w)break;await f(t,e)}for(let e of x){if(w)break;await u(t,e)}for(let e of S){if(w)break;await p(t,e)}}}}finally{_.current===C&&(m.current=a,h.current=o,v.current=!1)}})(),()=>{w=!0}},[e,t,n,s,r,l,u,f,p]),null}var F=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`]);function I(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function L(e){try{return decodeURIComponent(e)}catch{return e}}function se({pathname:e,appName:t,objects:n=[],basePathSegment:r=`apps`,disabled:i=!1}){let{addRecentItem:a}=p(),o=(0,g.useRef)(n);o.current=n,(0,g.useEffect)(()=>{if(i||!t)return;let n=e.split(`/`).filter(Boolean);if(n[0]!==r||n[1]!==t)return;let s=n[2],c=n[3],l=`/${r}/${t}`;if(s===`metadata`){let e=n[3],t=n[4];e&&t&&t!==`new`&&a({id:`metadata:${e}:${L(t)}`,label:L(t),href:`${l}/metadata/${e}/${t}`,type:`metadata`});return}if(s&&!F.has(s)){let e=o.current.find(e=>e.name===s);e&&a({id:`object:${e.name}`,label:e.label||e.name,href:`${l}/${e.name}`,type:`object`});return}if(c)switch(s){case`dashboard`:a({id:`dashboard:${c}`,label:I(c),href:`${l}/dashboard/${c}`,type:`dashboard`});break;case`page`:a({id:`page:${c}`,label:I(c),href:`${l}/page/${c}`,type:`page`});break;case`report`:a({id:`report:${c}`,label:I(c),href:`${l}/report/${c}`,type:`report`});break;default:break}},[e,t,r,i])}function ce(e){return{status:`drafted`,drafted:e.items,...e.summary?{summary:e.summary}:{},...e.packageId?{packageId:e.packageId}:{},...e.autoPublishable?{autoPublishable:!0}:{},...e.failedCount?{failed:Array.from({length:e.failedCount},()=>null)}:{},...e.materialized?{materialized:!0}:{},...e.verification?{verification:e.verification}:{},...e.issues&&e.issues.length?{issues:e.issues}:{},...e.nextSteps&&e.nextSteps.length?{nextSteps:e.nextSteps}:{}}}function le(e){return{status:`blueprint_proposed`,...e.summary?{summary:e.summary}:{},counts:e.counts,questions:e.questions,...e.targetApp?{targetApp:e.targetApp}:{},blueprint:{objects:e.objects.map(e=>({name:e.name,...e.label?{label:e.label}:{},fields:Array.from({length:e.fieldCount},()=>null)})),assumptions:e.assumptions}}}var R=`objectstack:ai-chat-conversation-id`,z=`objectstack:ai-chat-messages`;function B(e,t){return t?`${R}:${e}:${t}`:`${R}:${e}`}function V(e){try{return localStorage.getItem(e)??void 0}catch{return}}function H(e,t){try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}}function U(e){return`${z}:${e}`}function W(e){try{let t=localStorage.getItem(U(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`&&(e.role===`user`||e.role===`assistant`||e.role===`system`)&&Array.isArray(e.parts)):[]}catch{return[]}}function G(e,t){if(e)try{if(t.length===0){localStorage.removeItem(U(e));return}localStorage.setItem(U(e),JSON.stringify(t))}catch{}}function ue(e){return e.map(e=>{let t=[];if(e.content&&t.push({type:`text`,text:e.content}),e.role===`assistant`)for(let n of e.toolInvocations??[]){let e=n.draftReview?ce(n.draftReview):n.proposedPlan?le(n.proposedPlan):void 0;t.push({type:`tool-${n.toolName}`,toolCallId:n.toolCallId,toolName:n.toolName,state:n.state??(n.errorText?`output-error`:`output-available`),...n.errorText?{errorText:n.errorText}:{},...e===void 0?{}:{output:e}})}if(t.length!==0)return{id:e.id,role:e.role,parts:t}}).filter(e=>!!e)}function K(e){return typeof e==`string`?e?[{type:`text`,text:e}]:[]:Array.isArray(e)?e.map(e=>{if(typeof e==`string`)return e?{type:`text`,text:e}:void 0;if(e&&typeof e==`object`&&`type`in e&&typeof e.type==`string`)return e;if(e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`)return{type:`text`,text:e.text}}).filter(e=>!!e):e&&typeof e==`object`&&`parts`in e&&Array.isArray(e.parts)?K(e.parts):[]}function de(e,t){for(let n of K(e)){let e=typeof n.toolCallId==`string`?n.toolCallId:void 0;if(!e)continue;let r=t.get(e);if(!r)continue;let i=n.output??n.result;if(i===void 0)continue;r.output=i;let a=n.errorText;r.state=n.isError||typeof a==`string`?`output-error`:`output-available`,typeof a==`string`&&(r.errorText=a)}}function q(e){if(!e)return[];let t=[],n=new Map;return e.forEach((e,r)=>{let i=e.role;if(i===`tool`){de(e.content,n);return}if(i!==`user`&&i!==`assistant`&&i!==`system`)return;let a=K(e.content);if(a.length!==0){if(i===`assistant`)for(let e of a){e.type===`tool-call`&&typeof e.toolName==`string`&&e.toolName&&(e.type=`tool-${e.toolName}`);let t=typeof e.toolCallId==`string`?e.toolCallId:void 0;t&&(e.type===`tool-call`||e.type.startsWith(`tool-`))&&n.set(t,e)}t.push({id:e.id??`msg-${r}`,role:i,parts:a})}}),t}function J(e){if(!(typeof e!=`string`||!e))try{let t=JSON.parse(e);return Array.isArray(t)?t:void 0}catch{return}}function fe(e){return e?e.map(e=>{let t=e.id,n=typeof e.content==`string`?e.content:``;if(e.role===`assistant`){let r=J(e.tool_calls);if(r&&r.length>0){let e=[];return n&&e.push({type:`text`,text:n}),e.push(...r),{id:t,role:`assistant`,content:e}}return{id:t,role:`assistant`,content:n}}if(e.role===`tool`){let r=J(e.content);return r&&r.length>0&&r[0]?.type===`tool-result`?{id:t,role:`tool`,content:r}:{id:t,role:`tool`,content:[{type:`tool-result`,toolCallId:e.tool_call_id??``,toolName:`unknown`,output:{type:`text`,value:n}}]}}return{id:t,role:e.role,content:n}}):[]}async function Y(e,t){let n=await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{credentials:`include`});if(n.status===404||n.status===403)return null;if(!n.ok)throw Error(`GET conversation failed: ${n.status}`);return await n.json()}async function X(e){let t=await fetch(`${e}/conversations`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok)throw Error(`POST conversation failed: ${t.status}`);return await t.json()}async function pe(e,t){await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`include`}).catch(()=>{})}function Z(e){let{userId:t,scope:n,apiBase:r,activeId:i,forceNew:a}=e,[o,s]=(0,g.useState)(void 0),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(!!t),f=(0,g.useRef)(!0),p=(0,g.useRef)(void 0),m=(0,g.useRef)(void 0);(0,g.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]),(0,g.useEffect)(()=>{if(!t){s(void 0),l([]),d(!1),p.current=void 0,m.current=void 0;return}let e=m.current!==n;if(!i&&!a&&!e&&p.current===t&&o)return;let c=!1,u=B(t,n);return!i&&(a||e&&p.current===t)&&(s(void 0),l([])),d(!0),(async()=>{try{if(i){let e=await Y(r,i);if(c)return;if(e){H(u,e.id),s(e.id);let r=q(e.messages);l(r.length>0?r:W(e.id)),p.current=t,m.current=n;return}H(u,void 0),G(i,[])}else if(!a){let e=V(u);if(e){let i=await Y(r,e);if(c)return;if(i){s(i.id);let e=q(i.messages);l(e.length>0?e:W(i.id)),p.current=t,m.current=n;return}H(u,void 0),G(e,[])}}let e=await X(r);if(c)return;H(u,e.id),s(e.id),l(q(e.messages)),p.current=t,m.current=n}catch{c||(s(void 0),l([]))}finally{c||d(!1)}})(),()=>{c=!0}},[t,n,r,i,a]);let h=(0,g.useCallback)(async()=>{if(!t)return;let e=B(t,n);d(!0);try{o&&await pe(r,o),G(o,[]),H(e,void 0);let t=await X(r);if(H(e,t.id),G(t.id,[]),!f.current)return;s(t.id),l([])}catch{f.current&&(s(void 0),l([]))}finally{f.current&&d(!1)}},[o,t,n,r]);return{conversationId:o,conversationScope:m.current,initialMessages:c,isLoading:u,reset:h}}var me=new Set([`new chat`,`new conversation`,`untitled`,`新对话`]);function he(e){let t=e?.trim().toLowerCase();return!t||me.has(t)}function ge(e){let t=e.messages;if(!t||t.length===0)return;for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.role===`user`){let e=Q(n.content);if(e)return e}}let n=t[t.length-1];return Q(n?.content)}function Q(e){if(typeof e==`string`)return e.slice(0,140);if(e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`)return e.text.slice(0,140);if(e&&typeof e==`object`&&`parts`in e&&Array.isArray(e.parts))return Q(e.parts);if(Array.isArray(e)){let t=e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).join(``);return t?t.slice(0,140):void 0}}function $(e){let t=e.title?.trim(),n=ge(e)??Q(e.preview);return{id:e.id,title:he(t)?void 0:t,agentId:e.agentId,createdAt:e.createdAt,updatedAt:e.updatedAt,preview:n}}async function _e(e,t){let n=await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{credentials:`include`});if(!n.ok)return;let r=await n.json();return $(`conversation`in r&&r.conversation?r.conversation:r)}function ve(e){let{userId:t,apiBase:n,limit:r=50,refreshKey:i}=e,[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(!!t),[l,u]=(0,g.useState)(void 0),[d,f]=(0,g.useState)(0),p=(0,g.useCallback)(async()=>{f(e=>e+1)},[]),m=(0,g.useCallback)(async e=>{try{await fetch(`${n}/conversations/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`})}finally{o(t=>t.filter(t=>t.id!==e))}},[n]),h=(0,g.useCallback)(async(e,t)=>{let r=t.trim();o(t=>t.map(t=>t.id===e?{...t,title:r||void 0}:t));let i=await fetch(`${n}/conversations/${encodeURIComponent(e)}`,{method:`PATCH`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:r})});if(!i.ok)throw f(e=>e+1),Error(`PATCH conversation failed: ${i.status}`)},[n]);return(0,g.useEffect)(()=>{if(!t){o([]),c(!1),u(void 0);return}let e=!1;return c(!0),u(void 0),(async()=>{try{let t=await fetch(`${n}/conversations?limit=${encodeURIComponent(String(r))}`,{credentials:`include`});if(!t.ok)throw Error(`GET conversations failed: ${t.status}`);let i=await t.json(),a=Array.isArray(i)?i:i.conversations??i.items??[];if(e)return;let s=a.map($).sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));o(s);let c=s.filter(e=>!e.title&&!e.preview).slice(0,20);if(c.length>0){let t=await Promise.all(c.map(e=>_e(n,e.id).catch(()=>void 0)));if(e)return;let r=new Map(t.filter(e=>!!(e?.preview||e?.title)).map(e=>[e.id,e]));r.size>0&&o(e=>e.map(e=>{let t=r.get(e.id);return t?{...e,title:e.title??t.title,preview:e.preview??t.preview}:e}))}}catch(t){if(e)return;u(t instanceof Error?t:Error(String(t))),o([])}finally{e||c(!1)}})(),()=>{e=!0}},[t,n,r,d,i]),{conversations:a,isLoading:s,error:l,refetch:p,remove:m,rename:h}}async function ye(e){let t=await fetch(`/api/v1/meta/_drafts?packageId=${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok)throw Error(`_drafts HTTP ${t.status}`);let n=await t.json(),r=Array.isArray(n)?n:n?.drafts??n?.data?.drafts??[];return Array.isArray(r)?r.length:0}function be(e){if(!e||e.length===0)return!1;let t=e[e.length-1];return!t||t.role!==`assistant`?!1:t.parts.some(e=>e.type===`text`&&String(e.text??``).trim().length>0)}function xe(e){let{chatApi:t,conversationId:n}=e,[r,i]=(0,g.useState)(!1),a=(0,g.useRef)(void 0);return{errorSuppressed:r,handleChatError:(0,g.useCallback)(async e=>{let r=t?.replace(/\/agents\/[^/]+\/chat$/,``);if(!n||!r){i(!1);return}try{let e=q((await Y(r,n))?.messages);if(be(e)&&a.current){a.current(e),i(!0);return}}catch{}i(!1)},[n,t]),setMessagesRef:a,resetSuppression:(0,g.useCallback)(()=>i(!1),[])}}export{Y as a,Z as c,P as d,ie as f,_ as g,y as h,fe as i,G as l,C as m,ye as n,ue as o,ee as p,ve as r,q as s,xe as t,se as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=new Set([`created_by`,`updated_by`,`owner_id`]);function t(e){return e?Array.isArray(e)?e.filter(e=>e&&e.name!=null).map(e=>[String(e.name),e]):Object.entries(e):[]}function n(n,r){if(!n?.name||!Array.isArray(r)||r.length===0)return[];let i=n.name,a=[],o=[],s=new Set;for(let n of r)if(!(!n?.name||n.name===i))for(let[r,c]of t(n.fields)){if(!c)continue;let t=c.type;if(t!==`lookup`&&t!==`master_detail`||(c.reference_to||c.reference)!==i||e.has(r)||c.relatedList===!1||s.has(n.name))continue;s.add(n.name);let l={childObject:n.name,childLabel:n.label||n.name,referenceField:r,isOwned:t===`master_detail`,...typeof c.relatedListTitle==`string`&&c.relatedListTitle?{title:c.relatedListTitle}:{},...Array.isArray(c.relatedListColumns)&&c.relatedListColumns.length>0?{columns:c.relatedListColumns}:{}};(l.isOwned?a:o).push(l);break}return[...a,...o]}function r(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var i=`\0`,a=`[-\\u2013\\u2014|/·,:]`;function o(e,t){let n=typeof e==`string`?e:e&&typeof e==`object`&&typeof e.source==`string`?e.source:void 0;if(!n||!t)return t?.id||t?._id||`Record`;let r=!1,o=n.replace(/\{([^{}]+)\}/g,(e,n)=>{let a=String(n).trim().split(`.`),o=t;for(let e of a){if(o==null)break;o=o[e]}if(o&&typeof o==`object`){let e=o,t=e.name??e.full_name??e.display_name??e.label??e.title??e.subject??null;(t==null||typeof t==`string`&&!t.trim())&&(t=[e.salutation,e.first_name,e.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e.email==`string`&&e.email.trim()?e.email.trim():null)),o=t}return o==null||o===``?i:(r=!0,String(o))});if(!r)return``;let s=RegExp(`\\s*${a}\\s*${i}`,`g`),c=RegExp(`${i}\\s*${a}\\s*`,`g`);return o=o.replace(s,``).replace(c,``).replace(new RegExp(i,`g`),``).replace(/\s+/g,` `).trim(),o}function s(e,t){if(e?.titleFormat){let n=o(e.titleFormat,t);if(n)return n}return t?.name||t?.full_name||t?.fullName||t?.title||t?.label||t?.subject||t?.id||t?._id||`Untitled`}export{r as n,n as r,s as t};
|
package/dist/index.html
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
<script>
|
|
19
19
|
window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
|
|
20
20
|
</script>
|
|
21
|
-
<script type="module" crossorigin src="./assets/index-
|
|
21
|
+
<script type="module" crossorigin src="./assets/index-Vh0-yrfs.js"></script>
|
|
22
22
|
<link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
|
|
23
23
|
<link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
|
|
24
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
25
|
-
<link rel="modulepreload" href="./assets/framework-
|
|
26
|
-
<link rel="modulepreload" href="./assets/ui-components-
|
|
24
|
+
<link rel="stylesheet" crossorigin href="./assets/index-_u4ypVlX.css">
|
|
25
|
+
<link rel="modulepreload" href="./assets/framework-CQlIjbCT.js" />
|
|
26
|
+
<link rel="modulepreload" href="./assets/ui-components-CgiD1ql5.js" />
|
|
27
27
|
<link rel="modulepreload" href="./assets/vendor-radix-90T7eS-d.js" />
|
|
28
28
|
<link rel="modulepreload" href="./assets/vendor-react-ClIa1CJA.js" />
|
|
29
29
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/console",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
|
package/LICENSE.apache
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute
|
|
108
|
-
must include a readable copy of the attribution notices
|
|
109
|
-
contained within such NOTICE file, excluding those notices
|
|
110
|
-
that do not pertain to any part of the Derivative Works,
|
|
111
|
-
in at least one of the following places: within a NOTICE
|
|
112
|
-
text file distributed as part of the Derivative Works; within
|
|
113
|
-
the Source form or documentation, if provided along with
|
|
114
|
-
the Derivative Works; or, within a display generated by the
|
|
115
|
-
Derivative Works, if and wherever such third-party notices
|
|
116
|
-
normally appear. The contents of the NOTICE file are for
|
|
117
|
-
informational purposes only and do not modify the License.
|
|
118
|
-
You may add Your own attribution notices within Derivative
|
|
119
|
-
Works that You distribute, alongside or as an addendum to
|
|
120
|
-
the NOTICE text from the Work, provided that such additional
|
|
121
|
-
attribution notices cannot be construed as modifying the
|
|
122
|
-
License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright 2026 ObjectStack
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-CsYa1Kaj.js";import{As as i,Ci as a,Cr as o,Gn as s,Hr as c,Ii as l,Ki as u,Kn as d,Ms as f,Ns as p,Pa as m,Wi as h,Wn as g,cs as _,er as v,es as ee,uo as y}from"./ui-components-DXl7VfQF.js";import"./src-ZyouQodC.js";var b=e(t(),1),x=[`plugin`,`plugins`,`kind`,`package`];function S(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var C={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function w(e,t){let n=C[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function te(){let e=r(),[t,n]=(0,b.useState)([]),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(null),u=(0,b.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(C)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...w(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),m=d.filter(e=>!x.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...S(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`];n(Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,b.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var T=n(),E={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},ne={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},re=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],D=1;function O(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:x}=te(),[S,C]=(0,b.useState)(``),[w,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(null),[ie,j]=(0,b.useState)(``),[ae,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(null),[V,H]=(0,b.useState)([]),[U,oe]=(0,b.useState)(null),[W,G]=(0,b.useState)(!1),K=(0,b.useMemo)(()=>{if(!S)return t;let e=S.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,S]),se=(0,b.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,b.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,b.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());return e.length===0?J:`${J}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[J,F]),X=(0,b.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:D++,key:e,value:t,enabled:!0}])},[]),le=(0,b.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,b.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,b.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,b.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();B({status:r.status,body:a,duration:i}),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,b.useCallback)(e=>{j(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:D++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,b.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,T.jsx)(`button`,{onClick:x,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,T.jsx)(l,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(a,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(m,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(y,{className:`h-6 w-6 opacity-30 mb-2`}),(0,T.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,T.jsxs)(g,{open:t,onOpenChange:()=>se(e.key),children:[(0,T.jsx)(d,{asChild:!0,children:(0,T.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,T.jsx)(i,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,T.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,T.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,T.jsx)(s,{children:(0,T.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,T.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,T.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,T.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,T.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(h,{className:`h-3 w-3`}),`Add`]})]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,T.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,T.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,T.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,T.jsx)(o,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`select`,{value:q,onChange:e=>j(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${E[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))}),(0,T.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,T.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,T.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,T.jsx)(u,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,T.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,T.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(m,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,T.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,T.jsx)(_,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,T.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,T.jsx)(p,{className:`h-3 w-3`}):(0,T.jsx)(ee,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,T.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,T.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,T.jsx)(y,{className:`h-10 w-10 mx-auto opacity-20`}),(0,T.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,T.jsx)(`strong`,{children:`Send`})]}),(0,T.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,T.jsxs)(`div`,{className:`border-t`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,T.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,T.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(c,{className:`h-3 w-3`}),`Clear`]})]}),(0,T.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,T.jsxs)(`div`,{className:`rounded border`,children:[(0,T.jsxs)(`button`,{onClick:()=>oe(U===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[U===e.id?(0,T.jsx)(f,{className:`h-3 w-3 shrink-0`}):(0,T.jsx)(i,{className:`h-3 w-3 shrink-0`}),(0,T.jsx)(v,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,T.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,T.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,T.jsx)(u,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,T.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{O as ApiConsolePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{A as a}from"./framework-CsYa1Kaj.js";import{Bo as o,Ci as s,Hr as c,Jn as l,Ua as u,Ur as d,Wi as f,Wr as p,Yn as m,Zi as h,er as g,gr as _,nn as v,qn as y,ri as b}from"./ui-components-DXl7VfQF.js";import{r as x}from"./vendor-ui-utils-C92Fl7BT.js";import"./src-ZyouQodC.js";var S=e(t(),1);function C(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var w=r();function T(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,{apps:T,refresh:E}=a(),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(new Set),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(!1),F=(T||[]).filter(e=>{if(!D)return!0;let t=D.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),I=(0,S.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=(0,S.useCallback)(()=>{k.size===F.length?A(new Set):A(new Set(F.map(e=>e.name)))},[k.size,F]),R=(0,S.useCallback)(async e=>{P(!0);try{let t=e.active===!1;x.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await E()}catch{x.error(`Failed to toggle app status`)}finally{P(!1)}},[E]),z=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${e.label||e.name} set as default`),await E()}catch{x.error(`Failed to set default app`)}finally{P(!1)}},[E]),B=(0,S.useCallback)(async e=>{if(j!==e.name){M(e.name);return}P(!0);try{x.success(`${e.label||e.name} deleted`),M(null),await E()}catch{x.error(`Failed to delete app`)}finally{P(!1)}},[j,E]),V=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${k.size} apps ${e?`enabled`:`disabled`}`),A(new Set),await E()}catch{x.error(`Bulk operation failed`)}finally{P(!1)}},[k,E]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,w.jsxs)(_,{onClick:()=>e(`${r}/create-app`),"data-testid":`create-app-btn`,children:[(0,w.jsx)(f,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,w.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,w.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(v,{id:`app-search`,placeholder:`Search apps...`,value:D,onChange:e=>O(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),k.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(g,{variant:`secondary`,children:[k.size,` selected`]}),(0,w.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>V(!0),disabled:N,children:`Enable`}),(0,w.jsx)(_,{variant:`outline`,size:`sm`,onClick:()=>V(!1),disabled:N,children:`Disable`})]})]}),F.length>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(y,{id:`select-all-apps`,checked:k.size===F.length&&F.length>0,onCheckedChange:()=>L()}),(0,w.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,F.length,`)`]})]}),F.length===0?(0,w.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,w.jsx)(u,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{children:`No apps found.`})]}):(0,w.jsx)(`div`,{className:`grid gap-3`,children:F.map(t=>{let n=t.active!==!1,i=t.isDefault===!0,a=j===t.name;return(0,w.jsx)(l,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,w.jsxs)(m,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,w.jsx)(y,{id:`select-app-${t.name}`,checked:k.has(t.name),onCheckedChange:()=>I(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,w.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,w.jsx)(u,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`font-medium truncate`,children:C(t.label)||t.name}),i&&(0,w.jsx)(g,{variant:`default`,className:`text-xs`,children:`Default`}),(0,w.jsx)(g,{variant:n?`secondary`:`outline`,className:`text-xs`,children:n?`Active`:`Inactive`})]}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:C(t.description)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t._packageId??t.name}`),children:(0,w.jsx)(o,{className:`h-4 w-4`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${r}/edit-app/${t.name}`),children:(0,w.jsx)(h,{className:`h-4 w-4`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:n?`Disable app`:`Enable app`,"aria-label":n?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>R(t),disabled:N,children:n?(0,w.jsx)(d,{className:`h-4 w-4`}):(0,w.jsx)(p,{className:`h-4 w-4`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>z(t),disabled:N||i,children:(0,w.jsx)(b,{className:`h-4 w-4 ${i?`fill-current text-yellow-500`:``}`})}),(0,w.jsx)(_,{variant:`ghost`,size:`icon`,title:a?`Click again to confirm delete`:`Delete app`,"aria-label":a?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>B(t),disabled:N,className:a?`text-destructive`:``,children:(0,w.jsx)(c,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{T as AppManagementPage};
|