{"version":3,"file":"spaces.mjs","names":[],"sources":["../../src/assert-descriptor-self-consistency.ts","../../src/compute-extension-space-apply-path.ts","../../src/contract-space-from-json.ts","../../src/emit-contract-space-artefacts.ts","../../src/gather-disk-contract-space-state.ts","../../src/plan-all-spaces.ts"],"sourcesContent":["import type { PreserveEmptyPredicate, StorageSort } from '@prisma-next/contract/hashing';\nimport { computeStorageHash } from '@prisma-next/contract/hashing';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { errorDescriptorHeadHashMismatch } from './errors';\n\n/**\n * Inputs the helper needs to recompute the descriptor's storage hash and\n * compare it to the published `headRef.hash`. Kept structural so the SQL\n * family (and any future target family) can compose the check without\n * coupling to its own descriptor types.\n */\nexport interface DescriptorSelfConsistencyInputs {\n  readonly extensionId: string;\n  readonly target: string;\n  readonly targetFamily: string;\n  /**\n   * Family-specific storage object. Typed as `unknown` so callers can\n   * pass their own narrow storage shape (e.g. `SqlStorage`) without an\n   * inline cast — the helper canonicalises through `JSON.stringify`\n   * inside {@link computeStorageHash} and only requires a plain\n   * record-shaped value at runtime.\n   */\n  readonly storage: unknown;\n  readonly headRefHash: string;\n  readonly shouldPreserveEmpty?: PreserveEmptyPredicate;\n  readonly sortStorage?: StorageSort;\n}\n\n/**\n * Assert that an extension descriptor is self-consistent: the\n * `headRef.hash` it publishes must match the canonical hash recomputed\n * from its `contractSpace.contractJson`.\n *\n * Recomputes via {@link computeStorageHash} — the same canonical-JSON\n * pipeline the descriptor's own emit pipeline produced the hash with —\n * over `(target, targetFamily, storage)`. Mismatch indicates the\n * extension author bumped `contractJson` without rerunning emit, leaving\n * the descriptor's `headRef.hash` stale; the consumer-side helpers\n * (drift detection, on-disk artefact emission, runner marker writes) all\n * trust `headRef.hash` as the canonical identity, so a stale value would\n * silently corrupt every downstream boundary.\n *\n * Synchronous, pure, no I/O. Throws\n * `MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH` on failure with both the\n * recomputed and published hashes in `details` so callers can surface a\n * clear remediation hint without re-deriving them.\n */\nexport function assertDescriptorSelfConsistency(inputs: DescriptorSelfConsistencyInputs): void {\n  // The published `storage.storageHash` is the *output* of the production\n  // emit pipeline's `computeStorageHash` call, computed over a storage\n  // object that did not yet carry `storageHash`. Recomputing against the\n  // published storage as-is would feed the result back into its own input\n  // and produce a different digest. Strip `storageHash` before\n  // recomputing so the helper sees the same canonical shape the\n  // descriptor's authoring pipeline saw.\n  // The helper requires only a plain record-shaped storage value at\n  // runtime; a single cast here keeps the public input type\n  // family-agnostic (`unknown`) while still letting us strip the\n  // descriptor-published `storageHash` before re-canonicalising.\n  const storageRecord = inputs.storage as Record<string, unknown>;\n  const { storageHash: _stripped, ...storageWithoutHash } = storageRecord;\n  const recomputed = computeStorageHash({\n    target: inputs.target,\n    targetFamily: inputs.targetFamily,\n    storage: storageWithoutHash,\n    ...ifDefined('shouldPreserveEmpty', inputs.shouldPreserveEmpty),\n    ...ifDefined('sortStorage', inputs.sortStorage),\n  });\n  if (recomputed !== inputs.headRefHash) {\n    throw errorDescriptorHeadHashMismatch({\n      extensionId: inputs.extensionId,\n      recomputedHash: recomputed,\n      headRefHash: inputs.headRefHash,\n    });\n  }\n}\n","import { EMPTY_CONTRACT_HASH } from './constants';\nimport { readMigrationsDir } from './io';\nimport { findPathWithDecision, reconstructGraph } from './migration-graph';\nimport type { MigrationOps } from './package';\nimport {\n  type ContractSpaceHeadRef,\n  readContractSpaceHeadRef,\n} from './read-contract-space-head-ref';\nimport { spaceMigrationDirectory } from './space-layout';\n\n/**\n * Outcome of {@link computeExtensionSpaceApplyPath} — a discriminated union\n * mirroring {@link import('./migration-graph').FindPathOutcome} so callers\n * can map structural / invariant failures to their preferred CLI envelope\n * without re-running pathfinding.\n */\nexport type ExtensionSpaceApplyPathOutcome =\n  | {\n      readonly kind: 'ok';\n      readonly contractSpaceHeadRef: ContractSpaceHeadRef;\n      /**\n       * Sorted, deduplicated invariant ids covered by the walked path.\n       * Mirrors the on-disk `providedInvariants` summed across edges and\n       * canonicalised — what the runner stamps on the marker after apply.\n       */\n      readonly providedInvariants: readonly string[];\n      /**\n       * Path operations in apply order. Empty when the marker is already\n       * at the recorded head (no-op).\n       */\n      readonly pathOps: MigrationOps;\n      /**\n       * Migration directory names walked, in order. Mirrors `pathOps`'s\n       * structure but at the package granularity — useful for surfacing\n       * \"applied N migration(s)\" messages.\n       */\n      readonly walkedMigrationDirs: readonly string[];\n    }\n  | { readonly kind: 'unreachable'; readonly contractSpaceHeadRef: ContractSpaceHeadRef }\n  | {\n      readonly kind: 'unsatisfiable';\n      readonly contractSpaceHeadRef: ContractSpaceHeadRef;\n      readonly missing: readonly string[];\n      readonly structuralPath: readonly { readonly dirName: string; readonly to: string }[];\n    }\n  | { readonly kind: 'contractSpaceHeadRefMissing' };\n\n/**\n * Inputs to {@link computeExtensionSpaceApplyPath}. The helper is\n * deliberately framework-neutral and consumes only on-disk state:\n *\n * - `projectMigrationsDir` is the project's top-level `migrations/` dir.\n * - `spaceId` selects the per-space subdirectory under it.\n * - `currentMarkerHash` / `currentMarkerInvariants` come from the live\n *   marker row keyed by `space = <spaceId>`. `null` hash = no marker yet\n *   (the pathfinder treats this as the empty-contract sentinel per ADR\n *   208).\n */\nexport interface ComputeExtensionSpaceApplyPathInputs {\n  readonly projectMigrationsDir: string;\n  readonly spaceId: string;\n  readonly currentMarkerHash: string | null;\n  readonly currentMarkerInvariants: readonly string[];\n}\n\n/**\n * Compute the apply path for an extension contract space — the shortest\n * sequence of on-disk migration packages that walks the live marker\n * forward to the on-disk head ref hash, covering every required\n * invariant.\n *\n * Reads only on-disk artefacts (`migrations/<spaceId>/refs/head.json`\n * and the per-space migration packages). **Does not import any\n * extension descriptor module** — `db init` / `db update` must remain\n * runnable without the descriptor source on disk.\n *\n * Behaviour:\n * - Returns `{ kind: 'ok', pathOps: [], … }` when the marker is already\n *   at the recorded head and no required invariants are missing.\n * - Returns `{ kind: 'unreachable' }` when the marker hash is not\n *   structurally connected to the recorded head in the graph.\n * - Returns `{ kind: 'unsatisfiable', missing, … }` when the marker is\n *   reachable but no path covers the required invariants.\n * - Returns `{ kind: 'contractSpaceHeadRefMissing' }` when the per-space\n *   `refs/head.json` is absent — the precheck verifier should already\n *   have rejected this case, but the helper is defensive so callers can\n *   surface a coherent error rather than throw.\n */\nexport async function computeExtensionSpaceApplyPath(\n  inputs: ComputeExtensionSpaceApplyPathInputs,\n): Promise<ExtensionSpaceApplyPathOutcome> {\n  const { projectMigrationsDir, spaceId, currentMarkerHash, currentMarkerInvariants } = inputs;\n\n  const contractSpaceHeadRef = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n  if (contractSpaceHeadRef === null) {\n    return { kind: 'contractSpaceHeadRefMissing' };\n  }\n\n  const spaceDir = spaceMigrationDirectory(projectMigrationsDir, spaceId);\n  const { packages } = await readMigrationsDir(spaceDir);\n  const graph = reconstructGraph(packages);\n\n  // Live-marker layer encodes \"no prior state\" as EMPTY_CONTRACT_HASH;\n  // mirror the `migrate` flow so a fresh-marker initial walk\n  // hits the baseline migration whose `from` is EMPTY_CONTRACT_HASH.\n  const fromHash = currentMarkerHash ?? EMPTY_CONTRACT_HASH;\n  const required = new Set(\n    contractSpaceHeadRef.invariants.filter((id) => !currentMarkerInvariants.includes(id)),\n  );\n\n  const outcome = findPathWithDecision(graph, fromHash, contractSpaceHeadRef.hash, { required });\n\n  if (outcome.kind === 'unreachable') {\n    return { kind: 'unreachable', contractSpaceHeadRef };\n  }\n  if (outcome.kind === 'unsatisfiable') {\n    return {\n      kind: 'unsatisfiable',\n      contractSpaceHeadRef,\n      missing: outcome.missing,\n      structuralPath: outcome.structuralPath.map(({ dirName, to }) => ({ dirName, to })),\n    };\n  }\n\n  const packagesByHash = new Map(packages.map((pkg) => [pkg.metadata.migrationHash, pkg]));\n\n  const pathOps: MigrationOps[number][] = [];\n  const walkedMigrationDirs: string[] = [];\n  const providedInvariantsSet = new Set<string>();\n  for (const edge of outcome.decision.selectedPath) {\n    const pkg = packagesByHash.get(edge.migrationHash);\n    if (!pkg) {\n      // Path edges always come from the same `packages` array, so this\n      // is only reachable when the graph is internally inconsistent —\n      // surface it loudly rather than silently truncating the path.\n      throw new Error(\n        `Migration package missing for edge ${edge.migrationHash} in space \"${spaceId}\"`,\n      );\n    }\n    walkedMigrationDirs.push(pkg.dirName);\n    for (const op of pkg.ops) pathOps.push(op);\n    for (const invariant of pkg.metadata.providedInvariants) providedInvariantsSet.add(invariant);\n  }\n\n  return {\n    kind: 'ok',\n    contractSpaceHeadRef,\n    providedInvariants: [...providedInvariantsSet].sort(),\n    pathOps,\n    walkedMigrationDirs,\n  };\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n  ContractSpace,\n  ContractSpaceHeadRef,\n  MigrationPackage,\n  MigrationPlanOperation,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMetadata } from './metadata';\n\n/**\n * Materialise a typed {@link ContractSpace} from the JSON artefacts a\n * contract-space extension package emits to disk.\n *\n * Extension descriptors wire `contract.json`, per-migration\n * `migration.json` / `ops.json`, and `refs/head.json` to the framework's\n * typed surfaces. TypeScript widens JSON imports to a structural record\n * that does not preserve readonly modifiers or branded scalars (e.g.\n * `StorageHashBase<'sha256:...'>`), so authoring the descriptor inline\n * forces every wiring site to cast through `unknown`. This helper\n * encapsulates the single narrowing point: descriptor sources stay\n * cast-free, and the (necessary) coercion is colocated with the\n * documentation explaining why it is safe.\n *\n * Safety: the JSON files passed here are produced by the framework's own\n * emit pipeline (`prisma-next contract emit` and `MigrationCLI.run`)\n * and re-validated downstream by the runner / verifier. The descriptor\n * is a pass-through wiring layer — no descriptor consumer treats the\n * narrowed types as a stronger guarantee than \"these came from the\n * canonical emit pipeline\".\n *\n * The helper does not introspect or schema-validate the inputs; runtime\n * validation is the responsibility of `family.deserializeContract`\n * (codec-aware, invoked at control-stack construction) and the\n * per-migration `readMigrationPackage` reader used when loading\n * from disk. JSON-imported packages flow through the descriptor without\n * a disk read, so the equivalent runtime guarantee comes from the emit\n * pipeline that produced the JSON in the first place.\n */\nexport function contractSpaceFromJson<TContract extends Contract = Contract>(inputs: {\n  readonly contractJson: unknown;\n  readonly migrations: ReadonlyArray<{\n    readonly dirName: string;\n    readonly metadata: unknown;\n    readonly ops: unknown;\n  }>;\n  readonly headRef: ContractSpaceHeadRef;\n}): ContractSpace<TContract> {\n  // The narrowing happens once, here. Casting via `unknown` rather than a\n  // direct cast preserves TS's structural soundness checks for the\n  // inputs (they must be assignable to `unknown`, which is trivial); the\n  // resulting type is the family-specific Contract / MigrationPackage\n  // surface descriptors publish.\n  const migrations: readonly MigrationPackage[] = inputs.migrations.map((m) => ({\n    dirName: m.dirName,\n    metadata: m.metadata as MigrationMetadata,\n    ops: m.ops as readonly MigrationPlanOperation[],\n  }));\n  return {\n    contractJson: inputs.contractJson as TContract,\n    migrations,\n    headRef: inputs.headRef,\n  };\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { canonicalizeJson } from '@prisma-next/framework-components/utils';\nimport { join } from 'pathe';\nimport type { ContractSpaceHeadRef } from './read-contract-space-head-ref';\nimport { assertValidSpaceId, spaceRefsDirectory } from './space-layout';\n\n/**\n * Inputs for {@link emitContractSpaceArtefacts}.\n *\n * - `contract` is the canonical contract value the framework just emitted\n *   for the space; it is serialised through {@link canonicalizeJson}, so\n *   it must be a JSON-compatible value (objects / arrays / primitives).\n *   Typed as `unknown` rather than the SQL-family `Contract<SqlStorage>`\n *   to keep `migration-tools` framework-neutral; SQL-family callers pass\n *   their typed value through unchanged.\n *\n * - `contractDts` is the pre-rendered `.d.ts` text. Rendering happens in\n *   the SQL family (which owns the codec / typemap input the renderer\n *   needs), so this helper accepts the text verbatim and writes it out\n *   without further transformation.\n *\n * - `headRef` is the head reference for the space.\n *   `invariants` are sorted alphabetically before serialisation so two\n *   callers passing the same set in different orders produce\n *   byte-identical `refs/head.json`.\n */\nexport interface ContractSpaceArtefactInputs {\n  readonly contract: unknown;\n  readonly contractDts: string;\n  readonly headRef: ContractSpaceHeadRef;\n}\n\n/**\n * Emit the per-space artefacts (`contract.json`, `contract.d.ts`,\n * `refs/head.json`) under `<projectMigrationsDir>/<spaceId>/`.\n *\n * Always-overwrite: the framework owns these files; running `migrate`\n * twice with the same inputs is a no-op observably (idempotent), but the\n * helper does not check pre-existing contents — re-emit always wins.\n *\n * Path layout matches the convention in\n * [`spaceMigrationDirectory`](./space-layout.ts). The space id is\n * validated against `[a-z][a-z0-9_-]{0,63}` via\n * {@link assertValidSpaceId} for filesystem-safety reasons; the helper\n * accepts every space uniformly (including the app space, default\n * `'app'`).\n *\n * The migrations directory and space subdirectory are created if they\n * do not yet exist (`mkdir { recursive: true }`).\n */\nexport async function emitContractSpaceArtefacts(\n  projectMigrationsDir: string,\n  spaceId: string,\n  inputs: ContractSpaceArtefactInputs,\n): Promise<void> {\n  assertValidSpaceId(spaceId);\n\n  const dir = join(projectMigrationsDir, spaceId);\n  const refsDir = spaceRefsDirectory(dir);\n  await mkdir(refsDir, { recursive: true });\n\n  await writeFile(join(dir, 'contract.json'), `${canonicalizeJson(inputs.contract)}\\n`);\n  await writeFile(join(dir, 'contract.d.ts'), inputs.contractDts);\n\n  const sortedInvariants = [...inputs.headRef.invariants].sort();\n  const headJson = canonicalizeJson({\n    hash: inputs.headRef.hash,\n    invariants: sortedInvariants,\n  });\n  await writeFile(join(refsDir, 'head.json'), `${headJson}\\n`);\n}\n","import { readContractSpaceHeadRef } from './read-contract-space-head-ref';\nimport { APP_SPACE_ID } from './space-layout';\nimport {\n  type ContractSpaceHeadRecord,\n  listContractSpaceDirectories,\n} from './verify-contract-spaces';\n\n/**\n * Disk-side inputs to {@link import('./verify-contract-spaces').verifyContractSpaces}\n * — gathered without touching the live database. The caller composes\n * this with the marker rows it reads from the runtime to invoke the\n * verifier.\n */\nexport interface DiskContractSpaceState {\n  /** Contract-space directory names observed under `<projectMigrationsDir>/`. */\n  readonly spaceDirsOnDisk: readonly string[];\n  /** Head-ref `(hash, invariants)` per extension space. */\n  readonly headRefsBySpace: ReadonlyMap<string, ContractSpaceHeadRecord>;\n}\n\n/**\n * Read the on-disk state the per-space verifier needs:\n *\n * - The list of contract-space directories under\n *   `<projectMigrationsDir>/` (via\n *   {@link import('./verify-contract-spaces').listContractSpaceDirectories}).\n * - The on-disk head ref `(hash, invariants)` for each declared extension space\n *   (via {@link readContractSpaceHeadRef}; missing on-disk artefacts are simply\n *   omitted — the verifier reports them as `declaredButUnmigrated`).\n *\n * Synchronous in spirit but async due to filesystem reads. Reads only\n * the user's repo. **Does not import any extension descriptor module.**\n *\n * Composition convention: pure target-agnostic primitive in\n * `1-framework`; the SQL family (and any future target family) wires\n * it into its `dbInit` / `verify` flows alongside its own marker-row\n * read before invoking `verifyContractSpaces`.\n */\nexport async function gatherDiskContractSpaceState(args: {\n  readonly projectMigrationsDir: string;\n  /**\n   * Set of space ids the project declares: `'app'` plus each entry in\n   * `extensionPacks` whose descriptor exposes a `contractSpace`. The\n   * helper reads on-disk head data only for the extension members.\n   */\n  readonly loadedSpaceIds: ReadonlySet<string>;\n}): Promise<DiskContractSpaceState> {\n  const { projectMigrationsDir, loadedSpaceIds } = args;\n\n  const spaceDirsOnDisk = await listContractSpaceDirectories(projectMigrationsDir);\n\n  const headRefsBySpace = new Map<string, ContractSpaceHeadRecord>();\n  for (const spaceId of loadedSpaceIds) {\n    if (spaceId === APP_SPACE_ID) continue;\n    const head = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n    if (head !== null) {\n      headRefsBySpace.set(spaceId, head);\n    }\n  }\n\n  return { spaceDirsOnDisk, headRefsBySpace };\n}\n","import { errorDuplicateSpaceId } from './errors';\n\n/**\n * Per-space input for {@link planAllSpaces}. One entry per loaded\n * contract space (the application's `'app'` plus each extension that\n * exposes a `contractSpace`).\n *\n * - `priorContract` is `null` for a space that has never been emitted\n *   (no `migrations/<space-id>/contract.json` on disk yet); otherwise it\n *   is the canonical contract value emitted for that space.\n * - `newContract` is the canonical contract value the planner is about\n *   to emit for that space — for app-space, the just-emitted root\n *   `contract.json`; for an extension space, the descriptor's\n *   `contractSpace.contractJson`.\n */\nexport interface SpacePlanInput<TContract> {\n  readonly spaceId: string;\n  readonly priorContract: TContract | null;\n  readonly newContract: TContract;\n}\n\nexport interface SpacePlanOutput<TPackage> {\n  readonly spaceId: string;\n  readonly migrationPackages: readonly TPackage[];\n}\n\n/**\n * Iterate the per-space planner across a set of loaded contract spaces\n * and return a deterministic shape regardless of declaration order.\n *\n * Behaviour:\n *\n * - The output is sorted alphabetically by `spaceId`. Two callers\n *   passing the same set of inputs in different orders observe\n *   byte-identical outputs.\n * - The per-space planner (`planSpace`) is called exactly once per\n *   input, in alphabetical-by-spaceId order. Its return value is\n *   attached to the corresponding output entry verbatim.\n * - Duplicate `spaceId`s in the input array throw\n *   `MIGRATION.DUPLICATE_SPACE_ID` before any `planSpace` call runs,\n *   keeping the planner pure when the input is malformed.\n *\n * The signature is generic over `TContract` and `TPackage` because the\n * shape is framework-neutral (SQL family today, Mongo family\n * eventually). Callers wire in whatever contract value and migration\n * package shape their family already speaks.\n *\n * Synchronous: the underlying per-space planner (target's\n * `MigrationPlanner.plan(...)`) is synchronous; callers that need to\n * resolve async I/O (e.g. reading on-disk `contract.json` from disk)\n * resolve it before calling `planAllSpaces` and pass the materialised\n * inputs through.\n */\nexport function planAllSpaces<TContract, TPackage>(\n  inputs: readonly SpacePlanInput<TContract>[],\n  planSpace: (input: SpacePlanInput<TContract>) => readonly TPackage[],\n): readonly SpacePlanOutput<TPackage>[] {\n  const seen = new Set<string>();\n  for (const input of inputs) {\n    if (seen.has(input.spaceId)) {\n      throw errorDuplicateSpaceId(input.spaceId);\n    }\n    seen.add(input.spaceId);\n  }\n\n  const sorted = [...inputs].sort((a, b) => {\n    if (a.spaceId < b.spaceId) return -1;\n    if (a.spaceId > b.spaceId) return 1;\n    return 0;\n  });\n\n  return sorted.map((input) => ({\n    spaceId: input.spaceId,\n    migrationPackages: planSpace(input),\n  }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;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