@theobourgeois/ytdb 0.2.15 → 0.2.16
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +3 -3
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/[connectionId]/[schema]/[table]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/diff/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/page.js +1 -1
- package/.next/server/app/[connectionId]/migrations/[setId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/migrations/page.js +1 -1
- package/.next/server/app/[connectionId]/migrations/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/[connectionId]/query/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/activity/route.js +1 -1
- package/.next/server/app/api/repo/route.js +1 -1
- package/.next/server/app/api/schema/route.js +1 -1
- package/.next/server/app/api/tables/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +3 -3
- package/.next/server/chunks/161.js +1 -1
- package/.next/server/chunks/172.js +1 -1
- package/.next/server/chunks/605.js +1 -1
- package/.next/server/chunks/729.js +1 -1
- package/.next/server/chunks/814.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/{3732-422f344679f5d126.js → 3732-535d9f485cf90098.js} +1 -1
- package/.next/static/chunks/6090-3a613287bf7c9e90.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-18158f23ccdab4cf.js +1 -0
- package/.next/static/chunks/app/[connectionId]/migrations/page-2ed07ba3810d1ee6.js +1 -0
- package/.next/static/chunks/app/[connectionId]/page-22bcfd48d84d7598.js +1 -0
- package/package.json +1 -1
- package/.next/static/chunks/6090-2831a02797d69073.js +0 -1
- package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-1886726af1052176.js +0 -1
- package/.next/static/chunks/app/[connectionId]/migrations/page-33e44680d62cbc05.js +0 -1
- package/.next/static/chunks/app/[connectionId]/page-df1d6620d85e3e15.js +0 -1
- /package/.next/static/{7RCujTjKg604vUCcqYNh6 → OyIGZSorg5OrE1_BWj2Lr}/_buildManifest.js +0 -0
- /package/.next/static/{7RCujTjKg604vUCcqYNh6 → OyIGZSorg5OrE1_BWj2Lr}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5838],{10037:(e,t,n)=>{"use strict";n.d(t,{MigrationDetail:()=>Z});var r=n(95155),s=n(98500),i=n.n(s),a=n(73321),l=n(12115),o=n(13267),d=n(36331),c=n(79781),u=n(17491),m=n(89239),h=n(72264),x=n(35942),p=n(87364),f=n(27529),g=n(62417),j=n(56012),v=n(74590),b=n(9385),k=n(79668),y=n(34263),N=n(40980),w=n(72194),S=n(40891),$=n(30374),C=n(25);function R(e){let t=e.replace(/\r\n?/g,"\n").replace(/\s+$/,"");return t?t.split("\n"):[]}let z={same:" ",add:"+",remove:"-"};function A({before:e,after:t,className:n}){let s=(0,l.useMemo)(()=>(function(e,t=3){let n=[];e.forEach((r,s)=>{if("same"===r.kind)return;let i=Math.max(0,s-t),a=Math.min(e.length-1,s+t),l=n.at(-1);l&&i<=l[1]+1?l[1]=Math.max(l[1],a):n.push([i,a])});let r=[],s=[],i=0,a=0;for(let t of e)r.push(i),s.push(a),"add"!==t.kind&&(i+=1),"remove"!==t.kind&&(a+=1);return n.map(([t,n])=>{let i=e.slice(t,n+1),a=i.filter(e=>"add"!==e.kind).length,l=i.filter(e=>"remove"!==e.kind).length,o=r[t]+ +(0!==a),d=s[t]+ +(0!==l);return{header:`@@ -${o},${a} +${d},${l} @@`,lines:i}})})(function(e,t){let n=R(e),r=R(t),s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;let i=0;for(;i<n.length-s&&i<r.length-s&&n[n.length-1-i]===r[r.length-1-i];)i+=1;let a=n.slice(s,n.length-i),l=r.slice(s,r.length-i),o=function(e,t){let n=e.length,r=t.length,s=n+r,i=s+1,a=new Int32Array(2*s+3),l=[],o=!1;for(let d=0;d<=s&&!o;d+=1){if((l.length+1)*a.length>2e7)return null;l.push(a.slice());for(let s=-d;s<=d;s+=2){let l=s===-d||s!==d&&a[i+s-1]<a[i+s+1]?a[i+s+1]:a[i+s-1]+1,c=l-s;for(;l<n&&c<r&&e[l]===t[c];)l+=1,c+=1;if(a[i+s]=l,l>=n&&c>=r){o=!0;break}}}let d=[],c=n,u=r;for(let n=l.length-1;n>=0;n-=1){let r=l[n],s=c-u,a=s===-n||s!==n&&r[i+s-1]<r[i+s+1]?s+1:s-1,o=r[i+a],m=o-a;for(;c>o&&u>m;)d.push({kind:"same",text:e[c-1]}),c-=1,u-=1;n>0&&(c===o?d.push({kind:"add",text:t[u-1]}):d.push({kind:"remove",text:e[c-1]})),c=o,u=m}return d.reverse()}(a,l)??[...a.map(e=>({kind:"remove",text:e})),...l.map(e=>({kind:"add",text:e}))],d=[...n.slice(0,s).map(e=>({kind:"same",text:e})),...o,...n.slice(n.length-i).map(e=>({kind:"same",text:e}))],c=0,u=0;return d.map(e=>"same"===e.kind?(c+=1,u+=1,{...e,oldNo:c,newNo:u}):"remove"===e.kind?(c+=1,{...e,oldNo:c,newNo:null}):(u+=1,{...e,oldNo:null,newNo:u}))}(e,t)),[e,t]);return 0===s.length?(0,r.jsx)("p",{className:(0,N.cn)("text-xs text-muted-foreground",n),children:"Only whitespace at the end of the file differs."}):(0,r.jsx)("div",{className:(0,N.cn)("overflow-auto font-mono text-[11px] leading-5",n),children:(0,r.jsx)("table",{className:"w-full border-collapse",children:s.map(e=>(0,r.jsxs)("tbody",{children:[(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:3,className:"bg-muted/60 px-3 text-muted-foreground select-none",children:e.header})}),e.lines.map((e,t)=>(0,r.jsxs)("tr",{className:(0,N.cn)("add"===e.kind&&"bg-emerald-500/12","remove"===e.kind&&"bg-red-500/12"),children:[(0,r.jsx)(M,{value:e.oldNo}),(0,r.jsx)(M,{value:e.newNo}),(0,r.jsxs)("td",{className:"pr-3 whitespace-pre",children:[(0,r.jsx)("span",{className:(0,N.cn)("inline-block w-4 pl-1 select-none","add"===e.kind&&"text-emerald-600 dark:text-emerald-400","remove"===e.kind&&"text-red-600 dark:text-red-400"),children:z[e.kind]}),e.text]})]},t))]},e.header))})})}function M({value:e}){return(0,r.jsx)("td",{className:"w-10 min-w-10 pr-2 text-right text-muted-foreground/50 tabular-nums select-none",children:e??""})}let E="w-24",q="w-[104px]";function F({checked:e,label:t,onToggle:n}){return(0,r.jsx)("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":t,title:t,onMouseDown:e=>e.shiftKey&&e.preventDefault(),onClick:e=>n(e.shiftKey),className:(0,N.cn)("flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[5px] border outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/60",e?"border-foreground bg-foreground text-background":"border-input hover:border-foreground/50"),children:"mixed"===e?(0,r.jsx)(o.uPM,{className:"size-3"}):e?(0,r.jsx)(o.wiW,{className:"size-3"}):null})}let O={applied:"applied",drifted:"applied, but the file changed since",pending:"not applied",unknown:"not read yet"};function T({status:e}){return"applied"===e?(0,r.jsx)(o.wiW,{className:"size-4 text-emerald-600 dark:text-emerald-400"}):"drifted"===e?(0,r.jsx)(o.e5t,{className:"size-3.5 text-amber-600 dark:text-amber-400"}):"unknown"===e?(0,r.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}):(0,r.jsx)(o.uPM,{className:"size-3.5 text-muted-foreground/40"})}function _({step:e,environments:t,targetId:n,status:s,isNewestApplied:i,expanded:a,busy:d,editable:c=!0,drift:u,selected:x,onSelect:p,onToggle:f,actions:g}){let[j,v]=(0,l.useState)(null),b="changes"!==j||u?j??(u?"changes":"apply"):"apply",k="revert"===b?"revert":"apply",[y,w]=(0,l.useState)(!1),R="revert"===k?e.revertSql??"":e.applySql,z=(0,C.qb)(e.transaction),M=(0,C.TA)(e.transaction),D=[];async function I(){await (0,S.mw)(R),w(!0),window.setTimeout(()=>w(!1),1500)}return"drifted"===s&&"changes"!==b&&D.push("This file changed after it was applied here, so it is no longer the migration that ran."),M&&D.push(M),(0,r.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,r.jsxs)("div",{className:(0,N.cn)("flex h-10 items-center transition-colors hover:bg-muted/40",x&&"bg-muted/30",d&&"opacity-60"),children:[(0,r.jsx)("span",{className:"flex h-10 shrink-0 items-center pl-3",children:(0,r.jsx)(F,{checked:x,label:x?`Deselect ${e.version}`:`Select ${e.version}`,onToggle:p})}),(0,r.jsxs)("button",{type:"button","aria-expanded":a,"aria-label":a?`Hide SQL for ${e.version}`:`Show SQL for ${e.version}`,onClick:f,className:"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,r.jsx)(o.nNJ,{className:(0,N.cn)("size-3.5 shrink-0 text-muted-foreground/70 transition-transform",a&&"rotate-90")}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:e.version}),(0,r.jsx)("span",{className:"min-w-0 truncate text-sm",children:e.name}),z&&(0,r.jsx)("span",{className:"shrink-0 rounded border border-amber-600/25 bg-amber-500/10 px-1.5 text-[10px] text-amber-700 dark:text-amber-400",children:z})]}),t.map(t=>{let s=t.connection.id===n;return(0,r.jsx)("span",{title:t.error?`${t.connection.name}: ${t.error}`:`${e.version} is ${O[t.status]} on ${t.connection.name}${t.entry?` — ${function(e){if(!e)return"";let t=new Date(e.appliedAt);return Number.isNaN(t.getTime())?e.appliedAt:t.toLocaleString()}(t.entry)}`:""}`,className:(0,N.cn)("flex h-10 shrink-0 items-center justify-center",E,s&&"bg-foreground/[0.04]"),children:(0,r.jsx)(T,{status:t.status})},t.connection.id)}),(0,r.jsxs)("div",{className:(0,N.cn)("flex shrink-0 items-center justify-end gap-1 pr-2 pl-1",q),children:["pending"===s&&(0,r.jsx)(m.$,{size:"xs",variant:"outline",disabled:d,onClick:g.onApplyThrough,children:"Apply"}),i&&e.revertSql&&(0,r.jsxs)(m.$,{size:"xs",variant:"ghost",disabled:d,onClick:g.onRevertThrough,children:[(0,r.jsx)(o.ij9,{"data-icon":"inline-start"}),"Revert"]}),(0,r.jsxs)(h.rI,{children:[(0,r.jsx)(h.ty,{render:(0,r.jsx)(m.$,{size:"icon-xs",variant:"ghost","aria-label":`Actions for ${e.version}`}),className:"cursor-pointer",children:(0,r.jsx)(o.YKd,{})}),(0,r.jsxs)(h.SQ,{align:"end",className:"min-w-56",children:[(0,r.jsx)(h._2,{disabled:d||"applied"===s,onClick:g.onApplyThrough,children:"Apply everything through here"}),(0,r.jsx)(h._2,{disabled:d||"applied"===s,onClick:g.onApplyOne,children:"Apply only this one"}),(0,r.jsx)(h._2,{disabled:d||"pending"===s||!e.revertSql,onClick:g.onRevertThrough,children:"Revert back through here"}),(0,r.jsx)(h.mB,{}),(0,r.jsxs)(h._2,{disabled:d||"applied"===s,onClick:g.onMarkApplied,children:[(0,r.jsx)(o.nXx,{}),"Mark as already applied"]}),(0,r.jsxs)(h._2,{disabled:d||"pending"===s,onClick:g.onMarkPending,children:[(0,r.jsx)(o.fJ4,{}),"Mark as not applied"]}),(0,r.jsx)(h.mB,{}),c&&(0,r.jsxs)(h._2,{onClick:g.onAttachRevert,children:[(0,r.jsx)(o.W4E,{}),e.revertSql?"Replace revert file…":"Add a revert file…"]}),(0,r.jsxs)(h._2,{onClick:()=>g.onOpenInEditor(R),children:[(0,r.jsx)(o.Uoo,{}),"Open ",k," SQL in editor"]}),(0,r.jsxs)(h._2,{onClick:()=>void I(),children:[(0,r.jsx)(o.hX7,{}),"Copy ",k," SQL"]}),c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.mB,{}),(0,r.jsx)(h._2,{variant:"destructive",onClick:g.onRemove,children:"Remove from this set"})]})]})]})]})]}),a&&(0,r.jsxs)("div",{className:"border-t bg-muted/25",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,r.jsx)($.x,{label:`SQL for ${e.version}`,value:b,onChange:v,options:[...u?[{value:"changes",label:"Changes"}]:[],{value:"apply",label:"Apply"},{value:"revert",label:"Revert"}]}),"changes"===b&&u?(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-3 font-mono text-[11px]",children:[(0,r.jsxs)("span",{className:"shrink-0 text-red-600 dark:text-red-400",children:["− ran on ",u.connectionName]}),(0,r.jsxs)("span",{className:"truncate text-emerald-600 dark:text-emerald-400",children:["+ ",e.applyPath]})]}):(0,r.jsx)("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",children:"revert"===b?e.revertPath??"no revert file":e.applyPath}),"changes"!==b&&(0,r.jsxs)(m.$,{size:"xs",variant:"ghost",className:"ml-auto",onClick:()=>void I(),children:[y?(0,r.jsx)(o.wiW,{"data-icon":"inline-start"}):(0,r.jsx)(o.hX7,{"data-icon":"inline-start"}),y?"Copied":"Copy"]})]}),D.length>0&&(0,r.jsx)("ul",{className:"space-y-1 px-3 pb-2",children:D.map(e=>(0,r.jsxs)("li",{className:"flex gap-1.5 text-[11px] text-amber-700 dark:text-amber-400",children:[(0,r.jsx)(o.e5t,{className:"mt-px size-3 shrink-0"}),(0,r.jsx)("span",{children:e})]},e))}),"changes"===b&&u?u.error?(0,r.jsx)("p",{className:"px-3 pb-3 font-mono text-xs text-destructive",children:u.error}):void 0===u.appliedSql?(0,r.jsxs)("p",{className:"px-3 pb-3 text-xs text-muted-foreground",children:["Reading what ran on ",u.connectionName,"…"]}):null===u.appliedSql?(0,r.jsxs)("p",{className:"px-3 pb-3 text-xs text-muted-foreground",children:[u.connectionName," did not keep the SQL it ran, so there is nothing to compare against."]}):(0,r.jsx)(A,{before:u.appliedSql,after:e.applySql,className:"max-h-96 pb-2"}):R?(0,r.jsx)(S.os,{sql:R,className:"max-h-72 overflow-auto px-3 pb-3"}):(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-3 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:"No revert file, so this one cannot be undone from here."}),c&&(0,r.jsxs)(m.$,{size:"xs",variant:"outline",onClick:g.onAttachRevert,children:[(0,r.jsx)(o.W4E,{"data-icon":"inline-start"}),"Add one"]})]})]})]})}function D({environments:e,targetId:t,onSelect:n}){let s=e.find(e=>e.connection.id===t);return s?(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Running against"}),(0,r.jsxs)(h.rI,{children:[(0,r.jsxs)(h.ty,{disabled:e.length<2,className:"flex h-7 cursor-pointer items-center gap-1.5 rounded-lg border bg-background px-2 text-xs font-medium outline-none hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-default data-open:bg-muted/60",children:[(0,r.jsx)(w.F,{connection:s.connection}),(0,r.jsx)("span",{className:"max-w-32 truncate",children:s.connection.name})]}),(0,r.jsx)(h.SQ,{align:"start",className:"min-w-52",children:e.map(e=>(0,r.jsxs)(h._2,{onClick:()=>n(e.connection.id),className:e.connection.id===t?"font-medium":void 0,children:[(0,r.jsx)(w.F,{connection:e.connection}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.connection.name}),(0,r.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[e.summary.applied,"/",e.summary.total]})]},e.connection.id))})]})]}):null}function I({environments:e,targetId:t,caption:n,loading:s,selection:i,onSelect:a,onCompare:l}){return(0,r.jsxs)("div",{className:"flex h-11 shrink-0 items-center border-b bg-muted/20",children:[(0,r.jsx)("span",{className:"flex h-11 shrink-0 items-center pl-3",children:(0,r.jsx)(F,{checked:i.checked,label:i.checked?"Clear selection":"Select all",onToggle:()=>i.onToggle()})}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate px-2 text-xs text-muted-foreground",children:n}),e.map(e=>{let{connection:n,summary:i,ledger:l,error:o}=e,d=n.id===t;return(0,r.jsxs)("button",{type:"button",disabled:d,"aria-current":d?"true":void 0,title:d?`${n.name} is what Apply and Revert run against`:`Run against ${n.name} instead`,onClick:()=>a(n.id),className:(0,N.cn)("flex h-11 shrink-0 flex-col items-center justify-center gap-0.5 border-l text-[11px] outline-none",E,d?"cursor-default bg-foreground/[0.04] font-medium":"cursor-pointer text-muted-foreground hover:bg-muted/60 hover:text-foreground",s&&"opacity-60"),children:[(0,r.jsxs)("span",{className:"flex max-w-full items-center gap-1",children:[(0,r.jsx)(w.F,{connection:n,className:"size-1.5"}),(0,r.jsx)("span",{className:"truncate",children:n.name})]}),o?(0,r.jsx)("span",{className:"text-destructive",children:"unreachable"}):l?(0,r.jsxs)("span",{className:"tabular-nums text-muted-foreground/80",children:[i.applied,"/",i.total,i.drifted>0&&(0,r.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:" !"})]}):(0,r.jsx)("span",{className:"text-muted-foreground/70",children:"reading…"})]},n.id)}),(0,r.jsx)("div",{className:(0,N.cn)("flex shrink-0 items-center justify-end border-l pr-2 pl-1",q),children:e.length>1&&(0,r.jsx)(m.$,{size:"icon-xs",variant:"ghost",title:"Compare the two schemas","aria-label":"Compare schemas",onClick:()=>{let n=e.find(e=>e.connection.id!==t);n&&l(n.connection.id)},children:(0,r.jsx)(o.R4X,{})})})]})}var L=n(42763),P=n(60529),B=n(33807);function G({schema:e,found:t,onOpenChange:n,onSave:s}){let[i,a]=(0,l.useState)(e),o=i.trim(),d=(0,j.hD)(o),c=t.filter(e=>e.schema!==o);function u(){d&&(s(o),n(!1))}return(0,r.jsx)(L.lG,{open:!0,onOpenChange:n,children:(0,r.jsxs)(L.Cf,{className:"sm:max-w-md",children:[(0,r.jsxs)(L.c7,{children:[(0,r.jsx)(L.L3,{children:"Ledger schema"}),(0,r.jsx)(L.rr,{children:"Where each database keeps its record of what has run. Created on the first apply."})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)(B.J,{htmlFor:"ledger-schema",children:"Schema"}),(0,r.jsx)(P.p,{id:"ledger-schema",value:i,spellCheck:!1,autoComplete:"off","aria-invalid":o.length>0&&!d,onChange:e=>a(e.target.value),onKeyDown:e=>"Enter"===e.key&&u()}),(0,r.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:d?`${o}.${j.R9}`:"\xa0"}),o.length>0&&!d&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:"Letters, digits and underscores only, starting with a letter or underscore."})]}),c.length>0&&(0,r.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[c.map(e=>`${e.name} keeps its ledger in ${e.schema}`).join("; "),". That one stays where it is."]}),(0,r.jsxs)(L.Es,{children:[o!==j.aC&&(0,r.jsx)(m.$,{variant:"ghost",onClick:()=>a(j.aC),children:"Reset"}),(0,r.jsx)(m.$,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),(0,r.jsx)(m.$,{disabled:!d,onClick:u,children:"Save"})]})]})})}var Q=n(42611),V=n(41069),Y=n(77649),K=n(27013),W=n(18349);function X({initial:e,file:t,onOpenChange:n,onSave:s}){let[i,a]=(0,l.useState)(e),[o,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),h=i.trim()!==e.trim();async function x(e){if(e?.preventDefault(),h&&!o){d(!0),u(null);try{await s(i.trim()),n(!1)}catch(e){u(e instanceof Error?e.message:String(e))}finally{d(!1)}}}return(0,r.jsx)(L.lG,{open:!0,onOpenChange:e=>!o&&n(e),children:(0,r.jsx)(L.Cf,{className:"sm:max-w-lg",showCloseButton:!1,children:(0,r.jsxs)("form",{onSubmit:e=>void x(e),className:"flex flex-col gap-4",children:[(0,r.jsx)(L.c7,{children:(0,r.jsxs)("div",{className:"flex items-baseline gap-3",children:[(0,r.jsx)(L.L3,{children:"Note"}),t&&(0,r.jsx)("span",{className:"ml-auto truncate font-mono text-[11px] text-muted-foreground",title:"Written into the migration's folder, to commit with the SQL",children:t})]})}),(0,r.jsx)(W.T,{autoFocus:!0,"aria-label":"Note",value:i,maxLength:j.XG,placeholder:"Apply 0001–0007, deploy the app, then apply 0008.",className:"max-h-[50vh] min-h-32",onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&x()}}),c&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:c}),(0,r.jsxs)(L.Es,{children:[(0,r.jsx)(m.$,{type:"button",variant:"ghost",disabled:o,onClick:()=>n(!1),children:"Cancel"}),(0,r.jsx)(m.$,{type:"submit",disabled:!h||o,children:o?"Saving…":"Save"})]})]})})})}var U=n(83504),H=n(71612);function Z({setId:e}){let t=(0,a.useRouter)(),{connection:n,tables:s}=(0,d.k)(),u=(0,k.jV)(e=>e.addFiles),w=(0,k.jV)(e=>e.renameSet),S=(0,k.jV)(e=>e.setNote),$=(0,k.jV)(e=>e.removeSet),C=(0,k.jV)(e=>e.removeStep),R=(0,k.jV)(e=>e.record),z=(0,k.jV)(e=>e.ledgerSchema),A=(0,k.jV)(e=>e.setLedgerSchema),M=(0,k.Ss)(e),{root:E}=(0,k.ox)(n.id),q=(0,H.y)((0,j.km)(e)?E:null),F=(0,j.km)(e)?q.data?.sets.find(t=>t.id===e)??null:M,O=!!F?.source,T=(0,v.gz)(n.id),L=(0,y.En)(e=>e.setDraft),P=(0,c.$C)(),[B,W]=(0,l.useState)("migrations"),[er,es]=(0,l.useState)([]),[ei,ea]=(0,l.useState)([]),el=(0,l.useRef)(null),[eo,ed]=(0,l.useState)(null),[ec,eu]=(0,l.useState)(null),[em,eh]=(0,l.useState)(!1),[ex,ep]=(0,l.useState)(!1),[ef,eg]=(0,l.useState)(null),[ej,ev]=(0,l.useState)(null),[eb,ek]=(0,l.useState)(!1),[ey,eN]=(0,l.useState)(!1),[ew,eS]=(0,l.useState)(!1),e$=(0,l.useRef)(null),eC=(0,l.useRef)(!1),eR=(0,l.useMemo)(()=>[n,...T],[n,T]),ez=eR.map(e=>e.url).join("|"),eA=(0,p.Y)(`ledgers:${z}:${ez}`,async e=>Object.fromEntries(await Promise.all(eR.map(async t=>{try{return[t.id,{ledger:await f.F.ledger(t.url,z,e),error:null}]}catch(n){if(e.aborted)throw n;return[t.id,{ledger:null,error:n instanceof Error?n.message:String(n)}]}})))),eM=eA.data?.[n.id]??null,eE=F?.name??"",eq=(0,l.useMemo)(()=>(0,g.Gf)(eM?.ledger,eE),[eM?.ledger,eE]),eF=(0,l.useMemo)(()=>eR.map(e=>{let t=eA.data?.[e.id]??null,n=(0,g.Gf)(t?.ledger,eE);return{connection:e,ledger:n,error:t?.error??null,summary:(0,g.eh)(F,n)}}),[eR,eA.data,F,eE]),eO=(0,l.useMemo)(()=>{let e=new Set;for(let t of F?.steps??[])if(er.includes(t.version))for(let n of eF)"drifted"===(0,g.FY)(t,n.ledger)&&e.add(n.connection.id);return eR.filter(t=>e.has(t.id))},[F,er,eF,eR]),eT=(0,p.Y)(`stored:${z}:${eO.map(e=>e.url).join("|")}`,async e=>Object.fromEntries(await Promise.all(eO.map(async t=>{try{return[t.id,{ledger:await f.F.ledger(t.url,z,e,!0),error:null}]}catch(n){if(e.aborted)throw n;return[t.id,{ledger:null,error:n instanceof Error?n.message:String(n)}]}})))),e_=`/${encodeURIComponent(n.id)}/migrations`,eD=(0,k.jV)(e=>e.history),eI=(0,l.useMemo)(()=>(0,b.x)(eF.map(e=>({connection:e.connection,ledger:e.ledger})),eD).filter(e=>e.setName===eE),[eF,eD,eE]),eL=(0,g.eh)(F,eq),eP=(0,l.useMemo)(()=>(0,g.nb)(F,eq),[F,eq]),eB=(0,g.kB)(F,eq),eG=(0,l.useCallback)(t=>{eg(u(e,t.files)),W("migrations")},[u,e]),eQ=(0,Y.$)(eG);function eV(e,t,n=!1){(0!==t.steps.length||t.blockedBy)&&(eu(null),ed({...t,direction:e,recordOnly:n}))}function eY(e){return{steps:e,blockedBy:null}}async function eK(){if(!eo||!F)return;eC.current=!1,eh(!0);let e=eo.steps.map(e=>({version:e.version,name:e.name,status:"waiting"}));eu(e);let t=(t,n)=>{eu(e=e.map((e,r)=>r===t?{...e,...n}:e))},r=t=>{eu(e=e.map((e,n)=>n>=t&&"waiting"===e.status?{...e,status:"skipped"}:e))};for(let[e,s]of eo.steps.entries()){if(eC.current){r(e);break}let i="apply"===eo.direction?s.applySql:s.revertSql;if(!i&&!eo.recordOnly){t(e,{status:"failed",error:"No revert file for this migration."}),r(e+1);break}t(e,{status:"running"});try{let r=await f.F.migrate(n.url,{direction:eo.direction,version:s.version,name:s.name,checksum:s.checksum,setName:F.name,sql:i??"",revertSql:"apply"===eo.direction?s.revertSql:void 0,ledgerSchema:z,recordOnly:eo.recordOnly});t(e,{status:"ok",durationMs:r.durationMs}),R({setId:F.id,setName:F.name,connectionId:n.id,connectionName:n.name,direction:eo.direction,version:s.version,name:s.name,status:"ok",recorded:eo.recordOnly,durationMs:r.durationMs})}catch(a){let i=a instanceof Error?a.message:String(a);t(e,{status:"failed",error:i}),r(e+1),R({setId:F.id,setName:F.name,connectionId:n.id,connectionName:n.name,direction:eo.direction,version:s.version,name:s.name,status:"failed",durationMs:0,error:i});break}}eh(!1),eA.reload(),eT.reload(),s.reload(),e.every(e=>"ok"===e.status)&&ea([])}function eW(e){L(n.id,e),t.push(`/${encodeURIComponent(n.id)}/query`)}function eX(e){P(e)}async function eU(e){F&&(F.source?(await f.F.note(F.source.root,F.source.path,e),q.reload()):S(F.id,e))}async function eH(e){let t=e?.[0];ev(null),t&&ej&&F&&eg(u(F.id,[{path:`revert/${ej}_${t.name}`,text:await t.text()}]))}if(!F){let t=(0,j.km)(e)&&q.loading;return(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)(J,{name:t?"Reading…":"Not found"}),(0,r.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:t?(0,r.jsx)("p",{className:"text-sm",children:"Reading the folder…"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm",children:q.error?q.error:(0,j.km)(e)?"That migration is not in the folder on the branch you have checked out.":"That migration is no longer here."}),(0,r.jsx)(i(),{href:e_,className:"text-foreground underline underline-offset-4",children:"All migrations"})]})})]})}let eZ=new Set(ei),eJ=F.steps.filter(e=>eZ.has(e.version)).length,e0=eJ>0,e1=e0?(0,g.DM)(F,eq,eZ):(0,g.gj)(F,eq),e2=e0?(0,g.n9)(F,eq,eZ):(0,g.e)(F,eq),e3=em||eA.loading||q.loading;return(0,r.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",onDragOver:e=>{!O&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),ep(!0))},children:[(0,r.jsxs)(J,{name:F?.name??"",indexHref:e_,children:[F.source&&(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Read from ${F.source.path}`,children:[(0,r.jsx)(o.WzY,{className:"size-3.5 shrink-0"}),(0,r.jsx)("span",{className:"max-w-48 truncate font-mono",children:F.source.path})]}),(0,r.jsx)(D,{environments:eF,targetId:n.id,onSelect:eX}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,r.jsx)(m.$,{size:"icon-sm",variant:"ghost",disabled:eA.loading||q.loading,"aria-label":"Refresh",title:O?"Re-read the files and every environment's ledger":"Re-read every environment's ledger",onClick:function(){eA.reload(),eT.reload(),O&&q.reload()},children:(0,r.jsx)(o.oS8,{className:(0,N.cn)((eA.loading||q.loading)&&"animate-spin")})}),!O&&(0,r.jsxs)(m.$,{size:"sm",variant:"ghost",onClick:()=>ep(!0),children:[(0,r.jsx)(o.FeY,{"data-icon":"inline-start"}),"Import"]}),(0,r.jsxs)(h.rI,{children:[(0,r.jsx)(h.ty,{render:(0,r.jsx)(m.$,{size:"icon-sm",variant:"ghost","aria-label":"More migration actions"}),className:"cursor-pointer",children:(0,r.jsx)(o.YKd,{})}),(0,r.jsxs)(h.SQ,{align:"end",className:"min-w-64",children:[(0,r.jsxs)(h._2,{disabled:e3||0===e1.steps.length,onClick:()=>eV("apply",eY(e1.steps),!0),children:[(0,r.jsx)(o.nXx,{}),"Mark ",e1.steps.length," as already applied"]}),(0,r.jsx)(h.mB,{}),(0,r.jsxs)(h._2,{disabled:e3||0===e2.steps.length,onClick:()=>eV("revert",e2),children:[(0,r.jsx)(o.ij9,{}),e0?`Revert ${e2.steps.length} selected on ${n.name}`:`Revert everything on ${n.name}`]}),(0,r.jsx)(h.mB,{}),(0,r.jsxs)(h._2,{onClick:()=>eS(!0),children:[(0,r.jsx)(o.UA_,{}),F.note?"Edit note":"Add note"]}),!O&&(0,r.jsxs)(h._2,{onClick:()=>eN(!0),children:[(0,r.jsx)(o.NOV,{}),"Rename"]}),(0,r.jsxs)(h._2,{onClick:()=>ek(!0),children:[(0,r.jsx)(o.ooN,{}),"Ledger table",(0,r.jsxs)("span",{className:"ml-auto pl-3 font-mono text-[11px] text-muted-foreground",children:[z,".",j.R9]})]}),!O&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.mB,{}),(0,r.jsx)(h._2,{variant:"destructive",onClick:function(){F&&($(F.id),t.push(e_))},children:"Forget this migration"})]})]})]}),(0,r.jsxs)(m.$,{size:"sm",disabled:e3||0===e1.steps.length,onClick:()=>eV("apply",e1),children:[(0,r.jsx)(o.eGB,{"data-icon":"inline-start"}),0===e1.steps.length?e0?"Nothing selected to apply":"Up to date":`Apply ${e1.steps.length}${e0?" selected":""} to ${n.name}`]})]})]}),ef&&(0,r.jsx)(et,{report:ef,onDismiss:()=>eg(null)}),eQ.error&&(0,r.jsx)("p",{className:"border-b bg-destructive/5 px-4 py-1.5 text-xs text-destructive",children:eQ.error}),"migrations"===B&&F.note&&(0,r.jsx)(ee,{note:F.note,notePath:F.source?.notePath??null,onEdit:()=>eS(!0)}),(0,r.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:["history"===B?(0,r.jsx)(x.F,{className:"min-h-0 flex-1",children:(0,r.jsx)(Q.H,{events:eI,connections:eR,loading:eA.loading})}):eM?.error?(0,r.jsx)("p",{className:"flex-1 px-4 py-6 font-mono text-xs text-destructive",children:eM.error}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{environments:eF,targetId:n.id,caption:e0?`${eJ} selected`:function(e,t){if(t&&0===e.total)return"Reading…";let n=`${e.total} migration${1===e.total?"":"s"}`;return e.foreign>0?`${n} \xb7 ${e.foreign} not in this folder`:n}(eL,eA.loading),loading:eA.loading,selection:{checked:0!==eJ&&(eJ===F.steps.length||"mixed"),onToggle:function(){if(!F)return;let e=F.steps.map(e=>e.version);ea(t=>t.some(t=>e.includes(t))?[]:e)}},onSelect:eX,onCompare:function(e){v.lz.getState().setCompareTarget(n.id,e),t.push(`/${encodeURIComponent(n.id)}/diff`)}}),(0,r.jsxs)(x.F,{className:(0,N.cn)("min-h-0 flex-1",eA.loading&&"opacity-70"),children:[(F?.steps.length??0)===0&&!O&&(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(Y.k,{onFiles:eG,compact:!0})}),F.skipped.length>0&&O&&(0,r.jsxs)("div",{className:"border-b bg-muted/20 px-4 py-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),"Skipped ",F.skipped.length," file",1===F.skipped.length?"":"s"]}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5 pl-5 font-mono text-[11px]",children:F.skipped.map(e=>(0,r.jsx)("li",{children:e},e))})]}),(F?.steps??[]).map(e=>(0,r.jsx)(_,{step:e,targetId:n.id,status:(0,g.FY)(e,eq),environments:eF.map(t=>({connection:t.connection,status:(0,g.FY)(e,t.ledger),entry:(0,g.ay)(e,t.ledger),error:t.error})),isNewestApplied:eB?.version===e.version,expanded:er.includes(e.version),busy:e3,editable:!O,drift:function(e){let t=eF.filter(t=>"drifted"===(0,g.FY)(e,t.ledger)),r=t.find(e=>e.connection.id===n.id)??t[0];if(!r)return null;let s=eT.data?.[r.connection.id],i=s?.ledger?.entries.find(t=>t.setName===eE&&t.version===e.version);return{connectionName:r.connection.name,appliedSql:s?.ledger?i?.applySql??null:void 0,error:s?.error??null}}(e),selected:eZ.has(e.version),onSelect:t=>(function(e,t){if(!F)return;let n=F.steps.map(e=>e.version),r=el.current;el.current=e,ea(s=>{let i=!s.includes(e),a=[e];if(t&&r&&r!==e&&n.includes(r)){let[t,s]=[n.indexOf(r),n.indexOf(e)].sort((e,t)=>e-t);a=n.slice(t,s+1)}let l=new Set(s);for(let e of a)i?l.add(e):l.delete(e);return n.filter(e=>l.has(e))})})(e.version,t),onToggle:()=>{var t;return t=e.version,void es(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},actions:{onApplyThrough:()=>eV("apply",(0,g.gj)(F,eq,e.version)),onApplyOne:()=>eV("apply",{steps:[e],blockedBy:null}),onRevertThrough:()=>eV("revert",(0,g.e)(F,eq,e.version)),onMarkApplied:()=>eV("apply",eY([e]),!0),onMarkPending:()=>eV("revert",eY([e]),!0),onAttachRevert:()=>{ev(e.version),window.requestAnimationFrame(()=>e$.current?.click())},onRemove:()=>F&&C(F.id,e.version),onOpenInEditor:eW}},e.version)),eP.length>0&&(0,r.jsx)(en,{entries:eP,connectionName:n.name})]})]}),ex&&!O&&(0,r.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/85 p-6",onDragOver:e=>e.preventDefault(),onDragLeave:()=>ep(!1),onDrop:e=>{e.preventDefault(),ep(!1),eQ.importFrom(e.dataTransfer)},children:(0,r.jsx)(Y.k,{onFiles:eG,className:"w-full max-w-xl bg-background"})})]}),(0,r.jsx)(V.l,{pane:B,onPaneChange:W,historyCount:eI.length,migrationsLabel:"Files",caption:function({connectionName:e,summary:t,initialized:n,loading:r,foundIn:s,configuredSchema:i}){if(r&&null===n)return"Reading ledgers…";let a=[];return!1===n||t.pending>0?a.push(`${t.pending} of ${t.total} pending on ${e}`):a.push(`${e} is up to date`),t.drifted>0&&a.push(`${t.drifted} changed since applied`),s&&s!==i&&a.push(`ledger in ${s}`),a.join(" \xb7 ")}({connectionName:n.name,summary:eL,initialized:eq?.initialized??null,loading:eA.loading,foundIn:eq?.initialized?eq.schema:null,configuredSchema:z})}),(0,r.jsx)("input",{ref:e$,type:"file",accept:".sql",className:"sr-only",onChange:e=>{eH(e.target.files),e.target.value=""}}),(0,r.jsx)(K.K,{open:ey,title:"Rename migration",initial:F.name,submitLabel:"Rename",onOpenChange:eN,onSubmit:function(e){F&&w(F.id,e)}}),ew&&(0,r.jsx)(X,{initial:F.note??"",file:F.source?F.source.notePath?.split(/[\\/]/).at(-1)??"README.md":null,onOpenChange:eS,onSave:eU}),eb&&(0,r.jsx)(G,{schema:z,found:eF.filter(e=>e.ledger?.initialized).map(e=>({name:e.connection.name,schema:e.ledger?.schema??z})),onOpenChange:ek,onSave:e=>{A(e),eA.reload()}}),eo&&(0,r.jsx)(U.I,{open:!0,direction:eo.direction,connection:n,steps:eo.steps,blockedBy:eo.blockedBy,progress:ec,running:em,recordOnly:eo.recordOnly??!1,note:F.note,onRun:()=>void eK(),onStop:()=>{eC.current=!0},onClose:function(){em||(ed(null),eu(null))}})]})}function J({name:e,indexHref:t,children:n}){let s=(0,r.jsx)(o.olY,{className:"size-4 shrink-0 text-muted-foreground"});return(0,r.jsxs)(u.X,{children:[t?(0,r.jsx)(i(),{href:t,title:"All migrations","aria-label":"All migrations",className:"flex size-6 shrink-0 items-center justify-center rounded-md outline-none hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60",children:s}):s,(0,r.jsx)("span",{className:"min-w-0 truncate font-medium",children:e}),n]})}function ee({note:e,notePath:t,onEdit:n}){return(0,r.jsxs)("button",{type:"button",title:t?`${t} \xb7 click to edit`:"Click to edit",onClick:n,className:"group flex w-full cursor-pointer items-start gap-2 border-b px-4 py-2.5 text-left text-xs outline-none hover:bg-muted/30 focus-visible:bg-muted/30",children:[(0,r.jsx)(o.UA_,{className:"mt-px size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"max-h-40 min-w-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words",children:e}),(0,r.jsx)(o.NOV,{className:"mt-px size-3.5 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"})]})}function et({report:e,onDismiss:t}){let n=[];return e.added>0&&n.push(`added ${e.added}`),e.updated>0&&n.push(`updated ${e.updated}`),e.reverts>0&&n.push(`${e.reverts} revert file${1===e.reverts?"":"s"}`),(0,r.jsxs)("div",{className:"flex items-start gap-2 border-b bg-muted/30 px-4 py-1.5 text-xs",children:[(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[n.length>0?`Imported: ${n.join(", ")}`:"Nothing new in those files",e.skipped.length>0&&(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" ","\xb7 skipped ",e.skipped.slice(0,2).join(", "),e.skipped.length>2&&` and ${e.skipped.length-2} more`]})]}),(0,r.jsx)(m.$,{size:"xs",variant:"ghost",onClick:t,children:"Dismiss"})]})}function en({entries:e,connectionName:t}){return(0,r.jsxs)("div",{className:"border-t bg-muted/20",children:[(0,r.jsxs)("p",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),"Applied on ",t,", not in this folder"]}),e.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 text-xs opacity-70",children:[(0,r.jsx)(T,{status:"applied"}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name||"—"}),(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:new Date(e.appliedAt).toLocaleString()})]},e.version))]})}},15923:(e,t,n)=>{"use strict";n.d(t,{T:()=>s,r:()=>i});let r=new Set;function s(e){return r.add(e),()=>{r.delete(e)}}function i(){for(let e of r)e()}},18349:(e,t,n)=>{"use strict";n.d(t,{T:()=>i});var r=n(95155);n(12115);var s=n(40980);function i({className:e,...t}){return(0,r.jsx)("textarea",{"data-slot":"textarea",className:(0,s.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}},34263:(e,t,n)=>{"use strict";n.d(t,{En:()=>c,Pc:()=>d,jl:()=>o});var r=n(1934),s=n(31692),i=n(40980),a=n(63307);let l="ytdb:queries";(0,a.q)("db-studio:queries",l);let o=144,d=800,c=(0,r.v)()((0,s.Zr)(e=>({drafts:{},editorHeight:224,history:[],setDraft:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:n}})),setEditorHeight:t=>e({editorHeight:Math.min(d,Math.max(o,Math.round(t)))}),record:(t,n)=>e(e=>{let r=n.trim();if(!r)return e;let s=e.history.find(e=>e.connectionId===t&&e.sql===r),a={id:s?.id??(0,i.z)(),connectionId:t,sql:r,executedAt:Date.now()},l=0,o=0;return{history:[a,...e.history.filter(e=>e.id!==a.id)].filter(e=>!(l>=200)&&!(o+e.sql.length>1e6)&&(l+=1,o+=e.sql.length,!0))}}),remove:t=>e(e=>({history:e.history.filter(e=>e.id!==t)}))}),{name:l}))},40891:(e,t,n)=>{"use strict";n.d(t,{os:()=>v,iX:()=>b,mw:()=>j});var r=n(95155),s=n(12115),i=n(13267),a=n(89239),l=n(86846);let o=new Set(["add","all","alter","always","and","as","asc","authorization","between","by","cascade","case","cast","check","collate","column","concurrently","constraint","create","cross","current","default","deferrable","deferred","delete","desc","distinct","drop","else","end","except","exclude","exists","false","foreign","from","full","generated","grant","group","having","identity","if","ilike","immediate","in","include","index","inherits","inner","instead","intersect","into","is","join","key","lateral","left","like","limit","match","materialized","natural","no","not","null","nulls","of","offset","on","only","or","order","outer","over","partition","primary","references","replace","restrict","returning","right","select","server","set","stored","table","temp","temporary","then","time","to","trigger","true","union","unique","unlogged","update","using","values","view","when","where","window","with","without","zone"]);function d(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!r)break;if(m(r)){let r=n;for(n+=1;n<e.length&&m(e[n]);)n+=1;t.push({kind:"text",value:e.slice(r,n)});continue}if("-"===r&&"-"===e[n+1]){let r=n;for(n+=2;n<e.length&&"\n"!==e[n];)n+=1;t.push({kind:"comment",value:e.slice(r,n)});continue}if("/"===r&&"*"===e[n+1]){let r=e.indexOf("*/",n+2),s=-1===r?e.length:r+2;t.push({kind:"comment",value:e.slice(n,s)}),n=s;continue}if("$"===r){let r=function(e,t){if("$"!==e[t])return null;let n=t+1;for(;n<e.length&&p(e[n]);)n+=1;return"$"!==e[n]?null:e.slice(t,n+1)}(e,n);if(r){let s=n+r.length,i=e.indexOf(r,s),a=-1===i?e.length:i+r.length;t.push({kind:"string",value:e.slice(n,a)}),n=a;continue}}if('"'===r){n=u(e,n,'"',"ident",t);continue}if("'"===r){n=u(e,n,"'","string",t);continue}if(h(r)||"."===r&&h(e[n+1])){let r=n;n=function(e,t){let n=t;for("."===e[n]&&(n+=1);n<e.length&&h(e[n]);)n+=1;if("."===e[n]&&h(e[n+1]))for(n+=1;n<e.length&&h(e[n]);)n+=1;if("e"===e[n]||"E"===e[n]){let t=n+1;if(("+"===e[t]||"-"===e[t])&&(t+=1),h(e[t]))for(n=t;n<e.length&&h(e[n]);)n+=1}return n}(e,n),t.push({kind:"number",value:e.slice(r,n)});continue}if(x(r)){let r=n;for(n+=1;n<e.length&&p(e[n]);)n+=1;let s=e.slice(r,n);t.push({kind:function(e,t,n){let r=t.toLowerCase();if(o.has(r))return"keyword";let s=n;for(;s<e.length&&(" "===e[s]||" "===e[s]);)s+=1;return"("===e[s]?"function":"ident"}(e,s,n),value:s});continue}t.push({kind:"text",value:r}),n+=1}return t}function c(e){let t=[[]];for(let n of e){let e=n.value.split("\n");for(let r=0;r<e.length;r+=1){r>0&&t.push([]);let s=e[r],i=t[t.length-1];s&&i&&i.push({kind:n.kind,value:s})}}return t}function u(e,t,n,r,s){let i=t+1;for(;i<e.length;){if(e[i]===n){if(e[i+1]===n){i+=2;continue}i+=1;break}i+=1}return s.push({kind:r,value:e.slice(t,i)}),i}function m(e){return" "===e||" "===e||"\n"===e||"\r"===e}function h(e){return void 0!==e&&e>="0"&&e<="9"}function x(e){return void 0!==e&&(e>="A"&&e<="Z"||e>="a"&&e<="z"||"_"===e)}function p(e){return x(e)||h(e)||"$"===e}var f=n(40980);function g({tokens:e}){return e.map((e,t)=>(0,r.jsx)("span",{className:function(e){switch(e){case"keyword":return"text-sky-700 dark:text-sky-400";case"function":return"text-violet-700 dark:text-fuchsia-400";case"ident":return"text-foreground";case"string":case"number":return"text-amber-700 dark:text-amber-300";case"comment":return"text-muted-foreground";case"text":return"text-foreground/80";default:return e}}(e.kind),children:e.value},t))}async function j(e){try{await navigator.clipboard.writeText(e);return}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),t.remove()}}function v({sql:e,className:t}){let n=(0,s.useMemo)(()=>c(d(e.trimEnd())),[e]);return(0,r.jsx)("pre",{className:(0,f.cn)("overflow-x-auto font-mono text-[12px] leading-5 whitespace-pre",t),children:(0,r.jsx)("code",{children:n.map((e,t)=>(0,r.jsx)("div",{className:"min-h-5",children:(0,r.jsx)(g,{tokens:e})},t))})})}function b({sql:e,error:t,loading:n,actions:o}){let[u,m]=(0,s.useState)(!1),h=(0,s.useMemo)(()=>e?c(d(e.trimEnd())):[],[e]);if(t)return(0,r.jsx)("p",{className:"flex-1 px-4 py-6 font-mono text-xs text-destructive",children:t});if(!e||n&&0===h.length)return(0,r.jsx)("div",{className:"flex flex-col gap-2 p-4",children:Array.from({length:16},(e,t)=>(0,r.jsx)(l.E,{className:"h-4 w-full"},t))});async function x(){e&&(await j(e),m(!0),window.setTimeout(()=>m(!1),1500))}let p=`${Math.max(String(h.length).length,2)+1}ch`;return(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col","data-sql-source":"",children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-center justify-end gap-2 px-3 py-1",children:[o,(0,r.jsxs)(a.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>void x(),children:[u?(0,r.jsx)(i.wiW,{"data-icon":"inline-start"}):(0,r.jsx)(i.hX7,{"data-icon":"inline-start"}),u?"Copied":"Copy SQL"]})]}),(0,r.jsx)("div",{className:(0,f.cn)("min-h-0 flex-1 overflow-auto",n&&"opacity-60"),children:(0,r.jsx)("pre",{className:"min-w-max px-4 pb-4 font-mono text-[13px] leading-6",children:h.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-h-6",children:[(0,r.jsx)("span",{className:"sticky left-0 shrink-0 bg-background pr-4 text-right text-muted-foreground/45 select-none",style:{width:p},children:t+1}),(0,r.jsx)("code",{className:"pr-8 whitespace-pre",children:(0,r.jsx)(g,{tokens:e})})]},t))})})]})}},52310:(e,t,n)=>{Promise.resolve().then(n.bind(n,10037))},79781:(e,t,n)=>{"use strict";n.d(t,{$C:()=>c,yG:()=>u});var r=n(73321),s=n(12115),i=n(27529),a=n(15923),l=n(20185),o=n(69586),d=n(36331);function c(){let e=(0,r.useRouter)(),t=(0,r.usePathname)(),{connection:n}=(0,d.k)(),c=(0,o.Z)(e=>e.connections);return(0,s.useCallback)(async r=>{if(r===n.id)return;let s=c.find(e=>e.id===r);if(!s)return;(0,a.r)();let o=(0,l.ZG)(t),d=!!n.layoutGroup&&n.layoutGroup===s.layoutGroup,u=!0;if("table"===o.kind&&!d)try{var m,h;m=await i.F.tables(s.url),h=o.table,u=m.some(e=>e.schema===h.schema&&e.name===h.name)}catch{u=!1}e.push((0,l.gZ)(t,r,{tableExists:u}))},[n.id,n.layoutGroup,c,t,e])}function u(){let{connection:e}=(0,d.k)(),t=(0,o.Z)(e=>e.connections),n=c(),r=function(e,t){let n=e.findIndex(e=>e.id===t);if(!(e.length<2)&&-1!==n)return e[(n+1)%e.length]}(t,e.id);return{run:()=>r?n(r.id):Promise.resolve(),enabled:void 0!==r,next:r}}},86846:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(95155),s=n(40980);function i({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,s.cn)("animate-pulse rounded-md bg-muted",e),...t})}}},e=>{e.O(0,[4506,1731,8026,4730,8361,8322,6090,7709,3732,8441,3794,7358],()=>e(e.s=52310)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9820],{7412:(e,t,n)=>{"use strict";n.d(t,{L:()=>i});var s=n(95155),r=n(13267),a=n(40980);function i({trailing:e,className:t,...n}){return(0,s.jsxs)("div",{className:(0,a.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,s.jsx)(r.TfF,{className:"size-3.5 shrink-0"}),(0,s.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...n,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},28330:(e,t,n)=>{Promise.resolve().then(n.bind(n,69063))},69063:(e,t,n)=>{"use strict";n.d(t,{MigrationsIndex:()=>V});var s=n(95155),r=n(98500),a=n.n(r),i=n(73321),l=n(12115),o=n(13267),d=n(72194),c=n(36331),m=n(17491),h=n(89239),u=n(72264),x=n(35942),p=n(7412),g=n(87364),f=n(27529),j=n(9385),v=n(62417),b=n(74590),N=n(79668),y=n(40980),k=n(42611),w=n(20642),$=n(77649),C=n(27013),S=n(41069),z=n(42763),F=n(83504);let M=[{verdict:"applied",title:"Already there",hint:"Everything these create or change is in the database.",preselected:!0},{verdict:"partial",title:"Partly there",hint:"Some of what these do is in the database and some is not — often a later migration changed it again.",preselected:!1},{verdict:"unknown",title:"Leaves no trace",hint:"Data changes, seeds, and grants cannot be seen in the schema. Include them if you know they ran.",preselected:!1},{verdict:"pending",title:"Not there",hint:"Nothing these do is in the database. Marking these hides work that still needs to run.",preselected:!1}];function R(e){return`${e.setName}\0${e.version}`}function E({connection:e,ledgerSchema:t,plan:n,onDone:r,onOpenChange:a}){let[i,c]=(0,l.useState)(null),[m,u]=(0,l.useState)(null),[x,p]=(0,l.useState)(new Set),[g,j]=(0,l.useState)([]),[v,b]=(0,l.useState)(!1),[N,k]=(0,l.useState)(null),[w,$]=(0,l.useState)(null);(0,l.useEffect)(()=>{let t=new AbortController;return f.F.detect(e.url,n.entries.map(e=>({setName:e.setName,version:e.version,sql:e.applySql})),t.signal).then(({results:e})=>{c(e);let t=new Set;for(let n of e)M.find(e=>e.verdict===n.verdict)?.preselected&&t.add(R(n));p(t)}).catch(e=>{t.signal.aborted||u(e instanceof Error?e.message:String(e))}),()=>t.abort()},[e.url,n.entries]);let C=(0,l.useMemo)(()=>{if(!i)return[];let e=new Map(n.entries.map(e=>[R(e),e]));return M.map(t=>({verdict:t.verdict,title:t.title,hint:t.hint,entries:i.filter(e=>e.verdict===t.verdict).flatMap(t=>{let n=e.get(R(t));return n?[{entry:n,result:t}]:[]})})).filter(e=>e.entries.length>0)},[i,n.entries]),S=n.entries.filter(e=>x.has(R(e)));async function I(n){b(!0),$(null);try{k(await f.F.adopt(e.url,{ledgerSchema:t,entries:n})),r()}catch(e){$(e instanceof Error?e.message:String(e))}finally{b(!1)}}let O=!i&&!m;return(0,s.jsx)(z.lG,{open:!0,onOpenChange:e=>!v&&a(e),children:(0,s.jsxs)(z.Cf,{className:"sm:max-w-xl",children:[(0,s.jsxs)(z.c7,{children:[(0,s.jsx)(z.L3,{children:N?`Marked ${N.recorded} as applied`:O?`Checking ${e.name}…`:`Mark as already applied on ${e.name}`}),(0,s.jsx)(z.rr,{children:(0,s.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)("span",{children:N?"Recorded on":"Records on"}),(0,s.jsx)(d.F,{connection:e}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.name}),(0,s.jsx)("span",{className:"font-mono text-[11px]",children:(0,F.p)(e.url)})]})})]}),N?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:N.existing>0?`${N.existing} were already in the ledger and were left as they were.`:"Every one of them was new to the ledger."}):O?(0,s.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)(o.gnh,{className:"size-3.5 animate-spin"}),"Reading the schema to see which of the ",n.entries.length," have already run…"]}):m?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"max-h-32 overflow-auto rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:m}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The check could not run. You can still mark all ",n.entries.length," as applied if you know the database already has these changes."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"max-h-80 overflow-y-auto rounded-md border",children:C.map(e=>{let t=e.entries.filter(({entry:e})=>x.has(R(e))).length,n=g.includes(e.verdict);return(0,s.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,s.jsx)("input",{type:"checkbox","aria-label":`Include ${e.title}`,className:"size-3.5 cursor-pointer accent-primary",checked:t===e.entries.length,ref:n=>{n&&(n.indeterminate=t>0&&t<e.entries.length)},onChange:t=>{var n;return n=t.target.checked,void p(t=>{let s=new Set(t);for(let{entry:t}of e.entries)n?s.add(R(t)):s.delete(R(t));return s})}}),(0,s.jsxs)("button",{type:"button","aria-expanded":n,onClick:()=>{var t;return t=e.verdict,void j(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",children:[(0,s.jsx)(o.nNJ,{className:(0,y.cn)("size-3.5 shrink-0 text-muted-foreground/70 transition-transform",n&&"rotate-90")}),(0,s.jsx)("span",{className:"text-sm",children:e.title}),(0,s.jsxs)("span",{className:"tabular-nums text-xs text-muted-foreground",children:[t,"/",e.entries.length]})]}),(0,s.jsx)(q,{verdict:e.verdict})]}),!n&&(0,s.jsx)("p",{className:"px-9 pb-2 text-[11px] text-muted-foreground",children:e.hint}),n&&(0,s.jsxs)("div",{className:"bg-muted/25",children:[(0,s.jsx)("p",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:e.hint}),e.entries.map(({entry:e,result:t})=>{let n=t.evidence.filter(e=>!e.satisfied),r=t.evidence.find(e=>e.note)?.note;return(0,s.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 border-t px-3 py-1.5 text-xs hover:bg-muted/40",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-0.5 size-3.5 cursor-pointer accent-primary",checked:x.has(R(e)),onChange:()=>{p(t=>{let n=new Set(t),s=R(e);return n.has(s)?n.delete(s):n.add(s),n})}}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e.setName}),(0,s.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,s.jsx)("span",{className:"min-w-0 truncate",children:e.name})]}),(n.length>0||r)&&(0,s.jsxs)("span",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",children:[n.length>0&&(0,s.jsxs)(s.Fragment,{children:["Missing: ",n.slice(0,2).map(e=>e.description).join(", "),n.length>2&&` and ${n.length-2} more`]}),n.length>0&&r&&" \xb7 ",r]})]})]},R(e))})]})]},e.verdict)})}),(0,s.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[(0,s.jsx)("span",{className:"font-medium",children:"No SQL runs."})," Only the ledger on"," ",e.name," changes, in one transaction. Rows already there are not touched."]})]}),w&&(0,s.jsx)("p",{className:"max-h-32 overflow-auto rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-[11px] whitespace-pre-wrap text-destructive",children:w}),(0,s.jsx)(z.Es,{children:N?(0,s.jsx)(h.$,{onClick:()=>a(!1),children:"Close"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h.$,{variant:"outline",disabled:v,onClick:()=>a(!1),children:"Cancel"}),m?(0,s.jsx)(h.$,{disabled:v,onClick:()=>void I(n.entries),children:v?"Marking…":`Mark all ${n.entries.length} as applied`}):(0,s.jsx)(h.$,{disabled:v||O||0===S.length,onClick:()=>void I(S),children:v?"Marking…":`Mark as applied (${S.length})`})]})})]})})}function q({verdict:e}){return"applied"===e?(0,s.jsx)(o.wiW,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400"}):"partial"===e?(0,s.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}):"pending"===e?(0,s.jsx)(o.e5t,{className:"size-3.5 shrink-0 text-destructive"}):(0,s.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"})}var I=n(60529),O=n(33807);function A({root:e,environmentNames:t,onOpenChange:n,onSave:r}){let[a,i]=(0,l.useState)(e??""),o=a.trim(),d=o.startsWith("/")||o.startsWith("~")||/^[A-Za-z]:[\\/]/.test(o);function c(){o&&d&&(r(o),n(!1))}return(0,s.jsx)(z.lG,{open:!0,onOpenChange:n,children:(0,s.jsxs)(z.Cf,{className:"sm:max-w-lg",children:[(0,s.jsxs)(z.c7,{children:[(0,s.jsx)(z.L3,{children:"Migrations folder"}),(0,s.jsxs)(z.rr,{children:["A folder on this computer. Each folder inside it that holds .sql files is one migration, read fresh from disk every time — whatever branch is checked out is what shows. ",t.join(", ")," will all read from it."]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)(O.J,{htmlFor:"repo-root",children:"Path"}),(0,s.jsx)(I.p,{id:"repo-root",value:a,placeholder:"~/code/app/src/lib/supabase/migrations",spellCheck:!1,autoComplete:"off",autoFocus:!0,"aria-invalid":o.length>0&&!d,onChange:e=>i(e.target.value),onKeyDown:e=>"Enter"===e.key&&c()}),o.length>0&&!d&&(0,s.jsx)("p",{className:"text-xs text-destructive",children:"An absolute path, or one starting with ~."})]}),(0,s.jsxs)(z.Es,{children:[e&&(0,s.jsx)(h.$,{variant:"ghost",className:"mr-auto",onClick:function(){r(null),n(!1)},children:"Stop reading from disk"}),(0,s.jsx)(h.$,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),(0,s.jsx)(h.$,{disabled:!o||!d,onClick:c,children:"Save"})]})]})})}var L=n(71612);function V(){let e=(0,i.useRouter)(),{connection:t}=(0,c.k)(),n=(0,N.jV)(e=>e.sets),r=(0,N.jV)(e=>e.createSet),a=(0,N.jV)(e=>e.adoptSet),d=(0,N.jV)(e=>e.addFiles),p=(0,N.jV)(e=>e.removeSet),z=(0,N.jV)(e=>e.ledgerSchema),F=(0,N.jV)(e=>e.history),M=(0,b.gz)(t.id),[R,q]=(0,l.useState)("migrations"),[I,O]=(0,l.useState)(null),[V,_]=(0,l.useState)(null),[U,W]=(0,l.useState)(!1),[D,T]=(0,l.useState)(!1),[G,H]=(0,l.useState)(null),K=(0,l.useMemo)(()=>[t,...M],[t,M]),J=K.map(e=>e.url).join("|"),{scope:X,root:Z}=(0,N.ox)(t.id),ee=(0,N.jV)(e=>e.setRepoRoot),et=(0,N.kG)(X),en=(0,N.jV)(e=>e.setListFilter),es=(0,L.y)(Z),er=(0,l.useMemo)(()=>[...es.data?.sets??[]].sort((e,t)=>t.importedAt-e.importedAt),[es.data]),ea=(0,g.Y)(`ledgers:${z}:${J}`,async e=>Object.fromEntries(await Promise.all(K.map(async t=>{try{return[t.id,{ledger:await f.F.ledger(t.url,z,e),error:null}]}catch(n){if(e.aborted)throw n;return[t.id,{ledger:null,error:n instanceof Error?n.message:String(n)}]}})))),ei=(0,l.useMemo)(()=>(0,j.x)(K.map(e=>({connection:e,ledger:ea.data?.[e.id]?.ledger??null})),F),[K,ea.data,F]),el=`/${encodeURIComponent(t.id)}/migrations`,eo=(0,l.useCallback)(t=>{let n=r(t.name);d(n,t.files),e.push(`${el}/${encodeURIComponent(n)}`)},[r,d,e,el]);async function ed(t){O(t),_(null);try{let n=await Promise.all(K.map(async e=>{try{return{read:await f.F.ledger(e.url,z,void 0,!0),error:null}}catch(e){return{read:null,error:e instanceof Error?e.message:String(e)}}})),s=n.find(e=>e.error);if(s?.error)return void _(s.error);let r=n.some(e=>e.read&&void 0===e.read.withSql),i=new Map;for(let{read:e}of n)for(let n of e?.entries??[]){if(n.setName.trim()!==t)continue;let e=i.get(n.version);e?.applySql||i.set(n.version,n)}let{set:l,missing:o}=(0,w.wQ)(t,[...i.values()]);if(0===l.steps.length)return void _(r?"The YTDB running on your machine is older than this page and cannot send stored SQL. Restart it with `npx @theobourgeois/ytdb@latest`.":`${t} was applied before YTDB stored SQL, so it cannot be rebuilt. Drop its folder instead.`);a(l),o.length>0&&_(`Rebuilt ${l.steps.length} of ${l.steps.length+o.length}. No SQL was stored for ${o.join(", ")}.`),e.push(`${el}/${encodeURIComponent(l.id)}`)}catch(e){_(e instanceof Error?e.message:String(e))}finally{O(null)}}let ec=(0,l.useMemo)(()=>[...n].sort((e,t)=>t.importedAt-e.importedAt),[n]),em=(0,l.useMemo)(()=>(0,v.lF)(K.map(e=>({connection:e,ledger:ea.data?.[e.id]?.ledger??null})),[...er,...n].map(e=>e.name)),[K,ea.data,er,n]),eh=(0,l.useMemo)(()=>{let e=ea.data?.[t.id]?.ledger??null,n=[],s=0;if(!e)return{sets:0,entries:n};for(let t of er){let r=(0,v.gj)(t,(0,v.Gf)(e,t.name));if(0!==r.steps.length)for(let e of(s+=1,r.steps))n.push({setName:t.name,version:e.version,name:e.name,checksum:e.checksum,applySql:e.applySql,revertSql:e.revertSql})}return{sets:s,entries:n}},[ea.data,t.id,er]),eu=ea.loading||es.loading,ex=0===er.length&&0===n.length&&0===em.length,ep=(0,l.useCallback)(e=>K.map(t=>({connection:t,summary:(0,v.eh)(e,ea.data?.[t.id]?.ledger??null),read:!!ea.data?.[t.id]?.ledger,error:ea.data?.[t.id]?.error??null})),[K,ea.data]),eg=(0,l.useCallback)(e=>(0,v.yy)(e,ep(e).map(e=>({connectionId:e.connection.id,summary:e.summary,read:e.read})),et),[ep,et]),ef=(0,l.useMemo)(()=>er.filter(eg),[er,eg]),ej=(0,l.useMemo)(()=>ec.filter(eg),[ec,eg]),ev=""!==et.query.trim()||"all"!==et.status,eb=er.length+ec.length-ef.length-ej.length;return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,s.jsxs)(m.X,{children:[(0,s.jsx)(o.olY,{className:"size-4 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"font-medium",children:"Migrations"}),Z&&(0,s.jsx)(Y,{root:Z,git:es.data?.git??null,onEdit:()=>T(!0)}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,s.jsx)(h.$,{size:"icon-sm",variant:"ghost",disabled:eu,"aria-label":"Refresh",title:Z?"Re-read the folder and every environment's ledger":"Re-read every environment's ledger",onClick:function(){ea.reload(),es.reload()},children:(0,s.jsx)(o.oS8,{className:(0,y.cn)(eu&&"animate-spin")})}),!Z&&(0,s.jsxs)(h.$,{size:"sm",variant:"ghost",onClick:()=>T(!0),children:[(0,s.jsx)(o.WzY,{"data-icon":"inline-start"}),"Read from a folder"]}),(0,s.jsxs)(h.$,{size:"sm",variant:"ghost",onClick:()=>W(!0),children:[(0,s.jsx)(o.enO,{"data-icon":"inline-start"}),"New migration"]}),(Z||n.length>0)&&(0,s.jsxs)(u.rI,{children:[(0,s.jsx)(u.ty,{render:(0,s.jsx)(h.$,{size:"icon-sm",variant:"ghost","aria-label":"More migration actions"}),className:"cursor-pointer",children:(0,s.jsx)(o.YKd,{})}),(0,s.jsxs)(u.SQ,{align:"end",className:"min-w-72",children:[Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u._2,{disabled:eu||0===eh.entries.length,onClick:()=>H(eh),children:[(0,s.jsx)(o.nXx,{}),"Mark everything as applied on ",t.name,(0,s.jsx)("span",{className:"ml-auto pl-3 font-mono text-[11px] text-muted-foreground",children:eh.entries.length})]}),(0,s.jsx)(u.mB,{}),(0,s.jsxs)(u._2,{onClick:()=>T(!0),children:[(0,s.jsx)(o.WzY,{}),"Change folder…"]})]}),n.length>0&&(0,s.jsxs)(s.Fragment,{children:[Z&&(0,s.jsx)(u.mB,{}),(0,s.jsxs)(u._2,{variant:"destructive",onClick:function(){for(let e of n)p(e.id)},children:["Forget ",n.length," imported migration",1===n.length?"":"s"]})]})]})]})]})]}),es.error&&(0,s.jsxs)("p",{className:"flex items-start gap-2 border-b bg-destructive/5 px-4 py-1.5 text-xs text-destructive",children:[(0,s.jsx)(o.e5t,{className:"mt-px size-3.5 shrink-0"}),(0,s.jsx)("span",{className:"min-w-0 flex-1",children:es.error}),(0,s.jsx)(h.$,{size:"xs",variant:"ghost",onClick:()=>T(!0),children:"Change folder"})]}),"history"===R?(0,s.jsx)(x.F,{className:"min-h-0 flex-1",children:(0,s.jsx)(k.H,{events:ei,connections:K,loading:ea.loading})}):ex&&Z&&es.loading?(0,s.jsxs)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:["Reading ",Z,"…"]}):ex&&Z?(0,s.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 p-6 text-center",children:[(0,s.jsxs)("p",{className:"text-sm",children:["Nothing in ",Z," yet."]}),(0,s.jsx)("p",{className:"max-w-md text-xs text-muted-foreground",children:"Each folder inside it that holds .sql files becomes a migration here, the moment it exists on the branch you have checked out."})]}):ex?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 p-6",children:[(0,s.jsx)($.k,{onFiles:eo,className:"w-full max-w-xl"}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Or"," ",(0,s.jsx)("button",{type:"button",className:"cursor-pointer underline underline-offset-4 hover:text-foreground",onClick:()=>T(!0),children:"read straight from a folder on this computer"}),", so nothing has to be imported."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Q,{filter:et,environments:K,hidden:eb,onChange:e=>en(X,e)}),(0,s.jsxs)(x.F,{className:"min-h-0 flex-1",children:[ef.map(e=>(0,s.jsx)(P,{set:e,href:`${el}/${encodeURIComponent(e.id)}`,environments:ep(e)},e.id)),ej.length>0&&Z&&(0,s.jsx)("p",{className:"border-b px-4 pt-2.5 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",title:"Imported into this browser rather than read from the folder.",children:"Imported"}),ej.map(e=>(0,s.jsx)(P,{set:e,href:`${el}/${encodeURIComponent(e.id)}`,environments:ep(e)},e.id)),ev&&0===ef.length&&0===ej.length&&(0,s.jsxs)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:["Nothing matches."," ",(0,s.jsx)("button",{type:"button",className:"cursor-pointer underline underline-offset-4 hover:text-foreground",onClick:()=>en(X,{query:"",status:"all"}),children:"Clear the filter"})]}),em.length>0&&(0,s.jsxs)("div",{className:"border-b bg-muted/20",children:[(0,s.jsx)("p",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase",title:"Applied to a database from elsewhere. The SQL is kept in its ledger, so it opens without the folder.",children:"In the ledger only"}),em.map(e=>(0,s.jsx)(B,{migration:e,busy:I===e.name,onOpen:()=>void ed(e.name)},e.name)),V&&(0,s.jsx)("p",{className:"px-4 pt-1 pb-2 text-xs text-destructive",children:V})]}),!Z&&(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)($.k,{onFiles:eo,compact:!0,className:"w-full"})})]})]}),(0,s.jsx)(S.l,{caption:function(e,t,n,s){if(s&&0===e)return"Reading folder…";if(0===e&&0===t&&0===n)return"No migrations yet";let r=[];return e>0&&r.push(`${e} migration${1===e?"":"s"} on disk`),t>0&&r.push(`${t} imported`),n>0&&r.push(`${n} in the ledger only`),r.join(" \xb7 ")}(er.length,n.length,em.length,null!==Z&&es.loading),pane:R,onPaneChange:q,historyCount:ei.length}),D&&(0,s.jsx)(A,{root:Z,environmentNames:K.map(e=>e.name),onOpenChange:T,onSave:e=>ee(X,e)}),G&&(0,s.jsx)(E,{connection:t,ledgerSchema:z,plan:G,onDone:()=>ea.reload(),onOpenChange:e=>!e&&H(null)}),(0,s.jsx)(C.K,{open:U,title:"New migration",submitLabel:"Create",onOpenChange:W,onSubmit:function(t){let n=r(t);e.push(`${el}/${encodeURIComponent(n)}`)}})]})}let _={all:"All",pending:"Not fully applied",untouched:"Not started anywhere",complete:"Applied everywhere"};function Q({filter:e,environments:t,hidden:n,onChange:r}){let a="all"!==e.status;return(0,s.jsxs)("div",{className:"flex items-center gap-1 border-b px-2 py-1",children:[(0,s.jsx)(p.L,{value:e.query,onChange:e=>r({query:e.target.value}),placeholder:"Search migrations","aria-label":"Search migrations",className:"min-w-0 flex-1",trailing:e.query?(0,s.jsx)("button",{type:"button","aria-label":"Clear search",className:"cursor-pointer rounded p-0.5 hover:text-foreground",onClick:()=>r({query:""}),children:(0,s.jsx)(o.yBK,{className:"size-3.5"})}):null}),(0,s.jsxs)(u.rI,{children:[(0,s.jsxs)(u.ty,{render:(0,s.jsx)(h.$,{size:"sm",variant:a?"outline":"ghost"}),className:"cursor-pointer",children:[function(e,t){if(e.startsWith("pending:")){let n=t.find(t=>t.id===e.slice(8));return n?`Pending on ${n.name}`:_.pending}return _[e]}(e.status,t),(0,s.jsx)(o.RQe,{"data-icon":"inline-end"})]}),(0,s.jsx)(u.SQ,{align:"end",className:"min-w-56",children:(0,s.jsxs)(u.Hr,{value:e.status,onValueChange:e=>r({status:e}),children:[Object.keys(_).map(e=>(0,s.jsx)(u.Ht,{value:e,children:_[e]},e)),t.length>1&&(0,s.jsx)(u.mB,{}),t.length>1&&t.map(e=>(0,s.jsxs)(u.Ht,{value:`pending:${e.id}`,children:[(0,s.jsx)(d.F,{connection:e,className:"size-1.5"}),"Pending on ",e.name]},e.id))]})})]}),n>0&&(0,s.jsxs)("span",{className:"shrink-0 pr-1 text-[11px] tabular-nums text-muted-foreground",children:[n," hidden"]})]})}function Y({root:e,git:t,onEdit:n}){var r;let a;return(0,s.jsxs)("button",{type:"button",title:`Reading from ${e}${t?` on ${t.branch} (${t.commit}${t.dirty?", uncommitted changes":""})`:""}. Click to change.`,onClick:n,className:"flex min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs text-muted-foreground outline-none hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,s.jsx)(o.WzY,{className:"size-3.5 shrink-0"}),(0,s.jsx)("span",{className:"max-w-64 truncate font-mono text-[11px]",children:(a=(r=e).split(/[\/]/).filter(Boolean)).length>2?`…/${a.slice(-2).join("/")}`:r}),t&&(0,s.jsxs)("span",{className:"shrink-0 rounded border px-1.5 font-mono text-[10px]",children:[t.branch,t.dirty&&"*"]})]})}function P({set:e,href:t,environments:n}){return(0,s.jsxs)(a(),{href:t,className:"flex items-center gap-3 border-b px-4 py-3 outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("p",{className:"flex min-w-0 items-center gap-1.5 text-sm font-medium",children:[(0,s.jsx)("span",{className:"truncate",children:e.name}),e.note&&(0,s.jsx)("span",{title:e.note,className:"shrink-0 text-muted-foreground",children:(0,s.jsx)(o.UA_,{className:"size-3.5"})})]}),(0,s.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[0===e.steps.length?"No files yet":`${e.steps.length} migration${1===e.steps.length?"":"s"}`,e.steps.length>0&&` \xb7 ${e.steps[0].version}–${e.steps.at(-1)?.version}`,e.skipped.length>0&&` \xb7 ${e.skipped.length} skipped`]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:n.map(e=>(0,s.jsx)(U,{environment:e},e.connection.id))}),(0,s.jsx)(o.nNJ,{className:"size-4 shrink-0 text-muted-foreground/60"})]})}function B({migration:e,busy:t,onOpen:n}){return(0,s.jsxs)("div",{className:"flex items-center gap-3 border-t px-4 py-2.5 first:border-t-0",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"truncate text-sm",children:e.name}),(0,s.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[e.total," migration",1===e.total?"":"s",e.versions.length>0&&` \xb7 ${e.versions[0]}–${e.versions.at(-1)}`]})]}),(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-1.5",children:e.applied.map(t=>(0,s.jsxs)("span",{className:"flex h-6 items-center gap-1.5 rounded-lg border border-dashed px-2 text-[11px] text-muted-foreground",children:[(0,s.jsx)("span",{className:"max-w-24 truncate",children:t.connectionName}),(0,s.jsxs)("span",{className:"tabular-nums",children:[t.count,"/",e.total]})]},t.connectionId))}),(0,s.jsx)(h.$,{size:"xs",variant:"outline",disabled:t,onClick:n,children:t?"Opening…":"Open"})]})}function U({environment:e}){let{connection:t,summary:n,read:r,error:a}=e,i=r&&n.total>0&&0===n.pending&&0===n.drifted,l=r&&0===n.applied&&0===n.drifted;return(0,s.jsxs)("span",{title:a?`${t.name}: ${a}`:r?`${t.name}: ${n.applied} of ${n.total} applied`:`${t.name}: reading…`,className:(0,y.cn)("flex h-6 items-center gap-1.5 rounded-lg border px-2 text-[11px]",a&&"border-destructive/30 text-destructive",i&&"border-emerald-600/30 bg-emerald-500/10",!a&&!i&&!l&&"border-amber-600/30 bg-amber-500/10",l&&"text-muted-foreground"),children:[(0,s.jsx)(d.F,{connection:t,className:"size-1.5"}),(0,s.jsx)("span",{className:"max-w-24 truncate",children:t.name}),(0,s.jsx)("span",{className:"tabular-nums",children:a?"—":r?`${n.applied}/${n.total}`:"…"})]})}}},e=>{e.O(0,[4506,1731,8026,4730,8361,8322,6090,7709,3732,8441,3794,7358],()=>e(e.s=28330)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2336],{4108:(e,t,n)=>{Promise.resolve().then(n.bind(n,21890))},20185:(e,t,n)=>{"use strict";function r(e){let t=e.split("/").filter(Boolean).map(decodeURIComponent);if(0===t.length)return{kind:"home"};let[n,r,o]=t;if(1===t.length)return{kind:"connection",connectionId:n};if(2===t.length){if("query"===r)return{kind:"query",connectionId:n};if("diff"===r)return{kind:"diff",connectionId:n};if("migrations"===r)return{kind:"migrations",connectionId:n}}return 3===t.length?"migrations"===r?{kind:"migration",connectionId:n,setId:o}:{kind:"table",connectionId:n,table:{schema:r,name:o}}:{kind:"connection",connectionId:n}}function o(e){let t=encodeURIComponent;switch(e.kind){case"home":return"/";case"connection":return`/${t(e.connectionId)}`;case"query":case"diff":case"migrations":return`/${t(e.connectionId)}/${e.kind}`;case"migration":return`/${t(e.connectionId)}/migrations/${t(e.setId)}`;case"table":return`/${t(e.connectionId)}/${t(e.table.schema)}/${t(e.table.name)}`}}function i(e,t,{tableExists:n=!0}={}){let a=r(e);return"home"!==a.kind&&("table"!==a.kind||n)?o({...a,connectionId:t}):o({kind:"connection",connectionId:t})}n.d(t,{Jn:()=>o,ZG:()=>r,gZ:()=>i})},21890:(e,t,n)=>{"use strict";n.d(t,{ConnectionHome:()=>p});var r=n(95155),o=n(73321),i=n(12115),a=n(74590),s=n(88263),l=n(20185),c=n(43262),u=n(95848),d=n(36331);function p(){let e=(0,o.useRouter)(),{connection:t,tables:n}=(0,d.k)(),[p]=(0,a.DE)(t.id),f=p.recentTables[0]??null,h=f?(n.data??[]).find(e=>(0,u.i)(e)===f):void 0;return((0,i.useEffect)(()=>{h&&(s.c.getState().markReplace(),e.replace((0,l.Jn)({kind:"table",connectionId:t.id,table:{schema:h.schema,name:h.name}})))},[h,t.id,e]),!n.data||h)?null:(0,r.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-1.5 text-muted-foreground",children:[(0,r.jsx)("p",{className:"text-sm",children:"Select a table"}),(0,r.jsx)("kbd",{className:"font-mono text-[11px] text-muted-foreground/60",children:c.Ar.tableSearch})]})}},27529:(e,t,n)=>{"use strict";n.d(t,{F:()=>i});var r=n(72914);async function o(e,t,n){let o,i=await (0,r.Qv)(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n}),a=await i.text();if(!a)throw Error(`YTDB bridge returned an empty response (HTTP ${i.status}). Restart YTDB to update the local bridge.`);try{o=JSON.parse(a)}catch{if(404===i.status)throw Error("The YTDB running on your machine is older than this page and does not know this request. Restart it with `npx @theobourgeois/ytdb@latest`.");throw Error(`YTDB bridge returned an invalid response (HTTP ${i.status}).`)}if(!i.ok)throw Error((o&&"object"==typeof o&&"error"in o&&"string"==typeof o.error?o.error:i.statusText)||`YTDB bridge request failed with HTTP ${i.status}.`);return o}let i={tables:(e,t)=>o("/api/tables",{connectionUrl:e},t),rows:(e,t,n)=>o("/api/rows",{connectionUrl:e,query:t},n),query:(e,t,n)=>o("/api/query",{connectionUrl:e,sql:t},n),updateCell:(e,t,n)=>o("/api/cell",{connectionUrl:e,update:t},n),insertRow:(e,t,n)=>o("/api/insert-row",{connectionUrl:e,insertion:t},n),updateRow:(e,t,n)=>o("/api/update-row",{connectionUrl:e,update:t},n),deleteRows:(e,t,n)=>o("/api/delete-rows",{connectionUrl:e,deletion:t},n),related:(e,t,n)=>o("/api/related",{connectionUrl:e,lookups:t},n),lookup:(e,t,n)=>o("/api/lookup",{connectionUrl:e,query:t},n),definition:(e,t,n)=>o("/api/definition",{connectionUrl:e,table:t},n),schema:(e,t)=>o("/api/schema",{connectionUrl:e},t),ledger:(e,t,n,r=!1)=>o("/api/ledger",{connectionUrl:e,ledgerSchema:t,withSql:r},n),migrate:(e,t,n)=>o("/api/migrate",{connectionUrl:e,migration:t},n),adopt:(e,t,n)=>o("/api/adopt",{connectionUrl:e,adopt:t},n),detect:(e,t,n)=>o("/api/detect",{connectionUrl:e,migrations:t},n),repo:(e,t)=>o("/api/repo",{root:e},t),note:(e,t,n,r)=>o("/api/note",{root:e,path:t,note:n},r)}},32538:(e,t,n)=>{"use strict";n.d(t,{I_:()=>r,Mq:()=>a,XU:()=>i,yQ:()=>o});let r=["#e11d48","#f97316","#d97706","#65a30d","#0d9488","#0284c7","#4f46e5","#7c3aed","#c026d3","#57534e"];function o(e){return r.some(t=>t===e)}function i(e){let t=r.find(t=>!e.includes(t));return t||(r[e.length%r.length]??r[0])}function a(e){if(o(e.color))return e.color;var t=e.id;let n=0;for(let e of t)n=31*n+e.charCodeAt(0)>>>0;return r[n%r.length]??r[0]}},36331:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l,k:()=>c});var r=n(95155),o=n(12115),i=n(27529),a=n(87364);let s=(0,o.createContext)(null);function l({connection:e,children:t}){let n=(0,a.Y)(e.url,t=>i.F.tables(e.url,t));return(0,r.jsx)(s.Provider,{value:{connection:e,tables:n},children:t})}function c(){let e=(0,o.useContext)(s);if(!e)throw Error("useExplorerContext must be used inside ExplorerProvider");return e}},40980:(e,t,n)=>{"use strict";n.d(t,{cn:()=>i,z:()=>a});var r=n(29722),o=n(622);function i(...e){return(0,o.QP)((0,r.$)(e))}function a(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;let t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}},42256:(e,t,n)=>{"use strict";n.d(t,{L:()=>o});var r=n(72914);function o(e,t){let{connectionUrl:n,...o}=t??{};(0,r.Qv)("/api/activity",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,connectionUrl:n,params:o}),keepalive:!0}).catch(()=>{})}},43262:(e,t,n)=>{"use strict";n.d(t,{Ar:()=>r,US:()=>s,s5:()=>c,tT:()=>u,vI:()=>l});let r={commandPalette:"⌘⇧P",tableSearch:"⌘P",columnSearch:"⌘/",sqlEditor:"⌘E",switchConnection:"⌘⇧E",compareSchema:"⌘⇧D",migrations:"⌘⇧M",back:"⌘[",forward:"⌘]"};function o(){let e=new Set;return{register:t=>(e.add(t),()=>{e.delete(t)}),open(){for(let t of e)t()}}}let i=o(),a=o(),s=i.register,l=i.open,c=a.register,u=a.open},63307:(e,t,n)=>{"use strict";function r(e,t){if(null!==window.localStorage.getItem(t))return;let n=window.localStorage.getItem(e);null!==n&&window.localStorage.setItem(t,n)}n.d(t,{q:()=>r})},69586:(e,t,n)=>{"use strict";n.d(t,{Z:()=>u,w:()=>d});var r=n(1934),o=n(31692),i=n(42256),a=n(32538),s=n(40980),l=n(63307);let c="ytdb:connections";(0,l.q)("db-studio:connections",c);let u=(0,r.v)()((0,o.Zr)((e,t)=>({connections:[],add:n=>{let r=n.color??(0,a.XU)(t().connections.map(e=>(0,a.Mq)(e))),o={id:(0,s.z)(),...n,color:r};return e(e=>({connections:[...e.connections,o]})),(0,i.L)("connection.add",{connectionUrl:o.url,name:o.name}),o},update:(n,r)=>{let o=t().connections.find(e=>e.id===n);e(e=>({connections:e.connections.map(e=>e.id===n?{...e,...r}:e)})),(0,i.L)("connection.update",{connectionUrl:r.url??o?.url,name:r.name??o?.name,changed:Object.keys(r)})},remove:n=>{let r=t().connections.find(e=>e.id===n);e(e=>({connections:e.connections.filter(e=>e.id!==n)})),(0,i.L)("connection.remove",{connectionUrl:r?.url,name:r?.name})}}),{name:c}));function d(e){return u(t=>t.connections.find(t=>t.id===e))}},72914:(e,t,n)=>{"use strict";n.d(t,{Qv:()=>a,Yf:()=>i,i:()=>o});let r="ytdb:bridge";function o(){var e;return"localhost"!==(e=window.location.hostname)&&"127.0.0.1"!==e&&"[::1]"!==e&&"local.ytdb"!==e&&"local.dbstudio"!==e}function i(){let e=function(){let e=new URLSearchParams(window.location.hash.slice(1)),t=e.get("token"),n=e.get("port");if(!t)return null;let o=n?Number(n):4371;if(!Number.isInteger(o)||o<1024||o>65535)return null;let i={origin:`http://127.0.0.1:${o}`,token:t};return window.sessionStorage.setItem(r,JSON.stringify(i)),window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`),i}();if(e)return e;let t=window.sessionStorage.getItem(r);if(!t)return null;try{let e=JSON.parse(t);if("string"==typeof e.origin&&/^http:\/\/127\.0\.0\.1:\d+$/.test(e.origin)&&"string"==typeof e.token&&e.token.length>0)return e}catch{}return window.sessionStorage.removeItem(r),null}async function a(e,t={}){let n=i();if(o()&&!n)throw Error("Start YTDB with `npx @theobourgeois/ytdb`, then use the browser tab it opens.");let r=new Headers(t.headers);return n&&r.set("Authorization",`Bearer ${n.token}`),fetch(n?new URL(e,n.origin):e,{...t,headers:r,targetAddressSpace:n?"loopback":void 0})}},73321:(e,t,n)=>{"use strict";var r=n(74645);n.o(r,"useParams")&&n.d(t,{useParams:function(){return r.useParams}}),n.o(r,"usePathname")&&n.d(t,{usePathname:function(){return r.usePathname}}),n.o(r,"useRouter")&&n.d(t,{useRouter:function(){return r.useRouter}})},74590:(e,t,n)=>{"use strict";n.d(t,{DE:()=>S,gz:()=>$,jn:()=>v,lz:()=>w,mQ:()=>k,y3:()=>x});var r=n(1934),o=n(31692),i=n(95848),a=n(40980),s=n(69586),l=n(63307);let c="ytdb:explorer";(0,l.q)("db-studio:explorer",c);let u={search:"",selectedSchemas:null,collapsedSchemas:[],pinnedTables:[],recentTables:[],sidebarWidth:256,sidebarCollapsed:!1},d={filters:[],search:"",sort:null,columnWidths:{},hiddenColumns:[],page:0,pageSize:50},p=["selectedSchemas","collapsedSchemas","pinnedTables"],f=["search","recentTables","sidebarWidth","sidebarCollapsed"],h=["columnWidths","hiddenColumns","pinnedColumns","pageSize"],m=["filters","search","sort","page"];function g(e,t){return`${e}:${(0,i.i)(t)}`}function y(e){let t=s.Z.getState().connections.find(t=>t.id===e);return t?.layoutGroup??e}function b(e,t){let n={};for(let r of t)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}let w=(0,r.v)()((0,o.Zr)(e=>({browse:{},tables:{},compareTargets:{},setBrowse:(t,n)=>e(e=>{let r=y(t),o=b(n,p),i=b(n,f),a={...e.browse};return r===t?a[t]={...a[t]??u,...o,...i}:(Object.keys(o).length>0&&(a[r]={...a[r]??u,...o}),Object.keys(i).length>0&&(a[t]={...a[t]??u,...i})),{browse:a}}),setTable:(t,n,r)=>e(e=>{let o=g(y(t),n),i=g(t,n),a=b(r,h),s=b(r,m),l={...e.tables};return o===i?l[i]={...l[i]??d,...a,...s}:(Object.keys(a).length>0&&(l[o]={...l[o]??d,...a}),Object.keys(s).length>0&&(l[i]={...l[i]??d,...s})),{tables:l}}),setCompareTarget:(t,n)=>e(e=>({compareTargets:{...e.compareTargets,[t]:n}})),copyLayout:(t,n)=>e(e=>{if(t===n)return e;let r={...e.browse},o=r[t];o&&(r[n]={...r[n]??u,...b(o,p)});let i={...e.tables},a=`${t}:`;for(let[t,r]of Object.entries(e.tables)){if(!t.startsWith(a))continue;let e=`${n}:${t.slice(a.length)}`;i[e]={...i[e]??d,...b(r,h)}}return{browse:r,tables:i}})}),{name:c}));function S(e){let t,n=(0,s.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup??e),r=w(t=>n===e?void 0:t.browse[n]),o=w(t=>t.browse[e]),i=w(e=>e.setBrowse);return[(t=o&&"selectedSchemas"in o?o.selectedSchemas??null:o?.schema?[o.schema]:null,{...u,...o,selectedSchemas:t,...r?{selectedSchemas:r.selectedSchemas,collapsedSchemas:r.collapsedSchemas,pinnedTables:r.pinnedTables}:{}}),t=>i(e,t)]}function v(e,t){let n=(0,s.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup??e),r=w(r=>n===e?void 0:r.tables[g(n,t)]),o=w(n=>n.tables[g(e,t)]),i=w(e=>e.setTable);return[{...d,...o,search:o?.search??d.search,hiddenColumns:o?.hiddenColumns??d.hiddenColumns,...r?{columnWidths:r.columnWidths,hiddenColumns:r.hiddenColumns,pinnedColumns:r.pinnedColumns,pageSize:r.pageSize}:{}},n=>i(e,t,n)]}function k(e,t){let n=[...new Set([e,...t])],{connections:r,update:o}=s.Z.getState(),i=w.getState(),l=r.find(t=>t.id===e);if(!l)return;let c=new Map;for(let e of r){if(!e.layoutGroup)continue;let t=c.get(e.layoutGroup)??[];t.push(e.id),c.set(e.layoutGroup,t)}let u=l.layoutGroup,d=u?c.get(u)??[e]:[e],p=d.filter(e=>!n.includes(e));for(let t of p)i.copyLayout(u??e,t),o(t,{layoutGroup:void 0});if(u){let t=d.filter(t=>!p.includes(t)&&t!==e);if(1===t.length){let e=t[0];e&&(i.copyLayout(u,e),o(e,{layoutGroup:void 0}))}}if(n.length<=1){u&&(i.copyLayout(u,e),o(e,{layoutGroup:void 0}));return}let f=u??(0,a.z)();for(let t of(u||i.copyLayout(e,f),n)){let e=r.find(e=>e.id===t);if(e){if(e.layoutGroup&&e.layoutGroup!==f){let r=e.layoutGroup,a=(c.get(r)??[]).filter(e=>e!==t&&!n.includes(e));if(1===a.length){let e=a[0];e&&(i.copyLayout(r,e),o(e,{layoutGroup:void 0}))}else a.length}o(t,{layoutGroup:f})}}}let T=[];function $(e){let t=(0,s.Z)(e=>e.connections),n=(0,s.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup);return n?t.filter(t=>t.layoutGroup===n&&t.id!==e):T}function x(e){let t=(0,s.Z)(e=>e.connections),n=w(t=>t.compareTargets[e]),r=w(e=>e.setCompareTarget),o=(0,s.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup),i=t.filter(t=>t.id!==e),a=o?i.filter(e=>e.layoutGroup===o):[];return{target:i.find(e=>e.id===n)??a[0]??i[0]??null,candidates:i,partnerIds:a.map(e=>e.id),setTarget:t=>r(e,t)}}},87364:(e,t,n)=>{"use strict";n.d(t,{Y:()=>o});var r=n(12115);function o(e,t){let[n,o]=(0,r.useState)(0),[i,a]=(0,r.useState)({key:"",error:null}),s=`${n}:${e}`;(0,r.useEffect)(()=>{let e=new AbortController;return t(e.signal).then(e=>a({key:s,data:e,error:null})).catch(t=>{if(e.signal.aborted)return;let n=t instanceof Error?t.message:String(t);a(e=>({key:s,data:e.data,error:n}))}),()=>e.abort()},[s]);let l=(0,r.useCallback)(()=>o(e=>e+1),[]),c=i.key!==s;return{data:i.data,error:c?null:i.error,loading:c,reload:l}}},88263:(e,t,n)=>{"use strict";n.d(t,{c:()=>s});var r=n(1934),o=n(31692);let i="ytdbNav";function a(e){let t=window.history.state;t&&"object"==typeof t&&t[i]===e||window.history.replaceState({...t??{},[i]:e},"")}let s=(0,r.v)()((0,o.Zr)((e,t)=>({entries:[],index:-1,traversing:!1,replaceNext:!1,markTraversal:()=>e({traversing:!0}),markReplace:()=>e({replaceNext:!0}),arrive:n=>{let r,{entries:o,index:s,traversing:l,replaceNext:c}=t(),u=function(){let e=window.history.state;if(!e||"object"!=typeof e)return;let t=e[i];return"number"==typeof t?t:void 0}();if(o[s]===n&&!c){e({traversing:!1}),a(s);return}let d=o;void 0!==u&&o[u]===n?r=u:l&&o[s-1]===n?r=s-1:l&&o[s+1]===n?r=s+1:c&&s>=0?(d=o.map((e,t)=>t===s?n:e),r=s):r=(d=[...o.slice(0,s+1),n]).length-1,e({entries:d,index:r,traversing:!1,replaceNext:!1}),a(r)}}),{name:"ytdb:navigation",storage:(0,o.KU)(()=>sessionStorage),partialize:e=>({entries:e.entries,index:e.index})}))},95848:(e,t,n)=>{"use strict";function r(e){return`${e.schema}.${e.name}`}n.d(t,{i:()=>r})}},e=>{e.O(0,[1731,8441,3794,7358],()=>e(e.s=4108)),_N_E=e.O()}]);
|
|
File without changes
|
|
File without changes
|