@lunora/studio 1.0.0-alpha.390 → 1.0.0-alpha.391
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/standalone/{chunk-RJJRUUTE.js → chunk-24N5RZRI.js} +1 -1
- package/dist/standalone/{chunk-KIQ34774.js → chunk-2G7JHC6S.js} +1 -1
- package/dist/standalone/{chunk-OJR7BDKC.js → chunk-2QYMVMYR.js} +1 -1
- package/dist/standalone/{chunk-OWCTA7GY.js → chunk-3IGIBOCF.js} +1 -1
- package/dist/standalone/{chunk-L6VJTINV.js → chunk-3K56NZDT.js} +1 -1
- package/dist/standalone/{chunk-NFI2TNKU.js → chunk-4RII5S3H.js} +1 -1
- package/dist/standalone/{chunk-I6YVDNKQ.js → chunk-4YWFAODW.js} +1 -1
- package/dist/standalone/{chunk-ZP453BM4.js → chunk-4ZEERXMN.js} +1 -1
- package/dist/standalone/{chunk-LRUYEVHH.js → chunk-6C555TU5.js} +1 -1
- package/dist/standalone/{chunk-CO6R6GCX.js → chunk-73D52JHL.js} +1 -1
- package/dist/standalone/{chunk-HCK62XWB.js → chunk-7Z5MTBZB.js} +1 -1
- package/dist/standalone/{chunk-UFS6UP4Z.js → chunk-B3GOYA2R.js} +1 -1
- package/dist/standalone/{chunk-SGIEXE5J.js → chunk-BBJJJI7F.js} +1 -1
- package/dist/standalone/{chunk-2CDROYSG.js → chunk-BULGXI7X.js} +1 -1
- package/dist/standalone/chunk-C6FOSG2A.js +7 -0
- package/dist/standalone/{chunk-BU5VWXRR.js → chunk-CDJMXV45.js} +1 -1
- package/dist/standalone/{chunk-OQTMT64P.js → chunk-DRFBJBEN.js} +1 -1
- package/dist/standalone/{chunk-6K4F727K.js → chunk-E7QYOQWH.js} +1 -1
- package/dist/standalone/{chunk-CY45AO5T.js → chunk-EAYN3IGE.js} +1 -1
- package/dist/standalone/{chunk-AXDXIMCN.js → chunk-EGUFPKS4.js} +1 -1
- package/dist/standalone/{chunk-7ASIMMZY.js → chunk-EHU26D2V.js} +1 -1
- package/dist/standalone/{chunk-HJOXP6C3.js → chunk-FGHKL42J.js} +1 -1
- package/dist/standalone/{chunk-JZN3MNJX.js → chunk-FKF2BRRN.js} +1 -1
- package/dist/standalone/{chunk-AXB32N5O.js → chunk-FR22DHUN.js} +1 -1
- package/dist/standalone/{chunk-DZV6YFWZ.js → chunk-GERWUNAM.js} +1 -1
- package/dist/standalone/{chunk-BRPLE2Z6.js → chunk-GTJYJW4A.js} +1 -1
- package/dist/standalone/{chunk-QTWNCDLK.js → chunk-H54J65DJ.js} +1 -1
- package/dist/standalone/{chunk-U7NVTULW.js → chunk-HB6ABGZU.js} +1 -1
- package/dist/standalone/{chunk-ZADOHFZB.js → chunk-HQZ7B5EU.js} +1 -1
- package/dist/standalone/{chunk-BWBECJFT.js → chunk-I2XT2POX.js} +1 -1
- package/dist/standalone/chunk-IPDJJHZK.js +1 -0
- package/dist/standalone/{chunk-WEPANQGT.js → chunk-KRSQ6N4R.js} +1 -1
- package/dist/standalone/{chunk-V4B7ZPEG.js → chunk-KYZZGUIG.js} +1 -1
- package/dist/standalone/{chunk-Y2AKO63C.js → chunk-KZXAVLQ4.js} +1 -1
- package/dist/standalone/{chunk-PBXRUYD3.js → chunk-LIZUJ6AU.js} +1 -1
- package/dist/standalone/{chunk-KGQPMSNY.js → chunk-LQWEU5ZI.js} +1 -1
- package/dist/standalone/{chunk-EKXAE4PS.js → chunk-MAWEZEX6.js} +1 -1
- package/dist/standalone/{chunk-L7TFQUD7.js → chunk-MKH4V2DR.js} +1 -1
- package/dist/standalone/{chunk-2YDK4MZM.js → chunk-NMZ34D2Z.js} +1 -1
- package/dist/standalone/{chunk-4YVCKOYF.js → chunk-NNKVZBKP.js} +1 -1
- package/dist/standalone/{chunk-2M37OAK3.js → chunk-NTVQ4PWU.js} +1 -1
- package/dist/standalone/{chunk-HUL247LG.js → chunk-OG7AJWFV.js} +1 -1
- package/dist/standalone/{chunk-HLBZ7OAO.js → chunk-PPC2ESMI.js} +1 -1
- package/dist/standalone/{chunk-KZXSJF7K.js → chunk-PTL32GA6.js} +1 -1
- package/dist/standalone/{chunk-5EIGSLIK.js → chunk-Q6VRHDZJ.js} +1 -1
- package/dist/standalone/{chunk-3OVQC66W.js → chunk-QJFCK6J4.js} +1 -1
- package/dist/standalone/{chunk-ELPLRD4S.js → chunk-SKK6PGQ3.js} +1 -1
- package/dist/standalone/{chunk-3YCWRKSW.js → chunk-SKMAKUOG.js} +1 -1
- package/dist/standalone/{chunk-NP6CBOPK.js → chunk-SQ3M7JDP.js} +1 -1
- package/dist/standalone/{chunk-375GZTYC.js → chunk-TS4CMM2L.js} +1 -1
- package/dist/standalone/{chunk-CVJDEN5L.js → chunk-UYW53K2N.js} +1 -1
- package/dist/standalone/{chunk-LYWT6GTX.js → chunk-VJGP3BTD.js} +1 -1
- package/dist/standalone/{chunk-FYAUOSTX.js → chunk-W6UUGZH7.js} +1 -1
- package/dist/standalone/{chunk-P3ML7HGE.js → chunk-WLMTK3FN.js} +1 -1
- package/dist/standalone/{chunk-AQG5OGO4.js → chunk-WMKSIEJP.js} +1 -1
- package/dist/standalone/{chunk-CXXCVBMK.js → chunk-WODOEE2A.js} +1 -1
- package/dist/standalone/{chunk-U5UEDY4E.js → chunk-Y34WXKCA.js} +1 -1
- package/dist/standalone/{chunk-2OSZRVNW.js → chunk-YDFZA3T4.js} +1 -1
- package/dist/standalone/{chunk-IXCSVK2Z.js → chunk-Z3AINTU6.js} +1 -1
- package/dist/standalone/{chunk-ERUKFS3I.js → chunk-ZLAVM2NT.js} +1 -1
- package/dist/standalone/{chunk-4MFQ4XEJ.js → chunk-ZQ7KYIN6.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +3 -3
- package/dist/standalone/chunk-K5W5C237.js +0 -1
- package/dist/standalone/chunk-QFN62JQJ.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ie}from"./chunk-NAGIOR23.js";import{a as Se}from"./chunk-VQQEDEHH.js";import{a as _}from"./chunk-MNN3YCKF.js";import{a as Ne}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import{a as ge}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as V}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as E}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as ce}from"./chunk-HMMALUXM.js";import{b as z}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as ke}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as we,b as Pe,c as Ce,d as me,e as le,f as ie}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as X}from"./chunk-LYVYUTQY.js";import{c as re}from"./chunk-LRUYEVHH.js";import{a as ne,b as ye,c as be,d as ve,e as de}from"./chunk-XV2XEUUB.js";import{d as pe,n as se}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as K,h as ue,i as fe,j as he,p as xe,s as ae}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.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-NAGIOR23.js";import{a as Se}from"./chunk-VQQEDEHH.js";import{a as _}from"./chunk-MNN3YCKF.js";import{a as Ne}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import{a as ge}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as V}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as E}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as ce}from"./chunk-HMMALUXM.js";import{b as z}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as ke}from"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import{a as we,b as Pe,c as Ce,d as me,e as le,f as ie}from"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as X}from"./chunk-LYVYUTQY.js";import{c as re}from"./chunk-6C555TU5.js";import{a as ne,b as ye,c as be,d as ve,e as de}from"./chunk-XV2XEUUB.js";import{d as pe,n as se}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as K,h as ue,i as fe,j as he,p as xe,s as ae}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.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 +1 @@
|
|
|
1
|
-
import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-YLC2ZYCL.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-LLD7TMBV.js";import{a as j,b as te}from"./chunk-
|
|
1
|
+
import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-YLC2ZYCL.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-LLD7TMBV.js";import{a as j,b as te}from"./chunk-WMKSIEJP.js";import{a as V}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-6C555TU5.js";import"./chunk-XV2XEUUB.js";import{n as Q}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as q,h as M,i as C,o as G,s as N}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as _}from"./chunk-5PEAXTYQ.js";var E=_(me(),1);var c=_(he(),1);var S=_(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:n}=t;if(typeof n!="string"||n.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:r}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof r=="string"&&r.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(n=>JSON.stringify(n)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:n,indexName:a,table:r,testId:i}=t,u=q(),[h,f]=(0,c.useState)(null),m;e[0]!==n||e[1]!==a?(m=l(()=>{let b=be(a,n),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=n,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==r||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:r})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:r}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=r,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==r?(p=u("Copy index declaration for {table}",{table:r}),e[11]=u,e[12]=r,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let n=new Map;for(let a of e){let r=`${a.table} ${a.index}`;n.set(r,(n.get(r)??0)+a.reads)}return t.map(a=>({index:a.index,reads:n.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let n of t)for(let a of n.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([n,a])=>({scans:a,table:n}))},"Te"),re=l((t,e)=>e.filter(n=>n.type!=="vector"&&n.unique!==!0).map(n=>({index:n.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),n=ve(t.functions??[]),a=t.shardTraffic??[],r=t.analyticsMetrics,i=r&&r.indexHits.length>0?r.indexHits:e,u=r&&r.tableScans.length>0?r.tableScans:n,h=r&&r.shardTraffic.length>0?r.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>j(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:n,table:a}=t,r=q(),i;e[0]!==n||e[1]!==a?(i=l(()=>{n(a)},"o"),e[0]=n,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==r||e[4]!==a?(f=r("Add index on {table}",{table:a}),e[3]=r,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let n=Q(),a=D(),r=q(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>n.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await n.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await n.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await n.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(r,o):`${ie(r,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(r,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=j(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,r]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-NAGIOR23.js";import{a as L}from"./chunk-HMMALUXM.js";import{b as S}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-ZJIYJZ6F.js";import"./chunk-EOFWXI3T.js";import{a as C}from"./chunk-LYVYUTQY.js";import{c as w}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-NAGIOR23.js";import{a as L}from"./chunk-HMMALUXM.js";import{b as S}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-ZJIYJZ6F.js";import"./chunk-EOFWXI3T.js";import{a as C}from"./chunk-LYVYUTQY.js";import{c as w}from"./chunk-6C555TU5.js";import{a as I,e as $}from"./chunk-XV2XEUUB.js";import"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as b}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as _}from"./chunk-A6TVTNKO.js";import{b as j}from"./chunk-ADABTCDI.js";import{a as f,d as y}from"./chunk-5PEAXTYQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=b(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=w(C.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(L,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(I,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(S,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ct}from"./chunk-CFQQHZYU.js";import{a as lt}from"./chunk-NAGIOR23.js";import"./chunk-JNWK5MJC.js";import{a as De}from"./chunk-MNN3YCKF.js";import"./chunk-CP3LCFFM.js";import"./chunk-Y2YLTUMD.js";import"./chunk-CQDENTSP.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as it}from"./chunk-2KTN53PK.js";import{a as nt}from"./chunk-YLC2ZYCL.js";import{b as rt}from"./chunk-EDL46BPM.js";import{a as Ye}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{h as Ue,i as ze}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as Ze}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as Xe}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as qe}from"./chunk-HMMALUXM.js";import{b as et}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Te}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as ot,b as st,c as dt,d as _e,e as q,f as T}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as F}from"./chunk-LYVYUTQY.js";import{c as de}from"./chunk-LRUYEVHH.js";import{a as tt,e as at}from"./chunk-XV2XEUUB.js";import{n as Ge}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as ce,h as He,i as Qe,j as Ve,s as Se,w as je,x as le}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as Be}from"./chunk-A6TVTNKO.js";import{a as Pe,b as We}from"./chunk-ADABTCDI.js";import{a as d,d as se}from"./chunk-5PEAXTYQ.js";var be=se(Be(),1),he=se(Pe(),1);var mt=se(Be(),1),O=se(Pe(),1);var m=se(We(),1);var Tt=He(F.runMigration),ut=d(t=>{let e=(0,mt.c)(98),{initialShardKey:r}=t,n=Ge(),a=ce(),{queryShardKey:o,setShardKey:i,shardKey:s}=it(r),[l,f]=(0,O.useState)(""),[h,g]=(0,O.useState)("up"),[p,b]=(0,O.useState)(!0),[v,x]=(0,O.useState)(!1),[y,u]=(0,O.useState)(null),[w,k]=(0,O.useState)(null),L;e[0]!==s?(L=s.trim(),e[0]=s,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=de(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ve,ye;e[5]!==o||e[6]!==$.data?(ve=d(()=>{$.data!==void 0&&rt(o)},"W"),ye=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ve,e[8]=ye):(ve=e[7],ye=e[8]),(0,O.useEffect)(ve,ye);let xe;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==s||e[14]!==$||e[15]!==a){let I=d(async()=>{let Ae=l.trim();if(Ae===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await n.query(Tt,{direction:h,dryRun:p,id:Ae},Qe(s));u(Le),$.refetch()}catch(Le){let qt=Le;u(null),k(Ve(qt))}x(!1)},"u");xe=d(()=>{Se(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=l,e[13]=s,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=d(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Ot=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=d(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=d(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let jt=Ne,_;e[20]!==i||e[21]!==s?(_=(0,m.jsx)(nt,{onChange:i,testId:"mg-shard-input",value:s}),e[20]=i,e[21]=s,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(lt,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(qe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(tt,{className:"overflow-hidden py-0",children:(0,m.jsx)(at,{className:"px-0",children:(0,m.jsxs)(ot,{"data-testid":"mg-table",children:[(0,m.jsx)(st,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(dt,{children:N.map(Ct)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(Ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Ot,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:jt,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==v||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(Xe,{"data-testid":"mg-run",disabled:v||!C,onClick:ke,type:"button",children:a(v?"Running\u2026":"Run")}):(0,m.jsx)(Ye,{confirmLabel:a(v?"Running\u2026":"Run migration?"),disabled:v||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=v,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ne;e[82]!==B||e[83]!==re?(ne=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==y||e[88]!==a?(oe=y!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[y.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:y.status}),y.processed,a(", changed"),y.changed]}),e[87]=y,e[88]=a,e[89]=oe):oe=e[89];let Oe;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ne||e[95]!==ie||e[96]!==oe?(Oe=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ne,ie,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=Oe):Oe=e[97],Oe},"yt");function Ct(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(et,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:je(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}d(Ct,"Je");var c=se(We(),1);var Ke=1;function Mt(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}d(Mt,"ue");var me=d(t=>typeof t=="object"&&t!==null,"O"),It=d(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","me"),Ft=d(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!It(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"he"),Rt=d((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"pe"),ht=d(t=>t.unique!==void 0,"Q"),ge=d(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Mt(a)),"M"),ft=d(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"U"),pt=d(t=>t.kind==="union"&&t.members?t.members.map(e=>ft(e)):[ft({...t,nullable:!1,optional:!1})],"W"),Lt=d((t,e)=>{if(e.kind!=="union")return!1;let r=pt(e);return pt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"ge"),S=d(t=>{switch(t.kind){case"array":return`array(${t.of?S(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?S(t.key):"?"}, ${t.of?S(t.of):"?"})`;case"union":return(t.members??[]).map(e=>S(e)).join(" | ");default:return t.kind}},"x"),fe=d((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),pe=d((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"F"),wt=d((t,e)=>{let r=JSON.stringify(t),n=JSON.stringify(e);return r===n?0:r<n?-1:1},"N"),ue=d(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(wt)}:{}}),"S"),gt=d(t=>t.kind==="union"?t.members??[]:[t],"B"),_t=d((t,e)=>{let r=[...t],n=[...e],a=new Set,o=new Set,i=d((s,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=n.findIndex((p,b)=>!a.has(b)&&s(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],n[g]]=Me(h,n[g])))}},"s");return i((s,l)=>JSON.stringify(s)===JSON.stringify(l),!1),i((s,l)=>ge(ue(s))===ge(ue(l)),!0),[r,n]},"ve"),Me=d((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=_t(gt(t),gt(e)),i=d((s,l)=>s.kind==="union"?{...s,members:l.toSorted(wt)}:l[0],"s");return[i(t,a),i(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},n={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],n[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],i=e.fields?.[a];o&&i&&r.fields&&n.fields&&([r.fields[a],n.fields[a]]=Me(o,i))}return[{...t,...r},{...e,...n}]},"R"),Dt=d((t,e,r,n,a)=>{let[o,i]=Me(r,n);if(o.kind===i.kind&&(!a||ge(o)===ge(i)))return;if(a&&Lt(o,i))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${S(o)} \u2192 ${S(i)} \u2014 every stored value stays valid`);if(o.kind!==i.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${i.kind} \u2014 add a data migration to convert existing values`);let s=Object.values(i.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&s.length>0&&s.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${S(o)} \u2192 ${S(i)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Kt=d((t,e,r,n,a)=>{let o=[];return r.unique!==n.unique&&o.push(n.unique===!0?{...fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`),field:e,uniqueOn:[e]}:pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&o.push(n.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),a&&r.refined!==n.refined&&o.push(n.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),o},"ye"),$t=d((t,e,r,n,a=!0)=>{let o=[],i=ht(r)&&ht(n),s=Dt(t,e,r,n,i);return s&&o.push(s),i&&o.push(...Kt(t,e,r,n,a)),r.optional&&!n.optional?o.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&o.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),o},"ee"),Et=d((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"xe"),Jt=d((t,e)=>e.refinementsRecorded!==!0||t.refinementsRecorded===!0,"ke"),At=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push({...Et(t,a,o),field:a}):n.push(...$t(t,a,i,o,Jt(e,r)).map(s=>({...s,field:a})))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.push({field:a,remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"$e"),Pt=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Rt(i,o)||n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`index ${a} on ${t} changed shape and is unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"changedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`index ${a} on ${t} changed shape \u2014 a query that relied on the old index may need updating`,table:t,type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&n.push({remediation:"none",severity:"safe",index:a,summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` no longer compiles`,table:t,scope:"table",type:"removedIndex"})},"we"),Bt=d((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`removed relation ${t}.${a} \u2014 the stored foreign-key values stay in place, but its \`onDelete\` action no longer runs and a \`with: { ${a} }\` read no longer compiles`,table:t,type:"removedRelation",warning:!0})},"Oe"),Ee="shardBy:_unknown_",Ce="global",Wt=d((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"Se"),Ut=d((t,e,r)=>{if(e===r)return r!==Ee?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${Ee}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Wt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode",...r===Ee?{}:{coverage:{shardMode:r,table:t}}}},"je"),bt=d(t=>t.memory!==void 0,"K"),vt=d(t=>t.after??0,"Y"),Je=d(t=>t.after===void 0?`{ field: "${t.field}" }`:`{ after: ${String(t.after)}, field: "${t.field}" }`,"_"),R=d(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),zt=d((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=d((s,l)=>({coverage:{table:t,ttl:{...l.after===void 0?{}:{after:l.after},field:l.field}},expiry:{...l.after===void 0?{}:{after:l.after},field:l.field,...e===void 0?{}:{previous:{...e.after===void 0?{}:{after:e.after},field:e.field}}},remediation:"backfill",scope:"table",severity:"breaking",summary:s,table:t,type:"changedTtlPolicy"}),"n"),a=d(s=>({remediation:"none",scope:"table",severity:"safe",summary:s,table:t,type:"changedTtlPolicy",warning:!0}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept, so they stay until something else deletes them`);if(e===void 0)return n(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; refresh or clear "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);if(e.field!==r.field)return n(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; populate "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);let o=vt(e),i=vt(r);return i<o?n(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; refresh "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r):i>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 every row stays, and expires later than it would have`):void 0},"Te"),Ht=d((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode",coverage:{memory:!0,table:t}}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&n.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering",identityRewrites:!0}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer .commitOrdered() \u2014 stored rows are untouched, but new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers`,table:t,type:"changedCommitOrdering",warning:!0}),n},"Fe"),Qt=d((t,e,r,n)=>{let a=Ut(t,e.shardMode,r.shardMode);if(a&&n.push(a),bt(e)&&bt(r)){n.push(...Ht(t,e,r));let o=zt(t,e.ttl,r.ttl);o&&n.push(o)}At(t,e,r,n),Pt(t,e,r,n),Bt(t,e,r,n)},"qe"),Vt=d((t,e)=>{let r=[],n=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Qt(a,i,o,r)}for(let a of Object.keys(n))e.tables[a]===void 0&&r.push({remediation:"none",scope:"table",severity:"safe",summary:`removed table ${a} \u2014 its rows are left in place in each shard's SQLite (nothing deletes them) but are unreachable through the schema; export the shard first if the data must be kept, or declare the table again to reach it`,table:a,type:"removedTable",warning:!0});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (export then import to move it). Revert the change, or declare a migration with covers: { jurisdiction: "${e.jurisdiction??"none"}" } once the data is moved.`,type:"changedJurisdiction",coverage:{jurisdiction:e.jurisdiction??"none"}})}return{changes:r}},"Me"),yt=d(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:S(r)})),"z"),xt=d((t,e,r)=>{let n={},a=e?.fields??{},o=r?.fields??{};for(let[i,s]of Object.entries(o)){let l=a[i];l===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=$t(t,i,l,s).length===0?"unchanged":"changed"}for(let i of Object.keys(a))o[i]===void 0&&(n[i]="removed");return n},"X"),Gt=d((t,e)=>{let{changes:r}=Vt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],o=d((i,s)=>i?"added":n.has(s)?"changed":"context","r");for(let[i,s]of Object.entries(e.tables)){let l=t?.tables[i],f=o(l===void 0,i);a.push({columns:yt(s),fieldStatus:xt(i,l,s),name:i,shardMode:s.shardMode,status:f})}for(let[i,s]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:yt(s),fieldStatus:xt(i,s,void 0),name:i,shardMode:s.shardMode,status:"removed"});return a.sort((i,s)=>i.name.localeCompare(s.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Ce"),kt=d(t=>{let e=Ft(t);return e.status==="ok"?e.snapshot:void 0},"Z"),Xt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Yt=d(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ie"),Zt=d(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:o,seq:i}=t,s=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==s?(l=le("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",s),e[0]=s,e[1]=l):l=e[1];let f=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=d(()=>{a(n)},"m"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==i?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=g):g=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let v;e[11]!==g||e[12]!==b?(v=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=v):v=e[13];let x;e[14]!==r?(x=je(r),e[14]=r,e[15]=x):x=e[15];let y;e[16]!==x?(y=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=y):y=e[17];let u;return e[18]!==y||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==v?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[v,y]})}),e[18]=y,e[19]=l,e[20]=f,e[21]=h,e[22]=v,e[23]=u):u=e[23],u},"Ee"),ea=d(t=>{let e=(0,be.c)(26),{breaking:r,count:n,first:a}=t,o=ce();if(a){let b;e[0]!==n?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=b):b=e[1];let v;e[2]!==o?(v=o("tables"),e[2]=o,e[3]=v):v=e[3];let x;e[4]!==v?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=x):x=e[5];let y;return e[6]!==b||e[7]!==x?(y=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=y):y=e[8],y}let i=r>0&&"text-destructive",s;e[9]!==i?(s=le("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=s):s=e[10];let l;e[11]!==n||e[12]!==s?(l=(0,c.jsx)("span",{className:s,children:n}),e[11]=n,e[12]=s,e[13]=l):l=e[13];let f;e[14]!==n||e[15]!==o?(f=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Ae"),Nt={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},ta=d((t,e)=>{let r=`${Nt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"De"),aa=d(t=>{let e=new Map;for(let n of t){let a=n.table??"",o=e.get(a);o===void 0?e.set(a,[n]):o.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Le"),ra=d(t=>{let e=(0,be.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"Je"),na=d(({pane:t,shardKey:e=""})=>{let r=ce(),n=ze(),a=Ue({strict:!1}).version,o=d(u=>{Se(n({search:{version:u},to:"/migrations"}))},"s"),i=de(F.schemaHistory,{},{shardKey:e}),s=i.data?.versions??[],l=a!==void 0&&s.some(u=>u.hash===a)?a:s[0]?.hash,f=s.findIndex(u=>u.hash===l),h=f===-1?void 0:s[f+1]?.hash,g=de(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=de(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=kt(g.data?.version?.snapshotJson);if(u!==void 0)return Gt(kt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),v=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Yt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Xt[w.status];return u},[b]);if(i.error!==null)return(0,c.jsx)(Te,{error:i.errorSource,testId:"sh-error"});if(s.length===0)return(0,c.jsx)(qe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let y=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ra,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:s.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(ea,{breaking:b?.breakingCount??0,count:h===void 0?v.length:y.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(ct,{fill:!0,nodeClasses:x,tables:v,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:aa(y).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=Nt[k.type],j=k.severity==="breaking",M=ta(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:le("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:le("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Pe"),ia=d(t=>le("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"_e"),_a=d(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,n=ce(),[a,o]=(0,he.useState)("diagram"),i;e[0]!==a?(i=d((g,p,b,v)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ia(a===g),"data-testid":b,onClick:d(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,v!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"s"),e[0]=a,e[1]=i):i=e[1];let s=i,l;e[2]!==n||e[3]!==s?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[s("diagram",n("Diagram"),"mg-pane-diagram"),s("changes",n("Changes"),"mg-pane-changes"),s("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=s,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ut,{initialShardKey:r})}):(0,c.jsx)(na,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"et");export{_a as default};
|
|
1
|
+
import{a as ct}from"./chunk-CFQQHZYU.js";import{a as lt}from"./chunk-NAGIOR23.js";import"./chunk-JNWK5MJC.js";import{a as De}from"./chunk-MNN3YCKF.js";import"./chunk-CP3LCFFM.js";import"./chunk-Y2YLTUMD.js";import"./chunk-CQDENTSP.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as it}from"./chunk-2KTN53PK.js";import{a as nt}from"./chunk-YLC2ZYCL.js";import{b as rt}from"./chunk-EDL46BPM.js";import{a as Ye}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{h as Ue,i as ze}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as Ze}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as Xe}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as qe}from"./chunk-HMMALUXM.js";import{b as et}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Te}from"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import{a as ot,b as st,c as dt,d as _e,e as q,f as T}from"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as F}from"./chunk-LYVYUTQY.js";import{c as de}from"./chunk-6C555TU5.js";import{a as tt,e as at}from"./chunk-XV2XEUUB.js";import{n as Ge}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as ce,h as He,i as Qe,j as Ve,s as Se,w as je,x as le}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as Be}from"./chunk-A6TVTNKO.js";import{a as Pe,b as We}from"./chunk-ADABTCDI.js";import{a as d,d as se}from"./chunk-5PEAXTYQ.js";var be=se(Be(),1),he=se(Pe(),1);var mt=se(Be(),1),O=se(Pe(),1);var m=se(We(),1);var Tt=He(F.runMigration),ut=d(t=>{let e=(0,mt.c)(98),{initialShardKey:r}=t,n=Ge(),a=ce(),{queryShardKey:o,setShardKey:i,shardKey:s}=it(r),[l,f]=(0,O.useState)(""),[h,g]=(0,O.useState)("up"),[p,b]=(0,O.useState)(!0),[v,x]=(0,O.useState)(!1),[y,u]=(0,O.useState)(null),[w,k]=(0,O.useState)(null),L;e[0]!==s?(L=s.trim(),e[0]=s,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=de(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ve,ye;e[5]!==o||e[6]!==$.data?(ve=d(()=>{$.data!==void 0&&rt(o)},"W"),ye=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ve,e[8]=ye):(ve=e[7],ye=e[8]),(0,O.useEffect)(ve,ye);let xe;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==s||e[14]!==$||e[15]!==a){let I=d(async()=>{let Ae=l.trim();if(Ae===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await n.query(Tt,{direction:h,dryRun:p,id:Ae},Qe(s));u(Le),$.refetch()}catch(Le){let qt=Le;u(null),k(Ve(qt))}x(!1)},"u");xe=d(()=>{Se(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=l,e[13]=s,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=d(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Ot=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=d(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=d(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let jt=Ne,_;e[20]!==i||e[21]!==s?(_=(0,m.jsx)(nt,{onChange:i,testId:"mg-shard-input",value:s}),e[20]=i,e[21]=s,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(lt,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(qe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(tt,{className:"overflow-hidden py-0",children:(0,m.jsx)(at,{className:"px-0",children:(0,m.jsxs)(ot,{"data-testid":"mg-table",children:[(0,m.jsx)(st,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(dt,{children:N.map(Ct)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(Ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Ot,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:jt,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==v||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(Xe,{"data-testid":"mg-run",disabled:v||!C,onClick:ke,type:"button",children:a(v?"Running\u2026":"Run")}):(0,m.jsx)(Ye,{confirmLabel:a(v?"Running\u2026":"Run migration?"),disabled:v||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=v,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ne;e[82]!==B||e[83]!==re?(ne=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==y||e[88]!==a?(oe=y!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[y.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:y.status}),y.processed,a(", changed"),y.changed]}),e[87]=y,e[88]=a,e[89]=oe):oe=e[89];let Oe;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ne||e[95]!==ie||e[96]!==oe?(Oe=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ne,ie,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=Oe):Oe=e[97],Oe},"yt");function Ct(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(et,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:je(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}d(Ct,"Je");var c=se(We(),1);var Ke=1;function Mt(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}d(Mt,"ue");var me=d(t=>typeof t=="object"&&t!==null,"O"),It=d(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","me"),Ft=d(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!It(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"he"),Rt=d((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"pe"),ht=d(t=>t.unique!==void 0,"Q"),ge=d(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Mt(a)),"M"),ft=d(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"U"),pt=d(t=>t.kind==="union"&&t.members?t.members.map(e=>ft(e)):[ft({...t,nullable:!1,optional:!1})],"W"),Lt=d((t,e)=>{if(e.kind!=="union")return!1;let r=pt(e);return pt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"ge"),S=d(t=>{switch(t.kind){case"array":return`array(${t.of?S(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?S(t.key):"?"}, ${t.of?S(t.of):"?"})`;case"union":return(t.members??[]).map(e=>S(e)).join(" | ");default:return t.kind}},"x"),fe=d((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),pe=d((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"F"),wt=d((t,e)=>{let r=JSON.stringify(t),n=JSON.stringify(e);return r===n?0:r<n?-1:1},"N"),ue=d(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(wt)}:{}}),"S"),gt=d(t=>t.kind==="union"?t.members??[]:[t],"B"),_t=d((t,e)=>{let r=[...t],n=[...e],a=new Set,o=new Set,i=d((s,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=n.findIndex((p,b)=>!a.has(b)&&s(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],n[g]]=Me(h,n[g])))}},"s");return i((s,l)=>JSON.stringify(s)===JSON.stringify(l),!1),i((s,l)=>ge(ue(s))===ge(ue(l)),!0),[r,n]},"ve"),Me=d((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=_t(gt(t),gt(e)),i=d((s,l)=>s.kind==="union"?{...s,members:l.toSorted(wt)}:l[0],"s");return[i(t,a),i(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},n={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],n[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],i=e.fields?.[a];o&&i&&r.fields&&n.fields&&([r.fields[a],n.fields[a]]=Me(o,i))}return[{...t,...r},{...e,...n}]},"R"),Dt=d((t,e,r,n,a)=>{let[o,i]=Me(r,n);if(o.kind===i.kind&&(!a||ge(o)===ge(i)))return;if(a&&Lt(o,i))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${S(o)} \u2192 ${S(i)} \u2014 every stored value stays valid`);if(o.kind!==i.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${i.kind} \u2014 add a data migration to convert existing values`);let s=Object.values(i.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&s.length>0&&s.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${S(o)} \u2192 ${S(i)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Kt=d((t,e,r,n,a)=>{let o=[];return r.unique!==n.unique&&o.push(n.unique===!0?{...fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`),field:e,uniqueOn:[e]}:pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&o.push(n.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),a&&r.refined!==n.refined&&o.push(n.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),o},"ye"),$t=d((t,e,r,n,a=!0)=>{let o=[],i=ht(r)&&ht(n),s=Dt(t,e,r,n,i);return s&&o.push(s),i&&o.push(...Kt(t,e,r,n,a)),r.optional&&!n.optional?o.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&o.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),o},"ee"),Et=d((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"xe"),Jt=d((t,e)=>e.refinementsRecorded!==!0||t.refinementsRecorded===!0,"ke"),At=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push({...Et(t,a,o),field:a}):n.push(...$t(t,a,i,o,Jt(e,r)).map(s=>({...s,field:a})))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.push({field:a,remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"$e"),Pt=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Rt(i,o)||n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`index ${a} on ${t} changed shape and is unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"changedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`index ${a} on ${t} changed shape \u2014 a query that relied on the old index may need updating`,table:t,type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&n.push({remediation:"none",severity:"safe",index:a,summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` no longer compiles`,table:t,scope:"table",type:"removedIndex"})},"we"),Bt=d((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`removed relation ${t}.${a} \u2014 the stored foreign-key values stay in place, but its \`onDelete\` action no longer runs and a \`with: { ${a} }\` read no longer compiles`,table:t,type:"removedRelation",warning:!0})},"Oe"),Ee="shardBy:_unknown_",Ce="global",Wt=d((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"Se"),Ut=d((t,e,r)=>{if(e===r)return r!==Ee?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${Ee}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Wt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode",...r===Ee?{}:{coverage:{shardMode:r,table:t}}}},"je"),bt=d(t=>t.memory!==void 0,"K"),vt=d(t=>t.after??0,"Y"),Je=d(t=>t.after===void 0?`{ field: "${t.field}" }`:`{ after: ${String(t.after)}, field: "${t.field}" }`,"_"),R=d(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),zt=d((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=d((s,l)=>({coverage:{table:t,ttl:{...l.after===void 0?{}:{after:l.after},field:l.field}},expiry:{...l.after===void 0?{}:{after:l.after},field:l.field,...e===void 0?{}:{previous:{...e.after===void 0?{}:{after:e.after},field:e.field}}},remediation:"backfill",scope:"table",severity:"breaking",summary:s,table:t,type:"changedTtlPolicy"}),"n"),a=d(s=>({remediation:"none",scope:"table",severity:"safe",summary:s,table:t,type:"changedTtlPolicy",warning:!0}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept, so they stay until something else deletes them`);if(e===void 0)return n(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; refresh or clear "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);if(e.field!==r.field)return n(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; populate "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);let o=vt(e),i=vt(r);return i<o?n(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; refresh "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r):i>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 every row stays, and expires later than it would have`):void 0},"Te"),Ht=d((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode",coverage:{memory:!0,table:t}}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&n.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering",identityRewrites:!0}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer .commitOrdered() \u2014 stored rows are untouched, but new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers`,table:t,type:"changedCommitOrdering",warning:!0}),n},"Fe"),Qt=d((t,e,r,n)=>{let a=Ut(t,e.shardMode,r.shardMode);if(a&&n.push(a),bt(e)&&bt(r)){n.push(...Ht(t,e,r));let o=zt(t,e.ttl,r.ttl);o&&n.push(o)}At(t,e,r,n),Pt(t,e,r,n),Bt(t,e,r,n)},"qe"),Vt=d((t,e)=>{let r=[],n=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Qt(a,i,o,r)}for(let a of Object.keys(n))e.tables[a]===void 0&&r.push({remediation:"none",scope:"table",severity:"safe",summary:`removed table ${a} \u2014 its rows are left in place in each shard's SQLite (nothing deletes them) but are unreachable through the schema; export the shard first if the data must be kept, or declare the table again to reach it`,table:a,type:"removedTable",warning:!0});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (export then import to move it). Revert the change, or declare a migration with covers: { jurisdiction: "${e.jurisdiction??"none"}" } once the data is moved.`,type:"changedJurisdiction",coverage:{jurisdiction:e.jurisdiction??"none"}})}return{changes:r}},"Me"),yt=d(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:S(r)})),"z"),xt=d((t,e,r)=>{let n={},a=e?.fields??{},o=r?.fields??{};for(let[i,s]of Object.entries(o)){let l=a[i];l===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=$t(t,i,l,s).length===0?"unchanged":"changed"}for(let i of Object.keys(a))o[i]===void 0&&(n[i]="removed");return n},"X"),Gt=d((t,e)=>{let{changes:r}=Vt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],o=d((i,s)=>i?"added":n.has(s)?"changed":"context","r");for(let[i,s]of Object.entries(e.tables)){let l=t?.tables[i],f=o(l===void 0,i);a.push({columns:yt(s),fieldStatus:xt(i,l,s),name:i,shardMode:s.shardMode,status:f})}for(let[i,s]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:yt(s),fieldStatus:xt(i,s,void 0),name:i,shardMode:s.shardMode,status:"removed"});return a.sort((i,s)=>i.name.localeCompare(s.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Ce"),kt=d(t=>{let e=Ft(t);return e.status==="ok"?e.snapshot:void 0},"Z"),Xt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Yt=d(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ie"),Zt=d(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:o,seq:i}=t,s=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==s?(l=le("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",s),e[0]=s,e[1]=l):l=e[1];let f=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=d(()=>{a(n)},"m"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==i?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=g):g=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let v;e[11]!==g||e[12]!==b?(v=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=v):v=e[13];let x;e[14]!==r?(x=je(r),e[14]=r,e[15]=x):x=e[15];let y;e[16]!==x?(y=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=y):y=e[17];let u;return e[18]!==y||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==v?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[v,y]})}),e[18]=y,e[19]=l,e[20]=f,e[21]=h,e[22]=v,e[23]=u):u=e[23],u},"Ee"),ea=d(t=>{let e=(0,be.c)(26),{breaking:r,count:n,first:a}=t,o=ce();if(a){let b;e[0]!==n?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=b):b=e[1];let v;e[2]!==o?(v=o("tables"),e[2]=o,e[3]=v):v=e[3];let x;e[4]!==v?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=x):x=e[5];let y;return e[6]!==b||e[7]!==x?(y=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=y):y=e[8],y}let i=r>0&&"text-destructive",s;e[9]!==i?(s=le("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=s):s=e[10];let l;e[11]!==n||e[12]!==s?(l=(0,c.jsx)("span",{className:s,children:n}),e[11]=n,e[12]=s,e[13]=l):l=e[13];let f;e[14]!==n||e[15]!==o?(f=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Ae"),Nt={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},ta=d((t,e)=>{let r=`${Nt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"De"),aa=d(t=>{let e=new Map;for(let n of t){let a=n.table??"",o=e.get(a);o===void 0?e.set(a,[n]):o.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Le"),ra=d(t=>{let e=(0,be.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"Je"),na=d(({pane:t,shardKey:e=""})=>{let r=ce(),n=ze(),a=Ue({strict:!1}).version,o=d(u=>{Se(n({search:{version:u},to:"/migrations"}))},"s"),i=de(F.schemaHistory,{},{shardKey:e}),s=i.data?.versions??[],l=a!==void 0&&s.some(u=>u.hash===a)?a:s[0]?.hash,f=s.findIndex(u=>u.hash===l),h=f===-1?void 0:s[f+1]?.hash,g=de(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=de(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=kt(g.data?.version?.snapshotJson);if(u!==void 0)return Gt(kt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),v=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Yt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Xt[w.status];return u},[b]);if(i.error!==null)return(0,c.jsx)(Te,{error:i.errorSource,testId:"sh-error"});if(s.length===0)return(0,c.jsx)(qe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let y=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ra,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:s.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(ea,{breaking:b?.breakingCount??0,count:h===void 0?v.length:y.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(ct,{fill:!0,nodeClasses:x,tables:v,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:aa(y).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=Nt[k.type],j=k.severity==="breaking",M=ta(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:le("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:le("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Pe"),ia=d(t=>le("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"_e"),_a=d(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,n=ce(),[a,o]=(0,he.useState)("diagram"),i;e[0]!==a?(i=d((g,p,b,v)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ia(a===g),"data-testid":b,onClick:d(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,v!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"s"),e[0]=a,e[1]=i):i=e[1];let s=i,l;e[2]!==n||e[3]!==s?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[s("diagram",n("Diagram"),"mg-pane-diagram"),s("changes",n("Changes"),"mg-pane-changes"),s("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=s,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ut,{initialShardKey:r})}):(0,c.jsx)(na,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"et");export{_a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R}from"./chunk-LYVYUTQY.js";import{c as K}from"./chunk-
|
|
1
|
+
import{a as R}from"./chunk-LYVYUTQY.js";import{c as K}from"./chunk-6C555TU5.js";import{a as N}from"./chunk-A6TVTNKO.js";import{a as C,b as F}from"./chunk-ADABTCDI.js";import{a as o,d as A}from"./chunk-5PEAXTYQ.js";var b=A(N(),1),u=A(C(),1);var S=A(F(),1);var x=(0,u.createContext)(void 0),w={},T="New chat",j=o((n,s)=>({id:n,name:s?.title??T,schema:s?.schema??[],shardKey:s?.shardKey,suggestions:s?.suggestions??[],turns:[]}),"F"),D=o((n,s)=>[...n.sessions,s].slice(-10),"T"),m=o((n,s)=>{let a=`chat-${String(n.seq+1)}`;return{activeId:a,draft:s?.draft===void 0?void 0:{id:n.seq+1,text:s.draft},hasEditor:n.hasEditor,insertRequest:void 0,open:!0,pendingAsk:s?.ask===void 0?void 0:{id:n.seq+1,sessionId:a,text:s.ask},seq:n.seq+1,sessions:D(n,j(a,s))}},"f"),v=o((n,s)=>n.find(a=>a.id===s),"l"),O=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:a}:c),"D"),U=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:[],shardKey:a}:c),"O"),$=o((n,s)=>n.filter(a=>a.id!==s),"U"),E=o((n,s,a)=>n.map(c=>c.id===s?{...c,turns:a}:c),"y"),z=o(n=>{let s=(0,b.c)(16),{children:a}=n,c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={shardKey:""},s[0]=c):c=s[0];let _=K(R.aiAvailable,w,c),l;s[1]===Symbol.for("react.memo_cache_sentinel")?(l={activeId:void 0,draft:void 0,hasEditor:!1,insertRequest:void 0,open:!1,pendingAsk:void 0,seq:0,sessions:[]},s[1]=l):l=s[1];let[d,h]=(0,u.useState)(l),p;s[2]===Symbol.for("react.memo_cache_sentinel")?(p=o(()=>({close:o(()=>{h(H)},"close"),deleteChat:o(t=>{h(e=>{let i=$(e.sessions,t);return{...e,activeId:e.activeId===t?i.at(-1)?.id:e.activeId,open:i.length===0?!1:e.open,sessions:i}})},"deleteChat"),newChat:o(t=>{h(e=>m(e,t))},"newChat"),openAssistant:o(t=>{h(e=>{let i=e.activeId===void 0?void 0:v(e.sessions,e.activeId);return t?.ask!==void 0||i===void 0||(t?.shardKey??"")!==(i.shardKey??"")?m(e,t):{...e,draft:t?.draft===void 0?e.draft:{id:e.seq+1,text:t.draft},open:!0,sessions:t?.schema===void 0?e.sessions:O(e.sessions,i.id,t.schema),seq:e.seq+1}})},"openAssistant"),rebindShard:o((t,e)=>{h(i=>{let r=i.activeId===void 0?void 0:v(i.sessions,i.activeId);return!i.open||r===void 0||(r.shardKey??"")!==t||t===e?i:r.turns.length===0?{...i,sessions:U(i.sessions,r.id,e)}:m(i,{shardKey:e,title:r.name})})},"rebindShard"),requestInsert:o(t=>{h(e=>({...e,insertRequest:{id:e.seq+1,sql:t},seq:e.seq+1}))},"requestInsert"),setHasEditor:o(t=>{h(e=>e.hasEditor===t?e:{...e,hasEditor:t})},"setHasEditor"),takeInsert:o(t=>{h(e=>e.insertRequest?.id===t?{...e,insertRequest:void 0}:e)},"takeInsert"),selectChat:o(t=>{h(e=>({...e,activeId:t,open:!0}))},"selectChat"),branchFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);if(r===void 0)return i;let y=m(i,{schema:r.schema,shardKey:r.shardKey,title:r.name});return{...y,sessions:E(y.sessions,y.activeId??"",r.turns.slice(0,e+1))}})},"branchFrom"),setTurns:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,typeof e=="function"?e(r.turns):e)}})},"setTurns"),toggle:o(()=>{h(M)},"toggle"),truncateFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,r.turns.slice(0,e))}})},"truncateFrom"),takeAsk:o(t=>{h(e=>e.pendingAsk?.id===t?{...e,pendingAsk:void 0}:e)},"takeAsk")}),"c"),s[2]=p):p=s[2];let[I]=(0,u.useState)(p),g=_.data?.available!==!0,f;s[3]!==I||s[4]!==d.activeId||s[5]!==d.draft||s[6]!==d.hasEditor||s[7]!==d.insertRequest||s[8]!==d.open||s[9]!==d.pendingAsk||s[10]!==d.sessions||s[11]!==g?(f={...I,activeId:d.activeId,draft:d.draft,hasEditor:d.hasEditor,insertRequest:d.insertRequest,open:d.open,pendingAsk:d.pendingAsk,sessions:d.sessions,unavailable:g},s[3]=I,s[4]=d.activeId,s[5]=d.draft,s[6]=d.hasEditor,s[7]=d.insertRequest,s[8]=d.open,s[9]=d.pendingAsk,s[10]=d.sessions,s[11]=g,s[12]=f):f=s[12];let k=f,q;return s[13]!==a||s[14]!==k?(q=(0,S.jsx)(x,{value:k,children:a}),s[13]=a,s[14]=k,s[15]=q):q=s[15],q},"P"),B=o(()=>(0,u.use)(x),"Q");function H(n){return{...n,open:!1}}o(H,"$");function M(n){return!n.open&&n.activeId===void 0?m(n,void 0):{...n,open:!n.open}}o(M,"j");export{z as a,B as b};
|