import type { EntityData, EntityMetadata, EntityName, New, Primary } from '../typings.js'; import type { EntityManager } from '../EntityManager.js'; import type { EntityComparator } from '../utils/EntityComparator.js'; /** @internal Options for creating and merging entities via the EntityFactory. */ export interface FactoryOptions { /** Whether the entity should be marked as initialized. */ initialized?: boolean; /** Whether the entity is being newly created (uses constructor). */ newEntity?: boolean; /** * Property `onCreate` hooks are normally executed during `flush` operation. * With this option, they will be processed early inside `em.create()` method. */ processOnCreateHooksEarly?: boolean; /** Whether to merge the entity into the identity map. */ merge?: boolean; /** Whether to refresh an already loaded entity with new data. */ refresh?: boolean; /** Whether to convert custom types during hydration. */ convertCustomTypes?: boolean; /** Whether to recompute the entity snapshot after creation. */ recomputeSnapshot?: boolean; /** Schema from FindOptions, overrides default schema. */ schema?: string; /** Parent entity schema for nested entity creation. */ parentSchema?: string; /** Whether to normalize accessors to the correct property names (normally handled via result mapper). */ normalizeAccessors?: boolean; /** * Property name to use for identity map lookup instead of the primary key. * This is useful for creating references by unique non-PK properties. */ key?: string; } /** @internal Factory responsible for creating, merging, and hydrating entity instances. */ export declare class EntityFactory { #private; constructor(em: EntityManager); /** Creates a new entity instance or returns an existing one from the identity map, hydrating it with the provided data. */ create(entityName: EntityName, data: EntityData, options?: FactoryOptions): New; /** Merges new data into an existing entity, preserving user-modified properties. */ mergeData(meta: EntityMetadata, entity: T, data: EntityData, options?: FactoryOptions): void; /** Creates or retrieves an uninitialized entity reference by its primary key or alternate key. */ createReference(entityName: EntityName, id: Primary | Primary[] | Record>, options?: Pick): T; /** Creates an embeddable entity instance from the provided data. */ createEmbeddable(entityName: EntityName, data: EntityData, options?: Pick): T; /** Returns the EntityComparator instance used for diffing entities. */ getComparator(): EntityComparator; private createEntity; /** @internal */ assignDefaultValues(entity: T, meta: EntityMetadata, onCreateOnly?: boolean): void; private hydrate; private findEntity; private processDiscriminatorColumn; /** * denormalize PK to value required by driver (e.g. ObjectId) */ private denormalizePrimaryKey; /** * returns parameters for entity constructor, creating references from plain ids */ private extractConstructorParams; private get unitOfWork(); }