@lunora/studio 1.0.0-alpha.322 → 1.0.0-alpha.324

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 (99) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  3. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  4. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  5. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  6. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  7. package/dist/packem_chunks/MailPanel.mjs +1 -1
  8. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  9. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  10. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  11. package/dist/packem_chunks/agents-panel.mjs +1 -1
  12. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  13. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  14. package/dist/packem_chunks/evals-panel.mjs +1 -1
  15. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  16. package/dist/packem_chunks/flags-panel.mjs +1 -1
  17. package/dist/packem_chunks/migrations-route.mjs +1 -1
  18. package/dist/packem_chunks/payments-panel.mjs +1 -1
  19. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  20. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  21. package/dist/packem_chunks/queues-panel.mjs +1 -1
  22. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  23. package/dist/packem_chunks/rls-panel.mjs +1 -1
  24. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  25. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  26. package/dist/packem_chunks/traces-panel.mjs +1 -1
  27. package/dist/packem_shared/{MigrationsPanel-CkVIwAbK.mjs → MigrationsPanel-C2kb3oL-.mjs} +1 -1
  28. package/dist/packem_shared/{advisor-view-DzI2RQhY.mjs → advisor-view-y4cW5JcX.mjs} +1 -1
  29. package/dist/packem_shared/error-alert-DAsOWnCL.mjs +1 -0
  30. package/dist/standalone/{chunk-CKZGSVRG.js → chunk-22TUDRBR.js} +1 -1
  31. package/dist/standalone/{chunk-DBO2LRU7.js → chunk-2H5IXFGR.js} +1 -1
  32. package/dist/standalone/{chunk-MP7FGHRS.js → chunk-2JH7ZYVY.js} +1 -1
  33. package/dist/standalone/{chunk-R2JJKTII.js → chunk-2QLSWJDL.js} +1 -1
  34. package/dist/standalone/{chunk-K55GCMUG.js → chunk-3OHVDOV5.js} +1 -1
  35. package/dist/standalone/chunk-3YH5TM3G.js +1 -0
  36. package/dist/standalone/{chunk-YOJMTBDR.js → chunk-4K6CXILB.js} +1 -1
  37. package/dist/standalone/{chunk-FUS6IIPK.js → chunk-4Y5AFETG.js} +1 -1
  38. package/dist/standalone/{chunk-DWHBAXWL.js → chunk-5WOMOENH.js} +1 -1
  39. package/dist/standalone/{chunk-ZQU6EUUL.js → chunk-6MFVEI7C.js} +1 -1
  40. package/dist/standalone/{chunk-VKR53NLO.js → chunk-6YQ3RTCB.js} +1 -1
  41. package/dist/standalone/{chunk-JWTNX66E.js → chunk-7AF3FZCB.js} +1 -1
  42. package/dist/standalone/{chunk-7IN4NR3Q.js → chunk-7RAYXTNN.js} +1 -1
  43. package/dist/standalone/chunk-BOYS4DOC.js +9 -0
  44. package/dist/standalone/{chunk-ZZHEKODS.js → chunk-CUJGTNYR.js} +1 -1
  45. package/dist/standalone/{chunk-J3BTWJEN.js → chunk-DL6TTBE6.js} +1 -1
  46. package/dist/standalone/{chunk-IPQ5KYVD.js → chunk-DSIY2CMT.js} +1 -1
  47. package/dist/standalone/{chunk-Y5IYXX5E.js → chunk-EEDIMNRC.js} +1 -1
  48. package/dist/standalone/{chunk-L6AEV23T.js → chunk-ESSG4L6C.js} +1 -1
  49. package/dist/standalone/{chunk-2V47JHXK.js → chunk-EXYBVVHU.js} +1 -1
  50. package/dist/standalone/{chunk-EJ6CPRPX.js → chunk-F3UUFO2C.js} +1 -1
  51. package/dist/standalone/{chunk-62EQDW2D.js → chunk-HER5A45F.js} +1 -1
  52. package/dist/standalone/{chunk-YJFMMO37.js → chunk-HM57YJY5.js} +1 -1
  53. package/dist/standalone/{chunk-VOWSZXG7.js → chunk-HOGQLP3J.js} +1 -1
  54. package/dist/standalone/{chunk-UJANVTRM.js → chunk-ICU56FBP.js} +1 -1
  55. package/dist/standalone/{chunk-CY25HYNM.js → chunk-JL6LEVHQ.js} +1 -1
  56. package/dist/standalone/{chunk-3NBWCIGD.js → chunk-JNBWPXNV.js} +1 -1
  57. package/dist/standalone/{chunk-TQVDKDYK.js → chunk-KLTGKTSL.js} +1 -1
  58. package/dist/standalone/{chunk-QN5CM3OH.js → chunk-KU3IXE36.js} +1 -1
  59. package/dist/standalone/{chunk-HNWZRLZK.js → chunk-MB5JGSN6.js} +1 -1
  60. package/dist/standalone/{chunk-RX3SOFXA.js → chunk-MGEACGEE.js} +1 -1
  61. package/dist/standalone/{chunk-EY2JVIQL.js → chunk-MJ3SSK6L.js} +1 -1
  62. package/dist/standalone/{chunk-4WONEGEO.js → chunk-MRJB4FPI.js} +1 -1
  63. package/dist/standalone/{chunk-4DXGIJNQ.js → chunk-MTGFTTXO.js} +1 -1
  64. package/dist/standalone/{chunk-WVWG6LII.js → chunk-N7LJO732.js} +1 -1
  65. package/dist/standalone/{chunk-FT66XZJF.js → chunk-NDGHCEE3.js} +1 -1
  66. package/dist/standalone/{chunk-ZG3DITNB.js → chunk-NW6FNJ4L.js} +1 -1
  67. package/dist/standalone/{chunk-E2AT2DLH.js → chunk-NYHYH5Z5.js} +1 -1
  68. package/dist/standalone/{chunk-VDCF6PXM.js → chunk-OH7DVC7S.js} +1 -1
  69. package/dist/standalone/{chunk-WZXQIVY4.js → chunk-OK35SLOW.js} +1 -1
  70. package/dist/standalone/{chunk-FQJMIMK6.js → chunk-OM3B3V47.js} +1 -1
  71. package/dist/standalone/{chunk-DFSX67L5.js → chunk-OX6JWCPF.js} +1 -1
  72. package/dist/standalone/{chunk-V77ZHGXW.js → chunk-POKVFO6Q.js} +1 -1
  73. package/dist/standalone/{chunk-WJS62UEZ.js → chunk-QSUWAGXH.js} +1 -1
  74. package/dist/standalone/{chunk-DLVUJBD6.js → chunk-QZRKA2E4.js} +1 -1
  75. package/dist/standalone/{chunk-LIRPYTMM.js → chunk-R4ILI46D.js} +1 -1
  76. package/dist/standalone/{chunk-LWWPLBPR.js → chunk-R6PJYMJT.js} +1 -1
  77. package/dist/standalone/{chunk-DLVNLCCI.js → chunk-RBAD4SMG.js} +1 -1
  78. package/dist/standalone/{chunk-JDIDVWA7.js → chunk-RDJCY5PQ.js} +1 -1
  79. package/dist/standalone/{chunk-MRMELMIL.js → chunk-SB4443ME.js} +1 -1
  80. package/dist/standalone/{chunk-EP35WNFQ.js → chunk-SNJ5HRZO.js} +1 -1
  81. package/dist/standalone/{chunk-ZZPTGL45.js → chunk-SQ2LCZBH.js} +1 -1
  82. package/dist/standalone/{chunk-KMQTUDFK.js → chunk-TIQ7OBZJ.js} +1 -1
  83. package/dist/standalone/{chunk-P3JRWNOG.js → chunk-U4YBJ4OW.js} +1 -1
  84. package/dist/standalone/{chunk-67WMIBQI.js → chunk-UDMY3BMT.js} +1 -1
  85. package/dist/standalone/{chunk-D4GOAQJM.js → chunk-VFL7VJWF.js} +1 -1
  86. package/dist/standalone/{chunk-PL7TI67W.js → chunk-VKURTWDH.js} +1 -1
  87. package/dist/standalone/{chunk-4SANMGOJ.js → chunk-W3LXMSGC.js} +1 -1
  88. package/dist/standalone/{chunk-N76L7Y6I.js → chunk-WAX5WY6F.js} +1 -1
  89. package/dist/standalone/{chunk-HO7FAUZP.js → chunk-WFNUMMDF.js} +2 -2
  90. package/dist/standalone/{chunk-I54U4T6W.js → chunk-WJHMDTV2.js} +1 -1
  91. package/dist/standalone/{chunk-N4SDDVZW.js → chunk-WP2AS7SZ.js} +1 -1
  92. package/dist/standalone/{chunk-GKUCH3IT.js → chunk-XTQR2C6N.js} +1 -1
  93. package/dist/standalone/{chunk-6ATAM7XD.js → chunk-Z6THFOLU.js} +1 -1
  94. package/dist/standalone/{chunk-GCAGUIGJ.js → chunk-ZJQI4C3A.js} +1 -1
  95. package/dist/standalone/studio.js +1 -1
  96. package/package.json +5 -5
  97. package/dist/packem_shared/error-alert-DueSEkt-.mjs +0 -1
  98. package/dist/standalone/chunk-JSP7QF52.js +0 -9
  99. package/dist/standalone/chunk-SEZ2IRFD.js +0 -1
