bun-query-builder 0.2.58 → 0.2.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{Aa as l6,D as V6,E as W6,F as D6,G as L6,H as M6,I as w6,J as P6,K as N6,L as O6,M as T6,N as x6,O as B6,P as E6,Q as b6,R as I6,S as A6,T as R6,X as C6,Y as k6,ea as l,fa as r,ga as a,ka as h6,la as v6,ma as y6,n as K6,na as S6,oa as g6,pa as _6,qa as f6,ra as m6,sa as s,ta as t,ua as d6,va as u6,wa as i6,xa as c6,ya as n6,za as p6}from"../chunk-
|
|
3
|
+
import{Aa as l6,D as V6,E as W6,F as D6,G as L6,H as M6,I as w6,J as P6,K as N6,L as O6,M as T6,N as x6,O as B6,P as E6,Q as b6,R as I6,S as A6,T as R6,X as C6,Y as k6,ea as l,fa as r,ga as a,ka as h6,la as v6,ma as y6,n as K6,na as S6,oa as g6,pa as _6,qa as f6,ra as m6,sa as s,ta as t,ua as d6,va as u6,wa as i6,xa as c6,ya as n6,za as p6}from"../chunk-4q37wh0k.js";import"../chunk-asdkg5va.js";import"../chunk-j9778t8e.js";import{sc as K}from"../chunk-739qq8wk.js";import{existsSync as r6}from"fs";import S from"fs/promises";import e from"os";import g from"path";import T from"process";import{EventEmitter as a6}from"events";import N from"process";import z6 from"process";import d from"process";import k from"process";import E from"process";import Z6 from"tty";import S4,{stdin as Dz,stdout as Lz}from"process";import Q6,{stdin as f4,stdout as m4}from"process";import d4 from"readline";class j6{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let z=e.homedir(),q=g.join(z,".config","clapp");this.configPath=g.join(q,"telemetry.json")}async isEnabled(){if(T.env.DO_NOT_TRACK==="1"||T.env.DO_NOT_TRACK==="true")return!1;if(T.env.NO_TELEMETRY==="1"||T.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let z=await this.loadConfig();if(z.enabled=!0,!z.userId)z.userId=this.generateUserId();await this.saveConfig(z)}async disable(){let z=await this.loadConfig();z.enabled=!1,await this.saveConfig(z)}async track(z,q){if(!await this.isEnabled())return;let Z={event:z,...q,timestamp:Date.now(),platform:e.platform(),nodeVersion:T.version};if(this.events.push(Z),this.events.length>=10)await this.send()}async trackCommand(z,q){await this.track("command",{command:z,duration:q})}async trackError(z,q){await this.track("error",{error:z,command:q})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let q=await this.loadConfig();return q.lastSent=Date.now(),await this.saveConfig(q),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let q=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(q),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(z){return new Promise((q)=>setTimeout(q,z))}async status(){let z=await this.loadConfig();return{enabled:z.enabled,doNotTrack:T.env.DO_NOT_TRACK==="1"||T.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:z.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(r6(this.configPath)){let z=await S.readFile(this.configPath,"utf-8");return this.config=JSON.parse(z),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(z){this.config=z;try{let q=g.dirname(this.configPath);await S.mkdir(q,{recursive:!0}),await S.writeFile(this.configPath,JSON.stringify(z,null,2),"utf-8")}catch{}}generateUserId(){let z=Math.random().toString(36).substring(2,15),q=Date.now().toString(36);return`${z}-${q}`}}var $z=new j6;function m(z){return z.replace(/[<[].+/,"").trim()}function s6(z){let q=/<([^>]+)>/g,J=/\[([^\]]+)\]/g,Z=[],$=(X)=>{let Q=!1,j=X[1];if(j.startsWith("..."))j=j.slice(3),Q=!0;return{required:X[0].startsWith("<"),value:j,variadic:Q}},Y;while(Y=q.exec(z))Z.push($(Y));let F;while(F=J.exec(z))Z.push($(F));return Z}function t6(z){let q={alias:{},boolean:[]};for(let[J,Z]of z.entries()){if(Z.names.length>1)q.alias[Z.names[0]]=Z.names.slice(1);if(Z.isBoolean)if(Z.negated){if(!z.some((Y,F)=>{return F!==J&&Y.names.some((X)=>Z.names.includes(X))&&typeof Y.required==="boolean"}))q.boolean.push(Z.names[0])}else q.boolean.push(Z.names[0])}return q}function q6(z){return z.reduce((q,J)=>q.length>=J.length?q:J,"")}function _(z,q){return z.length>=q?z:`${z}${" ".repeat(q-z.length)}`}function C(z){return z.replace(/([a-z])-([a-z])/g,(q,J,Z)=>{return J+Z.toUpperCase()})}function o6(z,q,J){let Z=0,$=q.length,Y=z,F;for(;Z<$;++Z)F=Y[q[Z]],Y=Y[q[Z]]=Z===$-1?J:F!=null?F:!!~q[Z+1].indexOf(".")||!(+q[Z+1]>-1)?{}:[]}function e6(z,q){for(let J of Object.keys(q)){let Z=q[J];if(Z.shouldTransform){if(z[J]=Array.prototype.concat.call([],z[J]),typeof Z.transformFunction==="function")z[J]=z[J].map(Z.transformFunction)}}}function z4(z){let q=/([^\\/]+)$/.exec(z);return q?q[1]:""}function b(z){return z.split(".").map((q,J)=>{return J===0?C(q):q}).join(".")}class I extends Error{exitCode=2;isUsageError=!0;usage;constructor(z,q){super(z);if(this.name=this.constructor.name,q!==void 0)this.usage=q;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(z).stack}format(z=!1){if(z&&this.stack)return`${this.message}
|
|
4
4
|
|
|
5
5
|
Stack trace:
|
|
6
6
|
${this.stack}`;return this.message}}function q4(z){if(z instanceof I)return!0;return!!z&&typeof z==="object"&&z.name==="ClappError"&&typeof z.message==="string"}function J4(){let{env:z}=z6,{TERM:q,TERM_PROGRAM:J}=z;if(z6.platform!=="win32")return q!=="linux";return Boolean(z.WT_SESSION)||Boolean(z.TERMINUS_SUBLIME)||z.ConEmuTask==="{cmd::Cmder}"||J==="Terminus-Sublime"||J==="vscode"||q==="xterm-256color"||q==="alacritty"||q==="rxvt-unicode"||q==="rxvt-unicode-256color"||z.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var y="\x1B",L=`${y}[`;var P={to(z,q){if(!q)return`${L}${z+1}G`;return`${L}${q+1};${z+1}H`},move(z,q){let J="";if(z<0)J+=`${L}${-z}D`;else if(z>0)J+=`${L}${z}C`;if(q<0)J+=`${L}${-q}A`;else if(q>0)J+=`${L}${q}B`;return J},up:(z=1)=>`${L}${z}A`,down:(z=1)=>`${L}${z}B`,forward:(z=1)=>`${L}${z}C`,backward:(z=1)=>`${L}${z}D`,nextLine:(z=1)=>`${L}E`.repeat(z),prevLine:(z=1)=>`${L}F`.repeat(z),left:`${L}G`,hide:`${L}?25l`,show:`${L}?25h`,save:`${y}7`,restore:`${y}8`};var f={screen:`${L}2J`,up:(z=1)=>`${L}1J`.repeat(z),down:(z=1)=>`${L}J`.repeat(z),line:`${L}2K`,lineEnd:`${L}K`,lineStart:`${L}1K`,lines(z){let q="";for(let J=0;J<z;J++)q+=this.line+(J<z-1?P.up():"");if(z)q+=P.left;return q}},Xz={screen:`${y}c`};function Z4(z,q){let J=[];for(let Z=0;Z<=q.length;Z++)J[Z]=[Z];for(let Z=0;Z<=z.length;Z++)J[0][Z]=Z;for(let Z=1;Z<=q.length;Z++)for(let $=1;$<=z.length;$++)if(q.charAt(Z-1)===z.charAt($-1))J[Z][$]=J[Z-1][$-1];else J[Z][$]=Math.min(J[Z-1][$-1]+1,J[Z][$-1]+1,J[Z-1][$]+1);return J[q.length][z.length]}function X6(z,q,J=2,Z=3){return q.map(($)=>({cmd:$,distance:Z4(z,$)})).filter(({distance:$})=>$<=J).sort(($,Y)=>$.distance-Y.distance).slice(0,Z).map(({cmd:$})=>$)}function $4(z,q={}){let J={_:[]},Z=q.alias||{},$=new Set(q.boolean||[]),Y={};for(let X of Object.keys(Z))for(let Q of Z[X])Y[Q]=X;for(let X of $)if(Z[X])for(let Q of Z[X])$.add(Q);function F(X,Q){let j=Y[X]||X;if(J[j]=Q,Z[j])for(let U of Z[j])J[U]=Q;if(Y[X]&&Z[Y[X]])for(let U of Z[Y[X]])J[U]=Q;J[X]=Q}for(let X=0;X<z.length;X++){let Q=z[X];if(Q==="--"){J._.push(...z.slice(X+1));break}if(Q.startsWith("--")){let j=Q.indexOf("=");if(j!==-1){let U=C(Q.slice(2,j)),H=Q.slice(j+1);F(U,H)}else{let U=Q.slice(2);if(U.startsWith("no-")){let w=C(U.slice(3));F(w,!1);continue}let H=C(U),V=Y[H]||H;if($.has(V)||$.has(H))F(H,!0);else{let w=z[X+1];if(w!==void 0&&!w.startsWith("-"))F(H,w),X++;else F(H,!0)}}}else if(Q.startsWith("-")&&Q.length>1){let j=Q.slice(1);for(let U=0;U<j.length;U++){let H=j[U],V=Y[H]||H;if(U===j.length-1&&!$.has(V)&&!$.has(H)){let w=z[X+1];if(w!==void 0&&!w.startsWith("-"))F(H,w),X++;else F(H,!0)}else F(H,!0)}}else J._.push(Q)}return J}class U6{rawName;description;name;names;isBoolean;required;config;negated;constructor(z,q,J){if(this.rawName=z,this.description=q,this.config=Object.assign({},J),z=z.replace(/\.\*/g,""),this.negated=!1,this.names=m(z).split(",").map((Z)=>{let $=Z.trim().replace(/^-{1,2}/,"");if($.startsWith("no-"))this.negated=!0,$=$.replace(/^no-/,"");return b($)}).sort((Z,$)=>Z.length>$.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(z.includes("<"))this.required=!0;else if(z.includes("["))this.required=!1;else this.isBoolean=!0}}var Fz=d.argv,Q4=`${d.platform}-${d.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,J6=k.argv,Y4=`${k.platform}-${k.arch} node-${k.version}`;class u{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(z,q,J,Z){this.rawName=z,this.description=q,this.config=J,this.cli=Z,this.options=[],this.aliasNames=[],this.name=m(z);let $=m(z),Y=$.indexOf(":");if(Y>0)this.namespace=$.substring(0,Y),this.name=$.substring(Y+1);if(this.args=s6(z),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!J)this.config={}}usage(z){return this.usageText=z,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(z,q="-v, --version"){return this.versionNumber=z,this.option(q,"Display version number"),this}example(z){return this.examples.push(z),this}option(z,q,J){let Z=new U6(z,q,J);return this.options.push(Z),this}alias(z){return this.aliasNames.push(z),this}action(z){return this.commandAction=z,this}before(z){return this.beforeHooks.push(z),this}after(z){return this.afterHooks.push(z),this}use(z){return this.middleware.push(z),this}isMatched(z){if(this.aliasNames.includes(z))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===z;return this.name===z}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof i}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(z){let q=b(z.split(".")[0]);return!!this.options.find((J)=>{return J.names.some((Z)=>b(Z)===q)})}outputHelp(){let{name:z,commands:q}=this.cli,{versionNumber:J,options:Z,helpCallback:$}=this.cli.globalCommand,Y=[{body:`${z}${J?`/${J}`:""}`}];if(Y.push({title:"Usage",body:` $ ${z} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&q.length>0){let j=q6(q.map((M)=>M.rawName)),U=new Map,H=[];for(let M of q)if(M.namespace){if(!U.has(M.namespace))U.set(M.namespace,[]);U.get(M.namespace).push(M)}else H.push(M);let V="";if(H.sort((M,A)=>M.rawName<A.rawName?-1:M.rawName>A.rawName?1:0),H.length>0)V+=H.map((M)=>{return` ${_(M.rawName,j.length)} ${M.description}`}).join(`
|
|
@@ -38,7 +38,7 @@ Run \`${this.name??"cli"} --help\` for usage.`;N.stderr.write(`${J}${q}${Z}
|
|
|
38
38
|
`).length-1;this.output.write(P.move(-999,z*-1))}render(){let z=Y6(this._render(this)??"",Q6.stdout.columns,{hard:!0,trim:!1});if(z===this._prevFrame)return;if(this.state==="initial")this.output.write(P.hide);else{let q=_4(this._prevFrame,z);if(this.restoreCursor(),q&&q?.length===1){let J=q[0];this.output.write(P.move(0,J)),this.output.write(f.lines(1));let Z=z.split(`
|
|
39
39
|
`);this.output.write(Z[J]),this._prevFrame=z,this.output.write(P.move(0,Z.length-J-1));return}if(q&&q?.length>1){let J=q[0];this.output.write(P.move(0,J)),this.output.write(f.down());let $=z.split(`
|
|
40
40
|
`).slice(J);this.output.write($.join(`
|
|
41
|
-
`)),this._prevFrame=z;return}this.output.write(f.down())}if(this.output.write(z),this.state==="initial")this.state="active";this._prevFrame=z}}function c4(z,q){if(z===void 0)return 0;if(q.length===0)return 0;let Z=q.findIndex(($)=>$.value===z);return Z!==-1?Z:0}function n4(z,q){return(q.label??String(q.value)).toLowerCase().includes(z.toLowerCase())}function p4(z,q){if(!q)return;if(z)return q;return q[0]}class l4 extends n{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#J="";#Z;#q;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return h.inverse(h.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let z=this.userInput.slice(0,this._cursor),[q,...J]=this.userInput.slice(this._cursor);return`${z}${h.inverse(q)}${J.join("")}`}get options(){if(typeof this.#q==="function")return this.#q();return this.#q}constructor(z){super(z);this.#q=z.options;let q=this.options;this.filteredOptions=[...q],this.multiple=z.multiple===!0,this.#Z=z.filter??n4;let J;if(z.initialValue&&Array.isArray(z.initialValue))if(this.multiple)J=z.initialValue;else J=z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)J=[this.options[0].value];if(J)for(let Z of J){let $=q.findIndex((Y)=>Y.value===Z);if($!==-1)this.toggleSelected(Z),this.#z=$}this.focusedValue=this.options[this.#z]?.value,this.on("key",(Z,$)=>this.#$(Z,$)),this.on("userInput",(Z)=>this.#Q(Z))}_isActionKey(z,q){return z==="\t"||this.multiple&&this.isNavigating&&q.name==="space"&&z!==void 0&&z!==""}#$(z,q){let J=q.name==="up",Z=q.name==="down",$=q.name==="return";if(J||Z){if(this.#z=Math.max(0,Math.min(this.#z+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if($)this.value=p4(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&(q.name==="tab"||this.isNavigating&&q.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(z))this.selectedValues=this.selectedValues.filter((q)=>q!==z);else this.selectedValues=[...this.selectedValues,z];else this.selectedValues=[z]}#Q(z){if(z!==this.#J){this.#J=z;let q=this.options;if(z)this.filteredOptions=q.filter((J)=>this.#Z(z,J));else this.filteredOptions=[...q];if(this.#z=c4(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class r4 extends n{options;cursor=0;#z;getGroupItems(z){return this.options.filter((q)=>q.group===z)}isGroupSelected(z){let q=this.getGroupItems(z),J=this.value;if(J===void 0)return!1;return q.every((Z)=>J.includes(Z.value))}toggleValue(){let z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(z.group===!0){let q=String(z.value),J=this.getGroupItems(q);if(this.isGroupSelected(q))this.value=this.value.filter((Z)=>J.findIndex(($)=>$.value===Z)===-1);else this.value=[...this.value,...J.map((Z)=>Z.value)];this.value=Array.from(new Set(this.value))}else{let q=this.value.includes(z.value);this.value=q?this.value.filter((J)=>J!==z.value):[...this.value,z.value]}}constructor(z){super(z,!1);let{options:q}=z;this.#z=z.selectableGroups!==!1,this.options=Object.entries(q).flatMap(([J,Z])=>[{value:J,group:!0,label:J},...Z.map(($)=>({...$,group:J}))]),this.value=[...z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===z.cursorAt),this.#z?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var a4=J4();var W=(z,q)=>a4?z:q,Nz=W("\u25C6","*"),Oz=W("\u25A0","x"),Tz=W("\u25B2","x"),xz=W("\u25C7","o"),Bz=W("\u250C","T"),s4=W("\u2502","|"),Ez=W("\u2514","\u2014"),bz=W("\u25CF",">"),Iz=W("\u25CB"," "),Az=W("\u25FB","[\u2022]"),Rz=W("\u25FC","[+]"),Cz=W("\u25FB","[ ]"),kz=W("\u25AA","\u2022"),hz=W("\u2500","-"),vz=W("\u256E","+"),yz=W("\u251C","+"),Sz=W("\u256F","+"),gz=W("\u25CF","\u2022"),_z=W("\u25C6","*"),fz=W("\u25B2","!"),mz=W("\u25A0","x");var dz={light:W("\u2500","-"),heavy:W("\u2501","="),block:W("\u2588","#")};function t4(){return`${h.gray(s4)} `}var uz=t4();var p="0.2.
|
|
41
|
+
`)),this._prevFrame=z;return}this.output.write(f.down())}if(this.output.write(z),this.state==="initial")this.state="active";this._prevFrame=z}}function c4(z,q){if(z===void 0)return 0;if(q.length===0)return 0;let Z=q.findIndex(($)=>$.value===z);return Z!==-1?Z:0}function n4(z,q){return(q.label??String(q.value)).toLowerCase().includes(z.toLowerCase())}function p4(z,q){if(!q)return;if(z)return q;return q[0]}class l4 extends n{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#J="";#Z;#q;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return h.inverse(h.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let z=this.userInput.slice(0,this._cursor),[q,...J]=this.userInput.slice(this._cursor);return`${z}${h.inverse(q)}${J.join("")}`}get options(){if(typeof this.#q==="function")return this.#q();return this.#q}constructor(z){super(z);this.#q=z.options;let q=this.options;this.filteredOptions=[...q],this.multiple=z.multiple===!0,this.#Z=z.filter??n4;let J;if(z.initialValue&&Array.isArray(z.initialValue))if(this.multiple)J=z.initialValue;else J=z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)J=[this.options[0].value];if(J)for(let Z of J){let $=q.findIndex((Y)=>Y.value===Z);if($!==-1)this.toggleSelected(Z),this.#z=$}this.focusedValue=this.options[this.#z]?.value,this.on("key",(Z,$)=>this.#$(Z,$)),this.on("userInput",(Z)=>this.#Q(Z))}_isActionKey(z,q){return z==="\t"||this.multiple&&this.isNavigating&&q.name==="space"&&z!==void 0&&z!==""}#$(z,q){let J=q.name==="up",Z=q.name==="down",$=q.name==="return";if(J||Z){if(this.#z=Math.max(0,Math.min(this.#z+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if($)this.value=p4(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&(q.name==="tab"||this.isNavigating&&q.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(z))this.selectedValues=this.selectedValues.filter((q)=>q!==z);else this.selectedValues=[...this.selectedValues,z];else this.selectedValues=[z]}#Q(z){if(z!==this.#J){this.#J=z;let q=this.options;if(z)this.filteredOptions=q.filter((J)=>this.#Z(z,J));else this.filteredOptions=[...q];if(this.#z=c4(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class r4 extends n{options;cursor=0;#z;getGroupItems(z){return this.options.filter((q)=>q.group===z)}isGroupSelected(z){let q=this.getGroupItems(z),J=this.value;if(J===void 0)return!1;return q.every((Z)=>J.includes(Z.value))}toggleValue(){let z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(z.group===!0){let q=String(z.value),J=this.getGroupItems(q);if(this.isGroupSelected(q))this.value=this.value.filter((Z)=>J.findIndex(($)=>$.value===Z)===-1);else this.value=[...this.value,...J.map((Z)=>Z.value)];this.value=Array.from(new Set(this.value))}else{let q=this.value.includes(z.value);this.value=q?this.value.filter((J)=>J!==z.value):[...this.value,z.value]}}constructor(z){super(z,!1);let{options:q}=z;this.#z=z.selectableGroups!==!1,this.options=Object.entries(q).flatMap(([J,Z])=>[{value:J,group:!0,label:J},...Z.map(($)=>({...$,group:J}))]),this.value=[...z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===z.cursorAt),this.#z?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var a4=J4();var W=(z,q)=>a4?z:q,Nz=W("\u25C6","*"),Oz=W("\u25A0","x"),Tz=W("\u25B2","x"),xz=W("\u25C7","o"),Bz=W("\u250C","T"),s4=W("\u2502","|"),Ez=W("\u2514","\u2014"),bz=W("\u25CF",">"),Iz=W("\u25CB"," "),Az=W("\u25FB","[\u2022]"),Rz=W("\u25FC","[+]"),Cz=W("\u25FB","[ ]"),kz=W("\u25AA","\u2022"),hz=W("\u2500","-"),vz=W("\u256E","+"),yz=W("\u251C","+"),Sz=W("\u256F","+"),gz=W("\u25CF","\u2022"),_z=W("\u25C6","*"),fz=W("\u25B2","!"),mz=W("\u25A0","x");var dz={light:W("\u2500","-"),heavy:W("\u2501","="),block:W("\u2588","#")};function t4(){return`${h.gray(s4)} `}var uz=t4();var p="0.2.59";var G=new c("query-builder");G.command("introspect <dir>","Load models and print inferred schema").option("--verbose","Enable verbose logging").example("query-builder introspect ./app/Models --verbose").action(async(z,q)=>{await R6(z,q)});G.command("introspect:db","Reverse-introspect the live database into defineModel() source (#1047)").option("--table <table>","Limit to a single table (repeatable)").example("query-builder introspect:db > app/Models/generated.ts").action(async(z)=>{let q=z?.table,J=q?Array.isArray(q)?q:[q]:void 0,Z=await C6({tables:J});console.log(`import { defineModel } from 'bun-query-builder'
|
|
42
42
|
|
|
43
43
|
${Z.map(($)=>$.source).join(`
|
|
44
44
|
`)}`)});G.command("sql <dir> <table>","Build a sample query for a table").option("--limit <n>","Limit rows",{default:10}).example("query-builder sql ./app/Models users --limit 5").action(async(z,q,J)=>{await i6(z,q,J)});G.command("ping","Test database connectivity (uses environment variables)").example("query-builder ping").action(async()=>{await _6()});G.command("wait-ready","Wait for database to become ready").option("--attempts <n>","Number of attempts",{default:10}).option("--delay <ms>","Delay between attempts",{default:100}).example("query-builder wait-ready --attempts 30 --delay 250").action(async(z)=>{try{await l6(z)}catch{let q=await import("process");q.default.exitCode=1}});G.command("unsafe <sql>","Execute an unsafe SQL string (one statement with params)").option("--params <json>","JSON array of parameters").example('query-builder unsafe "SELECT * FROM users WHERE id = $1" --params "[1]"').action(async(z,q)=>{await c6(z,q)});G.command("file <path>","Execute a SQL file (supports $1, $2 params)").option("--params <json>","JSON array of parameters").example("query-builder file ./migrations/seed.sql").example('query-builder file ./reports/top.sql --params "[30]"').action(async(z,q)=>{await b6(z,q)});G.command("migrate <dir>","Generate SQL migrations from models").option("--dialect <d>","Dialect (postgres|mysql|sqlite) \u2014 defaults to the configured dialect").option("--state <path>","Path to migration state file (defaults to <dir>/.qb-migrations.<dialect>.json)").option("--apply","Execute the generated SQL against the database").option("--full","Force full migration SQL instead of incremental diff").example("query-builder migrate ./app/Models --dialect postgres").action(async(z,q)=>{try{await l(z,{dialect:q.dialect,state:q.state,apply:q.apply,full:q.full}),await r()}catch(J){console.error("-- Migration failed:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("explain <sql>","Explain a query").example('query-builder explain "SELECT * FROM users WHERE active = true"').action(async(z)=>{await E6(z)});G.command("query:explain-all <path>","Run EXPLAIN on all SQL files in a directory").option("--verbose","Enable verbose output").option("--json","Output as JSON").example("query-builder query:explain-all ./queries").example("query-builder query:explain-all ./queries/users.sql").action(async(z,q)=>{try{await f6(z,{verbose:q.verbose,json:q.json})}catch(J){console.error("-- Explain all failed:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("relation:diagram","Generate relationship diagram from models").option("--dir <path>","Models directory (defaults to app/Models)").option("--format <fmt>","Output format (mermaid|dot)",{default:"mermaid"}).option("--output <path>","Output file path").option("--verbose","Enable verbose output").example("query-builder relation:diagram").example("query-builder relation:diagram --format dot --output schema.dot").example("query-builder relation:diagram --output schema.mmd").action(async(z)=>{try{await m6({dir:z.dir,format:z.format,output:z.output,verbose:z.verbose})}catch(q){console.error("-- Diagram generation failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("migrate:fresh <dir>","Reset database and run all migrations").option("--dialect <d>","Dialect (postgres|mysql|sqlite) \u2014 defaults to the configured dialect").option("--state <path>","Path to migration state file (defaults to <dir>/.qb-migrations.<dialect>.json)").option("--full","Force full migration SQL instead of incremental diff").example("query-builder migrate:fresh ./app/Models --dialect postgres").action(async(z,q)=>{try{console.log("-- Resetting database..."),await a(z,{dialect:q.dialect,state:q.state}),console.log("-- Generating fresh migrations..."),await l(z,{dialect:q.dialect,state:q.state,full:q.full}),console.log("-- Executing migrations..."),await r()}catch(J){console.error("-- Migrate fresh failed:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("reset <dir>","Drop all tables and reset database").option("--dialect <d>","Dialect (postgres|mysql|sqlite) \u2014 defaults to the configured dialect").option("--state <path>","Path to migration state file (defaults to <dir>/.qb-migrations.<dialect>.json)").example("query-builder reset ./app/Models --dialect postgres").action(async(z,q)=>{try{await a(z,{dialect:q.dialect,state:q.state})}catch(J){console.error("-- Reset failed:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("seed","Run database seeders").option("--dir <path>","Path to seeders directory (defaults to database/seeders)").option("--class <name>","Run a specific seeder class").option("--verbose","Enable verbose logging").example("query-builder seed").example("query-builder seed --class UserSeeder").example("query-builder seed --dir ./database/seeders").action(async(z)=>{try{if(z.class)await t(z.class,{verbose:z.verbose});else await s({seedersDir:z.dir,verbose:z.verbose})}catch(q){console.error("-- Seeding failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("db:seed","Run database seeders (alias for seed)").option("--dir <path>","Path to seeders directory (defaults to database/seeders)").option("--class <name>","Run a specific seeder class").option("--verbose","Enable verbose logging").example("query-builder db:seed").example("query-builder db:seed --class UserSeeder").action(async(z)=>{try{if(z.class)await t(z.class,{verbose:z.verbose});else await s({seedersDir:z.dir,verbose:z.verbose})}catch(q){console.error("-- Seeding failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("make:seeder <name>","Create a new seeder file").example("query-builder make:seeder User").example("query-builder make:seeder UserSeeder").action(async(z)=>{try{await d6(z)}catch(q){console.error("-- Failed to create seeder:",q);let J=await import("process");J.default.exitCode=1}});G.command("db:fresh","Drop all tables, re-run migrations and seed the database").option("--models <path>","Path to models directory (defaults to app/Models)").option("--seeders <path>","Path to seeders directory (defaults to database/seeders)").option("--verbose","Enable verbose logging").example("query-builder db:fresh").example("query-builder db:fresh --models ./app/Models --seeders ./database/seeders").action(async(z)=>{try{await u6({modelsDir:z.models,seedersDir:z.seeders,verbose:z.verbose})}catch(q){console.error("-- Database fresh failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("make:model <name>","Create a new model file").option("--table <name>","Table name (defaults to plural of model name)").option("--dir <path>","Models directory (defaults to app/Models)").option("--timestamps","Include timestamp fields (default: true)").example("query-builder make:model User").example("query-builder make:model Post --table=blog_posts").action(async(z,q)=>{try{await k6(z,{table:q.table,dir:q.dir,timestamps:q.timestamps})}catch(J){console.error("-- Failed to create model:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("model:show <name>","Show detailed model information").option("--dir <path>","Models directory (defaults to app/Models)").option("--json","Output as JSON").option("--verbose","Enable verbose output").example("query-builder model:show User").example("query-builder model:show Post --json").action(async(z,q)=>{try{await g6(z,{dir:q.dir,json:q.json,verbose:q.verbose})}catch(J){console.error("-- Failed to show model:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("migrate:status","Show migration status").example("query-builder migrate:status").action(async()=>{try{await y6()}catch(z){console.error("-- Failed to get migration status:",z);let q=await import("process");q.default.exitCode=1}});G.command("migrate:list","List all migrations (alias for migrate:status)").example("query-builder migrate:list").action(async()=>{try{await S6()}catch(z){console.error("-- Failed to list migrations:",z);let q=await import("process");q.default.exitCode=1}});G.command("migrate:rollback","Rollback migrations").option("--steps <n>","Number of migrations to rollback",{default:1}).option("--no-reverse-schema","Only remove the migration records; leave the schema alone").option("--delete-files","Also delete the rolled-back migration files from disk").example("query-builder migrate:rollback").example("query-builder migrate:rollback --steps 2").example("query-builder migrate:rollback --no-reverse-schema").action(async(z)=>{try{await v6({steps:Number(z.steps),reverseSchema:z.reverseSchema,deleteFiles:Boolean(z.deleteFiles)})}catch(q){console.error("-- Rollback failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("migrate:generate [dir]","Generate migration from model changes").option("--dialect <d>","Dialect (postgres|mysql|sqlite) \u2014 defaults to the configured dialect").option("--state <path>","Path to migration state file").option("--apply","Execute the generated SQL").option("--full","Force full migration SQL").example("query-builder migrate:generate").example("query-builder migrate:generate ./app/Models --dialect postgres").action(async(z,q)=>{try{await h6(z,{dialect:q?.dialect,state:q?.state,apply:q?.apply,full:q?.full})}catch(J){console.error("-- Generate migration failed:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("db:info","Show database information and statistics").example("query-builder db:info").action(async()=>{try{await O6()}catch(z){console.error("-- Failed to get database info:",z);let q=await import("process");q.default.exitCode=1}});G.command("db:stats","Show database statistics (alias for db:info)").example("query-builder db:stats").action(async()=>{try{await T6()}catch(z){console.error("-- Failed to get database stats:",z);let q=await import("process");q.default.exitCode=1}});G.command("db:wipe","Drop all tables from the database").option("--dialect <d>","Dialect (postgres|mysql|sqlite) \u2014 defaults to the configured dialect").option("--force","Skip confirmation prompt").option("--verbose","Enable verbose output").example("query-builder db:wipe").example("query-builder db:wipe --force").action(async(z)=>{try{await B6({dialect:z.dialect,force:z.force,verbose:z.verbose})}catch(q){console.error("-- Wipe failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("db:optimize","Optimize database tables (VACUUM, ANALYZE, OPTIMIZE)").option("--dialect <d>","Dialect (postgres|mysql|sqlite) \u2014 defaults to the configured dialect").option("--aggressive","Use aggressive optimization (VACUUM FULL for postgres)").option("--tables <tables>","Comma-separated list of tables to optimize").option("--verbose","Enable verbose output").example("query-builder db:optimize").example("query-builder db:optimize --aggressive").example("query-builder db:optimize --tables users,posts").action(async(z)=>{try{await x6({dialect:z.dialect,aggressive:z.aggressive,tables:z.tables?z.tables.split(","):void 0,verbose:z.verbose})}catch(q){console.error("-- Optimize failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("console","Start interactive query console").example("query-builder console").action(async()=>{try{await L6()}catch(z){console.error("-- Console failed:",z);let q=await import("process");q.default.exitCode=1}});G.command("tinker","Start interactive query console (alias for console)").example("query-builder tinker").action(async()=>{try{await M6()}catch(z){console.error("-- Tinker failed:",z);let q=await import("process");q.default.exitCode=1}});G.command("inspect <table>","Inspect a table structure").option("--verbose","Enable verbose output",{default:!0}).example("query-builder inspect users").action(async(z,q)=>{try{await I6(z,{verbose:q.verbose})}catch(J){console.error("-- Failed to inspect table:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("table:info <table>","Show table information (alias for inspect)").option("--verbose","Enable verbose output",{default:!0}).example("query-builder table:info users").action(async(z,q)=>{try{await A6(z,{verbose:q.verbose})}catch(J){console.error("-- Failed to get table info:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("cache:clear","Clear the query cache").example("query-builder cache:clear").action(async()=>{try{await V6()}catch(z){console.error("-- Failed to clear cache:",z);let q=await import("process");q.default.exitCode=1}});G.command("cache:stats","Show cache statistics").example("query-builder cache:stats").action(async()=>{try{await W6()}catch(z){console.error("-- Failed to get cache stats:",z);let q=await import("process");q.default.exitCode=1}});G.command("cache:config","Configure cache settings").option("--size <n>","Set maximum cache size").example("query-builder cache:config --size 500").action(async(z)=>{try{await D6({size:z.size})}catch(q){console.error("-- Failed to configure cache:",q);let J=await import("process");J.default.exitCode=1}});G.command("benchmark","Run performance benchmarks").option("--operations <ops>","Comma-separated list of operations (select,insert,update,delete,count)").option("--iterations <n>","Number of iterations per operation",{default:1000}).example("query-builder benchmark").example("query-builder benchmark --operations select,insert --iterations 5000").action(async(z)=>{try{await K6({operations:z.operations,iterations:z.iterations?Number(z.iterations):void 0})}catch(q){console.error("-- Benchmark failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("validate:schema [dir]","Validate models against database schema").example("query-builder validate:schema").example("query-builder validate:schema ./app/Models").action(async(z)=>{try{await n6(z)}catch(q){console.error("-- Validation failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("check [dir]","Validate schema (alias for validate:schema)").example("query-builder check").action(async(z)=>{try{await p6(z)}catch(q){console.error("-- Check failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("export <table>","Export data from a table").option("--format <fmt>","Export format (json|csv|sql)",{default:"json"}).option("--output <path>","Output file path").option("--limit <n>","Limit number of rows").example("query-builder export users").example("query-builder export users --format csv --output users.csv").example("query-builder export users --format sql --limit 100").action(async(z,q)=>{try{await w6(z,{format:q.format,output:q.output,limit:q.limit?Number(q.limit):void 0})}catch(J){console.error("-- Export failed:",J);let Z=await import("process");Z.default.exitCode=1}});G.command("import <table> <file>","Import data into a table").option("--format <fmt>","Import format (json|csv)").option("--truncate","Truncate table before import").example("query-builder import users users.json").example("query-builder import users users.csv --truncate").action(async(z,q,J)=>{try{await P6(z,q,{format:J.format,truncate:J.truncate})}catch(Z){console.error("-- Import failed:",Z);let $=await import("process");$.default.exitCode=1}});G.command("dump","Dump database to SQL file").option("--tables <tables>","Comma-separated list of tables to dump").option("--output <path>","Output file path").example("query-builder dump").example("query-builder dump --tables users,posts").example("query-builder dump --output backup.sql").action(async(z)=>{try{await N6({tables:z.tables,output:z.output})}catch(q){console.error("-- Dump failed:",q);let J=await import("process");J.default.exitCode=1}});G.command("version","Show the version of the CLI").action(()=>{console.log(p)});G.version(p);G.help();G.parse();
|
|
@@ -402,7 +402,7 @@ export default class ${J} extends Seeder {
|
|
|
402
402
|
return 100
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
|
-
`;TU(U,H),console.log(`-- \u2713 Created seeder: ${U}`)}async function xU(Z={}){let $=z7(o9.cwd()),Y=Z.modelsDir||c8($,"app/Models"),X=Z.seedersDir||c8($,"database/seeders"),J=Z.verbose??!0;try{let{resetDatabase:G,generateMigration:U,executeMigration:H}=await import("./chunk-
|
|
405
|
+
`;TU(U,H),console.log(`-- \u2713 Created seeder: ${U}`)}async function xU(Z={}){let $=z7(o9.cwd()),Y=Z.modelsDir||c8($,"app/Models"),X=Z.seedersDir||c8($,"database/seeders"),J=Z.verbose??!0;try{let{resetDatabase:G,generateMigration:U,executeMigration:H}=await import("./chunk-cggx9cr8.js");if(J)console.log("-- Refreshing database...");if(await G(Y),J)console.log("-- Running migrations...");if(await U(Y,{full:!0}),await H(),J)console.log("-- Running seeders...");if(await Q1({seedersDir:X,verbose:J}),J)console.log("-- \u2713 Database refreshed successfully")}catch(G){throw console.error("-- \u2717 Database refresh failed:",G),G}}qZ();function vU(Z,$,Y={}){let X=Q8({modelsDir:Z}),J=G7(X);if(y.debug)y.debug.captureText=!0;let G=JZ({schema:J}),U=G.selectFrom($).limit(Number(Y.limit||10)).toText?.()??"";return console.log(U||"[query]"),{sql:U,qb:G,schema:J}}async function yU(Z,$={}){let Y=JZ(),X=$.params?JSON.parse($.params):void 0,J=await Y.unsafe(Z,X);return console.log(JSON.stringify(J)),J}qZ();import{existsSync as hU}from"fs";import{dirname as _1,join as V1}from"path";import K1 from"process";function bU(Z){let $=Z;while($!==_1($)){if(hU(V1($,"package.json")))return $;$=_1($)}return K1.cwd()}async function L1(Z){if(!Z)Z=V1(bU(K1.cwd()),"app/Models");let $=y.dialect||"postgres";console.log("-- Validating Schema"),console.log(`-- Models directory: ${Z}`),console.log(`-- Dialect: ${$}`),console.log();let Y=[];try{let X=await Q8({modelsDir:Z}),J=r9(X,{dialect:$}),G=JZ(),U=[];if($==="sqlite")U=(await G.unsafe(`
|
|
406
406
|
SELECT name FROM sqlite_master
|
|
407
407
|
WHERE type = 'table'
|
|
408
408
|
AND name NOT LIKE 'sqlite_%'
|
|
@@ -440,6 +440,6 @@ ${Z}`),fZ(`-- Migration file created: ${G}`),v8++,K7.push(G),S9?.add(X),!0}funct
|
|
|
440
440
|
`);G(d,`create-${I.table}-table`)}let w=new Set;for(let V of Object.keys(Q)){let F=W[V],I=Q[V];if(!F)continue;let E=Z$(F.columns),n=Z$(I.columns);for(let x of Object.keys(n)){let d=n[x];if(d.type!=="enum"||!d.enumValues||d.enumValues.length===0)continue;let P=`${I.table}_${d.name}_type`;if(d.enumTypeName=P,E[x])continue;if(!w.has(P)){let M=z.createEnumType(P,d.enumValues);if(M)U.push(M),H.push({kind:"create_enum",table:I.table,column:d.name,destructive:!1,sql:M}),G(M,`create-${P}-enum`);w.add(P)}}}for(let V of Object.keys(Q)){let F=W[V],I=Q[V];if(!F)continue;let E=Z$(F.columns),n=k0(F.indexes,F.table),x=Z$(I.columns),d=k0(I.indexes,I.table),P=[],M=Object.keys(E).filter((q)=>!x[q]),S=Object.keys(x).filter((q)=>!E[q]);if(X&&!J){let q=I2(E,x,A);P=q.renames,M=q.removed,S=q.added}if(J){let q=M.map((u)=>E[u]),l=F.indexes.filter((u)=>!d[VJ(u,F.table)]);if(q.length>0||l.length>0){if(q.length>0)fZ(`-- Keeping ${q.length} column(s) on "${I.table}" no model declares: ${M.join(", ")} \u2014 reconciled from the database, where an undeclared column is out of scope rather than removed`);if(l.length>0)fZ(`-- Keeping ${l.length} index(es) on "${I.table}" no model declares: ${l.map((u)=>u.name).join(", ")} \u2014 reconciled from the database, where an undeclared index is out of scope rather than removed`);I={...I,columns:[...I.columns,...q],indexes:[...I.indexes,...l]},x=Z$(I.columns),d=k0(I.indexes,I.table)}M=[]}let C=Object.keys(x).filter((q)=>E[q]&&D2(E[q],x[q],A)),v=Object.keys(x).filter((q)=>E[q]&&w2(E[q].references,x[q].references));if(A==="sqlite"){if(C.length>0||v.length>0||M.some((l)=>M2(F,l))){let l={},u=new Map(P.map((GZ)=>[GZ.to,GZ.from]));for(let GZ of I.columns)if(E[GZ.name])l[GZ.name]=GZ.name;else if(u.has(GZ.name))l[GZ.name]=u.get(GZ.name);let r=`_qb_tmp_${I.table}`,b=0;while((W[r]||Q[r])&&b<100)b+=1,r=`_qb_tmp_${I.table}_${b}`;let c=z.rebuildTable({target:I,tempName:r,columnSource:l});U.push(c);let t=C.some((GZ)=>E[GZ].type!==x[GZ].type);H.push({kind:"rebuild_table",table:I.table,destructive:M.length>0||t,sql:c});for(let GZ of P)H.push({kind:"rename_column",table:I.table,from:GZ.from,to:GZ.to,destructive:!1,confidence:"high",sql:c});for(let GZ of M)H.push({kind:"drop_column",table:I.table,column:GZ,destructive:!0,sql:c});fZ(`-- Detected SQLite table rebuild required: ${I.table}`),G(c,`alter-${I.table}-table`);continue}}let i=[],m=!1;for(let q of Object.keys(n))if(!d[q]){let l=n[q],u=z.dropIndex(I.table,l.name);i.push(u),U.push(u),H.push({kind:"drop_index",table:I.table,column:l.name,destructive:!1,sql:u}),fZ(`-- Detected dropped index: ${l.name} from ${I.table}`),m=!0}for(let q of P){let l=z.renameColumn(I.table,q.from,q.to);i.push(l),U.push(l),H.push({kind:"rename_column",table:I.table,from:q.from,to:q.to,destructive:!1,confidence:"high",sql:l}),fZ(`-- Detected renamed column: ${I.table}.${q.from} -> ${q.to}`),m=!0}for(let q of M){let l=z.dropColumn(I.table,q);i.push(l),U.push(l),H.push({kind:"drop_column",table:I.table,column:q,destructive:!0,sql:l}),fZ(`-- Detected dropped column: ${I.table}.${q}`),m=!0}for(let q of C){let l=E[q],u=x[q],r=z.modifyColumn(I.table,u);i.push(r),U.push(r),H.push({kind:"modify_column",table:I.table,column:q,destructive:l.type!==u.type&&!B2(l.type,u.type),sql:r}),fZ(`-- Detected column change: ${I.table}.${q} (${l.type} -> ${u.type})`),m=!0}for(let q of v){let l=x[q];if(!l.references)continue;let u=z.addForeignKey(I.table,l.name,l.references.table,l.references.column,l.references.onDelete,l.references.onUpdate,E[q].references?.constraintNames);if(!u)continue;i.push(u),U.push(u),H.push({kind:"add_foreign_key",table:I.table,column:q,destructive:!1,sql:u}),fZ(`-- Detected foreign-key change: ${I.table}.${q} -> ${l.references.table}(${l.references.column})`),m=!0}for(let q of S){let l=x[q],u=z.addColumn(I.table,l);if(i.push(u),U.push(u),H.push({kind:"add_column",table:I.table,column:l.name,destructive:!1,sql:u}),fZ(`-- Detected new column: ${I.table}.${l.name}`),m=!0,l.references){let r=z.addForeignKey(I.table,l.name,l.references.table,l.references.column,l.references.onDelete,l.references.onUpdate);if(r)i.push(r),U.push(r),H.push({kind:"add_foreign_key",table:I.table,column:l.name,destructive:!1,sql:r})}}for(let q of Object.keys(d))if(!n[q]){let l=d[q],u=z.createIndex(I.table,l,I.columns);i.push(u),U.push(u),H.push({kind:"create_index",table:I.table,column:l.name,destructive:!1,sql:u}),fZ(`-- Detected new index: ${l.name} in ${I.table}`),m=!0}if(m){let q=i.join(`
|
|
441
441
|
|
|
442
442
|
`);G(q,`alter-${I.table}-table`)}}if(v8+s8===0)fZ("-- Nothing to migrate");else{let V=[];if(v8>0)V.push(`${v8} created`);if(s8>0)V.push(`${s8} updated`);fZ(`-- Migration files: ${V.join(", ")}`)}return{statements:U.length===0?["-- No changes detected"]:U,operations:H}}function C2(Z,$,Y={}){return f0(Z,$,Y).statements}P0();function a3(Z){return Z}class S2{get order(){return 100}get description(){return}}function Zj(Z){return Z}e9();e9();Z7();l$();qZ();function KJ(Z){switch(Z){case"text":return"text";case"string":case"enum":return"varchar";case"integer":case"bigint":return"integer";case"float":case"double":case"decimal":return"fractional";case"boolean":return"boolean";case"date":case"datetime":case"timestamptz":return"date";case"json":return"json";default:return"other"}}function LJ(Z){let $=String(Z??"").toLowerCase().trim();if(/^(?:bool|boolean|bit)\b/.test($)||$==="tinyint(1)")return"boolean";if(/^(?:json|jsonb)\b/.test($))return"json";if(/^(?:bytea|blob|binary|varbinary)\b/.test($))return"binary";if(/^(?:date|time|timestamp|datetime)\b/.test($))return"date";if(/(?:^|\b)(?:varchar|character varying|nvarchar|char)\b/.test($))return"varchar";if(/^(?:text|longtext|mediumtext|tinytext|clob|citext)\b/.test($))return"text";if(/^(?:decimal|numeric|real|double|money)\b/.test($)||/^float\d*\b/.test($))return"fractional";if(/^(?:integer|bigint|smallint|tinyint|serial|bigserial|smallserial|mediumint)\b/.test($)||/^int\d*\b/.test($))return"integer";return"other"}function FJ(Z,$,Y){if(Z===$)return!0;if(Y==="sqlite"){if(Z==="boolean"&&$==="integer")return!0;if((Z==="date"||Z==="json")&&$==="text")return!0}if(YZ(Y)&&Z==="boolean"&&$==="integer")return!0;if(Z==="varchar"&&$==="text")return!0;if(Z==="integer"&&$==="fractional")return!0;if(Z==="other"||$==="other")return!0;return!1}async function N2(Z,$={}){let Y=$.dialect??y.dialect,X=Z.tables.map((A)=>A.table),J=await Q0({tables:X}),G=new Map(J.map((A)=>[A.table.toLowerCase(),A])),U=[],H=[],z=[];for(let A of Z.tables){let W=G.get(A.table.toLowerCase());if(!W){U.push(A.table);continue}let Q=new Map(W.columns.map((L)=>[L.name.toLowerCase(),L]));for(let L of A.columns){let O=Q.get(L.name.toLowerCase()),T=KJ(L.type);if(!O){H.push({table:A.table,column:L.name,expected:T});continue}let w=LJ(O.sqlType);if(!FJ(T,w,Y))z.push({table:A.table,column:L.name,expected:T,actual:w,actualSqlType:O.sqlType})}}return{missingTables:U,missingColumns:H,typeMismatches:z,clean:U.length===0&&H.length===0&&z.length===0}}function P2(Z){if(Z.clean)return"";let $=[];if(Z.missingTables.length>0)$.push(` Missing tables: ${Z.missingTables.join(", ")}`);for(let J of Z.missingColumns.slice(0,10))$.push(` \u2022 ${J.table}.${J.column} is missing (models declare ${J.expected})`);for(let J of Z.typeMismatches.slice(0,10))$.push(` \u2022 ${J.table}.${J.column} is ${J.actualSqlType}, models declare ${J.expected}`);let Y=Math.min(Z.missingColumns.length,10)+Math.min(Z.typeMismatches.length,10),X=Z.missingColumns.length+Z.typeMismatches.length;if(X>Y)$.push(` + ${X-Y} more`);return["The live schema does not match the models.",...$,"","Migrations will NOT fix this on their own: the runner only applies files that have","not run yet, and a corrected `CREATE TABLE IF NOT EXISTS` is a no-op against a table","that already exists. Regenerate and apply the difference, or rebuild the schema."].join(`
|
|
443
|
-
`)}async function k2(Z,$,Y){if(Y.length===0)return;let X=SJ(U9());try{await NJ(Z,$);for(let J of Y)await F7(Z,J,$),XZ(`-- \u2713 Recorded applied migration: ${J}`)}catch(J){XZ(`-- Could not record applied migrations (the schema change itself succeeded): ${J instanceof Error?J.message:String(J)}`)}}function MJ(Z,$){try{return AJ(Y$($8(Z,$),"utf8"))}catch{return!1}}function x2(Z){let $=Z instanceof Error?Z.message:String(Z);return/duplicate column name/i.test($)||/duplicate key name/i.test($)||/\balready exists\b/i.test($)}function XZ(Z){if(y.verbose)console.log(Z)}function wJ(Z){return $8(Z,y.snapshotDir||".qb")}function d0(Z,$){return $8(wJ(Z),`model-snapshot.${$}.json`)}function v2(Z,$){let Y=d0(Z,$);if(!y8(Y))return;try{let X=Y$(Y,"utf8"),J=JSON.parse(X);if(J?.plan&&Array.isArray(J.plan.tables)&&J.plan.dialect)return J.plan;if(Array.isArray(J?.tables)&&J?.dialect)return J;XZ("-- Invalid snapshot format, treating as no previous state");return}catch(X){XZ(`-- Could not load snapshot, treating as no previous state: ${X instanceof Error?X.message:String(X)}`);return}}function CJ(Z,$,Y){let X=d0(Z,$),J=wJ(Z),G=_J(Y);if(y8(X))try{let H=JSON.parse(Y$(X,"utf8"));if(H?.hash===G&&H?.dialect===$&&H?.plan){XZ("-- Model snapshot unchanged");return}}catch{}if(!y8(J))OJ(J,{recursive:!0}),XZ(`-- Created snapshot directory: ${J}`);let U={plan:Y,hash:G,dialect:$,updatedAt:new Date().toISOString()};IJ(X,JSON.stringify(U,null,2)),XZ(`-- Model snapshot saved to ${X}`)}function pU(Z,$={}){let Y=$.dialect??Z.dialect;CJ($.workspaceRoot??U9(),Y,Z)}function U9(){return B0()}function SJ(Z){let $=T8(Z,y.migrationDir);if(!y8($))OJ($,{recursive:!0}),XZ(`-- Created SQL directory: ${$}`);return $}async function F0(Z,$={}){if(await i$(),!Z)Z=$8(p0.cwd(),"app/Models");let Y=$.dialect||y.dialect||"postgres",X=U9(),J=await Q8({modelsDir:Z}),G=r9(J,{dialect:Y,vitessSharded:$.vitessSharded}),U,H=!1;if(!$.full)if(U=v2(X,Y),U)XZ("-- Comparing with stored model snapshot");else{let O=$8(Z,`.qb-migrations.${Y}.json`),T=String($.state||O);if(y8(T))try{let w=Y$(T,"utf8"),K=JSON.parse(w);if(U=K?.plan&&K.plan.tables?K.plan:K?.tables?K:void 0,U)XZ("-- Comparing with legacy state file (will migrate to new snapshot format)")}catch{}if(!U||$.fromDb)try{let w=await rX(Y),K=new Set(G.tables.map((V)=>V.table)),B=w.tables.filter((V)=>K.has(V.table));if(B.length>0)U={dialect:w.dialect,tables:B},H=!0,XZ(`-- No snapshot; reconciling against live database (${B.length} matching table${B.length===1?"":"s"})`)}catch(w){XZ(`-- Could not introspect live database, treating as no previous state: ${w instanceof Error?w.message:String(w)}`)}if(!U)XZ("-- No previous snapshot found, generating full migration")}else XZ("-- Full migration requested, ignoring any previous state");let z=$.full?{statements:L7(G,{dryRun:$.dryRun}),operations:G.tables.map((O)=>({kind:"create_table",table:O.table,destructive:!1,sql:""}))}:f0(U,G,{applyRenames:$.applyRenames,dryRun:$.dryRun,preserveUnknownColumns:H}),A=z.statements,W=z.operations,Q=A.join(`
|
|
443
|
+
`)}async function k2(Z,$,Y){if(Y.length===0)return;let X=SJ(U9());try{await NJ(Z,$);for(let J of Y)await F7(Z,J,$),XZ(`-- \u2713 Recorded applied migration: ${J}`)}catch(J){XZ(`-- Could not record applied migrations (the schema change itself succeeded): ${J instanceof Error?J.message:String(J)}`)}}function MJ(Z,$){try{return AJ(Y$($8(Z,$),"utf8"))}catch{return!1}}function x2(Z){let $=Z instanceof Error?Z.message:String(Z);return/duplicate column name/i.test($)||/duplicate key name/i.test($)||/duplicate foreign key constraint name/i.test($)||/\balready exists\b/i.test($)}function XZ(Z){if(y.verbose)console.log(Z)}function wJ(Z){return $8(Z,y.snapshotDir||".qb")}function d0(Z,$){return $8(wJ(Z),`model-snapshot.${$}.json`)}function v2(Z,$){let Y=d0(Z,$);if(!y8(Y))return;try{let X=Y$(Y,"utf8"),J=JSON.parse(X);if(J?.plan&&Array.isArray(J.plan.tables)&&J.plan.dialect)return J.plan;if(Array.isArray(J?.tables)&&J?.dialect)return J;XZ("-- Invalid snapshot format, treating as no previous state");return}catch(X){XZ(`-- Could not load snapshot, treating as no previous state: ${X instanceof Error?X.message:String(X)}`);return}}function CJ(Z,$,Y){let X=d0(Z,$),J=wJ(Z),G=_J(Y);if(y8(X))try{let H=JSON.parse(Y$(X,"utf8"));if(H?.hash===G&&H?.dialect===$&&H?.plan){XZ("-- Model snapshot unchanged");return}}catch{}if(!y8(J))OJ(J,{recursive:!0}),XZ(`-- Created snapshot directory: ${J}`);let U={plan:Y,hash:G,dialect:$,updatedAt:new Date().toISOString()};IJ(X,JSON.stringify(U,null,2)),XZ(`-- Model snapshot saved to ${X}`)}function pU(Z,$={}){let Y=$.dialect??Z.dialect;CJ($.workspaceRoot??U9(),Y,Z)}function U9(){return B0()}function SJ(Z){let $=T8(Z,y.migrationDir);if(!y8($))OJ($,{recursive:!0}),XZ(`-- Created SQL directory: ${$}`);return $}async function F0(Z,$={}){if(await i$(),!Z)Z=$8(p0.cwd(),"app/Models");let Y=$.dialect||y.dialect||"postgres",X=U9(),J=await Q8({modelsDir:Z}),G=r9(J,{dialect:Y,vitessSharded:$.vitessSharded}),U,H=!1;if(!$.full)if(U=v2(X,Y),U)XZ("-- Comparing with stored model snapshot");else{let O=$8(Z,`.qb-migrations.${Y}.json`),T=String($.state||O);if(y8(T))try{let w=Y$(T,"utf8"),K=JSON.parse(w);if(U=K?.plan&&K.plan.tables?K.plan:K?.tables?K:void 0,U)XZ("-- Comparing with legacy state file (will migrate to new snapshot format)")}catch{}if(!U||$.fromDb)try{let w=await rX(Y),K=new Set(G.tables.map((V)=>V.table)),B=w.tables.filter((V)=>K.has(V.table));if(B.length>0)U={dialect:w.dialect,tables:B},H=!0,XZ(`-- No snapshot; reconciling against live database (${B.length} matching table${B.length===1?"":"s"})`)}catch(w){XZ(`-- Could not introspect live database, treating as no previous state: ${w instanceof Error?w.message:String(w)}`)}if(!U)XZ("-- No previous snapshot found, generating full migration")}else XZ("-- Full migration requested, ignoring any previous state");let z=$.full?{statements:L7(G,{dryRun:$.dryRun}),operations:G.tables.map((O)=>({kind:"create_table",table:O.table,destructive:!1,sql:""}))}:f0(U,G,{applyRenames:$.applyRenames,dryRun:$.dryRun,preserveUnknownColumns:H}),A=z.statements,W=z.operations,Q=A.join(`
|
|
444
444
|
`),L=A.some((O)=>/\b(?:CREATE|ALTER|DROP)\b/i.test(O));if($.apply){let O=T2($8(q2(),"qb-migrate-")),T=$8(O,"migration.sql");try{if(L){IJ(T,Q);let w=JZ();await w.file(T),XZ("-- Migration applied"),await k2(w,Y,zJ())}else XZ("-- No changes; nothing to apply")}catch(w){throw console.error("-- Migration failed:",w),w}finally{DJ(O,{recursive:!0,force:!0})}}if(!$.dryRun)CJ(X,Y,G);return{sql:Q,sqlStatements:A,hasChanges:L,plan:G,operations:W}}var BJ="bun-query-builder:migrate",y2=/\bCONCURRENTLY\b|^\s*VACUUM\b|^\s*BEGIN\s*(?:;|TRANSACTION\b)|^\s*PRAGMA\s+foreign_keys\b/im;function RJ(Z){return Z==="postgres"||Z==="sqlite"}async function h2(Z,$){if(Z==="sqlite")return await $();let Y=JZ(),X;try{X=await Y.reserve()}catch{return await $()}let J=!1;try{return await X.advisoryLock(BJ),J=!0,await $()}finally{try{if(J)await X.advisoryUnlock(BJ)}finally{X.release?.()}}}async function dU(Z){await i$();let $=U9(),Y=SJ($),X=y.dialect||"postgres",G=EJ(Y).filter((U)=>U.endsWith(".sql")).sort();if(G.length===0)return XZ("-- No migration files found to execute"),!0;XZ(`-- Found ${G.length} script files to execute`);try{let U=JZ();return await h2(X,async()=>{await NJ(U,X);let H=await p2(U,X),z=G.filter((A)=>!H.includes(A));if(z.length===0)return XZ("-- No pending migrations to execute"),!0;XZ(`-- Executing ${z.length} migration${z.length===1?"":"s"}`);for(let A of z){let W=$8(Y,A);XZ(`-- Executing: ${A}`);try{if(RJ(X)&&!y2.test(Y$(W,"utf-8")))await U.transaction(async(L)=>{await L.file(W),await F7(L,A,X)});else if(await U.file(W),await F7(U,A,X),!RJ(X))XZ(`-- (${X} commits DDL implicitly, so ${A} was not applied atomically)`);else XZ(`-- (${A} contains a statement that cannot run in a transaction, so it was not applied atomically)`);XZ(`-- \u2713 Migration ${A} executed and recorded`)}catch(Q){if(MJ(Y,A)&&x2(Q)){await F7(U,A,X),XZ(`-- \u2713 Migration ${A} was already applied; recorded it (${Q instanceof Error?Q.message:String(Q)})`);continue}throw console.error(`-- \u2717 Migration ${A} failed:`,Q),Q}}return XZ("-- All migrations executed successfully"),!0})}catch(U){throw console.error("-- Migration execution failed:",U),U}return!0}async function mU(Z,$={}){if(await i$(),!Z)Z=$8(p0.cwd(),"app/Models");let Y=$.dialect||y.dialect||"postgres",X=B8(Y),J=U9(),G=async(U)=>{let H=X.dropTable(U);await z0(async(z)=>{if(Y==="sqlite")await z.unsafe("PRAGMA foreign_keys = OFF").execute();if(Y==="mysql"||Y==="vitess")await z.unsafe("SET FOREIGN_KEY_CHECKS = 0").execute();try{await z.unsafe(H).execute()}finally{if(Y==="sqlite")await z.unsafe("PRAGMA foreign_keys = ON").execute();if(Y==="mysql"||Y==="vitess")await z.unsafe("SET FOREIGN_KEY_CHECKS = 1").execute()}})};try{try{await G("migrations"),XZ("-- Dropped migrations table")}catch(z){console.error(z)}let U=[],H=[];try{let z=await Q8({modelsDir:Z}),A=r9(z,{dialect:Y});U=A.tables.map((Q)=>Q.table);let W=new Set;for(let Q of A.tables)for(let L of Q.columns)if(L.type==="enum"&&L.enumValues&&L.enumValues.length>0){let O=`${Q.table}_${L.name}_type`;W.add(O)}H=Array.from(W)}catch(z){console.error(z),U=[],H=[]}if(U.length===0)XZ("-- No tables found to drop");else{XZ(`-- Dropping ${U.length} tables: ${U.join(", ")}`);for(let z of U.reverse())try{await G(z),XZ(`-- Dropped table: ${z}`)}catch(A){console.error(A),XZ(`-- Table ${z} may not exist, skipping drop`)}}if(H.length>0){XZ(`-- Dropping ${H.length} enum types: ${H.join(", ")}`);for(let z of H)try{let A=X.dropEnumType(z);if(A)await z0(async(W)=>{await W.unsafe(A).execute(),XZ(`-- Dropped enum type: ${z}`)})}catch(A){console.error(A),XZ(`-- Enum type ${z} may not exist, skipping drop`)}}else XZ("-- No enum types found to drop");if(U.length>0&&!$.preserveMigrationState)try{await b2(Z,J,$)}catch(z){console.error(z),XZ("-- Could not clean up migration files")}else if(U.length===0)XZ("-- No models directory found; keeping committed migration files in place");else XZ("-- Preserving migration files and model snapshot for fresh replay");if(!$.preserveMigrationState)try{await g2(J)}catch(z){console.error(z),XZ("-- Could not clear generated directory")}return XZ("-- Database reset completed successfully"),!0}catch(U){return console.error("-- Database reset failed:",U),!1}}async function b2(Z,$,Y={}){if(!Z)Z=$8(p0.cwd(),"app/Models");if(!$)$=U9();let X=String(Y.dialect||y.dialect||"postgres"),J=d0($,X);if(y8(J))g0(J),XZ(`-- Removed model snapshot file: ${J}`);let G=$8(Z,`.qb-migrations.${X}.json`),U=String(Y.state||G);if(y8(U))g0(U),XZ(`-- Removed legacy migration state file: ${U}`);f2(T8($,y.migrationDir))}function f2(Z){if(!y8(Z))return;let $=0,Y=[];for(let X of EJ(Z).filter((J)=>J.endsWith(".sql"))){if(!MJ(Z,X)){Y.push(X);continue}g0($8(Z,X)),XZ(`-- Removed generated migration file: ${X}`),$+=1}if(XZ(`-- Cleaned up ${$} generated migration file${$===1?"":"s"} from migrations directory`),Y.length>0)XZ(`-- Kept ${Y.length} hand-written migration${Y.length===1?"":"s"}: ${Y.slice(0,5).join(", ")}${Y.length>5?`, +${Y.length-5} more`:""}`)}async function cj(Z,$){}async function g2(Z){if(!Z)Z=U9();let $=$8(Z,"generated");if(y8($))try{DJ($,{recursive:!0,force:!0}),XZ("-- Cleared generated directory")}catch(Y){console.error("-- Failed to clear generated directory:",Y)}}async function NJ(Z,$){let X=B8($).createMigrationsTable();try{await Z.unsafe(X).execute(),XZ("-- Migrations table ready")}catch(J){throw console.error("-- Failed to create migrations table:",J),J}}async function p2(Z,$){let Y=B8($);try{return(await Z.unsafe(Y.getExecutedMigrationsQuery()).execute()).map((J)=>J.migration)}catch(X){return console.error("-- Failed to get executed migrations:",X),[]}}async function F7(Z,$,Y){let X=B8(Y);try{XZ(`-- Recording migration: ${$}`),await Z.unsafe(X.recordMigrationQuery(),[$]).execute(),XZ(`-- Successfully recorded migration: ${$}`)}catch(J){throw console.error(`-- Failed to record migration ${$}:`,J),J}}
|
|
445
445
|
export{YZ as a,RX as b,y as c,n$ as d,e,NZ as f,i$ as g,DX as h,y4 as i,r5 as j,t5 as k,d9 as l,TX as m,_6 as n,A0 as o,p8 as p,V6 as q,K6 as r,d8 as s,e8 as t,CH as u,F6 as v,vH as w,U8 as x,B6 as y,E6 as z,JZ as A,fX as B,gX as C,P6 as D,T6 as E,q6 as F,pX as G,x6 as H,h6 as I,b6 as J,f6 as K,dX as L,g6 as M,mX as N,cX as O,p6 as P,d6 as Q,uX as R,m6 as S,c6 as T,nX as U,j0 as V,lX as W,Q0 as X,JU as Y,hZ as Z,o$ as _,r$ as $,t$ as aa,e$ as ba,B8 as ca,pU as da,F0 as ea,dU as fa,mU as ga,b2 as ha,cj as ia,g2 as ja,GU as ka,_U as la,X1 as ma,LU as na,G1 as oa,RU as pa,H1 as qa,A1 as ra,Q1 as sa,qU as ta,kU as ua,xU as va,vU as wa,yU as xa,L1 as ya,fU as za,gU as Aa,B1 as Ba,N1 as Ca,O1 as Da,E1 as Ea,Z3 as Fa,$3 as Ga,k1 as Ha,x1 as Ia,Y3 as Ja,X3 as Ka,b1 as La,f1 as Ma,g1 as Na,p1 as Oa,d1 as Pa,T0 as Qa,m1 as Ra,X2 as Sa,i8 as Ta,O8 as Ua,A3 as Va,W3 as Wa,j3 as Xa,c1 as Ya,u1 as Za,n1 as _a,i1 as $a,l1 as ab,V3 as bb,s1 as cb,J2 as db,L3 as eb,F3 as fb,B3 as gb,R3 as hb,o1 as ib,w3 as jb,C3 as kb,S3 as lb,G7 as mb,Q8 as nb,ZJ as ob,zJ as pb,HJ as qb,AJ as rb,WJ as sb,B2 as tb,r9 as ub,L7 as vb,o3 as wb,r3 as xb,_J as yb,y0 as zb,x8 as Ab,h0 as Bb,f0 as Cb,C2 as Db,a3 as Eb,S2 as Fb,Zj as Gb,KJ as Hb,LJ as Ib,FJ as Jb,N2 as Kb,P2 as Lb};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{da as a,ea as b,fa as c,ga as d,ha as e,ia as f,ja as g}from"./chunk-
|
|
2
|
+
import{da as a,ea as b,fa as c,ga as d,ha as e,ia as f,ja as g}from"./chunk-4q37wh0k.js";import"./chunk-asdkg5va.js";import"./chunk-j9778t8e.js";import"./chunk-739qq8wk.js";export{a as saveMigrationSnapshot,d as resetDatabase,b as generateMigration,c as executeMigration,e as deleteMigrationFiles,f as copyModelsToGenerated,g as clearGeneratedDirectory};
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$,$a as hb,A,Aa as za,Ab as _b,B,Ba as Ja,Bb as $b,C,Ca as Ka,Cb as ac,D,Da as La,Db as bc,E,Ea as Ma,Eb as cc,F,Fa as Na,Fb as dc,G,Ga as Oa,Gb as ec,H,Ha as Pa,Hb as fc,I,Ia as Qa,Ib as gc,J,Ja as Ra,Jb as hc,K,Ka as Sa,Kb as ic,L,La as Ta,Lb as jc,M,Ma as Ua,N,Na as Va,O,Oa as Wa,P,Pa as Xa,Q,Qa as Ya,R,Ra as Za,S,Sa as _a,T,Ta as $a,U,Ua as ab,V,Va as bb,W,Wa as cb,X,Xa as db,Y,Ya as eb,Z,Za as fb,_,_a as gb,a,aa,ab as ib,b,ba,bb as jb,c,ca as ea,cb as kb,d,da as fa,db as lb,e,ea as ga,eb as mb,f,fa as ha,fb as nb,g,ga as ia,gb as ob,h,hb as pb,i,ib as qb,j,jb as rb,k,ka as ja,kb as sb,l,la as ka,lb as tb,m,ma as la,mb as Mb,n,na as ma,nb as Nb,o,oa as na,ob as Ob,p,pa as oa,pb as Pb,q,qa as pa,qb as Qb,r,ra as qa,rb as Rb,s,sa as ra,sb as Sb,t,ta as sa,tb as Tb,u,ua as ta,ub as Ub,v,va as ua,vb as Vb,w,wa as va,wb as Wb,x,xa as wa,xb as Xb,y,ya as xa,yb as Yb,z,za as ya,zb as Zb}from"../chunk-
|
|
2
|
+
import{$,$a as hb,A,Aa as za,Ab as _b,B,Ba as Ja,Bb as $b,C,Ca as Ka,Cb as ac,D,Da as La,Db as bc,E,Ea as Ma,Eb as cc,F,Fa as Na,Fb as dc,G,Ga as Oa,Gb as ec,H,Ha as Pa,Hb as fc,I,Ia as Qa,Ib as gc,J,Ja as Ra,Jb as hc,K,Ka as Sa,Kb as ic,L,La as Ta,Lb as jc,M,Ma as Ua,N,Na as Va,O,Oa as Wa,P,Pa as Xa,Q,Qa as Ya,R,Ra as Za,S,Sa as _a,T,Ta as $a,U,Ua as ab,V,Va as bb,W,Wa as cb,X,Xa as db,Y,Ya as eb,Z,Za as fb,_,_a as gb,a,aa,ab as ib,b,ba,bb as jb,c,ca as ea,cb as kb,d,da as fa,db as lb,e,ea as ga,eb as mb,f,fa as ha,fb as nb,g,ga as ia,gb as ob,h,hb as pb,i,ib as qb,j,jb as rb,k,ka as ja,kb as sb,l,la as ka,lb as tb,m,ma as la,mb as Mb,n,na as ma,nb as Nb,o,oa as na,ob as Ob,p,pa as oa,pb as Pb,q,qa as pa,qb as Qb,r,ra as qa,rb as Rb,s,sa as ra,sb as Sb,t,ta as sa,tb as Tb,u,ua as ta,ub as Ub,v,va as ua,vb as Vb,w,wa as va,wb as Wb,x,xa as wa,xb as Xb,y,ya as xa,yb as Yb,z,za as ya,zb as Zb}from"../chunk-4q37wh0k.js";import{Mb as Aa,Nb as Ba,Ob as Ca,Pb as Da,Qb as Ea,Rb as Fa,Sb as Ga,Tb as Ha,Ub as Ia}from"../chunk-asdkg5va.js";import{$b as wb,Xb as ca,Yb as da,Zb as ub,_b as vb,ac as xb,bc as yb,cc as zb,dc as Ab,ec as Bb,fc as Cb,gc as Db,hc as Eb,ic as Fb,jc as Gb,kc as Hb,lc as Ib,mc as Jb,nc as Kb,oc as Lb}from"../chunk-j9778t8e.js";import"../chunk-739qq8wk.js";export{O as wipeDatabase,za as waitReady,xa as validateSchema,wa as unsafe,pb as unmarshallItem,o as toTableName,nb as toModelInstance,mb as toDynamoDBItem,v as toDialectPlaceholders,H as tinker,y as temporalLiteral,p as tableNameFor,S as tableInfo,q as stripTrailingS,G as startConsole,tb as stacksModelToEntity,U as sqlTypeToAttr,va as sql,s as singularizerFor,na as showModel,C as setQueryCacheMaxSize,h as setConfig,Sa as seedModel,fa as saveMigrationSnapshot,hc as satisfies,ra as runSeeders,sa as runSeeder,n as runBenchmark,k as resolveSqlitePragmas,t as resolvePivot,kb as resolveKeyPattern,d as resolveDialect,ia as resetDatabase,m as resetConnection,qa as relationDiagram,Ya as registerModel,_a as registerBrowserModels,w as raw,x as quoteColumnForDialect,pa as queryExplainAll,oa as ping,lb as parseStacksModels,N as optimizeDatabase,na as modelShow,V as modelNameForTable,Sb as migrationBody,la as migrateStatus,ka as migrateRollback,Ib as migrateModels,ma as migrateList,ja as migrateGenerate,ob as marshallObject,ta as makeSeeder,Y as makeModel,Nb as loadModels,Pb as lastCreatedMigrationFiles,u as iterateAllPivots,a as isMysqlLike,Tb as isLosslessTypeChange,Rb as isGeneratedMigrationSql,Db as isDefinitionEqual,Ca as isBrowser,X as introspectDatabase,T as introspect,R as inspectTable,r as inflectSingular,J as importData,yb as hashTableDefinition,Yb as hashMigrationPlan,Wa as hasModel,f as getPlaceholders,e as getPlaceholder,Va as getModelRegistry,Ta as getModel,ea as getDialectDriver,Oa as getDatabase,g as getConfig,Ba as getBrowserConfig,Ua as getAllModels,Wb as generateSqlString,Vb as generateSql,W as generateModelSource,ga as generateMigration,Xb as generateDiffSqlString,bc as generateDiffSql,ac as generateDiffOperations,qa as generateDiagram,sb as generateAccessPatterns,ua as freshDatabase,jc as formatSchemaDrift,Q as file,gc as familyOfSqlType,fc as familyOfDeclared,zb as extractTableDefinition,Ab as extractModelSchema,Ma as extractInsertId,La as extractChanges,I as exportData,pa as explainAllQueries,P as explain,ha as executeMigration,z as escapeStringLiteral,Kb as dynamo,K as dumpDatabase,ec as defineSeeder,cc as defineModels,Za as defineModel,i as defineConfig,b as defaultConfig,O as dbWipe,M as dbStats,N as dbOptimize,L as dbInfo,Ra as createTableFromModel,hb as createSingleTableManager,ib as createRepository,A as createQueryBuilder,Qa as createModel,Hb as createMigrationDriver,Ja as createFakerCompatLayer,rb as createDynamoDBToolingAdapter,bb as createDynamoDBQueryBuilder,cb as createDynamoDBItemBuilder,da as createDynamoDBDriver,db as createDynamoDBClient,Lb as createDynamo,vb as createClient,Ha as createBrowserModel,Ga as createBrowserDb,Bb as convertSchemaToDefinition,Na as configureOrm,wb as configureModels,Aa as configureBrowser,c as config,B as clearQueryCache,Xa as clearModelRegistry,Ka as clearLocalModels,ya as checkSchema,$b as canonicalizeDefault,Zb as canonicalStorageType,E as cacheStats,F as cacheConfig,D as cacheClear,Ob as buildSchemaMeta,Ub as buildMigrationPlan,Cb as buildDynamoDBMigrationPlan,Mb as buildDatabaseSchema,Fa as browserQuery,Ia as browserAuth,ic as auditSchemaDrift,l as applySqliteBootstrapPragmas,aa as VitessDriver,_b as UTC_CLOCK_DEFAULT,fb as SingleTableRepository,gb as SingleTableQueryBuilder,jb as SingleTablePatterns,eb as SingleTableManager,$ as SingleStoreDriver,dc as Seeder,ba as SQLiteDriver,_ as PostgresDriver,Z as MySQLDriver,xb as Model,Eb as MIGRATIONS_TABLE,Qb as GENERATED_MARKER,Jb as EntityQueryBuilder,qb as DynamoDBToolingAdapter,$a as DynamoDBQueryBuilder,Fb as DynamoDBMigrationTracker,Gb as DynamoDBMigrationDriver,ab as DynamoDBItemBuilder,ca as DynamoDBDriverImpl,ub as DynamoDBClient,j as DEFAULT_SQLITE_PRAGMAS,Da as BrowserQueryError,Ea as BrowserQueryBuilder,Pa as BelongsToManyRelationBuilder};
|
package/package.json
CHANGED