@prisma/studio-core 0.2.0 → 0.2.2
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-O6LRAFT5.js +10 -0
- package/dist/chunk-P5LRZ6C2.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 +2 -2
- package/dist/data/pglite/index.d.ts +2 -2
- 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 +80 -20
- package/dist/data/postgres-core/index.d.ts +80 -20
- 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/{adapter-CKFCHq71.d.cts → query-Q-ZKX_Vr.d.cts} +94 -7
- package/dist/{adapter-CKFCHq71.d.ts → query-Q-ZKX_Vr.d.ts} +94 -7
- package/dist/ui/index.cjs +258 -1370
- package/dist/ui/index.css +1234 -700
- package/dist/ui/index.d.cts +69 -3
- package/dist/ui/index.d.ts +69 -3
- package/dist/ui/index.js +267 -42
- package/package.json +36 -32
- package/dist/CPIOZS5X-V4BHP4CI.js +0 -1
- package/dist/OKF6E45R-XYOIK2NY.js +0 -1
- package/dist/chunk-2ZJZX5I7.js +0 -0
- package/dist/chunk-5MNS4IJC.js +0 -1332
- package/dist/chunk-BMVJYUJW.js +0 -1
- package/dist/chunk-N2MLAUEV.js +0 -1
- package/dist/chunk-P72NBTYE.js +0 -1
- package/dist/chunk-XS52QRY2.js +0 -1
- package/dist/index-BDPv5Gnt.d.ts +0 -48
- package/dist/index-BNAA6jKD.d.cts +0 -48
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { WhereInterface, DialectAdapter, QueryCompiler } from 'kysely';
|
|
2
|
+
|
|
1
3
|
type Either<E, R> = [E] | [null, R];
|
|
2
4
|
type NumericString = `${number}`;
|
|
3
5
|
type BigIntString = `${bigint}`;
|
|
@@ -14,23 +16,23 @@ interface Adapter {
|
|
|
14
16
|
*
|
|
15
17
|
* @param options - Options for the introspection request.
|
|
16
18
|
*/
|
|
17
|
-
introspect(options: AdapterIntrospectOptions): Promise<Either<
|
|
19
|
+
introspect(options: AdapterIntrospectOptions): Promise<Either<AdapterError, AdapterIntrospectResult>>;
|
|
18
20
|
/**
|
|
19
21
|
* Executes a structured query against the database.
|
|
20
22
|
*/
|
|
21
|
-
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<
|
|
23
|
+
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<AdapterError, AdapterQueryResult>>;
|
|
22
24
|
/**
|
|
23
25
|
* Inserts a single row into the database.
|
|
24
26
|
*/
|
|
25
|
-
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<
|
|
27
|
+
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<AdapterError, AdapterInsertResult>>;
|
|
26
28
|
/**
|
|
27
29
|
* Updates a given row in the database with given changes.
|
|
28
30
|
*/
|
|
29
|
-
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<
|
|
31
|
+
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<AdapterError, AdapterUpdateResult>>;
|
|
30
32
|
/**
|
|
31
33
|
* Deletes given rows from the database.
|
|
32
34
|
*/
|
|
33
|
-
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<
|
|
35
|
+
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<AdapterError, AdapterDeleteResult>>;
|
|
34
36
|
}
|
|
35
37
|
interface AdapterBaseOptions {
|
|
36
38
|
}
|
|
@@ -46,12 +48,15 @@ interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
|
46
48
|
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
47
49
|
}
|
|
48
50
|
type SchemaName = string;
|
|
49
|
-
interface
|
|
51
|
+
interface AdapterIntrospectResult {
|
|
50
52
|
schemas: Record<SchemaName, Schema>;
|
|
51
53
|
timezone: string;
|
|
54
|
+
filterOperators: FilterOperator[];
|
|
55
|
+
query: Query;
|
|
52
56
|
}
|
|
53
57
|
type TableName = string;
|
|
54
58
|
interface Schema {
|
|
59
|
+
name: string;
|
|
55
60
|
tables: Record<TableName, Table>;
|
|
56
61
|
}
|
|
57
62
|
type ColumnName = string;
|
|
@@ -68,6 +73,9 @@ interface Column {
|
|
|
68
73
|
nullable: boolean;
|
|
69
74
|
schema: SchemaName;
|
|
70
75
|
table: TableName;
|
|
76
|
+
fkSchema: SchemaName | null;
|
|
77
|
+
fkColumn: ColumnName | null;
|
|
78
|
+
fkTable: TableName | null;
|
|
71
79
|
}
|
|
72
80
|
interface DataType {
|
|
73
81
|
/**
|
|
@@ -117,6 +125,25 @@ interface AdapterQueryDetails {
|
|
|
117
125
|
* The table to select from.
|
|
118
126
|
*/
|
|
119
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;
|
|
120
147
|
}
|
|
121
148
|
interface SortOrderItem {
|
|
122
149
|
/**
|
|
@@ -129,6 +156,9 @@ interface SortOrderItem {
|
|
|
129
156
|
direction: SortDirection;
|
|
130
157
|
}
|
|
131
158
|
type SortDirection = "asc" | "desc";
|
|
159
|
+
declare class AdapterError extends Error {
|
|
160
|
+
query?: Query;
|
|
161
|
+
}
|
|
132
162
|
interface AdapterQueryResult {
|
|
133
163
|
/**
|
|
134
164
|
* The total number of rows the query would return if not limited.
|
|
@@ -140,6 +170,10 @@ interface AdapterQueryResult {
|
|
|
140
170
|
* The rows returned by the query.
|
|
141
171
|
*/
|
|
142
172
|
rows: Record<ColumnName, unknown>[];
|
|
173
|
+
/**
|
|
174
|
+
* The executed query string.
|
|
175
|
+
*/
|
|
176
|
+
query: Query;
|
|
143
177
|
}
|
|
144
178
|
interface AdapterInsertDetails {
|
|
145
179
|
/**
|
|
@@ -158,6 +192,10 @@ interface AdapterInsertResult {
|
|
|
158
192
|
* The freshly inserted row data.
|
|
159
193
|
*/
|
|
160
194
|
rows: Record<string, unknown>[];
|
|
195
|
+
/**
|
|
196
|
+
* The executed query string.
|
|
197
|
+
*/
|
|
198
|
+
query: Query;
|
|
161
199
|
}
|
|
162
200
|
interface AdapterUpdateDetails {
|
|
163
201
|
/**
|
|
@@ -183,6 +221,10 @@ interface AdapterUpdateResult {
|
|
|
183
221
|
*/
|
|
184
222
|
__ps_updated_at__: string | number | Date;
|
|
185
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* The executed query string.
|
|
226
|
+
*/
|
|
227
|
+
query: Query;
|
|
186
228
|
}
|
|
187
229
|
interface AdapterDeleteDetails {
|
|
188
230
|
/**
|
|
@@ -196,6 +238,51 @@ interface AdapterDeleteDetails {
|
|
|
196
238
|
}
|
|
197
239
|
interface AdapterDeleteResult {
|
|
198
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;
|
|
199
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;
|
|
200
287
|
|
|
201
|
-
export type
|
|
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 };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { WhereInterface, DialectAdapter, QueryCompiler } from 'kysely';
|
|
2
|
+
|
|
1
3
|
type Either<E, R> = [E] | [null, R];
|
|
2
4
|
type NumericString = `${number}`;
|
|
3
5
|
type BigIntString = `${bigint}`;
|
|
@@ -14,23 +16,23 @@ interface Adapter {
|
|
|
14
16
|
*
|
|
15
17
|
* @param options - Options for the introspection request.
|
|
16
18
|
*/
|
|
17
|
-
introspect(options: AdapterIntrospectOptions): Promise<Either<
|
|
19
|
+
introspect(options: AdapterIntrospectOptions): Promise<Either<AdapterError, AdapterIntrospectResult>>;
|
|
18
20
|
/**
|
|
19
21
|
* Executes a structured query against the database.
|
|
20
22
|
*/
|
|
21
|
-
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<
|
|
23
|
+
query(details: AdapterQueryDetails, options: AdapterQueryOptions): Promise<Either<AdapterError, AdapterQueryResult>>;
|
|
22
24
|
/**
|
|
23
25
|
* Inserts a single row into the database.
|
|
24
26
|
*/
|
|
25
|
-
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<
|
|
27
|
+
insert(details: AdapterInsertDetails, options: AdapterInsertOptions): Promise<Either<AdapterError, AdapterInsertResult>>;
|
|
26
28
|
/**
|
|
27
29
|
* Updates a given row in the database with given changes.
|
|
28
30
|
*/
|
|
29
|
-
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<
|
|
31
|
+
update(details: AdapterUpdateDetails, options: AdapterUpdateOptions): Promise<Either<AdapterError, AdapterUpdateResult>>;
|
|
30
32
|
/**
|
|
31
33
|
* Deletes given rows from the database.
|
|
32
34
|
*/
|
|
33
|
-
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<
|
|
35
|
+
delete(details: AdapterDeleteDetails, options: AdapterDeleteOptions): Promise<Either<AdapterError, AdapterDeleteResult>>;
|
|
34
36
|
}
|
|
35
37
|
interface AdapterBaseOptions {
|
|
36
38
|
}
|
|
@@ -46,12 +48,15 @@ interface AdapterUpdateOptions extends AdapterBaseOptions {
|
|
|
46
48
|
interface AdapterDeleteOptions extends AdapterBaseOptions {
|
|
47
49
|
}
|
|
48
50
|
type SchemaName = string;
|
|
49
|
-
interface
|
|
51
|
+
interface AdapterIntrospectResult {
|
|
50
52
|
schemas: Record<SchemaName, Schema>;
|
|
51
53
|
timezone: string;
|
|
54
|
+
filterOperators: FilterOperator[];
|
|
55
|
+
query: Query;
|
|
52
56
|
}
|
|
53
57
|
type TableName = string;
|
|
54
58
|
interface Schema {
|
|
59
|
+
name: string;
|
|
55
60
|
tables: Record<TableName, Table>;
|
|
56
61
|
}
|
|
57
62
|
type ColumnName = string;
|
|
@@ -68,6 +73,9 @@ interface Column {
|
|
|
68
73
|
nullable: boolean;
|
|
69
74
|
schema: SchemaName;
|
|
70
75
|
table: TableName;
|
|
76
|
+
fkSchema: SchemaName | null;
|
|
77
|
+
fkColumn: ColumnName | null;
|
|
78
|
+
fkTable: TableName | null;
|
|
71
79
|
}
|
|
72
80
|
interface DataType {
|
|
73
81
|
/**
|
|
@@ -117,6 +125,25 @@ interface AdapterQueryDetails {
|
|
|
117
125
|
* The table to select from.
|
|
118
126
|
*/
|
|
119
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;
|
|
120
147
|
}
|
|
121
148
|
interface SortOrderItem {
|
|
122
149
|
/**
|
|
@@ -129,6 +156,9 @@ interface SortOrderItem {
|
|
|
129
156
|
direction: SortDirection;
|
|
130
157
|
}
|
|
131
158
|
type SortDirection = "asc" | "desc";
|
|
159
|
+
declare class AdapterError extends Error {
|
|
160
|
+
query?: Query;
|
|
161
|
+
}
|
|
132
162
|
interface AdapterQueryResult {
|
|
133
163
|
/**
|
|
134
164
|
* The total number of rows the query would return if not limited.
|
|
@@ -140,6 +170,10 @@ interface AdapterQueryResult {
|
|
|
140
170
|
* The rows returned by the query.
|
|
141
171
|
*/
|
|
142
172
|
rows: Record<ColumnName, unknown>[];
|
|
173
|
+
/**
|
|
174
|
+
* The executed query string.
|
|
175
|
+
*/
|
|
176
|
+
query: Query;
|
|
143
177
|
}
|
|
144
178
|
interface AdapterInsertDetails {
|
|
145
179
|
/**
|
|
@@ -158,6 +192,10 @@ interface AdapterInsertResult {
|
|
|
158
192
|
* The freshly inserted row data.
|
|
159
193
|
*/
|
|
160
194
|
rows: Record<string, unknown>[];
|
|
195
|
+
/**
|
|
196
|
+
* The executed query string.
|
|
197
|
+
*/
|
|
198
|
+
query: Query;
|
|
161
199
|
}
|
|
162
200
|
interface AdapterUpdateDetails {
|
|
163
201
|
/**
|
|
@@ -183,6 +221,10 @@ interface AdapterUpdateResult {
|
|
|
183
221
|
*/
|
|
184
222
|
__ps_updated_at__: string | number | Date;
|
|
185
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* The executed query string.
|
|
226
|
+
*/
|
|
227
|
+
query: Query;
|
|
186
228
|
}
|
|
187
229
|
interface AdapterDeleteDetails {
|
|
188
230
|
/**
|
|
@@ -196,6 +238,51 @@ interface AdapterDeleteDetails {
|
|
|
196
238
|
}
|
|
197
239
|
interface AdapterDeleteResult {
|
|
198
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;
|
|
199
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;
|
|
200
287
|
|
|
201
|
-
export type
|
|
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 };
|