@lunora/studio 1.0.0-alpha.85 → 1.0.0-alpha.87

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.
Files changed (145) hide show
  1. package/dist/index.d.ts +18 -3
  2. package/dist/index.js +1 -1
  3. package/dist/mount.js +1 -1
  4. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
  5. package/dist/packem_chunks/ApiTab.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  8. package/dist/packem_chunks/FileBrowser.js +1 -1
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  20. package/dist/packem_chunks/SettingsPanel.js +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.js +6 -6
  22. package/dist/packem_chunks/TableEditor.js +1 -1
  23. package/dist/packem_chunks/agents-panel.js +1 -1
  24. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  25. package/dist/packem_chunks/containers-panel.js +1 -1
  26. package/dist/packem_chunks/dashboards-panel.js +1 -1
  27. package/dist/packem_chunks/fanout-panel.js +1 -1
  28. package/dist/packem_chunks/flags-panel.js +1 -1
  29. package/dist/packem_chunks/issues-panel.js +1 -1
  30. package/dist/packem_chunks/kv-browser.js +1 -1
  31. package/dist/packem_chunks/migrations-route.js +1 -1
  32. package/dist/packem_chunks/payments-panel.js +1 -1
  33. package/dist/packem_chunks/permissions-panel.js +1 -1
  34. package/dist/packem_chunks/queues-panel.js +1 -1
  35. package/dist/packem_chunks/rls-panel.js +1 -1
  36. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  37. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  38. package/dist/packem_chunks/traces-panel.js +1 -1
  39. package/dist/packem_chunks/users-panel.js +1 -1
  40. package/dist/packem_chunks/workflows-panel.js +1 -1
  41. package/dist/packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js +1 -0
  42. package/dist/packem_shared/{ApiDocsPanel-fYS9NiLg.js → ApiDocsPanel-DLMeLZ5-.js} +1 -1
  43. package/dist/packem_shared/DataBrowser-CZZ_WkJ-.js +1 -0
  44. package/dist/packem_shared/{GlobalDataBrowser-CSttudUx.js → GlobalDataBrowser-DpkjHfDg.js} +1 -1
  45. package/dist/packem_shared/{HomePanel-BYsfMhKh.js → HomePanel-3baDsDBU.js} +1 -1
  46. package/dist/packem_shared/MigrationsPanel-dygzHUvg.js +1 -0
  47. package/dist/packem_shared/{Studio-Ba9x0dG_.js → Studio-forQt-PC.js} +1 -1
  48. package/dist/packem_shared/{StudioApp-B_PRdg4h.js → StudioApp-B1AWsBzi.js} +1 -1
  49. package/dist/packem_shared/{home-panel-B60-5YfI.js → home-panel-CeeqqV0z.js} +1 -1
  50. package/dist/packem_shared/{studio-CPuoAmjh.js → studio-BtC7WPbz.js} +1 -1
  51. package/dist/packem_shared/table-list-sidebar-D9Bd4qgi.js +1 -0
  52. package/dist/packem_shared/use-shard-key-B2JtNa5m.js +1 -0
  53. package/dist/packem_shared/{use-sql-assistant-BLG9unQN.js → use-sql-assistant-C6dl2_Ty.js} +1 -1
  54. package/dist/packem_shared/useDebounced-CU-uftxO.js +1 -0
  55. package/dist/standalone/chunk-2VWWXVWK.js +1 -0
  56. package/dist/standalone/chunk-3CWGJYBB.js +1 -0
  57. package/dist/standalone/{chunk-52OYJHM7.js → chunk-4JIOFDMR.js} +1 -1
  58. package/dist/standalone/{chunk-MN64D74P.js → chunk-4LCY5XUR.js} +1 -1
  59. package/dist/standalone/{chunk-JE3WK77V.js → chunk-5KRD6F67.js} +1 -1
  60. package/dist/standalone/{chunk-RC3H4OP3.js → chunk-5X4OZ7OD.js} +1 -1
  61. package/dist/standalone/{chunk-TO45V3L6.js → chunk-6MGI5IN6.js} +1 -1
  62. package/dist/standalone/{chunk-HJR42BJY.js → chunk-7DNDRUMZ.js} +1 -1
  63. package/dist/standalone/chunk-7FO57AZY.js +1 -0
  64. package/dist/standalone/{chunk-YNBIW2GN.js → chunk-B5S6GSUC.js} +1 -1
  65. package/dist/standalone/{chunk-QZ6TCNWR.js → chunk-B5UFGO4E.js} +1 -1
  66. package/dist/standalone/{chunk-RFBU5RZI.js → chunk-BDNDSBYM.js} +1 -1
  67. package/dist/standalone/{chunk-QS4IFAFJ.js → chunk-CLNB7I3O.js} +1 -1
  68. package/dist/standalone/{chunk-QSFKPGK4.js → chunk-D3JTCLSF.js} +1 -1
  69. package/dist/standalone/chunk-DABW4OOI.js +1 -0
  70. package/dist/standalone/{chunk-SPT3KPV7.js → chunk-EAIUBZA5.js} +1 -1
  71. package/dist/standalone/{chunk-FUBR2PAD.js → chunk-EJ2CHD4G.js} +1 -1
  72. package/dist/standalone/chunk-EVTCXQ5D.js +1 -0
  73. package/dist/standalone/{chunk-OLM62NLS.js → chunk-EWDLYYJM.js} +1 -1
  74. package/dist/standalone/{chunk-ZOX6X2DL.js → chunk-F7NVC7YK.js} +1 -1
  75. package/dist/standalone/chunk-FURI47Z2.js +1 -0
  76. package/dist/standalone/chunk-FW75RYZU.js +1 -0
  77. package/dist/standalone/chunk-GE5WTIWX.js +1 -0
  78. package/dist/standalone/{chunk-BAAU4OTI.js → chunk-GZS3ORGS.js} +1 -1
  79. package/dist/standalone/chunk-HYCMT2V5.js +1 -0
  80. package/dist/standalone/{chunk-5YADKLAQ.js → chunk-IAKPXGTQ.js} +1 -1
  81. package/dist/standalone/chunk-IVCIG5J7.js +4 -0
  82. package/dist/standalone/chunk-KJIBL5D4.js +1 -0
  83. package/dist/standalone/chunk-L4RW5BFD.js +1 -0
  84. package/dist/standalone/{chunk-PWTURL56.js → chunk-LYRAWNV7.js} +1 -1
  85. package/dist/standalone/chunk-MIFLRBVS.js +11 -0
  86. package/dist/standalone/{chunk-OOL3FV6A.js → chunk-MV4A2PAK.js} +1 -1
  87. package/dist/standalone/{chunk-347H2BQO.js → chunk-NBUBAW3V.js} +1 -1
  88. package/dist/standalone/{chunk-232MBXB2.js → chunk-NCWUTRZB.js} +1 -1
  89. package/dist/standalone/{chunk-D67BVBQW.js → chunk-NMLCYY4H.js} +1 -1
  90. package/dist/standalone/{chunk-MDHUWMFD.js → chunk-OOWHAURL.js} +1 -1
  91. package/dist/standalone/{chunk-UOQ24BAY.js → chunk-ORVR33FM.js} +1 -1
  92. package/dist/standalone/{chunk-7AG3T4DK.js → chunk-OUCGTB3Y.js} +2 -2
  93. package/dist/standalone/chunk-PDMZITZZ.js +1 -0
  94. package/dist/standalone/{chunk-VORDESEQ.js → chunk-PNAVAJAF.js} +1 -1
  95. package/dist/standalone/{chunk-LVJ5IHEU.js → chunk-QJTGO4JG.js} +1 -1
  96. package/dist/standalone/{chunk-EDOMDMVI.js → chunk-QP7IQOKF.js} +1 -1
  97. package/dist/standalone/chunk-QXDMHM2V.js +1 -0
  98. package/dist/standalone/{chunk-VKEJTZY7.js → chunk-S2CXYDNT.js} +1 -1
  99. package/dist/standalone/{chunk-AQKXMWNF.js → chunk-S3DWUXGY.js} +1 -1
  100. package/dist/standalone/{chunk-YSMJN36P.js → chunk-SJZQPIZB.js} +1 -1
  101. package/dist/standalone/{chunk-ETZYJL7Z.js → chunk-SMEW3ZTU.js} +1 -1
  102. package/dist/standalone/chunk-SNK7TOOO.js +6 -0
  103. package/dist/standalone/{chunk-QI25LTPH.js → chunk-T2Q7I3V2.js} +1 -1
  104. package/dist/standalone/{chunk-ESKVOZLC.js → chunk-T3CGXSXO.js} +1 -1
  105. package/dist/standalone/{chunk-YGKR536O.js → chunk-TS6346VY.js} +1 -1
  106. package/dist/standalone/{chunk-ENBTOX7N.js → chunk-TVGKSIIW.js} +1 -1
  107. package/dist/standalone/{chunk-U5IIRHZ6.js → chunk-UNVK2VZP.js} +1 -1
  108. package/dist/standalone/{chunk-U44CWN7H.js → chunk-UR3X4K4T.js} +1 -1
  109. package/dist/standalone/chunk-VDW32UET.js +1 -0
  110. package/dist/standalone/chunk-VQK34A2H.js +1 -0
  111. package/dist/standalone/{chunk-MBVSXVTV.js → chunk-WPUINKEO.js} +1 -1
  112. package/dist/standalone/chunk-XNGYYOLS.js +14 -0
  113. package/dist/standalone/{chunk-2SC3EG5Y.js → chunk-XR7RBXKA.js} +1 -1
  114. package/dist/standalone/{chunk-KNHWIHC7.js → chunk-XZN645UJ.js} +1 -1
  115. package/dist/standalone/chunk-YFJXQUPW.js +1 -0
  116. package/dist/standalone/chunk-YKAO3JNJ.js +1 -0
  117. package/dist/standalone/{chunk-AHVDZWB3.js → chunk-YRYEZHOJ.js} +1 -1
  118. package/dist/standalone/{chunk-TIR6CWHO.js → chunk-ZCFDQW4U.js} +1 -1
  119. package/dist/standalone/studio.js +1 -1
  120. package/package.json +6 -6
  121. package/dist/packem_shared/ADMIN_FUNCTIONS-CZESgd10.js +0 -1
  122. package/dist/packem_shared/DataBrowser-C4J4gVUu.js +0 -1
  123. package/dist/packem_shared/MigrationsPanel-2JbQ2HwG.js +0 -1
  124. package/dist/packem_shared/table-list-sidebar-BRv3hTLX.js +0 -1
  125. package/dist/packem_shared/useDebounced-Ihdiid_k.js +0 -1
  126. package/dist/standalone/chunk-22LOWEEC.js +0 -1
  127. package/dist/standalone/chunk-2EJADIPC.js +0 -1
  128. package/dist/standalone/chunk-4I2TBTZS.js +0 -1
  129. package/dist/standalone/chunk-6IEBRNDW.js +0 -1
  130. package/dist/standalone/chunk-D3FRQZ4X.js +0 -1
  131. package/dist/standalone/chunk-ERMTJYQF.js +0 -1
  132. package/dist/standalone/chunk-JAT5ZBQK.js +0 -1
  133. package/dist/standalone/chunk-JOFD43OI.js +0 -1
  134. package/dist/standalone/chunk-LFKCLLPT.js +0 -1
  135. package/dist/standalone/chunk-MLULN4R2.js +0 -1
  136. package/dist/standalone/chunk-MUGKOGZG.js +0 -1
  137. package/dist/standalone/chunk-NPKNFZUW.js +0 -6
  138. package/dist/standalone/chunk-OV63HVE4.js +0 -4
  139. package/dist/standalone/chunk-QFJRZR4U.js +0 -1
  140. package/dist/standalone/chunk-QNRAMF4X.js +0 -1
  141. package/dist/standalone/chunk-QNUWWC3N.js +0 -14
  142. package/dist/standalone/chunk-S67SBGB3.js +0 -1
  143. package/dist/standalone/chunk-SHD2IWQI.js +0 -1
  144. package/dist/standalone/chunk-SKFZXESP.js +0 -1
  145. package/dist/standalone/chunk-UBR4KB6K.js +0 -11
