//#region src/verify-contract-spaces.d.ts /** * List the per-space subdirectories under * `/migrations/`. Returns space-id directory names (sorted * alphabetically) — i.e. any non-dot-prefixed subdirectory whose root * does **not** contain a `migration.json` manifest. The manifest is the * structural marker of a user-authored migration directory (see * `readMigrationsDir` in `./io`); directory names themselves belong to * the user and are not part of the contract. * * Returns `[]` if the migrations directory does not exist (greenfield * project). * * Reads only the user's repo. **No descriptor import.** The caller * (verifier) feeds the result into {@link verifyContractSpaces} alongside * the loaded-space set and the marker rows. */ declare function listContractSpaceDirectories(projectMigrationsDir: string): Promise; /** * On-disk head value (`(hash, invariants)`) for one contract space. * The verifier compares this against the marker row for the same space * to detect drift between the user-emitted artefacts and the live DB * marker. */ interface ContractSpaceHeadRecord { readonly hash: string; readonly invariants: readonly string[]; } /** * Marker row read from `prisma_contract.marker` (one per `space`). * Caller resolves these via the family runtime's marker reader before * invoking {@link verifyContractSpaces}. */ interface SpaceMarkerRecord { readonly hash: string; readonly invariants: readonly string[]; } interface VerifyContractSpacesInputs { /** * Set of contract spaces the project declares: `'app'` plus each * extension space in `extensionPacks`. The caller's discovery path * never reads the extension descriptor module — it walks the * `extensionPacks` configuration in `prisma-next.config.ts` for the * space ids. */ readonly loadedSpaces: ReadonlySet; /** * Per-space subdirectories observed under * `/migrations/`. Resolved via * {@link listContractSpaceDirectories}. */ readonly spaceDirsOnDisk: readonly string[]; /** * Head ref per space, keyed by space id. Caller reads * `/migrations//contract.json` and * `/migrations//refs/head.json` to construct * this map. Spaces with no contract-space dir on disk simply omit a * map entry. */ readonly headRefsBySpace: ReadonlyMap; /** * Marker rows keyed by `space`. Caller reads them from the * `prisma_contract.marker` table. */ readonly markerRowsBySpace: ReadonlyMap; } type SpaceVerifierViolation = { readonly kind: 'declaredButUnmigrated'; readonly spaceId: string; readonly remediation: string; } | { readonly kind: 'orphanMarker'; readonly spaceId: string; readonly remediation: string; } | { readonly kind: 'orphanSpaceDir'; readonly spaceId: string; readonly remediation: string; } | { readonly kind: 'hashMismatch'; readonly spaceId: string; readonly priorHeadHash: string; readonly markerHash: string; readonly remediation: string; } | { readonly kind: 'invariantsMismatch'; readonly spaceId: string; readonly onDiskInvariants: readonly string[]; readonly markerInvariants: readonly string[]; readonly remediation: string; }; type VerifyContractSpacesResult = { readonly ok: true; } | { readonly ok: false; readonly violations: readonly SpaceVerifierViolation[]; }; /** * Pure structural verifier for the per-space mechanism. Aggregates the * three orphan / missing checks plus per-space hash and invariant * comparison. * * Algorithm: * * - For every extension space declared in `loadedSpaces` (`'app'` * excluded — the per-space verifier is scoped to extension members; * the app is verified through the aggregate path): * - If no contract-space dir on disk → `declaredButUnmigrated`. * - Else if `markerRowsBySpace` lacks an entry → no violation here; * the live-DB compare done outside this helper is where the * absence shows up. * - Else compare marker hash / invariants vs. on-disk head hash / * invariants → `hashMismatch` / `invariantsMismatch` on drift. * - For every contract-space dir on disk that is not in `loadedSpaces` → * `orphanSpaceDir`. * - For every marker row whose `space` is not in `loadedSpaces` → * `orphanMarker`. The app-space marker is always loaded (`'app'` is * in `loadedSpaces` by definition). * * Output is deterministic: violations are sorted first by `kind` * (`declaredButUnmigrated` → `orphanMarker` → `orphanSpaceDir` → * `hashMismatch` → `invariantsMismatch`) then by `spaceId`. Two callers * passing equivalent inputs see byte-identical violation lists. * * Synchronous, pure, no I/O. **Does not import the extension descriptor** * (the inputs are pre-resolved by the caller); the verifier reads only * the user repo, not `node_modules`. */ declare function verifyContractSpaces(inputs: VerifyContractSpacesInputs): VerifyContractSpacesResult; //#endregion export { VerifyContractSpacesResult as a, VerifyContractSpacesInputs as i, SpaceMarkerRecord as n, listContractSpaceDirectories as o, SpaceVerifierViolation as r, verifyContractSpaces as s, ContractSpaceHeadRecord as t }; //# sourceMappingURL=verify-contract-spaces-CnXNGpBV.d.mts.map