prisma-next 0.5.0-dev.67 → 0.5.0-dev.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +8 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/client-0ZX24FXF.mjs +1398 -0
- package/dist/client-0ZX24FXF.mjs.map +1 -0
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +7 -5
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +2 -2
- package/dist/commands/db-sign.mjs +2 -2
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +7 -5
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.d.mts.map +1 -1
- package/dist/commands/db-verify.mjs +1 -320
- package/dist/commands/migration-apply.mjs +11 -11
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.mjs +5 -5
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -344
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.mjs +1 -1
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +8 -7
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.mjs +1 -1
- package/dist/{contract-emit-B0nGrDtk.mjs → contract-emit-DkMqO7f2.mjs} +2 -2
- package/dist/{contract-emit-B0nGrDtk.mjs.map → contract-emit-DkMqO7f2.mjs.map} +1 -1
- package/dist/{contract-infer-BjMJaOOa.mjs → contract-infer-BDKAE0B0.mjs} +3 -3
- package/dist/{contract-infer-BjMJaOOa.mjs.map → contract-infer-BDKAE0B0.mjs.map} +1 -1
- package/dist/db-verify-B4TdDKOI.mjs +403 -0
- package/dist/db-verify-B4TdDKOI.mjs.map +1 -0
- package/dist/exports/control-api.d.mts +201 -3
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +2 -2
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +17 -17
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{init-C3qdc0Sh.mjs → init-Deo7U8_U.mjs} +2 -2
- package/dist/{init-C3qdc0Sh.mjs.map → init-Deo7U8_U.mjs.map} +1 -1
- package/dist/{inspect-live-schema-33rxnu0K.mjs → inspect-live-schema-BAgQMYpD.mjs} +3 -3
- package/dist/{inspect-live-schema-33rxnu0K.mjs.map → inspect-live-schema-BAgQMYpD.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-DQo4R0XT.mjs → migration-command-scaffold-B8J702Uh.mjs} +3 -3
- package/dist/{migration-command-scaffold-DQo4R0XT.mjs.map → migration-command-scaffold-B8J702Uh.mjs.map} +1 -1
- package/dist/migration-plan-BcKNnTM7.mjs +530 -0
- package/dist/migration-plan-BcKNnTM7.mjs.map +1 -0
- package/dist/{migration-status-C_2FSkbf.mjs → migration-status-CjwB2of-.mjs} +6 -6
- package/dist/{migration-status-C_2FSkbf.mjs.map → migration-status-CjwB2of-.mjs.map} +1 -1
- package/dist/{output-BTgnZ5c_.mjs → output-DnjfCC_u.mjs} +1 -1
- package/dist/{output-BTgnZ5c_.mjs.map → output-DnjfCC_u.mjs.map} +1 -1
- package/dist/{result-handler-C0QeiqKO.mjs → result-handler-DWb1rFS-.mjs} +18 -3
- package/dist/result-handler-DWb1rFS-.mjs.map +1 -0
- package/package.json +11 -11
- package/dist/client-CW1hcUtM.mjs +0 -1025
- package/dist/client-CW1hcUtM.mjs.map +0 -1
- package/dist/commands/db-verify.mjs.map +0 -1
- package/dist/commands/migration-plan.mjs.map +0 -1
- package/dist/result-handler-C0QeiqKO.mjs.map +0 -1
- /package/dist/{cli-errors-BWn943z2.d.mts → cli-errors-QH8kf-C2.d.mts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-plan-BcKNnTM7.mjs","names":[],"sources":["../src/utils/contract-space-extension-migrations-pass.ts","../src/utils/contract-space-migrate-pass.ts","../src/commands/migration-plan.ts"],"sourcesContent":["import { materialiseExtensionMigrationPackageIfMissing } from '@prisma-next/migration-tools/io';\nimport type { MigrationMetadata } from '@prisma-next/migration-tools/metadata';\nimport type { MigrationOps } from '@prisma-next/migration-tools/package';\nimport {\n planAllSpaces,\n type SpacePlanOutput,\n spaceMigrationDirectory,\n} from '@prisma-next/migration-tools/spaces';\n\n/**\n * In-memory authored migration package shipped by an extension descriptor.\n * Mirrors `MigrationPackage` from `@prisma-next/migration-tools/io`\n * (the on-disk shape minus `dirPath`); redeclared structurally here so\n * the CLI helper does not couple to the SQL family's `ExtensionMigrationPackage`\n * type — any family that ships pre-built migration packages can pass them\n * through unchanged.\n */\nexport interface DescriptorMigrationPackage {\n readonly dirName: string;\n readonly metadata: MigrationMetadata;\n readonly ops: MigrationOps;\n}\n\n/**\n * Minimal descriptor view consumed by the migration-materialisation pass.\n * Mirrors {@link import('./contract-space-migrate-pass').MigrateExtensionInput}\n * but adds the `migrations` field — the canonical set of pre-built\n * migration packages the extension ships.\n */\nexport interface ExtensionMigrationsExtensionInput {\n readonly id: string;\n readonly contractSpace?: {\n readonly contractJson: unknown;\n readonly migrations: readonly DescriptorMigrationPackage[];\n readonly headRef: { readonly hash: string; readonly invariants: readonly string[] };\n };\n}\n\nexport interface ContractSpaceExtensionMigrationsPassInputs {\n readonly migrationsDir: string;\n readonly extensionPacks: ReadonlyArray<ExtensionMigrationsExtensionInput>;\n}\n\nexport interface ContractSpaceExtensionMigrationsPassResult {\n readonly emitted: readonly { readonly spaceId: string; readonly dirName: string }[];\n readonly skipped: readonly { readonly spaceId: string; readonly dirName: string }[];\n}\n\n/**\n * Materialise an extension's pre-built migration packages onto disk\n * under `migrations/<spaceId>/<dirName>/` for every package that does\n * not yet exist there.\n *\n * Helper-location pattern — the per-space \"planner\" for extension\n * spaces is a no-op that just returns the descriptor's `migrations`\n * verbatim; the value `planAllSpaces` brings to this consumer site is\n * **deterministic ordering** (alphabetical by spaceId) and\n * **duplicate-spaceId detection**. The actual write is performed via\n * `materialiseMigrationPackage` per package.\n *\n * Idempotent: an existing `migrations/<spaceId>/<dirName>/` is left\n * untouched and reported in `result.skipped` — the helper never\n * overwrites authored migration content, ensuring re-running\n * `migrate` does not corrupt or churn extension migration packages.\n *\n * Per-space artefacts (`contract.json`, `contract.d.ts`,\n * `refs/head.json`) are emitted by\n * {@link import('./contract-space-migrate-pass').runContractSpaceMigratePass}\n * separately — they cover the head-pointer side of the ledger. This\n * helper covers the migration-graph side.\n */\nexport async function runContractSpaceExtensionMigrationsPass(\n inputs: ContractSpaceExtensionMigrationsPassInputs,\n): Promise<ContractSpaceExtensionMigrationsPassResult> {\n const planInputs = inputs.extensionPacks\n .filter(\n (\n pack,\n ): pack is ExtensionMigrationsExtensionInput & {\n contractSpace: NonNullable<ExtensionMigrationsExtensionInput['contractSpace']>;\n } => pack.contractSpace !== undefined,\n )\n .map((pack) => ({\n spaceId: pack.id,\n priorContract: null,\n newContract: pack.contractSpace.contractJson,\n __migrations: pack.contractSpace.migrations,\n }));\n\n // Threading the descriptor's pre-built migrations into the\n // `planAllSpaces` callback by piggybacking on the input shape.\n // The framework helper is generic over the per-space planner output;\n // here the \"planner\" is a no-op that returns the descriptor's\n // `migrations` array. The benefit of routing through `planAllSpaces`\n // is duplicate-spaceId detection + alphabetical ordering — failures\n // there throw `MIGRATION.DUPLICATE_SPACE_ID` before any write.\n const planned: readonly SpacePlanOutput<DescriptorMigrationPackage>[] = planAllSpaces(\n planInputs,\n (input) =>\n (input as typeof input & { readonly __migrations: readonly DescriptorMigrationPackage[] })\n .__migrations,\n );\n\n const emitted: { spaceId: string; dirName: string }[] = [];\n const skipped: { spaceId: string; dirName: string }[] = [];\n\n for (const space of planned) {\n const spaceDir = spaceMigrationDirectory(inputs.migrationsDir, space.spaceId);\n for (const pkg of space.migrationPackages) {\n const { written } = await materialiseExtensionMigrationPackageIfMissing(spaceDir, pkg);\n if (written) {\n emitted.push({ spaceId: space.spaceId, dirName: pkg.dirName });\n } else {\n skipped.push({ spaceId: space.spaceId, dirName: pkg.dirName });\n }\n }\n }\n\n return { emitted, skipped };\n}\n","import {\n detectSpaceContractDrift,\n emitContractSpaceArtefacts,\n readContractSpaceHeadRef,\n type SpaceContractDriftResult,\n} from '@prisma-next/migration-tools/spaces';\n\n/**\n * Minimal descriptor view consumed by the migrate-time per-space pass.\n *\n * The CLI receives descriptors typed against the SQL family (or any other\n * family in the future); this helper only needs the structural shape of\n * `contractSpace`, so it accepts an `unknown`-typed `contractJson` and\n * a structurally-typed `headRef`. SQL-family callers pass the same\n * `Contract<SqlStorage>` value through unchanged — `emitContractSpaceArtefacts`\n * already serialises through `canonicalizeJson` and is framework-neutral.\n *\n * @see specs/framework-mechanism.spec.md § 3 — Per-space helper location.\n */\nexport interface MigrateExtensionInput {\n readonly id: string;\n readonly contractSpace?: {\n readonly contractJson: unknown;\n readonly headRef: { readonly hash: string; readonly invariants: readonly string[] };\n };\n}\n\n/**\n * Inputs needed to compose the migrate-time per-space pass at the CLI\n * surface — typically called once after the app-space migration package\n * has been written, regardless of whether the app-space had structural\n * changes (an extension bump alone should still re-pin its artefacts).\n */\nexport interface ContractSpaceMigratePassInputs {\n readonly migrationsDir: string;\n readonly extensionPacks: ReadonlyArray<MigrateExtensionInput>;\n}\n\nexport interface ContractSpaceMigratePassResult {\n readonly drifts: readonly SpaceContractDriftResult[];\n readonly emittedSpaceIds: readonly string[];\n}\n\n/**\n * Run drift detection + on-disk artefact emission for every loaded\n * extension space at `migrate` time.\n *\n * Per sub-spec § 3:\n *\n * - For each declared extension that exposes a `contractSpace`:\n * - Read the on-disk head hash from `migrations/<spaceId>/refs/head.json`\n * (returns `null` on first emit).\n * - Compare against the descriptor's `headRef.hash` via\n * `detectSpaceContractDrift`. The `kind` discriminant decides whether\n * the user sees a warning (`drift`), a no-op silent emit (`firstEmit`,\n * `noDrift`), or nothing at all.\n * - Always re-emit the on-disk artefacts (`contract.json`, `contract.d.ts`,\n * `refs/head.json`). The framework owns these files and the helper is\n * idempotent.\n *\n * Drift warnings are returned to the caller for formatting (TerminalUI,\n * structured-output envelope, etc.) — the helper does not print directly,\n * keeping it framework-neutral and unit-testable.\n *\n * Extension migration packages (the descriptor's pre-canned `migrations`\n * array → `migrations/<spaceId>/<dirName>/`) are intentionally not\n * materialised here — that interaction will be wired in a follow-on round\n * once the runner-side single-tx slice (sub-spec § 6) is in place.\n * On-disk artefacts are sufficient to lock the drift-warning behaviour\n * and the always-on re-emit AC for R2.\n *\n * @see specs/framework-mechanism.spec.md § 3 — Drift detection (T1.9).\n */\nexport async function runContractSpaceMigratePass(\n inputs: ContractSpaceMigratePassInputs,\n): Promise<ContractSpaceMigratePassResult> {\n const drifts: SpaceContractDriftResult[] = [];\n const emittedSpaceIds: string[] = [];\n\n for (const pack of inputs.extensionPacks) {\n if (pack.contractSpace === undefined) continue;\n const { contractJson, headRef } = pack.contractSpace;\n\n const onDiskHeadRef = await readContractSpaceHeadRef(inputs.migrationsDir, pack.id);\n const drift = detectSpaceContractDrift(pack.id, {\n descriptorHash: headRef.hash,\n priorHeadHash: onDiskHeadRef?.hash ?? null,\n });\n drifts.push(drift);\n\n await emitContractSpaceArtefacts(inputs.migrationsDir, pack.id, {\n contract: contractJson,\n contractDts: buildPlaceholderContractDts(pack.id),\n headRef: { hash: headRef.hash, invariants: headRef.invariants },\n });\n emittedSpaceIds.push(pack.id);\n }\n\n return { drifts, emittedSpaceIds };\n}\n\n/**\n * Format the user-facing drift warning for a single space. Callers\n * funnel this through their preferred output channel (TerminalUI line,\n * structured-output envelope `warnings[]`, etc.).\n *\n * Locks AM7 — drift warning surfaces the extension name and the diff\n * direction (descriptor → on-disk head).\n */\nexport function formatContractSpaceDriftWarning(drift: SpaceContractDriftResult): string {\n if (drift.kind !== 'drift') {\n throw new Error(`formatContractSpaceDriftWarning called with non-drift result: ${drift.kind}`);\n }\n return (\n `Contract-space drift detected for \"${drift.spaceId}\": descriptor hash ` +\n `${drift.descriptorHash} differs from on-disk head hash ${drift.priorHeadHash ?? '<none>'}. ` +\n `The on-disk artefacts under migrations/${drift.spaceId}/ will be refreshed to match the descriptor.`\n );\n}\n\n/**\n * Placeholder `.d.ts` content for an extension space's on-disk mirror.\n *\n * Rendering a fully-typed `.d.ts` for an extension contract requires the\n * SQL-family renderer with the codec / typemap registry threaded\n * through; that integration is tracked under sub-spec Open Question 3\n * (see `projects/extension-contract-spaces/specs/framework-mechanism.spec.md`).\n *\n * Until that ships, the on-disk `.d.ts` is a `@ts-nocheck` stub. The\n * spec gap closing alongside the typed renderer is **AC2 / AC14**\n * (byte-equivalence of per-space artefacts under `migrate`):\n * a placeholder cannot be byte-equal to a fully-rendered `.d.ts` from\n * the same descriptor, so AC2 / AC14 are PARTIAL today and become\n * fully-PASS once OQ3 closes.\n *\n * Scheduled to close in **M3** (cipherstash editor tooling) — that's\n * the milestone where the typed renderer gets its first real\n * extension-space consumer and the byte-equivalence guarantee is\n * practically required.\n */\nfunction buildPlaceholderContractDts(spaceId: string): string {\n return [\n '// @ts-nocheck',\n '/**',\n ` * Placeholder \\`.d.ts\\` for extension space \"${spaceId}\".`,\n ' *',\n ' * The framework re-emits this file on every `migrate` run alongside',\n ' * `contract.json` and `refs/head.json`. A typed `.d.ts` rendering',\n \" * pass for extension contracts is tracked under the project's open\",\n ' * questions; until that ships, consumers should import',\n ' * `contract.json` directly with `validateContract<…>(…)`.',\n ' */',\n 'export {};',\n '',\n ].join('\\n');\n}\n","import { readFile } from 'node:fs/promises';\nimport type { Contract } from '@prisma-next/contract/types';\nimport { getEmittedArtifactPaths } from '@prisma-next/emitter';\nimport {\n APP_SPACE_ID,\n createControlStack,\n hasOperationPreview,\n type MigrationPlanOperation,\n type OperationPreview,\n} from '@prisma-next/framework-components/control';\nimport { MigrationToolsError } from '@prisma-next/migration-tools/errors';\nimport { computeMigrationHash } from '@prisma-next/migration-tools/hash';\nimport { deriveProvidedInvariants } from '@prisma-next/migration-tools/invariants';\nimport {\n copyFilesWithRename,\n formatMigrationDirName,\n writeMigrationPackage,\n} from '@prisma-next/migration-tools/io';\nimport type { MigrationMetadata } from '@prisma-next/migration-tools/metadata';\nimport { findLatestMigration } from '@prisma-next/migration-tools/migration-graph';\nimport { writeMigrationTs } from '@prisma-next/migration-tools/migration-ts';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { join, relative } from 'pathe';\nimport { loadConfig } from '../config-loader';\nimport {\n type CliErrorConflict,\n CliStructuredError,\n errorContractValidationFailed,\n errorFileNotFound,\n errorMigrationPlanningFailed,\n errorRuntime,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n mapMigrationToolsError,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n getTargetMigrations,\n loadMigrationPackages,\n resolveContractPath,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport {\n type ExtensionMigrationsExtensionInput,\n runContractSpaceExtensionMigrationsPass,\n} from '../utils/contract-space-extension-migrations-pass';\nimport {\n formatContractSpaceDriftWarning,\n type MigrateExtensionInput,\n runContractSpaceMigratePass,\n} from '../utils/contract-space-migrate-pass';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport { assertFrameworkComponentsCompatible } from '../utils/framework-components';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\n\ninterface MigrationPlanOptions extends CommonCommandOptions {\n readonly config?: string;\n readonly name?: string;\n readonly from?: string;\n}\n\nexport interface MigrationPlanResult {\n readonly ok: boolean;\n readonly noOp: boolean;\n readonly from: string | null;\n readonly to: string;\n readonly dir?: string;\n readonly operations: readonly {\n readonly id: string;\n readonly label: string;\n readonly operationClass: string;\n }[];\n /**\n * Family-agnostic textual preview of the migration plan operations.\n * Replaces the previous `sql?: readonly string[]` field; consumers should\n * read `result.preview?.statements`.\n */\n readonly preview?: OperationPreview;\n readonly summary: string;\n /**\n * When true, `migration.ts` was written but contains unfilled\n * `placeholder(...)` calls. The user must edit the file and then run\n * `node migration.ts` to self-emit `ops.json` / `migration.json`.\n */\n readonly pendingPlaceholders?: boolean;\n readonly timings: {\n readonly total: number;\n };\n}\n\nasync function executeMigrationPlanCommand(\n options: MigrationPlanOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n startTime: number,\n): Promise<Result<MigrationPlanResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, appMigrationsDir, appMigrationsRelative } =\n resolveMigrationPaths(options.config, config);\n\n const contractPathAbsolute = resolveContractPath(config);\n const contractPath = relative(process.cwd(), contractPathAbsolute);\n\n if (!flags.json && !flags.quiet) {\n const details: Array<{ label: string; value: string }> = [\n { label: 'config', value: configPath },\n { label: 'contract', value: contractPath },\n { label: 'migrations', value: appMigrationsRelative },\n ];\n if (options.from) {\n details.push({ label: 'from', value: options.from });\n }\n if (options.name) {\n details.push({ label: 'name', value: options.name });\n }\n const header = formatStyledHeader({\n command: 'migration plan',\n description: 'Plan a migration from contract changes',\n url: 'https://pris.ly/migration-plan',\n details,\n flags,\n });\n ui.stderr(header);\n }\n\n // Load contract file (the \"to\" contract)\n let contractJsonContent: string;\n try {\n contractJsonContent = await readFile(contractPathAbsolute, 'utf-8');\n } catch (error) {\n if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {\n return notOk(\n errorFileNotFound(contractPathAbsolute, {\n why: `Contract file not found at ${contractPathAbsolute}`,\n fix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`,\n }),\n );\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n }\n\n let toContractJson: Contract;\n try {\n toContractJson = JSON.parse(contractJsonContent) as Contract;\n } catch (error) {\n return notOk(\n errorContractValidationFailed(\n `Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`,\n { where: { path: contractPathAbsolute } },\n ),\n );\n }\n\n const rawStorageHash = toContractJson.storage?.storageHash;\n if (typeof rawStorageHash !== 'string') {\n return notOk(\n errorContractValidationFailed('Contract is missing storageHash', {\n where: { path: contractPathAbsolute },\n }),\n );\n }\n const toStorageHash = rawStorageHash;\n\n // Read existing migrations and determine \"from\" contract\n let fromContract: Contract | null = null;\n let fromHash: string | null = null;\n let fromContractSourceDir: string | null = null;\n\n try {\n const { bundles, graph } = await loadMigrationPackages(appMigrationsDir);\n\n if (options.from) {\n const resolved = resolveBundleByPrefix(bundles, options.from);\n if (!resolved.ok) {\n const f = resolved.failure;\n return notOk(\n f.reason === 'ambiguous'\n ? errorRuntime('Multiple matching migrations found', {\n why: `Prefix \"${options.from}\" matches ${f.count} migrations in ${appMigrationsRelative}`,\n fix: 'Provide a longer prefix to disambiguate, or omit --from to use the latest migration target.',\n })\n : errorRuntime('Starting contract not found', {\n why: `No migration with to hash matching \"${options.from}\" exists in ${appMigrationsRelative}`,\n fix: 'Check that the --from hash matches a known migration target hash, or omit --from to use the latest migration target.',\n }),\n );\n }\n fromHash = resolved.value.metadata.to;\n fromContract = resolved.value.metadata.toContract;\n fromContractSourceDir = resolved.value.dirPath;\n } else {\n const latestMigration = findLatestMigration(graph);\n if (latestMigration) {\n fromHash = latestMigration.to;\n const leafPkg = bundles.find(\n (p) => p.metadata.migrationHash === latestMigration.migrationHash,\n );\n if (leafPkg) {\n fromContract = leafPkg.metadata.toContract;\n fromContractSourceDir = leafPkg.dirPath;\n }\n }\n }\n } catch (error) {\n if (MigrationToolsError.is(error)) {\n return notOk(mapMigrationToolsError(error));\n }\n // Wrap unexpected (non-MigrationToolsError) failures from the migration\n // load phase in a structured CLI envelope. Letting them throw would\n // bypass `handleResult()` and crash the command — see CLI structured-\n // errors guideline (CliStructuredError + Result pattern).\n const message = error instanceof Error ? error.message : String(error);\n return notOk(\n errorUnexpected(message, {\n why: `Unexpected error while loading migrations: ${message}`,\n }),\n );\n }\n\n // Per-space migrate pass: drift detection + on-disk artefact emission for\n // every loaded extension that exposes a `contractSpace`. Runs *before*\n // the app-space no-op check so that an extension bump alone (with no\n // structural app-space change) still re-pins extension artefacts on\n // disk. Drift warnings are non-fatal — the on-disk artefacts are refreshed\n // and the user is notified that the bump is being captured.\n const extensionInputs: readonly MigrateExtensionInput[] = (config.extensionPacks ?? []).map(\n (pack) => {\n const cs = (pack as { readonly contractSpace?: MigrateExtensionInput['contractSpace'] })\n .contractSpace;\n return cs !== undefined ? { id: pack.id, contractSpace: cs } : { id: pack.id };\n },\n );\n const migratePass = await runContractSpaceMigratePass({\n migrationsDir,\n extensionPacks: extensionInputs,\n });\n if (!flags.json && !flags.quiet) {\n for (const drift of migratePass.drifts) {\n if (drift.kind === 'drift') {\n ui.stderr(formatContractSpaceDriftWarning(drift));\n }\n }\n }\n\n // Materialise descriptor-shipped migration packages onto disk under\n // `migrations/<spaceId>/<dirName>/` for any package not yet present.\n // Idempotent (existing dirs are left untouched).\n // Uses `planAllSpaces` for deterministic ordering + duplicate-spaceId\n // detection.\n const extensionMigrationsInputs: readonly ExtensionMigrationsExtensionInput[] = (\n config.extensionPacks ?? []\n ).map((pack) => {\n const cs = (\n pack as {\n readonly contractSpace?: ExtensionMigrationsExtensionInput['contractSpace'];\n }\n ).contractSpace;\n return cs !== undefined ? { id: pack.id, contractSpace: cs } : { id: pack.id };\n });\n const extensionMigrationsResult = await runContractSpaceExtensionMigrationsPass({\n migrationsDir,\n extensionPacks: extensionMigrationsInputs,\n });\n if (!flags.json && !flags.quiet) {\n for (const entry of extensionMigrationsResult.emitted) {\n ui.step(`Emitted ${entry.spaceId}/${entry.dirName}`);\n }\n }\n\n // Check for no-op (same hash means no changes)\n if (fromHash === toStorageHash) {\n const result: MigrationPlanResult = {\n ok: true,\n noOp: true,\n from: fromHash,\n to: toStorageHash,\n operations: [],\n summary: 'No changes detected between contracts',\n timings: { total: Date.now() - startTime },\n };\n return ok(result);\n }\n\n // Check target supports migrations\n const migrations = getTargetMigrations(config.target);\n if (!migrations) {\n return notOk(\n errorTargetMigrationNotSupported({\n why: `Target \"${config.target.id}\" does not support migrations`,\n }),\n );\n }\n const frameworkComponents = assertFrameworkComponentsCompatible(\n config.family.familyId,\n config.target.targetId,\n [config.target, config.adapter, ...(config.extensionPacks ?? [])],\n );\n\n // Build manifest and write migration package\n const timestamp = new Date();\n const slug = options.name ?? 'migration';\n const dirName = formatMigrationDirName(timestamp, slug);\n const packageDir = join(appMigrationsDir, dirName);\n\n const baseMetadata: Omit<MigrationMetadata, 'migrationHash' | 'providedInvariants'> = {\n from: fromHash,\n to: toStorageHash,\n fromContract,\n toContract: toContractJson,\n hints: {\n used: [],\n applied: [],\n plannerVersion: '2.0.0',\n },\n labels: [],\n createdAt: timestamp.toISOString(),\n };\n\n try {\n const stack = createControlStack(config);\n const familyInstance = config.family.create(stack);\n const planner = migrations.createPlanner(familyInstance);\n const fromSchema = migrations.contractToSchema(fromContract, frameworkComponents);\n const plannerResult = planner.plan({\n contract: toContractJson,\n schema: fromSchema,\n policy: { allowedOperationClasses: ['additive', 'widening', 'destructive', 'data'] },\n fromContract,\n frameworkComponents,\n spaceId: APP_SPACE_ID,\n });\n if (plannerResult.kind === 'failure') {\n return notOk(\n errorMigrationPlanningFailed({\n conflicts: plannerResult.conflicts as readonly CliErrorConflict[],\n }),\n );\n }\n\n // Accessing .operations triggers toOp() on each call. If any call\n // is a DataTransformCall with an unfilled placeholder stub, toOp()\n // throws PN-MIG-2001. We catch that here so the migration can still\n // be scaffolded with `ops: []`; the user fills the placeholder, then\n // re-runs `node migration.ts` to attest with the real ops.\n let plannedOps: readonly MigrationPlanOperation[] = [];\n let hasPlaceholders = false;\n try {\n plannedOps = plannerResult.plan.operations;\n if (plannedOps.length === 0) {\n return notOk(\n errorMigrationPlanningFailed({\n conflicts: [\n {\n kind: 'unsupportedChange',\n summary:\n 'Contract changed but planner produced no operations. ' +\n 'This indicates unsupported or ignored changes.',\n },\n ],\n }),\n );\n }\n } catch (e) {\n if (CliStructuredError.is(e) && e.domain === 'MIG' && e.code === '2001') {\n hasPlaceholders = true;\n } else {\n throw e;\n }\n }\n\n const migrationTsContent = plannerResult.plan.renderTypeScript();\n\n // Always-attest: compute migrationHash over (metadata, ops). When\n // placeholders blocked lowering, ops is `[]` and the hash is computed\n // over the empty list — re-emitting after the user fills the placeholder\n // produces a different hash (over the real ops). This is intentional;\n // there is no on-disk \"draft\" state.\n const opsForWrite = hasPlaceholders ? [] : plannedOps;\n const metadataWithInvariants: Omit<MigrationMetadata, 'migrationHash'> = {\n ...baseMetadata,\n providedInvariants: deriveProvidedInvariants(opsForWrite),\n };\n const metadata: MigrationMetadata = {\n ...metadataWithInvariants,\n migrationHash: computeMigrationHash(metadataWithInvariants, opsForWrite),\n };\n\n await writeMigrationPackage(packageDir, metadata, opsForWrite);\n const destinationArtifacts = getEmittedArtifactPaths(contractPathAbsolute);\n await copyFilesWithRename(packageDir, [\n { sourcePath: destinationArtifacts.jsonPath, destName: 'end-contract.json' },\n { sourcePath: destinationArtifacts.dtsPath, destName: 'end-contract.d.ts' },\n ]);\n if (fromContractSourceDir !== null) {\n const sourceArtifacts = getEmittedArtifactPaths(\n join(fromContractSourceDir, 'end-contract.json'),\n );\n await copyFilesWithRename(packageDir, [\n { sourcePath: sourceArtifacts.jsonPath, destName: 'start-contract.json' },\n { sourcePath: sourceArtifacts.dtsPath, destName: 'start-contract.d.ts' },\n ]);\n }\n await writeMigrationTs(packageDir, migrationTsContent);\n\n if (hasPlaceholders) {\n const result: MigrationPlanResult = {\n ok: true,\n noOp: false,\n from: fromHash,\n to: toStorageHash,\n dir: relative(process.cwd(), packageDir),\n operations: [],\n pendingPlaceholders: true,\n summary:\n 'Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit',\n timings: { total: Date.now() - startTime },\n };\n return ok(result);\n }\n\n const preview = hasOperationPreview(familyInstance)\n ? familyInstance.toOperationPreview(plannedOps)\n : undefined;\n const result: MigrationPlanResult = {\n ok: true,\n noOp: false,\n from: fromHash,\n to: toStorageHash,\n dir: relative(process.cwd(), packageDir),\n operations: plannedOps.map((op) => ({\n id: op.id,\n label: op.label,\n operationClass: op.operationClass,\n })),\n ...(preview !== undefined ? { preview } : {}),\n summary: `Planned ${plannedOps.length} operation(s)`,\n timings: { total: Date.now() - startTime },\n };\n return ok(result);\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n if (MigrationToolsError.is(error)) {\n return notOk(mapMigrationToolsError(error));\n }\n const message = error instanceof Error ? error.message : String(error);\n return notOk(\n errorUnexpected(message, {\n why: `Unexpected error during migration plan: ${message}`,\n }),\n );\n }\n}\n\nexport function createMigrationPlanCommand(): Command {\n const command = new Command('plan');\n setCommandDescriptions(\n command,\n 'Plan a migration from contract changes',\n 'Compares the emitted contract against the latest on-disk migration state and\\n' +\n 'produces a new migration package with the required operations. No database\\n' +\n 'connection is needed — this is a fully offline operation.',\n );\n setCommandExamples(command, [\n 'prisma-next migration plan',\n 'prisma-next migration plan --name add-users-table',\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--name <slug>', 'Name slug for the migration directory', 'migration')\n .option('--from <hash>', 'Explicit starting contract hash (overrides latest migration target)')\n .action(async (options: MigrationPlanOptions) => {\n const flags = parseGlobalFlags(options);\n const startTime = Date.now();\n\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeMigrationPlanCommand(options, flags, ui, startTime);\n\n const exitCode = handleResult(result, flags, ui, (planResult) => {\n if (flags.json) {\n ui.output(JSON.stringify(planResult, null, 2));\n } else if (!flags.quiet) {\n ui.log(formatMigrationPlanOutput(planResult, flags));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n\nfunction formatMigrationPlanOutput(result: MigrationPlanResult, flags: GlobalFlags): string {\n const lines: string[] = [];\n const useColor = flags.color !== false;\n\n const green_ = useColor ? (s: string) => `\\x1b[32m${s}\\x1b[0m` : (s: string) => s;\n const yellow_ = useColor ? (s: string) => `\\x1b[33m${s}\\x1b[0m` : (s: string) => s;\n const dim_ = useColor ? (s: string) => `\\x1b[2m${s}\\x1b[0m` : (s: string) => s;\n\n if (result.noOp) {\n lines.push(`${green_('✔')} No changes detected`);\n lines.push(dim_(` from: ${result.from}`));\n lines.push(dim_(` to: ${result.to}`));\n return lines.join('\\n');\n }\n\n if (result.pendingPlaceholders) {\n lines.push(`${yellow_('⚠')} ${result.summary}`);\n lines.push('');\n lines.push(dim_(`from: ${result.from}`));\n lines.push(dim_(`to: ${result.to}`));\n if (result.dir) {\n lines.push(dim_(`dir: ${result.dir}`));\n }\n lines.push('');\n lines.push(\n 'Open migration.ts and replace each `placeholder(...)` call with your actual query.',\n );\n lines.push(`Then run: ${green_(`node ${result.dir ?? '<dir>'}/migration.ts`)}`);\n return lines.join('\\n');\n }\n\n lines.push(`${green_('✔')} ${result.summary}`);\n lines.push('');\n\n if (result.operations.length > 0) {\n lines.push(dim_('│'));\n for (let i = 0; i < result.operations.length; i++) {\n const op = result.operations[i]!;\n const isLast = i === result.operations.length - 1;\n const treeChar = isLast ? '└' : '├';\n const opClassLabel =\n op.operationClass === 'destructive'\n ? yellow_(`[${op.operationClass}]`)\n : dim_(`[${op.operationClass}]`);\n lines.push(`${dim_(treeChar)}─ ${op.label} ${opClassLabel}`);\n }\n\n const hasDestructive = result.operations.some((op) => op.operationClass === 'destructive');\n if (hasDestructive) {\n lines.push('');\n lines.push(\n `${yellow_('⚠')} This migration contains destructive operations that may cause data loss.`,\n );\n }\n lines.push('');\n }\n\n lines.push(dim_(`from: ${result.from}`));\n lines.push(dim_(`to: ${result.to}`));\n if (result.dir) {\n lines.push(dim_(`dir: ${result.dir}`));\n }\n\n lines.push('');\n lines.push(\n `Next: review ${green_(result.dir ?? '<dir>')} if needed, then run ${green_('prisma-next migration apply')}.`,\n );\n\n if (result.preview && result.preview.statements.length > 0) {\n // The non-empty length is already guaranteed by the surrounding check, so\n // a plain `every` here is equivalent to the helper in formatters/migrations.ts.\n const allSql = result.preview.statements.every((s) => s.language === 'sql');\n lines.push('');\n lines.push(dim_(allSql ? 'DDL preview' : 'Operation preview'));\n lines.push('');\n for (const statement of result.preview.statements) {\n const trimmed = statement.text.trim();\n if (!trimmed) continue;\n const line = statement.language === 'sql' && !trimmed.endsWith(';') ? `${trimmed};` : trimmed;\n lines.push(line);\n }\n }\n\n if (flags.verbose && result.timings) {\n lines.push('');\n lines.push(dim_(`Total time: ${result.timings.total}ms`));\n }\n\n return lines.join('\\n');\n}\n\nexport type PrefixResolutionFailure =\n | { reason: 'ambiguous'; count: number }\n | { reason: 'not-found' };\n\n/**\n * Resolve a migration package by **target contract hash** (`metadata.to`)\n * using exact match or prefix match.\n *\n * Note: matches `metadata.to` (the contract hash this migration produces),\n * not `metadata.migrationHash` (the package's content-addressed identity).\n * Tries exact match first, then prefix match (auto-prepending `sha256:` when\n * the needle omits the scheme). Returns the matched package on success, or a\n * discriminated failure indicating whether the prefix was ambiguous or simply\n * not found.\n *\n * @internal Exported for testing only.\n */\nexport function resolveBundleByPrefix<T extends { metadata: { to: string } }>(\n bundles: readonly T[],\n needle: string,\n): Result<T, PrefixResolutionFailure> {\n const exact = bundles.find((p) => p.metadata.to === needle);\n if (exact) return ok(exact);\n\n const prefixWithScheme = needle.startsWith('sha256:') ? needle : `sha256:${needle}`;\n const candidates = bundles.filter((p) => p.metadata.to.startsWith(prefixWithScheme));\n\n if (candidates.length === 1) return ok(candidates[0]!);\n if (candidates.length > 1) return notOk({ reason: 'ambiguous', count: candidates.length });\n return notOk({ reason: 'not-found' });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;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I,OAAO,OAAO,GAAG,MAAM;CAE3B,MAAM,mBAAmB,OAAO,WAAW,UAAU,GAAG,SAAS,UAAU;CAC3E,MAAM,aAAa,QAAQ,QAAQ,MAAM,EAAE,SAAS,GAAG,WAAW,iBAAiB,CAAC;CAEpF,IAAI,WAAW,WAAW,GAAG,OAAO,GAAG,WAAW,GAAI;CACtD,IAAI,WAAW,SAAS,GAAG,OAAO,MAAM;EAAE,QAAQ;EAAa,OAAO,WAAW;EAAQ,CAAC;CAC1F,OAAO,MAAM,EAAE,QAAQ,aAAa,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as loadConfig } from "./config-loader-B6sJjXTv.mjs";
|
|
2
2
|
import { _ as errorUnexpected, m as errorRuntime, v as mapMigrationToolsError } from "./cli-errors-D3_sMh2K.mjs";
|
|
3
3
|
import { t as TerminalUI } from "./terminal-ui-zaRDhJnP.mjs";
|
|
4
|
-
import { a as loadMigrationPackages, d as setCommandDescriptions, f as setCommandExamples, g as parseGlobalFlags, h as toStructuralEdge, l as resolveMigrationPaths, m as toPathDecisionResult, n as addGlobalOptions, o as maskConnectionUrl, r as collectDeclaredInvariants, s as readContractEnvelope, t as handleResult, y as formatStyledHeader } from "./result-handler-
|
|
5
|
-
import { t as createControlClient } from "./client-
|
|
4
|
+
import { a as loadMigrationPackages, d as setCommandDescriptions, f as setCommandExamples, g as parseGlobalFlags, h as toStructuralEdge, l as resolveMigrationPaths, m as toPathDecisionResult, n as addGlobalOptions, o as maskConnectionUrl, r as collectDeclaredInvariants, s as readContractEnvelope, t as handleResult, y as formatStyledHeader } from "./result-handler-DWb1rFS-.mjs";
|
|
5
|
+
import { t as createControlClient } from "./client-0ZX24FXF.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
8
8
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
@@ -1238,7 +1238,7 @@ function determineLimit(opts) {
|
|
|
1238
1238
|
}
|
|
1239
1239
|
async function executeMigrationStatusCommand(options, flags, ui) {
|
|
1240
1240
|
const config = await loadConfig(options.config);
|
|
1241
|
-
const { configPath,
|
|
1241
|
+
const { configPath, appMigrationsDir, appMigrationsRelative, refsDir } = resolveMigrationPaths(options.config, config);
|
|
1242
1242
|
const dbConnection = options.db ?? config.db?.connection;
|
|
1243
1243
|
const hasDriver = !!config.driver;
|
|
1244
1244
|
let activeRefName;
|
|
@@ -1273,7 +1273,7 @@ async function executeMigrationStatusCommand(options, flags, ui) {
|
|
|
1273
1273
|
value: configPath
|
|
1274
1274
|
}, {
|
|
1275
1275
|
label: "migrations",
|
|
1276
|
-
value:
|
|
1276
|
+
value: appMigrationsRelative
|
|
1277
1277
|
}];
|
|
1278
1278
|
if (dbConnection && hasDriver) details.push({
|
|
1279
1279
|
label: "database",
|
|
@@ -1310,7 +1310,7 @@ async function executeMigrationStatusCommand(options, flags, ui) {
|
|
|
1310
1310
|
let bundles;
|
|
1311
1311
|
let graph;
|
|
1312
1312
|
try {
|
|
1313
|
-
({bundles, graph} = await loadMigrationPackages(
|
|
1313
|
+
({bundles, graph} = await loadMigrationPackages(appMigrationsDir));
|
|
1314
1314
|
} catch (error) {
|
|
1315
1315
|
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
1316
1316
|
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));
|
|
@@ -1615,4 +1615,4 @@ function summarizeRefDistance(graph, markerHash, refHash, refName) {
|
|
|
1615
1615
|
//#endregion
|
|
1616
1616
|
export { deriveEdgeStatuses as n, formatStatusSummary as r, createMigrationStatusCommand as t };
|
|
1617
1617
|
|
|
1618
|
-
//# sourceMappingURL=migration-status-
|
|
1618
|
+
//# sourceMappingURL=migration-status-CjwB2of-.mjs.map
|