@mikro-orm/core 7.0.0-dev.7 → 7.0.0-dev.70

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 (162) hide show
  1. package/EntityManager.d.ts +85 -42
  2. package/EntityManager.js +282 -194
  3. package/MikroORM.d.ts +11 -29
  4. package/MikroORM.js +33 -127
  5. package/README.md +3 -2
  6. package/cache/FileCacheAdapter.d.ts +2 -1
  7. package/cache/FileCacheAdapter.js +5 -4
  8. package/connections/Connection.d.ts +11 -7
  9. package/connections/Connection.js +16 -13
  10. package/drivers/DatabaseDriver.d.ts +11 -5
  11. package/drivers/DatabaseDriver.js +13 -4
  12. package/drivers/IDatabaseDriver.d.ts +27 -5
  13. package/entity/BaseEntity.d.ts +0 -1
  14. package/entity/BaseEntity.js +0 -3
  15. package/entity/Collection.d.ts +98 -30
  16. package/entity/Collection.js +432 -93
  17. package/entity/EntityAssigner.d.ts +1 -1
  18. package/entity/EntityAssigner.js +9 -1
  19. package/entity/EntityFactory.d.ts +7 -0
  20. package/entity/EntityFactory.js +63 -40
  21. package/entity/EntityHelper.js +26 -9
  22. package/entity/EntityLoader.d.ts +5 -4
  23. package/entity/EntityLoader.js +69 -36
  24. package/entity/EntityRepository.d.ts +1 -1
  25. package/entity/EntityValidator.js +4 -4
  26. package/entity/Reference.d.ts +9 -7
  27. package/entity/Reference.js +32 -5
  28. package/entity/WrappedEntity.d.ts +0 -2
  29. package/entity/WrappedEntity.js +1 -5
  30. package/entity/defineEntity.d.ts +549 -0
  31. package/entity/defineEntity.js +529 -0
  32. package/entity/index.d.ts +2 -1
  33. package/entity/index.js +2 -1
  34. package/entity/utils.d.ts +7 -0
  35. package/entity/utils.js +15 -3
  36. package/enums.d.ts +20 -5
  37. package/enums.js +13 -0
  38. package/errors.d.ts +6 -1
  39. package/errors.js +14 -4
  40. package/events/EventSubscriber.d.ts +3 -1
  41. package/hydration/ObjectHydrator.d.ts +4 -4
  42. package/hydration/ObjectHydrator.js +35 -24
  43. package/index.d.ts +2 -2
  44. package/index.js +1 -2
  45. package/logging/DefaultLogger.d.ts +1 -1
  46. package/logging/SimpleLogger.d.ts +1 -1
  47. package/metadata/EntitySchema.d.ts +9 -13
  48. package/metadata/EntitySchema.js +44 -26
  49. package/metadata/MetadataDiscovery.d.ts +6 -7
  50. package/metadata/MetadataDiscovery.js +161 -162
  51. package/metadata/MetadataProvider.d.ts +2 -2
  52. package/metadata/MetadataProvider.js +15 -0
  53. package/metadata/MetadataStorage.d.ts +0 -4
  54. package/metadata/MetadataStorage.js +7 -11
  55. package/metadata/MetadataValidator.d.ts +0 -7
  56. package/metadata/MetadataValidator.js +4 -13
  57. package/metadata/discover-entities.d.ts +5 -0
  58. package/metadata/discover-entities.js +39 -0
  59. package/metadata/index.d.ts +1 -1
  60. package/metadata/index.js +1 -1
  61. package/metadata/types.d.ts +480 -0
  62. package/metadata/types.js +1 -0
  63. package/naming-strategy/AbstractNamingStrategy.d.ts +5 -1
  64. package/naming-strategy/AbstractNamingStrategy.js +7 -1
  65. package/naming-strategy/NamingStrategy.d.ts +11 -1
  66. package/package.json +11 -10
  67. package/platforms/Platform.d.ts +6 -10
  68. package/platforms/Platform.js +6 -22
  69. package/serialization/EntitySerializer.d.ts +2 -0
  70. package/serialization/EntitySerializer.js +29 -11
  71. package/serialization/EntityTransformer.js +22 -12
  72. package/serialization/SerializationContext.js +14 -11
  73. package/types/ArrayType.d.ts +1 -1
  74. package/types/ArrayType.js +1 -2
  75. package/types/BigIntType.d.ts +8 -6
  76. package/types/BlobType.d.ts +0 -1
  77. package/types/BlobType.js +0 -3
  78. package/types/BooleanType.d.ts +2 -1
  79. package/types/BooleanType.js +3 -0
  80. package/types/DecimalType.d.ts +6 -4
  81. package/types/DecimalType.js +1 -1
  82. package/types/DoubleType.js +1 -1
  83. package/types/JsonType.d.ts +1 -1
  84. package/types/JsonType.js +7 -2
  85. package/types/Type.d.ts +2 -1
  86. package/types/Type.js +1 -1
  87. package/types/Uint8ArrayType.d.ts +0 -1
  88. package/types/Uint8ArrayType.js +0 -3
  89. package/types/index.d.ts +1 -1
  90. package/typings.d.ts +112 -77
  91. package/typings.js +32 -32
  92. package/unit-of-work/ChangeSetComputer.js +8 -3
  93. package/unit-of-work/ChangeSetPersister.d.ts +4 -2
  94. package/unit-of-work/ChangeSetPersister.js +37 -16
  95. package/unit-of-work/UnitOfWork.d.ts +8 -1
  96. package/unit-of-work/UnitOfWork.js +111 -54
  97. package/utils/AbstractSchemaGenerator.d.ts +5 -5
  98. package/utils/AbstractSchemaGenerator.js +10 -8
  99. package/utils/Configuration.d.ts +202 -191
  100. package/utils/Configuration.js +143 -153
  101. package/utils/ConfigurationLoader.d.ts +3 -44
  102. package/utils/ConfigurationLoader.js +26 -239
  103. package/utils/Cursor.d.ts +3 -3
  104. package/utils/Cursor.js +3 -0
  105. package/utils/DataloaderUtils.d.ts +15 -5
  106. package/utils/DataloaderUtils.js +53 -7
  107. package/utils/EntityComparator.d.ts +8 -4
  108. package/utils/EntityComparator.js +107 -60
  109. package/utils/QueryHelper.d.ts +9 -1
  110. package/utils/QueryHelper.js +69 -8
  111. package/utils/RawQueryFragment.d.ts +36 -4
  112. package/utils/RawQueryFragment.js +34 -13
  113. package/utils/TransactionManager.d.ts +65 -0
  114. package/utils/TransactionManager.js +223 -0
  115. package/utils/Utils.d.ts +18 -85
  116. package/utils/Utils.js +128 -252
  117. package/utils/index.d.ts +1 -0
  118. package/utils/index.js +1 -0
  119. package/utils/upsert-utils.d.ts +7 -2
  120. package/utils/upsert-utils.js +52 -1
  121. package/decorators/Check.d.ts +0 -3
  122. package/decorators/Check.js +0 -13
  123. package/decorators/CreateRequestContext.d.ts +0 -3
  124. package/decorators/CreateRequestContext.js +0 -32
  125. package/decorators/Embeddable.d.ts +0 -8
  126. package/decorators/Embeddable.js +0 -11
  127. package/decorators/Embedded.d.ts +0 -18
  128. package/decorators/Embedded.js +0 -18
  129. package/decorators/Entity.d.ts +0 -18
  130. package/decorators/Entity.js +0 -12
  131. package/decorators/Enum.d.ts +0 -9
  132. package/decorators/Enum.js +0 -16
  133. package/decorators/Filter.d.ts +0 -2
  134. package/decorators/Filter.js +0 -8
  135. package/decorators/Formula.d.ts +0 -4
  136. package/decorators/Formula.js +0 -15
  137. package/decorators/Indexed.d.ts +0 -19
  138. package/decorators/Indexed.js +0 -20
  139. package/decorators/ManyToMany.d.ts +0 -40
  140. package/decorators/ManyToMany.js +0 -14
  141. package/decorators/ManyToOne.d.ts +0 -30
  142. package/decorators/ManyToOne.js +0 -14
  143. package/decorators/OneToMany.d.ts +0 -28
  144. package/decorators/OneToMany.js +0 -17
  145. package/decorators/OneToOne.d.ts +0 -24
  146. package/decorators/OneToOne.js +0 -7
  147. package/decorators/PrimaryKey.d.ts +0 -8
  148. package/decorators/PrimaryKey.js +0 -20
  149. package/decorators/Property.d.ts +0 -250
  150. package/decorators/Property.js +0 -32
  151. package/decorators/Transactional.d.ts +0 -13
  152. package/decorators/Transactional.js +0 -28
  153. package/decorators/hooks.d.ts +0 -16
  154. package/decorators/hooks.js +0 -47
  155. package/decorators/index.d.ts +0 -17
  156. package/decorators/index.js +0 -17
  157. package/entity/ArrayCollection.d.ts +0 -116
  158. package/entity/ArrayCollection.js +0 -402
  159. package/metadata/ReflectMetadataProvider.d.ts +0 -8
  160. package/metadata/ReflectMetadataProvider.js +0 -44
  161. package/utils/resolveContextProvider.d.ts +0 -10
  162. package/utils/resolveContextProvider.js +0 -28
