@mikro-orm/sql 7.0.4 → 7.0.5-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.
Files changed (87) hide show
  1. package/AbstractSqlConnection.d.ts +58 -94
  2. package/AbstractSqlConnection.js +238 -235
  3. package/AbstractSqlDriver.d.ts +155 -410
  4. package/AbstractSqlDriver.js +1941 -2064
  5. package/AbstractSqlPlatform.d.ts +73 -83
  6. package/AbstractSqlPlatform.js +158 -162
  7. package/PivotCollectionPersister.d.ts +15 -33
  8. package/PivotCollectionPersister.js +160 -158
  9. package/README.md +1 -1
  10. package/SqlEntityManager.d.ts +22 -67
  11. package/SqlEntityManager.js +38 -54
  12. package/SqlEntityRepository.d.ts +14 -14
  13. package/SqlEntityRepository.js +23 -23
  14. package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -12
  15. package/dialects/mssql/MsSqlNativeQueryBuilder.js +194 -192
  16. package/dialects/mysql/BaseMySqlPlatform.d.ts +45 -64
  17. package/dialects/mysql/BaseMySqlPlatform.js +131 -134
  18. package/dialects/mysql/MySqlExceptionConverter.d.ts +6 -6
  19. package/dialects/mysql/MySqlExceptionConverter.js +77 -91
  20. package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +3 -3
  21. package/dialects/mysql/MySqlNativeQueryBuilder.js +69 -66
  22. package/dialects/mysql/MySqlSchemaHelper.d.ts +39 -39
  23. package/dialects/mysql/MySqlSchemaHelper.js +319 -327
  24. package/dialects/oracledb/OracleDialect.d.ts +52 -81
  25. package/dialects/oracledb/OracleDialect.js +149 -155
  26. package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +12 -12
  27. package/dialects/oracledb/OracleNativeQueryBuilder.js +236 -232
  28. package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +106 -109
  29. package/dialects/postgresql/BasePostgreSqlPlatform.js +353 -354
  30. package/dialects/postgresql/FullTextType.d.ts +6 -10
  31. package/dialects/postgresql/FullTextType.js +51 -51
  32. package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +5 -5
  33. package/dialects/postgresql/PostgreSqlExceptionConverter.js +43 -55
  34. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +1 -1
  35. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +4 -4
  36. package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +82 -102
  37. package/dialects/postgresql/PostgreSqlSchemaHelper.js +705 -733
  38. package/dialects/sqlite/BaseSqliteConnection.d.ts +5 -3
  39. package/dialects/sqlite/BaseSqliteConnection.js +19 -21
  40. package/dialects/sqlite/NodeSqliteDialect.d.ts +1 -1
  41. package/dialects/sqlite/NodeSqliteDialect.js +23 -23
  42. package/dialects/sqlite/SqliteDriver.d.ts +1 -1
  43. package/dialects/sqlite/SqliteDriver.js +3 -3
  44. package/dialects/sqlite/SqliteExceptionConverter.d.ts +6 -6
  45. package/dialects/sqlite/SqliteExceptionConverter.js +51 -67
  46. package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +2 -2
  47. package/dialects/sqlite/SqliteNativeQueryBuilder.js +7 -7
  48. package/dialects/sqlite/SqlitePlatform.d.ts +72 -63
  49. package/dialects/sqlite/SqlitePlatform.js +139 -139
  50. package/dialects/sqlite/SqliteSchemaHelper.d.ts +60 -70
  51. package/dialects/sqlite/SqliteSchemaHelper.js +520 -533
  52. package/package.json +2 -2
  53. package/plugin/index.d.ts +35 -42
  54. package/plugin/index.js +36 -43
  55. package/plugin/transformer.d.ts +94 -117
  56. package/plugin/transformer.js +881 -890
  57. package/query/ArrayCriteriaNode.d.ts +4 -4
  58. package/query/ArrayCriteriaNode.js +18 -18
  59. package/query/CriteriaNode.d.ts +25 -35
  60. package/query/CriteriaNode.js +123 -133
  61. package/query/CriteriaNodeFactory.d.ts +6 -49
  62. package/query/CriteriaNodeFactory.js +94 -97
  63. package/query/NativeQueryBuilder.d.ts +118 -118
  64. package/query/NativeQueryBuilder.js +480 -484
  65. package/query/ObjectCriteriaNode.d.ts +12 -12
  66. package/query/ObjectCriteriaNode.js +282 -298
  67. package/query/QueryBuilder.d.ts +905 -1557
  68. package/query/QueryBuilder.js +2192 -2322
  69. package/query/QueryBuilderHelper.d.ts +72 -153
  70. package/query/QueryBuilderHelper.js +1028 -1079
  71. package/query/ScalarCriteriaNode.d.ts +3 -3
  72. package/query/ScalarCriteriaNode.js +46 -53
  73. package/query/enums.d.ts +14 -14
  74. package/query/enums.js +14 -14
  75. package/query/raw.d.ts +6 -16
  76. package/query/raw.js +10 -10
  77. package/schema/DatabaseSchema.d.ts +50 -73
  78. package/schema/DatabaseSchema.js +307 -331
  79. package/schema/DatabaseTable.d.ts +73 -96
  80. package/schema/DatabaseTable.js +927 -1012
  81. package/schema/SchemaComparator.d.ts +66 -70
  82. package/schema/SchemaComparator.js +740 -766
  83. package/schema/SchemaHelper.d.ts +95 -109
  84. package/schema/SchemaHelper.js +659 -675
  85. package/schema/SqlSchemaGenerator.d.ts +58 -78
  86. package/schema/SqlSchemaGenerator.js +501 -535
  87. package/typings.d.ts +266 -380
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,415 +7,320 @@ 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
- table_name: string;
30
- schema_name?: string;
31
- table_comment?: string;
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
- 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;
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
- 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')[];
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
- columnNames: string[];
77
- constraintName: string;
78
- localTableName: string;
79
- referencedTableName: string;
80
- referencedColumnNames: string[];
81
- updateRule?: string;
82
- deleteRule?: string;
83
- deferMode?: DeferMode;
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
- 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<{
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
- 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;
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
- name: string;
128
- expression: string | CheckCallback<T>;
129
- definition?: string;
130
- columnName?: string;
106
+ name: string;
107
+ expression: string | CheckCallback<T>;
108
+ definition?: string;
109
+ columnName?: string;
131
110
  }
