import { mongo, Schema, FilterQuery, UpdateQuery, QueryOptions, UpdateWithAggregationPipeline, ProjectionType, PipelineStage, PopulateOptions, InsertManyOptions, ClientSession, AnyObject, AggregateOptions, MongooseBulkWriteOptions, AnyBulkWriteOperation, Cursor } from 'mongoose'; import type { UpdateResult, BulkWriteResult as MongoBulkWriteResult } from 'mongodb'; import { FindAllOption, FindAllResponse, IBaseRepository, META, ILogger } from './definitions'; interface BaseEntity { orgIds?: string[]; [key: string]: any; } /** * Base repository class providing common database operations with error handling, logging, and validation * * REFACTORED: Uses modular operation classes for better maintainability and testability * * @template T - The entity type extending BaseEntity */ export declare abstract class BaseRepository implements IBaseRepository { private readonly memCacheConnections; private readonly name; private readonly schema; private readonly collection; private readonly isDiscriminator; private readonly discriminator?; private model; private readonly logger?; private readonly connectionManager; private readonly retryExecutor; private readonly createOps; private readonly readOps; private readonly updateOps; private readonly deleteOps; private readonly aggregateOps; /** * Creates a new BaseRepository instance * * @param name - Model name * @param schema - Mongoose schema * @param collection - Collection name (optional) * @param discriminator - Discriminator configuration (optional) * @param logger - Logger instance for development logging (optional) */ constructor(name: string, schema: Schema, collection: string | null, discriminator?: { baseName: string; baseSchema: Schema; baseCollection: string; }, logger?: ILogger); /** * Initializes the Mongoose model * @private */ private initializeModel; /** * Sets the model for a specific domain (deprecated - handled automatically) * * @deprecated This method is no-op in the refactored architecture. * Model registration is handled automatically by ConnectionManager. * @param domain - Domain identifier */ setModel(domain: string): void; /** * Removes undefined values from an object * @protected */ protected removeUndefinedValue(object: Record): void; /** * Create body of $set function. It will use to update sub-document. * * Return: { "subDocumentName.$.key": "value" } */ protected createSetOfSubDocument(subDocumentName: keyof Doc, subDocument: Partial): Record; protected createObjectID(): string; /** * Creates a new document */ create(entity: Partial, session?: ClientSession, meta?: META): Promise; /** * Inserts multiple documents */ insertMany(docs: Array>, options?: InsertManyOptions & { lean: true; }, meta?: META): Promise; /** * Finds a single document matching the condition */ findOne(cond?: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null, meta?: META): Promise; /** * Finds all documents matching the condition with pagination */ findAll(cond: FilterQuery, options?: Partial>, meta?: META): Promise>; /** * Finds multiple documents matching the filter */ find(filter: FilterQuery, projection?: ProjectionType | null | undefined, options?: QueryOptions | null | undefined, meta?: META): Promise; /** * Counts documents matching the condition */ countDocuments(cond: FilterQuery, options?: mongo.CountOptions, meta?: META): Promise; /** * Returns a cursor for iterating over documents */ findCursor(filter: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null, meta?: META): Promise>; /** * Updates a document by ID */ updateById(id: string, doc: Partial, meta?: META): Promise; /** * Finds a document and updates it, or creates it if it doesn't exist (upsert) */ findOneAndUpdate(cond: FilterQuery, doc: UpdateQuery, options?: QueryOptions, meta?: META): Promise; /** * Updates a single document matching the filter */ updateOne(filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: mongo.UpdateOptions, meta?: META): Promise; /** * Updates multiple documents matching the filter */ updateMany(filter: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: mongo.UpdateOptions, meta?: META): Promise; /** * Deletes a document by ID */ deleteById(id: string, meta?: META): Promise; /** * Deletes multiple documents matching the filter */ deleteMany(filter?: FilterQuery, options?: mongo.DeleteOptions, meta?: META): Promise; /** * Performs an aggregation pipeline operation */ aggregate(pipeline?: PipelineStage[], options?: AggregateOptions, meta?: META): Promise; /** * Populates document references */ populate(docs: Array | any, options: PopulateOptions | Array, meta?: META): Promise; /** * Finds documents and populates their references */ findAndPopulate(filter: FilterQuery, options: PopulateOptions | PopulateOptions[], projection?: ProjectionType | null | undefined, meta?: META): Promise; /** * Performs bulk write operations */ bulkWrite(writes: Array, options?: MongooseBulkWriteOptions, meta?: META): Promise; } export {};