@prisma-next/cli 0.3.0-pr.99.6 → 0.4.0-dev.1
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/LICENSE +201 -0
- package/README.md +381 -128
- package/dist/agent-skill-mongo.md +106 -0
- package/dist/agent-skill-postgres.md +106 -0
- package/dist/cli-errors-BDCYR5ap.mjs +4 -0
- package/dist/cli-errors-DStABy9d.d.mts +3 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.js +1 -2910
- package/dist/cli.mjs +254 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/client-DiUkJAeN.mjs +987 -0
- package/dist/client-DiUkJAeN.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts +7 -0
- package/dist/commands/contract-emit.d.mts.map +1 -0
- package/dist/commands/contract-emit.mjs +4 -0
- package/dist/commands/contract-infer.d.mts +7 -0
- package/dist/commands/contract-infer.d.mts.map +1 -0
- package/dist/commands/contract-infer.mjs +4 -0
- package/dist/commands/db-init.d.mts +7 -0
- package/dist/commands/db-init.d.mts.map +1 -0
- package/dist/commands/db-init.mjs +125 -0
- package/dist/commands/db-init.mjs.map +1 -0
- package/dist/commands/db-schema.d.mts +7 -0
- package/dist/commands/db-schema.d.mts.map +1 -0
- package/dist/commands/db-schema.mjs +53 -0
- package/dist/commands/db-schema.mjs.map +1 -0
- package/dist/commands/db-sign.d.mts +7 -0
- package/dist/commands/db-sign.d.mts.map +1 -0
- package/dist/commands/db-sign.mjs +136 -0
- package/dist/commands/db-sign.mjs.map +1 -0
- package/dist/commands/db-update.d.mts +7 -0
- package/dist/commands/db-update.d.mts.map +1 -0
- package/dist/commands/db-update.mjs +122 -0
- package/dist/commands/db-update.mjs.map +1 -0
- package/dist/commands/db-verify.d.mts +7 -0
- package/dist/commands/db-verify.d.mts.map +1 -0
- package/dist/commands/db-verify.mjs +322 -0
- package/dist/commands/db-verify.mjs.map +1 -0
- package/dist/commands/migration-apply.d.mts +36 -0
- package/dist/commands/migration-apply.d.mts.map +1 -0
- package/dist/commands/migration-apply.mjs +244 -0
- package/dist/commands/migration-apply.mjs.map +1 -0
- package/dist/commands/migration-new.d.mts +8 -0
- package/dist/commands/migration-new.d.mts.map +1 -0
- package/dist/commands/migration-new.mjs +152 -0
- package/dist/commands/migration-new.mjs.map +1 -0
- package/dist/commands/migration-plan.d.mts +47 -0
- package/dist/commands/migration-plan.d.mts.map +1 -0
- package/dist/commands/migration-plan.mjs +313 -0
- package/dist/commands/migration-plan.mjs.map +1 -0
- package/dist/commands/migration-ref.d.mts +43 -0
- package/dist/commands/migration-ref.d.mts.map +1 -0
- package/dist/commands/migration-ref.mjs +195 -0
- package/dist/commands/migration-ref.mjs.map +1 -0
- package/dist/commands/migration-show.d.mts +28 -0
- package/dist/commands/migration-show.d.mts.map +1 -0
- package/dist/commands/migration-show.mjs +140 -0
- package/dist/commands/migration-show.mjs.map +1 -0
- package/dist/commands/migration-status.d.mts +86 -0
- package/dist/commands/migration-status.d.mts.map +1 -0
- package/dist/commands/migration-status.mjs +4 -0
- package/dist/commands/migration-verify.d.mts +16 -0
- package/dist/commands/migration-verify.d.mts.map +1 -0
- package/dist/commands/migration-verify.mjs +110 -0
- package/dist/commands/migration-verify.mjs.map +1 -0
- package/dist/config-loader-C4VXKl8f.mjs +43 -0
- package/dist/config-loader-C4VXKl8f.mjs.map +1 -0
- package/dist/{config-loader.d.ts → config-loader.d.mts} +8 -3
- package/dist/config-loader.d.mts.map +1 -0
- package/dist/config-loader.mjs +3 -0
- package/dist/contract-emit-D2wDXfyo.mjs +191 -0
- package/dist/contract-emit-D2wDXfyo.mjs.map +1 -0
- package/dist/contract-emit-D9WOShFz.mjs +4 -0
- package/dist/contract-emit-Zm_sd1wQ.mjs +112 -0
- package/dist/contract-emit-Zm_sd1wQ.mjs.map +1 -0
- package/dist/contract-enrichment-CGW6mm-E.mjs +79 -0
- package/dist/contract-enrichment-CGW6mm-E.mjs.map +1 -0
- package/dist/contract-infer-DozZT511.mjs +90 -0
- package/dist/contract-infer-DozZT511.mjs.map +1 -0
- package/dist/exports/config-types.d.mts +2 -0
- package/dist/exports/config-types.mjs +3 -0
- package/dist/exports/control-api.d.mts +624 -0
- package/dist/exports/control-api.d.mts.map +1 -0
- package/dist/exports/control-api.mjs +6 -0
- package/dist/{load-ts-contract.d.ts → exports/index.d.mts} +12 -7
- package/dist/exports/index.d.mts.map +1 -0
- package/dist/exports/index.mjs +137 -0
- package/dist/exports/index.mjs.map +1 -0
- package/dist/extract-operation-statements-DZUJNmL3.mjs +13 -0
- package/dist/extract-operation-statements-DZUJNmL3.mjs.map +1 -0
- package/dist/extract-sql-ddl-DDMX-9mz.mjs +26 -0
- package/dist/extract-sql-ddl-DDMX-9mz.mjs.map +1 -0
- package/dist/framework-components-BAsliT4V.mjs +59 -0
- package/dist/framework-components-BAsliT4V.mjs.map +1 -0
- package/dist/init-DQ8auNB4.mjs +430 -0
- package/dist/init-DQ8auNB4.mjs.map +1 -0
- package/dist/inspect-live-schema-BYnhztxZ.mjs +91 -0
- package/dist/inspect-live-schema-BYnhztxZ.mjs.map +1 -0
- package/dist/migration-command-scaffold-CntCcntR.mjs +105 -0
- package/dist/migration-command-scaffold-CntCcntR.mjs.map +1 -0
- package/dist/migration-status-CJANY4yr.mjs +1583 -0
- package/dist/migration-status-CJANY4yr.mjs.map +1 -0
- package/dist/migrations-DTZBYXm1.mjs +173 -0
- package/dist/migrations-DTZBYXm1.mjs.map +1 -0
- package/dist/progress-adapter-B-YvmcDu.mjs +43 -0
- package/dist/progress-adapter-B-YvmcDu.mjs.map +1 -0
- package/dist/quick-reference-mongo.md +93 -0
- package/dist/quick-reference-postgres.md +91 -0
- package/dist/result-handler-oK_vA-Fn.mjs +697 -0
- package/dist/result-handler-oK_vA-Fn.mjs.map +1 -0
- package/dist/terminal-ui-C5k88MmW.mjs +274 -0
- package/dist/terminal-ui-C5k88MmW.mjs.map +1 -0
- package/dist/validate-contract-deps-esa-VQ0h.mjs +37 -0
- package/dist/validate-contract-deps-esa-VQ0h.mjs.map +1 -0
- package/dist/verify-DlFQ2FOw.mjs +385 -0
- package/dist/verify-DlFQ2FOw.mjs.map +1 -0
- package/package.json +87 -40
- package/src/cli.ts +118 -58
- package/src/commands/contract-emit.ts +101 -78
- package/src/commands/contract-infer-paths.ts +32 -0
- package/src/commands/contract-infer.ts +143 -0
- package/src/commands/db-init.ts +97 -219
- package/src/commands/db-schema.ts +77 -0
- package/src/commands/db-sign.ts +46 -73
- package/src/commands/db-update.ts +236 -0
- package/src/commands/db-verify.ts +409 -119
- package/src/commands/init/detect-package-manager.ts +47 -0
- package/src/commands/init/index.ts +21 -0
- package/src/commands/init/init.ts +203 -0
- package/src/commands/init/templates/agent-skill-mongo.md +106 -0
- package/src/commands/init/templates/agent-skill-postgres.md +106 -0
- package/src/commands/init/templates/agent-skill.ts +19 -0
- package/src/commands/init/templates/code-templates.ts +168 -0
- package/src/commands/init/templates/quick-reference-mongo.md +93 -0
- package/src/commands/init/templates/quick-reference-postgres.md +91 -0
- package/src/commands/init/templates/quick-reference.ts +19 -0
- package/src/commands/init/templates/render.ts +20 -0
- package/src/commands/init/templates/tsconfig.ts +35 -0
- package/src/commands/inspect-live-schema.ts +170 -0
- package/src/commands/migration-apply.ts +427 -0
- package/src/commands/migration-new.ts +260 -0
- package/src/commands/migration-plan.ts +519 -0
- package/src/commands/migration-ref.ts +305 -0
- package/src/commands/migration-show.ts +246 -0
- package/src/commands/migration-status.ts +864 -0
- package/src/commands/migration-verify.ts +180 -0
- package/src/config-loader.ts +13 -3
- package/src/control-api/client.ts +205 -183
- package/src/control-api/contract-enrichment.ts +119 -0
- package/src/control-api/errors.ts +9 -0
- package/src/control-api/operations/contract-emit.ts +181 -0
- package/src/control-api/operations/db-init.ts +53 -49
- package/src/control-api/operations/db-update.ts +220 -0
- package/src/control-api/operations/extract-operation-statements.ts +14 -0
- package/src/control-api/operations/extract-sql-ddl.ts +47 -0
- package/src/control-api/operations/migration-apply.ts +191 -0
- package/src/control-api/operations/migration-helpers.ts +49 -0
- package/src/control-api/types.ts +274 -52
- package/src/exports/config-types.ts +4 -3
- package/src/exports/control-api.ts +15 -5
- package/src/load-ts-contract.ts +30 -19
- package/src/utils/cli-errors.ts +14 -8
- package/src/utils/command-helpers.ts +302 -3
- package/src/utils/formatters/emit.ts +67 -0
- package/src/utils/formatters/errors.ts +82 -0
- package/src/utils/formatters/graph-migration-mapper.ts +240 -0
- package/src/utils/formatters/graph-render.ts +1323 -0
- package/src/utils/formatters/graph-types.ts +120 -0
- package/src/utils/formatters/help.ts +380 -0
- package/src/utils/formatters/helpers.ts +28 -0
- package/src/utils/formatters/migrations.ts +346 -0
- package/src/utils/formatters/styled.ts +212 -0
- package/src/utils/formatters/verify.ts +621 -0
- package/src/utils/framework-components.ts +13 -10
- package/src/utils/global-flags.ts +41 -23
- package/src/utils/migration-command-scaffold.ts +184 -0
- package/src/utils/migration-types.ts +12 -0
- package/src/utils/progress-adapter.ts +18 -29
- package/src/utils/result-handler.ts +12 -13
- package/src/utils/shutdown.ts +92 -0
- package/src/utils/suggest-command.ts +31 -0
- package/src/utils/terminal-ui.ts +276 -0
- package/src/utils/validate-contract-deps.ts +49 -0
- package/dist/chunk-AGOTG4L3.js +0 -965
- package/dist/chunk-AGOTG4L3.js.map +0 -1
- package/dist/chunk-HLLI4YL7.js +0 -180
- package/dist/chunk-HLLI4YL7.js.map +0 -1
- package/dist/chunk-HWYQOCAJ.js +0 -47
- package/dist/chunk-HWYQOCAJ.js.map +0 -1
- package/dist/chunk-VG2R7DGF.js +0 -735
- package/dist/chunk-VG2R7DGF.js.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/contract-emit.d.ts +0 -3
- package/dist/commands/contract-emit.d.ts.map +0 -1
- package/dist/commands/contract-emit.js +0 -10
- package/dist/commands/contract-emit.js.map +0 -1
- package/dist/commands/db-init.d.ts +0 -3
- package/dist/commands/db-init.d.ts.map +0 -1
- package/dist/commands/db-init.js +0 -257
- package/dist/commands/db-init.js.map +0 -1
- package/dist/commands/db-introspect.d.ts +0 -3
- package/dist/commands/db-introspect.d.ts.map +0 -1
- package/dist/commands/db-introspect.js +0 -155
- package/dist/commands/db-introspect.js.map +0 -1
- package/dist/commands/db-schema-verify.d.ts +0 -3
- package/dist/commands/db-schema-verify.d.ts.map +0 -1
- package/dist/commands/db-schema-verify.js +0 -171
- package/dist/commands/db-schema-verify.js.map +0 -1
- package/dist/commands/db-sign.d.ts +0 -3
- package/dist/commands/db-sign.d.ts.map +0 -1
- package/dist/commands/db-sign.js +0 -195
- package/dist/commands/db-sign.js.map +0 -1
- package/dist/commands/db-verify.d.ts +0 -3
- package/dist/commands/db-verify.d.ts.map +0 -1
- package/dist/commands/db-verify.js +0 -193
- package/dist/commands/db-verify.js.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js +0 -7
- package/dist/config-loader.js.map +0 -1
- package/dist/control-api/client.d.ts +0 -13
- package/dist/control-api/client.d.ts.map +0 -1
- package/dist/control-api/operations/db-init.d.ts +0 -29
- package/dist/control-api/operations/db-init.d.ts.map +0 -1
- package/dist/control-api/types.d.ts +0 -387
- package/dist/control-api/types.d.ts.map +0 -1
- package/dist/exports/config-types.d.ts +0 -3
- package/dist/exports/config-types.d.ts.map +0 -1
- package/dist/exports/config-types.js +0 -6
- package/dist/exports/config-types.js.map +0 -1
- package/dist/exports/control-api.d.ts +0 -13
- package/dist/exports/control-api.d.ts.map +0 -1
- package/dist/exports/control-api.js +0 -7
- package/dist/exports/control-api.js.map +0 -1
- package/dist/exports/index.d.ts +0 -4
- package/dist/exports/index.d.ts.map +0 -1
- package/dist/exports/index.js +0 -176
- package/dist/exports/index.js.map +0 -1
- package/dist/load-ts-contract.d.ts.map +0 -1
- package/dist/utils/cli-errors.d.ts +0 -7
- package/dist/utils/cli-errors.d.ts.map +0 -1
- package/dist/utils/command-helpers.d.ts +0 -12
- package/dist/utils/command-helpers.d.ts.map +0 -1
- package/dist/utils/framework-components.d.ts +0 -70
- package/dist/utils/framework-components.d.ts.map +0 -1
- package/dist/utils/global-flags.d.ts +0 -25
- package/dist/utils/global-flags.d.ts.map +0 -1
- package/dist/utils/output.d.ts +0 -142
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/progress-adapter.d.ts +0 -26
- package/dist/utils/progress-adapter.d.ts.map +0 -1
- package/dist/utils/result-handler.d.ts +0 -15
- package/dist/utils/result-handler.d.ts.map +0 -1
- package/src/commands/db-introspect.ts +0 -227
- package/src/commands/db-schema-verify.ts +0 -238
- package/src/utils/output.ts +0 -1471
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { t as loadConfig } from "./config-loader-C4VXKl8f.mjs";
|
|
2
|
+
import { _ as errorUnexpected$1, a as errorContractValidationFailed, m as errorRuntime, t as CliStructuredError } from "./cli-errors-BDCYR5ap.mjs";
|
|
3
|
+
import { t as createControlClient } from "./client-DiUkJAeN.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-oK_vA-Fn.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 { errorContractConfigMissing } from "@prisma-next/errors/control";
|
|
10
|
+
import { notOk, ok } from "@prisma-next/utils/result";
|
|
11
|
+
import { dirname, isAbsolute, join, relative, resolve } from "pathe";
|
|
12
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
13
|
+
|
|
14
|
+
//#region src/utils/formatters/emit.ts
|
|
15
|
+
/**
|
|
16
|
+
* Formats human-readable output for contract emit.
|
|
17
|
+
*/
|
|
18
|
+
function formatEmitOutput(result, flags) {
|
|
19
|
+
if (flags.quiet) return "";
|
|
20
|
+
const lines = [];
|
|
21
|
+
const jsonPath = relative(process.cwd(), result.files.json);
|
|
22
|
+
const dtsPath = relative(process.cwd(), result.files.dts);
|
|
23
|
+
lines.push(`✔ Emitted contract.json → ${jsonPath}`);
|
|
24
|
+
lines.push(`✔ Emitted contract.d.ts → ${dtsPath}`);
|
|
25
|
+
lines.push(` storageHash: ${result.storageHash}`);
|
|
26
|
+
if (result.executionHash) lines.push(` executionHash: ${result.executionHash}`);
|
|
27
|
+
if (result.profileHash) lines.push(` profileHash: ${result.profileHash}`);
|
|
28
|
+
if (isVerbose(flags, 1)) lines.push(` Total time: ${result.timings.total}ms`);
|
|
29
|
+
return lines.join("\n");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Formats JSON output for contract emit.
|
|
33
|
+
*/
|
|
34
|
+
function formatEmitJson(result) {
|
|
35
|
+
const output = {
|
|
36
|
+
ok: true,
|
|
37
|
+
storageHash: result.storageHash,
|
|
38
|
+
...ifDefined("executionHash", result.executionHash),
|
|
39
|
+
...result.profileHash ? { profileHash: result.profileHash } : {},
|
|
40
|
+
outDir: result.outDir,
|
|
41
|
+
files: result.files,
|
|
42
|
+
timings: result.timings
|
|
43
|
+
};
|
|
44
|
+
return JSON.stringify(output, null, 2);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/commands/contract-emit.ts
|
|
49
|
+
function mapDiagnosticsToIssues(failure) {
|
|
50
|
+
return (failure.diagnostics?.diagnostics ?? []).map((diagnostic) => {
|
|
51
|
+
const location = diagnostic.sourceId && diagnostic.span ? ` (${diagnostic.sourceId}:${diagnostic.span.start.line}:${diagnostic.span.start.column})` : diagnostic.sourceId ? ` (${diagnostic.sourceId})` : "";
|
|
52
|
+
return {
|
|
53
|
+
kind: diagnostic.code,
|
|
54
|
+
message: `${diagnostic.message}${location}`
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Maps an EmitFailure to a CliStructuredError for consistent error handling.
|
|
60
|
+
*/
|
|
61
|
+
function mapEmitFailure(failure, context) {
|
|
62
|
+
if (failure.code === "CONTRACT_SOURCE_INVALID") {
|
|
63
|
+
const issues = mapDiagnosticsToIssues(failure);
|
|
64
|
+
return errorRuntime(failure.summary, {
|
|
65
|
+
why: failure.why ?? "Contract source provider failed",
|
|
66
|
+
fix: "Check your contract source provider in prisma-next.config.ts and ensure it returns Result<Contract, Diagnostics>",
|
|
67
|
+
...issues.length > 0 ? { meta: { issues } } : {}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (failure.code === "CONTRACT_VALIDATION_FAILED") return errorContractValidationFailed(failure.why ?? "Contract validation failed while emitting", context?.configPath ? { where: { path: context.configPath } } : void 0);
|
|
71
|
+
if (failure.code === "EMIT_FAILED") return errorRuntime(failure.summary, {
|
|
72
|
+
why: failure.why ?? "Failed to emit contract",
|
|
73
|
+
fix: "Check your contract configuration and ensure the source is valid"
|
|
74
|
+
});
|
|
75
|
+
const exhaustive = failure.code;
|
|
76
|
+
throw new Error(`Unhandled EmitFailure code: ${exhaustive}`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Executes the contract emit command and returns a structured Result.
|
|
80
|
+
*/
|
|
81
|
+
async function executeContractEmitCommand(options, flags, ui, startTime) {
|
|
82
|
+
let config;
|
|
83
|
+
try {
|
|
84
|
+
config = await loadConfig(options.config);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (error instanceof CliStructuredError) return notOk(error);
|
|
87
|
+
return notOk(errorUnexpected$1(error instanceof Error ? error.message : String(error), { why: "Failed to load config" }));
|
|
88
|
+
}
|
|
89
|
+
const configPath = options.config ? relative(process.cwd(), resolve(options.config)) : "prisma-next.config.ts";
|
|
90
|
+
if (!config.contract) return notOk(errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" }));
|
|
91
|
+
const contractConfig = config.contract;
|
|
92
|
+
if (!contractConfig.output) return notOk(errorContractConfigMissing({ why: "Contract config must have output path. This should not happen if defineConfig() was used." }));
|
|
93
|
+
if (!contractConfig.output.endsWith(".json")) return notOk(errorContractConfigMissing({ why: "Contract config output path must end with .json (e.g., \"src/prisma/contract.json\")" }));
|
|
94
|
+
const configDir = options.config ? dirname(resolve(options.config)) : process.cwd();
|
|
95
|
+
const outputJsonPath = isAbsolute(contractConfig.output) ? contractConfig.output : join(configDir, contractConfig.output);
|
|
96
|
+
const outputDtsPath = `${outputJsonPath.slice(0, -5)}.d.ts`;
|
|
97
|
+
if (!flags.json && !flags.quiet) {
|
|
98
|
+
const contractPath = relative(process.cwd(), outputJsonPath);
|
|
99
|
+
const typesPath = relative(process.cwd(), outputDtsPath);
|
|
100
|
+
const header = formatStyledHeader({
|
|
101
|
+
command: "contract emit",
|
|
102
|
+
description: "Emit your contract artifacts",
|
|
103
|
+
url: "https://pris.ly/contract-emit",
|
|
104
|
+
details: [
|
|
105
|
+
{
|
|
106
|
+
label: "config",
|
|
107
|
+
value: configPath
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: "contract",
|
|
111
|
+
value: contractPath
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: "types",
|
|
115
|
+
value: typesPath
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
flags
|
|
119
|
+
});
|
|
120
|
+
ui.stderr(header);
|
|
121
|
+
}
|
|
122
|
+
const client = createControlClient({
|
|
123
|
+
family: config.family,
|
|
124
|
+
target: config.target,
|
|
125
|
+
adapter: config.adapter,
|
|
126
|
+
extensionPacks: config.extensionPacks ?? []
|
|
127
|
+
});
|
|
128
|
+
const onProgress = createProgressAdapter({
|
|
129
|
+
ui,
|
|
130
|
+
flags
|
|
131
|
+
});
|
|
132
|
+
try {
|
|
133
|
+
const result = await client.emit({
|
|
134
|
+
contractConfig: {
|
|
135
|
+
sourceProvider: contractConfig.source,
|
|
136
|
+
output: outputJsonPath
|
|
137
|
+
},
|
|
138
|
+
onProgress
|
|
139
|
+
});
|
|
140
|
+
if (!result.ok) return notOk(mapEmitFailure(result.failure, { configPath }));
|
|
141
|
+
mkdirSync(dirname(outputJsonPath), { recursive: true });
|
|
142
|
+
mkdirSync(dirname(outputDtsPath), { recursive: true });
|
|
143
|
+
writeFileSync(outputJsonPath, result.value.contractJson, "utf-8");
|
|
144
|
+
writeFileSync(outputDtsPath, result.value.contractDts, "utf-8");
|
|
145
|
+
const { validateContractDeps } = await import("./validate-contract-deps-esa-VQ0h.mjs");
|
|
146
|
+
const depsValidation = validateContractDeps(result.value.contractDts, dirname(outputDtsPath));
|
|
147
|
+
if (depsValidation.warning) ui.warn(depsValidation.warning);
|
|
148
|
+
return ok({
|
|
149
|
+
storageHash: result.value.storageHash,
|
|
150
|
+
...result.value.executionHash ? { executionHash: result.value.executionHash } : {},
|
|
151
|
+
profileHash: result.value.profileHash,
|
|
152
|
+
outDir: dirname(outputJsonPath),
|
|
153
|
+
files: {
|
|
154
|
+
json: outputJsonPath,
|
|
155
|
+
dts: outputDtsPath
|
|
156
|
+
},
|
|
157
|
+
timings: { total: Date.now() - startTime }
|
|
158
|
+
});
|
|
159
|
+
} catch (error) {
|
|
160
|
+
if (CliStructuredError.is(error)) return notOk(error);
|
|
161
|
+
return notOk(errorUnexpected$1("Unexpected error during contract emit", { why: error instanceof Error ? error.message : String(error) }));
|
|
162
|
+
} finally {
|
|
163
|
+
await client.close();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function createContractEmitCommand() {
|
|
167
|
+
const command = new Command("emit");
|
|
168
|
+
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.");
|
|
169
|
+
setCommandExamples(command, ["prisma-next contract emit", "prisma-next contract emit --config ./custom-config.ts"]);
|
|
170
|
+
addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").action(async (options) => {
|
|
171
|
+
const flags = parseGlobalFlags(options);
|
|
172
|
+
const ui = new TerminalUI({
|
|
173
|
+
color: flags.color,
|
|
174
|
+
interactive: flags.interactive
|
|
175
|
+
});
|
|
176
|
+
const exitCode = handleResult(await executeContractEmitCommand(options, flags, ui, Date.now()), flags, ui, (emitResult) => {
|
|
177
|
+
if (flags.json) ui.output(formatEmitJson(emitResult));
|
|
178
|
+
else {
|
|
179
|
+
const output = formatEmitOutput(emitResult, flags);
|
|
180
|
+
if (output) ui.log(output);
|
|
181
|
+
if (!flags.quiet) ui.success(formatSuccessMessage(flags));
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
process.exit(exitCode);
|
|
185
|
+
});
|
|
186
|
+
return command;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
export { createContractEmitCommand as t };
|
|
191
|
+
//# sourceMappingURL=contract-emit-D2wDXfyo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-emit-D2wDXfyo.mjs","names":["lines: string[]","exhaustive: never","config: Awaited<ReturnType<typeof loadConfig>>","errorUnexpected"],"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 { errorContractConfigMissing } from '@prisma-next/errors/control';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { dirname, isAbsolute, join, 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 if (!contractConfig.output.endsWith('.json')) {\n return notOk(\n errorContractConfigMissing({\n why: 'Contract config output path must end with .json (e.g., \"src/prisma/contract.json\")',\n }),\n );\n }\n const configDir = options.config ? dirname(resolve(options.config)) : process.cwd();\n const outputJsonPath = isAbsolute(contractConfig.output)\n ? contractConfig.output\n : join(configDir, contractConfig.output);\n // Colocate .d.ts with .json (contract.json → contract.d.ts)\n const outputDtsPath = `${outputJsonPath.slice(0, -5)}.d.ts`;\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 sourceProvider: 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,EAAE;;;;;AC9BxC,SAAS,uBACP,SACkD;AAElD,SADoB,QAAQ,aAAa,eAAe,E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,eAAe;AAC/D,OAAI,MAAM,KACR,IAAG,OAAO,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"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { t as loadConfig } from "./config-loader-C4VXKl8f.mjs";
|
|
2
|
+
import { i as errorContractConfigMissing, m as errorRuntime } from "./cli-errors-BDCYR5ap.mjs";
|
|
3
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-BAsliT4V.mjs";
|
|
4
|
+
import { t as enrichContract } from "./contract-enrichment-CGW6mm-E.mjs";
|
|
5
|
+
import { dirname, isAbsolute, join, resolve } from "pathe";
|
|
6
|
+
import { emit } from "@prisma-next/emitter";
|
|
7
|
+
import { createControlStack } from "@prisma-next/framework-components/control";
|
|
8
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
9
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
10
|
+
import { abortable } from "@prisma-next/utils/abortable";
|
|
11
|
+
|
|
12
|
+
//#region src/control-api/operations/contract-emit.ts
|
|
13
|
+
function isRecord(value) {
|
|
14
|
+
return typeof value === "object" && value !== null;
|
|
15
|
+
}
|
|
16
|
+
function isAbortError(error) {
|
|
17
|
+
return isRecord(error) && typeof error["name"] === "string" && error["name"] === "AbortError";
|
|
18
|
+
}
|
|
19
|
+
function isProviderFailureLike(value) {
|
|
20
|
+
return isRecord(value) && typeof value["summary"] === "string" && Array.isArray(value["diagnostics"]);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Executes the contract emit operation.
|
|
24
|
+
*
|
|
25
|
+
* This is an offline operation that:
|
|
26
|
+
* 1. Loads the Prisma Next config from the specified path
|
|
27
|
+
* 2. Resolves the contract source from config
|
|
28
|
+
* 3. Creates a control plane stack and family instance
|
|
29
|
+
* 4. Emits contract artifacts (JSON and DTS)
|
|
30
|
+
* 5. Writes files to the paths specified in config
|
|
31
|
+
*
|
|
32
|
+
* Supports AbortSignal for cancellation, enabling "last change wins" behavior.
|
|
33
|
+
*
|
|
34
|
+
* @param options - Options including configPath and optional signal
|
|
35
|
+
* @returns File paths and hashes of emitted artifacts
|
|
36
|
+
* @throws If config loading fails, contract is invalid, or file I/O fails
|
|
37
|
+
* @throws signal.reason if cancelled via AbortSignal (typically DOMException with name 'AbortError')
|
|
38
|
+
*/
|
|
39
|
+
async function executeContractEmit(options) {
|
|
40
|
+
const { configPath, signal = new AbortController().signal } = options;
|
|
41
|
+
const unlessAborted = abortable(signal);
|
|
42
|
+
const config = await unlessAborted(loadConfig(configPath));
|
|
43
|
+
if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
|
|
44
|
+
const contractConfig = config.contract;
|
|
45
|
+
if (!contractConfig.output) throw errorContractConfigMissing({ why: "Contract config must have output path. This should not happen if defineConfig() was used." });
|
|
46
|
+
if (!contractConfig.output.endsWith(".json")) throw errorContractConfigMissing({ why: "Contract config output path must end with .json (e.g., \"src/prisma/contract.json\")" });
|
|
47
|
+
if (typeof contractConfig.source !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider function" });
|
|
48
|
+
const configDir = dirname(resolve(configPath));
|
|
49
|
+
const outputJsonPath = isAbsolute(contractConfig.output) ? contractConfig.output : join(configDir, contractConfig.output);
|
|
50
|
+
const outputDtsPath = `${outputJsonPath.slice(0, -5)}.d.ts`;
|
|
51
|
+
const sourceContext = { composedExtensionPacks: (config.extensionPacks ?? []).map((p) => p.id) };
|
|
52
|
+
let providerResult;
|
|
53
|
+
try {
|
|
54
|
+
providerResult = await unlessAborted(contractConfig.source(sourceContext));
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (signal.aborted || isAbortError(error)) throw error;
|
|
57
|
+
throw errorRuntime("Failed to resolve contract source", {
|
|
58
|
+
why: error instanceof Error ? error.message : String(error),
|
|
59
|
+
fix: "Ensure contract.source resolves to ok(Contract) or returns structured diagnostics."
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (!isRecord(providerResult) || typeof providerResult.ok !== "boolean") throw errorRuntime("Failed to resolve contract source", {
|
|
63
|
+
why: "Contract source provider returned malformed result shape.",
|
|
64
|
+
fix: "Ensure contract.source resolves to ok(Contract) or notOk({ summary, diagnostics })."
|
|
65
|
+
});
|
|
66
|
+
if (providerResult.ok && !("value" in providerResult)) throw errorRuntime("Failed to resolve contract source", {
|
|
67
|
+
why: "Contract source provider returned malformed success result: missing value.",
|
|
68
|
+
fix: "Ensure contract.source success payload is ok(Contract)."
|
|
69
|
+
});
|
|
70
|
+
if (!providerResult.ok && !isProviderFailureLike(providerResult.failure)) throw errorRuntime("Failed to resolve contract source", {
|
|
71
|
+
why: "Contract source provider returned malformed failure result: expected summary and diagnostics.",
|
|
72
|
+
fix: "Ensure contract.source failure payload is notOk({ summary, diagnostics, meta? })."
|
|
73
|
+
});
|
|
74
|
+
if (!providerResult.ok) throw errorRuntime("Failed to resolve contract source", {
|
|
75
|
+
why: providerResult.failure.summary,
|
|
76
|
+
fix: "Fix contract source diagnostics and return ok(Contract).",
|
|
77
|
+
meta: {
|
|
78
|
+
diagnostics: providerResult.failure.diagnostics,
|
|
79
|
+
...ifDefined("providerMeta", providerResult.failure.meta)
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const stack = createControlStack(config);
|
|
83
|
+
const familyInstance = config.family.create(stack);
|
|
84
|
+
const rawComponents = [
|
|
85
|
+
config.target,
|
|
86
|
+
config.adapter,
|
|
87
|
+
...config.extensionPacks ?? []
|
|
88
|
+
];
|
|
89
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, rawComponents);
|
|
90
|
+
const enrichedIR = enrichContract(providerResult.value, frameworkComponents);
|
|
91
|
+
familyInstance.validateContract(enrichedIR);
|
|
92
|
+
const emitResult = await unlessAborted(emit(enrichedIR, stack, config.family.emission));
|
|
93
|
+
await unlessAborted(mkdir(dirname(outputJsonPath), { recursive: true }));
|
|
94
|
+
await unlessAborted(writeFile(outputJsonPath, emitResult.contractJson, "utf-8"));
|
|
95
|
+
await unlessAborted(writeFile(outputDtsPath, emitResult.contractDts, "utf-8"));
|
|
96
|
+
const { validateContractDeps } = await import("./validate-contract-deps-esa-VQ0h.mjs");
|
|
97
|
+
const depsValidation = validateContractDeps(emitResult.contractDts, dirname(outputDtsPath));
|
|
98
|
+
if (depsValidation.warning) process.stderr.write(`\n⚠ ${depsValidation.warning}\n`);
|
|
99
|
+
return {
|
|
100
|
+
storageHash: emitResult.storageHash,
|
|
101
|
+
...ifDefined("executionHash", emitResult.executionHash),
|
|
102
|
+
profileHash: emitResult.profileHash,
|
|
103
|
+
files: {
|
|
104
|
+
json: outputJsonPath,
|
|
105
|
+
dts: outputDtsPath
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
export { executeContractEmit as t };
|
|
112
|
+
//# sourceMappingURL=contract-emit-Zm_sd1wQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-emit-Zm_sd1wQ.mjs","names":["providerResult: Awaited<ReturnType<typeof contractConfig.source>>"],"sources":["../src/control-api/operations/contract-emit.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport type { Contract } from '@prisma-next/contract/types';\nimport { emit } from '@prisma-next/emitter';\nimport { createControlStack } from '@prisma-next/framework-components/control';\nimport { abortable } from '@prisma-next/utils/abortable';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { dirname, isAbsolute, join, resolve } from 'pathe';\nimport { loadConfig } from '../../config-loader';\nimport { errorContractConfigMissing, errorRuntime } from '../../utils/cli-errors';\nimport { assertFrameworkComponentsCompatible } from '../../utils/framework-components';\nimport { enrichContract } from '../contract-enrichment';\nimport type { ContractEmitOptions, ContractEmitResult } from '../types';\n\ninterface ProviderFailureLike {\n readonly summary: string;\n readonly diagnostics: readonly unknown[];\n readonly meta?: unknown;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isAbortError(error: unknown): boolean {\n return isRecord(error) && typeof error['name'] === 'string' && error['name'] === 'AbortError';\n}\n\nfunction isProviderFailureLike(value: unknown): value is ProviderFailureLike {\n return (\n isRecord(value) && typeof value['summary'] === 'string' && Array.isArray(value['diagnostics'])\n );\n}\n\n/**\n * Executes the contract emit operation.\n *\n * This is an offline operation that:\n * 1. Loads the Prisma Next config from the specified path\n * 2. Resolves the contract source from config\n * 3. Creates a control plane stack and family instance\n * 4. Emits contract artifacts (JSON and DTS)\n * 5. Writes files to the paths specified in config\n *\n * Supports AbortSignal for cancellation, enabling \"last change wins\" behavior.\n *\n * @param options - Options including configPath and optional signal\n * @returns File paths and hashes of emitted artifacts\n * @throws If config loading fails, contract is invalid, or file I/O fails\n * @throws signal.reason if cancelled via AbortSignal (typically DOMException with name 'AbortError')\n */\nexport async function executeContractEmit(\n options: ContractEmitOptions,\n): Promise<ContractEmitResult> {\n const { configPath, signal = new AbortController().signal } = options;\n const unlessAborted = abortable(signal);\n\n // Load config using the existing config loader\n const config = await unlessAborted(loadConfig(configPath));\n\n // Validate contract config is present\n if (!config.contract) {\n throw errorContractConfigMissing({\n why: 'Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }',\n });\n }\n\n const contractConfig = config.contract;\n\n // Validate output path is present and ends with .json\n if (!contractConfig.output) {\n throw errorContractConfigMissing({\n why: 'Contract config must have output path. This should not happen if defineConfig() was used.',\n });\n }\n if (!contractConfig.output.endsWith('.json')) {\n throw errorContractConfigMissing({\n why: 'Contract config output path must end with .json (e.g., \"src/prisma/contract.json\")',\n });\n }\n\n // Validate source exists and is callable\n if (typeof contractConfig.source !== 'function') {\n throw errorContractConfigMissing({\n why: 'Contract config must include a valid source provider function',\n });\n }\n\n // Normalize configPath and resolve artifact paths relative to config file directory\n const normalizedConfigPath = resolve(configPath);\n const configDir = dirname(normalizedConfigPath);\n const outputJsonPath = isAbsolute(contractConfig.output)\n ? contractConfig.output\n : join(configDir, contractConfig.output);\n // Colocate .d.ts with .json (contract.json → contract.d.ts)\n const outputDtsPath = `${outputJsonPath.slice(0, -5)}.d.ts`;\n\n const sourceContext = {\n composedExtensionPacks: (config.extensionPacks ?? []).map((p) => p.id),\n };\n\n let providerResult: Awaited<ReturnType<typeof contractConfig.source>>;\n try {\n providerResult = await unlessAborted(contractConfig.source(sourceContext));\n } catch (error) {\n if (signal.aborted || isAbortError(error)) {\n throw error;\n }\n throw errorRuntime('Failed to resolve contract source', {\n why: error instanceof Error ? error.message : String(error),\n fix: 'Ensure contract.source resolves to ok(Contract) or returns structured diagnostics.',\n });\n }\n\n if (!isRecord(providerResult) || typeof providerResult.ok !== 'boolean') {\n throw errorRuntime('Failed to resolve contract source', {\n why: 'Contract source provider returned malformed result shape.',\n fix: 'Ensure contract.source resolves to ok(Contract) or notOk({ summary, diagnostics }).',\n });\n }\n\n if (providerResult.ok && !('value' in providerResult)) {\n throw errorRuntime('Failed to resolve contract source', {\n why: 'Contract source provider returned malformed success result: missing value.',\n fix: 'Ensure contract.source success payload is ok(Contract).',\n });\n }\n\n if (!providerResult.ok && !isProviderFailureLike(providerResult.failure)) {\n throw errorRuntime('Failed to resolve contract source', {\n why: 'Contract source provider returned malformed failure result: expected summary and diagnostics.',\n fix: 'Ensure contract.source failure payload is notOk({ summary, diagnostics, meta? }).',\n });\n }\n\n if (!providerResult.ok) {\n throw errorRuntime('Failed to resolve contract source', {\n why: providerResult.failure.summary,\n fix: 'Fix contract source diagnostics and return ok(Contract).',\n meta: {\n diagnostics: providerResult.failure.diagnostics,\n ...ifDefined('providerMeta', providerResult.failure.meta),\n },\n });\n }\n\n const stack = createControlStack(config);\n const familyInstance = config.family.create(stack);\n\n const rawComponents = [config.target, config.adapter, ...(config.extensionPacks ?? [])];\n const frameworkComponents = assertFrameworkComponentsCompatible(\n config.family.familyId,\n config.target.targetId,\n rawComponents,\n );\n const enrichedIR = enrichContract(providerResult.value as Contract, frameworkComponents);\n\n familyInstance.validateContract(enrichedIR);\n const emitResult = await unlessAborted(emit(enrichedIR, stack, config.family.emission));\n\n // Create directory if needed and write files (both colocated)\n await unlessAborted(mkdir(dirname(outputJsonPath), { recursive: true }));\n await unlessAborted(writeFile(outputJsonPath, emitResult.contractJson, 'utf-8'));\n await unlessAborted(writeFile(outputDtsPath, emitResult.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(emitResult.contractDts, dirname(outputDtsPath));\n if (depsValidation.warning) {\n process.stderr.write(`\\n⚠ ${depsValidation.warning}\\n`);\n }\n\n return {\n storageHash: emitResult.storageHash,\n ...ifDefined('executionHash', emitResult.executionHash),\n profileHash: emitResult.profileHash,\n files: {\n json: outputJsonPath,\n dts: outputDtsPath,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,aAAa,OAAyB;AAC7C,QAAO,SAAS,MAAM,IAAI,OAAO,MAAM,YAAY,YAAY,MAAM,YAAY;;AAGnF,SAAS,sBAAsB,OAA8C;AAC3E,QACE,SAAS,MAAM,IAAI,OAAO,MAAM,eAAe,YAAY,MAAM,QAAQ,MAAM,eAAe;;;;;;;;;;;;;;;;;;;AAqBlG,eAAsB,oBACpB,SAC6B;CAC7B,MAAM,EAAE,YAAY,SAAS,IAAI,iBAAiB,CAAC,WAAW;CAC9D,MAAM,gBAAgB,UAAU,OAAO;CAGvC,MAAM,SAAS,MAAM,cAAc,WAAW,WAAW,CAAC;AAG1D,KAAI,CAAC,OAAO,SACV,OAAM,2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ACL,MAAM;GACJ,aAAa,eAAe,QAAQ;GACpC,GAAG,UAAU,gBAAgB,eAAe,QAAQ,KAAK;GAC1D;EACF,CAAC;CAGJ,MAAM,QAAQ,mBAAmB,OAAO;CACxC,MAAM,iBAAiB,OAAO,OAAO,OAAO,MAAM;CAElD,MAAM,gBAAgB;EAAC,OAAO;EAAQ,OAAO;EAAS,GAAI,OAAO,kBAAkB,EAAE;EAAE;CACvF,MAAM,sBAAsB,oCAC1B,OAAO,OAAO,UACd,OAAO,OAAO,UACd,cACD;CACD,MAAM,aAAa,eAAe,eAAe,OAAmB,oBAAoB;AAExF,gBAAe,iBAAiB,WAAW;CAC3C,MAAM,aAAa,MAAM,cAAc,KAAK,YAAY,OAAO,OAAO,OAAO,SAAS,CAAC;AAGvF,OAAM,cAAc,MAAM,QAAQ,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC,CAAC;AACxE,OAAM,cAAc,UAAU,gBAAgB,WAAW,cAAc,QAAQ,CAAC;AAChF,OAAM,cAAc,UAAU,eAAe,WAAW,aAAa,QAAQ,CAAC;CAG9E,MAAM,EAAE,yBAAyB,MAAM,OAAO;CAC9C,MAAM,iBAAiB,qBAAqB,WAAW,aAAa,QAAQ,cAAc,CAAC;AAC3F,KAAI,eAAe,QACjB,SAAQ,OAAO,MAAM,OAAO,eAAe,QAAQ,IAAI;AAGzD,QAAO;EACL,aAAa,WAAW;EACxB,GAAG,UAAU,iBAAiB,WAAW,cAAc;EACvD,aAAa,WAAW;EACxB,OAAO;GACL,MAAM;GACN,KAAK;GACN;EACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//#region src/control-api/contract-enrichment.ts
|
|
2
|
+
function isPlainObject(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function sortDeep(value) {
|
|
6
|
+
if (Array.isArray(value)) return value.map(sortDeep);
|
|
7
|
+
if (!isPlainObject(value)) return value;
|
|
8
|
+
const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));
|
|
9
|
+
const next = {};
|
|
10
|
+
for (const [key, child] of entries) next[key] = sortDeep(child);
|
|
11
|
+
return next;
|
|
12
|
+
}
|
|
13
|
+
function sortDeepTyped(value) {
|
|
14
|
+
return sortDeep(value);
|
|
15
|
+
}
|
|
16
|
+
function extractCapabilityMatrix(value) {
|
|
17
|
+
if (!isPlainObject(value)) return {};
|
|
18
|
+
const out = {};
|
|
19
|
+
for (const [namespace, maybeCaps] of Object.entries(value)) {
|
|
20
|
+
if (!isPlainObject(maybeCaps)) continue;
|
|
21
|
+
const caps = {};
|
|
22
|
+
for (const [key, flag] of Object.entries(maybeCaps)) if (typeof flag === "boolean") caps[key] = flag;
|
|
23
|
+
if (Object.keys(caps).length > 0) out[namespace] = caps;
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
function mergeCapabilities(left, right) {
|
|
28
|
+
const next = { ...left };
|
|
29
|
+
for (const [namespace, capabilities] of Object.entries(right)) next[namespace] = {
|
|
30
|
+
...left[namespace] ?? {},
|
|
31
|
+
...capabilities
|
|
32
|
+
};
|
|
33
|
+
return next;
|
|
34
|
+
}
|
|
35
|
+
function extractExtensionPackMeta(component) {
|
|
36
|
+
const { kind, id, version, capabilities, types } = component;
|
|
37
|
+
const base = {
|
|
38
|
+
kind,
|
|
39
|
+
id,
|
|
40
|
+
familyId: component.familyId,
|
|
41
|
+
targetId: component.targetId,
|
|
42
|
+
version
|
|
43
|
+
};
|
|
44
|
+
if (capabilities) base["capabilities"] = capabilities;
|
|
45
|
+
if (types) if (types.codecTypes) {
|
|
46
|
+
const { controlPlaneHooks: _, codecInstances: _ci, ...cleanedCodecTypes } = types.codecTypes;
|
|
47
|
+
base["types"] = {
|
|
48
|
+
...types,
|
|
49
|
+
codecTypes: cleanedCodecTypes
|
|
50
|
+
};
|
|
51
|
+
} else base["types"] = types;
|
|
52
|
+
return base;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Enriches a raw contract with framework-derived metadata:
|
|
56
|
+
* capabilities from all component descriptors and extension pack metadata
|
|
57
|
+
* from extension descriptors. Produces deterministically sorted output.
|
|
58
|
+
*/
|
|
59
|
+
function enrichContract(ir, components) {
|
|
60
|
+
let mergedCapabilities = ir.capabilities;
|
|
61
|
+
const extensionPacksMeta = {};
|
|
62
|
+
for (const component of components) {
|
|
63
|
+
if (component.capabilities) mergedCapabilities = mergeCapabilities(mergedCapabilities, extractCapabilityMatrix(component.capabilities));
|
|
64
|
+
if (component.kind === "extension") extensionPacksMeta[component.id] = extractExtensionPackMeta(component);
|
|
65
|
+
}
|
|
66
|
+
const extensionPacks = Object.keys(extensionPacksMeta).length > 0 ? {
|
|
67
|
+
...ir.extensionPacks,
|
|
68
|
+
...extensionPacksMeta
|
|
69
|
+
} : ir.extensionPacks;
|
|
70
|
+
return {
|
|
71
|
+
...ir,
|
|
72
|
+
capabilities: sortDeepTyped(mergedCapabilities),
|
|
73
|
+
extensionPacks: sortDeepTyped(extensionPacks)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
export { enrichContract as t };
|
|
79
|
+
//# sourceMappingURL=contract-enrichment-CGW6mm-E.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-enrichment-CGW6mm-E.mjs","names":["next: Record<string, unknown>","out: CapabilityMatrix","caps: Record<string, boolean>","next: CapabilityMatrix","base: Record<string, unknown>","extensionPacksMeta: Record<string, unknown>"],"sources":["../src/control-api/contract-enrichment.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\n\ntype CapabilityMatrix = Record<string, Record<string, boolean>>;\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction sortDeep(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortDeep);\n }\n if (!isPlainObject(value)) {\n return value;\n }\n const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));\n const next: Record<string, unknown> = {};\n for (const [key, child] of entries) {\n next[key] = sortDeep(child);\n }\n return next;\n}\n\nfunction sortDeepTyped<T>(value: T): T {\n return sortDeep(value) as T;\n}\n\nfunction extractCapabilityMatrix(value: unknown): CapabilityMatrix {\n if (!isPlainObject(value)) return {};\n\n const out: CapabilityMatrix = {};\n for (const [namespace, maybeCaps] of Object.entries(value)) {\n if (!isPlainObject(maybeCaps)) continue;\n const caps: Record<string, boolean> = {};\n for (const [key, flag] of Object.entries(maybeCaps)) {\n if (typeof flag === 'boolean') {\n caps[key] = flag;\n }\n }\n if (Object.keys(caps).length > 0) {\n out[namespace] = caps;\n }\n }\n\n return out;\n}\n\nfunction mergeCapabilities(left: CapabilityMatrix, right: CapabilityMatrix): CapabilityMatrix {\n const next: CapabilityMatrix = { ...left };\n for (const [namespace, capabilities] of Object.entries(right)) {\n next[namespace] = {\n ...(left[namespace] ?? {}),\n ...capabilities,\n };\n }\n return next;\n}\n\nfunction extractExtensionPackMeta(\n component: TargetBoundComponentDescriptor<string, string>,\n): Record<string, unknown> {\n const { kind, id, version, capabilities, types } = component;\n const base: Record<string, unknown> = {\n kind,\n id,\n familyId: component.familyId,\n targetId: component.targetId,\n version,\n };\n if (capabilities) {\n base['capabilities'] = capabilities;\n }\n if (types) {\n if (types.codecTypes) {\n const { controlPlaneHooks: _, codecInstances: _ci, ...cleanedCodecTypes } = types.codecTypes;\n base['types'] = { ...types, codecTypes: cleanedCodecTypes };\n } else {\n base['types'] = types;\n }\n }\n return base;\n}\n\n/**\n * Enriches a raw contract with framework-derived metadata:\n * capabilities from all component descriptors and extension pack metadata\n * from extension descriptors. Produces deterministically sorted output.\n */\nexport function enrichContract(\n ir: Contract,\n components: ReadonlyArray<TargetBoundComponentDescriptor<string, string>>,\n): Contract {\n let mergedCapabilities = ir.capabilities;\n const extensionPacksMeta: Record<string, unknown> = {};\n\n for (const component of components) {\n if (component.capabilities) {\n mergedCapabilities = mergeCapabilities(\n mergedCapabilities,\n extractCapabilityMatrix(component.capabilities),\n );\n }\n if (component.kind === 'extension') {\n extensionPacksMeta[component.id] = extractExtensionPackMeta(component);\n }\n }\n\n const extensionPacks =\n Object.keys(extensionPacksMeta).length > 0\n ? { ...ir.extensionPacks, ...extensionPacksMeta }\n : ir.extensionPacks;\n\n return {\n ...ir,\n capabilities: sortDeepTyped(mergedCapabilities),\n extensionPacks: sortDeepTyped(extensionPacks),\n };\n}\n"],"mappings":";AAKA,SAAS,cAAc,OAAkD;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAS,SAAS,OAAyB;AACzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,SAAS;AAE5B,KAAI,CAAC,cAAc,MAAM,CACvB,QAAO;CAET,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;CAC5E,MAAMA,OAAgC,EAAE;AACxC,MAAK,MAAM,CAAC,KAAK,UAAU,QACzB,MAAK,OAAO,SAAS,MAAM;AAE7B,QAAO;;AAGT,SAAS,cAAiB,OAAa;AACrC,QAAO,SAAS,MAAM;;AAGxB,SAAS,wBAAwB,OAAkC;AACjE,KAAI,CAAC,cAAc,MAAM,CAAE,QAAO,EAAE;CAEpC,MAAMC,MAAwB,EAAE;AAChC,MAAK,MAAM,CAAC,WAAW,cAAc,OAAO,QAAQ,MAAM,EAAE;AAC1D,MAAI,CAAC,cAAc,UAAU,CAAE;EAC/B,MAAMC,OAAgC,EAAE;AACxC,OAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,UAAU,CACjD,KAAI,OAAO,SAAS,UAClB,MAAK,OAAO;AAGhB,MAAI,OAAO,KAAK,KAAK,CAAC,SAAS,EAC7B,KAAI,aAAa;;AAIrB,QAAO;;AAGT,SAAS,kBAAkB,MAAwB,OAA2C;CAC5F,MAAMC,OAAyB,EAAE,GAAG,MAAM;AAC1C,MAAK,MAAM,CAAC,WAAW,iBAAiB,OAAO,QAAQ,MAAM,CAC3D,MAAK,aAAa;EAChB,GAAI,KAAK,cAAc,EAAE;EACzB,GAAG;EACJ;AAEH,QAAO;;AAGT,SAAS,yBACP,WACyB;CACzB,MAAM,EAAE,MAAM,IAAI,SAAS,cAAc,UAAU;CACnD,MAAMC,OAAgC;EACpC;EACA;EACA,UAAU,UAAU;EACpB,UAAU,UAAU;EACpB;EACD;AACD,KAAI,aACF,MAAK,kBAAkB;AAEzB,KAAI,MACF,KAAI,MAAM,YAAY;EACpB,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,KAAK,GAAG,sBAAsB,MAAM;AAClF,OAAK,WAAW;GAAE,GAAG;GAAO,YAAY;GAAmB;OAE3D,MAAK,WAAW;AAGpB,QAAO;;;;;;;AAQT,SAAgB,eACd,IACA,YACU;CACV,IAAI,qBAAqB,GAAG;CAC5B,MAAMC,qBAA8C,EAAE;AAEtD,MAAK,MAAM,aAAa,YAAY;AAClC,MAAI,UAAU,aACZ,sBAAqB,kBACnB,oBACA,wBAAwB,UAAU,aAAa,CAChD;AAEH,MAAI,UAAU,SAAS,YACrB,oBAAmB,UAAU,MAAM,yBAAyB,UAAU;;CAI1E,MAAM,iBACJ,OAAO,KAAK,mBAAmB,CAAC,SAAS,IACrC;EAAE,GAAG,GAAG;EAAgB,GAAG;EAAoB,GAC/C,GAAG;AAET,QAAO;EACL,GAAG;EACH,cAAc,cAAc,mBAAmB;EAC/C,gBAAgB,cAAc,eAAe;EAC9C"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "./result-handler-oK_vA-Fn.mjs";
|
|
2
|
+
import { t as TerminalUI } from "./terminal-ui-C5k88MmW.mjs";
|
|
3
|
+
import { t as inspectLiveSchema } from "./inspect-live-schema-BYnhztxZ.mjs";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { notOk, ok } from "@prisma-next/utils/result";
|
|
7
|
+
import { dirname, relative, resolve } from "pathe";
|
|
8
|
+
import { errorRuntime } from "@prisma-next/errors/execution";
|
|
9
|
+
import { printPsl, validatePrintableSqlSchemaIR } from "@prisma-next/psl-printer";
|
|
10
|
+
import { createPostgresDefaultMapping, createPostgresTypeMap, extractEnumInfo, parseRawDefault } from "@prisma-next/psl-printer/postgres";
|
|
11
|
+
|
|
12
|
+
//#region src/commands/contract-infer-paths.ts
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the output path for the inferred PSL contract.
|
|
15
|
+
*
|
|
16
|
+
* Priority:
|
|
17
|
+
* 1. --output <path> flag (resolved relative to cwd)
|
|
18
|
+
* 2. contract.prisma next to config.contract.output
|
|
19
|
+
* 3. Canonical default: contract.prisma in the config directory
|
|
20
|
+
*/
|
|
21
|
+
function resolveContractInferOutputPath(options, contractOutput) {
|
|
22
|
+
const configDir = options.config ? dirname(resolve(process.cwd(), options.config)) : process.cwd();
|
|
23
|
+
if (options.output) return resolve(process.cwd(), options.output);
|
|
24
|
+
if (contractOutput) return resolve(dirname(resolve(configDir, contractOutput)), "contract.prisma");
|
|
25
|
+
return resolve(configDir, "contract.prisma");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/commands/contract-infer.ts
|
|
30
|
+
async function executeContractInferCommand(options, ui, startTime) {
|
|
31
|
+
const flags = parseGlobalFlags(options);
|
|
32
|
+
const inspectResult = await inspectLiveSchema(options, flags, ui, startTime, {
|
|
33
|
+
commandName: "contract infer",
|
|
34
|
+
description: "Infer a PSL contract from the live database schema",
|
|
35
|
+
url: "https://pris.ly/contract-infer"
|
|
36
|
+
});
|
|
37
|
+
if (!inspectResult.ok) return inspectResult;
|
|
38
|
+
const { config, target, meta } = inspectResult.value;
|
|
39
|
+
if (target.familyId !== "sql") return notOk(errorRuntime(`contract infer is not supported for family "${target.familyId}"`, {
|
|
40
|
+
why: "contract infer currently supports SQL targets only",
|
|
41
|
+
fix: "Use an SQL target (e.g. Postgres) with this command"
|
|
42
|
+
}));
|
|
43
|
+
const schema = validatePrintableSqlSchemaIR(inspectResult.value.schema);
|
|
44
|
+
const outputPath = resolveContractInferOutputPath(options, config.contract?.output);
|
|
45
|
+
const enumInfo = extractEnumInfo(schema.annotations);
|
|
46
|
+
const pslContent = printPsl(schema, {
|
|
47
|
+
defaultMapping: createPostgresDefaultMapping(),
|
|
48
|
+
typeMap: createPostgresTypeMap(enumInfo.typeNames),
|
|
49
|
+
enumInfo,
|
|
50
|
+
parseRawDefault
|
|
51
|
+
});
|
|
52
|
+
if (existsSync(outputPath) && !flags.json && !flags.quiet) ui.stderr(`\u26A0 Overwriting existing file: ${relative(process.cwd(), outputPath)}`);
|
|
53
|
+
mkdirSync(dirname(outputPath), { recursive: true });
|
|
54
|
+
writeFileSync(outputPath, pslContent, "utf-8");
|
|
55
|
+
const pslPath = relative(process.cwd(), outputPath);
|
|
56
|
+
if (!flags.json && !flags.quiet) ui.stderr(`\u2714 Contract written to ${pslPath}`);
|
|
57
|
+
return ok({
|
|
58
|
+
ok: true,
|
|
59
|
+
summary: "Contract inferred successfully",
|
|
60
|
+
target,
|
|
61
|
+
psl: { path: pslPath },
|
|
62
|
+
meta,
|
|
63
|
+
timings: { total: Date.now() - startTime }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function createContractInferCommand() {
|
|
67
|
+
const command = new Command("infer");
|
|
68
|
+
setCommandDescriptions(command, "Infer a PSL contract from the live database schema", "Reads the live database schema and writes an inferred PSL contract to disk.\nThis command stops at `contract.prisma`; follow it with `contract emit` and\n`db sign` as separate steps.");
|
|
69
|
+
setCommandExamples(command, [
|
|
70
|
+
"prisma-next contract infer --db $DATABASE_URL",
|
|
71
|
+
"prisma-next contract infer --db $DATABASE_URL --output ./prisma/contract.prisma",
|
|
72
|
+
"prisma-next contract infer --db $DATABASE_URL --json"
|
|
73
|
+
]);
|
|
74
|
+
addGlobalOptions(command).option("--db <url>", "Database connection string").option("--config <path>", "Path to prisma-next.config.ts").option("--output <path>", "Write the inferred PSL contract to the specified path").action(async (options) => {
|
|
75
|
+
const flags = parseGlobalFlags(options);
|
|
76
|
+
const ui = new TerminalUI({
|
|
77
|
+
color: flags.color,
|
|
78
|
+
interactive: flags.interactive
|
|
79
|
+
});
|
|
80
|
+
const exitCode = handleResult(await executeContractInferCommand(options, ui, Date.now()), flags, ui, (value) => {
|
|
81
|
+
if (flags.json) ui.output(JSON.stringify(value, null, 2));
|
|
82
|
+
});
|
|
83
|
+
process.exit(exitCode);
|
|
84
|
+
});
|
|
85
|
+
return command;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { createContractInferCommand as t };
|
|
90
|
+
//# sourceMappingURL=contract-infer-DozZT511.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-infer-DozZT511.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(exitC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