132
111
  export interface ColumnDifference {
133
- oldColumnName: string;
134
- column: Column;
135
- fromColumn: Column;
136
- changedProperties: Set<string>;
112
+ oldColumnName: string;
113
+ column: Column;
114
+ fromColumn: Column;
115
+ changedProperties: Set<string>;
137
116
  }
138
117
  export interface TableDifference {
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>;
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
- }
167
- export interface SchemaDifference {
168
- newNamespaces: Set<string>;
169
- newNativeEnums: {
170
- name: string;
171
- schema?: string;
172
- items: string[];
173
- }[];
174
- newTables: Dictionary<DatabaseTable>;
175
- changedTables: Dictionary<TableDifference>;
176
- removedTables: Dictionary<DatabaseTable>;
177
- newViews: Dictionary<DatabaseView>;
178
- changedViews: Dictionary<{
179
- from: DatabaseView;
180
- to: DatabaseView;
181
- }>;
182
- removedViews: Dictionary<DatabaseView>;
183
- removedNamespaces: Set<string>;
184
- removedNativeEnums: {
185
138
  name: string;
186
139
  schema?: string;
187
- }[];
188
- orphanedForeignKeys: ForeignKey[];
189
- fromSchema: DatabaseSchema;
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
+ }
146
+ export interface SchemaDifference {
147
+ newNamespaces: Set<string>;
148
+ newNativeEnums: {
149
+ name: string;
150
+ schema?: string;
151
+ items: string[];
152
+ }[];
153
+ newTables: Dictionary<DatabaseTable>;
154
+ changedTables: Dictionary<TableDifference>;
155
+ removedTables: Dictionary<DatabaseTable>;
156
+ newViews: Dictionary<DatabaseView>;
157
+ changedViews: Dictionary<{
158
+ from: DatabaseView;
159
+ to: DatabaseView;
160
+ }>;
161
+ removedViews: Dictionary<DatabaseView>;
162
+ removedNamespaces: Set<string>;
163
+ removedNativeEnums: {
164
+ name: string;
165
+ schema?: string;
166
+ }[];
167
+ orphanedForeignKeys: ForeignKey[];
168
+ fromSchema: DatabaseSchema;
190
169
  }
