@lunora/studio 1.0.0-alpha.394 → 1.0.0-alpha.395

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 (126) hide show
  1. package/README.md +2 -0
  2. package/dist/index.mjs +1 -1
  3. package/dist/mount.mjs +1 -1
  4. package/dist/packem_chunks/ai-knowledge.mjs +1 -1
  5. package/dist/packem_shared/StudioApp-CmlMUUAq.mjs +1 -0
  6. package/dist/standalone/{chunk-AWMHWVF7.js → chunk-2ASCHUYZ.js} +1 -1
  7. package/dist/standalone/{chunk-BTHVLHPT.js → chunk-2GY7PZLR.js} +1 -1
  8. package/dist/standalone/{chunk-DUICFFES.js → chunk-2Q2YW6DP.js} +1 -1
  9. package/dist/standalone/{chunk-YQI2YAD7.js → chunk-2SQ4R6JF.js} +1 -1
  10. package/dist/standalone/{chunk-Y4KOJPOW.js → chunk-2V76BRXG.js} +1 -1
  11. package/dist/standalone/{chunk-U4ZQVQZA.js → chunk-37QBGHAB.js} +1 -1
  12. package/dist/standalone/{chunk-YREHZBTG.js → chunk-37YN7GKB.js} +1 -1
  13. package/dist/standalone/{chunk-4Z2GLDF7.js → chunk-3FRO43CC.js} +1 -1
  14. package/dist/standalone/chunk-3NPH3ZH2.js +1 -0
  15. package/dist/standalone/{chunk-DRSX6KR3.js → chunk-3SFU5VY4.js} +1 -1
  16. package/dist/standalone/{chunk-YC3TUO5H.js → chunk-3WPPFTDC.js} +1 -1
  17. package/dist/standalone/{chunk-BUYKTV27.js → chunk-43LNUM4U.js} +1 -1
  18. package/dist/standalone/{chunk-HCLUIJMW.js → chunk-4A6J4C6A.js} +1 -1
  19. package/dist/standalone/chunk-4DZXYINC.js +1 -0
  20. package/dist/standalone/{chunk-26RNXTU3.js → chunk-4EJG4J2A.js} +1 -1
  21. package/dist/standalone/{chunk-BCT3KY76.js → chunk-4FTKFUPJ.js} +1 -1
  22. package/dist/standalone/{chunk-SQO3WGXH.js → chunk-4L2BABMS.js} +1 -1
  23. package/dist/standalone/{chunk-A33FOU2H.js → chunk-5BI76KCT.js} +1 -1
  24. package/dist/standalone/{chunk-BMGMBZAW.js → chunk-5IFJNGRV.js} +1 -1
  25. package/dist/standalone/{chunk-PT4GNZU7.js → chunk-5JCH67JD.js} +1 -1
  26. package/dist/standalone/{chunk-JCJCUWVN.js → chunk-5KNYRYVI.js} +1 -1
  27. package/dist/standalone/{chunk-5J2UX2CO.js → chunk-5PWQ7HBE.js} +1 -1
  28. package/dist/standalone/{chunk-JXW6H6LE.js → chunk-6CVUGL2K.js} +1 -1
  29. package/dist/standalone/{chunk-IC2PEYF7.js → chunk-6E2GHT3X.js} +1 -1
  30. package/dist/standalone/chunk-6MAIN66N.js +1 -0
  31. package/dist/standalone/{chunk-3GBBYV7C.js → chunk-6OE7TT2Y.js} +1 -1
  32. package/dist/standalone/{chunk-T6YZEXZO.js → chunk-6PQX7SHZ.js} +1 -1
  33. package/dist/standalone/{chunk-PVQDT47U.js → chunk-6QP547WA.js} +1 -1
  34. package/dist/standalone/chunk-7EUM7G2I.js +33 -0
  35. package/dist/standalone/{chunk-EEDAK4NS.js → chunk-7TGL5VXY.js} +1 -1
  36. package/dist/standalone/{chunk-TNQHMR76.js → chunk-7UN2ZZZV.js} +1 -1
  37. package/dist/standalone/{chunk-7URG6FZD.js → chunk-AFOBKJOK.js} +1 -1
  38. package/dist/standalone/{chunk-BFV46XUH.js → chunk-AGM656HF.js} +1 -1
  39. package/dist/standalone/{chunk-EBGXOUAO.js → chunk-AHX6CSR3.js} +1 -1
  40. package/dist/standalone/{chunk-2Q4WVEPB.js → chunk-AK6ZI3YN.js} +1 -1
  41. package/dist/standalone/{chunk-VLQU4G6O.js → chunk-AL5S7LVU.js} +1 -1
  42. package/dist/standalone/{chunk-M6WDFEUZ.js → chunk-B65U64C3.js} +1 -1
  43. package/dist/standalone/{chunk-PWHUPKZB.js → chunk-B7W7O2RS.js} +1 -1
  44. package/dist/standalone/chunk-BD76RVBZ.js +7 -0
  45. package/dist/standalone/{chunk-ZARTCW6W.js → chunk-BGU4O7PL.js} +1 -1
  46. package/dist/standalone/{chunk-VUWHTKLJ.js → chunk-BNDXMSLI.js} +1 -1
  47. package/dist/standalone/{chunk-ZG6VEBVA.js → chunk-BYUH4YAY.js} +1 -1
  48. package/dist/standalone/{chunk-N3MKRANL.js → chunk-CKGUHRV2.js} +1 -1
  49. package/dist/standalone/{chunk-ADOZBBJC.js → chunk-DL5ZVSGL.js} +1 -1
  50. package/dist/standalone/{chunk-TAZRDWQE.js → chunk-EE6QEAGV.js} +1 -1
  51. package/dist/standalone/{chunk-5BTQ4VV2.js → chunk-EGO7EG33.js} +1 -1
  52. package/dist/standalone/{chunk-AFUJCRWR.js → chunk-EHQ2LCCB.js} +1 -1
  53. package/dist/standalone/{chunk-HXWW3XML.js → chunk-FGAXBLHE.js} +1 -1
  54. package/dist/standalone/{chunk-K3HWPNON.js → chunk-FHR4JFT7.js} +1 -1
  55. package/dist/standalone/{chunk-EH53XOVI.js → chunk-G237Z4YL.js} +1 -1
  56. package/dist/standalone/{chunk-WVAWKCNQ.js → chunk-H4NGBPG2.js} +1 -1
  57. package/dist/standalone/{chunk-RRIRWVQY.js → chunk-I6TDZTVT.js} +1 -1
  58. package/dist/standalone/{chunk-QJ3M3IQW.js → chunk-IB4M4AI2.js} +1 -1
  59. package/dist/standalone/{chunk-S3HFNWDK.js → chunk-IGQXAWBB.js} +1 -1
  60. package/dist/standalone/{chunk-5XQM44J7.js → chunk-IGSYGAHI.js} +1 -1
  61. package/dist/standalone/{chunk-J2SIGUHW.js → chunk-IJAV3RXF.js} +1 -1
  62. package/dist/standalone/{chunk-NFIFRB3W.js → chunk-IT3JTYC4.js} +1 -1
  63. package/dist/standalone/{chunk-D4CP2AUO.js → chunk-J2IFOOCG.js} +1 -1
  64. package/dist/standalone/{chunk-YQEIOEEC.js → chunk-JARVMFE6.js} +1 -1
  65. package/dist/standalone/{chunk-WARWYT4K.js → chunk-JCHZNPJU.js} +1 -1
  66. package/dist/standalone/{chunk-2ZNMZPPZ.js → chunk-JGSHDQGZ.js} +1 -1
  67. package/dist/standalone/{chunk-EYFAYJYD.js → chunk-KHNHN37V.js} +1 -1
  68. package/dist/standalone/{chunk-ECXQQPVU.js → chunk-LTWCT32V.js} +1 -1
  69. package/dist/standalone/{chunk-HPQLTLIE.js → chunk-LVWOITSU.js} +1 -1
  70. package/dist/standalone/{chunk-TIFTYP3Z.js → chunk-M2NWC7G3.js} +1 -1
  71. package/dist/standalone/{chunk-MEYZIZGX.js → chunk-M2SFKF5Z.js} +1 -1
  72. package/dist/standalone/{chunk-S3WL3QZ2.js → chunk-MCJCCS7G.js} +1 -1
  73. package/dist/standalone/chunk-MYIUZ3KE.js +1 -0
  74. package/dist/standalone/{chunk-TDF4VVIF.js → chunk-N6F3WFL4.js} +1 -1
  75. package/dist/standalone/{chunk-FSY7UKMG.js → chunk-NBJ6DCHA.js} +1 -1
  76. package/dist/standalone/{chunk-QRXJTY2S.js → chunk-NJMFSHMW.js} +1 -1
  77. package/dist/standalone/{chunk-4OWWWAMB.js → chunk-OGRACGHY.js} +1 -1
  78. package/dist/standalone/{chunk-ZSXJJYWN.js → chunk-OSYCXIGN.js} +1 -1
  79. package/dist/standalone/{chunk-FRKRT73U.js → chunk-P5SHS466.js} +1 -1
  80. package/dist/standalone/{chunk-RIRXDYLA.js → chunk-PIFKJ3ES.js} +1 -1
  81. package/dist/standalone/chunk-QE2BYD4G.js +1 -0
  82. package/dist/standalone/{chunk-C4PC3TVC.js → chunk-QJH6HTCT.js} +1 -1
  83. package/dist/standalone/{chunk-OEPNNICC.js → chunk-RELSLYVS.js} +1 -1
  84. package/dist/standalone/{chunk-CBFVQCWS.js → chunk-REZHNEUN.js} +1 -1
  85. package/dist/standalone/{chunk-3BDGZAZD.js → chunk-RG5MG5I4.js} +1 -1
  86. package/dist/standalone/{chunk-5FHGTA7V.js → chunk-SFGYW6JZ.js} +1 -1
  87. package/dist/standalone/{chunk-UB6S6VYI.js → chunk-STKYARMP.js} +1 -1
  88. package/dist/standalone/{chunk-A7L3PZEL.js → chunk-THCO2YN5.js} +1 -1
  89. package/dist/standalone/{chunk-KEHWNM7Q.js → chunk-TPY5BJYD.js} +1 -1
  90. package/dist/standalone/{chunk-HLN47VMG.js → chunk-TWOO3G2Q.js} +1 -1
  91. package/dist/standalone/{chunk-LUHBGCMO.js → chunk-U7U4ADXH.js} +1 -1
  92. package/dist/standalone/{chunk-MLX6ME3Q.js → chunk-UWJXX5AV.js} +1 -1
  93. package/dist/standalone/{chunk-UHFZV34O.js → chunk-V335NVH7.js} +1 -1
  94. package/dist/standalone/{chunk-HE2XT2P7.js → chunk-V4X27TLH.js} +1 -1
  95. package/dist/standalone/{chunk-E32WBVTB.js → chunk-VAZ2FZKT.js} +1 -1
  96. package/dist/standalone/{chunk-WY23EROJ.js → chunk-VKBLXJIZ.js} +1 -1
  97. package/dist/standalone/{chunk-XWLURY4U.js → chunk-VUC5V5XF.js} +1 -1
  98. package/dist/standalone/{chunk-7XZENNML.js → chunk-WC2DKA2R.js} +1 -1
  99. package/dist/standalone/{chunk-4WFEKKAZ.js → chunk-X7ZYE4GP.js} +1 -1
  100. package/dist/standalone/{chunk-KJHVB5KM.js → chunk-XACKMLPO.js} +1 -1
  101. package/dist/standalone/{chunk-EOTHFTZG.js → chunk-YCZQNUZV.js} +1 -1
  102. package/dist/standalone/chunk-YIZDDGWA.js +1 -0
  103. package/dist/standalone/{chunk-VEG327ST.js → chunk-YNO5YLZT.js} +5 -5
  104. package/dist/standalone/chunk-YQJIG7QG.js +167 -0
  105. package/dist/standalone/{chunk-HPCOC223.js → chunk-YRC2DXSL.js} +1 -1
  106. package/dist/standalone/{chunk-VND72OIC.js → chunk-YUENB45T.js} +1 -1
  107. package/dist/standalone/{chunk-F4NZZ3LK.js → chunk-YYRXX5Z4.js} +1 -1
  108. package/dist/standalone/chunk-Z2ERBKWN.js +1 -0
  109. package/dist/standalone/{chunk-VUMS4VIV.js → chunk-ZBAR562M.js} +1 -1
  110. package/dist/standalone/{chunk-V5ZKAZR6.js → chunk-ZKEXJDGJ.js} +1 -1
  111. package/dist/standalone/{chunk-BADHCM45.js → chunk-ZO6KBU54.js} +1 -1
  112. package/dist/standalone/{chunk-5YEMXXQZ.js → chunk-ZQGRGSI7.js} +1 -1
  113. package/dist/standalone/studio.js +5 -5
  114. package/dist/styles.css +1 -1
  115. package/package.json +4 -4
  116. package/dist/packem_shared/StudioApp-DKBDIF7N.mjs +0 -1
  117. package/dist/standalone/chunk-C57KLL4U.js +0 -1
  118. package/dist/standalone/chunk-G4H5DPO6.js +0 -33
  119. package/dist/standalone/chunk-GATWEWRW.js +0 -1
  120. package/dist/standalone/chunk-HQJXQWJM.js +0 -1
  121. package/dist/standalone/chunk-JSVT5VBU.js +0 -1
  122. package/dist/standalone/chunk-KQ6YQP3Z.js +0 -1
  123. package/dist/standalone/chunk-OZUPOUHR.js +0 -1
  124. package/dist/standalone/chunk-PLCYDHU3.js +0 -7
  125. package/dist/standalone/chunk-UG6ZNYWH.js +0 -167
  126. package/dist/standalone/chunk-ZUFBUWT4.js +0 -1
