@prisma-next/core-control-plane 0.1.0-dev.3 → 0.1.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.
- package/README.md +28 -2
- package/dist/{chunk-DZPZSLCM.js → chunk-U5RYT6PT.js} +60 -9
- package/dist/chunk-U5RYT6PT.js.map +1 -0
- package/dist/exports/config-types.d.ts +3 -2
- package/dist/exports/config-types.js +1 -1
- package/dist/exports/config-types.js.map +1 -1
- package/dist/exports/config-validation.d.ts +2 -1
- package/dist/exports/config-validation.js +16 -16
- package/dist/exports/config-validation.js.map +1 -1
- package/dist/exports/emission.d.ts +1 -1
- package/dist/exports/emission.js +30 -33
- package/dist/exports/emission.js.map +1 -1
- package/dist/exports/errors.d.ts +39 -1
- package/dist/exports/errors.js +9 -1
- package/dist/exports/types.d.ts +331 -113
- package/package.json +10 -6
- package/dist/chunk-DZPZSLCM.js.map +0 -1
package/README.md
CHANGED
|
@@ -14,9 +14,11 @@ This package provides the core domain logic for control plane operations (contra
|
|
|
14
14
|
- **Domain Actions**:
|
|
15
15
|
- `verifyDatabase()`: Verifies database contract markers (accepts config object and ContractIR)
|
|
16
16
|
|
|
17
|
-
Note: Contract emission is implemented on family
|
|
17
|
+
Note: Contract emission is implemented on the SQL family instance (e.g., `familyInstance.emitContract()`), not as a core domain action.
|
|
18
18
|
- **Error Factories**: Domain error factories (`CliStructuredError`, config errors, runtime errors)
|
|
19
19
|
- **Pack Manifest Types**: Type definitions for extension pack manifests
|
|
20
|
+
- **Migration SPI**: Generic migration planner/runner interfaces (`MigrationPlanner<TFamilyId, TTargetId>`, `MigrationRunner<TFamilyId, TTargetId>`, `TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>`) that thread family/target IDs for compile-time component compatibility enforcement
|
|
21
|
+
- `MigrationRunnerFailure` includes optional `meta` for structured debugging context (e.g., schema issues, SQL state)
|
|
20
22
|
|
|
21
23
|
## Dependencies
|
|
22
24
|
|
|
@@ -102,13 +104,37 @@ throw errorConfigFileNotFound('prisma-next.config.ts', {
|
|
|
102
104
|
});
|
|
103
105
|
```
|
|
104
106
|
|
|
107
|
+
## Migration SPI Design
|
|
108
|
+
|
|
109
|
+
The migration planner/runner interfaces are generic over `TFamilyId` and `TTargetId` to enable compile-time enforcement of component compatibility:
|
|
110
|
+
|
|
111
|
+
- **`MigrationPlanner<TFamilyId, TTargetId>`**: Generic planner interface that accepts `TargetBoundComponentDescriptor<TFamilyId, TTargetId>[]`
|
|
112
|
+
- **`MigrationRunner<TFamilyId, TTargetId>`**: Generic runner interface that accepts `TargetBoundComponentDescriptor<TFamilyId, TTargetId>[]`
|
|
113
|
+
- **`TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>`**: Generic capability interface for targets that support migrations
|
|
114
|
+
|
|
115
|
+
The CLI performs runtime validation at the composition boundary using `assertFrameworkComponentsCompatible()` before calling typed planner/runner instances. This validates that all components have matching `familyId` and `targetId`, then returns a typed `TargetBoundComponentDescriptor` array that satisfies the planner/runner interface requirements.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// CLI composition boundary - runtime assertion + type narrowing
|
|
119
|
+
const rawComponents = [config.target, config.adapter, ...(config.extensions ?? [])];
|
|
120
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
121
|
+
config.family.familyId,
|
|
122
|
+
config.target.targetId,
|
|
123
|
+
rawComponents,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Now frameworkComponents is typed as TargetBoundComponentDescriptor<TFamilyId, TTargetId>[]
|
|
127
|
+
const planner = target.migrations.createPlanner(sqlFamilyInstance);
|
|
128
|
+
planner.plan({ contract, schema, policy, frameworkComponents });
|
|
129
|
+
```
|
|
130
|
+
|
|
105
131
|
## Package Location
|
|
106
132
|
|
|
107
133
|
This package is part of the **framework domain**, **core layer**, **migration plane**:
|
|
108
134
|
- **Domain**: framework (target-agnostic)
|
|
109
135
|
- **Layer**: core
|
|
110
136
|
- **Plane**: migration (control plane operations)
|
|
111
|
-
- **Path**: `packages/framework/core
|
|
137
|
+
- **Path**: `packages/1-framework/1-core/migration/control-plane`
|
|
112
138
|
|
|
113
139
|
## Related Documentation
|
|
114
140
|
|
|
@@ -62,7 +62,7 @@ function errorContractValidationFailed(reason, options) {
|
|
|
62
62
|
return new CliStructuredError("4003", "Contract validation failed", {
|
|
63
63
|
domain: "CLI",
|
|
64
64
|
why: reason,
|
|
65
|
-
fix: "
|
|
65
|
+
fix: "Re-run `prisma-next contract emit`, or fix the contract file and try again",
|
|
66
66
|
docsUrl: "https://prisma-next.dev/docs/contracts",
|
|
67
67
|
...options?.where ? { where: options.where } : {}
|
|
68
68
|
});
|
|
@@ -71,15 +71,16 @@ function errorFileNotFound(filePath, options) {
|
|
|
71
71
|
return new CliStructuredError("4004", "File not found", {
|
|
72
72
|
domain: "CLI",
|
|
73
73
|
why: options?.why ?? `File not found: ${filePath}`,
|
|
74
|
-
fix: "Check that the file path is correct",
|
|
75
|
-
where: { path: filePath }
|
|
74
|
+
fix: options?.fix ?? "Check that the file path is correct",
|
|
75
|
+
where: { path: filePath },
|
|
76
|
+
...options?.docsUrl ? { docsUrl: options.docsUrl } : {}
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
function errorDatabaseUrlRequired(options) {
|
|
79
80
|
return new CliStructuredError("4005", "Database URL is required", {
|
|
80
81
|
domain: "CLI",
|
|
81
|
-
why: options?.why ?? "Database URL is required for
|
|
82
|
-
fix:
|
|
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'
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
86
|
function errorQueryRunnerFactoryRequired(options) {
|
|
@@ -98,12 +99,58 @@ function errorFamilyReadMarkerSqlRequired(options) {
|
|
|
98
99
|
docsUrl: "https://prisma-next.dev/docs/cli/db-verify"
|
|
99
100
|
});
|
|
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
|
+
}
|
|
101
114
|
function errorDriverRequired(options) {
|
|
102
115
|
return new CliStructuredError("4010", "Driver is required for DB-connected commands", {
|
|
103
116
|
domain: "CLI",
|
|
104
|
-
why: options?.why ?? "Config.driver is required for
|
|
105
|
-
fix: "Add driver to prisma-next.config.ts",
|
|
106
|
-
docsUrl: "https://prisma-next.dev/docs/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"
|
|
107
154
|
});
|
|
108
155
|
}
|
|
109
156
|
function errorConfigValidation(field, options) {
|
|
@@ -167,7 +214,11 @@ export {
|
|
|
167
214
|
errorDatabaseUrlRequired,
|
|
168
215
|
errorQueryRunnerFactoryRequired,
|
|
169
216
|
errorFamilyReadMarkerSqlRequired,
|
|
217
|
+
errorJsonFormatNotSupported,
|
|
170
218
|
errorDriverRequired,
|
|
219
|
+
errorContractMissingExtensionPacks,
|
|
220
|
+
errorMigrationPlanningFailed,
|
|
221
|
+
errorTargetMigrationNotSupported,
|
|
171
222
|
errorConfigValidation,
|
|
172
223
|
errorMarkerMissing,
|
|
173
224
|
errorHashMismatch,
|
|
@@ -175,4 +226,4 @@ export {
|
|
|
175
226
|
errorRuntime,
|
|
176
227
|
errorUnexpected
|
|
177
228
|
};
|
|
178
|
-
//# sourceMappingURL=chunk-
|
|
229
|
+
//# sourceMappingURL=chunk-U5RYT6PT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 ?? 'Check the error message and try again',\n });\n}\n"],"mappings":";AAkCO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAMA;AAAA,EACA;AAAA,EAET,YACE,MACA,SACA,SASA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS,SAAS,UAAU;AACjC,SAAK,WAAW,SAAS,YAAY;AACrC,SAAK,MAAM,SAAS;AACpB,SAAK,MAAM,SAAS;AACpB,SAAK,QAAQ,SAAS,QAClB;AAAA,MACE,MAAM,QAAQ,MAAM;AAAA,MACpB,MAAM,QAAQ,MAAM;AAAA,IACtB,IACA;AACJ,SAAK,OAAO,SAAS;AACrB,SAAK,UAAU,SAAS;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,aAA+B;AAC7B,UAAM,aAAa,KAAK,WAAW,QAAQ,YAAY;AACvD,WAAO;AAAA,MACL,MAAM,GAAG,UAAU,GAAG,KAAK,IAAI;AAAA,MAC/B,QAAQ,KAAK;AAAA,MACb,UAAU,KAAK;AAAA,MACf,SAAS,KAAK;A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AQ,iBAAiB;AAAA,IACrD,QAAQ;AAAA,IACR,KAAK,SAAS,OAAO;AAAA,IACrB,KAAK;AAAA,IACL,GAAI,SAAS,YAAY,SAAS,SAC9B;AAAA,MACE,MAAM;AAAA,QACJ,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,QACzD,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;AAAA,MACrD;AAAA,IACF,IACA,CAAC;AAAA,EACP,CAAC;AACH;AAKO,SAAS,oBACd,UACA,QACA,SAGoB;AACpB,SAAO,IAAI,mBAAmB,QAAQ,mBAAmB;AAAA,IACvD,QAAQ;AAAA,IACR,KACE,SAAS,OACT,2DAA2D,QAAQ,aAAa,MAAM;AAAA,IACxF,KAAK;AAAA,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,7 +1,8 @@
|
|
|
1
1
|
import { ControlFamilyDescriptor, ControlTargetDescriptor, ControlAdapterDescriptor, ControlExtensionDescriptor, ControlDriverDescriptor } from './types.js';
|
|
2
|
+
import '@prisma-next/contract/framework-components';
|
|
2
3
|
import '@prisma-next/contract/ir';
|
|
3
|
-
import '@prisma-next/contract/pack-manifest-types';
|
|
4
4
|
import '@prisma-next/contract/types';
|
|
5
|
+
import '@prisma-next/utils/result';
|
|
5
6
|
import './schema-view.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -36,7 +37,7 @@ interface PrismaNextConfig<TFamilyId extends string = string, TTargetId extends
|
|
|
36
37
|
readonly family: ControlFamilyDescriptor<TFamilyId>;
|
|
37
38
|
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
|
|
38
39
|
readonly adapter: ControlAdapterDescriptor<TFamilyId, TTargetId>;
|
|
39
|
-
readonly
|
|
40
|
+
readonly extensionPacks?: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
|
|
40
41
|
/**
|
|
41
42
|
* Driver descriptor for DB-connected CLI commands.
|
|
42
43
|
* Required for DB-connected commands (e.g., db verify).
|
|
@@ -14,7 +14,7 @@ var PrismaNextConfigSchema = type({
|
|
|
14
14
|
// ControlTargetDescriptor - validated separately
|
|
15
15
|
adapter: "unknown",
|
|
16
16
|
// ControlAdapterDescriptor - validated separately
|
|
17
|
-
"
|
|
17
|
+
"extensionPacks?": "unknown[]",
|
|
18
18
|
"driver?": "unknown",
|
|
19
19
|
// ControlDriverDescriptor - validated separately (optional)
|
|
20
20
|
"db?": "unknown",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config-types.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { type } from 'arktype';\nimport type {\n ControlAdapterDescriptor,\n ControlDriverDescriptor,\n ControlDriverInstance,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from './types';\n\n/**\n * Type alias for CLI driver instances.\n */\nexport type CliDriver = ControlDriverInstance
|
|
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,8 +1,9 @@
|
|
|
1
1
|
import { PrismaNextConfig } from './config-types.js';
|
|
2
2
|
import './types.js';
|
|
3
|
+
import '@prisma-next/contract/framework-components';
|
|
3
4
|
import '@prisma-next/contract/ir';
|
|
4
|
-
import '@prisma-next/contract/pack-manifest-types';
|
|
5
5
|
import '@prisma-next/contract/types';
|
|
6
|
+
import '@prisma-next/utils/result';
|
|
6
7
|
import './schema-view.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
errorConfigValidation
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-U5RYT6PT.js";
|
|
4
4
|
|
|
5
5
|
// src/config-validation.ts
|
|
6
6
|
function validateConfig(config) {
|
|
@@ -30,9 +30,9 @@ function validateConfig(config) {
|
|
|
30
30
|
why: "Config.family must have familyId: string"
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
34
|
-
throw errorConfigValidation("family.
|
|
35
|
-
why: "Config.family must have
|
|
33
|
+
if (typeof family["version"] !== "string") {
|
|
34
|
+
throw errorConfigValidation("family.version", {
|
|
35
|
+
why: "Config.family must have version: string"
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
if (!family["hook"] || typeof family["hook"] !== "object") {
|
|
@@ -62,9 +62,9 @@ function validateConfig(config) {
|
|
|
62
62
|
why: "Config.target must have familyId: string"
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
if (
|
|
66
|
-
throw errorConfigValidation("target.
|
|
67
|
-
why: "Config.target must have
|
|
65
|
+
if (typeof target["version"] !== "string") {
|
|
66
|
+
throw errorConfigValidation("target.version", {
|
|
67
|
+
why: "Config.target must have version: string"
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
if (target["familyId"] !== familyId) {
|
|
@@ -99,9 +99,9 @@ function validateConfig(config) {
|
|
|
99
99
|
why: "Config.adapter must have familyId: string"
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
if (
|
|
103
|
-
throw errorConfigValidation("adapter.
|
|
104
|
-
why: "Config.adapter must have
|
|
102
|
+
if (typeof adapter["version"] !== "string") {
|
|
103
|
+
throw errorConfigValidation("adapter.version", {
|
|
104
|
+
why: "Config.adapter must have version: string"
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
if (adapter["familyId"] !== familyId) {
|
|
@@ -152,9 +152,9 @@ function validateConfig(config) {
|
|
|
152
152
|
why: "Config.extensions items must have familyId: string"
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
if (
|
|
156
|
-
throw errorConfigValidation("extensions[].
|
|
157
|
-
why: "Config.extensions items must have
|
|
155
|
+
if (typeof extObj["version"] !== "string") {
|
|
156
|
+
throw errorConfigValidation("extensions[].version", {
|
|
157
|
+
why: "Config.extensions items must have version: string"
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
if (extObj["familyId"] !== familyId) {
|
|
@@ -191,9 +191,9 @@ function validateConfig(config) {
|
|
|
191
191
|
why: "Config.driver must have id: string"
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
if (
|
|
195
|
-
throw errorConfigValidation("driver.
|
|
196
|
-
why: "Config.driver must have
|
|
194
|
+
if (typeof driver["version"] !== "string") {
|
|
195
|
+
throw errorConfigValidation("driver.version", {
|
|
196
|
+
why: "Config.driver must have version: string"
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
if (typeof driver["familyId"] !== "string") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config-validation.ts"],"sourcesContent":["import type { PrismaNextConfig } from './config-types';\nimport { errorConfigValidation } from './errors';\n\n/**\n * Validates that the config has the required structure.\n * This is pure validation logic with no file I/O or CLI awareness.\n *\n * @param config - Config object to validate\n * @throws CliStructuredError if config structure is invalid\n */\nexport function validateConfig(config: unknown): asserts config is PrismaNextConfig {\n if (!config || typeof config !== 'object') {\n throw errorConfigValidation('object', {\n why: 'Config must be an object',\n });\n }\n\n const configObj = config as Record<string, unknown>;\n\n if (!configObj['family']) {\n throw errorConfigValidation('family');\n }\n\n if (!configObj['target']) {\n throw errorConfigValidation('target');\n }\n\n if (!configObj['adapter']) {\n throw errorConfigValidation('adapter');\n }\n\n // Validate family descriptor\n const family = configObj['family'] as Record<string, unknown>;\n if (family['kind'] !== 'family') {\n throw errorConfigValidation('family.kind', {\n why: 'Config.family must have kind: \"family\"',\n });\n }\n if (typeof family['familyId'] !== 'string') {\n throw errorConfigValidation('family.familyId', {\n why: 'Config.family must have familyId: string',\n });\n }\n if (!family['manifest'] || typeof family['manifest'] !== 'object') {\n throw errorConfigValidation('family.manifest', {\n why: 'Config.family must have manifest: ExtensionPackManifest',\n });\n }\n if (!family['hook'] || typeof family['hook'] !== 'object') {\n throw errorConfigValidation('family.hook', {\n why: 'Config.family must have hook: TargetFamilyHook',\n });\n }\n if (typeof family['create'] !== 'function') {\n throw errorConfigValidation('family.create', {\n why: 'Config.family must have create: function',\n });\n }\n\n const familyId = family['familyId'] as string;\n\n // Validate target descriptor\n const target = configObj['target'] as Record<string, unknown>;\n if (target['kind'] !== 'target') {\n throw errorConfigValidation('target.kind', {\n why: 'Config.target must have kind: \"target\"',\n });\n }\n if (typeof target['id'] !== 'string') {\n throw errorConfigValidation('target.id', {\n why: 'Config.target must have id: string',\n });\n }\n if (typeof target['familyId'] !== 'string') {\n throw errorConfigValidation('target.familyId', {\n why: 'Config.target must have familyId: string',\n });\n }\n if (!target['manifest'] || typeof target['manifest'] !== 'object') {\n throw errorConfigValidation('target.manifest', {\n why: 'Config.target must have manifest: ExtensionPackManifest',\n });\n }\n if (target['familyId'] !== familyId) {\n throw errorConfigValidation('target.familyId', {\n why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target['familyId']})`,\n });\n }\n if (typeof target['targetId'] !== 'string') {\n throw errorConfigValidation('target.targetId', {\n why: 'Config.target must have targetId: string',\n });\n }\n if (typeof target['create'] !== 'function') {\n throw errorConfigValidation('target.create', {\n why: 'Config.target must have create: function',\n });\n }\n const expectedTargetId = target['targetId'] as string;\n\n // Validate adapter descriptor\n const adapter = configObj['adapter'] as Record<string, unknown>;\n if (adapter['kind'] !== 'adapter') {\n throw errorConfigValidation('adapter.kind', {\n why: 'Config.adapter must have kind: \"adapter\"',\n });\n }\n if (typeof adapter['id'] !== 'string') {\n throw errorConfigValidation('adapter.id', {\n why: 'Config.adapter must have id: string',\n });\n }\n if (typeof adapter['familyId'] !== 'string') {\n throw errorConfigValidation('adapter.familyId', {\n why: 'Config.adapter must have familyId: string',\n });\n }\n if (!adapter['manifest'] || typeof adapter['manifest'] !== 'object') {\n throw errorConfigValidation('adapter.manifest', {\n why: 'Config.adapter must have manifest: ExtensionPackManifest',\n });\n }\n if (adapter['familyId'] !== familyId) {\n throw errorConfigValidation('adapter.familyId', {\n why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter['familyId']})`,\n });\n }\n if (typeof adapter['targetId'] !== 'string') {\n throw errorConfigValidation('adapter.targetId', {\n why: 'Config.adapter must have targetId: string',\n });\n }\n if (adapter['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('adapter.targetId', {\n why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter['targetId']})`,\n });\n }\n if (typeof adapter['create'] !== 'function') {\n throw errorConfigValidation('adapter.create', {\n why: 'Config.adapter must have create: function',\n });\n }\n\n // Validate extensions array if present\n if (configObj['extensions'] !== undefined) {\n if (!Array.isArray(configObj['extensions'])) {\n throw errorConfigValidation('extensions', {\n why: 'Config.extensions must be an array',\n });\n }\n for (const ext of configObj['extensions']) {\n if (!ext || typeof ext !== 'object') {\n throw errorConfigValidation('extensions[]', {\n why: 'Config.extensions must contain ExtensionDescriptor objects',\n });\n }\n const extObj = ext as Record<string, unknown>;\n if (extObj['kind'] !== 'extension') {\n throw errorConfigValidation('extensions[].kind', {\n why: 'Config.extensions items must have kind: \"extension\"',\n });\n }\n if (typeof extObj['id'] !== 'string') {\n throw errorConfigValidation('extensions[].id', {\n why: 'Config.extensions items must have id: string',\n });\n }\n if (typeof extObj['familyId'] !== 'string') {\n throw errorConfigValidation('extensions[].familyId', {\n why: 'Config.extensions items must have familyId: string',\n });\n }\n if (!extObj['manifest'] || typeof extObj['manifest'] !== 'object') {\n throw errorConfigValidation('extensions[].manifest', {\n why: 'Config.extensions items must have manifest: ExtensionPackManifest',\n });\n }\n if (extObj['familyId'] !== familyId) {\n throw errorConfigValidation('extensions[].familyId', {\n why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj['familyId']})`,\n });\n }\n if (typeof extObj['targetId'] !== 'string') {\n throw errorConfigValidation('extensions[].targetId', {\n why: 'Config.extensions items must have targetId: string',\n });\n }\n if (extObj['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('extensions[].targetId', {\n why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj['targetId']})`,\n });\n }\n if (typeof extObj['create'] !== 'function') {\n throw errorConfigValidation('extensions[].create', {\n why: 'Config.extensions items must have create: function',\n });\n }\n }\n }\n\n // Validate driver descriptor if present\n if (configObj['driver'] !== undefined) {\n const driver = configObj['driver'] as Record<string, unknown>;\n if (driver['kind'] !== 'driver') {\n throw errorConfigValidation('driver.kind', {\n why: 'Config.driver must have kind: \"driver\"',\n });\n }\n if (typeof driver['id'] !== 'string') {\n throw errorConfigValidation('driver.id', {\n why: 'Config.driver must have id: string',\n });\n }\n if (!driver['manifest'] || typeof driver['manifest'] !== 'object') {\n throw errorConfigValidation('driver.manifest', {\n why: 'Config.driver must have manifest: ExtensionPackManifest',\n });\n }\n if (typeof driver['familyId'] !== 'string') {\n throw errorConfigValidation('driver.familyId', {\n why: 'Config.driver must have familyId: string',\n });\n }\n if (driver['familyId'] !== familyId) {\n throw errorConfigValidation('driver.familyId', {\n why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver['familyId']})`,\n });\n }\n if (typeof driver['targetId'] !== 'string') {\n throw errorConfigValidation('driver.targetId', {\n why: 'Config.driver must have targetId: string',\n });\n }\n if (driver['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('driver.targetId', {\n why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver['targetId']})`,\n });\n }\n if (typeof driver['create'] !== 'function') {\n throw errorConfigValidation('driver.create', {\n why: 'Config.driver must have create: function',\n });\n }\n }\n\n // Validate contract config if present (structure validation - defineConfig() handles normalization)\n if (configObj['contract'] !== undefined) {\n const contract = configObj['contract'] as Record<string, unknown>;\n if (!contract || typeof contract !== 'object') {\n throw errorConfigValidation('contract', {\n why: 'Config.contract must be an object',\n });\n }\n if (!('source' in contract)) {\n throw errorConfigValidation('contract.source', {\n why: 'Config.contract.source is required when contract is provided',\n });\n }\n if (contract['output'] !== undefined && typeof contract['output'] !== 'string') {\n throw errorConfigValidation('contract.output', {\n why: 'Config.contract.output must be a string when provided',\n });\n }\n if (contract['types'] !== undefined && typeof contract['types'] !== 'string') {\n throw errorConfigValidation('contract.types', {\n why: 'Config.contract.types must be a string when provided',\n });\n }\n }\n}\n"],"mappings":";;;;;AAUO,SAAS,eAAe,QAAqD;AAClF,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,sBAAsB,UAAU;AAAA,MACpC,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AAEA,QAAM,YAAY;AAElB,MAAI,CAAC,UAAU,QAAQ,GAAG;AACxB,UAAM,sBAAsB,QAAQ;AAAA,EACtC;AAEA,MAAI,CAAC,UAAU,QAAQ,GAAG;AACxB,UAAM,sBAAsB,QAAQ;AAAA,EACtC;AAEA,MAAI,CAAC,UAAU,SAAS,GAAG;AACzB,UAAM,sBAAsB,SAAS;AAAA,EACvC;AAGA,QAAM,SAAS,UAAU,QAAQ;AACjC,MAAI,OAAO,MAAM,MAAM,UAAU;AAC/B,UAAM,sBAAsB,eAAe;AAAA,MACzC,K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AAC;AAAA,IACH;AACA,QAAI,OAAO,OAAO,QAAQ,MAAM,YAAY;AAC1C,YAAM,sBAAsB,iBAAiB;AAAA,QAC3C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AAAA,EACF;AAGA,MAAI,UAAU,UAAU,MAAM,QAAW;AACvC,UAAM,WAAW,UAAU,UAAU;AACrC,QAAI,CAAC,YAAY,OAAO,aAAa,UAAU;AAC7C,YAAM,sBAAsB,YAAY;AAAA,QACtC,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,EAAE,YAAY,WAAW;AAC3B,YAAM,sBAAsB,mBAAmB;AAAA,QAC7C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,SAAS,QAAQ,MAAM,UAAa,OAAO,SAAS,QAAQ,MAAM,UAAU;AAC9E,YAAM,sBAAsB,mBAAmB;AAAA,QAC7C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,SAAS,OAAO,MAAM,UAAa,OAAO,SAAS,OAAO,MAAM,UAAU;AAC5E,YAAM,sBAAsB,kBAAkB;AAAA,QAC5C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/config-validation.ts"],"sourcesContent":["import type { PrismaNextConfig } from './config-types';\nimport { errorConfigValidation } from './errors';\n\n/**\n * Validates that the config has the required structure.\n * This is pure validation logic with no file I/O or CLI awareness.\n *\n * @param config - Config object to validate\n * @throws CliStructuredError if config structure is invalid\n */\nexport function validateConfig(config: unknown): asserts config is PrismaNextConfig {\n if (!config || typeof config !== 'object') {\n throw errorConfigValidation('object', {\n why: 'Config must be an object',\n });\n }\n\n const configObj = config as Record<string, unknown>;\n\n if (!configObj['family']) {\n throw errorConfigValidation('family');\n }\n\n if (!configObj['target']) {\n throw errorConfigValidation('target');\n }\n\n if (!configObj['adapter']) {\n throw errorConfigValidation('adapter');\n }\n\n // Validate family descriptor\n const family = configObj['family'] as Record<string, unknown>;\n if (family['kind'] !== 'family') {\n throw errorConfigValidation('family.kind', {\n why: 'Config.family must have kind: \"family\"',\n });\n }\n if (typeof family['familyId'] !== 'string') {\n throw errorConfigValidation('family.familyId', {\n why: 'Config.family must have familyId: string',\n });\n }\n if (typeof family['version'] !== 'string') {\n throw errorConfigValidation('family.version', {\n why: 'Config.family must have version: string',\n });\n }\n if (!family['hook'] || typeof family['hook'] !== 'object') {\n throw errorConfigValidation('family.hook', {\n why: 'Config.family must have hook: TargetFamilyHook',\n });\n }\n if (typeof family['create'] !== 'function') {\n throw errorConfigValidation('family.create', {\n why: 'Config.family must have create: function',\n });\n }\n\n const familyId = family['familyId'] as string;\n\n // Validate target descriptor\n const target = configObj['target'] as Record<string, unknown>;\n if (target['kind'] !== 'target') {\n throw errorConfigValidation('target.kind', {\n why: 'Config.target must have kind: \"target\"',\n });\n }\n if (typeof target['id'] !== 'string') {\n throw errorConfigValidation('target.id', {\n why: 'Config.target must have id: string',\n });\n }\n if (typeof target['familyId'] !== 'string') {\n throw errorConfigValidation('target.familyId', {\n why: 'Config.target must have familyId: string',\n });\n }\n if (typeof target['version'] !== 'string') {\n throw errorConfigValidation('target.version', {\n why: 'Config.target must have version: string',\n });\n }\n if (target['familyId'] !== familyId) {\n throw errorConfigValidation('target.familyId', {\n why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target['familyId']})`,\n });\n }\n if (typeof target['targetId'] !== 'string') {\n throw errorConfigValidation('target.targetId', {\n why: 'Config.target must have targetId: string',\n });\n }\n if (typeof target['create'] !== 'function') {\n throw errorConfigValidation('target.create', {\n why: 'Config.target must have create: function',\n });\n }\n const expectedTargetId = target['targetId'] as string;\n\n // Validate adapter descriptor\n const adapter = configObj['adapter'] as Record<string, unknown>;\n if (adapter['kind'] !== 'adapter') {\n throw errorConfigValidation('adapter.kind', {\n why: 'Config.adapter must have kind: \"adapter\"',\n });\n }\n if (typeof adapter['id'] !== 'string') {\n throw errorConfigValidation('adapter.id', {\n why: 'Config.adapter must have id: string',\n });\n }\n if (typeof adapter['familyId'] !== 'string') {\n throw errorConfigValidation('adapter.familyId', {\n why: 'Config.adapter must have familyId: string',\n });\n }\n if (typeof adapter['version'] !== 'string') {\n throw errorConfigValidation('adapter.version', {\n why: 'Config.adapter must have version: string',\n });\n }\n if (adapter['familyId'] !== familyId) {\n throw errorConfigValidation('adapter.familyId', {\n why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter['familyId']})`,\n });\n }\n if (typeof adapter['targetId'] !== 'string') {\n throw errorConfigValidation('adapter.targetId', {\n why: 'Config.adapter must have targetId: string',\n });\n }\n if (adapter['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('adapter.targetId', {\n why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter['targetId']})`,\n });\n }\n if (typeof adapter['create'] !== 'function') {\n throw errorConfigValidation('adapter.create', {\n why: 'Config.adapter must have create: function',\n });\n }\n\n // Validate extensions array if present\n if (configObj['extensions'] !== undefined) {\n if (!Array.isArray(configObj['extensions'])) {\n throw errorConfigValidation('extensions', {\n why: 'Config.extensions must be an array',\n });\n }\n for (const ext of configObj['extensions']) {\n if (!ext || typeof ext !== 'object') {\n throw errorConfigValidation('extensions[]', {\n why: 'Config.extensions must contain ExtensionDescriptor objects',\n });\n }\n const extObj = ext as Record<string, unknown>;\n if (extObj['kind'] !== 'extension') {\n throw errorConfigValidation('extensions[].kind', {\n why: 'Config.extensions items must have kind: \"extension\"',\n });\n }\n if (typeof extObj['id'] !== 'string') {\n throw errorConfigValidation('extensions[].id', {\n why: 'Config.extensions items must have id: string',\n });\n }\n if (typeof extObj['familyId'] !== 'string') {\n throw errorConfigValidation('extensions[].familyId', {\n why: 'Config.extensions items must have familyId: string',\n });\n }\n if (typeof extObj['version'] !== 'string') {\n throw errorConfigValidation('extensions[].version', {\n why: 'Config.extensions items must have version: string',\n });\n }\n if (extObj['familyId'] !== familyId) {\n throw errorConfigValidation('extensions[].familyId', {\n why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj['familyId']})`,\n });\n }\n if (typeof extObj['targetId'] !== 'string') {\n throw errorConfigValidation('extensions[].targetId', {\n why: 'Config.extensions items must have targetId: string',\n });\n }\n if (extObj['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('extensions[].targetId', {\n why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj['targetId']})`,\n });\n }\n if (typeof extObj['create'] !== 'function') {\n throw errorConfigValidation('extensions[].create', {\n why: 'Config.extensions items must have create: function',\n });\n }\n }\n }\n\n // Validate driver descriptor if present\n if (configObj['driver'] !== undefined) {\n const driver = configObj['driver'] as Record<string, unknown>;\n if (driver['kind'] !== 'driver') {\n throw errorConfigValidation('driver.kind', {\n why: 'Config.driver must have kind: \"driver\"',\n });\n }\n if (typeof driver['id'] !== 'string') {\n throw errorConfigValidation('driver.id', {\n why: 'Config.driver must have id: string',\n });\n }\n if (typeof driver['version'] !== 'string') {\n throw errorConfigValidation('driver.version', {\n why: 'Config.driver must have version: string',\n });\n }\n if (typeof driver['familyId'] !== 'string') {\n throw errorConfigValidation('driver.familyId', {\n why: 'Config.driver must have familyId: string',\n });\n }\n if (driver['familyId'] !== familyId) {\n throw errorConfigValidation('driver.familyId', {\n why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver['familyId']})`,\n });\n }\n if (typeof driver['targetId'] !== 'string') {\n throw errorConfigValidation('driver.targetId', {\n why: 'Config.driver must have targetId: string',\n });\n }\n if (driver['targetId'] !== expectedTargetId) {\n throw errorConfigValidation('driver.targetId', {\n why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver['targetId']})`,\n });\n }\n if (typeof driver['create'] !== 'function') {\n throw errorConfigValidation('driver.create', {\n why: 'Config.driver must have create: function',\n });\n }\n }\n\n // Validate contract config if present (structure validation - defineConfig() handles normalization)\n if (configObj['contract'] !== undefined) {\n const contract = configObj['contract'] as Record<string, unknown>;\n if (!contract || typeof contract !== 'object') {\n throw errorConfigValidation('contract', {\n why: 'Config.contract must be an object',\n });\n }\n if (!('source' in contract)) {\n throw errorConfigValidation('contract.source', {\n why: 'Config.contract.source is required when contract is provided',\n });\n }\n if (contract['output'] !== undefined && typeof contract['output'] !== 'string') {\n throw errorConfigValidation('contract.output', {\n why: 'Config.contract.output must be a string when provided',\n });\n }\n if (contract['types'] !== undefined && typeof contract['types'] !== 'string') {\n throw errorConfigValidation('contract.types', {\n why: 'Config.contract.types must be a string when provided',\n });\n }\n }\n}\n"],"mappings":";;;;;AAUO,SAAS,eAAe,QAAqD;AAClF,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,sBAAsB,UAAU;AAAA,MACpC,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AAEA,QAAM,YAAY;AAElB,MAAI,CAAC,UAAU,QAAQ,GAAG;AACxB,UAAM,sBAAsB,QAAQ;AAAA,EACtC;AAEA,MAAI,CAAC,UAAU,QAAQ,GAAG;AACxB,UAAM,sBAAsB,QAAQ;AAAA,EACtC;AAEA,MAAI,CAAC,UAAU,SAAS,GAAG;AACzB,UAAM,sBAAsB,SAAS;AAAA,EACvC;AAGA,QAAM,SAAS,UAAU,QAAQ;AACjC,MAAI,OAAO,MAAM,MAAM,UAAU;AAC/B,UAAM,sBAAsB,eAAe;AAAA,MACzC,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,MAAI,OAAO,OAAO,UAAU,MAAM,UAAU;AAC1C,UAAM,sBAAsB,mBAAmB;AAAA,MAC7C,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,MAAI,OAAO,OAAO,SAAS,MAAM,UAAU;AACzC,UAAM,sBAAsB,kBAAkB;AAAA,MAC5C,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,MAAI,CAAC,OAAO,MAAM,KAAK,OAAO,OAAO,MAAM,MAAM,UAAU;AACzD,UAAM,sBAAsB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AO,SAAS,QAAQ,MAAM,UAAU;AAC9E,YAAM,sBAAsB,mBAAmB;AAAA,QAC7C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AACA,QAAI,SAAS,OAAO,MAAM,UAAa,OAAO,SAAS,OAAO,MAAM,UAAU;AAC5E,YAAM,sBAAsB,kBAAkB;AAAA,QAC5C,KAAK;AAAA,MACP,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
|
@@ -30,7 +30,7 @@ type ContractInput = {
|
|
|
30
30
|
models: Record<string, unknown>;
|
|
31
31
|
relations: Record<string, unknown>;
|
|
32
32
|
storage: Record<string, unknown>;
|
|
33
|
-
|
|
33
|
+
extensionPacks: Record<string, unknown>;
|
|
34
34
|
sources: Record<string, unknown>;
|
|
35
35
|
capabilities: Record<string, Record<string, boolean>>;
|
|
36
36
|
meta: Record<string, unknown>;
|
package/dist/exports/emission.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/emission/canonicalization.ts
|
|
2
|
+
import { isArrayEqual } from "@prisma-next/utils/array-equal";
|
|
2
3
|
var TOP_LEVEL_ORDER = [
|
|
3
4
|
"schemaVersion",
|
|
4
5
|
"canonicalVersion",
|
|
@@ -9,7 +10,7 @@ var TOP_LEVEL_ORDER = [
|
|
|
9
10
|
"models",
|
|
10
11
|
"storage",
|
|
11
12
|
"capabilities",
|
|
12
|
-
"
|
|
13
|
+
"extensionPacks",
|
|
13
14
|
"meta",
|
|
14
15
|
"sources"
|
|
15
16
|
];
|
|
@@ -43,19 +44,28 @@ function omitDefaults(obj, path) {
|
|
|
43
44
|
continue;
|
|
44
45
|
}
|
|
45
46
|
if (isDefaultValue(value)) {
|
|
46
|
-
const isRequiredModels = currentPath
|
|
47
|
-
const isRequiredTables = currentPath
|
|
48
|
-
const isRequiredRelations = currentPath
|
|
49
|
-
const
|
|
50
|
-
const isRequiredCapabilities = currentPath
|
|
51
|
-
const isRequiredMeta = currentPath
|
|
52
|
-
const isRequiredSources = currentPath
|
|
53
|
-
const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === "
|
|
54
|
-
const isModelRelations = currentPath.length === 3 && currentPath[0]
|
|
55
|
-
const isTableUniques = currentPath.length === 4 &&
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
const isRequiredModels = isArrayEqual(currentPath, ["models"]);
|
|
48
|
+
const isRequiredTables = isArrayEqual(currentPath, ["storage", "tables"]);
|
|
49
|
+
const isRequiredRelations = isArrayEqual(currentPath, ["relations"]);
|
|
50
|
+
const isRequiredExtensionPacks = isArrayEqual(currentPath, ["extensionPacks"]);
|
|
51
|
+
const isRequiredCapabilities = isArrayEqual(currentPath, ["capabilities"]);
|
|
52
|
+
const isRequiredMeta = isArrayEqual(currentPath, ["meta"]);
|
|
53
|
+
const isRequiredSources = isArrayEqual(currentPath, ["sources"]);
|
|
54
|
+
const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === "extensionPacks";
|
|
55
|
+
const isModelRelations = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[2]], ["models", "relations"]);
|
|
56
|
+
const isTableUniques = currentPath.length === 4 && isArrayEqual(
|
|
57
|
+
[currentPath[0], currentPath[1], currentPath[3]],
|
|
58
|
+
["storage", "tables", "uniques"]
|
|
59
|
+
);
|
|
60
|
+
const isTableIndexes = currentPath.length === 4 && isArrayEqual(
|
|
61
|
+
[currentPath[0], currentPath[1], currentPath[3]],
|
|
62
|
+
["storage", "tables", "indexes"]
|
|
63
|
+
);
|
|
64
|
+
const isTableForeignKeys = currentPath.length === 4 && isArrayEqual(
|
|
65
|
+
[currentPath[0], currentPath[1], currentPath[3]],
|
|
66
|
+
["storage", "tables", "foreignKeys"]
|
|
67
|
+
);
|
|
68
|
+
if (!isRequiredModels && !isRequiredTables && !isRequiredRelations && !isRequiredExtensionPacks && !isRequiredCapabilities && !isRequiredMeta && !isRequiredSources && !isExtensionNamespace && !isModelRelations && !isTableUniques && !isTableIndexes && !isTableForeignKeys) {
|
|
59
69
|
continue;
|
|
60
70
|
}
|
|
61
71
|
}
|
|
@@ -137,7 +147,7 @@ function canonicalizeContract(ir) {
|
|
|
137
147
|
models: ir.models,
|
|
138
148
|
relations: ir.relations,
|
|
139
149
|
storage: ir.storage,
|
|
140
|
-
|
|
150
|
+
extensionPacks: ir.extensionPacks,
|
|
141
151
|
capabilities: ir.capabilities,
|
|
142
152
|
meta: ir.meta,
|
|
143
153
|
sources: ir.sources
|
|
@@ -174,7 +184,7 @@ function computeCoreHash(contract) {
|
|
|
174
184
|
models: contract.models,
|
|
175
185
|
relations: contract.relations,
|
|
176
186
|
storage: contract.storage,
|
|
177
|
-
|
|
187
|
+
extensionPacks: contract.extensionPacks,
|
|
178
188
|
sources: contract.sources,
|
|
179
189
|
capabilities: contract.capabilities,
|
|
180
190
|
meta: contract.meta
|
|
@@ -190,7 +200,7 @@ function computeProfileHash(contract) {
|
|
|
190
200
|
models: {},
|
|
191
201
|
relations: {},
|
|
192
202
|
storage: {},
|
|
193
|
-
|
|
203
|
+
extensionPacks: {},
|
|
194
204
|
capabilities: contract.capabilities,
|
|
195
205
|
meta: {},
|
|
196
206
|
sources: {}
|
|
@@ -219,8 +229,8 @@ function validateCoreStructure(ir) {
|
|
|
219
229
|
if (!ir.relations || typeof ir.relations !== "object") {
|
|
220
230
|
throw new Error("ContractIR must have relations");
|
|
221
231
|
}
|
|
222
|
-
if (!ir.
|
|
223
|
-
throw new Error("ContractIR must have
|
|
232
|
+
if (!ir.extensionPacks || typeof ir.extensionPacks !== "object") {
|
|
233
|
+
throw new Error("ContractIR must have extensionPacks");
|
|
224
234
|
}
|
|
225
235
|
if (!ir.capabilities || typeof ir.capabilities !== "object") {
|
|
226
236
|
throw new Error("ContractIR must have capabilities");
|
|
@@ -232,16 +242,6 @@ function validateCoreStructure(ir) {
|
|
|
232
242
|
throw new Error("ContractIR must have sources");
|
|
233
243
|
}
|
|
234
244
|
}
|
|
235
|
-
function validateExtensions(ir, extensionIds) {
|
|
236
|
-
const extensions = ir.extensions;
|
|
237
|
-
for (const extensionId of extensionIds) {
|
|
238
|
-
if (!extensions[extensionId]) {
|
|
239
|
-
throw new Error(
|
|
240
|
-
`Extension "${extensionId}" must appear in contract.extensions.${extensionId}`
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
245
|
async function emit(ir, options, targetFamily) {
|
|
246
246
|
const { operationRegistry, codecTypeImports, operationTypeImports, extensionIds } = options;
|
|
247
247
|
validateCoreStructure(ir);
|
|
@@ -253,9 +253,6 @@ async function emit(ir, options, targetFamily) {
|
|
|
253
253
|
};
|
|
254
254
|
targetFamily.validateTypes(ir, ctx);
|
|
255
255
|
targetFamily.validateStructure(ir);
|
|
256
|
-
if (extensionIds) {
|
|
257
|
-
validateExtensions(ir, extensionIds);
|
|
258
|
-
}
|
|
259
256
|
const contractJson = {
|
|
260
257
|
schemaVersion: ir.schemaVersion,
|
|
261
258
|
targetFamily: ir.targetFamily,
|
|
@@ -263,7 +260,7 @@ async function emit(ir, options, targetFamily) {
|
|
|
263
260
|
models: ir.models,
|
|
264
261
|
relations: ir.relations,
|
|
265
262
|
storage: ir.storage,
|
|
266
|
-
|
|
263
|
+
extensionPacks: ir.extensionPacks,
|
|
267
264
|
capabilities: ir.capabilities,
|
|
268
265
|
meta: ir.meta,
|
|
269
266
|
sources: ir.sources
|