191
170
  export interface IQueryBuilder<T> {
192
- readonly alias: string;
193
- readonly type: QueryType;
194
- /** @internal */
195
- state: {
196
- fields?: InternalField<T>[];
197
- [key: string]: any;
198
- };
199
- /** @internal */
200
- helper: any;
201
- select(fields: string | RawQueryFragment | (string | RawQueryFragment)[], distinct?: boolean): this;
202
- addSelect(fields: string | string[]): this;
203
- from<T extends object>(target: EntityName<T> | IQueryBuilder<T>, aliasName?: string): IQueryBuilder<T>;
204
- insert(data: any): this;
205
- update(data: any): this;
206
- delete(cond?: FilterQuery<any>): this;
207
- truncate(): this;
208
- count(field?: string | string[], distinct?: boolean): this;
209
- join(field: string, alias: string, cond?: FilterQuery<any>, type?: JoinType, path?: string): this;
210
- innerJoin(field: string, alias: string, cond?: FilterQuery<any>): this;
211
- leftJoin(field: string, alias: string, cond?: FilterQuery<any>): this;
212
- joinAndSelect(field: any, alias: string, cond?: FilterQuery<any>): this;
213
- leftJoinAndSelect(field: any, alias: string, cond?: FilterQuery<any>, fields?: string[]): this;
214
- innerJoinAndSelect(field: any, alias: string, cond?: FilterQuery<any>, fields?: string[]): this;
215
- withSubQuery(subQuery: RawQueryFragment | NativeQueryBuilder, alias: string): this;
216
- where(
217
- cond: FilterQuery<T> | string | RawQueryFragment | Dictionary,
218
- operator?: keyof typeof GroupOperator | any[],
219
- operator2?: keyof typeof GroupOperator,
220
- ): this;
221
- andWhere(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, params?: any[]): this;
222
- orWhere(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, params?: any[]): this;
223
- orderBy(orderBy: QueryOrderMap<T>): this;
224
- groupBy(fields: (string | keyof T) | (string | keyof T)[]): this;
225
- having(cond?: FilterQuery<any> | string, params?: any[]): this;
226
- getAliasForJoinPath(path: string, options?: ICriteriaNodeProcessOptions): string | undefined;
227
- getJoinForPath(path?: string, options?: ICriteriaNodeProcessOptions): JoinOptions | undefined;
228
- getNextAlias(entityName?: string | EntityName<T>): string;
229
- clone(reset?: boolean | string[], preserve?: string[]): IQueryBuilder<T>;
230
- setFlag(flag: QueryFlag): this;
231
- unsetFlag(flag: QueryFlag): this;
232
- hasFlag(flag: QueryFlag): boolean;
233
- with(name: string, query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment, options?: CteOptions): this;
234
- withRecursive(
235
- name: string,
236
- query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment,
237
- options?: CteOptions,
238
- ): this;
239
- scheduleFilterCheck(path: string): void;
240
- withSchema(schema: string): this;
171
+ readonly alias: string;
172
+ readonly type: QueryType;
173
+ /** @internal */
174
+ state: {
175
+ fields?: InternalField<T>[];
176
+ [key: string]: any;
177
+ };
178
+ /** @internal */
179
+ helper: any;
180
+ select(fields: string | RawQueryFragment | (string | RawQueryFragment)[], distinct?: boolean): this;
181
+ addSelect(fields: string | string[]): this;
182
+ from<T extends object>(target: EntityName<T> | IQueryBuilder<T>, aliasName?: string): IQueryBuilder<T>;
183
+ insert(data: any): this;
184
+ update(data: any): this;
185
+ delete(cond?: FilterQuery<any>): this;
186
+ truncate(): this;
187
+ count(field?: string | string[], distinct?: boolean): this;
188
+ join(field: string, alias: string, cond?: FilterQuery<any>, type?: JoinType, path?: string): this;
189
+ innerJoin(field: string, alias: string, cond?: FilterQuery<any>): this;
190
+ leftJoin(field: string, alias: string, cond?: FilterQuery<any>): this;
191
+ joinAndSelect(field: any, alias: string, cond?: FilterQuery<any>): this;
192
+ leftJoinAndSelect(field: any, alias: string, cond?: FilterQuery<any>, fields?: string[]): this;
193
+ innerJoinAndSelect(field: any, alias: string, cond?: FilterQuery<any>, fields?: string[]): this;
194
+ withSubQuery(subQuery: RawQueryFragment | NativeQueryBuilder, alias: string): this;
195
+ where(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, operator?: keyof typeof GroupOperator | any[], operator2?: keyof typeof GroupOperator): this;
196
+ andWhere(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, params?: any[]): this;
197
+ orWhere(cond: FilterQuery<T> | string | RawQueryFragment | Dictionary, params?: any[]): this;
198
+ orderBy(orderBy: QueryOrderMap<T>): this;
199
+ groupBy(fields: (string | keyof T) | (string | keyof T)[]): this;
200
+ having(cond?: FilterQuery<any> | string, params?: any[]): this;
201
+ getAliasForJoinPath(path: string, options?: ICriteriaNodeProcessOptions): string | undefined;
202
+ getJoinForPath(path?: string, options?: ICriteriaNodeProcessOptions): JoinOptions | undefined;
203
+ getNextAlias(entityName?: string | EntityName<T>): string;
204
+ clone(reset?: boolean | string[], preserve?: string[]): IQueryBuilder<T>;
205
+ setFlag(flag: QueryFlag): this;
206
+ unsetFlag(flag: QueryFlag): this;
207
+ hasFlag(flag: QueryFlag): boolean;
208
+ with(name: string, query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment, options?: CteOptions): this;
209
+ withRecursive(name: string, query: AnyQueryBuilder | NativeQueryBuilder | RawQueryFragment, options?: CteOptions): this;
210
+ scheduleFilterCheck(path: string): void;
211
+ withSchema(schema: string): this;
241
212
  }
