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<T extends object, P extends string = string>(
    entityName: EntityName<T>,
    data: EntityData<T>,
    options?: FactoryOptions,
  ): New<T, P>;
  /** Merges new data into an existing entity, preserving user-modified properties. */
  mergeData<T extends object>(meta: EntityMetadata<T>, entity: T, data: EntityData<T>, options?: FactoryOptions): void;
  /** Creates or retrieves an uninitialized entity reference by its primary key or alternate key. */
  createReference<T extends object>(
    entityName: EntityName<T>,
    id: Primary<T> | Primary<T>[] | Record<string, Primary<T>>,
    options?: Pick<FactoryOptions, 'merge' | 'convertCustomTypes' | 'schema' | 'key'>,
  ): T;
  /** Creates an embeddable entity instance from the provided data. */
  createEmbeddable<T extends object>(
    entityName: EntityName<T>,
    data: EntityData<T>,
    options?: Pick<FactoryOptions, 'newEntity' | 'convertCustomTypes'>,
  ): T;
  /** Returns the EntityComparator instance used for diffing entities. */
  getComparator(): EntityComparator;
  private createEntity;
  private assignDefaultValues;
  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();
}
