# @prisma-next/contract

> Data contract type definitions and JSON schema for Prisma Next

Latest version **0.16.0** (published 2026-07-21) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @prisma-next/contract
pnpm add @prisma-next/contract
yarn add @prisma-next/contract
bun add @prisma-next/contract
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.16.0 |
| Published | 2026-07-21 |
| First published | 2025-12-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=24 |
| Dependencies | 3 |
| Unpacked size | 226.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 414 |
| Maintainers | sevinf, tylerhogarth, aqrln, wmadden-prisma |

## Links

- npm: https://www.npmjs.com/package/@prisma-next/contract
- Repository: https://github.com/prisma/prisma-next
- Homepage: https://github.com/prisma/prisma-next#readme
- Issues: https://github.com/prisma/prisma-next/issues
- npm.io page: https://npm.io/package/@prisma-next/contract

## Dependencies (3)

- [arktype](https://npm.io/package/arktype.md) ^2.2.2
- [@prisma-next/utils](https://npm.io/package/@prisma-next/utils.md) 0.16.0
- [@standard-schema/spec](https://npm.io/package/@standard-schema/spec.md) ^1.1.0

## Recent versions

- 0.16.0 (latest) — 2026-07-21
- 0.16.0-dev.35 (dev) — 2026-08-24
- 0.3.0-pr.112.2 (pr) — 2026-01-13
- 0.16.0-dev.34 — 2026-07-27
- 0.16.0-dev.33 — 2026-07-27
- 0.16.0-dev.32 — 2026-07-27
- 0.16.0-dev.31 — 2026-07-27
- 0.16.0-dev.30 — 2026-07-27
- 0.16.0-dev.29 — 2026-07-27
- 0.16.0-dev.28 — 2026-07-24
- 0.16.0-dev.27 — 2026-07-24
- 0.16.0-dev.26 — 2026-07-24
- 0.16.0-dev.25 — 2026-07-24
- 0.16.0-dev.24 — 2026-07-24
- 0.16.0-dev.23 — 2026-07-24
- … 1109 more at https://npm.io/package/@prisma-next/contract/versions

## README

# @prisma-next/contract

> **Internal package.** This package is an implementation detail of [`prisma-next`](https://www.npmjs.com/package/prisma-next)
> and is published only to support its runtime. Its API is unstable and may change
> without notice. Do not depend on this package directly; install `prisma-next` instead.

Core contract data types and JSON schemas for Prisma Next.

## Overview

This package provides the foundational type definitions for Prisma Next data contracts:

- **Contract data types**: The canonical description of an application's data model and storage layout (`ContractBase`, `DocumentContract`, `Source`, `FieldType`)
- **Plan metadata**: Target-family-agnostic plan metadata (`PlanMeta`). The plan markers themselves (`QueryPlan`, `ExecutionPlan`) live in `@prisma-next/framework-components/runtime`; family-specific plans (`SqlExecutionPlan`, `MongoExecutionPlan`) live in their respective domains. Per [ADR 205](../../../../docs/architecture%20docs/adrs/ADR%20205%20-%20Execution%20metadata%20lives%20on%20AST.md), execution metadata (codec IDs, projection refs, parameter descriptors) lives on the family AST when one is present, not on `PlanMeta`.
- **Hash types**: Branded hash types for storage, execution, and profile hashing (`StorageHashBase`, `ExecutionHashBase`, `ProfileHashBase`)
- **JSON Schemas**: Validation schemas for contract files
- **Type guards**: Runtime type guards for narrowing contract types (`isDocumentContract`)

This package is a **foundation-layer leaf** — it has no framework-domain dependencies and is consumed by all layers above it.

## Usage

```typescript
import type {
  Contract,
  ContractMarkerRecord,
  DocumentContract,
  PlanMeta,
} from '@prisma-next/contract/types';
import { isDocumentContract, coreHash, profileHash } from '@prisma-next/contract/types';

if (isDocumentContract(contract)) {
  const collections = contract.storage.document.collections;
}
```

### JSON Schema Validation

Reference the appropriate JSON schema in your `contract.json` files to enable IDE validation:

```json
{
  "$schema": "node_modules/@prisma-next/contract/schemas/data-contract-document-v1.json",
  "schemaVersion": "1",
  "target": "mongodb",
  "targetFamily": "document",
  "storageHash": "sha256:..."
}
```

For SQL contracts, use `@prisma-next/sql-contract-ts/schema-sql` instead.

## Exports

- `./types`: Contract data types, hash types, plan types, type guards
- `./hashing`: Contract hashing utilities
- `./testing`: Test helpers for creating contract fixtures
- `./validate-contract`: Contract structure validation
- `./validate-domain`: Domain model validation

## Type System

### Column Defaults

- When adding column defaults, re-emit the contract and verify the emitted JSON includes the full default payload.
- Keep `nullable: false` explicit for columns with defaults in emitted contracts.
- Add the corresponding `defaults.*` capability when using function defaults like `autoincrement()` or `now()`.

## Dependencies

- **`@prisma-next/utils`**: Shared utility functions

## Related Subsystems

- [Data Contract](../../../../../docs/architecture%20docs/subsystems/1.%20Data%20Contract.md)
- [Contract Emitter & Types](../../../../../docs/architecture%20docs/subsystems/2.%20Contract%20Emitter%20&%20Types.md)

## Related ADRs

- [ADR 001 - Migrations as Edges](../../../../../docs/architecture%20docs/adrs/ADR%20001%20-%20Migrations%20as%20Edges.md)
- [ADR 004 - Storage Hash vs Profile Hash](../../../../../docs/architecture%20docs/adrs/ADR%20004%20-%20Storage%20Hash%20vs%20Profile%20Hash.md)
- [ADR 010 - Canonicalization Rules](../../../../../docs/architecture%20docs/adrs/ADR%20010%20-%20Canonicalization%20Rules.md)
- [ADR 021 - Contract Marker Storage](../../../../../docs/architecture%20docs/adrs/ADR%20021%20-%20Contract%20Marker%20Storage.md)
- [ADR 185 - SPI types live at the lowest consuming layer](../../../../../docs/architecture%20docs/adrs/ADR%20185%20-%20SPI%20types%20live%20at%20the%20lowest%20consuming%20layer.md)

---
_Source: https://npm.io/package/@prisma-next/contract · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
