{"version":3,"file":"migration.mjs","names":["#endView","#startView"],"sources":["../src/core/mongo-migration.ts"],"sourcesContent":["import { Migration, MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { MongoContract } from '@prisma-next/mongo-contract';\nimport type { AnyMongoMigrationOperation } from '@prisma-next/mongo-query-ast/control';\nimport { MongoContractView } from './ir/mongo-contract-view';\n\n/**\n * Family-owned base class for Mongo migrations.\n *\n * Provides the fixed `targetId = 'mongo'` so that user-authored migrations\n * and renderer-generated scaffolds (e.g. the output of\n * `renderCallsToTypeScript`) inherit it directly and don't have to re-declare\n * the abstract `targetId` member from `Migration`.\n *\n * The operation type parameter is `AnyMongoMigrationOperation` — the union\n * of DDL-shaped `MongoMigrationPlanOperation` and `MongoDataTransformOperation` —\n * so subclasses can return a mix of schema operations (e.g. `createIndex`,\n * `setValidation`) and data-transform operations (e.g. `dataTransform`).\n * Mirrors the generic parameter used by `PlannerProducedMongoMigration`.\n *\n * Binds the framework base's `Start` / `End` contract generics so a subclass\n * that assigns its `start-contract.json` / `end-contract.json` imports gets\n * fully-typed view accessors: `this.endContract` is a `MongoContractView<End>`\n * (and `this.startContract` a `MongoContractView<Start> | null`), built lazily\n * from those JSON fields via the shared `MigrationContractViews` helper. The\n * framework base derives `describe()` from the same JSON. View getters live on\n * the family base (not the framework base) because `MongoContractView`'s shape\n * is Mongo-specific.\n */\nexport abstract class MongoMigration<\n  Start extends MongoContract = MongoContract,\n  End extends MongoContract = MongoContract,\n> extends Migration<AnyMongoMigrationOperation, string, string, Start, End> {\n  readonly targetId = 'mongo' as const;\n\n  #endView = new MigrationContractViews<MongoContractView<End>>(this, 'MongoMigration', (json) =>\n    MongoContractView.fromJson<End>(json),\n  );\n  #startView = new MigrationContractViews<MongoContractView<Start>>(\n    this,\n    'MongoMigration',\n    (json) => MongoContractView.fromJson<Start>(json),\n  );\n\n  /**\n   * The typed, namespace-unwrapped view over this migration's end-state\n   * contract — `this.endContract.collection.<name>.validator`, etc. Throws if\n   * no `endContractJson` was provided (a `describe()`-overriding migration\n   * with no contract has no view to expose).\n   */\n  get endContract(): MongoContractView<End> {\n    return this.#endView.endContract;\n  }\n\n  /**\n   * The typed view over this migration's start-state contract, or `null` for\n   * a baseline migration (no `startContractJson`).\n   */\n  get startContract(): MongoContractView<Start> | null {\n    return this.#startView.startContract;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAsB,iBAAtB,cAGU,UAAkE;CAC1E,WAAoB;CAEpB,WAAW,IAAI,uBAA+C,MAAM,mBAAmB,SACrF,kBAAkB,SAAc,IAAI,CACtC;CACA,aAAa,IAAI,uBACf,MACA,mBACC,SAAS,kBAAkB,SAAgB,IAAI,CAClD;;;;;;;CAQA,IAAI,cAAsC;EACxC,OAAO,KAAKA,SAAS;CACvB;;;;;CAMA,IAAI,gBAAiD;EACnD,OAAO,KAAKC,WAAW;CACzB;AACF"}