@@ -5,133 +5,137 @@ import { NullHighlighter } from '../utils/NullHighlighter.js';
5
5
  import { DefaultLogger } from '../logging/DefaultLogger.js';
6
6
  import { colors } from '../logging/colors.js';
7
7
  import { Utils } from '../utils/Utils.js';
8
- import { ReflectMetadataProvider } from '../metadata/ReflectMetadataProvider.js';
8
+ import { MetadataProvider } from '../metadata/MetadataProvider.js';
9
9
  import { NotFoundError } from '../errors.js';
10
10
  import { RequestContext } from './RequestContext.js';
11
11
  import { DataloaderType, FlushMode, LoadStrategy, PopulateHint } from '../enums.js';
12
12
  import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
13
13
  import { EntityComparator } from './EntityComparator.js';
14
+ const DEFAULTS = {
15
+ pool: {},
16
+ entities: [],
17
+ entitiesTs: [],
18
+ extensions: [],
19
+ subscribers: [],
20
+ filters: {},
21
+ discovery: {
22
+ warnWhenNoEntities: true,
23
+ checkDuplicateTableNames: true,
24
+ checkDuplicateFieldNames: true,
25
+ checkDuplicateEntities: true,
26
+ checkNonPersistentCompositeProps: true,
27
+ inferDefaultValues: true,
28
+ },
29
+ strict: false,
30
+ validate: false,
31
+ validateRequired: true,
32
+ context: (name) => RequestContext.getEntityManager(name),
33
+ contextName: 'default',
34
+ allowGlobalContext: false,
35
+ // eslint-disable-next-line no-console
36
+ logger: console.log.bind(console),
37
+ colors: true,
38
+ findOneOrFailHandler: (entityName, where) => NotFoundError.findOneFailed(entityName, where),
39
+ findExactlyOneOrFailHandler: (entityName, where) => NotFoundError.findExactlyOneFailed(entityName, where),
40
+ baseDir: process.cwd(),
41
+ hydrator: ObjectHydrator,
42
+ flushMode: FlushMode.AUTO,
43
+ loadStrategy: LoadStrategy.BALANCED,
44
+ dataloader: DataloaderType.NONE,
45
+ populateWhere: PopulateHint.ALL,
46
+ ignoreUndefinedInQuery: false,
47
+ onQuery: (sql) => sql,
48
+ autoJoinOneToOneOwner: true,
49
+ autoJoinRefsForFilters: true,
50
+ filtersOnRelations: true,
51
+ propagationOnPrototype: true,
52
+ populateAfterFlush: true,
53
+ serialization: {
54
+ includePrimaryKeys: true,
55
+ },
56
+ assign: {
57
+ updateNestedEntities: true,
58
+ updateByPrimaryKey: true,
59
+ mergeObjectProperties: false,
60
+ mergeEmbeddedProperties: true,
61
+ ignoreUndefined: false,
62
+ },
63
+ persistOnCreate: true,
64
+ upsertManaged: true,
65
+ forceEntityConstructor: false,
66
+ forceUndefined: false,
67
+ processOnCreateHooksEarly: false,
68
+ ensureDatabase: true,
69
+ ensureIndexes: false,
70
+ batchSize: 300,
71
+ hashAlgorithm: 'md5',
72
+ debug: false,
73
+ ignoreDeprecations: false,
74
+ verbose: false,
75
+ driverOptions: {},
76
+ migrations: {
77
+ tableName: 'mikro_orm_migrations',
78
+ path: './migrations',
79
+ glob: '!(*.d).{js,ts,cjs}',
80
+ silent: false,
81
+ transactional: true,
82
+ disableForeignKeys: false,
83
+ allOrNothing: true,
84
+ dropTables: true,
85
+ safe: false,
86
+ snapshot: true,
87
+ emit: 'ts',
88
+ fileName: (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`,
89
+ },
90
+ schemaGenerator: {
91
+ disableForeignKeys: false,
92
+ createForeignKeyConstraints: true,
93
+ ignoreSchema: [],
94
+ skipTables: [],
95
+ skipColumns: {},
96
+ },
97
+ embeddables: {
98
+ prefixMode: 'relative',
99
+ },
100
+ entityGenerator: {
101
+ forceUndefined: true,
102
+ undefinedDefaults: false,
103
+ scalarTypeInDecorator: false,
104
+ bidirectionalRelations: true,
105
+ identifiedReferences: true,
106
+ scalarPropertiesForRelations: 'never',
107
+ entityDefinition: 'defineEntity',
108
+ decorators: 'legacy',
109
+ enumMode: 'dictionary',
110
+ fileName: (className) => className,
111
+ onlyPurePivotTables: false,
112
+ outputPurePivotTables: false,
113
+ readOnlyPivotTables: false,
114
+ useCoreBaseEntity: false,
115
+ },
116
+ metadataCache: {
117
+ pretty: false,
118
+ adapter: FileCacheAdapter,
119
+ options: { cacheDir: process.cwd() + '/temp' },
120
+ },
121
+ resultCache: {
122
+ adapter: MemoryCacheAdapter,
123
+ expiration: 1000, // 1s
124
+ options: {},
125
+ },
126
+ metadataProvider: MetadataProvider,
127
+ highlighter: new NullHighlighter(),
128
+ seeder: {
129
+ path: './seeders',
130
+ defaultSeeder: 'DatabaseSeeder',
131
+ glob: '!(*.d).{js,ts}',
132
+ emit: 'ts',
133
+ fileName: (className) => className,
134
+ },
135
+ preferReadReplicas: true,
136
+ dynamicImportProvider: /* v8 ignore next */ (id) => import(id),
137
+ };
14
138
  export class Configuration {
15
- static DEFAULTS = {
16
- pool: {},
17
- entities: [],
18
- entitiesTs: [],
19
- extensions: [],
20
- subscribers: [],
21
- filters: {},
22
- discovery: {
23
- warnWhenNoEntities: true,
24
- requireEntitiesArray: false,
25
- checkDuplicateTableNames: true,
26
- checkDuplicateFieldNames: true,
27
- checkDuplicateEntities: true,
28
- checkNonPersistentCompositeProps: true,
29
- alwaysAnalyseProperties: true,
30
- disableDynamicFileAccess: false,
31
- inferDefaultValues: true,
32
- },
33
- strict: false,
34
- validate: false,
35
- validateRequired: true,
36
- context: (name) => RequestContext.getEntityManager(name),
37
- contextName: 'default',
38
- allowGlobalContext: false,
39
- // eslint-disable-next-line no-console
40
- logger: console.log.bind(console),
41
- colors: true,
42
- findOneOrFailHandler: (entityName, where) => NotFoundError.findOneFailed(entityName, where),
43
- findExactlyOneOrFailHandler: (entityName, where) => NotFoundError.findExactlyOneFailed(entityName, where),
44
- baseDir: process.cwd(),
45
- hydrator: ObjectHydrator,
46
- flushMode: FlushMode.AUTO,
47
- loadStrategy: LoadStrategy.JOINED,
48
- dataloader: DataloaderType.NONE,
49
- populateWhere: PopulateHint.ALL,
50
- connect: true,
51
- ignoreUndefinedInQuery: false,
52
- onQuery: sql => sql,
53
- autoJoinOneToOneOwner: true,
54
- autoJoinRefsForFilters: true,
55
- propagationOnPrototype: true,
56
- populateAfterFlush: true,
57
- serialization: {
58
- includePrimaryKeys: true,
59
- },
60
- assign: {
61
- updateNestedEntities: true,
62
- updateByPrimaryKey: true,
63
- mergeObjectProperties: false,
64
- mergeEmbeddedProperties: true,
65
- ignoreUndefined: false,
66
- },
67
- persistOnCreate: true,
68
- upsertManaged: true,
69
- forceEntityConstructor: false,
70
- forceUndefined: false,
71
- ensureDatabase: true,
72
- ensureIndexes: false,
73
- batchSize: 300,
74
- debug: false,
75
- ignoreDeprecations: false,
76
- verbose: false,
77
- driverOptions: {},
78
- migrations: {
79
- tableName: 'mikro_orm_migrations',
80
- path: './migrations',
81
- glob: '!(*.d).{js,ts,cjs}',
82
- silent: false,
83
- transactional: true,
84
- disableForeignKeys: false,
85
- allOrNothing: true,
86
- dropTables: true,
87
- safe: false,
88
- snapshot: true,
89
- emit: 'ts',
90
- fileName: (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`,
91
- },
92
- schemaGenerator: {
93
- disableForeignKeys: false,
94
- createForeignKeyConstraints: true,
95
- ignoreSchema: [],
96
- },
97
- embeddables: {
98
- prefixMode: 'absolute',
99
- },
100
- entityGenerator: {
101
- forceUndefined: true,
102
- undefinedDefaults: false,
103
- bidirectionalRelations: false,
104
- identifiedReferences: false,
105
- scalarTypeInDecorator: false,
106
- scalarPropertiesForRelations: 'never',
107
- fileName: (className) => className,
108
- onlyPurePivotTables: false,
109
- outputPurePivotTables: false,
110
- readOnlyPivotTables: false,
111
- useCoreBaseEntity: false,
112
- },
113
- metadataCache: {
114
- pretty: false,
115
- adapter: FileCacheAdapter,
116
- options: { cacheDir: process.cwd() + '/temp' },
117
- },
118
- resultCache: {
119
- adapter: MemoryCacheAdapter,
120
- expiration: 1000, // 1s
121
- options: {},
122
- },
123
- metadataProvider: ReflectMetadataProvider,
124
- highlighter: new NullHighlighter(),
125
- seeder: {
126
- path: './seeders',
127
- defaultSeeder: 'DatabaseSeeder',
128
- glob: '!(*.d).{js,ts}',
129
- emit: 'ts',
130
- fileName: (className) => className,
131
- },
132
- preferReadReplicas: true,
133
- dynamicImportProvider: /* v8 ignore next */ (id) => import(id),
134
- };
135
139
  options;
136
140
  logger;
137
141
  driver;
@@ -140,11 +144,10 @@ export class Configuration {
140
144
  extensions = new Map();
141
145
  constructor(options, validate = true) {
142
146
  if (options.dynamicImportProvider) {
143
- Utils.setDynamicImportProvider(options.dynamicImportProvider);
147
+ Utils.dynamicImportProvider = options.dynamicImportProvider;
144
148
  }
145
- this.options = Utils.mergeConfig({}, Configuration.DEFAULTS, options);
149
+ this.options = Utils.mergeConfig({}, DEFAULTS, options);
146
150
  this.options.baseDir = Utils.absolutePath(this.options.baseDir);
147
- this.options.preferTs ??= options.preferTs;
148
151
  if (validate) {
149
152
  this.validateOptions();
150
153
  }
@@ -190,7 +193,7 @@ export class Configuration {
190
193
  * Resets the configuration to its default value
191
194
  */
192
195
  reset(key) {
193
- this.options[key] = Configuration.DEFAULTS[key];
196
+ this.options[key] = DEFAULTS[key];
194
197
  }
195
198
  /**
196
199
  * Gets Logger instance.
@@ -204,15 +207,6 @@ export class Configuration {
204
207
  }
205
208
  return this.options.dataloader;
206
209
  }
207
- /**
208
- * Gets current client URL (connection string).
209
- */
210
- getClientUrl(hidePassword = false) {
211
- if (hidePassword) {
212
- return this.options.clientUrl.replace(/\/\/([^:]+):(.+)@/, '//$1:*****@');
213
- }
214
- return this.options.clientUrl;
215
- }
216
210
  getSchema(skipDefaultSchema = false) {
217
211
  if (skipDefaultSchema && this.options.schema === this.platform.getDefaultSchemaName()) {
218
212
  return undefined;
@@ -268,7 +262,7 @@ export class Configuration {
268
262
  * Gets instance of metadata CacheAdapter. (cached)
269
263
  */
270
264
  getMetadataCacheAdapter() {
271
- return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty);
265
+ return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty, this.options.hashAlgorithm);
272
266
  }
273
267
  /**
274
268
  * Gets instance of CacheAdapter for result cache. (cached)
@@ -293,8 +287,7 @@ export class Configuration {
293
287
  */
294
288
  getCachedService(cls, ...args) {
295
289
  if (!this.cache.has(cls.name)) {
296
- const Class = cls;
297
- this.cache.set(cls.name, new Class(...args));
290
+ this.cache.set(cls.name, new cls(...args));
298
291
  }
299
292
  return this.cache.get(cls.name);
300
293
  }
@@ -311,17 +304,15 @@ export class Configuration {
311
304
  if (!this.options.clientUrl) {
312
305
  this.options.clientUrl = this.platform.getDefaultClientUrl();
313
306
  }
314
- if (!('implicitTransactions' in this.options)) {
315
- this.options.implicitTransactions = this.platform.usesImplicitTransactions();
316
- }
307
+ this.options.implicitTransactions ??= this.platform.usesImplicitTransactions();
317
308
  try {
318
- const url = new URL(this.getClientUrl());
309
+ const url = new URL(this.options.clientUrl);
319
310
  if (url.pathname) {
320
311
  this.options.dbName = this.get('dbName', decodeURIComponent(url.pathname).substring(1));
321
312
  }
322
313
  }
323
314
  catch {
324
- const url = this.getClientUrl().match(/:\/\/.*\/([^?]+)/);
315
+ const url = this.options.clientUrl.match(/:\/\/.*\/([^?]+)/);
325
316
  if (url) {
326
317
  this.options.dbName = this.get('dbName', decodeURIComponent(url[1]));
327
318
  }
@@ -329,15 +320,14 @@ export class Configuration {
329
320
  if (validate && !this.options.dbName && this.options.clientUrl) {
330
321
  throw new Error("No database specified, `clientUrl` option provided but it's missing the pathname.");
331
322
  }
332
- if (!this.options.schema) {
333
- this.options.schema = this.platform.getDefaultSchemaName();
334
- }
335
- if (!this.options.charset) {
336
- this.options.charset = this.platform.getDefaultCharset();
337
- }
323
+ this.options.schema ??= this.platform.getDefaultSchemaName();
324
+ this.options.charset ??= this.platform.getDefaultCharset();
338
325
  Object.keys(this.options.filters).forEach(key => {
339
326
  this.options.filters[key].default ??= true;
340
327
  });
328
+ if (!this.options.filtersOnRelations) {
329
+ this.options.autoJoinRefsForFilters ??= false;
330
+ }
341
331
  this.options.subscribers = Utils.unique(this.options.subscribers).map(subscriber => {
342
332
  return subscriber.constructor.name === 'Function' ? new subscriber() : subscriber;
343
333
  });
@@ -359,13 +349,13 @@ export class Configuration {
359
349
  * break existing projects, only help with the new ones.
360
350
  */
361
351
  detectSourceFolder(options) {
362
- if (!Utils.pathExistsSync(this.options.baseDir + '/src')) {
352
+ if (!Utils.pathExists(this.options.baseDir + '/src')) {
363
353
  return;
364
354
  }
365
- const migrationsPathExists = Utils.pathExistsSync(this.options.baseDir + '/' + this.options.migrations.path);
366
- const seedersPathExists = Utils.pathExistsSync(this.options.baseDir + '/' + this.options.seeder.path);
367
- const distDir = Utils.pathExistsSync(this.options.baseDir + '/dist');
368
- const buildDir = Utils.pathExistsSync(this.options.baseDir + '/build');
355
+ const migrationsPathExists = Utils.pathExists(this.options.baseDir + '/' + this.options.migrations.path);
356
+ const seedersPathExists = Utils.pathExists(this.options.baseDir + '/' + this.options.seeder.path);
357
+ const distDir = Utils.pathExists(this.options.baseDir + '/dist');
358
+ const buildDir = Utils.pathExists(this.options.baseDir + '/build');
369
359
  // if neither `dist` nor `build` exist, we use the `src` folder as it might be a JS project without building, but with `src` folder
370
360
  const path = distDir ? './dist' : (buildDir ? './build' : './src');
371
361
  // only if the user did not provide any values and if the default path does not exist
@@ -1,54 +1,13 @@
1
- import type { EntityManager } from '../EntityManager.js';
2
- import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
1
+ import type { IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
3
2
  import type { Dictionary } from '../typings.js';
4
- import { Configuration, type Options } from './Configuration.js';
3
+ import { type Options } from './Configuration.js';
5
4
  /**
6
5
  * @internal
7
6
  */
8
7
  export declare class ConfigurationLoader {
9
- /**
10
- * Gets a named configuration
11
- *
12
- * @param contextName Load a config with the given `contextName` value. Used when config file exports array or factory function. Setting it to "default" matches also config objects without `contextName` set.
13
- * @param paths Array of possible paths for a configuration file. Files will be checked in order, and the first existing one will be used. Defaults to the output of {@link ConfigurationLoader.getConfigPaths}.
14
- * @param options Additional options to augment the final configuration with.
15
- */
16
- static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(contextName: string, paths?: string[], options?: Partial<Options>): Promise<Configuration<D, EM>>;
17
- /**
18
- * Gets the default config from the default paths
19
- *
20
- * @deprecated Prefer to explicitly set the `contextName` at the first argument. This signature is available for backwards compatibility, and may be removed in v7.
21
- */
22
- static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(): Promise<Configuration<D, EM>>;
23
- /**
24
- * Gets default configuration out of the default paths, and possibly from `process.argv`
25
- *
26
- * @param validate Whether to validate the final configuration.
27
- * @param options Additional options to augment the final configuration with (just before validation).
28
- *
29
- * @deprecated Use the other overloads of this method. This signature will be removed in v7.
30
- */
31
- static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(validate: boolean, options?: Partial<Options>): Promise<Configuration<D, EM>>;
32
- static getConfigFile(paths: string[]): Promise<[string, unknown] | []>;
8
+ static loadEnvironmentVars<D extends IDatabaseDriver>(): Partial<Options<D>>;
33
9
  static getPackageConfig(basePath?: string): Dictionary;
34
- static getSettings(): Settings;
35
- static configPathsFromArg(): string[] | undefined;
36
- static getConfigPaths(): string[];
37
- static isESM(): boolean;
38
- static registerTypeScriptSupport(configPath?: string): Promise<boolean>;
39
- static registerDotenv<D extends IDatabaseDriver>(options?: Options<D>): void;
40
- static loadEnvironmentVars<D extends IDatabaseDriver>(): Promise<Partial<Options<D>>>;
41
- static loadEnvironmentVarsSync<D extends IDatabaseDriver>(): Partial<Options<D>>;
42
10
  static getORMPackages(): Set<string>;
43
- /** @internal */
44
- static commonJSCompat(options: Partial<Options>): void;
45
11
  static getORMPackageVersion(name: string): string | undefined;
46
12
  static checkPackageVersion(): string;
47
13
  }
48
- export interface Settings {
49
- alwaysAllowTs?: boolean;
50
- verbose?: boolean;
51
- preferTs?: boolean;
52
- tsConfigPath?: string;
53
- configPaths?: string[];
54
- }