@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 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3732],{9385:(e,t,n)=>{n.d(t,{x:()=>r});function r(e,t){let n=new Map(e.map(e=>[e.connection.id,e])),r=t.filter(e=>n.has(e.connectionId)).map(e=>({id:e.id,connectionId:e.connectionId,connectionName:e.connectionName,version:e.version,name:e.name,at:e.ranAt,kind:"failed"===e.status?"failed":e.recorded?"apply"===e.direction?"marked":"unmarked":"apply"===e.direction?"applied":"reverted",durationMs:e.durationMs,error:e.error,setName:e.setName,fromLedger:!1})),a=new Map;for(let e of r){let t=`${e.connectionId}:${e.setName??""}:${e.version}`,n=a.get(t);(!n||e.at>n.at)&&a.set(t,e)}let s=[...r];for(let t of e)for(let e of t.ledger?.entries??[]){let n=`${t.connection.id}:${e.setName}:${e.version}`,r=a.get(n);if(r&&("applied"===r.kind||"marked"===r.kind)){r.appliedBy=e.appliedBy;continue}s.push({id:`ledger:${t.connection.id}:${e.setName}:${e.version}`,connectionId:t.connection.id,connectionName:t.connection.name,version:e.version,name:e.name||e.version,at:function(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}(e.appliedAt),kind:"applied",durationMs:e.durationMs,setName:e.setName,appliedBy:e.appliedBy,fromLedger:!0})}return s.sort((e,t)=>t.at-e.at)}},17491:(e,t,n)=>{n.d(t,{X:()=>u});var r=n(95155),a=n(40980),s=n(13267),i=n(89239),l=n(43262),o=n(36331),d=n(48861);function c({className:e}){let{connection:t}=(0,o.k)(),{back:n,forward:u,goBack:m,goForward:p}=(0,d.Q)(t.id);return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center",e),children:[(0,r.jsx)(i.$,{variant:"ghost",size:"icon-sm",disabled:!n,"aria-label":n?`Back to ${n.label}`:"Back",title:n?`Back to ${n.label} (${l.Ar.back})`:void 0,className:"disabled:opacity-30",onClick:m,children:(0,r.jsx)(s.SI1,{})}),(0,r.jsx)(i.$,{variant:"ghost",size:"icon-sm",disabled:!u,"aria-label":u?`Forward to ${u.label}`:"Forward",title:u?`Forward to ${u.label} (${l.Ar.forward})`:void 0,className:"disabled:opacity-30",onClick:p,children:(0,r.jsx)(s.nNJ,{})})]})}function u({children:e,className:t}){return(0,r.jsxs)("header",{className:(0,a.cn)("flex h-11 shrink-0 items-center gap-2 border-b pr-3 pl-1.5",t),children:[(0,r.jsx)(c,{className:"mr-0.5"}),e]})}},27013:(e,t,n)=>{n.d(t,{K:()=>o});var r=n(95155),a=n(12115),s=n(89239),i=n(42763),l=n(60529);function o(e){return(0,r.jsx)(i.lG,{open:e.open,onOpenChange:e.onOpenChange,children:(0,r.jsx)(i.Cf,{className:"sm:max-w-sm",showCloseButton:!1,children:e.open&&(0,r.jsx)(d,{...e})})})}function d({title:e,initial:t="",submitLabel:n,onOpenChange:o,onSubmit:c}){let[u,m]=(0,a.useState)(t),p=u.trim();return(0,r.jsxs)("form",{onSubmit:function(e){e.preventDefault(),p&&(c(p),o(!1))},className:"flex flex-col gap-4",children:[(0,r.jsx)(i.c7,{children:(0,r.jsx)(i.L3,{children:e})}),(0,r.jsx)(l.p,{autoFocus:!0,"aria-label":"Migration name",value:u,placeholder:"add_users_table",onChange:e=>m(e.target.value),onFocus:e=>e.currentTarget.select()}),(0,r.jsxs)(i.Es,{children:[(0,r.jsx)(s.$,{type:"button",variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),(0,r.jsx)(s.$,{type:"submit",disabled:!p,children:n})]})]})}},30374:(e,t,n)=>{n.d(t,{x:()=>s});var r=n(95155),a=n(40980);function s({value:e,options:t,onChange:n,label:i}){return(0,r.jsx)("div",{role:"group","aria-label":i,className:"flex h-7 items-center rounded-md border bg-muted/50 p-0.5",children:t.map(t=>(0,r.jsx)("button",{type:"button","aria-pressed":t.value===e,onClick:()=>n(t.value),className:(0,a.cn)("h-full rounded-sm px-2 text-xs transition-colors",t.value===e?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:t.label},t.value))})}},33807:(e,t,n)=>{n.d(t,{J:()=>s});var r=n(95155);n(12115);var a=n(40980);function s({className:e,...t}){return(0,r.jsx)("label",{"data-slot":"label",className:(0,a.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}},35942:(e,t,n)=>{n.d(t,{F:()=>c});var r=n(95155);n(12115);var a=n(76166),s=n(90839),i=n(84588),l=n(66784),o=n(64084),d=n(40980);function c({className:e,children:t,...n}){return(0,r.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,d.cn)("relative",e),...n,children:[(0,r.jsx)(s.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),(0,r.jsx)(u,{}),(0,r.jsx)(i.I,{})]})}function u({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(l.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,d.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...n,children:(0,r.jsx)(o.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},41069:(e,t,n)=>{n.d(t,{l:()=>s});var r=n(95155),a=n(30374);function s({caption:e,pane:t,onPaneChange:n,historyCount:i,migrationsLabel:l="Migrations"}){return(0,r.jsxs)("footer",{className:"flex shrink-0 items-center gap-2 border-t px-4 py-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:e}),(0,r.jsx)("div",{className:"ml-auto",children:(0,r.jsx)(a.x,{label:"Migrations pane",value:t,onChange:n,options:[{value:"migrations",label:l},{value:"history",label:i>0?`History (${i})`:"History"}]})})]})}},42611:(e,t,n)=>{n.d(t,{H:()=>m});var r=n(95155),a=n(13267),s=n(72194),i=n(89239),l=n(79668),o=n(40980);let d={applied:"applied",reverted:"reverted",marked:"marked",unmarked:"unmarked",failed:"failed"};function c({kind:e}){switch(e){case"failed":return(0,r.jsx)(a.yBK,{className:"size-3.5 shrink-0 text-destructive"});case"reverted":return(0,r.jsx)(a.ij9,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"});case"marked":return(0,r.jsx)(a.nXx,{className:"size-3.5 shrink-0 text-muted-foreground"});case"unmarked":return(0,r.jsx)(a.fJ4,{className:"size-3.5 shrink-0 text-muted-foreground"});default:return(0,r.jsx)(a.wiW,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"})}}function u({event:e,connection:t}){return(0,r.jsxs)("div",{className:"flex items-start gap-2 border-b px-4 py-2 text-xs last:border-b-0",children:[(0,r.jsx)("span",{className:"mt-0.5",children:(0,r.jsx)(c,{kind:e.kind})}),(0,r.jsx)("span",{className:(0,o.cn)("mt-px shrink-0 rounded-md px-1.5 text-[11px]","failed"===e.kind?"bg-destructive/10 text-destructive":"reverted"===e.kind?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"bg-muted text-muted-foreground"),children:d[e.kind]}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"truncate",children:e.name}),e.error&&(0,r.jsx)("span",{className:"mt-1 block font-mono text-[11px] whitespace-pre-wrap text-destructive",children:e.error})]}),e.setName&&(0,r.jsx)("span",{className:"hidden max-w-32 shrink-0 truncate text-muted-foreground/60 lg:inline",children:e.setName}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-muted-foreground",children:[t&&(0,r.jsx)(s.F,{connection:t,className:"size-1.5"}),e.connectionName]}),e.appliedBy&&(0,r.jsx)("span",{className:"hidden shrink-0 text-muted-foreground/60 xl:inline",children:e.appliedBy}),(0,r.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/70",children:null===e.durationMs?"":`${e.durationMs} ms`}),(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground/70",title:e.fromLedger?"Read from the database's own ledger":"Run from this browser",children:new Date(e.at).toLocaleString()})]})}function m({events:e,connections:t,loading:n}){let a=(0,l.jV)(e=>e.clearHistory),s=new Map(t.map(e=>[e.id,e])),o=e.filter(e=>!e.fromLedger).length;return 0===e.length?(0,r.jsx)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:n?"Reading ledgers…":"Nothing has run yet."}):(0,r.jsxs)("div",{children:[e.map(e=>(0,r.jsx)(u,{event:e,connection:s.get(e.connectionId)},e.id)),o>0&&(0,r.jsx)("div",{className:"flex justify-end px-3 py-2",children:(0,r.jsx)(i.$,{size:"xs",variant:"ghost",className:"text-muted-foreground",title:"Clears this browser's log. The databases' ledgers are untouched.",onClick:()=>a(),children:"Clear local log"})})]})}},42763:(e,t,n)=>{n.d(t,{Cf:()=>g,Es:()=>b,L3:()=>j,c7:()=>v,lG:()=>f,rr:()=>k});var r=n(95155);n(12115);var a=n(98408),s=n(32949),i=n(45477),l=n(88593),o=n(52579),d=n(11975),c=n(31799),u=n(40980),m=n(89239),p=n(13267);function f({...e}){return(0,r.jsx)(a.D,{"data-slot":"dialog",...e})}function x({...e}){return(0,r.jsx)(s.Z,{"data-slot":"dialog-portal",...e})}function h({className:e,...t}){return(0,r.jsx)(i.X,{"data-slot":"dialog-overlay",className:(0,u.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function g({className:e,children:t,showCloseButton:n=!0,...a}){return(0,r.jsxs)(x,{children:[(0,r.jsx)(h,{}),(0,r.jsxs)(l.h,{"data-slot":"dialog-content",className:(0,u.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a,children:[t,n&&(0,r.jsxs)(o.H,{"data-slot":"dialog-close",render:(0,r.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,r.jsx)(p.yBK,{}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function v({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"dialog-header",className:(0,u.cn)("flex flex-col gap-2",e),...t})}function b({className:e,showCloseButton:t=!1,children:n,...a}){return(0,r.jsxs)("div",{"data-slot":"dialog-footer",className:(0,u.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...a,children:[n,t&&(0,r.jsx)(o.H,{render:(0,r.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function j({className:e,...t}){return(0,r.jsx)(d.L,{"data-slot":"dialog-title",className:(0,u.cn)("font-heading text-base leading-none font-medium",e),...t})}function k({className:e,...t}){return(0,r.jsx)(c.r,{"data-slot":"dialog-description",className:(0,u.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}},60529:(e,t,n)=>{n.d(t,{p:()=>i});var r=n(95155);n(12115);var a=n(64878),s=n(40980);function i({className:e,type:t,...n}){return(0,r.jsx)(a.p,{type:t,"data-slot":"input",className:(0,s.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none 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),...n})}},62417:(e,t,n)=>{n.d(t,{DM:()=>p,FY:()=>o,Gf:()=>s,ay:()=>l,e:()=>m,eh:()=>d,gj:()=>u,kB:()=>x,lF:()=>h,n9:()=>f,nb:()=>c,yy:()=>g});var r=n(20642);let a={steps:[],blockedBy:null};function s(e,t){return e?{...e,entries:e.entries.filter(e=>e.setName===t)}:null}function i(e){let t=new Map;for(let n of e?.entries??[])t.set(n.version,n);return t}function l(e,t){return t?t.entries.find(t=>t.version===e.version)??null:null}function o(e,t){if(!t)return"unknown";let n=l(e,t);return n?n.checksum&&n.checksum!==e.checksum?"drifted":"applied":"pending"}function d(e,t){let n={total:e?.steps.length??0,applied:0,drifted:0,pending:0,foreign:0};if(!e)return n;let r=s(t,e.name);for(let t of e.steps){let e=o(t,r);"applied"===e?n.applied+=1:"drifted"===e?n.drifted+=1:"pending"===e&&(n.pending+=1)}return n.foreign=c(e,r).length,n}function c(e,t){if(!t)return[];let n=new Set((e?.steps??[]).map(e=>e.version));return t.entries.filter(e=>!n.has(e.version)).sort((e,t)=>(0,r.Zy)(e.version,t.version))}function u(e,t,n){if(!e||!t)return a;let r=[];for(let a of e.steps)if("pending"===o(a,t)&&r.push(a),void 0!==n&&a.version===n)break;return{steps:r,blockedBy:null}}function m(e,t,n){if(!e||!t)return a;let s=i(t),l=[];for(let t of[...e.steps].reverse()){if(void 0!==n&&0>(0,r.Zy)(t.version,n))break;if(s.has(t.version)){if(!t.revertSql)return{steps:l,blockedBy:t};l.push(t)}}return{steps:l,blockedBy:null}}function p(e,t,n){return e&&t?{steps:e.steps.filter(e=>n.has(e.version)&&"pending"===o(e,t)),blockedBy:null}:a}function f(e,t,n){if(!e||!t)return a;let r=i(t),s=[];for(let t of[...e.steps].reverse())if(n.has(t.version)&&r.has(t.version)){if(!t.revertSql)return{steps:s,blockedBy:t};s.push(t)}return{steps:s,blockedBy:null}}function x(e,t){if(!e||!t)return null;let n=i(t);for(let t of[...e.steps].reverse())if(n.has(t.version))return t;return null}function h(e,t){let n=new Set(t.map(e=>e.toLowerCase())),a=new Map;for(let t of e)for(let e of t.ledger?.entries??[]){let r=e.setName.trim();if(!r||n.has(r.toLowerCase()))continue;let s=a.get(r)??new Map,i=s.get(t.connection.id)??new Set;i.add(e.version),s.set(t.connection.id,i),a.set(r,s)}return[...a.entries()].map(([t,n])=>{let a=new Set;for(let e of n.values())for(let t of e)a.add(t);return{name:t,versions:[...a].sort(r.Zy),total:a.size,applied:e.map(e=>({connectionId:e.connection.id,connectionName:e.connection.name,count:n.get(e.connection.id)?.size??0}))}}).sort((e,t)=>e.name.localeCompare(t.name))}function g(e,t,n){let r=n.query.trim().toLowerCase();if(r&&![e.name,...e.steps.flatMap(e=>[e.version,e.name])].join("\n").toLowerCase().includes(r))return!1;let{status:a}=n;if("all"===a)return!0;if(a.startsWith("pending:")){let e=t.find(e=>e.connectionId===a.slice(8));return!e||!e.read||e.summary.pending>0||e.summary.drifted>0}return"pending"===a?t.some(e=>!e.read||e.summary.pending>0||e.summary.drifted>0):"untouched"===a?t.every(e=>!e.read||0===e.summary.applied&&0===e.summary.drifted):"complete"!==a||e.steps.length>0&&t.every(e=>e.read&&0===e.summary.pending&&0===e.summary.drifted)}},71612:(e,t,n)=>{n.d(t,{y:()=>s});var r=n(87364),a=n(27529);function s(e){return(0,r.Y)(`repo:${e??""}`,async t=>e?a.F.repo(e,t):null)}},72194:(e,t,n)=>{n.d(t,{F:()=>i});var r=n(95155),a=n(40980),s=n(32538);function i({connection:e,className:t}){return(0,r.jsx)("span",{"aria-hidden":!0,className:(0,a.cn)("size-2.5 shrink-0 rounded-full",t),style:{background:(0,s.Mq)(e)}})}},77649:(e,t,n)=>{n.d(t,{k:()=>p,$:()=>m});var r=n(95155),a=n(12115),s=n(13267),i=n(89239);function l(e){let t=e.createReader?.();return t?new Promise((e,n)=>{let r=[],a=()=>{t.readEntries(t=>{0===t.length||r.length>=2e3?e(r):(r.push(...t),a())},n)};a()}):Promise.resolve([])}async function o(e,t,n,r){if(r.length>=2e3||n>6||e.name.startsWith("."))return;let a=t?`${t}/${e.name}`:e.name;if(e.isFile){if(!/\.sql$/i.test(e.name))return;let t=await new Promise((t,n)=>{e.file?e.file(t,n):n(Error(`Could not read ${e.name}`))});r.push({path:a,text:await t.text()});return}if(e.isDirectory)for(let t of(await l(e)))await o(t,a,n+1,r)}async function d(e){let t=[];for(let n of Array.from(e.items)){if("file"!==n.kind)continue;let e=n.webkitGetAsEntry?.();e&&t.push(e)}if(0===t.length){let t=Array.from(e.files).filter(e=>/\.sql$/i.test(e.name));return 0===t.length?null:{name:"Migrations",files:await Promise.all(t.map(async e=>({path:e.name,text:await e.text()})))}}let n=1===t.length&&t[0].isDirectory?t[0]:null,r=[];if(n){for(let e of(await l(n)))await o(e,"",1,r);return{name:n.name,files:r}}for(let e of t)await o(e,"",0,r);return r.length>0?{name:"Migrations",files:r}:null}async function c(e){let t,n=Array.from(e).filter(e=>/\.sql$/i.test(e.name));if(0===n.length)return null;let r=new Set(n.map(e=>(e.webkitRelativePath||e.name).split("/")[0])),a=1===r.size&&((t=n[0]).webkitRelativePath||t.name).includes("/")?[...r][0]:null;return{name:a??"Migrations",files:await Promise.all(n.slice(0,2e3).map(async e=>{let t=e.webkitRelativePath||e.name;return{path:a?t.slice(a.length+1):t,text:await e.text()}}))}}var u=n(40980);function m(e){let[t,n]=(0,a.useState)(!1),[r,s]=(0,a.useState)(null);return{importFrom:(0,a.useCallback)(async t=>{n(!0),s(null);try{let n=t instanceof FileList?await c(t):await d(t);if(!n||0===n.files.length)return void s("No .sql files in there.");e(n)}catch(e){s(e instanceof Error?e.message:"Couldn’t read that folder.")}finally{n(!1)}},[e]),busy:t,error:r,clearError:()=>s(null)}}function p({onFiles:e,className:t,compact:n=!1}){let{importFrom:l,busy:o,error:d}=m(e),[c,f]=(0,a.useState)(!1),x=(0,a.useRef)(null),h=(0,a.useRef)(null);return(0,a.useEffect)(()=>{x.current?.setAttribute("webkitdirectory",""),x.current?.setAttribute("directory","")},[]),(0,r.jsxs)("div",{onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:e=>{e.preventDefault(),f(!1),l(e.dataTransfer)},className:(0,u.cn)("flex items-center justify-center rounded-lg border border-dashed text-center transition-colors",n?"flex-wrap gap-x-3 gap-y-2 px-4 py-3":"flex-col gap-4 px-6 py-10",c?"border-primary bg-primary/5":"border-border",t),children:[o?(0,r.jsx)(s.gnh,{className:"size-4 shrink-0 animate-spin text-muted-foreground"}):(0,r.jsx)(s.FeY,{className:(0,u.cn)("shrink-0 text-muted-foreground",n?"size-4":"size-5")}),n?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Drop a folder of .sql files"}):(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Drop a migration folder"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:".sql files, optionally split into apply/ and revert/"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)(i.$,{size:n?"xs":"sm",variant:n?"ghost":"outline",disabled:o,onClick:()=>x.current?.click(),children:[(0,r.jsx)(s.WzY,{"data-icon":"inline-start"}),"Choose folder"]}),(0,r.jsx)(i.$,{size:n?"xs":"sm",variant:"ghost",disabled:o,onClick:()=>h.current?.click(),children:"Choose files"})]}),d&&(0,r.jsx)("p",{className:"w-full text-xs text-destructive",children:d}),(0,r.jsx)("input",{ref:x,type:"file",multiple:!0,className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&l(t),e.target.value=""}}),(0,r.jsx)("input",{ref:h,type:"file",multiple:!0,accept:".sql",className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&l(t),e.target.value=""}})]})}},83504:(e,t,n)=>{n.d(t,{I:()=>c,p:()=>o});var r=n(95155),a=n(13267),s=n(72194),i=n(89239),l=n(42763);function o(e){try{let t=new URL(e),n=t.username?`${decodeURIComponent(t.username)}@`:"",r=t.port?`:${t.port}`:"";return`${n}${t.hostname}${r}${t.pathname}`}catch{return"this connection"}}function d({status:e}){switch(e){case"running":return(0,r.jsx)(a.gnh,{className:"size-3.5 shrink-0 animate-spin text-primary"});case"ok":return(0,r.jsx)(a.wiW,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"});case"failed":return(0,r.jsx)(a.yBK,{className:"size-3.5 shrink-0 text-destructive"});case"skipped":return(0,r.jsx)(a.uPM,{className:"size-3.5 shrink-0 text-muted-foreground/60"});default:return(0,r.jsx)(a.Rzr,{className:"size-3.5 shrink-0 text-muted-foreground/60"})}}function c({open:e,direction:t,connection:n,steps:u,blockedBy:m,progress:p,running:f,recordOnly:x,note:h,onRun:g,onStop:v,onClose:b}){let j=x?"apply"===t?"Mark as applied":"Mark as not applied":"apply"===t?"Apply":"Revert",k=x?"Marked":"apply"===t?"Applied":"Reverted",N=u.length,y=u.filter(e=>{var t;return"wrapped-by-ytdb"!==(t=e.transaction)&&"self-wrapped"!==t}),w=p?.find(e=>"failed"===e.status)??null,$=null!==p&&!f,C=p?.filter(e=>"ok"===e.status).length??0,z=p??u.map(e=>({version:e.version,name:e.name,status:"waiting"}));return(0,r.jsx)(l.lG,{open:e,onOpenChange:e=>!e&&!f&&b(),children:(0,r.jsxs)(l.Cf,{className:"sm:max-w-lg",children:[(0,r.jsxs)(l.c7,{children:[(0,r.jsx)(l.L3,{children:0===N&&m?"Nothing here can be reverted":$?w?`${j} stopped after ${C} of ${N}`:`${k} ${C} migration${1===C?"":"s"}`:x?`${"Mark as applied"===j?"Mark":"Unmark"} ${N} migration${1===N?"":"s"} on ${n.name}?`:`${j} ${N} migration${1===N?"":"s"}?`}),(0,r.jsx)(l.rr,{children:(0,r.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{children:x?$?"Recorded on":"Records on":$?"Ran against":"Runs against"}),(0,r.jsx)(s.F,{connection:n}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:n.name}),(0,r.jsx)("span",{className:"font-mono text-[11px]",children:o(n.url)})]})})]}),!p&&h&&(0,r.jsxs)("p",{className:"flex max-h-40 gap-2 overflow-y-auto rounded-md border bg-muted/30 px-3 py-2 text-xs",children:[(0,r.jsx)(a.UA_,{className:"mt-px size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:h})]}),z.length>0&&(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:z.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3 py-1.5 text-xs last:border-b-0",children:[(0,r.jsx)(d,{status:e.status}),(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}),void 0!==e.durationMs&&(0,r.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[e.durationMs," ms"]})]},e.version))}),w?.error&&(0,r.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.error}),!p&&m&&(0,r.jsxs)("p",{className:"flex gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(a.e5t,{className:"mt-px size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),(0,r.jsx)("span",{children:0===N?`${m.version} ${m.name} is the newest one applied and has no revert file, so nothing below it can be reached.`:`Stops at ${m.version} ${m.name}, which has no revert file.`})]}),!p&&x&&(0,r.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:"No SQL runs."})," Only the ledger on ",n.name," ","changes."]}),!p&&!x&&y.length>0&&(0,r.jsxs)("p",{className:"flex gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(a.e5t,{className:"mt-px size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),(0,r.jsx)("span",{children:1===y.length?`${y[0].version} runs outside a transaction, so a failure partway leaves it half applied.`:`${y.length} of these run outside a transaction, so a failure partway leaves them half applied.`})]}),!p&&!x&&"revert"===t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Reverting runs newest first and can drop data the migrations created."}),(0,r.jsx)(l.Es,{children:f?(0,r.jsx)(i.$,{variant:"outline",onClick:v,children:"Stop after this one"}):$?(0,r.jsx)(i.$,{onClick:b,children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$,{variant:"outline",onClick:b,children:0===N?"Close":"Cancel"}),N>0&&(0,r.jsx)(i.$,{variant:x||"revert"!==t?"default":"destructive",onClick:g,children:x?`${j} (${N})`:`${j} ${1===N?"migration":`${N} migrations`}`})]})})]})})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3732],{9385:(e,t,n)=>{n.d(t,{x:()=>r});function r(e,t){let n=new Map(e.map(e=>[e.connection.id,e])),r=t.filter(e=>n.has(e.connectionId)).map(e=>({id:e.id,connectionId:e.connectionId,connectionName:e.connectionName,version:e.version,name:e.name,at:e.ranAt,kind:"failed"===e.status?"failed":e.recorded?"apply"===e.direction?"marked":"unmarked":"apply"===e.direction?"applied":"reverted",durationMs:e.durationMs,error:e.error,setName:e.setName,fromLedger:!1})),a=new Map;for(let e of r){let t=`${e.connectionId}:${e.setName??""}:${e.version}`,n=a.get(t);(!n||e.at>n.at)&&a.set(t,e)}let s=[...r];for(let t of e)for(let e of t.ledger?.entries??[]){let n=`${t.connection.id}:${e.setName}:${e.version}`,r=a.get(n);if(r&&("applied"===r.kind||"marked"===r.kind)){r.appliedBy=e.appliedBy;continue}s.push({id:`ledger:${t.connection.id}:${e.setName}:${e.version}`,connectionId:t.connection.id,connectionName:t.connection.name,version:e.version,name:e.name||e.version,at:function(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}(e.appliedAt),kind:"applied",durationMs:e.durationMs,setName:e.setName,appliedBy:e.appliedBy,fromLedger:!0})}return s.sort((e,t)=>t.at-e.at)}},17491:(e,t,n)=>{n.d(t,{X:()=>u});var r=n(95155),a=n(40980),s=n(13267),i=n(89239),l=n(43262),o=n(36331),d=n(48861);function c({className:e}){let{connection:t}=(0,o.k)(),{back:n,forward:u,goBack:m,goForward:p}=(0,d.Q)(t.id);return(0,r.jsxs)("div",{className:(0,a.cn)("flex items-center",e),children:[(0,r.jsx)(i.$,{variant:"ghost",size:"icon-sm",disabled:!n,"aria-label":n?`Back to ${n.label}`:"Back",title:n?`Back to ${n.label} (${l.Ar.back})`:void 0,className:"disabled:opacity-30",onClick:m,children:(0,r.jsx)(s.SI1,{})}),(0,r.jsx)(i.$,{variant:"ghost",size:"icon-sm",disabled:!u,"aria-label":u?`Forward to ${u.label}`:"Forward",title:u?`Forward to ${u.label} (${l.Ar.forward})`:void 0,className:"disabled:opacity-30",onClick:p,children:(0,r.jsx)(s.nNJ,{})})]})}function u({children:e,className:t}){return(0,r.jsxs)("header",{className:(0,a.cn)("flex h-11 shrink-0 items-center gap-2 border-b pr-3 pl-1.5",t),children:[(0,r.jsx)(c,{className:"mr-0.5"}),e]})}},27013:(e,t,n)=>{n.d(t,{K:()=>o});var r=n(95155),a=n(12115),s=n(89239),i=n(42763),l=n(60529);function o(e){return(0,r.jsx)(i.lG,{open:e.open,onOpenChange:e.onOpenChange,children:(0,r.jsx)(i.Cf,{className:"sm:max-w-sm",showCloseButton:!1,children:e.open&&(0,r.jsx)(d,{...e})})})}function d({title:e,initial:t="",submitLabel:n,onOpenChange:o,onSubmit:c}){let[u,m]=(0,a.useState)(t),p=u.trim();return(0,r.jsxs)("form",{onSubmit:function(e){e.preventDefault(),p&&(c(p),o(!1))},className:"flex flex-col gap-4",children:[(0,r.jsx)(i.c7,{children:(0,r.jsx)(i.L3,{children:e})}),(0,r.jsx)(l.p,{autoFocus:!0,"aria-label":"Migration name",value:u,placeholder:"add_users_table",onChange:e=>m(e.target.value),onFocus:e=>e.currentTarget.select()}),(0,r.jsxs)(i.Es,{children:[(0,r.jsx)(s.$,{type:"button",variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),(0,r.jsx)(s.$,{type:"submit",disabled:!p,children:n})]})]})}},30374:(e,t,n)=>{n.d(t,{x:()=>s});var r=n(95155),a=n(40980);function s({value:e,options:t,onChange:n,label:i}){return(0,r.jsx)("div",{role:"group","aria-label":i,className:"flex h-7 items-center rounded-md border bg-muted/50 p-0.5",children:t.map(t=>(0,r.jsx)("button",{type:"button","aria-pressed":t.value===e,onClick:()=>n(t.value),className:(0,a.cn)("h-full rounded-sm px-2 text-xs transition-colors",t.value===e?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"),children:t.label},t.value))})}},33807:(e,t,n)=>{n.d(t,{J:()=>s});var r=n(95155);n(12115);var a=n(40980);function s({className:e,...t}){return(0,r.jsx)("label",{"data-slot":"label",className:(0,a.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}},35942:(e,t,n)=>{n.d(t,{F:()=>c});var r=n(95155);n(12115);var a=n(76166),s=n(90839),i=n(84588),l=n(66784),o=n(64084),d=n(40980);function c({className:e,children:t,...n}){return(0,r.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,d.cn)("relative",e),...n,children:[(0,r.jsx)(s.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),(0,r.jsx)(u,{}),(0,r.jsx)(i.I,{})]})}function u({className:e,orientation:t="vertical",...n}){return(0,r.jsx)(l.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,d.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...n,children:(0,r.jsx)(o.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},41069:(e,t,n)=>{n.d(t,{l:()=>s});var r=n(95155),a=n(30374);function s({caption:e,pane:t,onPaneChange:n,historyCount:i,migrationsLabel:l="Migrations"}){return(0,r.jsxs)("footer",{className:"flex shrink-0 items-center gap-2 border-t px-4 py-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"min-w-0 truncate",children:e}),(0,r.jsx)("div",{className:"ml-auto",children:(0,r.jsx)(a.x,{label:"Migrations pane",value:t,onChange:n,options:[{value:"migrations",label:l},{value:"history",label:i>0?`History (${i})`:"History"}]})})]})}},42611:(e,t,n)=>{n.d(t,{H:()=>m});var r=n(95155),a=n(13267),s=n(72194),i=n(89239),l=n(79668),o=n(40980);let d={applied:"applied",reverted:"reverted",marked:"marked",unmarked:"unmarked",failed:"failed"};function c({kind:e}){switch(e){case"failed":return(0,r.jsx)(a.yBK,{className:"size-3.5 shrink-0 text-destructive"});case"reverted":return(0,r.jsx)(a.ij9,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"});case"marked":return(0,r.jsx)(a.nXx,{className:"size-3.5 shrink-0 text-muted-foreground"});case"unmarked":return(0,r.jsx)(a.fJ4,{className:"size-3.5 shrink-0 text-muted-foreground"});default:return(0,r.jsx)(a.wiW,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"})}}function u({event:e,connection:t}){return(0,r.jsxs)("div",{className:"flex items-start gap-2 border-b px-4 py-2 text-xs last:border-b-0",children:[(0,r.jsx)("span",{className:"mt-0.5",children:(0,r.jsx)(c,{kind:e.kind})}),(0,r.jsx)("span",{className:(0,o.cn)("mt-px shrink-0 rounded-md px-1.5 text-[11px]","failed"===e.kind?"bg-destructive/10 text-destructive":"reverted"===e.kind?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"bg-muted text-muted-foreground"),children:d[e.kind]}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"truncate",children:e.name}),e.error&&(0,r.jsx)("span",{className:"mt-1 block font-mono text-[11px] whitespace-pre-wrap text-destructive",children:e.error})]}),e.setName&&(0,r.jsx)("span",{className:"hidden max-w-32 shrink-0 truncate text-muted-foreground/60 lg:inline",children:e.setName}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-muted-foreground",children:[t&&(0,r.jsx)(s.F,{connection:t,className:"size-1.5"}),e.connectionName]}),e.appliedBy&&(0,r.jsx)("span",{className:"hidden shrink-0 text-muted-foreground/60 xl:inline",children:e.appliedBy}),(0,r.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/70",children:null===e.durationMs?"":`${e.durationMs} ms`}),(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground/70",title:e.fromLedger?"Read from the database's own ledger":"Run from this browser",children:new Date(e.at).toLocaleString()})]})}function m({events:e,connections:t,loading:n}){let a=(0,l.jV)(e=>e.clearHistory),s=new Map(t.map(e=>[e.id,e])),o=e.filter(e=>!e.fromLedger).length;return 0===e.length?(0,r.jsx)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:n?"Reading ledgers…":"Nothing has run yet."}):(0,r.jsxs)("div",{children:[e.map(e=>(0,r.jsx)(u,{event:e,connection:s.get(e.connectionId)},e.id)),o>0&&(0,r.jsx)("div",{className:"flex justify-end px-3 py-2",children:(0,r.jsx)(i.$,{size:"xs",variant:"ghost",className:"text-muted-foreground",title:"Clears this browser's log. The databases' ledgers are untouched.",onClick:()=>a(),children:"Clear local log"})})]})}},42763:(e,t,n)=>{n.d(t,{Cf:()=>g,Es:()=>b,L3:()=>j,c7:()=>v,lG:()=>f,rr:()=>k});var r=n(95155);n(12115);var a=n(98408),s=n(32949),i=n(45477),l=n(88593),o=n(52579),d=n(11975),c=n(31799),u=n(40980),m=n(89239),p=n(13267);function f({...e}){return(0,r.jsx)(a.D,{"data-slot":"dialog",...e})}function x({...e}){return(0,r.jsx)(s.Z,{"data-slot":"dialog-portal",...e})}function h({className:e,...t}){return(0,r.jsx)(i.X,{"data-slot":"dialog-overlay",className:(0,u.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function g({className:e,children:t,showCloseButton:n=!0,...a}){return(0,r.jsxs)(x,{children:[(0,r.jsx)(h,{}),(0,r.jsxs)(l.h,{"data-slot":"dialog-content",className:(0,u.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a,children:[t,n&&(0,r.jsxs)(o.H,{"data-slot":"dialog-close",render:(0,r.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,r.jsx)(p.yBK,{}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function v({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"dialog-header",className:(0,u.cn)("flex flex-col gap-2",e),...t})}function b({className:e,showCloseButton:t=!1,children:n,...a}){return(0,r.jsxs)("div",{"data-slot":"dialog-footer",className:(0,u.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...a,children:[n,t&&(0,r.jsx)(o.H,{render:(0,r.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function j({className:e,...t}){return(0,r.jsx)(d.L,{"data-slot":"dialog-title",className:(0,u.cn)("font-heading text-base leading-none font-medium",e),...t})}function k({className:e,...t}){return(0,r.jsx)(c.r,{"data-slot":"dialog-description",className:(0,u.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}},60529:(e,t,n)=>{n.d(t,{p:()=>i});var r=n(95155);n(12115);var a=n(64878),s=n(40980);function i({className:e,type:t,...n}){return(0,r.jsx)(a.p,{type:t,"data-slot":"input",className:(0,s.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none 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),...n})}},62417:(e,t,n)=>{n.d(t,{DM:()=>p,FY:()=>o,Gf:()=>s,ay:()=>l,e:()=>m,eh:()=>d,gj:()=>u,kB:()=>x,lF:()=>h,n9:()=>f,nb:()=>c,yy:()=>g});var r=n(20642);let a={steps:[],blockedBy:null};function s(e,t){return e?{...e,entries:e.entries.filter(e=>e.setName===t)}:null}function i(e){let t=new Map;for(let n of e?.entries??[])t.set(n.version,n);return t}function l(e,t){return t?t.entries.find(t=>t.version===e.version)??null:null}function o(e,t){if(!t)return"unknown";let n=l(e,t);return n?n.checksum&&n.checksum!==e.checksum?"drifted":"applied":"pending"}function d(e,t){let n={total:e?.steps.length??0,applied:0,drifted:0,pending:0,foreign:0};if(!e)return n;let r=s(t,e.name);for(let t of e.steps){let e=o(t,r);"applied"===e?n.applied+=1:"drifted"===e?n.drifted+=1:"pending"===e&&(n.pending+=1)}return n.foreign=c(e,r).length,n}function c(e,t){if(!t)return[];let n=new Set((e?.steps??[]).map(e=>e.version));return t.entries.filter(e=>!n.has(e.version)).sort((e,t)=>(0,r.Zy)(e.version,t.version))}function u(e,t,n){if(!e||!t)return a;let r=[];for(let a of e.steps)if("pending"===o(a,t)&&r.push(a),void 0!==n&&a.version===n)break;return{steps:r,blockedBy:null}}function m(e,t,n){if(!e||!t)return a;let s=i(t),l=[];for(let t of[...e.steps].reverse()){if(void 0!==n&&0>(0,r.Zy)(t.version,n))break;if(s.has(t.version)){if(!t.revertSql)return{steps:l,blockedBy:t};l.push(t)}}return{steps:l,blockedBy:null}}function p(e,t,n){return e&&t?{steps:e.steps.filter(e=>n.has(e.version)&&"pending"===o(e,t)),blockedBy:null}:a}function f(e,t,n){if(!e||!t)return a;let r=i(t),s=[];for(let t of[...e.steps].reverse())if(n.has(t.version)&&r.has(t.version)){if(!t.revertSql)return{steps:s,blockedBy:t};s.push(t)}return{steps:s,blockedBy:null}}function x(e,t){if(!e||!t)return null;let n=i(t);for(let t of[...e.steps].reverse())if(n.has(t.version))return t;return null}function h(e,t){let n=new Set(t.map(e=>e.toLowerCase())),a=new Map;for(let t of e)for(let e of t.ledger?.entries??[]){let r=e.setName.trim();if(!r||n.has(r.toLowerCase()))continue;let s=a.get(r)??new Map,i=s.get(t.connection.id)??new Set;i.add(e.version),s.set(t.connection.id,i),a.set(r,s)}return[...a.entries()].map(([t,n])=>{let a=new Set;for(let e of n.values())for(let t of e)a.add(t);return{name:t,versions:[...a].sort(r.Zy),total:a.size,applied:e.map(e=>({connectionId:e.connection.id,connectionName:e.connection.name,count:n.get(e.connection.id)?.size??0}))}}).sort((e,t)=>e.name.localeCompare(t.name))}function g(e,t,n){let r=n.query.trim().toLowerCase();if(r&&![e.name,...e.steps.flatMap(e=>[e.version,e.name])].join("\n").toLowerCase().includes(r))return!1;let{status:a}=n;if("all"===a)return!0;if(a.startsWith("pending:")){let e=t.find(e=>e.connectionId===a.slice(8));return!e||!e.read||e.summary.pending>0||e.summary.drifted>0}return"pending"===a?t.some(e=>!e.read||e.summary.pending>0||e.summary.drifted>0):"untouched"===a?t.every(e=>!e.read||0===e.summary.applied&&0===e.summary.drifted):"complete"!==a||e.steps.length>0&&t.every(e=>e.read&&0===e.summary.pending&&0===e.summary.drifted)}},71612:(e,t,n)=>{n.d(t,{y:()=>s});var r=n(87364),a=n(27529);function s(e,t){return(0,r.Y)(`repo:${e??""}:${t??""}`,async n=>e?a.F.repo(e,t,n):null)}},72194:(e,t,n)=>{n.d(t,{F:()=>i});var r=n(95155),a=n(40980),s=n(32538);function i({connection:e,className:t}){return(0,r.jsx)("span",{"aria-hidden":!0,className:(0,a.cn)("size-2.5 shrink-0 rounded-full",t),style:{background:(0,s.Mq)(e)}})}},77649:(e,t,n)=>{n.d(t,{k:()=>p,$:()=>m});var r=n(95155),a=n(12115),s=n(13267),i=n(89239);function l(e){let t=e.createReader?.();return t?new Promise((e,n)=>{let r=[],a=()=>{t.readEntries(t=>{0===t.length||r.length>=2e3?e(r):(r.push(...t),a())},n)};a()}):Promise.resolve([])}async function o(e,t,n,r){if(r.length>=2e3||n>6||e.name.startsWith("."))return;let a=t?`${t}/${e.name}`:e.name;if(e.isFile){if(!/\.sql$/i.test(e.name))return;let t=await new Promise((t,n)=>{e.file?e.file(t,n):n(Error(`Could not read ${e.name}`))});r.push({path:a,text:await t.text()});return}if(e.isDirectory)for(let t of(await l(e)))await o(t,a,n+1,r)}async function d(e){let t=[];for(let n of Array.from(e.items)){if("file"!==n.kind)continue;let e=n.webkitGetAsEntry?.();e&&t.push(e)}if(0===t.length){let t=Array.from(e.files).filter(e=>/\.sql$/i.test(e.name));return 0===t.length?null:{name:"Migrations",files:await Promise.all(t.map(async e=>({path:e.name,text:await e.text()})))}}let n=1===t.length&&t[0].isDirectory?t[0]:null,r=[];if(n){for(let e of(await l(n)))await o(e,"",1,r);return{name:n.name,files:r}}for(let e of t)await o(e,"",0,r);return r.length>0?{name:"Migrations",files:r}:null}async function c(e){let t,n=Array.from(e).filter(e=>/\.sql$/i.test(e.name));if(0===n.length)return null;let r=new Set(n.map(e=>(e.webkitRelativePath||e.name).split("/")[0])),a=1===r.size&&((t=n[0]).webkitRelativePath||t.name).includes("/")?[...r][0]:null;return{name:a??"Migrations",files:await Promise.all(n.slice(0,2e3).map(async e=>{let t=e.webkitRelativePath||e.name;return{path:a?t.slice(a.length+1):t,text:await e.text()}}))}}var u=n(40980);function m(e){let[t,n]=(0,a.useState)(!1),[r,s]=(0,a.useState)(null);return{importFrom:(0,a.useCallback)(async t=>{n(!0),s(null);try{let n=t instanceof FileList?await c(t):await d(t);if(!n||0===n.files.length)return void s("No .sql files in there.");e(n)}catch(e){s(e instanceof Error?e.message:"Couldn’t read that folder.")}finally{n(!1)}},[e]),busy:t,error:r,clearError:()=>s(null)}}function p({onFiles:e,className:t,compact:n=!1}){let{importFrom:l,busy:o,error:d}=m(e),[c,f]=(0,a.useState)(!1),x=(0,a.useRef)(null),h=(0,a.useRef)(null);return(0,a.useEffect)(()=>{x.current?.setAttribute("webkitdirectory",""),x.current?.setAttribute("directory","")},[]),(0,r.jsxs)("div",{onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:e=>{e.preventDefault(),f(!1),l(e.dataTransfer)},className:(0,u.cn)("flex items-center justify-center rounded-lg border border-dashed text-center transition-colors",n?"flex-wrap gap-x-3 gap-y-2 px-4 py-3":"flex-col gap-4 px-6 py-10",c?"border-primary bg-primary/5":"border-border",t),children:[o?(0,r.jsx)(s.gnh,{className:"size-4 shrink-0 animate-spin text-muted-foreground"}):(0,r.jsx)(s.FeY,{className:(0,u.cn)("shrink-0 text-muted-foreground",n?"size-4":"size-5")}),n?(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Drop a folder of .sql files"}):(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Drop a migration folder"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:".sql files, optionally split into apply/ and revert/"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)(i.$,{size:n?"xs":"sm",variant:n?"ghost":"outline",disabled:o,onClick:()=>x.current?.click(),children:[(0,r.jsx)(s.WzY,{"data-icon":"inline-start"}),"Choose folder"]}),(0,r.jsx)(i.$,{size:n?"xs":"sm",variant:"ghost",disabled:o,onClick:()=>h.current?.click(),children:"Choose files"})]}),d&&(0,r.jsx)("p",{className:"w-full text-xs text-destructive",children:d}),(0,r.jsx)("input",{ref:x,type:"file",multiple:!0,className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&l(t),e.target.value=""}}),(0,r.jsx)("input",{ref:h,type:"file",multiple:!0,accept:".sql",className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&l(t),e.target.value=""}})]})}},83504:(e,t,n)=>{n.d(t,{I:()=>c,p:()=>o});var r=n(95155),a=n(13267),s=n(72194),i=n(89239),l=n(42763);function o(e){try{let t=new URL(e),n=t.username?`${decodeURIComponent(t.username)}@`:"",r=t.port?`:${t.port}`:"";return`${n}${t.hostname}${r}${t.pathname}`}catch{return"this connection"}}function d({status:e}){switch(e){case"running":return(0,r.jsx)(a.gnh,{className:"size-3.5 shrink-0 animate-spin text-primary"});case"ok":return(0,r.jsx)(a.wiW,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"});case"failed":return(0,r.jsx)(a.yBK,{className:"size-3.5 shrink-0 text-destructive"});case"skipped":return(0,r.jsx)(a.uPM,{className:"size-3.5 shrink-0 text-muted-foreground/60"});default:return(0,r.jsx)(a.Rzr,{className:"size-3.5 shrink-0 text-muted-foreground/60"})}}function c({open:e,direction:t,connection:n,steps:u,blockedBy:m,progress:p,running:f,recordOnly:x,note:h,onRun:g,onStop:v,onClose:b}){let j=x?"apply"===t?"Mark as applied":"Mark as not applied":"apply"===t?"Apply":"Revert",k=x?"Marked":"apply"===t?"Applied":"Reverted",N=u.length,y=u.filter(e=>{var t;return"wrapped-by-ytdb"!==(t=e.transaction)&&"self-wrapped"!==t}),w=p?.find(e=>"failed"===e.status)??null,$=null!==p&&!f,C=p?.filter(e=>"ok"===e.status).length??0,z=p??u.map(e=>({version:e.version,name:e.name,status:"waiting"}));return(0,r.jsx)(l.lG,{open:e,onOpenChange:e=>!e&&!f&&b(),children:(0,r.jsxs)(l.Cf,{className:"sm:max-w-lg",children:[(0,r.jsxs)(l.c7,{children:[(0,r.jsx)(l.L3,{children:0===N&&m?"Nothing here can be reverted":$?w?`${j} stopped after ${C} of ${N}`:`${k} ${C} migration${1===C?"":"s"}`:x?`${"Mark as applied"===j?"Mark":"Unmark"} ${N} migration${1===N?"":"s"} on ${n.name}?`:`${j} ${N} migration${1===N?"":"s"}?`}),(0,r.jsx)(l.rr,{children:(0,r.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)("span",{children:x?$?"Recorded on":"Records on":$?"Ran against":"Runs against"}),(0,r.jsx)(s.F,{connection:n}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:n.name}),(0,r.jsx)("span",{className:"font-mono text-[11px]",children:o(n.url)})]})})]}),!p&&h&&(0,r.jsxs)("p",{className:"flex max-h-40 gap-2 overflow-y-auto rounded-md border bg-muted/30 px-3 py-2 text-xs",children:[(0,r.jsx)(a.UA_,{className:"mt-px size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:h})]}),z.length>0&&(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:z.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b px-3 py-1.5 text-xs last:border-b-0",children:[(0,r.jsx)(d,{status:e.status}),(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}),void 0!==e.durationMs&&(0,r.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[e.durationMs," ms"]})]},e.version))}),w?.error&&(0,r.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.error}),!p&&m&&(0,r.jsxs)("p",{className:"flex gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(a.e5t,{className:"mt-px size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),(0,r.jsx)("span",{children:0===N?`${m.version} ${m.name} is the newest one applied and has no revert file, so nothing below it can be reached.`:`Stops at ${m.version} ${m.name}, which has no revert file.`})]}),!p&&x&&(0,r.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:"No SQL runs."})," Only the ledger on ",n.name," ","changes."]}),!p&&!x&&y.length>0&&(0,r.jsxs)("p",{className:"flex gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(a.e5t,{className:"mt-px size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),(0,r.jsx)("span",{children:1===y.length?`${y[0].version} runs outside a transaction, so a failure partway leaves it half applied.`:`${y.length} of these run outside a transaction, so a failure partway leaves them half applied.`})]}),!p&&!x&&"revert"===t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Reverting runs newest first and can drop data the migrations created."}),(0,r.jsx)(l.Es,{children:f?(0,r.jsx)(i.$,{variant:"outline",onClick:v,children:"Stop after this one"}):$?(0,r.jsx)(i.$,{onClick:b,children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$,{variant:"outline",onClick:b,children:0===N?"Close":"Cancel"}),N>0&&(0,r.jsx)(i.$,{variant:x||"revert"!==t?"default":"destructive",onClick:g,children:x?`${j} (${N})`:`${j} ${1===N?"migration":`${N} migrations`}`})]})})]})})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6090],{25:(e,t,n)=>{n.d(t,{Ol:()=>l,TA:()=>d,qb:()=>c});let r=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,i=new Set(["begin","start"]),o=new Set(["commit","end"]),a=new Set(["rollback"]);function s(e){return void 0!==e&&(e>="A"&&e<="Z"||e>="a"&&e<="z"||"_"===e)||void 0!==e&&e>="0"&&e<="9"}function l(e){if(r.test(e))return{mode:"unwrapped",sql:e,atomic:!1};let t=function(e){let t=[],n=0,r=0,i=r=>{let i=function(e,t){let n=t;for(;n<e.length;){let t=e[n];if(" "===t||" "===t||"\n"===t||"\r"===t){n+=1;continue}if("-"===t&&"-"===e[n+1]){for(;n<e.length&&"\n"!==e[n];)n+=1;continue}if("/"===t&&"*"===e[n+1]){let t=e.indexOf("*/",n+2);n=-1===t?e.length:t+2;continue}break}return n}(e,n);if(i>=r)return;let o=i;for(;o<e.length&&s(e[o]);)o+=1;t.push({at:i,end:r,keyword:e.slice(i,o).toLowerCase()})};for(;r<e.length;){let t=e[r];if("-"===t&&"-"===e[r+1]){for(;r<e.length&&"\n"!==e[r];)r+=1;continue}if("/"===t&&"*"===e[r+1]){let t=e.indexOf("*/",r+2);r=-1===t?e.length:t+2;continue}if("'"===t||'"'===t){r=function(e,t,n){let r=t+1;for(;r<e.length;){if(e[r]===n){if(e[r+1]===n){r+=2;continue}return r+1}r+=1}return r}(e,r,t);continue}if("$"===t){let t=function(e,t){if("$"!==e[t])return null;let n=t+1;for(;n<e.length&&s(e[n]);)n+=1;return"$"!==e[n]?null:e.slice(t,n+1)}(e,r);if(t){let n=e.indexOf(t,r+t.length);r=-1===n?e.length:n+t.length;continue}}if(";"===t){i(r+1),r+=1,n=r;continue}r+=1}return i(e.length),t}(e),n=t.filter(e=>i.has(e.keyword)||o.has(e.keyword)||a.has(e.keyword));if(0===n.length)return{mode:"wrapped-by-ytdb",sql:e,atomic:!0};let l=t[0],d=t[t.length-1];return 2===n.length&&n[0]===l&&n[1]===d&&i.has(l.keyword)&&o.has(d.keyword)?{mode:"self-wrapped",sql:e.slice(0,l.at)+e.slice(l.end,d.at)+e.slice(d.end),atomic:!0}:{mode:"self-managed",sql:e,atomic:!1}}function d(e){switch(e){case"unwrapped":return"Marked `-- ytdb:no-transaction`, so it runs with no transaction. A failure partway leaves the statements before it applied.";case"self-managed":return"This file commits more than once, so YTDB runs it as written and records it afterwards. A failure partway can leave it half applied and unrecorded.";default:return null}}function c(e){return"unwrapped"===e?"no transaction":"self-managed"===e?"self-managed":null}},20185:(e,t,n)=>{function r(e){let t=e.split("/").filter(Boolean).map(decodeURIComponent);if(0===t.length)return{kind:"home"};let[n,r,i]=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:i}:{kind:"table",connectionId:n,table:{schema:r,name:i}}:{kind:"connection",connectionId:n}}function i(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 o(e,t,{tableExists:n=!0}={}){let a=r(e);return"home"!==a.kind&&("table"!==a.kind||n)?i({...a,connectionId:t}):i({kind:"connection",connectionId:t})}n.d(t,{Jn:()=>i,ZG:()=>r,gZ:()=>o})},20642:(e,t,n)=>{n.d(t,{Ai:()=>g,Nz:()=>h,Zy:()=>p,mj:()=>m,wQ:()=>y});var r=n(40980),i=n(25);let o=new Set(["apply","up","forward"]),a=new Set(["revert","down","rollback","undo"]),s=[".up",".apply",".forward","_up","_apply","-up","-apply"],l=[".down",".revert",".rollback",".undo","_down","_revert","_rollback","_undo","-down","-revert","-rollback","-undo"];function d(e){return e.split("/").filter(e=>e.length>0)}function c(e){let t=/^[Vv](\d+(?:[._]\d+)*)__(.*)$/.exec(e);if(t)return{version:t[1].replace(/_/g,"."),name:u(t[2])};let n=/^(\d+(?:[-.]\d+)*)(?:[-_.\s]+(.*))?$/.exec(e);return n?{version:n[1],name:u(n[2]??"")}:{version:e,name:u(e)}}function u(e){return e.replace(/[-_]+/g," ").trim()}function p(e,t){let n=/(\d+)|(\D+)/g,r=e.match(n)??[],i=t.match(n)??[],o=Math.min(r.length,i.length);for(let e=0;e<o;e+=1){let t=r[e],n=i[e],o=/^\d+$/.test(t)&&/^\d+$/.test(n)?Number(t)-Number(n):t.localeCompare(n);if(0!==o)return o}return r.length-i.length}function f(e){let t=e.replace(/\r\n/g,"\n").trim(),n=0x811c9dc5,r=0x1000193;for(let e=0;e<t.length;e+=1){let i=t.charCodeAt(e);n=Math.imul(n^i,0x1000193)>>>0,r=Math.imul(r+i,0x85ebca6b)>>>0}return`${n.toString(16).padStart(8,"0")}${r.toString(16).padStart(8,"0")}`}function h(e){let t={applies:new Map,reverts:new Map,skipped:[],errors:[]},n=e.filter(e=>{var t;let n=d(t=e.path).at(-1)??t;return!n.startsWith(".")&&/\.sql$/i.test(n)});if(0===n.length)return t.errors.push("No .sql files in there."),t;let r=n.reduce((e,t)=>e+t.text.length,0);if(r>4e6)return t.errors.push(`That is ${b(r)} of SQL, over the ${b(4e6)} limit.`),t;let i=[];for(let e of n){if(e.text.length>5e5){t.skipped.push(`${e.path} — over ${b(5e5)}`);continue}if(e.text.includes("\0")){t.skipped.push(`${e.path} — not text`);continue}if(!e.text.trim()){t.skipped.push(`${e.path} — empty`);continue}i.push({file:e,...function(e){let t=d(e),n=(t.at(-1)??e).replace(/\.sql$/i,"");for(let e of t.slice(0,-1)){let t=e.toLowerCase();if(a.has(t))return{direction:"revert",stem:n};if(o.has(t))return{direction:"apply",stem:n}}let r=n.toLowerCase();for(let e of l)if(r.endsWith(e))return{direction:"revert",stem:n.slice(0,-e.length)};for(let e of s)if(r.endsWith(e))return{direction:"apply",stem:n.slice(0,-e.length)};return{direction:"apply",stem:n}}(e.path)})}let p=new Set,f=!1;for(let{direction:e,stem:t}of i){if("apply"!==e)continue;let{version:n}=c(t);p.has(n)&&(f=!0),p.add(n)}for(let{file:e,direction:n,stem:r}of i){let{version:i,name:o}=f?{version:r,name:u(r)}:c(r),a=("apply"===n?t.applies:t.reverts).get(i);if(a){t.skipped.push(`${e.path} — ${a.path} is already version ${i}`);continue}"apply"===n?t.applies.set(i,{path:e.path,sql:e.text,name:o}):t.reverts.set(i,{path:e.path,sql:e.text})}return 0===t.applies.size&&0===t.reverts.size&&t.errors.push("None of those .sql files could be read as a migration."),t}function g(e,t){let n=new Map(e.map(e=>[e.version,{...e}])),r=[...t.skipped],o=0,a=0,s=0;for(let[e,s]of t.applies){let t=n.get(e);if(t){t.applySql!==s.sql&&(a+=1),t.name=s.name||t.name,t.applyPath=s.path,t.applySql=s.sql,t.checksum=f(s.sql),t.transaction=(0,i.Ol)(s.sql).mode;continue}if(n.size>=500){r.push(`${s.path} — over 500 migrations`);continue}n.set(e,{version:e,name:s.name||e,applyPath:s.path,applySql:s.sql,checksum:f(s.sql),transaction:(0,i.Ol)(s.sql).mode}),o+=1}for(let[e,i]of t.reverts){let t=n.get(e);if(!t){r.push(`${i.path} — no migration ${e} to revert`);continue}t.revertPath=i.path,t.revertSql=i.sql,s+=1}return{steps:[...n.values()].sort((e,t)=>p(e.version,t.version)),added:o,updated:a,reverts:s,skipped:r}}function m(e){return{id:(0,r.z)(),name:v(e),importedAt:Date.now(),steps:[],skipped:[]}}function v(e){return e.trim().replace(/\s+/g," ").slice(0,80)||"Migrations"}function b(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function y(e,t){let n=[],o=[];for(let e of[...t].sort((e,t)=>p(e.version,t.version))){if(!e.applySql){n.push(e.version);continue}o.push({version:e.version,name:e.name||e.version,applyPath:`${e.version} (from the ledger)`,applySql:e.applySql,checksum:f(e.applySql),revertPath:e.revertSql?`${e.version} revert (from the ledger)`:void 0,revertSql:e.revertSql,transaction:(0,i.Ol)(e.applySql).mode})}return{set:{id:(0,r.z)(),name:v(e),importedAt:Date.now(),steps:o,skipped:[]},missing:n}}},27529:(e,t,n)=>{n.d(t,{F:()=>o});var r=n(72914);async function i(e,t,n){let i,o=await (0,r.Qv)(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n}),a=await o.text();if(!a)throw Error(`YTDB bridge returned an empty response (HTTP ${o.status}). Restart YTDB to update the local bridge.`);try{i=JSON.parse(a)}catch{if(404===o.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 ${o.status}).`)}if(!o.ok)throw Error((i&&"object"==typeof i&&"error"in i&&"string"==typeof i.error?i.error:o.statusText)||`YTDB bridge request failed with HTTP ${o.status}.`);return i}let o={tables:(e,t)=>i("/api/tables",{connectionUrl:e},t),rows:(e,t,n)=>i("/api/rows",{connectionUrl:e,query:t},n),query:(e,t,n)=>i("/api/query",{connectionUrl:e,sql:t},n),updateCell:(e,t,n)=>i("/api/cell",{connectionUrl:e,update:t},n),insertRow:(e,t,n)=>i("/api/insert-row",{connectionUrl:e,insertion:t},n),updateRow:(e,t,n)=>i("/api/update-row",{connectionUrl:e,update:t},n),deleteRows:(e,t,n)=>i("/api/delete-rows",{connectionUrl:e,deletion:t},n),related:(e,t,n)=>i("/api/related",{connectionUrl:e,lookups:t},n),lookup:(e,t,n)=>i("/api/lookup",{connectionUrl:e,query:t},n),definition:(e,t,n)=>i("/api/definition",{connectionUrl:e,table:t},n),schema:(e,t)=>i("/api/schema",{connectionUrl:e},t),ledger:(e,t,n,r=!1)=>i("/api/ledger",{connectionUrl:e,ledgerSchema:t,withSql:r},n),migrate:(e,t,n)=>i("/api/migrate",{connectionUrl:e,migration:t},n),adopt:(e,t,n)=>i("/api/adopt",{connectionUrl:e,adopt:t},n),detect:(e,t,n)=>i("/api/detect",{connectionUrl:e,migrations:t},n),repo:(e,t,n)=>i("/api/repo",{root:e,checkout:t},n),note:(e,t,n,r)=>i("/api/note",{root:e,path:t,note:n},r)}},32538:(e,t,n)=>{n.d(t,{I_:()=>r,Mq:()=>a,XU:()=>o,yQ:()=>i});let r=["#e11d48","#f97316","#d97706","#65a30d","#0d9488","#0284c7","#4f46e5","#7c3aed","#c026d3","#57534e"];function i(e){return r.some(t=>t===e)}function o(e){let t=r.find(t=>!e.includes(t));return t||(r[e.length%r.length]??r[0])}function a(e){if(i(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)=>{n.d(t,{Z:()=>l,k:()=>d});var r=n(95155),i=n(12115),o=n(27529),a=n(87364);let s=(0,i.createContext)(null);function l({connection:e,children:t}){let n=(0,a.Y)(e.url,t=>o.F.tables(e.url,t));return(0,r.jsx)(s.Provider,{value:{connection:e,tables:n},children:t})}function d(){let e=(0,i.useContext)(s);if(!e)throw Error("useExplorerContext must be used inside ExplorerProvider");return e}},40980:(e,t,n)=>{n.d(t,{cn:()=>o,z:()=>a});var r=n(29722),i=n(622);function o(...e){return(0,i.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)=>{n.d(t,{L:()=>i});var r=n(72914);function i(e,t){let{connectionUrl:n,...i}=t??{};(0,r.Qv)("/api/activity",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,connectionUrl:n,params:i}),keepalive:!0}).catch(()=>{})}},43262:(e,t,n)=>{n.d(t,{Ar:()=>r,US:()=>s,s5:()=>d,tT:()=>c,vI:()=>l});let r={commandPalette:"⌘⇧P",tableSearch:"⌘P",columnSearch:"⌘/",sqlEditor:"⌘E",switchConnection:"⌘⇧E",compareSchema:"⌘⇧D",migrations:"⌘⇧M",back:"⌘[",forward:"⌘]"};function i(){let e=new Set;return{register:t=>(e.add(t),()=>{e.delete(t)}),open(){for(let t of e)t()}}}let o=i(),a=i(),s=o.register,l=o.open,d=a.register,c=a.open},48861:(e,t,n)=>{n.d(t,{Q:()=>d});var r=n(73321),i=n(12115),o=n(69586),a=n(79668),s=n(88263),l=n(20185);function d(e){let t,n,d=(0,r.useRouter)(),c=(0,s.c)(e=>e.entries),u=(0,s.c)(e=>e.index),p=(t=(0,o.Z)(e=>e.connections),n=(0,a.jV)(e=>e.sets),(0,i.useCallback)((e,r)=>{let i=e=>t.find(t=>t.id===e)?.name??e,o="connectionId"in e&&e.connectionId!==r?` \xb7 ${i(e.connectionId)}`:"";switch(e.kind){case"home":return"Connections";case"connection":return i(e.connectionId);case"query":return`SQL query${o}`;case"diff":return`Compare schema${o}`;case"migrations":return`Migrations${o}`;case"migration":return`${n.find(t=>t.id===e.setId)?.name??"Migration"}${o}`;case"table":return`${e.table.name}${o}`}},[t,n]));return(0,i.useMemo)(()=>{let t=t=>{let n=c[t];if(void 0===n)return null;let r=(0,l.ZG)(n);return{href:n,route:r,label:p(r,e)}},n=t(u-1),r=t(u+1);return{back:n,forward:r,goBack:()=>{n&&d.back()},goForward:()=>{r&&d.forward()}}},[c,u,p,e,d])}},56012:(e,t,n)=>{n.d(t,{R9:()=>i,XG:()=>a,aC:()=>r,hD:()=>o,km:()=>s});let r="maintenance",i="ytdb_migrations";function o(e){return"string"==typeof e&&e.length>0&&e.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(e)}let a=2e4;function s(e){return e.startsWith("repo:")}},63307:(e,t,n)=>{n.d(t,{q:()=>r});function r(e,t){if(null!==window.localStorage.getItem(t))return;let n=window.localStorage.getItem(e);null!==n&&window.localStorage.setItem(t,n)}},69586:(e,t,n)=>{n.d(t,{Z:()=>c,w:()=>u});var r=n(1934),i=n(31692),o=n(42256),a=n(32538),s=n(40980),l=n(63307);let d="ytdb:connections";(0,l.q)("db-studio:connections",d);let c=(0,r.v)()((0,i.Zr)((e,t)=>({connections:[],add:n=>{let r=n.color??(0,a.XU)(t().connections.map(e=>(0,a.Mq)(e))),i={id:(0,s.z)(),...n,color:r};return e(e=>({connections:[...e.connections,i]})),(0,o.L)("connection.add",{connectionUrl:i.url,name:i.name}),i},update:(n,r)=>{let i=t().connections.find(e=>e.id===n);e(e=>({connections:e.connections.map(e=>e.id===n?{...e,...r}:e)})),(0,o.L)("connection.update",{connectionUrl:r.url??i?.url,name:r.name??i?.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,o.L)("connection.remove",{connectionUrl:r?.url,name:r?.name})}}),{name:d}));function u(e){return c(t=>t.connections.find(t=>t.id===e))}},72914:(e,t,n)=>{n.d(t,{Qv:()=>a,Yf:()=>o,i:()=>i});let r="ytdb:bridge";function i(){var e;return"localhost"!==(e=window.location.hostname)&&"127.0.0.1"!==e&&"[::1]"!==e&&"local.ytdb"!==e&&"local.dbstudio"!==e}function o(){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 i=n?Number(n):4371;if(!Number.isInteger(i)||i<1024||i>65535)return null;let o={origin:`http://127.0.0.1:${i}`,token:t};return window.sessionStorage.setItem(r,JSON.stringify(o)),window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`),o}();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=o();if(i()&&!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})}},79668:(e,t,n)=>{n.d(t,{Ss:()=>p,jV:()=>u,kG:()=>f,ox:()=>h});var r=n(1934),i=n(31692),o=n(42256),a=n(20642),s=n(56012),l=n(40980),d=n(69586);let c={query:"",status:"all"},u=(0,r.v)()((0,i.Zr)((e,t)=>({sets:[],history:[],ledgerSchema:s.aC,setLedgerSchema:t=>{(0,s.hD)(t)&&e({ledgerSchema:t})},listFilters:{},setListFilter:(t,n)=>e(e=>({listFilters:{...e.listFilters,[t]:{...e.listFilters[t]??c,...n}}})),repoRoots:{},setRepoRoot:(t,n)=>e(e=>{let r={...e.repoRoots},i=n?.trim();i?r[t]=i:delete r[t],(0,o.L)("migrations.folder",{set:!!i});let a={...e.repoCheckouts};return delete a[t],{repoRoots:r,repoCheckouts:a}}),repoCheckouts:{},setRepoCheckout:(t,n)=>e(e=>{let r={...e.repoCheckouts};return n?r[t]=n:delete r[t],(0,o.L)("migrations.checkout",{set:!!n}),{repoCheckouts:r}}),createSet:t=>{let n=(0,a.mj)(t);return e(e=>({sets:[...e.sets,n]})),n.id},addFiles:(n,r)=>{let i=t().sets.find(e=>e.id===n),s=(0,a.Nz)(r),l=(0,a.Ai)(i?.steps??[],s);return i&&e(e=>({sets:e.sets.map(e=>e.id===n?{...e,steps:l.steps,skipped:l.skipped,importedAt:Date.now()}:e)})),(0,o.L)("migrations.import",{name:i?.name,added:l.added,updated:l.updated,reverts:l.reverts,skipped:l.skipped.length}),l},adoptSet:t=>(e(e=>({sets:[...e.sets,t]})),(0,o.L)("migrations.import",{name:t.name,migrations:t.steps.length,source:"ledger"}),t.id),renameSet:(t,n)=>{let r=n.trim().replace(/\s+/g," ").slice(0,80);r&&e(e=>({sets:e.sets.map(e=>e.id===t?{...e,name:r}:e)}))},setNote:(t,n)=>{let r=n.trim().slice(0,s.XG)||void 0;e(e=>({sets:e.sets.map(e=>e.id===t?{...e,note:r}:e)}))},removeStep:(t,n)=>e(e=>({sets:e.sets.map(e=>e.id===t?{...e,steps:e.steps.filter(e=>e.version!==n)}:e)})),removeSet:n=>{let r=t().sets.find(e=>e.id===n);e(e=>({sets:e.sets.filter(e=>e.id!==n)})),(0,o.L)("migrations.remove",{name:r?.name})},record:t=>e(e=>({history:[{...t,id:(0,l.z)(),ranAt:Date.now()},...e.history].slice(0,300)})),clearHistory:t=>e(e=>({history:t?e.history.filter(e=>e.setId!==t):[]}))}),{name:"ytdb:migrations"}));function p(e){return u(t=>t.sets.find(t=>t.id===e)??null)}function f(e){return u(t=>t.listFilters[e]??c)}function h(e){let t=(0,d.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup??e),n=u(e=>e.repoRoots[t]??null),r=u(e=>e.repoCheckouts[t]??null);return{scope:t,root:n,checkout:r}}},87364:(e,t,n)=>{n.d(t,{Y:()=>i});var r=n(12115);function i(e,t){let[n,i]=(0,r.useState)(0),[o,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)(()=>i(e=>e+1),[]),d=o.key!==s;return{data:o.data,error:d?null:o.error,loading:d,reload:l}}},88263:(e,t,n)=>{n.d(t,{c:()=>s});var r=n(1934),i=n(31692);let o="ytdbNav";function a(e){let t=window.history.state;t&&"object"==typeof t&&t[o]===e||window.history.replaceState({...t??{},[o]:e},"")}let s=(0,r.v)()((0,i.Zr)((e,t)=>({entries:[],index:-1,traversing:!1,replaceNext:!1,markTraversal:()=>e({traversing:!0}),markReplace:()=>e({replaceNext:!0}),arrive:n=>{let r,{entries:i,index:s,traversing:l,replaceNext:d}=t(),c=function(){let e=window.history.state;if(!e||"object"!=typeof e)return;let t=e[o];return"number"==typeof t?t:void 0}();if(i[s]===n&&!d){e({traversing:!1}),a(s);return}let u=i;void 0!==c&&i[c]===n?r=c:l&&i[s-1]===n?r=s-1:l&&i[s+1]===n?r=s+1:d&&s>=0?(u=i.map((e,t)=>t===s?n:e),r=s):r=(u=[...i.slice(0,s+1),n]).length-1,e({entries:u,index:r,traversing:!1,replaceNext:!1}),a(r)}}),{name:"ytdb:navigation",storage:(0,i.KU)(()=>sessionStorage),partialize:e=>({entries:e.entries,index:e.index})}))},89239:(e,t,n)=>{n.d(t,{$:()=>l,r:()=>s});var r=n(95155),i=n(35684),o=n(18460),a=n(40980);let s=(0,o.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function l({className:e,variant:t="default",size:n="default",...o}){return(0,r.jsx)(i.$,{"data-slot":"button",className:(0,a.cn)(s({variant:t,size:n,className:e})),...o})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
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),x=n(72264),h=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:h,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",h&&"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:h,label:h?`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)(x.rI,{children:[(0,r.jsx)(x.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)(x.SQ,{align:"end",className:"min-w-56",children:[(0,r.jsx)(x._2,{disabled:d||"applied"===s,onClick:g.onApplyThrough,children:"Apply everything through here"}),(0,r.jsx)(x._2,{disabled:d||"applied"===s,onClick:g.onApplyOne,children:"Apply only this one"}),(0,r.jsx)(x._2,{disabled:d||"pending"===s||!e.revertSql,onClick:g.onRevertThrough,children:"Revert back through here"}),(0,r.jsx)(x.mB,{}),(0,r.jsxs)(x._2,{disabled:d||"applied"===s,onClick:g.onMarkApplied,children:[(0,r.jsx)(o.nXx,{}),"Mark as already applied"]}),(0,r.jsxs)(x._2,{disabled:d||"pending"===s,onClick:g.onMarkPending,children:[(0,r.jsx)(o.fJ4,{}),"Mark as not applied"]}),(0,r.jsx)(x.mB,{}),c&&(0,r.jsxs)(x._2,{onClick:g.onAttachRevert,children:[(0,r.jsx)(o.W4E,{}),e.revertSql?"Replace revert file…":"Add a revert file…"]}),(0,r.jsxs)(x._2,{onClick:()=>g.onOpenInEditor(R),children:[(0,r.jsx)(o.Uoo,{}),"Open ",k," SQL in editor"]}),(0,r.jsxs)(x._2,{onClick:()=>void I(),children:[(0,r.jsx)(o.hX7,{}),"Copy ",k," SQL"]}),c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.mB,{}),(0,r.jsx)(x._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)(x.rI,{children:[(0,r.jsxs)(x.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)(x.SQ,{align:"start",className:"min-w-52",children:e.map(e=>(0,r.jsxs)(x._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),x=i.trim()!==e.trim();async function h(e){if(e?.preventDefault(),x&&!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 h(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)&&h()}}),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:!x||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,checkout:q}=(0,k.ox)(n.id),F=(0,H.y)((0,j.km)(e)?E:null,q),O=(0,j.km)(e)?F.data?.sets.find(t=>t.id===e)??null:M,T=!!O?.source,L=(0,v.gz)(n.id),P=(0,y.En)(e=>e.setDraft),B=(0,c.$C)(),[W,er]=(0,l.useState)("migrations"),[es,ei]=(0,l.useState)([]),[ea,el]=(0,l.useState)([]),eo=(0,l.useRef)(null),[ed,ec]=(0,l.useState)(null),[eu,em]=(0,l.useState)(null),[ex,eh]=(0,l.useState)(!1),[ep,ef]=(0,l.useState)(!1),[eg,ej]=(0,l.useState)(null),[ev,eb]=(0,l.useState)(null),[ek,ey]=(0,l.useState)(!1),[eN,ew]=(0,l.useState)(!1),[eS,e$]=(0,l.useState)(!1),eC=(0,l.useRef)(null),eR=(0,l.useRef)(!1),ez=(0,l.useMemo)(()=>[n,...L],[n,L]),eA=ez.map(e=>e.url).join("|"),eM=(0,p.Y)(`ledgers:${z}:${eA}`,async e=>Object.fromEntries(await Promise.all(ez.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)}]}})))),eE=eM.data?.[n.id]??null,eq=O?.name??"",eF=(0,l.useMemo)(()=>(0,g.Gf)(eE?.ledger,eq),[eE?.ledger,eq]),eO=(0,l.useMemo)(()=>ez.map(e=>{let t=eM.data?.[e.id]??null,n=(0,g.Gf)(t?.ledger,eq);return{connection:e,ledger:n,error:t?.error??null,summary:(0,g.eh)(O,n)}}),[ez,eM.data,O,eq]),eT=(0,l.useMemo)(()=>{let e=new Set;for(let t of O?.steps??[])if(es.includes(t.version))for(let n of eO)"drifted"===(0,g.FY)(t,n.ledger)&&e.add(n.connection.id);return ez.filter(t=>e.has(t.id))},[O,es,eO,ez]),e_=(0,p.Y)(`stored:${z}:${eT.map(e=>e.url).join("|")}`,async e=>Object.fromEntries(await Promise.all(eT.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)}]}})))),eD=`/${encodeURIComponent(n.id)}/migrations`,eI=(0,k.jV)(e=>e.history),eL=(0,l.useMemo)(()=>(0,b.x)(eO.map(e=>({connection:e.connection,ledger:e.ledger})),eI).filter(e=>e.setName===eq),[eO,eI,eq]),eP=(0,g.eh)(O,eF),eB=(0,l.useMemo)(()=>(0,g.nb)(O,eF),[O,eF]),eG=(0,g.kB)(O,eF),eQ=(0,l.useCallback)(t=>{ej(u(e,t.files)),er("migrations")},[u,e]),eV=(0,Y.$)(eQ);function eY(e,t,n=!1){(0!==t.steps.length||t.blockedBy)&&(em(null),ec({...t,direction:e,recordOnly:n}))}function eK(e){return{steps:e,blockedBy:null}}async function eW(){if(!ed||!O)return;eR.current=!1,eh(!0);let e=ed.steps.map(e=>({version:e.version,name:e.name,status:"waiting"}));em(e);let t=(t,n)=>{em(e=e.map((e,r)=>r===t?{...e,...n}:e))},r=t=>{em(e=e.map((e,n)=>n>=t&&"waiting"===e.status?{...e,status:"skipped"}:e))};for(let[e,s]of ed.steps.entries()){if(eR.current){r(e);break}let i="apply"===ed.direction?s.applySql:s.revertSql;if(!i&&!ed.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:ed.direction,version:s.version,name:s.name,checksum:s.checksum,setName:O.name,sql:i??"",revertSql:"apply"===ed.direction?s.revertSql:void 0,ledgerSchema:z,recordOnly:ed.recordOnly});t(e,{status:"ok",durationMs:r.durationMs}),R({setId:O.id,setName:O.name,connectionId:n.id,connectionName:n.name,direction:ed.direction,version:s.version,name:s.name,status:"ok",recorded:ed.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:O.id,setName:O.name,connectionId:n.id,connectionName:n.name,direction:ed.direction,version:s.version,name:s.name,status:"failed",durationMs:0,error:i});break}}eh(!1),eM.reload(),e_.reload(),s.reload(),e.every(e=>"ok"===e.status)&&el([])}function eX(e){P(n.id,e),t.push(`/${encodeURIComponent(n.id)}/query`)}function eU(e){B(e)}async function eH(e){O&&(O.source?(await f.F.note(O.source.root,O.source.path,e),F.reload()):S(O.id,e))}async function eZ(e){let t=e?.[0];eb(null),t&&ev&&O&&ej(u(O.id,[{path:`revert/${ev}_${t.name}`,text:await t.text()}]))}if(!O){let t=(0,j.km)(e)&&F.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:F.error?F.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:eD,className:"text-foreground underline underline-offset-4",children:"All migrations"})]})})]})}let eJ=new Set(ea),e0=O.steps.filter(e=>eJ.has(e.version)).length,e1=e0>0,e2=e1?(0,g.DM)(O,eF,eJ):(0,g.gj)(O,eF),e3=e1?(0,g.n9)(O,eF,eJ):(0,g.e)(O,eF),e5=ex||eM.loading||F.loading;return(0,r.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",onDragOver:e=>{!T&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),ef(!0))},children:[(0,r.jsxs)(J,{name:O?.name??"",indexHref:eD,children:[O.source&&(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Read from ${O.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:O.source.path}),F.data?.git&&(0,r.jsxs)("span",{className:"shrink-0 rounded border px-1.5 font-mono text-[10px]",children:[F.data.git.branch,F.data.git.dirty&&"*"]})]}),(0,r.jsx)(D,{environments:eO,targetId:n.id,onSelect:eU}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,r.jsx)(m.$,{size:"icon-sm",variant:"ghost",disabled:eM.loading||F.loading,"aria-label":"Refresh",title:T?"Re-read the files and every environment's ledger":"Re-read every environment's ledger",onClick:function(){eM.reload(),e_.reload(),T&&F.reload()},children:(0,r.jsx)(o.oS8,{className:(0,N.cn)((eM.loading||F.loading)&&"animate-spin")})}),!T&&(0,r.jsxs)(m.$,{size:"sm",variant:"ghost",onClick:()=>ef(!0),children:[(0,r.jsx)(o.FeY,{"data-icon":"inline-start"}),"Import"]}),(0,r.jsxs)(x.rI,{children:[(0,r.jsx)(x.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)(x.SQ,{align:"end",className:"min-w-64",children:[(0,r.jsxs)(x._2,{disabled:e5||0===e2.steps.length,onClick:()=>eY("apply",eK(e2.steps),!0),children:[(0,r.jsx)(o.nXx,{}),"Mark ",e2.steps.length," as already applied"]}),(0,r.jsx)(x.mB,{}),(0,r.jsxs)(x._2,{disabled:e5||0===e3.steps.length,onClick:()=>eY("revert",e3),children:[(0,r.jsx)(o.ij9,{}),e1?`Revert ${e3.steps.length} selected on ${n.name}`:`Revert everything on ${n.name}`]}),(0,r.jsx)(x.mB,{}),(0,r.jsxs)(x._2,{onClick:()=>e$(!0),children:[(0,r.jsx)(o.UA_,{}),O.note?"Edit note":"Add note"]}),!T&&(0,r.jsxs)(x._2,{onClick:()=>ew(!0),children:[(0,r.jsx)(o.NOV,{}),"Rename"]}),(0,r.jsxs)(x._2,{onClick:()=>ey(!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]})]}),!T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.mB,{}),(0,r.jsx)(x._2,{variant:"destructive",onClick:function(){O&&($(O.id),t.push(eD))},children:"Forget this migration"})]})]})]}),(0,r.jsxs)(m.$,{size:"sm",disabled:e5||0===e2.steps.length,onClick:()=>eY("apply",e2),children:[(0,r.jsx)(o.eGB,{"data-icon":"inline-start"}),0===e2.steps.length?e1?"Nothing selected to apply":"Up to date":`Apply ${e2.steps.length}${e1?" selected":""} to ${n.name}`]})]})]}),eg&&(0,r.jsx)(et,{report:eg,onDismiss:()=>ej(null)}),eV.error&&(0,r.jsx)("p",{className:"border-b bg-destructive/5 px-4 py-1.5 text-xs text-destructive",children:eV.error}),"migrations"===W&&O.note&&(0,r.jsx)(ee,{note:O.note,notePath:O.source?.notePath??null,onEdit:()=>e$(!0)}),(0,r.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:["history"===W?(0,r.jsx)(h.F,{className:"min-h-0 flex-1",children:(0,r.jsx)(Q.H,{events:eL,connections:ez,loading:eM.loading})}):eE?.error?(0,r.jsx)("p",{className:"flex-1 px-4 py-6 font-mono text-xs text-destructive",children:eE.error}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{environments:eO,targetId:n.id,caption:e1?`${e0} 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}(eP,eM.loading),loading:eM.loading,selection:{checked:0!==e0&&(e0===O.steps.length||"mixed"),onToggle:function(){if(!O)return;let e=O.steps.map(e=>e.version);el(t=>t.some(t=>e.includes(t))?[]:e)}},onSelect:eU,onCompare:function(e){v.lz.getState().setCompareTarget(n.id,e),t.push(`/${encodeURIComponent(n.id)}/diff`)}}),(0,r.jsxs)(h.F,{className:(0,N.cn)("min-h-0 flex-1",eM.loading&&"opacity-70"),children:[(O?.steps.length??0)===0&&!T&&(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(Y.k,{onFiles:eQ,compact:!0})}),O.skipped.length>0&&T&&(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 ",O.skipped.length," file",1===O.skipped.length?"":"s"]}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5 pl-5 font-mono text-[11px]",children:O.skipped.map(e=>(0,r.jsx)("li",{children:e},e))})]}),(O?.steps??[]).map(e=>(0,r.jsx)(_,{step:e,targetId:n.id,status:(0,g.FY)(e,eF),environments:eO.map(t=>({connection:t.connection,status:(0,g.FY)(e,t.ledger),entry:(0,g.ay)(e,t.ledger),error:t.error})),isNewestApplied:eG?.version===e.version,expanded:es.includes(e.version),busy:e5,editable:!T,drift:function(e){let t=eO.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=e_.data?.[r.connection.id],i=s?.ledger?.entries.find(t=>t.setName===eq&&t.version===e.version);return{connectionName:r.connection.name,appliedSql:s?.ledger?i?.applySql??null:void 0,error:s?.error??null}}(e),selected:eJ.has(e.version),onSelect:t=>(function(e,t){if(!O)return;let n=O.steps.map(e=>e.version),r=eo.current;eo.current=e,el(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 ei(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},actions:{onApplyThrough:()=>eY("apply",(0,g.gj)(O,eF,e.version)),onApplyOne:()=>eY("apply",{steps:[e],blockedBy:null}),onRevertThrough:()=>eY("revert",(0,g.e)(O,eF,e.version)),onMarkApplied:()=>eY("apply",eK([e]),!0),onMarkPending:()=>eY("revert",eK([e]),!0),onAttachRevert:()=>{eb(e.version),window.requestAnimationFrame(()=>eC.current?.click())},onRemove:()=>O&&C(O.id,e.version),onOpenInEditor:eX}},e.version)),eB.length>0&&(0,r.jsx)(en,{entries:eB,connectionName:n.name})]})]}),ep&&!T&&(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:()=>ef(!1),onDrop:e=>{e.preventDefault(),ef(!1),eV.importFrom(e.dataTransfer)},children:(0,r.jsx)(Y.k,{onFiles:eQ,className:"w-full max-w-xl bg-background"})})]}),(0,r.jsx)(V.l,{pane:W,onPaneChange:er,historyCount:eL.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:eP,initialized:eF?.initialized??null,loading:eM.loading,foundIn:eF?.initialized?eF.schema:null,configuredSchema:z})}),(0,r.jsx)("input",{ref:eC,type:"file",accept:".sql",className:"sr-only",onChange:e=>{eZ(e.target.files),e.target.value=""}}),(0,r.jsx)(K.K,{open:eN,title:"Rename migration",initial:O.name,submitLabel:"Rename",onOpenChange:ew,onSubmit:function(e){O&&w(O.id,e)}}),eS&&(0,r.jsx)(X,{initial:O.note??"",file:O.source?O.source.notePath?.split(/[\\/]/).at(-1)??"README.md":null,onOpenChange:e$,onSave:eH}),ek&&(0,r.jsx)(G,{schema:z,found:eO.filter(e=>e.ledger?.initialized).map(e=>({name:e.connection.name,schema:e.ledger?.schema??z})),onOpenChange:ey,onSave:e=>{A(e),eM.reload()}}),ed&&(0,r.jsx)(U.I,{open:!0,direction:ed.direction,connection:n,steps:ed.steps,blockedBy:ed.blockedBy,progress:eu,running:ex,recordOnly:ed.recordOnly??!1,note:O.note,onRun:()=>void eW(),onStop:()=>{eR.current=!0},onClose:function(){ex||(ec(null),em(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(x(r)||"."===r&&x(e[n+1])){let r=n;n=function(e,t){let n=t;for("."===e[n]&&(n+=1);n<e.length&&x(e[n]);)n+=1;if("."===e[n]&&x(e[n+1]))for(n+=1;n<e.length&&x(e[n]);)n+=1;if("e"===e[n]||"E"===e[n]){let t=n+1;if(("+"===e[t]||"-"===e[t])&&(t+=1),x(e[t]))for(n=t;n<e.length&&x(e[n]);)n+=1}return n}(e,n),t.push({kind:"number",value:e.slice(r,n)});continue}if(h(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 x(e){return void 0!==e&&e>="0"&&e<="9"}function h(e){return void 0!==e&&(e>="A"&&e<="Z"||e>="a"&&e<="z"||"_"===e)}function p(e){return h(e)||x(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),x=(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===x.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 h(){e&&(await j(e),m(!0),window.setTimeout(()=>m(!1),1500))}let p=`${Math.max(String(x.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 h(),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:x.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,x;m=await i.F.tables(s.url),x=o.table,u=m.some(e=>e.schema===x.schema&&e.name===x.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()}]);
|
|
@@ -0,0 +1 @@
|
|
|
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),x=n(72264),u=n(35942),p=n(7412),g=n(87364),f=n(27529),j=n(9385),v=n(62417),N=n(74590),b=n(79668),k=n(40980),y=n(42611),w=n(20642),$=n(77649),C=n(27013),S=n(41069),z=n(42763),M=n(83504);let F=[{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,x]=(0,l.useState)(null),[u,p]=(0,l.useState)(new Set),[g,j]=(0,l.useState)([]),[v,N]=(0,l.useState)(!1),[b,y]=(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)F.find(e=>e.verdict===n.verdict)?.preselected&&t.add(R(n));p(t)}).catch(e=>{t.signal.aborted||x(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 F.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=>u.has(R(e)));async function q(n){N(!0),$(null);try{y(await f.F.adopt(e.url,{ledgerSchema:t,entries:n})),r()}catch(e){$(e instanceof Error?e.message:String(e))}finally{N(!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:b?`Marked ${b.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:b?"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,M.p)(e.url)})]})})]}),b?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:b.existing>0?`${b.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})=>u.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,k.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)(I,{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:u.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:b?(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 q(n.entries),children:v?"Marking…":`Mark all ${n.entries.length} as applied`}):(0,s.jsx)(h.$,{disabled:v||O||0===S.length,onClick:()=>void q(S),children:v?"Marking…":`Mark as applied (${S.length})`})]})})]})})}function I({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 q=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)(q.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,b.jV)(e=>e.sets),r=(0,b.jV)(e=>e.createSet),a=(0,b.jV)(e=>e.adoptSet),d=(0,b.jV)(e=>e.addFiles),p=(0,b.jV)(e=>e.removeSet),z=(0,b.jV)(e=>e.ledgerSchema),M=(0,b.jV)(e=>e.history),F=(0,N.gz)(t.id),[R,I]=(0,l.useState)("migrations"),[q,O]=(0,l.useState)(null),[V,Q]=(0,l.useState)(null),[U,W]=(0,l.useState)(!1),[D,H]=(0,l.useState)(!1),[T,G]=(0,l.useState)(null),K=(0,l.useMemo)(()=>[t,...F],[t,F]),J=K.map(e=>e.url).join("|"),{scope:X,root:Z,checkout:ee}=(0,b.ox)(t.id),et=(0,b.jV)(e=>e.setRepoRoot),en=(0,b.jV)(e=>e.setRepoCheckout),es=(0,b.kG)(X),er=(0,b.jV)(e=>e.setListFilter),ea=(0,L.y)(Z,ee),ei=(0,l.useMemo)(()=>[...ea.data?.sets??[]].sort((e,t)=>t.importedAt-e.importedAt),[ea.data]),el=(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)}]}})))),eo=(0,l.useMemo)(()=>(0,j.x)(K.map(e=>({connection:e,ledger:el.data?.[e.id]?.ledger??null})),M),[K,el.data,M]),ed=`/${encodeURIComponent(t.id)}/migrations`,ec=(0,l.useCallback)(t=>{let n=r(t.name);d(n,t.files),e.push(`${ed}/${encodeURIComponent(n)}`)},[r,d,e,ed]);async function em(t){O(t),Q(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 Q(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 Q(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&&Q(`Rebuilt ${l.steps.length} of ${l.steps.length+o.length}. No SQL was stored for ${o.join(", ")}.`),e.push(`${ed}/${encodeURIComponent(l.id)}`)}catch(e){Q(e instanceof Error?e.message:String(e))}finally{O(null)}}let eh=(0,l.useMemo)(()=>[...n].sort((e,t)=>t.importedAt-e.importedAt),[n]),ex=(0,l.useMemo)(()=>(0,v.lF)(K.map(e=>({connection:e,ledger:el.data?.[e.id]?.ledger??null})),[...ei,...n].map(e=>e.name)),[K,el.data,ei,n]),eu=(0,l.useMemo)(()=>{let e=el.data?.[t.id]?.ledger??null,n=[],s=0;if(!e)return{sets:0,entries:n};for(let t of ei){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}},[el.data,t.id,ei]),ep=el.loading||ea.loading,eg=0===ei.length&&0===n.length&&0===ex.length,ef=(0,l.useCallback)(e=>K.map(t=>({connection:t,summary:(0,v.eh)(e,el.data?.[t.id]?.ledger??null),read:!!el.data?.[t.id]?.ledger,error:el.data?.[t.id]?.error??null})),[K,el.data]),ej=(0,l.useCallback)(e=>(0,v.yy)(e,ef(e).map(e=>({connectionId:e.connection.id,summary:e.summary,read:e.read})),es),[ef,es]),ev=(0,l.useMemo)(()=>ei.filter(ej),[ei,ej]),eN=(0,l.useMemo)(()=>eh.filter(ej),[eh,ej]),eb=""!==es.query.trim()||"all"!==es.status,ek=ei.length+eh.length-ev.length-eN.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)(P,{root:ea.data?.root??Z,git:ea.data?.git??null,checkouts:ea.data?.checkouts??[],checkout:ea.data?.checkout??null,onEdit:()=>H(!0),onPick:e=>en(X,e)}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,s.jsx)(h.$,{size:"icon-sm",variant:"ghost",disabled:ep,"aria-label":"Refresh",title:Z?"Re-read the folder and every environment's ledger":"Re-read every environment's ledger",onClick:function(){el.reload(),ea.reload()},children:(0,s.jsx)(o.oS8,{className:(0,k.cn)(ep&&"animate-spin")})}),!Z&&(0,s.jsxs)(h.$,{size:"sm",variant:"ghost",onClick:()=>H(!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)(x.rI,{children:[(0,s.jsx)(x.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)(x.SQ,{align:"end",className:"min-w-72",children:[Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(x._2,{disabled:ep||0===eu.entries.length,onClick:()=>G(eu),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:eu.entries.length})]}),(0,s.jsx)(x.mB,{}),(0,s.jsxs)(x._2,{onClick:()=>H(!0),children:[(0,s.jsx)(o.WzY,{}),"Change folder…"]})]}),n.length>0&&(0,s.jsxs)(s.Fragment,{children:[Z&&(0,s.jsx)(x.mB,{}),(0,s.jsxs)(x._2,{variant:"destructive",onClick:function(){for(let e of n)p(e.id)},children:["Forget ",n.length," imported migration",1===n.length?"":"s"]})]})]})]})]})]}),ea.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:ea.error}),(0,s.jsx)(h.$,{size:"xs",variant:"ghost",onClick:()=>H(!0),children:"Change folder"})]}),"history"===R?(0,s.jsx)(u.F,{className:"min-h-0 flex-1",children:(0,s.jsx)(y.H,{events:eo,connections:K,loading:el.loading})}):eg&&Z&&ea.loading?(0,s.jsxs)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:["Reading ",Z,"…"]}):eg&&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."})]}):eg?(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:ec,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:()=>H(!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)(_,{filter:es,environments:K,hidden:ek,onChange:e=>er(X,e)}),(0,s.jsxs)(u.F,{className:"min-h-0 flex-1",children:[ev.map(e=>(0,s.jsx)(Y,{set:e,href:`${ed}/${encodeURIComponent(e.id)}`,environments:ef(e)},e.id)),eN.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"}),eN.map(e=>(0,s.jsx)(Y,{set:e,href:`${ed}/${encodeURIComponent(e.id)}`,environments:ef(e)},e.id)),eb&&0===ev.length&&0===eN.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:()=>er(X,{query:"",status:"all"}),children:"Clear the filter"})]}),ex.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"}),ex.map(e=>(0,s.jsx)(B,{migration:e,busy:q===e.name,onOpen:()=>void em(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:ec,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 ")}(ei.length,n.length,ex.length,null!==Z&&ea.loading),pane:R,onPaneChange:I,historyCount:eo.length}),D&&(0,s.jsx)(A,{root:Z,environmentNames:K.map(e=>e.name),onOpenChange:H,onSave:e=>et(X,e)}),T&&(0,s.jsx)(E,{connection:t,ledgerSchema:z,plan:T,onDone:()=>el.reload(),onOpenChange:e=>!e&&G(null)}),(0,s.jsx)(C.K,{open:U,title:"New migration",submitLabel:"Create",onOpenChange:W,onSubmit:function(t){let n=r(t);e.push(`${ed}/${encodeURIComponent(n)}`)}})]})}let Q={all:"All",pending:"Not fully applied",untouched:"Not started anywhere",complete:"Applied everywhere"};function _({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)(x.rI,{children:[(0,s.jsxs)(x.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}`:Q.pending}return Q[e]}(e.status,t),(0,s.jsx)(o.RQe,{"data-icon":"inline-end"})]}),(0,s.jsx)(x.SQ,{align:"end",className:"min-w-56",children:(0,s.jsxs)(x.Hr,{value:e.status,onValueChange:e=>r({status:e}),children:[Object.keys(Q).map(e=>(0,s.jsx)(x.Ht,{value:e,children:Q[e]},e)),t.length>1&&(0,s.jsx)(x.mB,{}),t.length>1&&t.map(e=>(0,s.jsxs)(x.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 P({root:e,git:t,checkouts:n,checkout:r,onEdit:a,onPick:i}){var l;let d,c="cursor-pointer rounded-md outline-none hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",m=t&&(0,s.jsxs)("span",{className:"shrink-0 rounded border px-1.5 font-mono text-[10px]",children:[t.branch,t.dirty&&"*"]});return(0,s.jsxs)("div",{className:"flex min-w-0 items-center text-xs text-muted-foreground",children:[(0,s.jsxs)("button",{type:"button",title:`Reading from ${e}. Click to change.`,onClick:a,className:(0,k.cn)("flex min-w-0 items-center gap-1.5 px-1.5 py-0.5",c),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:(d=(l=e).split(/[\/]/).filter(Boolean)).length>2?`…/${d.slice(-2).join("/")}`:l})]}),t&&n.length>1?(0,s.jsxs)(x.rI,{children:[(0,s.jsxs)(x.ty,{title:`${t.branch} (${t.commit}${t.dirty?", uncommitted changes":""}). Read from another worktree.`,className:(0,k.cn)("flex shrink-0 items-center gap-0.5 px-1 py-0.5",c),children:[m,(0,s.jsx)(o.klM,{className:"size-3"})]}),(0,s.jsx)(x.SQ,{align:"start",className:"min-w-56",children:(0,s.jsx)(x.Hr,{value:r??"",onValueChange:e=>i(e),children:n.map(e=>(0,s.jsx)(x.Ht,{value:e.path,title:e.path,children:(0,s.jsx)("span",{className:"font-mono text-xs",children:e.branch})},e.path))})})]}):t&&(0,s.jsx)("span",{className:"px-1",title:`${t.branch} (${t.commit}${t.dirty?", uncommitted changes":""})`,children:m})]})}function Y({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,k.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()}]);
|
|
@@ -0,0 +1 @@
|
|
|
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,n)=>o("/api/repo",{root:e,checkout:t},n),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()}]);
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6090],{25:(e,t,n)=>{n.d(t,{Ol:()=>l,TA:()=>d,qb:()=>c});let r=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,i=new Set(["begin","start"]),o=new Set(["commit","end"]),a=new Set(["rollback"]);function s(e){return void 0!==e&&(e>="A"&&e<="Z"||e>="a"&&e<="z"||"_"===e)||void 0!==e&&e>="0"&&e<="9"}function l(e){if(r.test(e))return{mode:"unwrapped",sql:e,atomic:!1};let t=function(e){let t=[],n=0,r=0,i=r=>{let i=function(e,t){let n=t;for(;n<e.length;){let t=e[n];if(" "===t||" "===t||"\n"===t||"\r"===t){n+=1;continue}if("-"===t&&"-"===e[n+1]){for(;n<e.length&&"\n"!==e[n];)n+=1;continue}if("/"===t&&"*"===e[n+1]){let t=e.indexOf("*/",n+2);n=-1===t?e.length:t+2;continue}break}return n}(e,n);if(i>=r)return;let o=i;for(;o<e.length&&s(e[o]);)o+=1;t.push({at:i,end:r,keyword:e.slice(i,o).toLowerCase()})};for(;r<e.length;){let t=e[r];if("-"===t&&"-"===e[r+1]){for(;r<e.length&&"\n"!==e[r];)r+=1;continue}if("/"===t&&"*"===e[r+1]){let t=e.indexOf("*/",r+2);r=-1===t?e.length:t+2;continue}if("'"===t||'"'===t){r=function(e,t,n){let r=t+1;for(;r<e.length;){if(e[r]===n){if(e[r+1]===n){r+=2;continue}return r+1}r+=1}return r}(e,r,t);continue}if("$"===t){let t=function(e,t){if("$"!==e[t])return null;let n=t+1;for(;n<e.length&&s(e[n]);)n+=1;return"$"!==e[n]?null:e.slice(t,n+1)}(e,r);if(t){let n=e.indexOf(t,r+t.length);r=-1===n?e.length:n+t.length;continue}}if(";"===t){i(r+1),r+=1,n=r;continue}r+=1}return i(e.length),t}(e),n=t.filter(e=>i.has(e.keyword)||o.has(e.keyword)||a.has(e.keyword));if(0===n.length)return{mode:"wrapped-by-ytdb",sql:e,atomic:!0};let l=t[0],d=t[t.length-1];return 2===n.length&&n[0]===l&&n[1]===d&&i.has(l.keyword)&&o.has(d.keyword)?{mode:"self-wrapped",sql:e.slice(0,l.at)+e.slice(l.end,d.at)+e.slice(d.end),atomic:!0}:{mode:"self-managed",sql:e,atomic:!1}}function d(e){switch(e){case"unwrapped":return"Marked `-- ytdb:no-transaction`, so it runs with no transaction. A failure partway leaves the statements before it applied.";case"self-managed":return"This file commits more than once, so YTDB runs it as written and records it afterwards. A failure partway can leave it half applied and unrecorded.";default:return null}}function c(e){return"unwrapped"===e?"no transaction":"self-managed"===e?"self-managed":null}},20185:(e,t,n)=>{function r(e){let t=e.split("/").filter(Boolean).map(decodeURIComponent);if(0===t.length)return{kind:"home"};let[n,r,i]=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:i}:{kind:"table",connectionId:n,table:{schema:r,name:i}}:{kind:"connection",connectionId:n}}function i(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 o(e,t,{tableExists:n=!0}={}){let a=r(e);return"home"!==a.kind&&("table"!==a.kind||n)?i({...a,connectionId:t}):i({kind:"connection",connectionId:t})}n.d(t,{Jn:()=>i,ZG:()=>r,gZ:()=>o})},20642:(e,t,n)=>{n.d(t,{Ai:()=>g,Nz:()=>h,Zy:()=>p,mj:()=>m,wQ:()=>y});var r=n(40980),i=n(25);let o=new Set(["apply","up","forward"]),a=new Set(["revert","down","rollback","undo"]),s=[".up",".apply",".forward","_up","_apply","-up","-apply"],l=[".down",".revert",".rollback",".undo","_down","_revert","_rollback","_undo","-down","-revert","-rollback","-undo"];function d(e){return e.split("/").filter(e=>e.length>0)}function c(e){let t=/^[Vv](\d+(?:[._]\d+)*)__(.*)$/.exec(e);if(t)return{version:t[1].replace(/_/g,"."),name:u(t[2])};let n=/^(\d+(?:[-.]\d+)*)(?:[-_.\s]+(.*))?$/.exec(e);return n?{version:n[1],name:u(n[2]??"")}:{version:e,name:u(e)}}function u(e){return e.replace(/[-_]+/g," ").trim()}function p(e,t){let n=/(\d+)|(\D+)/g,r=e.match(n)??[],i=t.match(n)??[],o=Math.min(r.length,i.length);for(let e=0;e<o;e+=1){let t=r[e],n=i[e],o=/^\d+$/.test(t)&&/^\d+$/.test(n)?Number(t)-Number(n):t.localeCompare(n);if(0!==o)return o}return r.length-i.length}function f(e){let t=e.replace(/\r\n/g,"\n").trim(),n=0x811c9dc5,r=0x1000193;for(let e=0;e<t.length;e+=1){let i=t.charCodeAt(e);n=Math.imul(n^i,0x1000193)>>>0,r=Math.imul(r+i,0x85ebca6b)>>>0}return`${n.toString(16).padStart(8,"0")}${r.toString(16).padStart(8,"0")}`}function h(e){let t={applies:new Map,reverts:new Map,skipped:[],errors:[]},n=e.filter(e=>{var t;let n=d(t=e.path).at(-1)??t;return!n.startsWith(".")&&/\.sql$/i.test(n)});if(0===n.length)return t.errors.push("No .sql files in there."),t;let r=n.reduce((e,t)=>e+t.text.length,0);if(r>4e6)return t.errors.push(`That is ${b(r)} of SQL, over the ${b(4e6)} limit.`),t;let i=[];for(let e of n){if(e.text.length>5e5){t.skipped.push(`${e.path} — over ${b(5e5)}`);continue}if(e.text.includes("\0")){t.skipped.push(`${e.path} — not text`);continue}if(!e.text.trim()){t.skipped.push(`${e.path} — empty`);continue}i.push({file:e,...function(e){let t=d(e),n=(t.at(-1)??e).replace(/\.sql$/i,"");for(let e of t.slice(0,-1)){let t=e.toLowerCase();if(a.has(t))return{direction:"revert",stem:n};if(o.has(t))return{direction:"apply",stem:n}}let r=n.toLowerCase();for(let e of l)if(r.endsWith(e))return{direction:"revert",stem:n.slice(0,-e.length)};for(let e of s)if(r.endsWith(e))return{direction:"apply",stem:n.slice(0,-e.length)};return{direction:"apply",stem:n}}(e.path)})}let p=new Set,f=!1;for(let{direction:e,stem:t}of i){if("apply"!==e)continue;let{version:n}=c(t);p.has(n)&&(f=!0),p.add(n)}for(let{file:e,direction:n,stem:r}of i){let{version:i,name:o}=f?{version:r,name:u(r)}:c(r),a=("apply"===n?t.applies:t.reverts).get(i);if(a){t.skipped.push(`${e.path} — ${a.path} is already version ${i}`);continue}"apply"===n?t.applies.set(i,{path:e.path,sql:e.text,name:o}):t.reverts.set(i,{path:e.path,sql:e.text})}return 0===t.applies.size&&0===t.reverts.size&&t.errors.push("None of those .sql files could be read as a migration."),t}function g(e,t){let n=new Map(e.map(e=>[e.version,{...e}])),r=[...t.skipped],o=0,a=0,s=0;for(let[e,s]of t.applies){let t=n.get(e);if(t){t.applySql!==s.sql&&(a+=1),t.name=s.name||t.name,t.applyPath=s.path,t.applySql=s.sql,t.checksum=f(s.sql),t.transaction=(0,i.Ol)(s.sql).mode;continue}if(n.size>=500){r.push(`${s.path} — over 500 migrations`);continue}n.set(e,{version:e,name:s.name||e,applyPath:s.path,applySql:s.sql,checksum:f(s.sql),transaction:(0,i.Ol)(s.sql).mode}),o+=1}for(let[e,i]of t.reverts){let t=n.get(e);if(!t){r.push(`${i.path} — no migration ${e} to revert`);continue}t.revertPath=i.path,t.revertSql=i.sql,s+=1}return{steps:[...n.values()].sort((e,t)=>p(e.version,t.version)),added:o,updated:a,reverts:s,skipped:r}}function m(e){return{id:(0,r.z)(),name:v(e),importedAt:Date.now(),steps:[],skipped:[]}}function v(e){return e.trim().replace(/\s+/g," ").slice(0,80)||"Migrations"}function b(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function y(e,t){let n=[],o=[];for(let e of[...t].sort((e,t)=>p(e.version,t.version))){if(!e.applySql){n.push(e.version);continue}o.push({version:e.version,name:e.name||e.version,applyPath:`${e.version} (from the ledger)`,applySql:e.applySql,checksum:f(e.applySql),revertPath:e.revertSql?`${e.version} revert (from the ledger)`:void 0,revertSql:e.revertSql,transaction:(0,i.Ol)(e.applySql).mode})}return{set:{id:(0,r.z)(),name:v(e),importedAt:Date.now(),steps:o,skipped:[]},missing:n}}},27529:(e,t,n)=>{n.d(t,{F:()=>o});var r=n(72914);async function i(e,t,n){let i,o=await (0,r.Qv)(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n}),a=await o.text();if(!a)throw Error(`YTDB bridge returned an empty response (HTTP ${o.status}). Restart YTDB to update the local bridge.`);try{i=JSON.parse(a)}catch{if(404===o.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 ${o.status}).`)}if(!o.ok)throw Error((i&&"object"==typeof i&&"error"in i&&"string"==typeof i.error?i.error:o.statusText)||`YTDB bridge request failed with HTTP ${o.status}.`);return i}let o={tables:(e,t)=>i("/api/tables",{connectionUrl:e},t),rows:(e,t,n)=>i("/api/rows",{connectionUrl:e,query:t},n),query:(e,t,n)=>i("/api/query",{connectionUrl:e,sql:t},n),updateCell:(e,t,n)=>i("/api/cell",{connectionUrl:e,update:t},n),insertRow:(e,t,n)=>i("/api/insert-row",{connectionUrl:e,insertion:t},n),updateRow:(e,t,n)=>i("/api/update-row",{connectionUrl:e,update:t},n),deleteRows:(e,t,n)=>i("/api/delete-rows",{connectionUrl:e,deletion:t},n),related:(e,t,n)=>i("/api/related",{connectionUrl:e,lookups:t},n),lookup:(e,t,n)=>i("/api/lookup",{connectionUrl:e,query:t},n),definition:(e,t,n)=>i("/api/definition",{connectionUrl:e,table:t},n),schema:(e,t)=>i("/api/schema",{connectionUrl:e},t),ledger:(e,t,n,r=!1)=>i("/api/ledger",{connectionUrl:e,ledgerSchema:t,withSql:r},n),migrate:(e,t,n)=>i("/api/migrate",{connectionUrl:e,migration:t},n),adopt:(e,t,n)=>i("/api/adopt",{connectionUrl:e,adopt:t},n),detect:(e,t,n)=>i("/api/detect",{connectionUrl:e,migrations:t},n),repo:(e,t)=>i("/api/repo",{root:e},t),note:(e,t,n,r)=>i("/api/note",{root:e,path:t,note:n},r)}},32538:(e,t,n)=>{n.d(t,{I_:()=>r,Mq:()=>a,XU:()=>o,yQ:()=>i});let r=["#e11d48","#f97316","#d97706","#65a30d","#0d9488","#0284c7","#4f46e5","#7c3aed","#c026d3","#57534e"];function i(e){return r.some(t=>t===e)}function o(e){let t=r.find(t=>!e.includes(t));return t||(r[e.length%r.length]??r[0])}function a(e){if(i(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)=>{n.d(t,{Z:()=>l,k:()=>d});var r=n(95155),i=n(12115),o=n(27529),a=n(87364);let s=(0,i.createContext)(null);function l({connection:e,children:t}){let n=(0,a.Y)(e.url,t=>o.F.tables(e.url,t));return(0,r.jsx)(s.Provider,{value:{connection:e,tables:n},children:t})}function d(){let e=(0,i.useContext)(s);if(!e)throw Error("useExplorerContext must be used inside ExplorerProvider");return e}},40980:(e,t,n)=>{n.d(t,{cn:()=>o,z:()=>a});var r=n(29722),i=n(622);function o(...e){return(0,i.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)=>{n.d(t,{L:()=>i});var r=n(72914);function i(e,t){let{connectionUrl:n,...i}=t??{};(0,r.Qv)("/api/activity",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,connectionUrl:n,params:i}),keepalive:!0}).catch(()=>{})}},43262:(e,t,n)=>{n.d(t,{Ar:()=>r,US:()=>s,s5:()=>d,tT:()=>c,vI:()=>l});let r={commandPalette:"⌘⇧P",tableSearch:"⌘P",columnSearch:"⌘/",sqlEditor:"⌘E",switchConnection:"⌘⇧E",compareSchema:"⌘⇧D",migrations:"⌘⇧M",back:"⌘[",forward:"⌘]"};function i(){let e=new Set;return{register:t=>(e.add(t),()=>{e.delete(t)}),open(){for(let t of e)t()}}}let o=i(),a=i(),s=o.register,l=o.open,d=a.register,c=a.open},48861:(e,t,n)=>{n.d(t,{Q:()=>d});var r=n(73321),i=n(12115),o=n(69586),a=n(79668),s=n(88263),l=n(20185);function d(e){let t,n,d=(0,r.useRouter)(),c=(0,s.c)(e=>e.entries),u=(0,s.c)(e=>e.index),p=(t=(0,o.Z)(e=>e.connections),n=(0,a.jV)(e=>e.sets),(0,i.useCallback)((e,r)=>{let i=e=>t.find(t=>t.id===e)?.name??e,o="connectionId"in e&&e.connectionId!==r?` \xb7 ${i(e.connectionId)}`:"";switch(e.kind){case"home":return"Connections";case"connection":return i(e.connectionId);case"query":return`SQL query${o}`;case"diff":return`Compare schema${o}`;case"migrations":return`Migrations${o}`;case"migration":return`${n.find(t=>t.id===e.setId)?.name??"Migration"}${o}`;case"table":return`${e.table.name}${o}`}},[t,n]));return(0,i.useMemo)(()=>{let t=t=>{let n=c[t];if(void 0===n)return null;let r=(0,l.ZG)(n);return{href:n,route:r,label:p(r,e)}},n=t(u-1),r=t(u+1);return{back:n,forward:r,goBack:()=>{n&&d.back()},goForward:()=>{r&&d.forward()}}},[c,u,p,e,d])}},56012:(e,t,n)=>{n.d(t,{R9:()=>i,XG:()=>a,aC:()=>r,hD:()=>o,km:()=>s});let r="maintenance",i="ytdb_migrations";function o(e){return"string"==typeof e&&e.length>0&&e.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(e)}let a=2e4;function s(e){return e.startsWith("repo:")}},63307:(e,t,n)=>{n.d(t,{q:()=>r});function r(e,t){if(null!==window.localStorage.getItem(t))return;let n=window.localStorage.getItem(e);null!==n&&window.localStorage.setItem(t,n)}},69586:(e,t,n)=>{n.d(t,{Z:()=>c,w:()=>u});var r=n(1934),i=n(31692),o=n(42256),a=n(32538),s=n(40980),l=n(63307);let d="ytdb:connections";(0,l.q)("db-studio:connections",d);let c=(0,r.v)()((0,i.Zr)((e,t)=>({connections:[],add:n=>{let r=n.color??(0,a.XU)(t().connections.map(e=>(0,a.Mq)(e))),i={id:(0,s.z)(),...n,color:r};return e(e=>({connections:[...e.connections,i]})),(0,o.L)("connection.add",{connectionUrl:i.url,name:i.name}),i},update:(n,r)=>{let i=t().connections.find(e=>e.id===n);e(e=>({connections:e.connections.map(e=>e.id===n?{...e,...r}:e)})),(0,o.L)("connection.update",{connectionUrl:r.url??i?.url,name:r.name??i?.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,o.L)("connection.remove",{connectionUrl:r?.url,name:r?.name})}}),{name:d}));function u(e){return c(t=>t.connections.find(t=>t.id===e))}},72914:(e,t,n)=>{n.d(t,{Qv:()=>a,Yf:()=>o,i:()=>i});let r="ytdb:bridge";function i(){var e;return"localhost"!==(e=window.location.hostname)&&"127.0.0.1"!==e&&"[::1]"!==e&&"local.ytdb"!==e&&"local.dbstudio"!==e}function o(){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 i=n?Number(n):4371;if(!Number.isInteger(i)||i<1024||i>65535)return null;let o={origin:`http://127.0.0.1:${i}`,token:t};return window.sessionStorage.setItem(r,JSON.stringify(o)),window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`),o}();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=o();if(i()&&!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})}},79668:(e,t,n)=>{n.d(t,{Ss:()=>p,jV:()=>u,kG:()=>f,ox:()=>h});var r=n(1934),i=n(31692),o=n(42256),a=n(20642),s=n(56012),l=n(40980),d=n(69586);let c={query:"",status:"all"},u=(0,r.v)()((0,i.Zr)((e,t)=>({sets:[],history:[],ledgerSchema:s.aC,setLedgerSchema:t=>{(0,s.hD)(t)&&e({ledgerSchema:t})},listFilters:{},setListFilter:(t,n)=>e(e=>({listFilters:{...e.listFilters,[t]:{...e.listFilters[t]??c,...n}}})),repoRoots:{},setRepoRoot:(t,n)=>e(e=>{let r={...e.repoRoots},i=n?.trim();return i?r[t]=i:delete r[t],(0,o.L)("migrations.folder",{set:!!i}),{repoRoots:r}}),createSet:t=>{let n=(0,a.mj)(t);return e(e=>({sets:[...e.sets,n]})),n.id},addFiles:(n,r)=>{let i=t().sets.find(e=>e.id===n),s=(0,a.Nz)(r),l=(0,a.Ai)(i?.steps??[],s);return i&&e(e=>({sets:e.sets.map(e=>e.id===n?{...e,steps:l.steps,skipped:l.skipped,importedAt:Date.now()}:e)})),(0,o.L)("migrations.import",{name:i?.name,added:l.added,updated:l.updated,reverts:l.reverts,skipped:l.skipped.length}),l},adoptSet:t=>(e(e=>({sets:[...e.sets,t]})),(0,o.L)("migrations.import",{name:t.name,migrations:t.steps.length,source:"ledger"}),t.id),renameSet:(t,n)=>{let r=n.trim().replace(/\s+/g," ").slice(0,80);r&&e(e=>({sets:e.sets.map(e=>e.id===t?{...e,name:r}:e)}))},setNote:(t,n)=>{let r=n.trim().slice(0,s.XG)||void 0;e(e=>({sets:e.sets.map(e=>e.id===t?{...e,note:r}:e)}))},removeStep:(t,n)=>e(e=>({sets:e.sets.map(e=>e.id===t?{...e,steps:e.steps.filter(e=>e.version!==n)}:e)})),removeSet:n=>{let r=t().sets.find(e=>e.id===n);e(e=>({sets:e.sets.filter(e=>e.id!==n)})),(0,o.L)("migrations.remove",{name:r?.name})},record:t=>e(e=>({history:[{...t,id:(0,l.z)(),ranAt:Date.now()},...e.history].slice(0,300)})),clearHistory:t=>e(e=>({history:t?e.history.filter(e=>e.setId!==t):[]}))}),{name:"ytdb:migrations"}));function p(e){return u(t=>t.sets.find(t=>t.id===e)??null)}function f(e){return u(t=>t.listFilters[e]??c)}function h(e){let t=(0,d.Z)(t=>t.connections.find(t=>t.id===e)?.layoutGroup??e),n=u(e=>e.repoRoots[t]??null);return{scope:t,root:n}}},87364:(e,t,n)=>{n.d(t,{Y:()=>i});var r=n(12115);function i(e,t){let[n,i]=(0,r.useState)(0),[o,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)(()=>i(e=>e+1),[]),d=o.key!==s;return{data:o.data,error:d?null:o.error,loading:d,reload:l}}},88263:(e,t,n)=>{n.d(t,{c:()=>s});var r=n(1934),i=n(31692);let o="ytdbNav";function a(e){let t=window.history.state;t&&"object"==typeof t&&t[o]===e||window.history.replaceState({...t??{},[o]:e},"")}let s=(0,r.v)()((0,i.Zr)((e,t)=>({entries:[],index:-1,traversing:!1,replaceNext:!1,markTraversal:()=>e({traversing:!0}),markReplace:()=>e({replaceNext:!0}),arrive:n=>{let r,{entries:i,index:s,traversing:l,replaceNext:d}=t(),c=function(){let e=window.history.state;if(!e||"object"!=typeof e)return;let t=e[o];return"number"==typeof t?t:void 0}();if(i[s]===n&&!d){e({traversing:!1}),a(s);return}let u=i;void 0!==c&&i[c]===n?r=c:l&&i[s-1]===n?r=s-1:l&&i[s+1]===n?r=s+1:d&&s>=0?(u=i.map((e,t)=>t===s?n:e),r=s):r=(u=[...i.slice(0,s+1),n]).length-1,e({entries:u,index:r,traversing:!1,replaceNext:!1}),a(r)}}),{name:"ytdb:navigation",storage:(0,i.KU)(()=>sessionStorage),partialize:e=>({entries:e.entries,index:e.index})}))},89239:(e,t,n)=>{n.d(t,{$:()=>l,r:()=>s});var r=n(95155),i=n(35684),o=n(18460),a=n(40980);let s=(0,o.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function l({className:e,variant:t="default",size:n="default",...o}){return(0,r.jsx)(i.$,{"data-slot":"button",className:(0,a.cn)(s({variant:t,size:n,className:e})),...o})}}}]);
|