import { a as DropCollectionCall, c as schemaCollectionToCreateCollectionOptions, i as CreateIndexCall, l as schemaIndexToCreateIndexOptions, n as CollModMeta, o as DropIndexCall, r as CreateCollectionCall, s as OpFactoryCall, t as CollModCall } from "./op-factory-call-DcVIews3.mjs"; import { Namespace, NamespaceBase } from "@prisma-next/framework-components/ir"; import { MarkerOperations, MongoRunnerDependencies } from "@prisma-next/adapter-mongo/control"; import { MongoControlTargetDescriptor } from "@prisma-next/family-mongo/control"; import { Result } from "@prisma-next/utils/result"; import { MongoSchemaIR } from "@prisma-next/mongo-schema-ir"; import { AnyMongoMigrationOperation, MongoAndExpr, MongoExistsExpr, MongoExprFilter, MongoFieldFilter, MongoFilterExpr, MongoFilterVisitor, MongoMigrationPlanOperation, MongoNotExpr, MongoOrExpr } from "@prisma-next/mongo-query-ast/control"; import { Migration, MigrationMeta } from "@prisma-next/migration-tools/migration"; import { MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerPerSpaceSuccessValue, MigrationScaffoldContext, OperationContext, SchemaDiffIssue, SchemaVerifyOptions, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control"; import { MongoQueryPlan } from "@prisma-next/mongo-query-ast/execution"; import { MongoContractSerializerBase, MongoSchemaVerifierBase } from "@prisma-next/family-mongo/ir"; import { MongoCollection, MongoCollectionInput, MongoContract, MongoNamespaceEntries, MongoStorage, MongoValueSetInput } from "@prisma-next/mongo-contract"; import { Contract } from "@prisma-next/contract/types"; import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components"; import { AggregateMigrationEdgeRef } from "@prisma-next/migration-tools/aggregate"; import { JsonObject } from "@prisma-next/utils/json"; //#region src/core/mongo-target-contract.d.ts /** * Mongo target contract envelope: the result of * `descriptor.contractSerializer.deserializeContract(json)`. * * Structurally `MongoContract` with the storage envelope promoted to * the family-layer `MongoStorage` class instance — the class carries * `namespaces` and gives the rest of the framework a stable surface to * reach for. The leaf collection / index shapes inside * `storage.collections` are family-layer `MongoCollection` instances. */ type MongoTargetContract = Omit & { readonly storage: MongoStorage; }; //#endregion //#region src/core/control-target.d.ts /** * `migration.ts` default-exports a `Migration` subclass whose `operations` * getter returns the ordered list of operations and whose `describe()` * returns the manifest identity metadata. `MongoMigrationPlanner.plan()` * returns a `MigrationPlanWithAuthoringSurface` that knows how to render * itself back to such a file; `MongoMigrationPlanner.emptyMigration()` * returns the same shape for `migration new`. Users run the scaffolded * `migration.ts` directly (via `node migration.ts`) to self-emit * `ops.json` and attest the `migrationHash`. */ declare const mongoTargetDescriptor: MongoControlTargetDescriptor; //#endregion //#region src/core/filter-evaluator.d.ts declare class FilterEvaluator implements MongoFilterVisitor { private doc; evaluate(filter: MongoFilterExpr, doc: Record): boolean; field(expr: MongoFieldFilter): boolean; and(expr: MongoAndExpr): boolean; or(expr: MongoOrExpr): boolean; not(expr: MongoNotExpr): boolean; exists(expr: MongoExistsExpr): boolean; expr(_expr: MongoExprFilter): boolean; } //#endregion //#region src/core/mongo-ops-serializer.d.ts declare function deserializeMongoOp(json: unknown): AnyMongoMigrationOperation; declare function deserializeMongoOps(json: readonly unknown[]): AnyMongoMigrationOperation[]; declare function serializeMongoOps(ops: readonly AnyMongoMigrationOperation[]): string; //#endregion //#region src/core/mongo-planner.d.ts type PlanCallsResult = { readonly kind: 'success'; readonly calls: OpFactoryCall[]; } | { readonly kind: 'failure'; readonly conflicts: MigrationPlannerConflict[]; }; declare class MongoMigrationPlanner implements MigrationPlanner<'mongo', 'mongo'> { planCalls(options: { readonly contract: unknown; readonly schema: unknown; readonly policy: MigrationOperationPolicy; readonly frameworkComponents: ReadonlyArray>; }): PlanCallsResult; plan(options: { readonly contract: unknown; readonly schema: unknown; readonly policy: MigrationOperationPolicy; /** * The "from" contract (state the planner assumes the database starts at), * or `null` for reconciliation flows. Used to populate `describe().from` * on the produced plan as `fromContract?.storage.storageHash ?? null`. */ readonly fromContract: Contract | null; readonly frameworkComponents: ReadonlyArray>; }): MigrationPlannerResult; /** * Produce an empty `migration.ts` authoring surface for `migration new`. * * The "empty migration" is a `PlannerProducedMongoMigration` with no * operations; `renderTypeScript()` emits a stub class with the correct * `from`/`to` metadata that the user then fills in with operations. The * contract path on the context is unused — Mongo's emitted source does * not import from the generated contract `.d.ts`. */ emptyMigration(context: MigrationScaffoldContext): MigrationPlanWithAuthoringSurface; } //#endregion //#region src/core/mongo-runner.d.ts interface MongoMigrationRunnerExecuteOptions { readonly plan: MigrationPlan; readonly destinationContract: MongoContract; readonly policy: MigrationOperationPolicy; readonly callbacks?: { onOperationStart?(op: MigrationPlanOperation): void; onOperationComplete?(op: MigrationPlanOperation): void; }; readonly executionChecks?: MigrationRunnerExecutionChecks; readonly frameworkComponents: ReadonlyArray>; readonly strictVerification?: boolean; readonly context?: OperationContext; /** * Per-space verify-result scope. When set, the runner verifies the * destination contract against the **full** introspected schema, then * applies this to scope the result to the space the contract claims — * dropping the `extra` findings for collections a sibling space owns. * * The target descriptor's `execute` injects this callback, derived from * the sibling spaces in the aggregate. Callers that don't scope leave it * unset and verify against the whole introspected schema. */ readonly scopeVerifyResult?: (result: VerifyDatabaseSchemaResult) => VerifyDatabaseSchemaResult; /** Per-edge breakdown from graph-walk planning; drives per-edge ledger writes. */ readonly migrationEdges: readonly AggregateMigrationEdgeRef[]; } type MongoMigrationRunnerResult = Result; declare class MongoMigrationRunner { private readonly deps; constructor(deps: MongoRunnerDependencies); execute(options: MongoMigrationRunnerExecuteOptions): Promise; private recordLedgerEntries; private executeDataTransform; private evaluateDataTransformChecks; private evaluateChecks; private allChecksSatisfied; private enforcePolicyCompatibility; private ensureMarkerCompatibility; } //#endregion //#region src/core/mongo-target-contract-serializer.d.ts declare class MongoTargetContractSerializer extends MongoContractSerializerBase { protected constructTargetContract(validated: MongoContract): MongoTargetContract; serializeContract(contract: MongoTargetContract): JsonObject; } //#endregion //#region src/core/mongo-target-database.d.ts interface MongoTargetDatabaseInput { readonly id: string; readonly entries?: Readonly>>> & { readonly collection?: Readonly>; readonly valueSet?: Readonly>; }; } /** * Mongo target `Namespace` concretion. In Mongo the "namespace" concept * binds to the connection's `db` field — a `MongoTargetDatabase` instance * names the database the collections live under. `entries['collection']` * holds collection IR. The unbound singleton (below) is the late-bound * namespace whose binding the connection's `db` resolves at runtime rather * than at authoring time. * * Qualifier emission is the rendering seam: query / DDL emission asks the * namespace for its qualifier (e.g. `"."`) and consumes * the result polymorphically. The unbound singleton overrides these * methods to elide the prefix entirely — call sites stay polymorphic and * never branch on `id === UNBOUND_NAMESPACE_ID`. */ declare class MongoTargetDatabase extends NamespaceBase { readonly kind: string; readonly id: string; readonly entries: MongoNamespaceEntries; constructor(input: MongoTargetDatabaseInput); get collection(): Readonly>; /** * The bare qualifier as it would appear in a rendered string. The * unbound-database singleton overrides this to return `''`. */ qualifier(): string; /** * Qualify a collection name with the database prefix. The * unbound-database singleton overrides this to emit just the * collection name. Used by emission/introspection paths that need a * fully-qualified reference. */ qualifyCollection(collectionName: string): string; } /** * Singleton subclass for the reserved sentinel namespace id * (`UNBOUND_NAMESPACE_ID`) — the late-bound namespace whose binding the * connection's `db` resolves at runtime. Overrides qualifier emission * to elide the database prefix; call sites that consume `qualifier()` * / `qualifyCollection()` get unqualified output without branching on * the namespace id. * * This is the target-side materialization of "the framework provides * affordances; targets implement specifics": the framework names the * sentinel; Mongo decides what late-bound means here (the collection * name, naked — the database is supplied by the live connection). */ declare class MongoTargetUnboundDatabase extends MongoTargetDatabase { static readonly instance: MongoTargetUnboundDatabase; private constructor(); qualifier(): string; qualifyCollection(collectionName: string): string; } //#endregion //#region src/core/mongo-target-schema-verifier.d.ts /** * Mongo target `SchemaVerifier` concretion. Extends the family base's * namespace-walk scaffolding and contributes the per-namespace diff via * `verifyNamespace`; the diff body reuses the existing target-side * helpers (`contractToMongoSchemaIR`, `canonicalizeSchemasForVerification`, * `diffMongoSchemas`) so production verification behaviour is unchanged. * * Today's invariant: every Mongo contract carries exactly one * namespace (the unbound singleton, materialised as * `MongoTargetUnboundDatabase`), so the family-base namespace walk * dispatches exactly once and the per-namespace body runs the existing * whole-schema diff. Future per-collection namespace assignment will * have this hook project the diff to the namespace's owned collections. * * `verifyTargetExtensions` returns the empty list — Mongo has no * target-only kinds today. * * Strict diff mode is `false` for SPI-routed calls; production * verification today still goes through `verifyMongoSchema` which * receives strict from the CLI. */ declare class MongoTargetSchemaVerifier extends MongoSchemaVerifierBase { protected verifyNamespace(options: { readonly contract: MongoTargetContract; readonly schema: MongoSchemaIR; readonly namespaceId: string; readonly namespace: Namespace; }): readonly SchemaDiffIssue[]; protected verifyTargetExtensions(_options: SchemaVerifyOptions): readonly SchemaDiffIssue[]; } //#endregion //#region src/core/planner-produced-migration.d.ts /** * Planner-produced Mongo migration, returned by `MongoMigrationPlanner.plan(...)` * and `MongoMigrationPlanner.emptyMigration(...)`. * * Unlike user-authored migrations (which extend `MongoMigration` from * `@prisma-next/family-mongo/migration`), this class lives inside the target * and holds the richer authoring IR (`OpFactoryCall[]`) needed to render * itself back to TypeScript source. It implements * `MigrationPlanWithAuthoringSurface` so that the CLI can uniformly ask any * planner result to serialize itself to a `migration.ts`. * * Extends the framework `Migration` base class directly (not * `MongoMigration`) because `MongoMigration` lives in `@prisma-next/family-mongo`, * which depends on this package — extending it here would create a dependency * cycle. */ declare class PlannerProducedMongoMigration extends Migration implements MigrationPlanWithAuthoringSurface { private readonly calls; private readonly meta; readonly targetId: "mongo"; constructor(calls: readonly OpFactoryCall[], meta: MigrationMeta); get operations(): readonly AnyMongoMigrationOperation[]; describe(): MigrationMeta; renderTypeScript(): string; } //#endregion //#region src/core/render-ops.d.ts declare function renderOps(calls: ReadonlyArray): MongoMigrationPlanOperation[]; //#endregion //#region src/core/render-typescript.d.ts interface RenderMigrationMeta { readonly from: string | null; readonly to: string; } /** * Render a list of Mongo `OpFactoryCall`s as a `migration.ts` source string. * The result is shebanged, imports the committed contract JSON * (`end-contract.json`, plus `start-contract.json` for a non-baseline * migration), extends `Migration` (or `Migration` for * a baseline) from `@prisma-next/family-mongo`, assigns the JSON to * `endContractJson` / `startContractJson`, and implements `operations`. The * `Migration` base derives `describe()` from those fields. * * The walk is polymorphic: each call node contributes its own * `renderTypeScript()` expression and declares its own `importRequirements()`. * The top-level renderer aggregates imports across all nodes and emits one * `import { … } from "…"` line per module. The `Migration` / `MigrationCLI` * base imports and the contract-JSON imports are always emitted, independent * of the call nodes. */ declare function renderCallsToTypeScript(calls: ReadonlyArray, meta: RenderMigrationMeta): string; //#endregion export { CollModCall, type CollModMeta, CreateCollectionCall, CreateIndexCall, DropCollectionCall, DropIndexCall, FilterEvaluator, type MarkerOperations, MongoMigrationPlanner, MongoMigrationRunner, type MongoMigrationRunnerExecuteOptions, type MongoRunnerDependencies, type MongoTargetContract, MongoTargetContractSerializer, MongoTargetDatabase, MongoTargetSchemaVerifier, MongoTargetUnboundDatabase, type OpFactoryCall, type PlanCallsResult, PlannerProducedMongoMigration, type RenderMigrationMeta, deserializeMongoOp, deserializeMongoOps, mongoTargetDescriptor, renderCallsToTypeScript, renderOps, schemaCollectionToCreateCollectionOptions, schemaIndexToCreateIndexOptions, serializeMongoOps }; //# sourceMappingURL=control.d.mts.map