@mikro-orm/core 7.0.0-dev.233 → 7.0.0-dev.235

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.
@@ -345,7 +345,7 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
345
345
  /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
346
346
  referencedColumnNames(...referencedColumnNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
347
347
  /** Specify the property name on the target entity that this FK references instead of the primary key. */
348
- targetKey(targetKey: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
348
+ targetKey(targetKey: keyof Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
349
349
  /** What to do when the target entity gets deleted. */
350
350
  deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
351
351
  /** What to do when the reference to the target entity gets updated. */
@@ -373,7 +373,7 @@ export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> e
373
373
  kind: '1:m';
374
374
  }, IncludeKeysForOneToManyOptions> {
375
375
  /** Point to the owning side property name. */
376
- mappedBy(mappedBy: (AnyString & keyof Value) | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
376
+ mappedBy(mappedBy: (keyof Value) | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
377
377
  kind: '1:m';
378
378
  }, IncludeKeysForOneToManyOptions>, IncludeKeysForOneToManyOptions>;
379
379
  }
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.233",
4
+ "version": "7.0.0-dev.235",
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",
@@ -1,18 +1,15 @@
1
- import { type Configuration } from '../utils/Configuration.js';
2
- import type { MetadataStorage } from '../metadata/MetadataStorage.js';
3
1
  import type { AnyEntity } from '../typings.js';
4
2
  import { ChangeSet } from './ChangeSet.js';
5
3
  import { type Collection } from '../entity/Collection.js';
6
- import type { Platform } from '../platforms/Platform.js';
7
4
  import type { EntityManager } from '../EntityManager.js';
8
5
  export declare class ChangeSetComputer {
6
+ private readonly em;
9
7
  private readonly collectionUpdates;
8
+ private readonly comparator;
10
9
  private readonly metadata;
11
10
  private readonly platform;
12
11
  private readonly config;
13
- private readonly em;
14
- private readonly comparator;
15
- constructor(collectionUpdates: Set<Collection<AnyEntity>>, metadata: MetadataStorage, platform: Platform, config: Configuration, em: EntityManager);
12
+ constructor(em: EntityManager, collectionUpdates: Set<Collection<AnyEntity>>);
16
13
  computeChangeSet<T extends object>(entity: T): ChangeSet<T> | null;
17
14
  /**
18
15
  * Traverses entity graph and executes `onCreate` and `onUpdate` methods, assigning the values to given properties.
@@ -7,18 +7,18 @@ import { Reference } from '../entity/Reference.js';
7
7
  import { PolymorphicRef } from '../entity/PolymorphicRef.js';
8
8
  import { ReferenceKind } from '../enums.js';
9
9
  export class ChangeSetComputer {
10
+ em;
10
11
  collectionUpdates;
12
+ comparator;
11
13
  metadata;
12
14
  platform;
13
15
  config;
14
- em;
15
- comparator;
16
- constructor(collectionUpdates, metadata, platform, config, em) {
17
- this.collectionUpdates = collectionUpdates;
18
- this.metadata = metadata;
19
- this.platform = platform;
20
- this.config = config;
16
+ constructor(em, collectionUpdates) {
21
17
  this.em = em;
18
+ this.collectionUpdates = collectionUpdates;
19
+ this.config = this.em.config;
20
+ this.metadata = this.em.getMetadata();
21
+ this.platform = this.em.getPlatform();
22
22
  this.comparator = this.config.getComparator(this.metadata);
23
23
  }
24
24
  computeChangeSet(entity) {
@@ -1,21 +1,18 @@
1
- import type { MetadataStorage } from '../metadata/MetadataStorage.js';
2
- import type { Dictionary, EntityDictionary, EntityMetadata, IHydrator } from '../typings.js';
3
- import { type EntityFactory } from '../entity/EntityFactory.js';
1
+ import type { Dictionary, EntityDictionary, EntityMetadata } from '../typings.js';
4
2
  import { type ChangeSet } from './ChangeSet.js';
5
- import { type Configuration } from '../utils/Configuration.js';
6
- import type { DriverMethodOptions, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
3
+ import type { DriverMethodOptions } from '../drivers/IDatabaseDriver.js';
7
4
  import type { EntityManager } from '../EntityManager.js';
8
5
  export declare class ChangeSetPersister {
6
+ private readonly em;
7
+ private readonly platform;
8
+ private readonly comparator;
9
+ private readonly usesReturningStatement;
9
10
  private readonly driver;
10
11
  private readonly metadata;
11
12
  private readonly hydrator;
12
13
  private readonly factory;
13
14
  private readonly config;
14
- private readonly em;
15
- private readonly platform;
16
- private readonly comparator;
17
- private readonly usesReturningStatement;
18
- constructor(driver: IDatabaseDriver, metadata: MetadataStorage, hydrator: IHydrator, factory: EntityFactory, config: Configuration, em: EntityManager);
15
+ constructor(em: EntityManager);
19
16
  executeInserts<T extends object>(changeSets: ChangeSet<T>[], options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
20
17
  executeUpdates<T extends object>(changeSets: ChangeSet<T>[], batched: boolean, options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
21
18
  executeDeletes<T extends object>(changeSets: ChangeSet<T>[], options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
@@ -7,23 +7,23 @@ import { Utils } from '../utils/Utils.js';
7
7
  import { OptimisticLockError, ValidationError } from '../errors.js';
8
8
  import { ReferenceKind } from '../enums.js';
9
9
  export class ChangeSetPersister {
10
+ em;
11
+ platform;
12
+ comparator;
13
+ usesReturningStatement;
10
14
  driver;
11
15
  metadata;
12
16
  hydrator;
13
17
  factory;
14
18
  config;
15
- em;
16
- platform;
17
- comparator;
18
- usesReturningStatement;
19
- constructor(driver, metadata, hydrator, factory, config, em) {
20
- this.driver = driver;
21
- this.metadata = metadata;
22
- this.hydrator = hydrator;
23
- this.factory = factory;
24
- this.config = config;
19
+ constructor(em) {
25
20
  this.em = em;
21
+ this.driver = this.em.getDriver();
22
+ this.config = this.em.config;
23
+ this.metadata = this.em.getMetadata();
24
+ this.factory = this.em.getEntityFactory();
26
25
  this.platform = this.driver.getPlatform();
26
+ this.hydrator = this.config.getHydrator(this.metadata);
27
27
  this.comparator = this.config.getComparator(this.metadata);
28
28
  this.usesReturningStatement = this.platform.usesReturningStatement() || this.platform.usesOutputStatement();
29
29
  }
@@ -42,8 +42,8 @@ export class UnitOfWork {
42
42
  this.identityMap = new IdentityMap(this.platform.getDefaultSchemaName());
43
43
  this.eventManager = this.em.getEventManager();
44
44
  this.comparator = this.em.getComparator();
45
- this.changeSetComputer = new ChangeSetComputer(this.collectionUpdates, this.metadata, this.platform, this.em.config, this.em);
46
- this.changeSetPersister = new ChangeSetPersister(this.em.getDriver(), this.metadata, this.em.config.getHydrator(this.metadata), this.em.getEntityFactory(), this.em.config, this.em);
45
+ this.changeSetComputer = new ChangeSetComputer(this.em, this.collectionUpdates);
46
+ this.changeSetPersister = new ChangeSetPersister(this.em);
47
47
  }
48
48
  merge(entity, visited) {
49
49
  const wrapped = helper(entity);
package/utils/Utils.js CHANGED
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
123
123
  }
124
124
  export class Utils {
125
125
  static PK_SEPARATOR = '~~~';
126
- static #ORM_VERSION = '7.0.0-dev.233';
126
+ static #ORM_VERSION = '7.0.0-dev.235';
127
127
  /**
128
128
  * Checks if the argument is instance of `Object`. Returns false for arrays.
129
129
  */