@lunora/studio 1.0.0-alpha.96 → 1.0.0-alpha.97
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/standalone/{chunk-ESIEIGR3.js → chunk-2KRXOCZ2.js} +1 -1
- package/dist/standalone/{chunk-2YGNOZPZ.js → chunk-3626PHEZ.js} +1 -1
- package/dist/standalone/{chunk-2FRLB5SB.js → chunk-3IF75YS7.js} +1 -1
- package/dist/standalone/{chunk-44T6NSYY.js → chunk-3SGYSFRC.js} +1 -1
- package/dist/standalone/{chunk-WPERYUTG.js → chunk-4EHNOASW.js} +1 -1
- package/dist/standalone/{chunk-ZCPQGIQW.js → chunk-5A7NIX77.js} +1 -1
- package/dist/standalone/{chunk-34WN3PEC.js → chunk-5L2VKBAJ.js} +1 -1
- package/dist/standalone/{chunk-YOKL7XDT.js → chunk-5L63KFHD.js} +1 -1
- package/dist/standalone/{chunk-LZGOETI3.js → chunk-6F7KP54M.js} +1 -1
- package/dist/standalone/{chunk-DXJWFZFI.js → chunk-73B3T2SA.js} +1 -1
- package/dist/standalone/{chunk-VWKQ6X2S.js → chunk-7CWPU3LW.js} +1 -1
- package/dist/standalone/{chunk-IGBUUFPN.js → chunk-A6NAMYVS.js} +1 -1
- package/dist/standalone/{chunk-57BUSXRD.js → chunk-ATLV7KWK.js} +1 -1
- package/dist/standalone/{chunk-NSUBZT43.js → chunk-BLHSTFG3.js} +1 -1
- package/dist/standalone/{chunk-ETU7KIO4.js → chunk-C2ZFQARQ.js} +1 -1
- package/dist/standalone/{chunk-WQJOV6L5.js → chunk-CXBXUT5A.js} +2 -2
- package/dist/standalone/{chunk-HJC67CE4.js → chunk-D264UAKY.js} +1 -1
- package/dist/standalone/{chunk-AUXEGD24.js → chunk-DDO5EGID.js} +1 -1
- package/dist/standalone/{chunk-QNQTMABQ.js → chunk-E3Z4QXAD.js} +1 -1
- package/dist/standalone/{chunk-I7FF5IIJ.js → chunk-EZKBI7SZ.js} +1 -1
- package/dist/standalone/{chunk-UZHRBXA7.js → chunk-FHZ5WDTU.js} +1 -1
- package/dist/standalone/{chunk-WOBRLIBX.js → chunk-FXBBFE7Y.js} +1 -1
- package/dist/standalone/{chunk-BAJXBWFJ.js → chunk-G2O3XP7Y.js} +1 -1
- package/dist/standalone/{chunk-BLJANR7J.js → chunk-H5ZYPSLB.js} +1 -1
- package/dist/standalone/{chunk-J4POSI6T.js → chunk-HH5CZ6KD.js} +1 -1
- package/dist/standalone/{chunk-UE6A3CRB.js → chunk-I7V54EDS.js} +1 -1
- package/dist/standalone/{chunk-EYIEO5QZ.js → chunk-II64XEZV.js} +1 -1
- package/dist/standalone/{chunk-TKFI6XYV.js → chunk-IZFPJXB3.js} +1 -1
- package/dist/standalone/{chunk-D7B2KFWM.js → chunk-J4UYSDWF.js} +1 -1
- package/dist/standalone/{chunk-TVRCPIAV.js → chunk-JNY7CFF4.js} +1 -1
- package/dist/standalone/{chunk-TAWXVVAZ.js → chunk-KP6VHTO4.js} +1 -1
- package/dist/standalone/{chunk-CFXL7MQK.js → chunk-LAEO6D34.js} +1 -1
- package/dist/standalone/{chunk-QVPKPH2T.js → chunk-LHAHIDNT.js} +1 -1
- package/dist/standalone/{chunk-LT236J7E.js → chunk-M2M3RYJU.js} +1 -1
- package/dist/standalone/{chunk-KGPNIBOV.js → chunk-M3Z2YAHD.js} +1 -1
- package/dist/standalone/{chunk-TGQH54CS.js → chunk-MW5YIENZ.js} +1 -1
- package/dist/standalone/{chunk-2IFGRS6R.js → chunk-NBANYYGB.js} +1 -1
- package/dist/standalone/{chunk-3WISGFZ7.js → chunk-NCKRVNF2.js} +1 -1
- package/dist/standalone/{chunk-JRAUQ4L2.js → chunk-NDO6YSEG.js} +1 -1
- package/dist/standalone/{chunk-DGO2XJOT.js → chunk-NJRW66LJ.js} +1 -1
- package/dist/standalone/{chunk-LV5UVTHL.js → chunk-OKZP3YY3.js} +1 -1
- package/dist/standalone/{chunk-NQ4FA65F.js → chunk-ON2FIVI2.js} +1 -1
- package/dist/standalone/{chunk-U7ILDM43.js → chunk-OQIGV6FX.js} +1 -1
- package/dist/standalone/{chunk-E2C6CK7F.js → chunk-OZA2RA45.js} +1 -1
- package/dist/standalone/{chunk-YEGFNH56.js → chunk-P33WK7YI.js} +1 -1
- package/dist/standalone/{chunk-LZ2RREQV.js → chunk-PKWJ7UOG.js} +1 -1
- package/dist/standalone/{chunk-GL7YL3VF.js → chunk-PLFTCTMX.js} +1 -1
- package/dist/standalone/{chunk-Q2QILUP4.js → chunk-PMGTIUU2.js} +1 -1
- package/dist/standalone/{chunk-SFQX7RUJ.js → chunk-QC4T2L6I.js} +1 -1
- package/dist/standalone/{chunk-U5MIBWJD.js → chunk-QEVFPILV.js} +1 -1
- package/dist/standalone/{chunk-ECF57FQF.js → chunk-QQYX5WN4.js} +1 -1
- package/dist/standalone/{chunk-7URLLMST.js → chunk-S7ZOM3NK.js} +1 -1
- package/dist/standalone/{chunk-AQZMKZMP.js → chunk-SPE3AB54.js} +1 -1
- package/dist/standalone/{chunk-7KU3LR7G.js → chunk-STESBRLN.js} +1 -1
- package/dist/standalone/{chunk-ZURV2PEP.js → chunk-SZXVX6PY.js} +1 -1
- package/dist/standalone/{chunk-OZK52CH2.js → chunk-UYPXC3OO.js} +1 -1
- package/dist/standalone/{chunk-3PXUIMP2.js → chunk-VH2IO643.js} +1 -1
- package/dist/standalone/{chunk-BMYWOK5Q.js → chunk-WLXH4ECM.js} +1 -1
- package/dist/standalone/{chunk-2NO45MRI.js → chunk-XPOUF2XH.js} +1 -1
- package/dist/standalone/{chunk-MVJMAEP4.js → chunk-YP7WZ6YM.js} +1 -1
- package/dist/standalone/{chunk-FA6AR5QU.js → chunk-YZIR7PL5.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N}from"./chunk-
|
|
1
|
+
import{a as N}from"./chunk-NCKRVNF2.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-WJQLNYGX.js";import{a as x,e as b}from"./chunk-WQH3LT2P.js";import{d as h}from"./chunk-IUYFXK4X.js";import{a as s,e as p,f as R,h as T,j as g}from"./chunk-3XIESWL4.js";var $=p(R(),1);var e=p(T(),1);var S={ERROR:"error",INFO:"info",WARN:"warning"},B=s(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:S[r.level]}},"U"),j=["error","warning","info"],A={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},O=s((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"A"),U=s((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"O"),W=s((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"S"),q=s(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"j"),G=s(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:f})=>{let a=h(),[m,k]=(0,$.useState)("error"),I=q(o),u=(o??[]).filter(t=>t.level===m),E=s(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:j.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:E,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",A[t])}),O(a,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:U(a,t,I[t])})]},t))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:a("Issue type")}),(0,e.jsx)(c,{children:a("Entity/item")}),(0,e.jsx)(c,{children:a("Description")})]})}),(0,e.jsx)(y,{children:u.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:W(a,m)}),(0,e.jsx)("span",{className:"block text-sm",children:a("Nothing to report for this deployment.")})]})}):u.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"q");export{B as a,G as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ge,b as fe,c as xe,d as Ne,e as we}from"./chunk-MKYEFQCA.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ce}from"./chunk-V53KNYRN.js";import{a as ue}from"./chunk-JN2Y24PY.js";import{a as q}from"./chunk-5Y3QLNWX.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-FA6AR5QU.js";import"./chunk-WQJOV6L5.js";import"./chunk-3C3CG7ZK.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-HPFLBYRI.js";import"./chunk-CZZWYUTR.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import{R as ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as B}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as he}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import"./chunk-VDW32UET.js";import"./chunk-LZGOETI3.js";import{f as G}from"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as ke}from"./chunk-XQCVZAGU.js";import{a as se,b as ie,c as oe,d as Q,e as X,f as Y}from"./chunk-WJQLNYGX.js";import{a as re,e as ne}from"./chunk-WQH3LT2P.js";import{d as R,h as Z,l as be,o as A,q as de}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as i,e as le,f as Oe,g as _e,h as De}from"./chunk-3XIESWL4.js";var $=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Je=i(r=>{let e=r.trim();if(e==="")return;let d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},"_e"),Le=i(r=>r===void 0?"\u2014":new Date(r*1e3).toISOString(),"Je"),Pe=i(r=>new TextEncoder().encode(r).length,"De"),Fe=i(r=>{if(r.trim()!=="")try{return JSON.stringify(JSON.parse(r),void 0,2)}catch{return}},"ge"),Ke=i(r=>{if(r.trim()==="")return!0;try{return JSON.parse(r),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Ce=i((r,e)=>{let d=r.trim();if(d==="")return"";let u=Number(d),s=Ee.find(v=>v.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*s)):d},"ue"),Ve=i(r=>{let e=r.trim();if(e==="")return!0;let d=Number(e);return Number.isInteger(d)&&d>=60},"Ce"),Te=i((r,e,d,u)=>{let s=Je(r.ttl);return{expiration:s===void 0?u:void 0,expirationTtl:s,key:e,metadata:r.metadata.trim()===""?void 0:JSON.parse(r.metadata),namespace:d,value:r.value}},"we"),Me=i(r=>{let e=(0,ee.c)(60),{helper:d,id:u,invalid:s,onChange:v,testId:o}=r,t=R(),[l,p]=(0,$.useState)(""),[c,x]=(0,$.useState)("seconds"),g;e[0]!==v||e[1]!==c?(g=i(f=>{p(f.target.value),v(Ce(f.target.value,c))},"f"),e[0]=v,e[1]=c,e[2]=g):g=e[2];let O=g,V;e[3]!==l||e[4]!==v?(V=i(f=>{f!==null&&(x(f),v(Ce(l,f)))},"K"),e[3]=l,e[4]=v,e[5]=V):V=e[5];let _=V,y;e[6]!==t?(y=t("days"),e[6]=t,e[7]=y):y=e[7];let m;e[8]!==t?(m=t("hours"),e[8]=t,e[9]=m):m=e[9];let h;e[10]!==t?(h=t("minutes"),e[10]=t,e[11]=h):h=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let w;e[14]!==y||e[15]!==m||e[16]!==h||e[17]!==N?(w={days:y,hours:m,minutes:h,seconds:N},e[14]=y,e[15]=m,e[16]=h,e[17]=N,e[18]=w):w=e[18];let C=w,b;e[19]!==t?(b=t("Expires after"),e[19]=t,e[20]=b):b=e[20];let S;e[21]!==u||e[22]!==b?(S=(0,a.jsx)(q,{className:"text-xs",htmlFor:u,children:b}),e[21]=u,e[22]=b,e[23]=S):S=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let J;e[26]!==l||e[27]!==u||e[28]!==s||e[29]!==O||e[30]!==E||e[31]!==o?(J=(0,a.jsx)(ae,{"aria-invalid":s,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:O,placeholder:E,value:l}),e[26]=l,e[27]=u,e[28]=s,e[29]=O,e[30]=E,e[31]=o,e[32]=J):J=e[32];let T;e[33]!==t?(T=t("TTL unit"),e[33]=t,e[34]=T):T=e[34];let P=`${o}-unit`,L;e[35]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(fe,{}),e[35]=L):L=e[35];let M;e[36]!==T||e[37]!==P?(M=(0,a.jsx)(xe,{"aria-label":T,className:"w-[7.5rem]","data-testid":P,children:L}),e[36]=T,e[37]=P,e[38]=M):M=e[38];let n;e[39]!==C?(n=Ee.map(f=>(0,a.jsx)(we,{value:f.key,children:C[f.key]},f.key)),e[39]=C,e[40]=n):n=e[40];let k;e[41]!==n?(k=(0,a.jsx)(Ne,{children:n}),e[41]=n,e[42]=k):k=e[42];let F;e[43]!==_||e[44]!==M||e[45]!==k||e[46]!==c?(F=(0,a.jsxs)(ge,{onValueChange:_,value:c,children:[M,k]}),e[43]=_,e[44]=M,e[45]=k,e[46]=c,e[47]=F):F=e[47];let I;e[48]!==J||e[49]!==F?(I=(0,a.jsxs)("div",{className:"flex gap-2",children:[J,F]}),e[48]=J,e[49]=F,e[50]=I):I=e[50];let K;e[51]!==d||e[52]!==s||e[53]!==t||e[54]!==o?(K=s?(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")}):d!==void 0&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:d}),e[51]=d,e[52]=s,e[53]=t,e[54]=o,e[55]=K):K=e[55];let D;return e[56]!==I||e[57]!==K||e[58]!==S?(D=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,I,K]}),e[56]=I,e[57]=K,e[58]=S,e[59]=D):D=e[59],D},"Se"),Ie=i(r=>{let e=(0,ee.c)(36),{id:d,invalidTestId:u,onChange:s,testId:v,valid:o,value:t}=r,l=R(),p;e[0]!==t?(p=Fe(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==l?(x=l("Metadata (JSON)"),e[2]=l,e[3]=x):x=e[3];let g;e[4]!==d||e[5]!==x?(g=(0,a.jsx)(q,{className:"text-xs",htmlFor:d,children:x}),e[4]=d,e[5]=x,e[6]=g):g=e[6];let O=`${v}-format`,V=c===void 0,_;e[7]!==c||e[8]!==s?(_=i(()=>{c!==void 0&&s(c)},"O"),e[7]=c,e[8]=s,e[9]=_):_=e[9];let y;e[10]!==l?(y=l("Format JSON"),e[10]=l,e[11]=y):y=e[11];let m;e[12]!==O||e[13]!==V||e[14]!==_||e[15]!==y?(m=(0,a.jsx)(B,{"data-testid":O,disabled:V,onClick:_,size:"sm",variant:"outline",children:y}),e[12]=O,e[13]=V,e[14]=_,e[15]=y,e[16]=m):m=e[16];let h;e[17]!==g||e[18]!==m?(h=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[g,m]}),e[17]=g,e[18]=m,e[19]=h):h=e[19];let N=!o,w;e[20]!==s?(w=i(E=>{s(E.target.value)},"N"),e[20]=s,e[21]=w):w=e[21];let C;e[22]!==d||e[23]!==N||e[24]!==w||e[25]!==v||e[26]!==t?(C=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":v,id:d,onChange:w,value:t}),e[22]=d,e[23]=N,e[24]=w,e[25]=v,e[26]=t,e[27]=C):C=e[27];let b;e[28]!==u||e[29]!==l||e[30]!==o?(b=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:l("Metadata must be valid JSON.")}),e[28]=u,e[29]=l,e[30]=o,e[31]=b):b=e[31];let S;return e[32]!==C||e[33]!==b||e[34]!==h?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[h,C,b]}),e[32]=C,e[33]=b,e[34]=h,e[35]=S):S=e[35],S},"$e"),$e={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Be=i((r,e)=>{switch(e.type){case"setField":return{...r,[e.field]:e.value};case"submitFailed":return{...r,busy:!1,error:e.error};case"submitStart":return{...r,busy:!0,error:null};default:return r}},"Be"),je=i(r=>{let e=(0,ee.c)(73),{namespace:d,onCancel:u,onCreated:s}=r,v=G(),o=R(),[t,l]=(0,$.useReducer)(Be,$e),p;e[0]!==t.metadata?(p=Ke(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ve(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let g=x,O;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==g?(O=t.name.trim()!==""&&c&&g&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=g,e[8]=O):O=e[8];let V=O,_;e[9]!==V||e[10]!==v||e[11]!==d||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(_=i(()=>{V&&(l({type:"submitStart"}),A((async()=>{try{await v.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),s()}catch(z){l({error:Z(z),type:"submitFailed"})}})()))},"O"),e[9]=V,e[10]=v,e[11]=d,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=_):_=e[17];let y=_,m;e[18]!==o?(m=o("Key name"),e[18]=o,e[19]=m):m=e[19];let h;e[20]!==m?(h=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-name",children:m}),e[20]=m,e[21]=h):h=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=i(z=>{l({field:"name",type:"setField",value:z.target.value})},"x"),e[22]=N):N=e[22];let w;e[23]!==o?(w=o("Key name"),e[23]=o,e[24]=w):w=e[24];let C;e[25]!==t.name||e[26]!==w?(C=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:w,value:t.name}),e[25]=t.name,e[26]=w,e[27]=C):C=e[27];let b;e[28]!==h||e[29]!==C?(b=(0,a.jsxs)("div",{className:"grid gap-1",children:[h,C]}),e[28]=h,e[29]=C,e[30]=b):b=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let E;e[33]!==S?(E=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=E):E=e[34];let J;e[35]===Symbol.for("react.memo_cache_sentinel")?(J=i(z=>{l({field:"value",type:"setField",value:z.target.value})},"J"),e[35]=J):J=e[35];let T;e[36]!==t.value?(T=(0,a.jsx)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:J,value:t.value}),e[36]=t.value,e[37]=T):T=e[37];let P;e[38]!==E||e[39]!==T?(P=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,T]}),e[38]=E,e[39]=T,e[40]=P):P=e[40];let L=!g,M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=i(z=>{l({field:"ttl",type:"setField",value:z})},"M"),e[41]=M):M=e[41];let n;e[42]!==L?(n=(0,a.jsx)(Me,{id:"kv-create-ttl",invalid:L,onChange:M,testId:"kv-create-ttl"}),e[42]=L,e[43]=n):n=e[43];let k;e[44]===Symbol.for("react.memo_cache_sentinel")?(k=i(z=>{l({field:"metadata",type:"setField",value:z})},"h"),e[44]=k):k=e[44];let F;e[45]!==c||e[46]!==t.metadata?(F=(0,a.jsx)(Ie,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:k,testId:"kv-create-metadata",valid:c,value:t.metadata}),e[45]=c,e[46]=t.metadata,e[47]=F):F=e[47];let I=!V,K;e[48]!==t.busy||e[49]!==o?(K=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=K):K=e[50];let D;e[51]!==y||e[52]!==I||e[53]!==K?(D=(0,a.jsx)(B,{"data-testid":"kv-create-submit",disabled:I,onClick:y,children:K}),e[51]=y,e[52]=I,e[53]=K,e[54]=D):D=e[54];let f=t.busy,j;e[55]!==o?(j=o("Cancel"),e[55]=o,e[56]=j):j=e[56];let H;e[57]!==u||e[58]!==t.busy||e[59]!==j?(H=(0,a.jsx)(B,{"data-testid":"kv-create-cancel",disabled:f,onClick:u,variant:"outline",children:j}),e[57]=u,e[58]=t.busy,e[59]=j,e[60]=H):H=e[60];let U;e[61]!==D||e[62]!==H?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,H]}),e[61]=D,e[62]=H,e[63]=U):U=e[63];let W;e[64]!==t.error?(W=t.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=W):W=e[65];let te;return e[66]!==b||e[67]!==P||e[68]!==n||e[69]!==F||e[70]!==U||e[71]!==W?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[b,P,n,F,U,W]}),e[66]=b,e[67]=P,e[68]=n,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),ze={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Ae=i((r,e)=>{switch(e.type){case"deleteStart":return{...r,busy:"deleting",writeError:null};case"editMetadata":return{...r,editedMetadata:e.value};case"editTtl":return{...r,editedTtl:e.value};case"editValue":return{...r,editedValue:e.value};case"loaded":return{...r,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"saveOk":return{...r,busy:"",value:r.editedValue};case"saveStart":return{...r,busy:"saving",writeError:null};case"writeFailed":return{...r,busy:"",writeError:e.error};default:return r}},"Ae"),He=i(r=>{let e=(0,ee.c)(67),{expiration:d,keyName:u,namespace:s,onDeleted:v}=r,o=G(),t=R(),[l,p]=(0,$.useReducer)(Ae,ze),c,x;e[0]!==o||e[1]!==u||e[2]!==s?(c=i(()=>{let f={cancelled:!1};return A((async()=>{try{let j=await o.getKvValue({key:u,namespace:s});f.cancelled||p({metadata:j.metadata,type:"loaded",value:j.value})}catch(j){let H=j;f.cancelled||p({error:Z(H),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},"o"),x=[o,s,u],e[0]=o,e[1]=u,e[2]=s,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,$.useEffect)(c,x);let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=i(f=>{p({type:"editValue",value:f.target.value})},"f"),e[5]=g):g=e[5];let O=g,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=i(f=>{p({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let _=V,y;e[7]!==l.editedValue?(y=Fe(l.editedValue),e[7]=l.editedValue,e[8]=y):y=e[8];let m=y,h;e[9]!==l.editedMetadata?(h=Ke(l.editedMetadata),e[9]=l.editedMetadata,e[10]=h):h=e[10];let N=h,w;e[11]!==l.editedTtl?(w=Ve(l.editedTtl),e[11]=l.editedTtl,e[12]=w):w=e[12];let C=w,b;e[13]!==m?(b=i(()=>{m!==void 0&&p({type:"editValue",value:m})},"k"),e[13]=m,e[14]=b):b=e[14];let S=b,E;e[15]!==o||e[16]!==d||e[17]!==u||e[18]!==N||e[19]!==s||e[20]!==l.editedMetadata||e[21]!==l.editedTtl||e[22]!==l.editedValue||e[23]!==t?(E=i(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),A((async()=>{try{await o.putKvValue(Te({metadata:l.editedMetadata,ttl:l.editedTtl,value:l.editedValue},u,s,d)),p({type:"saveOk"})}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"E"),e[15]=o,e[16]=d,e[17]=u,e[18]=N,e[19]=s,e[20]=l.editedMetadata,e[21]=l.editedTtl,e[22]=l.editedValue,e[23]=t,e[24]=E):E=e[24];let J=E,T;e[25]!==o||e[26]!==u||e[27]!==s||e[28]!==v?(T=i(()=>{p({type:"deleteStart"}),A((async()=>{try{await o.deleteKvKey({key:u,namespace:s}),v(u)}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"V"),e[25]=o,e[26]=u,e[27]=s,e[28]=v,e[29]=T):T=e[29];let P=T,L;e[30]!==u?(L=i(()=>{de(u)},"D"),e[30]=u,e[31]=L):L=e[31];let M;e[32]!==t?(M=t("Copy key"),e[32]=t,e[33]=M):M=e[33];let n;e[34]!==L||e[35]!==M?(n=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)(B,{"data-testid":"kv-copy-key-btn",onClick:L,size:"sm",variant:"outline",children:M})}),e[34]=L,e[35]=M,e[36]=n):n=e[36];let k;e[37]!==l.loadError?(k=l.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:l.loadError}),e[37]=l.loadError,e[38]=k):k=e[38];let F;e[39]!==l.loading||e[40]!==t?(F=l.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=l.loading,e[40]=t,e[41]=F):F=e[41];let I;e[42]!==m||e[43]!==N||e[44]!==P||e[45]!==S||e[46]!==J||e[47]!==l.busy||e[48]!==l.editedMetadata||e[49]!==l.editedValue||e[50]!==l.loading||e[51]!==l.value||e[52]!==l.writeError||e[53]!==t||e[54]!==C?(I=!l.loading&&l.value!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),m!==void 0&&(0,a.jsx)(he,{variant:"secondary",children:t("JSON")}),(0,a.jsx)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:be(Pe(l.editedValue))})]}),(0,a.jsx)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:O,value:l.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)(B,{"data-testid":"kv-format-btn",disabled:m===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)(B,{"data-testid":"kv-copy-value-btn",onClick:i(()=>{de(l.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(Me,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!C,onChange:i(f=>{p({type:"editTtl",value:f})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(Ie,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:_,testId:"kv-metadata-editor",valid:N,value:l.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(B,{"data-testid":"kv-save-btn",disabled:l.busy!==""||!N||!C,onClick:J,children:l.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)(B,{"data-testid":"kv-delete-btn",disabled:l.busy!=="",onClick:P,variant:"destructive",children:l.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),l.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:l.writeError})]}),e[42]=m,e[43]=N,e[44]=P,e[45]=S,e[46]=J,e[47]=l.busy,e[48]=l.editedMetadata,e[49]=l.editedValue,e[50]=l.loading,e[51]=l.value,e[52]=l.writeError,e[53]=t,e[54]=C,e[55]=I):I=e[55];let K;e[56]!==l.loadError||e[57]!==l.loading||e[58]!==l.value||e[59]!==t?(K=!l.loading&&l.value===null&&l.loadError===null&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=l.loadError,e[57]=l.loading,e[58]=l.value,e[59]=t,e[60]=K):K=e[60];let D;return e[61]!==n||e[62]!==k||e[63]!==F||e[64]!==I||e[65]!==K?(D=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[n,k,F,I,K]}),e[61]=n,e[62]=k,e[63]=F,e[64]=I,e[65]=K,e[66]=D):D=e[66],D},"ze"),Se=100,Ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=i((r,e)=>{switch(e.type){case"appendPage":return{...r,cursor:e.cursor,keys:[...r.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...r,appliedPrefix:r.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{let d=new Set(e.deleted);return{...r,bulk:r.bulk.filter(u=>!d.has(u)),bulkBusy:!1,bulkError:e.error,keys:r.keys===null?null:r.keys.filter(u=>!d.has(u.name)),selectedKey:r.selectedKey!==null&&d.has(r.selectedKey)?null:r.selectedKey}}case"bulkDeleteStart":return{...r,bulkBusy:!0,bulkError:null};case"firstPage":return{...r,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...r,bulk:r.bulk.filter(d=>d!==e.name),keys:r.keys===null?null:r.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"loadStart":return{...r,loadError:null,loading:!0};case"prefixInput":return{...r,prefixInput:e.value};case"reload":return{...r,bulk:[],bulkError:null,reloadNonce:r.reloadNonce+1,selectedKey:null};case"selectKey":return{...r,selectedKey:e.name};case"toggleAllBulk":return{...r,bulk:e.names};case"toggleBulk":return{...r,bulk:r.bulk.includes(e.name)?r.bulk.filter(d=>d!==e.name):[...r.bulk,e.name]};default:return r}},"Re"),Ue=i(({namespace:r})=>{let e=G(),d=R(),[u,s]=(0,$.useReducer)(Re,Ze),{appliedPrefix:v,bulk:o,bulkBusy:t,bulkError:l,cursor:p,keys:c,listComplete:x,loadError:g,loading:O,prefixInput:V,reloadNonce:_,selectedKey:y}=u,[m,h]=(0,$.useState)(!1);(0,$.useEffect)(()=>{let n={cancelled:!1};return A((async()=>{s({type:"loadStart"});try{let k=await e.listKvKeys({limit:Se,namespace:r,prefix:v===""?void 0:v});n.cancelled||s({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){n.cancelled||s({error:Z(k),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,r,v,_]);let N=i(n=>{s({type:"prefixInput",value:n.target.value})},"x"),w=i(()=>{s({type:"applyFilter"})},"N"),C=i(n=>{s({name:n.currentTarget.dataset.key??null,type:"selectKey"})},"C"),b=i(()=>{p!==null&&(s({type:"loadStart"}),A((async()=>{try{let n=await e.listKvKeys({cursor:p,limit:Se,namespace:r,prefix:v===""?void 0:v});s({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){s({error:Z(n),type:"loadFailed"})}})()))},"k"),S=i(n=>{s({name:n,type:"keyDeleted"})},"w"),E=i(n=>{s({name:n,type:"toggleBulk"})},"E"),J=i(n=>{s({names:n&&c!==null?c.map(k=>k.name):[],type:"toggleAllBulk"})},"J"),T=i(()=>{if(o.length===0)return;let n=[...o];s({type:"bulkDeleteStart"}),A((async()=>{let k=await Promise.allSettled(n.map(K=>e.deleteKvKey({key:K,namespace:r}))),F=n.filter((K,D)=>k[D]?.status==="fulfilled"),I=n.length-F.length;s({deleted:F,error:I>0?d("Failed to delete {count} keys.",{count:I}):null,type:"bulkDeleted"})})())},"V"),P=i(()=>{h(!1),s({type:"reload"})},"L"),L=c!==null&&c.length>0&&o.length===c.length,M=new Set(o);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ae,{"aria-label":d("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:d("Filter by prefix\u2026"),value:V}),(0,a.jsx)(B,{"data-testid":"kv-filter-btn",disabled:O,onClick:w,children:d("Filter")}),(0,a.jsx)(B,{"data-testid":"kv-new-key-btn",onClick:i(()=>{h(n=>!n)},"onClick"),variant:"outline",children:d("New key")}),o.length>0&&(0,a.jsx)(B,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:T,variant:"destructive",children:t?d("Deleting\u2026"):d("Delete {count}",{count:o.length})})]}),l!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:l}),g!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:g}),c!==null&&c.length===0&&!O&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:d("No keys.")}),c!==null&&c.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-key-table",children:[(0,a.jsx)(ie,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(X,{className:"w-10",children:(0,a.jsx)(ue,{"aria-label":d("Select all"),checked:L,"data-testid":"kv-select-all",onCheckedChange:J})}),(0,a.jsx)(X,{children:d("Key")}),(0,a.jsx)(X,{children:d("Expiration")})]})}),(0,a.jsx)(oe,{children:c.map(n=>(0,a.jsxs)(Q,{className:n.name===y?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":n.name,"data-testid":`kv-key-row-${n.name}`,onClick:C,children:[(0,a.jsx)(Y,{onClick:i(k=>{k.stopPropagation()},"onClick"),children:(0,a.jsx)(ue,{"aria-label":d("Select {name}",{name:n.name}),checked:M.has(n.name),"data-testid":`kv-select-${n.name}`,onCheckedChange:i(()=>{E(n.name)},"onCheckedChange")})}),(0,a.jsx)(Y,{className:"font-mono text-xs",children:n.name}),(0,a.jsx)(Y,{className:"tabular-nums text-xs",children:Le(n.expiration)})]},n.name))})]})})}),!x&&p!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(B,{"data-testid":"kv-load-more",disabled:O,onClick:b,variant:"outline",children:d(O?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:i(n=>{n||h(!1)},"onOpenChange"),open:m,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{children:d("New key")})}),(0,a.jsx)(je,{namespace:r,onCancel:i(()=>{h(!1)},"onCancel"),onCreated:P})]})}),(0,a.jsx)(me,{onOpenChange:i(n=>{n||s({name:null,type:"selectKey"})},"onOpenChange"),open:y!==null,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{className:"truncate font-mono text-xs",children:y})}),y!==null&&(0,a.jsx)(He,{expiration:c?.find(n=>n.name===y)?.expiration,keyName:y,namespace:r,onDeleted:S},`${r}:${y}`)]})})]})},"Ue"),it=i(({loadNamespaces:r}={})=>{let e=G(),d=R(),[u,s]=(0,$.useState)(null),[v,o]=(0,$.useState)(null),[t,l]=(0,$.useState)(null);(0,$.useEffect)(()=>{let c={cancelled:!1};return A((async()=>{try{let x=await(r??(()=>e.listKvNamespaces()))();c.cancelled||(s(x),o(null),l(g=>g??x[0]?.binding??null))}catch(x){c.cancelled||(s(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,r]);let p=i(c=>{l(c.currentTarget.dataset.ns??null)},"v");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[v!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:v}),u!==null&&u.length===0&&(0,a.jsx)(ke,{description:d("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:d("No KV namespaces.")}),u!==null&&u.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(ie,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(X,{children:d("Namespace")})})}),(0,a.jsx)(oe,{children:u.map(c=>(0,a.jsx)(Q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,a.jsx)(Y,{className:"font-mono text-xs",children:c.binding})},c.binding))})]})})}),t!==null&&(0,a.jsx)(Ue,{namespace:t},t)]})},"ct");export{it as KvBrowser};
|
|
1
|
+
import{a as ge,b as fe,c as xe,d as Ne,e as we}from"./chunk-MKYEFQCA.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ce}from"./chunk-V53KNYRN.js";import{a as ue}from"./chunk-JN2Y24PY.js";import{a as q}from"./chunk-5Y3QLNWX.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-YZIR7PL5.js";import"./chunk-CXBXUT5A.js";import"./chunk-3C3CG7ZK.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-HPFLBYRI.js";import"./chunk-CZZWYUTR.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import{R as ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as B}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as he}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import"./chunk-VDW32UET.js";import"./chunk-6F7KP54M.js";import{f as G}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as ke}from"./chunk-XQCVZAGU.js";import{a as se,b as ie,c as oe,d as Q,e as X,f as Y}from"./chunk-WJQLNYGX.js";import{a as re,e as ne}from"./chunk-WQH3LT2P.js";import{d as R,h as Z,l as be,o as A,q as de}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as le,f as Oe,g as _e,h as De}from"./chunk-3XIESWL4.js";var $=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Je=i(r=>{let e=r.trim();if(e==="")return;let d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},"_e"),Le=i(r=>r===void 0?"\u2014":new Date(r*1e3).toISOString(),"Je"),Pe=i(r=>new TextEncoder().encode(r).length,"De"),Fe=i(r=>{if(r.trim()!=="")try{return JSON.stringify(JSON.parse(r),void 0,2)}catch{return}},"ge"),Ke=i(r=>{if(r.trim()==="")return!0;try{return JSON.parse(r),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Ce=i((r,e)=>{let d=r.trim();if(d==="")return"";let u=Number(d),s=Ee.find(v=>v.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*s)):d},"ue"),Ve=i(r=>{let e=r.trim();if(e==="")return!0;let d=Number(e);return Number.isInteger(d)&&d>=60},"Ce"),Te=i((r,e,d,u)=>{let s=Je(r.ttl);return{expiration:s===void 0?u:void 0,expirationTtl:s,key:e,metadata:r.metadata.trim()===""?void 0:JSON.parse(r.metadata),namespace:d,value:r.value}},"we"),Me=i(r=>{let e=(0,ee.c)(60),{helper:d,id:u,invalid:s,onChange:v,testId:o}=r,t=R(),[l,p]=(0,$.useState)(""),[c,x]=(0,$.useState)("seconds"),g;e[0]!==v||e[1]!==c?(g=i(f=>{p(f.target.value),v(Ce(f.target.value,c))},"f"),e[0]=v,e[1]=c,e[2]=g):g=e[2];let O=g,V;e[3]!==l||e[4]!==v?(V=i(f=>{f!==null&&(x(f),v(Ce(l,f)))},"K"),e[3]=l,e[4]=v,e[5]=V):V=e[5];let _=V,y;e[6]!==t?(y=t("days"),e[6]=t,e[7]=y):y=e[7];let m;e[8]!==t?(m=t("hours"),e[8]=t,e[9]=m):m=e[9];let h;e[10]!==t?(h=t("minutes"),e[10]=t,e[11]=h):h=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let w;e[14]!==y||e[15]!==m||e[16]!==h||e[17]!==N?(w={days:y,hours:m,minutes:h,seconds:N},e[14]=y,e[15]=m,e[16]=h,e[17]=N,e[18]=w):w=e[18];let C=w,b;e[19]!==t?(b=t("Expires after"),e[19]=t,e[20]=b):b=e[20];let S;e[21]!==u||e[22]!==b?(S=(0,a.jsx)(q,{className:"text-xs",htmlFor:u,children:b}),e[21]=u,e[22]=b,e[23]=S):S=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let J;e[26]!==l||e[27]!==u||e[28]!==s||e[29]!==O||e[30]!==E||e[31]!==o?(J=(0,a.jsx)(ae,{"aria-invalid":s,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:O,placeholder:E,value:l}),e[26]=l,e[27]=u,e[28]=s,e[29]=O,e[30]=E,e[31]=o,e[32]=J):J=e[32];let T;e[33]!==t?(T=t("TTL unit"),e[33]=t,e[34]=T):T=e[34];let P=`${o}-unit`,L;e[35]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.jsx)(fe,{}),e[35]=L):L=e[35];let M;e[36]!==T||e[37]!==P?(M=(0,a.jsx)(xe,{"aria-label":T,className:"w-[7.5rem]","data-testid":P,children:L}),e[36]=T,e[37]=P,e[38]=M):M=e[38];let n;e[39]!==C?(n=Ee.map(f=>(0,a.jsx)(we,{value:f.key,children:C[f.key]},f.key)),e[39]=C,e[40]=n):n=e[40];let k;e[41]!==n?(k=(0,a.jsx)(Ne,{children:n}),e[41]=n,e[42]=k):k=e[42];let F;e[43]!==_||e[44]!==M||e[45]!==k||e[46]!==c?(F=(0,a.jsxs)(ge,{onValueChange:_,value:c,children:[M,k]}),e[43]=_,e[44]=M,e[45]=k,e[46]=c,e[47]=F):F=e[47];let I;e[48]!==J||e[49]!==F?(I=(0,a.jsxs)("div",{className:"flex gap-2",children:[J,F]}),e[48]=J,e[49]=F,e[50]=I):I=e[50];let K;e[51]!==d||e[52]!==s||e[53]!==t||e[54]!==o?(K=s?(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")}):d!==void 0&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:d}),e[51]=d,e[52]=s,e[53]=t,e[54]=o,e[55]=K):K=e[55];let D;return e[56]!==I||e[57]!==K||e[58]!==S?(D=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,I,K]}),e[56]=I,e[57]=K,e[58]=S,e[59]=D):D=e[59],D},"Se"),Ie=i(r=>{let e=(0,ee.c)(36),{id:d,invalidTestId:u,onChange:s,testId:v,valid:o,value:t}=r,l=R(),p;e[0]!==t?(p=Fe(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==l?(x=l("Metadata (JSON)"),e[2]=l,e[3]=x):x=e[3];let g;e[4]!==d||e[5]!==x?(g=(0,a.jsx)(q,{className:"text-xs",htmlFor:d,children:x}),e[4]=d,e[5]=x,e[6]=g):g=e[6];let O=`${v}-format`,V=c===void 0,_;e[7]!==c||e[8]!==s?(_=i(()=>{c!==void 0&&s(c)},"O"),e[7]=c,e[8]=s,e[9]=_):_=e[9];let y;e[10]!==l?(y=l("Format JSON"),e[10]=l,e[11]=y):y=e[11];let m;e[12]!==O||e[13]!==V||e[14]!==_||e[15]!==y?(m=(0,a.jsx)(B,{"data-testid":O,disabled:V,onClick:_,size:"sm",variant:"outline",children:y}),e[12]=O,e[13]=V,e[14]=_,e[15]=y,e[16]=m):m=e[16];let h;e[17]!==g||e[18]!==m?(h=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[g,m]}),e[17]=g,e[18]=m,e[19]=h):h=e[19];let N=!o,w;e[20]!==s?(w=i(E=>{s(E.target.value)},"N"),e[20]=s,e[21]=w):w=e[21];let C;e[22]!==d||e[23]!==N||e[24]!==w||e[25]!==v||e[26]!==t?(C=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":v,id:d,onChange:w,value:t}),e[22]=d,e[23]=N,e[24]=w,e[25]=v,e[26]=t,e[27]=C):C=e[27];let b;e[28]!==u||e[29]!==l||e[30]!==o?(b=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:l("Metadata must be valid JSON.")}),e[28]=u,e[29]=l,e[30]=o,e[31]=b):b=e[31];let S;return e[32]!==C||e[33]!==b||e[34]!==h?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[h,C,b]}),e[32]=C,e[33]=b,e[34]=h,e[35]=S):S=e[35],S},"$e"),$e={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Be=i((r,e)=>{switch(e.type){case"setField":return{...r,[e.field]:e.value};case"submitFailed":return{...r,busy:!1,error:e.error};case"submitStart":return{...r,busy:!0,error:null};default:return r}},"Be"),je=i(r=>{let e=(0,ee.c)(73),{namespace:d,onCancel:u,onCreated:s}=r,v=G(),o=R(),[t,l]=(0,$.useReducer)(Be,$e),p;e[0]!==t.metadata?(p=Ke(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ve(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let g=x,O;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==g?(O=t.name.trim()!==""&&c&&g&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=g,e[8]=O):O=e[8];let V=O,_;e[9]!==V||e[10]!==v||e[11]!==d||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(_=i(()=>{V&&(l({type:"submitStart"}),A((async()=>{try{await v.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),s()}catch(z){l({error:Z(z),type:"submitFailed"})}})()))},"O"),e[9]=V,e[10]=v,e[11]=d,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=_):_=e[17];let y=_,m;e[18]!==o?(m=o("Key name"),e[18]=o,e[19]=m):m=e[19];let h;e[20]!==m?(h=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-name",children:m}),e[20]=m,e[21]=h):h=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=i(z=>{l({field:"name",type:"setField",value:z.target.value})},"x"),e[22]=N):N=e[22];let w;e[23]!==o?(w=o("Key name"),e[23]=o,e[24]=w):w=e[24];let C;e[25]!==t.name||e[26]!==w?(C=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:w,value:t.name}),e[25]=t.name,e[26]=w,e[27]=C):C=e[27];let b;e[28]!==h||e[29]!==C?(b=(0,a.jsxs)("div",{className:"grid gap-1",children:[h,C]}),e[28]=h,e[29]=C,e[30]=b):b=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let E;e[33]!==S?(E=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=E):E=e[34];let J;e[35]===Symbol.for("react.memo_cache_sentinel")?(J=i(z=>{l({field:"value",type:"setField",value:z.target.value})},"J"),e[35]=J):J=e[35];let T;e[36]!==t.value?(T=(0,a.jsx)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:J,value:t.value}),e[36]=t.value,e[37]=T):T=e[37];let P;e[38]!==E||e[39]!==T?(P=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,T]}),e[38]=E,e[39]=T,e[40]=P):P=e[40];let L=!g,M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=i(z=>{l({field:"ttl",type:"setField",value:z})},"M"),e[41]=M):M=e[41];let n;e[42]!==L?(n=(0,a.jsx)(Me,{id:"kv-create-ttl",invalid:L,onChange:M,testId:"kv-create-ttl"}),e[42]=L,e[43]=n):n=e[43];let k;e[44]===Symbol.for("react.memo_cache_sentinel")?(k=i(z=>{l({field:"metadata",type:"setField",value:z})},"h"),e[44]=k):k=e[44];let F;e[45]!==c||e[46]!==t.metadata?(F=(0,a.jsx)(Ie,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:k,testId:"kv-create-metadata",valid:c,value:t.metadata}),e[45]=c,e[46]=t.metadata,e[47]=F):F=e[47];let I=!V,K;e[48]!==t.busy||e[49]!==o?(K=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=K):K=e[50];let D;e[51]!==y||e[52]!==I||e[53]!==K?(D=(0,a.jsx)(B,{"data-testid":"kv-create-submit",disabled:I,onClick:y,children:K}),e[51]=y,e[52]=I,e[53]=K,e[54]=D):D=e[54];let f=t.busy,j;e[55]!==o?(j=o("Cancel"),e[55]=o,e[56]=j):j=e[56];let H;e[57]!==u||e[58]!==t.busy||e[59]!==j?(H=(0,a.jsx)(B,{"data-testid":"kv-create-cancel",disabled:f,onClick:u,variant:"outline",children:j}),e[57]=u,e[58]=t.busy,e[59]=j,e[60]=H):H=e[60];let U;e[61]!==D||e[62]!==H?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[D,H]}),e[61]=D,e[62]=H,e[63]=U):U=e[63];let W;e[64]!==t.error?(W=t.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=W):W=e[65];let te;return e[66]!==b||e[67]!==P||e[68]!==n||e[69]!==F||e[70]!==U||e[71]!==W?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[b,P,n,F,U,W]}),e[66]=b,e[67]=P,e[68]=n,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),ze={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Ae=i((r,e)=>{switch(e.type){case"deleteStart":return{...r,busy:"deleting",writeError:null};case"editMetadata":return{...r,editedMetadata:e.value};case"editTtl":return{...r,editedTtl:e.value};case"editValue":return{...r,editedValue:e.value};case"loaded":return{...r,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"saveOk":return{...r,busy:"",value:r.editedValue};case"saveStart":return{...r,busy:"saving",writeError:null};case"writeFailed":return{...r,busy:"",writeError:e.error};default:return r}},"Ae"),He=i(r=>{let e=(0,ee.c)(67),{expiration:d,keyName:u,namespace:s,onDeleted:v}=r,o=G(),t=R(),[l,p]=(0,$.useReducer)(Ae,ze),c,x;e[0]!==o||e[1]!==u||e[2]!==s?(c=i(()=>{let f={cancelled:!1};return A((async()=>{try{let j=await o.getKvValue({key:u,namespace:s});f.cancelled||p({metadata:j.metadata,type:"loaded",value:j.value})}catch(j){let H=j;f.cancelled||p({error:Z(H),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},"o"),x=[o,s,u],e[0]=o,e[1]=u,e[2]=s,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,$.useEffect)(c,x);let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=i(f=>{p({type:"editValue",value:f.target.value})},"f"),e[5]=g):g=e[5];let O=g,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=i(f=>{p({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let _=V,y;e[7]!==l.editedValue?(y=Fe(l.editedValue),e[7]=l.editedValue,e[8]=y):y=e[8];let m=y,h;e[9]!==l.editedMetadata?(h=Ke(l.editedMetadata),e[9]=l.editedMetadata,e[10]=h):h=e[10];let N=h,w;e[11]!==l.editedTtl?(w=Ve(l.editedTtl),e[11]=l.editedTtl,e[12]=w):w=e[12];let C=w,b;e[13]!==m?(b=i(()=>{m!==void 0&&p({type:"editValue",value:m})},"k"),e[13]=m,e[14]=b):b=e[14];let S=b,E;e[15]!==o||e[16]!==d||e[17]!==u||e[18]!==N||e[19]!==s||e[20]!==l.editedMetadata||e[21]!==l.editedTtl||e[22]!==l.editedValue||e[23]!==t?(E=i(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),A((async()=>{try{await o.putKvValue(Te({metadata:l.editedMetadata,ttl:l.editedTtl,value:l.editedValue},u,s,d)),p({type:"saveOk"})}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"E"),e[15]=o,e[16]=d,e[17]=u,e[18]=N,e[19]=s,e[20]=l.editedMetadata,e[21]=l.editedTtl,e[22]=l.editedValue,e[23]=t,e[24]=E):E=e[24];let J=E,T;e[25]!==o||e[26]!==u||e[27]!==s||e[28]!==v?(T=i(()=>{p({type:"deleteStart"}),A((async()=>{try{await o.deleteKvKey({key:u,namespace:s}),v(u)}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"V"),e[25]=o,e[26]=u,e[27]=s,e[28]=v,e[29]=T):T=e[29];let P=T,L;e[30]!==u?(L=i(()=>{de(u)},"D"),e[30]=u,e[31]=L):L=e[31];let M;e[32]!==t?(M=t("Copy key"),e[32]=t,e[33]=M):M=e[33];let n;e[34]!==L||e[35]!==M?(n=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)(B,{"data-testid":"kv-copy-key-btn",onClick:L,size:"sm",variant:"outline",children:M})}),e[34]=L,e[35]=M,e[36]=n):n=e[36];let k;e[37]!==l.loadError?(k=l.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:l.loadError}),e[37]=l.loadError,e[38]=k):k=e[38];let F;e[39]!==l.loading||e[40]!==t?(F=l.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=l.loading,e[40]=t,e[41]=F):F=e[41];let I;e[42]!==m||e[43]!==N||e[44]!==P||e[45]!==S||e[46]!==J||e[47]!==l.busy||e[48]!==l.editedMetadata||e[49]!==l.editedValue||e[50]!==l.loading||e[51]!==l.value||e[52]!==l.writeError||e[53]!==t||e[54]!==C?(I=!l.loading&&l.value!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),m!==void 0&&(0,a.jsx)(he,{variant:"secondary",children:t("JSON")}),(0,a.jsx)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:be(Pe(l.editedValue))})]}),(0,a.jsx)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:O,value:l.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)(B,{"data-testid":"kv-format-btn",disabled:m===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)(B,{"data-testid":"kv-copy-value-btn",onClick:i(()=>{de(l.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(Me,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!C,onChange:i(f=>{p({type:"editTtl",value:f})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(Ie,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:_,testId:"kv-metadata-editor",valid:N,value:l.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(B,{"data-testid":"kv-save-btn",disabled:l.busy!==""||!N||!C,onClick:J,children:l.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)(B,{"data-testid":"kv-delete-btn",disabled:l.busy!=="",onClick:P,variant:"destructive",children:l.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),l.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:l.writeError})]}),e[42]=m,e[43]=N,e[44]=P,e[45]=S,e[46]=J,e[47]=l.busy,e[48]=l.editedMetadata,e[49]=l.editedValue,e[50]=l.loading,e[51]=l.value,e[52]=l.writeError,e[53]=t,e[54]=C,e[55]=I):I=e[55];let K;e[56]!==l.loadError||e[57]!==l.loading||e[58]!==l.value||e[59]!==t?(K=!l.loading&&l.value===null&&l.loadError===null&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=l.loadError,e[57]=l.loading,e[58]=l.value,e[59]=t,e[60]=K):K=e[60];let D;return e[61]!==n||e[62]!==k||e[63]!==F||e[64]!==I||e[65]!==K?(D=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[n,k,F,I,K]}),e[61]=n,e[62]=k,e[63]=F,e[64]=I,e[65]=K,e[66]=D):D=e[66],D},"ze"),Se=100,Ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=i((r,e)=>{switch(e.type){case"appendPage":return{...r,cursor:e.cursor,keys:[...r.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...r,appliedPrefix:r.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{let d=new Set(e.deleted);return{...r,bulk:r.bulk.filter(u=>!d.has(u)),bulkBusy:!1,bulkError:e.error,keys:r.keys===null?null:r.keys.filter(u=>!d.has(u.name)),selectedKey:r.selectedKey!==null&&d.has(r.selectedKey)?null:r.selectedKey}}case"bulkDeleteStart":return{...r,bulkBusy:!0,bulkError:null};case"firstPage":return{...r,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...r,bulk:r.bulk.filter(d=>d!==e.name),keys:r.keys===null?null:r.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"loadStart":return{...r,loadError:null,loading:!0};case"prefixInput":return{...r,prefixInput:e.value};case"reload":return{...r,bulk:[],bulkError:null,reloadNonce:r.reloadNonce+1,selectedKey:null};case"selectKey":return{...r,selectedKey:e.name};case"toggleAllBulk":return{...r,bulk:e.names};case"toggleBulk":return{...r,bulk:r.bulk.includes(e.name)?r.bulk.filter(d=>d!==e.name):[...r.bulk,e.name]};default:return r}},"Re"),Ue=i(({namespace:r})=>{let e=G(),d=R(),[u,s]=(0,$.useReducer)(Re,Ze),{appliedPrefix:v,bulk:o,bulkBusy:t,bulkError:l,cursor:p,keys:c,listComplete:x,loadError:g,loading:O,prefixInput:V,reloadNonce:_,selectedKey:y}=u,[m,h]=(0,$.useState)(!1);(0,$.useEffect)(()=>{let n={cancelled:!1};return A((async()=>{s({type:"loadStart"});try{let k=await e.listKvKeys({limit:Se,namespace:r,prefix:v===""?void 0:v});n.cancelled||s({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){n.cancelled||s({error:Z(k),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,r,v,_]);let N=i(n=>{s({type:"prefixInput",value:n.target.value})},"x"),w=i(()=>{s({type:"applyFilter"})},"N"),C=i(n=>{s({name:n.currentTarget.dataset.key??null,type:"selectKey"})},"C"),b=i(()=>{p!==null&&(s({type:"loadStart"}),A((async()=>{try{let n=await e.listKvKeys({cursor:p,limit:Se,namespace:r,prefix:v===""?void 0:v});s({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){s({error:Z(n),type:"loadFailed"})}})()))},"k"),S=i(n=>{s({name:n,type:"keyDeleted"})},"w"),E=i(n=>{s({name:n,type:"toggleBulk"})},"E"),J=i(n=>{s({names:n&&c!==null?c.map(k=>k.name):[],type:"toggleAllBulk"})},"J"),T=i(()=>{if(o.length===0)return;let n=[...o];s({type:"bulkDeleteStart"}),A((async()=>{let k=await Promise.allSettled(n.map(K=>e.deleteKvKey({key:K,namespace:r}))),F=n.filter((K,D)=>k[D]?.status==="fulfilled"),I=n.length-F.length;s({deleted:F,error:I>0?d("Failed to delete {count} keys.",{count:I}):null,type:"bulkDeleted"})})())},"V"),P=i(()=>{h(!1),s({type:"reload"})},"L"),L=c!==null&&c.length>0&&o.length===c.length,M=new Set(o);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ae,{"aria-label":d("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:d("Filter by prefix\u2026"),value:V}),(0,a.jsx)(B,{"data-testid":"kv-filter-btn",disabled:O,onClick:w,children:d("Filter")}),(0,a.jsx)(B,{"data-testid":"kv-new-key-btn",onClick:i(()=>{h(n=>!n)},"onClick"),variant:"outline",children:d("New key")}),o.length>0&&(0,a.jsx)(B,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:T,variant:"destructive",children:t?d("Deleting\u2026"):d("Delete {count}",{count:o.length})})]}),l!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:l}),g!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:g}),c!==null&&c.length===0&&!O&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:d("No keys.")}),c!==null&&c.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-key-table",children:[(0,a.jsx)(ie,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(X,{className:"w-10",children:(0,a.jsx)(ue,{"aria-label":d("Select all"),checked:L,"data-testid":"kv-select-all",onCheckedChange:J})}),(0,a.jsx)(X,{children:d("Key")}),(0,a.jsx)(X,{children:d("Expiration")})]})}),(0,a.jsx)(oe,{children:c.map(n=>(0,a.jsxs)(Q,{className:n.name===y?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":n.name,"data-testid":`kv-key-row-${n.name}`,onClick:C,children:[(0,a.jsx)(Y,{onClick:i(k=>{k.stopPropagation()},"onClick"),children:(0,a.jsx)(ue,{"aria-label":d("Select {name}",{name:n.name}),checked:M.has(n.name),"data-testid":`kv-select-${n.name}`,onCheckedChange:i(()=>{E(n.name)},"onCheckedChange")})}),(0,a.jsx)(Y,{className:"font-mono text-xs",children:n.name}),(0,a.jsx)(Y,{className:"tabular-nums text-xs",children:Le(n.expiration)})]},n.name))})]})})}),!x&&p!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(B,{"data-testid":"kv-load-more",disabled:O,onClick:b,variant:"outline",children:d(O?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:i(n=>{n||h(!1)},"onOpenChange"),open:m,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{children:d("New key")})}),(0,a.jsx)(je,{namespace:r,onCancel:i(()=>{h(!1)},"onCancel"),onCreated:P})]})}),(0,a.jsx)(me,{onOpenChange:i(n=>{n||s({name:null,type:"selectKey"})},"onOpenChange"),open:y!==null,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{className:"truncate font-mono text-xs",children:y})}),y!==null&&(0,a.jsx)(He,{expiration:c?.find(n=>n.name===y)?.expiration,keyName:y,namespace:r,onDeleted:S},`${r}:${y}`)]})})]})},"Ue"),it=i(({loadNamespaces:r}={})=>{let e=G(),d=R(),[u,s]=(0,$.useState)(null),[v,o]=(0,$.useState)(null),[t,l]=(0,$.useState)(null);(0,$.useEffect)(()=>{let c={cancelled:!1};return A((async()=>{try{let x=await(r??(()=>e.listKvNamespaces()))();c.cancelled||(s(x),o(null),l(g=>g??x[0]?.binding??null))}catch(x){c.cancelled||(s(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,r]);let p=i(c=>{l(c.currentTarget.dataset.ns??null)},"v");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[v!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:v}),u!==null&&u.length===0&&(0,a.jsx)(ke,{description:d("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:d("No KV namespaces.")}),u!==null&&u.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(ie,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(X,{children:d("Namespace")})})}),(0,a.jsx)(oe,{children:u.map(c=>(0,a.jsx)(Q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,a.jsx)(Y,{className:"font-mono text-xs",children:c.binding})},c.binding))})]})})}),t!==null&&(0,a.jsx)(Ue,{namespace:t},t)]})},"ct");export{it as KvBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-
|
|
1
|
+
import{a as C}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as S}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as c}from"./chunk-XQCVZAGU.js";import{a as w,b as A,c as O,d as f,e as l,f as s}from"./chunk-WJQLNYGX.js";import{a as y,e as N}from"./chunk-WQH3LT2P.js";import{d as x}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as n,e as p,f as $,h as L}from"./chunk-3XIESWL4.js";var F=p($(),1);var e=p(L(),1);var q=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"L"),D='{ "targetingKey": "user-123", "plan": "premium" }',M=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"V"),Y=n(({initialShardKey:a=""})=>{let t=x(),[o,j]=(0,F.useState)(""),{context:g,error:m}=q(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,U=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,V)=>r.key.localeCompare(V.key)):[],d;return u&&!U?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(A,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(l,{children:t("Key")}),(0,e.jsx)(l,{children:t("Type")}),(0,e.jsx)(l,{children:t("Value")}),(0,e.jsx)(l,{children:t("Reason")}),(0,e.jsx)(l,{children:t("Variant")})]})}),(0,e.jsx)(O,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(s,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(s,{className:"font-mono text-xs",children:M(r)}),(0,e.jsx)(s,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(T,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(C,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:D,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"X");export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as S}from"./chunk-
|
|
1
|
+
import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as S}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as f}from"./chunk-VDW32UET.js";import{c as p}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as C,b as j,c as I,d as m,e as n,f as o}from"./chunk-WJQLNYGX.js";import{a as A,e as k}from"./chunk-WQH3LT2P.js";import{d as B,r as M}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as z,f as W,h as X}from"./chunk-3XIESWL4.js";var D=z(W(),1);var e=z(X(),1);var F="agent_threads",Y="agent_messages",Z=100,ee=250,te={},ae={filters:[],limit:Z,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:F},l=i((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"l"),K=i((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"b"),P=i(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"z"),re=i(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"ee"),se=i(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"te"),ne=i(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ae"),fe=i(({initialShardKey:s=""})=>{let t=B(),[a,$]=(0,D.useState)(void 0),{data:x}=p(f.listTables,te,{live:!0,shardKey:s}),L=x!==void 0,u=Array.isArray(x)&&x.some(r=>r.name===F),{data:U,error:O,errorSource:R,liveError:G}=p(f.readTablePage,ae,{enabled:u,live:!0,shardKey:s}),H={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Y},{data:_,error:J,errorSource:Q}=p(f.readTablePage,H,{enabled:u&&a!==void 0,live:!0,shardKey:s}),v=Array.isArray(U?.rows)?U.rows:[],q=Array.isArray(_?.rows)?_.rows:[],E=v.find(r=>l(r,"key")===a),h;return L&&!u?h=(0,e.jsx)(T,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):u&&v.length===0?h=(0,e.jsx)(T,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):h=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(j,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Agent")}),(0,e.jsx)(n,{children:t("Key")}),(0,e.jsx)(n,{children:t("Status")}),(0,e.jsx)(n,{children:t("Messages")}),(0,e.jsx)(n,{children:t("Tokens")}),(0,e.jsx)(n,{children:t("Updated")}),(0,e.jsx)(n,{"aria-label":t("Actions")})]})}),(0,e.jsx)(I,{children:v.map(r=>{let d=l(r,"key")??"",c=l(r,"status"),g=P(r);return(0,e.jsxs)(m,{"data-active":d===a?"":void 0,"data-testid":`agents-thread-${d}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:l(r,"agent")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:d}),(0,e.jsx)(o,{children:(0,e.jsx)(b,{"data-testid":`agents-thread-status-${d}`,variant:se(c),children:c??"\u2014"})}),(0,e.jsx)(o,{className:"tabular-nums",children:K(r,"messageCount")??"\u2014"}),(0,e.jsx)(o,{className:"tabular-nums text-muted-foreground",children:g??"\u2014"}),(0,e.jsx)(o,{className:"text-muted-foreground tabular-nums",children:M(K(r,"updatedAt"),"\u2014")}),(0,e.jsx)(o,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${d}`,onClick:i(()=>{$(d)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},d)})})]})})}),J!==null&&(0,e.jsx)(S,{error:Q,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(k,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,E!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",P(E)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:i(()=>{$(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),q.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(j,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Role")}),(0,e.jsx)(n,{children:t("Content")}),(0,e.jsx)(n,{children:t("Tool")}),(0,e.jsx)(n,{children:t("Approval")})]})}),(0,e.jsx)(I,{children:q.map((r,d)=>{let c=l(r,"role")??"\u2014",g=re(r),V=l(r,"toolName"),y=l(r,"status"),N=K(r,"seq")??d;return(0,e.jsxs)(m,{"data-testid":`agents-message-${String(N)}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:c}),(0,e.jsx)(o,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(r,"content")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:V??(g.length>0?g.join(", "):"\u2014")}),(0,e.jsx)(o,{className:"align-top",children:y===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(b,{"data-testid":`agents-message-approval-${String(N)}`,variant:ne(y),children:y})})]},l(r,"messageKey")??`${c}:${String(N)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[O!==null&&(0,e.jsx)(S,{error:R,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),G!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),h]})},"pe");export{fe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Pe}from"./chunk-V53KNYRN.js";import{a as he}from"./chunk-5Y3QLNWX.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-QBWRC5YX.js";import{a as Q}from"./chunk-HPFLBYRI.js";import{a as Oe}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ye}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ve}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Ie}from"./chunk-VDW32UET.js";import{f as H}from"./chunk-
|
|
1
|
+
import{a as Pe}from"./chunk-V53KNYRN.js";import{a as he}from"./chunk-5Y3QLNWX.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-QBWRC5YX.js";import{a as Q}from"./chunk-HPFLBYRI.js";import{a as Oe}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ye}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ve}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Ie}from"./chunk-VDW32UET.js";import{f as H}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as B}from"./chunk-XQCVZAGU.js";import{d as E,e as Se,f as se,g as ie,h as le,o as $e,q as ae}from"./chunk-IUYFXK4X.js";import{c as be}from"./chunk-P33WK7YI.js";import{a as u,e as K,f as ue,g as te,h as re,j as fe}from"./chunk-3XIESWL4.js";var Fe=K(te(),1),ge=K(ue(),1);var Z=K(te(),1);var X=K(ue(),1);var T=K(re(),1);var Ve=se(Ie.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"J"),Ce=u(({file:t,fn:e,kind:a})=>`await client.${Ze[a]}(api.${t}.${e}, { /* args */ });`,"U"),Ye=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ce(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"re"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"se"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
|
|
2
2
|
`),"de"),rt=u((t,e)=>{switch(t){case"cli":return et(e);case"client":return Ce(e);default:return Ye(e)}},"ce"),Te=u(t=>{let e=(0,Z.c)(19),{code:a,label:r,testId:n}=t,s=E(),o;e[0]!==a?(o=u(()=>{ae(a)},"s"),e[0]=a,e[1]=o):o=e[1];let i=o,d;e[2]!==r?(d=(0,T.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=d):d=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let c;e[6]!==i||e[7]!==m||e[8]!==l?(c=(0,T.jsx)(U,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=c):c=e[9];let f;e[10]!==d||e[11]!==c?(f=(0,T.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[d,c]}),e[10]=d,e[11]=c,e[12]=f):f=e[12];let x;e[13]!==a||e[14]!==n?(x=(0,T.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=x):x=e[15];let h;return e[16]!==f||e[17]!==x?(h=(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,x]}),e[16]=f,e[17]=x,e[18]=h):h=e[18],h},"V"),at=u(t=>{let e=(0,Z.c)(50),{file:a,fn:r,kind:n}=t,s=E(),[o,i]=(0,X.useState)("react"),d,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let $={file:a,fn:r,kind:n},S;e[8]!==s?(S=s("CLI"),e[8]=s,e[9]=S):S=e[9];let C;e[10]!==s?(C=s("Client"),e[10]=s,e[11]=C):C=e[11];let A;e[12]!==s?(A=s("React"),e[12]=s,e[13]=A):A=e[13];let M;e[14]!==S||e[15]!==C||e[16]!==A?(M={cli:S,client:C,react:A},e[14]=S,e[15]=C,e[16]=A,e[17]=M):M=e[17],l=M;let _;e[18]===Symbol.for("react.memo_cache_sentinel")?(_=u(J=>{i(J.currentTarget.dataset.tab)},"D"),e[18]=_):_=e[18],d=_,m=rt(o,$),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=d,e[6]=m,e[7]=l}else d=e[5],m=e[6],l=e[7];let c=m,f=n==="action"&&o==="react"&&!Xe,x=`api.${a}.${r}`,h;e[19]!==x?(h=(0,T.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:x}),e[19]=x,e[20]=h):h=e[20];let b;e[21]!==n||e[22]!==s?(b=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=b):b=e[23];let y;e[24]!==b?(y=(0,T.jsx)("p",{className:"text-xs text-muted-foreground",children:b}),e[24]=b,e[25]=y):y=e[25];let N;e[26]!==h||e[27]!==y?(N=(0,T.jsxs)("div",{children:[h,y]}),e[26]=h,e[27]=y,e[28]=N):N=e[28];let v;e[29]!==s?(v=s("Snippet flavour"),e[29]=s,e[30]=v):v=e[30];let g;e[31]!==d||e[32]!==o||e[33]!==l?(g=Qe.map($=>(0,T.jsx)(U,{"aria-selected":o===$,"data-tab":$,"data-testid":`api-tab-${$}`,onClick:d,role:"tab",size:"xs",type:"button",variant:o===$?"default":"outline",children:l[$]},$)),e[31]=d,e[32]=o,e[33]=l,e[34]=g):g=e[34];let k;e[35]!==v||e[36]!==g?(k=(0,T.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:g}),e[35]=v,e[36]=g,e[37]=k):k=e[37];let O=l[o],P=`api-snippet-${o}`,w;e[38]!==c||e[39]!==O||e[40]!==P?(w=(0,T.jsx)(Te,{code:c,label:O,testId:P}),e[38]=c,e[39]=O,e[40]=P,e[41]=w):w=e[41];let I;e[42]!==f||e[43]!==s?(I=f&&(0,T.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:s("Actions have no React hook \u2014 call them through the client.")}),e[42]=f,e[43]=s,e[44]=I):I=e[44];let j;return e[45]!==w||e[46]!==I||e[47]!==N||e[48]!==k?(j=(0,T.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[N,k,w,I]}),e[45]=w,e[46]=I,e[47]=N,e[48]=k,e[49]=j):j=e[49],j},"pe"),nt=u(t=>{let e=(0,Z.c)(19),{name:a}=t,r=E(),n;e[0]!==a?(n=tt(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,T.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,T.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=d):d=e[7];let m;e[8]!==o||e[9]!==d?(m=(0,T.jsxs)("div",{children:[o,d]}),e[8]=o,e[9]=d,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let c;e[13]!==s||e[14]!==l?(c=(0,T.jsx)(Te,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=c):c=e[15];let f;return e[16]!==m||e[17]!==c?(f=(0,T.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,c]}),e[16]=m,e[17]=c,e[18]=f):f=e[18],f},"fe"),je=u(t=>{let e=(0,Z.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"u"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let d=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==d||e[5]!==m||e[6]!==s?(l=(0,T.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:d,type:"button",children:r}),e[3]=r,e[4]=d,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),ot=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=_e(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"me"),Ae=u(t=>{let e=(0,Z.c)(58),{functions:a,initialShardKey:r}=t,n=E(),s=H(),[o,i]=(0,X.useState)(null),[d,m]=(0,X.useState)(null),l,c;e[0]!==s||e[1]!==r?(l=u(()=>{let M=!1;return s.query(Ve,{},ie(r??"")).then(_=>(M||i(_),_)).catch(()=>{M||i([])}),()=>{M=!0}},"r"),c=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=c):(l=e[2],c=e[3]),(0,X.useEffect)(l,c);let f,x,h,b,y,N,v,g,k,O;if(e[4]!==a||e[5]!==d||e[6]!==n||e[7]!==o){let M=a??[],_=ot(M),J=(o??[]).map(st).toSorted(it),R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=u(z=>{m({kind:"fn",path:z})},"F"),e[18]=R):R=e[18];let D=R,V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=u(z=>{m({kind:"table",name:z})},"H"),e[19]=V):V=e[19];let Ge=V;x=d?.kind==="fn"?M.find(z=>z.path===d.path):void 0,f=M.length>0||J.length>0,h=x===void 0?void 0:_e(x.path),k="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",O="lunora-api-docs",e[20]!==n?(b=n("API resources"),e[20]=n,e[21]=b):b=e[21],y="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==d||e[23]!==n?(ne=u(z=>(0,T.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,T.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:z.file||n("(root)")}),z.items.map(ee=>(0,T.jsx)(je,{active:d?.kind==="fn"&&d.path===ee.path,label:ee.fn,onSelect:D,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},z.file),"K"),e[22]=d,e[23]=n,e[24]=ne):ne=e[24],v=_.map(ne),g=J.length>0&&(0,T.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,T.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),J.map(z=>(0,T.jsx)(je,{active:d?.kind==="table"&&d.name===z,label:z,onSelect:Ge,testId:`api-rail-table-${z}`,value:z},z))]}),e[4]=a,e[5]=d,e[6]=n,e[7]=o,e[8]=f,e[9]=x,e[10]=h,e[11]=b,e[12]=y,e[13]=N,e[14]=v,e[15]=g,e[16]=k,e[17]=O}else f=e[8],x=e[9],h=e[10],b=e[11],y=e[12],N=e[13],v=e[14],g=e[15],k=e[16],O=e[17];let P;e[25]!==f||e[26]!==n?(P=!f&&(0,T.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=P):P=e[27];let w;e[28]!==P||e[29]!==b||e[30]!==y||e[31]!==N||e[32]!==v||e[33]!==g?(w=(0,T.jsxs)("nav",{"aria-label":b,className:y,"data-testid":N,children:[v,g,P]}),e[28]=P,e[29]=b,e[30]=y,e[31]=N,e[32]=v,e[33]=g,e[34]=w):w=e[34];let I;e[35]!==d||e[36]!==n?(I=d===null&&(0,T.jsx)(B,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=d,e[36]=n,e[37]=I):I=e[37];let j;e[38]!==d?.kind||e[39]!==x||e[40]!==h?(j=d?.kind==="fn"&&x!==void 0&&h!==void 0&&(0,T.jsx)(at,{file:h.file,fn:h.fn,kind:x.kind},x.path),e[38]=d?.kind,e[39]=x,e[40]=h,e[41]=j):j=e[41];let $;e[42]!==d?.kind||e[43]!==x||e[44]!==n?($=d?.kind==="fn"&&x===void 0&&(0,T.jsx)(B,{testId:"api-empty",title:n("API usage snippets")}),e[42]=d?.kind,e[43]=x,e[44]=n,e[45]=$):$=e[45];let S;e[46]!==d?(S=d?.kind==="table"&&(0,T.jsx)(nt,{name:d.name}),e[46]=d,e[47]=S):S=e[47];let C;e[48]!==I||e[49]!==j||e[50]!==$||e[51]!==S?(C=(0,T.jsxs)("div",{className:"min-w-0",children:[I,j,$,S]}),e[48]=I,e[49]=j,e[50]=$,e[51]=S,e[52]=C):C=e[52];let A;return e[53]!==w||e[54]!==C||e[55]!==k||e[56]!==O?(A=(0,T.jsxs)("div",{className:k,"data-testid":O,children:[w,C]}),e[53]=w,e[54]=C,e[55]=k,e[56]=O,e[57]=A):A=e[57],A},"Se");function st(t){return t.name}u(st,"ue");function it(t,e){return t.localeCompare(e)}u(it,"he");var We=K(te(),1);var q=K(te(),1),L=K(ue(),1);var p=K(re(),1);var pe=u(function(t,e,a){let r=(0,q.c)(10),n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},r[0]=n):n=r[0];let[s,o]=(0,L.useState)(n),i,d;r[1]!==a||r[2]!==e||r[3]!==t?(i=u(()=>{if(t!==void 0)return;let l=!1;return e().then(c=>(l||o(a(c)),c)).catch(c=>{l||o({kind:"error",message:le(c)})}),()=>{l=!0}},"l"),d=[a,e,t],r[1]=a,r[2]=e,r[3]=t,r[4]=i,r[5]=d):(i=r[4],d=r[5]),(0,L.useEffect)(i,d);let m;return r[6]!==a||r[7]!==s||r[8]!==t?(m=t===void 0?s:a(t),r[6]=a,r[7]=s,r[8]=t,r[9]=m):m=r[9],m},"gt"),lt=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","$e"),Re=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"X"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","B"),dt=u(t=>{let e=Re(t);return e!==void 0?t.type??lt(e[0]):ce(t)},"ke"),ct=u(t=>{let e=Re(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"Se"),pt=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"we"),mt=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Oe"),Y=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Y(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Y(r);return e}case"string":return"";default:return null}},"q"),de=u(t=>{let e=(0,q.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,p.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,p.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,p.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"W"),ut=u(t=>{let e=(0,q.c)(40),{name:a,required:r,schema:n}=t,s=E(),o;e[0]!==n?(o=pt(n),e[0]=n,e[1]=o):o=e[1];let i=o,d;e[2]!==n?(d=ct(n),e[2]=n,e[3]=d):d=e[3];let m=d,l=n["x-lunora-table"],c=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=mt(n),e[4]=n,e[5]=f):f=e[5];let x=f,h=r?"*":"?",b;e[6]!==h?(b=(0,p.jsx)("span",{className:"text-muted-foreground",children:h}),e[6]=h,e[7]=b):b=e[7];let y;e[8]!==a||e[9]!==b?(y=(0,p.jsxs)("span",{className:"font-mono text-foreground",children:[a,b]}),e[8]=a,e[9]=b,e[10]=y):y=e[10];let N;e[11]!==n?(N=dt(n),e[11]=n,e[12]=N):N=e[12];let v;e[13]!==N?(v=(0,p.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=v):v=e[14];let g;e[15]!==y||e[16]!==v?(g=(0,p.jsxs)("div",{className:"flex items-baseline gap-2",children:[y,v]}),e[15]=y,e[16]=v,e[17]=g):g=e[17];let k;e[18]!==n.description?(k=n.description!==void 0&&(0,p.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=k):k=e[19];let O;e[20]!==c||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(O=c&&(0,p.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,p.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,p.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,p.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,p.jsx)(de,{label:s("relation"),value:l})]}),e[20]=c,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=O):O=e[26];let P;e[27]!==k||e[28]!==O||e[29]!==g?(P=(0,p.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[g,k,O]}),e[27]=k,e[28]=O,e[29]=g,e[30]=P):P=e[30];let w=P;if(x===void 0){let S;return e[31]!==w?(S=(0,p.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:w}),e[31]=w,e[32]=S):S=e[32],S}let I;e[33]!==w?(I=(0,p.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:w}),e[33]=w,e[34]=I):I=e[34];let j;e[35]!==x?(j=(0,p.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,p.jsx)(Je,{schema:x})}),e[35]=x,e[36]=j):j=e[36];let $;return e[37]!==I||e[38]!==j?($=(0,p.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[I,j]}),e[37]=I,e[38]=j,e[39]=$):$=e[39],$},"je"),Je=u(t=>{let e=(0,q.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,p.jsx)("div",{className:"flex flex-col",children:o.map(d=>{let[m,l]=d;return(0,p.jsx)(ut,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"Y"),Me=u(t=>{let e=(0,q.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,p.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,p.jsx)(Je,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,p.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"G"),ft=["curl","javascript","lunora"],ht={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},xt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"Pe"),gt=u(t=>{let e=Y(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"Te"),bt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(gt(e),void 0,2),s=JSON.stringify(Y(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
|
|
3
3
|
`)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
|
|
4
4
|
import { api } from "./_generated/api";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as k}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as q}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as F}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as B}from"./chunk-
|
|
1
|
+
import{R as k}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as q}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as F}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as B}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as P}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as M}from"./chunk-XQCVZAGU.js";import{a as G,b as H,c as J,d as T,e as x,f as w}from"./chunk-WJQLNYGX.js";import{a as z,e as D}from"./chunk-WQH3LT2P.js";import{d as U,r as O}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as b,e as j,f as V,g as X,h as Y}from"./chunk-3XIESWL4.js";var K=j(X(),1),W=j(V(),1);var t=j(Y(),1);var de=b(()=>{let e=(0,K.c)(39),r=U(),[s,$]=(0,W.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:A,error:i,errorSource:S,isLoading:_,refetch:E}=P(R.getAuthAuditLog,y),C;if(e[1]!==A?.entries||e[2]!==s){let a=A?.entries??[],v=s.trim().toLowerCase();C=v===""?a:a.filter(N=>N.event.toLowerCase().includes(v)||(N.actorId??"").toLowerCase().includes(v)||(N.actorEmail??"").toLowerCase().includes(v)||(N.ip??"").toLowerCase().includes(v)||N.outcome.toLowerCase().includes(v)),e[1]=A?.entries,e[2]=s,e[3]=C}else C=e[3];let o=C,I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=b(a=>{$(a.target.value)},"I"),e[4]=I):I=e[4];let Q=I,l;e[5]!==r?(l=r("Filter security events"),e[5]=r,e[6]=l):l=e[6];let n;e[7]!==r?(n=r("filter event, actor, IP"),e[7]=r,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==l||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":l,className:"h-8 w-56","data-testid":"aa-search",onChange:Q,placeholder:n,value:s}),e[9]=s,e[10]=l,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==E?(d=b(()=>{E()},"m"),e[13]=E,e[14]=d):d=e[14];let m;e[15]!==r?(m=r("Refresh"),e[15]=r,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==i||e[24]!==S?(f=i!==null&&(0,t.jsx)(B,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==i||e[27]!==o.length||e[28]!==_||e[29]!==r?(p=i===null&&!_&&o.length===0&&(0,t.jsx)(M,{description:r("Authentication and security events are recorded here."),testId:"aa-empty",title:r("No security events.")}),e[26]=i,e[27]=o.length,e[28]=_,e[29]=r,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==r?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(x,{children:r("time")}),(0,t.jsx)(x,{children:r("event")}),(0,t.jsx)(x,{children:r("actor")}),(0,t.jsx)(x,{children:r("ip / user agent")}),(0,t.jsx)(x,{children:r("outcome")})]})}),(0,t.jsx)(J,{children:o.map(a=>(0,t.jsxs)(T,{"data-testid":"aa-row",children:[(0,t.jsx)(w,{className:"text-muted-foreground tabular-nums",children:O(a.ts,"\u2014")}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:"secondary",children:a.event})}),(0,t.jsx)(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:a.actorId??void 0,children:a.actorEmail??a.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:a.userAgent??void 0,children:[a.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),a.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",a.userAgent]})]}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:a.outcome==="failure"?"destructive":"outline",children:r(a.outcome)})})]},a.seq))})]})})}),e[31]=o,e[32]=r,e[33]=g):g=e[33];let L;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(L=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=L):L=e[38],L},"ce");export{de as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-AREBQI6D.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as E}from"./chunk-LZGOETI3.js";import{f as _}from"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-WJQLNYGX.js";import{a as B,e as D}from"./chunk-WQH3LT2P.js";import{d as A,h as O,o as T,r as X}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[v,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),b=v??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==b?.length||e[10]!==r?(S=b?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=S):S=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,v=me(i,a,e),n=c(async s=>{if(v!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await v(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),v!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),v!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let v;e[3]!==l||e[4]!==d?(v=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=v):v=e[5];let n=E(N,v),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=b!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==b||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(b(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=b,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let v=E(o,N),{data:n,error:s}=v,m;e[7]!==v?(m=c(()=>{v.refetch()},"s"),e[7]=v,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=b):b=e[24],b},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),v;e[2]!==l?(v=l("Cron triggers"),e[2]=l,e[3]=v):v=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==v||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:v,dead:n,jobs:s,pools:m},e[10]=v,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==b||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
|
|
1
|
+
import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-AREBQI6D.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as E}from"./chunk-6F7KP54M.js";import{f as _}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-WJQLNYGX.js";import{a as B,e as D}from"./chunk-WQH3LT2P.js";import{d as A,h as O,o as T,r as X}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[v,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),b=v??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==b?.length||e[10]!==r?(S=b?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=S):S=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,v=me(i,a,e),n=c(async s=>{if(v!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await v(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),v!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),v!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let v;e[3]!==l||e[4]!==d?(v=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=v):v=e[5];let n=E(N,v),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=b!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==b||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(b(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=b,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let v=E(o,N),{data:n,error:s}=v,m;e[7]!==v?(m=c(()=>{v.refetch()},"s"),e[7]=v,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=b):b=e[24],b},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),v;e[2]!==l?(v=l("Cron triggers"),e[2]=l,e[3]=v):v=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==v||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:v,dead:n,jobs:s,pools:m},e[10]=v,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==b||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as T}from"./chunk-
|
|
1
|
+
import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as T}from"./chunk-CXBXUT5A.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as E}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as y}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-WJQLNYGX.js";import{a as u,e as N}from"./chunk-WQH3LT2P.js";import{d as _,r as S}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as c,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],$={},D=new Set(["active","trialing"]),q=new Set(["past_due","unpaid"]),a=c((s,t)=>{if(s[t]!==void 0)return s[t];let m=s.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"i"),i=c(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","s"),z=c(s=>D.has(s)?"default":q.has(s)?"destructive":"outline","L"),ae=c(({limit:s=100})=>{let t=_(),m=T(),{data:g}=b(y.listTables,$,{live:!0}),O=g!==void 0,B=Array.isArray(g)&&H.every(r=>g.some(d=>d.name===r)),p=m.payments&&B,o=b(y.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),f=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),f.refetch())},!0);let h=o.data?.rows??[],U=f.data?.rows??[],C=o.error??f.error,F=o.error===null?f.errorSource:o.errorSource,P=h.filter(r=>D.has(i(a(r,"state")))).length,L=U.toSorted((r,d)=>Number(a(d,"processedAt")??0)-Number(a(r,"processedAt")??0));return O&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(u,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),C===null?void 0:(0,e.jsx)(E,{error:F}),h.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(u,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:h.map(r=>{let d=i(a(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{children:i(a(r,"referenceId"))}),(0,e.jsx)(n,{children:i(a(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(x,{variant:z(d),children:d})}),(0,e.jsx)(n,{children:S(a(r,"currentPeriodEnd"))})]},i(a(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(u,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:L.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(a(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(a(r,"processedAt"))})]},i(a(r,"providerEventId"))))})})})]})]})},"ae");export{ae as PaymentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as D,c as g,d as P,f as k}from"./chunk-
|
|
1
|
+
import{b as D,c as g,d as P,f as k}from"./chunk-C2ZFQARQ.js";import{f as v,g as S,h as T,o as q}from"./chunk-IUYFXK4X.js";import{a as i,e as A,f as $,g as M}from"./chunk-3XIESWL4.js";var I=A(M(),1);var f=A($(),1);var l=i(e=>typeof e=="string"?e===""?void 0:e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,"u"),h=i(e=>e.filter(r=>r!==void 0).join(" "),"d"),Q={deleteRows:i(e=>h([l(e.table),Array.isArray(e.ids)?`${String(e.ids.length)} rows`:void 0]),"deleteRows"),facetColumn:i(e=>h([l(e.table),l(e.column)]),"facetColumn"),lintSql:i(()=>"sql","lintSql"),readTablePage:i(e=>h([l(e.table),Array.isArray(e.filters)&&e.filters.length>0?`${String(e.filters.length)} filters`:void 0,typeof e.search=="string"&&e.search!==""?"search":void 0,typeof e.limit=="number"?`limit ${String(e.limit)}`:void 0]),"readTablePage"),runMigration:i(e=>h([l(e.id),l(e.direction),e.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(e=>typeof e.sql=="string"?`${String(e.sql.length)} chars`:"","runSql"),schemaVersion:i(e=>typeof e.hash=="string"?e.hash.slice(0,8):"","schemaVersion"),writeRow:i(e=>h([l(e.table),"1 row"]),"writeRow")},E="__lunora_admin__:",C=i((e,r)=>{let s=e.startsWith(E)?e.slice(E.length):e,t=Q[s];if(t!==void 0)return t(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"N"),L=i(e=>{if(Array.isArray(e))return e.length;if(!(typeof e!="object"||e===null)){for(let r of Object.values(e))if(Array.isArray(r))return r.length}},"K"),w=class{static{i(this,"L")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,s,t){return this.append(r,s,t,"call","pending")}startSubscription(r,s,t){return this.append(r,s,t,"subscription","live")}recordPush(r){if(this.listeners.size===0){let s=this.entries.find(t=>t.seq===r);s!==void 0&&(s.pushes=(s.pushes??0)+1);return}this.patch(r,s=>({...s,pushes:(s.pushes??0)+1}))}failSubscription(r,s){this.patch(r,t=>({...t,error:s,status:"error"}))}endSubscription(r){this.patch(r,s=>s.status==="error"?s:{...s,durationMs:Date.now()-s.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,s){this.patch(r,t=>({...t,durationMs:Date.now()-t.startedAt,...s.error===void 0?{resultCount:L(s.result),status:"ok"}:{error:s.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,s,t,n,a){let o=this.nextSeq;this.nextSeq+=1;let d={functionPath:r,kind:n,seq:o,shardKey:t,startedAt:Date.now(),status:a,summary:C(r,s),...n==="subscription"?{pushes:0}:{}},u=[...this.entries,d];return this.entries=u.length>300?u.slice(u.length-300):u,this.emit(),o}patch(r,s){let t=this.entries.findIndex(n=>n.seq===r);t!==-1&&(this.entries=this.entries.with(t,s(this.entries[t])),this.emit())}emit(){for(let r of this.listeners)r()}},p=new w,_=i((e,r,s)=>["lunora-admin",e,r,s.trim()],"q");function R(e,r,s={}){let{enabled:t=!0,keepPreviousData:n=!1,staleTime:a=0}=s,o=P({enabled:t,queryFn:r,placeholderData:n?D:void 0,queryKey:e,staleTime:a});return{data:o.data,error:o.error?T(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(R,"M");function V(e,r,s={}){let t=k(),n=g(),{enabled:a=!0,keepPreviousData:o=!1,live:d=!1,shardKey:u="",staleTime:j}=s,m=_(e,r,u),x=R(m,()=>t.query(v(e),r,S(u)),{enabled:a,keepPreviousData:o,staleTime:j??(d?Number.POSITIVE_INFINITY:0)}),[N,y]=(0,f.useState)(void 0),O=JSON.stringify(m);return(0,f.useEffect)(()=>{if(!a||!d)return;y(void 0);let b=p.startSubscription(e,r,u),K=t.subscribe(v(e),r,c=>{p.recordPush(b),y(void 0),n.setQueryData(m,c)},{...S(u),onError:i(c=>{p.failSubscription(b,c.message),y(c.message)},"onError")});return()=>{p.endSubscription(b),K()}},[O,a,d]),{...x,liveError:a&&d?N:void 0}}i(V,"z");var U=i(()=>{let e=(0,I.c)(2),r=g(),s;return e[0]!==r?(s=i((t,n,a)=>{let o=n===void 0?["lunora-admin",t]:_(t,n,a??"");q(r.invalidateQueries({queryKey:o}))},"e"),e[0]=r,e[1]=s):s=e[1],s},"J");export{p as a,R as b,V as c,U as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as fe}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as ie}from"./chunk-IC4L6G56.js";import{a as pe}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{R as de}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as x}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ne}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as he}from"./chunk-
|
|
1
|
+
import{a as fe}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as ie}from"./chunk-IC4L6G56.js";import{a as pe}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{R as de}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as x}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ne}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as he}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as P}from"./chunk-VDW32UET.js";import{c as ue}from"./chunk-6F7KP54M.js";import{f as le}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as Y,f as ge,g as ve,h as Ne,j as se}from"./chunk-3XIESWL4.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"xe");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"ae"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"ye"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"we"),Te=Z(P.clearCapturedMail),Le=Z(P.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:D,error:w,errorSource:C,isLoading:g,refetch:n}=ue(P.getCapturedMail,p),[k,f]=(0,N.useState)(null),[E,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,U]=(0,N.useState)(""),b=D?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"S"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let W=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"$"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let B=L,j;e[8]!==n?(j=i(()=>{n()},"T"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==W?(M=i(()=>{ae(W())},"L"),e[10]=W,e[11]=M):M=e[11];let R=M,_;e[12]!==B?(_=i(()=>{ae(B())},"j"),e[12]=B,e[13]=_):_=e[13];let G=_,$;e[14]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{U(m.currentTarget.value)},"M"),e[14]=$):$=e[14];let J=$,z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"_"),e[15]=z):z=e[15];let K=z,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"z"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,E),d=Ce(O),q;e[17]!==d?(q=i(()=>{d!==void 0&&me(d)},"O"),e[17]=d,e[18]=q):q=e[18];let V=q,H;e[19]!==d?(H=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"I"),e[19]=d,e[20]=H):H=e[20];let X=H,I;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==R||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(I={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:R,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=R,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=I):I=e[37],I},"Se"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Te"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:D,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:E,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:U}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:D}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:U.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:E,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
|
|
2
2
|
`)}))]})]})]})]})},"We");export{Je as MailPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as u,n as d}from"./chunk-
|
|
1
|
+
import{m as u,n as d}from"./chunk-OQIGV6FX.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-P33WK7YI.js";import{a as c,e as m,g as y,h as b}from"./chunk-3XIESWL4.js";var h=m(y(),1);var n=m(b(),1);var p={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},_=c(o=>{let e=(0,h.c)(6),{data:i}=o,a,r;if(e[0]!==i){r=Symbol.for("react.early_return_sentinel");e:{let f=i.slice(-16);if(f.length<3){r=null;break e}a=f.map(g)}e[0]=i,e[1]=a,e[2]=r}else a=e[1],r=e[2];if(r!==Symbol.for("react.early_return_sentinel"))return r;let s=a,t;e[3]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)(d,{dataKey:"value"}),e[3]=t):t=e[3];let l;return e[4]!==s?(l=(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28",children:(0,n.jsx)(u,{animationType:"none",barCategoryGap:1,className:"h-8 w-full",config:p,data:s,children:t})}),e[4]=s,e[5]=l):l=e[5],l},"b");function g(o,e){return{index:e,value:o}}c(g,"h");export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O,b as U}from"./chunk-AVAC26HJ.js";import{a as F}from"./chunk-IGCNMZSB.js";import{a as j}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-
|
|
1
|
+
import{a as O,b as U}from"./chunk-AVAC26HJ.js";import{a as F}from"./chunk-IGCNMZSB.js";import{a as j}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{a as A,b as T,c as q,d as p,e as n,f as d}from"./chunk-WJQLNYGX.js";import{a as I,e as E}from"./chunk-WQH3LT2P.js";import{d as b,r as k}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as i,e as y,f as ee,h as te}from"./chunk-3XIESWL4.js";var o=y(ee(),1);var e=y(te(),1);var B=80,re=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>B?`${t.slice(0,B)}\u2026`:t},"te"),ae=41,H=480,D=5,ie=i((s,t)=>O(s,l=>{t(l.height>0?l:{height:H,width:l.width})}),"ae"),Ne=i(({initialShardKey:s})=>{let t=b(),{queryShardKey:l,setShardKey:J,shardKey:P}=j(s),[c,W]=(0,o.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=M(R.getAuditLog,{},{live:!0,shardKey:l}),h=(0,o.useMemo)(()=>f?.entries??[],[f]),m=(0,o.useMemo)(()=>{let a=c.trim().toLowerCase();return a===""?h:h.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[h,c]),x=(0,o.useRef)(null),v=U({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:H,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:J,testId:"au-shard-input",value:P}),(0,e.jsx)(F,{message:$,prefix:"au"}),(0,e.jsx)(C,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:c})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(K,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(n,{children:t("time")}),(0,e.jsx)(n,{children:t("op")}),(0,e.jsx)(n,{children:t("table")}),(0,e.jsx)(n,{children:t("id")}),(0,e.jsx)(n,{children:t("detail")})]})}),(0,e.jsxs)(q,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:D,style:Q})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:k(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(L,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:D,style:X})})]})]})})})]})},"we");export{Ne as AuditPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as k,d as I,e as S,f as w,h as T,i as X,j as B,k as g,l as K,m as D,n as E,o as G,p as O}from"./chunk-
|
|
1
|
+
import{c as k,d as I,e as S,f as w,h as T,i as X,j as B,k as g,l as K,m as D,n as E,o as G,p as O}from"./chunk-OQIGV6FX.js";import{d as j,m as q}from"./chunk-IUYFXK4X.js";import{a as x,e as C,g as F,h as H}from"./chunk-3XIESWL4.js";var L=C(F(),1);var e=C(H(),1);var R=50,$={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},W=x(o=>{let a=o.columns.find(t=>o.rows.length>0&&o.rows.every(l=>typeof l[t]=="number"))??null;return{label:o.columns.find(t=>t!==a)??null,value:a}},"G"),z=x(o=>{let a=(0,L.c)(3),{data:t,kind:l}=o,s;return a[0]!==t||a[1]!==l?(s=(0,e.jsx)(B,{className:"h-full w-full",config:$,children:l==="area"?(0,e.jsxs)(X,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(K,{content:(0,e.jsx)(g,{})}),(0,e.jsx)(S,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,e.jsxs)(T,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(K,{content:(0,e.jsx)(g,{})}),(0,e.jsx)(I,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=t,a[1]=l,a[2]=s):s=a[2],s},"H"),U=x(o=>{let a=(0,L.c)(21),{axes:t,result:l}=o,s=j(),u;a[0]!==l?(u=W(l),a[0]=l,a[1]=u):u=a[1];let N=u,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let h=m,v=t!==void 0&&h.has(t.x)?t.x:N.label,f;a[4]!==t?.y||a[5]!==h?(f=t?.y.find(r=>h.has(r)),a[4]=t?.y,a[5]=h,a[6]=f):f=a[6];let A=f,d=A??N.value,p;a[7]!==v||a[8]!==l.rows||a[9]!==d?(p=d===null?[]:l.rows.slice(0,R).map((r,c)=>({label:v===null?`#${(c+1).toString()}`:q(r[v]),value:Number(r[d])||0})),a[7]=v,a[8]=l.rows,a[9]=d,a[10]=p):p=a[10];let y=p;if(d===null){let r;a[11]!==s?(r=s("No numeric column to chart."),a[11]=s,a[12]=r):r=a[12];let c;return a[13]!==r?(c=(0,e.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:r}),a[13]=r,a[14]=c):c=a[14],c}let n=t!==void 0&&A!==void 0?t.kind:"bar",i;a[15]!==y||a[16]!==n?(i=n==="bar"?(0,e.jsxs)(D,{className:"h-full w-full",config:$,data:y,children:[(0,e.jsx)(G,{dataKey:"label"}),(0,e.jsx)(E,{dataKey:"value"}),(0,e.jsx)(O,{})]}):(0,e.jsx)(z,{data:y,kind:n}),a[15]=y,a[16]=n,a[17]=i):i=a[17];let b;return a[18]!==n||a[19]!==i?(b=(0,e.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":n,"data-testid":"sql-chart",children:i}),a[18]=n,a[19]=i,a[20]=b):b=a[20],b},"R");export{U as a};
|