@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
@@ -1,229 +0,0 @@
1
- // src/errors.ts
2
- var CliStructuredError = class extends Error {
3
- code;
4
- domain;
5
- severity;
6
- why;
7
- fix;
8
- where;
9
- meta;
10
- docsUrl;
11
- constructor(code, summary, options) {
12
- super(summary);
13
- this.name = "CliStructuredError";
14
- this.code = code;
15
- this.domain = options?.domain ?? "CLI";
16
- this.severity = options?.severity ?? "error";
17
- this.why = options?.why;
18
- this.fix = options?.fix;
19
- this.where = options?.where ? {
20
- path: options.where.path,
21
- line: options.where.line
22
- } : void 0;
23
- this.meta = options?.meta;
24
- this.docsUrl = options?.docsUrl;
25
- }
26
- /**
27
- * Converts this error to a CLI error envelope for output formatting.
28
- */
29
- toEnvelope() {
30
- const codePrefix = this.domain === "CLI" ? "PN-CLI-" : "PN-RTM-";
31
- return {
32
- code: `${codePrefix}${this.code}`,
33
- domain: this.domain,
34
- severity: this.severity,
35
- summary: this.message,
36
- why: this.why,
37
- fix: this.fix,
38
- where: this.where,
39
- meta: this.meta,
40
- docsUrl: this.docsUrl
41
- };
42
- }
43
- };
44
- function errorConfigFileNotFound(configPath, options) {
45
- return new CliStructuredError("4001", "Config file not found", {
46
- domain: "CLI",
47
- ...options?.why ? { why: options.why } : { why: "Config file not found" },
48
- fix: "Run 'prisma-next init' to create a config file",
49
- docsUrl: "https://prisma-next.dev/docs/cli/config",
50
- ...configPath ? { where: { path: configPath } } : {}
51
- });
52
- }
53
- function errorContractConfigMissing(options) {
54
- return new CliStructuredError("4002", "Contract configuration missing", {
55
- domain: "CLI",
56
- why: options?.why ?? "The contract configuration is required for emit",
57
- fix: "Add contract configuration to your prisma-next.config.ts",
58
- docsUrl: "https://prisma-next.dev/docs/cli/contract-emit"
59
- });
60
- }
61
- function errorContractValidationFailed(reason, options) {
62
- return new CliStructuredError("4003", "Contract validation failed", {
63
- domain: "CLI",
64
- why: reason,
65
- fix: "Re-run `prisma-next contract emit`, or fix the contract file and try again",
66
- docsUrl: "https://prisma-next.dev/docs/contracts",
67
- ...options?.where ? { where: options.where } : {}
68
- });
69
- }
70
- function errorFileNotFound(filePath, options) {
71
- return new CliStructuredError("4004", "File not found", {
72
- domain: "CLI",
73
- why: options?.why ?? `File not found: ${filePath}`,
74
- fix: options?.fix ?? "Check that the file path is correct",
75
- where: { path: filePath },
76
- ...options?.docsUrl ? { docsUrl: options.docsUrl } : {}
77
- });
78
- }
79
- function errorDatabaseUrlRequired(options) {
80
- return new CliStructuredError("4005", "Database URL is required", {
81
- domain: "CLI",
82
- why: options?.why ?? "Database URL is required for this command",
83
- fix: 'Provide `--db <url>` or set `db: { url: "postgres://\u2026" }` in prisma-next.config.ts'
84
- });
85
- }
86
- function errorQueryRunnerFactoryRequired(options) {
87
- return new CliStructuredError("4006", "Query runner factory is required", {
88
- domain: "CLI",
89
- why: options?.why ?? "Config.db.queryRunnerFactory is required for db verify",
90
- fix: "Add db.queryRunnerFactory to prisma-next.config.ts",
91
- docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
92
- });
93
- }
94
- function errorFamilyReadMarkerSqlRequired(options) {
95
- return new CliStructuredError("4007", "Family readMarker() is required", {
96
- domain: "CLI",
97
- why: options?.why ?? "Family verify.readMarker is required for db verify",
98
- fix: "Ensure family.verify.readMarker() is exported by your family package",
99
- docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
100
- });
101
- }
102
- function errorJsonFormatNotSupported(options) {
103
- return new CliStructuredError("4008", "Unsupported JSON format", {
104
- domain: "CLI",
105
- why: `The ${options.command} command does not support --json ${options.format}`,
106
- fix: `Use --json ${options.supportedFormats.join(" or ")}, or omit --json for human output`,
107
- meta: {
108
- command: options.command,
109
- format: options.format,
110
- supportedFormats: options.supportedFormats
111
- }
112
- });
113
- }
114
- function errorDriverRequired(options) {
115
- return new CliStructuredError("4010", "Driver is required for DB-connected commands", {
116
- domain: "CLI",
117
- why: options?.why ?? "Config.driver is required for DB-connected commands",
118
- fix: "Add a control-plane driver to prisma-next.config.ts (e.g. import a driver descriptor and set `driver: postgresDriver`)",
119
- docsUrl: "https://prisma-next.dev/docs/cli/config"
120
- });
121
- }
122
- function errorContractMissingExtensionPacks(options) {
123
- const missing = [...options.missingExtensionPacks].sort();
124
- return new CliStructuredError("4011", "Missing extension packs in config", {
125
- domain: "CLI",
126
- 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.`,
127
- fix: "Add the missing extension descriptors to `extensions` in prisma-next.config.ts",
128
- docsUrl: "https://prisma-next.dev/docs/cli/config",
129
- meta: {
130
- missingExtensionPacks: missing,
131
- providedComponentIds: [...options.providedComponentIds].sort()
132
- }
133
- });
134
- }
135
- function errorMigrationPlanningFailed(options) {
136
- const conflictSummaries = options.conflicts.map((c) => c.summary);
137
- const computedWhy = options.why ?? conflictSummaries.join("\n");
138
- const conflictFixes = options.conflicts.map((c) => c.why).filter((why) => typeof why === "string");
139
- const computedFix = conflictFixes.length > 0 ? conflictFixes.join("\n") : "Use `db schema-verify` to inspect conflicts, or ensure the database is empty";
140
- return new CliStructuredError("4020", "Migration planning failed", {
141
- domain: "CLI",
142
- why: computedWhy,
143
- fix: computedFix,
144
- meta: { conflicts: options.conflicts },
145
- docsUrl: "https://prisma-next.dev/docs/cli/db-init"
146
- });
147
- }
148
- function errorTargetMigrationNotSupported(options) {
149
- return new CliStructuredError("4021", "Target does not support migrations", {
150
- domain: "CLI",
151
- why: options?.why ?? "The configured target does not provide migration planner/runner",
152
- fix: "Select a target that provides migrations (it must export `target.migrations` for db init)",
153
- docsUrl: "https://prisma-next.dev/docs/cli/db-init"
154
- });
155
- }
156
- function errorConfigValidation(field, options) {
157
- return new CliStructuredError("4001", "Config file not found", {
158
- domain: "CLI",
159
- why: options?.why ?? `Config must have a "${field}" field`,
160
- fix: "Run 'prisma-next init' to create a config file",
161
- docsUrl: "https://prisma-next.dev/docs/cli/config"
162
- });
163
- }
164
- function errorMarkerMissing(options) {
165
- return new CliStructuredError("3001", "Marker missing", {
166
- domain: "RTM",
167
- why: options?.why ?? "Contract marker not found in database",
168
- fix: "Run `prisma-next db sign --db <url>` to create marker"
169
- });
170
- }
171
- function errorHashMismatch(options) {
172
- return new CliStructuredError("3002", "Hash mismatch", {
173
- domain: "RTM",
174
- why: options?.why ?? "Contract hash does not match database marker",
175
- fix: "Migrate database or re-sign if intentional",
176
- ...options?.expected || options?.actual ? {
177
- meta: {
178
- ...options.expected ? { expected: options.expected } : {},
179
- ...options.actual ? { actual: options.actual } : {}
180
- }
181
- } : {}
182
- });
183
- }
184
- function errorTargetMismatch(expected, actual, options) {
185
- return new CliStructuredError("3003", "Target mismatch", {
186
- domain: "RTM",
187
- why: options?.why ?? `Contract target does not match config target (expected: ${expected}, actual: ${actual})`,
188
- fix: "Align contract target and config target",
189
- meta: { expected, actual }
190
- });
191
- }
192
- function errorRuntime(summary, options) {
193
- return new CliStructuredError("3000", summary, {
194
- domain: "RTM",
195
- ...options?.why ? { why: options.why } : { why: "Verification failed" },
196
- ...options?.fix ? { fix: options.fix } : { fix: "Check contract and database state" },
197
- ...options?.meta ? { meta: options.meta } : {}
198
- });
199
- }
200
- function errorUnexpected(message, options) {
201
- return new CliStructuredError("4999", "Unexpected error", {
202
- domain: "CLI",
203
- why: options?.why ?? message,
204
- fix: options?.fix ?? "Check the error message and try again"
205
- });
206
- }
207
-
208
- export {
209
- CliStructuredError,
210
- errorConfigFileNotFound,
211
- errorContractConfigMissing,
212
- errorContractValidationFailed,
213
- errorFileNotFound,
214
- errorDatabaseUrlRequired,
215
- errorQueryRunnerFactoryRequired,
216
- errorFamilyReadMarkerSqlRequired,
217
- errorJsonFormatNotSupported,
218
- errorDriverRequired,
219
- errorContractMissingExtensionPacks,
220
- errorMigrationPlanningFailed,
221
- errorTargetMigrationNotSupported,
222
- errorConfigValidation,
223
- errorMarkerMissing,
224
- errorHashMismatch,
225
- errorTargetMismatch,
226
- errorRuntime,
227
- errorUnexpected
228
- };
229
- //# sourceMappingURL=chunk-U5RYT6PT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"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// ============================================================================\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 URL is required but not provided.\n */\nexport function errorDatabaseUrlRequired(options?: { readonly why?: string }): CliStructuredError {\n return new CliStructuredError('4005', 'Database URL is required', {\n domain: 'CLI',\n why: options?.why ?? 'Database URL is required for this command',\n fix: 'Provide `--db <url>` or set `db: { url: \"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 ?? '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,IACL,MAAM,EAAE,UAAU,OAAO;AAAA,EAC3B,CAAC;AACH;AAKO,SAAS,aACd,SACA,SAKoB;AACpB,SAAO,IAAI,mBAAmB,QAAQ,SAAS;AAAA,IAC7C,QAAQ;AAAA,IACR,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,EAAE,KAAK,sBAAsB;AAAA,IACvE,GAAI,SAAS,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,EAAE,KAAK,oCAAoC;AAAA,IACrF,GAAI,SAAS,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;AAAA,EAChD,CAAC;AACH;AASO,SAAS,gBACd,SACA,SAIoB;AACpB,SAAO,IAAI,mBAAmB,QAAQ,oBAAoB;AAAA,IACxD,QAAQ;AAAA,IACR,KAAK,SAAS,OAAO;AAAA,IACrB,KAAK,SAAS,OAAO;AAAA,EACvB,CAAC;AACH;","names":[]}
@@ -1,70 +0,0 @@
1
- import { ControlFamilyDescriptor, ControlTargetDescriptor, ControlAdapterDescriptor, ControlExtensionDescriptor, ControlDriverDescriptor } from './types.js';
2
- import '@prisma-next/contract/framework-components';
3
- import '@prisma-next/contract/ir';
4
- import '@prisma-next/contract/types';
5
- import '@prisma-next/utils/result';
6
- import './schema-view.js';
7
-
8
- /**
9
- * Contract configuration specifying source and artifact locations.
10
- */
11
- interface ContractConfig {
12
- /**
13
- * Contract source. Can be a value or a function that returns a value (sync or async).
14
- * If a function, it will be called to resolve the contract.
15
- */
16
- readonly source: unknown | (() => unknown | Promise<unknown>);
17
- /**
18
- * Path to contract.json artifact. Defaults to 'src/prisma/contract.json'.
19
- * This is the canonical location where other CLI commands can find the contract JSON.
20
- */
21
- readonly output?: string;
22
- /**
23
- * Path to contract.d.ts artifact. Defaults to output with .d.ts extension.
24
- * If output ends with .json, replaces .json with .d.ts.
25
- * Otherwise, appends .d.ts to the directory containing output.
26
- */
27
- readonly types?: string;
28
- }
29
- /**
30
- * Configuration for Prisma Next CLI.
31
- * Uses Control*Descriptor types for type-safe wiring with compile-time compatibility checks.
32
- *
33
- * @template TFamilyId - The family ID (e.g., 'sql', 'document')
34
- * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
35
- */
36
- interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends string = string> {
37
- readonly family: ControlFamilyDescriptor<TFamilyId>;
38
- readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
39
- readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
40
- readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
41
- /**
42
- * Driver descriptor for DB-connected CLI commands.
43
- * Required for DB-connected commands (e.g., db verify).
44
- * Optional for commands that don't need database access (e.g., emit).
45
- */
46
- readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId>;
47
- readonly db?: {
48
- readonly url?: string;
49
- };
50
- /**
51
- * Contract configuration. Specifies source and artifact locations.
52
- * Required for emit command; optional for other commands that only read artifacts.
53
- */
54
- readonly contract?: ContractConfig;
55
- }
56
- /**
57
- * Helper function to define a Prisma Next config.
58
- * Validates and normalizes the config using Arktype, then returns the normalized IR.
59
- *
60
- * Normalization:
61
- * - contract.output defaults to 'src/prisma/contract.json' if missing
62
- * - contract.types defaults to output with .d.ts extension if missing
63
- *
64
- * @param config - Raw config input from user
65
- * @returns Normalized config IR with defaults applied
66
- * @throws Error if config structure is invalid
67
- */
68
- declare function defineConfig<TFamilyId extends string = string, TTargetId extends string = string>(config: PrismaNextConfig<TFamilyId, TTargetId>): PrismaNextConfig<TFamilyId, TTargetId>;
69
-
70
- export { type ContractConfig, type PrismaNextConfig, defineConfig };
@@ -1,53 +0,0 @@
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
@@ -1 +0,0 @@
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 */\nexport interface PrismaNextConfig<\n TFamilyId extends string = string,\n TTargetId extends string = string,\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 */\n readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId>;\n readonly db?: {\n readonly url?: string;\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;AAyErB,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":[]}
@@ -1,252 +0,0 @@
1
- import {
2
- errorConfigValidation
3
- } from "../chunk-U5RYT6PT.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