import { PopulateOptions, QueryOptions, ConnectOptions, mongo, InsertManyOptions, AggregateOptions, AnyBulkWriteOperation, MongooseBulkWriteOptions, FilterQuery, ProjectionType, PipelineStage, AnyObject, UpdateWithAggregationPipeline, UpdateQuery, Cursor } from 'mongoose'; import type { UpdateResult, DeleteResult, BulkWriteResult } from 'mongodb'; export type META = { domain: string; orgIds?: string[]; [key: string]: any; }; export interface IMongoConfig { connectionString?: string; options?: ConnectOptions; reconnectAttempt?: number; } export type UpdateOptions = { new?: boolean; upsert?: boolean; }; export interface FindAllOption { limit?: number; skip?: number; sort?: any; select?: any; populate?: any; lean?: boolean; queryOptions?: QueryOptions; fields?: string; page?: number; populateOptions?: PopulateOptions[]; } export interface FindAllResponse { data: T[]; total: number; limit: number; page: number; totalPages: number; } export interface IBaseRepository { create(entity: Partial, session?: any, meta?: META): Promise; updateById(id: string, doc: Partial, meta?: META): Promise; deleteById(id: string, meta?: META): Promise; find(filter: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null, meta?: META): Promise; findOne(cond?: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null, meta?: META): Promise; findOneAndUpdate(cond: FilterQuery, doc: UpdateQuery, options?: QueryOptions, meta?: META): Promise; findAll(cond: FilterQuery, options?: Partial>, meta?: META): Promise>; updateOne(filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: mongo.UpdateOptions, meta?: META): Promise; aggregate(pipeline: PipelineStage[], options?: AggregateOptions, meta?: META): Promise; populate(docs: Array | any, options: any, meta?: META): Promise; findAndPopulate(filter: FilterQuery, options: PopulateOptions | (PopulateOptions | string)[], projection?: ProjectionType | null | undefined, meta?: META): Promise; insertMany(docs: Array>, options?: InsertManyOptions, meta?: META): Promise; updateMany(filter: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: mongo.UpdateOptions, meta?: META): Promise; deleteMany(filter?: FilterQuery, options?: mongo.DeleteOptions, meta?: META): Promise; countDocuments(cond: FilterQuery, options?: mongo.CountOptions, meta?: META): Promise; bulkWrite(writes: Array, options?: MongooseBulkWriteOptions, meta?: META): Promise; findCursor(filter: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null, meta?: META): Promise>; } export interface ILogger { info(message?: string, details?: any): void; error(message?: string, details?: any): void; warn(message?: string, details?: any): void; debug(message?: string, details?: any): void; } export interface ISystemNotify { sendErrorToTelegram(title: string, error?: any): Promise; sendSuccessMessageToTelegram(title: string): Promise; } export type DeleteResponse = { ok?: number; n?: number; } & { deletedCount?: number; }; export type PartialDeep = { [P in keyof T]?: PartialDeep; };