@prisma-next/core-control-plane 0.3.0-dev.3 → 0.3.0-dev.30

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 (67) hide show
  1. package/README.md +29 -0
  2. package/dist/config-types-h9ifypQ0.d.mts +79 -0
  3. package/dist/config-types-h9ifypQ0.d.mts.map +1 -0
  4. package/dist/config-types.d.mts +2 -0
  5. package/dist/config-types.mjs +65 -0
  6. package/dist/config-types.mjs.map +1 -0
  7. package/dist/{exports/config-validation.d.ts → config-validation.d.mts} +5 -8
  8. package/dist/config-validation.d.mts.map +1 -0
  9. package/dist/config-validation.mjs +79 -0
  10. package/dist/config-validation.mjs.map +1 -0
  11. package/dist/emission.d.mts +57 -0
  12. package/dist/emission.d.mts.map +1 -0
  13. package/dist/emission.mjs +261 -0
  14. package/dist/emission.mjs.map +1 -0
  15. package/dist/errors-Qlh0sdcb.mjs +276 -0
  16. package/dist/errors-Qlh0sdcb.mjs.map +1 -0
  17. package/dist/{exports/errors.d.ts → errors.d.mts} +86 -79
  18. package/dist/errors.d.mts.map +1 -0
  19. package/dist/errors.mjs +3 -0
  20. package/dist/{exports/schema-view.d.ts → schema-view-BG_ebqoV.d.mts} +10 -8
  21. package/dist/schema-view-BG_ebqoV.d.mts.map +1 -0
  22. package/dist/schema-view.d.mts +2 -0
  23. package/dist/schema-view.mjs +1 -0
  24. package/dist/stack.d.mts +30 -0
  25. package/dist/stack.d.mts.map +1 -0
  26. package/dist/stack.mjs +30 -0
  27. package/dist/stack.mjs.map +1 -0
  28. package/dist/types-CsaU_uQP.d.mts +595 -0
  29. package/dist/types-CsaU_uQP.d.mts.map +1 -0
  30. package/dist/types.d.mts +2 -0
  31. package/dist/types.mjs +1 -0
  32. package/package.json +29 -40
  33. package/src/config-types.ts +174 -0
  34. package/src/config-validation.ts +270 -0
  35. package/src/emission/canonicalization.ts +253 -0
  36. package/src/emission/emit.ts +135 -0
  37. package/src/emission/hashing.ts +57 -0
  38. package/src/emission/types.ts +27 -0
  39. package/src/errors.ts +445 -0
  40. package/src/exports/config-types.ts +5 -0
  41. package/src/exports/config-validation.ts +1 -0
  42. package/src/exports/emission.ts +6 -0
  43. package/src/exports/errors.ts +22 -0
  44. package/src/exports/schema-view.ts +1 -0
  45. package/src/exports/stack.ts +1 -0
  46. package/src/exports/types.ts +38 -0
  47. package/src/migrations.ts +247 -0
  48. package/src/schema-view.ts +95 -0
  49. package/src/stack.ts +38 -0
  50. package/src/types.ts +530 -0
  51. package/dist/chunk-U5RYT6PT.js +0 -229
  52. package/dist/chunk-U5RYT6PT.js.map +0 -1
  53. package/dist/exports/config-types.d.ts +0 -70
  54. package/dist/exports/config-types.js +0 -53
  55. package/dist/exports/config-types.js.map +0 -1
  56. package/dist/exports/config-validation.js +0 -252
  57. package/dist/exports/config-validation.js.map +0 -1
  58. package/dist/exports/emission.d.ts +0 -42
  59. package/dist/exports/emission.js +0 -310
  60. package/dist/exports/emission.js.map +0 -1
  61. package/dist/exports/errors.js +0 -43
  62. package/dist/exports/errors.js.map +0 -1
  63. package/dist/exports/schema-view.js +0 -1
  64. package/dist/exports/schema-view.js.map +0 -1
  65. package/dist/exports/types.d.ts +0 -589
  66. package/dist/exports/types.js +0 -1
  67. package/dist/exports/types.js.map +0 -1