@@ -1 +1 @@
1
- import{c as R}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-DueSEkt-.mjs";import{B as j}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as z}from"../packem_shared/button-q0UYSmrn.mjs";import{C as D,a as M}from"../packem_shared/card-By2O8ULa.mjs";import{E as O}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as Q}from"../packem_shared/input-CXhxesPC.mjs";import{T as U,a as $,b as F,c as N,d as G,e as w}from"../packem_shared/table-D0SBiDu-.mjs";import{u as J}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as W}from"../packem_shared/internal-Df43vQI0.mjs";import{jsx as a,jsxs as l}from"react/jsx-runtime";const ne=()=>{const e=R(39),t=K(),[o,H]=k("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:L,error:i,errorSource:S,isLoading:E,refetch:B}=J(V.getAuthAuditLog,b);let A;if(e[1]!==L?.entries||e[2]!==o){const r=L?.entries??[],x=o.trim().toLowerCase();A=x===""?r:r.filter(C=>C.event.toLowerCase().includes(x)||(C.actorId??"").toLowerCase().includes(x)||(C.actorEmail??"").toLowerCase().includes(x)||(C.ip??"").toLowerCase().includes(x)||C.outcome.toLowerCase().includes(x)),e[1]=L?.entries,e[2]=o,e[3]=A}else A=e[3];const s=A;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=r=>{H(r.target.value)},e[4]=I):I=e[4];const P=I;let c;e[5]!==t?(c=t("Filter security events"),e[5]=t,e[6]=c):c=e[6];let n;e[7]!==t?(n=t("filter event, actor, IP"),e[7]=t,e[8]=n):n=e[8];let d;e[9]!==o||e[10]!==c||e[11]!==n?(d=a(Q,{"aria-label":c,className:"h-8 w-56","data-testid":"aa-search",onChange:P,placeholder:n,value:o}),e[9]=o,e[10]=c,e[11]=n,e[12]=d):d=e[12];let m;e[13]!==B?(m=()=>{B()},e[13]=B,e[14]=m):m=e[14];let u;e[15]!==t?(u=t("Refresh"),e[15]=t,e[16]=u):u=e[16];let h;e[17]!==m||e[18]!==u?(h=a(z,{"data-testid":"aa-refresh",onClick:m,size:"xs",type:"button",variant:"ghost",children:u}),e[17]=m,e[18]=u,e[19]=h):h=e[19];let f;e[20]!==d||e[21]!==h?(f=l("div",{className:"flex flex-wrap items-center gap-2",children:[d,h]}),e[20]=d,e[21]=h,e[22]=f):f=e[22];let p;e[23]!==i||e[24]!==S?(p=i!==null&&a(q,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=p):p=e[25];let g;e[26]!==i||e[27]!==s.length||e[28]!==E||e[29]!==t?(g=i===null&&!E&&s.length===0&&a(O,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=i,e[27]=s.length,e[28]=E,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==s||e[32]!==t?(v=s.length>0&&a(D,{className:"overflow-hidden py-0",children:a(M,{className:"max-h-[30rem] overflow-auto px-0",children:l(U,{"data-testid":"aa-table",children:[a($,{children:l(F,{children:[a(N,{children:t("time")}),a(N,{children:t("event")}),a(N,{children:t("actor")}),a(N,{children:t("ip / user agent")}),a(N,{children:t("outcome")})]})}),a(G,{children:s.map(r=>l(F,{"data-testid":"aa-row",children:[a(w,{className:"text-muted-foreground tabular-nums",children:W(r.ts,"—")}),a(w,{children:a(j,{variant:"secondary",children:r.event})}),a(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??a("span",{className:"text-muted-foreground",children:"—"})}),l(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??a("span",{className:"text-muted-foreground",children:"—"}),r.userAgent!==void 0&&l("span",{className:"ml-1 opacity-70",children:["· ",r.userAgent]})]}),a(w,{children:a(j,{variant:r.outcome==="failure"?"destructive":"outline",children:t(r.outcome)})})]},r.seq))})]})})}),e[31]=s,e[32]=t,e[33]=v):v=e[33];let T;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(T=l("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[f,p,g,v]}),e[34]=p,e[35]=g,e[36]=v,e[37]=f,e[38]=T):T=e[38],T};export{ne as default};
1
+ import{c as R}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{B as j}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as z}from"../packem_shared/button-q0UYSmrn.mjs";import{C as D,a as M}from"../packem_shared/card-By2O8ULa.mjs";import{E as O}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as Q}from"../packem_shared/input-CXhxesPC.mjs";import{T as U,a as $,b as F,c as N,d as G,e as w}from"../packem_shared/table-D0SBiDu-.mjs";import{u as J}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as W}from"../packem_shared/internal-Df43vQI0.mjs";import{jsx as a,jsxs as l}from"react/jsx-runtime";const ne=()=>{const e=R(39),t=K(),[o,H]=k("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:L,error:i,errorSource:S,isLoading:E,refetch:B}=J(V.getAuthAuditLog,b);let A;if(e[1]!==L?.entries||e[2]!==o){const r=L?.entries??[],x=o.trim().toLowerCase();A=x===""?r:r.filter(C=>C.event.toLowerCase().includes(x)||(C.actorId??"").toLowerCase().includes(x)||(C.actorEmail??"").toLowerCase().includes(x)||(C.ip??"").toLowerCase().includes(x)||C.outcome.toLowerCase().includes(x)),e[1]=L?.entries,e[2]=o,e[3]=A}else A=e[3];const s=A;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=r=>{H(r.target.value)},e[4]=I):I=e[4];const P=I;let c;e[5]!==t?(c=t("Filter security events"),e[5]=t,e[6]=c):c=e[6];let n;e[7]!==t?(n=t("filter event, actor, IP"),e[7]=t,e[8]=n):n=e[8];let d;e[9]!==o||e[10]!==c||e[11]!==n?(d=a(Q,{"aria-label":c,className:"h-8 w-56","data-testid":"aa-search",onChange:P,placeholder:n,value:o}),e[9]=o,e[10]=c,e[11]=n,e[12]=d):d=e[12];let m;e[13]!==B?(m=()=>{B()},e[13]=B,e[14]=m):m=e[14];let u;e[15]!==t?(u=t("Refresh"),e[15]=t,e[16]=u):u=e[16];let h;e[17]!==m||e[18]!==u?(h=a(z,{"data-testid":"aa-refresh",onClick:m,size:"xs",type:"button",variant:"ghost",children:u}),e[17]=m,e[18]=u,e[19]=h):h=e[19];let f;e[20]!==d||e[21]!==h?(f=l("div",{className:"flex flex-wrap items-center gap-2",children:[d,h]}),e[20]=d,e[21]=h,e[22]=f):f=e[22];let p;e[23]!==i||e[24]!==S?(p=i!==null&&a(q,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=p):p=e[25];let g;e[26]!==i||e[27]!==s.length||e[28]!==E||e[29]!==t?(g=i===null&&!E&&s.length===0&&a(O,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=i,e[27]=s.length,e[28]=E,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==s||e[32]!==t?(v=s.length>0&&a(D,{className:"overflow-hidden py-0",children:a(M,{className:"max-h-[30rem] overflow-auto px-0",children:l(U,{"data-testid":"aa-table",children:[a($,{children:l(F,{children:[a(N,{children:t("time")}),a(N,{children:t("event")}),a(N,{children:t("actor")}),a(N,{children:t("ip / user agent")}),a(N,{children:t("outcome")})]})}),a(G,{children:s.map(r=>l(F,{"data-testid":"aa-row",children:[a(w,{className:"text-muted-foreground tabular-nums",children:W(r.ts,"—")}),a(w,{children:a(j,{variant:"secondary",children:r.event})}),a(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??a("span",{className:"text-muted-foreground",children:"—"})}),l(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??a("span",{className:"text-muted-foreground",children:"—"}),r.userAgent!==void 0&&l("span",{className:"ml-1 opacity-70",children:["· ",r.userAgent]})]}),a(w,{children:a(j,{variant:r.outcome==="failure"?"destructive":"outline",children:t(r.outcome)})})]},r.seq))})]})})}),e[31]=s,e[32]=t,e[33]=v):v=e[33];let T;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(T=l("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[f,p,g,v]}),e[34]=p,e[35]=g,e[36]=v,e[37]=f,e[38]=T):T=e[38],T};export{ne as default};
@@ -1 +1 @@
1
- import{c as I}from"react/compiler-runtime";import{E as K}from"../packem_shared/error-alert-DueSEkt-.mjs";import{ShardInput as O}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as w}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as j}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as T}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{u as A}from"../packem_shared/use-open-trace-DMVhpnyG.mjs";import{u as k}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as R}from"../packem_shared/internal-Df43vQI0.mjs";import{S as B}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as g,jsx as c}from"react/jsx-runtime";const F=n=>n.length===0?void 0:{max:Math.max(...n),mean:n.reduce((e,t)=>e+t,0)/n.length,min:Math.min(...n)},_=/^gen_ai\.evaluation\.(.+)\.score$/u,q=n=>{const e=[];for(const t of n)for(const r of t.spans)for(const[a,l]of Object.entries(r.attributes??{})){const o=_.exec(a);if(!o||typeof l!="number")continue;const m=o[1],i=r.attributes?.[`gen_ai.evaluation.${m}.label`];e.push({...typeof i=="string"?{label:i}:{},name:m,score:l,spanName:r.name,startTs:t.startTs+r.offsetMs,traceId:t.traceId})}return e.toSorted((t,r)=>r.startTs-t.startTs)},D=n=>{const e=[];for(const t of n?.series??[]){const r=_.exec(t.name);r&&e.push({name:r[1],points:t.points})}return e},H=(n,e)=>{const t=new Set([...n.map(a=>a.name),...e.map(a=>a.name)]),r=[];for(const a of t){const l=n.filter(s=>s.name===a),o=e.find(s=>s.name===a)?.points??[],m=o.at(-1)?.last??l[0]?.score,i=o.length>0?{max:Math.max(...o.map(s=>s.max)),mean:o.reduce((s,d)=>s+d.sum,0)/o.reduce((s,d)=>s+d.count,0),min:Math.min(...o.map(s=>s.min))}:F(l.map(s=>s.score));r.push({...m===void 0?{}:{latest:m},...i,name:a,points:o,runs:l})}return r.toSorted((a,l)=>a.name.localeCompare(l.name))},L=n=>Array.isArray(n?.traces)?n.traces:[],y=n=>n===void 0?"—":n.toFixed(2),P=n=>{const e=I(34),{card:t,onOpenTrace:r}=n,a=C();let l;e[0]!==t.name?(l=c("h3",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"ev-name",children:t.name}),e[0]=t.name,e[1]=l):l=e[1];let o;e[2]!==t.latest?(o=y(t.latest),e[2]=t.latest,e[3]=o):o=e[3];let m;e[4]!==o?(m=c("span",{className:"font-mono text-lg text-foreground","data-testid":"ev-latest",children:o}),e[4]=o,e[5]=m):m=e[5];let i;e[6]!==l||e[7]!==m?(i=g("div",{className:"flex items-baseline justify-between gap-3",children:[l,m]}),e[6]=l,e[7]=m,e[8]=i):i=e[8];let s;e[9]!==t.max||e[10]!==t.mean||e[11]!==t.min||e[12]!==a?(s=a("min {min} · mean {mean} · max {max}",{max:y(t.max),mean:y(t.mean),min:y(t.min)}),e[9]=t.max,e[10]=t.mean,e[11]=t.min,e[12]=a,e[13]=s):s=e[13];let d;e[14]!==s?(d=c("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"ev-summary",children:s}),e[14]=s,e[15]=d):d=e[15];let f;e[16]!==t.name||e[17]!==t.points||e[18]!==a?(f=t.points.length>1?c(B,{ariaLabel:a("Score trend for {name}",{name:t.name}),className:"h-10 w-full",series:t.points.map(Q),testId:"ev-trend"}):c("p",{className:"text-xs text-muted-foreground","data-testid":"ev-no-trend",children:a("No durable history yet — pass ctx.metrics to recordEvaluation to chart a trend.")}),e[16]=t.name,e[17]=t.points,e[18]=a,e[19]=f):f=e[19];let u;if(e[20]!==t.runs||e[21]!==r||e[22]!==a){let x;e[24]!==r||e[25]!==a?(x=p=>g("div",{className:"flex items-center justify-between gap-2 font-mono text-xs","data-testid":"ev-run",children:[g("span",{className:"truncate text-muted-foreground",children:[R(p.startTs)," · ",p.spanName]}),g("span",{className:"flex items-center gap-2",children:[p.label===void 0?null:c(w,{variant:"outline",children:p.label}),c("span",{className:"text-foreground",children:y(p.score)}),r===void 0?null:c("button",{className:"text-muted-foreground underline-offset-2 hover:underline",onClick:()=>{r(p.traceId)},title:a("Open the trace {trace}",{trace:p.traceId}),type:"button",children:p.traceId.slice(0,8)})]})]},`${p.traceId}:${p.spanName}`),e[24]=r,e[25]=a,e[26]=x):x=e[26],u=t.runs.slice(0,5).map(x),e[20]=t.runs,e[21]=r,e[22]=a,e[23]=u}else u=e[23];let h;e[27]!==u?(h=c("div",{className:"flex flex-col gap-1",children:u}),e[27]=u,e[28]=h):h=e[28];let v;return e[29]!==i||e[30]!==d||e[31]!==f||e[32]!==h?(v=c(M,{"data-testid":"ev-card",children:g($,{className:"flex flex-col gap-3 p-4",children:[i,d,f,h]})}),e[29]=i,e[30]=d,e[31]=f,e[32]=h,e[33]=v):v=e[33],v},re=n=>{const e=I(19),{initialShardKey:t}=n,r=C(),{queryShardKey:a,setShardKey:l,shardKey:o}=k(t),m=A(a);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let s;e[1]!==a?(s={live:!0,shardKey:a},e[1]=a,e[2]=s):s=e[2];const{data:d,error:f}=T(E.getTraces,i,s);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={},e[3]=u):u=e[3];let h;e[4]!==a?(h={live:!0,shardKey:a},e[4]=a,e[5]=h):h=e[5];const{data:v}=T(E.getMetricHistory,u,h);let x;if(e[6]!==d||e[7]!==f||e[8]!==v||e[9]!==m||e[10]!==l||e[11]!==o||e[12]!==r){const p=H(q(L(d)),D(v));let N;e[14]!==l||e[15]!==o?(N=c(O,{onChange:l,testId:"ev-shard-input",value:o}),e[14]=l,e[15]=o,e[16]=N):N=e[16];let b;e[17]!==f?(b=f===null?null:c(K,{error:f,testId:"ev-error"}),e[17]=f,e[18]=b):b=e[18],x=g("section",{className:"flex flex-col gap-4","data-testid":"ev-panel",children:[N,b,p.length===0?c(j,{description:r("Call recordEvaluation from a graded run and its score shows up here."),testId:"ev-empty",title:r("No evals recorded")}):c("div",{className:"grid gap-3 md:grid-cols-2",children:p.map(S=>c(P,{card:S,onOpenTrace:m},S.name))})]}),e[6]=d,e[7]=f,e[8]=v,e[9]=m,e[10]=l,e[11]=o,e[12]=r,e[13]=x}else x=e[13];return x};function Q(n){return n.last}export{re as default};
1
+ import{c as I}from"react/compiler-runtime";import{E as K}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{ShardInput as O}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as w}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as j}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as T}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{u as A}from"../packem_shared/use-open-trace-DMVhpnyG.mjs";import{u as k}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as R}from"../packem_shared/internal-Df43vQI0.mjs";import{S as B}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as g,jsx as c}from"react/jsx-runtime";const F=n=>n.length===0?void 0:{max:Math.max(...n),mean:n.reduce((e,t)=>e+t,0)/n.length,min:Math.min(...n)},_=/^gen_ai\.evaluation\.(.+)\.score$/u,q=n=>{const e=[];for(const t of n)for(const r of t.spans)for(const[a,l]of Object.entries(r.attributes??{})){const o=_.exec(a);if(!o||typeof l!="number")continue;const m=o[1],i=r.attributes?.[`gen_ai.evaluation.${m}.label`];e.push({...typeof i=="string"?{label:i}:{},name:m,score:l,spanName:r.name,startTs:t.startTs+r.offsetMs,traceId:t.traceId})}return e.toSorted((t,r)=>r.startTs-t.startTs)},D=n=>{const e=[];for(const t of n?.series??[]){const r=_.exec(t.name);r&&e.push({name:r[1],points:t.points})}return e},H=(n,e)=>{const t=new Set([...n.map(a=>a.name),...e.map(a=>a.name)]),r=[];for(const a of t){const l=n.filter(s=>s.name===a),o=e.find(s=>s.name===a)?.points??[],m=o.at(-1)?.last??l[0]?.score,i=o.length>0?{max:Math.max(...o.map(s=>s.max)),mean:o.reduce((s,d)=>s+d.sum,0)/o.reduce((s,d)=>s+d.count,0),min:Math.min(...o.map(s=>s.min))}:F(l.map(s=>s.score));r.push({...m===void 0?{}:{latest:m},...i,name:a,points:o,runs:l})}return r.toSorted((a,l)=>a.name.localeCompare(l.name))},L=n=>Array.isArray(n?.traces)?n.traces:[],y=n=>n===void 0?"—":n.toFixed(2),P=n=>{const e=I(34),{card:t,onOpenTrace:r}=n,a=C();let l;e[0]!==t.name?(l=c("h3",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"ev-name",children:t.name}),e[0]=t.name,e[1]=l):l=e[1];let o;e[2]!==t.latest?(o=y(t.latest),e[2]=t.latest,e[3]=o):o=e[3];let m;e[4]!==o?(m=c("span",{className:"font-mono text-lg text-foreground","data-testid":"ev-latest",children:o}),e[4]=o,e[5]=m):m=e[5];let i;e[6]!==l||e[7]!==m?(i=g("div",{className:"flex items-baseline justify-between gap-3",children:[l,m]}),e[6]=l,e[7]=m,e[8]=i):i=e[8];let s;e[9]!==t.max||e[10]!==t.mean||e[11]!==t.min||e[12]!==a?(s=a("min {min} · mean {mean} · max {max}",{max:y(t.max),mean:y(t.mean),min:y(t.min)}),e[9]=t.max,e[10]=t.mean,e[11]=t.min,e[12]=a,e[13]=s):s=e[13];let d;e[14]!==s?(d=c("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"ev-summary",children:s}),e[14]=s,e[15]=d):d=e[15];let f;e[16]!==t.name||e[17]!==t.points||e[18]!==a?(f=t.points.length>1?c(B,{ariaLabel:a("Score trend for {name}",{name:t.name}),className:"h-10 w-full",series:t.points.map(Q),testId:"ev-trend"}):c("p",{className:"text-xs text-muted-foreground","data-testid":"ev-no-trend",children:a("No durable history yet — pass ctx.metrics to recordEvaluation to chart a trend.")}),e[16]=t.name,e[17]=t.points,e[18]=a,e[19]=f):f=e[19];let u;if(e[20]!==t.runs||e[21]!==r||e[22]!==a){let x;e[24]!==r||e[25]!==a?(x=p=>g("div",{className:"flex items-center justify-between gap-2 font-mono text-xs","data-testid":"ev-run",children:[g("span",{className:"truncate text-muted-foreground",children:[R(p.startTs)," · ",p.spanName]}),g("span",{className:"flex items-center gap-2",children:[p.label===void 0?null:c(w,{variant:"outline",children:p.label}),c("span",{className:"text-foreground",children:y(p.score)}),r===void 0?null:c("button",{className:"text-muted-foreground underline-offset-2 hover:underline",onClick:()=>{r(p.traceId)},title:a("Open the trace {trace}",{trace:p.traceId}),type:"button",children:p.traceId.slice(0,8)})]})]},`${p.traceId}:${p.spanName}`),e[24]=r,e[25]=a,e[26]=x):x=e[26],u=t.runs.slice(0,5).map(x),e[20]=t.runs,e[21]=r,e[22]=a,e[23]=u}else u=e[23];let h;e[27]!==u?(h=c("div",{className:"flex flex-col gap-1",children:u}),e[27]=u,e[28]=h):h=e[28];let v;return e[29]!==i||e[30]!==d||e[31]!==f||e[32]!==h?(v=c(M,{"data-testid":"ev-card",children:g($,{className:"flex flex-col gap-3 p-4",children:[i,d,f,h]})}),e[29]=i,e[30]=d,e[31]=f,e[32]=h,e[33]=v):v=e[33],v},re=n=>{const e=I(19),{initialShardKey:t}=n,r=C(),{queryShardKey:a,setShardKey:l,shardKey:o}=k(t),m=A(a);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let s;e[1]!==a?(s={live:!0,shardKey:a},e[1]=a,e[2]=s):s=e[2];const{data:d,error:f}=T(E.getTraces,i,s);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={},e[3]=u):u=e[3];let h;e[4]!==a?(h={live:!0,shardKey:a},e[4]=a,e[5]=h):h=e[5];const{data:v}=T(E.getMetricHistory,u,h);let x;if(e[6]!==d||e[7]!==f||e[8]!==v||e[9]!==m||e[10]!==l||e[11]!==o||e[12]!==r){const p=H(q(L(d)),D(v));let N;e[14]!==l||e[15]!==o?(N=c(O,{onChange:l,testId:"ev-shard-input",value:o}),e[14]=l,e[15]=o,e[16]=N):N=e[16];let b;e[17]!==f?(b=f===null?null:c(K,{error:f,testId:"ev-error"}),e[17]=f,e[18]=b):b=e[18],x=g("section",{className:"flex flex-col gap-4","data-testid":"ev-panel",children:[N,b,p.length===0?c(j,{description:r("Call recordEvaluation from a graded run and its score shows up here."),testId:"ev-empty",title:r("No evals recorded")}):c("div",{className:"grid gap-3 md:grid-cols-2",children:p.map(S=>c(P,{card:S,onOpenTrace:m},S.name))})]}),e[6]=d,e[7]=f,e[8]=v,e[9]=m,e[10]=l,e[11]=o,e[12]=r,e[13]=x}else x=e[13];return x};function Q(n){return n.last}export{re as default};
@@ -1 +1 @@
1
- import{c as R}from"react/compiler-runtime";import{E as B}from"../packem_shared/error-alert-DueSEkt-.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{S as I}from"../packem_shared/stat-card-BAv73QtB.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as _}from"../packem_shared/card-By2O8ULa.mjs";import{E as j}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as G,a as H,b as A,c as w,d as L,e as K}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Q}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as W}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{u as q}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as U}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as m,jsx as l,Fragment as z}from"react/jsx-runtime";const D=d=>`${d.toString()} ms`,J=d=>d.totalConnections===0&&d.shapePoke.passes===0&&d.whisper.passes===0&&d.shapeProbe.run===0&&d.shapeProbe.served===0&&d.globalPoll.drains===0&&d.globalPoll.pairsSkipped===0,F=d=>{const e=R(48),{counters:o,includeTiming:t,prefix:r,t:a,title:u}=d,c=`${r}-section`;let n;e[0]!==u?(n=l("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];const s=`${r}-stats`;let i;e[2]!==a?(i=a("Passes"),e[2]=a,e[3]=i):i=e[3];const f=`${r}-passes`;let N;e[4]!==o.passes||e[5]!==i||e[6]!==f?(N=l(I,{label:i,testId:f,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=f,e[7]=N):N=e[7];let g;e[8]!==a?(g=a("Sockets iterated"),e[8]=a,e[9]=g):g=e[9];const k=`${r}-iterated`;let p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=l(I,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let h;e[14]!==a?(h=a("Delivered"),e[14]=a,e[15]=h):h=e[15];const y=`${r}-delivered`;let b;e[16]!==o.socketsDelivered||e[17]!==h||e[18]!==y?(b=l(I,{label:h,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=h,e[18]=y,e[19]=b):b=e[19];let x;e[20]!==a?(x=a("Peak width"),e[20]=a,e[21]=x):x=e[21];const S=`${r}-peak`;let v;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==S?(v=l(I,{label:x,testId:S,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=S,e[25]=v):v=e[25];let C;e[26]!==o.totalMs||e[27]!==t||e[28]!==r||e[29]!==a?(C=t&&l(I,{label:a("Total time"),testId:`${r}-total-ms`,value:D(o.totalMs)}),e[26]=o.totalMs,e[27]=t,e[28]=r,e[29]=a,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==t||e[33]!==r||e[34]!==a?(P=t&&l(I,{label:a("Max time"),testId:`${r}-max-ms`,value:D(o.maxMs)}),e[31]=o.maxMs,e[32]=t,e[33]=r,e[34]=a,e[35]=P):P=e[35];let $;e[36]!==b||e[37]!==v||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==N||e[42]!==p?($=m("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[N,p,b,v,C,P]}),e[36]=b,e[37]=v,e[38]=C,e[39]=P,e[40]=s,e[41]=N,e[42]=p,e[43]=$):$=e[43];let T;return e[44]!==c||e[45]!==$||e[46]!==n?(T=m("section",{className:"flex flex-col gap-2","data-testid":c,children:[n,$]}),e[44]=c,e[45]=$,e[46]=n,e[47]=T):T=e[47],T},V=d=>{const e=R(20),{counters:o,t}=d;let r;e[0]!==t?(r=t("Membership probes"),e[0]=t,e[1]=r):r=e[1];let a;e[2]!==r?(a=l("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;e[4]!==t?(u=t("Queries run"),e[4]=t,e[5]=u):u=e[5];let c;e[6]!==o.run||e[7]!==u?(c=l(I,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=c):c=e[8];let n;e[9]!==t?(n=t("Shared from cache"),e[9]=t,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=l(I,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==c||e[15]!==s?(i=m("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[c,s]}),e[14]=c,e[15]=s,e[16]=i):i=e[16];let f;return e[17]!==a||e[18]!==i?(f=m("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[a,i]}),e[17]=a,e[18]=i,e[19]=f):f=e[19],f},X=d=>{const e=R(20),{counters:o,t}=d;let r;e[0]!==t?(r=t("Global shape polls"),e[0]=t,e[1]=r):r=e[1];let a;e[2]!==r?(a=l("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;e[4]!==t?(u=t("Global reads"),e[4]=t,e[5]=u):u=e[5];let c;e[6]!==o.drains||e[7]!==u?(c=l(I,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=c):c=e[8];let n;e[9]!==t?(n=t("Pairs skipped"),e[9]=t,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=l(I,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==c||e[15]!==s?(i=m("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[c,s]}),e[14]=c,e[15]=s,e[16]=i):i=e[16];let f;return e[17]!==a||e[18]!==i?(f=m("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[a,i]}),e[17]=a,e[18]=i,e[19]=f):f=e[19],f},me=d=>{const e=R(31),{initialShardKey:o}=d,t=O(),{queryShardKey:r,setShardKey:a,shardKey:u}=q(o);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];const{data:s,error:i,errorSource:f,refetch:N}=Q(U.getFanoutMetrics,c,n);W(N,!0);let g;e[3]!==s?(g=s!==void 0&&J(s),e[3]=s,e[4]=g):g=e[4];const k=g;let p;e[5]!==a||e[6]!==u?(p=l(E,{onChange:a,testId:"fanout-shard-input",value:u}),e[5]=a,e[6]=u,e[7]=p):p=e[7];let h;e[8]!==s||e[9]!==t?(h=s!==void 0&&m("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&l(M,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?t("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):t("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),l(M,{variant:"secondary",children:t("{count} connections",{count:s.totalConnections})}),l(M,{variant:"secondary",children:t("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=t,e[10]=h):h=e[10];let y;e[11]!==p||e[12]!==h?(y=m("div",{className:"flex flex-wrap items-center gap-2",children:[p,h]}),e[11]=p,e[12]=h,e[13]=y):y=e[13];let b;e[14]!==i||e[15]!==f?(b=i!==null&&l(B,{error:f,testId:"fanout-error"}),e[14]=i,e[15]=f,e[16]=b):b=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==t?(x=i===null&&k&&l(j,{description:t("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:l("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:l("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:t("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=t,e[20]=x):x=e[20];let S;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==t?(S=i===null&&s!==void 0&&!k&&m(z,{children:[s.topics.length>0&&m("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[l("h3",{className:"text-sm font-medium text-foreground",children:t("Hot topics")}),l(_,{className:"overflow-hidden py-0",children:m(G,{"data-testid":"fanout-topics-table",children:[l(H,{children:m(A,{children:[l(w,{children:t("Topic")}),l(w,{children:t("Kind")}),l(w,{className:"text-right",children:t("Subscribers")})]})}),l(L,{children:s.topics.map(Y)})]})})]}),m("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[l("h2",{className:"text-sm font-medium text-muted-foreground",children:t("Fan-out cost since this instance woke")}),l(F,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t,title:t("Shape pokes")}),l(F,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t,title:t("Whisper broadcasts")}),l(V,{counters:s.shapeProbe,t}),l(X,{counters:s.globalPoll,t})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=t,e[25]=S):S=e[25];let v;return e[26]!==y||e[27]!==b||e[28]!==x||e[29]!==S?(v=m("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,b,x,S]}),e[26]=y,e[27]=b,e[28]=x,e[29]=S,e[30]=v):v=e[30],v};function Y(d){return m(A,{"data-testid":"fanout-topic-row",children:[l(K,{className:"font-mono text-xs",children:d.topic}),l(K,{children:l(M,{variant:"outline",children:d.kind})}),l(K,{className:"text-right font-medium tabular-nums",children:d.subscribers})]},`${d.kind}:${d.topic}`)}export{me as default};
1
+ import{c as R}from"react/compiler-runtime";import{E as B}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{S as I}from"../packem_shared/stat-card-BAv73QtB.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as _}from"../packem_shared/card-By2O8ULa.mjs";import{E as j}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as G,a as H,b as A,c as w,d as L,e as K}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Q}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as W}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{u as q}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as U}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as m,jsx as l,Fragment as z}from"react/jsx-runtime";const D=d=>`${d.toString()} ms`,J=d=>d.totalConnections===0&&d.shapePoke.passes===0&&d.whisper.passes===0&&d.shapeProbe.run===0&&d.shapeProbe.served===0&&d.globalPoll.drains===0&&d.globalPoll.pairsSkipped===0,F=d=>{const e=R(48),{counters:o,includeTiming:t,prefix:r,t:a,title:u}=d,c=`${r}-section`;let n;e[0]!==u?(n=l("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];const s=`${r}-stats`;let i;e[2]!==a?(i=a("Passes"),e[2]=a,e[3]=i):i=e[3];const f=`${r}-passes`;let N;e[4]!==o.passes||e[5]!==i||e[6]!==f?(N=l(I,{label:i,testId:f,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=f,e[7]=N):N=e[7];let g;e[8]!==a?(g=a("Sockets iterated"),e[8]=a,e[9]=g):g=e[9];const k=`${r}-iterated`;let p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=l(I,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let h;e[14]!==a?(h=a("Delivered"),e[14]=a,e[15]=h):h=e[15];const y=`${r}-delivered`;let b;e[16]!==o.socketsDelivered||e[17]!==h||e[18]!==y?(b=l(I,{label:h,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=h,e[18]=y,e[19]=b):b=e[19];let x;e[20]!==a?(x=a("Peak width"),e[20]=a,e[21]=x):x=e[21];const S=`${r}-peak`;let v;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==S?(v=l(I,{label:x,testId:S,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=S,e[25]=v):v=e[25];let C;e[26]!==o.totalMs||e[27]!==t||e[28]!==r||e[29]!==a?(C=t&&l(I,{label:a("Total time"),testId:`${r}-total-ms`,value:D(o.totalMs)}),e[26]=o.totalMs,e[27]=t,e[28]=r,e[29]=a,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==t||e[33]!==r||e[34]!==a?(P=t&&l(I,{label:a("Max time"),testId:`${r}-max-ms`,value:D(o.maxMs)}),e[31]=o.maxMs,e[32]=t,e[33]=r,e[34]=a,e[35]=P):P=e[35];let $;e[36]!==b||e[37]!==v||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==N||e[42]!==p?($=m("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[N,p,b,v,C,P]}),e[36]=b,e[37]=v,e[38]=C,e[39]=P,e[40]=s,e[41]=N,e[42]=p,e[43]=$):$=e[43];let T;return e[44]!==c||e[45]!==$||e[46]!==n?(T=m("section",{className:"flex flex-col gap-2","data-testid":c,children:[n,$]}),e[44]=c,e[45]=$,e[46]=n,e[47]=T):T=e[47],T},V=d=>{const e=R(20),{counters:o,t}=d;let r;e[0]!==t?(r=t("Membership probes"),e[0]=t,e[1]=r):r=e[1];let a;e[2]!==r?(a=l("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;e[4]!==t?(u=t("Queries run"),e[4]=t,e[5]=u):u=e[5];let c;e[6]!==o.run||e[7]!==u?(c=l(I,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=c):c=e[8];let n;e[9]!==t?(n=t("Shared from cache"),e[9]=t,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=l(I,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==c||e[15]!==s?(i=m("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[c,s]}),e[14]=c,e[15]=s,e[16]=i):i=e[16];let f;return e[17]!==a||e[18]!==i?(f=m("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[a,i]}),e[17]=a,e[18]=i,e[19]=f):f=e[19],f},X=d=>{const e=R(20),{counters:o,t}=d;let r;e[0]!==t?(r=t("Global shape polls"),e[0]=t,e[1]=r):r=e[1];let a;e[2]!==r?(a=l("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;e[4]!==t?(u=t("Global reads"),e[4]=t,e[5]=u):u=e[5];let c;e[6]!==o.drains||e[7]!==u?(c=l(I,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=c):c=e[8];let n;e[9]!==t?(n=t("Pairs skipped"),e[9]=t,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=l(I,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==c||e[15]!==s?(i=m("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[c,s]}),e[14]=c,e[15]=s,e[16]=i):i=e[16];let f;return e[17]!==a||e[18]!==i?(f=m("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[a,i]}),e[17]=a,e[18]=i,e[19]=f):f=e[19],f},me=d=>{const e=R(31),{initialShardKey:o}=d,t=O(),{queryShardKey:r,setShardKey:a,shardKey:u}=q(o);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];const{data:s,error:i,errorSource:f,refetch:N}=Q(U.getFanoutMetrics,c,n);W(N,!0);let g;e[3]!==s?(g=s!==void 0&&J(s),e[3]=s,e[4]=g):g=e[4];const k=g;let p;e[5]!==a||e[6]!==u?(p=l(E,{onChange:a,testId:"fanout-shard-input",value:u}),e[5]=a,e[6]=u,e[7]=p):p=e[7];let h;e[8]!==s||e[9]!==t?(h=s!==void 0&&m("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&l(M,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?t("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):t("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),l(M,{variant:"secondary",children:t("{count} connections",{count:s.totalConnections})}),l(M,{variant:"secondary",children:t("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=t,e[10]=h):h=e[10];let y;e[11]!==p||e[12]!==h?(y=m("div",{className:"flex flex-wrap items-center gap-2",children:[p,h]}),e[11]=p,e[12]=h,e[13]=y):y=e[13];let b;e[14]!==i||e[15]!==f?(b=i!==null&&l(B,{error:f,testId:"fanout-error"}),e[14]=i,e[15]=f,e[16]=b):b=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==t?(x=i===null&&k&&l(j,{description:t("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:l("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:l("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:t("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=t,e[20]=x):x=e[20];let S;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==t?(S=i===null&&s!==void 0&&!k&&m(z,{children:[s.topics.length>0&&m("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[l("h3",{className:"text-sm font-medium text-foreground",children:t("Hot topics")}),l(_,{className:"overflow-hidden py-0",children:m(G,{"data-testid":"fanout-topics-table",children:[l(H,{children:m(A,{children:[l(w,{children:t("Topic")}),l(w,{children:t("Kind")}),l(w,{className:"text-right",children:t("Subscribers")})]})}),l(L,{children:s.topics.map(Y)})]})})]}),m("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[l("h2",{className:"text-sm font-medium text-muted-foreground",children:t("Fan-out cost since this instance woke")}),l(F,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t,title:t("Shape pokes")}),l(F,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t,title:t("Whisper broadcasts")}),l(V,{counters:s.shapeProbe,t}),l(X,{counters:s.globalPoll,t})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=t,e[25]=S):S=e[25];let v;return e[26]!==y||e[27]!==b||e[28]!==x||e[29]!==S?(v=m("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,b,x,S]}),e[26]=y,e[27]=b,e[28]=x,e[29]=S,e[30]=v):v=e[30],v};function Y(d){return m(A,{"data-testid":"fanout-topic-row",children:[l(K,{className:"font-mono text-xs",children:d.topic}),l(K,{children:l(M,{variant:"outline",children:d.kind})}),l(K,{className:"text-right font-medium tabular-nums",children:d.subscribers})]},`${d.kind}:${d.topic}`)}export{me as default};
@@ -1 +1 @@
1
- import{useState as C}from"react";import{E as S}from"../packem_shared/error-alert-DueSEkt-.mjs";import{B as w}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as A,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as g}from"../packem_shared/empty-state-D7jEML_T.mjs";import{L as E}from"../packem_shared/label-DKFzyHq6.mjs";import{T as O,a as F,b as x,c as s,d as j,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{T as I}from"../packem_shared/textarea--40GKAyz.mjs";import{u as J}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as L}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as l}from"react/jsx-runtime";const H=a=>{const t=a.trim();if(t.length===0)return{context:void 0,error:null};try{const o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},K='{ "targetingKey": "user-123", "plan": "premium" }',R=a=>a.type==="object"?JSON.stringify(a.value):String(a.value),W=({initialShardKey:a=""})=>{const t=L(),[o,p]=C(""),{context:c,error:f}=H(o),h=c===void 0?{}:{context:c},{data:i,error:y,errorSource:v,liveError:N}=J(B.listFlags,h,{live:!0,shardKey:a}),m=i!==void 0,b=i?.configured??!1,u=Array.isArray(i?.flags)?[...i.flags].toSorted((r,T)=>r.key.localeCompare(T.key)):[];let d;return m&&!b?d=e(g,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):m&&u.length===0?d=e(g,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=e(A,{className:"overflow-hidden py-0",children:e(k,{className:"px-0",children:l(O,{"data-testid":"flags-table",children:[e(F,{children:l(x,{children:[e(s,{children:t("Key")}),e(s,{children:t("Type")}),e(s,{children:t("Value")}),e(s,{children:t("Reason")}),e(s,{children:t("Variant")})]})}),e(j,{children:u.map(r=>l(x,{"data-testid":`flags-row-${r.key}`,children:[e(n,{className:"font-mono text-xs",children:r.key}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.type}),e(n,{className:"font-mono text-xs",children:R(r)}),e(n,{children:r.errorCode===void 0?e("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"—"}):e(w,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"—"})]},r.key))})]})})}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[y!==null&&e(S,{error:v,testId:"flags-error"}),e("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),l("div",{className:"flex flex-col gap-2",children:[e(E,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),e(I,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:r=>{p(r.target.value)},placeholder:K,rows:3,value:o}),f!==null&&e("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(f)}),N!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})};export{W as default};
1
+ import{useState as C}from"react";import{E as S}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{B as w}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as A,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as g}from"../packem_shared/empty-state-D7jEML_T.mjs";import{L as E}from"../packem_shared/label-DKFzyHq6.mjs";import{T as O,a as F,b as x,c as s,d as j,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{T as I}from"../packem_shared/textarea--40GKAyz.mjs";import{u as J}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as L}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as l}from"react/jsx-runtime";const H=a=>{const t=a.trim();if(t.length===0)return{context:void 0,error:null};try{const o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},K='{ "targetingKey": "user-123", "plan": "premium" }',R=a=>a.type==="object"?JSON.stringify(a.value):String(a.value),W=({initialShardKey:a=""})=>{const t=L(),[o,p]=C(""),{context:c,error:f}=H(o),h=c===void 0?{}:{context:c},{data:i,error:y,errorSource:v,liveError:N}=J(B.listFlags,h,{live:!0,shardKey:a}),m=i!==void 0,b=i?.configured??!1,u=Array.isArray(i?.flags)?[...i.flags].toSorted((r,T)=>r.key.localeCompare(T.key)):[];let d;return m&&!b?d=e(g,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):m&&u.length===0?d=e(g,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=e(A,{className:"overflow-hidden py-0",children:e(k,{className:"px-0",children:l(O,{"data-testid":"flags-table",children:[e(F,{children:l(x,{children:[e(s,{children:t("Key")}),e(s,{children:t("Type")}),e(s,{children:t("Value")}),e(s,{children:t("Reason")}),e(s,{children:t("Variant")})]})}),e(j,{children:u.map(r=>l(x,{"data-testid":`flags-row-${r.key}`,children:[e(n,{className:"font-mono text-xs",children:r.key}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.type}),e(n,{className:"font-mono text-xs",children:R(r)}),e(n,{children:r.errorCode===void 0?e("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"—"}):e(w,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"—"})]},r.key))})]})})}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[y!==null&&e(S,{error:v,testId:"flags-error"}),e("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),l("div",{className:"flex flex-col gap-2",children:[e(E,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),e(I,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:r=>{p(r.target.value)},placeholder:K,rows:3,value:o}),f!==null&&e("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(f)}),N!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})};export{W as default};
@@ -1 +1 @@
1
- import{c as C}from"react/compiler-runtime";import{useMemo as I,useState as Z}from"react";import{useT as L}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as j}from"../packem_shared/utils-bhneXptQ.mjs";import{MigrationsPanel as N}from"../packem_shared/MigrationsPanel-CkVIwAbK.mjs";import{useNavigate as ee,useSearch as te}from"@tanstack/react-router";import{E as ie}from"../packem_shared/error-alert-DueSEkt-.mjs";import{E as ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as R}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as se,f as oe}from"../packem_shared/internal-Df43vQI0.mjs";import{S as ae}from"../packem_shared/schema-diagram-C5oilX7l.mjs";import{jsx as c,jsxs as y}from"react/jsx-runtime";const A=1;function re(t){const e={},i=Object.keys(t);i.sort();for(const n of i)e[n]=t[n];return e}const O=t=>typeof t=="object"&&t!==null,de=t=>O(t)&&O(t.fields)&&O(t.indexes)&&O(t.relations)&&typeof t.shardMode=="string",le=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(n){return{error:`baseline is not valid JSON: ${n instanceof Error?n.message:String(n)}`,status:"invalid"}}if(!O(e)||e.version!==A||!O(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(A)})`,status:"invalid"};for(const[n,s]of Object.entries(e.tables))if(!de(s))return{error:`baseline table "${n}" 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:A},status:"ok"}},ce=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((i,n)=>i===e.fields[n]),J=t=>t.unique!==void 0,D=({nullable:t,optional:e,refined:i,unique:n,...s})=>JSON.stringify(re(s)),H=t=>({form:JSON.stringify([D(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),V=t=>t.kind==="union"&&t.members?t.members.map(e=>H(e)):[H({...t,nullable:!1,optional:!1})],me=(t,e)=>{if(e.kind!=="union")return!1;const i=V(e);return V(t).every(n=>i.some(s=>s.form===n.form&&(n.refined||!s.refined)))},x=t=>{switch(t.kind){case"array":return`array(${t.of?x(t.of):"?"})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?x(t.key):"?"}, ${t.of?x(t.of):"?"})`;case"union":return(t.members??[]).map(e=>x(e)).join(" | ");default:return t.kind}},T=(t,e,i)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:i,table:t,type:e}),q=(t,e,i)=>({remediation:"none",scope:"table",severity:"safe",summary:i,table:t,type:e}),he=(t,e,i,n,s)=>{if(!(i.kind===n.kind&&(!s||D(i)===D(n))))return s&&me(i,n)?q(t,"widenedFieldShape",`field ${t}.${e} widened: ${x(i)} → ${x(n)} — every stored value stays valid`):i.kind!==n.kind?T(t,"changedFieldKind",`field ${t}.${e} changed type: ${i.kind} → ${n.kind} — add a data migration to convert existing values`):T(t,"changedFieldShape",`field ${t}.${e} changed shape: ${x(i)} → ${x(n)} — stored values were written against the old shape; add a data migration to convert them`)},fe=(t,e,i,n)=>{const s=[];return i.unique!==n.unique&&s.push(n.unique===!0?T(t,"addedFieldConstraint",`field ${t}.${e} became unique — existing duplicates would violate it; add a data migration to de-duplicate first`):q(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),i.nullable!==n.nullable&&s.push(n.nullable===!0?q(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):T(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable — rows holding NULL would be invalid; add a data migration to backfill them`)),i.refined!==n.refined&&s.push(n.refined===!0?T(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement — stored values were never checked against it; add a data migration if any could fail`):q(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),s},Y=(t,e,i,n)=>{const s=[],a=J(i)&&J(n),o=he(t,e,i,n,a);return o&&s.push(o),a&&s.push(...fe(t,e,i,n)),i.optional&&!n.optional?s.push({remediation:"backfill",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"}):!i.optional&&n.optional&&s.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),s},ue=(t,e,i)=>i.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",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"},pe=(t,e,i,n)=>{for(const[s,a]of Object.entries(i.fields)){const o=e.fields[s];o===void 0?n.push(ue(t,s,a)):n.push(...Y(t,s,o,a))}for(const s of Object.keys(e.fields))i.fields[s]===void 0&&n.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${s} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},ge=(t,e,i,n)=>{for(const[s,a]of Object.entries(i.indexes)){const o=e.indexes[s];if(o===void 0){n.push(a.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${s} on ${t} — existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${s} on ${t}`,table:t,type:"addedIndex"});continue}ce(o,a)||n.push({remediation:"code",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))i.indexes[s]===void 0&&n.push({remediation:"code",severity:"breaking",summary:`removed index ${s} on ${t} — a query that used \`.withIndex("${s}")\` would break`,table:t,scope:"table",type:"removedIndex"})},be=(t,e,i,n)=>{for(const s of Object.keys(i.relations))e.relations[s]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${s}`,table:t,type:"addedRelation"});for(const s of Object.keys(e.relations))i.relations[s]===void 0&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${s}`,table:t,type:"removedRelation"})},G="shardBy:_unknown_",F="global",ye=(t,e)=>t===F&&e.startsWith(`${F}:`)||e===F&&t.startsWith(`${F}:`),ve=(t,e,i)=>{if(e===i)return i!==G?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it — every such key records as "${G}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!ye(e,i))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} → ${i} — its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},Q=t=>t.memory!==void 0,W=t=>t.after??0,w=t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,xe=(t,e,i)=>{if(e===void 0&&i===void 0)return;const n=r=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:"changedTtlPolicy"}),s=r=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:"changedTtlPolicy"});if(i===void 0)return s(`table ${t} dropped its TTL policy — its rows are no longer swept`);if(e===void 0)return n(`table ${t} gained a TTL policy ${w(i)} — every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${i.field}" on the rows written before it`);if(e.field!==i.field)return n(`table ${t} moved its TTL to a different column: ${w(e)} → ${w(i)} — rows are now expired by a column they were never written against; add a data migration to populate "${i.field}"`);const a=W(e),o=W(i);return o<a?n(`table ${t} shortened its TTL: ${w(e)} → ${w(i)} — rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${i.field}" on the rows that must survive`):o>a?s(`table ${t} lengthened its TTL: ${w(e)} → ${w(i)}`):void 0},ke=(t,e,i)=>{const n=[];return e.memory!==i.memory&&n.push(i.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table — every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table — its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==i.commitOrdered&&n.push(i.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() — rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() — new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),n},$e=(t,e,i,n)=>{const s=ve(t,e.shardMode,i.shardMode);if(s&&n.push(s),Q(e)&&Q(i)){n.push(...ke(t,e,i));const a=xe(t,e.ttl,i.ttl);a&&n.push(a)}pe(t,e,i,n),ge(t,e,i,n),be(t,e,i,n)},we=(t,e)=>{const i=[],n=t?.tables??{};for(const[s,a]of Object.entries(e.tables)){const o=n[s];if(o===void 0){i.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${s}`,table:s,type:"addedTable"});continue}$e(s,o,a,i)}for(const s of Object.keys(n))e.tables[s]===void 0&&i.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${s} — its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:s,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const s=t.jurisdiction??"(none)",a=e.jurisdiction??"(none)";i.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${s} to ${a} — 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:i}},B=t=>Object.entries(t.fields).map(([e,i])=>({name:e,optional:i.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:x(i)})),U=(t,e,i)=>{const n={},s=e?.fields??{},a=i?.fields??{};for(const[o,r]of Object.entries(a)){const d=s[o];d===void 0?n[o]=e===void 0?"unchanged":"added":n[o]=Y(t,o,d,r).length===0?"unchanged":"changed"}for(const o of Object.keys(s))a[o]===void 0&&(n[o]="removed");return n},Oe=(t,e)=>{const{changes:i}=we(t,e),n=new Set(i.filter(o=>o.scope==="table"&&o.table!==void 0).map(o=>o.table)),s=[],a=(o,r)=>o?"added":n.has(r)?"changed":"context";for(const[o,r]of Object.entries(e.tables)){const d=t?.tables[o],m=a(d===void 0,o);s.push({columns:B(r),fieldStatus:U(o,d,r),name:o,shardMode:r.shardMode,status:m})}for(const[o,r]of Object.entries(t?.tables??{}))e.tables[o]===void 0&&s.push({columns:B(r),fieldStatus:U(o,r,void 0),name:o,shardMode:r.shardMode,status:"removed"});return s.sort((o,r)=>o.name.localeCompare(r.name)),{breakingCount:i.filter(o=>o.severity==="breaking").length,changes:i,tables:s}},K=t=>{const e=le(t);return e.status==="ok"?e.snapshot:void 0},Se={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"},Te=t=>t==="global"||t.startsWith("global:")?"global":"shard",je=t=>{const e=C(24),{appliedAt:i,hash:n,onSelect:s,selected:a,seq:o}=t,r=a?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let d;e[0]!==r?(d=j("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]=d):d=e[1];const m=`sh-version-${n}`;let u;e[2]!==n||e[3]!==s?(u=()=>{s(n)},e[2]=n,e[3]=s,e[4]=u):u=e[4];let f;e[5]!==o?(f=y("span",{className:"font-mono text-[13px] tabular-nums",children:["v",o]}),e[5]=o,e[6]=f):f=e[6];let g;e[7]!==n?(g=n.slice(0,7),e[7]=n,e[8]=g):g=e[8];let p;e[9]!==g?(p=c("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:g}),e[9]=g,e[10]=p):p=e[10];let h;e[11]!==f||e[12]!==p?(h=y("span",{className:"flex w-full items-baseline gap-2",children:[f,p]}),e[11]=f,e[12]=p,e[13]=h):h=e[13];let b;e[14]!==i?(b=se(i),e[14]=i,e[15]=b):b=e[15];let v;e[16]!==b?(v=c("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=v):v=e[17];let k;return e[18]!==v||e[19]!==d||e[20]!==m||e[21]!==u||e[22]!==h?(k=c("li",{children:y("button",{className:d,"data-testid":m,onClick:u,type:"button",children:[h,v]})}),e[18]=v,e[19]=d,e[20]=m,e[21]=u,e[22]=h,e[23]=k):k=e[23],k},Fe=t=>{const e=C(26),{breaking:i,count:n,first:s}=t,a=L();if(s){let p;e[0]!==n?(p=c("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let h;e[2]!==a?(h=a("tables"),e[2]=a,e[3]=h):h=e[3];let b;e[4]!==h?(b=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:h}),e[4]=h,e[5]=b):b=e[5];let v;return e[6]!==p||e[7]!==b?(v=y("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=v):v=e[8],v}const o=i>0&&"text-destructive";let r;e[9]!==o?(r=j("text-3xl leading-none font-light tracking-tight tabular-nums",o),e[9]=o,e[10]=r):r=e[10];let d;e[11]!==n||e[12]!==r?(d=c("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=d):d=e[13];let m;e[14]!==n||e[15]!==a?(m=a(n===1?"change":"changes"),e[14]=n,e[15]=a,e[16]=m):m=e[16];let u;e[17]!==m?(u=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:m}),e[17]=m,e[18]=u):u=e[18];let f;e[19]!==i||e[20]!==a?(f=i>0&&y("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",a("{count} breaking",{count:i})]}),e[19]=i,e[20]=a,e[21]=f):f=e[21];let g;return e[22]!==d||e[23]!==u||e[24]!==f?(g=y("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[d,u,f]}),e[22]=d,e[23]=u,e[24]=f,e[25]=g):g=e[25],g},z={addedFieldConstraint:{action:"added",kind:"constraint"},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"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field → wider"}},qe=(t,e)=>{const i=`${z[t.type].action} ${e} `;return t.summary.startsWith(i)?t.summary.slice(i.length):t.summary},Ce=t=>{const e=new Map;for(const n of t){const s=n.table??"",a=e.get(s);a===void 0?e.set(s,[n]):a.push(n)}const i=[...e].map(([n,s])=>({changes:s,table:n}));return[...i.filter(n=>n.table!==""),...i.filter(n=>n.table==="")]},Me=t=>{const e=C(2),{children:i}=t;let n;return e[0]!==i?(n=c("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:i}),e[0]=i,e[1]=n):n=e[1],n},Ie=({pane:t,shardKey:e=""})=>{const i=L(),n=ee(),a=te({strict:!1}).version,o=l=>{oe(n({search:{version:l},to:"/migrations"}))},r=R(E.schemaHistory,{},{shardKey:e}),d=r.data?.versions??[],m=a!==void 0&&d.some(l=>l.hash===a)?a:d[0]?.hash,u=d.findIndex(l=>l.hash===m),f=u===-1?void 0:d[u+1]?.hash,g=R(E.schemaVersion,{hash:m??""},{enabled:m!==void 0,shardKey:e}),p=R(E.schemaVersion,{hash:f??""},{enabled:f!==void 0,shardKey:e}),h=I(()=>{const l=K(g.data?.version?.snapshotJson);if(l!==void 0)return Oe(K(p.data?.version?.snapshotJson),l)},[g.data,p.data]),b=I(()=>(h?.tables??[]).map(l=>({columns:l.columns,name:l.name,tier:Te(l.shardMode)})),[h]),v=I(()=>{const l={};for(const S of h?.tables??[])l[S.name]=Se[S.status];return l},[h]);if(r.error!==null)return c(ie,{error:r.errorSource,testId:"sh-error"});if(d.length===0)return c(ne,{description:i("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:i("No schema versions recorded yet.")});const k=h?.changes??[];return y("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[y("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[c(Me,{children:i("Schema versions")}),c("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(l=>c(je,{appliedAt:l.appliedAt,hash:l.hash,onSelect:o,selected:l.hash===m,seq:l.seq},l.hash))})]}),y("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[c(Fe,{breaking:h?.breakingCount??0,count:f===void 0?b.length:k.length,first:f===void 0}),t==="diagram"?c("div",{className:"flex min-h-0 flex-1 flex-col",children:c(ae,{fill:!0,nodeClasses:v,tables:b,testIdPrefix:"sh"})}):c("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Ce(k).map(l=>{const S=(h?.tables??[]).find($=>$.name===l.table);return y("section",{className:"mb-6",children:[y("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[c("span",{className:"font-mono text-[13px] text-foreground",children:l.table===""?i("schema"):l.table}),S!==void 0&&c("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:i("{count} columns",{count:S.columns.length})}),l.changes.length>1&&c("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:l.changes.length})]}),c("ul",{children:l.changes.map($=>{const{action:X,kind:P}=z[$.type],M=$.severity==="breaking",_=qe($,P);return y("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[c("span",{"aria-hidden":"true",className:j("-ms-3 h-3 w-0.5 shrink-0 self-center",M?"bg-destructive":"bg-transparent")}),y("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[i(X)," ",P]}),_!==l.table&&c("span",{className:j("min-w-0 font-mono text-[13px]",M?"text-destructive":"text-foreground"),children:_}),M&&c("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:i("breaking")})]},`${$.type}-${$.summary}`)})})]},l.table)})})]})]})},Re=t=>j("-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"),Ue=t=>{const e=C(11),{initialShardKey:i}=t,n=L(),[s,a]=Z("diagram");let o;e[0]!==s?(o=(f,g,p,h)=>y("button",{"aria-selected":s===f,className:Re(s===f),"data-testid":p,onClick:()=>{a(f)},role:"tab",type:"button",children:[g,h!==void 0&&c("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:h})]}),e[0]=s,e[1]=o):o=e[1];const r=o;let d;e[2]!==n||e[3]!==r?(d=y("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]=d):d=e[4];let m;e[5]!==i||e[6]!==s?(m=c("div",{className:"flex min-h-0 flex-1 flex-col",children:s==="data"?c("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:c(N,{initialShardKey:i})}):c(Ie,{pane:s,shardKey:i})}),e[5]=i,e[6]=s,e[7]=m):m=e[7];let u;return e[8]!==d||e[9]!==m?(u=y("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[d,m]}),e[8]=d,e[9]=m,e[10]=u):u=e[10],u};export{Ue as default};
1
+ import{c as C}from"react/compiler-runtime";import{useMemo as I,useState as Z}from"react";import{useT as L}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as j}from"../packem_shared/utils-bhneXptQ.mjs";import{MigrationsPanel as N}from"../packem_shared/MigrationsPanel-C2kb3oL-.mjs";import{useNavigate as ee,useSearch as te}from"@tanstack/react-router";import{E as ie}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{E as ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as R}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as se,f as oe}from"../packem_shared/internal-Df43vQI0.mjs";import{S as ae}from"../packem_shared/schema-diagram-C5oilX7l.mjs";import{jsx as c,jsxs as y}from"react/jsx-runtime";const A=1;function re(t){const e={},i=Object.keys(t);i.sort();for(const n of i)e[n]=t[n];return e}const O=t=>typeof t=="object"&&t!==null,de=t=>O(t)&&O(t.fields)&&O(t.indexes)&&O(t.relations)&&typeof t.shardMode=="string",le=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(n){return{error:`baseline is not valid JSON: ${n instanceof Error?n.message:String(n)}`,status:"invalid"}}if(!O(e)||e.version!==A||!O(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(A)})`,status:"invalid"};for(const[n,s]of Object.entries(e.tables))if(!de(s))return{error:`baseline table "${n}" 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:A},status:"ok"}},ce=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((i,n)=>i===e.fields[n]),J=t=>t.unique!==void 0,D=({nullable:t,optional:e,refined:i,unique:n,...s})=>JSON.stringify(re(s)),H=t=>({form:JSON.stringify([D(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),V=t=>t.kind==="union"&&t.members?t.members.map(e=>H(e)):[H({...t,nullable:!1,optional:!1})],me=(t,e)=>{if(e.kind!=="union")return!1;const i=V(e);return V(t).every(n=>i.some(s=>s.form===n.form&&(n.refined||!s.refined)))},x=t=>{switch(t.kind){case"array":return`array(${t.of?x(t.of):"?"})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?x(t.key):"?"}, ${t.of?x(t.of):"?"})`;case"union":return(t.members??[]).map(e=>x(e)).join(" | ");default:return t.kind}},T=(t,e,i)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:i,table:t,type:e}),q=(t,e,i)=>({remediation:"none",scope:"table",severity:"safe",summary:i,table:t,type:e}),he=(t,e,i,n,s)=>{if(!(i.kind===n.kind&&(!s||D(i)===D(n))))return s&&me(i,n)?q(t,"widenedFieldShape",`field ${t}.${e} widened: ${x(i)} → ${x(n)} — every stored value stays valid`):i.kind!==n.kind?T(t,"changedFieldKind",`field ${t}.${e} changed type: ${i.kind} → ${n.kind} — add a data migration to convert existing values`):T(t,"changedFieldShape",`field ${t}.${e} changed shape: ${x(i)} → ${x(n)} — stored values were written against the old shape; add a data migration to convert them`)},fe=(t,e,i,n)=>{const s=[];return i.unique!==n.unique&&s.push(n.unique===!0?T(t,"addedFieldConstraint",`field ${t}.${e} became unique — existing duplicates would violate it; add a data migration to de-duplicate first`):q(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),i.nullable!==n.nullable&&s.push(n.nullable===!0?q(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):T(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable — rows holding NULL would be invalid; add a data migration to backfill them`)),i.refined!==n.refined&&s.push(n.refined===!0?T(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement — stored values were never checked against it; add a data migration if any could fail`):q(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),s},Y=(t,e,i,n)=>{const s=[],a=J(i)&&J(n),o=he(t,e,i,n,a);return o&&s.push(o),a&&s.push(...fe(t,e,i,n)),i.optional&&!n.optional?s.push({remediation:"backfill",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"}):!i.optional&&n.optional&&s.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),s},ue=(t,e,i)=>i.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",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"},pe=(t,e,i,n)=>{for(const[s,a]of Object.entries(i.fields)){const o=e.fields[s];o===void 0?n.push(ue(t,s,a)):n.push(...Y(t,s,o,a))}for(const s of Object.keys(e.fields))i.fields[s]===void 0&&n.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${s} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},ge=(t,e,i,n)=>{for(const[s,a]of Object.entries(i.indexes)){const o=e.indexes[s];if(o===void 0){n.push(a.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${s} on ${t} — existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${s} on ${t}`,table:t,type:"addedIndex"});continue}ce(o,a)||n.push({remediation:"code",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))i.indexes[s]===void 0&&n.push({remediation:"code",severity:"breaking",summary:`removed index ${s} on ${t} — a query that used \`.withIndex("${s}")\` would break`,table:t,scope:"table",type:"removedIndex"})},be=(t,e,i,n)=>{for(const s of Object.keys(i.relations))e.relations[s]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${s}`,table:t,type:"addedRelation"});for(const s of Object.keys(e.relations))i.relations[s]===void 0&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${s}`,table:t,type:"removedRelation"})},G="shardBy:_unknown_",F="global",ye=(t,e)=>t===F&&e.startsWith(`${F}:`)||e===F&&t.startsWith(`${F}:`),ve=(t,e,i)=>{if(e===i)return i!==G?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it — every such key records as "${G}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!ye(e,i))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} → ${i} — its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},Q=t=>t.memory!==void 0,W=t=>t.after??0,w=t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,xe=(t,e,i)=>{if(e===void 0&&i===void 0)return;const n=r=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:"changedTtlPolicy"}),s=r=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:"changedTtlPolicy"});if(i===void 0)return s(`table ${t} dropped its TTL policy — its rows are no longer swept`);if(e===void 0)return n(`table ${t} gained a TTL policy ${w(i)} — every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${i.field}" on the rows written before it`);if(e.field!==i.field)return n(`table ${t} moved its TTL to a different column: ${w(e)} → ${w(i)} — rows are now expired by a column they were never written against; add a data migration to populate "${i.field}"`);const a=W(e),o=W(i);return o<a?n(`table ${t} shortened its TTL: ${w(e)} → ${w(i)} — rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${i.field}" on the rows that must survive`):o>a?s(`table ${t} lengthened its TTL: ${w(e)} → ${w(i)}`):void 0},ke=(t,e,i)=>{const n=[];return e.memory!==i.memory&&n.push(i.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table — every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table — its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==i.commitOrdered&&n.push(i.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() — rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() — new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),n},$e=(t,e,i,n)=>{const s=ve(t,e.shardMode,i.shardMode);if(s&&n.push(s),Q(e)&&Q(i)){n.push(...ke(t,e,i));const a=xe(t,e.ttl,i.ttl);a&&n.push(a)}pe(t,e,i,n),ge(t,e,i,n),be(t,e,i,n)},we=(t,e)=>{const i=[],n=t?.tables??{};for(const[s,a]of Object.entries(e.tables)){const o=n[s];if(o===void 0){i.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${s}`,table:s,type:"addedTable"});continue}$e(s,o,a,i)}for(const s of Object.keys(n))e.tables[s]===void 0&&i.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${s} — its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:s,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const s=t.jurisdiction??"(none)",a=e.jurisdiction??"(none)";i.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${s} to ${a} — 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:i}},B=t=>Object.entries(t.fields).map(([e,i])=>({name:e,optional:i.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:x(i)})),U=(t,e,i)=>{const n={},s=e?.fields??{},a=i?.fields??{};for(const[o,r]of Object.entries(a)){const d=s[o];d===void 0?n[o]=e===void 0?"unchanged":"added":n[o]=Y(t,o,d,r).length===0?"unchanged":"changed"}for(const o of Object.keys(s))a[o]===void 0&&(n[o]="removed");return n},Oe=(t,e)=>{const{changes:i}=we(t,e),n=new Set(i.filter(o=>o.scope==="table"&&o.table!==void 0).map(o=>o.table)),s=[],a=(o,r)=>o?"added":n.has(r)?"changed":"context";for(const[o,r]of Object.entries(e.tables)){const d=t?.tables[o],m=a(d===void 0,o);s.push({columns:B(r),fieldStatus:U(o,d,r),name:o,shardMode:r.shardMode,status:m})}for(const[o,r]of Object.entries(t?.tables??{}))e.tables[o]===void 0&&s.push({columns:B(r),fieldStatus:U(o,r,void 0),name:o,shardMode:r.shardMode,status:"removed"});return s.sort((o,r)=>o.name.localeCompare(r.name)),{breakingCount:i.filter(o=>o.severity==="breaking").length,changes:i,tables:s}},K=t=>{const e=le(t);return e.status==="ok"?e.snapshot:void 0},Se={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"},Te=t=>t==="global"||t.startsWith("global:")?"global":"shard",je=t=>{const e=C(24),{appliedAt:i,hash:n,onSelect:s,selected:a,seq:o}=t,r=a?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let d;e[0]!==r?(d=j("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]=d):d=e[1];const m=`sh-version-${n}`;let u;e[2]!==n||e[3]!==s?(u=()=>{s(n)},e[2]=n,e[3]=s,e[4]=u):u=e[4];let f;e[5]!==o?(f=y("span",{className:"font-mono text-[13px] tabular-nums",children:["v",o]}),e[5]=o,e[6]=f):f=e[6];let g;e[7]!==n?(g=n.slice(0,7),e[7]=n,e[8]=g):g=e[8];let p;e[9]!==g?(p=c("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:g}),e[9]=g,e[10]=p):p=e[10];let h;e[11]!==f||e[12]!==p?(h=y("span",{className:"flex w-full items-baseline gap-2",children:[f,p]}),e[11]=f,e[12]=p,e[13]=h):h=e[13];let b;e[14]!==i?(b=se(i),e[14]=i,e[15]=b):b=e[15];let v;e[16]!==b?(v=c("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=v):v=e[17];let k;return e[18]!==v||e[19]!==d||e[20]!==m||e[21]!==u||e[22]!==h?(k=c("li",{children:y("button",{className:d,"data-testid":m,onClick:u,type:"button",children:[h,v]})}),e[18]=v,e[19]=d,e[20]=m,e[21]=u,e[22]=h,e[23]=k):k=e[23],k},Fe=t=>{const e=C(26),{breaking:i,count:n,first:s}=t,a=L();if(s){let p;e[0]!==n?(p=c("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let h;e[2]!==a?(h=a("tables"),e[2]=a,e[3]=h):h=e[3];let b;e[4]!==h?(b=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:h}),e[4]=h,e[5]=b):b=e[5];let v;return e[6]!==p||e[7]!==b?(v=y("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=v):v=e[8],v}const o=i>0&&"text-destructive";let r;e[9]!==o?(r=j("text-3xl leading-none font-light tracking-tight tabular-nums",o),e[9]=o,e[10]=r):r=e[10];let d;e[11]!==n||e[12]!==r?(d=c("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=d):d=e[13];let m;e[14]!==n||e[15]!==a?(m=a(n===1?"change":"changes"),e[14]=n,e[15]=a,e[16]=m):m=e[16];let u;e[17]!==m?(u=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:m}),e[17]=m,e[18]=u):u=e[18];let f;e[19]!==i||e[20]!==a?(f=i>0&&y("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",a("{count} breaking",{count:i})]}),e[19]=i,e[20]=a,e[21]=f):f=e[21];let g;return e[22]!==d||e[23]!==u||e[24]!==f?(g=y("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[d,u,f]}),e[22]=d,e[23]=u,e[24]=f,e[25]=g):g=e[25],g},z={addedFieldConstraint:{action:"added",kind:"constraint"},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"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field → wider"}},qe=(t,e)=>{const i=`${z[t.type].action} ${e} `;return t.summary.startsWith(i)?t.summary.slice(i.length):t.summary},Ce=t=>{const e=new Map;for(const n of t){const s=n.table??"",a=e.get(s);a===void 0?e.set(s,[n]):a.push(n)}const i=[...e].map(([n,s])=>({changes:s,table:n}));return[...i.filter(n=>n.table!==""),...i.filter(n=>n.table==="")]},Me=t=>{const e=C(2),{children:i}=t;let n;return e[0]!==i?(n=c("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:i}),e[0]=i,e[1]=n):n=e[1],n},Ie=({pane:t,shardKey:e=""})=>{const i=L(),n=ee(),a=te({strict:!1}).version,o=l=>{oe(n({search:{version:l},to:"/migrations"}))},r=R(E.schemaHistory,{},{shardKey:e}),d=r.data?.versions??[],m=a!==void 0&&d.some(l=>l.hash===a)?a:d[0]?.hash,u=d.findIndex(l=>l.hash===m),f=u===-1?void 0:d[u+1]?.hash,g=R(E.schemaVersion,{hash:m??""},{enabled:m!==void 0,shardKey:e}),p=R(E.schemaVersion,{hash:f??""},{enabled:f!==void 0,shardKey:e}),h=I(()=>{const l=K(g.data?.version?.snapshotJson);if(l!==void 0)return Oe(K(p.data?.version?.snapshotJson),l)},[g.data,p.data]),b=I(()=>(h?.tables??[]).map(l=>({columns:l.columns,name:l.name,tier:Te(l.shardMode)})),[h]),v=I(()=>{const l={};for(const S of h?.tables??[])l[S.name]=Se[S.status];return l},[h]);if(r.error!==null)return c(ie,{error:r.errorSource,testId:"sh-error"});if(d.length===0)return c(ne,{description:i("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:i("No schema versions recorded yet.")});const k=h?.changes??[];return y("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[y("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[c(Me,{children:i("Schema versions")}),c("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(l=>c(je,{appliedAt:l.appliedAt,hash:l.hash,onSelect:o,selected:l.hash===m,seq:l.seq},l.hash))})]}),y("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[c(Fe,{breaking:h?.breakingCount??0,count:f===void 0?b.length:k.length,first:f===void 0}),t==="diagram"?c("div",{className:"flex min-h-0 flex-1 flex-col",children:c(ae,{fill:!0,nodeClasses:v,tables:b,testIdPrefix:"sh"})}):c("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Ce(k).map(l=>{const S=(h?.tables??[]).find($=>$.name===l.table);return y("section",{className:"mb-6",children:[y("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[c("span",{className:"font-mono text-[13px] text-foreground",children:l.table===""?i("schema"):l.table}),S!==void 0&&c("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:i("{count} columns",{count:S.columns.length})}),l.changes.length>1&&c("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:l.changes.length})]}),c("ul",{children:l.changes.map($=>{const{action:X,kind:P}=z[$.type],M=$.severity==="breaking",_=qe($,P);return y("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[c("span",{"aria-hidden":"true",className:j("-ms-3 h-3 w-0.5 shrink-0 self-center",M?"bg-destructive":"bg-transparent")}),y("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[i(X)," ",P]}),_!==l.table&&c("span",{className:j("min-w-0 font-mono text-[13px]",M?"text-destructive":"text-foreground"),children:_}),M&&c("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:i("breaking")})]},`${$.type}-${$.summary}`)})})]},l.table)})})]})]})},Re=t=>j("-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"),Ue=t=>{const e=C(11),{initialShardKey:i}=t,n=L(),[s,a]=Z("diagram");let o;e[0]!==s?(o=(f,g,p,h)=>y("button",{"aria-selected":s===f,className:Re(s===f),"data-testid":p,onClick:()=>{a(f)},role:"tab",type:"button",children:[g,h!==void 0&&c("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:h})]}),e[0]=s,e[1]=o):o=e[1];const r=o;let d;e[2]!==n||e[3]!==r?(d=y("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]=d):d=e[4];let m;e[5]!==i||e[6]!==s?(m=c("div",{className:"flex min-h-0 flex-1 flex-col",children:s==="data"?c("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:c(N,{initialShardKey:i})}):c(Ie,{pane:s,shardKey:i})}),e[5]=i,e[6]=s,e[7]=m):m=e[7];let u;return e[8]!==d||e[9]!==m?(u=y("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[d,m]}),e[8]=d,e[9]=m,e[10]=u):u=e[10],u};export{Ue as default};
@@ -1 +1 @@
1
- import{decodeDocument as D}from"@lunora/wire";import{E as F}from"../packem_shared/error-alert-DueSEkt-.mjs";import{B as E}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as x,a as A}from"../packem_shared/card-By2O8ULa.mjs";import{E as I}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as P,a as V,b as g,c as m,d as C,e as o}from"../packem_shared/table-D0SBiDu-.mjs";import{u as h}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as H}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{u as M}from"../packem_shared/home-panel-BcE8S2Nn.mjs";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as b}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as B}from"../packem_shared/internal-Df43vQI0.mjs";import{jsx as e,jsxs as d}from"react/jsx-runtime";const T="payment_subscriptions",R="payment_events",k=[T,R],G={},N=new Set(["active","trialing"]),Y=new Set(["past_due","unpaid"]),a=(n,r)=>{if(n[r]!==void 0)return n[r];const p=n.__doc__;return typeof p=="string"?D(p)?.[r]:void 0},s=n=>typeof n=="string"?n:typeof n=="number"||typeof n=="bigint"||typeof n=="boolean"?String(n):"",q=n=>N.has(n)?"default":Y.has(n)?"destructive":"outline",oe=({limit:n=100})=>{const r=U(),p=M(),{data:y}=h(b.listTables,G,{live:!0}),_=y!==void 0,w=Array.isArray(y)&&k.every(t=>y.some(c=>c.name===t)),l=p.payments&&w,i=h(b.readTablePage,{filters:[],limit:n,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:T},{enabled:l}),u=h(b.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:R},{enabled:l}),v=h(b.facetColumn,{column:"state",table:T},{enabled:l});H(()=>{l&&(i.refetch(),u.refetch(),v.refetch())},!0);const f=i.data?.rows??[],L=u.data?.rows??[],O=i.error??u.error,Q=i.error===null?u.errorSource:i.errorSource,j=i.data?.total??f.length,S=v.data?.values===void 0?f.filter(t=>N.has(s(a(t,"state")))).length:v.data.values.reduce((t,c)=>t+(N.has(s(c.value))?c.count:0),0);return _&&!l?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(I,{description:r("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:r("No payments configured")})}):d("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:d(x,{className:"justify-between gap-0 py-0",children:[d("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:r("Subscriptions")}),d("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:S}),e(E,{variant:"default",children:r("{count} active",{count:S})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r("{total} total",{total:j})})]})}),O===null?void 0:e(F,{error:Q}),f.length===0&&!i.isLoading?e(I,{testId:"payments-empty",title:r("No subscriptions yet")}):e(x,{className:"overflow-hidden py-0",children:e(A,{className:"px-0",children:d(P,{children:[e(V,{children:d(g,{children:[e(m,{children:r("Provider")}),e(m,{children:r("Reference")}),e(m,{children:r("Plan")}),e(m,{children:r("State")}),e(m,{children:r("Renews")})]})}),e(C,{children:f.map(t=>{const c=s(a(t,"state"));return d(g,{"data-testid":"payment-subscription-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{children:s(a(t,"referenceId"))}),e(o,{children:s(a(t,"priceId"))}),e(o,{children:e(E,{variant:q(c),children:c})}),e(o,{children:B(a(t,"currentPeriodEnd"))})]},s(a(t,"providerSubscriptionId")))})})]})})}),d(x,{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:r("Recent webhook events")})}),e(A,{className:"px-0",children:e(P,{children:e(C,{children:L.map(t=>d(g,{"data-testid":"payment-event-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{className:"font-medium",children:s(a(t,"type"))}),e(o,{className:"text-muted-foreground",children:s(a(t,"providerEventId"))}),e(o,{children:B(a(t,"processedAt"))})]},s(a(t,"providerEventId"))))})})})]})]})};export{oe as PaymentsPanel};
1
+ import{decodeDocument as D}from"@lunora/wire";import{E as F}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{B as E}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as x,a as A}from"../packem_shared/card-By2O8ULa.mjs";import{E as I}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as P,a as V,b as g,c as m,d as C,e as o}from"../packem_shared/table-D0SBiDu-.mjs";import{u as h}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as H}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{u as M}from"../packem_shared/home-panel-BcE8S2Nn.mjs";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as b}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as B}from"../packem_shared/internal-Df43vQI0.mjs";import{jsx as e,jsxs as d}from"react/jsx-runtime";const T="payment_subscriptions",R="payment_events",k=[T,R],G={},N=new Set(["active","trialing"]),Y=new Set(["past_due","unpaid"]),a=(n,r)=>{if(n[r]!==void 0)return n[r];const p=n.__doc__;return typeof p=="string"?D(p)?.[r]:void 0},s=n=>typeof n=="string"?n:typeof n=="number"||typeof n=="bigint"||typeof n=="boolean"?String(n):"",q=n=>N.has(n)?"default":Y.has(n)?"destructive":"outline",oe=({limit:n=100})=>{const r=U(),p=M(),{data:y}=h(b.listTables,G,{live:!0}),_=y!==void 0,w=Array.isArray(y)&&k.every(t=>y.some(c=>c.name===t)),l=p.payments&&w,i=h(b.readTablePage,{filters:[],limit:n,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:T},{enabled:l}),u=h(b.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:R},{enabled:l}),v=h(b.facetColumn,{column:"state",table:T},{enabled:l});H(()=>{l&&(i.refetch(),u.refetch(),v.refetch())},!0);const f=i.data?.rows??[],L=u.data?.rows??[],O=i.error??u.error,Q=i.error===null?u.errorSource:i.errorSource,j=i.data?.total??f.length,S=v.data?.values===void 0?f.filter(t=>N.has(s(a(t,"state")))).length:v.data.values.reduce((t,c)=>t+(N.has(s(c.value))?c.count:0),0);return _&&!l?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(I,{description:r("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:r("No payments configured")})}):d("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:d(x,{className:"justify-between gap-0 py-0",children:[d("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:r("Subscriptions")}),d("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:S}),e(E,{variant:"default",children:r("{count} active",{count:S})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r("{total} total",{total:j})})]})}),O===null?void 0:e(F,{error:Q}),f.length===0&&!i.isLoading?e(I,{testId:"payments-empty",title:r("No subscriptions yet")}):e(x,{className:"overflow-hidden py-0",children:e(A,{className:"px-0",children:d(P,{children:[e(V,{children:d(g,{children:[e(m,{children:r("Provider")}),e(m,{children:r("Reference")}),e(m,{children:r("Plan")}),e(m,{children:r("State")}),e(m,{children:r("Renews")})]})}),e(C,{children:f.map(t=>{const c=s(a(t,"state"));return d(g,{"data-testid":"payment-subscription-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{children:s(a(t,"referenceId"))}),e(o,{children:s(a(t,"priceId"))}),e(o,{children:e(E,{variant:q(c),children:c})}),e(o,{children:B(a(t,"currentPeriodEnd"))})]},s(a(t,"providerSubscriptionId")))})})]})})}),d(x,{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:r("Recent webhook events")})}),e(A,{className:"px-0",children:e(P,{children:e(C,{children:L.map(t=>d(g,{"data-testid":"payment-event-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{className:"font-medium",children:s(a(t,"type"))}),e(o,{className:"text-muted-foreground",children:s(a(t,"providerEventId"))}),e(o,{children:B(a(t,"processedAt"))})]},s(a(t,"providerEventId"))))})})})]})]})};export{oe as PaymentsPanel};
@@ -1 +1 @@
1
- import{useState as h,useRef as se,useEffect as oe}from"react";import{c as xe,d as ye,b as be,a as de,C as me}from"../packem_shared/card-By2O8ULa.mjs";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as fe}from"react/compiler-runtime";import{E as ge}from"../packem_shared/error-alert-DueSEkt-.mjs";import{L as ve}from"../packem_shared/live-status-BuJdUZFU.mjs";import{B as $}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as L}from"../packem_shared/button-q0UYSmrn.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as ie,c as te,d as Se,e as ae}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{ADMIN_FUNCTIONS as X}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{useLunora as ue}from"@lunora/react";import{decodeWire as Ce}from"@lunora/wire";import{ShardInput as we}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{I as J}from"../packem_shared/input-CXhxesPC.mjs";import{L as U}from"../packem_shared/label-DKFzyHq6.mjs";import{T as Pe}from"../packem_shared/textarea--40GKAyz.mjs";import{d as Ae,c as Ee,b as Te,f as le,j as _e}from"../packem_shared/internal-Df43vQI0.mjs";const ne=["read","insert","update","delete"],Ie=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Re=e=>e.file===""?e.procedure:`${e.file}:${e.procedure}`,Fe=e=>{const t=new Set;for(const s of e?.advisories??[])if(s.name==="rls_uncovered_table"){const{table:c}=s.metadata;typeof c=="string"&&c!==""&&t.add(c)}return t},Oe=(e,t,s)=>{const c=new Map,r=n=>{const o=c.get(n);if(o!==void 0)return o;const f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:s.has(n)};return c.set(n,f),f};for(const n of e)r(n.table).cells[n.on]={path:Re(n),procedure:n.procedure};for(const n of t)r(n.table).maskedColumns.add(n.column);for(const n of s)r(n);return[...c.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},De=e=>{const t=fe(17);let s;t[0]!==e?(s=e===void 0?{}:e,t[0]=e,t[1]=s):s=t[1];const{onProbe:c}=s,r=ee();let n,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},t[2]=n,t[3]=o):(n=t[2],o=t[3]);const f=re(X.rlsPolicies,n,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const b=re(X.maskPolicies,l);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u={},t[5]=u):u=t[5];const g=re(X.getAdvisories,u);let v;if(t[6]!==g.data||t[7]!==b.data||t[8]!==c||t[9]!==f||t[10]!==r){let N=null;f.data!==void 0&&(N=Array.isArray(f.data.policies)?f.data.policies:[]);const R=Array.isArray(b.data?.columns)?b.data.columns:[],M=g.data??null,{error:P,errorSource:k,liveError:A}=f,_=N===null?[]:Oe(N,R,Fe(M));let S;t[12]!==A?(S=a("div",{className:"flex items-center justify-end",children:a(ve,{message:A,prefix:"pm"})}),t[12]=A,t[13]=S):S=t[13];let p;t[14]!==P||t[15]!==k?(p=P!==null&&a(ge,{error:k,testId:"pm-error"}),t[14]=P,t[15]=k,t[16]=p):p=t[16],v=i("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[S,p,N!==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")}):i(Ne,{"data-testid":"pm-table",children:[a(ke,{children:i(ie,{children:[a(te,{children:r("Table")}),ne.map(m=>a(te,{children:Ie(r,m)},m)),a(te,{children:r("Masked columns")})]})}),a(Se,{children:_.map(m=>i(ie,{"data-testid":`pm-row-${m.table}`,children:[a(ae,{className:"font-mono text-xs",children:i("span",{className:"flex items-center gap-1.5",children:[m.table,m.uncovered&&a($,{"data-testid":`pm-uncovered-${m.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ne.map(E=>{const x=m.cells[E];return a(ae,{"data-testid":`pm-cell-${m.table}-${E}`,children:x.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):i("span",{className:"flex flex-col gap-1",children:[a($,{variant:"secondary",children:r("Covered by {procedure}",{procedure:x.procedure})}),c!==void 0&&a(L,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${m.table}-${E}`,onClick:()=>{c(m.table,E,x.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},E)}),a(ae,{children:m.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...m.maskedColumns].map(Le)})})]},m.table))})]})]}),t[6]=g.data,t[7]=b.data,t[8]=c,t[9]=f,t[10]=r,t[11]=v}else v=t[11];return v};function Le(e){return a($,{variant:"outline",children:e},e)}const $e=Ee(X.runAs),Ue=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Me=e=>{const t=e?.code;return typeof t=="string"?t:void 0},ze=()=>{const e=ue();return async({args:t,functionPath:s,shardKey:c="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const n=$e;try{return{kind:"allowed",value:await e.query(n,{args:t,functionPath:s,userId:r},Ae(c))}}catch(o){const f=o instanceof Error?o.message:String(o),l=Me(o);return l!==void 0&&Ue.has(l)?{kind:"denied",message:f}:{kind:"errored",message:f}}}},je=e=>e===void 0?"undefined":JSON.stringify(e,_e,2),qe=({functions:e,prefill:t,runAsIdentity:s=!1}={})=>{const c=ue(),r=ee(),n=ze(),[o,f]=h(null),[l,b]=h(null),u=e??o??[],[g,v]=h(""),[N,R]=h("{}"),[M,P]=h(""),[k,A]=h(""),[_,S]=h(!1),[p,m]=h(null),[E,x]=h(null),I=se(-1),C=se(0);oe(()=>{if(e!==void 0)return;let d=!1;return c.listFunctions().then(y=>(d||f(y),y)).catch(y=>{d||b(Te(y))}),()=>{d=!0}},[c,e]),oe(()=>{if(t===void 0||I.current===t.nonce)return;I.current=t.nonce,C.current+=1;const d=t.functionPath;queueMicrotask(()=>{v(d),m(null)})},[t]);const w=g===""?u[0]?.path??"":g,F=async()=>{if(w==="")return;let d;try{d=N.trim()===""?{}:Ce(JSON.parse(N))}catch(T){x(r("Invalid JSON args: {message}",{message:T.message})),m(null);return}C.current+=1;const y=C.current;x(null),S(!0);try{const T=await n({args:d,functionPath:w,shardKey:M.trim(),userId:k.trim()});y===C.current&&m(T)}finally{S(!1)}},K=()=>{le(F())},O=d=>{v(d.target.value)},D=d=>{R(d.target.value)},Y=d=>{A(d.target.value)};return i("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}),!s&&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.")}),i("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[i("div",{className:"flex flex-col gap-1.5",children:[a(U,{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:O,value:w,children:u.map(d=>i("option",{value:d.path,children:[d.path," (",d.kind,")"]},d.path))})]}),i("div",{className:"flex flex-col gap-1.5",children:[a(U,{htmlFor:"pp-args",children:r("Arguments")}),a(Pe,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:D,value:N})]}),a(we,{onChange:P,testId:"pp-shard",value:M}),i("div",{className:"flex flex-col gap-1.5",children:[a(U,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(J,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:Y,placeholder:r("Required — the identity to probe as"),value:k})]}),i("div",{className:"flex items-center gap-2",children:[a(L,{"data-testid":"pp-run",disabled:!s||_||w==="",onClick:K,type:"button",children:r(_?"Probing…":"Run probe")}),k.trim()!==""&&a($,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:k.trim()})})]})]}),E!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:E}),p!==null&&p.kind==="allowed"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a($,{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:je(p.value)})]}),p!==null&&p.kind==="invalid"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[a($,{variant:"outline",children:r("Not run")}),a("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:p.message})]}),p!==null&&p.kind==="errored"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[a($,{variant:"outline",children:r("Errored")}),a("p",{className:"text-sm text-muted-foreground",children:r("The call failed for a reason that is not an access verdict, so it says nothing about the policy.")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:p.message})]}),p!==null&&p.kind==="denied"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a($,{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:p.message})]})]})},Be="/__lunora/policy-scaffold",We={"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(Be,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),s=await t.json();if(s.needsManualEdit===!0)return{kind:"needs-manual-edit",message:s.message??"This change must be made by hand."};if(t.ok)return{diagnostics:s.diagnostics??[],kind:"ok",label:s.fileName??s.exportName??""};const c=s.error;return{kind:"error",message:c===void 0?`policy scaffold failed (${String(t.status)})`:We[c]??c}},ce={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},He=()=>{const e=fe(69),t=ee(),[s,c]=h(null),[r,n]=h(!1),[o,f]=h(null),[l,b]=h(ce);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Z=>{const H=Z.target.name,{value:G}=Z.target;b(he=>({...he,[H]:G}))},e[0]=u):u=e[0];const g=u;let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{c(null),b(ce)},e[1]=v):v=e[1];const N=v;let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R=async Z=>{n(!0),f(null);try{const H=await Qe(Z);f(H),H.kind==="ok"&&N()}catch(H){const G=H;f({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},e[2]=R):R=e[2];const M=R;let P;e[3]!==l.policyName||e[4]!==l.tableName?(P=()=>{le(M({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=P):P=e[5];const k=P;let A;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(A=()=>{le(M({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]=A):A=e[9];const _=A;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{f(null),c("scaffold")},e[10]=S):S=e[10];const p=S;let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{f(null),c("wire")},e[11]=m):m=e[11];const E=m;let x;e[12]!==t?(x=t("Scaffold access rules"),e[12]=t,e[13]=x):x=e[13];let I;e[14]!==x?(I=a(xe,{children:x}),e[14]=x,e[15]=I):I=e[15];let C;e[16]!==t?(C=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]=C):C=e[17];let w;e[18]!==C?(w=a(ye,{children:C}),e[18]=C,e[19]=w):w=e[19];let F;e[20]!==w||e[21]!==I?(F=i(be,{children:[I,w]}),e[20]=w,e[21]=I,e[22]=F):F=e[22];const K=s==="scaffold"?"default":"outline";let O;e[23]!==t?(O=t("New policy file"),e[23]=t,e[24]=O):O=e[24];let D;e[25]!==K||e[26]!==O?(D=a(L,{"data-testid":"policy-scaffolder-new",onClick:p,size:"xs",type:"button",variant:K,children:O}),e[25]=K,e[26]=O,e[27]=D):D=e[27];const Y=s==="wire"?"default":"outline";let d;e[28]!==t?(d=t("Wire into a procedure"),e[28]=t,e[29]=d):d=e[29];let y;e[30]!==Y||e[31]!==d?(y=a(L,{"data-testid":"policy-scaffolder-wire",onClick:E,size:"xs",type:"button",variant:Y,children:d}),e[30]=Y,e[31]=d,e[32]=y):y=e[32];let T;e[33]!==D||e[34]!==y?(T=i("div",{className:"flex flex-wrap gap-2",children:[D,y]}),e[33]=D,e[34]=y,e[35]=T):T=e[35];let z;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==s||e[40]!==k||e[41]!==t?(z=s==="scaffold"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(J,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:l.policyName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(J,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:l.tableName})]}),a(L,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:k,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(L,{onClick:N,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=s,e[40]=k,e[41]=t,e[42]=z):z=e[42];let j;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==s||e[48]!==_||e[49]!==t?(j=s==="wire"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(J,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:l.filePath})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(J,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:l.exportName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(J,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:l.policies})]}),a(L,{"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(L,{onClick:N,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]=s,e[48]=_,e[49]=t,e[50]=j):j=e[50];let q;e[51]!==o?(q=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]=q):q=e[52];let B;e[53]!==o?.kind||e[54]!==t?(B=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]=B):B=e[55];let W;e[56]!==o||e[57]!==t?(W=o?.kind==="ok"&&i("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(Je)})]}),e[56]=o,e[57]=t,e[58]=W):W=e[58];let Q;e[59]!==T||e[60]!==z||e[61]!==j||e[62]!==q||e[63]!==B||e[64]!==W?(Q=i(de,{children:[T,z,j,q,B,W]}),e[59]=T,e[60]=z,e[61]=j,e[62]=q,e[63]=B,e[64]=W,e[65]=Q):Q=e[65];let V;return e[66]!==F||e[67]!==Q?(V=i(me,{"data-testid":"policy-scaffolder",size:"sm",children:[F,Q]}),e[66]=F,e[67]=Q,e[68]=V):V=e[68],V};function Je(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const ut=({functions:e,runAsIdentity:t=!1,schemaEditable:s=!1}={})=>{const c=ee(),[r,n]=h(void 0),o=(f,l,b)=>{b!==""&&n(u=>({functionPath:b,nonce:(u?.nonce??0)+1}))};return i("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[i("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:c("Permissions")})}),a(De,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:i(me,{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:c("Probe")})}),i(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:c("Pick a function and an identity, then run it to see the access outcome.")}),a(qe,{functions:e,prefill:r,runAsIdentity:t})]})]})}),s&&a("section",{className:"flex flex-col gap-2",children:a(He,{})})]})};export{ut as PermissionsPanel};
1
+ import{useState as h,useRef as se,useEffect as oe}from"react";import{c as xe,d as ye,b as be,a as de,C as me}from"../packem_shared/card-By2O8ULa.mjs";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as fe}from"react/compiler-runtime";import{E as ge}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{L as ve}from"../packem_shared/live-status-BuJdUZFU.mjs";import{B as $}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as L}from"../packem_shared/button-q0UYSmrn.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as ie,c as te,d as Se,e as ae}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{ADMIN_FUNCTIONS as X}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{useLunora as ue}from"@lunora/react";import{decodeWire as Ce}from"@lunora/wire";import{ShardInput as we}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{I as J}from"../packem_shared/input-CXhxesPC.mjs";import{L as U}from"../packem_shared/label-DKFzyHq6.mjs";import{T as Pe}from"../packem_shared/textarea--40GKAyz.mjs";import{d as Ae,c as Ee,b as Te,f as le,j as _e}from"../packem_shared/internal-Df43vQI0.mjs";const ne=["read","insert","update","delete"],Ie=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Re=e=>e.file===""?e.procedure:`${e.file}:${e.procedure}`,Fe=e=>{const t=new Set;for(const s of e?.advisories??[])if(s.name==="rls_uncovered_table"){const{table:c}=s.metadata;typeof c=="string"&&c!==""&&t.add(c)}return t},Oe=(e,t,s)=>{const c=new Map,r=n=>{const o=c.get(n);if(o!==void 0)return o;const f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:s.has(n)};return c.set(n,f),f};for(const n of e)r(n.table).cells[n.on]={path:Re(n),procedure:n.procedure};for(const n of t)r(n.table).maskedColumns.add(n.column);for(const n of s)r(n);return[...c.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},De=e=>{const t=fe(17);let s;t[0]!==e?(s=e===void 0?{}:e,t[0]=e,t[1]=s):s=t[1];const{onProbe:c}=s,r=ee();let n,o;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},t[2]=n,t[3]=o):(n=t[2],o=t[3]);const f=re(X.rlsPolicies,n,o);let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l={},t[4]=l):l=t[4];const b=re(X.maskPolicies,l);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u={},t[5]=u):u=t[5];const g=re(X.getAdvisories,u);let v;if(t[6]!==g.data||t[7]!==b.data||t[8]!==c||t[9]!==f||t[10]!==r){let N=null;f.data!==void 0&&(N=Array.isArray(f.data.policies)?f.data.policies:[]);const R=Array.isArray(b.data?.columns)?b.data.columns:[],M=g.data??null,{error:P,errorSource:k,liveError:A}=f,_=N===null?[]:Oe(N,R,Fe(M));let S;t[12]!==A?(S=a("div",{className:"flex items-center justify-end",children:a(ve,{message:A,prefix:"pm"})}),t[12]=A,t[13]=S):S=t[13];let p;t[14]!==P||t[15]!==k?(p=P!==null&&a(ge,{error:k,testId:"pm-error"}),t[14]=P,t[15]=k,t[16]=p):p=t[16],v=i("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[S,p,N!==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")}):i(Ne,{"data-testid":"pm-table",children:[a(ke,{children:i(ie,{children:[a(te,{children:r("Table")}),ne.map(m=>a(te,{children:Ie(r,m)},m)),a(te,{children:r("Masked columns")})]})}),a(Se,{children:_.map(m=>i(ie,{"data-testid":`pm-row-${m.table}`,children:[a(ae,{className:"font-mono text-xs",children:i("span",{className:"flex items-center gap-1.5",children:[m.table,m.uncovered&&a($,{"data-testid":`pm-uncovered-${m.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ne.map(E=>{const x=m.cells[E];return a(ae,{"data-testid":`pm-cell-${m.table}-${E}`,children:x.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):i("span",{className:"flex flex-col gap-1",children:[a($,{variant:"secondary",children:r("Covered by {procedure}",{procedure:x.procedure})}),c!==void 0&&a(L,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${m.table}-${E}`,onClick:()=>{c(m.table,E,x.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},E)}),a(ae,{children:m.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...m.maskedColumns].map(Le)})})]},m.table))})]})]}),t[6]=g.data,t[7]=b.data,t[8]=c,t[9]=f,t[10]=r,t[11]=v}else v=t[11];return v};function Le(e){return a($,{variant:"outline",children:e},e)}const $e=Ee(X.runAs),Ue=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Me=e=>{const t=e?.code;return typeof t=="string"?t:void 0},ze=()=>{const e=ue();return async({args:t,functionPath:s,shardKey:c="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const n=$e;try{return{kind:"allowed",value:await e.query(n,{args:t,functionPath:s,userId:r},Ae(c))}}catch(o){const f=o instanceof Error?o.message:String(o),l=Me(o);return l!==void 0&&Ue.has(l)?{kind:"denied",message:f}:{kind:"errored",message:f}}}},je=e=>e===void 0?"undefined":JSON.stringify(e,_e,2),qe=({functions:e,prefill:t,runAsIdentity:s=!1}={})=>{const c=ue(),r=ee(),n=ze(),[o,f]=h(null),[l,b]=h(null),u=e??o??[],[g,v]=h(""),[N,R]=h("{}"),[M,P]=h(""),[k,A]=h(""),[_,S]=h(!1),[p,m]=h(null),[E,x]=h(null),I=se(-1),C=se(0);oe(()=>{if(e!==void 0)return;let d=!1;return c.listFunctions().then(y=>(d||f(y),y)).catch(y=>{d||b(Te(y))}),()=>{d=!0}},[c,e]),oe(()=>{if(t===void 0||I.current===t.nonce)return;I.current=t.nonce,C.current+=1;const d=t.functionPath;queueMicrotask(()=>{v(d),m(null)})},[t]);const w=g===""?u[0]?.path??"":g,F=async()=>{if(w==="")return;let d;try{d=N.trim()===""?{}:Ce(JSON.parse(N))}catch(T){x(r("Invalid JSON args: {message}",{message:T.message})),m(null);return}C.current+=1;const y=C.current;x(null),S(!0);try{const T=await n({args:d,functionPath:w,shardKey:M.trim(),userId:k.trim()});y===C.current&&m(T)}finally{S(!1)}},K=()=>{le(F())},O=d=>{v(d.target.value)},D=d=>{R(d.target.value)},Y=d=>{A(d.target.value)};return i("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}),!s&&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.")}),i("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[i("div",{className:"flex flex-col gap-1.5",children:[a(U,{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:O,value:w,children:u.map(d=>i("option",{value:d.path,children:[d.path," (",d.kind,")"]},d.path))})]}),i("div",{className:"flex flex-col gap-1.5",children:[a(U,{htmlFor:"pp-args",children:r("Arguments")}),a(Pe,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:D,value:N})]}),a(we,{onChange:P,testId:"pp-shard",value:M}),i("div",{className:"flex flex-col gap-1.5",children:[a(U,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(J,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:Y,placeholder:r("Required — the identity to probe as"),value:k})]}),i("div",{className:"flex items-center gap-2",children:[a(L,{"data-testid":"pp-run",disabled:!s||_||w==="",onClick:K,type:"button",children:r(_?"Probing…":"Run probe")}),k.trim()!==""&&a($,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:k.trim()})})]})]}),E!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:E}),p!==null&&p.kind==="allowed"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a($,{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:je(p.value)})]}),p!==null&&p.kind==="invalid"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[a($,{variant:"outline",children:r("Not run")}),a("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:p.message})]}),p!==null&&p.kind==="errored"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[a($,{variant:"outline",children:r("Errored")}),a("p",{className:"text-sm text-muted-foreground",children:r("The call failed for a reason that is not an access verdict, so it says nothing about the policy.")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:p.message})]}),p!==null&&p.kind==="denied"&&i("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a($,{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:p.message})]})]})},Be="/__lunora/policy-scaffold",We={"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(Be,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),s=await t.json();if(s.needsManualEdit===!0)return{kind:"needs-manual-edit",message:s.message??"This change must be made by hand."};if(t.ok)return{diagnostics:s.diagnostics??[],kind:"ok",label:s.fileName??s.exportName??""};const c=s.error;return{kind:"error",message:c===void 0?`policy scaffold failed (${String(t.status)})`:We[c]??c}},ce={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},He=()=>{const e=fe(69),t=ee(),[s,c]=h(null),[r,n]=h(!1),[o,f]=h(null),[l,b]=h(ce);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Z=>{const H=Z.target.name,{value:G}=Z.target;b(he=>({...he,[H]:G}))},e[0]=u):u=e[0];const g=u;let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{c(null),b(ce)},e[1]=v):v=e[1];const N=v;let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R=async Z=>{n(!0),f(null);try{const H=await Qe(Z);f(H),H.kind==="ok"&&N()}catch(H){const G=H;f({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},e[2]=R):R=e[2];const M=R;let P;e[3]!==l.policyName||e[4]!==l.tableName?(P=()=>{le(M({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},e[3]=l.policyName,e[4]=l.tableName,e[5]=P):P=e[5];const k=P;let A;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(A=()=>{le(M({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]=A):A=e[9];const _=A;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{f(null),c("scaffold")},e[10]=S):S=e[10];const p=S;let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{f(null),c("wire")},e[11]=m):m=e[11];const E=m;let x;e[12]!==t?(x=t("Scaffold access rules"),e[12]=t,e[13]=x):x=e[13];let I;e[14]!==x?(I=a(xe,{children:x}),e[14]=x,e[15]=I):I=e[15];let C;e[16]!==t?(C=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]=C):C=e[17];let w;e[18]!==C?(w=a(ye,{children:C}),e[18]=C,e[19]=w):w=e[19];let F;e[20]!==w||e[21]!==I?(F=i(be,{children:[I,w]}),e[20]=w,e[21]=I,e[22]=F):F=e[22];const K=s==="scaffold"?"default":"outline";let O;e[23]!==t?(O=t("New policy file"),e[23]=t,e[24]=O):O=e[24];let D;e[25]!==K||e[26]!==O?(D=a(L,{"data-testid":"policy-scaffolder-new",onClick:p,size:"xs",type:"button",variant:K,children:O}),e[25]=K,e[26]=O,e[27]=D):D=e[27];const Y=s==="wire"?"default":"outline";let d;e[28]!==t?(d=t("Wire into a procedure"),e[28]=t,e[29]=d):d=e[29];let y;e[30]!==Y||e[31]!==d?(y=a(L,{"data-testid":"policy-scaffolder-wire",onClick:E,size:"xs",type:"button",variant:Y,children:d}),e[30]=Y,e[31]=d,e[32]=y):y=e[32];let T;e[33]!==D||e[34]!==y?(T=i("div",{className:"flex flex-wrap gap-2",children:[D,y]}),e[33]=D,e[34]=y,e[35]=T):T=e[35];let z;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==s||e[40]!==k||e[41]!==t?(z=s==="scaffold"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(J,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:l.policyName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(J,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:l.tableName})]}),a(L,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:k,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(L,{onClick:N,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=s,e[40]=k,e[41]=t,e[42]=z):z=e[42];let j;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==s||e[48]!==_||e[49]!==t?(j=s==="wire"&&i("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(J,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:l.filePath})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(J,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:l.exportName})]}),i("div",{className:"flex flex-col gap-1 text-xs",children:[a(U,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(J,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:l.policies})]}),a(L,{"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(L,{onClick:N,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]=s,e[48]=_,e[49]=t,e[50]=j):j=e[50];let q;e[51]!==o?(q=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]=q):q=e[52];let B;e[53]!==o?.kind||e[54]!==t?(B=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]=B):B=e[55];let W;e[56]!==o||e[57]!==t?(W=o?.kind==="ok"&&i("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(Je)})]}),e[56]=o,e[57]=t,e[58]=W):W=e[58];let Q;e[59]!==T||e[60]!==z||e[61]!==j||e[62]!==q||e[63]!==B||e[64]!==W?(Q=i(de,{children:[T,z,j,q,B,W]}),e[59]=T,e[60]=z,e[61]=j,e[62]=q,e[63]=B,e[64]=W,e[65]=Q):Q=e[65];let V;return e[66]!==F||e[67]!==Q?(V=i(me,{"data-testid":"policy-scaffolder",size:"sm",children:[F,Q]}),e[66]=F,e[67]=Q,e[68]=V):V=e[68],V};function Je(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const ut=({functions:e,runAsIdentity:t=!1,schemaEditable:s=!1}={})=>{const c=ee(),[r,n]=h(void 0),o=(f,l,b)=>{b!==""&&n(u=>({functionPath:b,nonce:(u?.nonce??0)+1}))};return i("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[i("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:c("Permissions")})}),a(De,{onProbe:o})]}),a("section",{className:"flex flex-col gap-3",children:i(me,{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:c("Probe")})}),i(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:c("Pick a function and an identity, then run it to see the access outcome.")}),a(qe,{functions:e,prefill:r,runAsIdentity:t})]})]})}),s&&a("section",{className:"flex flex-col gap-2",children:a(He,{})})]})};export{ut as PermissionsPanel};
@@ -1 +1 @@
1
- import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-DueSEkt-.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ne}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as w,a as ae,b as te,d as de,T as ce,e as O}from"../packem_shared/table-D0SBiDu-.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{h as J}from"../packem_shared/internal-Df43vQI0.mjs";import{c as oe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as i,jsxs as z}from"react/jsx-runtime";const ue=new Set(["cancelled","completed","expired"]),fe=r=>ue.has(r),me=r=>r.extendedDueAt??r.dueAt,ve=r=>!fe(r)&&r!=="ready",pe=(r,e)=>ve(r.status)&&e.getTime()>me(r).getTime(),ye=(r,e)=>pe({dueAt:new Date(r.dueAt),status:r.status,...r.extendedDueAt===void 0||r.extendedDueAt===null?{}:{extendedDueAt:new Date(r.extendedDueAt)}},new Date(e)),he=["studio","privacy-requests"],xe={cancelled:"outline",completed:"success",expired:"outline",failed:"destructive",grace:"secondary",processing:"warning",ready:"success",received:"info"},Ae=r=>J(r??void 0,"—"),ge=r=>{const e=W(55),{asOf:o,retrying:t,row:s,onRetry:q}=r,a=X();let d,c,D;e[0]!==o||e[1]!==s?(c=ye(s,o),d=te,D=oe(c&&"bg-destructive/5"),e[0]=o,e[1]=s,e[2]=d,e[3]=c,e[4]=D):(d=e[2],c=e[3],D=e[4]);const S=c?"true":"false";let u;e[5]!==s.id?(u=i(O,{className:"font-mono text-xs",children:s.id}),e[5]=s.id,e[6]=u):u=e[6];let f;e[7]!==s.type||e[8]!==a?(f=s.type==="export"?a("Export"):a("Erasure"),e[7]=s.type,e[8]=a,e[9]=f):f=e[9];let E;e[10]!==f?(E=i(O,{children:i(G,{variant:"secondary",children:f})}),e[10]=f,e[11]=E):E=e[11];let n;e[12]!==s.subjectId?(n=i(O,{className:"font-mono text-xs",children:s.subjectId}),e[12]=s.subjectId,e[13]=n):n=e[13];const N=xe[s.status];let b;e[14]!==s.status||e[15]!==N?(b=i(O,{children:i(G,{variant:N,children:s.status})}),e[14]=s.status,e[15]=N,e[16]=b):b=e[16];let R;e[17]!==s.receivedAt?(R=J(s.receivedAt),e[17]=s.receivedAt,e[18]=R):R=e[18];let P;e[19]!==R?(P=i(O,{children:R}),e[19]=R,e[20]=P):P=e[20];let m;e[21]!==s.dueAt?(m=J(s.dueAt),e[21]=s.dueAt,e[22]=m):m=e[22];let v;e[23]!==m?(v=i(O,{children:m}),e[23]=m,e[24]=v):v=e[24];let p;e[25]!==s.extendedDueAt?(p=Ae(s.extendedDueAt),e[25]=s.extendedDueAt,e[26]=p):p=e[26];let y;e[27]!==p?(y=i(O,{children:p}),e[27]=p,e[28]=y):y=e[28];let h;e[29]!==c||e[30]!==a?(h=c&&i(G,{"data-testid":"privacy-overdue",variant:"destructive",children:a("Overdue")}),e[29]=c,e[30]=a,e[31]=h):h=e[31];let x;e[32]!==h?(x=i(O,{children:h}),e[32]=h,e[33]=x):x=e[33];let A;e[34]!==q||e[35]!==t||e[36]!==s.id||e[37]!==s.status||e[38]!==a?(A=s.status==="failed"&&i(ne,{disabled:t,onClick:()=>{q(s.id)},size:"xs",variant:"outline",children:a("Retry")}),e[34]=q,e[35]=t,e[36]=s.id,e[37]=s.status,e[38]=a,e[39]=A):A=e[39];let g;e[40]!==A?(g=i(O,{children:A}),e[40]=A,e[41]=g):g=e[41];let I;return e[42]!==d||e[43]!==D||e[44]!==P||e[45]!==v||e[46]!==y||e[47]!==x||e[48]!==g||e[49]!==S||e[50]!==u||e[51]!==E||e[52]!==n||e[53]!==b?(I=z(d,{className:D,"data-overdue":S,"data-testid":"privacy-request-row",children:[u,E,n,b,P,v,y,x,g]}),e[42]=d,e[43]=D,e[44]=P,e[45]=v,e[46]=y,e[47]=x,e[48]=g,e[49]=S,e[50]=u,e[51]=E,e[52]=n,e[53]=b,e[54]=I):I=e[54],I},Te=r=>{const e=W(95),{source:o}=r,t=X(),s=se(),q=le();let a;e[0]!==q?(a=[...he,q],e[0]=q,e[1]=a):a=e[1];const d=a;let c;e[2]!==o?(c=async()=>({asOf:Date.now(),requests:await o.listOpenPrivacyRequests()}),e[2]=o,e[3]=c):c=e[3];let D;e[4]!==d||e[5]!==c?(D={queryKey:d,refetchInterval:6e4,queryFn:c,staleTime:0},e[4]=d,e[5]=c,e[6]=D):D=e[6];const S=ie(D);let u;e[7]!==o?(u=l=>o.retryPrivacyRequest(l),e[7]=o,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==d?(f=async()=>{await s.invalidateQueries({queryKey:d})},e[9]=s,e[10]=d,e[11]=f):f=e[11];let E;e[12]!==u||e[13]!==f?(E={mutationFn:u,onSuccess:f},e[12]=u,e[13]=f,e[14]=E):E=e[14];const n=re(E);let N;e[15]!==n?(N=l=>{n.mutate(l)},e[15]=n,e[16]=N):N=e[16];const b=N;if(S.isPending){let l;e[17]!==t?(l=t("Loading privacy requests…"),e[17]=t,e[18]=l):l=e[18];let T;return e[19]!==l?(T=i("p",{className:"text-sm text-muted-foreground","data-testid":"privacy-requests-loading",role:"status",children:l}),e[19]=l,e[20]=T):T=e[20],T}if(S.isError){let l;return e[21]!==S.error?(l=i(Z,{error:S.error,testId:"privacy-requests-error"}),e[21]=S.error,e[22]=l):l=e[22],l}const{asOf:R,requests:P}=S.data;if(P.length===0){let l;e[23]!==t?(l=t("No open privacy requests."),e[23]=t,e[24]=l):l=e[24];let T;return e[25]!==l?(T=i(ee,{testId:"privacy-requests-empty",title:l}),e[25]=l,e[26]=T):T=e[26],T}let m;e[27]!==n.error||e[28]!==n.isError?(m=n.isError&&i(Z,{error:n.error,testId:"privacy-retry-error"}),e[27]=n.error,e[28]=n.isError,e[29]=m):m=e[29];let v;e[30]!==t?(v=t("ID"),e[30]=t,e[31]=v):v=e[31];let p;e[32]!==v?(p=i(w,{children:v}),e[32]=v,e[33]=p):p=e[33];let y;e[34]!==t?(y=t("Type"),e[34]=t,e[35]=y):y=e[35];let h;e[36]!==y?(h=i(w,{children:y}),e[36]=y,e[37]=h):h=e[37];let x;e[38]!==t?(x=t("Subject"),e[38]=t,e[39]=x):x=e[39];let A;e[40]!==x?(A=i(w,{children:x}),e[40]=x,e[41]=A):A=e[41];let g;e[42]!==t?(g=t("Status"),e[42]=t,e[43]=g):g=e[43];let I;e[44]!==g?(I=i(w,{children:g}),e[44]=g,e[45]=I):I=e[45];let j;e[46]!==t?(j=t("Received"),e[46]=t,e[47]=j):j=e[47];let B;e[48]!==j?(B=i(w,{children:j}),e[48]=j,e[49]=B):B=e[49];let C;e[50]!==t?(C=t("Due"),e[50]=t,e[51]=C):C=e[51];let Q;e[52]!==C?(Q=i(w,{children:C}),e[52]=C,e[53]=Q):Q=e[53];let U;e[54]!==t?(U=t("Extended due"),e[54]=t,e[55]=U):U=e[55];let V;e[56]!==U?(V=i(w,{children:U}),e[56]=U,e[57]=V):V=e[57];let _;e[58]!==t?(_=t("Overdue"),e[58]=t,e[59]=_):_=e[59];let $;e[60]!==_?($=i(w,{children:_}),e[60]=_,e[61]=$):$=e[61];let F;e[62]!==t?(F=t("Actions"),e[62]=t,e[63]=F):F=e[63];let H;e[64]!==F?(H=i(w,{children:F}),e[64]=F,e[65]=H):H=e[65];let K;e[66]!==p||e[67]!==h||e[68]!==A||e[69]!==I||e[70]!==B||e[71]!==Q||e[72]!==V||e[73]!==$||e[74]!==H?(K=i(ae,{children:z(te,{children:[p,h,A,I,B,Q,V,$,H]})}),e[66]=p,e[67]=h,e[68]=A,e[69]=I,e[70]=B,e[71]=Q,e[72]=V,e[73]=$,e[74]=H,e[75]=K):K=e[75];let L;if(e[76]!==R||e[77]!==b||e[78]!==P||e[79]!==n.isPending||e[80]!==n.variables){let l;e[82]!==R||e[83]!==b||e[84]!==n.isPending||e[85]!==n.variables?(l=T=>i(ge,{asOf:R,onRetry:b,retrying:n.isPending&&n.variables===T.id,row:T},T.id),e[82]=R,e[83]=b,e[84]=n.isPending,e[85]=n.variables,e[86]=l):l=e[86],L=P.map(l),e[76]=R,e[77]=b,e[78]=P,e[79]=n.isPending,e[80]=n.variables,e[81]=L}else L=e[81];let M;e[87]!==L?(M=i(de,{children:L}),e[87]=L,e[88]=M):M=e[88];let Y;e[89]!==K||e[90]!==M?(Y=z(ce,{children:[K,M]}),e[89]=K,e[90]=M,e[91]=Y):Y=e[91];let k;return e[92]!==Y||e[93]!==m?(k=z("div",{className:"flex flex-col gap-3",children:[m,Y]}),e[92]=Y,e[93]=m,e[94]=k):k=e[94],k},Be=r=>{const e=W(11);let o;e[0]!==r?(o=r===void 0?{}:r,e[0]=r,e[1]=o):o=e[1];const{source:t}=o,s=X();if(t===void 0){let a;e[2]!==s?(a=s("Pass privacyRequests to the Studio to list and retry data-subject requests."),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==s?(d=s("Privacy requests not configured"),e[4]=s,e[5]=d):d=e[5];let c;return e[6]!==a||e[7]!==d?(c=i(ee,{description:a,testId:"privacy-requests-not-configured",title:d}),e[6]=a,e[7]=d,e[8]=c):c=e[8],c}let q;return e[9]!==t?(q=i(Te,{source:t}),e[9]=t,e[10]=q):q=e[10],q};export{Be as PrivacyRequestsPanel};
1
+ import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ne}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as w,a as ae,b as te,d as de,T as ce,e as O}from"../packem_shared/table-D0SBiDu-.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{h as J}from"../packem_shared/internal-Df43vQI0.mjs";import{c as oe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as i,jsxs as z}from"react/jsx-runtime";const ue=new Set(["cancelled","completed","expired"]),fe=r=>ue.has(r),me=r=>r.extendedDueAt??r.dueAt,ve=r=>!fe(r)&&r!=="ready",pe=(r,e)=>ve(r.status)&&e.getTime()>me(r).getTime(),ye=(r,e)=>pe({dueAt:new Date(r.dueAt),status:r.status,...r.extendedDueAt===void 0||r.extendedDueAt===null?{}:{extendedDueAt:new Date(r.extendedDueAt)}},new Date(e)),he=["studio","privacy-requests"],xe={cancelled:"outline",completed:"success",expired:"outline",failed:"destructive",grace:"secondary",processing:"warning",ready:"success",received:"info"},Ae=r=>J(r??void 0,"—"),ge=r=>{const e=W(55),{asOf:o,retrying:t,row:s,onRetry:q}=r,a=X();let d,c,D;e[0]!==o||e[1]!==s?(c=ye(s,o),d=te,D=oe(c&&"bg-destructive/5"),e[0]=o,e[1]=s,e[2]=d,e[3]=c,e[4]=D):(d=e[2],c=e[3],D=e[4]);const S=c?"true":"false";let u;e[5]!==s.id?(u=i(O,{className:"font-mono text-xs",children:s.id}),e[5]=s.id,e[6]=u):u=e[6];let f;e[7]!==s.type||e[8]!==a?(f=s.type==="export"?a("Export"):a("Erasure"),e[7]=s.type,e[8]=a,e[9]=f):f=e[9];let E;e[10]!==f?(E=i(O,{children:i(G,{variant:"secondary",children:f})}),e[10]=f,e[11]=E):E=e[11];let n;e[12]!==s.subjectId?(n=i(O,{className:"font-mono text-xs",children:s.subjectId}),e[12]=s.subjectId,e[13]=n):n=e[13];const N=xe[s.status];let b;e[14]!==s.status||e[15]!==N?(b=i(O,{children:i(G,{variant:N,children:s.status})}),e[14]=s.status,e[15]=N,e[16]=b):b=e[16];let R;e[17]!==s.receivedAt?(R=J(s.receivedAt),e[17]=s.receivedAt,e[18]=R):R=e[18];let P;e[19]!==R?(P=i(O,{children:R}),e[19]=R,e[20]=P):P=e[20];let m;e[21]!==s.dueAt?(m=J(s.dueAt),e[21]=s.dueAt,e[22]=m):m=e[22];let v;e[23]!==m?(v=i(O,{children:m}),e[23]=m,e[24]=v):v=e[24];let p;e[25]!==s.extendedDueAt?(p=Ae(s.extendedDueAt),e[25]=s.extendedDueAt,e[26]=p):p=e[26];let y;e[27]!==p?(y=i(O,{children:p}),e[27]=p,e[28]=y):y=e[28];let h;e[29]!==c||e[30]!==a?(h=c&&i(G,{"data-testid":"privacy-overdue",variant:"destructive",children:a("Overdue")}),e[29]=c,e[30]=a,e[31]=h):h=e[31];let x;e[32]!==h?(x=i(O,{children:h}),e[32]=h,e[33]=x):x=e[33];let A;e[34]!==q||e[35]!==t||e[36]!==s.id||e[37]!==s.status||e[38]!==a?(A=s.status==="failed"&&i(ne,{disabled:t,onClick:()=>{q(s.id)},size:"xs",variant:"outline",children:a("Retry")}),e[34]=q,e[35]=t,e[36]=s.id,e[37]=s.status,e[38]=a,e[39]=A):A=e[39];let g;e[40]!==A?(g=i(O,{children:A}),e[40]=A,e[41]=g):g=e[41];let I;return e[42]!==d||e[43]!==D||e[44]!==P||e[45]!==v||e[46]!==y||e[47]!==x||e[48]!==g||e[49]!==S||e[50]!==u||e[51]!==E||e[52]!==n||e[53]!==b?(I=z(d,{className:D,"data-overdue":S,"data-testid":"privacy-request-row",children:[u,E,n,b,P,v,y,x,g]}),e[42]=d,e[43]=D,e[44]=P,e[45]=v,e[46]=y,e[47]=x,e[48]=g,e[49]=S,e[50]=u,e[51]=E,e[52]=n,e[53]=b,e[54]=I):I=e[54],I},Te=r=>{const e=W(95),{source:o}=r,t=X(),s=se(),q=le();let a;e[0]!==q?(a=[...he,q],e[0]=q,e[1]=a):a=e[1];const d=a;let c;e[2]!==o?(c=async()=>({asOf:Date.now(),requests:await o.listOpenPrivacyRequests()}),e[2]=o,e[3]=c):c=e[3];let D;e[4]!==d||e[5]!==c?(D={queryKey:d,refetchInterval:6e4,queryFn:c,staleTime:0},e[4]=d,e[5]=c,e[6]=D):D=e[6];const S=ie(D);let u;e[7]!==o?(u=l=>o.retryPrivacyRequest(l),e[7]=o,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==d?(f=async()=>{await s.invalidateQueries({queryKey:d})},e[9]=s,e[10]=d,e[11]=f):f=e[11];let E;e[12]!==u||e[13]!==f?(E={mutationFn:u,onSuccess:f},e[12]=u,e[13]=f,e[14]=E):E=e[14];const n=re(E);let N;e[15]!==n?(N=l=>{n.mutate(l)},e[15]=n,e[16]=N):N=e[16];const b=N;if(S.isPending){let l;e[17]!==t?(l=t("Loading privacy requests…"),e[17]=t,e[18]=l):l=e[18];let T;return e[19]!==l?(T=i("p",{className:"text-sm text-muted-foreground","data-testid":"privacy-requests-loading",role:"status",children:l}),e[19]=l,e[20]=T):T=e[20],T}if(S.isError){let l;return e[21]!==S.error?(l=i(Z,{error:S.error,testId:"privacy-requests-error"}),e[21]=S.error,e[22]=l):l=e[22],l}const{asOf:R,requests:P}=S.data;if(P.length===0){let l;e[23]!==t?(l=t("No open privacy requests."),e[23]=t,e[24]=l):l=e[24];let T;return e[25]!==l?(T=i(ee,{testId:"privacy-requests-empty",title:l}),e[25]=l,e[26]=T):T=e[26],T}let m;e[27]!==n.error||e[28]!==n.isError?(m=n.isError&&i(Z,{error:n.error,testId:"privacy-retry-error"}),e[27]=n.error,e[28]=n.isError,e[29]=m):m=e[29];let v;e[30]!==t?(v=t("ID"),e[30]=t,e[31]=v):v=e[31];let p;e[32]!==v?(p=i(w,{children:v}),e[32]=v,e[33]=p):p=e[33];let y;e[34]!==t?(y=t("Type"),e[34]=t,e[35]=y):y=e[35];let h;e[36]!==y?(h=i(w,{children:y}),e[36]=y,e[37]=h):h=e[37];let x;e[38]!==t?(x=t("Subject"),e[38]=t,e[39]=x):x=e[39];let A;e[40]!==x?(A=i(w,{children:x}),e[40]=x,e[41]=A):A=e[41];let g;e[42]!==t?(g=t("Status"),e[42]=t,e[43]=g):g=e[43];let I;e[44]!==g?(I=i(w,{children:g}),e[44]=g,e[45]=I):I=e[45];let j;e[46]!==t?(j=t("Received"),e[46]=t,e[47]=j):j=e[47];let B;e[48]!==j?(B=i(w,{children:j}),e[48]=j,e[49]=B):B=e[49];let C;e[50]!==t?(C=t("Due"),e[50]=t,e[51]=C):C=e[51];let Q;e[52]!==C?(Q=i(w,{children:C}),e[52]=C,e[53]=Q):Q=e[53];let U;e[54]!==t?(U=t("Extended due"),e[54]=t,e[55]=U):U=e[55];let V;e[56]!==U?(V=i(w,{children:U}),e[56]=U,e[57]=V):V=e[57];let _;e[58]!==t?(_=t("Overdue"),e[58]=t,e[59]=_):_=e[59];let $;e[60]!==_?($=i(w,{children:_}),e[60]=_,e[61]=$):$=e[61];let F;e[62]!==t?(F=t("Actions"),e[62]=t,e[63]=F):F=e[63];let H;e[64]!==F?(H=i(w,{children:F}),e[64]=F,e[65]=H):H=e[65];let K;e[66]!==p||e[67]!==h||e[68]!==A||e[69]!==I||e[70]!==B||e[71]!==Q||e[72]!==V||e[73]!==$||e[74]!==H?(K=i(ae,{children:z(te,{children:[p,h,A,I,B,Q,V,$,H]})}),e[66]=p,e[67]=h,e[68]=A,e[69]=I,e[70]=B,e[71]=Q,e[72]=V,e[73]=$,e[74]=H,e[75]=K):K=e[75];let L;if(e[76]!==R||e[77]!==b||e[78]!==P||e[79]!==n.isPending||e[80]!==n.variables){let l;e[82]!==R||e[83]!==b||e[84]!==n.isPending||e[85]!==n.variables?(l=T=>i(ge,{asOf:R,onRetry:b,retrying:n.isPending&&n.variables===T.id,row:T},T.id),e[82]=R,e[83]=b,e[84]=n.isPending,e[85]=n.variables,e[86]=l):l=e[86],L=P.map(l),e[76]=R,e[77]=b,e[78]=P,e[79]=n.isPending,e[80]=n.variables,e[81]=L}else L=e[81];let M;e[87]!==L?(M=i(de,{children:L}),e[87]=L,e[88]=M):M=e[88];let Y;e[89]!==K||e[90]!==M?(Y=z(ce,{children:[K,M]}),e[89]=K,e[90]=M,e[91]=Y):Y=e[91];let k;return e[92]!==Y||e[93]!==m?(k=z("div",{className:"flex flex-col gap-3",children:[m,Y]}),e[92]=Y,e[93]=m,e[94]=k):k=e[94],k},Be=r=>{const e=W(11);let o;e[0]!==r?(o=r===void 0?{}:r,e[0]=r,e[1]=o):o=e[1];const{source:t}=o,s=X();if(t===void 0){let a;e[2]!==s?(a=s("Pass privacyRequests to the Studio to list and retry data-subject requests."),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==s?(d=s("Privacy requests not configured"),e[4]=s,e[5]=d):d=e[5];let c;return e[6]!==a||e[7]!==d?(c=i(ee,{description:a,testId:"privacy-requests-not-configured",title:d}),e[6]=a,e[7]=d,e[8]=c):c=e[8],c}let q;return e[9]!==t?(q=i(Te,{source:t}),e[9]=t,e[10]=q):q=e[10],q};export{Be as PrivacyRequestsPanel};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{useLunora as et}from"@lunora/react";import{useState as R,Fragment as tt}from"react";import{ConfirmButton as st}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{E as at}from"../packem_shared/error-alert-DueSEkt-.mjs";import{A as rt}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Te}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ve}from"../packem_shared/button-q0UYSmrn.mjs";import{C as ke,a as Fe}from"../packem_shared/card-By2O8ULa.mjs";import{E as we}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as nt}from"../packem_shared/input-CXhxesPC.mjs";import{S as ot}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Ue,a as je,b as W,c as _,d as Je,e as T}from"../packem_shared/table-D0SBiDu-.mjs";import{T as lt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as $e}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as it}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as Ee,b as oe,d as _e,c as Qe,h as ct,j as dt}from"../packem_shared/internal-Df43vQI0.mjs";import{jsx as s,jsxs as N,Fragment as Pe}from"react/jsx-runtime";const ut=(a,e)=>{const t=new Set(a.map(r=>r.deadLetterQueue).filter(r=>typeof r=="string"&&r!=="")),i=a.filter(r=>(r.deadLetterQueue===void 0||r.deadLetterQueue==="")&&!t.has(r.name)),o=e.filter(r=>r.deadLettered).length;return{deadLetteredCount:o,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||o>0}},Ce="topic:",Ae=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},We=a=>`${Ce}${a}`,mt=(a,e)=>a.startsWith(Ce)?(e.get(a.slice(Ce.length))??[]).map(t=>t.exportName):[a],pt=200,ft=Qe(G.sendQueueMessage),ht=async(a,e,t)=>{const o=(await Promise.allSettled(e.map(async n=>a.query(ft,n,_e(""))))).flatMap((n,l)=>n.status==="rejected"?[{exportName:e[l]?.exportName??"",message:oe(n.reason)}]:[]),[r]=o;return r===void 0?null:e.length===1?r.message:t("Not sent to {failed}",{failed:o.map(n=>`${n.exportName}: ${n.message}`).join("; ")})},gt=Qe(G.replayQueueMessage),xt=Qe(G.clearQueueMessages),Oe=96,yt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},bt=a=>a.length>Oe?`${a.slice(0,Oe)}…`:a,Nt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",qt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ge=a=>{const e=U(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let o;e[0]!==t.exportName?(o=s(T,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=o):o=e[1];let r;e[2]!==t.name?(r=s(T,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=r):r=e[3];let n;e[4]!==t.mode?(n=s(T,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=n):n=e[5];let l;e[6]!==t.binding?(l=s(T,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const u=t.deadLetterQueue??"—";let c;e[8]!==u?(c=s(T,{className:"font-mono text-xs text-muted-foreground",children:u}),e[8]=u,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==o||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==c?(m=N(W,{"data-testid":i,children:[o,r,n,l,c]}),e[10]=i,e[11]=o,e[12]=r,e[13]=n,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},St=a=>{const e=U(8),{loaded:t,queues:i}=a,o=z();let r;if(e[0]!==t||e[1]!==i||e[2]!==o){const{plain:n,topics:l}=Ae(i);let u;e[4]!==o?(u=o("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=o,e[5]=u):u=e[5];let c;e[6]!==u?(c=s("p",{className:"text-sm text-muted-foreground",children:u}),e[6]=u,e[7]=c):c=e[7],r=N("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(we,{description:o("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:o("No queues defined")}):s(ke,{className:"overflow-hidden py-0",children:s(Fe,{className:"px-0",children:N(Ue,{"data-testid":"queues-table",children:[s(je,{children:N(W,{children:[s(_,{children:o("Export")}),s(_,{children:o("Queue")}),s(_,{children:o("Mode")}),s(_,{children:o("Binding")}),s(_,{children:o("Dead-letter")})]})}),N(Je,{children:[n.map(Ct),[...l].map(m=>{const[h,g]=m;return N(tt,{children:[s(W,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(T,{className:"text-xs font-medium",colSpan:5,children:o("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(vt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=o,e[3]=r}else r=e[3];return r},Et=a=>{const e=U(67),{message:t,onReplay:i,replayingId:o}=a,r=z();let n,l,u,c,m,h,g,d,p,y;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==r){const j=yt(t.body);l=W,h=`queues-message-${t.id}`;const J=t.exportName??t.queue;e[19]!==J?(g=s(T,{className:"font-mono text-xs",children:J}),e[19]=J,e[20]=g):g=e[20],e[21]!==t.messageId?(d=s(T,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=d):d=e[22],e[23]!==t.attempts?(p=s(T,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const A=`queues-outcome-${t.id}`;let I;e[25]!==t.outcome?(I=Nt(t.outcome),e[25]=t.outcome,e[26]=I):I=e[26];let C;e[27]!==t.outcome||e[28]!==A||e[29]!==I?(C=s(Te,{"data-testid":A,variant:I,children:t.outcome}),e[27]=t.outcome,e[28]=A,e[29]=I,e[30]=C):C=e[30];let M;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==r?(M=t.deadLettered&&s(Te,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:r("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=r,e[34]=M):M=e[34],e[35]!==C||e[36]!==M?(y=s(T,{children:N("span",{className:"inline-flex items-center gap-1",children:[C,M]})}),e[35]=C,e[36]=M,e[37]=y):y=e[37],n=T,u="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=j,m=bt(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]=r,e[9]=n,e[10]=l,e[11]=u,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=d,e[17]=p,e[18]=y}else n=e[9],l=e[10],u=e[11],c=e[12],m=e[13],h=e[14],g=e[15],d=e[16],p=e[17],y=e[18];let x;e[38]!==n||e[39]!==u||e[40]!==c||e[41]!==m?(x=s(n,{className:u,title:c,children:m}),e[38]=n,e[39]=u,e[40]=c,e[41]=m,e[42]=x):x=e[42];let q;e[43]!==t.capturedAt?(q=ct(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=q):q=e[44];let b;e[45]!==q?(b=s(T,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=b):b=e[46];const S=`queues-replay-${t.id}`,v=o!==null;let w;e[47]!==t.id||e[48]!==o||e[49]!==r?(w=o===t.id?r("Replaying…"):r("Replay"),e[47]=t.id,e[48]=o,e[49]=r,e[50]=w):w=e[50];let Q;e[51]!==t.id||e[52]!==i||e[53]!==S||e[54]!==v||e[55]!==w?(Q=s(T,{children:s(ve,{"data-id":t.id,"data-testid":S,disabled:v,onClick:i,size:"xs",type:"button",variant:"outline",children:w})}),e[51]=t.id,e[52]=i,e[53]=S,e[54]=v,e[55]=w,e[56]=Q):Q=e[56];let B;return e[57]!==l||e[58]!==b||e[59]!==Q||e[60]!==h||e[61]!==g||e[62]!==d||e[63]!==p||e[64]!==y||e[65]!==x?(B=N(l,{"data-testid":h,children:[g,d,p,y,x,b,Q]}),e[57]=l,e[58]=b,e[59]=Q,e[60]=h,e[61]=g,e[62]=d,e[63]=p,e[64]=y,e[65]=x,e[66]=B):B=e[66],B},Tt=a=>{const e=U(29),{hasError:t,messages:i,onClear:o,onReplay:r,replayingId:n}=a,l=z();let u;e[0]!==l?(u=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=u):u=e[1];let c;e[2]!==u?(c=s("p",{className:"text-sm text-muted-foreground",children:u}),e[2]=u,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let d;e[8]!==o||e[9]!==m||e[10]!==h||e[11]!==g?(d=s("div",{className:"ml-auto",children:s(st,{confirmLabel:m,disabled:h,onConfirm:o,testId:"queues-clear",children:g})}),e[8]=o,e[9]=m,e[10]=h,e[11]=g,e[12]=d):d=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Te,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==d||e[18]!==p?(y=N("div",{className:"flex flex-wrap items-center gap-2",children:[c,d,p]}),e[16]=c,e[17]=d,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==r||e[23]!==n||e[24]!==l?(x=!t&&i.length===0?s(we,{description:l("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:l("No consumed messages yet.")}):s(ke,{className:"overflow-hidden py-0",children:s(Fe,{className:"px-0",children:s(ot,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:N(Ue,{"data-testid":"queues-messages-table",children:[s(je,{children:N(W,{children:[s(_,{children:l("Export")}),s(_,{children:l("Message")}),s(_,{children:l("Attempts")}),s(_,{children:l("Outcome")}),s(_,{children:l("Body")}),s(_,{children:l("Captured")}),s(_,{})]})}),s(Je,{children:i.map(b=>s(Et,{message:b,onReplay:r,replayingId:n},b.id))})]})})})}),e[20]=t,e[21]=i,e[22]=r,e[23]=n,e[24]=l,e[25]=x):x=e[25];let q;return e[26]!==y||e[27]!==x?(q=N("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=q):q=e[28],q},_t=a=>{const e=U(20),{batchMode:t,bodyText:i,delayText:o,onBatchModeChange:r,onBodyChange:n,onDelayChange:l,onSelectExport:u,onSend:c,queues:m,selectedExportName:h,sending:g}=a,d=z();let p;e[0]!==d?(p=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==o||e[7]!==r||e[8]!==n||e[9]!==l||e[10]!==u||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==d?(x=m.length===0?s(we,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")}):N(Pe,{children:[N("div",{className:"flex flex-wrap items-center gap-2",children:[N("select",{"aria-label":d("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:u,value:h,children:[m.map(wt),[...Ae(m).topics].map(b=>{const[S,v]=b;return s("option",{value:We(S),children:d("{topic} (topic → {count} subscriptions)",{count:v.length,topic:S})},S)})]}),s(nt,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:d("Delay (s)"),type:"number",value:o}),N("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:r,type:"checkbox"}),d("Send as batch (JSON array)")]}),s(ve,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:d(g?"Sending…":"Send message")})]}),s(lt,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:n,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=o,e[7]=r,e[8]=n,e[9]=l,e[10]=u,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=d,e[16]=x):x=e[16];let q;return e[17]!==y||e[18]!==x?(q=N("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=q):q=e[19],q},es=a=>{const e=U(57),{limit:t}=a,i=t??pt,o=et(),r=z(),[n,l]=R("declared"),[u,c]=R(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:d}=$e(G.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:q,refetch:b}=$e(G.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(Qt):[],v=y?.entries??[],{deadLetteredCount:w,queuesWithoutDlq:Q,showReliabilityWarning:B}=ut(S,v),[j,J]=R(""),[A,I]=R(""),[C,M]=R(""),[P,ze]=R(!1),[le,Ie]=R(!1),[ie,Me]=R(null),{topics:Le}=Ae(S),Re=[...S.map(At),...[...Le.keys()].map(It)],H=Re.includes(j)?j:Re[0]??"",Be=n==="messages"?x:g,He=n==="messages"?q:d,ce=Be??u,de=Be===null?u:He;let V;e[3]!==b?(V=()=>{b()},e[3]=b,e[4]=V):V=e[4],it(V,n==="messages");const Ve=async()=>{c(null);const f=H;if(f==="")return;let E=null;const qe=A.trim();if(qe!=="")try{E=JSON.parse(qe)}catch{c(r("Body must be valid JSON."));return}let Se;const De=C.trim();if(De!==""){const L=Number(De);if(!Number.isFinite(L)||L<0){c(r("Delay must be a non-negative number of seconds."));return}Se=L}if(P&&!Array.isArray(E)){c(r("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ie(!0);const Ze=mt(f,Le).map(L=>P?{batch:E,delaySeconds:Se,exportName:L}:{body:E,delaySeconds:Se,exportName:L});try{c(await ht(o,Ze,r)),b()}catch(L){c(oe(L))}Ie(!1)};let X;e[5]!==o||e[6]!==b?(X=async f=>{c(null),Me(f);try{await o.query(gt,{id:f},_e("")),b()}catch(E){c(oe(E))}Me(null)},e[5]=o,e[6]=b,e[7]=X):X=e[7];const ue=X;let Y;e[8]!==o||e[9]!==b?(Y=async()=>{c(null);try{await o.query(xt,{},_e("")),b()}catch(f){c(oe(f))}},e[8]=o,e[9]=b,e[10]=Y):Y=e[10];const me=Y;let K;e[11]===Symbol.for("react.memo_cache_sentinel")?(K=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[11]=K):K=e[11];const Xe=K;let Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=f=>{J(f.currentTarget.value)},e[12]=Z):Z=e[12];const pe=Z;let ee;e[13]===Symbol.for("react.memo_cache_sentinel")?(ee=f=>{I(f.currentTarget.value)},e[13]=ee):ee=e[13];const fe=ee;let te;e[14]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{M(f.currentTarget.value)},e[14]=te):te=e[14];const he=te;let se;e[15]===Symbol.for("react.memo_cache_sentinel")?(se=f=>{ze(f.currentTarget.checked)},e[15]=se):se=e[15];const ge=se,xe=()=>{Ee(Ve())};let ae;e[16]!==ue?(ae=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Ee(ue(E))},e[16]=ue,e[17]=ae):ae=e[17];const ye=ae;let re;e[18]!==me?(re=()=>{Ee(me())},e[18]=me,e[19]=re):re=e[19];const be=re,Ye="flex flex-col gap-6",Ke="lunora-queues-panel";let D;e[20]!==r||e[21]!==n?(D=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(ve,{"aria-selected":n===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Xe,role:"tab",size:"sm",type:"button",variant:n===f?"secondary":"ghost",children:qt(f,r)},f))}),e[20]=r,e[21]=n,e[22]=D):D=e[22];let $;e[23]!==ce||e[24]!==de?($=ce!==null&&s(at,{error:de,testId:"queues-error"}),e[23]=ce,e[24]=de,e[25]=$):$=e[25];const Ne=B&&s(rt,{icon:s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:N("div",{className:"flex flex-col gap-1",children:[Q.length>0&&N(Pe,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:Q.map(Mt).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),w>0&&s("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:w===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:w})})]})});let O;e[26]!==S||e[27]!==h||e[28]!==n?(O=n==="declared"&&s(St,{loaded:h!==void 0,queues:S}),e[26]=S,e[27]=h,e[28]=n,e[29]=O):O=e[29];let k;e[30]!==v||e[31]!==x||e[32]!==be||e[33]!==ye||e[34]!==ie||e[35]!==n?(k=n==="messages"&&s(Tt,{hasError:x!==null,messages:v,onClear:be,onReplay:ye,replayingId:ie}),e[30]=v,e[31]=x,e[32]=be,e[33]=ye,e[34]=ie,e[35]=n,e[36]=k):k=e[36];let F;e[37]!==P||e[38]!==A||e[39]!==C||e[40]!==ge||e[41]!==fe||e[42]!==he||e[43]!==pe||e[44]!==xe||e[45]!==S||e[46]!==H||e[47]!==le||e[48]!==n?(F=n==="send"&&s(_t,{batchMode:P,bodyText:A,delayText:C,onBatchModeChange:ge,onBodyChange:fe,onDelayChange:he,onSelectExport:pe,onSend:xe,queues:S,selectedExportName:H,sending:le}),e[37]=P,e[38]=A,e[39]=C,e[40]=ge,e[41]=fe,e[42]=he,e[43]=pe,e[44]=xe,e[45]=S,e[46]=H,e[47]=le,e[48]=n,e[49]=F):F=e[49];let ne;return e[50]!==D||e[51]!==$||e[52]!==Ne||e[53]!==O||e[54]!==k||e[55]!==F?(ne=N("div",{className:Ye,"data-testid":Ke,children:[D,$,Ne,O,k,F]}),e[50]=D,e[51]=$,e[52]=Ne,e[53]=O,e[54]=k,e[55]=F,e[56]=ne):ne=e[56],ne};function Ct(a){return s(Ge,{queue:a},a.exportName)}function vt(a){return s(Ge,{queue:a},a.exportName)}function wt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function Qt(a,e){return a.exportName.localeCompare(e.exportName)}function At(a){return a.exportName}function It(a){return We(a)}function Mt(a){return a.name}export{es as default};
1
+ import{c as U}from"react/compiler-runtime";import{useLunora as et}from"@lunora/react";import{useState as R,Fragment as tt}from"react";import{ConfirmButton as st}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{E as at}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{A as rt}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Te}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ve}from"../packem_shared/button-q0UYSmrn.mjs";import{C as ke,a as Fe}from"../packem_shared/card-By2O8ULa.mjs";import{E as we}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as nt}from"../packem_shared/input-CXhxesPC.mjs";import{S as ot}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Ue,a as je,b as W,c as _,d as Je,e as T}from"../packem_shared/table-D0SBiDu-.mjs";import{T as lt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as $e}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as it}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as Ee,b as oe,d as _e,c as Qe,h as ct,j as dt}from"../packem_shared/internal-Df43vQI0.mjs";import{jsx as s,jsxs as N,Fragment as Pe}from"react/jsx-runtime";const ut=(a,e)=>{const t=new Set(a.map(r=>r.deadLetterQueue).filter(r=>typeof r=="string"&&r!=="")),i=a.filter(r=>(r.deadLetterQueue===void 0||r.deadLetterQueue==="")&&!t.has(r.name)),o=e.filter(r=>r.deadLettered).length;return{deadLetteredCount:o,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||o>0}},Ce="topic:",Ae=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},We=a=>`${Ce}${a}`,mt=(a,e)=>a.startsWith(Ce)?(e.get(a.slice(Ce.length))??[]).map(t=>t.exportName):[a],pt=200,ft=Qe(G.sendQueueMessage),ht=async(a,e,t)=>{const o=(await Promise.allSettled(e.map(async n=>a.query(ft,n,_e(""))))).flatMap((n,l)=>n.status==="rejected"?[{exportName:e[l]?.exportName??"",message:oe(n.reason)}]:[]),[r]=o;return r===void 0?null:e.length===1?r.message:t("Not sent to {failed}",{failed:o.map(n=>`${n.exportName}: ${n.message}`).join("; ")})},gt=Qe(G.replayQueueMessage),xt=Qe(G.clearQueueMessages),Oe=96,yt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},bt=a=>a.length>Oe?`${a.slice(0,Oe)}…`:a,Nt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",qt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ge=a=>{const e=U(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let o;e[0]!==t.exportName?(o=s(T,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=o):o=e[1];let r;e[2]!==t.name?(r=s(T,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=r):r=e[3];let n;e[4]!==t.mode?(n=s(T,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=n):n=e[5];let l;e[6]!==t.binding?(l=s(T,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const u=t.deadLetterQueue??"—";let c;e[8]!==u?(c=s(T,{className:"font-mono text-xs text-muted-foreground",children:u}),e[8]=u,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==o||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==c?(m=N(W,{"data-testid":i,children:[o,r,n,l,c]}),e[10]=i,e[11]=o,e[12]=r,e[13]=n,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},St=a=>{const e=U(8),{loaded:t,queues:i}=a,o=z();let r;if(e[0]!==t||e[1]!==i||e[2]!==o){const{plain:n,topics:l}=Ae(i);let u;e[4]!==o?(u=o("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=o,e[5]=u):u=e[5];let c;e[6]!==u?(c=s("p",{className:"text-sm text-muted-foreground",children:u}),e[6]=u,e[7]=c):c=e[7],r=N("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(we,{description:o("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:o("No queues defined")}):s(ke,{className:"overflow-hidden py-0",children:s(Fe,{className:"px-0",children:N(Ue,{"data-testid":"queues-table",children:[s(je,{children:N(W,{children:[s(_,{children:o("Export")}),s(_,{children:o("Queue")}),s(_,{children:o("Mode")}),s(_,{children:o("Binding")}),s(_,{children:o("Dead-letter")})]})}),N(Je,{children:[n.map(Ct),[...l].map(m=>{const[h,g]=m;return N(tt,{children:[s(W,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(T,{className:"text-xs font-medium",colSpan:5,children:o("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(vt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=o,e[3]=r}else r=e[3];return r},Et=a=>{const e=U(67),{message:t,onReplay:i,replayingId:o}=a,r=z();let n,l,u,c,m,h,g,d,p,y;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==r){const j=yt(t.body);l=W,h=`queues-message-${t.id}`;const J=t.exportName??t.queue;e[19]!==J?(g=s(T,{className:"font-mono text-xs",children:J}),e[19]=J,e[20]=g):g=e[20],e[21]!==t.messageId?(d=s(T,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=d):d=e[22],e[23]!==t.attempts?(p=s(T,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const A=`queues-outcome-${t.id}`;let I;e[25]!==t.outcome?(I=Nt(t.outcome),e[25]=t.outcome,e[26]=I):I=e[26];let C;e[27]!==t.outcome||e[28]!==A||e[29]!==I?(C=s(Te,{"data-testid":A,variant:I,children:t.outcome}),e[27]=t.outcome,e[28]=A,e[29]=I,e[30]=C):C=e[30];let M;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==r?(M=t.deadLettered&&s(Te,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:r("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=r,e[34]=M):M=e[34],e[35]!==C||e[36]!==M?(y=s(T,{children:N("span",{className:"inline-flex items-center gap-1",children:[C,M]})}),e[35]=C,e[36]=M,e[37]=y):y=e[37],n=T,u="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=j,m=bt(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]=r,e[9]=n,e[10]=l,e[11]=u,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=d,e[17]=p,e[18]=y}else n=e[9],l=e[10],u=e[11],c=e[12],m=e[13],h=e[14],g=e[15],d=e[16],p=e[17],y=e[18];let x;e[38]!==n||e[39]!==u||e[40]!==c||e[41]!==m?(x=s(n,{className:u,title:c,children:m}),e[38]=n,e[39]=u,e[40]=c,e[41]=m,e[42]=x):x=e[42];let q;e[43]!==t.capturedAt?(q=ct(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=q):q=e[44];let b;e[45]!==q?(b=s(T,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=b):b=e[46];const S=`queues-replay-${t.id}`,v=o!==null;let w;e[47]!==t.id||e[48]!==o||e[49]!==r?(w=o===t.id?r("Replaying…"):r("Replay"),e[47]=t.id,e[48]=o,e[49]=r,e[50]=w):w=e[50];let Q;e[51]!==t.id||e[52]!==i||e[53]!==S||e[54]!==v||e[55]!==w?(Q=s(T,{children:s(ve,{"data-id":t.id,"data-testid":S,disabled:v,onClick:i,size:"xs",type:"button",variant:"outline",children:w})}),e[51]=t.id,e[52]=i,e[53]=S,e[54]=v,e[55]=w,e[56]=Q):Q=e[56];let B;return e[57]!==l||e[58]!==b||e[59]!==Q||e[60]!==h||e[61]!==g||e[62]!==d||e[63]!==p||e[64]!==y||e[65]!==x?(B=N(l,{"data-testid":h,children:[g,d,p,y,x,b,Q]}),e[57]=l,e[58]=b,e[59]=Q,e[60]=h,e[61]=g,e[62]=d,e[63]=p,e[64]=y,e[65]=x,e[66]=B):B=e[66],B},Tt=a=>{const e=U(29),{hasError:t,messages:i,onClear:o,onReplay:r,replayingId:n}=a,l=z();let u;e[0]!==l?(u=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=u):u=e[1];let c;e[2]!==u?(c=s("p",{className:"text-sm text-muted-foreground",children:u}),e[2]=u,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let d;e[8]!==o||e[9]!==m||e[10]!==h||e[11]!==g?(d=s("div",{className:"ml-auto",children:s(st,{confirmLabel:m,disabled:h,onConfirm:o,testId:"queues-clear",children:g})}),e[8]=o,e[9]=m,e[10]=h,e[11]=g,e[12]=d):d=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Te,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==d||e[18]!==p?(y=N("div",{className:"flex flex-wrap items-center gap-2",children:[c,d,p]}),e[16]=c,e[17]=d,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==r||e[23]!==n||e[24]!==l?(x=!t&&i.length===0?s(we,{description:l("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:l("No consumed messages yet.")}):s(ke,{className:"overflow-hidden py-0",children:s(Fe,{className:"px-0",children:s(ot,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:N(Ue,{"data-testid":"queues-messages-table",children:[s(je,{children:N(W,{children:[s(_,{children:l("Export")}),s(_,{children:l("Message")}),s(_,{children:l("Attempts")}),s(_,{children:l("Outcome")}),s(_,{children:l("Body")}),s(_,{children:l("Captured")}),s(_,{})]})}),s(Je,{children:i.map(b=>s(Et,{message:b,onReplay:r,replayingId:n},b.id))})]})})})}),e[20]=t,e[21]=i,e[22]=r,e[23]=n,e[24]=l,e[25]=x):x=e[25];let q;return e[26]!==y||e[27]!==x?(q=N("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=q):q=e[28],q},_t=a=>{const e=U(20),{batchMode:t,bodyText:i,delayText:o,onBatchModeChange:r,onBodyChange:n,onDelayChange:l,onSelectExport:u,onSend:c,queues:m,selectedExportName:h,sending:g}=a,d=z();let p;e[0]!==d?(p=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==o||e[7]!==r||e[8]!==n||e[9]!==l||e[10]!==u||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==d?(x=m.length===0?s(we,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")}):N(Pe,{children:[N("div",{className:"flex flex-wrap items-center gap-2",children:[N("select",{"aria-label":d("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:u,value:h,children:[m.map(wt),[...Ae(m).topics].map(b=>{const[S,v]=b;return s("option",{value:We(S),children:d("{topic} (topic → {count} subscriptions)",{count:v.length,topic:S})},S)})]}),s(nt,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:d("Delay (s)"),type:"number",value:o}),N("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:r,type:"checkbox"}),d("Send as batch (JSON array)")]}),s(ve,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:d(g?"Sending…":"Send message")})]}),s(lt,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:n,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=o,e[7]=r,e[8]=n,e[9]=l,e[10]=u,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=d,e[16]=x):x=e[16];let q;return e[17]!==y||e[18]!==x?(q=N("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=q):q=e[19],q},es=a=>{const e=U(57),{limit:t}=a,i=t??pt,o=et(),r=z(),[n,l]=R("declared"),[u,c]=R(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:d}=$e(G.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:q,refetch:b}=$e(G.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(Qt):[],v=y?.entries??[],{deadLetteredCount:w,queuesWithoutDlq:Q,showReliabilityWarning:B}=ut(S,v),[j,J]=R(""),[A,I]=R(""),[C,M]=R(""),[P,ze]=R(!1),[le,Ie]=R(!1),[ie,Me]=R(null),{topics:Le}=Ae(S),Re=[...S.map(At),...[...Le.keys()].map(It)],H=Re.includes(j)?j:Re[0]??"",Be=n==="messages"?x:g,He=n==="messages"?q:d,ce=Be??u,de=Be===null?u:He;let V;e[3]!==b?(V=()=>{b()},e[3]=b,e[4]=V):V=e[4],it(V,n==="messages");const Ve=async()=>{c(null);const f=H;if(f==="")return;let E=null;const qe=A.trim();if(qe!=="")try{E=JSON.parse(qe)}catch{c(r("Body must be valid JSON."));return}let Se;const De=C.trim();if(De!==""){const L=Number(De);if(!Number.isFinite(L)||L<0){c(r("Delay must be a non-negative number of seconds."));return}Se=L}if(P&&!Array.isArray(E)){c(r("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ie(!0);const Ze=mt(f,Le).map(L=>P?{batch:E,delaySeconds:Se,exportName:L}:{body:E,delaySeconds:Se,exportName:L});try{c(await ht(o,Ze,r)),b()}catch(L){c(oe(L))}Ie(!1)};let X;e[5]!==o||e[6]!==b?(X=async f=>{c(null),Me(f);try{await o.query(gt,{id:f},_e("")),b()}catch(E){c(oe(E))}Me(null)},e[5]=o,e[6]=b,e[7]=X):X=e[7];const ue=X;let Y;e[8]!==o||e[9]!==b?(Y=async()=>{c(null);try{await o.query(xt,{},_e("")),b()}catch(f){c(oe(f))}},e[8]=o,e[9]=b,e[10]=Y):Y=e[10];const me=Y;let K;e[11]===Symbol.for("react.memo_cache_sentinel")?(K=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[11]=K):K=e[11];const Xe=K;let Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=f=>{J(f.currentTarget.value)},e[12]=Z):Z=e[12];const pe=Z;let ee;e[13]===Symbol.for("react.memo_cache_sentinel")?(ee=f=>{I(f.currentTarget.value)},e[13]=ee):ee=e[13];const fe=ee;let te;e[14]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{M(f.currentTarget.value)},e[14]=te):te=e[14];const he=te;let se;e[15]===Symbol.for("react.memo_cache_sentinel")?(se=f=>{ze(f.currentTarget.checked)},e[15]=se):se=e[15];const ge=se,xe=()=>{Ee(Ve())};let ae;e[16]!==ue?(ae=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Ee(ue(E))},e[16]=ue,e[17]=ae):ae=e[17];const ye=ae;let re;e[18]!==me?(re=()=>{Ee(me())},e[18]=me,e[19]=re):re=e[19];const be=re,Ye="flex flex-col gap-6",Ke="lunora-queues-panel";let D;e[20]!==r||e[21]!==n?(D=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(ve,{"aria-selected":n===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Xe,role:"tab",size:"sm",type:"button",variant:n===f?"secondary":"ghost",children:qt(f,r)},f))}),e[20]=r,e[21]=n,e[22]=D):D=e[22];let $;e[23]!==ce||e[24]!==de?($=ce!==null&&s(at,{error:de,testId:"queues-error"}),e[23]=ce,e[24]=de,e[25]=$):$=e[25];const Ne=B&&s(rt,{icon:s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:N("div",{className:"flex flex-col gap-1",children:[Q.length>0&&N(Pe,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:Q.map(Mt).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),w>0&&s("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:w===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:w})})]})});let O;e[26]!==S||e[27]!==h||e[28]!==n?(O=n==="declared"&&s(St,{loaded:h!==void 0,queues:S}),e[26]=S,e[27]=h,e[28]=n,e[29]=O):O=e[29];let k;e[30]!==v||e[31]!==x||e[32]!==be||e[33]!==ye||e[34]!==ie||e[35]!==n?(k=n==="messages"&&s(Tt,{hasError:x!==null,messages:v,onClear:be,onReplay:ye,replayingId:ie}),e[30]=v,e[31]=x,e[32]=be,e[33]=ye,e[34]=ie,e[35]=n,e[36]=k):k=e[36];let F;e[37]!==P||e[38]!==A||e[39]!==C||e[40]!==ge||e[41]!==fe||e[42]!==he||e[43]!==pe||e[44]!==xe||e[45]!==S||e[46]!==H||e[47]!==le||e[48]!==n?(F=n==="send"&&s(_t,{batchMode:P,bodyText:A,delayText:C,onBatchModeChange:ge,onBodyChange:fe,onDelayChange:he,onSelectExport:pe,onSend:xe,queues:S,selectedExportName:H,sending:le}),e[37]=P,e[38]=A,e[39]=C,e[40]=ge,e[41]=fe,e[42]=he,e[43]=pe,e[44]=xe,e[45]=S,e[46]=H,e[47]=le,e[48]=n,e[49]=F):F=e[49];let ne;return e[50]!==D||e[51]!==$||e[52]!==Ne||e[53]!==O||e[54]!==k||e[55]!==F?(ne=N("div",{className:Ye,"data-testid":Ke,children:[D,$,Ne,O,k,F]}),e[50]=D,e[51]=$,e[52]=Ne,e[53]=O,e[54]=k,e[55]=F,e[56]=ne):ne=e[56],ne};function Ct(a){return s(Ge,{queue:a},a.exportName)}function vt(a){return s(Ge,{queue:a},a.exportName)}function wt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function Qt(a,e){return a.exportName.localeCompare(e.exportName)}function At(a){return a.exportName}function It(a){return We(a)}function Mt(a){return a.name}export{es as default};
@@ -1 +1 @@
1
- import{E as g}from"../packem_shared/error-alert-DueSEkt-.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card-By2O8ULa.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as S,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=E(),{data:l,error:p,errorSource:u,liveError:f}=A(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(S,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
1
+ import{E as g}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card-By2O8ULa.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as S,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=E(),{data:l,error:p,errorSource:u,liveError:f}=A(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(S,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-DueSEkt-.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as _,C as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as L}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};
1
+ import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-DAsOWnCL.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as _,C as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as L}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};