@prisma/studio-core 0.0.0-dev.202505151603 → 0.0.0-dev.202505160133
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-NVCWH6WH.js +2 -0
- package/dist/data/accelerate/index.d.cts +2 -2
- package/dist/data/accelerate/index.d.ts +2 -2
- package/dist/data/bff/index.d.cts +2 -2
- package/dist/data/bff/index.d.ts +2 -2
- package/dist/data/index.d.cts +11 -2
- package/dist/data/index.d.ts +11 -2
- package/dist/data/pglite/index.cjs +2 -2
- package/dist/data/pglite/index.d.cts +2 -2
- package/dist/data/pglite/index.d.ts +2 -2
- package/dist/data/pglite/index.js +1 -1
- package/dist/data/postgres-core/index.cjs +2 -2
- package/dist/data/postgres-core/index.d.cts +46 -42
- package/dist/data/postgres-core/index.d.ts +46 -42
- package/dist/data/postgres-core/index.js +1 -1
- package/dist/{adapter-Bt_0JnjE.d.cts → query-Q-ZKX_Vr.d.cts} +71 -7
- package/dist/{adapter-Bt_0JnjE.d.ts → query-Q-ZKX_Vr.d.ts} +71 -7
- package/dist/ui/index.cjs +57 -41
- package/dist/ui/index.css +72 -0
- package/dist/ui/index.d.cts +66 -14
- package/dist/ui/index.d.ts +66 -14
- package/dist/ui/index.js +23 -7
- package/package.json +1 -1
- package/dist/chunk-AJWO5DG3.js +0 -2
- package/dist/index-B6_kEBLg.d.ts +0 -48
- package/dist/index-C9ZnIXOd.d.cts +0 -48
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Adapter, T as Table, F as FilterOperator,
|
|
2
|
-
import {
|
|
1
|
+
import { A as Adapter, T as Table, F as FilterOperator, Q as Query, c as AdapterInsertDetails, B as BuilderRequirements, d as AdapterQueryDetails, e as AdapterUpdateDetails, f as AdapterDeleteDetails } from '../../query-Q-ZKX_Vr.cjs';
|
|
2
|
+
import { Executor } from '../index.cjs';
|
|
3
3
|
import * as kysely from 'kysely';
|
|
4
4
|
|
|
5
5
|
interface PostgresAdapterRequirements {
|
|
@@ -11,11 +11,13 @@ declare function createPostgresAdapter(requirements: PostgresAdapterRequirements
|
|
|
11
11
|
* For testing purposes.
|
|
12
12
|
*/
|
|
13
13
|
declare function mockIntrospect(): {
|
|
14
|
-
schemas: { [K in "public"]: {
|
|
15
|
-
|
|
14
|
+
schemas: { [K in "zoo" | "public"]: {
|
|
15
|
+
name: K;
|
|
16
|
+
tables: { [T in "animals" | "users"]: Table; };
|
|
16
17
|
}; };
|
|
17
18
|
timezone: "UTC";
|
|
18
19
|
filterOperators: FilterOperator[];
|
|
20
|
+
query: Query;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -53,6 +55,7 @@ declare function mockSelectQuery(): [{
|
|
|
53
55
|
readonly name: "John Doe";
|
|
54
56
|
readonly oid: "2";
|
|
55
57
|
readonly role: "admin";
|
|
58
|
+
readonly name_role: "Jonn Doe - admin";
|
|
56
59
|
}, {
|
|
57
60
|
readonly created_at: Date;
|
|
58
61
|
readonly ctid: "(0,2)";
|
|
@@ -61,6 +64,7 @@ declare function mockSelectQuery(): [{
|
|
|
61
64
|
readonly name: "Jane Doe";
|
|
62
65
|
readonly oid: "2";
|
|
63
66
|
readonly role: "poweruser";
|
|
67
|
+
readonly name_role: "Jane Doe - poweruser";
|
|
64
68
|
}];
|
|
65
69
|
/**
|
|
66
70
|
* Returns a query that updates a given row in a table with given changes.
|
|
@@ -98,23 +102,23 @@ declare function getTablesQuery(requirements?: Omit<BuilderRequirements, "Adapte
|
|
|
98
102
|
* For testing purposes.
|
|
99
103
|
*/
|
|
100
104
|
declare function mockTablesQuery(): [{
|
|
101
|
-
readonly schema: "
|
|
102
|
-
readonly name: "
|
|
105
|
+
readonly schema: "zoo";
|
|
106
|
+
readonly name: "animals";
|
|
103
107
|
readonly columns: [{
|
|
104
108
|
readonly name: "id";
|
|
105
|
-
readonly datatype: "
|
|
106
|
-
readonly datatype_schema: "
|
|
109
|
+
readonly datatype: "int4";
|
|
110
|
+
readonly datatype_schema: "pg_catalog";
|
|
107
111
|
readonly pk: true;
|
|
108
112
|
readonly computed: false;
|
|
109
113
|
readonly options: [];
|
|
110
|
-
readonly nullable:
|
|
114
|
+
readonly nullable: false;
|
|
111
115
|
readonly foreign_key_schema: null;
|
|
112
116
|
readonly foreign_key_table: null;
|
|
113
117
|
readonly foreign_key_column: null;
|
|
114
118
|
}, {
|
|
115
119
|
readonly name: "name";
|
|
116
|
-
readonly datatype: "
|
|
117
|
-
readonly datatype_schema: "
|
|
120
|
+
readonly datatype: "text";
|
|
121
|
+
readonly datatype_schema: "pg_catalog";
|
|
118
122
|
readonly pk: false;
|
|
119
123
|
readonly computed: false;
|
|
120
124
|
readonly options: [];
|
|
@@ -122,21 +126,25 @@ declare function mockTablesQuery(): [{
|
|
|
122
126
|
readonly foreign_key_schema: null;
|
|
123
127
|
readonly foreign_key_table: null;
|
|
124
128
|
readonly foreign_key_column: null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
}];
|
|
130
|
+
}, {
|
|
131
|
+
readonly schema: "public";
|
|
132
|
+
readonly name: "users";
|
|
133
|
+
readonly columns: [{
|
|
134
|
+
readonly name: "id";
|
|
135
|
+
readonly datatype: "int4";
|
|
136
|
+
readonly datatype_schema: "pg_catalog";
|
|
137
|
+
readonly pk: true;
|
|
130
138
|
readonly computed: false;
|
|
131
|
-
readonly options: [
|
|
132
|
-
readonly nullable:
|
|
139
|
+
readonly options: [];
|
|
140
|
+
readonly nullable: false;
|
|
133
141
|
readonly foreign_key_schema: null;
|
|
134
142
|
readonly foreign_key_table: null;
|
|
135
143
|
readonly foreign_key_column: null;
|
|
136
144
|
}, {
|
|
137
145
|
readonly name: "created_at";
|
|
138
|
-
readonly datatype: "
|
|
139
|
-
readonly datatype_schema: "
|
|
146
|
+
readonly datatype: "timestamp";
|
|
147
|
+
readonly datatype_schema: "pg_catalog";
|
|
140
148
|
readonly pk: false;
|
|
141
149
|
readonly computed: false;
|
|
142
150
|
readonly options: [];
|
|
@@ -146,8 +154,8 @@ declare function mockTablesQuery(): [{
|
|
|
146
154
|
readonly foreign_key_column: null;
|
|
147
155
|
}, {
|
|
148
156
|
readonly name: "deleted_at";
|
|
149
|
-
readonly datatype: "
|
|
150
|
-
readonly datatype_schema: "
|
|
157
|
+
readonly datatype: "timestamp";
|
|
158
|
+
readonly datatype_schema: "pg_catalog";
|
|
151
159
|
readonly pk: false;
|
|
152
160
|
readonly computed: false;
|
|
153
161
|
readonly options: [];
|
|
@@ -155,15 +163,11 @@ declare function mockTablesQuery(): [{
|
|
|
155
163
|
readonly foreign_key_schema: null;
|
|
156
164
|
readonly foreign_key_table: null;
|
|
157
165
|
readonly foreign_key_column: null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
readonly name: "id";
|
|
164
|
-
readonly datatype: "bigint";
|
|
165
|
-
readonly datatype_schema: "public";
|
|
166
|
-
readonly pk: true;
|
|
166
|
+
}, {
|
|
167
|
+
readonly name: "role";
|
|
168
|
+
readonly datatype: "varchar";
|
|
169
|
+
readonly datatype_schema: "pg_catalog";
|
|
170
|
+
readonly pk: false;
|
|
167
171
|
readonly computed: false;
|
|
168
172
|
readonly options: [];
|
|
169
173
|
readonly nullable: true;
|
|
@@ -171,24 +175,24 @@ declare function mockTablesQuery(): [{
|
|
|
171
175
|
readonly foreign_key_table: null;
|
|
172
176
|
readonly foreign_key_column: null;
|
|
173
177
|
}, {
|
|
174
|
-
readonly name: "
|
|
175
|
-
readonly datatype: "
|
|
176
|
-
readonly datatype_schema: "
|
|
178
|
+
readonly name: "name";
|
|
179
|
+
readonly datatype: "varchar";
|
|
180
|
+
readonly datatype_schema: "pg_catalog";
|
|
177
181
|
readonly pk: false;
|
|
178
182
|
readonly computed: false;
|
|
179
183
|
readonly options: [];
|
|
180
|
-
readonly nullable:
|
|
181
|
-
readonly foreign_key_schema:
|
|
182
|
-
readonly foreign_key_table:
|
|
183
|
-
readonly foreign_key_column:
|
|
184
|
+
readonly nullable: true;
|
|
185
|
+
readonly foreign_key_schema: null;
|
|
186
|
+
readonly foreign_key_table: null;
|
|
187
|
+
readonly foreign_key_column: null;
|
|
184
188
|
}, {
|
|
185
|
-
readonly name: "
|
|
189
|
+
readonly name: "name_role";
|
|
186
190
|
readonly datatype: "text";
|
|
187
|
-
readonly datatype_schema: "
|
|
191
|
+
readonly datatype_schema: "pg_catalog";
|
|
188
192
|
readonly pk: false;
|
|
189
|
-
readonly computed:
|
|
193
|
+
readonly computed: true;
|
|
190
194
|
readonly options: [];
|
|
191
|
-
readonly nullable:
|
|
195
|
+
readonly nullable: false;
|
|
192
196
|
readonly foreign_key_schema: null;
|
|
193
197
|
readonly foreign_key_table: null;
|
|
194
198
|
readonly foreign_key_column: null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Adapter, T as Table, F as FilterOperator,
|
|
2
|
-
import {
|
|
1
|
+
import { A as Adapter, T as Table, F as FilterOperator, Q as Query, c as AdapterInsertDetails, B as BuilderRequirements, d as AdapterQueryDetails, e as AdapterUpdateDetails, f as AdapterDeleteDetails } from '../../query-Q-ZKX_Vr.js';
|
|
2
|
+
import { Executor } from '../index.js';
|
|
3
3
|
import * as kysely from 'kysely';
|
|
4
4
|
|
|
5
5
|
interface PostgresAdapterRequirements {
|
|
@@ -11,11 +11,13 @@ declare function createPostgresAdapter(requirements: PostgresAdapterRequirements
|
|
|
11
11
|
* For testing purposes.
|
|
12
12
|
*/
|
|
13
13
|
declare function mockIntrospect(): {
|
|
14
|
-
schemas: { [K in "public"]: {
|
|
15
|
-
|
|
14
|
+
schemas: { [K in "zoo" | "public"]: {
|
|
15
|
+
name: K;
|
|
16
|
+
tables: { [T in "animals" | "users"]: Table; };
|
|
16
17
|
}; };
|
|
17
18
|
timezone: "UTC";
|
|
18
19
|
filterOperators: FilterOperator[];
|
|
20
|
+
query: Query;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -53,6 +55,7 @@ declare function mockSelectQuery(): [{
|
|
|
53
55
|
readonly name: "John Doe";
|
|
54
56
|
readonly oid: "2";
|
|
55
57
|
readonly role: "admin";
|
|
58
|
+
readonly name_role: "Jonn Doe - admin";
|
|
56
59
|
}, {
|
|
57
60
|
readonly created_at: Date;
|
|
58
61
|
readonly ctid: "(0,2)";
|
|
@@ -61,6 +64,7 @@ declare function mockSelectQuery(): [{
|
|
|
61
64
|
readonly name: "Jane Doe";
|
|
62
65
|
readonly oid: "2";
|
|
63
66
|
readonly role: "poweruser";
|
|
67
|
+
readonly name_role: "Jane Doe - poweruser";
|
|
64
68
|
}];
|
|
65
69
|
/**
|
|
66
70
|
* Returns a query that updates a given row in a table with given changes.
|
|
@@ -98,23 +102,23 @@ declare function getTablesQuery(requirements?: Omit<BuilderRequirements, "Adapte
|
|
|
98
102
|
* For testing purposes.
|
|
99
103
|
*/
|
|
100
104
|
declare function mockTablesQuery(): [{
|
|
101
|
-
readonly schema: "
|
|
102
|
-
readonly name: "
|
|
105
|
+
readonly schema: "zoo";
|
|
106
|
+
readonly name: "animals";
|
|
103
107
|
readonly columns: [{
|
|
104
108
|
readonly name: "id";
|
|
105
|
-
readonly datatype: "
|
|
106
|
-
readonly datatype_schema: "
|
|
109
|
+
readonly datatype: "int4";
|
|
110
|
+
readonly datatype_schema: "pg_catalog";
|
|
107
111
|
readonly pk: true;
|
|
108
112
|
readonly computed: false;
|
|
109
113
|
readonly options: [];
|
|
110
|
-
readonly nullable:
|
|
114
|
+
readonly nullable: false;
|
|
111
115
|
readonly foreign_key_schema: null;
|
|
112
116
|
readonly foreign_key_table: null;
|
|
113
117
|
readonly foreign_key_column: null;
|
|
114
118
|
}, {
|
|
115
119
|
readonly name: "name";
|
|
116
|
-
readonly datatype: "
|
|
117
|
-
readonly datatype_schema: "
|
|
120
|
+
readonly datatype: "text";
|
|
121
|
+
readonly datatype_schema: "pg_catalog";
|
|
118
122
|
readonly pk: false;
|
|
119
123
|
readonly computed: false;
|
|
120
124
|
readonly options: [];
|
|
@@ -122,21 +126,25 @@ declare function mockTablesQuery(): [{
|
|
|
122
126
|
readonly foreign_key_schema: null;
|
|
123
127
|
readonly foreign_key_table: null;
|
|
124
128
|
readonly foreign_key_column: null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
}];
|
|
130
|
+
}, {
|
|
131
|
+
readonly schema: "public";
|
|
132
|
+
readonly name: "users";
|
|
133
|
+
readonly columns: [{
|
|
134
|
+
readonly name: "id";
|
|
135
|
+
readonly datatype: "int4";
|
|
136
|
+
readonly datatype_schema: "pg_catalog";
|
|
137
|
+
readonly pk: true;
|
|
130
138
|
readonly computed: false;
|
|
131
|
-
readonly options: [
|
|
132
|
-
readonly nullable:
|
|
139
|
+
readonly options: [];
|
|
140
|
+
readonly nullable: false;
|
|
133
141
|
readonly foreign_key_schema: null;
|
|
134
142
|
readonly foreign_key_table: null;
|
|
135
143
|
readonly foreign_key_column: null;
|
|
136
144
|
}, {
|
|
137
145
|
readonly name: "created_at";
|
|
138
|
-
readonly datatype: "
|
|
139
|
-
readonly datatype_schema: "
|
|
146
|
+
readonly datatype: "timestamp";
|
|
147
|
+
readonly datatype_schema: "pg_catalog";
|
|
140
148
|
readonly pk: false;
|
|
141
149
|
readonly computed: false;
|
|
142
150
|
readonly options: [];
|
|
@@ -146,8 +154,8 @@ declare function mockTablesQuery(): [{
|
|
|
146
154
|
readonly foreign_key_column: null;
|
|
147
155
|
}, {
|
|
148
156
|
readonly name: "deleted_at";
|
|
149
|
-
readonly datatype: "
|
|
150
|
-
readonly datatype_schema: "
|
|
157
|
+
readonly datatype: "timestamp";
|
|
158
|
+
readonly datatype_schema: "pg_catalog";
|
|
151
159
|
readonly pk: false;
|
|
152
160
|
readonly computed: false;
|
|
153
161
|
readonly options: [];
|
|
@@ -155,15 +163,11 @@ declare function mockTablesQuery(): [{
|
|
|
155
163
|
readonly foreign_key_schema: null;
|
|
156
164
|
readonly foreign_key_table: null;
|
|
157
165
|
readonly foreign_key_column: null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
readonly name: "id";
|
|
164
|
-
readonly datatype: "bigint";
|
|
165
|
-
readonly datatype_schema: "public";
|
|
166
|
-
readonly pk: true;
|
|
166
|
+
}, {
|
|
167
|
+
readonly name: "role";
|
|
168
|
+
readonly datatype: "varchar";
|
|
169
|
+
readonly datatype_schema: "pg_catalog";
|
|
170
|
+
readonly pk: false;
|
|
167
171
|
readonly computed: false;
|
|
168
172
|
readonly options: [];
|
|
169
173
|
readonly nullable: true;
|
|
@@ -171,24 +175,24 @@ declare function mockTablesQuery(): [{
|
|
|
171
175
|
readonly foreign_key_table: null;
|
|
172
176
|
readonly foreign_key_column: null;
|
|
173
177
|
}, {
|
|
174
|
-
readonly name: "
|
|
175
|
-
readonly datatype: "
|
|
176
|
-
readonly datatype_schema: "
|
|
178
|
+
readonly name: "name";
|
|
179
|
+
readonly datatype: "varchar";
|
|
180
|
+
readonly datatype_schema: "pg_catalog";
|
|
177
181
|
readonly pk: false;
|
|
178
182
|
readonly computed: false;
|
|
179
183
|
readonly options: [];
|
|
180
|
-
readonly nullable:
|
|
181
|
-
readonly foreign_key_schema:
|
|
182
|
-
readonly foreign_key_table:
|
|
183
|
-
readonly foreign_key_column:
|
|
184
|
+
readonly nullable: true;
|
|
185
|
+
readonly foreign_key_schema: null;
|
|
186
|
+
readonly foreign_key_table: null;
|
|
187
|
+
readonly foreign_key_column: null;
|
|
184
188
|
}, {
|
|
185
|
-
readonly name: "
|
|
189
|
+
readonly name: "name_role";
|
|
186
190
|
readonly datatype: "text";
|
|
187
|
-
readonly datatype_schema: "
|
|
191
|
+
readonly datatype_schema: "pg_catalog";
|
|
188
192
|
readonly pk: false;
|
|
189
|
-
readonly computed:
|
|
193
|
+
readonly computed: true;
|
|
190
194
|
readonly options: [];
|
|
191
|
-
readonly nullable:
|
|
195
|
+
readonly nullable: false;
|
|
192
196
|
readonly foreign_key_schema: null;
|
|
193
197
|
readonly foreign_key_table: null;
|
|
194
198
|
readonly foreign_key_column: null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"../../chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"../../chunk-NVCWH6WH.js";import"../../chunk-OGMDOPWW.js";import"../../chunk-XBQ4XZ2M.js";export{j as createPostgresAdapter,e as getDeleteQuery,a as getInsertQuery,b as getSelectQuery,f as getTablesQuery,h as getTimezoneQuery,d as getUpdateQuery,k as mockIntrospect,c as mockSelectQuery,g as mockTablesQuery,i as mockTimezoneQuery};
|
|
2
2
|
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFtdLAogICJtYXBwaW5ncyI6ICIiLAogICJuYW1lcyI6IFtdCn0K
|
|
@@ -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,13 +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;
|
|
52
54
|
filterOperators: FilterOperator[];
|
|
55
|
+
query: Query;
|
|
53
56
|
}
|
|
54
57
|
type TableName = string;
|
|
55
58
|
interface Schema {
|
|
59
|
+
name: string;
|
|
56
60
|
tables: Record<TableName, Table>;
|
|
57
61
|
}
|
|
58
62
|
type ColumnName = string;
|
|
@@ -152,6 +156,9 @@ interface SortOrderItem {
|
|
|
152
156
|
direction: SortDirection;
|
|
153
157
|
}
|
|
154
158
|
type SortDirection = "asc" | "desc";
|
|
159
|
+
declare class AdapterError extends Error {
|
|
160
|
+
query?: Query;
|
|
161
|
+
}
|
|
155
162
|
interface AdapterQueryResult {
|
|
156
163
|
/**
|
|
157
164
|
* The total number of rows the query would return if not limited.
|
|
@@ -163,6 +170,10 @@ interface AdapterQueryResult {
|
|
|
163
170
|
* The rows returned by the query.
|
|
164
171
|
*/
|
|
165
172
|
rows: Record<ColumnName, unknown>[];
|
|
173
|
+
/**
|
|
174
|
+
* The executed query string.
|
|
175
|
+
*/
|
|
176
|
+
query: Query;
|
|
166
177
|
}
|
|
167
178
|
interface AdapterInsertDetails {
|
|
168
179
|
/**
|
|
@@ -181,6 +192,10 @@ interface AdapterInsertResult {
|
|
|
181
192
|
* The freshly inserted row data.
|
|
182
193
|
*/
|
|
183
194
|
rows: Record<string, unknown>[];
|
|
195
|
+
/**
|
|
196
|
+
* The executed query string.
|
|
197
|
+
*/
|
|
198
|
+
query: Query;
|
|
184
199
|
}
|
|
185
200
|
interface AdapterUpdateDetails {
|
|
186
201
|
/**
|
|
@@ -206,6 +221,10 @@ interface AdapterUpdateResult {
|
|
|
206
221
|
*/
|
|
207
222
|
__ps_updated_at__: string | number | Date;
|
|
208
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* The executed query string.
|
|
226
|
+
*/
|
|
227
|
+
query: Query;
|
|
209
228
|
}
|
|
210
229
|
interface AdapterDeleteDetails {
|
|
211
230
|
/**
|
|
@@ -219,6 +238,51 @@ interface AdapterDeleteDetails {
|
|
|
219
238
|
}
|
|
220
239
|
interface AdapterDeleteResult {
|
|
221
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;
|
|
222
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;
|
|
223
287
|
|
|
224
|
-
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,13 +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;
|
|
52
54
|
filterOperators: FilterOperator[];
|
|
55
|
+
query: Query;
|
|
53
56
|
}
|
|
54
57
|
type TableName = string;
|
|
55
58
|
interface Schema {
|
|
59
|
+
name: string;
|
|
56
60
|
tables: Record<TableName, Table>;
|
|
57
61
|
}
|
|
58
62
|
type ColumnName = string;
|
|
@@ -152,6 +156,9 @@ interface SortOrderItem {
|
|
|
152
156
|
direction: SortDirection;
|
|
153
157
|
}
|
|
154
158
|
type SortDirection = "asc" | "desc";
|
|
159
|
+
declare class AdapterError extends Error {
|
|
160
|
+
query?: Query;
|
|
161
|
+
}
|
|
155
162
|
interface AdapterQueryResult {
|
|
156
163
|
/**
|
|
157
164
|
* The total number of rows the query would return if not limited.
|
|
@@ -163,6 +170,10 @@ interface AdapterQueryResult {
|
|
|
163
170
|
* The rows returned by the query.
|
|
164
171
|
*/
|
|
165
172
|
rows: Record<ColumnName, unknown>[];
|
|
173
|
+
/**
|
|
174
|
+
* The executed query string.
|
|
175
|
+
*/
|
|
176
|
+
query: Query;
|
|
166
177
|
}
|
|
167
178
|
interface AdapterInsertDetails {
|
|
168
179
|
/**
|
|
@@ -181,6 +192,10 @@ interface AdapterInsertResult {
|
|
|
181
192
|
* The freshly inserted row data.
|
|
182
193
|
*/
|
|
183
194
|
rows: Record<string, unknown>[];
|
|
195
|
+
/**
|
|
196
|
+
* The executed query string.
|
|
197
|
+
*/
|
|
198
|
+
query: Query;
|
|
184
199
|
}
|
|
185
200
|
interface AdapterUpdateDetails {
|
|
186
201
|
/**
|
|
@@ -206,6 +221,10 @@ interface AdapterUpdateResult {
|
|
|
206
221
|
*/
|
|
207
222
|
__ps_updated_at__: string | number | Date;
|
|
208
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* The executed query string.
|
|
226
|
+
*/
|
|
227
|
+
query: Query;
|
|
209
228
|
}
|
|
210
229
|
interface AdapterDeleteDetails {
|
|
211
230
|
/**
|
|
@@ -219,6 +238,51 @@ interface AdapterDeleteDetails {
|
|
|
219
238
|
}
|
|
220
239
|
interface AdapterDeleteResult {
|
|
221
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;
|
|
222
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;
|
|
223
287
|
|
|
224
|
-
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 };
|