@prisma/studio-core 0.1.0 → 0.2.1
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/chunk-BUOKRYKO.js +10 -0
- package/dist/chunk-FRW62KTF.js +10 -0
- package/dist/chunk-P5LRZ6C2.js +10 -0
- package/dist/chunk-T2BEVNT5.js +10 -0
- package/dist/data/accelerate/index.cjs +2 -1
- package/dist/data/accelerate/index.d.cts +10 -2
- package/dist/data/accelerate/index.d.ts +10 -2
- package/dist/data/accelerate/index.js +10 -1
- package/dist/data/bff/index.cjs +2 -1
- package/dist/data/bff/index.d.cts +10 -3
- package/dist/data/bff/index.d.ts +10 -3
- package/dist/data/bff/index.js +10 -1
- package/dist/data/index.cjs +2 -1
- package/dist/data/index.d.cts +11 -2
- package/dist/data/index.d.ts +11 -2
- package/dist/data/index.js +10 -1
- package/dist/data/pglite/index.cjs +2 -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 +10 -1
- package/dist/data/postgres-core/index.cjs +2 -1
- package/dist/data/postgres-core/index.d.cts +103 -18
- package/dist/data/postgres-core/index.d.ts +103 -18
- package/dist/data/postgres-core/index.js +10 -1
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/query-Q-ZKX_Vr.d.cts +288 -0
- package/dist/query-Q-ZKX_Vr.d.ts +288 -0
- package/dist/ui/index.cjs +263 -1367
- package/dist/ui/index.css +1327 -680
- package/dist/ui/index.d.cts +69 -3
- package/dist/ui/index.d.ts +69 -3
- package/dist/ui/index.js +274 -41
- package/package.json +38 -31
- package/dist/CPIOZS5X-NALOZFPD.js +0 -1
- package/dist/OKF6E45R-6KC3BLVB.js +0 -1
- package/dist/adapter-Co8KY8Hi.d.cts +0 -166
- package/dist/adapter-Co8KY8Hi.d.ts +0 -166
- package/dist/chunk-2FW6TKD6.js +0 -1
- package/dist/chunk-5MNS4IJC.js +0 -1332
- package/dist/chunk-N2MLAUEV.js +0 -1
- package/dist/chunk-RGBMDID6.js +0 -1
- package/dist/chunk-ZCFLMQMM.js +0 -1
- package/dist/index-CnVNNyod.d.cts +0 -35
- package/dist/index-M4EjPWNJ.d.ts +0 -35
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { WhereInterface, DialectAdapter, QueryCompiler } from 'kysely';
|
|
2
|
+
|
|
3
|
+
type Either<E, R> = [E] | [null, R];
|
|
4
|
+
type NumericString = `${number}`;
|
|
5
|
+
type BigIntString = `${bigint}`;
|
|
6
|
+
|
|
7
|
+
interface Adapter {
|
|
8
|
+
/**
|
|
9
|
+
* The schema studio will choose by default.
|
|
10
|
+
*
|
|
11
|
+
* e.g. `public` for PostgreSQL
|
|
12
|
+
*/
|
|
13
|
+
readonly defaultSchema?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Introspects the database and returns structured information about the schemas, tables, etc.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Options for the introspection request.
|
|
18
|
+
*/
|
|
19
|
+
introspect(options: AdapterIntrospectOptions): Promise<Either<AdapterError, AdapterIntrospectResult>>;
|
|
20
|
+
/**
|
|
21
|
+
* Executes a structured query against the database.
|
|
22
|
+
*/
|
|
23
|
+
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<AdapterError, AdapterQueryResult>>;
|
|
24
|
+
/**
|
|
25
|
+
* Inserts a single row into the database.
|
|
26
|
+
*/
|
|
27
|
+
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<AdapterError, AdapterInsertResult>>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates a given row in the database with given changes.
|
|
30
|
+
*/
|
|
31
|
+
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<AdapterError, AdapterUpdateResult>>;
|
|
32
|
+
/**
|
|
33
|
+
* Deletes given rows from the database.
|
|
34
|
+
*/
|
|
35
|
+
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<AdapterError, AdapterDeleteResult>>;
|
|
36
|
+
}
|
|
37
|
+
interface AdapterBaseOptions {
|
|
38
|
+
}
|
|
39
|
+
interface AdapterIntrospectOptions extends AdapterBaseOptions {
|
|
40
|
+
}
|
|
41
|
+
interface AdapterQueryOptions extends AdapterBaseOptions {
|
|
42
|
+
abortSignal: AbortSignal;
|
|
43
|
+
}
|
|
44
|
+
interface AdapterInsertOptions extends AdapterBaseOptions {
|
|
45
|
+
}
|
|
46
|
+
interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
47
|
+
}
|
|
48
|
+
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
49
|
+
}
|
|
50
|
+
type SchemaName = string;
|
|
51
|
+
interface AdapterIntrospectResult {
|
|
52
|
+
schemas: Record<SchemaName, Schema>;
|
|
53
|
+
timezone: string;
|
|
54
|
+
filterOperators: FilterOperator[];
|
|
55
|
+
query: Query;
|
|
56
|
+
}
|
|
57
|
+
type TableName = string;
|
|
58
|
+
interface Schema {
|
|
59
|
+
name: string;
|
|
60
|
+
tables: Record<TableName, Table>;
|
|
61
|
+
}
|
|
62
|
+
type ColumnName = string;
|
|
63
|
+
interface Table {
|
|
64
|
+
columns: Record<ColumnName, Column>;
|
|
65
|
+
name: TableName;
|
|
66
|
+
schema: SchemaName;
|
|
67
|
+
}
|
|
68
|
+
interface Column {
|
|
69
|
+
datatype: DataType;
|
|
70
|
+
isComputed: boolean;
|
|
71
|
+
isInPrimaryKey: boolean;
|
|
72
|
+
name: ColumnName;
|
|
73
|
+
nullable: boolean;
|
|
74
|
+
schema: SchemaName;
|
|
75
|
+
table: TableName;
|
|
76
|
+
fkSchema: SchemaName | null;
|
|
77
|
+
fkColumn: ColumnName | null;
|
|
78
|
+
fkTable: TableName | null;
|
|
79
|
+
}
|
|
80
|
+
interface DataType {
|
|
81
|
+
/**
|
|
82
|
+
* A simplification/normalization for UI usage.
|
|
83
|
+
*
|
|
84
|
+
* e.g. varchar and char are strings.
|
|
85
|
+
*/
|
|
86
|
+
group: DataTypeGroup;
|
|
87
|
+
/**
|
|
88
|
+
* Is this a native array type?
|
|
89
|
+
*/
|
|
90
|
+
isArray: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Is a native database datatype or a user-defined datatype?
|
|
93
|
+
*
|
|
94
|
+
* e.g. PostgreSQL enums are user-defined datatypes, but `int4` is a native datatype.
|
|
95
|
+
*/
|
|
96
|
+
isNative: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Will be displayed as-is.
|
|
99
|
+
*/
|
|
100
|
+
name: string;
|
|
101
|
+
/**
|
|
102
|
+
* Enum values for enum types.
|
|
103
|
+
*/
|
|
104
|
+
options: string[];
|
|
105
|
+
/**
|
|
106
|
+
* The schema the datatype belongs to.
|
|
107
|
+
*/
|
|
108
|
+
schema: string;
|
|
109
|
+
}
|
|
110
|
+
type DataTypeGroup = "string" | "datetime" | "boolean" | "enum" | "time" | "raw" | "numeric" | "json";
|
|
111
|
+
interface AdapterQueryDetails {
|
|
112
|
+
/**
|
|
113
|
+
* Zero-based index of the page to fetch.
|
|
114
|
+
*/
|
|
115
|
+
pageIndex: number;
|
|
116
|
+
/**
|
|
117
|
+
* Maximum number of rows to fetch from the database.
|
|
118
|
+
*/
|
|
119
|
+
pageSize: number;
|
|
120
|
+
/**
|
|
121
|
+
* Sort order for the query.
|
|
122
|
+
*/
|
|
123
|
+
sortOrder: SortOrderItem[];
|
|
124
|
+
/**
|
|
125
|
+
* The table to select from.
|
|
126
|
+
*/
|
|
127
|
+
table: Table;
|
|
128
|
+
/**
|
|
129
|
+
* The filter to be applied.
|
|
130
|
+
*/
|
|
131
|
+
filter?: FilterGroup;
|
|
132
|
+
}
|
|
133
|
+
type FilterOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "is" | "is not" | "like" | "not like" | "ilike" | "not ilike";
|
|
134
|
+
interface ColumnFilter {
|
|
135
|
+
kind: "ColumnFilter";
|
|
136
|
+
column: string;
|
|
137
|
+
operator: FilterOperator;
|
|
138
|
+
value: unknown;
|
|
139
|
+
after: "and" | "or";
|
|
140
|
+
id: string;
|
|
141
|
+
}
|
|
142
|
+
interface FilterGroup {
|
|
143
|
+
kind: "FilterGroup";
|
|
144
|
+
filters: (ColumnFilter | FilterGroup)[];
|
|
145
|
+
after: "and" | "or";
|
|
146
|
+
id: string;
|
|
147
|
+
}
|
|
148
|
+
interface SortOrderItem {
|
|
149
|
+
/**
|
|
150
|
+
* The column to sort by.
|
|
151
|
+
*/
|
|
152
|
+
column: ColumnName;
|
|
153
|
+
/**
|
|
154
|
+
* The direction to sort the column by.
|
|
155
|
+
*/
|
|
156
|
+
direction: SortDirection;
|
|
157
|
+
}
|
|
158
|
+
type SortDirection = "asc" | "desc";
|
|
159
|
+
declare class AdapterError extends Error {
|
|
160
|
+
query?: Query;
|
|
161
|
+
}
|
|
162
|
+
interface AdapterQueryResult {
|
|
163
|
+
/**
|
|
164
|
+
* The total number of rows the query would return if not limited.
|
|
165
|
+
*
|
|
166
|
+
* If the database does not support counting rows, this should be set to `Infinity`.
|
|
167
|
+
*/
|
|
168
|
+
filteredRowCount: number | bigint | NumericString | BigIntString;
|
|
169
|
+
/**
|
|
170
|
+
* The rows returned by the query.
|
|
171
|
+
*/
|
|
172
|
+
rows: Record<ColumnName, unknown>[];
|
|
173
|
+
/**
|
|
174
|
+
* The executed query string.
|
|
175
|
+
*/
|
|
176
|
+
query: Query;
|
|
177
|
+
}
|
|
178
|
+
interface AdapterInsertDetails {
|
|
179
|
+
/**
|
|
180
|
+
* The table to insert into.
|
|
181
|
+
*/
|
|
182
|
+
table: Table;
|
|
183
|
+
/**
|
|
184
|
+
* The values to insert into the table.
|
|
185
|
+
* - The keys should match the column names in the table.
|
|
186
|
+
* - The values should be the values to insert into the table.
|
|
187
|
+
*/
|
|
188
|
+
rows: Record<string, unknown>[];
|
|
189
|
+
}
|
|
190
|
+
interface AdapterInsertResult {
|
|
191
|
+
/**
|
|
192
|
+
* The freshly inserted row data.
|
|
193
|
+
*/
|
|
194
|
+
rows: Record<string, unknown>[];
|
|
195
|
+
/**
|
|
196
|
+
* The executed query string.
|
|
197
|
+
*/
|
|
198
|
+
query: Query;
|
|
199
|
+
}
|
|
200
|
+
interface AdapterUpdateDetails {
|
|
201
|
+
/**
|
|
202
|
+
* Changes to apply to the row.
|
|
203
|
+
*/
|
|
204
|
+
changes: Record<ColumnName, unknown>;
|
|
205
|
+
/**
|
|
206
|
+
* The row to update.
|
|
207
|
+
*/
|
|
208
|
+
row: Record<ColumnName, unknown>;
|
|
209
|
+
/**
|
|
210
|
+
* The table to update in.
|
|
211
|
+
*/
|
|
212
|
+
table: Table;
|
|
213
|
+
}
|
|
214
|
+
interface AdapterUpdateResult {
|
|
215
|
+
/**
|
|
216
|
+
* The updated row data.
|
|
217
|
+
*/
|
|
218
|
+
row: Record<ColumnName, unknown> & {
|
|
219
|
+
/**
|
|
220
|
+
* When the changes were applied in database time.
|
|
221
|
+
*/
|
|
222
|
+
__ps_updated_at__: string | number | Date;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* The executed query string.
|
|
226
|
+
*/
|
|
227
|
+
query: Query;
|
|
228
|
+
}
|
|
229
|
+
interface AdapterDeleteDetails {
|
|
230
|
+
/**
|
|
231
|
+
* The rows to delete.
|
|
232
|
+
*/
|
|
233
|
+
rows: Record<ColumnName, unknown>[];
|
|
234
|
+
/**
|
|
235
|
+
* The table to delete from.
|
|
236
|
+
*/
|
|
237
|
+
table: Table;
|
|
238
|
+
}
|
|
239
|
+
interface AdapterDeleteResult {
|
|
240
|
+
rows: Record<ColumnName, unknown>[];
|
|
241
|
+
/**
|
|
242
|
+
* The executed query string.
|
|
243
|
+
*/
|
|
244
|
+
query: Query;
|
|
245
|
+
}
|
|
246
|
+
declare function createAdapterError(args: {
|
|
247
|
+
error: Error;
|
|
248
|
+
query?: Query;
|
|
249
|
+
}): [AdapterError];
|
|
250
|
+
|
|
251
|
+
interface BuilderRequirements {
|
|
252
|
+
Adapter: {
|
|
253
|
+
new (): DialectAdapter;
|
|
254
|
+
};
|
|
255
|
+
noParameters?: boolean;
|
|
256
|
+
QueryCompiler: {
|
|
257
|
+
new (): QueryCompiler;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
declare const queryType: unique symbol;
|
|
261
|
+
interface Query<T = unknown> {
|
|
262
|
+
[queryType]?: T;
|
|
263
|
+
parameters: readonly unknown[];
|
|
264
|
+
sql: string;
|
|
265
|
+
}
|
|
266
|
+
type QueryResult<T> = T extends Query<infer R> ? R[] : T extends (...args: any[]) => Query<infer R> ? R[] : never;
|
|
267
|
+
/**
|
|
268
|
+
* Applies a filter to the given rows based on the primary key columns of the table.
|
|
269
|
+
*
|
|
270
|
+
* @example db.selectFrom("users").$call(applyInferredRowFilters(rows, columns)).selectAll()
|
|
271
|
+
*/
|
|
272
|
+
declare function applyInferredRowFilters(rows: Record<string, unknown>[], columns: Table["columns"]): <QB extends WhereInterface<any, any>>(qb: QB) => QB;
|
|
273
|
+
/**
|
|
274
|
+
* Part of a filter that predicts a match.
|
|
275
|
+
* ie. ... WHERE $ColumName = $Value ...
|
|
276
|
+
*/
|
|
277
|
+
type RowFilterPredicate = [ColumnName: string, Value: unknown];
|
|
278
|
+
/**
|
|
279
|
+
* A row filter is comprised of one or more predicates.
|
|
280
|
+
*/
|
|
281
|
+
type RowFilter = RowFilterPredicate[];
|
|
282
|
+
/**
|
|
283
|
+
* Infers the filter that is necessary to uniquely identify a given row
|
|
284
|
+
* individually.
|
|
285
|
+
*/
|
|
286
|
+
declare function inferRowFilter(row: Record<string, unknown>, columns: Table["columns"]): RowFilter;
|
|
287
|
+
|
|
288
|
+
export { type Adapter as A, type BuilderRequirements as B, type Column as C, type DataType as D, type Either as E, type FilterOperator as F, type NumericString as N, type Query as Q, type Schema as S, type Table as T, type QueryResult as a, AdapterError as b, type AdapterInsertDetails as c, type AdapterQueryDetails as d, type AdapterUpdateDetails as e, type AdapterDeleteDetails as f, applyInferredRowFilters as g, type AdapterBaseOptions as h, inferRowFilter as i, type AdapterIntrospectOptions as j, type AdapterQueryOptions as k, type AdapterInsertOptions as l, type AdapterUpdateOptions as m, type AdapterDeleteOptions as n, type AdapterIntrospectResult as o, type DataTypeGroup as p, type ColumnFilter as q, type FilterGroup as r, type SortOrderItem as s, type SortDirection as t, type AdapterQueryResult as u, type AdapterInsertResult as v, type AdapterUpdateResult as w, type AdapterDeleteResult as x, createAdapterError as y, type BigIntString as z };
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { WhereInterface, DialectAdapter, QueryCompiler } from 'kysely';
|
|
2
|
+
|
|
3
|
+
type Either<E, R> = [E] | [null, R];
|
|
4
|
+
type NumericString = `${number}`;
|
|
5
|
+
type BigIntString = `${bigint}`;
|
|
6
|
+
|
|
7
|
+
interface Adapter {
|
|
8
|
+
/**
|
|
9
|
+
* The schema studio will choose by default.
|
|
10
|
+
*
|
|
11
|
+
* e.g. `public` for PostgreSQL
|
|
12
|
+
*/
|
|
13
|
+
readonly defaultSchema?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Introspects the database and returns structured information about the schemas, tables, etc.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Options for the introspection request.
|
|
18
|
+
*/
|
|
19
|
+
introspect(options: AdapterIntrospectOptions): Promise<Either<AdapterError, AdapterIntrospectResult>>;
|
|
20
|
+
/**
|
|
21
|
+
* Executes a structured query against the database.
|
|
22
|
+
*/
|
|
23
|
+
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<AdapterError, AdapterQueryResult>>;
|
|
24
|
+
/**
|
|
25
|
+
* Inserts a single row into the database.
|
|
26
|
+
*/
|
|
27
|
+
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<AdapterError, AdapterInsertResult>>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates a given row in the database with given changes.
|
|
30
|
+
*/
|
|
31
|
+
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<AdapterError, AdapterUpdateResult>>;
|
|
32
|
+
/**
|
|
33
|
+
* Deletes given rows from the database.
|
|
34
|
+
*/
|
|
35
|
+
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<AdapterError, AdapterDeleteResult>>;
|
|
36
|
+
}
|
|
37
|
+
interface AdapterBaseOptions {
|
|
38
|
+
}
|
|
39
|
+
interface AdapterIntrospectOptions extends AdapterBaseOptions {
|
|
40
|
+
}
|
|
41
|
+
interface AdapterQueryOptions extends AdapterBaseOptions {
|
|
42
|
+
abortSignal: AbortSignal;
|
|
43
|
+
}
|
|
44
|
+
interface AdapterInsertOptions extends AdapterBaseOptions {
|
|
45
|
+
}
|
|
46
|
+
interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
47
|
+
}
|
|
48
|
+
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
49
|
+
}
|
|
50
|
+
type SchemaName = string;
|
|
51
|
+
interface AdapterIntrospectResult {
|
|
52
|
+
schemas: Record<SchemaName, Schema>;
|
|
53
|
+
timezone: string;
|
|
54
|
+
filterOperators: FilterOperator[];
|
|
55
|
+
query: Query;
|
|
56
|
+
}
|
|
57
|
+
type TableName = string;
|
|
58
|
+
interface Schema {
|
|
59
|
+
name: string;
|
|
60
|
+
tables: Record<TableName, Table>;
|
|
61
|
+
}
|
|
62
|
+
type ColumnName = string;
|
|
63
|
+
interface Table {
|
|
64
|
+
columns: Record<ColumnName, Column>;
|
|
65
|
+
name: TableName;
|
|
66
|
+
schema: SchemaName;
|
|
67
|
+
}
|
|
68
|
+
interface Column {
|
|
69
|
+
datatype: DataType;
|
|
70
|
+
isComputed: boolean;
|
|
71
|
+
isInPrimaryKey: boolean;
|
|
72
|
+
name: ColumnName;
|
|
73
|
+
nullable: boolean;
|
|
74
|
+
schema: SchemaName;
|
|
75
|
+
table: TableName;
|
|
76
|
+
fkSchema: SchemaName | null;
|
|
77
|
+
fkColumn: ColumnName | null;
|
|
78
|
+
fkTable: TableName | null;
|
|
79
|
+
}
|
|
80
|
+
interface DataType {
|
|
81
|
+
/**
|
|
82
|
+
* A simplification/normalization for UI usage.
|
|
83
|
+
*
|
|
84
|
+
* e.g. varchar and char are strings.
|
|
85
|
+
*/
|
|
86
|
+
group: DataTypeGroup;
|
|
87
|
+
/**
|
|
88
|
+
* Is this a native array type?
|
|
89
|
+
*/
|
|
90
|
+
isArray: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Is a native database datatype or a user-defined datatype?
|
|
93
|
+
*
|
|
94
|
+
* e.g. PostgreSQL enums are user-defined datatypes, but `int4` is a native datatype.
|
|
95
|
+
*/
|
|
96
|
+
isNative: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Will be displayed as-is.
|
|
99
|
+
*/
|
|
100
|
+
name: string;
|
|
101
|
+
/**
|
|
102
|
+
* Enum values for enum types.
|
|
103
|
+
*/
|
|
104
|
+
options: string[];
|
|
105
|
+
/**
|
|
106
|
+
* The schema the datatype belongs to.
|
|
107
|
+
*/
|
|
108
|
+
schema: string;
|
|
109
|
+
}
|
|
110
|
+
type DataTypeGroup = "string" | "datetime" | "boolean" | "enum" | "time" | "raw" | "numeric" | "json";
|
|
111
|
+
interface AdapterQueryDetails {
|
|
112
|
+
/**
|
|
113
|
+
* Zero-based index of the page to fetch.
|
|
114
|
+
*/
|
|
115
|
+
pageIndex: number;
|
|
116
|
+
/**
|
|
117
|
+
* Maximum number of rows to fetch from the database.
|
|
118
|
+
*/
|
|
119
|
+
pageSize: number;
|
|
120
|
+
/**
|
|
121
|
+
* Sort order for the query.
|
|
122
|
+
*/
|
|
123
|
+
sortOrder: SortOrderItem[];
|
|
124
|
+
/**
|
|
125
|
+
* The table to select from.
|
|
126
|
+
*/
|
|
127
|
+
table: Table;
|
|
128
|
+
/**
|
|
129
|
+
* The filter to be applied.
|
|
130
|
+
*/
|
|
131
|
+
filter?: FilterGroup;
|
|
132
|
+
}
|
|
133
|
+
type FilterOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "is" | "is not" | "like" | "not like" | "ilike" | "not ilike";
|
|
134
|
+
interface ColumnFilter {
|
|
135
|
+
kind: "ColumnFilter";
|
|
136
|
+
column: string;
|
|
137
|
+
operator: FilterOperator;
|
|
138
|
+
value: unknown;
|
|
139
|
+
after: "and" | "or";
|
|
140
|
+
id: string;
|
|
141
|
+
}
|
|
142
|
+
interface FilterGroup {
|
|
143
|
+
kind: "FilterGroup";
|
|
144
|
+
filters: (ColumnFilter | FilterGroup)[];
|
|
145
|
+
after: "and" | "or";
|
|
146
|
+
id: string;
|
|
147
|
+
}
|
|
148
|
+
interface SortOrderItem {
|
|
149
|
+
/**
|
|
150
|
+
* The column to sort by.
|
|
151
|
+
*/
|
|
152
|
+
column: ColumnName;
|
|
153
|
+
/**
|
|
154
|
+
* The direction to sort the column by.
|
|
155
|
+
*/
|
|
156
|
+
direction: SortDirection;
|
|
157
|
+
}
|
|
158
|
+
type SortDirection = "asc" | "desc";
|
|
159
|
+
declare class AdapterError extends Error {
|
|
160
|
+
query?: Query;
|
|
161
|
+
}
|
|
162
|
+
interface AdapterQueryResult {
|
|
163
|
+
/**
|
|
164
|
+
* The total number of rows the query would return if not limited.
|
|
165
|
+
*
|
|
166
|
+
* If the database does not support counting rows, this should be set to `Infinity`.
|
|
167
|
+
*/
|
|
168
|
+
filteredRowCount: number | bigint | NumericString | BigIntString;
|
|
169
|
+
/**
|
|
170
|
+
* The rows returned by the query.
|
|
171
|
+
*/
|
|
172
|
+
rows: Record<ColumnName, unknown>[];
|
|
173
|
+
/**
|
|
174
|
+
* The executed query string.
|
|
175
|
+
*/
|
|
176
|
+
query: Query;
|
|
177
|
+
}
|
|
178
|
+
interface AdapterInsertDetails {
|
|
179
|
+
/**
|
|
180
|
+
* The table to insert into.
|
|
181
|
+
*/
|
|
182
|
+
table: Table;
|
|
183
|
+
/**
|
|
184
|
+
* The values to insert into the table.
|
|
185
|
+
* - The keys should match the column names in the table.
|
|
186
|
+
* - The values should be the values to insert into the table.
|
|
187
|
+
*/
|
|
188
|
+
rows: Record<string, unknown>[];
|
|
189
|
+
}
|
|
190
|
+
interface AdapterInsertResult {
|
|
191
|
+
/**
|
|
192
|
+
* The freshly inserted row data.
|
|
193
|
+
*/
|
|
194
|
+
rows: Record<string, unknown>[];
|
|
195
|
+
/**
|
|
196
|
+
* The executed query string.
|
|
197
|
+
*/
|
|
198
|
+
query: Query;
|
|
199
|
+
}
|
|
200
|
+
interface AdapterUpdateDetails {
|
|
201
|
+
/**
|
|
202
|
+
* Changes to apply to the row.
|
|
203
|
+
*/
|
|
204
|
+
changes: Record<ColumnName, unknown>;
|
|
205
|
+
/**
|
|
206
|
+
* The row to update.
|
|
207
|
+
*/
|
|
208
|
+
row: Record<ColumnName, unknown>;
|
|
209
|
+
/**
|
|
210
|
+
* The table to update in.
|
|
211
|
+
*/
|
|
212
|
+
table: Table;
|
|
213
|
+
}
|
|
214
|
+
interface AdapterUpdateResult {
|
|
215
|
+
/**
|
|
216
|
+
* The updated row data.
|
|
217
|
+
*/
|
|
218
|
+
row: Record<ColumnName, unknown> & {
|
|
219
|
+
/**
|
|
220
|
+
* When the changes were applied in database time.
|
|
221
|
+
*/
|
|
222
|
+
__ps_updated_at__: string | number | Date;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* The executed query string.
|
|
226
|
+
*/
|
|
227
|
+
query: Query;
|
|
228
|
+
}
|
|
229
|
+
interface AdapterDeleteDetails {
|
|
230
|
+
/**
|
|
231
|
+
* The rows to delete.
|
|
232
|
+
*/
|
|
233
|
+
rows: Record<ColumnName, unknown>[];
|
|
234
|
+
/**
|
|
235
|
+
* The table to delete from.
|
|
236
|
+
*/
|
|
237
|
+
table: Table;
|
|
238
|
+
}
|
|
239
|
+
interface AdapterDeleteResult {
|
|
240
|
+
rows: Record<ColumnName, unknown>[];
|
|
241
|
+
/**
|
|
242
|
+
* The executed query string.
|
|
243
|
+
*/
|
|
244
|
+
query: Query;
|
|
245
|
+
}
|
|
246
|
+
declare function createAdapterError(args: {
|
|
247
|
+
error: Error;
|
|
248
|
+
query?: Query;
|
|
249
|
+
}): [AdapterError];
|
|
250
|
+
|
|
251
|
+
interface BuilderRequirements {
|
|
252
|
+
Adapter: {
|
|
253
|
+
new (): DialectAdapter;
|
|
254
|
+
};
|
|
255
|
+
noParameters?: boolean;
|
|
256
|
+
QueryCompiler: {
|
|
257
|
+
new (): QueryCompiler;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
declare const queryType: unique symbol;
|
|
261
|
+
interface Query<T = unknown> {
|
|
262
|
+
[queryType]?: T;
|
|
263
|
+
parameters: readonly unknown[];
|
|
264
|
+
sql: string;
|
|
265
|
+
}
|
|
266
|
+
type QueryResult<T> = T extends Query<infer R> ? R[] : T extends (...args: any[]) => Query<infer R> ? R[] : never;
|
|
267
|
+
/**
|
|
268
|
+
* Applies a filter to the given rows based on the primary key columns of the table.
|
|
269
|
+
*
|
|
270
|
+
* @example db.selectFrom("users").$call(applyInferredRowFilters(rows, columns)).selectAll()
|
|
271
|
+
*/
|
|
272
|
+
declare function applyInferredRowFilters(rows: Record<string, unknown>[], columns: Table["columns"]): <QB extends WhereInterface<any, any>>(qb: QB) => QB;
|
|
273
|
+
/**
|
|
274
|
+
* Part of a filter that predicts a match.
|
|
275
|
+
* ie. ... WHERE $ColumName = $Value ...
|
|
276
|
+
*/
|
|
277
|
+
type RowFilterPredicate = [ColumnName: string, Value: unknown];
|
|
278
|
+
/**
|
|
279
|
+
* A row filter is comprised of one or more predicates.
|
|
280
|
+
*/
|
|
281
|
+
type RowFilter = RowFilterPredicate[];
|
|
282
|
+
/**
|
|
283
|
+
* Infers the filter that is necessary to uniquely identify a given row
|
|
284
|
+
* individually.
|
|
285
|
+
*/
|
|
286
|
+
declare function inferRowFilter(row: Record<string, unknown>, columns: Table["columns"]): RowFilter;
|
|
287
|
+
|
|
288
|
+
export { type Adapter as A, type BuilderRequirements as B, type Column as C, type DataType as D, type Either as E, type FilterOperator as F, type NumericString as N, type Query as Q, type Schema as S, type Table as T, type QueryResult as a, AdapterError as b, type AdapterInsertDetails as c, type AdapterQueryDetails as d, type AdapterUpdateDetails as e, type AdapterDeleteDetails as f, applyInferredRowFilters as g, type AdapterBaseOptions as h, inferRowFilter as i, type AdapterIntrospectOptions as j, type AdapterQueryOptions as k, type AdapterInsertOptions as l, type AdapterUpdateOptions as m, type AdapterDeleteOptions as n, type AdapterIntrospectResult as o, type DataTypeGroup as p, type ColumnFilter as q, type FilterGroup as r, type SortOrderItem as s, type SortDirection as t, type AdapterQueryResult as u, type AdapterInsertResult as v, type AdapterUpdateResult as w, type AdapterDeleteResult as x, createAdapterError as y, type BigIntString as z };
|