@prisma-next/core-control-plane 0.3.0-dev.55 → 0.3.0-dev.57

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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@prisma-next/core-control-plane",
3
- "version": "0.3.0-dev.55",
3
+ "version": "0.3.0-dev.57",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
- "description": "Control plane domain actions, config types, validation, and error factories for Prisma Next",
6
+ "description": "Control-plane migration/emission primitives and structured error utilities",
7
7
  "dependencies": {
8
8
  "arktype": "^2.1.26",
9
9
  "prettier": "^3.3.3",
10
- "@prisma-next/contract": "0.3.0-dev.55",
11
- "@prisma-next/operations": "0.3.0-dev.55",
12
- "@prisma-next/utils": "0.3.0-dev.55"
10
+ "@prisma-next/contract": "0.3.0-dev.57",
11
+ "@prisma-next/operations": "0.3.0-dev.57",
12
+ "@prisma-next/utils": "0.3.0-dev.57"
13
13
  },
14
14
  "devDependencies": {
15
15
  "tsdown": "0.18.4",
@@ -27,8 +27,6 @@
27
27
  "node": ">=20"
28
28
  },
29
29
  "exports": {
30
- "./config-types": "./dist/config-types.mjs",
31
- "./config-validation": "./dist/config-validation.mjs",
32
30
  "./emission": "./dist/emission.mjs",
33
31
  "./errors": "./dist/errors.mjs",
34
32
  "./schema-view": "./dist/schema-view.mjs",
@@ -1,96 +0,0 @@
1
- import { a as ControlExtensionDescriptor, i as ControlDriverInstance, r as ControlDriverDescriptor, s as ControlFamilyDescriptor, t as ControlAdapterDescriptor, u as ControlTargetDescriptor } from "./types-DWZxwNKq.mjs";
2
- import { ContractIR } from "@prisma-next/contract/ir";
3
- import { Result } from "@prisma-next/utils/result";
4
-
5
- //#region src/contract-source-types.d.ts
6
- interface ContractSourceDiagnosticPosition {
7
- readonly offset: number;
8
- readonly line: number;
9
- readonly column: number;
10
- }
11
- interface ContractSourceDiagnosticSpan {
12
- readonly start: ContractSourceDiagnosticPosition;
13
- readonly end: ContractSourceDiagnosticPosition;
14
- }
15
- interface ContractSourceDiagnostic {
16
- readonly code: string;
17
- readonly message: string;
18
- readonly sourceId?: string;
19
- readonly span?: ContractSourceDiagnosticSpan;
20
- }
21
- interface ContractSourceDiagnostics {
22
- readonly summary: string;
23
- readonly diagnostics: readonly ContractSourceDiagnostic[];
24
- readonly meta?: Record<string, unknown>;
25
- }
26
- type ContractSourceProvider = () => Promise<Result<ContractIR, ContractSourceDiagnostics>>;
27
- //#endregion
28
- //#region src/config-types.d.ts
29
- /**
30
- * Contract configuration specifying source and artifact locations.
31
- */
32
- interface ContractConfig {
33
- /**
34
- * Contract source provider. The provider is always async and must return
35
- * a Result containing either ContractIR or structured diagnostics.
36
- */
37
- readonly source: ContractSourceProvider;
38
- /**
39
- * Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.
40
- * The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).
41
- */
42
- readonly output?: string;
43
- }
44
- /**
45
- * Configuration for Prisma Next CLI.
46
- * Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.
47
- *
48
- * @template TFamilyId - The family ID (e.g., 'sql', 'document')
49
- * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
50
- * @template TConnection - The driver connection input type (defaults to `unknown` for config flexibility)
51
- */
52
- interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends string = string, TConnection = unknown> {
53
- readonly family: ControlFamilyDescriptor<TFamilyId>;
54
- readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
55
- readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
56
- readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
57
- /**
58
- * Driver descriptor for DB-connected CLI commands.
59
- * Required for DB-connected commands (e.g., db verify).
60
- * Optional for commands that don't need database access (e.g., emit).
61
- * The driver's connection type matches the TConnection config parameter.
62
- */
63
- readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId, ControlDriverInstance<TFamilyId, TTargetId>, TConnection>;
64
- /**
65
- * Database connection configuration.
66
- * The connection type is driver-specific (e.g., URL string for Postgres).
67
- */
68
- readonly db?: {
69
- /**
70
- * Driver-specific connection input.
71
- * For Postgres: a connection string (URL).
72
- * For other drivers: may be a structured object.
73
- */
74
- readonly connection?: TConnection;
75
- };
76
- /**
77
- * Contract configuration. Specifies source and artifact locations.
78
- * Required for emit command; optional for other commands that only read artifacts.
79
- */
80
- readonly contract?: ContractConfig;
81
- }
82
- /**
83
- * Helper function to define a Prisma Next config.
84
- * Validates and normalizes the config using Arktype, then returns the normalized IR.
85
- *
86
- * Normalization:
87
- * - contract.output defaults to 'src/prisma/contract.json' if missing
88
- *
89
- * @param config - Raw config input from user
90
- * @returns Normalized config IR with defaults applied
91
- * @throws Error if config structure is invalid
92
- */
93
- declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
94
- //#endregion
95
- export { ContractSourceDiagnosticPosition as a, ContractSourceProvider as c, ContractSourceDiagnostic as i, PrismaNextConfig as n, ContractSourceDiagnosticSpan as o, defineConfig as r, ContractSourceDiagnostics as s, ContractConfig as t };
96
- //# sourceMappingURL=config-types-UTSsxKk2.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-types-UTSsxKk2.d.mts","names":[],"sources":["../src/contract-source-types.ts","../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;;UAGiB,gCAAA;;;EAAA,SAAA,MAAA,EAAA,MAAA;AAMjB;AAKiB,UALA,4BAAA,CASC;EAGD,SAAA,KAAA,EAXC,gCAae;EAIrB,SAAA,GAAA,EAhBI,gCAgBkB;;AAAoC,UAbrD,wBAAA,CAaqD;EAAnB,SAAA,IAAA,EAAA,MAAA;EAAR,SAAA,OAAA,EAAA,MAAA;EAAO,SAAA,QAAA,CAAA,EAAA,MAAA;kBAThC;;UAGD,yBAAA;ECDA,SAAA,OAAA,EAAc,MAAA;EAqBd,SAAA,WAAgB,EAAA,SDlBA,wBCkBA,EAAA;EAKU,SAAA,IAAA,CAAA,EDtBzB,MCsByB,CAAA,MAAA,EAAA,OAAA,CAAA;;AACA,KDpB/B,sBAAA,GCoB+B,GAAA,GDpBA,OCoBA,CDpBQ,MCoBR,CDpBe,UCoBf,EDpB2B,yBCoB3B,CAAA,CAAA;;;ADjC3C;AAOA;AAMA;AAA0D,UCPzC,cAAA,CDOyC;EAAY;;;;mBCFnD;;;AALnB;AAqBA;EAK2C,SAAA,MAAA,CAAA,EAAA,MAAA;;;;;;;;;;AAGN,UARpB,gBAQoB,CAAA,kBAAA,MAAA,GAAA,MAAA,EAAA,kBAAA,MAAA,GAAA,MAAA,EAAA,cAAA,OAAA,CAAA,CAAA;EAQjC,SAAA,MAAA,EAXe,uBAWf,CAXuC,SAWvC,CAAA;EACA,SAAA,MAAA,EAXe,uBAWf,CAXuC,SAWvC,EAXkD,SAWlD,CAAA;EACsB,SAAA,OAAA,EAXN,wBAWM,CAXmB,SAWnB,EAX8B,SAW9B,CAAA;EAAW,SAAA,cAAA,CAAA,EAAA,SAVA,0BAUA,CAV2B,SAU3B,EAVsC,SAUtC,CAAA,EAAA;EAAjC;;;;;;EAyDY,SAAA,MAAY,CAAA,EA5DR,uBA4DQ,CA3DxB,SA2DwB,EA1DxB,SA0DwB,EAzDxB,qBAyDwB,CAzDF,SAyDE,EAzDS,SAyDT,CAAA,EAxDxB,WAwDwB,CAAA;EACD;;;;EACI,SAAA,EAAA,CAAA,EAAA;IAA5B;;;;;0BA9CuB;;;;;;sBAMJ;;;;;;;;;;;;;iBAsCN,2FACN,iBAAiB,WAAW,aACnC,iBAAiB,WAAW"}
@@ -1,3 +0,0 @@
1
- import { a as ContractSourceDiagnosticPosition, c as ContractSourceProvider, i as ContractSourceDiagnostic, n as PrismaNextConfig, o as ContractSourceDiagnosticSpan, r as defineConfig, s as ContractSourceDiagnostics, t as ContractConfig } from "./config-types-UTSsxKk2.mjs";
2
- import "./types-DWZxwNKq.mjs";
3
- export { type ContractConfig, type ContractSourceDiagnostic, type ContractSourceDiagnosticPosition, type ContractSourceDiagnosticSpan, type ContractSourceDiagnostics, type ContractSourceProvider, type PrismaNextConfig, defineConfig };
@@ -1,60 +0,0 @@
1
- import { type } from "arktype";
2
-
3
- //#region src/config-types.ts
4
- /**
5
- * Arktype schema for ContractConfig validation.
6
- * Validates presence/shape only.
7
- * contract.source is validated as a provider function at runtime in defineConfig().
8
- */
9
- const ContractConfigSchema = type({
10
- source: "unknown",
11
- "output?": "string"
12
- });
13
- /**
14
- * Arktype schema for PrismaNextConfig validation.
15
- * Note: This validates structure only. Descriptor objects (family, target, adapter) are validated separately.
16
- */
17
- const PrismaNextConfigSchema = type({
18
- family: "unknown",
19
- target: "unknown",
20
- adapter: "unknown",
21
- "extensionPacks?": "unknown[]",
22
- "driver?": "unknown",
23
- "db?": "unknown",
24
- "contract?": ContractConfigSchema
25
- });
26
- /**
27
- * Helper function to define a Prisma Next config.
28
- * Validates and normalizes the config using Arktype, then returns the normalized IR.
29
- *
30
- * Normalization:
31
- * - contract.output defaults to 'src/prisma/contract.json' if missing
32
- *
33
- * @param config - Raw config input from user
34
- * @returns Normalized config IR with defaults applied
35
- * @throws Error if config structure is invalid
36
- */
37
- function defineConfig(config) {
38
- const validated = PrismaNextConfigSchema(config);
39
- if (validated instanceof type.errors) {
40
- const messages = validated.map((p) => p.message).join("; ");
41
- throw new Error(`Config validation failed: ${messages}`);
42
- }
43
- if (config.contract) {
44
- if (typeof config.contract.source !== "function") throw new Error("Config.contract.source must be a provider function");
45
- const output = config.contract.output ?? "src/prisma/contract.json";
46
- const normalizedContract = {
47
- source: config.contract.source,
48
- output
49
- };
50
- return {
51
- ...config,
52
- contract: normalizedContract
53
- };
54
- }
55
- return config;
56
- }
57
-
58
- //#endregion
59
- export { defineConfig };
60
- //# sourceMappingURL=config-types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-types.mjs","names":["normalizedContract: ContractConfig"],"sources":["../src/config-types.ts"],"sourcesContent":["import { type } from 'arktype';\nimport type { ContractSourceProvider } from './contract-source-types';\nimport type {\n ControlAdapterDescriptor,\n ControlDriverDescriptor,\n ControlDriverInstance,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from './types';\n\n/**\n * Type alias for CLI driver instances.\n * Uses string for both family and target IDs for maximum flexibility.\n */\nexport type CliDriver = ControlDriverInstance<string, string>;\n\n/**\n * Contract configuration specifying source and artifact locations.\n */\nexport interface ContractConfig {\n /**\n * Contract source provider. The provider is always async and must return\n * a Result containing either ContractIR or structured diagnostics.\n */\n readonly source: ContractSourceProvider;\n /**\n * Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.\n * The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).\n */\n readonly output?: string;\n}\n\n/**\n * Configuration for Prisma Next CLI.\n * Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.\n *\n * @template TFamilyId - The family ID (e.g., 'sql', 'document')\n * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')\n * @template TConnection - The driver connection input type (defaults to `unknown` for config flexibility)\n */\nexport interface PrismaNextConfig<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n TConnection = unknown,\n> {\n readonly family: ControlFamilyDescriptor<TFamilyId>;\n readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;\n readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];\n /**\n * Driver descriptor for DB-connected CLI commands.\n * Required for DB-connected commands (e.g., db verify).\n * Optional for commands that don't need database access (e.g., emit).\n * The driver's connection type matches the TConnection config parameter.\n */\n readonly driver?: ControlDriverDescriptor<\n TFamilyId,\n TTargetId,\n ControlDriverInstance<TFamilyId, TTargetId>,\n TConnection\n >;\n /**\n * Database connection configuration.\n * The connection type is driver-specific (e.g., URL string for Postgres).\n */\n readonly db?: {\n /**\n * Driver-specific connection input.\n * For Postgres: a connection string (URL).\n * For other drivers: may be a structured object.\n */\n readonly connection?: TConnection;\n };\n /**\n * Contract configuration. Specifies source and artifact locations.\n * Required for emit command; optional for other commands that only read artifacts.\n */\n readonly contract?: ContractConfig;\n}\n\n/**\n * Arktype schema for ContractConfig validation.\n * Validates presence/shape only.\n * contract.source is validated as a provider function at runtime in defineConfig().\n */\nconst ContractConfigSchema = type({\n source: 'unknown', // Runtime check enforces provider function shape\n 'output?': 'string',\n});\n\n/**\n * Arktype schema for PrismaNextConfig validation.\n * Note: This validates structure only. Descriptor objects (family, target, adapter) are validated separately.\n */\nconst PrismaNextConfigSchema = type({\n family: 'unknown', // ControlFamilyDescriptor - validated separately\n target: 'unknown', // ControlTargetDescriptor - validated separately\n adapter: 'unknown', // ControlAdapterDescriptor - validated separately\n 'extensionPacks?': 'unknown[]',\n 'driver?': 'unknown', // ControlDriverDescriptor - validated separately (optional)\n 'db?': 'unknown',\n 'contract?': ContractConfigSchema,\n});\n\n/**\n * Helper function to define a Prisma Next config.\n * Validates and normalizes the config using Arktype, then returns the normalized IR.\n *\n * Normalization:\n * - contract.output defaults to 'src/prisma/contract.json' if missing\n *\n * @param config - Raw config input from user\n * @returns Normalized config IR with defaults applied\n * @throws Error if config structure is invalid\n */\nexport function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(\n config: PrismaNextConfig<TFamilyId, TTargetId>,\n): PrismaNextConfig<TFamilyId, TTargetId> {\n // Validate structure using Arktype\n const validated = PrismaNextConfigSchema(config);\n if (validated instanceof type.errors) {\n const messages = validated.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Config validation failed: ${messages}`);\n }\n\n // Normalize contract config if present\n if (config.contract) {\n // Validate contract.source provider function shape at runtime.\n const source = config.contract.source;\n if (typeof source !== 'function') {\n throw new Error('Config.contract.source must be a provider function');\n }\n\n // Apply defaults\n const output = config.contract.output ?? 'src/prisma/contract.json';\n\n const normalizedContract: ContractConfig = {\n source: config.contract.source,\n output,\n };\n\n // Return normalized config\n return {\n ...config,\n contract: normalizedContract,\n };\n }\n\n // Return config as-is if no contract (preserve literal types)\n return config;\n}\n"],"mappings":";;;;;;;;AAsFA,MAAM,uBAAuB,KAAK;CAChC,QAAQ;CACR,WAAW;CACZ,CAAC;;;;;AAMF,MAAM,yBAAyB,KAAK;CAClC,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,mBAAmB;CACnB,WAAW;CACX,OAAO;CACP,aAAa;CACd,CAAC;;;;;;;;;;;;AAaF,SAAgB,aACd,QACwC;CAExC,MAAM,YAAY,uBAAuB,OAAO;AAChD,KAAI,qBAAqB,KAAK,QAAQ;EACpC,MAAM,WAAW,UAAU,KAAK,MAA2B,EAAE,QAAQ,CAAC,KAAK,KAAK;AAChF,QAAM,IAAI,MAAM,6BAA6B,WAAW;;AAI1D,KAAI,OAAO,UAAU;AAGnB,MAAI,OADW,OAAO,SAAS,WACT,WACpB,OAAM,IAAI,MAAM,qDAAqD;EAIvE,MAAM,SAAS,OAAO,SAAS,UAAU;EAEzC,MAAMA,qBAAqC;GACzC,QAAQ,OAAO,SAAS;GACxB;GACD;AAGD,SAAO;GACL,GAAG;GACH,UAAU;GACX;;AAIH,QAAO"}
@@ -1,16 +0,0 @@
1
- import { n as PrismaNextConfig } from "./config-types-UTSsxKk2.mjs";
2
- import "./types-DWZxwNKq.mjs";
3
-
4
- //#region src/config-validation.d.ts
5
-
6
- /**
7
- * Validates that the config has the required structure.
8
- * This is pure validation logic with no file I/O or CLI awareness.
9
- *
10
- * @param config - Config object to validate
11
- * @throws CliStructuredError if config structure is invalid
12
- */
13
- declare function validateConfig(config: unknown): asserts config is PrismaNextConfig;
14
- //#endregion
15
- export { validateConfig };
16
- //# sourceMappingURL=config-validation.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-validation.d.mts","names":[],"sources":["../src/config-validation.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUA;;;;iBAAgB,cAAA,qCAAmD"}
@@ -1,79 +0,0 @@
1
- import { r as errorConfigValidation } from "./errors-CvuQhtGp.mjs";
2
-
3
- //#region src/config-validation.ts
4
- /**
5
- * Validates that the config has the required structure.
6
- * This is pure validation logic with no file I/O or CLI awareness.
7
- *
8
- * @param config - Config object to validate
9
- * @throws CliStructuredError if config structure is invalid
10
- */
11
- function validateConfig(config) {
12
- if (!config || typeof config !== "object") throw errorConfigValidation("object", { why: "Config must be an object" });
13
- const configObj = config;
14
- if (!configObj["family"]) throw errorConfigValidation("family");
15
- if (!configObj["target"]) throw errorConfigValidation("target");
16
- if (!configObj["adapter"]) throw errorConfigValidation("adapter");
17
- const family = configObj["family"];
18
- if (family["kind"] !== "family") throw errorConfigValidation("family.kind", { why: "Config.family must have kind: \"family\"" });
19
- if (typeof family["familyId"] !== "string") throw errorConfigValidation("family.familyId", { why: "Config.family must have familyId: string" });
20
- if (typeof family["version"] !== "string") throw errorConfigValidation("family.version", { why: "Config.family must have version: string" });
21
- if (!family["hook"] || typeof family["hook"] !== "object") throw errorConfigValidation("family.hook", { why: "Config.family must have hook: TargetFamilyHook" });
22
- if (typeof family["create"] !== "function") throw errorConfigValidation("family.create", { why: "Config.family must have create: function" });
23
- const familyId = family["familyId"];
24
- const target = configObj["target"];
25
- if (target["kind"] !== "target") throw errorConfigValidation("target.kind", { why: "Config.target must have kind: \"target\"" });
26
- if (typeof target["id"] !== "string") throw errorConfigValidation("target.id", { why: "Config.target must have id: string" });
27
- if (typeof target["familyId"] !== "string") throw errorConfigValidation("target.familyId", { why: "Config.target must have familyId: string" });
28
- if (typeof target["version"] !== "string") throw errorConfigValidation("target.version", { why: "Config.target must have version: string" });
29
- if (target["familyId"] !== familyId) throw errorConfigValidation("target.familyId", { why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target["familyId"]})` });
30
- if (typeof target["targetId"] !== "string") throw errorConfigValidation("target.targetId", { why: "Config.target must have targetId: string" });
31
- if (typeof target["create"] !== "function") throw errorConfigValidation("target.create", { why: "Config.target must have create: function" });
32
- const expectedTargetId = target["targetId"];
33
- const adapter = configObj["adapter"];
34
- if (adapter["kind"] !== "adapter") throw errorConfigValidation("adapter.kind", { why: "Config.adapter must have kind: \"adapter\"" });
35
- if (typeof adapter["id"] !== "string") throw errorConfigValidation("adapter.id", { why: "Config.adapter must have id: string" });
36
- if (typeof adapter["familyId"] !== "string") throw errorConfigValidation("adapter.familyId", { why: "Config.adapter must have familyId: string" });
37
- if (typeof adapter["version"] !== "string") throw errorConfigValidation("adapter.version", { why: "Config.adapter must have version: string" });
38
- if (adapter["familyId"] !== familyId) throw errorConfigValidation("adapter.familyId", { why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter["familyId"]})` });
39
- if (typeof adapter["targetId"] !== "string") throw errorConfigValidation("adapter.targetId", { why: "Config.adapter must have targetId: string" });
40
- if (adapter["targetId"] !== expectedTargetId) throw errorConfigValidation("adapter.targetId", { why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter["targetId"]})` });
41
- if (typeof adapter["create"] !== "function") throw errorConfigValidation("adapter.create", { why: "Config.adapter must have create: function" });
42
- if (configObj["extensions"] !== void 0) {
43
- if (!Array.isArray(configObj["extensions"])) throw errorConfigValidation("extensions", { why: "Config.extensions must be an array" });
44
- for (const ext of configObj["extensions"]) {
45
- if (!ext || typeof ext !== "object") throw errorConfigValidation("extensions[]", { why: "Config.extensions must contain ExtensionDescriptor objects" });
46
- const extObj = ext;
47
- if (extObj["kind"] !== "extension") throw errorConfigValidation("extensions[].kind", { why: "Config.extensions items must have kind: \"extension\"" });
48
- if (typeof extObj["id"] !== "string") throw errorConfigValidation("extensions[].id", { why: "Config.extensions items must have id: string" });
49
- if (typeof extObj["familyId"] !== "string") throw errorConfigValidation("extensions[].familyId", { why: "Config.extensions items must have familyId: string" });
50
- if (typeof extObj["version"] !== "string") throw errorConfigValidation("extensions[].version", { why: "Config.extensions items must have version: string" });
51
- if (extObj["familyId"] !== familyId) throw errorConfigValidation("extensions[].familyId", { why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj["familyId"]})` });
52
- if (typeof extObj["targetId"] !== "string") throw errorConfigValidation("extensions[].targetId", { why: "Config.extensions items must have targetId: string" });
53
- if (extObj["targetId"] !== expectedTargetId) throw errorConfigValidation("extensions[].targetId", { why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj["targetId"]})` });
54
- if (typeof extObj["create"] !== "function") throw errorConfigValidation("extensions[].create", { why: "Config.extensions items must have create: function" });
55
- }
56
- }
57
- if (configObj["driver"] !== void 0) {
58
- const driver = configObj["driver"];
59
- if (driver["kind"] !== "driver") throw errorConfigValidation("driver.kind", { why: "Config.driver must have kind: \"driver\"" });
60
- if (typeof driver["id"] !== "string") throw errorConfigValidation("driver.id", { why: "Config.driver must have id: string" });
61
- if (typeof driver["version"] !== "string") throw errorConfigValidation("driver.version", { why: "Config.driver must have version: string" });
62
- if (typeof driver["familyId"] !== "string") throw errorConfigValidation("driver.familyId", { why: "Config.driver must have familyId: string" });
63
- if (driver["familyId"] !== familyId) throw errorConfigValidation("driver.familyId", { why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver["familyId"]})` });
64
- if (typeof driver["targetId"] !== "string") throw errorConfigValidation("driver.targetId", { why: "Config.driver must have targetId: string" });
65
- if (driver["targetId"] !== expectedTargetId) throw errorConfigValidation("driver.targetId", { why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver["targetId"]})` });
66
- if (typeof driver["create"] !== "function") throw errorConfigValidation("driver.create", { why: "Config.driver must have create: function" });
67
- }
68
- if (configObj["contract"] !== void 0) {
69
- const contract = configObj["contract"];
70
- if (!contract || typeof contract !== "object") throw errorConfigValidation("contract", { why: "Config.contract must be an object" });
71
- if (!("source" in contract)) throw errorConfigValidation("contract.source", { why: "Config.contract.source is required when contract is provided" });
72
- if (typeof contract["source"] !== "function") throw errorConfigValidation("contract.source", { why: "Config.contract.source must be a provider function" });
73
- if (contract["output"] !== void 0 && typeof contract["output"] !== "string") throw errorConfigValidation("contract.output", { why: "Config.contract.output must be a string when provided" });
74
- }
75
- }
76
-
77
- //#endregion
78
- export { validateConfig };
79
- //# sourceMappingURL=config-validation.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-validation.mjs","names":[],"sources":["../src/config-validation.ts"],"sourcesContent":["import type { PrismaNextConfig } from './config-types';\nimport { errorConfigValidation } from './errors';\n\n/**\n * Validates that the config has the required structure.\n * This is pure validation logic with no file I/O or CLI awareness.\n *\n * @param config - Config object to validate\n * @throws CliStructuredError if config structure is invalid\n */\nexport function validateConfig(config: unknown): asserts config is PrismaNextConfig {\n if (!config || typeof config !== 'object') {\n throw errorConfigValidation('object', {\n why: 'Config must be an object',\n });\n }\n\n const configObj = config as Record<string, unknown>;\n\n if (!configObj['family']) {\n throw errorConfigValidation('family');\n }\n\n if (!configObj['target']) {\n throw errorConfigValidation('target');\n }\n\n if (!configObj['adapter']) {\n throw errorConfigValidation('adapter');\n }\n\n // Validate family descriptor\n const family = configObj['family'] as Record<string, unknown>;\n if (family['kind'] !== 'family') {\n throw errorConfigValidation('family.kind', {\n why: 'Config.family must have kind: \"family\"',\n });\n }\n if (typeof family['familyId'] !== 'string') {\n throw errorConfigValidation('family.familyId', {\n why: 'Config.family must have familyId: string',\n });\n }\n if (typeof family['version'] !== 'string') {\n throw errorConfigValidation('family.version', {\n why: 'Config.family must have version: string',\n });\n }\n if (!family['hook'] || typeof family['hook'] !== 'object') {\n throw errorConfigValidation('family.hook', {\n why: 'Config.family must have hook: TargetFamilyHook',\n });\n }\n if (typeof family['create'] !== 'function') {\n throw errorConfigValidation('family.create', {\n why: 'Config.family must have create: function',\n });\n }\n\n const familyId = family['familyId'] as string;\n\n // Validate target descriptor\n const target = configObj['target'] as Record<string, unknown>;\n if (target['kind'] !== 'target') {\n throw errorConfigValidation('target.kind', {\n why: 'Config.target must have kind: \"target\"',\n });\n }\n if (typeof target['id'] !== 'string') {\n throw errorConfigValidation('target.id', {\n why: 'Config.target must have id: string',\n });\n }\n if (typeof target['familyId'] !== 'string') {\n throw errorConfigValidation('target.familyId', {\n why: 'Config.target must have familyId: string',\n });\n }\n if (typeof target['version'] !== 'string') {\n throw errorConfigValidation('target.version', {\n why: 'Config.target must have version: string',\n });\n }\n if (target['familyId'] !== familyId) {\n throw errorConfigValidation('target.familyId', {\n why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target['familyId']})`,\n });\n }\n if (typeof target['targetId'] !== 'string') {\n throw errorConfigValidation('target.targetId', {\n why: 'Config.target must have targetId: string',\n });\n }\n if (typeof target['create'] !== 'function') {\n throw errorConfigValidation('target.create', {\n why: 'Config.target must have create: function',\n });\n }\n const expectedTargetId = target['targetId'] as string;\n\n // Validate adapter descriptor\n const adapter = configObj['adapter'] as Record<string, unknown>;\n if (adapter['kind'] !== 'adapter') {\n throw errorConfigValidation('adapter.kind', {\n why: 'Config.adapter must have kind: \"adapter\"',\n });\n }\n if (typeof adapter['id'] !== 'string') {\n throw errorConfigValidation('adapter.id', {\n why: 'Config.adapter must have id: string',\n });\n }\n if (typeof adapter['familyId'] !== 'string') {\n throw errorConfigValidation('adapter.familyId', {\n why: 'Config.adapter must have familyId: string',\n });\n }\n if (typeof adapter['version'] !== 'string') {\n throw errorConfigValidation('adapter.version', {\n why: 'Config.adapter must have version: string',\n });\n }\n if (adapter['familyId'] !== familyId) {\n throw errorConfigValidation('adapter.familyId', {\n why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter['familyId']})`,\n });\n }\n if (typeof adapter['targetId'] !== 'string') {\n throw errorConfigValidation('adapter.targetId', {\n why: 'Config.adapter must have targetId: string',\n });\n }\n if (adapter['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('adapter.targetId', {\n why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter['targetId']})`,\n });\n }\n if (typeof adapter['create'] !== 'function') {\n throw errorConfigValidation('adapter.create', {\n why: 'Config.adapter must have create: function',\n });\n }\n\n // Validate extensions array if present\n if (configObj['extensions'] !== undefined) {\n if (!Array.isArray(configObj['extensions'])) {\n throw errorConfigValidation('extensions', {\n why: 'Config.extensions must be an array',\n });\n }\n for (const ext of configObj['extensions']) {\n if (!ext || typeof ext !== 'object') {\n throw errorConfigValidation('extensions[]', {\n why: 'Config.extensions must contain ExtensionDescriptor objects',\n });\n }\n const extObj = ext as Record<string, unknown>;\n if (extObj['kind'] !== 'extension') {\n throw errorConfigValidation('extensions[].kind', {\n why: 'Config.extensions items must have kind: \"extension\"',\n });\n }\n if (typeof extObj['id'] !== 'string') {\n throw errorConfigValidation('extensions[].id', {\n why: 'Config.extensions items must have id: string',\n });\n }\n if (typeof extObj['familyId'] !== 'string') {\n throw errorConfigValidation('extensions[].familyId', {\n why: 'Config.extensions items must have familyId: string',\n });\n }\n if (typeof extObj['version'] !== 'string') {\n throw errorConfigValidation('extensions[].version', {\n why: 'Config.extensions items must have version: string',\n });\n }\n if (extObj['familyId'] !== familyId) {\n throw errorConfigValidation('extensions[].familyId', {\n why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj['familyId']})`,\n });\n }\n if (typeof extObj['targetId'] !== 'string') {\n throw errorConfigValidation('extensions[].targetId', {\n why: 'Config.extensions items must have targetId: string',\n });\n }\n if (extObj['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('extensions[].targetId', {\n why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj['targetId']})`,\n });\n }\n if (typeof extObj['create'] !== 'function') {\n throw errorConfigValidation('extensions[].create', {\n why: 'Config.extensions items must have create: function',\n });\n }\n }\n }\n\n // Validate driver descriptor if present\n if (configObj['driver'] !== undefined) {\n const driver = configObj['driver'] as Record<string, unknown>;\n if (driver['kind'] !== 'driver') {\n throw errorConfigValidation('driver.kind', {\n why: 'Config.driver must have kind: \"driver\"',\n });\n }\n if (typeof driver['id'] !== 'string') {\n throw errorConfigValidation('driver.id', {\n why: 'Config.driver must have id: string',\n });\n }\n if (typeof driver['version'] !== 'string') {\n throw errorConfigValidation('driver.version', {\n why: 'Config.driver must have version: string',\n });\n }\n if (typeof driver['familyId'] !== 'string') {\n throw errorConfigValidation('driver.familyId', {\n why: 'Config.driver must have familyId: string',\n });\n }\n if (driver['familyId'] !== familyId) {\n throw errorConfigValidation('driver.familyId', {\n why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver['familyId']})`,\n });\n }\n if (typeof driver['targetId'] !== 'string') {\n throw errorConfigValidation('driver.targetId', {\n why: 'Config.driver must have targetId: string',\n });\n }\n if (driver['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('driver.targetId', {\n why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver['targetId']})`,\n });\n }\n if (typeof driver['create'] !== 'function') {\n throw errorConfigValidation('driver.create', {\n why: 'Config.driver must have create: function',\n });\n }\n }\n\n // Validate contract config if present (structure validation - defineConfig() handles normalization)\n if (configObj['contract'] !== undefined) {\n const contract = configObj['contract'] as Record<string, unknown>;\n if (!contract || typeof contract !== 'object') {\n throw errorConfigValidation('contract', {\n why: 'Config.contract must be an object',\n });\n }\n if (!('source' in contract)) {\n throw errorConfigValidation('contract.source', {\n why: 'Config.contract.source is required when contract is provided',\n });\n }\n\n if (typeof contract['source'] !== 'function') {\n throw errorConfigValidation('contract.source', {\n why: 'Config.contract.source must be a provider function',\n });\n }\n\n if (contract['output'] !== undefined && typeof contract['output'] !== 'string') {\n throw errorConfigValidation('contract.output', {\n why: 'Config.contract.output must be a string when provided',\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,eAAe,QAAqD;AAClF,KAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,OAAM,sBAAsB,UAAU,EACpC,KAAK,4BACN,CAAC;CAGJ,MAAM,YAAY;AAElB,K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