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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/index.d.ts +18 -3
  2. package/dist/index.js +1 -1
  3. package/dist/mount.js +1 -1
  4. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
  5. package/dist/packem_chunks/ApiTab.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  8. package/dist/packem_chunks/FileBrowser.js +1 -1
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  20. package/dist/packem_chunks/SettingsPanel.js +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.js +6 -6
  22. package/dist/packem_chunks/TableEditor.js +1 -1
  23. package/dist/packem_chunks/agents-panel.js +1 -1
  24. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  25. package/dist/packem_chunks/containers-panel.js +1 -1
  26. package/dist/packem_chunks/dashboards-panel.js +1 -1
  27. package/dist/packem_chunks/fanout-panel.js +1 -1
  28. package/dist/packem_chunks/flags-panel.js +1 -1
  29. package/dist/packem_chunks/issues-panel.js +1 -1
  30. package/dist/packem_chunks/kv-browser.js +1 -1
  31. package/dist/packem_chunks/migrations-route.js +1 -1
  32. package/dist/packem_chunks/payments-panel.js +1 -1
  33. package/dist/packem_chunks/permissions-panel.js +1 -1
  34. package/dist/packem_chunks/queues-panel.js +1 -1
  35. package/dist/packem_chunks/rls-panel.js +1 -1
  36. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  37. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  38. package/dist/packem_chunks/traces-panel.js +1 -1
  39. package/dist/packem_chunks/users-panel.js +1 -1
  40. package/dist/packem_chunks/workflows-panel.js +1 -1
  41. package/dist/packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js +1 -0
  42. package/dist/packem_shared/{ApiDocsPanel-fYS9NiLg.js → ApiDocsPanel-DLMeLZ5-.js} +1 -1
  43. package/dist/packem_shared/DataBrowser-CZZ_WkJ-.js +1 -0
  44. package/dist/packem_shared/{GlobalDataBrowser-CSttudUx.js → GlobalDataBrowser-DpkjHfDg.js} +1 -1
  45. package/dist/packem_shared/{HomePanel-BYsfMhKh.js → HomePanel-3baDsDBU.js} +1 -1
  46. package/dist/packem_shared/MigrationsPanel-dygzHUvg.js +1 -0
  47. package/dist/packem_shared/{Studio-Ba9x0dG_.js → Studio-forQt-PC.js} +1 -1
  48. package/dist/packem_shared/{StudioApp-B_PRdg4h.js → StudioApp-B1AWsBzi.js} +1 -1
  49. package/dist/packem_shared/{home-panel-B60-5YfI.js → home-panel-CeeqqV0z.js} +1 -1
  50. package/dist/packem_shared/{studio-CPuoAmjh.js → studio-BtC7WPbz.js} +1 -1
  51. package/dist/packem_shared/table-list-sidebar-D9Bd4qgi.js +1 -0
  52. package/dist/packem_shared/use-shard-key-B2JtNa5m.js +1 -0
  53. package/dist/packem_shared/{use-sql-assistant-BLG9unQN.js → use-sql-assistant-C6dl2_Ty.js} +1 -1
  54. package/dist/packem_shared/useDebounced-CU-uftxO.js +1 -0
  55. package/dist/standalone/chunk-2VWWXVWK.js +1 -0
  56. package/dist/standalone/chunk-3CWGJYBB.js +1 -0
  57. package/dist/standalone/{chunk-52OYJHM7.js → chunk-4JIOFDMR.js} +1 -1
  58. package/dist/standalone/{chunk-MN64D74P.js → chunk-4LCY5XUR.js} +1 -1
  59. package/dist/standalone/{chunk-JE3WK77V.js → chunk-5KRD6F67.js} +1 -1
  60. package/dist/standalone/{chunk-RC3H4OP3.js → chunk-5X4OZ7OD.js} +1 -1
  61. package/dist/standalone/{chunk-TO45V3L6.js → chunk-6MGI5IN6.js} +1 -1
  62. package/dist/standalone/{chunk-HJR42BJY.js → chunk-7DNDRUMZ.js} +1 -1
  63. package/dist/standalone/chunk-7FO57AZY.js +1 -0
  64. package/dist/standalone/{chunk-YNBIW2GN.js → chunk-B5S6GSUC.js} +1 -1
  65. package/dist/standalone/{chunk-QZ6TCNWR.js → chunk-B5UFGO4E.js} +1 -1
  66. package/dist/standalone/{chunk-RFBU5RZI.js → chunk-BDNDSBYM.js} +1 -1
  67. package/dist/standalone/{chunk-QS4IFAFJ.js → chunk-CLNB7I3O.js} +1 -1
  68. package/dist/standalone/{chunk-QSFKPGK4.js → chunk-D3JTCLSF.js} +1 -1
  69. package/dist/standalone/chunk-DABW4OOI.js +1 -0
  70. package/dist/standalone/{chunk-SPT3KPV7.js → chunk-EAIUBZA5.js} +1 -1
  71. package/dist/standalone/{chunk-FUBR2PAD.js → chunk-EJ2CHD4G.js} +1 -1
  72. package/dist/standalone/chunk-EVTCXQ5D.js +1 -0
  73. package/dist/standalone/{chunk-OLM62NLS.js → chunk-EWDLYYJM.js} +1 -1
  74. package/dist/standalone/{chunk-ZOX6X2DL.js → chunk-F7NVC7YK.js} +1 -1
  75. package/dist/standalone/chunk-FURI47Z2.js +1 -0
  76. package/dist/standalone/chunk-FW75RYZU.js +1 -0
  77. package/dist/standalone/chunk-GE5WTIWX.js +1 -0
  78. package/dist/standalone/{chunk-BAAU4OTI.js → chunk-GZS3ORGS.js} +1 -1
  79. package/dist/standalone/chunk-HYCMT2V5.js +1 -0
  80. package/dist/standalone/{chunk-5YADKLAQ.js → chunk-IAKPXGTQ.js} +1 -1
  81. package/dist/standalone/chunk-IVCIG5J7.js +4 -0
  82. package/dist/standalone/chunk-KJIBL5D4.js +1 -0
  83. package/dist/standalone/chunk-L4RW5BFD.js +1 -0
  84. package/dist/standalone/{chunk-PWTURL56.js → chunk-LYRAWNV7.js} +1 -1
  85. package/dist/standalone/chunk-MIFLRBVS.js +11 -0
  86. package/dist/standalone/{chunk-OOL3FV6A.js → chunk-MV4A2PAK.js} +1 -1
  87. package/dist/standalone/{chunk-347H2BQO.js → chunk-NBUBAW3V.js} +1 -1
  88. package/dist/standalone/{chunk-232MBXB2.js → chunk-NCWUTRZB.js} +1 -1
  89. package/dist/standalone/{chunk-D67BVBQW.js → chunk-NMLCYY4H.js} +1 -1
  90. package/dist/standalone/{chunk-MDHUWMFD.js → chunk-OOWHAURL.js} +1 -1
  91. package/dist/standalone/{chunk-UOQ24BAY.js → chunk-ORVR33FM.js} +1 -1
  92. package/dist/standalone/{chunk-7AG3T4DK.js → chunk-OUCGTB3Y.js} +2 -2
  93. package/dist/standalone/chunk-PDMZITZZ.js +1 -0
  94. package/dist/standalone/{chunk-VORDESEQ.js → chunk-PNAVAJAF.js} +1 -1
  95. package/dist/standalone/{chunk-LVJ5IHEU.js → chunk-QJTGO4JG.js} +1 -1
  96. package/dist/standalone/{chunk-EDOMDMVI.js → chunk-QP7IQOKF.js} +1 -1
  97. package/dist/standalone/chunk-QXDMHM2V.js +1 -0
  98. package/dist/standalone/{chunk-VKEJTZY7.js → chunk-S2CXYDNT.js} +1 -1
  99. package/dist/standalone/{chunk-AQKXMWNF.js → chunk-S3DWUXGY.js} +1 -1
  100. package/dist/standalone/{chunk-YSMJN36P.js → chunk-SJZQPIZB.js} +1 -1
  101. package/dist/standalone/{chunk-ETZYJL7Z.js → chunk-SMEW3ZTU.js} +1 -1
  102. package/dist/standalone/chunk-SNK7TOOO.js +6 -0
  103. package/dist/standalone/{chunk-QI25LTPH.js → chunk-T2Q7I3V2.js} +1 -1
  104. package/dist/standalone/{chunk-ESKVOZLC.js → chunk-T3CGXSXO.js} +1 -1
  105. package/dist/standalone/{chunk-YGKR536O.js → chunk-TS6346VY.js} +1 -1
  106. package/dist/standalone/{chunk-ENBTOX7N.js → chunk-TVGKSIIW.js} +1 -1
  107. package/dist/standalone/{chunk-U5IIRHZ6.js → chunk-UNVK2VZP.js} +1 -1
  108. package/dist/standalone/{chunk-U44CWN7H.js → chunk-UR3X4K4T.js} +1 -1
  109. package/dist/standalone/chunk-VDW32UET.js +1 -0
  110. package/dist/standalone/chunk-VQK34A2H.js +1 -0
  111. package/dist/standalone/{chunk-MBVSXVTV.js → chunk-WPUINKEO.js} +1 -1
  112. package/dist/standalone/chunk-XNGYYOLS.js +14 -0
  113. package/dist/standalone/{chunk-2SC3EG5Y.js → chunk-XR7RBXKA.js} +1 -1
  114. package/dist/standalone/{chunk-KNHWIHC7.js → chunk-XZN645UJ.js} +1 -1
  115. package/dist/standalone/chunk-YFJXQUPW.js +1 -0
  116. package/dist/standalone/chunk-YKAO3JNJ.js +1 -0
  117. package/dist/standalone/{chunk-AHVDZWB3.js → chunk-YRYEZHOJ.js} +1 -1
  118. package/dist/standalone/{chunk-TIR6CWHO.js → chunk-ZCFDQW4U.js} +1 -1
  119. package/dist/standalone/studio.js +1 -1
  120. package/package.json +6 -6
  121. package/dist/packem_shared/ADMIN_FUNCTIONS-CZESgd10.js +0 -1
  122. package/dist/packem_shared/DataBrowser-C4J4gVUu.js +0 -1
  123. package/dist/packem_shared/MigrationsPanel-2JbQ2HwG.js +0 -1
  124. package/dist/packem_shared/table-list-sidebar-BRv3hTLX.js +0 -1
  125. package/dist/packem_shared/useDebounced-Ihdiid_k.js +0 -1
  126. package/dist/standalone/chunk-22LOWEEC.js +0 -1
  127. package/dist/standalone/chunk-2EJADIPC.js +0 -1
  128. package/dist/standalone/chunk-4I2TBTZS.js +0 -1
  129. package/dist/standalone/chunk-6IEBRNDW.js +0 -1
  130. package/dist/standalone/chunk-D3FRQZ4X.js +0 -1
  131. package/dist/standalone/chunk-ERMTJYQF.js +0 -1
  132. package/dist/standalone/chunk-JAT5ZBQK.js +0 -1
  133. package/dist/standalone/chunk-JOFD43OI.js +0 -1
  134. package/dist/standalone/chunk-LFKCLLPT.js +0 -1
  135. package/dist/standalone/chunk-MLULN4R2.js +0 -1
  136. package/dist/standalone/chunk-MUGKOGZG.js +0 -1
  137. package/dist/standalone/chunk-NPKNFZUW.js +0 -6
  138. package/dist/standalone/chunk-OV63HVE4.js +0 -4
  139. package/dist/standalone/chunk-QFJRZR4U.js +0 -1
  140. package/dist/standalone/chunk-QNRAMF4X.js +0 -1
  141. package/dist/standalone/chunk-QNUWWC3N.js +0 -14
  142. package/dist/standalone/chunk-S67SBGB3.js +0 -1
  143. package/dist/standalone/chunk-SHD2IWQI.js +0 -1
  144. package/dist/standalone/chunk-SKFZXESP.js +0 -1
  145. package/dist/standalone/chunk-UBR4KB6K.js +0 -11
