import { Filter, UpdateFilter } from 'mongodb'; import { PipeOutput, Pipe, PipeInput, ConditionalObjectKeys, DistributiveOmit, DeepPartial } from 'valleyed'; import { K as KafkaEventBus } from './kafka-Cf-TUJgv.js'; declare enum QueryKeys { and = "and", or = "or" } declare enum Conditions { lt = "lt", lte = "lte", gt = "gt", gte = "gte", eq = "eq", ne = "ne", in = "in", nin = "nin", exists = "exists" } declare const queryKeys: Pipe; declare const queryWhere: Pipe<{ field: string; value: any; condition: Conditions | undefined; }, { field: string; value: any; condition: Conditions; }>; declare function queryParamsPipe(): Pipe<{ all: boolean | undefined; limit: number | undefined; page: number | undefined; search: { value: string; fields: string[]; } | null | undefined; sort: { field: string; desc: boolean | undefined; }[] | undefined; whereType: QueryKeys | undefined; where: ({ field: string; value: any; condition: Conditions | undefined; } | { condition: PipeInput; value: PipeInput[]; })[] | undefined; }, { auth: ({ field: string; value: any; condition: Conditions; } | { condition: PipeOutput; value: PipeOutput[]; })[]; authType: QueryKeys; all: boolean; limit: number; page: number; search: { value: string; fields: string[]; } | null; sort: { field: string; desc: boolean; }[]; whereType: QueryKeys; where: ({ field: string; value: any; condition: Conditions; } | { condition: PipeOutput; value: PipeOutput[]; })[]; }>; declare function queryResultsPipe(model: Pipe): Pipe<{ pages: { current: number; start: number; last: number; previous: number | null; next: number | null; }; docs: { limit: number; total: number; count: number; }; results: any[]; }, { pages: { current: number; start: number; last: number; previous: number | null; next: number | null; }; docs: { limit: number; total: number; count: number; }; results: T[]; }>; declare function wrapQueryParams(params: QueryParamsInput): QueryParams; type QueryParams = PipeOutput>; type QueryParamsInput = ConditionalObjectKeys>>; type QueryWhereClause = QueryParams['where'][number]; type QueryWhere = Extract; type QueryWhereBlock = Exclude; type QueryResults = PipeOutput>>; declare const mongoDbConfigPipe: () => Pipe<{ uri: string; }, { uri: string; }>; type MongoDbConfig = PipeOutput>; type DbChangeConfig = { eventBus: KafkaEventBus; debeziumUrl: string; }; type DbConfig = { changes?: DbChangeConfig; }; declare abstract class DbChange, Entity extends Entity> { protected config: DbChangeConfig; protected callbacks: DbChangeCallbacks; protected mapper: (model: Model) => Entity; constructor(config: DbChangeConfig, callbacks: DbChangeCallbacks, mapper: (model: Model) => Entity); protected configureConnector(key: string, data: Record): Promise; } type IdType = { _id: string; } | { id: string; }; type Entity = { toJSON: () => Record; }; type ModelId = T extends Model ? Id[keyof Id] : never; type Model = IdKey & { createdAt?: number; updatedAt?: number; }; type Sort = NonNullable[number]; type Table, E extends Entity, Extras extends Record = {}> = { query: (query: QueryParams) => Promise>; findMany: (filter: Filter, options?: { limit?: number; sort?: Sort | Sort[]; }) => Promise; findOne: (filter: Filter) => Promise; findById: (id: ModelId) => Promise; insertOne: (values: CreateInput, options?: { makeId?: () => string; getTime?: () => Date; }) => Promise; insertMany: (values: CreateInput[], options?: { makeId?: (i: number) => string; getTime?: () => Date; }) => Promise; updateMany: (filter: Filter, values: UpdateInput, options?: { getTime?: () => Date; }) => Promise; updateOne: (filter: Filter, values: UpdateInput, options?: { getTime?: () => Date; }) => Promise; updateById: (id: ModelId, values: UpdateInput, options?: { getTime?: () => Date; }) => Promise; upsertOne: (filter: Filter, values: { insert: CreateInput; } | { insert: Partial>; update: UpdateInput; }, options?: { makeId?: () => string; getTime?: () => Date; }) => Promise; deleteOne: (filter: Filter) => Promise; deleteById: (id: ModelId) => Promise; deleteMany: (filter: Filter) => Promise; bulkWrite: (operations: BulkWriteOperation[], options?: { getTime?: () => Date; }) => Promise; readonly config: Config; readonly extras: Extras; watch: (callbacks: DbChangeCallbacks) => DbChange; }; type AllKeys = T extends any ? keyof T : never; type EntityInput> = ConditionalObjectKeys | keyof Model>>; type CreateInput> = EntityInput; type UpdateInput> = DistributiveOmit>, '$setOnInsert'>; type BulkWriteOperation> = { op: 'insert'; value: CreateInput; makeId?: (i: number) => string; } | { op: 'update'; filter: Filter; value: UpdateInput; } | ({ op: 'upsert'; filter: Filter; makeId?: (i: number) => string; } & ({ insert: CreateInput; } | { insert: Partial>; update: UpdateInput; })) | { op: 'delete'; filter: Filter; }; type DbChangeCallbacks, E extends Entity> = { created?: (data: { before: null; after: E; }) => Promise; updated?: (data: { before: E; after: E; changes: DeepPartial; }) => Promise; deleted?: (data: { before: E; after: null; }) => Promise; }; type Config, E extends Entity> = { db: string; col: string; mapper: (model: M) => E; options?: { skipAudit?: boolean; }; }; export { type BulkWriteOperation as B, type CreateInput as C, DbChange as D, type Entity as E, type IdType as I, type Model as M, QueryKeys as Q, type Table as T, type UpdateInput as U, type MongoDbConfig as a, type DbChangeConfig as b, type DbChangeCallbacks as c, type EntityInput as d, type Config as e, type DbConfig as f, Conditions as g, queryResultsPipe as h, type QueryParams as i, type QueryParamsInput as j, type QueryWhereClause as k, type QueryWhere as l, type QueryWhereBlock as m, type QueryResults as n, mongoDbConfigPipe as o, queryParamsPipe as q, wrapQueryParams as w };