@mikro-orm/core 7.0.0-dev.71 → 7.0.0-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 +1 -1
- package/unit-of-work/UnitOfWork.js +2 -1
- package/utils/Configuration.d.ts +580 -4
- package/utils/ConfigurationLoader.js +69 -59
- package/utils/Utils.d.ts +0 -6
- package/utils/Utils.js +0 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.73",
|
|
5
5
|
"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.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
|
@@ -327,7 +327,8 @@ export class UnitOfWork {
|
|
|
327
327
|
this.filterCollectionUpdates();
|
|
328
328
|
// nothing to do, do not start transaction
|
|
329
329
|
if (this.changeSets.size === 0 && this.collectionUpdates.size === 0 && this.extraUpdates.size === 0) {
|
|
330
|
-
|
|
330
|
+
await this.eventManager.dispatchEvent(EventType.afterFlush, { em: this.em, uow: this });
|
|
331
|
+
return;
|
|
331
332
|
}
|
|
332
333
|
const groups = this.getChangeSetGroups();
|
|
333
334
|
const platform = this.em.getPlatform();
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -230,181 +230,757 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
230
230
|
* Type helper to make it easier to use `mikro-orm.config.js`.
|
|
231
231
|
*/
|
|
232
232
|
export declare function defineConfig<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Options<D, EM, Entities>;
|
|
233
|
+
/**
|
|
234
|
+
* Connection configuration options for database connections.
|
|
235
|
+
* @see https://mikro-orm.io/docs/configuration#connection
|
|
236
|
+
*/
|
|
233
237
|
export interface ConnectionOptions {
|
|
238
|
+
/** Name of the database to connect to. */
|
|
234
239
|
dbName?: string;
|
|
240
|
+
/** Default database schema to use. */
|
|
235
241
|
schema?: string;
|
|
242
|
+
/** Name of the connection (used for logging when replicas are used). */
|
|
236
243
|
name?: string;
|
|
244
|
+
/** Full client connection URL. Overrides individual connection options. */
|
|
237
245
|
clientUrl?: string;
|
|
246
|
+
/** Database server hostname. */
|
|
238
247
|
host?: string;
|
|
248
|
+
/** Database server port number. */
|
|
239
249
|
port?: number;
|
|
250
|
+
/** Database user name. */
|
|
240
251
|
user?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Database password. Can be a string or a callback function that returns the password.
|
|
254
|
+
* The callback is useful for short-lived tokens from cloud providers.
|
|
255
|
+
* @example
|
|
256
|
+
* password: async () => someCallToGetTheToken()
|
|
257
|
+
*/
|
|
241
258
|
password?: string | (() => MaybePromise<string>);
|
|
259
|
+
/** Character set for the connection. */
|
|
242
260
|
charset?: string;
|
|
261
|
+
/** Collation for the connection. */
|
|
243
262
|
collate?: string;
|
|
263
|
+
/**
|
|
264
|
+
* Enable multiple statements in a single query.
|
|
265
|
+
* Required for importing database dump files.
|
|
266
|
+
* Should be disabled in production for security.
|
|
267
|
+
* @default false
|
|
268
|
+
*/
|
|
244
269
|
multipleStatements?: boolean;
|
|
270
|
+
/** Connection pool configuration. */
|
|
245
271
|
pool?: PoolConfig;
|
|
272
|
+
/**
|
|
273
|
+
* Additional driver-specific options.
|
|
274
|
+
* The object will be deeply merged with internal driver options.
|
|
275
|
+
*/
|
|
246
276
|
driverOptions?: Dictionary;
|
|
277
|
+
/** Callback to execute when a new connection is created. */
|
|
247
278
|
onCreateConnection?: (connection: unknown) => Promise<void>;
|
|
248
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Configuration options for database migrations.
|
|
282
|
+
* @see https://mikro-orm.io/docs/migrations
|
|
283
|
+
*/
|
|
249
284
|
export type MigrationsOptions = {
|
|
285
|
+
/**
|
|
286
|
+
* Name of the migrations table.
|
|
287
|
+
* @default 'mikro_orm_migrations'
|
|
288
|
+
*/
|
|
250
289
|
tableName?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Path to the folder with migration files (for compiled JavaScript files).
|
|
292
|
+
* @default './migrations'
|
|
293
|
+
*/
|
|
251
294
|
path?: string;
|
|
295
|
+
/**
|
|
296
|
+
* Path to the folder with migration files (for TypeScript source files).
|
|
297
|
+
* Used when running in TypeScript mode.
|
|
298
|
+
*/
|
|
252
299
|
pathTs?: string;
|
|
300
|
+
/**
|
|
301
|
+
* Glob pattern to match migration files.
|
|
302
|
+
* @default '!(*.d).{js,ts,cjs}'
|
|
303
|
+
*/
|
|
253
304
|
glob?: string;
|
|
305
|
+
/**
|
|
306
|
+
* Disable logging for migration operations.
|
|
307
|
+
* @default false
|
|
308
|
+
*/
|
|
254
309
|
silent?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Run each migration inside a transaction.
|
|
312
|
+
* @default true
|
|
313
|
+
*/
|
|
255
314
|
transactional?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Try to disable foreign key checks during migrations.
|
|
317
|
+
* @default false
|
|
318
|
+
*/
|
|
256
319
|
disableForeignKeys?: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Run all migrations in the current batch in a master transaction.
|
|
322
|
+
* @default true
|
|
323
|
+
*/
|
|
257
324
|
allOrNothing?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Allow dropping tables during schema diff.
|
|
327
|
+
* @default true
|
|
328
|
+
*/
|
|
258
329
|
dropTables?: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Safe mode - only allow adding new tables and columns, never dropping existing ones.
|
|
332
|
+
* @default false
|
|
333
|
+
*/
|
|
259
334
|
safe?: boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Create a snapshot of the current schema after migration generation.
|
|
337
|
+
* @default true
|
|
338
|
+
*/
|
|
260
339
|
snapshot?: boolean;
|
|
340
|
+
/** Custom name for the snapshot file. */
|
|
261
341
|
snapshotName?: string;
|
|
342
|
+
/**
|
|
343
|
+
* File extension for generated migration files.
|
|
344
|
+
* @default 'ts'
|
|
345
|
+
*/
|
|
262
346
|
emit?: 'js' | 'ts' | 'cjs';
|
|
347
|
+
/** Custom migration generator class. */
|
|
263
348
|
generator?: Constructor<IMigrationGenerator>;
|
|
349
|
+
/**
|
|
350
|
+
* Custom function to generate migration file names.
|
|
351
|
+
* @default (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`
|
|
352
|
+
*/
|
|
264
353
|
fileName?: (timestamp: string, name?: string) => string;
|
|
354
|
+
/** List of migration classes or objects to use instead of file-based discovery. */
|
|
265
355
|
migrationsList?: (MigrationObject | Constructor<Migration>)[];
|
|
266
356
|
};
|
|
357
|
+
/**
|
|
358
|
+
* Configuration options for database seeders.
|
|
359
|
+
* @see https://mikro-orm.io/docs/seeding
|
|
360
|
+
*/
|
|
267
361
|
export interface SeederOptions {
|
|
362
|
+
/**
|
|
363
|
+
* Path to the folder with seeder files (for compiled JavaScript files).
|
|
364
|
+
* @default './seeders'
|
|
365
|
+
*/
|
|
268
366
|
path?: string;
|
|
367
|
+
/**
|
|
368
|
+
* Path to the folder with seeder files (for TypeScript source files).
|
|
369
|
+
* Used when running in TypeScript mode.
|
|
370
|
+
*/
|
|
269
371
|
pathTs?: string;
|
|
372
|
+
/**
|
|
373
|
+
* Glob pattern to match seeder files.
|
|
374
|
+
* @default '!(*.d).{js,ts}'
|
|
375
|
+
*/
|
|
270
376
|
glob?: string;
|
|
377
|
+
/**
|
|
378
|
+
* Name of the default seeder class to run.
|
|
379
|
+
* @default 'DatabaseSeeder'
|
|
380
|
+
*/
|
|
271
381
|
defaultSeeder?: string;
|
|
382
|
+
/**
|
|
383
|
+
* File extension for generated seeder files.
|
|
384
|
+
* @default 'ts'
|
|
385
|
+
*/
|
|
272
386
|
emit?: 'js' | 'ts';
|
|
387
|
+
/**
|
|
388
|
+
* Custom function to generate seeder file names.
|
|
389
|
+
* @default (className) => className
|
|
390
|
+
*/
|
|
273
391
|
fileName?: (className: string) => string;
|
|
274
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* Connection pool configuration.
|
|
395
|
+
* @see https://mikro-orm.io/docs/configuration#connection
|
|
396
|
+
*/
|
|
275
397
|
export interface PoolConfig {
|
|
398
|
+
/** Minimum number of connections to keep in the pool. */
|
|
276
399
|
min?: number;
|
|
400
|
+
/** Maximum number of connections allowed in the pool. */
|
|
277
401
|
max?: number;
|
|
402
|
+
/** Time in milliseconds before an idle connection is closed. */
|
|
278
403
|
idleTimeoutMillis?: number;
|
|
279
404
|
}
|
|
405
|
+
/**
|
|
406
|
+
* Configuration options for metadata discovery.
|
|
407
|
+
* @see https://mikro-orm.io/docs/configuration#entity-discovery
|
|
408
|
+
*/
|
|
280
409
|
export interface MetadataDiscoveryOptions {
|
|
410
|
+
/**
|
|
411
|
+
* Throw an error when no entities are discovered.
|
|
412
|
+
* @default true
|
|
413
|
+
*/
|
|
281
414
|
warnWhenNoEntities?: boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Check for duplicate table names and throw an error if found.
|
|
417
|
+
* @default true
|
|
418
|
+
*/
|
|
282
419
|
checkDuplicateTableNames?: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Check for duplicate field names and throw an error if found.
|
|
422
|
+
* @default true
|
|
423
|
+
*/
|
|
283
424
|
checkDuplicateFieldNames?: boolean;
|
|
425
|
+
/**
|
|
426
|
+
* Check for duplicate entities and throw an error if found.
|
|
427
|
+
* @default true
|
|
428
|
+
*/
|
|
284
429
|
checkDuplicateEntities?: boolean;
|
|
430
|
+
/**
|
|
431
|
+
* Check for composite primary keys marked as `persist: false` and throw an error if found.
|
|
432
|
+
* @default true
|
|
433
|
+
*/
|
|
285
434
|
checkNonPersistentCompositeProps?: boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Infer default values from property initializers when possible
|
|
437
|
+
* (if the constructor can be invoked without parameters).
|
|
438
|
+
* @default true
|
|
439
|
+
*/
|
|
286
440
|
inferDefaultValues?: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Custom callback to override default type mapping.
|
|
443
|
+
* Allows customizing how property types are mapped to database column types.
|
|
444
|
+
* @example
|
|
445
|
+
* getMappedType(type, platform) {
|
|
446
|
+
* if (type === 'string') {
|
|
447
|
+
* return Type.getType(TextType);
|
|
448
|
+
* }
|
|
449
|
+
* return platform.getDefaultMappedType(type);
|
|
450
|
+
* }
|
|
451
|
+
*/
|
|
287
452
|
getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
|
|
453
|
+
/**
|
|
454
|
+
* Hook called for each entity metadata during discovery.
|
|
455
|
+
* Can be used to modify metadata dynamically before defaults are filled in.
|
|
456
|
+
* The hook can be async when using `MikroORM.init()`.
|
|
457
|
+
*/
|
|
288
458
|
onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
|
|
459
|
+
/**
|
|
460
|
+
* Hook called after all entities are discovered.
|
|
461
|
+
* Can be used to access and modify all metadata at once.
|
|
462
|
+
*/
|
|
289
463
|
afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
|
|
464
|
+
/** Path to the TypeScript configuration file for ts-morph metadata provider. */
|
|
290
465
|
tsConfigPath?: string;
|
|
291
466
|
/** @internal */
|
|
292
467
|
skipSyncDiscovery?: boolean;
|
|
293
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* MikroORM configuration options.
|
|
471
|
+
* @see https://mikro-orm.io/docs/configuration
|
|
472
|
+
*/
|
|
294
473
|
export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<Driver> & Driver[typeof EntityManagerType] = EntityManager<Driver> & Driver[typeof EntityManagerType], Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends ConnectionOptions {
|
|
474
|
+
/**
|
|
475
|
+
* Array of entity classes or paths to entity modules.
|
|
476
|
+
* Paths support glob patterns for automatic discovery.
|
|
477
|
+
* @example
|
|
478
|
+
* entities: [Author, Book, Publisher] // class references
|
|
479
|
+
* entities: ['./dist/entities'] // folder paths
|
|
480
|
+
*/
|
|
295
481
|
entities?: Entities;
|
|
482
|
+
/**
|
|
483
|
+
* Array of TypeScript entity source paths.
|
|
484
|
+
* Used when running in TypeScript mode (e.g., via `tsx` or `swc`).
|
|
485
|
+
* Should always be specified when using folder-based discovery.
|
|
486
|
+
* @example
|
|
487
|
+
* entitiesTs: ['./src/entities']
|
|
488
|
+
*/
|
|
296
489
|
entitiesTs?: Entities;
|
|
490
|
+
/**
|
|
491
|
+
* ORM extensions to register (e.g., Migrator, EntityGenerator, SeedManager).
|
|
492
|
+
* Extensions registered here are available via shortcuts like `orm.migrator`.
|
|
493
|
+
* @example
|
|
494
|
+
* extensions: [Migrator, EntityGenerator, SeedManager]
|
|
495
|
+
*/
|
|
297
496
|
extensions?: {
|
|
298
497
|
register: (orm: MikroORM) => void;
|
|
299
498
|
}[];
|
|
499
|
+
/**
|
|
500
|
+
* Event subscribers to register.
|
|
501
|
+
* Can be class references or instances.
|
|
502
|
+
*/
|
|
300
503
|
subscribers?: (EventSubscriber | Constructor<EventSubscriber>)[];
|
|
504
|
+
/**
|
|
505
|
+
* Global entity filters to apply.
|
|
506
|
+
* Filters are applied by default unless explicitly disabled.
|
|
507
|
+
* @see https://mikro-orm.io/docs/filters
|
|
508
|
+
*/
|
|
301
509
|
filters?: Dictionary<{
|
|
302
510
|
name?: string;
|
|
303
511
|
} & Omit<FilterDef, 'name'>>;
|
|
512
|
+
/**
|
|
513
|
+
* Metadata discovery configuration options.
|
|
514
|
+
* Controls how entities are discovered and validated.
|
|
515
|
+
*/
|
|
304
516
|
discovery?: MetadataDiscoveryOptions;
|
|
517
|
+
/**
|
|
518
|
+
* Database driver class to use.
|
|
519
|
+
* Should be imported from the specific driver package (e.g. `@mikro-orm/mysql`, `@mikro-orm/postgresql`).
|
|
520
|
+
* Alternatively, use the `defineConfig` helper or `MikroORM` class exported from the driver package.
|
|
521
|
+
* @example
|
|
522
|
+
* import { MySqlDriver } from '@mikro-orm/mysql';
|
|
523
|
+
*
|
|
524
|
+
* MikroORM.init({
|
|
525
|
+
* driver: MySqlDriver,
|
|
526
|
+
* dbName: 'my_db',
|
|
527
|
+
* });
|
|
528
|
+
*/
|
|
305
529
|
driver?: {
|
|
306
530
|
new (config: Configuration): Driver;
|
|
307
531
|
};
|
|
532
|
+
/**
|
|
533
|
+
* Custom naming strategy class for mapping entity/property names to database table/column names.
|
|
534
|
+
* Built-in options: `UnderscoreNamingStrategy`, `MongoNamingStrategy`, `EntityCaseNamingStrategy`.
|
|
535
|
+
* @see https://mikro-orm.io/docs/naming-strategy
|
|
536
|
+
*/
|
|
308
537
|
namingStrategy?: {
|
|
309
538
|
new (): NamingStrategy;
|
|
310
539
|
};
|
|
540
|
+
/**
|
|
541
|
+
* Enable implicit transactions for all write operations.
|
|
542
|
+
* When enabled, all queries will be wrapped in a transaction.
|
|
543
|
+
* Disabled for MongoDB driver by default.
|
|
544
|
+
*/
|
|
311
545
|
implicitTransactions?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Disable all transactions.
|
|
548
|
+
* When enabled, no queries will be wrapped in transactions, even when explicitly requested.
|
|
549
|
+
* @default false
|
|
550
|
+
*/
|
|
312
551
|
disableTransactions?: boolean;
|
|
552
|
+
/**
|
|
553
|
+
* Enable verbose logging of internal operations.
|
|
554
|
+
* @default false
|
|
555
|
+
*/
|
|
313
556
|
verbose?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Ignore `undefined` values in find queries instead of treating them as `null`.
|
|
559
|
+
* @default false
|
|
560
|
+
* @example
|
|
561
|
+
* // With ignoreUndefinedInQuery: true
|
|
562
|
+
* em.find(User, { email: undefined }) // resolves to em.find(User, {})
|
|
563
|
+
*/
|
|
314
564
|
ignoreUndefinedInQuery?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Hook to modify SQL queries before execution.
|
|
567
|
+
* Useful for adding observability hints or query modifications.
|
|
568
|
+
* @param sql - The generated SQL query
|
|
569
|
+
* @param params - Query parameters
|
|
570
|
+
* @returns Modified SQL query
|
|
571
|
+
*/
|
|
315
572
|
onQuery?: (sql: string, params: readonly unknown[]) => string;
|
|
573
|
+
/**
|
|
574
|
+
* Automatically join the owning side of 1:1 relations when querying the inverse side.
|
|
575
|
+
* @default true
|
|
576
|
+
*/
|
|
316
577
|
autoJoinOneToOneOwner?: boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Automatically join M:1 and 1:1 relations when filters are defined on them.
|
|
580
|
+
* Important for implementing soft deletes via filters.
|
|
581
|
+
* @default true
|
|
582
|
+
*/
|
|
317
583
|
autoJoinRefsForFilters?: boolean;
|
|
584
|
+
/**
|
|
585
|
+
* Apply filters to relations in queries.
|
|
586
|
+
* @default true
|
|
587
|
+
*/
|
|
318
588
|
filtersOnRelations?: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* Enable propagation of changes on entity prototypes.
|
|
591
|
+
* @default true
|
|
592
|
+
*/
|
|
319
593
|
propagationOnPrototype?: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Mark all relations as populated after flush for new entities.
|
|
596
|
+
* This aligns serialized output of loaded entities and just-inserted ones.
|
|
597
|
+
* @default true
|
|
598
|
+
*/
|
|
320
599
|
populateAfterFlush?: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* Serialization options for `toJSON()` and `serialize()` methods.
|
|
602
|
+
*/
|
|
321
603
|
serialization?: {
|
|
604
|
+
/**
|
|
605
|
+
* Include primary keys in serialized output.
|
|
606
|
+
* @default true
|
|
607
|
+
*/
|
|
322
608
|
includePrimaryKeys?: boolean;
|
|
323
|
-
/**
|
|
609
|
+
/**
|
|
610
|
+
* Enforce unpopulated references to be returned as objects.
|
|
611
|
+
* When enabled, references are serialized as `{ author: { id: 1 } }` instead of `{ author: 1 }`.
|
|
612
|
+
* @default false
|
|
613
|
+
*/
|
|
324
614
|
forceObject?: boolean;
|
|
325
615
|
};
|
|
616
|
+
/**
|
|
617
|
+
* Default options for entity assignment via `em.assign()`.
|
|
618
|
+
* @see https://mikro-orm.io/docs/entity-helper
|
|
619
|
+
*/
|
|
326
620
|
assign?: AssignOptions<boolean>;
|
|
621
|
+
/**
|
|
622
|
+
* Automatically call `em.persist()` on entities created via `em.create()`.
|
|
623
|
+
* @default true
|
|
624
|
+
*/
|
|
327
625
|
persistOnCreate?: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* When upsert creates a new entity, mark it as managed in the identity map.
|
|
628
|
+
* @default true
|
|
629
|
+
*/
|
|
328
630
|
upsertManaged?: boolean;
|
|
631
|
+
/**
|
|
632
|
+
* Force use of entity constructors when creating entity instances.
|
|
633
|
+
* Required when using native private properties inside entities.
|
|
634
|
+
* Can be `true` for all entities or an array of specific entity classes/names.
|
|
635
|
+
* @default false
|
|
636
|
+
*/
|
|
329
637
|
forceEntityConstructor?: boolean | (Constructor<AnyEntity> | string)[];
|
|
638
|
+
/**
|
|
639
|
+
* Convert `null` values from database to `undefined` when hydrating entities.
|
|
640
|
+
* @default false
|
|
641
|
+
*/
|
|
330
642
|
forceUndefined?: boolean;
|
|
331
643
|
/**
|
|
332
644
|
* Property `onCreate` hooks are normally executed during `flush` operation.
|
|
333
645
|
* With this option, they will be processed early inside `em.create()` method.
|
|
646
|
+
* @default false
|
|
334
647
|
*/
|
|
335
648
|
processOnCreateHooksEarly?: boolean;
|
|
649
|
+
/**
|
|
650
|
+
* Force `Date` values to be stored in UTC for datetime columns without timezone.
|
|
651
|
+
* Works for MySQL (`datetime` type) and PostgreSQL (`timestamp` type).
|
|
652
|
+
* SQLite does this by default.
|
|
653
|
+
* @default false
|
|
654
|
+
*/
|
|
336
655
|
forceUtcTimezone?: boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Timezone to use for date operations.
|
|
658
|
+
* @example '+02:00'
|
|
659
|
+
*/
|
|
337
660
|
timezone?: string;
|
|
661
|
+
/**
|
|
662
|
+
* Ensure the database exists when initializing the ORM.
|
|
663
|
+
* When `true`, will create the database if it doesn't exist.
|
|
664
|
+
* @default true
|
|
665
|
+
*/
|
|
338
666
|
ensureDatabase?: boolean | EnsureDatabaseOptions;
|
|
667
|
+
/**
|
|
668
|
+
* Ensure database indexes exist on startup. This option works only with the MongoDB driver.
|
|
669
|
+
* When enabled, indexes will be created based on entity metadata.
|
|
670
|
+
* @default false
|
|
671
|
+
*/
|
|
339
672
|
ensureIndexes?: boolean;
|
|
673
|
+
/**
|
|
674
|
+
* Use batch insert queries for better performance.
|
|
675
|
+
* @default true
|
|
676
|
+
*/
|
|
340
677
|
useBatchInserts?: boolean;
|
|
678
|
+
/**
|
|
679
|
+
* Use batch update queries for better performance.
|
|
680
|
+
* @default true
|
|
681
|
+
*/
|
|
341
682
|
useBatchUpdates?: boolean;
|
|
683
|
+
/**
|
|
684
|
+
* Number of entities to process in each batch for batch inserts/updates.
|
|
685
|
+
* @default 300
|
|
686
|
+
*/
|
|
342
687
|
batchSize?: number;
|
|
688
|
+
/**
|
|
689
|
+
* Custom hydrator class for assigning database values to entities.
|
|
690
|
+
* @default ObjectHydrator
|
|
691
|
+
*/
|
|
343
692
|
hydrator?: HydratorConstructor;
|
|
693
|
+
/**
|
|
694
|
+
* Default loading strategy for relations.
|
|
695
|
+
* - `'joined'`: Use SQL JOINs (single query, may cause cartesian product)
|
|
696
|
+
* - `'select-in'`: Use separate SELECT IN queries (multiple queries)
|
|
697
|
+
* - `'balanced'`: Decides based on relation type and context.
|
|
698
|
+
* @default 'balanced'
|
|
699
|
+
*/
|
|
344
700
|
loadStrategy?: LoadStrategy | `${LoadStrategy}`;
|
|
701
|
+
/**
|
|
702
|
+
* Enable dataloader for batching reference loading.
|
|
703
|
+
* - `true` or `DataloaderType.ALL`: Enable for all relation types
|
|
704
|
+
* - `false` or `DataloaderType.NONE`: Disable dataloader
|
|
705
|
+
* - `DataloaderType.REFERENCE`: Enable only for scalar references
|
|
706
|
+
* - `DataloaderType.COLLECTION`: Enable only for collections
|
|
707
|
+
* @default DataloaderType.NONE
|
|
708
|
+
*/
|
|
345
709
|
dataloader?: DataloaderType | boolean;
|
|
710
|
+
/**
|
|
711
|
+
* Determines how where conditions are applied during population.
|
|
712
|
+
* - `'all'`: Populate all matching relations (default in v5+)
|
|
713
|
+
* - `'infer'`: Infer conditions from the original query (v4 behavior)
|
|
714
|
+
* @default 'all'
|
|
715
|
+
*/
|
|
346
716
|
populateWhere?: PopulateHint | `${PopulateHint}`;
|
|
717
|
+
/**
|
|
718
|
+
* Default flush mode for the entity manager.
|
|
719
|
+
* - `'commit'`: Flush only on explicit commit
|
|
720
|
+
* - `'auto'`: Flush before queries when needed
|
|
721
|
+
* - `'always'`: Always flush before queries
|
|
722
|
+
* @default 'auto'
|
|
723
|
+
*/
|
|
347
724
|
flushMode?: FlushMode | `${FlushMode}`;
|
|
725
|
+
/**
|
|
726
|
+
* Custom base repository class for all entities.
|
|
727
|
+
* Entity-specific repositories can still be defined and will take precedence.
|
|
728
|
+
* @see https://mikro-orm.io/docs/repositories
|
|
729
|
+
*/
|
|
348
730
|
entityRepository?: EntityClass<EntityRepository<any>>;
|
|
731
|
+
/**
|
|
732
|
+
* Custom entity manager class to use.
|
|
733
|
+
*/
|
|
349
734
|
entityManager?: Constructor<EM>;
|
|
735
|
+
/**
|
|
736
|
+
* Read replica connection configurations.
|
|
737
|
+
* Each replica can override parts of the main connection options.
|
|
738
|
+
* @see https://mikro-orm.io/docs/read-connections
|
|
739
|
+
*/
|
|
350
740
|
replicas?: ConnectionOptions[];
|
|
741
|
+
/**
|
|
742
|
+
* Enable strict mode which disables automatic data type conversion.
|
|
743
|
+
* In strict mode, the ORM throws errors instead of fixing wrong data types.
|
|
744
|
+
* @default false
|
|
745
|
+
* @see https://mikro-orm.io/docs/property-validation
|
|
746
|
+
*/
|
|
351
747
|
strict?: boolean;
|
|
748
|
+
/**
|
|
749
|
+
* Enable runtime property validation before persisting.
|
|
750
|
+
* Has performance implications and is usually not needed.
|
|
751
|
+
* @default false
|
|
752
|
+
* @see https://mikro-orm.io/docs/property-validation
|
|
753
|
+
*/
|
|
352
754
|
validate?: boolean;
|
|
755
|
+
/**
|
|
756
|
+
* Validate that required properties are set on new entities before insert.
|
|
757
|
+
* @default true
|
|
758
|
+
*/
|
|
353
759
|
validateRequired?: boolean;
|
|
760
|
+
/**
|
|
761
|
+
* Callback to get the current request context's EntityManager.
|
|
762
|
+
* Used for automatic context propagation in web frameworks.
|
|
763
|
+
* @default RequestContext.getEntityManager
|
|
764
|
+
*/
|
|
354
765
|
context?: (name: string) => EntityManager | undefined;
|
|
766
|
+
/**
|
|
767
|
+
* Name of the context for multi-ORM setups.
|
|
768
|
+
* @default 'default'
|
|
769
|
+
*/
|
|
355
770
|
contextName?: string;
|
|
771
|
+
/**
|
|
772
|
+
* Allow using the global EntityManager without a request context.
|
|
773
|
+
* Not recommended for production - each request should have its own context.
|
|
774
|
+
* Can also be set via `MIKRO_ORM_ALLOW_GLOBAL_CONTEXT` environment variable.
|
|
775
|
+
* @default false
|
|
776
|
+
*/
|
|
356
777
|
allowGlobalContext?: boolean;
|
|
778
|
+
/**
|
|
779
|
+
* Disable the identity map.
|
|
780
|
+
* When disabled, each query returns new entity instances.
|
|
781
|
+
* Not recommended for most use cases.
|
|
782
|
+
* @default false
|
|
783
|
+
*/
|
|
357
784
|
disableIdentityMap?: boolean;
|
|
785
|
+
/**
|
|
786
|
+
* Custom logger function for ORM output.
|
|
787
|
+
* @default console.log
|
|
788
|
+
*/
|
|
358
789
|
logger?: (message: string) => void;
|
|
790
|
+
/**
|
|
791
|
+
* Enable colored output in logs.
|
|
792
|
+
* @default true
|
|
793
|
+
*/
|
|
359
794
|
colors?: boolean;
|
|
795
|
+
/**
|
|
796
|
+
* Factory function to create a custom logger instance.
|
|
797
|
+
* @default DefaultLogger.create
|
|
798
|
+
*/
|
|
360
799
|
loggerFactory?: (options: LoggerOptions) => Logger;
|
|
800
|
+
/**
|
|
801
|
+
* Custom error handler for `em.findOneOrFail()` when no entity is found.
|
|
802
|
+
* @param entityName - Name of the entity being queried
|
|
803
|
+
* @param where - Query conditions
|
|
804
|
+
* @returns Error instance to throw
|
|
805
|
+
*/
|
|
361
806
|
findOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
|
|
807
|
+
/**
|
|
808
|
+
* Custom error handler for `em.findExactlyOneOrFail()` when entity count is not exactly one.
|
|
809
|
+
* Used when strict mode is enabled.
|
|
810
|
+
* @param entityName - Name of the entity being queried
|
|
811
|
+
* @param where - Query conditions
|
|
812
|
+
* @returns Error instance to throw
|
|
813
|
+
*/
|
|
362
814
|
findExactlyOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
|
|
815
|
+
/**
|
|
816
|
+
* Enable debug logging.
|
|
817
|
+
* Can be `true` for all namespaces or an array of specific namespaces.
|
|
818
|
+
* Available namespaces: `'query'`, `'query-params'`, `'discovery'`, `'info'`.
|
|
819
|
+
* @default false
|
|
820
|
+
* @see https://mikro-orm.io/docs/logging
|
|
821
|
+
*/
|
|
363
822
|
debug?: boolean | LoggerNamespace[];
|
|
823
|
+
/**
|
|
824
|
+
* Ignore deprecation warnings.
|
|
825
|
+
* Can be `true` to ignore all or an array of specific deprecation labels.
|
|
826
|
+
* @default false
|
|
827
|
+
* @see https://mikro-orm.io/docs/logging#deprecation-warnings
|
|
828
|
+
*/
|
|
364
829
|
ignoreDeprecations?: boolean | string[];
|
|
830
|
+
/**
|
|
831
|
+
* Syntax highlighter for SQL queries in logs.
|
|
832
|
+
* @default NullHighlighter
|
|
833
|
+
*/
|
|
365
834
|
highlighter?: Highlighter;
|
|
366
835
|
/**
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
836
|
+
* Force the ORM to use TypeScript options regardless of detection.
|
|
837
|
+
* Uses `entitiesTs` for discovery and `pathTs` for migrations/seeders.
|
|
838
|
+
* Should only be used for tests, not production builds.
|
|
839
|
+
* @default false
|
|
370
840
|
*/
|
|
371
841
|
preferTs?: boolean;
|
|
842
|
+
/**
|
|
843
|
+
* Base directory for resolving relative paths.
|
|
844
|
+
* @default process.cwd()
|
|
845
|
+
*/
|
|
372
846
|
baseDir?: string;
|
|
847
|
+
/**
|
|
848
|
+
* Migration configuration options.
|
|
849
|
+
* @see https://mikro-orm.io/docs/migrations
|
|
850
|
+
*/
|
|
373
851
|
migrations?: MigrationsOptions;
|
|
852
|
+
/**
|
|
853
|
+
* Schema generator configuration options.
|
|
854
|
+
*/
|
|
374
855
|
schemaGenerator?: {
|
|
856
|
+
/**
|
|
857
|
+
* Try to disable foreign key checks during schema operations.
|
|
858
|
+
* @default false
|
|
859
|
+
*/
|
|
375
860
|
disableForeignKeys?: boolean;
|
|
861
|
+
/**
|
|
862
|
+
* Generate foreign key constraints.
|
|
863
|
+
* @default true
|
|
864
|
+
*/
|
|
376
865
|
createForeignKeyConstraints?: boolean;
|
|
866
|
+
/**
|
|
867
|
+
* Schema names to ignore when comparing schemas.
|
|
868
|
+
* @default []
|
|
869
|
+
*/
|
|
377
870
|
ignoreSchema?: string[];
|
|
871
|
+
/**
|
|
872
|
+
* Table names or patterns to skip during schema generation.
|
|
873
|
+
* @default []
|
|
874
|
+
*/
|
|
378
875
|
skipTables?: (string | RegExp)[];
|
|
876
|
+
/**
|
|
877
|
+
* Column names or patterns to skip during schema generation, keyed by table name.
|
|
878
|
+
* @default {}
|
|
879
|
+
*/
|
|
379
880
|
skipColumns?: Dictionary<(string | RegExp)[]>;
|
|
881
|
+
/**
|
|
882
|
+
* Database name to use for management operations (e.g., creating/dropping databases).
|
|
883
|
+
*/
|
|
380
884
|
managementDbName?: string;
|
|
381
885
|
};
|
|
886
|
+
/**
|
|
887
|
+
* Embeddable entity configuration options.
|
|
888
|
+
*/
|
|
382
889
|
embeddables?: {
|
|
890
|
+
/**
|
|
891
|
+
* Mode for generating column prefixes for embedded properties.
|
|
892
|
+
* @default 'relative'
|
|
893
|
+
*/
|
|
383
894
|
prefixMode: EmbeddedPrefixMode;
|
|
384
895
|
};
|
|
896
|
+
/**
|
|
897
|
+
* Entity generator (code generation) configuration options.
|
|
898
|
+
* @see https://mikro-orm.io/docs/entity-generator
|
|
899
|
+
*/
|
|
385
900
|
entityGenerator?: GenerateOptions;
|
|
901
|
+
/**
|
|
902
|
+
* Metadata cache configuration for improved startup performance.
|
|
903
|
+
* @see https://mikro-orm.io/docs/metadata-cache
|
|
904
|
+
*/
|
|
386
905
|
metadataCache?: {
|
|
906
|
+
/**
|
|
907
|
+
* Enable metadata caching.
|
|
908
|
+
* Defaults based on the metadata provider's `useCache()` method.
|
|
909
|
+
*/
|
|
387
910
|
enabled?: boolean;
|
|
911
|
+
/**
|
|
912
|
+
* Combine all metadata into a single cache file.
|
|
913
|
+
* Can be `true` for default path or a custom path string.
|
|
914
|
+
*/
|
|
388
915
|
combined?: boolean | string;
|
|
916
|
+
/**
|
|
917
|
+
* Pretty print JSON cache files.
|
|
918
|
+
* @default false
|
|
919
|
+
*/
|
|
389
920
|
pretty?: boolean;
|
|
921
|
+
/**
|
|
922
|
+
* Cache adapter class to use.
|
|
923
|
+
* @default FileCacheAdapter
|
|
924
|
+
*/
|
|
390
925
|
adapter?: {
|
|
391
926
|
new (...params: any[]): SyncCacheAdapter;
|
|
392
927
|
};
|
|
928
|
+
/**
|
|
929
|
+
* Options passed to the cache adapter constructor.
|
|
930
|
+
* @default { cacheDir: process.cwd() + '/temp' }
|
|
931
|
+
*/
|
|
393
932
|
options?: Dictionary;
|
|
394
933
|
};
|
|
934
|
+
/**
|
|
935
|
+
* Result cache configuration for query result caching.
|
|
936
|
+
*/
|
|
395
937
|
resultCache?: {
|
|
938
|
+
/**
|
|
939
|
+
* Default cache expiration time in milliseconds.
|
|
940
|
+
* @default 1000
|
|
941
|
+
*/
|
|
396
942
|
expiration?: number;
|
|
943
|
+
/**
|
|
944
|
+
* Cache adapter class to use.
|
|
945
|
+
* @default MemoryCacheAdapter
|
|
946
|
+
*/
|
|
397
947
|
adapter?: {
|
|
398
948
|
new (...params: any[]): CacheAdapter;
|
|
399
949
|
};
|
|
950
|
+
/**
|
|
951
|
+
* Options passed to the cache adapter constructor.
|
|
952
|
+
* @default {}
|
|
953
|
+
*/
|
|
400
954
|
options?: Dictionary;
|
|
955
|
+
/**
|
|
956
|
+
* Enable global result caching for all queries.
|
|
957
|
+
* Can be `true`, an expiration number, or a tuple of `[key, expiration]`.
|
|
958
|
+
*/
|
|
401
959
|
global?: boolean | number | [string, number];
|
|
402
960
|
};
|
|
961
|
+
/**
|
|
962
|
+
* Metadata provider class for entity discovery.
|
|
963
|
+
* Built-in options: `ReflectMetadataProvider` (default), `TsMorphMetadataProvider`.
|
|
964
|
+
* @default ReflectMetadataProvider
|
|
965
|
+
* @see https://mikro-orm.io/docs/metadata-providers
|
|
966
|
+
*/
|
|
403
967
|
metadataProvider?: {
|
|
404
968
|
new (config: Configuration): MetadataProvider;
|
|
405
969
|
};
|
|
970
|
+
/**
|
|
971
|
+
* Seeder configuration options.
|
|
972
|
+
* @see https://mikro-orm.io/docs/seeding
|
|
973
|
+
*/
|
|
406
974
|
seeder?: SeederOptions;
|
|
975
|
+
/**
|
|
976
|
+
* Prefer read replicas for read operations when available.
|
|
977
|
+
* @default true
|
|
978
|
+
*/
|
|
407
979
|
preferReadReplicas?: boolean;
|
|
980
|
+
/**
|
|
981
|
+
* Custom dynamic import provider for loading modules.
|
|
982
|
+
* @default (id) => import(id)
|
|
983
|
+
*/
|
|
408
984
|
dynamicImportProvider?: (id: string) => Promise<unknown>;
|
|
409
985
|
}
|
|
410
986
|
type MarkRequired<T, D> = {
|
|
@@ -7,78 +7,88 @@ import { colors } from '../logging/colors.js';
|
|
|
7
7
|
export class ConfigurationLoader {
|
|
8
8
|
static loadEnvironmentVars() {
|
|
9
9
|
const ret = {};
|
|
10
|
+
const getEnvKey = (key, envPrefix = 'MIKRO_ORM_') => {
|
|
11
|
+
return envPrefix + key
|
|
12
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
13
|
+
.replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
|
|
14
|
+
.toUpperCase();
|
|
15
|
+
};
|
|
10
16
|
const array = (v) => v.split(',').map(vv => vv.trim());
|
|
11
17
|
const bool = (v) => ['true', 't', '1'].includes(v.toLowerCase());
|
|
12
18
|
const num = (v) => +v;
|
|
13
|
-
const read = (o,
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
const read = (o, envPrefix, key, mapper = v => v) => {
|
|
20
|
+
const envKey = getEnvKey(key, envPrefix);
|
|
21
|
+
if (envKey in process.env) {
|
|
22
|
+
o[key] = mapper(process.env[envKey]);
|
|
16
23
|
}
|
|
17
|
-
const val = process.env[envKey];
|
|
18
|
-
o[key] = mapper(val);
|
|
19
24
|
};
|
|
20
25
|
const cleanup = (o, k) => Utils.hasObjectKeys(o[k]) ? {} : delete o[k];
|
|
21
|
-
read(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
const read0 = read.bind(null, ret, 'MIKRO_ORM_');
|
|
27
|
+
read0('baseDir');
|
|
28
|
+
read0('entities', array);
|
|
29
|
+
read0('entitiesTs', array);
|
|
30
|
+
read0('clientUrl');
|
|
31
|
+
read0('host');
|
|
32
|
+
read0('port', num);
|
|
33
|
+
read0('user');
|
|
34
|
+
read0('password');
|
|
35
|
+
read0('dbName');
|
|
36
|
+
read0('schema');
|
|
37
|
+
read0('loadStrategy');
|
|
38
|
+
read0('batchSize', num);
|
|
39
|
+
read0('useBatchInserts', bool);
|
|
40
|
+
read0('useBatchUpdates', bool);
|
|
41
|
+
read0('strict', bool);
|
|
42
|
+
read0('validate', bool);
|
|
43
|
+
read0('allowGlobalContext', bool);
|
|
44
|
+
read0('autoJoinOneToOneOwner', bool);
|
|
45
|
+
read0('populateAfterFlush', bool);
|
|
46
|
+
read0('forceEntityConstructor', bool);
|
|
47
|
+
read0('forceUndefined', bool);
|
|
48
|
+
read0('forceUtcTimezone', bool);
|
|
49
|
+
read0('timezone');
|
|
50
|
+
read0('ensureIndexes', bool);
|
|
51
|
+
read0('implicitTransactions', bool);
|
|
52
|
+
read0('debug', bool);
|
|
53
|
+
read0('colors', bool);
|
|
48
54
|
ret.discovery = {};
|
|
49
|
-
read(ret.discovery, '
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
const read1 = read.bind(null, ret.discovery, 'MIKRO_ORM_DISCOVERY_');
|
|
56
|
+
read1('warnWhenNoEntities', bool);
|
|
57
|
+
read1('checkDuplicateTableNames', bool);
|
|
58
|
+
read1('checkDuplicateFieldNames', bool);
|
|
59
|
+
read1('checkDuplicateEntities', bool);
|
|
60
|
+
read1('checkNonPersistentCompositeProps', bool);
|
|
61
|
+
read1('inferDefaultValues', bool);
|
|
62
|
+
read1('tsConfigPath');
|
|
56
63
|
cleanup(ret, 'discovery');
|
|
57
64
|
ret.migrations = {};
|
|
58
|
-
read(ret.migrations, '
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const read2 = read.bind(null, ret.migrations, 'MIKRO_ORM_MIGRATIONS_');
|
|
66
|
+
read2('tableName');
|
|
67
|
+
read2('path');
|
|
68
|
+
read2('pathTs');
|
|
69
|
+
read2('glob');
|
|
70
|
+
read2('transactional', bool);
|
|
71
|
+
read2('disableForeignKeys', bool);
|
|
72
|
+
read2('allOrNothing', bool);
|
|
73
|
+
read2('dropTables', bool);
|
|
74
|
+
read2('safe', bool);
|
|
75
|
+
read2('silent', bool);
|
|
76
|
+
read2('emit');
|
|
77
|
+
read2('snapshot', bool);
|
|
78
|
+
read2('snapshotName');
|
|
71
79
|
cleanup(ret, 'migrations');
|
|
72
80
|
ret.schemaGenerator = {};
|
|
73
|
-
read(ret.schemaGenerator, '
|
|
74
|
-
|
|
81
|
+
const read3 = read.bind(null, ret.schemaGenerator, 'MIKRO_ORM_SCHEMA_GENERATOR_');
|
|
82
|
+
read3('disableForeignKeys', bool);
|
|
83
|
+
read3('createForeignKeyConstraints', bool);
|
|
75
84
|
cleanup(ret, 'schemaGenerator');
|
|
76
85
|
ret.seeder = {};
|
|
77
|
-
read(ret.seeder, '
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
const read4 = read.bind(null, ret.seeder, 'MIKRO_ORM_SEEDER_');
|
|
87
|
+
read4('path');
|
|
88
|
+
read4('pathTs');
|
|
89
|
+
read4('glob');
|
|
90
|
+
read4('emit');
|
|
91
|
+
read4('defaultSeeder');
|
|
82
92
|
cleanup(ret, 'seeder');
|
|
83
93
|
return ret;
|
|
84
94
|
}
|
package/utils/Utils.d.ts
CHANGED
|
@@ -168,12 +168,6 @@ export declare class Utils {
|
|
|
168
168
|
* @param [from] Location to start the node resolution
|
|
169
169
|
*/
|
|
170
170
|
static requireFrom<T extends Dictionary>(id: string, from?: string): T;
|
|
171
|
-
/**
|
|
172
|
-
* Resolve path to a module.
|
|
173
|
-
* @param id The module to require
|
|
174
|
-
* @param [from] Location to start the node resolution
|
|
175
|
-
*/
|
|
176
|
-
static resolveModulePath(id: string, from?: string): string;
|
|
177
171
|
static dynamicImport<T = any>(id: string): Promise<T>;
|
|
178
172
|
static ensureDir(path: string): void;
|
|
179
173
|
static readJSONSync(path: string): Dictionary;
|
package/utils/Utils.js
CHANGED
|
@@ -762,21 +762,6 @@ export class Utils {
|
|
|
762
762
|
}
|
|
763
763
|
return createRequire(resolve(from))(id);
|
|
764
764
|
}
|
|
765
|
-
/**
|
|
766
|
-
* Resolve path to a module.
|
|
767
|
-
* @param id The module to require
|
|
768
|
-
* @param [from] Location to start the node resolution
|
|
769
|
-
*/
|
|
770
|
-
static resolveModulePath(id, from = process.cwd()) {
|
|
771
|
-
if (!extname(from)) {
|
|
772
|
-
from = join(from, '__fake.js');
|
|
773
|
-
}
|
|
774
|
-
const path = Utils.normalizePath(createRequire(resolve(from)).resolve(id));
|
|
775
|
-
const parts = path.split('/');
|
|
776
|
-
const idx = parts.lastIndexOf(id) + 1;
|
|
777
|
-
parts.splice(idx, parts.length - idx);
|
|
778
|
-
return parts.join('/');
|
|
779
|
-
}
|
|
780
765
|
static async dynamicImport(id) {
|
|
781
766
|
/* v8 ignore next */
|
|
782
767
|
const specifier = id.startsWith('file://') ? id : pathToFileURL(id).href;
|