@objectstack/console 9.11.0 → 10.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-497l4p4y.js +1 -0
- package/dist/assets/{AiPendingActionsPage-DBH0IlpT.js → AiPendingActionsPage-ux0cUuun.js} +1 -1
- package/dist/assets/{ApiConsolePage-BV14INY2.js → ApiConsolePage-uUkhblGX.js} +1 -1
- package/dist/assets/{AppDocsIndex-C22gKPwi.js → AppDocsIndex-BSiJIyVl.js} +1 -1
- package/dist/assets/{AppManagementPage-DTh0NujK.js → AppManagementPage-COxgYP-L.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-Dfa8zdNx.js +1 -0
- package/dist/assets/{AuditLogPage-B_Zg_tx5.js → AuditLogPage-DD_8Xcar.js} +1 -1
- package/dist/assets/{ComponentNavView-BhShg1Hw.js → ComponentNavView-BxuZYn-k.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-DEn_10k3.js +1 -0
- package/dist/assets/DashboardView-Ca89ME-z.js +1 -0
- package/dist/assets/DashboardWidgetInspector-DKZkel6E.js +1 -0
- package/dist/assets/{DeveloperHubPage--9rLh7im.js → DeveloperHubPage-fRcSSqZS.js} +1 -1
- package/dist/assets/{ExpressionProvider-B9tL1RMW.js → ExpressionProvider-CHhp2xGN.js} +1 -1
- package/dist/assets/FlowRunsPage-dkCyzr_z.js +1 -0
- package/dist/assets/{IntegrationsPage-CMt7Atqp.js → IntegrationsPage-BsKw9532.js} +2 -2
- package/dist/assets/InterfaceListPage-BChUfRxQ.js +1 -0
- package/dist/assets/{ManagedByBadge-BF_1ck8d.js → ManagedByBadge-By7dMA5p.js} +1 -1
- package/dist/assets/MarketplaceAccessDenied-BfvByBjR.js +1 -0
- package/dist/assets/{MarketplaceInstalledPage-DBh3sDdm.js → MarketplaceInstalledPage-DvncMfVp.js} +1 -1
- package/dist/assets/MarketplacePackagePage-BLKOlOvZ.js +4 -0
- package/dist/assets/MarketplacePage-Dkjj-Z_o.js +1 -0
- package/dist/assets/MetadataInspector-DXNojk_m.js +1 -0
- package/dist/assets/{MetadataProvider-xgIDLxXw.js → MetadataProvider-0eg8cMSY.js} +1 -1
- package/dist/assets/{MonacoImpl-BsJjT9SV.js → MonacoImpl-VsaaS7Wx.js} +1 -1
- package/dist/assets/{PageView-pabqNsbK.js → PageView-DCLMAUNP.js} +1 -1
- package/dist/assets/ProfilePage-D4gJzhqR.js +1 -0
- package/dist/assets/PublicFormsPage-C46q0LJ_.js +1 -0
- package/dist/assets/RecordDetailView-B11-8-pz.js +9 -0
- package/dist/assets/{RecordFormPage-Dh_BBkOw.js → RecordFormPage-CmfCTKov.js} +1 -1
- package/dist/assets/ReportDefaultInspector-CRLMz2jp.js +7 -0
- package/dist/assets/ReportView-B4fZ9FuM.js +2 -0
- package/dist/assets/{SearchResultsPage-BPgmZAb1.js → SearchResultsPage-BjfVk8_a.js} +1 -1
- package/dist/assets/{SettingsHub-B47RbJU1.js → SettingsHub-C_eMjvQA.js} +1 -1
- package/dist/assets/{SettingsView-B75wJU1L.js → SettingsView-BRVJ5Qgf.js} +1 -1
- package/dist/assets/SystemHubPage-X9aTvTMd.js +1 -0
- package/dist/assets/architecture-7EHR7CIX-X1S5OWmc.js +1 -0
- package/dist/assets/{architectureDiagram-3BPJPVTR-SscyJlk0.js → architectureDiagram-3BPJPVTR-MvRuEgzs.js} +1 -1
- package/dist/assets/{assistantBus-3d9MxsCF.js → assistantBus-BMrg1uLy.js} +1 -1
- package/dist/assets/blockDiagram-GPEHLZMM-Bv7ki00F.js +132 -0
- package/dist/assets/{c4Diagram-AAUBKEIU-VLeNt7tD.js → c4Diagram-AAUBKEIU-BRUAUvfZ.js} +1 -1
- package/dist/assets/channel-BqPJ7J2_.js +1 -0
- package/dist/assets/{chunk-2J33WTMH-DyXQVMuc.js → chunk-2J33WTMH-DTuZqhEo.js} +1 -1
- package/dist/assets/{chunk-3OPIFGDE-3g0dk_di.js → chunk-3OPIFGDE-C_qRhnNp.js} +1 -1
- package/dist/assets/{chunk-4BX2VUAB-BpAZJ7ZC.js → chunk-4BX2VUAB-Curilu76.js} +1 -1
- package/dist/assets/chunk-55IACEB6-ClqERWh2.js +1 -0
- package/dist/assets/chunk-5ZQYHXKU-NIbfS0Mi.js +2 -0
- package/dist/assets/{chunk-727SXJPM-DwSFE_v-.js → chunk-727SXJPM-C9Y2Btvf.js} +1 -1
- package/dist/assets/{chunk-AQP2D5EJ-DWgSztUW.js → chunk-AQP2D5EJ-CtIyrl6v.js} +1 -1
- package/dist/assets/{chunk-BSJP7CBP-okvguKD4.js → chunk-BSJP7CBP-DjJyEH0K.js} +1 -1
- package/dist/assets/chunk-CSCIHK7Q-DbAqhmGo.js +124 -0
- package/dist/assets/{chunk-FMBD7UC4-CZzqt4RW.js → chunk-FMBD7UC4-DZ7XVMi3.js} +1 -1
- package/dist/assets/{chunk-KSCS5N6A-IxEh4Ag5.js → chunk-KSCS5N6A-DHHPqSRu.js} +2 -2
- package/dist/assets/{chunk-L5ZTLDWV-DW1lPBoG.js → chunk-L5ZTLDWV-Cm-9mVS5.js} +1 -1
- package/dist/assets/{chunk-LZXEDZCA-C_-aaYcd.js → chunk-LZXEDZCA-DNmRzWTq.js} +1 -1
- package/dist/assets/{chunk-ND2GUHAM-C1toj0H3.js → chunk-ND2GUHAM-D-GBTiNx.js} +1 -1
- package/dist/assets/{chunk-NZK2D7GU-H2MwBqQV.js → chunk-NZK2D7GU-CtXqakqk.js} +1 -1
- package/dist/assets/{chunk-O5CBEL6O-BzyWPZhZ.js → chunk-O5CBEL6O-B7H8dfmV.js} +3 -3
- package/dist/assets/chunk-QZHKN3VN-WFr5OVn5.js +1 -0
- package/dist/assets/chunk-WU5MYG2G-DKJgGIni.js +1 -0
- package/dist/assets/{chunk-XPW4576I-DPNxFY7Q.js → chunk-XPW4576I-BnrxXe1_.js} +1 -1
- package/dist/assets/classDiagram-4FO5ZUOK-WH7-26qH.js +1 -0
- package/dist/assets/classDiagram-v2-Q7XG4LA2-WH7-26qH.js +1 -0
- package/dist/assets/{cose-bilkent-S5V4N54A-HKJWDQRL.js → cose-bilkent-S5V4N54A-DhuYtQPb.js} +1 -1
- package/dist/assets/{dagre-BM42HDAG-CU8nx02l.js → dagre-BM42HDAG-Dnyz2UIF.js} +1 -1
- package/dist/assets/{data-adapter-Hh2YXzlW.js → data-adapter-DISUVKTH.js} +1 -1
- package/dist/assets/{diagram-2AECGRRQ-CormMz8j.js → diagram-2AECGRRQ-sHfykK_1.js} +1 -1
- package/dist/assets/{diagram-5GNKFQAL-Dh1SagBx.js → diagram-5GNKFQAL-CQPF5SyR.js} +1 -1
- package/dist/assets/{diagram-KO2AKTUF-DcG6Z05V.js → diagram-KO2AKTUF-DG_jPd_S.js} +1 -1
- package/dist/assets/{diagram-LMA3HP47-DrVLZ6ZE.js → diagram-LMA3HP47-eeIrBazE.js} +1 -1
- package/dist/assets/{diagram-OG6HWLK6-C4_MMUc2.js → diagram-OG6HWLK6-aTF20BV0.js} +1 -1
- package/dist/assets/{dist-DYcwLEm6.js → dist-D80kLFC3.js} +1 -1
- package/dist/assets/{erDiagram-TEJ5UH35-BZH_OrBL.js → erDiagram-TEJ5UH35-CZG8EC14.js} +1 -1
- package/dist/assets/eventmodeling-FCH6USID-y9LH0zSr.js +1 -0
- package/dist/assets/{flowDiagram-I6XJVG4X-CnjHQUK0.js → flowDiagram-I6XJVG4X-Dy6yH4qt.js} +1 -1
- package/dist/assets/framework-DI54pxGD.js +34 -0
- package/dist/assets/{ganttDiagram-6RSMTGT7-rVbHlqzo.js → ganttDiagram-6RSMTGT7-BbnAVyeg.js} +2 -2
- package/dist/assets/{gitGraph-WXDBUCRP-9vsQCBlr.js → gitGraph-WXDBUCRP-CWBdNpUZ.js} +1 -1
- package/dist/assets/{gitGraphDiagram-PVQCEYII-CH2LgClA.js → gitGraphDiagram-PVQCEYII-DQzVZDx1.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-0aDolIZW.js → highlighted-body-OFNGDK62-13WB1hjG.js} +1 -1
- package/dist/assets/index-BnskSwad.css +2 -0
- package/dist/assets/index-Nsh10i14.js +4 -0
- package/dist/assets/{info-J43DQDTF-CfWeH1Bg.js → info-J43DQDTF-BT1tFy_c.js} +1 -1
- package/dist/assets/{infoDiagram-5YYISTIA-CRC7ojj-.js → infoDiagram-5YYISTIA-CL6j94aA.js} +1 -1
- package/dist/assets/infrastructure-BsIvKvpW.js +3 -0
- package/dist/assets/{ishikawaDiagram-YF4QCWOH-8v73fBR1.js → ishikawaDiagram-YF4QCWOH-B2te-ZRn.js} +1 -1
- package/dist/assets/{journeyDiagram-JHISSGLW-DbRK-WaU.js → journeyDiagram-JHISSGLW-lZExleN9.js} +1 -1
- package/dist/assets/{kanban-definition-UN3LZRKU-BggLxHvZ.js → kanban-definition-UN3LZRKU-C9AtY5D5.js} +1 -1
- package/dist/assets/{marketplaceApi-CucX7DD9.js → marketplaceApi-DL8PegzV.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-CnMh6H1N.js +1 -0
- package/dist/assets/{mermaid-parser.core-iuxcj-n_.js → mermaid-parser.core-Fbhy6q19.js} +1 -1
- package/dist/assets/mermaid.core-X9A0zXAG.js +8 -0
- package/dist/assets/metadata-admin-BI5ITi-1.js +21 -0
- package/dist/assets/{mindmap-definition-RKZ34NQL-kqhi9XCR.js → mindmap-definition-RKZ34NQL-BLNposyO.js} +1 -1
- package/dist/assets/{packet-YPE3B663-C0xexAqH.js → packet-YPE3B663-2eu0wHWY.js} +1 -1
- package/dist/assets/{pie-LRSECV5Y-DbQVOiyX.js → pie-LRSECV5Y-BA_jHDuN.js} +1 -1
- package/dist/assets/{pieDiagram-4H26LBE5-9fHcPmFE.js → pieDiagram-4H26LBE5-B_jWIggY.js} +3 -3
- package/dist/assets/plugin-calendar--KxXPKcZ.js +1 -0
- package/dist/assets/plugin-charts-BtGgj50F.js +7 -0
- package/dist/assets/{plugin-chatbot-76fXVh9-.js → plugin-chatbot-BnXRjqnw.js} +53 -53
- package/dist/assets/plugin-dashboard-BJU4e4Lc.js +6 -0
- package/dist/assets/plugin-form-CfWEBrxU.js +1 -0
- package/dist/assets/plugin-gantt-DWE_Yo3S.js +39 -0
- package/dist/assets/plugin-grid-MJIEbrKE.js +6 -0
- package/dist/assets/plugin-kanban-CuXc4XOR.js +1 -0
- package/dist/assets/{plugin-map-C3ZvB3-I.js → plugin-map-BJaiEhqS.js} +1 -1
- package/dist/assets/{plugin-markdown-C0Wtx408.js → plugin-markdown-5mHDCnjJ.js} +1 -1
- package/dist/assets/plugin-report-DXVbwZO1.js +59 -0
- package/dist/assets/{plugin-timeline-BStIRl3O.js → plugin-timeline-CRg278ig.js} +1 -1
- package/dist/assets/plugin-tree-D3iB5Xsc.js +1 -0
- package/dist/assets/plugin-view-DuycwTEq.js +1 -0
- package/dist/assets/plugins-views-FDlQfg4L.js +4 -0
- package/dist/assets/{quadrantDiagram-W4KKPZXB-CaMxia_k.js → quadrantDiagram-W4KKPZXB-DuQbsXa3.js} +1 -1
- package/dist/assets/{radar-GUYGQ44K-DapGfmwo.js → radar-GUYGQ44K-BdSwem6Q.js} +1 -1
- package/dist/assets/{requirementDiagram-4Y6WPE33-CXwY4Gdd.js → requirementDiagram-4Y6WPE33-BS1D5lNA.js} +1 -1
- package/dist/assets/{sankeyDiagram-5OEKKPKP-KEb3hSPZ.js → sankeyDiagram-5OEKKPKP-DGvgs5mF.js} +2 -2
- package/dist/assets/{sequenceDiagram-3UESZ5HK-BfbOOh3M.js → sequenceDiagram-3UESZ5HK-CoXT3Sa8.js} +1 -1
- package/dist/assets/{skeletons-Y2db5nbR.js → skeletons-CCMkzfAg.js} +1 -1
- package/dist/assets/{src-BLxLm3Xq.js → src-BTw3UGh8.js} +1 -1
- package/dist/assets/{src-CVz7aDdY.js → src-B_91OByQ.js} +1 -1
- package/dist/assets/src-KdhDBRhc.js +2 -0
- package/dist/assets/{stateDiagram-AJRCARHV-BLJI6xj_.js → stateDiagram-AJRCARHV-CGBlOS6N.js} +1 -1
- package/dist/assets/stateDiagram-v2-BHNVJYJU-B7qRtpsa.js +1 -0
- package/dist/assets/{timeline-definition-PNZ67QCA-aiklZXLq.js → timeline-definition-PNZ67QCA-C3SxX0_p.js} +1 -1
- package/dist/assets/{treeView-BLDUP644-Byr_7ESV.js → treeView-BLDUP644-LYooC8jV.js} +1 -1
- package/dist/assets/{treemap-LRROVOQU-B6DiJnlo.js → treemap-LRROVOQU-DRMY684K.js} +1 -1
- package/dist/assets/{types-C6YwlE8G.js → types-BXXHtG0t.js} +1 -1
- package/dist/assets/ui-components-BecTKcFn.js +42 -0
- package/dist/assets/ui-layout-BG3TnLjr.js +1 -0
- package/dist/assets/{useActionModal-Dz0k3wwf.js → useActionModal-DezoqP6c.js} +1 -1
- package/dist/assets/useOpenRecordList-DjbGsO2B.js +1 -0
- package/dist/assets/{usePackageL10n-shLsxEAx.js → usePackageL10n-DIEe85Ot.js} +1 -1
- package/dist/assets/useReconcileOnError-Df2Wf71r.js +1 -0
- package/dist/assets/vendor-charts-BMpO4zwC.js +39 -0
- package/dist/assets/{vendor-dndkit-DMFEUxSy.js → vendor-dndkit-CJ-mJJuO.js} +1 -1
- package/dist/assets/{vendor-i18n-Bz5UncqE.js → vendor-i18n-DA5MKfC_.js} +1 -1
- package/dist/assets/{vendor-icons-core-C_yMA5lO.js → vendor-icons-core-y1IwBwLD.js} +1 -1
- package/dist/assets/{vendor-markdown-CyAGIM8D.js → vendor-markdown-BhPWU2N7.js} +1 -1
- package/dist/assets/vendor-objectstack-CMEER4tu.js +96 -0
- package/dist/assets/vendor-radix-90T7eS-d.js +46 -0
- package/dist/assets/vendor-react-ClIa1CJA.js +11 -0
- package/dist/assets/vendor-sentry-DUcsR3Vf.js +501 -0
- package/dist/assets/{vendor-ui-utils-rQOI1gAo.js → vendor-ui-utils-C92Fl7BT.js} +1 -1
- package/dist/assets/{vennDiagram-CIIHVFJN-DsKC4yvC.js → vennDiagram-CIIHVFJN-BWIbAw03.js} +1 -1
- package/dist/assets/{wardley-L42UT6IY-f1iiSYpj.js → wardley-L42UT6IY-zPLhQ1bd.js} +1 -1
- package/dist/assets/{wardleyDiagram-YWT4CUSO-DbrUmWlY.js → wardleyDiagram-YWT4CUSO-Ck_J2TTN.js} +1 -1
- package/dist/assets/{xychartDiagram-2RQKCTM6-B4biX1Sz.js → xychartDiagram-2RQKCTM6-CDqp4wV0.js} +2 -2
- package/dist/index.html +6 -6
- package/package.json +1 -1
- package/dist/assets/AdapterProvider-DQfb2hDB.js +0 -1
- package/dist/assets/ApprovalsInboxPage-C0mBPkCR.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-Ct9u34kL.js +0 -1
- package/dist/assets/DashboardView-D3oJL44H.js +0 -1
- package/dist/assets/DashboardWidgetInspector-BhjBPVJV.js +0 -1
- package/dist/assets/FlowRunsPage-CDYR2nha.js +0 -1
- package/dist/assets/InterfaceListPage-CIYeUsaL.js +0 -1
- package/dist/assets/MarketplaceAccessDenied-DvMKTKZG.js +0 -1
- package/dist/assets/MarketplacePackagePage-DuZ5A7L3.js +0 -4
- package/dist/assets/MarketplacePage-8XMnemHc.js +0 -1
- package/dist/assets/MetadataInspector-BcJZckHC.js +0 -1
- package/dist/assets/ProfilePage-CPP3LKyF.js +0 -1
- package/dist/assets/PublicFormsPage-CJz8WQst.js +0 -1
- package/dist/assets/RecordDetailView-Dg0FtCgX.js +0 -9
- package/dist/assets/ReportDefaultInspector-bXn7Ud0K.js +0 -1
- package/dist/assets/ReportView-CYKdWMWV.js +0 -2
- package/dist/assets/RuntimeDraftBar-CpfEHMPU.js +0 -1
- package/dist/assets/SystemHubPage-DFwicwZT.js +0 -1
- package/dist/assets/architecture-7EHR7CIX-BdMnUPE0.js +0 -1
- package/dist/assets/blockDiagram-GPEHLZMM-D6-9deBJ.js +0 -132
- package/dist/assets/channel-ByUUDCyR.js +0 -1
- package/dist/assets/chunk-55IACEB6-BhOjfCrn.js +0 -1
- package/dist/assets/chunk-5ZQYHXKU-DG12s6lW.js +0 -2
- package/dist/assets/chunk-CSCIHK7Q-DfSAlgJl.js +0 -124
- package/dist/assets/chunk-QZHKN3VN-ujroCBCz.js +0 -1
- package/dist/assets/chunk-WU5MYG2G-DwQt8tuZ.js +0 -1
- package/dist/assets/classDiagram-4FO5ZUOK-B7mTyEXp.js +0 -1
- package/dist/assets/classDiagram-v2-Q7XG4LA2-B7mTyEXp.js +0 -1
- package/dist/assets/eventmodeling-FCH6USID-CFiyy8DS.js +0 -1
- package/dist/assets/framework-DCMHw4uc.js +0 -34
- package/dist/assets/index-DIwBADyw.css +0 -2
- package/dist/assets/index-OUEQY-pz.js +0 -4
- package/dist/assets/infrastructure-CJNwTVno.js +0 -3
- package/dist/assets/mergeServerFields-DLHgCyyI.js +0 -7
- package/dist/assets/mermaid-GHXKKRXX-BkPYaQdJ.js +0 -1
- package/dist/assets/mermaid.core-C41Aiku8.js +0 -8
- package/dist/assets/metadata-admin-CLro8Vr2.js +0 -19
- package/dist/assets/plugin-calendar-BnAXrMpl.js +0 -1
- package/dist/assets/plugin-charts-CqgNZ5dQ.js +0 -7
- package/dist/assets/plugin-dashboard-lpyBUnU3.js +0 -5
- package/dist/assets/plugin-form-DjP7n76r.js +0 -1
- package/dist/assets/plugin-gantt-BRce7Qx4.js +0 -39
- package/dist/assets/plugin-grid-3MIxvbIs.js +0 -6
- package/dist/assets/plugin-kanban-BY5U45PP.js +0 -1
- package/dist/assets/plugin-report-CjGy4oCX.js +0 -59
- package/dist/assets/plugin-view-C15Djdpb.js +0 -1
- package/dist/assets/plugins-views-DvIN271Q.js +0 -4
- package/dist/assets/src-ChUzpvnF.js +0 -2
- package/dist/assets/stateDiagram-v2-BHNVJYJU-DPQJ1_JB.js +0 -1
- package/dist/assets/ui-components-D1FYlKrM.js +0 -42
- package/dist/assets/ui-layout-CL-1JYQ8.js +0 -1
- package/dist/assets/useReconcileOnError-Cxzq30_3.js +0 -1
- package/dist/assets/vendor-charts-fo4ZbB_t.js +0 -39
- package/dist/assets/vendor-objectstack-BNd856rx.js +0 -96
- package/dist/assets/vendor-radix-CSVEhP0L.js +0 -56
- package/dist/assets/vendor-react-DR370ovB.js +0 -11
- package/dist/assets/vendor-sentry-BIOhD5Kg.js +0 -501
|
@@ -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{m as r}from"./infrastructure-BsIvKvpW.js";import{D as i}from"./framework-DI54pxGD.js";import{t as a}from"./data-adapter-DISUVKTH.js";var o=e(t(),1),s=0,c=new Set,l=[];function u(){for(let e of c)try{e(s)}catch{}if(s===0&&l.length>0){let e=l;l=[];for(let t of e)try{t()}catch{}}}function d(){s+=1,u()}function f(){s=Math.max(0,s-1),u()}function p(){return s}function m(){return s===0}function h(e){return c.add(e),()=>{c.delete(e)}}function g(e=1e4){return s===0?Promise.resolve():new Promise(t=>{let n=!1,r=()=>{n||(n=!0,t())};l.push(r),e>0&&typeof setTimeout<`u`&&setTimeout(r,e)})}function _(e){return(async(...t)=>{d();try{return await e(...t)}finally{f()}})}function v(){if(typeof window>`u`)return;let e=window,t=e.__objectui??={};Object.defineProperty(t,"pendingRequests",{get:p,configurable:!0}),Object.defineProperty(t,"idle",{get:m,configurable:!0}),t.whenIdle=g,t.subscribe=h}var y=n();function b({children:e,adapter:t}){let[n,s]=(0,o.useState)(t??null);return(0,o.useEffect)(()=>{if(t){s(t);return}let e=!1;v();async function n(){try{let t=new a({baseUrl:``,fetch:_(r()),autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});await t.connect(),e||s(t)}catch(t){e||console.error(`[Console] Failed to initialize:`,t)}}return n(),()=>{e=!0}},[t]),(0,y.jsx)(i.Provider,{value:n,children:e})}export{b as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{n as r}from"./plugin-chatbot-BnXRjqnw.js";var i=e(t(),1),a=n();function o(){let e={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},t=e.VITE_AI_BASE_URL;return t?t.replace(/\/$/,``):`${(e.VITE_SERVER_URL??``).replace(/\/$/,``)}/api/v1/ai`}function s(){let e=(0,i.useMemo)(()=>o(),[]);return(0,a.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto`,children:[(0,a.jsxs)(`div`,{className:`mb-4`,children:[(0,a.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`AI Approvals`}),(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Review actions an AI agent proposed. Approve to execute them server-side; reject to send a reason back to the model so it can revise the next turn.`})]}),(0,a.jsx)(r,{apiBase:e,variant:`card`,title:`Queue`,description:`Polled every 5 seconds. Decisions are recorded under your identity.`})]})}export{s as AiPendingActionsPage,s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DCMHw4uc.js";import{$n as i,Es as a,Fi as o,Gi as s,Gn as c,Ma as l,Os as u,Si as d,Sr as f,Ui as p,Un as m,Vr as h,Wn as g,Xo as _,is as v,ks as ee,oo as y}from"./ui-components-D1FYlKrM.js";import"./src-ChUzpvnF.js";var b=e(t(),1),x=[`plugin`,`plugins`,`kind`,`package`];function S(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var C={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function w(e,t){let n=C[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function te(){let e=r(),[t,n]=(0,b.useState)([]),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(null),u=(0,b.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(C)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...w(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),m=d.filter(e=>!x.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...S(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`];n(Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,b.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var T=n(),E={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},ne={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},re=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],D=1;function O(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:x}=te(),[S,C]=(0,b.useState)(``),[w,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(null),[ie,j]=(0,b.useState)(``),[ae,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(null),[V,H]=(0,b.useState)([]),[U,oe]=(0,b.useState)(null),[W,G]=(0,b.useState)(!1),K=(0,b.useMemo)(()=>{if(!S)return t;let e=S.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,S]),se=(0,b.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,b.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,b.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());return e.length===0?J:`${J}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[J,F]),X=(0,b.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:D++,key:e,value:t,enabled:!0}])},[]),le=(0,b.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,b.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,b.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,b.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();B({status:r.status,body:a,duration:i}),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,b.useCallback)(e=>{j(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:D++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,b.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,T.jsx)(`button`,{onClick:x,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,T.jsx)(o,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(d,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(y,{className:`h-6 w-6 opacity-30 mb-2`}),(0,T.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,T.jsxs)(m,{open:t,onOpenChange:()=>se(e.key),children:[(0,T.jsx)(c,{asChild:!0,children:(0,T.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,T.jsx)(a,{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)(g,{children:(0,T.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,T.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,T.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,T.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(p,{className:`h-3 w-3`}),`Add`]})]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,T.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,T.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,T.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,T.jsx)(f,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`select`,{value:q,onChange:e=>j(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${E[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))}),(0,T.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,T.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,T.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,T.jsx)(s,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,T.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,T.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(l,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,T.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,T.jsx)(v,{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)(ee,{className:`h-3 w-3`}):(0,T.jsx)(_,{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)(h,{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)(u,{className:`h-3 w-3 shrink-0`}):(0,T.jsx)(a,{className:`h-3 w-3 shrink-0`}),(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,T.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,T.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,T.jsx)(s,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,T.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{O as ApiConsolePage};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-DI54pxGD.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-BecTKcFn.js";import"./src-KdhDBRhc.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 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,a as n,f as r,r as i,t as a}from"./vendor-react-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,a as n,f as r,r as i,t as a}from"./vendor-react-ClIa1CJA.js";import{Pa as o,ec as s}from"./ui-components-BecTKcFn.js";import{a as c,i as l,n as u,r as d}from"./index-Nsh10i14.js";var f=e(t(),1),p=a();function m(){let{appName:e}=r(),{books:t,docs:a,state:m}=u(),h=(0,f.useMemo)(()=>t.filter(t=>l(t)===e),[t,e]),g=(0,f.useMemo)(()=>d(h,a),[h,a]);return m===`loading`?(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,p.jsx)(o,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):g.length===1?(0,p.jsx)(n,{to:`/apps/${e}/docs/${g[0].slug}`,replace:!0}):(0,p.jsx)(c,{children:(0,p.jsx)(`div`,{className:`mx-auto max-w-3xl p-4 sm:p-6`,children:g.length===0?(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,p.jsx)(s,{className:`h-10 w-10`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`This app does not ship any documentation yet.`}),(0,p.jsx)(i,{to:`/docs`,className:`text-sm font-medium text-primary hover:underline`,children:`Browse all documentation`})]}):(0,p.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:g.map(t=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(i,{to:`/apps/${e}/docs/${t.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,p.jsx)(s,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold`,children:t.label}),t.description?(0,p.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:t.description}):t.subtitle?(0,p.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:t.subtitle}):null,(0,p.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[t.docCount,` `,t.docCount===1?`article`:`articles`]})]})]})},t.name))})})})}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-
|
|
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-DI54pxGD.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-BecTKcFn.js";import{r as x}from"./vendor-ui-utils-C92Fl7BT.js";import"./src-KdhDBRhc.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,r,t as i}from"./vendor-react-ClIa1CJA.js";import{d as a,f as ee}from"./infrastructure-BsIvKvpW.js";import{i as te}from"./framework-DI54pxGD.js";import{As as ne,Bo as re,Bt as ie,Ci as ae,Cr as oe,Ft as se,H as ce,Ht as o,Ii as le,It as ue,Jn as de,Lr as fe,Lt as pe,Mr as me,Mt as s,Ns as he,Pt as ge,R as _e,Rt as ve,Si as ye,Ut as be,Vt as xe,Wt as Se,Yn as Ce,Zo as we,ar as Te,at as Ee,cr as c,cs as De,ct as l,dr as u,dt as Oe,er as ke,es as Ae,fc as je,fr as d,gr as f,gs as Me,hr as Ne,ir as Pe,it as Fe,js as Ie,li as Le,lr as p,lt as m,mr as h,nn as Re,nt as ze,on as Be,ot as Ve,pr as g,ps as He,qn as Ue,rc as We,rt as Ge,sr as _,st as Ke,tt as qe,ur as v,ut as Je,ws as Ye,xs as Xe,yc as y,z as Ze,zt as Qe}from"./ui-components-BecTKcFn.js";import{r as b}from"./vendor-ui-utils-C92Fl7BT.js";var x=e(t(),1),$e=`${``.replace(/\/$/,``)}/api/v1`;async function S(e,t){let n=await fetch(`${$e}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.code??`HTTP_${n.status}`,t=r?.message??r?.error??n.statusText,i=Error(`${e}: ${t}`);throw i.code=e,i.status=n.status,i.details=r,i}return r}var C={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return S(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return S(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await S(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return S(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return S(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function et(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.roles||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}var w=i(),tt=50,nt={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function rt(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function T(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function E(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function it(e){return e.process_label||E(e.process_name)}function at(e){return e.step_label?e.step_label:e.current_step?E(e.current_step):null}function ot(e){return e.submitter_name||T(e.submitter_id)}function st(e,t){return t.pending_approver_names?.[e]||T(e)}function ct(e){return e.object_label||e.object_name}function D(e){return e.submitted_at||e.created_at||void 0}function O(e){let t=D(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function lt(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=O(e);return t==null?`text-muted-foreground`:t>72?`text-red-600 dark:text-red-400 font-medium`:t>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function ut(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var k=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function A(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function j(e,t){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var dt=/^[A-Za-z0-9_-]{15,}$/;function ft(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(k.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&dt.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([A(i),e??j(i,a)]),r.length>=n))break}return r}function pt(){let{t:e,language:t}=te(),{user:i}=ee(),$e=a(),{appName:S}=n(),E=(0,x.useMemo)(()=>et(i),[i]),O=(0,x.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),k=(0,x.useCallback)(e=>{if(!e)return`—`;let n=Date.parse(e);if(Number.isNaN(n))return e;let r=Math.round((Date.now()-n)/1e3);if(r<45)return O(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return O(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return O(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return O(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(t)}catch{return e}},[O,t]),A=(0,x.useCallback)(e=>{switch(e){case`pending`:return O(`statusPending`,`Pending`);case`approved`:return O(`statusApproved`,`Approved`);case`rejected`:return O(`statusRejected`,`Rejected`);case`recalled`:return O(`statusRecalled`,`Recalled`);case`returned`:return O(`statusReturned`,`Returned for revision`);default:return e}},[O]),j=(0,x.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?O(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?O(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?O(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?O(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?O(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[O]);function dt({status:e}){return(0,w.jsx)(ke,{variant:`outline`,className:y(`font-medium`,nt[e]??``),children:A(e)})}let pt=(0,x.useCallback)(e=>`/apps/${S||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[S]),[M,mt]=(0,x.useState)(`pending`),[N,ht]=(0,x.useState)([]),[gt,_t]=(0,x.useState)(!1),[vt,yt]=(0,x.useState)(!1),[bt,xt]=(0,x.useState)(null),[St,Ct]=(0,x.useState)(null),[wt,Tt]=(0,x.useState)(0),[P,Et]=(0,x.useState)(null),[F,Dt]=(0,x.useState)(null),[Ot,kt]=(0,x.useState)([]),[At,jt]=(0,x.useState)(!1),[I,L]=(0,x.useState)(``),[R,Mt]=(0,x.useState)(``),[z,Nt]=(0,x.useState)(null),[B,Pt]=(0,x.useState)(``),[Ft,It]=(0,x.useState)(``),[Lt,Rt]=(0,x.useState)(`all`),[zt,Bt]=(0,x.useState)(`all`),[V,Vt]=(0,x.useState)(`all`),[H,Ht]=(0,x.useState)(new Set),[Ut,Wt]=(0,x.useState)(!1),[U,Gt]=(0,x.useState)(null),[Kt,qt]=(0,x.useState)(null),[Jt,Yt]=(0,x.useState)(!1),[Xt,Zt]=(0,x.useState)(``),[Qt,$t]=(0,x.useState)(!1),[en,tn]=(0,x.useState)(``),[nn,rn]=(0,x.useState)(!1),[an,on]=(0,x.useState)(``),[sn,cn]=(0,x.useState)(!1),[ln,un]=(0,x.useState)(``),[W,G]=(0,x.useState)(!1),[dn,fn]=(0,x.useState)([]),[pn,mn]=(0,x.useState)(-1);(0,x.useEffect)(()=>{if(M===`pending`)return;let e=window.setTimeout(()=>It(B),350);return()=>window.clearTimeout(e)},[B,M]);let K=(0,x.useCallback)(async()=>{_t(!0),Ct(null);try{let e=[];if(M===`pending`)e=E.length?(await C.listRequests({status:`pending`,approverId:E})).data:[],Tt(e.length),xt(null);else{let t={q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:0};if(M===`submitted`){let n=i?.id;if(n){let r=await C.listRequests({submitterId:n,...t});e=r.data,xt(r.total??r.data.length)}else e=[],xt(0)}else{let n=await C.listRequests(t);e=n.data,xt(n.total??n.data.length)}E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(D(t)||``).localeCompare(D(e)||``)),ht(e)}catch(e){Ct(e?.message||String(e)),ht([])}finally{_t(!1)}},[M,E,i?.id,Ft,V]);(0,x.useEffect)(()=>{K()},[K]);let hn=(0,x.useCallback)(async()=>{if(!(M===`pending`||vt)){yt(!0);try{let e=await C.listRequests({submitterId:M===`submitted`?i?.id??void 0:void 0,q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:N.length});ht(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&xt(e.total)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`)))}finally{yt(!1)}}},[M,vt,i?.id,Ft,V,N.length,j,O]),q=(0,x.useCallback)(async e=>{Et(e),jt(!0),L(``),Mt(``);try{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`))),Dt(null),kt([])}finally{jt(!1)}},[j,O]),gn=()=>{Et(null),Dt(null),kt([]),L(``),Mt(``)},J=(0,x.useCallback)(e=>{if(R.trim())return R.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of E)if(t.has(e))return e;return i?.id||``},[R,E,i?.id]),Y=(0,x.useCallback)(()=>{E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})},[E]),_n=(0,x.useCallback)(async e=>{if(!F)return;let t=e===`recall`&&i?.id||J(F);if(!t){b.error(O(`noActor`,`Cannot determine the acting identity`));return}Nt(e);try{let n={actor_id:t,comment:I.trim()||void 0},r=await(e===`approve`?C.approve:e===`reject`?C.reject:C.recall)(F.id,n);if(b.success(e===`approve`?r.finalized?O(`approvedFinal`,`Approved`):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?O(`rejectedToast`,`Rejected`):O(`recalledToast`,`Request recalled`)),L(``),e!==`recall`&&M===`pending`){let e=Rn.current,t=e.findIndex(e=>e.id===F.id),n=e[t+1]??e[t-1];K(),n&&n.id!==F.id?q(n.id):gn();return}let[i,a]=await Promise.all([C.getRequest(F.id),C.listActions(F.id)]);Dt(i.data),kt(a.data),K()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{Nt(null)}},[F,J,I,K,i?.id,j,O,M,q]),X=(0,x.useCallback)(async e=>{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data),K()},[K]),vn=(0,x.useCallback)(async()=>{if(!(!F||!Xt.trim())){G(!0);try{await C.reassign(F.id,{actor_id:J(F),to:Xt.trim(),comment:I.trim()||void 0}),b.success(O(`reassignSuccess`,`Handed to {{to}}`,{to:Xt.trim()})),Yt(!1),Zt(``),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,Xt,I,J,X,Y,j,O]),yn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.remind(F.id,{actor_id:i?.id});b.success(O(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e.notified})),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,i?.id,X,j,O]),bn=(0,x.useCallback)(async()=>{if(!(!F||!en.trim())){G(!0);try{await C.requestInfo(F.id,{actor_id:J(F),comment:en.trim()}),b.success(O(`requestInfoSent`,`Sent back to the requester for more information`)),$t(!1),tn(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,en,J,X,j,O]),xn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.sendBack(F.id,{actor_id:J(F),comment:an.trim()||void 0});b.success(e.autoRejected?O(`sendBackAutoRejected`,`Revision limit reached — the request was auto-rejected`):O(`sendBackSuccess`,`Sent back for revision — the requester can now edit and resubmit`)),rn(!1),on(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,an,J,X,Y,j,O]),Sn=(0,x.useCallback)(async()=>{if(F){cn(!0);try{await C.resubmit(F.id,{actor_id:i?.id,comment:I.trim()||void 0}),b.success(O(`resubmitSuccess`,`Resubmitted — a new approval round has opened`)),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{cn(!1)}}},[F,I,i?.id,X,Y,j,O]),Cn=(0,x.useCallback)(async()=>{if(!(!F||!ln.trim())){G(!0);try{await C.comment(F.id,{actor_id:i?.id,comment:ln.trim()}),un(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,ln,i?.id,X,j,O]),wn=(0,x.useCallback)(async()=>{if(!dn.length)try{let e=``.replace(/\/$/,``);fn(((await(await fetch(`${e}/api/v1/data/sys_user?limit=100`,{credentials:`include`})).json()).records||[]).filter(e=>e.email&&e.name&&e.id!==i?.id).map(e=>({name:String(e.name),email:String(e.email)})))}catch{}},[dn.length,i?.id]),Tn=(0,x.useMemo)(()=>{if(!F||F.status!==`pending`)return!1;let e=new Set(F.pending_approvers||[]);return E.some(t=>e.has(t))||R.trim().length>0},[F,E,R]),En=(0,x.useMemo)(()=>!F||F.status!==`pending`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),Dn=(0,x.useMemo)(()=>!F||F.status!==`returned`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),On=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)e.add(it(t));return Array.from(e).sort()},[N]),kn=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[N]),Z=(0,x.useMemo)(()=>{let e=B.trim().toLowerCase();return N.filter(t=>Lt!==`all`&&it(t)!==Lt||zt!==`all`&&t.object_name!==zt||V!==`all`&&t.status!==V?!1:M!==`pending`||!e?!0:[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e))},[N,B,Lt,zt,V,M]),An=(0,x.useMemo)(()=>P?Z.findIndex(e=>e.id===P):-1,[Z,P]);(0,x.useEffect)(()=>{if(H.size===0)return;let e=new Set(Z.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Ht(n)},[Z,H]),(0,x.useEffect)(()=>{pn>=Z.length&&mn(Z.length-1)},[Z.length,pn]);let Q=(0,x.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(E);return(e.pending_approvers||[]).some(e=>t.has(e))},[E]),$=(0,x.useMemo)(()=>Z.filter(e=>H.has(e.id)&&Q(e)),[Z,H,Q]),jn=Z.filter(e=>e.status===`pending`),Mn=jn.length>0&&jn.every(e=>H.has(e.id)),Nn=(0,x.useCallback)(()=>{Ht(e=>{if(Mn)return new Set;let t=new Set(e);for(let e of jn)t.add(e.id);return t})},[Mn,jn]),Pn=(0,x.useCallback)(e=>{Ht(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,x.useCallback)(async e=>{let t=$;if(t.length===0)return;Wt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=E.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?C.approve:C.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||T(a.record_id))}}if(Wt(!1),Ht(new Set),r.length===0)b.success(e===`approve`?O(`bulkApproved`,`Approved {{count}} requests`,{count:n}):O(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);b.error(O(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),Y()},[$,E,i?.id,K,Y,O]),In=(0,x.useCallback)(async e=>{if(!Q(e)||Kt)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id);try{let t=await C.approve(e.id,{actor_id:n});b.success(t.finalized?O(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||T(e.record_id)}):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[Q,Kt,E,i?.id,K,Y,j,O]),Ln=(0,x.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id),Gt(null);try{await C.reject(e.id,{actor_id:n}),b.success(O(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||T(e.record_id)})),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[U,E,i?.id,K,Y,j,O]),Rn=(0,x.useRef)(Z);Rn.current=Z;let zn=(0,x.useRef)(pn);zn.current=pn,(0,x.useEffect)(()=>{let e=e=>{if(P||U)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current;if(!r.length)return;let i=zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),mn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),mn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&M===`pending`?(e.preventDefault(),Pn(r[i].id)):e.key===`a`&&i>=0&&r[i]?(e.preventDefault(),In(r[i])):e.key===`r`&&i>=0&&r[i]&&Q(r[i])&&(e.preventDefault(),Gt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,U,M,q,Pn,In,Q]),(0,x.useEffect)(()=>{if(!P)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current,i=r.findIndex(e=>e.id===P);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,q]);let Bn=!!B||Lt!==`all`||zt!==`all`||V!==`all`,Vn=e=>{mt(e),Vt(`all`),Rt(`all`),Bt(`all`),Pt(``),mn(-1)};function Hn({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`font-medium truncate`,children:it(e)}),(0,w.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[at(e)||`—`,(e.round??1)>1&&(0,w.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Un({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(e),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,w.jsx)(`span`,{className:`truncate`,children:e.record_title||T(e.record_id)}),(0,w.jsx)(re,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:ct(e)})]})}function Wn({r:e}){if(!Q(e))return null;let t=Kt===e.id;return(0,w.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),children:[(0,w.jsx)(f,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:t,onClick:()=>void In(e),"aria-label":O(`approve`,`Approve`),children:(0,w.jsx)(Xe,{className:`h-4 w-4`})}),(0,w.jsx)(f,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:t,onClick:()=>Gt(e),"aria-label":O(`reject`,`Reject`),children:(0,w.jsx)(He,{className:`h-4 w-4`})})]})}return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,w.jsx)(Le,{className:`h-6 w-6`}),O(`title`,`Approvals Inbox`)]}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:O(`subtitle`,`Review and act on approval requests.`)})]}),(0,w.jsxs)(f,{variant:`outline`,size:`sm`,onClick:K,disabled:gt,className:`self-start sm:self-auto`,children:[(0,w.jsx)(le,{className:`h-4 w-4 mr-2 ${gt?`animate-spin`:``}`}),O(`refresh`,`Refresh`)]})]}),St&&(0,w.jsxs)(Pe,{variant:`destructive`,children:[(0,w.jsx)(Ye,{className:`h-4 w-4`}),(0,w.jsx)(Te,{children:St})]}),(0,w.jsxs)(ze,{value:M,onValueChange:Vn,children:[(0,w.jsxs)(Fe,{children:[(0,w.jsxs)(Ee,{value:`pending`,children:[O(`tabMyPending`,`My Pending`),wt>0&&(0,w.jsx)(ke,{variant:`secondary`,className:`ml-2`,children:wt})]}),(0,w.jsx)(Ee,{value:`submitted`,children:O(`tabSubmitted`,`Submitted by me`)}),(0,w.jsx)(Ee,{value:`all`,children:O(`tabAll`,`All`)})]}),(0,w.jsxs)(Ge,{value:M,className:`mt-4 space-y-3`,children:[!gt&&(N.length>0||M!==`pending`&&(Ft||V!==`all`))&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,w.jsx)(ae,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,w.jsx)(Re,{value:B,onChange:e=>Pt(e.target.value),placeholder:O(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,w.jsx)(`button`,{type:`button`,onClick:()=>Pt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":O(`clearSearch`,`Clear search`),children:(0,w.jsx)(oe,{className:`h-3.5 w-3.5`})})]}),M!==`pending`&&(0,w.jsxs)(ie,{value:V,onValueChange:Vt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`statusFilter`,`Status`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allStatuses`,`All statuses`)}),(0,w.jsx)(o,{value:`pending`,children:A(`pending`)}),(0,w.jsx)(o,{value:`approved`,children:A(`approved`)}),(0,w.jsx)(o,{value:`rejected`,children:A(`rejected`)}),(0,w.jsx)(o,{value:`recalled`,children:A(`recalled`)}),(0,w.jsx)(o,{value:`returned`,children:A(`returned`)})]})]}),On.length>1&&(0,w.jsxs)(ie,{value:Lt,onValueChange:Rt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`processFilter`,`Process`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allProcesses`,`All processes`)}),On.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),kn.length>1&&(0,w.jsxs)(ie,{value:zt,onValueChange:Bt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`objectFilter`,`Object`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allObjects`,`All objects`)}),kn.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),Bn&&(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`filterCount`,`{{shown}} of {{total}}`,{shown:Z.length,total:N.length})})]}),M===`pending`&&H.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`strong`,{children:H.size}),` `,O(`selected`,`selected`),$.length!==H.size&&(0,w.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:O(`actionableCount`,`({{count}} actionable)`,{count:$.length})})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,disabled:Ut||$.length===0,children:[(0,w.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),O(`approveN`,`Approve {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:$.length})}),(0,w.jsx)(u,{children:O(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>Fn(`approve`),children:O(`approveN`,`Approve {{count}}`,{count:$.length})})]})]})]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:Ut||$.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(He,{className:`h-3.5 w-3.5 mr-1`}),O(`rejectN`,`Reject {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:$.length})}),(0,w.jsx)(u,{children:O(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`rejectN`,`Reject {{count}}`,{count:$.length})})]})]})]}),(0,w.jsx)(f,{size:`sm`,variant:`ghost`,onClick:()=>Ht(new Set),disabled:Ut,children:O(`clear`,`Clear`)})]})]}),gt?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`})]}):N.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,w.jsxs)(_e,{children:[(0,w.jsx)(ce,{children:O(`emptyTitle`,`No requests`)}),(0,w.jsx)(Ze,{children:M===`pending`?O(`emptyPending`,`You're all caught up — nothing is waiting on you.`):O(`emptyOther`,`Nothing here yet.`)}),M===`pending`&&(0,w.jsx)(f,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:O(`emptyViewAll`,`Browse all requests`)})]})}):Z.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:O(`noMatches`,`No matches for current filters.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(de,{className:`hidden md:block`,children:(0,w.jsx)(Ce,{className:`p-0`,children:(0,w.jsxs)(Ve,{children:[(0,w.jsx)(Je,{children:(0,w.jsxs)(Oe,{children:[M===`pending`&&(0,w.jsx)(m,{className:`w-10`,children:(0,w.jsx)(Ue,{checked:Mn,onCheckedChange:Nn,"aria-label":O(`selectAll`,`Select all`),disabled:jn.length===0})}),(0,w.jsx)(m,{children:O(`colRequest`,`Request`)}),(0,w.jsx)(m,{children:O(`colRecord`,`Record`)}),(0,w.jsx)(m,{children:O(`colRequester`,`Requester`)}),(0,w.jsx)(m,{children:O(`colStatus`,`Status`)}),(0,w.jsx)(m,{children:O(`colWaiting`,`Submitted`)}),(0,w.jsx)(m,{className:`w-20`,"aria-label":O(`colActions`,`Actions`)})]})}),(0,w.jsx)(Ke,{children:Z.map((e,t)=>(0,w.jsxs)(Oe,{className:y(`group cursor-pointer hover:bg-accent/50`,pn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{mn(t),q(e.id)},children:[M===`pending`&&(0,w.jsx)(l,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,w.jsx)(Ue,{checked:H.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":O(`selectRow`,`Select request`)})}),(0,w.jsx)(l,{children:(0,w.jsx)(Hn,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsx)(Un,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,w.jsx)(me,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,w.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ot(e)})]})}),(0,w.jsx)(l,{children:(0,w.jsx)(dt,{status:e.status})}),(0,w.jsxs)(l,{className:y(`text-xs whitespace-nowrap`,lt(e)),title:rt(D(e)),children:[(0,w.jsx)(De,{className:`h-3 w-3 inline mr-1`}),k(D(e)),e.status===`pending`&&e.sla_due_at&&(0,w.jsx)(`div`,{className:y(`mt-0.5 text-[10px] font-medium`,Date.parse(e.sla_due_at)<Date.now()?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:Date.parse(e.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(e.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,w.jsx)(l,{className:`w-20`,children:(0,w.jsx)(Wn,{r:e})})]},e.id))})]})})}),(0,w.jsx)(`div`,{className:`md:hidden space-y-2`,children:Z.map(e=>(0,w.jsx)(de,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,w.jsxs)(Ce,{className:`p-3 space-y-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsx)(`div`,{className:`font-medium text-sm truncate`,children:it(e)}),(0,w.jsx)(dt,{status:e.status})]}),(0,w.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||T(e.record_id),(0,w.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:ct(e)})]}),(0,w.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,w.jsx)(me,{className:`h-3 w-3`}),ot(e)]}),(0,w.jsxs)(`span`,{className:y(`inline-flex items-center gap-1 whitespace-nowrap`,lt(e)),children:[(0,w.jsx)(De,{className:`h-3 w-3`}),k(D(e))]})]}),Q(e)&&(0,w.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(f,{size:`sm`,className:`h-7 flex-1`,disabled:Kt===e.id,onClick:()=>void In(e),children:[(0,w.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),O(`approve`,`Approve`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Kt===e.id,onClick:()=>Gt(e),children:[(0,w.jsx)(He,{className:`h-3.5 w-3.5 mr-1`}),O(`reject`,`Reject`)]})]})]})},e.id))}),M!==`pending`&&bt!=null&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:N.length,total:bt})}),N.length<bt&&(0,w.jsx)(f,{size:`sm`,variant:`outline`,disabled:vt,onClick:()=>void hn(),children:vt?O(`loadingMore`,`Loading…`):O(`loadMore`,`Load more`)})]}),(0,w.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:O(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,w.jsx)(_,{open:Jt,onOpenChange:e=>{e||(Yt(!1),Zt(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`reassignTitle`,`Hand this approval to someone else?`)}),(0,w.jsx)(u,{children:O(`reassignBody`,`Your approver slot moves to the person you pick — they are notified and can act immediately.`)})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Be,{htmlFor:`reassign-to`,className:`text-xs`,children:O(`reassignTo`,`New approver`)}),(0,w.jsx)(Re,{id:`reassign-to`,list:`reassign-user-options`,value:Xt,onChange:e=>Zt(e.target.value),placeholder:O(`reassignToPlaceholder`,`Pick a user or type an email / role:<name>`),className:`mt-1`}),(0,w.jsx)(`datalist`,{id:`reassign-user-options`,children:dn.map(e=>(0,w.jsx)(`option`,{value:e.email,children:e.name},e.email))})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:!Xt.trim()||W,onClick:()=>void vn(),children:O(`reassignBtn`,`Reassign`)})]})]})}),(0,w.jsx)(_,{open:Qt,onOpenChange:e=>{e||($t(!1),tn(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`requestInfoTitle`,`Ask the requester for more information?`)}),(0,w.jsx)(u,{children:O(`requestInfoBody`,`The request stays pending; the requester is notified and can reply on the thread.`)})]}),(0,w.jsx)(qe,{value:en,onChange:e=>tn(e.target.value),rows:3,placeholder:O(`requestInfoPlaceholder`,`What do you need from the requester?`)}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:!en.trim()||W,onClick:()=>void bn(),children:O(`requestInfoBtn`,`Request info`)})]})]})}),(0,w.jsx)(_,{open:nn,onOpenChange:e=>{e||(rn(!1),on(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`sendBackTitle`,`Send this request back for revision?`)}),(0,w.jsx)(u,{children:O(`sendBackBody`,`This round ends and the record unlocks so the requester can fix the data. When they resubmit, a fresh approval round opens for all approvers.`)})]}),(0,w.jsx)(qe,{value:an,onChange:e=>on(e.target.value),rows:3,placeholder:O(`sendBackPlaceholder`,`What needs to be fixed before this can be approved?`)}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:W,onClick:()=>void xn(),children:O(`sendBackBtn`,`Send back`)})]})]})}),(0,w.jsx)(_,{open:!!U,onOpenChange:e=>!e&&Gt(null),children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`rejectOneTitle`,`Reject "{{title}}"?`,{title:U?U.record_title||T(U.record_id):``})}),(0,w.jsx)(u,{children:O(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})}),(0,w.jsx)(ge,{open:!!P,onOpenChange:e=>!e&&gn(),children:(0,w.jsxs)(se,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,w.jsxs)(pe,{children:[(0,w.jsx)(ve,{children:F?it(F):O(`drawerTitle`,`Approval Request`)}),(0,w.jsx)(ue,{children:F?at(F)||ct(F):``})]}),F&&An>=0&&Z.length>1&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An<=0,onClick:()=>{let e=Z[An-1];e&&q(e.id)},children:[(0,w.jsx)(Ie,{className:`h-4 w-4 mr-0.5`}),O(`prevRequest`,`Previous`)]}),(0,w.jsx)(`span`,{children:O(`positionOf`,`{{index}} of {{total}}`,{index:An+1,total:Z.length})}),(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An>=Z.length-1,onClick:()=>{let e=Z[An+1];e&&q(e.id)},children:[O(`nextRequest`,`Next`),(0,w.jsx)(ne,{className:`h-4 w-4 ml-0.5`})]})]}),At?(0,w.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,w.jsx)(s,{className:`h-6 w-3/4`}),(0,w.jsx)(s,{className:`h-6 w-1/2`}),(0,w.jsx)(s,{className:`h-20 w-full`})]}):F?(0,w.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(dt,{status:F.status}),(F.round??1)>1&&(0,w.jsx)(ke,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:F.round})}),(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:rt(D(F)),children:[(0,w.jsx)(De,{className:`h-3 w-3`}),O(`submittedAgo`,`Submitted {{when}}`,{when:k(D(F))})]}),F.completed_at&&(0,w.jsxs)(`span`,{children:[`· `,O(`completedAt`,`Completed {{when}}`,{when:k(F.completed_at)})]}),F.status===`pending`&&F.sla_due_at&&(0,w.jsx)(ke,{variant:`outline`,className:y(`text-[10px]`,Date.parse(F.sla_due_at)<Date.now()?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:Date.parse(F.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(F.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(F.sla_due_at)-Date.now())})})]}),(0,w.jsx)(de,{children:(0,w.jsxs)(Ce,{className:`p-4 space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(F),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:F.record_title||T(F.record_id)}),(0,w.jsx)(re,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:ct(F)})]}),(0,w.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,w.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,w.jsx)(me,{className:`h-3 w-3`}),(0,w.jsx)(`span`,{title:F.submitter_id||``,children:ot(F)})]})})]}),ft(F.payload,F.payload_display).length>0&&(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:ft(F.payload,F.payload_display).map(([e,t])=>(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,w.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),F.status===`pending`&&(F.pending_approvers||[]).length>0&&(0,w.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:O(`waitingOn`,`Waiting on`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(F.pending_approvers||[]).map((e,t)=>(0,w.jsx)(ke,{variant:`outline`,className:`text-[11px]`,title:e,children:st(e,F)},t))})]})]})}),(F.flow_steps?.length??0)>1&&(0,w.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":O(`stepProgress`,`Approval steps`),children:F.flow_steps.map((e,t)=>(0,w.jsxs)(x.Fragment,{children:[t>0&&(0,w.jsx)(`div`,{className:y(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,w.jsx)(`span`,{className:y(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,w.jsx)(he,{className:`h-3 w-3`}):t+1}),(0,w.jsx)(`span`,{className:y(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:O(`history`,`Activity`)}),Ot.length===0?(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`noActions`,`No actions yet.`)}):(0,w.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:Ot.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?O(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===F.submitter_id?ot(F):T(e.actor_id)),r=e.action===`submit`?O(`actSubmit`,`Submitted`):e.action===`approve`?O(`actApprove`,`Approved`):e.action===`reject`?O(`actReject`,`Rejected`):e.action===`recall`?O(`actRecall`,`Recalled`):e.action===`reassign`?O(`actReassign`,`Reassigned`):e.action===`remind`?O(`actRemind`,`Reminder sent`):e.action===`request_info`?O(`actRequestInfo`,`Requested more info`):e.action===`comment`?O(`actComment`,`Commented`):e.action===`escalate`?O(`actEscalate`,`SLA escalated`):e.action===`revise`?O(`actRevise`,`Sent back for revision`):e.action===`resubmit`?O(`actResubmit`,`Resubmitted`):e.action;return(0,w.jsxs)(`li`,{className:`relative text-xs`,children:[(0,w.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,w.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:r}),(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,w.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,w.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:rt(e.created_at),children:k(e.created_at)})]}),e.comment&&(0,w.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})}),F.status===`pending`&&(Tn||En)&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,w.jsx)(Re,{value:ln,onChange:e=>un(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ln.trim()&&(e.preventDefault(),Cn())},placeholder:O(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,w.jsx)(f,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!ln.trim()||W,onClick:()=>void Cn(),children:(0,w.jsx)(ye,{className:`h-3.5 w-3.5`})})]})]}),F.payload!=null&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`rawData`,`Raw data (JSON)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(`div`,{className:`flex justify-end`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(F.payload,null,2)),b.success(O(`copied`,`Copied`))}catch{b.error(O(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,w.jsx)(Ae,{className:`h-3 w-3`}),O(`copy`,`Copy`)]})}),(0,w.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(F.payload,null,2)})]})]}),F.status===`pending`&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[$e&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`overrideActor`,`Act as another identity (admin)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(Be,{htmlFor:`actor-override`,className:`text-xs`,children:O(`actor`,`Actor`)}),(0,w.jsx)(`input`,{id:`actor-override`,type:`text`,value:R,onChange:e=>Mt(e.target.value),placeholder:`${O(`auto`,`Auto`)}: ${J(F)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,w.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:O(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Be,{htmlFor:`comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[O(`quickPhrase1`,`Approved — meets requirements.`),O(`quickPhrase2`,`Approved with conditions — please monitor execution.`),O(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,w.jsx)(`button`,{type:`button`,onClick:()=>L(e),className:`text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:e},e))}),(0,w.jsx)(qe,{id:`comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsxs)(f,{size:`sm`,onClick:()=>_n(`approve`),disabled:!Tn||z!==null,children:[(0,w.jsx)(Xe,{className:`h-4 w-4 mr-1`}),z===`approve`?O(`approving`,`Approving…`):O(`approve`,`Approve`)]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:!Tn||z!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(He,{className:`h-4 w-4 mr-1`}),z===`reject`?O(`rejecting`,`Rejecting…`):O(`reject`,`Reject`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`rejectTitle`,`Reject this request?`)}),(0,w.jsx)(u,{children:O(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})]}),Tn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-violet-300 text-violet-700 hover:bg-violet-50 dark:text-violet-400`,onClick:()=>rn(!0),children:[(0,w.jsx)(we,{className:`h-4 w-4 mr-1`}),O(`sendBackBtn`,`Send back`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-amber-300 text-amber-700 hover:bg-amber-50 dark:text-amber-400`,onClick:()=>$t(!0),children:[(0,w.jsx)(Me,{className:`h-4 w-4 mr-1`}),O(`requestInfoBtn`,`Request info`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,onClick:()=>{wn(),Yt(!0)},children:[(0,w.jsx)(je,{className:`h-4 w-4 mr-1`}),O(`reassignBtn`,`Reassign`)]})]}),En&&(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:W,onClick:()=>void yn(),children:[(0,w.jsx)(We,{className:`h-4 w-4 mr-1`}),O(`remindBtn`,`Send reminder`)]}),En&&(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null,children:[(0,w.jsx)(fe,{className:`h-4 w-4 mr-1`}),z===`recall`?O(`recalling`,`Recalling…`):O(`recall`,`Recall`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`recallTitle`,`Recall this request?`)}),(0,w.jsx)(u,{children:O(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]}),!Tn&&(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?O(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):O(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(F.pending_approvers||[]).map(e=>st(e,F)).join(`, `)||`—`})})]})]}),Dn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Be,{htmlFor:`resubmit-comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(qe,{id:`resubmit-comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`,placeholder:O(`resubmitPlaceholder`,`What did you change?`)})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsx)(f,{asChild:!0,size:`sm`,variant:`outline`,children:(0,w.jsxs)(r,{to:pt(F),children:[(0,w.jsx)(re,{className:`h-4 w-4 mr-1`}),O(`editRecordBtn`,`Edit record`)]})}),(0,w.jsxs)(f,{size:`sm`,disabled:sn,onClick:()=>void Sn(),children:[(0,w.jsx)(le,{className:y(`h-4 w-4 mr-1`,sn&&`animate-spin`)}),sn?O(`resubmitting`,`Resubmitting…`):O(`resubmitBtn`,`Resubmit`)]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:sn,children:[(0,w.jsx)(fe,{className:`h-4 w-4 mr-1`}),O(`recall`,`Recall`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`abandonTitle`,`Abandon this revision?`)}),(0,w.jsx)(u,{children:O(`abandonBody`,`This withdraws the request instead of resubmitting it. The approval ends here.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]})]})]})]}):null]})})]})}export{pt as ApprovalsInboxPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{Bt as r,Ci as i,Cr as a,Ft as ee,H as te,Ht as o,Ii as ne,It as re,Jn as s,Lt as c,Mt as l,Pt as u,R as ie,Rt as ae,Ut as oe,Vt as d,Wt as f,Yn as p,ar as m,ct as h,dt as g,er as _,gr as v,ir as se,lt as y,nn as b,on as x,ot as ce,st as le,ut as ue,wi as S,ws as C,z as w,zt as T}from"./ui-components-BecTKcFn.js";var E=e(t(),1),D=n(),de=`${``.replace(/\/$/,``)}/api/v1`,fe=[`create`,`update`,`delete`,`restore`,`login`,`logout`,`permission_change`,`config_change`,`export`,`import`],O={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`},k=50;function A(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function j(e,t=24){return e?e.length>t?`${e.slice(0,t-1)}…`:e:`—`}function M(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function N(){let[e,t]=(0,E.useState)([]),[n,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(null),[I,L]=(0,E.useState)(`all`),[R,z]=(0,E.useState)(``),[B,V]=(0,E.useState)(``),[H,U]=(0,E.useState)(``),[W,G]=(0,E.useState)(``),[K,q]=(0,E.useState)(0),[J,Y]=(0,E.useState)(!1),[X,Z]=(0,E.useState)(null),Q=(0,E.useCallback)(async()=>{N(!0),F(null);try{let e={};I&&I!==`all`&&(e.action=I),R.trim()&&(e.object_name=R.trim()),B.trim()&&(e.user_id=B.trim()),H&&(e.created_at={...e.created_at||{},$gte:H}),W&&(e.created_at={...e.created_at||{},$lte:`${W}T23:59:59`});let n=new URLSearchParams;Object.keys(e).length>0&&n.set(`$filter`,JSON.stringify(e)),n.set(`$orderby`,`created_at desc`),n.set(`$top`,`51`),n.set(`$skip`,String(K*k));let r=await fetch(`${de}/data/sys_audit_log?${n.toString()}`,{credentials:`include`});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`HTTP ${r.status}: ${e.slice(0,200)||r.statusText}`)}let i=await r.json(),a=Array.isArray(i)?i:Array.isArray(i?.records)?i.records:Array.isArray(i?.data)?i.data:[];Y(a.length>k),t(a.slice(0,k))}catch(e){console.warn(`[AuditLogPage] load failed:`,e),F(e?.message||`Failed to load audit log`),t([]),Y(!1)}finally{N(!1)}},[I,R,B,H,W,K]);(0,E.useEffect)(()=>{Q()},[Q]);let pe=(0,E.useCallback)(()=>{L(`all`),z(``),V(``),U(``),G(``),q(0)},[]),$=(0,E.useMemo)(()=>{let e=0;return I!==`all`&&(e+=1),R.trim()&&(e+=1),B.trim()&&(e+=1),H&&(e+=1),W&&(e+=1),e},[I,R,B,H,W]);return(0,D.jsxs)(`div`,{className:`p-6 space-y-4 max-w-screen-2xl mx-auto`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(S,{className:`h-6 w-6 text-muted-foreground`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Audit Log`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only system activity and record changes. Newest first.`})]}),(0,D.jsxs)(v,{variant:`outline`,size:`sm`,onClick:Q,disabled:n,children:[(0,D.jsx)(ne,{className:`h-4 w-4 mr-1 ${n?`animate-spin`:``}`}),`Refresh`]})]}),(0,D.jsx)(s,{children:(0,D.jsxs)(p,{className:`p-4 grid grid-cols-1 md:grid-cols-5 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`Action`}),(0,D.jsxs)(r,{value:I,onValueChange:e=>{L(e),q(0)},children:[(0,D.jsx)(oe,{className:`h-9`,children:(0,D.jsx)(f,{})}),(0,D.jsxs)(d,{children:[(0,D.jsx)(o,{value:`all`,children:`All actions`}),fe.map(e=>(0,D.jsx)(o,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`Object`}),(0,D.jsx)(b,{placeholder:`e.g. account`,value:R,onChange:e=>{z(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`Actor (user id)`}),(0,D.jsx)(b,{placeholder:`user id`,value:B,onChange:e=>{V(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`From`}),(0,D.jsx)(b,{type:`date`,value:H,onChange:e=>{U(e.target.value),q(0)},className:`h-9`})]}),(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(x,{className:`text-xs`,children:`To`}),(0,D.jsx)(b,{type:`date`,value:W,onChange:e=>{G(e.target.value),q(0)},className:`h-9`})]}),$>0&&(0,D.jsx)(`div`,{className:`md:col-span-5 flex justify-end`,children:(0,D.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:pe,children:[(0,D.jsx)(a,{className:`h-4 w-4 mr-1`}),`Clear filters (`,$,`)`]})})]})}),P&&(0,D.jsxs)(se,{variant:`destructive`,children:[(0,D.jsx)(C,{className:`h-4 w-4`}),(0,D.jsx)(m,{children:P})]}),(0,D.jsx)(s,{children:(0,D.jsx)(p,{className:`p-0`,children:n&&e.length===0?(0,D.jsx)(`div`,{className:`p-6 space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,D.jsx)(l,{className:`h-9 w-full`},t))}):e.length===0?(0,D.jsx)(`div`,{className:`p-12`,children:(0,D.jsxs)(ie,{children:[(0,D.jsx)(i,{className:`h-8 w-8 text-muted-foreground mb-3`}),(0,D.jsx)(te,{children:`No audit entries`}),(0,D.jsx)(w,{children:$>0?`Try clearing filters or widening the date range.`:`Events will appear here once tracked objects are modified.`})]})}):(0,D.jsxs)(ce,{children:[(0,D.jsx)(ue,{children:(0,D.jsxs)(g,{children:[(0,D.jsx)(y,{className:`w-[180px]`,children:`Timestamp`}),(0,D.jsx)(y,{className:`w-[130px]`,children:`Action`}),(0,D.jsx)(y,{children:`Object`}),(0,D.jsx)(y,{children:`Record`}),(0,D.jsx)(y,{children:`Actor`}),(0,D.jsx)(y,{className:`w-[130px]`,children:`IP`})]})}),(0,D.jsx)(le,{children:e.map(e=>{let t=O[e.action||``]||`outline`;return(0,D.jsxs)(g,{className:`cursor-pointer`,onClick:()=>Z(e),children:[(0,D.jsx)(h,{className:`font-mono text-xs`,children:A(e.created_at)}),(0,D.jsx)(h,{children:(0,D.jsx)(_,{variant:t,children:e.action||`—`})}),(0,D.jsx)(h,{children:e.object_name||`—`}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:j(e.record_id,18)}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:j(e.user_id,18)}),(0,D.jsx)(h,{className:`font-mono text-xs`,children:e.ip_address||`—`})]},e.id)})})]})})}),(e.length>0||K>0)&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground`,children:[(0,D.jsxs)(`span`,{children:[`Page `,K+1,J?``:` · end`]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(v,{variant:`outline`,size:`sm`,disabled:K===0||n,onClick:()=>q(e=>Math.max(0,e-1)),children:`Previous`}),(0,D.jsx)(v,{variant:`outline`,size:`sm`,disabled:!J||n,onClick:()=>q(e=>e+1),children:`Next`})]})]}),(0,D.jsx)(u,{open:!!X,onOpenChange:e=>!e&&Z(null),children:(0,D.jsxs)(ee,{side:`right`,className:`sm:max-w-2xl w-full overflow-y-auto`,children:[(0,D.jsxs)(c,{children:[(0,D.jsxs)(ae,{className:`flex items-center gap-2`,children:[(0,D.jsx)(_,{variant:X&&O[X.action||``]||`outline`,children:X?.action||`—`}),X?.object_name||`Audit Event`]}),(0,D.jsx)(re,{children:X?.id?(0,D.jsx)(`span`,{className:`font-mono text-xs`,children:X.id}):null})]}),X&&(0,D.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timestamp`}),(0,D.jsx)(`div`,{className:`font-mono`,children:A(X.created_at)})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`IP Address`}),(0,D.jsx)(`div`,{className:`font-mono`,children:X.ip_address||`—`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Actor (user_id)`}),(0,D.jsx)(`div`,{className:`font-mono break-all`,children:X.user_id||`—`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tenant`}),(0,D.jsx)(`div`,{className:`font-mono break-all`,children:X.tenant_id||`—`})]}),(0,D.jsxs)(`div`,{className:`col-span-2`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Target record`}),(0,D.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[X.object_name||`—`,` / `,X.record_id||`—`]})]}),X.user_agent&&(0,D.jsxs)(`div`,{className:`col-span-2`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`User Agent`}),(0,D.jsx)(`div`,{className:`font-mono text-xs break-all`,children:X.user_agent})]})]}),(X.old_value||X.new_value)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(T,{}),(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(`div`,{className:`text-sm font-medium`,children:`Change payload`}),X.old_value&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Before`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.old_value)})]}),X.new_value&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`After`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.new_value)})]})]})]}),X.metadata&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(T,{}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,D.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-48 overflow-auto`,children:M(X.metadata)})]})]})]})]})})]})}export{N as AuditLogPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-CMxvf4Kt.js";import{_ as e,f as t,p as n,t as r}from"./vendor-react-
|
|
1
|
+
import"./rolldown-runtime-CMxvf4Kt.js";import{_ as e,f as t,p as n,t as r}from"./vendor-react-ClIa1CJA.js";import{H as i,R as a,z as o}from"./ui-components-BecTKcFn.js";import{t as s}from"./componentRegistry-ByxoJqMW.js";e();var c=r();function l({extraProps:e}={}){let r=t(),[l]=n(),u=r.ns,d=r.name,f=u&&d?`${u}:${d}`:u??``,p=s(f);if(!p)return(0,c.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,c.jsxs)(a,{children:[(0,c.jsx)(i,{children:`Component not registered`}),(0,c.jsxs)(o,{children:[`No component is registered for `,(0,c.jsx)(`code`,{className:`font-mono`,children:f||`(empty)`}),`. Ensure the plugin that provides this surface is installed and has called`,(0,c.jsx)(`code`,{className:`font-mono`,children:` registerAppComponent()`}),`.`]})]})});let m={};for(let[e,t]of l.entries())m[e]=t;let h=p.component;return(0,c.jsx)(h,{...m,...e??{}})}export{l as ComponentNavView,l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{i as a}from"./framework-DI54pxGD.js";import{Bt as o,Ht as s,Ut as c,Vt as l,Wt as u,gr as d,oi as f,w as p,yi as m}from"./ui-components-BecTKcFn.js";import{r as h}from"./vendor-ui-utils-C92Fl7BT.js";import{i as g,s as _,t as v}from"./assistantBus-BMrg1uLy.js";import{a as y,n as b,o as x,s as ee,t as te}from"./useReconcileOnError-Df2Wf71r.js";import{S,a as ne,d as C,p as w,r as re,t as ie,u as T,v as E}from"./plugin-chatbot-BnXRjqnw.js";import{b as D,n as O}from"./marketplaceApi-DL8PegzV.js";var k=e(t(),1),A=r(),j={ask:{zh:`智能助手`,en:`Assistant`},build:{zh:`构建助手`,en:`Build assistant`}};function M(e,t,n){let r=t?j[w(t)]:void 0;return r?e?r.zh:r.en:n}function ae(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=M(a,n,r),s=i.slice(0,2).map(e=>e.label||e.name);if(a){let e=[s[0]?`查询最近创建的${s[0]}`:`帮我查询最近的数据`,s[0]?`统计${s[0]}的总数量`:`统计各对象的记录数量`,s[1]?`${s[1]}有哪些字段?`:`当前应用里有哪些数据对象?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`你好,我是${o}`,emptyDescription:`随时帮你查询和分析「${t}」中的数据。试试下面的问题,或直接输入你的需求。`,clear:`清空对话`,sendHint:`发送`,agentActivity:`执行过程`,toolCompleted:`已完成`,toolRunning:`运行中`,toolAwaitingApproval:`等待确认`,toolFailed:`失败`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,nextSteps:`下一步`,planTitle:`方案预览`,planQuestions:`搭建前请确认`,planAssumptions:`假设`,planApproveHint:`回复以确认或调整该方案。`,planApprove:`开始搭建`,planAdjust:`调整方案`,planApproveMessage:`就按这个方案搭建吧。`,planApproveDefaultsMessage:`就按你的合理假设直接搭建,未决问题用默认即可。`,planAnswer:(e,t)=>`关于「${e}」,我选择「${t}」。`,publishOk:`已发布,对象已生效。`,publishFailed:`发布失败`,seedWarn:`已发布,但部分示例数据未能载入。`,openBuiltApp:`打开应用`,suggestions:e}}let c=[s[0]?`Show the latest ${s[0]}`:`Show my most recent records`,s[0]?`How many ${s[0]} are there?`:`Count records by status`,s[1]?`What fields does ${s[1]} have?`:`What data can I work with here?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`Hi, I'm ${o}`,emptyDescription:`I can help you query and analyze your ${t} data. Try a prompt below, or just type your question.`,clear:`Clear`,sendHint:`to send`,agentActivity:`Agent activity`,toolCompleted:`Completed`,toolRunning:`Running`,toolAwaitingApproval:`Awaiting approval`,toolFailed:`Failed`,toolDetailsHidden:`Tool inputs and raw results are hidden in this view.`,copy:`Copy`,copied:`Copied`,regenerate:`Regenerate`,model:`Model`,submit:`Submit`,uploadFiles:`Upload files`,stopResponse:`Stop response`,trace:`trace`,viewTrace:`View trace`},placeholder:`Ask ${o}...`,loadingPlaceholder:`Loading assistant...`,title:`${t} Assistant`,newChat:`New chat`,share:`Share conversation`,reviewDraft:e=>`Review ${e} change${e===1?``:`s`}`,publishDrafts:`Publish`,published:`Published`,nextSteps:`What's next`,planTitle:`Proposed plan`,planQuestions:`Confirm before building`,planAssumptions:`Assumptions`,planApproveHint:`Reply to approve or adjust this plan.`,planApprove:`Build it`,planAdjust:`Adjust`,planApproveMessage:`Looks good — build it as proposed.`,planApproveDefaultsMessage:`Build it with your best assumptions; use sensible defaults for the open questions.`,planAnswer:(e,t)=>`For "${e}", go with: ${t}.`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var N=`/api/v1/ai`;function P(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${N}`}function oe(e,t){if(!e||e.type!==`object`)return null;let n=e.label||e.name||`this object`;return(t??``).toLowerCase().startsWith(`zh`)?[`为「${n}」补充字段`,`为「${n}」建议校验规则`,`添加一个状态选项字段`]:[`Add fields to ${n}`,`Suggest validations for ${n}`,`Add a status picklist field`]}var F=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`,`metadata`]);function I(e){try{return decodeURIComponent(e)}catch{return e}}function se(e,t){let n=e.split(`/`).filter(Boolean),r=n.indexOf(`apps`);if(r===-1||n.length<r+3)return{};let i=I(n[r+2]);if(F.has(i)||!t.some(e=>e.name===i))return{};let a=n[r+3]?I(n[r+3]):void 0,o=a&&a!==`new`?a:void 0;return{objectName:i,...o?{recordId:o}:{}}}function L({appLabel:e,appName:t,objects:r,agents:x,agentsLoading:C,activeAgent:w,onAgentChange:T,showAgentPicker:j,chatApi:M,apiBase:N,defaultOpen:P=!1,conversationId:F,initialMessages:I}){let{language:L}=a(),R=i(),z=n(),B=k.useMemo(()=>se(z.pathname,r),[z.pathname,r]),{editor:V}=_(),H=k.useMemo(()=>!I||I.length===0?[]:S(I),[I]),U=k.useMemo(()=>x.find(e=>e.name===w)?.label??w??e,[x,w,e]),W=k.useMemo(()=>ae(L,e,w,U,r),[L,e,w,U,r]),G=k.useMemo(()=>oe(V,L),[V,L]),{errorSuppressed:ce,handleChatError:le,setMessagesRef:ue,resetSuppression:K}=te({chatApi:M,conversationId:F}),{messages:q,isLoading:J,error:de,sendMessage:Y,stop:fe,reload:pe,clear:X,setMessages:Z}=E({api:M,conversationId:F,onError:le,body:{context:{activeApp:e,appName:t,objects:r.map(e=>({name:e.name,label:e.label})),agentName:w,autoPublishAiBuilds:D().features.autoPublishAiBuilds,...B.objectName?{objectName:B.objectName}:{},...B.recordId?{recordId:B.recordId}:{},...V?{editing:V}:{}}},initialMessages:H,autoResponse:!M,autoResponseText:r.length>0?`I can help you work with ${r.map(e=>e.label||e.name).join(`, `)}. What would you like to do?`:`Thanks for your message! I'm here to help you navigate and manage your data.`,autoResponseDelay:600});k.useEffect(()=>{ue.current=Z},[Z]),k.useEffect(()=>{ee(F,y(q))},[F,q]);let Q=ie({messages:q,apiBase:N,continueConversation:e=>{K(),Y(e)}}),me=j&&x.length>1?(0,A.jsxs)(o,{value:w,onValueChange:T,disabled:C,children:[(0,A.jsx)(c,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,A.jsx)(u,{placeholder:`Choose agent...`})}),(0,A.jsx)(l,{align:`end`,children:x.map(e=>(0,A.jsxs)(s,{value:e.name,className:`text-xs`,children:[(0,A.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,A.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[he,$]=k.useState(!1),ge=k.useMemo(()=>N.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[N]),_e=(0,A.jsxs)(A.Fragment,{children:[q.length>0?(0,A.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":W.newChat,title:W.newChat,"data-testid":`floating-chatbot-new`,onClick:X,children:(0,A.jsx)(f,{className:`h-4 w-4`})}):null,F?(0,A.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":W.share,title:W.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,A.jsx)(m,{className:`h-4 w-4`})}):null]});return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(re,{onUpgrade:()=>window.open(O(),`_blank`,`noopener,noreferrer`),floatingConfig:{position:`bottom-right`,defaultOpen:P,panelWidth:420,panelHeight:560,title:W.title,triggerSize:56},headerExtra:me,headerActions:_e,messages:q,labels:W.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:W.agentLabel,suggestions:q.length===0?G??W.suggestions:void 0,placeholder:w?W.placeholder:C?W.loadingPlaceholder:W.placeholder,onSendMessage:e=>{K(),Y(e)},onClear:X,onStop:J?fe:void 0,onReload:pe,isLoading:J,error:ce?void 0:de,enableMarkdown:!0,onToolApprove:Q.decide,toolDecisions:Q.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&g(e[0])},toolReviewLabel:W.reviewDraft,onOpenBuiltApp:e=>R(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:W.openBuiltApp,onPreviewDraftApp:(e,t)=>R(t?.materialized?`/apps/${encodeURIComponent(e)}`:`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)v(t)},fetchPendingDraftCount:b,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;i&&i.success===!1?h.warning(W.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):h.success(W.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&R(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:ne(n)}}catch(e){return h.error(W.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:W.publishDrafts,nextStepsLabel:W.nextSteps,planTitleLabel:W.planTitle,planQuestionsLabel:W.planQuestions,planAssumptionsLabel:W.planAssumptions,planApproveHintLabel:W.planApproveHint,planApproveLabel:W.planApprove,planAdjustLabel:W.planAdjust,planApproveMessage:W.planApproveMessage,planApproveDefaultsMessage:W.planApproveDefaultsMessage,planAnswerMessage:W.planAnswer,publishedLabel:W.published,autoPublishDrafts:D().features.autoPublishAiBuilds}),F&&(0,A.jsx)(p,{open:he,onOpenChange:$,objectName:`ai_conversations`,recordId:F,recordLabel:`this conversation`,apiBase:ge})]})}function R({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=k.useMemo(()=>P(r),[r]),l={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},u=l.VITE_AI_DEFAULT_AGENT,d=a??l.VITE_AI_SHOW_AGENT_PICKER===`true`,{agents:f,isLoading:p,error:m}=C({apiBase:c}),[h,g]=k.useState(void 0);k.useEffect(()=>{if(!h&&f.length>0){let e=T(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:y}=x({userId:h?s:void 0,scope:h,apiBase:c});return(0,A.jsx)(L,{appLabel:e,appName:t,objects:n,agents:f,agentsLoading:p,agentsError:m,activeAgent:h,onAgentChange:g,showAgentPicker:d,chatApi:_,apiBase:c,defaultOpen:o,conversationId:v,initialMessages:y},`${_??`local`}:${v??`pending`}`)}export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i}from"./vendor-react-ClIa1CJA.js";import{f as a}from"./infrastructure-BsIvKvpW.js";import{A as o,f as s,i as c,k as l}from"./framework-DI54pxGD.js";import{$r as u,Bn as d,Bs as f,Cr as p,Ga as m,H as h,Hn as g,Hr as _,Is as v,R as y,Rn as b,Tc as x,Ua as S,Un as C,Vn as w,Vs as T,Wi as E,Zi as ee,gr as D,pc as O,z as te,zn as k,zr as A}from"./ui-components-BecTKcFn.js";import{r as j}from"./vendor-ui-utils-C92Fl7BT.js";import"./AdapterProvider-497l4p4y.js";import{n as ne}from"./plugin-form-CfWEBrxU.js";import"./MetadataProvider-0eg8cMSY.js";import{r as re}from"./ExpressionProvider-CHhp2xGN.js";import{Z as ie,v as M}from"./ReportDefaultInspector-CRLMz2jp.js";import{n as N}from"./utils-29quoGQV.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-DXNojk_m.js";import{n as P,t as F}from"./DashboardWidgetInspector-DKZkel6E.js";import{i as ce,n as I,t as le}from"./useOpenRecordList-DjbGsO2B.js";import{n as ue}from"./skeletons-CCMkzfAg.js";import{n as de}from"./plugin-dashboard-BJU4e4Lc.js";var L=e(n(),1),R=i();function fe({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:s,name:l,metadataClient:u,onAfterChange:d}){let{t:f}=c(),m=(0,L.useMemo)(()=>M(),[]),[h,g]=(0,L.useState)(!1),[v,y]=(0,L.useState)(0),b=(0,L.useCallback)(e=>{g(!0),o({...n??{},...e})},[n,o]),x=(0,L.useCallback)(e=>{o(e),g(!1)},[o]),S=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),C=Array.isArray(n?.widgets)?n.widgets:[],w=r?C.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,E=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":E,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(D,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(O,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:E})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&s&&(0,R.jsx)(D,{variant:`ghost`,size:`sm`,onClick:()=>s(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(D,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(p,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:b,onClearSelection:()=>i(null),onSelectionChange:S,readOnly:!1,locale:m}):(0,R.jsx)(P,{type:`dashboard`,name:T,draft:n??{},onPatch:b,onSelectionChange:S,readOnly:!1,locale:m})}),(0,R.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,R.jsx)(I,{type:`dashboard`,name:l||T||void 0,metadataClient:u,dirty:h,onResume:x,savedSignal:v,onAfterChange:d}),(0,R.jsx)(D,{size:`sm`,onClick:()=>{a(n??{}),g(!1),y(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:A},{type:`bar`,label:`Bar Chart`,Icon:T},{type:`line`,label:`Line Chart`,Icon:f},{type:`pie`,label:`Pie Chart`,Icon:v},{type:`table`,label:`Table`,Icon:u},{type:`pivot`,label:`Pivot`,Icon:S}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function pe(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function me(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let t=le(),{dashboardName:n}=r(),{showDebug:i}=ae(),u=l(),f=ie(),{t:p}=c(),{dashboardLabel:_,dashboardDescription:v}=x(),{user:S}=a(),T=S?.role===`admin`,[O,A]=(0,L.useState)(!0),[M,P]=(0,L.useState)(!1),[F,I]=(0,L.useState)(null),[z,V]=(0,L.useState)(null),U=(0,L.useCallback)(e=>{V(t=>(t&&t.resolve(e),null))},[]),he=(0,L.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;V({schema:n,resolve:t})}),[]),ge=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(p(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(p(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(p(`dashboardActions.forecastSoon`)),{success:!0})}),[p]);(0,L.useEffect)(()=>{A(!0),J(null),P(!1),I(null),queueMicrotask(()=>A(!1))},[n]);let{dashboards:_e,objects:W,refresh:G}=o(),{app:ve}=re(),K=oe(_e,n,ve?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{M||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{f&&await ce(`dashboard`,n,e,{metadataClient:f}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[f,n,G]),ye=(0,L.useCallback)(()=>{J(pe(K)),P(!0)},[K]),be=(0,L.useCallback)(()=>{P(!1),I(null)},[]),xe=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:me(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),I(t)},[q,Y]),X=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),F===e&&I(null)},[q,F,Y]),Se=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),Ce=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.useMemo)(()=>{if(!Q||Z.size===0)return Q;let e=Q.widgets;if(!Array.isArray(e)||e.length===0)return Q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return t?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return O?(0,R.jsx)(ue,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=N(($||K).title,p),t=N(K.label,p),n=_({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=v({name:K.name,description:N(e,p)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[M&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>xe(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,R.jsx)(E,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),T&&(0,R.jsxs)(`button`,{type:`button`,onClick:ye,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,R.jsx)(ee,{className:`h-3.5 w-3.5`}),p(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(s,{value:{openRecordList:t},children:(0,R.jsx)(de,{schema:$,dataSource:e,designMode:M,selectedWidgetId:F,onWidgetClick:I,onWidgetsReorder:Se,modalHandler:he,scriptHandlers:ge,hideHeaderText:!0})})}),(0,R.jsx)(fe,{open:M&&T,onClose:be,schema:Ce,selectedWidgetId:F,onSelectWidget:I,onSave:Y,onChange:J,onRemoveWidget:X,name:n,metadataClient:f,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),z&&z.schema?.objectName?(0,R.jsx)(ne,{schema:{type:`object-form`,formType:`modal`,objectName:z.schema.objectName,mode:z.schema.mode||`create`,recordId:z.schema.recordId,title:z.schema.title,description:z.schema.description,fields:z.schema.fields,open:!0,onOpenChange:e=>{e||U({success:!1})},onSuccess:e=>{U({success:!0,reload:!0,data:e})},onCancel:()=>{U({success:!1})},showSubmit:!0,showCancel:!0},dataSource:u}):z?(0,R.jsx)(b,{open:!0,onOpenChange:e=>{e||U({success:!1})},children:(0,R.jsxs)(k,{children:[(0,R.jsxs)(g,{children:[(0,R.jsx)(C,{children:z.schema?.title||p(`actionDialog.defaultActionTitle`)}),z.schema?.description&&(0,R.jsx)(d,{children:z.schema.description})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(D,{variant:`outline`,onClick:()=>U({success:!1}),children:p(`actionDialog.cancel`)}),(0,R.jsx)(D,{onClick:()=>U({success:!0}),children:p(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(y,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(h,{children:p(`empty.dashboardNotFound`)}),(0,R.jsx)(te,{children:p(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{z 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{R as r,l as i,m as a}from"./vendor-objectstack-CMEER4tu.js";import{$r as o,$t as s,An as c,Bs as l,Bt as u,Ci as d,Cr as f,Es as p,Fa as m,Fn as h,Fs as g,Go as _,Hs as v,Ht as y,In as b,Is as x,Jo as S,Mn as ee,Nn as C,Ns as w,Pn as te,Rs as T,Ut as E,Vr as D,Vt as O,Wi as k,Wt as A,ao as j,co as M,en as ne,er as re,gr as N,is as ie,nn as P,on as F,tn as ae,vc as oe,yc as I,zs as se}from"./ui-components-BecTKcFn.js";import{G as ce,J as le,K as ue,U as de,V as fe,W as L,Z as R,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as ye,r as be,t as xe,y as z}from"./ReportDefaultInspector-CRLMz2jp.js";var B=e(t(),1),V=n();function Se(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function H({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:l,loading:u,allowCustom:d=!0,mono:f,className:m}){let[g,_]=B.useState(!1),[v,y]=B.useState(``),x=r.find(e=>e.value===t),S=x?x.label:t||(u?`Loading…`:i),T=B.useMemo(()=>r.filter(e=>Se(e,v)),[r,v]),E=B.useMemo(()=>{let e=[],t=new Map;for(let n of T){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[T]),D=v.trim(),O=d&&!!D&&!r.some(e=>e.value===D),k=e=>{n(e),_(!1),y(``)},A=(0,V.jsxs)(s,{open:g,onOpenChange:e=>{_(e),e||y(``)},children:[(0,V.jsx)(ae,{asChild:!0,children:(0,V.jsxs)(N,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:l,className:I(`h-8 w-full justify-between px-2 text-sm font-normal`,m),children:[(0,V.jsx)(`span`,{className:I(`truncate`,f&&`font-mono`,!x&&!t&&`text-muted-foreground`),children:S}),(0,V.jsx)(p,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,V.jsx)(ne,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,V.jsxs)(c,{shouldFilter:!1,children:[(0,V.jsx)(te,{value:v,onValueChange:y,placeholder:a}),(0,V.jsxs)(b,{children:[!O&&T.length===0&&(0,V.jsx)(ee,{children:o}),O&&(0,V.jsx)(C,{children:(0,V.jsx)(h,{value:`__custom__${D}`,onSelect:()=>k(D),children:(0,V.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[`“`,D,`”`]})]})})}),E.map((e,n)=>(0,V.jsx)(C,{heading:e.heading||void 0,children:e.items.map(e=>(0,V.jsxs)(h,{value:e.value,onSelect:()=>k(e.value),children:[(0,V.jsx)(w,{className:I(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,V.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,V.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,V.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:e}),A]}):A}var Ce=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function U(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function we(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Te(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function W(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=U(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:U(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&Ce.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:we(e.def)}))}}function Ee(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=e.relationships.find(e=>e.name===i),a=t?.referenceTo?n[t.referenceTo]:void 0;if(!a)continue;let o=`${t.label} → ${a.label}`;for(let e of a.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:o})}return r}function G(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>G(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&G(e,t))}function K(){let e=R(),[t,n]=B.useState({options:[],loading:!0});return B.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:U(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function De(e,t){let n=R(),r=t.join(`\0`),[i,a]=B.useState({relationships:[],fieldOptions:[],loading:!!e});return B.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=W(i,e),s=new Set;for(let e of r?r.split(`\0`):[]){let t=o.relationships.find(t=>t.name===e);t?.referenceTo&&s.add(t.referenceTo)}let c=await Promise.all([...s].map(async e=>{try{return[e,W(await n.get(`object`,e),e)]}catch{return[e,W(null,e)]}}));if(t)return;let l=Object.fromEntries(c),u=r?r.split(`\0`):[];a({relationships:o.relationships,fieldOptions:Ee(o,u,l),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Oe(e){let t=R(),[n,r]=B.useState({reports:0,dashboards:0,loading:!!e});return B.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>G(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>G(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var q={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:j},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:se},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:T},line:{id:`line`,label:`Line chart`,category:`chart`,icon:l},area:{id:`area`,label:`Area chart`,category:`chart`,icon:v},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:x},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:_},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:g},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:D},table:{id:`table`,label:`Data table`,category:`data`,icon:o},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:S},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:ie}},ke={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},J=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(q).filter(t=>t.category===e)})),Y=oe;function X({onAdd:e,label:t=`Add widget`}){let[n,r]=B.useState(!1),[i,a]=B.useState(``),o=B.useRef(null),s=B.useRef(null);B.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=B.useMemo(()=>{let e=i.trim().toLowerCase();return e?J.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):J},[i]);return(0,V.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,V.jsx)(k,{className:`h-3 w-3`}),t]}),n&&(0,V.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,V.jsx)(d,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,V.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,V.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:ke[t.category]}),t.types.map(t=>(0,V.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,V.jsx)(q[t.id]?.icon??Y,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,V.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var Ae={io:`input`,unrepresentable:`any`},je=new Set([`widgets`,`label`,`description`,`name`]),Z,Me=!1;function Ne(){if(Z||Me)return Z;try{Z=r(i,Ae)}catch(e){Me=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Pe(){if(Q)return Q;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!je.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Fe=new Set([`name`,`label`,`description`,`widgets`]);function Ie({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=B.useCallback(e=>z(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=B.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=le(`widget`,l.map(e=>e?.id).filter(Boolean)),r=q[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ce(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:ye(l,e,null)})},p=(e,n)=>{e!==n&&t({widgets:ue(l,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=B.useState(null),[_,v]=B.useState(null),{schema:y,form:b}=B.useMemo(()=>me({bundledSchema:Ne(),bundledForm:Pe(),serverSchema:a,excludeFields:Fe,sectionTitle:z(`engine.inspector.moreFields`,r)}),[a,r]);return(0,V.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,V.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,V.jsx)(re,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,V.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,V.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=q[e?.type]?.icon??Y;return(0,V.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,V.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,V.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,V.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,V.jsx)(X,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,V.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,V.jsx)(ve,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Le=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Re=[`count`,`sum`,`avg`,`min`,`max`],ze=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Be(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function Ve({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,l=c?Be(e,c):null,d=l?.widget??{},p=typeof d.dataset==`string`?d.dataset:``,m=typeof d.object==`string`?d.object:``,h=Array.isArray(d.dimensions)?d.dimensions.filter(e=>typeof e==`string`):[],g=Array.isArray(d.values)?d.values.filter(e=>typeof e==`string`):[],_=be(),v=ge(p||void 0,_),{options:b,loading:x}=K(),{fields:S}=he(m||void 0),ee=B.useMemo(()=>{let e=_.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return p&&!e.some(e=>e.value===p)&&e.push({value:p,label:p}),e},[_.datasets,p]),C=B.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),w=B.useMemo(()=>S.map(e=>({value:e.name,label:e.label,hint:e.type})),[S]),te=B.useMemo(()=>v.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[v.measures]),T=B.useMemo(()=>v.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[v.dimensions]);if(t.kind!==`widget`)return(0,V.jsx)(He,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!l)return(0,V.jsx)(He,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:D,index:k}=l;function j(e){let t=[...s];t[k]={...t[k],...e},n({widgets:t})}function M(e){n({widgets:ue(s,k,e)}),D.id&&i?.({kind:`widget`,id:D.id,label:D.title??void 0})}return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:z(`engine.inspector.widget.kind`,o)}),(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:D.title||t.label||`Widget ${k+1}`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,V.jsx)(fe,{index:k,total:s.length,onMove:M,upLabel:z(`engine.inspector.reorder.up`,o),downLabel:z(`engine.inspector.reorder.down`,o),disabled:a}),(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:z(`engine.inspector.widget.close`,o),"aria-label":z(`engine.inspector.widget.close`,o),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,V.jsx)($,{id:`widget-title`,label:z(`engine.inspector.widget.title`,o),children:(0,V.jsx)(P,{id:`widget-title`,value:D.title??``,onChange:e=>j({title:e.target.value}),disabled:a})}),(0,V.jsx)($,{id:`widget-type`,label:z(`engine.inspector.widget.type`,o),children:(0,V.jsxs)(u,{value:D.type??`metric`,onValueChange:e=>j({type:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-type`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Le.map(e=>(0,V.jsx)(y,{value:e.value,children:e.label},e.value))})]})}),(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,V.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:z(`engine.inspector.widget.datasetSection`,o)}),(0,V.jsxs)($,{id:`widget-dataset`,label:z(`engine.inspector.widget.dataset`,o),children:[(0,V.jsx)(H,{value:p,onCommit:e=>j({dataset:e||void 0}),options:ee,loading:_.loading,placeholder:z(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:z(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,V.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:z(`engine.inspector.widget.datasetHint`,o)})]}),p&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xe,{label:z(`engine.inspector.widget.dimensions`,o),emptyText:z(`engine.inspector.widget.dimensionsHint`,o),names:h,options:T,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({dimensions:e})}),(0,V.jsx)(xe,{label:z(`engine.inspector.widget.values`,o),emptyText:z(`engine.inspector.widget.valuesHint`,o),names:g,options:te,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({values:e})})]})]}),(0,V.jsx)($,{id:`widget-object`,label:z(`engine.inspector.widget.object`,o),children:(0,V.jsx)(H,{value:D.object??``,onCommit:e=>j({object:e||void 0}),options:C,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-value-field`,label:z(`engine.inspector.widget.valueField`,o),children:(0,V.jsx)(H,{value:D.valueField??``,onCommit:e=>j({valueField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-category-field`,label:z(`engine.inspector.widget.categoryField`,o),children:(0,V.jsx)(H,{value:D.categoryField??``,onCommit:e=>j({categoryField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-aggregate`,label:z(`engine.inspector.widget.aggregate`,o),children:(0,V.jsxs)(u,{value:D.aggregate??`count`,onValueChange:e=>j({aggregate:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-aggregate`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Re.map(e=>(0,V.jsx)(y,{value:e,children:e},e))})]})}),(0,V.jsx)($,{id:`widget-color`,label:z(`engine.inspector.widget.color`,o),children:(0,V.jsx)(pe,{value:D.colorVariant??`default`,onChange:e=>j({colorVariant:e}),disabled:a,options:ze.map(e=>({value:e}))})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsx)($,{id:`widget-w`,label:z(`engine.inspector.widget.width`,o),children:(0,V.jsx)(P,{id:`widget-w`,type:`number`,min:1,value:D.layout?.w??1,onChange:e=>j({layout:{...D.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,V.jsx)($,{id:`widget-h`,label:z(`engine.inspector.widget.height`,o),children:(0,V.jsx)(P,{id:`widget-h`,type:`number`,min:1,value:D.layout?.h??1,onChange:e=>j({layout:{...D.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,V.jsx)(`div`,{className:`pt-2 border-t`,children:(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(k,1),n({widgets:t}),r()},children:z(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(F,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function He({message:e,onClose:t,locale:n}){return(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,V.jsx)(`p`,{children:e}),(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:z(`engine.inspector.widget.close`,n)})]})}export{Te as a,K as c,q as i,H as l,Ie as n,De as o,X as r,Oe as s,Ve as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e,t,u as n}from"./vendor-react-
|
|
1
|
+
import{f as e,t,u as n}from"./vendor-react-ClIa1CJA.js";import{Do as r,Gi as i,Jn as a,Qn as o,Tr as s,Xn as c,Yn as l,Yr as u,Zn as d}from"./ui-components-BecTKcFn.js";var f=t();function p(){let t=n(),{appName:p}=e(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:i,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:u,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:s,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:r,href:`${m}/developer/public-forms`}];return(0,f.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Developer`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Tools for building, debugging, and sharing ObjectStack apps`})]}),(0,f.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:h.map(e=>{let n=e.icon;return(0,f.jsxs)(a,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>t(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:[(0,f.jsxs)(d,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(n,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(o,{className:`text-base`,children:e.title}),(0,f.jsx)(c,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(l,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{W as r,vt as i}from"./framework-DI54pxGD.js";var a=e(t(),1),o=n(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({user:t,app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,evaluator:new i(e)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
|
|
@@ -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{k as r}from"./framework-DI54pxGD.js";import{Ft as i,Gt as a,Ii as o,It as s,Jn as c,Ki as l,Lt as u,Mt as d,Pa as f,Pt as p,Qn as m,Rt as h,Tr as g,Xn as _,Yn as v,Zn as y,cs as b,ct as x,dt as S,er as C,ft as w,gr as T,lt as E,nn as D,on as O,ot as k,ps as A,st as j,tt as M,ut as N,ws as P,xs as F}from"./ui-components-BecTKcFn.js";import"./src-KdhDBRhc.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:F,cls:`text-emerald-600 border-emerald-300`},completed:{icon:F,cls:`text-emerald-600 border-emerald-300`},failed:{icon:A,cls:`text-red-600 border-red-300`},error:{icon:A,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:b,cls:`text-amber-600 border-amber-300`},skipped:{icon:P,cls:`text-muted-foreground`}}[e]??{icon:P,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(C,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[u,f]=(0,I.useState)(``),[p,h]=(0,I.useState)(0),b=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!u&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{b()},[b]);let x=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(g,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:b,disabled:i,children:[(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[i&&(0,L.jsx)(d,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:u,onChange:e=>f(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),x&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:x.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:x.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[p,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),d(null),h(null)},[t?.name]);let g=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(c,{children:[(0,L.jsxs)(y,{className:`pb-3`,children:[(0,L.jsx)(m,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(v,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(w,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>g(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(M,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(D,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(T,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}s(!0),h(null),d(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{s(!1)}},disabled:o,size:`sm`,children:[o?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2`}),o?`Running…`:`Run Flow`]})}),(u||p)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[p||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(F,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,l]=(0,I.useState)([]),[g,b]=(0,I.useState)(!0),[w,D]=(0,I.useState)(null),[O,A]=(0,I.useState)(null),[M,P]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){D(`automation.listRuns is not available on this client`),b(!1);return}b(!0),D(null);try{let n=await e.automation.listRuns(t,{limit:20});l(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){D(e?.message??String(e))}finally{b(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),P(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);P(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:W,disabled:g,children:[g?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[g&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`})]}),!g&&w&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),!g&&!w&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!g&&!w&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(S,{children:[(0,L.jsx)(E,{children:`Run`}),(0,L.jsx)(E,{children:`Status`}),(0,L.jsx)(E,{children:`Started`}),(0,L.jsx)(E,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(S,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!O,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(i,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(u,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,O]}),(0,L.jsx)(s,{children:M&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:M.status}),typeof M.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[M.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(M.startedAt)})]})})]}),(0,L.jsxs)(a,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&M&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(M.steps)&&M.steps.length>0?M.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:M})]})})]})]})})]})}export{H as FlowRunsPage};
|