@prisma-next/cli 0.3.0-pr.77.4 → 0.3.0-pr.78.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/dist/{chunk-QUPBU4KV.js → chunk-464LNZCE.js} +8 -5
- package/dist/chunk-464LNZCE.js.map +1 -0
- package/dist/{chunk-CVNWLFXO.js → chunk-ZKYEJROM.js} +9 -6
- package/dist/chunk-ZKYEJROM.js.map +1 -0
- package/dist/cli.js +60 -34
- package/dist/cli.js.map +1 -1
- package/dist/commands/contract-emit.d.ts.map +1 -1
- package/dist/commands/contract-emit.js +1 -1
- package/dist/commands/db-init.d.ts.map +1 -1
- package/dist/commands/db-init.js +10 -6
- package/dist/commands/db-init.js.map +1 -1
- package/dist/commands/db-introspect.d.ts.map +1 -1
- package/dist/commands/db-introspect.js +10 -6
- package/dist/commands/db-introspect.js.map +1 -1
- package/dist/commands/db-schema-verify.d.ts.map +1 -1
- package/dist/commands/db-schema-verify.js +10 -6
- package/dist/commands/db-schema-verify.js.map +1 -1
- package/dist/commands/db-sign.d.ts.map +1 -1
- package/dist/commands/db-sign.js +10 -6
- package/dist/commands/db-sign.js.map +1 -1
- package/dist/commands/db-verify.d.ts.map +1 -1
- package/dist/commands/db-verify.js +10 -6
- package/dist/commands/db-verify.js.map +1 -1
- package/dist/exports/index.js +1 -1
- package/dist/utils/framework-components.d.ts +18 -7
- package/dist/utils/framework-components.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/commands/contract-emit.ts +11 -4
- package/src/commands/db-init.ts +9 -5
- package/src/commands/db-introspect.ts +9 -5
- package/src/commands/db-schema-verify.ts +9 -5
- package/src/commands/db-sign.ts +9 -5
- package/src/commands/db-verify.ts +9 -5
- package/src/utils/framework-components.ts +30 -11
- package/dist/chunk-CVNWLFXO.js.map +0 -1
- package/dist/chunk-QUPBU4KV.js.map +0 -1
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
import { mkdirSync, writeFileSync } from "fs";
|
|
19
19
|
import { dirname, relative, resolve } from "path";
|
|
20
20
|
import { errorContractConfigMissing } from "@prisma-next/core-control-plane/errors";
|
|
21
|
-
import { createControlPlaneStack } from "@prisma-next/core-control-plane/types";
|
|
22
21
|
import { Command } from "commander";
|
|
23
22
|
function createContractEmitCommand() {
|
|
24
23
|
const command = new Command("emit");
|
|
@@ -66,13 +65,17 @@ function createContractEmitCommand() {
|
|
|
66
65
|
});
|
|
67
66
|
console.log(header);
|
|
68
67
|
}
|
|
69
|
-
|
|
68
|
+
if (!config.driver) {
|
|
69
|
+
throw errorContractConfigMissing({
|
|
70
|
+
why: "Config.driver is required. Even though emit does not use the driver, it is required by ControlFamilyDescriptor.create()"
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const familyInstance = config.family.create({
|
|
70
74
|
target: config.target,
|
|
71
75
|
adapter: config.adapter,
|
|
72
76
|
driver: config.driver,
|
|
73
|
-
extensionPacks: config.extensionPacks
|
|
77
|
+
extensionPacks: config.extensionPacks ?? []
|
|
74
78
|
});
|
|
75
|
-
const familyInstance = config.family.create(stack);
|
|
76
79
|
let contractRaw;
|
|
77
80
|
if (typeof contractConfig.source === "function") {
|
|
78
81
|
contractRaw = await contractConfig.source();
|
|
@@ -128,4 +131,4 @@ function createContractEmitCommand() {
|
|
|
128
131
|
export {
|
|
129
132
|
createContractEmitCommand
|
|
130
133
|
};
|
|
131
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
//# sourceMappingURL=chunk-464LNZCE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/contract-emit.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, relative, resolve } from 'node:path';\nimport { errorContractConfigMissing } from '@prisma-next/core-control-plane/errors';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport { performAction } from '../utils/action';\nimport { setCommandDescriptions } from '../utils/command-helpers';\nimport { parseGlobalFlags } from '../utils/global-flags';\nimport {\n formatCommandHelp,\n formatEmitJson,\n formatEmitOutput,\n formatStyledHeader,\n formatSuccessMessage,\n} from '../utils/output';\nimport { handleResult } from '../utils/result-handler';\nimport { withSpinner } from '../utils/spinner';\n\ninterface ContractEmitOptions {\n readonly config?: string;\n readonly json?: string | boolean;\n readonly quiet?: boolean;\n readonly q?: boolean;\n readonly verbose?: boolean;\n readonly v?: boolean;\n readonly vv?: boolean;\n readonly trace?: boolean;\n readonly timestamps?: boolean;\n readonly color?: boolean;\n readonly 'no-color'?: boolean;\n}\n\nexport function createContractEmitCommand(): Command {\n const command = new Command('emit');\n setCommandDescriptions(\n command,\n 'Write your contract to JSON and sign it',\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 command\n .configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n })\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--json [format]', 'Output as JSON (object or ndjson)', false)\n .option('-q, --quiet', 'Quiet mode: errors only')\n .option('-v, --verbose', 'Verbose output: debug info, timings')\n .option('-vv, --trace', 'Trace output: deep internals, stack traces')\n .option('--timestamps', 'Add timestamps to output')\n .option('--color', 'Force color output')\n .option('--no-color', 'Disable color output')\n .action(async (options: ContractEmitOptions) => {\n const flags = parseGlobalFlags(options);\n\n const result = await performAction(async () => {\n // Load config\n const config = await loadConfig(options.config);\n\n // Resolve contract from config\n if (!config.contract) {\n throw errorContractConfigMissing({\n why: 'Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ..., types: ... }',\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 || !contractConfig.types) {\n throw errorContractConfigMissing({\n why: 'Contract config must have output and types paths. This should not happen if defineConfig() was used.',\n });\n }\n const outputJsonPath = resolve(contractConfig.output);\n const outputDtsPath = resolve(contractConfig.types);\n\n // Output header (only for human-readable output)\n if (flags.json !== 'object' && !flags.quiet) {\n // Normalize config path for display (match contract path format - no ./ prefix)\n const configPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n // Convert absolute paths to relative paths for display\n const contractPath = relative(process.cwd(), outputJsonPath);\n const typesPath = relative(process.cwd(), outputDtsPath);\n const header = formatStyledHeader({\n command: 'contract emit',\n description: 'Write your contract to JSON and sign it',\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 console.log(header);\n }\n\n // Create family instance (assembles operation registry, type imports, extension IDs)\n // Note: emit command doesn't need driver, but ControlFamilyDescriptor.create() requires it\n // We'll need to provide a minimal driver descriptor or make driver optional for emit\n // For now, we'll require driver to be present in config even for emit\n if (!config.driver) {\n throw errorContractConfigMissing({\n why: 'Config.driver is required. Even though emit does not use the driver, it is required by ControlFamilyDescriptor.create()',\n });\n }\n const familyInstance = config.family.create({\n target: config.target,\n adapter: config.adapter,\n driver: config.driver,\n extensionPacks: config.extensionPacks ?? [],\n });\n\n // Resolve contract source from config (user's config handles loading)\n let contractRaw: unknown;\n if (typeof contractConfig.source === 'function') {\n contractRaw = await contractConfig.source();\n } else {\n contractRaw = contractConfig.source;\n }\n\n // Call emitContract on family instance (handles stripping mappings and validation internally)\n const emitResult = await withSpinner(\n () => familyInstance.emitContract({ contractIR: contractRaw }),\n {\n message: 'Emitting contract...',\n flags,\n },\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, emitResult.contractJson, 'utf-8');\n writeFileSync(outputDtsPath, emitResult.contractDts, 'utf-8');\n\n // Add blank line after all async operations if spinners were shown\n if (!flags.quiet && flags.json !== 'object' && process.stdout.isTTY) {\n console.log('');\n }\n\n // Return result with file paths for output formatting\n return {\n coreHash: emitResult.coreHash,\n profileHash: emitResult.profileHash,\n outDir: dirname(outputJsonPath),\n files: {\n json: outputJsonPath,\n dts: outputDtsPath,\n },\n timings: {\n total: 0, // Timing is handled by emitContract internally if needed\n },\n };\n });\n\n // Handle result - formats output and returns exit code\n const exitCode = handleResult(result, flags, (emitResult) => {\n // Output based on flags\n if (flags.json === 'object') {\n // JSON output to stdout\n console.log(formatEmitJson(emitResult));\n } else {\n // Human-readable output to stdout\n const output = formatEmitOutput(emitResult, flags);\n if (output) {\n console.log(output);\n }\n // Output success message\n if (!flags.quiet) {\n console.log(formatSuccessMessage(flags));\n }\n }\n });\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,qBAAqB;AACzC,SAAS,SAAS,UAAU,eAAe;AAC3C,SAAS,kCAAkC;AAC3C,SAAS,eAAe;AA6BjB,SAAS,4BAAqC;AACnD,QAAM,UAAU,IAAI,QAAQ,MAAM;AAClC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EAGF;AACA,UACG,cAAc;AAAA,IACb,YAAY,CAAC,QAAQ;AACnB,YAAM,QAAQ,iBAAiB,CAAC,CAAC;AACjC,aAAO,kBAAkB,EAAE,SAAS,KAAK,MAAM,CAAC;AAAA,IAClD;AAAA,EACF,CAAC,EACA,OAAO,mBAAmB,+BAA+B,EACzD,OAAO,mBAAmB,qCAAqC,KAAK,EACpE,OAAO,eAAe,yBAAyB,EAC/C,OAAO,iBAAiB,qCAAqC,EAC7D,OAAO,gBAAgB,4CAA4C,EACnE,OAAO,gBAAgB,0BAA0B,EACjD,OAAO,WAAW,oBAAoB,EACtC,OAAO,cAAc,sBAAsB,EAC3C,OAAO,OAAO,YAAiC;AAC9C,UAAM,QAAQ,iBAAiB,OAAO;AAEtC,UAAM,SAAS,MAAM,cAAc,YAAY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
54
54
|
}
|
|
55
55
|
function assertContractRequirementsSatisfied({
|
|
56
56
|
contract,
|
|
57
|
-
|
|
57
|
+
family,
|
|
58
|
+
target,
|
|
59
|
+
adapter,
|
|
60
|
+
extensionPacks
|
|
58
61
|
}) {
|
|
59
|
-
const providedComponentIds = /* @__PURE__ */ new Set([
|
|
60
|
-
for (const extension of
|
|
62
|
+
const providedComponentIds = /* @__PURE__ */ new Set([target.id, adapter.id]);
|
|
63
|
+
for (const extension of extensionPacks ?? []) {
|
|
61
64
|
providedComponentIds.add(extension.id);
|
|
62
65
|
}
|
|
63
66
|
const result = checkContractComponentRequirements({
|
|
64
67
|
contract,
|
|
65
|
-
expectedTargetFamily:
|
|
66
|
-
expectedTargetId:
|
|
68
|
+
expectedTargetFamily: family.familyId,
|
|
69
|
+
expectedTargetId: target.targetId,
|
|
67
70
|
providedComponentIds
|
|
68
71
|
});
|
|
69
72
|
if (result.familyMismatch) {
|
|
@@ -88,4 +91,4 @@ export {
|
|
|
88
91
|
assertFrameworkComponentsCompatible,
|
|
89
92
|
assertContractRequirementsSatisfied
|
|
90
93
|
};
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-ZKYEJROM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/framework-components.ts"],"sourcesContent":["import {\n checkContractComponentRequirements,\n type TargetBoundComponentDescriptor,\n} from '@prisma-next/contract/framework-components';\nimport type { ContractIR } from '@prisma-next/contract/ir';\nimport type {\n ControlAdapterDescriptor,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from '@prisma-next/core-control-plane/types';\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 family, 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 IR to validate (must include targetFamily, target, extensionPacks).\n * @param family - The configured family descriptor.\n * @param target - The configured target descriptor.\n * @param adapter - The configured adapter descriptor.\n * @param extensionPacks - Optional array of extension descriptors provided by the config.\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 contractIR = await loadContractJson(config.contract.output);\n *\n * // Throws if contract is incompatible with config\n * assertContractRequirementsSatisfied({\n * contract: contractIR,\n * family: config.family,\n * target: config.target,\n * adapter: config.adapter,\n * extensionPacks: config.extensionPacks,\n * });\n * ```\n */\nexport function assertContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n family,\n target,\n adapter,\n extensionPacks,\n}: {\n readonly contract: Pick<ContractIR, 'targetFamily' | 'target' | 'extensionPacks'>;\n readonly family: ControlFamilyDescriptor<TFamilyId>;\n readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;\n readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[] | undefined;\n}): void {\n const providedComponentIds = new Set<string>([target.id, adapter.id]);\n for (const extension of extensionPacks ?? []) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetFamily: family.familyId,\n expectedTargetId: 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":";;;;;;AAAA;AAAA,EACE;AAAA,OAEK;AA4CA,SAAS,oCAId,kBACA,kBACA,qBACqE;AACrE,WAAS,IAAI,GAAG,IAAI,oBAAoB,QAAQ,KAAK;AACnD,UAAM,YAAY,oBAAoB,CAAC;AAGvC,QAAI,OAAO,cAAc,YAAY,cAAc,MAAM;AACvD,YAAM,sBAAsB,yBAAyB;AAAA,QACnD,KAAK,gCAAgC,CAAC;AAAA,MACxC,CAAC;AAAA,IACH;AAEA,UAAM,SAAS;AAGf,QAAI,CAAC,OAAO,OAAO,QAAQ,MAAM,GAAG;AAClC,YAAM,sBAAsB,8BAA8B;A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Aa,kBAAkB,CAAC,GAAG;AAC5C,yBAAqB,IAAI,UAAU,EAAE;AAAA,EACvC;AAEA,QAAM,SAAS,mCAAmC;AAAA,IAChD;AAAA,IACA,sBAAsB,OAAO;AAAA,IAC7B,kBAAkB,OAAO;AAAA,IACzB;AAAA,EACF,CAAC;AAED,MAAI,OAAO,gBAAgB;AACzB,UAAM,sBAAsB,yBAAyB;AAAA,MACnD,KAAK,oCAAoC,OAAO,eAAe,MAAM,iCAAiC,OAAO,eAAe,QAAQ;AAAA,IACtI,CAAC;AAAA,EACH;AAEA,MAAI,OAAO,gBAAgB;AACzB,UAAM,sBAAsB,mBAAmB;AAAA,MAC7C,KAAK,oBAAoB,OAAO,eAAe,MAAM,gCAAgC,OAAO,eAAe,QAAQ;AAAA,IACrH,CAAC;AAAA,EACH;AAEA,MAAI,OAAO,wBAAwB,SAAS,GAAG;AAC7C,UAAM,mCAAmC;AAAA,MACvC,uBAAuB,OAAO;AAAA,MAC9B,sBAAsB,CAAC,GAAG,oBAAoB;AAAA,IAChD,CAAC;AAAA,EACH;AACF;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,6 @@ import { Command as Command7 } from "commander";
|
|
|
7
7
|
import { mkdirSync, writeFileSync } from "fs";
|
|
8
8
|
import { dirname as dirname2, relative as relative2, resolve as resolve2 } from "path";
|
|
9
9
|
import { errorContractConfigMissing as errorContractConfigMissing2 } from "@prisma-next/core-control-plane/errors";
|
|
10
|
-
import { createControlPlaneStack } from "@prisma-next/core-control-plane/types";
|
|
11
10
|
import { Command } from "commander";
|
|
12
11
|
|
|
13
12
|
// src/config-loader.ts
|
|
@@ -1130,13 +1129,17 @@ function createContractEmitCommand() {
|
|
|
1130
1129
|
});
|
|
1131
1130
|
console.log(header);
|
|
1132
1131
|
}
|
|
1133
|
-
|
|
1132
|
+
if (!config.driver) {
|
|
1133
|
+
throw errorContractConfigMissing2({
|
|
1134
|
+
why: "Config.driver is required. Even though emit does not use the driver, it is required by ControlFamilyDescriptor.create()"
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
const familyInstance = config.family.create({
|
|
1134
1138
|
target: config.target,
|
|
1135
1139
|
adapter: config.adapter,
|
|
1136
1140
|
driver: config.driver,
|
|
1137
|
-
extensionPacks: config.extensionPacks
|
|
1141
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1138
1142
|
});
|
|
1139
|
-
const familyInstance = config.family.create(stack);
|
|
1140
1143
|
let contractRaw;
|
|
1141
1144
|
if (typeof contractConfig.source === "function") {
|
|
1142
1145
|
contractRaw = await contractConfig.source();
|
|
@@ -1192,7 +1195,6 @@ function createContractEmitCommand() {
|
|
|
1192
1195
|
// src/commands/db-init.ts
|
|
1193
1196
|
import { readFile } from "fs/promises";
|
|
1194
1197
|
import { relative as relative3, resolve as resolve3 } from "path";
|
|
1195
|
-
import { createControlPlaneStack as createControlPlaneStack2 } from "@prisma-next/core-control-plane/types";
|
|
1196
1198
|
import { redactDatabaseUrl } from "@prisma-next/utils/redact-db-url";
|
|
1197
1199
|
import { Command as Command2 } from "commander";
|
|
1198
1200
|
|
|
@@ -1247,16 +1249,19 @@ function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId,
|
|
|
1247
1249
|
}
|
|
1248
1250
|
function assertContractRequirementsSatisfied({
|
|
1249
1251
|
contract,
|
|
1250
|
-
|
|
1252
|
+
family,
|
|
1253
|
+
target,
|
|
1254
|
+
adapter,
|
|
1255
|
+
extensionPacks
|
|
1251
1256
|
}) {
|
|
1252
|
-
const providedComponentIds = /* @__PURE__ */ new Set([
|
|
1253
|
-
for (const extension of
|
|
1257
|
+
const providedComponentIds = /* @__PURE__ */ new Set([target.id, adapter.id]);
|
|
1258
|
+
for (const extension of extensionPacks ?? []) {
|
|
1254
1259
|
providedComponentIds.add(extension.id);
|
|
1255
1260
|
}
|
|
1256
1261
|
const result = checkContractComponentRequirements({
|
|
1257
1262
|
contract,
|
|
1258
|
-
expectedTargetFamily:
|
|
1259
|
-
expectedTargetId:
|
|
1263
|
+
expectedTargetFamily: family.familyId,
|
|
1264
|
+
expectedTargetId: target.targetId,
|
|
1260
1265
|
providedComponentIds
|
|
1261
1266
|
});
|
|
1262
1267
|
if (result.familyMismatch) {
|
|
@@ -1384,13 +1389,12 @@ function createDbInitCommand() {
|
|
|
1384
1389
|
});
|
|
1385
1390
|
}
|
|
1386
1391
|
try {
|
|
1387
|
-
const
|
|
1392
|
+
const familyInstance = config.family.create({
|
|
1388
1393
|
target: config.target,
|
|
1389
1394
|
adapter: config.adapter,
|
|
1390
1395
|
driver: driverDescriptor,
|
|
1391
|
-
extensionPacks: config.extensionPacks
|
|
1396
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1392
1397
|
});
|
|
1393
|
-
const familyInstance = config.family.create(stack);
|
|
1394
1398
|
const rawComponents = [config.target, config.adapter, ...config.extensionPacks ?? []];
|
|
1395
1399
|
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1396
1400
|
config.family.familyId,
|
|
@@ -1398,7 +1402,13 @@ function createDbInitCommand() {
|
|
|
1398
1402
|
rawComponents
|
|
1399
1403
|
);
|
|
1400
1404
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1401
|
-
assertContractRequirementsSatisfied({
|
|
1405
|
+
assertContractRequirementsSatisfied({
|
|
1406
|
+
contract: contractIR,
|
|
1407
|
+
family: config.family,
|
|
1408
|
+
target: config.target,
|
|
1409
|
+
adapter: config.adapter,
|
|
1410
|
+
extensionPacks: config.extensionPacks
|
|
1411
|
+
});
|
|
1402
1412
|
const planner = migrations.createPlanner(familyInstance);
|
|
1403
1413
|
const runner = migrations.createRunner(familyInstance);
|
|
1404
1414
|
const schemaIR = await withSpinner(() => familyInstance.introspect({ driver }), {
|
|
@@ -1586,7 +1596,6 @@ import {
|
|
|
1586
1596
|
errorRuntime as errorRuntime2,
|
|
1587
1597
|
errorUnexpected as errorUnexpected3
|
|
1588
1598
|
} from "@prisma-next/core-control-plane/errors";
|
|
1589
|
-
import { createControlPlaneStack as createControlPlaneStack3 } from "@prisma-next/core-control-plane/types";
|
|
1590
1599
|
import { Command as Command3 } from "commander";
|
|
1591
1600
|
function createDbIntrospectCommand() {
|
|
1592
1601
|
const command = new Command3("introspect");
|
|
@@ -1653,16 +1662,21 @@ function createDbIntrospectCommand() {
|
|
|
1653
1662
|
flags
|
|
1654
1663
|
});
|
|
1655
1664
|
try {
|
|
1656
|
-
const
|
|
1665
|
+
const familyInstance = config.family.create({
|
|
1657
1666
|
target: config.target,
|
|
1658
1667
|
adapter: config.adapter,
|
|
1659
1668
|
driver: driverDescriptor,
|
|
1660
|
-
extensionPacks: config.extensionPacks
|
|
1669
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1661
1670
|
});
|
|
1662
|
-
const familyInstance = config.family.create(stack);
|
|
1663
1671
|
if (contractIR) {
|
|
1664
1672
|
const validatedContract = familyInstance.validateContractIR(contractIR);
|
|
1665
|
-
assertContractRequirementsSatisfied({
|
|
1673
|
+
assertContractRequirementsSatisfied({
|
|
1674
|
+
contract: validatedContract,
|
|
1675
|
+
family: config.family,
|
|
1676
|
+
target: config.target,
|
|
1677
|
+
adapter: config.adapter,
|
|
1678
|
+
extensionPacks: config.extensionPacks
|
|
1679
|
+
});
|
|
1666
1680
|
contractIR = validatedContract;
|
|
1667
1681
|
}
|
|
1668
1682
|
let schemaIR;
|
|
@@ -1752,7 +1766,6 @@ import {
|
|
|
1752
1766
|
errorRuntime as errorRuntime3,
|
|
1753
1767
|
errorUnexpected as errorUnexpected4
|
|
1754
1768
|
} from "@prisma-next/core-control-plane/errors";
|
|
1755
|
-
import { createControlPlaneStack as createControlPlaneStack4 } from "@prisma-next/core-control-plane/types";
|
|
1756
1769
|
import { Command as Command4 } from "commander";
|
|
1757
1770
|
function createDbSchemaVerifyCommand() {
|
|
1758
1771
|
const command = new Command4("schema-verify");
|
|
@@ -1808,15 +1821,20 @@ function createDbSchemaVerifyCommand() {
|
|
|
1808
1821
|
throw errorDriverRequired3();
|
|
1809
1822
|
}
|
|
1810
1823
|
const driverDescriptor = config.driver;
|
|
1811
|
-
const
|
|
1824
|
+
const familyInstance = config.family.create({
|
|
1812
1825
|
target: config.target,
|
|
1813
1826
|
adapter: config.adapter,
|
|
1814
1827
|
driver: driverDescriptor,
|
|
1815
|
-
extensionPacks: config.extensionPacks
|
|
1828
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1816
1829
|
});
|
|
1817
|
-
const familyInstance = config.family.create(stack);
|
|
1818
1830
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1819
|
-
assertContractRequirementsSatisfied({
|
|
1831
|
+
assertContractRequirementsSatisfied({
|
|
1832
|
+
contract: contractIR,
|
|
1833
|
+
family: config.family,
|
|
1834
|
+
target: config.target,
|
|
1835
|
+
adapter: config.adapter,
|
|
1836
|
+
extensionPacks: config.extensionPacks
|
|
1837
|
+
});
|
|
1820
1838
|
const dbUrl = options.db ?? config.db?.url;
|
|
1821
1839
|
if (!dbUrl) {
|
|
1822
1840
|
throw errorDatabaseUrlRequired3();
|
|
@@ -1890,7 +1908,6 @@ import {
|
|
|
1890
1908
|
errorRuntime as errorRuntime4,
|
|
1891
1909
|
errorUnexpected as errorUnexpected5
|
|
1892
1910
|
} from "@prisma-next/core-control-plane/errors";
|
|
1893
|
-
import { createControlPlaneStack as createControlPlaneStack5 } from "@prisma-next/core-control-plane/types";
|
|
1894
1911
|
import { Command as Command5 } from "commander";
|
|
1895
1912
|
function createDbSignCommand() {
|
|
1896
1913
|
const command = new Command5("sign");
|
|
@@ -1950,15 +1967,20 @@ function createDbSignCommand() {
|
|
|
1950
1967
|
throw errorDriverRequired4();
|
|
1951
1968
|
}
|
|
1952
1969
|
const driverDescriptor = config.driver;
|
|
1953
|
-
const
|
|
1970
|
+
const familyInstance = config.family.create({
|
|
1954
1971
|
target: config.target,
|
|
1955
1972
|
adapter: config.adapter,
|
|
1956
1973
|
driver: driverDescriptor,
|
|
1957
|
-
extensionPacks: config.extensionPacks
|
|
1974
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1958
1975
|
});
|
|
1959
|
-
const familyInstance = config.family.create(stack);
|
|
1960
1976
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1961
|
-
assertContractRequirementsSatisfied({
|
|
1977
|
+
assertContractRequirementsSatisfied({
|
|
1978
|
+
contract: contractIR,
|
|
1979
|
+
family: config.family,
|
|
1980
|
+
target: config.target,
|
|
1981
|
+
adapter: config.adapter,
|
|
1982
|
+
extensionPacks: config.extensionPacks
|
|
1983
|
+
});
|
|
1962
1984
|
const rawComponents = [config.target, config.adapter, ...config.extensionPacks ?? []];
|
|
1963
1985
|
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1964
1986
|
config.family.familyId,
|
|
@@ -2064,7 +2086,6 @@ import {
|
|
|
2064
2086
|
errorTargetMismatch as errorTargetMismatch2,
|
|
2065
2087
|
errorUnexpected as errorUnexpected6
|
|
2066
2088
|
} from "@prisma-next/core-control-plane/errors";
|
|
2067
|
-
import { createControlPlaneStack as createControlPlaneStack6 } from "@prisma-next/core-control-plane/types";
|
|
2068
2089
|
import { Command as Command6 } from "commander";
|
|
2069
2090
|
function createDbVerifyCommand() {
|
|
2070
2091
|
const command = new Command6("verify");
|
|
@@ -2129,15 +2150,20 @@ function createDbVerifyCommand() {
|
|
|
2129
2150
|
flags
|
|
2130
2151
|
});
|
|
2131
2152
|
try {
|
|
2132
|
-
const
|
|
2153
|
+
const familyInstance = config.family.create({
|
|
2133
2154
|
target: config.target,
|
|
2134
2155
|
adapter: config.adapter,
|
|
2135
2156
|
driver: driverDescriptor,
|
|
2136
|
-
extensionPacks: config.extensionPacks
|
|
2157
|
+
extensionPacks: config.extensionPacks ?? []
|
|
2137
2158
|
});
|
|
2138
|
-
const familyInstance = config.family.create(stack);
|
|
2139
2159
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
2140
|
-
assertContractRequirementsSatisfied({
|
|
2160
|
+
assertContractRequirementsSatisfied({
|
|
2161
|
+
contract: contractIR,
|
|
2162
|
+
family: config.family,
|
|
2163
|
+
target: config.target,
|
|
2164
|
+
adapter: config.adapter,
|
|
2165
|
+
extensionPacks: config.extensionPacks
|
|
2166
|
+
});
|
|
2141
2167
|
let verifyResult;
|
|
2142
2168
|
try {
|
|
2143
2169
|
verifyResult = await withSpinner(
|