@prisma-next/core-control-plane 0.3.0-pr.94.3 → 0.3.0-pr.95.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.
Files changed (84) hide show
  1. package/dist/chunk-YT6YGR3N.js +240 -0
  2. package/dist/chunk-YT6YGR3N.js.map +1 -0
  3. package/dist/config-types.d.ts +79 -0
  4. package/dist/config-types.d.ts.map +1 -0
  5. package/dist/config-validation.d.ts +10 -0
  6. package/dist/config-validation.d.ts.map +1 -0
  7. package/dist/emission/canonicalization.d.ts +6 -0
  8. package/dist/emission/canonicalization.d.ts.map +1 -0
  9. package/dist/emission/emit.d.ts +5 -0
  10. package/dist/emission/emit.d.ts.map +1 -0
  11. package/dist/emission/hashing.d.ts +17 -0
  12. package/dist/emission/hashing.d.ts.map +1 -0
  13. package/dist/emission/types.d.ts +21 -0
  14. package/dist/emission/types.d.ts.map +1 -0
  15. package/dist/errors.d.ts +188 -0
  16. package/dist/errors.d.ts.map +1 -0
  17. package/dist/exports/config-types.d.ts +3 -0
  18. package/dist/exports/config-types.d.ts.map +1 -0
  19. package/dist/exports/config-types.js +53 -0
  20. package/dist/exports/config-types.js.map +1 -0
  21. package/dist/exports/config-validation.d.ts +2 -0
  22. package/dist/exports/config-validation.d.ts.map +1 -0
  23. package/dist/exports/config-validation.js +252 -0
  24. package/dist/exports/config-validation.js.map +1 -0
  25. package/dist/exports/emission.d.ts +5 -0
  26. package/dist/exports/emission.d.ts.map +1 -0
  27. package/dist/exports/emission.js +317 -0
  28. package/dist/exports/emission.js.map +1 -0
  29. package/dist/exports/errors.d.ts +3 -0
  30. package/dist/exports/errors.d.ts.map +1 -0
  31. package/dist/exports/errors.js +43 -0
  32. package/dist/exports/errors.js.map +1 -0
  33. package/dist/exports/schema-view.d.ts +2 -0
  34. package/dist/exports/schema-view.d.ts.map +1 -0
  35. package/dist/exports/schema-view.js +1 -0
  36. package/dist/exports/schema-view.js.map +1 -0
  37. package/dist/exports/stack.d.ts +2 -0
  38. package/dist/exports/stack.d.ts.map +1 -0
  39. package/dist/exports/stack.js +13 -0
  40. package/dist/exports/stack.js.map +1 -0
  41. package/dist/exports/types.d.ts +2 -0
  42. package/dist/exports/types.d.ts.map +1 -0
  43. package/dist/exports/types.js +1 -0
  44. package/dist/exports/types.js.map +1 -0
  45. package/dist/migrations.d.ts +190 -0
  46. package/dist/migrations.d.ts.map +1 -0
  47. package/dist/{schema-view-BG_ebqoV.d.mts → schema-view.d.ts} +10 -13
  48. package/dist/schema-view.d.ts.map +1 -0
  49. package/dist/stack.d.ts +25 -0
  50. package/dist/stack.d.ts.map +1 -0
  51. package/dist/types.d.ts +416 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/package.json +36 -20
  54. package/src/emission/emit.ts +8 -1
  55. package/src/emission/types.ts +6 -1
  56. package/dist/config-types-h9ifypQ0.d.mts +0 -79
  57. package/dist/config-types-h9ifypQ0.d.mts.map +0 -1
  58. package/dist/config-types.d.mts +0 -2
  59. package/dist/config-types.mjs +0 -65
  60. package/dist/config-types.mjs.map +0 -1
  61. package/dist/config-validation.d.mts +0 -15
  62. package/dist/config-validation.d.mts.map +0 -1
  63. package/dist/config-validation.mjs +0 -79
  64. package/dist/config-validation.mjs.map +0 -1
  65. package/dist/emission.d.mts +0 -47
  66. package/dist/emission.d.mts.map +0 -1
  67. package/dist/emission.mjs +0 -255
  68. package/dist/emission.mjs.map +0 -1
  69. package/dist/errors-Qlh0sdcb.mjs +0 -276
  70. package/dist/errors-Qlh0sdcb.mjs.map +0 -1
  71. package/dist/errors.d.mts +0 -191
  72. package/dist/errors.d.mts.map +0 -1
  73. package/dist/errors.mjs +0 -3
  74. package/dist/schema-view-BG_ebqoV.d.mts.map +0 -1
  75. package/dist/schema-view.d.mts +0 -2
  76. package/dist/schema-view.mjs +0 -1
  77. package/dist/stack.d.mts +0 -30
  78. package/dist/stack.d.mts.map +0 -1
  79. package/dist/stack.mjs +0 -30
  80. package/dist/stack.mjs.map +0 -1
  81. package/dist/types-CsaU_uQP.d.mts +0 -595
  82. package/dist/types-CsaU_uQP.d.mts.map +0 -1
  83. package/dist/types.d.mts +0 -2
  84. package/dist/types.mjs +0 -1
