@prisma-next/cli 0.4.0-dev.5 → 0.4.0-dev.6
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/README.md +8 -7
- package/dist/cli-errors-BUuJr6py.mjs +5 -0
- package/dist/{cli-errors-DStABy9d.d.mts → cli-errors-Dic2eADK.d.mts} +1 -0
- package/dist/cli.mjs +9 -16
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-tdnbk0OR.mjs → client-DUs1DH-1.mjs} +2 -2
- package/dist/{client-tdnbk0OR.mjs.map → client-DUs1DH-1.mjs.map} +1 -1
- package/dist/commands/contract-emit.mjs +1 -6
- package/dist/commands/contract-infer.mjs +1 -7
- package/dist/commands/db-init.mjs +5 -6
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +3 -6
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.mjs +4 -5
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.mjs +5 -6
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +4 -5
- package/dist/commands/db-verify.mjs.map +1 -1
- package/dist/commands/migration-apply.mjs +6 -7
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-emit.d.mts +38 -0
- package/dist/commands/migration-emit.d.mts.map +1 -0
- package/dist/commands/migration-emit.mjs +81 -0
- package/dist/commands/migration-emit.mjs.map +1 -0
- 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 +13 -32
- package/dist/commands/migration-plan.mjs.map +1 -1
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.mjs +2 -2
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +4 -4
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.mjs +1 -6
- package/dist/{contract-emit-Ctn6mH9H.mjs → contract-emit-7jqH6dq9.mjs} +5 -5
- package/dist/{contract-emit-Ctn6mH9H.mjs.map → contract-emit-7jqH6dq9.mjs.map} +1 -1
- package/dist/contract-emit-C2_J2U7A.mjs +4 -0
- package/dist/{contract-emit-CRoS1nx5.mjs → contract-emit-CKig_Lra.mjs} +4 -4
- package/dist/{contract-emit-CRoS1nx5.mjs.map → contract-emit-CKig_Lra.mjs.map} +1 -1
- package/dist/{contract-infer-Ba1SE57Q.mjs → contract-infer-BFlIbyl9.mjs} +3 -3
- package/dist/{contract-infer-Ba1SE57Q.mjs.map → contract-infer-BFlIbyl9.mjs.map} +1 -1
- package/dist/exports/control-api.mjs +2 -4
- package/dist/exports/index.mjs +1 -6
- package/dist/exports/index.mjs.map +1 -1
- package/dist/{framework-components-BAsliT4V.mjs → framework-components-Bsr1GaIj.mjs} +2 -2
- package/dist/{framework-components-BAsliT4V.mjs.map → framework-components-Bsr1GaIj.mjs.map} +1 -1
- package/dist/{init-CYWnL7gq.mjs → init-DlFLMBaU.mjs} +2 -2
- package/dist/{init-CYWnL7gq.mjs.map → init-DlFLMBaU.mjs.map} +1 -1
- package/dist/{inspect-live-schema-gYQiWfpl.mjs → inspect-live-schema-gjmUZ8xm.mjs} +4 -4
- package/dist/{inspect-live-schema-gYQiWfpl.mjs.map → inspect-live-schema-gjmUZ8xm.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-x4n_ZhAh.mjs → migration-command-scaffold-CfllKppa.mjs} +4 -4
- package/dist/{migration-command-scaffold-x4n_ZhAh.mjs.map → migration-command-scaffold-CfllKppa.mjs.map} +1 -1
- package/dist/migration-emit-dRXV6QSz.mjs +72 -0
- package/dist/migration-emit-dRXV6QSz.mjs.map +1 -0
- package/dist/{migration-status-DyVDf5NI.mjs → migration-status-BwKCQB_a.mjs} +5 -5
- package/dist/{migration-status-DyVDf5NI.mjs.map → migration-status-BwKCQB_a.mjs.map} +1 -1
- package/dist/{migrations-DTZBYXm1.mjs → migrations-BIsjFjSV.mjs} +6 -15
- package/dist/migrations-BIsjFjSV.mjs.map +1 -0
- package/dist/{result-handler-oK_vA-Fn.mjs → result-handler-AFK4hxyX.mjs} +2 -2
- package/dist/result-handler-AFK4hxyX.mjs.map +1 -0
- package/dist/{validate-contract-deps-esa-VQ0h.mjs → validate-contract-deps-DBH6iTAD.mjs} +1 -1
- package/dist/{validate-contract-deps-esa-VQ0h.mjs.map → validate-contract-deps-DBH6iTAD.mjs.map} +1 -1
- package/dist/{verify-DlFQ2FOw.mjs → verify-C56CuQc7.mjs} +2 -2
- package/dist/{verify-DlFQ2FOw.mjs.map → verify-C56CuQc7.mjs.map} +1 -1
- package/package.json +19 -19
- package/src/cli.ts +4 -4
- package/src/commands/migration-apply.ts +2 -2
- package/src/commands/migration-emit.ts +132 -0
- package/src/commands/migration-new.ts +3 -3
- package/src/commands/migration-plan.ts +15 -57
- package/src/commands/migration-show.ts +1 -1
- package/src/commands/migration-status.ts +1 -1
- package/src/lib/migration-emit.ts +113 -0
- package/src/utils/cli-errors.ts +5 -0
- package/src/utils/formatters/help.ts +1 -1
- package/src/utils/formatters/migrations.ts +6 -20
- package/dist/cli-errors-BDCYR5ap.mjs +0 -4
- package/dist/commands/migration-verify.d.mts +0 -16
- package/dist/commands/migration-verify.d.mts.map +0 -1
- package/dist/commands/migration-verify.mjs +0 -110
- package/dist/commands/migration-verify.mjs.map +0 -1
- package/dist/contract-emit-CVUWsFfx.mjs +0 -6
- package/dist/migrations-DTZBYXm1.mjs.map +0 -1
- package/dist/result-handler-oK_vA-Fn.mjs.map +0 -1
- package/src/commands/migration-verify.ts +0 -180
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-command-scaffold-
|
|
1
|
+
{"version":3,"file":"migration-command-scaffold-CfllKppa.mjs","names":["details: Array<{ label: string; value: string }>","contractJsonContent: string","contractJson: Record<string, unknown>"],"sources":["../src/utils/migration-command-scaffold.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { hasMigrations } from '@prisma-next/framework-components/control';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport type { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport type { ControlClient } from '../control-api/types';\nimport {\n type CliStructuredError,\n errorContractValidationFailed,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorFileNotFound,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n} from './cli-errors';\nimport { addGlobalOptions, maskConnectionUrl, resolveContractPath } from './command-helpers';\nimport { formatStyledHeader } from './formatters/styled';\nimport type { GlobalFlags } from './global-flags';\nimport { createProgressAdapter } from './progress-adapter';\nimport type { TerminalUI } from './terminal-ui';\n\n/**\n * Resolved context for a migration command.\n * Contains everything needed to invoke a control-api operation.\n */\nexport interface MigrationContext {\n readonly client: ControlClient;\n readonly contractJson: Record<string, unknown>;\n readonly dbConnection: unknown;\n readonly onProgress: ReturnType<typeof createProgressAdapter>;\n readonly configPath: string;\n readonly contractPath: string;\n readonly contractPathAbsolute: string;\n readonly config: Awaited<ReturnType<typeof loadConfig>>;\n}\n\n/**\n * Command-specific configuration for the shared scaffold.\n */\nexport interface MigrationCommandDescriptor {\n readonly commandName: string;\n readonly description: string;\n readonly url: string;\n}\n\n/**\n * Prepares the shared context for migration commands (db init, db update).\n *\n * Handles: config loading, contract file reading, JSON parsing, connection resolution,\n * driver/migration-support validation, client creation, and header output.\n *\n * Returns a Result with either the resolved context or a structured error.\n */\nexport async function prepareMigrationContext(\n options: { readonly db?: string; readonly config?: string; readonly dryRun?: boolean },\n flags: GlobalFlags,\n ui: TerminalUI,\n descriptor: MigrationCommandDescriptor,\n): Promise<Result<MigrationContext, CliStructuredError>> {\n // Load config\n const config = await loadConfig(options.config);\n const configPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n const contractPathAbsolute = resolveContractPath(config);\n const contractPath = relative(process.cwd(), contractPathAbsolute);\n\n // Output header to stderr (decoration)\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 ];\n if (options.db) {\n details.push({ label: 'database', value: maskConnectionUrl(options.db) });\n }\n if (options.dryRun) {\n details.push({ label: 'mode', value: 'dry run' });\n }\n const header = formatStyledHeader({\n command: descriptor.commandName,\n description: descriptor.description,\n url: descriptor.url,\n details,\n flags,\n });\n ui.stderr(header);\n }\n\n // Load contract file\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 // Parse contract JSON\n let contractJson: Record<string, unknown>;\n try {\n contractJson = JSON.parse(contractJsonContent) as Record<string, unknown>;\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 // Resolve database connection (--db flag or config.db.connection)\n const dbConnection = options.db ?? config.db?.connection;\n if (!dbConnection) {\n return notOk(\n errorDatabaseConnectionRequired({\n why: `Database connection is required for ${descriptor.commandName} (set db.connection in ${configPath}, or pass --db <url>)`,\n commandName: descriptor.commandName,\n }),\n );\n }\n\n // Check for driver\n if (!config.driver) {\n return notOk(\n errorDriverRequired({ why: `Config.driver is required for ${descriptor.commandName}` }),\n );\n }\n\n if (!hasMigrations(config.target)) {\n return notOk(\n errorTargetMigrationNotSupported({\n why: `Target \"${config.target.id}\" does not support migrations`,\n }),\n );\n }\n\n // Create control client\n const client = createControlClient({\n family: config.family,\n target: config.target,\n adapter: config.adapter,\n driver: config.driver,\n extensionPacks: config.extensionPacks ?? [],\n });\n\n // Create progress adapter\n const onProgress = createProgressAdapter({ ui, flags });\n\n return ok({\n client,\n contractJson,\n dbConnection,\n onProgress,\n configPath,\n contractPath,\n contractPathAbsolute,\n config,\n });\n}\n\n/**\n * Registers the shared CLI options for migration commands (db init, db update).\n */\nexport function addMigrationCommandOptions(command: Command): Command {\n addGlobalOptions(command);\n return command\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--dry-run', 'Preview planned operations without applying', false);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,eAAsB,wBACpB,SACA,OACA,IACA,YACuD;CAEvD,MAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;CAC/C,MAAM,aAAa,QAAQ,SACvB,SAAS,QAAQ,KAAK,EAAE,QAAQ,QAAQ,OAAO,CAAC,GAChD;CACJ,MAAM,uBAAuB,oBAAoB,OAAO;CACxD,MAAM,eAAe,SAAS,QAAQ,KAAK,EAAE,qBAAqB;AAGlE,KAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAC/B,MAAMA,UAAmD,CACvD;GAAE,OAAO;GAAU,OAAO;GAAY,EACtC;GAAE,OAAO;GAAY,OAAO;GAAc,CAC3C;AACD,MAAI,QAAQ,GACV,SAAQ,KAAK;GAAE,OAAO;GAAY,OAAO,kBAAkB,QAAQ,GAAG;GAAE,CAAC;AAE3E,MAAI,QAAQ,OACV,SAAQ,KAAK;GAAE,OAAO;GAAQ,OAAO;GAAW,CAAC;EAEnD,MAAM,SAAS,mBAAmB;GAChC,SAAS,WAAW;GACpB,aAAa,WAAW;GACxB,KAAK,WAAW;GAChB;GACA;GACD,CAAC;AACF,KAAG,OAAO,OAAO;;CAInB,IAAIC;AACJ,KAAI;AACF,wBAAsB,MAAM,SAAS,sBAAsB,QAAQ;UAC5D,OAAO;AACd,MAAI,iBAAiB,SAAU,MAA4B,SAAS,SAClE,QAAO,MACL,kBAAkB,sBAAsB;GACtC,KAAK,8BAA8B;GACnC,KAAK,iDAAiD,aAAa,4CAA4C;GAChH,CAAC,CACH;AAEH,SAAO,MACL,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,EAAE,EACtE,KAAK,iCAAiC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC7F,CAAC,CACH;;CAIH,IAAIC;AACJ,KAAI;AACF,iBAAe,KAAK,MAAM,oBAAoB;UACvC,OAAO;AACd,SAAO,MACL,8BACE,6BAA6B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACnF,EAAE,OAAO,EAAE,MAAM,sBAAsB,EAAE,CAC1C,CACF;;CAIH,MAAM,eAAe,QAAQ,MAAM,OAAO,IAAI;AAC9C,KAAI,CAAC,aACH,QAAO,MACL,gCAAgC;EAC9B,KAAK,uCAAuC,WAAW,YAAY,yBAAyB,WAAW;EACvG,aAAa,WAAW;EACzB,CAAC,CACH;AAIH,KAAI,CAAC,OAAO,OACV,QAAO,MACL,oBAAoB,EAAE,KAAK,iCAAiC,WAAW,eAAe,CAAC,CACxF;AAGH,KAAI,CAAC,cAAc,OAAO,OAAO,CAC/B,QAAO,MACL,iCAAiC,EAC/B,KAAK,WAAW,OAAO,OAAO,GAAG,gCAClC,CAAC,CACH;CAIH,MAAM,SAAS,oBAAoB;EACjC,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,SAAS,OAAO;EAChB,QAAQ,OAAO;EACf,gBAAgB,OAAO,kBAAkB,EAAE;EAC5C,CAAC;CAGF,MAAM,aAAa,sBAAsB;EAAE;EAAI;EAAO,CAAC;AAEvD,QAAO,GAAG;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;;;;;AAMJ,SAAgB,2BAA2B,SAA2B;AACpE,kBAAiB,QAAQ;AACzB,QAAO,QACJ,OAAO,cAAc,6BAA6B,CAClD,OAAO,mBAAmB,gCAAgC,CAC1D,OAAO,aAAa,+CAA+C,MAAM"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { f as errorMigrationFileMissing, g as errorTargetMigrationNotSupported } from "./cli-errors-BUuJr6py.mjs";
|
|
2
|
+
import { readMigrationPackage, writeMigrationOps } from "@prisma-next/migration-tools/io";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { attestMigration } from "@prisma-next/migration-tools/attestation";
|
|
5
|
+
import { evaluateMigrationTs, hasMigrationTs } from "@prisma-next/migration-tools/migration-ts";
|
|
6
|
+
|
|
7
|
+
//#region src/lib/migration-emit.ts
|
|
8
|
+
/**
|
|
9
|
+
* Shared helper for emitting `ops.json` from a migration package's
|
|
10
|
+
* `migration.ts`.
|
|
11
|
+
*
|
|
12
|
+
* Two flows are dispatched here:
|
|
13
|
+
* - Descriptor flow (Postgres): the framework evaluates `migration.ts` (which
|
|
14
|
+
* re-exports the planner's descriptor list), calls the target's
|
|
15
|
+
* `resolveDescriptors` to produce display-oriented operations, and writes
|
|
16
|
+
* `ops.json` + `manifest.json`.
|
|
17
|
+
* - Class flow (Mongo): the target owns the source-loading and ops
|
|
18
|
+
* serialization step via its `emit` capability. The capability
|
|
19
|
+
* dynamic-imports `migration.ts`, invokes its class to produce
|
|
20
|
+
* operations, and calls `writeMigrationOps`. The framework helper
|
|
21
|
+
* then attests the package (single source of truth for
|
|
22
|
+
* `migrationId`).
|
|
23
|
+
*
|
|
24
|
+
* Used by `migration emit` (always) and `migration plan` (always, after
|
|
25
|
+
* scaffolding `migration.ts`). Both flows run in-process so that structured
|
|
26
|
+
* errors thrown during evaluation propagate as real exceptions and the
|
|
27
|
+
* CLI's error envelope renders them with full structured metadata.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Emit `ops.json` and attest `migrationId` for the migration package at `dir`.
|
|
31
|
+
*
|
|
32
|
+
* Dispatches to descriptor flow when the target implements `resolveDescriptors`,
|
|
33
|
+
* otherwise to the target's `emit` capability. Throws a structured error if
|
|
34
|
+
* `migration.ts` is missing or the target supports neither flow. Other
|
|
35
|
+
* structured errors thrown during evaluation propagate unchanged.
|
|
36
|
+
*/
|
|
37
|
+
async function emitMigration(dir, ctx) {
|
|
38
|
+
if (!await hasMigrationTs(dir)) throw errorMigrationFileMissing(dir);
|
|
39
|
+
if (ctx.migrations.resolveDescriptors) return emitDescriptorFlow(dir, ctx.migrations, ctx);
|
|
40
|
+
if (ctx.migrations.emit) return {
|
|
41
|
+
operations: await ctx.migrations.emit({
|
|
42
|
+
dir,
|
|
43
|
+
frameworkComponents: ctx.frameworkComponents
|
|
44
|
+
}),
|
|
45
|
+
migrationId: await attestMigration(dir)
|
|
46
|
+
};
|
|
47
|
+
throw errorTargetMigrationNotSupported({ why: `Target "${ctx.targetId}" does not implement resolveDescriptors or emit; cannot emit a migration package` });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Descriptor flow: evaluate `migration.ts` to obtain a list of operation
|
|
51
|
+
* descriptors, hand them to the target's `resolveDescriptors` along with the
|
|
52
|
+
* manifest's contract bookends, then persist `ops.json` and attest the package.
|
|
53
|
+
*/
|
|
54
|
+
async function emitDescriptorFlow(dir, migrations, ctx) {
|
|
55
|
+
assert(migrations.resolveDescriptors, "emitDescriptorFlow requires resolveDescriptors; gated by caller");
|
|
56
|
+
const pkg = await readMigrationPackage(dir);
|
|
57
|
+
const descriptors = await evaluateMigrationTs(dir);
|
|
58
|
+
const operations = migrations.resolveDescriptors(descriptors, {
|
|
59
|
+
fromContract: pkg.manifest.fromContract,
|
|
60
|
+
toContract: pkg.manifest.toContract,
|
|
61
|
+
frameworkComponents: ctx.frameworkComponents
|
|
62
|
+
});
|
|
63
|
+
await writeMigrationOps(dir, operations);
|
|
64
|
+
return {
|
|
65
|
+
operations,
|
|
66
|
+
migrationId: await attestMigration(dir)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { emitMigration as t };
|
|
72
|
+
//# sourceMappingURL=migration-emit-dRXV6QSz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-emit-dRXV6QSz.mjs","names":[],"sources":["../src/lib/migration-emit.ts"],"sourcesContent":["/**\n * Shared helper for emitting `ops.json` from a migration package's\n * `migration.ts`.\n *\n * Two flows are dispatched here:\n * - Descriptor flow (Postgres): the framework evaluates `migration.ts` (which\n * re-exports the planner's descriptor list), calls the target's\n * `resolveDescriptors` to produce display-oriented operations, and writes\n * `ops.json` + `manifest.json`.\n * - Class flow (Mongo): the target owns the source-loading and ops\n * serialization step via its `emit` capability. The capability\n * dynamic-imports `migration.ts`, invokes its class to produce\n * operations, and calls `writeMigrationOps`. The framework helper\n * then attests the package (single source of truth for\n * `migrationId`).\n *\n * Used by `migration emit` (always) and `migration plan` (always, after\n * scaffolding `migration.ts`). Both flows run in-process so that structured\n * errors thrown during evaluation propagate as real exceptions and the\n * CLI's error envelope renders them with full structured metadata.\n */\n\nimport assert from 'node:assert/strict';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanOperation,\n OperationDescriptor,\n TargetMigrationsCapability,\n} from '@prisma-next/framework-components/control';\nimport { attestMigration } from '@prisma-next/migration-tools/attestation';\nimport { readMigrationPackage, writeMigrationOps } from '@prisma-next/migration-tools/io';\nimport { evaluateMigrationTs, hasMigrationTs } from '@prisma-next/migration-tools/migration-ts';\nimport { errorMigrationFileMissing, errorTargetMigrationNotSupported } from '../utils/cli-errors';\n\n/**\n * Context passed to `emitMigration`. Captures everything the helper needs to\n * dispatch to the right flow without re-loading the config.\n */\nexport interface EmitMigrationContext {\n readonly targetId: string;\n readonly migrations: TargetMigrationsCapability;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<string, string>>;\n}\n\n/**\n * Result of a successful emit: the operations that were written to `ops.json`\n * (display-oriented shape) and the content-addressed migrationId persisted to\n * `manifest.json`.\n */\nexport interface EmitMigrationResult {\n readonly operations: readonly MigrationPlanOperation[];\n readonly migrationId: string;\n}\n\n/**\n * Emit `ops.json` and attest `migrationId` for the migration package at `dir`.\n *\n * Dispatches to descriptor flow when the target implements `resolveDescriptors`,\n * otherwise to the target's `emit` capability. Throws a structured error if\n * `migration.ts` is missing or the target supports neither flow. Other\n * structured errors thrown during evaluation propagate unchanged.\n */\nexport async function emitMigration(\n dir: string,\n ctx: EmitMigrationContext,\n): Promise<EmitMigrationResult> {\n if (!(await hasMigrationTs(dir))) {\n throw errorMigrationFileMissing(dir);\n }\n\n if (ctx.migrations.resolveDescriptors) {\n return emitDescriptorFlow(dir, ctx.migrations, ctx);\n }\n\n if (ctx.migrations.emit) {\n const operations = await ctx.migrations.emit({\n dir,\n frameworkComponents: ctx.frameworkComponents,\n });\n const migrationId = await attestMigration(dir);\n return { operations, migrationId };\n }\n\n throw errorTargetMigrationNotSupported({\n why: `Target \"${ctx.targetId}\" does not implement resolveDescriptors or emit; cannot emit a migration package`,\n });\n}\n\n/**\n * Descriptor flow: evaluate `migration.ts` to obtain a list of operation\n * descriptors, hand them to the target's `resolveDescriptors` along with the\n * manifest's contract bookends, then persist `ops.json` and attest the package.\n */\nasync function emitDescriptorFlow(\n dir: string,\n migrations: TargetMigrationsCapability,\n ctx: EmitMigrationContext,\n): Promise<EmitMigrationResult> {\n assert(\n migrations.resolveDescriptors,\n 'emitDescriptorFlow requires resolveDescriptors; gated by caller',\n );\n const pkg = await readMigrationPackage(dir);\n const descriptors = await evaluateMigrationTs(dir);\n const operations = migrations.resolveDescriptors(descriptors as OperationDescriptor[], {\n fromContract: pkg.manifest.fromContract,\n toContract: pkg.manifest.toContract,\n frameworkComponents: ctx.frameworkComponents,\n });\n await writeMigrationOps(dir, operations);\n const migrationId = await attestMigration(dir);\n return { operations, migrationId };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,eAAsB,cACpB,KACA,KAC8B;AAC9B,KAAI,CAAE,MAAM,eAAe,IAAI,CAC7B,OAAM,0BAA0B,IAAI;AAGtC,KAAI,IAAI,WAAW,mBACjB,QAAO,mBAAmB,KAAK,IAAI,YAAY,IAAI;AAGrD,KAAI,IAAI,WAAW,KAMjB,QAAO;EAAE,YALU,MAAM,IAAI,WAAW,KAAK;GAC3C;GACA,qBAAqB,IAAI;GAC1B,CAAC;EAEmB,aADD,MAAM,gBAAgB,IAAI;EACZ;AAGpC,OAAM,iCAAiC,EACrC,KAAK,WAAW,IAAI,SAAS,mFAC9B,CAAC;;;;;;;AAQJ,eAAe,mBACb,KACA,YACA,KAC8B;AAC9B,QACE,WAAW,oBACX,kEACD;CACD,MAAM,MAAM,MAAM,qBAAqB,IAAI;CAC3C,MAAM,cAAc,MAAM,oBAAoB,IAAI;CAClD,MAAM,aAAa,WAAW,mBAAmB,aAAsC;EACrF,cAAc,IAAI,SAAS;EAC3B,YAAY,IAAI,SAAS;EACzB,qBAAqB,IAAI;EAC1B,CAAC;AACF,OAAM,kBAAkB,KAAK,WAAW;AAExC,QAAO;EAAE;EAAY,aADD,MAAM,gBAAgB,IAAI;EACZ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as loadConfig } from "./config-loader-C4VXKl8f.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as createControlClient } from "./client-
|
|
4
|
-
import { _ as formatStyledHeader, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, i as loadAllBundles, m as parseGlobalFlags, n as addGlobalOptions, o as readContractEnvelope, p as toPathDecisionResult, t as handleResult, u as setCommandDescriptions } from "./result-handler-
|
|
2
|
+
import { h as errorRuntime, v as errorUnexpected } from "./cli-errors-BUuJr6py.mjs";
|
|
3
|
+
import { t as createControlClient } from "./client-DUs1DH-1.mjs";
|
|
4
|
+
import { _ as formatStyledHeader, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, i as loadAllBundles, m as parseGlobalFlags, n as addGlobalOptions, o as readContractEnvelope, p as toPathDecisionResult, t as handleResult, u as setCommandDescriptions } from "./result-handler-AFK4hxyX.mjs";
|
|
5
5
|
import { t as TerminalUI } from "./terminal-ui-C5k88MmW.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
@@ -1333,7 +1333,7 @@ async function executeMigrationStatusCommand(options, flags, ui) {
|
|
|
1333
1333
|
code: "MIGRATION.DRAFTS",
|
|
1334
1334
|
severity: "warn",
|
|
1335
1335
|
message: `${drafts.length} draft migration(s) found: ${drafts.map((d) => d.dirName).join(", ")}`,
|
|
1336
|
-
hints: ["Run 'prisma-next migration
|
|
1336
|
+
hints: ["Run 'prisma-next migration emit --dir <path>' to attest draft migrations before applying"]
|
|
1337
1337
|
});
|
|
1338
1338
|
if (attested.length === 0) {
|
|
1339
1339
|
if (contractHash !== EMPTY_CONTRACT_HASH) diagnostics.push({
|
|
@@ -1580,4 +1580,4 @@ function summarizeRefDistance(graph, markerHash, refHash, refName) {
|
|
|
1580
1580
|
|
|
1581
1581
|
//#endregion
|
|
1582
1582
|
export { deriveEdgeStatuses as n, createMigrationStatusCommand as t };
|
|
1583
|
-
//# sourceMappingURL=migration-status-
|
|
1583
|
+
//# sourceMappingURL=migration-status-BwKCQB_a.mjs.map
|