@lunora/studio 1.0.0-alpha.80 → 1.0.0-alpha.82
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/index.d.ts +35 -6
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.js +1 -0
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +2 -2
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +6 -6
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/log-drains-panel.js +1 -1
- package/dist/packem_chunks/migrations-route.js +1 -1
- package/dist/packem_chunks/organizations-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-CZESgd10.js +1 -0
- package/dist/packem_shared/{ApiDocsPanel-DfUQ1ZAF.js → ApiDocsPanel-fYS9NiLg.js} +1 -1
- package/dist/packem_shared/DataBrowser-C4J4gVUu.js +1 -0
- package/dist/packem_shared/GlobalDataBrowser-CSttudUx.js +1 -0
- package/dist/packem_shared/{HomePanel-Dcs4a3Ax.js → HomePanel-BYsfMhKh.js} +1 -1
- package/dist/packem_shared/{MigrationsPanel-C2OnsqRb.js → MigrationsPanel-2JbQ2HwG.js} +1 -1
- package/dist/packem_shared/{Studio-B26_pT8J.js → Studio-Ba9x0dG_.js} +1 -1
- package/dist/packem_shared/{StudioApp-bXhJeLlZ.js → StudioApp-B_PRdg4h.js} +1 -1
- package/dist/packem_shared/{cf-links-gbDy51nR.js → cf-links-Dmg86v1D.js} +1 -1
- package/dist/packem_shared/{home-panel-CU6MWLHG.js → home-panel-B60-5YfI.js} +1 -1
- package/dist/packem_shared/stat-card-fm_TF1mo.js +1 -0
- package/dist/packem_shared/studio-CPuoAmjh.js +2 -0
- package/dist/packem_shared/table-list-sidebar-BRv3hTLX.js +1 -0
- package/dist/packem_shared/{use-sql-assistant-CHEu2-Rk.js → use-sql-assistant-BLG9unQN.js} +1 -1
- package/dist/standalone/{chunk-RQ7AFLIV.js → chunk-2QSHLBCO.js} +1 -1
- package/dist/standalone/{chunk-33CL6OHR.js → chunk-5SQRE3VR.js} +1 -1
- package/dist/standalone/{chunk-5CVJS7ON.js → chunk-6QP5N57V.js} +1 -1
- package/dist/standalone/chunk-73GRNONE.js +1 -0
- package/dist/standalone/{chunk-JRMMYIAF.js → chunk-74DN6HIE.js} +1 -1
- package/dist/standalone/{chunk-KZ3ALMMP.js → chunk-7H7LZRLP.js} +1 -1
- package/dist/standalone/{chunk-FOBRNWBG.js → chunk-7YKWP4QK.js} +1 -1
- package/dist/standalone/{chunk-T7IUZIF4.js → chunk-7ZUQE3KU.js} +1 -1
- package/dist/standalone/{chunk-P4YLIBCN.js → chunk-A3KUNMU6.js} +1 -1
- package/dist/standalone/{chunk-S2VVR7HI.js → chunk-B2H5DK55.js} +1 -1
- package/dist/standalone/{chunk-FNPJ7GJZ.js → chunk-BDJCCVB6.js} +1 -1
- package/dist/standalone/{chunk-KJB7YAKB.js → chunk-C7EOC2WS.js} +1 -1
- package/dist/standalone/{chunk-KLQYC6CC.js → chunk-CGLS2ILT.js} +1 -1
- package/dist/standalone/chunk-CPSGJSHY.js +1 -0
- package/dist/standalone/{chunk-RJP3WBZ4.js → chunk-CU6SCYQ7.js} +1 -1
- package/dist/standalone/chunk-DGBJE7YF.js +4 -0
- package/dist/standalone/{chunk-G6PSMGLD.js → chunk-DOZAODYC.js} +1 -1
- package/dist/standalone/chunk-EQZTSISX.js +1 -0
- package/dist/standalone/chunk-ERMTJYQF.js +1 -0
- package/dist/standalone/{chunk-QZGTH6WH.js → chunk-GB6LP6UJ.js} +1 -1
- package/dist/standalone/{chunk-GYKVBKT5.js → chunk-GM67EQJU.js} +1 -1
- package/dist/standalone/chunk-GN567L2T.js +1 -0
- package/dist/standalone/{chunk-L7R74G63.js → chunk-GWHM4C4N.js} +1 -1
- package/dist/standalone/{chunk-JLOWAJRR.js → chunk-GWQIPIYA.js} +1 -1
- package/dist/standalone/{chunk-6YTSSIEJ.js → chunk-HEB6GQQ6.js} +1 -1
- package/dist/standalone/chunk-HOR3JLUY.js +6 -0
- package/dist/standalone/{chunk-7LWMHTJ3.js → chunk-I6A5C46N.js} +1 -1
- package/dist/standalone/{chunk-H6YOWRFB.js → chunk-KAPSM6AI.js} +1 -1
- package/dist/standalone/{chunk-6NY7SPDL.js → chunk-KSRP7GZV.js} +1 -1
- package/dist/standalone/chunk-LLF5KWDZ.js +2 -0
- package/dist/standalone/chunk-NRCXRCJX.js +1 -0
- package/dist/standalone/chunk-OE465DVY.js +1 -0
- package/dist/standalone/{chunk-HJ3E4YF5.js → chunk-PXYWCZ7T.js} +1 -1
- package/dist/standalone/{chunk-PZVU2QMX.js → chunk-Q7QTRX2E.js} +1 -1
- package/dist/standalone/{chunk-E3NMX2VU.js → chunk-S4ILMYP5.js} +1 -1
- package/dist/standalone/{chunk-KC44QCN6.js → chunk-SDQBPFLO.js} +1 -1
- package/dist/standalone/chunk-SV52HB7D.js +1 -0
- package/dist/standalone/{chunk-WBYSSCV2.js → chunk-T242WITF.js} +1 -1
- package/dist/standalone/{chunk-VHWOCPRK.js → chunk-TBRZQICB.js} +1 -1
- package/dist/standalone/{chunk-6LNCYDZO.js → chunk-TQXZ7LG4.js} +1 -1
- package/dist/standalone/chunk-U457LHCO.js +1 -0
- package/dist/standalone/chunk-UBPYN4DU.js +1 -0
- package/dist/standalone/{chunk-34D36UCW.js → chunk-UDVB4URN.js} +1 -1
- package/dist/standalone/{chunk-6IKEW5LG.js → chunk-UETNCBWU.js} +1 -1
- package/dist/standalone/{chunk-OY2RVUZL.js → chunk-UU2QJMGJ.js} +1 -1
- package/dist/standalone/chunk-VC5SSRUP.js +1 -0
- package/dist/standalone/{chunk-GXSZH7VJ.js → chunk-VCXH5V3Z.js} +1 -1
- package/dist/standalone/{chunk-RNRJKBY3.js → chunk-VTLYN3CX.js} +1 -1
- package/dist/standalone/{chunk-3O3HAXW7.js → chunk-WDG4WFUV.js} +1 -1
- package/dist/standalone/{chunk-3STOIE7Q.js → chunk-WJGOI3FZ.js} +1 -1
- package/dist/standalone/{chunk-W6SAOXGH.js → chunk-WLZ7YPBH.js} +1 -1
- package/dist/standalone/{chunk-2VDFV5TD.js → chunk-WQVVA5NB.js} +1 -1
- package/dist/standalone/{chunk-TTGOOYLF.js → chunk-WZ3B3MEV.js} +1 -1
- package/dist/standalone/{chunk-SKW6J4VW.js → chunk-Y7A5NCXT.js} +1 -1
- package/dist/standalone/{chunk-IHQC7J35.js → chunk-YSRW5RNU.js} +1 -1
- package/dist/standalone/{chunk-GAX5IZYG.js → chunk-YTA2HGRD.js} +1 -1
- package/dist/standalone/chunk-ZHBIKP5G.js +1 -0
- package/dist/standalone/{chunk-CCVXYYPJ.js → chunk-ZK3XKFCI.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js +0 -1
- package/dist/packem_shared/DataBrowser-CuRlztBz.js +0 -1
- package/dist/packem_shared/GlobalDataBrowser-DB-vQ2_H.js +0 -1
- package/dist/packem_shared/studio-q-C-acL7.js +0 -2
- package/dist/packem_shared/table-list-sidebar-BFkSQwlB.js +0 -1
- package/dist/standalone/chunk-2GA4SHO7.js +0 -1
- package/dist/standalone/chunk-2WOIRKEI.js +0 -1
- package/dist/standalone/chunk-6PNPIW6I.js +0 -2
- package/dist/standalone/chunk-6YI4WJO4.js +0 -1
- package/dist/standalone/chunk-A74VSSA2.js +0 -4
- package/dist/standalone/chunk-CT5MMH4O.js +0 -1
- package/dist/standalone/chunk-GB6U2BPU.js +0 -1
- package/dist/standalone/chunk-GEDMLM4A.js +0 -6
- package/dist/standalone/chunk-S252DAFP.js +0 -1
- package/dist/standalone/chunk-XS5LDR52.js +0 -1
- package/dist/standalone/chunk-YJYTMQJI.js +0 -1
- package/dist/standalone/chunk-Z2V42P7J.js +0 -1
- /package/dist/standalone/{chunk-SKHEGARW.js → chunk-XF2B7P5A.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as x}from"./chunk-ERMTJYQF.js";import{c as C}from"./chunk-XDAT7LHC.js";import{f as q}from"./chunk-EN2QAEO4.js";import{d as k,f as g,g as y,l as S}from"./chunk-OG4N2XHD.js";import{a as f,e as w,f as L,g as F,h as O}from"./chunk-3XIESWL4.js";var v=w(L(),1);var j={},I=g(x.aiGenerateSql),T=g(x.aiTableFilter),A=g(x.aiChartConfig),R=f(s=>{let e=q(),[l,d]=(0,v.useState)({}),[n,r]=(0,v.useState)({}),a=C(x.aiAvailable,j,{shardKey:s}),[u,i]=(0,v.useState)(!1),b=u||a.data?.available===!1,p=f(t=>{d(o=>({...o,[t]:!0})),r(o=>({...o,[t]:void 0}))},"n"),h=f((t,o)=>{d(c=>({...c,[t]:!1})),o!==void 0&&r(c=>({...c,[t]:o})),o==="no-ai-binding"&&i(!0)},"t");return{generate:f(async(t,o)=>{p("sql");try{let{result:c}=await e.query(I,{failedError:o?.error,failedSql:o?.sql,prompt:t},y(s));return h("sql",c.degraded?c.reason:void 0),c.degraded?void 0:c.sql}catch{h("sql","ai-error");return}},"generate"),inferChart:f(async t=>{p("chart");try{let{result:o}=await e.query(A,t,y(s));return h("chart",o.degraded?o.reason:void 0),o.degraded?void 0:o.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:f(t=>l[t]===!0,"pending"),reason:f(t=>n[t],"reason"),suggestFilter:f(async(t,o)=>{p("filter");try{let{result:c}=await e.query(T,{prompt:t,table:o},y(s));return h("filter",c.degraded?c.reason:void 0),c.degraded?void 0:c.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:b}},"k");var N=w(F(),1);var m=w(O(),1);var U=f((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),r=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,r))a>r&&l.push({match:!1,offset:r,text:s.slice(r,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),r=a+e.length;return r<s.length&&l.push({match:!1,offset:r,text:s.slice(r)}),l},"N"),z=f(s=>{let e=(0,N.c)(9),{highlight:l,value:d}=s;if(d==null){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=i):i=e[0],i}let n,r,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let i=S(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:i,children:i});break e}n=i,r=U(i,l).map(D)}e[1]=l,e[2]=d,e[3]=n,e[4]=r,e[5]=a}else n=e[3],r=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==r?(u=(0,m.jsx)("span",{title:n,children:r}),e[6]=n,e[7]=r,e[8]=u):u=e[8],u},"v"),Q=f(s=>{let e=(0,N.c)(22),{columns:l,rows:d}=s,n=k(),r;e[0]!==n?(r=n("Field"),e[0]=n,e[1]=r):r=e[1];let a;e[2]!==r?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let t;e[7]!==n?(t=f((o,c)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:c+1})},c),"i"),e[7]=n,e[8]=t):t=e[8],u=d.map(t),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let i;e[9]!==a||e[10]!==u?(i=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=i):i=e[11];let b;if(e[12]!==l||e[13]!==d){let t;e[15]!==d?(t=f(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((c,_)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(z,{value:c[o]})},_))]},o),"i"),e[15]=d,e[16]=t):t=e[16],b=l.map(t),e[12]=l,e[13]=d,e[14]=b}else b=e[14];let p;e[17]!==b?(p=(0,m.jsx)("tbody",{children:b}),e[17]=b,e[18]=p):p=e[18];let h;return e[19]!==i||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[i,p]})}),e[19]=i,e[20]=p,e[21]=h):h=e[21],h},"j"),V=f(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"O");function D(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}f(D,"k");export{R as a,z as b,Q as c,V as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u}from"./chunk-UZERI5YC.js";import{a as x,e as f,g as h,h as N}from"./chunk-3XIESWL4.js";var b=f(h(),1);var t=f(N(),1);var v=x(g=>{let e=(0,b.c)(16),{chart:c,footer:n,label:i,testId:m,value:p}=g,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i}),e[0]=i,e[1]=r):r=e[1];let a;e[2]!==m||e[3]!==p?(a=(0,t.jsx)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":m,children:p}),e[2]=m,e[3]=p,e[4]=a):a=e[4];let s;e[5]!==c||e[6]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a,c]}),e[5]=c,e[6]=a,e[7]=s):s=e[7];let l;e[8]!==r||e[9]!==s?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[r,s]}),e[8]=r,e[9]=s,e[10]=l):l=e[10];let o;e[11]!==n?(o=n!=null&&(0,t.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:n}),e[11]=n,e[12]=o):o=e[12];let d;return e[13]!==l||e[14]!==o?(d=(0,t.jsxs)(u,{className:"justify-between gap-0 py-0",children:[l,o]}),e[13]=l,e[14]=o,e[15]=d):d=e[15],d},"j");export{v as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _={aiAvailable:"__lunora_admin__:aiAvailable",aiChartConfig:"__lunora_admin__:aiChartConfig",aiGenerateSql:"__lunora_admin__:aiGenerateSql",aiTableFilter:"__lunora_admin__:aiTableFilter",assignIssue:"__lunora_admin__:assignIssue",backRelationCounts:"__lunora_admin__:backRelationCounts",clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",explainIssue:"__lunora_admin__:explainIssue",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAdvisorProcedures:"__lunora_admin__:getAdvisorProcedures",getAuditLog:"__lunora_admin__:getAuditLog",getAuthAuditLog:"__lunora_admin__:getAuthAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",lintSql:"__lunora_admin__:lintSql",listFlags:"__lunora_admin__:listFlags",listPushSubscriptions:"__lunora_admin__:listPushSubscriptions",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetricHistory:"__lunora_admin__:getMetricHistory",getMetricSeries:"__lunora_admin__:getMetricSeries",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueryInsights:"__lunora_admin__:getQueryInsights",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",ignoreIssue:"__lunora_admin__:ignoreIssue",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",resolveIssue:"__lunora_admin__:resolveIssue",rlsPolicies:"__lunora_admin__:rlsPolicies",schemaHistory:"__lunora_admin__:schemaHistory",schemaVersion:"__lunora_admin__:schemaVersion",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",setIssueSeverity:"__lunora_admin__:setIssueSeverity",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{_ as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as et}from"./chunk-GAX5IZYG.js";import{a as Ze}from"./chunk-CTNB2KIA.js";import"./chunk-GMR677FL.js";import"./chunk-KZ3ALMMP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-7LWMHTJ3.js";import"./chunk-RQ7AFLIV.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-4UOFSGUS.js";import{a as Ye}from"./chunk-QXXIJAD5.js";import{d as Ke,e as _e}from"./chunk-SMIESS7P.js";import{a as He}from"./chunk-LFKCLLPT.js";import"./chunk-T6VMSOBB.js";import{a as $e}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{c as de}from"./chunk-XDAT7LHC.js";import{a as Ge,b as Qe,c as Xe,d as Ie,e as M,f as I}from"./chunk-MIQTKZAR.js";import{a as Je,e as Pe}from"./chunk-UZERI5YC.js";import{a as Re}from"./chunk-5Y3QLNWX.js";import"./chunk-QBWRC5YX.js";import{a as ze}from"./chunk-X665E2HU.js";import{b as We}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as Le}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Ee}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as T}from"./chunk-2WOIRKEI.js";import{f as Fe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as ke}from"./chunk-XQCVZAGU.js";import{d as oe,f as Be,g as Ue,h as Ve,m as Ne,q as we}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as m,e as ie,f as Ce,g as Te,h as De,j as se}from"./chunk-3XIESWL4.js";var me=ie(Te(),1),ce=ie(Ce(),1);var tt=ie(Te(),1);var $=ie(Ce(),1);var l=ie(De(),1);var mt=Be(T.runMigration),at=m(a=>{let e=(0,tt.c)(99),{initialShardKey:r}=a,n=Fe(),t=oe(),[i,s]=(0,$.useState)(r??""),[d,u]=(0,$.useState)(""),[f,g]=(0,$.useState)("up"),[h,x]=(0,$.useState)(!0),[p,v]=(0,$.useState)(!1),[b,y]=(0,$.useState)(null),[c,j]=(0,$.useState)(null),k;e[0]!==i?(k=i.trim(),e[0]=i,e[1]=k):k=e[1];let N=He(k,400),R;e[2]!==i?(R=i.trim(),e[2]=i,e[3]=R):R=e[3];let O=R===N,q;e[4]===Symbol.for("react.memo_cache_sentinel")?(q={},e[4]=q):q=e[4];let ue;e[5]!==N?(ue={live:!0,shardKey:N},e[5]=N,e[6]=ue):ue=e[6];let w=de(T.migrationStatus,q,ue),S=w.data?.migrations??null,je=w.error,{errorSource:Se,liveError:Oe}=w,he,pe;e[7]!==N||e[8]!==w.data?(he=m(()=>{w.data!==void 0&&We(N)},"H"),pe=[w.data,N],e[7]=N,e[8]=w.data,e[9]=he,e[10]=pe):(he=e[9],pe=e[10]),(0,$.useEffect)(he,pe);let fe;if(e[11]!==n||e[12]!==f||e[13]!==h||e[14]!==d||e[15]!==i||e[16]!==w||e[17]!==t){let C=m(async()=>{let qe=d.trim();if(qe===""){j(t("Enter a migration id")),y(null);return}v(!0),j(null);try{let Me=await n.query(mt,{direction:f,dryRun:h,id:qe},Ue(i));y(Me),w.refetch()}catch(Me){let ct=Me;y(null),j(Ve(ct))}v(!1)},"m");fe=m(()=>{Ne(C())},"X"),e[11]=n,e[12]=f,e[13]=h,e[14]=d,e[15]=i,e[16]=w,e[17]=t,e[18]=fe}else fe=e[18];let ge=fe,be;e[19]===Symbol.for("react.memo_cache_sentinel")?(be=m(C=>{u(C.target.value)},"Z"),e[19]=be):be=e[19];let ot=be,ve;e[20]===Symbol.for("react.memo_cache_sentinel")?(ve=m(C=>{g(C.target.value==="down"?"down":"up")},"ee"),e[20]=ve):ve=e[20];let dt=ve,xe;e[21]===Symbol.for("react.memo_cache_sentinel")?(xe=m(C=>{x(C.target.checked)},"re"),e[21]=xe):xe=e[21];let lt=xe,D;e[22]!==i?(D=(0,l.jsx)(ze,{onChange:s,testId:"mg-shard-input",value:i}),e[22]=i,e[23]=D):D=e[23];let F;e[24]!==Oe?(F=(0,l.jsx)(Ze,{message:Oe,prefix:"mg"}),e[24]=Oe,e[25]=F):F=e[25];let K;e[26]!==D||e[27]!==F?(K=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[D,F]}),e[26]=D,e[27]=F,e[28]=K):K=e[28];let _;e[29]!==je||e[30]!==Se?(_=je!==null&&(0,l.jsx)($e,{error:Se,testId:"mg-status-error"}),e[29]=je,e[30]=Se,e[31]=_):_=e[31];let E;e[32]!==S||e[33]!==t?(E=S!==null&&S.length===0&&(0,l.jsx)(ke,{description:t("Data migrations you run against this shard will be tracked here."),icon:(0,l.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:t("No migrations have run on this shard.")}),e[32]=S,e[33]=t,e[34]=E):E=e[34];let A;e[35]!==S||e[36]!==t?(A=S!==null&&S.length>0&&(0,l.jsx)(Je,{className:"overflow-hidden py-0",children:(0,l.jsx)(Pe,{className:"px-0",children:(0,l.jsxs)(Ge,{"data-testid":"mg-table",children:[(0,l.jsx)(Qe,{children:(0,l.jsxs)(Ie,{children:[(0,l.jsx)(M,{children:t("id")}),(0,l.jsx)(M,{children:t("direction")}),(0,l.jsx)(M,{children:t("status")}),(0,l.jsx)(M,{children:t("processed")}),(0,l.jsx)(M,{children:t("changed")}),(0,l.jsx)(M,{children:t("updated")}),(0,l.jsx)(M,{children:t("error")})]})}),(0,l.jsx)(Xe,{children:S.map(ut)})]})})}),e[35]=S,e[36]=t,e[37]=A):A=e[37];let L;e[38]!==t?(L=t("Run migration"),e[38]=t,e[39]=L):L=e[39];let J;e[40]!==L?(J=(0,l.jsx)(Re,{children:L}),e[40]=L,e[41]=J):J=e[41];let P;e[42]!==t?(P=t("Migration id"),e[42]=t,e[43]=P):P=e[43];let B;e[44]!==t?(B=t("migration id"),e[44]=t,e[45]=B):B=e[45];let U;e[46]!==d||e[47]!==P||e[48]!==B?(U=(0,l.jsx)(Ae,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:ot,placeholder:B,value:d}),e[46]=d,e[47]=P,e[48]=B,e[49]=U):U=e[49];let V;e[50]!==t?(V=t("Direction"),e[50]=t,e[51]=V):V=e[51];let W;e[52]!==t?(W=t("up"),e[52]=t,e[53]=W):W=e[53];let z;e[54]!==W?(z=(0,l.jsx)("option",{value:"up",children:W}),e[54]=W,e[55]=z):z=e[55];let H;e[56]!==t?(H=t("down"),e[56]=t,e[57]=H):H=e[57];let G;e[58]!==H?(G=(0,l.jsx)("option",{value:"down",children:H}),e[58]=H,e[59]=G):G=e[59];let Q;e[60]!==f||e[61]!==V||e[62]!==z||e[63]!==G?(Q=(0,l.jsxs)("select",{"aria-label":V,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:dt,value:f,children:[z,G]}),e[60]=f,e[61]=V,e[62]=z,e[63]=G,e[64]=Q):Q=e[64];let X;e[65]!==h?(X=(0,l.jsx)("input",{checked:h,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:lt,type:"checkbox"}),e[65]=h,e[66]=X):X=e[66];let Y;e[67]!==t?(Y=t("Dry run"),e[67]=t,e[68]=Y):Y=e[68];let Z;e[69]!==X||e[70]!==Y?(Z=(0,l.jsxs)(Re,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[X,Y]}),e[69]=X,e[70]=Y,e[71]=Z):Z=e[71];let ee;e[72]!==h||e[73]!==ge||e[74]!==p||e[75]!==O||e[76]!==t?(ee=h?(0,l.jsx)(Le,{"data-testid":"mg-run",disabled:p||!O,onClick:ge,type:"button",children:t(p?"Running\u2026":"Run")}):(0,l.jsx)(Ye,{confirmLabel:t(p?"Running\u2026":"Run migration?"),disabled:p||!O,onConfirm:ge,testId:"mg-run",children:t("Run")}),e[72]=h,e[73]=ge,e[74]=p,e[75]=O,e[76]=t,e[77]=ee):ee=e[77];let te;e[78]!==U||e[79]!==Q||e[80]!==Z||e[81]!==ee?(te=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[U,Q,Z,ee]}),e[78]=U,e[79]=Q,e[80]=Z,e[81]=ee,e[82]=te):te=e[82];let ae;e[83]!==J||e[84]!==te?(ae=(0,l.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[J,te]}),e[83]=J,e[84]=te,e[85]=ae):ae=e[85];let re;e[86]!==c?(re=c!==null&&(0,l.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:c}),e[86]=c,e[87]=re):re=e[87];let ne;e[88]!==b||e[89]!==t?(ne=b!==null&&(0,l.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[b.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:b.status}),b.processed,t(", changed"),b.changed]}),e[88]=b,e[89]=t,e[90]=ne):ne=e[90];let ye;return e[91]!==K||e[92]!==_||e[93]!==E||e[94]!==A||e[95]!==ae||e[96]!==re||e[97]!==ne?(ye=(0,l.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,_,E,A,ae,re,ne]}),e[91]=K,e[92]=_,e[93]=E,e[94]=A,e[95]=ae,e[96]=re,e[97]=ne,e[98]=ye):ye=e[98],ye},"vr");function ut(a){return(0,l.jsxs)(Ie,{"data-testid":`mg-row-${a.id}`,children:[(0,l.jsx)(I,{children:a.id}),(0,l.jsx)(I,{children:a.direction}),(0,l.jsx)(I,{children:(0,l.jsx)(Ee,{variant:"secondary",children:a.status})}),(0,l.jsx)(I,{children:a.processed}),(0,l.jsx)(I,{children:a.changed}),(0,l.jsx)(I,{children:we(a.updatedAt)}),(0,l.jsx)(I,{children:a.error??""})]},a.id)}m(ut,"Qe");var o=ie(De(),1);var le=m(a=>typeof a=="object"&&a!==null,"k"),ht=m(a=>le(a)&&le(a.fields)&&le(a.indexes)&&le(a.relations)&&typeof a.shardMode=="string","z"),pt=m(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!le(e)||e.version!==1||!le(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!ht(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},"B"),ft=m((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((r,n)=>r===e.fields[n]),"L"),gt=m((a,e,r,n)=>{let t=[];return r.kind!==n.kind&&t.push({severity:"breaking",summary:`field ${a}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`,table:a,scope:"table",type:"changedFieldKind"}),r.optional&&!n.optional?t.push({severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&t.push({scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"Q"),bt=m((a,e,r)=>r.optional?{scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"G"),vt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.fields)){let s=e.fields[t];s===void 0?n.push(bt(a,t,i)):n.push(...gt(a,t,s,i))}for(let t of Object.keys(e.fields))r.fields[t]===void 0&&n.push({severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"X"),xt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.indexes)){let s=e.indexes[t];if(s===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}ft(s,i)||n.push({severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))r.indexes[t]===void 0&&n.push({severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"Y"),yt=m((a,e,r,n)=>{for(let t of Object.keys(r.relations))e.relations[t]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))r.relations[t]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"Z"),kt=m((a,e,r,n)=>{e.shardMode!==r.shardMode&&n.push({severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${r.shardMode} \u2014 its physical storage moves; add a data migration / re-shard plan`,table:a,scope:"table",type:"changedShardMode"}),vt(a,e,r,n),xt(a,e,r,n),yt(a,e,r,n)},"ee"),Nt=m((a,e)=>{let r=[],n=a?.tables??{};for(let[t,i]of Object.entries(e.tables)){let s=n[t];if(s===void 0){r.push({scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}kt(t,s,i,r)}for(let t of Object.keys(n))e.tables[t]===void 0&&r.push({scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 add a data migration if its data must be archived/cleaned up`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",i=e.jurisdiction??"(none)";r.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${i} \u2014 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:r}},"te"),rt=m(a=>Object.entries(a.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(a.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:r.kind})),"T"),nt=m((a,e)=>{let r={},n=a?.fields??{},t=e?.fields??{};for(let[i,s]of Object.entries(t)){let d=n[i];d===void 0?r[i]=a===void 0?"unchanged":"added":r[i]=d.kind===s.kind&&d.optional===s.optional?"unchanged":"changed"}for(let i of Object.keys(n))t[i]===void 0&&(r[i]="removed");return r},"F"),wt=m((a,e)=>{let{changes:r}=Nt(a,e),n=new Set(r.filter(s=>s.scope==="table"&&s.table!==void 0).map(s=>s.table)),t=[],i=m((s,d)=>s?"added":n.has(d)?"changed":"context","o");for(let[s,d]of Object.entries(e.tables)){let u=a?.tables[s],f=i(u===void 0,s);t.push({columns:rt(d),fieldStatus:nt(u,d),name:s,shardMode:d.shardMode,status:f})}for(let[s,d]of Object.entries(a?.tables??{}))e.tables[s]===void 0&&t.push({columns:rt(d),fieldStatus:nt(d,void 0),name:s,shardMode:d.shardMode,status:"removed"});return t.sort((s,d)=>s.name.localeCompare(d.name)),{breakingCount:r.filter(s=>s.severity==="breaking").length,changes:r,tables:t}},"ae"),it=m(a=>{let e=pt(a);return e.status==="ok"?e.snapshot:void 0},"A"),$t={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"},jt=m(a=>a==="global"?"global":"shard","se"),St=m(a=>{let e=(0,me.c)(24),{appliedAt:r,hash:n,onSelect:t,selected:i,seq:s}=a,d=i?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=se("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=u):u=e[1];let f=`sh-version-${n}`,g;e[2]!==n||e[3]!==t?(g=m(()=>{t(n)},"m"),e[2]=n,e[3]=t,e[4]=g):g=e[4];let h;e[5]!==s?(h=(0,o.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",s]}),e[5]=s,e[6]=h):h=e[6];let x;e[7]!==n?(x=n.slice(0,7),e[7]=n,e[8]=x):x=e[8];let p;e[9]!==x?(p=(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:x}),e[9]=x,e[10]=p):p=e[10];let v;e[11]!==h||e[12]!==p?(v=(0,o.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[h,p]}),e[11]=h,e[12]=p,e[13]=v):v=e[13];let b;e[14]!==r?(b=we(r),e[14]=r,e[15]=b):b=e[15];let y;e[16]!==b?(y=(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=y):y=e[17];let c;return e[18]!==y||e[19]!==u||e[20]!==f||e[21]!==g||e[22]!==v?(c=(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:u,"data-testid":f,onClick:g,type:"button",children:[v,y]})}),e[18]=y,e[19]=u,e[20]=f,e[21]=g,e[22]=v,e[23]=c):c=e[23],c},"ie"),Ot=m(a=>{let e=(0,me.c)(26),{breaking:r,count:n,first:t}=a,i=oe();if(t){let p;e[0]!==n?(p=(0,o.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let v;e[2]!==i?(v=i("tables"),e[2]=i,e[3]=v):v=e[3];let b;e[4]!==v?(b=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=b):b=e[5];let y;return e[6]!==p||e[7]!==b?(y=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=y):y=e[8],y}let s=r>0&&"text-destructive",d;e[9]!==s?(d=se("text-3xl leading-none font-light tracking-tight tabular-nums",s),e[9]=s,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,o.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let f;e[14]!==n||e[15]!==i?(f=i(n===1?"change":"changes"),e[14]=n,e[15]=i,e[16]=f):f=e[16];let g;e[17]!==f?(g=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=g):g=e[18];let h;e[19]!==r||e[20]!==i?(h=r>0&&(0,o.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",i("{count} breaking",{count:r})]}),e[19]=r,e[20]=i,e[21]=h):h=e[21];let x;return e[22]!==u||e[23]!==g||e[24]!==h?(x=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,g,h]}),e[22]=u,e[23]=g,e[24]=h,e[25]=x):x=e[25],x},"re"),st={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"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},Mt=m((a,e)=>{let r=`${st[a.type].action} ${e} `;return a.summary.startsWith(r)?a.summary.slice(r.length):a.summary},"oe"),It=m(a=>{let e=new Map;for(let n of a){let t=n.table??"",i=e.get(t);i===void 0?e.set(t,[n]):i.push(n)}let r=[...e].map(([n,t])=>({changes:t,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"de"),Rt=m(a=>{let e=(0,me.c)(2),{children:r}=a,n;return e[0]!==r?(n=(0,o.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"le"),qt=m(({pane:a,shardKey:e=""})=>{let r=oe(),n=_e(),t=Ke({strict:!1}).version,i=m(c=>{Ne(n({search:{version:c},to:"/migrations"}))},"o"),s=de(T.schemaHistory,{},{shardKey:e}),d=s.data?.versions??[],u=t!==void 0&&d.some(c=>c.hash===t)?t:d[0]?.hash,f=d.findIndex(c=>c.hash===u),g=f===-1?void 0:d[f+1]?.hash,h=de(T.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),x=de(T.schemaVersion,{hash:g??""},{enabled:g!==void 0,shardKey:e}),p=(0,ce.useMemo)(()=>{let c=it(h.data?.version?.snapshotJson);if(c!==void 0)return wt(it(x.data?.version?.snapshotJson),c)},[h.data,x.data]),v=(0,ce.useMemo)(()=>(p?.tables??[]).map(c=>({columns:c.columns,name:c.name,tier:jt(c.shardMode)})),[p]),b=(0,ce.useMemo)(()=>{let c={};for(let j of p?.tables??[])c[j.name]=$t[j.status];return c},[p]);if(s.error!==null)return(0,o.jsx)($e,{error:s.errorSource,testId:"sh-error"});if(d.length===0)return(0,o.jsx)(ke,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let y=p?.changes??[];return(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,o.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,o.jsx)(Rt,{children:r("Schema versions")}),(0,o.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(c=>(0,o.jsx)(St,{appliedAt:c.appliedAt,hash:c.hash,onSelect:i,selected:c.hash===u,seq:c.seq},c.hash))})]}),(0,o.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,o.jsx)(Ot,{breaking:p?.breakingCount??0,count:g===void 0?v.length:y.length,first:g===void 0}),a==="diagram"?(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,o.jsx)(et,{fill:!0,nodeClasses:b,tables:v,testIdPrefix:"sh"})}):(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:It(y).map(c=>{let j=(p?.tables??[]).find(k=>k.name===c.table);return(0,o.jsxs)("section",{className:"mb-6",children:[(0,o.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,o.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:c.table===""?r("schema"):c.table}),j!==void 0&&(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:j.columns.length})}),c.changes.length>1&&(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:c.changes.length})]}),(0,o.jsx)("ul",{children:c.changes.map(k=>{let{action:N,kind:R}=st[k.type],O=k.severity==="breaking",q=Mt(k,R);return(0,o.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,o.jsx)("span",{"aria-hidden":"true",className:se("-ms-3 h-3 w-0.5 shrink-0 self-center",O?"bg-destructive":"bg-transparent")}),(0,o.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(N)," ",R]}),q!==c.table&&(0,o.jsx)("span",{className:se("min-w-0 font-mono text-[13px]",O?"text-destructive":"text-foreground"),children:q}),O&&(0,o.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},c.table)})})]})]})},"ce"),Ct=m(a=>se("-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",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"me"),la=m(a=>{let e=(0,me.c)(11),{initialShardKey:r}=a,n=oe(),[t,i]=(0,ce.useState)("diagram"),s;e[0]!==t?(s=m((h,x,p,v)=>(0,o.jsxs)("button",{"aria-selected":t===h,className:Ct(t===h),"data-testid":p,onClick:m(()=>{i(h)},"onClick"),role:"tab",type:"button",children:[x,v!==void 0&&(0,o.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"i"),e[0]=t,e[1]=s):s=e[1];let d=s,u;e[2]!==n||e[3]!==d?(u=(0,o.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t?(f=(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,o.jsx)(at,{initialShardKey:r})}):(0,o.jsx)(qt,{pane:t,shardKey:r})}),e[5]=r,e[6]=t,e[7]=f):f=e[7];let g;return e[8]!==u||e[9]!==f?(g=(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,f]}),e[8]=u,e[9]=f,e[10]=g):g=e[10],g},"je");export{la as MigrationsRoutePanel};
|
|
1
|
+
import{a as et}from"./chunk-YTA2HGRD.js";import"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Re}from"./chunk-5Y3QLNWX.js";import{a as Ze}from"./chunk-CTNB2KIA.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as Ye}from"./chunk-QXXIJAD5.js";import{a as ze}from"./chunk-X665E2HU.js";import{b as We}from"./chunk-GRL5MG3Z.js";import{d as Ke,e as _e}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{a as He}from"./chunk-LFKCLLPT.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as Le}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Ee}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as $e}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{a as T}from"./chunk-ERMTJYQF.js";import{c as de}from"./chunk-XDAT7LHC.js";import{f as Fe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as ke}from"./chunk-XQCVZAGU.js";import{a as Ge,b as Qe,c as Xe,d as Ie,e as M,f as I}from"./chunk-MIQTKZAR.js";import{a as Je,e as Pe}from"./chunk-UZERI5YC.js";import{d as oe,f as Be,g as Ue,h as Ve,m as Ne,q as we}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as m,e as ie,f as Ce,g as Te,h as De,j as se}from"./chunk-3XIESWL4.js";var me=ie(Te(),1),ce=ie(Ce(),1);var tt=ie(Te(),1);var $=ie(Ce(),1);var l=ie(De(),1);var mt=Be(T.runMigration),at=m(a=>{let e=(0,tt.c)(99),{initialShardKey:r}=a,n=Fe(),t=oe(),[i,s]=(0,$.useState)(r??""),[d,u]=(0,$.useState)(""),[f,g]=(0,$.useState)("up"),[h,x]=(0,$.useState)(!0),[p,v]=(0,$.useState)(!1),[b,y]=(0,$.useState)(null),[c,j]=(0,$.useState)(null),k;e[0]!==i?(k=i.trim(),e[0]=i,e[1]=k):k=e[1];let N=He(k,400),R;e[2]!==i?(R=i.trim(),e[2]=i,e[3]=R):R=e[3];let O=R===N,q;e[4]===Symbol.for("react.memo_cache_sentinel")?(q={},e[4]=q):q=e[4];let ue;e[5]!==N?(ue={live:!0,shardKey:N},e[5]=N,e[6]=ue):ue=e[6];let w=de(T.migrationStatus,q,ue),S=w.data?.migrations??null,je=w.error,{errorSource:Se,liveError:Oe}=w,he,pe;e[7]!==N||e[8]!==w.data?(he=m(()=>{w.data!==void 0&&We(N)},"H"),pe=[w.data,N],e[7]=N,e[8]=w.data,e[9]=he,e[10]=pe):(he=e[9],pe=e[10]),(0,$.useEffect)(he,pe);let fe;if(e[11]!==n||e[12]!==f||e[13]!==h||e[14]!==d||e[15]!==i||e[16]!==w||e[17]!==t){let C=m(async()=>{let qe=d.trim();if(qe===""){j(t("Enter a migration id")),y(null);return}v(!0),j(null);try{let Me=await n.query(mt,{direction:f,dryRun:h,id:qe},Ue(i));y(Me),w.refetch()}catch(Me){let ct=Me;y(null),j(Ve(ct))}v(!1)},"m");fe=m(()=>{Ne(C())},"X"),e[11]=n,e[12]=f,e[13]=h,e[14]=d,e[15]=i,e[16]=w,e[17]=t,e[18]=fe}else fe=e[18];let ge=fe,be;e[19]===Symbol.for("react.memo_cache_sentinel")?(be=m(C=>{u(C.target.value)},"Z"),e[19]=be):be=e[19];let ot=be,ve;e[20]===Symbol.for("react.memo_cache_sentinel")?(ve=m(C=>{g(C.target.value==="down"?"down":"up")},"ee"),e[20]=ve):ve=e[20];let dt=ve,xe;e[21]===Symbol.for("react.memo_cache_sentinel")?(xe=m(C=>{x(C.target.checked)},"re"),e[21]=xe):xe=e[21];let lt=xe,D;e[22]!==i?(D=(0,l.jsx)(ze,{onChange:s,testId:"mg-shard-input",value:i}),e[22]=i,e[23]=D):D=e[23];let F;e[24]!==Oe?(F=(0,l.jsx)(Ze,{message:Oe,prefix:"mg"}),e[24]=Oe,e[25]=F):F=e[25];let K;e[26]!==D||e[27]!==F?(K=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[D,F]}),e[26]=D,e[27]=F,e[28]=K):K=e[28];let _;e[29]!==je||e[30]!==Se?(_=je!==null&&(0,l.jsx)($e,{error:Se,testId:"mg-status-error"}),e[29]=je,e[30]=Se,e[31]=_):_=e[31];let E;e[32]!==S||e[33]!==t?(E=S!==null&&S.length===0&&(0,l.jsx)(ke,{description:t("Data migrations you run against this shard will be tracked here."),icon:(0,l.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:t("No migrations have run on this shard.")}),e[32]=S,e[33]=t,e[34]=E):E=e[34];let A;e[35]!==S||e[36]!==t?(A=S!==null&&S.length>0&&(0,l.jsx)(Je,{className:"overflow-hidden py-0",children:(0,l.jsx)(Pe,{className:"px-0",children:(0,l.jsxs)(Ge,{"data-testid":"mg-table",children:[(0,l.jsx)(Qe,{children:(0,l.jsxs)(Ie,{children:[(0,l.jsx)(M,{children:t("id")}),(0,l.jsx)(M,{children:t("direction")}),(0,l.jsx)(M,{children:t("status")}),(0,l.jsx)(M,{children:t("processed")}),(0,l.jsx)(M,{children:t("changed")}),(0,l.jsx)(M,{children:t("updated")}),(0,l.jsx)(M,{children:t("error")})]})}),(0,l.jsx)(Xe,{children:S.map(ut)})]})})}),e[35]=S,e[36]=t,e[37]=A):A=e[37];let L;e[38]!==t?(L=t("Run migration"),e[38]=t,e[39]=L):L=e[39];let J;e[40]!==L?(J=(0,l.jsx)(Re,{children:L}),e[40]=L,e[41]=J):J=e[41];let P;e[42]!==t?(P=t("Migration id"),e[42]=t,e[43]=P):P=e[43];let B;e[44]!==t?(B=t("migration id"),e[44]=t,e[45]=B):B=e[45];let U;e[46]!==d||e[47]!==P||e[48]!==B?(U=(0,l.jsx)(Ae,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:ot,placeholder:B,value:d}),e[46]=d,e[47]=P,e[48]=B,e[49]=U):U=e[49];let V;e[50]!==t?(V=t("Direction"),e[50]=t,e[51]=V):V=e[51];let W;e[52]!==t?(W=t("up"),e[52]=t,e[53]=W):W=e[53];let z;e[54]!==W?(z=(0,l.jsx)("option",{value:"up",children:W}),e[54]=W,e[55]=z):z=e[55];let H;e[56]!==t?(H=t("down"),e[56]=t,e[57]=H):H=e[57];let G;e[58]!==H?(G=(0,l.jsx)("option",{value:"down",children:H}),e[58]=H,e[59]=G):G=e[59];let Q;e[60]!==f||e[61]!==V||e[62]!==z||e[63]!==G?(Q=(0,l.jsxs)("select",{"aria-label":V,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:dt,value:f,children:[z,G]}),e[60]=f,e[61]=V,e[62]=z,e[63]=G,e[64]=Q):Q=e[64];let X;e[65]!==h?(X=(0,l.jsx)("input",{checked:h,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:lt,type:"checkbox"}),e[65]=h,e[66]=X):X=e[66];let Y;e[67]!==t?(Y=t("Dry run"),e[67]=t,e[68]=Y):Y=e[68];let Z;e[69]!==X||e[70]!==Y?(Z=(0,l.jsxs)(Re,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[X,Y]}),e[69]=X,e[70]=Y,e[71]=Z):Z=e[71];let ee;e[72]!==h||e[73]!==ge||e[74]!==p||e[75]!==O||e[76]!==t?(ee=h?(0,l.jsx)(Le,{"data-testid":"mg-run",disabled:p||!O,onClick:ge,type:"button",children:t(p?"Running\u2026":"Run")}):(0,l.jsx)(Ye,{confirmLabel:t(p?"Running\u2026":"Run migration?"),disabled:p||!O,onConfirm:ge,testId:"mg-run",children:t("Run")}),e[72]=h,e[73]=ge,e[74]=p,e[75]=O,e[76]=t,e[77]=ee):ee=e[77];let te;e[78]!==U||e[79]!==Q||e[80]!==Z||e[81]!==ee?(te=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[U,Q,Z,ee]}),e[78]=U,e[79]=Q,e[80]=Z,e[81]=ee,e[82]=te):te=e[82];let ae;e[83]!==J||e[84]!==te?(ae=(0,l.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[J,te]}),e[83]=J,e[84]=te,e[85]=ae):ae=e[85];let re;e[86]!==c?(re=c!==null&&(0,l.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:c}),e[86]=c,e[87]=re):re=e[87];let ne;e[88]!==b||e[89]!==t?(ne=b!==null&&(0,l.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[b.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:b.status}),b.processed,t(", changed"),b.changed]}),e[88]=b,e[89]=t,e[90]=ne):ne=e[90];let ye;return e[91]!==K||e[92]!==_||e[93]!==E||e[94]!==A||e[95]!==ae||e[96]!==re||e[97]!==ne?(ye=(0,l.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,_,E,A,ae,re,ne]}),e[91]=K,e[92]=_,e[93]=E,e[94]=A,e[95]=ae,e[96]=re,e[97]=ne,e[98]=ye):ye=e[98],ye},"vr");function ut(a){return(0,l.jsxs)(Ie,{"data-testid":`mg-row-${a.id}`,children:[(0,l.jsx)(I,{children:a.id}),(0,l.jsx)(I,{children:a.direction}),(0,l.jsx)(I,{children:(0,l.jsx)(Ee,{variant:"secondary",children:a.status})}),(0,l.jsx)(I,{children:a.processed}),(0,l.jsx)(I,{children:a.changed}),(0,l.jsx)(I,{children:we(a.updatedAt)}),(0,l.jsx)(I,{children:a.error??""})]},a.id)}m(ut,"Qe");var o=ie(De(),1);var le=m(a=>typeof a=="object"&&a!==null,"k"),ht=m(a=>le(a)&&le(a.fields)&&le(a.indexes)&&le(a.relations)&&typeof a.shardMode=="string","z"),pt=m(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!le(e)||e.version!==1||!le(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!ht(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},"B"),ft=m((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((r,n)=>r===e.fields[n]),"L"),gt=m((a,e,r,n)=>{let t=[];return r.kind!==n.kind&&t.push({severity:"breaking",summary:`field ${a}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`,table:a,scope:"table",type:"changedFieldKind"}),r.optional&&!n.optional?t.push({severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&t.push({scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"Q"),bt=m((a,e,r)=>r.optional?{scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"G"),vt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.fields)){let s=e.fields[t];s===void 0?n.push(bt(a,t,i)):n.push(...gt(a,t,s,i))}for(let t of Object.keys(e.fields))r.fields[t]===void 0&&n.push({severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"X"),xt=m((a,e,r,n)=>{for(let[t,i]of Object.entries(r.indexes)){let s=e.indexes[t];if(s===void 0){n.push({scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}ft(s,i)||n.push({severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))r.indexes[t]===void 0&&n.push({severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"Y"),yt=m((a,e,r,n)=>{for(let t of Object.keys(r.relations))e.relations[t]===void 0&&n.push({scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))r.relations[t]===void 0&&n.push({scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"Z"),kt=m((a,e,r,n)=>{e.shardMode!==r.shardMode&&n.push({severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${r.shardMode} \u2014 its physical storage moves; add a data migration / re-shard plan`,table:a,scope:"table",type:"changedShardMode"}),vt(a,e,r,n),xt(a,e,r,n),yt(a,e,r,n)},"ee"),Nt=m((a,e)=>{let r=[],n=a?.tables??{};for(let[t,i]of Object.entries(e.tables)){let s=n[t];if(s===void 0){r.push({scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}kt(t,s,i,r)}for(let t of Object.keys(n))e.tables[t]===void 0&&r.push({scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 add a data migration if its data must be archived/cleaned up`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",i=e.jurisdiction??"(none)";r.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${i} \u2014 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:r}},"te"),rt=m(a=>Object.entries(a.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(a.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:r.kind})),"T"),nt=m((a,e)=>{let r={},n=a?.fields??{},t=e?.fields??{};for(let[i,s]of Object.entries(t)){let d=n[i];d===void 0?r[i]=a===void 0?"unchanged":"added":r[i]=d.kind===s.kind&&d.optional===s.optional?"unchanged":"changed"}for(let i of Object.keys(n))t[i]===void 0&&(r[i]="removed");return r},"F"),wt=m((a,e)=>{let{changes:r}=Nt(a,e),n=new Set(r.filter(s=>s.scope==="table"&&s.table!==void 0).map(s=>s.table)),t=[],i=m((s,d)=>s?"added":n.has(d)?"changed":"context","o");for(let[s,d]of Object.entries(e.tables)){let u=a?.tables[s],f=i(u===void 0,s);t.push({columns:rt(d),fieldStatus:nt(u,d),name:s,shardMode:d.shardMode,status:f})}for(let[s,d]of Object.entries(a?.tables??{}))e.tables[s]===void 0&&t.push({columns:rt(d),fieldStatus:nt(d,void 0),name:s,shardMode:d.shardMode,status:"removed"});return t.sort((s,d)=>s.name.localeCompare(d.name)),{breakingCount:r.filter(s=>s.severity==="breaking").length,changes:r,tables:t}},"ae"),it=m(a=>{let e=pt(a);return e.status==="ok"?e.snapshot:void 0},"A"),$t={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"},jt=m(a=>a==="global"?"global":"shard","se"),St=m(a=>{let e=(0,me.c)(24),{appliedAt:r,hash:n,onSelect:t,selected:i,seq:s}=a,d=i?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=se("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=u):u=e[1];let f=`sh-version-${n}`,g;e[2]!==n||e[3]!==t?(g=m(()=>{t(n)},"m"),e[2]=n,e[3]=t,e[4]=g):g=e[4];let h;e[5]!==s?(h=(0,o.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",s]}),e[5]=s,e[6]=h):h=e[6];let x;e[7]!==n?(x=n.slice(0,7),e[7]=n,e[8]=x):x=e[8];let p;e[9]!==x?(p=(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:x}),e[9]=x,e[10]=p):p=e[10];let v;e[11]!==h||e[12]!==p?(v=(0,o.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[h,p]}),e[11]=h,e[12]=p,e[13]=v):v=e[13];let b;e[14]!==r?(b=we(r),e[14]=r,e[15]=b):b=e[15];let y;e[16]!==b?(y=(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:b}),e[16]=b,e[17]=y):y=e[17];let c;return e[18]!==y||e[19]!==u||e[20]!==f||e[21]!==g||e[22]!==v?(c=(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:u,"data-testid":f,onClick:g,type:"button",children:[v,y]})}),e[18]=y,e[19]=u,e[20]=f,e[21]=g,e[22]=v,e[23]=c):c=e[23],c},"ie"),Ot=m(a=>{let e=(0,me.c)(26),{breaking:r,count:n,first:t}=a,i=oe();if(t){let p;e[0]!==n?(p=(0,o.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=p):p=e[1];let v;e[2]!==i?(v=i("tables"),e[2]=i,e[3]=v):v=e[3];let b;e[4]!==v?(b=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=b):b=e[5];let y;return e[6]!==p||e[7]!==b?(y=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[p,b]}),e[6]=p,e[7]=b,e[8]=y):y=e[8],y}let s=r>0&&"text-destructive",d;e[9]!==s?(d=se("text-3xl leading-none font-light tracking-tight tabular-nums",s),e[9]=s,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,o.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let f;e[14]!==n||e[15]!==i?(f=i(n===1?"change":"changes"),e[14]=n,e[15]=i,e[16]=f):f=e[16];let g;e[17]!==f?(g=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=g):g=e[18];let h;e[19]!==r||e[20]!==i?(h=r>0&&(0,o.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",i("{count} breaking",{count:r})]}),e[19]=r,e[20]=i,e[21]=h):h=e[21];let x;return e[22]!==u||e[23]!==g||e[24]!==h?(x=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,g,h]}),e[22]=u,e[23]=g,e[24]=h,e[25]=x):x=e[25],x},"re"),st={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"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},Mt=m((a,e)=>{let r=`${st[a.type].action} ${e} `;return a.summary.startsWith(r)?a.summary.slice(r.length):a.summary},"oe"),It=m(a=>{let e=new Map;for(let n of a){let t=n.table??"",i=e.get(t);i===void 0?e.set(t,[n]):i.push(n)}let r=[...e].map(([n,t])=>({changes:t,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"de"),Rt=m(a=>{let e=(0,me.c)(2),{children:r}=a,n;return e[0]!==r?(n=(0,o.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"le"),qt=m(({pane:a,shardKey:e=""})=>{let r=oe(),n=_e(),t=Ke({strict:!1}).version,i=m(c=>{Ne(n({search:{version:c},to:"/migrations"}))},"o"),s=de(T.schemaHistory,{},{shardKey:e}),d=s.data?.versions??[],u=t!==void 0&&d.some(c=>c.hash===t)?t:d[0]?.hash,f=d.findIndex(c=>c.hash===u),g=f===-1?void 0:d[f+1]?.hash,h=de(T.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),x=de(T.schemaVersion,{hash:g??""},{enabled:g!==void 0,shardKey:e}),p=(0,ce.useMemo)(()=>{let c=it(h.data?.version?.snapshotJson);if(c!==void 0)return wt(it(x.data?.version?.snapshotJson),c)},[h.data,x.data]),v=(0,ce.useMemo)(()=>(p?.tables??[]).map(c=>({columns:c.columns,name:c.name,tier:jt(c.shardMode)})),[p]),b=(0,ce.useMemo)(()=>{let c={};for(let j of p?.tables??[])c[j.name]=$t[j.status];return c},[p]);if(s.error!==null)return(0,o.jsx)($e,{error:s.errorSource,testId:"sh-error"});if(d.length===0)return(0,o.jsx)(ke,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let y=p?.changes??[];return(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,o.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,o.jsx)(Rt,{children:r("Schema versions")}),(0,o.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(c=>(0,o.jsx)(St,{appliedAt:c.appliedAt,hash:c.hash,onSelect:i,selected:c.hash===u,seq:c.seq},c.hash))})]}),(0,o.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,o.jsx)(Ot,{breaking:p?.breakingCount??0,count:g===void 0?v.length:y.length,first:g===void 0}),a==="diagram"?(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,o.jsx)(et,{fill:!0,nodeClasses:b,tables:v,testIdPrefix:"sh"})}):(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:It(y).map(c=>{let j=(p?.tables??[]).find(k=>k.name===c.table);return(0,o.jsxs)("section",{className:"mb-6",children:[(0,o.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,o.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:c.table===""?r("schema"):c.table}),j!==void 0&&(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:j.columns.length})}),c.changes.length>1&&(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:c.changes.length})]}),(0,o.jsx)("ul",{children:c.changes.map(k=>{let{action:N,kind:R}=st[k.type],O=k.severity==="breaking",q=Mt(k,R);return(0,o.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,o.jsx)("span",{"aria-hidden":"true",className:se("-ms-3 h-3 w-0.5 shrink-0 self-center",O?"bg-destructive":"bg-transparent")}),(0,o.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(N)," ",R]}),q!==c.table&&(0,o.jsx)("span",{className:se("min-w-0 font-mono text-[13px]",O?"text-destructive":"text-foreground"),children:q}),O&&(0,o.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},c.table)})})]})]})},"ce"),Ct=m(a=>se("-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",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"me"),la=m(a=>{let e=(0,me.c)(11),{initialShardKey:r}=a,n=oe(),[t,i]=(0,ce.useState)("diagram"),s;e[0]!==t?(s=m((h,x,p,v)=>(0,o.jsxs)("button",{"aria-selected":t===h,className:Ct(t===h),"data-testid":p,onClick:m(()=>{i(h)},"onClick"),role:"tab",type:"button",children:[x,v!==void 0&&(0,o.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"i"),e[0]=t,e[1]=s):s=e[1];let d=s,u;e[2]!==n||e[3]!==d?(u=(0,o.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t?(f=(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,o.jsx)(at,{initialShardKey:r})}):(0,o.jsx)(qt,{pane:t,shardKey:r})}),e[5]=r,e[6]=t,e[7]=f):f=e[7];let g;return e[8]!==u||e[9]!==f?(g=(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,f]}),e[8]=u,e[9]=f,e[10]=g):g=e[10],g},"je");export{la as MigrationsRoutePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-QXXIJAD5.js";import{b as E}from"./chunk-XDAT7LHC.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-MIQTKZAR.js";import{a as B,e as D}from"./chunk-UZERI5YC.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as _}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{d as A,h as O,m as T,q as X}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[b,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),v=b??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==v?.length||e[10]!==r?(S=v?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=v?.length,e[10]=r,e[11]=S):S=e[11];let $=v!==void 0&&v.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:v.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,b=me(i,a,e),n=c(async s=>{if(b!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await b(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),b!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),b!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let b;e[3]!==l||e[4]!==d?(b=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(ve),"h"),e[3]=l,e[4]=d,e[5]=b):b=e[5];let n=E(N,b),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let v=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=v!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==v||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(v(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=v,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function ve(a,e){return(e.attempts??0)-(a.attempts??0)}c(ve,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),be=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let b=E(o,N),{data:n,error:s}=b,m;e[7]!==b?(m=c(()=>{b.refetch()},"s"),e[7]=b,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let v;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=v):v=e[24],v},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),b;e[2]!==l?(b=l("Cron triggers"),e[2]=l,e[3]=b):b=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==b||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:b,dead:n,jobs:s,pools:m},e[10]=b,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,v;e[16]!==l?(v=l("Schedule view"),e[16]=l,e[17]=v):v=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==v||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=v,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(be,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
|
|
1
|
+
import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-QXXIJAD5.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as E}from"./chunk-XDAT7LHC.js";import{f as _}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-MIQTKZAR.js";import{a as B,e as D}from"./chunk-UZERI5YC.js";import{d as A,h as O,m as T,q as X}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[b,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),v=b??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==v?.length||e[10]!==r?(S=v?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=v?.length,e[10]=r,e[11]=S):S=e[11];let $=v!==void 0&&v.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:v.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,b=me(i,a,e),n=c(async s=>{if(b!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await b(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),b!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),b!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let b;e[3]!==l||e[4]!==d?(b=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(ve),"h"),e[3]=l,e[4]=d,e[5]=b):b=e[5];let n=E(N,b),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let v=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=v!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==v||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(v(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=v,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function ve(a,e){return(e.attempts??0)-(a.attempts??0)}c(ve,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),be=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let b=E(o,N),{data:n,error:s}=b,m;e[7]!==b?(m=c(()=>{b.refetch()},"s"),e[7]=b,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let v;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=v):v=e[24],v},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),b;e[2]!==l?(b=l("Cron triggers"),e[2]=l,e[3]=b):b=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==b||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:b,dead:n,jobs:s,pools:m},e[10]=b,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,v;e[16]!==l?(v=l("Schedule view"),e[16]=l,e[17]=v):v=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==v||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=v,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(be,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ze}from"./chunk-YTA2HGRD.js";import{a as Me,b as Ve}from"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as _e}from"./chunk-5Y3QLNWX.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as He}from"./chunk-X665E2HU.js";import{b as Xe}from"./chunk-GRL5MG3Z.js";import{e as Qe}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{a as Ye}from"./chunk-LFKCLLPT.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ge}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Fe}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as qe}from"./chunk-ERMTJYQF.js";import{f as Je}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as We}from"./chunk-XQCVZAGU.js";import{a as Oe,b as Pe,c as Ge,d as Le,e as Ke}from"./chunk-UZERI5YC.js";import{d as Ee,f as ze,g as $e,h as je,m as pe}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as r,e as De,f as nt,g as st,h as rt,j as Re}from"./chunk-3XIESWL4.js";var we=De(st(),1);var f=De(nt(),1);var t=De(rt(),1);var ot=ze(qe.listTables),it=ze(qe.listTableIndexes),dt=ze(qe.readTablePage),ct=ze(qe.describeTables),mt={},Be=[],ut=r(s=>{let e=(0,we.c)(75),{initialShardKey:u,initialTable:n}=s,l=Je(),[a,c]=(0,f.useState)("graph"),[i,d]=(0,f.useState)(u??""),[h,m]=(0,f.useState)(""),[o,p]=(0,f.useState)(null),[C,b]=(0,f.useState)(null),z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z={},e[0]=z):z=e[0];let[_,ce]=(0,f.useState)(z),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let[O,$]=(0,f.useState)(v),[E,k]=(0,f.useState)(null),w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w={},e[2]=w):w=e[2];let[I,P]=(0,f.useState)(w),B;e[3]===Symbol.for("react.memo_cache_sentinel")?(B={},e[3]=B):B=e[3];let[me,A]=(0,f.useState)(B),[y,xe]=(0,f.useState)(null),[G,ue]=(0,f.useState)(null),ee;e[4]===Symbol.for("react.memo_cache_sentinel")?(ee={},e[4]=ee):ee=e[4];let[J,Ne]=(0,f.useState)(ee),[Q,fe]=(0,f.useState)(null),W;e[5]!==l?(W=r(async g=>{b(null);try{let N=await l.query(ot,{},$e(g));Xe(g),p(N),ce({}),$({}),k(null),P(T=>Object.fromEntries(Object.entries(T).filter(F=>{let[S]=F;return S!==g}))),A(T=>Object.fromEntries(Object.entries(T).filter(F=>{let[S]=F;return S!==g})))}catch(N){let T=N;p(null),b(je(T))}},"Y"),e[5]=l,e[6]=W):W=e[6];let te=W,L;e[7]!==l?(L=r(async()=>{ue(null);try{xe(await l.listGlobalTables())}catch(g){let N=g;xe(null),ue(je(N))}},"L"),e[7]=l,e[8]=L):L=e[8];let le=L,ae;e[9]!==i?(ae=i.trim(),e[9]=i,e[10]=ae):ae=e[10];let he=Ye(ae,400),K,ne;e[11]!==he||e[12]!==te||e[13]!==le?(ne=r(()=>{pe(te(he)),pe(le())},"ne"),K=[te,le,he],e[11]=he,e[12]=te,e[13]=le,e[14]=K,e[15]=ne):(K=e[14],ne=e[15]),(0,f.useEffect)(ne,K);let M;e[16]!==l||e[17]!==_||e[18]!==E||e[19]!==i?(M=r(async g=>{if(E===g){k(null);return}k(g);let N=`${i}:${g}`;if(_[N]!==void 0)return;let[T,F]=await Promise.allSettled([l.query(dt,{limit:1,offset:0,table:g},$e(i)),l.query(it,{table:g},$e(i))]);T.status==="fulfilled"?ce(S=>({...S,[N]:T.value.columns})):b(je(T.reason)),F.status==="fulfilled"&&$(S=>({...S,[N]:F.value.indexes}))},"M"),e[16]=l,e[17]=_,e[18]=E,e[19]=i,e[20]=M):M=e[20];let se=M,re;e[21]!==l||e[22]!==J||e[23]!==Q?(re=r(async g=>{if(Q===g){fe(null);return}if(fe(g),J[g]===void 0)try{let N=await l.readGlobalTablePage({limit:1,offset:0,table:g});Ne(T=>({...T,[g]:N.columns}))}catch(N){ue(je(N))}},"re"),e[21]=l,e[22]=J,e[23]=Q,e[24]=re):re=e[24];let be=re,X=(0,f.useRef)(void 0),H,D;e[25]!==n||e[26]!==o||e[27]!==se?(H=r(()=>{n===void 0||o===null||X.current===n||o.some(g=>g.name===n)&&(X.current=n,pe(se(n)))},"J"),D=[n,o,se],e[25]=n,e[26]=o,e[27]=se,e[28]=H,e[29]=D):(H=e[28],D=e[29]),(0,f.useEffect)(H,D);let oe;e[30]!==l?(oe=r(async(g,N,T)=>{let[F,S]=await Promise.all([Promise.allSettled([l.query(ct,{tables:[...N,...T]},$e(g))]),Promise.all(T.map(async U=>{let Te=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:U})]),Ue=Te[0].status==="fulfilled"?Te[0].value:void 0;return{columns:Ue?.columns??[],refs:Ue?.refs??{},table:U}}))]),ke=F[0].status==="fulfilled"?F[0].value?.columnsByTable??{}:{},Se=F[0].status==="rejected",Ie=new Map(S.map(ht)),q=[...N,...T].map(U=>{let Te=ke[U]??[];return[U,Te.length>0?Te:Ie.get(U)??[]]});P(U=>({...U,[g]:Object.fromEntries(q)})),A(U=>({...U,[g]:Se}))},"oe"),e[30]=l,e[31]=oe):oe=e[31];let R=oe,ie,V;e[32]!==G||e[33]!==y||e[34]!==R||e[35]!==I||e[36]!==i||e[37]!==o||e[38]!==a?(ie=r(()=>{a!=="graph"||o===null||y===null&&G===null||I[i]!==void 0||pe(R(i,o.map(bt),(y??[]).map(gt)))},"ie"),V=[a,o,y,G,i,I,R],e[32]=G,e[33]=y,e[34]=R,e[35]=I,e[36]=i,e[37]=o,e[38]=a,e[39]=ie,e[40]=V):(ie=e[39],V=e[40]),(0,f.useEffect)(ie,V);let j=I[i]??mt,Y;if(e[41]!==j||e[42]!==y||e[43]!==o){let g;e[45]!==j?(g=r(S=>({columns:j[S.name]??Be,name:S.name,tier:"shard"}),"p"),e[45]=j,e[46]=g):g=e[46];let N=(o??[]).map(g),T;e[47]!==j?(T=r(S=>({columns:j[S.name]??Be,name:S.name,tier:"global"}),"T"),e[47]=j,e[48]=T):T=e[48];let F=(y??[]).map(T);Y=[...N,...F],e[41]=j,e[42]=y,e[43]=o,e[44]=Y}else Y=e[44];let x=Y,Z;if(e[49]!==h||e[50]!==o){let g=h.trim().toLowerCase();Z=(o??[]).filter(N=>N.name.toLowerCase().includes(g)),e[49]=h,e[50]=o,e[51]=Z}else Z=e[51];let de=Z,ve;if(e[52]!==y||e[53]!==h){let g=h.trim().toLowerCase();ve=(y??[]).filter(N=>N.name.toLowerCase().includes(g)),e[52]=y,e[53]=h,e[54]=ve}else ve=e[54];let Ce=ve,ye;return e[55]!==_||e[56]!==x||e[57]!==C||e[58]!==E||e[59]!==Ce||e[60]!==de||e[61]!==J||e[62]!==G||e[63]!==Q||e[64]!==y||e[65]!==O||e[66]!==te||e[67]!==me||e[68]!==i||e[69]!==h||e[70]!==o||e[71]!==se||e[72]!==be||e[73]!==a?(ye={columns:_,diagramTables:x,error:C,expanded:E,filteredGlobalTables:Ce,filteredTables:de,globalColumns:J,globalError:G,globalExpanded:Q,globalTables:y,indexes:O,refresh:te,setShardKey:d,setTableFilter:m,setView:c,shardColumnsError:me,shardKey:i,tableFilter:h,tables:o,toggle:se,toggleGlobal:be,view:a},e[55]=_,e[56]=x,e[57]=C,e[58]=E,e[59]=Ce,e[60]=de,e[61]=J,e[62]=G,e[63]=Q,e[64]=y,e[65]=O,e[66]=te,e[67]=me,e[68]=i,e[69]=h,e[70]=o,e[71]=se,e[72]=be,e[73]=a,e[74]=ye):ye=e[74],ye},"mt");function ht(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ht,"ut");function bt(s){return s.name}r(bt,"ht");function gt(s){return s.name}r(gt,"pt");var pt="/__lunora/schema-edit",xt=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"bt"),ft=r(s=>{let e=(0,we.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:c,onDestructive:i}=s,d=Ee(),h=n==="addTable"?"default":"outline",m;e[0]!==d?(m=d("Add table"),e[0]=d,e[1]=m):m=e[1];let o;e[2]!==c||e[3]!==h||e[4]!==m?(o=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:h,children:m}),e[2]=c,e[3]=h,e[4]=m,e[5]=o):o=e[5];let p=!u,C=n==="addColumn"?"default":"outline",b;e[6]!==d?(b=d("Add column"),e[6]=d,e[7]=b):b=e[7];let z;e[8]!==l||e[9]!==p||e[10]!==C||e[11]!==b?(z=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-column",disabled:p,onClick:l,size:"xs",type:"button",variant:C,children:b}),e[8]=l,e[9]=p,e[10]=C,e[11]=b,e[12]=z):z=e[12];let _=!u,ce=n==="addIndex"?"default":"outline",v;e[13]!==d?(v=d("Add index"),e[13]=d,e[14]=v):v=e[14];let O;e[15]!==a||e[16]!==v||e[17]!==_||e[18]!==ce?(O=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:ce,children:v}),e[15]=a,e[16]=v,e[17]=_,e[18]=ce,e[19]=O):O=e[19];let $=!u,E=n==="destructive"?"default":"ghost",k;e[20]!==d?(k=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=k):k=e[21];let w;e[22]!==i||e[23]!==$||e[24]!==E||e[25]!==k?(w=(0,t.jsx)(ge,{"data-testid":"sc-editor-destructive",disabled:$,onClick:i,size:"xs",type:"button",variant:E,children:k}),e[22]=i,e[23]=$,e[24]=E,e[25]=k,e[26]=w):w=e[26];let I;return e[27]!==O||e[28]!==w||e[29]!==o||e[30]!==z?(I=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[o,z,O,w]}),e[27]=O,e[28]=w,e[29]=o,e[30]=z,e[31]=I):I=e[31],I},"ft"),vt=r(s=>{let e=(0,we.c)(28),{onOpenMigrations:u,result:n}=s,l=Ee();if(n===null){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(t.Fragment,{}),e[0]=m):m=e[0],m}if(n.kind==="error"){let m;return e[1]!==n.message?(m=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=m):m=e[2],m}if(n.kind==="needs-migration"){let m;e[3]!==n.message||e[4]!==l?(m=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=m):m=e[5];let o;e[6]!==m?(o=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:m}),e[6]=m,e[7]=o):o=e[7];let p;e[8]!==l?(p=l("Open Migrations"),e[8]=l,e[9]=p):p=e[9];let C;e[10]!==u||e[11]!==p?(C=(0,t.jsx)(ge,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:p}),e[10]=u,e[11]=p,e[12]=C):C=e[12];let b;return e[13]!==o||e[14]!==C?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[o,C]}),e[13]=o,e[14]=C,e[15]=b):b=e[15],b}if(n.diagnostics.length===0){let m;return e[16]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(t.Fragment,{}),e[16]=m):m=e[16],m}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let c;e[19]!==a?(c=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=c):c=e[20];let i;e[21]!==n.diagnostics?(i=n.diagnostics.map(yt),e[21]=n.diagnostics,e[22]=i):i=e[22];let d;e[23]!==i?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:i}),e[23]=i,e[24]=d):d=e[24];let h;return e[25]!==c||e[26]!==d?(h=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,d]}),e[25]=c,e[26]=d,e[27]=h):h=e[27],h},"xt");function yt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(yt,"vt");var Nt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",wt=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),Tt=r(s=>{let e=(0,we.c)(83),{onApplied:u,tableNames:n}=s,l=Ee(),a=Qe(),[c,i]=(0,f.useState)(null),[d,h]=(0,f.useState)(!1),[m,o]=(0,f.useState)(null),[p,C]=(0,f.useState)(""),[b,z]=(0,f.useState)(""),[_,ce]=(0,f.useState)(Ct),[v,O]=(0,f.useState)(n[0]??""),[$,E]=(0,f.useState)(""),[k,w]=(0,f.useState)(""),[I,P]=(0,f.useState)(!1),B;e[0]===Symbol.for("react.memo_cache_sentinel")?(B=r(()=>{i(null),C(""),z(""),E(""),w(""),P(!1)},"Z"),e[0]=B):B=e[0];let me=B,A;e[1]!==u?(A=r(async q=>{h(!0),o(null);try{let U=await xt(q);o(U),U.kind==="ok"&&(u(U.tables),me())}catch(U){let Te=U;o({kind:"error",message:Te instanceof Error?Te.message:String(Te)})}h(!1)},"I"),e[1]=u,e[2]=A):A=e[2];let y=A,xe;e[3]!==y||e[4]!==p?(xe=r(()=>{pe(y({kind:"addTable",table:p.trim()}))},"ge"),e[3]=y,e[4]=p,e[5]=xe):xe=e[5];let G=xe,ue;e[6]!==b||e[7]!==y||e[8]!==v||e[9]!==_?(ue=r(()=>{pe(y({column:b.trim(),kind:"addOptionalColumn",table:v,validator:_}))},"ue"),e[6]=b,e[7]=y,e[8]=v,e[9]=_,e[10]=ue):ue=e[10];let ee=ue,J;e[11]!==k||e[12]!==$||e[13]!==y||e[14]!==v||e[15]!==I?(J=r(()=>{pe(y({fields:wt(k),kind:"addIndex",name:$.trim(),table:v,unique:I}))},"U"),e[11]=k,e[12]=$,e[13]=y,e[14]=v,e[15]=I,e[16]=J):J=e[16];let Ne=J,Q;e[17]===Symbol.for("react.memo_cache_sentinel")?(Q=r(()=>{o(null),i("addTable")},"X"),e[17]=Q):Q=e[17];let fe=Q,W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=r(()=>{o(null),i("addColumn")},"Y"),e[18]=W):W=e[18];let te=W,L;e[19]===Symbol.for("react.memo_cache_sentinel")?(L=r(()=>{o(null),i("addIndex")},"L"),e[19]=L):L=e[19];let le=L,ae;e[20]!==l?(ae=r(()=>{i("destructive"),o({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ae"),e[20]=l,e[21]=ae):ae=e[21];let he=ae,K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=r(q=>{C(q.target.value)},"K"),e[22]=K):K=e[22];let ne=K,M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=r(q=>{z(q.target.value)},"M"),e[23]=M):M=e[23];let se=M,re;e[24]===Symbol.for("react.memo_cache_sentinel")?(re=r(q=>{ce(q.target.value)},"re"),e[24]=re):re=e[24];let be=re,X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=r(q=>{O(q.target.value)},"H"),e[25]=X):X=e[25];let H=X,D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=r(q=>{E(q.target.value)},"D"),e[26]=D):D=e[26];let oe=D,R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=r(q=>{w(q.target.value)},"R"),e[27]=R):R=e[27];let ie=R,V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=r(q=>{P(q.target.checked)},"V"),e[28]=V):V=e[28];let j=V,Y;e[29]!==a?(Y=r(()=>{pe(a({to:"/migrations"}))},"W"),e[29]=a,e[30]=Y):Y=e[30];let x=Y,Z;e[31]!==l?(Z=l("Edit schema"),e[31]=l,e[32]=Z):Z=e[32];let de;e[33]!==Z?(de=(0,t.jsx)(Ge,{children:Z}),e[33]=Z,e[34]=de):de=e[34];let ve;e[35]!==l?(ve=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=ve):ve=e[36];let Ce;e[37]!==ve?(Ce=(0,t.jsx)(Le,{children:ve}),e[37]=ve,e[38]=Ce):Ce=e[38];let ye;e[39]!==de||e[40]!==Ce?(ye=(0,t.jsxs)(Pe,{children:[de,Ce]}),e[39]=de,e[40]=Ce,e[41]=ye):ye=e[41];let g=n.length>0,N;e[42]!==c||e[43]!==he||e[44]!==g?(N=(0,t.jsx)(ft,{hasTables:g,mode:c,onAddColumn:te,onAddIndex:le,onAddTable:fe,onDestructive:he}),e[42]=c,e[43]=he,e[44]=g,e[45]=N):N=e[45];let T;e[46]!==d||e[47]!==c||e[48]!==G||e[49]!==l||e[50]!==p?(T=c==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ne,value:p})]}),(0,t.jsx)(ge,{"data-testid":"sc-editor-table-apply",disabled:d||p.trim()==="",onClick:G,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=c,e[48]=G,e[49]=l,e[50]=p,e[51]=T):T=e[51];let F;e[52]!==d||e[53]!==b||e[54]!==c||e[55]!==ee||e[56]!==l||e[57]!==n||e[58]!==v||e[59]!==_?(F=c==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:H,value:v,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:se,value:b})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:be,value:_,children:Nt.map(kt)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(ge,{"data-testid":"sc-editor-column-apply",disabled:d||b.trim()===""||v==="",onClick:ee,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=b,e[54]=c,e[55]=ee,e[56]=l,e[57]=n,e[58]=v,e[59]=_,e[60]=F):F=e[60];let S;e[61]!==d||e[62]!==k||e[63]!==$||e[64]!==c||e[65]!==Ne||e[66]!==l||e[67]!==n||e[68]!==v||e[69]!==I?(S=c==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:H,value:v,children:n.map(St)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:oe,value:$})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ie,value:k})]}),(0,t.jsxs)(_e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:I,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:j,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(ge,{"data-testid":"sc-editor-index-apply",disabled:d||$.trim()===""||k.trim()==="",onClick:Ne,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=k,e[63]=$,e[64]=c,e[65]=Ne,e[66]=l,e[67]=n,e[68]=v,e[69]=I,e[70]=S):S=e[70];let ke;e[71]!==x||e[72]!==m?(ke=(0,t.jsx)(vt,{onOpenMigrations:x,result:m}),e[71]=x,e[72]=m,e[73]=ke):ke=e[73];let Se;e[74]!==N||e[75]!==T||e[76]!==F||e[77]!==S||e[78]!==ke?(Se=(0,t.jsxs)(Ke,{children:[N,T,F,S,ke]}),e[74]=N,e[75]=T,e[76]=F,e[77]=S,e[78]=ke,e[79]=Se):Se=e[79];let Ie;return e[80]!==ye||e[81]!==Se?(Ie=(0,t.jsxs)(Oe,{"data-testid":"sc-editor",size:"sm",children:[ye,Se]}),e[80]=ye,e[81]=Se,e[82]=Ie):Ie=e[82],Ie},"Tt");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");function kt(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(kt,"St");function St(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(St,"_t");var et=[],It=r(s=>{let e=(0,we.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=Re("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let c;return e[3]!==l?(c=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=c):c=e[4],c},"$t"),tt=r(s=>{let e=(0,we.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:c,rowTestId:i,toggleTestId:d}=s,h;e[0]!==n?(h=(0,t.jsx)(It,{open:n}),e[0]=n,e[1]=h):h=e[1];let m;e[2]!==l?(m=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=m):m=e[3];let o;e[4]!==c?(o=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=o):o=e[5];let p;e[6]!==n||e[7]!==a||e[8]!==h||e[9]!==m||e[10]!==o||e[11]!==d?(p=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[h,m," ",o]}),e[6]=n,e[7]=a,e[8]=h,e[9]=m,e[10]=o,e[11]=d,e[12]=p):p=e[12];let C;e[13]!==u||e[14]!==n?(C=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=C):C=e[15];let b;return e[16]!==i||e[17]!==p||e[18]!==C?(b=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":i,children:[p,C]}),e[16]=i,e[17]=p,e[18]=C,e[19]=b):b=e[19],b},"Ye"),lt=r(s=>{let e=(0,we.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(Et),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),At=r(s=>{let e=(0,we.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let c;e[2]!==n?(c=n.map(Ft),e[2]=n,e[3]=c):c=e[3];let i;e[4]!==c||e[5]!==l?(i=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:c}),e[4]=c,e[5]=l,e[6]=i):i=e[6];let d;return e[7]!==a||e[8]!==i?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,i]}),e[7]=a,e[8]=i,e[9]=d):d=e[9],d},"kt"),at=r(s=>Re("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ht=r(s=>{let e=(0,we.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Ee(),c;e[0]!==u||e[1]!==n?(c={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=c):c=e[2];let{columns:i,diagramTables:d,error:h,expanded:m,filteredGlobalTables:o,filteredTables:p,globalColumns:C,globalError:b,globalExpanded:z,globalTables:_,indexes:ce,refresh:v,setShardKey:O,setTableFilter:$,setView:E,shardColumnsError:k,shardKey:w,tableFilter:I,tables:P,toggle:B,toggleGlobal:me,view:A}=ut(c),y;e[3]!==E?(y=r(()=>{E("list")},"v"),e[3]=E,e[4]=y):y=e[4];let xe=y,G;e[5]!==E?(G=r(()=>{E("graph")},"G"),e[5]=E,e[6]=G):G=e[6];let ue=G,ee;e[7]!==$?(ee=r(x=>{$(x.target.value)},"ee"),e[7]=$,e[8]=ee):ee=e[8];let J=ee,Ne;e[9]!==v||e[10]!==w?(Ne=r(x=>{pe(v(w))},"Ne"),e[9]=v,e[10]=w,e[11]=Ne):Ne=e[11];let Q=Ne,fe;e[12]!==P?(fe=P??[],e[12]=P,e[13]=fe):fe=e[13];let W;e[14]!==fe?(W=fe.map(zt),e[14]=fe,e[15]=W):W=e[15];let te=W,L;e[16]!==O||e[17]!==w?(L=(0,t.jsx)(He,{onChange:O,testId:"sc-shard-input",value:w}),e[16]=O,e[17]=w,e[18]=L):L=e[18];let le;e[19]!==a?(le=a("Schema view"),e[19]=a,e[20]=le):le=e[20];let ae=A==="graph",he=A==="graph",K;e[21]!==he?(K=at(he),e[21]=he,e[22]=K):K=e[22];let ne;e[23]!==a?(ne=a("Graph"),e[23]=a,e[24]=ne):ne=e[24];let M;e[25]!==ue||e[26]!==ae||e[27]!==K||e[28]!==ne?(M=(0,t.jsx)("button",{"aria-selected":ae,className:K,"data-testid":"sc-view-graph",onClick:ue,role:"tab",type:"button",children:ne}),e[25]=ue,e[26]=ae,e[27]=K,e[28]=ne,e[29]=M):M=e[29];let se=A==="list",re=A==="list",be;e[30]!==re?(be=at(re),e[30]=re,e[31]=be):be=e[31];let X;e[32]!==a?(X=a("Table list"),e[32]=a,e[33]=X):X=e[33];let H;e[34]!==xe||e[35]!==se||e[36]!==be||e[37]!==X?(H=(0,t.jsx)("button",{"aria-selected":se,className:be,"data-testid":"sc-view-list",onClick:xe,role:"tab",type:"button",children:X}),e[34]=xe,e[35]=se,e[36]=be,e[37]=X,e[38]=H):H=e[38];let D;e[39]!==M||e[40]!==H||e[41]!==le?(D=(0,t.jsxs)("div",{"aria-label":le,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[M,H]}),e[39]=M,e[40]=H,e[41]=le,e[42]=D):D=e[42];let oe;e[43]!==D||e[44]!==L?(oe=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[L,D]}),e[43]=D,e[44]=L,e[45]=oe):oe=e[45];let R;e[46]!==Q||e[47]!==l||e[48]!==te?(R=l===!0&&(0,t.jsx)(Tt,{onApplied:Q,tableNames:te}),e[46]=Q,e[47]=l,e[48]=te,e[49]=R):R=e[49];let ie;e[50]!==J||e[51]!==a||e[52]!==I||e[53]!==A?(ie=A==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:J,placeholder:a("Filter tables"),value:I}),e[50]=J,e[51]=a,e[52]=I,e[53]=A,e[54]=ie):ie=e[54];let V;e[55]!==d||e[56]!==h||e[57]!==b||e[58]!==k||e[59]!==w||e[60]!==A?(V=A==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:h}),b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),(0,t.jsx)(Ze,{columnsError:k[w]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=h,e[57]=b,e[58]=k,e[59]=w,e[60]=A,e[61]=V):V=e[61];let j;e[62]!==i||e[63]!==h||e[64]!==m||e[65]!==o||e[66]!==p||e[67]!==C||e[68]!==b||e[69]!==z||e[70]!==_||e[71]!==ce||e[72]!==w||e[73]!==a||e[74]!==P||e[75]!==B||e[76]!==me||e[77]!==A?(j=A==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(Oe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),P!==null&&(0,t.jsx)(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:p.length})]}),(0,t.jsx)(Le,{children:Me.shard.hint})]}),(0,t.jsxs)(Ke,{children:[h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:h}),P!==null&&P.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),P!==null&&P.length>0&&p.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),p.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:p.map(x=>{let Z=`${w}:${x.name}`,de=ce[Z]??[];return(0,t.jsxs)(tt,{expanded:m===x.name,name:x.name,onToggle:r(()=>{pe(B(x.name))},"onToggle"),rowCount:x.rowCount,rowTestId:`sc-table-${x.name}`,toggleTestId:`sc-toggle-${x.name}`,children:[(0,t.jsx)(lt,{columns:i[Z]??et,testId:`sc-columns-${x.name}`}),de.length>0&&(0,t.jsx)(At,{heading:a("Indexes"),indexes:de,testId:`sc-indexes-${x.name}`})]},x.name)})})]})]}),(0,t.jsxs)(Oe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:o.length})]}),(0,t.jsx)(Le,{children:Me.global.hint})]}),(0,t.jsxs)(Ke,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),_!==null&&_.length===0&&(0,t.jsx)(We,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&o.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),o.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:o.map(x=>(0,t.jsx)(tt,{expanded:z===x.name,name:x.name,onToggle:r(()=>{pe(me(x.name))},"onToggle"),rowCount:x.rowCount,rowTestId:`sc-global-table-${x.name}`,toggleTestId:`sc-global-toggle-${x.name}`,children:(0,t.jsx)(lt,{columns:C[x.name]??et,testId:`sc-global-columns-${x.name}`})},x.name))})]})]})]}),e[62]=i,e[63]=h,e[64]=m,e[65]=o,e[66]=p,e[67]=C,e[68]=b,e[69]=z,e[70]=_,e[71]=ce,e[72]=w,e[73]=a,e[74]=P,e[75]=B,e[76]=me,e[77]=A,e[78]=j):j=e[78];let Y;return e[79]!==oe||e[80]!==R||e[81]!==ie||e[82]!==V||e[83]!==j?(Y=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[oe,R,ie,V,j]}),e[79]=oe,e[80]=R,e[81]=ie,e[82]=V,e[83]=j,e[84]=Y):Y=e[84],Y},"Qt");function Et(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(Et,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(Fe,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(Fe,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"At");function zt(s){return s.name}r(zt,"Et");export{Ht as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Pe}from"./chunk-CTNB2KIA.js";import{a as ge}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{c as ae}from"./chunk-XDAT7LHC.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-MIQTKZAR.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-UZERI5YC.js";import{a as ke}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{a as be}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as M}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as j}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Z}from"./chunk-2WOIRKEI.js";import{f as oe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as de}from"./chunk-XQCVZAGU.js";import{d as Y,f as he,g as xe,h as ye,m as te}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as d,e as ie,f as Ae,g as Ie,h as Fe}from"./chunk-3XIESWL4.js";var p=ie(Ae(),1);var me=ie(Ie(),1);var t=ie(Fe(),1);var Ce=["read","insert","update","delete"],Te=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"$e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ae"),ze=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"r");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Fe"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=Y(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let g=ae(Z.getAdvisories,h),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],R=g.data??null,{error:C,errorSource:w,liveError:S}=f,A=v===null?[]:ze(v,E,Ee(R)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let x;a[14]!==C||a[15]!==w?(x=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=x):x=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&A.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Te(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:A.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(j,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(_=>{let y=c.cells[_];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${_}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(F,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${_}`,onClick:d(()=>{s(c.table,_,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},_)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Le)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Ee");function Le(e){return(0,t.jsx)(j,{variant:"outline",children:e},e)}d(Le,"Te");var Oe=he(Z.runAs),Re=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{let n=Oe;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Re"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=Y(),n=Re(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),h=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[R,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[A,k]=(0,p.useState)(!1),[x,c]=(0,p.useState)(null),[_,y]=(0,p.useState)(null),I=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(ye(u))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||I.current===a.nonce)return;I.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?h[0]?.path??"":g,z=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(u){y(l("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),k(!0);try{let u=await n({args:m,functionPath:P,shardKey:R.trim(),userId:w.trim()});c(u)}finally{k(!1)}},"F"),$=d(()=>{te(z())},"E"),H=d(m=>{N(m.target.value)},"B"),L=d(m=>{E(m.target.value)},"T"),O=d(m=>{S(m.target.value)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:H,value:P,children:h.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:R}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:l("Leave empty to run as admin"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{"data-testid":"pp-run",disabled:!i||A||P==="",onClick:$,type:"button",children:l(A?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(j,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),x!==null&&x.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(x.value)})]}),x!==null&&x.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(j,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},"Oe"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Je=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"qe"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ke=d(()=>{let e=(0,me.c)(69),a=Y(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=d(ee=>{let G=ee.target.name,{value:V}=ee.target;b(_e=>({..._e,[G]:V}))},"u"),e[0]=h):h=e[0];let g=h,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"N"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Je(ee);f(G),G.kind==="ok"&&v()}catch(G){let V=G;f({kind:"error",message:V instanceof Error?V.message:String(V)})}n(!1)},"A"),e[2]=E):E=e[2];let R=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(R({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"S"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(R({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"C"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let A=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"k"),e[10]=k):k=e[10];let x=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"c"),e[11]=c):c=e[11];let _=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let I;e[14]!==y?(I=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=I):I=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let z;e[18]!==P?(z=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=z):z=e[19];let $;e[20]!==z||e[21]!==I?($=(0,t.jsxs)(pe,{children:[I,z]}),e[20]=z,e[21]=I,e[22]=$):$=e[22];let H=i==="scaffold"?"default":"outline",L;e[23]!==a?(L=a("New policy file"),e[23]=a,e[24]=L):L=e[24];let O;e[25]!==H||e[26]!==L?(O=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:H,children:L}),e[25]=H,e[26]=L,e[27]=O):O=e[27];let m=i==="wire"?"default":"outline",u;e[28]!==a?(u=a("Wire into a procedure"),e[28]=a,e[29]=u):u=e[29];let q;e[30]!==m||e[31]!==u?(q=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=q):q=e[32];let D;e[33]!==O||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[O,q]}),e[33]=O,e[34]=q,e[35]=D):D=e[35];let J;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(J=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=J):J=e[42];let K;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==A||e[49]!==a?(K=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=A,e[49]=a,e[50]=K):K=e[50];let U;e[51]!==o?(U=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=U):U=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ue)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let Q;e[59]!==D||e[60]!==J||e[61]!==K||e[62]!==U||e[63]!==W||e[64]!==B?(Q=(0,t.jsxs)(ne,{children:[D,J,K,U,W,B]}),e[59]=D,e[60]=J,e[61]=K,e[62]=U,e[63]=W,e[64]=B,e[65]=Q):Q=e[65];let X;return e[66]!==$||e[67]!==Q?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,Q]}),e[66]=$,e[67]=Q,e[68]=X):X=e[68],X},"Je");function Ue(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(Ue,"De");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=Y(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Ke,{})})]})},"nt");export{st as PermissionsPanel};
|
|
1
|
+
import{a as ke}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{a as Pe}from"./chunk-CTNB2KIA.js";import{a as be}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as M}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as j}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ge}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{a as Z}from"./chunk-ERMTJYQF.js";import{c as ae}from"./chunk-XDAT7LHC.js";import{f as oe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as de}from"./chunk-XQCVZAGU.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-MIQTKZAR.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-UZERI5YC.js";import{d as Y,f as he,g as xe,h as ye,m as te}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as d,e as ie,f as Ae,g as Ie,h as Fe}from"./chunk-3XIESWL4.js";var p=ie(Ae(),1);var me=ie(Ie(),1);var t=ie(Fe(),1);var Ce=["read","insert","update","delete"],Te=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"$e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ae"),ze=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"r");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Fe"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=Y(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let g=ae(Z.getAdvisories,h),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],R=g.data??null,{error:C,errorSource:w,liveError:S}=f,A=v===null?[]:ze(v,E,Ee(R)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let x;a[14]!==C||a[15]!==w?(x=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=x):x=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&A.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Te(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:A.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(j,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(_=>{let y=c.cells[_];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${_}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(F,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${_}`,onClick:d(()=>{s(c.table,_,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},_)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Le)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Ee");function Le(e){return(0,t.jsx)(j,{variant:"outline",children:e},e)}d(Le,"Te");var Oe=he(Z.runAs),Re=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{let n=Oe;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Re"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=Y(),n=Re(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),h=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[R,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[A,k]=(0,p.useState)(!1),[x,c]=(0,p.useState)(null),[_,y]=(0,p.useState)(null),I=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(ye(u))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||I.current===a.nonce)return;I.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?h[0]?.path??"":g,z=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(u){y(l("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),k(!0);try{let u=await n({args:m,functionPath:P,shardKey:R.trim(),userId:w.trim()});c(u)}finally{k(!1)}},"F"),$=d(()=>{te(z())},"E"),H=d(m=>{N(m.target.value)},"B"),L=d(m=>{E(m.target.value)},"T"),O=d(m=>{S(m.target.value)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:H,value:P,children:h.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:R}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:l("Leave empty to run as admin"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{"data-testid":"pp-run",disabled:!i||A||P==="",onClick:$,type:"button",children:l(A?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(j,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),x!==null&&x.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(x.value)})]}),x!==null&&x.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(j,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},"Oe"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Je=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"qe"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ke=d(()=>{let e=(0,me.c)(69),a=Y(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=d(ee=>{let G=ee.target.name,{value:V}=ee.target;b(_e=>({..._e,[G]:V}))},"u"),e[0]=h):h=e[0];let g=h,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"N"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Je(ee);f(G),G.kind==="ok"&&v()}catch(G){let V=G;f({kind:"error",message:V instanceof Error?V.message:String(V)})}n(!1)},"A"),e[2]=E):E=e[2];let R=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(R({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"S"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(R({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"C"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let A=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"k"),e[10]=k):k=e[10];let x=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"c"),e[11]=c):c=e[11];let _=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let I;e[14]!==y?(I=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=I):I=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let z;e[18]!==P?(z=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=z):z=e[19];let $;e[20]!==z||e[21]!==I?($=(0,t.jsxs)(pe,{children:[I,z]}),e[20]=z,e[21]=I,e[22]=$):$=e[22];let H=i==="scaffold"?"default":"outline",L;e[23]!==a?(L=a("New policy file"),e[23]=a,e[24]=L):L=e[24];let O;e[25]!==H||e[26]!==L?(O=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:H,children:L}),e[25]=H,e[26]=L,e[27]=O):O=e[27];let m=i==="wire"?"default":"outline",u;e[28]!==a?(u=a("Wire into a procedure"),e[28]=a,e[29]=u):u=e[29];let q;e[30]!==m||e[31]!==u?(q=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=q):q=e[32];let D;e[33]!==O||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[O,q]}),e[33]=O,e[34]=q,e[35]=D):D=e[35];let J;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(J=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=J):J=e[42];let K;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==A||e[49]!==a?(K=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=A,e[49]=a,e[50]=K):K=e[50];let U;e[51]!==o?(U=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=U):U=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ue)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let Q;e[59]!==D||e[60]!==J||e[61]!==K||e[62]!==U||e[63]!==W||e[64]!==B?(Q=(0,t.jsxs)(ne,{children:[D,J,K,U,W,B]}),e[59]=D,e[60]=J,e[61]=K,e[62]=U,e[63]=W,e[64]=B,e[65]=Q):Q=e[65];let X;return e[66]!==$||e[67]!==Q?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,Q]}),e[66]=$,e[67]=Q,e[68]=X):X=e[68],X},"Je");function Ue(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(Ue,"De");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=Y(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Ke,{})})]})},"nt");export{st as PermissionsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as w}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as S}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{a as f}from"./chunk-ERMTJYQF.js";import{c as p}from"./chunk-XDAT7LHC.js";import"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as C,b as j,c as I,d as m,e as n,f as o}from"./chunk-MIQTKZAR.js";import{a as A,e as k}from"./chunk-UZERI5YC.js";import{d as z,q as B}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as i,e as U,f as W,h as X}from"./chunk-3XIESWL4.js";var D=U(W(),1);var e=U(X(),1);var F="agent_threads",Y="agent_messages",Z=100,ee=250,te={},ae={filters:[],limit:Z,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:F},l=i((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"d"),K=i((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"b"),M=i(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"z"),re=i(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"ee"),se=i(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"te"),ne=i(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ae"),fe=i(({initialShardKey:s=""})=>{let t=z(),[a,$]=(0,D.useState)(void 0),{data:x}=p(f.listTables,te,{live:!0,shardKey:s}),L=x!==void 0,u=Array.isArray(x)&&x.some(r=>r.name===F),{data:_,error:O,errorSource:R,liveError:G}=p(f.readTablePage,ae,{enabled:u,live:!0,shardKey:s}),H={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Y},{data:q,error:J,errorSource:Q}=p(f.readTablePage,H,{enabled:u&&a!==void 0,live:!0,shardKey:s}),v=Array.isArray(_?.rows)?_.rows:[],E=Array.isArray(q?.rows)?q.rows:[],P=v.find(r=>l(r,"key")===a),h;return L&&!u?h=(0,e.jsx)(T,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):u&&v.length===0?h=(0,e.jsx)(T,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):h=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(j,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Agent")}),(0,e.jsx)(n,{children:t("Key")}),(0,e.jsx)(n,{children:t("Status")}),(0,e.jsx)(n,{children:t("Messages")}),(0,e.jsx)(n,{children:t("Tokens")}),(0,e.jsx)(n,{children:t("Updated")}),(0,e.jsx)(n,{"aria-label":t("Actions")})]})}),(0,e.jsx)(I,{children:v.map(r=>{let d=l(r,"key")??"",c=l(r,"status"),g=M(r);return(0,e.jsxs)(m,{"data-active":d===a?"":void 0,"data-testid":`agents-thread-${d}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:l(r,"agent")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:d}),(0,e.jsx)(o,{children:(0,e.jsx)(b,{"data-testid":`agents-thread-status-${d}`,variant:se(c),children:c??"\u2014"})}),(0,e.jsx)(o,{className:"tabular-nums",children:K(r,"messageCount")??"\u2014"}),(0,e.jsx)(o,{className:"tabular-nums text-muted-foreground",children:g??"\u2014"}),(0,e.jsx)(o,{className:"text-muted-foreground tabular-nums",children:B(K(r,"updatedAt"),"\u2014")}),(0,e.jsx)(o,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${d}`,onClick:i(()=>{$(d)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},d)})})]})})}),J!==null&&(0,e.jsx)(S,{error:Q,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(k,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,P!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",M(P)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:i(()=>{$(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),E.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(j,{children:(0,e.jsxs)(m,{children:[(0,e.jsx)(n,{children:t("Role")}),(0,e.jsx)(n,{children:t("Content")}),(0,e.jsx)(n,{children:t("Tool")}),(0,e.jsx)(n,{children:t("Approval")})]})}),(0,e.jsx)(I,{children:E.map((r,d)=>{let c=l(r,"role")??"\u2014",g=re(r),V=l(r,"toolName"),y=l(r,"status"),N=K(r,"seq")??d;return(0,e.jsxs)(m,{"data-testid":`agents-message-${String(N)}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:c}),(0,e.jsx)(o,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(r,"content")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:V??(g.length>0?g.join(", "):"\u2014")}),(0,e.jsx)(o,{className:"align-top",children:y===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(b,{"data-testid":`agents-message-approval-${String(N)}`,variant:ne(y),children:y})})]},l(r,"messageKey")??`${c}:${String(N)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[O!==null&&(0,e.jsx)(S,{error:R,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),G!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),h]})},"pe");export{fe as AgentsPanel};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as nt}from"./chunk-SFDOII3B.js";import{e as Ee}from"./chunk-SMIESS7P.js";import{c as
|
|
1
|
+
import{a as nt}from"./chunk-SFDOII3B.js";import{e as Ee}from"./chunk-SMIESS7P.js";import{c as Ue}from"./chunk-FXCBF4XT.js";import{b as Fe}from"./chunk-THIXMMZD.js";import{a as D}from"./chunk-ERMTJYQF.js";import{c as ke}from"./chunk-XDAT7LHC.js";import{f as We}from"./chunk-EN2QAEO4.js";import{a as Ye}from"./chunk-XQCVZAGU.js";import{a as T,e as He}from"./chunk-UZERI5YC.js";import{d as $,f as Qe,g as Xe,m as Se,n as et,o as tt,p as at}from"./chunk-OG4N2XHD.js";import{a as m,e as Ve,f as ct,g as dt,h as mt,j as Be}from"./chunk-3XIESWL4.js";var S=Ve(dt(),1);var L=Ve(ct(),1);var n=Ve(mt(),1);var ut=Qe(D.studioFeatures),it={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,notifications:!0,payments:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},pt=m(t=>{if(t===null||typeof t!="object")return it;let e=t,s=m(a=>typeof e[a]=="boolean"?e[a]:!0,"a");return{analytics:s("analytics"),auth:s("auth"),containers:s("containers"),flags:s("flags"),kv:s("kv"),mail:s("mail"),notifications:s("notifications"),payments:s("payments"),queues:s("queues"),scheduler:s("scheduler"),storage:s("storage"),vectors:s("vectors"),workflows:s("workflows")}},"ut"),ft=m(()=>{let t=(0,S.c)(3),e=We(),[s,a]=(0,L.useState)(it),r,l;return t[0]!==e?(r=m(()=>{Se((async()=>{try{a(pt(await e.query(ut,{},Xe(""))))}catch{}})())},"s"),l=[e],t[0]=e,t[1]=r,t[2]=l):(r=t[1],l=t[2]),(0,L.useEffect)(r,l),s},"pt"),ht=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"ft"),gt=m(t=>{let e=(0,S.c)(24),{group:s}=t,a=$(),r=Ee(),l;e[0]!==s.tab||e[1]!==r?(l=m(()=>{Se(r({to:`/${s.tab}`}))},"o"),e[0]=s.tab,e[1]=r,e[2]=l):l=e[2];let o=l,i=s.bindings.length,c;e[3]!==s.label?(c=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),e[3]=s.label,e[4]=c):c=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)(ht,{}),e[5]=p):p=e[5];let d;e[6]!==c?(d=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[c,p]}),e[6]=c,e[7]=d):d=e[7];let f;e[8]!==i||e[9]!==a?(f=i===1?a("1 binding"):a("{count} bindings",{count:i}),e[8]=i,e[9]=a,e[10]=f):f=e[10];let u;e[11]!==f?(u=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=u):u=e[12];let h;e[13]!==i||e[14]!==s.bindings?(h=i>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.bindings.map(yt)}),e[13]=i,e[14]=s.bindings,e[15]=h):h=e[15];let g;e[16]!==d||e[17]!==u||e[18]!==h?(g=(0,n.jsxs)(He,{className:"flex flex-col gap-2 py-4",children:[d,u,h]}),e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==s.testId||e[21]!==o||e[22]!==g?(x=(0,n.jsx)(T,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":s.testId,onClick:o,children:g}),e[20]=s.testId,e[21]=o,e[22]=g,e[23]=x):x=e[23],x},"ht"),st=["kv","files","vectors"],xt=m((t,e)=>[...t.filter(s=>s.tab!==e.tab),e].toSorted((s,a)=>st.indexOf(s.tab)-st.indexOf(a.tab)),"gt"),bt=m(()=>{let t=(0,S.c)(19),e=We(),s=ft(),a=$(),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];let[l,o]=(0,L.useState)(r),i,c;if(t[1]!==e||t[2]!==s.kv||t[3]!==s.storage||t[4]!==s.vectors||t[5]!==a?(i=m(()=>{let g={cancelled:!1},x=[{enabled:s.kv,label:a("KV Namespaces"),load:m(async()=>(await e.listKvNamespaces()).map(vt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:s.storage,label:a("R2 Buckets"),load:m(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:s.vectors,label:a("Vectorize Indexes"),load:m(async()=>(await e.listVectorIndexes()).map(Nt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Se((async()=>{try{let y=await b.load();if(!g.cancelled){let k={bindings:y,label:b.label,tab:b.tab,testId:b.testId};o(A=>xt(A,k))}}catch{}})());return()=>{g.cancelled=!0}},"i"),c=[e,s.kv,s.storage,s.vectors,a],t[1]=e,t[2]=s.kv,t[3]=s.storage,t[4]=s.vectors,t[5]=a,t[6]=i,t[7]=c):(i=t[6],c=t[7]),(0,L.useEffect)(i,c),l.length===0)return null;let p;t[8]!==a?(p=a("Bindings"),t[8]=a,t[9]=p):p=t[9];let d;t[10]!==p?(d=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:p}),t[10]=p,t[11]=d):d=t[11];let f;t[12]!==l?(f=l.map(_t),t[12]=l,t[13]=f):f=t[13];let u;t[14]!==f?(u=(0,n.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:f}),t[14]=f,t[15]=u):u=t[15];let h;return t[16]!==d||t[17]!==u?(h=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[d,u]}),t[16]=d,t[17]=u,t[18]=h):h=t[18],h},"xt");function yt(t){return(0,n.jsx)(Fe,{variant:"secondary",children:t},t)}m(yt,"bt");function vt(t){return t.binding}m(vt,"yt");function Nt(t){return t.name}m(Nt,"vt");function _t(t){return(0,n.jsx)(gt,{group:t},t.tab)}m(_t,"Nt");var St=[{name:"lunora_list_functions",summary:"list every query, mutation, and action with its path"},{name:"lunora_list_tables",summary:"list the schema's tables"},{name:"lunora_get_function_schema",summary:"read a function's argument JSON Schema before calling it"},{name:"lunora_run_query",summary:"run a read-only query"},{name:"lunora_run_mutation",summary:"run a mutation \u2014 writes; only when LUNORA_MCP_ALLOW_WRITES is set"},{name:"lunora_run_action",summary:"run an action \u2014 writes/effects; only when LUNORA_MCP_ALLOW_WRITES is set"}],kt=m(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"St"),wt=m(t=>{let e=St.map(s=>`- ${s.name} \u2014 ${s.summary}`).join(`
|
|
2
2
|
`);return[`You have a Lunora MCP server connected to the deployment at ${t}.`,"It exposes this backend's functions and schema so you can inspect and operate it:",e,"",`Start by calling lunora_list_functions and lunora_list_tables to learn what exists, then lunora_get_function_schema before any run call. The full HTTP API is also documented at ${t}/_lunora/admin/openapi (that endpoint needs the same admin token the MCP server is configured with).`].join(`
|
|
3
3
|
`)},"kt"),Mt=1500,It=m(()=>{let t=(0,S.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=et(),t[0]=s):s=t[0];let a=s,[r,l]=(0,L.useState)(null),o,i;t[1]!==r?(o=m(()=>{if(r===null)return;let C=globalThis.setTimeout(()=>{l(null)},Mt);return()=>{globalThis.clearTimeout(C)}},"l"),i=[r],t[1]=r,t[2]=o,t[3]=i):(o=t[2],i=t[3]),(0,L.useEffect)(o,i);let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=m((C,j)=>{tt(j)&&l(C)},"c"),t[4]=c):c=t[4];let p=c,d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=m(()=>{p("config",kt(a))},"d"),t[5]=d):d=t[5];let f=d,u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m(()=>{p("prompt",wt(a))},"m"),t[6]=u):u=t[6];let h=u,g;t[7]!==e?(g=e("Connect an AI agent"),t[7]=e,t[8]=g):g=t[8];let x;t[9]!==g?(x=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:g}),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==e?(b=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[11]=e,t[12]=b):b=t[12];let y;t[13]!==b?(y=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:b}),t[13]=b,t[14]=y):y=t[14];let k;t[15]!==x||t[16]!==y?(k=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[x,y]}),t[15]=x,t[16]=y,t[17]=k):k=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[18]=A):A=t[18];let w;t[19]!==r||t[20]!==e?(w=e(r==="config"?"Copied":"Copy MCP config"),t[19]=r,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:w}),t[22]=w,t[23]=v):v=t[23];let M;t[24]!==r||t[25]!==e?(M=e(r==="prompt"?"Copied":"Copy agent prompt"),t[24]=r,t[25]=e,t[26]=M):M=t[26];let I;t[27]!==M?(I=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-prompt",onClick:h,size:"xs",variant:"outline",children:M}),t[27]=M,t[28]=I):I=t[28];let N;t[29]!==v||t[30]!==I?(N=(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[A,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[v,I]})]}),t[29]=v,t[30]=I,t[31]=N):N=t[31];let _;return t[32]!==k||t[33]!==N?(_=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[k,N]}),t[32]=k,t[33]=N,t[34]=_):_=t[34],_},"$t"),Lt=(0,L.lazy)(()=>import("./chunk-Q7O6B7WC.js").then(t=>({default:t.Sparkline}))),Ze=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"Be"),At=m((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let a=Math.round(s/60);if(a<60)return`${String(a)}m ago`;let r=Math.round(a/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"Mt"),rt=m((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let a of t)s.set(a.bucketMs,(s.get(a.bucketMs)??0)+a[e]);return[...s.entries()].toSorted(([a],[r])=>a-r).map(([,a])=>a)},"He"),lt=m((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),a=t.slice(0,s).reduce((o,i)=>o+i,0),r=t.slice(s).reduce((o,i)=>o+i,0);if(a===0)return null;let l=(r-a)/a*100;return{positive:e?l>=0:l<=0,text:`${l>=0?"+":""}${l.toFixed(1)}%`}},"Je"),qe=m(t=>{let e=(0,S.c)(24),{delta:s,footer:a,label:r,trend:l,unit:o,value:i}=t,c=$(),p;e[0]!==r?(p=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=p):p=e[1];let d;e[2]!==i?(d=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[2]=i,e[3]=d):d=e[3];let f;e[4]!==o?(f=o!==void 0&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=f):f=e[5];let u;e[6]!==d||e[7]!==f?(u=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,f]}),e[6]=d,e[7]=f,e[8]=u):u=e[8];let h;e[9]!==l?(h=l!==void 0&&(0,n.jsx)(L.Suspense,{fallback:(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,n.jsx)(Lt,{data:l})}),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==u||e[12]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,h]}),e[11]=u,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==p||e[15]!==g?(x=(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]}),e[14]=p,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==a||e[19]!==c?(b=s==null?a!=null&&(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:a}):(0,n.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,n.jsx)("span",{className:Be("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=a,e[19]=c,e[20]=b):b=e[20];let y;return e[21]!==x||e[22]!==b?(y=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23],y},"Oe"),Ct=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"At"),Je=m(t=>{let e=(0,S.c)(7),{command:s,label:a}=t,r;e[0]!==a?(r=(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:a})}),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==s?(l=(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=l):l=e[3];let o;return e[4]!==r||e[5]!==l?(o=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,l]}),e[4]=r,e[5]=l,e[6]=o):o=e[6],o},"De"),ot=m(t=>{let e=(0,S.c)(18),{count:s,onView:a,testId:r,title:l}=t,o=$(),i;e[0]!==l?(i=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1];let c;e[2]!==s||e[3]!==o?(c=s===null?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o("No data yet")}):(0,n.jsx)(Fe,{variant:s>0?"destructive":"success",children:s>0?s:o("All clear")}),e[2]=s,e[3]=o,e[4]=c):c=e[4];let p;e[5]!==i||e[6]!==c?(p=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[i,c]}),e[5]=i,e[6]=c,e[7]=p):p=e[7];let d;e[8]!==o?(d=o("View"),e[8]=o,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(Ct,{}),e[10]=f):f=e[10];let u;e[11]!==a||e[12]!==d?(u=(0,n.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:a,type:"button",children:[d,f]}),e[11]=a,e[12]=d,e[13]=u):u=e[13];let h;return e[14]!==p||e[15]!==u||e[16]!==r?(h=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[p,u]}),e[14]=p,e[15]=u,e[16]=r,e[17]=h):h=e[17],h},"Ge"),$t=m(t=>{let e=(0,S.c)(7),{functions:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=[...s].toSorted(qt).slice(0,5),o;e[3]!==a?(o=a("Top functions"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[i,l.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No functions called yet.")}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,n.jsx)("span",{children:a("Function")}),(0,n.jsx)("span",{className:"text-end",children:a("Calls")}),(0,n.jsx)("span",{className:"w-12 text-end",children:a("Avg")}),(0,n.jsx)("span",{className:"w-8 text-end",children:a("Err")})]}),l.map(Rt)]})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Ct"),jt=m(t=>{let e=(0,S.c)(26),{subs:s}=t,a=$(),r;e[0]!==a?(r=a("Live connections"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=l):l=e[3];let o=s?.totalConnections??0,i;e[4]!==o?(i=o.toLocaleString(),e[4]=o,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==a?(p=a("sockets"),e[8]=a,e[9]=p):p=e[9];let d;e[10]!==p?(d=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),e[10]=p,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==d?(f=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,d]}),e[12]=c,e[13]=d,e[14]=f):f=e[14];let u=s?.totalSubscriptions??0,h;e[15]!==u?(h=u.toLocaleString(),e[15]=u,e[16]=h):h=e[16];let g;e[17]!==a?(g=a("active subscriptions"),e[17]=a,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==l||e[24]!==f?(b=(0,n.jsx)(T,{"data-testid":"home-live-connections",children:(0,n.jsxs)(He,{className:"flex flex-col gap-2.5 py-4",children:[l,f,x]})}),e[22]=x,e[23]=l,e[24]=f,e[25]=b):b=e[25],b},"It"),Tt=m(t=>{let e=(0,S.c)(7),{entries:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=Date.now(),o;e[3]!==a?(o=a("Recent activity"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[i,s.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No recent activity.")}):(0,n.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,n.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:At(c.ts,l)})]},c.seq))})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"jt"),Ot=m(t=>{let e=t.reduce((s,a)=>s+a.calls,0);return e===0?null:t.reduce((s,a)=>s+a.totalDurationMs,0)/e},"Tt"),Gt=m(t=>{let e=(0,S.c)(151),{initialShardKey:s}=t,a=$(),r=Ee(),l=s??"",o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let i;e[1]!==l?(i={shardKey:l},e[1]=l,e[2]=i):i=e[2];let c=ke(D.getMetrics,o,i),p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={},e[3]=p):p=e[3];let d;e[4]!==l?(d={shardKey:l},e[4]=l,e[5]=d):d=e[5];let f=ke(D.getFunctionStats,p,d),u,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={},h={shardKey:""},e[6]=u,e[7]=h):(u=e[6],h=e[7]);let g=ke(D.getSecurityAudit,u,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==l?(b={shardKey:l},e[9]=l,e[10]=b):b=e[10];let y=ke(D.listSubscriptions,x,b),k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k={},e[11]=k):k=e[11];let A;e[12]!==l?(A={shardKey:l},e[12]=l,e[13]=A):A=e[13];let w=ke(D.getAuditLog,k,A),v=c.data??null,M,I,N,_,C,j,P,O,q,V,W,E,R,K,B,F,U,H;if(e[14]!==w.data||e[15]!==g.data||e[16]!==v||e[17]!==c.data||e[18]!==r||e[19]!==f.data||e[20]!==y.data||e[21]!==a){_=Array.isArray(f.data?.functions)?f.data.functions:[],P=y.data??null;let Le;e[40]!==w.data?(Le=Array.isArray(w.data?.entries)?w.data.entries:[],e[40]=w.data,e[41]=Le):Le=e[41],I=Le,C=c.data===void 0||f.data===void 0?null:nt(v,_).length,j=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ae;e[42]!==r?(Ae=m(()=>{Se(r({to:"/security"}))},"Me"),e[42]=r,e[43]=Ae):Ae=e[43],H=Ae;let Ce;e[44]!==r?(Ce=m(()=>{Se(r({to:"/insights"}))},"Ae"),e[44]=r,e[45]=Ce):Ce=e[45],U=Ce;let $e=rt(v?.history,"calls"),je=rt(v?.history,"errors"),Ge=Ot(_),Te=Math.max(0,..._.map(Kt)),z=v?.cache,Oe;e[46]!==z?(Oe=z!=null&&z.hits+z.misses>0?Math.round(z.hits/(z.hits+z.misses)*100):null,e[46]=z,e[47]=Oe):Oe=e[47],N=Oe,B="flex flex-col gap-6",F="lunora-home",W="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let Ke=lt($e),ye;e[48]!==a?(ye=a("Requests"),e[48]=a,e[49]=ye):ye=e[49];let ze=v?.requests??0,ve;e[50]!==ze?(ve=ze.toLocaleString(),e[50]=ze,e[51]=ve):ve=e[51],e[52]!==$e||e[53]!==Ke||e[54]!==ye||e[55]!==ve?(R=(0,n.jsx)(qe,{delta:Ke,label:ye,trend:$e,value:ve}),e[52]=$e,e[53]=Ke,e[54]=ye,e[55]=ve,e[56]=R):R=e[56];let De=lt(je,!1),Ne;e[57]!==a?(Ne=a("Errors"),e[57]=a,e[58]=Ne):Ne=e[58];let Pe=v?.errors??0,_e;e[59]!==Pe?(_e=Pe.toLocaleString(),e[59]=Pe,e[60]=_e):_e=e[60],e[61]!==je||e[62]!==De||e[63]!==Ne||e[64]!==_e?(K=(0,n.jsx)(qe,{delta:De,label:Ne,trend:je,value:_e}),e[61]=je,e[62]=De,e[63]=Ne,e[64]=_e,e[65]=K):K=e[65],M=qe,e[66]!==Te||e[67]!==a?(O=Te>0?`${a("max")} ${Ze(Te)}`:void 0,e[66]=Te,e[67]=a,e[68]=O):O=e[68],e[69]!==a?(q=a("Avg latency"),e[69]=a,e[70]=q):q=e[70],V=Ge===null?"\u2014":Ze(Ge),e[14]=w.data,e[15]=g.data,e[16]=v,e[17]=c.data,e[18]=r,e[19]=f.data,e[20]=y.data,e[21]=a,e[22]=M,e[23]=I,e[24]=N,e[25]=_,e[26]=C,e[27]=j,e[28]=P,e[29]=O,e[30]=q,e[31]=V,e[32]=W,e[33]=E,e[34]=R,e[35]=K,e[36]=B,e[37]=F,e[38]=U,e[39]=H}else M=e[22],I=e[23],N=e[24],_=e[25],C=e[26],j=e[27],P=e[28],O=e[29],q=e[30],V=e[31],W=e[32],E=e[33],R=e[34],K=e[35],B=e[36],F=e[37],U=e[38],H=e[39];let J;e[71]!==M||e[72]!==O||e[73]!==q||e[74]!==V?(J=(0,n.jsx)(M,{footer:O,label:q,value:V}),e[71]=M,e[72]=O,e[73]=q,e[74]=V,e[75]=J):J=e[75];let Z;e[76]!==N||e[77]!==a?(Z=N===null?void 0:`${String(N)}% ${a("cache hit")}`,e[76]=N,e[77]=a,e[78]=Z):Z=e[78];let G;e[79]!==a?(G=a("Database size"),e[79]=a,e[80]=G):G=e[80];let Re=v?.databaseSize??null,Y;e[81]!==Re?(Y=at(Re),e[81]=Re,e[82]=Y):Y=e[82];let Q;e[83]!==Z||e[84]!==G||e[85]!==Y?(Q=(0,n.jsx)(qe,{footer:Z,label:G,value:Y}),e[83]=Z,e[84]=G,e[85]=Y,e[86]=Q):Q=e[86];let X;e[87]!==W||e[88]!==E||e[89]!==R||e[90]!==K||e[91]!==J||e[92]!==Q?(X=(0,n.jsxs)("div",{className:W,"data-testid":E,children:[R,K,J,Q]}),e[87]=W,e[88]=E,e[89]=R,e[90]=K,e[91]=J,e[92]=Q,e[93]=X):X=e[93];let we;e[94]===Symbol.for("react.memo_cache_sentinel")?(we=(0,n.jsx)(bt,{}),e[94]=we):we=e[94];let ee;e[95]!==_?(ee=(0,n.jsx)("div",{className:"lg:col-span-2",children:(0,n.jsx)($t,{functions:_})}),e[95]=_,e[96]=ee):ee=e[96];let te;e[97]!==P?(te=(0,n.jsx)(jt,{subs:P}),e[97]=P,e[98]=te):te=e[98];let ae;e[99]!==I?(ae=(0,n.jsx)(Tt,{entries:I}),e[99]=I,e[100]=ae):ae=e[100];let ne;e[101]!==te||e[102]!==ae?(ne=(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[te,ae]}),e[101]=te,e[102]=ae,e[103]=ne):ne=e[103];let se;e[104]!==ee||e[105]!==ne?(se=(0,n.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[ee,ne]}),e[104]=ee,e[105]=ne,e[106]=se):se=e[106];let re;e[107]!==a?(re=a("Advisors"),e[107]=a,e[108]=re):re=e[108];let le;e[109]!==re?(le=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:re}),e[109]=re,e[110]=le):le=e[110];let oe;e[111]!==C||e[112]!==j||e[113]!==a||e[114]!==U||e[115]!==H?(oe=j===0&&C===0?(0,n.jsx)(Ye,{description:a("No security or performance issues detected."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,n.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:a("No issues found")}):(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsx)(ot,{count:j,onView:H,testId:"home-security",title:a("Security findings")}),(0,n.jsx)(ot,{count:C,onView:U,testId:"home-performance",title:a("Performance issues")})]}),e[111]=C,e[112]=j,e[113]=a,e[114]=U,e[115]=H,e[116]=oe):oe=e[116];let ie;e[117]!==le||e[118]!==oe?(ie=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[le,oe]}),e[117]=le,e[118]=oe,e[119]=ie):ie=e[119];let ce;e[120]!==a?(ce=a("Get connected"),e[120]=a,e[121]=ce):ce=e[121];let de;e[122]!==ce?(de=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ce}),e[122]=ce,e[123]=de):de=e[123];let me;e[124]!==a?(me=a("Client SDK"),e[124]=a,e[125]=me):me=e[125];let ue;e[126]!==me?(ue=(0,n.jsx)(Je,{command:"npm i @lunora/client",label:me}),e[126]=me,e[127]=ue):ue=e[127];let pe;e[128]!==a?(pe=a("React"),e[128]=a,e[129]=pe):pe=e[129];let fe;e[130]!==pe?(fe=(0,n.jsx)(Je,{command:"npm i @lunora/react",label:pe}),e[130]=pe,e[131]=fe):fe=e[131];let he;e[132]!==a?(he=a("CLI"),e[132]=a,e[133]=he):he=e[133];let ge;e[134]!==he?(ge=(0,n.jsx)(Je,{command:"lunora dev",label:he}),e[134]=he,e[135]=ge):ge=e[135];let xe;e[136]!==ue||e[137]!==fe||e[138]!==ge?(xe=(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[ue,fe,ge]}),e[136]=ue,e[137]=fe,e[138]=ge,e[139]=xe):xe=e[139];let Me;e[140]===Symbol.for("react.memo_cache_sentinel")?(Me=(0,n.jsx)(It,{}),e[140]=Me):Me=e[140];let be;e[141]!==de||e[142]!==xe?(be=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[de,xe,Me]}),e[141]=de,e[142]=xe,e[143]=be):be=e[143];let Ie;return e[144]!==B||e[145]!==F||e[146]!==X||e[147]!==se||e[148]!==ie||e[149]!==be?(Ie=(0,n.jsxs)("div",{className:B,"data-testid":F,children:[X,we,se,ie,be]}),e[144]=B,e[145]=F,e[146]=X,e[147]=se,e[148]=ie,e[149]=be,e[150]=Ie):Ie=e[150],Ie},"Zt");function qt(t,e){return e.calls-t.calls}m(qt,"Ot");function Rt(t){return(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,n.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,n.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,n.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:Ze(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,n.jsx)("span",{className:Be("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}m(Rt,"Rt");function Kt(t){return t.maxDurationMs}m(Kt,"qt");export{ft as a,Gt as b};
|