242
213
  export interface ICriteriaNodeProcessOptions {
243
- alias?: string;
244
- matchPopulateJoins?: boolean;
245
- ignoreBranching?: boolean;
246
- preferNoBranch?: boolean;
247
- type?: 'orderBy' | 'having';
248
- filter?: boolean;
249
- parentPath?: string;
214
+ alias?: string;
215
+ matchPopulateJoins?: boolean;
216
+ ignoreBranching?: boolean;
217
+ preferNoBranch?: boolean;
218
+ type?: 'orderBy' | 'having';
219
+ filter?: boolean;
220
+ parentPath?: string;
250
221
  }
251
222
  export interface ICriteriaNode<T extends object> {
252
- readonly entityName: EntityName<T>;
253
- readonly parent?: ICriteriaNode<T> | undefined;
254
- readonly key?: string | symbol | undefined;
255
- readonly strict?: boolean;
256
- payload: any;
257
- prop?: EntityProperty;
258
- index?: number;
259
- process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
260
- shouldInline(payload: any): boolean;
261
- willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
262
- shouldRename(payload: any): boolean;
263
- renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string): string;
264
- getPath(opts?: { addIndex?: boolean }): string;
265
- getPivotPath(path: string): string;
223
+ readonly entityName: EntityName<T>;
224
+ readonly parent?: ICriteriaNode<T> | undefined;
225
+ readonly key?: string | symbol | undefined;
226
+ readonly strict?: boolean;
227
+ payload: any;
228
+ prop?: EntityProperty;
229
+ index?: number;
230
+ process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
231
+ shouldInline(payload: any): boolean;
232
+ willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
233
+ shouldRename(payload: any): boolean;
234
+ renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string): string;
235
+ getPath(opts?: {
236
+ addIndex?: boolean;
237
+ }): string;
238
+ getPivotPath(path: string): string;
266
239
  }
267
240
  export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
