@lunora/studio 1.0.0-alpha.182 → 1.0.0-alpha.184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/standalone/{chunk-FH3VYT3W.js → chunk-26L63KFY.js} +1 -1
- package/dist/standalone/{chunk-3PZNTIBM.js → chunk-2KM4MU7U.js} +1 -1
- package/dist/standalone/{chunk-IP7YCJUN.js → chunk-37CLUREK.js} +1 -1
- package/dist/standalone/{chunk-XKP3TSCE.js → chunk-3GJKDNXE.js} +1 -1
- package/dist/standalone/{chunk-FI6N7XWP.js → chunk-4P4DE3XL.js} +1 -1
- package/dist/standalone/{chunk-H43JNQM6.js → chunk-4PLYQWKJ.js} +1 -1
- package/dist/standalone/{chunk-TIIEZS24.js → chunk-4X5HAX5N.js} +1 -1
- package/dist/standalone/{chunk-QQ3CS3FX.js → chunk-55K64SUB.js} +1 -1
- package/dist/standalone/{chunk-5XRNQ732.js → chunk-56XCNBO4.js} +1 -1
- package/dist/standalone/{chunk-DAD33Q2T.js → chunk-5AQVGRDR.js} +1 -1
- package/dist/standalone/{chunk-I6FR5UAK.js → chunk-5TV5EBCO.js} +1 -1
- package/dist/standalone/{chunk-JYT34NQM.js → chunk-6VNVVY4F.js} +1 -1
- package/dist/standalone/{chunk-VWXJAY7R.js → chunk-724ZBLVZ.js} +1 -1
- package/dist/standalone/{chunk-AULH6SZB.js → chunk-75OWNJEY.js} +2 -2
- package/dist/standalone/{chunk-TTIBDOV6.js → chunk-7E4PCEOO.js} +1 -1
- package/dist/standalone/chunk-7MF5C3Z6.js +1 -0
- package/dist/standalone/{chunk-SDHFSBNM.js → chunk-7TRN7FQ4.js} +1 -1
- package/dist/standalone/{chunk-BAAPQWFF.js → chunk-AO5ROTB4.js} +1 -1
- package/dist/standalone/{chunk-A6S4TULR.js → chunk-BMVSHGFK.js} +1 -1
- package/dist/standalone/{chunk-B3JY36UV.js → chunk-CLELTQYS.js} +1 -1
- package/dist/standalone/{chunk-AX24JD2G.js → chunk-CZIPGHIR.js} +1 -1
- package/dist/standalone/{chunk-5LZJ5JBB.js → chunk-DVXDMRWA.js} +1 -1
- package/dist/standalone/{chunk-B6RRRJP5.js → chunk-EAQZEXBX.js} +1 -1
- package/dist/standalone/{chunk-IXNOQYEE.js → chunk-ETHN2RZR.js} +1 -1
- package/dist/standalone/{chunk-CBNGOAD4.js → chunk-FAFNOIJX.js} +1 -1
- package/dist/standalone/{chunk-ITMXIPQ7.js → chunk-FDB7QVEC.js} +1 -1
- package/dist/standalone/{chunk-GZAXFXZE.js → chunk-FGMA2GGM.js} +1 -1
- package/dist/standalone/{chunk-GAPFZFIL.js → chunk-FRMJ5VVM.js} +1 -1
- package/dist/standalone/{chunk-5MKG6RW3.js → chunk-FZ45WJQK.js} +1 -1
- package/dist/standalone/{chunk-2Y6PXGIS.js → chunk-GETL6R4M.js} +14 -14
- package/dist/standalone/{chunk-3TXB4AKZ.js → chunk-GKUDJ3RC.js} +1 -1
- package/dist/standalone/{chunk-AODYDAXY.js → chunk-HATH336U.js} +1 -1
- package/dist/standalone/{chunk-D4ZGY3II.js → chunk-IYUIJLIW.js} +1 -1
- package/dist/standalone/{chunk-66Z7ZIZZ.js → chunk-J6JOGFVB.js} +1 -1
- package/dist/standalone/{chunk-Y2I6GYEG.js → chunk-JM6U3CQE.js} +1 -1
- package/dist/standalone/{chunk-QWJQUQY3.js → chunk-JP6RVFCJ.js} +1 -1
- package/dist/standalone/{chunk-PGMASM2T.js → chunk-JYVJ2OWH.js} +1 -1
- package/dist/standalone/{chunk-DI34YDBW.js → chunk-LP7ELDUL.js} +1 -1
- package/dist/standalone/{chunk-L2CWAQUO.js → chunk-M3ANC2JI.js} +1 -1
- package/dist/standalone/{chunk-PZVVEPIN.js → chunk-MKRJGSYF.js} +1 -1
- package/dist/standalone/{chunk-URBHAYYZ.js → chunk-MWSNVNHE.js} +1 -1
- package/dist/standalone/{chunk-E2X625P3.js → chunk-N6LSV246.js} +1 -1
- package/dist/standalone/{chunk-RM4TNBYG.js → chunk-NRZ5MBPS.js} +1 -1
- package/dist/standalone/{chunk-4PRXEO3C.js → chunk-O337Z6XI.js} +1 -1
- package/dist/standalone/{chunk-WRZTTZFV.js → chunk-PVAE535J.js} +1 -1
- package/dist/standalone/{chunk-AFSPF2R4.js → chunk-PVV6LALL.js} +1 -1
- package/dist/standalone/{chunk-GZ6GAFM2.js → chunk-QZHPUFML.js} +1 -1
- package/dist/standalone/{chunk-MH2NGGUC.js → chunk-SDBOAPOT.js} +1 -1
- package/dist/standalone/{chunk-HGT5U6GD.js → chunk-SGL3ZV4P.js} +1 -1
- package/dist/standalone/{chunk-INXSZE5I.js → chunk-T57JAZCX.js} +1 -1
- package/dist/standalone/{chunk-WIXX2VWE.js → chunk-UZHJM2CX.js} +1 -1
- package/dist/standalone/{chunk-GP2GJRJ3.js → chunk-VCOPIBKL.js} +1 -1
- package/dist/standalone/{chunk-V7G6YTQ5.js → chunk-VG34EBBT.js} +1 -1
- package/dist/standalone/{chunk-QDHXQ56K.js → chunk-VICAUTXQ.js} +1 -1
- package/dist/standalone/{chunk-WD4WHTAV.js → chunk-WDJ4CHIO.js} +1 -1
- package/dist/standalone/{chunk-EBU3TTYR.js → chunk-XBKABVCJ.js} +1 -1
- package/dist/standalone/{chunk-G2XTVB6Q.js → chunk-Y6SKU4M7.js} +1 -1
- package/dist/standalone/{chunk-5B6TTEP6.js → chunk-YBZYUPAG.js} +1 -1
- package/dist/standalone/{chunk-Z2XS4ZOO.js → chunk-Z2CLSELV.js} +1 -1
- package/dist/standalone/{chunk-J3LCGEBD.js → chunk-ZGMGMEFM.js} +1 -1
- package/dist/standalone/{chunk-TXHTSFLO.js → chunk-ZWJGQACG.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/standalone/chunk-A7EWHGFT.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as C}from"react/compiler-runtime";import{useMemo as T,useState as W}from"react";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as j}from"../packem_shared/utils-bhneXptQ.mjs";import{MigrationsPanel as _}from"../packem_shared/MigrationsPanel-BPWzFdxC.mjs";import{useNavigate as B,useSearch as z}from"@tanstack/react-router";import{E as X}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{E as Y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as I}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{ADMIN_FUNCTIONS as M}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as Z,f as ee}from"../packem_shared/internal-B6haJbiP.mjs";import{S as te}from"../packem_shared/schema-diagram-CDj_69jF.mjs";import{jsx as c,jsxs as v}from"react/jsx-runtime";const R=1;function ne(t){const e={},s=Object.keys(t);s.sort();for(const n of s)e[n]=t[n];return e}const w=t=>typeof t=="object"&&t!==null,se=t=>w(t)&&w(t.fields)&&w(t.indexes)&&w(t.relations)&&typeof t.shardMode=="string",ie=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(n){return{error:`baseline is not valid JSON: ${n instanceof Error?n.message:String(n)}`,status:"invalid"}}if(!w(e)||e.version!==R||!w(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(R)})`,status:"invalid"};for(const[n,i]of Object.entries(e.tables))if(!se(i))return{error:`baseline table "${n}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:R},status:"ok"}},ae=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((s,n)=>s===e.fields[n]),J=t=>t.unique!==void 0,A=({nullable:t,optional:e,refined:s,unique:n,...i})=>JSON.stringify(ne(i)),P=t=>({form:JSON.stringify([A(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),V=t=>t.kind==="union"&&t.members?t.members.map(e=>P(e)):[P({...t,nullable:!1,optional:!1})],oe=(t,e)=>{if(e.kind!=="union")return!1;const s=V(e);return V(t).every(n=>s.some(i=>i.form===n.form&&(n.refined||!i.refined)))},y=t=>{switch(t.kind){case"array":return`array(${t.of?y(t.of):"?"})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?y(t.key):"?"}, ${t.of?y(t.of):"?"})`;case"union":return(t.members??[]).map(e=>y(e)).join(" | ");default:return t.kind}},O=(t,e,s)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:s,table:t,type:e}),F=(t,e,s)=>({remediation:"none",scope:"table",severity:"safe",summary:s,table:t,type:e}),re=(t,e,s,n,i)=>{if(!(s.kind===n.kind&&(!i||A(s)===A(n))))return i&&oe(s,n)?F(t,"widenedFieldShape",`field ${t}.${e} widened: ${y(s)} → ${y(n)} — every stored value stays valid`):s.kind!==n.kind?O(t,"changedFieldKind",`field ${t}.${e} changed type: ${s.kind} → ${n.kind} — add a data migration to convert existing values`):O(t,"changedFieldShape",`field ${t}.${e} changed shape: ${y(s)} → ${y(n)} — stored values were written against the old shape; add a data migration to convert them`)},de=(t,e,s,n)=>{const i=[];return s.unique!==n.unique&&i.push(n.unique===!0?O(t,"addedFieldConstraint",`field ${t}.${e} became unique — existing duplicates would violate it; add a data migration to de-duplicate first`):F(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),s.nullable!==n.nullable&&i.push(n.nullable===!0?F(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):O(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable — rows holding NULL would be invalid; add a data migration to backfill them`)),s.refined!==n.refined&&i.push(n.refined===!0?O(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement — stored values were never checked against it; add a data migration if any could fail`):F(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),i},K=(t,e,s,n)=>{const i=[],o=J(s)&&J(n),a=re(t,e,s,n,o);return a&&i.push(a),o&&i.push(...de(t,e,s,n)),s.optional&&!n.optional?i.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required — rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!s.optional&&n.optional&&i.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),i},le=(t,e,s)=>s.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} — existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},ce=(t,e,s,n)=>{for(const[i,o]of Object.entries(s.fields)){const a=e.fields[i];a===void 0?n.push(le(t,i,o)):n.push(...K(t,i,a,o))}for(const i of Object.keys(e.fields))s.fields[i]===void 0&&n.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${i} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},ue=(t,e,s,n)=>{for(const[i,o]of Object.entries(s.indexes)){const a=e.indexes[i];if(a===void 0){n.push({remediation:"none",scope:"table",severity:"safe",summary:`added index ${i} on ${t}`,table:t,type:"addedIndex"});continue}ae(a,o)||n.push({remediation:"code",severity:"breaking",summary:`index ${i} on ${t} changed shape — a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(const i of Object.keys(e.indexes))s.indexes[i]===void 0&&n.push({remediation:"code",severity:"breaking",summary:`removed index ${i} on ${t} — a query that used \`.withIndex("${i}")\` would break`,table:t,scope:"table",type:"removedIndex"})},me=(t,e,s,n)=>{for(const i of Object.keys(s.relations))e.relations[i]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${i}`,table:t,type:"addedRelation"});for(const i of Object.keys(e.relations))s.relations[i]===void 0&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${i}`,table:t,type:"removedRelation"})},fe=(t,e,s,n)=>{e.shardMode!==s.shardMode&&n.push({remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e.shardMode} → ${s.shardMode} — its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}),ce(t,e,s,n),ue(t,e,s,n),me(t,e,s,n)},he=(t,e)=>{const s=[],n=t?.tables??{};for(const[i,o]of Object.entries(e.tables)){const a=n[i];if(a===void 0){s.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${i}`,table:i,type:"addedTable"});continue}fe(i,a,o,s)}for(const i of Object.keys(n))e.tables[i]===void 0&&s.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${i} — its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:i,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const i=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";s.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${i} to ${o} — this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:s}},H=t=>Object.entries(t.fields).map(([e,s])=>({name:e,optional:s.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:y(s)})),Q=(t,e,s)=>{const n={},i=e?.fields??{},o=s?.fields??{};for(const[a,r]of Object.entries(o)){const d=i[a];d===void 0?n[a]=e===void 0?"unchanged":"added":n[a]=K(t,a,d,r).length===0?"unchanged":"changed"}for(const a of Object.keys(i))o[a]===void 0&&(n[a]="removed");return n},pe=(t,e)=>{const{changes:s}=he(t,e),n=new Set(s.filter(a=>a.scope==="table"&&a.table!==void 0).map(a=>a.table)),i=[],o=(a,r)=>a?"added":n.has(r)?"changed":"context";for(const[a,r]of Object.entries(e.tables)){const d=t?.tables[a],u=o(d===void 0,a);i.push({columns:H(r),fieldStatus:Q(a,d,r),name:a,shardMode:r.shardMode,status:u})}for(const[a,r]of Object.entries(t?.tables??{}))e.tables[a]===void 0&&i.push({columns:H(r),fieldStatus:Q(a,r,void 0),name:a,shardMode:r.shardMode,status:"removed"});return i.sort((a,r)=>a.name.localeCompare(r.name)),{breakingCount:s.filter(a=>a.severity==="breaking").length,changes:s,tables:i}},L=t=>{const e=ie(t);return e.status==="ok"?e.snapshot:void 0},ge={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},be=t=>t==="global"?"global":"shard",ve=t=>{const e=C(24),{appliedAt:s,hash:n,onSelect:i,selected:o,seq:a}=t,r=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let d;e[0]!==r?(d=j("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",r),e[0]=r,e[1]=d):d=e[1];const u=`sh-version-${n}`;let h;e[2]!==n||e[3]!==i?(h=()=>{i(n)},e[2]=n,e[3]=i,e[4]=h):h=e[4];let f;e[5]!==a?(f=v("span",{className:"font-mono text-[13px] tabular-nums",children:["v",a]}),e[5]=a,e[6]=f):f=e[6];let g;e[7]!==n?(g=n.slice(0,7),e[7]=n,e[8]=g):g=e[8];let p;e[9]!==g?(p=c("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:g}),e[9]=g,e[10]=p):p=e[10];let m;e[11]!==f||e[12]!==p?(m=v("span",{className:"flex w-full items-baseline gap-2",children:[f,p]}),e[11]=f,e[12]=p,e[13]=m):m=e[13];let b;e[14]!==s?(b=Z(s),e[14]=s,e[15]=b):b=e[15];let x;e[16]!==b?(x=c("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=x):x=e[17];let k;return e[18]!==x||e[19]!==d||e[20]!==u||e[21]!==h||e[22]!==m?(k=c("li",{children:v("button",{className:d,"data-testid":u,onClick:h,type:"button",children:[m,x]})}),e[18]=x,e[19]=d,e[20]=u,e[21]=h,e[22]=m,e[23]=k):k=e[23],k},xe=t=>{const e=C(26),{breaking:s,count:n,first:i}=t,o=E();if(i){let p;e[0]!==n?(p=c("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let m;e[2]!==o?(m=o("tables"),e[2]=o,e[3]=m):m=e[3];let b;e[4]!==m?(b=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:m}),e[4]=m,e[5]=b):b=e[5];let x;return e[6]!==p||e[7]!==b?(x=v("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=x):x=e[8],x}const a=s>0&&"text-destructive";let r;e[9]!==a?(r=j("text-3xl leading-none font-light tracking-tight tabular-nums",a),e[9]=a,e[10]=r):r=e[10];let d;e[11]!==n||e[12]!==r?(d=c("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=d):d=e[13];let u;e[14]!==n||e[15]!==o?(u=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=u):u=e[16];let h;e[17]!==u?(h=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:u}),e[17]=u,e[18]=h):h=e[18];let f;e[19]!==s||e[20]!==o?(f=s>0&&v("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",o("{count} breaking",{count:s})]}),e[19]=s,e[20]=o,e[21]=f):f=e[21];let g;return e[22]!==d||e[23]!==h||e[24]!==f?(g=v("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[d,h,f]}),e[22]=d,e[23]=h,e[24]=f,e[25]=g):g=e[25],g},U={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field → wider"}},ye=(t,e)=>{const s=`${U[t.type].action} ${e} `;return t.summary.startsWith(s)?t.summary.slice(s.length):t.summary},ke=t=>{const e=new Map;for(const n of t){const i=n.table??"",o=e.get(i);o===void 0?e.set(i,[n]):o.push(n)}const s=[...e].map(([n,i])=>({changes:i,table:n}));return[...s.filter(n=>n.table!==""),...s.filter(n=>n.table==="")]},$e=t=>{const e=C(2),{children:s}=t;let n;return e[0]!==s?(n=c("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:s}),e[0]=s,e[1]=n):n=e[1],n},we=({pane:t,shardKey:e=""})=>{const s=E(),n=B(),o=z({strict:!1}).version,a=l=>{ee(n({search:{version:l},to:"/migrations"}))},r=I(M.schemaHistory,{},{shardKey:e}),d=r.data?.versions??[],u=o!==void 0&&d.some(l=>l.hash===o)?o:d[0]?.hash,h=d.findIndex(l=>l.hash===u),f=h===-1?void 0:d[h+1]?.hash,g=I(M.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=I(M.schemaVersion,{hash:f??""},{enabled:f!==void 0,shardKey:e}),m=T(()=>{const l=L(g.data?.version?.snapshotJson);if(l!==void 0)return pe(L(p.data?.version?.snapshotJson),l)},[g.data,p.data]),b=T(()=>(m?.tables??[]).map(l=>({columns:l.columns,name:l.name,tier:be(l.shardMode)})),[m]),x=T(()=>{const l={};for(const S of m?.tables??[])l[S.name]=ge[S.status];return l},[m]);if(r.error!==null)return c(X,{error:r.errorSource,testId:"sh-error"});if(d.length===0)return c(Y,{description:s("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:s("No schema versions recorded yet.")});const k=m?.changes??[];return v("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[v("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[c($e,{children:s("Schema versions")}),c("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(l=>c(ve,{appliedAt:l.appliedAt,hash:l.hash,onSelect:a,selected:l.hash===u,seq:l.seq},l.hash))})]}),v("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[c(xe,{breaking:m?.breakingCount??0,count:f===void 0?b.length:k.length,first:f===void 0}),t==="diagram"?c("div",{className:"flex min-h-0 flex-1 flex-col",children:c(te,{fill:!0,nodeClasses:x,tables:b,testIdPrefix:"sh"})}):c("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ke(k).map(l=>{const S=(m?.tables??[]).find($=>$.name===l.table);return v("section",{className:"mb-6",children:[v("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[c("span",{className:"font-mono text-[13px] text-foreground",children:l.table===""?s("schema"):l.table}),S!==void 0&&c("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:s("{count} columns",{count:S.columns.length})}),l.changes.length>1&&c("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:l.changes.length})]}),c("ul",{children:l.changes.map($=>{const{action:G,kind:N}=U[$.type],q=$.severity==="breaking",D=ye($,N);return v("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[c("span",{"aria-hidden":"true",className:j("-ms-3 h-3 w-0.5 shrink-0 self-center",q?"bg-destructive":"bg-transparent")}),v("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[s(G)," ",N]}),D!==l.table&&c("span",{className:j("min-w-0 font-mono text-[13px]",q?"text-destructive":"text-foreground"),children:D}),q&&c("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:s("breaking")})]},`${$.type}-${$.summary}`)})})]},l.table)})})]})]})},Se=t=>j("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Je=t=>{const e=C(11),{initialShardKey:s}=t,n=E(),[i,o]=W("diagram");let a;e[0]!==i?(a=(f,g,p,m)=>v("button",{"aria-selected":i===f,className:Se(i===f),"data-testid":p,onClick:()=>{o(f)},role:"tab",type:"button",children:[g,m!==void 0&&c("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:m})]}),e[0]=i,e[1]=a):a=e[1];const r=a;let d;e[2]!==n||e[3]!==r?(d=v("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[r("diagram",n("Diagram"),"mg-pane-diagram"),r("changes",n("Changes"),"mg-pane-changes"),r("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=r,e[4]=d):d=e[4];let u;e[5]!==s||e[6]!==i?(u=c("div",{className:"flex min-h-0 flex-1 flex-col",children:i==="data"?c("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:c(_,{initialShardKey:s})}):c(we,{pane:i,shardKey:s})}),e[5]=s,e[6]=i,e[7]=u):u=e[7];let h;return e[8]!==d||e[9]!==u?(h=v("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[d,u]}),e[8]=d,e[9]=u,e[10]=h):h=e[10],h};export{Je as default};
|
|
1
|
+
import{c as q}from"react/compiler-runtime";import{useMemo as T,useState as W}from"react";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as j}from"../packem_shared/utils-bhneXptQ.mjs";import{MigrationsPanel as _}from"../packem_shared/MigrationsPanel-BPWzFdxC.mjs";import{useNavigate as B,useSearch as z}from"@tanstack/react-router";import{E as X}from"../packem_shared/error-alert-tf5zvSLV.mjs";import{E as Y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as I}from"../packem_shared/use-admin-query-BKXiqLci.mjs";import{ADMIN_FUNCTIONS as M}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as Z,f as ee}from"../packem_shared/internal-B6haJbiP.mjs";import{S as te}from"../packem_shared/schema-diagram-CDj_69jF.mjs";import{jsx as c,jsxs as v}from"react/jsx-runtime";const R=1;function ne(t){const e={},i=Object.keys(t);i.sort();for(const n of i)e[n]=t[n];return e}const w=t=>typeof t=="object"&&t!==null,ie=t=>w(t)&&w(t.fields)&&w(t.indexes)&&w(t.relations)&&typeof t.shardMode=="string",se=t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(n){return{error:`baseline is not valid JSON: ${n instanceof Error?n.message:String(n)}`,status:"invalid"}}if(!w(e)||e.version!==R||!w(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(R)})`,status:"invalid"};for(const[n,s]of Object.entries(e.tables))if(!ie(s))return{error:`baseline table "${n}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:R},status:"ok"}},ae=(t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((i,n)=>i===e.fields[n]),J=t=>t.unique!==void 0,A=({nullable:t,optional:e,refined:i,unique:n,...s})=>JSON.stringify(ne(s)),P=t=>({form:JSON.stringify([A(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),V=t=>t.kind==="union"&&t.members?t.members.map(e=>P(e)):[P({...t,nullable:!1,optional:!1})],oe=(t,e)=>{if(e.kind!=="union")return!1;const i=V(e);return V(t).every(n=>i.some(s=>s.form===n.form&&(n.refined||!s.refined)))},y=t=>{switch(t.kind){case"array":return`array(${t.of?y(t.of):"?"})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?y(t.key):"?"}, ${t.of?y(t.of):"?"})`;case"union":return(t.members??[]).map(e=>y(e)).join(" | ");default:return t.kind}},O=(t,e,i)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:i,table:t,type:e}),F=(t,e,i)=>({remediation:"none",scope:"table",severity:"safe",summary:i,table:t,type:e}),re=(t,e,i,n,s)=>{if(!(i.kind===n.kind&&(!s||A(i)===A(n))))return s&&oe(i,n)?F(t,"widenedFieldShape",`field ${t}.${e} widened: ${y(i)} → ${y(n)} — every stored value stays valid`):i.kind!==n.kind?O(t,"changedFieldKind",`field ${t}.${e} changed type: ${i.kind} → ${n.kind} — add a data migration to convert existing values`):O(t,"changedFieldShape",`field ${t}.${e} changed shape: ${y(i)} → ${y(n)} — stored values were written against the old shape; add a data migration to convert them`)},de=(t,e,i,n)=>{const s=[];return i.unique!==n.unique&&s.push(n.unique===!0?O(t,"addedFieldConstraint",`field ${t}.${e} became unique — existing duplicates would violate it; add a data migration to de-duplicate first`):F(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),i.nullable!==n.nullable&&s.push(n.nullable===!0?F(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):O(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable — rows holding NULL would be invalid; add a data migration to backfill them`)),i.refined!==n.refined&&s.push(n.refined===!0?O(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement — stored values were never checked against it; add a data migration if any could fail`):F(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),s},K=(t,e,i,n)=>{const s=[],o=J(i)&&J(n),a=re(t,e,i,n,o);return a&&s.push(a),o&&s.push(...de(t,e,i,n)),i.optional&&!n.optional?s.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required — rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!i.optional&&n.optional&&s.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),s},le=(t,e,i)=>i.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} — existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},ce=(t,e,i,n)=>{for(const[s,o]of Object.entries(i.fields)){const a=e.fields[s];a===void 0?n.push(le(t,s,o)):n.push(...K(t,s,a,o))}for(const s of Object.keys(e.fields))i.fields[s]===void 0&&n.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${s} — add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},ue=(t,e,i,n)=>{for(const[s,o]of Object.entries(i.indexes)){const a=e.indexes[s];if(a===void 0){n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${s} on ${t} — existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${s} on ${t}`,table:t,type:"addedIndex"});continue}ae(a,o)||n.push({remediation:"code",severity:"breaking",summary:`index ${s} on ${t} changed shape — a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(const s of Object.keys(e.indexes))i.indexes[s]===void 0&&n.push({remediation:"code",severity:"breaking",summary:`removed index ${s} on ${t} — a query that used \`.withIndex("${s}")\` would break`,table:t,scope:"table",type:"removedIndex"})},me=(t,e,i,n)=>{for(const s of Object.keys(i.relations))e.relations[s]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${s}`,table:t,type:"addedRelation"});for(const s of Object.keys(e.relations))i.relations[s]===void 0&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${s}`,table:t,type:"removedRelation"})},fe=(t,e,i,n)=>{e.shardMode!==i.shardMode&&n.push({remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e.shardMode} → ${i.shardMode} — its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}),ce(t,e,i,n),ue(t,e,i,n),me(t,e,i,n)},he=(t,e)=>{const i=[],n=t?.tables??{};for(const[s,o]of Object.entries(e.tables)){const a=n[s];if(a===void 0){i.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${s}`,table:s,type:"addedTable"});continue}fe(s,a,o,i)}for(const s of Object.keys(n))e.tables[s]===void 0&&i.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${s} — its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:s,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){const s=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";i.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${s} to ${o} — this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:i}},H=t=>Object.entries(t.fields).map(([e,i])=>({name:e,optional:i.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:y(i)})),Q=(t,e,i)=>{const n={},s=e?.fields??{},o=i?.fields??{};for(const[a,r]of Object.entries(o)){const d=s[a];d===void 0?n[a]=e===void 0?"unchanged":"added":n[a]=K(t,a,d,r).length===0?"unchanged":"changed"}for(const a of Object.keys(s))o[a]===void 0&&(n[a]="removed");return n},pe=(t,e)=>{const{changes:i}=he(t,e),n=new Set(i.filter(a=>a.scope==="table"&&a.table!==void 0).map(a=>a.table)),s=[],o=(a,r)=>a?"added":n.has(r)?"changed":"context";for(const[a,r]of Object.entries(e.tables)){const d=t?.tables[a],u=o(d===void 0,a);s.push({columns:H(r),fieldStatus:Q(a,d,r),name:a,shardMode:r.shardMode,status:u})}for(const[a,r]of Object.entries(t?.tables??{}))e.tables[a]===void 0&&s.push({columns:H(r),fieldStatus:Q(a,r,void 0),name:a,shardMode:r.shardMode,status:"removed"});return s.sort((a,r)=>a.name.localeCompare(r.name)),{breakingCount:i.filter(a=>a.severity==="breaking").length,changes:i,tables:s}},L=t=>{const e=se(t);return e.status==="ok"?e.snapshot:void 0},ge={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},be=t=>t==="global"?"global":"shard",ve=t=>{const e=q(24),{appliedAt:i,hash:n,onSelect:s,selected:o,seq:a}=t,r=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground";let d;e[0]!==r?(d=j("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",r),e[0]=r,e[1]=d):d=e[1];const u=`sh-version-${n}`;let h;e[2]!==n||e[3]!==s?(h=()=>{s(n)},e[2]=n,e[3]=s,e[4]=h):h=e[4];let f;e[5]!==a?(f=v("span",{className:"font-mono text-[13px] tabular-nums",children:["v",a]}),e[5]=a,e[6]=f):f=e[6];let g;e[7]!==n?(g=n.slice(0,7),e[7]=n,e[8]=g):g=e[8];let p;e[9]!==g?(p=c("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:g}),e[9]=g,e[10]=p):p=e[10];let m;e[11]!==f||e[12]!==p?(m=v("span",{className:"flex w-full items-baseline gap-2",children:[f,p]}),e[11]=f,e[12]=p,e[13]=m):m=e[13];let b;e[14]!==i?(b=Z(i),e[14]=i,e[15]=b):b=e[15];let x;e[16]!==b?(x=c("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=x):x=e[17];let k;return e[18]!==x||e[19]!==d||e[20]!==u||e[21]!==h||e[22]!==m?(k=c("li",{children:v("button",{className:d,"data-testid":u,onClick:h,type:"button",children:[m,x]})}),e[18]=x,e[19]=d,e[20]=u,e[21]=h,e[22]=m,e[23]=k):k=e[23],k},xe=t=>{const e=q(26),{breaking:i,count:n,first:s}=t,o=E();if(s){let p;e[0]!==n?(p=c("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let m;e[2]!==o?(m=o("tables"),e[2]=o,e[3]=m):m=e[3];let b;e[4]!==m?(b=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:m}),e[4]=m,e[5]=b):b=e[5];let x;return e[6]!==p||e[7]!==b?(x=v("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=x):x=e[8],x}const a=i>0&&"text-destructive";let r;e[9]!==a?(r=j("text-3xl leading-none font-light tracking-tight tabular-nums",a),e[9]=a,e[10]=r):r=e[10];let d;e[11]!==n||e[12]!==r?(d=c("span",{className:r,children:n}),e[11]=n,e[12]=r,e[13]=d):d=e[13];let u;e[14]!==n||e[15]!==o?(u=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=u):u=e[16];let h;e[17]!==u?(h=c("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:u}),e[17]=u,e[18]=h):h=e[18];let f;e[19]!==i||e[20]!==o?(f=i>0&&v("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["· ",o("{count} breaking",{count:i})]}),e[19]=i,e[20]=o,e[21]=f):f=e[21];let g;return e[22]!==d||e[23]!==h||e[24]!==f?(g=v("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[d,h,f]}),e[22]=d,e[23]=h,e[24]=f,e[25]=g):g=e[25],g},U={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field → required"},fieldRequiredToOptional:{action:"changed",kind:"field → optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field → wider"}},ye=(t,e)=>{const i=`${U[t.type].action} ${e} `;return t.summary.startsWith(i)?t.summary.slice(i.length):t.summary},ke=t=>{const e=new Map;for(const n of t){const s=n.table??"",o=e.get(s);o===void 0?e.set(s,[n]):o.push(n)}const i=[...e].map(([n,s])=>({changes:s,table:n}));return[...i.filter(n=>n.table!==""),...i.filter(n=>n.table==="")]},$e=t=>{const e=q(2),{children:i}=t;let n;return e[0]!==i?(n=c("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:i}),e[0]=i,e[1]=n):n=e[1],n},we=({pane:t,shardKey:e=""})=>{const i=E(),n=B(),o=z({strict:!1}).version,a=l=>{ee(n({search:{version:l},to:"/migrations"}))},r=I(M.schemaHistory,{},{shardKey:e}),d=r.data?.versions??[],u=o!==void 0&&d.some(l=>l.hash===o)?o:d[0]?.hash,h=d.findIndex(l=>l.hash===u),f=h===-1?void 0:d[h+1]?.hash,g=I(M.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=I(M.schemaVersion,{hash:f??""},{enabled:f!==void 0,shardKey:e}),m=T(()=>{const l=L(g.data?.version?.snapshotJson);if(l!==void 0)return pe(L(p.data?.version?.snapshotJson),l)},[g.data,p.data]),b=T(()=>(m?.tables??[]).map(l=>({columns:l.columns,name:l.name,tier:be(l.shardMode)})),[m]),x=T(()=>{const l={};for(const S of m?.tables??[])l[S.name]=ge[S.status];return l},[m]);if(r.error!==null)return c(X,{error:r.errorSource,testId:"sh-error"});if(d.length===0)return c(Y,{description:i("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:i("No schema versions recorded yet.")});const k=m?.changes??[];return v("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[v("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[c($e,{children:i("Schema versions")}),c("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(l=>c(ve,{appliedAt:l.appliedAt,hash:l.hash,onSelect:a,selected:l.hash===u,seq:l.seq},l.hash))})]}),v("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[c(xe,{breaking:m?.breakingCount??0,count:f===void 0?b.length:k.length,first:f===void 0}),t==="diagram"?c("div",{className:"flex min-h-0 flex-1 flex-col",children:c(te,{fill:!0,nodeClasses:x,tables:b,testIdPrefix:"sh"})}):c("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ke(k).map(l=>{const S=(m?.tables??[]).find($=>$.name===l.table);return v("section",{className:"mb-6",children:[v("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[c("span",{className:"font-mono text-[13px] text-foreground",children:l.table===""?i("schema"):l.table}),S!==void 0&&c("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:i("{count} columns",{count:S.columns.length})}),l.changes.length>1&&c("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:l.changes.length})]}),c("ul",{children:l.changes.map($=>{const{action:G,kind:N}=U[$.type],C=$.severity==="breaking",D=ye($,N);return v("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[c("span",{"aria-hidden":"true",className:j("-ms-3 h-3 w-0.5 shrink-0 self-center",C?"bg-destructive":"bg-transparent")}),v("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[i(G)," ",N]}),D!==l.table&&c("span",{className:j("min-w-0 font-mono text-[13px]",C?"text-destructive":"text-foreground"),children:D}),C&&c("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:i("breaking")})]},`${$.type}-${$.summary}`)})})]},l.table)})})]})]})},Se=t=>j("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Je=t=>{const e=q(11),{initialShardKey:i}=t,n=E(),[s,o]=W("diagram");let a;e[0]!==s?(a=(f,g,p,m)=>v("button",{"aria-selected":s===f,className:Se(s===f),"data-testid":p,onClick:()=>{o(f)},role:"tab",type:"button",children:[g,m!==void 0&&c("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:m})]}),e[0]=s,e[1]=a):a=e[1];const r=a;let d;e[2]!==n||e[3]!==r?(d=v("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[r("diagram",n("Diagram"),"mg-pane-diagram"),r("changes",n("Changes"),"mg-pane-changes"),r("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=r,e[4]=d):d=e[4];let u;e[5]!==i||e[6]!==s?(u=c("div",{className:"flex min-h-0 flex-1 flex-col",children:s==="data"?c("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:c(_,{initialShardKey:i})}):c(we,{pane:s,shardKey:i})}),e[5]=i,e[6]=s,e[7]=u):u=e[7];let h;return e[8]!==d||e[9]!==u?(h=v("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[d,u]}),e[8]=d,e[9]=u,e[10]=h):h=e[10],h};export{Je as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ge,b as fe,c as xe,d as Ne,e as Ce}from"./chunk-IHMGCHAA.js";import"./chunk-4JLGLPWV.js";import"./chunk-V3CZW3JB.js";import{a as ce}from"./chunk-EA2JKR5D.js";import{a as ue}from"./chunk-3FBLWUXD.js";import{a as q}from"./chunk-IMOHEGMV.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-G2XTVB6Q.js";import"./chunk-Q4CAKBWN.js";import"./chunk-AULH6SZB.js";import"./chunk-RLLKECZT.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5WJXVZMZ.js";import"./chunk-EVTM6Q43.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as $}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as he}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import"./chunk-4ZEL6BYL.js";import"./chunk-SDHFSBNM.js";import{f as G}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as ke}from"./chunk-FKVZRPV5.js";import{a as ie,b as se,c as oe,d as Q,e as X,f as Y}from"./chunk-HEAQVSNS.js";import{a as re,e as ne}from"./chunk-WUWBZPUK.js";import{d as R,h as Z,l as be,o as z,q as de}from"./chunk-FODLDLE2.js";import{a as s,d as le,e as Oe,f as _e,g as De}from"./chunk-YKXDMIHQ.js";var P=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Be=s(l=>{let e=l.trim();if(e==="")return;let d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},"Be"),Le=s(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"Oe"),Je=s(l=>new TextEncoder().encode(l).length,"Ae"),Fe=s(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"ge"),Ke=s(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],we=s((l,e)=>{let d=l.trim();if(d==="")return"";let u=Number(d),i=Ee.find(v=>v.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*i)):d},"ue"),Ve=s(l=>{let e=l.trim();if(e==="")return!0;let d=Number(e);return Number.isInteger(d)&&d>=60},"Ce"),Te=s((l,e,d,u)=>{let i=Be(l.ttl);return{expiration:i===void 0?u:void 0,expirationTtl:i,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:d,value:l.value}},"Se"),Me=s(l=>{let e=(0,ee.c)(60),{helper:d,id:u,invalid:i,onChange:v,testId:o}=l,t=R(),[r,p]=(0,P.useState)(""),[c,x]=(0,P.useState)("seconds"),g;e[0]!==v||e[1]!==c?(g=s(f=>{p(f.target.value),v(we(f.target.value,c))},"k"),e[0]=v,e[1]=c,e[2]=g):g=e[2];let O=g,V;e[3]!==r||e[4]!==v?(V=s(f=>{f!==null&&(x(f),v(we(r,f)))},"K"),e[3]=r,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 C;e[14]!==y||e[15]!==m||e[16]!==h||e[17]!==N?(C={days:y,hours:m,minutes:h,seconds:N},e[14]=y,e[15]=m,e[16]=h,e[17]=N,e[18]=C):C=e[18];let w=C,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 B;e[26]!==r||e[27]!==u||e[28]!==i||e[29]!==O||e[30]!==E||e[31]!==o?(B=(0,a.jsx)(ae,{"aria-invalid":i,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:O,placeholder:E,value:r}),e[26]=r,e[27]=u,e[28]=i,e[29]=O,e[30]=E,e[31]=o,e[32]=B):B=e[32];let T;e[33]!==t?(T=t("TTL unit"),e[33]=t,e[34]=T):T=e[34];let J=`${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]!==J?(M=(0,a.jsx)(xe,{"aria-label":T,className:"w-[7.5rem]","data-testid":J,children:L}),e[36]=T,e[37]=J,e[38]=M):M=e[38];let n;e[39]!==w?(n=Ee.map(f=>(0,a.jsx)(Ce,{value:f.key,children:w[f.key]},f.key)),e[39]=w,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]!==B||e[49]!==F?(I=(0,a.jsxs)("div",{className:"flex gap-2",children:[B,F]}),e[48]=B,e[49]=F,e[50]=I):I=e[50];let K;e[51]!==d||e[52]!==i||e[53]!==t||e[54]!==o?(K=i?(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]=i,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},"we"),Ie=s(l=>{let e=(0,ee.c)(36),{id:d,invalidTestId:u,onChange:i,testId:v,valid:o,value:t}=l,r=R(),p;e[0]!==t?(p=Fe(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,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]!==i?(_=s(()=>{c!==void 0&&i(c)},"L"),e[7]=c,e[8]=i,e[9]=_):_=e[9];let y;e[10]!==r?(y=r("Format JSON"),e[10]=r,e[11]=y):y=e[11];let m;e[12]!==O||e[13]!==V||e[14]!==_||e[15]!==y?(m=(0,a.jsx)($,{"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,C;e[20]!==i?(C=s(E=>{i(E.target.value)},"N"),e[20]=i,e[21]=C):C=e[21];let w;e[22]!==d||e[23]!==N||e[24]!==C||e[25]!==v||e[26]!==t?(w=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":v,id:d,onChange:C,value:t}),e[22]=d,e[23]=N,e[24]=C,e[25]=v,e[26]=t,e[27]=w):w=e[27];let b;e[28]!==u||e[29]!==r||e[30]!==o?(b=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:r("Metadata must be valid JSON.")}),e[28]=u,e[29]=r,e[30]=o,e[31]=b):b=e[31];let S;return e[32]!==w||e[33]!==b||e[34]!==h?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[h,w,b]}),e[32]=w,e[33]=b,e[34]=h,e[35]=S):S=e[35],S},"Te"),Pe={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},$e=s((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Je"),je=s(l=>{let e=(0,ee.c)(73),{namespace:d,onCancel:u,onCreated:i}=l,v=G(),o=R(),[t,r]=(0,P.useReducer)($e,Pe),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]!==i||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(_=s(()=>{V&&(r({type:"submitStart"}),z((async()=>{try{await v.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),i()}catch(A){r({error:Z(A),type:"submitFailed"})}})()))},"L"),e[9]=V,e[10]=v,e[11]=d,e[12]=i,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=s(A=>{r({field:"name",type:"setField",value:A.target.value})},"x"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let w;e[25]!==t.name||e[26]!==C?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name}),e[25]=t.name,e[26]=C,e[27]=w):w=e[27];let b;e[28]!==h||e[29]!==w?(b=(0,a.jsxs)("div",{className:"grid gap-1",children:[h,w]}),e[28]=h,e[29]=w,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 B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=s(A=>{r({field:"value",type:"setField",value:A.target.value})},"O"),e[35]=B):B=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:B,value:t.value}),e[36]=t.value,e[37]=T):T=e[37];let J;e[38]!==E||e[39]!==T?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,T]}),e[38]=E,e[39]=T,e[40]=J):J=e[40];let L=!g,M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{r({field:"ttl",type:"setField",value:A})},"I"),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=s(A=>{r({field:"metadata",type:"setField",value:A})},"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)($,{"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)($,{"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]!==J||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,J,n,F,U,W]}),e[66]=b,e[67]=J,e[68]=n,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),Ae={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},ze=s((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,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{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"je"),He=s(l=>{let e=(0,ee.c)(67),{expiration:d,keyName:u,namespace:i,onDeleted:v}=l,o=G(),t=R(),[r,p]=(0,P.useReducer)(ze,Ae),c,x;e[0]!==o||e[1]!==u||e[2]!==i?(c=s(()=>{let f={cancelled:!1};return z((async()=>{try{let j=await o.getKvValue({key:u,namespace:i});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,i,u],e[0]=o,e[1]=u,e[2]=i,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,P.useEffect)(c,x);let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=s(f=>{p({type:"editValue",value:f.target.value})},"k"),e[5]=g):g=e[5];let O=g,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=s(f=>{p({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let _=V,y;e[7]!==r.editedValue?(y=Fe(r.editedValue),e[7]=r.editedValue,e[8]=y):y=e[8];let m=y,h;e[9]!==r.editedMetadata?(h=Ke(r.editedMetadata),e[9]=r.editedMetadata,e[10]=h):h=e[10];let N=h,C;e[11]!==r.editedTtl?(C=Ve(r.editedTtl),e[11]=r.editedTtl,e[12]=C):C=e[12];let w=C,b;e[13]!==m?(b=s(()=>{m!==void 0&&p({type:"editValue",value:m})},"y"),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]!==i||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(E=s(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),z((async()=>{try{await o.putKvValue(Te({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},u,i,d)),p({type:"saveOk"})}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"F"),e[15]=o,e[16]=d,e[17]=u,e[18]=N,e[19]=i,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,T;e[25]!==o||e[26]!==u||e[27]!==i||e[28]!==v?(T=s(()=>{p({type:"deleteStart"}),z((async()=>{try{await o.deleteKvKey({key:u,namespace:i}),v(u)}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"V"),e[25]=o,e[26]=u,e[27]=i,e[28]=v,e[29]=T):T=e[29];let J=T,L;e[30]!==u?(L=s(()=>{de(u)},"A"),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)($,{"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]!==r.loadError?(k=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=k):k=e[38];let F;e[39]!==r.loading||e[40]!==t?(F=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=F):F=e[41];let I;e[42]!==m||e[43]!==N||e[44]!==J||e[45]!==S||e[46]!==B||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(I=!r.loading&&r.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(Je(r.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:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-format-btn",disabled:m===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)($,{"data-testid":"kv-copy-value-btn",onClick:s(()=>{de(r.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:!w,onChange:s(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:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!N||!w,onClick:B,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)($,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=m,e[43]=N,e[44]=J,e[45]=S,e[46]=B,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=I):I=e[55];let K;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(K=!r.loading&&r.value===null&&r.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]=r.loadError,e[57]=r.loading,e[58]=r.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},"He"),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=s((l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let d=new Set(e.deleted);return{...l,bulk:l.bulk.filter(u=>!d.has(u)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(u=>!d.has(u.name)),selectedKey:l.selectedKey!==null&&d.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(d=>d!==e.name),keys:l.keys===null?null:l.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(d=>d!==e.name):[...l.bulk,e.name]};default:return l}},"ze"),Ue=s(({namespace:l})=>{let e=G(),d=R(),[u,i]=(0,P.useReducer)(Re,Ze),{appliedPrefix:v,bulk:o,bulkBusy:t,bulkError:r,cursor:p,keys:c,listComplete:x,loadError:g,loading:O,prefixInput:V,reloadNonce:_,selectedKey:y}=u,[m,h]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n={cancelled:!1};return z((async()=>{i({type:"loadStart"});try{let k=await e.listKvKeys({limit:Se,namespace:l,prefix:v===""?void 0:v});n.cancelled||i({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){n.cancelled||i({error:Z(k),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,l,v,_]);let N=s(n=>{i({type:"prefixInput",value:n.target.value})},"x"),C=s(()=>{i({type:"applyFilter"})},"N"),w=s(n=>{i({name:n.currentTarget.dataset.key??null,type:"selectKey"})},"C"),b=s(()=>{p!==null&&(i({type:"loadStart"}),z((async()=>{try{let n=await e.listKvKeys({cursor:p,limit:Se,namespace:l,prefix:v===""?void 0:v});i({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){i({error:Z(n),type:"loadFailed"})}})()))},"y"),S=s(n=>{i({name:n,type:"keyDeleted"})},"S"),E=s(n=>{i({name:n,type:"toggleBulk"})},"F"),B=s(n=>{i({names:n&&c!==null?c.map(k=>k.name):[],type:"toggleAllBulk"})},"O"),T=s(()=>{if(o.length===0)return;let n=[...o];i({type:"bulkDeleteStart"}),z((async()=>{let k=await Promise.allSettled(n.map(K=>e.deleteKvKey({key:K,namespace:l}))),F=n.filter((K,D)=>k[D]?.status==="fulfilled"),I=n.length-F.length;i({deleted:F,error:I>0?d("Failed to delete {count} keys.",{count:I}):null,type:"bulkDeleted"})})())},"V"),J=s(()=>{h(!1),i({type:"reload"})},"D"),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)($,{"data-testid":"kv-filter-btn",disabled:O,onClick:C,children:d("Filter")}),(0,a.jsx)($,{"data-testid":"kv-new-key-btn",onClick:s(()=>{h(n=>!n)},"onClick"),variant:"outline",children:d("New key")}),o.length>0&&(0,a.jsx)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:T,variant:"destructive",children:t?d("Deleting\u2026"):d("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),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)(ie,{"data-testid":"kv-key-table",children:[(0,a.jsx)(se,{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:B})}),(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:w,children:[(0,a.jsx)(Y,{onClick:s(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:s(()=>{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)($,{"data-testid":"kv-load-more",disabled:O,onClick:b,variant:"outline",children:d(O?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:s(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:l,onCancel:s(()=>{h(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(me,{onOpenChange:s(n=>{n||i({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:l,onDeleted:S},`${l}:${y}`)]})})]})},"Ue"),st=s(({loadNamespaces:l}={})=>{let e=G(),d=R(),[u,i]=(0,P.useState)(null),[v,o]=(0,P.useState)(null),[t,r]=(0,P.useState)(null);(0,P.useEffect)(()=>{let c={cancelled:!1};return z((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();c.cancelled||(i(x),o(null),r(g=>g??x[0]?.binding??null))}catch(x){c.cancelled||(i(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,l]);let p=s(c=>{r(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)(ie,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(se,{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)]})},"ut");export{st as KvBrowser};
|
|
1
|
+
import{a as ge,b as fe,c as xe,d as Ne,e as Ce}from"./chunk-IHMGCHAA.js";import"./chunk-4JLGLPWV.js";import"./chunk-V3CZW3JB.js";import{a as ce}from"./chunk-EA2JKR5D.js";import{a as ue}from"./chunk-3FBLWUXD.js";import{a as q}from"./chunk-IMOHEGMV.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-Y6SKU4M7.js";import"./chunk-Q4CAKBWN.js";import"./chunk-75OWNJEY.js";import"./chunk-RLLKECZT.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5WJXVZMZ.js";import"./chunk-EVTM6Q43.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as $}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as he}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import"./chunk-4ZEL6BYL.js";import"./chunk-7TRN7FQ4.js";import{f as G}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as ke}from"./chunk-FKVZRPV5.js";import{a as ie,b as se,c as oe,d as Q,e as X,f as Y}from"./chunk-HEAQVSNS.js";import{a as re,e as ne}from"./chunk-WUWBZPUK.js";import{d as R,h as Z,l as be,o as z,q as de}from"./chunk-FODLDLE2.js";import{a as s,d as le,e as Oe,f as _e,g as De}from"./chunk-YKXDMIHQ.js";var P=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Be=s(l=>{let e=l.trim();if(e==="")return;let d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},"Be"),Le=s(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"Oe"),Je=s(l=>new TextEncoder().encode(l).length,"Ae"),Fe=s(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"ge"),Ke=s(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"xe"),Ee=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],we=s((l,e)=>{let d=l.trim();if(d==="")return"";let u=Number(d),i=Ee.find(v=>v.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*i)):d},"ue"),Ve=s(l=>{let e=l.trim();if(e==="")return!0;let d=Number(e);return Number.isInteger(d)&&d>=60},"Ce"),Te=s((l,e,d,u)=>{let i=Be(l.ttl);return{expiration:i===void 0?u:void 0,expirationTtl:i,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:d,value:l.value}},"Se"),Me=s(l=>{let e=(0,ee.c)(60),{helper:d,id:u,invalid:i,onChange:v,testId:o}=l,t=R(),[r,p]=(0,P.useState)(""),[c,x]=(0,P.useState)("seconds"),g;e[0]!==v||e[1]!==c?(g=s(f=>{p(f.target.value),v(we(f.target.value,c))},"k"),e[0]=v,e[1]=c,e[2]=g):g=e[2];let O=g,V;e[3]!==r||e[4]!==v?(V=s(f=>{f!==null&&(x(f),v(we(r,f)))},"K"),e[3]=r,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 C;e[14]!==y||e[15]!==m||e[16]!==h||e[17]!==N?(C={days:y,hours:m,minutes:h,seconds:N},e[14]=y,e[15]=m,e[16]=h,e[17]=N,e[18]=C):C=e[18];let w=C,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 B;e[26]!==r||e[27]!==u||e[28]!==i||e[29]!==O||e[30]!==E||e[31]!==o?(B=(0,a.jsx)(ae,{"aria-invalid":i,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:O,placeholder:E,value:r}),e[26]=r,e[27]=u,e[28]=i,e[29]=O,e[30]=E,e[31]=o,e[32]=B):B=e[32];let T;e[33]!==t?(T=t("TTL unit"),e[33]=t,e[34]=T):T=e[34];let J=`${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]!==J?(M=(0,a.jsx)(xe,{"aria-label":T,className:"w-[7.5rem]","data-testid":J,children:L}),e[36]=T,e[37]=J,e[38]=M):M=e[38];let n;e[39]!==w?(n=Ee.map(f=>(0,a.jsx)(Ce,{value:f.key,children:w[f.key]},f.key)),e[39]=w,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]!==B||e[49]!==F?(I=(0,a.jsxs)("div",{className:"flex gap-2",children:[B,F]}),e[48]=B,e[49]=F,e[50]=I):I=e[50];let K;e[51]!==d||e[52]!==i||e[53]!==t||e[54]!==o?(K=i?(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]=i,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},"we"),Ie=s(l=>{let e=(0,ee.c)(36),{id:d,invalidTestId:u,onChange:i,testId:v,valid:o,value:t}=l,r=R(),p;e[0]!==t?(p=Fe(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,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]!==i?(_=s(()=>{c!==void 0&&i(c)},"L"),e[7]=c,e[8]=i,e[9]=_):_=e[9];let y;e[10]!==r?(y=r("Format JSON"),e[10]=r,e[11]=y):y=e[11];let m;e[12]!==O||e[13]!==V||e[14]!==_||e[15]!==y?(m=(0,a.jsx)($,{"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,C;e[20]!==i?(C=s(E=>{i(E.target.value)},"N"),e[20]=i,e[21]=C):C=e[21];let w;e[22]!==d||e[23]!==N||e[24]!==C||e[25]!==v||e[26]!==t?(w=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":v,id:d,onChange:C,value:t}),e[22]=d,e[23]=N,e[24]=C,e[25]=v,e[26]=t,e[27]=w):w=e[27];let b;e[28]!==u||e[29]!==r||e[30]!==o?(b=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:r("Metadata must be valid JSON.")}),e[28]=u,e[29]=r,e[30]=o,e[31]=b):b=e[31];let S;return e[32]!==w||e[33]!==b||e[34]!==h?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[h,w,b]}),e[32]=w,e[33]=b,e[34]=h,e[35]=S):S=e[35],S},"Te"),Pe={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},$e=s((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Je"),je=s(l=>{let e=(0,ee.c)(73),{namespace:d,onCancel:u,onCreated:i}=l,v=G(),o=R(),[t,r]=(0,P.useReducer)($e,Pe),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]!==i||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(_=s(()=>{V&&(r({type:"submitStart"}),z((async()=>{try{await v.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),i()}catch(A){r({error:Z(A),type:"submitFailed"})}})()))},"L"),e[9]=V,e[10]=v,e[11]=d,e[12]=i,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=s(A=>{r({field:"name",type:"setField",value:A.target.value})},"x"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let w;e[25]!==t.name||e[26]!==C?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name}),e[25]=t.name,e[26]=C,e[27]=w):w=e[27];let b;e[28]!==h||e[29]!==w?(b=(0,a.jsxs)("div",{className:"grid gap-1",children:[h,w]}),e[28]=h,e[29]=w,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 B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=s(A=>{r({field:"value",type:"setField",value:A.target.value})},"O"),e[35]=B):B=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:B,value:t.value}),e[36]=t.value,e[37]=T):T=e[37];let J;e[38]!==E||e[39]!==T?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,T]}),e[38]=E,e[39]=T,e[40]=J):J=e[40];let L=!g,M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{r({field:"ttl",type:"setField",value:A})},"I"),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=s(A=>{r({field:"metadata",type:"setField",value:A})},"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)($,{"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)($,{"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]!==J||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,J,n,F,U,W]}),e[66]=b,e[67]=J,e[68]=n,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),Ae={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},ze=s((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,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{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"je"),He=s(l=>{let e=(0,ee.c)(67),{expiration:d,keyName:u,namespace:i,onDeleted:v}=l,o=G(),t=R(),[r,p]=(0,P.useReducer)(ze,Ae),c,x;e[0]!==o||e[1]!==u||e[2]!==i?(c=s(()=>{let f={cancelled:!1};return z((async()=>{try{let j=await o.getKvValue({key:u,namespace:i});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,i,u],e[0]=o,e[1]=u,e[2]=i,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,P.useEffect)(c,x);let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=s(f=>{p({type:"editValue",value:f.target.value})},"k"),e[5]=g):g=e[5];let O=g,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=s(f=>{p({type:"editMetadata",value:f})},"K"),e[6]=V):V=e[6];let _=V,y;e[7]!==r.editedValue?(y=Fe(r.editedValue),e[7]=r.editedValue,e[8]=y):y=e[8];let m=y,h;e[9]!==r.editedMetadata?(h=Ke(r.editedMetadata),e[9]=r.editedMetadata,e[10]=h):h=e[10];let N=h,C;e[11]!==r.editedTtl?(C=Ve(r.editedTtl),e[11]=r.editedTtl,e[12]=C):C=e[12];let w=C,b;e[13]!==m?(b=s(()=>{m!==void 0&&p({type:"editValue",value:m})},"y"),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]!==i||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(E=s(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),z((async()=>{try{await o.putKvValue(Te({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},u,i,d)),p({type:"saveOk"})}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"F"),e[15]=o,e[16]=d,e[17]=u,e[18]=N,e[19]=i,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,T;e[25]!==o||e[26]!==u||e[27]!==i||e[28]!==v?(T=s(()=>{p({type:"deleteStart"}),z((async()=>{try{await o.deleteKvKey({key:u,namespace:i}),v(u)}catch(f){p({error:Z(f),type:"writeFailed"})}})())},"V"),e[25]=o,e[26]=u,e[27]=i,e[28]=v,e[29]=T):T=e[29];let J=T,L;e[30]!==u?(L=s(()=>{de(u)},"A"),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)($,{"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]!==r.loadError?(k=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=k):k=e[38];let F;e[39]!==r.loading||e[40]!==t?(F=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=F):F=e[41];let I;e[42]!==m||e[43]!==N||e[44]!==J||e[45]!==S||e[46]!==B||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(I=!r.loading&&r.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(Je(r.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:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-format-btn",disabled:m===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)($,{"data-testid":"kv-copy-value-btn",onClick:s(()=>{de(r.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:!w,onChange:s(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:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!N||!w,onClick:B,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)($,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=m,e[43]=N,e[44]=J,e[45]=S,e[46]=B,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=I):I=e[55];let K;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(K=!r.loading&&r.value===null&&r.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]=r.loadError,e[57]=r.loading,e[58]=r.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},"He"),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=s((l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let d=new Set(e.deleted);return{...l,bulk:l.bulk.filter(u=>!d.has(u)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(u=>!d.has(u.name)),selectedKey:l.selectedKey!==null&&d.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(d=>d!==e.name),keys:l.keys===null?null:l.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(d=>d!==e.name):[...l.bulk,e.name]};default:return l}},"ze"),Ue=s(({namespace:l})=>{let e=G(),d=R(),[u,i]=(0,P.useReducer)(Re,Ze),{appliedPrefix:v,bulk:o,bulkBusy:t,bulkError:r,cursor:p,keys:c,listComplete:x,loadError:g,loading:O,prefixInput:V,reloadNonce:_,selectedKey:y}=u,[m,h]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n={cancelled:!1};return z((async()=>{i({type:"loadStart"});try{let k=await e.listKvKeys({limit:Se,namespace:l,prefix:v===""?void 0:v});n.cancelled||i({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){n.cancelled||i({error:Z(k),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,l,v,_]);let N=s(n=>{i({type:"prefixInput",value:n.target.value})},"x"),C=s(()=>{i({type:"applyFilter"})},"N"),w=s(n=>{i({name:n.currentTarget.dataset.key??null,type:"selectKey"})},"C"),b=s(()=>{p!==null&&(i({type:"loadStart"}),z((async()=>{try{let n=await e.listKvKeys({cursor:p,limit:Se,namespace:l,prefix:v===""?void 0:v});i({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){i({error:Z(n),type:"loadFailed"})}})()))},"y"),S=s(n=>{i({name:n,type:"keyDeleted"})},"S"),E=s(n=>{i({name:n,type:"toggleBulk"})},"F"),B=s(n=>{i({names:n&&c!==null?c.map(k=>k.name):[],type:"toggleAllBulk"})},"O"),T=s(()=>{if(o.length===0)return;let n=[...o];i({type:"bulkDeleteStart"}),z((async()=>{let k=await Promise.allSettled(n.map(K=>e.deleteKvKey({key:K,namespace:l}))),F=n.filter((K,D)=>k[D]?.status==="fulfilled"),I=n.length-F.length;i({deleted:F,error:I>0?d("Failed to delete {count} keys.",{count:I}):null,type:"bulkDeleted"})})())},"V"),J=s(()=>{h(!1),i({type:"reload"})},"D"),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)($,{"data-testid":"kv-filter-btn",disabled:O,onClick:C,children:d("Filter")}),(0,a.jsx)($,{"data-testid":"kv-new-key-btn",onClick:s(()=>{h(n=>!n)},"onClick"),variant:"outline",children:d("New key")}),o.length>0&&(0,a.jsx)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:T,variant:"destructive",children:t?d("Deleting\u2026"):d("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),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)(ie,{"data-testid":"kv-key-table",children:[(0,a.jsx)(se,{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:B})}),(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:w,children:[(0,a.jsx)(Y,{onClick:s(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:s(()=>{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)($,{"data-testid":"kv-load-more",disabled:O,onClick:b,variant:"outline",children:d(O?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:s(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:l,onCancel:s(()=>{h(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(me,{onOpenChange:s(n=>{n||i({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:l,onDeleted:S},`${l}:${y}`)]})})]})},"Ue"),st=s(({loadNamespaces:l}={})=>{let e=G(),d=R(),[u,i]=(0,P.useState)(null),[v,o]=(0,P.useState)(null),[t,r]=(0,P.useState)(null);(0,P.useEffect)(()=>{let c={cancelled:!1};return z((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();c.cancelled||(i(x),o(null),r(g=>g??x[0]?.binding??null))}catch(x){c.cancelled||(i(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,l]);let p=s(c=>{r(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)(ie,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(se,{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)]})},"ut");export{st as KvBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-7TRN7FQ4.js";import{a as n}from"./chunk-YKXDMIHQ.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),c=Symbol("lunora.operationSeq"),_=n(t=>{if(typeof t!="object"||t===null)return;let e=t[c];return typeof e=="number"?e:void 0},"g"),d=n((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,c,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"h"),m=n(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"p"),h=n(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"O"),w=n(t=>new Proxy(t,{get(e,u,y){let i=Reflect.get(e,u,y);if(typeof i!="function"||typeof u!="string"||!g.has(u))return typeof i=="function"?i.bind(e):i;let f=i;return async(...o)=>{let l=m(o[0]);if(l===void 0)return f.apply(e,o);let p=typeof o[1]=="object"&&o[1]!==null?o[1]:{},a=s.start(l,p,h(o[2]));try{let r=await f.apply(e,o);return s.settle(a,{result:r}),r}catch(r){throw s.settle(a,{error:r instanceof Error?r.message:String(r)}),d(r,a),r}}}}),"E");export{_ as a,w as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as I}from"./chunk-FKVZRPV5.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-HEAQVSNS.js";import{a as b,e as S}from"./chunk-WUWBZPUK.js";import{d as w}from"./chunk-FODLDLE2.js";import{a as f,d as y,f as _,g as j}from"./chunk-YKXDMIHQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as te}from"./chunk-PD6WIDY6.js";import{a as Z}from"./chunk-S3CRZLGS.js";import{a as Y}from"./chunk-2DX5MROH.js";import{b as X}from"./chunk-OGUKYRFM.js";import{a as W}from"./chunk-K7AJEMKE.js";import{e as G}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as ae,c as ne}from"./chunk-EY7RT4YO.js";import{a as q,b as ee}from"./chunk-
|
|
1
|
+
import{a as te}from"./chunk-PD6WIDY6.js";import{a as Z}from"./chunk-S3CRZLGS.js";import{a as Y}from"./chunk-2DX5MROH.js";import{b as X}from"./chunk-OGUKYRFM.js";import{a as W}from"./chunk-K7AJEMKE.js";import{e as G}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as ae,c as ne}from"./chunk-EY7RT4YO.js";import{a as q,b as ee}from"./chunk-CZIPGHIR.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as I}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-7TRN7FQ4.js";import{f as D}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as M,f as C,g as A,l as V,o as N}from"./chunk-FODLDLE2.js";import{a as l,d as j,e as he,f as me,g as pe}from"./chunk-YKXDMIHQ.js";var E=j(me(),1);var c=j(he(),1);var S=j(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:i}=t;if(typeof i!="string"||i.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:n}=e;return!Array.isArray(a)||a.length===0||a.some(s=>typeof s!="string"||s.length===0)?!1:typeof n=="string"&&n.length>0},"ye"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(i=>JSON.stringify(i)).join(", ")}])`,"ge"),ye=l(t=>{let e=(0,E.c)(19),{fields:i,indexName:a,table:n,testId:s}=t,u=M(),[h,f]=(0,c.useState)(null),m;e[0]!==i||e[1]!==a?(m=l(()=>{let b=be(a,i),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=i,e[1]=a,e[2]=m):m=e[2];let x=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==n||e[7]!==s?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${s}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:n})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${s}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:n}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=n,e[7]=s,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==n?(p=u("Copy index declaration for {table}",{table:n}),e[11]=u,e[12]=n,e[13]=p):p=e[13];let w;return e[14]!==x||e[15]!==T||e[16]!==p||e[17]!==s?(w=(0,S.jsx)(te,{confirmLabel:T,onConfirm:x,testId:s,children:p}),e[14]=x,e[15]=T,e[16]=p,e[17]=s,e[18]=w):w=e[18],w},"ve"),xe=l((t,e)=>{let i=new Map;for(let a of e){let n=`${a.table} ${a.index}`;i.set(n,(i.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:i.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let i of t)for(let a of i.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([i,a])=>({scans:a,table:i}))},"Te"),ie=l((t,e)=>e.map(i=>({index:i.name,table:t})),"P"),we=l(t=>{let e=xe(t.declaredIndexes??[],t.indexHits??[]),i=ve(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,s=n&&n.indexHits.length>0?n.indexHits:e,u=n&&n.tableScans.length>0?n.tableScans:i,h=n&&n.shardTraffic.length>0?n.shardTraffic:a,f=ne({indexHits:s,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(x=>!(x.metadata.kind==="hot_scan"&&typeof x.metadata.table=="string"&&m.has(x.metadata.table)))).map(x=>q(x))},"we"),Se=C(I.listTables),Te=C(I.listTableIndexes),Ie=C(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"L"),re=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),se=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:re(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:re(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:V(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:i,table:a}=t,n=M(),s;e[0]!==i||e[1]!==a?(s=l(()=>{i(a)},"i"),e[0]=i,e[1]=a,e[2]=s):s=e[2];let u=s,h=`in-add-index-${a}`,f;e[3]!==n||e[4]!==a?(f=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(Q,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let i=D(),a=G(),n=M(),{queryShardKey:s,setShardKey:u,shardKey:h}=Z(t),[f,m]=(0,c.useState)(null),[x,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=_(I.getMetrics,{},{live:!0,shardKey:s}),b=_(I.getFunctionStats,{},{live:!0,shardKey:s}),$=_(I.getAdvisories,{},{live:!0,shardKey:s}),L=w.data??null,H=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(r=>i.shardTraffic(r)),le=l(async(r,y)=>{let o=r[0];if(o===void 0||o===""){p.current===y&&T(null);return}try{let g=await oe(o);if(p.current!==y)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===y&&T(null)}},"Y"),de=l(async(r,y)=>{let o=await Promise.allSettled(r.map(async d=>[d,await i.query(Te,{table:d},A(y))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...ie(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async r=>{p.current=r;let y=[];try{let o=await i.query(Se,{},A(r));if(p.current!==r)return;X(r),y=o.map(d=>d.name);let g=[];if(y.length>0)try{let d=await i.query(Ie,{tables:y},A(r));if(p.current!==r)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...ie(v,k))}catch{if(g=await de(y,r),p.current!==r)return}m(g)}catch{p.current===r&&m(null)}await le(y,r)});(0,c.useEffect)(()=>{N(z(s))},[s]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(s))});(0,c.useEffect)(()=>{let r=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);let U=(0,c.useCallback)(r=>{N(a({search:{table:r},to:"/schema"}))},[a]),K=(0,c.useMemo)(()=>W(L,H),[H,L]),P=(0,c.useMemo)(()=>new Set(K.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[K]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:H,indexHits:J,shardTraffic:x,suppressHotScanTables:P}),[f,H,J,P,x]),ue=(0,c.useMemo)(()=>{let r=K.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?se(n,o):`${se(n,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(n,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),y=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=q(o);if(y.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(ye,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...r]},[F,K,U,R,n]),fe=(0,S.jsx)(Y,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(ee,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-
|
|
1
|
+
import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-75OWNJEY.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-Y6CXU7T4.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as g}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as y}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as w}from"./chunk-FKVZRPV5.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-HEAQVSNS.js";import{a as f,e as N}from"./chunk-WUWBZPUK.js";import{d as T,r as S}from"./chunk-FODLDLE2.js";import{a as c,d as G,g as H}from"./chunk-YKXDMIHQ.js";var e=G(H(),1);var Q=["subscriptions","events"],U={},B=new Set(["active","trialing"]),V=new Set(["past_due","unpaid"]),s=c((a,t)=>{if(a[t]!==void 0)return a[t];let m=a.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"n"),i=c(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","a"),q=c(a=>B.has(a)?"default":V.has(a)?"destructive":"outline","G"),se=c(({limit:a=100})=>{let t=T(),m=_(),{data:x}=b(y.listTables,U,{live:!0}),D=x!==void 0,C=Array.isArray(x)&&Q.every(r=>x.some(d=>d.name===r)),p=m.payments&&C,o=b(y.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),h=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),h.refetch())},!0);let u=o.data?.rows??[],O=h.data?.rows??[],F=o.error??h.error,L=o.error===null?h.errorSource:o.errorSource,P=u.filter(r=>B.has(i(s(r,"state")))).length,M=O.toSorted((r,d)=>Number(s(d,"processedAt")??0)-Number(s(r,"processedAt")??0));return D&&!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)(f,{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)(g,{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:u.length})})]})}),F===null?void 0:(0,e.jsx)(E,{error:L}),u.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(f,{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:u.map(r=>{let d=i(s(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{children:i(s(r,"referenceId"))}),(0,e.jsx)(n,{children:i(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(g,{variant:q(d),children:d})}),(0,e.jsx)(n,{children:S(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(f,{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:M.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})},"se");export{se as PaymentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v}from"./chunk-F7UC63UN.js";import{a as Q}from"./chunk-66UGPQVC.js";import{a as L}from"./chunk-S3CRZLGS.js";import{a as G}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as $}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as W}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-F7UC63UN.js";import{a as Q}from"./chunk-66UGPQVC.js";import{a as L}from"./chunk-S3CRZLGS.js";import{a as G}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as $}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as W}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{c as B}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as A}from"./chunk-FKVZRPV5.js";import{a as q,b as H,c as O,d as K,e as T,f as D}from"./chunk-HEAQVSNS.js";import{a as _}from"./chunk-WUWBZPUK.js";import{d as j}from"./chunk-FODLDLE2.js";import{a as S,d as F,f as J,g as V}from"./chunk-YKXDMIHQ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(31),{initialShardKey:o}=c,a=j(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,refetch:I}=B(E.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m?(h=i!==null&&(0,t.jsx)(W,{error:m,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=h):h=e[16];let x;e[17]!==i||e[18]!==k||e[19]!==a?(x=i===null&&k&&(0,t.jsx)(A,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),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 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[17]=i,e[18]=k,e[19]=a,e[20]=x):x=e[20];let N;e[21]!==i||e[22]!==k||e[23]!==s||e[24]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[21]=i,e[22]=k,e[23]=s,e[24]=a,e[25]=N):N=e[25];let b;return e[26]!==y||e[27]!==h||e[28]!==x||e[29]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[26]=y,e[27]=h,e[28]=x,e[29]=N,e[30]=b):b=e[30],b},"me");function ee(c){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(D,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}from"./chunk-
|
|
1
|
+
import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as z}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as E}from"./chunk-FKVZRPV5.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HEAQVSNS.js";import{a as D,e as _}from"./chunk-WUWBZPUK.js";import{d as q}from"./chunk-FODLDLE2.js";import{a as S,d as O,f as Q,g as V}from"./chunk-YKXDMIHQ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
|