9 lines
79 KiB
JavaScript
9 lines
79 KiB
JavaScript
// @bun
|
|
var S$=Object.defineProperty;var v$=($,X)=>{for(var Y in X)S$($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(Z)=>X[Y]=()=>Z})};var{SQL:T0}=globalThis.Bun;var G=Symbol.for("drizzle:entityKind"),a$=Symbol.for("drizzle:hasOwnEntityKind");function z($,X){if(!$||typeof $!=="object")return!1;if($ instanceof X)return!0;if(!Object.prototype.hasOwnProperty.call(X,G))throw new Error(`Class "${X.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let Y=Object.getPrototypeOf($).constructor;if(Y)while(Y){if(G in Y&&Y[G]===X[G])return!0;Y=Object.getPrototypeOf(Y)}return!1}class S0{static[G]="ConsoleLogWriter";write($){console.log($)}}class i2{static[G]="DefaultLogger";writer;constructor($){this.writer=$?.writer??new S0}logQuery($,X){let Y=X.map((_)=>{try{return JSON.stringify(_)}catch{return String(_)}}),Z=Y.length?` -- params: [${Y.join(", ")}]`:"";this.writer.write(`Query: ${$}${Z}`)}}class l2{static[G]="NoopLogger";logQuery(){}}class f{static[G]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((X)=>{return $?.(),X},(X)=>{throw $?.(),X})}then($,X){return this.execute().then($,X)}}class N{constructor($,X){this.table=$,this.config=X,this.name=X.name,this.keyAsName=X.keyAsName,this.notNull=X.notNull,this.default=X.default,this.defaultFn=X.defaultFn,this.onUpdateFn=X.onUpdateFn,this.hasDefault=X.hasDefault,this.primary=X.primaryKey,this.isUnique=X.isUnique,this.uniqueName=X.uniqueName,this.uniqueType=X.uniqueType,this.dataType=X.dataType,this.columnType=X.columnType,this.generated=X.generated,this.generatedIdentity=X.generatedIdentity}static[G]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class a2{static[G]="ColumnBuilder";config;constructor($,X,Y){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:X,columnType:Y,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var t=Symbol.for("drizzle:Name");class e2{static[G]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor($,X){if(this.reference=()=>{let{name:Y,columns:Z,foreignColumns:_}=$();return{name:Y,columns:Z,foreignTable:_[0].table,foreignColumns:_}},X)this._onUpdate=X.onUpdate,this._onDelete=X.onDelete}onUpdate($){return this._onUpdate=$===void 0?"no action":$,this}onDelete($){return this._onDelete=$===void 0?"no action":$,this}build($){return new v0($,this)}}class v0{constructor($,X){this.table=$,this.reference=X.reference,this.onUpdate=X._onUpdate,this.onDelete=X._onDelete}static[G]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:X,foreignColumns:Y}=this.reference(),Z=X.map((E)=>E.name),_=Y.map((E)=>E.name),W=[this.table[t],...Z,Y[0].table[t],..._];return $??`${W.join("_")}_fk`}}function N2($,...X){return $(...X)}function B0($){return new C0($)}function $0($,X){return`${$[t]}_${X.join("_")}_unique`}class h0{constructor($,X){this.name=X,this.columns=$}static[G]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build($){return new q0($,this.columns,this.nullsNotDistinctConfig,this.name)}}class C0{static[G]="PgUniqueOnConstraintBuilder";name;constructor($){this.name=$}on(...$){return new h0($,this.name)}}class q0{constructor($,X,Y,Z){this.table=$,this.columns=X,this.name=Z??$0(this.table,this.columns.map((_)=>_.name)),this.nullsNotDistinct=Y}static[G]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function P0($,X,Y){for(let Z=X;Z<$.length;Z++){let _=$[Z];if(_==="\\"){Z++;continue}if(_==='"')return[$.slice(X,Z).replace(/\\/g,""),Z+1];if(Y)continue;if(_===","||_==="}")return[$.slice(X,Z).replace(/\\/g,""),Z]}return[$.slice(X).replace(/\\/g,""),$.length]}function p0($,X=0){let Y=[],Z=X,_=!1;while(Z<$.length){let W=$[Z];if(W===","){if(_||Z===X)Y.push("");_=!0,Z++;continue}if(_=!1,W==="\\"){Z+=2;continue}if(W==='"'){let[D,H]=P0($,Z+1,!0);Y.push(D),Z=H;continue}if(W==="}")return[Y,Z+1];if(W==="{"){let[D,H]=p0($,Z+1);Y.push(D),Z=H;continue}let[E,F]=P0($,Z,!1);Y.push(E),Z=F}return[Y,Z]}function y0($){let[X]=p0($,1);return X}function X0($){return`{${$.map((X)=>{if(Array.isArray(X))return X0(X);if(typeof X==="string")return`"${X.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${X}`}).join(",")}}`}class M extends a2{foreignKeyConfigs=[];static[G]="PgColumnBuilder";array($){return new b0(this.config.name,this,$)}references($,X={}){return this.foreignKeyConfigs.push({ref:$,actions:X}),this}unique($,X){return this.config.isUnique=!0,this.config.uniqueName=$,this.config.uniqueType=X?.nulls,this}generatedAlwaysAs($){return this.config.generated={as:$,type:"always",mode:"stored"},this}buildForeignKeys($,X){return this.foreignKeyConfigs.map(({ref:Y,actions:Z})=>{return N2((_,W)=>{let E=new e2(()=>{let F=_();return{columns:[$],foreignColumns:[F]}});if(W.onUpdate)E.onUpdate(W.onUpdate);if(W.onDelete)E.onDelete(W.onDelete);return E.build(X)},Y,Z)})}buildExtraConfigColumn($){return new f0($,this.config)}}class O extends N{constructor($,X){if(!X.uniqueName)X.uniqueName=$0($,[X.name]);super($,X);this.table=$}static[G]="PgColumn"}class f0 extends O{static[G]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class b0 extends M{static[G]="PgArrayBuilder";constructor($,X,Y){super($,"array","PgArray");this.config.baseBuilder=X,this.config.size=Y}build($){let X=this.config.baseBuilder.build($);return new Y0($,this.config,X)}}class Y0 extends O{constructor($,X,Y,Z){super($,X);this.baseColumn=Y,this.range=Z,this.size=X.size}size;static[G]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue($){if(typeof $==="string")$=y0($);return $.map((X)=>this.baseColumn.mapFromDriverValue(X))}mapToDriverValue($,X=!1){let Y=$.map((Z)=>Z===null?null:z(this.baseColumn,Y0)?this.baseColumn.mapToDriverValue(Z,!0):this.baseColumn.mapToDriverValue(Z));if(X)return Y;return X0(Y)}}var d0=Symbol.for("drizzle:isPgEnum");function m0($){return!!$&&typeof $==="function"&&d0 in $&&$[d0]===!0}class B$ extends O{static[G]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,X){super($,X);this.enum=X.enum}getSQLType(){return this.enum.enumName}}class B{static[G]="Subquery";constructor($,X,Y,Z=!1){this._={brand:"Subquery",sql:$,selectedFields:X,alias:Y,isWith:Z}}}class D2 extends B{static[G]="WithSubquery"}var g0="0.41.0";var Z0,_0,k={startActiveSpan($,X){if(!Z0)return X();if(!_0)_0=Z0.trace.getTracer("drizzle-orm",g0);return N2((Y,Z)=>Z.startActiveSpan($,(_)=>{try{return X(_)}catch(W){throw _.setStatus({code:Y.SpanStatusCode.ERROR,message:W instanceof Error?W.message:"Unknown error"}),W}finally{_.end()}}),Z0,_0)}};var T=Symbol.for("drizzle:ViewBaseConfig");var k2=Symbol.for("drizzle:Schema"),T2=Symbol.for("drizzle:Columns"),c0=Symbol.for("drizzle:ExtraConfigColumns"),G0=Symbol.for("drizzle:OriginalName"),J0=Symbol.for("drizzle:BaseName"),O2=Symbol.for("drizzle:IsAlias"),u0=Symbol.for("drizzle:ExtraConfigBuilder"),h$=Symbol.for("drizzle:IsDrizzleTable");class V{static[G]="Table";static Symbol={Name:t,Schema:k2,OriginalName:G0,Columns:T2,ExtraConfigColumns:c0,BaseName:J0,IsAlias:O2,ExtraConfigBuilder:u0};[t];[G0];[k2];[T2];[c0];[J0];[O2]=!1;[h$]=!0;[u0]=void 0;constructor($,X,Y){this[t]=this[G0]=$,this[k2]=X,this[J0]=Y}}function m($){return $[t]}function G2($){return`${$[k2]??"public"}.${$[t]}`}function W0($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function C$($){let X={sql:"",params:[]};for(let Y of $)if(X.sql+=Y.sql,X.params.push(...Y.params),Y.typings?.length){if(!X.typings)X.typings=[];X.typings.push(...Y.typings)}return X}class h{static[G]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new x([this])}}class x{constructor($){this.queryChunks=$}static[G]="SQL";decoder=r0;shouldInlineParams=!1;append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return k.startActiveSpan("drizzle.buildSQL",(X)=>{let Y=this.buildQueryFromSourceParams(this.queryChunks,$);return X?.setAttributes({"drizzle.query.text":Y.sql,"drizzle.query.params":JSON.stringify(Y.params)}),Y})}buildQueryFromSourceParams($,X){let Y=Object.assign({},X,{inlineParams:X.inlineParams||this.shouldInlineParams,paramStartIndex:X.paramStartIndex||{value:0}}),{casing:Z,escapeName:_,escapeParam:W,prepareTyping:E,inlineParams:F,paramStartIndex:D}=Y;return C$($.map((H)=>{if(z(H,h))return{sql:H.value.join(""),params:[]};if(z(H,j2))return{sql:_(H.value),params:[]};if(H===void 0)return{sql:"",params:[]};if(Array.isArray(H)){let U=[new h("(")];for(let[A,Q]of H.entries())if(U.push(Q),A<H.length-1)U.push(new h(", "));return U.push(new h(")")),this.buildQueryFromSourceParams(U,Y)}if(z(H,x))return this.buildQueryFromSourceParams(H.queryChunks,{...Y,inlineParams:F||H.shouldInlineParams});if(z(H,V)){let U=H[V.Symbol.Schema],A=H[V.Symbol.Name];return{sql:U===void 0||H[O2]?_(A):_(U)+"."+_(A),params:[]}}if(z(H,N)){let U=Z.getColumnCasing(H);if(X.invokeSource==="indexes")return{sql:_(U),params:[]};let A=H.table[V.Symbol.Schema];return{sql:H.table[O2]||A===void 0?_(H.table[V.Symbol.Name])+"."+_(U):_(A)+"."+_(H.table[V.Symbol.Name])+"."+_(U),params:[]}}if(z(H,g)){let U=H[T].schema,A=H[T].name;return{sql:U===void 0||H[T].isAlias?_(A):_(U)+"."+_(A),params:[]}}if(z(H,o)){if(z(H.value,X2))return{sql:W(D.value++,H),params:[H],typings:["none"]};let U=H.value===null?null:H.encoder.mapToDriverValue(H.value);if(z(U,x))return this.buildQueryFromSourceParams([U],Y);if(F)return{sql:this.mapInlineParam(U,Y),params:[]};let A=["none"];if(E)A=[E(H.encoder)];return{sql:W(D.value++,U),params:[U],typings:A}}if(z(H,X2))return{sql:W(D.value++,H),params:[H],typings:["none"]};if(z(H,x.Aliased)&&H.fieldAlias!==void 0)return{sql:_(H.fieldAlias),params:[]};if(z(H,B)){if(H._.isWith)return{sql:_(H._.alias),params:[]};return this.buildQueryFromSourceParams([new h("("),H._.sql,new h(") "),new j2(H._.alias)],Y)}if(m0(H)){if(H.schema)return{sql:_(H.schema)+"."+_(H.enumName),params:[]};return{sql:_(H.enumName),params:[]}}if(W0(H)){if(H.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([H.getSQL()],Y);return this.buildQueryFromSourceParams([new h("("),H.getSQL(),new h(")")],Y)}if(F)return{sql:this.mapInlineParam(H,Y),params:[]};return{sql:W(D.value++,H),params:[H],typings:["none"]}}))}mapInlineParam($,{escapeString:X}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return X($);if(typeof $==="object"){let Y=$.toString();if(Y==="[object Object]")return X(JSON.stringify($));return X(Y)}throw new Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new x.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class j2{constructor($){this.value=$}static[G]="Name";brand;getSQL(){return new x([this])}}function o0($){return typeof $==="object"&&$!==null&&"mapToDriverValue"in $&&typeof $.mapToDriverValue==="function"}var r0={mapFromDriverValue:($)=>$},t0={mapToDriverValue:($)=>$},oX={...r0,...t0};class o{constructor($,X=t0){this.value=$,this.encoder=X}static[G]="Param";brand;getSQL(){return new x([this])}}function J($,...X){let Y=[];if(X.length>0||$.length>0&&$[0]!=="")Y.push(new h($[0]));for(let[Z,_]of X.entries())Y.push(_,new h($[Z+1]));return new x(Y)}(($)=>{function X(){return new x([])}$.empty=X;function Y(D){return new x(D)}$.fromList=Y;function Z(D){return new x([new h(D)])}$.raw=Z;function _(D,H){let U=[];for(let[A,Q]of D.entries()){if(A>0&&H!==void 0)U.push(H);U.push(Q)}return new x(U)}$.join=_;function W(D){return new j2(D)}$.identifier=W;function E(D){return new X2(D)}$.placeholder=E;function F(D,H){return new o(D,H)}$.param=F})(J||(J={}));(($)=>{class X{constructor(Y,Z){this.sql=Y,this.fieldAlias=Z}static[G]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new X(this.sql,this.fieldAlias)}}$.Aliased=X})(x||(x={}));class X2{constructor($){this.name=$}static[G]="Placeholder";getSQL(){return new x([this])}}function H0($,X){return $.map((Y)=>{if(z(Y,X2)){if(!(Y.name in X))throw new Error(`No value for placeholder "${Y.name}" was provided`);return X[Y.name]}if(z(Y,o)&&z(Y.value,X2)){if(!(Y.value.name in X))throw new Error(`No value for placeholder "${Y.value.name}" was provided`);return Y.encoder.mapToDriverValue(X[Y.value.name])}return Y})}var q$=Symbol.for("drizzle:IsDrizzleView");class g{static[G]="View";[T];[q$]=!0;constructor({name:$,schema:X,selectedFields:Y,query:Z}){this[T]={name:$,originalName:$,schema:X,selectedFields:Y,query:Z,isExisting:!Z,isAlias:!1}}getSQL(){return new x([this])}}N.prototype.getSQL=function(){return new x([this])};V.prototype.getSQL=function(){return new x([this])};B.prototype.getSQL=function(){return new x([this])};class H2{constructor($){this.table=$}static[G]="ColumnAliasProxyHandler";get($,X){if(X==="table")return this.table;return $[X]}}class U2{constructor($,X){this.alias=$,this.replaceOriginalName=X}static[G]="TableAliasProxyHandler";get($,X){if(X===V.Symbol.IsAlias)return!0;if(X===V.Symbol.Name)return this.alias;if(this.replaceOriginalName&&X===V.Symbol.OriginalName)return this.alias;if(X===T)return{...$[T],name:this.alias,isAlias:!0};if(X===V.Symbol.Columns){let Z=$[V.Symbol.Columns];if(!Z)return Z;let _={};return Object.keys(Z).map((W)=>{_[W]=new Proxy(Z[W],new H2(new Proxy($,this)))}),_}let Y=$[X];if(z(Y,N))return new Proxy(Y,new H2(new Proxy($,this)));return Y}}function S2($,X){return new Proxy($,new U2(X,!1))}function s($,X){return new Proxy($,new H2(new Proxy($.table,new U2(X,!1))))}function E0($,X){return new x.Aliased(V2($.sql,X),$.fieldAlias)}function V2($,X){return J.join($.queryChunks.map((Y)=>{if(z(Y,N))return s(Y,X);if(z(Y,x))return V2(Y,X);if(z(Y,x.Aliased))return E0(Y,X);return Y}))}class S{static[G]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,X){if(X==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(X===T)return{...$[T],selectedFields:new Proxy($[T].selectedFields,this)};if(typeof X==="symbol")return $[X];let Z=(z($,B)?$._.selectedFields:z($,g)?$[T].selectedFields:$)[X];if(z(Z,x.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!Z.isSelectionField)return Z.sql;let _=Z.clone();return _.isSelectionField=!0,_}if(z(Z,x)){if(this.config.sqlBehavior==="sql")return Z;throw new Error(`You tried to reference "${X}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(z(Z,N)){if(this.config.alias)return new Proxy(Z,new H2(new Proxy(Z.table,new U2(this.config.alias,this.config.replaceOriginalName??!1))));return Z}if(typeof Z!=="object"||Z===null)return Z;return new Proxy(Z,new S(this.config))}}function s0($,X,Y){let Z={},_=$.reduce((W,{path:E,field:F},D)=>{let H;if(z(F,N))H=F;else if(z(F,x))H=F.decoder;else H=F.sql.decoder;let U=W;for(let[A,Q]of E.entries())if(A<E.length-1){if(!(Q in U))U[Q]={};U=U[Q]}else{let K=X[D],v=U[Q]=K===null?null:H.mapFromDriverValue(K);if(Y&&z(F,N)&&E.length===2){let j=E[0];if(!(j in Z))Z[j]=v===null?m(F.table):!1;else if(typeof Z[j]==="string"&&Z[j]!==m(F.table))Z[j]=!1}}return W},{});if(Y&&Object.keys(Z).length>0){for(let[W,E]of Object.entries(Z))if(typeof E==="string"&&!Y[E])_[W]=null}return _}function r($,X){return Object.entries($).reduce((Y,[Z,_])=>{if(typeof Z!=="string")return Y;let W=X?[...X,Z]:[Z];if(z(_,N)||z(_,x)||z(_,x.Aliased))Y.push({path:W,field:_});else if(z(_,V))Y.push(...r(_[V.Symbol.Columns],W));else Y.push(...r(_,W));return Y},[])}function x2($,X){let Y=Object.keys($),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let[_,W]of Y.entries())if(W!==Z[_])return!1;return!0}function v2($,X){let Y=Object.entries(X).filter(([,Z])=>Z!==void 0).map(([Z,_])=>{if(z(_,x)||z(_,N))return[Z,_];else return[Z,new o(_,$[V.Symbol.Columns][Z])]});if(Y.length===0)throw new Error("No values to set");return Object.fromEntries(Y)}function n0($,X){for(let Y of X)for(let Z of Object.getOwnPropertyNames(Y.prototype)){if(Z==="constructor")continue;Object.defineProperty($.prototype,Z,Object.getOwnPropertyDescriptor(Y.prototype,Z)||Object.create(null))}}function i0($){return $[V.Symbol.Columns]}function i($){return z($,B)?$._.alias:z($,g)?$[T].name:z($,x)?void 0:$[V.Symbol.IsAlias]?$[V.Symbol.Name]:$[V.Symbol.BaseName]}function R($,X){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:X}}function l0($){if(typeof $!=="object"||$===null)return!1;if($.constructor.name!=="Object")return!1;if("logger"in $){let X=typeof $.logger;if(X!=="boolean"&&(X!=="object"||typeof $.logger.logQuery!=="function")&&X!=="undefined")return!1;return!0}if("schema"in $){let X=typeof $.schema;if(X!=="object"&&X!=="undefined")return!1;return!0}if("casing"in $){let X=typeof $.casing;if(X!=="string"&&X!=="undefined")return!1;return!0}if("mode"in $){if($.mode!=="default"||$.mode!=="planetscale"||$.mode!==void 0)return!1;return!0}if("connection"in $){let X=typeof $.connection;if(X!=="string"&&X!=="object"&&X!=="undefined")return!1;return!0}if("client"in $){let X=typeof $.client;if(X!=="object"&&X!=="function"&&X!=="undefined")return!1;return!0}if(Object.keys($).length===0)return!0;return!1}class B2 extends f{constructor($,X,Y,Z){super();this.session=X,this.dialect=Y,this.config={table:$,withList:Z}}static[G]="PgDelete";config;where($){return this.config.where=$,this}returning($=this.config.table[V.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=r($),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new S({alias:m(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}function P$($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((Y)=>Y.toLowerCase()).join("_")}function p$($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((Y,Z,_)=>{let W=_===0?Z.toLowerCase():`${Z[0].toUpperCase()}${Z.slice(1)}`;return Y+W},"")}function y$($){return $}class z0{static[G]="CasingCache";cache={};cachedTables={};convert;constructor($){this.convert=$==="snake_case"?P$:$==="camelCase"?p$:y$}getColumnCasing($){if(!$.keyAsName)return $.name;let X=$.table[V.Symbol.Schema]??"public",Y=$.table[V.Symbol.OriginalName],Z=`${X}.${Y}.${$.name}`;if(!this.cache[Z])this.cacheTable($.table);return this.cache[Z]}cacheTable($){let X=$[V.Symbol.Schema]??"public",Y=$[V.Symbol.OriginalName],Z=`${X}.${Y}`;if(!this.cachedTables[Z]){for(let _ of Object.values($[V.Symbol.Columns])){let W=`${Z}.${_.name}`;this.cache[W]=this.convert(_.name)}this.cachedTables[Z]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class h2 extends Error{static[G]="DrizzleError";constructor({message:$,cause:X}){super($);this.name="DrizzleError",this.cause=X}}class F0 extends h2{static[G]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class Y2 extends M{static[G]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity($){if($){let{name:X,...Y}=$;this.config.generatedIdentity={type:"always",sequenceName:X,sequenceOptions:Y}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity($){if($){let{name:X,...Y}=$;this.config.generatedIdentity={type:"byDefault",sequenceName:X,sequenceOptions:Y}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class a0 extends Y2{static[G]="PgBigInt53Builder";constructor($){super($,"number","PgBigInt53")}build($){return new e0($,this.config)}}class e0 extends O{static[G]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class $1 extends Y2{static[G]="PgBigInt64Builder";constructor($){super($,"bigint","PgBigInt64")}build($){return new X1($,this.config)}}class X1 extends O{static[G]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue($){return BigInt($)}}function Y1($,X){let{name:Y,config:Z}=R($,X);if(Z.mode==="number")return new a0(Y);return new $1(Y)}class Z1 extends M{static[G]="PgBigSerial53Builder";constructor($){super($,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new _1($,this.config)}}class _1 extends O{static[G]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class G1 extends M{static[G]="PgBigSerial64Builder";constructor($){super($,"bigint","PgBigSerial64");this.config.hasDefault=!0}build($){return new J1($,this.config)}}class J1 extends O{static[G]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue($){return BigInt($)}}function W1($,X){let{name:Y,config:Z}=R($,X);if(Z.mode==="number")return new Z1(Y);return new G1(Y)}class H1 extends M{static[G]="PgBooleanBuilder";constructor($){super($,"boolean","PgBoolean")}build($){return new E1($,this.config)}}class E1 extends O{static[G]="PgBoolean";getSQLType(){return"boolean"}}function z1($){return new H1($??"")}class F1 extends M{static[G]="PgCharBuilder";constructor($,X){super($,"string","PgChar");this.config.length=X.length,this.config.enumValues=X.enum}build($){return new D1($,this.config)}}class D1 extends O{static[G]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function O1($,X={}){let{name:Y,config:Z}=R($,X);return new F1(Y,Z)}class U1 extends M{static[G]="PgCidrBuilder";constructor($){super($,"string","PgCidr")}build($){return new V1($,this.config)}}class V1 extends O{static[G]="PgCidr";getSQLType(){return"cidr"}}function x1($){return new U1($??"")}class M1 extends M{static[G]="PgCustomColumnBuilder";constructor($,X,Y){super($,"custom","PgCustomColumn");this.config.fieldConfig=X,this.config.customTypeParams=Y}build($){return new A1($,this.config)}}class A1 extends O{static[G]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor($,X){super($,X);this.sqlName=X.customTypeParams.dataType(X.fieldConfig),this.mapTo=X.customTypeParams.toDriver,this.mapFrom=X.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function Q1($){return(X,Y)=>{let{name:Z,config:_}=R(X,Y);return new M1(Z,_,$)}}class l extends M{static[G]="PgDateColumnBaseBuilder";defaultNow(){return this.default(J`now()`)}}class I1 extends l{static[G]="PgDateBuilder";constructor($){super($,"date","PgDate")}build($){return new C2($,this.config)}}class C2 extends O{static[G]="PgDate";getSQLType(){return"date"}mapFromDriverValue($){return new Date($)}mapToDriverValue($){return $.toISOString()}}class R1 extends l{static[G]="PgDateStringBuilder";constructor($){super($,"string","PgDateString")}build($){return new q2($,this.config)}}class q2 extends O{static[G]="PgDateString";getSQLType(){return"date"}}function w1($,X){let{name:Y,config:Z}=R($,X);if(Z?.mode==="date")return new I1(Y);return new R1(Y)}class K1 extends M{static[G]="PgDoublePrecisionBuilder";constructor($){super($,"number","PgDoublePrecision")}build($){return new L1($,this.config)}}class L1 extends O{static[G]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue($){if(typeof $==="string")return Number.parseFloat($);return $}}function E2($){return new K1($??"")}class N1 extends M{static[G]="PgInetBuilder";constructor($){super($,"string","PgInet")}build($){return new k1($,this.config)}}class k1 extends O{static[G]="PgInet";getSQLType(){return"inet"}}function T1($){return new N1($??"")}class j1 extends Y2{static[G]="PgIntegerBuilder";constructor($){super($,"number","PgInteger")}build($){return new S1($,this.config)}}class S1 extends O{static[G]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue($){if(typeof $==="string")return Number.parseInt($);return $}}function Z2($){return new j1($??"")}class v1 extends M{static[G]="PgIntervalBuilder";constructor($,X){super($,"string","PgInterval");this.config.intervalConfig=X}build($){return new B1($,this.config)}}class B1 extends O{static[G]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let $=this.fields?` ${this.fields}`:"",X=this.precision?`(${this.precision})`:"";return`interval${$}${X}`}}function h1($,X={}){let{name:Y,config:Z}=R($,X);return new v1(Y,Z)}class C1 extends M{static[G]="PgJsonBuilder";constructor($){super($,"json","PgJson")}build($){return new P2($,this.config)}}class P2 extends O{static[G]="PgJson";constructor($,X){super($,X)}getSQLType(){return"json"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function q1($){return new C1($??"")}class P1 extends M{static[G]="PgJsonbBuilder";constructor($){super($,"json","PgJsonb")}build($){return new p2($,this.config)}}class p2 extends O{static[G]="PgJsonb";constructor($,X){super($,X)}getSQLType(){return"jsonb"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function p1($){return new P1($??"")}class y1 extends M{static[G]="PgLineBuilder";constructor($){super($,"array","PgLine")}build($){return new f1($,this.config)}}class f1 extends O{static[G]="PgLine";getSQLType(){return"line"}mapFromDriverValue($){let[X,Y,Z]=$.slice(1,-1).split(",");return[Number.parseFloat(X),Number.parseFloat(Y),Number.parseFloat(Z)]}mapToDriverValue($){return`{${$[0]},${$[1]},${$[2]}}`}}class b1 extends M{static[G]="PgLineABCBuilder";constructor($){super($,"json","PgLineABC")}build($){return new d1($,this.config)}}class d1 extends O{static[G]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue($){let[X,Y,Z]=$.slice(1,-1).split(",");return{a:Number.parseFloat(X),b:Number.parseFloat(Y),c:Number.parseFloat(Z)}}mapToDriverValue($){return`{${$.a},${$.b},${$.c}}`}}function m1($,X){let{name:Y,config:Z}=R($,X);if(!Z?.mode||Z.mode==="tuple")return new y1(Y);return new b1(Y)}class g1 extends M{static[G]="PgMacaddrBuilder";constructor($){super($,"string","PgMacaddr")}build($){return new c1($,this.config)}}class c1 extends O{static[G]="PgMacaddr";getSQLType(){return"macaddr"}}function u1($){return new g1($??"")}class o1 extends M{static[G]="PgMacaddr8Builder";constructor($){super($,"string","PgMacaddr8")}build($){return new r1($,this.config)}}class r1 extends O{static[G]="PgMacaddr8";getSQLType(){return"macaddr8"}}function t1($){return new o1($??"")}class s1 extends M{static[G]="PgNumericBuilder";constructor($,X,Y){super($,"string","PgNumeric");this.config.precision=X,this.config.scale=Y}build($){return new y2($,this.config)}}class y2 extends O{static[G]="PgNumeric";precision;scale;constructor($,X){super($,X);this.precision=X.precision,this.scale=X.scale}mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class n1 extends M{static[G]="PgNumericNumberBuilder";constructor($,X,Y){super($,"number","PgNumericNumber");this.config.precision=X,this.config.scale=Y}build($){return new i1($,this.config)}}class i1 extends O{static[G]="PgNumericNumber";precision;scale;constructor($,X){super($,X);this.precision=X.precision,this.scale=X.scale}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class l1 extends M{static[G]="PgNumericBigIntBuilder";constructor($,X,Y){super($,"bigint","PgNumericBigInt");this.config.precision=X,this.config.scale=Y}build($){return new a1($,this.config)}}class a1 extends O{static[G]="PgNumericBigInt";precision;scale;constructor($,X){super($,X);this.precision=X.precision,this.scale=X.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function e1($,X){let{name:Y,config:Z}=R($,X),_=Z?.mode;return _==="number"?new n1(Y,Z?.precision,Z?.scale):_==="bigint"?new l1(Y,Z?.precision,Z?.scale):new s1(Y,Z?.precision,Z?.scale)}class $8 extends M{static[G]="PgPointTupleBuilder";constructor($){super($,"array","PgPointTuple")}build($){return new X8($,this.config)}}class X8 extends O{static[G]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[X,Y]=$.slice(1,-1).split(",");return[Number.parseFloat(X),Number.parseFloat(Y)]}return[$.x,$.y]}mapToDriverValue($){return`(${$[0]},${$[1]})`}}class Y8 extends M{static[G]="PgPointObjectBuilder";constructor($){super($,"json","PgPointObject")}build($){return new Z8($,this.config)}}class Z8 extends O{static[G]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[X,Y]=$.slice(1,-1).split(",");return{x:Number.parseFloat(X),y:Number.parseFloat(Y)}}return $}mapToDriverValue($){return`(${$.x},${$.y})`}}function _8($,X){let{name:Y,config:Z}=R($,X);if(!Z?.mode||Z.mode==="tuple")return new $8(Y);return new Y8(Y)}function f$($){let X=[];for(let Y=0;Y<$.length;Y+=2)X.push(Number.parseInt($.slice(Y,Y+2),16));return new Uint8Array(X)}function G8($,X){let Y=new ArrayBuffer(8),Z=new DataView(Y);for(let _=0;_<8;_++)Z.setUint8(_,$[X+_]);return Z.getFloat64(0,!0)}function D0($){let X=f$($),Y=0,Z=X[Y];Y+=1;let _=new DataView(X.buffer),W=_.getUint32(Y,Z===1);Y+=4;let E;if(W&536870912)E=_.getUint32(Y,Z===1),Y+=4;if((W&65535)===1){let F=G8(X,Y);Y+=8;let D=G8(X,Y);return Y+=8,[F,D]}throw new Error("Unsupported geometry type")}class J8 extends M{static[G]="PgGeometryBuilder";constructor($){super($,"array","PgGeometry")}build($){return new W8($,this.config)}}class W8 extends O{static[G]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue($){return D0($)}mapToDriverValue($){return`point(${$[0]} ${$[1]})`}}class H8 extends M{static[G]="PgGeometryObjectBuilder";constructor($){super($,"json","PgGeometryObject")}build($){return new E8($,this.config)}}class E8 extends O{static[G]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue($){let X=D0($);return{x:X[0],y:X[1]}}mapToDriverValue($){return`point(${$.x} ${$.y})`}}function z8($,X){let{name:Y,config:Z}=R($,X);if(!Z?.mode||Z.mode==="tuple")return new J8(Y);return new H8(Y)}class F8 extends M{static[G]="PgRealBuilder";constructor($,X){super($,"number","PgReal");this.config.length=X}build($){return new D8($,this.config)}}class D8 extends O{static[G]="PgReal";constructor($,X){super($,X)}getSQLType(){return"real"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number.parseFloat($);return $}}function O8($){return new F8($??"")}class U8 extends M{static[G]="PgSerialBuilder";constructor($){super($,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new V8($,this.config)}}class V8 extends O{static[G]="PgSerial";getSQLType(){return"serial"}}function x8($){return new U8($??"")}class M8 extends Y2{static[G]="PgSmallIntBuilder";constructor($){super($,"number","PgSmallInt")}build($){return new A8($,this.config)}}class A8 extends O{static[G]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number($);return $}}function Q8($){return new M8($??"")}class I8 extends M{static[G]="PgSmallSerialBuilder";constructor($){super($,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new R8($,this.config)}}class R8 extends O{static[G]="PgSmallSerial";getSQLType(){return"smallserial"}}function w8($){return new I8($??"")}class K8 extends M{static[G]="PgTextBuilder";constructor($,X){super($,"string","PgText");this.config.enumValues=X.enum}build($){return new L8($,this.config)}}class L8 extends O{static[G]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function N8($,X={}){let{name:Y,config:Z}=R($,X);return new K8(Y,Z)}class k8 extends l{constructor($,X,Y){super($,"string","PgTime");this.withTimezone=X,this.precision=Y,this.config.withTimezone=X,this.config.precision=Y}static[G]="PgTimeBuilder";build($){return new f2($,this.config)}}class f2 extends O{static[G]="PgTime";withTimezone;precision;constructor($,X){super($,X);this.withTimezone=X.withTimezone,this.precision=X.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function T8($,X={}){let{name:Y,config:Z}=R($,X);return new k8(Y,Z.withTimezone??!1,Z.precision)}class j8 extends l{static[G]="PgTimestampBuilder";constructor($,X,Y){super($,"date","PgTimestamp");this.config.withTimezone=X,this.config.precision=Y}build($){return new b2($,this.config)}}class b2 extends O{static[G]="PgTimestamp";withTimezone;precision;constructor($,X){super($,X);this.withTimezone=X.withTimezone,this.precision=X.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=($)=>{return new Date(this.withTimezone?$:$+"+0000")};mapToDriverValue=($)=>{return $.toISOString()}}class S8 extends l{static[G]="PgTimestampStringBuilder";constructor($,X,Y){super($,"string","PgTimestampString");this.config.withTimezone=X,this.config.precision=Y}build($){return new d2($,this.config)}}class d2 extends O{static[G]="PgTimestampString";withTimezone;precision;constructor($,X){super($,X);this.withTimezone=X.withTimezone,this.precision=X.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function v8($,X={}){let{name:Y,config:Z}=R($,X);if(Z?.mode==="string")return new S8(Y,Z.withTimezone??!1,Z.precision);return new j8(Y,Z?.withTimezone??!1,Z?.precision)}class B8 extends M{static[G]="PgUUIDBuilder";constructor($){super($,"string","PgUUID")}defaultRandom(){return this.default(J`gen_random_uuid()`)}build($){return new m2($,this.config)}}class m2 extends O{static[G]="PgUUID";getSQLType(){return"uuid"}}function g2($){return new B8($??"")}class h8 extends M{static[G]="PgVarcharBuilder";constructor($,X){super($,"string","PgVarchar");this.config.length=X.length,this.config.enumValues=X.enum}build($){return new C8($,this.config)}}class C8 extends O{static[G]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function a($,X={}){let{name:Y,config:Z}=R($,X);return new h8(Y,Z)}class q8 extends M{static[G]="PgBinaryVectorBuilder";constructor($,X){super($,"string","PgBinaryVector");this.config.dimensions=X.dimensions}build($){return new P8($,this.config)}}class P8 extends O{static[G]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function p8($,X){let{name:Y,config:Z}=R($,X);return new q8(Y,Z)}class y8 extends M{static[G]="PgHalfVectorBuilder";constructor($,X){super($,"array","PgHalfVector");this.config.dimensions=X.dimensions}build($){return new f8($,this.config)}}class f8 extends O{static[G]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((X)=>Number.parseFloat(X))}}function b8($,X){let{name:Y,config:Z}=R($,X);return new y8(Y,Z)}class d8 extends M{static[G]="PgSparseVectorBuilder";constructor($,X){super($,"string","PgSparseVector");this.config.dimensions=X.dimensions}build($){return new m8($,this.config)}}class m8 extends O{static[G]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function g8($,X){let{name:Y,config:Z}=R($,X);return new d8(Y,Z)}class c8 extends M{static[G]="PgVectorBuilder";constructor($,X){super($,"array","PgVector");this.config.dimensions=X.dimensions}build($){return new u8($,this.config)}}class u8 extends O{static[G]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((X)=>Number.parseFloat(X))}}function o8($,X){let{name:Y,config:Z}=R($,X);return new c8(Y,Z)}function r8(){return{bigint:Y1,bigserial:W1,boolean:z1,char:O1,cidr:x1,customType:Q1,date:w1,doublePrecision:E2,inet:T1,integer:Z2,interval:h1,json:q1,jsonb:p1,line:m1,macaddr:u1,macaddr8:t1,numeric:e1,point:_8,geometry:z8,real:O8,serial:x8,smallint:Q8,smallserial:w8,text:N8,time:T8,timestamp:v8,uuid:g2,varchar:a,bit:p8,halfvec:b8,sparsevec:g8,vector:o8}}var O0=Symbol.for("drizzle:PgInlineForeignKeys"),t8=Symbol.for("drizzle:EnableRLS");class q extends V{static[G]="PgTable";static Symbol=Object.assign({},V.Symbol,{InlineForeignKeys:O0,EnableRLS:t8});[O0]=[];[t8]=!1;[V.Symbol.ExtraConfigBuilder]=void 0;[V.Symbol.ExtraConfigColumns]={}}function b$($,X,Y,Z,_=$){let W=new q($,Z,_),E=typeof X==="function"?X(r8()):X,F=Object.fromEntries(Object.entries(E).map(([U,A])=>{let Q=A;Q.setName(U);let K=Q.build(W);return W[O0].push(...Q.buildForeignKeys(K,W)),[U,K]})),D=Object.fromEntries(Object.entries(E).map(([U,A])=>{let Q=A;Q.setName(U);let K=Q.buildExtraConfigColumn(W);return[U,K]})),H=Object.assign(W,F);if(H[V.Symbol.Columns]=F,H[V.Symbol.ExtraConfigColumns]=D,Y)H[q.Symbol.ExtraConfigBuilder]=Y;return Object.assign(H,{enableRLS:()=>{return H[q.Symbol.EnableRLS]=!0,H}})}var s8=($,X,Y)=>{return b$($,X,Y,void 0)};class U0{static[G]="PgPrimaryKeyBuilder";columns;name;constructor($,X){this.columns=$,this.name=X}build($){return new n8($,this.columns,this.name)}}class n8{constructor($,X,Y){this.table=$,this.columns=X,this.name=Y}static[G]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[q.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}function c($,X){if(o0(X)&&!W0($)&&!z($,o)&&!z($,X2)&&!z($,N)&&!z($,V)&&!z($,g))return new o($,X);return $}var c2=($,X)=>{return J`${$} = ${c(X,$)}`},i8=($,X)=>{return J`${$} <> ${c(X,$)}`};function M2(...$){let X=$.filter((Y)=>Y!==void 0);if(X.length===0)return;if(X.length===1)return new x(X);return new x([new h("("),J.join(X,new h(" and ")),new h(")")])}function l8(...$){let X=$.filter((Y)=>Y!==void 0);if(X.length===0)return;if(X.length===1)return new x(X);return new x([new h("("),J.join(X,new h(" or ")),new h(")")])}function a8($){return J`not ${$}`}var e8=($,X)=>{return J`${$} > ${c(X,$)}`},$$=($,X)=>{return J`${$} >= ${c(X,$)}`},X$=($,X)=>{return J`${$} < ${c(X,$)}`},Y$=($,X)=>{return J`${$} <= ${c(X,$)}`};function Z$($,X){if(Array.isArray(X)){if(X.length===0)return J`false`;return J`${$} in ${X.map((Y)=>c(Y,$))}`}return J`${$} in ${c(X,$)}`}function _$($,X){if(Array.isArray(X)){if(X.length===0)return J`true`;return J`${$} not in ${X.map((Y)=>c(Y,$))}`}return J`${$} not in ${c(X,$)}`}function G$($){return J`${$} is null`}function J$($){return J`${$} is not null`}function W$($){return J`exists ${$}`}function H$($){return J`not exists ${$}`}function E$($,X,Y){return J`${$} between ${c(X,$)} and ${c(Y,$)}`}function z$($,X,Y){return J`${$} not between ${c(X,$)} and ${c(Y,$)}`}function F$($,X){return J`${$} like ${X}`}function D$($,X){return J`${$} not like ${X}`}function O$($,X){return J`${$} ilike ${X}`}function U$($,X){return J`${$} not ilike ${X}`}function V$($){return J`${$} asc`}function x$($){return J`${$} desc`}class V0{constructor($,X,Y){this.sourceTable=$,this.referencedTable=X,this.relationName=Y,this.referencedTableName=X[V.Symbol.Name]}static[G]="Relation";referencedTableName;fieldName}class M${constructor($,X){this.table=$,this.config=X}static[G]="Relations"}class _2 extends V0{constructor($,X,Y,Z){super($,X,Y?.relationName);this.config=Y,this.isNullable=Z}static[G]="One";withFieldName($){let X=new _2(this.sourceTable,this.referencedTable,this.config,this.isNullable);return X.fieldName=$,X}}class A2 extends V0{constructor($,X,Y){super($,X,Y?.relationName);this.config=Y}static[G]="Many";withFieldName($){let X=new A2(this.sourceTable,this.referencedTable,this.config);return X.fieldName=$,X}}function A$(){return{and:M2,between:E$,eq:c2,exists:W$,gt:e8,gte:$$,ilike:O$,inArray:Z$,isNull:G$,isNotNull:J$,like:F$,lt:X$,lte:Y$,ne:i8,not:a8,notBetween:z$,notExists:H$,notLike:D$,notIlike:U$,notInArray:_$,or:l8,sql:J}}function Q$(){return{sql:J,asc:V$,desc:x$}}function I$($,X){if(Object.keys($).length===1&&"default"in $&&!z($.default,V))$=$.default;let Y={},Z={},_={};for(let[W,E]of Object.entries($))if(z(E,V)){let F=G2(E),D=Z[F];Y[F]=W,_[W]={tsName:W,dbName:E[V.Symbol.Name],schema:E[V.Symbol.Schema],columns:E[V.Symbol.Columns],relations:D?.relations??{},primaryKey:D?.primaryKey??[]};for(let U of Object.values(E[V.Symbol.Columns]))if(U.primary)_[W].primaryKey.push(U);let H=E[V.Symbol.ExtraConfigBuilder]?.(E[V.Symbol.ExtraConfigColumns]);if(H){for(let U of Object.values(H))if(z(U,U0))_[W].primaryKey.push(...U.columns)}}else if(z(E,M$)){let F=G2(E.table),D=Y[F],H=E.config(X(E.table)),U;for(let[A,Q]of Object.entries(H))if(D){let K=_[D];if(K.relations[A]=Q,U)K.primaryKey.push(...U)}else{if(!(F in Z))Z[F]={relations:{},primaryKey:U};Z[F].relations[A]=Q}}return{tables:_,tableNamesMap:Y}}function d$($){return function X(Y,Z){return new _2($,Y,Z,Z?.fields.reduce((_,W)=>_&&W.notNull,!0)??!1)}}function m$($){return function X(Y,Z){return new A2($,Y,Z)}}function R$($,X,Y){if(z(Y,_2)&&Y.config)return{fields:Y.config.fields,references:Y.config.references};let Z=X[G2(Y.referencedTable)];if(!Z)throw new Error(`Table "${Y.referencedTable[V.Symbol.Name]}" not found in schema`);let _=$[Z];if(!_)throw new Error(`Table "${Z}" not found in schema`);let W=Y.sourceTable,E=X[G2(W)];if(!E)throw new Error(`Table "${W[V.Symbol.Name]}" not found in schema`);let F=[];for(let D of Object.values(_.relations))if(Y.relationName&&Y!==D&&D.relationName===Y.relationName||!Y.relationName&&D.referencedTable===Y.sourceTable)F.push(D);if(F.length>1)throw Y.relationName?new Error(`There are multiple relations with name "${Y.relationName}" in table "${Z}"`):new Error(`There are multiple relations between "${Z}" and "${Y.sourceTable[V.Symbol.Name]}". Please specify relation name`);if(F[0]&&z(F[0],_2)&&F[0].config)return{fields:F[0].config.references,references:F[0].config.fields};throw new Error(`There is not enough information to infer relation "${E}.${Y.fieldName}"`)}function w$($){return{one:d$($),many:m$($)}}function u2($,X,Y,Z,_=(W)=>W){let W={};for(let[E,F]of Z.entries())if(F.isJson){let D=X.relations[F.tsKey],H=Y[E],U=typeof H==="string"?JSON.parse(H):H;W[F.tsKey]=z(D,_2)?U&&u2($,$[F.relationTableTsKey],U,F.selection,_):U.map((A)=>u2($,$[F.relationTableTsKey],A,F.selection,_))}else{let D=_(Y[E]),H=F.field,U;if(z(H,N))U=H;else if(z(H,x))U=H.decoder;else U=H.sql.decoder;W[F.tsKey]=D===null?null:U.mapFromDriverValue(D)}return W}class Q2 extends g{static[G]="PgViewBase"}class J2{static[G]="PgDialect";casing;constructor($){this.casing=new z0($?.casing)}async migrate($,X,Y){let Z=typeof Y==="string"?"__drizzle_migrations":Y.migrationsTable??"__drizzle_migrations",_=typeof Y==="string"?"drizzle":Y.migrationsSchema??"drizzle",W=J`
|
|
CREATE TABLE IF NOT EXISTS ${J.identifier(_)}.${J.identifier(Z)} (
|
|
id SERIAL PRIMARY KEY,
|
|
hash text NOT NULL,
|
|
created_at bigint
|
|
)
|
|
`;await X.execute(J`CREATE SCHEMA IF NOT EXISTS ${J.identifier(_)}`),await X.execute(W);let F=(await X.all(J`select id, hash, created_at from ${J.identifier(_)}.${J.identifier(Z)} order by created_at desc limit 1`))[0];await X.transaction(async(D)=>{for await(let H of $)if(!F||Number(F.created_at)<H.folderMillis){for(let U of H.sql)await D.execute(J.raw(U));await D.execute(J`insert into ${J.identifier(_)}.${J.identifier(Z)} ("hash", "created_at") values(${H.hash}, ${H.folderMillis})`)}})}escapeName($){return`"${$}"`}escapeParam($){return`$${$+1}`}escapeString($){return`'${$.replace(/'/g,"''")}'`}buildWithCTE($){if(!$?.length)return;let X=[J`with `];for(let[Y,Z]of $.entries())if(X.push(J`${J.identifier(Z._.alias)} as (${Z._.sql})`),Y<$.length-1)X.push(J`, `);return X.push(J` `),J.join(X)}buildDeleteQuery({table:$,where:X,returning:Y,withList:Z}){let _=this.buildWithCTE(Z),W=Y?J` returning ${this.buildSelection(Y,{isSingleTable:!0})}`:void 0,E=X?J` where ${X}`:void 0;return J`${_}delete from ${$}${E}${W}`}buildUpdateSet($,X){let Y=$[V.Symbol.Columns],Z=Object.keys(Y).filter((W)=>X[W]!==void 0||Y[W]?.onUpdateFn!==void 0),_=Z.length;return J.join(Z.flatMap((W,E)=>{let F=Y[W],D=X[W]??J.param(F.onUpdateFn(),F),H=J`${J.identifier(this.casing.getColumnCasing(F))} = ${D}`;if(E<_-1)return[H,J.raw(", ")];return[H]}))}buildUpdateQuery({table:$,set:X,where:Y,returning:Z,withList:_,from:W,joins:E}){let F=this.buildWithCTE(_),D=$[q.Symbol.Name],H=$[q.Symbol.Schema],U=$[q.Symbol.OriginalName],A=D===U?void 0:D,Q=J`${H?J`${J.identifier(H)}.`:void 0}${J.identifier(U)}${A&&J` ${J.identifier(A)}`}`,K=this.buildUpdateSet($,X),v=W&&J.join([J.raw(" from "),this.buildFromTable(W)]),j=this.buildJoins(E),L=Z?J` returning ${this.buildSelection(Z,{isSingleTable:!W})}`:void 0,P=Y?J` where ${Y}`:void 0;return J`${F}update ${Q} set ${K}${v}${j}${P}${L}`}buildSelection($,{isSingleTable:X=!1}={}){let Y=$.length,Z=$.flatMap(({field:_},W)=>{let E=[];if(z(_,x.Aliased)&&_.isSelectionField)E.push(J.identifier(_.fieldAlias));else if(z(_,x.Aliased)||z(_,x)){let F=z(_,x.Aliased)?_.sql:_;if(X)E.push(new x(F.queryChunks.map((D)=>{if(z(D,O))return J.identifier(this.casing.getColumnCasing(D));return D})));else E.push(F);if(z(_,x.Aliased))E.push(J` as ${J.identifier(_.fieldAlias)}`)}else if(z(_,N))if(X)E.push(J.identifier(this.casing.getColumnCasing(_)));else E.push(_);if(W<Y-1)E.push(J`, `);return E});return J.join(Z)}buildJoins($){if(!$||$.length===0)return;let X=[];for(let[Y,Z]of $.entries()){if(Y===0)X.push(J` `);let _=Z.table,W=Z.lateral?J` lateral`:void 0;if(z(_,q)){let E=_[q.Symbol.Name],F=_[q.Symbol.Schema],D=_[q.Symbol.OriginalName],H=E===D?void 0:Z.alias;X.push(J`${J.raw(Z.joinType)} join${W} ${F?J`${J.identifier(F)}.`:void 0}${J.identifier(D)}${H&&J` ${J.identifier(H)}`} on ${Z.on}`)}else if(z(_,g)){let E=_[T].name,F=_[T].schema,D=_[T].originalName,H=E===D?void 0:Z.alias;X.push(J`${J.raw(Z.joinType)} join${W} ${F?J`${J.identifier(F)}.`:void 0}${J.identifier(D)}${H&&J` ${J.identifier(H)}`} on ${Z.on}`)}else X.push(J`${J.raw(Z.joinType)} join${W} ${_} on ${Z.on}`);if(Y<$.length-1)X.push(J` `)}return J.join(X)}buildFromTable($){if(z($,V)&&$[V.Symbol.IsAlias]){let X=J`${J.identifier($[V.Symbol.OriginalName])}`;if($[V.Symbol.Schema])X=J`${J.identifier($[V.Symbol.Schema])}.${X}`;return J`${X} ${J.identifier($[V.Symbol.Name])}`}return $}buildSelectQuery({withList:$,fields:X,fieldsFlat:Y,where:Z,having:_,table:W,joins:E,orderBy:F,groupBy:D,limit:H,offset:U,lockingClause:A,distinct:Q,setOperators:K}){let v=Y??r(X);for(let u of v)if(z(u.field,N)&&m(u.field.table)!==(z(W,B)?W._.alias:z(W,Q2)?W[T].name:z(W,x)?void 0:m(W))&&!((n)=>E?.some(({alias:n2})=>n2===(n[V.Symbol.IsAlias]?m(n):n[V.Symbol.BaseName])))(u.field.table)){let n=m(u.field.table);throw new Error(`Your "${u.path.join("->")}" field references a column "${n}"."${u.field.name}", but the table "${n}" is not part of the query! Did you forget to join it?`)}let j=!E||E.length===0,L=this.buildWithCTE($),P;if(Q)P=Q===!0?J` distinct`:J` distinct on (${J.join(Q.on,J`, `)})`;let y=this.buildSelection(v,{isSingleTable:j}),C=this.buildFromTable(W),e=this.buildJoins(E),p=Z?J` where ${Z}`:void 0,I=_?J` having ${_}`:void 0,w;if(F&&F.length>0)w=J` order by ${J.join(F,J`, `)}`;let d;if(D&&D.length>0)d=J` group by ${J.join(D,J`, `)}`;let L2=typeof H==="object"||typeof H==="number"&&H>=0?J` limit ${H}`:void 0,s2=U?J` offset ${U}`:void 0,W2=J.empty();if(A){let u=J` for ${J.raw(A.strength)}`;if(A.config.of)u.append(J` of ${J.join(Array.isArray(A.config.of)?A.config.of:[A.config.of],J`, `)}`);if(A.config.noWait)u.append(J` no wait`);else if(A.config.skipLocked)u.append(J` skip locked`);W2.append(u)}let $2=J`${L}select${P} ${y} from ${C}${e}${p}${d}${I}${w}${L2}${s2}${W2}`;if(K.length>0)return this.buildSetOperations($2,K);return $2}buildSetOperations($,X){let[Y,...Z]=X;if(!Y)throw new Error("Cannot pass undefined values to any set operator");if(Z.length===0)return this.buildSetOperationQuery({leftSelect:$,setOperator:Y});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:$,setOperator:Y}),Z)}buildSetOperationQuery({leftSelect:$,setOperator:{type:X,isAll:Y,rightSelect:Z,limit:_,orderBy:W,offset:E}}){let F=J`(${$.getSQL()}) `,D=J`(${Z.getSQL()})`,H;if(W&&W.length>0){let K=[];for(let v of W)if(z(v,O))K.push(J.identifier(v.name));else if(z(v,x)){for(let j=0;j<v.queryChunks.length;j++){let L=v.queryChunks[j];if(z(L,O))v.queryChunks[j]=J.identifier(L.name)}K.push(J`${v}`)}else K.push(J`${v}`);H=J` order by ${J.join(K,J`, `)} `}let U=typeof _==="object"||typeof _==="number"&&_>=0?J` limit ${_}`:void 0,A=J.raw(`${X} ${Y?"all ":""}`),Q=E?J` offset ${E}`:void 0;return J`${F}${A}${D}${H}${U}${Q}`}buildInsertQuery({table:$,values:X,onConflict:Y,returning:Z,withList:_,select:W,overridingSystemValue_:E}){let F=[],D=$[V.Symbol.Columns],H=Object.entries(D).filter(([L,P])=>!P.shouldDisableInsert()),U=H.map(([,L])=>J.identifier(this.casing.getColumnCasing(L)));if(W){let L=X;if(z(L,x))F.push(L);else F.push(L.getSQL())}else{let L=X;F.push(J.raw("values "));for(let[P,y]of L.entries()){let C=[];for(let[e,p]of H){let I=y[e];if(I===void 0||z(I,o)&&I.value===void 0)if(p.defaultFn!==void 0){let w=p.defaultFn(),d=z(w,x)?w:J.param(w,p);C.push(d)}else if(!p.default&&p.onUpdateFn!==void 0){let w=p.onUpdateFn(),d=z(w,x)?w:J.param(w,p);C.push(d)}else C.push(J`default`);else C.push(I)}if(F.push(C),P<L.length-1)F.push(J`, `)}}let A=this.buildWithCTE(_),Q=J.join(F),K=Z?J` returning ${this.buildSelection(Z,{isSingleTable:!0})}`:void 0,v=Y?J` on conflict ${Y}`:void 0,j=E===!0?J`overriding system value `:void 0;return J`${A}insert into ${$} ${U} ${j}${Q}${v}${K}`}buildRefreshMaterializedViewQuery({view:$,concurrently:X,withNoData:Y}){let Z=X?J` concurrently`:void 0,_=Y?J` with no data`:void 0;return J`refresh materialized view${Z} ${$}${_}`}prepareTyping($){if(z($,p2)||z($,P2))return"json";else if(z($,y2))return"decimal";else if(z($,f2))return"time";else if(z($,b2)||z($,d2))return"timestamp";else if(z($,C2)||z($,q2))return"date";else if(z($,m2))return"uuid";else return"none"}sqlToQuery($,X){return $.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:X})}buildRelationalQueryWithoutPK({fullSchema:$,schema:X,tableNamesMap:Y,table:Z,tableConfig:_,queryConfig:W,tableAlias:E,nestedQueryRelation:F,joinOn:D}){let H=[],U,A,Q=[],K,v=[];if(W===!0)H=Object.entries(_.columns).map(([P,y])=>({dbKey:y.name,tsKey:P,field:s(y,E),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let L=Object.fromEntries(Object.entries(_.columns).map(([I,w])=>[I,s(w,E)]));if(W.where){let I=typeof W.where==="function"?W.where(L,A$()):W.where;K=I&&V2(I,E)}let P=[],y=[];if(W.columns){let I=!1;for(let[w,d]of Object.entries(W.columns)){if(d===void 0)continue;if(w in _.columns){if(!I&&d===!0)I=!0;y.push(w)}}if(y.length>0)y=I?y.filter((w)=>W.columns?.[w]===!0):Object.keys(_.columns).filter((w)=>!y.includes(w))}else y=Object.keys(_.columns);for(let I of y){let w=_.columns[I];P.push({tsKey:I,value:w})}let C=[];if(W.with)C=Object.entries(W.with).filter((I)=>!!I[1]).map(([I,w])=>({tsKey:I,queryConfig:w,relation:_.relations[I]}));let e;if(W.extras){e=typeof W.extras==="function"?W.extras(L,{sql:J}):W.extras;for(let[I,w]of Object.entries(e))P.push({tsKey:I,value:E0(w,E)})}for(let{tsKey:I,value:w}of P)H.push({dbKey:z(w,x.Aliased)?w.fieldAlias:_.columns[I].name,tsKey:I,field:z(w,N)?s(w,E):w,relationTableTsKey:void 0,isJson:!1,selection:[]});let p=typeof W.orderBy==="function"?W.orderBy(L,Q$()):W.orderBy??[];if(!Array.isArray(p))p=[p];Q=p.map((I)=>{if(z(I,N))return s(I,E);return V2(I,E)}),U=W.limit,A=W.offset;for(let{tsKey:I,queryConfig:w,relation:d}of C){let L2=R$(X,Y,d),s2=G2(d.referencedTable),W2=Y[s2],$2=`${E}_${I}`,u=M2(...L2.fields.map((T$,j$)=>c2(s(L2.references[j$],$2),s(T$,E)))),n=this.buildRelationalQueryWithoutPK({fullSchema:$,schema:X,tableNamesMap:Y,table:$[W2],tableConfig:X[W2],queryConfig:z(d,_2)?w===!0?{limit:1}:{...w,limit:1}:w,tableAlias:$2,joinOn:u,nestedQueryRelation:d}),n2=J`${J.identifier($2)}.${J.identifier("data")}`.as(I);v.push({on:J`true`,table:new B(n.sql,{},$2),alias:$2,joinType:"left",lateral:!0}),H.push({dbKey:I,tsKey:I,field:n2,relationTableTsKey:W2,isJson:!0,selection:n.selection})}}if(H.length===0)throw new h2({message:`No fields selected for table "${_.tsName}" ("${E}")`});let j;if(K=M2(D,K),F){let L=J`json_build_array(${J.join(H.map(({field:C,tsKey:e,isJson:p})=>p?J`${J.identifier(`${E}_${e}`)}.${J.identifier("data")}`:z(C,x.Aliased)?C.sql:C),J`, `)})`;if(z(F,A2))L=J`coalesce(json_agg(${L}${Q.length>0?J` order by ${J.join(Q,J`, `)}`:void 0}), '[]'::json)`;let P=[{dbKey:"data",tsKey:"data",field:L.as("data"),isJson:!0,relationTableTsKey:_.tsName,selection:H}];if(U!==void 0||A!==void 0||Q.length>0)j=this.buildSelectQuery({table:S2(Z,E),fields:{},fieldsFlat:[{path:[],field:J.raw("*")}],where:K,limit:U,offset:A,orderBy:Q,setOperators:[]}),K=void 0,U=void 0,A=void 0,Q=[];else j=S2(Z,E);j=this.buildSelectQuery({table:z(j,q)?j:new B(j,{},E),fields:{},fieldsFlat:P.map(({field:C})=>({path:[],field:z(C,N)?s(C,E):C})),joins:v,where:K,limit:U,offset:A,orderBy:Q,setOperators:[]})}else j=this.buildSelectQuery({table:S2(Z,E),fields:{},fieldsFlat:H.map(({field:L})=>({path:[],field:z(L,N)?s(L,E):L})),joins:v,where:K,limit:U,offset:A,orderBy:Q,setOperators:[]});return{tableTsKey:_.tsName,sql:j,selection:H}}}class x0{static[G]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class b{static[G]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor($){if(this.fields=$.fields,this.session=$.session,this.dialect=$.dialect,$.withList)this.withList=$.withList;this.distinct=$.distinct}authToken;setToken($){return this.authToken=$,this}from($){let X=!!this.fields,Y=$,Z;if(this.fields)Z=this.fields;else if(z(Y,B))Z=Object.fromEntries(Object.keys(Y._.selectedFields).map((_)=>[_,Y[_]]));else if(z(Y,Q2))Z=Y[T].selectedFields;else if(z(Y,x))Z={};else Z=i0(Y);return new M0({table:Y,fields:Z,isPartialSelect:X,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class K$ extends x0{static[G]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:$,fields:X,isPartialSelect:Y,session:Z,dialect:_,withList:W,distinct:E}){super();this.config={withList:W,table:$,fields:{...X},distinct:E,setOperators:[]},this.isPartialSelect=Y,this.session=Z,this.dialect=_,this._={selectedFields:X},this.tableName=i($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin($){return(X,Y)=>{let Z=this.tableName,_=i(X);if(typeof _==="string"&&this.config.joins?.some((W)=>W.alias===_))throw new Error(`Alias "${_}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof Z==="string")this.config.fields={[Z]:this.config.fields};if(typeof _==="string"&&!z(X,x)){let W=z(X,B)?X._.selectedFields:z(X,g)?X[T].selectedFields:X[V.Symbol.Columns];this.config.fields[_]=W}}if(typeof Y==="function")Y=Y(new Proxy(this.config.fields,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:Y,table:X,joinType:$,alias:_}),typeof _==="string")switch($){case"left":{this.joinsNotNullableMap[_]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[_]=!0;break}case"inner":{this.joinsNotNullableMap[_]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[_]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");createSetOperator($,X){return(Y)=>{let Z=typeof Y==="function"?Y(g$()):Y;if(!x2(this.getSelectedFields(),Z.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:$,isAll:X,rightSelect:Z}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new S({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(X)?X:[X]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new S({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),Y=Array.isArray(X)?X:[X];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=Y;else this.config.orderBy=Y}else{let X=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=X;else this.config.orderBy=X}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}for($,X={}){return this.config.lockingClause={strength:$,config:X},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}as($){return new Proxy(new B(this.getSQL(),this.config.fields,$),new S({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new S({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class M0 extends K${static[G]="PgSelect";_prepare($){let{session:X,config:Y,dialect:Z,joinsNotNullableMap:_,authToken:W}=this;if(!X)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return k.startActiveSpan("drizzle.prepareQuery",()=>{let E=r(Y.fields),F=X.prepareQuery(Z.sqlToQuery(this.getSQL()),E,$,!0);return F.joinsNotNullableMap=_,F.setToken(W)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}n0(M0,[f]);function z2($,X){return(Y,Z,..._)=>{let W=[Z,..._].map((E)=>({type:$,isAll:X,rightSelect:E}));for(let E of W)if(!x2(Y.getSelectedFields(),E.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return Y.addSetOperators(W)}}var g$=()=>({union:c$,unionAll:u$,intersect:o$,intersectAll:r$,except:t$,exceptAll:s$}),c$=z2("union",!1),u$=z2("union",!0),o$=z2("intersect",!1),r$=z2("intersect",!0),t$=z2("except",!1),s$=z2("except",!0);class I2{static[G]="PgQueryBuilder";dialect;dialectConfig;constructor($){this.dialect=z($,J2)?$:void 0,this.dialectConfig=z($,J2)?void 0:$}$with=($,X)=>{let Y=this;return{as:(_)=>{if(typeof _==="function")_=_(Y);return new Proxy(new D2(_.getSQL(),X??("getSelectedFields"in _?_.getSelectedFields()??{}:{}),$,!0),new S({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...$){let X=this;function Y(W){return new b({fields:W??void 0,session:void 0,dialect:X.getDialect(),withList:$})}function Z(W){return new b({fields:W??void 0,session:void 0,dialect:X.getDialect(),distinct:!0})}function _(W,E){return new b({fields:E??void 0,session:void 0,dialect:X.getDialect(),distinct:{on:W}})}return{select:Y,selectDistinct:Z,selectDistinctOn:_}}select($){return new b({fields:$??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct($){return new b({fields:$??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn($,X){return new b({fields:X??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:$}})}getDialect(){if(!this.dialect)this.dialect=new J2(this.dialectConfig);return this.dialect}}class o2{constructor($,X,Y,Z,_){this.table=$,this.session=X,this.dialect=Y,this.withList=Z,this.overridingSystemValue_=_}static[G]="PgInsertBuilder";authToken;setToken($){return this.authToken=$,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values($){if($=Array.isArray($)?$:[$],$.length===0)throw new Error("values() must be called with at least one value");let X=$.map((Y)=>{let Z={},_=this.table[V.Symbol.Columns];for(let W of Object.keys(Y)){let E=Y[W];Z[W]=z(E,x)?E:new o(E,_[W])}return Z});return new A0(this.table,X,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select($){let X=typeof $==="function"?$(new I2):$;if(!z(X,x)&&!x2(this.table[T2],X._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new A0(this.table,X,this.session,this.dialect,this.withList,!0)}}class A0 extends f{constructor($,X,Y,Z,_,W,E){super();this.session=Y,this.dialect=Z,this.config={table:$,values:X,withList:_,select:W,overridingSystemValue_:E}}static[G]="PgInsert";config;returning($=this.config.table[V.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=r($),this}onConflictDoNothing($={}){if($.target===void 0)this.config.onConflict=J`do nothing`;else{let X="";X=Array.isArray($.target)?$.target.map((Z)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(Z))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target));let Y=$.where?J` where ${$.where}`:void 0;this.config.onConflict=J`(${J.raw(X)})${Y} do nothing`}return this}onConflictDoUpdate($){if($.where&&($.targetWhere||$.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let X=$.where?J` where ${$.where}`:void 0,Y=$.targetWhere?J` where ${$.targetWhere}`:void 0,Z=$.setWhere?J` where ${$.setWhere}`:void 0,_=this.dialect.buildUpdateSet(this.config.table,v2(this.config.table,$.set)),W="";return W=Array.isArray($.target)?$.target.map((E)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(E))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target)),this.config.onConflict=J`(${J.raw(W)})${Y} do update set ${_}${X}${Z}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new S({alias:m(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class Q0 extends f{constructor($,X,Y){super();this.session=X,this.dialect=Y,this.config={view:$}}static[G]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}class r2{constructor($,X,Y,Z){this.table=$,this.session=X,this.dialect=Y,this.withList=Z}static[G]="PgUpdateBuilder";authToken;setToken($){return this.authToken=$,this}set($){return new L$(this.table,v2(this.table,$),this.session,this.dialect,this.withList).setToken(this.authToken)}}class L$ extends f{constructor($,X,Y,Z,_){super();this.session=Y,this.dialect=Z,this.config={set:X,table:$,withList:_,joins:[]},this.tableName=i($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[G]="PgUpdate";config;tableName;joinsNotNullableMap;from($){let X=$,Y=i(X);if(typeof Y==="string")this.joinsNotNullableMap[Y]=!0;return this.config.from=X,this}getTableLikeFields($){if(z($,q))return $[V.Symbol.Columns];else if(z($,B))return $._.selectedFields;return $[T].selectedFields}createJoin($){return(X,Y)=>{let Z=i(X);if(typeof Z==="string"&&this.config.joins.some((_)=>_.alias===Z))throw new Error(`Alias "${Z}" is already used in this query`);if(typeof Y==="function"){let _=this.config.from&&!z(this.config.from,x)?this.getTableLikeFields(this.config.from):void 0;Y=Y(new Proxy(this.config.table[V.Symbol.Columns],new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),_&&new Proxy(_,new S({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:Y,table:X,joinType:$,alias:Z}),typeof Z==="string")switch($){case"left":{this.joinsNotNullableMap[Z]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([_])=>[_,!1])),this.joinsNotNullableMap[Z]=!0;break}case"inner":{this.joinsNotNullableMap[Z]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([_])=>[_,!1])),this.joinsNotNullableMap[Z]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}returning($){if(!$){if($=Object.assign({},this.config.table[V.Symbol.Columns]),this.config.from){let X=i(this.config.from);if(typeof X==="string"&&this.config.from&&!z(this.config.from,x)){let Y=this.getTableLikeFields(this.config.from);$[X]=Y}for(let Y of this.config.joins){let Z=i(Y.table);if(typeof Z==="string"&&!z(Y.table,x)){let _=this.getTableLikeFields(Y.table);$[Z]=_}}}}return this.config.returningFields=$,this.config.returning=r($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($){let X=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0);return X.joinsNotNullableMap=this.joinsNotNullableMap,X}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return this._prepare().execute($,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new S({alias:m(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class R2 extends x{constructor($){super(R2.buildEmbeddedCount($.source,$.filters).queryChunks);this.params=$,this.mapWith(Number),this.session=$.session,this.sql=R2.buildCount($.source,$.filters)}sql;token;static[G]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount($,X){return J`(select count(*) from ${$}${J.raw(" where ").if(X)}${X})`}static buildCount($,X){return J`select count(*) as count from ${$}${J.raw(" where ").if(X)}${X};`}setToken($){return this.token=$,this}then($,X){return Promise.resolve(this.session.count(this.sql,this.token)).then($,X)}catch($){return this.then(void 0,$)}finally($){return this.then((X)=>{return $?.(),X},(X)=>{throw $?.(),X})}}class R0{constructor($,X,Y,Z,_,W,E){this.fullSchema=$,this.schema=X,this.tableNamesMap=Y,this.table=Z,this.tableConfig=_,this.dialect=W,this.session=E}static[G]="PgRelationalQueryBuilder";findMany($){return new I0(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?$:{},"many")}findFirst($){return new I0(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?{...$,limit:1}:{limit:1},"first")}}class I0 extends f{constructor($,X,Y,Z,_,W,E,F,D){super();this.fullSchema=$,this.schema=X,this.tableNamesMap=Y,this.table=Z,this.tableConfig=_,this.dialect=W,this.session=E,this.config=F,this.mode=D}static[G]="PgRelationalQuery";_prepare($){return k.startActiveSpan("drizzle.prepareQuery",()=>{let{query:X,builtQuery:Y}=this._toSQL();return this.session.prepareQuery(Y,void 0,$,!0,(Z,_)=>{let W=Z.map((E)=>u2(this.schema,this.tableConfig,E,X.selection,_));if(this.mode==="first")return W[0];return W})})}prepare($){return this._prepare($)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let $=this._getQuery(),X=this.dialect.sqlToQuery($.sql);return{query:$,builtQuery:X}}toSQL(){return this._toSQL().builtQuery}authToken;setToken($){return this.authToken=$,this}execute(){return k.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class w0 extends f{constructor($,X,Y,Z){super();this.execute=$,this.sql=X,this.query=Y,this.mapBatchResult=Z}static[G]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult($,X){return X?this.mapBatchResult($):$}_prepare(){return this}isResponseInArrayMode(){return!1}}class w2{constructor($,X,Y){if(this.dialect=$,this.session=X,this._=Y?{schema:Y.schema,fullSchema:Y.fullSchema,tableNamesMap:Y.tableNamesMap,session:X}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:X},this.query={},this._.schema)for(let[Z,_]of Object.entries(this._.schema))this.query[Z]=new R0(Y.fullSchema,this._.schema,this._.tableNamesMap,Y.fullSchema[Z],_,$,X)}static[G]="PgDatabase";query;$with=($,X)=>{let Y=this;return{as:(_)=>{if(typeof _==="function")_=_(new I2(Y.dialect));return new Proxy(new D2(_.getSQL(),X??("getSelectedFields"in _?_.getSelectedFields()??{}:{}),$,!0),new S({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count($,X){return new R2({source:$,filters:X,session:this.session})}with(...$){let X=this;function Y(D){return new b({fields:D??void 0,session:X.session,dialect:X.dialect,withList:$})}function Z(D){return new b({fields:D??void 0,session:X.session,dialect:X.dialect,withList:$,distinct:!0})}function _(D,H){return new b({fields:H??void 0,session:X.session,dialect:X.dialect,withList:$,distinct:{on:D}})}function W(D){return new r2(D,X.session,X.dialect,$)}function E(D){return new o2(D,X.session,X.dialect,$)}function F(D){return new B2(D,X.session,X.dialect,$)}return{select:Y,selectDistinct:Z,selectDistinctOn:_,update:W,insert:E,delete:F}}select($){return new b({fields:$??void 0,session:this.session,dialect:this.dialect})}selectDistinct($){return new b({fields:$??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn($,X){return new b({fields:X??void 0,session:this.session,dialect:this.dialect,distinct:{on:$}})}update($){return new r2($,this.session,this.dialect)}insert($){return new o2($,this.session,this.dialect)}delete($){return new B2($,this.session,this.dialect)}refreshMaterializedView($){return new Q0($,this.session,this.dialect)}authToken;execute($){let X=typeof $==="string"?J.raw($):$.getSQL(),Y=this.dialect.sqlToQuery(X),Z=this.session.prepareQuery(Y,void 0,void 0,!1);return new w0(()=>Z.execute(void 0,this.authToken),X,Y,(_)=>Z.mapResult(_,!0))}transaction($,X){return this.session.transaction($,X)}}class K0{constructor($){this.query=$}authToken;getQuery(){return this.query}mapResult($,X){return $}setToken($){return this.authToken=$,this}static[G]="PgPreparedQuery";joinsNotNullableMap}class L0{constructor($){this.dialect=$}static[G]="PgSession";execute($,X){return k.startActiveSpan("drizzle.operation",()=>{return k.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1)}).setToken(X).execute(void 0,X)})}all($){return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1).all()}async count($,X){let Y=await this.execute($,X);return Number(Y[0].count)}}class N0 extends w2{constructor($,X,Y,Z=0){super($,X,Y);this.schema=Y,this.nestedIndex=Z}static[G]="PgTransaction";rollback(){throw new F0}getTransactionConfigSQL($){let X=[];if($.isolationLevel)X.push(`isolation level ${$.isolationLevel}`);if($.accessMode)X.push($.accessMode);if(typeof $.deferrable==="boolean")X.push($.deferrable?"deferrable":"not deferrable");return J.raw(X.join(" "))}setTransaction($){return this.session.execute(J`set transaction ${this.getTransactionConfigSQL($)}`)}}class N$ extends K0{constructor($,X,Y,Z,_,W,E){super({sql:X,params:Y});this.client=$,this.queryString=X,this.params=Y,this.logger=Z,this.fields=_,this._isResponseInArrayMode=W,this.customResultMapper=E}static[G]="BunSQLPreparedQuery";async execute($={}){return k.startActiveSpan("drizzle.execute",async(X)=>{let Y=H0(this.params,$);X?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.logger.logQuery(this.queryString,Y);let{fields:Z,queryString:_,client:W,joinsNotNullableMap:E,customResultMapper:F}=this;if(!Z&&!F)return k.startActiveSpan("drizzle.driver.execute",()=>{return W.unsafe(_,Y)});let D=await k.startActiveSpan("drizzle.driver.execute",()=>{return X?.setAttributes({"drizzle.query.text":_,"drizzle.query.params":JSON.stringify(Y)}),W.unsafe(_,Y).values()});return k.startActiveSpan("drizzle.mapResponse",()=>{return F?F(D):D.map((H)=>s0(Z,H,E))})})}all($={}){return k.startActiveSpan("drizzle.execute",async(X)=>{let Y=H0(this.params,$);return X?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.logger.logQuery(this.queryString,Y),k.startActiveSpan("drizzle.driver.execute",()=>{return X?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(Y)}),this.client.unsafe(this.queryString,Y)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class K2 extends L0{constructor($,X,Y,Z={}){super(X);this.client=$,this.schema=Y,this.options=Z,this.logger=Z.logger??new l2}static[G]="BunSQLSession";logger;prepareQuery($,X,Y,Z,_){return new N$(this.client,$.sql,$.params,this.logger,X,Z,_)}query($,X){return this.logger.logQuery($,X),this.client.unsafe($,X).values()}queryObjects($,X){return this.client.unsafe($,X)}transaction($,X){return this.client.begin(async(Y)=>{let Z=new K2(Y,this.dialect,this.schema,this.options),_=new k0(this.dialect,Z,this.schema);if(X)await _.setTransaction(X);return $(_)})}}class k0 extends N0{constructor($,X,Y,Z=0){super($,X,Y,Z);this.session=X}static[G]="BunSQLTransaction";transaction($){return this.session.client.savepoint((X)=>{let Y=new K2(X,this.dialect,this.schema,this.session.options),Z=new k0(this.dialect,Y,this.schema);return $(Z)})}}class k$ extends w2{static[G]="BunSQLDatabase"}function F2($,X={}){let Y=new J2({casing:X.casing}),Z;if(X.logger===!0)Z=new i2;else if(X.logger!==!1)Z=X.logger;let _;if(X.schema){let F=I$(X.schema,w$);_={fullSchema:X.schema,schema:F.tables,tableNamesMap:F.tableNamesMap}}let W=new K2($,Y,_,{logger:Z}),E=new k$(Y,W,_);return E.$client=$,E}function t2(...$){if(typeof $[0]==="string"){let X=new T0($[0]);return F2(X,$[1])}if(l0($[0])){let{connection:X,client:Y,...Z}=$[0];if(Y)return F2(Y,Z);if(typeof X==="object"&&X.url!==void 0){let{url:W,...E}=X,F=new T0({url:W,...E});return F2(F,Z)}let _=new T0(X);return F2(_,Z)}return F2($[0],$[1])}(($)=>{function X(Y){return F2({options:{parsers:{},serializers:{}}},Y)}$.mock=X})(t2||(t2={}));var j0={};v$(j0,{unitsTable:()=>n$});var n$=s8("units",{id:g2("id").defaultRandom().primaryKey(),unitNo:a("unit_no",{length:10}).notNull(),number:Z2("number"),project:a("project",{length:256}).notNull(),floor:Z2("floor").notNull(),unitType:a("unit_type",{length:256,enum:["Studio Squared","1 BR Squared","Studio Flex","2 BR Squared","One Bedroom2","Studio2","One Bedroom Loft","Two Bedroom Loft"]}),noOfBathrooms:Z2("no_of_bathrooms").notNull(),unitView:a("unit_view",{length:256,enum:["Canal / Amenities","Corner-Canal / Amenities","Corner-Canal View","Business Bay","Park Facing","Corner-Park Facing","Partial Park","BK/DT / Amenities","Corner-BK/DT / Amenities","Corner-Canal / BK/DT View","Marina View","Partial Marina View","Partial Marina, Partial City View","City view","Marina View, Sea View","Partial Marina View, Partial Sea View"]}),suitsArea:E2("suits_area").notNull(),squareFt:E2("square_ft").notNull(),noOfParkingSpace:Z2("no_of_parking_space").notNull(),salesPrice:Z2("sales_price").notNull(),state:a("state",{length:256,enum:["reserved","sold_spa","available","sold_registered"]}).notNull(),balconyArea:E2("balcony_area").notNull(),wing:a("wing",{enum:["East","West"]})},($)=>[B0().on($.project,$.unitNo)]);var{SQL:i$}=globalThis.Bun;var e5=t2({schema:j0,client:new i$("postgresql://postgres:v1sq3vD5faXL@194.26.138.94:5432/irth")});export{e5 as db};
|