@@ -1 +1 @@
1
- import{a as Ie}from"./chunk-BCT3KY76.js";import{a as Se}from"./chunk-5FHGTA7V.js";import{a as _}from"./chunk-KEHWNM7Q.js";import{a as Ne}from"./chunk-YC3TUO5H.js";import"./chunk-EDL46BPM.js";import{a as ge}from"./chunk-M6WDFEUZ.js";import"./chunk-4KPATTV6.js";import{j as V}from"./chunk-SQO3WGXH.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import{a as E}from"./chunk-ECXQQPVU.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as ce}from"./chunk-V5ZKAZR6.js";import{b as z}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as ke}from"./chunk-4OWWWAMB.js";import"./chunk-5XQM44J7.js";import{a as we,b as Pe,c as Ce,d as me,e as le,f as ie}from"./chunk-WVAWKCNQ.js";import"./chunk-VND72OIC.js";import"./chunk-VLQU4G6O.js";import"./chunk-EOFWXI3T.js";import{a as X}from"./chunk-LYVYUTQY.js";import{c as re}from"./chunk-LUHBGCMO.js";import{a as ne,b as ye,c as be,d as ve,e as de}from"./chunk-VUMS4VIV.js";import{d as pe,n as se}from"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as K,h as ue,i as fe,j as he,p as xe,s as ae}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as Te}from"./chunk-A6TVTNKO.js";import{a as Fe,b as Ee}from"./chunk-ADABTCDI.js";import{a as f,d as oe}from"./chunk-5PEAXTYQ.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),je=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),De=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Le=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:De(g,$,je(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(ke,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(ce,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(we,{"data-testid":"pm-table",children:[(0,a.jsx)(Pe,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Ce,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(z,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(z,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(E,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(Oe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function Oe(t){return(0,a.jsx)(z,{variant:"outline",children:t},t)}f(Oe,"$e");var qe=ue(X.runAs),Ue=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),We=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Me=f(()=>{let t=se();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=qe;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},fe(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=We(s);return r!==void 0&&Ue.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Je=f(t=>t===void 0?"undefined":JSON.stringify(t,xe,2),"qe"),Be=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(z,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Je(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(z,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.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:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(z,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(z,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"je"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(ge,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(E,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(z,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"Be"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=se(),i=K(),n=Me(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,j]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(he(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,D=d.find(u=>u.path===b),Z=b!==""&&D?.kind!=="query",L=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(B){v(i("Invalid JSON args: {message}",{message:B.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let B=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(B)}finally{k(!1)}},"L"),O=f(()=>{ae(L())},"$"),q=f(u=>{h(u.target.value)},"U"),U=f(u=>{$(u.target.value)},"W"),W=f(u=>{S(u.target.value)},"M"),M=f(u=>{j(u.target.checked),!u.target.checked&&Z&&h("")},"z"),J=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(ce,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("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:q,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:M,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:U,value:g})]}),(0,a.jsx)(Ne,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:W,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:J,executesWrites:Z,functionPath:b,onRun:O,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Be,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"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."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(be,{children:v}),t[14]=v,t[15]=F):F=t[15];let j;t[16]!==e?(j=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=j):j=t[17];let T;t[18]!==j?(T=(0,a.jsx)(ve,{children:j}),t[18]=j,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ye,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let D;t[25]!==Q||t[26]!==b?(D=(0,a.jsx)(E,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=D):D=t[27];let Z=l==="wire"?"default":"outline",L;t[28]!==e?(L=e("Wire into a procedure"),t[28]=e,t[29]=L):L=t[29];let O;t[30]!==Z||t[31]!==L?(O=(0,a.jsx)(E,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:L}),t[30]=Z,t[31]=L,t[32]=O):O=t[32];let q;t[33]!==D||t[34]!==O?(q=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,O]}),t[33]=D,t[34]=O,t[35]=q):q=t[35];let U;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(U=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(E,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(E,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=U):U=t[42];let W;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(W=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(E,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(E,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=W):W=t[50];let M;t[51]!==s?(M=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=M):M=t[52];let J;t[53]!==s?.kind||t[54]!==e?(J=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=J):J=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==q||t[60]!==U||t[61]!==W||t[62]!==M||t[63]!==J||t[64]!==u?(N=(0,a.jsxs)(de,{children:[q,U,W,M,J,u]}),t[59]=q,t[60]=U,t[61]=W,t[62]=M,t[63]=J,t[64]=u,t[65]=N):N=t[65];let B;return t[66]!==P||t[67]!==N?(B=(0,a.jsxs)(ne,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=B):B=t[68],B},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Le,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(ne,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(de,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
1
+ import{a as Ie}from"./chunk-4FTKFUPJ.js";import{a as Se}from"./chunk-SFGYW6JZ.js";import{a as _}from"./chunk-TPY5BJYD.js";import{a as Ne}from"./chunk-3WPPFTDC.js";import"./chunk-EDL46BPM.js";import{a as ge}from"./chunk-B65U64C3.js";import"./chunk-4KPATTV6.js";import{j as V}from"./chunk-4L2BABMS.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import{a as E}from"./chunk-LTWCT32V.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as ce}from"./chunk-ZKEXJDGJ.js";import{b as z}from"./chunk-STKYARMP.js";import"./chunk-DMQVY5L7.js";import{a as ke}from"./chunk-OGRACGHY.js";import"./chunk-IGSYGAHI.js";import{a as we,b as Pe,c as Ce,d as me,e as le,f as ie}from"./chunk-H4NGBPG2.js";import"./chunk-YUENB45T.js";import"./chunk-AL5S7LVU.js";import"./chunk-EOFWXI3T.js";import{a as X}from"./chunk-LYVYUTQY.js";import{c as re}from"./chunk-U7U4ADXH.js";import{a as ne,b as ye,c as be,d as ve,e as de}from"./chunk-ZBAR562M.js";import{d as pe,n as se}from"./chunk-BD76RVBZ.js";import"./chunk-VKBLXJIZ.js";import{B as K,h as ue,i as fe,j as he,p as xe,s as ae}from"./chunk-7EUM7G2I.js";import"./chunk-Z2ERBKWN.js";import{a as Te}from"./chunk-A6TVTNKO.js";import{a as Fe,b as Ee}from"./chunk-ADABTCDI.js";import{a as f,d as oe}from"./chunk-5PEAXTYQ.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),je=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),De=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Le=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:De(g,$,je(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(ke,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(ce,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(we,{"data-testid":"pm-table",children:[(0,a.jsx)(Pe,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Ce,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(z,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(z,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(E,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(Oe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function Oe(t){return(0,a.jsx)(z,{variant:"outline",children:t},t)}f(Oe,"$e");var qe=ue(X.runAs),Ue=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),We=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Me=f(()=>{let t=se();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=qe;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},fe(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=We(s);return r!==void 0&&Ue.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Je=f(t=>t===void 0?"undefined":JSON.stringify(t,xe,2),"qe"),Be=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(z,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Je(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(z,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.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:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(z,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(z,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"je"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(ge,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(E,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(z,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"Be"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=se(),i=K(),n=Me(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,j]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(he(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,D=d.find(u=>u.path===b),Z=b!==""&&D?.kind!=="query",L=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(B){v(i("Invalid JSON args: {message}",{message:B.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let B=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(B)}finally{k(!1)}},"L"),O=f(()=>{ae(L())},"$"),q=f(u=>{h(u.target.value)},"U"),U=f(u=>{$(u.target.value)},"W"),W=f(u=>{S(u.target.value)},"M"),M=f(u=>{j(u.target.checked),!u.target.checked&&Z&&h("")},"z"),J=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(ce,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("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:q,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:M,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:U,value:g})]}),(0,a.jsx)(Ne,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:W,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:J,executesWrites:Z,functionPath:b,onRun:O,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Be,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"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."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(be,{children:v}),t[14]=v,t[15]=F):F=t[15];let j;t[16]!==e?(j=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=j):j=t[17];let T;t[18]!==j?(T=(0,a.jsx)(ve,{children:j}),t[18]=j,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ye,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let D;t[25]!==Q||t[26]!==b?(D=(0,a.jsx)(E,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=D):D=t[27];let Z=l==="wire"?"default":"outline",L;t[28]!==e?(L=e("Wire into a procedure"),t[28]=e,t[29]=L):L=t[29];let O;t[30]!==Z||t[31]!==L?(O=(0,a.jsx)(E,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:L}),t[30]=Z,t[31]=L,t[32]=O):O=t[32];let q;t[33]!==D||t[34]!==O?(q=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,O]}),t[33]=D,t[34]=O,t[35]=q):q=t[35];let U;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(U=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(E,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(E,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=U):U=t[42];let W;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(W=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(E,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(E,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=W):W=t[50];let M;t[51]!==s?(M=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=M):M=t[52];let J;t[53]!==s?.kind||t[54]!==e?(J=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=J):J=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==q||t[60]!==U||t[61]!==W||t[62]!==M||t[63]!==J||t[64]!==u?(N=(0,a.jsxs)(de,{children:[q,U,W,M,J,u]}),t[59]=q,t[60]=U,t[61]=W,t[62]=M,t[63]=J,t[64]=u,t[65]=N):N=t[65];let B;return t[66]!==P||t[67]!==N?(B=(0,a.jsxs)(ne,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=B):B=t[68],B},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Le,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(ne,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(de,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
@@ -1,4 +1,4 @@
1
- import{a as je}from"./chunk-5FHGTA7V.js";import{a as he}from"./chunk-KEHWNM7Q.js";import{a as le}from"./chunk-MLX6ME3Q.js";import{a as V}from"./chunk-7XZENNML.js";import{d as Ie,f as Oe,g as $e,k as ie}from"./chunk-2NUCBQFU.js";import{a as Ce}from"./chunk-YC3TUO5H.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{j as we}from"./chunk-SQO3WGXH.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import{a as U}from"./chunk-ECXQQPVU.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as E}from"./chunk-V5ZKAZR6.js";import{b as Se}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as ke}from"./chunk-LYVYUTQY.js";import{n as F}from"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as M,b as be,g as ye,h as oe,i as se,j as ue,p as ve,s as Ne,v as ae,x as fe}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as me,b as re}from"./chunk-ADABTCDI.js";import{a as u,d as L}from"./chunk-5PEAXTYQ.js";var Qe=L(te(),1),xe=L(me(),1);var Y=L(te(),1),X=L(me(),1);var A=L(re(),1);var Xe={action:"action",mutation:"mutation",query:"query"},Te=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ne"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"ie"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"ae"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
1
+ import{a as je}from"./chunk-SFGYW6JZ.js";import{a as he}from"./chunk-TPY5BJYD.js";import{a as le}from"./chunk-UWJXX5AV.js";import{a as V}from"./chunk-WC2DKA2R.js";import{d as Ie,f as Oe,g as $e,k as ie}from"./chunk-2NUCBQFU.js";import{a as Ce}from"./chunk-3WPPFTDC.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{j as we}from"./chunk-4L2BABMS.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import{a as U}from"./chunk-LTWCT32V.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as E}from"./chunk-ZKEXJDGJ.js";import{b as Se}from"./chunk-STKYARMP.js";import"./chunk-DMQVY5L7.js";import{a as ke}from"./chunk-LYVYUTQY.js";import{n as F}from"./chunk-BD76RVBZ.js";import"./chunk-VKBLXJIZ.js";import{B as M,b as be,g as ye,h as oe,i as se,j as ue,p as ve,s as Ne,v as ae,x as fe}from"./chunk-7EUM7G2I.js";import"./chunk-Z2ERBKWN.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as me,b as re}from"./chunk-ADABTCDI.js";import{a as u,d as L}from"./chunk-5PEAXTYQ.js";var Qe=L(te(),1),xe=L(me(),1);var Y=L(te(),1),X=L(me(),1);var A=L(re(),1);var Xe={action:"action",mutation:"mutation",query:"query"},Te=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ne"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"ie"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"ae"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
2
  `),"se"),rt=oe(ke.listTables),at=["react","client","cli"],nt=u((t,e)=>{switch(t){case"cli":return et(e);case"client":return Ye(e);default:return Ze(e)}},"re"),Ae=u(t=>{let e=(0,Y.c)(19),{code:a,label:r,testId:n}=t,s=M(),o;e[0]!==a?(o=u(()=>{ae(a)},"c"),e[0]=a,e[1]=o):o=e[1];let i=o,c;e[2]!==r?(c=(0,A.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i||e[7]!==m||e[8]!==l?(p=(0,A.jsx)(U,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=p):p=e[9];let f;e[10]!==c||e[11]!==p?(f=(0,A.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[c,p]}),e[10]=c,e[11]=p,e[12]=f):f=e[12];let h;e[13]!==a||e[14]!==n?(h=(0,A.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=h):h=e[15];let g;return e[16]!==f||e[17]!==h?(g=(0,A.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18],g},"U"),ot=u(t=>{let e=(0,Y.c)(46),{file:a,fn:r,kind:n}=t,s=M(),[o,i]=(0,X.useState)("react"),c,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let w={file:a,fn:r,kind:n},j;e[8]!==s?(j=s("CLI"),e[8]=s,e[9]=j):j=e[9];let O;e[10]!==s?(O=s("Client"),e[10]=s,e[11]=O):O=e[11];let S;e[12]!==s?(S=s("React"),e[12]=s,e[13]=S):S=e[13];let T;e[14]!==j||e[15]!==O||e[16]!==S?(T={cli:j,client:O,react:S},e[14]=j,e[15]=O,e[16]=S,e[17]=T):T=e[17],l=T;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=u(_=>{i(_.currentTarget.dataset.tab)},"B"),e[18]=R):R=e[18],c=R,m=nt(o,w),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=c,e[6]=m,e[7]=l}else c=e[5],m=e[6],l=e[7];let p=m,f=`api.${a}.${r}`,h;e[19]!==f?(h=(0,A.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:f}),e[19]=f,e[20]=h):h=e[20];let g;e[21]!==n||e[22]!==s?(g=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=g):g=e[23];let x;e[24]!==g?(x=(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),e[24]=g,e[25]=x):x=e[25];let v;e[26]!==h||e[27]!==x?(v=(0,A.jsxs)("div",{children:[h,x]}),e[26]=h,e[27]=x,e[28]=v):v=e[28];let N;e[29]!==s?(N=s("Snippet flavour"),e[29]=s,e[30]=N):N=e[30];let y;e[31]!==c||e[32]!==o||e[33]!==l?(y=at.map(w=>(0,A.jsx)(U,{"aria-selected":o===w,"data-tab":w,"data-testid":`api-tab-${w}`,onClick:c,role:"tab",size:"xs",type:"button",variant:o===w?"default":"outline",children:l[w]},w)),e[31]=c,e[32]=o,e[33]=l,e[34]=y):y=e[34];let b;e[35]!==N||e[36]!==y?(b=(0,A.jsx)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:y}),e[35]=N,e[36]=y,e[37]=b):b=e[37];let I=l[o],C=`api-snippet-${o}`,$;e[38]!==p||e[39]!==I||e[40]!==C?($=(0,A.jsx)(Ae,{code:p,label:I,testId:C}),e[38]=p,e[39]=I,e[40]=C,e[41]=$):$=e[41];let k;return e[42]!==$||e[43]!==v||e[44]!==b?(k=(0,A.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[v,b,$]}),e[42]=$,e[43]=v,e[44]=b,e[45]=k):k=e[45],k},"de"),st=u(t=>{let e=(0,Y.c)(19),{name:a}=t,r=M(),n;e[0]!==a?(n=tt(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,A.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let m;e[8]!==o||e[9]!==c?(m=(0,A.jsxs)("div",{children:[o,c]}),e[8]=o,e[9]=c,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let p;e[13]!==s||e[14]!==l?(p=(0,A.jsx)(Ae,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=p):p=e[15];let f;return e[16]!==m||e[17]!==p?(f=(0,A.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,p]}),e[16]=m,e[17]=p,e[18]=f):f=e[18],f},"fe"),Pe=u(t=>{let e=(0,Y.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"m"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let c=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==c||e[5]!==m||e[6]!==s?(l=(0,A.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:c,type:"button",children:r}),e[3]=r,e[4]=c,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),it=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=Te(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"pe"),Re=u(t=>{let e=(0,Y.c)(58),{functions:a,initialShardKey:r}=t,n=M(),s=F(),[o,i]=(0,X.useState)(null),[c,m]=(0,X.useState)(null),l,p;e[0]!==s||e[1]!==r?(l=u(()=>{let _=!1;return s.query(rt,{},se(r??"")).then(P=>(_||i(P),P)).catch(()=>{_||i([])}),()=>{_=!0}},"o"),p=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=p):(l=e[2],p=e[3]),(0,X.useEffect)(l,p);let f,h,g,x,v,N,y,b,I,C;if(e[4]!==a||e[5]!==c||e[6]!==n||e[7]!==o){let _=a??[],P=it(_),q=(o??[]).map(lt).toSorted(dt),J;e[18]===Symbol.for("react.memo_cache_sentinel")?(J=u(K=>{m({kind:"fn",path:K})},"P"),e[18]=J):J=e[18];let W=J,Q;e[19]===Symbol.for("react.memo_cache_sentinel")?(Q=u(K=>{m({kind:"table",name:K})},"j"),e[19]=Q):Q=e[19];let Ve=Q;h=c?.kind==="fn"?_.find(K=>K.path===c.path):void 0,f=_.length>0||q.length>0,g=h===void 0?void 0:Te(h.path),I="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",C="lunora-api-docs",e[20]!==n?(x=n("API resources"),e[20]=n,e[21]=x):x=e[21],v="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==c||e[23]!==n?(ne=u(K=>(0,A.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,A.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K.file||n("(root)")}),K.items.map(ee=>(0,A.jsx)(Pe,{active:c?.kind==="fn"&&c.path===ee.path,label:ee.fn,onSelect:W,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},K.file),"q"),e[22]=c,e[23]=n,e[24]=ne):ne=e[24],y=P.map(ne),b=q.length>0&&(0,A.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,A.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),q.map(K=>(0,A.jsx)(Pe,{active:c?.kind==="table"&&c.name===K,label:K,onSelect:Ve,testId:`api-rail-table-${K}`,value:K},K))]}),e[4]=a,e[5]=c,e[6]=n,e[7]=o,e[8]=f,e[9]=h,e[10]=g,e[11]=x,e[12]=v,e[13]=N,e[14]=y,e[15]=b,e[16]=I,e[17]=C}else f=e[8],h=e[9],g=e[10],x=e[11],v=e[12],N=e[13],y=e[14],b=e[15],I=e[16],C=e[17];let $;e[25]!==f||e[26]!==n?($=!f&&(0,A.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=$):$=e[27];let k;e[28]!==$||e[29]!==x||e[30]!==v||e[31]!==N||e[32]!==y||e[33]!==b?(k=(0,A.jsxs)("nav",{"aria-label":x,className:v,"data-testid":N,children:[y,b,$]}),e[28]=$,e[29]=x,e[30]=v,e[31]=N,e[32]=y,e[33]=b,e[34]=k):k=e[34];let w;e[35]!==c||e[36]!==n?(w=c===null&&(0,A.jsx)(E,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=c,e[36]=n,e[37]=w):w=e[37];let j;e[38]!==c?.kind||e[39]!==h||e[40]!==g?(j=c?.kind==="fn"&&h!==void 0&&g!==void 0&&(0,A.jsx)(ot,{file:g.file,fn:g.fn,kind:h.kind},h.path),e[38]=c?.kind,e[39]=h,e[40]=g,e[41]=j):j=e[41];let O;e[42]!==c?.kind||e[43]!==h||e[44]!==n?(O=c?.kind==="fn"&&h===void 0&&(0,A.jsx)(E,{testId:"api-empty",title:n("API usage snippets")}),e[42]=c?.kind,e[43]=h,e[44]=n,e[45]=O):O=e[45];let S;e[46]!==c?(S=c?.kind==="table"&&(0,A.jsx)(st,{name:c.name}),e[46]=c,e[47]=S):S=e[47];let T;e[48]!==w||e[49]!==j||e[50]!==O||e[51]!==S?(T=(0,A.jsxs)("div",{className:"min-w-0",children:[w,j,O,S]}),e[48]=w,e[49]=j,e[50]=O,e[51]=S,e[52]=T):T=e[52];let R;return e[53]!==k||e[54]!==T||e[55]!==I||e[56]!==C?(R=(0,A.jsxs)("div",{className:I,"data-testid":C,children:[k,T]}),e[53]=k,e[54]=T,e[55]=I,e[56]=C,e[57]=R):R=e[57],R},"ke");function lt(t){return t.name}u(lt,"ue");function dt(t,e){return t.localeCompare(e)}u(dt,"me");var We=L(te(),1);var B=L(te(),1);var z=L(me(),1);var d=L(re(),1);var ct=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","we"),Me=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"Q"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","z"),pt=u(t=>{let e=Me(t);return e!==void 0?t.type??ct(e[0]):ce(t)},"ke"),mt=u(t=>{let e=Me(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"Oe"),ut=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"$e"),ft=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Te"),Z=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Z(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Z(r);return e}case"string":return"";default:return null}},"D"),de=u(t=>{let e=(0,B.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,d.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,d.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"K"),ht=u(t=>{let e=(0,B.c)(40),{name:a,required:r,schema:n}=t,s=M(),o;e[0]!==n?(o=ut(n),e[0]=n,e[1]=o):o=e[1];let i=o,c;e[2]!==n?(c=mt(n),e[2]=n,e[3]=c):c=e[3];let m=c,l=n["x-lunora-table"],p=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=ft(n),e[4]=n,e[5]=f):f=e[5];let h=f,g=r?"*":"?",x;e[6]!==g?(x=(0,d.jsx)("span",{className:"text-muted-foreground",children:g}),e[6]=g,e[7]=x):x=e[7];let v;e[8]!==a||e[9]!==x?(v=(0,d.jsxs)("span",{className:"font-mono text-foreground",children:[a,x]}),e[8]=a,e[9]=x,e[10]=v):v=e[10];let N;e[11]!==n?(N=pt(n),e[11]=n,e[12]=N):N=e[12];let y;e[13]!==N?(y=(0,d.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=y):y=e[14];let b;e[15]!==v||e[16]!==y?(b=(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[v,y]}),e[15]=v,e[16]=y,e[17]=b):b=e[17];let I;e[18]!==n.description?(I=n.description!==void 0&&(0,d.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=I):I=e[19];let C;e[20]!==p||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(C=p&&(0,d.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,d.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,d.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,d.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,d.jsx)(de,{label:s("relation"),value:l})]}),e[20]=p,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=C):C=e[26];let $;e[27]!==I||e[28]!==C||e[29]!==b?($=(0,d.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[b,I,C]}),e[27]=I,e[28]=C,e[29]=b,e[30]=$):$=e[30];let k=$;if(h===void 0){let S;return e[31]!==k?(S=(0,d.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:k}),e[31]=k,e[32]=S):S=e[32],S}let w;e[33]!==k?(w=(0,d.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k}),e[33]=k,e[34]=w):w=e[34];let j;e[35]!==h?(j=(0,d.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,d.jsx)(qe,{schema:h})}),e[35]=h,e[36]=j):j=e[36];let O;return e[37]!==w||e[38]!==j?(O=(0,d.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,j]}),e[37]=w,e[38]=j,e[39]=O):O=e[39],O},"Ce"),qe=u(t=>{let e=(0,B.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,d.jsx)("div",{className:"flex flex-col",children:o.map(c=>{let[m,l]=c;return(0,d.jsx)(ht,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"Z"),_e=u(t=>{let e=(0,B.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,d.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,d.jsx)(qe,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,d.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"V"),gt=["curl","javascript","lunora"],xt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},bt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"je"),yt=u(t=>{let e=Z(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"Ae"),vt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(yt(e),void 0,2),s=JSON.stringify(Z(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";
@@ -1 +1 @@
1
- import{x as d}from"./chunk-G4H5DPO6.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as i}from"./chunk-ADABTCDI.js";import{a as c,d as b}from"./chunk-5PEAXTYQ.js";var n=b(m(),1);var o=b(i(),1);function p(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,o.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(p,"f");function f(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(f,"p");function h(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(h,"m");function x(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(x,"u");function N(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(N,"h");function w(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(w,"x");export{p as a,f as b,h as c,x as d,N as e,w as f};
1
+ import{x as d}from"./chunk-7EUM7G2I.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as i}from"./chunk-ADABTCDI.js";import{a as c,d as b}from"./chunk-5PEAXTYQ.js";var n=b(m(),1);var o=b(i(),1);function p(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,o.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(p,"f");function f(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(f,"p");function h(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(h,"m");function x(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(x,"u");function N(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(N,"h");function w(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(w,"x");export{p as a,f as b,h as c,x as d,N as e,w as f};
@@ -1 +1 @@
1
- import{a as B}from"./chunk-HE2XT2P7.js";import{a as j}from"./chunk-BUYKTV27.js";import"./chunk-DA2CAFXI.js";import"./chunk-2ZNMZPPZ.js";import"./chunk-F4NZZ3LK.js";import"./chunk-ECXQQPVU.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as I}from"./chunk-V5ZKAZR6.js";import{b as w}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as C}from"./chunk-4OWWWAMB.js";import"./chunk-5XQM44J7.js";import{a as A,b as D,c as P,d as b,e as l,f as n}from"./chunk-WVAWKCNQ.js";import"./chunk-VND72OIC.js";import"./chunk-VLQU4G6O.js";import"./chunk-EOFWXI3T.js";import{a as u}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-LUHBGCMO.js";import{a as v,e as S}from"./chunk-VUMS4VIV.js";import{e as R}from"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as k,w as N}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import"./chunk-A6TVTNKO.js";import{b as Q}from"./chunk-ADABTCDI.js";import{a as m,d as H}from"./chunk-5PEAXTYQ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let f=a.__doc__;return typeof f=="string"?R(f)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=k(),f=B(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=f.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),h=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});j(()=>{if(c)return Promise.all([i.poll(),h.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=h.data?.rows??[],U=i.error??h.error,q=i.error===null?h.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(I,{description:t("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:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(w,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(C,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(I,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(D,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(w,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:N(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(S,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:N(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
1
+ import{a as B}from"./chunk-V4X27TLH.js";import{a as j}from"./chunk-43LNUM4U.js";import"./chunk-DA2CAFXI.js";import"./chunk-JGSHDQGZ.js";import"./chunk-YYRXX5Z4.js";import"./chunk-LTWCT32V.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as I}from"./chunk-ZKEXJDGJ.js";import{b as w}from"./chunk-STKYARMP.js";import"./chunk-DMQVY5L7.js";import{a as C}from"./chunk-OGRACGHY.js";import"./chunk-IGSYGAHI.js";import{a as A,b as D,c as P,d as b,e as l,f as n}from"./chunk-H4NGBPG2.js";import"./chunk-YUENB45T.js";import"./chunk-AL5S7LVU.js";import"./chunk-EOFWXI3T.js";import{a as u}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-U7U4ADXH.js";import{a as v,e as S}from"./chunk-ZBAR562M.js";import{e as R}from"./chunk-BD76RVBZ.js";import"./chunk-VKBLXJIZ.js";import{B as k,w as N}from"./chunk-7EUM7G2I.js";import"./chunk-Z2ERBKWN.js";import"./chunk-A6TVTNKO.js";import{b as Q}from"./chunk-ADABTCDI.js";import{a as m,d as H}from"./chunk-5PEAXTYQ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let f=a.__doc__;return typeof f=="string"?R(f)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=k(),f=B(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=f.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),h=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});j(()=>{if(c)return Promise.all([i.poll(),h.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=h.data?.rows??[],U=i.error??h.error,q=i.error===null?h.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(I,{description:t("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:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(v,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T}),(0,e.jsx)(w,{variant:"default",children:t("{count} active",{count:T})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:G})})]})}),U===null?void 0:(0,e.jsx)(C,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(I,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(D,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(w,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:N(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(S,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:N(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
@@ -1 +1 @@
1
- "use client";import{a as c,b as h,c as f}from"./chunk-UG6ZNYWH.js";import"./chunk-4AG356VE.js";import"./chunk-JSVT5VBU.js";import{a as C,b as I}from"./chunk-ADABTCDI.js";import{a as u,d as g}from"./chunk-5PEAXTYQ.js";var e=g(C(),1),p=g(I(),1);var T=u(({code:s,isIncomplete:l=!1,language:t,maxHeight:d,raw:r,className:x,startLine:H,lineNumbers:N,...B})=>{let{shikiTheme:m}=(0,e.useContext)(f),a=h(),[b,i]=(0,e.useState)(r);return(0,e.useEffect)(()=>{if(!a){i(r);return}let o=!0,n=a.highlight({code:s,isIncomplete:l,language:t,themes:m},k=>{o&&i(k)});return n&&i(n),()=>{o=!1}},[s,l,t,m,a,r]),(0,p.jsx)(c,{className:x,language:t,lineNumbers:N,maxHeight:d,result:b,startLine:H,...B})},"T");export{T as HighlightedCodeBlockBody};
1
+ "use client";import{a as c,b as h,c as f}from"./chunk-YQJIG7QG.js";import"./chunk-4AG356VE.js";import"./chunk-Z2ERBKWN.js";import{a as C,b as I}from"./chunk-ADABTCDI.js";import{a as u,d as g}from"./chunk-5PEAXTYQ.js";var e=g(C(),1),p=g(I(),1);var T=u(({code:s,isIncomplete:l=!1,language:t,maxHeight:d,raw:r,className:x,startLine:H,lineNumbers:N,...B})=>{let{shikiTheme:m}=(0,e.useContext)(f),a=h(),[b,i]=(0,e.useState)(r);return(0,e.useEffect)(()=>{if(!a){i(r);return}let o=!0,n=a.highlight({code:s,isIncomplete:l,language:t,themes:m},k=>{o&&i(k)});return n&&i(n),()=>{o=!1}},[s,l,t,m,a,r]),(0,p.jsx)(c,{className:x,language:t,lineNumbers:N,maxHeight:d,result:b,startLine:H,...B})},"T");export{T as HighlightedCodeBlockBody};
@@ -1 +1 @@
1
- import{a as _}from"./chunk-V5ZKAZR6.js";import{b as j}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as J}from"./chunk-4OWWWAMB.js";import"./chunk-5XQM44J7.js";import{a as E,b as G,c as L,d as I,e as c,f as p}from"./chunk-WVAWKCNQ.js";import"./chunk-VND72OIC.js";import{b as q}from"./chunk-VLQU4G6O.js";import"./chunk-EOFWXI3T.js";import{a as O}from"./chunk-LYVYUTQY.js";import{c as H}from"./chunk-LUHBGCMO.js";import{a as D,e as W}from"./chunk-VUMS4VIV.js";import"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as z}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as Q}from"./chunk-A6TVTNKO.js";import{b as V}from"./chunk-ADABTCDI.js";import{a as d,d as F}from"./chunk-5PEAXTYQ.js";var K=F(Q(),1);var r=F(V(),1);var U=["read","insert","update","delete"],M=30,X=d((e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],"z"),Y=d(e=>{let t=new Map;for(let s of e){let a=t.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};a.operations.add(s.on),a.procedures.add(s.procedure),t.set(s.table,a)}return[...t.values()].toSorted((s,a)=>s.table.localeCompare(a.table))},"J"),Z=d(e=>{let t=e.slice(0,M).map(s=>`${s.table}: ${U.filter(a=>s.operations.has(a)).join("/")}`).join("; ");return e.length>M?`${t}; and ${String(e.length-M)} more tables`:t},"K"),pe=d(()=>{let e=(0,K.c)(45),t=z(),s=q(),a=s!==void 0&&!s.unavailable,k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={},e[0]=k):k=e[0];let{data:l,error:C,errorSource:P}=H(O.rlsPolicies,k),o=l!==void 0,m;e[1]!==l?(m=Array.isArray(l?.policies)?l.policies:[],e[1]=l,e[2]=m):m=e[2];let S;e[3]!==m?(S=Y(m),e[3]=m,e[4]=S):S=e[4];let i=S,R;e[5]!==l?(R=Array.isArray(l?.roles)?l.roles:[],e[5]=l,e[6]=R):R=e[6];let T=R,h;e[7]!==C||e[8]!==P?(h=C!==null&&(0,r.jsx)(J,{error:P,testId:"rls-error"}),e[7]=C,e[8]=P,e[9]=h):h=e[9];let u;e[10]!==t?(u=t("Policies"),e[10]=t,e[11]=u):u=e[11];let f;e[12]!==u?(f=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u}),e[12]=u,e[13]=f):f=e[13];let b;e[14]!==s||e[15]!==a||e[16]!==o||e[17]!==t||e[18]!==i?(b=o&&a&&(0,r.jsx)("button",{className:"ms-auto text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"rls-ask-assistant",onClick:d(()=>{s.openAssistant({ask:i.length===0?t("This app declares no row-level-security policies at all. Which tables most need one, and what policy should I write for them?"):t("The Lunora RLS inspector shows these declared policies \u2014 {coverage}. Which tables and operations are still unguarded, and what policy should I add?",{coverage:Z(i)}),suggestions:[t("Which procedures still need .use(rls(...))?"),t("How do I test a policy?")],title:t("Access rules")})},"onClick"),type:"button",children:t("Ask the assistant")}),e[14]=s,e[15]=a,e[16]=o,e[17]=t,e[18]=i,e[19]=b):b=e[19];let x;e[20]!==f||e[21]!==b?(x=(0,r.jsxs)("header",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[f,b]}),e[20]=f,e[21]=b,e[22]=x):x=e[22];let g;e[23]!==o||e[24]!==t||e[25]!==i?(g=o&&i.length===0?(0,r.jsx)(_,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):(0,r.jsx)(W,{className:"px-0",children:(0,r.jsxs)(E,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(G,{children:(0,r.jsxs)(I,{children:[(0,r.jsx)(c,{children:t("Table")}),U.map(n=>(0,r.jsx)(c,{children:X(t,n)},n)),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(L,{children:i.map(n=>(0,r.jsxs)(I,{"data-testid":`rls-table-${n.table}`,children:[(0,r.jsx)(p,{className:"font-mono text-xs",children:n.table}),U.map(B=>(0,r.jsx)(p,{children:n.operations.has(B)?(0,r.jsx)(j,{variant:"secondary",children:t("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},B)),(0,r.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:[...n.procedures].join(", ")})]},n.table))})]})}),e[23]=o,e[24]=t,e[25]=i,e[26]=g):g=e[26];let N;e[27]!==x||e[28]!==g?(N=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[x,g]})}),e[27]=x,e[28]=g,e[29]=N):N=e[29];let y;e[30]!==t?(y=t("Roles"),e[30]=t,e[31]=y):y=e[31];let w;e[32]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[32]=y,e[33]=w):w=e[33];let v;e[34]!==o||e[35]!==T||e[36]!==t?(v=o&&T.length===0?(0,r.jsx)(_,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):(0,r.jsx)(W,{className:"px-0",children:(0,r.jsxs)(E,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(G,{children:(0,r.jsxs)(I,{children:[(0,r.jsx)(c,{children:t("Role")}),(0,r.jsx)(c,{children:t("Description")}),(0,r.jsx)(c,{children:t("Permissions")})]})}),(0,r.jsx)(L,{children:T.map(re)})]})}),e[34]=o,e[35]=T,e[36]=t,e[37]=v):v=e[37];let A;e[38]!==w||e[39]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[38]=w,e[39]=v,e[40]=A):A=e[40];let $;return e[41]!==N||e[42]!==A||e[43]!==h?($=(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-rls-panel",children:[h,N,A]}),e[41]=N,e[42]=A,e[43]=h,e[44]=$):$=e[44],$},"ce");function ee(e){return(0,r.jsx)(j,{variant:"outline",children:e},e)}d(ee,"V");function re(e){return(0,r.jsxs)(I,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(p,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(p,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(p,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(ee)})})]},e.name)}d(re,"Y");export{pe as default};
1
+ import{a as _}from"./chunk-ZKEXJDGJ.js";import{b as j}from"./chunk-STKYARMP.js";import"./chunk-DMQVY5L7.js";import{a as J}from"./chunk-OGRACGHY.js";import"./chunk-IGSYGAHI.js";import{a as E,b as G,c as L,d as I,e as c,f as p}from"./chunk-H4NGBPG2.js";import"./chunk-YUENB45T.js";import{b as q}from"./chunk-AL5S7LVU.js";import"./chunk-EOFWXI3T.js";import{a as O}from"./chunk-LYVYUTQY.js";import{c as H}from"./chunk-U7U4ADXH.js";import{a as D,e as W}from"./chunk-ZBAR562M.js";import"./chunk-BD76RVBZ.js";import"./chunk-VKBLXJIZ.js";import{B as z}from"./chunk-7EUM7G2I.js";import"./chunk-Z2ERBKWN.js";import{a as Q}from"./chunk-A6TVTNKO.js";import{b as V}from"./chunk-ADABTCDI.js";import{a as d,d as F}from"./chunk-5PEAXTYQ.js";var K=F(Q(),1);var r=F(V(),1);var U=["read","insert","update","delete"],M=30,X=d((e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],"z"),Y=d(e=>{let t=new Map;for(let s of e){let a=t.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};a.operations.add(s.on),a.procedures.add(s.procedure),t.set(s.table,a)}return[...t.values()].toSorted((s,a)=>s.table.localeCompare(a.table))},"J"),Z=d(e=>{let t=e.slice(0,M).map(s=>`${s.table}: ${U.filter(a=>s.operations.has(a)).join("/")}`).join("; ");return e.length>M?`${t}; and ${String(e.length-M)} more tables`:t},"K"),pe=d(()=>{let e=(0,K.c)(45),t=z(),s=q(),a=s!==void 0&&!s.unavailable,k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={},e[0]=k):k=e[0];let{data:l,error:C,errorSource:P}=H(O.rlsPolicies,k),o=l!==void 0,m;e[1]!==l?(m=Array.isArray(l?.policies)?l.policies:[],e[1]=l,e[2]=m):m=e[2];let S;e[3]!==m?(S=Y(m),e[3]=m,e[4]=S):S=e[4];let i=S,R;e[5]!==l?(R=Array.isArray(l?.roles)?l.roles:[],e[5]=l,e[6]=R):R=e[6];let T=R,h;e[7]!==C||e[8]!==P?(h=C!==null&&(0,r.jsx)(J,{error:P,testId:"rls-error"}),e[7]=C,e[8]=P,e[9]=h):h=e[9];let u;e[10]!==t?(u=t("Policies"),e[10]=t,e[11]=u):u=e[11];let f;e[12]!==u?(f=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u}),e[12]=u,e[13]=f):f=e[13];let b;e[14]!==s||e[15]!==a||e[16]!==o||e[17]!==t||e[18]!==i?(b=o&&a&&(0,r.jsx)("button",{className:"ms-auto text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"rls-ask-assistant",onClick:d(()=>{s.openAssistant({ask:i.length===0?t("This app declares no row-level-security policies at all. Which tables most need one, and what policy should I write for them?"):t("The Lunora RLS inspector shows these declared policies \u2014 {coverage}. Which tables and operations are still unguarded, and what policy should I add?",{coverage:Z(i)}),suggestions:[t("Which procedures still need .use(rls(...))?"),t("How do I test a policy?")],title:t("Access rules")})},"onClick"),type:"button",children:t("Ask the assistant")}),e[14]=s,e[15]=a,e[16]=o,e[17]=t,e[18]=i,e[19]=b):b=e[19];let x;e[20]!==f||e[21]!==b?(x=(0,r.jsxs)("header",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[f,b]}),e[20]=f,e[21]=b,e[22]=x):x=e[22];let g;e[23]!==o||e[24]!==t||e[25]!==i?(g=o&&i.length===0?(0,r.jsx)(_,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):(0,r.jsx)(W,{className:"px-0",children:(0,r.jsxs)(E,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(G,{children:(0,r.jsxs)(I,{children:[(0,r.jsx)(c,{children:t("Table")}),U.map(n=>(0,r.jsx)(c,{children:X(t,n)},n)),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(L,{children:i.map(n=>(0,r.jsxs)(I,{"data-testid":`rls-table-${n.table}`,children:[(0,r.jsx)(p,{className:"font-mono text-xs",children:n.table}),U.map(B=>(0,r.jsx)(p,{children:n.operations.has(B)?(0,r.jsx)(j,{variant:"secondary",children:t("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},B)),(0,r.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:[...n.procedures].join(", ")})]},n.table))})]})}),e[23]=o,e[24]=t,e[25]=i,e[26]=g):g=e[26];let N;e[27]!==x||e[28]!==g?(N=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[x,g]})}),e[27]=x,e[28]=g,e[29]=N):N=e[29];let y;e[30]!==t?(y=t("Roles"),e[30]=t,e[31]=y):y=e[31];let w;e[32]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[32]=y,e[33]=w):w=e[33];let v;e[34]!==o||e[35]!==T||e[36]!==t?(v=o&&T.length===0?(0,r.jsx)(_,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):(0,r.jsx)(W,{className:"px-0",children:(0,r.jsxs)(E,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(G,{children:(0,r.jsxs)(I,{children:[(0,r.jsx)(c,{children:t("Role")}),(0,r.jsx)(c,{children:t("Description")}),(0,r.jsx)(c,{children:t("Permissions")})]})}),(0,r.jsx)(L,{children:T.map(re)})]})}),e[34]=o,e[35]=T,e[36]=t,e[37]=v):v=e[37];let A;e[38]!==w||e[39]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[38]=w,e[39]=v,e[40]=A):A=e[40];let $;return e[41]!==N||e[42]!==A||e[43]!==h?($=(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-rls-panel",children:[h,N,A]}),e[41]=N,e[42]=A,e[43]=h,e[44]=$):$=e[44],$},"ce");function ee(e){return(0,r.jsx)(j,{variant:"outline",children:e},e)}d(ee,"V");function re(e){return(0,r.jsxs)(I,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(p,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(p,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(p,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(ee)})})]},e.name)}d(re,"Y");export{pe as default};
@@ -1 +1 @@
1
- import{a as b}from"./chunk-WY23EROJ.js";import{x as v}from"./chunk-G4H5DPO6.js";import{a as x}from"./chunk-A6TVTNKO.js";import{b as g}from"./chunk-ADABTCDI.js";import{a as c,d as l}from"./chunk-5PEAXTYQ.js";var u=l(x(),1);var s=l(g(),1);var p=b("flex items-start gap-2 rounded-md border px-3 py-2 text-sm [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0",{defaultVariants:{variant:"default"},variants:{variant:{default:"border-border bg-muted/40 text-foreground",destructive:"border-destructive/40 bg-destructive/5 text-destructive",warning:"border-amber-500/40 bg-amber-500/5 text-amber-700 dark:text-amber-400"}}}),j=c(f=>{let t=(0,u.c)(10),{children:d,className:i,icon:m,testId:o,variant:n}=f,e;t[0]!==i||t[1]!==n?(e=v(p({variant:n}),i),t[0]=i,t[1]=n,t[2]=e):e=t[2];let r;t[3]!==d?(r=(0,s.jsx)("div",{className:"min-w-0 flex-1",children:d}),t[3]=d,t[4]=r):r=t[4];let a;return t[5]!==m||t[6]!==e||t[7]!==r||t[8]!==o?(a=(0,s.jsxs)("div",{className:e,"data-testid":o,role:"alert",children:[m,r]}),t[5]=m,t[6]=e,t[7]=r,t[8]=o,t[9]=a):a=t[9],a},"N");export{j as a};
1
+ import{a as b}from"./chunk-VKBLXJIZ.js";import{x as v}from"./chunk-7EUM7G2I.js";import{a as x}from"./chunk-A6TVTNKO.js";import{b as g}from"./chunk-ADABTCDI.js";import{a as c,d as l}from"./chunk-5PEAXTYQ.js";var u=l(x(),1);var s=l(g(),1);var p=b("flex items-start gap-2 rounded-md border px-3 py-2 text-sm [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0",{defaultVariants:{variant:"default"},variants:{variant:{default:"border-border bg-muted/40 text-foreground",destructive:"border-destructive/40 bg-destructive/5 text-destructive",warning:"border-amber-500/40 bg-amber-500/5 text-amber-700 dark:text-amber-400"}}}),j=c(f=>{let t=(0,u.c)(10),{children:d,className:i,icon:m,testId:o,variant:n}=f,e;t[0]!==i||t[1]!==n?(e=v(p({variant:n}),i),t[0]=i,t[1]=n,t[2]=e):e=t[2];let r;t[3]!==d?(r=(0,s.jsx)("div",{className:"min-w-0 flex-1",children:d}),t[3]=d,t[4]=r):r=t[4];let a;return t[5]!==m||t[6]!==e||t[7]!==r||t[8]!==o?(a=(0,s.jsxs)("div",{className:e,"data-testid":o,role:"alert",children:[m,r]}),t[5]=m,t[6]=e,t[7]=r,t[8]=o,t[9]=a):a=t[9],a},"N");export{j as a};