@lunora/studio 1.0.0-alpha.8 → 1.0.0-alpha.80
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/dist/index.d.ts +777 -780
- package/dist/index.js +1 -41
- package/dist/mount.d.ts +10 -10
- package/dist/mount.js +1 -26
- package/dist/packem_chunks/ApiTab.js +1 -0
- package/dist/packem_chunks/AuditPanel.js +1 -0
- package/dist/packem_chunks/DeploymentHealthPanel.js +1 -0
- package/dist/packem_chunks/ExportImportPanel.js +3 -0
- package/dist/packem_chunks/FileBrowser.js +4 -0
- package/dist/packem_chunks/FunctionRunner.js +1 -0
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -0
- package/dist/packem_chunks/HealthPanel.js +1 -0
- package/dist/packem_chunks/InsightsPanel.js +1 -0
- package/dist/packem_chunks/LogsPanel.js +1 -0
- package/dist/packem_chunks/MailPanel.js +2 -0
- package/dist/packem_chunks/MetricsPanel.js +1 -0
- package/dist/packem_chunks/NotificationsPanel.js +1 -0
- package/dist/packem_chunks/PitrPanel.js +1 -0
- package/dist/packem_chunks/SchemaViewer.js +1 -0
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -0
- package/dist/packem_chunks/SettingsPanel.js +1 -0
- package/dist/packem_chunks/SqlEditorPanel.js +6 -0
- package/dist/packem_chunks/TableEditor.js +1 -0
- package/dist/packem_chunks/agents-panel.js +1 -0
- package/dist/packem_chunks/analytics-panel.js +1 -0
- package/dist/packem_chunks/auth-audit-panel.js +1 -0
- package/dist/packem_chunks/auth-config-panel.js +1 -0
- package/dist/packem_chunks/auth-sessions-panel.js +1 -0
- package/dist/packem_chunks/containers-panel.js +1 -0
- package/dist/packem_chunks/dashboards-panel.js +1 -0
- package/dist/packem_chunks/fanout-panel.js +1 -0
- package/dist/packem_chunks/flags-panel.js +1 -0
- package/dist/packem_chunks/issues-panel.js +1 -0
- package/dist/packem_chunks/kv-browser.js +1 -0
- package/dist/packem_chunks/log-drains-panel.js +4 -0
- package/dist/packem_chunks/migrations-route.js +1 -0
- package/dist/packem_chunks/organizations-panel.js +1 -0
- package/dist/packem_chunks/payments-panel.js +1 -0
- package/dist/packem_chunks/permissions-panel.js +1 -0
- package/dist/packem_chunks/queues-panel.js +1 -0
- package/dist/packem_chunks/rls-panel.js +1 -0
- package/dist/packem_chunks/schedule-panel.js +1 -0
- package/dist/packem_chunks/sparkline.js +1 -0
- package/dist/packem_chunks/storage-rules-panel.js +1 -0
- package/dist/packem_chunks/subscriptions-panel.js +1 -0
- package/dist/packem_chunks/sync-client-panel.js +1 -0
- package/dist/packem_chunks/traces-panel.js +1 -0
- package/dist/packem_chunks/users-panel.js +1 -0
- package/dist/packem_chunks/vector-browser.js +1 -0
- package/dist/packem_chunks/workflows-panel.js +1 -0
- package/dist/packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js +1 -0
- package/dist/packem_shared/ApiDocsPanel-DfUQ1ZAF.js +2 -0
- package/dist/packem_shared/ApiReferencePanel-9q8BbJl-.js +1 -0
- package/dist/packem_shared/CommandPalette--SQwfTW1.js +1 -0
- package/dist/packem_shared/ConfirmButton-CTL3f3kr.js +1 -0
- package/dist/packem_shared/ConnectionBadge-DOk0CQWo.js +1 -0
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js +1 -0
- package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js +1 -0
- package/dist/packem_shared/DEFAULT_LOCALE-BZ4NojpD.js +1 -0
- package/dist/packem_shared/DataBrowser-CuRlztBz.js +1 -0
- package/dist/packem_shared/DataFilters-B26ZeqBZ.js +1 -0
- package/dist/packem_shared/ErrorBoundary-DvzYskH7.js +1 -0
- package/dist/packem_shared/GlobalDataBrowser-DB-vQ2_H.js +1 -0
- package/dist/packem_shared/HomePanel-Dcs4a3Ax.js +1 -0
- package/dist/packem_shared/MigrationsPanel-C2OnsqRb.js +1 -0
- package/dist/packem_shared/OpenRpcReferencePanel-qOZcWXMs.js +1 -0
- package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js +1 -0
- package/dist/packem_shared/ScheduledJobs-D8kBZWBu.js +1 -0
- package/dist/packem_shared/ShardInput-BVn2iCU0.js +1 -0
- package/dist/packem_shared/Studio-B26_pT8J.js +1 -0
- package/dist/packem_shared/StudioApp-bXhJeLlZ.js +1 -0
- package/dist/packem_shared/StudioI18nProvider-CZ5h4nrV.js +1 -0
- package/dist/packem_shared/advisor-view-Pa8HLtBv.js +1 -0
- package/dist/packem_shared/aggregateMetrics-BNfajLa2.js +1 -0
- package/dist/packem_shared/alert-CVcOFuDR.js +1 -0
- package/dist/packem_shared/app.d-DW7yZsfu.d.ts +252 -0
- package/dist/packem_shared/badge-BbuuAio7.js +1 -0
- package/dist/packem_shared/bar-chart-DraN_srt.js +9 -0
- package/dist/packem_shared/browser-storage-xjTyMKY0.js +1 -0
- package/dist/packem_shared/button-BkCrNcAs.js +1 -0
- package/dist/packem_shared/card-CIDGUN6K.js +1 -0
- package/dist/packem_shared/cf-links-gbDy51nR.js +1 -0
- package/dist/packem_shared/checkbox-StT4Gob6.js +1 -0
- package/dist/packem_shared/data-grid-DcxyIXwG.js +1 -0
- package/dist/packem_shared/data-view-params-ClrV7XgF.js +1 -0
- package/dist/packem_shared/dropdown-menu-C3RQ_HlW.js +2 -0
- package/dist/packem_shared/empty-state-Cg7t_8qu.js +1 -0
- package/dist/packem_shared/error-alert-t6cpEi0z.js +1 -0
- package/dist/packem_shared/grid-features-jnrD0SpX.js +6 -0
- package/dist/packem_shared/home-panel-CU6MWLHG.js +3 -0
- package/dist/packem_shared/input-JHu63lTv.js +1 -0
- package/dist/packem_shared/internal-BSIsQVC6.js +2 -0
- package/dist/packem_shared/label-6uP1obNF.js +1 -0
- package/dist/packem_shared/live-status-CmuRLFKf.js +1 -0
- package/dist/packem_shared/log-fields-CoL3hsIQ.js +1 -0
- package/dist/packem_shared/modal-shell-CUwwWC2o.js +1 -0
- package/dist/packem_shared/operation-console-provider-BMJNtiyB.js +1 -0
- package/dist/packem_shared/recording-client-DRAZEmzE.js +1 -0
- package/dist/packem_shared/reference-view-DnYYWr7I.js +12 -0
- package/dist/packem_shared/result-chart-DzJOVsaw.js +1 -0
- package/dist/packem_shared/schema-diagram-cg-bz_VL.js +2 -0
- package/dist/packem_shared/scroll-area-DTEq6Jec.js +2 -0
- package/dist/packem_shared/select-Bul-DeII.js +2 -0
- package/dist/packem_shared/shard-history-DMEW5VBE.js +1 -0
- package/dist/packem_shared/skeleton-C1wQ9M5t.js +1 -0
- package/dist/packem_shared/sparkline-CgjeUU2I.js +1 -0
- package/dist/packem_shared/storage-tier-DznqOf-q.js +1 -0
- package/dist/packem_shared/studio-q-C-acL7.js +2 -0
- package/dist/packem_shared/table-DdJBrClo.js +2 -0
- package/dist/packem_shared/table-list-sidebar-BFkSQwlB.js +1 -0
- package/dist/packem_shared/textarea-Bu2-jKAs.js +1 -0
- package/dist/packem_shared/trace-handoff-Dw7mwjxu.js +1 -0
- package/dist/packem_shared/use-admin-query-QJ-ibl5u.js +1 -0
- package/dist/packem_shared/use-async-submit-q3ymBJkD.js +1 -0
- package/dist/packem_shared/use-auth-config-BObBpdsi.js +1 -0
- package/dist/packem_shared/use-sql-assistant-CHEu2-Rk.js +1 -0
- package/dist/packem_shared/useDebounced-Ihdiid_k.js +1 -0
- package/dist/packem_shared/utils-bhneXptQ.js +1 -0
- package/dist/packem_shared/virtual-rect-1o1veP7R.js +1 -0
- package/dist/standalone/chunk-2GA4SHO7.js +1 -0
- package/dist/standalone/chunk-2OUPA2WJ.js +1 -0
- package/dist/standalone/chunk-2PJNAWB3.js +1 -0
- package/dist/standalone/chunk-2VDFV5TD.js +1 -0
- package/dist/standalone/chunk-2WOIRKEI.js +1 -0
- package/dist/standalone/chunk-33CL6OHR.js +1 -0
- package/dist/standalone/chunk-34D36UCW.js +1 -0
- package/dist/standalone/chunk-3C3CG7ZK.js +1 -0
- package/dist/standalone/chunk-3O3HAXW7.js +1 -0
- package/dist/standalone/chunk-3STOIE7Q.js +1 -0
- package/dist/standalone/chunk-3XIESWL4.js +1 -0
- package/dist/standalone/chunk-4UOFSGUS.js +1 -0
- package/dist/standalone/chunk-53WEPGUD.js +1 -0
- package/dist/standalone/chunk-54MMVNPT.js +1 -0
- package/dist/standalone/chunk-5CVJS7ON.js +1 -0
- package/dist/standalone/chunk-5Y3QLNWX.js +1 -0
- package/dist/standalone/chunk-6IKEW5LG.js +1 -0
- package/dist/standalone/chunk-6LNCYDZO.js +1 -0
- package/dist/standalone/chunk-6NY7SPDL.js +1 -0
- package/dist/standalone/chunk-6PNPIW6I.js +2 -0
- package/dist/standalone/chunk-6ST5ECQA.js +1 -0
- package/dist/standalone/chunk-6VAKZALJ.js +1 -0
- package/dist/standalone/chunk-6YI4WJO4.js +1 -0
- package/dist/standalone/chunk-6YTSSIEJ.js +3 -0
- package/dist/standalone/chunk-7LWMHTJ3.js +1 -0
- package/dist/standalone/chunk-7QIFDWQV.js +1 -0
- package/dist/standalone/chunk-7T7UOTYK.js +1 -0
- package/dist/standalone/chunk-A74VSSA2.js +4 -0
- package/dist/standalone/chunk-AADILRJW.js +14 -0
- package/dist/standalone/chunk-AVAC26HJ.js +1 -0
- package/dist/standalone/chunk-BGBLQ563.js +1 -0
- package/dist/standalone/chunk-CCVXYYPJ.js +1 -0
- package/dist/standalone/chunk-CFPZYHPY.js +2 -0
- package/dist/standalone/chunk-CT5MMH4O.js +1 -0
- package/dist/standalone/chunk-CTNB2KIA.js +1 -0
- package/dist/standalone/chunk-CU55Y5TV.js +62 -0
- package/dist/standalone/chunk-D2RKH6JK.js +1 -0
- package/dist/standalone/chunk-E3NMX2VU.js +4 -0
- package/dist/standalone/chunk-EN2QAEO4.js +11 -0
- package/dist/standalone/chunk-ESVP44Y3.js +1 -0
- package/dist/standalone/chunk-FNPJ7GJZ.js +1 -0
- package/dist/standalone/chunk-FOBRNWBG.js +3 -0
- package/dist/standalone/chunk-FXCBF4XT.js +1 -0
- package/dist/standalone/chunk-G6PSMGLD.js +1 -0
- package/dist/standalone/chunk-GAX5IZYG.js +8 -0
- package/dist/standalone/chunk-GB6U2BPU.js +1 -0
- package/dist/standalone/chunk-GEDMLM4A.js +6 -0
- package/dist/standalone/chunk-GMR677FL.js +1 -0
- package/dist/standalone/chunk-GRL5MG3Z.js +1 -0
- package/dist/standalone/chunk-GXSZH7VJ.js +13 -0
- package/dist/standalone/chunk-GYKVBKT5.js +1 -0
- package/dist/standalone/chunk-H6YOWRFB.js +1 -0
- package/dist/standalone/chunk-HJ3E4YF5.js +1 -0
- package/dist/standalone/chunk-HJD2YUQS.js +1 -0
- package/dist/standalone/chunk-HPFLBYRI.js +1 -0
- package/dist/standalone/chunk-IC4L6G56.js +1 -0
- package/dist/standalone/chunk-IHQC7J35.js +1 -0
- package/dist/standalone/chunk-ILNELDFC.js +1 -0
- package/dist/standalone/chunk-IVFHIQOT.js +1 -0
- package/dist/standalone/chunk-JLOWAJRR.js +1 -0
- package/dist/standalone/chunk-JN2Y24PY.js +1 -0
- package/dist/standalone/chunk-JRMMYIAF.js +1 -0
- package/dist/standalone/chunk-KC44QCN6.js +1 -0
- package/dist/standalone/chunk-KJB7YAKB.js +1 -0
- package/dist/standalone/chunk-KLQYC6CC.js +1 -0
- package/dist/standalone/chunk-KUVMORDQ.js +1 -0
- package/dist/standalone/chunk-KZ3ALMMP.js +1 -0
- package/dist/standalone/chunk-L7R74G63.js +1 -0
- package/dist/standalone/chunk-LEDWUPXM.js +1 -0
- package/dist/standalone/chunk-LFKCLLPT.js +1 -0
- package/dist/standalone/chunk-MIQTKZAR.js +1 -0
- package/dist/standalone/chunk-OG4N2XHD.js +19 -0
- package/dist/standalone/chunk-OY2RVUZL.js +1 -0
- package/dist/standalone/chunk-P4YLIBCN.js +1 -0
- package/dist/standalone/chunk-PZVU2QMX.js +1 -0
- package/dist/standalone/chunk-Q7O6B7WC.js +1 -0
- package/dist/standalone/chunk-QBWRC5YX.js +1 -0
- package/dist/standalone/chunk-QLQADHFE.js +1 -0
- package/dist/standalone/chunk-QWGT25SE.js +1 -0
- package/dist/standalone/chunk-QXXIJAD5.js +1 -0
- package/dist/standalone/chunk-QZGTH6WH.js +1 -0
- package/dist/standalone/chunk-RJP3WBZ4.js +1 -0
- package/dist/standalone/chunk-RNL6BSFM.js +1 -0
- package/dist/standalone/chunk-RNRJKBY3.js +4 -0
- package/dist/standalone/chunk-RQ7AFLIV.js +1 -0
- package/dist/standalone/chunk-S252DAFP.js +1 -0
- package/dist/standalone/chunk-S2VVR7HI.js +1 -0
- package/dist/standalone/chunk-SD4BERSA.js +1 -0
- package/dist/standalone/chunk-SFDOII3B.js +1 -0
- package/dist/standalone/chunk-SKHEGARW.js +1 -0
- package/dist/standalone/chunk-SKW6J4VW.js +1 -0
- package/dist/standalone/chunk-SMIESS7P.js +1 -0
- package/dist/standalone/chunk-T6VMSOBB.js +1 -0
- package/dist/standalone/chunk-T7IUZIF4.js +1 -0
- package/dist/standalone/chunk-THIXMMZD.js +1 -0
- package/dist/standalone/chunk-TTGOOYLF.js +1 -0
- package/dist/standalone/chunk-U6TNNM5U.js +1 -0
- package/dist/standalone/chunk-UZERI5YC.js +1 -0
- package/dist/standalone/chunk-V53KNYRN.js +1 -0
- package/dist/standalone/chunk-VHWOCPRK.js +1 -0
- package/dist/standalone/chunk-W6SAOXGH.js +6 -0
- package/dist/standalone/chunk-WBYSSCV2.js +1 -0
- package/dist/standalone/chunk-X665E2HU.js +1 -0
- package/dist/standalone/chunk-XBDKZZ67.js +1 -0
- package/dist/standalone/chunk-XDAT7LHC.js +1 -0
- package/dist/standalone/chunk-XQCVZAGU.js +1 -0
- package/dist/standalone/chunk-XS5LDR52.js +1 -0
- package/dist/standalone/chunk-XXQUMVWH.js +1 -0
- package/dist/standalone/chunk-Y5Y7DHFW.js +1 -0
- package/dist/standalone/chunk-YJYTMQJI.js +1 -0
- package/dist/standalone/chunk-Z2V42P7J.js +1 -0
- package/dist/standalone/chunk-ZJGP6EKR.js +1 -0
- package/dist/standalone/studio.js +9 -356
- package/dist/styles.css +2 -2
- package/package.json +16 -14
- package/dist/packem_shared/ADMIN_FUNCTIONS-DjXgvJb6.js +0 -46
- package/dist/packem_shared/ApiDocsPanel-yVSGHK3H.js +0 -842
- package/dist/packem_shared/ApiReferencePanel-1vubqG5s.js +0 -229
- package/dist/packem_shared/ApiTab-rwttyQ1-.js +0 -251
- package/dist/packem_shared/AuditPanel-BqXZAsu_.js +0 -212
- package/dist/packem_shared/CommandPalette-BtgkBzZI.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-Ck_7QwNK.js +0 -4542
- package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
- package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
- package/dist/packem_shared/ExportImportPanel-Dq6rj0tI.js +0 -193
- package/dist/packem_shared/FileBrowser-0pCpdKPE.js +0 -2932
- package/dist/packem_shared/FunctionRunner-7NH3KcTg.js +0 -343
- package/dist/packem_shared/FunctionStatsPanel-Cn_EBpDy.js +0 -432
- package/dist/packem_shared/GlobalDataBrowser-BTEmGrph.js +0 -318
- package/dist/packem_shared/HealthPanel-CQ4LzVET.js +0 -640
- package/dist/packem_shared/HomePanel-CP0lN1eF.js +0 -1273
- package/dist/packem_shared/InsightsPanel-DzNtoz7k.js +0 -423
- package/dist/packem_shared/LogsPanel-C3W0mabf.js +0 -839
- package/dist/packem_shared/MailPanel-CoEfWkCh.js +0 -447
- package/dist/packem_shared/MetricsPanel-CujtUfpl.js +0 -1625
- package/dist/packem_shared/MigrationsPanel-RX5qIFSr.js +0 -246
- package/dist/packem_shared/OpenRpcReferencePanel-vbcYbv3V.js +0 -191
- package/dist/packem_shared/PitrPanel-LJGNP_IX.js +0 -252
- package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
- package/dist/packem_shared/ScheduledJobs-CabfKbyM.js +0 -159
- package/dist/packem_shared/SchemaViewer-Bam6ylvw.js +0 -2512
- package/dist/packem_shared/SecurityAdvisorPanel-DHr_bI38.js +0 -79
- package/dist/packem_shared/SettingsPanel-CBXQpYQA.js +0 -176
- package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
- package/dist/packem_shared/SqlEditorPanel-D5wMIxcg.js +0 -13
- package/dist/packem_shared/Studio-DkgODWD3.js +0 -33
- package/dist/packem_shared/StudioApp-ColQCvC_.js +0 -657
- package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
- package/dist/packem_shared/TableEditor-B8K5nUna.js +0 -371
- package/dist/packem_shared/advisor-view-CGcfMiPq.js +0 -159
- package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
- package/dist/packem_shared/app.d-Nbhpihxv.d.ts +0 -300
- package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
- package/dist/packem_shared/bar-chart-CzJAgqkp.js +0 -3245
- package/dist/packem_shared/button-BhsN2uZH.js +0 -49
- package/dist/packem_shared/card-DURq3ElK.js +0 -175
- package/dist/packem_shared/cf-links-2cktDedA.js +0 -8
- package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
- package/dist/packem_shared/data-grid-B5CaV3wS.js +0 -183
- 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/grid-features-CzUfqgsM.js +0 -840
- package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
- package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
- package/dist/packem_shared/label-D8ykjn5J.js +0 -46
- package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
- package/dist/packem_shared/reference-view-B4E49Lip.js +0 -2180
- package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
- package/dist/packem_shared/sparkline-10dG-_f0.js +0 -93
- package/dist/packem_shared/sql-editor-panel-Smfl_FDF.js +0 -2562
- package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
- package/dist/packem_shared/studio-Be28OqIx.js +0 -10413
- package/dist/packem_shared/table-_RzNvy3R.js +0 -246
- package/dist/packem_shared/table-list-sidebar-Bg7uzbvC.js +0 -832
- package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
- package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
- package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as w}from"react/compiler-runtime";import{useMemo as O,useState as D}from"react";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as N}from"../packem_shared/utils-bhneXptQ.js";import{MigrationsPanel as E}from"../packem_shared/MigrationsPanel-C2OnsqRb.js";import{useNavigate as J,useSearch as P}from"@tanstack/react-router";import{E as H}from"../packem_shared/error-alert-t6cpEi0z.js";import{E as U}from"../packem_shared/empty-state-Cg7t_8qu.js";import{N as S}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{i as V,f as W}from"../packem_shared/internal-BSIsQVC6.js";import{S as _}from"../packem_shared/schema-diagram-cg-bz_VL.js";import{jsx as l,jsxs as g}from"react/jsx-runtime";const k=t=>typeof t=="object"&&t!==null,z=t=>k(t)&&k(t.fields)&&k(t.indexes)&&k(t.relations)&&typeof t.shardMode=="string",B=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(a){return{error:`baseline is not valid JSON: ${a instanceof Error?a.message:String(a)}`,status:"invalid"}}if(!k(e)||e.version!==1||!k(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(const[a,n]of Object.entries(e.tables))if(!z(n))return{error:`baseline table "${a}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},L=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((a,n)=>a===e.fields[n]),Q=(t,e,a,n)=>{const s=[];return a.kind!==n.kind&&s.push({severity:"breaking",summary:`field ${t}.${e} changed type: ${a.kind} → ${n.kind} — add a data migration to convert existing values`,table:t,scope:"table",type:"changedFieldKind"}),a.optional&&!n.optional?s.push({severity:"breaking",summary:`field ${t}.${e} became required — rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!a.optional&&n.optional&&s.push({scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),s},G=(t,e,a)=>a.optional?{scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${t}.${e} — existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},X=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.fields)){const i=e.fields[s];i===void 0?n.push(G(t,s,o)):n.push(...Q(t,s,i,o))}for(const s of Object.keys(e.fields))a.fields[s]===void 0&&n.push({severity:"breaking",summary:`removed field ${t}.${s} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},Y=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.indexes)){const i=e.indexes[s];if(i===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${s} on ${t}`,table:t,type:"addedIndex"});continue}L(i,o)||n.push({severity:"breaking",summary:`index ${s} on ${t} changed shape — a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(const s of Object.keys(e.indexes))a.indexes[s]===void 0&&n.push({severity:"breaking",summary:`removed index ${s} on ${t} — a query that used \`.withIndex("${s}")\` would break`,table:t,scope:"table",type:"removedIndex"})},Z=(t,e,a,n)=>{for(const s of Object.keys(a.relations))e.relations[s]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${t}.${s}`,table:t,type:"addedRelation"});for(const s of Object.keys(e.relations))a.relations[s]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${t}.${s}`,table:t,type:"removedRelation"})},ee=(t,e,a,n)=>{e.shardMode!==a.shardMode&&n.push({severity:"breaking",summary:`table ${t} changed shard mode: ${e.shardMode} → ${a.shardMode} — its physical storage moves; add a data migration / re-shard plan`,table:t,scope:"table",type:"changedShardMode"}),X(t,e,a,n),Y(t,e,a,n),Z(t,e,a,n)},te=(t,e)=>{const a=[],n=t?.tables??{};for(const[s,o]of Object.entries(e.tables)){const i=n[s];if(i===void 0){a.push({scope:"table",severity:"safe",summary:`added table ${s}`,table:s,type:"addedTable"});continue}ee(s,i,o,a)}for(const s of Object.keys(n))e.tables[s]===void 0&&a.push({scope:"table",severity:"breaking",summary:`removed table ${s} — add a data migration if its data must be archived/cleaned up`,table:s,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const s=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";a.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${s} to ${o} — this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:a}},T=t=>Object.entries(t.fields).map(([e,a])=>({name:e,optional:a.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:a.kind})),F=(t,e)=>{const a={},n=t?.fields??{},s=e?.fields??{};for(const[o,i]of Object.entries(s)){const r=n[o];r===void 0?a[o]=t===void 0?"unchanged":"added":a[o]=r.kind===i.kind&&r.optional===i.optional?"unchanged":"changed"}for(const o of Object.keys(n))s[o]===void 0&&(a[o]="removed");return a},ae=(t,e)=>{const{changes:a}=te(t,e),n=new Set(a.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),s=[],o=(i,r)=>i?"added":n.has(r)?"changed":"context";for(const[i,r]of Object.entries(e.tables)){const c=t?.tables[i],u=o(c===void 0,i);s.push({columns:T(r),fieldStatus:F(c,r),name:i,shardMode:r.shardMode,status:u})}for(const[i,r]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&s.push({columns:T(r),fieldStatus:F(r,void 0),name:i,shardMode:r.shardMode,status:"removed"});return s.sort((i,r)=>i.name.localeCompare(r.name)),{breakingCount:a.filter(i=>i.severity==="breaking").length,changes:a,tables:s}},A=t=>{const e=B(t);return e.status==="ok"?e.snapshot:void 0},ne={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},se=t=>t==="global"?"global":"shard",ie=t=>{const e=w(24),{appliedAt:a,hash:n,onSelect:s,selected:o,seq:i}=t,r=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let c;e[0]!==r?(c=N("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",r),e[0]=r,e[1]=c):c=e[1];const u=`sh-version-${n}`;let m;e[2]!==n||e[3]!==s?(m=()=>{s(n)},e[2]=n,e[3]=s,e[4]=m):m=e[4];let p;e[5]!==i?(p=g("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=p):p=e[6];let b;e[7]!==n?(b=n.slice(0,7),e[7]=n,e[8]=b):b=e[8];let h;e[9]!==b?(h=l("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:b}),e[9]=b,e[10]=h):h=e[10];let f;e[11]!==p||e[12]!==h?(f=g("span",{className:"flex w-full items-baseline gap-2",children:[p,h]}),e[11]=p,e[12]=h,e[13]=f):f=e[13];let v;e[14]!==a?(v=V(a),e[14]=a,e[15]=v):v=e[15];let x;e[16]!==v?(x=l("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:v}),e[16]=v,e[17]=x):x=e[17];let d;return e[18]!==x||e[19]!==c||e[20]!==u||e[21]!==m||e[22]!==f?(d=l("li",{children:g("button",{className:c,"data-testid":u,onClick:m,type:"button",children:[f,x]})}),e[18]=x,e[19]=c,e[20]=u,e[21]=m,e[22]=f,e[23]=d):d=e[23],d},re=t=>{const e=w(26),{breaking:a,count:n,first:s}=t,o=M();if(s){let h;e[0]!==n?(h=l("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=h):h=e[1];let f;e[2]!==o?(f=o("tables"),e[2]=o,e[3]=f):f=e[3];let v;e[4]!==f?(v=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=v):v=e[5];let x;return e[6]!==h||e[7]!==v?(x=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[h,v]}),e[6]=h,e[7]=v,e[8]=x):x=e[8],x}const i=a>0&&"text-destructive";let r;e[9]!==i?(r=N("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=r):r=e[10];let c;e[11]!==n||e[12]!==r?(c=l("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=c):c=e[13];let u;e[14]!==n||e[15]!==o?(u=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=u):u=e[16];let m;e[17]!==u?(m=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:u}),e[17]=u,e[18]=m):m=e[18];let p;e[19]!==a||e[20]!==o?(p=a>0&&g("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",o("{count} breaking",{count:a})]}),e[19]=a,e[20]=o,e[21]=p):p=e[21];let b;return e[22]!==c||e[23]!==m||e[24]!==p?(b=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[c,m,p]}),e[22]=c,e[23]=m,e[24]=p,e[25]=b):b=e[25],b},K={addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},oe=(t,e)=>{const a=`${K[t.type].action} ${e} `;return t.summary.startsWith(a)?t.summary.slice(a.length):t.summary},de=t=>{const e=new Map;for(const n of t){const s=n.table??"",o=e.get(s);o===void 0?e.set(s,[n]):o.push(n)}const a=[...e].map(([n,s])=>({changes:s,table:n}));return[...a.filter(n=>n.table!==""),...a.filter(n=>n.table==="")]},le=t=>{const e=w(2),{children:a}=t;let n;return e[0]!==a?(n=l("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:a}),e[0]=a,e[1]=n):n=e[1],n},ce=({pane:t,shardKey:e=""})=>{const a=M(),n=J(),s=P({strict:!1}).version,o=d=>{W(n({search:{version:d},to:"/migrations"}))},i=S(I.schemaHistory,{},{shardKey:e}),r=i.data?.versions??[],c=s!==void 0&&r.some(d=>d.hash===s)?s:r[0]?.hash,u=r.findIndex(d=>d.hash===c),m=u===-1?void 0:r[u+1]?.hash,p=S(I.schemaVersion,{hash:c??""},{enabled:c!==void 0,shardKey:e}),b=S(I.schemaVersion,{hash:m??""},{enabled:m!==void 0,shardKey:e}),h=O(()=>{const d=A(p.data?.version?.snapshotJson);if(d!==void 0)return ae(A(b.data?.version?.snapshotJson),d)},[p.data,b.data]),f=O(()=>(h?.tables??[]).map(d=>({columns:d.columns,name:d.name,tier:se(d.shardMode)})),[h]),v=O(()=>{const d={};for(const $ of h?.tables??[])d[$.name]=ne[$.status];return d},[h]);if(i.error!==null)return l(H,{error:i.errorSource,testId:"sh-error"});if(r.length===0)return l(U,{description:a("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:a("No schema versions recorded yet.")});const x=h?.changes??[];return g("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[g("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[l(le,{children:a("Schema versions")}),l("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:r.map(d=>l(ie,{appliedAt:d.appliedAt,hash:d.hash,onSelect:o,selected:d.hash===c,seq:d.seq},d.hash))})]}),g("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[l(re,{breaking:h?.breakingCount??0,count:m===void 0?f.length:x.length,first:m===void 0}),t==="diagram"?l("div",{className:"flex min-h-0 flex-1 flex-col",children:l(_,{fill:!0,nodeClasses:v,tables:f,testIdPrefix:"sh"})}):l("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:de(x).map(d=>{const $=(h?.tables??[]).find(y=>y.name===d.table);return g("section",{className:"mb-6",children:[g("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[l("span",{className:"font-mono text-[13px] text-foreground",children:d.table===""?a("schema"):d.table}),$!==void 0&&l("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:a("{count} columns",{count:$.columns.length})}),d.changes.length>1&&l("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:d.changes.length})]}),l("ul",{children:d.changes.map(y=>{const{action:C,kind:q}=K[y.type],j=y.severity==="breaking",R=oe(y,q);return g("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[l("span",{"aria-hidden":"true",className:N("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),g("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[a(C)," ",q]}),R!==d.table&&l("span",{className:N("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:R}),j&&l("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:a("breaking")})]},`${y.type}-${y.summary}`)})})]},d.table)})})]})]})},me=t=>N("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),je=t=>{const e=w(11),{initialShardKey:a}=t,n=M(),[s,o]=D("diagram");let i;e[0]!==s?(i=(p,b,h,f)=>g("button",{"aria-selected":s===p,className:me(s===p),"data-testid":h,onClick:()=>{o(p)},role:"tab",type:"button",children:[b,f!==void 0&&l("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),e[0]=s,e[1]=i):i=e[1];const r=i;let c;e[2]!==n||e[3]!==r?(c=g("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[r("diagram",n("Diagram"),"mg-pane-diagram"),r("changes",n("Changes"),"mg-pane-changes"),r("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=r,e[4]=c):c=e[4];let u;e[5]!==a||e[6]!==s?(u=l("div",{className:"flex min-h-0 flex-1 flex-col",children:s==="data"?l("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:l(E,{initialShardKey:a})}):l(ce,{pane:s,shardKey:a})}),e[5]=a,e[6]=s,e[7]=u):u=e[7];let m;return e[8]!==c||e[9]!==u?(m=g("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[c,u]}),e[8]=c,e[9]=u,e[10]=m):m=e[10],m};export{je as MigrationsRoutePanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as G}from"react/compiler-runtime";import{useLunora as le}from"@lunora/react";import{useState as P}from"react";import{u as j}from"../packem_shared/button-BkCrNcAs.js";import{u as St,c as kt}from"../packem_shared/card-CIDGUN6K.js";import{E as et}from"../packem_shared/empty-state-Cg7t_8qu.js";import{p as me,d as Nt,m as bt,f as At,n as Ot,u as de}from"../packem_shared/table-DdJBrClo.js";import{O as Ze}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{u as Tt}from"../packem_shared/use-auth-config-BObBpdsi.js";import{useAutoRefresh as Dt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{h as S,f as Et,b as Lt,i as jt}from"../packem_shared/internal-BSIsQVC6.js";import{u as V}from"../packem_shared/input-JHu63lTv.js";import{p as Pt}from"../packem_shared/label-6uP1obNF.js";import{M as Jt}from"../packem_shared/modal-shell-CUwwWC2o.js";import{l as _t}from"../packem_shared/textarea-Bu2-jKAs.js";import{u as ie}from"../packem_shared/use-async-submit-q3ymBJkD.js";import{jsx as n,jsxs as T,Fragment as ht}from"react/jsx-runtime";const Ft=t=>{const e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},Ut=t=>{const e=Ft(t),r={};for(const[s,c]of Object.entries(e)){if(!Array.isArray(c)||c.some(l=>typeof l!="string"))throw new TypeError(`"${s}" must map to an array of action strings`);r[s]=c}return r},Rt=t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),Q=t=>{const e=G(6),{children:r,htmlFor:s,label:c}=t;let l;e[0]!==s||e[1]!==c?(l=n(Pt,{htmlFor:s,children:c}),e[0]=s,e[1]=c,e[2]=l):l=e[2];let o;return e[3]!==r||e[4]!==l?(o=T("div",{className:"flex flex-col gap-1",children:[l,r]}),e[3]=r,e[4]=l,e[5]=o):o=e[5],o},se=({busy:t,canSubmit:e,children:r,destructive:s=!1,error:c,onClose:l,onSubmit:o,submitLabel:a,testId:i,title:m})=>{const d=W();return T(Jt,{label:m,onClose:l,panelTestId:`${i}-panel`,testId:`${i}-overlay`,variant:"dialog",children:[n("h2",{className:"text-sm font-semibold text-foreground",children:m}),r,c!==null&&n("p",{className:"text-sm text-destructive","data-testid":`${i}-error`,role:"alert",children:c}),T("div",{className:"flex justify-end gap-2 pt-1",children:[n(j,{"data-testid":`${i}-cancel`,onClick:l,size:"sm",type:"button",variant:"outline",children:d("Cancel")}),n(j,{"data-testid":`${i}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:s?"destructive":"default",children:t?d("Saving…"):a})]})]})},$t=t=>{const e=G(79),{mode:r,onClose:s,onDone:c,org:l}=t,o=le(),a=W(),{busy:i,error:m,run:d}=ie();let p;e[0]!==l?(p=l?S(l.name):"",e[0]=l,e[1]=p):p=e[1];const[u,g]=P(p);let C;e[2]!==l?(C=l?S(l.slug):"",e[2]=l,e[3]=C):C=e[3];const[b,v]=P(C);let $;e[4]!==l?($=l?S(l.logo):"",e[4]=l,e[5]=$):$=e[5];const[f,w]=P($),[h,x]=P("");let y;e[6]!==r||e[7]!==l?.metadata?(y=r==="edit"?Rt(l?.metadata):"",e[6]=r,e[7]=l?.metadata,e[8]=y):y=e[8];const[I,z]=P(y);let O;e[9]!==o||e[10]!==f||e[11]!==I||e[12]!==r||e[13]!==u||e[14]!==s||e[15]!==c||e[16]!==l?.id||e[17]!==h||e[18]!==d||e[19]!==b?(O=()=>{d(async()=>{const E=I.trim()===""?void 0:Ft(I);r==="create"?await o.createAuthOrganization({logo:f.trim()===""?void 0:f.trim(),metadata:E,name:u.trim(),ownerId:h.trim()===""?void 0:h.trim(),slug:b.trim()===""?void 0:b.trim()}):await o.updateAuthOrganization({logo:f.trim()===""?void 0:f.trim(),metadata:E,name:u.trim()===""?void 0:u.trim(),organizationId:S(l?.id),slug:b.trim()===""?void 0:b.trim()}),c(),s()})},e[9]=o,e[10]=f,e[11]=I,e[12]=r,e[13]=u,e[14]=s,e[15]=c,e[16]=l?.id,e[17]=h,e[18]=d,e[19]=b,e[20]=O):O=e[20];const N=O;let k;e[21]!==r||e[22]!==u?(k=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=k):k=e[23];let D;e[24]!==r||e[25]!==a?(D=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=D):D=e[26];let _;e[27]!==r||e[28]!==a?(_=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=_):_=e[29];let J;e[30]!==a?(J=a("name"),e[30]=a,e[31]=J):J=e[31];let q;e[32]===Symbol.for("react.memo_cache_sentinel")?(q=E=>{g(E.target.value)},e[32]=q):q=e[32];let U;e[33]!==u?(U=n(V,{"data-testid":"org-form-name",id:"org-form-name",onChange:q,value:u}),e[33]=u,e[34]=U):U=e[34];let L;e[35]!==U||e[36]!==J?(L=n(Q,{htmlFor:"org-form-name",label:J,children:U}),e[35]=U,e[36]=J,e[37]=L):L=e[37];let B;e[38]!==a?(B=a("Slug (optional — derived from name)"),e[38]=a,e[39]=B):B=e[39];let K;e[40]===Symbol.for("react.memo_cache_sentinel")?(K=E=>{v(E.target.value)},e[40]=K):K=e[40];let F;e[41]!==b?(F=n(V,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:K,value:b}),e[41]=b,e[42]=F):F=e[42];let R;e[43]!==B||e[44]!==F?(R=n(Q,{htmlFor:"org-form-slug",label:B,children:F}),e[43]=B,e[44]=F,e[45]=R):R=e[45];let H;e[46]!==a?(H=a("Logo URL (optional)"),e[46]=a,e[47]=H):H=e[47];let re;e[48]===Symbol.for("react.memo_cache_sentinel")?(re=E=>{w(E.target.value)},e[48]=re):re=e[48];let X;e[49]!==f?(X=n(V,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:re,value:f}),e[49]=f,e[50]=X):X=e[50];let Y;e[51]!==H||e[52]!==X?(Y=n(Q,{htmlFor:"org-form-logo",label:H,children:X}),e[51]=H,e[52]=X,e[53]=Y):Y=e[53];let Z;e[54]!==r||e[55]!==h||e[56]!==a?(Z=r==="create"&&n(Q,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:n(V,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:E=>{x(E.target.value)},value:h})}),e[54]=r,e[55]=h,e[56]=a,e[57]=Z):Z=e[57];let ee;e[58]!==a?(ee=a("Metadata (JSON, optional)"),e[58]=a,e[59]=ee):ee=e[59];let oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(oe=E=>{z(E.target.value)},e[60]=oe):oe=e[60];let te;e[61]!==I?(te=n(_t,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:oe,value:I}),e[61]=I,e[62]=te):te=e[62];let A;e[63]!==ee||e[64]!==te?(A=n(Q,{htmlFor:"org-form-metadata",label:ee,children:te}),e[63]=ee,e[64]=te,e[65]=A):A=e[65];let ne;return e[66]!==i||e[67]!==m||e[68]!==s||e[69]!==N||e[70]!==L||e[71]!==R||e[72]!==Y||e[73]!==Z||e[74]!==A||e[75]!==k||e[76]!==D||e[77]!==_?(ne=T(se,{busy:i,canSubmit:k,error:m,onClose:s,onSubmit:N,submitLabel:D,testId:"org-form",title:_,children:[L,R,Y,Z,A]}),e[66]=i,e[67]=m,e[68]=s,e[69]=N,e[70]=L,e[71]=R,e[72]=Y,e[73]=Z,e[74]=A,e[75]=k,e[76]=D,e[77]=_,e[78]=ne):ne=e[78],ne},Bt=t=>{const e=G(40),{onClose:r,onDone:s,organizationId:c}=t,l=le(),o=W(),{busy:a,error:i,run:m}=ie(),[d,p]=P(""),[u,g]=P("");let C;e[0]!==l||e[1]!==r||e[2]!==s||e[3]!==c||e[4]!==u||e[5]!==m||e[6]!==d?(C=()=>{m(async()=>{await l.addAuthOrgMember({organizationId:c,role:u.trim()===""?void 0:u.trim(),userId:d.trim()}),s(),r()})},e[0]=l,e[1]=r,e[2]=s,e[3]=c,e[4]=u,e[5]=m,e[6]=d,e[7]=C):C=e[7];const b=C;let v;e[8]!==d?(v=d.trim(),e[8]=d,e[9]=v):v=e[9];const $=v!=="";let f;e[10]!==o?(f=o("Add member"),e[10]=o,e[11]=f):f=e[11];let w;e[12]!==o?(w=o("Add member"),e[12]=o,e[13]=w):w=e[13];let h;e[14]!==o?(h=o("User id"),e[14]=o,e[15]=h):h=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=_=>{p(_.target.value)},e[16]=x):x=e[16];let y;e[17]!==d?(y=n(V,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:x,value:d}),e[17]=d,e[18]=y):y=e[18];let I;e[19]!==h||e[20]!==y?(I=n(Q,{htmlFor:"org-add-member-user",label:h,children:y}),e[19]=h,e[20]=y,e[21]=I):I=e[21];let z;e[22]!==o?(z=o("Role (optional)"),e[22]=o,e[23]=z):z=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=_=>{g(_.target.value)},e[24]=O):O=e[24];let N;e[25]!==u?(N=n(V,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:O,value:u}),e[25]=u,e[26]=N):N=e[26];let k;e[27]!==z||e[28]!==N?(k=n(Q,{htmlFor:"org-add-member-role",label:z,children:N}),e[27]=z,e[28]=N,e[29]=k):k=e[29];let D;return e[30]!==a||e[31]!==i||e[32]!==r||e[33]!==b||e[34]!==k||e[35]!==$||e[36]!==f||e[37]!==w||e[38]!==I?(D=T(se,{busy:a,canSubmit:$,error:i,onClose:r,onSubmit:b,submitLabel:f,testId:"org-add-member",title:w,children:[I,k]}),e[30]=a,e[31]=i,e[32]=r,e[33]=b,e[34]=k,e[35]=$,e[36]=f,e[37]=w,e[38]=I,e[39]=D):D=e[39],D},Ht=t=>{const e=G(40),{onClose:r,onDone:s,organizationId:c}=t,l=le(),o=W(),{busy:a,error:i,run:m}=ie(),[d,p]=P(""),[u,g]=P("");let C;e[0]!==l||e[1]!==d||e[2]!==r||e[3]!==s||e[4]!==c||e[5]!==u||e[6]!==m?(C=()=>{m(async()=>{await l.inviteAuthOrgMember({email:d.trim(),organizationId:c,role:u.trim()===""?void 0:u.trim()}),s(),r()})},e[0]=l,e[1]=d,e[2]=r,e[3]=s,e[4]=c,e[5]=u,e[6]=m,e[7]=C):C=e[7];const b=C;let v;e[8]!==d?(v=d.trim(),e[8]=d,e[9]=v):v=e[9];const $=v!=="";let f;e[10]!==o?(f=o("Send invitation"),e[10]=o,e[11]=f):f=e[11];let w;e[12]!==o?(w=o("Invite member"),e[12]=o,e[13]=w):w=e[13];let h;e[14]!==o?(h=o("email"),e[14]=o,e[15]=h):h=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=_=>{p(_.target.value)},e[16]=x):x=e[16];let y;e[17]!==d?(y=n(V,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:x,type:"email",value:d}),e[17]=d,e[18]=y):y=e[18];let I;e[19]!==h||e[20]!==y?(I=n(Q,{htmlFor:"org-invite-member-email",label:h,children:y}),e[19]=h,e[20]=y,e[21]=I):I=e[21];let z;e[22]!==o?(z=o("Role (optional)"),e[22]=o,e[23]=z):z=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=_=>{g(_.target.value)},e[24]=O):O=e[24];let N;e[25]!==u?(N=n(V,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:O,value:u}),e[25]=u,e[26]=N):N=e[26];let k;e[27]!==z||e[28]!==N?(k=n(Q,{htmlFor:"org-invite-member-role",label:z,children:N}),e[27]=z,e[28]=N,e[29]=k):k=e[29];let D;return e[30]!==a||e[31]!==i||e[32]!==r||e[33]!==b||e[34]!==k||e[35]!==$||e[36]!==f||e[37]!==w||e[38]!==I?(D=T(se,{busy:a,canSubmit:$,error:i,onClose:r,onSubmit:b,submitLabel:f,testId:"org-invite-member",title:w,children:[I,k]}),e[30]=a,e[31]=i,e[32]=r,e[33]=b,e[34]=k,e[35]=$,e[36]=f,e[37]=w,e[38]=I,e[39]=D):D=e[39],D},qt=t=>{const e=G(32),{member:r,onClose:s,onDone:c}=t,l=le(),o=W(),{busy:a,error:i,run:m}=ie();let d;e[0]!==r.role?(d=()=>S(r.role),e[0]=r.role,e[1]=d):d=e[1];const[p,u]=P(d);let g;e[2]!==l||e[3]!==r.id||e[4]!==s||e[5]!==c||e[6]!==p||e[7]!==m?(g=()=>{m(async()=>{await l.setAuthOrgMemberRole({memberId:S(r.id),role:p.trim()}),c(),s()})},e[2]=l,e[3]=r.id,e[4]=s,e[5]=c,e[6]=p,e[7]=m,e[8]=g):g=e[8];const C=g;let b;e[9]!==p?(b=p.trim(),e[9]=p,e[10]=b):b=e[10];const v=b!=="";let $;e[11]!==o?($=o("Save"),e[11]=o,e[12]=$):$=e[12];let f;e[13]!==o?(f=o("Change member role"),e[13]=o,e[14]=f):f=e[14];let w;e[15]!==o?(w=o("Role"),e[15]=o,e[16]=w):w=e[16];let h;e[17]===Symbol.for("react.memo_cache_sentinel")?(h=z=>{u(z.target.value)},e[17]=h):h=e[17];let x;e[18]!==p?(x=n(V,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:h,value:p}),e[18]=p,e[19]=x):x=e[19];let y;e[20]!==w||e[21]!==x?(y=n(Q,{htmlFor:"org-member-role-value",label:w,children:x}),e[20]=w,e[21]=x,e[22]=y):y=e[22];let I;return e[23]!==a||e[24]!==i||e[25]!==s||e[26]!==C||e[27]!==y||e[28]!==v||e[29]!==$||e[30]!==f?(I=n(se,{busy:a,canSubmit:v,error:i,onClose:s,onSubmit:C,submitLabel:$,testId:"org-member-role",title:f,children:y}),e[23]=a,e[24]=i,e[25]=s,e[26]=C,e[27]=y,e[28]=v,e[29]=$,e[30]=f,e[31]=I):I=e[31],I},xt=t=>{const e=G(36),{mode:r,onClose:s,onDone:c,organizationId:l,team:o}=t,a=le(),i=W(),{busy:m,error:d,run:p}=ie();let u;e[0]!==o?(u=o?S(o.name):"",e[0]=o,e[1]=u):u=e[1];const[g,C]=P(u);let b;e[2]!==a||e[3]!==r||e[4]!==g||e[5]!==s||e[6]!==c||e[7]!==l||e[8]!==p||e[9]!==o?.id?(b=()=>{p(async()=>{await(r==="create"?a.createAuthOrgTeam({name:g.trim(),organizationId:l}):a.updateAuthOrgTeam({name:g.trim(),teamId:S(o?.id)})),c(),s()})},e[2]=a,e[3]=r,e[4]=g,e[5]=s,e[6]=c,e[7]=l,e[8]=p,e[9]=o?.id,e[10]=b):b=e[10];const v=b;let $;e[11]!==g?($=g.trim(),e[11]=g,e[12]=$):$=e[12];const f=$!=="";let w;e[13]!==r||e[14]!==i?(w=i(r==="create"?"Create":"Save"),e[13]=r,e[14]=i,e[15]=w):w=e[15];let h;e[16]!==r||e[17]!==i?(h=i(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=i,e[18]=h):h=e[18];let x;e[19]!==i?(x=i("name"),e[19]=i,e[20]=x):x=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=N=>{C(N.target.value)},e[21]=y):y=e[21];let I;e[22]!==g?(I=n(V,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:y,value:g}),e[22]=g,e[23]=I):I=e[23];let z;e[24]!==x||e[25]!==I?(z=n(Q,{htmlFor:"org-team-form-name",label:x,children:I}),e[24]=x,e[25]=I,e[26]=z):z=e[26];let O;return e[27]!==m||e[28]!==d||e[29]!==s||e[30]!==v||e[31]!==z||e[32]!==f||e[33]!==w||e[34]!==h?(O=n(se,{busy:m,canSubmit:f,error:d,onClose:s,onSubmit:v,submitLabel:w,testId:"org-team-form",title:h,children:z}),e[27]=m,e[28]=d,e[29]=s,e[30]=v,e[31]=z,e[32]=f,e[33]=w,e[34]=h,e[35]=O):O=e[35],O},Kt=t=>{const e=G(30),{onClose:r,onDone:s,teamId:c}=t,l=le(),o=W(),{busy:a,error:i,run:m}=ie(),[d,p]=P("");let u;e[0]!==l||e[1]!==r||e[2]!==s||e[3]!==m||e[4]!==c||e[5]!==d?(u=()=>{m(async()=>{await l.addAuthOrgTeamMember({teamId:c,userId:d.trim()}),s(),r()})},e[0]=l,e[1]=r,e[2]=s,e[3]=m,e[4]=c,e[5]=d,e[6]=u):u=e[6];const g=u;let C;e[7]!==d?(C=d.trim(),e[7]=d,e[8]=C):C=e[8];const b=C!=="";let v;e[9]!==o?(v=o("Add member"),e[9]=o,e[10]=v):v=e[10];let $;e[11]!==o?($=o("Add team member"),e[11]=o,e[12]=$):$=e[12];let f;e[13]!==o?(f=o("User id"),e[13]=o,e[14]=f):f=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=I=>{p(I.target.value)},e[15]=w):w=e[15];let h;e[16]!==d?(h=n(V,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:w,value:d}),e[16]=d,e[17]=h):h=e[17];let x;e[18]!==f||e[19]!==h?(x=n(Q,{htmlFor:"org-team-add-member-user",label:f,children:h}),e[18]=f,e[19]=h,e[20]=x):x=e[20];let y;return e[21]!==a||e[22]!==i||e[23]!==r||e[24]!==g||e[25]!==b||e[26]!==v||e[27]!==$||e[28]!==x?(y=n(se,{busy:a,canSubmit:b,error:i,onClose:r,onSubmit:g,submitLabel:v,testId:"org-team-add-member",title:$,children:x}),e[21]=a,e[22]=i,e[23]=r,e[24]=g,e[25]=b,e[26]=v,e[27]=$,e[28]=x,e[29]=y):y=e[29],y},zt=t=>{const e=G(47),{mode:r,onClose:s,onDone:c,organizationId:l,role:o}=t,a=le(),i=W(),{busy:m,error:d,run:p}=ie();let u;e[0]!==o?(u=o?S(o.role):"",e[0]=o,e[1]=u):u=e[1];const[g,C]=P(u);let b;e[2]!==r||e[3]!==o?.permission?(b=r==="edit"?Rt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=b):b=e[4];const[v,$]=P(b);let f;e[5]!==a||e[6]!==r||e[7]!==g||e[8]!==s||e[9]!==c||e[10]!==l||e[11]!==v||e[12]!==o?.id||e[13]!==p?(f=()=>{p(async()=>{const _=Ut(v);await(r==="create"?a.createAuthOrgRole({organizationId:l,permission:_,role:g.trim()}):a.updateAuthOrgRole({permission:_,roleId:S(o?.id)})),c(),s()})},e[5]=a,e[6]=r,e[7]=g,e[8]=s,e[9]=c,e[10]=l,e[11]=v,e[12]=o?.id,e[13]=p,e[14]=f):f=e[14];const w=f;let h;e[15]!==r||e[16]!==g||e[17]!==v?(h=v.trim()!==""&&(r==="edit"||g.trim()!==""),e[15]=r,e[16]=g,e[17]=v,e[18]=h):h=e[18];let x;e[19]!==r||e[20]!==i?(x=i(r==="create"?"Create":"Save"),e[19]=r,e[20]=i,e[21]=x):x=e[21];let y;e[22]!==r||e[23]!==i?(y=i(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=i,e[24]=y):y=e[24];let I;e[25]!==r||e[26]!==g||e[27]!==i?(I=r==="create"&&n(Q,{htmlFor:"org-role-form-name",label:i("Role name"),children:n(V,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:_=>{C(_.target.value)},value:g})}),e[25]=r,e[26]=g,e[27]=i,e[28]=I):I=e[28];let z;e[29]!==i?(z=i('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=i,e[30]=z):z=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=_=>{$(_.target.value)},e[31]=O):O=e[31];let N;e[32]!==v?(N=n(_t,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:O,value:v}),e[32]=v,e[33]=N):N=e[33];let k;e[34]!==N||e[35]!==z?(k=n(Q,{htmlFor:"org-role-form-permission",label:z,children:N}),e[34]=N,e[35]=z,e[36]=k):k=e[36];let D;return e[37]!==m||e[38]!==d||e[39]!==s||e[40]!==w||e[41]!==k||e[42]!==h||e[43]!==x||e[44]!==y||e[45]!==I?(D=T(se,{busy:m,canSubmit:h,error:d,onClose:s,onSubmit:w,submitLabel:x,testId:"org-role-form",title:y,children:[I,k]}),e[37]=m,e[38]=d,e[39]=s,e[40]=w,e[41]=k,e[42]=h,e[43]=x,e[44]=y,e[45]=I,e[46]=D):D=e[46],D},Mt=t=>{const e=G(18),{action:r,message:s,onClose:c,onDone:l,testId:o,title:a}=t,i=W(),{busy:m,error:d,run:p}=ie();let u;e[0]!==r||e[1]!==c||e[2]!==l||e[3]!==p?(u=()=>{p(async()=>{await r(),l(),c()})},e[0]=r,e[1]=c,e[2]=l,e[3]=p,e[4]=u):u=e[4];const g=u;let C;e[5]!==i?(C=i("Delete"),e[5]=i,e[6]=C):C=e[6];let b;e[7]!==s?(b=n("p",{className:"text-sm text-muted-foreground",children:s}),e[7]=s,e[8]=b):b=e[8];let v;return e[9]!==m||e[10]!==d||e[11]!==c||e[12]!==g||e[13]!==C||e[14]!==b||e[15]!==o||e[16]!==a?(v=n(se,{busy:m,canSubmit:!0,destructive:!0,error:d,onClose:c,onSubmit:g,submitLabel:C,testId:o,title:a,children:b}),e[9]=m,e[10]=d,e[11]=c,e[12]=g,e[13]=C,e[14]=b,e[15]=o,e[16]=a,e[17]=v):v=e[17],v},tt=t=>{const e=G(13),{action:r,children:s,heading:c,testId:l}=t;let o;e[0]!==c?(o=n("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[0]=c,e[1]=o):o=e[1];let a;e[2]!==r?(a=r!==void 0&&n("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let i;e[4]!==o||e[5]!==a?(i=T("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=i):i=e[6];let m;e[7]!==s?(m=n(St,{className:"px-0",children:s}),e[7]=s,e[8]=m):m=e[8];let d;return e[9]!==i||e[10]!==m||e[11]!==l?(d=T(kt,{className:"overflow-hidden py-0","data-testid":l,children:[i,m]}),e[9]=i,e[10]=m,e[11]=l,e[12]=d):d=e[12],d},rt=t=>{const e=G(23),{columns:r,rowActions:s,rowPrefix:c,rows:l}=t,o=W();let a;e[0]!==r?(a=r.map(Gt),e[0]=r,e[1]=a):a=e[1];let i;e[2]!==o?(i=o("Actions"),e[2]=o,e[3]=i):i=e[3];let m;e[4]!==i?(m=n(me,{"aria-label":i}),e[4]=i,e[5]=m):m=e[5];let d;e[6]!==a||e[7]!==m?(d=n(Nt,{children:T(bt,{children:[a,m]})}),e[6]=a,e[7]=m,e[8]=d):d=e[8];let p;if(e[9]!==r||e[10]!==s||e[11]!==c||e[12]!==l){let C;e[14]!==r||e[15]!==s||e[16]!==c?(C=b=>{const v=S(b.id);return T(bt,{"data-testid":`${c}-${v}`,children:[r.map($=>n(de,{className:$.className,children:$.render(b)},$.head)),n(de,{children:n("div",{className:"flex justify-end gap-1",children:s(b)})})]},v)},e[14]=r,e[15]=s,e[16]=c,e[17]=C):C=e[17],p=l.map(C),e[9]=r,e[10]=s,e[11]=c,e[12]=l,e[13]=p}else p=e[13];let u;e[18]!==p?(u=n(At,{children:p}),e[18]=p,e[19]=u):u=e[19];let g;return e[20]!==d||e[21]!==u?(g=T(Ot,{children:[d,u]}),e[20]=d,e[21]=u,e[22]=g):g=e[22],g},Qt=t=>{const e=G(219),{organizationId:r,rolesEnabled:s,teamsEnabled:c}=t,l=le(),o=W(),[a,i]=P(null),[m,d]=P(null),[p,u]=P(!1),[g,C]=P(null);let b;e[0]!==r?(b=["lunora-auth-org-members",r],e[0]=r,e[1]=b):b=e[1];let v;e[2]!==l||e[3]!==r?(v=()=>l.listAuthOrgMembers({limit:200,organizationId:r}),e[2]=l,e[3]=r,e[4]=v):v=e[4];const $=Ze(b,v);let f;e[5]!==r?(f=["lunora-auth-org-invitations",r],e[5]=r,e[6]=f):f=e[6];let w;e[7]!==l||e[8]!==r?(w=()=>l.listAuthOrgInvitations({limit:200,organizationId:r}),e[7]=l,e[8]=r,e[9]=w):w=e[9];const h=Ze(f,w);let x;e[10]!==r?(x=["lunora-auth-org-teams",r],e[10]=r,e[11]=x):x=e[11];let y;e[12]!==l||e[13]!==r?(y=()=>l.listAuthOrgTeams({limit:200,organizationId:r}),e[12]=l,e[13]=r,e[14]=y):y=e[14];let I;e[15]!==c?(I={enabled:c},e[15]=c,e[16]=I):I=e[16];const z=Ze(x,y,I);let O;e[17]!==r?(O=["lunora-auth-org-roles",r],e[17]=r,e[18]=O):O=e[18];let N;e[19]!==l||e[20]!==r?(N=()=>l.listAuthOrgRoles({limit:200,organizationId:r}),e[19]=l,e[20]=r,e[21]=N):N=e[21];let k;e[22]!==s?(k={enabled:s},e[22]=s,e[23]=k):k=e[23];const D=Ze(O,N,k);let _;e[24]!==m?(_=["lunora-auth-org-team-members",m],e[24]=m,e[25]=_):_=e[25];let J;e[26]!==l||e[27]!==m?(J=()=>l.listAuthOrgTeamMembers({limit:200,teamId:m??""}),e[26]=l,e[27]=m,e[28]=J):J=e[28];const q=m!==null;let U;e[29]!==q?(U={enabled:q},e[29]=q,e[30]=U):U=e[30];const L=Ze(_,J,U);let B;e[31]!==$.data?.rows?(B=$.data?.rows??[],e[31]=$.data?.rows,e[32]=B):B=e[32];const K=B;let F;e[33]!==h.data?.rows?(F=h.data?.rows??[],e[33]=h.data?.rows,e[34]=F):F=e[34];const R=F;let H;e[35]!==z.data?.rows?(H=z.data?.rows??[],e[35]=z.data?.rows,e[36]=H):H=e[36];const re=H;let X;e[37]!==D.data?.rows?(X=D.data?.rows??[],e[37]=D.data?.rows,e[38]=X):X=e[38];const Y=X;let Z;e[39]!==m||e[40]!==L?(Z=m===null?[]:L.data?.rows??[],e[39]=m,e[40]=L,e[41]=Z):Z=e[41];const ee=Z,oe=$.error??h.error??z.error??D.error??L.error;let te;e[42]!==h||e[43]!==$||e[44]!==s||e[45]!==D||e[46]!==m||e[47]!==L||e[48]!==c||e[49]!==z?(te=()=>{$.refetch(),h.refetch(),c&&z.refetch(),s&&D.refetch(),m!==null&&L.refetch()},e[42]=h,e[43]=$,e[44]=s,e[45]=D,e[46]=m,e[47]=L,e[48]=c,e[49]=z,e[50]=te):te=e[50];const A=te;Dt(A,!0);let ne;e[51]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{i(null)},e[51]=ne):ne=e[51];const E=ne;let ot;e[52]!==A?(ot=M=>{Et((async()=>{u(!0),C(null);try{await M(),A(),u(!1)}catch(gt){C(Lt(gt)),u(!1)}})())},e[52]=A,e[53]=ot):ot=e[53];const ae=ot;let nt;e[54]!==l||e[55]!==o?(nt=M=>{const gt=S(M.id);i({action:async()=>{await l.removeAuthOrgTeam({teamId:gt}),d(Ct=>Ct===gt?null:Ct)},kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},e[54]=l,e[55]=o,e[56]=nt):nt=e[56];const ft=nt;let ce;e[57]!==o?(ce=o("userId"),e[57]=o,e[58]=ce):ce=e[58];let ue;e[59]!==ce?(ue={head:ce,render:Vt},e[59]=ce,e[60]=ue):ue=e[60];let ge;e[61]!==o?(ge=o("role"),e[61]=o,e[62]=ge):ge=e[62];let he;e[63]!==ge?(he={head:ge,render:Wt},e[63]=ge,e[64]=he):he=e[64];let at;e[65]!==ue||e[66]!==he?(at=[ue,he],e[65]=ue,e[66]=he,e[67]=at):at=e[67];const pt=at;let be;e[68]!==o?(be=o("email"),e[68]=o,e[69]=be):be=e[69];let fe;e[70]!==be?(fe={head:be,render:Xt},e[70]=be,e[71]=fe):fe=e[71];let pe;e[72]!==o?(pe=o("role"),e[72]=o,e[73]=pe):pe=e[73];let ve;e[74]!==pe?(ve={head:pe,render:Yt},e[74]=pe,e[75]=ve):ve=e[75];let ye;e[76]!==o?(ye=o("status"),e[76]=o,e[77]=ye):ye=e[77];let Ie;e[78]!==ye?(Ie={head:ye,render:Zt},e[78]=ye,e[79]=Ie):Ie=e[79];let lt;e[80]!==fe||e[81]!==ve||e[82]!==Ie?(lt=[fe,ve,Ie],e[80]=fe,e[81]=ve,e[82]=Ie,e[83]=lt):lt=e[83];const vt=lt;let we;e[84]!==o?(we=o("id"),e[84]=o,e[85]=we):we=e[85];let Ce;e[86]!==we?(Ce={className:"font-mono text-xs",head:we,render:er},e[86]=we,e[87]=Ce):Ce=e[87];let $e;e[88]!==o?($e=o("name"),e[88]=o,e[89]=$e):$e=e[89];let xe;e[90]!==$e?(xe={head:$e,render:tr},e[90]=$e,e[91]=xe):xe=e[91];let it;e[92]!==Ce||e[93]!==xe?(it=[Ce,xe],e[92]=Ce,e[93]=xe,e[94]=it):it=e[94];const yt=it;let ze;e[95]!==o?(ze=o("userId"),e[95]=o,e[96]=ze):ze=e[96];let st;e[97]!==ze?(st=[{head:ze,render:rr}],e[97]=ze,e[98]=st):st=e[98];const It=st;let Se;e[99]!==o?(Se=o("role"),e[99]=o,e[100]=Se):Se=e[100];let ke;e[101]!==Se?(ke={head:Se,render:or},e[101]=Se,e[102]=ke):ke=e[102];let Ne;e[103]!==o?(Ne=o("Permission"),e[103]=o,e[104]=Ne):Ne=e[104];let Ae;e[105]!==Ne?(Ae={className:"font-mono text-xs whitespace-pre-wrap",head:Ne,render:nr},e[105]=Ne,e[106]=Ae):Ae=e[106];let mt;e[107]!==ke||e[108]!==Ae?(mt=[ke,Ae],e[107]=ke,e[108]=Ae,e[109]=mt):mt=e[109];const wt=mt;let Oe;e[110]!==oe?(Oe=oe!==null&&n("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:oe}),e[110]=oe,e[111]=Oe):Oe=e[111];let De;e[112]!==g?(De=g!==null&&n("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:g}),e[112]=g,e[113]=De):De=e[113];let dt;e[114]===Symbol.for("react.memo_cache_sentinel")?(dt=()=>{i({kind:"add-member"})},e[114]=dt):dt=e[114];let _e;e[115]!==o?(_e=o("Add member"),e[115]=o,e[116]=_e):_e=e[116];let Fe;e[117]!==_e?(Fe=n(j,{"data-testid":"org-open-add-member",onClick:dt,size:"xs",type:"button",variant:"outline",children:_e}),e[117]=_e,e[118]=Fe):Fe=e[118];let ct;e[119]===Symbol.for("react.memo_cache_sentinel")?(ct=()=>{i({kind:"invite-member"})},e[119]=ct):ct=e[119];let Re;e[120]!==o?(Re=o("Invite member"),e[120]=o,e[121]=Re):Re=e[121];let Me;e[122]!==Re?(Me=n(j,{"data-testid":"org-open-invite-member",onClick:ct,size:"xs",type:"button",variant:"outline",children:Re}),e[122]=Re,e[123]=Me):Me=e[123];let Te;e[124]!==Fe||e[125]!==Me?(Te=T(ht,{children:[Fe,Me]}),e[124]=Fe,e[125]=Me,e[126]=Te):Te=e[126];let Ee;e[127]!==o?(Ee=o("Members"),e[127]=o,e[128]=Ee):Ee=e[128];let Le;e[129]!==p||e[130]!==l||e[131]!==pt||e[132]!==K||e[133]!==ae||e[134]!==o?(Le=K.length===0?n("div",{className:"p-3",children:n(et,{testId:"org-members-empty",title:o("No members.")})}):n(rt,{columns:pt,rowActions:M=>T(ht,{children:[n(j,{"data-testid":`org-member-role-${S(M.id)}`,onClick:()=>{i({kind:"member-role",member:M})},size:"xs",type:"button",variant:"ghost",children:o("Change role")}),n(j,{"data-testid":`org-remove-member-${S(M.id)}`,disabled:p,onClick:()=>{ae(()=>l.removeAuthOrgMember({memberId:S(M.id)}))},size:"xs",type:"button",variant:"ghost",children:o("Remove")})]}),rowPrefix:"org-member",rows:K}),e[129]=p,e[130]=l,e[131]=pt,e[132]=K,e[133]=ae,e[134]=o,e[135]=Le):Le=e[135];let je;e[136]!==Te||e[137]!==Ee||e[138]!==Le?(je=n(tt,{action:Te,heading:Ee,testId:"org-members",children:Le}),e[136]=Te,e[137]=Ee,e[138]=Le,e[139]=je):je=e[139];let Pe;e[140]!==p||e[141]!==l||e[142]!==vt||e[143]!==R||e[144]!==ae||e[145]!==o?(Pe=R.length>0&&n(tt,{heading:o("Invitations"),testId:"org-invitations",children:n(rt,{columns:vt,rowActions:M=>n(j,{"data-testid":`org-cancel-invitation-${S(M.id)}`,disabled:p,onClick:()=>{ae(()=>l.cancelAuthOrgInvitation({invitationId:S(M.id)}))},size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),rowPrefix:"org-invitation",rows:R})}),e[140]=p,e[141]=l,e[142]=vt,e[143]=R,e[144]=ae,e[145]=o,e[146]=Pe):Pe=e[146];let Je;e[147]!==ft||e[148]!==m||e[149]!==o||e[150]!==yt||e[151]!==re||e[152]!==c?(Je=c&&n(tt,{action:n(j,{"data-testid":"org-open-create-team",onClick:()=>{i({kind:"team-create"})},size:"xs",type:"button",variant:"outline",children:o("New team")}),heading:o("Teams"),testId:"org-teams",children:re.length===0?n("div",{className:"p-3",children:n(et,{testId:"org-teams-empty",title:o("No teams.")})}):n(rt,{columns:yt,rowActions:M=>T(ht,{children:[n(j,{"aria-pressed":m===S(M.id),"data-testid":`org-team-select-${S(M.id)}`,onClick:()=>{d(S(M.id))},size:"xs",type:"button",variant:"ghost",children:o("Members")}),n(j,{"data-testid":`org-team-rename-${S(M.id)}`,onClick:()=>{i({kind:"team-rename",team:M})},size:"xs",type:"button",variant:"ghost",children:o("Rename")}),n(j,{"data-testid":`org-team-delete-${S(M.id)}`,onClick:()=>{ft(M)},size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),rowPrefix:"org-team",rows:re})}),e[147]=ft,e[148]=m,e[149]=o,e[150]=yt,e[151]=re,e[152]=c,e[153]=Je):Je=e[153];let Ue;e[154]!==p||e[155]!==l||e[156]!==ae||e[157]!==m||e[158]!==o||e[159]!==It||e[160]!==ee||e[161]!==c?(Ue=c&&m!==null&&n(tt,{action:n(j,{"data-testid":"org-open-add-team-member",onClick:()=>{i({kind:"team-add-member",teamId:m})},size:"xs",type:"button",variant:"outline",children:o("Add member")}),heading:o("Team members"),testId:"org-team-members",children:ee.length===0?n("div",{className:"p-3",children:n(et,{testId:"org-team-members-empty",title:o("No team members.")})}):n(rt,{columns:It,rowActions:M=>n(j,{"data-testid":`org-team-remove-member-${S(M.id)}`,disabled:p,onClick:()=>{ae(()=>l.removeAuthOrgTeamMember({teamMemberId:S(M.id)}))},size:"xs",type:"button",variant:"ghost",children:o("Remove")}),rowPrefix:"org-team-member",rows:ee})}),e[154]=p,e[155]=l,e[156]=ae,e[157]=m,e[158]=o,e[159]=It,e[160]=ee,e[161]=c,e[162]=Ue):Ue=e[162];let Be;e[163]!==l||e[164]!==wt||e[165]!==Y||e[166]!==s||e[167]!==o?(Be=s&&n(tt,{action:n(j,{"data-testid":"org-open-create-role",onClick:()=>{i({kind:"role-create"})},size:"xs",type:"button",variant:"outline",children:o("New role")}),heading:o("Roles"),testId:"org-roles",children:Y.length===0?n("div",{className:"p-3",children:n(et,{testId:"org-roles-empty",title:o("No custom roles.")})}):n(rt,{columns:wt,rowActions:M=>T(ht,{children:[n(j,{"data-testid":`org-role-edit-${S(M.id)}`,onClick:()=>{i({kind:"role-edit",role:M})},size:"xs",type:"button",variant:"ghost",children:o("Edit")}),n(j,{"data-testid":`org-role-delete-${S(M.id)}`,onClick:()=>{i({action:()=>l.deleteAuthOrgRole({roleId:S(M.id)}),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),rowPrefix:"org-role",rows:Y})}),e[163]=l,e[164]=wt,e[165]=Y,e[166]=s,e[167]=o,e[168]=Be):Be=e[168];let He;e[169]!==a?.kind||e[170]!==r||e[171]!==A?(He=a?.kind==="add-member"&&n(Bt,{onClose:E,onDone:A,organizationId:r}),e[169]=a?.kind,e[170]=r,e[171]=A,e[172]=He):He=e[172];let qe;e[173]!==a?.kind||e[174]!==r||e[175]!==A?(qe=a?.kind==="invite-member"&&n(Ht,{onClose:E,onDone:A,organizationId:r}),e[173]=a?.kind,e[174]=r,e[175]=A,e[176]=qe):qe=e[176];let Ke;e[177]!==a||e[178]!==A?(Ke=a?.kind==="member-role"&&n(qt,{member:a.member,onClose:E,onDone:A}),e[177]=a,e[178]=A,e[179]=Ke):Ke=e[179];let Qe;e[180]!==a?.kind||e[181]!==r||e[182]!==A?(Qe=a?.kind==="team-create"&&n(xt,{mode:"create",onClose:E,onDone:A,organizationId:r}),e[180]=a?.kind,e[181]=r,e[182]=A,e[183]=Qe):Qe=e[183];let Ge;e[184]!==a||e[185]!==r||e[186]!==A?(Ge=a?.kind==="team-rename"&&n(xt,{mode:"edit",onClose:E,onDone:A,organizationId:r,team:a.team}),e[184]=a,e[185]=r,e[186]=A,e[187]=Ge):Ge=e[187];let Ve;e[188]!==a||e[189]!==A?(Ve=a?.kind==="team-add-member"&&n(Kt,{onClose:E,onDone:A,teamId:a.teamId}),e[188]=a,e[189]=A,e[190]=Ve):Ve=e[190];let We;e[191]!==a?.kind||e[192]!==r||e[193]!==A?(We=a?.kind==="role-create"&&n(zt,{mode:"create",onClose:E,onDone:A,organizationId:r}),e[191]=a?.kind,e[192]=r,e[193]=A,e[194]=We):We=e[194];let Xe;e[195]!==a||e[196]!==r||e[197]!==A?(Xe=a?.kind==="role-edit"&&n(zt,{mode:"edit",onClose:E,onDone:A,organizationId:r,role:a.role}),e[195]=a,e[196]=r,e[197]=A,e[198]=Xe):Xe=e[198];let Ye;e[199]!==a||e[200]!==A?(Ye=a?.kind==="confirm"&&n(Mt,{action:a.action,message:a.message,onClose:E,onDone:A,testId:a.testId,title:a.title}),e[199]=a,e[200]=A,e[201]=Ye):Ye=e[201];let ut;return e[202]!==Oe||e[203]!==De||e[204]!==je||e[205]!==Pe||e[206]!==Je||e[207]!==Ue||e[208]!==Be||e[209]!==He||e[210]!==qe||e[211]!==Ke||e[212]!==Qe||e[213]!==Ge||e[214]!==Ve||e[215]!==We||e[216]!==Xe||e[217]!==Ye?(ut=T("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Oe,De,je,Pe,Je,Ue,Be,He,qe,Ke,Qe,Ge,Ve,We,Xe,Ye]}),e[202]=Oe,e[203]=De,e[204]=je,e[205]=Pe,e[206]=Je,e[207]=Ue,e[208]=Be,e[209]=He,e[210]=qe,e[211]=Ke,e[212]=Qe,e[213]=Ge,e[214]=Ve,e[215]=We,e[216]=Xe,e[217]=Ye,e[218]=ut):ut=e[218],ut};function Gt(t){return n(me,{children:t.head},t.head)}function Vt(t){return n("span",{className:"font-mono text-xs",children:S(t.userId)})}function Wt(t){return S(t.role)}function Xt(t){return S(t.email)}function Yt(t){return S(t.role)}function Zt(t){return S(t.status)}function er(t){return S(t.id)}function tr(t){return S(t.name)}function rr(t){return n("span",{className:"font-mono text-xs",children:S(t.userId)})}function or(t){return S(t.role)}function nr(t){return S(t.permission)}const $r=()=>{const t=G(62),e=le(),r=W(),{config:s,ready:c}=Tt(),l=s.capabilities.organization,[o,a]=P(null),[i,m]=P(null);let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-orgs"],t[0]=d):d=t[0];let p;t[1]!==e?(p=()=>e.listAuthOrganizations({limit:100}),t[1]=e,t[2]=p):p=t[2];let u;t[3]!==l?(u={enabled:l},t[3]=l,t[4]=u):u=t[4];const g=Ze(d,p,u),C=g.data?.rows??null;let b;t[5]!==g?(b=()=>{g.refetch()},t[5]=g,t[6]=b):b=t[6],Dt(b,l);let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(null)},t[7]=v):v=t[7];const $=v;let f;t[8]!==g?(f=()=>{g.refetch()},t[8]=g,t[9]=f):f=t[9];const w=f;let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=F=>{a(F)},t[10]=h):h=t[10];const x=h;if(c&&!l){let F;t[11]!==r?(F=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=F):F=t[12];let R;t[13]!==r?(R=r("Organizations are not enabled."),t[13]=r,t[14]=R):R=t[14];let H;return t[15]!==F||t[16]!==R?(H=n(et,{description:F,testId:"org-disabled",title:R}),t[15]=F,t[16]=R,t[17]=H):H=t[17],H}let y;t[18]!==r?(y=r("Organizations"),t[18]=r,t[19]=y):y=t[19];let I;t[20]!==y?(I=n("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),t[20]=y,t[21]=I):I=t[21];let z;t[22]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{m({kind:"create"})},t[22]=z):z=t[22];let O;t[23]!==r?(O=r("New organization"),t[23]=r,t[24]=O):O=t[24];let N;t[25]!==O?(N=n(j,{"data-testid":"org-new",onClick:z,size:"sm",type:"button",children:O}),t[25]=O,t[26]=N):N=t[26];let k;t[27]!==N||t[28]!==I?(k=T("div",{className:"flex items-center justify-between",children:[I,N]}),t[27]=N,t[28]=I,t[29]=k):k=t[29];let D;t[30]!==g.error?(D=g.error!==null&&n("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[30]=g.error,t[31]=D):D=t[31];let _;t[32]!==C||t[33]!==r?(_=C!==null&&C.length===0&&n(et,{testId:"org-empty",title:r("No organizations.")}),t[32]=C,t[33]=r,t[34]=_):_=t[34];let J;t[35]!==C||t[36]!==o||t[37]!==r?(J=C!==null&&C.length>0&&n(kt,{className:"overflow-hidden py-0",children:n(St,{className:"px-0",children:T(Ot,{"data-testid":"org-table",children:[n(Nt,{children:T(bt,{children:[n(me,{children:r("id")}),n(me,{children:r("name")}),n(me,{children:r("slug")}),n(me,{children:r("created")}),n(me,{"aria-label":r("Actions")})]})}),n(At,{children:C.map(F=>{const R=S(F.id);return T(bt,{"data-testid":`org-row-${R}`,children:[n(de,{className:"font-mono text-xs",children:R}),n(de,{children:S(F.name)}),n(de,{children:S(F.slug)}),n(de,{className:"text-muted-foreground tabular-nums",children:jt(F.createdAt)}),n(de,{children:T("div",{className:"flex justify-end gap-1",children:[n(j,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:()=>{x(R)},size:"xs",type:"button",variant:"ghost",children:r("Manage")}),n(j,{"data-testid":`org-edit-${R}`,onClick:()=>{m({kind:"edit",org:F})},size:"xs",type:"button",variant:"ghost",children:r("Edit")}),n(j,{"data-testid":`org-delete-${R}`,onClick:()=>{m({kind:"delete",org:F})},size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[35]=C,t[36]=o,t[37]=r,t[38]=J):J=t[38];let q;t[39]!==s.organization||t[40]!==o?(q=o!==null&&n(Qt,{organizationId:o,rolesEnabled:s.organization.roles,teamsEnabled:s.organization.teams}),t[39]=s.organization,t[40]=o,t[41]=q):q=t[41];let U;t[42]!==i?.kind||t[43]!==w?(U=i?.kind==="create"&&n($t,{mode:"create",onClose:$,onDone:w}),t[42]=i?.kind,t[43]=w,t[44]=U):U=t[44];let L;t[45]!==i||t[46]!==w?(L=i?.kind==="edit"&&n($t,{mode:"edit",onClose:$,onDone:w,org:i.org}),t[45]=i,t[46]=w,t[47]=L):L=t[47];let B;t[48]!==e||t[49]!==i||t[50]!==w||t[51]!==r?(B=i?.kind==="delete"&&n(Mt,{action:async()=>{const F=S(i.org.id);await e.deleteAuthOrganization({organizationId:F}),a(R=>R===F?null:R)},message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:$,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=i,t[50]=w,t[51]=r,t[52]=B):B=t[52];let K;return t[53]!==k||t[54]!==D||t[55]!==_||t[56]!==J||t[57]!==q||t[58]!==U||t[59]!==L||t[60]!==B?(K=T("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[k,D,_,J,q,U,L,B]}),t[53]=k,t[54]=D,t[55]=_,t[56]=J,t[57]=q,t[58]=U,t[59]=L,t[60]=B,t[61]=K):K=t[61],K};export{$r as OrganizationsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as B}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as N}from"../packem_shared/badge-BbuuAio7.js";import{c as y,u as w}from"../packem_shared/card-CIDGUN6K.js";import{E as S}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as A,d as D,m as b,p,f as I,u as n}from"../packem_shared/table-DdJBrClo.js";import{N as v}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{S as C}from"../packem_shared/home-panel-CU6MWLHG.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as g}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{i as E}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as e,jsxs as o}from"react/jsx-runtime";const F=["subscriptions","events"],G={},P=new Set(["active","trialing"]),H=new Set(["past_due","unpaid"]),s=(a,t)=>{if(a[t]!==void 0)return a[t];const m=a.__doc__;if(typeof m=="string")try{const d=JSON.parse(m);if(d!==null&&typeof d=="object"&&!Array.isArray(d))return d[t]}catch{}},i=a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"",J=a=>P.has(a)?"default":H.has(a)?"destructive":"outline",re=({limit:a=100})=>{const t=M(),m=C(),{data:d}=v(g.listTables,G,{live:!0}),T=d!==void 0,_=Array.isArray(d)&&F.every(r=>d.some(c=>c.name===r)),f=m.payments&&_,l=v(g.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),u=v(g.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});O(()=>{f&&(l.refetch(),u.refetch())},!0);const h=l.data?.rows??[],$=u.data?.rows??[],j=l.error??u.error,R=l.error===null?u.errorSource:l.errorSource,x=h.filter(r=>P.has(i(s(r,"state")))).length,k=$.toSorted((r,c)=>Number(s(c,"processedAt")??0)-Number(s(r,"processedAt")??0));return T&&!f?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(S,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, …) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):o("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[e("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:o(y,{className:"justify-between gap-0 py-0",children:[o("div",{className:"flex flex-col gap-2.5 p-4",children:[e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),o("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:x}),e(N,{variant:"default",children:t("{count} active",{count:x})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),j===null?void 0:e(B,{error:R}),h.length===0&&!l.isLoading?e(S,{testId:"payments-empty",title:t("No subscriptions yet")}):e(y,{className:"overflow-hidden py-0",children:e(w,{className:"px-0",children:o(A,{children:[e(D,{children:o(b,{children:[e(p,{children:t("Provider")}),e(p,{children:t("Reference")}),e(p,{children:t("Plan")}),e(p,{children:t("State")}),e(p,{children:t("Renews")})]})}),e(I,{children:h.map(r=>{const c=i(s(r,"state"));return o(b,{"data-testid":"payment-subscription-row",children:[e(n,{children:i(s(r,"provider"))}),e(n,{children:i(s(r,"referenceId"))}),e(n,{children:i(s(r,"priceId"))}),e(n,{children:e(N,{variant:J(c),children:c})}),e(n,{children:E(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),o(y,{className:"overflow-hidden py-0",children:[e("header",{className:"border-b border-border px-4 py-3",children:e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),e(w,{className:"px-0",children:e(A,{children:e(I,{children:k.map(r=>o(b,{"data-testid":"payment-event-row",children:[e(n,{children:i(s(r,"provider"))}),e(n,{className:"font-medium",children:i(s(r,"type"))}),e(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),e(n,{children:E(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})};export{re as PaymentsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as h,useRef as he,useEffect as ie}from"react";import{f as xe,m as ye,n as ge,u as de,c as ce}from"../packem_shared/card-CIDGUN6K.js";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as me}from"react/compiler-runtime";import{E as be}from"../packem_shared/error-alert-t6cpEi0z.js";import{L as Ne}from"../packem_shared/live-status-CmuRLFKf.js";import{g as Y}from"../packem_shared/badge-BbuuAio7.js";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{E as pe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as ve,d as we,m as oe,p as te,f as ke,u as ae}from"../packem_shared/table-DdJBrClo.js";import{N as re}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useLunora as fe}from"@lunora/react";import{ShardInput as Pe}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as G}from"../packem_shared/input-JHu63lTv.js";import{p as M}from"../packem_shared/label-6uP1obNF.js";import{l as Se}from"../packem_shared/textarea-Bu2-jKAs.js";import{d as Ce,g as Ie,b as _e,f as le}from"../packem_shared/internal-BSIsQVC6.js";const se=["read","insert","update","delete"],$e=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Ae=e=>{const t=new Set;for(const i of e?.advisories??[])if(i.name==="rls_uncovered_table"){const{table:n}=i.metadata;typeof n=="string"&&n!==""&&t.add(n)}return t},Fe=(e,t,i)=>{const n=new Map,r=d=>{const o=n.get(d);if(o!==void 0)return o;const p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:d,uncovered:i.has(d)};return n.set(d,p),p};for(const d of e)r(d.table).cells[d.on]={procedure:d.procedure};for(const d of t)r(d.table).maskedColumns.add(d.column);for(const d of i)r(d);return[...n.values()].toSorted((d,o)=>d.table.localeCompare(o.table))},Ee=e=>{const t=me(17);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const{onProbe:n}=i,r=ee();let d,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={},o={live:!0},t[2]=d,t[3]=o):(d=t[2],o=t[3]);const p=re(Z.rlsPolicies,d,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const g=re(Z.maskPolicies,l);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u={},t[5]=u):u=t[5];const b=re(Z.getAdvisories,u);let N;if(t[6]!==b.data||t[7]!==g.data||t[8]!==n||t[9]!==p||t[10]!==r){let v=null;p.data!==void 0&&(v=Array.isArray(p.data.policies)?p.data.policies:[]);const A=Array.isArray(g.data?.columns)?g.data.columns:[],O=b.data??null,{error:S,errorSource:w,liveError:C}=p,_=v===null?[]:Fe(v,A,Ae(O));let k;t[12]!==C?(k=a("div",{className:"flex items-center justify-end",children:a(Ne,{message:C,prefix:"pm"})}),t[12]=C,t[13]=k):k=t[13];let x;t[14]!==S||t[15]!==w?(x=S!==null&&a(be,{error:w,testId:"pm-error"}),t[14]=S,t[15]=w,t[16]=x):x=t[16],N=s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&_.length===0?a(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):s(ve,{"data-testid":"pm-table",children:[a(we,{children:s(oe,{children:[a(te,{children:r("Table")}),se.map(c=>a(te,{children:$e(r,c)},c)),a(te,{children:r("Masked columns")})]})}),a(ke,{children:_.map(c=>s(oe,{"data-testid":`pm-row-${c.table}`,children:[a(ae,{className:"font-mono text-xs",children:s("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&a(Y,{"data-testid":`pm-uncovered-${c.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),se.map(I=>{const y=c.cells[I];return a(ae,{"data-testid":`pm-cell-${c.table}-${I}`,children:y.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):s("span",{className:"flex flex-col gap-1",children:[a(Y,{variant:"secondary",children:r("Covered by {procedure}",{procedure:y.procedure})}),n!==void 0&&a(R,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${I}`,onClick:()=>{n(c.table,I,y.procedure??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},I)}),a(ae,{children:c.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Te)})})]},c.table))})]})]}),t[6]=b.data,t[7]=g.data,t[8]=n,t[9]=p,t[10]=r,t[11]=N}else N=t[11];return N};function Te(e){return a(Y,{variant:"outline",children:e},e)}const Le=Ie(Z.runAs),Re=()=>{const e=fe();return async({args:t,functionPath:i,shardKey:n="",userId:r})=>{const d=Le;try{return{kind:"allowed",value:await e.query(d,{args:t,functionPath:i,userId:r},Ce(n))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},Me=e=>e===void 0?"undefined":JSON.stringify(e,null,2),Oe=({functions:e,prefill:t,runAsIdentity:i=!1}={})=>{const n=fe(),r=ee(),d=Re(),[o,p]=h(null),[l,g]=h(null),u=e??o??[],[b,N]=h(""),[v,A]=h("{}"),[O,S]=h(""),[w,C]=h(""),[_,k]=h(!1),[x,c]=h(null),[I,y]=h(null),$=he(-1);ie(()=>{if(e!==void 0)return;let m=!1;return n.listFunctions().then(f=>(m||p(f),f)).catch(f=>{m||g(_e(f))}),()=>{m=!0}},[n,e]),ie(()=>{if(t===void 0||$.current===t.nonce)return;$.current=t.nonce;const m=t.functionPath;queueMicrotask(()=>{N(m),c(null)})},[t]);const P=b===""?u[0]?.path??"":b,F=async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(f){y(r("Invalid JSON args: {message}",{message:f.message})),c(null);return}y(null),k(!0);try{const f=await d({args:m,functionPath:P,shardKey:O.trim(),userId:w.trim()});c(f)}finally{k(!1)}},E=()=>{le(F())},B=m=>{N(m.target.value)},T=m=>{A(m.target.value)},L=m=>{C(m.target.value)};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!i&&a(pe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),s("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-function",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 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:B,value:P,children:u.map(m=>s("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-args",children:r("Arguments")}),a(Se,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:T,value:v})]}),a(Pe,{onChange:S,testId:"pp-shard",value:O}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(G,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:L,placeholder:r("Leave empty to run as admin"),value:w})]}),s("div",{className:"flex items-center gap-2",children:[a(R,{"data-testid":"pp-run",disabled:!i||_||P==="",onClick:E,type:"button",children:r(_?"Probing…":"Run probe")}),w.trim()!==""&&a(Y,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:w.trim()})})]})]}),I!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),x!==null&&x.kind==="allowed"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a(Y,{variant:"secondary",children:r("Allowed")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Me(x.value)})]}),x!==null&&x.kind==="denied"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a(Y,{variant:"destructive",children:r("Denied")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},ze="/__lunora/policy-scaffold",je={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},qe=async e=>{const t=await fetch(ze,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await t.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(t.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};const n=i.error;return{kind:"error",message:n===void 0?`policy scaffold failed (${String(t.status)})`:je[n]??n}},ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Je=()=>{const e=me(69),t=ee(),[i,n]=h(null),[r,d]=h(!1),[o,p]=h(null),[l,g]=h(ne);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=X=>{const K=X.target.name,{value:Q}=X.target;g(ue=>({...ue,[K]:Q}))},e[0]=u):u=e[0];const b=u;let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{n(null),g(ne)},e[1]=N):N=e[1];const v=N;let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=async X=>{d(!0),p(null);try{const K=await qe(X);p(K),K.kind==="ok"&&v()}catch(K){const Q=K;p({kind:"error",message:Q instanceof Error?Q.message:String(Q)})}d(!1)},e[2]=A):A=e[2];const O=A;let S;e[3]!==l.policyName||e[4]!==l.tableName?(S=()=>{le(O({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=S):S=e[5];const w=S;let C;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(C=()=>{le(O({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=C):C=e[9];const _=C;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{p(null),n("scaffold")},e[10]=k):k=e[10];const x=k;let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{p(null),n("wire")},e[11]=c):c=e[11];const I=c;let y;e[12]!==t?(y=t("Scaffold access rules"),e[12]=t,e[13]=y):y=e[13];let $;e[14]!==y?($=a(xe,{children:y}),e[14]=y,e[15]=$):$=e[15];let P;e[16]!==t?(P=t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=t,e[17]=P):P=e[17];let F;e[18]!==P?(F=a(ye,{children:P}),e[18]=P,e[19]=F):F=e[19];let E;e[20]!==F||e[21]!==$?(E=s(ge,{children:[$,F]}),e[20]=F,e[21]=$,e[22]=E):E=e[22];const B=i==="scaffold"?"default":"outline";let T;e[23]!==t?(T=t("New policy file"),e[23]=t,e[24]=T):T=e[24];let L;e[25]!==B||e[26]!==T?(L=a(R,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:B,children:T}),e[25]=B,e[26]=T,e[27]=L):L=e[27];const m=i==="wire"?"default":"outline";let f;e[28]!==t?(f=t("Wire into a procedure"),e[28]=t,e[29]=f):f=e[29];let z;e[30]!==m||e[31]!==f?(z=a(R,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:m,children:f}),e[30]=m,e[31]=f,e[32]=z):z=e[32];let j;e[33]!==L||e[34]!==z?(j=s("div",{className:"flex flex-wrap gap-2",children:[L,z]}),e[33]=L,e[34]=z,e[35]=j):j=e[35];let q;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==i||e[40]!==w||e[41]!==t?(q=i==="scaffold"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(G,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:b,value:l.policyName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(G,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:b,value:l.tableName})]}),a(R,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=i,e[40]=w,e[41]=t,e[42]=q):q=e[42];let J;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==i||e[48]!==_||e[49]!==t?(J=i==="wire"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(G,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:b,value:l.filePath})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(G,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:b,value:l.exportName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(G,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:b,value:l.policies})]}),a(R,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:_,size:"xs",type:"button",children:t(r?"Wiring…":"Wire RLS")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=i,e[48]=_,e[49]=t,e[50]=J):J=e[50];let D;e[51]!==o?(D=o?.kind==="error"&&a("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=D):D=e[52];let W;e[53]!==o?.kind||e[54]!==t?(W=o?.kind==="needs-manual-edit"&&a("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=t,e[55]=W):W=e[55];let U;e[56]!==o||e[57]!==t?(U=o?.kind==="ok"&&s("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[a("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&a("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(De)})]}),e[56]=o,e[57]=t,e[58]=U):U=e[58];let H;e[59]!==j||e[60]!==q||e[61]!==J||e[62]!==D||e[63]!==W||e[64]!==U?(H=s(de,{children:[j,q,J,D,W,U]}),e[59]=j,e[60]=q,e[61]=J,e[62]=D,e[63]=W,e[64]=U,e[65]=H):H=e[65];let V;return e[66]!==E||e[67]!==H?(V=s(ce,{"data-testid":"policy-scaffolder",size:"sm",children:[E,H]}),e[66]=E,e[67]=H,e[68]=V):V=e[68],V};function De(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const nt=({functions:e,runAsIdentity:t=!1,schemaEditable:i=!1}={})=>{const n=ee(),[r,d]=h(void 0),o=(p,l,g)=>{g!==""&&d(u=>({functionPath:g,nonce:(u?.nonce??0)+1}))};return s("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[s("section",{className:"flex flex-col gap-3",children:[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("Permissions")})}),a(Ee,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:s(ce,{className:"gap-0 py-0",children:[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("Probe")})}),s(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:n("Pick a function and an identity, then run it to see the access outcome.")}),a(Oe,{functions:e,prefill:r,runAsIdentity:t})]})]})}),i&&a("section",{className:"flex flex-col gap-2",children:a(Je,{})})]})};export{nt as PermissionsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as P}from"react/compiler-runtime";import{useLunora as Ke}from"@lunora/react";import{useState as _}from"react";import{E as Ve}from"../packem_shared/error-alert-t6cpEi0z.js";import{A as Xe}from"../packem_shared/alert-CVcOFuDR.js";import{g as Qe}from"../packem_shared/badge-BbuuAio7.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{c as ke,u as Oe}from"../packem_shared/card-CIDGUN6K.js";import{E as Ie}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ye}from"../packem_shared/input-JHu63lTv.js";import{p as Ze}from"../packem_shared/scroll-area-DTEq6Jec.js";import{n as Be,d as Je,m as de,p as $,f as Fe,u as w}from"../packem_shared/table-DdJBrClo.js";import{l as et}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as De}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as tt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as j}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{d as $e,b as we,g as Ae,i as at,f as Ce}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as a,jsxs as b,Fragment as We}from"react/jsx-runtime";const st=(r,e)=>{const t=new Set(r.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),u=r.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!t.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:u,showReliabilityWarning:u.length>0||d>0}},rt=200,nt=Ae(j.sendQueueMessage),ot=Ae(j.replayQueueMessage),dt=Ae(j.clearQueueMessages),Re=96,lt=r=>{if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"[unserializable]"}},ut=r=>r.length>Re?`${r.slice(0,Re)}…`:r,ct=r=>r==="error"?"destructive":r==="retry"?"outline":"secondary",it=(r,e)=>e(r==="messages"?"Messages":r==="send"?"Send":"Declared"),mt=r=>{const e=P(11),{loaded:t,queues:u}=r,d=U();let s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=a("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let n;e[4]!==t||e[5]!==u||e[6]!==d?(n=t&&u.length===0?a(Ie,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:b(Be,{"data-testid":"queues-table",children:[a(Je,{children:b(de,{children:[a($,{children:d("Export")}),a($,{children:d("Queue")}),a($,{children:d("Mode")}),a($,{children:d("Binding")}),a($,{children:d("Dead-letter")})]})}),a(Fe,{children:u.map(ft)})]})})}),e[4]=t,e[5]=u,e[6]=d,e[7]=n):n=e[7];let h;return e[8]!==o||e[9]!==n?(h=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,n]}),e[8]=o,e[9]=n,e[10]=h):h=e[10],h},ht=r=>{const e=P(67),{message:t,onReplay:u,replayingId:d}=r,s=U();let o,n,h,i,y,p,x,l,m,g;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==s){const J=lt(t.body);n=de,p=`queues-message-${t.id}`;const F=t.exportName??t.queue;e[19]!==F?(x=a(w,{className:"font-mono text-xs",children:F}),e[19]=F,e[20]=x):x=e[20],e[21]!==t.messageId?(l=a(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=l):l=e[22],e[23]!==t.attempts?(m=a(w,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const E=`queues-outcome-${t.id}`;let L;e[25]!==t.outcome?(L=ct(t.outcome),e[25]=t.outcome,e[26]=L):L=e[26];let C;e[27]!==t.outcome||e[28]!==E||e[29]!==L?(C=a(Qe,{"data-testid":E,variant:L,children:t.outcome}),e[27]=t.outcome,e[28]=E,e[29]=L,e[30]=C):C=e[30];let M;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==s?(M=t.deadLettered&&a(Qe,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:s("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=s,e[34]=M):M=e[34],e[35]!==C||e[36]!==M?(g=a(w,{children:b("span",{className:"inline-flex items-center gap-1",children:[C,M]})}),e[35]=C,e[36]=M,e[37]=g):g=e[37],o=w,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=J,y=ut(J),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=s,e[9]=o,e[10]=n,e[11]=h,e[12]=i,e[13]=y,e[14]=p,e[15]=x,e[16]=l,e[17]=m,e[18]=g}else o=e[9],n=e[10],h=e[11],i=e[12],y=e[13],p=e[14],x=e[15],l=e[16],m=e[17],g=e[18];let f;e[38]!==o||e[39]!==h||e[40]!==i||e[41]!==y?(f=a(o,{className:h,title:i,children:y}),e[38]=o,e[39]=h,e[40]=i,e[41]=y,e[42]=f):f=e[42];let q;e[43]!==t.capturedAt?(q=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=q):q=e[44];let N;e[45]!==q?(N=a(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=N):N=e[46];const S=`queues-replay-${t.id}`,A=d!==null;let Q;e[47]!==t.id||e[48]!==d||e[49]!==s?(Q=d===t.id?s("Replaying…"):s("Replay"),e[47]=t.id,e[48]=d,e[49]=s,e[50]=Q):Q=e[50];let I;e[51]!==t.id||e[52]!==u||e[53]!==S||e[54]!==A||e[55]!==Q?(I=a(w,{children:a(oe,{"data-id":t.id,"data-testid":S,disabled:A,onClick:u,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=u,e[53]=S,e[54]=A,e[55]=Q,e[56]=I):I=e[56];let T;return e[57]!==n||e[58]!==N||e[59]!==I||e[60]!==p||e[61]!==x||e[62]!==l||e[63]!==m||e[64]!==g||e[65]!==f?(T=b(n,{"data-testid":p,children:[x,l,m,g,f,N,I]}),e[57]=n,e[58]=N,e[59]=I,e[60]=p,e[61]=x,e[62]=l,e[63]=m,e[64]=g,e[65]=f,e[66]=T):T=e[66],T},pt=r=>{const e=P(26),{hasError:t,messages:u,onClear:d,onReplay:s,replayingId:o}=r,n=U();let h;e[0]!==n?(h=n("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=n,e[1]=h):h=e[1];let i;e[2]!==h?(i=a("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=i):i=e[3];const y=u.length===0;let p;e[4]!==n?(p=n("Clear log"),e[4]=n,e[5]=p):p=e[5];let x;e[6]!==d||e[7]!==y||e[8]!==p?(x=a(oe,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[6]=d,e[7]=y,e[8]=p,e[9]=x):x=e[9];let l;e[10]!==u.length||e[11]!==n?(l=u.length>0&&a(Qe,{"data-testid":"queues-count",variant:"secondary",children:n("{count} messages",{count:u.length})}),e[10]=u.length,e[11]=n,e[12]=l):l=e[12];let m;e[13]!==i||e[14]!==x||e[15]!==l?(m=b("div",{className:"flex flex-wrap items-center gap-2",children:[i,x,l]}),e[13]=i,e[14]=x,e[15]=l,e[16]=m):m=e[16];let g;e[17]!==t||e[18]!==u||e[19]!==s||e[20]!==o||e[21]!==n?(g=!t&&u.length===0?a(Ie,{description:n("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:n("No consumed messages yet.")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:a(Ze,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Be,{"data-testid":"queues-messages-table",children:[a(Je,{children:b(de,{children:[a($,{children:n("Export")}),a($,{children:n("Message")}),a($,{children:n("Attempts")}),a($,{children:n("Outcome")}),a($,{children:n("Body")}),a($,{children:n("Captured")}),a($,{})]})}),a(Fe,{children:u.map(q=>a(ht,{message:q,onReplay:s,replayingId:o},q.id))})]})})})}),e[17]=t,e[18]=u,e[19]=s,e[20]=o,e[21]=n,e[22]=g):g=e[22];let f;return e[23]!==m||e[24]!==g?(f=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]}),e[23]=m,e[24]=g,e[25]=f):f=e[25],f},gt=r=>{const e=P(20),{batchMode:t,bodyText:u,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:n,onSelectExport:h,onSend:i,queues:y,selectedExportName:p,sending:x}=r,l=U();let m;e[0]!==l?(m=l("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=l,e[1]=m):m=e[1];let g;e[2]!==m?(g=a("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=g):g=e[3];let f;e[4]!==t||e[5]!==u||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==n||e[10]!==h||e[11]!==i||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==l?(f=y.length===0?a(Ie,{description:l("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:l("No queues to send to")}):b(We,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[a("select",{"aria-label":l("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(xt)}),a(Ye,{"aria-label":l("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:n,placeholder:l("Delay (s)"),type:"number",value:d}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[a("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),l("Send as batch (JSON array)")]}),a(oe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:i,type:"button",children:l(x?"Sending…":"Send message")})]}),a(et,{"aria-label":l("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:u})]}),e[4]=t,e[5]=u,e[6]=d,e[7]=s,e[8]=o,e[9]=n,e[10]=h,e[11]=i,e[12]=y,e[13]=p,e[14]=x,e[15]=l,e[16]=f):f=e[16];let q;return e[17]!==g||e[18]!==f?(q=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,f]}),e[17]=g,e[18]=f,e[19]=q):q=e[19],q},Bt=r=>{const e=P(59),{limit:t}=r,u=t??rt,d=Ke(),s=U(),[o,n]=_("declared"),[h,i]=_(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];const{data:p,error:x,errorSource:l}=De(j.listQueues,y);let m;e[1]!==u?(m={limit:u},e[1]=u,e[2]=m):m=e[2];const{data:g,error:f,errorSource:q,refetch:N}=De(j.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(yt):[],A=g?.entries??[],{deadLetteredCount:Q,queuesWithoutDlq:I,showReliabilityWarning:T}=st(S,A),[J,F]=_(""),[E,L]=_(""),[C,M]=_(""),[W,ze]=_(!1),[le,Ee]=_(!1),[ue,Le]=_(null),G=S.some(c=>c.exportName===J)?J:S[0]?.exportName??"",Me=o==="messages"?f:x,je=o==="messages"?q:l,ce=Me??h,ie=Me===null?h:je;let H;e[3]!==N?(H=()=>{N()},e[3]=N,e[4]=H):H=e[4],tt(H,o==="messages");const me=async()=>{i(null);const c=G;if(c==="")return;let v=null;const _e=E.trim();if(_e!=="")try{v=JSON.parse(_e)}catch{i(s("Body must be valid JSON."));return}let Se;const Te=C.trim();if(Te!==""){const z=Number(Te);if(!Number.isFinite(z)||z<0){i(s("Delay must be a non-negative number of seconds."));return}Se=z}if(W&&!Array.isArray(v)){i(s("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ee(!0);const He=W?{batch:v,delaySeconds:Se,exportName:c}:{body:v,delaySeconds:Se,exportName:c};try{await d.query(nt,He,$e("")),N()}catch(z){i(we(z))}Ee(!1)};let K;e[5]!==d||e[6]!==N?(K=async c=>{i(null),Le(c);try{await d.query(ot,{id:c},$e("")),N()}catch(v){i(we(v))}Le(null)},e[5]=d,e[6]=N,e[7]=K):K=e[7];const he=K;let V;e[8]!==d||e[9]!==N?(V=async()=>{i(null);try{await d.query(dt,{},$e("")),N()}catch(c){i(we(c))}},e[8]=d,e[9]=N,e[10]=V):V=e[10];const pe=V;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const v=c.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&n(v)},e[11]=X):X=e[11];const Pe=X;let Y;e[12]===Symbol.for("react.memo_cache_sentinel")?(Y=c=>{F(c.currentTarget.value)},e[12]=Y):Y=e[12];const ge=Y;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{L(c.currentTarget.value)},e[13]=Z):Z=e[13];const fe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{M(c.currentTarget.value)},e[14]=ee):ee=e[14];const xe=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{ze(c.currentTarget.checked)},e[15]=te):te=e[15];const ye=te;let ae;e[16]!==me?(ae=()=>{Ce(me())},e[16]=me,e[17]=ae):ae=e[17];const Ne=ae;let se;e[18]!==he?(se=c=>{const{id:v}=c.currentTarget.dataset;v!==void 0&&Ce(he(v))},e[18]=he,e[19]=se):se=e[19];const be=se;let re;e[20]!==pe?(re=()=>{Ce(pe())},e[20]=pe,e[21]=re):re=e[21];const qe=re,Ue="flex flex-col gap-6",Ge="lunora-queues-panel";let D;e[22]!==s||e[23]!==o?(D=a("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>a(oe,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:it(c,s)},c))}),e[22]=s,e[23]=o,e[24]=D):D=e[24];let R;e[25]!==ce||e[26]!==ie?(R=ce!==null&&a(Ve,{error:ie,testId:"queues-error"}),e[25]=ce,e[26]=ie,e[27]=R):R=e[27];const ve=T&&a(Xe,{icon:a("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[I.length>0&&b(We,{children:[a("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:I.map(Nt).join(", ")})}),a("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),Q>0&&a("p",{className:I.length>0?"text-muted-foreground":"font-medium",children:Q===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:Q})})]})});let k;e[28]!==S||e[29]!==p||e[30]!==o?(k=o==="declared"&&a(mt,{loaded:p!==void 0,queues:S}),e[28]=S,e[29]=p,e[30]=o,e[31]=k):k=e[31];let O;e[32]!==A||e[33]!==f||e[34]!==qe||e[35]!==be||e[36]!==ue||e[37]!==o?(O=o==="messages"&&a(pt,{hasError:f!==null,messages:A,onClear:qe,onReplay:be,replayingId:ue}),e[32]=A,e[33]=f,e[34]=qe,e[35]=be,e[36]=ue,e[37]=o,e[38]=O):O=e[38];let B;e[39]!==W||e[40]!==E||e[41]!==C||e[42]!==ye||e[43]!==fe||e[44]!==xe||e[45]!==ge||e[46]!==Ne||e[47]!==S||e[48]!==G||e[49]!==le||e[50]!==o?(B=o==="send"&&a(gt,{batchMode:W,bodyText:E,delayText:C,onBatchModeChange:ye,onBodyChange:fe,onDelayChange:xe,onSelectExport:ge,onSend:Ne,queues:S,selectedExportName:G,sending:le}),e[39]=W,e[40]=E,e[41]=C,e[42]=ye,e[43]=fe,e[44]=xe,e[45]=ge,e[46]=Ne,e[47]=S,e[48]=G,e[49]=le,e[50]=o,e[51]=B):B=e[51];let ne;return e[52]!==D||e[53]!==R||e[54]!==ve||e[55]!==k||e[56]!==O||e[57]!==B?(ne=b("div",{className:Ue,"data-testid":Ge,children:[D,R,ve,k,O,B]}),e[52]=D,e[53]=R,e[54]=ve,e[55]=k,e[56]=O,e[57]=B,e[58]=ne):ne=e[58],ne};function ft(r){return b(de,{"data-testid":`queues-row-${r.exportName}`,children:[a(w,{className:"font-mono text-xs",children:r.exportName}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.name}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.mode}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.binding}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.deadLetterQueue??"—"})]},r.exportName)}function xt(r){return a("option",{value:r.exportName,children:r.exportName},r.exportName)}function yt(r,e){return r.exportName.localeCompare(e.exportName)}function Nt(r){return r.name}export{Bt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as F}from"react/compiler-runtime";import{E as J}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as z}from"../packem_shared/badge-BbuuAio7.js";import{u as C,c as D}from"../packem_shared/card-CIDGUN6K.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as G,d as M,m as E,p as A,f as O,u as S}from"../packem_shared/table-DdJBrClo.js";import{N as K}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";const U=["read","insert","update","delete"],q=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],B=e=>{const t=new Map;for(const s of e){const l=t.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),t.set(s.table,l)}return[...t.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},ae=()=>{const e=F(49),t=V();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:I,errorSource:R}=K(W.rlsPolicies,s),c=l!==void 0;let p,n,m,a,h,f,u,x,i;if(e[1]!==l||e[2]!==I||e[3]!==R||e[4]!==c||e[5]!==t){const T=B(Array.isArray(l?.policies)?l.policies:[]);let k;e[15]!==l?(k=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=k):k=e[16],n=k,u="flex flex-col gap-6",x="lunora-rls-panel",e[17]!==I||e[18]!==R?(i=I!==null&&r(J,{error:R,testId:"rls-error"}),e[17]=I,e[18]=R,e[19]=i):i=e[19],f="flex flex-col gap-2",p=D,m="overflow-hidden py-0";let v;e[20]!==t?(v=t("Policies"),e[20]=t,e[21]=v):v=e[21],e[22]!==v?(a=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v})}),e[22]=v,e[23]=a):a=e[23],h=c&&T.length===0?r(j,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):r(C,{className:"px-0",children:o(G,{"data-testid":"rls-policies-table",children:[r(M,{children:o(E,{children:[r(A,{children:t("Table")}),U.map(d=>r(A,{children:q(t,d)},d)),r(A,{children:t("Guarded by")})]})}),r(O,{children:T.map(d=>o(E,{"data-testid":`rls-table-${d.table}`,children:[r(S,{className:"font-mono text-xs",children:d.table}),U.map(_=>r(S,{children:d.operations.has(_)?r(z,{variant:"secondary",children:t("Guarded")}):r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},_)),r(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=I,e[3]=R,e[4]=c,e[5]=t,e[6]=p,e[7]=n,e[8]=m,e[9]=a,e[10]=h,e[11]=f,e[12]=u,e[13]=x,e[14]=i}else p=e[6],n=e[7],m=e[8],a=e[9],h=e[10],f=e[11],u=e[12],x=e[13],i=e[14];let N;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==h?(N=o(p,{className:m,children:[a,h]}),e[24]=p,e[25]=m,e[26]=a,e[27]=h,e[28]=N):N=e[28];let b;e[29]!==f||e[30]!==N?(b=r("section",{className:f,children:N}),e[29]=f,e[30]=N,e[31]=b):b=e[31];let g;e[32]!==t?(g=t("Roles"),e[32]=t,e[33]=g):g=e[33];let y;e[34]!==g?(y=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[34]=g,e[35]=y):y=e[35];let $;e[36]!==c||e[37]!==n||e[38]!==t?($=c&&n.length===0?r(j,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):r(C,{className:"px-0",children:o(G,{"data-testid":"rls-roles-table",children:[r(M,{children:o(E,{children:[r(A,{children:t("Role")}),r(A,{children:t("Description")}),r(A,{children:t("Permissions")})]})}),r(O,{children:n.map(L)})]})}),e[36]=c,e[37]=n,e[38]=t,e[39]=$):$=e[39];let w;e[40]!==y||e[41]!==$?(w=r("section",{className:"flex flex-col gap-2",children:o(D,{className:"overflow-hidden py-0",children:[y,$]})}),e[40]=y,e[41]=$,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==x||e[46]!==i||e[47]!==b?(P=o("div",{className:u,"data-testid":x,children:[i,b,w]}),e[43]=w,e[44]=u,e[45]=x,e[46]=i,e[47]=b,e[48]=P):P=e[48],P};function H(e){return r(z,{variant:"outline",children:e},e)}function L(e){return o(E,{"data-testid":`rls-role-${e.name}`,children:[r(S,{className:"font-mono text-xs",children:e.name}),r(S,{className:"text-muted-foreground",children:e.description??""}),r(S,{children:e.permissions.length===0?r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):r("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(H)})})]},e.name)}export{ae as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as M}from"react/compiler-runtime";import{useState as _}from"react";import{u as Z}from"../packem_shared/button-BkCrNcAs.js";import{useT as B}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{useLunora as E}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{g as Y}from"../packem_shared/badge-BbuuAio7.js";import{c as T,u as A}from"../packem_shared/card-CIDGUN6K.js";import{E as W}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as z,d as K,m as I,p as x,f as V,u as b}from"../packem_shared/table-DdJBrClo.js";import{O}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{f as R,b as H,i as X}from"../packem_shared/internal-BSIsQVC6.js";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-D8kBZWBu.js";const te={kind:"idle"},oe=(n,e,c)=>c!==void 0?c:e===void 0?d=>n.runCronJob(d):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=E(),d=B(),[f,a]=_({}),r=O(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:o,error:k}=r,h=oe(c,n,e),i=async l=>{if(h!==void 0){a(s=>({...s,[l]:{kind:"running"}}));try{await h(l),a(s=>({...s,[l]:{kind:"ok"}})),r.refetch()}catch(s){a(v=>({...v,[l]:{kind:"error",message:H(s)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:k}),o?.length===0&&t(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&t(T,{className:"overflow-hidden py-0",children:t(A,{className:"px-0",children:m(z,{"data-testid":"cron-table",children:[t(K,{children:m(I,{children:[t(x,{children:d("name")}),t(x,{children:d("schedule")}),t(x,{children:d("target")}),t(x,{children:d("shard")}),h!==void 0&&t(x,{"aria-label":d("Actions")})]})}),t(V,{children:o.map(l=>{const s=f[l.name]??te;return m(I,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(Y,{variant:"outline",children:d("function")}):t(Y,{variant:"secondary",children:d("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[s.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:d("ran")}),s.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:s.message}),t(G,{confirmLabel:d("Run now?"),disabled:s.kind==="running",onConfirm:()=>{R(i(l.name))},testId:`cron-run-${l.name}`,children:s.kind==="running"?d("Running…"):d("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},re=n=>Number.isFinite(n)?X(n,"—"):"—",ne=n=>{const e=M(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:d,removeJob:f,retryJob:a}=c,r=E(),o=B();let k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=["lunora-dead-jobs"],e[2]=k):k=e[2];let h;e[3]!==r||e[4]!==d?(h=async()=>(await(d??(()=>r.listDeadJobs()))()).toSorted(ae),e[3]=r,e[4]=d,e[5]=h):h=e[5];const i=O(k,h),l=i.data,[s,v]=_(void 0),N=i.error??s,u=d===void 0;let w;e[6]!==r||e[7]!==u||e[8]!==a?(w=a??(u?p=>r.retryDeadJob(p):void 0),e[6]=r,e[7]=u,e[8]=a,e[9]=w):w=e[9];const g=w;let $;e[10]!==r||e[11]!==u||e[12]!==f?($=f??(u?p=>r.removeDeadJob(p):void 0),e[10]=r,e[11]=u,e[12]=f,e[13]=$):$=e[13];const C=$;let J;e[14]!==i?(J=()=>{i.refetch()},e[14]=i,e[15]=J):J=e[15],Q(J,!0);let j;e[16]!==i?(j=async p=>{v(void 0);try{await p,i.refetch()}catch(U){v(H(U))}},e[16]=i,e[17]=j):j=e[17];const S=j,L=g!==void 0||C!==void 0;let q;e[18]!==N?(q=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=q):q=e[19];let y;e[20]!==l?.length||e[21]!==o?(y=l?.length===0&&t(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("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 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=l?.length,e[21]=o,e[22]=y):y=e[22];let P;e[23]!==S||e[24]!==L||e[25]!==l||e[26]!==C||e[27]!==g||e[28]!==o?(P=l!==void 0&&l.length>0&&t(T,{className:"overflow-hidden py-0",children:t(A,{className:"px-0",children:m(z,{"data-testid":"dlq-table",children:[t(K,{children:m(I,{children:[t(x,{children:o("function")}),t(x,{children:o("attempts")}),t(x,{children:o("last tried")}),t(x,{children:o("pool")}),t(x,{children:o("shard")}),t(x,{children:o("id")}),L&&t(x,{"aria-label":o("Actions")})]})}),t(V,{children:l.map(p=>m(I,{"data-testid":`dlq-row-${p.id}`,children:[t(b,{className:"font-mono text-xs",children:p.functionPath}),t(b,{className:"tabular-nums",children:p.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:re(p.scheduledFor)}),t(b,{className:"font-mono text-xs",children:p.pool??""}),t(b,{children:p.shardKey??""}),t(b,{className:"font-mono text-xs",children:p.id}),L&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&t(Z,{"data-testid":`dlq-retry-${p.id}`,onClick:()=>{R(S(g(p.id)))},size:"sm",type:"button",variant:"outline",children:o("Retry")}),C!==void 0&&t(G,{confirmLabel:o("Drop job?"),onConfirm:()=>{R(S(C(p.id)))},testId:`dlq-remove-${p.id}`,children:o("Drop")})]})})]},p.id))})]})})}),e[23]=S,e[24]=L,e[25]=l,e[26]=C,e[27]=g,e[28]=o,e[29]=P):P=e[29];let D;return e[30]!==P||e[31]!==q||e[32]!==y?(D=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[q,y,P]}),e[30]=P,e[31]=q,e[32]=y,e[33]=D):D=e[33],D};function ae(n,e){return(e.attempts??0)-(n.attempts??0)}const F=n=>{const e=M(8),{label:c,testId:d,value:f}=n;let a;e[0]!==c?(a=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=a):a=e[1];let r;e[2]!==d||e[3]!==f?(r=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=t(T,{className:"flex-1 py-0",children:m(A,{className:"flex flex-col gap-1 p-4",children:[a,r]})}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o},de=n=>{const e=M(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:d}=c,f=E(),a=B(),r=d===void 0;let o;e[2]!==r?(o=["lunora-scheduler-status",r],e[2]=r,e[3]=o):o=e[3];let k;e[4]!==f||e[5]!==d?(k=async()=>{const $=await(d??(()=>f.schedulerStatus()))();return{...$,pools:$.pools.toSorted(ie)}},e[4]=f,e[5]=d,e[6]=k):k=e[6];const h=O(o,k),{data:i,error:l}=h;let s;e[7]!==h?(s=()=>{h.refetch()},e[7]=h,e[8]=s):s=e[8],Q(s,!0);let v;e[9]!==l?(v=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=v):v=e[10];let N;e[11]!==i||e[12]!==a?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(F,{label:a("backlog"),testId:"pools-backlog",value:i.backlog}),t(F,{label:a("in flight"),testId:"pools-inflight",value:i.inFlight}),t(F,{label:a("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=a,e[13]=N):N=e[13];let u;e[14]!==i?.pools.length||e[15]!==a?(u=i?.pools.length===0&&t(W,{description:a("Pools created with createWorkpool appear here once they have activity."),icon:t("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 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:a("No workpools.")}),e[14]=i?.pools.length,e[15]=a,e[16]=u):u=e[16];let w;e[17]!==i||e[18]!==a?(w=i!==void 0&&i.pools.length>0&&t(T,{className:"overflow-hidden py-0",children:t(A,{className:"px-0",children:m(z,{"data-testid":"pools-table",children:[t(K,{children:m(I,{children:[t(x,{children:a("pool")}),t(x,{children:a("queued")}),t(x,{children:a("in flight")}),t(x,{children:a("max concurrency")})]})}),t(V,{children:i.pools.map(se)})]})})}),e[17]=i,e[18]=a,e[19]=w):w=e[19];let g;return e[20]!==v||e[21]!==N||e[22]!==u||e[23]!==w?(g=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[v,N,u,w]}),e[20]=v,e[21]=N,e[22]=u,e[23]=w,e[24]=g):g=e[24],g};function ie(n,e){return e.queued-n.queued}function se(n){return m(I,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Je=n=>{const e=M(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:d,scheduledCancel:f,scheduledLoad:a}=c,r=B(),[o,k]=_("jobs");let h;e[2]!==r?(h=r("Cron triggers"),e[2]=r,e[3]=h):h=e[3];let i;e[4]!==r?(i=r("Dead letter"),e[4]=r,e[5]=i):i=e[5];let l;e[6]!==r?(l=r("Scheduled jobs"),e[6]=r,e[7]=l):l=e[7];let s;e[8]!==r?(s=r("Pools"),e[8]=r,e[9]=s):s=e[9];let v;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==s?(v={cron:h,dead:i,jobs:l,pools:s},e[10]=h,e[11]=i,e[12]=l,e[13]=s,e[14]=v):v=e[14];const N=v;let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=y=>{k(y.currentTarget.dataset.view)},e[15]=u):u=e[15];const w=u;let g;e[16]!==r?(g=r("Schedule view"),e[16]=r,e[17]=g):g=e[17];let $;e[18]!==o||e[19]!==N?($=ce.map(y=>t(Z,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:w,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:N[y]},y)),e[18]=o,e[19]=N,e[20]=$):$=e[20];let C;e[21]!==g||e[22]!==$?(C=t("div",{"aria-label":g,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:$}),e[21]=g,e[22]=$,e[23]=C):C=e[23];let J;e[24]!==f||e[25]!==a||e[26]!==o?(J=o==="jobs"&&t(ee,{cancelJob:f,loadJobs:a}),e[24]=f,e[25]=a,e[26]=o,e[27]=J):J=e[27];let j;e[28]!==o?(j=o==="dead"&&t(ne,{}),e[28]=o,e[29]=j):j=e[29];let S;e[30]!==o?(S=o==="pools"&&t(de,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&t(le,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let q;return e[35]!==C||e[36]!==J||e[37]!==j||e[38]!==S||e[39]!==L?(q=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[C,J,j,S,L]}),e[35]=C,e[36]=J,e[37]=j,e[38]=S,e[39]=L,e[40]=q):q=e[40],q};export{Je as SchedulePanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as m}from"react/compiler-runtime";import{B as u,E as f}from"../packem_shared/bar-chart-DraN_srt.js";import{jsx as c}from"react/jsx-runtime";const d={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},b=n=>{const e=m(6),{data:o}=n;let a,r;if(e[0]!==o){r=Symbol.for("react.early_return_sentinel");e:{const s=o.slice(-16);if(s.length<3){r=null;break e}a=s.map(h)}e[0]=o,e[1]=a,e[2]=r}else a=e[1],r=e[2];if(r!==Symbol.for("react.early_return_sentinel"))return r;const i=a;let t;e[3]===Symbol.for("react.memo_cache_sentinel")?(t=c(u,{dataKey:"value"}),e[3]=t):t=e[3];let l;return e[4]!==i?(l=c("div",{"aria-hidden":"true",className:"h-8 w-28",children:c(f,{animationType:"none",barCategoryGap:1,className:"h-8 w-full",config:d,data:i,children:t})}),e[4]=i,e[5]=l):l=e[5],l};function h(n,e){return{index:e,value:n}}export{b as Sparkline};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as $}from"react/compiler-runtime";import{E as b}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as y}from"../packem_shared/badge-BbuuAio7.js";import{c as k,u as S}from"../packem_shared/card-CIDGUN6K.js";import{E as w}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as R,d as v,m as x,p as u,f as A,u as p}from"../packem_shared/table-DdJBrClo.js";import{N as E}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{jsx as t,jsxs as f}from"react/jsx-runtime";const C=(e,r)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[r],N={delete:2,list:3,read:0,write:1},T=e=>[...e].toSorted((r,s)=>r.bucket.localeCompare(s.bucket)||N[r.on]-N[s.on]||(r.prefix??"").localeCompare(s.prefix??"")),U=()=>{const e=$(14),r=j();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:i,errorSource:d}=E(I.storageRules,s),h=l!==void 0;let n;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==r){const g=T(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==i||e[8]!==d?(c=i!==null&&t(b,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=c):c=e[9];let a;e[10]!==r?(a=r("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=r,e[11]=a):a=e[11];let m;e[12]!==a?(m=t("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:a}),e[12]=a,e[13]=m):m=e[13],n=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&g.length===0?t(w,{description:r("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:r("No storage rules defined")}):t(k,{className:"overflow-hidden py-0",children:t(S,{className:"px-0",children:f(R,{"data-testid":"storage-rules-table",children:[t(v,{children:f(x,{children:[t(u,{children:r("Bucket")}),t(u,{children:r("Operation")}),t(u,{children:r("Key prefix")}),t(u,{children:r("Guarded by")})]})}),t(A,{children:g.map(o=>f(x,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[t(p,{className:"font-mono text-xs",children:o.bucket}),t(p,{children:t(y,{variant:"secondary",children:C(r,o.on)})}),t(p,{className:"font-mono text-xs",children:o.prefix??t("span",{className:"text-muted-foreground",children:r("(whole bucket)")})}),t(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=r,e[6]=n}else n=e[6];return n};export{U as StorageRulesPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as T}from"react/compiler-runtime";import{useState as j}from"react";import{E as P}from"../packem_shared/error-alert-t6cpEi0z.js";import{ShardInput as _}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as I}from"../packem_shared/badge-BbuuAio7.js";import{c as D,u as F}from"../packem_shared/card-CIDGUN6K.js";import{E as K}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as L,d as O,m as C,p as N,f as U,u as g}from"../packem_shared/table-DdJBrClo.js";import{N as W}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as B}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import J from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as R}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{jsx as e,jsxs as c}from"react/jsx-runtime";const E=80,X=a=>{if(a===void 0)return"";const t=JSON.stringify(a);return t.length>E?`${t.slice(0,E)}…`:t},Z=a=>{const t=[];for(const o of a){const n=o.id.toString();if(o.subscriptions.length===0){t.push({admin:o.admin,connectionId:o.id,key:`c${n}`,subscription:null});continue}o.subscriptions.forEach((r,S)=>{t.push({admin:o.admin,connectionId:o.id,key:`c${n}-s${S.toString()}`,subscription:r})})}return t},w=e("span",{className:"text-muted-foreground",children:"—"}),at=a=>{const t=T(22),{initialShardKey:o}=a,n=Q(),[r,S]=j(o??"");let u;t[0]!==r?(u=r.trim(),t[0]=r,t[1]=u):u=t[1];const y=J(u,400);let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h={},t[2]=h):h=t[2];let p;t[3]!==y?(p={keepPreviousData:!0,shardKey:y},t[3]=y,t[4]=p):p=t[4];const{data:i,error:s,errorSource:m,refetch:M}=W(R.listSubscriptions,h,p);B(M,!0);let f;if(t[5]!==s||t[6]!==m||t[7]!==i||t[8]!==r||t[9]!==n){const $=i===void 0?[]:Z(i.connections);let l;t[11]!==r?(l=e(_,{onChange:S,testId:"subs-shard-input",value:r}),t[11]=r,t[12]=l):l=t[12];let d;t[13]!==i||t[14]!==n?(d=i!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[e(I,{variant:"secondary",children:n("{count} connections",{count:i.totalConnections})}),e(I,{variant:"secondary",children:n("{count} subscriptions",{count:i.totalSubscriptions})})]}),t[13]=i,t[14]=n,t[15]=d):d=t[15];let b;t[16]!==l||t[17]!==d?(b=c("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),t[16]=l,t[17]=d,t[18]=b):b=t[18];let v;t[19]!==s||t[20]!==m?(v=s!==null&&e(P,{error:m,testId:"subs-error"}),t[19]=s,t[20]=m,t[21]=v):v=t[21],f=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[b,v,s===null&&i!==void 0&&$.length===0&&e(K,{description:n("Active WebSocket subscriptions on this shard."),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:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),s===null&&$.length>0&&e(D,{className:"overflow-hidden py-0",children:e(F,{className:"px-0",children:c(L,{"data-testid":"subs-table",children:[e(O,{children:c(C,{children:[e(N,{children:n("Connection")}),e(N,{children:n("Function path")}),e(N,{children:n("Table")}),e(N,{children:n("Arguments")})]})}),e(U,{children:$.map(x=>{const{subscription:k}=x,A=X(k?.args);return c(C,{"data-testid":"subs-row",children:[e(g,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",x.connectionId,x.admin&&e(I,{variant:"outline",children:n("admin")})]})}),e(g,{className:"font-mono text-xs",children:k?.functionPath??w}),e(g,{children:k?.table??w}),e(g,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:A||void 0,children:A||w})]},x.key)})})]})})})]}),t[5]=s,t[6]=m,t[7]=i,t[8]=r,t[9]=n,t[10]=f}else f=t[10];return f};export{at as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as z}from"react/compiler-runtime";import{useLunora as D}from"@lunora/react";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{c as K,u as L}from"../packem_shared/card-CIDGUN6K.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as A,d as E,m as _,p as i,f as M,u as c}from"../packem_shared/table-DdJBrClo.js";import{O as Y}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as B}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as F}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";const G=2e3,H=new Set(["open"]),re=O=>{const e=z(41),{read:x}=O,n=F(),P=D();let S;e[0]!==P||e[1]!==x?(S=()=>Promise.resolve(x?x():P.debug()),e[0]=P,e[1]=x,e[2]=S):S=e[2];const W=S,R=x?"injected":"live";let v;e[3]!==R?(v=["lunora-studio","sync-client-debug",R],e[3]=R,e[4]=v):v=e[4];const{data:l,refetch:q}=Y(v,W);if(B(q,!0,G),!l){let r;e[5]!==n?(r=n("Reading the sync client's state…"),e[5]=n,e[6]=r):r=e[6];let y;e[7]!==n?(y=n("Sync client"),e[7]=n,e[8]=y):y=e[8];let w;return e[9]!==r||e[10]!==y?(w=t(K,{children:t(L,{children:t(j,{description:r,title:y})})}),e[9]=r,e[10]=y,e[11]=w):w=e[11],w}const{pendingWrites:$,shards:b,subscriptions:N}=l;let o;e[12]!==n?(o=n("This Studio session's sync client"),e[12]=n,e[13]=o):o=e[13];let d;e[14]!==o?(d=t("span",{className:"text-sm font-medium",children:o}),e[14]=o,e[15]=d):d=e[15];const T=l.connectionStatus==="connected"?"default":"secondary";let a;e[16]!==l.connectionStatus||e[17]!==T?(a=t(C,{variant:T,children:l.connectionStatus}),e[16]=l.connectionStatus,e[17]=T,e[18]=a):a=e[18];let h;e[19]!==$||e[20]!==n?(h=$>0?t(C,{variant:"secondary",children:n("{count} pending writes",{count:$})}):null,e[19]=$,e[20]=n,e[21]=h):h=e[21];let u;e[22]!==d||e[23]!==a||e[24]!==h?(u=s("div",{className:"flex flex-wrap items-center gap-2",children:[d,a,h]}),e[22]=d,e[23]=a,e[24]=h,e[25]=u):u=e[25];let m;e[26]!==n?(m=n("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=n,e[27]=m):m=e[27];let p;e[28]!==m?(p=t("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=p):p=e[29];let f;e[30]!==b||e[31]!==n?(f=b.length===0?t(j,{description:n("No shard connection has been opened yet."),title:n("No shards")}):s(A,{children:[t(E,{children:s(_,{children:[t(i,{children:n("Shard")}),t(i,{children:n("Socket")}),t(i,{children:n("Confirmed watermark")})]})}),t(M,{children:b.map(r=>s(_,{children:[t(c,{children:r.shardKey??n("(default)")}),t(c,{children:t(C,{variant:H.has(r.wsState)?"default":"secondary",children:r.wsState})}),t(c,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=b,e[31]=n,e[32]=f):f=e[32];let g;e[33]!==N||e[34]!==n?(g=N.length===0?t(j,{description:n("This client holds no live queries or shapes."),title:n("No subscriptions")}):s(A,{children:[t(E,{children:s(_,{children:[t(i,{children:n("Subscription")}),t(i,{children:n("Kind")}),t(i,{children:n("Acked")}),t(i,{children:n("Cursor")}),t(i,{children:n("Pending overlays")})]})}),t(M,{children:N.map(r=>s(_,{children:[t(c,{className:"font-mono text-xs",children:r.functionPath}),t(c,{children:r.kind}),t(c,{children:t(C,{variant:r.acked?"default":"secondary",children:r.acked?n("yes"):n("no")})}),t(c,{children:r.serverCursor??"—"}),t(c,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=N,e[34]=n,e[35]=g):g=e[35];let k;return e[36]!==p||e[37]!==f||e[38]!==g||e[39]!==u?(k=t(K,{children:s(L,{className:"flex flex-col gap-4",children:[u,p,f,g]})}),e[36]=p,e[37]=f,e[38]=g,e[39]=u,e[40]=k):k=e[40],k};export{re as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as z}from"react/compiler-runtime";import{useState as Q,useEffect as J}from"react";import{f as Y}from"../packem_shared/log-fields-CoL3hsIQ.js";import{E as Z}from"../packem_shared/error-alert-t6cpEi0z.js";import{L as ee}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as te}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as re}from"../packem_shared/badge-BbuuAio7.js";import{E as ae}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as se}from"../packem_shared/input-JHu63lTv.js";import{N as ne}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import oe from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{i as ie}from"../packem_shared/internal-BSIsQVC6.js";import{r as de}from"../packem_shared/shard-history-DMEW5VBE.js";import{p as ce,c as me}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as B}from"react/jsx-runtime";const V=o=>Math.min(100,Math.max(0,o)),he=(o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=V(o.offsetMs/e*100),a=o.durationMs/e*100,r=Math.max(.5,Math.min(V(a),100-t));return{leftPercent:t,widthPercent:r}},fe=(o,e)=>{const t=e.trim().toLowerCase();return t===""?[...o]:o.filter(a=>a.rootName.toLowerCase().includes(t)||a.functionPath.toLowerCase().includes(t)||a.traceId.toLowerCase().includes(t))},U=o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"—",pe=14,ge=o=>Array.isArray(o?.traces)?o.traces:[],xe=o=>{const e=z(50),{span:t,traceDurationMs:a}=o,r=G();let n;e[0]!==t||e[1]!==a?(n=he(t,a),e[0]=t,e[1]=a,e[2]=n):n=e[2];const{leftPercent:S,widthPercent:x}=n;let P;e[3]!==t.attributes?(P=Y(t.attributes),e[3]=t.attributes,e[4]=P):P=e[4];const M=P,L=t.depth*pe;let y;e[5]!==L?(y={paddingLeft:L},e[5]=L,e[6]=y):y=e[6];const b=y,c=`${String(S)}%`,w=`${String(x)}%`;let p;e[7]!==c||e[8]!==w?(p={left:c,width:w},e[7]=c,e[8]=w,e[9]=p):p=e[9];const l=p,f=t.depth;let i;e[10]!==t.ok||e[11]!==r?(i=t.ok?null:s("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"●"}),e[10]=t.ok,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==b||e[14]!==t.name||e[15]!==i?(v=B("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:b,title:t.name,children:[i,t.name]}),e[13]=b,e[14]=t.name,e[15]=i,e[16]=v):v=e[16];let d;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(d=r("starts {offset} in, runs {duration}",{duration:U(t.durationMs),offset:U(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=d):d=e[20];const N=t.ok?"bg-primary/70":"bg-destructive";let m;e[21]!==N?(m=ue("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=m):m=e[22];let u;e[23]!==l||e[24]!==S||e[25]!==m||e[26]!==x?(u=s("span",{className:m,"data-left":S,"data-testid":"tr-span-bar","data-width":x,style:l}),e[23]=l,e[24]=S,e[25]=m,e[26]=x,e[27]=u):u=e[27];let h;e[28]!==d||e[29]!==u?(h=s("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:u}),e[28]=d,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==t.durationMs?(g=U(t.durationMs),e[31]=t.durationMs,e[32]=g):g=e[32];let k;e[33]!==g?(k=s("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:g}),e[33]=g,e[34]=k):k=e[34];let I;e[35]!==t.error?(I=t.error===void 0?null:s("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=I):I=e[36];let $;e[37]!==I?($=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:I}),e[37]=I,e[38]=$):$=e[38];let C;e[39]!==M?(C=M===""?null:s("span",{"data-testid":"tr-span-attributes",title:M,children:M}),e[39]=M,e[40]=C):C=e[40];let T;e[41]!==C?(T=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[41]=C,e[42]=T):T=e[42];let F;return e[43]!==t.depth||e[44]!==v||e[45]!==h||e[46]!==k||e[47]!==$||e[48]!==T?(F=B("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":f,"data-testid":"tr-span-row",role:"row",children:[v,h,k,$,T]}),e[43]=t.depth,e[44]=v,e[45]=h,e[46]=k,e[47]=$,e[48]=T,e[49]=F):F=e[49],F},be=o=>{const e=z(50),{expanded:t,onToggle:a,trace:r}=o,n=G();let S;e[0]!==a||e[1]!==r.traceId?(S=()=>{a(r.traceId)},e[0]=a,e[1]=r.traceId,e[2]=S):S=e[2];const x=S,P=`tr-row-${r.traceId}`,M=`tr-waterfall-${r.traceId}`,L=`tr-toggle-${r.traceId}`,y=t?"▾":"▸";let b;e[3]!==y?(b=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:y}),e[3]=y,e[4]=b):b=e[4];let c;e[5]!==r.rootName?(c=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=c):c=e[6];let w;e[7]!==r.functionPath?(w=s("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let p;e[9]!==r.durationMs?(p=U(r.durationMs),e[9]=r.durationMs,e[10]=p):p=e[10];let l;e[11]!==p?(l=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:p}),e[11]=p,e[12]=l):l=e[12];let f;e[13]!==n||e[14]!==r.spans.length?(f=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=f):f=e[15];let i;e[16]!==f?(i=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:f}),e[16]=f,e[17]=i):i=e[17];const v=r.ok?"secondary":"destructive";let d;e[18]!==n||e[19]!==r.ok?(d=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=d):d=e[20];let N;e[21]!==v||e[22]!==d?(N=s("span",{className:"shrink-0",children:s(re,{variant:v,children:d})}),e[21]=v,e[22]=d,e[23]=N):N=e[23];let m;e[24]!==r.startTs?(m=ie(r.startTs),e[24]=r.startTs,e[25]=m):m=e[25];let u;e[26]!==m?(u=s("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:m}),e[26]=m,e[27]=u):u=e[27];let h;e[28]!==t||e[29]!==x||e[30]!==l||e[31]!==i||e[32]!==N||e[33]!==u||e[34]!==M||e[35]!==L||e[36]!==b||e[37]!==c||e[38]!==w?(h=B("button",{"aria-controls":M,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":L,onClick:x,type:"button",children:[b,c,w,l,i,N,u]}),e[28]=t,e[29]=x,e[30]=l,e[31]=i,e[32]=N,e[33]=u,e[34]=M,e[35]=L,e[36]=b,e[37]=c,e[38]=w,e[39]=h):h=e[39];let g;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(g=t&&s("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(I=>s(xe,{span:I,traceDurationMs:r.durationMs},I.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=g):g=e[45];let k;return e[46]!==h||e[47]!==g||e[48]!==P?(k=B("div",{className:"border-b border-border last:border-b-0","data-testid":P,children:[h,g]}),e[46]=h,e[47]=g,e[48]=P,e[49]=k):k=e[49],k},Be=o=>{const e=z(44),{initialShardKey:t}=o,a=G(),[r]=Q(ce),[n,S]=Q(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[x,P]=Q(r?.traceId??""),[M,L]=Q(we);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],J(Ne,y);let b;e[1]!==n?(b=n.trim(),e[1]=n,e[2]=b):b=e[2];const c=oe(b,400);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let p;e[4]!==c?(p={live:!0,shardKey:c},e[4]=c,e[5]=p):p=e[5];const{data:l,error:f,errorSource:i,isLoading:v,liveError:d}=ne(le.getTraces,w,p);let N,m;e[6]!==l||e[7]!==c?(N=()=>{l!==void 0&&de(c)},m=[l,c],e[6]=l,e[7]=c,e[8]=N,e[9]=m):(N=e[8],m=e[9]),J(N,m);let u;if(e[10]!==l||e[11]!==f||e[12]!==i||e[13]!==M||e[14]!==v||e[15]!==d||e[16]!==x||e[17]!==n||e[18]!==a){const h=ge(l),g=l?.total??h.length,k=g>h.length,I=fe(h,x);let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=_=>{P(_.target.value)},e[20]=$):$=e[20];const C=$;let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=_=>{L(X=>{const H=new Set(X);return H.has(_)?H.delete(_):H.add(_),H})},e[21]=T):T=e[21];const F=T,W=f===null&&I.length===0&&!v;let K;e[22]!==n?(K=s(te,{onChange:S,testId:"tr-shard-input",value:n}),e[22]=n,e[23]=K):K=e[23];let A;e[24]!==a?(A=a("Search traces"),e[24]=a,e[25]=A):A=e[25];let D;e[26]!==a?(D=a("search trace or function"),e[26]=a,e[27]=D):D=e[27];let j;e[28]!==x||e[29]!==A||e[30]!==D?(j=s(se,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:C,placeholder:D,value:x}),e[28]=x,e[29]=A,e[30]=D,e[31]=j):j=e[31];let E;e[32]!==d?(E=s(ee,{message:d,prefix:"tr"}),e[32]=d,e[33]=E):E=e[33];let R;e[34]!==K||e[35]!==j||e[36]!==E?(R=B("div",{className:"flex flex-wrap items-center gap-2",children:[K,j,E]}),e[34]=K,e[35]=j,e[36]=E,e[37]=R):R=e[37];let O;e[38]!==f||e[39]!==i?(O=f!==null&&s(Z,{error:i,testId:"tr-error"}),e[38]=f,e[39]=i,e[40]=O):O=e[40];let q;e[41]!==W||e[42]!==a?(q=W&&s(ae,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[41]=W,e[42]=a,e[43]=q):q=e[43],u=B("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[R,O,q,f===null&&k&&s("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:h.length,total:g})}),f===null&&I.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:I.map(_=>s(be,{expanded:M.has(_.traceId),onToggle:F,trace:_},_.traceId))})]}),e[10]=l,e[11]=f,e[12]=i,e[13]=M,e[14]=v,e[15]=d,e[16]=x,e[17]=n,e[18]=a,e[19]=u}else u=e[19];return u};function we(){return new Set}function Ne(){me()}export{Be as TracesPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useLunora as ge}from"@lunora/react";import{useState as $,useEffect as Ve}from"react";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as $e,u as Fe}from"../packem_shared/card-CIDGUN6K.js";import{E as Je}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{n as Ue,d as Pe,m as L,p as z,f as _e,u as U}from"../packem_shared/table-DdJBrClo.js";import{O as Ke}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{c as Ne}from"react/compiler-runtime";import{u as Oe}from"../packem_shared/use-auth-config-BObBpdsi.js";import{useAutoRefresh as We}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Ze from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as Re,b as Ee}from"../packem_shared/internal-BSIsQVC6.js";import{f as Qe}from"../packem_shared/checkbox-StT4Gob6.js";import{p as V}from"../packem_shared/label-6uP1obNF.js";import{M as Ge}from"../packem_shared/modal-shell-CUwwWC2o.js";import{u as Xe}from"../packem_shared/use-async-submit-q3ymBJkD.js";import{jsx as t,jsxs as n,Fragment as Ye}from"react/jsx-runtime";const et=()=>{const u=Ne(3),{config:e,ready:s}=Oe();let l;return u[0]!==e.capabilities||u[1]!==s?(l={capabilities:e.capabilities,ready:s},u[0]=e.capabilities,u[1]=s,u[2]=l):l=u[2],l},tt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),lt=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const s=typeof e=="string"?e.trim():"";if(s!==""){if(u.type==="number"){const l=Number(s);return Number.isNaN(l)?void 0:{value:l}}return{value:s}}},st=u=>{const e=Ne(105),{onClose:s,onCreated:l}=u,c=ge(),a=ke(),{config:o}=Oe(),{busy:r,error:i,run:m}=Xe(),[k,I]=$(""),[x,w]=$(""),[y,A]=$(""),[h,g]=$("");let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[f,d]=$(v);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=p=>{I(p.target.value)},e[1]=C):C=e[1];const b=C;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=p=>{w(p.target.value)},e[2]=F):F=e[2];const T=F;let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=p=>{A(p.target.value)},e[3]=_):_=e[3];const De=_;let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=p=>{g(p.target.value)},e[4]=O):O=e[4];const je=O;let G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=(p,P)=>{d(q=>({...q,[p]:P}))},e[5]=G):G=e[5];const Se=G;let H;e[6]!==f?(H=p=>f[p.name]??(p.type==="boolean"?!1:""),e[6]=f,e[7]=H):H=e[7];const R=H;let J;if(e[8]!==o.userFields||e[9]!==R){let p;e[11]!==R?(p=P=>!P.required||at(P,R(P)),e[11]=R,e[12]=p):p=e[12],J=o.userFields.every(p),e[8]=o.userFields,e[9]=R,e[10]=J}else J=e[10];const we=J;let K;e[13]!==r||e[14]!==k||e[15]!==x||e[16]!==we?(K=!r&&k.trim()!==""&&x.trim()!==""&&we,e[13]=r,e[14]=k,e[15]=x,e[16]=we,e[17]=K):K=e[17];const Te=K;let W;e[18]!==o.userFields||e[19]!==R?(W=()=>{const p={};for(const P of o.userFields){const q=lt(P,R(P));q!==void 0&&(p[P.name]=q.value)}return Object.keys(p).length===0?void 0:p},e[18]=o.userFields,e[19]=R,e[20]=W):W=e[20];const Ce=W;let Z;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==s||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(Z=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),s()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=s,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=Z):Z=e[30];const N=Z;let D;e[31]!==a?(D=a("Create user"),e[31]=a,e[32]=D):D=e[32];let B;e[33]!==a?(B=a("Create user"),e[33]=a,e[34]=B):B=e[34];let E;e[35]!==B?(E=t("h2",{className:"text-sm font-semibold text-foreground",children:B}),e[35]=B,e[36]=E):E=e[36];let Q;e[37]!==a?(Q=a("email"),e[37]=a,e[38]=Q):Q=e[38];let X;e[39]!==Q?(X=t(V,{htmlFor:"uc-email",children:Q}),e[39]=Q,e[40]=X):X=e[40];let Y;e[41]!==k?(Y=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:k}),e[41]=k,e[42]=Y):Y=e[42];let ee;e[43]!==X||e[44]!==Y?(ee=n("div",{className:"flex flex-col gap-1",children:[X,Y]}),e[43]=X,e[44]=Y,e[45]=ee):ee=e[45];let te;e[46]!==a?(te=a("name"),e[46]=a,e[47]=te):te=e[47];let ae;e[48]!==te?(ae=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=ae):ae=e[49];let le;e[50]!==x?(le=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:x}),e[50]=x,e[51]=le):le=e[51];let se;e[52]!==ae||e[53]!==le?(se=n("div",{className:"flex flex-col gap-1",children:[ae,le]}),e[52]=ae,e[53]=le,e[54]=se):se=e[54];let re;e[55]!==a?(re=a("Password (optional)"),e[55]=a,e[56]=re):re=e[56];let ie;e[57]!==re?(ie=t(V,{htmlFor:"uc-password",children:re}),e[57]=re,e[58]=ie):ie=e[58];let ne;e[59]!==y?(ne=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:De,type:"password",value:y}),e[59]=y,e[60]=ne):ne=e[60];let de;e[61]!==ie||e[62]!==ne?(de=n("div",{className:"flex flex-col gap-1",children:[ie,ne]}),e[61]=ie,e[62]=ne,e[63]=de):de=e[63];let oe;e[64]!==a?(oe=a("Role (optional)"),e[64]=a,e[65]=oe):oe=e[65];let ce;e[66]!==oe?(ce=t(V,{htmlFor:"uc-role",children:oe}),e[66]=oe,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:je,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=n("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==o.userFields||e[74]!==R||e[75]!==a?(he=o.userFields.length>0&&n("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{const P=`uc-field-${p.name}`,q=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){const Me=R(p)===!0;return n("label",{className:"flex items-center gap-2",htmlFor:P,children:[t(Qe,{checked:Me,"data-testid":P,id:P,onCheckedChange:He=>{Se(p.name,He)}}),n("span",{className:"text-sm",children:[p.name,q]})]},p.name)}const qe=R(p);return n("div",{className:"flex flex-col gap-1",children:[n(V,{htmlFor:P,children:[p.name,q]}),t(j,{"data-testid":P,id:P,onChange:Me=>{Se(p.name,Me.target.value)},type:tt[p.type],value:typeof qe=="string"?qe:""})]},p.name)})]}),e[73]=o.userFields,e[74]=R,e[75]=a,e[76]=he):he=e[76];let pe;e[77]!==i?(pe=i!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:i}),e[77]=i,e[78]=pe):pe=e[78];let fe;e[79]!==a?(fe=a("Cancel"),e[79]=a,e[80]=fe):fe=e[80];let ve;e[81]!==s||e[82]!==fe?(ve=t(S,{"data-testid":"uc-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:fe}),e[81]=s,e[82]=fe,e[83]=ve):ve=e[83];const Be=!Te;let be;e[84]!==r||e[85]!==a?(be=a(r?"Creating…":"Create"),e[84]=r,e[85]=a,e[86]=be):be=e[86];let xe;e[87]!==N||e[88]!==Be||e[89]!==be?(xe=t(S,{"data-testid":"uc-submit",disabled:Be,onClick:N,size:"sm",type:"button",children:be}),e[87]=N,e[88]=Be,e[89]=be,e[90]=xe):xe=e[90];let ye;e[91]!==ve||e[92]!==xe?(ye=n("div",{className:"flex justify-end gap-2 pt-1",children:[ve,xe]}),e[91]=ve,e[92]=xe,e[93]=ye):ye=e[93];let ze;return e[94]!==s||e[95]!==D||e[96]!==E||e[97]!==ee||e[98]!==se||e[99]!==de||e[100]!==me||e[101]!==he||e[102]!==pe||e[103]!==ye?(ze=n(Ge,{label:D,onClose:s,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[E,ee,se,de,me,he,pe,ye]}),e[94]=s,e[95]=D,e[96]=E,e[97]=ee,e[98]=se,e[99]=de,e[100]=me,e[101]=he,e[102]=pe,e[103]=ye,e[104]=ze):ze=e[104],ze},Le=u=>{const e=Ne(2),{children:s}=u;let l;return e[0]!==s?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[0]=s,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{const b=await o.listAuthSessions({limit:50,userId:c});m(b.rows)}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l?(y=b=>{l(()=>o.revokeAuthSession({sessionId:b}))},e[7]=o,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==r?(h=r("Sessions"),e[10]=r,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Le,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=v):v=e[15];let f;e[16]!==i||e[17]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:r("No active sessions.")}),e[16]=i,e[17]=r,e[18]=f):f=e[18];let d;e[19]!==s||e[20]!==A||e[21]!==i||e[22]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-sessions-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("expires")}),t(z,{children:r("ip")}),t(z,{children:r("user agent")}),t(z,{"aria-label":r("Actions")})]})}),t(_e,{children:i.map(b=>n(L,{"data-testid":`ud-session-${b.id}`,children:[t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.expiresAt)}),t(U,{children:b.ipAddress??""}),t(U,{className:"max-w-40 truncate",children:b.userAgent??""}),t(U,{children:t(S,{"data-testid":`ud-revoke-${b.id}`,disabled:s,onClick:()=>{A(b.id)},size:"xs",type:"button",variant:"ghost",children:r("Revoke")})})]},b.id))})]})})}),e[19]=s,e[20]=A,e[21]=i,e[22]=r,e[23]=d):d=e[23];let C;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{m(await o.listAuthAccounts({userId:c}))}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l||e[9]!==c?(y=b=>{l(()=>o.unlinkAuthAccount({accountId:b,userId:c}))},e[7]=o,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==r?(h=r("Linked accounts"),e[11]=r,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Le,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=v):v=e[16];let f;e[17]!==i||e[18]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No linked accounts.")}),e[17]=i,e[18]=r,e[19]=f):f=e[19];let d;e[20]!==i||e[21]!==s||e[22]!==A||e[23]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-accounts-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(_e,{children:i.map(b=>{const F=Ae(b.id);return n(L,{"data-testid":`ud-account-${F}`,children:[t(U,{children:Ae(b.providerId)}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-unlink-${F}`,disabled:s,onClick:()=>{A(F)},size:"xs",type:"button",variant:"ghost",children:r("Unlink")})})]},F)})})]})})}),e[20]=i,e[21]=s,e[22]=A,e[23]=r,e[24]=d):d=e[24];let C;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=C):C=e[29],C},nt=u=>{const e=Ne(40),{busy:s,capabilities:l,runAction:c,userId:a,version:o}=u,r=ge(),i=ke(),[m,k]=$(null);let I;e[0]!==l.passkey||e[1]!==r||e[2]!==a?(I=()=>{l.passkey&&Re((async()=>{try{k(await r.listAuthPasskeys({userId:a}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=r,e[2]=a,e[3]=I):I=e[3];let x;e[4]!==l.passkey||e[5]!==r||e[6]!==a||e[7]!==o?(x=[l.passkey,r,a,o],e[4]=l.passkey,e[5]=r,e[6]=a,e[7]=o,e[8]=x):x=e[8],Ve(I,x);let w;e[9]!==r||e[10]!==c||e[11]!==a?(w=()=>{c(()=>r.disableAuthTwoFactor({userId:a}))},e[9]=r,e[10]=c,e[11]=a,e[12]=w):w=e[12];const y=w;let A;e[13]!==r||e[14]!==c?(A=F=>{c(()=>r.deleteAuthPasskey({passkeyId:F}))},e[13]=r,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==i?(g=i("Security"),e[16]=i,e[17]=g):g=e[17];let v;e[18]!==g?(v=t(Le,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==s||e[21]!==l.twoFactor||e[22]!==y||e[23]!==i?(f=l.twoFactor&&t(S,{"data-testid":"ud-disable-2fa",disabled:s,onClick:y,size:"sm",type:"button",variant:"outline",children:i("Disable two-factor")}),e[20]=s,e[21]=l.twoFactor,e[22]=y,e[23]=i,e[24]=f):f=e[24];let d;e[25]!==l.passkey||e[26]!==m||e[27]!==i?(d=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:i("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=i,e[28]=d):d=e[28];let C;e[29]!==s||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==i?(C=l.passkey&&m!==null&&m.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-passkeys-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(_e,{children:m.map(F=>{const T=Ae(F.id);return n(L,{"data-testid":`ud-passkey-${T}`,children:[t(U,{children:Ae(F.name)||T}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-delete-passkey-${T}`,disabled:s,onClick:()=>{h(T)},size:"xs",type:"button",variant:"ghost",children:i("Delete")})})]},T)})})]})})}),e[29]=s,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=i,e[34]=C):C=e[34];let b;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==C?(b=n("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,C]}),e[35]=v,e[36]=f,e[37]=d,e[38]=C,e[39]=b):b=e[39],b},dt=/(?:at|expires)$/iu,ot=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ct=(u,e)=>typeof e=="number"&&dt.test(u)?Ie(e):Ae(e),ut=({capabilities:u,onChanged:e,onClose:s,user:l})=>{const c=ge(),a=ke(),o=l.banned===!0,[r,i]=$(null),[m,k]=$(!1),[I,x]=$(0),[w,y]=$(typeof l.role=="string"?l.role:""),[A,h]=$(""),[g,v]=$(""),[f,d]=$(""),[C,b]=$(null),[F,T]=$(!1),_=(N,D)=>{Re((async()=>{k(!0),i(null);try{const B=await N();D?.refresh!==!1&&(x(E=>E+1),e()),D?.onResult?.(B)}catch(B){i(Ee(B))}k(!1)})())},De=N=>{y(N.target.value)},O=N=>{h(N.target.value)},je=N=>{v(N.target.value)},G=N=>{d(N.target.value)},Se=()=>{const N=w.trim();N!==""&&_(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},H=()=>{const N=Number.parseInt(g,10),D=Number.isFinite(N)&&N>0?N*86400:void 0;_(async()=>{await c.banAuthUser({expiresInSeconds:D,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},R=()=>{_(async()=>{await c.unbanAuthUser({userId:l.id})})},J=()=>{_(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{_(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{_(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{_(async()=>{await c.removeAuthUser({userId:l.id}),s()})},W=()=>{T(!0)},Ce=()=>{T(!1)},Z=Object.entries(l).filter(([N])=>!ot.has(N));return n(Ge,{label:a("User details"),onClose:s,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[n("div",{className:"flex items-start justify-between gap-2",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),n("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),o?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"outline",children:a("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:a("verified")}):t(M,{variant:"outline",children:a("unverified")})]})]}),t(S,{"data-testid":"ud-close",onClick:s,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:r}),u.admin&&n($e,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),n(Fe,{className:"flex flex-col gap-3 p-3",children:[n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:a("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:De,value:w})]}),t(S,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Se,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?t(S,{"data-testid":"ud-unban",disabled:m,onClick:R,size:"sm",type:"button",variant:"outline",children:a("Unban")}):n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:O,value:A})]}),n("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:a("Days")}),t(j,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:je,type:"number",value:g})]}),t(S,{"data-testid":"ud-ban",disabled:m,onClick:H,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:a("New password")}),t(j,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:f})]}),t(S,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:J,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),n("div",{className:"flex flex-wrap gap-2",children:[t(S,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),t(S,{"data-testid":"ud-revoke-all",disabled:m,onClick:K,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?n(Ye,{children:[t(S,{"data-testid":"ud-delete-confirm",disabled:m,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),t(S,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):t(S,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),C!==null&&n("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:a("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:_,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:_,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:_,userId:l.id,version:I}),n("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),t("dl",{className:"flex flex-col",children:Z.map(([N,D])=>n("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ct(N,D)})]},N))})]})]})},mt=50,_t=({pageSize:u=mt}={})=>{const e=ge(),s=ke(),[l,c]=$(""),[a,o]=$(""),r=Ze(l),[i,m]=$(null),[k,I]=$(!1),{capabilities:x}=et(),w=r.trim(),y=a.trim(),A=Ke(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,v=()=>{A.refetch()};We(()=>{A.refetch()},!0);const f=i===null?null:h?.find(d=>d.id===i)??null;return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":s("Search users"),className:"w-56","data-testid":"us-search",onChange:d=>{c(d.target.value)},placeholder:s("Search by email or name…"),value:l}),t(j,{"aria-label":s("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:d=>{o(d.target.value)},placeholder:s("Filter by role"),value:a}),t(S,{"data-testid":"us-new",onClick:()=>{I(!0)},size:"sm",type:"button",children:s("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Je,{description:s("Users who sign up to your app will appear here."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:s("No users.")}),h!==null&&h.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"us-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:s("id")}),t(z,{children:s("email")}),t(z,{children:s("name")}),t(z,{children:s("role")}),t(z,{children:s("status")}),t(z,{children:s("verified")}),t(z,{children:s("created")}),t(z,{"aria-label":s("Actions")})]})}),t(_e,{children:h.map(d=>n(L,{"data-testid":`us-row-${d.id}`,children:[t(U,{className:"font-mono text-xs",children:d.id}),t(U,{children:d.email??""}),t(U,{children:d.name??""}),t(U,{children:typeof d.role=="string"&&d.role!==""?t(M,{variant:"secondary",children:d.role}):""}),t(U,{children:d.banned===!0?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"success",children:s("Active")})}),t(U,{children:d.emailVerified===!0?t(M,{variant:"success",children:s("yes")}):t(M,{variant:"outline",children:s("no")})}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),t(U,{children:t(S,{"data-testid":`us-manage-${d.id}`,onClick:()=>{m(d.id)},size:"xs",type:"button",variant:"ghost",children:s("Manage")})})]},d.id))})]})})}),f!==null&&t(ut,{capabilities:x,onChanged:v,onClose:()=>{m(null)},user:f}),k&&t(st,{onClose:()=>{I(!1)},onCreated:v})]})};export{_t as UsersPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as A}from"react/compiler-runtime";import{useLunora as H}from"@lunora/react";import{useState as h,useEffect as Q}from"react";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{c as V,u as j}from"../packem_shared/card-CIDGUN6K.js";import{E as W}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as D}from"../packem_shared/input-JHu63lTv.js";import{n as q,d as E,m as N,p as o,f as L,u as i}from"../packem_shared/table-DdJBrClo.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{f as M,b as B,h as J}from"../packem_shared/internal-BSIsQVC6.js";import{jsxs as n,jsx as e}from"react/jsx-runtime";const O=10,g=x=>{const r=A(7),{label:m,value:a}=x;let l;r[0]!==m?(l=e("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),r[0]=m,r[1]=l):l=r[1];const f=a??"—";let c;r[2]!==f?(c=e("span",{className:"font-mono text-sm",children:f}),r[2]=f,r[3]=c):c=r[3];let u;return r[4]!==l||r[5]!==c?(u=n("div",{className:"flex flex-col gap-0.5",children:[l,c]}),r[4]=l,r[5]=c,r[6]=u):u=r[6],u},ce=({loadIndexes:x,runQuery:r}={})=>{const m=H(),a=G(),[l,f]=h(null),[c,u]=h(null),[v,C]=h(null),[b,F]=h(""),[p,y]=h(null),[k,w]=h(null),[I,S]=h(!1);Q(()=>{const t={cancelled:!1};return M((async()=>{try{const d=await(x??(()=>m.listVectorIndexes()))();t.cancelled||(f(d),u(null),C($=>$??d[0]?.name??null))}catch(d){t.cancelled||(f(null),u(B(d)))}})()),()=>{t.cancelled=!0}},[m,x]);const s=l?.find(t=>t.name===v)??null,K=t=>{C(t.currentTarget.dataset.index??null),y(null),w(null)},T=t=>{F(t.target.value)},Z=async()=>{const t=b.trim();if(!(v===null||t==="")){S(!0),w(null);try{const d=await(r??($=>m.queryVectorIndex($)))({name:v,text:t,topK:O});y(d)}catch(d){y(null),w(B(d))}S(!1)}},z=()=>{M(Z())};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[c!==null&&e("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:c}),l!==null&&l.length===0&&e(W,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear 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:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),l!==null&&l.length>0&&e(V,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:n(q,{"data-testid":"vector-table",children:[e(E,{children:n(N,{children:[e(o,{children:a("name")}),e(o,{children:a("table")}),e(o,{children:a("dimensions")}),e(o,{children:a("metric")}),e(o,{children:a("vectors")})]})}),e(L,{children:l.map(t=>n(N,{className:t.name===v?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:K,children:[e(i,{className:"font-mono text-xs",children:t.name}),e(i,{className:"font-mono text-xs",children:t.table}),e(i,{className:"tabular-nums",children:t.dimensions??"—"}),e(i,{children:t.metric??"—"}),e(i,{className:"tabular-nums",children:t.vectorsCount??"—"})]},t.name))})]})})}),s!==null&&n("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[n("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e(g,{label:a("field"),value:s.field}),e(g,{label:a("dimensions"),value:s.dimensions}),e(g,{label:a("metric"),value:s.metric}),e(g,{label:a("vectors"),value:s.vectorsCount})]}),s.metadata!==void 0&&s.metadata.length>0&&n("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",e("span",{className:"font-mono",children:s.metadata.join(", ")})]}),n("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e(D,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:T,placeholder:a("Search by similarity…"),value:b}),e(R,{"data-testid":"vector-search",disabled:I||b.trim()==="",onClick:z,children:a(I?"Searching…":"Search")})]}),k!==null&&e("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:k}),p!==null&&p.length===0&&e("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),p!==null&&p.length>0&&e(V,{className:"mt-3 overflow-hidden py-0",children:e(j,{className:"px-0",children:n(q,{"data-testid":"vector-matches",children:[e(E,{children:n(N,{children:[e(o,{children:a("id")}),e(o,{children:a("score")}),e(o,{children:a("metadata")})]})}),e(L,{children:p.map(t=>n(N,{"data-testid":`vector-match-${t.id}`,children:[e(i,{className:"font-mono text-xs",children:t.id}),e(i,{className:"tabular-nums",children:t.score.toFixed(4)}),e(i,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"—":J(t.metadata)})]},t.id))})]})})})]})]})};export{ce as VectorBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useLunora as Q}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{u as W}from"../packem_shared/button-BkCrNcAs.js";import{c as J,u as L}from"../packem_shared/card-CIDGUN6K.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{n as U,d as _,m as x,p as i,f as q,u as d}from"../packem_shared/table-DdJBrClo.js";import{l as re}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as ne}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{f as A,b as E,d as H,g as X}from"../packem_shared/internal-BSIsQVC6.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const se=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const r=o.error??o.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:r,readOnly:N,runAction:T,workflowName:g})=>{const I=Q(),n=V(),[h,k]=m(null),[S,$]=m(null),[v,j]=m(""),[b,f]=m(null),[F,C]=m(!1),[R,z]=m(null),p=o??(a=>I.getWorkflowInstance(a)),w=N?void 0:T??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{f(null),C(!1);const a=v===""?void 0:v;try{if(r===void 0){const l=await I.listWorkflowInstances({name:g,status:a});if(l.configured===!1){k(null),C(!0);return}k(l.instances);return}k(await r({name:g,status:a}))}catch(l){k(null),ie(l)?C(!0):f(E(l))}};te(()=>{$(null),A(O())},[g,v]);const D=async a=>{f(null);try{$(await p({id:a,name:g}))}catch(l){f(E(l))}},K=async(a,l)=>{if(w!==void 0){z(a),f(null);try{await w({action:l,id:a,name:g}),await O()}catch(P){f(E(P))}z(null)}};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[s("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:n("Instance history")}),s("select",{"aria-label":n("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:a=>{j(a.target.value)},value:v,children:[e("option",{value:"",children:n("All statuses")}),se.map(a=>e("option",{value:a,children:a},a))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),F&&e(M,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!F&&h!==null&&h.length===0&&e(M,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),h!==null&&h.length>0&&e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflow-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:n("Instance id")}),e(i,{children:n("Status")}),e(i,{children:n("Created")}),e(i,{children:n("Ended")}),e(i,{"aria-label":n("Actions")})]})}),e(q,{children:h.map(a=>s(x,{"data-testid":`workflow-instance-${a.id}`,children:[e(d,{className:"font-mono text-xs",children:a.id}),e(d,{className:"font-mono text-xs",children:a.status}),e(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(d,{className:"text-right",children:s("div",{className:"flex justify-end gap-1.5",children:[e(W,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:()=>{A(D(a.id))},size:"sm",type:"button",variant:"outline",children:n("Steps")}),w!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:R===a.id,onClick:()=>{A(K(a.id,l))},size:"sm",type:"button",variant:"ghost",children:n(l)},l))]})})]},a.id))})]})})}),S!==null&&e(J,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:s(L,{className:"flex flex-col gap-2 px-4 py-3",children:[s("div",{className:"flex items-center justify-between",children:[s("span",{className:"font-mono text-xs",children:[n("Steps")," · ",S.id]}),e(W,{"data-testid":"workflow-instance-detail-close",onClick:()=>{$(null)},size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),S.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):s(U,{"data-testid":"workflow-instance-steps",children:[e(_,{children:s(x,{children:[e(i,{children:n("Step")}),e(i,{children:n("Type")}),e(i,{children:n("Attempts")}),e(i,{children:n("Started")}),e(i,{children:n("Output")})]})}),e(q,{children:S.steps.map((a,l)=>s(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:a.name}),e(d,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(d,{className:"tabular-nums",children:a.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},me=X(B.createWorkflowInstance),ue=X(B.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,r)=>o.some(N=>N.exportName===r)?r:o[0]?.exportName??"",Oe=()=>{const o=Q(),r=V(),{data:N,error:T}=ne(B.listWorkflows,{}),[g,I]=m(""),[n,h]=m(""),[k,S]=m(""),[$,v]=m(!1),[j,b]=m(null),[f,F]=m([]),[C,R]=m(null),z=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=he(p,g),O=p.find(t=>t.exportName===w),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},K=async()=>{const t=w;if(t==="")return;let u;const c=k.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{const y=n.trim(),G=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},H(""));D({exportName:t,id:G.id,status:G.status}),h("")}catch(y){b(E(y))}v(!1)},a=()=>{A(K())},l=async(t,u)=>{R(u);try{const c=await o.query(ue,{exportName:t,id:u},H(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(E(c))}R(null)},P=t=>{I(t.target.value)},Y=t=>{h(t.target.value)},Z=t=>{S(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&A(l(u,c))};return s("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:T}),e("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),z&&p.length===0?e(M,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Export")}),e(i,{children:r("Name")}),e(i,{children:r("Class")}),e(i,{children:r("Binding")})]})}),e(q,{children:p.map(t=>s(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:r("Start instance")}),j!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),s("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:P,value:w,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Y,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||w==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(re,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:Z,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:r("Instances")}),e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Workflow")}),e(i,{children:r("Instance id")}),e(i,{children:r("Status")}),e(i,{children:r("Output")}),e(i,{})]})}),e(q,{children:f.map(t=>s(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:ee,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(ce,{workflowName:O.name})]})};export{Oe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _="__lunora_admin__:",a={aiAvailable:"__lunora_admin__:aiAvailable",aiChartConfig:"__lunora_admin__:aiChartConfig",aiGenerateSql:"__lunora_admin__:aiGenerateSql",aiTableFilter:"__lunora_admin__:aiTableFilter",assignIssue:"__lunora_admin__:assignIssue",backRelationCounts:"__lunora_admin__:backRelationCounts",clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",explainIssue:"__lunora_admin__:explainIssue",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAuditLog:"__lunora_admin__:getAuditLog",getAuthAuditLog:"__lunora_admin__:getAuthAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",lintSql:"__lunora_admin__:lintSql",listFlags:"__lunora_admin__:listFlags",listPushSubscriptions:"__lunora_admin__:listPushSubscriptions",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetricHistory:"__lunora_admin__:getMetricHistory",getMetricSeries:"__lunora_admin__:getMetricSeries",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueryInsights:"__lunora_admin__:getQueryInsights",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",ignoreIssue:"__lunora_admin__:ignoreIssue",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",resolveIssue:"__lunora_admin__:resolveIssue",rlsPolicies:"__lunora_admin__:rlsPolicies",schemaHistory:"__lunora_admin__:schemaHistory",schemaVersion:"__lunora_admin__:schemaVersion",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",setIssueSeverity:"__lunora_admin__:setIssueSeverity",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{a as ADMIN_FUNCTIONS,_ as ADMIN_FUNCTION_PREFIX};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as E}from"react/compiler-runtime";import{useLunora as Y}from"@lunora/react";import{useState as M,useEffect as Z}from"react";import{u as Q}from"./button-BkCrNcAs.js";import{E as z}from"./empty-state-Cg7t_8qu.js";import{useT as L}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"./ADMIN_FUNCTIONS-BnD4aovm.js";import{c as ee,d as te,g as ae}from"./internal-BSIsQVC6.js";import{jsxs as A,jsx as m}from"react/jsx-runtime";const ne=ae(B.listTables),ie=["react","client","cli"],le=!1,oe={action:"action",mutation:"mutation",query:"query"},J=i=>{const e=i.indexOf(":");return e===-1?{file:"",fn:i}:{file:i.slice(0,e),fn:i.slice(e+1)}},U=({file:i,fn:e,kind:l})=>`await client.${oe[l]}(api.${i}.${e}, { /* args */ });`,re=i=>{const e=`api.${i.file}.${i.fn}`;switch(i.kind){case"action":return U(i);case"mutation":return`const ${i.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},se=({file:i,fn:e})=>`lunora run ${i}:${e} --args '{ }'`,de=i=>["// Read rows",`const rows = await ctx.db.query("${i}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${i}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${i}">;`,`type RowId = Id<"${i}">;`].join(`
|
|
2
|
+
`),ce=(i,e)=>{switch(i){case"cli":return se(e);case"client":return U(e);default:return re(e)}},V=i=>{const e=E(19),{code:l,label:o,testId:a}=i,n=L();let s;e[0]!==l?(s=()=>{ee(l)},e[0]=l,e[1]=s):s=e[1];const u=s;let t;e[2]!==o?(t=m("span",{className:"text-xs font-medium text-muted-foreground",children:o}),e[2]=o,e[3]=t):t=e[3];const c=`${a}-copy`;let r;e[4]!==n?(r=n("Copy"),e[4]=n,e[5]=r):r=e[5];let p;e[6]!==u||e[7]!==c||e[8]!==r?(p=m(Q,{"data-testid":c,onClick:u,size:"xs",type:"button",variant:"ghost",children:r}),e[6]=u,e[7]=c,e[8]=r,e[9]=p):p=e[9];let f;e[10]!==t||e[11]!==p?(f=A("div",{className:"flex items-center justify-between gap-2",children:[t,p]}),e[10]=t,e[11]=p,e[12]=f):f=e[12];let d;e[13]!==l||e[14]!==a?(d=m("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":a,children:l}),e[13]=l,e[14]=a,e[15]=d):d=e[15];let h;return e[16]!==f||e[17]!==d?(h=A("div",{className:"flex flex-col gap-1.5",children:[f,d]}),e[16]=f,e[17]=d,e[18]=h):h=e[18],h},pe=i=>{const e=E(50),{file:l,fn:o,kind:a}=i,n=L(),[s,u]=M("react");let t,c,r;if(e[0]!==l||e[1]!==o||e[2]!==a||e[3]!==n||e[4]!==s){const x={file:l,fn:o,kind:a};let I;e[8]!==n?(I=n("CLI"),e[8]=n,e[9]=I):I=e[9];let C;e[10]!==n?(C=n("Client"),e[10]=n,e[11]=C):C=e[11];let T;e[12]!==n?(T=n("React"),e[12]=n,e[13]=T):T=e[13];let _;e[14]!==I||e[15]!==C||e[16]!==T?(_={cli:I,client:C,react:T},e[14]=I,e[15]=C,e[16]=T,e[17]=_):_=e[17],r=_;let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=P=>{u(P.currentTarget.dataset.tab)},e[18]=D):D=e[18],t=D,c=ce(s,x),e[0]=l,e[1]=o,e[2]=a,e[3]=n,e[4]=s,e[5]=t,e[6]=c,e[7]=r}else t=e[5],c=e[6],r=e[7];const p=c,f=a==="action"&&s==="react"&&!le,d=`api.${l}.${o}`;let h;e[19]!==d?(h=m("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:d}),e[19]=d,e[20]=h):h=e[20];let b;e[21]!==a||e[22]!==n?(b=n("Call this {kind} from your app.",{kind:a}),e[21]=a,e[22]=n,e[23]=b):b=e[23];let v;e[24]!==b?(v=m("p",{className:"text-xs text-muted-foreground",children:b}),e[24]=b,e[25]=v):v=e[25];let y;e[26]!==h||e[27]!==v?(y=A("div",{children:[h,v]}),e[26]=h,e[27]=v,e[28]=y):y=e[28];let k;e[29]!==n?(k=n("Snippet flavour"),e[29]=n,e[30]=k):k=e[30];let $;e[31]!==t||e[32]!==s||e[33]!==r?($=ie.map(x=>m(Q,{"aria-selected":s===x,"data-tab":x,"data-testid":`api-tab-${x}`,onClick:t,role:"tab",size:"xs",type:"button",variant:s===x?"default":"outline",children:r[x]},x)),e[31]=t,e[32]=s,e[33]=r,e[34]=$):$=e[34];let N;e[35]!==k||e[36]!==$?(N=m("div",{"aria-label":k,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:$}),e[35]=k,e[36]=$,e[37]=N):N=e[37];const O=r[s],j=`api-snippet-${s}`;let w;e[38]!==p||e[39]!==O||e[40]!==j?(w=m(V,{code:p,label:O,testId:j}),e[38]=p,e[39]=O,e[40]=j,e[41]=w):w=e[41];let S;e[42]!==f||e[43]!==n?(S=f&&m("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:n("Actions have no React hook — call them through the client.")}),e[42]=f,e[43]=n,e[44]=S):S=e[44];let R;return e[45]!==w||e[46]!==S||e[47]!==y||e[48]!==N?(R=A("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[y,N,w,S]}),e[45]=w,e[46]=S,e[47]=y,e[48]=N,e[49]=R):R=e[49],R},fe=i=>{const e=E(19),{name:l}=i,o=L();let a;e[0]!==l?(a=de(l),e[0]=l,e[1]=a):a=e[1];const n=a;let s;e[2]!==l?(s=m("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:l}),e[2]=l,e[3]=s):s=e[3];let u;e[4]!==o?(u=o("Read and write this table through the typed data model."),e[4]=o,e[5]=u):u=e[5];let t;e[6]!==u?(t=m("p",{className:"text-xs text-muted-foreground",children:u}),e[6]=u,e[7]=t):t=e[7];let c;e[8]!==s||e[9]!==t?(c=A("div",{children:[s,t]}),e[8]=s,e[9]=t,e[10]=c):c=e[10];let r;e[11]!==o?(r=o("Data model"),e[11]=o,e[12]=r):r=e[12];let p;e[13]!==n||e[14]!==r?(p=m(V,{code:n,label:r,testId:"api-snippet-table"}),e[13]=n,e[14]=r,e[15]=p):p=e[15];let f;return e[16]!==c||e[17]!==p?(f=A("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,p]}),e[16]=c,e[17]=p,e[18]=f):f=e[18],f},G=i=>{const e=E(8),{active:l,label:o,onSelect:a,testId:n,value:s}=i;let u;e[0]!==a||e[1]!==s?(u=()=>{a(s)},e[0]=a,e[1]=s,e[2]=u):u=e[2];const t=u,c=l?"page":void 0;let r;return e[3]!==o||e[4]!==t||e[5]!==c||e[6]!==n?(r=m("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":n,onClick:t,type:"button",children:o}),e[3]=o,e[4]=t,e[5]=c,e[6]=n,e[7]=r):r=e[7],r},me=i=>{const e=new Map;for(const l of i){const{file:o,fn:a}=J(l.path),n=e.get(o)??[];n.push({fn:a,kind:l.kind,path:l.path}),e.set(o,n)}return[...e.entries()].map(([l,o])=>({file:l,items:o.toSorted((a,n)=>a.fn.localeCompare(n.fn))})).toSorted((l,o)=>l.file.localeCompare(o.file))},Se=i=>{const e=E(58),{functions:l,initialShardKey:o}=i,a=L(),n=Y(),[s,u]=M(null),[t,c]=M(null);let r,p;e[0]!==n||e[1]!==o?(r=()=>{let _=!1;return n.query(ne,{},te(o??"")).then(D=>(_||u(D),D)).catch(()=>{_||u([])}),()=>{_=!0}},p=[n,o],e[0]=n,e[1]=o,e[2]=r,e[3]=p):(r=e[2],p=e[3]),Z(r,p);let f,d,h,b,v,y,k,$,N,O;if(e[4]!==l||e[5]!==t||e[6]!==a||e[7]!==s){const _=l??[],D=me(_),P=(s??[]).map(ue).toSorted(he);let F;e[18]===Symbol.for("react.memo_cache_sentinel")?(F=g=>{c({kind:"fn",path:g})},e[18]=F):F=e[18];const W=F;let H;e[19]===Symbol.for("react.memo_cache_sentinel")?(H=g=>{c({kind:"table",name:g})},e[19]=H):H=e[19];const X=H;d=t?.kind==="fn"?_.find(g=>g.path===t.path):void 0,f=_.length>0||P.length>0,h=d===void 0?void 0:J(d.path),N="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",O="lunora-api-docs",e[20]!==a?(b=a("API resources"),e[20]=a,e[21]=b):b=e[21],v="flex flex-col gap-4 overflow-y-auto",y="api-rail";let K;e[22]!==t||e[23]!==a?(K=g=>A("div",{className:"flex flex-col gap-1",children:[m("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g.file||a("(root)")}),g.items.map(q=>m(G,{active:t?.kind==="fn"&&t.path===q.path,label:q.fn,onSelect:W,testId:`api-rail-fn-${q.path}`,value:q.path},q.path))]},g.file),e[22]=t,e[23]=a,e[24]=K):K=e[24],k=D.map(K),$=P.length>0&&A("div",{className:"flex flex-col gap-1",children:[m("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Tables")}),P.map(g=>m(G,{active:t?.kind==="table"&&t.name===g,label:g,onSelect:X,testId:`api-rail-table-${g}`,value:g},g))]}),e[4]=l,e[5]=t,e[6]=a,e[7]=s,e[8]=f,e[9]=d,e[10]=h,e[11]=b,e[12]=v,e[13]=y,e[14]=k,e[15]=$,e[16]=N,e[17]=O}else f=e[8],d=e[9],h=e[10],b=e[11],v=e[12],y=e[13],k=e[14],$=e[15],N=e[16],O=e[17];let j;e[25]!==f||e[26]!==a?(j=!f&&m("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:a("No functions or tables to document yet.")}),e[25]=f,e[26]=a,e[27]=j):j=e[27];let w;e[28]!==j||e[29]!==b||e[30]!==v||e[31]!==y||e[32]!==k||e[33]!==$?(w=A("nav",{"aria-label":b,className:v,"data-testid":y,children:[k,$,j]}),e[28]=j,e[29]=b,e[30]=v,e[31]=y,e[32]=k,e[33]=$,e[34]=w):w=e[34];let S;e[35]!==t||e[36]!==a?(S=t===null&&m(z,{description:a("Select a function or table to see how to call it from your app."),testId:"api-empty",title:a("API usage snippets")}),e[35]=t,e[36]=a,e[37]=S):S=e[37];let R;e[38]!==t?.kind||e[39]!==d||e[40]!==h?(R=t?.kind==="fn"&&d!==void 0&&h!==void 0&&m(pe,{file:h.file,fn:h.fn,kind:d.kind},d.path),e[38]=t?.kind,e[39]=d,e[40]=h,e[41]=R):R=e[41];let x;e[42]!==t?.kind||e[43]!==d||e[44]!==a?(x=t?.kind==="fn"&&d===void 0&&m(z,{testId:"api-empty",title:a("API usage snippets")}),e[42]=t?.kind,e[43]=d,e[44]=a,e[45]=x):x=e[45];let I;e[46]!==t?(I=t?.kind==="table"&&m(fe,{name:t.name}),e[46]=t,e[47]=I):I=e[47];let C;e[48]!==S||e[49]!==R||e[50]!==x||e[51]!==I?(C=A("div",{className:"min-w-0",children:[S,R,x,I]}),e[48]=S,e[49]=R,e[50]=x,e[51]=I,e[52]=C):C=e[52];let T;return e[53]!==w||e[54]!==C||e[55]!==N||e[56]!==O?(T=A("div",{className:N,"data-testid":O,children:[w,C]}),e[53]=w,e[54]=C,e[55]=N,e[56]=O,e[57]=T):T=e[57],T};function ue(i){return i.name}function he(i,e){return i.localeCompare(e)}export{le as REACT_HAS_ACTION_HOOK,se as buildCliSnippet,U as buildClientSnippet,re as buildReactSnippet,de as buildTableSnippet,Se as default,J as splitPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as y}from"react/compiler-runtime";import{useLunora as k}from"@lunora/react";import{E as u}from"./empty-state-Cg7t_8qu.js";import{n as h}from"./skeleton-C1wQ9M5t.js";import{u as v,U as j}from"./reference-view-DnYYWr7I.js";import{useT as I}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{jsxs as w,jsx as f}from"react/jsx-runtime";const x=["get","post","put","patch","delete","head","options","trace"],g=i=>i?.content?.["application/json"]?.schema,P=(i,e)=>Object.entries(i.responses??{}).map(([a,t])=>{const c=t.$ref?.replace("#/components/responses/",""),n=c===void 0?t:e.components?.responses?.[c]??t;return{description:n.description,schema:g(n),status:a}}),A=(i,e,a,t,c)=>{const n=g(t.requestBody),r=n?.properties?.functionPath?.const,s=typeof r=="string"?r:void 0,m=s===void 0?n:n?.properties?.args,d=t.operationId??`${a} ${e}`;return{argsSchema:m,description:t.description,functionPath:s,httpPath:e,key:i,kind:t["x-lunora-function-kind"],method:a.toUpperCase(),operationId:d,requestSchema:n,responses:P(t,c),summary:t.summary??d,tags:t.tags??[],title:t.summary??d}},O=i=>{const e=[];for(const[a,t]of Object.entries(i.paths??{})){const c=a.includes("#")?a.slice(0,a.indexOf("#")):a;for(const n of x){const r=t[n];r!==void 0&&e.push(A(a,c,n,r,i))}}return e},b=i=>{const e=i??{},a=O(e),t=new Map((e.tags??[]).map(s=>[s.name,s.description])),c=new Set,n=[],r=s=>{if(c.has(s))return;c.add(s);const m=a.filter(d=>(d.tags[0]??"")===s);m.length>0&&n.push({description:t.get(s),name:s,operations:m})};for(const s of e.tags??[])r(s.name);for(const s of a)r(s.tags[0]??"");return{groups:n,operationByKey:new Map(a.map(s=>[s.key,s])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},S=i=>{const{paths:e}=i;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},$=i=>{const e=i;return S(e)?{kind:"empty"}:{kind:"ready",spec:e}},U=i=>{const e=y(23),{spec:a}=i,t=I(),c=k();let n;e[0]!==c?(n=()=>c.fetchOpenApi(),e[0]=c,e[1]=n):n=e[1];const r=v(a,n,$);let s;e[2]!==r.kind||e[3]!==r.spec?(s=r.kind==="ready"?b(r.spec):void 0,e[2]=r.kind,e[3]=r.spec,e[4]=s):s=e[4];const m=s;if(r.kind==="loading"){let o;return e[5]===Symbol.for("react.memo_cache_sentinel")?(o=w("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[f(h,{className:"h-8 w-48"}),f(h,{className:"h-64 w-full"})]}),e[5]=o):o=e[5],o}if(r.kind==="error"){let o;e[6]!==r.message||e[7]!==t?(o=t("Couldn't load the OpenAPI spec: {message}",{message:r.message}),e[6]=r.message,e[7]=t,e[8]=o):o=e[8];let p;e[9]!==t?(p=t("API reference unavailable"),e[9]=t,e[10]=p):p=e[10];let l;return e[11]!==o||e[12]!==p?(l=f(u,{description:o,testId:"api-reference-error",title:p}),e[11]=o,e[12]=p,e[13]=l):l=e[13],l}if(r.kind==="empty"||m===void 0){let o;e[14]!==t?(o=t("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=t,e[15]=o):o=e[15];let p;e[16]!==t?(p=t("No OpenAPI spec configured"),e[16]=t,e[17]=p):p=e[17];let l;return e[18]!==o||e[19]!==p?(l=f(u,{description:o,testId:"api-reference-empty",title:p}),e[18]=o,e[19]=p,e[20]=l):l=e[20],l}let d;return e[21]!==m?(d=f(j,{model:m}),e[21]=m,e[22]=d):d=e[22],d};export{U as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as I}from"react/compiler-runtime";import{Dialog as L}from"@base-ui/react/dialog";import{useNavigate as M}from"@tanstack/react-router";import{useState as R,useRef as O,useEffect as U}from"react";import{useT as W}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{f as X}from"./internal-BSIsQVC6.js";import{c as Y}from"./utils-bhneXptQ.js";import{jsx as l,jsxs as S}from"react/jsx-runtime";const z="lunora:command-palette",re=()=>{"window"in globalThis&&globalThis.dispatchEvent(new Event(z))},q=g=>{const e=I(18),{active:u,index:a,item:n,onActivate:f,onSelect:h}=g;let s;e[0]!==n||e[1]!==h?(s=()=>{h(n)},e[0]=n,e[1]=h,e[2]=s):s=e[2];const b=s;let c;e[3]!==a||e[4]!==f?(c=()=>{f(a)},e[3]=a,e[4]=f,e[5]=c):c=e[5];const p=c,x=u?"bg-accent text-accent-foreground":"text-foreground";let i;e[6]!==x?(i=Y("flex w-full items-center justify-between gap-3 rounded-md px-3 py-2 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",x),e[6]=x,e[7]=i):i=e[7];let d;e[8]!==n.label?(d=l("span",{children:n.label}),e[8]=n.label,e[9]=d):d=e[9];let m;e[10]!==n.group?(m=l("span",{className:"text-xs text-muted-foreground",children:n.group}),e[10]=n.group,e[11]=m):m=e[11];let t;return e[12]!==b||e[13]!==p||e[14]!==i||e[15]!==d||e[16]!==m?(t=l("li",{children:S("button",{className:i,onClick:b,onMouseEnter:p,type:"button",children:[d,m]})}),e[12]=b,e[13]=p,e[14]=i,e[15]=d,e[16]=m,e[17]=t):t=e[17],t},G=(g,e)=>{const u=e.trim().toLowerCase();return u===""?g:g.filter(a=>a.label.toLowerCase().includes(u)||a.group.toLowerCase().includes(u))},le=g=>{const e=I(39),{items:u}=g,a=W(),n=M(),[f,h]=R(!1),[s,b]=R(""),[c,p]=R(0),x=O(null);let i,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const o=B=>{(B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="k"&&(B.preventDefault(),h(!0))},r=()=>{h(!0)};return globalThis.addEventListener("keydown",o),globalThis.addEventListener(z,r),()=>{globalThis.removeEventListener("keydown",o),globalThis.removeEventListener(z,r)}},d=[],e[0]=i,e[1]=d):(i=e[0],d=e[1]),U(i,d);let m;e[2]!==u||e[3]!==s?(m=G(u,s),e[2]=u,e[3]=s,e[4]=m):m=e[4];const t=m;let T;e[5]===Symbol.for("react.memo_cache_sentinel")?(T=o=>{h(o),o||(b(""),p(0))},e[5]=T):T=e[5];const H=T;let D;e[6]!==n?(D=o=>{H(!1),X(n({to:o.to}))},e[6]=n,e[7]=D):D=e[7];const v=D;let A;e[8]===Symbol.for("react.memo_cache_sentinel")?(A=o=>{b(o.target.value),p(0)},e[8]=A):A=e[8];const J=A;let j;e[9]!==c||e[10]!==t||e[11]!==v?(j=o=>{e:switch(o.key){case"ArrowDown":{o.preventDefault(),p(r=>t.length===0?0:(r+1)%t.length);break e}case"ArrowUp":{o.preventDefault(),p(r=>t.length===0?0:(r-1+t.length)%t.length);break e}case"Enter":{o.preventDefault();const r=t[c];r!==void 0&&v(r);break e}}},e[9]=c,e[10]=t,e[11]=v,e[12]=j):j=e[12];const F=j;let K;e[13]===Symbol.for("react.memo_cache_sentinel")?(K=l(L.Backdrop,{className:"fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0"}),e[13]=K):K=e[13];let w;e[14]!==a?(w=a("Command palette"),e[14]=a,e[15]=w):w=e[15];let y;e[16]!==w?(y=l(L.Title,{className:"sr-only",children:w}),e[16]=w,e[17]=y):y=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=S("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.8,viewBox:"0 0 24 24",children:[l("circle",{cx:"11",cy:"11",r:"7"}),l("path",{d:"m21 21-4.3-4.3",strokeLinecap:"round"})]}),e[18]=P):P=e[18];let k;e[19]!==a?(k=a("Search…"),e[19]=a,e[20]=k):k=e[20];let N;e[21]!==F||e[22]!==s||e[23]!==k?(N=S("div",{className:"flex items-center gap-2 border-b border-border px-3",children:[P,l("input",{className:"h-11 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground","data-testid":"dash-command-input",onChange:J,onKeyDown:F,placeholder:k,ref:x,type:"text",value:s})]}),e[21]=F,e[22]=s,e[23]=k,e[24]=N):N=e[24];let C;e[25]!==c||e[26]!==t||e[27]!==v||e[28]!==a?(C=t.length===0?l("li",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:a("No results.")}):t.map((o,r)=>l(q,{active:r===c,index:r,item:o,onActivate:p,onSelect:v},o.to)),e[25]=c,e[26]=t,e[27]=v,e[28]=a,e[29]=C):C=e[29];let _;e[30]!==C?(_=l("ul",{className:"max-h-80 overflow-y-auto p-1.5","data-testid":"dash-command-list",children:C}),e[30]=C,e[31]=_):_=e[31];let E;e[32]!==y||e[33]!==N||e[34]!==_?(E=S(L.Portal,{children:[K,S(L.Popup,{className:"fixed start-1/2 top-24 z-50 w-[36rem] max-w-[90vw] -translate-x-1/2 overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95","data-testid":"dash-command-palette",initialFocus:x,children:[y,N,_]})]}),e[32]=y,e[33]=N,e[34]=_,e[35]=E):E=e[35];let $;return e[36]!==f||e[37]!==E?($=l(L.Root,{onOpenChange:H,open:f,children:E}),e[36]=f,e[37]=E,e[38]=$):$=e[38],$};export{le as CommandPalette,re as openCommandPalette};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as p}from"react";import{useT as u}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{u as i}from"./button-BkCrNcAs.js";import{jsxs as b,jsx as n}from"react/jsx-runtime";const $=({children:o,confirmLabel:r,disabled:s=!1,onConfirm:l,testId:t})=>{const a=u(),[d,e]=p(!1),m=()=>{e(!0)},c=()=>{e(!1)},f=()=>{e(!1),l()};return d?b("span",{className:"inline-flex items-center gap-1","data-testid":`${t}-prompt`,role:"group",children:[n(i,{"data-testid":`${t}-confirm`,disabled:s,onClick:f,size:"sm",type:"button",variant:"destructive",children:r??a("Confirm")}),n(i,{"data-testid":`${t}-cancel`,onClick:c,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):n(i,{"data-testid":t,disabled:s,onClick:m,size:"sm",type:"button",variant:"outline",children:o})};export{$ as ConfirmButton};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as l}from"react/compiler-runtime";import{useConnectionStatus as d}from"@lunora/react";import{useT as f}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{c as u}from"./utils-bhneXptQ.js";import{jsx as m,jsxs as g}from"react/jsx-runtime";const p={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},j=()=>{const e=l(16),n=f(),a=d();let s;e:switch(a){case"connected":{let t;e[0]!==n?(t=n("Connected"),e[0]=n,e[1]=t):t=e[1],s=t;break e}case"connecting":{let t;e[2]!==n?(t=n("Connecting…"),e[2]=n,e[3]=t):t=e[3],s=t;break e}case"idle":{let t;e[4]!==n?(t=n("Idle"),e[4]=n,e[5]=t):t=e[5],s=t;break e}case"offline":{let t;e[6]!==n?(t=n("Offline"),e[6]=n,e[7]=t):t=e[7],s=t;break e}default:s=a}const r=p[a];let o;e[8]!==r?(o=u("size-2 rounded-full",r),e[8]=r,e[9]=o):o=e[9];let c;e[10]!==o?(c=m("span",{"aria-hidden":"true",className:o}),e[10]=o,e[11]=c):c=e[11];let i;return e[12]!==a||e[13]!==c||e[14]!==s?(i=g("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[c,s]}),e[12]=a,e[13]=c,e[14]=s,e[15]=i):i=e[15],i};export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as m}from"react/compiler-runtime";import{useRef as a,useEffect as f}from"react";const d=5e3,h=(e,r,u)=>{const t=m(6),o=u===void 0?d:u,l=a(e);let n;t[0]!==e?(n=()=>{l.current=e},t[0]=e,t[1]=n):n=t[1],f(n);let c,s;t[2]!==r||t[3]!==o?(c=()=>{if(!r)return;const i=setInterval(()=>{globalThis.document?.hidden!==!0&&l.current()},o);return()=>{clearInterval(i)}},s=[r,o],t[2]=r,t[3]=o,t[4]=c,t[5]=s):(c=t[4],s=t[5]),f(c,s)};export{d as DEFAULT_AUTO_REFRESH_MS,h as useAutoRefresh};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c={highErrorRate:.05,highWriteContention:.1,lowCacheHitRate:.5,minCacheSamples:10,minConflictCalls:5,minErrorCalls:5,slowFunctionMs:1e3},l={error:0,info:2,warning:1},u=(i,t)=>{const s=[];if(i.maxDurationMs>=t.slowFunctionMs){const e=i.scannedTables??[];e.length>0?s.push({fn:i.path,kind:"missing-index",severity:"warning",tables:e.map(a=>a.table),value:i.maxDurationMs}):s.push({fn:i.path,kind:"slow-function",severity:"info",value:i.maxDurationMs})}i.calls>=t.minErrorCalls&&i.errors/i.calls>=t.highErrorRate&&s.push({fn:i.path,kind:"high-error-rate",message:i.lastErrorMessage??void 0,severity:"error",value:i.errors/i.calls});const r=i.conflicts??0;return r>0&&i.calls>=t.minConflictCalls&&r/i.calls>=t.highWriteContention&&s.push({fn:i.path,kind:"high-write-contention",severity:"warning",value:r/i.calls}),s},g=(i,t,s=c)=>{const r=[];if(i?.cache){const{evictions:e,hits:a,misses:h}=i.cache,o=a+h;if(o>=s.minCacheSamples){const n=a/o;n<s.lowCacheHitRate&&r.push({kind:"low-cache-hit-rate",severity:"warning",value:n})}e>0&&e>a&&r.push({kind:"high-evictions",severity:"warning",value:e})}for(const e of t??[])r.push(...u(e,s));return r.toSorted((e,a)=>l[e.severity]-l[a.severity])};export{c as DEFAULT_INSIGHT_THRESHOLDS,g as deriveInsights};
|