import { AutoUpdatedClientObject } from "./AutoUpdatedClientObjectClass.js"; import { AutoUpdateServerManager } from "./AutoUpdateServerManagerClass.js"; import { Constructor, IsData, PathValueOf, LoggersType, EventEmitter3, IAutoUpdatedClientObject, IAutoUpdatedServerObject, ExtractedData, DEMErrorCode, DEMArrayMutationParams, DEMArrayMutationRequest, DEMArrayMutationResponse } from "./CommonTypes.js"; import { DocumentType } from "@typegoose/typegoose"; export declare abstract class AutoUpdatedServerObject> extends AutoUpdatedClientObject implements IAutoUpdatedServerObject { protected readonly isServer: boolean; protected entry: DocumentType | null; parentManager: AutoUpdateServerManager; private saveLock; private loadPromise; /** * Initializes an AutoUpdatedServerObject instance. * * @param classParam - Target entity constructor class. * @param socket - Socket server or transport instance. * @param data - Initial entity data payload. * @param loggers - Logging interfaces. * @param className - Managed entity class name. * @param parentManager - Host server manager. * @param emitter - Shared event emitter. * @throws {DEMError} Throws DEMErrorCode.MISSING_ARGUMENT when required arguments are omitted. */ constructor(); constructor(classParam: Constructor, socket: unknown, data: IsData, loggers: LoggersType, className: string, parentManager: AutoUpdateServerManager, emitter: EventEmitter3); /** * Persists active document changes to MongoDB with queue serialization. * * @returns Promise resolving when database write finishes. */ save(): Promise; /** * Loads entity document data directly from MongoDB by ID. * * @returns Promise resolving when data is populated. * @throws {DEMError} Throws DEMErrorCode.MISSING_ID or DOCUMENT_NOT_FOUND. */ loadFromDB(): Promise; /** * Ingests existing MongoDB Mongoose document into instance state. * * @param document - Mongoose Typegoose document. */ loadFromDocument(document: DocumentType): void; /** * Internal cached serialized data payload without deep cloning. * Safe for read-only serialization. * * @returns Raw extracted data representation of the entity. */ getRawExtractedData(): ExtractedData>; /** * Serialized data payload with resolved reference identifiers, cached for performance. * * @returns Extracted data representation of the entity. */ get extractedData(): ExtractedData>; /** * Sets a property value on the entity with deadlock-safe queueing during onUpdate hooks. * * @param key - Property key to modify. * @param val - Value to set matching property type or never for invalid property. * @returns Promise resolving to operation outcome. */ setValue(key: K, val: PathValueOf, K>): Promise<{ success: boolean; msg: string; code?: DEMErrorCode; }>; /** * Internal setter with re-entrant write queue lock support. * * @param key - Property key. * @param val - Value to set. * @param silent - Whether socket broadcast is skipped. * @param noGet - Whether local update bypasses get. * @param noUpdate - Whether onUpdate hook is skipped. * @param isParentUpdate - Whether mutation originated from parent. * @returns Promise resolving to update outcome. */ protected setValue__(key: string, val: unknown, silent?: boolean, noGet?: boolean, noUpdate?: boolean, isParentUpdate?: boolean): Promise<{ success: boolean; msg: string; code?: DEMErrorCode; }>; /** * Internal database and memory setter executing MongoDB updates and socket events. * * @param key - Property key to modify. * @param value - Value to set. * @param silent - Whether socket broadcast is bypassed. * @param noUpdate - Whether onUpdate hook is bypassed. * @returns Promise resolving to setter outcome. */ protected setValueInternal(key: string, value: unknown, silent?: boolean, noUpdate?: boolean): Promise<{ success: boolean; msg: string; code?: DEMErrorCode; }>; /** * Enqueues an array mutation in the entity write queue with deadlock-safe queueing during onUpdate hooks. * * @param key - Target array property key. * @param req - Array mutation parameters payload. * @param isRef - Whether the target property holds relational entities. * @returns Promise resolving to mutation result. */ mutateArrayQueue(key: string, req: DEMArrayMutationParams, isRef: boolean): Promise; /** * Internal isomorphic hook executing an array mutation on the server. * * @param key - Target array property key. * @param mutation - Structured array mutation request. * @param isRef - Whether target property is a relational reference array. * @returns Promise resolving to mutation response. */ executeServerArrayMutation(key: string, mutation: DEMArrayMutationRequest, isRef?: boolean): Promise; /** * Executes atomic or positional array mutation on server entity and persists to MongoDB. * * @param key - Target array property key. * @param mutation - Structured array mutation request. * @param isRef - Optional flag indicating relational reference array. * @returns Promise resolving to mutation response with updated array state. */ mutateArray(key: string, mutation: DEMArrayMutationRequest, isRef?: boolean): Promise; /** * Deletes entity from MongoDB and emits delete socket events. * * @param once - Internal flag for single-pass deletion. * @returns Promise resolving to deletion outcome. */ destroy(once?: boolean): Promise<{ success: boolean; message: string; }>; /** * Executes configured onUpdate hook with deadlock-safe write execution. * * @param noUpdate - Whether hook execution is skipped. * @param key - Modified property key. */ protected onUpdate(noUpdate: boolean | undefined, key: string): Promise; /** * Executes configured onDeletion hook prior to database removal. */ protected onDeletion(): Promise; } /** * Instantiates and loads an AutoUpdatedServerObject instance. * * @param classParam - Constructor of the server entity class. * @param className - Managed entity class name. * @param socket - Socket server or transport instance. * @param data - Entity identifier or initial data object. * @param loggers - Logging interfaces. * @param parentManager - Host server manager. * @param emitter - Shared event emitter. * @param document - Optional pre-loaded Mongoose document. * @returns Promise resolving to the initialized server entity. */ export declare function createAutoUpdatedClass>(classParam: Constructor, className: string, socket: unknown, data: string | IsData, loggers: LoggersType, parentManager: AutoUpdateServerManager, emitter: EventEmitter3, document?: DocumentType): Promise>;