@lunora/studio 1.0.0-alpha.35 → 1.0.0-alpha.350
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/LICENSE.md +6 -0
- package/README.md +4 -4
- package/dist/index.d.mts +1618 -0
- package/dist/index.d.ts +1010 -809
- package/dist/index.mjs +1 -0
- package/dist/mount.d.mts +23 -0
- package/dist/mount.d.ts +13 -11
- package/dist/mount.mjs +1 -0
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -0
- package/dist/packem_chunks/ApiTab.mjs +1 -0
- package/dist/packem_chunks/AuditPanel.mjs +1 -0
- package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -0
- package/dist/packem_chunks/ExportImportPanel.mjs +8 -0
- package/dist/packem_chunks/FileBrowser.mjs +4 -0
- package/dist/packem_chunks/FunctionRunner.mjs +1 -0
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -0
- package/dist/packem_chunks/HealthPanel.mjs +1 -0
- package/dist/packem_chunks/InsightsPanel.mjs +1 -0
- package/dist/packem_chunks/LogsPanel.mjs +1 -0
- package/dist/packem_chunks/MailPanel.mjs +2 -0
- package/dist/packem_chunks/MetricsPanel.mjs +1 -0
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -0
- package/dist/packem_chunks/PitrPanel.mjs +1 -0
- package/dist/packem_chunks/SchemaViewer.mjs +1 -0
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -0
- package/dist/packem_chunks/SettingsPanel.mjs +1 -0
- package/dist/packem_chunks/SqlEditorPanel.mjs +10 -0
- package/dist/packem_chunks/TableEditor.mjs +1 -0
- package/dist/packem_chunks/agents-panel.mjs +1 -0
- package/dist/packem_chunks/ai-usage-panel.mjs +1 -0
- package/dist/packem_chunks/analytics-panel.mjs +1 -0
- package/dist/packem_chunks/architecture-panel.mjs +1 -0
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -0
- package/dist/packem_chunks/auth-config-panel.mjs +1 -0
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -0
- package/dist/packem_chunks/containers-panel.mjs +1 -0
- package/dist/packem_chunks/dashboards-panel.mjs +1 -0
- package/dist/packem_chunks/evals-panel.mjs +1 -0
- package/dist/packem_chunks/fanout-panel.mjs +1 -0
- package/dist/packem_chunks/flags-panel.mjs +1 -0
- package/dist/packem_chunks/issues-panel.mjs +1 -0
- package/dist/packem_chunks/kv-browser.mjs +1 -0
- package/dist/packem_chunks/log-drains-panel.mjs +4 -0
- package/dist/packem_chunks/migrations-route.mjs +1 -0
- package/dist/packem_chunks/organizations-panel.mjs +1 -0
- package/dist/packem_chunks/payments-panel.mjs +1 -0
- package/dist/packem_chunks/permissions-panel.mjs +1 -0
- package/dist/packem_chunks/privacy-requests-panel.mjs +1 -0
- package/dist/packem_chunks/queues-panel.mjs +1 -0
- package/dist/packem_chunks/reactors-panel.mjs +1 -0
- package/dist/packem_chunks/rls-panel.mjs +1 -0
- package/dist/packem_chunks/schedule-panel.mjs +1 -0
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -0
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -0
- package/dist/packem_chunks/sync-client-panel.mjs +1 -0
- package/dist/packem_chunks/theme-indicator.mjs +1 -0
- package/dist/packem_chunks/traces-panel.mjs +1 -0
- package/dist/packem_chunks/users-panel.mjs +1 -0
- package/dist/packem_chunks/vector-browser.mjs +1 -0
- package/dist/packem_chunks/workflows-panel.mjs +1 -0
- package/dist/packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs +1 -0
- package/dist/packem_shared/ApiDocsPanel-B_RaW7Br.mjs +2 -0
- package/dist/packem_shared/ApiReferencePanel-u9Rrljdf.mjs +1 -0
- package/dist/packem_shared/CommandPalette-5OsK8PNe.mjs +1 -0
- package/dist/packem_shared/ConfirmButton-CIXYF6Mg.mjs +1 -0
- package/dist/packem_shared/ConnectionBadge-BfcoN-VE.mjs +1 -0
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs +1 -0
- package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs +1 -0
- package/dist/packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs +1 -0
- package/dist/packem_shared/DataBrowser-Cc1qZX-4.mjs +4 -0
- package/dist/packem_shared/DataFilters--ocFTVT2.mjs +1 -0
- package/dist/packem_shared/ErrorBoundary-BWNF98VF.mjs +1 -0
- package/dist/packem_shared/GlobalDataBrowser-Hq6gTlkb.mjs +1 -0
- package/dist/packem_shared/HomePanel-DeyYLVxc.mjs +1 -0
- package/dist/packem_shared/MigrationsPanel-CMZYYcQ5.mjs +1 -0
- package/dist/packem_shared/OpenRpcReferencePanel-E9cDfHRv.mjs +1 -0
- package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.mjs +1 -0
- package/dist/packem_shared/ScheduledJobs-D4CUj7aX.mjs +1 -0
- package/dist/packem_shared/ShardInput-CoySruKZ.mjs +1 -0
- package/dist/packem_shared/Studio-BhTqTeGb.mjs +1 -0
- package/dist/packem_shared/StudioApp-B1d0beD4.mjs +1 -0
- package/dist/packem_shared/StudioI18nProvider-CGXCPnQn.mjs +1 -0
- package/dist/packem_shared/advisor-view-fNcNYW2Q.mjs +1 -0
- package/dist/packem_shared/aggregateMetrics-DKFJc-o5.mjs +1 -0
- package/dist/packem_shared/alert-PB5W11MM.mjs +1 -0
- package/dist/packem_shared/app.d-D425h1XO.d.mts +352 -0
- package/dist/packem_shared/app.d-D425h1XO.d.ts +352 -0
- package/dist/packem_shared/auth-pager-DW77WeZw.mjs +1 -0
- package/dist/packem_shared/badge-r_5B4LHP.mjs +1 -0
- package/dist/packem_shared/bar-chart-BCsEIQoQ.mjs +6 -0
- package/dist/packem_shared/browser-storage-BH1MxLZs.mjs +1 -0
- package/dist/packem_shared/button-q0UYSmrn.mjs +1 -0
- package/dist/packem_shared/card-By2O8ULa.mjs +1 -0
- package/dist/packem_shared/cf-links-CBJ5SywP.mjs +1 -0
- package/dist/packem_shared/checkbox-CnS9cyCz.mjs +1 -0
- package/dist/packem_shared/control-button-BOZ5K-FC.mjs +1 -0
- package/dist/packem_shared/data-grid-r3isM8Nq.mjs +1 -0
- package/dist/packem_shared/data-view-params-C-_G-biH.mjs +1 -0
- package/dist/packem_shared/diagram-export-panel-aBDQdX4e.mjs +2 -0
- package/dist/packem_shared/dropdown-menu-jLZenfWH.mjs +2 -0
- package/dist/packem_shared/empty-state-D7jEML_T.mjs +1 -0
- package/dist/packem_shared/error-alert-54TiaMvZ.mjs +1 -0
- package/dist/packem_shared/grid-features-2c5SaBtH.mjs +6 -0
- package/dist/packem_shared/grid-pagination-DY2erU65.mjs +1 -0
- package/dist/packem_shared/home-panel-0XMGe1hP.mjs +3 -0
- package/dist/packem_shared/input-CXhxesPC.mjs +1 -0
- package/dist/packem_shared/internal-BXEjuLPN.mjs +2 -0
- package/dist/packem_shared/label-DKFzyHq6.mjs +1 -0
- package/dist/packem_shared/live-status-D1GasNsH.mjs +1 -0
- package/dist/packem_shared/log-fields-BolUoZ9g.mjs +1 -0
- package/dist/packem_shared/log-line-BWDt_F56.mjs +1 -0
- package/dist/packem_shared/metrics-format-1sNGG47R.mjs +1 -0
- package/dist/packem_shared/modal-shell-CDztwLnv.mjs +1 -0
- package/dist/packem_shared/operation-console-provider-DoloEvon.mjs +1 -0
- package/dist/packem_shared/recording-client-MbGZ28I0.mjs +1 -0
- package/dist/packem_shared/reference-view-DCEC5kjY.mjs +13 -0
- package/dist/packem_shared/schema-diagram-k7cFl7Wp.mjs +2 -0
- package/dist/packem_shared/scroll-area-CXCQH7VT.mjs +2 -0
- package/dist/packem_shared/select-DPyS18Vy.mjs +2 -0
- package/dist/packem_shared/shard-history-CaO3C4KQ.mjs +1 -0
- package/dist/packem_shared/shortcuts-B9gDaXmw.mjs +1 -0
- package/dist/packem_shared/skeleton-DX1gfixl.mjs +1 -0
- package/dist/packem_shared/sparkline-B_sPPO_8.mjs +1 -0
- package/dist/packem_shared/sql-result-table-CatgdmMh.mjs +1 -0
- package/dist/packem_shared/stat-card-BAv73QtB.mjs +1 -0
- package/dist/packem_shared/storage-tier-C2mKwYRj.mjs +1 -0
- package/dist/packem_shared/studio-CA3ZKwVK.mjs +2 -0
- package/dist/packem_shared/table-D0SBiDu-.mjs +2 -0
- package/dist/packem_shared/table-list-sidebar-nA7g7uSk.mjs +1 -0
- package/dist/packem_shared/textarea--40GKAyz.mjs +1 -0
- package/dist/packem_shared/trace-handoff-BV3EWqy_.mjs +1 -0
- package/dist/packem_shared/use-admin-query-BW9IuacC.mjs +1 -0
- package/dist/packem_shared/use-admin-spec-BdNLZbTO.mjs +1 -0
- package/dist/packem_shared/use-async-submit-2eBBD0-m.mjs +1 -0
- package/dist/packem_shared/use-auth-config-KO9tnI39.mjs +1 -0
- package/dist/packem_shared/use-mirrored-ref-CVDf2z1M.mjs +1 -0
- package/dist/packem_shared/use-open-trace-B_0LbTD7.mjs +1 -0
- package/dist/packem_shared/use-shard-key-BsP3o5wT.mjs +1 -0
- package/dist/packem_shared/use-sql-assistant-DXnqbBs-.mjs +1 -0
- package/dist/packem_shared/use-studio-client-DCA50tF2.mjs +1 -0
- package/dist/packem_shared/useDebounced-DVeQ5-oW.mjs +1 -0
- package/dist/packem_shared/utils-bhneXptQ.mjs +1 -0
- package/dist/packem_shared/virtual-rect-D_j7aLxX.mjs +1 -0
- package/dist/standalone/chunk-26OKWFLO.js +1 -0
- package/dist/standalone/chunk-2EL4EMYZ.js +1 -0
- package/dist/standalone/chunk-2O6KKVH2.js +1 -0
- package/dist/standalone/chunk-2WNL74MI.js +4 -0
- package/dist/standalone/chunk-2X6O33OX.js +1 -0
- package/dist/standalone/chunk-2ZO7XY3Z.js +1 -0
- package/dist/standalone/chunk-3GXPALXG.js +1 -0
- package/dist/standalone/chunk-3Y5K3IQO.js +1 -0
- package/dist/standalone/chunk-4C4THJUD.js +1 -0
- package/dist/standalone/chunk-4IEMXFUB.js +1 -0
- package/dist/standalone/chunk-4SQBAPY6.js +1 -0
- package/dist/standalone/chunk-4ZEL6BYL.js +1 -0
- package/dist/standalone/chunk-5DNGK3NT.js +1 -0
- package/dist/standalone/chunk-5J32EGHF.js +1 -0
- package/dist/standalone/chunk-5NZWQEEJ.js +1 -0
- package/dist/standalone/chunk-6I42AM75.js +1 -0
- package/dist/standalone/chunk-6M7FLLMT.js +1 -0
- package/dist/standalone/chunk-6QEXGYWH.js +1 -0
- package/dist/standalone/chunk-7AZYREIY.js +1 -0
- package/dist/standalone/chunk-7F3S5OQT.js +1 -0
- package/dist/standalone/chunk-7MN724WR.js +1 -0
- package/dist/standalone/chunk-7RGYCU6F.js +1 -0
- package/dist/standalone/chunk-A566HCBX.js +1 -0
- package/dist/standalone/chunk-AOHKAKKL.js +1 -0
- package/dist/standalone/chunk-AP4PC2M4.js +1 -0
- package/dist/standalone/chunk-B3AXFXAD.js +1 -0
- package/dist/standalone/chunk-B7MHW3A5.js +1 -0
- package/dist/standalone/chunk-BHOLL76W.js +8 -0
- package/dist/standalone/chunk-BTRYFPZH.js +1 -0
- package/dist/standalone/chunk-BVKQA5OL.js +1 -0
- package/dist/standalone/chunk-CGZVMM3P.js +1 -0
- package/dist/standalone/chunk-CIVMATZK.js +3 -0
- package/dist/standalone/chunk-CLINNLLE.js +1 -0
- package/dist/standalone/chunk-CTE6RPXC.js +1 -0
- package/dist/standalone/chunk-CW57Q264.js +1 -0
- package/dist/standalone/chunk-D7JK65OK.js +1 -0
- package/dist/standalone/chunk-DBVJ5VLI.js +1 -0
- package/dist/standalone/chunk-DS7HZKZ2.js +6 -0
- package/dist/standalone/chunk-DX55P3KZ.js +1 -0
- package/dist/standalone/chunk-E26OT26O.js +1 -0
- package/dist/standalone/chunk-E32FS6PE.js +5 -0
- package/dist/standalone/chunk-E3VSRIQU.js +1 -0
- package/dist/standalone/chunk-EDGOSJXL.js +1 -0
- package/dist/standalone/chunk-EOR73TZZ.js +1 -0
- package/dist/standalone/chunk-F5LTDUMB.js +1 -0
- package/dist/standalone/chunk-FLVDICZL.js +1 -0
- package/dist/standalone/chunk-FPIUVV7Q.js +1 -0
- package/dist/standalone/chunk-GMW2DYFU.js +1 -0
- package/dist/standalone/chunk-GPOSJNMV.js +14 -0
- package/dist/standalone/chunk-GQYA5W5T.js +1 -0
- package/dist/standalone/chunk-HFYFYNSX.js +1 -0
- package/dist/standalone/chunk-HKLF627N.js +1 -0
- package/dist/standalone/chunk-HKPDPKXD.js +1 -0
- package/dist/standalone/chunk-HLAAOW33.js +1 -0
- package/dist/standalone/chunk-HOPAJ5F6.js +15 -0
- package/dist/standalone/chunk-IBJVVHV5.js +1 -0
- package/dist/standalone/chunk-IH2CJZF2.js +1 -0
- package/dist/standalone/chunk-JAHK7RRJ.js +1 -0
- package/dist/standalone/chunk-JG2C7SS2.js +1 -0
- package/dist/standalone/chunk-JGMQQ3S7.js +1 -0
- package/dist/standalone/chunk-JTGGWF7R.js +1 -0
- package/dist/standalone/chunk-KFNDET5D.js +1 -0
- package/dist/standalone/chunk-KRPXOSBL.js +1 -0
- package/dist/standalone/chunk-KYONGQQ4.js +1 -0
- package/dist/standalone/chunk-LIGOLZND.js +1 -0
- package/dist/standalone/chunk-LKCO3E2B.js +1 -0
- package/dist/standalone/chunk-LOV52GLG.js +1 -0
- package/dist/standalone/chunk-LPINY2IJ.js +19 -0
- package/dist/standalone/chunk-LRXCL6IA.js +1 -0
- package/dist/standalone/chunk-LUHXNZI4.js +2 -0
- package/dist/standalone/chunk-MD67S53Z.js +1 -0
- package/dist/standalone/chunk-MDAXV2XH.js +4 -0
- package/dist/standalone/chunk-MFNO5BFR.js +8 -0
- package/dist/standalone/chunk-MMJTKSHL.js +1 -0
- package/dist/standalone/chunk-NGVP66OH.js +1 -0
- package/dist/standalone/chunk-NMVFSJM7.js +1 -0
- package/dist/standalone/chunk-NVHHB5EV.js +2 -0
- package/dist/standalone/chunk-O3FDK56W.js +1 -0
- package/dist/standalone/chunk-OECMBE6Q.js +1 -0
- package/dist/standalone/chunk-OSJ7HV7B.js +1 -0
- package/dist/standalone/chunk-OUFWXYEF.js +1 -0
- package/dist/standalone/chunk-OXFKZ4BM.js +1 -0
- package/dist/standalone/chunk-P5GAJKDW.js +1 -0
- package/dist/standalone/chunk-P6L6ABWO.js +1 -0
- package/dist/standalone/chunk-PZZWUL5U.js +1 -0
- package/dist/standalone/chunk-QAQVT4FS.js +1 -0
- package/dist/standalone/chunk-R36QXQZX.js +1 -0
- package/dist/standalone/chunk-R3KLR5EP.js +1 -0
- package/dist/standalone/chunk-RXVXXRYD.js +1 -0
- package/dist/standalone/chunk-S7XAAH7U.js +1 -0
- package/dist/standalone/chunk-SDQH4HR6.js +3 -0
- package/dist/standalone/chunk-SFY646MC.js +1 -0
- package/dist/standalone/chunk-SJLEEYCR.js +1 -0
- package/dist/standalone/chunk-SLIDAWNX.js +1 -0
- package/dist/standalone/chunk-SOO2HXV6.js +1 -0
- package/dist/standalone/chunk-SXD6JQXF.js +1 -0
- package/dist/standalone/{chunk-BJGBHGK3.js → chunk-SYGCASPT.js} +1 -1
- package/dist/standalone/chunk-TDVDZ7XQ.js +1 -0
- package/dist/standalone/chunk-TRZTGE4R.js +1 -0
- package/dist/standalone/chunk-TWMS2TMF.js +1 -0
- package/dist/standalone/chunk-U76DVXTR.js +21 -0
- package/dist/standalone/chunk-UTX6IBA3.js +1 -0
- package/dist/standalone/chunk-UYEZR3BI.js +1 -0
- package/dist/standalone/chunk-UZIBQZ2F.js +1 -0
- package/dist/standalone/chunk-VB6YJKPA.js +1 -0
- package/dist/standalone/chunk-VEWQWS3J.js +1 -0
- package/dist/standalone/chunk-W2BCSK5S.js +1 -0
- package/dist/standalone/chunk-W2XSKODB.js +1 -0
- package/dist/standalone/chunk-W7MRISE3.js +1 -0
- package/dist/standalone/chunk-W7Z35E2E.js +1 -0
- package/dist/standalone/chunk-WIET27J3.js +1 -0
- package/dist/standalone/chunk-WQGT24W6.js +1 -0
- package/dist/standalone/chunk-WS36BO4R.js +1 -0
- package/dist/standalone/chunk-WZTY3ZYI.js +1 -0
- package/dist/standalone/chunk-X5KWBDTF.js +1 -0
- package/dist/standalone/chunk-X74GEPSG.js +1 -0
- package/dist/standalone/chunk-XBZUJDHD.js +1 -0
- package/dist/standalone/chunk-XMEVNOCA.js +1 -0
- package/dist/standalone/chunk-XWEDIIIT.js +1 -0
- package/dist/standalone/chunk-XYR5NST4.js +1 -0
- package/dist/standalone/chunk-YHTHRYP5.js +1 -0
- package/dist/standalone/chunk-YJ2WHOGO.js +1 -0
- package/dist/standalone/chunk-YJWR6ZWC.js +1 -0
- package/dist/standalone/chunk-Z5EV64KS.js +1 -0
- package/dist/standalone/chunk-ZBFWT34B.js +59 -0
- package/dist/standalone/chunk-ZBON5T5A.js +1 -0
- package/dist/standalone/chunk-ZGSL4DPP.js +1 -0
- package/dist/standalone/chunk-ZMQ6PKLN.js +1 -0
- package/dist/standalone/chunk-ZTOREMGH.js +1 -0
- package/dist/standalone/chunk-ZTOXQK4V.js +1 -0
- package/dist/standalone/chunk-ZWDORIZY.js +1 -0
- package/dist/standalone/chunk-ZZAJHNZ6.js +1 -0
- package/dist/standalone/studio.js +9 -214
- package/dist/styles.css +2 -2
- package/package.json +26 -22
- package/dist/index.js +0 -41
- package/dist/mount.js +0 -27
- package/dist/packem_chunks/ApiTab.js +0 -251
- package/dist/packem_chunks/AuditPanel.js +0 -200
- package/dist/packem_chunks/ExportImportPanel.js +0 -198
- package/dist/packem_chunks/FileBrowser.js +0 -2932
- package/dist/packem_chunks/FunctionRunner.js +0 -343
- package/dist/packem_chunks/FunctionStatsPanel.js +0 -377
- package/dist/packem_chunks/HealthPanel.js +0 -648
- package/dist/packem_chunks/InsightsPanel.js +0 -462
- package/dist/packem_chunks/LogsPanel.js +0 -827
- package/dist/packem_chunks/MailPanel.js +0 -353
- package/dist/packem_chunks/MetricsPanel.js +0 -1344
- package/dist/packem_chunks/MigrationsPanel.js +0 -239
- package/dist/packem_chunks/PitrPanel.js +0 -252
- package/dist/packem_chunks/SchemaViewer.js +0 -2513
- package/dist/packem_chunks/SecurityAdvisorPanel.js +0 -95
- package/dist/packem_chunks/SettingsPanel.js +0 -391
- package/dist/packem_chunks/SqlEditorPanel.js +0 -2323
- package/dist/packem_chunks/TableEditor.js +0 -313
- package/dist/packem_chunks/analytics-panel.js +0 -261
- package/dist/packem_chunks/auth-config-panel.js +0 -179
- package/dist/packem_chunks/auth-sessions-panel.js +0 -175
- package/dist/packem_chunks/containers-panel.js +0 -247
- package/dist/packem_chunks/dashboards-panel.js +0 -780
- package/dist/packem_chunks/fanout-panel.js +0 -482
- package/dist/packem_chunks/flags-panel.js +0 -176
- package/dist/packem_chunks/kv-browser.js +0 -1896
- package/dist/packem_chunks/log-drains-panel.js +0 -273
- package/dist/packem_chunks/organizations-panel.js +0 -670
- package/dist/packem_chunks/payments-panel.js +0 -186
- package/dist/packem_chunks/permissions-panel.js +0 -805
- package/dist/packem_chunks/queues-panel.js +0 -1052
- package/dist/packem_chunks/rls-panel.js +0 -315
- package/dist/packem_chunks/schedule-panel.js +0 -831
- package/dist/packem_chunks/sparkline.js +0 -79
- package/dist/packem_chunks/storage-rules-panel.js +0 -140
- package/dist/packem_chunks/subscriptions-panel.js +0 -238
- package/dist/packem_chunks/users-panel.js +0 -1265
- package/dist/packem_chunks/vector-browser.js +0 -281
- package/dist/packem_chunks/workflows-panel.js +0 -562
- package/dist/packem_shared/ADMIN_FUNCTIONS-BHHJi3Gb.js +0 -52
- package/dist/packem_shared/ApiDocsPanel-D4CJf2ad.js +0 -842
- package/dist/packem_shared/ApiReferencePanel-Co_wpRF2.js +0 -230
- package/dist/packem_shared/CommandPalette-BUPpbpMc.js +0 -373
- package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
- package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
- package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
- package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
- package/dist/packem_shared/DataBrowser-BeVNxSVm.js +0 -4493
- package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
- package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
- package/dist/packem_shared/GlobalDataBrowser-ErfvIs1S.js +0 -289
- package/dist/packem_shared/HomePanel-D9MQk8I7.js +0 -14
- package/dist/packem_shared/OpenRpcReferencePanel-DLWzrIx9.js +0 -192
- package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
- package/dist/packem_shared/ScheduledJobs-ClaNpZsg.js +0 -262
- package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
- package/dist/packem_shared/Studio-C48P1K5W.js +0 -16
- package/dist/packem_shared/StudioApp-Cqh-SYm2.js +0 -657
- package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
- package/dist/packem_shared/advisor-view-D3-U4kRR.js +0 -159
- package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
- package/dist/packem_shared/alert-CdAET2K_.js +0 -68
- package/dist/packem_shared/app.d-CNLRTrWw.d.ts +0 -300
- package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
- package/dist/packem_shared/bar-chart-DSwcWIRy.js +0 -3246
- package/dist/packem_shared/browser-storage-tLOxkIHd.js +0 -185
- package/dist/packem_shared/button-BhsN2uZH.js +0 -49
- package/dist/packem_shared/card-DURq3ElK.js +0 -175
- package/dist/packem_shared/cf-links-BZfRdxSE.js +0 -8
- package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
- package/dist/packem_shared/data-grid-Jz8FqQ2C.js +0 -183
- package/dist/packem_shared/data-view-params-Cd6yRVbv.js +0 -96
- package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
- package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
- package/dist/packem_shared/error-alert-BBT6D22d.js +0 -114
- package/dist/packem_shared/grid-features-CUr8Z1_O.js +0 -745
- package/dist/packem_shared/home-panel-CoGxi-oj.js +0 -1639
- package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
- package/dist/packem_shared/internal-DTsYVn-g.js +0 -97
- package/dist/packem_shared/label-D8ykjn5J.js +0 -46
- package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
- package/dist/packem_shared/modal-shell-hyaJvIJ6.js +0 -100
- package/dist/packem_shared/reference-view-CSKyUyPl.js +0 -2141
- package/dist/packem_shared/scroll-area-DLhcy-ml.js +0 -93
- package/dist/packem_shared/select-UkNYCT3s.js +0 -273
- package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
- package/dist/packem_shared/skeleton-CGhL0p20.js +0 -45
- package/dist/packem_shared/sparkline-BnA1kC9X.js +0 -93
- package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
- package/dist/packem_shared/studio-CPHA_-3I.js +0 -4015
- package/dist/packem_shared/table-DsCa9Qp9.js +0 -246
- package/dist/packem_shared/table-list-sidebar-B5psdSV1.js +0 -832
- package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
- package/dist/packem_shared/use-admin-query-BHPKmPuj.js +0 -106
- package/dist/packem_shared/use-auth-capabilities-C-VH0oJJ.js +0 -32
- package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
- package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
- package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
- package/dist/standalone/chunk-25VHPD2I.js +0 -1
- package/dist/standalone/chunk-2GGMGPEP.js +0 -1
- package/dist/standalone/chunk-2K47A3P6.js +0 -1
- package/dist/standalone/chunk-2NGUNNGW.js +0 -1
- package/dist/standalone/chunk-3CJW6NWG.js +0 -4
- package/dist/standalone/chunk-3OA7PECS.js +0 -6
- package/dist/standalone/chunk-46K3NKPA.js +0 -1
- package/dist/standalone/chunk-474C2O7W.js +0 -1
- package/dist/standalone/chunk-4H2OJBXO.js +0 -1
- package/dist/standalone/chunk-4QHKBC77.js +0 -1
- package/dist/standalone/chunk-55YA7ZZI.js +0 -76
- package/dist/standalone/chunk-5OH3VPZF.js +0 -1
- package/dist/standalone/chunk-5OIBXYZM.js +0 -1
- package/dist/standalone/chunk-6GFEVKJP.js +0 -1
- package/dist/standalone/chunk-6UGM5IHN.js +0 -4
- package/dist/standalone/chunk-6WRZP62V.js +0 -1
- package/dist/standalone/chunk-764T6X6X.js +0 -1
- package/dist/standalone/chunk-7TJJXVSE.js +0 -1
- package/dist/standalone/chunk-7VF3IAAW.js +0 -2
- package/dist/standalone/chunk-7WNJ4Q7Z.js +0 -8
- package/dist/standalone/chunk-AHILM3ZP.js +0 -1
- package/dist/standalone/chunk-AJIUI7DD.js +0 -1
- package/dist/standalone/chunk-BACPICH6.js +0 -1
- package/dist/standalone/chunk-BI35RXKQ.js +0 -1
- package/dist/standalone/chunk-BOXSWNXZ.js +0 -1
- package/dist/standalone/chunk-BQUQS7QN.js +0 -1
- package/dist/standalone/chunk-CKSHCYGC.js +0 -2
- package/dist/standalone/chunk-DORBUITF.js +0 -1
- package/dist/standalone/chunk-DVC6YWVP.js +0 -1
- package/dist/standalone/chunk-DVKPRFIJ.js +0 -1
- package/dist/standalone/chunk-DWDILV2E.js +0 -1
- package/dist/standalone/chunk-DWTBY343.js +0 -1
- package/dist/standalone/chunk-EIQW6ACH.js +0 -1
- package/dist/standalone/chunk-EUIHTPKI.js +0 -1
- package/dist/standalone/chunk-FCSPAJW4.js +0 -1
- package/dist/standalone/chunk-FKO3HO6I.js +0 -4
- package/dist/standalone/chunk-GMSGZDDH.js +0 -13
- package/dist/standalone/chunk-GTM65MVX.js +0 -1
- package/dist/standalone/chunk-HV7G6DFP.js +0 -5
- package/dist/standalone/chunk-ILCTSAOB.js +0 -1
- package/dist/standalone/chunk-IODYGARQ.js +0 -1
- package/dist/standalone/chunk-J6J54MBP.js +0 -1
- package/dist/standalone/chunk-JE2YOAB7.js +0 -4
- package/dist/standalone/chunk-JFSZIUZT.js +0 -4
- package/dist/standalone/chunk-JSEXCW5Q.js +0 -1
- package/dist/standalone/chunk-K3GNLVYK.js +0 -1
- package/dist/standalone/chunk-KEGAWN6Y.js +0 -1
- package/dist/standalone/chunk-KZ6INM5M.js +0 -1
- package/dist/standalone/chunk-LD2R263D.js +0 -1
- package/dist/standalone/chunk-LI43EKM6.js +0 -1
- package/dist/standalone/chunk-M55U7NHO.js +0 -1
- package/dist/standalone/chunk-MPTM7ZU3.js +0 -3
- package/dist/standalone/chunk-MPYFGAOW.js +0 -1
- package/dist/standalone/chunk-NJFMWO6P.js +0 -1
- package/dist/standalone/chunk-O3NAGRTR.js +0 -1
- package/dist/standalone/chunk-O77VNUFD.js +0 -1
- package/dist/standalone/chunk-OCHNCAXJ.js +0 -1
- package/dist/standalone/chunk-PACH5AHG.js +0 -1
- package/dist/standalone/chunk-PN5NCZDX.js +0 -1
- package/dist/standalone/chunk-PVZI3CXP.js +0 -19
- package/dist/standalone/chunk-PZ7HD5T2.js +0 -1
- package/dist/standalone/chunk-QAFAJBAW.js +0 -1
- package/dist/standalone/chunk-QBAT52GB.js +0 -1
- package/dist/standalone/chunk-QLM6FYZW.js +0 -2
- package/dist/standalone/chunk-RRAFQ5G2.js +0 -1
- package/dist/standalone/chunk-RRCPZMC2.js +0 -22
- package/dist/standalone/chunk-RSEEHNFI.js +0 -1
- package/dist/standalone/chunk-SEU5V7I6.js +0 -1
- package/dist/standalone/chunk-SLKF2L74.js +0 -1
- package/dist/standalone/chunk-SVR644RF.js +0 -1
- package/dist/standalone/chunk-TAD43CG5.js +0 -1
- package/dist/standalone/chunk-TBMYIZIO.js +0 -1
- package/dist/standalone/chunk-TDL7NEWA.js +0 -1
- package/dist/standalone/chunk-TO4JQX7W.js +0 -1
- package/dist/standalone/chunk-TQ36RWOP.js +0 -1
- package/dist/standalone/chunk-U4OAQPBT.js +0 -1
- package/dist/standalone/chunk-UII66UVF.js +0 -1
- package/dist/standalone/chunk-UK64ZSUW.js +0 -1
- package/dist/standalone/chunk-VLXV72QE.js +0 -1
- package/dist/standalone/chunk-VSHUSN6T.js +0 -1
- package/dist/standalone/chunk-VTGBPW24.js +0 -1
- package/dist/standalone/chunk-WXPWVBIY.js +0 -1
- package/dist/standalone/chunk-X6F22DBL.js +0 -1
- package/dist/standalone/chunk-X7MMBSNW.js +0 -1
- package/dist/standalone/chunk-XGMIDFUK.js +0 -1
- package/dist/standalone/chunk-XNJNSCLM.js +0 -1
- package/dist/standalone/chunk-XUGSA2NG.js +0 -1
- package/dist/standalone/chunk-XZE2RNDA.js +0 -1
- package/dist/standalone/chunk-Y2ZPNDL7.js +0 -4
- package/dist/standalone/chunk-YAECF5LW.js +0 -1
- package/dist/standalone/chunk-YEVCU7TB.js +0 -13
- package/dist/standalone/chunk-YV43BOP7.js +0 -1
- package/dist/standalone/chunk-ZHVTQ37P.js +0 -1
- package/dist/standalone/chunk-ZPP2KOR4.js +0 -1
- package/dist/standalone/chunk-ZPUO7FNI.js +0 -1
- package/dist/standalone/chunk-ZU4DZ6NK.js +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StudioApp as r}from"./packem_shared/StudioApp-B1d0beD4.mjs";import{CommandPalette as a,openCommandPalette as f}from"./packem_shared/CommandPalette-5OsK8PNe.mjs";import{S as m}from"./packem_shared/studio-CA3ZKwVK.mjs";import{ConfirmButton as l}from"./packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{default as s}from"./packem_shared/ConnectionBadge-BfcoN-VE.mjs";import{ErrorBoundary as d}from"./packem_shared/ErrorBoundary-BWNF98VF.mjs";import{ShardInput as P}from"./packem_shared/ShardInput-CoySruKZ.mjs";import{default as A}from"./packem_chunks/AdvisorHealthPanel.mjs";import{DEFAULT_INSIGHT_THRESHOLDS as I,deriveInsights as T}from"./packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{InsightsPanel as g}from"./packem_chunks/InsightsPanel.mjs";import{default as F}from"./packem_chunks/SecurityAdvisorPanel.mjs";import{default as h}from"./packem_shared/ApiDocsPanel-B_RaW7Br.mjs";import{default as C}from"./packem_shared/ApiReferencePanel-u9Rrljdf.mjs";import{default as O}from"./packem_chunks/ApiTab.mjs";import{default as N}from"./packem_shared/OpenRpcReferencePanel-E9cDfHRv.mjs";import{DataBrowser as U}from"./packem_shared/DataBrowser-Cc1qZX-4.mjs";import{DataFilters as b,toFilterClauses as v}from"./packem_shared/DataFilters--ocFTVT2.mjs";import{GlobalDataBrowser as y}from"./packem_shared/GlobalDataBrowser-Hq6gTlkb.mjs";import{TableEditor as q}from"./packem_chunks/TableEditor.mjs";import{ExportImportPanel as V}from"./packem_chunks/ExportImportPanel.mjs";import{MigrationsPanel as j}from"./packem_shared/MigrationsPanel-CMZYYcQ5.mjs";import{PitrPanel as z}from"./packem_chunks/PitrPanel.mjs";import{FunctionRunner as Q}from"./packem_chunks/FunctionRunner.mjs";import{FunctionStatsPanel as Y}from"./packem_chunks/FunctionStatsPanel.mjs";import{DeploymentHealthPanel as $}from"./packem_chunks/DeploymentHealthPanel.mjs";import{H as oe}from"./packem_shared/home-panel-0XMGe1hP.mjs";import{AuditPanel as te}from"./packem_chunks/AuditPanel.mjs";import{LogsPanel as fe}from"./packem_chunks/LogsPanel.mjs";import{MailPanel as me}from"./packem_chunks/MailPanel.mjs";import{ScheduledJobs as le}from"./packem_shared/ScheduledJobs-D4CUj7aX.mjs";import{default as se}from"./packem_chunks/NotificationsPanel.mjs";import{HealthPanel as de}from"./packem_chunks/HealthPanel.mjs";import{aggregateMetrics as Pe,shardsToAggregate as Se}from"./packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{MetricsPanel as ce}from"./packem_chunks/MetricsPanel.mjs";import{SchemaViewer as Te}from"./packem_chunks/SchemaViewer.mjs";import{SettingsPanel as ge}from"./packem_chunks/SettingsPanel.mjs";import{SqlEditorPanel as Fe}from"./packem_chunks/SqlEditorPanel.mjs";import{FileBrowser as he}from"./packem_chunks/FileBrowser.mjs";import{DEFAULT_AUTO_REFRESH_MS as Ce,useAutoRefresh as He}from"./packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{default as Le}from"./packem_shared/useDebounced-DVeQ5-oW.mjs";import{DEFAULT_LOCALE as Me,createStudioI18n as Ue,studioI18n as Be,useT as be}from"./packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{StudioI18nProvider as we}from"./packem_shared/StudioI18nProvider-CGXCPnQn.mjs";import{ADMIN_FUNCTIONS as Ge,ADMIN_FUNCTION_PREFIX as qe}from"./packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{default as Ve}from"./packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.mjs";export{Ge as ADMIN_FUNCTIONS,qe as ADMIN_FUNCTION_PREFIX,A as AdvisorHealthPanel,h as ApiDocsPanel,C as ApiReferencePanel,O as ApiTab,te as AuditPanel,a as CommandPalette,l as ConfirmButton,s as ConnectionBadge,Ce as DEFAULT_AUTO_REFRESH_MS,I as DEFAULT_INSIGHT_THRESHOLDS,Me as DEFAULT_LOCALE,U as DataBrowser,b as DataFilters,$ as DeploymentHealthPanel,d as ErrorBoundary,V as ExportImportPanel,he as FileBrowser,Q as FunctionRunner,Y as FunctionStatsPanel,y as GlobalDataBrowser,de as HealthPanel,oe as HomePanel,g as InsightsPanel,fe as LogsPanel,me as MailPanel,ce as MetricsPanel,j as MigrationsPanel,se as NotificationsPanel,N as OpenRpcReferencePanel,z as PitrPanel,Ve as STUDIO_ROOT_CLASS,le as ScheduledJobs,Te as SchemaViewer,F as SecurityAdvisorPanel,ge as SettingsPanel,P as ShardInput,Fe as SqlEditorPanel,m as Studio,r as StudioApp,we as StudioI18nProvider,q as TableEditor,Pe as aggregateMetrics,Ue as createStudioI18n,T as deriveInsights,f as openCommandPalette,Se as shardsToAggregate,Be as studioI18n,v as toFilterClauses,He as useAutoRefresh,Le as useDebounced,be as useT};
|
package/dist/mount.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Root } from 'react-dom/client';
|
|
2
|
+
import { S as StudioAppProps } from "./packem_shared/app.d-D425h1XO.mjs";
|
|
3
|
+
import '@lunora/client/admin';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@lingui/core';
|
|
6
|
+
import '@lunora/bindings/analytics-sql';
|
|
7
|
+
import '@lunora/client';
|
|
8
|
+
interface MountStudioOptions extends StudioAppProps {
|
|
9
|
+
/**
|
|
10
|
+
* The container to mount into. Accepts an element or a selector; defaults to
|
|
11
|
+
* `#root`. Throws if the selector matches nothing so misconfiguration fails
|
|
12
|
+
* loudly rather than silently rendering nowhere.
|
|
13
|
+
*/
|
|
14
|
+
readonly container?: Element | string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Mount the batteries-included {@link StudioApp} into the DOM and return the
|
|
18
|
+
* React root (call `.unmount()` to tear it down). This is the entry the
|
|
19
|
+
* standalone app's `main.tsx` and the `@lunora/vite` dev route both call — it
|
|
20
|
+
* keeps the host HTML to a single `<div id="root">` plus one script.
|
|
21
|
+
*/
|
|
22
|
+
declare const mountStudio: (options?: MountStudioOptions) => Root;
|
|
23
|
+
export { MountStudioOptions, mountStudio };
|
package/dist/mount.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { Root } from 'react-dom/client';
|
|
2
|
-
import { S as StudioAppProps } from "./packem_shared/app.d-
|
|
3
|
-
import '@lunora/client';
|
|
2
|
+
import { S as StudioAppProps } from "./packem_shared/app.d-D425h1XO.js";
|
|
3
|
+
import '@lunora/client/admin';
|
|
4
4
|
import 'react';
|
|
5
5
|
import '@lingui/core';
|
|
6
|
+
import '@lunora/bindings/analytics-sql';
|
|
7
|
+
import '@lunora/client';
|
|
6
8
|
interface MountStudioOptions extends StudioAppProps {
|
|
7
9
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* The container to mount into. Accepts an element or a selector; defaults to
|
|
11
|
+
* `#root`. Throws if the selector matches nothing so misconfiguration fails
|
|
12
|
+
* loudly rather than silently rendering nowhere.
|
|
13
|
+
*/
|
|
12
14
|
readonly container?: Element | string;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
|
-
* Mount the batteries-included {@link StudioApp} into the DOM and return the
|
|
16
|
-
* React root (call `.unmount()` to tear it down). This is the entry the
|
|
17
|
-
* standalone app's `main.tsx` and the `@lunora/vite` dev route both call — it
|
|
18
|
-
* keeps the host HTML to a single
|
|
19
|
-
*/
|
|
17
|
+
* Mount the batteries-included {@link StudioApp} into the DOM and return the
|
|
18
|
+
* React root (call `.unmount()` to tear it down). This is the entry the
|
|
19
|
+
* standalone app's `main.tsx` and the `@lunora/vite` dev route both call — it
|
|
20
|
+
* keeps the host HTML to a single `<div id="root">` plus one script.
|
|
21
|
+
*/
|
|
20
22
|
declare const mountStudio: (options?: MountStudioOptions) => Root;
|
|
21
23
|
export { MountStudioOptions, mountStudio };
|
package/dist/mount.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as m}from"@lunora/errors";import{createRoot as i}from"react-dom/client";import{StudioApp as p}from"./packem_shared/StudioApp-B1d0beD4.mjs";import{jsx as u}from"react/jsx-runtime";const a=(n={})=>{const{container:o="#root",...e}=n,t=typeof o=="string"?document.querySelector(o):o;if(t===null)throw new m("INTERNAL",`mountStudio: container ${typeof o=="string"?o:"element"} not found`);const r=i(t);return r.render(u(p,{...e})),r};export{a as mountStudio};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{scoreAdvisor as T}from"@lunora/advisor";import{E as A}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{C as c,a as o}from"../packem_shared/card-By2O8ULa.mjs";import{T as j,a as R,b as f,c as i,d as $,e as m}from"../packem_shared/table-D0SBiDu-.mjs";import{u as v}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as N}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as u}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as e,jsxs as r}from"react/jsx-runtime";const n={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},b={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},E=(s,a)=>`exempt: ${s.exemptReason===void 0||s.exemptReason===""?a:s.exemptReason}`,S=s=>s.toSorted((a,l)=>a.coverage==="clean"&&l.coverage!=="clean"?1:l.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-l.score),Y=({testId:s="advisor-health"})=>{const a=C(),l=v(N.getAdvisories,{},{live:!0}),x=v(N.getAdvisorProcedures,{},{live:!0}),p=l.data?.advisories??null,h=x.data?.procedures??null,t=p===null||h===null?null:T(h,p),g=x.error??l.error;if(g!==null)return e(A,{error:g,testId:`${s}-error`});if(t===null)return e(c,{children:e(o,{className:"py-8 text-center text-muted-foreground","data-testid":`${s}-loading`,children:a("Loading…")})});const k=S(t.procedures);return r("div",{className:"space-y-4","data-testid":s,children:[e(c,{children:r(o,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[r("div",{children:[e("span",{className:u("text-4xl font-semibold tabular-nums",b[t.grade]),"data-testid":`${s}-score`,children:t.score}),e("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),e("span",{className:u("text-sm font-medium uppercase tracking-wide",b[t.grade]),"data-testid":`${s}-grade`,children:t.grade}),r("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${s}-summary`,children:[r("span",{className:n.clean,children:[t.summary.clean," ",a("clean")]}),r("span",{className:n.warned,children:[t.summary.warned," ",a("warned")]}),r("span",{className:n.failing,children:[t.summary.failing," ",a("failing")]}),r("span",{className:n.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&e(c,{children:r(o,{className:"py-4 text-sm","data-testid":`${s}-project`,children:[r("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),r("span",{className:"text-muted-foreground",children:[" — ",t.project.checks.map(d=>d.name).join(", ")]})]})}),e(c,{children:e(o,{className:"p-0",children:r(j,{children:[e(R,{children:r(f,{children:[e(i,{className:"w-20",children:a("Score")}),e(i,{children:a("Procedure")}),e(i,{className:"w-32",children:a("Kind")}),e(i,{children:a("Rules fired")})]})}),e($,{children:k.map(d=>r(f,{"data-testid":`${s}-row`,children:[e(m,{className:u("tabular-nums font-medium",n[d.coverage]),children:d.coverage==="exempt"?"—":d.score}),e(m,{className:"font-mono text-xs",children:d.id}),r(m,{className:"text-muted-foreground text-xs",children:[d.visibility," ",d.kind,d.sensitivity.level==="high"&&e("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),e(m,{className:"text-muted-foreground text-xs",children:d.coverage==="exempt"?E(d,a("no reason given")):d.checks.map(w=>w.name).join(", ")})]},d.id))})]})})})]})};export{Y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as L}from"react/compiler-runtime";import{useState as F}from"react";import{B as K}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import D from"../packem_shared/ApiDocsPanel-B_RaW7Br.mjs";import M from"../packem_shared/ApiReferencePanel-u9Rrljdf.mjs";import W from"../packem_shared/OpenRpcReferencePanel-E9cDfHRv.mjs";import{jsx as r,jsxs as E}from"react/jsx-runtime";const _=["reference","snippets"],q=["openapi","openrpc"],k=V=>{const e=L(51),{functions:R,initialShardKey:N,openApiSpec:T,openRpcSpec:I}=V,t=Y(),[i,$]=F("reference"),[a,j]=F("openapi");let s;e[0]!==t?(s=t("Reference"),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==t?(o=t("Snippets"),e[2]=t,e[3]=o):o=e[3];let w;e[4]!==s||e[5]!==o?(w={reference:s,snippets:o},e[4]=s,e[5]=o,e[6]=w):w=e[6];const O=w;let n;e[7]!==t?(n=t("OpenAPI"),e[7]=t,e[8]=n):n=e[8];let c;e[9]!==t?(c=t("OpenRPC"),e[9]=t,e[10]=c):c=e[10];let g;e[11]!==n||e[12]!==c?(g={openapi:n,openrpc:c},e[11]=n,e[12]=c,e[13]=g):g=e[13];const C=g;let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=l=>{$(l.currentTarget.dataset.view)},e[14]=S):S=e[14];const z=S;let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=l=>{j(l.currentTarget.dataset.format)},e[15]=A):A=e[15];const B=A;let p;e[16]!==t?(p=t("API view"),e[16]=t,e[17]=p):p=e[17];let f;e[18]!==i||e[19]!==O?(f=_.map(l=>r(K,{"aria-selected":i===l,"data-testid":`api-view-${l}`,"data-view":l,onClick:z,role:"tab",size:"sm",type:"button",variant:i===l?"default":"outline",children:O[l]},l)),e[18]=i,e[19]=O,e[20]=f):f=e[20];let m;e[21]!==f||e[22]!==p?(m=r("div",{"aria-label":p,className:"flex gap-1.5","data-testid":"api-view-toggle",role:"tablist",children:f}),e[21]=f,e[22]=p,e[23]=m):m=e[23];let d;e[24]!==a||e[25]!==C||e[26]!==t||e[27]!==i?(d=i==="reference"&&r("div",{"aria-label":t("API spec format"),className:"flex gap-1.5","data-testid":"api-format-toggle",role:"tablist",children:q.map(l=>r(K,{"aria-selected":a===l,"data-format":l,"data-testid":`api-format-${l}`,onClick:B,role:"tab",size:"sm",type:"button",variant:a===l?"default":"outline",children:C[l]},l))}),e[24]=a,e[25]=C,e[26]=t,e[27]=i,e[28]=d):d=e[28];let b;e[29]!==m||e[30]!==d?(b=E("div",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-6 py-3",children:[m,d]}),e[29]=m,e[30]=d,e[31]=b):b=e[31];let v;e[32]!==R||e[33]!==N||e[34]!==i?(v=i==="snippets"&&r("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:r(D,{functions:R,initialShardKey:N})}),e[32]=R,e[33]=N,e[34]=i,e[35]=v):v=e[35];let h;e[36]!==a||e[37]!==T||e[38]!==i?(h=i==="reference"&&a==="openapi"&&r(M,{spec:T}),e[36]=a,e[37]=T,e[38]=i,e[39]=h):h=e[39];let u;e[40]!==a||e[41]!==I||e[42]!==i?(u=i==="reference"&&a==="openrpc"&&r(W,{spec:I}),e[40]=a,e[41]=I,e[42]=i,e[43]=u):u=e[43];let x;e[44]!==v||e[45]!==h||e[46]!==u?(x=E("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[v,h,u]}),e[44]=v,e[45]=h,e[46]=u,e[47]=x):x=e[47];let P;return e[48]!==b||e[49]!==x?(P=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"lunora-api-tab",children:[b,x]}),e[48]=b,e[49]=x,e[50]=P):P=e[50],P};export{k as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useVirtualizer as A,observeElementRect as B}from"@tanstack/react-virtual";import{useState as K,useMemo as w,useRef as M}from"react";import{E as V}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{L as _}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as j}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as U}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as q,a as D}from"../packem_shared/card-By2O8ULa.mjs";import{E as F}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as G}from"../packem_shared/input-CXhxesPC.mjs";import{T as W,a as J,b as N,c as s,d as P,e as l}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Q}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as Z}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Y}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as $,k as ee}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as i,jsx as e}from"react/jsx-runtime";const te=o=>o===void 0?"":JSON.stringify(o,ee),re=41,C=480,b=5,ae=(o,t)=>B(o,n=>{t(n.height>0?n:{height:C,width:n.width})}),we=({initialShardKey:o})=>{const t=X(),{queryShardKey:n,setShardKey:y,shardKey:T}=Z(o),[c,L]=K(""),{data:u,error:p,errorSource:R,isLoading:E,liveError:I}=Q(Y.getAuditLog,{},{live:!0,shardKey:n}),m=w(()=>u?.entries??[],[u]),d=w(()=>{const a=c.trim().toLowerCase();return a===""?m:m.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[m,c]),f=M(null),g=A({count:d.length,estimateSize:()=>re,getScrollElement:()=>f.current,initialRect:{height:C,width:800},observeElementRect:ae,overscan:8}),h=g.getVirtualItems(),H=g.getTotalSize(),v=h[0]?.start??0,x=H-(h.at(-1)?.end??0),O={height:v},k={height:x},z=a=>{L(a.target.value)};return i("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[i("div",{className:"flex flex-wrap items-center gap-2",children:[e(j,{onChange:y,testId:"au-shard-input",value:T}),e(_,{message:I,prefix:"au"}),e(G,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:z,placeholder:t("filter op, table, id"),value:c})]}),p!==null&&e(V,{error:R,testId:"au-error"}),p===null&&!E&&d.length===0&&e(F,{description:t("State-changing admin operations are recorded here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),d.length>0&&e(q,{className:"overflow-hidden py-0",children:e(D,{className:"max-h-[30rem] overflow-auto px-0",ref:f,children:i(W,{"data-testid":"au-table",children:[e(J,{children:i(N,{children:[e(s,{children:t("time")}),e(s,{children:t("op")}),e(s,{children:t("table")}),e(s,{children:t("id")}),e(s,{children:t("detail")})]})}),i(P,{children:[v>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:b,style:O})}),h.map(a=>{const r=d[a.index],S=te(r.detail);return i(N,{"data-testid":"au-row",children:[e(l,{className:"text-muted-foreground tabular-nums",children:$(r.ts,"—")}),e(l,{children:e(U,{variant:"secondary",children:r.op})}),e(l,{className:"font-medium",children:r.table??e("span",{className:"text-muted-foreground",children:"—"})}),e(l,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??e("span",{className:"text-muted-foreground",children:"—"})}),e(l,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||e("span",{className:"text-muted-foreground",children:"—"})})]},r.seq)}),x>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:b,style:k})})]})]})})})]})};export{we as AuditPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as ee}from"react/compiler-runtime";import{useQuery as re}from"@tanstack/react-query";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as J}from"../packem_shared/card-By2O8ULa.mjs";import{E as ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{S as X}from"../packem_shared/skeleton-DX1gfixl.mjs";import{u as te}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as ie}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{h as oe}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as se}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as p,jsx as a}from"react/jsx-runtime";const de="/_lunora/health",ce="/_lunora/health/ready",me=(r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,pe=()=>{const r=te();return async e=>{const w=e==="ready"?ce:de,t=r.getAuthToken(),y=me(r.url,w);try{const i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}});let u=null;try{u=await i.json()}catch{u=null}return{body:u,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},ue={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},fe=r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok",Z=r=>{const e=ee(13),{label:w,level:t,testId:y,value:i}=r,u=ue[t];let o;e[0]!==u?(o=se("size-1.5 shrink-0 rounded-full",u),e[0]=u,e[1]=o):o=e[1];let d;e[2]!==o?(d=a("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=d):d=e[3];let c;e[4]!==w||e[5]!==d?(c=p("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[d,w]}),e[4]=w,e[5]=d,e[6]=c):c=e[6];let f;e[7]!==y||e[8]!==i?(f=a("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=f):f=e[9];let H;return e[10]!==c||e[11]!==f?(H=a(J,{className:"gap-0 py-0",children:p("div",{className:"flex flex-col gap-2.5 p-4",children:[c,f]})}),e[10]=c,e[11]=f,e[12]=H):H=e[12],H},_e=r=>{const e=ee(107),{probe:w}=r,t=ie(),y=te(),i=pe(),u=w??i;let o;e[0]!==u?(o=async()=>{const[s,n]=await Promise.all([u("live"),u("ready")]);return{live:s,ready:n}},e[0]=u,e[1]=o):o=e[1];let d;e[2]!==y?(d=y.clientIdentifier(),e[2]=y,e[3]=d):d=e[3];let c;e[4]!==d?(c=["deployment-health",d],e[4]=d,e[5]=c):c=e[5];let f;e[6]!==o||e[7]!==c?(f={queryFn:o,queryKey:c},e[6]=o,e[7]=c,e[8]=f):f=e[8];const{data:H,isPending:le}=re(f),K=H?.live??null,ae=H?.ready??null;if(le){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=p("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[a(X,{className:"h-16 w-full"}),a(X,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}const l=K?.body??null;if(l===null){const s=K?.status===403;let n;e[10]!==s||e[11]!==K?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:K?.error??t("no response")}),e[10]=s,e[11]=K?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let g;return e[16]!==n||e[17]!==m?(g=a(ne,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=g):g=e[18],g}let Y;e[19]!==l.status?(Y=fe(l.status),e[19]=l.status,e[20]=Y):Y=e[20];const Q=Y;let h;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],h=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],h=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],h=s}const T=ae?.ok??!1,W=T?"ok":"crit";let P,_,C,N,v,b,L,E,k,S;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==Q||e[32]!==W||e[33]!==T||e[34]!==h||e[35]!==t){const s=[...l.checks].toSorted(he);_="flex flex-col gap-6",C="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint — wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(N=a("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=N):N=e[49];let m;e[50]!==h?(m=a("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:h}),e[50]=h,e[51]=m):m=e[51];let g;e[52]!==l.appName||e[53]!==l.appVersion?(g=p("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," · ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=g):g=e[54];let A;e[55]!==m||e[56]!==g?(A=a("div",{className:"flex items-center gap-3",children:p("div",{className:"grid leading-tight",children:[m,g]})}),e[55]=m,e[56]=g,e[57]=A):A=e[57];let D;e[58]!==t?(D=t("Checked"),e[58]=t,e[59]=D):D=e[59];let V;e[60]!==D?(V=a("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:D}),e[60]=D,e[61]=V):V=e[61];let I;e[62]!==l.timestamp?(I=oe(l.timestamp),e[62]=l.timestamp,e[63]=I):I=e[63];let R;e[64]!==I?(R=a("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:I}),e[64]=I,e[65]=R):R=e[65];let $;e[66]!==V||e[67]!==R?($=p("div",{className:"text-end",children:[V,R]}),e[66]=V,e[67]=R,e[68]=$):$=e[68],e[69]!==A||e[70]!==$?(v=a(J,{className:"gap-0 py-0",children:p("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[A,$]})}),e[69]=A,e[70]=$,e[71]=v):v=e[71];let z;e[72]!==t?(z=t("Liveness"),e[72]=t,e[73]=z):z=e[73];let B;e[74]!==Q||e[75]!==h||e[76]!==z?(B=a(Z,{label:z,level:Q,testId:"dh-liveness",value:h}),e[74]=Q,e[75]=h,e[76]=z,e[77]=B):B=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let q;e[80]!==T||e[81]!==t?(q=t(T?"Ready":"Not ready"),e[80]=T,e[81]=t,e[82]=q):q=e[82];let O;e[83]!==W||e[84]!==U||e[85]!==q?(O=a(Z,{label:U,level:W,testId:"dh-readiness",value:q}),e[83]=W,e[84]=U,e[85]=q,e[86]=O):O=e[86],e[87]!==B||e[88]!==O?(b=p("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[B,O]}),e[87]=B,e[88]=O,e[89]=b):b=e[89],P=J,L="gap-0 py-0",E="dh-checks";let F;e[90]!==t?(F=t("Subsystem checks"),e[90]=t,e[91]=F):F=e[91],e[92]!==F?(k=a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:F})}),e[92]=F,e[93]=k):k=e[93],S=s.length===0?a("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):a("ul",{className:"divide-y divide-border",children:s.map(x=>p("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${x.name}`,children:[p("span",{className:"flex items-center gap-2",children:[a("span",{"aria-hidden":"true",className:se("size-1.5 shrink-0 rounded-full",x.status==="up"?"bg-success":"bg-destructive")}),a("span",{className:"font-mono text-foreground",children:x.name}),x.critical&&a(M,{variant:"outline",children:t("Critical")})]}),p("span",{className:"flex shrink-0 items-center gap-2",children:[x.message!==void 0&&a("span",{className:"text-muted-foreground",children:x.message}),a(M,{"data-testid":`dh-check-status-${x.name}`,variant:x.status==="up"?"secondary":"destructive",children:x.status==="up"?t("Up"):t("Down")})]})]},x.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=Q,e[32]=W,e[33]=T,e[34]=h,e[35]=t,e[36]=P,e[37]=_,e[38]=C,e[39]=N,e[40]=v,e[41]=b,e[42]=L,e[43]=E,e[44]=k,e[45]=S}else P=e[36],_=e[37],C=e[38],N=e[39],v=e[40],b=e[41],L=e[42],E=e[43],k=e[44],S=e[45];let j;e[94]!==P||e[95]!==L||e[96]!==E||e[97]!==k||e[98]!==S?(j=p(P,{className:L,"data-testid":E,children:[k,S]}),e[94]=P,e[95]=L,e[96]=E,e[97]=k,e[98]=S,e[99]=j):j=e[99];let G;return e[100]!==_||e[101]!==C||e[102]!==N||e[103]!==v||e[104]!==b||e[105]!==j?(G=p("div",{className:_,"data-testid":C,children:[N,v,b,j]}),e[100]=_,e[101]=C,e[102]=N,e[103]=v,e[104]=b,e[105]=j,e[106]=G):G=e[106],G};function he(r,e){return r.name.localeCompare(e.name)}export{_e as DeploymentHealthPanel};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{c as xe}from"react/compiler-runtime";import{LunoraError as K}from"@lunora/errors";import{encodeWire as X,decodeWire as ve}from"@lunora/wire";import{useState as S}from"react";import{ConfirmButton as ye}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{ShardInput as be}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as W}from"../packem_shared/button-q0UYSmrn.mjs";import{C as J,a as Y}from"../packem_shared/card-By2O8ULa.mjs";import{c as Ne,S as Ce,a as ke,b as Ee,d as Te}from"../packem_shared/select-DPyS18Vy.mjs";import{b as Ie,u as Se}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as Re}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as re}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as Z,d as O,b as L,c as A}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as G}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{d as _e}from"../packem_shared/grid-features-2c5SaBtH.mjs";import{jsxs as E,jsx as m}from"react/jsx-runtime";class R extends Error{problem;constructor(e){super(e.kind),this.name="CsvFormatError",this.problem=e}}const Oe="\uFEFF",Fe=()=>{let t=[],e=1,n=!1,r=!1,o="start",s="";const i=()=>{t.push(o==="closing"||s!==""?s:void 0),o="start",s=""},c=l=>{i(),t.some(a=>a!==void 0)&&l.push({cells:t,number:e}),t=[],e+=1},d=(l,a)=>{const u=n;if(n=!1,!(u&&l===`
|
|
2
|
+
`)){if(o==="quoted"){l==='"'?o="closing":s+=l;return}if(o==="closing"&&l==='"'){s+=l,o="quoted";return}if(l===","){i();return}if(l==="\r"){c(a),n=!0;return}if(l===`
|
|
3
|
+
`){c(a);return}if(o==="closing")throw new R({kind:"text-after-quote",record:e});if(o==="start"&&l==='"'){o="quoted";return}o="unquoted",s+=l}};return{finish:()=>{if(o==="quoted")throw new R({kind:"unterminated-quote",record:e});const l=[];return c(l),l},push:l=>{const a=[];let u=0;for(!r&&l!==""&&(r=!0,u=l.startsWith(Oe)?1:0);u<l.length;u+=1)d(l.charAt(u),a);return a}}},oe=async function*(t){const e=Fe();for await(const n of t)yield*e.push(n);yield*e.finish()},D=(t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0})},se=t=>{const e=[],n=new Set;return t.forEach((r,o)=>{const s=(r??"").trim();if(s==="")throw new R({column:o+1,kind:"empty-header"});if(n.has(s))throw new R({kind:"duplicate-header",name:s});n.add(s),e.push(s)}),e},ie=({cells:t,number:e},n,r)=>{if(t.length!==n.length)throw new R({expected:n.length,found:t.length,kind:"ragged",record:e});const o={};return n.forEach((s,i)=>{const c=t[i];c!==void 0?D(o,s,c):r.has(s)&&D(o,s,null)}),{doc:o,record:e}},Le=/^-?\d+$/u,je=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/iu,De=/^-?\d{11,}$/u,Ae=/^(\d{4})-(\d{2})-(\d{2})$/u,$e=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/u,Be=/\.(\d+)/u,Pe=/[1-9]/u,Me=/^[+-]?(\d*)(?:\.(\d*))?(?:e([+-]?\d+))?$/iu,z=t=>{const[,e="",n="",r="0"]=Me.exec(t)??[],o=`${e}${n}`;let s=0,i=o.length;for(;s<i&&o.charAt(s)==="0";)s+=1;for(;i>s&&o.charAt(i-1)==="0";)i-=1;return s===i?{digits:"",exponent:0}:{digits:o.slice(s,i),exponent:Number(r)-n.length+(o.length-i)}},qe=(t,e)=>{const n=z(t),r=z(e.toExponential());return n.digits===r.digits&&n.exponent===r.exponent?!0:n.digits!==""&&n.exponent>=0&&Number.isInteger(e)&&BigInt(n.digits)*10n**BigInt(n.exponent)===BigInt(Math.abs(e))},Ke=t=>{const e=t.trim();if(!je.test(e))return;const n=Number(e);if(Number.isFinite(n))return qe(e,n)?{number:n}:{inexact:!0}},Xe=(t,e,n)=>{const r=new Date(0);return r.setUTCFullYear(t,e-1,n),r.getUTCMonth()===e-1&&r.getUTCDate()===n},Ue=(t,e,n,r)=>Number(t)<=23&&Number(e)<=59&&Number(n)<=59&&(r==="Z"||Number(r.slice(1,3))<=23&&Number(r.slice(4,6))<=59),Ve=t=>{const[e="",n,...r]=t.split("T"),o=Ae.exec(e),s=n===void 0?void 0:$e.exec(n);if(o===null||r.length>0||n!==void 0&&s===null)return;const[,i="",c="",d=""]=o;if(!Xe(Number(i),Number(c),Number(d)))return;const[,l="0",a="0",u="0",y]=s??[];if(!Ue(l,a,u,y??"Z"))return;const p=Be.exec(n??"")?.[1]??"";if(Pe.test(p.slice(3)))return;const h=Date.parse(s!==void 0&&y===void 0?`${t}Z`:t);return Number.isFinite(h)?h:void 0},He=t=>{const e=Ke(t);return e===void 0?{expected:"number",kind:"rejected"}:"number"in e?{kind:"ok",value:e.number}:{expected:"number",inexact:!0,kind:"rejected"}},We=t=>{const e=t.trim();let n=Ve(e);return n===void 0&&De.test(e)&&(n=Number(e)),n===void 0||!Number.isFinite(new Date(n).getTime())?{expected:"date",kind:"rejected"}:{kind:"ok",value:n}},Je=t=>{try{return X(t),!0}catch{return!1}},Ye=(t,e)=>{if(e==="bigint"){const n=t.trim();if(!Le.test(n))return{expected:"bigint",kind:"rejected"};const r=BigInt(n);return Je(r)?{kind:"ok",value:r}:{expected:"bigint",kind:"rejected",tooLong:!0}}if(e==="boolean"){const n=t.trim().toLowerCase();return n==="true"||n==="false"?{kind:"ok",value:n==="true"}:{expected:"boolean",kind:"rejected"}}return e==="number"?He(t):e==="date"||e==="timestamp"?We(t):{kind:"ok",value:t}},le=({doc:t,record:e},n)=>{const r={};for(const[o,s]of Object.entries(t)){if(s===null){D(r,o,null);continue}const i=Ye(s,n.get(o));if(i.kind==="rejected")throw new R({column:o,expected:i.expected,...i.inexact===!0&&{inexact:!0},kind:"cell-type",record:e,...i.tooLong===!0&&{tooLong:!0},value:s});D(r,o,i.value)}return{doc:r,record:e}},Ze=async function*(t,e,n){let r;for await(const o of oe(t))r===void 0?r=se(o.cells):yield le(ie(o,r,n),e)},Ge=t=>new Set(t.filter(e=>e.nullable===!0&&!e.optional).map(e=>e.name)),Q=t=>{if(t instanceof R)return t;throw t},ze=async(t,e,n,r)=>{let o,s,i;for await(const d of oe(t)){if(o===void 0){try{o=se(d.cells)}catch(a){s=Q(a),o=[]}continue}let l;try{l=le(ie(d,o,n),e)}catch(a){i??=Q(a);continue}r(l)}const c=s??i;if(c!==void 0)throw c},Qe=A(_.exportShard),M=A(_.importShard),et=A(_.listTables),tt=A(_.describeTable),nt={},rt=t=>t.map(e=>JSON.stringify(X(e))).join(`
|
|
4
|
+
`),ot=(t,e)=>{const n=t.trim();if(n==="")return;const r=ve(JSON.parse(n));if(typeof r!="object"||r===null)throw new K("INTERNAL",`line ${e.toString()}: expected a { table, doc } object`);const o=r;if(typeof o.table!="string"||typeof o.doc!="object"||o.doc===null||Array.isArray(o.doc))throw new K("INTERNAL",`line ${e.toString()}: expected a { table, doc } object`);return o},ee=1024*1024,U=async function*(t){const e=new TextDecoder("utf-8",{fatal:!0});for(let r=0;r<t.size;r+=ee){const o=await t.slice(r,r+ee).arrayBuffer();yield e.decode(o,{stream:!0})}const n=e.decode();n!==""&&(yield n)},st=async function*(t){let e="",n=0;for await(const r of U(t)){const o=`${e}${r}`.split(`
|
|
5
|
+
`);e=o.pop()??"";for(const s of o)n+=1,yield{line:s,lineNumber:n}}e!==""&&(yield{line:e,lineNumber:n+1})},it=async function*(t){for await(const{line:e,lineNumber:n}of st(t)){const r=ot(e,n);r!==void 0&&(yield{line:n,row:r})}},lt=async function*(t,e,n,r){for await(const{doc:o,record:s}of Ze(U(t),n,r))yield{line:s,row:{doc:o,table:e}}},at=async(t,e,n,r)=>{try{const{columns:o}=await t.query(tt,{table:r},O(n));return{kinds:new Map(o.map(s=>[s.name,s.type])),nullOnEmpty:Ge(o)}}catch(o){return{failure:e("Couldn't read the columns of {table}: {message}",{message:L(o),table:r})}}},te=50,ct=500,$=9e5,V=t=>new TextEncoder().encode(JSON.stringify(X(t))).byteLength,q="application/x-ndjson",ae=t=>new K("INTERNAL",`line ${t.toString()}: a single row is over the ${$.toString()}-byte import limit`),dt=async t=>{let e=0;for await(const{line:n,row:r}of t){if(V(r)>$)throw ae(n);e+=1}return e},ut=async(t,e,n,r)=>{const o={rows:0};if(await ze(U(t),n,r,({doc:s,record:i})=>{o.rows+=1,o.wide===void 0&&V({doc:s,table:e})>$&&(o.wide=i)}),o.wide!==void 0)throw ae(o.wide);return o.rows},ne=async(t,e)=>{let n=[],r=0,o=0,s=0;for await(const{line:i,row:c}of t){const d=V(c),l=i!==s+1;n.length>0&&(l||n.length===ct||r+d>$)&&(await e(n,o),n=[],r=0),n.length===0&&(o=i),n.push(c),r+=d,s=i}n.length>0&&await e(n,o)},ft=/\.csv$/iu,mt=t=>ft.test(t.name)||t.type==="text/csv",ht=(t,e)=>t.expected==="boolean"?e("line {line}: column “{column}” must be true or false, got “{value}”.",{column:t.column,line:t.record,value:t.value}):t.tooLong===!0?e("line {line}: column “{column}” holds an integer longer than the import can send.",{column:t.column,line:t.record}):t.expected==="bigint"?e("line {line}: column “{column}” must be an integer, got “{value}”.",{column:t.column,line:t.record,value:t.value}):t.expected==="date"?e("line {line}: column “{column}” must be an ISO-8601 date or epoch milliseconds of at least 11 digits, got “{value}”.",{column:t.column,line:t.record,value:t.value}):t.inexact===!0?e("line {line}: column “{column}” holds “{value}”, which a number column cannot store exactly. Store a whole number past 9007199254740991 in a bigint column.",{column:t.column,line:t.record,value:t.value}):e("line {line}: column “{column}” must be a number, got “{value}”.",{column:t.column,line:t.record,value:t.value}),pt=(t,e)=>t.kind==="duplicate-header"?e("The header “{name}” appears more than once.",{name:t.name}):t.kind==="empty-header"?e("Header column {column} is empty.",{column:t.column}):t.kind==="ragged"?e("line {line}: expected {expected} cells, found {found}.",{expected:t.expected,found:t.found,line:t.record}):t.kind==="cell-type"?ht(t,e):t.kind==="text-after-quote"?e("line {line}: text follows a closing quote.",{line:t.record}):e("line {line}: a quoted field is never closed.",{line:t.record}),wt=(t,e,n)=>{const r=e instanceof R?pt(e.problem,n):L(e);return t===null?n("Invalid NDJSON: {message}",{message:r}):n("Invalid CSV: {message}",{message:r})},gt=t=>{const e=xe(31),{onChange:n,shardKey:r,value:o}=t,s=re();let i;e[0]!==r?(i={shardKey:r},e[0]=r,e[1]=i):i=e[1];const{data:c}=Se(_.listTables,nt,i);let d;e[2]!==n?(d=C=>{n(C??"")},e[2]=n,e[3]=d):d=e[3];let l;e[4]!==s?(l=s("Target table"),e[4]=s,e[5]=l):l=e[5];let a;e[6]!==s?(a=s("Choose a table"),e[6]=s,e[7]=a):a=e[7];let u;e[8]!==a?(u=m(Ce,{placeholder:a}),e[8]=a,e[9]=u):u=e[9];let y;e[10]!==l||e[11]!==u?(y=m(ke,{"aria-label":l,className:"w-56","data-testid":"ei-csv-table",children:u}),e[10]=l,e[11]=u,e[12]=y):y=e[12];let p;e[13]!==c?(p=c??[],e[13]=c,e[14]=p):p=e[14];let h;e[15]!==p?(h=p.map(vt),e[15]=p,e[16]=h):h=e[16];let g;e[17]!==h?(g=m(Ee,{children:h}),e[17]=h,e[18]=g):g=e[18];let N;e[19]!==d||e[20]!==y||e[21]!==g||e[22]!==o?(N=E(Te,{onValueChange:d,value:o,children:[y,g]}),e[19]=d,e[20]=y,e[21]=g,e[22]=o,e[23]=N):N=e[23];let b;e[24]!==s?(b=s("CSV rows have no table column, so choose the table they go into."),e[24]=s,e[25]=b):b=e[25];let w;e[26]!==b?(w=m("p",{className:"text-xs text-muted-foreground",children:b}),e[26]=b,e[27]=w):w=e[27];let f;return e[28]!==N||e[29]!==w?(f=E("div",{className:"flex flex-col gap-1.5",children:[N,w]}),e[28]=N,e[29]=w,e[30]=f):f=e[30],f},ce=t=>Object.values(t).reduce((e,n)=>e+n,0),xt=async(t,e,n,r,o,s)=>{const i={conflicts:0,errors:[],inserted:{}};let c;const d=s===null?{kinds:new Map,nullOnEmpty:new Set}:await at(t,e,n,s);if("failure"in d)return{failure:{message:d.failure,rows:0},total:i};const{kinds:l,nullOnEmpty:a}=d;try{if(s===null){const f=()=>it(o);c={rows:await dt(f()),source:f}}else c={rows:await ut(o,s,l,a),source:()=>lt(o,s,l,a)}}catch(f){return{failure:{message:wt(s,f,e),rows:0},total:i}}const{rows:u,source:y}=c;if(s!==null&&u===0)return{failure:{message:e("The CSV has no data rows after the header."),rows:0},total:i};const p={conflicts:0,errors:[],inserted:{}};r(e("Checking {total} rows before writing…",{total:u}));try{if((await t.query(M,{dryRun:!0,rows:[],startLine:1},O(n))).dryRun!==!0)return{failure:{message:e("This shard predates import checks, so it would write the file while checking it. Nothing was sent. Update the app and import again."),rows:0},total:i};await ne(y(),async(C,k)=>{const T=await t.query(M,{dryRun:!0,rows:C,startLine:k},O(n));p.errors.push(...T.errors)})}catch(f){return{failure:{message:L(f),rows:0},total:i}}if(p.errors.length>0)return{failure:{message:e("Nothing was written, because some rows would be refused. Fix the rows listed below and import again."),rows:0},total:p};let h=0,g=1;const N={},b={},w=async(f,C)=>{r(e("Importing rows {from}–{to} of {total}…",{from:h+1,to:h+f.length,total:u})),b.startLine=C;const k=await t.query(M,{dryRun:!1,rows:f,startLine:C},O(n));b.startLine=void 0,i.conflicts+=k.conflicts,i.errors.push(...k.errors);for(const[T,B]of Object.entries(k.inserted))i.inserted[T]=(i.inserted[T]??0)+B;if(h+=f.length,g=C+f.length,k.errors.length>0){const T=ce(i.inserted);throw N.refused=!0,new Error(T===0?e("The shard refused {count} rows, so the rest of the file was not sent. Nothing was written. Fix the rows listed below and import again.",{count:k.errors.length}):e("The shard refused {count} rows, so the rest of the file was not sent. {written} rows were already written, so do not import the whole file again. Import the refused rows and any rows from line {line} onward, or delete the written rows first and then import the whole file.",{count:k.errors.length,line:C+f.length,written:T}))}};try{return await ne(y(),w),{failure:void 0,total:i}}catch(f){return{failure:{message:L(f),nextLine:g,rows:h,unknownFrom:b.startLine,...N},total:i}}},$t=({initialShardKey:t})=>{const e=Re(),n=Ie(),r=re(),[o,s]=S(t??""),[i,c]=S(null),[d,l]=S(null),[a,u]=S(!1),[y,p]=S(null),[h,g]=S(null),[N,b]=S(null),[w,f]=S(null),C=i!==null&&mt(i),k=d!==null&&d.shardKey===o?d.table:"",T=i!==null&&(!C||k!==""),B=async()=>{const x=o;u(!0),p(null),g(null),f(null);try{const F=await e.query(et,{},O(x));let v=new Blob([],{type:q}),I=0;const j=[];for(const{name:ge}of F){const{rows:P}=await e.query(Qe,{tables:[ge]},O(x));if(P.length===0)continue;const H=rt(P);v=new Blob([v,`${H}
|
|
6
|
+
`],{type:q}),I+=P.length,j.length<te&&j.push(...H.split(`
|
|
7
|
+
`).slice(0,te-j.length))}G(x),f({blob:v,count:I,preview:j.join(`
|
|
8
|
+
`),shardKey:x})}catch(F){p(L(F))}},de=async(x,F)=>{u(!0),p(null),g(null),f(null);const{failure:v,total:I}=await xt(e,r,o,b,x,F);v===void 0?(G(o),g(I)):v.unknownFrom===void 0&&(v.refused===!0||v.rows===0)?(I.errors.length>0&&g(I),p(v.message)):v.unknownFrom===void 0?(g(I),p(r("Import stopped after {rows} rows: {message}. The counts below cover those rows. Rows from line {line} onward were not sent: do not import the whole file again, import from that line onward, or delete the written rows first and then import the whole file.",{line:v.nextLine,message:v.message,rows:v.rows}))):(g(I),p(r("Import stopped after {rows} rows: {message}. The counts below cover completed chunks only. The chunk from line {line} may have written rows: check the table for rows from line {line} onward before importing again, or delete the written rows first and then import the whole file.",{line:v.unknownFrom,message:v.message,rows:v.rows}))),n(_.readTablePage),n(_.listTables)},ue=h===null?0:ce(h.inserted),fe=()=>{Z(B().finally(()=>{u(!1)}))},me=()=>{i!==null&&T&&Z(de(i,C?k:null).finally(()=>{b(null),u(!1)}))},he=()=>{w!==null&&_e(`${w.shardKey.trim()===""?"shard":w.shardKey.trim()}.ndjson`,w.blob,q)},pe=x=>{c(x.target.files?.[0]??null),l(null)},we=x=>{l({shardKey:o,table:x})};return E("div",{className:"flex flex-col gap-4","data-testid":"lunora-export-import",children:[E(J,{className:"gap-0 py-0 rounded-xl border border-border bg-card shadow-xs",children:[m("header",{className:"border-b border-border px-4 py-3",children:m("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Export")})}),E(Y,{className:"flex flex-col gap-3 p-4",children:[E("div",{className:"flex flex-wrap items-center gap-2",children:[m(be,{onChange:s,testId:"ei-shard-input",value:o}),m(W,{"data-testid":"ei-export",disabled:a,onClick:fe,type:"button",children:r("Export")})]}),w!==null&&E("div",{className:"flex flex-col gap-2",children:[E("div",{className:"flex flex-wrap items-center gap-2",children:[m("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:r("Exported {count} rows.",{count:w.count})}),m(W,{"data-testid":"ei-download",onClick:he,size:"sm",type:"button",variant:"outline",children:r("Download")})]}),w.preview!==""&&m("pre",{className:"max-h-60 overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"ei-preview",children:w.preview})]})]})]}),E(J,{className:"gap-0 py-0 rounded-xl border border-border bg-card shadow-xs",children:[m("header",{className:"border-b border-border px-4 py-3",children:m("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Import")})}),E(Y,{className:"flex flex-col gap-3 p-4",children:[m("input",{accept:".ndjson,.jsonl,.csv,application/x-ndjson,text/csv","aria-label":r("Import file"),className:"text-sm","data-testid":"ei-file",onChange:pe,type:"file"}),C&&m(gt,{onChange:we,shardKey:o,value:k}),m("div",{className:"flex flex-wrap items-center gap-2",children:m(ye,{confirmLabel:r("Import (writes rows)?"),disabled:a||!T,onConfirm:me,testId:"ei-import",children:r("Import")})}),N!==null&&m("p",{className:"text-sm text-muted-foreground","data-testid":"ei-progress",role:"status",children:N}),h!==null&&E("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[m("p",{className:"text-sm text-muted-foreground",children:r("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:h.conflicts,errors:h.errors.length,inserted:ue})}),h.errors.length>0&&m("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:h.errors.map(x=>m("li",{className:"text-xs text-destructive",children:r("line {line} ({table}): {message}",{line:x.line,message:x.message,table:x.table})},`${x.table}-${x.line.toString()}`))})]})]})]}),y!==null&&m("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:y})]})};function vt(t){return m(Ne,{value:t.name,children:t.name},t.name)}export{$t as ExportImportPanel};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as U}from"react/compiler-runtime";import{useState as B,useEffect as ne,useRef as de,useMemo as ge,useCallback as ot}from"react";import{ShardInput as rt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as oe}from"../packem_shared/button-q0UYSmrn.mjs";import{E as Te}from"../packem_shared/empty-state-D7jEML_T.mjs";import{useT as it}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{S as at}from"../packem_shared/grid-features-2c5SaBtH.mjs";import{C as ct,a as dt}from"../packem_shared/card-By2O8ULa.mjs";import{C as Ee}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{c as le,a as ft,b as be,d as ut,T as ht,e as Q}from"../packem_shared/table-D0SBiDu-.mjs";import{n as _e,f as q,b as ie,d as Se,c as $e,g as mt}from"../packem_shared/internal-BXEjuLPN.mjs";import{ConfirmButton as pt}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{jsx as r,jsxs as R,Fragment as gt}from"react/jsx-runtime";import{I as bt}from"../packem_shared/input-CXhxesPC.mjs";import{d as yt}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{useAutoRefresh as xt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as vt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";const Re=(d,e,t)=>{const{onCopy:s,onDelete:n,onDownload:l,onToggleSelect:a}=t,c=()=>{s(d.key)},o=()=>{l(d.key)},f=()=>{n(d.key)},h=()=>{a(d.key)};return{copy:c,download:o,name:d.key.slice(e.length),remove:f,toggle:h}},ze=d=>{const e=U(31),{busy:t,buttonClassName:s,copied:n,objectKey:l,onCopy:a,onDelete:c,onDownload:o,t:f}=d,h=`storage-copy-${l}`;let u;e[0]!==n||e[1]!==f?(u=f(n?"Copied":"Copy URL"),e[0]=n,e[1]=f,e[2]=u):u=e[2];let m;e[3]!==t||e[4]!==s||e[5]!==a||e[6]!==h||e[7]!==u?(m=r(oe,{className:s,"data-testid":h,disabled:t,onClick:a,size:"sm",type:"button",variant:"ghost",children:u}),e[3]=t,e[4]=s,e[5]=a,e[6]=h,e[7]=u,e[8]=m):m=e[8];const k=`storage-download-${l}`;let i;e[9]!==f?(i=f("Download"),e[9]=f,e[10]=i):i=e[10];let v;e[11]!==t||e[12]!==s||e[13]!==o||e[14]!==k||e[15]!==i?(v=r(oe,{className:s,"data-testid":k,disabled:t,onClick:o,size:"sm",type:"button",variant:"ghost",children:i}),e[11]=t,e[12]=s,e[13]=o,e[14]=k,e[15]=i,e[16]=v):v=e[16];let S;e[17]!==f?(S=f("Delete object?"),e[17]=f,e[18]=S):S=e[18];const y=`storage-delete-${l}`;let g;e[19]!==f?(g=f("Delete"),e[19]=f,e[20]=g):g=e[20];let b;e[21]!==t||e[22]!==c||e[23]!==S||e[24]!==y||e[25]!==g?(b=r(pt,{confirmLabel:S,disabled:t,onConfirm:c,testId:y,children:g}),e[21]=t,e[22]=c,e[23]=S,e[24]=y,e[25]=g,e[26]=b):b=e[26];let x;return e[27]!==b||e[28]!==m||e[29]!==v?(x=R(gt,{children:[m,v,b]}),e[27]=b,e[28]=m,e[29]=v,e[30]=x):x=e[30],x},De=d=>{const e=U(14),{objectKey:t,references:s,t:n}=d;if(s===void 0)return null;if(s.length===0){const h=`storage-orphan-${t}`;let u;e[0]!==n?(u=n("Orphan"),e[0]=n,e[1]=u):u=e[1];let m;return e[2]!==h||e[3]!==u?(m=r(fe,{"data-testid":h,variant:"warning",children:u}),e[2]=h,e[3]=u,e[4]=m):m=e[4],m}let l;e[5]!==s?(l=s.map(kt).join(`
|
|
2
|
+
`),e[5]=s,e[6]=l):l=e[6];const a=l,c=`storage-refs-${t}`;let o;e[7]!==s.length||e[8]!==n?(o=s.length===1?n("1 record"):n("{count} records",{count:s.length}),e[7]=s.length,e[8]=n,e[9]=o):o=e[9];let f;return e[10]!==a||e[11]!==c||e[12]!==o?(f=r(fe,{"data-testid":c,title:a,variant:"secondary",children:o}),e[10]=a,e[11]=c,e[12]=o,e[13]=f):f=e[13],f},je=d=>{const e=U(7),{objectKey:t,onToggle:s,selected:n,t:l}=d;let a;e[0]!==l?(a=l("Select row"),e[0]=l,e[1]=a):a=e[1];const c=`storage-select-${t}`;let o;return e[2]!==s||e[3]!==n||e[4]!==a||e[5]!==c?(o=r(Ee,{"aria-label":a,checked:n,"data-testid":c,onCheckedChange:s}),e[2]=s,e[3]=n,e[4]=a,e[5]=c,e[6]=o):o=e[6],o};function kt(d){return`${d.table}·${d.id}`}const St=d=>{const e=U(10),{colSpan:t,name:s,onEnter:n}=d;let l;e[0]!==s||e[1]!==n?(l=()=>{n(s)},e[0]=s,e[1]=n,e[2]=l):l=e[2];const a=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=r("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=c):c=e[3];let o;e[4]!==a||e[5]!==s?(o=R("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:a,type:"button",children:[c,s]}),e[4]=a,e[5]=s,e[6]=o):o=e[6];let f;return e[7]!==t||e[8]!==o?(f=r(be,{children:r(Q,{colSpan:t,children:o})}),e[7]=t,e[8]=o,e[9]=f):f=e[9],f},wt=d=>{const e=U(37),{busy:t,copiedKey:s,handlers:n,object:l,prefix:a,references:c,selected:o,showReferences:f,t:h}=d;let u;e[0]!==n||e[1]!==l||e[2]!==a?(u=Re(l,a,n),e[0]=n,e[1]=l,e[2]=a,e[3]=u):u=e[3];const{copy:m,download:k,name:i,remove:v,toggle:S}=u;let y;e[4]!==l.key||e[5]!==o||e[6]!==h||e[7]!==S?(y=r(Q,{className:"w-8",children:r(je,{objectKey:l.key,onToggle:S,selected:o,t:h})}),e[4]=l.key,e[5]=o,e[6]=h,e[7]=S,e[8]=y):y=e[8];let g;e[9]!==i?(g=r(Q,{className:"font-mono text-xs",children:i}),e[9]=i,e[10]=g):g=e[10];let b;e[11]!==l.size?(b=_e(l.size),e[11]=l.size,e[12]=b):b=e[12];let x;e[13]!==b?(x=r(Q,{className:"tabular-nums text-muted-foreground",children:b}),e[13]=b,e[14]=x):x=e[14];const N=l.httpMetadata?.contentType??"";let w;e[15]!==N?(w=r(Q,{children:N}),e[15]=N,e[16]=w):w=e[16];let C;e[17]!==l.key||e[18]!==c||e[19]!==f||e[20]!==h?(C=f&&r(Q,{children:r(De,{objectKey:l.key,references:c,t:h})}),e[17]=l.key,e[18]=c,e[19]=f,e[20]=h,e[21]=C):C=e[21];const E=s===l.key;let T;e[22]!==t||e[23]!==m||e[24]!==k||e[25]!==l.key||e[26]!==v||e[27]!==h||e[28]!==E?(T=r(Q,{className:"text-right",children:r("span",{className:"inline-flex items-center gap-1",children:r(ze,{busy:t,copied:E,objectKey:l.key,onCopy:m,onDelete:v,onDownload:k,t:h})})}),e[22]=t,e[23]=m,e[24]=k,e[25]=l.key,e[26]=v,e[27]=h,e[28]=E,e[29]=T):T=e[29];let F;return e[30]!==T||e[31]!==y||e[32]!==g||e[33]!==x||e[34]!==w||e[35]!==C?(F=R(be,{"data-testid":"fb-row",children:[y,g,x,w,C,T]}),e[30]=T,e[31]=y,e[32]=g,e[33]=x,e[34]=w,e[35]=C,e[36]=F):F=e[36],F},Ct=d=>{const e=U(65),{allSelected:t,busy:s,copiedKey:n,files:l,folders:a,handlers:c,onEnterFolder:o,prefix:f,references:h,selected:u,showReferences:m,someSelected:k,t:i,toggleSelectAll:v}=d;let S;e[0]!==i?(S=i("Select all rows"),e[0]=i,e[1]=S):S=e[1];let y;e[2]!==t||e[3]!==k||e[4]!==S||e[5]!==v?(y=r(le,{className:"w-8",children:r(Ee,{"aria-label":S,checked:t,"data-testid":"storage-select-all",indeterminate:k,onCheckedChange:v})}),e[2]=t,e[3]=k,e[4]=S,e[5]=v,e[6]=y):y=e[6];let g;e[7]!==i?(g=i("key"),e[7]=i,e[8]=g):g=e[8];let b;e[9]!==g?(b=r(le,{children:g}),e[9]=g,e[10]=b):b=e[10];let x;e[11]!==i?(x=i("size"),e[11]=i,e[12]=x):x=e[12];let N;e[13]!==x?(N=r(le,{children:x}),e[13]=x,e[14]=N):N=e[14];let w;e[15]!==i?(w=i("content-type"),e[15]=i,e[16]=w):w=e[16];let C;e[17]!==w?(C=r(le,{children:w}),e[17]=w,e[18]=C):C=e[18];let E;e[19]!==m||e[20]!==i?(E=m&&r(le,{children:i("used by")}),e[19]=m,e[20]=i,e[21]=E):E=e[21];let T;e[22]!==i?(T=i("Actions"),e[22]=i,e[23]=T):T=e[23];let F;e[24]!==T?(F=r(le,{"aria-label":T}),e[24]=T,e[25]=F):F=e[25];let _;e[26]!==F||e[27]!==y||e[28]!==b||e[29]!==N||e[30]!==C||e[31]!==E?(_=r(ft,{children:R(be,{children:[y,b,N,C,E,F]})}),e[26]=F,e[27]=y,e[28]=b,e[29]=N,e[30]=C,e[31]=E,e[32]=_):_=e[32];let z;if(e[33]!==a||e[34]!==o||e[35]!==m){let D;e[37]!==o||e[38]!==m?(D=K=>r(St,{colSpan:m?6:5,name:K,onEnter:o},K),e[37]=o,e[38]=m,e[39]=D):D=e[39],z=a.map(D),e[33]=a,e[34]=o,e[35]=m,e[36]=z}else z=e[36];let L;if(e[40]!==s||e[41]!==n||e[42]!==l||e[43]!==c||e[44]!==f||e[45]!==h||e[46]!==u||e[47]!==m||e[48]!==i){let D;e[50]!==s||e[51]!==n||e[52]!==c||e[53]!==f||e[54]!==h||e[55]!==u||e[56]!==m||e[57]!==i?(D=K=>r(wt,{busy:s,copiedKey:n,handlers:c,object:K,prefix:f,references:h[K.key],selected:u.has(K.key),showReferences:m,t:i},K.key),e[50]=s,e[51]=n,e[52]=c,e[53]=f,e[54]=h,e[55]=u,e[56]=m,e[57]=i,e[58]=D):D=e[58],L=l.map(D),e[40]=s,e[41]=n,e[42]=l,e[43]=c,e[44]=f,e[45]=h,e[46]=u,e[47]=m,e[48]=i,e[49]=L}else L=e[49];let j;e[59]!==z||e[60]!==L?(j=R(ut,{children:[z,L]}),e[59]=z,e[60]=L,e[61]=j):j=e[61];let I;return e[62]!==_||e[63]!==j?(I=r(ct,{className:"overflow-hidden py-0",children:r(dt,{className:"px-0",children:R(ht,{"data-testid":"fb-table",children:[_,j]})})}),e[62]=_,e[63]=j,e[64]=I):I=e[64],I},Nt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],Tt=3600,we=(d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;const t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},Et=(d,e,t)=>{const s=t==="desc"?-1:1;return d.toSorted((n,l)=>{const a=we(n,e),c=we(l,e);return(typeof a=="number"&&typeof c=="number"?a-c:String(a).localeCompare(String(c)))*s})},_t=(d,e)=>{const t=new Set,s=[];for(const n of d){const l=n.key.slice(e.length),a=l.indexOf("/");a===-1?s.push(n):t.add(l.slice(0,a+1))}return{files:s,folders:[...t].toSorted((n,l)=>n.localeCompare(l))}},$t=d=>{const e=U(59),{bucket:t,buckets:s,busy:n,draftPrefix:l,expiry:a,fileInputRef:c,onBucketChange:o,onExpiryChange:f,onFileChange:h,onList:u,onPrefixChange:m,onUploadClick:k,t:i}=d;let v;e[0]!==m?(v=G=>{m(G.target.value)},e[0]=m,e[1]=v):v=e[1];const S=v;let y;e[2]!==o?(y=G=>{o(G.target.value)},e[2]=o,e[3]=y):y=e[3];const g=y;let b;e[4]!==f?(b=G=>{f(Number.parseInt(G.target.value,10))},e[4]=f,e[5]=b):b=e[5];const x=b;let N;e[6]!==t||e[7]!==s||e[8]!==g||e[9]!==i?(N=s.length>0&&r("select",{"aria-label":i("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:g,value:t,children:s.map(Rt)}),e[6]=t,e[7]=s,e[8]=g,e[9]=i,e[10]=N):N=e[10];let w;e[11]!==i?(w=i("Key prefix"),e[11]=i,e[12]=w):w=e[12];let C;e[13]!==i?(C=i("key prefix (optional)"),e[13]=i,e[14]=C):C=e[14];let E;e[15]!==l||e[16]!==S||e[17]!==w||e[18]!==C?(E=r(bt,{"aria-label":w,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:S,placeholder:C,value:l}),e[15]=l,e[16]=S,e[17]=w,e[18]=C,e[19]=E):E=e[19];let T;e[20]!==i?(T=i("List"),e[20]=i,e[21]=T):T=e[21];let F;e[22]!==n||e[23]!==u||e[24]!==T?(F=r(oe,{"data-testid":"fb-list",disabled:n,onClick:u,size:"sm",type:"button",children:T}),e[22]=n,e[23]=u,e[24]=T,e[25]=F):F=e[25];let _;e[26]!==n||e[27]!==i?(_=i(n?"Uploading…":"Upload"),e[26]=n,e[27]=i,e[28]=_):_=e[28];let z;e[29]!==n||e[30]!==k||e[31]!==_?(z=r(oe,{"data-testid":"storage-upload",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:_}),e[29]=n,e[30]=k,e[31]=_,e[32]=z):z=e[32];let L;e[33]!==c||e[34]!==h?(L=r("input",{className:"hidden","data-testid":"storage-file-input",onChange:h,ref:c,type:"file"}),e[33]=c,e[34]=h,e[35]=L):L=e[35];let j;e[36]!==i?(j=i("Link expiry"),e[36]=i,e[37]=j):j=e[37];let I;e[38]!==i?(I=Nt.map(G=>r("option",{value:G.seconds,children:i(G.label)},G.seconds)),e[38]=i,e[39]=I):I=e[39];let D;e[40]!==a||e[41]!==x||e[42]!==I?(D=r("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:x,value:a,children:I}),e[40]=a,e[41]=x,e[42]=I,e[43]=D):D=e[43];let K;e[44]!==j||e[45]!==D?(K=R("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[j,D]}),e[44]=j,e[45]=D,e[46]=K):K=e[46];let A;e[47]!==i?(A=i("Open in Cloudflare"),e[47]=i,e[48]=A):A=e[48];let M;e[49]!==A?(M=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:A}),e[49]=A,e[50]=M):M=e[50];let H;return e[51]!==z||e[52]!==L||e[53]!==K||e[54]!==M||e[55]!==N||e[56]!==E||e[57]!==F?(H=R("div",{className:"flex flex-wrap items-center gap-2",children:[N,E,F,z,L,K,M]}),e[51]=z,e[52]=L,e[53]=K,e[54]=M,e[55]=N,e[56]=E,e[57]=F,e[58]=H):H=e[58],H},Ft=d=>{const e=U(66),{onSortKeyChange:t,onThumbSizeChange:s,showGrid:n,showList:l,sortDirection:a,sortKey:c,t:o,tagKeys:f,thumbSize:h,toggleSortDirection:u,view:m}=d;let k;e[0]!==t?(k=W=>{t(W.target.value)},e[0]=t,e[1]=k):k=e[1];const i=k;let v;e[2]!==s?(v=W=>{s(Number.parseInt(W.target.value,10))},e[2]=s,e[3]=v):v=e[3];const S=v,y=m==="list";let g;e[4]!==o?(g=o("List"),e[4]=o,e[5]=g):g=e[5];let b;e[6]!==l||e[7]!==y||e[8]!==g?(b=r("button",{"aria-pressed":y,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:l,type:"button",children:g}),e[6]=l,e[7]=y,e[8]=g,e[9]=b):b=e[9];const x=m==="grid";let N;e[10]!==o?(N=o("Grid"),e[10]=o,e[11]=N):N=e[11];let w;e[12]!==n||e[13]!==x||e[14]!==N?(w=r("button",{"aria-pressed":x,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:n,type:"button",children:N}),e[12]=n,e[13]=x,e[14]=N,e[15]=w):w=e[15];let C;e[16]!==b||e[17]!==w?(C=R("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[b,w]}),e[16]=b,e[17]=w,e[18]=C):C=e[18];let E;e[19]!==o?(E=o("Sort"),e[19]=o,e[20]=E):E=e[20];let T;e[21]!==o?(T=o("Name"),e[21]=o,e[22]=T):T=e[22];let F;e[23]!==T?(F=r("option",{value:"name",children:T}),e[23]=T,e[24]=F):F=e[24];let _;e[25]!==o?(_=o("size"),e[25]=o,e[26]=_):_=e[26];let z;e[27]!==_?(z=r("option",{value:"size",children:_}),e[27]=_,e[28]=z):z=e[28];let L;e[29]!==o?(L=o("Type"),e[29]=o,e[30]=L):L=e[30];let j;e[31]!==L?(j=r("option",{value:"type",children:L}),e[31]=L,e[32]=j):j=e[32];let I;e[33]!==o?(I=o("Modified"),e[33]=o,e[34]=I):I=e[34];let D;e[35]!==I?(D=r("option",{value:"date",children:I}),e[35]=I,e[36]=D):D=e[36];let K;e[37]!==f?(K=f.map(zt),e[37]=f,e[38]=K):K=e[38];let A;e[39]!==i||e[40]!==c||e[41]!==F||e[42]!==z||e[43]!==j||e[44]!==D||e[45]!==K?(A=R("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:i,value:c,children:[F,z,j,D,K]}),e[39]=i,e[40]=c,e[41]=F,e[42]=z,e[43]=j,e[44]=D,e[45]=K,e[46]=A):A=e[46];let M;e[47]!==E||e[48]!==A?(M=R("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[E,A]}),e[47]=E,e[48]=A,e[49]=M):M=e[49];let H;e[50]!==o?(H=o("Toggle sort direction"),e[50]=o,e[51]=H):H=e[51];const G=a==="asc"?"↑":"↓";let P;e[52]!==H||e[53]!==G||e[54]!==u?(P=r("button",{"aria-label":H,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:u,type:"button",children:G}),e[52]=H,e[53]=G,e[54]=u,e[55]=P):P=e[55];let Z;e[56]!==S||e[57]!==o||e[58]!==h||e[59]!==m?(Z=m==="grid"&&R("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[o("Thumbnail size"),r("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:S,step:8,type:"range",value:h})]}),e[56]=S,e[57]=o,e[58]=h,e[59]=m,e[60]=Z):Z=e[60];let ee;return e[61]!==M||e[62]!==P||e[63]!==Z||e[64]!==C?(ee=R("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[C,M,P,Z]}),e[61]=M,e[62]=P,e[63]=Z,e[64]=C,e[65]=ee):ee=e[65],ee};function Rt(d){return r("option",{value:d,children:d},d)}function zt(d){return r("option",{value:`tag:${d}`,children:d},d)}const Dt=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,jt=d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Dt.test(d.key),Kt=()=>{const d=U(1);let e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=r("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:r("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},Bt=d=>{const e=U(13),{object:t,resolveUrl:s}=d,[n,l]=B(null),[a,c]=B(!1);let o;e[0]!==t?(o=jt(t),e[0]=t,e[1]=o):o=e[1];const f=o;let h,u;e[2]!==f||e[3]!==t.key||e[4]!==s?(h=()=>{if(!f)return;const v={cancelled:!1};return q((async()=>{try{const S=await s(t.key);v.cancelled||l(S)}catch{v.cancelled||c(!0)}})()),()=>{v.cancelled=!0}},u=[f,t.key,s],e[2]=f,e[3]=t.key,e[4]=s,e[5]=h,e[6]=u):(h=e[5],u=e[6]),ne(h,u);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{c(!0)},e[7]=m):m=e[7];const k=m;let i;return e[8]!==a||e[9]!==f||e[10]!==t.key||e[11]!==n?(i=r("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:f&&n!==null&&!a?r("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:k,src:n}):r(Kt,{})}),e[8]=a,e[9]=f,e[10]=t.key,e[11]=n,e[12]=i):i=e[12],i},Lt=d=>{const e=U(42),{busy:t,copiedKey:s,handlers:n,object:l,prefix:a,references:c,resolveUrl:o,selected:f,showReferences:h,t:u}=d;let m;e[0]!==n||e[1]!==l||e[2]!==a?(m=Re(l,a,n),e[0]=n,e[1]=l,e[2]=a,e[3]=m):m=e[3];const{copy:k,download:i,name:v,remove:S,toggle:y}=m;let g;e[4]!==l||e[5]!==o?(g=r(Bt,{object:l,resolveUrl:o}),e[4]=l,e[5]=o,e[6]=g):g=e[6];let b;e[7]!==l.key||e[8]!==f||e[9]!==u||e[10]!==y?(b=r("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:r(je,{objectKey:l.key,onToggle:y,selected:f,t:u})}),e[7]=l.key,e[8]=f,e[9]=u,e[10]=y,e[11]=b):b=e[11];let x;e[12]!==g||e[13]!==b?(x=R("div",{className:"relative",children:[g,b]}),e[12]=g,e[13]=b,e[14]=x):x=e[14];let N;e[15]!==v?(N=r("p",{className:"truncate font-mono text-xs",title:v,children:v}),e[15]=v,e[16]=N):N=e[16];let w;e[17]!==l.size?(w=_e(l.size),e[17]=l.size,e[18]=w):w=e[18];let C;e[19]!==w?(C=r("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:w}),e[19]=w,e[20]=C):C=e[20];let E;e[21]!==l.key||e[22]!==c||e[23]!==h||e[24]!==u?(E=h&&r("div",{className:"mt-1",children:r(De,{objectKey:l.key,references:c,t:u})}),e[21]=l.key,e[22]=c,e[23]=h,e[24]=u,e[25]=E):E=e[25];let T;e[26]!==N||e[27]!==C||e[28]!==E?(T=R("div",{className:"min-w-0",children:[N,C,E]}),e[26]=N,e[27]=C,e[28]=E,e[29]=T):T=e[29];const F=s===l.key;let _;e[30]!==t||e[31]!==k||e[32]!==i||e[33]!==l.key||e[34]!==S||e[35]!==u||e[36]!==F?(_=r("div",{className:"flex items-center gap-1",children:r(ze,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:l.key,onCopy:k,onDelete:S,onDownload:i,t:u})}),e[30]=t,e[31]=k,e[32]=i,e[33]=l.key,e[34]=S,e[35]=u,e[36]=F,e[37]=_):_=e[37];let z;return e[38]!==_||e[39]!==x||e[40]!==T?(z=R("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[x,T,_]}),e[38]=_,e[39]=x,e[40]=T,e[41]=z):z=e[41],z},It=d=>{const e=U(9),{name:t,onEnter:s}=d;let n;e[0]!==t||e[1]!==s?(n=()=>{s(t)},e[0]=t,e[1]=s,e[2]=n):n=e[2];const l=n;let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:r("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:r("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=a):a=e[3];let c;e[4]!==t?(c=r("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=c):c=e[5];let o;return e[6]!==l||e[7]!==c?(o=R("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:l,type:"button",children:[a,c]}),e[6]=l,e[7]=c,e[8]=o):o=e[8],o},Ot=d=>{const e=U(34),{busy:t,copiedKey:s,files:n,folders:l,handlers:a,onEnterFolder:c,prefix:o,references:f,resolveUrl:h,selected:u,showReferences:m,size:k,t:i}=d;let v;e[0]!==k?(v=k.toString(),e[0]=k,e[1]=v):v=e[1];const S=`repeat(auto-fill, minmax(${v}px, 1fr))`;let y;e[2]!==S?(y={gridTemplateColumns:S},e[2]=S,e[3]=y):y=e[3];const g=y;let b;if(e[4]!==l||e[5]!==c){let w;e[7]!==c?(w=C=>r(It,{name:C,onEnter:c},C),e[7]=c,e[8]=w):w=e[8],b=l.map(w),e[4]=l,e[5]=c,e[6]=b}else b=e[6];let x;if(e[9]!==t||e[10]!==s||e[11]!==n||e[12]!==a||e[13]!==o||e[14]!==f||e[15]!==h||e[16]!==u||e[17]!==m||e[18]!==i){let w;e[20]!==t||e[21]!==s||e[22]!==a||e[23]!==o||e[24]!==f||e[25]!==h||e[26]!==u||e[27]!==m||e[28]!==i?(w=C=>r(Lt,{busy:t,copiedKey:s,handlers:a,object:C,prefix:o,references:f[C.key],resolveUrl:h,selected:u.has(C.key),showReferences:m,t:i},C.key),e[20]=t,e[21]=s,e[22]=a,e[23]=o,e[24]=f,e[25]=h,e[26]=u,e[27]=m,e[28]=i,e[29]=w):w=e[29],x=n.map(w),e[9]=t,e[10]=s,e[11]=n,e[12]=a,e[13]=o,e[14]=f,e[15]=h,e[16]=u,e[17]=m,e[18]=i,e[19]=x}else x=e[19];let N;return e[30]!==g||e[31]!==b||e[32]!==x?(N=R("div",{className:"grid gap-4","data-testid":"fb-gallery",style:g,children:[b,x]}),e[30]=g,e[31]=b,e[32]=x,e[33]=N):N=e[33],N},At=d=>{const e=U(23),{reference:t,t:s}=d,n=`fb-dangling-${t.table}-${t.id}-${t.column}`,l=`${t.table}·${t.id}`;let a;e[0]!==l?(a=r(fe,{variant:"secondary",children:l}),e[0]=l,e[1]=a):a=e[1];let c;e[2]!==t.column?(c=r("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=c):c=e[3];let o;e[4]!==s?(o=s("→"),e[4]=s,e[5]=o):o=e[5];let f;e[6]!==o?(f=r("span",{className:"text-muted-foreground/60",children:o}),e[6]=o,e[7]=f):f=e[7];let h;e[8]!==t.key?(h=r("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==c||e[12]!==f||e[13]!==h?(u=R("span",{className:"flex flex-wrap items-center gap-1.5",children:[a,c,f,h]}),e[10]=a,e[11]=c,e[12]=f,e[13]=h,e[14]=u):u=e[14];let m;e[15]!==s?(m=s("Missing object"),e[15]=s,e[16]=m):m=e[16];let k;e[17]!==m?(k=r(fe,{className:"border-destructive/40 text-destructive",variant:"outline",children:m}),e[17]=m,e[18]=k):k=e[18];let i;return e[19]!==n||e[20]!==k||e[21]!==u?(i=R("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":n,children:[u,k]}),e[19]=n,e[20]=k,e[21]=u,e[22]=i):i=e[22],i},Ut=d=>{const e=U(42),{busy:t,onCheck:s,references:n,t:l,truncated:a}=d;let c;e[0]!==l?(c=l("Integrity"),e[0]=l,e[1]=c):c=e[1];let o;e[2]!==c?(o=r("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:c}),e[2]=c,e[3]=o):o=e[3];let f;e[4]!==l?(f=l("Orphaned objects"),e[4]=l,e[5]=f):f=e[5];let h;e[6]!==f?(h=r("span",{className:"text-sm font-medium text-foreground",children:f}),e[6]=f,e[7]=h):h=e[7];let u;e[8]!==l?(u=l("Find records whose file reference points at an object the bucket no longer has."),e[8]=l,e[9]=u):u=e[9];let m;e[10]!==u?(m=r("span",{className:"text-xs text-muted-foreground",children:u}),e[10]=u,e[11]=m):m=e[11];let k;e[12]!==o||e[13]!==h||e[14]!==m?(k=R("div",{className:"flex flex-col gap-1",children:[o,h,m]}),e[12]=o,e[13]=h,e[14]=m,e[15]=k):k=e[15];let i;e[16]!==t||e[17]!==l?(i=l(t?"Checking…":"Check for orphans"),e[16]=t,e[17]=l,e[18]=i):i=e[18];let v;e[19]!==t||e[20]!==s||e[21]!==i?(v=r(oe,{"data-testid":"fb-orphans-check",disabled:t,onClick:s,size:"sm",type:"button",variant:"outline",children:i}),e[19]=t,e[20]=s,e[21]=i,e[22]=v):v=e[22];let S;e[23]!==k||e[24]!==v?(S=R("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[k,v]}),e[23]=k,e[24]=v,e[25]=S):S=e[25];let y;e[26]!==n||e[27]!==l||e[28]!==a?(y=a&&r("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:n===void 0||n.length===0?l("The bucket is larger than the scan's key limit, so dangling references could not be checked."):l("Showing the first {count} dangling references — the scan was truncated.",{count:n.length})}),e[26]=n,e[27]=l,e[28]=a,e[29]=y):y=e[29];let g;e[30]!==n?.length||e[31]!==l||e[32]!==a?(g=n?.length===0&&!a&&r(Te,{description:l("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:l("No dangling references.")}),e[30]=n?.length,e[31]=l,e[32]=a,e[33]=g):g=e[33];let b;e[34]!==n||e[35]!==l?(b=n!==void 0&&n.length>0&&r("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:n.map(N=>r(At,{reference:N,t:l},`${N.table}·${N.id}·${N.column}`))}),e[34]=n,e[35]=l,e[36]=b):b=e[36];let x;return e[37]!==S||e[38]!==y||e[39]!==g||e[40]!==b?(x=R("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[S,y,g,b]}),e[37]=S,e[38]=y,e[39]=g,e[40]=b,e[41]=x):x=e[41],x},Mt=function(d,e){const t=U(18);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=new Set,t[0]=s):s=t[0];const[n,l]=B(s);let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=y=>{l(g=>{const b=new Set(g);return b.has(y)?b.delete(y):b.add(y),b})},t[1]=a):a=t[1];const c=a;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{l(new Set)},t[2]=o):o=t[2];const f=o;let h,u,m;if(t[3]!==d||t[4]!==e||t[5]!==n){let y;t[9]!==e?(y=g=>e(g),t[9]=e,t[10]=y):y=t[10],u=d.map(y),h=u.length>0&&u.every(g=>n.has(g)),m=!h&&u.some(g=>n.has(g)),t[3]=d,t[4]=e,t[5]=n,t[6]=h,t[7]=u,t[8]=m}else h=t[6],u=t[7],m=t[8];const k=m;let i;t[11]!==u?(i=()=>{l(y=>u.every(g=>y.has(g))?new Set:new Set(u))},t[11]=u,t[12]=i):i=t[12];const v=i;let S;return t[13]!==h||t[14]!==n||t[15]!==k||t[16]!==v?(S={allSelected:h,clear:f,selected:n,someSelected:k,toggle:c,toggleAll:v},t[13]=h,t[14]=n,t[15]=k,t[16]=v,t[17]=S):S=t[17],S},Gt=$e(Fe.storageReferences),Ht=$e(Fe.storageOrphans),Ce=1e4,Pt=1e3,qt=async d=>{const e=[];let t,s=!0,n=!1;for(;s&&e.length<Ce;){const l=await d.list({cursor:t,limit:Pt}),a=Ce-e.length;for(const c of l.objects.slice(0,a))e.push(c.key);n||=l.objects.length>a,t=l.cursor,s=t!==void 0}return{liveKeys:e,truncated:n||s}},Wt=3600,Vt=(d,e)=>{if(!("document"in globalThis))return;const t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},Zt=d=>d.key,Xt=({initialPrefix:d,pageSize:e})=>{const t=vt(),[s,n]=B(d??""),[l,a]=B(d??""),[c,o]=B(Tt),[f,h]=B("list"),[u,m]=B(128),[k,i]=B("name"),[v,S]=B("asc"),[y,g]=B(void 0),[b,x]=B(void 0),[N,w]=B(!1),[C,E]=B(void 0),[T,F]=B(void 0),[_,z]=B(""),[L,j]=B({}),[I,D]=B(!1),[K,A]=B(void 0),[M,H]=B(!1),[G,P]=B(!1),[Z,ee]=B([]),[W,ye]=B(""),te=de(0),X=de(0),ae=de(0);ne(()=>{const p={cancelled:!1};return q((async()=>{try{const $=await t.listStorageBuckets();if(!p.cancelled){ee($);const[O]=$;O!==void 0&&ye(J=>J===""?O:J)}}catch{}})()),()=>{p.cancelled=!0}},[t]);const V=ge(()=>({list:p=>t.listStorageObjects({...p,bucket:W}),remove:p=>t.deleteStorageObject(p,{bucket:W}),signedUrl:(p,$)=>t.signedStorageUrl(p,{...$,bucket:W}),upload:p=>t.uploadStorageObject({...p,bucket:W})}),[W,t]),Y=ot(async(p,$,O,J=!1)=>{te.current+=1;const pe=te.current;x(void 0),w(!0);try{const se=await V.list({cursor:$,limit:e,prefix:p});if(pe!==te.current)return;g(ke=>O&&ke!==void 0?[...ke,...se.objects]:se.objects),F(se.cursor)}catch(se){if(pe!==te.current)return;if(O||g(void 0),x(ie(se)),J)throw se}finally{pe===te.current&&w(!1)}},[e,V]);ne(()=>{q(Y(d??"",void 0,!1))},[Y,d]);const Ke=(y?.length??0)<=e;xt(()=>Y(s,void 0,!1,!0),Ke);const{files:ue,folders:Be}=_t(y??[],s),Le=ge(()=>{const p=new Set;for(const $ of ue)for(const O of Object.keys($.customMetadata??{}))p.add(O);return[...p].toSorted(($,O)=>$.localeCompare(O))},[ue]),ce=Et(ue,k,v),he=ge(()=>[...new Set(ce.map(p=>p.key))].toSorted((p,$)=>p.localeCompare($)).join(`
|
|
3
|
+
`),[ce]);ne(()=>{const p=he===""?[]:he.split(`
|
|
4
|
+
`);if(p.length===0){j({});return}const $={current:!0};return q((async()=>{try{const O=await t.query(Gt,{keys:p},Se(_));$.current&&(j(O.references??{}),D(Object.keys(O.storageColumns??{}).length>0))}catch{$.current&&(j({}),D(!1))}})()),()=>{$.current=!1}},[t,he,_]);const{allSelected:Ie,clear:re,selected:xe,someSelected:Oe,toggle:Ae,toggleAll:Ue}=Mt(ce,Zt),Me=()=>{n(l),re(),q(Y(l,void 0,!1))},Ge=()=>{q(Y(s,T,!0))},ve=p=>{n(p),a(p),re(),q(Y(p,void 0,!1))},He=p=>{ve(`${s}${p}`)},Pe=p=>V.signedUrl(p,{expiresInSeconds:Wt}),qe=()=>{h("list")},We=()=>{h("grid")},Ve=p=>{i(p)},Ze=()=>{S(p=>p==="asc"?"desc":"asc")},Xe=p=>{m(p)},Ye=p=>{o(p)},me=p=>{const $=ae.current;x(void 0),w(!0),q((async()=>{try{await p(),$===ae.current&&await Y(s,void 0,!1)}catch(O){x(ie(O))}$===ae.current&&w(!1)})())},Je=()=>{me(async()=>{for(const p of xe)await V.remove(p);re()})},Qe=p=>{x(void 0),q((async()=>{try{const $=await V.signedUrl(p,{expiresInSeconds:c});mt($)&&E(p)}catch($){x(ie($))}})())},et=p=>{x(void 0),q((async()=>{try{const $=await V.signedUrl(p,{expiresInSeconds:c}),O=p.slice(p.lastIndexOf("/")+1)||p;Vt($,O)}catch($){x(ie($))}})())};ne(()=>{if(C===void 0)return;const p=globalThis.setTimeout(()=>{E(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[C]);const tt=p=>{me(async()=>{await V.remove(p)})},st=p=>{const $=`${s}${p.name}`;me(async()=>{const O=await p.arrayBuffer();await V.upload({body:O,contentType:p.type===""?void 0:p.type,key:$})})};ne(()=>{X.current+=1,A(void 0),P(!1)},[_]);const lt=()=>{X.current+=1;const p=X.current;x(void 0),H(!0),q((async()=>{try{const{liveKeys:$,truncated:O}=await qt(V);if(O)p===X.current&&(A(void 0),P(!0));else{const J=await t.query(Ht,{liveKeys:$},Se(_));p===X.current&&(A(J.references??[]),P(J.truncated===!0))}}catch($){p===X.current&&(A(void 0),P(!1),x(ie($)))}p===X.current&&H(!1)})())},nt=p=>{te.current+=1,X.current+=1,ae.current+=1,ye(p),n(d??""),a(d??""),g(void 0),A(void 0),P(!1),re()};return{allSelected:Ie,bucket:W,buckets:Z,bulkDelete:Je,busy:N,checkOrphans:lt,clearSelection:re,copiedKey:C,danglingBusy:M,danglingReferences:K,danglingTruncated:G,draftPrefix:l,enterFolder:He,error:b,expiry:c,files:ce,folders:Be,hasObjects:y!==void 0&&y.length>0,hasStorageColumns:I,listFirst:Me,loaded:y!==void 0,loadMore:Ge,navigate:ve,nextCursor:T,onCopy:Qe,onDelete:tt,onDownload:et,onExpiryChange:Ye,onFile:st,onSortKeyChange:Ve,onThumbSizeChange:Xe,prefix:s,referenceShard:_,references:L,resolveUrl:Pe,selectBucket:nt,selected:xe,setDraftPrefix:a,setReferenceShard:z,showGrid:We,showList:qe,someSelected:Oe,sortDirection:v,sortKey:k,tagKeys:Le,thumbSize:u,toggleSelect:Ae,toggleSelectAll:Ue,toggleSortDirection:Ze,view:f}},Yt=100,Ne=d=>{const e=U(6),{label:t,onNavigate:s,target:n}=d;let l;e[0]!==s||e[1]!==n?(l=()=>{s(n)},e[0]=s,e[1]=n,e[2]=l):l=e[2];const a=l;let c;return e[3]!==a||e[4]!==t?(c=r("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:a,type:"button",children:t}),e[3]=a,e[4]=t,e[5]=c):c=e[5],c},Jt=d=>{const e=U(11),{onNavigate:t,prefix:s,t:n}=d;let l;if(e[0]!==t||e[1]!==s||e[2]!==n){const a=s.split("/").filter(Qt);let c;e[4]!==n?(c=n("Folder path"),e[4]=n,e[5]=c):c=e[5];let o;e[6]!==n?(o=n("root"),e[6]=n,e[7]=o):o=e[7];let f;e[8]!==t||e[9]!==o?(f=r(Ne,{label:o,onNavigate:t,target:""}),e[8]=t,e[9]=o,e[10]=f):f=e[10],l=R("nav",{"aria-label":c,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[f,a.map((h,u)=>R("span",{className:"flex items-center gap-0.5",children:[r("span",{className:"text-muted-foreground/50",children:"/"}),r(Ne,{label:h,onNavigate:t,target:`${a.slice(0,u+1).join("/")}/`})]},`${h}-${u.toString()}`))]}),e[0]=t,e[1]=s,e[2]=n,e[3]=l}else l=e[3];return l},xs=({initialPrefix:d,pageSize:e=Yt})=>{const t=it(),s=Xt({initialPrefix:d,pageSize:e}),n=de(null),{onCopy:l,onDelete:a,onDownload:c,onFile:o,toggleSelect:f}=s,h={onCopy:l,onDelete:a,onDownload:c,onToggleSelect:f},u=()=>{n.current?.click()},m=i=>{const v=i.target,S=v.files?.[0];v.value="",S&&o(S)},k=s.loaded&&!s.hasObjects;return R("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[r($t,{bucket:s.bucket,buckets:s.buckets,busy:s.busy,draftPrefix:s.draftPrefix,expiry:s.expiry,fileInputRef:n,onBucketChange:s.selectBucket,onExpiryChange:s.onExpiryChange,onFileChange:m,onList:s.listFirst,onPrefixChange:s.setDraftPrefix,onUploadClick:u,t}),s.loaded&&r(Jt,{onNavigate:s.navigate,prefix:s.prefix,t}),s.hasObjects&&r(Ft,{onSortKeyChange:s.onSortKeyChange,onThumbSizeChange:s.onThumbSizeChange,showGrid:s.showGrid,showList:s.showList,sortDirection:s.sortDirection,sortKey:s.sortKey,t,tagKeys:s.tagKeys,thumbSize:s.thumbSize,toggleSortDirection:s.toggleSortDirection,view:s.view}),s.hasStorageColumns&&R("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[r("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),r(rt,{id:"fb-reference-shard-input",onChange:s.setReferenceShard,testId:"fb-reference-shard-input",value:s.referenceShard}),r("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),s.hasStorageColumns&&r(Ut,{busy:s.danglingBusy,onCheck:s.checkOrphans,references:s.danglingReferences,t,truncated:s.danglingTruncated}),s.selected.size>0&&r(at,{count:s.selected.size,editable:!0,onClear:s.clearSelection,onDelete:s.bulkDelete}),s.error!==void 0&&r("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:s.error}),k&&r(Te,{description:t("Objects you upload to your R2 buckets will appear here."),icon:R("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[r("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),r("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),s.hasObjects&&s.view==="list"&&r(Ct,{allSelected:s.allSelected,busy:s.busy,copiedKey:s.copiedKey,files:s.files,folders:s.folders,handlers:h,onEnterFolder:s.enterFolder,prefix:s.prefix,references:s.references,selected:s.selected,showReferences:s.hasStorageColumns,someSelected:s.someSelected,t,toggleSelectAll:s.toggleSelectAll}),s.hasObjects&&s.view==="grid"&&r(Ot,{busy:s.busy,copiedKey:s.copiedKey,files:s.files,folders:s.folders,handlers:h,onEnterFolder:s.enterFolder,prefix:s.prefix,references:s.references,resolveUrl:s.resolveUrl,selected:s.selected,showReferences:s.hasStorageColumns,size:s.thumbSize,t}),s.nextCursor!==void 0&&r("div",{children:r(oe,{"data-testid":"fb-next",disabled:s.busy,onClick:s.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})};function Qt(d){return d!==""}export{xs as FileBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{encodeWire as U,decodeWire as ee}from"@lunora/wire";import{useState as u,useEffect as te}from"react";import{ConfirmButton as re}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{ShardInput as se}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as z}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as k}from"../packem_shared/button-q0UYSmrn.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{L as R}from"../packem_shared/label-DKFzyHq6.mjs";import{T as oe}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as ie}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as ce}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as J,h as le,f as de,k as ue,m as fe,c as he}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as pe}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{jsxs as d,jsx as a}from"react/jsx-runtime";const me=t=>t.kind==="id"?t.table===void 0?"id":`id<${t.table}>`:t.kind==="array"?t.element===void 0?"array":`${t.element}[]`:t.kind,ge=t=>t===void 0||t.length===0?"()":`(${t.map(e=>`${e.name}${e.optional?"?":""}: ${me(e)}`).join(", ")})`,be=t=>{switch(t){case"array":return[];case"bigint":return U(0n);case"boolean":return!1;case"bytes":return U(new ArrayBuffer(0));case"number":return 0;case"object":case"record":return{};default:return""}},xe=t=>{const e={};for(const r of t??[])r.optional||(e[r.name]=be(r.kind));return JSON.stringify(e,void 0,2)},ye=he(ce.runAs),m="«sensitive»",ve=t=>(t??[]).filter(e=>e.sensitive===!0).map(e=>e.name),Ne=(t,e)=>{if(e.length===0)return t;try{const r=JSON.parse(t);if(typeof r!="object"||r===null||Array.isArray(r))return"";const i={...r};for(const n of e)Object.hasOwn(i,n)&&(i[n]=m);return JSON.stringify(i,null,2)}catch{return""}},Se=4,Ae=t=>{const e=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}},we=t=>Array.isArray(t)?[]:Object.keys(t).filter(e=>e.length>0),ke=t=>{const e=[],r=new Set,i=[t];for(;i.length>0;){const n=i.pop();if(typeof n=="string")n.length>0&&e.push(n);else if(typeof n=="number"||typeof n=="bigint")e.push(String(n));else if(n instanceof ArrayBuffer||ArrayBuffer.isView(n)){const l=Ae(n);l!==void 0&&l.length>0&&e.push(l)}else typeof n=="object"&&n!==null&&!r.has(n)&&(r.add(n),e.push(...we(n)),i.push(...Object.values(n)))}return e},Re=(t,e)=>{const r=[],i=new Set,n=[[t,e]];for(;n.length>0;){const[l,o]=n.pop()??[void 0,void 0];typeof o=="boolean"?r.push({key:l,text:o?"true":"false"}):typeof o=="object"&&o!==null&&!i.has(o)&&(i.add(o),Array.isArray(o)?n.push(...o.map(h=>[void 0,h])):n.push(...Object.entries(o)))}return r},P=t=>t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`),Oe=(t,e)=>e.length>=Se?t.replaceAll(e,m):t.replaceAll(new RegExp(`(?<![A-Za-z0-9])${P(e)}(?![A-Za-z0-9])`,"gu"),m),Ie=(t,e)=>{const r=t.replaceAll(`"${e.text}"`,m);if(e.key===void 0)return r;const i=P(e.key);return r.replaceAll(new RegExp(`(?<![A-Za-z0-9_])${i}=${e.text}(?![A-Za-z0-9_])`,"gu"),`${e.key}=${m}`).replaceAll(new RegExp(String.raw`"${i}":\s*${e.text}(?![A-Za-z0-9_])`,"gu"),`"${e.key}":${m}`)},$e=(t,e,r)=>{if(r.length===0||typeof e!="object"||e===null)return t;const i=r.flatMap(o=>Re(o,e[o])),n=r.flatMap(o=>ke(e[o])).flatMap(o=>{const h=JSON.stringify(o).slice(1,-1);return h===o?[o]:[o,h]}).toSorted((o,h)=>h.length-o.length);let l=t;for(const o of i)l=Ie(l,o);for(const o of n)l=Oe(l,o);return l},Te=10,Ce=t=>t===void 0?"undefined":JSON.stringify(t,ue,2),Ee=(t,e)=>[{argsText:Ne(e.argsText,e.sensitive),at:Date.now(),id:(t[0]?.id??0)+1,kind:e.selected.kind,path:e.selected.path,redacted:e.sensitive.length>0,shardKey:e.shardKey,status:e.runStatus},...t].slice(0,Te),Ge=({functions:t,runAsIdentity:e=!1}={})=>{const r=ie(),i=ae(),[n,l]=u(null),[o,h]=u(null),S=t??n??[],[O,I]=u(""),[y,A]=u("{}"),[g,$]=u(""),[b,V]=u(""),[w,x]=u("idle"),[Z,v]=u(void 0),[T,N]=u(null),[C,q]=u([]);te(()=>{if(t!==void 0)return;let s=!1;return i.listFunctions().then(f=>(s||l(f),f)).catch(f=>{s||h(J(f))}),()=>{s=!0}},[i,t]);const E=O===""?S[0]?.path??"":O,c=S.find(s=>s.path===E),H=async()=>{if(!c)return;let s;try{s=y.trim()===""?{}:ee(JSON.parse(y))}catch(p){x("error"),v(void 0),N(r("Invalid JSON args: {message}",{message:p.message}));return}const f={__lunoraRef:c.path},L=g.trim()===""?{}:{shardKey:g.trim()},K=e?b.trim():"",D=ve(c.args),M=p=>{q(Q=>Ee(Q,{argsText:y,runStatus:p,selected:c,sensitive:D,shardKey:g}))};x("running"),N(null);try{const p=K===""?await fe(i,c.kind,f,s,L):await i.query(ye,{args:s,functionPath:c.path,userId:K},L);pe(g),v(p),x("success"),M("success")}catch(p){v(void 0),N($e(J(p),s,D)),x("error"),M("error")}},G=s=>{if(I(s.path),$(s.shardKey),s.redacted){v(void 0),N(r("Re-enter the sensitive values before running this again.")),x("error");return}A(s.argsText)},W=s=>{I(s.target.value)},X=s=>{A(s.target.value)},Y=s=>{V(s.target.value)},j=()=>{de(H())},B=e?b.trim():"",F=w==="running"||c===void 0,_=()=>{A(xe(c?.args))};return d("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[o!==null&&a("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:o}),d("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[d("div",{className:"flex flex-col gap-1.5",children:[a(R,{htmlFor:"function-select",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:W,value:E,children:S.map(s=>d("option",{value:s.path,children:[s.path," (",s.kind,")"]},s.path))}),c!==void 0&&d("p",{className:"text-xs text-muted-foreground",children:[a("span",{className:"mr-1.5 font-medium",children:r("Signature")}),a("code",{className:"font-mono","data-testid":"function-signature",children:ge(c.args)})]})]}),d("div",{className:"flex flex-col gap-1.5",children:[d("div",{className:"flex items-center justify-between gap-2",children:[a(R,{htmlFor:"args-input",children:r("Arguments")}),a(k,{"data-testid":"prefill-button",disabled:c===void 0,onClick:_,size:"xs",type:"button",variant:"ghost",children:r("Prefill")})]}),a(oe,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:X,value:y})]}),a(se,{onChange:$,testId:"shard-input",value:g}),e&&d("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[a(R,{htmlFor:"run-as-input",children:r("Run as identity (userId)")}),a(ne,{"aria-label":r("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:Y,placeholder:r("Leave empty to run as admin"),value:b}),a("p",{className:"text-[11px] text-muted-foreground",children:r("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),d("div",{className:"flex flex-wrap items-center gap-2",children:[B!==""&&c!==void 0&&c.kind!=="query"?a(re,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:c.path,userId:B}),disabled:F,onConfirm:j,testId:"run-button",children:r("Run")}):a(k,{"data-testid":"run-button",disabled:F,onClick:j,type:"button",children:r("Run")}),c!==void 0&&a(z,{variant:"outline",children:c.kind}),e&&b.trim()!==""&&a(z,{"data-testid":"run-as-badge",variant:"secondary",children:r("as {userId}",{userId:b.trim()})})]})]}),w==="error"&&T!==null&&a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:T}),w==="success"&&a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:Ce(Z)}),C.length>0&&a("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:C.map((s,f)=>d("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[a("span",{className:s.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${f.toString()}`,children:s.status==="success"?"✓":"✗"})," ",d("span",{className:"font-mono text-xs",children:[s.path," (",s.kind,")"]})," ",a("time",{className:"text-xs text-muted-foreground",children:le(s.at)})," ",a(k,{className:"ml-auto","data-testid":`fn-history-load-${f.toString()}`,onClick:()=>{G(s)},size:"xs",type:"button",variant:"ghost",children:r("Load")})]},s.id))})]})};export{Ge as FunctionRunner};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as Q}from"react/compiler-runtime";import{useState as U}from"react";import{E as V}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{L as W}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as G}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as J}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as X}from"../packem_shared/button-q0UYSmrn.mjs";import{C as Y,a as Z}from"../packem_shared/card-By2O8ULa.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as te,a as re,b as L,c as a,d as le,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as se}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as ae}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as ne}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as ie}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as j}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as y}from"react/jsx-runtime";const ce={action:"outline",mutation:"default",query:"secondary"},q=r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,de=r=>r.calls===0?"—":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,me=r=>{const e=r.conflicts??0;return r.calls===0?"—":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},ue={calls:(r,e)=>e.calls-r.calls,recent:(r,e)=>e.lastCalledAt-r.lastCalledAt,slowest:(r,e)=>e.maxDurationMs-r.maxDurationMs},Ae=r=>{const e=Q(47),{functions:I,initialShardKey:P}=r,s=ne(),{queryShardKey:F,setShardKey:N,shardKey:S}=ae(P),[o,H]=U("recent");let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={},e[0]=M):M=e[0];let T;e[1]!==F?(T={live:!0,shardKey:F},e[1]=F,e[2]=T):T=e[2];const{data:O,error:i,errorSource:b,liveError:v}=se(oe.getFunctionStats,M,T),k=O?.functions??null;let w;e[3]!==I?(w=new Map((I??[]).map(fe)),e[3]=I,e[4]=w):w=e[4];const _=w;let E;e[5]===Symbol.for("react.memo_cache_sentinel")?(E=C=>{H(C.currentTarget.dataset.sort)},e[5]=E):E=e[5];const z=E;let K;if(e[6]!==i||e[7]!==b||e[8]!==_||e[9]!==v||e[10]!==N||e[11]!==S||e[12]!==o||e[13]!==k||e[14]!==s){const C=k===null?[]:k.toSorted(ue[o]);let c;e[16]!==s?(c=s("Recent"),e[16]=s,e[17]=c):c=e[17];let d;e[18]!==c?(d={key:"recent",label:c},e[18]=c,e[19]=d):d=e[19];let m;e[20]!==s?(m=s("Most called"),e[20]=s,e[21]=m):m=e[21];let u;e[22]!==m?(u={key:"calls",label:m},e[22]=m,e[23]=u):u=e[23];let f;e[24]!==s?(f=s("Slowest"),e[24]=s,e[25]=f):f=e[25];let h;e[26]!==f?(h={key:"slowest",label:f},e[26]=f,e[27]=h):h=e[27];let $;e[28]!==h||e[29]!==d||e[30]!==u?($=[d,u,h],e[28]=h,e[29]=d,e[30]=u,e[31]=$):$=e[31];const D=$;let p;e[32]!==N||e[33]!==S?(p=t(G,{onChange:N,testId:"fs-shard-input",value:S}),e[32]=N,e[33]=S,e[34]=p):p=e[34];let x;e[35]!==v?(x=t(W,{message:v,prefix:"fs"}),e[35]=v,e[36]=x):x=e[36];let g;e[37]!==D||e[38]!==o?(g=t("div",{className:"ml-auto flex items-center gap-1",role:"group",children:D.map(l=>t(X,{"data-sort":l.key,"data-testid":`fs-sort-${l.key}`,onClick:z,size:"sm",type:"button",variant:o===l.key?"secondary":"ghost",children:l.label},l.key))}),e[37]=D,e[38]=o,e[39]=g):g=e[39];let A;e[40]!==p||e[41]!==x||e[42]!==g?(A=y("div",{className:"flex flex-wrap items-center gap-2",children:[p,x,g]}),e[40]=p,e[41]=x,e[42]=g,e[43]=A):A=e[43];let B;e[44]!==i||e[45]!==b?(B=i!==null&&t(V,{error:b,testId:"fs-error"}),e[44]=i,e[45]=b,e[46]=B):B=e[46],K=y("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[A,B,k!==null&&C.length===0&&i===null&&t(ee,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:y("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M3 3v18h18"}),t("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),C.length>0&&t(Y,{className:"overflow-hidden py-0",children:t(Z,{className:"px-0",children:y(te,{"data-testid":"fs-table",children:[t(re,{children:y(L,{children:[t(a,{children:s("function")}),t(a,{children:s("kind")}),t(a,{className:"text-right",children:s("calls")}),t(a,{className:"text-right",children:s("errors")}),t(a,{className:"text-right",children:s("conflicts")}),t(a,{className:"text-right",children:s("avg")}),t(a,{className:"text-right",children:s("max")}),t(a,{children:s("last run")}),t(a,{children:s("last error")})]})}),t(le,{children:C.map(l=>{const R=_.get(l.path);return y(L,{"data-testid":`fs-row-${l.path}`,children:[t(n,{className:"font-medium",children:l.path}),t(n,{children:R===void 0?t("span",{className:"text-muted-foreground",children:"—"}):t(J,{variant:ce[R],children:R})}),t(n,{className:"text-right tabular-nums",children:l.calls}),t(n,{className:j("text-right tabular-nums",l.errors>0&&"text-destructive"),children:de(l)}),t(n,{className:j("text-right tabular-nums",(l.conflicts??0)>0&&"text-warning"),children:me(l)}),t(n,{className:"text-right tabular-nums",children:l.calls===0?"—":q(l.totalDurationMs/l.calls)}),t(n,{className:"text-right tabular-nums",children:l.calls===0?"—":q(l.maxDurationMs)}),t(n,{className:"text-muted-foreground",children:ie(l.lastCalledAt,"—")}),t(n,{className:"max-w-[24ch] truncate text-destructive",title:l.lastErrorMessage??void 0,children:l.lastErrorMessage??t("span",{className:"text-muted-foreground",children:"—"})})]},l.path)})})]})})})]}),e[6]=i,e[7]=b,e[8]=_,e[9]=v,e[10]=N,e[11]=S,e[12]=o,e[13]=k,e[14]=s,e[15]=K}else K=e[15];return K};function fe(r){return[r.path,r.kind]}export{Ae as FunctionStatsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as se}from"react/compiler-runtime";import{useState as F,useRef as Z,useCallback as xe,useEffect as ie}from"react";import ve from"../packem_shared/ConnectionBadge-BfcoN-VE.mjs";import{L as Ne}from"../packem_shared/live-status-D1GasNsH.mjs";import{B as te}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as X}from"../packem_shared/card-By2O8ULa.mjs";import{u as be}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as Se}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as ye,f as ae,d as ce,b as ue,c as J}from"../packem_shared/internal-BXEjuLPN.mjs";import{l as Ee}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{c as W}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as a,jsxs as m}from"react/jsx-runtime";import{shardsToAggregate as we}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as ne}from"../packem_shared/sparkline-B_sPPO_8.mjs";const Te={crit:"destructive",ok:"secondary",warn:"default"},re=(s,e)=>e===0?"—":`${(s/e*100).toFixed(1)}%`,oe=(s,e,l)=>Number.isNaN(s)?"ok":s>=l?"crit":s>=e?"warn":"ok",me=.01,he=.05,_e=s=>{const e=se(36),{errorCount:l,logsError:t,topErrors:r,worstFunctions:c}=s,i=le();let n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let d;e[4]!==i||e[5]!==c?(d=c.length===0?a("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):a("ul",{className:"divide-y divide-border",children:c.map(b=>m("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[a("span",{className:"truncate font-mono text-foreground",children:b.path}),m("span",{className:"flex shrink-0 items-center gap-2",children:[a("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:b.calls.toString()})}),a(te,{variant:Te[oe(b.errors/b.calls,me,he)],children:re(b.errors,b.calls)})]})]},b.path))}),e[4]=i,e[5]=c,e[6]=d):d=e[6];let p;e[7]!==o||e[8]!==d?(p=m(X,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,d]}),e[7]=o,e[8]=d,e[9]=p):p=e[9];let x;e[10]!==i?(x=i("Recent errors"),e[10]=i,e[11]=x):x=e[11];let f;e[12]!==x?(f=a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:x}),e[12]=x,e[13]=f):f=e[13];const u=l>0?"destructive":"outline";let g;e[14]!==l||e[15]!==u?(g=a(te,{"data-testid":"hl-error-count",variant:u,children:l}),e[14]=l,e[15]=u,e[16]=g):g=e[16];let h;e[17]!==f||e[18]!==g?(h=m("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[f,g]}),e[17]=f,e[18]=g,e[19]=h):h=e[19];let E;e[20]!==t?(E=t!==null&&a("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:t}),e[20]=t,e[21]=E):E=e[21];let w;e[22]!==t||e[23]!==i||e[24]!==r.length?(w=t===null&&r.length===0&&a("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=t,e[23]=i,e[24]=r.length,e[25]=w):w=e[25];let T;e[26]!==r?(T=r.length>0&&a("ul",{className:"divide-y divide-border",children:r.map(Ae)}),e[26]=r,e[27]=T):T=e[27];let S;e[28]!==E||e[29]!==w||e[30]!==T||e[31]!==h?(S=m(X,{className:"gap-0 py-0",children:[h,E,w,T]}),e[28]=E,e[29]=w,e[30]=T,e[31]=h,e[32]=S):S=e[32];let y;return e[33]!==S||e[34]!==p?(y=m("div",{className:"grid gap-3 lg:grid-cols-2",children:[p,S]}),e[33]=S,e[34]=p,e[35]=y):y=e[35],y};function Ae(s,e){return m("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[m("span",{className:"flex items-center gap-2",children:[a("time",{className:"shrink-0 text-muted-foreground",children:ye(s.timestamp)}),s.functionPath!==void 0&&a("span",{className:"truncate font-mono text-foreground",children:s.functionPath})]}),a("span",{className:"text-destructive",children:s.message})]},`${s.timestamp.toString()}-${e.toString()}`)}const de={completed:0,failed:2,in_progress:1},ke=s=>{let e=0,l=0,t=0,r=0,c=!1;const i=[];for(const{metrics:n}of s){if(n===null){r+=1;continue}t+=1,e+=n.requests,l+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:l,failed:r,history:i,historyTruncated:c,reachable:t,requests:e}},Re=s=>{const e=new Map;for(const l of s)for(const t of l){const r=e.get(t.path);if(r===void 0){e.set(t.path,{...t});continue}r.calls+=t.calls,r.errors+=t.errors,r.totalDurationMs+=t.totalDurationMs,r.scans=(r.scans??0)+(t.scans??0),r.maxDurationMs=Math.max(r.maxDurationMs,t.maxDurationMs),r.lastCalledAt=Math.max(r.lastCalledAt,t.lastCalledAt),(t.lastErrorAt??0)>(r.lastErrorAt??0)&&(r.lastErrorAt=t.lastErrorAt,r.lastErrorMessage=t.lastErrorMessage)}return[...e.values()]},Me=s=>{const e=new Map;for(const l of s)for(const t of l){const r=e.get(t.id);if(r===void 0){e.set(t.id,t);continue}const c=de[t.status]-de[r.status];(c>0||c===0&&(t.updatedAt??0)>(r.updatedAt??0))&&e.set(t.id,t)}return[...e.values()]},Le=J(z.getAuthMetrics),Ie=J(z.getFunctionStats),Ce=J(z.getLogs),qe=J(z.getMetrics),Oe=J(z.migrationStatus),Fe=5,fe=2e3,De=5,je=.1,Ue=.3,Pe=1,Ge=50,$e=(s,e,l)=>s>=l?"crit":s>=e?"warn":"ok",Be=s=>{const e=new Map;for(const t of s??[]){const r=e.get(t.bucketMs)??{calls:0,errors:0};r.calls+=t.calls,r.errors+=t.errors,e.set(t.bucketMs,r)}const l=[...e.entries()].toSorted((t,r)=>t[0]-r[0]);return{errors:l.map(([,t])=>t.errors),requests:l.map(([,t])=>t.calls)}},Ve=s=>{let e=0,l=0;for(const r of s)r.status==="failed"?e+=1:r.status==="in_progress"&&(l+=1);let t="ok";return e>0?t="crit":l>0&&(t="warn"),{failed:e,level:t,running:l}},He=(s,e)=>s.failed>0?e("{count} failed",{count:s.failed.toString()}):s.running>0?e("{count} running",{count:s.running.toString()}):e("OK"),pe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ge={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Ke={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},ze=s=>s.includes("crit")?"crit":s.includes("warn")?"warn":"ok",ee=s=>{const e=se(19),{chart:l,label:t,level:r,testId:c,value:i}=s,n=pe[r];let o;e[0]!==n?(o=W("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let d;e[2]!==o?(d=a("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=d):d=e[3];let p;e[4]!==t||e[5]!==d?(p=m("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[d,t]}),e[4]=t,e[5]=d,e[6]=p):p=e[6];const x=ge[r];let f;e[7]!==x?(f=W("truncate text-2xl font-semibold tabular-nums",x),e[7]=x,e[8]=f):f=e[8];let u;e[9]!==f||e[10]!==c||e[11]!==i?(u=a("span",{className:f,"data-testid":c,children:i}),e[9]=f,e[10]=c,e[11]=i,e[12]=u):u=e[12];let g;e[13]!==l||e[14]!==u?(g=m("div",{className:"flex items-center justify-between gap-3",children:[u,l]}),e[13]=l,e[14]=u,e[15]=g):g=e[15];let h;return e[16]!==p||e[17]!==g?(h=a(X,{className:"gap-0 py-0",children:m("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]})}),e[16]=p,e[17]=g,e[18]=h):h=e[18],h},Qe=async(s,e,l)=>{const t=await Promise.all(l.map(f=>{const u=ce(f);return Promise.allSettled([s.query(qe,{},u),s.query(Ie,{},u),s.query(Oe,{},u)])})),r=ce(e),c=typeof s.schedulerStatus=="function"?s.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([s.query(Ce,{},r),s.query(Le,{},r),c]),d=t.map(([f,u,g])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:f.status==="fulfilled"?f.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),p=ke(d),x=t[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Re(d.map(f=>f.functions)),logsError:i.status==="rejected"?ue(i.reason):null,metricsError:p.reachable===0&&x?.status==="rejected"?ue(x.reason):null,migrations:Me(d.map(f=>f.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:p}},We=s=>{const e=s?.history??[];return{attempts:e.map(l=>l.attempts),failures:e.map(l=>l.failures)}},Xe=(s,e)=>s==="crit"?{description:e("One or more service levels are breached."),label:e("Critical")}:s==="warn"?{description:e("Some service levels need attention."),label:e("Degraded")}:{description:e("All service levels are within target."),label:e("All systems healthy")},Je=s=>{const e=se(75),{errorLevel:l,liveError:t,metricsError:r,overall:c,requestSeries:i,totals:n}=s,o=le();let d;e[0]!==c||e[1]!==o?(d=Xe(c,o),e[0]=c,e[1]=o,e[2]=d):d=e[2];const{description:p,label:x}=d,f=Ke[c];let u;e[3]!==f?(u=W("flex size-10 shrink-0 items-center justify-center rounded-full",f),e[3]=f,e[4]=u):u=e[4];const g=pe[c];let h;e[5]!==g?(h=W("size-3 rounded-full",g),e[5]=g,e[6]=h):h=e[6];let E;e[7]!==h?(E=a("span",{className:h}),e[7]=h,e[8]=E):E=e[8];let w;e[9]!==u||e[10]!==E?(w=a("span",{"aria-hidden":"true",className:u,children:E}),e[9]=u,e[10]=E,e[11]=w):w=e[11];let T;e[12]!==x?(T=a("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:x}),e[12]=x,e[13]=T):T=e[13];let S;e[14]!==p?(S=a("span",{className:"text-[13px] text-muted-foreground",children:p}),e[14]=p,e[15]=S):S=e[15];let y;e[16]!==T||e[17]!==S?(y=m("div",{className:"grid leading-tight",children:[T,S]}),e[16]=T,e[17]=S,e[18]=y):y=e[18];let b;e[19]!==y||e[20]!==w?(b=m("div",{className:"flex items-center gap-3",children:[w,y]}),e[19]=y,e[20]=w,e[21]=b):b=e[21];let k;e[22]!==o?(k=o("Requests"),e[22]=o,e[23]=k):k=e[23];let _;e[24]!==k?(_=a("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:k}),e[24]=k,e[25]=_):_=e[25];let A;e[26]!==i||e[27]!==o?(A=i.length>=2&&a(ne,{ariaLabel:o("Requests over time"),className:"h-6 w-20 text-foreground",series:i,testId:"hl-spark-requests"}),e[26]=i,e[27]=o,e[28]=A):A=e[28];const D=n?.requests??0;let j;e[29]!==D?(j=D.toString(),e[29]=D,e[30]=j):j=e[30];let I;e[31]!==j?(I=a("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:j}),e[31]=j,e[32]=I):I=e[32];let U;e[33]!==A||e[34]!==I?(U=m("div",{className:"flex items-center justify-end gap-2",children:[A,I]}),e[33]=A,e[34]=I,e[35]=U):U=e[35];let C;e[36]!==_||e[37]!==U?(C=m("div",{className:"text-end",children:[_,U]}),e[36]=_,e[37]=U,e[38]=C):C=e[38];let $;e[39]===Symbol.for("react.memo_cache_sentinel")?($=a("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[39]=$):$=e[39];let R;e[40]!==o?(R=o("Error rate"),e[40]=o,e[41]=R):R=e[41];let q;e[42]!==R?(q=a("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:R}),e[42]=R,e[43]=q):q=e[43];const Q=ge[l];let M;e[44]!==Q?(M=W("text-lg font-semibold tabular-nums",Q),e[44]=Q,e[45]=M):M=e[45];let P;e[46]!==n?(P=n===null?"—":re(n.errors,n.requests),e[46]=n,e[47]=P):P=e[47];let L;e[48]!==M||e[49]!==P?(L=a("div",{className:M,"data-testid":"hl-error-rate",children:P}),e[48]=M,e[49]=P,e[50]=L):L=e[50];let O;e[51]!==q||e[52]!==L?(O=m("div",{className:"text-end",children:[q,L]}),e[51]=q,e[52]=L,e[53]=O):O=e[53];let G;e[54]===Symbol.for("react.memo_cache_sentinel")?(G=a("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[54]=G):G=e[54];let B;e[55]===Symbol.for("react.memo_cache_sentinel")?(B=a(ve,{}),e[55]=B):B=e[55];let v;e[56]!==t?(v=m("div",{className:"flex items-center gap-2",children:[B,a(Ne,{message:t,prefix:"hl"})]}),e[56]=t,e[57]=v):v=e[57];let N;e[58]!==C||e[59]!==O||e[60]!==v?(N=m("div",{className:"flex flex-wrap items-center gap-4",children:[C,$,O,G,v]}),e[58]=C,e[59]=O,e[60]=v,e[61]=N):N=e[61];let V;e[62]!==b||e[63]!==N?(V=m("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[b,N]}),e[62]=b,e[63]=N,e[64]=V):V=e[64];let H;e[65]!==r?(H=r!==null&&a("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:r}),e[65]=r,e[66]=H):H=e[66];let K;e[67]!==r||e[68]!==o||e[69]!==n?.historyTruncated?(K=r===null&&n?.historyTruncated===!0&&a("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:o("Showing a partial request/error history — one or more shards have more data than the trend chart can display.")}),e[67]=r,e[68]=o,e[69]=n?.historyTruncated,e[70]=K):K=e[70];let Y;return e[71]!==V||e[72]!==H||e[73]!==K?(Y=m(X,{className:"gap-0 py-0",children:[V,H,K]}),e[71]=V,e[72]=H,e[73]=K,e[74]=Y):Y=e[74],Y},Ye=s=>{const e=se(14),{shards:l}=s,t=le();let r;e[0]!==t?(r=t("Shards seen"),e[0]=t,e[1]=r):r=e[1];let c;e[2]!==r?(c=a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=c):c=e[3];let i;e[4]!==l.length?(i=a(te,{"data-testid":"hl-shard-count",variant:"outline",children:l.length}),e[4]=l.length,e[5]=i):i=e[5];let n;e[6]!==c||e[7]!==i?(n=m("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[c,i]}),e[6]=c,e[7]=i,e[8]=n):n=e[8];let o;e[9]!==l?(o=l.length>0&&a("ul",{className:"flex flex-wrap gap-1.5 p-4",children:l.map(Ze)}),e[9]=l,e[10]=o):o=e[10];let d;return e[11]!==n||e[12]!==o?(d=m(X,{className:"gap-0 py-0",children:[n,o]}),e[11]=n,e[12]=o,e[13]=d):d=e[13],d},gt=({initialShardKey:s})=>{const e=Se(),l=le(),[t,r]=F([]),[c,i]=F(null),[n,o]=F(null),[d,p]=F(null),[x,f]=F([]),[u,g]=F(null),[h,E]=F(null),[w,T]=F([]),[S]=F(Ee),y=Z(!1),b=Z(0),k=Z(0),_=Z(null),A=s??"",D=xe(async()=>{if(y.current)return;y.current=!0;const v=b.current,N=await Qe(e,A,we(A,S));v===b.current&&(o(N.totals),p(N.metricsError),f(N.functions),T(N.migrations),r(N.entries),i(N.logsError),g(N.auth),E(N.scheduler),y.current=!1)},[e,S,A]);ie(()=>(ae(D()),()=>{b.current+=1,y.current=!1,_.current!==null&&(clearTimeout(_.current),_.current=null)}),[D]);const j=()=>{const v=Date.now()-k.current;if(v>=fe){k.current=Date.now(),ae(D());return}_.current===null&&(_.current=setTimeout(()=>{_.current=null,k.current=Date.now(),ae(D())},fe-v))},{data:I,liveError:U}=be(z.getMetrics,{},{live:!0,shardKey:A});ie(()=>{I!==void 0&&j()},[I]);const C=t.filter(v=>v.level==="error"),$=C.slice(0,Fe),R=Be(n?.history),q=We(u),Q=x.filter(v=>v.calls>0).toSorted((v,N)=>N.errors/N.calls-v.errors/v.calls||N.calls-v.calls).slice(0,De),M=Ve(w),P=n===null||n.requests===0?0:n.errors/n.requests,L=oe(P,me,he),O=u===null?"ok":oe(u.failureRate,je,Ue),G=h===null?"ok":$e(h.backlog,Pe,Ge),B=ze([L,O,G,M.level]);return m("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[a(Je,{errorLevel:L,liveError:U,metricsError:d,overall:B,requestSeries:R.requests,totals:n}),m("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[a(ee,{chart:R.errors.length>=2?a(ne,{ariaLabel:l("Errors over time"),className:"h-7 w-20 text-destructive",series:R.errors,testId:"hl-spark-errors"}):void 0,label:l("Error rate"),level:L,testId:"hl-slo-errorrate",value:n===null?"—":re(n.errors,n.requests)}),a(ee,{chart:q.failures.length>=2?a(ne,{ariaLabel:l("Auth failures over time"),className:"h-7 w-20 text-destructive",series:q.failures,testId:"hl-spark-auth"}):void 0,label:l("Auth failures"),level:O,testId:"hl-slo-auth",value:u===null?"—":re(u.failures,u.attempts)}),a(ee,{label:l("Scheduler backlog"),level:G,testId:"hl-slo-backlog",value:h===null?"—":h.backlog.toString()}),a(ee,{label:l("Migrations"),level:M.level,testId:"hl-slo-migrations",value:He(M,l)})]}),a(_e,{errorCount:C.length,logsError:c,topErrors:$,worstFunctions:Q}),a(Ye,{shards:S})]})};function Ze(s){return a("li",{"data-testid":"hl-shard",children:a(te,{variant:"secondary",children:s})},s)}export{gt as HealthPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as X}from"react/compiler-runtime";import{useNavigate as se}from"@tanstack/react-router";import{useState as L,useRef as ae,useEffectEvent as Q,useEffect as z,useCallback as re,useMemo as N}from"react";import{ShardInput as oe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as ie}from"../packem_shared/button-q0UYSmrn.mjs";import{u as B}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as ce}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as le}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as w}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as k,d as E,c as M,n as de}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as ue}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{a as G,A as fe}from"../packem_shared/advisor-view-fNcNYW2Q.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{jsx as v,jsxs as he}from"react/jsx-runtime";import{deriveInsights as pe}from"../packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{runAdvisor as be,RUNTIME_LINTS as xe}from"@lunora/advisor";const ye=t=>{const{suggestedIndex:e,table:a}=t;if(typeof a!="string"||a.length===0||typeof e!="object"||e===null)return!1;const{fields:n,name:s}=e;return!Array.isArray(n)||n.length===0||n.some(i=>typeof i!="string"||i.length===0)?!1:typeof s=="string"&&s.length>0},ge=(t,e)=>`.index(${JSON.stringify(t)}, [${e.map(a=>JSON.stringify(a)).join(", ")}])`,ve=t=>{const e=X(19),{fields:a,indexName:n,table:s,testId:i}=t,l=K(),[f,d]=L(null);let m;e[0]!==a||e[1]!==n?(m=()=>{const b=ge(n,a),I="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(I===void 0){d({copied:!1,declaration:b});return}k(I.writeText(b).then(()=>(d({copied:!0,declaration:b}),!0)),()=>{d({copied:!1,declaration:b})})},e[0]=a,e[1]=n,e[2]=m):m=e[2];const S=m;if(f!==null){let b;return e[3]!==f.copied||e[4]!==f.declaration||e[5]!==l||e[6]!==s||e[7]!==i?(b=f.copied?v("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:l("Index declaration copied — add it to {table} in lunora/schema.ts.",{table:s})}):he("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[l("Could not reach the clipboard — add this to {table} in lunora/schema.ts:",{table:s}),v("code",{className:"font-mono break-all select-all",children:f.declaration})]}),e[3]=f.copied,e[4]=f.declaration,e[5]=l,e[6]=s,e[7]=i,e[8]=b):b=e[8],b}let u;e[9]!==l?(u=l("Copy?"),e[9]=l,e[10]=u):u=e[10];let h;e[11]!==l||e[12]!==s?(h=l("Copy index declaration for {table}",{table:s}),e[11]=l,e[12]=s,e[13]=h):h=e[13];let y;return e[14]!==S||e[15]!==u||e[16]!==h||e[17]!==i?(y=v(me,{confirmLabel:u,onConfirm:S,testId:i,children:h}),e[14]=S,e[15]=u,e[16]=h,e[17]=i,e[18]=y):y=e[18],y},Se=(t,e)=>{const a=new Map;for(const n of e){const s=`${n.table} ${n.index}`;a.set(s,(a.get(s)??0)+n.reads)}return t.map(n=>({index:n.index,reads:a.get(`${n.table} ${n.index}`)??0,table:n.table}))},Te=t=>{const e=new Map;for(const a of t)for(const n of a.scannedTables??[])e.set(n.table,(e.get(n.table)??0)+n.scans);return[...e].map(([a,n])=>({scans:n,table:a}))},P=(t,e)=>e.map(a=>({index:a.name,table:t})),we=t=>{const e=Se(t.declaredIndexes??[],t.indexHits??[]),a=Te(t.functions??[]),n=t.shardTraffic??[],s=t.analyticsMetrics,i=s&&s.indexHits.length>0?s.indexHits:e,l=s&&s.tableScans.length>0?s.tableScans:a,f=s&&s.shardTraffic.length>0?s.shardTraffic:n,d=be({indexHits:i,schema:{tables:[]},shardTraffic:f,tableScans:l},{lints:xe,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?d:d.filter(u=>!(u.metadata.kind==="hot_scan"&&typeof u.metadata.table=="string"&&m.has(u.metadata.table)))).map(u=>G(u))},Ie=M(w.listTables),$e=M(w.listTableIndexes),Ae=M(w.listTablesIndexes),H=t=>`${(t*100).toFixed(1)}%`,V=t=>`${(t/1e3).toFixed(2)}s`,Ne=t=>{if(t.length<=1)return t[0]??"";const e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},ke=(t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],U=(t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:H(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict — consider sharding to cut contention.",{rate:H(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:H(e.value)}),"missing-index":t("Slowest call took {duration} — it full-scanned {tables} with no index.",{duration:V(e.value),tables:Ne(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:V(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling — plan a .shardBy() migration while it still has runway.",{size:de(e.value)})})[e.kind],Be=t=>{const e=X(10),{onJump:a,table:n}=t,s=K();let i;e[0]!==a||e[1]!==n?(i=()=>{a(n)},e[0]=a,e[1]=n,e[2]=i):i=e[2];const l=i,f=`in-add-index-${n}`;let d;e[3]!==s||e[4]!==n?(d=s("Add index on {table}",{table:n}),e[3]=s,e[4]=n,e[5]=d):d=e[5];let m;return e[6]!==l||e[7]!==f||e[8]!==d?(m=v(ie,{"data-testid":f,onClick:l,size:"sm",type:"button",variant:"outline",children:d}),e[6]=l,e[7]=f,e[8]=d,e[9]=m):m=e[9],m},Ue=({initialShardKey:t,loadShardTraffic:e})=>{const a=le(),n=se(),s=K(),{queryShardKey:i,setShardKey:l,shardKey:f}=ce(t),[d,m]=L(null),[S,u]=L(null),h=ae(""),y=B(w.getMetrics,{},{live:!0,shardKey:i}),b=B(w.getFunctionStats,{},{live:!0,shardKey:i}),I=B(w.getAdvisories,{},{live:!0,shardKey:i}),C=y.data??null,$=b.data?.functions??null,D=I.data?.advisories??null,R=y.data?.indexHits??null,j=y.error!==null&&b.error!==null?y.error:null,W=e??(r=>a.shardTraffic(r)),Y=async(r,x)=>{const g=r[0];if(g===void 0||g===""){h.current===x&&u(null);return}try{const o=await W(g);if(h.current!==x)return;const c=new Map;for(const p of o.shards)c.has(p.shardKey)||c.set(p.shardKey,{requests:p.requests,shardKey:p.shardKey});u([...c.values()])}catch{h.current===x&&u(null)}},Z=async(r,x)=>{const g=await Promise.allSettled(r.map(async c=>[c,await a.query($e,{table:c},E(x))])),o=[];for(const c of g)if(c.status==="fulfilled"){const[p,T]=c.value;o.push(...P(p,T.indexes))}return o},F=Q(async r=>{h.current=r;let x=[];try{const g=await a.query(Ie,{},E(r));if(h.current!==r)return;ue(r),x=g.map(c=>c.name);let o=[];if(x.length>0)try{const c=await a.query(Ae,{tables:x},E(r));if(h.current!==r)return;for(const[p,T]of Object.entries(c.indexesByTable))o.push(...P(p,T))}catch{if(o=await Z(x,r),h.current!==r)return}m(o)}catch{h.current===r&&m(null)}await Y(x,r)});z(()=>{k(F(i))},[i]);const _=Q(()=>{y.refetch(),b.refetch(),I.refetch(),k(F(i))});z(()=>{const r=()=>{document.visibilityState==="visible"&&_()};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);const O=re(r=>{k(n({search:{table:r},to:"/schema"}))},[n]),A=N(()=>pe(C,$),[$,C]),q=N(()=>new Set(A.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[A]),J=N(()=>we({declaredIndexes:d??[],functions:$,indexHits:R,shardTraffic:S,suppressHotScanTables:q}),[d,$,R,q,S]),ee=N(()=>{const r=A.map(o=>{const c=o.kind==="missing-index"?o.tables??[]:[];return{action:c.length>0?c.map(p=>v(Be,{onJump:O,table:p},p)):void 0,description:o.message===void 0?U(s,o):`${U(s,o)} — ${o.message}`,entity:o.fn,issueType:ke(s,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(D??[]).map(o=>{const c=G(o);if(x.has(o.name)&&ye(o.metadata)){const{table:p,suggestedIndex:T}=o.metadata,ne=`in-apply-index-${p}-${T.name}`;return{...c,action:v(ve,{fields:T.fields,indexName:T.name,table:p,testId:ne})}}return c}),...J,...r]},[D,A,O,J,s]),te=v(oe,{onChange:l,testId:"in-shard-input",value:f});return v(fe,{error:j,errorSource:j===null?void 0:y.errorSource,rows:ee,testId:"lunora-insights",toolbar:te})};export{Ue as InsightsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as q}from"react/compiler-runtime";import{useVirtualizer as Ce}from"@tanstack/react-virtual";import{useState as F,useReducer as Le,useRef as ue,useEffect as me,useMemo as Ne}from"react";import{f as fe}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{E as Se}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as he}from"../packem_shared/badge-r_5B4LHP.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as le}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as Te}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as Ie}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as Re}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as ke}from"../packem_shared/virtual-rect-D_j7aLxX.mjs";import{B as Pe}from"../packem_shared/button-q0UYSmrn.mjs";import{I as D}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Oe,b as ge,c as B,d as _e,e as V}from"../packem_shared/table-D0SBiDu-.mjs";import ae from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as Fe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{a as pe}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{f as ne,j as qe,b as ie}from"../packem_shared/internal-BXEjuLPN.mjs";import{a as Ae,L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{jsx as r,jsxs as E,Fragment as $e}from"react/jsx-runtime";import{c as H}from"../packem_shared/utils-bhneXptQ.mjs";import{L as Ue}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as Ke}from"../packem_shared/ShardInput-CoySruKZ.mjs";const re=["trace","debug","log","info","warn","error","fatal"],Be="LOG_ARCHIVE_NOT_CONFIGURED",Ve={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=(i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},Qe=i=>{const e=q(33),{row:t}=i;let a;e[0]!==t.fields?(a=fe(t.fields),e[0]=t.fields,e[1]=a):a=e[1];const n=a,o=`lg-archive-row-${String(t.ts)}`;let d;e[2]!==t.ts?(d=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=d):d=e[3];let p;e[4]!==d?(p=r(V,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:d}),e[4]=d,e[5]=p):p=e[5];const m=Ae[t.level];let c;e[6]!==t.level||e[7]!==m?(c=r(V,{children:r(he,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=c):c=e[8];let s;e[9]!==t.functionPath?(s=r(V,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=s):s=e[10];let f;e[11]!==t.message?(f=r("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=f):f=e[12];let l;e[13]!==n?(l=n!==""&&r("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n,children:n}),e[13]=n,e[14]=l):l=e[14];let u;e[15]!==f||e[16]!==l?(u=E(V,{className:"max-w-md",children:[f,l]}),e[15]=f,e[16]=l,e[17]=u):u=e[17];const h=t.traceId??"—";let v;e[18]!==h?(v=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:h}),e[18]=h,e[19]=v):v=e[19];const b=t.shardKey??"—";let y;e[20]!==b?(y=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:b}),e[20]=b,e[21]=y):y=e[21];const w=t.userId??"—";let x;e[22]!==w?(x=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[22]=w,e[23]=x):x=e[23];let T;return e[24]!==u||e[25]!==v||e[26]!==y||e[27]!==x||e[28]!==o||e[29]!==p||e[30]!==c||e[31]!==s?(T=E(ge,{"data-testid":o,children:[p,c,s,u,v,y,x]}),e[24]=u,e[25]=v,e[26]=y,e[27]=x,e[28]=o,e[29]=p,e[30]=c,e[31]=s,e[32]=T):T=e[32],T},ze=({shardKey:i})=>{const e=Fe(),t=Q(),[a,n]=F(""),[o,d]=F(""),[p,m]=F(""),[{cursor:c,error:s,loading:f,notConfigured:l,rows:u},h]=Le(De,Ve),v=ae(a.trim(),400),b=ae(o.trim(),400),y={...v===""?{}:{functionPathPrefix:v},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...b===""?{}:{userId:b}},w=JSON.stringify(y),x=ue(w);me(()=>{const g={cancelled:!1};return x.current=w,ne((async()=>{h({type:"loading"});try{const C=await e.queryLogArchive(y);g.cancelled||h({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){g.cancelled||h(qe(C)===Be?{type:"notConfigured"}:{message:ie(C),type:"failed"})}})()),()=>{g.cancelled=!0}},[e,w]);const T=async()=>{if(c===void 0)return;const g=w;h({type:"loading"});try{const C=await e.queryLogArchive({...y,cursor:c});x.current===g&&h({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){x.current===g&&h({message:ie(C),type:"pageFailed"})}},R=g=>{n(g.target.value)},N=g=>{d(g.target.value)},L=g=>{m(g.target.value)},S=()=>{ne(T())};return l?r(ee,{action:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:pe,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline → R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):E("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[E("div",{className:"flex flex-wrap items-center gap-2",children:[r(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path…"),value:a}),r(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:N,placeholder:t("user id…"),value:o}),E("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:L,value:p,children:[r("option",{value:"",children:t("min level")}),re.map(g=>r("option",{value:g,children:g},g))]})]}),s!==null&&r("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:s}),f&&u===null&&s===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading…")}),u!==null&&u.length===0&&r(ee,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&r("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:E(Ee,{"data-testid":"lg-archive-table",children:[r(Oe,{children:E(ge,{children:[r(B,{children:t("Time")}),r(B,{children:t("Level")}),r(B,{children:t("Function")}),r(B,{children:t("Message")}),r(B,{children:t("Trace")}),r(B,{children:t("Shard")}),r(B,{children:t("User")})]})}),r(_e,{children:u.map((g,C)=>r(Qe,{row:g},`${String(g.ts)}-${String(C)}`))})]})}),c!==void 0&&r("div",{children:r(Pe,{"data-testid":"lg-archive-more",disabled:f,onClick:S,size:"sm",variant:"outline",children:t(f?"Loading…":"Load more")})})]})},Ge=i=>{const e=q(11),{level:t,onToggle:a,selected:n}=i;let o;e[0]!==t||e[1]!==a?(o=()=>{a(t)},e[0]=t,e[1]=a,e[2]=o):o=e[2];const d=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground";let m;e[3]!==p?(m=H("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];const c=`logs-level-${t}`;let s;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==m||e[9]!==c?(s=r("button",{"aria-pressed":n,className:m,"data-testid":c,onClick:d,type:"button",children:t}),e[5]=t,e[6]=d,e[7]=n,e[8]=m,e[9]=c,e[10]=s):s=e[10],s},He=i=>{const e=q(68),{levelFilter:t,onLogPathChange:a,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:d,onToggleSummary:p,pathFilter:m,search:c,showSummary:s,timeRange:f}=i,l=Q();let u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==l?(h=l("search message"),e[2]=l,e[3]=h):h=e[3];let v;e[4]!==n||e[5]!==c||e[6]!==u||e[7]!==h?(v=r(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:h,value:c}),e[4]=n,e[5]=c,e[6]=u,e[7]=h,e[8]=v):v=e[8];let b;e[9]!==l?(b=l("Function path"),e[9]=l,e[10]=b):b=e[10];let y;e[11]!==l?(y=l("filter path"),e[11]=l,e[12]=y):y=e[12];let w;e[13]!==a||e[14]!==m||e[15]!==b||e[16]!==y?(w=r(D,{"aria-label":b,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:a,placeholder:y,value:m}),e[13]=a,e[14]=m,e[15]=b,e[16]=y,e[17]=w):w=e[17];let x;e[18]!==l?(x=l("Level filter"),e[18]=l,e[19]=x):x=e[19];let T;e[20]!==t||e[21]!==d?(T=re.map(G=>r(Ge,{level:G,onToggle:d,selected:t.has(G)},G)),e[20]=t,e[21]=d,e[22]=T):T=e[22];let R;e[23]!==x||e[24]!==T?(R=r("div",{"aria-label":x,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=x,e[24]=T,e[25]=R):R=e[25];let N;e[26]!==l?(N=l("Time range"),e[26]=l,e[27]=N):N=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=r("option",{value:"all",children:L}),e[30]=L,e[31]=S):S=e[31];let g;e[32]!==l?(g=l("Last 5m"),e[32]=l,e[33]=g):g=e[33];let C;e[34]!==g?(C=r("option",{value:"5m",children:g}),e[34]=g,e[35]=C):C=e[35];let k;e[36]!==l?(k=l("Last 15m"),e[36]=l,e[37]=k):k=e[37];let P;e[38]!==k?(P=r("option",{value:"15m",children:k}),e[38]=k,e[39]=P):P=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let _;e[42]!==O?(_=r("option",{value:"1h",children:O}),e[42]=O,e[43]=_):_=e[43];let A;e[44]!==o||e[45]!==N||e[46]!==S||e[47]!==C||e[48]!==P||e[49]!==_||e[50]!==f?(A=E("select",{"aria-label":N,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:f,children:[S,C,P,_]}),e[44]=o,e[45]=N,e[46]=S,e[47]=C,e[48]=P,e[49]=_,e[50]=f,e[51]=A):A=e[51];const z=s?"border-border bg-muted font-medium":"border-input text-muted-foreground";let M;e[52]!==z?(M=H("h-8 rounded-md border px-3 text-sm",z),e[52]=z,e[53]=M):M=e[53];let U;e[54]!==s||e[55]!==l?(U=l(s?"List":"Summary"),e[54]=s,e[55]=l,e[56]=U):U=e[56];let $;e[57]!==p||e[58]!==s||e[59]!==M||e[60]!==U?($=r("button",{"aria-pressed":s,className:M,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=s,e[59]=M,e[60]=U,e[61]=$):$=e[61];let K;return e[62]!==A||e[63]!==$||e[64]!==v||e[65]!==w||e[66]!==R?(K=E("div",{className:"flex flex-wrap items-center gap-2",children:[v,w,R,A,$]}),e[62]=A,e[63]=$,e[64]=v,e[65]=w,e[66]=R,e[67]=K):K=e[67],K},We=i=>{const e=q(53),{onOutcomeChange:t,onPathChange:a,onTableChange:n,onUserChange:o,outcomeFilter:d,pathPrefix:p,tableFilter:m,userIdFilter:c}=i,s=Q();let f;e[0]!==s?(f=s("Function path"),e[0]=s,e[1]=f):f=e[1];let l;e[2]!==s?(l=s("file:function"),e[2]=s,e[3]=l):l=e[3];let u;e[4]!==a||e[5]!==p||e[6]!==f||e[7]!==l?(u=r(D,{"aria-label":f,className:"h-8 w-44","data-testid":"lg-req-path",onChange:a,placeholder:l,value:p}),e[4]=a,e[5]=p,e[6]=f,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==s?(h=s("User id"),e[9]=s,e[10]=h):h=e[10];let v;e[11]!==s?(v=s("userId"),e[11]=s,e[12]=v):v=e[12];let b;e[13]!==o||e[14]!==h||e[15]!==v||e[16]!==c?(b=r(D,{"aria-label":h,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:v,value:c}),e[13]=o,e[14]=h,e[15]=v,e[16]=c,e[17]=b):b=e[17];let y;e[18]!==s?(y=s("Table touched"),e[18]=s,e[19]=y):y=e[19];let w;e[20]!==s?(w=s("table"),e[20]=s,e[21]=w):w=e[21];let x;e[22]!==n||e[23]!==y||e[24]!==w||e[25]!==m?(x=r(D,{"aria-label":y,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:w,value:m}),e[22]=n,e[23]=y,e[24]=w,e[25]=m,e[26]=x):x=e[26];let T;e[27]!==s?(T=s("Outcome filter"),e[27]=s,e[28]=T):T=e[28];let R;e[29]!==s?(R=s("all"),e[29]=s,e[30]=R):R=e[30];let N;e[31]!==R?(N=r("option",{value:"all",children:R}),e[31]=R,e[32]=N):N=e[32];let L;e[33]!==s?(L=s("ok"),e[33]=s,e[34]=L):L=e[34];let S;e[35]!==L?(S=r("option",{value:"ok",children:L}),e[35]=L,e[36]=S):S=e[36];let g;e[37]!==s?(g=s("error"),e[37]=s,e[38]=g):g=e[38];let C;e[39]!==g?(C=r("option",{value:"error",children:g}),e[39]=g,e[40]=C):C=e[40];let k;e[41]!==t||e[42]!==d||e[43]!==T||e[44]!==N||e[45]!==S||e[46]!==C?(k=E("select",{"aria-label":T,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:d,children:[N,S,C]}),e[41]=t,e[42]=d,e[43]=T,e[44]=N,e[45]=S,e[46]=C,e[47]=k):k=e[47];let P;return e[48]!==k||e[49]!==u||e[50]!==b||e[51]!==x?(P=E("div",{className:"flex flex-wrap items-center gap-2",children:[u,b,x,k]}),e[48]=k,e[49]=u,e[50]=b,e[51]=x,e[52]=P):P=e[52],P},ve=i=>{const e=q(7),{bucket:t}=i;let a;e[0]!==t.key?(a=r("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=a):a=e[1];let n;e[2]!==t.count?(n=r("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==a||e[5]!==n?(o=E("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[a,n]}),e[4]=a,e[5]=n,e[6]=o):o=e[6],o},Ye=i=>{const e=q(31),{summary:t}=i,a=Q();let n;e[0]!==t.total||e[1]!==a?(n=a("{count} entries",{count:t.total}),e[0]=t.total,e[1]=a,e[2]=n):n=e[2];let o;e[3]!==n?(o=r("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let d;e[5]!==a?(d=a("By level"),e[5]=a,e[6]=d):d=e[6];let p;e[7]!==d?(p=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d}),e[7]=d,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(je),e[9]=t.byLevel,e[10]=m):m=e[10];let c;e[11]!==m?(c=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=c):c=e[12];let s;e[13]!==p||e[14]!==c?(s=E("div",{children:[p,c]}),e[13]=p,e[14]=c,e[15]=s):s=e[15];let f;e[16]!==a?(f=a("By function"),e[16]=a,e[17]=f):f=e[17];let l;e[18]!==f?(l=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f}),e[18]=f,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(Je),e[20]=t.byPath,e[21]=u):u=e[21];let h;e[22]!==u?(h=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=h):h=e[23];let v;e[24]!==h||e[25]!==l?(v=E("div",{children:[l,h]}),e[24]=h,e[25]=l,e[26]=v):v=e[26];let b;return e[27]!==v||e[28]!==o||e[29]!==s?(b=E("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,s,v]}),e[27]=v,e[28]=o,e[29]=s,e[30]=b):b=e[30],b};function je(i){return r(ve,{bucket:i},i.key)}function Je(i){return r(ve,{bucket:i},i.key)}const Xe=i=>{const e=q(46),{liveError:t,onShardKeyChange:a,onShowArchive:n,onShowErrors:o,onShowRequests:d,shardKey:p,view:m}=i,c=Q(),s=m==="requests",f=m==="requests"?"bg-muted font-medium":"text-muted-foreground";let l;e[0]!==f?(l=H("px-3 py-1 text-sm",f),e[0]=f,e[1]=l):l=e[1];let u;e[2]!==c?(u=c("Requests"),e[2]=c,e[3]=u):u=e[3];let h;e[4]!==d||e[5]!==s||e[6]!==l||e[7]!==u?(h=r("button",{"aria-selected":s,className:l,"data-testid":"lg-view-requests",onClick:d,role:"tab",type:"button",children:u}),e[4]=d,e[5]=s,e[6]=l,e[7]=u,e[8]=h):h=e[8];const v=m==="errors",b=m==="errors"?"bg-muted font-medium":"text-muted-foreground";let y;e[9]!==b?(y=H("px-3 py-1 text-sm",b),e[9]=b,e[10]=y):y=e[10];let w;e[11]!==c?(w=c("Errors"),e[11]=c,e[12]=w):w=e[12];let x;e[13]!==o||e[14]!==v||e[15]!==y||e[16]!==w?(x=r("button",{"aria-selected":v,className:y,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:w}),e[13]=o,e[14]=v,e[15]=y,e[16]=w,e[17]=x):x=e[17];const T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground";let N;e[18]!==R?(N=H("px-3 py-1 text-sm",R),e[18]=R,e[19]=N):N=e[19];let L;e[20]!==c?(L=c("Archive"),e[20]=c,e[21]=L):L=e[21];let S;e[22]!==n||e[23]!==T||e[24]!==N||e[25]!==L?(S=r("button",{"aria-selected":T,className:N,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:L}),e[22]=n,e[23]=T,e[24]=N,e[25]=L,e[26]=S):S=e[26];let g;e[27]!==x||e[28]!==S||e[29]!==h?(g=E("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[h,x,S]}),e[27]=x,e[28]=S,e[29]=h,e[30]=g):g=e[30];let C;e[31]!==a||e[32]!==p?(C=r(Ke,{onChange:a,testId:"lg-shard-input",value:p}),e[31]=a,e[32]=p,e[33]=C):C=e[33];let k;e[34]!==t||e[35]!==m?(k=m!=="archive"&&r(Ue,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=k):k=e[36];let P;e[37]!==c?(P=c("Open in Cloudflare"),e[37]=c,e[38]=P):P=e[38];let O;e[39]!==P?(O=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:pe,rel:"noreferrer",target:"_blank",children:P}),e[39]=P,e[40]=O):O=e[40];let _;return e[41]!==g||e[42]!==C||e[43]!==k||e[44]!==O?(_=E("div",{className:"flex flex-wrap items-center gap-2",children:[g,C,k,O]}),e[41]=g,e[42]=C,e[43]=k,e[44]=O,e[45]=_):_=e[45],_},te=400,Ze=36,et={height:te,overflow:"auto"},be={left:0,position:"absolute",top:0,width:"100%"},tt={error:"destructive",ok:"secondary"},xe=i=>{const e=q(6),{onOpenTrace:t,traceId:a}=i,n=Q();let o;e[0]!==t||e[1]!==n||e[2]!==a?(o=a===void 0?null:r("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:()=>{t(a)},type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=a,e[3]=o):o=e[3];let d;return e[4]!==o?(d=r("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=d):d=e[5],d},rt=i=>{const e=q(13),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t?(s=r(Me,{entry:t}),e[2]=t,e[3]=s):s=e[3];let f;e[4]!==t.traceId||e[5]!==o?(f=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=f):f=e[6];let l;return e[7]!==a||e[8]!==n||e[9]!==c||e[10]!==s||e[11]!==f?(l=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-row",ref:n,role:"row",style:c,children:[s,f]}),e[7]=a,e[8]=n,e[9]=c,e[10]=s,e[11]=f,e[12]=l):l=e[12],l},ce=i=>i.length===0?"—":i.join(", "),st=i=>{const e=q(41),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t.ts?(s=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=s):s=e[3];let f;e[4]!==s?(f=r("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:s}),e[4]=s,e[5]=f):f=e[5];const l=tt[t.outcome];let u;e[6]!==t.outcome||e[7]!==l?(u=r("span",{className:"w-16 shrink-0",role:"gridcell",children:r(he,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==t.functionPath?(h=r("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=h):h=e[10];const v=t.shardKey??"—";let b;e[11]!==v?(b=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:v}),e[11]=v,e[12]=b):b=e[12];const y=t.userId??"—";let w;e[13]!==y?(w=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:y}),e[13]=y,e[14]=w):w=e[14];let x;e[15]!==t.durationMs?(x=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=x):x=e[16];const T=`${String(x)}ms`;let R;e[17]!==T?(R=r("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let N;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(N=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ce(t.tablesRead)} · w:${ce(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=N):N=e[23];let L;e[24]!==N?(L=r("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:N}),e[24]=N,e[25]=L):L=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let g;return e[29]!==a||e[30]!==n||e[31]!==c||e[32]!==w||e[33]!==R||e[34]!==L||e[35]!==S||e[36]!==f||e[37]!==u||e[38]!==h||e[39]!==b?(g=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-req-row",ref:n,role:"row",style:c,children:[f,u,h,b,w,R,L,S]}),e[29]=a,e[30]=n,e[31]=c,e[32]=w,e[33]=R,e[34]=L,e[35]=S,e[36]=f,e[37]=u,e[38]=h,e[39]=b,e[40]=g):g=e[40],g},de=i=>{const{entries:e}=i??{};return Array.isArray(e)?e:[]},lt=i=>{const e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},ot={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},at=(i,e)=>{const t=e.search.trim().toLowerCase(),a=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-ot[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||a!==""&&!(o.functionPath??"").toLowerCase().includes(a)?!1:t===""||o.message.toLowerCase().includes(t)||fe(o.fields).toLowerCase().includes(t))},nt="—",it=i=>{const e=new Map,t=new Map;for(const o of i){e.set(o.level,(e.get(o.level)??0)+1);const d=o.functionPath??nt;t.set(d,(t.get(d)??0)+1)}const a=re.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:a,byPath:n,total:i.length}},Wt=({initialShardKey:i})=>{const e=Q(),[t,a]=F("requests"),{queryShardKey:n,setShardKey:o,shardKey:d}=Ie(i),[p,m]=F(""),[c,s]=F(()=>new Set),[f,l]=F(""),[u,h]=F("all"),[v,b]=F(!1),[y,w]=F(""),[x,T]=F(""),[R,N]=F(""),[L,S]=F("all"),g=lt({functionPathPrefix:y,outcome:L,tableTouched:R,userId:x}),C=le(oe.getRequestLog,g,{enabled:t==="requests",live:!0,shardKey:n}),k=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),P=t==="requests"?C:k,{error:O,errorSource:_,isLoading:A,liveError:z}=P,M=Te(n),U=de(k.data),$=de(C.data);me(()=>{P.data!==void 0&&Re(n)},[P.data,n]);const K=at(U,{levels:c,now:Date.now(),path:f,range:u,search:p}),G=it(K),J=t==="requests"?$.length:K.length,X=t==="errors"&&v,W=Ne(()=>O!==null?"error":J===0?A?X?"summary":"list":"empty":X?"summary":"list",[J,A,O,X]),se=ue(null),Y=Ce({count:J,estimateSize:()=>Ze,getScrollElement:()=>se.current,initialRect:{height:te,width:800},observeElementRect:(I,Z)=>ke(I,Z,te),overscan:8}),ye=Y.getVirtualItems(),we={height:Y.getTotalSize(),position:"relative",width:"100%"};return E("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[r(Xe,{liveError:z,onShardKeyChange:o,onShowArchive:()=>{a("archive"),b(!1)},onShowErrors:()=>{a("errors"),b(!1)},onShowRequests:()=>{a("requests"),b(!1)},shardKey:d,view:t}),t==="errors"&&r(He,{levelFilter:c,onLogPathChange:I=>{l(I.target.value)},onSearchChange:I=>{m(I.target.value)},onTimeRangeChange:I=>{h(I.target.value)},onToggleLevel:I=>{s(Z=>{const j=new Set(Z);return j.has(I)?j.delete(I):j.add(I),j})},onToggleSummary:()=>{b(I=>!I)},pathFilter:f,search:p,showSummary:v,timeRange:u}),t==="requests"&&r(We,{onOutcomeChange:I=>{S(I.target.value)},onPathChange:I=>{w(I.target.value)},onTableChange:I=>{N(I.target.value)},onUserChange:I=>{T(I.target.value)},outcomeFilter:L,pathPrefix:y,tableFilter:R,userIdFilter:x}),t==="archive"?r(ze,{shardKey:n}):E($e,{children:[W==="error"&&r(Se,{error:_,testId:"lg-error"}),W==="empty"&&r(ee,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),W==="summary"&&r(Ye,{summary:G}),W==="list"&&r("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:se,style:et,children:r("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:we,children:ye.map(I=>t==="requests"?r(st,{entry:$[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key):r(rt,{entry:K[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key))})})]})]})};export{Wt as LogsPanel,at as filterLogs,it as summarizeLogs};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{E as se}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as ie}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as g}from"../packem_shared/button-q0UYSmrn.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{S as le}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as n,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as ae,d as X,b as Z,f as ee,g as he,h as te}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as pe}from"react/compiler-runtime";import{useState as F}from"react";import{u as fe}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useAutoRefresh as xe}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as be}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";function ge({className:r,orientation:e="horizontal",...i}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...i})}const ve=/https?:\/\/[^\s"'<>)]+/i,re=r=>r===void 0?void 0:ve.exec(r)?.[0],v=r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,Ne=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,we=/&(?:amp|#0*38|#x0*26);/giu,ye=r=>r===void 0?void 0:((r.html===void 0?void 0:Ne.exec(r.html)?.[1])??re(r.text)??re(r.html))?.replaceAll(we,"&"),Ce=(r,e)=>{const i=e.trim().toLowerCase();return i===""?r:r.filter(o=>`${o.subject} ${v(o.to)} ${v(o.cc)}`.toLowerCase().includes(i))},Se=(r,e)=>{if(r.length!==0)return r.find(i=>i.id===e)??r[0]},Te=ae(J.clearCapturedMail),ke=ae(J.sendTestMail),Ae=r=>{const e=pe(36),{limit:i}=r,o=be();let p;e[0]!==i?(p={limit:i},e[0]=i,e[1]=p):p=e[1];const{data:P,error:N,errorSource:w,isLoading:b,poll:R,refetch:m}=fe(J.getCapturedMail,p),[y,f]=F(null),[O,C]=F(null),[s,h]=F("html"),[x,H]=F(""),a=P?.entries??[],u=N??y,B=N===null?y:w;let S;e[2]!==o||e[3]!==m?(S=async()=>{f(null);try{await o.query(Te,{},X("")),C(null),m()}catch(d){f(Z(d))}},e[2]=o,e[3]=m,e[4]=S):S=e[4];const D=S;let T;e[5]!==o||e[6]!==m?(T=async()=>{f(null);try{await o.query(ke,{},X("")),m()}catch(d){f(Z(d))}},e[5]=o,e[6]=m,e[7]=T):T=e[7];const q=T;xe(R,!0);let k;e[8]!==D?(k=()=>{ee(D())},e[8]=D,e[9]=k):k=e[9];const U=k;let A;e[10]!==q?(A=()=>{ee(q())},e[10]=q,e[11]=A):A=e[11];const W=A;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=d=>{H(d.currentTarget.value)},e[12]=E):E=e[12];const K=E;let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=d=>{const{id:c}=d.currentTarget.dataset;c!==void 0&&C(c)},e[13]=_):_=e[13];const Q=_;let L;e[14]===Symbol.for("react.memo_cache_sentinel")?(L=d=>{const c=d.currentTarget.dataset.tab;(c==="headers"||c==="html"||c==="text")&&h(c)},e[14]=L):L=e[14];const V=L,M=Ce(a,x),I=Se(M,O),l=ye(I);let j;e[15]!==l?(j=()=>{l!==void 0&&he(l)},e[15]=l,e[16]=j):j=e[16];const Y=j;let $;e[17]!==l?($=()=>{l!==void 0&&"window"in globalThis&&globalThis.window.open(l,"_blank","noopener")},e[17]=l,e[18]=$):$=e[18];const G=$;let z;return e[19]!==a||e[20]!==u||e[21]!==B||e[22]!==x||e[23]!==b||e[24]!==l||e[25]!==U||e[26]!==Y||e[27]!==K||e[28]!==G||e[29]!==Q||e[30]!==V||e[31]!==W||e[32]!==I||e[33]!==s||e[34]!==M?(z={entries:a,error:u,errorSource:B,filter:x,isLoading:b,link:l,onClear:U,onCopyLink:Y,onFilterChange:K,onOpenLink:G,onSelectMessage:Q,onSelectTab:V,onSendTest:W,selected:I,tab:s,visible:M},e[19]=a,e[20]=u,e[21]=B,e[22]=x,e[23]=b,e[24]=l,e[25]=U,e[26]=Y,e[27]=K,e[28]=G,e[29]=Q,e[30]=V,e[31]=W,e[32]=I,e[33]=s,e[34]=M,e[35]=z):z=e[35],z},Ee=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=r=>`${Ee}${r}`,Qe=({limit:r=100})=>{const e=ue(),{entries:i,error:o,errorSource:p,filter:P,isLoading:N,link:w,onClear:b,onCopyLink:R,onFilterChange:m,onOpenLink:y,onSelectMessage:f,onSelectTab:O,onSendTest:C,selected:s,tab:h,visible:x}=Ae({limit:r}),H=a=>e(a==="html"?"HTML":a==="text"?"Plain text":"Headers");return n("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(g,{"data-testid":"mail-send-test",onClick:C,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(g,{"data-testid":"mail-clear",disabled:i.length===0,onClick:b,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),i.length>0&&t(ie,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:i.length})})]}),o!==null&&t(se,{error:p,testId:"mail-error"}),o===null&&!N&&i.length===0&&t(oe,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),i.length>0&&n("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[n("div",{className:"flex flex-col gap-2",children:[t(ne,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:m,placeholder:e("Filter messages"),type:"search",value:P}),t(le,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:x.map(a=>{const u=a.id===s?.id;return t("li",{children:n("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":a.id,"data-testid":"mail-list-item",onClick:f,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:a.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:v(a.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(a.capturedAt,"—")})]})},a.id)})})})]}),s!==void 0&&n("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:s.subject||e("(no subject)")}),n("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:s.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:v(s.to)}),s.cc!==void 0&&s.cc.length>0&&n(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:v(s.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(s.capturedAt,"—")})]})]}),n("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(g,{"data-testid":"mail-copy-link",disabled:w===void 0,onClick:R,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(g,{"data-testid":"mail-open-link",disabled:w===void 0,onClick:y,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(ge,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(a=>t(g,{"aria-selected":h===a,"data-tab":a,"data-testid":`mail-tab-${a}`,onClick:O,role:"tab",size:"sm",type:"button",variant:h===a?"secondary":"ghost",children:H(a)},a))}),n("div",{className:"min-h-[12rem]",children:[h==="html"&&(s.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(s.html),title:e("Email preview")})),h==="text"&&(s.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:s.text})),h==="headers"&&(s.headers===void 0||Object.keys(s.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(s.headers).map(([a,u])=>`${a}: ${u}`).join(`
|
|
2
|
+
`)}))]})]})]})]})};export{Qe as MailPanel};
|