import type { PopulatePath } from '../enums.js'; import type { EntityManager } from '../EntityManager.js'; import type { Dictionary, EntityData, EntityDictionary, EntityMetadata, IHydrator, EntityKey, PopulateOptions, Primary, AutoPath, Ref, AddEager, LoadedReference, EntityDTO, Loaded, SerializeDTO, FromEntityType, IsSubset, MergeSelected } from '../typings.js'; import { Reference } from './Reference.js'; import { type AssignOptions } from './EntityAssigner.js'; import type { EntityLoaderOptions } from './EntityLoader.js'; import type { EntityIdentifier } from './EntityIdentifier.js'; import type { SerializationContext } from '../serialization/SerializationContext.js'; import { type SerializeOptions } from '../serialization/EntitySerializer.js'; import type { FindOneOptions, LoadHint } from '../drivers/IDatabaseDriver.js'; import type { Platform } from '../platforms/Platform.js'; import type { Configuration } from '../utils/Configuration.js'; /** @internal Wrapper attached to every managed entity, holding ORM state such as initialization flags, identity map references, and change tracking snapshots. */ export declare class WrappedEntity { __initialized: boolean; __populated?: boolean; __managed?: boolean; __onLoadFired?: boolean; __schema?: string; __em?: EntityManager; __loadedProperties: Set; __data: Dictionary; __processing: boolean; __serializationContext: { root?: SerializationContext; populate?: PopulateOptions[]; fields?: Set; exclude?: readonly string[]; }; /** stores last known primary key, as its current state might be broken due to propagation/orphan removal, but we need to know the PK to be able t remove the entity */ __pk?: Primary; /** holds the reference wrapper instance (if created), so we can maintain the identity on reference wrappers too */ __reference?: Reference; /** holds last entity data snapshot, so we can compute changes when persisting managed entities */ __originalEntityData?: EntityData; /** holds wrapped primary key, so we can compute change set without eager commit */ __identifier?: EntityIdentifier; private readonly entity; private readonly hydrator; private readonly pkGetter?; private readonly pkSerializer?; private readonly pkGetterConverted?; constructor(entity: Entity, hydrator: IHydrator, pkGetter?: (e: Entity) => Primary, pkSerializer?: (e: Entity) => string, pkGetterConverted?: (e: Entity) => Primary); /** Returns whether the entity has been fully loaded from the database. */ isInitialized(): boolean; /** Returns whether the entity is managed by an EntityManager (tracked in the identity map). */ isManaged(): boolean; /** Marks the entity as populated or not for serialization purposes. */ populated(populated?: boolean | undefined): void; /** Sets the serialization context with populate hints, field selections, and exclusions. */ setSerializationContext(options: LoadHint): void; /** Returns a Reference wrapper for this entity, creating one if it does not already exist. */ toReference(): Ref & LoadedReference>>; /** Converts the entity to a plain object representation, optionally excluding specified fields. */ toObject = never>(ignoreFields?: Ignored[]): Omit, Ignored>; /** Serializes the entity with control over which relations and fields to include or exclude. */ serialize(options?: SerializeOptions): SerializeDTO; /** Converts the entity to a plain object, including all properties regardless of serialization rules. */ toPOJO(): EntityDTO; /** Serializes the entity using its `toJSON` method (supports `JSON.stringify`). */ toJSON(...args: any[]): EntityDictionary; /** Assigns the given data to this entity, updating its properties and relations. */ assign = FromEntityType, Convert extends boolean = false, Data extends EntityData | Partial> = EntityData | Partial>>(data: Data & IsSubset, Data>, options?: AssignOptions): MergeSelected; /** Initializes (refreshes) the entity by reloading it from the database. Returns null if not found. */ init(options?: FindOneOptions): Promise | null>; /** Loads the specified relations on this entity. */ populate(populate: AutoPath[] | false, options?: EntityLoaderOptions): Promise>; /** Returns whether this entity has a primary key value set. */ hasPrimaryKey(): boolean; /** Returns the primary key value, optionally converting custom types to their database representation. */ getPrimaryKey(convertCustomTypes?: boolean): Primary | null; /** Returns all primary key values as an array. Used internally for composite key handling. */ getPrimaryKeys(convertCustomTypes?: boolean): Primary[] | null; /** Returns the database schema this entity belongs to. */ getSchema(): string | undefined; /** Sets the database schema for this entity. */ setSchema(schema?: string): void; /** Sets the primary key value on the entity. */ setPrimaryKey(id: Primary | null): void; /** Returns the primary key serialized as a string suitable for identity map lookups. */ getSerializedPrimaryKey(): string; get __meta(): EntityMetadata; get __platform(): Platform; get __config(): Configuration; get __primaryKeys(): Primary[]; }