@mikro-orm/core 6.3.14-dev.72 → 6.3.14-dev.73

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.3.14-dev.72",
3
+ "version": "6.3.14-dev.73",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.2.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.3.14-dev.72",
67
+ "mikro-orm": "6.3.14-dev.73",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -7,32 +7,28 @@ import { Configuration, type Options } from './Configuration';
7
7
  */
8
8
  export declare class ConfigurationLoader {
9
9
  /**
10
- * Gets a named configuration from a set of paths
10
+ * Gets a named configuration
11
11
  *
12
- * @param contextName Name of context to load from the config. Used when config file exports array or factory function.
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.
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
14
  * @param options Additional options to augment the final configuration with.
15
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>>;
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
17
  /**
18
- * Gets a named configuration from a set of paths
18
+ * Gets the default config from the default paths
19
19
  *
20
- * @param contextName Name of context to load from the config. Used when config file exports array or factory function. Defaults to "default".
21
- * @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}
22
- * @param options Additional options to augment the final configuration with.
23
- *
24
- * @deprecated Prefer to explicitly set the parameter values. The defaults are available for backwards compatibility.
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.
25
21
  */
26
- static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(contextName?: string, paths?: string[], options?: Partial<Options>): Promise<Configuration<D, EM>>;
22
+ static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(): Promise<Configuration<D, EM>>;
27
23
  /**
28
- * Gets default configuration
24
+ * Gets default configuration out of the default paths, and possibly from `process.argv`
29
25
  *
30
- * @param validate It was used to control Configuration constructor's validate parameter. Currently is no-op. Set to `true` to enable cross-version calls that also check for --config in process.argv.
31
- * @param options Additional options to augment the final configuration with.
26
+ * @param validate Whether to validate the final configuration.
27
+ * @param options Additional options to augment the final configuration with (just before validation).
32
28
  *
33
- * @deprecated Use the other overload of this method. This signature will be removed in v7.
29
+ * @deprecated Use the other overloads of this method. This signature will be removed in v7.
34
30
  */
35
- static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(validate: true, options?: Partial<Options>): Promise<Configuration<D, EM>>;
31
+ static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(validate: boolean, options?: Partial<Options>): Promise<Configuration<D, EM>>;
36
32
  static getPackageConfig(basePath?: string): Dictionary;
37
33
  static getSettings(): Settings;
38
34
  static configPathsFromArg(): string[] | undefined;
@@ -17,9 +17,11 @@ const Utils_1 = require("./Utils");
17
17
  */
18
18
  class ConfigurationLoader {
19
19
  static async getConfiguration(contextName = 'default', paths = ConfigurationLoader.getConfigPaths(), options = {}) {
20
- if (contextName === true || !Array.isArray(paths)) {
20
+ if (typeof contextName === 'boolean' || !Array.isArray(paths)) {
21
21
  const configPathFromArg = ConfigurationLoader.configPathsFromArg();
22
- const config = (await ConfigurationLoader.getConfiguration(process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default', configPathFromArg ?? ConfigurationLoader.getConfigPaths(), Array.isArray(paths) ? undefined : paths));
22
+ const config = contextName
23
+ ? (await ConfigurationLoader.getConfiguration(process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default', configPathFromArg ?? ConfigurationLoader.getConfigPaths(), Array.isArray(paths) ? {} : paths))
24
+ : new Configuration_1.Configuration(Utils_1.Utils.mergeConfig({}, options, this.loadEnvironmentVars()), false);
23
25
  if (configPathFromArg) {
24
26
  config.getLogger().warn('deprecated', 'Path for config file was inferred from the command line arguments. Instead, you should set the MIKRO_ORM_CLI_CONFIG environment variable to specify the path, or if you really must use the command line arguments, import the config manually based on them, and pass it to init.', { label: 'D0001' });
25
27
  }