268
- export type InferEntityProperties<Schema> =
269
- Schema extends EntitySchemaWithMeta<any, any, any, any, infer Properties> ? Properties : never;
270
- export type InferKyselyDB<
271
- TEntities extends {
241
+ export type InferEntityProperties<Schema> = Schema extends EntitySchemaWithMeta<any, any, any, any, infer Properties> ? Properties : never;
242
+ export type InferKyselyDB<TEntities extends {
272
243
  name: string;
273
- },
274
- TOptions extends MikroKyselyPluginOptions = {},
275
- > = MapValueAsTable<MapTableName<TEntities, TOptions>, TOptions>;
244
+ }, TOptions extends MikroKyselyPluginOptions = {}> = MapValueAsTable<MapTableName<TEntities, TOptions>, TOptions>;
276
245
  export type InferDBFromKysely<TKysely extends Kysely<any>> = TKysely extends Kysely<infer TDB> ? TDB : never;
277
- type PreferStringLiteral<TCandidate, TFallback> = [TCandidate] extends [never]
278
- ? TFallback
279
- : string extends TCandidate
280
- ? TFallback
281
- : TCandidate extends string
282
- ? TCandidate
283
- : TFallback;
284
- export type MapTableName<
285
- T extends {
246
+ type PreferStringLiteral<TCandidate, TFallback> = [TCandidate] extends [never] ? TFallback : string extends TCandidate ? TFallback : TCandidate extends string ? TCandidate : TFallback;
247
+ export type MapTableName<T extends {
286
248
  name: string;
287
249
  tableName?: string;
288
- },
289
- TOptions extends MikroKyselyPluginOptions = {},
290
- > = {
291
- [P in T as TOptions['tableNamingStrategy'] extends 'entity'
292
- ? P['name']
293
- : PreferStringLiteral<NonNullable<P['tableName']>, P['name']>]: P;
250
+ }, TOptions extends MikroKyselyPluginOptions = {}> = {
251
+ [P in T as TOptions['tableNamingStrategy'] extends 'entity' ? P['name'] : PreferStringLiteral<NonNullable<P['tableName']>, P['name']>]: P;
294
252
  };
295
253
  export type MapValueAsTable<TMap extends Record<string, any>, TOptions extends MikroKyselyPluginOptions = {}> = {
296
- [K in keyof TMap as TransformName<
297
- K,
298
- TOptions['tableNamingStrategy'] extends 'entity' ? 'entity' : 'underscore'
299
- >]: InferKyselyTable<TMap[K], TOptions>;
254
+ [K in keyof TMap as TransformName<K, TOptions['tableNamingStrategy'] extends 'entity' ? 'entity' : 'underscore'>]: InferKyselyTable<TMap[K], TOptions>;
300
255
  };
301
- export type InferKyselyTable<
302
- TSchema extends EntitySchemaWithMeta,
303
- TOptions extends MikroKyselyPluginOptions = {},
304
- > = ExcludeNever<{
305
- -readonly [K in keyof InferEntityProperties<TSchema> as TransformColumnName<
306
- K,
307
- TOptions['columnNamingStrategy'] extends 'property' ? 'property' : 'underscore',
308
- MaybeReturnType<InferEntityProperties<TSchema>[K]>
309
- >]: InferColumnValue<
310
- MaybeReturnType<InferEntityProperties<TSchema>[K]>,
311
- TOptions['processOnCreateHooks'] extends true ? true : false
312
- >;
256
+ export type InferKyselyTable<TSchema extends EntitySchemaWithMeta, TOptions extends MikroKyselyPluginOptions = {}> = ExcludeNever<{
257
+ -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>;
313
258
  }>;
314
- type TransformName<TName, TNamingStrategy extends 'underscore' | 'entity'> = TNamingStrategy extends 'underscore'
315
- ? TName extends string
316
- ? SnakeCase<TName>
317
- : TName
318
- : TName;
319
- type TransformColumnName<
320
- TName,
321
- TNamingStrategy extends 'underscore' | 'property',
322
- TBuilder,
323
- > = TNamingStrategy extends 'property'
324
- ? TName
325
- : TBuilder extends {
326
- '~options': {
327
- fieldName: string;
328
- };
329
- }
330
- ? TBuilder['~options']['fieldName']
331
- : TName extends string
332
- ? MaybeJoinColumnName<SnakeCase<TName>, TBuilder>
333
- : never;
259
+ type TransformName<TName, TNamingStrategy extends 'underscore' | 'entity'> = TNamingStrategy extends 'underscore' ? TName extends string ? SnakeCase<TName> : TName : TName;
260
+ type TransformColumnName<TName, TNamingStrategy extends 'underscore' | 'property', TBuilder> = TNamingStrategy extends 'property' ? TName : TBuilder extends {
261
+ '~options': {
262
+ fieldName: string;
263
+ };
264
+ } ? TBuilder['~options']['fieldName'] : TName extends string ? MaybeJoinColumnName<SnakeCase<TName>, TBuilder> : never;
334
265
  type MaybeJoinColumnName<TName extends string, TBuilder> = TBuilder extends {
335
- '~type'?: {
336
- value: infer Value;
337
- };
338
- '~options': {
339
- kind: 'm:1';
340
- };
341
- }
342
- ? PrimaryProperty<Value> extends string
343
- ? `${TName}_${SnakeCase<PrimaryProperty<Value>>}`
344
- : never
345
- : TBuilder extends {
346
- '~type'?: {
347
- value: infer Value;
348
- };
349
- '~options': {
350
- kind: '1:1';
351
- owner: true;
352
- };
353
- }
354
- ? PrimaryProperty<Value> extends string
355
- ? `${TName}_${SnakeCase<PrimaryProperty<Value>>}`
356
- : never
357
- : TName;
358
- export type SnakeCase<TName extends string> = TName extends `${infer A}${infer B}${infer Rest}`
359
- ? IsUpperLetter<B> extends never
360
- ? `${Lowercase<A>}${SnakeCase<`${B}${Rest}`>}`
361
- : IsLowerLetter<A> extends never
362
- ? `${Lowercase<A>}${SnakeCase<`${B}${Rest}`>}`
363
- : `${Lowercase<A>}_${SnakeCase<`${B}${Rest}`>}`
364
- : Lowercase<TName>;
266
+ '~type'?: {
267
+ value: infer Value;
268
+ };
269
+ '~options': {
270
+ kind: 'm:1';
271
+ };
272
+ } ? PrimaryProperty<Value> extends string ? `${TName}_${SnakeCase<PrimaryProperty<Value>>}` : never : TBuilder extends {
273
+ '~type'?: {
274
+ value: infer Value;
275
+ };
276
+ '~options': {
277
+ kind: '1:1';
278
+ owner: true;
279
+ };
280
+ } ? PrimaryProperty<Value> extends string ? `${TName}_${SnakeCase<PrimaryProperty<Value>>}` : never : TName;
281
+ 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>;
365
282
  type IsLowerLetter<C extends string> = C extends Lowercase<C> ? (C extends Uppercase<C> ? never : C) : never;
366
283
  type IsUpperLetter<C extends string> = C extends Uppercase<C> ? (C extends Lowercase<C> ? never : C) : never;
367
284
  type InferColumnValue<TBuilder, TProcessOnCreate extends boolean> = TBuilder extends {
368
- '~type'?: {
369
- value: infer Value;
370
- };
371
- '~options': infer TOptions;
372
- }
373
- ? MaybeNever<MaybeGenerated<MaybeJoinKey<Value, TOptions>, TOptions, TProcessOnCreate>, TOptions>
374
- : never;
285
+ '~type'?: {
286
+ value: infer Value;
287
+ };
288
+ '~options': infer TOptions;
289
+ } ? MaybeNever<MaybeGenerated<MaybeJoinKey<Value, TOptions>, TOptions, TProcessOnCreate>, TOptions> : never;
375
290
  type MaybeGenerated<TValue, TOptions, TProcessOnCreate extends boolean> = TOptions extends {
376
- nullable: true;
377
- }
378
- ? TValue | null
379
- : TOptions extends {
380
- autoincrement: true;
381
- }
382
- ? Generated<TValue>
383
- : TOptions extends {
384
- default: true;
385
- }
386
- ? Generated<TValue>
387
- : TOptions extends {
388
- defaultRaw: true;
389
- }
390
- ? Generated<TValue>
391
- : TProcessOnCreate extends false
392
- ? TValue
393
- : TOptions extends {
394
- onCreate: Function;
395
- }
396
- ? Generated<TValue>
397
- : TValue;
291
+ nullable: true;
292
+ } ? TValue | null : TOptions extends {
293
+ autoincrement: true;
294
+ } ? Generated<TValue> : TOptions extends {
295
+ default: true;
296
+ } ? Generated<TValue> : TOptions extends {
297
+ defaultRaw: true;
298
+ } ? Generated<TValue> : TProcessOnCreate extends false ? TValue : TOptions extends {
299
+ onCreate: Function;
300
+ } ? Generated<TValue> : TValue;
398
301
  type MaybeJoinKey<TValue, TOptions> = TOptions extends {
399
- kind: 'm:1';
400
- }
401
- ? UnwrapOpt<Primary<TValue>>
402
- : TOptions extends {
403
- kind: '1:1';
404
- }
405
- ? TOptions extends {
406
- owner: true;
407
- }
408
- ? UnwrapOpt<Primary<TValue>>
409
- : never
410
- : TValue;
302
+ kind: 'm:1';
303
+ } ? UnwrapOpt<Primary<TValue>> : TOptions extends {
304
+ kind: '1:1';
305
+ } ? TOptions extends {
306
+ owner: true;
307
+ } ? UnwrapOpt<Primary<TValue>> : never : TValue;
411
308
  type UnwrapOpt<TValue> = TValue extends Opt<infer OriginalValue> ? OriginalValue : TValue;