@@ -1 +1 @@
1
- import{c as xe}from"react/compiler-runtime";import{findIssueSolution as Ie,flattenHint as Se}from"@lunora/errors";import{useLunora as $e}from"@lunora/react";import{useState as re}from"react";import{L as ke}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as Me}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as ge}from"../packem_shared/badge-BbuuAio7.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{c as Ae,u as Ce}from"../packem_shared/card-CIDGUN6K.js";import{E as Te}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as _e}from"../packem_shared/input-JHu63lTv.js";import{N as Ee,y as Ke,_ as Le,k as be,w as Re}from"../packem_shared/select-Bul-DeII.js";import{n as ze,d as Fe,m as ve,p as q,f as Ve,u as j}from"../packem_shared/table-DdJBrClo.js";import{N as We}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{u as je}from"../packem_shared/use-async-submit-q3ymBJkD.js";import qe from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as ye}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{i as De,f as ne,g as de,d as we,b as Oe}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as s,jsxs as I,Fragment as Be}from"react/jsx-runtime";const fe="none",Ge=["all","open","resolved","ignored"],Ue=["critical","high","medium","low"],He=de(le.resolveIssue),Je=de(le.ignoreIssue),Ne=de(le.assignIssue),Pe=de(le.setIssueSeverity),Qe=de(le.explainIssue),Xe=n=>Array.isArray(n?.issues)?n.issues:[],Ye=n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning",Ze=n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary",et=n=>{const e=xe(44),{expanded:o,issue:t,shardKey:S}=n,i=$e(),l=ye(),[a,C]=re(void 0),{busy:T,error:_,run:F}=je();let E;e[0]!==i||e[1]!==t||e[2]!==F||e[3]!==S?(E=()=>{C(void 0),F(async()=>{const g={culprit:t.culprit,sampleMessage:t.sampleMessage,title:t.title},w=await i.query(Qe,g,we(S));C(w)})},e[0]=i,e[1]=t,e[2]=F,e[3]=S,e[4]=E):E=e[4];const K=E;if(!o)return null;let d;if(e[5]!==t.sampleMessage){const g=Ie(t.sampleMessage);d=g===void 0?void 0:Se(g.body),e[5]=t.sampleMessage,e[6]=d}else d=e[6];const M=d,L=`issues-detail-${t.hash}`;let h;e[7]!==t.sampleMessage?(h=s("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:t.sampleMessage}),e[7]=t.sampleMessage,e[8]=h):h=e[8];let f;e[9]!==l?(f=l("Suggested fix"),e[9]=l,e[10]=f):f=e[10];let v;e[11]!==f?(v=s("div",{className:"text-xs font-medium text-muted-foreground",children:f}),e[11]=f,e[12]=v):v=e[12];let N;e[13]!==M||e[14]!==t.hash||e[15]!==l?(N=M===void 0?s("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${t.hash}`,children:l("No known fix for this error yet.")}):s("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${t.hash}`,children:M}),e[13]=M,e[14]=t.hash,e[15]=l,e[16]=N):N=e[16];let c;e[17]!==v||e[18]!==N?(c=I("div",{children:[v,N]}),e[17]=v,e[18]=N,e[19]=c):c=e[19];const A=`issues-explain-${t.hash}`;let u;e[20]!==T||e[21]!==l?(u=l(T?"Explaining…":"Explain in plain language"),e[20]=T,e[21]=l,e[22]=u):u=e[22];let $;e[23]!==T||e[24]!==K||e[25]!==u||e[26]!==A?($=s("div",{children:s(oe,{"data-testid":A,disabled:T,onClick:K,size:"sm",type:"button",variant:"outline",children:u})}),e[23]=T,e[24]=K,e[25]=u,e[26]=A,e[27]=$):$=e[27];let m;e[28]!==_||e[29]!==t.hash?(m=_!==null&&s("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${t.hash}`,role:"alert",children:_}),e[28]=_,e[29]=t.hash,e[30]=m):m=e[30];let x;e[31]!==a||e[32]!==t.hash||e[33]!==l?(x=a!==void 0&&(a.degraded?s("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${t.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations — the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):I("div",{"data-testid":`issues-explanation-${t.hash}`,children:[s("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),s("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&s("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${t.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),s("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=t.hash,e[33]=l,e[34]=x):x=e[34];let p;e[35]!==$||e[36]!==m||e[37]!==x||e[38]!==h||e[39]!==c?(p=s(j,{className:"bg-muted/30",colSpan:7,children:I("div",{className:"flex flex-col gap-3 py-1",children:[h,c,$,m,x]})}),e[35]=$,e[36]=m,e[37]=x,e[38]=h,e[39]=c,e[40]=p):p=e[40];let b;return e[41]!==p||e[42]!==L?(b=s(ve,{"data-testid":L,children:p}),e[41]=p,e[42]=L,e[43]=b):b=e[43],b},tt=n=>{const e=xe(119),{busy:o,issue:t,rowError:S,runTriage:i,shardKey:l}=n,a=ye(),[C,T]=re(!1);let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{T(st)},e[0]=_):_=e[0];const F=_;let E;e[1]!==t.hash||e[2]!==i?(E=ie=>{const ce=ie===null||ie===fe?null:ie;ne(i(t.hash,Pe,{severity:ce}))},e[1]=t.hash,e[2]=i,e[3]=E):E=e[3];const K=E;let d;e[4]!==t.hash||e[5]!==i?(d=ie=>{if(ie.key!=="Enter")return;const ce=ie.currentTarget.value.trim();ne(i(t.hash,Ne,{assignee:ce===""?null:ce}))},e[4]=t.hash,e[5]=i,e[6]=d):d=e[6];const M=d,L=`issues-row-${t.hash}`;let h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];const f=`issues-toggle-${t.hash}`,v=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${C?"rotate-90":""}`;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=s("path",{d:"m9 6 6 6-6 6"}),e[9]=N):N=e[9];let c;e[10]!==v?(c=s("svg",{"aria-hidden":"true",className:v,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:N}),e[10]=v,e[11]=c):c=e[11];let A;e[12]!==t.title?(A=s("span",{className:"block truncate font-medium",title:t.title,children:t.title}),e[12]=t.title,e[13]=A):A=e[13];let u;e[14]!==t.culprit?(u=s("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:t.culprit,children:t.culprit}),e[14]=t.culprit,e[15]=u):u=e[15];let $;e[16]!==A||e[17]!==u?($=I("span",{className:"min-w-0",children:[A,u]}),e[16]=A,e[17]=u,e[18]=$):$=e[18];let m;e[19]!==C||e[20]!==$||e[21]!==h||e[22]!==f||e[23]!==c?(m=I("button",{"aria-expanded":C,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":f,onClick:F,type:"button",children:[c,$]}),e[19]=C,e[20]=$,e[21]=h,e[22]=f,e[23]=c,e[24]=m):m=e[24];let x;e[25]!==t.hash||e[26]!==S?(x=S!==void 0&&s("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${t.hash}`,role:"alert",children:S}),e[25]=t.hash,e[26]=S,e[27]=x):x=e[27];let p;e[28]!==m||e[29]!==x?(p=I(j,{className:"max-w-80",children:[m,x]}),e[28]=m,e[29]=x,e[30]=p):p=e[30];const b=`issues-status-${t.hash}`;let g;e[31]!==t.status?(g=Ye(t.status),e[31]=t.status,e[32]=g):g=e[32];let w;e[33]!==t.status||e[34]!==b||e[35]!==g?(w=s(j,{children:s(ge,{"data-testid":b,variant:g,children:t.status})}),e[33]=t.status,e[34]=b,e[35]=g,e[36]=w):w=e[36];const z=t.severity??fe;let R;e[37]!==a?(R=a("Set severity"),e[37]=a,e[38]=R):R=e[38];const r=`issues-severity-${t.hash}`;let V;e[39]!==a?(V=a("—"),e[39]=a,e[40]=V):V=e[40];let W;e[41]!==t.severity||e[42]!==a?(W=t.severity===void 0?s("span",{className:"text-muted-foreground",children:a("—")}):s(ge,{variant:Ze(t.severity),children:t.severity}),e[41]=t.severity,e[42]=a,e[43]=W):W=e[43];let y;e[44]!==V||e[45]!==W?(y=s(Ee,{placeholder:V,children:W}),e[44]=V,e[45]=W,e[46]=y):y=e[46];let k;e[47]!==R||e[48]!==r||e[49]!==y?(k=s(Ke,{"aria-label":R,className:"h-7 w-[110px]","data-testid":r,children:y}),e[47]=R,e[48]=r,e[49]=y,e[50]=k):k=e[50];let D;e[51]===Symbol.for("react.memo_cache_sentinel")?(D=Ue.map(at),e[51]=D):D=e[51];let O;e[52]!==a?(O=a("Clear"),e[52]=a,e[53]=O):O=e[53];let B;e[54]!==O?(B=I(Le,{children:[D,s(be,{value:fe,children:O})]}),e[54]=O,e[55]=B):B=e[55];let G;e[56]!==o||e[57]!==K||e[58]!==z||e[59]!==k||e[60]!==B?(G=s(j,{children:I(Re,{disabled:o,onValueChange:K,value:z,children:[k,B]})}),e[56]=o,e[57]=K,e[58]=z,e[59]=k,e[60]=B,e[61]=G):G=e[61];let U;e[62]!==a?(U=a("Assignee"),e[62]=a,e[63]=U):U=e[63];const ue=`issues-assignee-${t.hash}`,me=t.assignee??"",pe=t.assignee??"";let H;e[64]!==a?(H=a("Unassigned"),e[64]=a,e[65]=H):H=e[65];let J;e[66]!==o||e[67]!==M||e[68]!==U||e[69]!==ue||e[70]!==me||e[71]!==pe||e[72]!==H?(J=s(j,{children:s(_e,{"aria-label":U,className:"h-7 w-32","data-testid":ue,defaultValue:me,disabled:o,onKeyDown:M,placeholder:H},pe)}),e[66]=o,e[67]=M,e[68]=U,e[69]=ue,e[70]=me,e[71]=pe,e[72]=H,e[73]=J):J=e[73];let P;e[74]!==t.count?(P=s(j,{className:"text-right",children:s(ge,{variant:"secondary",children:t.count})}),e[74]=t.count,e[75]=P):P=e[75];let Q;e[76]!==t.lastSeen?(Q=De(t.lastSeen),e[76]=t.lastSeen,e[77]=Q):Q=e[77];let X;e[78]!==Q?(X=s(j,{className:"text-xs tabular-nums text-muted-foreground",children:Q}),e[78]=Q,e[79]=X):X=e[79];let Y;e[80]!==o||e[81]!==t.hash||e[82]!==t.status||e[83]!==i||e[84]!==a?(Y=t.status!=="resolved"&&s(oe,{"data-testid":`issues-resolve-${t.hash}`,disabled:o,onClick:()=>{ne(i(t.hash,He,{}))},size:"xs",variant:"outline",children:a("Resolve")}),e[80]=o,e[81]=t.hash,e[82]=t.status,e[83]=i,e[84]=a,e[85]=Y):Y=e[85];let Z;e[86]!==o||e[87]!==t.hash||e[88]!==t.status||e[89]!==i||e[90]!==a?(Z=t.status!=="ignored"&&s(oe,{"data-testid":`issues-ignore-${t.hash}`,disabled:o,onClick:()=>{ne(i(t.hash,Je,{}))},size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=o,e[87]=t.hash,e[88]=t.status,e[89]=i,e[90]=a,e[91]=Z):Z=e[91];let ee;e[92]!==o||e[93]!==t.assignee||e[94]!==t.hash||e[95]!==t.status||e[96]!==i||e[97]!==a?(ee=t.status!=="open"&&s(oe,{"data-testid":`issues-reopen-${t.hash}`,disabled:o,onClick:()=>{ne(i(t.hash,Ne,{assignee:t.assignee??null}))},size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=o,e[93]=t.assignee,e[94]=t.hash,e[95]=t.status,e[96]=i,e[97]=a,e[98]=ee):ee=e[98];let te;e[99]!==Y||e[100]!==Z||e[101]!==ee?(te=s(j,{className:"text-right",children:I("div",{className:"flex justify-end gap-1",children:[Y,Z,ee]})}),e[99]=Y,e[100]=Z,e[101]=ee,e[102]=te):te=e[102];let se;e[103]!==p||e[104]!==w||e[105]!==G||e[106]!==J||e[107]!==P||e[108]!==X||e[109]!==L||e[110]!==te?(se=I(ve,{"data-testid":L,children:[p,w,G,J,P,X,te]}),e[103]=p,e[104]=w,e[105]=G,e[106]=J,e[107]=P,e[108]=X,e[109]=L,e[110]=te,e[111]=se):se=e[111];let ae;e[112]!==C||e[113]!==t||e[114]!==l?(ae=s(et,{expanded:C,issue:t,shardKey:l},t.sampleMessage),e[112]=C,e[113]=t,e[114]=l,e[115]=ae):ae=e[115];let he;return e[116]!==se||e[117]!==ae?(he=I(Be,{children:[se,ae]}),e[116]=se,e[117]=ae,e[118]=he):he=e[118],he},kt=n=>{const e=xe(38),{initialShardKey:o}=n,t=ye(),S=$e(),[i,l]=re(o??""),[a,C]=re("all"),[T,_]=re(it),[F,E]=re(rt);let K;e[0]!==i?(K=i.trim(),e[0]=i,e[1]=K):K=e[1];const d=qe(K,400);let M;e[2]!==a?(M=a==="all"?{}:{status:a},e[2]=a,e[3]=M):M=e[3];let L;e[4]!==d?(L={live:!0,shardKey:d},e[4]=d,e[5]=L):L=e[5];const{data:h,error:f,liveError:v}=We(le.getIssues,M,L),N=h!==void 0;let c;if(e[6]!==F||e[7]!==T||e[8]!==S||e[9]!==h||e[10]!==d||e[11]!==f||e[12]!==v||e[13]!==N||e[14]!==i||e[15]!==a||e[16]!==t){const A=Xe(h);let u;e[18]!==S||e[19]!==d?(u=async(r,V,W)=>{E(y=>{if(!y.has(r))return y;const k=new Map(y);return k.delete(r),k}),_(y=>new Set(y).add(r));try{await S.query(V,{...W,hash:r},we(d))}catch(y){const k=Oe(y);E(D=>new Map(D).set(r,k))}_(y=>{const k=new Set(y);return k.delete(r),k})},e[18]=S,e[19]=d,e[20]=u):u=e[20];const $=u;let m;e[21]!==t?(m=r=>t(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),e[21]=t,e[22]=m):m=e[22];const x=m;let p;e[23]!==f?(p=f!==null&&s("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:f}),e[23]=f,e[24]=p):p=e[24];let b;e[25]!==i?(b=s(Me,{onChange:l,testId:"issues-shard-input",value:i}),e[25]=i,e[26]=b):b=e[26];let g;e[27]!==v?(g=s(ke,{message:v,prefix:"issues"}),e[27]=v,e[28]=g):g=e[28];let w;e[29]!==a||e[30]!==x?(w=Ge.map(r=>s(oe,{"data-active":a===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:()=>{C(r)},size:"xs",variant:a===r?"default":"outline",children:x(r)},r)),e[29]=a,e[30]=x,e[31]=w):w=e[31];let z;e[32]!==w?(z=s("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:w}),e[32]=w,e[33]=z):z=e[33];let R;e[34]!==z||e[35]!==b||e[36]!==g?(R=I("div",{className:"flex flex-wrap items-center gap-2",children:[b,g,z]}),e[34]=z,e[35]=b,e[36]=g,e[37]=R):R=e[37],c=I("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,R,N&&A.length===0?s(Te,{description:t("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:t("No issues")}):s(Ae,{className:"overflow-hidden py-0",children:s(Ce,{className:"px-0",children:I(ze,{"data-testid":"issues-table",children:[s(Fe,{children:I(ve,{children:[s(q,{children:t("Issue")}),s(q,{children:t("Status")}),s(q,{children:t("Severity")}),s(q,{children:t("Assignee")}),s(q,{className:"text-right",children:t("Events")}),s(q,{children:t("Last seen")}),s(q,{className:"text-right",children:t("Actions")})]})}),s(Ve,{children:A.map(r=>s(tt,{busy:T.has(r.hash),issue:r,rowError:F.get(r.hash),runTriage:$,shardKey:d},r.hash))})]})})})]}),e[6]=F,e[7]=T,e[8]=S,e[9]=h,e[10]=d,e[11]=f,e[12]=v,e[13]=N,e[14]=i,e[15]=a,e[16]=t,e[17]=c}else c=e[17];return c};function st(n){return!n}function at(n){return s(be,{value:n,children:n},n)}function it(){return new Set}function rt(){return new Map}export{kt as IssuesPanel};
1
+ import{c as xe}from"react/compiler-runtime";import{findIssueSolution as Ie,flattenHint as Se}from"@lunora/errors";import{useLunora as $e}from"@lunora/react";import{useState as le}from"react";import{L as ke}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as Me}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as ge}from"../packem_shared/badge-BbuuAio7.js";import{u as ne}from"../packem_shared/button-BkCrNcAs.js";import{c as Ae,u as Ce}from"../packem_shared/card-CIDGUN6K.js";import{E as Ke}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Te}from"../packem_shared/input-JHu63lTv.js";import{N as _e,y as Ee,_ as ze,k as be,w as Le}from"../packem_shared/select-Bul-DeII.js";import{n as Re,d as Fe,m as ve,p as O,f as je,u as q}from"../packem_shared/table-DdJBrClo.js";import{N as qe}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{u as Oe}from"../packem_shared/use-async-submit-q3ymBJkD.js";import{S as Ve}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as ye}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ae}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as We,f as re,g as oe,d as we,b as De}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as t,jsxs as I,Fragment as Ge}from"react/jsx-runtime";const fe="none",Be=["all","open","resolved","ignored"],He=["critical","high","medium","low"],Je=oe(ae.resolveIssue),Qe=oe(ae.ignoreIssue),Ne=oe(ae.assignIssue),Ue=oe(ae.setIssueSeverity),Xe=oe(ae.explainIssue),Ye=n=>Array.isArray(n?.issues)?n.issues:[],Ze=n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning",Pe=n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary",es=n=>{const e=xe(44),{expanded:c,issue:s,shardKey:S}=n,i=$e(),l=ye(),[a,o]=le(void 0),{busy:E,error:C,run:L}=Oe();let K;e[0]!==i||e[1]!==s||e[2]!==L||e[3]!==S?(K=()=>{o(void 0),L(async()=>{const p={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},w=await i.query(Xe,p,we(S));o(w)})},e[0]=i,e[1]=s,e[2]=L,e[3]=S,e[4]=K):K=e[4];const z=K;if(!c)return null;let k;if(e[5]!==s.sampleMessage){const p=Ie(s.sampleMessage);k=p===void 0?void 0:Se(p.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];const T=k,_=`issues-detail-${s.hash}`;let d;e[7]!==s.sampleMessage?(d=t("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=d):d=e[8];let f;e[9]!==l?(f=l("Suggested fix"),e[9]=l,e[10]=f):f=e[10];let M;e[11]!==f?(M=t("div",{className:"text-xs font-medium text-muted-foreground",children:f}),e[11]=f,e[12]=M):M=e[12];let x;e[13]!==T||e[14]!==s.hash||e[15]!==l?(x=T===void 0?t("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):t("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=x):x=e[16];let v;e[17]!==M||e[18]!==x?(v=I("div",{children:[M,x]}),e[17]=M,e[18]=x,e[19]=v):v=e[19];const N=`issues-explain-${s.hash}`;let $;e[20]!==E||e[21]!==l?($=l(E?"Explaining…":"Explain in plain language"),e[20]=E,e[21]=l,e[22]=$):$=e[22];let u;e[23]!==E||e[24]!==z||e[25]!==$||e[26]!==N?(u=t("div",{children:t(ne,{"data-testid":N,disabled:E,onClick:z,size:"sm",type:"button",variant:"outline",children:$})}),e[23]=E,e[24]=z,e[25]=$,e[26]=N,e[27]=u):u=e[27];let g;e[28]!==C||e[29]!==s.hash?(g=C!==null&&t("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:C}),e[28]=C,e[29]=s.hash,e[30]=g):g=e[30];let m;e[31]!==a||e[32]!==s.hash||e[33]!==l?(m=a!==void 0&&(a.degraded?t("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations — the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):I("div",{"data-testid":`issues-explanation-${s.hash}`,children:[t("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),t("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&t("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),t("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=m):m=e[34];let h;e[35]!==u||e[36]!==g||e[37]!==m||e[38]!==d||e[39]!==v?(h=t(q,{className:"bg-muted/30",colSpan:7,children:I("div",{className:"flex flex-col gap-3 py-1",children:[d,v,u,g,m]})}),e[35]=u,e[36]=g,e[37]=m,e[38]=d,e[39]=v,e[40]=h):h=e[40];let b;return e[41]!==h||e[42]!==_?(b=t(ve,{"data-testid":_,children:h}),e[41]=h,e[42]=_,e[43]=b):b=e[43],b},ss=n=>{const e=xe(119),{busy:c,issue:s,rowError:S,runTriage:i,shardKey:l}=n,a=ye(),[o,E]=le(!1);let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{E(ts)},e[0]=C):C=e[0];const L=C;let K;e[1]!==s.hash||e[2]!==i?(K=te=>{const ce=te===null||te===fe?null:te;re(i(s.hash,Ue,{severity:ce}))},e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];const z=K;let k;e[4]!==s.hash||e[5]!==i?(k=te=>{if(te.key!=="Enter")return;const ce=te.currentTarget.value.trim();re(i(s.hash,Ne,{assignee:ce===""?null:ce}))},e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];const T=k,_=`issues-row-${s.hash}`;let d;e[7]!==a?(d=a("Toggle issue details"),e[7]=a,e[8]=d):d=e[8];const f=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`;let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=t("path",{d:"m9 6 6 6-6 6"}),e[9]=x):x=e[9];let v;e[10]!==M?(v=t("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:x}),e[10]=M,e[11]=v):v=e[11];let N;e[12]!==s.title?(N=t("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=N):N=e[13];let $;e[14]!==s.culprit?($=t("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=$):$=e[15];let u;e[16]!==N||e[17]!==$?(u=I("span",{className:"min-w-0",children:[N,$]}),e[16]=N,e[17]=$,e[18]=u):u=e[18];let g;e[19]!==o||e[20]!==u||e[21]!==d||e[22]!==f||e[23]!==v?(g=I("button",{"aria-expanded":o,"aria-label":d,className:"flex w-full items-start gap-2 text-left","data-testid":f,onClick:L,type:"button",children:[v,u]}),e[19]=o,e[20]=u,e[21]=d,e[22]=f,e[23]=v,e[24]=g):g=e[24];let m;e[25]!==s.hash||e[26]!==S?(m=S!==void 0&&t("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:S}),e[25]=s.hash,e[26]=S,e[27]=m):m=e[27];let h;e[28]!==g||e[29]!==m?(h=I(q,{className:"max-w-80",children:[g,m]}),e[28]=g,e[29]=m,e[30]=h):h=e[30];const b=`issues-status-${s.hash}`;let p;e[31]!==s.status?(p=Ze(s.status),e[31]=s.status,e[32]=p):p=e[32];let w;e[33]!==s.status||e[34]!==b||e[35]!==p?(w=t(q,{children:t(ge,{"data-testid":b,variant:p,children:s.status})}),e[33]=s.status,e[34]=b,e[35]=p,e[36]=w):w=e[36];const R=s.severity??fe;let r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];const ie=`issues-severity-${s.hash}`;let F;e[39]!==a?(F=a("—"),e[39]=a,e[40]=F):F=e[40];let y;e[41]!==s.severity||e[42]!==a?(y=s.severity===void 0?t("span",{className:"text-muted-foreground",children:a("—")}):t(ge,{variant:Pe(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=y):y=e[43];let A;e[44]!==F||e[45]!==y?(A=t(_e,{placeholder:F,children:y}),e[44]=F,e[45]=y,e[46]=A):A=e[46];let j;e[47]!==r||e[48]!==ie||e[49]!==A?(j=t(Ee,{"aria-label":r,className:"h-7 w-[110px]","data-testid":ie,children:A}),e[47]=r,e[48]=ie,e[49]=A,e[50]=j):j=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=He.map(as),e[51]=de):de=e[51];let V;e[52]!==a?(V=a("Clear"),e[52]=a,e[53]=V):V=e[53];let W;e[54]!==V?(W=I(ze,{children:[de,t(be,{value:fe,children:V})]}),e[54]=V,e[55]=W):W=e[55];let D;e[56]!==c||e[57]!==z||e[58]!==R||e[59]!==j||e[60]!==W?(D=t(q,{children:I(Le,{disabled:c,onValueChange:z,value:R,children:[j,W]})}),e[56]=c,e[57]=z,e[58]=R,e[59]=j,e[60]=W,e[61]=D):D=e[61];let G;e[62]!==a?(G=a("Assignee"),e[62]=a,e[63]=G):G=e[63];const ue=`issues-assignee-${s.hash}`,me=s.assignee??"",pe=s.assignee??"";let B;e[64]!==a?(B=a("Unassigned"),e[64]=a,e[65]=B):B=e[65];let H;e[66]!==c||e[67]!==T||e[68]!==G||e[69]!==ue||e[70]!==me||e[71]!==pe||e[72]!==B?(H=t(q,{children:t(Te,{"aria-label":G,className:"h-7 w-32","data-testid":ue,defaultValue:me,disabled:c,onKeyDown:T,placeholder:B},pe)}),e[66]=c,e[67]=T,e[68]=G,e[69]=ue,e[70]=me,e[71]=pe,e[72]=B,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=t(q,{className:"text-right",children:t(ge,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let Q;e[76]!==s.lastSeen?(Q=We(s.lastSeen),e[76]=s.lastSeen,e[77]=Q):Q=e[77];let U;e[78]!==Q?(U=t(q,{className:"text-xs tabular-nums text-muted-foreground",children:Q}),e[78]=Q,e[79]=U):U=e[79];let X;e[80]!==c||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&t(ne,{"data-testid":`issues-resolve-${s.hash}`,disabled:c,onClick:()=>{re(i(s.hash,Je,{}))},size:"xs",variant:"outline",children:a("Resolve")}),e[80]=c,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==c||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&t(ne,{"data-testid":`issues-ignore-${s.hash}`,disabled:c,onClick:()=>{re(i(s.hash,Qe,{}))},size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=c,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==c||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&t(ne,{"data-testid":`issues-reopen-${s.hash}`,disabled:c,onClick:()=>{re(i(s.hash,Ne,{assignee:s.assignee??null}))},size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=c,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let P;e[99]!==X||e[100]!==Y||e[101]!==Z?(P=t(q,{className:"text-right",children:I("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=P):P=e[102];let ee;e[103]!==h||e[104]!==w||e[105]!==D||e[106]!==H||e[107]!==J||e[108]!==U||e[109]!==_||e[110]!==P?(ee=I(ve,{"data-testid":_,children:[h,w,D,H,J,U,P]}),e[103]=h,e[104]=w,e[105]=D,e[106]=H,e[107]=J,e[108]=U,e[109]=_,e[110]=P,e[111]=ee):ee=e[111];let se;e[112]!==o||e[113]!==s||e[114]!==l?(se=t(es,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=se):se=e[115];let he;return e[116]!==ee||e[117]!==se?(he=I(Ge,{children:[ee,se]}),e[116]=ee,e[117]=se,e[118]=he):he=e[118],he},ks=n=>{const e=xe(38),{initialShardKey:c}=n,s=ye(),S=$e(),{queryShardKey:i,setShardKey:l,shardKey:a}=Ve(c),[o,E]=le("all"),[C,L]=le(is),[K,z]=le(rs);let k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];const{data:_,error:d,liveError:f}=qe(ae.getIssues,k,T),M=_!==void 0;let x;if(e[4]!==K||e[5]!==C||e[6]!==S||e[7]!==_||e[8]!==d||e[9]!==f||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){const v=Ye(_);let N;e[17]!==S||e[18]!==i?(N=async(r,ie,F)=>{z(y=>{if(!y.has(r))return y;const A=new Map(y);return A.delete(r),A}),L(y=>new Set(y).add(r));try{await S.query(ie,{...F,hash:r},we(i))}catch(y){const A=De(y);z(j=>new Map(j).set(r,A))}L(y=>{const A=new Set(y);return A.delete(r),A})},e[17]=S,e[18]=i,e[19]=N):N=e[19];const $=N;let u;e[20]!==s?(u=r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),e[20]=s,e[21]=u):u=e[21];const g=u;let m;e[22]!==d?(m=d!==null&&t("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:d}),e[22]=d,e[23]=m):m=e[23];let h;e[24]!==l||e[25]!==a?(h=t(Me,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=h):h=e[26];let b;e[27]!==f?(b=t(ke,{message:f,prefix:"issues"}),e[27]=f,e[28]=b):b=e[28];let p;e[29]!==o||e[30]!==g?(p=Be.map(r=>t(ne,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:()=>{E(r)},size:"xs",variant:o===r?"default":"outline",children:g(r)},r)),e[29]=o,e[30]=g,e[31]=p):p=e[31];let w;e[32]!==p?(w=t("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:p}),e[32]=p,e[33]=w):w=e[33];let R;e[34]!==w||e[35]!==h||e[36]!==b?(R=I("div",{className:"flex flex-wrap items-center gap-2",children:[h,b,w]}),e[34]=w,e[35]=h,e[36]=b,e[37]=R):R=e[37],x=I("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[m,R,M&&v.length===0?t(Ke,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):t(Ae,{className:"overflow-hidden py-0",children:t(Ce,{className:"px-0",children:I(Re,{"data-testid":"issues-table",children:[t(Fe,{children:I(ve,{children:[t(O,{children:s("Issue")}),t(O,{children:s("Status")}),t(O,{children:s("Severity")}),t(O,{children:s("Assignee")}),t(O,{className:"text-right",children:s("Events")}),t(O,{children:s("Last seen")}),t(O,{className:"text-right",children:s("Actions")})]})}),t(je,{children:v.map(r=>t(ss,{busy:C.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:$,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=C,e[6]=S,e[7]=_,e[8]=d,e[9]=f,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=x}else x=e[16];return x};function ts(n){return!n}function as(n){return t(be,{value:n,children:n},n)}function is(){return new Set}function rs(){return new Map}export{ks as IssuesPanel};
@@ -1 +1 @@
1
- import{useLunora as ee}from"@lunora/react";import{useState as Z,useReducer as ae,useEffect as le}from"react";import{c as ve,u as pe}from"../packem_shared/card-CIDGUN6K.js";import{E as Fe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as ye,d as he,m as X,p as Y,f as ke,u as Q}from"../packem_shared/table-DdJBrClo.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{f as z,b as H,k as Ke,c as ne}from"../packem_shared/internal-BSIsQVC6.js";import{u as B}from"../packem_shared/button-BkCrNcAs.js";import{f as de}from"../packem_shared/checkbox-StT4Gob6.js";import{u as re}from"../packem_shared/input-JHu63lTv.js";import{g as se,c as ie,N as oe,v as ce}from"../packem_shared/studio-CPuoAmjh.js";import{c as te}from"react/compiler-runtime";import{p as G}from"../packem_shared/label-6uP1obNF.js";import{l as be}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as Ee,y as Ve,k as Me,_ as Te,w as Ie}from"../packem_shared/select-Bul-DeII.js";import{jsx as r,jsxs as $,Fragment as fe}from"react/jsx-runtime";import{g as Oe}from"../packem_shared/badge-BbuuAio7.js";const _e=l=>{const e=l.trim();if(e==="")return;const d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},Je=l=>l===void 0?"—":new Date(l*1e3).toISOString(),De=l=>new TextEncoder().encode(l).length,ge=l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},xe=l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},Ne=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],ue=(l,e)=>{const d=l.trim();if(d==="")return"";const c=Number(d),s=Ne.find(m=>m.key===e)?.seconds??1;return Number.isFinite(c)&&c>0?String(Math.round(c*s)):d},Ce=l=>{const e=l.trim();if(e==="")return!0;const d=Number(e);return Number.isInteger(d)&&d>=60},we=(l,e,d,c)=>{const s=_e(l.ttl);return{expiration:s===void 0?c:void 0,expirationTtl:s,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:d,value:l.value}},$e=l=>{const e=te(60),{helper:d,id:c,invalid:s,onChange:m,testId:i}=l,t=q(),[a,v]=Z(""),[o,g]=Z("seconds");let b;e[0]!==m||e[1]!==o?(b=f=>{v(f.target.value),m(ue(f.target.value,o))},e[0]=m,e[1]=o,e[2]=b):b=e[2];const I=b;let E;e[3]!==a||e[4]!==m?(E=f=>{f!==null&&(g(f),m(ue(a,f)))},e[3]=a,e[4]=m,e[5]=E):E=e[5];const O=E;let p;e[6]!==t?(p=t("days"),e[6]=t,e[7]=p):p=e[7];let u;e[8]!==t?(u=t("hours"),e[8]=t,e[9]=u):u=e[9];let y;e[10]!==t?(y=t("minutes"),e[10]=t,e[11]=y):y=e[11];let x;e[12]!==t?(x=t("seconds"),e[12]=t,e[13]=x):x=e[13];let N;e[14]!==p||e[15]!==u||e[16]!==y||e[17]!==x?(N={days:p,hours:u,minutes:y,seconds:x},e[14]=p,e[15]=u,e[16]=y,e[17]=x,e[18]=N):N=e[18];const C=N;let k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==c||e[22]!==k?(w=r(G,{className:"text-xs",htmlFor:c,children:k}),e[21]=c,e[22]=k,e[23]=w):w=e[23];let K;e[24]!==t?(K=t("No expiration"),e[24]=t,e[25]=K):K=e[25];let J;e[26]!==a||e[27]!==c||e[28]!==s||e[29]!==I||e[30]!==K||e[31]!==i?(J=r(re,{"aria-invalid":s,className:"flex-1","data-testid":i,id:c,inputMode:"numeric",onChange:I,placeholder:K,value:a}),e[26]=a,e[27]=c,e[28]=s,e[29]=I,e[30]=K,e[31]=i,e[32]=J):J=e[32];let V;e[33]!==t?(V=t("TTL unit"),e[33]=t,e[34]=V):V=e[34];const L=`${i}-unit`;let D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=r(Ee,{}),e[35]=D):D=e[35];let M;e[36]!==V||e[37]!==L?(M=r(Ve,{"aria-label":V,className:"w-[7.5rem]","data-testid":L,children:D}),e[36]=V,e[37]=L,e[38]=M):M=e[38];let n;e[39]!==C?(n=Ne.map(f=>r(Me,{value:f.key,children:C[f.key]},f.key)),e[39]=C,e[40]=n):n=e[40];let h;e[41]!==n?(h=r(Te,{children:n}),e[41]=n,e[42]=h):h=e[42];let S;e[43]!==O||e[44]!==M||e[45]!==h||e[46]!==o?(S=$(Ie,{onValueChange:O,value:o,children:[M,h]}),e[43]=O,e[44]=M,e[45]=h,e[46]=o,e[47]=S):S=e[47];let T;e[48]!==J||e[49]!==S?(T=$("div",{className:"flex gap-2",children:[J,S]}),e[48]=J,e[49]=S,e[50]=T):T=e[50];let F;e[51]!==d||e[52]!==s||e[53]!==t||e[54]!==i?(F=s?r("p",{className:"text-xs text-destructive","data-testid":`${i}-invalid`,children:t("TTL must be at least 60 seconds.")}):d!==void 0&&r("p",{className:"text-xs text-muted-foreground",children:d}),e[51]=d,e[52]=s,e[53]=t,e[54]=i,e[55]=F):F=e[55];let _;return e[56]!==T||e[57]!==F||e[58]!==w?(_=$("div",{className:"mb-3 grid gap-1",children:[w,T,F]}),e[56]=T,e[57]=F,e[58]=w,e[59]=_):_=e[59],_},Se=l=>{const e=te(36),{id:d,invalidTestId:c,onChange:s,testId:m,valid:i,value:t}=l,a=q();let v;e[0]!==t?(v=ge(t),e[0]=t,e[1]=v):v=e[1];const o=v;let g;e[2]!==a?(g=a("Metadata (JSON)"),e[2]=a,e[3]=g):g=e[3];let b;e[4]!==d||e[5]!==g?(b=r(G,{className:"text-xs",htmlFor:d,children:g}),e[4]=d,e[5]=g,e[6]=b):b=e[6];const I=`${m}-format`,E=o===void 0;let O;e[7]!==o||e[8]!==s?(O=()=>{o!==void 0&&s(o)},e[7]=o,e[8]=s,e[9]=O):O=e[9];let p;e[10]!==a?(p=a("Format JSON"),e[10]=a,e[11]=p):p=e[11];let u;e[12]!==I||e[13]!==E||e[14]!==O||e[15]!==p?(u=r(B,{"data-testid":I,disabled:E,onClick:O,size:"sm",variant:"outline",children:p}),e[12]=I,e[13]=E,e[14]=O,e[15]=p,e[16]=u):u=e[16];let y;e[17]!==b||e[18]!==u?(y=$("div",{className:"flex items-center justify-between gap-2",children:[b,u]}),e[17]=b,e[18]=u,e[19]=y):y=e[19];const x=!i;let N;e[20]!==s?(N=K=>{s(K.target.value)},e[20]=s,e[21]=N):N=e[21];let C;e[22]!==d||e[23]!==x||e[24]!==N||e[25]!==m||e[26]!==t?(C=r(be,{"aria-invalid":x,className:"min-h-[4rem] font-mono text-xs","data-testid":m,id:d,onChange:N,value:t}),e[22]=d,e[23]=x,e[24]=N,e[25]=m,e[26]=t,e[27]=C):C=e[27];let k;e[28]!==c||e[29]!==a||e[30]!==i?(k=!i&&r("p",{className:"text-xs text-destructive","data-testid":c,children:a("Metadata must be valid JSON.")}),e[28]=c,e[29]=a,e[30]=i,e[31]=k):k=e[31];let w;return e[32]!==C||e[33]!==k||e[34]!==y?(w=$("div",{className:"mb-3 grid gap-1",children:[y,C,k]}),e[32]=C,e[33]=k,e[34]=y,e[35]=w):w=e[35],w},Le={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Be=(l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},Pe=l=>{const e=te(73),{namespace:d,onCancel:c,onCreated:s}=l,m=ee(),i=q(),[t,a]=ae(Be,Le);let v;e[0]!==t.metadata?(v=xe(t.metadata),e[0]=t.metadata,e[1]=v):v=e[1];const o=v;let g;e[2]!==t.ttl?(g=Ce(t.ttl),e[2]=t.ttl,e[3]=g):g=e[3];const b=g;let I;e[4]!==o||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(I=t.name.trim()!==""&&o&&b&&!t.busy,e[4]=o,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=I):I=e[8];const E=I;let O;e[9]!==E||e[10]!==m||e[11]!==d||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(O=()=>{E&&(a({type:"submitStart"}),z((async()=>{try{await m.putKvValue(we({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),s()}catch(j){a({error:H(j),type:"submitFailed"})}})()))},e[9]=E,e[10]=m,e[11]=d,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=O):O=e[17];const p=O;let u;e[18]!==i?(u=i("Key name"),e[18]=i,e[19]=u):u=e[19];let y;e[20]!==u?(y=r(G,{className:"text-xs",htmlFor:"kv-create-name",children:u}),e[20]=u,e[21]=y):y=e[21];let x;e[22]===Symbol.for("react.memo_cache_sentinel")?(x=j=>{a({field:"name",type:"setField",value:j.target.value})},e[22]=x):x=e[22];let N;e[23]!==i?(N=i("Key name"),e[23]=i,e[24]=N):N=e[24];let C;e[25]!==t.name||e[26]!==N?(C=r(re,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:x,placeholder:N,value:t.name}),e[25]=t.name,e[26]=N,e[27]=C):C=e[27];let k;e[28]!==y||e[29]!==C?(k=$("div",{className:"grid gap-1",children:[y,C]}),e[28]=y,e[29]=C,e[30]=k):k=e[30];let w;e[31]!==i?(w=i("Value"),e[31]=i,e[32]=w):w=e[32];let K;e[33]!==w?(K=r(G,{className:"text-xs",htmlFor:"kv-create-value",children:w}),e[33]=w,e[34]=K):K=e[34];let J;e[35]===Symbol.for("react.memo_cache_sentinel")?(J=j=>{a({field:"value",type:"setField",value:j.target.value})},e[35]=J):J=e[35];let V;e[36]!==t.value?(V=r(be,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:J,value:t.value}),e[36]=t.value,e[37]=V):V=e[37];let L;e[38]!==K||e[39]!==V?(L=$("div",{className:"grid gap-1",children:[K,V]}),e[38]=K,e[39]=V,e[40]=L):L=e[40];const D=!b;let M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=j=>{a({field:"ttl",type:"setField",value:j})},e[41]=M):M=e[41];let n;e[42]!==D?(n=r($e,{id:"kv-create-ttl",invalid:D,onChange:M,testId:"kv-create-ttl"}),e[42]=D,e[43]=n):n=e[43];let h;e[44]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{a({field:"metadata",type:"setField",value:j})},e[44]=h):h=e[44];let S;e[45]!==o||e[46]!==t.metadata?(S=r(Se,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:h,testId:"kv-create-metadata",valid:o,value:t.metadata}),e[45]=o,e[46]=t.metadata,e[47]=S):S=e[47];const T=!E;let F;e[48]!==t.busy||e[49]!==i?(F=t.busy?i("Creating…"):i("Create key"),e[48]=t.busy,e[49]=i,e[50]=F):F=e[50];let _;e[51]!==p||e[52]!==T||e[53]!==F?(_=r(B,{"data-testid":"kv-create-submit",disabled:T,onClick:p,children:F}),e[51]=p,e[52]=T,e[53]=F,e[54]=_):_=e[54];const f=t.busy;let P;e[55]!==i?(P=i("Cancel"),e[55]=i,e[56]=P):P=e[56];let A;e[57]!==c||e[58]!==t.busy||e[59]!==P?(A=r(B,{"data-testid":"kv-create-cancel",disabled:f,onClick:c,variant:"outline",children:P}),e[57]=c,e[58]=t.busy,e[59]=P,e[60]=A):A=e[60];let R;e[61]!==_||e[62]!==A?(R=$("div",{className:"flex flex-wrap gap-2",children:[_,A]}),e[61]=_,e[62]=A,e[63]=R):R=e[63];let U;e[64]!==t.error?(U=t.error!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=U):U=e[65];let W;return e[66]!==k||e[67]!==L||e[68]!==n||e[69]!==S||e[70]!==R||e[71]!==U?(W=$("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,L,n,S,R,U]}),e[66]=k,e[67]=L,e[68]=n,e[69]=S,e[70]=R,e[71]=U,e[72]=W):W=e[72],W},je={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Ae=(l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},ze=l=>{const e=te(67),{expiration:d,keyName:c,namespace:s,onDeleted:m}=l,i=ee(),t=q(),[a,v]=ae(Ae,je);let o,g;e[0]!==i||e[1]!==c||e[2]!==s?(o=()=>{const f={cancelled:!1};return z((async()=>{try{const P=await i.getKvValue({key:c,namespace:s});f.cancelled||v({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){const A=P;f.cancelled||v({error:H(A),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},g=[i,s,c],e[0]=i,e[1]=c,e[2]=s,e[3]=o,e[4]=g):(o=e[3],g=e[4]),le(o,g);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=f=>{v({type:"editValue",value:f.target.value})},e[5]=b):b=e[5];const I=b;let E;e[6]===Symbol.for("react.memo_cache_sentinel")?(E=f=>{v({type:"editMetadata",value:f})},e[6]=E):E=e[6];const O=E;let p;e[7]!==a.editedValue?(p=ge(a.editedValue),e[7]=a.editedValue,e[8]=p):p=e[8];const u=p;let y;e[9]!==a.editedMetadata?(y=xe(a.editedMetadata),e[9]=a.editedMetadata,e[10]=y):y=e[10];const x=y;let N;e[11]!==a.editedTtl?(N=Ce(a.editedTtl),e[11]=a.editedTtl,e[12]=N):N=e[12];const C=N;let k;e[13]!==u?(k=()=>{u!==void 0&&v({type:"editValue",value:u})},e[13]=u,e[14]=k):k=e[14];const w=k;let K;e[15]!==i||e[16]!==d||e[17]!==c||e[18]!==x||e[19]!==s||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(K=()=>{if(!x){v({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}v({type:"saveStart"}),z((async()=>{try{await i.putKvValue(we({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},c,s,d)),v({type:"saveOk"})}catch(f){v({error:H(f),type:"writeFailed"})}})())},e[15]=i,e[16]=d,e[17]=c,e[18]=x,e[19]=s,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=K):K=e[24];const J=K;let V;e[25]!==i||e[26]!==c||e[27]!==s||e[28]!==m?(V=()=>{v({type:"deleteStart"}),z((async()=>{try{await i.deleteKvKey({key:c,namespace:s}),m(c)}catch(f){v({error:H(f),type:"writeFailed"})}})())},e[25]=i,e[26]=c,e[27]=s,e[28]=m,e[29]=V):V=e[29];const L=V;let D;e[30]!==c?(D=()=>{ne(c)},e[30]=c,e[31]=D):D=e[31];let M;e[32]!==t?(M=t("Copy key"),e[32]=t,e[33]=M):M=e[33];let n;e[34]!==D||e[35]!==M?(n=r("div",{className:"mb-2 flex justify-end",children:r(B,{"data-testid":"kv-copy-key-btn",onClick:D,size:"sm",variant:"outline",children:M})}),e[34]=D,e[35]=M,e[36]=n):n=e[36];let h;e[37]!==a.loadError?(h=a.loadError!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError}),e[37]=a.loadError,e[38]=h):h=e[38];let S;e[39]!==a.loading||e[40]!==t?(S=a.loading&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading…")}),e[39]=a.loading,e[40]=t,e[41]=S):S=e[41];let T;e[42]!==u||e[43]!==x||e[44]!==L||e[45]!==w||e[46]!==J||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==C?(T=!a.loading&&a.value!==null&&$(fe,{children:[$("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[r(G,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),u!==void 0&&r(Oe,{variant:"secondary",children:t("JSON")}),r("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:Ke(De(a.editedValue))})]}),r("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:I,value:a.editedValue}),$("div",{className:"mb-3 flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-format-btn",disabled:u===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")}),r(B,{"data-testid":"kv-copy-value-btn",onClick:()=>{ne(a.editedValue)},size:"sm",variant:"outline",children:t("Copy value")})]}),r($e,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!C,onChange:f=>{v({type:"editTtl",value:f})},testId:"kv-ttl-input"}),r(Se,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:O,testId:"kv-metadata-editor",valid:x,value:a.editedMetadata}),$("div",{className:"flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!x||!C,onClick:J,children:a.busy==="saving"?t("Saving…"):t("Save")}),r(B,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:L,variant:"destructive",children:a.busy==="deleting"?t("Deleting…"):t("Delete")})]}),a.writeError!==null&&r("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError})]}),e[42]=u,e[43]=x,e[44]=L,e[45]=w,e[46]=J,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=C,e[55]=T):T=e[55];let F;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(F=!a.loading&&a.value===null&&a.loadError===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=F):F=e[60];let _;return e[61]!==n||e[62]!==h||e[63]!==S||e[64]!==T||e[65]!==F?(_=$("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[n,h,S,T,F]}),e[61]=n,e[62]=h,e[63]=S,e[64]=T,e[65]=F,e[66]=_):_=e[66],_},me=100,He={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=(l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{const d=new Set(e.deleted);return{...l,bulk:l.bulk.filter(c=>!d.has(c)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(c=>!d.has(c.name)),selectedKey:l.selectedKey!==null&&d.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(d=>d!==e.name),keys:l.keys===null?null:l.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(d=>d!==e.name):[...l.bulk,e.name]};default:return l}},Ue=({namespace:l})=>{const e=ee(),d=q(),[c,s]=ae(Re,He),{appliedPrefix:m,bulk:i,bulkBusy:t,bulkError:a,cursor:v,keys:o,listComplete:g,loadError:b,loading:I,prefixInput:E,reloadNonce:O,selectedKey:p}=c,[u,y]=Z(!1);le(()=>{const n={cancelled:!1};return z((async()=>{s({type:"loadStart"});try{const h=await e.listKvKeys({limit:me,namespace:l,prefix:m===""?void 0:m});n.cancelled||s({cursor:h.cursor??null,keys:h.keys,listComplete:h.listComplete,type:"firstPage"})}catch(h){n.cancelled||s({error:H(h),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,l,m,O]);const x=n=>{s({type:"prefixInput",value:n.target.value})},N=()=>{s({type:"applyFilter"})},C=n=>{s({name:n.currentTarget.dataset.key??null,type:"selectKey"})},k=()=>{v!==null&&(s({type:"loadStart"}),z((async()=>{try{const n=await e.listKvKeys({cursor:v,limit:me,namespace:l,prefix:m===""?void 0:m});s({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){s({error:H(n),type:"loadFailed"})}})()))},w=n=>{s({name:n,type:"keyDeleted"})},K=n=>{s({name:n,type:"toggleBulk"})},J=n=>{s({names:n&&o!==null?o.map(h=>h.name):[],type:"toggleAllBulk"})},V=()=>{if(i.length===0)return;const n=[...i];s({type:"bulkDeleteStart"}),z((async()=>{const h=await Promise.allSettled(n.map(F=>e.deleteKvKey({key:F,namespace:l}))),S=n.filter((F,_)=>h[_]?.status==="fulfilled"),T=n.length-S.length;s({deleted:S,error:T>0?d("Failed to delete {count} keys.",{count:T}):null,type:"bulkDeleted"})})())},L=()=>{y(!1),s({type:"reload"})},D=o!==null&&o.length>0&&i.length===o.length,M=new Set(i);return $(fe,{children:[$("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[$("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r(re,{"aria-label":d("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:x,placeholder:d("Filter by prefix…"),value:E}),r(B,{"data-testid":"kv-filter-btn",disabled:I,onClick:N,children:d("Filter")}),r(B,{"data-testid":"kv-new-key-btn",onClick:()=>{y(n=>!n)},variant:"outline",children:d("New key")}),i.length>0&&r(B,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:V,variant:"destructive",children:t?d("Deleting…"):d("Delete {count}",{count:i.length})})]}),a!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a}),b!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b}),o!==null&&o.length===0&&!I&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:d("No keys.")}),o!==null&&o.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-key-table",children:[r(he,{children:$(X,{children:[r(Y,{className:"w-10",children:r(de,{"aria-label":d("Select all"),checked:D,"data-testid":"kv-select-all",onCheckedChange:J})}),r(Y,{children:d("Key")}),r(Y,{children:d("Expiration")})]})}),r(ke,{children:o.map(n=>$(X,{className:n.name===p?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":n.name,"data-testid":`kv-key-row-${n.name}`,onClick:C,children:[r(Q,{onClick:h=>{h.stopPropagation()},children:r(de,{"aria-label":d("Select {name}",{name:n.name}),checked:M.has(n.name),"data-testid":`kv-select-${n.name}`,onCheckedChange:()=>{K(n.name)}})}),r(Q,{className:"font-mono text-xs",children:n.name}),r(Q,{className:"tabular-nums text-xs",children:Je(n.expiration)})]},n.name))})]})})}),!g&&v!==null&&r("div",{className:"mt-2",children:r(B,{"data-testid":"kv-load-more",disabled:I,onClick:k,variant:"outline",children:d(I?"Loading…":"Load more")})})]}),r(se,{onOpenChange:n=>{n||y(!1)},open:u,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[r(oe,{children:r(ce,{children:d("New key")})}),r(Pe,{namespace:l,onCancel:()=>{y(!1)},onCreated:L})]})}),r(se,{onOpenChange:n=>{n||s({name:null,type:"selectKey"})},open:p!==null,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[r(oe,{children:r(ce,{className:"truncate font-mono text-xs",children:p})}),p!==null&&r(ze,{expiration:o?.find(n=>n.name===p)?.expiration,keyName:p,namespace:l,onDeleted:w},`${l}:${p}`)]})})]})},ct=({loadNamespaces:l}={})=>{const e=ee(),d=q(),[c,s]=Z(null),[m,i]=Z(null),[t,a]=Z(null);le(()=>{const o={cancelled:!1};return z((async()=>{try{const g=await(l??(()=>e.listKvNamespaces()))();o.cancelled||(s(g),i(null),a(b=>b??g[0]?.binding??null))}catch(g){o.cancelled||(s(null),i(H(g)))}})()),()=>{o.cancelled=!0}},[e,l]);const v=o=>{a(o.currentTarget.dataset.ns??null)};return $("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[m!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:m}),c!==null&&c.length===0&&r(Fe,{description:d("Add a kv_namespaces binding to wrangler.jsonc — it appears here automatically, no wiring needed."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:d("No KV namespaces.")}),c!==null&&c.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-namespace-table",children:[r(he,{children:r(X,{children:r(Y,{children:d("Namespace")})})}),r(ke,{children:c.map(o=>r(X,{className:o.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":o.binding,"data-testid":`kv-ns-row-${o.binding}`,onClick:v,children:r(Q,{className:"font-mono text-xs",children:o.binding})},o.binding))})]})})}),t!==null&&r(Ue,{namespace:t},t)]})};export{ct as KvBrowser};
1
+ import{useLunora as ee}from"@lunora/react";import{useState as Z,useReducer as ae,useEffect as le}from"react";import{c as ve,u as pe}from"../packem_shared/card-CIDGUN6K.js";import{E as Fe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as ye,d as he,m as X,p as Y,f as ke,u as Q}from"../packem_shared/table-DdJBrClo.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{f as z,b as H,k as Ke,c as ne}from"../packem_shared/internal-BSIsQVC6.js";import{u as B}from"../packem_shared/button-BkCrNcAs.js";import{f as de}from"../packem_shared/checkbox-StT4Gob6.js";import{u as re}from"../packem_shared/input-JHu63lTv.js";import{g as se,c as ie,N as oe,v as ce}from"../packem_shared/studio-BtC7WPbz.js";import{c as te}from"react/compiler-runtime";import{p as G}from"../packem_shared/label-6uP1obNF.js";import{l as be}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as Ee,y as Ve,k as Me,_ as Te,w as Ie}from"../packem_shared/select-Bul-DeII.js";import{jsx as r,jsxs as $,Fragment as fe}from"react/jsx-runtime";import{g as Oe}from"../packem_shared/badge-BbuuAio7.js";const _e=l=>{const e=l.trim();if(e==="")return;const d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},Je=l=>l===void 0?"—":new Date(l*1e3).toISOString(),De=l=>new TextEncoder().encode(l).length,ge=l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},xe=l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},Ne=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],ue=(l,e)=>{const d=l.trim();if(d==="")return"";const c=Number(d),s=Ne.find(m=>m.key===e)?.seconds??1;return Number.isFinite(c)&&c>0?String(Math.round(c*s)):d},Ce=l=>{const e=l.trim();if(e==="")return!0;const d=Number(e);return Number.isInteger(d)&&d>=60},we=(l,e,d,c)=>{const s=_e(l.ttl);return{expiration:s===void 0?c:void 0,expirationTtl:s,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:d,value:l.value}},$e=l=>{const e=te(60),{helper:d,id:c,invalid:s,onChange:m,testId:i}=l,t=q(),[a,v]=Z(""),[o,g]=Z("seconds");let b;e[0]!==m||e[1]!==o?(b=f=>{v(f.target.value),m(ue(f.target.value,o))},e[0]=m,e[1]=o,e[2]=b):b=e[2];const I=b;let E;e[3]!==a||e[4]!==m?(E=f=>{f!==null&&(g(f),m(ue(a,f)))},e[3]=a,e[4]=m,e[5]=E):E=e[5];const O=E;let p;e[6]!==t?(p=t("days"),e[6]=t,e[7]=p):p=e[7];let u;e[8]!==t?(u=t("hours"),e[8]=t,e[9]=u):u=e[9];let y;e[10]!==t?(y=t("minutes"),e[10]=t,e[11]=y):y=e[11];let x;e[12]!==t?(x=t("seconds"),e[12]=t,e[13]=x):x=e[13];let N;e[14]!==p||e[15]!==u||e[16]!==y||e[17]!==x?(N={days:p,hours:u,minutes:y,seconds:x},e[14]=p,e[15]=u,e[16]=y,e[17]=x,e[18]=N):N=e[18];const C=N;let k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==c||e[22]!==k?(w=r(G,{className:"text-xs",htmlFor:c,children:k}),e[21]=c,e[22]=k,e[23]=w):w=e[23];let K;e[24]!==t?(K=t("No expiration"),e[24]=t,e[25]=K):K=e[25];let J;e[26]!==a||e[27]!==c||e[28]!==s||e[29]!==I||e[30]!==K||e[31]!==i?(J=r(re,{"aria-invalid":s,className:"flex-1","data-testid":i,id:c,inputMode:"numeric",onChange:I,placeholder:K,value:a}),e[26]=a,e[27]=c,e[28]=s,e[29]=I,e[30]=K,e[31]=i,e[32]=J):J=e[32];let V;e[33]!==t?(V=t("TTL unit"),e[33]=t,e[34]=V):V=e[34];const L=`${i}-unit`;let D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=r(Ee,{}),e[35]=D):D=e[35];let M;e[36]!==V||e[37]!==L?(M=r(Ve,{"aria-label":V,className:"w-[7.5rem]","data-testid":L,children:D}),e[36]=V,e[37]=L,e[38]=M):M=e[38];let n;e[39]!==C?(n=Ne.map(f=>r(Me,{value:f.key,children:C[f.key]},f.key)),e[39]=C,e[40]=n):n=e[40];let h;e[41]!==n?(h=r(Te,{children:n}),e[41]=n,e[42]=h):h=e[42];let S;e[43]!==O||e[44]!==M||e[45]!==h||e[46]!==o?(S=$(Ie,{onValueChange:O,value:o,children:[M,h]}),e[43]=O,e[44]=M,e[45]=h,e[46]=o,e[47]=S):S=e[47];let T;e[48]!==J||e[49]!==S?(T=$("div",{className:"flex gap-2",children:[J,S]}),e[48]=J,e[49]=S,e[50]=T):T=e[50];let F;e[51]!==d||e[52]!==s||e[53]!==t||e[54]!==i?(F=s?r("p",{className:"text-xs text-destructive","data-testid":`${i}-invalid`,children:t("TTL must be at least 60 seconds.")}):d!==void 0&&r("p",{className:"text-xs text-muted-foreground",children:d}),e[51]=d,e[52]=s,e[53]=t,e[54]=i,e[55]=F):F=e[55];let _;return e[56]!==T||e[57]!==F||e[58]!==w?(_=$("div",{className:"mb-3 grid gap-1",children:[w,T,F]}),e[56]=T,e[57]=F,e[58]=w,e[59]=_):_=e[59],_},Se=l=>{const e=te(36),{id:d,invalidTestId:c,onChange:s,testId:m,valid:i,value:t}=l,a=q();let v;e[0]!==t?(v=ge(t),e[0]=t,e[1]=v):v=e[1];const o=v;let g;e[2]!==a?(g=a("Metadata (JSON)"),e[2]=a,e[3]=g):g=e[3];let b;e[4]!==d||e[5]!==g?(b=r(G,{className:"text-xs",htmlFor:d,children:g}),e[4]=d,e[5]=g,e[6]=b):b=e[6];const I=`${m}-format`,E=o===void 0;let O;e[7]!==o||e[8]!==s?(O=()=>{o!==void 0&&s(o)},e[7]=o,e[8]=s,e[9]=O):O=e[9];let p;e[10]!==a?(p=a("Format JSON"),e[10]=a,e[11]=p):p=e[11];let u;e[12]!==I||e[13]!==E||e[14]!==O||e[15]!==p?(u=r(B,{"data-testid":I,disabled:E,onClick:O,size:"sm",variant:"outline",children:p}),e[12]=I,e[13]=E,e[14]=O,e[15]=p,e[16]=u):u=e[16];let y;e[17]!==b||e[18]!==u?(y=$("div",{className:"flex items-center justify-between gap-2",children:[b,u]}),e[17]=b,e[18]=u,e[19]=y):y=e[19];const x=!i;let N;e[20]!==s?(N=K=>{s(K.target.value)},e[20]=s,e[21]=N):N=e[21];let C;e[22]!==d||e[23]!==x||e[24]!==N||e[25]!==m||e[26]!==t?(C=r(be,{"aria-invalid":x,className:"min-h-[4rem] font-mono text-xs","data-testid":m,id:d,onChange:N,value:t}),e[22]=d,e[23]=x,e[24]=N,e[25]=m,e[26]=t,e[27]=C):C=e[27];let k;e[28]!==c||e[29]!==a||e[30]!==i?(k=!i&&r("p",{className:"text-xs text-destructive","data-testid":c,children:a("Metadata must be valid JSON.")}),e[28]=c,e[29]=a,e[30]=i,e[31]=k):k=e[31];let w;return e[32]!==C||e[33]!==k||e[34]!==y?(w=$("div",{className:"mb-3 grid gap-1",children:[y,C,k]}),e[32]=C,e[33]=k,e[34]=y,e[35]=w):w=e[35],w},Le={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Be=(l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},Pe=l=>{const e=te(73),{namespace:d,onCancel:c,onCreated:s}=l,m=ee(),i=q(),[t,a]=ae(Be,Le);let v;e[0]!==t.metadata?(v=xe(t.metadata),e[0]=t.metadata,e[1]=v):v=e[1];const o=v;let g;e[2]!==t.ttl?(g=Ce(t.ttl),e[2]=t.ttl,e[3]=g):g=e[3];const b=g;let I;e[4]!==o||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(I=t.name.trim()!==""&&o&&b&&!t.busy,e[4]=o,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=I):I=e[8];const E=I;let O;e[9]!==E||e[10]!==m||e[11]!==d||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(O=()=>{E&&(a({type:"submitStart"}),z((async()=>{try{await m.putKvValue(we({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),s()}catch(j){a({error:H(j),type:"submitFailed"})}})()))},e[9]=E,e[10]=m,e[11]=d,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=O):O=e[17];const p=O;let u;e[18]!==i?(u=i("Key name"),e[18]=i,e[19]=u):u=e[19];let y;e[20]!==u?(y=r(G,{className:"text-xs",htmlFor:"kv-create-name",children:u}),e[20]=u,e[21]=y):y=e[21];let x;e[22]===Symbol.for("react.memo_cache_sentinel")?(x=j=>{a({field:"name",type:"setField",value:j.target.value})},e[22]=x):x=e[22];let N;e[23]!==i?(N=i("Key name"),e[23]=i,e[24]=N):N=e[24];let C;e[25]!==t.name||e[26]!==N?(C=r(re,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:x,placeholder:N,value:t.name}),e[25]=t.name,e[26]=N,e[27]=C):C=e[27];let k;e[28]!==y||e[29]!==C?(k=$("div",{className:"grid gap-1",children:[y,C]}),e[28]=y,e[29]=C,e[30]=k):k=e[30];let w;e[31]!==i?(w=i("Value"),e[31]=i,e[32]=w):w=e[32];let K;e[33]!==w?(K=r(G,{className:"text-xs",htmlFor:"kv-create-value",children:w}),e[33]=w,e[34]=K):K=e[34];let J;e[35]===Symbol.for("react.memo_cache_sentinel")?(J=j=>{a({field:"value",type:"setField",value:j.target.value})},e[35]=J):J=e[35];let V;e[36]!==t.value?(V=r(be,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:J,value:t.value}),e[36]=t.value,e[37]=V):V=e[37];let L;e[38]!==K||e[39]!==V?(L=$("div",{className:"grid gap-1",children:[K,V]}),e[38]=K,e[39]=V,e[40]=L):L=e[40];const D=!b;let M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=j=>{a({field:"ttl",type:"setField",value:j})},e[41]=M):M=e[41];let n;e[42]!==D?(n=r($e,{id:"kv-create-ttl",invalid:D,onChange:M,testId:"kv-create-ttl"}),e[42]=D,e[43]=n):n=e[43];let h;e[44]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{a({field:"metadata",type:"setField",value:j})},e[44]=h):h=e[44];let S;e[45]!==o||e[46]!==t.metadata?(S=r(Se,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:h,testId:"kv-create-metadata",valid:o,value:t.metadata}),e[45]=o,e[46]=t.metadata,e[47]=S):S=e[47];const T=!E;let F;e[48]!==t.busy||e[49]!==i?(F=t.busy?i("Creating…"):i("Create key"),e[48]=t.busy,e[49]=i,e[50]=F):F=e[50];let _;e[51]!==p||e[52]!==T||e[53]!==F?(_=r(B,{"data-testid":"kv-create-submit",disabled:T,onClick:p,children:F}),e[51]=p,e[52]=T,e[53]=F,e[54]=_):_=e[54];const f=t.busy;let P;e[55]!==i?(P=i("Cancel"),e[55]=i,e[56]=P):P=e[56];let A;e[57]!==c||e[58]!==t.busy||e[59]!==P?(A=r(B,{"data-testid":"kv-create-cancel",disabled:f,onClick:c,variant:"outline",children:P}),e[57]=c,e[58]=t.busy,e[59]=P,e[60]=A):A=e[60];let R;e[61]!==_||e[62]!==A?(R=$("div",{className:"flex flex-wrap gap-2",children:[_,A]}),e[61]=_,e[62]=A,e[63]=R):R=e[63];let U;e[64]!==t.error?(U=t.error!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=U):U=e[65];let W;return e[66]!==k||e[67]!==L||e[68]!==n||e[69]!==S||e[70]!==R||e[71]!==U?(W=$("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,L,n,S,R,U]}),e[66]=k,e[67]=L,e[68]=n,e[69]=S,e[70]=R,e[71]=U,e[72]=W):W=e[72],W},je={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Ae=(l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},ze=l=>{const e=te(67),{expiration:d,keyName:c,namespace:s,onDeleted:m}=l,i=ee(),t=q(),[a,v]=ae(Ae,je);let o,g;e[0]!==i||e[1]!==c||e[2]!==s?(o=()=>{const f={cancelled:!1};return z((async()=>{try{const P=await i.getKvValue({key:c,namespace:s});f.cancelled||v({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){const A=P;f.cancelled||v({error:H(A),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},g=[i,s,c],e[0]=i,e[1]=c,e[2]=s,e[3]=o,e[4]=g):(o=e[3],g=e[4]),le(o,g);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=f=>{v({type:"editValue",value:f.target.value})},e[5]=b):b=e[5];const I=b;let E;e[6]===Symbol.for("react.memo_cache_sentinel")?(E=f=>{v({type:"editMetadata",value:f})},e[6]=E):E=e[6];const O=E;let p;e[7]!==a.editedValue?(p=ge(a.editedValue),e[7]=a.editedValue,e[8]=p):p=e[8];const u=p;let y;e[9]!==a.editedMetadata?(y=xe(a.editedMetadata),e[9]=a.editedMetadata,e[10]=y):y=e[10];const x=y;let N;e[11]!==a.editedTtl?(N=Ce(a.editedTtl),e[11]=a.editedTtl,e[12]=N):N=e[12];const C=N;let k;e[13]!==u?(k=()=>{u!==void 0&&v({type:"editValue",value:u})},e[13]=u,e[14]=k):k=e[14];const w=k;let K;e[15]!==i||e[16]!==d||e[17]!==c||e[18]!==x||e[19]!==s||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(K=()=>{if(!x){v({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}v({type:"saveStart"}),z((async()=>{try{await i.putKvValue(we({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},c,s,d)),v({type:"saveOk"})}catch(f){v({error:H(f),type:"writeFailed"})}})())},e[15]=i,e[16]=d,e[17]=c,e[18]=x,e[19]=s,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=K):K=e[24];const J=K;let V;e[25]!==i||e[26]!==c||e[27]!==s||e[28]!==m?(V=()=>{v({type:"deleteStart"}),z((async()=>{try{await i.deleteKvKey({key:c,namespace:s}),m(c)}catch(f){v({error:H(f),type:"writeFailed"})}})())},e[25]=i,e[26]=c,e[27]=s,e[28]=m,e[29]=V):V=e[29];const L=V;let D;e[30]!==c?(D=()=>{ne(c)},e[30]=c,e[31]=D):D=e[31];let M;e[32]!==t?(M=t("Copy key"),e[32]=t,e[33]=M):M=e[33];let n;e[34]!==D||e[35]!==M?(n=r("div",{className:"mb-2 flex justify-end",children:r(B,{"data-testid":"kv-copy-key-btn",onClick:D,size:"sm",variant:"outline",children:M})}),e[34]=D,e[35]=M,e[36]=n):n=e[36];let h;e[37]!==a.loadError?(h=a.loadError!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError}),e[37]=a.loadError,e[38]=h):h=e[38];let S;e[39]!==a.loading||e[40]!==t?(S=a.loading&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading…")}),e[39]=a.loading,e[40]=t,e[41]=S):S=e[41];let T;e[42]!==u||e[43]!==x||e[44]!==L||e[45]!==w||e[46]!==J||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==C?(T=!a.loading&&a.value!==null&&$(fe,{children:[$("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[r(G,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),u!==void 0&&r(Oe,{variant:"secondary",children:t("JSON")}),r("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:Ke(De(a.editedValue))})]}),r("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:I,value:a.editedValue}),$("div",{className:"mb-3 flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-format-btn",disabled:u===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")}),r(B,{"data-testid":"kv-copy-value-btn",onClick:()=>{ne(a.editedValue)},size:"sm",variant:"outline",children:t("Copy value")})]}),r($e,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!C,onChange:f=>{v({type:"editTtl",value:f})},testId:"kv-ttl-input"}),r(Se,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:O,testId:"kv-metadata-editor",valid:x,value:a.editedMetadata}),$("div",{className:"flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!x||!C,onClick:J,children:a.busy==="saving"?t("Saving…"):t("Save")}),r(B,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:L,variant:"destructive",children:a.busy==="deleting"?t("Deleting…"):t("Delete")})]}),a.writeError!==null&&r("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError})]}),e[42]=u,e[43]=x,e[44]=L,e[45]=w,e[46]=J,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=C,e[55]=T):T=e[55];let F;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(F=!a.loading&&a.value===null&&a.loadError===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=F):F=e[60];let _;return e[61]!==n||e[62]!==h||e[63]!==S||e[64]!==T||e[65]!==F?(_=$("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[n,h,S,T,F]}),e[61]=n,e[62]=h,e[63]=S,e[64]=T,e[65]=F,e[66]=_):_=e[66],_},me=100,He={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=(l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{const d=new Set(e.deleted);return{...l,bulk:l.bulk.filter(c=>!d.has(c)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(c=>!d.has(c.name)),selectedKey:l.selectedKey!==null&&d.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(d=>d!==e.name),keys:l.keys===null?null:l.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(d=>d!==e.name):[...l.bulk,e.name]};default:return l}},Ue=({namespace:l})=>{const e=ee(),d=q(),[c,s]=ae(Re,He),{appliedPrefix:m,bulk:i,bulkBusy:t,bulkError:a,cursor:v,keys:o,listComplete:g,loadError:b,loading:I,prefixInput:E,reloadNonce:O,selectedKey:p}=c,[u,y]=Z(!1);le(()=>{const n={cancelled:!1};return z((async()=>{s({type:"loadStart"});try{const h=await e.listKvKeys({limit:me,namespace:l,prefix:m===""?void 0:m});n.cancelled||s({cursor:h.cursor??null,keys:h.keys,listComplete:h.listComplete,type:"firstPage"})}catch(h){n.cancelled||s({error:H(h),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,l,m,O]);const x=n=>{s({type:"prefixInput",value:n.target.value})},N=()=>{s({type:"applyFilter"})},C=n=>{s({name:n.currentTarget.dataset.key??null,type:"selectKey"})},k=()=>{v!==null&&(s({type:"loadStart"}),z((async()=>{try{const n=await e.listKvKeys({cursor:v,limit:me,namespace:l,prefix:m===""?void 0:m});s({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){s({error:H(n),type:"loadFailed"})}})()))},w=n=>{s({name:n,type:"keyDeleted"})},K=n=>{s({name:n,type:"toggleBulk"})},J=n=>{s({names:n&&o!==null?o.map(h=>h.name):[],type:"toggleAllBulk"})},V=()=>{if(i.length===0)return;const n=[...i];s({type:"bulkDeleteStart"}),z((async()=>{const h=await Promise.allSettled(n.map(F=>e.deleteKvKey({key:F,namespace:l}))),S=n.filter((F,_)=>h[_]?.status==="fulfilled"),T=n.length-S.length;s({deleted:S,error:T>0?d("Failed to delete {count} keys.",{count:T}):null,type:"bulkDeleted"})})())},L=()=>{y(!1),s({type:"reload"})},D=o!==null&&o.length>0&&i.length===o.length,M=new Set(i);return $(fe,{children:[$("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[$("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r(re,{"aria-label":d("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:x,placeholder:d("Filter by prefix…"),value:E}),r(B,{"data-testid":"kv-filter-btn",disabled:I,onClick:N,children:d("Filter")}),r(B,{"data-testid":"kv-new-key-btn",onClick:()=>{y(n=>!n)},variant:"outline",children:d("New key")}),i.length>0&&r(B,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:V,variant:"destructive",children:t?d("Deleting…"):d("Delete {count}",{count:i.length})})]}),a!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a}),b!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b}),o!==null&&o.length===0&&!I&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:d("No keys.")}),o!==null&&o.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-key-table",children:[r(he,{children:$(X,{children:[r(Y,{className:"w-10",children:r(de,{"aria-label":d("Select all"),checked:D,"data-testid":"kv-select-all",onCheckedChange:J})}),r(Y,{children:d("Key")}),r(Y,{children:d("Expiration")})]})}),r(ke,{children:o.map(n=>$(X,{className:n.name===p?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":n.name,"data-testid":`kv-key-row-${n.name}`,onClick:C,children:[r(Q,{onClick:h=>{h.stopPropagation()},children:r(de,{"aria-label":d("Select {name}",{name:n.name}),checked:M.has(n.name),"data-testid":`kv-select-${n.name}`,onCheckedChange:()=>{K(n.name)}})}),r(Q,{className:"font-mono text-xs",children:n.name}),r(Q,{className:"tabular-nums text-xs",children:Je(n.expiration)})]},n.name))})]})})}),!g&&v!==null&&r("div",{className:"mt-2",children:r(B,{"data-testid":"kv-load-more",disabled:I,onClick:k,variant:"outline",children:d(I?"Loading…":"Load more")})})]}),r(se,{onOpenChange:n=>{n||y(!1)},open:u,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[r(oe,{children:r(ce,{children:d("New key")})}),r(Pe,{namespace:l,onCancel:()=>{y(!1)},onCreated:L})]})}),r(se,{onOpenChange:n=>{n||s({name:null,type:"selectKey"})},open:p!==null,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[r(oe,{children:r(ce,{className:"truncate font-mono text-xs",children:p})}),p!==null&&r(ze,{expiration:o?.find(n=>n.name===p)?.expiration,keyName:p,namespace:l,onDeleted:w},`${l}:${p}`)]})})]})},ct=({loadNamespaces:l}={})=>{const e=ee(),d=q(),[c,s]=Z(null),[m,i]=Z(null),[t,a]=Z(null);le(()=>{const o={cancelled:!1};return z((async()=>{try{const g=await(l??(()=>e.listKvNamespaces()))();o.cancelled||(s(g),i(null),a(b=>b??g[0]?.binding??null))}catch(g){o.cancelled||(s(null),i(H(g)))}})()),()=>{o.cancelled=!0}},[e,l]);const v=o=>{a(o.currentTarget.dataset.ns??null)};return $("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[m!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:m}),c!==null&&c.length===0&&r(Fe,{description:d("Add a kv_namespaces binding to wrangler.jsonc — it appears here automatically, no wiring needed."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:d("No KV namespaces.")}),c!==null&&c.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-namespace-table",children:[r(he,{children:r(X,{children:r(Y,{children:d("Namespace")})})}),r(ke,{children:c.map(o=>r(X,{className:o.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":o.binding,"data-testid":`kv-ns-row-${o.binding}`,onClick:v,children:r(Q,{className:"font-mono text-xs",children:o.binding})},o.binding))})]})})}),t!==null&&r(Ue,{namespace:t},t)]})};export{ct as KvBrowser};
@@ -1 +1 @@
1
- import{c as w}from"react/compiler-runtime";import{useMemo as O,useState as D}from"react";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as N}from"../packem_shared/utils-bhneXptQ.js";import{MigrationsPanel as E}from"../packem_shared/MigrationsPanel-2JbQ2HwG.js";import{useNavigate as J,useSearch as P}from"@tanstack/react-router";import{E as H}from"../packem_shared/error-alert-t6cpEi0z.js";import{E as U}from"../packem_shared/empty-state-Cg7t_8qu.js";import{N as S}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{i as V,f as W}from"../packem_shared/internal-BSIsQVC6.js";import{S as _}from"../packem_shared/schema-diagram-cg-bz_VL.js";import{jsx as l,jsxs as g}from"react/jsx-runtime";const k=t=>typeof t=="object"&&t!==null,z=t=>k(t)&&k(t.fields)&&k(t.indexes)&&k(t.relations)&&typeof t.shardMode=="string",B=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(a){return{error:`baseline is not valid JSON: ${a instanceof Error?a.message:String(a)}`,status:"invalid"}}if(!k(e)||e.version!==1||!k(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(const[a,n]of Object.entries(e.tables))if(!z(n))return{error:`baseline table "${a}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},L=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((a,n)=>a===e.fields[n]),Q=(t,e,a,n)=>{const s=[];return a.kind!==n.kind&&s.push({severity:"breaking",summary:`field ${t}.${e} changed type: ${a.kind} → ${n.kind} — add a data migration to convert existing values`,table:t,scope:"table",type:"changedFieldKind"}),a.optional&&!n.optional?s.push({severity:"breaking",summary:`field ${t}.${e} became required — rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!a.optional&&n.optional&&s.push({scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),s},G=(t,e,a)=>a.optional?{scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${t}.${e} — existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},X=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.fields)){const i=e.fields[s];i===void 0?n.push(G(t,s,o)):n.push(...Q(t,s,i,o))}for(const s of Object.keys(e.fields))a.fields[s]===void 0&&n.push({severity:"breaking",summary:`removed field ${t}.${s} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},Y=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.indexes)){const i=e.indexes[s];if(i===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${s} on ${t}`,table:t,type:"addedIndex"});continue}L(i,o)||n.push({severity:"breaking",summary:`index ${s} on ${t} changed shape — a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(const s of Object.keys(e.indexes))a.indexes[s]===void 0&&n.push({severity:"breaking",summary:`removed index ${s} on ${t} — a query that used \`.withIndex("${s}")\` would break`,table:t,scope:"table",type:"removedIndex"})},Z=(t,e,a,n)=>{for(const s of Object.keys(a.relations))e.relations[s]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${t}.${s}`,table:t,type:"addedRelation"});for(const s of Object.keys(e.relations))a.relations[s]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${t}.${s}`,table:t,type:"removedRelation"})},ee=(t,e,a,n)=>{e.shardMode!==a.shardMode&&n.push({severity:"breaking",summary:`table ${t} changed shard mode: ${e.shardMode} → ${a.shardMode} — its physical storage moves; add a data migration / re-shard plan`,table:t,scope:"table",type:"changedShardMode"}),X(t,e,a,n),Y(t,e,a,n),Z(t,e,a,n)},te=(t,e)=>{const a=[],n=t?.tables??{};for(const[s,o]of Object.entries(e.tables)){const i=n[s];if(i===void 0){a.push({scope:"table",severity:"safe",summary:`added table ${s}`,table:s,type:"addedTable"});continue}ee(s,i,o,a)}for(const s of Object.keys(n))e.tables[s]===void 0&&a.push({scope:"table",severity:"breaking",summary:`removed table ${s} — add a data migration if its data must be archived/cleaned up`,table:s,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const s=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";a.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${s} to ${o} — this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:a}},T=t=>Object.entries(t.fields).map(([e,a])=>({name:e,optional:a.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:a.kind})),F=(t,e)=>{const a={},n=t?.fields??{},s=e?.fields??{};for(const[o,i]of Object.entries(s)){const r=n[o];r===void 0?a[o]=t===void 0?"unchanged":"added":a[o]=r.kind===i.kind&&r.optional===i.optional?"unchanged":"changed"}for(const o of Object.keys(n))s[o]===void 0&&(a[o]="removed");return a},ae=(t,e)=>{const{changes:a}=te(t,e),n=new Set(a.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),s=[],o=(i,r)=>i?"added":n.has(r)?"changed":"context";for(const[i,r]of Object.entries(e.tables)){const c=t?.tables[i],u=o(c===void 0,i);s.push({columns:T(r),fieldStatus:F(c,r),name:i,shardMode:r.shardMode,status:u})}for(const[i,r]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&s.push({columns:T(r),fieldStatus:F(r,void 0),name:i,shardMode:r.shardMode,status:"removed"});return s.sort((i,r)=>i.name.localeCompare(r.name)),{breakingCount:a.filter(i=>i.severity==="breaking").length,changes:a,tables:s}},A=t=>{const e=B(t);return e.status==="ok"?e.snapshot:void 0},ne={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},se=t=>t==="global"?"global":"shard",ie=t=>{const e=w(24),{appliedAt:a,hash:n,onSelect:s,selected:o,seq:i}=t,r=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let c;e[0]!==r?(c=N("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",r),e[0]=r,e[1]=c):c=e[1];const u=`sh-version-${n}`;let m;e[2]!==n||e[3]!==s?(m=()=>{s(n)},e[2]=n,e[3]=s,e[4]=m):m=e[4];let p;e[5]!==i?(p=g("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=p):p=e[6];let b;e[7]!==n?(b=n.slice(0,7),e[7]=n,e[8]=b):b=e[8];let h;e[9]!==b?(h=l("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:b}),e[9]=b,e[10]=h):h=e[10];let f;e[11]!==p||e[12]!==h?(f=g("span",{className:"flex w-full items-baseline gap-2",children:[p,h]}),e[11]=p,e[12]=h,e[13]=f):f=e[13];let v;e[14]!==a?(v=V(a),e[14]=a,e[15]=v):v=e[15];let x;e[16]!==v?(x=l("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:v}),e[16]=v,e[17]=x):x=e[17];let d;return e[18]!==x||e[19]!==c||e[20]!==u||e[21]!==m||e[22]!==f?(d=l("li",{children:g("button",{className:c,"data-testid":u,onClick:m,type:"button",children:[f,x]})}),e[18]=x,e[19]=c,e[20]=u,e[21]=m,e[22]=f,e[23]=d):d=e[23],d},re=t=>{const e=w(26),{breaking:a,count:n,first:s}=t,o=M();if(s){let h;e[0]!==n?(h=l("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=h):h=e[1];let f;e[2]!==o?(f=o("tables"),e[2]=o,e[3]=f):f=e[3];let v;e[4]!==f?(v=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=v):v=e[5];let x;return e[6]!==h||e[7]!==v?(x=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[h,v]}),e[6]=h,e[7]=v,e[8]=x):x=e[8],x}const i=a>0&&"text-destructive";let r;e[9]!==i?(r=N("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=r):r=e[10];let c;e[11]!==n||e[12]!==r?(c=l("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=c):c=e[13];let u;e[14]!==n||e[15]!==o?(u=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=u):u=e[16];let m;e[17]!==u?(m=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:u}),e[17]=u,e[18]=m):m=e[18];let p;e[19]!==a||e[20]!==o?(p=a>0&&g("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",o("{count} breaking",{count:a})]}),e[19]=a,e[20]=o,e[21]=p):p=e[21];let b;return e[22]!==c||e[23]!==m||e[24]!==p?(b=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[c,m,p]}),e[22]=c,e[23]=m,e[24]=p,e[25]=b):b=e[25],b},K={addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},oe=(t,e)=>{const a=`${K[t.type].action} ${e} `;return t.summary.startsWith(a)?t.summary.slice(a.length):t.summary},de=t=>{const e=new Map;for(const n of t){const s=n.table??"",o=e.get(s);o===void 0?e.set(s,[n]):o.push(n)}const a=[...e].map(([n,s])=>({changes:s,table:n}));return[...a.filter(n=>n.table!==""),...a.filter(n=>n.table==="")]},le=t=>{const e=w(2),{children:a}=t;let n;return e[0]!==a?(n=l("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:a}),e[0]=a,e[1]=n):n=e[1],n},ce=({pane:t,shardKey:e=""})=>{const a=M(),n=J(),s=P({strict:!1}).version,o=d=>{W(n({search:{version:d},to:"/migrations"}))},i=S(I.schemaHistory,{},{shardKey:e}),r=i.data?.versions??[],c=s!==void 0&&r.some(d=>d.hash===s)?s:r[0]?.hash,u=r.findIndex(d=>d.hash===c),m=u===-1?void 0:r[u+1]?.hash,p=S(I.schemaVersion,{hash:c??""},{enabled:c!==void 0,shardKey:e}),b=S(I.schemaVersion,{hash:m??""},{enabled:m!==void 0,shardKey:e}),h=O(()=>{const d=A(p.data?.version?.snapshotJson);if(d!==void 0)return ae(A(b.data?.version?.snapshotJson),d)},[p.data,b.data]),f=O(()=>(h?.tables??[]).map(d=>({columns:d.columns,name:d.name,tier:se(d.shardMode)})),[h]),v=O(()=>{const d={};for(const $ of h?.tables??[])d[$.name]=ne[$.status];return d},[h]);if(i.error!==null)return l(H,{error:i.errorSource,testId:"sh-error"});if(r.length===0)return l(U,{description:a("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:a("No schema versions recorded yet.")});const x=h?.changes??[];return g("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[g("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[l(le,{children:a("Schema versions")}),l("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:r.map(d=>l(ie,{appliedAt:d.appliedAt,hash:d.hash,onSelect:o,selected:d.hash===c,seq:d.seq},d.hash))})]}),g("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[l(re,{breaking:h?.breakingCount??0,count:m===void 0?f.length:x.length,first:m===void 0}),t==="diagram"?l("div",{className:"flex min-h-0 flex-1 flex-col",children:l(_,{fill:!0,nodeClasses:v,tables:f,testIdPrefix:"sh"})}):l("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:de(x).map(d=>{const $=(h?.tables??[]).find(y=>y.name===d.table);return g("section",{className:"mb-6",children:[g("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[l("span",{className:"font-mono text-[13px] text-foreground",children:d.table===""?a("schema"):d.table}),$!==void 0&&l("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:a("{count} columns",{count:$.columns.length})}),d.changes.length>1&&l("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:d.changes.length})]}),l("ul",{children:d.changes.map(y=>{const{action:C,kind:q}=K[y.type],j=y.severity==="breaking",R=oe(y,q);return g("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[l("span",{"aria-hidden":"true",className:N("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),g("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[a(C)," ",q]}),R!==d.table&&l("span",{className:N("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:R}),j&&l("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:a("breaking")})]},`${y.type}-${y.summary}`)})})]},d.table)})})]})]})},me=t=>N("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),je=t=>{const e=w(11),{initialShardKey:a}=t,n=M(),[s,o]=D("diagram");let i;e[0]!==s?(i=(p,b,h,f)=>g("button",{"aria-selected":s===p,className:me(s===p),"data-testid":h,onClick:()=>{o(p)},role:"tab",type:"button",children:[b,f!==void 0&&l("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),e[0]=s,e[1]=i):i=e[1];const r=i;let c;e[2]!==n||e[3]!==r?(c=g("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[r("diagram",n("Diagram"),"mg-pane-diagram"),r("changes",n("Changes"),"mg-pane-changes"),r("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=r,e[4]=c):c=e[4];let u;e[5]!==a||e[6]!==s?(u=l("div",{className:"flex min-h-0 flex-1 flex-col",children:s==="data"?l("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:l(E,{initialShardKey:a})}):l(ce,{pane:s,shardKey:a})}),e[5]=a,e[6]=s,e[7]=u):u=e[7];let m;return e[8]!==c||e[9]!==u?(m=g("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[c,u]}),e[8]=c,e[9]=u,e[10]=m):m=e[10],m};export{je as MigrationsRoutePanel};
1
+ import{c as w}from"react/compiler-runtime";import{useMemo as O,useState as D}from"react";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as N}from"../packem_shared/utils-bhneXptQ.js";import{MigrationsPanel as E}from"../packem_shared/MigrationsPanel-dygzHUvg.js";import{useNavigate as J,useSearch as P}from"@tanstack/react-router";import{E as H}from"../packem_shared/error-alert-t6cpEi0z.js";import{E as U}from"../packem_shared/empty-state-Cg7t_8qu.js";import{N as S}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as V,f as W}from"../packem_shared/internal-BSIsQVC6.js";import{S as _}from"../packem_shared/schema-diagram-cg-bz_VL.js";import{jsx as l,jsxs as g}from"react/jsx-runtime";const k=t=>typeof t=="object"&&t!==null,z=t=>k(t)&&k(t.fields)&&k(t.indexes)&&k(t.relations)&&typeof t.shardMode=="string",B=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(a){return{error:`baseline is not valid JSON: ${a instanceof Error?a.message:String(a)}`,status:"invalid"}}if(!k(e)||e.version!==1||!k(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(const[a,n]of Object.entries(e.tables))if(!z(n))return{error:`baseline table "${a}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},L=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((a,n)=>a===e.fields[n]),Q=(t,e,a,n)=>{const s=[];return a.kind!==n.kind&&s.push({severity:"breaking",summary:`field ${t}.${e} changed type: ${a.kind} → ${n.kind} — add a data migration to convert existing values`,table:t,scope:"table",type:"changedFieldKind"}),a.optional&&!n.optional?s.push({severity:"breaking",summary:`field ${t}.${e} became required — rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!a.optional&&n.optional&&s.push({scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),s},G=(t,e,a)=>a.optional?{scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${t}.${e} — existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},X=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.fields)){const i=e.fields[s];i===void 0?n.push(G(t,s,o)):n.push(...Q(t,s,i,o))}for(const s of Object.keys(e.fields))a.fields[s]===void 0&&n.push({severity:"breaking",summary:`removed field ${t}.${s} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},Y=(t,e,a,n)=>{for(const[s,o]of Object.entries(a.indexes)){const i=e.indexes[s];if(i===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${s} on ${t}`,table:t,type:"addedIndex"});continue}L(i,o)||n.push({severity:"breaking",summary:`index ${s} on ${t} changed shape — a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(const s of Object.keys(e.indexes))a.indexes[s]===void 0&&n.push({severity:"breaking",summary:`removed index ${s} on ${t} — a query that used \`.withIndex("${s}")\` would break`,table:t,scope:"table",type:"removedIndex"})},Z=(t,e,a,n)=>{for(const s of Object.keys(a.relations))e.relations[s]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${t}.${s}`,table:t,type:"addedRelation"});for(const s of Object.keys(e.relations))a.relations[s]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${t}.${s}`,table:t,type:"removedRelation"})},ee=(t,e,a,n)=>{e.shardMode!==a.shardMode&&n.push({severity:"breaking",summary:`table ${t} changed shard mode: ${e.shardMode} → ${a.shardMode} — its physical storage moves; add a data migration / re-shard plan`,table:t,scope:"table",type:"changedShardMode"}),X(t,e,a,n),Y(t,e,a,n),Z(t,e,a,n)},te=(t,e)=>{const a=[],n=t?.tables??{};for(const[s,o]of Object.entries(e.tables)){const i=n[s];if(i===void 0){a.push({scope:"table",severity:"safe",summary:`added table ${s}`,table:s,type:"addedTable"});continue}ee(s,i,o,a)}for(const s of Object.keys(n))e.tables[s]===void 0&&a.push({scope:"table",severity:"breaking",summary:`removed table ${s} — add a data migration if its data must be archived/cleaned up`,table:s,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const s=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";a.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${s} to ${o} — this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:a}},T=t=>Object.entries(t.fields).map(([e,a])=>({name:e,optional:a.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:a.kind})),F=(t,e)=>{const a={},n=t?.fields??{},s=e?.fields??{};for(const[o,i]of Object.entries(s)){const r=n[o];r===void 0?a[o]=t===void 0?"unchanged":"added":a[o]=r.kind===i.kind&&r.optional===i.optional?"unchanged":"changed"}for(const o of Object.keys(n))s[o]===void 0&&(a[o]="removed");return a},ae=(t,e)=>{const{changes:a}=te(t,e),n=new Set(a.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),s=[],o=(i,r)=>i?"added":n.has(r)?"changed":"context";for(const[i,r]of Object.entries(e.tables)){const c=t?.tables[i],u=o(c===void 0,i);s.push({columns:T(r),fieldStatus:F(c,r),name:i,shardMode:r.shardMode,status:u})}for(const[i,r]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&s.push({columns:T(r),fieldStatus:F(r,void 0),name:i,shardMode:r.shardMode,status:"removed"});return s.sort((i,r)=>i.name.localeCompare(r.name)),{breakingCount:a.filter(i=>i.severity==="breaking").length,changes:a,tables:s}},A=t=>{const e=B(t);return e.status==="ok"?e.snapshot:void 0},ne={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},se=t=>t==="global"?"global":"shard",ie=t=>{const e=w(24),{appliedAt:a,hash:n,onSelect:s,selected:o,seq:i}=t,r=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let c;e[0]!==r?(c=N("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",r),e[0]=r,e[1]=c):c=e[1];const u=`sh-version-${n}`;let m;e[2]!==n||e[3]!==s?(m=()=>{s(n)},e[2]=n,e[3]=s,e[4]=m):m=e[4];let p;e[5]!==i?(p=g("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=p):p=e[6];let b;e[7]!==n?(b=n.slice(0,7),e[7]=n,e[8]=b):b=e[8];let h;e[9]!==b?(h=l("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:b}),e[9]=b,e[10]=h):h=e[10];let f;e[11]!==p||e[12]!==h?(f=g("span",{className:"flex w-full items-baseline gap-2",children:[p,h]}),e[11]=p,e[12]=h,e[13]=f):f=e[13];let v;e[14]!==a?(v=V(a),e[14]=a,e[15]=v):v=e[15];let x;e[16]!==v?(x=l("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:v}),e[16]=v,e[17]=x):x=e[17];let d;return e[18]!==x||e[19]!==c||e[20]!==u||e[21]!==m||e[22]!==f?(d=l("li",{children:g("button",{className:c,"data-testid":u,onClick:m,type:"button",children:[f,x]})}),e[18]=x,e[19]=c,e[20]=u,e[21]=m,e[22]=f,e[23]=d):d=e[23],d},re=t=>{const e=w(26),{breaking:a,count:n,first:s}=t,o=M();if(s){let h;e[0]!==n?(h=l("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=h):h=e[1];let f;e[2]!==o?(f=o("tables"),e[2]=o,e[3]=f):f=e[3];let v;e[4]!==f?(v=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=v):v=e[5];let x;return e[6]!==h||e[7]!==v?(x=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[h,v]}),e[6]=h,e[7]=v,e[8]=x):x=e[8],x}const i=a>0&&"text-destructive";let r;e[9]!==i?(r=N("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=r):r=e[10];let c;e[11]!==n||e[12]!==r?(c=l("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=c):c=e[13];let u;e[14]!==n||e[15]!==o?(u=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=u):u=e[16];let m;e[17]!==u?(m=l("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:u}),e[17]=u,e[18]=m):m=e[18];let p;e[19]!==a||e[20]!==o?(p=a>0&&g("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",o("{count} breaking",{count:a})]}),e[19]=a,e[20]=o,e[21]=p):p=e[21];let b;return e[22]!==c||e[23]!==m||e[24]!==p?(b=g("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[c,m,p]}),e[22]=c,e[23]=m,e[24]=p,e[25]=b):b=e[25],b},K={addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},oe=(t,e)=>{const a=`${K[t.type].action} ${e} `;return t.summary.startsWith(a)?t.summary.slice(a.length):t.summary},de=t=>{const e=new Map;for(const n of t){const s=n.table??"",o=e.get(s);o===void 0?e.set(s,[n]):o.push(n)}const a=[...e].map(([n,s])=>({changes:s,table:n}));return[...a.filter(n=>n.table!==""),...a.filter(n=>n.table==="")]},le=t=>{const e=w(2),{children:a}=t;let n;return e[0]!==a?(n=l("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:a}),e[0]=a,e[1]=n):n=e[1],n},ce=({pane:t,shardKey:e=""})=>{const a=M(),n=J(),s=P({strict:!1}).version,o=d=>{W(n({search:{version:d},to:"/migrations"}))},i=S(I.schemaHistory,{},{shardKey:e}),r=i.data?.versions??[],c=s!==void 0&&r.some(d=>d.hash===s)?s:r[0]?.hash,u=r.findIndex(d=>d.hash===c),m=u===-1?void 0:r[u+1]?.hash,p=S(I.schemaVersion,{hash:c??""},{enabled:c!==void 0,shardKey:e}),b=S(I.schemaVersion,{hash:m??""},{enabled:m!==void 0,shardKey:e}),h=O(()=>{const d=A(p.data?.version?.snapshotJson);if(d!==void 0)return ae(A(b.data?.version?.snapshotJson),d)},[p.data,b.data]),f=O(()=>(h?.tables??[]).map(d=>({columns:d.columns,name:d.name,tier:se(d.shardMode)})),[h]),v=O(()=>{const d={};for(const $ of h?.tables??[])d[$.name]=ne[$.status];return d},[h]);if(i.error!==null)return l(H,{error:i.errorSource,testId:"sh-error"});if(r.length===0)return l(U,{description:a("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:a("No schema versions recorded yet.")});const x=h?.changes??[];return g("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[g("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[l(le,{children:a("Schema versions")}),l("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:r.map(d=>l(ie,{appliedAt:d.appliedAt,hash:d.hash,onSelect:o,selected:d.hash===c,seq:d.seq},d.hash))})]}),g("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[l(re,{breaking:h?.breakingCount??0,count:m===void 0?f.length:x.length,first:m===void 0}),t==="diagram"?l("div",{className:"flex min-h-0 flex-1 flex-col",children:l(_,{fill:!0,nodeClasses:v,tables:f,testIdPrefix:"sh"})}):l("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:de(x).map(d=>{const $=(h?.tables??[]).find(y=>y.name===d.table);return g("section",{className:"mb-6",children:[g("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[l("span",{className:"font-mono text-[13px] text-foreground",children:d.table===""?a("schema"):d.table}),$!==void 0&&l("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:a("{count} columns",{count:$.columns.length})}),d.changes.length>1&&l("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:d.changes.length})]}),l("ul",{children:d.changes.map(y=>{const{action:C,kind:q}=K[y.type],j=y.severity==="breaking",R=oe(y,q);return g("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[l("span",{"aria-hidden":"true",className:N("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),g("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[a(C)," ",q]}),R!==d.table&&l("span",{className:N("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:R}),j&&l("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:a("breaking")})]},`${y.type}-${y.summary}`)})})]},d.table)})})]})]})},me=t=>N("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),je=t=>{const e=w(11),{initialShardKey:a}=t,n=M(),[s,o]=D("diagram");let i;e[0]!==s?(i=(p,b,h,f)=>g("button",{"aria-selected":s===p,className:me(s===p),"data-testid":h,onClick:()=>{o(p)},role:"tab",type:"button",children:[b,f!==void 0&&l("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),e[0]=s,e[1]=i):i=e[1];const r=i;let c;e[2]!==n||e[3]!==r?(c=g("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[r("diagram",n("Diagram"),"mg-pane-diagram"),r("changes",n("Changes"),"mg-pane-changes"),r("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=r,e[4]=c):c=e[4];let u;e[5]!==a||e[6]!==s?(u=l("div",{className:"flex min-h-0 flex-1 flex-col",children:s==="data"?l("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:l(E,{initialShardKey:a})}):l(ce,{pane:s,shardKey:a})}),e[5]=a,e[6]=s,e[7]=u):u=e[7];let m;return e[8]!==c||e[9]!==u?(m=g("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[c,u]}),e[8]=c,e[9]=u,e[10]=m):m=e[10],m};export{je as MigrationsRoutePanel};
@@ -1 +1 @@
1
- import{E as B}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as N}from"../packem_shared/badge-BbuuAio7.js";import{c as y,u as w}from"../packem_shared/card-CIDGUN6K.js";import{E as S}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as A,d as D,m as b,p,f as I,u as n}from"../packem_shared/table-DdJBrClo.js";import{N as v}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{S as C}from"../packem_shared/home-panel-B60-5YfI.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as g}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{i as E}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as e,jsxs as o}from"react/jsx-runtime";const F=["subscriptions","events"],G={},P=new Set(["active","trialing"]),H=new Set(["past_due","unpaid"]),s=(a,t)=>{if(a[t]!==void 0)return a[t];const m=a.__doc__;if(typeof m=="string")try{const d=JSON.parse(m);if(d!==null&&typeof d=="object"&&!Array.isArray(d))return d[t]}catch{}},i=a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"",J=a=>P.has(a)?"default":H.has(a)?"destructive":"outline",re=({limit:a=100})=>{const t=M(),m=C(),{data:d}=v(g.listTables,G,{live:!0}),T=d!==void 0,_=Array.isArray(d)&&F.every(r=>d.some(c=>c.name===r)),f=m.payments&&_,l=v(g.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),u=v(g.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});O(()=>{f&&(l.refetch(),u.refetch())},!0);const h=l.data?.rows??[],$=u.data?.rows??[],j=l.error??u.error,R=l.error===null?u.errorSource:l.errorSource,x=h.filter(r=>P.has(i(s(r,"state")))).length,k=$.toSorted((r,c)=>Number(s(c,"processedAt")??0)-Number(s(r,"processedAt")??0));return T&&!f?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(S,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, …) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):o("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[e("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:o(y,{className:"justify-between gap-0 py-0",children:[o("div",{className:"flex flex-col gap-2.5 p-4",children:[e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),o("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:x}),e(N,{variant:"default",children:t("{count} active",{count:x})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),j===null?void 0:e(B,{error:R}),h.length===0&&!l.isLoading?e(S,{testId:"payments-empty",title:t("No subscriptions yet")}):e(y,{className:"overflow-hidden py-0",children:e(w,{className:"px-0",children:o(A,{children:[e(D,{children:o(b,{children:[e(p,{children:t("Provider")}),e(p,{children:t("Reference")}),e(p,{children:t("Plan")}),e(p,{children:t("State")}),e(p,{children:t("Renews")})]})}),e(I,{children:h.map(r=>{const c=i(s(r,"state"));return o(b,{"data-testid":"payment-subscription-row",children:[e(n,{children:i(s(r,"provider"))}),e(n,{children:i(s(r,"referenceId"))}),e(n,{children:i(s(r,"priceId"))}),e(n,{children:e(N,{variant:J(c),children:c})}),e(n,{children:E(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),o(y,{className:"overflow-hidden py-0",children:[e("header",{className:"border-b border-border px-4 py-3",children:e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),e(w,{className:"px-0",children:e(A,{children:e(I,{children:k.map(r=>o(b,{"data-testid":"payment-event-row",children:[e(n,{children:i(s(r,"provider"))}),e(n,{className:"font-medium",children:i(s(r,"type"))}),e(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),e(n,{children:E(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})};export{re as PaymentsPanel};
1
+ import{E as B}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as N}from"../packem_shared/badge-BbuuAio7.js";import{c as y,u as w}from"../packem_shared/card-CIDGUN6K.js";import{E as S}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as A,d as D,m as b,p,f as I,u as n}from"../packem_shared/table-DdJBrClo.js";import{N as v}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{S as C}from"../packem_shared/home-panel-CeeqqV0z.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as g}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as E}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as e,jsxs as o}from"react/jsx-runtime";const F=["subscriptions","events"],G={},P=new Set(["active","trialing"]),H=new Set(["past_due","unpaid"]),s=(a,t)=>{if(a[t]!==void 0)return a[t];const m=a.__doc__;if(typeof m=="string")try{const d=JSON.parse(m);if(d!==null&&typeof d=="object"&&!Array.isArray(d))return d[t]}catch{}},i=a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"",J=a=>P.has(a)?"default":H.has(a)?"destructive":"outline",re=({limit:a=100})=>{const t=M(),m=C(),{data:d}=v(g.listTables,G,{live:!0}),T=d!==void 0,_=Array.isArray(d)&&F.every(r=>d.some(c=>c.name===r)),f=m.payments&&_,l=v(g.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),u=v(g.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});O(()=>{f&&(l.refetch(),u.refetch())},!0);const h=l.data?.rows??[],$=u.data?.rows??[],j=l.error??u.error,R=l.error===null?u.errorSource:l.errorSource,x=h.filter(r=>P.has(i(s(r,"state")))).length,k=$.toSorted((r,c)=>Number(s(c,"processedAt")??0)-Number(s(r,"processedAt")??0));return T&&!f?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(S,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, …) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):o("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[e("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:o(y,{className:"justify-between gap-0 py-0",children:[o("div",{className:"flex flex-col gap-2.5 p-4",children:[e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),o("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:x}),e(N,{variant:"default",children:t("{count} active",{count:x})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),j===null?void 0:e(B,{error:R}),h.length===0&&!l.isLoading?e(S,{testId:"payments-empty",title:t("No subscriptions yet")}):e(y,{className:"overflow-hidden py-0",children:e(w,{className:"px-0",children:o(A,{children:[e(D,{children:o(b,{children:[e(p,{children:t("Provider")}),e(p,{children:t("Reference")}),e(p,{children:t("Plan")}),e(p,{children:t("State")}),e(p,{children:t("Renews")})]})}),e(I,{children:h.map(r=>{const c=i(s(r,"state"));return o(b,{"data-testid":"payment-subscription-row",children:[e(n,{children:i(s(r,"provider"))}),e(n,{children:i(s(r,"referenceId"))}),e(n,{children:i(s(r,"priceId"))}),e(n,{children:e(N,{variant:J(c),children:c})}),e(n,{children:E(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),o(y,{className:"overflow-hidden py-0",children:[e("header",{className:"border-b border-border px-4 py-3",children:e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),e(w,{className:"px-0",children:e(A,{children:e(I,{children:k.map(r=>o(b,{"data-testid":"payment-event-row",children:[e(n,{children:i(s(r,"provider"))}),e(n,{className:"font-medium",children:i(s(r,"type"))}),e(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),e(n,{children:E(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})};export{re as PaymentsPanel};
@@ -1 +1 @@
1
- import{useState as h,useRef as he,useEffect as ie}from"react";import{f as xe,m as ye,n as ge,u as de,c as ce}from"../packem_shared/card-CIDGUN6K.js";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as me}from"react/compiler-runtime";import{E as be}from"../packem_shared/error-alert-t6cpEi0z.js";import{L as Ne}from"../packem_shared/live-status-CmuRLFKf.js";import{g as Y}from"../packem_shared/badge-BbuuAio7.js";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{E as pe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as ve,d as we,m as oe,p as te,f as ke,u as ae}from"../packem_shared/table-DdJBrClo.js";import{N as re}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useLunora as fe}from"@lunora/react";import{ShardInput as Pe}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as G}from"../packem_shared/input-JHu63lTv.js";import{p as M}from"../packem_shared/label-6uP1obNF.js";import{l as Se}from"../packem_shared/textarea-Bu2-jKAs.js";import{d as Ce,g as Ie,b as _e,f as le}from"../packem_shared/internal-BSIsQVC6.js";const se=["read","insert","update","delete"],$e=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Ae=e=>{const t=new Set;for(const i of e?.advisories??[])if(i.name==="rls_uncovered_table"){const{table:n}=i.metadata;typeof n=="string"&&n!==""&&t.add(n)}return t},Fe=(e,t,i)=>{const n=new Map,r=d=>{const o=n.get(d);if(o!==void 0)return o;const p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:d,uncovered:i.has(d)};return n.set(d,p),p};for(const d of e)r(d.table).cells[d.on]={procedure:d.procedure};for(const d of t)r(d.table).maskedColumns.add(d.column);for(const d of i)r(d);return[...n.values()].toSorted((d,o)=>d.table.localeCompare(o.table))},Ee=e=>{const t=me(17);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const{onProbe:n}=i,r=ee();let d,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={},o={live:!0},t[2]=d,t[3]=o):(d=t[2],o=t[3]);const p=re(Z.rlsPolicies,d,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const g=re(Z.maskPolicies,l);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u={},t[5]=u):u=t[5];const b=re(Z.getAdvisories,u);let N;if(t[6]!==b.data||t[7]!==g.data||t[8]!==n||t[9]!==p||t[10]!==r){let v=null;p.data!==void 0&&(v=Array.isArray(p.data.policies)?p.data.policies:[]);const A=Array.isArray(g.data?.columns)?g.data.columns:[],O=b.data??null,{error:S,errorSource:w,liveError:C}=p,_=v===null?[]:Fe(v,A,Ae(O));let k;t[12]!==C?(k=a("div",{className:"flex items-center justify-end",children:a(Ne,{message:C,prefix:"pm"})}),t[12]=C,t[13]=k):k=t[13];let x;t[14]!==S||t[15]!==w?(x=S!==null&&a(be,{error:w,testId:"pm-error"}),t[14]=S,t[15]=w,t[16]=x):x=t[16],N=s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&_.length===0?a(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):s(ve,{"data-testid":"pm-table",children:[a(we,{children:s(oe,{children:[a(te,{children:r("Table")}),se.map(c=>a(te,{children:$e(r,c)},c)),a(te,{children:r("Masked columns")})]})}),a(ke,{children:_.map(c=>s(oe,{"data-testid":`pm-row-${c.table}`,children:[a(ae,{className:"font-mono text-xs",children:s("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&a(Y,{"data-testid":`pm-uncovered-${c.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),se.map(I=>{const y=c.cells[I];return a(ae,{"data-testid":`pm-cell-${c.table}-${I}`,children:y.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):s("span",{className:"flex flex-col gap-1",children:[a(Y,{variant:"secondary",children:r("Covered by {procedure}",{procedure:y.procedure})}),n!==void 0&&a(R,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${I}`,onClick:()=>{n(c.table,I,y.procedure??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},I)}),a(ae,{children:c.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Te)})})]},c.table))})]})]}),t[6]=b.data,t[7]=g.data,t[8]=n,t[9]=p,t[10]=r,t[11]=N}else N=t[11];return N};function Te(e){return a(Y,{variant:"outline",children:e},e)}const Le=Ie(Z.runAs),Re=()=>{const e=fe();return async({args:t,functionPath:i,shardKey:n="",userId:r})=>{const d=Le;try{return{kind:"allowed",value:await e.query(d,{args:t,functionPath:i,userId:r},Ce(n))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},Me=e=>e===void 0?"undefined":JSON.stringify(e,null,2),Oe=({functions:e,prefill:t,runAsIdentity:i=!1}={})=>{const n=fe(),r=ee(),d=Re(),[o,p]=h(null),[l,g]=h(null),u=e??o??[],[b,N]=h(""),[v,A]=h("{}"),[O,S]=h(""),[w,C]=h(""),[_,k]=h(!1),[x,c]=h(null),[I,y]=h(null),$=he(-1);ie(()=>{if(e!==void 0)return;let m=!1;return n.listFunctions().then(f=>(m||p(f),f)).catch(f=>{m||g(_e(f))}),()=>{m=!0}},[n,e]),ie(()=>{if(t===void 0||$.current===t.nonce)return;$.current=t.nonce;const m=t.functionPath;queueMicrotask(()=>{N(m),c(null)})},[t]);const P=b===""?u[0]?.path??"":b,F=async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(f){y(r("Invalid JSON args: {message}",{message:f.message})),c(null);return}y(null),k(!0);try{const f=await d({args:m,functionPath:P,shardKey:O.trim(),userId:w.trim()});c(f)}finally{k(!1)}},E=()=>{le(F())},B=m=>{N(m.target.value)},T=m=>{A(m.target.value)},L=m=>{C(m.target.value)};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!i&&a(pe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),s("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-function",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:B,value:P,children:u.map(m=>s("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-args",children:r("Arguments")}),a(Se,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:T,value:v})]}),a(Pe,{onChange:S,testId:"pp-shard",value:O}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(G,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:L,placeholder:r("Leave empty to run as admin"),value:w})]}),s("div",{className:"flex items-center gap-2",children:[a(R,{"data-testid":"pp-run",disabled:!i||_||P==="",onClick:E,type:"button",children:r(_?"Probing…":"Run probe")}),w.trim()!==""&&a(Y,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:w.trim()})})]})]}),I!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),x!==null&&x.kind==="allowed"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a(Y,{variant:"secondary",children:r("Allowed")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Me(x.value)})]}),x!==null&&x.kind==="denied"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a(Y,{variant:"destructive",children:r("Denied")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},ze="/__lunora/policy-scaffold",je={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},qe=async e=>{const t=await fetch(ze,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await t.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(t.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};const n=i.error;return{kind:"error",message:n===void 0?`policy scaffold failed (${String(t.status)})`:je[n]??n}},ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Je=()=>{const e=me(69),t=ee(),[i,n]=h(null),[r,d]=h(!1),[o,p]=h(null),[l,g]=h(ne);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=X=>{const K=X.target.name,{value:Q}=X.target;g(ue=>({...ue,[K]:Q}))},e[0]=u):u=e[0];const b=u;let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{n(null),g(ne)},e[1]=N):N=e[1];const v=N;let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=async X=>{d(!0),p(null);try{const K=await qe(X);p(K),K.kind==="ok"&&v()}catch(K){const Q=K;p({kind:"error",message:Q instanceof Error?Q.message:String(Q)})}d(!1)},e[2]=A):A=e[2];const O=A;let S;e[3]!==l.policyName||e[4]!==l.tableName?(S=()=>{le(O({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=S):S=e[5];const w=S;let C;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(C=()=>{le(O({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=C):C=e[9];const _=C;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{p(null),n("scaffold")},e[10]=k):k=e[10];const x=k;let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{p(null),n("wire")},e[11]=c):c=e[11];const I=c;let y;e[12]!==t?(y=t("Scaffold access rules"),e[12]=t,e[13]=y):y=e[13];let $;e[14]!==y?($=a(xe,{children:y}),e[14]=y,e[15]=$):$=e[15];let P;e[16]!==t?(P=t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=t,e[17]=P):P=e[17];let F;e[18]!==P?(F=a(ye,{children:P}),e[18]=P,e[19]=F):F=e[19];let E;e[20]!==F||e[21]!==$?(E=s(ge,{children:[$,F]}),e[20]=F,e[21]=$,e[22]=E):E=e[22];const B=i==="scaffold"?"default":"outline";let T;e[23]!==t?(T=t("New policy file"),e[23]=t,e[24]=T):T=e[24];let L;e[25]!==B||e[26]!==T?(L=a(R,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:B,children:T}),e[25]=B,e[26]=T,e[27]=L):L=e[27];const m=i==="wire"?"default":"outline";let f;e[28]!==t?(f=t("Wire into a procedure"),e[28]=t,e[29]=f):f=e[29];let z;e[30]!==m||e[31]!==f?(z=a(R,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:m,children:f}),e[30]=m,e[31]=f,e[32]=z):z=e[32];let j;e[33]!==L||e[34]!==z?(j=s("div",{className:"flex flex-wrap gap-2",children:[L,z]}),e[33]=L,e[34]=z,e[35]=j):j=e[35];let q;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==i||e[40]!==w||e[41]!==t?(q=i==="scaffold"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(G,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:b,value:l.policyName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(G,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:b,value:l.tableName})]}),a(R,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=i,e[40]=w,e[41]=t,e[42]=q):q=e[42];let J;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==i||e[48]!==_||e[49]!==t?(J=i==="wire"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(G,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:b,value:l.filePath})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(G,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:b,value:l.exportName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(G,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:b,value:l.policies})]}),a(R,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:_,size:"xs",type:"button",children:t(r?"Wiring…":"Wire RLS")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=i,e[48]=_,e[49]=t,e[50]=J):J=e[50];let D;e[51]!==o?(D=o?.kind==="error"&&a("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=D):D=e[52];let W;e[53]!==o?.kind||e[54]!==t?(W=o?.kind==="needs-manual-edit"&&a("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=t,e[55]=W):W=e[55];let U;e[56]!==o||e[57]!==t?(U=o?.kind==="ok"&&s("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[a("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&a("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(De)})]}),e[56]=o,e[57]=t,e[58]=U):U=e[58];let H;e[59]!==j||e[60]!==q||e[61]!==J||e[62]!==D||e[63]!==W||e[64]!==U?(H=s(de,{children:[j,q,J,D,W,U]}),e[59]=j,e[60]=q,e[61]=J,e[62]=D,e[63]=W,e[64]=U,e[65]=H):H=e[65];let V;return e[66]!==E||e[67]!==H?(V=s(ce,{"data-testid":"policy-scaffolder",size:"sm",children:[E,H]}),e[66]=E,e[67]=H,e[68]=V):V=e[68],V};function De(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const nt=({functions:e,runAsIdentity:t=!1,schemaEditable:i=!1}={})=>{const n=ee(),[r,d]=h(void 0),o=(p,l,g)=>{g!==""&&d(u=>({functionPath:g,nonce:(u?.nonce??0)+1}))};return s("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[s("section",{className:"flex flex-col gap-3",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Permissions")})}),a(Ee,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:s(ce,{className:"gap-0 py-0",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Probe")})}),s(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:n("Pick a function and an identity, then run it to see the access outcome.")}),a(Oe,{functions:e,prefill:r,runAsIdentity:t})]})]})}),i&&a("section",{className:"flex flex-col gap-2",children:a(Je,{})})]})};export{nt as PermissionsPanel};
1
+ import{useState as h,useRef as he,useEffect as ie}from"react";import{f as xe,m as ye,n as ge,u as de,c as ce}from"../packem_shared/card-CIDGUN6K.js";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as me}from"react/compiler-runtime";import{E as be}from"../packem_shared/error-alert-t6cpEi0z.js";import{L as Ne}from"../packem_shared/live-status-CmuRLFKf.js";import{g as Y}from"../packem_shared/badge-BbuuAio7.js";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{E as pe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as ve,d as we,m as oe,p as te,f as ke,u as ae}from"../packem_shared/table-DdJBrClo.js";import{N as re}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as a,jsxs as s}from"react/jsx-runtime";import{useLunora as fe}from"@lunora/react";import{ShardInput as Pe}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as G}from"../packem_shared/input-JHu63lTv.js";import{p as M}from"../packem_shared/label-6uP1obNF.js";import{l as Se}from"../packem_shared/textarea-Bu2-jKAs.js";import{d as Ce,g as Ie,b as _e,f as le}from"../packem_shared/internal-BSIsQVC6.js";const se=["read","insert","update","delete"],$e=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Ae=e=>{const t=new Set;for(const i of e?.advisories??[])if(i.name==="rls_uncovered_table"){const{table:n}=i.metadata;typeof n=="string"&&n!==""&&t.add(n)}return t},Fe=(e,t,i)=>{const n=new Map,r=d=>{const o=n.get(d);if(o!==void 0)return o;const p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:d,uncovered:i.has(d)};return n.set(d,p),p};for(const d of e)r(d.table).cells[d.on]={procedure:d.procedure};for(const d of t)r(d.table).maskedColumns.add(d.column);for(const d of i)r(d);return[...n.values()].toSorted((d,o)=>d.table.localeCompare(o.table))},Ee=e=>{const t=me(17);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const{onProbe:n}=i,r=ee();let d,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={},o={live:!0},t[2]=d,t[3]=o):(d=t[2],o=t[3]);const p=re(Z.rlsPolicies,d,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const g=re(Z.maskPolicies,l);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u={},t[5]=u):u=t[5];const b=re(Z.getAdvisories,u);let N;if(t[6]!==b.data||t[7]!==g.data||t[8]!==n||t[9]!==p||t[10]!==r){let v=null;p.data!==void 0&&(v=Array.isArray(p.data.policies)?p.data.policies:[]);const A=Array.isArray(g.data?.columns)?g.data.columns:[],O=b.data??null,{error:S,errorSource:w,liveError:C}=p,_=v===null?[]:Fe(v,A,Ae(O));let k;t[12]!==C?(k=a("div",{className:"flex items-center justify-end",children:a(Ne,{message:C,prefix:"pm"})}),t[12]=C,t[13]=k):k=t[13];let x;t[14]!==S||t[15]!==w?(x=S!==null&&a(be,{error:w,testId:"pm-error"}),t[14]=S,t[15]=w,t[16]=x):x=t[16],N=s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&_.length===0?a(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):s(ve,{"data-testid":"pm-table",children:[a(we,{children:s(oe,{children:[a(te,{children:r("Table")}),se.map(c=>a(te,{children:$e(r,c)},c)),a(te,{children:r("Masked columns")})]})}),a(ke,{children:_.map(c=>s(oe,{"data-testid":`pm-row-${c.table}`,children:[a(ae,{className:"font-mono text-xs",children:s("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&a(Y,{"data-testid":`pm-uncovered-${c.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),se.map(I=>{const y=c.cells[I];return a(ae,{"data-testid":`pm-cell-${c.table}-${I}`,children:y.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):s("span",{className:"flex flex-col gap-1",children:[a(Y,{variant:"secondary",children:r("Covered by {procedure}",{procedure:y.procedure})}),n!==void 0&&a(R,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${I}`,onClick:()=>{n(c.table,I,y.procedure??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},I)}),a(ae,{children:c.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Te)})})]},c.table))})]})]}),t[6]=b.data,t[7]=g.data,t[8]=n,t[9]=p,t[10]=r,t[11]=N}else N=t[11];return N};function Te(e){return a(Y,{variant:"outline",children:e},e)}const Le=Ie(Z.runAs),Re=()=>{const e=fe();return async({args:t,functionPath:i,shardKey:n="",userId:r})=>{const d=Le;try{return{kind:"allowed",value:await e.query(d,{args:t,functionPath:i,userId:r},Ce(n))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},Me=e=>e===void 0?"undefined":JSON.stringify(e,null,2),Oe=({functions:e,prefill:t,runAsIdentity:i=!1}={})=>{const n=fe(),r=ee(),d=Re(),[o,p]=h(null),[l,g]=h(null),u=e??o??[],[b,N]=h(""),[v,A]=h("{}"),[O,S]=h(""),[w,C]=h(""),[_,k]=h(!1),[x,c]=h(null),[I,y]=h(null),$=he(-1);ie(()=>{if(e!==void 0)return;let m=!1;return n.listFunctions().then(f=>(m||p(f),f)).catch(f=>{m||g(_e(f))}),()=>{m=!0}},[n,e]),ie(()=>{if(t===void 0||$.current===t.nonce)return;$.current=t.nonce;const m=t.functionPath;queueMicrotask(()=>{N(m),c(null)})},[t]);const P=b===""?u[0]?.path??"":b,F=async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(f){y(r("Invalid JSON args: {message}",{message:f.message})),c(null);return}y(null),k(!0);try{const f=await d({args:m,functionPath:P,shardKey:O.trim(),userId:w.trim()});c(f)}finally{k(!1)}},E=()=>{le(F())},B=m=>{N(m.target.value)},T=m=>{A(m.target.value)},L=m=>{C(m.target.value)};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!i&&a(pe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),s("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-function",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:B,value:P,children:u.map(m=>s("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-args",children:r("Arguments")}),a(Se,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:T,value:v})]}),a(Pe,{onChange:S,testId:"pp-shard",value:O}),s("div",{className:"flex flex-col gap-1.5",children:[a(M,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(G,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:L,placeholder:r("Leave empty to run as admin"),value:w})]}),s("div",{className:"flex items-center gap-2",children:[a(R,{"data-testid":"pp-run",disabled:!i||_||P==="",onClick:E,type:"button",children:r(_?"Probing…":"Run probe")}),w.trim()!==""&&a(Y,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:w.trim()})})]})]}),I!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),x!==null&&x.kind==="allowed"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a(Y,{variant:"secondary",children:r("Allowed")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Me(x.value)})]}),x!==null&&x.kind==="denied"&&s("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a(Y,{variant:"destructive",children:r("Denied")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},ze="/__lunora/policy-scaffold",je={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},qe=async e=>{const t=await fetch(ze,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await t.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(t.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};const n=i.error;return{kind:"error",message:n===void 0?`policy scaffold failed (${String(t.status)})`:je[n]??n}},ne={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Je=()=>{const e=me(69),t=ee(),[i,n]=h(null),[r,d]=h(!1),[o,p]=h(null),[l,g]=h(ne);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=X=>{const K=X.target.name,{value:Q}=X.target;g(ue=>({...ue,[K]:Q}))},e[0]=u):u=e[0];const b=u;let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{n(null),g(ne)},e[1]=N):N=e[1];const v=N;let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=async X=>{d(!0),p(null);try{const K=await qe(X);p(K),K.kind==="ok"&&v()}catch(K){const Q=K;p({kind:"error",message:Q instanceof Error?Q.message:String(Q)})}d(!1)},e[2]=A):A=e[2];const O=A;let S;e[3]!==l.policyName||e[4]!==l.tableName?(S=()=>{le(O({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=S):S=e[5];const w=S;let C;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(C=()=>{le(O({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=C):C=e[9];const _=C;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{p(null),n("scaffold")},e[10]=k):k=e[10];const x=k;let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{p(null),n("wire")},e[11]=c):c=e[11];const I=c;let y;e[12]!==t?(y=t("Scaffold access rules"),e[12]=t,e[13]=y):y=e[13];let $;e[14]!==y?($=a(xe,{children:y}),e[14]=y,e[15]=$):$=e[15];let P;e[16]!==t?(P=t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=t,e[17]=P):P=e[17];let F;e[18]!==P?(F=a(ye,{children:P}),e[18]=P,e[19]=F):F=e[19];let E;e[20]!==F||e[21]!==$?(E=s(ge,{children:[$,F]}),e[20]=F,e[21]=$,e[22]=E):E=e[22];const B=i==="scaffold"?"default":"outline";let T;e[23]!==t?(T=t("New policy file"),e[23]=t,e[24]=T):T=e[24];let L;e[25]!==B||e[26]!==T?(L=a(R,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:B,children:T}),e[25]=B,e[26]=T,e[27]=L):L=e[27];const m=i==="wire"?"default":"outline";let f;e[28]!==t?(f=t("Wire into a procedure"),e[28]=t,e[29]=f):f=e[29];let z;e[30]!==m||e[31]!==f?(z=a(R,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:m,children:f}),e[30]=m,e[31]=f,e[32]=z):z=e[32];let j;e[33]!==L||e[34]!==z?(j=s("div",{className:"flex flex-wrap gap-2",children:[L,z]}),e[33]=L,e[34]=z,e[35]=j):j=e[35];let q;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==i||e[40]!==w||e[41]!==t?(q=i==="scaffold"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(G,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:b,value:l.policyName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(G,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:b,value:l.tableName})]}),a(R,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=i,e[40]=w,e[41]=t,e[42]=q):q=e[42];let J;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==i||e[48]!==_||e[49]!==t?(J=i==="wire"&&s("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(G,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:b,value:l.filePath})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(G,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:b,value:l.exportName})]}),s("div",{className:"flex flex-col gap-1 text-xs",children:[a(M,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(G,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:b,value:l.policies})]}),a(R,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:_,size:"xs",type:"button",children:t(r?"Wiring…":"Wire RLS")}),a(R,{onClick:v,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=i,e[48]=_,e[49]=t,e[50]=J):J=e[50];let D;e[51]!==o?(D=o?.kind==="error"&&a("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=D):D=e[52];let W;e[53]!==o?.kind||e[54]!==t?(W=o?.kind==="needs-manual-edit"&&a("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=t,e[55]=W):W=e[55];let U;e[56]!==o||e[57]!==t?(U=o?.kind==="ok"&&s("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[a("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&a("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(De)})]}),e[56]=o,e[57]=t,e[58]=U):U=e[58];let H;e[59]!==j||e[60]!==q||e[61]!==J||e[62]!==D||e[63]!==W||e[64]!==U?(H=s(de,{children:[j,q,J,D,W,U]}),e[59]=j,e[60]=q,e[61]=J,e[62]=D,e[63]=W,e[64]=U,e[65]=H):H=e[65];let V;return e[66]!==E||e[67]!==H?(V=s(ce,{"data-testid":"policy-scaffolder",size:"sm",children:[E,H]}),e[66]=E,e[67]=H,e[68]=V):V=e[68],V};function De(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const nt=({functions:e,runAsIdentity:t=!1,schemaEditable:i=!1}={})=>{const n=ee(),[r,d]=h(void 0),o=(p,l,g)=>{g!==""&&d(u=>({functionPath:g,nonce:(u?.nonce??0)+1}))};return s("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[s("section",{className:"flex flex-col gap-3",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Permissions")})}),a(Ee,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:s(ce,{className:"gap-0 py-0",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Probe")})}),s(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:n("Pick a function and an identity, then run it to see the access outcome.")}),a(Oe,{functions:e,prefill:r,runAsIdentity:t})]})]})}),i&&a("section",{className:"flex flex-col gap-2",children:a(Je,{})})]})};export{nt as PermissionsPanel};
@@ -1 +1 @@
1
- import{c as P}from"react/compiler-runtime";import{useLunora as Ke}from"@lunora/react";import{useState as _}from"react";import{E as Ve}from"../packem_shared/error-alert-t6cpEi0z.js";import{A as Xe}from"../packem_shared/alert-CVcOFuDR.js";import{g as Qe}from"../packem_shared/badge-BbuuAio7.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{c as ke,u as Oe}from"../packem_shared/card-CIDGUN6K.js";import{E as Ie}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ye}from"../packem_shared/input-JHu63lTv.js";import{p as Ze}from"../packem_shared/scroll-area-DTEq6Jec.js";import{n as Be,d as Je,m as de,p as $,f as Fe,u as w}from"../packem_shared/table-DdJBrClo.js";import{l as et}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as De}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as tt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as j}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{d as $e,b as we,g as Ae,i as at,f as Ce}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as a,jsxs as b,Fragment as We}from"react/jsx-runtime";const st=(r,e)=>{const t=new Set(r.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),u=r.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!t.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:u,showReliabilityWarning:u.length>0||d>0}},rt=200,nt=Ae(j.sendQueueMessage),ot=Ae(j.replayQueueMessage),dt=Ae(j.clearQueueMessages),Re=96,lt=r=>{if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"[unserializable]"}},ut=r=>r.length>Re?`${r.slice(0,Re)}…`:r,ct=r=>r==="error"?"destructive":r==="retry"?"outline":"secondary",it=(r,e)=>e(r==="messages"?"Messages":r==="send"?"Send":"Declared"),mt=r=>{const e=P(11),{loaded:t,queues:u}=r,d=U();let s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=a("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let n;e[4]!==t||e[5]!==u||e[6]!==d?(n=t&&u.length===0?a(Ie,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:b(Be,{"data-testid":"queues-table",children:[a(Je,{children:b(de,{children:[a($,{children:d("Export")}),a($,{children:d("Queue")}),a($,{children:d("Mode")}),a($,{children:d("Binding")}),a($,{children:d("Dead-letter")})]})}),a(Fe,{children:u.map(ft)})]})})}),e[4]=t,e[5]=u,e[6]=d,e[7]=n):n=e[7];let h;return e[8]!==o||e[9]!==n?(h=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,n]}),e[8]=o,e[9]=n,e[10]=h):h=e[10],h},ht=r=>{const e=P(67),{message:t,onReplay:u,replayingId:d}=r,s=U();let o,n,h,i,y,p,x,l,m,g;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==s){const J=lt(t.body);n=de,p=`queues-message-${t.id}`;const F=t.exportName??t.queue;e[19]!==F?(x=a(w,{className:"font-mono text-xs",children:F}),e[19]=F,e[20]=x):x=e[20],e[21]!==t.messageId?(l=a(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=l):l=e[22],e[23]!==t.attempts?(m=a(w,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const E=`queues-outcome-${t.id}`;let L;e[25]!==t.outcome?(L=ct(t.outcome),e[25]=t.outcome,e[26]=L):L=e[26];let C;e[27]!==t.outcome||e[28]!==E||e[29]!==L?(C=a(Qe,{"data-testid":E,variant:L,children:t.outcome}),e[27]=t.outcome,e[28]=E,e[29]=L,e[30]=C):C=e[30];let M;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==s?(M=t.deadLettered&&a(Qe,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:s("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=s,e[34]=M):M=e[34],e[35]!==C||e[36]!==M?(g=a(w,{children:b("span",{className:"inline-flex items-center gap-1",children:[C,M]})}),e[35]=C,e[36]=M,e[37]=g):g=e[37],o=w,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=J,y=ut(J),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=s,e[9]=o,e[10]=n,e[11]=h,e[12]=i,e[13]=y,e[14]=p,e[15]=x,e[16]=l,e[17]=m,e[18]=g}else o=e[9],n=e[10],h=e[11],i=e[12],y=e[13],p=e[14],x=e[15],l=e[16],m=e[17],g=e[18];let f;e[38]!==o||e[39]!==h||e[40]!==i||e[41]!==y?(f=a(o,{className:h,title:i,children:y}),e[38]=o,e[39]=h,e[40]=i,e[41]=y,e[42]=f):f=e[42];let q;e[43]!==t.capturedAt?(q=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=q):q=e[44];let N;e[45]!==q?(N=a(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=N):N=e[46];const S=`queues-replay-${t.id}`,A=d!==null;let Q;e[47]!==t.id||e[48]!==d||e[49]!==s?(Q=d===t.id?s("Replaying…"):s("Replay"),e[47]=t.id,e[48]=d,e[49]=s,e[50]=Q):Q=e[50];let I;e[51]!==t.id||e[52]!==u||e[53]!==S||e[54]!==A||e[55]!==Q?(I=a(w,{children:a(oe,{"data-id":t.id,"data-testid":S,disabled:A,onClick:u,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=u,e[53]=S,e[54]=A,e[55]=Q,e[56]=I):I=e[56];let T;return e[57]!==n||e[58]!==N||e[59]!==I||e[60]!==p||e[61]!==x||e[62]!==l||e[63]!==m||e[64]!==g||e[65]!==f?(T=b(n,{"data-testid":p,children:[x,l,m,g,f,N,I]}),e[57]=n,e[58]=N,e[59]=I,e[60]=p,e[61]=x,e[62]=l,e[63]=m,e[64]=g,e[65]=f,e[66]=T):T=e[66],T},pt=r=>{const e=P(26),{hasError:t,messages:u,onClear:d,onReplay:s,replayingId:o}=r,n=U();let h;e[0]!==n?(h=n("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=n,e[1]=h):h=e[1];let i;e[2]!==h?(i=a("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=i):i=e[3];const y=u.length===0;let p;e[4]!==n?(p=n("Clear log"),e[4]=n,e[5]=p):p=e[5];let x;e[6]!==d||e[7]!==y||e[8]!==p?(x=a(oe,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[6]=d,e[7]=y,e[8]=p,e[9]=x):x=e[9];let l;e[10]!==u.length||e[11]!==n?(l=u.length>0&&a(Qe,{"data-testid":"queues-count",variant:"secondary",children:n("{count} messages",{count:u.length})}),e[10]=u.length,e[11]=n,e[12]=l):l=e[12];let m;e[13]!==i||e[14]!==x||e[15]!==l?(m=b("div",{className:"flex flex-wrap items-center gap-2",children:[i,x,l]}),e[13]=i,e[14]=x,e[15]=l,e[16]=m):m=e[16];let g;e[17]!==t||e[18]!==u||e[19]!==s||e[20]!==o||e[21]!==n?(g=!t&&u.length===0?a(Ie,{description:n("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:n("No consumed messages yet.")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:a(Ze,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Be,{"data-testid":"queues-messages-table",children:[a(Je,{children:b(de,{children:[a($,{children:n("Export")}),a($,{children:n("Message")}),a($,{children:n("Attempts")}),a($,{children:n("Outcome")}),a($,{children:n("Body")}),a($,{children:n("Captured")}),a($,{})]})}),a(Fe,{children:u.map(q=>a(ht,{message:q,onReplay:s,replayingId:o},q.id))})]})})})}),e[17]=t,e[18]=u,e[19]=s,e[20]=o,e[21]=n,e[22]=g):g=e[22];let f;return e[23]!==m||e[24]!==g?(f=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]}),e[23]=m,e[24]=g,e[25]=f):f=e[25],f},gt=r=>{const e=P(20),{batchMode:t,bodyText:u,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:n,onSelectExport:h,onSend:i,queues:y,selectedExportName:p,sending:x}=r,l=U();let m;e[0]!==l?(m=l("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=l,e[1]=m):m=e[1];let g;e[2]!==m?(g=a("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=g):g=e[3];let f;e[4]!==t||e[5]!==u||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==n||e[10]!==h||e[11]!==i||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==l?(f=y.length===0?a(Ie,{description:l("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:l("No queues to send to")}):b(We,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[a("select",{"aria-label":l("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(xt)}),a(Ye,{"aria-label":l("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:n,placeholder:l("Delay (s)"),type:"number",value:d}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[a("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),l("Send as batch (JSON array)")]}),a(oe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:i,type:"button",children:l(x?"Sending…":"Send message")})]}),a(et,{"aria-label":l("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:u})]}),e[4]=t,e[5]=u,e[6]=d,e[7]=s,e[8]=o,e[9]=n,e[10]=h,e[11]=i,e[12]=y,e[13]=p,e[14]=x,e[15]=l,e[16]=f):f=e[16];let q;return e[17]!==g||e[18]!==f?(q=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,f]}),e[17]=g,e[18]=f,e[19]=q):q=e[19],q},Bt=r=>{const e=P(59),{limit:t}=r,u=t??rt,d=Ke(),s=U(),[o,n]=_("declared"),[h,i]=_(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];const{data:p,error:x,errorSource:l}=De(j.listQueues,y);let m;e[1]!==u?(m={limit:u},e[1]=u,e[2]=m):m=e[2];const{data:g,error:f,errorSource:q,refetch:N}=De(j.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(yt):[],A=g?.entries??[],{deadLetteredCount:Q,queuesWithoutDlq:I,showReliabilityWarning:T}=st(S,A),[J,F]=_(""),[E,L]=_(""),[C,M]=_(""),[W,ze]=_(!1),[le,Ee]=_(!1),[ue,Le]=_(null),G=S.some(c=>c.exportName===J)?J:S[0]?.exportName??"",Me=o==="messages"?f:x,je=o==="messages"?q:l,ce=Me??h,ie=Me===null?h:je;let H;e[3]!==N?(H=()=>{N()},e[3]=N,e[4]=H):H=e[4],tt(H,o==="messages");const me=async()=>{i(null);const c=G;if(c==="")return;let v=null;const _e=E.trim();if(_e!=="")try{v=JSON.parse(_e)}catch{i(s("Body must be valid JSON."));return}let Se;const Te=C.trim();if(Te!==""){const z=Number(Te);if(!Number.isFinite(z)||z<0){i(s("Delay must be a non-negative number of seconds."));return}Se=z}if(W&&!Array.isArray(v)){i(s("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ee(!0);const He=W?{batch:v,delaySeconds:Se,exportName:c}:{body:v,delaySeconds:Se,exportName:c};try{await d.query(nt,He,$e("")),N()}catch(z){i(we(z))}Ee(!1)};let K;e[5]!==d||e[6]!==N?(K=async c=>{i(null),Le(c);try{await d.query(ot,{id:c},$e("")),N()}catch(v){i(we(v))}Le(null)},e[5]=d,e[6]=N,e[7]=K):K=e[7];const he=K;let V;e[8]!==d||e[9]!==N?(V=async()=>{i(null);try{await d.query(dt,{},$e("")),N()}catch(c){i(we(c))}},e[8]=d,e[9]=N,e[10]=V):V=e[10];const pe=V;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const v=c.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&n(v)},e[11]=X):X=e[11];const Pe=X;let Y;e[12]===Symbol.for("react.memo_cache_sentinel")?(Y=c=>{F(c.currentTarget.value)},e[12]=Y):Y=e[12];const ge=Y;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{L(c.currentTarget.value)},e[13]=Z):Z=e[13];const fe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{M(c.currentTarget.value)},e[14]=ee):ee=e[14];const xe=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{ze(c.currentTarget.checked)},e[15]=te):te=e[15];const ye=te;let ae;e[16]!==me?(ae=()=>{Ce(me())},e[16]=me,e[17]=ae):ae=e[17];const Ne=ae;let se;e[18]!==he?(se=c=>{const{id:v}=c.currentTarget.dataset;v!==void 0&&Ce(he(v))},e[18]=he,e[19]=se):se=e[19];const be=se;let re;e[20]!==pe?(re=()=>{Ce(pe())},e[20]=pe,e[21]=re):re=e[21];const qe=re,Ue="flex flex-col gap-6",Ge="lunora-queues-panel";let D;e[22]!==s||e[23]!==o?(D=a("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>a(oe,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:it(c,s)},c))}),e[22]=s,e[23]=o,e[24]=D):D=e[24];let R;e[25]!==ce||e[26]!==ie?(R=ce!==null&&a(Ve,{error:ie,testId:"queues-error"}),e[25]=ce,e[26]=ie,e[27]=R):R=e[27];const ve=T&&a(Xe,{icon:a("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[I.length>0&&b(We,{children:[a("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:I.map(Nt).join(", ")})}),a("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),Q>0&&a("p",{className:I.length>0?"text-muted-foreground":"font-medium",children:Q===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:Q})})]})});let k;e[28]!==S||e[29]!==p||e[30]!==o?(k=o==="declared"&&a(mt,{loaded:p!==void 0,queues:S}),e[28]=S,e[29]=p,e[30]=o,e[31]=k):k=e[31];let O;e[32]!==A||e[33]!==f||e[34]!==qe||e[35]!==be||e[36]!==ue||e[37]!==o?(O=o==="messages"&&a(pt,{hasError:f!==null,messages:A,onClear:qe,onReplay:be,replayingId:ue}),e[32]=A,e[33]=f,e[34]=qe,e[35]=be,e[36]=ue,e[37]=o,e[38]=O):O=e[38];let B;e[39]!==W||e[40]!==E||e[41]!==C||e[42]!==ye||e[43]!==fe||e[44]!==xe||e[45]!==ge||e[46]!==Ne||e[47]!==S||e[48]!==G||e[49]!==le||e[50]!==o?(B=o==="send"&&a(gt,{batchMode:W,bodyText:E,delayText:C,onBatchModeChange:ye,onBodyChange:fe,onDelayChange:xe,onSelectExport:ge,onSend:Ne,queues:S,selectedExportName:G,sending:le}),e[39]=W,e[40]=E,e[41]=C,e[42]=ye,e[43]=fe,e[44]=xe,e[45]=ge,e[46]=Ne,e[47]=S,e[48]=G,e[49]=le,e[50]=o,e[51]=B):B=e[51];let ne;return e[52]!==D||e[53]!==R||e[54]!==ve||e[55]!==k||e[56]!==O||e[57]!==B?(ne=b("div",{className:Ue,"data-testid":Ge,children:[D,R,ve,k,O,B]}),e[52]=D,e[53]=R,e[54]=ve,e[55]=k,e[56]=O,e[57]=B,e[58]=ne):ne=e[58],ne};function ft(r){return b(de,{"data-testid":`queues-row-${r.exportName}`,children:[a(w,{className:"font-mono text-xs",children:r.exportName}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.name}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.mode}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.binding}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.deadLetterQueue??"—"})]},r.exportName)}function xt(r){return a("option",{value:r.exportName,children:r.exportName},r.exportName)}function yt(r,e){return r.exportName.localeCompare(e.exportName)}function Nt(r){return r.name}export{Bt as default};
1
+ import{c as P}from"react/compiler-runtime";import{useLunora as Ke}from"@lunora/react";import{useState as _}from"react";import{ConfirmButton as Ve}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{E as Xe}from"../packem_shared/error-alert-t6cpEi0z.js";import{A as Ye}from"../packem_shared/alert-CVcOFuDR.js";import{g as Ce}from"../packem_shared/badge-BbuuAio7.js";import{u as Ie}from"../packem_shared/button-BkCrNcAs.js";import{c as Oe,u as ke}from"../packem_shared/card-CIDGUN6K.js";import{E as Qe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ze}from"../packem_shared/input-JHu63lTv.js";import{p as et}from"../packem_shared/scroll-area-DTEq6Jec.js";import{n as Be,d as Je,m as oe,p as $,f as Fe,u as w}from"../packem_shared/table-DdJBrClo.js";import{l as tt}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as Te}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as at}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as j}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as Se,b as $e,g as Ae,i as st,f as we}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as a,jsxs as q,Fragment as We}from"react/jsx-runtime";const rt=(n,e)=>{const t=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),l=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!t.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:l,showReliabilityWarning:l.length>0||d>0}},nt=200,ot=Ae(j.sendQueueMessage),dt=Ae(j.replayQueueMessage),lt=Ae(j.clearQueueMessages),Re=96,ut=n=>{if(n===void 0)return"—";try{return JSON.stringify(n)}catch{return"[unserializable]"}},it=n=>n.length>Re?`${n.slice(0,Re)}…`:n,ct=n=>n==="error"?"destructive":n==="retry"?"outline":"secondary",mt=(n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),ht=n=>{const e=P(11),{loaded:t,queues:l}=n,d=U();let s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=a("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let r;e[4]!==t||e[5]!==l||e[6]!==d?(r=t&&l.length===0?a(Qe,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):a(Oe,{className:"overflow-hidden py-0",children:a(ke,{className:"px-0",children:q(Be,{"data-testid":"queues-table",children:[a(Je,{children:q(oe,{children:[a($,{children:d("Export")}),a($,{children:d("Queue")}),a($,{children:d("Mode")}),a($,{children:d("Binding")}),a($,{children:d("Dead-letter")})]})}),a(Fe,{children:l.map(xt)})]})})}),e[4]=t,e[5]=l,e[6]=d,e[7]=r):r=e[7];let h;return e[8]!==o||e[9]!==r?(h=q("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=h):h=e[10],h},pt=n=>{const e=P(67),{message:t,onReplay:l,replayingId:d}=n,s=U();let o,r,h,c,f,y,x,u,m,g;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==s){const J=ut(t.body);r=oe,y=`queues-message-${t.id}`;const F=t.exportName??t.queue;e[19]!==F?(x=a(w,{className:"font-mono text-xs",children:F}),e[19]=F,e[20]=x):x=e[20],e[21]!==t.messageId?(u=a(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(m=a(w,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const L=`queues-outcome-${t.id}`;let E;e[25]!==t.outcome?(E=ct(t.outcome),e[25]=t.outcome,e[26]=E):E=e[26];let C;e[27]!==t.outcome||e[28]!==L||e[29]!==E?(C=a(Ce,{"data-testid":L,variant:E,children:t.outcome}),e[27]=t.outcome,e[28]=L,e[29]=E,e[30]=C):C=e[30];let M;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==s?(M=t.deadLettered&&a(Ce,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:s("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=s,e[34]=M):M=e[34],e[35]!==C||e[36]!==M?(g=a(w,{children:q("span",{className:"inline-flex items-center gap-1",children:[C,M]})}),e[35]=C,e[36]=M,e[37]=g):g=e[37],o=w,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=J,f=it(J),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=s,e[9]=o,e[10]=r,e[11]=h,e[12]=c,e[13]=f,e[14]=y,e[15]=x,e[16]=u,e[17]=m,e[18]=g}else o=e[9],r=e[10],h=e[11],c=e[12],f=e[13],y=e[14],x=e[15],u=e[16],m=e[17],g=e[18];let p;e[38]!==o||e[39]!==h||e[40]!==c||e[41]!==f?(p=a(o,{className:h,title:c,children:f}),e[38]=o,e[39]=h,e[40]=c,e[41]=f,e[42]=p):p=e[42];let b;e[43]!==t.capturedAt?(b=st(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=b):b=e[44];let N;e[45]!==b?(N=a(w,{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[45]=b,e[46]=N):N=e[46];const S=`queues-replay-${t.id}`,A=d!==null;let I;e[47]!==t.id||e[48]!==d||e[49]!==s?(I=d===t.id?s("Replaying…"):s("Replay"),e[47]=t.id,e[48]=d,e[49]=s,e[50]=I):I=e[50];let Q;e[51]!==t.id||e[52]!==l||e[53]!==S||e[54]!==A||e[55]!==I?(Q=a(w,{children:a(Ie,{"data-id":t.id,"data-testid":S,disabled:A,onClick:l,size:"xs",type:"button",variant:"outline",children:I})}),e[51]=t.id,e[52]=l,e[53]=S,e[54]=A,e[55]=I,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==N||e[59]!==Q||e[60]!==y||e[61]!==x||e[62]!==u||e[63]!==m||e[64]!==g||e[65]!==p?(D=q(r,{"data-testid":y,children:[x,u,m,g,p,N,Q]}),e[57]=r,e[58]=N,e[59]=Q,e[60]=y,e[61]=x,e[62]=u,e[63]=m,e[64]=g,e[65]=p,e[66]=D):D=e[66],D},gt=n=>{const e=P(30),{hasError:t,messages:l,onClear:d,onReplay:s,replayingId:o}=n,r=U();let h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=r,e[1]=h):h=e[1];let c;e[2]!==h?(c=a("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=c):c=e[3];let f;e[4]!==l.length||e[5]!==r?(f=r("Clear {count} messages?",{count:l.length}),e[4]=l.length,e[5]=r,e[6]=f):f=e[6];const y=l.length===0;let x;e[7]!==r?(x=r("Clear log"),e[7]=r,e[8]=x):x=e[8];let u;e[9]!==d||e[10]!==f||e[11]!==y||e[12]!==x?(u=a("div",{className:"ml-auto",children:a(Ve,{confirmLabel:f,disabled:y,onConfirm:d,testId:"queues-clear",children:x})}),e[9]=d,e[10]=f,e[11]=y,e[12]=x,e[13]=u):u=e[13];let m;e[14]!==l.length||e[15]!==r?(m=l.length>0&&a(Ce,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:l.length})}),e[14]=l.length,e[15]=r,e[16]=m):m=e[16];let g;e[17]!==c||e[18]!==u||e[19]!==m?(g=q("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,m]}),e[17]=c,e[18]=u,e[19]=m,e[20]=g):g=e[20];let p;e[21]!==t||e[22]!==l||e[23]!==s||e[24]!==o||e[25]!==r?(p=!t&&l.length===0?a(Qe,{description:r("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:r("No consumed messages yet.")}):a(Oe,{className:"overflow-hidden py-0",children:a(ke,{className:"px-0",children:a(et,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:q(Be,{"data-testid":"queues-messages-table",children:[a(Je,{children:q(oe,{children:[a($,{children:r("Export")}),a($,{children:r("Message")}),a($,{children:r("Attempts")}),a($,{children:r("Outcome")}),a($,{children:r("Body")}),a($,{children:r("Captured")}),a($,{})]})}),a(Fe,{children:l.map(N=>a(pt,{message:N,onReplay:s,replayingId:o},N.id))})]})})})}),e[21]=t,e[22]=l,e[23]=s,e[24]=o,e[25]=r,e[26]=p):p=e[26];let b;return e[27]!==g||e[28]!==p?(b=q("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[g,p]}),e[27]=g,e[28]=p,e[29]=b):b=e[29],b},ft=n=>{const e=P(20),{batchMode:t,bodyText:l,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:r,onSelectExport:h,onSend:c,queues:f,selectedExportName:y,sending:x}=n,u=U();let m;e[0]!==u?(m=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]=m):m=e[1];let g;e[2]!==m?(g=a("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=g):g=e[3];let p;e[4]!==t||e[5]!==l||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==r||e[10]!==h||e[11]!==c||e[12]!==f||e[13]!==y||e[14]!==x||e[15]!==u?(p=f.length===0?a(Qe,{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")}):q(We,{children:[q("div",{className:"flex flex-wrap items-center gap-2",children:[a("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:h,value:y,children:f.map(yt)}),a(Ze,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:u("Delay (s)"),type:"number",value:d}),q("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[a("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),u("Send as batch (JSON array)")]}),a(Ie,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||y==="",onClick:c,type:"button",children:u(x?"Sending…":"Send message")})]}),a(tt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:l})]}),e[4]=t,e[5]=l,e[6]=d,e[7]=s,e[8]=o,e[9]=r,e[10]=h,e[11]=c,e[12]=f,e[13]=y,e[14]=x,e[15]=u,e[16]=p):p=e[16];let b;return e[17]!==g||e[18]!==p?(b=q("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,p]}),e[17]=g,e[18]=p,e[19]=b):b=e[19],b},Ft=n=>{const e=P(59),{limit:t}=n,l=t??nt,d=Ke(),s=U(),[o,r]=_("declared"),[h,c]=_(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];const{data:y,error:x,errorSource:u}=Te(j.listQueues,f);let m;e[1]!==l?(m={limit:l},e[1]=l,e[2]=m):m=e[2];const{data:g,error:p,errorSource:b,refetch:N}=Te(j.getQueueMessages,m),S=Array.isArray(y?.queues)?[...y.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:I,queuesWithoutDlq:Q,showReliabilityWarning:D}=rt(S,A),[J,F]=_(""),[L,E]=_(""),[C,M]=_(""),[W,ze]=_(!1),[de,Le]=_(!1),[le,Ee]=_(null),G=S.some(i=>i.exportName===J)?J:S[0]?.exportName??"",Me=o==="messages"?p:x,je=o==="messages"?b:u,ue=Me??h,ie=Me===null?h:je;let H;e[3]!==N?(H=()=>{N()},e[3]=N,e[4]=H):H=e[4],at(H,o==="messages");const ce=async()=>{c(null);const i=G;if(i==="")return;let v=null;const _e=L.trim();if(_e!=="")try{v=JSON.parse(_e)}catch{c(s("Body must be valid JSON."));return}let ve;const De=C.trim();if(De!==""){const z=Number(De);if(!Number.isFinite(z)||z<0){c(s("Delay must be a non-negative number of seconds."));return}ve=z}if(W&&!Array.isArray(v)){c(s("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Le(!0);const He=W?{batch:v,delaySeconds:ve,exportName:i}:{body:v,delaySeconds:ve,exportName:i};try{await d.query(ot,He,Se("")),N()}catch(z){c($e(z))}Le(!1)};let K;e[5]!==d||e[6]!==N?(K=async i=>{c(null),Ee(i);try{await d.query(dt,{id:i},Se("")),N()}catch(v){c($e(v))}Ee(null)},e[5]=d,e[6]=N,e[7]=K):K=e[7];const me=K;let V;e[8]!==d||e[9]!==N?(V=async()=>{c(null);try{await d.query(lt,{},Se("")),N()}catch(i){c($e(i))}},e[8]=d,e[9]=N,e[10]=V):V=e[10];const he=V;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=i=>{const v=i.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&r(v)},e[11]=X):X=e[11];const Pe=X;let Y;e[12]===Symbol.for("react.memo_cache_sentinel")?(Y=i=>{F(i.currentTarget.value)},e[12]=Y):Y=e[12];const pe=Y;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=i=>{E(i.currentTarget.value)},e[13]=Z):Z=e[13];const ge=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=i=>{M(i.currentTarget.value)},e[14]=ee):ee=e[14];const fe=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=i=>{ze(i.currentTarget.checked)},e[15]=te):te=e[15];const xe=te;let ae;e[16]!==ce?(ae=()=>{we(ce())},e[16]=ce,e[17]=ae):ae=e[17];const ye=ae;let se;e[18]!==me?(se=i=>{const{id:v}=i.currentTarget.dataset;v!==void 0&&we(me(v))},e[18]=me,e[19]=se):se=e[19];const Ne=se;let re;e[20]!==he?(re=()=>{we(he())},e[20]=he,e[21]=re):re=e[21];const be=re,Ue="flex flex-col gap-6",Ge="lunora-queues-panel";let T;e[22]!==s||e[23]!==o?(T=a("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(i=>a(Ie,{"aria-selected":o===i,"data-tab":i,"data-testid":`queues-tab-${i}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===i?"secondary":"ghost",children:mt(i,s)},i))}),e[22]=s,e[23]=o,e[24]=T):T=e[24];let R;e[25]!==ue||e[26]!==ie?(R=ue!==null&&a(Xe,{error:ie,testId:"queues-error"}),e[25]=ue,e[26]=ie,e[27]=R):R=e[27];const qe=D&&a(Ye,{icon:a("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:q("div",{className:"flex flex-col gap-1",children:[Q.length>0&&q(We,{children:[a("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:Q.map(bt).join(", ")})}),a("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),I>0&&a("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:I===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:I})})]})});let O;e[28]!==S||e[29]!==y||e[30]!==o?(O=o==="declared"&&a(ht,{loaded:y!==void 0,queues:S}),e[28]=S,e[29]=y,e[30]=o,e[31]=O):O=e[31];let k;e[32]!==A||e[33]!==p||e[34]!==be||e[35]!==Ne||e[36]!==le||e[37]!==o?(k=o==="messages"&&a(gt,{hasError:p!==null,messages:A,onClear:be,onReplay:Ne,replayingId:le}),e[32]=A,e[33]=p,e[34]=be,e[35]=Ne,e[36]=le,e[37]=o,e[38]=k):k=e[38];let B;e[39]!==W||e[40]!==L||e[41]!==C||e[42]!==xe||e[43]!==ge||e[44]!==fe||e[45]!==pe||e[46]!==ye||e[47]!==S||e[48]!==G||e[49]!==de||e[50]!==o?(B=o==="send"&&a(ft,{batchMode:W,bodyText:L,delayText:C,onBatchModeChange:xe,onBodyChange:ge,onDelayChange:fe,onSelectExport:pe,onSend:ye,queues:S,selectedExportName:G,sending:de}),e[39]=W,e[40]=L,e[41]=C,e[42]=xe,e[43]=ge,e[44]=fe,e[45]=pe,e[46]=ye,e[47]=S,e[48]=G,e[49]=de,e[50]=o,e[51]=B):B=e[51];let ne;return e[52]!==T||e[53]!==R||e[54]!==qe||e[55]!==O||e[56]!==k||e[57]!==B?(ne=q("div",{className:Ue,"data-testid":Ge,children:[T,R,qe,O,k,B]}),e[52]=T,e[53]=R,e[54]=qe,e[55]=O,e[56]=k,e[57]=B,e[58]=ne):ne=e[58],ne};function xt(n){return q(oe,{"data-testid":`queues-row-${n.exportName}`,children:[a(w,{className:"font-mono text-xs",children:n.exportName}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.name}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),a(w,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"—"})]},n.exportName)}function yt(n){return a("option",{value:n.exportName,children:n.exportName},n.exportName)}function Nt(n,e){return n.exportName.localeCompare(e.exportName)}function bt(n){return n.name}export{Ft as default};
@@ -1 +1 @@
1
- import{c as F}from"react/compiler-runtime";import{E as J}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as z}from"../packem_shared/badge-BbuuAio7.js";import{u as C,c as D}from"../packem_shared/card-CIDGUN6K.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as G,d as M,m as E,p as A,f as O,u as S}from"../packem_shared/table-DdJBrClo.js";import{N as K}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";const U=["read","insert","update","delete"],q=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],B=e=>{const t=new Map;for(const s of e){const l=t.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),t.set(s.table,l)}return[...t.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},ae=()=>{const e=F(49),t=V();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:I,errorSource:R}=K(W.rlsPolicies,s),c=l!==void 0;let p,n,m,a,h,f,u,x,i;if(e[1]!==l||e[2]!==I||e[3]!==R||e[4]!==c||e[5]!==t){const T=B(Array.isArray(l?.policies)?l.policies:[]);let k;e[15]!==l?(k=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=k):k=e[16],n=k,u="flex flex-col gap-6",x="lunora-rls-panel",e[17]!==I||e[18]!==R?(i=I!==null&&r(J,{error:R,testId:"rls-error"}),e[17]=I,e[18]=R,e[19]=i):i=e[19],f="flex flex-col gap-2",p=D,m="overflow-hidden py-0";let v;e[20]!==t?(v=t("Policies"),e[20]=t,e[21]=v):v=e[21],e[22]!==v?(a=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v})}),e[22]=v,e[23]=a):a=e[23],h=c&&T.length===0?r(j,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):r(C,{className:"px-0",children:o(G,{"data-testid":"rls-policies-table",children:[r(M,{children:o(E,{children:[r(A,{children:t("Table")}),U.map(d=>r(A,{children:q(t,d)},d)),r(A,{children:t("Guarded by")})]})}),r(O,{children:T.map(d=>o(E,{"data-testid":`rls-table-${d.table}`,children:[r(S,{className:"font-mono text-xs",children:d.table}),U.map(_=>r(S,{children:d.operations.has(_)?r(z,{variant:"secondary",children:t("Guarded")}):r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},_)),r(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=I,e[3]=R,e[4]=c,e[5]=t,e[6]=p,e[7]=n,e[8]=m,e[9]=a,e[10]=h,e[11]=f,e[12]=u,e[13]=x,e[14]=i}else p=e[6],n=e[7],m=e[8],a=e[9],h=e[10],f=e[11],u=e[12],x=e[13],i=e[14];let N;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==h?(N=o(p,{className:m,children:[a,h]}),e[24]=p,e[25]=m,e[26]=a,e[27]=h,e[28]=N):N=e[28];let b;e[29]!==f||e[30]!==N?(b=r("section",{className:f,children:N}),e[29]=f,e[30]=N,e[31]=b):b=e[31];let g;e[32]!==t?(g=t("Roles"),e[32]=t,e[33]=g):g=e[33];let y;e[34]!==g?(y=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[34]=g,e[35]=y):y=e[35];let $;e[36]!==c||e[37]!==n||e[38]!==t?($=c&&n.length===0?r(j,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):r(C,{className:"px-0",children:o(G,{"data-testid":"rls-roles-table",children:[r(M,{children:o(E,{children:[r(A,{children:t("Role")}),r(A,{children:t("Description")}),r(A,{children:t("Permissions")})]})}),r(O,{children:n.map(L)})]})}),e[36]=c,e[37]=n,e[38]=t,e[39]=$):$=e[39];let w;e[40]!==y||e[41]!==$?(w=r("section",{className:"flex flex-col gap-2",children:o(D,{className:"overflow-hidden py-0",children:[y,$]})}),e[40]=y,e[41]=$,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==x||e[46]!==i||e[47]!==b?(P=o("div",{className:u,"data-testid":x,children:[i,b,w]}),e[43]=w,e[44]=u,e[45]=x,e[46]=i,e[47]=b,e[48]=P):P=e[48],P};function H(e){return r(z,{variant:"outline",children:e},e)}function L(e){return o(E,{"data-testid":`rls-role-${e.name}`,children:[r(S,{className:"font-mono text-xs",children:e.name}),r(S,{className:"text-muted-foreground",children:e.description??""}),r(S,{children:e.permissions.length===0?r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):r("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(H)})})]},e.name)}export{ae as default};
1
+ import{c as F}from"react/compiler-runtime";import{E as J}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as z}from"../packem_shared/badge-BbuuAio7.js";import{u as C,c as D}from"../packem_shared/card-CIDGUN6K.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as G,d as M,m as E,p as A,f as O,u as S}from"../packem_shared/table-DdJBrClo.js";import{N as K}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";const U=["read","insert","update","delete"],q=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],B=e=>{const t=new Map;for(const s of e){const l=t.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),t.set(s.table,l)}return[...t.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},ae=()=>{const e=F(49),t=V();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:I,errorSource:R}=K(W.rlsPolicies,s),c=l!==void 0;let p,n,m,a,h,f,u,x,i;if(e[1]!==l||e[2]!==I||e[3]!==R||e[4]!==c||e[5]!==t){const T=B(Array.isArray(l?.policies)?l.policies:[]);let k;e[15]!==l?(k=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=k):k=e[16],n=k,u="flex flex-col gap-6",x="lunora-rls-panel",e[17]!==I||e[18]!==R?(i=I!==null&&r(J,{error:R,testId:"rls-error"}),e[17]=I,e[18]=R,e[19]=i):i=e[19],f="flex flex-col gap-2",p=D,m="overflow-hidden py-0";let v;e[20]!==t?(v=t("Policies"),e[20]=t,e[21]=v):v=e[21],e[22]!==v?(a=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v})}),e[22]=v,e[23]=a):a=e[23],h=c&&T.length===0?r(j,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):r(C,{className:"px-0",children:o(G,{"data-testid":"rls-policies-table",children:[r(M,{children:o(E,{children:[r(A,{children:t("Table")}),U.map(d=>r(A,{children:q(t,d)},d)),r(A,{children:t("Guarded by")})]})}),r(O,{children:T.map(d=>o(E,{"data-testid":`rls-table-${d.table}`,children:[r(S,{className:"font-mono text-xs",children:d.table}),U.map(_=>r(S,{children:d.operations.has(_)?r(z,{variant:"secondary",children:t("Guarded")}):r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},_)),r(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=I,e[3]=R,e[4]=c,e[5]=t,e[6]=p,e[7]=n,e[8]=m,e[9]=a,e[10]=h,e[11]=f,e[12]=u,e[13]=x,e[14]=i}else p=e[6],n=e[7],m=e[8],a=e[9],h=e[10],f=e[11],u=e[12],x=e[13],i=e[14];let N;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==h?(N=o(p,{className:m,children:[a,h]}),e[24]=p,e[25]=m,e[26]=a,e[27]=h,e[28]=N):N=e[28];let b;e[29]!==f||e[30]!==N?(b=r("section",{className:f,children:N}),e[29]=f,e[30]=N,e[31]=b):b=e[31];let g;e[32]!==t?(g=t("Roles"),e[32]=t,e[33]=g):g=e[33];let y;e[34]!==g?(y=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[34]=g,e[35]=y):y=e[35];let $;e[36]!==c||e[37]!==n||e[38]!==t?($=c&&n.length===0?r(j,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):r(C,{className:"px-0",children:o(G,{"data-testid":"rls-roles-table",children:[r(M,{children:o(E,{children:[r(A,{children:t("Role")}),r(A,{children:t("Description")}),r(A,{children:t("Permissions")})]})}),r(O,{children:n.map(L)})]})}),e[36]=c,e[37]=n,e[38]=t,e[39]=$):$=e[39];let w;e[40]!==y||e[41]!==$?(w=r("section",{className:"flex flex-col gap-2",children:o(D,{className:"overflow-hidden py-0",children:[y,$]})}),e[40]=y,e[41]=$,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==x||e[46]!==i||e[47]!==b?(P=o("div",{className:u,"data-testid":x,children:[i,b,w]}),e[43]=w,e[44]=u,e[45]=x,e[46]=i,e[47]=b,e[48]=P):P=e[48],P};function H(e){return r(z,{variant:"outline",children:e},e)}function L(e){return o(E,{"data-testid":`rls-role-${e.name}`,children:[r(S,{className:"font-mono text-xs",children:e.name}),r(S,{className:"text-muted-foreground",children:e.description??""}),r(S,{children:e.permissions.length===0?r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):r("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(H)})})]},e.name)}export{ae as default};
@@ -1 +1 @@
1
- import{c as $}from"react/compiler-runtime";import{E as b}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as y}from"../packem_shared/badge-BbuuAio7.js";import{c as k,u as S}from"../packem_shared/card-CIDGUN6K.js";import{E as w}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as R,d as v,m as x,p as u,f as A,u as p}from"../packem_shared/table-DdJBrClo.js";import{N as E}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{jsx as t,jsxs as f}from"react/jsx-runtime";const C=(e,r)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[r],N={delete:2,list:3,read:0,write:1},T=e=>[...e].toSorted((r,s)=>r.bucket.localeCompare(s.bucket)||N[r.on]-N[s.on]||(r.prefix??"").localeCompare(s.prefix??"")),U=()=>{const e=$(14),r=j();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:i,errorSource:d}=E(I.storageRules,s),h=l!==void 0;let n;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==r){const g=T(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==i||e[8]!==d?(c=i!==null&&t(b,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=c):c=e[9];let a;e[10]!==r?(a=r("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=r,e[11]=a):a=e[11];let m;e[12]!==a?(m=t("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:a}),e[12]=a,e[13]=m):m=e[13],n=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&g.length===0?t(w,{description:r("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:r("No storage rules defined")}):t(k,{className:"overflow-hidden py-0",children:t(S,{className:"px-0",children:f(R,{"data-testid":"storage-rules-table",children:[t(v,{children:f(x,{children:[t(u,{children:r("Bucket")}),t(u,{children:r("Operation")}),t(u,{children:r("Key prefix")}),t(u,{children:r("Guarded by")})]})}),t(A,{children:g.map(o=>f(x,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[t(p,{className:"font-mono text-xs",children:o.bucket}),t(p,{children:t(y,{variant:"secondary",children:C(r,o.on)})}),t(p,{className:"font-mono text-xs",children:o.prefix??t("span",{className:"text-muted-foreground",children:r("(whole bucket)")})}),t(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=r,e[6]=n}else n=e[6];return n};export{U as StorageRulesPanel};
1
+ import{c as $}from"react/compiler-runtime";import{E as b}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as y}from"../packem_shared/badge-BbuuAio7.js";import{c as k,u as S}from"../packem_shared/card-CIDGUN6K.js";import{E as w}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as R,d as v,m as x,p as u,f as A,u as p}from"../packem_shared/table-DdJBrClo.js";import{N as E}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as t,jsxs as f}from"react/jsx-runtime";const C=(e,r)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[r],N={delete:2,list:3,read:0,write:1},T=e=>[...e].toSorted((r,s)=>r.bucket.localeCompare(s.bucket)||N[r.on]-N[s.on]||(r.prefix??"").localeCompare(s.prefix??"")),U=()=>{const e=$(14),r=j();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:i,errorSource:d}=E(I.storageRules,s),h=l!==void 0;let n;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==r){const g=T(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==i||e[8]!==d?(c=i!==null&&t(b,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=c):c=e[9];let a;e[10]!==r?(a=r("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=r,e[11]=a):a=e[11];let m;e[12]!==a?(m=t("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:a}),e[12]=a,e[13]=m):m=e[13],n=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&g.length===0?t(w,{description:r("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:r("No storage rules defined")}):t(k,{className:"overflow-hidden py-0",children:t(S,{className:"px-0",children:f(R,{"data-testid":"storage-rules-table",children:[t(v,{children:f(x,{children:[t(u,{children:r("Bucket")}),t(u,{children:r("Operation")}),t(u,{children:r("Key prefix")}),t(u,{children:r("Guarded by")})]})}),t(A,{children:g.map(o=>f(x,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[t(p,{className:"font-mono text-xs",children:o.bucket}),t(p,{children:t(y,{variant:"secondary",children:C(r,o.on)})}),t(p,{className:"font-mono text-xs",children:o.prefix??t("span",{className:"text-muted-foreground",children:r("(whole bucket)")})}),t(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=r,e[6]=n}else n=e[6];return n};export{U as StorageRulesPanel};