@@ -0,0 +1,261 @@
1
+ import { isArrayEqual } from "@prisma-next/utils/array-equal";
2
+ import { ifDefined } from "@prisma-next/utils/defined";
3
+ import { format } from "prettier";
4
+ import { createHash } from "node:crypto";
5
+
6
+ //#region src/emission/canonicalization.ts
7
+ const TOP_LEVEL_ORDER = [
8
+ "schemaVersion",
9
+ "canonicalVersion",
10
+ "targetFamily",
11
+ "target",
12
+ "coreHash",
13
+ "profileHash",
14
+ "models",
15
+ "storage",
16
+ "capabilities",
17
+ "extensionPacks",
18
+ "meta",
19
+ "sources"
20
+ ];
21
+ function isDefaultValue(value) {
22
+ if (value === false) return true;
23
+ if (value === null) return false;
24
+ if (Array.isArray(value) && value.length === 0) return true;
25
+ if (typeof value === "object" && value !== null) return Object.keys(value).length === 0;
26
+ return false;
27
+ }
28
+ function omitDefaults(obj, path) {
29
+ if (obj === null || typeof obj !== "object") return obj;
30
+ if (Array.isArray(obj)) return obj.map((item) => omitDefaults(item, path));
31
+ const result = {};
32
+ for (const [key, value] of Object.entries(obj)) {
33
+ const currentPath = [...path, key];
34
+ if (key === "_generated") continue;
35
+ if (key === "nullable" && value === false) continue;
36
+ if (key === "generated" && value === false) continue;
37
+ if (isDefaultValue(value)) {
38
+ const isRequiredModels = isArrayEqual(currentPath, ["models"]);
39
+ const isRequiredTables = isArrayEqual(currentPath, ["storage", "tables"]);
40
+ const isRequiredRelations = isArrayEqual(currentPath, ["relations"]);
41
+ const isRequiredExtensionPacks = isArrayEqual(currentPath, ["extensionPacks"]);
42
+ const isRequiredCapabilities = isArrayEqual(currentPath, ["capabilities"]);
43
+ const isRequiredMeta = isArrayEqual(currentPath, ["meta"]);
44
+ const isRequiredSources = isArrayEqual(currentPath, ["sources"]);
45
+ const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === "extensionPacks";
46
+ const isModelRelations = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[2]], ["models", "relations"]);
47
+ const isTableUniques = currentPath.length === 4 && isArrayEqual([
48
+ currentPath[0],
49
+ currentPath[1],
50
+ currentPath[3]
51
+ ], [
52
+ "storage",
53
+ "tables",
54
+ "uniques"
55
+ ]);
56
+ const isTableIndexes = currentPath.length === 4 && isArrayEqual([
57
+ currentPath[0],
58
+ currentPath[1],
59
+ currentPath[3]
60
+ ], [
61
+ "storage",
62
+ "tables",
63
+ "indexes"
64
+ ]);
65
+ const isTableForeignKeys = currentPath.length === 4 && isArrayEqual([
66
+ currentPath[0],
67
+ currentPath[1],
68
+ currentPath[3]
69
+ ], [
70
+ "storage",
71
+ "tables",
72
+ "foreignKeys"
73
+ ]);
74
+ if (!isRequiredModels && !isRequiredTables && !isRequiredRelations && !isRequiredExtensionPacks && !isRequiredCapabilities && !isRequiredMeta && !isRequiredSources && !isExtensionNamespace && !isModelRelations && !isTableUniques && !isTableIndexes && !isTableForeignKeys) continue;
75
+ }
76
+ result[key] = omitDefaults(value, currentPath);
77
+ }
78
+ return result;
79
+ }
80
+ function sortObjectKeys(obj) {
81
+ if (obj === null || typeof obj !== "object") return obj;
82
+ if (Array.isArray(obj)) return obj.map((item) => sortObjectKeys(item));
83
+ const sorted = {};
84
+ const keys = Object.keys(obj).sort();
85
+ for (const key of keys) sorted[key] = sortObjectKeys(obj[key]);
86
+ return sorted;
87
+ }
88
+ function sortIndexesAndUniques(storage) {
89
+ if (!storage || typeof storage !== "object") return storage;
90
+ const storageObj = storage;
91
+ if (!storageObj.tables || typeof storageObj.tables !== "object") return storage;
92
+ const tables = storageObj.tables;
93
+ const result = { ...storageObj };
94
+ result.tables = {};
95
+ const sortedTableNames = Object.keys(tables).sort();
96
+ for (const tableName of sortedTableNames) {
97
+ const table = tables[tableName];
98
+ if (!table || typeof table !== "object") {
99
+ result.tables[tableName] = table;
100
+ continue;
101
+ }
102
+ const tableObj = table;
103
+ const sortedTable = { ...tableObj };
104
+ if (Array.isArray(tableObj.indexes)) sortedTable.indexes = [...tableObj.indexes].sort((a, b) => {
105
+ const nameA = a?.name || "";
106
+ const nameB = b?.name || "";
107
+ return nameA.localeCompare(nameB);
108
+ });
109
+ if (Array.isArray(tableObj.uniques)) sortedTable.uniques = [...tableObj.uniques].sort((a, b) => {
110
+ const nameA = a?.name || "";
111
+ const nameB = b?.name || "";
112
+ return nameA.localeCompare(nameB);
113
+ });
114
+ result.tables[tableName] = sortedTable;
115
+ }
116
+ return result;
117
+ }
118
+ function orderTopLevel(obj) {
119
+ const ordered = {};
120
+ const remaining = new Set(Object.keys(obj));
121
+ for (const key of TOP_LEVEL_ORDER) if (remaining.has(key)) {
122
+ ordered[key] = obj[key];
123
+ remaining.delete(key);
124
+ }
125
+ for (const key of Array.from(remaining).sort()) ordered[key] = obj[key];
126
+ return ordered;
127
+ }
128
+ function canonicalizeContract(ir) {
129
+ const normalized = {
130
+ schemaVersion: ir.schemaVersion,
131
+ targetFamily: ir.targetFamily,
132
+ target: ir.target,
133
+ models: ir.models,
134
+ relations: ir.relations,
135
+ storage: ir.storage,
136
+ extensionPacks: ir.extensionPacks,
137
+ capabilities: ir.capabilities,
138
+ meta: ir.meta,
139
+ sources: ir.sources
140
+ };
141
+ if (ir.coreHash !== void 0) normalized.coreHash = ir.coreHash;
142
+ if (ir.profileHash !== void 0) normalized.profileHash = ir.profileHash;
143
+ const withDefaultsOmitted = omitDefaults(normalized, []);
144
+ const withSortedIndexes = sortIndexesAndUniques(withDefaultsOmitted.storage);
145
+ const withOrderedTopLevel = orderTopLevel(sortObjectKeys({
146
+ ...withDefaultsOmitted,
147
+ storage: withSortedIndexes
148
+ }));
149
+ return JSON.stringify(withOrderedTopLevel, null, 2);
150
+ }
151
+
152
+ //#endregion
153
+ //#region src/emission/hashing.ts
154
+ function computeHash(content) {
155
+ const hash = createHash("sha256");
156
+ hash.update(content);
157
+ return `sha256:${hash.digest("hex")}`;
158
+ }
159
+ function computeCoreHash(contract) {
160
+ return computeHash(canonicalizeContract({
161
+ schemaVersion: contract.schemaVersion,
162
+ targetFamily: contract.targetFamily,
163
+ target: contract.target,
164
+ models: contract.models,
165
+ relations: contract.relations,
166
+ storage: contract.storage,
167
+ extensionPacks: contract.extensionPacks,
168
+ sources: contract.sources,
169
+ capabilities: contract.capabilities,
170
+ meta: contract.meta
171
+ }));
172
+ }
173
+ function computeProfileHash(contract) {
174
+ return computeHash(canonicalizeContract({
175
+ schemaVersion: contract.schemaVersion,
176
+ targetFamily: contract.targetFamily,
177
+ target: contract.target,
178
+ models: {},
179
+ relations: {},
180
+ storage: {},
181
+ extensionPacks: {},
182
+ capabilities: contract.capabilities,
183
+ meta: {},
184
+ sources: {}
185
+ }));
186
+ }
187
+
188
+ //#endregion
189
+ //#region src/emission/emit.ts
190
+ function validateCoreStructure(ir) {
191
+ if (!ir.targetFamily) throw new Error("ContractIR must have targetFamily");
192
+ if (!ir.target) throw new Error("ContractIR must have target");
193
+ if (!ir.schemaVersion) throw new Error("ContractIR must have schemaVersion");
194
+ if (!ir.models || typeof ir.models !== "object") throw new Error("ContractIR must have models");
195
+ if (!ir.storage || typeof ir.storage !== "object") throw new Error("ContractIR must have storage");
196
+ if (!ir.relations || typeof ir.relations !== "object") throw new Error("ContractIR must have relations");
197
+ if (!ir.extensionPacks || typeof ir.extensionPacks !== "object") throw new Error("ContractIR must have extensionPacks");
198
+ if (!ir.capabilities || typeof ir.capabilities !== "object") throw new Error("ContractIR must have capabilities");
199
+ if (!ir.meta || typeof ir.meta !== "object") throw new Error("ContractIR must have meta");
200
+ if (!ir.sources || typeof ir.sources !== "object") throw new Error("ContractIR must have sources");
201
+ }
202
+ async function emit(ir, options, targetFamily) {
203
+ const { operationRegistry, codecTypeImports, operationTypeImports, extensionIds, parameterizedRenderers, parameterizedTypeImports } = options;
204
+ validateCoreStructure(ir);
205
+ const ctx = {
206
+ ...ifDefined("operationRegistry", operationRegistry),
207
+ ...ifDefined("codecTypeImports", codecTypeImports),
208
+ ...ifDefined("operationTypeImports", operationTypeImports),
209
+ ...ifDefined("extensionIds", extensionIds)
210
+ };
211
+ targetFamily.validateTypes(ir, ctx);
212
+ targetFamily.validateStructure(ir);
213
+ const contractJson = {
214
+ schemaVersion: ir.schemaVersion,
215
+ targetFamily: ir.targetFamily,
216
+ target: ir.target,
217
+ models: ir.models,
218
+ relations: ir.relations,
219
+ storage: ir.storage,
220
+ extensionPacks: ir.extensionPacks,
221
+ capabilities: ir.capabilities,
222
+ meta: ir.meta,
223
+ sources: ir.sources
224
+ };
225
+ const coreHash = computeCoreHash(contractJson);
226
+ const profileHash = computeProfileHash(contractJson);
227
+ const contractWithHashes = {
228
+ ...ir,
229
+ schemaVersion: contractJson.schemaVersion,
230
+ coreHash,
231
+ profileHash
232
+ };
233
+ const contractJsonWithMeta = {
234
+ ...JSON.parse(canonicalizeContract(contractWithHashes)),
235
+ _generated: {
236
+ warning: "⚠️ GENERATED FILE - DO NOT EDIT",
237
+ message: "This file is automatically generated by \"prisma-next contract emit\".",
238
+ regenerate: "To regenerate, run: prisma-next contract emit"
239
+ }
240
+ };
241
+ const contractJsonString = JSON.stringify(contractJsonWithMeta, null, 2);
242
+ const generateOptions = parameterizedRenderers || parameterizedTypeImports ? {
243
+ ...ifDefined("parameterizedRenderers", parameterizedRenderers),
244
+ ...ifDefined("parameterizedTypeImports", parameterizedTypeImports)
245
+ } : void 0;
246
+ return {
247
+ contractJson: contractJsonString,
248
+ contractDts: await format(targetFamily.generateContractTypes(ir, codecTypeImports ?? [], operationTypeImports ?? [], generateOptions), {
249
+ parser: "typescript",
250
+ singleQuote: true,
251
+ semi: true,
252
+ printWidth: 100
253
+ }),
254
+ coreHash,
255
+ profileHash
256
+ };
257
+ }
258
+
259
+ //#endregion
260
+ export { canonicalizeContract, computeCoreHash, computeProfileHash, emit };
261
+ //# sourceMappingURL=emission.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emission.mjs","names":["result: Record<string, unknown>","sorted: Record<string, unknown>","result: StorageObject","sortedTable: TableObject","ordered: Record<string, unknown>","normalized: NormalizedContract","ctx: ValidationContext","contractWithHashes: ContractIR & { coreHash?: string; profileHash?: string }"],"sources":["../src/emission/canonicalization.ts","../src/emission/hashing.ts","../src/emission/emit.ts"],"sourcesContent":["import type { ContractIR } from '@prisma-next/contract/ir';\nimport { isArrayEqual } from '@prisma-next/utils/array-equal';\n\ntype NormalizedContract = {\n schemaVersion: string;\n targetFamily: string;\n target: string;\n coreHash?: string;\n profileHash?: string;\n models: Record<string, unknown>;\n relations: Record<string, unknown>;\n storage: Record<string, unknown>;\n extensionPacks: Record<string, unknown>;\n capabilities: Record<string, Record<string, boolean>>;\n meta: Record<string, unknown>;\n sources: Record<string, unknown>;\n};\n\nconst TOP_LEVEL_ORDER = [\n 'schemaVersion',\n 'canonicalVersion',\n 'targetFamily',\n 'target',\n 'coreHash',\n 'profileHash',\n 'models',\n 'storage',\n 'capabilities',\n 'extensionPacks',\n 'meta',\n 'sources',\n] as const;\n\nfunction isDefaultValue(value: unknown): boolean {\n if (value === false) return true;\n if (value === null) return false;\n if (Array.isArray(value) && value.length === 0) return true;\n if (typeof value === 'object' && value !== null) {\n const keys = Object.keys(value);\n return keys.length === 0;\n }\n return false;\n}\n\nfunction omitDefaults(obj: unknown, path: readonly string[]): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => omitDefaults(item, path));\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n const currentPath = [...path, key];\n\n // Exclude metadata fields from canonicalization\n if (key === '_generated') {\n continue;\n }\n\n if (key === 'nullable' && value === false) {\n continue;\n }\n\n if (key === 'generated' && value === false) {\n continue;\n }\n\n if (isDefaultValue(value)) {\n const isRequiredModels = isArrayEqual(currentPath, ['models']);\n const isRequiredTables = isArrayEqual(currentPath, ['storage', 'tables']);\n const isRequiredRelations = isArrayEqual(currentPath, ['relations']);\n const isRequiredExtensionPacks = isArrayEqual(currentPath, ['extensionPacks']);\n const isRequiredCapabilities = isArrayEqual(currentPath, ['capabilities']);\n const isRequiredMeta = isArrayEqual(currentPath, ['meta']);\n const isRequiredSources = isArrayEqual(currentPath, ['sources']);\n const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === 'extensionPacks';\n const isModelRelations =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[2]], ['models', 'relations']);\n const isTableUniques =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'uniques'],\n );\n const isTableIndexes =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'indexes'],\n );\n const isTableForeignKeys =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'foreignKeys'],\n );\n\n if (\n !isRequiredModels &&\n !isRequiredTables &&\n !isRequiredRelations &&\n !isRequiredExtensionPacks &&\n !isRequiredCapabilities &&\n !isRequiredMeta &&\n !isRequiredSources &&\n !isExtensionNamespace &&\n !isModelRelations &&\n !isTableUniques &&\n !isTableIndexes &&\n !isTableForeignKeys\n ) {\n continue;\n }\n }\n\n result[key] = omitDefaults(value, currentPath);\n }\n\n return result;\n}\n\nfunction sortObjectKeys(obj: unknown): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => sortObjectKeys(item));\n }\n\n const sorted: Record<string, unknown> = {};\n const keys = Object.keys(obj).sort();\n for (const key of keys) {\n sorted[key] = sortObjectKeys((obj as Record<string, unknown>)[key]);\n }\n\n return sorted;\n}\n\ntype StorageObject = {\n tables?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\ntype TableObject = {\n indexes?: unknown[];\n uniques?: unknown[];\n [key: string]: unknown;\n};\n\nfunction sortIndexesAndUniques(storage: unknown): unknown {\n if (!storage || typeof storage !== 'object') {\n return storage;\n }\n\n const storageObj = storage as StorageObject;\n if (!storageObj.tables || typeof storageObj.tables !== 'object') {\n return storage;\n }\n\n const tables = storageObj.tables;\n const result: StorageObject = { ...storageObj };\n\n result.tables = {};\n // Sort table names to ensure deterministic ordering\n const sortedTableNames = Object.keys(tables).sort();\n for (const tableName of sortedTableNames) {\n const table = tables[tableName];\n if (!table || typeof table !== 'object') {\n result.tables[tableName] = table;\n continue;\n }\n\n const tableObj = table as TableObject;\n const sortedTable: TableObject = { ...tableObj };\n\n if (Array.isArray(tableObj.indexes)) {\n sortedTable.indexes = [...tableObj.indexes].sort((a, b) => {\n const nameA = (a as { name?: string })?.name || '';\n const nameB = (b as { name?: string })?.name || '';\n return nameA.localeCompare(nameB);\n });\n }\n\n if (Array.isArray(tableObj.uniques)) {\n sortedTable.uniques = [...tableObj.uniques].sort((a, b) => {\n const nameA = (a as { name?: string })?.name || '';\n const nameB = (b as { name?: string })?.name || '';\n return nameA.localeCompare(nameB);\n });\n }\n\n result.tables[tableName] = sortedTable;\n }\n\n return result;\n}\n\nfunction orderTopLevel(obj: Record<string, unknown>): Record<string, unknown> {\n const ordered: Record<string, unknown> = {};\n const remaining = new Set(Object.keys(obj));\n\n for (const key of TOP_LEVEL_ORDER) {\n if (remaining.has(key)) {\n ordered[key] = obj[key];\n remaining.delete(key);\n }\n }\n\n for (const key of Array.from(remaining).sort()) {\n ordered[key] = obj[key];\n }\n\n return ordered;\n}\n\nexport function canonicalizeContract(\n ir: ContractIR & { coreHash?: string; profileHash?: string },\n): string {\n const normalized: NormalizedContract = {\n schemaVersion: ir.schemaVersion,\n targetFamily: ir.targetFamily,\n target: ir.target,\n models: ir.models,\n relations: ir.relations,\n storage: ir.storage,\n extensionPacks: ir.extensionPacks,\n capabilities: ir.capabilities,\n meta: ir.meta,\n sources: ir.sources,\n };\n\n if (ir.coreHash !== undefined) {\n normalized.coreHash = ir.coreHash;\n }\n\n if (ir.profileHash !== undefined) {\n normalized.profileHash = ir.profileHash;\n }\n\n const withDefaultsOmitted = omitDefaults(normalized, []) as NormalizedContract;\n const withSortedIndexes = sortIndexesAndUniques(withDefaultsOmitted.storage);\n const withSortedStorage = { ...withDefaultsOmitted, storage: withSortedIndexes };\n const withSortedKeys = sortObjectKeys(withSortedStorage) as Record<string, unknown>;\n const withOrderedTopLevel = orderTopLevel(withSortedKeys);\n\n return JSON.stringify(withOrderedTopLevel, null, 2);\n}\n","import { createHash } from 'node:crypto';\nimport type { ContractIR } from '@prisma-next/contract/ir';\nimport { canonicalizeContract } from './canonicalization';\n\ntype ContractInput = {\n schemaVersion: string;\n targetFamily: string;\n target: string;\n models: Record<string, unknown>;\n relations: Record<string, unknown>;\n storage: Record<string, unknown>;\n extensionPacks: Record<string, unknown>;\n sources: Record<string, unknown>;\n capabilities: Record<string, Record<string, boolean>>;\n meta: Record<string, unknown>;\n [key: string]: unknown;\n};\n\nfunction computeHash(content: string): string {\n const hash = createHash('sha256');\n hash.update(content);\n return `sha256:${hash.digest('hex')}`;\n}\n\nexport function computeCoreHash(contract: ContractInput): string {\n const coreContract: ContractIR = {\n schemaVersion: contract.schemaVersion,\n targetFamily: contract.targetFamily,\n target: contract.target,\n models: contract.models,\n relations: contract.relations,\n storage: contract.storage,\n extensionPacks: contract.extensionPacks,\n sources: contract.sources,\n capabilities: contract.capabilities,\n meta: contract.meta,\n };\n const canonical = canonicalizeContract(coreContract);\n return computeHash(canonical);\n}\n\nexport function computeProfileHash(contract: ContractInput): string {\n const profileContract: ContractIR = {\n schemaVersion: contract.schemaVersion,\n targetFamily: contract.targetFamily,\n target: contract.target,\n models: {},\n relations: {},\n storage: {},\n extensionPacks: {},\n capabilities: contract.capabilities,\n meta: {},\n sources: {},\n };\n const canonical = canonicalizeContract(profileContract);\n return computeHash(canonical);\n}\n","import type { ContractIR } from '@prisma-next/contract/ir';\nimport type { TargetFamilyHook, ValidationContext } from '@prisma-next/contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { format } from 'prettier';\nimport { canonicalizeContract } from './canonicalization';\nimport { computeCoreHash, computeProfileHash } from './hashing';\nimport type { EmitOptions, EmitResult } from './types';\n\nfunction validateCoreStructure(ir: ContractIR): void {\n if (!ir.targetFamily) {\n throw new Error('ContractIR must have targetFamily');\n }\n if (!ir.target) {\n throw new Error('ContractIR must have target');\n }\n if (!ir.schemaVersion) {\n throw new Error('ContractIR must have schemaVersion');\n }\n if (!ir.models || typeof ir.models !== 'object') {\n throw new Error('ContractIR must have models');\n }\n if (!ir.storage || typeof ir.storage !== 'object') {\n throw new Error('ContractIR must have storage');\n }\n if (!ir.relations || typeof ir.relations !== 'object') {\n throw new Error('ContractIR must have relations');\n }\n if (!ir.extensionPacks || typeof ir.extensionPacks !== 'object') {\n throw new Error('ContractIR must have extensionPacks');\n }\n if (!ir.capabilities || typeof ir.capabilities !== 'object') {\n throw new Error('ContractIR must have capabilities');\n }\n if (!ir.meta || typeof ir.meta !== 'object') {\n throw new Error('ContractIR must have meta');\n }\n if (!ir.sources || typeof ir.sources !== 'object') {\n throw new Error('ContractIR must have sources');\n }\n}\n\nexport async function emit(\n ir: ContractIR,\n options: EmitOptions,\n targetFamily: TargetFamilyHook,\n): Promise<EmitResult> {\n const {\n operationRegistry,\n codecTypeImports,\n operationTypeImports,\n extensionIds,\n parameterizedRenderers,\n parameterizedTypeImports,\n } = options;\n\n validateCoreStructure(ir);\n\n const ctx: ValidationContext = {\n ...ifDefined('operationRegistry', operationRegistry),\n ...ifDefined('codecTypeImports', codecTypeImports),\n ...ifDefined('operationTypeImports', operationTypeImports),\n ...ifDefined('extensionIds', extensionIds),\n };\n targetFamily.validateTypes(ir, ctx);\n\n targetFamily.validateStructure(ir);\n\n const contractJson = {\n schemaVersion: ir.schemaVersion,\n targetFamily: ir.targetFamily,\n target: ir.target,\n models: ir.models,\n relations: ir.relations,\n storage: ir.storage,\n extensionPacks: ir.extensionPacks,\n capabilities: ir.capabilities,\n meta: ir.meta,\n sources: ir.sources,\n } as const;\n\n const coreHash = computeCoreHash(contractJson);\n const profileHash = computeProfileHash(contractJson);\n\n const contractWithHashes: ContractIR & { coreHash?: string; profileHash?: string } = {\n ...ir,\n schemaVersion: contractJson.schemaVersion,\n coreHash,\n profileHash,\n };\n\n // Add _generated metadata to indicate this is a generated artifact\n // This ensures consistency between CLI emit and programmatic emit\n // Always add/update _generated with standard content for consistency\n const contractJsonObj = JSON.parse(canonicalizeContract(contractWithHashes)) as Record<\n string,\n unknown\n >;\n const contractJsonWithMeta = {\n ...contractJsonObj,\n _generated: {\n warning: '⚠️ GENERATED FILE - DO NOT EDIT',\n message: 'This file is automatically generated by \"prisma-next contract emit\".',\n regenerate: 'To regenerate, run: prisma-next contract emit',\n },\n };\n const contractJsonString = JSON.stringify(contractJsonWithMeta, null, 2);\n\n const generateOptions =\n parameterizedRenderers || parameterizedTypeImports\n ? {\n ...ifDefined('parameterizedRenderers', parameterizedRenderers),\n ...ifDefined('parameterizedTypeImports', parameterizedTypeImports),\n }\n : undefined;\n\n const contractDtsRaw = targetFamily.generateContractTypes(\n ir,\n codecTypeImports ?? [],\n operationTypeImports ?? [],\n generateOptions,\n );\n const contractDts = await format(contractDtsRaw, {\n parser: 'typescript',\n singleQuote: true,\n semi: true,\n printWidth: 100,\n });\n\n return {\n contractJson: contractJsonString,\n contractDts,\n coreHash,\n profileHash,\n };\n}\n"],"mappings":";;;;;;AAkBA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAS,eAAe,OAAyB;AAC/C,KAAI,UAAU,MAAO,QAAO;AAC5B,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,EAAG,QAAO;AACvD,KAAI,OAAO,UAAU,YAAY,UAAU,KAEzC,QADa,OAAO,KAAK,MAAM,CACnB,WAAW;AAEzB,QAAO;;AAGT,SAAS,aAAa,KAAc,MAAkC;AACpE,KAAI,QAAQ,QAAQ,OAAO,QAAQ,SACjC,QAAO;AAGT,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAK,SAAS,aAAa,MAAM,KAAK,CAAC;CAGpD,MAAMA,SAAkC,EAAE;AAE1C,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,EAAE;EAC9C,MAAM,cAAc,CAAC,GAAG,MAAM,IAAI;AAGlC,MAAI,QAAQ,aACV;AAGF,MAAI,QAAQ,cAAc,UAAU,MAClC;AAGF,MAAI,QAAQ,eAAe,UAAU,MACnC;AAGF,MAAI,eAAe,MAAM,EAAE;GACzB,MAAM,mBAAmB,aAAa,aAAa,CAAC,SAAS,CAAC;GAC9D,MAAM,mBAAmB,aAAa,aAAa,CAAC,WAAW,SAAS,CAAC;GACzE,MAAM,sBAAsB,aAAa,aAAa,CAAC,YAAY,C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GAAG;EACZ,gBAAgB,GAAG;EACnB,cAAc,GAAG;EACjB,MAAM,GAAG;EACT,SAAS,GAAG;EACb;CAED,MAAM,WAAW,gBAAgB,aAAa;CAC9C,MAAM,cAAc,mBAAmB,aAAa;CAEpD,MAAMC,qBAA+E;EACnF,GAAG;EACH,eAAe,aAAa;EAC5B;EACA;EACD;CASD,MAAM,uBAAuB;EAC3B,GALsB,KAAK,MAAM,qBAAqB,mBAAmB,CAAC;EAM1E,YAAY;GACV,SAAS;GACT,SAAS;GACT,YAAY;GACb;EACF;CACD,MAAM,qBAAqB,KAAK,UAAU,sBAAsB,MAAM,EAAE;CAExE,MAAM,kBACJ,0BAA0B,2BACtB;EACE,GAAG,UAAU,0BAA0B,uBAAuB;EAC9D,GAAG,UAAU,4BAA4B,yBAAyB;EACnE,GACD;AAeN,QAAO;EACL,cAAc;EACd,aATkB,MAAM,OANH,aAAa,sBAClC,IACA,oBAAoB,EAAE,EACtB,wBAAwB,EAAE,EAC1B,gBACD,EACgD;GAC/C,QAAQ;GACR,aAAa;GACb,MAAM;GACN,YAAY;GACb,CAAC;EAKA;EACA;EACD"}
@@ -0,0 +1,276 @@
1
+ //#region src/errors.ts
2
+ /**
3
+ * Structured CLI error that contains all information needed for error envelopes.
4
+ * Call sites throw these errors with full context.
5
+ */
6
+ var CliStructuredError = class extends Error {
7
+ code;
8
+ domain;
9
+ severity;
10
+ why;
11
+ fix;
12
+ where;
13
+ meta;
14
+ docsUrl;
15
+ constructor(code, summary, options) {
16
+ super(summary);
17
+ this.name = "CliStructuredError";
18
+ this.code = code;
19
+ this.domain = options?.domain ?? "CLI";
20
+ this.severity = options?.severity ?? "error";
21
+ this.why = options?.why;
22
+ this.fix = options?.fix;
23
+ this.where = options?.where ? {
24
+ path: options.where.path,
25
+ line: options.where.line
26
+ } : void 0;
27
+ this.meta = options?.meta;
28
+ this.docsUrl = options?.docsUrl;
29
+ }
30
+ /**
31
+ * Converts this error to a CLI error envelope for output formatting.
32
+ */
33
+ toEnvelope() {
34
+ return {
35
+ code: `${this.domain === "CLI" ? "PN-CLI-" : "PN-RTM-"}${this.code}`,
36
+ domain: this.domain,
37
+ severity: this.severity,
38
+ summary: this.message,
39
+ why: this.why,
40
+ fix: this.fix,
41
+ where: this.where,
42
+ meta: this.meta,
43
+ docsUrl: this.docsUrl
44
+ };
45
+ }
46
+ /**
47
+ * Type guard to check if an error is a CliStructuredError.
48
+ * Uses duck-typing to work across module boundaries where instanceof may fail.
49
+ */
50
+ static is(error) {
51
+ if (!(error instanceof Error)) return false;
52
+ const candidate = error;
53
+ return candidate.name === "CliStructuredError" && typeof candidate.code === "string" && (candidate.domain === "CLI" || candidate.domain === "RTM") && typeof candidate.toEnvelope === "function";
54
+ }
55
+ };
56
+ /**
57
+ * Config file not found or missing.
58
+ */
59
+ function errorConfigFileNotFound(configPath, options) {
60
+ return new CliStructuredError("4001", "Config file not found", {
61
+ domain: "CLI",
62
+ ...options?.why ? { why: options.why } : { why: "Config file not found" },
63
+ fix: "Run 'prisma-next init' to create a config file",
64
+ docsUrl: "https://prisma-next.dev/docs/cli/config",
65
+ ...configPath ? { where: { path: configPath } } : {}
66
+ });
67
+ }
68
+ /**
69
+ * Contract configuration missing from config.
70
+ */
71
+ function errorContractConfigMissing(options) {
72
+ return new CliStructuredError("4002", "Contract configuration missing", {
73
+ domain: "CLI",
74
+ why: options?.why ?? "The contract configuration is required for emit",
75
+ fix: "Add contract configuration to your prisma-next.config.ts",
76
+ docsUrl: "https://prisma-next.dev/docs/cli/contract-emit"
77
+ });
78
+ }
79
+ /**
80
+ * Contract validation failed.
81
+ */
82
+ function errorContractValidationFailed(reason, options) {
83
+ return new CliStructuredError("4003", "Contract validation failed", {
84
+ domain: "CLI",
85
+ why: reason,
86
+ fix: "Re-run `prisma-next contract emit`, or fix the contract file and try again",
87
+ docsUrl: "https://prisma-next.dev/docs/contracts",
88
+ ...options?.where ? { where: options.where } : {}
89
+ });
90
+ }
91
+ /**
92
+ * File not found.
93
+ */
94
+ function errorFileNotFound(filePath, options) {
95
+ return new CliStructuredError("4004", "File not found", {
96
+ domain: "CLI",
97
+ why: options?.why ?? `File not found: ${filePath}`,
98
+ fix: options?.fix ?? "Check that the file path is correct",
99
+ where: { path: filePath },
100
+ ...options?.docsUrl ? { docsUrl: options.docsUrl } : {}
101
+ });
102
+ }
103
+ /**
104
+ * Database connection is required but not provided.
105
+ */
106
+ function errorDatabaseConnectionRequired(options) {
107
+ return new CliStructuredError("4005", "Database connection is required", {
108
+ domain: "CLI",
109
+ why: options?.why ?? "Database connection is required for this command",
110
+ fix: "Provide `--db <url>` or set `db: { connection: \"postgres://…\" }` in prisma-next.config.ts"
111
+ });
112
+ }
113
+ /**
114
+ * Query runner factory is required but not provided in config.
115
+ */
116
+ function errorQueryRunnerFactoryRequired(options) {
117
+ return new CliStructuredError("4006", "Query runner factory is required", {
118
+ domain: "CLI",
119
+ why: options?.why ?? "Config.db.queryRunnerFactory is required for db verify",
120
+ fix: "Add db.queryRunnerFactory to prisma-next.config.ts",
121
+ docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
122
+ });
123
+ }
124
+ /**
125
+ * Family verify.readMarker is required but not provided.
126
+ */
127
+ function errorFamilyReadMarkerSqlRequired(options) {
128
+ return new CliStructuredError("4007", "Family readMarker() is required", {
129
+ domain: "CLI",
130
+ why: options?.why ?? "Family verify.readMarker is required for db verify",
131
+ fix: "Ensure family.verify.readMarker() is exported by your family package",
132
+ docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
133
+ });
134
+ }
135
+ /**
136
+ * JSON output format not supported.
137
+ */
138
+ function errorJsonFormatNotSupported(options) {
139
+ return new CliStructuredError("4008", "Unsupported JSON format", {
140
+ domain: "CLI",
141
+ why: `The ${options.command} command does not support --json ${options.format}`,
142
+ fix: `Use --json ${options.supportedFormats.join(" or ")}, or omit --json for human output`,
143
+ meta: {
144
+ command: options.command,
145
+ format: options.format,
146
+ supportedFormats: options.supportedFormats
147
+ }
148
+ });
149
+ }
150
+ /**
151
+ * Driver is required for DB-connected commands but not provided.
152
+ */
153
+ function errorDriverRequired(options) {
154
+ return new CliStructuredError("4010", "Driver is required for DB-connected commands", {
155
+ domain: "CLI",
156
+ why: options?.why ?? "Config.driver is required for DB-connected commands",
157
+ fix: "Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)",
158
+ docsUrl: "https://prisma-next.dev/docs/cli/config"
159
+ });
160
+ }
161
+ /**
162
+ * Contract requires extension packs that are not provided by config descriptors.
163
+ */
164
+ function errorContractMissingExtensionPacks(options) {
165
+ const missing = [...options.missingExtensionPacks].sort();
166
+ return new CliStructuredError("4011", "Missing extension packs in config", {
167
+ domain: "CLI",
168
+ why: missing.length === 1 ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.` : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(", ")}, but CLI config does not provide matching descriptors.`,
169
+ fix: "Add the missing extension descriptors to `extensions` in prisma-next.config.ts",
170
+ docsUrl: "https://prisma-next.dev/docs/cli/config",
171
+ meta: {
172
+ missingExtensionPacks: missing,
173
+ providedComponentIds: [...options.providedComponentIds].sort()
174
+ }
175
+ });
176
+ }
177
+ /**
178
+ * Migration planning failed due to conflicts.
179
+ */
180
+ function errorMigrationPlanningFailed(options) {
181
+ const conflictSummaries = options.conflicts.map((c) => c.summary);
182
+ const computedWhy = options.why ?? conflictSummaries.join("\n");
183
+ const conflictFixes = options.conflicts.map((c) => c.why).filter((why) => typeof why === "string");
184
+ return new CliStructuredError("4020", "Migration planning failed", {
185
+ domain: "CLI",
186
+ why: computedWhy,
187
+ fix: conflictFixes.length > 0 ? conflictFixes.join("\n") : "Use `db schema-verify` to inspect conflicts, or ensure the database is empty",
188
+ meta: { conflicts: options.conflicts },
189
+ docsUrl: "https://prisma-next.dev/docs/cli/db-init"
190
+ });
191
+ }
192
+ /**
193
+ * Target does not support migrations (missing createPlanner/createRunner).
194
+ */
195
+ function errorTargetMigrationNotSupported(options) {
196
+ return new CliStructuredError("4021", "Target does not support migrations", {
197
+ domain: "CLI",
198
+ why: options?.why ?? "The configured target does not provide migration planner/runner",
199
+ fix: "Select a target that provides migrations (it must export `target.migrations` for db init)",
200
+ docsUrl: "https://prisma-next.dev/docs/cli/db-init"
201
+ });
202
+ }
203
+ /**
204
+ * Config validation error (missing required fields).
205
+ */
206
+ function errorConfigValidation(field, options) {
207
+ return new CliStructuredError("4001", "Config file not found", {
208
+ domain: "CLI",
209
+ why: options?.why ?? `Config must have a "${field}" field`,
210
+ fix: "Run 'prisma-next init' to create a config file",
211
+ docsUrl: "https://prisma-next.dev/docs/cli/config"
212
+ });
213
+ }
214
+ /**
215
+ * Contract marker not found in database.
216
+ */
217
+ function errorMarkerMissing(options) {
218
+ return new CliStructuredError("3001", "Marker missing", {
219
+ domain: "RTM",
220
+ why: options?.why ?? "Contract marker not found in database",
221
+ fix: "Run `prisma-next db sign --db <url>` to create marker"
222
+ });
223
+ }
224
+ /**
225
+ * Contract hash does not match database marker.
226
+ */
227
+ function errorHashMismatch(options) {
228
+ return new CliStructuredError("3002", "Hash mismatch", {
229
+ domain: "RTM",
230
+ why: options?.why ?? "Contract hash does not match database marker",
231
+ fix: "Migrate database or re-sign if intentional",
232
+ ...options?.expected || options?.actual ? { meta: {
233
+ ...options.expected ? { expected: options.expected } : {},
234
+ ...options.actual ? { actual: options.actual } : {}
235
+ } } : {}
236
+ });
237
+ }
238
+ /**
239
+ * Contract target does not match config target.
240
+ */
241
+ function errorTargetMismatch(expected, actual, options) {
242
+ return new CliStructuredError("3003", "Target mismatch", {
243
+ domain: "RTM",
244
+ why: options?.why ?? `Contract target does not match config target (expected: ${expected}, actual: ${actual})`,
245
+ fix: "Align contract target and config target",
246
+ meta: {
247
+ expected,
248
+ actual
249
+ }
250
+ });
251
+ }
252
+ /**
253
+ * Generic runtime error.
254
+ */
255
+ function errorRuntime(summary, options) {
256
+ return new CliStructuredError("3000", summary, {
257
+ domain: "RTM",
258
+ ...options?.why ? { why: options.why } : { why: "Verification failed" },
259
+ ...options?.fix ? { fix: options.fix } : { fix: "Check contract and database state" },
260
+ ...options?.meta ? { meta: options.meta } : {}
261
+ });
262
+ }
263
+ /**
264
+ * Generic unexpected error.
265
+ */
266
+ function errorUnexpected(message, options) {
267
+ return new CliStructuredError("4999", "Unexpected error", {
268
+ domain: "CLI",
269
+ why: options?.why ?? message,
270
+ fix: options?.fix ?? "Check the error message and try again"
271
+ });
272
+ }
273
+
274
+ //#endregion
275
+ export { errorTargetMigrationNotSupported as _, errorContractMissingExtensionPacks as a, errorDriverRequired as c, errorHashMismatch as d, errorJsonFormatNotSupported as f, errorRuntime as g, errorQueryRunnerFactoryRequired as h, errorContractConfigMissing as i, errorFamilyReadMarkerSqlRequired as l, errorMigrationPlanningFailed as m, errorConfigFileNotFound as n, errorContractValidationFailed as o, errorMarkerMissing as p, errorConfigValidation as r, errorDatabaseConnectionRequired as s, CliStructuredError as t, errorFileNotFound as u, errorTargetMismatch as v, errorUnexpected as y };
276
+ //# sourceMappingURL=errors-Qlh0sdcb.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-Qlh0sdcb.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * CLI error envelope for output formatting.\n * This is the serialized form of a CliStructuredError.\n */\nexport interface CliErrorEnvelope {\n readonly code: string;\n readonly domain: string;\n readonly severity: 'error' | 'warn' | 'info';\n readonly summary: string;\n readonly why: string | undefined;\n readonly fix: string | undefined;\n readonly where:\n | {\n readonly path: string | undefined;\n readonly line: number | undefined;\n }\n | undefined;\n readonly meta: Record<string, unknown> | undefined;\n readonly docsUrl: string | undefined;\n}\n\n/**\n * Minimal conflict data structure expected by CLI output.\n */\nexport interface CliErrorConflict {\n readonly kind: string;\n readonly summary: string;\n readonly why?: string;\n}\n\n/**\n * Structured CLI error that contains all information needed for error envelopes.\n * Call sites throw these errors with full context.\n */\nexport class CliStructuredError extends Error {\n readonly code: string;\n readonly domain: 'CLI' | 'RTM';\n readonly severity: 'error' | 'warn' | 'info';\n readonly why: string | undefined;\n readonly fix: string | undefined;\n readonly where:\n | {\n readonly path: string | undefined;\n readonly line: number | undefined;\n }\n | undefined;\n readonly meta: Record<string, unknown> | undefined;\n readonly docsUrl: string | undefined;\n\n constructor(\n code: string,\n summary: string,\n options?: {\n readonly domain?: 'CLI' | 'RTM';\n readonly severity?: 'error' | 'warn' | 'info';\n readonly why?: string;\n readonly fix?: string;\n readonly where?: { readonly path?: string; readonly line?: number };\n readonly meta?: Record<string, unknown>;\n readonly docsUrl?: string;\n },\n ) {\n super(summary);\n this.name = 'CliStructuredError';\n this.code = code;\n this.domain = options?.domain ?? 'CLI';\n this.severity = options?.severity ?? 'error';\n this.why = options?.why;\n this.fix = options?.fix;\n this.where = options?.where\n ? {\n path: options.where.path,\n line: options.where.line,\n }\n : undefined;\n this.meta = options?.meta;\n this.docsUrl = options?.docsUrl;\n }\n\n /**\n * Converts this error to a CLI error envelope for output formatting.\n */\n toEnvelope(): CliErrorEnvelope {\n const codePrefix = this.domain === 'CLI' ? 'PN-CLI-' : 'PN-RTM-';\n return {\n code: `${codePrefix}${this.code}`,\n domain: this.domain,\n severity: this.severity,\n summary: this.message,\n why: this.why,\n fix: this.fix,\n where: this.where,\n meta: this.meta,\n docsUrl: this.docsUrl,\n };\n }\n\n /**\n * Type guard to check if an error is a CliStructuredError.\n * Uses duck-typing to work across module boundaries where instanceof may fail.\n */\n static is(error: unknown): error is CliStructuredError {\n if (!(error instanceof Error)) {\n return false;\n }\n const candidate = error as CliStructuredError;\n return (\n candidate.name === 'CliStructuredError' &&\n typeof candidate.code === 'string' &&\n (candidate.domain === 'CLI' || candidate.domain === 'RTM') &&\n typeof candidate.toEnvelope === 'function'\n );\n }\n}\n\n// ============================================================================\n// Config Errors (PN-CLI-4001-4007)\n// ============================================================================\n\n/**\n * Config file not found or missing.\n */\nexport function errorConfigFileNotFound(\n configPath?: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4001', 'Config file not found', {\n domain: 'CLI',\n ...(options?.why ? { why: options.why } : { why: 'Config file not found' }),\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n ...(configPath ? { where: { path: configPath } } : {}),\n });\n}\n\n/**\n * Contract configuration missing from config.\n */\nexport function errorContractConfigMissing(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4002', 'Contract configuration missing', {\n domain: 'CLI',\n why: options?.why ?? 'The contract configuration is required for emit',\n fix: 'Add contract configuration to your prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/contract-emit',\n });\n}\n\n/**\n * Contract validation failed.\n */\nexport function errorContractValidationFailed(\n reason: string,\n options?: {\n readonly where?: { readonly path?: string; readonly line?: number };\n },\n): CliStructuredError {\n return new CliStructuredError('4003', 'Contract validation failed', {\n domain: 'CLI',\n why: reason,\n fix: 'Re-run `prisma-next contract emit`, or fix the contract file and try again',\n docsUrl: 'https://prisma-next.dev/docs/contracts',\n ...(options?.where ? { where: options.where } : {}),\n });\n}\n\n/**\n * File not found.\n */\nexport function errorFileNotFound(\n filePath: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly docsUrl?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4004', 'File not found', {\n domain: 'CLI',\n why: options?.why ?? `File not found: ${filePath}`,\n fix: options?.fix ?? 'Check that the file path is correct',\n where: { path: filePath },\n ...(options?.docsUrl ? { docsUrl: options.docsUrl } : {}),\n });\n}\n\n/**\n * Database connection is required but not provided.\n */\nexport function errorDatabaseConnectionRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4005', 'Database connection is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database connection is required for this command',\n fix: 'Provide `--db <url>` or set `db: { connection: \"postgres://…\" }` in prisma-next.config.ts',\n });\n}\n\n/**\n * Query runner factory is required but not provided in config.\n */\nexport function errorQueryRunnerFactoryRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4006', 'Query runner factory is required', {\n domain: 'CLI',\n why: options?.why ?? 'Config.db.queryRunnerFactory is required for db verify',\n fix: 'Add db.queryRunnerFactory to prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * Family verify.readMarker is required but not provided.\n */\nexport function errorFamilyReadMarkerSqlRequired(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4007', 'Family readMarker() is required', {\n domain: 'CLI',\n why: options?.why ?? 'Family verify.readMarker is required for db verify',\n fix: 'Ensure family.verify.readMarker() is exported by your family package',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-verify',\n });\n}\n\n/**\n * JSON output format not supported.\n */\nexport function errorJsonFormatNotSupported(options: {\n readonly command: string;\n readonly format: string;\n readonly supportedFormats: readonly string[];\n}): CliStructuredError {\n return new CliStructuredError('4008', 'Unsupported JSON format', {\n domain: 'CLI',\n why: `The ${options.command} command does not support --json ${options.format}`,\n fix: `Use --json ${options.supportedFormats.join(' or ')}, or omit --json for human output`,\n meta: {\n command: options.command,\n format: options.format,\n supportedFormats: options.supportedFormats,\n },\n });\n}\n\n/**\n * Driver is required for DB-connected commands but not provided.\n */\nexport function errorDriverRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4010', 'Driver is required for DB-connected commands', {\n domain: 'CLI',\n why: options?.why ?? 'Config.driver is required for DB-connected commands',\n fix: 'Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n/**\n * Contract requires extension packs that are not provided by config descriptors.\n */\nexport function errorContractMissingExtensionPacks(options: {\n readonly missingExtensionPacks: readonly string[];\n readonly providedComponentIds: readonly string[];\n}): CliStructuredError {\n const missing = [...options.missingExtensionPacks].sort();\n return new CliStructuredError('4011', 'Missing extension packs in config', {\n domain: 'CLI',\n why:\n missing.length === 1\n ? `Contract requires extension pack '${missing[0]}', but CLI config does not provide a matching descriptor.`\n : `Contract requires extension packs ${missing.map((p) => `'${p}'`).join(', ')}, but CLI config does not provide matching descriptors.`,\n fix: 'Add the missing extension descriptors to `extensions` in prisma-next.config.ts',\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n meta: {\n missingExtensionPacks: missing,\n providedComponentIds: [...options.providedComponentIds].sort(),\n },\n });\n}\n\n/**\n * Migration planning failed due to conflicts.\n */\nexport function errorMigrationPlanningFailed(options: {\n readonly conflicts: readonly CliErrorConflict[];\n readonly why?: string;\n}): CliStructuredError {\n // Build \"why\" from conflict summaries - these contain the actual problem description\n const conflictSummaries = options.conflicts.map((c) => c.summary);\n const computedWhy = options.why ?? conflictSummaries.join('\\n');\n\n // Build \"fix\" from conflict \"why\" fields - these contain actionable advice\n const conflictFixes = options.conflicts\n .map((c) => c.why)\n .filter((why): why is string => typeof why === 'string');\n const computedFix =\n conflictFixes.length > 0\n ? conflictFixes.join('\\n')\n : 'Use `db schema-verify` to inspect conflicts, or ensure the database is empty';\n\n return new CliStructuredError('4020', 'Migration planning failed', {\n domain: 'CLI',\n why: computedWhy,\n fix: computedFix,\n meta: { conflicts: options.conflicts },\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * Target does not support migrations (missing createPlanner/createRunner).\n */\nexport function errorTargetMigrationNotSupported(options?: {\n readonly why?: string;\n}): CliStructuredError {\n return new CliStructuredError('4021', 'Target does not support migrations', {\n domain: 'CLI',\n why: options?.why ?? 'The configured target does not provide migration planner/runner',\n fix: 'Select a target that provides migrations (it must export `target.migrations` for db init)',\n docsUrl: 'https://prisma-next.dev/docs/cli/db-init',\n });\n}\n\n/**\n * Config validation error (missing required fields).\n */\nexport function errorConfigValidation(\n field: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4001', 'Config file not found', {\n domain: 'CLI',\n why: options?.why ?? `Config must have a \"${field}\" field`,\n fix: \"Run 'prisma-next init' to create a config file\",\n docsUrl: 'https://prisma-next.dev/docs/cli/config',\n });\n}\n\n// ============================================================================\n// Runtime Errors (PN-RTM-3000-3003)\n// ============================================================================\n\n/**\n * Contract marker not found in database.\n */\nexport function errorMarkerMissing(options?: {\n readonly why?: string;\n readonly dbUrl?: string;\n}): CliStructuredError {\n return new CliStructuredError('3001', 'Marker missing', {\n domain: 'RTM',\n why: options?.why ?? 'Contract marker not found in database',\n fix: 'Run `prisma-next db sign --db <url>` to create marker',\n });\n}\n\n/**\n * Contract hash does not match database marker.\n */\nexport function errorHashMismatch(options?: {\n readonly why?: string;\n readonly expected?: string;\n readonly actual?: string;\n}): CliStructuredError {\n return new CliStructuredError('3002', 'Hash mismatch', {\n domain: 'RTM',\n why: options?.why ?? 'Contract hash does not match database marker',\n fix: 'Migrate database or re-sign if intentional',\n ...(options?.expected || options?.actual\n ? {\n meta: {\n ...(options.expected ? { expected: options.expected } : {}),\n ...(options.actual ? { actual: options.actual } : {}),\n },\n }\n : {}),\n });\n}\n\n/**\n * Contract target does not match config target.\n */\nexport function errorTargetMismatch(\n expected: string,\n actual: string,\n options?: {\n readonly why?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('3003', 'Target mismatch', {\n domain: 'RTM',\n why:\n options?.why ??\n `Contract target does not match config target (expected: ${expected}, actual: ${actual})`,\n fix: 'Align contract target and config target',\n meta: { expected, actual },\n });\n}\n\n/**\n * Generic runtime error.\n */\nexport function errorRuntime(\n summary: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n readonly meta?: Record<string, unknown>;\n },\n): CliStructuredError {\n return new CliStructuredError('3000', summary, {\n domain: 'RTM',\n ...(options?.why ? { why: options.why } : { why: 'Verification failed' }),\n ...(options?.fix ? { fix: options.fix } : { fix: 'Check contract and database state' }),\n ...(options?.meta ? { meta: options.meta } : {}),\n });\n}\n\n// ============================================================================\n// Generic Error\n// ============================================================================\n\n/**\n * Generic unexpected error.\n */\nexport function errorUnexpected(\n message: string,\n options?: {\n readonly why?: string;\n readonly fix?: string;\n },\n): CliStructuredError {\n return new CliStructuredError('4999', 'Unexpected error', {\n domain: 'CLI',\n why: options?.why ?? message,\n fix: options?.fix ?? 'Check the error message and try again',\n });\n}\n"],"mappings":";;;;;AAkCA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CAMT,AAAS;CACT,AAAS;CAET,YACE,MACA,SACA,SASA;AACA,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,SAAS,SAAS,UAAU;AACjC,OAAK,WAAW,SAAS,YAAY;AACrC,OAAK,MAAM,SAAS;AACpB,OAAK,MAAM,SAAS;AACpB,OAAK,QAAQ,SAAS,QAClB;GACE,MAAM,QAAQ,MAAM;GACpB,MAAM,QAAQ,MAAM;GACrB,GACD;AACJ,OAAK,OAAO,SAAS;AACrB,OAAK,UAAU,SAAS;;;;;CAM1B,aAA+B;AAE7B,SAAO;GACL,MAAM,GAFW,KAAK,WAAW,QAAQ,YAAY,YAE/B,KAAK;GAC3B,QAAQ,KAAK;GACb,UAAU,KAAK;GACf,SAAS,KAAK;GACd,KAAK,KAAK;GACV,KAAK,KAAK;GACV,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,SAAS,KAAK;GACf;;;;;;CAOH,OAAO,GAAG,OAA6C;AACrD,MAAI,EAAE,iBAAiB,OACrB,QAAO;EAET,MAAM,YAAY;AAClB,SACE,UAAU,SAAS,wBACnB,OAAO,UAAU,SAAS,aACzB,UAAU,WAAW,SAAS,UAAU,WAAW,UACpD,OAAO,UAAU,eAAe;;;;;;AAYtC,SAAgB,wBACd,YACA,SAGoB;AACpB,QAAO,IAAI,mBAAmB,QAAQ,yBAAyB;EAC7D,QAAQ;EACR,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,KAAK,GAAG,EAAE,KAAK,yBAAyB;EAC1E,KAAK;EAC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