412
- type MaybeNever<TValue, TOptions> = TOptions extends
413
- | {
414
- persist: false;
415
- }
416
- | {
417
- kind: 'm:n' | '1:m';
418
- }
419
- ? never
420
- : TValue;
309
+ type MaybeNever<TValue, TOptions> = TOptions extends {
310
+ persist: false;
311
+ } | {
312
+ kind: 'm:n' | '1:m';
313
+ } ? never : TValue;
421
314
  type ExcludeNever<TMap extends Record<string, any>> = {
422
- [K in keyof TMap as TMap[K] extends never ? never : K]: TMap[K];
315
+ [K in keyof TMap as TMap[K] extends never ? never : K]: TMap[K];
423
316
  };
424
- export type InferClassEntityDB<TEntities, TOptions extends MikroKyselyPluginOptions = {}> =
425
- ClassEntityDBMap<TEntities, TOptions> extends infer R ? ([keyof R] extends [never] ? unknown : R) : never;
317
+ export type InferClassEntityDB<TEntities, TOptions extends MikroKyselyPluginOptions = {}> = ClassEntityDBMap<TEntities, TOptions> extends infer R ? ([keyof R] extends [never] ? unknown : R) : never;
426
318
  type ClassEntityDBMap<TEntities, TOptions extends MikroKyselyPluginOptions = {}> = {
427
- [T in TEntities as ClassEntityTableName<T, TOptions>]: ClassEntityColumns<T>;
319
+ [T in TEntities as ClassEntityTableName<T, TOptions>]: ClassEntityColumns<T>;
428
320
  };