@@ -1 +1 @@
1
- import{a as ke}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{a as Pe}from"./chunk-CTNB2KIA.js";import{a as be}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as M}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as j}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ge}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as Z}from"./chunk-ERMTJYQF.js";import{c as ae}from"./chunk-YGKR536O.js";import{f as oe}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as de}from"./chunk-XQCVZAGU.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-MIQTKZAR.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-UZERI5YC.js";import{d as Y,f as he,g as xe,h as ye,m as te}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as d,e as ie,f as Ae,g as Ie,h as Fe}from"./chunk-3XIESWL4.js";var p=ie(Ae(),1);var me=ie(Ie(),1);var t=ie(Fe(),1);var Ce=["read","insert","update","delete"],Te=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"$e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ae"),ze=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"r");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Fe"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=Y(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let g=ae(Z.getAdvisories,h),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],R=g.data??null,{error:C,errorSource:w,liveError:S}=f,A=v===null?[]:ze(v,E,Ee(R)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let x;a[14]!==C||a[15]!==w?(x=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=x):x=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&A.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Te(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:A.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(j,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(_=>{let y=c.cells[_];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${_}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(F,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${_}`,onClick:d(()=>{s(c.table,_,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},_)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Le)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Ee");function Le(e){return(0,t.jsx)(j,{variant:"outline",children:e},e)}d(Le,"Te");var Oe=he(Z.runAs),Re=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{let n=Oe;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Re"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=Y(),n=Re(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),h=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[R,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[A,k]=(0,p.useState)(!1),[x,c]=(0,p.useState)(null),[_,y]=(0,p.useState)(null),I=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(ye(u))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||I.current===a.nonce)return;I.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?h[0]?.path??"":g,z=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(u){y(l("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),k(!0);try{let u=await n({args:m,functionPath:P,shardKey:R.trim(),userId:w.trim()});c(u)}finally{k(!1)}},"F"),$=d(()=>{te(z())},"E"),H=d(m=>{N(m.target.value)},"B"),L=d(m=>{E(m.target.value)},"T"),O=d(m=>{S(m.target.value)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("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:H,value:P,children:h.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:R}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:l("Leave empty to run as admin"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{"data-testid":"pp-run",disabled:!i||A||P==="",onClick:$,type:"button",children:l(A?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(j,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),x!==null&&x.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(x.value)})]}),x!==null&&x.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(j,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},"Oe"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 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({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Je=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"qe"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ke=d(()=>{let e=(0,me.c)(69),a=Y(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=d(ee=>{let G=ee.target.name,{value:V}=ee.target;b(_e=>({..._e,[G]:V}))},"u"),e[0]=h):h=e[0];let g=h,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"N"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Je(ee);f(G),G.kind==="ok"&&v()}catch(G){let V=G;f({kind:"error",message:V instanceof Error?V.message:String(V)})}n(!1)},"A"),e[2]=E):E=e[2];let R=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(R({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"S"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(R({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"C"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let A=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"k"),e[10]=k):k=e[10];let x=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"c"),e[11]=c):c=e[11];let _=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let I;e[14]!==y?(I=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=I):I=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let z;e[18]!==P?(z=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=z):z=e[19];let $;e[20]!==z||e[21]!==I?($=(0,t.jsxs)(pe,{children:[I,z]}),e[20]=z,e[21]=I,e[22]=$):$=e[22];let H=i==="scaffold"?"default":"outline",L;e[23]!==a?(L=a("New policy file"),e[23]=a,e[24]=L):L=e[24];let O;e[25]!==H||e[26]!==L?(O=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:H,children:L}),e[25]=H,e[26]=L,e[27]=O):O=e[27];let m=i==="wire"?"default":"outline",u;e[28]!==a?(u=a("Wire into a procedure"),e[28]=a,e[29]=u):u=e[29];let q;e[30]!==m||e[31]!==u?(q=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=q):q=e[32];let D;e[33]!==O||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[O,q]}),e[33]=O,e[34]=q,e[35]=D):D=e[35];let J;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(J=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=J):J=e[42];let K;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==A||e[49]!==a?(K=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=A,e[49]=a,e[50]=K):K=e[50];let U;e[51]!==o?(U=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=U):U=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ue)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let Q;e[59]!==D||e[60]!==J||e[61]!==K||e[62]!==U||e[63]!==W||e[64]!==B?(Q=(0,t.jsxs)(ne,{children:[D,J,K,U,W,B]}),e[59]=D,e[60]=J,e[61]=K,e[62]=U,e[63]=W,e[64]=B,e[65]=Q):Q=e[65];let X;return e[66]!==$||e[67]!==Q?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,Q]}),e[66]=$,e[67]=Q,e[68]=X):X=e[68],X},"Je");function Ue(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(Ue,"De");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=Y(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Ke,{})})]})},"nt");export{st as PermissionsPanel};
1
+ import{a as ke}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{a as Pe}from"./chunk-CTNB2KIA.js";import{a as be}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as M}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as j}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ge}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as Z}from"./chunk-VDW32UET.js";import{c as ae}from"./chunk-TS6346VY.js";import{f as oe}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as de}from"./chunk-XQCVZAGU.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-MIQTKZAR.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-UZERI5YC.js";import{d as Y,f as he,g as xe,h as ye,m as te}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as d,e as ie,f as Ae,g as Ie,h as Fe}from"./chunk-3XIESWL4.js";var p=ie(Ae(),1);var me=ie(Ie(),1);var t=ie(Fe(),1);var Ce=["read","insert","update","delete"],Te=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"$e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ae"),ze=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"r");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Fe"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=Y(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let g=ae(Z.getAdvisories,h),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],R=g.data??null,{error:C,errorSource:w,liveError:S}=f,A=v===null?[]:ze(v,E,Ee(R)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let x;a[14]!==C||a[15]!==w?(x=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=x):x=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&A.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Te(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:A.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(j,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(_=>{let y=c.cells[_];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${_}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(F,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${_}`,onClick:d(()=>{s(c.table,_,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},_)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Le)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Ee");function Le(e){return(0,t.jsx)(j,{variant:"outline",children:e},e)}d(Le,"Te");var Oe=he(Z.runAs),Re=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{let n=Oe;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Re"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=Y(),n=Re(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),h=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[R,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[A,k]=(0,p.useState)(!1),[x,c]=(0,p.useState)(null),[_,y]=(0,p.useState)(null),I=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(ye(u))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||I.current===a.nonce)return;I.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?h[0]?.path??"":g,z=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(u){y(l("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),k(!0);try{let u=await n({args:m,functionPath:P,shardKey:R.trim(),userId:w.trim()});c(u)}finally{k(!1)}},"F"),$=d(()=>{te(z())},"E"),H=d(m=>{N(m.target.value)},"B"),L=d(m=>{E(m.target.value)},"T"),O=d(m=>{S(m.target.value)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("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:H,value:P,children:h.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:R}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:l("Leave empty to run as admin"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{"data-testid":"pp-run",disabled:!i||A||P==="",onClick:$,type:"button",children:l(A?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(j,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),x!==null&&x.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(x.value)})]}),x!==null&&x.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(j,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},"Oe"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 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({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Je=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"qe"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ke=d(()=>{let e=(0,me.c)(69),a=Y(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=d(ee=>{let G=ee.target.name,{value:V}=ee.target;b(_e=>({..._e,[G]:V}))},"u"),e[0]=h):h=e[0];let g=h,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"N"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Je(ee);f(G),G.kind==="ok"&&v()}catch(G){let V=G;f({kind:"error",message:V instanceof Error?V.message:String(V)})}n(!1)},"A"),e[2]=E):E=e[2];let R=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(R({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"S"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(R({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"C"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let A=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"k"),e[10]=k):k=e[10];let x=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"c"),e[11]=c):c=e[11];let _=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let I;e[14]!==y?(I=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=I):I=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let z;e[18]!==P?(z=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=z):z=e[19];let $;e[20]!==z||e[21]!==I?($=(0,t.jsxs)(pe,{children:[I,z]}),e[20]=z,e[21]=I,e[22]=$):$=e[22];let H=i==="scaffold"?"default":"outline",L;e[23]!==a?(L=a("New policy file"),e[23]=a,e[24]=L):L=e[24];let O;e[25]!==H||e[26]!==L?(O=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:H,children:L}),e[25]=H,e[26]=L,e[27]=O):O=e[27];let m=i==="wire"?"default":"outline",u;e[28]!==a?(u=a("Wire into a procedure"),e[28]=a,e[29]=u):u=e[29];let q;e[30]!==m||e[31]!==u?(q=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=q):q=e[32];let D;e[33]!==O||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[O,q]}),e[33]=O,e[34]=q,e[35]=D):D=e[35];let J;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(J=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=J):J=e[42];let K;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==A||e[49]!==a?(K=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=A,e[49]=a,e[50]=K):K=e[50];let U;e[51]!==o?(U=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=U):U=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ue)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let Q;e[59]!==D||e[60]!==J||e[61]!==K||e[62]!==U||e[63]!==W||e[64]!==B?(Q=(0,t.jsxs)(ne,{children:[D,J,K,U,W,B]}),e[59]=D,e[60]=J,e[61]=K,e[62]=U,e[63]=W,e[64]=B,e[65]=Q):Q=e[65];let X;return e[66]!==$||e[67]!==Q?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,Q]}),e[66]=$,e[67]=Q,e[68]=X):X=e[68],X},"Je");function Ue(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(Ue,"De");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=Y(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Ke,{})})]})},"nt");export{st as PermissionsPanel};
@@ -1 +1 @@
1
- import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as v}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-ERMTJYQF.js";import{c as $}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as I,c as j,d as x,e as n,f as c}from"./chunk-MIQTKZAR.js";import{a as k,e as S}from"./chunk-UZERI5YC.js";import{d as b}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as f,e as N,g as E,h as _}from"./chunk-3XIESWL4.js";var T=N(E(),1);var r=N(_(),1);var D=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"C"),C={delete:2,list:3,read:0,write:1},O=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||C[t.on]-C[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"T"),W=f(()=>{let e=(0,T.c)(14),t=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(R.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=O(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(v,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(w,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(S,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(I,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(n,{children:t("Bucket")}),(0,r.jsx)(n,{children:t("Operation")}),(0,r.jsx)(n,{children:t("Key prefix")}),(0,r.jsx)(n,{children:t("Guarded by")})]})}),(0,r.jsx)(j,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(c,{children:(0,r.jsx)(y,{variant:"secondary",children:D(t,s.on)})}),(0,r.jsx)(c,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"U");export{W as StorageRulesPanel};
1
+ import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as v}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as I,c as j,d as x,e as n,f as c}from"./chunk-MIQTKZAR.js";import{a as k,e as S}from"./chunk-UZERI5YC.js";import{d as b}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as f,e as N,g as E,h as _}from"./chunk-3XIESWL4.js";var T=N(E(),1);var r=N(_(),1);var D=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"C"),C={delete:2,list:3,read:0,write:1},O=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||C[t.on]-C[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"T"),W=f(()=>{let e=(0,T.c)(14),t=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(R.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=O(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(v,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(w,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(S,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(I,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(n,{children:t("Bucket")}),(0,r.jsx)(n,{children:t("Operation")}),(0,r.jsx)(n,{children:t("Key prefix")}),(0,r.jsx)(n,{children:t("Guarded by")})]})}),(0,r.jsx)(j,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(c,{children:(0,r.jsx)(y,{variant:"secondary",children:D(t,s.on)})}),(0,r.jsx)(c,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"U");export{W as StorageRulesPanel};
@@ -1 +1 @@
1
- import{b as B}from"./chunk-XF2B7P5A.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as P}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-ERMTJYQF.js";import{c as F}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as R,b as q,c as z,d as K,e as _,f as C}from"./chunk-MIQTKZAR.js";import{a as D,e as j}from"./chunk-UZERI5YC.js";import{d as V}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as k,e as O,g as H,h as W}from"./chunk-3XIESWL4.js";var G=O(H(),1);var t=O(W(),1);var $={binding:"outline",secret:"destructive",var:"secondary"},J=k((n,e)=>{if(n===void 0)return[];let m=[];return n.workerUrl!==void 0&&m.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&m.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&m.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&m.push({label:e("Version"),value:n.versionTag}),m},"B"),le=k(n=>{let e=(0,G.c)(52),{initialShardKey:m}=n,r=V(),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let E=m??"",S;e[1]!==E?(S={shardKey:E},e[1]=E,e[2]=S):S=e[2];let{data:s,error:l,errorSource:b,isLoading:U}=F(M.getSettings,w,S),a,c,p,d,o,i,u;if(e[3]!==l||e[4]!==b||e[5]!==s?.deploy||e[6]!==s?.settings||e[7]!==r){let L=J(s?.deploy,r),T;e[15]!==s?.settings?(T=s?.settings??[],e[15]=s?.settings,e[16]=T):T=e[16],a=T,c="flex flex-col gap-4",p="lunora-settings";let y;e[17]!==r?(y=r("Open in Cloudflare"),e[17]=r,e[18]=y):y=e[18],e[19]!==y?(d=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:B,rel:"noreferrer",target:"_blank",children:y})}),e[19]=y,e[20]=d):d=e[20];let N;e[21]!==r?(N=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=N):N=e[22],e[23]!==N?(o=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:N}),e[23]=N,e[24]=o):o=e[24],e[25]!==l||e[26]!==b?(i=l!==null&&(0,t.jsx)(P,{error:b,testId:"set-error"}),e[25]=l,e[26]=b,e[27]=i):i=e[27],u=L.length>0&&(0,t.jsxs)(D,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(j,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:L.map(Q)})})]}),e[3]=l,e[4]=b,e[5]=s?.deploy,e[6]=s?.settings,e[7]=r,e[8]=a,e[9]=c,e[10]=p,e[11]=d,e[12]=o,e[13]=i,e[14]=u}else a=e[8],c=e[9],p=e[10],d=e[11],o=e[12],i=e[13],u=e[14];let h;e[28]!==r?(h=r("Environment & bindings"),e[28]=r,e[29]=h):h=e[29];let f;e[30]!==h?(f=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h})}),e[30]=h,e[31]=f):f=e[31];let g;e[32]!==l||e[33]!==U||e[34]!==a.length||e[35]!==r?(g=l===null&&!U&&a.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[32]=l,e[33]=U,e[34]=a.length,e[35]=r,e[36]=g):g=e[36];let x;e[37]!==a||e[38]!==r?(x=a.length>0&&(0,t.jsx)(j,{className:"px-0 py-0",children:(0,t.jsxs)(R,{"data-testid":"set-table",children:[(0,t.jsx)(q,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(_,{children:r("name")}),(0,t.jsx)(_,{children:r("kind")}),(0,t.jsx)(_,{children:r("value")})]})}),(0,t.jsx)(z,{children:a.map(X)})]})}),e[37]=a,e[38]=r,e[39]=x):x=e[39];let v;e[40]!==f||e[41]!==g||e[42]!==x?(v=(0,t.jsxs)(D,{className:"py-0",children:[f,g,x]}),e[40]=f,e[41]=g,e[42]=x,e[43]=v):v=e[43];let I;return e[44]!==v||e[45]!==c||e[46]!==p||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==u?(I=(0,t.jsxs)("div",{className:c,"data-testid":p,children:[d,o,i,u,v]}),e[44]=v,e[45]=c,e[46]=p,e[47]=d,e[48]=o,e[49]=i,e[50]=u,e[51]=I):I=e[51],I},"le");function Q(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}k(Q,"G");function X(n){return(0,t.jsxs)(K,{"data-testid":"set-row",children:[(0,t.jsx)(C,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(C,{children:(0,t.jsx)(A,{variant:$[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(C,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}k(X,"H");export{le as SettingsPanel};
1
+ import{b as B}from"./chunk-XF2B7P5A.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as P}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-VDW32UET.js";import{c as F}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as R,b as q,c as z,d as K,e as _,f as C}from"./chunk-MIQTKZAR.js";import{a as D,e as j}from"./chunk-UZERI5YC.js";import{d as V}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as k,e as O,g as H,h as W}from"./chunk-3XIESWL4.js";var G=O(H(),1);var t=O(W(),1);var $={binding:"outline",secret:"destructive",var:"secondary"},J=k((n,e)=>{if(n===void 0)return[];let m=[];return n.workerUrl!==void 0&&m.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&m.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&m.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&m.push({label:e("Version"),value:n.versionTag}),m},"B"),le=k(n=>{let e=(0,G.c)(52),{initialShardKey:m}=n,r=V(),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let E=m??"",S;e[1]!==E?(S={shardKey:E},e[1]=E,e[2]=S):S=e[2];let{data:s,error:l,errorSource:b,isLoading:U}=F(M.getSettings,w,S),a,c,p,d,o,i,u;if(e[3]!==l||e[4]!==b||e[5]!==s?.deploy||e[6]!==s?.settings||e[7]!==r){let L=J(s?.deploy,r),T;e[15]!==s?.settings?(T=s?.settings??[],e[15]=s?.settings,e[16]=T):T=e[16],a=T,c="flex flex-col gap-4",p="lunora-settings";let y;e[17]!==r?(y=r("Open in Cloudflare"),e[17]=r,e[18]=y):y=e[18],e[19]!==y?(d=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:B,rel:"noreferrer",target:"_blank",children:y})}),e[19]=y,e[20]=d):d=e[20];let N;e[21]!==r?(N=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=N):N=e[22],e[23]!==N?(o=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:N}),e[23]=N,e[24]=o):o=e[24],e[25]!==l||e[26]!==b?(i=l!==null&&(0,t.jsx)(P,{error:b,testId:"set-error"}),e[25]=l,e[26]=b,e[27]=i):i=e[27],u=L.length>0&&(0,t.jsxs)(D,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(j,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:L.map(Q)})})]}),e[3]=l,e[4]=b,e[5]=s?.deploy,e[6]=s?.settings,e[7]=r,e[8]=a,e[9]=c,e[10]=p,e[11]=d,e[12]=o,e[13]=i,e[14]=u}else a=e[8],c=e[9],p=e[10],d=e[11],o=e[12],i=e[13],u=e[14];let h;e[28]!==r?(h=r("Environment & bindings"),e[28]=r,e[29]=h):h=e[29];let f;e[30]!==h?(f=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h})}),e[30]=h,e[31]=f):f=e[31];let g;e[32]!==l||e[33]!==U||e[34]!==a.length||e[35]!==r?(g=l===null&&!U&&a.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[32]=l,e[33]=U,e[34]=a.length,e[35]=r,e[36]=g):g=e[36];let x;e[37]!==a||e[38]!==r?(x=a.length>0&&(0,t.jsx)(j,{className:"px-0 py-0",children:(0,t.jsxs)(R,{"data-testid":"set-table",children:[(0,t.jsx)(q,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(_,{children:r("name")}),(0,t.jsx)(_,{children:r("kind")}),(0,t.jsx)(_,{children:r("value")})]})}),(0,t.jsx)(z,{children:a.map(X)})]})}),e[37]=a,e[38]=r,e[39]=x):x=e[39];let v;e[40]!==f||e[41]!==g||e[42]!==x?(v=(0,t.jsxs)(D,{className:"py-0",children:[f,g,x]}),e[40]=f,e[41]=g,e[42]=x,e[43]=v):v=e[43];let I;return e[44]!==v||e[45]!==c||e[46]!==p||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==u?(I=(0,t.jsxs)("div",{className:c,"data-testid":p,children:[d,o,i,u,v]}),e[44]=v,e[45]=c,e[46]=p,e[47]=d,e[48]=o,e[49]=i,e[50]=u,e[51]=I):I=e[51],I},"le");function Q(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}k(Q,"G");function X(n){return(0,t.jsxs)(K,{"data-testid":"set-row",children:[(0,t.jsx)(C,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(C,{children:(0,t.jsx)(A,{variant:$[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(C,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}k(X,"H");export{le as SettingsPanel};
@@ -1 +1 @@
1
- import{a as T}from"./chunk-V53KNYRN.js";import{a as O}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as S}from"./chunk-ERMTJYQF.js";import{c as b}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as c}from"./chunk-XQCVZAGU.js";import{a as w,b as A,c as F,d as f,e as l,f as s}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as x}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as n,e as p,f as L,h as _}from"./chunk-3XIESWL4.js";var C=p(L(),1);var e=p(_(),1);var q=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let 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."}}},"L"),D='{ "targetingKey": "user-123", "plan": "premium" }',M=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"_"),Y=n(({initialShardKey:a=""})=>{let t=x(),[o,j]=(0,C.useState)(""),{context:g,error:m}=q(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,V=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,$)=>r.key.localeCompare($.key)):[],d;return u&&!V?d=(0,e.jsx)(c,{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")}):u&&h.length===0?d=(0,e.jsx)(c,{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=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(A,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(l,{children:t("Key")}),(0,e.jsx)(l,{children:t("Type")}),(0,e.jsx)(l,{children:t("Value")}),(0,e.jsx)(l,{children:t("Reason")}),(0,e.jsx)(l,{children:t("Variant")})]})}),(0,e.jsx)(F,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(s,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(s,{className:"font-mono text-xs",children:M(r)}),(0,e.jsx)(s,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("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.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(T,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:D,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("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]})},"X");export{Y as FlagsPanel};
1
+ import{a as T}from"./chunk-V53KNYRN.js";import{a as O}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as S}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as c}from"./chunk-XQCVZAGU.js";import{a as w,b as A,c as F,d as f,e as l,f as s}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as x}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as n,e as p,f as L,h as _}from"./chunk-3XIESWL4.js";var C=p(L(),1);var e=p(_(),1);var q=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let 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."}}},"L"),D='{ "targetingKey": "user-123", "plan": "premium" }',M=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"_"),Y=n(({initialShardKey:a=""})=>{let t=x(),[o,j]=(0,C.useState)(""),{context:g,error:m}=q(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,V=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,$)=>r.key.localeCompare($.key)):[],d;return u&&!V?d=(0,e.jsx)(c,{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")}):u&&h.length===0?d=(0,e.jsx)(c,{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=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(A,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(l,{children:t("Key")}),(0,e.jsx)(l,{children:t("Type")}),(0,e.jsx)(l,{children:t("Value")}),(0,e.jsx)(l,{children:t("Reason")}),(0,e.jsx)(l,{children:t("Variant")})]})}),(0,e.jsx)(F,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(s,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(s,{className:"font-mono text-xs",children:M(r)}),(0,e.jsx)(s,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("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.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(T,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:D,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("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]})},"X");export{Y as FlagsPanel};
@@ -0,0 +1 @@
1
+ import{a as Y}from"./chunk-QXXIJAD5.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-X665E2HU.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-FW75RYZU.js";import{a as _,b as W}from"./chunk-UR3X4K4T.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-TS6346VY.js";import{f as B}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as A,f as H,g as K,m as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
@@ -1 +1 @@
1
- import{b as R}from"./chunk-U44CWN7H.js";import"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as p}from"./chunk-ERMTJYQF.js";import{c as h}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as g}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};
1
+ import{b as R}from"./chunk-UR3X4K4T.js";import"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as p}from"./chunk-VDW32UET.js";import{c as h}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as g}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};