@prisma-next/contract 0.3.0-dev.33 → 0.3.0-dev.35
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 +26 -5
- package/dist/framework-components.d.mts +529 -2
- package/dist/framework-components.d.mts.map +1 -0
- package/dist/framework-components.mjs.map +1 -1
- package/dist/{ir-B8zNqals.d.mts → ir-C9rRU5WS.d.mts} +14 -9
- package/dist/ir-C9rRU5WS.d.mts.map +1 -0
- package/dist/ir.d.mts +1 -1
- package/dist/ir.mjs +9 -4
- package/dist/ir.mjs.map +1 -1
- package/dist/types-BJr2H3qm.d.mts +377 -0
- package/dist/types-BJr2H3qm.d.mts.map +1 -0
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +7 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +8 -4
- package/schemas/data-contract-document-v1.json +9 -4
- package/src/exports/framework-components.ts +0 -1
- package/src/exports/types.ts +12 -9
- package/src/framework-components.ts +6 -68
- package/src/ir.ts +25 -9
- package/src/types.ts +107 -36
- package/dist/framework-components-CLCmcNJY.d.mts +0 -857
- package/dist/framework-components-CLCmcNJY.d.mts.map +0 -1
- package/dist/ir-B8zNqals.d.mts.map +0 -1
- package/dist/pack-manifest-types.d.mts +0 -2
- package/dist/pack-manifest-types.mjs +0 -1
- package/src/exports/pack-manifest-types.ts +0 -6
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ This package provides the foundational type definitions for Prisma Next, includi
|
|
|
14
14
|
- **Core Contract Types**: Defines framework-level contract types (`ContractBase`, `Source`, `FamilyInstance`) that are shared across all target families
|
|
15
15
|
- **Framework Component Model**: Provides base descriptor interfaces (`FamilyDescriptor`, `TargetDescriptor`, `AdapterDescriptor`, `DriverDescriptor`, `ExtensionDescriptor`) and identity instance bases (`FamilyInstance`, `TargetInstance`, `AdapterInstance`, `DriverInstance`, `ExtensionInstance`) that plane-specific types extend
|
|
16
16
|
- **Document Family Types**: Provides TypeScript types for document target family contracts (`DocumentContract`)
|
|
17
|
+
- **Shared Column Defaults**: Defines `ColumnDefault` for db-agnostic defaults (literal and function) reused across family contracts and authoring builders
|
|
17
18
|
- **JSON Schema Validation**: Provides JSON Schemas for validating contract structure in IDEs and tooling
|
|
18
19
|
- **Type Guards**: Provides runtime type guards for narrowing contract types (`isDocumentContract`)
|
|
19
20
|
- **Emitter Types**: Defines emitter SPI types (`TargetFamilyHook`, `ValidationContext`, `TypesImportSpec`) that are shared between emitter and control plane
|
|
@@ -54,7 +55,7 @@ function processContract(contract: DocumentContract) {
|
|
|
54
55
|
|
|
55
56
|
// Use ContractMarkerRecord for database marker operations
|
|
56
57
|
function processMarker(marker: ContractMarkerRecord) {
|
|
57
|
-
console.log(marker.
|
|
58
|
+
console.log(marker.storageHash, marker.profileHash);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
// Use emitter types for implementing family hooks
|
|
@@ -149,7 +150,7 @@ For document targets (MongoDB, Firestore, etc.):
|
|
|
149
150
|
"schemaVersion": "1",
|
|
150
151
|
"target": "mongodb",
|
|
151
152
|
"targetFamily": "document",
|
|
152
|
-
"
|
|
153
|
+
"storageHash": "sha256:...",
|
|
153
154
|
"storage": {
|
|
154
155
|
"document": {
|
|
155
156
|
"collections": {
|
|
@@ -174,7 +175,7 @@ For document targets (MongoDB, Firestore, etc.):
|
|
|
174
175
|
"schemaVersion": "1",
|
|
175
176
|
"target": "postgres",
|
|
176
177
|
"targetFamily": "sql",
|
|
177
|
-
"
|
|
178
|
+
"storageHash": "sha256:...",
|
|
178
179
|
"storage": {
|
|
179
180
|
"tables": {
|
|
180
181
|
"user": {
|
|
@@ -207,7 +208,8 @@ All contracts share these common fields:
|
|
|
207
208
|
- **`schemaVersion`** (required): Contract schema version (currently `"1"`)
|
|
208
209
|
- **`target`** (required): Database target identifier (e.g., `"postgres"`, `"mongo"`, `"firestore"`)
|
|
209
210
|
- **`targetFamily`** (required): Target family classification (`"document"` for document contracts)
|
|
210
|
-
- **`
|
|
211
|
+
- **`storageHash`** (required): SHA-256 hash of the storage schema structure
|
|
212
|
+
- **`executionHash`** (optional): SHA-256 hash of execution-time mutation defaults
|
|
211
213
|
- **`profileHash`** (optional): SHA-256 hash of the capability profile
|
|
212
214
|
- **`capabilities`** (optional): Capability flags declared by the contract
|
|
213
215
|
- **`extensionPacks`** (optional): Extension packs and their configuration
|
|
@@ -219,11 +221,30 @@ All contracts share these common fields:
|
|
|
219
221
|
- **`storage.document.collections`**: Object mapping collection names to collection definitions
|
|
220
222
|
- Each collection includes:
|
|
221
223
|
- **`name`**: Logical collection name
|
|
222
|
-
- **`id`** (optional): ID generation strategy (`auto`, `client`, `uuid`, `
|
|
224
|
+
- **`id`** (optional): ID generation strategy (`auto`, `client`, `uuid`, `objectId`)
|
|
223
225
|
- **`fields`**: Field definitions using `FieldType` (supports nested objects and arrays)
|
|
224
226
|
- **`indexes`** (optional): Array of index definitions with keys and optional predicates
|
|
225
227
|
- **`readOnly`** (optional): Whether mutations are disallowed
|
|
226
228
|
|
|
229
|
+
## Column Defaults
|
|
230
|
+
|
|
231
|
+
### Key Points
|
|
232
|
+
|
|
233
|
+
- When adding column defaults, re-emit the contract and verify the emitted JSON includes the full default payload.
|
|
234
|
+
- Keep `nullable: false` explicit for columns with defaults in emitted contracts.
|
|
235
|
+
- Literal defaults must include a `value` in the emitted contract; avoid falsey literals unless the emitter preserves them.
|
|
236
|
+
- Add the corresponding `defaults.*` capability when using function defaults like `autoincrement()` or `now()`.
|
|
237
|
+
|
|
238
|
+
### CLI Output: Tree vs JSON
|
|
239
|
+
|
|
240
|
+
Column defaults are handled differently depending on output format:
|
|
241
|
+
|
|
242
|
+
- **Tree output** (`db introspect`): Labels show only type and nullability, e.g. `id: int4 (not nullable)`. Defaults are omitted from labels to keep tree output concise.
|
|
243
|
+
- **JSON output** (`db introspect --json`): Full default information is preserved in the schema IR.
|
|
244
|
+
- **Programmatic access**: Defaults are always available in `SchemaTreeNode.meta.default` for tooling that needs them.
|
|
245
|
+
|
|
246
|
+
This separation keeps human-readable tree output clean while preserving full data for automation.
|
|
247
|
+
|
|
227
248
|
## Type System
|
|
228
249
|
|
|
229
250
|
### Type Guards
|
|
@@ -1,2 +1,529 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { M as TypesImportSpec, w as RenderTypeContext } from "./types-BJr2H3qm.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/framework-components.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A template-based type renderer (structured form).
|
|
7
|
+
* Uses mustache-style placeholders (e.g., `Vector<{{length}}>`) that are
|
|
8
|
+
* replaced with typeParams values during rendering.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* { kind: 'template', template: 'Vector<{{length}}>' }
|
|
13
|
+
* // With typeParams { length: 1536 }, renders: 'Vector<1536>'
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
interface TypeRendererTemplate {
|
|
17
|
+
readonly kind: 'template';
|
|
18
|
+
/** Template string with `{{key}}` placeholders for typeParams values */
|
|
19
|
+
readonly template: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A function-based type renderer for full control over type expression generation.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* {
|
|
27
|
+
* kind: 'function',
|
|
28
|
+
* render: (params, ctx) => `Vector<${params.length}>`
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
interface TypeRendererFunction {
|
|
33
|
+
readonly kind: 'function';
|
|
34
|
+
/** Render function that produces a TypeScript type expression */
|
|
35
|
+
readonly render: (params: Record<string, unknown>, ctx: RenderTypeContext) => string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A raw template string type renderer (convenience form).
|
|
39
|
+
* Shorthand for TypeRendererTemplate - just the template string without wrapper.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* 'Vector<{{length}}>'
|
|
44
|
+
* // Equivalent to: { kind: 'template', template: 'Vector<{{length}}>' }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
type TypeRendererString = string;
|
|
48
|
+
/**
|
|
49
|
+
* A raw function type renderer (convenience form).
|
|
50
|
+
* Shorthand for TypeRendererFunction - just the function without wrapper.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* (params, ctx) => `Vector<${params.length}>`
|
|
55
|
+
* // Equivalent to: { kind: 'function', render: ... }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
type TypeRendererRawFunction = (params: Record<string, unknown>, ctx: RenderTypeContext) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Union of type renderer formats.
|
|
61
|
+
*
|
|
62
|
+
* Supports both structured forms (with `kind` discriminator) and convenience forms:
|
|
63
|
+
* - `string` - Template string with `{{key}}` placeholders (manifest-safe, JSON-serializable)
|
|
64
|
+
* - `function` - Render function for full control (requires runtime execution)
|
|
65
|
+
* - `{ kind: 'template', template: string }` - Structured template form
|
|
66
|
+
* - `{ kind: 'function', render: fn }` - Structured function form
|
|
67
|
+
*
|
|
68
|
+
* Templates are normalized to functions during pack assembly.
|
|
69
|
+
* **Prefer template strings** for most cases - they are JSON-serializable.
|
|
70
|
+
*/
|
|
71
|
+
type TypeRenderer = TypeRendererString | TypeRendererRawFunction | TypeRendererTemplate | TypeRendererFunction;
|
|
72
|
+
/**
|
|
73
|
+
* Normalized type renderer - always a function after assembly.
|
|
74
|
+
* This is the form received by the emitter.
|
|
75
|
+
*/
|
|
76
|
+
interface NormalizedTypeRenderer {
|
|
77
|
+
readonly codecId: string;
|
|
78
|
+
readonly render: (params: Record<string, unknown>, ctx: RenderTypeContext) => string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Interpolates a template string with params values.
|
|
82
|
+
* Used internally by normalizeRenderer to compile templates to functions.
|
|
83
|
+
*
|
|
84
|
+
* @throws Error if a placeholder key is not found in params (except 'CodecTypes')
|
|
85
|
+
*/
|
|
86
|
+
declare function interpolateTypeTemplate(template: string, params: Record<string, unknown>, ctx: RenderTypeContext): string;
|
|
87
|
+
/**
|
|
88
|
+
* Normalizes a TypeRenderer to function form.
|
|
89
|
+
* Called during pack assembly, not at emission time.
|
|
90
|
+
*
|
|
91
|
+
* Handles all TypeRenderer forms:
|
|
92
|
+
* - Raw string template: `'Vector<{{length}}>'`
|
|
93
|
+
* - Raw function: `(params, ctx) => ...`
|
|
94
|
+
* - Structured template: `{ kind: 'template', template: '...' }`
|
|
95
|
+
* - Structured function: `{ kind: 'function', render: fn }`
|
|
96
|
+
*/
|
|
97
|
+
declare function normalizeRenderer(codecId: string, renderer: TypeRenderer): NormalizedTypeRenderer;
|
|
98
|
+
/**
|
|
99
|
+
* Declarative fields that describe component metadata.
|
|
100
|
+
*/
|
|
101
|
+
interface ComponentMetadata {
|
|
102
|
+
/** Component version (semver) */
|
|
103
|
+
readonly version: string;
|
|
104
|
+
/**
|
|
105
|
+
* Capabilities this component provides.
|
|
106
|
+
*
|
|
107
|
+
* For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into
|
|
108
|
+
* the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);
|
|
109
|
+
* keep these declarations in sync. Targets are identifiers/descriptors and typically do not
|
|
110
|
+
* declare capabilities.
|
|
111
|
+
*/
|
|
112
|
+
readonly capabilities?: Record<string, unknown>;
|
|
113
|
+
/** Type imports for contract.d.ts generation */
|
|
114
|
+
readonly types?: {
|
|
115
|
+
readonly codecTypes?: {
|
|
116
|
+
/**
|
|
117
|
+
* Base codec types import spec.
|
|
118
|
+
* Optional: adapters typically provide this, extensions usually don't.
|
|
119
|
+
*/
|
|
120
|
+
readonly import?: TypesImportSpec;
|
|
121
|
+
/**
|
|
122
|
+
* Optional renderers for parameterized codecs owned by this component.
|
|
123
|
+
* Key is codecId (e.g., 'pg/vector@1'), value is the type renderer.
|
|
124
|
+
*
|
|
125
|
+
* Templates are normalized to functions during pack assembly.
|
|
126
|
+
* Duplicate codecId across descriptors is a hard error.
|
|
127
|
+
*/
|
|
128
|
+
readonly parameterized?: Record<string, TypeRenderer>;
|
|
129
|
+
/**
|
|
130
|
+
* Optional additional type-only imports required by parameterized renderers.
|
|
131
|
+
*
|
|
132
|
+
* These imports are included in generated `contract.d.ts` but are NOT treated as
|
|
133
|
+
* codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
|
|
134
|
+
*
|
|
135
|
+
* Example: `Vector<N>` for pgvector renderers that emit `Vector<{{length}}>`
|
|
136
|
+
*/
|
|
137
|
+
readonly typeImports?: ReadonlyArray<TypesImportSpec>;
|
|
138
|
+
/**
|
|
139
|
+
* Optional control-plane hooks keyed by codecId.
|
|
140
|
+
* Used by family-specific planners/verifiers to handle storage types.
|
|
141
|
+
*/
|
|
142
|
+
readonly controlPlaneHooks?: Record<string, unknown>;
|
|
143
|
+
};
|
|
144
|
+
readonly operationTypes?: {
|
|
145
|
+
readonly import: TypesImportSpec;
|
|
146
|
+
};
|
|
147
|
+
readonly storage?: ReadonlyArray<{
|
|
148
|
+
readonly typeId: string;
|
|
149
|
+
readonly familyId: string;
|
|
150
|
+
readonly targetId: string;
|
|
151
|
+
readonly nativeType?: string;
|
|
152
|
+
}>;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Base descriptor for any framework component.
|
|
157
|
+
*
|
|
158
|
+
* All component descriptors share these fundamental properties that identify
|
|
159
|
+
* the component and provide its metadata. This interface is extended by
|
|
160
|
+
* specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
|
|
161
|
+
*
|
|
162
|
+
* @template Kind - Discriminator literal identifying the component type.
|
|
163
|
+
* Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',
|
|
164
|
+
* but the type accepts any string to allow ecosystem extensions.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* // All descriptors have these properties
|
|
169
|
+
* descriptor.kind // The Kind type parameter (e.g., 'family', 'target', or custom kinds)
|
|
170
|
+
* descriptor.id // Unique string identifier (e.g., 'sql', 'postgres')
|
|
171
|
+
* descriptor.version // Component version (semver)
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {
|
|
175
|
+
/** Discriminator identifying the component type */
|
|
176
|
+
readonly kind: Kind;
|
|
177
|
+
/** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */
|
|
178
|
+
readonly id: string;
|
|
179
|
+
}
|
|
180
|
+
interface ContractComponentRequirementsCheckInput {
|
|
181
|
+
readonly contract: {
|
|
182
|
+
readonly target: string;
|
|
183
|
+
readonly targetFamily?: string | undefined;
|
|
184
|
+
readonly extensionPacks?: Record<string, unknown> | undefined;
|
|
185
|
+
};
|
|
186
|
+
readonly expectedTargetFamily?: string | undefined;
|
|
187
|
+
readonly expectedTargetId?: string | undefined;
|
|
188
|
+
readonly providedComponentIds: Iterable<string>;
|
|
189
|
+
}
|
|
190
|
+
interface ContractComponentRequirementsCheckResult {
|
|
191
|
+
readonly familyMismatch?: {
|
|
192
|
+
readonly expected: string;
|
|
193
|
+
readonly actual: string;
|
|
194
|
+
} | undefined;
|
|
195
|
+
readonly targetMismatch?: {
|
|
196
|
+
readonly expected: string;
|
|
197
|
+
readonly actual: string;
|
|
198
|
+
} | undefined;
|
|
199
|
+
readonly missingExtensionPackIds: readonly string[];
|
|
200
|
+
}
|
|
201
|
+
declare function checkContractComponentRequirements(input: ContractComponentRequirementsCheckInput): ContractComponentRequirementsCheckResult;
|
|
202
|
+
/**
|
|
203
|
+
* Descriptor for a family component.
|
|
204
|
+
*
|
|
205
|
+
* A "family" represents a category of data sources with shared semantics
|
|
206
|
+
* (e.g., SQL databases, document stores). Families define:
|
|
207
|
+
* - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)
|
|
208
|
+
* - Contract structure (tables vs collections, columns vs fields)
|
|
209
|
+
* - Type system and codecs
|
|
210
|
+
*
|
|
211
|
+
* Families are the top-level grouping. Each family contains multiple targets
|
|
212
|
+
* (e.g., SQL family contains Postgres, MySQL, SQLite targets).
|
|
213
|
+
*
|
|
214
|
+
* Extended by plane-specific descriptors:
|
|
215
|
+
* - `ControlFamilyDescriptor` - adds `hook` for CLI/tooling operations
|
|
216
|
+
* - `RuntimeFamilyDescriptor` - adds runtime-specific factory methods
|
|
217
|
+
*
|
|
218
|
+
* @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```ts
|
|
222
|
+
* import sql from '@prisma-next/family-sql/control';
|
|
223
|
+
*
|
|
224
|
+
* sql.kind // 'family'
|
|
225
|
+
* sql.familyId // 'sql'
|
|
226
|
+
* sql.id // 'sql'
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {
|
|
230
|
+
/** The family identifier (e.g., 'sql', 'document') */
|
|
231
|
+
readonly familyId: TFamilyId;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Descriptor for a target component.
|
|
235
|
+
*
|
|
236
|
+
* A "target" represents a specific database or data store within a family
|
|
237
|
+
* (e.g., Postgres, MySQL, MongoDB). Targets define:
|
|
238
|
+
* - Native type mappings (e.g., Postgres int4 → TypeScript number)
|
|
239
|
+
* - Target-specific capabilities (e.g., RETURNING, LATERAL joins)
|
|
240
|
+
*
|
|
241
|
+
* Targets are bound to a family and provide the target-specific implementation
|
|
242
|
+
* details that adapters and drivers use.
|
|
243
|
+
*
|
|
244
|
+
* Extended by plane-specific descriptors:
|
|
245
|
+
* - `ControlTargetDescriptor` - adds optional `migrations` capability
|
|
246
|
+
* - `RuntimeTargetDescriptor` - adds runtime factory method
|
|
247
|
+
*
|
|
248
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
249
|
+
* @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* import postgres from '@prisma-next/target-postgres/control';
|
|
254
|
+
*
|
|
255
|
+
* postgres.kind // 'target'
|
|
256
|
+
* postgres.familyId // 'sql'
|
|
257
|
+
* postgres.targetId // 'postgres'
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
interface TargetDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'target'> {
|
|
261
|
+
/** The family this target belongs to */
|
|
262
|
+
readonly familyId: TFamilyId;
|
|
263
|
+
/** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
|
|
264
|
+
readonly targetId: TTargetId;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Base shape for any pack reference.
|
|
268
|
+
* Pack refs are pure JSON-friendly objects safe to import in authoring flows.
|
|
269
|
+
*/
|
|
270
|
+
interface PackRefBase<Kind extends string, TFamilyId extends string> extends ComponentMetadata {
|
|
271
|
+
readonly kind: Kind;
|
|
272
|
+
readonly id: string;
|
|
273
|
+
readonly familyId: TFamilyId;
|
|
274
|
+
readonly targetId?: string;
|
|
275
|
+
}
|
|
276
|
+
type TargetPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'target', TFamilyId> & {
|
|
277
|
+
readonly targetId: TTargetId;
|
|
278
|
+
};
|
|
279
|
+
type AdapterPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'adapter', TFamilyId> & {
|
|
280
|
+
readonly targetId: TTargetId;
|
|
281
|
+
};
|
|
282
|
+
type ExtensionPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'extension', TFamilyId> & {
|
|
283
|
+
readonly targetId: TTargetId;
|
|
284
|
+
};
|
|
285
|
+
type DriverPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'driver', TFamilyId> & {
|
|
286
|
+
readonly targetId: TTargetId;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Descriptor for an adapter component.
|
|
290
|
+
*
|
|
291
|
+
* An "adapter" provides the protocol and dialect implementation for a target.
|
|
292
|
+
* Adapters handle:
|
|
293
|
+
* - SQL/query generation (lowering AST to target-specific syntax)
|
|
294
|
+
* - Codec registration (encoding/decoding between JS and wire types)
|
|
295
|
+
* - Type mappings and coercions
|
|
296
|
+
*
|
|
297
|
+
* Adapters are bound to a specific family+target combination and work with
|
|
298
|
+
* any compatible driver for that target.
|
|
299
|
+
*
|
|
300
|
+
* Extended by plane-specific descriptors:
|
|
301
|
+
* - `ControlAdapterDescriptor` - control-plane factory
|
|
302
|
+
* - `RuntimeAdapterDescriptor` - runtime factory
|
|
303
|
+
*
|
|
304
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
305
|
+
* @template TTargetId - Literal type for the target identifier
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* import postgresAdapter from '@prisma-next/adapter-postgres/control';
|
|
310
|
+
*
|
|
311
|
+
* postgresAdapter.kind // 'adapter'
|
|
312
|
+
* postgresAdapter.familyId // 'sql'
|
|
313
|
+
* postgresAdapter.targetId // 'postgres'
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'adapter'> {
|
|
317
|
+
/** The family this adapter belongs to */
|
|
318
|
+
readonly familyId: TFamilyId;
|
|
319
|
+
/** The target this adapter is designed for */
|
|
320
|
+
readonly targetId: TTargetId;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Descriptor for a driver component.
|
|
324
|
+
*
|
|
325
|
+
* A "driver" provides the connection and execution layer for a target.
|
|
326
|
+
* Drivers handle:
|
|
327
|
+
* - Connection management (pooling, timeouts, retries)
|
|
328
|
+
* - Query execution (sending SQL/commands, receiving results)
|
|
329
|
+
* - Transaction management
|
|
330
|
+
* - Wire protocol communication
|
|
331
|
+
*
|
|
332
|
+
* Drivers are bound to a specific family+target and work with any compatible
|
|
333
|
+
* adapter. Multiple drivers can exist for the same target (e.g., node-postgres
|
|
334
|
+
* vs postgres.js for Postgres).
|
|
335
|
+
*
|
|
336
|
+
* Extended by plane-specific descriptors:
|
|
337
|
+
* - `ControlDriverDescriptor` - creates driver from connection URL
|
|
338
|
+
* - `RuntimeDriverDescriptor` - creates driver with runtime options
|
|
339
|
+
*
|
|
340
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
341
|
+
* @template TTargetId - Literal type for the target identifier
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* import postgresDriver from '@prisma-next/driver-postgres/control';
|
|
346
|
+
*
|
|
347
|
+
* postgresDriver.kind // 'driver'
|
|
348
|
+
* postgresDriver.familyId // 'sql'
|
|
349
|
+
* postgresDriver.targetId // 'postgres'
|
|
350
|
+
* ```
|
|
351
|
+
*/
|
|
352
|
+
interface DriverDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'driver'> {
|
|
353
|
+
/** The family this driver belongs to */
|
|
354
|
+
readonly familyId: TFamilyId;
|
|
355
|
+
/** The target this driver connects to */
|
|
356
|
+
readonly targetId: TTargetId;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Descriptor for an extension component.
|
|
360
|
+
*
|
|
361
|
+
* An "extension" adds optional capabilities to a target. Extensions can provide:
|
|
362
|
+
* - Additional operations (e.g., vector similarity search with pgvector)
|
|
363
|
+
* - Custom types and codecs (e.g., vector type)
|
|
364
|
+
* - Extended query capabilities
|
|
365
|
+
*
|
|
366
|
+
* Extensions are bound to a specific family+target and are registered in the
|
|
367
|
+
* config alongside the core components. Multiple extensions can be used together.
|
|
368
|
+
*
|
|
369
|
+
* Extended by plane-specific descriptors:
|
|
370
|
+
* - `ControlExtensionDescriptor` - control-plane extension factory
|
|
371
|
+
* - `RuntimeExtensionDescriptor` - runtime extension factory
|
|
372
|
+
*
|
|
373
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
374
|
+
* @template TTargetId - Literal type for the target identifier
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```ts
|
|
378
|
+
* import pgvector from '@prisma-next/extension-pgvector/control';
|
|
379
|
+
*
|
|
380
|
+
* pgvector.kind // 'extension'
|
|
381
|
+
* pgvector.familyId // 'sql'
|
|
382
|
+
* pgvector.targetId // 'postgres'
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'extension'> {
|
|
386
|
+
/** The family this extension belongs to */
|
|
387
|
+
readonly familyId: TFamilyId;
|
|
388
|
+
/** The target this extension is designed for */
|
|
389
|
+
readonly targetId: TTargetId;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Union type for target-bound component descriptors.
|
|
393
|
+
*
|
|
394
|
+
* Target-bound components are those that must be compatible with a specific
|
|
395
|
+
* family+target combination. This includes targets, adapters, drivers, and
|
|
396
|
+
* extensions. Families are not target-bound.
|
|
397
|
+
*
|
|
398
|
+
* This type is used in migration and verification interfaces to enforce
|
|
399
|
+
* type-level compatibility between components.
|
|
400
|
+
*
|
|
401
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
402
|
+
* @template TTargetId - Literal type for the target identifier
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```ts
|
|
406
|
+
* // All these components must have matching familyId and targetId
|
|
407
|
+
* const components: TargetBoundComponentDescriptor<'sql', 'postgres'>[] = [
|
|
408
|
+
* postgresTarget,
|
|
409
|
+
* postgresAdapter,
|
|
410
|
+
* postgresDriver,
|
|
411
|
+
* pgvectorExtension,
|
|
412
|
+
* ];
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends string> = TargetDescriptor<TFamilyId, TTargetId> | AdapterDescriptor<TFamilyId, TTargetId> | DriverDescriptor<TFamilyId, TTargetId> | ExtensionDescriptor<TFamilyId, TTargetId>;
|
|
416
|
+
/**
|
|
417
|
+
* Base interface for family instances.
|
|
418
|
+
*
|
|
419
|
+
* A family instance is created by a family descriptor's `create()` method.
|
|
420
|
+
* This base interface carries only the identity; plane-specific interfaces
|
|
421
|
+
* add domain actions (e.g., `emitContract`, `verify` on ControlFamilyInstance).
|
|
422
|
+
*
|
|
423
|
+
* @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```ts
|
|
427
|
+
* const instance = sql.create({ target, adapter, driver, extensions });
|
|
428
|
+
* instance.familyId // 'sql'
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
interface FamilyInstance<TFamilyId extends string> {
|
|
432
|
+
/** The family identifier (e.g., 'sql', 'document') */
|
|
433
|
+
readonly familyId: TFamilyId;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Base interface for target instances.
|
|
437
|
+
*
|
|
438
|
+
* A target instance is created by a target descriptor's `create()` method.
|
|
439
|
+
* This base interface carries only the identity; plane-specific interfaces
|
|
440
|
+
* add target-specific behavior.
|
|
441
|
+
*
|
|
442
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
443
|
+
* @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* const instance = postgres.create();
|
|
448
|
+
* instance.familyId // 'sql'
|
|
449
|
+
* instance.targetId // 'postgres'
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
interface TargetInstance<TFamilyId extends string, TTargetId extends string> {
|
|
453
|
+
/** The family this target belongs to */
|
|
454
|
+
readonly familyId: TFamilyId;
|
|
455
|
+
/** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
|
|
456
|
+
readonly targetId: TTargetId;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Base interface for adapter instances.
|
|
460
|
+
*
|
|
461
|
+
* An adapter instance is created by an adapter descriptor's `create()` method.
|
|
462
|
+
* This base interface carries only the identity; plane-specific interfaces
|
|
463
|
+
* add adapter-specific behavior (e.g., codec registration, query lowering).
|
|
464
|
+
*
|
|
465
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
466
|
+
* @template TTargetId - Literal type for the target identifier
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```ts
|
|
470
|
+
* const instance = postgresAdapter.create();
|
|
471
|
+
* instance.familyId // 'sql'
|
|
472
|
+
* instance.targetId // 'postgres'
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {
|
|
476
|
+
/** The family this adapter belongs to */
|
|
477
|
+
readonly familyId: TFamilyId;
|
|
478
|
+
/** The target this adapter is designed for */
|
|
479
|
+
readonly targetId: TTargetId;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Base interface for driver instances.
|
|
483
|
+
*
|
|
484
|
+
* A driver instance is created by a driver descriptor's `create()` method.
|
|
485
|
+
* This base interface carries only the identity; plane-specific interfaces
|
|
486
|
+
* add driver-specific behavior (e.g., `query`, `close` on ControlDriverInstance).
|
|
487
|
+
*
|
|
488
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
489
|
+
* @template TTargetId - Literal type for the target identifier
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```ts
|
|
493
|
+
* const instance = postgresDriver.create({ databaseUrl });
|
|
494
|
+
* instance.familyId // 'sql'
|
|
495
|
+
* instance.targetId // 'postgres'
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
interface DriverInstance<TFamilyId extends string, TTargetId extends string> {
|
|
499
|
+
/** The family this driver belongs to */
|
|
500
|
+
readonly familyId: TFamilyId;
|
|
501
|
+
/** The target this driver connects to */
|
|
502
|
+
readonly targetId: TTargetId;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Base interface for extension instances.
|
|
506
|
+
*
|
|
507
|
+
* An extension instance is created by an extension descriptor's `create()` method.
|
|
508
|
+
* This base interface carries only the identity; plane-specific interfaces
|
|
509
|
+
* add extension-specific behavior.
|
|
510
|
+
*
|
|
511
|
+
* @template TFamilyId - Literal type for the family identifier
|
|
512
|
+
* @template TTargetId - Literal type for the target identifier
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```ts
|
|
516
|
+
* const instance = pgvector.create();
|
|
517
|
+
* instance.familyId // 'sql'
|
|
518
|
+
* instance.targetId // 'postgres'
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {
|
|
522
|
+
/** The family this extension belongs to */
|
|
523
|
+
readonly familyId: TFamilyId;
|
|
524
|
+
/** The target this extension is designed for */
|
|
525
|
+
readonly targetId: TTargetId;
|
|
526
|
+
}
|
|
527
|
+
//#endregion
|
|
528
|
+
export { type AdapterDescriptor, type AdapterInstance, type AdapterPackRef, type ComponentDescriptor, type ComponentMetadata, type ContractComponentRequirementsCheckInput, type ContractComponentRequirementsCheckResult, type DriverDescriptor, type DriverInstance, type DriverPackRef, type ExtensionDescriptor, type ExtensionInstance, type ExtensionPackRef, type FamilyDescriptor, type FamilyInstance, type NormalizedTypeRenderer, type PackRefBase, type TargetBoundComponentDescriptor, type TargetDescriptor, type TargetInstance, type TargetPackRef, type TypeRenderer, type TypeRendererFunction, type TypeRendererTemplate, checkContractComponentRequirements, interpolateTypeTemplate, normalizeRenderer };
|
|
529
|
+
//# sourceMappingURL=framework-components.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-components.d.mts","names":[],"sources":["../src/framework-components.ts"],"sourcesContent":[],"mappings":";;;;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