prisma-next 0.5.0-dev.4 → 0.5.0-dev.41

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.
Files changed (113) hide show
  1. package/dist/agent-skill-mongo.md +63 -31
  2. package/dist/agent-skill-postgres.md +1 -1
  3. package/dist/cli-errors-By1iVE3z.mjs +34 -0
  4. package/dist/cli-errors-By1iVE3z.mjs.map +1 -0
  5. package/dist/{cli-errors-C0JhVj0c.d.mts → cli-errors-DDeVsP2Y.d.mts} +1 -0
  6. package/dist/cli.mjs +123 -15
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/{client-TG7rbCWT.mjs → client-1JqqkiC7.mjs} +45 -20
  9. package/dist/client-1JqqkiC7.mjs.map +1 -0
  10. package/dist/commands/contract-emit.d.mts.map +1 -1
  11. package/dist/commands/contract-emit.mjs +2 -2
  12. package/dist/commands/contract-infer.d.mts.map +1 -1
  13. package/dist/commands/contract-infer.mjs +2 -2
  14. package/dist/commands/db-init.d.mts.map +1 -1
  15. package/dist/commands/db-init.mjs +10 -9
  16. package/dist/commands/db-init.mjs.map +1 -1
  17. package/dist/commands/db-schema.mjs +5 -5
  18. package/dist/commands/db-sign.mjs +7 -7
  19. package/dist/commands/db-update.mjs +9 -9
  20. package/dist/commands/db-update.mjs.map +1 -1
  21. package/dist/commands/db-verify.mjs +9 -9
  22. package/dist/commands/migration-apply.d.mts +5 -2
  23. package/dist/commands/migration-apply.d.mts.map +1 -1
  24. package/dist/commands/migration-apply.mjs +55 -56
  25. package/dist/commands/migration-apply.mjs.map +1 -1
  26. package/dist/commands/migration-new.d.mts.map +1 -1
  27. package/dist/commands/migration-new.mjs +26 -32
  28. package/dist/commands/migration-new.mjs.map +1 -1
  29. package/dist/commands/migration-plan.d.mts +14 -5
  30. package/dist/commands/migration-plan.d.mts.map +1 -1
  31. package/dist/commands/migration-plan.mjs +45 -48
  32. package/dist/commands/migration-plan.mjs.map +1 -1
  33. package/dist/commands/migration-ref.d.mts +1 -1
  34. package/dist/commands/migration-ref.d.mts.map +1 -1
  35. package/dist/commands/migration-ref.mjs +6 -10
  36. package/dist/commands/migration-ref.mjs.map +1 -1
  37. package/dist/commands/migration-show.d.mts +13 -7
  38. package/dist/commands/migration-show.d.mts.map +1 -1
  39. package/dist/commands/migration-show.mjs +27 -29
  40. package/dist/commands/migration-show.mjs.map +1 -1
  41. package/dist/commands/migration-status.d.mts +23 -5
  42. package/dist/commands/migration-status.d.mts.map +1 -1
  43. package/dist/commands/migration-status.mjs +3 -3
  44. package/dist/{config-loader-_W4T21X1.mjs → config-loader-ih8ViDb_.mjs} +2 -2
  45. package/dist/config-loader-ih8ViDb_.mjs.map +1 -0
  46. package/dist/config-loader.mjs +1 -1
  47. package/dist/contract-emit-LjzCoicC.mjs +4 -0
  48. package/dist/contract-emit-RZBWzkop.mjs +329 -0
  49. package/dist/contract-emit-RZBWzkop.mjs.map +1 -0
  50. package/dist/contract-emit-rt_Nmdwq.mjs +150 -0
  51. package/dist/contract-emit-rt_Nmdwq.mjs.map +1 -0
  52. package/dist/{contract-enrichment-CGW6mm-E.mjs → contract-enrichment-4Ptgw3Pe.mjs} +1 -1
  53. package/dist/{contract-enrichment-CGW6mm-E.mjs.map → contract-enrichment-4Ptgw3Pe.mjs.map} +1 -1
  54. package/dist/{contract-infer-BS4kIX9c.mjs → contract-infer-Cf5J2wVg.mjs} +11 -19
  55. package/dist/contract-infer-Cf5J2wVg.mjs.map +1 -0
  56. package/dist/exports/control-api.d.mts +86 -21
  57. package/dist/exports/control-api.d.mts.map +1 -1
  58. package/dist/exports/control-api.mjs +5 -5
  59. package/dist/exports/index.mjs +3 -3
  60. package/dist/exports/init-output.d.mts +39 -0
  61. package/dist/exports/init-output.d.mts.map +1 -0
  62. package/dist/exports/init-output.mjs +3 -0
  63. package/dist/{framework-components-DfZKQBQ2.mjs → framework-components-Bgcre3Z6.mjs} +2 -2
  64. package/dist/{framework-components-DfZKQBQ2.mjs.map → framework-components-Bgcre3Z6.mjs.map} +1 -1
  65. package/dist/init-C7dE9KOJ.mjs +2062 -0
  66. package/dist/init-C7dE9KOJ.mjs.map +1 -0
  67. package/dist/{inspect-live-schema-BsoFVoS1.mjs → inspect-live-schema-LWtXfxm_.mjs} +9 -9
  68. package/dist/inspect-live-schema-LWtXfxm_.mjs.map +1 -0
  69. package/dist/migration-cli.d.mts +41 -11
  70. package/dist/migration-cli.d.mts.map +1 -1
  71. package/dist/migration-cli.mjs +308 -84
  72. package/dist/migration-cli.mjs.map +1 -1
  73. package/dist/{migration-command-scaffold-DOXnheFa.mjs → migration-command-scaffold-CU452v9h.mjs} +7 -7
  74. package/dist/{migration-command-scaffold-DOXnheFa.mjs.map → migration-command-scaffold-CU452v9h.mjs.map} +1 -1
  75. package/dist/{migration-status-Ry3TnEya.mjs → migration-status-DoPrFIOQ.mjs} +114 -57
  76. package/dist/migration-status-DoPrFIOQ.mjs.map +1 -0
  77. package/dist/{migrations-fU0xoKjS.mjs → migrations-MEoKMiV5.mjs} +42 -21
  78. package/dist/migrations-MEoKMiV5.mjs.map +1 -0
  79. package/dist/output-BpcQrnnq.mjs +103 -0
  80. package/dist/output-BpcQrnnq.mjs.map +1 -0
  81. package/dist/{progress-adapter-B-YvmcDu.mjs → progress-adapter-DgRGldpT.mjs} +1 -1
  82. package/dist/{progress-adapter-B-YvmcDu.mjs.map → progress-adapter-DgRGldpT.mjs.map} +1 -1
  83. package/dist/quick-reference-mongo.md +34 -13
  84. package/dist/quick-reference-postgres.md +11 -9
  85. package/dist/{result-handler-BJwA7ufw.mjs → result-handler-Ch6hVnOo.mjs} +35 -93
  86. package/dist/result-handler-Ch6hVnOo.mjs.map +1 -0
  87. package/dist/{terminal-ui-C5k88MmW.mjs → terminal-ui-u2YgKghu.mjs} +76 -2
  88. package/dist/terminal-ui-u2YgKghu.mjs.map +1 -0
  89. package/dist/{verify-bl__PkXk.mjs → verify-BT9tgCOH.mjs} +2 -2
  90. package/dist/{verify-bl__PkXk.mjs.map → verify-BT9tgCOH.mjs.map} +1 -1
  91. package/package.json +12 -10
  92. package/dist/cli-errors-DHq6GQGu.mjs +0 -5
  93. package/dist/client-TG7rbCWT.mjs.map +0 -1
  94. package/dist/config-loader-_W4T21X1.mjs.map +0 -1
  95. package/dist/contract-emit-CQfj7xJn.mjs +0 -122
  96. package/dist/contract-emit-CQfj7xJn.mjs.map +0 -1
  97. package/dist/contract-emit-DpPjuFy-.mjs +0 -195
  98. package/dist/contract-emit-DpPjuFy-.mjs.map +0 -1
  99. package/dist/contract-emit-fhNwwhkQ.mjs +0 -4
  100. package/dist/contract-infer-BS4kIX9c.mjs.map +0 -1
  101. package/dist/extract-operation-statements-DZUJNmL3.mjs +0 -13
  102. package/dist/extract-operation-statements-DZUJNmL3.mjs.map +0 -1
  103. package/dist/extract-sql-ddl-DDMX-9mz.mjs +0 -26
  104. package/dist/extract-sql-ddl-DDMX-9mz.mjs.map +0 -1
  105. package/dist/init-CQfo_4Ro.mjs +0 -430
  106. package/dist/init-CQfo_4Ro.mjs.map +0 -1
  107. package/dist/inspect-live-schema-BsoFVoS1.mjs.map +0 -1
  108. package/dist/migration-status-Ry3TnEya.mjs.map +0 -1
  109. package/dist/migrations-fU0xoKjS.mjs.map +0 -1
  110. package/dist/result-handler-BJwA7ufw.mjs.map +0 -1
  111. package/dist/terminal-ui-C5k88MmW.mjs.map +0 -1
  112. package/dist/validate-contract-deps-esa-VQ0h.mjs +0 -37
  113. package/dist/validate-contract-deps-esa-VQ0h.mjs.map +0 -1
