@prisma-next/sql-contract-ts 0.3.0-dev.135 → 0.3.0-dev.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -154
- package/dist/config-types.d.mts +2 -2
- package/dist/config-types.d.mts.map +1 -1
- package/dist/config-types.mjs +2 -2
- package/dist/config-types.mjs.map +1 -1
- package/dist/contract-builder.d.mts +192 -236
- package/dist/contract-builder.d.mts.map +1 -1
- package/dist/contract-builder.mjs +317 -422
- package/dist/contract-builder.mjs.map +1 -1
- package/package.json +8 -6
- package/schemas/data-contract-sql-v1.json +6 -6
- package/src/authoring-helper-runtime.ts +2 -2
- package/src/authoring-type-utils.ts +2 -2
- package/src/build-contract.ts +463 -0
- package/src/composed-authoring-helpers.ts +8 -6
- package/src/config-types.ts +3 -3
- package/src/contract-builder.ts +122 -636
- package/src/{semantic-contract.ts → contract-definition.ts} +33 -16
- package/src/{staged-contract-dsl.ts → contract-dsl.ts} +30 -28
- package/src/{staged-contract-lowering.ts → contract-lowering.ts} +46 -48
- package/src/{staged-contract-types.ts → contract-types.ts} +185 -145
- package/src/{staged-contract-warnings.ts → contract-warnings.ts} +18 -21
- package/src/exports/contract-builder.ts +12 -13
- package/src/contract-ir-builder.ts +0 -475
- package/src/contract.ts +0 -475
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @prisma-next/sql-contract-ts
|
|
2
2
|
|
|
3
|
-
**Status:**
|
|
3
|
+
**Status:** Current SQL TypeScript contract authoring surface
|
|
4
4
|
|
|
5
|
-
This package
|
|
5
|
+
This package owns the SQL TypeScript authoring API for Prisma Next.
|
|
6
6
|
|
|
7
7
|
## Package Classification
|
|
8
8
|
|
|
@@ -10,116 +10,118 @@ This package contains the SQL-specific TypeScript contract authoring surface for
|
|
|
10
10
|
- **Layer**: authoring
|
|
11
11
|
- **Plane**: migration
|
|
12
12
|
|
|
13
|
-
**Note**: SQL authoring may depend on SQL core layer (e.g., `@prisma-next/sql-contract/types`) within the same domain.
|
|
14
|
-
|
|
15
13
|
## Overview
|
|
16
14
|
|
|
17
15
|
This package is part of the SQL family namespace (`packages/2-sql/2-authoring/contract-ts`) and provides:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
16
|
+
|
|
17
|
+
- the SQL contract DSL centered on `defineContract(...)`
|
|
18
|
+
- the base structural helpers exported from `./contract-builder`: `field.column(...)`, `field.generated(...)`, `field.namedType(...)`, plus `model(...)` and `rel.*`
|
|
19
|
+
- an optional callback overload that exposes pack-composed helper namespaces such as `field.id.uuidv7()`, `field.text()`, `field.createdAt()`, and `type.enum(...)`
|
|
20
|
+
- lowering from authored model definitions into the canonical SQL `Contract`
|
|
21
|
+
- a SQL contract JSON schema export via `./schema-sql`
|
|
22
22
|
|
|
23
23
|
## Responsibilities
|
|
24
24
|
|
|
25
|
-
- **SQL
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
25
|
+
- **SQL contract authoring**: Build SQL contracts programmatically with type safety
|
|
26
|
+
- **Pack-composed helper vocabulary**: Merge family, target, and extension authoring contributions into the callback helper namespaces
|
|
27
|
+
- **Lowering pipeline**: Turn authored model definitions into the canonical SQL contract artifacts consumed by the rest of the stack
|
|
28
|
+
- **Config helper**: Provide `typescriptContract(...)` for `prisma-next.config.ts`
|
|
29
|
+
- **Schema export**: Publish the SQL JSON schema used by editors and tooling
|
|
30
30
|
|
|
31
31
|
## Package Status
|
|
32
32
|
|
|
33
|
-
This
|
|
33
|
+
This is the current SQL TypeScript authoring implementation. Shared descriptor types live in `@prisma-next/contract-authoring`. Contract validation lives in `@prisma-next/sql-contract/validate`.
|
|
34
34
|
|
|
35
35
|
## Architecture
|
|
36
36
|
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **SQL
|
|
37
|
+
- **Base DSL**: `./contract-builder` exports the stable structural DSL (`defineContract`, `field`, `model`, `rel`)
|
|
38
|
+
- **Composed helper namespaces**: `defineContract(config, (helpers) => ...)` synthesizes `helpers.field.*` and `helpers.type.*` from the selected family, target, and extension packs
|
|
39
|
+
- **SQL resolution and contract generation**: internal resolution normalizes names, relations, indexes, and FK materialization before producing the canonical SQL contract artifacts
|
|
40
|
+
- **Shared descriptor layer**: `@prisma-next/contract-authoring` provides the target-neutral descriptor types used by the DSL and by authoring-adjacent packs
|
|
41
|
+
|
|
42
|
+
Contributor-facing lowering notes and detailed warning semantics live in [DEVELOPING.md](./DEVELOPING.md).
|
|
40
43
|
|
|
41
44
|
```mermaid
|
|
42
45
|
flowchart LR
|
|
43
|
-
builderInput[
|
|
46
|
+
builderInput[TypeScript contract input] --> sqlContractTs[@prisma-next/sql-contract-ts]
|
|
44
47
|
sqlContractTs --> authoringCore[@prisma-next/contract-authoring]
|
|
45
48
|
sqlContractTs --> sqlTypes[@prisma-next/sql-contract/types]
|
|
46
|
-
sqlContractTs -->
|
|
49
|
+
sqlContractTs --> contract[SQL Contract]
|
|
47
50
|
```
|
|
48
51
|
|
|
49
|
-
This package is part of the package layering architecture:
|
|
50
|
-
- **Location**: `packages/2-sql/2-authoring/contract-ts` (SQL family namespace)
|
|
51
|
-
- **Ring**: SQL family namespace (can import from core, authoring, targets, and other SQL family packages)
|
|
52
|
-
|
|
53
52
|
## Exports
|
|
54
53
|
|
|
55
|
-
- `./contract-builder` -
|
|
56
|
-
- `./config-types` -
|
|
54
|
+
- `./contract-builder` - SQL contract DSL (`defineContract`, `field`, `model`, `rel`)
|
|
55
|
+
- `./config-types` - `typescriptContract(...)` config helper
|
|
57
56
|
- `./schema-sql` - SQL contract JSON schema (`data-contract-sql-v1.json`)
|
|
58
57
|
|
|
59
58
|
## Usage
|
|
60
59
|
|
|
61
|
-
###
|
|
60
|
+
### Direct Structural DSL
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
Direct imports expose the base structural helpers. Use this surface when you want to author with explicit column descriptors, explicit generators, or named storage types.
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
- field-level `id()` and `unique()` for the common single-field case
|
|
67
|
-
- portable helper presets such as `field.id.uuidv4()`, `field.id.uuidv7()`, `field.id.nanoid({ size: 16 })`, `field.uuid()`, `field.nanoid({ size: 16 })`, `field.text()`, and `field.createdAt()`
|
|
68
|
-
- field-local `.sql({ column | id | unique })` and belongsTo-local `.sql({ fk })` overlays for one-off storage detail
|
|
69
|
-
- an optional integrated callback form where `defineContract(config, ({ type, field, model, rel }) => ...)` exposes composition-shaped `type.*` and pack-owned `field.*` helper namespaces
|
|
70
|
-
- `.attributes(...)` for compound `id` and compound `unique`
|
|
71
|
-
- optional staged `.relations(...)` for mutually recursive model graphs
|
|
72
|
-
- model-level `.sql(...)` for table naming, indexes, and advanced fallback storage detail
|
|
64
|
+
Built-in ID helpers from `@prisma-next/ids` already return the generated-field spec accepted by `field.generated(...)`, so `field.generated(uuidv4())` is a valid structural DSL call.
|
|
73
65
|
|
|
74
66
|
```typescript
|
|
67
|
+
import { textColumn, timestamptzColumn } from '@prisma-next/adapter-postgres/column-types';
|
|
68
|
+
import sqlFamily from '@prisma-next/family-sql/pack';
|
|
69
|
+
import { uuidv4 } from '@prisma-next/ids';
|
|
75
70
|
import { defineContract, field, model, rel } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
76
71
|
import postgresPack from '@prisma-next/target-postgres/pack';
|
|
77
72
|
|
|
78
73
|
const User = model('User', {
|
|
79
74
|
fields: {
|
|
80
|
-
id: field.
|
|
81
|
-
email: field.
|
|
82
|
-
createdAt: field.
|
|
75
|
+
id: field.generated(uuidv4()).id(),
|
|
76
|
+
email: field.column(textColumn).unique(),
|
|
77
|
+
createdAt: field.column(timestamptzColumn).defaultSql('now()'),
|
|
83
78
|
},
|
|
84
|
-
})
|
|
79
|
+
})
|
|
80
|
+
.relations({
|
|
81
|
+
posts: rel.hasMany('Post', { by: 'userId' }),
|
|
82
|
+
})
|
|
83
|
+
.sql({
|
|
84
|
+
table: 'app_user',
|
|
85
|
+
});
|
|
85
86
|
|
|
86
87
|
const Post = model('Post', {
|
|
87
88
|
fields: {
|
|
88
|
-
id: field.id
|
|
89
|
-
userId: field.
|
|
90
|
-
title: field.
|
|
89
|
+
id: field.generated(uuidv4()).id(),
|
|
90
|
+
userId: field.column(textColumn),
|
|
91
|
+
title: field.column(textColumn),
|
|
91
92
|
},
|
|
92
|
-
})
|
|
93
|
+
})
|
|
94
|
+
.relations({
|
|
95
|
+
user: rel.belongsTo(User, { from: 'userId', to: 'id' }),
|
|
96
|
+
})
|
|
97
|
+
.sql({
|
|
98
|
+
table: 'blog_post',
|
|
99
|
+
});
|
|
93
100
|
|
|
94
101
|
export const contract = defineContract({
|
|
102
|
+
family: sqlFamily,
|
|
95
103
|
target: postgresPack,
|
|
96
104
|
naming: { tables: 'snake_case', columns: 'snake_case' },
|
|
97
105
|
models: {
|
|
98
|
-
User
|
|
99
|
-
|
|
100
|
-
}).sql({
|
|
101
|
-
table: 'app_user',
|
|
102
|
-
}),
|
|
103
|
-
Post: Post.relations({
|
|
104
|
-
user: rel
|
|
105
|
-
.belongsTo(User, { from: 'userId', to: 'id' })
|
|
106
|
-
.sql({ fk: { name: 'blog_post_user_id_fkey', onDelete: 'cascade' } }),
|
|
107
|
-
}).sql({
|
|
108
|
-
table: 'blog_post',
|
|
109
|
-
}),
|
|
106
|
+
User,
|
|
107
|
+
Post,
|
|
110
108
|
},
|
|
111
109
|
});
|
|
112
110
|
```
|
|
113
111
|
|
|
114
|
-
|
|
112
|
+
### Callback Helper Vocabulary
|
|
113
|
+
|
|
114
|
+
Pack-provided helper presets are available through the callback overload. This is the surface that exposes `field.id.*`, `field.text()`, `field.createdAt()`, and `type.*`.
|
|
115
115
|
|
|
116
116
|
```typescript
|
|
117
117
|
import pgvector from '@prisma-next/extension-pgvector/pack';
|
|
118
|
+
import sqlFamily from '@prisma-next/family-sql/pack';
|
|
118
119
|
import { defineContract } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
119
120
|
import postgresPack from '@prisma-next/target-postgres/pack';
|
|
120
121
|
|
|
121
122
|
export const contract = defineContract(
|
|
122
123
|
{
|
|
124
|
+
family: sqlFamily,
|
|
123
125
|
target: postgresPack,
|
|
124
126
|
extensionPacks: { pgvector },
|
|
125
127
|
},
|
|
@@ -135,15 +137,28 @@ export const contract = defineContract(
|
|
|
135
137
|
role: field.namedType(types.Role),
|
|
136
138
|
embedding: field.namedType(types.Embedding1536).optional(),
|
|
137
139
|
},
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const Post = model('Post', {
|
|
143
|
+
fields: {
|
|
144
|
+
id: field.id.uuidv7(),
|
|
145
|
+
authorId: field.uuid(),
|
|
146
|
+
title: field.text(),
|
|
147
|
+
},
|
|
140
148
|
});
|
|
141
149
|
|
|
142
150
|
return {
|
|
143
151
|
types,
|
|
144
152
|
models: {
|
|
145
153
|
User: User.relations({
|
|
146
|
-
posts: rel.hasMany(
|
|
154
|
+
posts: rel.hasMany(Post, { by: 'authorId' }),
|
|
155
|
+
}).sql({
|
|
156
|
+
table: 'user',
|
|
157
|
+
}),
|
|
158
|
+
Post: Post.relations({
|
|
159
|
+
author: rel.belongsTo(User, { from: 'authorId', to: 'id' }),
|
|
160
|
+
}).sql({
|
|
161
|
+
table: 'post',
|
|
147
162
|
}),
|
|
148
163
|
},
|
|
149
164
|
};
|
|
@@ -151,7 +166,9 @@ export const contract = defineContract(
|
|
|
151
166
|
);
|
|
152
167
|
```
|
|
153
168
|
|
|
154
|
-
|
|
169
|
+
### Constraint Placement
|
|
170
|
+
|
|
171
|
+
Single-field constraints are usually most readable inline on the field, while compound constraints live in `.attributes(...)` or model-level `.sql(...)`.
|
|
155
172
|
|
|
156
173
|
```typescript
|
|
157
174
|
const Membership = model('Membership', {
|
|
@@ -172,94 +189,34 @@ const Membership = model('Membership', {
|
|
|
172
189
|
.sql({ table: 'membership' });
|
|
173
190
|
```
|
|
174
191
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
- use `field.id.uuidv4()` or `field.id.uuidv7()` for single-field UUID primary keys with explicit generator choice
|
|
178
|
-
- use `field.id.nanoid({ size })`, `field.id.ulid()`, `field.id.cuid2()`, and `field.id.ksuid()` for other generated primary-key strategies
|
|
179
|
-
- use `field.uuid()` for portable UUID-shaped foreign keys and other scalar fields
|
|
180
|
-
- use `field.nanoid({ size })`, `field.ulid()`, `field.cuid2()`, and `field.ksuid()` when you want those scalar storage shapes without generation
|
|
181
|
-
- use `field.text()`, `field.timestamp()`, and `field.createdAt()` for portable common SQL scalars
|
|
182
|
-
- use `field.sql({ column | id | unique })` and belongsTo-local `.sql({ fk })` when the storage override belongs next to one field or one FK
|
|
183
|
-
- use pack-provided column descriptors with `field.column(...)` when you need target-specific types
|
|
184
|
-
- use generated-column specs with `field.generated(...)` when you want explicit generator control
|
|
185
|
-
- use root `types` directly with `field.namedType(types.Role)` for `storage.types` references
|
|
186
|
-
- `field.namedType('Role')` still works as a fallback, but when `types.Role` exists in the same contract the builder emits `PN_CONTRACT_TYPED_FALLBACK_AVAILABLE`; prefer `field.namedType(types.Role)` for autocomplete and typed local refs
|
|
187
|
-
- use the callback overload when you want target- and extension-composed `type.*` and pack-owned `field.*` helper autocomplete inside `contract.ts`
|
|
188
|
-
- use named model tokens plus `User.refs.id` or `User.ref('id')` for cross-model foreign-key targets
|
|
189
|
-
- `constraints.ref('Model', 'field')` still works as a fallback, but when the named model token exists in the same contract the builder emits `PN_CONTRACT_TYPED_FALLBACK_AVAILABLE`; prefer `User.refs.id`-style refs for autocomplete and typed model refs
|
|
190
|
-
- string relation targets such as `rel.belongsTo('User', ...)`, `rel.hasMany('Post', ...)`, and `rel.manyToMany('Tag', { through: 'PostTag', ... })` still work, but when named model tokens exist in the same contract the builder emits `PN_CONTRACT_TYPED_FALLBACK_AVAILABLE`; prefer model tokens so cross-model authoring stays typed end-to-end
|
|
191
|
-
- use inline `.id()` for single-field identity and `.attributes(({ fields, constraints }) => ({ id: constraints.id([...]) }))` for compound identity
|
|
192
|
-
- use inline `.unique()` for single-field uniqueness and `.attributes(({ fields, constraints }) => ({ uniques: [constraints.unique([...])] }))` for compound uniqueness
|
|
193
|
-
- duplicate named primary keys, uniques, indexes, and foreign keys are rejected during build/validation instead of silently overriding each other
|
|
194
|
-
|
|
195
|
-
#### Legacy Chain Builder
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
import { defineContract } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
199
|
-
import postgresPack from '@prisma-next/target-postgres/pack';
|
|
200
|
-
import pgvector from '@prisma-next/extension-pgvector/pack';
|
|
201
|
-
import { enumColumn, enumType, int4Column, textColumn } from '@prisma-next/adapter-postgres/column-types';
|
|
202
|
-
|
|
203
|
-
const contract = defineContract()
|
|
204
|
-
.target(postgresPack)
|
|
205
|
-
.extensionPacks({ pgvector })
|
|
206
|
-
.storageType('Role', enumType('role', ['USER', 'ADMIN']))
|
|
207
|
-
.table('user', (t) =>
|
|
208
|
-
t
|
|
209
|
-
.column('id', { type: int4Column, nullable: false })
|
|
210
|
-
.column('email', { type: textColumn, nullable: false })
|
|
211
|
-
.column('role', { type: enumColumn('Role', 'role') })
|
|
212
|
-
.primaryKey(['id'], 'user_pkey') // Named primary key
|
|
213
|
-
.unique(['email'], 'user_email_unique') // Named unique constraint
|
|
214
|
-
.index(['email'], 'user_email_idx'), // Named index
|
|
215
|
-
)
|
|
216
|
-
.table('post', (t) =>
|
|
217
|
-
t
|
|
218
|
-
.column('id', { type: int4Column, nullable: false })
|
|
219
|
-
.column('userId', { type: int4Column, nullable: false })
|
|
220
|
-
.column('title', { type: textColumn, nullable: false })
|
|
221
|
-
.primaryKey(['id'])
|
|
222
|
-
.foreignKey(['userId'], { table: 'user', columns: ['id'] }, 'post_userId_fkey'), // Named FK
|
|
223
|
-
)
|
|
224
|
-
.model('User', 'user', (m) => m.field('id', 'id').field('email', 'email'))
|
|
225
|
-
.model('Post', 'post', (m) => m.field('id', 'id').field('userId', 'userId').field('title', 'title'))
|
|
226
|
-
.foreignKeys({ constraints: true, indexes: false }) // Optional FK config
|
|
227
|
-
.build();
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
#### Table Builder Methods
|
|
231
|
-
|
|
232
|
-
The table builder supports the following constraint methods:
|
|
192
|
+
### Helper Notes
|
|
233
193
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
| `.foreignKey(columns, references, name?)` | Add foreign key with optional name |
|
|
194
|
+
- Structural helpers: `field.column(...)`, `field.generated(...)`, `field.namedType(...)`, plus `model(...)` and `rel.*`
|
|
195
|
+
- Callback helper presets: `field.id.uuidv4()`, `field.id.uuidv7()`, `field.id.nanoid({ size })`, `field.uuid()`, `field.text()`, `field.timestamp()`, `field.createdAt()`, and `type.*`
|
|
196
|
+
- Keep field-local and FK-local storage overrides next to the authoring site with `field.sql(...)` and `rel.belongsTo(...).sql({ fk })`
|
|
197
|
+
- Prefer typed local refs such as `field.namedType(types.Role)`, `User.refs.id`, and `User.ref('id')` when those tokens are available
|
|
198
|
+
- See [API.md](./API.md) for generated-field spec semantics, validation rules, and typed-reference warning behavior
|
|
240
199
|
|
|
241
|
-
|
|
200
|
+
### Foreign Key Defaults
|
|
242
201
|
|
|
243
|
-
|
|
202
|
+
Use the root-level `foreignKeyDefaults` option when a contract wants non-default FK materialization:
|
|
244
203
|
|
|
245
204
|
```typescript
|
|
246
|
-
const contract = defineContract
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
205
|
+
const contract = defineContract({
|
|
206
|
+
family: sqlFamily,
|
|
207
|
+
target: postgresPack,
|
|
208
|
+
foreignKeyDefaults: { constraint: true, index: false },
|
|
209
|
+
models: {
|
|
210
|
+
// ...
|
|
211
|
+
},
|
|
212
|
+
});
|
|
251
213
|
```
|
|
252
214
|
|
|
253
|
-
|
|
254
|
-
|--------|---------|-------------|
|
|
255
|
-
| `constraints` | `true` | Emit `FOREIGN KEY` constraints in DDL |
|
|
256
|
-
| `indexes` | `true` | Emit FK-backing indexes (e.g., `CREATE INDEX ... ON post (user_id)`) |
|
|
257
|
-
|
|
258
|
-
When `.foreignKeys()` is not called, defaults to `{ constraints: true, indexes: true }`. See [ADR 161](../../../docs/architecture%20docs/adrs/ADR%20161%20-%20Explicit%20foreign%20key%20constraint%20and%20index%20configuration.md).
|
|
215
|
+
Per-FK overrides still live next to the FK authoring site, either via `constraints.foreignKey(...)` inside model `.sql(...)` or via `rel.belongsTo(...).sql({ fk: ... })`. See [ADR 161](../../../../docs/architecture%20docs/adrs/ADR%20161%20-%20Explicit%20foreign%20key%20constraint%20and%20index%20configuration.md).
|
|
259
216
|
|
|
260
217
|
### Validating Contracts
|
|
261
218
|
|
|
262
|
-
Contract JSON validation
|
|
219
|
+
Contract JSON validation lives in `@prisma-next/sql-contract/validate`, while this package focuses on authoring and lowering.
|
|
263
220
|
|
|
264
221
|
```typescript
|
|
265
222
|
import { validateContract } from '@prisma-next/sql-contract/validate';
|
|
@@ -278,34 +235,30 @@ import { typescriptContract } from '@prisma-next/sql-contract-ts/config-types';
|
|
|
278
235
|
import { contract } from './src/prisma/contract';
|
|
279
236
|
|
|
280
237
|
export default defineConfig({
|
|
281
|
-
// ...
|
|
282
238
|
contract: typescriptContract(contract, 'src/prisma/contract.json'),
|
|
283
239
|
});
|
|
284
240
|
```
|
|
285
241
|
|
|
286
242
|
## Dependencies
|
|
287
243
|
|
|
288
|
-
- **`@prisma-next/
|
|
289
|
-
- **`@prisma-next/contract`** -
|
|
290
|
-
- **`@prisma-next/
|
|
291
|
-
- **`@prisma-next/sql-contract`** - SQL contract types
|
|
292
|
-
- **`arktype`** - Runtime validation
|
|
293
|
-
- **`ts-toolbelt`** - Type utilities
|
|
244
|
+
- **`@prisma-next/config`** - `ContractConfig` types used by `typescriptContract(...)`
|
|
245
|
+
- **`@prisma-next/contract-authoring`** - Shared descriptor types
|
|
246
|
+
- **`@prisma-next/framework-components`** - Pack refs, authoring contributions, and codec lookup types
|
|
247
|
+
- **`@prisma-next/sql-contract`** - SQL contract types and validation target
|
|
294
248
|
|
|
295
249
|
## Testing
|
|
296
250
|
|
|
297
|
-
|
|
251
|
+
Unit tests for the authoring DSL live in this package. Broader integration tests that span authoring, emission, CLI, and runtime packages live in `@prisma-next/integration-tests`.
|
|
298
252
|
|
|
299
253
|
## Migration Notes
|
|
300
254
|
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
- **Phase 2 Complete**: The target-agnostic core has been extracted to `@prisma-next/contract-authoring`. This package composes the generic core with SQL-specific types.
|
|
255
|
+
- Direct imports give you the structural DSL
|
|
256
|
+
- The callback overload gives you pack-composed helper vocabularies
|
|
257
|
+
- Import authoring helpers directly from `@prisma-next/sql-contract-ts`
|
|
258
|
+
- Import validation from `@prisma-next/sql-contract/validate`
|
|
306
259
|
|
|
307
260
|
## See Also
|
|
308
261
|
|
|
309
|
-
- `@prisma-next/contract-authoring` -
|
|
310
|
-
- `@prisma-next/sql-contract-psl` - PSL parser-output to SQL
|
|
311
|
-
- `@prisma-next/sql-contract-psl/provider` - SQL PSL-first `prismaContract()` helper
|
|
262
|
+
- `@prisma-next/contract-authoring` - Shared target-neutral authoring descriptor types
|
|
263
|
+
- `@prisma-next/sql-contract-psl` - PSL parser-output to SQL contract interpreter
|
|
264
|
+
- `@prisma-next/sql-contract-psl/provider` - SQL PSL-first `prismaContract()` helper
|
package/dist/config-types.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
1
2
|
import { ContractConfig, ContractConfig as ContractConfig$1 } from "@prisma-next/config/config-types";
|
|
2
|
-
import { ContractIR } from "@prisma-next/contract/ir";
|
|
3
3
|
|
|
4
4
|
//#region src/config-types.d.ts
|
|
5
|
-
declare function typescriptContract(
|
|
5
|
+
declare function typescriptContract(contract: Contract, output?: string): ContractConfig$1;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { type ContractConfig, typescriptContract };
|
|
8
8
|
//# sourceMappingURL=config-types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;iBAKgB,kBAAA,
|
|
1
|
+
{"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"sourcesContent":[],"mappings":";;;;iBAKgB,kBAAA,WAA6B,4BAA4B"}
|
package/dist/config-types.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { ifDefined } from "@prisma-next/utils/defined";
|
|
|
2
2
|
import { ok } from "@prisma-next/utils/result";
|
|
3
3
|
|
|
4
4
|
//#region src/config-types.ts
|
|
5
|
-
function typescriptContract(
|
|
5
|
+
function typescriptContract(contract, output) {
|
|
6
6
|
return {
|
|
7
|
-
source: async (_context) => ok(
|
|
7
|
+
source: async (_context) => ok(contract),
|
|
8
8
|
...ifDefined("output", output)
|
|
9
9
|
};
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import type { ContractConfig } from '@prisma-next/config/config-types';\nimport type {
|
|
1
|
+
{"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import type { ContractConfig } from '@prisma-next/config/config-types';\nimport type { Contract } from '@prisma-next/contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\n\nexport function typescriptContract(contract: Contract, output?: string): ContractConfig {\n return {\n source: async (_context) => ok(contract),\n ...ifDefined('output', output),\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,mBAAmB,UAAoB,QAAiC;AACtF,QAAO;EACL,QAAQ,OAAO,aAAa,GAAG,SAAS;EACxC,GAAG,UAAU,UAAU,OAAO;EAC/B"}
|