@prisma-next/cli 0.4.0-dev.9 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -18
- package/dist/agent-skill-mongo.md +63 -31
- package/dist/agent-skill-postgres.md +1 -1
- package/dist/cli-errors-BFYgBH3L.d.mts +4 -0
- package/dist/cli-errors-Cd79vmTH.mjs +5 -0
- package/dist/cli.mjs +127 -25
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-CJxHfhze.mjs → client-CrsnY58k.mjs} +9 -8
- package/dist/{client-CJxHfhze.mjs.map → client-CrsnY58k.mjs.map} +1 -1
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +7 -7
- package/dist/commands/contract-infer.mjs +8 -8
- package/dist/commands/db-init.mjs +8 -8
- package/dist/commands/db-schema.mjs +8 -8
- package/dist/commands/db-sign.mjs +8 -8
- package/dist/commands/db-update.mjs +8 -8
- package/dist/commands/db-verify.mjs +9 -9
- package/dist/commands/migration-apply.d.mts +1 -1
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +37 -28
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +48 -23
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +6 -1
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +94 -71
- package/dist/commands/migration-plan.mjs.map +1 -1
- package/dist/commands/migration-ref.d.mts +6 -4
- package/dist/commands/migration-ref.d.mts.map +1 -1
- package/dist/commands/migration-ref.mjs +29 -34
- package/dist/commands/migration-ref.mjs.map +1 -1
- package/dist/commands/migration-show.d.mts +2 -2
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +11 -16
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +4 -5
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +7 -7
- package/dist/config-loader-C25b63rJ.mjs +90 -0
- package/dist/config-loader-C25b63rJ.mjs.map +1 -0
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/contract-emit-DxgyXrqV.mjs +6 -0
- package/dist/{contract-emit-gpJNLGs7.mjs → contract-emit-NJ01hiiv.mjs} +20 -16
- package/dist/contract-emit-NJ01hiiv.mjs.map +1 -0
- package/dist/{contract-emit-CKig_Lra.mjs → contract-emit-V5SSitUT.mjs} +25 -21
- package/dist/contract-emit-V5SSitUT.mjs.map +1 -0
- package/dist/{contract-enrichment-CGW6mm-E.mjs → contract-enrichment-CAOELa-H.mjs} +1 -1
- package/dist/{contract-enrichment-CGW6mm-E.mjs.map → contract-enrichment-CAOELa-H.mjs.map} +1 -1
- package/dist/{contract-infer-BDJgg7Xb.mjs → contract-infer-D9cC3rJm.mjs} +4 -4
- package/dist/{contract-infer-BDJgg7Xb.mjs.map → contract-infer-D9cC3rJm.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +2 -2
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +6 -6
- package/dist/exports/index.mjs +7 -7
- package/dist/exports/init-output.d.mts +39 -0
- package/dist/exports/init-output.d.mts.map +1 -0
- package/dist/exports/init-output.mjs +3 -0
- package/dist/{extract-operation-statements-DZUJNmL3.mjs → extract-operation-statements-DsFfxXVZ.mjs} +2 -2
- package/dist/{extract-operation-statements-DZUJNmL3.mjs.map → extract-operation-statements-DsFfxXVZ.mjs.map} +1 -1
- package/dist/{extract-sql-ddl-DDMX-9mz.mjs → extract-sql-ddl-D9UbZDyz.mjs} +1 -1
- package/dist/{extract-sql-ddl-DDMX-9mz.mjs.map → extract-sql-ddl-D9UbZDyz.mjs.map} +1 -1
- package/dist/{framework-components-Bsr1GaIj.mjs → framework-components-Cr--XBKy.mjs} +2 -2
- package/dist/{framework-components-Bsr1GaIj.mjs.map → framework-components-Cr--XBKy.mjs.map} +1 -1
- package/dist/init-m8x0UoPY.mjs +2062 -0
- package/dist/init-m8x0UoPY.mjs.map +1 -0
- package/dist/{inspect-live-schema-ChqrALmw.mjs → inspect-live-schema-yrHAvG71.mjs} +6 -6
- package/dist/{inspect-live-schema-ChqrALmw.mjs.map → inspect-live-schema-yrHAvG71.mjs.map} +1 -1
- package/dist/migration-cli.d.mts +50 -0
- package/dist/migration-cli.d.mts.map +1 -0
- package/dist/migration-cli.mjs +184 -0
- package/dist/migration-cli.mjs.map +1 -0
- package/dist/{migration-command-scaffold-B0oH_hyB.mjs → migration-command-scaffold-B3B09et6.mjs} +7 -7
- package/dist/{migration-command-scaffold-B0oH_hyB.mjs.map → migration-command-scaffold-B3B09et6.mjs.map} +1 -1
- package/dist/{migration-status-CPamfEPj.mjs → migration-status-DUMiH8_G.mjs} +25 -43
- package/dist/migration-status-DUMiH8_G.mjs.map +1 -0
- package/dist/{migrations-BIsjFjSV.mjs → migrations-Bo5WtTla.mjs} +4 -15
- package/dist/migrations-Bo5WtTla.mjs.map +1 -0
- package/dist/output-BpcQrnnq.mjs +103 -0
- package/dist/output-BpcQrnnq.mjs.map +1 -0
- package/dist/{progress-adapter-B-YvmcDu.mjs → progress-adapter-DvQWB1nK.mjs} +1 -1
- package/dist/{progress-adapter-B-YvmcDu.mjs.map → progress-adapter-DvQWB1nK.mjs.map} +1 -1
- package/dist/quick-reference-mongo.md +34 -13
- package/dist/quick-reference-postgres.md +11 -9
- package/dist/{result-handler-AFK4hxyX.mjs → result-handler-Ba3zWQsI.mjs} +26 -88
- package/dist/result-handler-Ba3zWQsI.mjs.map +1 -0
- package/dist/{terminal-ui-C5k88MmW.mjs → terminal-ui-C3ZLwQxK.mjs} +76 -2
- package/dist/terminal-ui-C3ZLwQxK.mjs.map +1 -0
- package/dist/{validate-contract-deps-DBH6iTAD.mjs → validate-contract-deps-B_Cs29TL.mjs} +1 -1
- package/dist/{validate-contract-deps-DBH6iTAD.mjs.map → validate-contract-deps-B_Cs29TL.mjs.map} +1 -1
- package/dist/{verify-C56CuQc7.mjs → verify-Bkycc-Tf.mjs} +2 -2
- package/dist/{verify-C56CuQc7.mjs.map → verify-Bkycc-Tf.mjs.map} +1 -1
- package/package.json +24 -19
- package/src/cli.ts +1 -5
- package/src/commands/contract-emit.ts +9 -10
- package/src/commands/init/detect-pnpm-catalog.ts +141 -0
- package/src/commands/init/errors.ts +254 -0
- package/src/commands/init/exit-codes.ts +62 -0
- package/src/commands/init/hygiene-gitattributes.ts +97 -0
- package/src/commands/init/hygiene-gitignore.ts +48 -0
- package/src/commands/init/hygiene-package-scripts.ts +91 -0
- package/src/commands/init/index.ts +112 -7
- package/src/commands/init/init.ts +766 -144
- package/src/commands/init/inputs.ts +421 -0
- package/src/commands/init/output.ts +147 -0
- package/src/commands/init/probe-db.ts +308 -0
- package/src/commands/init/reinit-cleanup.ts +83 -0
- package/src/commands/init/templates/agent-skill-mongo.md +63 -31
- package/src/commands/init/templates/agent-skill-postgres.md +1 -1
- package/src/commands/init/templates/agent-skill.ts +25 -3
- package/src/commands/init/templates/code-templates.ts +125 -32
- package/src/commands/init/templates/env.ts +80 -0
- package/src/commands/init/templates/quick-reference-mongo.md +34 -13
- package/src/commands/init/templates/quick-reference-postgres.md +11 -9
- package/src/commands/init/templates/quick-reference.ts +42 -3
- package/src/commands/init/templates/tsconfig.ts +167 -5
- package/src/commands/migration-apply.ts +37 -26
- package/src/commands/migration-new.ts +39 -17
- package/src/commands/migration-plan.ts +119 -104
- package/src/commands/migration-ref.ts +32 -47
- package/src/commands/migration-show.ts +6 -16
- package/src/commands/migration-status.ts +30 -55
- package/src/config-loader.ts +35 -29
- package/src/config-path-validation.ts +75 -0
- package/src/control-api/client.ts +2 -1
- package/src/control-api/operations/contract-emit.ts +24 -23
- package/src/control-api/types.ts +1 -1
- package/src/exports/init-output.ts +10 -0
- package/src/migration-cli.ts +254 -0
- package/src/utils/cli-errors.ts +1 -0
- package/src/utils/command-helpers.ts +18 -22
- package/src/utils/formatters/graph-migration-mapper.ts +5 -14
- package/src/utils/formatters/help.ts +0 -1
- package/src/utils/formatters/migrations.ts +2 -29
- package/dist/cli-errors-BUuJr6py.mjs +0 -5
- package/dist/cli-errors-Dic2eADK.d.mts +0 -4
- package/dist/commands/migration-emit.d.mts +0 -38
- package/dist/commands/migration-emit.d.mts.map +0 -1
- package/dist/commands/migration-emit.mjs +0 -81
- package/dist/commands/migration-emit.mjs.map +0 -1
- package/dist/config-loader-C4VXKl8f.mjs +0 -43
- package/dist/config-loader-C4VXKl8f.mjs.map +0 -1
- package/dist/contract-emit-CKig_Lra.mjs.map +0 -1
- package/dist/contract-emit-CU-SYNe4.mjs +0 -6
- package/dist/contract-emit-gpJNLGs7.mjs.map +0 -1
- package/dist/init-DZWvhEP0.mjs +0 -430
- package/dist/init-DZWvhEP0.mjs.map +0 -1
- package/dist/migration-emit-Du4DBMqz.mjs +0 -125
- package/dist/migration-emit-Du4DBMqz.mjs.map +0 -1
- package/dist/migration-status-CPamfEPj.mjs.map +0 -1
- package/dist/migrations-BIsjFjSV.mjs.map +0 -1
- package/dist/result-handler-AFK4hxyX.mjs.map +0 -1
- package/dist/terminal-ui-C5k88MmW.mjs.map +0 -1
- package/src/commands/migration-emit.ts +0 -134
- package/src/lib/migration-emit.ts +0 -125
- package/src/lib/migration-strategy.ts +0 -49
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as loadConfig } from "./config-loader-
|
|
2
|
-
import {
|
|
3
|
-
import { t as assertFrameworkComponentsCompatible } from "./framework-components-
|
|
4
|
-
import { t as enrichContract } from "./contract-enrichment-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { createControlStack } from "@prisma-next/framework-components/control";
|
|
1
|
+
import { t as loadConfig } from "./config-loader-C25b63rJ.mjs";
|
|
2
|
+
import { i as errorContractConfigMissing, m as errorRuntime } from "./cli-errors-Cd79vmTH.mjs";
|
|
3
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-Cr--XBKy.mjs";
|
|
4
|
+
import { t as enrichContract } from "./contract-enrichment-CAOELa-H.mjs";
|
|
5
|
+
import { emit, getEmittedArtifactPaths } from "@prisma-next/emitter";
|
|
6
|
+
import { dirname } from "pathe";
|
|
8
7
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
8
|
+
import { createControlStack } from "@prisma-next/framework-components/control";
|
|
9
9
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
10
10
|
import { abortable } from "@prisma-next/utils/abortable";
|
|
11
11
|
|
|
@@ -43,40 +43,44 @@ async function executeContractEmit(options) {
|
|
|
43
43
|
if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
|
|
44
44
|
const contractConfig = config.contract;
|
|
45
45
|
if (!contractConfig.output) throw errorContractConfigMissing({ why: "Contract config must have output path. This should not happen if defineConfig() was used." });
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
if (typeof contractConfig.source?.load !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider object" });
|
|
47
|
+
let outputPaths;
|
|
48
|
+
try {
|
|
49
|
+
outputPaths = getEmittedArtifactPaths(contractConfig.output);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw errorContractConfigMissing({ why: error instanceof Error ? error.message : String(error) });
|
|
52
|
+
}
|
|
53
|
+
const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;
|
|
51
54
|
const stack = createControlStack(config);
|
|
52
55
|
const sourceContext = {
|
|
53
56
|
composedExtensionPacks: stack.extensionPacks.map((p) => p.id),
|
|
54
57
|
scalarTypeDescriptors: stack.scalarTypeDescriptors,
|
|
55
58
|
authoringContributions: stack.authoringContributions,
|
|
56
59
|
codecLookup: stack.codecLookup,
|
|
57
|
-
controlMutationDefaults: stack.controlMutationDefaults
|
|
60
|
+
controlMutationDefaults: stack.controlMutationDefaults,
|
|
61
|
+
resolvedInputs: contractConfig.source.inputs ?? []
|
|
58
62
|
};
|
|
59
63
|
let providerResult;
|
|
60
64
|
try {
|
|
61
|
-
providerResult = await unlessAborted(contractConfig.source(sourceContext));
|
|
65
|
+
providerResult = await unlessAborted(contractConfig.source.load(sourceContext));
|
|
62
66
|
} catch (error) {
|
|
63
67
|
if (signal.aborted || isAbortError(error)) throw error;
|
|
64
68
|
throw errorRuntime("Failed to resolve contract source", {
|
|
65
69
|
why: error instanceof Error ? error.message : String(error),
|
|
66
|
-
fix: "Ensure contract.source resolves to ok(Contract) or returns structured diagnostics."
|
|
70
|
+
fix: "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics."
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
73
|
if (!isRecord(providerResult) || typeof providerResult.ok !== "boolean") throw errorRuntime("Failed to resolve contract source", {
|
|
70
74
|
why: "Contract source provider returned malformed result shape.",
|
|
71
|
-
fix: "Ensure contract.source resolves to ok(Contract) or notOk({ summary, diagnostics })."
|
|
75
|
+
fix: "Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics })."
|
|
72
76
|
});
|
|
73
77
|
if (providerResult.ok && !("value" in providerResult)) throw errorRuntime("Failed to resolve contract source", {
|
|
74
78
|
why: "Contract source provider returned malformed success result: missing value.",
|
|
75
|
-
fix: "Ensure contract.source success payload is ok(Contract)."
|
|
79
|
+
fix: "Ensure contract.source.load success payload is ok(Contract)."
|
|
76
80
|
});
|
|
77
81
|
if (!providerResult.ok && !isProviderFailureLike(providerResult.failure)) throw errorRuntime("Failed to resolve contract source", {
|
|
78
82
|
why: "Contract source provider returned malformed failure result: expected summary and diagnostics.",
|
|
79
|
-
fix: "Ensure contract.source failure payload is notOk({ summary, diagnostics, meta? })."
|
|
83
|
+
fix: "Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? })."
|
|
80
84
|
});
|
|
81
85
|
if (!providerResult.ok) throw errorRuntime("Failed to resolve contract source", {
|
|
82
86
|
why: providerResult.failure.summary,
|
|
@@ -95,11 +99,11 @@ async function executeContractEmit(options) {
|
|
|
95
99
|
const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, rawComponents);
|
|
96
100
|
const enrichedIR = enrichContract(providerResult.value, frameworkComponents);
|
|
97
101
|
familyInstance.validateContract(enrichedIR);
|
|
98
|
-
const emitResult = await unlessAborted(emit(enrichedIR, stack, config.family.emission));
|
|
102
|
+
const emitResult = await unlessAborted(emit(enrichedIR, stack, config.family.emission, { outputJsonPath }));
|
|
99
103
|
await unlessAborted(mkdir(dirname(outputJsonPath), { recursive: true }));
|
|
100
104
|
await unlessAborted(writeFile(outputJsonPath, emitResult.contractJson, "utf-8"));
|
|
101
105
|
await unlessAborted(writeFile(outputDtsPath, emitResult.contractDts, "utf-8"));
|
|
102
|
-
const { validateContractDeps } = await import("./validate-contract-deps-
|
|
106
|
+
const { validateContractDeps } = await import("./validate-contract-deps-B_Cs29TL.mjs");
|
|
103
107
|
const depsValidation = validateContractDeps(emitResult.contractDts, dirname(outputDtsPath));
|
|
104
108
|
if (depsValidation.warning) process.stderr.write(`\n⚠ ${depsValidation.warning}\n`);
|
|
105
109
|
return {
|
|
@@ -115,4 +119,4 @@ async function executeContractEmit(options) {
|
|
|
115
119
|
|
|
116
120
|
//#endregion
|
|
117
121
|
export { executeContractEmit as t };
|
|
118
|
-
//# sourceMappingURL=contract-emit-
|
|
122
|
+
//# sourceMappingURL=contract-emit-V5SSitUT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-emit-V5SSitUT.mjs","names":["outputPaths: ReturnType<typeof getEmittedArtifactPaths>","providerResult: Awaited<ReturnType<typeof contractConfig.source.load>>"],"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, getEmittedArtifactPaths } 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 } 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\n // Validate source exists and is callable\n if (typeof contractConfig.source?.load !== 'function') {\n throw errorContractConfigMissing({\n why: 'Contract config must include a valid source provider object',\n });\n }\n\n let outputPaths: ReturnType<typeof getEmittedArtifactPaths>;\n try {\n outputPaths = getEmittedArtifactPaths(contractConfig.output);\n } catch (error) {\n throw errorContractConfigMissing({\n why: error instanceof Error ? error.message : String(error),\n });\n }\n const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;\n\n const stack = createControlStack(config);\n\n const sourceContext = {\n composedExtensionPacks: stack.extensionPacks.map((p) => p.id),\n scalarTypeDescriptors: stack.scalarTypeDescriptors,\n authoringContributions: stack.authoringContributions,\n codecLookup: stack.codecLookup,\n controlMutationDefaults: stack.controlMutationDefaults,\n resolvedInputs: contractConfig.source.inputs ?? [],\n };\n\n let providerResult: Awaited<ReturnType<typeof contractConfig.source.load>>;\n try {\n providerResult = await unlessAborted(contractConfig.source.load(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.load 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.load 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.load 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.load 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 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(\n emit(enrichedIR, stack, config.family.emission, {\n outputJsonPath: outputJsonPath,\n }),\n );\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,e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AAW,cAAc;EACvD,aAAa,WAAW;EACxB,OAAO;GACL,MAAM;GACN,KAAK;GACN;EACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-enrichment-
|
|
1
|
+
{"version":3,"file":"contract-enrichment-CAOELa-H.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,EA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A8C,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as inspectLiveSchema } from "./inspect-live-schema-
|
|
1
|
+
import { t as TerminalUI } from "./terminal-ui-C3ZLwQxK.mjs";
|
|
2
|
+
import { d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "./result-handler-Ba3zWQsI.mjs";
|
|
3
|
+
import { t as inspectLiveSchema } from "./inspect-live-schema-yrHAvG71.mjs";
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
@@ -87,4 +87,4 @@ function createContractInferCommand() {
|
|
|
87
87
|
|
|
88
88
|
//#endregion
|
|
89
89
|
export { createContractInferCommand as t };
|
|
90
|
-
//# sourceMappingURL=contract-infer-
|
|
90
|
+
//# sourceMappingURL=contract-infer-D9cC3rJm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-infer-
|
|
1
|
+
{"version":3,"file":"contract-infer-D9cC3rJm.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,QAAO,QAAQ,WAAW,kBAAkB;;;;;ACe9C,eAAe,4BACb,SACA,IACA,WACiE;CACjE,MAAM,QAAQ,iBAAiB,QAAQ;CACvC,MAAM,gBAAgB,MAAM,kBAAkB,SAAS,OAAO,IAAI,WAAW;EAC3E,aAAa;EACb,aAAa;EACb,KAAK;EACN,CAAC;AAEF,KAAI,CAAC,cAAc,GACjB,QAAO;CAGT,MAAM,EAAE,QAAQ,QAAQ,SAAS,cAAc;AAE/C,KAAI,OAAO,aAAa,MACtB,QAAO,MACL,aAAa,+CAA+C,OAAO,SAAS,IAAI;EAC9E,KAAK;EACL,KAAK;EACN,CAAC,CACH;CAGH,MAAM,SAAS,6BAA6B,cAAc,MAAM,OAAO;CACvE,MAAM,aAAa,+BAA+B,SAAS,OAAO,UAAU,OAAO;CACnF,MAAM,WAAW,gBAAgB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|
1
1
|
import { Result } from "@prisma-next/utils/result";
|
|
2
|
+
import { ContractSourceDiagnostics, ContractSourceProvider } from "@prisma-next/config/config-types";
|
|
2
3
|
import { ControlAdapterDescriptor, ControlDriverDescriptor, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlStack, ControlTargetDescriptor, CoreSchemaView, MigrationPlanOperation, MigrationPlannerConflict, SignDatabaseResult, SignDatabaseResult as SignDatabaseResult$1, VerifyDatabaseResult, VerifyDatabaseResult as VerifyDatabaseResult$1, VerifyDatabaseSchemaResult, VerifyDatabaseSchemaResult as VerifyDatabaseSchemaResult$1 } from "@prisma-next/framework-components/control";
|
|
3
4
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
4
|
-
import { ContractSourceDiagnostics, ContractSourceProvider } from "@prisma-next/config/config-types";
|
|
5
5
|
import { Contract, ContractMarkerRecord } from "@prisma-next/contract/types";
|
|
6
6
|
|
|
7
7
|
//#region src/control-api/types.d.ts
|
|
@@ -199,7 +199,7 @@ interface EmitContractConfig {
|
|
|
199
199
|
/**
|
|
200
200
|
* Contract source provider.
|
|
201
201
|
*/
|
|
202
|
-
readonly
|
|
202
|
+
readonly source: ContractSourceProvider;
|
|
203
203
|
/**
|
|
204
204
|
* Output path for contract.json.
|
|
205
205
|
* The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-api.d.mts","names":[],"sources":["../../src/control-api/types.ts","../../src/control-api/client.ts","../../src/control-api/contract-enrichment.ts","../../src/control-api/operations/contract-emit.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAmCA;;;;;;;;AA2BY,UA3BK,oBAAA,CA2BY;EAuBjB,SAAA,MAAA,EAhDO,uBAkDI,CAAA,GAAA,EAAA,GAAA,CAAA;EAkBX,SAAA,MAAA,EAlEO,uBAkEqB,CAAA,GAAA,EAAA,GAAA,EAAA,GAAoB,CAAA;EAS3C,SAAA,OAAa,EAz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,SAAA,MAAA,CAAA,EAAA,OAAA;EAAR;;;;;EAmBlB,SAAA,UAAA,CAAA,EAAA,OAAA;EAaU;EAAgC,SAAA,UAAA,CAAA,EA7flC,iBA6fkC;;;;;AA0B1C,UAjhBC,WAAA,CAihBD;EAAsB;EAAR,SAAA,QAAA,EAAA,OAAA;EAAO;;;;ECnnBrB;;;;ECmCA;;;;;EAGL,SAAA,UAAA,CAAA,EAAA,OAAA;;wBF8Ea;;AGxHxB;;;AAEG,UH4Hc,aAAA,CG5Hd;EAAO;;;;;;;;;;;;;;;wBH4Ic;;;;;UAMP,eAAA;;;;;;;;;;;;;;;;;;;;;;;;wBAwBO;;;;;UAMP,iBAAA;;;;;;;;;;;;wBAYO;;;;;UAMP,kBAAA;;;;
|
|
1
|
+
{"version":3,"file":"control-api.d.mts","names":[],"sources":["../../src/control-api/types.ts","../../src/control-api/client.ts","../../src/control-api/contract-enrichment.ts","../../src/control-api/operations/contract-emit.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAmCA;;;;;;;;AA2BY,UA3BK,oBAAA,CA2BY;EAuBjB,SAAA,MAAA,EAhDO,uBAkDI,CAAA,GAAA,EAAA,GAAA,CAAA;EAkBX,SAAA,MAAA,EAlEO,uBAkEqB,CAAA,GAAA,EAAA,GAAA,EAAA,GAAoB,CAAA;EAS3C,SAAA,OAAa,EAzEV,wBAmFI,CAAA,GAAiB,EAAA,GAAA,EAAA,GAAA,CAAA;EAMxB;EAsBA,SAAA,MAAW,CAAA,EA5GR,uBA8HI,CAAA,GAAiB,EAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA;EAMxB,SAAA,cAAa,CAAA,EAlIF,aAkJJ,CAlJkB,0BAkJD,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,CAAA;EAMxB;AA8BjB;AAkBA;AAeA;AAgBA;EA4BY,SAAA,UAAA,CAAiB,EAAA,OAAA;AAK7B;;;;AAKiB,KA7PL,iBAAA,GA6PK,QAAA,GAAA,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AAQ;;;;;;;;;;AAtoBtC;;;;AASoB,iBCUJ,mBAAA,CDVI,OAAA,ECUyB,oBDVzB,CAAA,ECUgD,aDVhD;;;;;;;;AATH,iBEsDD,cAAA,CFtDqB,EAAA,EEuD/B,QFvD+B,EAAA,UAAA,EEwDvB,aFxDuB,CEwDT,8BFxDS,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA,CAAA,EEyDlC,QFzDkC;;;;;;;;;AAArC;;;;;;;;AA2BA;AAuBA;AAoBA;AASiB,iBGhEK,mBAAA,CH0EE,OAAiB,EGzE9B,mBHyE8B,CAAA,EGxEtC,OHwEsC,CGxE9B,kBHwE8B,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../config-loader-
|
|
2
|
-
import "../cli-errors-
|
|
3
|
-
import "../framework-components-
|
|
4
|
-
import { t as enrichContract } from "../contract-enrichment-
|
|
5
|
-
import { t as createControlClient } from "../client-
|
|
6
|
-
import { t as executeContractEmit } from "../contract-emit-
|
|
1
|
+
import "../config-loader-C25b63rJ.mjs";
|
|
2
|
+
import "../cli-errors-Cd79vmTH.mjs";
|
|
3
|
+
import "../framework-components-Cr--XBKy.mjs";
|
|
4
|
+
import { t as enrichContract } from "../contract-enrichment-CAOELa-H.mjs";
|
|
5
|
+
import { t as createControlClient } from "../client-CrsnY58k.mjs";
|
|
6
|
+
import { t as executeContractEmit } from "../contract-emit-V5SSitUT.mjs";
|
|
7
7
|
|
|
8
8
|
export { createControlClient, enrichContract, executeContractEmit };
|
package/dist/exports/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../config-loader-
|
|
2
|
-
import "../cli-errors-
|
|
3
|
-
import "../framework-components-
|
|
4
|
-
import "../client-
|
|
5
|
-
import "../
|
|
6
|
-
import
|
|
7
|
-
import "../
|
|
1
|
+
import "../config-loader-C25b63rJ.mjs";
|
|
2
|
+
import "../cli-errors-Cd79vmTH.mjs";
|
|
3
|
+
import "../framework-components-Cr--XBKy.mjs";
|
|
4
|
+
import "../client-CrsnY58k.mjs";
|
|
5
|
+
import "../terminal-ui-C3ZLwQxK.mjs";
|
|
6
|
+
import "../result-handler-Ba3zWQsI.mjs";
|
|
7
|
+
import { t as createContractEmitCommand } from "../contract-emit-NJ01hiiv.mjs";
|
|
8
8
|
import { existsSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { join } from "pathe";
|
|
10
10
|
import { tmpdir } from "node:os";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "@clack/prompts";
|
|
2
|
+
import * as arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
|
|
3
|
+
|
|
4
|
+
//#region src/commands/init/output.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* arktype schema for the structured success document `init --json` writes
|
|
8
|
+
* to stdout (FR1.5). The same shape backs the human-readable outro
|
|
9
|
+
* renderer (FR10), so the two output modes carry identical information.
|
|
10
|
+
*
|
|
11
|
+
* `target` is normalised to the user-facing flag value (`mongodb` rather
|
|
12
|
+
* than the internal `mongo`) so consumers can round-trip the document
|
|
13
|
+
* straight into a follow-up `--target` invocation.
|
|
14
|
+
*
|
|
15
|
+
* The `ok: true` literal is the documented success/error discriminator —
|
|
16
|
+
* see [Style Guide § JSON Semantics](../../../../../../../docs/CLI%20Style%20Guide.md#json-semantics).
|
|
17
|
+
* Error envelopes (`CliErrorEnvelope`) carry `ok: false` so consumers can
|
|
18
|
+
* branch with `if (doc.ok)` without inspecting the rest of the structure.
|
|
19
|
+
*/
|
|
20
|
+
declare const InitOutputSchema: arktype_internal_variants_object_ts0.ObjectType<{
|
|
21
|
+
ok: true;
|
|
22
|
+
target: "postgres" | "mongodb";
|
|
23
|
+
authoring: "psl" | "typescript";
|
|
24
|
+
schemaPath: string;
|
|
25
|
+
filesWritten: string[];
|
|
26
|
+
filesDeleted: string[];
|
|
27
|
+
packagesInstalled: {
|
|
28
|
+
skipped: boolean;
|
|
29
|
+
deps: string[];
|
|
30
|
+
devDeps: string[];
|
|
31
|
+
};
|
|
32
|
+
contractEmitted: boolean;
|
|
33
|
+
nextSteps: string[];
|
|
34
|
+
warnings: string[];
|
|
35
|
+
}, {}>;
|
|
36
|
+
type InitOutput = typeof InitOutputSchema.infer;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { type InitOutput, InitOutputSchema };
|
|
39
|
+
//# sourceMappingURL=init-output.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-output.d.mts","names":[],"sources":["../../src/commands/init/output.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkBA;AAwBA;;;;;;;;;;;cAxBa,kBAsBX,oCAAA,CAtB2B;;;;;;;;;;;;;;;;KAwBjB,UAAA,UAAoB,gBAAA,CAAiB"}
|
package/dist/{extract-operation-statements-DZUJNmL3.mjs → extract-operation-statements-DsFfxXVZ.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as extractSqlDdl } from "./extract-sql-ddl-
|
|
1
|
+
import { t as extractSqlDdl } from "./extract-sql-ddl-D9UbZDyz.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/control-api/operations/extract-operation-statements.ts
|
|
4
4
|
function extractOperationStatements(familyId, operations) {
|
|
@@ -10,4 +10,4 @@ function extractOperationStatements(familyId, operations) {
|
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
export { extractOperationStatements as t };
|
|
13
|
-
//# sourceMappingURL=extract-operation-statements-
|
|
13
|
+
//# sourceMappingURL=extract-operation-statements-DsFfxXVZ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-operation-statements-
|
|
1
|
+
{"version":3,"file":"extract-operation-statements-DsFfxXVZ.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-sql-ddl-
|
|
1
|
+
{"version":3,"file":"extract-sql-ddl-D9UbZDyz.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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as errorConfigValidation } from "./cli-errors-
|
|
1
|
+
import { r as errorConfigValidation } from "./cli-errors-Cd79vmTH.mjs";
|
|
2
2
|
import "@prisma-next/framework-components/components";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/framework-components.ts
|
|
@@ -56,4 +56,4 @@ function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId,
|
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
58
|
export { assertFrameworkComponentsCompatible as t };
|
|
59
|
-
//# sourceMappingURL=framework-components-
|
|
59
|
+
//# sourceMappingURL=framework-components-Cr--XBKy.mjs.map
|
package/dist/{framework-components-Bsr1GaIj.mjs.map → framework-components-Cr--XBKy.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-components-
|
|
1
|
+
{"version":3,"file":"framework-components-Cr--XBKy.mjs","names":[],"sources":["../src/utils/framework-components.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n checkContractComponentRequirements,\n type TargetBoundComponentDescriptor,\n} from '@prisma-next/framework-components/components';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { errorConfigValidation, errorContractMissingExtensionPacks } from './cli-errors';\n\n/**\n * Asserts that all framework components are compatible with the expected family and target.\n *\n * This function validates that each component in the framework components array:\n * - Has kind 'target', 'adapter', 'extension', or 'driver'\n * - Has familyId matching expectedFamilyId\n * - Has targetId matching expectedTargetId\n *\n * This validation happens at the CLI composition boundary, before passing components\n * to typed planner/runner instances. It fills the gap between runtime validation\n * (via `validateConfig()`) and compile-time type enforcement.\n *\n * @param expectedFamilyId - The expected family ID (e.g., 'sql')\n * @param expectedTargetId - The expected target ID (e.g., 'postgres')\n * @param frameworkComponents - Array of framework components to validate\n * @returns The same array typed as TargetBoundComponentDescriptor\n * @throws CliStructuredError if any component is incompatible\n *\n * @example\n * ```ts\n * const config = await loadConfig();\n * const frameworkComponents = [config.target, config.adapter, ...(config.extensionPacks ?? [])];\n *\n * // Validate and type-narrow components before passing to planner\n * const typedComponents = assertFrameworkComponentsCompatible(\n * config.family.familyId,\n * config.target.targetId,\n * frameworkComponents\n * );\n *\n * const planner = target.migrations.createPlanner(familyInstance);\n * planner.plan({ contract, schema, policy, frameworkComponents: typedComponents });\n * ```\n */\nexport function assertFrameworkComponentsCompatible<\n TFamilyId extends string,\n TTargetId extends string,\n>(\n expectedFamilyId: TFamilyId,\n expectedTargetId: TTargetId,\n frameworkComponents: ReadonlyArray<unknown>,\n): ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>> {\n for (let i = 0; i < frameworkComponents.length; i++) {\n const component = frameworkComponents[i];\n\n // Check that component is an object\n if (typeof component !== 'object' || component === null) {\n throw errorConfigValidation('frameworkComponents[]', {\n why: `Framework component at index ${i} must be an object`,\n });\n }\n\n const record = component as Record<string, unknown>;\n\n // Check kind\n if (!Object.hasOwn(record, 'kind')) {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} must have 'kind' property`,\n });\n }\n\n const kind = record['kind'];\n if (kind !== 'target' && kind !== 'adapter' && kind !== 'extension' && kind !== 'driver') {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`,\n });\n }\n\n // Check familyId\n if (!Object.hasOwn(record, 'familyId')) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`,\n });\n }\n\n const familyId = record['familyId'];\n if (familyId !== expectedFamilyId) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`,\n });\n }\n\n // Check targetId\n if (!Object.hasOwn(record, 'targetId')) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`,\n });\n }\n\n const targetId = record['targetId'];\n if (targetId !== expectedTargetId) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`,\n });\n }\n }\n\n // Type assertion is safe because we've validated all components above\n return frameworkComponents as ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;\n}\n\n/**\n * Validates that a contract is compatible with the configured target, adapter,\n * and extension packs. Throws on family/target mismatches or missing extension packs.\n *\n * This check ensures the emitted contract matches the CLI config before running\n * commands that depend on the contract (e.g., db verify, db sign).\n *\n * @param contract - The contract to validate (must include targetFamily, target, extensionPacks).\n * @param stack - The control plane stack (target, adapter, driver, extensionPacks).\n *\n * @throws {CliStructuredError} errorConfigValidation when contract.targetFamily or contract.target\n * doesn't match the configured family/target.\n * @throws {CliStructuredError} errorContractMissingExtensionPacks when the contract requires\n * extension packs that are not provided in the config (includes all missing packs in error.meta).\n *\n * @example\n * ```ts\n * import { assertContractRequirementsSatisfied } from './framework-components';\n *\n * const config = await loadConfig();\n * const contract = await loadContractJson(config.contract.output);\n * const stack = createControlStack({ family: config.family, target: config.target, adapter: config.adapter, ... });\n *\n * // Throws if contract is incompatible with config\n * assertContractRequirementsSatisfied({ contract, stack });\n * ```\n */\nexport function assertContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n stack,\n}: {\n readonly contract: Pick<Contract, 'targetFamily' | 'target' | 'extensionPacks'>;\n readonly stack: ControlStack<TFamilyId, TTargetId>;\n}): void {\n const providedComponentIds = new Set<string>([\n stack.target.id,\n ...(stack.adapter ? [stack.adapter.id] : []),\n ]);\n for (const extension of stack.extensionPacks) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetFamily: stack.target.familyId,\n expectedTargetId: stack.target.targetId,\n providedComponentIds,\n });\n\n if (result.familyMismatch) {\n throw errorConfigValidation('contract.targetFamily', {\n why: `Contract was emitted for family '${result.familyMismatch.actual}' but CLI config is wired to '${result.familyMismatch.expected}'.`,\n });\n }\n\n if (result.targetMismatch) {\n throw errorConfigValidation('contract.target', {\n why: `Contract target '${result.targetMismatch.actual}' does not match CLI target '${result.targetMismatch.expected}'.`,\n });\n }\n\n if (result.missingExtensionPackIds.length > 0) {\n throw errorContractMissingExtensionPacks({\n missingExtensionPacks: result.missingExtensionPackIds,\n providedComponentIds: [...providedComponentIds],\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,oCAId,kBACA,kBACA,qBACqE;AACrE,MAAK,IAAI,IAAI,GAAG,IAAI,oBAAoB,QAAQ,KAAK;EACnD,MAAM,YAAY,oBAAoB;AAGtC,MAAI,OAAO,cAAc,YAAY,cAAc,KACjD,OAAM,sBAAsB,yBAAyB,EACnD,KAAK,gCAAgC,EAAE,qBACxC,CAAC;EAGJ,MAAM,SAAS;AAGf,MAAI,CAAC,OAAO,OAAO,QAAQ,OAAO,C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