@@ -0,0 +1,3 @@
1
+ export type { ContractConfig, PrismaNextConfig, } from '../config-types';
2
+ export { defineConfig } from '../config-types';
3
+ //# sourceMappingURL=config-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../../src/exports/config-types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,53 @@
1
+ // src/config-types.ts
2
+ import { dirname, join } from "path";
3
+ import { type } from "arktype";
4
+ var ContractConfigSchema = type({
5
+ source: "unknown",
6
+ // Can be value or function - runtime check needed
7
+ "output?": "string",
8
+ "types?": "string"
9
+ });
10
+ var PrismaNextConfigSchema = type({
11
+ family: "unknown",
12
+ // ControlFamilyDescriptor - validated separately
13
+ target: "unknown",
14
+ // ControlTargetDescriptor - validated separately
15
+ adapter: "unknown",
16
+ // ControlAdapterDescriptor - validated separately
17
+ "extensionPacks?": "unknown[]",
18
+ "driver?": "unknown",
19
+ // ControlDriverDescriptor - validated separately (optional)
20
+ "db?": "unknown",
21
+ "contract?": ContractConfigSchema
22
+ });
23
+ function defineConfig(config) {
24
+ const validated = PrismaNextConfigSchema(config);
25
+ if (validated instanceof type.errors) {
26
+ const messages = validated.map((p) => p.message).join("; ");
27
+ throw new Error(`Config validation failed: ${messages}`);
28
+ }
29
+ if (config.contract) {
30
+ const source = config.contract.source;
31
+ if (source !== null && typeof source !== "object" && typeof source !== "function" && typeof source !== "string" && typeof source !== "number" && typeof source !== "boolean") {
32
+ throw new Error(
33
+ "Config.contract.source must be a value (object, string, number, boolean, null) or a function"
34
+ );
35
+ }
36
+ const output = config.contract.output ?? "src/prisma/contract.json";
37
+ const types = config.contract.types ?? (output.endsWith(".json") ? `${output.slice(0, -5)}.d.ts` : join(dirname(output), "contract.d.ts"));
38
+ const normalizedContract = {
39
+ source: config.contract.source,
40
+ output,
41
+ types
42
+ };
43
+ return {
44
+ ...config,
45
+ contract: normalizedContract
46
+ };
47
+ }
48
+ return config;
49
+ }
50
+ export {
51
+ defineConfig
52
+ };
53
+ //# sourceMappingURL=config-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/config-types.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { type } from 'arktype';\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. Can be a value or a function that returns a value (sync or async).\n * If a function, it will be called to resolve the contract.\n */\n readonly source: unknown | (() => unknown | Promise<unknown>);\n /**\n * Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.\n * This is the canonical location where other CLI commands can find the contract JSON.\n */\n readonly output?: string;\n /**\n * Path to contract.d.ts artifact. Defaults to output with .d.ts extension.\n * If output ends with .json, replaces .json with .d.ts.\n * Otherwise, appends .d.ts to the directory containing output.\n */\n readonly types?: 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 that source is present and output/types are strings when provided.\n */\nconst ContractConfigSchema = type({\n source: 'unknown', // Can be value or function - runtime check needed\n 'output?': 'string',\n 'types?': '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 * - contract.types defaults to output with .d.ts extension 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 is a value or function (runtime check)\n const source = config.contract.source;\n if (\n source !== null &&\n typeof source !== 'object' &&\n typeof source !== 'function' &&\n typeof source !== 'string' &&\n typeof source !== 'number' &&\n typeof source !== 'boolean'\n ) {\n throw new Error(\n 'Config.contract.source must be a value (object, string, number, boolean, null) or a function',\n );\n }\n\n // Apply defaults\n const output = config.contract.output ?? 'src/prisma/contract.json';\n const types =\n config.contract.types ??\n (output.endsWith('.json')\n ? `${output.slice(0, -5)}.d.ts`\n : join(dirname(output), 'contract.d.ts'));\n\n const normalizedContract: ContractConfig = {\n source: config.contract.source,\n output,\n types,\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":";AAAA,SAAS,SAAS,YAAY;AAC9B,SAAS,YAAY;AA0FrB,IAAM,uBAAuB,KAAK;AAAA,EAChC,QAAQ;AAAA;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AACZ,CAAC;AAMD,IAAM,yBAAyB,KAAK;AAAA,EAClC,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA;AAAA,EACR,SAAS;AAAA;AAAA,EACT,mBAAmB;AAAA,EACnB,WAAW;AAAA;AAAA,EACX,OAAO;AAAA,EACP,aAAa;AACf,CAAC;AAcM,SAAS,aACd,QACwC;AAExC,QAAM,YAAY,uBAAuB,MAAM;AAC/C,MAAI,qBAAqB,KAAK,QAAQ;AACpC,UAAM,WAAW,UAAU,IAAI,CAAC,MAA2B,EAAE,OAAO,EAAE,KAAK,IAAI;AAC/E,UAAM,IAAI,MAAM,6BAA6B,QAAQ,EAAE;AAAA,EACzD;AAGA,MAAI,OAAO,UAAU;AAEnB,UAAM,SAAS,OAAO,SAAS;AAC/B,QACE,WAAW,QACX,OAAO,WAAW,YAClB,OAAO,WAAW,cAClB,OAAO,WAAW,YAClB,OAAO,WAAW,YAClB,OAAO,WAAW,WAClB;AACA,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAGA,UAAM,SAAS,OAAO,SAAS,UAAU;AACzC,UAAM,QACJ,OAAO,SAAS,UACf,OAAO,SAAS,OAAO,IACpB,GAAG,OAAO,MAAM,GAAG,EAAE,CAAC,UACtB,KAAK,QAAQ,MAAM,GAAG,eAAe;AAE3C,UAAM,qBAAqC;AAAA,MACzC,QAAQ,OAAO,SAAS;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AAGA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,UAAU;AAAA,IACZ;AAAA,EACF;AAGA,SAAO;AACT;","names":[]}
@@ -0,0 +1,2 @@
1
+ export { validateConfig } from '../config-validation';
2
+ //# sourceMappingURL=config-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../../src/exports/config-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,252 @@
1
+ import {
2
+ errorConfigValidation
3
+ } from "../chunk-YT6YGR3N.js";
4
+
5
+ // src/config-validation.ts
6
+ function validateConfig(config) {
7
+ if (!config || typeof config !== "object") {
8
+ throw errorConfigValidation("object", {
9
+ why: "Config must be an object"
10
+ });
11
+ }
12
+ const configObj = config;
13
+ if (!configObj["family"]) {
14
+ throw errorConfigValidation("family");
15
+ }
16
+ if (!configObj["target"]) {
17
+ throw errorConfigValidation("target");
18
+ }
19
+ if (!configObj["adapter"]) {
20
+ throw errorConfigValidation("adapter");
21
+ }
22
+ const family = configObj["family"];
23
+ if (family["kind"] !== "family") {
24
+ throw errorConfigValidation("family.kind", {
25
+ why: 'Config.family must have kind: "family"'
26
+ });
27
+ }
28
+ if (typeof family["familyId"] !== "string") {
29
+ throw errorConfigValidation("family.familyId", {
30
+ why: "Config.family must have familyId: string"
31
+ });
32
+ }
33
+ if (typeof family["version"] !== "string") {
34
+ throw errorConfigValidation("family.version", {
35
+ why: "Config.family must have version: string"
36
+ });
37
+ }
38
+ if (!family["hook"] || typeof family["hook"] !== "object") {
39
+ throw errorConfigValidation("family.hook", {
40
+ why: "Config.family must have hook: TargetFamilyHook"
41
+ });
42
+ }
43
+ if (typeof family["create"] !== "function") {
44
+ throw errorConfigValidation("family.create", {
45
+ why: "Config.family must have create: function"
46
+ });
47
+ }
48
+ const familyId = family["familyId"];
49
+ const target = configObj["target"];
50
+ if (target["kind"] !== "target") {
51
+ throw errorConfigValidation("target.kind", {
52
+ why: 'Config.target must have kind: "target"'
53
+ });
54
+ }
55
+ if (typeof target["id"] !== "string") {
56
+ throw errorConfigValidation("target.id", {
57
+ why: "Config.target must have id: string"
58
+ });
59
+ }
60
+ if (typeof target["familyId"] !== "string") {
61
+ throw errorConfigValidation("target.familyId", {
62
+ why: "Config.target must have familyId: string"
63
+ });
64
+ }
65
+ if (typeof target["version"] !== "string") {
66
+ throw errorConfigValidation("target.version", {
67
+ why: "Config.target must have version: string"
68
+ });
69
+ }
70
+ if (target["familyId"] !== familyId) {
71
+ throw errorConfigValidation("target.familyId", {
72
+ why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target["familyId"]})`
73
+ });
74
+ }
75
+ if (typeof target["targetId"] !== "string") {
76
+ throw errorConfigValidation("target.targetId", {
77
+ why: "Config.target must have targetId: string"
78
+ });
79
+ }
80
+ if (typeof target["create"] !== "function") {
81
+ throw errorConfigValidation("target.create", {
82
+ why: "Config.target must have create: function"
83
+ });
84
+ }
85
+ const expectedTargetId = target["targetId"];
86
+ const adapter = configObj["adapter"];
87
+ if (adapter["kind"] !== "adapter") {
88
+ throw errorConfigValidation("adapter.kind", {
89
+ why: 'Config.adapter must have kind: "adapter"'
90
+ });
91
+ }
92
+ if (typeof adapter["id"] !== "string") {
93
+ throw errorConfigValidation("adapter.id", {
94
+ why: "Config.adapter must have id: string"
95
+ });
96
+ }
97
+ if (typeof adapter["familyId"] !== "string") {
98
+ throw errorConfigValidation("adapter.familyId", {
99
+ why: "Config.adapter must have familyId: string"
100
+ });
101
+ }
102
+ if (typeof adapter["version"] !== "string") {
103
+ throw errorConfigValidation("adapter.version", {
104
+ why: "Config.adapter must have version: string"
105
+ });
106
+ }
107
+ if (adapter["familyId"] !== familyId) {
108
+ throw errorConfigValidation("adapter.familyId", {
109
+ why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter["familyId"]})`
110
+ });
111
+ }
112
+ if (typeof adapter["targetId"] !== "string") {
113
+ throw errorConfigValidation("adapter.targetId", {
114
+ why: "Config.adapter must have targetId: string"
115
+ });
116
+ }
117
+ if (adapter["targetId"] !== expectedTargetId) {
118
+ throw errorConfigValidation("adapter.targetId", {
119
+ why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter["targetId"]})`
120
+ });
121
+ }
122
+ if (typeof adapter["create"] !== "function") {
123
+ throw errorConfigValidation("adapter.create", {
124
+ why: "Config.adapter must have create: function"
125
+ });
126
+ }
127
+ if (configObj["extensions"] !== void 0) {
128
+ if (!Array.isArray(configObj["extensions"])) {
129
+ throw errorConfigValidation("extensions", {
130
+ why: "Config.extensions must be an array"
131
+ });
132
+ }
133
+ for (const ext of configObj["extensions"]) {
134
+ if (!ext || typeof ext !== "object") {
135
+ throw errorConfigValidation("extensions[]", {
136
+ why: "Config.extensions must contain ExtensionDescriptor objects"
137
+ });
138
+ }
139
+ const extObj = ext;
140
+ if (extObj["kind"] !== "extension") {
141
+ throw errorConfigValidation("extensions[].kind", {
142
+ why: 'Config.extensions items must have kind: "extension"'
143
+ });
144
+ }
145
+ if (typeof extObj["id"] !== "string") {
146
+ throw errorConfigValidation("extensions[].id", {
147
+ why: "Config.extensions items must have id: string"
148
+ });
149
+ }
150
+ if (typeof extObj["familyId"] !== "string") {
151
+ throw errorConfigValidation("extensions[].familyId", {
152
+ why: "Config.extensions items must have familyId: string"
153
+ });
154
+ }
155
+ if (typeof extObj["version"] !== "string") {
156
+ throw errorConfigValidation("extensions[].version", {
157
+ why: "Config.extensions items must have version: string"
158
+ });
159
+ }
160
+ if (extObj["familyId"] !== familyId) {
161
+ throw errorConfigValidation("extensions[].familyId", {
162
+ why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj["familyId"]})`
163
+ });
164
+ }
165
+ if (typeof extObj["targetId"] !== "string") {
166
+ throw errorConfigValidation("extensions[].targetId", {
167
+ why: "Config.extensions items must have targetId: string"
168
+ });
169
+ }
170
+ if (extObj["targetId"] !== expectedTargetId) {
171
+ throw errorConfigValidation("extensions[].targetId", {
172
+ why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj["targetId"]})`
173
+ });
174
+ }
175
+ if (typeof extObj["create"] !== "function") {
176
+ throw errorConfigValidation("extensions[].create", {
177
+ why: "Config.extensions items must have create: function"
178
+ });
179
+ }
180
+ }
181
+ }
182
+ if (configObj["driver"] !== void 0) {
183
+ const driver = configObj["driver"];
184
+ if (driver["kind"] !== "driver") {
185
+ throw errorConfigValidation("driver.kind", {
186
+ why: 'Config.driver must have kind: "driver"'
187
+ });
188
+ }
189
+ if (typeof driver["id"] !== "string") {
190
+ throw errorConfigValidation("driver.id", {
191
+ why: "Config.driver must have id: string"
192
+ });
193
+ }
194
+ if (typeof driver["version"] !== "string") {
195
+ throw errorConfigValidation("driver.version", {
196
+ why: "Config.driver must have version: string"
197
+ });
198
+ }
199
+ if (typeof driver["familyId"] !== "string") {
200
+ throw errorConfigValidation("driver.familyId", {
201
+ why: "Config.driver must have familyId: string"
202
+ });
203
+ }
204
+ if (driver["familyId"] !== familyId) {
205
+ throw errorConfigValidation("driver.familyId", {
206
+ why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver["familyId"]})`
207
+ });
208
+ }
209
+ if (typeof driver["targetId"] !== "string") {
210
+ throw errorConfigValidation("driver.targetId", {
211
+ why: "Config.driver must have targetId: string"
212
+ });
213
+ }
214
+ if (driver["targetId"] !== expectedTargetId) {
215
+ throw errorConfigValidation("driver.targetId", {
216
+ why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver["targetId"]})`
217
+ });
218
+ }
219
+ if (typeof driver["create"] !== "function") {
220
+ throw errorConfigValidation("driver.create", {
221
+ why: "Config.driver must have create: function"
222
+ });
223
+ }
224
+ }
225
+ if (configObj["contract"] !== void 0) {
226
+ const contract = configObj["contract"];
227
+ if (!contract || typeof contract !== "object") {
228
+ throw errorConfigValidation("contract", {
229
+ why: "Config.contract must be an object"
230
+ });
231
+ }
232
+ if (!("source" in contract)) {
233
+ throw errorConfigValidation("contract.source", {
234
+ why: "Config.contract.source is required when contract is provided"
235
+ });
236
+ }
237
+ if (contract["output"] !== void 0 && typeof contract["output"] !== "string") {
238
+ throw errorConfigValidation("contract.output", {
239
+ why: "Config.contract.output must be a string when provided"
240
+ });
241
+ }
242
+ if (contract["types"] !== void 0 && typeof contract["types"] !== "string") {
243
+ throw errorConfigValidation("contract.types", {
244
+ why: "Config.contract.types must be a string when provided"
245
+ });
246
+ }
247
+ }
248
+ }
249
+ export {
250
+ validateConfig
251
+ };
252
+ //# sourceMappingURL=config-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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 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 if (contract['types'] !== undefined && typeof contract['types'] !== 'string') {\n throw errorConfigValidation('contract.types', {\n why: 'Config.contract.types must be a string when provided',\n });\n }\n }\n}\n"],"mappings":";;;;;AAUO,SAAS,eAAe,QAAqD;AAClF,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,sBAAsB,UAAU;AAAA,MACpC,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AAEA,QAAM,YAAY;AAElB,MAAI,CAAC,UAAU,QAAQ,GAAG;AACxB,UAAM,sBAAsB,QAAQ;AAAA,EACtC;AAEA,MAAI,CAAC,UAAU,QAAQ,GAAG;AACxB,UAAM,sBAAsB,QAAQ;AAAA,EACtC;AAEA,MAAI,CAAC,UAAU,SAAS,GAAG;AACzB,UAAM,sBAAsB,SAAS;AAAA,EACvC;AAGA,QAAM,SAAS,UAAU,QAAQ;AACjC,MAAI,OAAO,MAAM,MAAM,UAAU;AAC/B,UAAM,sBAAsB,eAAe;AAAA,MACzC,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,MAAI,OAAO,OAAO,UAAU,MAAM,UAAU;AAC1C,UAAM,sBAAsB,mBAAmB;AAAA,MAC7C,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AAO,aAAa,UAAU;AAC7C,YAAM,sBAAsB,YAAY;AAAA,QACtC,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,EAAE,YAAY,WAAW;AAC3B,YAAM,sBAAsB,mBAAmB;AAAA,QAC7C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,SAAS,QAAQ,MAAM,UAAa,OAAO,SAAS,QAAQ,MAAM,UAAU;AAC9E,YAAM,sBAAsB,mBAAmB;AAAA,QAC7C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,SAAS,OAAO,MAAM,UAAa,OAAO,SAAS,OAAO,MAAM,UAAU;AAC5E,YAAM,sBAAsB,kBAAkB;AAAA,QAC5C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,5 @@
1
+ export { canonicalizeContract } from '../emission/canonicalization';
2
+ export { emit } from '../emission/emit';
3
+ export { computeCoreHash, computeProfileHash } from '../emission/hashing';
4
+ export type { EmitOptions, EmitResult } from '../emission/types';
5
+ //# sourceMappingURL=emission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emission.d.ts","sourceRoot":"","sources":["../../src/exports/emission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}