@prisma/studio-core 0.1.0 → 0.2.0
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/{CPIOZS5X-NALOZFPD.js → CPIOZS5X-V4BHP4CI.js} +1 -1
- package/dist/{OKF6E45R-6KC3BLVB.js → OKF6E45R-XYOIK2NY.js} +1 -1
- package/dist/{adapter-Co8KY8Hi.d.cts → adapter-CKFCHq71.d.cts} +40 -5
- package/dist/{adapter-Co8KY8Hi.d.ts → adapter-CKFCHq71.d.ts} +40 -5
- package/dist/chunk-2ZJZX5I7.js +0 -0
- package/dist/chunk-BMVJYUJW.js +1 -0
- package/dist/chunk-P72NBTYE.js +1 -0
- package/dist/chunk-XS52QRY2.js +1 -0
- package/dist/data/accelerate/index.d.cts +2 -2
- package/dist/data/accelerate/index.d.ts +2 -2
- package/dist/data/accelerate/index.js +1 -1
- package/dist/data/bff/index.d.cts +2 -2
- package/dist/data/bff/index.d.ts +2 -2
- package/dist/data/bff/index.js +1 -1
- package/dist/data/index.cjs +1 -1
- package/dist/data/index.d.cts +2 -2
- package/dist/data/index.d.ts +2 -2
- package/dist/data/index.js +1 -1
- package/dist/data/pglite/index.cjs +1 -1
- package/dist/data/pglite/index.d.cts +22 -5
- package/dist/data/pglite/index.d.ts +22 -5
- package/dist/data/pglite/index.js +1 -1
- package/dist/data/postgres-core/index.cjs +1 -1
- package/dist/data/postgres-core/index.d.cts +35 -10
- package/dist/data/postgres-core/index.d.ts +35 -10
- package/dist/data/postgres-core/index.js +1 -1
- package/dist/{index-M4EjPWNJ.d.ts → index-BDPv5Gnt.d.ts} +19 -6
- package/dist/{index-CnVNNyod.d.cts → index-BNAA6jKD.d.cts} +19 -6
- package/dist/ui/index.cjs +62 -54
- package/dist/ui/index.css +154 -41
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +14 -6
- package/package.json +5 -2
- package/dist/chunk-2FW6TKD6.js +0 -1
- package/dist/chunk-RGBMDID6.js +0 -1
- package/dist/chunk-ZCFLMQMM.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as l,b as a,c as m,d as s,e as u,f as v}from"./chunk-5MNS4IJC.js";import{Z as c,g as n,q as e}from"./chunk-N2MLAUEV.js";import"./chunk-
|
|
1
|
+
import{a as l,b as a,c as m,d as s,e as u,f as v}from"./chunk-5MNS4IJC.js";import{Z as c,g as n,q as e}from"./chunk-N2MLAUEV.js";import"./chunk-BMVJYUJW.js";var p=i=>{let[r,t]=l({prefix:"TanstackQueryDevtools"}),d=c(),f=n(()=>{let o=r.theme_preference||a;return o!=="system"?o:d()});return e(m.Provider,{value:i,get children(){return e(s,{localStore:r,setLocalStore:t,get children(){return e(u.Provider,{value:f,get children(){return e(v,{localStore:r,setLocalStore:t})}})}})}})},E=p;export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as s,c as u,d as i,e as m,g as d,h as P}from"./chunk-5MNS4IJC.js";import{Z as a,g as l,q as e}from"./chunk-N2MLAUEV.js";import"./chunk-
|
|
1
|
+
import{a as c,b as s,c as u,d as i,e as m,g as d,h as P}from"./chunk-5MNS4IJC.js";import{Z as a,g as l,q as e}from"./chunk-N2MLAUEV.js";import"./chunk-BMVJYUJW.js";var C=t=>{let[r,o]=c({prefix:"TanstackQueryDevtools"}),v=a(),h=l(()=>{let n=r.theme_preference||s;return n!=="system"?n:v()});return e(u.Provider,{value:t,get children(){return e(i,{disabled:!0,localStore:r,setLocalStore:o,get children(){return e(m.Provider,{value:h,get children(){return e(d,{get children(){return e(P,{localStore:r,setLocalStore:o,get onClose(){return t.onClose},showPanelViewOnly:!0})}})}})}})}})},E=C;export{E as default};
|
|
@@ -27,6 +27,10 @@ interface Adapter {
|
|
|
27
27
|
* Updates a given row in the database with given changes.
|
|
28
28
|
*/
|
|
29
29
|
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<Error, AdapterUpdateResult>>;
|
|
30
|
+
/**
|
|
31
|
+
* Deletes given rows from the database.
|
|
32
|
+
*/
|
|
33
|
+
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<Error, AdapterDeleteResult>>;
|
|
30
34
|
}
|
|
31
35
|
interface AdapterBaseOptions {
|
|
32
36
|
}
|
|
@@ -39,6 +43,8 @@ interface AdapterInsertOptions extends AdapterBaseOptions {
|
|
|
39
43
|
}
|
|
40
44
|
interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
41
45
|
}
|
|
46
|
+
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
47
|
+
}
|
|
42
48
|
type SchemaName = string;
|
|
43
49
|
interface Introspection {
|
|
44
50
|
schemas: Record<SchemaName, Schema>;
|
|
@@ -56,10 +62,12 @@ interface Table {
|
|
|
56
62
|
}
|
|
57
63
|
interface Column {
|
|
58
64
|
datatype: DataType;
|
|
65
|
+
isComputed: boolean;
|
|
66
|
+
isInPrimaryKey: boolean;
|
|
59
67
|
name: ColumnName;
|
|
68
|
+
nullable: boolean;
|
|
60
69
|
schema: SchemaName;
|
|
61
70
|
table: TableName;
|
|
62
|
-
isInPrimaryKey: boolean;
|
|
63
71
|
}
|
|
64
72
|
interface DataType {
|
|
65
73
|
/**
|
|
@@ -72,12 +80,26 @@ interface DataType {
|
|
|
72
80
|
* Is this a native array type?
|
|
73
81
|
*/
|
|
74
82
|
isArray: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Is a native database datatype or a user-defined datatype?
|
|
85
|
+
*
|
|
86
|
+
* e.g. PostgreSQL enums are user-defined datatypes, but `int4` is a native datatype.
|
|
87
|
+
*/
|
|
88
|
+
isNative: boolean;
|
|
75
89
|
/**
|
|
76
90
|
* Will be displayed as-is.
|
|
77
91
|
*/
|
|
78
92
|
name: string;
|
|
93
|
+
/**
|
|
94
|
+
* Enum values for enum types.
|
|
95
|
+
*/
|
|
96
|
+
options: string[];
|
|
97
|
+
/**
|
|
98
|
+
* The schema the datatype belongs to.
|
|
99
|
+
*/
|
|
100
|
+
schema: string;
|
|
79
101
|
}
|
|
80
|
-
type DataTypeGroup = "string" | "datetime" | "time" | "raw";
|
|
102
|
+
type DataTypeGroup = "string" | "datetime" | "boolean" | "enum" | "time" | "raw" | "numeric" | "json";
|
|
81
103
|
interface AdapterQueryDetails {
|
|
82
104
|
/**
|
|
83
105
|
* Zero-based index of the page to fetch.
|
|
@@ -129,13 +151,13 @@ interface AdapterInsertDetails {
|
|
|
129
151
|
* - The keys should match the column names in the table.
|
|
130
152
|
* - The values should be the values to insert into the table.
|
|
131
153
|
*/
|
|
132
|
-
|
|
154
|
+
rows: Record<string, unknown>[];
|
|
133
155
|
}
|
|
134
156
|
interface AdapterInsertResult {
|
|
135
157
|
/**
|
|
136
158
|
* The freshly inserted row data.
|
|
137
159
|
*/
|
|
138
|
-
|
|
160
|
+
rows: Record<string, unknown>[];
|
|
139
161
|
}
|
|
140
162
|
interface AdapterUpdateDetails {
|
|
141
163
|
/**
|
|
@@ -162,5 +184,18 @@ interface AdapterUpdateResult {
|
|
|
162
184
|
__ps_updated_at__: string | number | Date;
|
|
163
185
|
};
|
|
164
186
|
}
|
|
187
|
+
interface AdapterDeleteDetails {
|
|
188
|
+
/**
|
|
189
|
+
* The rows to delete.
|
|
190
|
+
*/
|
|
191
|
+
rows: Record<ColumnName, unknown>[];
|
|
192
|
+
/**
|
|
193
|
+
* The table to delete from.
|
|
194
|
+
*/
|
|
195
|
+
table: Table;
|
|
196
|
+
}
|
|
197
|
+
interface AdapterDeleteResult {
|
|
198
|
+
rows: Record<ColumnName, unknown>[];
|
|
199
|
+
}
|
|
165
200
|
|
|
166
|
-
export type { Adapter as A, BigIntString as B, Column as C, DataType as D, Either as E, Introspection as I, NumericString as N, Schema as S, Table as T, AdapterInsertDetails as a, AdapterQueryDetails as b, AdapterUpdateDetails as c,
|
|
201
|
+
export type { Adapter as A, BigIntString as B, Column as C, DataType as D, Either as E, Introspection as I, NumericString as N, Schema as S, Table as T, AdapterInsertDetails as a, AdapterQueryDetails as b, AdapterUpdateDetails as c, AdapterDeleteDetails as d, AdapterBaseOptions as e, AdapterIntrospectOptions as f, AdapterQueryOptions as g, AdapterInsertOptions as h, AdapterUpdateOptions as i, AdapterDeleteOptions as j, DataTypeGroup as k, SortOrderItem as l, SortDirection as m, AdapterQueryResult as n, AdapterInsertResult as o, AdapterUpdateResult as p, AdapterDeleteResult as q };
|
|
@@ -27,6 +27,10 @@ interface Adapter {
|
|
|
27
27
|
* Updates a given row in the database with given changes.
|
|
28
28
|
*/
|
|
29
29
|
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<Error, AdapterUpdateResult>>;
|
|
30
|
+
/**
|
|
31
|
+
* Deletes given rows from the database.
|
|
32
|
+
*/
|
|
33
|
+
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<Error, AdapterDeleteResult>>;
|
|
30
34
|
}
|
|
31
35
|
interface AdapterBaseOptions {
|
|
32
36
|
}
|
|
@@ -39,6 +43,8 @@ interface AdapterInsertOptions extends AdapterBaseOptions {
|
|
|
39
43
|
}
|
|
40
44
|
interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
41
45
|
}
|
|
46
|
+
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
47
|
+
}
|
|
42
48
|
type SchemaName = string;
|
|
43
49
|
interface Introspection {
|
|
44
50
|
schemas: Record<SchemaName, Schema>;
|
|
@@ -56,10 +62,12 @@ interface Table {
|
|
|
56
62
|
}
|
|
57
63
|
interface Column {
|
|
58
64
|
datatype: DataType;
|
|
65
|
+
isComputed: boolean;
|
|
66
|
+
isInPrimaryKey: boolean;
|
|
59
67
|
name: ColumnName;
|
|
68
|
+
nullable: boolean;
|
|
60
69
|
schema: SchemaName;
|
|
61
70
|
table: TableName;
|
|
62
|
-
isInPrimaryKey: boolean;
|
|
63
71
|
}
|
|
64
72
|
interface DataType {
|
|
65
73
|
/**
|
|
@@ -72,12 +80,26 @@ interface DataType {
|
|
|
72
80
|
* Is this a native array type?
|
|
73
81
|
*/
|
|
74
82
|
isArray: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Is a native database datatype or a user-defined datatype?
|
|
85
|
+
*
|
|
86
|
+
* e.g. PostgreSQL enums are user-defined datatypes, but `int4` is a native datatype.
|
|
87
|
+
*/
|
|
88
|
+
isNative: boolean;
|
|
75
89
|
/**
|
|
76
90
|
* Will be displayed as-is.
|
|
77
91
|
*/
|
|
78
92
|
name: string;
|
|
93
|
+
/**
|
|
94
|
+
* Enum values for enum types.
|
|
95
|
+
*/
|
|
96
|
+
options: string[];
|
|
97
|
+
/**
|
|
98
|
+
* The schema the datatype belongs to.
|
|
99
|
+
*/
|
|
100
|
+
schema: string;
|
|
79
101
|
}
|
|
80
|
-
type DataTypeGroup = "string" | "datetime" | "time" | "raw";
|
|
102
|
+
type DataTypeGroup = "string" | "datetime" | "boolean" | "enum" | "time" | "raw" | "numeric" | "json";
|
|
81
103
|
interface AdapterQueryDetails {
|
|
82
104
|
/**
|
|
83
105
|
* Zero-based index of the page to fetch.
|
|
@@ -129,13 +151,13 @@ interface AdapterInsertDetails {
|
|
|
129
151
|
* - The keys should match the column names in the table.
|
|
130
152
|
* - The values should be the values to insert into the table.
|
|
131
153
|
*/
|
|
132
|
-
|
|
154
|
+
rows: Record<string, unknown>[];
|
|
133
155
|
}
|
|
134
156
|
interface AdapterInsertResult {
|
|
135
157
|
/**
|
|
136
158
|
* The freshly inserted row data.
|
|
137
159
|
*/
|
|
138
|
-
|
|
160
|
+
rows: Record<string, unknown>[];
|
|
139
161
|
}
|
|
140
162
|
interface AdapterUpdateDetails {
|
|
141
163
|
/**
|
|
@@ -162,5 +184,18 @@ interface AdapterUpdateResult {
|
|
|
162
184
|
__ps_updated_at__: string | number | Date;
|
|
163
185
|
};
|
|
164
186
|
}
|
|
187
|
+
interface AdapterDeleteDetails {
|
|
188
|
+
/**
|
|
189
|
+
* The rows to delete.
|
|
190
|
+
*/
|
|
191
|
+
rows: Record<ColumnName, unknown>[];
|
|
192
|
+
/**
|
|
193
|
+
* The table to delete from.
|
|
194
|
+
*/
|
|
195
|
+
table: Table;
|
|
196
|
+
}
|
|
197
|
+
interface AdapterDeleteResult {
|
|
198
|
+
rows: Record<ColumnName, unknown>[];
|
|
199
|
+
}
|
|
165
200
|
|
|
166
|
-
export type { Adapter as A, BigIntString as B, Column as C, DataType as D, Either as E, Introspection as I, NumericString as N, Schema as S, Table as T, AdapterInsertDetails as a, AdapterQueryDetails as b, AdapterUpdateDetails as c,
|
|
201
|
+
export type { Adapter as A, BigIntString as B, Column as C, DataType as D, Either as E, Introspection as I, NumericString as N, Schema as S, Table as T, AdapterInsertDetails as a, AdapterQueryDetails as b, AdapterUpdateDetails as c, AdapterDeleteDetails as d, AdapterBaseOptions as e, AdapterIntrospectOptions as f, AdapterQueryOptions as g, AdapterInsertOptions as h, AdapterUpdateOptions as i, AdapterDeleteOptions as j, DataTypeGroup as k, SortOrderItem as l, SortDirection as m, AdapterQueryResult as n, AdapterInsertResult as o, AdapterUpdateResult as p, AdapterDeleteResult as q };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var l=(b,a)=>{for(var c in a)g(b,c,{get:a[c],enumerable:!0})},f=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!j.call(b,d)&&d!==c&&g(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b},m=(b,a,c)=>(f(b,a,"default"),c&&f(c,a,"default"));var p={postgres:{encoded:"ZGF0YXNvdXJjZSBkYiB7CiAgICBwcm92aWRlciA9ICJwb3N0Z3JlcyIKICAgIHVybCAgICAgID0gZW52KCJEQVRBQkFTRV9VUkwiKQp9CiAgICAKZ2VuZXJhdG9yIGNsaWVudCB7CiAgICBwcm92aWRlciA9ICJwcmlzbWEtY2xpZW50LWpzIgp9",hash:"54195896aeafa3318ca33f5a8bb44c6b4d89c368cb15288f3bd5ace35a3f9227"}};export{l as a,m as b,p as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function U(r){return typeof r>"u"||r===void 0}function W(r){return typeof r=="string"}function Le(r){return typeof r=="number"}function qr(r){return typeof r=="boolean"}function Ir(r){return r===null}function ci(r){return r instanceof Date}function Br(r){return typeof r=="bigint"}function O(r){return typeof r=="function"}function A(r){return typeof r=="object"&&r!==null}function o(r){return Object.freeze(r)}function yr(r){return D(r)?r:[r]}function D(r){return Array.isArray(r)}function L(r){return r}var h=o({is(r){return r.kind==="AlterTableNode"},create(r){return o({kind:"AlterTableNode",table:r})},cloneWithTableProps(r,e){return o({...r,...e})},cloneWithColumnAlteration(r,e){return o({...r,columnAlterations:r.columnAlterations?[...r.columnAlterations,e]:[e]})}});var d=o({is(r){return r.kind==="IdentifierNode"},create(r){return o({kind:"IdentifierNode",name:r})}});var Y=o({is(r){return r.kind==="CreateIndexNode"},create(r){return o({kind:"CreateIndexNode",name:d.create(r)})},cloneWith(r,e){return o({...r,...e})},cloneWithColumns(r,e){return o({...r,columns:[...r.columns||[],...e]})}});var Dr=o({is(r){return r.kind==="CreateSchemaNode"},create(r,e){return o({kind:"CreateSchemaNode",schema:d.create(r),...e})},cloneWith(r,e){return o({...r,...e})}});var Po=["preserve rows","delete rows","drop"],M=o({is(r){return r.kind==="CreateTableNode"},create(r){return o({kind:"CreateTableNode",table:r,columns:o([])})},cloneWithColumn(r,e){return o({...r,columns:o([...r.columns,e])})},cloneWithConstraint(r,e){return o({...r,constraints:r.constraints?o([...r.constraints,e]):o([e])})},cloneWithFrontModifier(r,e){return o({...r,frontModifiers:r.frontModifiers?o([...r.frontModifiers,e]):o([e])})},cloneWithEndModifier(r,e){return o({...r,endModifiers:r.endModifiers?o([...r.endModifiers,e]):o([e])})},cloneWith(r,e){return o({...r,...e})}});var Q=o({is(r){return r.kind==="SchemableIdentifierNode"},create(r){return o({kind:"SchemableIdentifierNode",identifier:d.create(r)})},createWithSchema(r,e){return o({kind:"SchemableIdentifierNode",schema:d.create(r),identifier:d.create(e)})}});var We=o({is(r){return r.kind==="DropIndexNode"},create(r,e){return o({kind:"DropIndexNode",name:Q.create(r),...e})},cloneWith(r,e){return o({...r,...e})}});var wr=o({is(r){return r.kind==="DropSchemaNode"},create(r,e){return o({kind:"DropSchemaNode",schema:d.create(r),...e})},cloneWith(r,e){return o({...r,...e})}});var xr=o({is(r){return r.kind==="DropTableNode"},create(r,e){return o({kind:"DropTableNode",table:r,...e})},cloneWith(r,e){return o({...r,...e})}});var P=o({is(r){return r.kind==="AliasNode"},create(r,e){return o({kind:"AliasNode",node:r,alias:e})}});var J=o({is(r){return r.kind==="TableNode"},create(r){return o({kind:"TableNode",table:Q.create(r)})},createWithSchema(r,e){return o({kind:"TableNode",table:Q.createWithSchema(r,e)})}});function g(r){return A(r)&&O(r.toOperationNode)}function Qr(r){return A(r)&&"expressionType"in r&&g(r)}function vo(r){return A(r)&&"expression"in r&&W(r.alias)&&g(r)}var se=o({is(r){return r.kind==="SelectModifierNode"},create(r,e){return o({kind:"SelectModifierNode",modifier:r,of:e})},createWithExpression(r){return o({kind:"SelectModifierNode",rawModifier:r})}});var z=o({is(r){return r.kind==="AndNode"},create(r,e){return o({kind:"AndNode",left:r,right:e})}});var X=o({is(r){return r.kind==="OrNode"},create(r,e){return o({kind:"OrNode",left:r,right:e})}});var Pr=o({is(r){return r.kind==="OnNode"},create(r){return o({kind:"OnNode",on:r})},cloneWithOperation(r,e,t){return o({...r,on:e==="And"?z.create(r.on,t):X.create(r.on,t)})}});var he=o({is(r){return r.kind==="JoinNode"},create(r,e){return o({kind:"JoinNode",joinType:r,table:e,on:void 0})},createWithOn(r,e,t){return o({kind:"JoinNode",joinType:r,table:e,on:Pr.create(t)})},cloneWithOn(r,e){return o({...r,on:r.on?Pr.cloneWithOperation(r.on,"And",e):Pr.create(e)})}});var ge=o({is(r){return r.kind==="BinaryOperationNode"},create(r,e,t){return o({kind:"BinaryOperationNode",leftOperand:r,operator:e,rightOperand:t})}});var qn=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],In=["+","-","*","/","%","^","&","|","#","<<",">>"],Lo=["->","->>"],Bn=[...qn,...In,"&&","||"],Dn=["exists","not exists"],Qn=["not","-",...Dn],Fo=[...Bn,...Lo,...Qn,"between","between symmetric"],Z=o({is(r){return r.kind==="OperatorNode"},create(r){return o({kind:"OperatorNode",operator:r})}});function Lt(r){return W(r)&&Lo.includes(r)}var m=o({is(r){return r.kind==="ColumnNode"},create(r){return o({kind:"ColumnNode",column:d.create(r)})}});var Fe=o({is(r){return r.kind==="SelectAllNode"},create(){return o({kind:"SelectAllNode"})}});var Me=o({is(r){return r.kind==="ReferenceNode"},create(r,e){return o({kind:"ReferenceNode",table:e,column:r})},createSelectAll(r){return o({kind:"ReferenceNode",table:r,column:Fe.create()})}});var vr=class{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return Ft(this.#e)}};function Lr(r){return A(r)&&g(r)&&W(r.dynamicReference)}var _=o({is(r){return r.kind==="OrderByItemNode"},create(r,e){return o({kind:"OrderByItemNode",orderBy:r,direction:e})},cloneWith(r,e){return o({...r,...e})}});var v=o({is(r){return r.kind==="RawNode"},create(r,e){return o({kind:"RawNode",sqlFragments:o(r),parameters:o(e)})},createWithSql(r){return v.create([r],[])},createWithChild(r){return v.create(["",""],[r])},createWithChildren(r){return v.create(new Array(r.length+1).fill(""),r)}});var Mo={is(r){return r.kind==="CollateNode"},create(r){return o({kind:"CollateNode",collation:d.create(r)})}};var Fr=class r{#e;constructor(e){this.#e=o(e)}desc(){return new r({node:_.cloneWith(this.#e.node,{direction:v.createWithSql("desc")})})}asc(){return new r({node:_.cloneWith(this.#e.node,{direction:v.createWithSql("asc")})})}nullsLast(){return new r({node:_.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new r({node:_.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new r({node:_.cloneWith(this.#e.node,{collation:Mo.create(e)})})}toOperationNode(){return this.#e.node}};var zo=new Set;function ze(r){zo.has(r)||(zo.add(r),console.log(r))}function zt(r){return r==="asc"||r==="desc"}function $(r){if(r.length===2)return[Mt(r[0],r[1])];if(r.length===1){let[e]=r;return Array.isArray(e)?(ze("orderBy(array) is deprecated, use multiple orderBy calls instead."),e.map(t=>Mt(t))):[Mt(e)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${r.length}`)}function Mt(r,e){let t=Pn(r);if(_.is(t)){if(e)throw new Error("Cannot specify direction twice!");return t}return Vo(t,e)}function Pn(r){if(le(r))return V(r);if(Lr(r))return r.toOperationNode();let[e,t]=r.split(" ");return t?(ze("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),Vo(ee(e),t)):ee(r)}function Vo(r,e){if(typeof e=="string"){if(!zt(e))throw new Error(`Invalid order by direction: ${e}`);return _.create(r,v.createWithSql(e))}if(Qr(e))return ze("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),_.create(r,e.toOperationNode());let t=_.create(r);return e?e(new Fr({node:t})).toOperationNode():t}var Ve=o({is(r){return r.kind==="JSONReferenceNode"},create(r,e){return o({kind:"JSONReferenceNode",reference:r,traversal:e})},cloneWithTraversal(r,e){return o({...r,traversal:e})}});var Mr=o({is(r){return r.kind==="JSONOperatorChainNode"},create(r){return o({kind:"JSONOperatorChainNode",operator:r,values:o([])})},cloneWithValue(r,e){return o({...r,values:o([...r.values,e])})}});var Ce=o({is(r){return r.kind==="JSONPathNode"},create(r){return o({kind:"JSONPathNode",inOperator:r,pathLegs:o([])})},cloneWithLeg(r,e){return o({...r,pathLegs:o([...r.pathLegs,e])})}});function Ft(r){return W(r)?ee(r):r.toOperationNode()}function pe(r){return D(r)?r.map(e=>R(e)):[R(r)]}function R(r){return le(r)?V(r):Ft(r)}function Uo(r,e){let t=ee(r);if(Lt(e))return Ve.create(t,Mr.create(Z.create(e)));let n=e.slice(0,-1);if(Lt(n))return Ve.create(t,Ce.create(Z.create(n)));throw new Error(`Invalid JSON operator: ${e}`)}function ee(r){let e=".";if(!r.includes(e))return Me.create(m.create(r));let t=r.split(e).map(Ut);if(t.length===3)return vn(t);if(t.length===2)return Ln(t);throw new Error(`invalid column reference ${r}`)}function Jo(r){let e=" as ";if(r.includes(e)){let[t,n]=r.split(e).map(Ut);return P.create(ee(t),d.create(n))}else return ee(r)}function Vt(r){return m.create(r)}function Ue(r){let e=" ";if(r.includes(e)){let[t,n]=r.split(e).map(Ut);if(!zt(n))throw new Error(`invalid order direction "${n}" next to "${t}"`);return $([t,n])[0]}else return Vt(r)}function vn(r){let[e,t,n]=r;return Me.create(m.create(n),J.createWithSchema(e,t))}function Ln(r){let[e,t]=r;return Me.create(m.create(t),J.create(e))}function Ut(r){return r.trim()}var zr=o({is(r){return r.kind==="PrimitiveValueListNode"},create(r){return o({kind:"PrimitiveValueListNode",values:o([...r])})}});var ae=o({is(r){return r.kind==="ValueListNode"},create(r){return o({kind:"ValueListNode",values:o(r)})}});var b=o({is(r){return r.kind==="ValueNode"},create(r){return o({kind:"ValueNode",value:r})},createImmediate(r){return o({kind:"ValueNode",value:r,immediate:!0})}});function $o(r){return D(r)?Fn(r):w(r)}function w(r){return le(r)?V(r):b.create(r)}function Vr(r){return Le(r)||qr(r)||Ir(r)}function Or(r){if(!Vr(r))throw new Error(`unsafe immediate value ${JSON.stringify(r)}`);return b.createImmediate(r)}function Fn(r){return r.some(le)?ae.create(r.map(e=>w(e))):zr.create(r)}var be=o({is(r){return r.kind==="ParensNode"},create(r){return o({kind:"ParensNode",node:r})}});function N(r){if(r.length===3)return Ur(r[0],r[1],r[2]);if(r.length===1)return w(r[0]);throw new Error(`invalid arguments: ${JSON.stringify(r)}`)}function Ur(r,e,t){return Mn(e)&&Go(t)?ge.create(R(r),Jt(e),b.createImmediate(t)):ge.create(R(r),Jt(e),$o(t))}function T(r,e,t){return ge.create(R(r),Jt(e),R(t))}function $t(r,e){return Je(Object.entries(r).filter(([,t])=>!U(t)).map(([t,n])=>Ur(t,Go(n)?"is":"=",n)),e)}function Je(r,e,t=!0){let n=e==="and"?z.create:X.create;if(r.length===0)return ge.create(b.createImmediate(1),Z.create("="),b.createImmediate(e==="and"?1:0));let s=Ko(r[0]);for(let u=1;u<r.length;++u)s=n(s,Ko(r[u]));return r.length>1&&t?be.create(s):s}function Mn(r){return r==="is"||r==="is not"}function Go(r){return Ir(r)||qr(r)}function Jt(r){if(W(r)&&Fo.includes(r))return Z.create(r);if(g(r))return r.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(r)}`)}function Ko(r){return g(r)?r.toOperationNode():r}var fe=o({is(r){return r.kind==="OrderByNode"},create(r){return o({kind:"OrderByNode",items:o([...r])})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var Kt=o({is(r){return r.kind==="PartitionByNode"},create(r){return o({kind:"PartitionByNode",items:o(r)})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var Wr=o({is(r){return r.kind==="OverNode"},create(){return o({kind:"OverNode"})},cloneWithOrderByItems(r,e){return o({...r,orderBy:r.orderBy?fe.cloneWithItems(r.orderBy,e):fe.create(e)})},cloneWithPartitionByItems(r,e){return o({...r,partitionBy:r.partitionBy?Kt.cloneWithItems(r.partitionBy,e):Kt.create(e)})}});var Re=o({is(r){return r.kind==="FromNode"},create(r){return o({kind:"FromNode",froms:o(r)})},cloneWithFroms(r,e){return o({...r,froms:o([...r.froms,...e])})}});var Gt=o({is(r){return r.kind==="GroupByNode"},create(r){return o({kind:"GroupByNode",items:o(r)})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var jt=o({is(r){return r.kind==="HavingNode"},create(r){return o({kind:"HavingNode",having:r})},cloneWithOperation(r,e,t){return o({...r,having:e==="And"?z.create(r.having,t):X.create(r.having,t)})}});var C=o({is(r){return r.kind==="InsertQueryNode"},create(r,e,t){return o({kind:"InsertQueryNode",into:r,...e&&{with:e},replace:t})},createWithoutInto(){return o({kind:"InsertQueryNode"})},cloneWith(r,e){return o({...r,...e})}});var Jr=o({is(r){return r.kind==="ListNode"},create(r){return o({kind:"ListNode",items:o(r)})}});var ue=o({is(r){return r.kind==="UpdateQueryNode"},create(r,e){return o({kind:"UpdateQueryNode",table:r.length===1?r[0]:Jr.create(r),...e&&{with:e}})},createWithoutTable(){return o({kind:"UpdateQueryNode"})},cloneWithFromItems(r,e){return o({...r,from:r.from?Re.cloneWithFroms(r.from,e):Re.create(e)})},cloneWithUpdates(r,e){return o({...r,updates:r.updates?o([...r.updates,...e]):e})},cloneWithLimit(r,e){return o({...r,limit:e})}});var Ht=o({is(r){return r.kind==="UsingNode"},create(r){return o({kind:"UsingNode",tables:o(r)})},cloneWithTables(r,e){return o({...r,tables:o([...r.tables,...e])})}});var ke=o({is(r){return r.kind==="DeleteQueryNode"},create(r,e){return o({kind:"DeleteQueryNode",from:Re.create(r),...e&&{with:e}})},cloneWithOrderByItems:(r,e)=>a.cloneWithOrderByItems(r,e),cloneWithoutOrderBy:r=>a.cloneWithoutOrderBy(r),cloneWithLimit(r,e){return o({...r,limit:e})},cloneWithoutLimit(r){return o({...r,limit:void 0})},cloneWithUsing(r,e){return o({...r,using:r.using!==void 0?Ht.cloneWithTables(r.using,e):Ht.create(e)})}});var q=o({is(r){return r.kind==="WhereNode"},create(r){return o({kind:"WhereNode",where:r})},cloneWithOperation(r,e,t){return o({...r,where:e==="And"?z.create(r.where,t):X.create(r.where,t)})}});var Yt=o({is(r){return r.kind==="ReturningNode"},create(r){return o({kind:"ReturningNode",selections:o(r)})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})}});var jo=o({is(r){return r.kind==="ExplainNode"},create(r,e){return o({kind:"ExplainNode",format:r,options:e})}});var Ne=o({is(r){return r.kind==="WhenNode"},create(r){return o({kind:"WhenNode",condition:r})},cloneWithResult(r,e){return o({...r,result:e})}});var K=o({is(r){return r.kind==="MergeQueryNode"},create(r,e){return o({kind:"MergeQueryNode",into:r,...e&&{with:e}})},cloneWithUsing(r,e){return o({...r,using:e})},cloneWithWhen(r,e){return o({...r,whens:r.whens?o([...r.whens,e]):o([e])})},cloneWithThen(r,e){return o({...r,whens:r.whens?o([...r.whens.slice(0,-1),Ne.cloneWithResult(r.whens[r.whens.length-1],e)]):void 0})}});var Xt=o({is(r){return r.kind==="OutputNode"},create(r){return o({kind:"OutputNode",selections:o(r)})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})}});var a=o({is(r){return f.is(r)||C.is(r)||ue.is(r)||ke.is(r)||K.is(r)},cloneWithEndModifier(r,e){return o({...r,endModifiers:r.endModifiers?o([...r.endModifiers,e]):o([e])})},cloneWithWhere(r,e){return o({...r,where:r.where?q.cloneWithOperation(r.where,"And",e):q.create(e)})},cloneWithJoin(r,e){return o({...r,joins:r.joins?o([...r.joins,e]):o([e])})},cloneWithReturning(r,e){return o({...r,returning:r.returning?Yt.cloneWithSelections(r.returning,e):Yt.create(e)})},cloneWithoutReturning(r){return o({...r,returning:void 0})},cloneWithoutWhere(r){return o({...r,where:void 0})},cloneWithExplain(r,e,t){return o({...r,explain:jo.create(e,t?.toOperationNode())})},cloneWithTop(r,e){return o({...r,top:e})},cloneWithOutput(r,e){return o({...r,output:r.output?Xt.cloneWithSelections(r.output,e):Xt.create(e)})},cloneWithOrderByItems(r,e){return o({...r,orderBy:r.orderBy?fe.cloneWithItems(r.orderBy,e):fe.create(e)})},cloneWithoutOrderBy(r){return o({...r,orderBy:void 0})}});var f=o({is(r){return r.kind==="SelectQueryNode"},create(r){return o({kind:"SelectQueryNode",...r&&{with:r}})},createFrom(r,e){return o({kind:"SelectQueryNode",from:Re.create(r),...e&&{with:e}})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})},cloneWithDistinctOn(r,e){return o({...r,distinctOn:r.distinctOn?o([...r.distinctOn,...e]):o(e)})},cloneWithFrontModifier(r,e){return o({...r,frontModifiers:r.frontModifiers?o([...r.frontModifiers,e]):o([e])})},cloneWithOrderByItems:(r,e)=>a.cloneWithOrderByItems(r,e),cloneWithGroupByItems(r,e){return o({...r,groupBy:r.groupBy?Gt.cloneWithItems(r.groupBy,e):Gt.create(e)})},cloneWithLimit(r,e){return o({...r,limit:e})},cloneWithOffset(r,e){return o({...r,offset:e})},cloneWithFetch(r,e){return o({...r,fetch:e})},cloneWithHaving(r,e){return o({...r,having:r.having?jt.cloneWithOperation(r.having,"And",e):jt.create(e)})},cloneWithSetOperations(r,e){return o({...r,setOperations:r.setOperations?o([...r.setOperations,...e]):o([...e])})},cloneWithoutSelections(r){return o({...r,selections:[]})},cloneWithoutLimit(r){return o({...r,limit:void 0})},cloneWithoutOffset(r){return o({...r,offset:void 0})},cloneWithoutOrderBy:r=>a.cloneWithoutOrderBy(r),cloneWithoutGroupBy(r){return o({...r,groupBy:void 0})}});var $r=class r{#e;constructor(e){this.#e=o(e)}on(...e){return new r({...this.#e,joinNode:he.cloneWithOn(this.#e.joinNode,N(e))})}onRef(e,t,n){return new r({...this.#e,joinNode:he.cloneWithOn(this.#e.joinNode,T(e,t,n))})}onTrue(){return new r({...this.#e,joinNode:he.cloneWithOn(this.#e.joinNode,v.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}};var Ho=o({is(r){return r.kind==="PartitionByItemNode"},create(r){return o({kind:"PartitionByItemNode",partitionBy:r})}});function Yo(r){return pe(r).map(Ho.create)}var Kr=class r{#e;constructor(e){this.#e=o(e)}orderBy(...e){return new r({overNode:Wr.cloneWithOrderByItems(this.#e.overNode,$(e))})}clearOrderBy(){return new r({overNode:a.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new r({overNode:Wr.cloneWithPartitionByItems(this.#e.overNode,Yo(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}};var $e=o({is(r){return r.kind==="SelectionNode"},create(r){return o({kind:"SelectionNode",selection:r})},createSelectAll(){return o({kind:"SelectionNode",selection:Fe.create()})},createSelectAllFromTable(r){return o({kind:"SelectionNode",selection:Me.createSelectAll(r)})}});function k(r){return O(r)?k(r(re())):D(r)?r.map(e=>Xo(e)):[Xo(r)]}function Xo(r){return W(r)?$e.create(Jo(r)):Lr(r)?$e.create(r.toOperationNode()):$e.create(Gr(r))}function S(r){return r?Array.isArray(r)?r.map(Zo):[Zo(r)]:[$e.createSelectAll()]}function Zo(r){if(W(r))return $e.createSelectAllFromTable(l(r));throw new Error(`invalid value selectAll expression: ${JSON.stringify(r)}`)}var _o=o({is(r){return r.kind==="ValuesNode"},create(r){return o({kind:"ValuesNode",values:o(r)})}});var en=o({is(r){return r.kind==="DefaultInsertValueNode"},create(){return o({kind:"DefaultInsertValueNode"})}});function jr(r){let e=O(r)?r(re()):r,t=D(e)?e:o([e]);return zn(t)}function zn(r){let e=Vn(r);return[o([...e.keys()].map(m.create)),_o.create(r.map(t=>Un(t,e)))]}function Vn(r){let e=new Map;for(let t of r){let n=Object.keys(t);for(let s of n)!e.has(s)&&t[s]!==void 0&&e.set(s,e.size)}return e}function Un(r,e){let t=Object.keys(r),n=Array.from({length:e.size}),s=!1,u=t.length;for(let E of t){let I=e.get(E);if(U(I)){u--;continue}let B=r[E];(U(B)||le(B))&&(s=!0),n[I]=B}if(u<e.size||s){let E=en.create();return ae.create(n.map(I=>U(I)?E:w(I)))}return zr.create(n)}var Zt=o({is(r){return r.kind==="ColumnUpdateNode"},create(r,e){return o({kind:"ColumnUpdateNode",column:r,value:e})}});function rn(...r){return r.length===2?[Zt.create(R(r[0]),w(r[1]))]:gr(r[0])}function gr(r){let e=O(r)?r(re()):r;return Object.entries(e).filter(([t,n])=>n!==void 0).map(([t,n])=>Zt.create(m.create(t),w(n)))}var tn=o({is(r){return r.kind==="OnDuplicateKeyNode"},create(r){return o({kind:"OnDuplicateKeyNode",updates:r})}});var Hr=class{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}};var j=class extends Error{node;constructor(e){super("no result"),this.node=e}};function de(r){return Object.prototype.hasOwnProperty.call(r,"prototype")}var F=o({is(r){return r.kind==="OnConflictNode"},create(){return o({kind:"OnConflictNode"})},cloneWith(r,e){return o({...r,...e})},cloneWithIndexWhere(r,e){return o({...r,indexWhere:r.indexWhere?q.cloneWithOperation(r.indexWhere,"And",e):q.create(e)})},cloneWithIndexOrWhere(r,e){return o({...r,indexWhere:r.indexWhere?q.cloneWithOperation(r.indexWhere,"Or",e):q.create(e)})},cloneWithUpdateWhere(r,e){return o({...r,updateWhere:r.updateWhere?q.cloneWithOperation(r.updateWhere,"And",e):q.create(e)})},cloneWithUpdateOrWhere(r,e){return o({...r,updateWhere:r.updateWhere?q.cloneWithOperation(r.updateWhere,"Or",e):q.create(e)})},cloneWithoutIndexWhere(r){return o({...r,indexWhere:void 0})},cloneWithoutUpdateWhere(r){return o({...r,updateWhere:void 0})}});var Yr=class r{#e;constructor(e){this.#e=o(e)}column(e){let t=m.create(e);return new r({...this.#e,onConflictNode:F.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?o([...this.#e.onConflictNode.columns,t]):o([t])})})}columns(e){let t=e.map(m.create);return new r({...this.#e,onConflictNode:F.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?o([...this.#e.onConflictNode.columns,...t]):o(t)})})}constraint(e){return new r({...this.#e,onConflictNode:F.cloneWith(this.#e.onConflictNode,{constraint:d.create(e)})})}expression(e){return new r({...this.#e,onConflictNode:F.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new r({...this.#e,onConflictNode:F.cloneWithIndexWhere(this.#e.onConflictNode,N(e))})}whereRef(e,t,n){return new r({...this.#e,onConflictNode:F.cloneWithIndexWhere(this.#e.onConflictNode,T(e,t,n))})}clearWhere(){return new r({...this.#e,onConflictNode:F.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new _t({...this.#e,onConflictNode:F.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new eo({...this.#e,onConflictNode:F.cloneWith(this.#e.onConflictNode,{updates:gr(e)})})}$call(e){return e(this)}},_t=class{#e;constructor(e){this.#e=o(e)}toOperationNode(){return this.#e.onConflictNode}},eo=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,onConflictNode:F.cloneWithUpdateWhere(this.#e.onConflictNode,N(e))})}whereRef(e,t,n){return new r({...this.#e,onConflictNode:F.cloneWithUpdateWhere(this.#e.onConflictNode,T(e,t,n))})}clearWhere(){return new r({...this.#e,onConflictNode:F.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}};var on=o({is(r){return r.kind==="TopNode"},create(r,e){return o({kind:"TopNode",expression:r,modifiers:e})}});function te(r,e){if(!Le(r)&&!Br(r))throw new Error(`Invalid top expression: ${r}`);if(!U(e)&&!Jn(e))throw new Error(`Invalid top modifiers: ${e}`);return on.create(r,e)}function Jn(r){return r==="percent"||r==="with ties"||r==="percent with ties"}var qe=o({is(r){return r.kind==="OrActionNode"},create(r){return o({kind:"OrActionNode",action:r})}});var Cr=class r{#e;constructor(e){this.#e=o(e)}values(e){let[t,n]=jr(e);return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{columns:t,values:n})})}columns(e){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{columns:o(e.map(m.create))})})}expression(e){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{values:V(e)})})}defaultValues(){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{orAction:qe.create("ignore")})})}orIgnore(){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{orAction:qe.create("ignore")})})}orAbort(){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{orAction:qe.create("abort")})})}orFail(){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{orAction:qe.create("fail")})})}orReplace(){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{orAction:qe.create("replace")})})}orRollback(){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{orAction:qe.create("rollback")})})}top(e,t){return new r({...this.#e,queryNode:a.cloneWithTop(this.#e.queryNode,te(e,t))})}onConflict(e){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{onConflict:e(new Yr({onConflictNode:F.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new r({...this.#e,queryNode:C.cloneWith(this.#e.queryNode,{onDuplicateKey:tn.create(gr(e))})})}returning(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,k(e))})}returningAll(){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,S())})}output(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,k(e))})}outputAll(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,S(e))})}clearReturning(){return new r({...this.#e,queryNode:a.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e,this.#e.queryId),{adapter:n}=this.#e.executor,s=e.query;return s.returning&&n.supportsReturning||s.output&&n.supportsOutput?t.rows:[new Hr(t.insertId,t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=j){let t=await this.executeTakeFirst();if(t===void 0)throw de(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e,this.#e.queryId);for await(let s of n)yield*s.rows}async explain(e,t){return await new r({...this.#e,queryNode:a.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var Xr=class{numDeletedRows;constructor(e){this.numDeletedRows=e}};var Ke=o({is(r){return r.kind==="LimitNode"},create(r){return o({kind:"LimitNode",limit:r})}});var Zr=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,queryNode:a.cloneWithWhere(this.#e.queryNode,N(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:a.cloneWithWhere(this.#e.queryNode,T(e,t,n))})}clearWhere(){return new r({...this.#e,queryNode:a.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new r({...this.#e,queryNode:a.cloneWithTop(this.#e.queryNode,te(e,t))})}using(e){return new r({...this.#e,queryNode:ke.cloneWithUsing(this.#e.queryNode,oe(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,t){return new r({...this.#e,queryNode:a.cloneWithJoin(this.#e.queryNode,Te(e,t))})}returning(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,k(e))})}returningAll(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,S(e))})}output(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,k(e))})}outputAll(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,S(e))})}clearReturning(){return new r({...this.#e,queryNode:a.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new r({...this.#e,queryNode:ke.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new r({...this.#e,queryNode:a.cloneWithOrderByItems(this.#e.queryNode,$(e))})}clearOrderBy(){return new r({...this.#e,queryNode:a.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new r({...this.#e,queryNode:ke.cloneWithLimit(this.#e.queryNode,Ke.create(w(e)))})}modifyEnd(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e,this.#e.queryId),{adapter:n}=this.#e.executor,s=e.query;return s.returning&&n.supportsReturning||s.output&&n.supportsOutput?t.rows:[new Xr(t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=j){let t=await this.executeTakeFirst();if(t===void 0)throw de(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e,this.#e.queryId);for await(let s of n)yield*s.rows}async explain(e,t){return await new r({...this.#e,queryNode:a.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var _r=class{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}};var Ge=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,queryNode:a.cloneWithWhere(this.#e.queryNode,N(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:a.cloneWithWhere(this.#e.queryNode,T(e,t,n))})}clearWhere(){return new r({...this.#e,queryNode:a.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new r({...this.#e,queryNode:a.cloneWithTop(this.#e.queryNode,te(e,t))})}from(e){return new r({...this.#e,queryNode:ue.cloneWithFromItems(this.#e.queryNode,oe(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,t){return new r({...this.#e,queryNode:a.cloneWithJoin(this.#e.queryNode,Te(e,t))})}orderBy(...e){return new r({...this.#e,queryNode:a.cloneWithOrderByItems(this.#e.queryNode,$(e))})}clearOrderBy(){return new r({...this.#e,queryNode:a.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new r({...this.#e,queryNode:ue.cloneWithLimit(this.#e.queryNode,Ke.create(w(e)))})}set(...e){return new r({...this.#e,queryNode:ue.cloneWithUpdates(this.#e.queryNode,rn(...e))})}returning(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,k(e))})}returningAll(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,S(e))})}output(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,k(e))})}outputAll(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,S(e))})}modifyEnd(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new r({...this.#e,queryNode:a.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e,this.#e.queryId),{adapter:n}=this.#e.executor,s=e.query;return s.returning&&n.supportsReturning||s.output&&n.supportsOutput?t.rows:[new _r(t.numAffectedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=j){let t=await this.executeTakeFirst();if(t===void 0)throw de(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e,this.#e.queryId);for await(let s of n)yield*s.rows}async explain(e,t){return await new r({...this.#e,queryNode:a.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var ro=o({is(r){return r.kind==="CommonTableExpressionNameNode"},create(r,e){return o({kind:"CommonTableExpressionNameNode",table:J.create(r),columns:e?o(e.map(m.create)):void 0})}});var je=o({is(r){return r.kind==="CommonTableExpressionNode"},create(r,e){return o({kind:"CommonTableExpressionNode",name:r,expression:e})},cloneWith(r,e){return o({...r,...e})}});var et=class r{#e;constructor(e){this.#e=o(e)}materialized(){return new r({...this.#e,node:je.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new r({...this.#e,node:je.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}};function to(r,e){let t=e(sn()).toOperationNode();return O(r)?r($n(t)).toOperationNode():je.create(nn(r),t)}function $n(r){return e=>new et({node:je.create(nn(e),r)})}function nn(r){if(r.includes("(")){let e=r.split(/[\(\)]/),t=e[0],n=e[1].split(",").map(s=>s.trim());return ro.create(t,n)}else return ro.create(r)}var br=o({is(r){return r.kind==="WithNode"},create(r,e){return o({kind:"WithNode",expressions:o([r]),...e})},cloneWithExpression(r,e){return o({...r,expressions:o([...r.expressions,e])})}});var an=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function un(r){let e="";for(let t=0;t<r;++t)e+=Kn();return e}function Kn(){return an[~~(Math.random()*an.length)]}function x(){return new oo}var oo=class{#e;get queryId(){return this.#e===void 0&&(this.#e=un(8)),this.#e}};var Se=class{nodeStack=[];#e=o({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,t){if(!e)return e;this.nodeStack.push(e);let n=this.transformNodeImpl(e,t);return this.nodeStack.pop(),o(n)}transformNodeImpl(e,t){return this.#e[e.kind](e,t)}transformNodeList(e,t){return e&&o(e.map(n=>this.transformNode(n,t)))}transformSelectQuery(e,t){return{kind:"SelectQueryNode",from:this.transformNode(e.from,t),selections:this.transformNodeList(e.selections,t),distinctOn:this.transformNodeList(e.distinctOn,t),joins:this.transformNodeList(e.joins,t),groupBy:this.transformNode(e.groupBy,t),orderBy:this.transformNode(e.orderBy,t),where:this.transformNode(e.where,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),limit:this.transformNode(e.limit,t),offset:this.transformNode(e.offset,t),with:this.transformNode(e.with,t),having:this.transformNode(e.having,t),explain:this.transformNode(e.explain,t),setOperations:this.transformNodeList(e.setOperations,t),fetch:this.transformNode(e.fetch,t),top:this.transformNode(e.top,t)}}transformSelection(e,t){return{kind:"SelectionNode",selection:this.transformNode(e.selection,t)}}transformColumn(e,t){return{kind:"ColumnNode",column:this.transformNode(e.column,t)}}transformAlias(e,t){return{kind:"AliasNode",node:this.transformNode(e.node,t),alias:this.transformNode(e.alias,t)}}transformTable(e,t){return{kind:"TableNode",table:this.transformNode(e.table,t)}}transformFrom(e,t){return{kind:"FromNode",froms:this.transformNodeList(e.froms,t)}}transformReference(e,t){return{kind:"ReferenceNode",column:this.transformNode(e.column,t),table:this.transformNode(e.table,t)}}transformAnd(e,t){return{kind:"AndNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformOr(e,t){return{kind:"OrNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformValueList(e,t){return{kind:"ValueListNode",values:this.transformNodeList(e.values,t)}}transformParens(e,t){return{kind:"ParensNode",node:this.transformNode(e.node,t)}}transformJoin(e,t){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,t),on:this.transformNode(e.on,t)}}transformRaw(e,t){return{kind:"RawNode",sqlFragments:o([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,t)}}transformWhere(e,t){return{kind:"WhereNode",where:this.transformNode(e.where,t)}}transformInsertQuery(e,t){return{kind:"InsertQueryNode",into:this.transformNode(e.into,t),columns:this.transformNodeList(e.columns,t),values:this.transformNode(e.values,t),returning:this.transformNode(e.returning,t),onConflict:this.transformNode(e.onConflict,t),onDuplicateKey:this.transformNode(e.onDuplicateKey,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),ignore:e.ignore,orAction:this.transformNode(e.orAction,t),replace:e.replace,explain:this.transformNode(e.explain,t),defaultValues:e.defaultValues,top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformValues(e,t){return{kind:"ValuesNode",values:this.transformNodeList(e.values,t)}}transformDeleteQuery(e,t){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,t),using:this.transformNode(e.using,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),orderBy:this.transformNode(e.orderBy,t),limit:this.transformNode(e.limit,t),explain:this.transformNode(e.explain,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformReturning(e,t){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,t)}}transformCreateTable(e,t){return{kind:"CreateTableNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),constraints:this.transformNodeList(e.constraints,t),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),selectQuery:this.transformNode(e.selectQuery,t)}}transformColumnDefinition(e,t){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),references:this.transformNode(e.references,t),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,t),check:this.transformNode(e.check,t),generated:this.transformNode(e.generated,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,t){return{kind:"AddColumnNode",column:this.transformNode(e.column,t)}}transformDropTable(e,t){return{kind:"DropTableNode",table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e,t){return{kind:"OrderByNode",items:this.transformNodeList(e.items,t)}}transformOrderByItem(e,t){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,t),direction:this.transformNode(e.direction,t),collation:this.transformNode(e.collation,t),nulls:e.nulls}}transformGroupBy(e,t){return{kind:"GroupByNode",items:this.transformNodeList(e.items,t)}}transformGroupByItem(e,t){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,t)}}transformUpdateQuery(e,t){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,t),from:this.transformNode(e.from,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),updates:this.transformNodeList(e.updates,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),explain:this.transformNode(e.explain,t),limit:this.transformNode(e.limit,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t),orderBy:this.transformNode(e.orderBy,t)}}transformColumnUpdate(e,t){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,t),value:this.transformNode(e.value,t)}}transformLimit(e,t){return{kind:"LimitNode",limit:this.transformNode(e.limit,t)}}transformOffset(e,t){return{kind:"OffsetNode",offset:this.transformNode(e.offset,t)}}transformOnConflict(e,t){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,t),constraint:this.transformNode(e.constraint,t),indexExpression:this.transformNode(e.indexExpression,t),indexWhere:this.transformNode(e.indexWhere,t),updates:this.transformNodeList(e.updates,t),updateWhere:this.transformNode(e.updateWhere,t),doNothing:e.doNothing}}transformOnDuplicateKey(e,t){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,t)}}transformCreateIndex(e,t){return{kind:"CreateIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,t),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,t){return{kind:"ListNode",items:this.transformNodeList(e.items,t)}}transformDropIndex(e,t){return{kind:"DropIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,t){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,t){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,t){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,t),references:this.transformNode(e.references,t),name:this.transformNode(e.name,t),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,t){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,t),all:e.all}}transformReferences(e,t){return{kind:"ReferencesNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,t){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,t),name:this.transformNode(e.name,t)}}transformWith(e,t){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,t),recursive:e.recursive}}transformCommonTableExpression(e,t){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,t),materialized:e.materialized,expression:this.transformNode(e.expression,t)}}transformCommonTableExpressionName(e,t){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t)}}transformHaving(e,t){return{kind:"HavingNode",having:this.transformNode(e.having,t)}}transformCreateSchema(e,t){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,t),ifNotExists:e.ifNotExists}}transformDropSchema(e,t){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,t),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,t){return{kind:"AlterTableNode",table:this.transformNode(e.table,t),renameTo:this.transformNode(e.renameTo,t),setSchema:this.transformNode(e.setSchema,t),columnAlterations:this.transformNodeList(e.columnAlterations,t),addConstraint:this.transformNode(e.addConstraint,t),dropConstraint:this.transformNode(e.dropConstraint,t),renameConstraint:this.transformNode(e.renameConstraint,t),addIndex:this.transformNode(e.addIndex,t),dropIndex:this.transformNode(e.dropIndex,t)}}transformDropColumn(e,t){return{kind:"DropColumnNode",column:this.transformNode(e.column,t)}}transformRenameColumn(e,t){return{kind:"RenameColumnNode",column:this.transformNode(e.column,t),renameTo:this.transformNode(e.renameTo,t)}}transformAlterColumn(e,t){return{kind:"AlterColumnNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),dataTypeExpression:this.transformNode(e.dataTypeExpression,t),setDefault:this.transformNode(e.setDefault,t),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,t){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,t)}}transformAddConstraint(e,t){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,t)}}transformDropConstraint(e,t){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,t),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,t){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,t),newName:this.transformNode(e.newName,t)}}transformCreateView(e,t){return{kind:"CreateViewNode",name:this.transformNode(e.name,t),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,t),as:this.transformNode(e.as,t)}}transformRefreshMaterializedView(e,t){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,t),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,t){return{kind:"DropViewNode",name:this.transformNode(e.name,t),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,t){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,t)}}transformDefaultValue(e,t){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,t)}}transformOn(e,t){return{kind:"OnNode",on:this.transformNode(e.on,t)}}transformSelectModifier(e,t){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,t),of:this.transformNodeList(e.of,t)}}transformCreateType(e,t){return{kind:"CreateTypeNode",name:this.transformNode(e.name,t),enum:this.transformNode(e.enum,t)}}transformDropType(e,t){return{kind:"DropTypeNode",name:this.transformNode(e.name,t),ifExists:e.ifExists}}transformExplain(e,t){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,t)}}transformSchemableIdentifier(e,t){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,t),identifier:this.transformNode(e.identifier,t)}}transformAggregateFunction(e,t){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,t),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,t),withinGroup:this.transformNode(e.withinGroup,t),filter:this.transformNode(e.filter,t),over:this.transformNode(e.over,t)}}transformOver(e,t){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,t),partitionBy:this.transformNode(e.partitionBy,t)}}transformPartitionBy(e,t){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,t)}}transformPartitionByItem(e,t){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,t)}}transformBinaryOperation(e,t){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,t),operator:this.transformNode(e.operator,t),rightOperand:this.transformNode(e.rightOperand,t)}}transformUnaryOperation(e,t){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,t),operand:this.transformNode(e.operand,t)}}transformUsing(e,t){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,t)}}transformFunction(e,t){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,t)}}transformCase(e,t){return{kind:"CaseNode",value:this.transformNode(e.value,t),when:this.transformNodeList(e.when,t),else:this.transformNode(e.else,t),isStatement:e.isStatement}}transformWhen(e,t){return{kind:"WhenNode",condition:this.transformNode(e.condition,t),result:this.transformNode(e.result,t)}}transformJSONReference(e,t){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,t),traversal:this.transformNode(e.traversal,t)}}transformJSONPath(e,t){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,t),pathLegs:this.transformNodeList(e.pathLegs,t)}}transformJSONPathLeg(e,t){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,t){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,t),values:this.transformNodeList(e.values,t)}}transformTuple(e,t){return{kind:"TupleNode",values:this.transformNodeList(e.values,t)}}transformMergeQuery(e,t){return{kind:"MergeQueryNode",into:this.transformNode(e.into,t),using:this.transformNode(e.using,t),whens:this.transformNodeList(e.whens,t),with:this.transformNode(e.with,t),top:this.transformNode(e.top,t),endModifiers:this.transformNodeList(e.endModifiers,t),output:this.transformNode(e.output,t),returning:this.transformNode(e.returning,t)}}transformMatched(e,t){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,t){return{kind:"AddIndexNode",name:this.transformNode(e.name,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists}}transformCast(e,t){return{kind:"CastNode",expression:this.transformNode(e.expression,t),dataType:this.transformNode(e.dataType,t)}}transformFetch(e,t){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,t),modifier:e.modifier}}transformTop(e,t){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,t){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,t)}}transformDataType(e,t){return e}transformSelectAll(e,t){return e}transformIdentifier(e,t){return e}transformValue(e,t){return e}transformPrimitiveValueList(e,t){return e}transformOperator(e,t){return e}transformDefaultInsertValue(e,t){return e}transformOrAction(e,t){return e}transformCollate(e,t){return e}};var Gn=o({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),jn={json_agg:!0,to_json:!0},rt=class extends Se{#e;#r=new Set;#t=new Set;constructor(e){super(),this.#e=e}transformNodeImpl(e,t){if(!this.#o(e))return super.transformNodeImpl(e,t);let n=this.#d(e);for(let c of n)this.#t.add(c);let s=this.#a(e);for(let c of s)this.#r.add(c);let u=super.transformNodeImpl(e,t);for(let c of s)this.#r.delete(c);for(let c of n)this.#t.delete(c);return u}transformSchemableIdentifier(e,t){let n=super.transformSchemableIdentifier(e,t);return n.schema||!this.#r.has(e.identifier.name)?n:{...n,schema:d.create(this.#e)}}transformReferences(e,t){let n=super.transformReferences(e,t);return n.table.table.schema?n:{...n,table:J.createWithSchema(this.#e,n.table.table.identifier.name)}}transformAggregateFunction(e,t){return{...super.transformAggregateFunction({...e,aggregated:[]},t),aggregated:this.#i(e,t,"aggregated")}}transformFunction(e,t){return{...super.transformFunction({...e,arguments:[]},t),arguments:this.#i(e,t,"arguments")}}#i(e,t,n){return jn[e.func]?e[n].map(s=>!J.is(s)||s.table.schema?this.transformNode(s,t):{...s,table:this.transformIdentifier(s.table.identifier,t)}):this.transformNodeList(e[n],t)}#o(e){return e.kind in Gn}#a(e){let t=new Set;if("name"in e&&e.name&&Q.is(e.name)&&this.#s(e.name,t),"from"in e&&e.from)for(let n of e.from.froms)this.#n(n,t);if("into"in e&&e.into&&this.#n(e.into,t),"table"in e&&e.table&&this.#n(e.table,t),"joins"in e&&e.joins)for(let n of e.joins)this.#n(n.table,t);return"using"in e&&e.using&&this.#n(e.using,t),t}#d(e){let t=new Set;return"with"in e&&e.with&&this.#u(e.with,t),t}#n(e,t){if(J.is(e))this.#s(e.table,t);else if(P.is(e)&&J.is(e.node))this.#s(e.node.table,t);else if(Jr.is(e))for(let n of e.items)this.#n(n,t)}#s(e,t){let n=e.identifier.name;!this.#r.has(n)&&!this.#t.has(n)&&t.add(n)}#u(e,t){for(let n of e.expressions){let s=n.name.table.table.identifier.name;this.#t.has(s)||t.add(s)}}};var H=class{#e;constructor(e){this.#e=new rt(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}};var dn=o({is(r){return r.kind==="MatchedNode"},create(r,e=!1){return o({kind:"MatchedNode",not:r,bySource:e})}});function no(r,e,t){return Ne.create(Je([dn.create(!r.isMatched,r.bySource),...e&&e.length>0?[e.length===3&&t?T(e[0],e[1],e[2]):N(e)]:[]],"and",!1))}function He(r){return W(r)?v.create([r],[]):g(r)?r.toOperationNode():r}var kr=class{#e;#r;#t;constructor(){this.#e=new Promise((e,t)=>{this.#t=t,this.#r=e})}get promise(){return this.#e}resolve=e=>{this.#r&&this.#r(e)};reject=e=>{this.#t&&this.#t(e)}};async function tt(r){let e=new kr,t=new kr;return r.provideConnection(async n=>(e.resolve(n),await t.promise)).catch(n=>e.reject(n)),o({connection:await e.promise,release:t.resolve})}var Hn=o([]),Ye=class{#e;constructor(e=Hn){this.#e=e}get plugins(){return this.#e}transformQuery(e,t){for(let n of this.#e){let s=n.transformQuery({node:e,queryId:t});if(s.kind===e.kind)e=s;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${s.kind}`].join(" "))}return e}async executeQuery(e,t){return await this.provideConnection(async n=>{let s=await n.executeQuery(e);return"numUpdatedOrDeletedRows"in s&&ze("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`."),await this.#r(s,t)})}async*stream(e,t,n){let{connection:s,release:u}=await tt(this);try{for await(let c of s.streamQuery(e,t))yield await this.#r(c,n)}finally{u()}}async#r(e,t){for(let n of this.#e)e=await n.transformResult({result:e,queryId:t});return e}};var io=class r extends Ye{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new r([...this.plugins,e])}withPlugins(e){return new r([...this.plugins,...e])}withPluginAtFront(e){return new r([e,...this.plugins])}withoutPlugins(){return new r([])}},Xe=new io;var ot=class{numChangedRows;constructor(e){this.numChangedRows=e}};var nt=class r{#e;constructor(e){this.#e=o(e)}modifyEnd(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new r({...this.#e,queryNode:a.cloneWithTop(this.#e.queryNode,te(e,t))})}using(...e){return new Ee({...this.#e,queryNode:K.cloneWithUsing(this.#e.queryNode,Te("Using",e))})}returning(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,k(e))})}returningAll(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,S(e))})}output(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,k(e))})}outputAll(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,S(e))})}},Ee=class r{#e;constructor(e){this.#e=o(e)}modifyEnd(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new r({...this.#e,queryNode:a.cloneWithTop(this.#e.queryNode,te(e,t))})}whenMatched(){return this.#r([])}whenMatchedAnd(...e){return this.#r(e)}whenMatchedAndRef(e,t,n){return this.#r([e,t,n],!0)}#r(e,t){return new it({...this.#e,queryNode:K.cloneWithWhen(this.#e.queryNode,no({isMatched:!0},e,t))})}whenNotMatched(){return this.#t([])}whenNotMatchedAnd(...e){return this.#t(e)}whenNotMatchedAndRef(e,t,n){return this.#t([e,t,n],!0)}whenNotMatchedBySource(){return this.#t([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#t(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,n){return this.#t([e,t,n],!0,!0)}returning(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,k(e))})}returningAll(e){return new r({...this.#e,queryNode:a.cloneWithReturning(this.#e.queryNode,S(e))})}output(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,k(e))})}outputAll(e){return new r({...this.#e,queryNode:a.cloneWithOutput(this.#e.queryNode,S(e))})}#t(e,t=!1,n=!1){let s={...this.#e,queryNode:K.cloneWithWhen(this.#e.queryNode,no({isMatched:!1,bySource:n},e,t))},u=n?it:so;return new u(s)}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e,this.#e.queryId),{adapter:n}=this.#e.executor,s=e.query;return s.returning&&n.supportsReturning||s.output&&n.supportsOutput?t.rows:[new ot(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=j){let t=await this.executeTakeFirst();if(t===void 0)throw de(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}},it=class{#e;constructor(e){this.#e=o(e)}thenDelete(){return new Ee({...this.#e,queryNode:K.cloneWithThen(this.#e.queryNode,He("delete"))})}thenDoNothing(){return new Ee({...this.#e,queryNode:K.cloneWithThen(this.#e.queryNode,He("do nothing"))})}thenUpdate(e){return new Ee({...this.#e,queryNode:K.cloneWithThen(this.#e.queryNode,He(e(new Ge({queryId:this.#e.queryId,executor:Xe,queryNode:ue.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}},so=class{#e;constructor(e){this.#e=o(e)}thenDoNothing(){return new Ee({...this.#e,queryNode:K.cloneWithThen(this.#e.queryNode,He("do nothing"))})}thenInsertValues(e){let[t,n]=jr(e);return new Ee({...this.#e,queryNode:K.cloneWithThen(this.#e.queryNode,He(C.cloneWith(C.createWithoutInto(),{columns:t,values:n})))})}};var Ze=class r{#e;constructor(e){this.#e=o(e)}selectFrom(e){return Tr({queryId:x(),executor:this.#e.executor,queryNode:f.createFrom(oe(e),this.#e.withNode)})}selectNoFrom(e){return Tr({queryId:x(),executor:this.#e.executor,queryNode:f.cloneWithSelections(f.create(this.#e.withNode),k(e))})}insertInto(e){return new Cr({queryId:x(),executor:this.#e.executor,queryNode:C.create(l(e),this.#e.withNode)})}replaceInto(e){return new Cr({queryId:x(),executor:this.#e.executor,queryNode:C.create(l(e),this.#e.withNode,!0)})}deleteFrom(e){return new Zr({queryId:x(),executor:this.#e.executor,queryNode:ke.create(oe(e),this.#e.withNode)})}updateTable(e){return new Ge({queryId:x(),executor:this.#e.executor,queryNode:ue.create(oe(e),this.#e.withNode)})}mergeInto(e){return new nt({queryId:x(),executor:this.#e.executor,queryNode:K.create(ao(e),this.#e.withNode)})}with(e,t){let n=to(e,t);return new r({...this.#e,withNode:this.#e.withNode?br.cloneWithExpression(this.#e.withNode,n):br.create(n)})}withRecursive(e,t){let n=to(e,t);return new r({...this.#e,withNode:this.#e.withNode?br.cloneWithExpression(this.#e.withNode,n):br.create(n,{recursive:!0})})}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new r({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new r({...this.#e,executor:this.#e.executor.withPluginAtFront(new H(e))})}};function sn(){return new Ze({executor:Xe})}function cn(r,e){return new $r({joinNode:he.create(r,Ie(e))})}function mn(){return new Kr({overNode:Wr.create()})}function Te(r,e){if(e.length===3)return Xn(r,e[0],e[1],e[2]);if(e.length===2)return Yn(r,e[0],e[1]);if(e.length===1)return Zn(r,e[0]);throw new Error("not implemented")}function Yn(r,e,t){return t(cn(r,e)).toOperationNode()}function Xn(r,e,t,n){return he.createWithOn(r,Ie(e),T(t,"=",n))}function Zn(r,e){return he.create(r,Ie(e))}var hn=o({is(r){return r.kind==="OffsetNode"},create(r){return o({kind:"OffsetNode",offset:r})}});var ln=o({is(r){return r.kind==="GroupByItemNode"},create(r){return o({kind:"GroupByItemNode",groupBy:r})}});function pn(r){return r=O(r)?r(re()):r,pe(r).map(ln.create)}var fn=o({is(r){return r.kind==="SetOperationNode"},create(r,e,t){return o({kind:"SetOperationNode",operator:r,expression:e,all:t})}});function Be(r,e,t){return O(e)&&(e=e(st())),D(e)||(e=[e]),e.map(n=>fn.create(r,V(n),t))}var p=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new Sr(this,e)}or(...e){return new uo(X.create(this.#e,N(e)))}and(...e){return new co(z.create(this.#e,N(e)))}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e}},Sr=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return P.create(this.#e.toOperationNode(),g(this.#r)?this.#r.toOperationNode():d.create(this.#r))}},uo=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new Sr(this,e)}or(...e){return new r(X.create(this.#e,N(e)))}$castTo(){return new r(this.#e)}toOperationNode(){return be.create(this.#e)}},co=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new Sr(this,e)}and(...e){return new r(z.create(this.#e,N(e)))}$castTo(){return new r(this.#e)}toOperationNode(){return be.create(this.#e)}};var Nn={is(r){return r.kind==="FetchNode"},create(r,e){return{kind:"FetchNode",rowCount:b.create(r),modifier:e}}};function yn(r,e){if(!Le(r)&&!Br(r))throw new Error(`Invalid fetch row count: ${r}`);if(!_n(e))throw new Error(`Invalid fetch modifier: ${e}`);return Nn.create(r,e)}function _n(r){return r==="only"||r==="with ties"}var mo=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new r({...this.#e,queryNode:a.cloneWithWhere(this.#e.queryNode,N(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:a.cloneWithWhere(this.#e.queryNode,T(e,t,n))})}having(...e){return new r({...this.#e,queryNode:f.cloneWithHaving(this.#e.queryNode,N(e))})}havingRef(e,t,n){return new r({...this.#e,queryNode:f.cloneWithHaving(this.#e.queryNode,T(e,t,n))})}select(e){return new r({...this.#e,queryNode:f.cloneWithSelections(this.#e.queryNode,k(e))})}distinctOn(e){return new r({...this.#e,queryNode:f.cloneWithDistinctOn(this.#e.queryNode,pe(e))})}modifyFront(e){return new r({...this.#e,queryNode:f.cloneWithFrontModifier(this.#e.queryNode,se.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,se.createWithExpression(e.toOperationNode()))})}distinct(){return new r({...this.#e,queryNode:f.cloneWithFrontModifier(this.#e.queryNode,se.create("Distinct"))})}forUpdate(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,se.create("ForUpdate",e?yr(e).map(l):void 0))})}forShare(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,se.create("ForShare",e?yr(e).map(l):void 0))})}forKeyShare(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,se.create("ForKeyShare",e?yr(e).map(l):void 0))})}forNoKeyUpdate(e){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,se.create("ForNoKeyUpdate",e?yr(e).map(l):void 0))})}skipLocked(){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,se.create("SkipLocked"))})}noWait(){return new r({...this.#e,queryNode:a.cloneWithEndModifier(this.#e.queryNode,se.create("NoWait"))})}selectAll(e){return new r({...this.#e,queryNode:f.cloneWithSelections(this.#e.queryNode,S(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}crossJoin(...e){return this.#r("CrossJoin",e)}innerJoinLateral(...e){return this.#r("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#r("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#r("LateralCrossJoin",e)}crossApply(...e){return this.#r("CrossApply",e)}outerApply(...e){return this.#r("OuterApply",e)}#r(e,t){return new r({...this.#e,queryNode:a.cloneWithJoin(this.#e.queryNode,Te(e,t))})}orderBy(...e){return new r({...this.#e,queryNode:a.cloneWithOrderByItems(this.#e.queryNode,$(e))})}groupBy(e){return new r({...this.#e,queryNode:f.cloneWithGroupByItems(this.#e.queryNode,pn(e))})}limit(e){return new r({...this.#e,queryNode:f.cloneWithLimit(this.#e.queryNode,Ke.create(w(e)))})}offset(e){return new r({...this.#e,queryNode:f.cloneWithOffset(this.#e.queryNode,hn.create(w(e)))})}fetch(e,t="only"){return new r({...this.#e,queryNode:f.cloneWithFetch(this.#e.queryNode,yn(e,t))})}top(e,t){return new r({...this.#e,queryNode:a.cloneWithTop(this.#e.queryNode,te(e,t))})}union(e){return new r({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,Be("union",e,!1))})}unionAll(e){return new r({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,Be("union",e,!0))})}intersect(e){return new r({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,Be("intersect",e,!1))})}intersectAll(e){return new r({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,Be("intersect",e,!0))})}except(e){return new r({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,Be("except",e,!1))})}exceptAll(e){return new r({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,Be("except",e,!0))})}as(e){return new ho(this,e)}clearSelect(){return new r({...this.#e,queryNode:f.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new r({...this.#e,queryNode:a.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new r({...this.#e,queryNode:f.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new r({...this.#e,queryNode:f.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new r({...this.#e,queryNode:a.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new r({...this.#e,queryNode:f.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}$asTuple(){return new p(this.toOperationNode())}$asScalar(){return new p(this.toOperationNode())}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile();return(await this.#e.executor.executeQuery(e,this.#e.queryId)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=j){let t=await this.executeTakeFirst();if(t===void 0)throw de(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e,this.#e.queryId);for await(let s of n)yield*s.rows}async explain(e,t){return await new r({...this.#e,queryNode:a.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};function Tr(r){return new mo(r)}var ho=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return P.create(this.#e.toOperationNode(),d.create(this.#r))}};var ce=o({is(r){return r.kind==="AggregateFunctionNode"},create(r,e=[]){return o({kind:"AggregateFunctionNode",func:r,aggregated:e})},cloneWithDistinct(r){return o({...r,distinct:!0})},cloneWithOrderBy(r,e,t=!1){let n=t?"withinGroup":"orderBy";return o({...r,[n]:r[n]?fe.cloneWithItems(r[n],e):fe.create(e)})},cloneWithFilter(r,e){return o({...r,filter:r.filter?q.cloneWithOperation(r.filter,"And",e):q.create(e)})},cloneWithOrFilter(r,e){return o({...r,filter:r.filter?q.cloneWithOperation(r.filter,"Or",e):q.create(e)})},cloneWithOver(r,e){return o({...r,over:e})}});var lo=o({is(r){return r.kind==="FunctionNode"},create(r,e){return o({kind:"FunctionNode",func:r,arguments:e})}});var _e=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}as(e){return new po(this,e)}distinct(){return new r({...this.#e,aggregateFunctionNode:ce.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new r({...this.#e,aggregateFunctionNode:a.cloneWithOrderByItems(this.#e.aggregateFunctionNode,$(e))})}clearOrderBy(){return new r({...this.#e,aggregateFunctionNode:a.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new r({...this.#e,aggregateFunctionNode:ce.cloneWithOrderBy(this.#e.aggregateFunctionNode,$(e),!0)})}filterWhere(...e){return new r({...this.#e,aggregateFunctionNode:ce.cloneWithFilter(this.#e.aggregateFunctionNode,N(e))})}filterWhereRef(e,t,n){return new r({...this.#e,aggregateFunctionNode:ce.cloneWithFilter(this.#e.aggregateFunctionNode,T(e,t,n))})}over(e){let t=mn();return new r({...this.#e,aggregateFunctionNode:ce.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}},po=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return P.create(this.#e.toOperationNode(),d.create(this.#r))}};function at(){let r=(t,n)=>new p(lo.create(t,pe(n??[]))),e=(t,n)=>new _e({aggregateFunctionNode:ce.create(t,n?pe(n):void 0)});return Object.assign(r,{agg:e,avg(t){return e("avg",[t])},coalesce(...t){return r("coalesce",t)},count(t){return e("count",[t])},countAll(t){return new _e({aggregateFunctionNode:ce.create("count",S(t))})},max(t){return e("max",[t])},min(t){return e("min",[t])},sum(t){return e("sum",[t])},any(t){return r("any",[t])},jsonAgg(t){return new _e({aggregateFunctionNode:ce.create("json_agg",[W(t)?l(t):t.toOperationNode()])})},toJson(t){return new p(lo.create("to_json",[W(t)?l(t):t.toOperationNode()]))}})}var wn=o({is(r){return r.kind==="UnaryOperationNode"},create(r,e){return o({kind:"UnaryOperationNode",operator:r,operand:e})}});function xn(r,e){return wn.create(Z.create(r),R(e))}var G=o({is(r){return r.kind==="CaseNode"},create(r){return o({kind:"CaseNode",value:r})},cloneWithWhen(r,e){return o({...r,when:o(r.when?[...r.when,e]:[e])})},cloneWithThen(r,e){return o({...r,when:r.when?o([...r.when.slice(0,-1),Ne.cloneWithResult(r.when[r.when.length-1],e)]):void 0})},cloneWith(r,e){return o({...r,...e})}});var er=class{#e;constructor(e){this.#e=o(e)}when(...e){return new ut({...this.#e,node:G.cloneWithWhen(this.#e.node,Ne.create(N(e)))})}},ut=class{#e;constructor(e){this.#e=o(e)}then(e){return new fo({...this.#e,node:G.cloneWithThen(this.#e.node,Vr(e)?Or(e):w(e))})}},fo=class{#e;constructor(e){this.#e=o(e)}when(...e){return new ut({...this.#e,node:G.cloneWithWhen(this.#e.node,Ne.create(N(e)))})}else(e){return new No({...this.#e,node:G.cloneWith(this.#e.node,{else:Vr(e)?Or(e):w(e)})})}end(){return new p(G.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new p(G.cloneWith(this.#e.node,{isStatement:!0}))}},No=class{#e;constructor(e){this.#e=o(e)}end(){return new p(G.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new p(G.cloneWith(this.#e.node,{isStatement:!0}))}};var yo=o({is(r){return r.kind==="JSONPathLegNode"},create(r,e){return o({kind:"JSONPathLegNode",type:r,value:e})}});var rr=class{#e;constructor(e){this.#e=e}at(e){return this.#r("ArrayLocation",e)}key(e){return this.#r("Member",e)}#r(e,t){return Ve.is(this.#e)?new dt(Ve.cloneWithTraversal(this.#e,Ce.is(this.#e.traversal)?Ce.cloneWithLeg(this.#e.traversal,yo.create(e,t)):Mr.cloneWithValue(this.#e.traversal,b.createImmediate(t)))):new dt(Ce.cloneWithLeg(this.#e,yo.create(e,t)))}},dt=class r extends rr{#e;constructor(e){super(e),this.#e=e}get expressionType(){}as(e){return new wo(this,e)}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e}},wo=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return P.create(this.#e.toOperationNode(),g(this.#r)?this.#r.toOperationNode():d.create(this.#r))}};var xo=o({is(r){return r.kind==="TupleNode"},create(r){return o({kind:"TupleNode",values:o(r)})}});var ei=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],ri=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],On=o({is(r){return r.kind==="DataTypeNode"},create(r){return o({kind:"DataTypeNode",dataType:r})}});function Wn(r){return!!(ei.includes(r)||ri.some(e=>e.test(r)))}function ne(r){if(g(r))return r.toOperationNode();if(Wn(r))return On.create(r);throw new Error(`invalid column data type ${JSON.stringify(r)}`)}var gn=o({is(r){return r.kind==="CastNode"},create(r,e){return o({kind:"CastNode",expression:r,dataType:e})}});function st(r=Xe){function e(s,u,c){return new p(Ur(s,u,c))}function t(s,u){return new p(xn(s,u))}let n=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(s){return Tr({queryId:x(),executor:r,queryNode:f.createFrom(oe(s))})},case(s){return new er({node:G.create(U(s)?void 0:R(s))})},ref(s,u){return U(u)?new p(ee(s)):new rr(Uo(s,u))},jsonPath(){return new rr(Ce.create())},table(s){return new p(l(s))},val(s){return new p(w(s))},refTuple(...s){return new p(xo.create(s.map(R)))},tuple(...s){return new p(xo.create(s.map(w)))},lit(s){return new p(Or(s))},unary:t,not(s){return t("not",s)},exists(s){return t("exists",s)},neg(s){return t("-",s)},between(s,u,c){return new p(ge.create(R(s),Z.create("between"),z.create(w(u),w(c))))},betweenSymmetric(s,u,c){return new p(ge.create(R(s),Z.create("between symmetric"),z.create(w(u),w(c))))},and(s){return D(s)?new p(Je(s,"and")):new p($t(s,"and"))},or(s){return D(s)?new p(Je(s,"or")):new p($t(s,"or"))},parens(...s){let u=N(s);return be.is(u)?new p(u):new p(be.create(u))},cast(s,u){return new p(gn.create(R(s),ne(u)))},withSchema(s){return st(r.withPluginAtFront(new H(s)))}});return n.fn=at(),n.eb=n,n}function re(r){return st()}function V(r){if(g(r))return r.toOperationNode();if(O(r))return r(re()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify(r)}`)}function Gr(r){if(g(r))return r.toOperationNode();if(O(r))return r(re()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify(r)}`)}function le(r){return Qr(r)||vo(r)||O(r)}var ct=class{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new Oo(this.#e,e)}},Oo=class{#e;#r;get table(){return this.#e}get alias(){return this.#r}constructor(e,t){this.#e=e,this.#r=t}toOperationNode(){return P.create(l(this.#e),d.create(this.#r))}};function Cn(r){return A(r)&&g(r)&&W(r.table)&&W(r.alias)}function oe(r){return D(r)?r.map(e=>Ie(e)):[Ie(r)]}function Ie(r){return W(r)?ao(r):Cn(r)?r.toOperationNode():Gr(r)}function ao(r){let e=" as ";if(r.includes(e)){let[t,n]=r.split(e).map(bn);return P.create(l(t),d.create(n))}else return l(r)}function l(r){let e=".";if(r.includes(e)){let[t,n]=r.split(e).map(bn);return J.createWithSchema(t,n)}else return J.create(r)}function bn(r){return r.trim()}var Wo=o({is(r){return r.kind==="AddColumnNode"},create(r){return o({kind:"AddColumnNode",column:r})}});var y=o({is(r){return r.kind==="ColumnDefinitionNode"},create(r,e){return o({kind:"ColumnDefinitionNode",column:m.create(r),dataType:e})},cloneWithFrontModifier(r,e){return o({...r,frontModifiers:r.frontModifiers?o([...r.frontModifiers,e]):[e]})},cloneWithEndModifier(r,e){return o({...r,endModifiers:r.endModifiers?o([...r.endModifiers,e]):[e]})},cloneWith(r,e){return o({...r,...e})}});var go=o({is(r){return r.kind==="DropColumnNode"},create(r){return o({kind:"DropColumnNode",column:m.create(r)})}});var Co=o({is(r){return r.kind==="RenameColumnNode"},create(r,e){return o({kind:"RenameColumnNode",column:m.create(r),renameTo:m.create(e)})}});var tr=o({is(r){return r.kind==="CheckConstraintNode"},create(r,e){return o({kind:"CheckConstraintNode",expression:r,name:e?d.create(e):void 0})}});var kn=["no action","restrict","cascade","set null","set default"],or=o({is(r){return r.kind==="ReferencesNode"},create(r,e){return o({kind:"ReferencesNode",table:r,columns:o([...e])})},cloneWithOnDelete(r,e){return o({...r,onDelete:e})},cloneWithOnUpdate(r,e){return o({...r,onUpdate:e})}});function mt(r){return g(r)?r.toOperationNode():b.createImmediate(r)}var Er=o({is(r){return r.kind==="GeneratedNode"},create(r){return o({kind:"GeneratedNode",...r})},createWithExpression(r){return o({kind:"GeneratedNode",always:!0,expression:r})},cloneWith(r,e){return o({...r,...e})}});var Tn=o({is(r){return r.kind==="DefaultValueNode"},create(r){return o({kind:"DefaultValueNode",defaultValue:r})}});function nr(r){if(kn.includes(r))return r;throw new Error(`invalid OnModifyForeignAction ${r}`)}var ye=class r{#e;constructor(e){this.#e=e}autoIncrement(){return new r(y.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new r(y.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new r(y.cloneWith(this.#e,{primaryKey:!0}))}references(e){let t=ee(e);if(!t.table||Fe.is(t.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new r(y.cloneWith(this.#e,{references:or.create(t.table,[t.column])}))}onDelete(e){if(!this.#e.references)throw new Error("on delete constraint can only be added for foreign keys");return new r(y.cloneWith(this.#e,{references:or.cloneWithOnDelete(this.#e.references,nr(e))}))}onUpdate(e){if(!this.#e.references)throw new Error("on update constraint can only be added for foreign keys");return new r(y.cloneWith(this.#e,{references:or.cloneWithOnUpdate(this.#e.references,nr(e))}))}unique(){return new r(y.cloneWith(this.#e,{unique:!0}))}notNull(){return new r(y.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new r(y.cloneWith(this.#e,{unsigned:!0}))}defaultTo(e){return new r(y.cloneWith(this.#e,{defaultTo:Tn.create(mt(e))}))}check(e){return new r(y.cloneWith(this.#e,{check:tr.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new r(y.cloneWith(this.#e,{generated:Er.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new r(y.cloneWith(this.#e,{generated:Er.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new r(y.cloneWith(this.#e,{generated:Er.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new r(y.cloneWith(this.#e,{generated:Er.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(e){return new r(y.cloneWithFrontModifier(this.#e,e.toOperationNode()))}nullsNotDistinct(){return new r(y.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new r(y.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(e){return new r(y.cloneWithEndModifier(this.#e,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#e}};var bo=o({is(r){return r.kind==="ModifyColumnNode"},create(r){return o({kind:"ModifyColumnNode",column:r})}});var ie=o({is(r){return r.kind==="ForeignKeyConstraintNode"},create(r,e,t,n){return o({kind:"ForeignKeyConstraintNode",columns:r,references:or.create(e,t),name:n?d.create(n):void 0})},cloneWith(r,e){return o({...r,...e})}});var ir=class r{#e;constructor(e){this.#e=e}onDelete(e){return new r(ie.cloneWith(this.#e,{onDelete:nr(e)}))}onUpdate(e){return new r(ie.cloneWith(this.#e,{onUpdate:nr(e)}))}deferrable(){return new r(ie.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new r(ie.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new r(ie.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new r(ie.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}};var sr=o({is(r){return r.kind==="AddConstraintNode"},create(r){return o({kind:"AddConstraintNode",constraint:r})}});var me=o({is(r){return r.kind==="UniqueConstraintNode"},create(r,e,t){return o({kind:"UniqueConstraintNode",columns:o(r.map(m.create)),name:e?d.create(e):void 0,nullsNotDistinct:t})},cloneWith(r,e){return o({...r,...e})}});var ar=o({is(r){return r.kind==="DropConstraintNode"},create(r){return o({kind:"DropConstraintNode",constraintName:d.create(r)})},cloneWith(r,e){return o({...r,...e})}});var ur=o({is(r){return r.kind==="AlterColumnNode"},create(r,e,t){return o({kind:"AlterColumnNode",column:m.create(r),[e]:t})}});var Ar=class{#e;constructor(e){this.#e=e}setDataType(e){return new De(ur.create(this.#e,"dataType",ne(e)))}setDefault(e){return new De(ur.create(this.#e,"setDefault",mt(e)))}dropDefault(){return new De(ur.create(this.#e,"dropDefault",!0))}setNotNull(){return new De(ur.create(this.#e,"setNotNull",!0))}dropNotNull(){return new De(ur.create(this.#e,"dropNotNull",!0))}$call(e){return e(this)}},De=class{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}};var we=class{#e;constructor(e){this.#e=o(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var ht=class r{#e;constructor(e){this.#e=o(e)}onDelete(e){return new r({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(e)})}onUpdate(e){return new r({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(e)})}deferrable(){return new r({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new r({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new r({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new r({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(h.cloneWithTableProps(this.#e.node,{addConstraint:sr.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var Rr=class r{#e;constructor(e){this.#e=o(e)}ifExists(){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{dropConstraint:ar.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{dropConstraint:ar.cloneWith(this.#e.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{dropConstraint:ar.cloneWith(this.#e.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var xe=o({is(r){return r.kind==="PrimaryKeyConstraintNode"},create(r,e){return o({kind:"PrimaryKeyConstraintNode",columns:o(r.map(m.create)),name:e?d.create(e):void 0})},cloneWith(r,e){return o({...r,...e})}});var Ae=o({is(r){return r.kind==="AddIndexNode"},create(r){return o({kind:"AddIndexNode",name:d.create(r)})},cloneWith(r,e){return o({...r,...e})},cloneWithColumns(r,e){return o({...r,columns:[...r.columns||[],...e]})}});var lt=class r{#e;constructor(e){this.#e=o(e)}unique(){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addIndex:Ae.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(e){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addIndex:Ae.cloneWithColumns(this.#e.node.addIndex,[Ue(e)])})})}columns(e){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addIndex:Ae.cloneWithColumns(this.#e.node.addIndex,e.map(Ue))})})}expression(e){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addIndex:Ae.cloneWithColumns(this.#e.node.addIndex,[e.toOperationNode()])})})}using(e){return new r({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addIndex:Ae.cloneWith(this.#e.node.addIndex,{using:v.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var dr=class r{#e;constructor(e){this.#e=e}nullsNotDistinct(){return new r(me.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new r(me.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new r(me.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new r(me.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new r(me.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}};var cr=class r{#e;constructor(e){this.#e=e}deferrable(){return new r(xe.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new r(xe.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new r(xe.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new r(xe.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(e){return e(this)}toOperationNode(){return this.#e}};var mr=class{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}};var Sn=o({is(r){return r.kind==="RenameConstraintNode"},create(r,e){return o({kind:"RenameConstraintNode",oldName:d.create(r),newName:d.create(e)})}});var pt=class{#e;constructor(e){this.#e=o(e)}renameTo(e){return new we({...this.#e,node:h.cloneWithTableProps(this.#e.node,{renameTo:l(e)})})}setSchema(e){return new we({...this.#e,node:h.cloneWithTableProps(this.#e.node,{setSchema:d.create(e)})})}alterColumn(e,t){let n=t(new Ar(e));return new Qe({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,n.toOperationNode())})}dropColumn(e){return new Qe({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,go.create(e))})}renameColumn(e,t){return new Qe({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,Co.create(e,t))})}addColumn(e,t,n=L){let s=n(new ye(y.create(e,ne(t))));return new Qe({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,Wo.create(s.toOperationNode()))})}modifyColumn(e,t,n=L){let s=n(new ye(y.create(e,ne(t))));return new Qe({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,bo.create(s.toOperationNode()))})}addUniqueConstraint(e,t,n=L){let s=n(new dr(me.create(t,e)));return new we({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addConstraint:sr.create(s.toOperationNode())})})}addCheckConstraint(e,t,n=L){let s=n(new mr(tr.create(t.toOperationNode(),e)));return new we({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addConstraint:sr.create(s.toOperationNode())})})}addForeignKeyConstraint(e,t,n,s,u=L){let c=u(new ir(ie.create(t.map(m.create),l(n),s.map(m.create),e)));return new ht({...this.#e,constraintBuilder:c})}addPrimaryKeyConstraint(e,t,n=L){let s=n(new cr(xe.create(t,e)));return new we({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addConstraint:sr.create(s.toOperationNode())})})}dropConstraint(e){return new Rr({...this.#e,node:h.cloneWithTableProps(this.#e.node,{dropConstraint:ar.create(e)})})}renameConstraint(e,t){return new Rr({...this.#e,node:h.cloneWithTableProps(this.#e.node,{renameConstraint:Sn.create(e,t)})})}addIndex(e){return new lt({...this.#e,node:h.cloneWithTableProps(this.#e.node,{addIndex:Ae.create(e)})})}dropIndex(e){return new we({...this.#e,node:h.cloneWithTableProps(this.#e.node,{dropIndex:We.create(e)})})}$call(e){return e(this)}},Qe=class r{#e;constructor(e){this.#e=o(e)}alterColumn(e,t){let n=t(new Ar(e));return new r({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,n.toOperationNode())})}dropColumn(e){return new r({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,go.create(e))})}renameColumn(e,t){return new r({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,Co.create(e,t))})}addColumn(e,t,n=L){let s=n(new ye(y.create(e,ne(t))));return new r({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,Wo.create(s.toOperationNode()))})}modifyColumn(e,t,n=L){let s=n(new ye(y.create(e,ne(t))));return new r({...this.#e,node:h.cloneWithColumnAlteration(this.#e.node,bo.create(s.toOperationNode()))})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var hr=class extends Se{transformPrimitiveValueList(e){return ae.create(e.values.map(b.createImmediate))}transformValue(e){return b.createImmediate(e.value)}};var ft=class r{#e;constructor(e){this.#e=o(e)}ifNotExists(){return new r({...this.#e,node:Y.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new r({...this.#e,node:Y.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new r({...this.#e,node:Y.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(e){return new r({...this.#e,node:Y.cloneWith(this.#e.node,{table:l(e)})})}column(e){return new r({...this.#e,node:Y.cloneWithColumns(this.#e.node,[Ue(e)])})}columns(e){return new r({...this.#e,node:Y.cloneWithColumns(this.#e.node,e.map(Ue))})}expression(e){return new r({...this.#e,node:Y.cloneWithColumns(this.#e.node,[e.toOperationNode()])})}using(e){return new r({...this.#e,node:Y.cloneWith(this.#e.node,{using:v.createWithSql(e)})})}where(...e){let t=new hr;return new r({...this.#e,node:a.cloneWithWhere(this.#e.node,t.transformNode(N(e),this.#e.queryId))})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var Nt=class r{#e;constructor(e){this.#e=o(e)}ifNotExists(){return new r({...this.#e,node:Dr.cloneWith(this.#e.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};function En(r){if(Po.includes(r))return r;throw new Error(`invalid OnCommitAction ${r}`)}var yt=class r{#e;constructor(e){this.#e=o(e)}temporary(){return new r({...this.#e,node:M.cloneWith(this.#e.node,{temporary:!0})})}onCommit(e){return new r({...this.#e,node:M.cloneWith(this.#e.node,{onCommit:En(e)})})}ifNotExists(){return new r({...this.#e,node:M.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(e,t,n=L){let s=n(new ye(y.create(e,ne(t))));return new r({...this.#e,node:M.cloneWithColumn(this.#e.node,s.toOperationNode())})}addPrimaryKeyConstraint(e,t,n=L){let s=n(new cr(xe.create(t,e)));return new r({...this.#e,node:M.cloneWithConstraint(this.#e.node,s.toOperationNode())})}addUniqueConstraint(e,t,n=L){let s=n(new dr(me.create(t,e)));return new r({...this.#e,node:M.cloneWithConstraint(this.#e.node,s.toOperationNode())})}addCheckConstraint(e,t,n=L){let s=n(new mr(tr.create(t.toOperationNode(),e)));return new r({...this.#e,node:M.cloneWithConstraint(this.#e.node,s.toOperationNode())})}addForeignKeyConstraint(e,t,n,s,u=L){let c=u(new ir(ie.create(t.map(m.create),l(n),s.map(m.create),e)));return new r({...this.#e,node:M.cloneWithConstraint(this.#e.node,c.toOperationNode())})}modifyFront(e){return new r({...this.#e,node:M.cloneWithFrontModifier(this.#e.node,e.toOperationNode())})}modifyEnd(e){return new r({...this.#e,node:M.cloneWithEndModifier(this.#e.node,e.toOperationNode())})}as(e){return new r({...this.#e,node:M.cloneWith(this.#e.node,{selectQuery:V(e)})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var wt=class r{#e;constructor(e){this.#e=o(e)}on(e){return new r({...this.#e,node:We.cloneWith(this.#e.node,{table:l(e)})})}ifExists(){return new r({...this.#e,node:We.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new r({...this.#e,node:We.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var xt=class r{#e;constructor(e){this.#e=o(e)}ifExists(){return new r({...this.#e,node:wr.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new r({...this.#e,node:wr.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var Ot=class r{#e;constructor(e){this.#e=o(e)}ifExists(){return new r({...this.#e,node:xr.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new r({...this.#e,node:xr.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var Oe=o({is(r){return r.kind==="CreateViewNode"},create(r){return o({kind:"CreateViewNode",name:Q.create(r)})},cloneWith(r,e){return o({...r,...e})}});var Wt=class{#e=new hr;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}};var gt=class r{#e;constructor(e){this.#e=o(e)}temporary(){return new r({...this.#e,node:Oe.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new r({...this.#e,node:Oe.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new r({...this.#e,node:Oe.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new r({...this.#e,node:Oe.cloneWith(this.#e.node,{orReplace:!0})})}columns(e){return new r({...this.#e,node:Oe.cloneWith(this.#e.node,{columns:e.map(Vt)})})}as(e){let t=e.withPlugin(new Wt).toOperationNode();return new r({...this.#e,node:Oe.cloneWith(this.#e.node,{as:t})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var lr=o({is(r){return r.kind==="DropViewNode"},create(r){return o({kind:"DropViewNode",name:Q.create(r)})},cloneWith(r,e){return o({...r,...e})}});var Ct=class r{#e;constructor(e){this.#e=o(e)}materialized(){return new r({...this.#e,node:lr.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new r({...this.#e,node:lr.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new r({...this.#e,node:lr.cloneWith(this.#e.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var bt=o({is(r){return r.kind==="CreateTypeNode"},create(r){return o({kind:"CreateTypeNode",name:r})},cloneWithEnum(r,e){return o({...r,enum:ae.create(e.map(b.createImmediate))})}});var kt=class r{#e;constructor(e){this.#e=o(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(e){return new r({...this.#e,node:bt.cloneWithEnum(this.#e.node,e)})}$call(e){return e(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var Tt=o({is(r){return r.kind==="DropTypeNode"},create(r){return o({kind:"DropTypeNode",name:r})},cloneWith(r,e){return o({...r,...e})}});var St=class r{#e;constructor(e){this.#e=o(e)}ifExists(){return new r({...this.#e,node:Tt.cloneWith(this.#e.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};function ko(r){let e=".";if(r.includes(e)){let t=r.split(e).map(ti);if(t.length===2)return Q.createWithSchema(t[0],t[1]);throw new Error(`invalid schemable identifier ${r}`)}else return Q.create(r)}function ti(r){return r.trim()}var pr=o({is(r){return r.kind==="RefreshMaterializedViewNode"},create(r){return o({kind:"RefreshMaterializedViewNode",name:Q.create(r)})},cloneWith(r,e){return o({...r,...e})}});var Et=class r{#e;constructor(e){this.#e=o(e)}concurrently(){return new r({...this.#e,node:pr.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new r({...this.#e,node:pr.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new r({...this.#e,node:pr.cloneWith(this.#e.node,{withNoData:!0,concurrently:!1})})}$call(e){return e(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile(),this.#e.queryId)}};var At=class r{#e;constructor(e){this.#e=e}createTable(e){return new yt({queryId:x(),executor:this.#e,node:M.create(l(e))})}dropTable(e){return new Ot({queryId:x(),executor:this.#e,node:xr.create(l(e))})}createIndex(e){return new ft({queryId:x(),executor:this.#e,node:Y.create(e)})}dropIndex(e){return new wt({queryId:x(),executor:this.#e,node:We.create(e)})}createSchema(e){return new Nt({queryId:x(),executor:this.#e,node:Dr.create(e)})}dropSchema(e){return new xt({queryId:x(),executor:this.#e,node:wr.create(e)})}alterTable(e){return new pt({queryId:x(),executor:this.#e,node:h.create(l(e))})}createView(e){return new gt({queryId:x(),executor:this.#e,node:Oe.create(e)})}refreshMaterializedView(e){return new Et({queryId:x(),executor:this.#e,node:pr.create(e)})}dropView(e){return new Ct({queryId:x(),executor:this.#e,node:lr.create(e)})}createType(e){return new kt({queryId:x(),executor:this.#e,node:bt.create(ko(e))})}dropType(e){return new St({queryId:x(),executor:this.#e,node:Tt.create(ko(e))})}withPlugin(e){return new r(this.#e.withPlugin(e))}withoutPlugins(){return new r(this.#e.withoutPlugins())}withSchema(e){return new r(this.#e.withPluginAtFront(new H(e)))}};var Rt=class{ref(e){return new vr(e)}table(e){return new ct(e)}};var qt=class{#e;constructor(e){this.#e=e}async provideConnection(e){let t=await this.#e.acquireConnection();try{return await e(t)}finally{await this.#e.releaseConnection(t)}}};var It=class r extends Ye{#e;#r;#t;constructor(e,t,n,s=[]){super(s),this.#e=e,this.#r=t,this.#t=n}get adapter(){return this.#r}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e){return this.#t.provideConnection(e)}withPlugins(e){return new r(this.#e,this.#r,this.#t,[...this.plugins,...e])}withPlugin(e){return new r(this.#e,this.#r,this.#t,[...this.plugins,e])}withPluginAtFront(e){return new r(this.#e,this.#r,this.#t,[e,...this.plugins])}withConnectionProvider(e){return new r(this.#e,this.#r,e,[...this.plugins])}withoutPlugins(){return new r(this.#e,this.#r,this.#t,[])}};function Bt(){return typeof performance<"u"&&O(performance.now)?performance.now():Date.now()}var Dt=class{#e;#r;#t;#i;#o;#a=new WeakSet;constructor(e,t){this.#i=!1,this.#e=e,this.#r=t}async init(){if(this.#o)throw new Error("driver has already been destroyed");this.#t||(this.#t=this.#e.init().then(()=>{this.#i=!0}).catch(e=>(this.#t=void 0,Promise.reject(e)))),await this.#t}async acquireConnection(){if(this.#o)throw new Error("driver has already been destroyed");this.#i||await this.init();let e=await this.#e.acquireConnection();return this.#a.has(e)||(this.#d()&&this.#n(e),this.#a.add(e)),e}async releaseConnection(e){await this.#e.releaseConnection(e)}beginTransaction(e,t){return this.#e.beginTransaction(e,t)}commitTransaction(e){return this.#e.commitTransaction(e)}rollbackTransaction(e){return this.#e.rollbackTransaction(e)}savepoint(e,t,n){if(this.#e.savepoint)return this.#e.savepoint(e,t,n);throw new Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint(e,t,n){if(this.#e.rollbackToSavepoint)return this.#e.rollbackToSavepoint(e,t,n);throw new Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint(e,t,n){if(this.#e.releaseSavepoint)return this.#e.releaseSavepoint(e,t,n);throw new Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){this.#t&&(await this.#t,this.#o||(this.#o=this.#e.destroy().catch(e=>(this.#o=void 0,Promise.reject(e)))),await this.#o)}#d(){return this.#r.isLevelEnabled("query")||this.#r.isLevelEnabled("error")}#n(e){let t=e.executeQuery,n=e.streamQuery,s=this;e.executeQuery=async u=>{let c,E=Bt();try{return await t.call(e,u)}catch(I){throw c=I,await s.#s(I,u,E),I}finally{c||await s.#u(u,E)}},e.streamQuery=async function*(u,c){let E,I=Bt();try{for await(let B of n.call(e,u,c))yield B}catch(B){throw E=B,await s.#s(B,u,I),B}finally{E||await s.#u(u,I,!0)}}}async#s(e,t,n){await this.#r.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#c(n)}))}async#u(e,t,n=!1){await this.#r.query(()=>({level:"query",isStream:n,query:e,queryDurationMillis:this.#c(t)}))}#c(e){return Bt()-e}};var oi=()=>{},fr=class{#e;#r;constructor(e){this.#e=e}async provideConnection(e){for(;this.#r;)await this.#r.catch(oi);return this.#r=this.#t(e).finally(()=>{this.#r=void 0}),this.#r}async#t(e){return await e(this.#e)}};var ni=["read only","read write"],ii=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function To(r){if(r.accessMode&&!ni.includes(r.accessMode))throw new Error(`invalid transaction access mode ${r.accessMode}`);if(r.isolationLevel&&!ii.includes(r.isolationLevel))throw new Error(`invalid transaction isolation level ${r.isolationLevel}`)}var UC=o(["query","error"]),Qt=class{#e;#r;constructor(e){O(e)?(this.#r=e,this.#e=o({query:!0,error:!0})):(this.#r=si,this.#e=o({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#e[e]}async query(e){this.#e.query&&await this.#r(e())}async error(e){this.#e.error&&await this.#r(e())}};function si(r){if(r.level==="query"){let e=`kysely:query:${r.isStream?"stream:":""}`;console.log(`${e} ${r.query.sql}`),console.log(`${e} duration: ${r.queryDurationMillis.toFixed(1)}ms`)}else r.level==="error"&&(r.error instanceof Error?console.error(`kysely:error: ${r.error.stack??r.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:r.error,query:r.query.sql,queryDurationMillis:r.queryDurationMillis})}`))}function An(r){return A(r)&&O(r.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");var Nr=class r extends Ze{#e;constructor(e){let t,n;if(ai(e))t={executor:e.executor},n={...e};else{let s=e.dialect,u=s.createDriver(),c=s.createQueryCompiler(),E=s.createAdapter(),I=new Qt(e.log??[]),B=new Dt(u,I),Rn=new qt(B),Qo=new It(c,E,Rn,e.plugins??[]);t={executor:Qo},n={config:e,executor:Qo,dialect:s,driver:B}}super(t),this.#e=o(n)}get schema(){return new At(this.#e.executor)}get dynamic(){return new Rt}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(e){return new er({node:G.create(U(e)?void 0:V(e))})}get fn(){return at()}transaction(){return new Eo({...this.#e})}startTransaction(){return new Ao({...this.#e})}connection(){return new So({...this.#e})}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new r({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new r({...this.#e,executor:this.#e.executor.withPluginAtFront(new H(e))})}withTables(){return new r({...this.#e})}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}executeQuery(e,t=x()){let n=An(e)?e.compile():e;return this.getExecutor().executeQuery(n,t)}async[Symbol.asyncDispose](){await this.destroy()}},Pt=class r extends Nr{#e;constructor(e){super(e),this.#e=e}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new r({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new r({...this.#e,executor:this.#e.executor.withPluginAtFront(new H(e))})}withTables(){return new r({...this.#e})}};function ai(r){return A(r)&&A(r.config)&&A(r.driver)&&A(r.executor)&&A(r.dialect)}var So=class{#e;constructor(e){this.#e=o(e)}async execute(e){return this.#e.executor.provideConnection(async t=>{let n=this.#e.executor.withConnectionProvider(new fr(t)),s=new Nr({...this.#e,executor:n});return await e(s)})}},Eo=class r{#e;constructor(e){this.#e=o(e)}setAccessMode(e){return new r({...this.#e,accessMode:e})}setIsolationLevel(e){return new r({...this.#e,isolationLevel:e})}async execute(e){let{isolationLevel:t,accessMode:n,...s}=this.#e,u={isolationLevel:t,accessMode:n};return To(u),this.#e.executor.provideConnection(async c=>{let E=this.#e.executor.withConnectionProvider(new fr(c)),I=new Pt({...s,executor:E});try{await this.#e.driver.beginTransaction(c,u);let B=await e(I);return await this.#e.driver.commitTransaction(c),B}catch(B){throw await this.#e.driver.rollbackTransaction(c),B}})}},Ao=class r{#e;constructor(e){this.#e=o(e)}setAccessMode(e){return new r({...this.#e,accessMode:e})}setIsolationLevel(e){return new r({...this.#e,isolationLevel:e})}async execute(){let{isolationLevel:e,accessMode:t,...n}=this.#e,s={isolationLevel:e,accessMode:t};To(s);let u=await tt(this.#e.executor);return await this.#e.driver.beginTransaction(u.connection,s),new Ro({...n,connection:u,executor:this.#e.executor.withConnectionProvider(new fr(u.connection))})}},Ro=class r extends Pt{#e;#r;#t;constructor(e){let t={isCommitted:!1,isRolledBack:!1};e={...e,executor:new qo(e.executor,t)};let{connection:n,...s}=e;super(s),this.#e=o(e),this.#t=t;let u=x();this.#r=c=>e.executor.compileQuery(c,u)}get isCommitted(){return this.#t.isCommitted}get isRolledBack(){return this.#t.isRolledBack}commit(){return ve(this.#t),new Pe(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#t.isCommitted=!0,this.#e.connection.release()})}rollback(){return ve(this.#t),new Pe(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#t.isRolledBack=!0,this.#e.connection.release()})}savepoint(e){return ve(this.#t),new Pe(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,e,this.#r),new r({...this.#e})))}rollbackToSavepoint(e){return ve(this.#t),new Pe(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,e,this.#r),new r({...this.#e})))}releaseSavepoint(e){return ve(this.#t),new Pe(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,e,this.#r),new r({...this.#e})))}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new r({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new r({...this.#e,executor:this.#e.executor.withPluginAtFront(new H(e))})}withTables(){return new r({...this.#e})}},Pe=class{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}};function ve(r){if(r.isCommitted)throw new Error("Transaction is already committed");if(r.isRolledBack)throw new Error("Transaction is already rolled back")}var qo=class r{#e;#r;constructor(e,t){e instanceof r?this.#e=e.#e:this.#e=e,this.#r=t}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(e,t){return this.#e.transformQuery(e,t)}compileQuery(e,t){return this.#e.compileQuery(e,t)}provideConnection(e){return this.#e.provideConnection(e)}executeQuery(e,t){return ve(this.#r),this.#e.executeQuery(e,t)}stream(e,t,n){return ve(this.#r),this.#e.stream(e,t,n)}withConnectionProvider(e){return new r(this.#e.withConnectionProvider(e),this.#r)}withPlugin(e){return new r(this.#e.withPlugin(e),this.#r)}withPlugins(e){return new r(this.#e.withPlugins(e),this.#r)}withPluginAtFront(e){return new r(this.#e.withPluginAtFront(e),this.#r)}withoutPlugins(){return new r(this.#e.withoutPlugins(),this.#r)}};var vt=class{async init(){}async acquireConnection(){return new Io}async beginTransaction(){}async commitTransaction(){}async rollbackTransaction(){}async releaseConnection(){}async destroy(){}async releaseSavepoint(){}async rollbackToSavepoint(){}async savepoint(){}},Io=class{async executeQuery(){return{rows:[]}}async*streamQuery(){}};function wb(r){return new Nr({dialect:{createAdapter:()=>new r.Adapter,createDriver:()=>new vt,createIntrospector:()=>null,createQueryCompiler:()=>new r.QueryCompiler},plugins:[...r.noParameters?[new Bo]:[]]})}var Bo=class{#e=new Do;transformQuery(e){return this.#e.transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}},Do=class extends Se{transformPrimitiveValueList(e){return ae.create(e.values.map(b.createImmediate))}transformValue(e){return{...super.transformValue(e),immediate:!0}}};function xb(r){let e=r.compile();return{parameters:e.parameters,sql:e.sql}}function Ob(r,e){let t=di(r,e);return n=>n.where(s=>s.or(t.map(u=>s.and(u.map(([c,E])=>s(c,E===null?"is":"=",E))))))}function ui(r,e){return Object.entries(Object.values(e).reduce((t,n)=>{let{isInPrimaryKey:s,name:u}=n;return s&&(t[u]=r[u]??null),t},{}))}function di(r,e){return r.map(t=>ui(t,e))}export{W as a,Le as b,qr as c,Ir as d,ci as e,Br as f,o as g,d as h,M as i,P as j,g as k,Z as l,v as m,ze as n,ee as o,b as p,w as q,be as r,C as s,K as t,a as u,x as v,Xe as w,fn as x,l as y,Oe as z,wb as A,xb as B,Ob as C,ui as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as ei,B as g,C as B,a as E,b as z,c as Q,d as j,e as V,f as U,g as m,h as C,i as F,j as W,k as I,l as J,m as f,n as K,o as $,p as G,q as k,r as Y,s as H,t as w,u as T,v,w as X,x as Z,y as ii,z as ti}from"./chunk-P72NBTYE.js";var si={bool:{group:"boolean"},boolean:{group:"boolean"},bytea:{group:"string"},char:{group:"string"},citext:{group:"string"},date:{group:"datetime"},interval:{group:"string"},name:{group:"string"},varchar:{group:"string"},text:{group:"string"},time:{group:"time"},timestamp:{group:"datetime"},timestamptz:{group:"datetime"},"timestamp without time zone":{group:"datetime"},"timestamp with time zone":{group:"datetime"},timetz:{group:"time"},"time without time zone":{group:"time"},"time with time zone":{group:"datetime"},uuid:{group:"string"},int2:{group:"numeric"},int4:{group:"numeric"},int8:{group:"numeric"},smallint:{group:"numeric"},integer:{group:"numeric"},bigint:{group:"numeric"},decimal:{group:"numeric"},numeric:{group:"numeric"},real:{group:"numeric"},float4:{group:"numeric"},float8:{group:"numeric"},"double precision":{group:"numeric"},json:{group:"json"},jsonb:{group:"json"}};var P=class e{#i;constructor(i){this.#i=m(i)}get expressionType(){}get isRawBuilder(){return!0}as(i){return new q(this,i)}$castTo(){return new e({...this.#i})}$notNull(){return new e(this.#i)}withPlugin(i){return new e({...this.#i,plugins:this.#i.plugins!==void 0?m([...this.#i.plugins,i]):m([i])})}toOperationNode(){return this.#e(this.#t())}compile(i){return this.#s(this.#t(i))}async execute(i){let t=this.#t(i);return t.executeQuery(this.#s(t),this.#i.queryId)}#t(i){let t=i!==void 0?i.getExecutor():X;return this.#i.plugins!==void 0?t.withPlugins(this.#i.plugins):t}#e(i){return i.transformQuery(this.#i.rawNode,this.#i.queryId)}#s(i){return i.compileQuery(this.#e(i),this.#i.queryId)}};function N(e){return new P(e)}var q=class{#i;#t;constructor(i,t){this.#i=i,this.#t=t}get expression(){return this.#i}get alias(){return this.#t}get rawBuilder(){return this.#i}toOperationNode(){return W.create(this.#i.toOperationNode(),I(this.#t)?this.#t.toOperationNode():C.create(this.#t))}};var o=Object.assign((e,...i)=>N({queryId:v(),rawNode:f.create(e,i?.map(ri)??[])}),{ref(e){return N({queryId:v(),rawNode:f.createWithChild($(e))})},val(e){return N({queryId:v(),rawNode:f.createWithChild(k(e))})},value(e){return this.val(e)},table(e){return N({queryId:v(),rawNode:f.createWithChild(ii(e))})},id(...e){let i=new Array(e.length+1).fill(".");return i[0]="",i[i.length-1]="",N({queryId:v(),rawNode:f.create(i,e.map(C.create))})},lit(e){return N({queryId:v(),rawNode:f.createWithChild(G.createImmediate(e))})},literal(e){return this.lit(e)},raw(e){return N({queryId:v(),rawNode:f.createWithSql(e)})},join(e,i=o`, `){let t=new Array(Math.max(2*e.length-1,0)),s=i.toOperationNode();for(let r=0;r<e.length;++r)t[2*r]=ri(e[r]),r!==e.length-1&&(t[2*r+1]=s);return N({queryId:v(),rawNode:f.createWithChildren(t)})}});function ri(e){return I(e)?e.toOperationNode():k(e)}var O=class{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#i=m({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=i=>{this.nodeStack.push(i),this.#i[i.kind](i),this.nodeStack.pop()}};var Ni=/'/g,D=class extends O{#i="";#t=[];get numParameters(){return this.#t.length}compileQuery(i,t){return this.#i="",this.#t=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(i),m({query:i,queryId:t,sql:this.getSql(),parameters:[...this.#t]})}getSql(){return this.#i}visitSelectQuery(i){let t=this.parentNode!==void 0&&!Y.is(this.parentNode)&&!H.is(this.parentNode)&&!F.is(this.parentNode)&&!ti.is(this.parentNode)&&!Z.is(this.parentNode);this.parentNode===void 0&&i.explain&&(this.visitNode(i.explain),this.append(" ")),t&&this.append("("),i.with&&(this.visitNode(i.with),this.append(" ")),this.append("select"),i.distinctOn&&(this.append(" "),this.compileDistinctOn(i.distinctOn)),i.frontModifiers?.length&&(this.append(" "),this.compileList(i.frontModifiers," ")),i.top&&(this.append(" "),this.visitNode(i.top)),i.selections&&(this.append(" "),this.compileList(i.selections)),i.from&&(this.append(" "),this.visitNode(i.from)),i.joins&&(this.append(" "),this.compileList(i.joins," ")),i.where&&(this.append(" "),this.visitNode(i.where)),i.groupBy&&(this.append(" "),this.visitNode(i.groupBy)),i.having&&(this.append(" "),this.visitNode(i.having)),i.setOperations&&(this.append(" "),this.compileList(i.setOperations," ")),i.orderBy&&(this.append(" "),this.visitNode(i.orderBy)),i.limit&&(this.append(" "),this.visitNode(i.limit)),i.offset&&(this.append(" "),this.visitNode(i.offset)),i.fetch&&(this.append(" "),this.visitNode(i.fetch)),i.endModifiers?.length&&(this.append(" "),this.compileList(this.sortSelectModifiers([...i.endModifiers])," ")),t&&this.append(")")}visitFrom(i){this.append("from "),this.compileList(i.froms)}visitSelection(i){this.visitNode(i.selection)}visitColumn(i){this.visitNode(i.column)}compileDistinctOn(i){this.append("distinct on ("),this.compileList(i),this.append(")")}compileList(i,t=", "){let s=i.length-1;for(let r=0;r<=s;r++)this.visitNode(i[r]),r<s&&this.append(t)}visitWhere(i){this.append("where "),this.visitNode(i.where)}visitHaving(i){this.append("having "),this.visitNode(i.having)}visitInsertQuery(i){let t=this.nodeStack.find(T.is),s=t!==i;!s&&i.explain&&(this.visitNode(i.explain),this.append(" ")),s&&!w.is(t)&&this.append("("),i.with&&(this.visitNode(i.with),this.append(" ")),this.append(i.replace?"replace":"insert"),i.ignore&&(K("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore")),i.orAction&&(this.append(" "),this.visitNode(i.orAction)),i.top&&(this.append(" "),this.visitNode(i.top)),i.into&&(this.append(" into "),this.visitNode(i.into)),i.columns&&(this.append(" ("),this.compileList(i.columns),this.append(")")),i.output&&(this.append(" "),this.visitNode(i.output)),i.values&&(this.append(" "),this.visitNode(i.values)),i.defaultValues&&(this.append(" "),this.append("default values")),i.onConflict&&(this.append(" "),this.visitNode(i.onConflict)),i.onDuplicateKey&&(this.append(" "),this.visitNode(i.onDuplicateKey)),i.returning&&(this.append(" "),this.visitNode(i.returning)),s&&!w.is(t)&&this.append(")"),i.endModifiers?.length&&(this.append(" "),this.compileList(i.endModifiers," "))}visitValues(i){this.append("values "),this.compileList(i.values)}visitDeleteQuery(i){let t=this.nodeStack.find(T.is)!==i;!t&&i.explain&&(this.visitNode(i.explain),this.append(" ")),t&&this.append("("),i.with&&(this.visitNode(i.with),this.append(" ")),this.append("delete "),i.top&&(this.visitNode(i.top),this.append(" ")),this.visitNode(i.from),i.output&&(this.append(" "),this.visitNode(i.output)),i.using&&(this.append(" "),this.visitNode(i.using)),i.joins&&(this.append(" "),this.compileList(i.joins," ")),i.where&&(this.append(" "),this.visitNode(i.where)),i.orderBy&&(this.append(" "),this.visitNode(i.orderBy)),i.limit&&(this.append(" "),this.visitNode(i.limit)),i.returning&&(this.append(" "),this.visitNode(i.returning)),t&&this.append(")"),i.endModifiers?.length&&(this.append(" "),this.compileList(i.endModifiers," "))}visitReturning(i){this.append("returning "),this.compileList(i.selections)}visitAlias(i){this.visitNode(i.node),this.append(" as "),this.visitNode(i.alias)}visitReference(i){i.table&&(this.visitNode(i.table),this.append(".")),this.visitNode(i.column)}visitSelectAll(i){this.append("*")}visitIdentifier(i){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(i),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(i){if(!E(i.name))throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(i.name))}visitAnd(i){this.visitNode(i.left),this.append(" and "),this.visitNode(i.right)}visitOr(i){this.visitNode(i.left),this.append(" or "),this.visitNode(i.right)}visitValue(i){i.immediate?this.appendImmediateValue(i.value):this.appendValue(i.value)}visitValueList(i){this.append("("),this.compileList(i.values),this.append(")")}visitTuple(i){this.append("("),this.compileList(i.values),this.append(")")}visitPrimitiveValueList(i){this.append("(");let{values:t}=i;for(let s=0;s<t.length;++s)this.appendValue(t[s]),s!==t.length-1&&this.append(", ");this.append(")")}visitParens(i){this.append("("),this.visitNode(i.node),this.append(")")}visitJoin(i){this.append(yi[i.joinType]),this.append(" "),this.visitNode(i.table),i.on&&(this.append(" "),this.visitNode(i.on))}visitOn(i){this.append("on "),this.visitNode(i.on)}visitRaw(i){let{sqlFragments:t,parameters:s}=i;for(let r=0;r<t.length;++r)this.append(t[r]),s.length>r&&this.visitNode(s[r])}visitOperator(i){this.append(i.operator)}visitTable(i){this.visitNode(i.table)}visitSchemableIdentifier(i){i.schema&&(this.visitNode(i.schema),this.append(".")),this.visitNode(i.identifier)}visitCreateTable(i){this.append("create "),i.frontModifiers&&i.frontModifiers.length>0&&(this.compileList(i.frontModifiers," "),this.append(" ")),i.temporary&&this.append("temporary "),this.append("table "),i.ifNotExists&&this.append("if not exists "),this.visitNode(i.table),i.selectQuery?(this.append(" as "),this.visitNode(i.selectQuery)):(this.append(" ("),this.compileList([...i.columns,...i.constraints??[]]),this.append(")"),i.onCommit&&(this.append(" on commit "),this.append(i.onCommit)),i.endModifiers&&i.endModifiers.length>0&&(this.append(" "),this.compileList(i.endModifiers," ")))}visitColumnDefinition(i){i.ifNotExists&&this.append("if not exists "),this.visitNode(i.column),this.append(" "),this.visitNode(i.dataType),i.unsigned&&this.append(" unsigned"),i.frontModifiers&&i.frontModifiers.length>0&&(this.append(" "),this.compileList(i.frontModifiers," ")),i.generated&&(this.append(" "),this.visitNode(i.generated)),i.identity&&this.append(" identity"),i.defaultTo&&(this.append(" "),this.visitNode(i.defaultTo)),i.notNull&&this.append(" not null"),i.unique&&this.append(" unique"),i.nullsNotDistinct&&this.append(" nulls not distinct"),i.primaryKey&&this.append(" primary key"),i.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),i.references&&(this.append(" "),this.visitNode(i.references)),i.check&&(this.append(" "),this.visitNode(i.check)),i.endModifiers&&i.endModifiers.length>0&&(this.append(" "),this.compileList(i.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(i){this.append("references "),this.visitNode(i.table),this.append(" ("),this.compileList(i.columns),this.append(")"),i.onDelete&&(this.append(" on delete "),this.append(i.onDelete)),i.onUpdate&&(this.append(" on update "),this.append(i.onUpdate))}visitDropTable(i){this.append("drop table "),i.ifExists&&this.append("if exists "),this.visitNode(i.table),i.cascade&&this.append(" cascade")}visitDataType(i){this.append(i.dataType)}visitOrderBy(i){this.append("order by "),this.compileList(i.items)}visitOrderByItem(i){this.visitNode(i.orderBy),i.collation&&(this.append(" "),this.visitNode(i.collation)),i.direction&&(this.append(" "),this.visitNode(i.direction)),i.nulls&&(this.append(" nulls "),this.append(i.nulls))}visitGroupBy(i){this.append("group by "),this.compileList(i.items)}visitGroupByItem(i){this.visitNode(i.groupBy)}visitUpdateQuery(i){let t=this.nodeStack.find(T.is),s=t!==i;if(!s&&i.explain&&(this.visitNode(i.explain),this.append(" ")),s&&!w.is(t)&&this.append("("),i.with&&(this.visitNode(i.with),this.append(" ")),this.append("update "),i.top&&(this.visitNode(i.top),this.append(" ")),i.table&&(this.visitNode(i.table),this.append(" ")),this.append("set "),i.updates&&this.compileList(i.updates),i.output&&(this.append(" "),this.visitNode(i.output)),i.from&&(this.append(" "),this.visitNode(i.from)),i.joins){if(!i.from)throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList(i.joins," ")}i.where&&(this.append(" "),this.visitNode(i.where)),i.orderBy&&(this.append(" "),this.visitNode(i.orderBy)),i.limit&&(this.append(" "),this.visitNode(i.limit)),i.returning&&(this.append(" "),this.visitNode(i.returning)),s&&!w.is(t)&&this.append(")"),i.endModifiers?.length&&(this.append(" "),this.compileList(i.endModifiers," "))}visitColumnUpdate(i){this.visitNode(i.column),this.append(" = "),this.visitNode(i.value)}visitLimit(i){this.append("limit "),this.visitNode(i.limit)}visitOffset(i){this.append("offset "),this.visitNode(i.offset)}visitOnConflict(i){this.append("on conflict"),i.columns?(this.append(" ("),this.compileList(i.columns),this.append(")")):i.constraint?(this.append(" on constraint "),this.visitNode(i.constraint)):i.indexExpression&&(this.append(" ("),this.visitNode(i.indexExpression),this.append(")")),i.indexWhere&&(this.append(" "),this.visitNode(i.indexWhere)),i.doNothing===!0?this.append(" do nothing"):i.updates&&(this.append(" do update set "),this.compileList(i.updates),i.updateWhere&&(this.append(" "),this.visitNode(i.updateWhere)))}visitOnDuplicateKey(i){this.append("on duplicate key update "),this.compileList(i.updates)}visitCreateIndex(i){this.append("create "),i.unique&&this.append("unique "),this.append("index "),i.ifNotExists&&this.append("if not exists "),this.visitNode(i.name),i.table&&(this.append(" on "),this.visitNode(i.table)),i.using&&(this.append(" using "),this.visitNode(i.using)),i.columns&&(this.append(" ("),this.compileList(i.columns),this.append(")")),i.nullsNotDistinct&&this.append(" nulls not distinct"),i.where&&(this.append(" "),this.visitNode(i.where))}visitDropIndex(i){this.append("drop index "),i.ifExists&&this.append("if exists "),this.visitNode(i.name),i.table&&(this.append(" on "),this.visitNode(i.table)),i.cascade&&this.append(" cascade")}visitCreateSchema(i){this.append("create schema "),i.ifNotExists&&this.append("if not exists "),this.visitNode(i.schema)}visitDropSchema(i){this.append("drop schema "),i.ifExists&&this.append("if exists "),this.visitNode(i.schema),i.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(i){i.name&&(this.append("constraint "),this.visitNode(i.name),this.append(" ")),this.append("primary key ("),this.compileList(i.columns),this.append(")"),this.buildDeferrable(i)}buildDeferrable(i){i.deferrable!==void 0&&(i.deferrable?this.append(" deferrable"):this.append(" not deferrable")),i.initiallyDeferred!==void 0&&(i.initiallyDeferred?this.append(" initially deferred"):this.append(" initially immediate"))}visitUniqueConstraint(i){i.name&&(this.append("constraint "),this.visitNode(i.name),this.append(" ")),this.append("unique"),i.nullsNotDistinct&&this.append(" nulls not distinct"),this.append(" ("),this.compileList(i.columns),this.append(")"),this.buildDeferrable(i)}visitCheckConstraint(i){i.name&&(this.append("constraint "),this.visitNode(i.name),this.append(" ")),this.append("check ("),this.visitNode(i.expression),this.append(")")}visitForeignKeyConstraint(i){i.name&&(this.append("constraint "),this.visitNode(i.name),this.append(" ")),this.append("foreign key ("),this.compileList(i.columns),this.append(") "),this.visitNode(i.references),i.onDelete&&(this.append(" on delete "),this.append(i.onDelete)),i.onUpdate&&(this.append(" on update "),this.append(i.onUpdate)),this.buildDeferrable(i)}visitList(i){this.compileList(i.items)}visitWith(i){this.append("with "),i.recursive&&this.append("recursive "),this.compileList(i.expressions)}visitCommonTableExpression(i){this.visitNode(i.name),this.append(" as "),Q(i.materialized)&&(i.materialized||this.append("not "),this.append("materialized ")),this.visitNode(i.expression)}visitCommonTableExpressionName(i){this.visitNode(i.table),i.columns&&(this.append("("),this.compileList(i.columns),this.append(")"))}visitAlterTable(i){this.append("alter table "),this.visitNode(i.table),this.append(" "),i.renameTo&&(this.append("rename to "),this.visitNode(i.renameTo)),i.setSchema&&(this.append("set schema "),this.visitNode(i.setSchema)),i.addConstraint&&this.visitNode(i.addConstraint),i.dropConstraint&&this.visitNode(i.dropConstraint),i.renameConstraint&&this.visitNode(i.renameConstraint),i.columnAlterations&&this.compileColumnAlterations(i.columnAlterations),i.addIndex&&this.visitNode(i.addIndex),i.dropIndex&&this.visitNode(i.dropIndex)}visitAddColumn(i){this.append("add column "),this.visitNode(i.column)}visitRenameColumn(i){this.append("rename column "),this.visitNode(i.column),this.append(" to "),this.visitNode(i.renameTo)}visitDropColumn(i){this.append("drop column "),this.visitNode(i.column)}visitAlterColumn(i){this.append("alter column "),this.visitNode(i.column),this.append(" "),i.dataType&&(this.announcesNewColumnDataType()&&this.append("type "),this.visitNode(i.dataType),i.dataTypeExpression&&(this.append("using "),this.visitNode(i.dataTypeExpression))),i.setDefault&&(this.append("set default "),this.visitNode(i.setDefault)),i.dropDefault&&this.append("drop default"),i.setNotNull&&this.append("set not null"),i.dropNotNull&&this.append("drop not null")}visitModifyColumn(i){this.append("modify column "),this.visitNode(i.column)}visitAddConstraint(i){this.append("add "),this.visitNode(i.constraint)}visitDropConstraint(i){this.append("drop constraint "),i.ifExists&&this.append("if exists "),this.visitNode(i.constraintName),i.modifier==="cascade"?this.append(" cascade"):i.modifier==="restrict"&&this.append(" restrict")}visitRenameConstraint(i){this.append("rename constraint "),this.visitNode(i.oldName),this.append(" to "),this.visitNode(i.newName)}visitSetOperation(i){this.append(i.operator),this.append(" "),i.all&&this.append("all "),this.visitNode(i.expression)}visitCreateView(i){this.append("create "),i.orReplace&&this.append("or replace "),i.materialized&&this.append("materialized "),i.temporary&&this.append("temporary "),this.append("view "),i.ifNotExists&&this.append("if not exists "),this.visitNode(i.name),this.append(" "),i.columns&&(this.append("("),this.compileList(i.columns),this.append(") ")),i.as&&(this.append("as "),this.visitNode(i.as))}visitRefreshMaterializedView(i){this.append("refresh materialized view "),i.concurrently&&this.append("concurrently "),this.visitNode(i.name),i.withNoData?this.append(" with no data"):this.append(" with data")}visitDropView(i){this.append("drop "),i.materialized&&this.append("materialized "),this.append("view "),i.ifExists&&this.append("if exists "),this.visitNode(i.name),i.cascade&&this.append(" cascade")}visitGenerated(i){this.append("generated "),i.always&&this.append("always "),i.byDefault&&this.append("by default "),this.append("as "),i.identity&&this.append("identity"),i.expression&&(this.append("("),this.visitNode(i.expression),this.append(")")),i.stored&&this.append(" stored")}visitDefaultValue(i){this.append("default "),this.visitNode(i.defaultValue)}visitSelectModifier(i){i.rawModifier?this.visitNode(i.rawModifier):this.append(gi[i.modifier]),i.of&&(this.append(" of "),this.compileList(i.of,", "))}visitCreateType(i){this.append("create type "),this.visitNode(i.name),i.enum&&(this.append(" as enum "),this.visitNode(i.enum))}visitDropType(i){this.append("drop type "),i.ifExists&&this.append("if exists "),this.visitNode(i.name)}visitExplain(i){this.append("explain"),(i.options||i.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),i.options&&(this.visitNode(i.options),i.format&&this.append(this.getExplainOptionsDelimiter())),i.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(i.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(i){this.append("default")}visitAggregateFunction(i){this.append(i.func),this.append("("),i.distinct&&this.append("distinct "),this.compileList(i.aggregated),i.orderBy&&(this.append(" "),this.visitNode(i.orderBy)),this.append(")"),i.withinGroup&&(this.append(" within group ("),this.visitNode(i.withinGroup),this.append(")")),i.filter&&(this.append(" filter("),this.visitNode(i.filter),this.append(")")),i.over&&(this.append(" "),this.visitNode(i.over))}visitOver(i){this.append("over("),i.partitionBy&&(this.visitNode(i.partitionBy),i.orderBy&&this.append(" ")),i.orderBy&&this.visitNode(i.orderBy),this.append(")")}visitPartitionBy(i){this.append("partition by "),this.compileList(i.items)}visitPartitionByItem(i){this.visitNode(i.partitionBy)}visitBinaryOperation(i){this.visitNode(i.leftOperand),this.append(" "),this.visitNode(i.operator),this.append(" "),this.visitNode(i.rightOperand)}visitUnaryOperation(i){this.visitNode(i.operator),this.isMinusOperator(i.operator)||this.append(" "),this.visitNode(i.operand)}isMinusOperator(i){return J.is(i)&&i.operator==="-"}visitUsing(i){this.append("using "),this.compileList(i.tables)}visitFunction(i){this.append(i.func),this.append("("),this.compileList(i.arguments),this.append(")")}visitCase(i){this.append("case"),i.value&&(this.append(" "),this.visitNode(i.value)),i.when&&(this.append(" "),this.compileList(i.when," ")),i.else&&(this.append(" else "),this.visitNode(i.else)),this.append(" end"),i.isStatement&&this.append(" case")}visitWhen(i){this.append("when "),this.visitNode(i.condition),i.result&&(this.append(" then "),this.visitNode(i.result))}visitJSONReference(i){this.visitNode(i.reference),this.visitNode(i.traversal)}visitJSONPath(i){i.inOperator&&this.visitNode(i.inOperator),this.append("'$");for(let t of i.pathLegs)this.visitNode(t);this.append("'")}visitJSONPathLeg(i){let t=i.type==="ArrayLocation";this.append(t?"[":"."),this.append(String(i.value)),t&&this.append("]")}visitJSONOperatorChain(i){for(let t=0,s=i.values.length;t<s;t++)t===s-1?this.visitNode(i.operator):this.append("->"),this.visitNode(i.values[t])}visitMergeQuery(i){i.with&&(this.visitNode(i.with),this.append(" ")),this.append("merge "),i.top&&(this.visitNode(i.top),this.append(" ")),this.append("into "),this.visitNode(i.into),i.using&&(this.append(" "),this.visitNode(i.using)),i.whens&&(this.append(" "),this.compileList(i.whens," ")),i.returning&&(this.append(" "),this.visitNode(i.returning)),i.output&&(this.append(" "),this.visitNode(i.output)),i.endModifiers?.length&&(this.append(" "),this.compileList(i.endModifiers," "))}visitMatched(i){i.not&&this.append("not "),this.append("matched"),i.bySource&&this.append(" by source")}visitAddIndex(i){this.append("add "),i.unique&&this.append("unique "),this.append("index "),this.visitNode(i.name),i.columns&&(this.append(" ("),this.compileList(i.columns),this.append(")")),i.using&&(this.append(" using "),this.visitNode(i.using))}visitCast(i){this.append("cast("),this.visitNode(i.expression),this.append(" as "),this.visitNode(i.dataType),this.append(")")}visitFetch(i){this.append("fetch next "),this.visitNode(i.rowCount),this.append(` rows ${i.modifier}`)}visitOutput(i){this.append("output "),this.compileList(i.selections)}visitTop(i){this.append(`top(${i.expression})`),i.modifiers&&this.append(` ${i.modifiers}`)}visitOrAction(i){this.append(i.action)}visitCollate(i){this.append("collate "),this.visitNode(i.collation)}append(i){this.#i+=i}appendValue(i){this.addParameter(i),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(i){let t=this.getLeftIdentifierWrapper(),s=this.getRightIdentifierWrapper(),r="";for(let a of i)r+=a,a===t?r+=t:a===s&&(r+=s);return r}sanitizeStringLiteral(i){return i.replace(Ni,"''")}addParameter(i){this.#t.push(i)}appendImmediateValue(i){if(E(i))this.appendStringLiteral(i);else if(z(i)||Q(i))this.append(i.toString());else if(j(i))this.append("null");else if(V(i))this.appendImmediateValue(i.toISOString());else if(U(i))this.appendImmediateValue(i.toString());else throw new Error(`invalid immediate value ${i}`)}appendStringLiteral(i){this.append("'"),this.append(this.sanitizeStringLiteral(i)),this.append("'")}sortSelectModifiers(i){return i.sort((t,s)=>t.modifier&&s.modifier?ai[t.modifier]-ai[s.modifier]:1),m(i)}compileColumnAlterations(i){this.compileList(i)}announcesNewColumnDataType(){return!0}},gi=m({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),ai=m({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),yi=m({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"});var S=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}};var bi=/"/g,L=class extends D{sanitizeIdentifier(i){return i.replace(bi,'""')}};var xi=BigInt("3853314791062309107"),A=class extends S{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(i,t){await o`select pg_advisory_xact_lock(${o.lit(xi)})`.execute(i)}async releaseMigrationLock(i,t){}};function y(e){return ei({...e,Adapter:A,QueryCompiler:L})}function ni(e,i){let{table:t,rows:s}=e,{name:r,schema:a,columns:n}=t,p=y(i),h=Object.keys(n),l={[h[0]]:o`default`};return g(p.withSchema(a).insertInto(r).values(s.map(u=>Object.keys(u).length===0?l:u)).returning(h).returning(u=>u.cast("ctid","text").as("ctid")))}function pi(e,i){let{pageIndex:t,pageSize:s,sortOrder:r,table:{name:a,schema:n,columns:p}}=e,h=y(i),l=Object.keys(p),u=h.withSchema(n).selectFrom(a).select(d=>d.cast(d.fn.coalesce(d.fn.countAll(),o.lit(0)),"text").as("oid"));return g(h.with("count",()=>u).withSchema(n).selectFrom([a,"count"]).select(o.ref("count.oid").$castTo().as("oid")).select(d=>d.cast("ctid","text").as("ctid")).select(l).$call(d=>r.reduce((b,x)=>b.orderBy(x.column,x.direction),d)).limit(s).offset(o.lit(BigInt(t)*BigInt(s))))}function It(){return[{created_at:new Date("2025-01-26T21:56:12.345Z"),ctid:"(0,1)",deleted_at:null,id:1,name:"John Doe",oid:"2",role:"admin"},{created_at:new Date("2025-01-26T20:56:12.345Z"),ctid:"(0,2)",deleted_at:null,id:2,name:"Jane Doe",oid:"2",role:"poweruser"}]}function oi(e,i){let{changes:t,row:s,table:{columns:r,name:a,schema:n}}=e,p=y(i),h=Object.keys(r);return g(p.withSchema(n).updateTable(a).set(t).$call(B([s],r)).returning(h).returning(l=>[l.cast("ctid","text").as("ctid"),l.cast(l.fn("floor",[l(l.fn("extract",[o`epoch from now()`]),"*",1e6)]),"text").as("__ps_updated_at__")]))}function hi(e,i){let{rows:t,table:{columns:s,name:r,schema:a}}=e,n=y(i);return g(n.withSchema(a).deleteFrom(r).$call(B(t,s)))}function di(e){return o`(select coalesce(json_agg(agg), '[]') from ${e} as agg)`}var wi="r",Ci="v",Ii=[wi,Ci];function li(e){return g(y(e).selectFrom("pg_catalog.pg_class as cls").innerJoin("pg_catalog.pg_namespace as ns","cls.relnamespace","ns.oid").$call(Ti).where("cls.relkind","in",Ii).select(i=>["ns.nspname as schema","cls.relname as name",di(i.selectFrom("pg_catalog.pg_attribute as att").innerJoin("pg_catalog.pg_type as typ","typ.oid","att.atttypid").innerJoin("pg_catalog.pg_namespace as tns","tns.oid","typ.typnamespace").leftJoin("pg_catalog.pg_constraint as con",t=>t.on("con.contype","=","p").onRef("con.conrelid","=","cls.oid").on(s=>s("att.attnum","=",s.fn.any("con.conkey")))).whereRef("att.attrelid","=","cls.oid").where("att.attnum",">=",0).where("att.attisdropped","!=",!0).where("att.attgenerated","=","").select(["att.attname as name","typ.typname as datatype","tns.nspname as datatype_schema"]).select(t=>[t("con.conkey","is not",null).$castTo().as("pk"),t("att.attgenerated","!=","").$castTo().as("computed"),t("att.attnotnull","!=",!0).$castTo().as("nullable"),t.fn.coalesce(t.selectFrom("pg_catalog.pg_enum as enm").whereRef("enm.enumtypid","=","typ.oid").select(s=>s.fn.jsonAgg(s.ref("enm.enumlabel")).as("o")),o`'[]'`).as("options")])).as("columns")]))}function ui(){return[{schema:"public",name:"users",columns:[{name:"id",datatype:"bigint",datatype_schema:"public",pk:!0,computed:!1,options:[],nullable:!0},{name:"name",datatype:"varchar",datatype_schema:"public",pk:!1,computed:!1,options:[],nullable:!0},{name:"role",datatype:"role",datatype_schema:"public",pk:!1,computed:!1,options:["admin","maintainer","member"],nullable:!0},{name:"created_at",datatype:"timestamptz",datatype_schema:"public",pk:!1,computed:!1,options:[],nullable:!0},{name:"deleted_at",datatype:"timestamptz",datatype_schema:"public",pk:!1,computed:!1,options:[],nullable:!0}]}]}function ci(){let e=y();return g(e.selectNoFrom(e.fn("current_setting",[o.lit("timezone")]).as("timezone")))}function mi(){return[{timezone:"UTC"}]}function Ti(e){return e.where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema")}function Mt(e){let{executor:i,...t}=e;return{defaultSchema:"public",async introspect(s){try{let r=li(t),a=ci(),[[n,p],[h,l]]=await Promise.all([i.execute(r,s),i.execute(a,s)]),u=n||h;if(u)return[u];let[d]=l;return d?[null,fi(p,d.timezone)]:[new Error("Timezone not found")]}catch(r){return[r]}},async query(s,r){try{let a=pi(s,t),[n,p]=await i.execute(a,r);return n?[n]:[null,{filteredRowCount:p[0]?.oid||"0",rows:p}]}catch(a){return[a]}},async insert(s,r){try{let a=ni(s,t),[n,p]=await i.execute(a,r);return n?[n]:[null,{rows:p}]}catch(a){return[a]}},async update(s,r){try{let a=oi(s,t),[n,p]=await i.execute(a,r);if(n)return[n];let[h]=p;return h?[null,{row:h}]:[new Error("Update failed")]}catch(a){return[a]}},async delete(s,r){try{let a=hi(s,t),[n]=await i.execute(a,r);return n?[n]:[null,s]}catch(a){return[a]}}}}function fi(e,i){return e.reduce((t,s)=>{let{schemas:r}=t,{columns:a,name:n,schema:p}=s,h=a.reduce((l,u)=>{let{datatype:d,datatype_schema:b,name:x,options:M,nullable:vi}=u,_=d.startsWith("_"),R=_?d.slice(1):d;return{...l,[x]:{datatype:{...si[R]||{group:M.length>0?"enum":"raw"},isArray:_,isNative:b==="pg_catalog",name:_?`${R}[]`:R,options:M,schema:b},isComputed:u.computed,isInPrimaryKey:u.pk,name:x,nullable:vi,schema:p,table:n}}},{});return(r[p]||={tables:{}}).tables[n]={columns:h,name:n,schema:p},t},{schemas:{public:{tables:{}}},timezone:i})}function zt(){let e=ui(),[{timezone:i}]=mi();return fi(e,i)}export{ni as a,pi as b,It as c,oi as d,hi as e,li as f,ui as g,ci as h,mi as i,Mt as j,zt as k};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as Executor, Q as Query, a as ExecuteOptions, b as QueryResult } from '../../index-
|
|
2
|
-
import { E as Either } from '../../adapter-
|
|
1
|
+
import { E as Executor, Q as Query, a as ExecuteOptions, b as QueryResult } from '../../index-BNAA6jKD.cjs';
|
|
2
|
+
import { E as Either } from '../../adapter-CKFCHq71.cjs';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
|
|
5
5
|
declare function deserializeRawResult(response: RawResponse, valueDeserializerFn?: (value: unknown, type: QueryIntrospectionBuiltinType, column: string) => unknown): DeserializedResponse;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as Executor, Q as Query, a as ExecuteOptions, b as QueryResult } from '../../index-
|
|
2
|
-
import { E as Either } from '../../adapter-
|
|
1
|
+
import { E as Executor, Q as Query, a as ExecuteOptions, b as QueryResult } from '../../index-BDPv5Gnt.js';
|
|
2
|
+
import { E as Either } from '../../adapter-CKFCHq71.js';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
|
|
5
5
|
declare function deserializeRawResult(response: RawResponse, valueDeserializerFn?: (value: unknown, type: QueryIntrospectionBuiltinType, column: string) => unknown): DeserializedResponse;
|