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