Repository navigation
TML-1808 1: Contract schema for parameterized types - #95
Conversation
WalkthroughExtracts and normalizes parameterized type renderers from descriptors, threads them through SQL family assembly and instance creation into the emit pipeline, and uses them during contract TypeScript generation. Adds storage-level named type instances, column parameter fields, validation, and tests. Changes
Sequence Diagram(s)sequenceDiagram
participant Desc as Descriptor
participant Asm as Assembly
participant Inst as FamilyInstance
participant Emit as EmitLayer
participant Emtr as SQLEmitter
participant Gen as TypeGenerator
Desc->>Asm: provide descriptors (may include parameterized renderers)
Asm->>Asm: extractParameterizedRenderers(descriptors)
Note right of Asm: normalizeRenderer (compile templates → functions)\nenforce unique codecId ownership
Asm-->>Inst: Map<codecId, NormalizedTypeRenderer>
Inst->>Emit: assemble inputs + parameterizedRenderers
Emit->>Emtr: generateContractTypes(ir, imports, options={ parameterizedRenderers })
Emtr->>Gen: generateModelsType(models, storage, parameterizedRenderers)
Gen->>Gen: renderColumnType(column, storage, parameterizedRenderers)
Note right of Gen: resolve via typeRef → storage.types\nor inline typeParams\nor fallback to codec/native
Gen-->>Emtr: model types (with parameterized render results)
Emtr-->>Emit: contract TypeScript output
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI Agents
In @packages/1-framework/1-core/shared/contract/src/framework-components.ts:
- Around line 75-89: interpolateTypeTemplate currently silences missing
placeholder keys by returning an empty string; update the function
(interpolateTypeTemplate) to explicitly surface missing params (except the
special 'CodecTypes' key) by either throwing an Error that includes the template
and missing key or emitting a warning via a logger on the provided ctx (e.g.,
ctx.logger.warn or console.warn if no logger exists); ensure the new behavior
triggers when params[key] is undefined so template authors get immediate
feedback while preserving existing substitution logic for valid keys.
In @packages/2-sql/3-tooling/family/test/assembly.test.ts:
- Around line 116-171: The test should consolidate multiple boolean/size checks
into a single object matcher assertion: after calling
extractParameterizedRenderers(descriptors) and storing in renderers, replace the
separate expect(renderers.size)... and expect(renderers.has(...)) calls with one
assertion that compares renderers (or Array.from(renderers.keys())) against an
expected collection using an object/array matcher (e.g., toEqual or
toMatchObject) so the test verifies both entries ('pg/numeric@1' and
'pg/vector@1') in one assertion while still referencing the
extractParameterizedRenderers and renderers identifiers.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (18)
packages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-ts/schemas/data-contract-sql-v1.jsonpackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.jsonpackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
🧰 Additional context used
📓 Path-based instructions (41)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/{src/core,src/exports}/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Multi-plane packages must use a structured directory layout with
src/core/for shared plane code andsrc/exports/for entry points (control.ts, runtime.ts)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/family/src/core/instance.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-ts/schemas/data-contract-sql-v1.jsonpackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.jsonpackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/family/src/core/instance.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/family/src/core/instance.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-ts/schemas/data-contract-sql-v1.jsonpackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.jsonpackages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.json
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/src/core/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
packages/**/src/core/**: Keepsrc/core/**free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports insidesrc/core/**
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/src/core/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Core plane code in
src/core/**must not include CLI-specific or runtime-specific dependencies, only imports from shared plane packages
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/family/src/core/instance.ts
packages/**/src/index.ts
📄 CodeRabbit inference engine (.cursor/rules/no-barrel-files.mdc)
packages/**/src/index.ts: Never createindex.tsfiles that only containexport * from './other-module'orexport { something } from './other-module'- prefer explicit, direct imports instead
Only createindex.tsfiles when they contain actual implementation code; useexports/index.tspattern only for explicit, intentional API surfaces
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
**/index.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Avoid barrel files (as per
.cursor/rules/no-barrel-files.mdc)
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
🧠 Learnings (1)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/framework-components.ts
🧬 Code graph analysis (7)
packages/2-sql/1-core/contract/src/types.ts (1)
packages/2-sql/1-core/contract/src/exports/types.ts (3)
StorageTypeInstance(16-16)SqlStorage(13-13)StorageTable(15-15)
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts (1)
packages/2-sql/2-authoring/contract-ts/src/contract.ts (1)
validateContract(547-582)
packages/1-framework/1-core/migration/control-plane/src/emission/types.ts (1)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
TypeRenderEntry(197-200)
packages/2-sql/2-authoring/contract-ts/src/contract.ts (2)
packages/2-sql/1-core/contract/src/factories.ts (1)
storage(99-101)packages/1-framework/2-authoring/contract/src/table-builder.ts (1)
column(80-122)
packages/2-sql/3-tooling/emitter/src/index.ts (2)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
GenerateContractTypesOptions(205-212)packages/1-framework/2-authoring/contract/src/table-builder.ts (1)
column(80-122)
packages/2-sql/3-tooling/family/src/core/instance.ts (1)
packages/2-sql/3-tooling/family/src/core/assembly.ts (1)
extractParameterizedRenderers(133-165)
packages/1-framework/1-core/shared/contract/src/framework-components.ts (3)
packages/1-framework/1-core/shared/contract/src/exports/framework-components.ts (7)
RenderTypeContext(22-22)TypeRendererTemplate(29-29)TypeRendererFunction(28-28)TypeRenderer(27-27)NormalizedTypeRenderer(20-20)interpolateTypeTemplate(34-34)normalizeRenderer(35-35)packages/1-framework/1-core/shared/utils/src/result.ts (1)
value(59-65)packages/1-framework/1-core/shared/contract/src/types.ts (1)
TypesImportSpec(168-172)
…type Extend the SQL contract types to support parameterized column types: - Add StorageColumn.typeParams for codec-owned JS/type parameters - Add StorageColumn.typeRef for referencing named type instances - Add StorageTypeInstance type for named, parameterized type instances - Add SqlStorage.types for storing named type instances - Update Arktype validators to validate new optional fields These fields enable precise TypeScript types for parameterized columns like vectors (e.g. Vector<1536>) without coupling the SQL family emitter to specific adapter codec IDs. Part of TML-1808: Parameterized column types
Extend the validateContract() Arktype schemas to accept the new parameterized type fields: - Add typeParams? and typeRef? to StorageColumnSchema - Add StorageTypeInstanceSchema for named type instances - Add types? to StorageSchema Validation now accepts contracts with parameterized column types while maintaining backward compatibility with existing contracts. Part of TML-1808: Parameterized column types
Update the SQL contract JSON schema to include the new fields: - Add typeParams and typeRef to StorageColumn definition - Add StorageTypeInstance definition - Add storage.types for named type instances - Fix StorageColumn to use nativeType + codecId (matching TS types) Also update test fixtures to use the correct field names (nativeType + codecId instead of the old type field). Part of TML-1808: Parameterized column types
Add comprehensive tests for the new contract validation: - Column typeParams: accepts objects, rejects non-objects - Column typeRef: accepts strings, rejects non-strings - Storage types: validates required fields (codecId, nativeType, typeParams) - Validates optional nature of typeParams, typeRef, and storage.types 14 new test cases covering acceptance and rejection scenarios. Part of TML-1808: Parameterized column types
Addresses PR feedback to tighten contract validation: - Enforce typeParams/typeRef mutual exclusivity - Validate typeRef references an existing storage.types key - Reject array typeParams (must be plain object, not JS array) These constraints were documented in the spec but not enforced at validation time. Now validation fails early with clear error messages.
Introduces unified type renderer system for parameterized codecs:
- RenderTypeContext: context passed to renderers during d.ts generation
- TypeRendererTemplate: template-based renderer using {{key}} placeholders
- TypeRendererFunction: function-based renderer for full control
- NormalizedTypeRenderer: always-function form after assembly normalization
- normalizeRenderer(): compiles templates to functions at assembly time
- interpolateTypeTemplate(): template interpolation helper
Extends ComponentMetadata.types.codecTypes with parameterized field
to declare renderers for specific codecIds. Templates are normalized
to functions during pack assembly, not at emission time.
…decId error Adds assembly function that: - Extracts parameterized renderers from descriptor codecTypes.parameterized - Normalizes template-based renderers to functions at assembly time - Throws error when multiple descriptors provide renderer for same codecId This enforces the "duplicate codecId is a hard error" policy. Silent overrides are dangerous in a composition system; explicit errors surface conflicts immediately with clear context.
Updates the emission pipeline to pass parameterized renderers from assembly to the emitter: - Add TypeRenderContext, TypeRenderEntry, GenerateContractTypesOptions to @prisma-next/contract/types - Add parameterizedRenderers to EmitOptions - Update emit() to pass renderers to generateContractTypes - Update TargetFamilyHook.generateContractTypes signature with options - Add renderColumnType() helper to SQL emitter for parameterized types - Update generateModelsType() to use renderers for typeParams/typeRef The emitter now uses parameterized renderers to emit typed output for columns with typeParams or typeRef. This enables precise types like Vector<1536> instead of generic number[] for parameterized codecs.
Updates createSqlFamilyInstance to: - Extract parameterized renderers from descriptors during assembly - Pass renderers to emit() in emitContract() This completes the end-to-end wiring from descriptor declaration through assembly normalization to emission. Extensions can now declare template or function-based renderers in codecTypes.parameterized, which are normalized at assembly and used to emit precise types for columns with typeParams or typeRef.
Template authors now get immediate feedback when a placeholder key is not found in params. Throws an Error with the template and missing key info. The special CodecTypes placeholder is still handled via context.
Replace separate expect(renderers.size) and expect(renderers.has()) calls with a single object matcher comparing renderer keys. Also add test for missing template parameter error handling.
Use bracket notation for accessing properties from index signatures to satisfy TypeScript noPropertyAccessFromIndexSignature.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
@packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:
- Around line 1-452: Tests use the generic SqlContract<SqlStorage> with
validateContract which breaks type inference; define a concrete contract type
(e.g., a TestContract alias or inline fully-typed contract interface that
mirrors the fixtures used in this file) and replace all
validateContract<SqlContract<SqlStorage>>(...) calls with
validateContract<TestContract>(...), updating any extended inputs' types
likewise so each validateContract invocation uses the fully-typed contract
instead of the generic SqlContract<SqlStorage>.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (3)
packages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
🧰 Additional context used
📓 Path-based instructions (36)
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/1-framework/1-core/shared/contract/src/framework-components.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/1-framework/1-core/shared/contract/src/framework-components.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/1-framework/1-core/shared/contract/src/framework-components.ts
🧠 Learnings (1)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
🧬 Code graph analysis (1)
packages/2-sql/3-tooling/family/test/assembly.test.ts (1)
packages/2-sql/3-tooling/family/src/core/assembly.ts (1)
extractParameterizedRenderers(133-165)
🔇 Additional comments (13)
packages/1-framework/1-core/shared/contract/src/framework-components.ts (5)
3-24: Well-documented type renderer lifecycle.The lifecycle explanation (authoring → assembly → emission) is clear and helps developers understand when templates are compiled. The
RenderTypeContextinterface is appropriately minimal.
26-73: Clean discriminated union design for type renderers.The
kinddiscriminator enables type-safe handling. The normalized form correctly capturescodecIdfor tracking renderer ownership. The JSDoc examples are helpful for understanding usage.
75-97: Missing parameter handling implemented.The function now throws a descriptive error for missing template parameters (except
CodecTypes), addressing the previous review feedback. The error message helpfully includes both the template and available params.
99-114: LGTM!The normalizer correctly handles both renderer kinds. Template compilation defers validation to render time, which is appropriate since param availability depends on the column definition.
164-175: Clean extension of ComponentMetadata for parameterized codecs.The
parameterizedfield is optional (backward-compatible) and well-documented. The JSDoc correctly notes that duplicate codecId validation happens during assembly, keeping the type definition simple.packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts (1)
5-452: Well-structured test suite with good coverage.The test organization is excellent:
- Logical grouping by feature (typeParams, typeRef, storage.types)
- Comprehensive coverage of valid and invalid cases
- Test names are concise and omit 'should' as per guidelines
- Good use of shared
baseContractInputto avoid duplication- Appropriate use of object matchers and single assertions
packages/2-sql/3-tooling/family/test/assembly.test.ts (7)
1-13: LGTM!Clean imports and well-defined
TestDescriptortype alias that covers all relevant descriptor kinds for testing.
14-39: LGTM!Concise test verifying the empty-map edge case with a well-structured fixture.
81-114: LGTM!Correctly uses bracket notation for index signature access at line 99. The function-based renderer test effectively validates both extraction and invocation.
116-169: LGTM!Good consolidation of assertions at line 168 using a single
toEqualcheck on the keys array.
171-224: LGTM!Thorough error verification with regex matching that confirms the error message includes both conflicting descriptor IDs.
226-258: LGTM!Excellent coverage of
{{CodecTypes}}placeholder interpolation with context value, demonstrating both the context-based and param-based template variables in a single realistic template.
260-293: LGTM!Good error handling coverage for missing template parameters. The non-null assertion on line 288 is appropriate in test context after confirming extraction.
181c6f8 to
fb5c48a
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 (2)
packages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.json (1)
48-93: Consider adding test coverage for the new parameterized type fields.This fixture demonstrates the updated column schema (
nativeType,codecId,nullable) but doesn't exercise the newtypeParams,typeRef, orstorage.typesfeatures. Consider adding a fixture or test case that demonstrates parameterized type instances to ensure the schema evolution is fully validated.Would you like me to help identify where additional test fixtures with parameterized types should be added?
packages/2-sql/2-authoring/contract-ts/src/contract.ts (1)
24-36: Schema duplication betweenvalidators.tsandcontract.tsis noted.These schema definitions mirror those in
packages/2-sql/1-core/contract/src/validators.ts. While this duplication is likely intentional (different packages with different validation entry points), consider whether a shared schema module could reduce maintenance burden.
🤖 Fix all issues with AI agents
In @packages/2-sql/1-core/contract/src/types.ts:
- Around line 59-63: Add a short doc comment above the StorageTypeInstance type
explaining why typeParams is required (e.g., "named type instances must carry
type parameter metadata") and likewise document on StorageColumn that typeParams
is optional because columns can be non-parameterized; reference the symbols
StorageTypeInstance, StorageColumn, and the typeParams property in the comments
so future maintainers understand the intentional asymmetry.
- Around line 7-17: StorageColumnSchema currently only checks field types but
doesn't enforce that typeParams and typeRef are mutually exclusive; update the
schema declaration for StorageColumnSchema (the
type.declare<StorageColumn>().type(...) call) to add a .refine(...) validator
that returns false when both StorageColumn.typeParams !== undefined and
StorageColumn.typeRef !== undefined so any column with both fields set is
rejected at runtime.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (18)
packages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/1-framework/1-core/shared/contract/src/exports/types.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-ts/schemas/data-contract-sql-v1.jsonpackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.jsonpackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/3-tooling/family/test/assembly.test.ts
🧰 Additional context used
📓 Path-based instructions (41)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/**/{src/core,src/exports}/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Multi-plane packages must use a structured directory layout with
src/core/for shared plane code andsrc/exports/for entry points (control.ts, runtime.ts)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.jsonpackages/2-sql/2-authoring/contract-ts/schemas/data-contract-sql-v1.jsonpackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.jsonpackages/2-sql/2-authoring/contract-ts/schemas/data-contract-sql-v1.json
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/2-authoring/contract-ts/test/fixtures/contract-with-relations.jsonpackages/2-sql/2-authoring/contract-ts/test/fixtures/contract.json
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/src/core/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
packages/**/src/core/**: Keepsrc/core/**free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports insidesrc/core/**
Files:
packages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/core/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Core plane code in
src/core/**must not include CLI-specific or runtime-specific dependencies, only imports from shared plane packages
Files:
packages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/index.ts
📄 CodeRabbit inference engine (.cursor/rules/no-barrel-files.mdc)
packages/**/src/index.ts: Never createindex.tsfiles that only containexport * from './other-module'orexport { something } from './other-module'- prefer explicit, direct imports instead
Only createindex.tsfiles when they contain actual implementation code; useexports/index.tspattern only for explicit, intentional API surfaces
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
**/index.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Avoid barrel files (as per
.cursor/rules/no-barrel-files.mdc)
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
🧠 Learnings (3)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/2-sql/1-core/contract/src/exports/types.tspackages/1-framework/1-core/migration/control-plane/src/emission/types.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/family/test/assembly.test.tspackages/2-sql/3-tooling/family/src/core/instance.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/1-framework/1-core/migration/control-plane/src/emission/emit.tspackages/1-framework/1-core/shared/contract/src/exports/framework-components.tspackages/2-sql/3-tooling/family/src/core/assembly.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/contract/src/framework-components.tspackages/1-framework/1-core/shared/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/src/contract.tspackages/2-sql/1-core/contract/src/validators.tspackages/1-framework/1-core/shared/contract/src/exports/types.ts
📚 Learning: 2026-01-04T01:51:52.444Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/validate-contract-usage.mdc:0-0
Timestamp: 2026-01-04T01:51:52.444Z
Learning: Applies to **/*.{test,test-d,spec}.ts?(x) : For tests using `validateContract<TContract>()`, either use the fixture contract type or define a fully-typed contract type inline; never use `validateContract<SqlContract<SqlStorage>>()`.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
📚 Learning: 2026-01-04T01:51:52.444Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/validate-contract-usage.mdc:0-0
Timestamp: 2026-01-04T01:51:52.444Z
Learning: Applies to **/*.{ts,tsx,test-d.ts} : When using `validateContract<TContract>()`, always use a fully-typed contract type (not a generic `SqlContract<SqlStorage>`). Using a generic type causes all subsequent type inference to fail, resulting in `unknown` types throughout the code.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
🧬 Code graph analysis (4)
packages/1-framework/1-core/migration/control-plane/src/emission/types.ts (1)
packages/1-framework/1-core/shared/contract/src/types.ts (1)
TypeRenderEntry(197-200)
packages/2-sql/3-tooling/family/test/assembly.test.ts (1)
packages/2-sql/3-tooling/family/src/core/assembly.ts (1)
extractParameterizedRenderers(133-165)
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts (1)
packages/2-sql/2-authoring/contract-ts/src/contract.ts (1)
validateContract(547-582)
packages/2-sql/2-authoring/contract-ts/src/contract.ts (2)
packages/2-sql/1-core/contract/src/factories.ts (1)
storage(99-101)packages/1-framework/2-authoring/contract/src/table-builder.ts (1)
column(80-122)
General-purpose assertion functions for runtime invariants: - assertDefined<T>: narrows nullable values, throws with message if undefined/null - invariant: asserts boolean condition, throws with message if false These utilities eliminate coverage noise from redundant error branches that guard already-validated conditions.
Replace if-undefined-throw patterns with assertDefined() calls for cleaner invariant enforcement and improved branch coverage. Also adds tests for parameterized type rendering paths.
Covers placeholder interpolation, CodecTypes context substitution, multi-placeholder templates, and error throwing for missing params.
…types tests Using SqlContract<SqlStorage> directly breaks type inference because the generic loses literal types. The TestContract alias makes this explicit and provides a single point to update if needed.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/2-sql/3-tooling/emitter/src/index.ts:
- Around line 175-180: The code redundantly uses a non-null assertion and an
explicit check: remove the non-null assertion and rely on assertDefined for
safety; replace the line "const referencedTable: StorageTable =
storage.tables[fk.references.table]!;" with a plain lookup (e.g., "const
referencedTable: StorageTable = storage.tables[fk.references.table];") and keep
the existing assertDefined(...) that follows, or if you prefer the alternative,
remove the assertDefined call and keep only the non-null assertion—choose one
approach consistently for the lookup in this block involving referencedTable and
assertDefined.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
packages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/1-framework/1-core/shared/utils/package.jsonpackages/1-framework/1-core/shared/utils/src/assertions.tspackages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/utils/tsup.config.tspackages/2-sql/3-tooling/emitter/package.jsonpackages/2-sql/3-tooling/emitter/src/index.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.ts
🧰 Additional context used
📓 Path-based instructions (41)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/{src/core,src/exports}/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Multi-plane packages must use a structured directory layout with
src/core/for shared plane code andsrc/exports/for entry points (control.ts, runtime.ts)
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/package.jsonpackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/package.jsonpackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
packages/**/package.json
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
packages/**/package.json: Do not export plane-specific files via the wrong entrypoint
Export multi-plane entrypoints frompackage.jsonwith separate./adapter,./control, and./runtimesubpathsWhen resolving cyclic dependencies, check for unused dependencies before restructuring code. Use
grepto verify if a package actually imports from its dependency, and remove unused dependencies rather than restructuring code.
packages/**/package.json: SetsideEffects: falsein package.json for shared plane packages to ensure tree-shaking compatibility
Setplane: sharedin package.json metadata for shared plane packages
Create explicit export paths in package.json following the pattern: ./types, ./validators, ./factories for shared plane packages
Shared plane packages should depend only on framework core packages (@prisma-next/contract, @prisma-next/operations) and validation libraries like ArktypeWhen moving packages to new locations, update all relative paths that reference root-level files or other packages using the formula: count directory depth from package to root and use that many
../segments
Files:
packages/1-framework/1-core/shared/utils/package.jsonpackages/2-sql/3-tooling/emitter/package.json
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/package.jsonpackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/index.ts
📄 CodeRabbit inference engine (.cursor/rules/no-barrel-files.mdc)
packages/**/src/index.ts: Never createindex.tsfiles that only containexport * from './other-module'orexport { something } from './other-module'- prefer explicit, direct imports instead
Only createindex.tsfiles when they contain actual implementation code; useexports/index.tspattern only for explicit, intentional API surfaces
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
**/index.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Avoid barrel files (as per
.cursor/rules/no-barrel-files.mdc)
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
**/tsup.config.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Build configuration should use a single
tsupconfiguration block with entries for adapter, types, codec-types, control, and runtime, all outputting todist/exports
Files:
packages/1-framework/1-core/shared/utils/tsup.config.ts
🧠 Learnings (2)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/1-framework/1-core/shared/utils/src/exports/assertions.tspackages/1-framework/1-core/shared/utils/src/assertions.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.tspackages/2-sql/3-tooling/emitter/src/index.tspackages/1-framework/1-core/shared/utils/tsup.config.ts
📚 Learning: 2026-01-02T11:49:27.327Z
Learnt from: igalklebanov
Repo: prisma/prisma-next PR: 68
File: package.json:5-5
Timestamp: 2026-01-02T11:49:27.327Z
Learning: In package.json, when Corepack is involved, the packageManager field should use Corepack's hash format (hexadecimal, sha512.<hex>). This hex-based Corepack format is the standard representation of the hash; the base64 form (sha512-<base64>) is also a valid representation of the same hash but Corepack's hex format is the correct one to rely on in this field. Ensure you use the Corepack hex format for packageManager whenever Corepack is used to generate or verify integrity.
Applied to files:
packages/1-framework/1-core/shared/utils/package.jsonpackages/2-sql/3-tooling/emitter/package.json
🧬 Code graph analysis (2)
packages/1-framework/1-core/shared/utils/test/assertions.test.ts (1)
packages/1-framework/1-core/shared/utils/src/assertions.ts (2)
assertDefined(14-18)invariant(31-35)
packages/2-sql/3-tooling/emitter/src/index.ts (2)
packages/2-sql/1-core/contract/src/factories.ts (2)
storage(99-101)fk(51-66)packages/1-framework/1-core/shared/contract/src/types.ts (1)
GenerateContractTypesOptions(205-212)
🔇 Additional comments (13)
packages/1-framework/1-core/shared/contract/test/framework-components.renderer.test.ts (1)
1-103: LGTM! Comprehensive test coverage for template interpolation and renderer normalization.The test suite effectively validates both
interpolateTypeTemplateandnormalizeRendererutilities:
- interpolateTypeTemplate tests cover basic substitution, multiple placeholders, CodecTypes context replacement, combined placeholders, error handling for missing parameters (with helpful error messages), and type coercion of non-string values.
- normalizeRenderer tests verify template-to-function normalization, function renderer pass-through, and CodecTypes placeholder resolution.
The tests follow guidelines appropriately: concise descriptions without 'should', proper source imports, comprehensive error path coverage, and clear separation of concerns between static property checks and dynamic method result assertions.
packages/1-framework/1-core/shared/utils/tsup.config.ts (1)
6-6: LGTM!The new
exports/assertionsentry follows the established pattern for other utility exports in this config.packages/1-framework/1-core/shared/utils/package.json (1)
30-33: LGTM!The new
./assertionsexport path follows the established pattern for other utility exports and correctly references the build output.packages/1-framework/1-core/shared/utils/src/exports/assertions.ts (1)
1-1: LGTM!Clean barrel export following the established pattern for this package.
packages/1-framework/1-core/shared/utils/test/assertions.test.ts (1)
1-43: LGTM!Comprehensive test coverage for both
assertDefinedandinvariantutilities, including:
- Runtime behavior validation (throw/pass cases)
- Type narrowing verification
- Edge cases for falsy values
- Expression evaluation
Tests correctly import from source and follow the project's testing conventions.
packages/1-framework/1-core/shared/utils/src/assertions.ts (1)
1-35: LGTM!Well-documented assertion utilities with clear semantics:
assertDefinedprovides type narrowing for null/undefined checksinvariantprovides runtime invariant enforcementBoth functions are appropriately simple (2-3 lines of logic) and don't warrant external dependencies. The JSDoc documentation with examples is helpful for a public API surface.
packages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.ts (3)
1-1: LGTM!Import addition is appropriate for the new test cases below.
715-758: LGTM!Good test coverage for inline typeParams with parameterized renderers. The test correctly validates that when a column has
typeParamsand a matching renderer exists, the renderer produces the expected TypeScript type expression.
760-810: LGTM!Good test coverage for the typeRef path with parameterized renderers. The test validates the indirection chain: column's
typeRef→storage.types[typeRef]→ renderer using the referenced type's params.packages/2-sql/3-tooling/emitter/src/index.ts (4)
73-74: LGTM!Using
assertDefinedhere provides a clear runtime invariant check with a descriptive error message after thetableNames.has()validation. This aligns with the PR's pattern of usingassertDefinedfor invariant enforcement.
200-221: LGTM!The optional
optionsparameter addition andparameterizedRenderersextraction are cleanly implemented. The optional chaining ensures safe access when options is undefined.
302-335: LGTM with note on fallback behavior.The
renderColumnTypemethod cleanly handles typeRef resolution, inline typeParams, and the default scalar fallback. The precedence order (typeRef → inline typeParams → default) is sensible.One edge case to be aware of: if a column has
typeRefbut no matching renderer exists, the fallback usescolumn.codecIdrather thantypeInstance.codecId. In the current tests, these match, but if they could differ, you may want to track that scenario.
337-365: LGTM!Clean integration of
renderColumnTypeinto the field generation loop. The nullable handling correctly wraps the base type with| nullwhen needed.
StorageColumn.typeParams is optional because most columns use non-parameterized types. StorageTypeInstance.typeParams is required because named type instances exist specifically for reusable parameterized types. Also removes redundant non-null assertion from emitter; assertDefined provides the safety check.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
@packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:
- Around line 5-10: The TestContract alias currently uses the forbidden generic
SqlContract<SqlStorage>, which prevents proper type inference; replace that
alias with a concrete, fully-typed contract type that matches the test fixtures
(or import the fixture's contract type) and use that type with
validateContract<TestContract>(); specifically remove the line defining
TestContract as SqlContract<SqlStorage>, declare an explicit contract shape
matching your JSON fixtures (or import the fixture type) so validateContract,
SqlContract, and any usages of TestContract get proper literal types rather than
unknown.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (3)
packages/2-sql/1-core/contract/src/types.tspackages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/3-tooling/emitter/src/index.ts
🧰 Additional context used
📓 Path-based instructions (38)
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
packages/**/src/index.ts
📄 CodeRabbit inference engine (.cursor/rules/no-barrel-files.mdc)
packages/**/src/index.ts: Never createindex.tsfiles that only containexport * from './other-module'orexport { something } from './other-module'- prefer explicit, direct imports instead
Only createindex.tsfiles when they contain actual implementation code; useexports/index.tspattern only for explicit, intentional API surfaces
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
**/index.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Avoid barrel files (as per
.cursor/rules/no-barrel-files.mdc)
Files:
packages/2-sql/3-tooling/emitter/src/index.ts
🧠 Learnings (3)
📚 Learning: 2026-01-04T01:51:52.444Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/validate-contract-usage.mdc:0-0
Timestamp: 2026-01-04T01:51:52.444Z
Learning: Applies to **/*.{test,test-d,spec}.ts?(x) : For tests using `validateContract<TContract>()`, either use the fixture contract type or define a fully-typed contract type inline; never use `validateContract<SqlContract<SqlStorage>>()`.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
📚 Learning: 2026-01-04T01:51:52.444Z
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: .cursor/rules/validate-contract-usage.mdc:0-0
Timestamp: 2026-01-04T01:51:52.444Z
Learning: Applies to **/*.{ts,tsx,test-d.ts} : When using `validateContract<TContract>()`, always use a fully-typed contract type (not a generic `SqlContract<SqlStorage>`). Using a generic type causes all subsequent type inference to fail, resulting in `unknown` types throughout the code.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/3-tooling/emitter/src/index.ts
🧬 Code graph analysis (2)
packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts (1)
packages/2-sql/2-authoring/contract-ts/src/contract.ts (1)
validateContract(547-582)
packages/2-sql/3-tooling/emitter/src/index.ts (3)
packages/2-sql/1-core/contract/src/types.ts (3)
StorageTable(53-59)StorageColumn(10-25)SqlStorage(77-84)packages/1-framework/1-core/shared/contract/src/exports/types.ts (1)
GenerateContractTypesOptions(16-16)packages/1-framework/1-core/shared/contract/src/types.ts (1)
GenerateContractTypesOptions(205-212)
🔇 Additional comments (11)
packages/2-sql/1-core/contract/src/types.ts (4)
3-9: LGTM - Clear documentation of design rationale.The JSDoc effectively explains why
typeParamsis optional for columns and documents the two approaches (inline vs. reference).
61-75: Excellent documentation of the design asymmetry.The JSDoc clearly explains why
typeParamsis required forStorageTypeInstance(exists specifically for parameterized types) while optional forStorageColumn(most columns are non-parameterized). This addresses the previous review feedback effectively.
79-83: LGTM - Consistent with the parameterized types design.The optional
typesfield appropriately extends the storage surface to support named type instances.
14-24: Runtime validation still needed for mutual exclusivity.The documentation correctly states that
typeParamsandtypeRefare mutually exclusive, but runtime validation is missing. This was flagged in a previous review and remains unresolved.Likely an incorrect or invalid review comment.
packages/2-sql/3-tooling/emitter/src/index.ts (7)
2-14: LGTM - Imports align with parameterized rendering features.The added imports support the new
renderColumnTypemethod and parameterized renderer threading.
73-74: LGTM - Proper assertion pattern without redundancy.Clean use of
assertDefinedwithout non-null assertions. This is the correct pattern for validated lookups.
200-205: LGTM - Clean API extension for parameterized rendering.Adding the optional
optionsparameter maintains backward compatibility while enabling parameterized type support.
214-219: LGTM - Proper extraction and threading of parameterized renderers.Clean pattern for propagating
parameterizedRenderersthrough the generation pipeline.
337-365: LGTM - Clean integration of parameterized rendering.The refactor to use
renderColumnTypecentralizes type resolution logic and properly threads parameterized renderers through model generation. The nullable wrapping is correctly applied after base type resolution.
175-180: Redundant: remove non-null assertion, keepassertDefinedalone.Line 176 uses
!and lines 177-180 callassertDefinedwith the same validation. This was flagged in a previous review and remains unresolved.🔎 Recommended fix
- // Table existence guaranteed by Set.has() check above - const referencedTable: StorageTable | undefined = storage.tables[fk.references.table]!; - assertDefined( - referencedTable, - `Table "${tableName}" foreignKey references non-existent table "${fk.references.table}"`, - ); + const referencedTable = storage.tables[fk.references.table]; + assertDefined( + referencedTable, + `Table "${tableName}" foreignKey references non-existent table "${fk.references.table}"`, + );Likely an incorrect or invalid review comment.
302-335: Logic is sound, consider early returns for clarity.The cascading type resolution (typeRef → inline typeParams → scalar) is correct. The method properly delegates to parameterized renderers when available.
🔎 Optional refactor for improved readability
Consider early returns to flatten the nesting:
renderColumnType( column: StorageColumn, storage: SqlStorage, parameterizedRenderers?: GenerateContractTypesOptions['parameterizedRenderers'], ): string { const codecId = column.codecId; // Check for typeRef - use the referenced type instance's params if (column.typeRef && storage.types) { const typeInstance = storage.types[column.typeRef]; if (typeInstance) { const renderer = parameterizedRenderers?.get(typeInstance.codecId); - if (renderer) { - return renderer.render(typeInstance.typeParams, { codecTypesName: 'CodecTypes' }); - } + if (renderer) { + return renderer.render(typeInstance.typeParams, { codecTypesName: 'CodecTypes' }); + } } } // Check for inline typeParams if (column.typeParams) { const renderer = parameterizedRenderers?.get(codecId); - if (renderer) { - return renderer.render(column.typeParams, { codecTypesName: 'CodecTypes' }); - } + if (renderer) { + return renderer.render(column.typeParams, { codecTypesName: 'CodecTypes' }); + } } // Default: scalar codec type return `CodecTypes['${codecId}']['output']`; }Likely an incorrect or invalid review comment.
StorageColumnSchema now uses .narrow() to reject columns that have both typeParams and typeRef set. These fields are documented as mutually exclusive; this enforces that constraint at validation time.
| it('passes through defined values', () => { | ||
| const value: string | undefined = 'hello'; | ||
| assertDefined(value, 'should not throw'); | ||
| // After assertion, value is narrowed to string |
There was a problem hiding this comment.
Probably AI comment, not really needed as it's after a pretty obvious function call assertDefined, is it?
|
|
||
| it('throws for null', () => { | ||
| const value: string | null = null; | ||
| expect(() => assertDefined(value, 'value was null')).toThrow('value was null'); |
There was a problem hiding this comment.
Nit: store the error string in a re-usable variable, rather than copying the same literal twice.
Use the same pattern above and below. Ideally, we can write this into our TESTING.md or similar AI-driven docs.
| const parameterized = descriptor.types?.codecTypes?.parameterized as | ||
| | Record<string, TypeRenderer> | ||
| | undefined; |
There was a problem hiding this comment.
This looks very ad-hoc, and it escapes the type signature of:
descriptors: ReadonlyArray<
| ControlTargetDescriptor<'sql', string>
| ControlAdapterDescriptor<'sql', string>
| ControlExtensionDescriptor<'sql', string>Is this type casting truly needed, or can we refine the types of descriptors to avoid it?
jkomyno
left a comment
There was a problem hiding this comment.
Approved with a few comments
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @packages/1-framework/1-core/shared/utils/test/assertions.test.ts:
- Around line 22-26: The test currently bundles multiple unrelated assertions in
one it block which reduces failure isolation; split the single test into three
separate tests that each call assertDefined once: one it('allows zero', ...)
that asserts assertDefined(0, ...), one it('allows empty string', ...) that
asserts assertDefined('', ...), and one it('allows false', ...) that asserts
assertDefined(false, ...); ensure each test has a clear description and keeps
the same message strings so failures point directly to the offending value.
In @packages/2-sql/3-tooling/family/src/core/assembly.ts:
- Around line 143-161: The code uses optional chaining when reading
parameterized after already validating codecTypes and codecTypes.parameterized;
update the assignment of parameterized to use a non-null assertion instead of
optional chaining so it reflects the prior check (i.e., read
codecTypes!.parameterized into the local parameterized variable) while leaving
the surrounding loop, owners, renderers, and normalizeRenderer usage unchanged.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (2)
packages/1-framework/1-core/shared/utils/test/assertions.test.tspackages/2-sql/3-tooling/family/src/core/assembly.ts
🧰 Additional context used
📓 Path-based instructions (39)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx}: Use localpnpm typecheckscripts instead of writingtsccommands from scratch for TypeScript type checking
Never add file extensions to imports in TypeScript
**/*.{ts,tsx}: Core contract types (ContractBase,Source) and document family types (DocumentContract) should be imported from@prisma-next/contract/types
SQL emitter hook should be imported from@prisma-next/sql-contract-emitter(canonical source)
Target-neutral operations should be imported from@prisma-next/operations(canonical source)
**/*.{ts,tsx}: ExtractCodecTypesfrom contract usingExtractCodecTypes<Contract>helper type with fallback toRecord<string, never>
ExtractOperationTypesfrom contract usingExtractOperationTypes<Contract>helper type with fallback toRecord<string, never>
Never passCodecTypesorOperationTypesas separate type parameters toschema(),sql(), ororm()functions
Always extract types from contract using the helper types instead of passing them directly
Contract must be validated before passing tocreateRuntimeContext()usingvalidateContract<Contract>()
**/*.{ts,tsx}: Use pnpm and local scripts (not ad-hoctsc,jest) for building and testing
Use adapters instead of branching on target in core code
Prefer links to canonical docs over long comments in code
Use type parameter pattern with.d.tsfor precise types instead of inferring types from JSON imports
Always usevalidateContract<Contract>(json)with fully-typed Contract type parameter, not genericSqlContract<SqlStorage>
Access table columns usingtable.columns.fieldNameto avoid conflicts with table properties
Builder methods return new instances; always chain calls instead of reassigning variables
No backward-compatibility shims; update call sites instead
Package layering is enforced; fix violations rather than bypassing them
Capability-gated features must be enabled in contract capabilities before use (e.g.,includeMany,returning())
Expo...
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
**/*.{ts,tsx,js,jsx}: Use arktype instead of zod for schema validation
Don't add comments if avoidable; prefer code which expresses its intent
Don't add exports for backwards compatibility unless explicitly requested
Do not reexport things from one file in another, except in theexports/foldersImport from shared plane packages using package name and export identifier (e.g.,
@prisma-next/sql-contract/types), not/exports/paths
**/*.{ts,tsx,js,jsx}: Follow layering rules and exceptions for imports as defined in.cursor/rules/import-validation.mdcand.cursor/architecture.config.json
Follow includeMany type inference patterns (as per.cursor/rules/include-many-patterns.mdc)
Follow Arktype usage guidelines defined in.cursor/rules/arktype-usage.mdc
UseObject.hasOwn()instead ofhasOwnProperty()(as per.cursor/rules/object-hasown.mdc)
Prefer assertions over defensive checks to avoid schema validation redundancy (as per.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/control-plane-descriptors.mdc)
packages/**/*.{ts,tsx}: UseControlFamilyDescriptor<TFamilyId, TFamilyInstance>type for family descriptors in control plane implementations
UseControlTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>type for target descriptors in control plane implementations
UseControlAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>type for adapter descriptors in control plane implementations
UseControlDriverDescriptor<TFamilyId, TTargetId, TDriverInstance>type for driver descriptors in control plane implementations
UseControlExtensionDescriptor<TFamilyId, TTargetId, TExtensionInstance>type for extension descriptors in control plane implementations
All control plane descriptors must includekindproperty as a discriminator with value'family' | 'target' | 'adapter' | 'driver' | 'extension'
All control plane descriptors must includeidproperty as a string identifier
All control plane descriptors must includefamilyIdproperty as a literal type (e.g.,'sql')
Target, adapter, driver, and extension descriptors must includetargetIdproperty as a literal type (e.g.,'postgres')
All control plane descriptors must includemanifestproperty of typeExtensionPackManifest
All control plane descriptors must includecreate()factory method that returns an instance
Always passdriverparameter toControlFamilyDescriptor.create(), even for commands that don't use it (e.g.,contract emit)
Do not use legacy descriptor types (FamilyDescriptor,TargetDescriptor,AdapterDescriptor,DriverDescriptor,ExtensionDescriptor,ControlPlaneDriver). UseControl*DescriptorandControl*Instancetypes instead
packages/**/*.{ts,tsx}: Family instances must implement control-plane domain actions (e.g.,emitContract,verify,schemaVerify,introspect) as self-contained methods that own their implementation logic
In family instance domain actions, import and use pure helper functions (e.g.,canonicalizeContract, `computeCoreHas...
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/{2-sql,sql}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/include-many-patterns.mdc)
packages/{2-sql,sql}/**/*.ts: Use a generic type parameter that accumulates include definitions across multipleincludeMany()calls with an Includes map:Includes extends Record<string, any> = Record<string, never>
Use a helper typeExtractIncludeType<K extends string, Includes extends Record<string, any>>for safe type-safe lookup of include types from accumulated map with fallback tounknown
Handle booleantruein type inference to allowselect({ posts: true })to inferArray<ChildShape>from the Includes map using pattern:P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : ...
Implement runtime capability checks in builder methods to gate features likeincludeMany()andreturning(), throwingplanInvalid()errors when required capabilities are missing or false
For features requiring multiple capabilities (e.g.,includeManyrequires both 'lateral' and 'jsonAgg'), check all required capabilities at runtime:if (targetCapabilities['lateral'] !== true || targetCapabilities['jsonAgg'] !== true)
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/core/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
packages/**/src/core/**: Keepsrc/core/**free of migration/runtime imports; depend only on shared-plane packages
Do not add plane-crossing imports insidesrc/core/**
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-entrypoints.mdc)
Structure multi-plane packages with split sources by plane:
src/core/**for shared,src/exports/control.tsfor migration,src/exports/runtime.tsfor runtime
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/{src/core,src/exports}/**
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Multi-plane packages must use a structured directory layout with
src/core/for shared plane code andsrc/exports/for entry points (control.ts, runtime.ts)
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/core/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/multi-plane-packages.mdc)
Core plane code in
src/core/**must not include CLI-specific or runtime-specific dependencies, only imports from shared plane packages
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add backward-compatibility shims or migration scaffolding in the codebase
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not add deprecation warnings or migration helpers
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
{packages,examples,test}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/object-hasown.mdc)
Always use
Object.hasOwn()instead ofhasOwnProperty()to check for own properties. The modern ES2022 API is preferred as it cannot be overridden or shadowed, and is enforced by Biome lint rulenoPrototypeBuiltins.Export interfaces and factory functions for public APIs; keep concrete classes as private implementation details
No generic defaults unless meaningful: defaults are semantics, not flexibility. See
.cursor/rules/generic-parameters.mdcfor details.
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/{2-sql,3-targets}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/postgres-lateral-patterns.mdc)
packages/{2-sql,3-targets}/**/*.{ts,tsx}: Don't quote identifiers early in functions. Quote them only when needed in SQL generation to avoid double-quoting issues.
When using LATERAL joins in PostgreSQL adapters, use different aliases for the table alias and column alias: table alias as{alias}_lateral, column alias as{alias}, and select usingtable_alias.column_alias(e.g.,posts_lateral.posts)
When both ORDER BY and LIMIT are present in a LATERAL subquery, wrap the query in an inner SELECT that projects individual columns with aliases, then usejson_agg(row_to_json(sub.*))on the result
Use column aliases in ORDER BY when the column is in the SELECT list; map column references to their aliases before generating ORDER BY clause
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Organize shared plane package source code with separate files: types.ts, validators.ts (optional), and factories.ts (optional)
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
Do not import migration-plane packages (emitter, CLI) or runtime-plane packages (lanes, runtime) in shared plane packages
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/sql-types-imports.mdc)
{packages/2-sql/**,packages/3-targets/**,examples/**,test/**}/*.{ts,tsx,js}: Import SQL-specific contract types (SqlContract,SqlStorage,SqlMappings,ModelDefinition,StorageTable,StorageColumn, etc.) from@prisma-next/sql-contract/types(shared plane package), not from@prisma-next/contract/types
SQL contract validators should be imported from@prisma-next/sql-contract/validators(shared plane)
SQL contract IR factories should be imported from@prisma-next/sql-contract/factories(shared plane)
SQL-specific operations should be imported from@prisma-next/sql-operations(canonical source, shared plane)
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
**/*.{ts,tsx,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
When using
validateContract<TContract>(), always use a fully-typed contract type (not a genericSqlContract<SqlStorage>). Using a generic type causes all subsequent type inference to fail, resulting inunknowntypes throughout the code.
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/!(*.test|*.test-d|*.spec).ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For production code using
validateContract<TContract>(), always import the contract type fromcontract.d.ts(generated by the emitter) rather than defining types inline.
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
{packages,test,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/arktype-usage.mdc)
{packages,test,examples}/**/*.{ts,tsx}: Use Arktype instead of Zod for schema validation and type definitions
Use optional keys via 'key?' syntax in Arktype schemas (not 'string | undefined')
Use 'type({ "[string]": Schema })' for defining record types in Arktype
Use 'Schema.array()' for array definitions in Arktype (avoid tuple mistakes)
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
{packages,examples,test}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-target-branches.mdc)
Never branch on
targetin core code - use adapters instead. Target-specific logic should be encapsulated in adapter interfaces and target-specific packages, not in conditional branches checking the target value.
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
{packages,test,examples}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
{packages,test,examples}/**/*.ts: Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g.,columnMeta!) after validation checks instead of optional chaining
Remove optional chaining and conditional property spreading for properties that are guaranteed to exist after validation - access required properties directly without?.operators
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-assertions-over-defensive-checks.mdc)
packages/**/*.ts: Use schema validators (Arktype) for structural validation of required fields, types, and shapes rather than redundant manual checks for these properties
Focus logical validators on consistency checks (foreign key references, model-to-table mappings, constraint relationships) that schema validators cannot perform, not on re-validating structural properties
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
{packages/2-sql,packages/sql,examples,test}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/query-patterns.mdc)
{packages/2-sql,packages/sql,examples,test}/**/*.ts: Prefer accessing columns viatables.user.columns.emailpattern instead of conflicting with table properties
Extract local variables when a file usestablesfrequently - useconst user = tables.userandconst cols = user.columnsfor readability
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
{packages,examples}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/type-predicates.mdc)
Avoid blind casts like
as unknown as Xin production TypeScript code. Use type predicates (value is X) or type guards instead to let the compiler narrow types safely.
{packages,examples}/**/*.{ts,tsx}: Export interfaces; construct via factories: keep classes as private implementation details.
Replace blind casts with type predicates. See.cursor/rules/type-predicates.mdcfor details.
Use interface-based design with factory functions for object construction. See.cursor/rules/interface-factory-pattern.mdcfor details.
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
For packages that span multiple planes, follow patterns in
.cursor/rules/multi-plane-packages.mdcand.cursor/rules/multi-plane-entrypoints.mdc
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/*.{sql,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
Use LATERAL and json_agg patterns as defined in
.cursor/rules/postgres-lateral-patterns.mdc
Files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/{2-sql,3-targets}/**
📄 CodeRabbit inference engine (.cursor/rules/directory-layout.mdc)
Place all SQL target-family packages (all layers and planes) under
packages/2-sql/**; place concrete dialects, adapters, and drivers underpackages/3-targets/**
Files:
packages/2-sql/3-tooling/family/src/core/assembly.ts
**/*.{test,spec}.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/omit-should-in-tests.mdc)
Omit the word 'should' in test descriptions - write concise, direct descriptions instead (e.g., 'equals 1' instead of 'should equal 1')
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/use-correct-tools.mdc)
Use local
pnpm testscripts for testing; usepnpm test:coveragefor all packages orpnpm coverage:packagesfor packages only
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/contract-normalization-responsibilities.mdc)
When writing tests for contract normalization, test that the builder normalizes correctly. Tests for validators, parsers, and emitter hooks should test that they work with already-normalized contracts, NOT that they normalize.
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/*.{test,spec}.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/no-backward-compatibility.md)
Do not keep old code or 'legacy' test fixtures for reference; delete old code entirely and update all references to use new approaches
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
**/*.test.ts: Keep test files under 500 lines to maintain readability and navigability. If a test file exceeds this limit, it should be split into multiple files.
Split test files when they exceed 500 lines, contain multiple distinct concerns that can be logically separated, or have multiple top-leveldescribeblocks that can be split by functionality.
Use descriptive file names with the pattern{base}.{category}.test.ts, such as.basic.test.ts,.errors.test.ts,.structure.test.ts, or feature-area prefixes likeruntime.joins.test.ts,runtime.projections.test.ts. Keep the base name consistent across related test files.
Group tests by logical boundaries: by functionality (e.g., 'basic', 'errors', 'structure', 'generation'), by feature area (e.g., 'joins', 'projections', 'includes'), or by test type (e.g., 'unit', 'integration', 'edge-cases'). Split at natural boundaries defined bydescribeblocks.
Prefer object comparison usingtoEqualortoMatchObjectfor assertions on objects, rather than property-by-property checks withtoHavePropertyor individual property assertions. Useexpect.any()for type-only checks andexpect.not.objectContaining()for absence checks.
Compare entire plan structures using singletoEqualassertions rather than piece-by-piece checks. Verify complete AST structures to ensure all fields are present and correct, not just a subset.
Ensure each split test file is complete and independently runnable: include all necessary imports, all necessary setup/teardown code, and verify all files are under 500 lines after splitting.
**/*.test.ts: Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Exception: Manual creation of Opera...
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/test/**/*.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/prefer-object-matcher.mdc)
Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/shared-plane-packages.mdc)
packages/**/test/**/*.{ts,tsx}: Create unit tests for validators and factories in shared plane packages, and include type tests for exported types
Do not create integration tests in shared plane packages that require migration-plane or runtime-plane packages
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/test/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/test-file-organization.mdc)
Integration tests that depend on multiple packages should be placed in
@prisma-next/integration-teststo avoid cyclic dependencies.Use factory functions like
createContractIR()instead of manual object creation for ContractIR objects in test utilities to avoid duplication, ensure type safety, and reduce maintenance burden when ContractIR structure changes
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/test/**
📄 CodeRabbit inference engine (.cursor/rules/use-ast-factories.mdc)
Use factory functions (createColumnRef, createParamRef, createLiteralExpr, createTableRef, createBinaryExpr) from @prisma-next/sql-relational-core/ast instead of manual object creation when creating AST nodes in tests
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/*.{test,test-d,spec}.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/validate-contract-usage.mdc)
For tests using
validateContract<TContract>(), either use the fixture contract type or define a fully-typed contract type inline; never usevalidateContract<SqlContract<SqlStorage>>().
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
packages/**/test/**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-import-patterns.mdc)
Within-package tests: Import from source (
../src/...), not from package exports
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/*.{test.ts,test-d.ts}
📄 CodeRabbit inference engine (.cursor/rules/test-mocking-patterns.mdc)
**/*.{test.ts,test-d.ts}: Use@ts-expect-errorwith a short reason in tests instead of blanket@ts-ignore
Use double casts (as unknown as X) for mocks and dynamic proxies in tests instead of direct casts
Preferunknownoveranyin tests to keep the unsafe boundary explicit
Don't spread class instances in tests ({ ...instance }), as you'll lose prototype methods. UseObject.create()andObject.assign()instead
Keep mock shapes minimal, containing only the fields needed for the test
Place type casts at mock boundaries (return statements), not sprinkled throughout the test
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/README.md)
**/*.test.{ts,tsx,js,jsx}: In test descriptions, omit the word 'should' (as per.cursor/rules/omit-should-in-tests.mdc)
In test files, use source file imports with relative paths, not exports intended for tests (as per.cursor/rules/test-import-patterns.mdc)
Organize test files with a maximum of 500 lines per file; split by functionality (as per.cursor/rules/test-file-organization.mdc)
Prefer object matchers over multiple individualexpect().toBe()calls in tests (as per.cursor/rules/prefer-object-matcher.mdc)
Use factory functions for creating AST nodes instead of manual object creation (as per.cursor/rules/use-ast-factories.mdc)
Use factory functions for ContractIR objects in tests instead of manual object creation (as per.cursor/rules/use-contract-ir-factories.mdc)
Follow test-only assertions and mocking patterns (as per.cursor/rules/test-mocking-patterns.mdc)
Files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
🧠 Learnings (2)
📚 Learning: 2025-12-26T23:02:40.679Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.
Applied to files:
packages/2-sql/3-tooling/family/src/core/assembly.tspackages/1-framework/1-core/shared/utils/test/assertions.test.ts
📚 Learning: 2026-01-07T05:58:01.640Z
Learnt from: wmadden
Repo: prisma/prisma-next PR: 95
File: packages/2-sql/2-authoring/contract-ts/test/contract.parameterized-types.test.ts:5-10
Timestamp: 2026-01-07T05:58:01.640Z
Learning: In test files named with .test.*, .spec.*, or .test-d.* (e.g., *.test.ts, *.spec.ts, *.test-d.ts, *.test.tsx), when using validateContract, it's acceptable to use a type alias like 'type TestContract = SqlContract<SqlStorage>' even if it doesn't provide full TypeScript type inference. The priority in tests is runtime validation behavior over precise TS type inference; use such aliases to simplify tests while keeping runtime correctness clear.
Applied to files:
packages/1-framework/1-core/shared/utils/test/assertions.test.ts
🧬 Code graph analysis (2)
packages/2-sql/3-tooling/family/src/core/assembly.ts (1)
packages/1-framework/1-core/shared/contract/src/framework-components.ts (3)
NormalizedTypeRenderer(70-73)TypeRenderer(64-64)normalizeRenderer(103-114)
packages/1-framework/1-core/shared/utils/test/assertions.test.ts (1)
packages/1-framework/1-core/shared/utils/src/assertions.ts (2)
assertDefined(14-18)invariant(31-35)
🔇 Additional comments (3)
packages/1-framework/1-core/shared/utils/test/assertions.test.ts (1)
1-43: Well-structured tests with good coverage.The test suite provides comprehensive coverage of both utilities:
assertDefinedcorrectly tests defined values, null, undefined, and falsy edge casesinvarianttests both passing and failing conditions with expression evaluationThe tests are concise, use appropriate imports from source, and follow the guideline of omitting "should" in test descriptions.
packages/2-sql/3-tooling/family/src/core/assembly.ts (2)
1-5: LGTM! Clean imports following guidelines.The imports correctly use type-only imports where appropriate and import from the specific module path without file extensions.
124-141: LGTM! Well-structured function with clear documentation.The function signature uses the correct control plane descriptor types, and the JSDoc clearly documents the intentional hard-error behavior for duplicate codecIds. The dual-map pattern (renderers + owners) is effective for tracking conflicts.
| it('allows zero and empty string', () => { | ||
| assertDefined(0, 'should not throw'); | ||
| assertDefined('', 'should not throw'); | ||
| assertDefined(false, 'should not throw'); | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider splitting into separate test cases for better failure isolation.
The test description mentions "zero and empty string" but also tests false. Additionally, bundling multiple unrelated assertions means if one fails, the others won't execute, making debugging harder.
♻️ Proposed refactor to separate test cases
- it('allows zero and empty string', () => {
- assertDefined(0, 'should not throw');
- assertDefined('', 'should not throw');
- assertDefined(false, 'should not throw');
+ it('allows zero', () => {
+ assertDefined(0, 'should not throw');
+ });
+
+ it('allows empty string', () => {
+ assertDefined('', 'should not throw');
+ });
+
+ it('allows false', () => {
+ assertDefined(false, 'should not throw');
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('allows zero and empty string', () => { | |
| assertDefined(0, 'should not throw'); | |
| assertDefined('', 'should not throw'); | |
| assertDefined(false, 'should not throw'); | |
| }); | |
| it('allows zero', () => { | |
| assertDefined(0, 'should not throw'); | |
| }); | |
| it('allows empty string', () => { | |
| assertDefined('', 'should not throw'); | |
| }); | |
| it('allows false', () => { | |
| assertDefined(false, 'should not throw'); | |
| }); |
🤖 Prompt for AI Agents
In @packages/1-framework/1-core/shared/utils/test/assertions.test.ts around
lines 22 - 26, The test currently bundles multiple unrelated assertions in one
it block which reduces failure isolation; split the single test into three
separate tests that each call assertDefined once: one it('allows zero', ...)
that asserts assertDefined(0, ...), one it('allows empty string', ...) that
asserts assertDefined('', ...), and one it('allows false', ...) that asserts
assertDefined(false, ...); ensure each test has a clear description and keeps
the same message strings so failures point directly to the offending value.
| for (const descriptor of descriptors) { | ||
| const codecTypes = descriptor.types?.codecTypes; | ||
| if (!codecTypes?.parameterized) continue; | ||
|
|
||
| const parameterized: Record<string, TypeRenderer> = codecTypes.parameterized; | ||
| for (const [codecId, renderer] of Object.entries(parameterized)) { | ||
| const existingOwner = owners.get(codecId); | ||
| if (existingOwner !== undefined) { | ||
| throw new Error( | ||
| `Duplicate parameterized renderer for codecId "${codecId}". ` + | ||
| `Descriptor "${descriptor.id}" conflicts with "${existingOwner}". ` + | ||
| 'Each codecId can only have one renderer.', | ||
| ); | ||
| } | ||
|
|
||
| renderers.set(codecId, normalizeRenderer(codecId, renderer)); | ||
| owners.set(codecId, descriptor.id); | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Use non-null assertion after validation check.
After the validation on line 145 confirms that codecTypes and codecTypes.parameterized exist, line 147 should use a non-null assertion to follow the project's guidelines about preferring assertions over defensive checks when data is guaranteed valid.
♻️ Apply non-null assertion pattern
const codecTypes = descriptor.types?.codecTypes;
if (!codecTypes?.parameterized) continue;
- const parameterized: Record<string, TypeRenderer> = codecTypes.parameterized;
+ const parameterized: Record<string, TypeRenderer> = codecTypes!.parameterized;
for (const [codecId, renderer] of Object.entries(parameterized)) {This makes it explicit that we've validated codecTypes exists and follows the pattern from the coding guidelines: "Prefer assertions over defensive checks when data is guaranteed to be valid - use non-null assertions (e.g., columnMeta!) after validation checks instead of optional chaining".
Based on coding guidelines: "Prefer assertions over defensive checks when data is guaranteed to be valid".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| for (const descriptor of descriptors) { | |
| const codecTypes = descriptor.types?.codecTypes; | |
| if (!codecTypes?.parameterized) continue; | |
| const parameterized: Record<string, TypeRenderer> = codecTypes.parameterized; | |
| for (const [codecId, renderer] of Object.entries(parameterized)) { | |
| const existingOwner = owners.get(codecId); | |
| if (existingOwner !== undefined) { | |
| throw new Error( | |
| `Duplicate parameterized renderer for codecId "${codecId}". ` + | |
| `Descriptor "${descriptor.id}" conflicts with "${existingOwner}". ` + | |
| 'Each codecId can only have one renderer.', | |
| ); | |
| } | |
| renderers.set(codecId, normalizeRenderer(codecId, renderer)); | |
| owners.set(codecId, descriptor.id); | |
| } | |
| } | |
| for (const descriptor of descriptors) { | |
| const codecTypes = descriptor.types?.codecTypes; | |
| if (!codecTypes?.parameterized) continue; | |
| const parameterized: Record<string, TypeRenderer> = codecTypes!.parameterized; | |
| for (const [codecId, renderer] of Object.entries(parameterized)) { | |
| const existingOwner = owners.get(codecId); | |
| if (existingOwner !== undefined) { | |
| throw new Error( | |
| `Duplicate parameterized renderer for codecId "${codecId}". ` + | |
| `Descriptor "${descriptor.id}" conflicts with "${existingOwner}". ` + | |
| 'Each codecId can only have one renderer.', | |
| ); | |
| } | |
| renderers.set(codecId, normalizeRenderer(codecId, renderer)); | |
| owners.set(codecId, descriptor.id); | |
| } | |
| } |
🤖 Prompt for AI Agents
In @packages/2-sql/3-tooling/family/src/core/assembly.ts around lines 143 - 161,
The code uses optional chaining when reading parameterized after already
validating codecTypes and codecTypes.parameterized; update the assignment of
parameterized to use a non-null assertion instead of optional chaining so it
reflects the prior check (i.e., read codecTypes!.parameterized into the local
parameterized variable) while leaving the surrounding loop, owners, renderers,
and normalizeRenderer usage unchanged.
Part 1 of 6 in the parameterized column types stack.
Adds TypeRenderer types for parameterized codec emission and wires parameterized renderers into the SQL family instance.
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.