import { i as Refs } from "../refs-BNCUu58Y.mjs"; import { n as MigrationGraph, t as MigrationEdge } from "../graph-bDjJ4GL9.mjs"; import { Result } from "@prisma-next/utils/result"; //#region src/refs/types.d.ts /** Context required to resolve a contract or migration reference. */ interface RefResolutionContext { readonly graph: MigrationGraph; readonly refs: Refs; /** * Hash of the on-disk contract (`contract.json`). Required to resolve the * `@contract` reserved token, which is an offline-resolvable alias for * "the working contract the app carries." */ readonly contractHash?: string; } type ContractRefProvenance = { readonly kind: 'hash'; readonly input: string; } | { readonly kind: 'ref'; readonly refName: string; } | { readonly kind: 'migration-to'; readonly dirName: string; } | { readonly kind: 'migration-from'; readonly dirName: string; } /** * Resolved from the `@contract` reserved token — the hash of the on-disk * working contract (`contract.json`). Offline-resolvable. */ | { readonly kind: 'reserved-contract'; } /** * Resolved from the `@db` reserved token — the live database marker. * The `hash` field is a placeholder; callers must resolve the actual hash * via `readAllMarkers()` before using it. Check `provenance.kind === * 'reserved-db'` to detect this case and perform the DB lookup. */ | { readonly kind: 'reserved-db'; }; /** A resolved contract reference: the target hash and how it was derived. */ interface ContractRef { readonly hash: string; readonly provenance: ContractRefProvenance; } type MigrationRefProvenance = { readonly kind: 'dir-name'; readonly dirName: string; } | { readonly kind: 'hash'; readonly input: string; }; /** A resolved migration reference. */ interface MigrationRef { readonly dirName: string; readonly migrationHash: string; readonly from: string; readonly to: string; readonly provenance: MigrationRefProvenance; } interface RefResolutionNotFound { readonly kind: 'not-found'; readonly input: string; readonly grammar: 'contract' | 'migration'; } interface RefResolutionAmbiguous { readonly kind: 'ambiguous'; readonly input: string; readonly candidates: readonly string[]; readonly grammar: 'contract' | 'migration'; } interface RefResolutionWrongGrammar { readonly kind: 'wrong-grammar'; readonly input: string; readonly expectedGrammar: 'contract' | 'migration'; readonly message: string; readonly fix: string; } interface RefResolutionInvalidFormat { readonly kind: 'invalid-format'; readonly input: string; readonly reason: string; } type RefResolutionError = RefResolutionNotFound | RefResolutionAmbiguous | RefResolutionWrongGrammar | RefResolutionInvalidFormat; declare function findEdgeByDirName(graph: MigrationGraph, dirName: string): MigrationEdge | undefined; //#endregion //#region src/refs/contract-ref.d.ts /** * Resolve a user-supplied string to a contract hash using the unified * contract-reference grammar. * * Accepted forms: * - `@contract` — the on-disk working contract hash (offline; requires * `ctx.contractHash` to be set) * - `@db` — the live database marker (connection-required); callers MUST * check `result.value.provenance.kind === 'reserved-db'` and resolve the * actual hash via `readAllMarkers()` before using `result.value.hash` * - Full storage hash (`sha256:<64 hex>` or `sha256:empty`) * - Hex prefix (6+ hex chars, must uniquely identify one contract) * - Ref name (looked up in the refs index) * - Migration directory name (resolves to the migration's `to`-contract) * - `