Repository navigation
refactor(config): extract @prisma-next/config - #197
Conversation
TML-2018 Optional: split up `1-core/migration`
packages/1-framework/1-core/migration/control-plane/src/config-types.ts This package has become overloaded, with config types validations and contract types present. This task is to split out some more framework core packages - at least one for config types and logic. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughA new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Comment |
d9a525f to
a2c6327
Compare
@prisma-next/runtime-executor
@prisma-next/sql-runtime
@prisma-next/extension-pgvector
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/contract-authoring
@prisma-next/contract-ts
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/cli
@prisma-next/emitter
@prisma-next/eslint-plugin
@prisma-next/vite-plugin-contract-emit
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/family-sql
@prisma-next/sql-kysely-lane
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-lane
@prisma-next/target-postgres
@prisma-next/driver-postgres
@prisma-next/core-control-plane
@prisma-next/core-execution-plane
@prisma-next/config
@prisma-next/contract
@prisma-next/operations
@prisma-next/plan
@prisma-next/utils
@prisma-next/adapter-postgres
commit: |
a2c6327 to
c705a31
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/1-framework/1-core/shared/config/src/config-types.ts (1)
96-103:⚠️ Potential issue | 🔴 CriticalFix validation drift: use
extensionPacksconsistently in runtime validator and tests.The runtime validator in
config-validation.ts(lines 115–169) checks forconfigObj['extensions']and throws errors referencingConfig.extensions, but the type definition usesextensionPacks. This inconsistency allows non-TS configs to use the wrong key and pass validation.Update the validator to check
extensionPacksinstead, and fix test fixtures inconfig-validation.test.ts(lines 194–280) that passextensions:to useextensionPacks:consistently with the type definition.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/shared/config/src/config-types.ts` around lines 96 - 103, The validator and tests use the wrong key name `extensions` while the type is `extensionPacks`; update the runtime validator in config-validation.ts (the block that inspects configObj['extensions'] and emits errors referencing Config.extensions) to instead check configObj['extensionPacks'] and update the error messages to reference Config.extensionPacks; also update test fixtures in config-validation.test.ts that currently pass `extensions:` to use `extensionPacks:` so tests align with the PrismaNextConfigSchema and prevent validation drift (refer to PrismaNextConfigSchema and ContractConfigSchema for the expected shape).
🧹 Nitpick comments (6)
packages/1-framework/1-core/shared/config/test/config-types.test-d.ts (1)
111-112: Add reason text to@ts-expect-errordirectives.Per coding guidelines,
@ts-expect-errorshould include a short reason explaining why the error is expected.📝 Suggested improvement
- // `@ts-expect-error` targetId mismatch + // `@ts-expect-error` targetId mismatch: mysql target descriptor incompatible with postgres config target: mysqlTargetDescriptor,And similarly on line 135:
- // `@ts-expect-error` targetId mismatch + // `@ts-expect-error` targetId mismatch: mysql adapter descriptor incompatible with postgres config adapter: mysqlAdapterDescriptor,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/shared/config/test/config-types.test-d.ts` around lines 111 - 112, Add a short reason to the `@ts-expect-error` directives that suppress the expected type mismatch for the `target` property (the line referencing `target: mysqlTargetDescriptor`) so reviewers know why the error is intentional; update that directive to something like `// `@ts-expect-error`: intentional targetId type mismatch for test` and do the same for the other occurrence that references `mysqlTargetDescriptor` (the later `@ts-expect-error` in the same test file) so both suppressed errors include a brief explanatory reason.packages/2-sql/2-authoring/contract-psl/test/provider.test.ts (1)
1-3: Consider usingpatheinstead ofnode:path.Per coding guidelines and learnings, prefer
patheovernode:pathfor path operations across the codebase for consistent cross-platform behavior.📝 Suggested change
import { mkdtemp, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; -import { join } from 'node:path'; +import { join } from 'pathe';Based on learnings: "In the Prisma-next repository, prefer importing and using 'pathe' over the built-in 'node:path' module for path operations across the codebase."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-sql/2-authoring/contract-psl/test/provider.test.ts` around lines 1 - 3, Replace the node:path import with pathe: remove "join" from "node:path" and import "join" (or suitable pathe functions) from "pathe" instead; update any uses of join in the test (e.g., in provider.test.ts where join is used alongside mkdtemp, tmpdir, writeFile, rm) to rely on the pathe-provided join to ensure consistent cross-platform behavior.packages/1-framework/3-tooling/cli/src/commands/db-init.ts (1)
2-2: Preferpatheovernode:pathfor path operations.Based on learnings, the codebase prefers
pathefor consistent cross-platform path handling.♻️ Proposed fix
-import { relative, resolve } from 'node:path'; +import { relative, resolve } from 'pathe';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/src/commands/db-init.ts` at line 2, Replace the native Node path import with the project's preferred pathe module: update the import that currently brings in relative and resolve from 'node:path' to import them from 'pathe' instead (ensure functions referenced as relative and resolve in this file, e.g., any uses inside db-init.ts, continue to work unchanged).packages/1-framework/1-core/shared/config/tsconfig.prod.json (1)
4-6: Consider removing the commented-outrootDir.The commented placeholder serves no purpose. If it's intended as documentation for future use, it would be clearer to either remove it entirely or add a comment explaining why it's there.
🧹 Proposed cleanup
{ "$schema": "https://json.schemastore.org/tsconfig", - "extends": ["@prisma-next/tsconfig/prod"], - "compilerOptions": { - // "rootDir": "../../../../" - } + "extends": ["@prisma-next/tsconfig/prod"] }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/shared/config/tsconfig.prod.json` around lines 4 - 6, Remove the commented-out "rootDir": "../../../../" entry from tsconfig.prod.json (or replace it with a brief explanatory comment if you intend to keep it for future context); locate the commented line in the "compilerOptions" block and either delete it to clean up the config or change it into an explanatory comment that states why "rootDir" is omitted or what value should be used in production.packages/1-framework/3-tooling/cli/src/config-loader.ts (1)
1-1: Usepatheinstead ofnode:pathfor path operations.Per coding guidelines and learnings, prefer
patheovernode:pathfor consistent cross-platform behavior and non-Node runtime compatibility.♻️ Suggested change
-import { dirname, resolve } from 'node:path'; +import { dirname, resolve } from 'pathe';Based on learnings: "In the Prisma-next repository, prefer importing and using 'pathe' over the built-in 'node:path' module for path operations across the codebase (including CLI commands and tooling files)."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/src/config-loader.ts` at line 1, Replace the Node built-in path import with pathe: change the import of dirname and resolve from 'node:path' to import them from 'pathe' so all uses of dirname and resolve inside config-loader (e.g., in any functions or top-level logic referencing dirname or resolve) use pathe for consistent cross-platform/non-Node runtime behavior; update the import statement accordingly and ensure no other node:path usages remain in this file.packages/1-framework/3-tooling/cli/test/config-types.test.ts (1)
105-111: Consider using object matchers for related assertions.Lines 107-110 use multiple individual
expect().toBe()calls. Per coding guidelines, prefer object matchers when checking 2+ related values.♻️ Suggested refactor using toMatchObject
it('returns the config object unchanged when no contract', () => { const result = defineConfig(baseConfig); expect(result).toBe(baseConfig); - expect(result.family.familyId).toBe('sql'); - expect(result.target.id).toBe('postgres'); - expect(result.adapter.id).toBe('postgres'); + expect(result).toMatchObject({ + family: { familyId: 'sql' }, + target: { id: 'postgres' }, + adapter: { id: 'postgres' }, + }); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/test/config-types.test.ts` around lines 105 - 111, The test "returns the config object unchanged when no contract" uses multiple related assertions for properties; replace the separate expect(result.family.familyId).toBe('sql'), expect(result.target.id).toBe('postgres'), and expect(result.adapter.id).toBe('postgres') with a single object matcher on result (e.g., expect(result).toMatchObject({ family: { familyId: 'sql' }, target: { id: 'postgres' }, adapter: { id: 'postgres' }})) while keeping the identity assertion expect(result).toBe(baseConfig); update the test that calls defineConfig(baseConfig) to use this single toMatchObject assertion to verify related values together.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/1-framework/1-core/shared/config/src/config-validation.ts`:
- Around line 116-171: The validation currently inspects configObj['extensions']
but the canonical property is extensionPacks; update the checker in
config-validation.ts to look for configObj['extensionPacks'] (and iterate that
array) instead of configObj['extensions'], and adjust all related validation
keys/messages (e.g., 'extensions[]', 'extensions[].kind', etc.) to use
'extensionPacks[]' names so throwValidation uses the correct property
identifiers; keep the same item shape checks (kind, id, familyId, version,
targetId, create) and the existing familyId/targetId equality checks against
familyId and expectedTargetId.
In `@packages/1-framework/1-core/shared/config/test/config-validation.test.ts`:
- Around line 56-57: Tests and runtime validation are inconsistent: the fixture
uses the key extensionPacks while the validation/tests expect extensions; update
the validation logic and/or test fixtures in config-validation.test.ts so both
use the same canonical key (pick either extensionPacks or extensions), update
occurrences of the symbol extensionPacks or extensions in the file to match, and
add one explicit regression test asserting that the non-canonical key is either
rejected or accepted per API contract (i.e., a test that submits the alternate
key and expects a validation error or success).
---
Outside diff comments:
In `@packages/1-framework/1-core/shared/config/src/config-types.ts`:
- Around line 96-103: The validator and tests use the wrong key name
`extensions` while the type is `extensionPacks`; update the runtime validator in
config-validation.ts (the block that inspects configObj['extensions'] and emits
errors referencing Config.extensions) to instead check
configObj['extensionPacks'] and update the error messages to reference
Config.extensionPacks; also update test fixtures in config-validation.test.ts
that currently pass `extensions:` to use `extensionPacks:` so tests align with
the PrismaNextConfigSchema and prevent validation drift (refer to
PrismaNextConfigSchema and ContractConfigSchema for the expected shape).
---
Nitpick comments:
In `@packages/1-framework/1-core/shared/config/test/config-types.test-d.ts`:
- Around line 111-112: Add a short reason to the `@ts-expect-error` directives
that suppress the expected type mismatch for the `target` property (the line
referencing `target: mysqlTargetDescriptor`) so reviewers know why the error is
intentional; update that directive to something like `// `@ts-expect-error`:
intentional targetId type mismatch for test` and do the same for the other
occurrence that references `mysqlTargetDescriptor` (the later `@ts-expect-error`
in the same test file) so both suppressed errors include a brief explanatory
reason.
In `@packages/1-framework/1-core/shared/config/tsconfig.prod.json`:
- Around line 4-6: Remove the commented-out "rootDir": "../../../../" entry from
tsconfig.prod.json (or replace it with a brief explanatory comment if you intend
to keep it for future context); locate the commented line in the
"compilerOptions" block and either delete it to clean up the config or change it
into an explanatory comment that states why "rootDir" is omitted or what value
should be used in production.
In `@packages/1-framework/3-tooling/cli/src/commands/db-init.ts`:
- Line 2: Replace the native Node path import with the project's preferred pathe
module: update the import that currently brings in relative and resolve from
'node:path' to import them from 'pathe' instead (ensure functions referenced as
relative and resolve in this file, e.g., any uses inside db-init.ts, continue to
work unchanged).
In `@packages/1-framework/3-tooling/cli/src/config-loader.ts`:
- Line 1: Replace the Node built-in path import with pathe: change the import of
dirname and resolve from 'node:path' to import them from 'pathe' so all uses of
dirname and resolve inside config-loader (e.g., in any functions or top-level
logic referencing dirname or resolve) use pathe for consistent
cross-platform/non-Node runtime behavior; update the import statement
accordingly and ensure no other node:path usages remain in this file.
In `@packages/1-framework/3-tooling/cli/test/config-types.test.ts`:
- Around line 105-111: The test "returns the config object unchanged when no
contract" uses multiple related assertions for properties; replace the separate
expect(result.family.familyId).toBe('sql'),
expect(result.target.id).toBe('postgres'), and
expect(result.adapter.id).toBe('postgres') with a single object matcher on
result (e.g., expect(result).toMatchObject({ family: { familyId: 'sql' },
target: { id: 'postgres' }, adapter: { id: 'postgres' }})) while keeping the
identity assertion expect(result).toBe(baseConfig); update the test that calls
defineConfig(baseConfig) to use this single toMatchObject assertion to verify
related values together.
In `@packages/2-sql/2-authoring/contract-psl/test/provider.test.ts`:
- Around line 1-3: Replace the node:path import with pathe: remove "join" from
"node:path" and import "join" (or suitable pathe functions) from "pathe"
instead; update any uses of join in the test (e.g., in provider.test.ts where
join is used alongside mkdtemp, tmpdir, writeFile, rm) to rely on the
pathe-provided join to ensure consistent cross-platform behavior.
ℹ️ Review info
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Lite
⛔ Files ignored due to path filters (5)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlprojects/psl-contract-authoring/plans/optional-split-up-1-core-migration-plan.mdis excluded by!projects/**projects/psl-contract-authoring/plans/plan.mdis excluded by!projects/**projects/psl-contract-authoring/spec.mdis excluded by!projects/**projects/psl-contract-authoring/specs/optional-split-up-1-core-migration.spec.mdis excluded by!projects/**
📒 Files selected for processing (42)
packages/1-framework/1-core/migration/control-plane/README.mdpackages/1-framework/1-core/migration/control-plane/package.jsonpackages/1-framework/1-core/migration/control-plane/src/config-validation.tspackages/1-framework/1-core/migration/control-plane/test/config-types.test-d.tspackages/1-framework/1-core/migration/control-plane/test/config-validation.test.tspackages/1-framework/1-core/migration/control-plane/test/errors.test.tspackages/1-framework/1-core/migration/control-plane/tsdown.config.tspackages/1-framework/1-core/migration/control-plane/vitest.config.tspackages/1-framework/1-core/shared/config/README.mdpackages/1-framework/1-core/shared/config/biome.jsoncpackages/1-framework/1-core/shared/config/package.jsonpackages/1-framework/1-core/shared/config/src/config-types.tspackages/1-framework/1-core/shared/config/src/config-validation.tspackages/1-framework/1-core/shared/config/src/contract-source-types.tspackages/1-framework/1-core/shared/config/src/errors.tspackages/1-framework/1-core/shared/config/src/exports/config-types.tspackages/1-framework/1-core/shared/config/src/exports/config-validation.tspackages/1-framework/1-core/shared/config/src/exports/types.tspackages/1-framework/1-core/shared/config/src/types.tspackages/1-framework/1-core/shared/config/test/config-types.test-d.tspackages/1-framework/1-core/shared/config/test/config-validation.test.tspackages/1-framework/1-core/shared/config/tsconfig.jsonpackages/1-framework/1-core/shared/config/tsconfig.prod.jsonpackages/1-framework/1-core/shared/config/tsdown.config.tspackages/1-framework/1-core/shared/config/vitest.config.tspackages/1-framework/2-authoring/psl-parser/src/exports/types.tspackages/1-framework/2-authoring/psl-parser/test/parser.test.tspackages/1-framework/3-tooling/cli/package.jsonpackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/1-framework/3-tooling/cli/src/config-loader.tspackages/1-framework/3-tooling/cli/src/control-api/types.tspackages/1-framework/3-tooling/cli/src/exports/config-types.tspackages/1-framework/3-tooling/cli/test/config-types.test.tspackages/2-sql/2-authoring/contract-psl/package.jsonpackages/2-sql/2-authoring/contract-psl/src/interpreter.tspackages/2-sql/2-authoring/contract-psl/src/provider.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.test.tspackages/2-sql/2-authoring/contract-psl/test/provider.test.tspackages/2-sql/2-authoring/contract-ts/package.jsonpackages/2-sql/2-authoring/contract-ts/src/config-types.tspackages/2-sql/2-authoring/contract-ts/src/exports/config-types.tstsconfig.base.json
💤 Files with no reviewable changes (5)
- packages/1-framework/1-core/migration/control-plane/src/config-validation.ts
- packages/1-framework/1-core/migration/control-plane/test/config-types.test-d.ts
- packages/1-framework/1-core/migration/control-plane/tsdown.config.ts
- packages/1-framework/1-core/migration/control-plane/vitest.config.ts
- packages/1-framework/1-core/migration/control-plane/test/config-validation.test.ts
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/1-framework/1-core/shared/config/src/config-validation.ts`:
- Around line 15-235: validateConfig currently duplicates structural checks
already handled by Arktype schemas in defineConfig/config-types.ts; refactor by
removing the per-field typeof/required validations for descriptors (family,
target, adapter, driver, extensionPacks) from validateConfig and instead create
detailed Arktype schemas in config-types.ts for those descriptor shapes, keeping
only the runtime cross-field consistency checks (e.g. familyId and targetId
match validations) inside validateConfig; update defineConfig to use the new
Arktype descriptor schemas and ensure validateConfig still asserts and throws
via throwValidation only for the logical validators (familyId/targetId matching
and presence of top-level adapter/target/family references).
- Around line 34-213: The runtime validator is missing checks for the required
descriptor fields "id" and "manifest" on all control-plane descriptors; update
the validation logic for family, target, adapter, extensionPacks[] (extObj) and
driver to assert that ['id'] is a string and ['manifest'] exists and has the
correct shape (use the existing throwValidation helper for errors), i.e. add
checks like family['id'] typeof string and family['manifest'] typeof object (or
validate against ExtensionPackManifest), and mirror those checks for
target['id']/target['manifest'], adapter['id']/adapter['manifest'],
extensionPacks[].id/extensionPacks[].manifest (extObj), and
driver['id']/driver['manifest'] using the same error keys (e.g. 'family.id',
'family.manifest', 'extensionPacks[].manifest') so missing fields produce
consistent validation messages.
- Line 221: Replace the prototype-including property check "if (!('source' in
contract))" with an own-property check using Object.hasOwn(contract, 'source')
in the validation logic (the conditional that currently references contract and
'source'); specifically, change the test to if (!Object.hasOwn(contract,
'source')) so only own properties are considered during config validation for
the contract object.
ℹ️ Review info
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Lite
📒 Files selected for processing (3)
packages/1-framework/1-core/shared/config/README.mdpackages/1-framework/1-core/shared/config/src/config-validation.tspackages/1-framework/1-core/shared/config/test/config-validation.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/1-framework/1-core/shared/config/test/config-validation.test.ts
wmadden
left a comment
There was a problem hiding this comment.
Submitting stale pending review so thread-reply automation can proceed.
0b95d81 to
a02d925
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/1-framework/1-core/migration/control-plane/README.md (1)
33-49:⚠️ Potential issue | 🟡 MinorClarify the undefined
configvariable in the example.Line 46 references a
configvariable that is not defined anywhere in the example:const familyInstance = config.family.create(stack);This breaks the example's self-containment. Either introduce
configearlier in the example (showing how it's loaded/created), or replace this line with a comment explaining thatconfigwould typically come from loading a config file. Alternatively, ifconfigis not the main focus of this example, consider removing this line and keeping the example focused solely on stack creation.💡 Suggested clarification
Option 1: Add context for where
configcomes from:// Create a stack with sensible defaults const stack = createControlPlaneStack({ target: postgresTarget, adapter: postgresAdapter, driver: postgresDriver, // optional, defaults to undefined extensionPacks: [pgvector], // optional, defaults to [] }); -// Use stack for family instance creation -const familyInstance = config.family.create(stack); +// The stack is then used with your loaded config +// (typically from `@prisma-next/config`) +const familyInstance = loadedConfig.family.create(stack);Option 2: Remove the undefined reference and keep the example focused:
// Create a stack with sensible defaults const stack = createControlPlaneStack({ target: postgresTarget, adapter: postgresAdapter, driver: postgresDriver, // optional, defaults to undefined extensionPacks: [pgvector], // optional, defaults to [] }); -// Use stack for family instance creation -const familyInstance = config.family.create(stack); - // Stack is also used internally by ControlClient and CLI commands🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/migration/control-plane/README.md` around lines 33 - 49, The example shows createControlPlaneStack(...) but then calls an undefined config.family.create(stack); update the example to be self-contained: either add a brief snippet showing how to load/define config (e.g., a note that config is loaded from your app or config file and then used as config.family.create) or remove/replace the line with a single explanatory comment such as "// typically you'd create a family instance via your app config: config.family.create(stack)" so readers aren't left with an undefined symbol; ensure the change references createControlPlaneStack and the config.family.create(stack) call so it's clear what was adjusted.
🧹 Nitpick comments (2)
test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.missing-output.ts (1)
14-14: Add a negative runtime-validation case forextensionPackshere.Since this fixture intentionally bypasses
defineConfig, it’s a strong place to assert runtime rejection of malformedextensionPacks(not just[]) so the known validation drift is covered.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.missing-output.ts` at line 14, Add a negative runtime-validation case in the fixture that bypasses defineConfig by assigning a deliberately malformed value to extensionPacks (e.g., a string or object instead of an array of valid pack descriptors) and assert that loading/initializing the config throws/rejects at runtime; update the prisma-next.config.missing-output.ts fixture so extensionPacks is set to an invalid value and the test expects a runtime validation error when the config is consumed (referencing extensionPacks and the fact this fixture bypasses defineConfig).packages/1-framework/1-core/migration/control-plane/test/errors.test.ts (1)
139-143: Prefer object matchers for these related assertion groups.These tests check multiple related fields on the same object; switching to
toMatchObject(plus explicit undefined checks where needed) keeps failures more focused and matches repo test style.As per coding guidelines, "Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests".
Also applies to: 373-383
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/migration/control-plane/test/errors.test.ts` around lines 139 - 143, Replace the multiple separate assertions for errorConfigFileNotFound() with an object matcher: call errorConfigFileNotFound(), then use expect(...).toMatchObject({ code: '4001' }) and a separate expect(error.where).toBeUndefined() to keep the failure focused; do the same refactor for the related test block around the other occurrence (lines noted) so related fields are asserted via toMatchObject and explicit undefined checks for where.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/1-framework/1-core/shared/config/src/types.ts`:
- Line 77: The method signature for emitContract currently uses the redundant
union ContractIR | unknown—change its parameter type to match the other
interface methods by declaring emitContract(options: { readonly contractIR:
unknown }): Promise<EmitContractResult>; so the API is consistent with
schemaVerify, sign and introspect and the implementation can continue to
validate the input internally; update any related type references to remove the
misleading ContractIR | unknown union and keep EmitContractResult unchanged.
In `@packages/1-framework/3-tooling/cli/test/config-loader.test.ts`:
- Line 47: Add a regression test in config-loader.test.ts that asserts malformed
extensionPacks entries are rejected: construct a config object (or fixture) with
extensionPacks set to invalid values (e.g., [123], ["valid", {bad:"obj"}], or a
non-array) and call the same entry point used by other tests (the loader
function under test, e.g., loadConfig or parseConfig); expect it to throw/return
a validation error (use the existing test harness's expect(...).toThrow /
rejects.toThrow or equivalent) so invalid extensionPacks are explicitly covered
alongside the existing good-case tests that include extensionPacks: [].
---
Outside diff comments:
In `@packages/1-framework/1-core/migration/control-plane/README.md`:
- Around line 33-49: The example shows createControlPlaneStack(...) but then
calls an undefined config.family.create(stack); update the example to be
self-contained: either add a brief snippet showing how to load/define config
(e.g., a note that config is loaded from your app or config file and then used
as config.family.create) or remove/replace the line with a single explanatory
comment such as "// typically you'd create a family instance via your app
config: config.family.create(stack)" so readers aren't left with an undefined
symbol; ensure the change references createControlPlaneStack and the
config.family.create(stack) call so it's clear what was adjusted.
---
Nitpick comments:
In `@packages/1-framework/1-core/migration/control-plane/test/errors.test.ts`:
- Around line 139-143: Replace the multiple separate assertions for
errorConfigFileNotFound() with an object matcher: call
errorConfigFileNotFound(), then use expect(...).toMatchObject({ code: '4001' })
and a separate expect(error.where).toBeUndefined() to keep the failure focused;
do the same refactor for the related test block around the other occurrence
(lines noted) so related fields are asserted via toMatchObject and explicit
undefined checks for where.
In
`@test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.missing-output.ts`:
- Line 14: Add a negative runtime-validation case in the fixture that bypasses
defineConfig by assigning a deliberately malformed value to extensionPacks
(e.g., a string or object instead of an array of valid pack descriptors) and
assert that loading/initializing the config throws/rejects at runtime; update
the prisma-next.config.missing-output.ts fixture so extensionPacks is set to an
invalid value and the test expects a runtime validation error when the config is
consumed (referencing extensionPacks and the fact this fixture bypasses
defineConfig).
ℹ️ Review info
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Lite
⛔ Files ignored due to path filters (5)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlprojects/psl-contract-authoring/plans/optional-split-up-1-core-migration-plan.mdis excluded by!projects/**projects/psl-contract-authoring/plans/plan.mdis excluded by!projects/**projects/psl-contract-authoring/spec.mdis excluded by!projects/**projects/psl-contract-authoring/specs/optional-split-up-1-core-migration.spec.mdis excluded by!projects/**
📒 Files selected for processing (71)
packages/1-framework/1-core/migration/control-plane/README.mdpackages/1-framework/1-core/migration/control-plane/package.jsonpackages/1-framework/1-core/migration/control-plane/src/config-validation.tspackages/1-framework/1-core/migration/control-plane/test/config-types.test-d.tspackages/1-framework/1-core/migration/control-plane/test/config-validation.test.tspackages/1-framework/1-core/migration/control-plane/test/errors.test.tspackages/1-framework/1-core/migration/control-plane/tsdown.config.tspackages/1-framework/1-core/migration/control-plane/vitest.config.tspackages/1-framework/1-core/shared/config/README.mdpackages/1-framework/1-core/shared/config/biome.jsoncpackages/1-framework/1-core/shared/config/package.jsonpackages/1-framework/1-core/shared/config/src/config-types.tspackages/1-framework/1-core/shared/config/src/config-validation.tspackages/1-framework/1-core/shared/config/src/contract-source-types.tspackages/1-framework/1-core/shared/config/src/errors.tspackages/1-framework/1-core/shared/config/src/exports/config-types.tspackages/1-framework/1-core/shared/config/src/exports/config-validation.tspackages/1-framework/1-core/shared/config/src/exports/types.tspackages/1-framework/1-core/shared/config/src/types.tspackages/1-framework/1-core/shared/config/test/config-types.test-d.tspackages/1-framework/1-core/shared/config/test/config-validation.test.tspackages/1-framework/1-core/shared/config/tsconfig.jsonpackages/1-framework/1-core/shared/config/tsconfig.prod.jsonpackages/1-framework/1-core/shared/config/tsdown.config.tspackages/1-framework/1-core/shared/config/vitest.config.tspackages/1-framework/2-authoring/psl-parser/src/exports/types.tspackages/1-framework/2-authoring/psl-parser/test/parser.test.tspackages/1-framework/3-tooling/cli/package.jsonpackages/1-framework/3-tooling/cli/src/commands/db-init.tspackages/1-framework/3-tooling/cli/src/config-loader.tspackages/1-framework/3-tooling/cli/src/control-api/types.tspackages/1-framework/3-tooling/cli/src/exports/config-types.tspackages/1-framework/3-tooling/cli/test/config-loader.test.tspackages/1-framework/3-tooling/cli/test/config-types.test.tspackages/2-sql/2-authoring/contract-psl/package.jsonpackages/2-sql/2-authoring/contract-psl/src/interpreter.tspackages/2-sql/2-authoring/contract-psl/src/provider.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.test.tspackages/2-sql/2-authoring/contract-psl/test/provider.test.tspackages/2-sql/2-authoring/contract-ts/package.jsonpackages/2-sql/2-authoring/contract-ts/src/config-types.tspackages/2-sql/2-authoring/contract-ts/src/exports/config-types.tspackages/3-targets/7-drivers/postgres/test/driver.errors.test.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-init/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-driver.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-schema-verify/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-sign/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-driver.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-verify.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/emit/prisma-next.config.emit.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/emit/prisma-next.config.no-contract.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/vite-plugin/prisma-next.config.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.async-source.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.custom-output.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.defaults.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.document-family.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.invalid-contract.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.missing-output.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.no-contract.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.sync-source.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-contract/prisma-next.config.custom-output.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-contract/prisma-next.config.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/verify-database/prisma-next.config.mysql-target.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/verify-database/prisma-next.config.no-driver.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/verify-database/prisma-next.config.tstsconfig.base.json
💤 Files with no reviewable changes (5)
- packages/1-framework/1-core/migration/control-plane/src/config-validation.ts
- packages/1-framework/1-core/migration/control-plane/tsdown.config.ts
- packages/1-framework/1-core/migration/control-plane/vitest.config.ts
- packages/1-framework/1-core/migration/control-plane/test/config-validation.test.ts
- packages/1-framework/1-core/migration/control-plane/test/config-types.test-d.ts
✅ Files skipped from review due to trivial changes (1)
- packages/1-framework/1-core/shared/config/src/config-types.ts
🚧 Files skipped from review as they are similar to previous changes (19)
- packages/2-sql/2-authoring/contract-ts/src/exports/config-types.ts
- packages/1-framework/1-core/shared/config/tsconfig.prod.json
- packages/1-framework/1-core/shared/config/package.json
- packages/1-framework/1-core/shared/config/src/exports/types.ts
- packages/1-framework/1-core/shared/config/test/config-validation.test.ts
- packages/2-sql/2-authoring/contract-psl/test/interpreter.test.ts
- packages/1-framework/1-core/shared/config/src/config-validation.ts
- packages/2-sql/2-authoring/contract-psl/package.json
- packages/1-framework/1-core/shared/config/vitest.config.ts
- packages/1-framework/3-tooling/cli/src/exports/config-types.ts
- packages/1-framework/1-core/shared/config/biome.jsonc
- packages/2-sql/2-authoring/contract-psl/src/provider.ts
- packages/2-sql/2-authoring/contract-ts/package.json
- packages/1-framework/2-authoring/psl-parser/src/exports/types.ts
- packages/1-framework/1-core/shared/config/tsdown.config.ts
- packages/1-framework/3-tooling/cli/package.json
- packages/1-framework/1-core/shared/config/tsconfig.json
- packages/1-framework/1-core/shared/config/README.md
- tsconfig.base.json
Capture TML-2018 as an optional milestone addendum, defining @prisma-next/config responsibilities and architecture placement with a concrete execution plan.
Create @prisma-next/config so config typing, provider diagnostics, and validation live in the shared core plane instead of being implicitly owned by migration code.
…next/config Point config-loading and provider-facing consumers at the new package so config ownership is centralized and migration-plane packages no longer define the authoring contract.
…next/config Finalize the split by deleting migrated config types/validation exports from core-control-plane and tightening docs/build entries to reflect its migration-focused responsibilities.
Remove stale type exports that were no longer declared in parser types, which was breaking tsdown DTS generation. Update the trailing model attribute argument test to assert the generic attribute parsing behavior that the parser now guarantees.
Use bracket-based storage access and explicit narrowing in interpreter/provider tests so strict TypeScript index-signature rules pass during workspace typecheck.
Add targeted branch-path tests for control-plane error helpers and broaden config validation/error tests to cover descriptor, extension, driver, and contract failure branches.
Use extensionPacks as the canonical runtime validation key and reject legacy extensions to prevent silent config drift in non-TypeScript config paths.
Strengthen runtime config validation so non-TypeScript config inputs enforce required descriptor metadata and own-property checks, matching control-plane contract expectations raised in PR review.
Drop manifest-required runtime checks in shared config validation, update CLI fixture configs to use extensionPacks, and harden flaky driver error test timeout so full repo checks pass after rebase.
Assert loadConfig rejects invalid extensionPacks descriptors with a structured validation error so descriptor-shape drift is caught early.
Align emitContract with sibling APIs by accepting unknown directly, avoiding the redundant ContractIR | unknown annotation that collapses to unknown.
2b5027f to
e412aad
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (2)
packages/1-framework/1-core/shared/config/test/config-validation.test.ts (1)
359-379:⚠️ Potential issue | 🟠 MajorThis test enforces non-compliant behavior for descriptor
manifest.
accepts descriptors without manifest fieldscodifies the exact gap we need to prevent. This should assert failure paths (family.manifest,target.manifest, etc.) instead of success.As per coding guidelines, “All control plane descriptors must include `manifest` property of type `ExtensionPackManifest`.”✅ Suggested test direction
- it('accepts descriptors without manifest fields', () => { - const config = createValidRawConfig({ - family: { manifest: undefined }, - target: { manifest: undefined }, - adapter: { manifest: undefined }, - driver: { manifest: undefined }, - extensionPacks: [ - { - kind: 'extension', - id: 'pgvector', - familyId: 'sql', - targetId: 'postgres', - version: '0.0.1', - manifest: undefined, - create: vi.fn(), - }, - ], - }); - - expect(() => validateConfig(config)).not.toThrow(); - }); + it('requires manifest on descriptors', () => { + expectFieldError(createValidRawConfig({ family: { manifest: undefined } }), 'family.manifest'); + expectFieldError(createValidRawConfig({ target: { manifest: undefined } }), 'target.manifest'); + expectFieldError(createValidRawConfig({ adapter: { manifest: undefined } }), 'adapter.manifest'); + expectFieldError(createValidRawConfig({ driver: { manifest: undefined } }), 'driver.manifest'); + expectFieldError( + createValidRawConfig({ + extensionPacks: [ + { + kind: 'extension', + id: 'pgvector', + familyId: 'sql', + targetId: 'postgres', + version: '0.0.1', + manifest: undefined, + create: vi.fn(), + }, + ], + }), + 'extensionPacks[].manifest', + ); + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/shared/config/test/config-validation.test.ts` around lines 359 - 379, The test "accepts descriptors without manifest fields" currently allows missing manifest values but should enforce failure: update the test that builds the config with createValidRawConfig (setting family.manifest, target.manifest, adapter.manifest, driver.manifest and extensionPacks[].manifest to undefined) to expect validateConfig(config) to throw an error instead of notThrowing; specifically assert that validateConfig rejects configs missing the required ExtensionPackManifest on control-plane descriptors (family, target, adapter, driver, and extensionPacks entries) so the test verifies the validator enforces the manifest presence.packages/1-framework/1-core/shared/config/src/config-validation.ts (1)
34-215:⚠️ Potential issue | 🟠 MajorRequired
manifestvalidation is still missing across descriptor validators.Runtime validation currently accepts descriptors without
manifest, so malformed raw config can still pass on non-TS paths.As per coding guidelines, “All control plane descriptors must include `manifest` property of type `ExtensionPackManifest`.”🐛 Patch pattern
if (typeof family['version'] !== 'string') { throwValidation('family.version', 'Config.family must have version: string'); } + if (!family['manifest'] || typeof family['manifest'] !== 'object') { + throwValidation('family.manifest', 'Config.family must have manifest: ExtensionPackManifest'); + } @@ if (typeof target['version'] !== 'string') { throwValidation('target.version', 'Config.target must have version: string'); } + if (!target['manifest'] || typeof target['manifest'] !== 'object') { + throwValidation('target.manifest', 'Config.target must have manifest: ExtensionPackManifest'); + } @@ if (typeof adapter['version'] !== 'string') { throwValidation('adapter.version', 'Config.adapter must have version: string'); } + if (!adapter['manifest'] || typeof adapter['manifest'] !== 'object') { + throwValidation('adapter.manifest', 'Config.adapter must have manifest: ExtensionPackManifest'); + } @@ if (typeof extObj['version'] !== 'string') { throwValidation( 'extensionPacks[].version', 'Config.extensionPacks items must have version: string', ); } + if (!extObj['manifest'] || typeof extObj['manifest'] !== 'object') { + throwValidation( + 'extensionPacks[].manifest', + 'Config.extensionPacks items must have manifest: ExtensionPackManifest', + ); + } @@ if (typeof driver['version'] !== 'string') { throwValidation('driver.version', 'Config.driver must have version: string'); } + if (!driver['manifest'] || typeof driver['manifest'] !== 'object') { + throwValidation('driver.manifest', 'Config.driver must have manifest: ExtensionPackManifest'); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/shared/config/src/config-validation.ts` around lines 34 - 215, Several descriptor validators (family, target, adapter, each extensionPacks item extObj, and driver) are missing validation for a required manifest property; add checks that family['manifest'], target['manifest'], adapter['manifest'], extObj['manifest'] and driver['manifest'] exist and are of the correct type (ExtensionPackManifest) and call throwValidation with a clear key (e.g. 'family.manifest', 'target.manifest', 'adapter.manifest', 'extensionPacks[].manifest', 'driver.manifest') and descriptive messages when they are missing or wrong; follow the existing pattern used for id/version/targetId checks so the new validations are consistent with throwValidation usage.
🧹 Nitpick comments (3)
packages/1-framework/1-core/migration/control-plane/test/errors.test.ts (1)
153-157: Remove duplicated test cases and keep this suite lean.These two additions repeat scenarios already covered later in the file (
without configPath,with only expected,with only actual). Dropping the duplicates will also help keep this test file closer to the 500-line limit.As per coding guidelines, “Keep test files under 500 lines” and avoid tests that only restate already-covered behavior.♻️ Proposed cleanup
- it('errorConfigFileNotFound without path omits where', () => { - const error = errorConfigFileNotFound(); - expect(error.code).toBe('4001'); - expect(error.where).toBeUndefined(); - }); @@ - it('errorHashMismatch with expected only', () => { - const error = errorHashMismatch({ expected: 'hash1' }); - expect(error.meta?.['expected']).toBe('hash1'); - expect(error.meta?.['actual']).toBeUndefined(); - }); - - it('errorHashMismatch with actual only', () => { - const error = errorHashMismatch({ actual: 'hash2' }); - expect(error.meta?.['expected']).toBeUndefined(); - expect(error.meta?.['actual']).toBe('hash2'); - });Also applies to: 395-405
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/migration/control-plane/test/errors.test.ts` around lines 153 - 157, Remove the duplicated test cases that restate scenarios already covered later: delete the redundant it blocks invoking errorConfigFileNotFound() for the "without path"/"without configPath"/"with only expected"/"with only actual" variants so the suite stays lean and under 500 lines; locate the duplicate tests by searching for the errorConfigFileNotFound() invocations and remove the earlier duplicates (the blocks around the current snippet and the ones at the mentionedd duplicate region) leaving only the canonical tests that assert code '4001' and the distinct where/expected/actual behaviors.packages/1-framework/3-tooling/cli/src/config-loader.ts (2)
4-8: Use CLI-local structured error factories at this call site.For CLI sources, these factories should come from
utils/cli-errors.tsrather than@prisma-next/core-control-plane/errors.♻️ Suggested import change
import { errorConfigFileNotFound, errorConfigValidation, errorUnexpected, -} from '@prisma-next/core-control-plane/errors'; +} from './utils/cli-errors';As per coding guidelines "packages/1-framework/3-tooling/cli/**/*.ts: Call sites must throw
CliStructuredErrorinstances with full context (why, fix, docsUrl, etc.) instead of generic errors. Use factory functions fromutils/cli-errors.tsto create structured errors."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/src/config-loader.ts` around lines 4 - 8, The import of error factories errorConfigFileNotFound, errorConfigValidation, and errorUnexpected should be switched from '@prisma-next/core-control-plane/errors' to the CLI-local structured error factories in utils/cli-errors.ts and the code in config-loader.ts should use those CLI-specific factories (e.g., errorConfigFileNotFound, errorConfigValidation, errorUnexpected from utils/cli-errors.ts) so the loader throws CliStructuredError instances with full context (why, fix, docsUrl) instead of generic/core-plane errors; update the import statement and ensure any thrown errors in functions like the config parsing/validation paths call the CLI factory functions to produce structured errors.
1-3: Switchnode:pathimport topathefor cross-runtime consistency.Replace
import { dirname, resolve } from 'node:path'withimport { dirname, resolve } from 'pathe'. This matches the established pattern across the CLI tooling and aligns with repository conventions for path operations in TypeScript.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/src/config-loader.ts` around lines 1 - 3, Replace the Node builtin path import with the repository-standard pathe import: change the import that pulls dirname and resolve from 'node:path' to import them from 'pathe' so the code uses cross-runtime pathe utilities (affecting the import that currently reads "import { dirname, resolve } from 'node:path'"; keep references to dirname and resolve unchanged elsewhere in config-loader.ts).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/1-framework/1-core/shared/config/tsconfig.json`:
- Line 7: The tsconfig.json currently excludes build outputs and node_modules
but not internal test fixtures, which allows fixture-only types to leak into
package typechecking; update the "exclude" array in the tsconfig.json (the
"exclude" property) to add the fixture glob "test/fixtures/**/*" (or
"**/test/fixtures/**/*" if repo-wide), so fixtures are ignored by TypeScript
typechecking and internal fixture types won't affect package typings.
In `@packages/3-targets/7-drivers/postgres/test/driver.errors.test.ts`:
- Around line 362-363: The test currently asserts that
driver.acquireConnection() rejects twice but doesn't prove the driver attempted
a fresh connection after the first failure; update the test to also assert that
the mocked connect function was invoked twice (e.g., verify connect was called
two times) after the two rejects so you confirm the in-flight lease was cleared
and a new acquisition was attempted; locate the test around
driver.acquireConnection() calls and add an assertion referencing the mocked
connect (or connect mock) call count to equal 2.
---
Duplicate comments:
In `@packages/1-framework/1-core/shared/config/src/config-validation.ts`:
- Around line 34-215: Several descriptor validators (family, target, adapter,
each extensionPacks item extObj, and driver) are missing validation for a
required manifest property; add checks that family['manifest'],
target['manifest'], adapter['manifest'], extObj['manifest'] and
driver['manifest'] exist and are of the correct type (ExtensionPackManifest) and
call throwValidation with a clear key (e.g. 'family.manifest',
'target.manifest', 'adapter.manifest', 'extensionPacks[].manifest',
'driver.manifest') and descriptive messages when they are missing or wrong;
follow the existing pattern used for id/version/targetId checks so the new
validations are consistent with throwValidation usage.
In `@packages/1-framework/1-core/shared/config/test/config-validation.test.ts`:
- Around line 359-379: The test "accepts descriptors without manifest fields"
currently allows missing manifest values but should enforce failure: update the
test that builds the config with createValidRawConfig (setting family.manifest,
target.manifest, adapter.manifest, driver.manifest and extensionPacks[].manifest
to undefined) to expect validateConfig(config) to throw an error instead of
notThrowing; specifically assert that validateConfig rejects configs missing the
required ExtensionPackManifest on control-plane descriptors (family, target,
adapter, driver, and extensionPacks entries) so the test verifies the validator
enforces the manifest presence.
---
Nitpick comments:
In `@packages/1-framework/1-core/migration/control-plane/test/errors.test.ts`:
- Around line 153-157: Remove the duplicated test cases that restate scenarios
already covered later: delete the redundant it blocks invoking
errorConfigFileNotFound() for the "without path"/"without configPath"/"with only
expected"/"with only actual" variants so the suite stays lean and under 500
lines; locate the duplicate tests by searching for the errorConfigFileNotFound()
invocations and remove the earlier duplicates (the blocks around the current
snippet and the ones at the mentionedd duplicate region) leaving only the
canonical tests that assert code '4001' and the distinct where/expected/actual
behaviors.
In `@packages/1-framework/3-tooling/cli/src/config-loader.ts`:
- Around line 4-8: The import of error factories errorConfigFileNotFound,
errorConfigValidation, and errorUnexpected should be switched from
'@prisma-next/core-control-plane/errors' to the CLI-local structured error
factories in utils/cli-errors.ts and the code in config-loader.ts should use
those CLI-specific factories (e.g., errorConfigFileNotFound,
errorConfigValidation, errorUnexpected from utils/cli-errors.ts) so the loader
throws CliStructuredError instances with full context (why, fix, docsUrl)
instead of generic/core-plane errors; update the import statement and ensure any
thrown errors in functions like the config parsing/validation paths call the CLI
factory functions to produce structured errors.
- Around line 1-3: Replace the Node builtin path import with the
repository-standard pathe import: change the import that pulls dirname and
resolve from 'node:path' to import them from 'pathe' so the code uses
cross-runtime pathe utilities (affecting the import that currently reads "import
{ dirname, resolve } from 'node:path'"; keep references to dirname and resolve
unchanged elsewhere in config-loader.ts).
ℹ️ Review info
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Lite
⛔ Files ignored due to path filters (5)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlprojects/psl-contract-authoring/plans/optional-split-up-1-core-migration-plan.mdis excluded by!projects/**projects/psl-contract-authoring/plans/plan.mdis excluded by!projects/**projects/psl-contract-authoring/spec.mdis excluded by!projects/**projects/psl-contract-authoring/specs/optional-split-up-1-core-migration.spec.mdis excluded by!projects/**
📒 Files selected for processing (70)
packages/1-framework/1-core/migration/control-plane/README.mdpackages/1-framework/1-core/migration/control-plane/package.jsonpackages/1-framework/1-core/migration/control-plane/src/config-validation.tspackages/1-framework/1-core/migration/control-plane/test/config-types.test-d.tspackages/1-framework/1-core/migration/control-plane/test/config-validation.test.tspackages/1-framework/1-core/migration/control-plane/test/errors.test.tspackages/1-framework/1-core/migration/control-plane/tsdown.config.tspackages/1-framework/1-core/migration/control-plane/vitest.config.tspackages/1-framework/1-core/shared/config/README.mdpackages/1-framework/1-core/shared/config/biome.jsoncpackages/1-framework/1-core/shared/config/package.jsonpackages/1-framework/1-core/shared/config/src/config-types.tspackages/1-framework/1-core/shared/config/src/config-validation.tspackages/1-framework/1-core/shared/config/src/contract-source-types.tspackages/1-framework/1-core/shared/config/src/errors.tspackages/1-framework/1-core/shared/config/src/exports/config-types.tspackages/1-framework/1-core/shared/config/src/exports/config-validation.tspackages/1-framework/1-core/shared/config/src/exports/types.tspackages/1-framework/1-core/shared/config/src/types.tspackages/1-framework/1-core/shared/config/test/config-types.test-d.tspackages/1-framework/1-core/shared/config/test/config-validation.test.tspackages/1-framework/1-core/shared/config/tsconfig.jsonpackages/1-framework/1-core/shared/config/tsconfig.prod.jsonpackages/1-framework/1-core/shared/config/tsdown.config.tspackages/1-framework/1-core/shared/config/vitest.config.tspackages/1-framework/2-authoring/psl-parser/src/exports/types.tspackages/1-framework/2-authoring/psl-parser/test/parser.test.tspackages/1-framework/3-tooling/cli/package.jsonpackages/1-framework/3-tooling/cli/src/config-loader.tspackages/1-framework/3-tooling/cli/src/control-api/types.tspackages/1-framework/3-tooling/cli/src/exports/config-types.tspackages/1-framework/3-tooling/cli/test/config-loader.test.tspackages/1-framework/3-tooling/cli/test/config-types.test.tspackages/2-sql/2-authoring/contract-psl/package.jsonpackages/2-sql/2-authoring/contract-psl/src/interpreter.tspackages/2-sql/2-authoring/contract-psl/src/provider.tspackages/2-sql/2-authoring/contract-psl/test/interpreter.test.tspackages/2-sql/2-authoring/contract-psl/test/provider.test.tspackages/2-sql/2-authoring/contract-ts/package.jsonpackages/2-sql/2-authoring/contract-ts/src/config-types.tspackages/2-sql/2-authoring/contract-ts/src/exports/config-types.tspackages/3-targets/7-drivers/postgres/test/driver.errors.test.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-init/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-driver.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-schema-verify/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-sign/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-driver.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-verify.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.with-db.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/emit/prisma-next.config.emit.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/emit/prisma-next.config.no-contract.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/vite-plugin/prisma-next.config.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.async-source.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.custom-output.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.defaults.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.document-family.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.invalid-contract.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.missing-output.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.no-contract.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.sync-source.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-contract/prisma-next.config.custom-output.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-contract/prisma-next.config.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/verify-database/prisma-next.config.mysql-target.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/verify-database/prisma-next.config.no-driver.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/verify-database/prisma-next.config.tstsconfig.base.json
💤 Files with no reviewable changes (5)
- packages/1-framework/1-core/migration/control-plane/tsdown.config.ts
- packages/1-framework/1-core/migration/control-plane/test/config-validation.test.ts
- packages/1-framework/1-core/migration/control-plane/src/config-validation.ts
- packages/1-framework/1-core/migration/control-plane/vitest.config.ts
- packages/1-framework/1-core/migration/control-plane/test/config-types.test-d.ts
✅ Files skipped from review due to trivial changes (1)
- packages/1-framework/1-core/shared/config/src/config-types.ts
🚧 Files skipped from review as they are similar to previous changes (33)
- packages/2-sql/2-authoring/contract-ts/src/config-types.ts
- packages/1-framework/1-core/shared/config/package.json
- test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-driver.ts
- test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-introspect/prisma-next.config.no-db.ts
- packages/2-sql/2-authoring/contract-psl/test/interpreter.test.ts
- packages/1-framework/1-core/shared/config/test/config-types.test-d.ts
- packages/1-framework/3-tooling/cli/src/control-api/types.ts
- packages/1-framework/1-core/shared/config/src/errors.ts
- packages/2-sql/2-authoring/contract-psl/src/interpreter.ts
- packages/1-framework/2-authoring/psl-parser/src/exports/types.ts
- packages/2-sql/2-authoring/contract-psl/package.json
- test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/emit/prisma-next.config.no-contract.ts
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.async-source.ts
- packages/2-sql/2-authoring/contract-ts/package.json
- packages/2-sql/2-authoring/contract-psl/src/provider.ts
- packages/1-framework/1-core/shared/config/README.md
- packages/1-framework/1-core/shared/config/src/exports/types.ts
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.defaults.ts
- packages/1-framework/1-core/shared/config/tsconfig.prod.json
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.custom-output.ts
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.sync-source.ts
- test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-init/prisma-next.config.with-db.ts
- test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.ts
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.invalid-contract.ts
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.document-family.ts
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/verify-database/prisma-next.config.ts
- packages/2-sql/2-authoring/contract-ts/src/exports/config-types.ts
- packages/1-framework/1-core/shared/config/biome.jsonc
- tsconfig.base.json
- packages/1-framework/1-core/migration/control-plane/README.md
- packages/1-framework/2-authoring/psl-parser/test/parser.test.ts
- test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-verify.ts
- packages/1-framework/1-core/shared/config/vitest.config.ts
Keep migration target capability checks type-safe in the shared scaffold and update the db-update scenario fixture to use extensionPacks so contract emit succeeds under the new config surface.
Prevent fixture-only files from being typechecked as part of the shared config package by excluding test fixtures in tsconfig.
Strengthen the lease cleanup regression by asserting direct-client connect is retried on each failed acquireConnection call.
closes TML-2018
Intent
Split the
prisma-next.config.tsauthoring surface (types + validation + contract-source provider protocol) out of the migration/control-plane package into a dedicated shared package (@prisma-next/config), and update tooling/authoring consumers accordingly.Change map
Config contract (new home):
packages/1-framework/1-core/shared/config/src/config-types.ts (L18–L152)packages/1-framework/1-core/shared/config/src/config-validation.ts (L15–L229)Consumers moved:
packages/1-framework/3-tooling/cli/src/config-loader.ts (L1–L87)packages/2-sql/2-authoring/contract-ts/src/config-types.ts (L1–L11)packages/2-sql/2-authoring/contract-psl/src/provider.ts (L1–L55)Evidence:
packages/1-framework/1-core/shared/config/test/config-validation.test.ts (L61–L145)The story
@prisma-next/configas the shared-plane home for config typing/validation and the contract-source provider protocol.@prisma-next/core-control-planeexports and migrate CLI + SQL authoring consumers to the new package.Behavior changes & evidence
Adds
@prisma-next/configas the canonical config authoring surface.packages/1-framework/1-core/shared/config/README.md (L1–L43)packages/1-framework/1-core/shared/config/src/config-types.ts (L18–L152)packages/1-framework/1-core/shared/config/src/config-validation.ts (L15–L229)packages/1-framework/1-core/shared/config/test/config-validation.test.ts (L61–L145)CLI config loading now validates via
@prisma-next/configand maps validation failures into structured CLI errors.packages/1-framework/3-tooling/cli/src/config-loader.ts (L1–L87)Compatibility / migration / risk
tml-2001-psl-fixtures, so the diff includes the full divergence range between those long-lived branches.PrismaNextConfigexposesextensionPacks, but runtime validation currently checksextensionsinvalidateConfig()(so malformedextensionPackscan slip through for non-TS configs).packages/1-framework/1-core/shared/config/src/config-validation.ts (L115–L171)Follow-ups / open questions
extensionPacksvsextensions) and add a focused unit test.Summary by CodeRabbit
New Features
Breaking Changes
extensionsfield toextensionPacksin Prisma configuration files.Improvements