@lunora/studio 1.0.0-alpha.375 → 1.0.0-alpha.377
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +18 -8
- package/dist/index.d.ts +18 -8
- package/dist/index.mjs +1 -1
- package/dist/mount.d.mts +1 -1
- package/dist/mount.d.ts +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_chunks/AuditPanel.mjs +1 -1
- package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/FunctionRunner.mjs +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
- package/dist/packem_chunks/HealthPanel.mjs +1 -1
- package/dist/packem_chunks/InsightsPanel.mjs +1 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
- package/dist/packem_chunks/SettingsPanel.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
- package/dist/packem_chunks/assistant-panel.mjs +1 -1
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
- package/dist/packem_chunks/containers-panel.mjs +1 -1
- package/dist/packem_chunks/dashboards-panel.mjs +1 -1
- package/dist/packem_chunks/evals-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/flags-panel.mjs +1 -1
- package/dist/packem_chunks/issues-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_chunks/organizations-panel.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/reactors-panel.mjs +1 -1
- package/dist/packem_chunks/rls-panel.mjs +1 -1
- package/dist/packem_chunks/schedule-panel.mjs +1 -1
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/sync-client-panel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_chunks/users-panel.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs +1 -0
- package/dist/packem_shared/{ApiDocsPanel-xqgxgYCy.mjs → ApiDocsPanel-sEDqUNQq.mjs} +1 -1
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs +1 -0
- package/dist/packem_shared/{DataBrowser-BrRWqnCr.mjs → DataBrowser-CkVOu6py.mjs} +1 -1
- package/dist/packem_shared/GlobalDataBrowser-l2ECwXCm.mjs +1 -0
- package/dist/packem_shared/{HomePanel-CHq9VBrh.mjs → HomePanel-c7as4tvl.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-BWGgOwmX.mjs → MigrationsPanel-BQol4Un1.mjs} +1 -1
- package/dist/packem_shared/{ScheduledJobs-QCTRdugp.mjs → ScheduledJobs-Du8ZGL7v.mjs} +1 -1
- package/dist/packem_shared/{Studio-pDEG4JTx.mjs → Studio-BmbkaUrx.mjs} +1 -1
- package/dist/packem_shared/{StudioApp-C4IOJPR6.mjs → StudioApp-CsyDnrg2.mjs} +1 -1
- package/dist/packem_shared/{advisor-view-Dj-mZPAq.mjs → advisor-view-gtf_DhUU.mjs} +1 -1
- package/dist/packem_shared/{app.d-BXrVLb99.d.mts → app.d-DpxFQ0qO.d.mts} +14 -0
- package/dist/packem_shared/{app.d-BXrVLb99.d.ts → app.d-DpxFQ0qO.d.ts} +14 -0
- package/dist/packem_shared/{assistant-provider-BQG7QZAu.mjs → assistant-provider-Dw0roZh3.mjs} +1 -1
- package/dist/packem_shared/{error-alert-BzZfqmf4.mjs → error-alert-3AR_-s_s.mjs} +1 -1
- package/dist/packem_shared/{home-panel-DTWHlX5S.mjs → home-panel-TpxiaHgB.mjs} +1 -1
- package/dist/packem_shared/{studio-DE7i2--m.mjs → studio-DZlpp4Vx.mjs} +1 -1
- package/dist/packem_shared/{table-list-sidebar-DUnCjFL7.mjs → table-list-sidebar-Bfmg04MD.mjs} +1 -1
- package/dist/packem_shared/{use-assistant-rpc-DCC6ph2u.mjs → use-assistant-rpc-AKu8hvPm.mjs} +1 -1
- package/dist/standalone/{chunk-RKPVI2PI.js → chunk-22OYIN7Q.js} +1 -1
- package/dist/standalone/{chunk-N7EIHD3H.js → chunk-2BCNWFC5.js} +1 -1
- package/dist/standalone/{chunk-2MZLFQR5.js → chunk-2BUAJRHS.js} +1 -1
- package/dist/standalone/{chunk-J45HAKBU.js → chunk-2KTN53PK.js} +1 -1
- package/dist/standalone/chunk-2NUCBQFU.js +1 -0
- package/dist/standalone/{chunk-PIOHOROI.js → chunk-2SKEPLDB.js} +1 -1
- package/dist/standalone/{chunk-BQS3C5V3.js → chunk-3FVWKQLT.js} +1 -1
- package/dist/standalone/{chunk-C4BS3LHQ.js → chunk-3J26FAKO.js} +1 -1
- package/dist/standalone/{chunk-XZHTVLDG.js → chunk-446DKR7O.js} +1 -1
- package/dist/standalone/{chunk-Z6WEYWT7.js → chunk-44ZHY2EU.js} +1 -1
- package/dist/standalone/{chunk-4EPW63HS.js → chunk-4AG356VE.js} +1 -1
- package/dist/standalone/{chunk-ZSWW2UGP.js → chunk-4KPATTV6.js} +1 -1
- package/dist/standalone/{chunk-XITLHKKR.js → chunk-4RPRUFVA.js} +1 -1
- package/dist/standalone/{chunk-HFBSWKJS.js → chunk-4SY2N2RS.js} +1 -1
- package/dist/standalone/{chunk-KBYFBEG2.js → chunk-553O7ESU.js} +1 -1
- package/dist/standalone/{chunk-JPCVFWR5.js → chunk-5Z6PF6KC.js} +1 -1
- package/dist/standalone/{chunk-ILSJ22BK.js → chunk-5ZZO5UEC.js} +1 -1
- package/dist/standalone/chunk-6ALD476Y.js +8 -0
- package/dist/standalone/{chunk-TDJQ7HQM.js → chunk-6BWAMHRF.js} +1 -1
- package/dist/standalone/{chunk-2U6Z7A6C.js → chunk-6ORWM6ZT.js} +1 -1
- package/dist/standalone/{chunk-4RGKUS3H.js → chunk-74OCXJGH.js} +1 -1
- package/dist/standalone/{chunk-CBACG4XF.js → chunk-7E3RA4X6.js} +1 -1
- package/dist/standalone/{chunk-645S7KRU.js → chunk-7VZPHPTH.js} +1 -1
- package/dist/standalone/chunk-7WGZSDRS.js +2 -0
- package/dist/standalone/{chunk-GWNGVKLG.js → chunk-A6TVTNKO.js} +1 -1
- package/dist/standalone/{chunk-6G3E4PJ2.js → chunk-ADABTCDI.js} +1 -1
- package/dist/standalone/{chunk-WFXS3YRM.js → chunk-AFIY2ATE.js} +1 -1
- package/dist/standalone/{chunk-GXTSE66Z.js → chunk-AFLNQEZ5.js} +1 -1
- package/dist/standalone/{chunk-AERXMIND.js → chunk-AKOBXMLE.js} +1 -1
- package/dist/standalone/{chunk-MJWIIV2C.js → chunk-AMWPN5JC.js} +1 -1
- package/dist/standalone/{chunk-NGGTRLCC.js → chunk-APHDGDQX.js} +1 -1
- package/dist/standalone/{chunk-RDS46R5R.js → chunk-BMDQFH65.js} +1 -1
- package/dist/standalone/{chunk-7SNL633X.js → chunk-BS77NGL6.js} +1 -1
- package/dist/standalone/{chunk-OVEOTKK5.js → chunk-CD6Y4HMA.js} +1 -1
- package/dist/standalone/{chunk-HZU4WF4X.js → chunk-CF2MJGHC.js} +1 -1
- package/dist/standalone/{chunk-6VOBO5QL.js → chunk-CJJSRDJQ.js} +1 -1
- package/dist/standalone/{chunk-QHKR5JW4.js → chunk-COLRWCN5.js} +1 -1
- package/dist/standalone/{chunk-F5WJCL3F.js → chunk-CTIZP3XO.js} +1 -1
- package/dist/standalone/{chunk-QNY5EEBN.js → chunk-CVPH3ATG.js} +1 -1
- package/dist/standalone/{chunk-OSHODLMU.js → chunk-D76SLSGV.js} +1 -1
- package/dist/standalone/{chunk-LA76GGAT.js → chunk-D7SKD7RO.js} +1 -1
- package/dist/standalone/{chunk-PIQ4A4BZ.js → chunk-DB332GVZ.js} +1 -1
- package/dist/standalone/{chunk-OODTH4NA.js → chunk-DBOXAUII.js} +1 -1
- package/dist/standalone/{chunk-SKZNH5QQ.js → chunk-DBV2V6OY.js} +1 -1
- package/dist/standalone/{chunk-JAAXDIR5.js → chunk-DIZP54PG.js} +1 -1
- package/dist/standalone/{chunk-2DT3QG6Q.js → chunk-DRHZZ7IN.js} +1 -1
- package/dist/standalone/{chunk-4ADB7TWC.js → chunk-EC3XQQRV.js} +1 -1
- package/dist/standalone/{chunk-3D67ZJRW.js → chunk-EDL46BPM.js} +1 -1
- package/dist/standalone/{chunk-4PI2OSSP.js → chunk-EOFWXI3T.js} +1 -1
- package/dist/standalone/{chunk-LR2FBYCC.js → chunk-EYDMS22X.js} +1 -1
- package/dist/standalone/{chunk-B76HLC52.js → chunk-F4KT43QZ.js} +1 -1
- package/dist/standalone/chunk-FH4R64SS.js +5 -0
- package/dist/standalone/{chunk-IJNP6YSD.js → chunk-GBVYBBIF.js} +1 -1
- package/dist/standalone/{chunk-RDS72J4I.js → chunk-GQF53GWD.js} +1 -1
- package/dist/standalone/{chunk-FGZ73BFG.js → chunk-GWRKSV2Q.js} +1 -1
- package/dist/standalone/{chunk-2EB7FN5S.js → chunk-H6VTIXVB.js} +1 -1
- package/dist/standalone/{chunk-RUQTILJN.js → chunk-IAVAD545.js} +1 -1
- package/dist/standalone/{chunk-ELUYMLPL.js → chunk-IDK6WH4X.js} +1 -1
- package/dist/standalone/{chunk-RHYQB4RH.js → chunk-IEMQNFZ7.js} +1 -1
- package/dist/standalone/{chunk-KTK4NDWQ.js → chunk-IQ5CIBXJ.js} +1 -1
- package/dist/standalone/{chunk-4B54WP4R.js → chunk-IYN56FBP.js} +1 -1
- package/dist/standalone/{chunk-EX2DUBRT.js → chunk-JB5VB7PX.js} +1 -1
- package/dist/standalone/{chunk-HCOF7HOM.js → chunk-JNWK5MJC.js} +1 -1
- package/dist/standalone/{chunk-FT3BWJVP.js → chunk-JQH5M3FB.js} +1 -1
- package/dist/standalone/{chunk-WSG35SRF.js → chunk-JUTXPZQK.js} +1 -1
- package/dist/standalone/chunk-K24LZAP2.js +7 -0
- package/dist/standalone/{chunk-FWOOA2ZR.js → chunk-K7Z7UTJJ.js} +1 -1
- package/dist/standalone/{chunk-6YBEKVUG.js → chunk-KMA6JR2E.js} +1 -1
- package/dist/standalone/{chunk-YUVGMKHG.js → chunk-L27FKJTG.js} +1 -1
- package/dist/standalone/{chunk-LFKKTGEF.js → chunk-LD6JOIEW.js} +1 -1
- package/dist/standalone/{chunk-GH6CI2P2.js → chunk-LIQOSH6R.js} +1 -1
- package/dist/standalone/{chunk-UBX5ZPLV.js → chunk-LMCBMC2V.js} +1 -1
- package/dist/standalone/chunk-LYVYUTQY.js +1 -0
- package/dist/standalone/{chunk-ZCOMJH2I.js → chunk-M5VU6MF5.js} +1 -1
- package/dist/standalone/{chunk-ASD6UAND.js → chunk-M7EHYZ6R.js} +1 -1
- package/dist/standalone/{chunk-D3DZZHZA.js → chunk-MAZES4KJ.js} +1 -1
- package/dist/standalone/{chunk-42RZZFLX.js → chunk-MBA6SBBO.js} +1 -1
- package/dist/standalone/chunk-MHZNDDGI.js +1 -0
- package/dist/standalone/{chunk-JB3DZ2PJ.js → chunk-MUCEG53A.js} +1 -1
- package/dist/standalone/{chunk-R52GVSS2.js → chunk-MWF4AQ5B.js} +1 -1
- package/dist/standalone/{chunk-WJA2IGZC.js → chunk-MWMVXHQM.js} +1 -1
- package/dist/standalone/{chunk-CAEJQOMU.js → chunk-MXYZQCDR.js} +1 -1
- package/dist/standalone/{chunk-2CPMCEHD.js → chunk-N33IYFIX.js} +1 -1
- package/dist/standalone/{chunk-IELLWQGA.js → chunk-N6H4WQHD.js} +1 -1
- package/dist/standalone/{chunk-QRA7AKYO.js → chunk-N7FOBAV3.js} +1 -1
- package/dist/standalone/{chunk-D6CDIHHL.js → chunk-NSG5VFIL.js} +1 -1
- package/dist/standalone/{chunk-25WEL5RI.js → chunk-NXNTS5G2.js} +1 -1
- package/dist/standalone/{chunk-TW4O2BA5.js → chunk-O5QATFN3.js} +3 -3
- package/dist/standalone/{chunk-SUUBCPUD.js → chunk-O6HYP4FT.js} +1 -1
- package/dist/standalone/{chunk-6FPV3EK2.js → chunk-ODEIAS3V.js} +1 -1
- package/dist/standalone/{chunk-QN66FO5B.js → chunk-OR2CSCVB.js} +1 -1
- package/dist/standalone/{chunk-EAPNLM2Q.js → chunk-OVXKPVKS.js} +1 -1
- package/dist/standalone/{chunk-D65UVZIA.js → chunk-OWRWDDJT.js} +1 -1
- package/dist/standalone/chunk-OYCDWIG2.js +33 -0
- package/dist/standalone/{chunk-VUOEJJUH.js → chunk-OZID3UYF.js} +1 -1
- package/dist/standalone/{chunk-TUFOWHEF.js → chunk-P37L55FP.js} +1 -1
- package/dist/standalone/{chunk-XWVFKYZV.js → chunk-PGK4SNG3.js} +1 -1
- package/dist/standalone/{chunk-VDSTHVWZ.js → chunk-PP75AWAZ.js} +1 -1
- package/dist/standalone/{chunk-VNH4OBJS.js → chunk-QF743FSL.js} +1 -1
- package/dist/standalone/{chunk-52ULLZJX.js → chunk-QH6WAQIT.js} +1 -1
- package/dist/standalone/{chunk-ONTGYVAN.js → chunk-QLZGKBOW.js} +1 -1
- package/dist/standalone/{chunk-3BQD5ITB.js → chunk-QURAUVUB.js} +1 -1
- package/dist/standalone/{chunk-G5REMLEG.js → chunk-QVFWLGGW.js} +1 -1
- package/dist/standalone/chunk-R3RIZDUS.js +1 -0
- package/dist/standalone/{chunk-4EQAUONF.js → chunk-RNTEWZRJ.js} +1 -1
- package/dist/standalone/{chunk-LCIDEYA4.js → chunk-RNVK7QCW.js} +1 -1
- package/dist/standalone/{chunk-QMULO5AP.js → chunk-RQFK2LYP.js} +1 -1
- package/dist/standalone/{chunk-JMZT3CEW.js → chunk-SCTYLLJT.js} +1 -1
- package/dist/standalone/{chunk-O3AZ7JKE.js → chunk-T7UKRA6J.js} +1 -1
- package/dist/standalone/{chunk-MTX62MQ7.js → chunk-TKALUM7Y.js} +1 -1
- package/dist/standalone/{chunk-CGXIERYO.js → chunk-TLOLN6RV.js} +1 -1
- package/dist/standalone/{chunk-FK2S7VR4.js → chunk-UBAPZPI2.js} +1 -1
- package/dist/standalone/{chunk-MWYGLPDV.js → chunk-VB3BKQCE.js} +1 -1
- package/dist/standalone/{chunk-DDTWGWM4.js → chunk-VH4NT2WJ.js} +1 -1
- package/dist/standalone/{chunk-MGFELY5Q.js → chunk-VRAOBE6E.js} +1 -1
- package/dist/standalone/{chunk-VXZAS5VS.js → chunk-VSYZL2WH.js} +1 -1
- package/dist/standalone/{chunk-S36FVTKK.js → chunk-W7CLOQOU.js} +1 -1
- package/dist/standalone/chunk-WUWBRYJG.js +1 -0
- package/dist/standalone/{chunk-M4TCBPSY.js → chunk-XMJB5JOF.js} +1 -1
- package/dist/standalone/{chunk-HCWB4UDT.js → chunk-XNZ4WUSQ.js} +1 -1
- package/dist/standalone/{chunk-DHH7WHXQ.js → chunk-Y5HPCYBO.js} +1 -1
- package/dist/standalone/chunk-Y6OVSHPH.js +1 -0
- package/dist/standalone/{chunk-6IRGBPDN.js → chunk-YKUO2I5M.js} +1 -1
- package/dist/standalone/{chunk-XLYFGUEF.js → chunk-YNCZVYCO.js} +1 -1
- package/dist/standalone/chunk-YOUTNV5Y.js +1 -0
- package/dist/standalone/{chunk-A2Q3TGIQ.js → chunk-YYJGL32M.js} +1 -1
- package/dist/standalone/{chunk-2IOS27FL.js → chunk-ZAWNUXWP.js} +1 -1
- package/dist/standalone/{chunk-KYN4A72O.js → chunk-ZIUDJD6M.js} +1 -1
- package/dist/standalone/{chunk-HPD2PZP2.js → chunk-ZUVDTKXM.js} +1 -1
- package/dist/standalone/studio.js +3 -3
- package/package.json +13 -13
- package/dist/packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs +0 -1
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs +0 -1
- package/dist/packem_shared/GlobalDataBrowser-DB1B-WAN.mjs +0 -1
- package/dist/standalone/chunk-6A6AELDJ.js +0 -1
- package/dist/standalone/chunk-ACWAMBGT.js +0 -1
- package/dist/standalone/chunk-BG2CJOVS.js +0 -1
- package/dist/standalone/chunk-BKI3JMXQ.js +0 -1
- package/dist/standalone/chunk-KGLIQIZU.js +0 -1
- package/dist/standalone/chunk-ODLNNVP2.js +0 -7
- package/dist/standalone/chunk-PGJOTPWC.js +0 -1
- package/dist/standalone/chunk-PUK3H4RN.js +0 -33
- package/dist/standalone/chunk-QAOZXPLU.js +0 -1
- package/dist/standalone/chunk-RTS5G3ET.js +0 -2
- package/dist/standalone/chunk-USVLFLZL.js +0 -5
- package/dist/standalone/chunk-Z7ZGAQ5J.js +0 -8
- /package/dist/standalone/{chunk-NGVP66OH.js → chunk-QHVUXMRV.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as b,useRef as oe,useEffect as ie}from"react";import{c as xe,d as ge,b as be,a as fe,C as me}from"../packem_shared/card-By2O8ULa.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as te}from"react/compiler-runtime";import{E as ye}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{L as ve}from"../packem_shared/live-status-D1GasNsH.mjs";import{B as Q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as j}from"../packem_shared/button-q0UYSmrn.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as ne,c as ae,d as Ce,e as se}from"../packem_shared/table-D0SBiDu-.mjs";import{u as le}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{ADMIN_FUNCTIONS as ee}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{jsxs as u,jsx as s}from"react/jsx-runtime";import{decodeWire as Se}from"@lunora/wire";import{ConfirmButton as we}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{ShardInput as Pe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{I as Y}from"../packem_shared/input-CXhxesPC.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{T as Ie}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ue}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{d as Re,c as Te,b as Ae,f as re,k as Ee}from"../packem_shared/internal-hIuTpSbx.mjs";const ce=["read","insert","update","delete"],_e=(t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],Fe=t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,Oe=t=>{const e=new Set;for(const l of t?.advisories??[])if(l.name==="rls_uncovered_table"){const{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},De=(t,e,l)=>{const o=new Map,r=n=>{const i=o.get(n);if(i!==void 0)return i;const m={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,m),m};for(const n of t)r(n.table).cells[n.on]={path:Fe(n),procedure:n.procedure};for(const n of e)r(n.table).maskedColumns.add(n.column);for(const n of l)r(n);return[...o.values()].toSorted((n,i)=>n.table.localeCompare(i.table))},Le=t=>{const e=te(17);let l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];const{onProbe:o}=l,r=G();let n,i;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},i={live:!0},e[2]=n,e[3]=i):(n=e[2],i=e[3]);const m=le(ee.rlsPolicies,n,i);let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a={},e[4]=a):a=e[4];const f=le(ee.maskPolicies,a);let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c={},e[5]=c):c=e[5];const d=le(ee.getAdvisories,c);let h;if(e[6]!==d.data||e[7]!==f.data||e[8]!==o||e[9]!==m||e[10]!==r){let g=null;m.data!==void 0&&(g=Array.isArray(m.data.policies)?m.data.policies:[]);const F=Array.isArray(f.data?.columns)?f.data.columns:[],H=d.data??null,{error:w,errorSource:C,liveError:P}=m,R=g===null?[]:De(g,F,Oe(H));let k;e[12]!==P?(k=s("div",{className:"flex items-center justify-end",children:s(ve,{message:P,prefix:"pm"})}),e[12]=P,e[13]=k):k=e[13];let T;e[14]!==w||e[15]!==C?(T=w!==null&&s(ye,{error:C,testId:"pm-error"}),e[14]=w,e[15]=C,e[16]=T):T=e[16],h=u("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,T,g!==null&&R.length===0?s(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):u(Ne,{"data-testid":"pm-table",children:[s(ke,{children:u(ne,{children:[s(ae,{children:r("Table")}),ce.map(x=>s(ae,{children:_e(r,x)},x)),s(ae,{children:r("Masked columns")})]})}),s(Ce,{children:R.map(x=>u(ne,{"data-testid":`pm-row-${x.table}`,children:[s(se,{className:"font-mono text-xs",children:u("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&s(Q,{"data-testid":`pm-uncovered-${x.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ce.map(I=>{const v=x.cells[I];return s(se,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?s("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):u("span",{className:"flex flex-col gap-1",children:[s(Q,{variant:"secondary",children:r("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&s(j,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:()=>{o(x.table,I,v.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},I)}),s(se,{children:x.maskedColumns.size===0?s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):s("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map($e)})})]},x.table))})]})]}),e[6]=d.data,e[7]=f.data,e[8]=o,e[9]=m,e[10]=r,e[11]=h}else h=e[11];return h};function $e(t){return s(Q,{variant:"outline",children:t},t)}const Ue=Te(ee.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Me=t=>{const e=t?.code;return typeof e=="string"?e:void 0},ze=()=>{const t=ue();return async({args:e,functionPath:l,shardKey:o="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:r},Re(o))}}catch(i){const m=i instanceof Error?i.message:String(i),a=Me(i);return a!==void 0&&We.has(a)?{kind:"denied",message:m}:{kind:"errored",message:m}}}},qe=t=>t===void 0?"undefined":JSON.stringify(t,Ee,2),Be=t=>{const e=te(43),{outcome:l}=t,o=G();if(l.kind==="allowed"){let a;e[0]!==o?(a=o("Allowed"),e[0]=o,e[1]=a):a=e[1];let f;e[2]!==a?(f=s(Q,{variant:"secondary",children:a}),e[2]=a,e[3]=f):f=e[3];let c;e[4]!==l.value?(c=qe(l.value),e[4]=l.value,e[5]=c):c=e[5];let d;e[6]!==c?(d=s("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:c}),e[6]=c,e[7]=d):d=e[7];let h;return e[8]!==f||e[9]!==d?(h=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[f,d]}),e[8]=f,e[9]=d,e[10]=h):h=e[10],h}if(l.kind==="denied"){let a;e[11]!==o?(a=o("Denied"),e[11]=o,e[12]=a):a=e[12];let f;e[13]!==a?(f=s(Q,{variant:"destructive",children:a}),e[13]=a,e[14]=f):f=e[14];let c;e[15]!==l.message?(c=s("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:l.message}),e[15]=l.message,e[16]=c):c=e[16];let d;return e[17]!==f||e[18]!==c?(d=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[f,c]}),e[17]=f,e[18]=c,e[19]=d):d=e[19],d}if(l.kind==="errored"){let a;e[20]!==o?(a=o("Errored"),e[20]=o,e[21]=a):a=e[21];let f;e[22]!==a?(f=s(Q,{variant:"outline",children:a}),e[22]=a,e[23]=f):f=e[23];let c;e[24]!==o?(c=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=c):c=e[25];let d;e[26]!==c?(d=s("p",{className:"text-sm text-muted-foreground",children:c}),e[26]=c,e[27]=d):d=e[27];let h;e[28]!==l.message?(h=s("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==f||e[31]!==d||e[32]!==h?(g=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[f,d,h]}),e[30]=f,e[31]=d,e[32]=h,e[33]=g):g=e[33],g}let r;e[34]!==o?(r=o("Not run"),e[34]=o,e[35]=r):r=e[35];let n;e[36]!==r?(n=s(Q,{variant:"outline",children:r}),e[36]=r,e[37]=n):n=e[37];let i;e[38]!==l.message?(i=s("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=i):i=e[39];let m;return e[40]!==n||e[41]!==i?(m=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,i]}),e[40]=n,e[41]=i,e[42]=m):m=e[42],m},je=t=>{const e=te(17),{disabled:l,executesWrites:o,functionPath:r,onRun:n,running:i,userId:m}=t,a=G();let f;e[0]!==i||e[1]!==a?(f=a(i?"Probing…":"Run probe"),e[0]=i,e[1]=a,e[2]=f):f=e[2];const c=f;let d;e[3]!==l||e[4]!==o||e[5]!==r||e[6]!==c||e[7]!==n||e[8]!==a||e[9]!==m?(d=o?s(we,{confirmLabel:a("This will execute `{functionPath}` as user `{userId}`.",{functionPath:r,userId:m}),disabled:l,onConfirm:n,testId:"pp-run",children:c}):s(j,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:c}),e[3]=l,e[4]=o,e[5]=r,e[6]=c,e[7]=n,e[8]=a,e[9]=m,e[10]=d):d=e[10];let h;e[11]!==a||e[12]!==m?(h=m!==""&&s(Q,{"data-testid":"pp-as-badge",variant:"secondary",children:a("as {userId}",{userId:m})}),e[11]=a,e[12]=m,e[13]=h):h=e[13];let g;return e[14]!==d||e[15]!==h?(g=u("div",{className:"flex items-center gap-2",children:[d,h]}),e[14]=d,e[15]=h,e[16]=g):g=e[16],g},Qe=({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{const o=ue(),r=G(),n=ze(),[i,m]=b(null),[a,f]=b(null),c=t??i??[],[d,h]=b(""),[g,F]=b("{}"),[H,w]=b(""),[C,P]=b(""),[R,k]=b(!1),[T,x]=b(null),[I,v]=b(null),[A,O]=b(!1),E=oe(-1),S=oe(0);ie(()=>{if(t!==void 0)return;let p=!1;return o.listFunctions().then(N=>(p||m(N),N)).catch(N=>{p||f(Ae(N))}),()=>{p=!0}},[o,t]),ie(()=>{if(e===void 0||E.current===e.nonce)return;E.current=e.nonce,S.current+=1;const p=e.functionPath;queueMicrotask(()=>{h(p),x(null)})},[e]);const J=A?c:c.filter(p=>p.kind==="query"||p.path===d),y=d===""?J[0]?.path??"":d,D=c.find(p=>p.path===y),K=y!==""&&D?.kind!=="query",L=async()=>{if(y==="")return;let p;try{p=g.trim()===""?{}:Se(JSON.parse(g))}catch(B){v(r("Invalid JSON args: {message}",{message:B.message})),x(null);return}S.current+=1;const N=S.current;v(null),k(!0);try{const B=await n({args:p,functionPath:y,shardKey:H.trim(),userId:C.trim()});N===S.current&&x(B)}finally{k(!1)}},$=()=>{re(L())},U=p=>{h(p.target.value)},W=p=>{F(p.target.value)},M=p=>{P(p.target.value)},z=p=>{O(p.target.checked),!p.target.checked&&K&&h("")},q=!l||R||y==="";return u("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[a!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:a}),!l&&s(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.")}),u("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-function",children:r("Function")}),s("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:U,value:y,children:J.map(p=>u("option",{value:p.path,children:[p.path," (",p.kind,")"]},p.path))}),u(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[s("input",{checked:A,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:z,type:"checkbox"}),r("Include mutations and actions")]})]}),u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-args",children:r("Arguments")}),s(Ie,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),s(Pe,{onChange:w,testId:"pp-shard",value:H}),u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-user",children:r("Run as (userId)")}),s(Y,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:M,placeholder:r("Required — the identity to probe as"),value:C})]}),s(je,{disabled:q,executesWrites:K,functionPath:y,onRun:$,running:R,userId:C.trim()})]}),I!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),T!==null&&s(Be,{outcome:T})]})},He="/__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."},Ke=async t=>{const e=await fetch(He,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};const o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Je[o]??o}},de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ve=()=>{const t=te(69),e=G(),[l,o]=b(null),[r,n]=b(!1),[i,m]=b(null),[a,f]=b(de);let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=X=>{const V=X.target.name,{value:Z}=X.target;f(he=>({...he,[V]:Z}))},t[0]=c):c=t[0];const d=c;let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(null),f(de)},t[1]=h):h=t[1];const g=h;let F;t[2]===Symbol.for("react.memo_cache_sentinel")?(F=async X=>{n(!0),m(null);try{const V=await Ke(X);m(V),V.kind==="ok"&&g()}catch(V){const Z=V;m({kind:"error",message:Z instanceof Error?Z.message:String(Z)})}n(!1)},t[2]=F):F=t[2];const H=F;let w;t[3]!==a.policyName||t[4]!==a.tableName?(w=()=>{re(H({kind:"scaffoldPolicy",name:a.policyName.trim(),table:a.tableName.trim()}))},t[3]=a.policyName,t[4]=a.tableName,t[5]=w):w=t[5];const C=w;let P;t[6]!==a.exportName||t[7]!==a.filePath||t[8]!==a.policies?(P=()=>{re(H({exportName:a.exportName.trim(),filePath:a.filePath.trim(),kind:"wireRls",policies:a.policies.trim()}))},t[6]=a.exportName,t[7]=a.filePath,t[8]=a.policies,t[9]=P):P=t[9];const R=P;let k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{m(null),o("scaffold")},t[10]=k):k=t[10];const T=k;let x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m(null),o("wire")},t[11]=x):x=t[11];const I=x;let v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let A;t[14]!==v?(A=s(xe,{children:v}),t[14]=v,t[15]=A):A=t[15];let O;t[16]!==e?(O=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=O):O=t[17];let E;t[18]!==O?(E=s(ge,{children:O}),t[18]=O,t[19]=E):E=t[19];let S;t[20]!==E||t[21]!==A?(S=u(be,{children:[A,E]}),t[20]=E,t[21]=A,t[22]=S):S=t[22];const J=l==="scaffold"?"default":"outline";let y;t[23]!==e?(y=e("New policy file"),t[23]=e,t[24]=y):y=t[24];let D;t[25]!==J||t[26]!==y?(D=s(j,{"data-testid":"policy-scaffolder-new",onClick:T,size:"xs",type:"button",variant:J,children:y}),t[25]=J,t[26]=y,t[27]=D):D=t[27];const K=l==="wire"?"default":"outline";let L;t[28]!==e?(L=e("Wire into a procedure"),t[28]=e,t[29]=L):L=t[29];let $;t[30]!==K||t[31]!==L?($=s(j,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:K,children:L}),t[30]=K,t[31]=L,t[32]=$):$=t[32];let U;t[33]!==D||t[34]!==$?(U=u("div",{className:"flex flex-wrap gap-2",children:[D,$]}),t[33]=D,t[34]=$,t[35]=U):U=t[35];let W;t[36]!==r||t[37]!==a.policyName||t[38]!==a.tableName||t[39]!==l||t[40]!==C||t[41]!==e?(W=l==="scaffold"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),s(Y,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:d,value:a.policyName})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),s(Y,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:d,value:a.tableName})]}),s(j,{"data-testid":"policy-scaffolder-create",disabled:r||a.policyName.trim()===""||a.tableName.trim()==="",onClick:C,size:"xs",type:"button",children:e(r?"Creating…":"Create policy file")}),s(j,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=r,t[37]=a.policyName,t[38]=a.tableName,t[39]=l,t[40]=C,t[41]=e,t[42]=W):W=t[42];let M;t[43]!==r||t[44]!==a.exportName||t[45]!==a.filePath||t[46]!==a.policies||t[47]!==l||t[48]!==R||t[49]!==e?(M=l==="wire"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),s(Y,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:d,value:a.filePath})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),s(Y,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:d,value:a.exportName})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),s(Y,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:d,value:a.policies})]}),s(j,{"data-testid":"policy-scaffolder-apply",disabled:r||a.filePath.trim()===""||a.exportName.trim()===""||a.policies.trim()==="",onClick:R,size:"xs",type:"button",children:e(r?"Wiring…":"Wire RLS")}),s(j,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=r,t[44]=a.exportName,t[45]=a.filePath,t[46]=a.policies,t[47]=l,t[48]=R,t[49]=e,t[50]=M):M=t[50];let z;t[51]!==i?(z=i?.kind==="error"&&s("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:i.message}),t[51]=i,t[52]=z):z=t[52];let q;t[53]!==i?.kind||t[54]!==e?(q=i?.kind==="needs-manual-edit"&&s("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),t[53]=i?.kind,t[54]=e,t[55]=q):q=t[55];let p;t[56]!==i||t[57]!==e?(p=i?.kind==="ok"&&u("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[s("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:i.label})}),i.diagnostics.length>0&&s("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:i.diagnostics.map(Ye)})]}),t[56]=i,t[57]=e,t[58]=p):p=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==M||t[62]!==z||t[63]!==q||t[64]!==p?(N=u(fe,{children:[U,W,M,z,q,p]}),t[59]=U,t[60]=W,t[61]=M,t[62]=z,t[63]=q,t[64]=p,t[65]=N):N=t[65];let B;return t[66]!==S||t[67]!==N?(B=u(me,{"data-testid":"policy-scaffolder",size:"sm",children:[S,N]}),t[66]=S,t[67]=N,t[68]=B):B=t[68],B};function Ye(t){return s("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}const bt=({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{const o=G(),[r,n]=b(void 0),i=(m,a,f)=>{f!==""&&n(c=>({functionPath:f,nonce:(c?.nonce??0)+1}))};return u("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[u("section",{className:"flex flex-col gap-3",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),s(Le,{onProbe:i})]}),s("section",{className:"flex flex-col gap-3",children:u(me,{className:"gap-0 py-0",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),u(fe,{className:"px-4 py-4",children:[s("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),s(Qe,{functions:t,prefill:r,runAsIdentity:e})]})]})}),l&&s("section",{className:"flex flex-col gap-2",children:s(Ve,{})})]})};export{bt as PermissionsPanel};
|
|
1
|
+
import{useState as b,useRef as oe,useEffect as ie}from"react";import{c as xe,d as ge,b as be,a as fe,C as me}from"../packem_shared/card-By2O8ULa.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as te}from"react/compiler-runtime";import{E as ye}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{L as ve}from"../packem_shared/live-status-D1GasNsH.mjs";import{B as Q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as j}from"../packem_shared/button-q0UYSmrn.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as ne,c as ae,d as Ce,e as se}from"../packem_shared/table-D0SBiDu-.mjs";import{u as le}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{ADMIN_FUNCTIONS as ee}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{jsxs as u,jsx as s}from"react/jsx-runtime";import{decodeWire as Se}from"@lunora/wire";import{ConfirmButton as we}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{ShardInput as Pe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{I as Y}from"../packem_shared/input-CXhxesPC.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{T as Ie}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ue}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{d as Re,c as Te,b as Ae,f as re,k as Ee}from"../packem_shared/internal-hIuTpSbx.mjs";const ce=["read","insert","update","delete"],_e=(t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],Fe=t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,Oe=t=>{const e=new Set;for(const l of t?.advisories??[])if(l.name==="rls_uncovered_table"){const{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},De=(t,e,l)=>{const o=new Map,r=n=>{const i=o.get(n);if(i!==void 0)return i;const m={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,m),m};for(const n of t)r(n.table).cells[n.on]={path:Fe(n),procedure:n.procedure};for(const n of e)r(n.table).maskedColumns.add(n.column);for(const n of l)r(n);return[...o.values()].toSorted((n,i)=>n.table.localeCompare(i.table))},Le=t=>{const e=te(17);let l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];const{onProbe:o}=l,r=G();let n,i;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},i={live:!0},e[2]=n,e[3]=i):(n=e[2],i=e[3]);const m=le(ee.rlsPolicies,n,i);let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a={},e[4]=a):a=e[4];const f=le(ee.maskPolicies,a);let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c={},e[5]=c):c=e[5];const d=le(ee.getAdvisories,c);let h;if(e[6]!==d.data||e[7]!==f.data||e[8]!==o||e[9]!==m||e[10]!==r){let g=null;m.data!==void 0&&(g=Array.isArray(m.data.policies)?m.data.policies:[]);const F=Array.isArray(f.data?.columns)?f.data.columns:[],H=d.data??null,{error:w,errorSource:C,liveError:P}=m,R=g===null?[]:De(g,F,Oe(H));let k;e[12]!==P?(k=s("div",{className:"flex items-center justify-end",children:s(ve,{message:P,prefix:"pm"})}),e[12]=P,e[13]=k):k=e[13];let T;e[14]!==w||e[15]!==C?(T=w!==null&&s(ye,{error:C,testId:"pm-error"}),e[14]=w,e[15]=C,e[16]=T):T=e[16],h=u("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,T,g!==null&&R.length===0?s(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):u(Ne,{"data-testid":"pm-table",children:[s(ke,{children:u(ne,{children:[s(ae,{children:r("Table")}),ce.map(x=>s(ae,{children:_e(r,x)},x)),s(ae,{children:r("Masked columns")})]})}),s(Ce,{children:R.map(x=>u(ne,{"data-testid":`pm-row-${x.table}`,children:[s(se,{className:"font-mono text-xs",children:u("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&s(Q,{"data-testid":`pm-uncovered-${x.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ce.map(I=>{const v=x.cells[I];return s(se,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?s("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):u("span",{className:"flex flex-col gap-1",children:[s(Q,{variant:"secondary",children:r("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&s(j,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:()=>{o(x.table,I,v.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},I)}),s(se,{children:x.maskedColumns.size===0?s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):s("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map($e)})})]},x.table))})]})]}),e[6]=d.data,e[7]=f.data,e[8]=o,e[9]=m,e[10]=r,e[11]=h}else h=e[11];return h};function $e(t){return s(Q,{variant:"outline",children:t},t)}const Ue=Te(ee.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Me=t=>{const e=t?.code;return typeof e=="string"?e:void 0},ze=()=>{const t=ue();return async({args:e,functionPath:l,shardKey:o="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:r},Re(o))}}catch(i){const m=i instanceof Error?i.message:String(i),a=Me(i);return a!==void 0&&We.has(a)?{kind:"denied",message:m}:{kind:"errored",message:m}}}},qe=t=>t===void 0?"undefined":JSON.stringify(t,Ee,2),Be=t=>{const e=te(43),{outcome:l}=t,o=G();if(l.kind==="allowed"){let a;e[0]!==o?(a=o("Allowed"),e[0]=o,e[1]=a):a=e[1];let f;e[2]!==a?(f=s(Q,{variant:"secondary",children:a}),e[2]=a,e[3]=f):f=e[3];let c;e[4]!==l.value?(c=qe(l.value),e[4]=l.value,e[5]=c):c=e[5];let d;e[6]!==c?(d=s("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:c}),e[6]=c,e[7]=d):d=e[7];let h;return e[8]!==f||e[9]!==d?(h=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[f,d]}),e[8]=f,e[9]=d,e[10]=h):h=e[10],h}if(l.kind==="denied"){let a;e[11]!==o?(a=o("Denied"),e[11]=o,e[12]=a):a=e[12];let f;e[13]!==a?(f=s(Q,{variant:"destructive",children:a}),e[13]=a,e[14]=f):f=e[14];let c;e[15]!==l.message?(c=s("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:l.message}),e[15]=l.message,e[16]=c):c=e[16];let d;return e[17]!==f||e[18]!==c?(d=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[f,c]}),e[17]=f,e[18]=c,e[19]=d):d=e[19],d}if(l.kind==="errored"){let a;e[20]!==o?(a=o("Errored"),e[20]=o,e[21]=a):a=e[21];let f;e[22]!==a?(f=s(Q,{variant:"outline",children:a}),e[22]=a,e[23]=f):f=e[23];let c;e[24]!==o?(c=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=c):c=e[25];let d;e[26]!==c?(d=s("p",{className:"text-sm text-muted-foreground",children:c}),e[26]=c,e[27]=d):d=e[27];let h;e[28]!==l.message?(h=s("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==f||e[31]!==d||e[32]!==h?(g=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[f,d,h]}),e[30]=f,e[31]=d,e[32]=h,e[33]=g):g=e[33],g}let r;e[34]!==o?(r=o("Not run"),e[34]=o,e[35]=r):r=e[35];let n;e[36]!==r?(n=s(Q,{variant:"outline",children:r}),e[36]=r,e[37]=n):n=e[37];let i;e[38]!==l.message?(i=s("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=i):i=e[39];let m;return e[40]!==n||e[41]!==i?(m=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,i]}),e[40]=n,e[41]=i,e[42]=m):m=e[42],m},je=t=>{const e=te(17),{disabled:l,executesWrites:o,functionPath:r,onRun:n,running:i,userId:m}=t,a=G();let f;e[0]!==i||e[1]!==a?(f=a(i?"Probing…":"Run probe"),e[0]=i,e[1]=a,e[2]=f):f=e[2];const c=f;let d;e[3]!==l||e[4]!==o||e[5]!==r||e[6]!==c||e[7]!==n||e[8]!==a||e[9]!==m?(d=o?s(we,{confirmLabel:a("This will execute `{functionPath}` as user `{userId}`.",{functionPath:r,userId:m}),disabled:l,onConfirm:n,testId:"pp-run",children:c}):s(j,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:c}),e[3]=l,e[4]=o,e[5]=r,e[6]=c,e[7]=n,e[8]=a,e[9]=m,e[10]=d):d=e[10];let h;e[11]!==a||e[12]!==m?(h=m!==""&&s(Q,{"data-testid":"pp-as-badge",variant:"secondary",children:a("as {userId}",{userId:m})}),e[11]=a,e[12]=m,e[13]=h):h=e[13];let g;return e[14]!==d||e[15]!==h?(g=u("div",{className:"flex items-center gap-2",children:[d,h]}),e[14]=d,e[15]=h,e[16]=g):g=e[16],g},Qe=({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{const o=ue(),r=G(),n=ze(),[i,m]=b(null),[a,f]=b(null),c=t??i??[],[d,h]=b(""),[g,F]=b("{}"),[H,w]=b(""),[C,P]=b(""),[R,k]=b(!1),[T,x]=b(null),[I,v]=b(null),[A,O]=b(!1),E=oe(-1),S=oe(0);ie(()=>{if(t!==void 0)return;let p=!1;return o.listFunctions().then(N=>(p||m(N),N)).catch(N=>{p||f(Ae(N))}),()=>{p=!0}},[o,t]),ie(()=>{if(e===void 0||E.current===e.nonce)return;E.current=e.nonce,S.current+=1;const p=e.functionPath;queueMicrotask(()=>{h(p),x(null)})},[e]);const J=A?c:c.filter(p=>p.kind==="query"||p.path===d),y=d===""?J[0]?.path??"":d,D=c.find(p=>p.path===y),K=y!==""&&D?.kind!=="query",L=async()=>{if(y==="")return;let p;try{p=g.trim()===""?{}:Se(JSON.parse(g))}catch(B){v(r("Invalid JSON args: {message}",{message:B.message})),x(null);return}S.current+=1;const N=S.current;v(null),k(!0);try{const B=await n({args:p,functionPath:y,shardKey:H.trim(),userId:C.trim()});N===S.current&&x(B)}finally{k(!1)}},$=()=>{re(L())},U=p=>{h(p.target.value)},W=p=>{F(p.target.value)},M=p=>{P(p.target.value)},z=p=>{O(p.target.checked),!p.target.checked&&K&&h("")},q=!l||R||y==="";return u("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[a!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:a}),!l&&s(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.")}),u("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-function",children:r("Function")}),s("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:U,value:y,children:J.map(p=>u("option",{value:p.path,children:[p.path," (",p.kind,")"]},p.path))}),u(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[s("input",{checked:A,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:z,type:"checkbox"}),r("Include mutations and actions")]})]}),u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-args",children:r("Arguments")}),s(Ie,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),s(Pe,{onChange:w,testId:"pp-shard",value:H}),u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-user",children:r("Run as (userId)")}),s(Y,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:M,placeholder:r("Required — the identity to probe as"),value:C})]}),s(je,{disabled:q,executesWrites:K,functionPath:y,onRun:$,running:R,userId:C.trim()})]}),I!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),T!==null&&s(Be,{outcome:T})]})},He="/__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."},Ke=async t=>{const e=await fetch(He,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};const o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Je[o]??o}},de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ve=()=>{const t=te(69),e=G(),[l,o]=b(null),[r,n]=b(!1),[i,m]=b(null),[a,f]=b(de);let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=X=>{const V=X.target.name,{value:Z}=X.target;f(he=>({...he,[V]:Z}))},t[0]=c):c=t[0];const d=c;let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(null),f(de)},t[1]=h):h=t[1];const g=h;let F;t[2]===Symbol.for("react.memo_cache_sentinel")?(F=async X=>{n(!0),m(null);try{const V=await Ke(X);m(V),V.kind==="ok"&&g()}catch(V){const Z=V;m({kind:"error",message:Z instanceof Error?Z.message:String(Z)})}n(!1)},t[2]=F):F=t[2];const H=F;let w;t[3]!==a.policyName||t[4]!==a.tableName?(w=()=>{re(H({kind:"scaffoldPolicy",name:a.policyName.trim(),table:a.tableName.trim()}))},t[3]=a.policyName,t[4]=a.tableName,t[5]=w):w=t[5];const C=w;let P;t[6]!==a.exportName||t[7]!==a.filePath||t[8]!==a.policies?(P=()=>{re(H({exportName:a.exportName.trim(),filePath:a.filePath.trim(),kind:"wireRls",policies:a.policies.trim()}))},t[6]=a.exportName,t[7]=a.filePath,t[8]=a.policies,t[9]=P):P=t[9];const R=P;let k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{m(null),o("scaffold")},t[10]=k):k=t[10];const T=k;let x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m(null),o("wire")},t[11]=x):x=t[11];const I=x;let v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let A;t[14]!==v?(A=s(xe,{children:v}),t[14]=v,t[15]=A):A=t[15];let O;t[16]!==e?(O=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=O):O=t[17];let E;t[18]!==O?(E=s(ge,{children:O}),t[18]=O,t[19]=E):E=t[19];let S;t[20]!==E||t[21]!==A?(S=u(be,{children:[A,E]}),t[20]=E,t[21]=A,t[22]=S):S=t[22];const J=l==="scaffold"?"default":"outline";let y;t[23]!==e?(y=e("New policy file"),t[23]=e,t[24]=y):y=t[24];let D;t[25]!==J||t[26]!==y?(D=s(j,{"data-testid":"policy-scaffolder-new",onClick:T,size:"xs",type:"button",variant:J,children:y}),t[25]=J,t[26]=y,t[27]=D):D=t[27];const K=l==="wire"?"default":"outline";let L;t[28]!==e?(L=e("Wire into a procedure"),t[28]=e,t[29]=L):L=t[29];let $;t[30]!==K||t[31]!==L?($=s(j,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:K,children:L}),t[30]=K,t[31]=L,t[32]=$):$=t[32];let U;t[33]!==D||t[34]!==$?(U=u("div",{className:"flex flex-wrap gap-2",children:[D,$]}),t[33]=D,t[34]=$,t[35]=U):U=t[35];let W;t[36]!==r||t[37]!==a.policyName||t[38]!==a.tableName||t[39]!==l||t[40]!==C||t[41]!==e?(W=l==="scaffold"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),s(Y,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:d,value:a.policyName})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),s(Y,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:d,value:a.tableName})]}),s(j,{"data-testid":"policy-scaffolder-create",disabled:r||a.policyName.trim()===""||a.tableName.trim()==="",onClick:C,size:"xs",type:"button",children:e(r?"Creating…":"Create policy file")}),s(j,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=r,t[37]=a.policyName,t[38]=a.tableName,t[39]=l,t[40]=C,t[41]=e,t[42]=W):W=t[42];let M;t[43]!==r||t[44]!==a.exportName||t[45]!==a.filePath||t[46]!==a.policies||t[47]!==l||t[48]!==R||t[49]!==e?(M=l==="wire"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),s(Y,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:d,value:a.filePath})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),s(Y,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:d,value:a.exportName})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),s(Y,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:d,value:a.policies})]}),s(j,{"data-testid":"policy-scaffolder-apply",disabled:r||a.filePath.trim()===""||a.exportName.trim()===""||a.policies.trim()==="",onClick:R,size:"xs",type:"button",children:e(r?"Wiring…":"Wire RLS")}),s(j,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=r,t[44]=a.exportName,t[45]=a.filePath,t[46]=a.policies,t[47]=l,t[48]=R,t[49]=e,t[50]=M):M=t[50];let z;t[51]!==i?(z=i?.kind==="error"&&s("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:i.message}),t[51]=i,t[52]=z):z=t[52];let q;t[53]!==i?.kind||t[54]!==e?(q=i?.kind==="needs-manual-edit"&&s("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),t[53]=i?.kind,t[54]=e,t[55]=q):q=t[55];let p;t[56]!==i||t[57]!==e?(p=i?.kind==="ok"&&u("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[s("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:i.label})}),i.diagnostics.length>0&&s("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:i.diagnostics.map(Ye)})]}),t[56]=i,t[57]=e,t[58]=p):p=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==M||t[62]!==z||t[63]!==q||t[64]!==p?(N=u(fe,{children:[U,W,M,z,q,p]}),t[59]=U,t[60]=W,t[61]=M,t[62]=z,t[63]=q,t[64]=p,t[65]=N):N=t[65];let B;return t[66]!==S||t[67]!==N?(B=u(me,{"data-testid":"policy-scaffolder",size:"sm",children:[S,N]}),t[66]=S,t[67]=N,t[68]=B):B=t[68],B};function Ye(t){return s("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}const bt=({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{const o=G(),[r,n]=b(void 0),i=(m,a,f)=>{f!==""&&n(c=>({functionPath:f,nonce:(c?.nonce??0)+1}))};return u("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[u("section",{className:"flex flex-col gap-3",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),s(Le,{onProbe:i})]}),s("section",{className:"flex flex-col gap-3",children:u(me,{className:"gap-0 py-0",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),u(fe,{className:"px-4 py-4",children:[s("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),s(Qe,{functions:t,prefill:r,runAsIdentity:e})]})]})}),l&&s("section",{className:"flex flex-col gap-2",children:s(Ve,{})})]})};export{bt as PermissionsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-
|
|
1
|
+
import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ne}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as w,a as ae,b as te,d as de,T as ce,e as O}from"../packem_shared/table-D0SBiDu-.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{h as J}from"../packem_shared/internal-hIuTpSbx.mjs";import{c as oe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as i,jsxs as z}from"react/jsx-runtime";const ue=new Set(["cancelled","completed","expired"]),fe=r=>ue.has(r),me=r=>r.extendedDueAt??r.dueAt,ve=r=>!fe(r)&&r!=="ready",pe=(r,e)=>ve(r.status)&&e.getTime()>me(r).getTime(),ye=(r,e)=>pe({dueAt:new Date(r.dueAt),status:r.status,...r.extendedDueAt===void 0||r.extendedDueAt===null?{}:{extendedDueAt:new Date(r.extendedDueAt)}},new Date(e)),he=["studio","privacy-requests"],xe={cancelled:"outline",completed:"success",expired:"outline",failed:"destructive",grace:"secondary",processing:"warning",ready:"success",received:"info"},Ae=r=>J(r??void 0,"—"),ge=r=>{const e=W(55),{asOf:o,retrying:t,row:s,onRetry:q}=r,a=X();let d,c,D;e[0]!==o||e[1]!==s?(c=ye(s,o),d=te,D=oe(c&&"bg-destructive/5"),e[0]=o,e[1]=s,e[2]=d,e[3]=c,e[4]=D):(d=e[2],c=e[3],D=e[4]);const S=c?"true":"false";let u;e[5]!==s.id?(u=i(O,{className:"font-mono text-xs",children:s.id}),e[5]=s.id,e[6]=u):u=e[6];let f;e[7]!==s.type||e[8]!==a?(f=s.type==="export"?a("Export"):a("Erasure"),e[7]=s.type,e[8]=a,e[9]=f):f=e[9];let E;e[10]!==f?(E=i(O,{children:i(G,{variant:"secondary",children:f})}),e[10]=f,e[11]=E):E=e[11];let n;e[12]!==s.subjectId?(n=i(O,{className:"font-mono text-xs",children:s.subjectId}),e[12]=s.subjectId,e[13]=n):n=e[13];const N=xe[s.status];let b;e[14]!==s.status||e[15]!==N?(b=i(O,{children:i(G,{variant:N,children:s.status})}),e[14]=s.status,e[15]=N,e[16]=b):b=e[16];let R;e[17]!==s.receivedAt?(R=J(s.receivedAt),e[17]=s.receivedAt,e[18]=R):R=e[18];let P;e[19]!==R?(P=i(O,{children:R}),e[19]=R,e[20]=P):P=e[20];let m;e[21]!==s.dueAt?(m=J(s.dueAt),e[21]=s.dueAt,e[22]=m):m=e[22];let v;e[23]!==m?(v=i(O,{children:m}),e[23]=m,e[24]=v):v=e[24];let p;e[25]!==s.extendedDueAt?(p=Ae(s.extendedDueAt),e[25]=s.extendedDueAt,e[26]=p):p=e[26];let y;e[27]!==p?(y=i(O,{children:p}),e[27]=p,e[28]=y):y=e[28];let h;e[29]!==c||e[30]!==a?(h=c&&i(G,{"data-testid":"privacy-overdue",variant:"destructive",children:a("Overdue")}),e[29]=c,e[30]=a,e[31]=h):h=e[31];let x;e[32]!==h?(x=i(O,{children:h}),e[32]=h,e[33]=x):x=e[33];let A;e[34]!==q||e[35]!==t||e[36]!==s.id||e[37]!==s.status||e[38]!==a?(A=s.status==="failed"&&i(ne,{disabled:t,onClick:()=>{q(s.id)},size:"xs",variant:"outline",children:a("Retry")}),e[34]=q,e[35]=t,e[36]=s.id,e[37]=s.status,e[38]=a,e[39]=A):A=e[39];let g;e[40]!==A?(g=i(O,{children:A}),e[40]=A,e[41]=g):g=e[41];let I;return e[42]!==d||e[43]!==D||e[44]!==P||e[45]!==v||e[46]!==y||e[47]!==x||e[48]!==g||e[49]!==S||e[50]!==u||e[51]!==E||e[52]!==n||e[53]!==b?(I=z(d,{className:D,"data-overdue":S,"data-testid":"privacy-request-row",children:[u,E,n,b,P,v,y,x,g]}),e[42]=d,e[43]=D,e[44]=P,e[45]=v,e[46]=y,e[47]=x,e[48]=g,e[49]=S,e[50]=u,e[51]=E,e[52]=n,e[53]=b,e[54]=I):I=e[54],I},Te=r=>{const e=W(95),{source:o}=r,t=X(),s=se(),q=le();let a;e[0]!==q?(a=[...he,q],e[0]=q,e[1]=a):a=e[1];const d=a;let c;e[2]!==o?(c=async()=>({asOf:Date.now(),requests:await o.listOpenPrivacyRequests()}),e[2]=o,e[3]=c):c=e[3];let D;e[4]!==d||e[5]!==c?(D={queryKey:d,refetchInterval:6e4,queryFn:c,staleTime:0},e[4]=d,e[5]=c,e[6]=D):D=e[6];const S=ie(D);let u;e[7]!==o?(u=l=>o.retryPrivacyRequest(l),e[7]=o,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==d?(f=async()=>{await s.invalidateQueries({queryKey:d})},e[9]=s,e[10]=d,e[11]=f):f=e[11];let E;e[12]!==u||e[13]!==f?(E={mutationFn:u,onSuccess:f},e[12]=u,e[13]=f,e[14]=E):E=e[14];const n=re(E);let N;e[15]!==n?(N=l=>{n.mutate(l)},e[15]=n,e[16]=N):N=e[16];const b=N;if(S.isPending){let l;e[17]!==t?(l=t("Loading privacy requests…"),e[17]=t,e[18]=l):l=e[18];let T;return e[19]!==l?(T=i("p",{className:"text-sm text-muted-foreground","data-testid":"privacy-requests-loading",role:"status",children:l}),e[19]=l,e[20]=T):T=e[20],T}if(S.isError){let l;return e[21]!==S.error?(l=i(Z,{error:S.error,testId:"privacy-requests-error"}),e[21]=S.error,e[22]=l):l=e[22],l}const{asOf:R,requests:P}=S.data;if(P.length===0){let l;e[23]!==t?(l=t("No open privacy requests."),e[23]=t,e[24]=l):l=e[24];let T;return e[25]!==l?(T=i(ee,{testId:"privacy-requests-empty",title:l}),e[25]=l,e[26]=T):T=e[26],T}let m;e[27]!==n.error||e[28]!==n.isError?(m=n.isError&&i(Z,{error:n.error,testId:"privacy-retry-error"}),e[27]=n.error,e[28]=n.isError,e[29]=m):m=e[29];let v;e[30]!==t?(v=t("ID"),e[30]=t,e[31]=v):v=e[31];let p;e[32]!==v?(p=i(w,{children:v}),e[32]=v,e[33]=p):p=e[33];let y;e[34]!==t?(y=t("Type"),e[34]=t,e[35]=y):y=e[35];let h;e[36]!==y?(h=i(w,{children:y}),e[36]=y,e[37]=h):h=e[37];let x;e[38]!==t?(x=t("Subject"),e[38]=t,e[39]=x):x=e[39];let A;e[40]!==x?(A=i(w,{children:x}),e[40]=x,e[41]=A):A=e[41];let g;e[42]!==t?(g=t("Status"),e[42]=t,e[43]=g):g=e[43];let I;e[44]!==g?(I=i(w,{children:g}),e[44]=g,e[45]=I):I=e[45];let j;e[46]!==t?(j=t("Received"),e[46]=t,e[47]=j):j=e[47];let B;e[48]!==j?(B=i(w,{children:j}),e[48]=j,e[49]=B):B=e[49];let C;e[50]!==t?(C=t("Due"),e[50]=t,e[51]=C):C=e[51];let Q;e[52]!==C?(Q=i(w,{children:C}),e[52]=C,e[53]=Q):Q=e[53];let U;e[54]!==t?(U=t("Extended due"),e[54]=t,e[55]=U):U=e[55];let V;e[56]!==U?(V=i(w,{children:U}),e[56]=U,e[57]=V):V=e[57];let _;e[58]!==t?(_=t("Overdue"),e[58]=t,e[59]=_):_=e[59];let $;e[60]!==_?($=i(w,{children:_}),e[60]=_,e[61]=$):$=e[61];let F;e[62]!==t?(F=t("Actions"),e[62]=t,e[63]=F):F=e[63];let H;e[64]!==F?(H=i(w,{children:F}),e[64]=F,e[65]=H):H=e[65];let K;e[66]!==p||e[67]!==h||e[68]!==A||e[69]!==I||e[70]!==B||e[71]!==Q||e[72]!==V||e[73]!==$||e[74]!==H?(K=i(ae,{children:z(te,{children:[p,h,A,I,B,Q,V,$,H]})}),e[66]=p,e[67]=h,e[68]=A,e[69]=I,e[70]=B,e[71]=Q,e[72]=V,e[73]=$,e[74]=H,e[75]=K):K=e[75];let L;if(e[76]!==R||e[77]!==b||e[78]!==P||e[79]!==n.isPending||e[80]!==n.variables){let l;e[82]!==R||e[83]!==b||e[84]!==n.isPending||e[85]!==n.variables?(l=T=>i(ge,{asOf:R,onRetry:b,retrying:n.isPending&&n.variables===T.id,row:T},T.id),e[82]=R,e[83]=b,e[84]=n.isPending,e[85]=n.variables,e[86]=l):l=e[86],L=P.map(l),e[76]=R,e[77]=b,e[78]=P,e[79]=n.isPending,e[80]=n.variables,e[81]=L}else L=e[81];let M;e[87]!==L?(M=i(de,{children:L}),e[87]=L,e[88]=M):M=e[88];let Y;e[89]!==K||e[90]!==M?(Y=z(ce,{children:[K,M]}),e[89]=K,e[90]=M,e[91]=Y):Y=e[91];let k;return e[92]!==Y||e[93]!==m?(k=z("div",{className:"flex flex-col gap-3",children:[m,Y]}),e[92]=Y,e[93]=m,e[94]=k):k=e[94],k},Be=r=>{const e=W(11);let o;e[0]!==r?(o=r===void 0?{}:r,e[0]=r,e[1]=o):o=e[1];const{source:t}=o,s=X();if(t===void 0){let a;e[2]!==s?(a=s("Pass privacyRequests to the Studio to list and retry data-subject requests."),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==s?(d=s("Privacy requests not configured"),e[4]=s,e[5]=d):d=e[5];let c;return e[6]!==a||e[7]!==d?(c=i(ee,{description:a,testId:"privacy-requests-not-configured",title:d}),e[6]=a,e[7]=d,e[8]=c):c=e[8],c}let q;return e[9]!==t?(q=i(Te,{source:t}),e[9]=t,e[10]=q):q=e[10],q};export{Be as PrivacyRequestsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as B}from"react/compiler-runtime";import{useState as L,Fragment as Ze}from"react";import{ConfirmButton as et}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{E as tt}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{A as st}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ae}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Le}from"../packem_shared/button-q0UYSmrn.mjs";import{C as We,a as Je}from"../packem_shared/card-By2O8ULa.mjs";import{E as Re}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as rt}from"../packem_shared/input-CXhxesPC.mjs";import{S as at}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Pe,a as je,b as z,c as w,d as Ge,e as v}from"../packem_shared/table-D0SBiDu-.mjs";import{T as nt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Fe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as b,Fragment as ze}from"react/jsx-runtime";const ct=(a,e)=>{const t=new Set(a.map(n=>n.deadLetterQueue).filter(n=>typeof n=="string"&&n!=="")),i=a.filter(n=>(n.deadLetterQueue===void 0||n.deadLetterQueue==="")&&!t.has(n.name)),r=e.filter(n=>n.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||r>0}},Me="topic:",Be=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},He=a=>`${Me}${a}`,ut=(a,e)=>a.startsWith(Me)?(e.get(a.slice(Me.length))??[]).map(t=>t.exportName):[a],mt=200,pt=De(H.sendQueueMessage),ft=async(a,e,t)=>{const r=(await Promise.allSettled(e.map(async o=>a.query(pt,o,Ie(""))))).flatMap((o,l)=>o.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ue(o.reason)}]:[]),[n]=r;return n===void 0?null:e.length===1?n.message:t("Not sent to {failed}",{failed:r.map(o=>`${o.exportName}: ${o.message}`).join("; ")})},ht=De(H.replayQueueMessage),gt=De(H.clearQueueMessages),Ue=96,xt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},yt=a=>a.length>Ue?`${a.slice(0,Ue)}…`:a,bt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",Nt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ve=a=>{const e=B(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let r;e[0]!==t.exportName?(r=s(v,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let n;e[2]!==t.name?(n=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=n):n=e[3];let o;e[4]!==t.mode?(o=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=o):o=e[5];let l;e[6]!==t.binding?(l=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const d=t.deadLetterQueue??"—";let c;e[8]!==d?(c=s(v,{className:"font-mono text-xs text-muted-foreground",children:d}),e[8]=d,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==c?(m=b(z,{"data-testid":i,children:[r,n,o,l,c]}),e[10]=i,e[11]=r,e[12]=n,e[13]=o,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},qt=a=>{const e=B(8),{loaded:t,queues:i}=a,r=G();let n;if(e[0]!==t||e[1]!==i||e[2]!==r){const{plain:o,topics:l}=Be(i);let d;e[4]!==r?(d=r("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[4]=r,e[5]=d):d=e[5];let c;e[6]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[6]=d,e[7]=c):c=e[7],n=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(Re,{description:r("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:r("No queues defined")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:b(Pe,{"data-testid":"queues-table",children:[s(je,{children:b(z,{children:[s(w,{children:r("Export")}),s(w,{children:r("Queue")}),s(w,{children:r("Mode")}),s(w,{children:r("Binding")}),s(w,{children:r("Dead-letter")})]})}),b(Ge,{children:[o.map(vt),[...l].map(m=>{const[h,g]=m;return b(Ze,{children:[s(z,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(v,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(wt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=r,e[3]=n}else n=e[3];return n},St=a=>{const e=B(67),{message:t,onReplay:i,replayingId:r}=a,n=G();let o,l,d,c,m,h,g,u,p,y;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]!==n){const $=xt(t.body);l=z,h=`queues-message-${t.id}`;const O=t.exportName??t.queue;e[19]!==O?(g=s(v,{className:"font-mono text-xs",children:O}),e[19]=O,e[20]=g):g=e[20],e[21]!==t.messageId?(u=s(v,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(p=s(v,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const R=`queues-outcome-${t.id}`;let C;e[25]!==t.outcome?(C=bt(t.outcome),e[25]=t.outcome,e[26]=C):C=e[26];let I;e[27]!==t.outcome||e[28]!==R||e[29]!==C?(I=s(Ae,{"data-testid":R,variant:C,children:t.outcome}),e[27]=t.outcome,e[28]=R,e[29]=C,e[30]=I):I=e[30];let _;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==n?(_=t.deadLettered&&s(Ae,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:n("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=n,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(y=s(v,{children:b("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=y):y=e[37],o=v,d="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=$,m=yt($),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]=n,e[9]=o,e[10]=l,e[11]=d,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=u,e[17]=p,e[18]=y}else o=e[9],l=e[10],d=e[11],c=e[12],m=e[13],h=e[14],g=e[15],u=e[16],p=e[17],y=e[18];let x;e[38]!==o||e[39]!==d||e[40]!==c||e[41]!==m?(x=s(o,{className:d,title:c,children:m}),e[38]=o,e[39]=d,e[40]=c,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(v,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=r!==null;let Q;e[47]!==t.id||e[48]!==r||e[49]!==n?(Q=r===t.id?n("Replaying…"):n("Replay"),e[47]=t.id,e[48]=r,e[49]=n,e[50]=Q):Q=e[50];let A;e[51]!==t.id||e[52]!==i||e[53]!==q||e[54]!==S||e[55]!==Q?(A=s(v,{children:s(Le,{"data-id":t.id,"data-testid":q,disabled:S,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=i,e[53]=q,e[54]=S,e[55]=Q,e[56]=A):A=e[56];let M;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==u||e[63]!==p||e[64]!==y||e[65]!==x?(M=b(l,{"data-testid":h,children:[g,u,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=u,e[63]=p,e[64]=y,e[65]=x,e[66]=M):M=e[66],M},Et=a=>{const e=B(29),{hasError:t,messages:i,onClear:r,onReplay:n,replayingId:o}=a,l=G();let d;e[0]!==l?(d=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let u;e[8]!==r||e[9]!==m||e[10]!==h||e[11]!==g?(u=s("div",{className:"ml-auto",children:s(et,{confirmLabel:m,disabled:h,onConfirm:r,testId:"queues-clear",children:g})}),e[8]=r,e[9]=m,e[10]=h,e[11]=g,e[12]=u):u=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Ae,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==u||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p]}),e[16]=c,e[17]=u,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==n||e[23]!==o||e[24]!==l?(x=!t&&i.length===0?s(Re,{description:l("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:l("No consumed messages yet.")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:s(at,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Pe,{"data-testid":"queues-messages-table",children:[s(je,{children:b(z,{children:[s(w,{children:l("Export")}),s(w,{children:l("Message")}),s(w,{children:l("Attempts")}),s(w,{children:l("Outcome")}),s(w,{children:l("Body")}),s(w,{children:l("Captured")}),s(w,{})]})}),s(Ge,{children:i.map(T=>s(St,{message:T,onReplay:n,replayingId:o},T.id))})]})})})}),e[20]=t,e[21]=i,e[22]=n,e[23]=o,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},Tt=a=>{const e=B(20),{batchMode:t,bodyText:i,delayText:r,onBatchModeChange:n,onBodyChange:o,onDelayChange:l,onSelectExport:d,onSend:c,queues:m,selectedExportName:h,sending:g}=a,u=G();let p;e[0]!==u?(p=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==r||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==d||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==u?(x=m.length===0?s(Re,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):b(ze,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":u("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:d,value:h,children:[m.map(Qt),[...Be(m).topics].map(T=>{const[q,S]=T;return s("option",{value:He(q),children:u("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(rt,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:u("Delay (s)"),type:"number",value:r}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:n,type:"checkbox"}),u("Send as batch (JSON array)")]}),s(Le,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:u(g?"Sending…":"Send message")})]}),s(nt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=r,e[7]=n,e[8]=o,e[9]=l,e[10]=d,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=u,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},Ct=(a,e,t,i)=>{let r=null;const n=a.trim();if(n!=="")try{r=JSON.parse(n)}catch{return{error:i("Body must be valid JSON.")}}let o;const l=e.trim();if(l!==""){const d=Number(l);if(!Number.isFinite(d)||d<0)return{error:i("Delay must be a non-negative number of seconds.")};o=d}return t&&!Array.isArray(r)?{error:i("Batch mode needs a JSON array body — each element is enqueued as one message.")}:{body:r,delaySeconds:o}},_t=a=>{const e=B(11),{deadLetteredCount:t,queuesWithoutDlq:i}=a,r=G();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),e[0]=n):n=e[0];let o;e[1]!==i||e[2]!==r?(o=i.length>0&&b(ze,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:i.map(At).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=i,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==t||e[5]!==i.length||e[6]!==r?(l=t>0&&s("p",{className:i.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=i.length,e[6]=r,e[7]=l):l=e[7];let d;return e[8]!==o||e[9]!==l?(d=s(st,{icon:n,testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[o,l]})}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},ts=a=>{const e=B(76),{limit:t}=a,i=t??mt,r=lt(),n=G(),[o,l]=L("declared"),[d,c]=L(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:u}=Fe(H.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=Fe(H.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(It):[],Q=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:M,showReliabilityWarning:$}=ct(S,Q),[O,R]=L(""),[C,I]=L(""),[_,me]=L(""),[D,pe]=L(!1),[fe,V]=L(!1),[he,X]=L(null),{topics:Y}=Be(S),$e=[...S.map(Mt),...[...Y.keys()].map(Lt)],k=$e.includes(O)?O:$e[0]??"",Oe=o==="messages"?x:g,Xe=o==="messages"?N:u,ge=Oe??d,xe=Oe===null?d:Xe;ot(T,o==="messages");let K;e[3]!==D||e[4]!==C||e[5]!==r||e[6]!==_||e[7]!==q||e[8]!==k||e[9]!==V||e[10]!==n||e[11]!==Y?(K=async()=>{c(null);const f=k;if(f==="")return;const E=Ct(C,_,D,n);if("error"in E){c(E.error);return}const{body:we,delaySeconds:ke}=E;V(!0);const Ke=ut(f,Y).map(ce=>D?{batch:we,delaySeconds:ke,exportName:ce}:{body:we,delaySeconds:ke,exportName:ce});try{c(await ft(r,Ke,n)),q()}catch(ce){c(ue(ce))}V(!1)},e[3]=D,e[4]=C,e[5]=r,e[6]=_,e[7]=q,e[8]=k,e[9]=V,e[10]=n,e[11]=Y,e[12]=K):K=e[12];const ye=K;let Z;e[13]!==r||e[14]!==q||e[15]!==X?(Z=async f=>{c(null),X(f);try{await r.query(ht,{id:f},Ie("")),q()}catch(E){c(ue(E))}X(null)},e[13]=r,e[14]=q,e[15]=X,e[16]=Z):Z=e[16];const be=Z;let ee;e[17]!==r||e[18]!==q?(ee=async()=>{c(null);try{await r.query(gt,{},Ie("")),q()}catch(f){c(ue(f))}},e[17]=r,e[18]=q,e[19]=ee):ee=e[19];const Ne=ee;let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[20]=te):te=e[20];const Ye=te;let se;e[21]!==R?(se=f=>{R(f.currentTarget.value)},e[21]=R,e[22]=se):se=e[22];const qe=se;let re;e[23]!==I?(re=f=>{I(f.currentTarget.value)},e[23]=I,e[24]=re):re=e[24];const Se=re;let ae;e[25]!==me?(ae=f=>{me(f.currentTarget.value)},e[25]=me,e[26]=ae):ae=e[26];const Ee=ae;let ne;e[27]!==pe?(ne=f=>{pe(f.currentTarget.checked)},e[27]=pe,e[28]=ne):ne=e[28];const Te=ne;let oe;e[29]!==ye?(oe=()=>{Qe(ye())},e[29]=ye,e[30]=oe):oe=e[30];const Ce=oe;let le;e[31]!==be?(le=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Qe(be(E))},e[31]=be,e[32]=le):le=e[32];const _e=le;let ie;e[33]!==Ne?(ie=()=>{Qe(Ne())},e[33]=Ne,e[34]=ie):ie=e[34];const ve=ie;let F;e[35]!==n||e[36]!==o?(F=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Le,{"aria-selected":o===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Ye,role:"tab",size:"sm",type:"button",variant:o===f?"secondary":"ghost",children:Nt(f,n)},f))}),e[35]=n,e[36]=o,e[37]=F):F=e[37];let U;e[38]!==ge||e[39]!==xe?(U=ge!==null&&s(tt,{error:xe,testId:"queues-error"}),e[38]=ge,e[39]=xe,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==M||e[43]!==$?(W=$&&s(_t,{deadLetteredCount:A,queuesWithoutDlq:M}),e[41]=A,e[42]=M,e[43]=$,e[44]=W):W=e[44];let J;e[45]!==S||e[46]!==h||e[47]!==o?(J=o==="declared"&&s(qt,{loaded:h!==void 0,queues:S}),e[45]=S,e[46]=h,e[47]=o,e[48]=J):J=e[48];let P;e[49]!==Q||e[50]!==x||e[51]!==ve||e[52]!==_e||e[53]!==he||e[54]!==o?(P=o==="messages"&&s(Et,{hasError:x!==null,messages:Q,onClear:ve,onReplay:_e,replayingId:he}),e[49]=Q,e[50]=x,e[51]=ve,e[52]=_e,e[53]=he,e[54]=o,e[55]=P):P=e[55];let j;e[56]!==D||e[57]!==C||e[58]!==_||e[59]!==Te||e[60]!==Se||e[61]!==Ee||e[62]!==qe||e[63]!==Ce||e[64]!==S||e[65]!==k||e[66]!==fe||e[67]!==o?(j=o==="send"&&s(Tt,{batchMode:D,bodyText:C,delayText:_,onBatchModeChange:Te,onBodyChange:Se,onDelayChange:Ee,onSelectExport:qe,onSend:Ce,queues:S,selectedExportName:k,sending:fe}),e[56]=D,e[57]=C,e[58]=_,e[59]=Te,e[60]=Se,e[61]=Ee,e[62]=qe,e[63]=Ce,e[64]=S,e[65]=k,e[66]=fe,e[67]=o,e[68]=j):j=e[68];let de;return e[69]!==F||e[70]!==U||e[71]!==W||e[72]!==J||e[73]!==P||e[74]!==j?(de=b("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[F,U,W,J,P,j]}),e[69]=F,e[70]=U,e[71]=W,e[72]=J,e[73]=P,e[74]=j,e[75]=de):de=e[75],de};function vt(a){return s(Ve,{queue:a},a.exportName)}function wt(a){return s(Ve,{queue:a},a.exportName)}function Qt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function At(a){return a.name}function It(a,e){return a.exportName.localeCompare(e.exportName)}function Mt(a){return a.exportName}function Lt(a){return He(a)}export{ts as default};
|
|
1
|
+
import{c as B}from"react/compiler-runtime";import{useState as L,Fragment as Ze}from"react";import{ConfirmButton as et}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{E as tt}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{A as st}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ae}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Le}from"../packem_shared/button-q0UYSmrn.mjs";import{C as We,a as Je}from"../packem_shared/card-By2O8ULa.mjs";import{E as Re}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as rt}from"../packem_shared/input-CXhxesPC.mjs";import{S as at}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Pe,a as je,b as z,c as w,d as Ge,e as v}from"../packem_shared/table-D0SBiDu-.mjs";import{T as nt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Fe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as b,Fragment as ze}from"react/jsx-runtime";const ct=(a,e)=>{const t=new Set(a.map(n=>n.deadLetterQueue).filter(n=>typeof n=="string"&&n!=="")),i=a.filter(n=>(n.deadLetterQueue===void 0||n.deadLetterQueue==="")&&!t.has(n.name)),r=e.filter(n=>n.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||r>0}},Me="topic:",Be=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},He=a=>`${Me}${a}`,ut=(a,e)=>a.startsWith(Me)?(e.get(a.slice(Me.length))??[]).map(t=>t.exportName):[a],mt=200,pt=De(H.sendQueueMessage),ft=async(a,e,t)=>{const r=(await Promise.allSettled(e.map(async o=>a.query(pt,o,Ie(""))))).flatMap((o,l)=>o.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ue(o.reason)}]:[]),[n]=r;return n===void 0?null:e.length===1?n.message:t("Not sent to {failed}",{failed:r.map(o=>`${o.exportName}: ${o.message}`).join("; ")})},ht=De(H.replayQueueMessage),gt=De(H.clearQueueMessages),Ue=96,xt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},yt=a=>a.length>Ue?`${a.slice(0,Ue)}…`:a,bt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",Nt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ve=a=>{const e=B(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let r;e[0]!==t.exportName?(r=s(v,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let n;e[2]!==t.name?(n=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=n):n=e[3];let o;e[4]!==t.mode?(o=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=o):o=e[5];let l;e[6]!==t.binding?(l=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const d=t.deadLetterQueue??"—";let c;e[8]!==d?(c=s(v,{className:"font-mono text-xs text-muted-foreground",children:d}),e[8]=d,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==c?(m=b(z,{"data-testid":i,children:[r,n,o,l,c]}),e[10]=i,e[11]=r,e[12]=n,e[13]=o,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},qt=a=>{const e=B(8),{loaded:t,queues:i}=a,r=G();let n;if(e[0]!==t||e[1]!==i||e[2]!==r){const{plain:o,topics:l}=Be(i);let d;e[4]!==r?(d=r("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[4]=r,e[5]=d):d=e[5];let c;e[6]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[6]=d,e[7]=c):c=e[7],n=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(Re,{description:r("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:r("No queues defined")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:b(Pe,{"data-testid":"queues-table",children:[s(je,{children:b(z,{children:[s(w,{children:r("Export")}),s(w,{children:r("Queue")}),s(w,{children:r("Mode")}),s(w,{children:r("Binding")}),s(w,{children:r("Dead-letter")})]})}),b(Ge,{children:[o.map(vt),[...l].map(m=>{const[h,g]=m;return b(Ze,{children:[s(z,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(v,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(wt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=r,e[3]=n}else n=e[3];return n},St=a=>{const e=B(67),{message:t,onReplay:i,replayingId:r}=a,n=G();let o,l,d,c,m,h,g,u,p,y;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]!==n){const $=xt(t.body);l=z,h=`queues-message-${t.id}`;const O=t.exportName??t.queue;e[19]!==O?(g=s(v,{className:"font-mono text-xs",children:O}),e[19]=O,e[20]=g):g=e[20],e[21]!==t.messageId?(u=s(v,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(p=s(v,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const R=`queues-outcome-${t.id}`;let C;e[25]!==t.outcome?(C=bt(t.outcome),e[25]=t.outcome,e[26]=C):C=e[26];let I;e[27]!==t.outcome||e[28]!==R||e[29]!==C?(I=s(Ae,{"data-testid":R,variant:C,children:t.outcome}),e[27]=t.outcome,e[28]=R,e[29]=C,e[30]=I):I=e[30];let _;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==n?(_=t.deadLettered&&s(Ae,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:n("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=n,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(y=s(v,{children:b("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=y):y=e[37],o=v,d="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=$,m=yt($),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]=n,e[9]=o,e[10]=l,e[11]=d,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=u,e[17]=p,e[18]=y}else o=e[9],l=e[10],d=e[11],c=e[12],m=e[13],h=e[14],g=e[15],u=e[16],p=e[17],y=e[18];let x;e[38]!==o||e[39]!==d||e[40]!==c||e[41]!==m?(x=s(o,{className:d,title:c,children:m}),e[38]=o,e[39]=d,e[40]=c,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(v,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=r!==null;let Q;e[47]!==t.id||e[48]!==r||e[49]!==n?(Q=r===t.id?n("Replaying…"):n("Replay"),e[47]=t.id,e[48]=r,e[49]=n,e[50]=Q):Q=e[50];let A;e[51]!==t.id||e[52]!==i||e[53]!==q||e[54]!==S||e[55]!==Q?(A=s(v,{children:s(Le,{"data-id":t.id,"data-testid":q,disabled:S,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=i,e[53]=q,e[54]=S,e[55]=Q,e[56]=A):A=e[56];let M;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==u||e[63]!==p||e[64]!==y||e[65]!==x?(M=b(l,{"data-testid":h,children:[g,u,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=u,e[63]=p,e[64]=y,e[65]=x,e[66]=M):M=e[66],M},Et=a=>{const e=B(29),{hasError:t,messages:i,onClear:r,onReplay:n,replayingId:o}=a,l=G();let d;e[0]!==l?(d=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let u;e[8]!==r||e[9]!==m||e[10]!==h||e[11]!==g?(u=s("div",{className:"ml-auto",children:s(et,{confirmLabel:m,disabled:h,onConfirm:r,testId:"queues-clear",children:g})}),e[8]=r,e[9]=m,e[10]=h,e[11]=g,e[12]=u):u=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Ae,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==u||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p]}),e[16]=c,e[17]=u,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==n||e[23]!==o||e[24]!==l?(x=!t&&i.length===0?s(Re,{description:l("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:l("No consumed messages yet.")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:s(at,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Pe,{"data-testid":"queues-messages-table",children:[s(je,{children:b(z,{children:[s(w,{children:l("Export")}),s(w,{children:l("Message")}),s(w,{children:l("Attempts")}),s(w,{children:l("Outcome")}),s(w,{children:l("Body")}),s(w,{children:l("Captured")}),s(w,{})]})}),s(Ge,{children:i.map(T=>s(St,{message:T,onReplay:n,replayingId:o},T.id))})]})})})}),e[20]=t,e[21]=i,e[22]=n,e[23]=o,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},Tt=a=>{const e=B(20),{batchMode:t,bodyText:i,delayText:r,onBatchModeChange:n,onBodyChange:o,onDelayChange:l,onSelectExport:d,onSend:c,queues:m,selectedExportName:h,sending:g}=a,u=G();let p;e[0]!==u?(p=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==r||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==d||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==u?(x=m.length===0?s(Re,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):b(ze,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":u("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:d,value:h,children:[m.map(Qt),[...Be(m).topics].map(T=>{const[q,S]=T;return s("option",{value:He(q),children:u("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(rt,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:u("Delay (s)"),type:"number",value:r}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:n,type:"checkbox"}),u("Send as batch (JSON array)")]}),s(Le,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:u(g?"Sending…":"Send message")})]}),s(nt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=r,e[7]=n,e[8]=o,e[9]=l,e[10]=d,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=u,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},Ct=(a,e,t,i)=>{let r=null;const n=a.trim();if(n!=="")try{r=JSON.parse(n)}catch{return{error:i("Body must be valid JSON.")}}let o;const l=e.trim();if(l!==""){const d=Number(l);if(!Number.isFinite(d)||d<0)return{error:i("Delay must be a non-negative number of seconds.")};o=d}return t&&!Array.isArray(r)?{error:i("Batch mode needs a JSON array body — each element is enqueued as one message.")}:{body:r,delaySeconds:o}},_t=a=>{const e=B(11),{deadLetteredCount:t,queuesWithoutDlq:i}=a,r=G();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),e[0]=n):n=e[0];let o;e[1]!==i||e[2]!==r?(o=i.length>0&&b(ze,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:i.map(At).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=i,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==t||e[5]!==i.length||e[6]!==r?(l=t>0&&s("p",{className:i.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=i.length,e[6]=r,e[7]=l):l=e[7];let d;return e[8]!==o||e[9]!==l?(d=s(st,{icon:n,testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[o,l]})}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},ts=a=>{const e=B(76),{limit:t}=a,i=t??mt,r=lt(),n=G(),[o,l]=L("declared"),[d,c]=L(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:u}=Fe(H.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=Fe(H.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(It):[],Q=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:M,showReliabilityWarning:$}=ct(S,Q),[O,R]=L(""),[C,I]=L(""),[_,me]=L(""),[D,pe]=L(!1),[fe,V]=L(!1),[he,X]=L(null),{topics:Y}=Be(S),$e=[...S.map(Mt),...[...Y.keys()].map(Lt)],k=$e.includes(O)?O:$e[0]??"",Oe=o==="messages"?x:g,Xe=o==="messages"?N:u,ge=Oe??d,xe=Oe===null?d:Xe;ot(T,o==="messages");let K;e[3]!==D||e[4]!==C||e[5]!==r||e[6]!==_||e[7]!==q||e[8]!==k||e[9]!==V||e[10]!==n||e[11]!==Y?(K=async()=>{c(null);const f=k;if(f==="")return;const E=Ct(C,_,D,n);if("error"in E){c(E.error);return}const{body:we,delaySeconds:ke}=E;V(!0);const Ke=ut(f,Y).map(ce=>D?{batch:we,delaySeconds:ke,exportName:ce}:{body:we,delaySeconds:ke,exportName:ce});try{c(await ft(r,Ke,n)),q()}catch(ce){c(ue(ce))}V(!1)},e[3]=D,e[4]=C,e[5]=r,e[6]=_,e[7]=q,e[8]=k,e[9]=V,e[10]=n,e[11]=Y,e[12]=K):K=e[12];const ye=K;let Z;e[13]!==r||e[14]!==q||e[15]!==X?(Z=async f=>{c(null),X(f);try{await r.query(ht,{id:f},Ie("")),q()}catch(E){c(ue(E))}X(null)},e[13]=r,e[14]=q,e[15]=X,e[16]=Z):Z=e[16];const be=Z;let ee;e[17]!==r||e[18]!==q?(ee=async()=>{c(null);try{await r.query(gt,{},Ie("")),q()}catch(f){c(ue(f))}},e[17]=r,e[18]=q,e[19]=ee):ee=e[19];const Ne=ee;let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[20]=te):te=e[20];const Ye=te;let se;e[21]!==R?(se=f=>{R(f.currentTarget.value)},e[21]=R,e[22]=se):se=e[22];const qe=se;let re;e[23]!==I?(re=f=>{I(f.currentTarget.value)},e[23]=I,e[24]=re):re=e[24];const Se=re;let ae;e[25]!==me?(ae=f=>{me(f.currentTarget.value)},e[25]=me,e[26]=ae):ae=e[26];const Ee=ae;let ne;e[27]!==pe?(ne=f=>{pe(f.currentTarget.checked)},e[27]=pe,e[28]=ne):ne=e[28];const Te=ne;let oe;e[29]!==ye?(oe=()=>{Qe(ye())},e[29]=ye,e[30]=oe):oe=e[30];const Ce=oe;let le;e[31]!==be?(le=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Qe(be(E))},e[31]=be,e[32]=le):le=e[32];const _e=le;let ie;e[33]!==Ne?(ie=()=>{Qe(Ne())},e[33]=Ne,e[34]=ie):ie=e[34];const ve=ie;let F;e[35]!==n||e[36]!==o?(F=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Le,{"aria-selected":o===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Ye,role:"tab",size:"sm",type:"button",variant:o===f?"secondary":"ghost",children:Nt(f,n)},f))}),e[35]=n,e[36]=o,e[37]=F):F=e[37];let U;e[38]!==ge||e[39]!==xe?(U=ge!==null&&s(tt,{error:xe,testId:"queues-error"}),e[38]=ge,e[39]=xe,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==M||e[43]!==$?(W=$&&s(_t,{deadLetteredCount:A,queuesWithoutDlq:M}),e[41]=A,e[42]=M,e[43]=$,e[44]=W):W=e[44];let J;e[45]!==S||e[46]!==h||e[47]!==o?(J=o==="declared"&&s(qt,{loaded:h!==void 0,queues:S}),e[45]=S,e[46]=h,e[47]=o,e[48]=J):J=e[48];let P;e[49]!==Q||e[50]!==x||e[51]!==ve||e[52]!==_e||e[53]!==he||e[54]!==o?(P=o==="messages"&&s(Et,{hasError:x!==null,messages:Q,onClear:ve,onReplay:_e,replayingId:he}),e[49]=Q,e[50]=x,e[51]=ve,e[52]=_e,e[53]=he,e[54]=o,e[55]=P):P=e[55];let j;e[56]!==D||e[57]!==C||e[58]!==_||e[59]!==Te||e[60]!==Se||e[61]!==Ee||e[62]!==qe||e[63]!==Ce||e[64]!==S||e[65]!==k||e[66]!==fe||e[67]!==o?(j=o==="send"&&s(Tt,{batchMode:D,bodyText:C,delayText:_,onBatchModeChange:Te,onBodyChange:Se,onDelayChange:Ee,onSelectExport:qe,onSend:Ce,queues:S,selectedExportName:k,sending:fe}),e[56]=D,e[57]=C,e[58]=_,e[59]=Te,e[60]=Se,e[61]=Ee,e[62]=qe,e[63]=Ce,e[64]=S,e[65]=k,e[66]=fe,e[67]=o,e[68]=j):j=e[68];let de;return e[69]!==F||e[70]!==U||e[71]!==W||e[72]!==J||e[73]!==P||e[74]!==j?(de=b("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[F,U,W,J,P,j]}),e[69]=F,e[70]=U,e[71]=W,e[72]=J,e[73]=P,e[74]=j,e[75]=de):de=e[75],de};function vt(a){return s(Ve,{queue:a},a.exportName)}function wt(a){return s(Ve,{queue:a},a.exportName)}function Qt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function At(a){return a.name}function It(a,e){return a.exportName.localeCompare(e.exportName)}function Mt(a){return a.exportName}function Lt(a){return He(a)}export{ts as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as g}from"../packem_shared/error-alert-
|
|
1
|
+
import{E as g}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card-By2O8ULa.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as A,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as E}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as S}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=S(),{data:l,error:p,errorSource:u,liveError:f}=E(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(A,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,shardKey:a,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as W}from"react/compiler-runtime";import{u as G}from"../packem_shared/assistant-provider-
|
|
1
|
+
import{c as W}from"react/compiler-runtime";import{u as G}from"../packem_shared/assistant-provider-Dw0roZh3.mjs";import{E as F}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{B as U}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as B,C as M}from"../packem_shared/card-By2O8ULa.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as L,a as H,b as C,c as A,d as O,e as T}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Q}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{jsx as s,jsxs as a}from"react/jsx-runtime";const _=["read","insert","update","delete"],P=30,z=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],J=e=>{const t=new Map;for(const l of e){const r=t.get(l.table)??{operations:new Set,procedures:new Set,table:l.table};r.operations.add(l.on),r.procedures.add(l.procedure),t.set(l.table,r)}return[...t.values()].toSorted((l,r)=>l.table.localeCompare(r.table))},K=e=>{const t=e.slice(0,P).map(l=>`${l.table}: ${_.filter(r=>l.operations.has(r)).join("/")}`).join("; ");return e.length>P?`${t}; and ${String(e.length-P)} more tables`:t},ce=()=>{const e=W(45),t=X(),l=G(),r=l!==void 0&&!l.unavailable;let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const{data:i,error:E,errorSource:$}=Q(q.rlsPolicies,S),o=i!==void 0;let c;e[1]!==i?(c=Array.isArray(i?.policies)?i.policies:[],e[1]=i,e[2]=c):c=e[2];let v;e[3]!==c?(v=J(c),e[3]=c,e[4]=v):v=e[4];const n=v;let I;e[5]!==i?(I=Array.isArray(i?.roles)?i.roles:[],e[5]=i,e[6]=I):I=e[6];const R=I;let p;e[7]!==E||e[8]!==$?(p=E!==null&&s(F,{error:$,testId:"rls-error"}),e[7]=E,e[8]=$,e[9]=p):p=e[9];let m;e[10]!==t?(m=t("Policies"),e[10]=t,e[11]=m):m=e[11];let h;e[12]!==m?(h=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),e[12]=m,e[13]=h):h=e[13];let u;e[14]!==l||e[15]!==r||e[16]!==o||e[17]!==t||e[18]!==n?(u=o&&r&&s("button",{className:"ms-auto text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"rls-ask-assistant",onClick:()=>{l.openAssistant({ask:n.length===0?t("This app declares no row-level-security policies at all. Which tables most need one, and what policy should I write for them?"):t("The Lunora RLS inspector shows these declared policies — {coverage}. Which tables and operations are still unguarded, and what policy should I add?",{coverage:K(n)}),suggestions:[t("Which procedures still need .use(rls(...))?"),t("How do I test a policy?")],title:t("Access rules")})},type:"button",children:t("Ask the assistant")}),e[14]=l,e[15]=r,e[16]=o,e[17]=t,e[18]=n,e[19]=u):u=e[19];let f;e[20]!==h||e[21]!==u?(f=a("header",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[h,u]}),e[20]=h,e[21]=u,e[22]=f):f=e[22];let b;e[23]!==o||e[24]!==t||e[25]!==n?(b=o&&n.length===0?s(D,{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")}):s(B,{className:"px-0",children:a(L,{"data-testid":"rls-policies-table",children:[s(H,{children:a(C,{children:[s(A,{children:t("Table")}),_.map(d=>s(A,{children:z(t,d)},d)),s(A,{children:t("Guarded by")})]})}),s(O,{children:n.map(d=>a(C,{"data-testid":`rls-table-${d.table}`,children:[s(T,{className:"font-mono text-xs",children:d.table}),_.map(j=>s(T,{children:d.operations.has(j)?s(U,{variant:"secondary",children:t("Guarded")}):s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},j)),s(T,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[23]=o,e[24]=t,e[25]=n,e[26]=b):b=e[26];let x;e[27]!==f||e[28]!==b?(x=s("section",{className:"flex flex-col gap-2",children:a(M,{className:"overflow-hidden py-0",children:[f,b]})}),e[27]=f,e[28]=b,e[29]=x):x=e[29];let g;e[30]!==t?(g=t("Roles"),e[30]=t,e[31]=g):g=e[31];let y;e[32]!==g?(y=s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[32]=g,e[33]=y):y=e[33];let N;e[34]!==o||e[35]!==R||e[36]!==t?(N=o&&R.length===0?s(D,{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")}):s(B,{className:"px-0",children:a(L,{"data-testid":"rls-roles-table",children:[s(H,{children:a(C,{children:[s(A,{children:t("Role")}),s(A,{children:t("Description")}),s(A,{children:t("Permissions")})]})}),s(O,{children:R.map(Y)})]})}),e[34]=o,e[35]=R,e[36]=t,e[37]=N):N=e[37];let w;e[38]!==y||e[39]!==N?(w=s("section",{className:"flex flex-col gap-2",children:a(M,{className:"overflow-hidden py-0",children:[y,N]})}),e[38]=y,e[39]=N,e[40]=w):w=e[40];let k;return e[41]!==x||e[42]!==w||e[43]!==p?(k=a("div",{className:"flex flex-col gap-6","data-testid":"lunora-rls-panel",children:[p,x,w]}),e[41]=x,e[42]=w,e[43]=p,e[44]=k):k=e[44],k};function V(e){return s(U,{variant:"outline",children:e},e)}function Y(e){return a(C,{"data-testid":`rls-role-${e.name}`,children:[s(T,{className:"font-mono text-xs",children:e.name}),s(T,{className:"text-muted-foreground",children:e.description??""}),s(T,{children:e.permissions.length===0?s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):s("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(V)})})]},e.name)}export{ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as V}from"react/compiler-runtime";import{useState as G}from"react";import{D as we}from"../packem_shared/studio-DE7i2--m.mjs";import{B as le}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as j,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as ee,c as O,a as te,b as Q,d as se,e as K}from"../packem_shared/table-D0SBiDu-.mjs";import{a as ne,u as xe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as re}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as ie,f as Z,j as ge,b as de,c as ve,d as ke}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as R}from"react/jsx-runtime";import{I as Se}from"../packem_shared/input-CXhxesPC.mjs";import{u as Ce}from"../packem_shared/use-assistant-rpc-DCC6ph2u.mjs";import{c as Te}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as Ae}from"@lunora/react";import{ShardInput as be}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{u as ye}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as ce}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{ScheduledJobs as $e}from"../packem_shared/ScheduledJobs-QCTRdugp.mjs";const Ne={failed:"destructive",skipped:"warning",succeeded:"success"},Ie=25,Ee=t=>t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(1)} s`,Re=t=>{const e=V(39),{inFlight:i,last:n}=t,l=z();if(i!==void 0){let h;e[0]!==l?(h=l("running"),e[0]=l,e[1]=h):h=e[1];let g;e[2]!==h?(g=s(Y,{variant:"info",children:h}),e[2]=h,e[3]=g):g=e[3];let b;e[4]!==i.startedAt?(b=ie(i.startedAt,"—"),e[4]=i.startedAt,e[5]=b):b=e[5];let w;e[6]!==b?(w=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[6]=b,e[7]=w):w=e[7];let S;e[8]!==i.skipped||e[9]!==l?(S=i.skipped>0&&s("span",{className:"text-xs text-muted-foreground",children:l("{count} ticks skipped",{count:i.skipped})}),e[8]=i.skipped,e[9]=l,e[10]=S):S=e[10];let N;return e[11]!==g||e[12]!==w||e[13]!==S?(N=R("span",{className:"flex items-center gap-2",children:[g,w,S]}),e[11]=g,e[12]=w,e[13]=S,e[14]=N):N=e[14],N}if(n===void 0){let h;e[15]!==l?(h=l("never"),e[15]=l,e[16]=h):h=e[16];let g;return e[17]!==h?(g=s("span",{className:"text-xs text-muted-foreground",children:h}),e[17]=h,e[18]=g):g=e[18],g}let a;e[19]!==l?(a=l("failed"),e[19]=l,e[20]=a):a=e[20];let r;e[21]!==l?(r=l("skipped"),e[21]=l,e[22]=r):r=e[22];let o;e[23]!==l?(o=l("succeeded"),e[23]=l,e[24]=o):o=e[24];let u;e[25]!==a||e[26]!==r||e[27]!==o?(u={failed:a,skipped:r,succeeded:o},e[25]=a,e[26]=r,e[27]=o,e[28]=u):u=e[28];const v=u,f=Ne[n.status],c=v[n.status];let m;e[29]!==f||e[30]!==c?(m=s(Y,{variant:f,children:c}),e[29]=f,e[30]=c,e[31]=m):m=e[31];let y;e[32]!==n.startedAt?(y=ie(n.startedAt,"—"),e[32]=n.startedAt,e[33]=y):y=e[33];let p;e[34]!==y?(p=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:y}),e[34]=y,e[35]=p):p=e[35];let d;return e[36]!==m||e[37]!==p?(d=R("span",{className:"flex items-center gap-2",children:[m,p]}),e[36]=m,e[37]=p,e[38]=d):d=e[38],d},Le=t=>{const e=V(80),{runs:i}=t,n=z();if(i.length===0)return;let l,a,r,o,u,v,f,c,m,y,p;if(e[0]!==i||e[1]!==n){const S=i.toSorted(Oe).slice(0,Ie);let N;e[13]!==n?(N=n("failed"),e[13]=n,e[14]=N):N=e[14];let T;e[15]!==n?(T=n("skipped"),e[15]=n,e[16]=T):T=e[16];let L;e[17]!==n?(L=n("succeeded"),e[17]=n,e[18]=L):L=e[18];let $;e[19]!==L||e[20]!==N||e[21]!==T?($={failed:N,skipped:T,succeeded:L},e[19]=L,e[20]=N,e[21]=T,e[22]=$):$=e[22];const A=$;m="flex flex-col gap-2",y="cron-run-history";let C;e[23]!==n?(C=n("Recent runs"),e[23]=n,e[24]=C):C=e[24],e[25]!==C?(p=s("h3",{className:"text-sm font-medium",children:C}),e[25]=C,e[26]=p):p=e[26],o=j,c="overflow-hidden py-0",r=X,f="px-0",a=ee;let k;e[27]!==n?(k=n("name"),e[27]=n,e[28]=k):k=e[28];let x;e[29]!==k?(x=s(O,{children:k}),e[29]=k,e[30]=x):x=e[30];let I;e[31]!==n?(I=n("status"),e[31]=n,e[32]=I):I=e[32];let D;e[33]!==I?(D=s(O,{children:I}),e[33]=I,e[34]=D):D=e[34];let E;e[35]!==n?(E=n("started"),e[35]=n,e[36]=E):E=e[36];let _;e[37]!==E?(_=s(O,{children:E}),e[37]=E,e[38]=_):_=e[38];let F;e[39]!==n?(F=n("duration"),e[39]=n,e[40]=F):F=e[40];let B;e[41]!==F?(B=s(O,{children:F}),e[41]=F,e[42]=B):B=e[42];let J;e[43]!==n?(J=n("skipped"),e[43]=n,e[44]=J):J=e[44];let U;e[45]!==J?(U=s(O,{children:J}),e[45]=J,e[46]=U):U=e[46];let P;e[47]!==n?(P=n("error"),e[47]=n,e[48]=P):P=e[48];let M;e[49]!==P?(M=s(O,{children:P}),e[49]=P,e[50]=M):M=e[50],e[51]!==x||e[52]!==D||e[53]!==_||e[54]!==B||e[55]!==U||e[56]!==M?(v=s(te,{children:R(Q,{children:[x,D,_,B,U,M]})}),e[51]=x,e[52]=D,e[53]=_,e[54]=B,e[55]=U,e[56]=M,e[57]=v):v=e[57],l=se;let W;e[58]!==A?(W=H=>R(Q,{"data-testid":`cron-run-row-${H.runId}`,children:[s(K,{children:H.name}),s(K,{children:s(Y,{variant:Ne[H.status],children:A[H.status]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(H.startedAt,"—")}),s(K,{className:"tabular-nums",children:H.status==="skipped"?"":Ee(H.durationMs)}),s(K,{className:"tabular-nums",children:H.skipped>0?H.skipped:""}),s(K,{className:"text-xs text-destructive",children:H.error??""})]},H.runId),e[58]=A,e[59]=W):W=e[59],u=S.map(W),e[0]=i,e[1]=n,e[2]=l,e[3]=a,e[4]=r,e[5]=o,e[6]=u,e[7]=v,e[8]=f,e[9]=c,e[10]=m,e[11]=y,e[12]=p}else l=e[2],a=e[3],r=e[4],o=e[5],u=e[6],v=e[7],f=e[8],c=e[9],m=e[10],y=e[11],p=e[12];let d;e[60]!==l||e[61]!==u?(d=s(l,{children:u}),e[60]=l,e[61]=u,e[62]=d):d=e[62];let h;e[63]!==a||e[64]!==v||e[65]!==d?(h=R(a,{children:[v,d]}),e[63]=a,e[64]=v,e[65]=d,e[66]=h):h=e[66];let g;e[67]!==r||e[68]!==f||e[69]!==h?(g=s(r,{className:f,children:h}),e[67]=r,e[68]=f,e[69]=h,e[70]=g):g=e[70];let b;e[71]!==o||e[72]!==g||e[73]!==c?(b=s(o,{className:c,children:g}),e[71]=o,e[72]=g,e[73]=c,e[74]=b):b=e[74];let w;return e[75]!==b||e[76]!==m||e[77]!==y||e[78]!==p?(w=R("div",{className:m,"data-testid":y,children:[p,b]}),e[75]=b,e[76]=m,e[77]=y,e[78]=p,e[79]=w):w=e[79],w};function Oe(t,e){return e.startedAt-t.startedAt}const Ke=()=>{const t=V(50),e=z(),i=Ce(""),[n,l]=G(""),[a,r]=G(void 0),[o,u]=G(!1);if(i.unavailable)return null;let v;t[0]!==i?(v=i.pending("cron"),t[0]=i,t[1]=v):v=t[1];const f=v;let c;t[2]!==i?(c=i.reason("cron"),t[2]=i,t[3]=c):c=t[3];const m=c;let y;t[4]!==n||t[5]!==i?(y=()=>{const E=n.trim();if(E==="")return;Z((async()=>{const F=await i.suggestCron(E);u(!1),r(F)})())},t[4]=n,t[5]=i,t[6]=y):y=t[6];const p=y;let d;t[7]!==a?(d=()=>{const E="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(E===void 0||a===void 0)return;Z((async()=>{try{await E.writeText(a),u(!0)}catch{u(!1)}})())},t[7]=a,t[8]=d):d=t[8];const h=d;let g;t[9]!==e?(g=e("Describe a schedule"),t[9]=e,t[10]=g):g=t[10];let b;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{l(E.target.value)},t[11]=b):b=t[11];let w;t[12]!==p?(w=E=>{E.key==="Enter"&&(E.preventDefault(),p())},t[12]=p,t[13]=w):w=t[13];let S;t[14]!==e?(S=e("Describe a schedule"),t[14]=e,t[15]=S):S=t[15];let N;t[16]!==f||t[17]!==n||t[18]!==g||t[19]!==w||t[20]!==S?(N=s(Se,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"cron-assistant-prompt",disabled:f,onChange:b,onKeyDown:w,placeholder:S,value:n}),t[16]=f,t[17]=n,t[18]=g,t[19]=w,t[20]=S,t[21]=N):N=t[21];const T=f&&"opacity-60";let L;t[22]!==T?(L=Te("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",T),t[22]=T,t[23]=L):L=t[23];let $;t[24]!==f||t[25]!==n?($=f||n.trim()==="",t[24]=f,t[25]=n,t[26]=$):$=t[26];let A;t[27]!==f||t[28]!==e?(A=e(f?"Thinking…":"Suggest schedule"),t[27]=f,t[28]=e,t[29]=A):A=t[29];let C;t[30]!==p||t[31]!==L||t[32]!==$||t[33]!==A?(C=s("button",{className:L,"data-testid":"cron-assistant-generate",disabled:$,onClick:p,type:"button",children:A}),t[30]=p,t[31]=L,t[32]=$,t[33]=A,t[34]=C):C=t[34];let k;t[35]!==C||t[36]!==N?(k=R("div",{className:"flex items-center gap-2",children:[N,C]}),t[35]=C,t[36]=N,t[37]=k):k=t[37];let x;t[38]!==o||t[39]!==h||t[40]!==a||t[41]!==e?(x=a!==void 0&&R("div",{className:"flex items-center gap-2",children:[s("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums","data-testid":"cron-assistant-result",children:a}),s("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cron-assistant-copy",onClick:h,type:"button",children:e(o?"Copied":"Copy")}),s("span",{className:"text-[11px] text-muted-foreground",children:e("Add it to lunora/crons.ts — triggers are compiled into the worker.")})]}),t[38]=o,t[39]=h,t[40]=a,t[41]=e,t[42]=x):x=t[42];let I;t[43]!==m||t[44]!==e?(I=m!==void 0&&s("p",{className:"text-[11px] text-muted-foreground","data-testid":"cron-assistant-reason",role:"status",children:e(m==="ai-error"?"The model could not be reached.":"The model did not return a schedule Cron Triggers accept.")}),t[43]=m,t[44]=e,t[45]=I):I=t[45];let D;return t[46]!==k||t[47]!==x||t[48]!==I?(D=R("div",{className:"flex flex-col gap-1.5","data-testid":"cron-assistant",children:[k,x,I]}),t[46]=k,t[47]=x,t[48]=I,t[49]=D):D=t[49],D},De={kind:"idle"},_e="SCHEDULER_NOT_CONFIGURED",ue={inFlight:[],runs:[]},Fe=(t,e,i)=>i!==void 0?i:e===void 0?n=>t.runCronJob(n):void 0,Je=({loadCronJobs:t,loadCronRuns:e,runCronJob:i}={})=>{const n=ae(),l=z(),[a,r]=G({}),o=ne(["lunora-cron-jobs",t?"custom":"default"],()=>(t??(()=>n.getCronJobs()))()),{data:u,error:v}=o,f=e??(t===void 0?()=>n.listCronRuns():void 0),c=ne(["lunora-cron-runs",e?"custom":"default"],async()=>f===void 0?ue:f().catch(d=>{if(ge(d)===_e)return ue;throw d})),m=c.data??ue;re(()=>c.poll(),f!==void 0);const y=Fe(n,t,i),p=async d=>{if(y!==void 0){r(h=>({...h,[d]:{kind:"running"}}));try{await y(d),r(h=>({...h,[d]:{kind:"ok"}})),o.refetch(),c.refetch()}catch(h){r(g=>({...g,[d]:{kind:"error",message:de(h)}}))}}};return R("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[s(Ke,{}),v!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:v}),c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-runs-error",role:"alert",children:c.error}),u?.length===0&&s(oe,{description:l("Triggers declared with the cronJobs() builder appear here."),icon:R("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:l("No cron triggers.")}),u!==void 0&&u.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"cron-table",children:[s(te,{children:R(Q,{children:[s(O,{children:l("name")}),s(O,{children:l("schedule")}),s(O,{children:l("target")}),s(O,{children:l("shard")}),s(O,{children:l("last run")}),y!==void 0&&s(O,{"aria-label":l("Actions")})]})}),s(se,{children:u.map(d=>{const h=a[d.name]??De;return R(Q,{"data-testid":`cron-row-${d.name}`,children:[s(K,{children:d.name}),s(K,{className:"font-mono text-xs tabular-nums",children:d.cron}),s(K,{children:R("span",{className:"flex items-center gap-2",children:[d.workflow===void 0?s(Y,{variant:"outline",children:l("function")}):s(Y,{variant:"secondary",children:l("workflow")}),s("span",{className:"font-mono text-xs",children:d.workflow??d.functionPath})]})}),s(K,{children:d.shardKey??""}),s(K,{"data-testid":`cron-last-run-${d.name}`,children:s(Re,{inFlight:m.inFlight.find(g=>g.name===d.name),last:m.runs.find(g=>g.name===d.name)})}),y!==void 0&&s(K,{className:"text-right",children:R("span",{className:"flex items-center justify-end gap-2",children:[h.kind==="ok"&&s("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${d.name}`,children:l("ran")}),h.kind==="error"&&s("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${d.name}`,role:"alert",children:h.message}),s(me,{confirmLabel:l("Run now?"),disabled:h.kind==="running",onConfirm:()=>{Z(p(d.name))},testId:`cron-run-${d.name}`,children:h.kind==="running"?l("Running…"):l("Run now")})]})})]},`${d.cron}:${d.name}`)})})]})})}),s(Le,{runs:m.runs})]})},Me=t=>Number.isFinite(t)?ie(t,"—"):"—",Pe=t=>{const e=V(34);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n,removeJob:l,retryJob:a}=i,r=ae(),o=z();let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-dead-jobs"],e[2]=u):u=e[2];let v;e[3]!==r||e[4]!==n?(v=async()=>(await(n??(()=>r.listDeadJobs()))()).toSorted(qe),e[3]=r,e[4]=n,e[5]=v):v=e[5];const f=ne(u,v),c=f.data,[m,y]=G(void 0),p=f.error??m,d=n===void 0;let h;e[6]!==r||e[7]!==d||e[8]!==a?(h=a??(d?x=>r.retryDeadJob(x):void 0),e[6]=r,e[7]=d,e[8]=a,e[9]=h):h=e[9];const g=h;let b;e[10]!==r||e[11]!==d||e[12]!==l?(b=l??(d?x=>r.removeDeadJob(x):void 0),e[10]=r,e[11]=d,e[12]=l,e[13]=b):b=e[13];const w=b;let S;e[14]!==f?(S=()=>f.poll(),e[14]=f,e[15]=S):S=e[15],re(S,!0);let N;e[16]!==f?(N=async x=>{y(void 0);try{await x,f.refetch()}catch(I){y(de(I))}},e[16]=f,e[17]=N):N=e[17];const T=N,L=g!==void 0||w!==void 0;let $;e[18]!==p?($=p!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:p}),e[18]=p,e[19]=$):$=e[19];let A;e[20]!==c?.length||e[21]!==o?(A=c?.length===0&&s(oe,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),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:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=c?.length,e[21]=o,e[22]=A):A=e[22];let C;e[23]!==T||e[24]!==L||e[25]!==c||e[26]!==w||e[27]!==g||e[28]!==o?(C=c!==void 0&&c.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"dlq-table",children:[s(te,{children:R(Q,{children:[s(O,{children:o("function")}),s(O,{children:o("attempts")}),s(O,{children:o("last tried")}),s(O,{children:o("pool")}),s(O,{children:o("shard")}),s(O,{children:o("id")}),L&&s(O,{"aria-label":o("Actions")})]})}),s(se,{children:c.map(x=>R(Q,{"data-testid":`dlq-row-${x.id}`,children:[s(K,{className:"font-mono text-xs",children:x.workflow??x.functionPath}),s(K,{className:"tabular-nums",children:x.attempts??0}),s(K,{className:"text-muted-foreground tabular-nums",children:Me(x.scheduledFor)}),s(K,{className:"font-mono text-xs",children:x.pool??""}),s(K,{children:x.shardKey??""}),s(K,{className:"font-mono text-xs",children:x.id}),L&&s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&s(le,{"data-testid":`dlq-retry-${x.id}`,onClick:()=>{Z(T(g(x.id)))},size:"sm",type:"button",variant:"outline",children:o("Retry")}),w!==void 0&&s(me,{confirmLabel:o("Drop job?"),onConfirm:()=>{Z(T(w(x.id)))},testId:`dlq-remove-${x.id}`,children:o("Drop")})]})})]},x.id))})]})})}),e[23]=T,e[24]=L,e[25]=c,e[26]=w,e[27]=g,e[28]=o,e[29]=C):C=e[29];let k;return e[30]!==C||e[31]!==$||e[32]!==A?(k=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,A,C]}),e[30]=C,e[31]=$,e[32]=A,e[33]=k):k=e[33],k};function qe(t,e){return(e.attempts??0)-(t.attempts??0)}const Ue={canceled:"secondary",failed:"destructive",pending:"outline",running:"info",succeeded:"success"},Be=t=>{const e=V(47);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n}=i,l=ae(),a=z();let r;e[2]!==l||e[3]!==n?(r=n??(async q=>l.listScheduledHistory(q===void 0?{}:{cursor:q})),e[2]=l,e[3]=n,e[4]=r):r=e[4];const o=r,u=n?"custom":"default";let v;e[5]!==u?(v=["lunora-job-history",u],e[5]=u,e[6]=v):v=e[6];let f;e[7]!==o?(f=async()=>o(),e[7]=o,e[8]=f):f=e[8];const c=ne(v,f),[m,y]=G(void 0),[p,d]=G(!1),[h,g]=G(void 0),b=c.data?.records;let w;e[9]!==b?(w=new Set(b?.map(He)),e[9]=b,e[10]=w):w=e[10];const S=w,N=b===void 0?void 0:[...b,...(m?.records??[]).filter(q=>!S.has(q.id))],T=m===void 0?c.data?.cursor:m.cursor;let L;e[11]!==o||e[12]!==T?(L=async()=>{d(!0),g(void 0);try{const q=await o(T);y(pe=>({cursor:q.cursor,records:[...pe?.records??[],...q.records]})),d(!1)}catch(q){g(de(q)),d(!1)}},e[11]=o,e[12]=T,e[13]=L):L=e[13];const $=L;let A;e[14]!==a?(A=a("canceled"),e[14]=a,e[15]=A):A=e[15];let C;e[16]!==a?(C=a("failed"),e[16]=a,e[17]=C):C=e[17];let k;e[18]!==a?(k=a("pending"),e[18]=a,e[19]=k):k=e[19];let x;e[20]!==a?(x=a("running"),e[20]=a,e[21]=x):x=e[21];let I;e[22]!==a?(I=a("succeeded"),e[22]=a,e[23]=I):I=e[23];let D;e[24]!==k||e[25]!==x||e[26]!==I||e[27]!==A||e[28]!==C?(D={canceled:A,failed:C,pending:k,running:x,succeeded:I},e[24]=k,e[25]=x,e[26]=I,e[27]=A,e[28]=C,e[29]=D):D=e[29];const E=D;let _;e[30]!==c?(_=()=>c.poll(),e[30]=c,e[31]=_):_=e[31],re(_,m===void 0);const F="flex flex-col gap-3",B="lunora-job-history";let J;e[32]!==c.error?(J=c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"job-history-error",role:"alert",children:c.error}),e[32]=c.error,e[33]=J):J=e[33];const U=N?.length===0&&s(oe,{description:a("Jobs that succeed, fail or are cancelled stay here for seven days."),testId:"job-history-empty",title:a("No finished jobs.")}),P=N!==void 0&&N.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"job-history-table",children:[s(te,{children:R(Q,{children:[s(O,{children:a("function")}),s(O,{children:a("state")}),s(O,{children:a("finished")}),s(O,{children:a("error")}),s(O,{children:a("id")})]})}),s(se,{children:N.map(q=>R(Q,{"data-testid":`job-history-row-${q.id}`,children:[s(K,{className:"font-mono text-xs",children:q.workflow??q.functionPath}),s(K,{children:s(Y,{"data-testid":`job-history-state-${q.id}`,variant:Ue[q.state],children:E[q.state]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(q.completedAt,"—")}),s(K,{className:"text-xs text-destructive",children:q.error??""}),s(K,{className:"font-mono text-xs",children:q.id})]},q.id))})]})})});let M;e[34]!==h?(M=h!==void 0&&s("p",{className:"text-sm text-destructive",role:"alert",children:h}),e[34]=h,e[35]=M):M=e[35];let W;e[36]!==p||e[37]!==T||e[38]!==$||e[39]!==a?(W=T!==void 0&&s("div",{children:s(le,{"data-testid":"job-history-load-more",disabled:p,onClick:()=>{Z($())},variant:"outline",children:a(p?"Loading…":"Load more")})}),e[36]=p,e[37]=T,e[38]=$,e[39]=a,e[40]=W):W=e[40];let H;return e[41]!==J||e[42]!==U||e[43]!==P||e[44]!==M||e[45]!==W?(H=R("div",{className:F,"data-testid":B,children:[J,U,P,M,W]}),e[41]=J,e[42]=U,e[43]=P,e[44]=M,e[45]=W,e[46]=H):H=e[46],H};function He(t){return t.id}const Qe=ve(ce.dropOutboxEntry),Ve=ve(ce.retryOutboxEntry),ze=()=>{const t=V(8),e=z();let i;t[0]!==e?(i=e("Jobs whose mutation committed but that the scheduler has not accepted yet wait here."),t[0]=e,t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=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 4h16v12H4zM4 16l4 4h8l4-4"})}),t[2]=n):n=t[2];let l;t[3]!==e?(l=e("Nothing is waiting for the scheduler."),t[3]=e,t[4]=l):l=t[4];let a;return t[5]!==i||t[6]!==l?(a=s(oe,{description:i,icon:n,testId:"outbox-empty",title:l}),t[5]=i,t[6]=l,t[7]=a):a=t[7],a},We=t=>{const e=V(58),{entry:i,onAct:n}=t,l=z(),a=`outbox-row-${i.id}`;let r;e[0]!==i.target||e[1]!==l?(r=i.target??l("unreadable"),e[0]=i.target,e[1]=l,e[2]=r):r=e[2];let o;e[3]!==r?(o=s(K,{className:"font-mono text-xs",children:r}),e[3]=r,e[4]=o):o=e[4];const u=i.parked?"destructive":"secondary";let v;e[5]!==i.parked||e[6]!==l?(v=i.parked?l("parked"):l("retrying"),e[5]=i.parked,e[6]=l,e[7]=v):v=e[7];let f;e[8]!==u||e[9]!==v?(f=s(Y,{variant:u,children:v}),e[8]=u,e[9]=v,e[10]=f):f=e[10];let c;e[11]!==i.forever||e[12]!==l?(c=i.forever&&s(Y,{variant:"outline",children:l("forever")}),e[11]=i.forever,e[12]=l,e[13]=c):c=e[13];let m;e[14]!==f||e[15]!==c?(m=s(K,{children:R("div",{className:"flex gap-1",children:[f,c]})}),e[14]=f,e[15]=c,e[16]=m):m=e[16];let y;e[17]!==i.attempts?(y=s(K,{className:"tabular-nums",children:i.attempts}),e[17]=i.attempts,e[18]=y):y=e[18];let p;e[19]!==i.nextAttemptAt||e[20]!==i.parked?(p=i.parked?"—":ie(i.nextAttemptAt,"—"),e[19]=i.nextAttemptAt,e[20]=i.parked,e[21]=p):p=e[21];let d;e[22]!==p?(d=s(K,{className:"text-muted-foreground tabular-nums",children:p}),e[22]=p,e[23]=d):d=e[23];let h;e[24]!==i.id?(h=s(K,{className:"font-mono text-xs",children:i.id}),e[24]=i.id,e[25]=h):h=e[25];const g=`outbox-retry-${i.id}`;let b;e[26]!==i.id||e[27]!==n?(b=()=>{Z(n(Ve,i.id))},e[26]=i.id,e[27]=n,e[28]=b):b=e[28];let w;e[29]!==l?(w=l("Retry now"),e[29]=l,e[30]=w):w=e[30];let S;e[31]!==g||e[32]!==b||e[33]!==w?(S=s(le,{"data-testid":g,onClick:b,size:"sm",type:"button",variant:"outline",children:w}),e[31]=g,e[32]=b,e[33]=w,e[34]=S):S=e[34];let N;e[35]!==l?(N=l("Drop job?"),e[35]=l,e[36]=N):N=e[36];let T;e[37]!==i.id||e[38]!==n?(T=()=>{Z(n(Qe,i.id))},e[37]=i.id,e[38]=n,e[39]=T):T=e[39];const L=`outbox-drop-${i.id}`;let $;e[40]!==l?($=l("Drop"),e[40]=l,e[41]=$):$=e[41];let A;e[42]!==N||e[43]!==T||e[44]!==L||e[45]!==$?(A=s(me,{confirmLabel:N,onConfirm:T,testId:L,children:$}),e[42]=N,e[43]=T,e[44]=L,e[45]=$,e[46]=A):A=e[46];let C;e[47]!==S||e[48]!==A?(C=s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[S,A]})}),e[47]=S,e[48]=A,e[49]=C):C=e[49];let k;return e[50]!==a||e[51]!==d||e[52]!==h||e[53]!==C||e[54]!==o||e[55]!==m||e[56]!==y?(k=R(Q,{"data-testid":a,children:[o,m,y,d,h,C]}),e[50]=a,e[51]=d,e[52]=h,e[53]=C,e[54]=o,e[55]=m,e[56]=y,e[57]=k):k=e[57],k},Ge=t=>{const e=V(41),{entries:i,onAct:n}=t,l=z();let a;e[0]!==l?(a=l("function"),e[0]=l,e[1]=a):a=e[1];let r;e[2]!==a?(r=s(O,{children:a}),e[2]=a,e[3]=r):r=e[3];let o;e[4]!==l?(o=l("state"),e[4]=l,e[5]=o):o=e[5];let u;e[6]!==o?(u=s(O,{children:o}),e[6]=o,e[7]=u):u=e[7];let v;e[8]!==l?(v=l("attempts"),e[8]=l,e[9]=v):v=e[9];let f;e[10]!==v?(f=s(O,{children:v}),e[10]=v,e[11]=f):f=e[11];let c;e[12]!==l?(c=l("next attempt"),e[12]=l,e[13]=c):c=e[13];let m;e[14]!==c?(m=s(O,{children:c}),e[14]=c,e[15]=m):m=e[15];let y;e[16]!==l?(y=l("id"),e[16]=l,e[17]=y):y=e[17];let p;e[18]!==y?(p=s(O,{children:y}),e[18]=y,e[19]=p):p=e[19];let d;e[20]!==l?(d=l("Actions"),e[20]=l,e[21]=d):d=e[21];let h;e[22]!==d?(h=s(O,{"aria-label":d}),e[22]=d,e[23]=h):h=e[23];let g;e[24]!==p||e[25]!==h||e[26]!==r||e[27]!==u||e[28]!==f||e[29]!==m?(g=s(te,{children:R(Q,{children:[r,u,f,m,p,h]})}),e[24]=p,e[25]=h,e[26]=r,e[27]=u,e[28]=f,e[29]=m,e[30]=g):g=e[30];let b;if(e[31]!==i||e[32]!==n){let N;e[34]!==n?(N=T=>s(We,{entry:T,onAct:n},T.id),e[34]=n,e[35]=N):N=e[35],b=i.map(N),e[31]=i,e[32]=n,e[33]=b}else b=e[33];let w;e[36]!==b?(w=s(se,{children:b}),e[36]=b,e[37]=w):w=e[37];let S;return e[38]!==g||e[39]!==w?(S=s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"outbox-table",children:[g,w]})})}),e[38]=g,e[39]=w,e[40]=S):S=e[40],S},Ye=t=>{const e=V(11),{cursor:i,nextCursor:n,onFirst:l,onNext:a}=t,r=z();if(i===void 0&&n===void 0)return;let o;e[0]!==i||e[1]!==l||e[2]!==r?(o=i!==void 0&&s(le,{"data-testid":"outbox-first-page",onClick:l,size:"sm",type:"button",variant:"outline",children:r("First page")}),e[0]=i,e[1]=l,e[2]=r,e[3]=o):o=e[3];let u;e[4]!==n||e[5]!==a||e[6]!==r?(u=n!==void 0&&s(le,{"data-testid":"outbox-next-page",onClick:()=>{a(n)},size:"sm",type:"button",variant:"outline",children:r("Next page")}),e[4]=n,e[5]=a,e[6]=r,e[7]=u):u=e[7];let v;return e[8]!==o||e[9]!==u?(v=R("div",{className:"flex justify-end gap-1.5",children:[o,u]}),e[8]=o,e[9]=u,e[10]=v):v=e[10],v},je=t=>{const e=V(38);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n}=i,l=Ae(),a=z(),{queryShardKey:r,setShardKey:o,shardKey:u}=ye(n);let v;e[2]!==r?(v={cursor:void 0,shardKey:r},e[2]=r,e[3]=v):v=e[3];const[f,c]=G(v);f.shardKey!==r&&c({cursor:void 0,shardKey:r});const m=f.shardKey===r?f.cursor:void 0,y=u.trim()!==r;let p;e[4]!==m?(p=m===void 0?{}:{cursor:m},e[4]=m,e[5]=p):p=e[5];let d;e[6]!==r?(d={shardKey:r},e[6]=r,e[7]=d):d=e[7];const{data:h,error:g,poll:b,refetch:w}=xe(ce.getScheduleOutbox,p,d),S=y?void 0:h?.entries,N=y?void 0:h?.nextCursor,[T,L]=G(void 0),$=g??(T?.shardKey===r?T.message:void 0);re(b,!0);let A;e[8]!==l||e[9]!==r||e[10]!==w||e[11]!==a?(A=async(J,U)=>{L(void 0);try{(await l.query(J,{id:U},ke(r))).retried===!1&&L({message:a("That job is no longer in the outbox."),shardKey:r}),w()}catch(P){L({message:de(P),shardKey:r})}},e[8]=l,e[9]=r,e[10]=w,e[11]=a,e[12]=A):A=e[12];const C=A;let k;e[13]!==o||e[14]!==u?(k=s(be,{onChange:o,testId:"outbox-shard-input",value:u}),e[13]=o,e[14]=u,e[15]=k):k=e[15];let x;e[16]!==$?(x=$!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"outbox-error",role:"alert",children:$}),e[16]=$,e[17]=x):x=e[17];let I;e[18]!==m||e[19]!==S?.length?(I=S?.length===0&&m===void 0&&s(ze,{}),e[18]=m,e[19]=S?.length,e[20]=I):I=e[20];let D;e[21]!==C||e[22]!==S?(D=S!==void 0&&S.length>0&&s(Ge,{entries:S,onAct:C}),e[21]=C,e[22]=S,e[23]=D):D=e[23];let E,_;e[24]!==r?(E=()=>{c({cursor:void 0,shardKey:r})},_=J=>{c({cursor:J,shardKey:r})},e[24]=r,e[25]=E,e[26]=_):(E=e[25],_=e[26]);let F;e[27]!==m||e[28]!==N||e[29]!==E||e[30]!==_?(F=s(Ye,{cursor:m,nextCursor:N,onFirst:E,onNext:_}),e[27]=m,e[28]=N,e[29]=E,e[30]=_,e[31]=F):F=e[31];let B;return e[32]!==F||e[33]!==k||e[34]!==x||e[35]!==I||e[36]!==D?(B=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-schedule-outbox",children:[k,x,I,D,F]}),e[32]=F,e[33]=k,e[34]=x,e[35]=I,e[36]=D,e[37]=B):B=e[37],B},Xe="scheduler.lag_ms",he=t=>{const e=t.attributes?.function;return typeof e=="string"?e:t.functionPath},fe=t=>{const e=V(8),{label:i,testId:n,value:l}=t;let a;e[0]!==i?(a=s("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=a):a=e[1];let r;e[2]!==n||e[3]!==l?(r=s("span",{className:"text-2xl font-semibold tabular-nums","data-testid":n,children:l}),e[2]=n,e[3]=l,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=s(j,{className:"flex-1 py-0",children:R(X,{className:"flex flex-col gap-1 p-4",children:[a,r]})}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o},Ze=t=>{const e=V(65);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadStatus:l}=i,a=ae(),r=z(),o=l===void 0;let u;e[2]!==o?(u=["lunora-scheduler-status",o],e[2]=o,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==l?(v=async()=>{const J=await(l??(()=>a.schedulerStatus()))();return{...J,pools:J.pools.toSorted(et)}},e[4]=a,e[5]=l,e[6]=v):v=e[6];const f=ne(u,v),{data:c,error:m}=f,{queryShardKey:y,setShardKey:p,shardKey:d}=ye(n);let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h={},e[7]=h):h=e[7];let g;e[8]!==y?(g={shardKey:y},e[8]=y,e[9]=g):g=e[9];const b=xe(ce.getMetricSeries,h,g),{data:w,errorSource:S}=b;let N;e[10]!==S||e[11]!==b.error?(N=ge(S)==="FUNCTION_NOT_FOUND"?null:b.error,e[10]=S,e[11]=b.error,e[12]=N):N=e[12];const T=N;let L;e[13]!==f?(L=()=>f.poll(),e[13]=f,e[14]=L):L=e[14],re(L,!0);let $;e[15]!==b?($=()=>b.poll(),e[15]=b,e[16]=$):$=e[16],re($,!0);let A,C,k,x,I,D,E,_;if(e[17]!==m||e[18]!==w||e[19]!==T||e[20]!==p||e[21]!==d||e[22]!==c||e[23]!==r){const J=(Array.isArray(w?.series)?w.series:[]).filter(tt).toSorted(st);A="flex flex-col gap-3",C="lunora-scheduler-pools",e[32]!==m?(k=m!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:m}),e[32]=m,e[33]=k):k=e[33],e[34]!==c||e[35]!==r?(x=c!==void 0&&R("div",{className:"flex gap-3","data-testid":"pools-totals",children:[s(fe,{label:r("backlog"),testId:"pools-backlog",value:c.backlog}),s(fe,{label:r("in flight"),testId:"pools-inflight",value:c.inFlight}),s(fe,{label:r("pools"),testId:"pools-count",value:c.pools.length})]}),e[34]=c,e[35]=r,e[36]=x):x=e[36],e[37]!==c?.pools.length||e[38]!==r?(I=c?.pools.length===0&&s(oe,{description:r("Pools created with createWorkpool appear here once they have activity."),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 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[37]=c?.pools.length,e[38]=r,e[39]=I):I=e[39];let U;e[40]!==p||e[41]!==d?(U=s(be,{onChange:p,testId:"lag-shard-input",value:d}),e[40]=p,e[41]=d,e[42]=U):U=e[42];let P;e[43]!==r?(P=r("Start lag per job on this shard since it last woke; the series reset when the shard hibernates."),e[43]=r,e[44]=P):P=e[44];let M;e[45]!==P?(M=s("p",{className:"text-xs text-muted-foreground","data-testid":"lag-scope",children:P}),e[45]=P,e[46]=M):M=e[46],e[47]!==U||e[48]!==M?(D=R("div",{className:"flex flex-wrap items-center gap-3",children:[U,M]}),e[47]=U,e[48]=M,e[49]=D):D=e[49],e[50]!==T?(E=T!==null&&s("p",{className:"text-sm text-destructive","data-testid":"lag-error",role:"alert",children:T}),e[50]=T,e[51]=E):E=e[51],_=T===null&&J.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"lag-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("function")}),s(O,{children:r("runs")}),s(O,{children:r("mean lag (ms)")}),s(O,{children:r("max lag (ms)")}),s(O,{children:r("last lag (ms)")})]})}),s(se,{children:J.map(lt)})]})})}),e[17]=m,e[18]=w,e[19]=T,e[20]=p,e[21]=d,e[22]=c,e[23]=r,e[24]=A,e[25]=C,e[26]=k,e[27]=x,e[28]=I,e[29]=D,e[30]=E,e[31]=_}else A=e[24],C=e[25],k=e[26],x=e[27],I=e[28],D=e[29],E=e[30],_=e[31];let F;e[52]!==c||e[53]!==r?(F=c!==void 0&&c.pools.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"pools-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("pool")}),s(O,{children:r("queued")}),s(O,{children:r("in flight")}),s(O,{children:r("max concurrency")})]})}),s(se,{children:c.pools.map(rt)})]})})}),e[52]=c,e[53]=r,e[54]=F):F=e[54];let B;return e[55]!==A||e[56]!==C||e[57]!==k||e[58]!==x||e[59]!==I||e[60]!==D||e[61]!==E||e[62]!==_||e[63]!==F?(B=R("div",{className:A,"data-testid":C,children:[k,x,I,D,E,_,F]}),e[55]=A,e[56]=C,e[57]=k,e[58]=x,e[59]=I,e[60]=D,e[61]=E,e[62]=_,e[63]=F,e[64]=B):B=e[64],B};function et(t,e){return e.queued-t.queued}function tt(t){return t.name===Xe&&t.kind==="histogram"&&t.count>0}function st(t,e){return e.max-t.max}function lt(t){return R(Q,{"data-testid":`lag-row-${he(t)}`,children:[s(K,{className:"font-mono text-xs",children:he(t)}),s(K,{className:"tabular-nums",children:t.count}),s(K,{className:"tabular-nums",children:Math.round(t.sum/t.count)}),s(K,{className:"tabular-nums",children:t.max}),s(K,{className:"tabular-nums",children:t.last})]},he(t))}function rt(t){return R(Q,{"data-testid":`pools-row-${t.name}`,children:[s(K,{className:"font-mono text-xs",children:t.name}),s(K,{className:"tabular-nums",children:t.queued}),R(K,{className:"tabular-nums",children:[t.inFlight," / ",t.maxConcurrency]}),s(K,{className:"tabular-nums",children:t.maxConcurrency})]},t.name)}const it=["jobs","outbox","history","dead","pools","cron"],It=t=>{const e=V(55);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadCronJobs:l,scheduledCancel:a,scheduledLoad:r}=i,o=z(),[u,v]=G("jobs");let f;e[2]!==o?(f=o("Cron triggers"),e[2]=o,e[3]=f):f=e[3];let c;e[4]!==o?(c=o("Dead letter"),e[4]=o,e[5]=c):c=e[5];let m;e[6]!==o?(m=o("History"),e[6]=o,e[7]=m):m=e[7];let y;e[8]!==o?(y=o("Scheduled jobs"),e[8]=o,e[9]=y):y=e[9];let p;e[10]!==o?(p=o("Outbox"),e[10]=o,e[11]=p):p=e[11];let d;e[12]!==o?(d=o("Pools"),e[12]=o,e[13]=d):d=e[13];let h;e[14]!==f||e[15]!==c||e[16]!==m||e[17]!==y||e[18]!==p||e[19]!==d?(h={cron:f,dead:c,history:m,jobs:y,outbox:p,pools:d},e[14]=f,e[15]=c,e[16]=m,e[17]=y,e[18]=p,e[19]=d,e[20]=h):h=e[20];const g=h;let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{v(E.currentTarget.dataset.view)},e[21]=b):b=e[21];const w=b;let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=s(we,{}),e[22]=S):S=e[22];let N;e[23]!==o?(N=o("Schedule view"),e[23]=o,e[24]=N):N=e[24];let T;e[25]!==u||e[26]!==g?(T=it.map(E=>s(le,{"aria-selected":u===E,"data-testid":`schedule-view-${E}`,"data-view":E,onClick:w,role:"tab",size:"sm",type:"button",variant:u===E?"default":"outline",children:g[E]},E)),e[25]=u,e[26]=g,e[27]=T):T=e[27];let L;e[28]!==N||e[29]!==T?(L=s("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:T}),e[28]=N,e[29]=T,e[30]=L):L=e[30];let $;e[31]!==a||e[32]!==r||e[33]!==u?($=u==="jobs"&&s($e,{cancelJob:a,loadJobs:r}),e[31]=a,e[32]=r,e[33]=u,e[34]=$):$=e[34];let A;e[35]!==u?(A=u==="outbox"&&s(je,{}),e[35]=u,e[36]=A):A=e[36];let C;e[37]!==u?(C=u==="history"&&s(Be,{}),e[37]=u,e[38]=C):C=e[38];let k;e[39]!==u?(k=u==="dead"&&s(Pe,{}),e[39]=u,e[40]=k):k=e[40];let x;e[41]!==n||e[42]!==u?(x=u==="pools"&&s(Ze,{initialShardKey:n}),e[41]=n,e[42]=u,e[43]=x):x=e[43];let I;e[44]!==l||e[45]!==u?(I=u==="cron"&&s(Je,{loadCronJobs:l}),e[44]=l,e[45]=u,e[46]=I):I=e[46];let D;return e[47]!==L||e[48]!==$||e[49]!==A||e[50]!==C||e[51]!==k||e[52]!==x||e[53]!==I?(D=R("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,L,$,A,C,k,x,I]}),e[47]=L,e[48]=$,e[49]=A,e[50]=C,e[51]=k,e[52]=x,e[53]=I,e[54]=D):D=e[54],D};export{It as SchedulePanel};
|
|
1
|
+
import{c as V}from"react/compiler-runtime";import{useState as G}from"react";import{D as we}from"../packem_shared/studio-DZlpp4Vx.mjs";import{B as le}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as j,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as ee,c as O,a as te,b as Q,d as se,e as K}from"../packem_shared/table-D0SBiDu-.mjs";import{a as ne,u as xe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as re}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as ie,f as Z,j as ge,b as de,c as ve,d as ke}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as R}from"react/jsx-runtime";import{I as Se}from"../packem_shared/input-CXhxesPC.mjs";import{u as Ce}from"../packem_shared/use-assistant-rpc-AKu8hvPm.mjs";import{c as Te}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as Ae}from"@lunora/react";import{ShardInput as be}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{u as ye}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as ce}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{ScheduledJobs as $e}from"../packem_shared/ScheduledJobs-Du8ZGL7v.mjs";const Ne={failed:"destructive",skipped:"warning",succeeded:"success"},Ie=25,Ee=t=>t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(1)} s`,Re=t=>{const e=V(39),{inFlight:i,last:n}=t,l=z();if(i!==void 0){let h;e[0]!==l?(h=l("running"),e[0]=l,e[1]=h):h=e[1];let g;e[2]!==h?(g=s(Y,{variant:"info",children:h}),e[2]=h,e[3]=g):g=e[3];let b;e[4]!==i.startedAt?(b=ie(i.startedAt,"—"),e[4]=i.startedAt,e[5]=b):b=e[5];let w;e[6]!==b?(w=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[6]=b,e[7]=w):w=e[7];let S;e[8]!==i.skipped||e[9]!==l?(S=i.skipped>0&&s("span",{className:"text-xs text-muted-foreground",children:l("{count} ticks skipped",{count:i.skipped})}),e[8]=i.skipped,e[9]=l,e[10]=S):S=e[10];let N;return e[11]!==g||e[12]!==w||e[13]!==S?(N=R("span",{className:"flex items-center gap-2",children:[g,w,S]}),e[11]=g,e[12]=w,e[13]=S,e[14]=N):N=e[14],N}if(n===void 0){let h;e[15]!==l?(h=l("never"),e[15]=l,e[16]=h):h=e[16];let g;return e[17]!==h?(g=s("span",{className:"text-xs text-muted-foreground",children:h}),e[17]=h,e[18]=g):g=e[18],g}let a;e[19]!==l?(a=l("failed"),e[19]=l,e[20]=a):a=e[20];let r;e[21]!==l?(r=l("skipped"),e[21]=l,e[22]=r):r=e[22];let o;e[23]!==l?(o=l("succeeded"),e[23]=l,e[24]=o):o=e[24];let u;e[25]!==a||e[26]!==r||e[27]!==o?(u={failed:a,skipped:r,succeeded:o},e[25]=a,e[26]=r,e[27]=o,e[28]=u):u=e[28];const v=u,f=Ne[n.status],c=v[n.status];let m;e[29]!==f||e[30]!==c?(m=s(Y,{variant:f,children:c}),e[29]=f,e[30]=c,e[31]=m):m=e[31];let y;e[32]!==n.startedAt?(y=ie(n.startedAt,"—"),e[32]=n.startedAt,e[33]=y):y=e[33];let p;e[34]!==y?(p=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:y}),e[34]=y,e[35]=p):p=e[35];let d;return e[36]!==m||e[37]!==p?(d=R("span",{className:"flex items-center gap-2",children:[m,p]}),e[36]=m,e[37]=p,e[38]=d):d=e[38],d},Le=t=>{const e=V(80),{runs:i}=t,n=z();if(i.length===0)return;let l,a,r,o,u,v,f,c,m,y,p;if(e[0]!==i||e[1]!==n){const S=i.toSorted(Oe).slice(0,Ie);let N;e[13]!==n?(N=n("failed"),e[13]=n,e[14]=N):N=e[14];let T;e[15]!==n?(T=n("skipped"),e[15]=n,e[16]=T):T=e[16];let L;e[17]!==n?(L=n("succeeded"),e[17]=n,e[18]=L):L=e[18];let $;e[19]!==L||e[20]!==N||e[21]!==T?($={failed:N,skipped:T,succeeded:L},e[19]=L,e[20]=N,e[21]=T,e[22]=$):$=e[22];const A=$;m="flex flex-col gap-2",y="cron-run-history";let C;e[23]!==n?(C=n("Recent runs"),e[23]=n,e[24]=C):C=e[24],e[25]!==C?(p=s("h3",{className:"text-sm font-medium",children:C}),e[25]=C,e[26]=p):p=e[26],o=j,c="overflow-hidden py-0",r=X,f="px-0",a=ee;let k;e[27]!==n?(k=n("name"),e[27]=n,e[28]=k):k=e[28];let x;e[29]!==k?(x=s(O,{children:k}),e[29]=k,e[30]=x):x=e[30];let I;e[31]!==n?(I=n("status"),e[31]=n,e[32]=I):I=e[32];let D;e[33]!==I?(D=s(O,{children:I}),e[33]=I,e[34]=D):D=e[34];let E;e[35]!==n?(E=n("started"),e[35]=n,e[36]=E):E=e[36];let _;e[37]!==E?(_=s(O,{children:E}),e[37]=E,e[38]=_):_=e[38];let F;e[39]!==n?(F=n("duration"),e[39]=n,e[40]=F):F=e[40];let B;e[41]!==F?(B=s(O,{children:F}),e[41]=F,e[42]=B):B=e[42];let J;e[43]!==n?(J=n("skipped"),e[43]=n,e[44]=J):J=e[44];let U;e[45]!==J?(U=s(O,{children:J}),e[45]=J,e[46]=U):U=e[46];let P;e[47]!==n?(P=n("error"),e[47]=n,e[48]=P):P=e[48];let M;e[49]!==P?(M=s(O,{children:P}),e[49]=P,e[50]=M):M=e[50],e[51]!==x||e[52]!==D||e[53]!==_||e[54]!==B||e[55]!==U||e[56]!==M?(v=s(te,{children:R(Q,{children:[x,D,_,B,U,M]})}),e[51]=x,e[52]=D,e[53]=_,e[54]=B,e[55]=U,e[56]=M,e[57]=v):v=e[57],l=se;let W;e[58]!==A?(W=H=>R(Q,{"data-testid":`cron-run-row-${H.runId}`,children:[s(K,{children:H.name}),s(K,{children:s(Y,{variant:Ne[H.status],children:A[H.status]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(H.startedAt,"—")}),s(K,{className:"tabular-nums",children:H.status==="skipped"?"":Ee(H.durationMs)}),s(K,{className:"tabular-nums",children:H.skipped>0?H.skipped:""}),s(K,{className:"text-xs text-destructive",children:H.error??""})]},H.runId),e[58]=A,e[59]=W):W=e[59],u=S.map(W),e[0]=i,e[1]=n,e[2]=l,e[3]=a,e[4]=r,e[5]=o,e[6]=u,e[7]=v,e[8]=f,e[9]=c,e[10]=m,e[11]=y,e[12]=p}else l=e[2],a=e[3],r=e[4],o=e[5],u=e[6],v=e[7],f=e[8],c=e[9],m=e[10],y=e[11],p=e[12];let d;e[60]!==l||e[61]!==u?(d=s(l,{children:u}),e[60]=l,e[61]=u,e[62]=d):d=e[62];let h;e[63]!==a||e[64]!==v||e[65]!==d?(h=R(a,{children:[v,d]}),e[63]=a,e[64]=v,e[65]=d,e[66]=h):h=e[66];let g;e[67]!==r||e[68]!==f||e[69]!==h?(g=s(r,{className:f,children:h}),e[67]=r,e[68]=f,e[69]=h,e[70]=g):g=e[70];let b;e[71]!==o||e[72]!==g||e[73]!==c?(b=s(o,{className:c,children:g}),e[71]=o,e[72]=g,e[73]=c,e[74]=b):b=e[74];let w;return e[75]!==b||e[76]!==m||e[77]!==y||e[78]!==p?(w=R("div",{className:m,"data-testid":y,children:[p,b]}),e[75]=b,e[76]=m,e[77]=y,e[78]=p,e[79]=w):w=e[79],w};function Oe(t,e){return e.startedAt-t.startedAt}const Ke=()=>{const t=V(50),e=z(),i=Ce(""),[n,l]=G(""),[a,r]=G(void 0),[o,u]=G(!1);if(i.unavailable)return null;let v;t[0]!==i?(v=i.pending("cron"),t[0]=i,t[1]=v):v=t[1];const f=v;let c;t[2]!==i?(c=i.reason("cron"),t[2]=i,t[3]=c):c=t[3];const m=c;let y;t[4]!==n||t[5]!==i?(y=()=>{const E=n.trim();if(E==="")return;Z((async()=>{const F=await i.suggestCron(E);u(!1),r(F)})())},t[4]=n,t[5]=i,t[6]=y):y=t[6];const p=y;let d;t[7]!==a?(d=()=>{const E="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(E===void 0||a===void 0)return;Z((async()=>{try{await E.writeText(a),u(!0)}catch{u(!1)}})())},t[7]=a,t[8]=d):d=t[8];const h=d;let g;t[9]!==e?(g=e("Describe a schedule"),t[9]=e,t[10]=g):g=t[10];let b;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{l(E.target.value)},t[11]=b):b=t[11];let w;t[12]!==p?(w=E=>{E.key==="Enter"&&(E.preventDefault(),p())},t[12]=p,t[13]=w):w=t[13];let S;t[14]!==e?(S=e("Describe a schedule"),t[14]=e,t[15]=S):S=t[15];let N;t[16]!==f||t[17]!==n||t[18]!==g||t[19]!==w||t[20]!==S?(N=s(Se,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"cron-assistant-prompt",disabled:f,onChange:b,onKeyDown:w,placeholder:S,value:n}),t[16]=f,t[17]=n,t[18]=g,t[19]=w,t[20]=S,t[21]=N):N=t[21];const T=f&&"opacity-60";let L;t[22]!==T?(L=Te("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",T),t[22]=T,t[23]=L):L=t[23];let $;t[24]!==f||t[25]!==n?($=f||n.trim()==="",t[24]=f,t[25]=n,t[26]=$):$=t[26];let A;t[27]!==f||t[28]!==e?(A=e(f?"Thinking…":"Suggest schedule"),t[27]=f,t[28]=e,t[29]=A):A=t[29];let C;t[30]!==p||t[31]!==L||t[32]!==$||t[33]!==A?(C=s("button",{className:L,"data-testid":"cron-assistant-generate",disabled:$,onClick:p,type:"button",children:A}),t[30]=p,t[31]=L,t[32]=$,t[33]=A,t[34]=C):C=t[34];let k;t[35]!==C||t[36]!==N?(k=R("div",{className:"flex items-center gap-2",children:[N,C]}),t[35]=C,t[36]=N,t[37]=k):k=t[37];let x;t[38]!==o||t[39]!==h||t[40]!==a||t[41]!==e?(x=a!==void 0&&R("div",{className:"flex items-center gap-2",children:[s("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums","data-testid":"cron-assistant-result",children:a}),s("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cron-assistant-copy",onClick:h,type:"button",children:e(o?"Copied":"Copy")}),s("span",{className:"text-[11px] text-muted-foreground",children:e("Add it to lunora/crons.ts — triggers are compiled into the worker.")})]}),t[38]=o,t[39]=h,t[40]=a,t[41]=e,t[42]=x):x=t[42];let I;t[43]!==m||t[44]!==e?(I=m!==void 0&&s("p",{className:"text-[11px] text-muted-foreground","data-testid":"cron-assistant-reason",role:"status",children:e(m==="ai-error"?"The model could not be reached.":"The model did not return a schedule Cron Triggers accept.")}),t[43]=m,t[44]=e,t[45]=I):I=t[45];let D;return t[46]!==k||t[47]!==x||t[48]!==I?(D=R("div",{className:"flex flex-col gap-1.5","data-testid":"cron-assistant",children:[k,x,I]}),t[46]=k,t[47]=x,t[48]=I,t[49]=D):D=t[49],D},De={kind:"idle"},_e="SCHEDULER_NOT_CONFIGURED",ue={inFlight:[],runs:[]},Fe=(t,e,i)=>i!==void 0?i:e===void 0?n=>t.runCronJob(n):void 0,Je=({loadCronJobs:t,loadCronRuns:e,runCronJob:i}={})=>{const n=ae(),l=z(),[a,r]=G({}),o=ne(["lunora-cron-jobs",t?"custom":"default"],()=>(t??(()=>n.getCronJobs()))()),{data:u,error:v}=o,f=e??(t===void 0?()=>n.listCronRuns():void 0),c=ne(["lunora-cron-runs",e?"custom":"default"],async()=>f===void 0?ue:f().catch(d=>{if(ge(d)===_e)return ue;throw d})),m=c.data??ue;re(()=>c.poll(),f!==void 0);const y=Fe(n,t,i),p=async d=>{if(y!==void 0){r(h=>({...h,[d]:{kind:"running"}}));try{await y(d),r(h=>({...h,[d]:{kind:"ok"}})),o.refetch(),c.refetch()}catch(h){r(g=>({...g,[d]:{kind:"error",message:de(h)}}))}}};return R("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[s(Ke,{}),v!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:v}),c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-runs-error",role:"alert",children:c.error}),u?.length===0&&s(oe,{description:l("Triggers declared with the cronJobs() builder appear here."),icon:R("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:l("No cron triggers.")}),u!==void 0&&u.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"cron-table",children:[s(te,{children:R(Q,{children:[s(O,{children:l("name")}),s(O,{children:l("schedule")}),s(O,{children:l("target")}),s(O,{children:l("shard")}),s(O,{children:l("last run")}),y!==void 0&&s(O,{"aria-label":l("Actions")})]})}),s(se,{children:u.map(d=>{const h=a[d.name]??De;return R(Q,{"data-testid":`cron-row-${d.name}`,children:[s(K,{children:d.name}),s(K,{className:"font-mono text-xs tabular-nums",children:d.cron}),s(K,{children:R("span",{className:"flex items-center gap-2",children:[d.workflow===void 0?s(Y,{variant:"outline",children:l("function")}):s(Y,{variant:"secondary",children:l("workflow")}),s("span",{className:"font-mono text-xs",children:d.workflow??d.functionPath})]})}),s(K,{children:d.shardKey??""}),s(K,{"data-testid":`cron-last-run-${d.name}`,children:s(Re,{inFlight:m.inFlight.find(g=>g.name===d.name),last:m.runs.find(g=>g.name===d.name)})}),y!==void 0&&s(K,{className:"text-right",children:R("span",{className:"flex items-center justify-end gap-2",children:[h.kind==="ok"&&s("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${d.name}`,children:l("ran")}),h.kind==="error"&&s("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${d.name}`,role:"alert",children:h.message}),s(me,{confirmLabel:l("Run now?"),disabled:h.kind==="running",onConfirm:()=>{Z(p(d.name))},testId:`cron-run-${d.name}`,children:h.kind==="running"?l("Running…"):l("Run now")})]})})]},`${d.cron}:${d.name}`)})})]})})}),s(Le,{runs:m.runs})]})},Me=t=>Number.isFinite(t)?ie(t,"—"):"—",Pe=t=>{const e=V(34);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n,removeJob:l,retryJob:a}=i,r=ae(),o=z();let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-dead-jobs"],e[2]=u):u=e[2];let v;e[3]!==r||e[4]!==n?(v=async()=>(await(n??(()=>r.listDeadJobs()))()).toSorted(qe),e[3]=r,e[4]=n,e[5]=v):v=e[5];const f=ne(u,v),c=f.data,[m,y]=G(void 0),p=f.error??m,d=n===void 0;let h;e[6]!==r||e[7]!==d||e[8]!==a?(h=a??(d?x=>r.retryDeadJob(x):void 0),e[6]=r,e[7]=d,e[8]=a,e[9]=h):h=e[9];const g=h;let b;e[10]!==r||e[11]!==d||e[12]!==l?(b=l??(d?x=>r.removeDeadJob(x):void 0),e[10]=r,e[11]=d,e[12]=l,e[13]=b):b=e[13];const w=b;let S;e[14]!==f?(S=()=>f.poll(),e[14]=f,e[15]=S):S=e[15],re(S,!0);let N;e[16]!==f?(N=async x=>{y(void 0);try{await x,f.refetch()}catch(I){y(de(I))}},e[16]=f,e[17]=N):N=e[17];const T=N,L=g!==void 0||w!==void 0;let $;e[18]!==p?($=p!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:p}),e[18]=p,e[19]=$):$=e[19];let A;e[20]!==c?.length||e[21]!==o?(A=c?.length===0&&s(oe,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),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:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=c?.length,e[21]=o,e[22]=A):A=e[22];let C;e[23]!==T||e[24]!==L||e[25]!==c||e[26]!==w||e[27]!==g||e[28]!==o?(C=c!==void 0&&c.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"dlq-table",children:[s(te,{children:R(Q,{children:[s(O,{children:o("function")}),s(O,{children:o("attempts")}),s(O,{children:o("last tried")}),s(O,{children:o("pool")}),s(O,{children:o("shard")}),s(O,{children:o("id")}),L&&s(O,{"aria-label":o("Actions")})]})}),s(se,{children:c.map(x=>R(Q,{"data-testid":`dlq-row-${x.id}`,children:[s(K,{className:"font-mono text-xs",children:x.workflow??x.functionPath}),s(K,{className:"tabular-nums",children:x.attempts??0}),s(K,{className:"text-muted-foreground tabular-nums",children:Me(x.scheduledFor)}),s(K,{className:"font-mono text-xs",children:x.pool??""}),s(K,{children:x.shardKey??""}),s(K,{className:"font-mono text-xs",children:x.id}),L&&s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&s(le,{"data-testid":`dlq-retry-${x.id}`,onClick:()=>{Z(T(g(x.id)))},size:"sm",type:"button",variant:"outline",children:o("Retry")}),w!==void 0&&s(me,{confirmLabel:o("Drop job?"),onConfirm:()=>{Z(T(w(x.id)))},testId:`dlq-remove-${x.id}`,children:o("Drop")})]})})]},x.id))})]})})}),e[23]=T,e[24]=L,e[25]=c,e[26]=w,e[27]=g,e[28]=o,e[29]=C):C=e[29];let k;return e[30]!==C||e[31]!==$||e[32]!==A?(k=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,A,C]}),e[30]=C,e[31]=$,e[32]=A,e[33]=k):k=e[33],k};function qe(t,e){return(e.attempts??0)-(t.attempts??0)}const Ue={canceled:"secondary",failed:"destructive",pending:"outline",running:"info",succeeded:"success"},Be=t=>{const e=V(47);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n}=i,l=ae(),a=z();let r;e[2]!==l||e[3]!==n?(r=n??(async q=>l.listScheduledHistory(q===void 0?{}:{cursor:q})),e[2]=l,e[3]=n,e[4]=r):r=e[4];const o=r,u=n?"custom":"default";let v;e[5]!==u?(v=["lunora-job-history",u],e[5]=u,e[6]=v):v=e[6];let f;e[7]!==o?(f=async()=>o(),e[7]=o,e[8]=f):f=e[8];const c=ne(v,f),[m,y]=G(void 0),[p,d]=G(!1),[h,g]=G(void 0),b=c.data?.records;let w;e[9]!==b?(w=new Set(b?.map(He)),e[9]=b,e[10]=w):w=e[10];const S=w,N=b===void 0?void 0:[...b,...(m?.records??[]).filter(q=>!S.has(q.id))],T=m===void 0?c.data?.cursor:m.cursor;let L;e[11]!==o||e[12]!==T?(L=async()=>{d(!0),g(void 0);try{const q=await o(T);y(pe=>({cursor:q.cursor,records:[...pe?.records??[],...q.records]})),d(!1)}catch(q){g(de(q)),d(!1)}},e[11]=o,e[12]=T,e[13]=L):L=e[13];const $=L;let A;e[14]!==a?(A=a("canceled"),e[14]=a,e[15]=A):A=e[15];let C;e[16]!==a?(C=a("failed"),e[16]=a,e[17]=C):C=e[17];let k;e[18]!==a?(k=a("pending"),e[18]=a,e[19]=k):k=e[19];let x;e[20]!==a?(x=a("running"),e[20]=a,e[21]=x):x=e[21];let I;e[22]!==a?(I=a("succeeded"),e[22]=a,e[23]=I):I=e[23];let D;e[24]!==k||e[25]!==x||e[26]!==I||e[27]!==A||e[28]!==C?(D={canceled:A,failed:C,pending:k,running:x,succeeded:I},e[24]=k,e[25]=x,e[26]=I,e[27]=A,e[28]=C,e[29]=D):D=e[29];const E=D;let _;e[30]!==c?(_=()=>c.poll(),e[30]=c,e[31]=_):_=e[31],re(_,m===void 0);const F="flex flex-col gap-3",B="lunora-job-history";let J;e[32]!==c.error?(J=c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"job-history-error",role:"alert",children:c.error}),e[32]=c.error,e[33]=J):J=e[33];const U=N?.length===0&&s(oe,{description:a("Jobs that succeed, fail or are cancelled stay here for seven days."),testId:"job-history-empty",title:a("No finished jobs.")}),P=N!==void 0&&N.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"job-history-table",children:[s(te,{children:R(Q,{children:[s(O,{children:a("function")}),s(O,{children:a("state")}),s(O,{children:a("finished")}),s(O,{children:a("error")}),s(O,{children:a("id")})]})}),s(se,{children:N.map(q=>R(Q,{"data-testid":`job-history-row-${q.id}`,children:[s(K,{className:"font-mono text-xs",children:q.workflow??q.functionPath}),s(K,{children:s(Y,{"data-testid":`job-history-state-${q.id}`,variant:Ue[q.state],children:E[q.state]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(q.completedAt,"—")}),s(K,{className:"text-xs text-destructive",children:q.error??""}),s(K,{className:"font-mono text-xs",children:q.id})]},q.id))})]})})});let M;e[34]!==h?(M=h!==void 0&&s("p",{className:"text-sm text-destructive",role:"alert",children:h}),e[34]=h,e[35]=M):M=e[35];let W;e[36]!==p||e[37]!==T||e[38]!==$||e[39]!==a?(W=T!==void 0&&s("div",{children:s(le,{"data-testid":"job-history-load-more",disabled:p,onClick:()=>{Z($())},variant:"outline",children:a(p?"Loading…":"Load more")})}),e[36]=p,e[37]=T,e[38]=$,e[39]=a,e[40]=W):W=e[40];let H;return e[41]!==J||e[42]!==U||e[43]!==P||e[44]!==M||e[45]!==W?(H=R("div",{className:F,"data-testid":B,children:[J,U,P,M,W]}),e[41]=J,e[42]=U,e[43]=P,e[44]=M,e[45]=W,e[46]=H):H=e[46],H};function He(t){return t.id}const Qe=ve(ce.dropOutboxEntry),Ve=ve(ce.retryOutboxEntry),ze=()=>{const t=V(8),e=z();let i;t[0]!==e?(i=e("Jobs whose mutation committed but that the scheduler has not accepted yet wait here."),t[0]=e,t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=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 4h16v12H4zM4 16l4 4h8l4-4"})}),t[2]=n):n=t[2];let l;t[3]!==e?(l=e("Nothing is waiting for the scheduler."),t[3]=e,t[4]=l):l=t[4];let a;return t[5]!==i||t[6]!==l?(a=s(oe,{description:i,icon:n,testId:"outbox-empty",title:l}),t[5]=i,t[6]=l,t[7]=a):a=t[7],a},We=t=>{const e=V(58),{entry:i,onAct:n}=t,l=z(),a=`outbox-row-${i.id}`;let r;e[0]!==i.target||e[1]!==l?(r=i.target??l("unreadable"),e[0]=i.target,e[1]=l,e[2]=r):r=e[2];let o;e[3]!==r?(o=s(K,{className:"font-mono text-xs",children:r}),e[3]=r,e[4]=o):o=e[4];const u=i.parked?"destructive":"secondary";let v;e[5]!==i.parked||e[6]!==l?(v=i.parked?l("parked"):l("retrying"),e[5]=i.parked,e[6]=l,e[7]=v):v=e[7];let f;e[8]!==u||e[9]!==v?(f=s(Y,{variant:u,children:v}),e[8]=u,e[9]=v,e[10]=f):f=e[10];let c;e[11]!==i.forever||e[12]!==l?(c=i.forever&&s(Y,{variant:"outline",children:l("forever")}),e[11]=i.forever,e[12]=l,e[13]=c):c=e[13];let m;e[14]!==f||e[15]!==c?(m=s(K,{children:R("div",{className:"flex gap-1",children:[f,c]})}),e[14]=f,e[15]=c,e[16]=m):m=e[16];let y;e[17]!==i.attempts?(y=s(K,{className:"tabular-nums",children:i.attempts}),e[17]=i.attempts,e[18]=y):y=e[18];let p;e[19]!==i.nextAttemptAt||e[20]!==i.parked?(p=i.parked?"—":ie(i.nextAttemptAt,"—"),e[19]=i.nextAttemptAt,e[20]=i.parked,e[21]=p):p=e[21];let d;e[22]!==p?(d=s(K,{className:"text-muted-foreground tabular-nums",children:p}),e[22]=p,e[23]=d):d=e[23];let h;e[24]!==i.id?(h=s(K,{className:"font-mono text-xs",children:i.id}),e[24]=i.id,e[25]=h):h=e[25];const g=`outbox-retry-${i.id}`;let b;e[26]!==i.id||e[27]!==n?(b=()=>{Z(n(Ve,i.id))},e[26]=i.id,e[27]=n,e[28]=b):b=e[28];let w;e[29]!==l?(w=l("Retry now"),e[29]=l,e[30]=w):w=e[30];let S;e[31]!==g||e[32]!==b||e[33]!==w?(S=s(le,{"data-testid":g,onClick:b,size:"sm",type:"button",variant:"outline",children:w}),e[31]=g,e[32]=b,e[33]=w,e[34]=S):S=e[34];let N;e[35]!==l?(N=l("Drop job?"),e[35]=l,e[36]=N):N=e[36];let T;e[37]!==i.id||e[38]!==n?(T=()=>{Z(n(Qe,i.id))},e[37]=i.id,e[38]=n,e[39]=T):T=e[39];const L=`outbox-drop-${i.id}`;let $;e[40]!==l?($=l("Drop"),e[40]=l,e[41]=$):$=e[41];let A;e[42]!==N||e[43]!==T||e[44]!==L||e[45]!==$?(A=s(me,{confirmLabel:N,onConfirm:T,testId:L,children:$}),e[42]=N,e[43]=T,e[44]=L,e[45]=$,e[46]=A):A=e[46];let C;e[47]!==S||e[48]!==A?(C=s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[S,A]})}),e[47]=S,e[48]=A,e[49]=C):C=e[49];let k;return e[50]!==a||e[51]!==d||e[52]!==h||e[53]!==C||e[54]!==o||e[55]!==m||e[56]!==y?(k=R(Q,{"data-testid":a,children:[o,m,y,d,h,C]}),e[50]=a,e[51]=d,e[52]=h,e[53]=C,e[54]=o,e[55]=m,e[56]=y,e[57]=k):k=e[57],k},Ge=t=>{const e=V(41),{entries:i,onAct:n}=t,l=z();let a;e[0]!==l?(a=l("function"),e[0]=l,e[1]=a):a=e[1];let r;e[2]!==a?(r=s(O,{children:a}),e[2]=a,e[3]=r):r=e[3];let o;e[4]!==l?(o=l("state"),e[4]=l,e[5]=o):o=e[5];let u;e[6]!==o?(u=s(O,{children:o}),e[6]=o,e[7]=u):u=e[7];let v;e[8]!==l?(v=l("attempts"),e[8]=l,e[9]=v):v=e[9];let f;e[10]!==v?(f=s(O,{children:v}),e[10]=v,e[11]=f):f=e[11];let c;e[12]!==l?(c=l("next attempt"),e[12]=l,e[13]=c):c=e[13];let m;e[14]!==c?(m=s(O,{children:c}),e[14]=c,e[15]=m):m=e[15];let y;e[16]!==l?(y=l("id"),e[16]=l,e[17]=y):y=e[17];let p;e[18]!==y?(p=s(O,{children:y}),e[18]=y,e[19]=p):p=e[19];let d;e[20]!==l?(d=l("Actions"),e[20]=l,e[21]=d):d=e[21];let h;e[22]!==d?(h=s(O,{"aria-label":d}),e[22]=d,e[23]=h):h=e[23];let g;e[24]!==p||e[25]!==h||e[26]!==r||e[27]!==u||e[28]!==f||e[29]!==m?(g=s(te,{children:R(Q,{children:[r,u,f,m,p,h]})}),e[24]=p,e[25]=h,e[26]=r,e[27]=u,e[28]=f,e[29]=m,e[30]=g):g=e[30];let b;if(e[31]!==i||e[32]!==n){let N;e[34]!==n?(N=T=>s(We,{entry:T,onAct:n},T.id),e[34]=n,e[35]=N):N=e[35],b=i.map(N),e[31]=i,e[32]=n,e[33]=b}else b=e[33];let w;e[36]!==b?(w=s(se,{children:b}),e[36]=b,e[37]=w):w=e[37];let S;return e[38]!==g||e[39]!==w?(S=s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"outbox-table",children:[g,w]})})}),e[38]=g,e[39]=w,e[40]=S):S=e[40],S},Ye=t=>{const e=V(11),{cursor:i,nextCursor:n,onFirst:l,onNext:a}=t,r=z();if(i===void 0&&n===void 0)return;let o;e[0]!==i||e[1]!==l||e[2]!==r?(o=i!==void 0&&s(le,{"data-testid":"outbox-first-page",onClick:l,size:"sm",type:"button",variant:"outline",children:r("First page")}),e[0]=i,e[1]=l,e[2]=r,e[3]=o):o=e[3];let u;e[4]!==n||e[5]!==a||e[6]!==r?(u=n!==void 0&&s(le,{"data-testid":"outbox-next-page",onClick:()=>{a(n)},size:"sm",type:"button",variant:"outline",children:r("Next page")}),e[4]=n,e[5]=a,e[6]=r,e[7]=u):u=e[7];let v;return e[8]!==o||e[9]!==u?(v=R("div",{className:"flex justify-end gap-1.5",children:[o,u]}),e[8]=o,e[9]=u,e[10]=v):v=e[10],v},je=t=>{const e=V(38);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n}=i,l=Ae(),a=z(),{queryShardKey:r,setShardKey:o,shardKey:u}=ye(n);let v;e[2]!==r?(v={cursor:void 0,shardKey:r},e[2]=r,e[3]=v):v=e[3];const[f,c]=G(v);f.shardKey!==r&&c({cursor:void 0,shardKey:r});const m=f.shardKey===r?f.cursor:void 0,y=u.trim()!==r;let p;e[4]!==m?(p=m===void 0?{}:{cursor:m},e[4]=m,e[5]=p):p=e[5];let d;e[6]!==r?(d={shardKey:r},e[6]=r,e[7]=d):d=e[7];const{data:h,error:g,poll:b,refetch:w}=xe(ce.getScheduleOutbox,p,d),S=y?void 0:h?.entries,N=y?void 0:h?.nextCursor,[T,L]=G(void 0),$=g??(T?.shardKey===r?T.message:void 0);re(b,!0);let A;e[8]!==l||e[9]!==r||e[10]!==w||e[11]!==a?(A=async(J,U)=>{L(void 0);try{(await l.query(J,{id:U},ke(r))).retried===!1&&L({message:a("That job is no longer in the outbox."),shardKey:r}),w()}catch(P){L({message:de(P),shardKey:r})}},e[8]=l,e[9]=r,e[10]=w,e[11]=a,e[12]=A):A=e[12];const C=A;let k;e[13]!==o||e[14]!==u?(k=s(be,{onChange:o,testId:"outbox-shard-input",value:u}),e[13]=o,e[14]=u,e[15]=k):k=e[15];let x;e[16]!==$?(x=$!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"outbox-error",role:"alert",children:$}),e[16]=$,e[17]=x):x=e[17];let I;e[18]!==m||e[19]!==S?.length?(I=S?.length===0&&m===void 0&&s(ze,{}),e[18]=m,e[19]=S?.length,e[20]=I):I=e[20];let D;e[21]!==C||e[22]!==S?(D=S!==void 0&&S.length>0&&s(Ge,{entries:S,onAct:C}),e[21]=C,e[22]=S,e[23]=D):D=e[23];let E,_;e[24]!==r?(E=()=>{c({cursor:void 0,shardKey:r})},_=J=>{c({cursor:J,shardKey:r})},e[24]=r,e[25]=E,e[26]=_):(E=e[25],_=e[26]);let F;e[27]!==m||e[28]!==N||e[29]!==E||e[30]!==_?(F=s(Ye,{cursor:m,nextCursor:N,onFirst:E,onNext:_}),e[27]=m,e[28]=N,e[29]=E,e[30]=_,e[31]=F):F=e[31];let B;return e[32]!==F||e[33]!==k||e[34]!==x||e[35]!==I||e[36]!==D?(B=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-schedule-outbox",children:[k,x,I,D,F]}),e[32]=F,e[33]=k,e[34]=x,e[35]=I,e[36]=D,e[37]=B):B=e[37],B},Xe="scheduler.lag_ms",he=t=>{const e=t.attributes?.function;return typeof e=="string"?e:t.functionPath},fe=t=>{const e=V(8),{label:i,testId:n,value:l}=t;let a;e[0]!==i?(a=s("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=a):a=e[1];let r;e[2]!==n||e[3]!==l?(r=s("span",{className:"text-2xl font-semibold tabular-nums","data-testid":n,children:l}),e[2]=n,e[3]=l,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=s(j,{className:"flex-1 py-0",children:R(X,{className:"flex flex-col gap-1 p-4",children:[a,r]})}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o},Ze=t=>{const e=V(65);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadStatus:l}=i,a=ae(),r=z(),o=l===void 0;let u;e[2]!==o?(u=["lunora-scheduler-status",o],e[2]=o,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==l?(v=async()=>{const J=await(l??(()=>a.schedulerStatus()))();return{...J,pools:J.pools.toSorted(et)}},e[4]=a,e[5]=l,e[6]=v):v=e[6];const f=ne(u,v),{data:c,error:m}=f,{queryShardKey:y,setShardKey:p,shardKey:d}=ye(n);let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h={},e[7]=h):h=e[7];let g;e[8]!==y?(g={shardKey:y},e[8]=y,e[9]=g):g=e[9];const b=xe(ce.getMetricSeries,h,g),{data:w,errorSource:S}=b;let N;e[10]!==S||e[11]!==b.error?(N=ge(S)==="FUNCTION_NOT_FOUND"?null:b.error,e[10]=S,e[11]=b.error,e[12]=N):N=e[12];const T=N;let L;e[13]!==f?(L=()=>f.poll(),e[13]=f,e[14]=L):L=e[14],re(L,!0);let $;e[15]!==b?($=()=>b.poll(),e[15]=b,e[16]=$):$=e[16],re($,!0);let A,C,k,x,I,D,E,_;if(e[17]!==m||e[18]!==w||e[19]!==T||e[20]!==p||e[21]!==d||e[22]!==c||e[23]!==r){const J=(Array.isArray(w?.series)?w.series:[]).filter(tt).toSorted(st);A="flex flex-col gap-3",C="lunora-scheduler-pools",e[32]!==m?(k=m!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:m}),e[32]=m,e[33]=k):k=e[33],e[34]!==c||e[35]!==r?(x=c!==void 0&&R("div",{className:"flex gap-3","data-testid":"pools-totals",children:[s(fe,{label:r("backlog"),testId:"pools-backlog",value:c.backlog}),s(fe,{label:r("in flight"),testId:"pools-inflight",value:c.inFlight}),s(fe,{label:r("pools"),testId:"pools-count",value:c.pools.length})]}),e[34]=c,e[35]=r,e[36]=x):x=e[36],e[37]!==c?.pools.length||e[38]!==r?(I=c?.pools.length===0&&s(oe,{description:r("Pools created with createWorkpool appear here once they have activity."),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 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[37]=c?.pools.length,e[38]=r,e[39]=I):I=e[39];let U;e[40]!==p||e[41]!==d?(U=s(be,{onChange:p,testId:"lag-shard-input",value:d}),e[40]=p,e[41]=d,e[42]=U):U=e[42];let P;e[43]!==r?(P=r("Start lag per job on this shard since it last woke; the series reset when the shard hibernates."),e[43]=r,e[44]=P):P=e[44];let M;e[45]!==P?(M=s("p",{className:"text-xs text-muted-foreground","data-testid":"lag-scope",children:P}),e[45]=P,e[46]=M):M=e[46],e[47]!==U||e[48]!==M?(D=R("div",{className:"flex flex-wrap items-center gap-3",children:[U,M]}),e[47]=U,e[48]=M,e[49]=D):D=e[49],e[50]!==T?(E=T!==null&&s("p",{className:"text-sm text-destructive","data-testid":"lag-error",role:"alert",children:T}),e[50]=T,e[51]=E):E=e[51],_=T===null&&J.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"lag-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("function")}),s(O,{children:r("runs")}),s(O,{children:r("mean lag (ms)")}),s(O,{children:r("max lag (ms)")}),s(O,{children:r("last lag (ms)")})]})}),s(se,{children:J.map(lt)})]})})}),e[17]=m,e[18]=w,e[19]=T,e[20]=p,e[21]=d,e[22]=c,e[23]=r,e[24]=A,e[25]=C,e[26]=k,e[27]=x,e[28]=I,e[29]=D,e[30]=E,e[31]=_}else A=e[24],C=e[25],k=e[26],x=e[27],I=e[28],D=e[29],E=e[30],_=e[31];let F;e[52]!==c||e[53]!==r?(F=c!==void 0&&c.pools.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"pools-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("pool")}),s(O,{children:r("queued")}),s(O,{children:r("in flight")}),s(O,{children:r("max concurrency")})]})}),s(se,{children:c.pools.map(rt)})]})})}),e[52]=c,e[53]=r,e[54]=F):F=e[54];let B;return e[55]!==A||e[56]!==C||e[57]!==k||e[58]!==x||e[59]!==I||e[60]!==D||e[61]!==E||e[62]!==_||e[63]!==F?(B=R("div",{className:A,"data-testid":C,children:[k,x,I,D,E,_,F]}),e[55]=A,e[56]=C,e[57]=k,e[58]=x,e[59]=I,e[60]=D,e[61]=E,e[62]=_,e[63]=F,e[64]=B):B=e[64],B};function et(t,e){return e.queued-t.queued}function tt(t){return t.name===Xe&&t.kind==="histogram"&&t.count>0}function st(t,e){return e.max-t.max}function lt(t){return R(Q,{"data-testid":`lag-row-${he(t)}`,children:[s(K,{className:"font-mono text-xs",children:he(t)}),s(K,{className:"tabular-nums",children:t.count}),s(K,{className:"tabular-nums",children:Math.round(t.sum/t.count)}),s(K,{className:"tabular-nums",children:t.max}),s(K,{className:"tabular-nums",children:t.last})]},he(t))}function rt(t){return R(Q,{"data-testid":`pools-row-${t.name}`,children:[s(K,{className:"font-mono text-xs",children:t.name}),s(K,{className:"tabular-nums",children:t.queued}),R(K,{className:"tabular-nums",children:[t.inFlight," / ",t.maxConcurrency]}),s(K,{className:"tabular-nums",children:t.maxConcurrency})]},t.name)}const it=["jobs","outbox","history","dead","pools","cron"],It=t=>{const e=V(55);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadCronJobs:l,scheduledCancel:a,scheduledLoad:r}=i,o=z(),[u,v]=G("jobs");let f;e[2]!==o?(f=o("Cron triggers"),e[2]=o,e[3]=f):f=e[3];let c;e[4]!==o?(c=o("Dead letter"),e[4]=o,e[5]=c):c=e[5];let m;e[6]!==o?(m=o("History"),e[6]=o,e[7]=m):m=e[7];let y;e[8]!==o?(y=o("Scheduled jobs"),e[8]=o,e[9]=y):y=e[9];let p;e[10]!==o?(p=o("Outbox"),e[10]=o,e[11]=p):p=e[11];let d;e[12]!==o?(d=o("Pools"),e[12]=o,e[13]=d):d=e[13];let h;e[14]!==f||e[15]!==c||e[16]!==m||e[17]!==y||e[18]!==p||e[19]!==d?(h={cron:f,dead:c,history:m,jobs:y,outbox:p,pools:d},e[14]=f,e[15]=c,e[16]=m,e[17]=y,e[18]=p,e[19]=d,e[20]=h):h=e[20];const g=h;let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{v(E.currentTarget.dataset.view)},e[21]=b):b=e[21];const w=b;let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=s(we,{}),e[22]=S):S=e[22];let N;e[23]!==o?(N=o("Schedule view"),e[23]=o,e[24]=N):N=e[24];let T;e[25]!==u||e[26]!==g?(T=it.map(E=>s(le,{"aria-selected":u===E,"data-testid":`schedule-view-${E}`,"data-view":E,onClick:w,role:"tab",size:"sm",type:"button",variant:u===E?"default":"outline",children:g[E]},E)),e[25]=u,e[26]=g,e[27]=T):T=e[27];let L;e[28]!==N||e[29]!==T?(L=s("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:T}),e[28]=N,e[29]=T,e[30]=L):L=e[30];let $;e[31]!==a||e[32]!==r||e[33]!==u?($=u==="jobs"&&s($e,{cancelJob:a,loadJobs:r}),e[31]=a,e[32]=r,e[33]=u,e[34]=$):$=e[34];let A;e[35]!==u?(A=u==="outbox"&&s(je,{}),e[35]=u,e[36]=A):A=e[36];let C;e[37]!==u?(C=u==="history"&&s(Be,{}),e[37]=u,e[38]=C):C=e[38];let k;e[39]!==u?(k=u==="dead"&&s(Pe,{}),e[39]=u,e[40]=k):k=e[40];let x;e[41]!==n||e[42]!==u?(x=u==="pools"&&s(Ze,{initialShardKey:n}),e[41]=n,e[42]=u,e[43]=x):x=e[43];let I;e[44]!==l||e[45]!==u?(I=u==="cron"&&s(Je,{loadCronJobs:l}),e[44]=l,e[45]=u,e[46]=I):I=e[46];let D;return e[47]!==L||e[48]!==$||e[49]!==A||e[50]!==C||e[51]!==k||e[52]!==x||e[53]!==I?(D=R("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,L,$,A,C,k,x,I]}),e[47]=L,e[48]=$,e[49]=A,e[50]=C,e[51]=k,e[52]=x,e[53]=I,e[54]=D):D=e[54],D};export{It as SchedulePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-
|
|
1
|
+
import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(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]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-
|
|
1
|
+
import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as v,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{k as q}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as c,jsx as t}from"react/jsx-runtime";const w=80,G=l=>{if(l===void 0)return"";const e=JSON.stringify(l,q);return e.length>w?`${e.slice(0,w)}…`:e},J=l=>{const e=[];for(const r of l){const n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((s,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:s})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=l=>{const e=R(24),{initialShardKey:r}=l,n=O(),{queryShardKey:s,setShardKey:i,shardKey:m}=L(r);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==s?(f={keepPreviousData:!0,shardKey:s},e[1]=s,e[2]=f):f=e[2];const{data:o,error:a,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==a||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==i||e[8]!==m||e[9]!==n){const N=o===void 0?[]:J(o.connections);let d;e[11]!==i||e[12]!==m?(d=t(E,{onChange:i,testId:"subs-shard-input",value:m}),e[11]=i,e[12]=m,e[13]=d):d=e[13];let u;e[14]!==o||e[15]!==n?(u=o!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:o.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:o.totalSubscriptions})})]}),e[14]=o,e[15]=n,e[16]=u):u=e[16];let g;e[17]!==d||e[18]!==u?(g=c("div",{className:"flex flex-wrap items-center gap-2",children:[d,u]}),e[17]=d,e[18]=u,e[19]=g):g=e[19];let x;e[20]!==a||e[21]!==h||e[22]!==s?(x=a!==null&&t(j,{error:h,shardKey:s,testId:"subs-error"}),e[20]=a,e[21]=h,e[22]=s,e[23]=x):x=e[23],b=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,a===null&&o!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),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:"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.")}),a===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:c(_,{"data-testid":"subs-table",children:[t(D,{children:c(T,{children:[t(v,{children:n("Connection")}),t(v,{children:n("Function path")}),t(v,{children:n("Table")}),t(v,{children:n("Arguments")})]})}),t(H,{children:N.map(y=>{const{subscription:k}=y,I=G(k?.args);return c(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},y.key)})})]})})})]}),e[3]=a,e[4]=h,e[5]=s,e[6]=o,e[7]=i,e[8]=m,e[9]=n,e[10]=b}else b=e[10];return b};export{ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as q}from"react/compiler-runtime";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as s}from"../packem_shared/table-D0SBiDu-.mjs";import{a as I}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-
|
|
1
|
+
import{c as q}from"react/compiler-runtime";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as s}from"../packem_shared/table-D0SBiDu-.mjs";import{a as I}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as V}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as n,jsxs as r}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:g}=W,t=Y(),A=V();let T;e[0]!==A||e[1]!==g?(T=()=>Promise.resolve(g?g():A.debug()),e[0]=A,e[1]=g,e[2]=T):T=e[2];const M=T,E=g?"injected":"live";let x;e[3]!==E?(x=["lunora-studio","sync-client-debug",E],e[3]=E,e[4]=x):x=e[4];const{data:c,poll:O}=I(x,M);if(Q(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let S;e[7]!==t?(S=t("Sync client"),e[7]=t,e[8]=S):S=e[8];let k;return e[9]!==i||e[10]!==S?(k=n(R,{children:n(H,{children:n(P,{description:i,title:S})})}),e[9]=i,e[10]=S,e[11]=k):k=e[11],k}const{pendingWrites:C,shards:v,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const L=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==L?(d=n(_,{variant:L,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=L,e[18]=d):d=e[18];let h;e[19]!==C||e[20]!==t?(h=C>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:C})}):null,e[19]=C,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=r("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("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]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==v||e[31]!==t?(p=v.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:v.map(i=>r(w,{children:[n(s,{children:i.shardKey??t("(default)")}),n(s,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=v,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>r(w,{children:[n(s,{className:"font-mono text-xs",children:i.functionPath}),n(s,{children:i.kind}),n(s,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(s,{children:i.serverCursor??"—"}),n(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:r(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
|