@@ -1,195 +0,0 @@
1
- import { t as loadConfig } from "./config-loader-_W4T21X1.mjs";
2
- import { _ as errorUnexpected$1, a as errorContractValidationFailed, m as errorRuntime, t as CliStructuredError$1 } from "./cli-errors-DHq6GQGu.mjs";
3
- import { t as createControlClient } from "./client-TG7rbCWT.mjs";
4
- import { _ as formatStyledHeader, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions, v as formatSuccessMessage, x as isVerbose } from "./result-handler-BJwA7ufw.mjs";
5
- import { t as createProgressAdapter } from "./progress-adapter-B-YvmcDu.mjs";
6
- import { t as TerminalUI } from "./terminal-ui-C5k88MmW.mjs";
7
- import { Command } from "commander";
8
- import { mkdirSync, writeFileSync } from "node:fs";
9
- import { getEmittedArtifactPaths } from "@prisma-next/emitter";
10
- import { errorContractConfigMissing } from "@prisma-next/errors/control";
11
- import { notOk, ok } from "@prisma-next/utils/result";
12
- import { dirname, relative, resolve } from "pathe";
13
- import { ifDefined } from "@prisma-next/utils/defined";
14
-
15
- //#region src/utils/formatters/emit.ts
16
- /**
17
- * Formats human-readable output for contract emit.
18
- */
19
- function formatEmitOutput(result, flags) {
20
- if (flags.quiet) return "";
21
- const lines = [];
22
- const jsonPath = relative(process.cwd(), result.files.json);
23
- const dtsPath = relative(process.cwd(), result.files.dts);
24
- lines.push(`✔ Emitted contract.json → ${jsonPath}`);
25
- lines.push(`✔ Emitted contract.d.ts → ${dtsPath}`);
26
- lines.push(` storageHash: ${result.storageHash}`);
27
- if (result.executionHash) lines.push(` executionHash: ${result.executionHash}`);
28
- if (result.profileHash) lines.push(` profileHash: ${result.profileHash}`);
29
- if (isVerbose(flags, 1)) lines.push(` Total time: ${result.timings.total}ms`);
30
- return lines.join("\n");
31
- }
32
- /**
33
- * Formats JSON output for contract emit.
34
- */
35
- function formatEmitJson(result) {
36
- const output = {
37
- ok: true,
38
- storageHash: result.storageHash,
39
- ...ifDefined("executionHash", result.executionHash),
40
- ...result.profileHash ? { profileHash: result.profileHash } : {},
41
- outDir: result.outDir,
42
- files: result.files,
43
- timings: result.timings
44
- };
45
- return JSON.stringify(output, null, 2);
46
- }
47
-
48
- //#endregion
49
- //#region src/commands/contract-emit.ts
50
- function mapDiagnosticsToIssues(failure) {
51
- return (failure.diagnostics?.diagnostics ?? []).map((diagnostic) => {
52
- const location = diagnostic.sourceId && diagnostic.span ? ` (${diagnostic.sourceId}:${diagnostic.span.start.line}:${diagnostic.span.start.column})` : diagnostic.sourceId ? ` (${diagnostic.sourceId})` : "";
53
- return {
54
- kind: diagnostic.code,
55
- message: `${diagnostic.message}${location}`
56
- };
57
- });
58
- }
59
- /**
60
- * Maps an EmitFailure to a CliStructuredError for consistent error handling.
61
- */
62
- function mapEmitFailure(failure, context) {
63
- if (failure.code === "CONTRACT_SOURCE_INVALID") {
64
- const issues = mapDiagnosticsToIssues(failure);
65
- return errorRuntime(failure.summary, {
66
- why: failure.why ?? "Contract source provider failed",
67
- fix: "Check your contract source provider in prisma-next.config.ts and ensure it returns Result<Contract, Diagnostics>",
68
- ...issues.length > 0 ? { meta: { issues } } : {}
69
- });
70
- }
71
- if (failure.code === "CONTRACT_VALIDATION_FAILED") return errorContractValidationFailed(failure.why ?? "Contract validation failed while emitting", context?.configPath ? { where: { path: context.configPath } } : void 0);
72
- if (failure.code === "EMIT_FAILED") return errorRuntime(failure.summary, {
73
- why: failure.why ?? "Failed to emit contract",
74
- fix: "Check your contract configuration and ensure the source is valid"
75
- });
76
- const exhaustive = failure.code;
77
- throw new Error(`Unhandled EmitFailure code: ${exhaustive}`);
78
- }
79
- /**
80
- * Executes the contract emit command and returns a structured Result.
81
- */
82
- async function executeContractEmitCommand(options, flags, ui, startTime) {
83
- let config;
84
- try {
85
- config = await loadConfig(options.config);
86
- } catch (error) {
87
- if (error instanceof CliStructuredError$1) return notOk(error);
88
- return notOk(errorUnexpected$1(error instanceof Error ? error.message : String(error), { why: "Failed to load config" }));
89
- }
90
- const configPath = options.config ? relative(process.cwd(), resolve(options.config)) : "prisma-next.config.ts";
91
- if (!config.contract) return notOk(errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" }));
92
- const contractConfig = config.contract;
93
- if (!contractConfig.output) return notOk(errorContractConfigMissing({ why: "Contract config must have output path. This should not happen if defineConfig() was used." }));
94
- let outputPaths;
95
- try {
96
- outputPaths = getEmittedArtifactPaths(contractConfig.output);
97
- } catch (error) {
98
- return notOk(errorContractConfigMissing({ why: error instanceof Error ? error.message : String(error) }));
99
- }
100
- const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;
101
- if (!flags.json && !flags.quiet) {
102
- const contractPath = relative(process.cwd(), outputJsonPath);
103
- const typesPath = relative(process.cwd(), outputDtsPath);
104
- const header = formatStyledHeader({
105
- command: "contract emit",
106
- description: "Emit your contract artifacts",
107
- url: "https://pris.ly/contract-emit",
108
- details: [
109
- {
110
- label: "config",
111
- value: configPath
112
- },
113
- {
114
- label: "contract",
115
- value: contractPath
116
- },
117
- {
118
- label: "types",
119
- value: typesPath
120
- }
121
- ],
122
- flags
123
- });
124
- ui.stderr(header);
125
- }
126
- const client = createControlClient({
127
- family: config.family,
128
- target: config.target,
129
- adapter: config.adapter,
130
- extensionPacks: config.extensionPacks ?? []
131
- });
132
- const onProgress = createProgressAdapter({
133
- ui,
134
- flags
135
- });
136
- try {
137
- const result = await client.emit({
138
- contractConfig: {
139
- source: contractConfig.source,
140
- output: outputJsonPath
141
- },
142
- onProgress
143
- });
144
- if (!result.ok) return notOk(mapEmitFailure(result.failure, { configPath }));
145
- mkdirSync(dirname(outputJsonPath), { recursive: true });
146
- mkdirSync(dirname(outputDtsPath), { recursive: true });
147
- writeFileSync(outputJsonPath, result.value.contractJson, "utf-8");
148
- writeFileSync(outputDtsPath, result.value.contractDts, "utf-8");
149
- const { validateContractDeps } = await import("./validate-contract-deps-esa-VQ0h.mjs");
150
- const depsValidation = validateContractDeps(result.value.contractDts, dirname(outputDtsPath));
151
- if (depsValidation.warning) ui.warn(depsValidation.warning);
152
- return ok({
153
- storageHash: result.value.storageHash,
154
- ...result.value.executionHash ? { executionHash: result.value.executionHash } : {},
155
- profileHash: result.value.profileHash,
156
- outDir: dirname(outputJsonPath),
157
- files: {
158
- json: outputJsonPath,
159
- dts: outputDtsPath
160
- },
161
- timings: { total: Date.now() - startTime }
162
- });
163
- } catch (error) {
164
- if (CliStructuredError$1.is(error)) return notOk(error);
165
- return notOk(errorUnexpected$1("Unexpected error during contract emit", { why: error instanceof Error ? error.message : String(error) }));
166
- } finally {
167
- await client.close();
168
- }
169
- }
170
- function createContractEmitCommand() {
171
- const command = new Command("emit");
172
- setCommandDescriptions(command, "Emit your contract artifacts", "Reads your contract source (TypeScript or Prisma schema) and emits contract.json and\ncontract.d.ts. The contract.json contains the canonical contract structure, and\ncontract.d.ts provides TypeScript types for type-safe query building.");
173
- setCommandExamples(command, ["prisma-next contract emit", "prisma-next contract emit --config ./custom-config.ts"]);
174
- addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").action(async (options) => {
175
- const flags = parseGlobalFlags(options);
176
- const ui = new TerminalUI({
177
- color: flags.color,
178
- interactive: flags.interactive
179
- });
180
- const exitCode = handleResult(await executeContractEmitCommand(options, flags, ui, Date.now()), flags, ui, (emitResult) => {
181
- if (flags.json) ui.output(formatEmitJson(emitResult));
182
- else {
183
- const output = formatEmitOutput(emitResult, flags);
184
- if (output) ui.log(output);
185
- if (!flags.quiet) ui.success(formatSuccessMessage(flags));
186
- }
187
- });
188
- process.exit(exitCode);
189
- });
190
- return command;
191
- }
192
-
193
- //#endregion
194
- export { createContractEmitCommand as t };
195
- //# sourceMappingURL=contract-emit-DpPjuFy-.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract-emit-DpPjuFy-.mjs","names":["lines: string[]","exhaustive: never","config: Awaited<ReturnType<typeof loadConfig>>","CliStructuredError","errorUnexpected","outputPaths: ReturnType<typeof getEmittedArtifactPaths>"],"sources":["../src/utils/formatters/emit.ts","../src/commands/contract-emit.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\nimport { relative } from 'pathe';\n\nimport type { GlobalFlags } from '../global-flags';\nimport { isVerbose } from './helpers';\n\n// EmitContractResult type for CLI output formatting (includes file paths)\nexport interface EmitContractResult {\n readonly storageHash: string;\n readonly executionHash?: string;\n readonly profileHash: string;\n readonly outDir: string;\n readonly files: {\n readonly json: string;\n readonly dts: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\n/**\n * Formats human-readable output for contract emit.\n */\nexport function formatEmitOutput(result: EmitContractResult, flags: GlobalFlags): string {\n if (flags.quiet) {\n return '';\n }\n\n const lines: string[] = [];\n\n // Convert absolute paths to relative paths from cwd\n const jsonPath = relative(process.cwd(), result.files.json);\n const dtsPath = relative(process.cwd(), result.files.dts);\n\n lines.push(`✔ Emitted contract.json → ${jsonPath}`);\n lines.push(`✔ Emitted contract.d.ts → ${dtsPath}`);\n lines.push(` storageHash: ${result.storageHash}`);\n if (result.executionHash) {\n lines.push(` executionHash: ${result.executionHash}`);\n }\n if (result.profileHash) {\n lines.push(` profileHash: ${result.profileHash}`);\n }\n if (isVerbose(flags, 1)) {\n lines.push(` Total time: ${result.timings.total}ms`);\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Formats JSON output for contract emit.\n */\nexport function formatEmitJson(result: EmitContractResult): string {\n const output = {\n ok: true,\n storageHash: result.storageHash,\n ...ifDefined('executionHash', result.executionHash),\n ...(result.profileHash ? { profileHash: result.profileHash } : {}),\n outDir: result.outDir,\n files: result.files,\n timings: result.timings,\n };\n\n return JSON.stringify(output, null, 2);\n}\n","import { mkdirSync, writeFileSync } from 'node:fs';\nimport { getEmittedArtifactPaths } from '@prisma-next/emitter';\nimport { errorContractConfigMissing } from '@prisma-next/errors/control';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { dirname, relative, resolve } from 'pathe';\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport type { EmitFailure } from '../control-api/types';\nimport {\n CliStructuredError,\n errorContractValidationFailed,\n errorRuntime,\n errorUnexpected,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport {\n type EmitContractResult,\n formatEmitJson,\n formatEmitOutput,\n} from '../utils/formatters/emit';\nimport { formatStyledHeader, formatSuccessMessage } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlags } from '../utils/global-flags';\nimport { createProgressAdapter } from '../utils/progress-adapter';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\n\ninterface ContractEmitOptions extends CommonCommandOptions {\n readonly config?: string;\n}\n\nfunction mapDiagnosticsToIssues(\n failure: EmitFailure,\n): ReadonlyArray<{ kind: string; message: string }> {\n const diagnostics = failure.diagnostics?.diagnostics ?? [];\n return diagnostics.map((diagnostic) => {\n const location =\n diagnostic.sourceId && diagnostic.span\n ? ` (${diagnostic.sourceId}:${diagnostic.span.start.line}:${diagnostic.span.start.column})`\n : diagnostic.sourceId\n ? ` (${diagnostic.sourceId})`\n : '';\n return {\n kind: diagnostic.code,\n message: `${diagnostic.message}${location}`,\n };\n });\n}\n\n/**\n * Maps an EmitFailure to a CliStructuredError for consistent error handling.\n */\nfunction mapEmitFailure(\n failure: EmitFailure,\n context?: { readonly configPath?: string },\n): CliStructuredError {\n if (failure.code === 'CONTRACT_SOURCE_INVALID') {\n const issues = mapDiagnosticsToIssues(failure);\n return errorRuntime(failure.summary, {\n why: failure.why ?? 'Contract source provider failed',\n fix: 'Check your contract source provider in prisma-next.config.ts and ensure it returns Result<Contract, Diagnostics>',\n ...(issues.length > 0 ? { meta: { issues } } : {}),\n });\n }\n\n if (failure.code === 'CONTRACT_VALIDATION_FAILED') {\n return errorContractValidationFailed(\n failure.why ?? 'Contract validation failed while emitting',\n context?.configPath ? { where: { path: context.configPath } } : undefined,\n );\n }\n\n if (failure.code === 'EMIT_FAILED') {\n return errorRuntime(failure.summary, {\n why: failure.why ?? 'Failed to emit contract',\n fix: 'Check your contract configuration and ensure the source is valid',\n });\n }\n\n // Exhaustive check - TypeScript will error if a new code is added but not handled\n const exhaustive: never = failure.code;\n throw new Error(`Unhandled EmitFailure code: ${exhaustive}`);\n}\n\n/**\n * Executes the contract emit command and returns a structured Result.\n */\nasync function executeContractEmitCommand(\n options: ContractEmitOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n startTime: number,\n): Promise<Result<EmitContractResult, CliStructuredError>> {\n // Load config\n let config: Awaited<ReturnType<typeof loadConfig>>;\n try {\n config = await loadConfig(options.config);\n } catch (error) {\n // Convert thrown CliStructuredError to Result\n if (error instanceof CliStructuredError) {\n return notOk(error);\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: 'Failed to load config',\n }),\n );\n }\n\n const configPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n\n // Resolve contract from config\n if (!config.contract) {\n return notOk(\n errorContractConfigMissing({\n why: 'Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }',\n }),\n );\n }\n\n // Contract config is already normalized by defineConfig() with defaults applied\n const contractConfig = config.contract;\n\n // Resolve artifact paths from config (already normalized by defineConfig() with defaults)\n if (!contractConfig.output) {\n return notOk(\n errorContractConfigMissing({\n why: 'Contract config must have output path. This should not happen if defineConfig() was used.',\n }),\n );\n }\n let outputPaths: ReturnType<typeof getEmittedArtifactPaths>;\n try {\n outputPaths = getEmittedArtifactPaths(contractConfig.output);\n } catch (error) {\n return notOk(\n errorContractConfigMissing({\n why: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;\n\n // Output header to stderr (decoration)\n if (!flags.json && !flags.quiet) {\n const contractPath = relative(process.cwd(), outputJsonPath);\n const typesPath = relative(process.cwd(), outputDtsPath);\n const header = formatStyledHeader({\n command: 'contract emit',\n description: 'Emit your contract artifacts',\n url: 'https://pris.ly/contract-emit',\n details: [\n { label: 'config', value: configPath },\n { label: 'contract', value: contractPath },\n { label: 'types', value: typesPath },\n ],\n flags,\n });\n ui.stderr(header);\n }\n\n // Create control client (no driver needed for emit)\n const client = createControlClient({\n family: config.family,\n target: config.target,\n adapter: config.adapter,\n extensionPacks: config.extensionPacks ?? [],\n });\n\n // Create progress adapter\n const onProgress = createProgressAdapter({ ui, flags });\n\n try {\n // Call emit with progress callback\n const result = await client.emit({\n contractConfig: {\n source: contractConfig.source,\n output: outputJsonPath,\n },\n onProgress,\n });\n\n // Handle failures by mapping to CLI structured error\n if (!result.ok) {\n return notOk(mapEmitFailure(result.failure, { configPath }));\n }\n\n // Create directories if needed\n mkdirSync(dirname(outputJsonPath), { recursive: true });\n mkdirSync(dirname(outputDtsPath), { recursive: true });\n\n // Write the results to files\n writeFileSync(outputJsonPath, result.value.contractJson, 'utf-8');\n writeFileSync(outputDtsPath, result.value.contractDts, 'utf-8');\n\n // Validate that contract.d.ts type imports are resolvable\n const { validateContractDeps } = await import('../utils/validate-contract-deps');\n const depsValidation = validateContractDeps(result.value.contractDts, dirname(outputDtsPath));\n if (depsValidation.warning) {\n ui.warn(depsValidation.warning);\n }\n\n // Convert success result to CLI output format\n const emitResult: EmitContractResult = {\n storageHash: result.value.storageHash,\n ...(result.value.executionHash ? { executionHash: result.value.executionHash } : {}),\n profileHash: result.value.profileHash,\n outDir: dirname(outputJsonPath),\n files: {\n json: outputJsonPath,\n dts: outputDtsPath,\n },\n timings: { total: Date.now() - startTime },\n };\n\n return ok(emitResult);\n } catch (error) {\n // Use static type guard to work across module boundaries\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n\n // Wrap unexpected errors\n return notOk(\n errorUnexpected('Unexpected error during contract emit', {\n why: error instanceof Error ? error.message : String(error),\n }),\n );\n } finally {\n await client.close();\n }\n}\n\nexport function createContractEmitCommand(): Command {\n const command = new Command('emit');\n setCommandDescriptions(\n command,\n 'Emit your contract artifacts',\n 'Reads your contract source (TypeScript or Prisma schema) and emits contract.json and\\n' +\n 'contract.d.ts. The contract.json contains the canonical contract structure, and\\n' +\n 'contract.d.ts provides TypeScript types for type-safe query building.',\n );\n setCommandExamples(command, [\n 'prisma-next contract emit',\n 'prisma-next contract emit --config ./custom-config.ts',\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (options: ContractEmitOptions) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const startTime = Date.now();\n\n const result = await executeContractEmitCommand(options, flags, ui, startTime);\n\n // Handle result - formats output and returns exit code\n const exitCode = handleResult(result, flags, ui, (emitResult) => {\n if (flags.json) {\n ui.output(formatEmitJson(emitResult));\n } else {\n const output = formatEmitOutput(emitResult, flags);\n if (output) {\n ui.log(output);\n }\n if (!flags.quiet) {\n ui.success(formatSuccessMessage(flags));\n }\n }\n });\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAAgB,iBAAiB,QAA4B,OAA4B;AACvF,KAAI,MAAM,MACR,QAAO;CAGT,MAAMA,QAAkB,EAAE;CAG1B,MAAM,WAAW,SAAS,QAAQ,KAAK,EAAE,OAAO,MAAM,KAAK;CAC3D,MAAM,UAAU,SAAS,QAAQ,KAAK,EAAE,OAAO,MAAM,IAAI;AAEzD,OAAM,KAAK,6BAA6B,WAAW;AACnD,OAAM,KAAK,6BAA6B,UAAU;AAClD,OAAM,KAAK,kBAAkB,OAAO,cAAc;AAClD,KAAI,OAAO,cACT,OAAM,KAAK,oBAAoB,OAAO,gBAAgB;AAExD,KAAI,OAAO,YACT,OAAM,KAAK,kBAAkB,OAAO,cAAc;AAEpD,KAAI,UAAU,OAAO,EAAE,CACrB,OAAM,KAAK,iBAAiB,OAAO,QAAQ,MAAM,IAAI;AAGvD,QAAO,MAAM,KAAK,KAAK;;;;;AAMzB,SAAgB,eAAe,QAAoC;CACjE,MAAM,SAAS;EACb,IAAI;EACJ,aAAa,OAAO;EACpB,GAAG,UAAU,iBAAiB,OAAO,cAAc;EACnD,GAAI,OAAO,cAAc,EAAE,aAAa,OAAO,aAAa,GAAG,EAAE;EACjE,QAAQ,OAAO;EACf,OAAO,OAAO;EACd,SAAS,OAAO;EACjB;AAED,QAAO,KAAK,UAAU,QAAQ,MAAM,EAA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,eAAe,WAAW,CAAC;QAChC;IACL,MAAM,SAAS,iBAAiB,YAAY,MAAM;AAClD,QAAI,OACF,IAAG,IAAI,OAAO;AAEhB,QAAI,CAAC,MAAM,MACT,IAAG,QAAQ,qBAAqB,MAAM,CAAC;;IAG3C;AACF,UAAQ,KAAK,SAAS;GACtB;AAEJ,QAAO"}
@@ -1,4 +0,0 @@
1
- import "./config-loader-_W4T21X1.mjs";
2
- import { t as executeContractEmit } from "./contract-emit-CQfj7xJn.mjs";
3
-
4
- export { executeContractEmit };
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract-infer-BS4kIX9c.mjs","names":[],"sources":["../src/commands/contract-infer-paths.ts","../src/commands/contract-infer.ts"],"sourcesContent":["import { dirname, resolve } from 'pathe';\n\ninterface ContractInferPathOptions {\n readonly output?: string;\n readonly config?: string;\n}\n\n/**\n * Resolves the output path for the inferred PSL contract.\n *\n * Priority:\n * 1. --output <path> flag (resolved relative to cwd)\n * 2. contract.prisma next to config.contract.output\n * 3. Canonical default: contract.prisma in the config directory\n */\nexport function resolveContractInferOutputPath(\n options: ContractInferPathOptions,\n contractOutput: string | undefined,\n): string {\n const configDir = options.config\n ? dirname(resolve(process.cwd(), options.config))\n : process.cwd();\n\n if (options.output) {\n return resolve(process.cwd(), options.output);\n }\n if (contractOutput) {\n const contractPath = resolve(configDir, contractOutput);\n return resolve(dirname(contractPath), 'contract.prisma');\n }\n return resolve(configDir, 'contract.prisma');\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { errorRuntime } from '@prisma-next/errors/execution';\nimport { printPsl, validatePrintableSqlSchemaIR } from '@prisma-next/psl-printer';\nimport {\n createPostgresDefaultMapping,\n createPostgresTypeMap,\n extractEnumInfo,\n parseRawDefault,\n} from '@prisma-next/psl-printer/postgres';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { dirname, relative } from 'pathe';\nimport type { CliStructuredError } from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport { parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\nimport { resolveContractInferOutputPath } from './contract-infer-paths';\nimport {\n type InspectLiveSchemaOptions,\n type InspectLiveSchemaResult,\n inspectLiveSchema,\n} from './inspect-live-schema';\n\ninterface ContractInferOptions extends InspectLiveSchemaOptions {\n readonly output?: string;\n}\n\ninterface ContractInferSuccessResult {\n readonly ok: true;\n readonly summary: string;\n readonly target: InspectLiveSchemaResult['target'];\n readonly psl: {\n readonly path: string;\n };\n readonly meta: InspectLiveSchemaResult['meta'];\n readonly timings: {\n readonly total: number;\n };\n}\n\nasync function executeContractInferCommand(\n options: ContractInferOptions,\n ui: TerminalUI,\n startTime: number,\n): Promise<Result<ContractInferSuccessResult, CliStructuredError>> {\n const flags = parseGlobalFlags(options);\n const inspectResult = await inspectLiveSchema(options, flags, ui, startTime, {\n commandName: 'contract infer',\n description: 'Infer a PSL contract from the live database schema',\n url: 'https://pris.ly/contract-infer',\n });\n\n if (!inspectResult.ok) {\n return inspectResult;\n }\n\n const { config, target, meta } = inspectResult.value;\n\n if (target.familyId !== 'sql') {\n return notOk(\n errorRuntime(`contract infer is not supported for family \"${target.familyId}\"`, {\n why: 'contract infer currently supports SQL targets only',\n fix: 'Use an SQL target (e.g. Postgres) with this command',\n }),\n );\n }\n\n const schema = validatePrintableSqlSchemaIR(inspectResult.value.schema);\n const outputPath = resolveContractInferOutputPath(options, config.contract?.output);\n const enumInfo = extractEnumInfo(schema.annotations);\n const pslContent = printPsl(schema, {\n defaultMapping: createPostgresDefaultMapping(),\n typeMap: createPostgresTypeMap(enumInfo.typeNames),\n enumInfo,\n parseRawDefault,\n });\n\n if (existsSync(outputPath) && !flags.json && !flags.quiet) {\n ui.stderr(`\\u26A0 Overwriting existing file: ${relative(process.cwd(), outputPath)}`);\n }\n\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, pslContent, 'utf-8');\n\n const pslPath = relative(process.cwd(), outputPath);\n if (!flags.json && !flags.quiet) {\n ui.stderr(`\\u2714 Contract written to ${pslPath}`);\n }\n\n return ok({\n ok: true,\n summary: 'Contract inferred successfully',\n target,\n psl: {\n path: pslPath,\n },\n meta,\n timings: {\n total: Date.now() - startTime,\n },\n });\n}\n\nexport function createContractInferCommand(): Command {\n const command = new Command('infer');\n setCommandDescriptions(\n command,\n 'Infer a PSL contract from the live database schema',\n 'Reads the live database schema and writes an inferred PSL contract to disk.\\n' +\n 'This command stops at `contract.prisma`; follow it with `contract emit` and\\n' +\n '`db sign` as separate steps.',\n );\n setCommandExamples(command, [\n 'prisma-next contract infer --db $DATABASE_URL',\n 'prisma-next contract infer --db $DATABASE_URL --output ./prisma/contract.prisma',\n 'prisma-next contract infer --db $DATABASE_URL --json',\n ]);\n addGlobalOptions(command)\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--output <path>', 'Write the inferred PSL contract to the specified path')\n .action(async (options: ContractInferOptions) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const startTime = Date.now();\n\n const result = await executeContractInferCommand(options, ui, startTime);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value, null, 2));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA,SAAgB,+BACd,SACA,gBACQ;CACR,MAAM,YAAY,QAAQ,SACtB,QAAQ,QAAQ,QAAQ,KAAK,EAAE,QAAQ,OAAO,CAAC,GAC/C,QAAQ,KAAK;AAEjB,KAAI,QAAQ,OACV,QAAO,QAAQ,QAAQ,KAAK,EAAE,QAAQ,OAAO;AAE/C,KAAI,eAEF,QAAO,QAAQ,QADM,QAAQ,WAAW,eAAe,CACnB,EAAE,kBAAkB;AAE1D,QA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1B;EACA;EACA;EACD,CAAC;AACF,kBAAiB,QAAQ,CACtB,OAAO,cAAc,6BAA6B,CAClD,OAAO,mBAAmB,gCAAgC,CAC1D,OAAO,mBAAmB,wDAAwD,CAClF,OAAO,OAAO,YAAkC;EAC/C,MAAM,QAAQ,iBAAiB,QAAQ;EACvC,MAAM,KAAK,IAAI,WAAW;GAAE,OAAO,MAAM;GAAO,aAAa,MAAM;GAAa,CAAC;EAIjF,MAAM,WAAW,aADF,MAAM,4BAA4B,SAAS,IAFxC,KAAK,KAAK,CAE4C,EAClC,OAAO,KAAK,UAAU;AAC1D,OAAI,MAAM,KACR,IAAG,OAAO,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;IAE3C;AAEF,UAAQ,KAAK,SAAS;GACtB;AAEJ,QAAO"}
@@ -1,13 +0,0 @@
1
- import { t as extractSqlDdl } from "./extract-sql-ddl-DDMX-9mz.mjs";
2
-
3
- //#region src/control-api/operations/extract-operation-statements.ts
4
- function extractOperationStatements(familyId, operations) {
5
- switch (familyId) {
6
- case "sql": return extractSqlDdl(operations);
7
- default: return;
8
- }
9
- }
10
-
11
- //#endregion
12
- export { extractOperationStatements as t };
13
- //# sourceMappingURL=extract-operation-statements-DZUJNmL3.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract-operation-statements-DZUJNmL3.mjs","names":[],"sources":["../src/control-api/operations/extract-operation-statements.ts"],"sourcesContent":["import type { MigrationPlanOperation } from '@prisma-next/framework-components/control';\nimport { extractSqlDdl } from './extract-sql-ddl';\n\nexport function extractOperationStatements(\n familyId: string,\n operations: readonly MigrationPlanOperation[],\n): string[] | undefined {\n switch (familyId) {\n case 'sql':\n return extractSqlDdl(operations);\n default:\n return undefined;\n }\n}\n"],"mappings":";;;AAGA,SAAgB,2BACd,UACA,YACsB;AACtB,SAAQ,UAAR;EACE,KAAK,MACH,QAAO,cAAc,WAAW;EAClC,QACE"}
@@ -1,26 +0,0 @@
1
- //#region src/control-api/operations/extract-sql-ddl.ts
2
- function isDdlStatement(sqlStatement) {
3
- const trimmed = sqlStatement.trim().toLowerCase();
4
- return trimmed.startsWith("create ") || trimmed.startsWith("alter ") || trimmed.startsWith("drop ");
5
- }
6
- function hasExecuteSteps(operation) {
7
- const candidate = operation;
8
- if (!("execute" in candidate) || !Array.isArray(candidate["execute"])) return false;
9
- return candidate["execute"].every((step) => typeof step === "object" && step !== null && "sql" in step);
10
- }
11
- /**
12
- * Extracts a best-effort SQL DDL preview for CLI plan output.
13
- * This helper is presentation-only and is never used to decide migration correctness.
14
- */
15
- function extractSqlDdl(operations) {
16
- const statements = [];
17
- for (const operation of operations) {
18
- if (!hasExecuteSteps(operation)) continue;
19
- for (const step of operation.execute) if (typeof step.sql === "string" && isDdlStatement(step.sql)) statements.push(step.sql.trim());
20
- }
21
- return statements;
22
- }
23
-
24
- //#endregion
25
- export { extractSqlDdl as t };
26
- //# sourceMappingURL=extract-sql-ddl-DDMX-9mz.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract-sql-ddl-DDMX-9mz.mjs","names":["statements: string[]"],"sources":["../src/control-api/operations/extract-sql-ddl.ts"],"sourcesContent":["import type { MigrationPlanOperation } from '@prisma-next/framework-components/control';\n\n/**\n * Shape of an SQL execute step on SqlMigrationPlanOperation.\n * Used for runtime type narrowing without importing the concrete SQL type.\n */\ninterface SqlExecuteStep {\n readonly sql: string;\n}\n\nfunction isDdlStatement(sqlStatement: string): boolean {\n const trimmed = sqlStatement.trim().toLowerCase();\n return (\n trimmed.startsWith('create ') || trimmed.startsWith('alter ') || trimmed.startsWith('drop ')\n );\n}\n\nfunction hasExecuteSteps(\n operation: MigrationPlanOperation,\n): operation is MigrationPlanOperation & { readonly execute: readonly SqlExecuteStep[] } {\n const candidate = operation as unknown as Record<string, unknown>;\n if (!('execute' in candidate) || !Array.isArray(candidate['execute'])) {\n return false;\n }\n return candidate['execute'].every(\n (step: unknown) => typeof step === 'object' && step !== null && 'sql' in step,\n );\n}\n\n/**\n * Extracts a best-effort SQL DDL preview for CLI plan output.\n * This helper is presentation-only and is never used to decide migration correctness.\n */\nexport function extractSqlDdl(operations: readonly MigrationPlanOperation[]): string[] {\n const statements: string[] = [];\n for (const operation of operations) {\n if (!hasExecuteSteps(operation)) {\n continue;\n }\n for (const step of operation.execute) {\n if (typeof step.sql === 'string' && isDdlStatement(step.sql)) {\n statements.push(step.sql.trim());\n }\n }\n }\n return statements;\n}\n"],"mappings":";AAUA,SAAS,eAAe,cAA+B;CACrD,MAAM,UAAU,aAAa,MAAM,CAAC,aAAa;AACjD,QACE,QAAQ,WAAW,UAAU,IAAI,QAAQ,WAAW,SAAS,IAAI,QAAQ,WAAW,QAAQ;;AAIhG,SAAS,gBACP,WACuF;CACvF,MAAM,YAAY;AAClB,KAAI,EAAE,aAAa,cAAc,CAAC,MAAM,QAAQ,UAAU,WAAW,CACnE,QAAO;AAET,QAAO,UAAU,WAAW,OACzB,SAAkB,OAAO,SAAS,YAAY,SAAS,QAAQ,SAAS,KAC1E;;;;;;AAOH,SAAgB,cAAc,YAAyD;CACrF,MAAMA,aAAuB,EAAE;AAC/B,MAAK,MAAM,aAAa,YAAY;AAClC,MAAI,CAAC,gBAAgB,UAAU,CAC7B;AAEF,OAAK,MAAM,QAAQ,UAAU,QAC3B,KAAI,OAAO,KAAK,QAAQ,YAAY,eAAe,KAAK,IAAI,CAC1D,YAAW,KAAK,KAAK,IAAI,MAAM,CAAC;;AAItC,QAAO"}