429
- type ClassEntityTableName<T, TOptions extends MikroKyselyPluginOptions = {}> = T extends abstract new (
430
- ...args: any[]
431
- ) => infer Instance
432
- ? TransformName<InferEntityName<Instance>, TOptions['tableNamingStrategy'] extends 'entity' ? 'entity' : 'underscore'>
433
- : never;
434
- type ClassEntityColumns<T> = T extends abstract new (...args: any[]) => infer Instance
435
- ? {
436
- [K in keyof Instance as IsClassEntityColumn<K, Instance[K]>]: Instance[K];
437
- }
438
- : never;
321
+ type ClassEntityTableName<T, TOptions extends MikroKyselyPluginOptions = {}> = T extends abstract new (...args: any[]) => infer Instance ? TransformName<InferEntityName<Instance>, TOptions['tableNamingStrategy'] extends 'entity' ? 'entity' : 'underscore'> : never;
322
+ type ClassEntityColumns<T> = T extends abstract new (...args: any[]) => infer Instance ? {
323
+ [K in keyof Instance as IsClassEntityColumn<K, Instance[K]>]: Instance[K];
324
+ } : never;
439
325
  type IsClassEntityColumn<K, V> = K extends symbol ? never : NonNullable<V> extends Scalar ? K : never;
440
326
  export {};