Repository navigation
refactor(emitter): replace TargetFamilyHook with EmissionSpi - #304
Conversation
|
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:
📝 WalkthroughWalkthroughReplaces the TargetFamilyHook SPI with a new EmissionSpi focused on emission/type-generation; centralizes .d.ts assembly into generateContractDts; updates emitter core, family emitters, CLI wiring, framework descriptors, tests, fixtures, examples, and docs to use the new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as Client/CLI
participant Control as Control Client
participant Emitter as Emitter (emit)
participant Generator as generateContractDts
participant Family as EmissionSpi (sqlEmission/mongoEmission)
participant FS as Filesystem
CLI->>Control: request emit(contractIR)
Control->>Emitter: emit(contract, stack, family.emission)
Emitter->>Emitter: compute hashes & canonicalize
Emitter->>Generator: generateContractDts(contract, Family, imports..., hashes, options)
Generator->>Family: getFamilyImports / getFamilyTypeAliases / getTypeMapsExpression
alt family needs models
Generator->>Family: generateModelStorageType(model)
Generator->>Family: generateStorageType(contract, storageHashTypeName)
end
Generator-->>Emitter: return .d.ts content
Emitter->>FS: write contract.json and contract.d.ts
Emitter-->>Control: return emitResult (contractJson, contractDts, hashes)
Control-->>CLI: success/failure
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
0ac276e to
c18519c
Compare
@prisma-next/mongo-orm
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/emitter
@prisma-next/migration-tools
@prisma-next/vite-plugin-contract-emit
@prisma-next/runtime-executor
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-emitter
@prisma-next/mongo-query-ast
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@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/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/adapter-postgres
@prisma-next/driver-postgres
commit: |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
packages/1-framework/1-core/framework-components/README.md (1)
10-10:⚠️ Potential issue | 🟡 MinorEmission API list is stale relative to the new SPI description.
Line 24 correctly explains
EmissionSpi, but Line 10 still documents removedTargetFamilyHook/ValidationContextgeneration-era types. Please update that bullet to only list the current emission types.As per coding guidelines: "
**/*.{md,mdx}: Keep documentation current including READMEs, rules, and links."Also applies to: 24-24
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/1-core/framework-components/README.md` at line 10, Update the Emission SPI bullet to remove stale generation-era types (TargetFamilyHook, ValidationContext, GenerateContractTypesOptions, TypeRenderEntry, TypeRenderer, ParameterizedCodecDescriptor and related types) and instead document the current emission types as described by EmissionSpi (the new SPI); replace the old list with a concise, accurate enumeration that matches the explanation of EmissionSpi on Line 24.packages/2-mongo-family/3-tooling/emitter/README.md (1)
7-39:⚠️ Potential issue | 🟡 MinorREADME still documents removed
TargetFamilyHookbehavior.The usage snippet is updated to
mongoEmission, but the package contract still describesTargetFamilyHook/generateContractTypesand transition-state wording. Please align this section to the currentEmissionSpi+ framework-owned DTS assembly model only.As per coding guidelines: "
packages/**/*.md: Update design docs to reflect the current state only, not the transition history or legacy approaches" and "**/*.{md,mdx}: Keep documentation current including READMEs, rules, and links."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-mongo-family/3-tooling/emitter/README.md` around lines 7 - 39, Update the README to remove references to the legacy TargetFamilyHook and generateContractTypes flow and instead document the current EmissionSpi + framework-owned DTS assembly model: keep the usage example showing emit(contractIR, mongoEmission, options) and then replace the "What it provides" and architecture sections to describe mongoEmission as an EmissionSpi implementation that validates codec IDs and structure (ns/name@version), delegates domain-level type generation to `@prisma-next/emitter/domain-type-generation`, and relies on the framework to assemble the final contract.d.ts artifacts; remove transition-state wording and any mention of “generateContractTypes”/TargetFamilyHook while keeping Mongo-specific validation points (collections, owned/embedded rules, polymorphism, storage.relations) and references to contract.d.ts and contract generation flow.packages/2-mongo-family/3-tooling/emitter/src/index.ts (1)
6-120:⚠️ Potential issue | 🟠 MajorAdd
: EmissionSpitype annotation tomongoEmissionto enforce API boundary.
mongoEmissionis exported as an unannotated object literal, so its public type includes every property—includingvalidateTypes()andvalidateStructure(), which are not part of theEmissionSpiinterface. This breaks the SPI contract for consumers. Either make these validation methods private (e.g.,validateTypes→_validateTypes) or remove them entirely if they're not called from framework code, then annotate the export as: EmissionSpito enforce the boundary going forward.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-mongo-family/3-tooling/emitter/src/index.ts` around lines 6 - 120, The exported mongoEmission object exposes implementation-only methods validateTypes and validateStructure which leak beyond the EmissionSpi boundary; rename these methods to private names (e.g., _validateTypes and _validateStructure) or remove them if unused, then add an explicit type annotation ": EmissionSpi" to the mongoEmission export so the public surface matches the SPI. Update any internal callers to reference the new private names (mongoEmission._validateTypes / mongoEmission._validateStructure) or remove those calls, and ensure the file imports/uses EmissionSpi so the annotation type-checks.
🧹 Nitpick comments (6)
packages/2-sql/3-tooling/emitter/src/index.ts (1)
27-31: Blind casts oncontract.storageandcontract.modelsare present throughout.Lines 31, 62, 204, 278, and 297-298 use
as unknown aspatterns to cast generic contract properties to SQL-specific types. Per coding guidelines, blind casts are forbidden in production code. Consider introducing a type predicate (e.g.,isSqlStorage(storage): storage is SqlStorage) to narrow types safely, or documenting why these casts are necessary for the family-specific SPI context.That said, this appears to be a pre-existing pattern being carried forward from the previous implementation, so it may be acceptable to defer this refactor.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-sql/3-tooling/emitter/src/index.ts` around lines 27 - 31, The code uses unsafe blind casts (as unknown as ...) on contract.storage and contract.models inside sqlEmission (notably in validateTypes and other methods); replace these with proper type guards such as isSqlStorage(storage): storage is SqlStorage and isSqlModel(model): model is SqlModel and use them to narrow types before accessing SQL-specific fields in functions like validateTypes and any other methods referencing contract.storage/contract.models (replace casts at the locations currently using as unknown as); if this cannot be completed now, add a short justificatory comment where each cast remains explaining why the SPI-family context guarantees the type and mark TODO to implement the type predicate to avoid blind casts.packages/2-sql/3-tooling/emitter/test/emitter-hook.structure.test.ts (1)
1-933: Consider splitting this test file in a follow-up.At 933 lines, this file exceeds the 500-line guideline for test files. Consider splitting by validation category (e.g.,
emitter-hook.structure.models.test.ts,emitter-hook.structure.tables.test.ts,emitter-hook.structure.foreignkeys.test.ts) in a follow-up PR. This is not blocking for the current refactor.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-sql/3-tooling/emitter/test/emitter-hook.structure.test.ts` around lines 1 - 933, The test file is too large (933 lines); split the single large spec into multiple focused test files to meet the 500-line guideline: create smaller files such as emitter-hook.structure.models.test.ts, emitter-hook.structure.tables.test.ts, and emitter-hook.structure.foreignkeys.test.ts (or similar) and move related test cases that exercise sqlEmission.validateStructure, the describe('sql-target-family-hook') block, and the helper createContract into those files; ensure each new file imports sqlEmission and the createContract helper (or extract createContract into a shared test helper), and preserve all test names and expectations so tests for model-level checks, table-level checks, and foreignKey/index/constraint checks remain equivalent.packages/2-sql/3-tooling/emitter/README.md (2)
7-7: Stale reference toTargetFamilyHookin documentation.Line 7 mentions "implements the
TargetFamilyHookinterface" but the code examples now useEmissionSpi. Consider updating the prose to referenceEmissionSpifor consistency with the refactor.📝 Suggested fix
-This package provides the SQL-specific emitter hook implementation for the Prisma Next emitter. It validates SQL contracts and generates TypeScript type definitions for SQL contracts. It's part of the SQL tooling layer (migration plane) and implements the `TargetFamilyHook` interface. +This package provides the SQL-specific emitter hook implementation for the Prisma Next emitter. It validates SQL contracts and generates TypeScript type definitions for SQL contracts. It's part of the SQL tooling layer (migration plane) and implements the `EmissionSpi` interface.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-sql/3-tooling/emitter/README.md` at line 7, The README references the outdated symbol TargetFamilyHook; update the prose to reference the current interface EmissionSpi so docs match the code examples and refactor: replace the phrase "implements the `TargetFamilyHook` interface" with "implements the `EmissionSpi` interface" and adjust any surrounding wording to reflect EmissionSpi usage (search for TargetFamilyHook and EmissionSpi in the README to ensure consistency).
21-21: Stale reference toTargetFamilyHookin dependencies section.Line 21 mentions "
TargetFamilyHookSPI" but should referenceEmissionSpito match the refactor.📝 Suggested fix
- - `@prisma-next/contract` (contract IR, `TargetFamilyHook` SPI, `ValidationContext`, `TypesImportSpec` - types moved to shared plane) + - `@prisma-next/contract` (contract IR, `EmissionSpi` SPI, `ValidationContext`, `TypesImportSpec` - types moved to shared plane)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-sql/3-tooling/emitter/README.md` at line 21, The README's dependency list mentions the outdated symbol TargetFamilyHook; update that entry to reference the new EmissionSpi symbol instead (e.g., replace "TargetFamilyHook SPI" with "EmissionSpi" while preserving surrounding context such as `@prisma-next/contract` and other type names like `ValidationContext` and `TypesImportSpec`) so the doc reflects the refactor.packages/2-mongo-family/9-family/README.md (1)
8-16: Useemissionterminology consistently in this README.The symbol is correctly renamed to
mongoEmission, but the surrounding text still calls it a “target family hook.” Consider updating this toEmissionSpiphrasing for consistency with the current API surface.As per coding guidelines: "
packages/**/*.md: Update design docs to reflect the current state only, not the transition history or legacy approaches."Also applies to: 55-55
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-mongo-family/9-family/README.md` around lines 8 - 16, The README uses outdated "target family hook" wording around the renamed symbol mongoEmission; update the phrasing to consistently use "EmissionSpi" (or "emission" terminology) throughout the document — especially the bullet mentioning "Family Hook Integration" — and remove transition/legacy wording so the responsibilities read: Family Descriptor Export (ControlFamilyDescriptor), Family Instance Creation (MongoControlFamilyInstance via create()), and Family Hook Integration (mongoEmission / EmissionSpi); ensure all mentions of "target family hook" are replaced with "EmissionSpi" or "emission" to match the current API surface.packages/2-mongo-family/3-tooling/emitter/test/emitter-hook.generation.test.ts (1)
9-9: Rename the suite title to matchgenerateContractDtsusage.The current title still references
generateContractTypes, but the test exercisesgenerateContractDts.✏️ Suggested rename
-describe('mongoEmission.generateContractTypes', () => { +describe('generateContractDts (mongo emission)', () => {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-mongo-family/3-tooling/emitter/test/emitter-hook.generation.test.ts` at line 9, The test suite title is outdated: change the describe string from 'mongoEmission.generateContractTypes' to 'mongoEmission.generateContractDts' so the suite name matches the actual function under test (generateContractDts) used in the test; update the describe call in emitter-hook.generation.test.ts accordingly to keep the test message accurate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/architecture` docs/adrs/ADR 185 - SPI types live at the lowest consuming
layer.md:
- Around line 42-43: Update the ADR titled "ADR 185 - SPI types live at the
lowest consuming layer" to replace every reference to the old interface name
TargetFamilyHook with the current interface name EmissionSpi (including prose,
code examples, and any type/import mentions such as sqlEmission and
mongoEmission), ensuring examples and explanations still compile conceptually
with EmissionSpi and that any surrounding wording (e.g., "interface", "hook",
"SPI") is adjusted for the new name so the document is consistent.
In `@packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts`:
- Around line 60-63: The emitted execution clause currently serializes
contract.execution verbatim via serializeValue causing execution.executionHash
to become a plain string literal; instead, detect when contract.execution exists
and build the execution fragment explicitly so you can replace the nested
execution.executionHash with the generated ExecutionHash alias (same approach
used for contract.storage.storageHash), i.e., in the code that builds
executionClause (variable executionClause / function serializeValue usage),
construct an object/stringified fragment that injects ExecutionHash for
execution.executionHash rather than the literal from contract.execution and keep
other fields serialized as before.
- Around line 39-56: generateContractDts is passing an unvalidated Contract into
emitter.generateStorageType and generateModelsType which can produce generic
runtime errors; before computing storageType/modelsType call a contract
validation routine (e.g., validateContractStructure(contract) or
emitter.validateContract if available) and short-circuit by returning
diagnostics or throwing a clear ValidationError when validation fails. Also
ensure the serialized execution property uses the branded ExecutionHash alias
instead of the raw hash: when building models/storage types (before calling
emitter.generateStorageType and emitter.generateModelsType or in the data you
pass them), replace the nested execution.executionHash field with the generated
ExecutionHash type reference (the alias produced by generateHashTypeAliases) so
the emitted types reference ExecutionHash rather than the bare value.
In `@packages/2-sql/9-family/README.md`:
- Around line 8-17: The README mixes legacy "hook"/`TargetFamilyHook`
terminology with the new `sqlEmission`/`EmissionSpi` naming; update the document
to consistently use the new emission vocabulary (e.g., replace "target family
hook", `TargetFamilyHook`, and any "hook" mentions with "emission" and
`EmissionSpi`) including in the list items and responsibility bullets
(`sqlEmission`, `ControlFamilyDescriptor`, `SqlFamilyInstance`,
`MigrationPlanner`, `MigrationRunner`, `SqlControlTargetDescriptor`) so the doc
reflects the current API and removes transitional/legacy wording.
---
Outside diff comments:
In `@packages/1-framework/1-core/framework-components/README.md`:
- Line 10: Update the Emission SPI bullet to remove stale generation-era types
(TargetFamilyHook, ValidationContext, GenerateContractTypesOptions,
TypeRenderEntry, TypeRenderer, ParameterizedCodecDescriptor and related types)
and instead document the current emission types as described by EmissionSpi (the
new SPI); replace the old list with a concise, accurate enumeration that matches
the explanation of EmissionSpi on Line 24.
In `@packages/2-mongo-family/3-tooling/emitter/README.md`:
- Around line 7-39: Update the README to remove references to the legacy
TargetFamilyHook and generateContractTypes flow and instead document the current
EmissionSpi + framework-owned DTS assembly model: keep the usage example showing
emit(contractIR, mongoEmission, options) and then replace the "What it provides"
and architecture sections to describe mongoEmission as an EmissionSpi
implementation that validates codec IDs and structure (ns/name@version),
delegates domain-level type generation to
`@prisma-next/emitter/domain-type-generation`, and relies on the framework to
assemble the final contract.d.ts artifacts; remove transition-state wording and
any mention of “generateContractTypes”/TargetFamilyHook while keeping
Mongo-specific validation points (collections, owned/embedded rules,
polymorphism, storage.relations) and references to contract.d.ts and contract
generation flow.
In `@packages/2-mongo-family/3-tooling/emitter/src/index.ts`:
- Around line 6-120: The exported mongoEmission object exposes
implementation-only methods validateTypes and validateStructure which leak
beyond the EmissionSpi boundary; rename these methods to private names (e.g.,
_validateTypes and _validateStructure) or remove them if unused, then add an
explicit type annotation ": EmissionSpi" to the mongoEmission export so the
public surface matches the SPI. Update any internal callers to reference the new
private names (mongoEmission._validateTypes / mongoEmission._validateStructure)
or remove those calls, and ensure the file imports/uses EmissionSpi so the
annotation type-checks.
---
Nitpick comments:
In
`@packages/2-mongo-family/3-tooling/emitter/test/emitter-hook.generation.test.ts`:
- Line 9: The test suite title is outdated: change the describe string from
'mongoEmission.generateContractTypes' to 'mongoEmission.generateContractDts' so
the suite name matches the actual function under test (generateContractDts) used
in the test; update the describe call in emitter-hook.generation.test.ts
accordingly to keep the test message accurate.
In `@packages/2-mongo-family/9-family/README.md`:
- Around line 8-16: The README uses outdated "target family hook" wording around
the renamed symbol mongoEmission; update the phrasing to consistently use
"EmissionSpi" (or "emission" terminology) throughout the document — especially
the bullet mentioning "Family Hook Integration" — and remove transition/legacy
wording so the responsibilities read: Family Descriptor Export
(ControlFamilyDescriptor), Family Instance Creation (MongoControlFamilyInstance
via create()), and Family Hook Integration (mongoEmission / EmissionSpi); ensure
all mentions of "target family hook" are replaced with "EmissionSpi" or
"emission" to match the current API surface.
In `@packages/2-sql/3-tooling/emitter/README.md`:
- Line 7: The README references the outdated symbol TargetFamilyHook; update the
prose to reference the current interface EmissionSpi so docs match the code
examples and refactor: replace the phrase "implements the `TargetFamilyHook`
interface" with "implements the `EmissionSpi` interface" and adjust any
surrounding wording to reflect EmissionSpi usage (search for TargetFamilyHook
and EmissionSpi in the README to ensure consistency).
- Line 21: The README's dependency list mentions the outdated symbol
TargetFamilyHook; update that entry to reference the new EmissionSpi symbol
instead (e.g., replace "TargetFamilyHook SPI" with "EmissionSpi" while
preserving surrounding context such as `@prisma-next/contract` and other type
names like `ValidationContext` and `TypesImportSpec`) so the doc reflects the
refactor.
In `@packages/2-sql/3-tooling/emitter/src/index.ts`:
- Around line 27-31: The code uses unsafe blind casts (as unknown as ...) on
contract.storage and contract.models inside sqlEmission (notably in
validateTypes and other methods); replace these with proper type guards such as
isSqlStorage(storage): storage is SqlStorage and isSqlModel(model): model is
SqlModel and use them to narrow types before accessing SQL-specific fields in
functions like validateTypes and any other methods referencing
contract.storage/contract.models (replace casts at the locations currently using
as unknown as); if this cannot be completed now, add a short justificatory
comment where each cast remains explaining why the SPI-family context guarantees
the type and mark TODO to implement the type predicate to avoid blind casts.
In `@packages/2-sql/3-tooling/emitter/test/emitter-hook.structure.test.ts`:
- Around line 1-933: The test file is too large (933 lines); split the single
large spec into multiple focused test files to meet the 500-line guideline:
create smaller files such as emitter-hook.structure.models.test.ts,
emitter-hook.structure.tables.test.ts, and
emitter-hook.structure.foreignkeys.test.ts (or similar) and move related test
cases that exercise sqlEmission.validateStructure, the
describe('sql-target-family-hook') block, and the helper createContract into
those files; ensure each new file imports sqlEmission and the createContract
helper (or extract createContract into a shared test helper), and preserve all
test names and expectations so tests for model-level checks, table-level checks,
and foreignKey/index/constraint checks remain equivalent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: eadbedc1-784a-4251-8988-6b7a4c30d5cd
⛔ Files ignored due to path filters (6)
packages/2-sql/4-lanes/sql-builder/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**projects/contract-domain-extraction/plan.mdis excluded by!projects/**projects/contract-domain-extraction/plans/6-sql-emitter-shared-generation-plan.mdis excluded by!projects/**test/e2e/framework/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**test/integration/test/mongo/fixtures/generated/contract.d.tsis excluded by!**/generated/**
📒 Files selected for processing (60)
docs/Testing Guide.mddocs/architecture docs/adrs/ADR 185 - SPI types live at the lowest consuming layer.mdexamples/mongo-demo/src/app/App.tsxexamples/prisma-next-demo/src/prisma/contract.d.tspackages/1-framework/1-core/config/src/config-validation.tspackages/1-framework/1-core/config/test/config-types.test-d.tspackages/1-framework/1-core/config/test/config-validation.test.tspackages/1-framework/1-core/framework-components/README.mdpackages/1-framework/1-core/framework-components/src/control-descriptors.tspackages/1-framework/1-core/framework-components/src/emission-types.tspackages/1-framework/1-core/framework-components/src/exports/emission.tspackages/1-framework/1-core/framework-components/src/framework-components.tspackages/1-framework/3-tooling/cli/src/control-api/client.tspackages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.tspackages/1-framework/3-tooling/cli/test/config-loader.test.tspackages/1-framework/3-tooling/cli/test/config-types.test.tspackages/1-framework/3-tooling/cli/test/control-api/client.test.tspackages/1-framework/3-tooling/emitter/README.mdpackages/1-framework/3-tooling/emitter/src/domain-type-generation.tspackages/1-framework/3-tooling/emitter/src/emit.tspackages/1-framework/3-tooling/emitter/src/exports/index.tspackages/1-framework/3-tooling/emitter/src/generate-contract-dts.tspackages/1-framework/3-tooling/emitter/test/domain-type-generation.test.tspackages/1-framework/3-tooling/emitter/test/emitter.integration.test.tspackages/1-framework/3-tooling/emitter/test/emitter.roundtrip.test.tspackages/1-framework/3-tooling/emitter/test/emitter.test.tspackages/1-framework/3-tooling/emitter/test/mock-spi.tspackages/2-mongo-family/3-tooling/emitter/README.mdpackages/2-mongo-family/3-tooling/emitter/src/exports/index.tspackages/2-mongo-family/3-tooling/emitter/src/index.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.e2e.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.generation.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.structure.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.types.test.tspackages/2-mongo-family/3-tooling/emitter/test/generate-orm-fixture.tspackages/2-mongo-family/9-family/README.mdpackages/2-mongo-family/9-family/src/core/control-descriptor.tspackages/2-mongo-family/9-family/test/control.test.tspackages/2-sql/3-tooling/emitter/README.mdpackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.parameterized-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.structure.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.types.test.tspackages/2-sql/9-family/README.mdpackages/2-sql/9-family/src/core/control-descriptor.tspackages/2-sql/9-family/test/emit-parameterized.test.tspackages/2-sql/9-family/test/schema-view.test.tstest/integration/test/authoring/cli.emit-parity-fixtures.test.tstest/integration/test/authoring/psl.pgvector-dbinit.test.tstest/integration/test/cli.emit-contract.test.tstest/integration/test/cli.emit.test.tstest/integration/test/contract-imports.test.tstest/integration/test/control-api.test.tstest/integration/test/family.verify-database.basic.test.tstest/integration/test/family.verify-database.errors.test.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-verify.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.document-family.tstest/integration/test/fixtures/contract.d.ts
d8be901 to
db7e5ae
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/2-sql/3-tooling/emitter/src/index.ts (1)
390-400:⚠️ Potential issue | 🟠 MajorKeep SQL
modelsemission aligned with shared model metadata shape.Line 397 emits
ownerwithoutreadonly, and this override currently drops optional model metadata (discriminator,variants,base) when present. That can create a type-shape drift versus framework emission.🛠️ Proposed fix
- if (model.owner) { - modelParts.push(`owner: ${serializeValue(model.owner)}`); - } + if (model.owner) { + modelParts.push(`readonly owner: ${serializeValue(model.owner)}`); + } + if (model.discriminator) { + modelParts.push(`readonly discriminator: ${serializeValue(model.discriminator)}`); + } + if (model.variants) { + modelParts.push(`readonly variants: ${serializeValue(model.variants)}`); + } + if (model.base) { + modelParts.push(`readonly base: ${serializeValue(model.base)}`); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-sql/3-tooling/emitter/src/index.ts` around lines 390 - 400, The emitted model object is overriding the readonly shape and dropping optional metadata; change the push that handles model.owner to emit a readonly property (`readonly owner: ${serializeValue(model.owner)}`) and also include any optional metadata keys (`discriminator`, `variants`, `base`) into modelParts when present instead of overwriting the object literal—i.e., before pushing to modelParts, detect model.discriminator, model.variants, model.base and push corresponding `readonly <key>: ${serializeValue(...)}` entries alongside the owner entry so modelTypes (and symbols modelParts, modelName, serializeValue) preserve the full shared model metadata shape.
🤖 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/2-sql/3-tooling/emitter/src/index.ts`:
- Around line 303-305: The code is using a blind double-cast (as unknown as
SqlStorage) in generateModelsType and other methods which bypasses type safety;
replace these casts by either refining the Contract type signatures to carry
SqlStorage where appropriate (e.g., make the function accept
Contract<SqlStorage>) or add an explicit runtime/type predicate (e.g.,
isSqlStorage(storage): storage is SqlStorage) and use it to narrow storage
before using it in generateModelsType and the other affected functions (also
update uses in the other occurrences noted). If the check fails, return/throw a
clear error; this preserves safety without blind casting and keeps the
references to Contract, SqlStorage, ContractModel, and SqlModelStorage intact.
---
Outside diff comments:
In `@packages/2-sql/3-tooling/emitter/src/index.ts`:
- Around line 390-400: The emitted model object is overriding the readonly shape
and dropping optional metadata; change the push that handles model.owner to emit
a readonly property (`readonly owner: ${serializeValue(model.owner)}`) and also
include any optional metadata keys (`discriminator`, `variants`, `base`) into
modelParts when present instead of overwriting the object literal—i.e., before
pushing to modelParts, detect model.discriminator, model.variants, model.base
and push corresponding `readonly <key>: ${serializeValue(...)}` entries
alongside the owner entry so modelTypes (and symbols modelParts, modelName,
serializeValue) preserve the full shared model metadata shape.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 98ca4a36-796e-45d5-a5b7-c24dcb5af977
⛔ Files ignored due to path filters (6)
packages/2-sql/4-lanes/sql-builder/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**projects/contract-domain-extraction/plan.mdis excluded by!projects/**projects/contract-domain-extraction/plans/6-sql-emitter-shared-generation-plan.mdis excluded by!projects/**test/e2e/framework/test/fixtures/generated/contract.d.tsis excluded by!**/generated/**test/integration/test/mongo/fixtures/generated/contract.d.tsis excluded by!**/generated/**
📒 Files selected for processing (60)
docs/Testing Guide.mddocs/architecture docs/adrs/ADR 185 - SPI types live at the lowest consuming layer.mdexamples/mongo-demo/src/app/App.tsxexamples/prisma-next-demo/src/prisma/contract.d.tspackages/1-framework/1-core/config/src/config-validation.tspackages/1-framework/1-core/config/test/config-types.test-d.tspackages/1-framework/1-core/config/test/config-validation.test.tspackages/1-framework/1-core/framework-components/README.mdpackages/1-framework/1-core/framework-components/src/control-descriptors.tspackages/1-framework/1-core/framework-components/src/emission-types.tspackages/1-framework/1-core/framework-components/src/exports/emission.tspackages/1-framework/1-core/framework-components/src/framework-components.tspackages/1-framework/3-tooling/cli/src/control-api/client.tspackages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.tspackages/1-framework/3-tooling/cli/test/config-loader.test.tspackages/1-framework/3-tooling/cli/test/config-types.test.tspackages/1-framework/3-tooling/cli/test/control-api/client.test.tspackages/1-framework/3-tooling/emitter/README.mdpackages/1-framework/3-tooling/emitter/src/domain-type-generation.tspackages/1-framework/3-tooling/emitter/src/emit.tspackages/1-framework/3-tooling/emitter/src/exports/index.tspackages/1-framework/3-tooling/emitter/src/generate-contract-dts.tspackages/1-framework/3-tooling/emitter/test/domain-type-generation.test.tspackages/1-framework/3-tooling/emitter/test/emitter.integration.test.tspackages/1-framework/3-tooling/emitter/test/emitter.roundtrip.test.tspackages/1-framework/3-tooling/emitter/test/emitter.test.tspackages/1-framework/3-tooling/emitter/test/mock-spi.tspackages/2-mongo-family/3-tooling/emitter/README.mdpackages/2-mongo-family/3-tooling/emitter/src/exports/index.tspackages/2-mongo-family/3-tooling/emitter/src/index.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.e2e.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.generation.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.structure.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.types.test.tspackages/2-mongo-family/3-tooling/emitter/test/generate-orm-fixture.tspackages/2-mongo-family/9-family/README.mdpackages/2-mongo-family/9-family/src/core/control-descriptor.tspackages/2-mongo-family/9-family/test/control.test.tspackages/2-sql/3-tooling/emitter/README.mdpackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.parameterized-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.structure.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.types.test.tspackages/2-sql/9-family/README.mdpackages/2-sql/9-family/src/core/control-descriptor.tspackages/2-sql/9-family/test/emit-parameterized.test.tspackages/2-sql/9-family/test/schema-view.test.tstest/integration/test/authoring/cli.emit-parity-fixtures.test.tstest/integration/test/authoring/psl.pgvector-dbinit.test.tstest/integration/test/cli.emit-contract.test.tstest/integration/test/cli.emit.test.tstest/integration/test/contract-imports.test.tstest/integration/test/control-api.test.tstest/integration/test/family.verify-database.basic.test.tstest/integration/test/family.verify-database.errors.test.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-verify.tstest/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.document-family.tstest/integration/test/fixtures/contract.d.ts
✅ Files skipped from review due to trivial changes (29)
- examples/mongo-demo/src/app/App.tsx
- test/integration/test/family.verify-database.basic.test.ts
- test/integration/test/family.verify-database.errors.test.ts
- packages/1-framework/1-core/framework-components/src/control-descriptors.ts
- test/integration/test/contract-imports.test.ts
- packages/1-framework/1-core/framework-components/README.md
- packages/2-mongo-family/3-tooling/emitter/test/emitter-hook.structure.test.ts
- test/integration/test/authoring/cli.emit-parity-fixtures.test.ts
- packages/1-framework/1-core/framework-components/src/framework-components.ts
- packages/1-framework/1-core/framework-components/src/exports/emission.ts
- packages/2-sql/3-tooling/emitter/README.md
- packages/2-mongo-family/3-tooling/emitter/README.md
- packages/2-mongo-family/9-family/test/control.test.ts
- packages/2-sql/9-family/README.md
- test/integration/test/control-api.test.ts
- test/integration/test/cli.emit.test.ts
- packages/2-mongo-family/3-tooling/emitter/test/generate-orm-fixture.ts
- packages/2-mongo-family/3-tooling/emitter/test/emitter-hook.types.test.ts
- packages/2-sql/3-tooling/emitter/test/emitter-hook.types.test.ts
- packages/1-framework/3-tooling/cli/test/config-loader.test.ts
- packages/2-sql/3-tooling/emitter/test/emitter-hook.parameterized-types.test.ts
- docs/architecture docs/adrs/ADR 185 - SPI types live at the lowest consuming layer.md
- packages/1-framework/3-tooling/cli/test/control-api/client.test.ts
- packages/1-framework/1-core/config/test/config-validation.test.ts
- packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.ts
- packages/2-sql/3-tooling/emitter/test/emitter-hook.structure.test.ts
- packages/1-framework/3-tooling/emitter/README.md
- test/integration/test/authoring/psl.pgvector-dbinit.test.ts
- packages/2-mongo-family/3-tooling/emitter/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (23)
- packages/1-framework/3-tooling/cli/src/control-api/operations/contract-emit.ts
- packages/1-framework/3-tooling/cli/src/control-api/client.ts
- packages/1-framework/1-core/config/src/config-validation.ts
- packages/1-framework/3-tooling/emitter/src/exports/index.ts
- packages/2-mongo-family/9-family/README.md
- test/integration/test/fixtures/cli/cli-integration-test-app/fixtures/emit-command/prisma-next.config.document-family.ts
- packages/2-sql/9-family/test/emit-parameterized.test.ts
- packages/2-sql/9-family/src/core/control-descriptor.ts
- packages/2-mongo-family/3-tooling/emitter/src/exports/index.ts
- packages/2-sql/9-family/test/schema-view.test.ts
- packages/2-mongo-family/3-tooling/emitter/test/emitter-hook.generation.test.ts
- packages/1-framework/3-tooling/emitter/test/domain-type-generation.test.ts
- packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.ts
- packages/1-framework/3-tooling/emitter/src/emit.ts
- packages/1-framework/3-tooling/emitter/test/emitter.integration.test.ts
- packages/1-framework/3-tooling/emitter/test/emitter.test.ts
- examples/prisma-next-demo/src/prisma/contract.d.ts
- packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts
- docs/Testing Guide.md
- packages/1-framework/3-tooling/cli/test/config-types.test.ts
- packages/1-framework/1-core/framework-components/src/emission-types.ts
- test/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-verify/prisma-next.config.no-verify.ts
- packages/1-framework/1-core/config/test/config-types.test-d.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/2-sql/3-tooling/emitter/src/index.ts (1)
27-31: Add explicitEmissionSpitype annotation.The
sqlEmissionobject relies onas constwithout an explicit type annotation. This defers interface compliance checking to usage sites rather than catching mismatches at the definition.♻️ Suggested fix
+import type { EmissionSpi } from '@prisma-next/framework-components/emission'; + -export const sqlEmission = { +export const sqlEmission: EmissionSpi = { id: 'sql',Note: This would require removing
as constat the end of the object (line 442) since the explicit type provides the necessary constraints.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/2-sql/3-tooling/emitter/src/index.ts` around lines 27 - 31, The sqlEmission object should be explicitly typed as EmissionSpi to enforce interface conformance at the definition site; update the declaration to export const sqlEmission: EmissionSpi = { ... } (remove the trailing as const) so the compiler verifies all required members (e.g., validateTypes, id, and other methods/properties) are present and correctly typed, and adjust any implementations inside sqlEmission (such as validateTypes and references to SqlStorage) to satisfy the EmissionSpi signature.
🤖 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/2-sql/3-tooling/emitter/src/index.ts`:
- Around line 14-25: The function serializeTypeParamsLiteral has a runtime
defensive check for falsy params but its signature is Record<string, unknown>,
so update the signature to accept undefined (e.g., params: Record<string,
unknown> | undefined) and adjust any callers if necessary (notably where
typeInstance.typeParams is passed) so the type system reflects that the
parameter may be absent; ensure the rest of serializeTypeParamsLiteral logic
remains unchanged and still returns 'Record<string, never>' for undefined/empty
inputs.
---
Nitpick comments:
In `@packages/2-sql/3-tooling/emitter/src/index.ts`:
- Around line 27-31: The sqlEmission object should be explicitly typed as
EmissionSpi to enforce interface conformance at the definition site; update the
declaration to export const sqlEmission: EmissionSpi = { ... } (remove the
trailing as const) so the compiler verifies all required members (e.g.,
validateTypes, id, and other methods/properties) are present and correctly
typed, and adjust any implementations inside sqlEmission (such as validateTypes
and references to SqlStorage) to satisfy the EmissionSpi signature.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 3176bb01-d2ec-4d92-be74-d0d10e9fcb41
📒 Files selected for processing (3)
packages/1-framework/3-tooling/emitter/test/emitter.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.ts
✅ Files skipped from review due to trivial changes (1)
- packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.ts
cf97aff to
892c50d
Compare
Mark all M5 tasks complete. Rewrite M6 as a single-pass approach (post-M5): extend shared domain-level utilities, narrow the TargetFamilyHook interface, and migrate both SQL and Mongo hooks onto framework-owned template generation. Detailed plan: projects/contract-domain-extraction/plans/6-sql-emitter-shared-generation-plan.md
…rom emission, namespace SPI on descriptor
Move generateModelFieldsType from Mongo emitter local function to the
shared @prisma-next/emitter/domain-type-generation module. Both SQL and
Mongo families now emit { codecId, nullable } for model fields, so this
function is family-agnostic. Update Mongo hook to import from shared.
Iterates models sorted by name, generates fields via generateModelFieldsType, relations via generateModelRelationsType, and storage via a family-provided callback. Handles optional owner, discriminator, variants, and base properties.
Replace the vague TargetFamilyHook name with EmissionSpi — a focused interface for the family-specific parts of contract type emission. Rename the descriptor property from hook to emission. Pure rename, no behavioral change.
Establishes the call site for framework-owned template assembly. Initially delegates to emitter.generateContractTypes — the real template logic moves here in the next step.
…ntractDts Replace the monolithic generateContractTypes method with focused SPI callbacks: generateStorageType, generateModelStorageType, getFamilyImports, getFamilyTypeAliases, getTypeMapsExpression, getContractWrapper. SQL provides an optional generateModelsType override because it derives field codecs from storage columns. The framework generateContractDts function now owns the .d.ts template assembly using shared utilities and SPI callbacks. Both SQL and Mongo emitters implement the narrowed SPI. emit() delegates to generateContractDts instead of calling the hook directly.
Update mockHook objects in config and CLI tests to implement all EmissionSpi methods. Remove unused TypesImportSpec import and prefix unused modelName param in SQL emitter. Fix ContractVariantEntry shape in domain-type-generation test (value, not model). Regenerate e2e fixture contract.d.ts with framework-owned template output ordering.
Remove IRModelField/IRModelStorage/IRModelDefinition from SQL emitter, use ContractModel<SqlModelStorage> for type-safe storage access. Remove MongoModelIR from Mongo emitter, use ContractModel directly. Remove leaked serializeTypeParamsLiteral/serializeValue properties from SQL hook object (not part of EmissionSpi). Remove unnecessary type casts on contract.models in generateContractDts (always present). Remove redundant serialization tests already covered by shared module.
…sion/mongoEmission Align export names with the EmissionSpi concept. The old names referenced the replaced TargetFamilyHook abstraction.
Remove validateTypes/validateStructure from the EmissionSpi interface and from the emit() function. Validation is the responsibility of the upstream pipeline (familyInstance.validateContract() in contract-emit). The validation methods remain on the hook objects and are tested independently via their dedicated test files.
The framework template now emits readonly targetFamily alongside readonly target in the intersection type, restoring literal narrowing that was present in the old family-specific templates. Also restore empty-models guard in SQL generateModelsType.
Document the framework-owned template, EmissionSpi callbacks, and the SQL generateModelsType override limitation. Remove stale references to TargetFamilyHook and the old hook-based architecture.
The complex IR roundtrip test timed out at the default 200ms on CI. Add timeouts.typeScriptCompilation to match other roundtrip tests. Regenerate all contract.d.ts fixtures to reflect the new framework-owned template output (import order, ContractType alias, targetFamily literal, family type aliases positioning).
Cover emit.ts ?? fallbacks, generate-contract-dts.ts generateModelsType delegation and execution clause branches, and sql emitter generateModelStorageType and model.owner paths.
…nature Align the type signature with the defensive runtime check for falsy params.
Serialize the execution section field-by-field so executionHash references the generated ExecutionHash type alias instead of being a plain string literal.
Align all references, code examples, and descriptions with the renamed interface and the removal of validation methods from the emission SPI.
…elsType Rebase conflict resolution dropped the upstream renderer integration. Restore the check that uses parameterized renderers when available, clean up unused imports, and fix the resolved variable name mismatch.
0f79c30 to
f857cb5
Compare
Cast contract.models to Record<string, ContractModel> at the generate-contract-dts call site since Contract.models defaults to ContractModelBase but at emit time fields are always ContractField. Add timeouts.typeScriptCompilation to the stable-hashes integration test to prevent CI timeout on slower runners.
Contract.models defaults to ContractModelBase where fields are Readonly<Record<string, unknown>>, so field values are typed as unknown. Add a targeted cast since this is a validation function that checks for codecId presence.
closes TML-2188
Intent
Replace the monolithic
TargetFamilyHook.generateContractTypes()with a framework-owned.d.tstemplate assembler and a focusedEmissionSpithat families implement with only storage-specific type fragments. After this change, neither the SQL nor Mongo emitter owns the full template — the framework orchestrates assembly from shared domain-level generators and family callbacks.Key snippet
New — framework-owned template assembler
Change map
EmissionSpiinterface (replacesTargetFamilyHook)readonly emission: EmissionSpigenerateModelFieldsType,generateModelsTypegenerateContractDtsinstead oftargetFamily.generateContractTypesemission = sqlTargetFamilyHookemission = mongoTargetFamilyHookgenerateModelFieldsType,generateModelsTypegenerateContractDtsThe story
Extract shared model-level generation utilities —
generateModelFieldsType(from Mongo hook) andgenerateModelsType(new) are added to@prisma-next/emitter/domain-type-generation, establishing the shared vocabulary for model type emission that both families can use.Replace
TargetFamilyHookwithEmissionSpi— The vague "hook" abstraction becomes a focused emission SPI. TheControlFamilyDescriptorfield changes fromhooktoemission, namespacing the SPI on the descriptor for future extensibility (e.g.,descriptor.migration.*).Framework takes over the template —
generateContractDts()is added to@prisma-next/emitter, initially as a pass-through, then expanded to own the full.d.tsskeleton. It calls shared utilities for imports, hashes, codec intersections, roots, and models, and delegates toEmissionSpicallbacks for family-specific parts (storage type, family imports, type aliases, TypeMaps expression, contract wrapper).Narrow the SPI —
EmissionSpilosesgenerateContractTypes()and gains focused callbacks:generateStorageType,generateModelStorageType,getFamilyImports,getFamilyTypeAliases,getTypeMapsExpression,getContractWrapper. SQL and Mongo emitters are migrated to provide only these callbacks.Wire
emit()through the framework template —emit()now callsgenerateContractDts(contract, targetFamily, ...)instead oftargetFamily.generateContractTypes(...).Clean up internal types and leaked helpers — Remove
IRModelDefinition/IRModelField/IRModelStoragefrom the SQL emitter andMongoModelIRfrom the Mongo emitter (useContractModeldirectly). RemoveserializeValue/serializeTypeParamsLiteralproperties leaked onto the SQL emitter object literal.Behavior changes & evidence
Framework now owns
.d.tsassembly: Before, each family independently produced the entire.d.tsstring. After,generateContractDts()produces a structurally consistent.d.tsfrom shared generators and family callbacks.generateContractDtsgenerateContractDtsControlFamilyDescriptor.hook→ControlFamilyDescriptor.emission: All config construction, validation tests, CLI call sites, and family descriptors updated.emissionclearly scopes the SPI and makes the descriptor extensible.SQL emitter drops duplicated utilities (no behavior change):
serializeValue,serializeObjectKey,generateRootsType, import dedup, hash aliases, codec type intersection — all removed from the SQL emitter in favor of shared imports. ThegenerateContractTypesmethod (~140 lines of template + utility code) is removed.@prisma-next/emitter/domain-type-generation.Mongo emitter drops local helpers and template (no behavior change):
generateModelFieldsType,generateModelsType,generateStorageType(local), andgenerateContractTypesremoved. Replaced by shared imports and SPI callbacks.generateContractDtsinstead ofmongoTargetFamilyHook.generateContractTypes)Emitted
.d.tsimport ordering changed (cosmetic): Family imports (e.g.,ContractWithTypeMaps,TypeMaps as TypeMapsType) now appear before framework imports (Contract as ContractType, hash bases). The import alias for the framework contract type changed fromContractShapetoContractType.Compatibility / migration / risk
ControlFamilyDescriptorfield rename (hook→emission) is internal to the framework/family packages. No consumer code (ORM client, query builder, user configs) is affected..d.tschanged. This is cosmetic but may affect snapshot/golden-file tests in CI..d.tsno longer emitstargetFamilyin the TypeScript type (it was in the old hand-crafted template). The JSON still contains it.Follow-ups / open questions
EmissionSpi: The plan says to remove them but the implementation retains them. Either remove validation from the SPI or update the plan with the rationale.generateModelsTypeoverride: The SQL emitter provides its own models generation that bypasses the shared function. Track a follow-up to eliminate once SQL model construction populatesmodel.fields.codecIdat authoring time.sqlTargetFamilyHook→sqlEmission): Deferred to a follow-up commit.Non-goals / intentionally out of scope
generateModelsTypeoverrideSummary by CodeRabbit
New Features
Refactor
Documentation
Tests
Bug Fixes