Repository navigation
Config files import definePrismaConfig, the engine's current name for the marker - #30129
Conversation
… the marker `@prisma/cli-engine` has exported the config marker as `definePrismaConfig` since 0.2.0, keeping `defineConfig` as a deprecated alias. On the pinned 0.2.3 the two names are the same function object, so this sweep changes no behaviour today. Engine 0.3.0 drops the alias before launch, and every one of these files would then fail with `defineConfig is not a function`. 306 TypeScript files import the marker from `@prisma/cli-engine`; all of them move to the current name, at the import and at the call. Almost all are `prisma.config.ts` fixtures under `test/`, plus the example and app configs. Two things that share the name are untouched. The framework's own `defineConfig`, exported by the target facades and `@internal/cli/config-types`, is always imported aliased (`defineConfig as ormConfig`), so it never collided with the sweep. `defineConfigSection` is a separate and current engine export. 21 more files spell the old name out rather than importing it: - `scripts/regen-example-migrations.mjs` generates a temporary config file. Its `engineDefineConfig` alias existed only because the engine marker and the framework builder shared a name, so the alias goes with the rename. - The `CONFIG.VERSION_MARKER_MISSING` diagnostic told the reader to create the config with `defineConfig`. Its summary, explanation and fix now name `definePrismaConfig`, as does its entry in `docs/reference/error-reference.md` — which additionally pointed at the target package's `/config` entrypoint, the wrong import for the marker. - Doc comments in the config loader, the ORM loader and its config types, `init` and its package resolution, and the publish-surface import roots. - Four test names, and an `init` assertion that only checked for the substring `defineConfig` and so passed by accident against the scaffold's `definePrismaConfig`. The CHANGELOG, the rc.2 release notes and the rc.1-to-rc.2 upgrade recipes still say `defineConfig`, deliberately: they record releases where that was the name. This unblocks moving the engine pin to 0.3.0, which #30128 waits on. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
|
|
Important Review skippedToo many files! This PR contains 335 files, which is 35 over the limit of 300. To get a review, reduce the PR to 300 files or fewer by splitting it into smaller PRs or changing its base branch. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: Repository: prisma/orm/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (335)
You can disable this status message by setting the Comment |
@prisma/orm-extension-arktype-json
@prisma/orm-extension-middleware-cache
@prisma/orm-extension-paradedb
@prisma/orm-extension-pgvector
@prisma/orm-extension-postgis
@prisma/orm-extension-supabase
@prisma/orm-family-mongo
@prisma/orm-family-sql
@prisma/orm-framework
@prisma/orm-mongo
@prisma/orm-postgres
@prisma/orm-sqlite
@prisma/orm-target-mongo
@prisma/orm-target-postgres
@prisma/orm-target-sqlite
@prisma/orm-toolchain
commit: |
size-limit report 📦
|
The app entry is new; the extension entry replaces the incidental changes: [] declaration, since the rename is a real user-facing step: the deprecated engine alias goes away with the next engine release. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ndow The rc.8-to-rc.9 window shipped without the rename, so those files return to main's content and the entry lands in the current in-flight directory instead. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ngine resolves its paths (prisma#30372) ## At a glance The `orm` section of `prisma.config.ts` is declared once, with the fields that are paths marked as such: ```ts // packages/1-framework/3-tooling/config-loader/src/orm-section.ts export const ormConfigSchema = configSchema({ family: { kind: "'family'", ...descriptorFields, emission: 'object' }, target: { kind: "'target'", ...targetLikeFields }, adapter: { kind: "'adapter'", ...targetLikeFields }, 'driver?': { kind: "'driver'", ...targetLikeFields }, 'extensions?': [{ kind: "'extension'", ...targetLikeFields }, '[]'], 'db?': { 'connection?': 'unknown' }, 'contract?': { source: { load: 'Function', 'inputs?': 'path[]', 'format?': 'string' }, output: ['path', '=', () => 'src/prisma/contract.json'], }, migrations: [{ dir: ['path', '=', () => './migrations'] }, '=', () => ({})], 'formatter?': { 'indent?': "number.integer >= 1 | 'tab'", 'newline?': "'LF' | 'CRLF'" }, }).narrow(/* familyId and targetId agreement across descriptors */); ``` Given this project and this invocation: ``` exp/ sub/ prisma.config.ts # orm: ormConfig({ contract: './contract.prisma', migrations: { dir: './migrations' } }) contract.prisma ``` | Run from | Command | Before | After | | --------- | ------------------------------------------------------ | -------------------------------------------------------------- | ------------------------------ | | `exp/sub` | `prisma contract emit --config ./prisma.config.ts` | writes `exp/sub/contract.json` | same | | `exp` | `prisma contract emit --config ./sub/prisma.config.ts` | `CONTRACT.SOURCE_LOAD_FAILED`: looks for `exp/contract.prisma` | writes `exp/sub/contract.json` | Config files are unchanged. ## The decision A relative path in `prisma.config.ts` is relative to the file that wrote it. Only the ORM knows which of its fields are paths; only the CLI engine knows which file wrote each value, because its chain merge records that per key. The schema declaration puts the first where the second can use it. The engine derives validation, a `CLI.CONFIG_FIELD_INVALID` diagnostic per bad field naming the file to fix, and the resolution of every `path` field, from the one declaration; the ORM writes no validation, resolution, or path-anchoring code. This is [prisma/prisma-cli ADR 0005](https://github.com/prisma/prisma-cli/blob/main/docs/architecture/adrs/0005-config-sections-declare-their-shape.md), shipped in engine 0.6.0 by prisma/prisma-cli#279; every product that mounts commands declares its section this way. ## Why it broke The ORM's own `prisma` bin resolved config paths in its loader against the config file. The unified `prisma` CLI loads the config through the engine's loader, which handed the `orm` section over as written; the ORM's command wrapper then resolved paths itself, and the only directory it could see was the working directory. The same defect existed a second time in `projectConfigPathFor`, which rebuilt `<cwd>/prisma.config.ts` to find the project's `package.json` and, from a parent directory, read the wrong manifest. ## What changes - **`@internal/config-loader`** declares `ormConfigSchema` and `ormConfigSection` (`defineConfigSection({ name: 'orm', schema })`). It is the lowest package that can depend on the engine; `@internal/cli` and `@internal/cli-telemetry` consume the section from it. Path defaults are thunks, which arktype evaluates when the default is applied, so they resolve against the config file like authored values. - **Descriptors are declared references.** A control descriptor is a runtime object the config file constructs: `create` closes over module state, and its codec tables, contract serializer and migration hooks rely on their prototypes and on `this`. The schema declares each descriptor, and `db.connection`, with the engine's `reference(schema)` (prisma/prisma-cli#284), so the command receives the object the config file built. The schema checks only a descriptor's identifying fields: `kind`, `id`, `familyId`, `version`, `create`, and `targetId` or `emission`. Every value not declared a reference is copied before paths are resolved and defaults applied. Cross-descriptor rules (`familyId` and `targetId` agreement, the removed `extensionPacks` key) are one function, which the schema's `narrow` and the loader both call. - **A codec without params has no `paramsSchema`.** A codec that took no params used to declare `paramsSchema = voidParamsSchema`, a shared schema accepting only `undefined`, and `isParameterized` asked whether a descriptor's schema was that exact object. A copied descriptor carries a copy of that schema, so every codec on it reported itself parameterized, which is how `db init` failed with `Invalid typeParams for codec 'pg/text@1'`. `paramsSchema` is now `StandardSchemaV1<P> | undefined`, a codec without params sets it to `undefined`, and `isParameterized` is `paramsSchema !== undefined`, which no copy can change. Type-param validation still rejects `typeParams` for such a codec with `RUNTIME.TYPE_PARAMS_INVALID`. `voidParamsSchema` is removed; [`upgrade-instructions/pending/codec-without-params-schema/extension/`](https://github.com/prisma/orm/blob/feat/orm-config-schema/upgrade-instructions/pending/codec-without-params-schema/extension/instructions.md) tells extension authors how to follow. - **The ORM's bin** hands the engine each evaluated file with its sections as written (`loadConfigFiles`); the engine validates the merged section with that provenance before a command runs. `loadConfig` runs the same schema for the language server and the vite plugin, wrapping each field diagnostic as `CONFIG.VALIDATION_FAILED` with the subsection it concerns, so `requireConfigSections` keeps working. - **Commands** read absolute paths and `baseDir`. The command wrapper's cwd finalisation, `finalize-config.ts`, `collectConfigIssues` and its hand-written descriptor checks, and `projectConfigPathFor` are deleted. The migration path helpers take only the config. Control API operations that located the project through `configPath` take `projectDir`; `resolveMigrationPaths` takes the config. - **`@prisma/cli-engine` moves to 0.6.1** (0.6.0 plus prisma/prisma-cli#280 and #284: a schema declares the values it keeps as references) in `@internal/cli`, `@internal/config-loader`, `@prisma/orm-toolchain`'s peer, the four extension packages, and the integration test package. The `defineConfig` → `definePrismaConfig` rename the bump requires landed separately in prisma#30129. Examples and fixture apps consume published packages and keep their pins. - **Diagnostics under the unified CLI change code.** A malformed `orm` field is now reported by the engine as `CLI.CONFIG_FIELD_INVALID` (one per field, `meta.section: 'orm'`, `meta.field` the dotted path, `where.path` the config file that declared it) under `CLI.CONFIG_SECTION_INVALID`. `CONFIG.VALIDATION_FAILED` remains what the ORM's own loader raises for the language server and the vite plugin. The error reference records the split; the two integration files that asserted the old code are updated. - **Docs**: `config-validation-and-normalization.mdc` now describes the schema as the single home of structural rules, `loadConfigFiles`/`loadConfig` as evaluation plus diagnostics, and path resolution as the schema's job; the CLI Style Guide says relative paths in the config file resolve against the file that wrote them, with `--output-path` the one path relative to cwd; the loader README follows. The arktype rule now says to read the arktype docs before building validation machinery and never to read arktype's compiled node tree, and `docs/reference/arktype-usage.md` records what a transformation does to its input: any pipe or default makes arktype clone the whole input, and the default clone rebuilds plain objects and class instances. The codec authoring guide, the two codec ADRs and the package READMEs declare codecs without params with `paramsSchema = undefined`. ## Tests - `framework-components/test/materialize-codec.test.ts`: a descriptor copied the way arktype's default clone copies it keeps `isParameterized` for codecs with and without params (this test fails before the change), and a codec without params rejects `typeParams`. - `config-loader/test/orm-section.test.ts`: the schema accepts a valid config, supplies the migrations dir and default contract output, records `baseDir`, resolves inputs, output and migrations dir against the config file, leaves absolute paths alone, keeps a descriptor's class instances and functions, and the source's `load`, as the file built them (closures, prototypes and `this` survive), reports missing descriptors and descriptor field problems, family and target mismatches on target, adapter, driver and extensions, the removed `extensionPacks` key, contract, migrations and formatter problems, keeps fields the schema does not name on descriptors and on the contract source, and never throws on hostile input. `load.test.ts` still passes unchanged apart from the finalise module going away. - `@internal/cli`: `contract emit` and `migration plan` reached with `--config sub/prisma.config.ts` from the parent read and write under `sub/`, the plan test exercising the manifest walk from `baseDir`; the bin loader hands the engine the requested file with paths as written; ORM command tests seed the engine with a `prisma.config.ts` in the run directory through one shared helper so the engine validates the seed as it would a real file. Verified locally against a build of prisma/prisma-cli#280 overlaid on the installed engine: | Package | Result | | --- | --- | | `@internal/config` | 5 tests | | `@internal/config-loader` | 53 tests | | `@internal/cli` | 116 files, 1484 tests | | `@internal/cli-telemetry` (incl. the real-Postgres e2e) | 113 tests | | `@internal/vite-plugin-contract-emit` | 31 tests | | extensions (paradedb, pgvector, supabase, postgis) | 390 tests | | integration | 788 files, 4224 tests | | all package suites after the codec change | 83 tasks; the first run's 7 failures (tests that expected every codec to have a schema, and a bundled comment naming an internal package) fixed and rerun green | | repo | build, typecheck, lint, `lint:deps`, `lint:casts`, rules lints, `fixtures:check`, upgrade coverage pass | CI on this PR is red until `@prisma/[email protected]` is published and the pin here moves to it; the earlier red run (270 integration failures) was arktype's default clone rebuilding descriptors, which 0.6.1 fixes. Verified locally with a 0.6.1 build: `config-loader` (53), the CLI package (1484), and the config-related integration files (200) pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Configuration diagnostics now identify the affected field, section, and config file. * Relative paths in config files—including extended configs—resolve from the file that declares them. Command-line output paths remain relative to the working directory. * Config loading retains details about each file in an extended configuration chain. * **Bug Fixes** * Malformed configuration sections receive more specific diagnostics, while commands can proceed when errors affect sections they do not read. * **Breaking Changes** * Legacy configuration-validation exports and config-path operation options are no longer available. * `voidParamsSchema` is no longer exported. Codecs without parameters should set `paramsSchema` to `undefined`; non-empty type parameters are rejected, while empty parameters are accepted. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
#291) ## At a glance ```diff - exceptions: [ - { familyPackage: "@prisma/composer-cli", familyPin: "0.4.0", shellPin: "0.6.1", … }, - { familyPackage: "@prisma/composer-cli", familyPin: "0.5.0", shellPin: "0.6.1", channel: "dev", … }, - { familyPackage: "@prisma/orm-toolchain", familyPin: "0.4.0", shellPin: "0.6.1", … }, - ], + exceptions: [], ``` The release checks in `packages/cli/scripts/conformance.ts` refuse to ship a `prisma` whose command families were built against a different engine than the one it ships. While engine 0.6.1 was new, the families could not peer it yet, so these three entries let that mismatch through. Both families have now released against 0.6.1: | Package | Version pinned in `prisma` 8.0.0-rc.17 | Engine it peers | | --- | --- | --- | | `@prisma/composer-cli` | 0.23.0 | 0.6.1 | | `@prisma/orm-toolchain` | 8.0.0-rc.12 | 0.6.1 | So the entries now describe installs that no longer happen. They have to go: an entry left in place would let a real two-engine install through the next time those exact versions meet. ## Checked `pnpm check:conformance` reports "5 subject(s) checked, nothing to report" on both the release channel and the dev channel (`PUBLISH_CHANNEL=dev`), with the list empty. The dev builds (`[email protected]`, `[email protected]`) also peer 0.6.1. `pnpm lint` and `pnpm typecheck` pass. ## Also in this PR The project ledger (`.drive/projects/prisma-cli-v8/deferred.md`) closes three entries that were no longer true: - The engine transition "in flight" entry now records that the transitions through 0.6.1 are closed. - The family path-resolution entry now records how it shipped: composer through composer#262, and the orm section through prisma/orm#30372's `configSchema` declaration, which superseded prisma/orm#30128. It also records a check run from the published `prisma` 8.0.0-rc.17: root and nested configs merge, paths resolve against the file that declares them, and `prisma init` in a subdirectory skips the root-level steps. - The `defineConfig` rename entry is marked fixed by prisma/orm#30129. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Why now
@prisma/cli-enginehas exported the config marker asdefinePrismaConfigsince 0.2.0, keepingdefineConfigas a deprecated alias. Engine 0.3.0 drops the alias before launch. Everyprisma.config.tsin this repo still imports the old name, so on 0.3.0 they all fail at evaluation withdefineConfig is not a function.Doing the rename now, on the current 0.2.3 pin, costs nothing. The two names are literally the same function object there:
So this PR is mergeable today and changes no behaviour. It clears the last blocker on moving the engine pin to 0.3.0, which #30128 is waiting for.
What changed
306 TypeScript files import the marker from
@prisma/cli-engine. All move todefinePrismaConfig, at the import and at the call. Almost all areprisma.config.tsfixtures undertest/, plus the example and app configs.Two things that share the name are deliberately untouched:
defineConfig, exported by the target facades and@internal/cli/config-types. It is always imported aliased (defineConfig as ormConfig), so it never collided with the sweep.defineConfigSection, a separate and current engine export.Replacements were anchored on the exact import line and on
defineConfig(, never on a bare word match. After the sweep:defineConfigreference to@prisma/cli-engineremains in any.ts,.mts,.mjsor.jsfiledefineConfigSectionoccurrences are intact, and nodefinePrismaConfigSectionexists anywhere21 more files spell the old name out rather than importing it:
scripts/regen-example-migrations.mjsgenerates a temporary config file. ItsengineDefineConfigalias existed only because the engine marker and the framework builder shared a name, so the alias goes with the rename.CONFIG.VERSION_MARKER_MISSINGdiagnostic told the reader to create the config withdefineConfig. Its summary, explanation and fix now namedefinePrismaConfig. So does its entry indocs/reference/error-reference.md, which additionally pointed at the target package's/configentrypoint — the wrong import for the marker.initand its package resolution, and the publish-surface import roots.initassertion that only checked for the substringdefineConfigand so passed by accident against the scaffold'sdefinePrismaConfig. It now asserts the real name.The CHANGELOG, the rc.2 release notes and the rc.1-to-rc.2 upgrade recipes still say
defineConfig, deliberately: they record releases where that was the name.Verification
All on the current 0.2.3 pin — no override, no tarball.
pnpm buildturbo run typecheck --forceintegration-tests, whose tsconfig includestest/**/*, so all 262 fixture configs are typechecked.pnpm test:packagesmainbefore the change, so nothing was lost or silently skippedpnpm test:integration@internal/cli@internal/config-loader@internal/errors@internal/config@internal/language-serverpnpm lintpnpm lint:deps,lint:docs,lint:manifestspnpm check:conformancepnpm check:error-referenceThree test files fail somewhere in those runs. Each was checked and none is caused by this change:
test/ports/.../driver-adapters-error-forwardingfails identically on unmodifiedorigin/main— I checked outmainin this working copy and reproduced it.@prisma/orm-framework'smodule-identityalso fails on unmodifiedmainhere:pnpm packtrips over a leftover gitignoredskills/prisma-8directory.@internal/adapter-postgres'sorder-by-enumPGlite test fails only under parallel load; it passes on its own (7/7).Related
🤖 Generated with Claude Code