@prisma/studio-core 0.0.0-dev.202505082258 → 0.0.0-dev.202505082315
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-V4BHP4CI.js +1 -0
- package/dist/OKF6E45R-XYOIK2NY.js +1 -0
- package/dist/adapter-CH4qnR6R.d.cts +219 -0
- package/dist/adapter-CH4qnR6R.d.ts +219 -0
- package/dist/chunk-2ZJZX5I7.js +0 -0
- package/dist/chunk-555OIWZX.js +1 -0
- package/dist/chunk-5MNS4IJC.js +1332 -0
- package/dist/chunk-BMVJYUJW.js +1 -0
- package/dist/chunk-N2MLAUEV.js +1 -0
- package/dist/chunk-P72NBTYE.js +1 -0
- package/dist/data/accelerate/index.cjs +1 -0
- package/dist/data/accelerate/index.d.cts +47 -0
- package/dist/data/accelerate/index.d.ts +47 -0
- package/dist/data/accelerate/index.js +1 -0
- package/dist/data/bff/index.cjs +1 -0
- package/dist/data/bff/index.d.cts +55 -0
- package/dist/data/bff/index.d.ts +55 -0
- package/dist/data/bff/index.js +1 -0
- package/dist/data/index.cjs +1 -0
- package/dist/data/index.d.cts +3 -0
- package/dist/data/index.d.ts +3 -0
- package/dist/data/index.js +1 -0
- package/dist/data/pglite/index.cjs +1 -0
- package/dist/data/pglite/index.d.cts +26 -0
- package/dist/data/pglite/index.d.ts +26 -0
- package/dist/data/pglite/index.js +1 -0
- package/dist/data/postgres-core/index.cjs +1 -0
- package/dist/data/postgres-core/index.d.cts +155 -0
- package/dist/data/postgres-core/index.d.ts +155 -0
- package/dist/data/postgres-core/index.js +1 -0
- package/dist/index-BTblIzxR.d.ts +48 -0
- package/dist/index-DAubYhEp.d.cts +48 -0
- package/dist/ui/index.cjs +1603 -0
- package/dist/ui/index.css +2049 -0
- package/dist/ui/index.d.cts +27 -0
- package/dist/ui/index.d.ts +27 -0
- package/dist/ui/index.js +274 -0
- package/package.json +5 -8
|
@@ -0,0 +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-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};
|
|
@@ -0,0 +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-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};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
type Either<E, R> = [E] | [null, R];
|
|
2
|
+
type NumericString = `${number}`;
|
|
3
|
+
type BigIntString = `${bigint}`;
|
|
4
|
+
|
|
5
|
+
interface Adapter {
|
|
6
|
+
/**
|
|
7
|
+
* The schema studio will choose by default.
|
|
8
|
+
*
|
|
9
|
+
* e.g. `public` for PostgreSQL
|
|
10
|
+
*/
|
|
11
|
+
readonly defaultSchema?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Introspects the database and returns structured information about the schemas, tables, etc.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Options for the introspection request.
|
|
16
|
+
*/
|
|
17
|
+
introspect(options: AdapterIntrospectOptions): Promise<Either<Error, Introspection>>;
|
|
18
|
+
/**
|
|
19
|
+
* Executes a structured query against the database.
|
|
20
|
+
*/
|
|
21
|
+
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<Error, AdapterQueryResult>>;
|
|
22
|
+
/**
|
|
23
|
+
* Inserts a single row into the database.
|
|
24
|
+
*/
|
|
25
|
+
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<Error, AdapterInsertResult>>;
|
|
26
|
+
/**
|
|
27
|
+
* Updates a given row in the database with given changes.
|
|
28
|
+
*/
|
|
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>>;
|
|
34
|
+
}
|
|
35
|
+
interface AdapterBaseOptions {
|
|
36
|
+
}
|
|
37
|
+
interface AdapterIntrospectOptions extends AdapterBaseOptions {
|
|
38
|
+
}
|
|
39
|
+
interface AdapterQueryOptions extends AdapterBaseOptions {
|
|
40
|
+
abortSignal: AbortSignal;
|
|
41
|
+
}
|
|
42
|
+
interface AdapterInsertOptions extends AdapterBaseOptions {
|
|
43
|
+
}
|
|
44
|
+
interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
45
|
+
}
|
|
46
|
+
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
47
|
+
}
|
|
48
|
+
type SchemaName = string;
|
|
49
|
+
interface Introspection {
|
|
50
|
+
schemas: Record<SchemaName, Schema>;
|
|
51
|
+
timezone: string;
|
|
52
|
+
filterOperators: FilterOperator[];
|
|
53
|
+
}
|
|
54
|
+
type TableName = string;
|
|
55
|
+
interface Schema {
|
|
56
|
+
tables: Record<TableName, Table>;
|
|
57
|
+
}
|
|
58
|
+
type ColumnName = string;
|
|
59
|
+
interface Table {
|
|
60
|
+
columns: Record<ColumnName, Column>;
|
|
61
|
+
name: TableName;
|
|
62
|
+
schema: SchemaName;
|
|
63
|
+
}
|
|
64
|
+
interface Column {
|
|
65
|
+
datatype: DataType;
|
|
66
|
+
isComputed: boolean;
|
|
67
|
+
isInPrimaryKey: boolean;
|
|
68
|
+
name: ColumnName;
|
|
69
|
+
nullable: boolean;
|
|
70
|
+
schema: SchemaName;
|
|
71
|
+
table: TableName;
|
|
72
|
+
}
|
|
73
|
+
interface DataType {
|
|
74
|
+
/**
|
|
75
|
+
* A simplification/normalization for UI usage.
|
|
76
|
+
*
|
|
77
|
+
* e.g. varchar and char are strings.
|
|
78
|
+
*/
|
|
79
|
+
group: DataTypeGroup;
|
|
80
|
+
/**
|
|
81
|
+
* Is this a native array type?
|
|
82
|
+
*/
|
|
83
|
+
isArray: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Is a native database datatype or a user-defined datatype?
|
|
86
|
+
*
|
|
87
|
+
* e.g. PostgreSQL enums are user-defined datatypes, but `int4` is a native datatype.
|
|
88
|
+
*/
|
|
89
|
+
isNative: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Will be displayed as-is.
|
|
92
|
+
*/
|
|
93
|
+
name: string;
|
|
94
|
+
/**
|
|
95
|
+
* Enum values for enum types.
|
|
96
|
+
*/
|
|
97
|
+
options: string[];
|
|
98
|
+
/**
|
|
99
|
+
* The schema the datatype belongs to.
|
|
100
|
+
*/
|
|
101
|
+
schema: string;
|
|
102
|
+
}
|
|
103
|
+
type DataTypeGroup = "string" | "datetime" | "boolean" | "enum" | "time" | "raw" | "numeric" | "json";
|
|
104
|
+
interface AdapterQueryDetails {
|
|
105
|
+
/**
|
|
106
|
+
* Zero-based index of the page to fetch.
|
|
107
|
+
*/
|
|
108
|
+
pageIndex: number;
|
|
109
|
+
/**
|
|
110
|
+
* Maximum number of rows to fetch from the database.
|
|
111
|
+
*/
|
|
112
|
+
pageSize: number;
|
|
113
|
+
/**
|
|
114
|
+
* Sort order for the query.
|
|
115
|
+
*/
|
|
116
|
+
sortOrder: SortOrderItem[];
|
|
117
|
+
/**
|
|
118
|
+
* The table to select from.
|
|
119
|
+
*/
|
|
120
|
+
table: Table;
|
|
121
|
+
/**
|
|
122
|
+
* The filters to be applied.
|
|
123
|
+
*/
|
|
124
|
+
filters?: ColumnFilterGroup;
|
|
125
|
+
}
|
|
126
|
+
type FilterOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "in" | "not in" | "is" | "is not" | "like" | "not like" | "ilike" | "not ilike" | "match";
|
|
127
|
+
interface ColumnFilter {
|
|
128
|
+
kind: "ColumnFilter";
|
|
129
|
+
column: string;
|
|
130
|
+
operator: FilterOperator;
|
|
131
|
+
value: unknown;
|
|
132
|
+
after: "and" | "or";
|
|
133
|
+
}
|
|
134
|
+
interface ColumnFilterGroup {
|
|
135
|
+
kind: "ColumnFilters";
|
|
136
|
+
filters: (ColumnFilter | ColumnFilterGroup)[];
|
|
137
|
+
after: "and" | "or";
|
|
138
|
+
}
|
|
139
|
+
interface SortOrderItem {
|
|
140
|
+
/**
|
|
141
|
+
* The column to sort by.
|
|
142
|
+
*/
|
|
143
|
+
column: ColumnName;
|
|
144
|
+
/**
|
|
145
|
+
* The direction to sort the column by.
|
|
146
|
+
*/
|
|
147
|
+
direction: SortDirection;
|
|
148
|
+
}
|
|
149
|
+
type SortDirection = "asc" | "desc";
|
|
150
|
+
interface AdapterQueryResult {
|
|
151
|
+
/**
|
|
152
|
+
* The total number of rows the query would return if not limited.
|
|
153
|
+
*
|
|
154
|
+
* If the database does not support counting rows, this should be set to `Infinity`.
|
|
155
|
+
*/
|
|
156
|
+
filteredRowCount: number | bigint | NumericString | BigIntString;
|
|
157
|
+
/**
|
|
158
|
+
* The rows returned by the query.
|
|
159
|
+
*/
|
|
160
|
+
rows: Record<ColumnName, unknown>[];
|
|
161
|
+
}
|
|
162
|
+
interface AdapterInsertDetails {
|
|
163
|
+
/**
|
|
164
|
+
* The table to insert into.
|
|
165
|
+
*/
|
|
166
|
+
table: Table;
|
|
167
|
+
/**
|
|
168
|
+
* The values to insert into the table.
|
|
169
|
+
* - The keys should match the column names in the table.
|
|
170
|
+
* - The values should be the values to insert into the table.
|
|
171
|
+
*/
|
|
172
|
+
rows: Record<string, unknown>[];
|
|
173
|
+
}
|
|
174
|
+
interface AdapterInsertResult {
|
|
175
|
+
/**
|
|
176
|
+
* The freshly inserted row data.
|
|
177
|
+
*/
|
|
178
|
+
rows: Record<string, unknown>[];
|
|
179
|
+
}
|
|
180
|
+
interface AdapterUpdateDetails {
|
|
181
|
+
/**
|
|
182
|
+
* Changes to apply to the row.
|
|
183
|
+
*/
|
|
184
|
+
changes: Record<ColumnName, unknown>;
|
|
185
|
+
/**
|
|
186
|
+
* The row to update.
|
|
187
|
+
*/
|
|
188
|
+
row: Record<ColumnName, unknown>;
|
|
189
|
+
/**
|
|
190
|
+
* The table to update in.
|
|
191
|
+
*/
|
|
192
|
+
table: Table;
|
|
193
|
+
}
|
|
194
|
+
interface AdapterUpdateResult {
|
|
195
|
+
/**
|
|
196
|
+
* The updated row data.
|
|
197
|
+
*/
|
|
198
|
+
row: Record<ColumnName, unknown> & {
|
|
199
|
+
/**
|
|
200
|
+
* When the changes were applied in database time.
|
|
201
|
+
*/
|
|
202
|
+
__ps_updated_at__: string | number | Date;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface AdapterDeleteDetails {
|
|
206
|
+
/**
|
|
207
|
+
* The rows to delete.
|
|
208
|
+
*/
|
|
209
|
+
rows: Record<ColumnName, unknown>[];
|
|
210
|
+
/**
|
|
211
|
+
* The table to delete from.
|
|
212
|
+
*/
|
|
213
|
+
table: Table;
|
|
214
|
+
}
|
|
215
|
+
interface AdapterDeleteResult {
|
|
216
|
+
rows: Record<ColumnName, unknown>[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export type { Adapter as A, BigIntString as B, Column as C, DataType as D, Either as E, FilterOperator as F, 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, ColumnFilter as l, ColumnFilterGroup as m, SortOrderItem as n, SortDirection as o, AdapterQueryResult as p, AdapterInsertResult as q, AdapterUpdateResult as r, AdapterDeleteResult as s };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
type Either<E, R> = [E] | [null, R];
|
|
2
|
+
type NumericString = `${number}`;
|
|
3
|
+
type BigIntString = `${bigint}`;
|
|
4
|
+
|
|
5
|
+
interface Adapter {
|
|
6
|
+
/**
|
|
7
|
+
* The schema studio will choose by default.
|
|
8
|
+
*
|
|
9
|
+
* e.g. `public` for PostgreSQL
|
|
10
|
+
*/
|
|
11
|
+
readonly defaultSchema?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Introspects the database and returns structured information about the schemas, tables, etc.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Options for the introspection request.
|
|
16
|
+
*/
|
|
17
|
+
introspect(options: AdapterIntrospectOptions): Promise<Either<Error, Introspection>>;
|
|
18
|
+
/**
|
|
19
|
+
* Executes a structured query against the database.
|
|
20
|
+
*/
|
|
21
|
+
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<Error, AdapterQueryResult>>;
|
|
22
|
+
/**
|
|
23
|
+
* Inserts a single row into the database.
|
|
24
|
+
*/
|
|
25
|
+
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<Error, AdapterInsertResult>>;
|
|
26
|
+
/**
|
|
27
|
+
* Updates a given row in the database with given changes.
|
|
28
|
+
*/
|
|
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>>;
|
|
34
|
+
}
|
|
35
|
+
interface AdapterBaseOptions {
|
|
36
|
+
}
|
|
37
|
+
interface AdapterIntrospectOptions extends AdapterBaseOptions {
|
|
38
|
+
}
|
|
39
|
+
interface AdapterQueryOptions extends AdapterBaseOptions {
|
|
40
|
+
abortSignal: AbortSignal;
|
|
41
|
+
}
|
|
42
|
+
interface AdapterInsertOptions extends AdapterBaseOptions {
|
|
43
|
+
}
|
|
44
|
+
interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
45
|
+
}
|
|
46
|
+
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
47
|
+
}
|
|
48
|
+
type SchemaName = string;
|
|
49
|
+
interface Introspection {
|
|
50
|
+
schemas: Record<SchemaName, Schema>;
|
|
51
|
+
timezone: string;
|
|
52
|
+
filterOperators: FilterOperator[];
|
|
53
|
+
}
|
|
54
|
+
type TableName = string;
|
|
55
|
+
interface Schema {
|
|
56
|
+
tables: Record<TableName, Table>;
|
|
57
|
+
}
|
|
58
|
+
type ColumnName = string;
|
|
59
|
+
interface Table {
|
|
60
|
+
columns: Record<ColumnName, Column>;
|
|
61
|
+
name: TableName;
|
|
62
|
+
schema: SchemaName;
|
|
63
|
+
}
|
|
64
|
+
interface Column {
|
|
65
|
+
datatype: DataType;
|
|
66
|
+
isComputed: boolean;
|
|
67
|
+
isInPrimaryKey: boolean;
|
|
68
|
+
name: ColumnName;
|
|
69
|
+
nullable: boolean;
|
|
70
|
+
schema: SchemaName;
|
|
71
|
+
table: TableName;
|
|
72
|
+
}
|
|
73
|
+
interface DataType {
|
|
74
|
+
/**
|
|
75
|
+
* A simplification/normalization for UI usage.
|
|
76
|
+
*
|
|
77
|
+
* e.g. varchar and char are strings.
|
|
78
|
+
*/
|
|
79
|
+
group: DataTypeGroup;
|
|
80
|
+
/**
|
|
81
|
+
* Is this a native array type?
|
|
82
|
+
*/
|
|
83
|
+
isArray: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Is a native database datatype or a user-defined datatype?
|
|
86
|
+
*
|
|
87
|
+
* e.g. PostgreSQL enums are user-defined datatypes, but `int4` is a native datatype.
|
|
88
|
+
*/
|
|
89
|
+
isNative: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Will be displayed as-is.
|
|
92
|
+
*/
|
|
93
|
+
name: string;
|
|
94
|
+
/**
|
|
95
|
+
* Enum values for enum types.
|
|
96
|
+
*/
|
|
97
|
+
options: string[];
|
|
98
|
+
/**
|
|
99
|
+
* The schema the datatype belongs to.
|
|
100
|
+
*/
|
|
101
|
+
schema: string;
|
|
102
|
+
}
|
|
103
|
+
type DataTypeGroup = "string" | "datetime" | "boolean" | "enum" | "time" | "raw" | "numeric" | "json";
|
|
104
|
+
interface AdapterQueryDetails {
|
|
105
|
+
/**
|
|
106
|
+
* Zero-based index of the page to fetch.
|
|
107
|
+
*/
|
|
108
|
+
pageIndex: number;
|
|
109
|
+
/**
|
|
110
|
+
* Maximum number of rows to fetch from the database.
|
|
111
|
+
*/
|
|
112
|
+
pageSize: number;
|
|
113
|
+
/**
|
|
114
|
+
* Sort order for the query.
|
|
115
|
+
*/
|
|
116
|
+
sortOrder: SortOrderItem[];
|
|
117
|
+
/**
|
|
118
|
+
* The table to select from.
|
|
119
|
+
*/
|
|
120
|
+
table: Table;
|
|
121
|
+
/**
|
|
122
|
+
* The filters to be applied.
|
|
123
|
+
*/
|
|
124
|
+
filters?: ColumnFilterGroup;
|
|
125
|
+
}
|
|
126
|
+
type FilterOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "in" | "not in" | "is" | "is not" | "like" | "not like" | "ilike" | "not ilike" | "match";
|
|
127
|
+
interface ColumnFilter {
|
|
128
|
+
kind: "ColumnFilter";
|
|
129
|
+
column: string;
|
|
130
|
+
operator: FilterOperator;
|
|
131
|
+
value: unknown;
|
|
132
|
+
after: "and" | "or";
|
|
133
|
+
}
|
|
134
|
+
interface ColumnFilterGroup {
|
|
135
|
+
kind: "ColumnFilters";
|
|
136
|
+
filters: (ColumnFilter | ColumnFilterGroup)[];
|
|
137
|
+
after: "and" | "or";
|
|
138
|
+
}
|
|
139
|
+
interface SortOrderItem {
|
|
140
|
+
/**
|
|
141
|
+
* The column to sort by.
|
|
142
|
+
*/
|
|
143
|
+
column: ColumnName;
|
|
144
|
+
/**
|
|
145
|
+
* The direction to sort the column by.
|
|
146
|
+
*/
|
|
147
|
+
direction: SortDirection;
|
|
148
|
+
}
|
|
149
|
+
type SortDirection = "asc" | "desc";
|
|
150
|
+
interface AdapterQueryResult {
|
|
151
|
+
/**
|
|
152
|
+
* The total number of rows the query would return if not limited.
|
|
153
|
+
*
|
|
154
|
+
* If the database does not support counting rows, this should be set to `Infinity`.
|
|
155
|
+
*/
|
|
156
|
+
filteredRowCount: number | bigint | NumericString | BigIntString;
|
|
157
|
+
/**
|
|
158
|
+
* The rows returned by the query.
|
|
159
|
+
*/
|
|
160
|
+
rows: Record<ColumnName, unknown>[];
|
|
161
|
+
}
|
|
162
|
+
interface AdapterInsertDetails {
|
|
163
|
+
/**
|
|
164
|
+
* The table to insert into.
|
|
165
|
+
*/
|
|
166
|
+
table: Table;
|
|
167
|
+
/**
|
|
168
|
+
* The values to insert into the table.
|
|
169
|
+
* - The keys should match the column names in the table.
|
|
170
|
+
* - The values should be the values to insert into the table.
|
|
171
|
+
*/
|
|
172
|
+
rows: Record<string, unknown>[];
|
|
173
|
+
}
|
|
174
|
+
interface AdapterInsertResult {
|
|
175
|
+
/**
|
|
176
|
+
* The freshly inserted row data.
|
|
177
|
+
*/
|
|
178
|
+
rows: Record<string, unknown>[];
|
|
179
|
+
}
|
|
180
|
+
interface AdapterUpdateDetails {
|
|
181
|
+
/**
|
|
182
|
+
* Changes to apply to the row.
|
|
183
|
+
*/
|
|
184
|
+
changes: Record<ColumnName, unknown>;
|
|
185
|
+
/**
|
|
186
|
+
* The row to update.
|
|
187
|
+
*/
|
|
188
|
+
row: Record<ColumnName, unknown>;
|
|
189
|
+
/**
|
|
190
|
+
* The table to update in.
|
|
191
|
+
*/
|
|
192
|
+
table: Table;
|
|
193
|
+
}
|
|
194
|
+
interface AdapterUpdateResult {
|
|
195
|
+
/**
|
|
196
|
+
* The updated row data.
|
|
197
|
+
*/
|
|
198
|
+
row: Record<ColumnName, unknown> & {
|
|
199
|
+
/**
|
|
200
|
+
* When the changes were applied in database time.
|
|
201
|
+
*/
|
|
202
|
+
__ps_updated_at__: string | number | Date;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface AdapterDeleteDetails {
|
|
206
|
+
/**
|
|
207
|
+
* The rows to delete.
|
|
208
|
+
*/
|
|
209
|
+
rows: Record<ColumnName, unknown>[];
|
|
210
|
+
/**
|
|
211
|
+
* The table to delete from.
|
|
212
|
+
*/
|
|
213
|
+
table: Table;
|
|
214
|
+
}
|
|
215
|
+
interface AdapterDeleteResult {
|
|
216
|
+
rows: Record<ColumnName, unknown>[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export type { Adapter as A, BigIntString as B, Column as C, DataType as D, Either as E, FilterOperator as F, 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, ColumnFilter as l, ColumnFilterGroup as m, SortOrderItem as n, SortDirection as o, AdapterQueryResult as p, AdapterInsertResult as q, AdapterUpdateResult as r, AdapterDeleteResult as s };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as ei,B as y,C as q,a as B,b as F,c as Q,d as z,e as j,f as V,g as c,h as O,i as U,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=c(i)}get expressionType(){}get isRawBuilder(){return!0}as(i){return new M(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?c([...this.#i.plugins,i]):c([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 M=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():O.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(O.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 S=class{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#i=c({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 gi=/'/g,D=class extends S{#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),c({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)&&!U.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(!B(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(bi[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(yi[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 n of i)r+=n,n===t?r+=t:n===s&&(r+=s);return r}sanitizeStringLiteral(i){return i.replace(gi,"''")}addParameter(i){this.#t.push(i)}appendImmediateValue(i){if(B(i))this.appendStringLiteral(i);else if(F(i)||Q(i))this.append(i.toString());else if(z(i))this.append("null");else if(j(i))this.appendImmediateValue(i.toISOString());else if(V(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?ni[t.modifier]-ni[s.modifier]:1),c(i)}compileColumnAlterations(i){this.compileList(i)}announcesNewColumnDataType(){return!0}},yi=c({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),ni=c({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),bi=c({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 L=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}};var xi=/"/g,E=class extends D{sanitizeIdentifier(i){return i.replace(xi,'""')}};var wi=BigInt("3853314791062309107"),A=class extends L{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(i,t){await o`select pg_advisory_xact_lock(${o.lit(wi)})`.execute(i)}async releaseMigrationLock(i,t){}};function b(e){return ei({...e,Adapter:A,QueryCompiler:E})}function ai(e,i){let{table:t,rows:s}=e,{name:r,schema:n,columns:a}=t,p=b(i),d=Object.keys(a),h={[d[0]]:o`default`};return y(p.withSchema(n).insertInto(r).values(s.map(l=>Object.keys(l).length===0?h:l)).returning(d).returning(l=>l.cast("ctid","text").as("ctid")))}function pi(e,i){let{pageIndex:t,pageSize:s,sortOrder:r,table:{name:n,schema:a,columns:p},filters:d={kind:"ColumnFilters",after:"and",filters:[]}}=e,h=b(i),l=Object.keys(p),g=h.withSchema(a).selectFrom(n).select(m=>m.cast(m.fn.coalesce(m.fn.countAll(),o.lit(0)),"text").as("oid"));return y(h.with("count",()=>g).withSchema(a).selectFrom([n,"count"]).select(o.ref("count.oid").$castTo().as("oid")).select(m=>m.cast("ctid","text").as("ctid")).select(l).$call(m=>r.reduce((C,x)=>C.orderBy(x.column,x.direction),m)).where(oi(d.filters)).limit(s).offset(o.lit(BigInt(t)*BigInt(s))))}function Ci(e){return e.kind==="ColumnFilter"?i=>i(i.ref(e.column),e.operator,e.value):oi(e.filters)}function oi(e){if(e.length===0)return s=>s.lit(!0);let i=[],t=[];for(let s=0;s<e.length;s++)t.push(Ci(e[s])),(s===e.length-1||e[s].after==="or")&&(i.push(t),t=[]);return s=>{let r=i.map(n=>s.and(n.map(a=>a(s))));return s.or(r)}}function Et(){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 hi(e,i){let{changes:t,row:s,table:{columns:r,name:n,schema:a}}=e,p=b(i),d=Object.keys(r);return y(p.withSchema(a).updateTable(n).set(t).$call(q([s],r)).returning(d).returning(h=>[h.cast("ctid","text").as("ctid"),h.cast(h.fn("floor",[h(h.fn("extract",[o`epoch from now()`]),"*",1e6)]),"text").as("__ps_updated_at__")]))}function di(e,i){let{rows:t,table:{columns:s,name:r,schema:n}}=e,a=b(i);return y(a.withSchema(n).deleteFrom(r).$call(q(t,s)))}function li(e){return o`(select coalesce(json_agg(agg), '[]') from ${e} as agg)`}var Oi="r",Ii="v",Ti=[Oi,Ii];function ui(e){return y(b(e).selectFrom("pg_catalog.pg_class as cls").innerJoin("pg_catalog.pg_namespace as ns","cls.relnamespace","ns.oid").$call(Si).where("cls.relkind","in",Ti).select(i=>["ns.nspname as schema","cls.relname as name",li(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).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 ci(){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 mi(){let e=b();return y(e.selectNoFrom(e.fn("current_setting",[o.lit("timezone")]).as("timezone")))}function fi(){return[{timezone:"UTC"}]}function Si(e){return e.where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema")}function Wt(e){let{executor:i,...t}=e;return{defaultSchema:"public",async introspect(s){try{let r=ui(t),n=mi(),[[a,p],[d,h]]=await Promise.all([i.execute(r,s),i.execute(n,s)]),l=a||d;if(l)return[l];let[g]=h;return g?[null,vi(p,g.timezone)]:[new Error("Timezone not found")]}catch(r){return[r]}},async query(s,r){try{let n=pi(s,t),[a,p]=await i.execute(n,r);return a?[a]:[null,{filteredRowCount:p[0]?.oid||"0",rows:p}]}catch(n){return[n]}},async insert(s,r){try{let n=ai(s,t),[a,p]=await i.execute(n,r);return a?[a]:[null,{rows:p}]}catch(n){return[n]}},async update(s,r){try{let n=hi(s,t),[a,p]=await i.execute(n,r);if(a)return[a];let[d]=p;return d?[null,{row:d}]:[new Error("Update failed")]}catch(n){return[n]}},async delete(s,r){try{let n=di(s,t),[a]=await i.execute(n,r);return a?[a]:[null,s]}catch(n){return[n]}}}}function vi(e,i){return e.reduce((t,s)=>{let{schemas:r}=t,{columns:n,name:a,schema:p}=s,d=n.reduce((h,l)=>{let{datatype:g,datatype_schema:m,name:C,options:x,nullable:Ni}=l,_=g.startsWith("_"),R=_?g.slice(1):g;return{...h,[C]:{datatype:{...si[R]||{group:x.length>0?"enum":"raw"},isArray:_,isNative:m==="pg_catalog",name:_?`${R}[]`:R,options:x,schema:m},isComputed:l.computed,isInPrimaryKey:l.pk,name:C,nullable:Ni,schema:p,table:a}}},{});return(r[p]||={tables:{}}).tables[a]={columns:d,name:a,schema:p},t},{schemas:{public:{tables:{}}},timezone:i,filterOperators:Di})}var Di=["=","!=",">",">=","<","<=","in","not in","is","is not","like","not like","ilike","not ilike"];function Jt(){let e=ci(),[{timezone:i}]=fi();return vi(e,i)}export{ai as a,pi as b,Et as c,hi as d,di as e,ui as f,ci as g,mi as h,fi as i,Wt as j,Jt as k};
|