import { n as OnDiskMigrationPackage, t as MigrationOps } from "./package-CWicKzNs.mjs"; import { MigrationMetadata, MigrationPackage } from "@prisma-next/framework-components/control"; //#region src/io.d.ts declare function writeMigrationPackage(dir: string, metadata: MigrationMetadata, ops: MigrationOps): Promise; /** * Materialise an in-memory {@link MigrationPackage} to a per-space * directory on disk. * * Writes two files under `//`: * * - `migration.json` — the manifest (pretty-printed, matches * {@link writeMigrationPackage}'s output for byte-for-byte parity with * app-space migrations). * - `ops.json` — the operation list (pretty-printed). * * Distinct verb from the lower-level {@link writeMigrationPackage} * (which takes constituent `(metadata, ops)`): callers reading * `materialise…` know they are persisting a struct-typed package. * * Overwrite-idempotent: the per-package directory is cleared before * each emit, so re-running against the same `targetDir` produces * byte-identical contents and never leaves stale files behind. The * lower-level {@link writeMigrationPackage} stays strict because the * CLI authoring path (`migration plan` / `migration new`) deliberately * refuses to clobber an existing authored migration; this helper is * the re-emit path that is supposed to converge on a single canonical * on-disk shape. * * The per-space head contract lives at * `//contract.json` (written by * {@link import('./emit-contract-space-artefacts').emitContractSpaceArtefacts}), * not inside the per-package directory. The runner reads only * `migration.json` + `ops.json` from each package. */ declare function materialiseMigrationPackage(targetDir: string, pkg: MigrationPackage): Promise; /** * Idempotent variant of {@link materialiseMigrationPackage}: writes the * package only if `//` does not already exist on * disk as a directory; returns `{ written: false }` when the package * directory is present (no rewrite, no comparison — by-existence skip). * * Concretely: * - existing directory → skip silently, return `{ written: false }`. * - missing path → write three files via {@link materialiseMigrationPackage}, * return `{ written: true }`. * - path exists but is not a directory (file/symlink) → treated as * missing; {@link materialiseMigrationPackage} will attempt creation * and fail with an appropriate OS error. * - any other I/O error from `stat` → propagated unchanged. * * Used by the CLI's `runContractSpaceExtensionMigrationsPass` to * materialise extension migration packages into a project's * `migrations//` directory, and by extension-package tests * that mirror the same idempotent-rematerialise property locally * without taking a CLI dependency. */ declare function materialiseExtensionMigrationPackageIfMissing(targetDir: string, pkg: MigrationPackage): Promise<{ readonly written: boolean; }>; /** * Copy a list of files into `destDir`, optionally renaming each one. * * The destination directory is created (with `recursive: true`) if it * does not already exist. Each source path is copied byte-for-byte into * `destDir/`; missing sources throw `ENOENT`. The helper is * intentionally generic: callers own the list of files (e.g. a contract * emitter's emitted output) and the naming convention (e.g. renaming * the destination contract to `end-contract.*` and the source contract * to `start-contract.*`). */ declare function copyFilesWithRename(destDir: string, files: readonly { readonly sourcePath: string; readonly destName: string; }[]): Promise; declare function writeMigrationMetadata(dir: string, metadata: MigrationMetadata): Promise; declare function writeMigrationOps(dir: string, ops: MigrationOps): Promise; declare function readMigrationPackage(dir: string): Promise; /** * A per-package load-time problem returned by {@link readMigrationsDir}. * * Three variants, matching the relocated throws from the load path: * * - `hashMismatch` — stored `migrationHash` differs from the recomputed value. * The package is **retained** in the returned `packages` array. * - `providedInvariantsMismatch` — `migration.json` declares different * `providedInvariants` than `ops.json` implies. The package is **retained**. * - `packageUnloadable` — the manifest is missing, unparseable, or schema- * invalid. The package is **omitted** from `packages`. * * Callers that need the `spaceId` context (e.g. the aggregate loader) attach * it when converting to {@link import('./integrity-violation').IntegrityViolation}. */ type PackageLoadProblem = { readonly kind: 'hashMismatch'; readonly dirName: string; readonly stored: string; readonly computed: string; } | { readonly kind: 'providedInvariantsMismatch'; readonly dirName: string; } | { readonly kind: 'packageUnloadable'; readonly dirName: string; readonly detail: string; }; /** * Result returned by {@link readMigrationsDir}. * * - `packages` — every package that could be read; hash-mismatched and * invariants-mismatched packages are included here (the problem is * represented rather than fatal). * - `problems` — one entry per package that had a load-time issue. * `packageUnloadable` entries are **not** in `packages`. */ interface ReadMigrationsDirResult { readonly packages: readonly OnDiskMigrationPackage[]; readonly problems: readonly PackageLoadProblem[]; } declare function readMigrationsDir(migrationsRoot: string): Promise; declare function formatMigrationDirName(timestamp: Date, slug: string): string; //#endregion export { materialiseExtensionMigrationPackageIfMissing as a, readMigrationsDir as c, writeMigrationPackage as d, formatMigrationDirName as i, writeMigrationMetadata as l, ReadMigrationsDirResult as n, materialiseMigrationPackage as o, copyFilesWithRename as r, readMigrationPackage as s, PackageLoadProblem as t, writeMigrationOps as u }; //# sourceMappingURL=io-q04IrTcd.d.mts.map