import { b as DocShape, c as UpdaterResult, n as FieldAccessor } from "../field-accessor-BfujBG1Q.mjs"; import { AggregateCommand, FindOneAndUpdateCommand, InsertOneCommand, MongoFilterExpr, MongoPipelineStage } from "@prisma-next/mongo-query-ast/execution"; import { CreateCollectionCommand, CreateCollectionOptions, CreateIndexCommand, CreateIndexOptions, MongoIndexKey } from "@prisma-next/mongo-query-ast/control"; import { MongoValue } from "@prisma-next/mongo-value"; //#region src/contract-free/collection.d.ts /** * Fluent aggregate chain. Accumulates `$match` / `$sort` / `$limit` stages and * produces an `AggregateCommand` via `.build()`. * * Instances are immutable — each stage method returns a new chain. */ declare class AggregateChain { #private; constructor(collection: string, stages: ReadonlyArray); match(filterFn: (fields: FieldAccessor) => MongoFilterExpr): AggregateChain; sort(spec: Record): AggregateChain; limit(n: number): AggregateChain; build(): AggregateCommand; } /** * Fluent find-and-modify chain. Holds an accumulated list of filter expressions * (AND-folded into the wire command's `filter` slot) and exposes * `.findOneAndUpdate(...)` as the only terminal. * * Multiple `.match()` calls AND-fold internally — `MongoAndExpr.of` never * appears at the call site. * * Instances are immutable — `.match()` returns a new `FilteredBuilder`. */ declare class FilteredBuilder { #private; constructor(collection: string, filters: ReadonlyArray); match(filterFn: (fields: FieldAccessor) => MongoFilterExpr): FilteredBuilder; findOneAndUpdate(updaterFn: (fields: FieldAccessor) => UpdaterResult, opts?: { readonly upsert?: boolean; readonly returnDocument?: 'before' | 'after'; }): FindOneAndUpdateCommand; } /** * Contract-free fluent Mongo collection builder. Produces the canonical * `AggregateCommand` / `InsertOneCommand` / `FindOneAndUpdateCommand` command * nodes without any contract coupling — parameterised by an explicit `DocShape` * instead of a `MongoContract`. * * Mirrors SQL's `table(source, schema)` → `TableHandle` in spirit: a top-level * entry point that exposes fluent query chains from which call sites never write * `new MongoMatchStage(...)`, `MongoAndExpr.of([...])`, or `new AggregateCommand(...)`. * * ```ts * const markerLedger = collection('_prisma_migrations'); * * // aggregate * markerLedger.aggregate().match(f => f._id.eq(space)).limit(1).build(); * * // insertOne * markerLedger.insertOne({ _id: space, space, storageHash }); * * // findOneAndUpdate (CAS) * markerLedger.match(f => f._id.eq(space)).match(f => f.storageHash.eq(expectedFrom)) * .findOneAndUpdate(f => [f.stage.set({ storageHash: newHash })], { upsert: false }); * ``` */ interface CollectionBuilder { aggregate(): AggregateChain; insertOne(document: Record): InsertOneCommand; match(filterFn: (fields: FieldAccessor) => MongoFilterExpr): FilteredBuilder; createCollection(options?: CreateCollectionOptions): CreateCollectionCommand; createIndex(keys: ReadonlyArray, options?: CreateIndexOptions): CreateIndexCommand; } /** * Declare a contract-free collection builder parameterised by a `DocShape`. * The collection name is bound once; field access reuses `createFieldAccessor` * so the shape is typed at every call site without a contract. * * @param name The MongoDB collection name (e.g. `'_prisma_migrations'`) */ declare function collection(name: string): CollectionBuilder; //#endregion export { AggregateChain, type CollectionBuilder, FilteredBuilder, collection }; //# sourceMappingURL=contract-free.d.mts.map