@mikro-orm/sql 7.0.8 → 7.0.9-dev.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/AbstractSqlConnection.d.ts +58 -94
- package/AbstractSqlConnection.js +238 -235
- package/AbstractSqlDriver.d.ts +155 -410
- package/AbstractSqlDriver.js +1953 -2072
- package/AbstractSqlPlatform.d.ts +75 -85
- package/AbstractSqlPlatform.js +162 -166
- package/PivotCollectionPersister.d.ts +15 -33
- package/PivotCollectionPersister.js +160 -158
- package/README.md +1 -1
- package/SqlEntityManager.d.ts +22 -67
- package/SqlEntityManager.js +38 -54
- package/SqlEntityRepository.d.ts +14 -14
- package/SqlEntityRepository.js +23 -23
- package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -12
- package/dialects/mssql/MsSqlNativeQueryBuilder.js +201 -199
- package/dialects/mysql/BaseMySqlPlatform.d.ts +46 -65
- package/dialects/mysql/BaseMySqlPlatform.js +134 -137
- package/dialects/mysql/MySqlExceptionConverter.d.ts +6 -6
- package/dialects/mysql/MySqlExceptionConverter.js +77 -91
- package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +3 -3
- package/dialects/mysql/MySqlNativeQueryBuilder.js +69 -66
- package/dialects/mysql/MySqlSchemaHelper.d.ts +39 -58
- package/dialects/mysql/MySqlSchemaHelper.js +319 -327
- package/dialects/oracledb/OracleDialect.d.ts +52 -81
- package/dialects/oracledb/OracleDialect.js +149 -155
- package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +12 -12
- package/dialects/oracledb/OracleNativeQueryBuilder.js +243 -239
- package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +106 -109
- package/dialects/postgresql/BasePostgreSqlPlatform.js +353 -354
- package/dialects/postgresql/FullTextType.d.ts +6 -10
- package/dialects/postgresql/FullTextType.js +51 -51
- package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +5 -5
- package/dialects/postgresql/PostgreSqlExceptionConverter.js +43 -55
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +1 -1
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +4 -4
- package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +82 -117
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +711 -747
- package/dialects/sqlite/BaseSqliteConnection.d.ts +5 -3
- package/dialects/sqlite/BaseSqliteConnection.js +19 -21
- package/dialects/sqlite/NodeSqliteDialect.d.ts +1 -1
- package/dialects/sqlite/NodeSqliteDialect.js +23 -23
- package/dialects/sqlite/SqliteDriver.d.ts +1 -1
- package/dialects/sqlite/SqliteDriver.js +3 -3
- package/dialects/sqlite/SqliteExceptionConverter.d.ts +6 -6
- package/dialects/sqlite/SqliteExceptionConverter.js +51 -67
- package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +2 -2
- package/dialects/sqlite/SqliteNativeQueryBuilder.js +7 -7
- package/dialects/sqlite/SqlitePlatform.d.ts +72 -63
- package/dialects/sqlite/SqlitePlatform.js +139 -139
- package/dialects/sqlite/SqliteSchemaHelper.d.ts +60 -77
- package/dialects/sqlite/SqliteSchemaHelper.js +522 -541
- package/package.json +2 -2
- package/plugin/index.d.ts +35 -42
- package/plugin/index.js +36 -43
- package/plugin/transformer.d.ts +94 -117
- package/plugin/transformer.js +881 -890
- package/query/ArrayCriteriaNode.d.ts +4 -4
- package/query/ArrayCriteriaNode.js +18 -18
- package/query/CriteriaNode.d.ts +25 -35
- package/query/CriteriaNode.js +123 -133
- package/query/CriteriaNodeFactory.d.ts +6 -49
- package/query/CriteriaNodeFactory.js +94 -97
- package/query/NativeQueryBuilder.d.ts +120 -120
- package/query/NativeQueryBuilder.js +501 -507
- package/query/ObjectCriteriaNode.d.ts +12 -12
- package/query/ObjectCriteriaNode.js +282 -298
- package/query/QueryBuilder.d.ts +905 -1557
- package/query/QueryBuilder.js +2192 -2322
- package/query/QueryBuilderHelper.d.ts +72 -153
- package/query/QueryBuilderHelper.js +1028 -1079
- package/query/ScalarCriteriaNode.d.ts +3 -3
- package/query/ScalarCriteriaNode.js +46 -53
- package/query/enums.d.ts +14 -14
- package/query/enums.js +14 -14
- package/query/raw.d.ts +6 -16
- package/query/raw.js +10 -10
- package/schema/DatabaseSchema.d.ts +50 -74
- package/schema/DatabaseSchema.js +327 -355
- package/schema/DatabaseTable.d.ts +73 -96
- package/schema/DatabaseTable.js +927 -1012
- package/schema/SchemaComparator.d.ts +66 -70
- package/schema/SchemaComparator.js +764 -790
- package/schema/SchemaHelper.d.ts +96 -121
- package/schema/SchemaHelper.js +668 -683
- package/schema/SqlSchemaGenerator.d.ts +59 -79
- package/schema/SqlSchemaGenerator.js +495 -525
- package/typings.d.ts +275 -405
package/typings.d.ts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
import type { Generated, Kysely } from 'kysely';
|
|
2
|
-
import type {
|
|
3
|
-
CheckCallback,
|
|
4
|
-
DeferMode,
|
|
5
|
-
Dictionary,
|
|
6
|
-
EntityName,
|
|
7
|
-
EntityProperty,
|
|
8
|
-
EntitySchemaWithMeta,
|
|
9
|
-
FilterQuery,
|
|
10
|
-
GroupOperator,
|
|
11
|
-
IndexColumnOptions,
|
|
12
|
-
InferEntityName,
|
|
13
|
-
Opt,
|
|
14
|
-
Primary,
|
|
15
|
-
PrimaryProperty,
|
|
16
|
-
QueryFlag,
|
|
17
|
-
QueryOrderMap,
|
|
18
|
-
RawQueryFragment,
|
|
19
|
-
Scalar,
|
|
20
|
-
Type,
|
|
21
|
-
} from '@mikro-orm/core';
|
|
2
|
+
import type { CheckCallback, DeferMode, Dictionary, EntityName, EntityProperty, EntitySchemaWithMeta, FilterQuery, GroupOperator, IndexColumnOptions, InferEntityName, Opt, Primary, PrimaryProperty, QueryFlag, QueryOrderMap, RawQueryFragment, Scalar, Type } from '@mikro-orm/core';
|
|
22
3
|
import type { JoinType, QueryType } from './query/enums.js';
|
|
23
4
|
import type { DatabaseSchema } from './schema/DatabaseSchema.js';
|
|
24
5
|
import type { DatabaseTable } from './schema/DatabaseTable.js';
|
|
@@ -26,441 +7,330 @@ import type { AnyQueryBuilder } from './query/QueryBuilder.js';
|
|
|
26
7
|
import type { CteOptions, NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
27
8
|
import type { MikroKyselyPluginOptions } from './plugin/index.js';
|
|
28
9
|
export interface Table {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
table_name: string;
|
|
11
|
+
schema_name?: string;
|
|
12
|
+
table_comment?: string;
|
|
32
13
|
}
|
|
33
14
|
/** @internal */
|
|
34
15
|
export type InternalField<T> = string | RawQueryFragment | AnyQueryBuilder | NativeQueryBuilder;
|
|
35
16
|
export interface JoinOptions {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
17
|
+
table: string;
|
|
18
|
+
schema?: string;
|
|
19
|
+
type: JoinType;
|
|
20
|
+
alias: string;
|
|
21
|
+
ownerAlias: string;
|
|
22
|
+
inverseAlias?: string;
|
|
23
|
+
joinColumns?: string[];
|
|
24
|
+
inverseJoinColumns?: string[];
|
|
25
|
+
primaryKeys?: string[];
|
|
26
|
+
path?: string;
|
|
27
|
+
prop: EntityProperty;
|
|
28
|
+
cond: Dictionary;
|
|
29
|
+
cond_?: Dictionary;
|
|
30
|
+
subquery?: string;
|
|
31
|
+
nested?: Set<JoinOptions>;
|
|
32
|
+
parent?: JoinOptions;
|
|
52
33
|
}
|
|
53
34
|
export interface Column {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
mappedType: Type<unknown>;
|
|
38
|
+
unsigned?: boolean;
|
|
39
|
+
autoincrement?: boolean;
|
|
40
|
+
nullable?: boolean;
|
|
41
|
+
length?: number;
|
|
42
|
+
precision?: number;
|
|
43
|
+
scale?: number;
|
|
44
|
+
default?: string | null;
|
|
45
|
+
defaultConstraint?: string;
|
|
46
|
+
comment?: string;
|
|
47
|
+
generated?: string;
|
|
48
|
+
nativeEnumName?: string;
|
|
49
|
+
enumItems?: string[];
|
|
50
|
+
primary?: boolean;
|
|
51
|
+
unique?: boolean;
|
|
52
|
+
/** mysql only */
|
|
53
|
+
extra?: string;
|
|
54
|
+
ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
|
|
74
55
|
}
|
|
75
56
|
export interface ForeignKey {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
columnNames: string[];
|
|
58
|
+
constraintName: string;
|
|
59
|
+
localTableName: string;
|
|
60
|
+
referencedTableName: string;
|
|
61
|
+
referencedColumnNames: string[];
|
|
62
|
+
updateRule?: string;
|
|
63
|
+
deleteRule?: string;
|
|
64
|
+
deferMode?: DeferMode;
|
|
84
65
|
}
|
|
85
66
|
export interface IndexDef {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
| string
|
|
96
|
-
| Readonly<{
|
|
67
|
+
columnNames: string[];
|
|
68
|
+
keyName: string;
|
|
69
|
+
unique: boolean;
|
|
70
|
+
constraint: boolean;
|
|
71
|
+
primary: boolean;
|
|
72
|
+
composite?: boolean;
|
|
73
|
+
expression?: string;
|
|
74
|
+
options?: Dictionary;
|
|
75
|
+
type?: string | Readonly<{
|
|
97
76
|
indexType?: string;
|
|
98
77
|
storageEngineIndexType?: 'hash' | 'btree';
|
|
99
78
|
predicate?: string;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
79
|
+
}>;
|
|
80
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
81
|
+
/**
|
|
82
|
+
* Advanced column options for the index.
|
|
83
|
+
* When specified, these options override the simple columnNames for index generation.
|
|
84
|
+
*/
|
|
85
|
+
columns?: IndexColumnOptions[];
|
|
86
|
+
/**
|
|
87
|
+
* Columns to include in the index but not as part of the key (PostgreSQL, MSSQL).
|
|
88
|
+
*/
|
|
89
|
+
include?: string[];
|
|
90
|
+
/** Fill factor for the index as a percentage 0-100 (PostgreSQL, MSSQL). */
|
|
91
|
+
fillFactor?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the index is invisible/hidden from the query optimizer (MySQL 8+, MariaDB 10.6+, MongoDB).
|
|
94
|
+
*/
|
|
95
|
+
invisible?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the index is disabled (MSSQL only).
|
|
98
|
+
*/
|
|
99
|
+
disabled?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Whether the index should be clustered (MariaDB, MSSQL).
|
|
102
|
+
*/
|
|
103
|
+
clustered?: boolean;
|
|
125
104
|
}
|
|
126
105
|
export interface CheckDef<T = unknown> {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
106
|
+
name: string;
|
|
107
|
+
expression: string | CheckCallback<T>;
|
|
108
|
+
definition?: string;
|
|
109
|
+
columnName?: string;
|
|
131
110
|
}
|
|
132
111
|
export interface ColumnDifference {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
112
|
+
oldColumnName: string;
|
|
113
|
+
column: Column;
|
|
114
|
+
fromColumn: Column;
|
|
115
|
+
changedProperties: Set<string>;
|
|
137
116
|
}
|
|
138
117
|
export interface TableDifference {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
118
|
+
name: string;
|
|
119
|
+
changedComment?: string;
|
|
120
|
+
fromTable: DatabaseTable;
|
|
121
|
+
toTable: DatabaseTable;
|
|
122
|
+
addedColumns: Dictionary<Column>;
|
|
123
|
+
changedColumns: Dictionary<ColumnDifference>;
|
|
124
|
+
removedColumns: Dictionary<Column>;
|
|
125
|
+
renamedColumns: Dictionary<Column>;
|
|
126
|
+
addedIndexes: Dictionary<IndexDef>;
|
|
127
|
+
changedIndexes: Dictionary<IndexDef>;
|
|
128
|
+
removedIndexes: Dictionary<IndexDef>;
|
|
129
|
+
renamedIndexes: Dictionary<IndexDef>;
|
|
130
|
+
addedChecks: Dictionary<CheckDef>;
|
|
131
|
+
changedChecks: Dictionary<CheckDef>;
|
|
132
|
+
removedChecks: Dictionary<CheckDef>;
|
|
133
|
+
addedForeignKeys: Dictionary<ForeignKey>;
|
|
134
|
+
changedForeignKeys: Dictionary<ForeignKey>;
|
|
135
|
+
removedForeignKeys: Dictionary<ForeignKey>;
|
|
157
136
|
}
|
|
158
137
|
export interface DatabaseView {
|
|
159
|
-
name: string;
|
|
160
|
-
schema?: string;
|
|
161
|
-
definition: string;
|
|
162
|
-
/** True if this is a materialized view (PostgreSQL only). */
|
|
163
|
-
materialized?: boolean;
|
|
164
|
-
/** For materialized views, whether data was populated on creation. */
|
|
165
|
-
withData?: boolean;
|
|
166
|
-
/** Indexes on the materialized view. Only materialized views support indexes. */
|
|
167
|
-
indexes?: IndexDef[];
|
|
168
|
-
}
|
|
169
|
-
export interface SchemaDifference {
|
|
170
|
-
newNamespaces: Set<string>;
|
|
171
|
-
newNativeEnums: {
|
|
172
138
|
name: string;
|
|
173
139
|
schema?: string;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
140
|
+
definition: string;
|
|
141
|
+
/** True if this is a materialized view (PostgreSQL only). */
|
|
142
|
+
materialized?: boolean;
|
|
143
|
+
/** For materialized views, whether data was populated on creation. */
|
|
144
|
+
withData?: boolean;
|
|
145
|
+
/** Indexes on the materialized view. Only materialized views support indexes. */
|
|
146
|
+
indexes?: IndexDef[];
|
|
147
|
+
}
|
|
148
|
+
export interface SchemaDifference {
|
|
149
|
+
newNamespaces: Set<string>;
|
|
150
|
+
newNativeEnums: {
|
|
151
|
+
name: string;
|
|
152
|
+
schema?: string;
|
|
153
|
+
items: string[];
|
|
154
|
+
}[];
|
|
155
|
+
newTables: Dictionary<DatabaseTable>;
|
|
156
|
+
changedTables: Dictionary<TableDifference>;
|
|
157
|
+
removedTables: Dictionary<DatabaseTable>;
|
|
158
|
+
newViews: Dictionary<DatabaseView>;
|
|
159
|
+
changedViews: Dictionary<{
|
|
160
|
+
from: DatabaseView;
|
|
161
|
+
to: DatabaseView;
|
|
162
|
+
}>;
|
|
163
|
+
removedViews: Dictionary<DatabaseView>;
|
|
164
|
+
removedNamespaces: Set<string>;
|
|
165
|
+
removedNativeEnums: {
|
|
166
|
+
name: string;
|
|
167
|
+
schema?: string;
|
|
168
|
+
}[];
|
|
169
|
+
orphanedForeignKeys: ForeignKey[];
|
|
170
|
+
fromSchema: DatabaseSchema;
|
|
192
171
|
}
|
|
193
172
|
export interface IQueryBuilder<T> {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
cond: FilterQuery<T> | string | RawQueryFragment | Dictionary,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
with(name: string, query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment, options?: CteOptions): this;
|
|
236
|
-
withRecursive(
|
|
237
|
-
name: string,
|
|
238
|
-
query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment,
|
|
239
|
-
options?: CteOptions,
|
|
240
|
-
): this;
|
|
241
|
-
scheduleFilterCheck(path: string): void;
|
|
242
|
-
withSchema(schema: string): this;
|
|
173
|
+
readonly alias: string;
|
|
174
|
+
readonly type: QueryType;
|
|
175
|
+
/** @internal */
|
|
176
|
+
state: {
|
|
177
|
+
fields?: InternalField<T>[];
|
|
178
|
+
[key: string]: any;
|
|
179
|
+
};
|
|
180
|
+
/** @internal */
|
|
181
|
+
helper: any;
|
|
182
|
+
select(fields: string | RawQueryFragment | (string | RawQueryFragment)[], distinct?: boolean): this;
|
|
183
|
+
addSelect(fields: string | string[]): this;
|
|
184
|
+
from<T extends object>(target: EntityName<T> | IQueryBuilder<T>, aliasName?: string): IQueryBuilder<T>;
|
|
185
|
+
insert(data: any): this;
|
|
186
|
+
update(data: any): this;
|
|
187
|
+
delete(cond?: FilterQuery<any>): this;
|
|
188
|
+
truncate(): this;
|
|
189
|
+
count(field?: string | string[], distinct?: boolean): this;
|
|
190
|
+
join(field: string, alias: string, cond?: FilterQuery<any>, type?: JoinType, path?: string): this;
|
|
191
|
+
innerJoin(field: string, alias: string, cond?: FilterQuery<any>): this;
|
|
192
|
+
leftJoin(field: string, alias: string, cond?: FilterQuery<any>): this;
|
|
193
|
+
joinAndSelect(field: any, alias: string, cond?: FilterQuery<any>): this;
|
|
194
|
+
leftJoinAndSelect(field: any, alias: string, cond?: FilterQuery<any>, fields?: string[]): this;
|
|
195
|
+
innerJoinAndSelect(field: any, alias: string, cond?: FilterQuery<any>, fields?: string[]): this;
|
|
196
|
+
withSubQuery(subQuery: RawQueryFragment | NativeQueryBuilder, alias: string): this;
|
|
197
|
+
where(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, operator?: keyof typeof GroupOperator | any[], operator2?: keyof typeof GroupOperator): this;
|
|
198
|
+
andWhere(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, params?: any[]): this;
|
|
199
|
+
orWhere(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, params?: any[]): this;
|
|
200
|
+
orderBy(orderBy: QueryOrderMap<T>): this;
|
|
201
|
+
groupBy(fields: (string | keyof T) | (string | keyof T)[]): this;
|
|
202
|
+
having(cond?: FilterQuery<any> | string, params?: any[]): this;
|
|
203
|
+
getAliasForJoinPath(path: string, options?: ICriteriaNodeProcessOptions): string | undefined;
|
|
204
|
+
getJoinForPath(path?: string, options?: ICriteriaNodeProcessOptions): JoinOptions | undefined;
|
|
205
|
+
getNextAlias(entityName?: string | EntityName<T>): string;
|
|
206
|
+
clone(reset?: boolean | string[], preserve?: string[]): IQueryBuilder<T>;
|
|
207
|
+
setFlag(flag: QueryFlag): this;
|
|
208
|
+
unsetFlag(flag: QueryFlag): this;
|
|
209
|
+
hasFlag(flag: QueryFlag): boolean;
|
|
210
|
+
with(name: string, query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment, options?: CteOptions): this;
|
|
211
|
+
withRecursive(name: string, query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment, options?: CteOptions): this;
|
|
212
|
+
scheduleFilterCheck(path: string): void;
|
|
213
|
+
withSchema(schema: string): this;
|
|
243
214
|
}
|
|
244
215
|
export interface ICriteriaNodeProcessOptions {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
216
|
+
alias?: string;
|
|
217
|
+
matchPopulateJoins?: boolean;
|
|
218
|
+
ignoreBranching?: boolean;
|
|
219
|
+
preferNoBranch?: boolean;
|
|
220
|
+
type?: 'orderBy' | 'having';
|
|
221
|
+
filter?: boolean;
|
|
222
|
+
parentPath?: string;
|
|
252
223
|
}
|
|
253
224
|
export interface ICriteriaNode<T extends object> {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
225
|
+
readonly entityName: EntityName<T>;
|
|
226
|
+
readonly parent?: ICriteriaNode<T> | undefined;
|
|
227
|
+
readonly key?: string | symbol | undefined;
|
|
228
|
+
readonly strict?: boolean;
|
|
229
|
+
payload: any;
|
|
230
|
+
prop?: EntityProperty;
|
|
231
|
+
index?: number;
|
|
232
|
+
process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
|
|
233
|
+
shouldInline(payload: any): boolean;
|
|
234
|
+
willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
|
|
235
|
+
shouldRename(payload: any): boolean;
|
|
236
|
+
renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string): string;
|
|
237
|
+
getPath(opts?: {
|
|
238
|
+
addIndex?: boolean;
|
|
239
|
+
}): string;
|
|
240
|
+
getPivotPath(path: string): string;
|
|
268
241
|
}
|
|
269
242
|
export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
270
|
-
export type InferEntityProperties<Schema> =
|
|
271
|
-
|
|
272
|
-
export type InferKyselyDB<
|
|
273
|
-
TEntities extends {
|
|
243
|
+
export type InferEntityProperties<Schema> = Schema extends EntitySchemaWithMeta<any, any, any, any, infer Properties> ? Properties : never;
|
|
244
|
+
export type InferKyselyDB<TEntities extends {
|
|
274
245
|
name: string;
|
|
275
|
-
|
|
276
|
-
TOptions extends MikroKyselyPluginOptions = {},
|
|
277
|
-
> = MapValueAsTable<MapTableName<TEntities, TOptions>, TOptions>;
|
|
246
|
+
}, TOptions extends MikroKyselyPluginOptions = {}> = MapValueAsTable<MapTableName<TEntities, TOptions>, TOptions>;
|
|
278
247
|
export type InferDBFromKysely<TKysely extends Kysely<any>> = TKysely extends Kysely<infer TDB> ? TDB : never;
|
|
279
|
-
type PreferStringLiteral<TCandidate, TFallback> = [TCandidate] extends [never]
|
|
280
|
-
|
|
281
|
-
: string extends TCandidate
|
|
282
|
-
? TFallback
|
|
283
|
-
: TCandidate extends string
|
|
284
|
-
? TCandidate
|
|
285
|
-
: TFallback;
|
|
286
|
-
export type MapTableName<
|
|
287
|
-
T extends {
|
|
248
|
+
type PreferStringLiteral<TCandidate, TFallback> = [TCandidate] extends [never] ? TFallback : string extends TCandidate ? TFallback : TCandidate extends string ? TCandidate : TFallback;
|
|
249
|
+
export type MapTableName<T extends {
|
|
288
250
|
name: string;
|
|
289
251
|
tableName?: string;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
> = {
|
|
293
|
-
[P in T as TOptions['tableNamingStrategy'] extends 'entity'
|
|
294
|
-
? P['name']
|
|
295
|
-
: PreferStringLiteral<NonNullable<P['tableName']>, P['name']>]: P;
|
|
252
|
+
}, TOptions extends MikroKyselyPluginOptions = {}> = {
|
|
253
|
+
[P in T as TOptions['tableNamingStrategy'] extends 'entity' ? P['name'] : PreferStringLiteral<NonNullable<P['tableName']>, P['name']>]: P;
|
|
296
254
|
};
|
|
297
|
-
type ResolveTableNaming<TOptions extends MikroKyselyPluginOptions> = TOptions['tableNamingStrategy'] extends 'entity'
|
|
298
|
-
? 'entity'
|
|
299
|
-
: 'underscore';
|
|
255
|
+
type ResolveTableNaming<TOptions extends MikroKyselyPluginOptions> = TOptions['tableNamingStrategy'] extends 'entity' ? 'entity' : 'underscore';
|
|
300
256
|
export type MapValueAsTable<TMap extends Record<string, any>, TOptions extends MikroKyselyPluginOptions = {}> = {
|
|
301
|
-
|
|
257
|
+
[K in keyof TMap as TransformName<K, ResolveTableNaming<TOptions>>]: InferKyselyTable<TMap[K], TOptions>;
|
|
302
258
|
};
|
|
303
|
-
export type InferKyselyTable<
|
|
304
|
-
|
|
305
|
-
TOptions extends MikroKyselyPluginOptions = {},
|
|
306
|
-
> = ExcludeNever<{
|
|
307
|
-
-readonly [K in keyof InferEntityProperties<TSchema> as TransformColumnName<
|
|
308
|
-
K,
|
|
309
|
-
TOptions['columnNamingStrategy'] extends 'property' ? 'property' : 'underscore',
|
|
310
|
-
MaybeReturnType<InferEntityProperties<TSchema>[K]>
|
|
311
|
-
>]: InferColumnValue<
|
|
312
|
-
MaybeReturnType<InferEntityProperties<TSchema>[K]>,
|
|
313
|
-
TOptions['processOnCreateHooks'] extends true ? true : false
|
|
314
|
-
>;
|
|
259
|
+
export type InferKyselyTable<TSchema extends EntitySchemaWithMeta, TOptions extends MikroKyselyPluginOptions = {}> = ExcludeNever<{
|
|
260
|
+
-readonly [K in keyof InferEntityProperties<TSchema> as TransformColumnName<K, TOptions['columnNamingStrategy'] extends 'property' ? 'property' : 'underscore', MaybeReturnType<InferEntityProperties<TSchema>[K]>>]: InferColumnValue<MaybeReturnType<InferEntityProperties<TSchema>[K]>, TOptions['processOnCreateHooks'] extends true ? true : false>;
|
|
315
261
|
}>;
|
|
316
|
-
type TransformName<TName, TNamingStrategy extends 'underscore' | 'entity'> = TNamingStrategy extends 'underscore'
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
TName,
|
|
323
|
-
TNamingStrategy extends 'underscore' | 'property',
|
|
324
|
-
TBuilder,
|
|
325
|
-
> = TNamingStrategy extends 'property'
|
|
326
|
-
? TName
|
|
327
|
-
: TBuilder extends {
|
|
328
|
-
'~options': {
|
|
329
|
-
fieldName: string;
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
? TBuilder['~options']['fieldName']
|
|
333
|
-
: TName extends string
|
|
334
|
-
? MaybeJoinColumnName<SnakeCase<TName>, TBuilder>
|
|
335
|
-
: never;
|
|
262
|
+
type TransformName<TName, TNamingStrategy extends 'underscore' | 'entity'> = TNamingStrategy extends 'underscore' ? TName extends string ? SnakeCase<TName> : TName : TName;
|
|
263
|
+
type TransformColumnName<TName, TNamingStrategy extends 'underscore' | 'property', TBuilder> = TNamingStrategy extends 'property' ? TName : TBuilder extends {
|
|
264
|
+
'~options': {
|
|
265
|
+
fieldName: string;
|
|
266
|
+
};
|
|
267
|
+
} ? TBuilder['~options']['fieldName'] : TName extends string ? MaybeJoinColumnName<SnakeCase<TName>, TBuilder> : never;
|
|
336
268
|
type MaybeJoinColumnName<TName extends string, TBuilder> = TBuilder extends {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
'
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
owner: true;
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
? PrimaryProperty<Value> extends string
|
|
357
|
-
? `${TName}_${SnakeCase<PrimaryProperty<Value>>}`
|
|
358
|
-
: never
|
|
359
|
-
: TName;
|
|
360
|
-
export type SnakeCase<TName extends string> = TName extends `${infer A}${infer B}${infer Rest}`
|
|
361
|
-
? IsUpperLetter<B> extends never
|
|
362
|
-
? `${Lowercase<A>}${SnakeCase<`${B}${Rest}`>}`
|
|
363
|
-
: IsLowerLetter<A> extends never
|
|
364
|
-
? `${Lowercase<A>}${SnakeCase<`${B}${Rest}`>}`
|
|
365
|
-
: `${Lowercase<A>}_${SnakeCase<`${B}${Rest}`>}`
|
|
366
|
-
: Lowercase<TName>;
|
|
269
|
+
'~type'?: {
|
|
270
|
+
value: infer Value;
|
|
271
|
+
};
|
|
272
|
+
'~options': {
|
|
273
|
+
kind: 'm:1';
|
|
274
|
+
};
|
|
275
|
+
} ? PrimaryProperty<Value> extends string ? `${TName}_${SnakeCase<PrimaryProperty<Value>>}` : never : TBuilder extends {
|
|
276
|
+
'~type'?: {
|
|
277
|
+
value: infer Value;
|
|
278
|
+
};
|
|
279
|
+
'~options': {
|
|
280
|
+
kind: '1:1';
|
|
281
|
+
owner: true;
|
|
282
|
+
};
|
|
283
|
+
} ? PrimaryProperty<Value> extends string ? `${TName}_${SnakeCase<PrimaryProperty<Value>>}` : never : TName;
|
|
284
|
+
export type SnakeCase<TName extends string> = TName extends `${infer A}${infer B}${infer Rest}` ? IsUpperLetter<B> extends never ? `${Lowercase<A>}${SnakeCase<`${B}${Rest}`>}` : IsLowerLetter<A> extends never ? `${Lowercase<A>}${SnakeCase<`${B}${Rest}`>}` : `${Lowercase<A>}_${SnakeCase<`${B}${Rest}`>}` : Lowercase<TName>;
|
|
367
285
|
type IsLowerLetter<C extends string> = C extends Lowercase<C> ? (C extends Uppercase<C> ? never : C) : never;
|
|
368
286
|
type IsUpperLetter<C extends string> = C extends Uppercase<C> ? (C extends Lowercase<C> ? never : C) : never;
|
|
369
287
|
type InferColumnValue<TBuilder, TProcessOnCreate extends boolean> = TBuilder extends {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
? MaybeNever<MaybeGenerated<MaybeJoinKey<Value, TOptions>, TOptions, TProcessOnCreate>, TOptions>
|
|
376
|
-
: never;
|
|
288
|
+
'~type'?: {
|
|
289
|
+
value: infer Value;
|
|
290
|
+
};
|
|
291
|
+
'~options': infer TOptions;
|
|
292
|
+
} ? MaybeNever<MaybeGenerated<MaybeJoinKey<Value, TOptions>, TOptions, TProcessOnCreate>, TOptions> : never;
|
|
377
293
|
type MaybeGenerated<TValue, TOptions, TProcessOnCreate extends boolean> = TOptions extends {
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
? Generated<TValue>
|
|
389
|
-
: TOptions extends {
|
|
390
|
-
defaultRaw: true;
|
|
391
|
-
}
|
|
392
|
-
? Generated<TValue>
|
|
393
|
-
: TProcessOnCreate extends false
|
|
394
|
-
? TValue
|
|
395
|
-
: TOptions extends {
|
|
396
|
-
onCreate: Function;
|
|
397
|
-
}
|
|
398
|
-
? Generated<TValue>
|
|
399
|
-
: TValue;
|
|
294
|
+
nullable: true;
|
|
295
|
+
} ? TValue | null : TOptions extends {
|
|
296
|
+
autoincrement: true;
|
|
297
|
+
} ? Generated<TValue> : TOptions extends {
|
|
298
|
+
default: true;
|
|
299
|
+
} ? Generated<TValue> : TOptions extends {
|
|
300
|
+
defaultRaw: true;
|
|
301
|
+
} ? Generated<TValue> : TProcessOnCreate extends false ? TValue : TOptions extends {
|
|
302
|
+
onCreate: Function;
|
|
303
|
+
} ? Generated<TValue> : TValue;
|
|
400
304
|
type MaybeJoinKey<TValue, TOptions> = TOptions extends {
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
? TOptions extends {
|
|
408
|
-
owner: true;
|
|
409
|
-
}
|
|
410
|
-
? UnwrapOpt<Primary<TValue>>
|
|
411
|
-
: never
|
|
412
|
-
: TValue;
|
|
305
|
+
kind: 'm:1';
|
|
306
|
+
} ? UnwrapOpt<Primary<TValue>> : TOptions extends {
|
|
307
|
+
kind: '1:1';
|
|
308
|
+
} ? TOptions extends {
|
|
309
|
+
owner: true;
|
|
310
|
+
} ? UnwrapOpt<Primary<TValue>> : never : TValue;
|
|
413
311
|
type UnwrapOpt<TValue> = TValue extends Opt<infer OriginalValue> ? OriginalValue : TValue;
|
|
414
|
-
type MaybeNever<TValue, TOptions> = TOptions extends
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
kind: 'm:n' | '1:m';
|
|
420
|
-
}
|
|
421
|
-
? never
|
|
422
|
-
: TValue;
|
|
312
|
+
type MaybeNever<TValue, TOptions> = TOptions extends {
|
|
313
|
+
persist: false;
|
|
314
|
+
} | {
|
|
315
|
+
kind: 'm:n' | '1:m';
|
|
316
|
+
} ? never : TValue;
|
|
423
317
|
type ExcludeNever<TMap extends Record<string, any>> = {
|
|
424
|
-
|
|
318
|
+
[K in keyof TMap as TMap[K] extends never ? never : K]: TMap[K];
|
|
425
319
|
};
|
|
426
|
-
export type InferClassEntityDB<TEntities, TOptions extends MikroKyselyPluginOptions = {}> =
|
|
427
|
-
ClassEntityDBMap<TEntities, TOptions> extends infer R ? ([keyof R] extends [never] ? unknown : R) : never;
|
|
320
|
+
export type InferClassEntityDB<TEntities, TOptions extends MikroKyselyPluginOptions = {}> = ClassEntityDBMap<TEntities, TOptions> extends infer R ? ([keyof R] extends [never] ? unknown : R) : never;
|
|
428
321
|
type ClassEntityDBMap<TEntities, TOptions extends MikroKyselyPluginOptions = {}> = {
|
|
429
|
-
|
|
322
|
+
[T in TEntities as ClassEntityTableName<T, TOptions>]: ClassEntityColumns<T, TOptions>;
|
|
430
323
|
};
|
|
431
324
|
type ClassEntityTableName<T, TOptions extends MikroKyselyPluginOptions = {}> = T extends {
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
[K in keyof Instance as ClassEntityColumnName<K, Instance[K], TOptions>]: ClassEntityColumnValue<Instance[K]>;
|
|
443
|
-
}
|
|
444
|
-
: never;
|
|
445
|
-
type ClassEntityColumnName<K, V, TOptions extends MikroKyselyPluginOptions = {}> = K extends symbol
|
|
446
|
-
? never
|
|
447
|
-
: NonNullable<V> extends infer NV
|
|
448
|
-
? NV extends {
|
|
449
|
-
[k: number]: any;
|
|
450
|
-
readonly owner: object;
|
|
451
|
-
}
|
|
452
|
-
? never
|
|
453
|
-
: TOptions['columnNamingStrategy'] extends 'property'
|
|
454
|
-
? K
|
|
455
|
-
: NV extends Scalar
|
|
456
|
-
? K extends string
|
|
457
|
-
? SnakeCase<K>
|
|
458
|
-
: never
|
|
459
|
-
: K extends string
|
|
460
|
-
? ClassEntityJoinColumnName<SnakeCase<K>, NV>
|
|
461
|
-
: never
|
|
462
|
-
: never;
|
|
463
|
-
type ClassEntityJoinColumnName<TName extends string, V> =
|
|
464
|
-
PrimaryProperty<V> extends string ? `${TName}_${SnakeCase<PrimaryProperty<V>>}` : never;
|
|
325
|
+
'~entityName'?: infer Name extends string;
|
|
326
|
+
} ? TransformName<Name, ResolveTableNaming<TOptions>> : T extends abstract new (...args: any[]) => infer Instance ? TransformName<InferEntityName<Instance>, ResolveTableNaming<TOptions>> : never;
|
|
327
|
+
type ClassEntityColumns<T, TOptions extends MikroKyselyPluginOptions = {}> = T extends abstract new (...args: any[]) => infer Instance ? {
|
|
328
|
+
[K in keyof Instance as ClassEntityColumnName<K, Instance[K], TOptions>]: ClassEntityColumnValue<Instance[K]>;
|
|
329
|
+
} : never;
|
|
330
|
+
type ClassEntityColumnName<K, V, TOptions extends MikroKyselyPluginOptions = {}> = K extends symbol ? never : NonNullable<V> extends infer NV ? NV extends {
|
|
331
|
+
[k: number]: any;
|
|
332
|
+
readonly owner: object;
|
|
333
|
+
} ? never : TOptions['columnNamingStrategy'] extends 'property' ? K : NV extends Scalar ? K extends string ? SnakeCase<K> : never : K extends string ? ClassEntityJoinColumnName<SnakeCase<K>, NV> : never : never;
|
|
334
|
+
type ClassEntityJoinColumnName<TName extends string, V> = PrimaryProperty<V> extends string ? `${TName}_${SnakeCase<PrimaryProperty<V>>}` : never;
|
|
465
335
|
type ClassEntityColumnValue<V> = NonNullable<V> extends Scalar ? V : Primary<NonNullable<V>>;
|
|
466
336
|
export {};
|