@prisma-next/contract 0.3.0-dev.4 → 0.3.0-dev.40

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 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.coreHash, marker.profileHash);
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
- "coreHash": "sha256:...",
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
- "coreHash": "sha256:...",
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
- - **`coreHash`** (required): SHA-256 hash of the core schema structure
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`, `cuid`, `objectId`)
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,40 +1,156 @@
1
- import { TypesImportSpec, OperationManifest } from './types.js';
2
- import '@prisma-next/operations';
3
- import './ir.js';
1
+ import { M as TypesImportSpec, w as RenderTypeContext } from "./types-BJr2H3qm.mjs";
4
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;
5
98
  /**
6
99
  * Declarative fields that describe component metadata.
7
- * These fields are owned directly by descriptors (not nested under a manifest).
8
100
  */
9
101
  interface ComponentMetadata {
10
- /** Component version (semver) */
11
- readonly version: string;
12
- /**
13
- * Capabilities this component provides.
14
- *
15
- * For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into
16
- * the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);
17
- * keep these declarations in sync. Targets are identifiers/descriptors and typically do not
18
- * declare capabilities.
19
- */
20
- readonly capabilities?: Record<string, unknown>;
21
- /** Type imports for contract.d.ts generation */
22
- readonly types?: {
23
- readonly codecTypes?: {
24
- readonly import: TypesImportSpec;
25
- };
26
- readonly operationTypes?: {
27
- readonly import: TypesImportSpec;
28
- };
29
- readonly storage?: ReadonlyArray<{
30
- readonly typeId: string;
31
- readonly familyId: string;
32
- readonly targetId: string;
33
- readonly nativeType?: string;
34
- }>;
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;
35
146
  };
36
- /** Operation manifests for building operation registries */
37
- readonly operations?: ReadonlyArray<OperationManifest>;
147
+ readonly storage?: ReadonlyArray<{
148
+ readonly typeId: string;
149
+ readonly familyId: string;
150
+ readonly targetId: string;
151
+ readonly nativeType?: string;
152
+ }>;
153
+ };
38
154
  }
39
155
  /**
40
156
  * Base descriptor for any framework component.
@@ -56,31 +172,31 @@ interface ComponentMetadata {
56
172
  * ```
57
173
  */
58
174
  interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {
59
- /** Discriminator identifying the component type */
60
- readonly kind: Kind;
61
- /** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */
62
- readonly id: string;
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;
63
179
  }
64
180
  interface ContractComponentRequirementsCheckInput {
65
- readonly contract: {
66
- readonly target: string;
67
- readonly targetFamily?: string | undefined;
68
- readonly extensionPacks?: Record<string, unknown> | undefined;
69
- };
70
- readonly expectedTargetFamily?: string | undefined;
71
- readonly expectedTargetId?: string | undefined;
72
- readonly providedComponentIds: Iterable<string>;
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>;
73
189
  }
74
190
  interface ContractComponentRequirementsCheckResult {
75
- readonly familyMismatch?: {
76
- readonly expected: string;
77
- readonly actual: string;
78
- } | undefined;
79
- readonly targetMismatch?: {
80
- readonly expected: string;
81
- readonly actual: string;
82
- } | undefined;
83
- readonly missingExtensionPackIds: readonly string[];
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[];
84
200
  }
85
201
  declare function checkContractComponentRequirements(input: ContractComponentRequirementsCheckInput): ContractComponentRequirementsCheckResult;
86
202
  /**
@@ -111,8 +227,8 @@ declare function checkContractComponentRequirements(input: ContractComponentRequ
111
227
  * ```
112
228
  */
113
229
  interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {
114
- /** The family identifier (e.g., 'sql', 'document') */
115
- readonly familyId: TFamilyId;
230
+ /** The family identifier (e.g., 'sql', 'document') */
231
+ readonly familyId: TFamilyId;
116
232
  }
117
233
  /**
118
234
  * Descriptor for a target component.
@@ -142,32 +258,32 @@ interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor
142
258
  * ```
143
259
  */
144
260
  interface TargetDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'target'> {
145
- /** The family this target belongs to */
146
- readonly familyId: TFamilyId;
147
- /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
148
- readonly targetId: TTargetId;
261
+ /** The family this target belongs to */
262
+ readonly familyId: TFamilyId;
263
+ /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
264
+ readonly targetId: TTargetId;
149
265
  }
150
266
  /**
151
267
  * Base shape for any pack reference.
152
268
  * Pack refs are pure JSON-friendly objects safe to import in authoring flows.
153
269
  */
154
270
  interface PackRefBase<Kind extends string, TFamilyId extends string> extends ComponentMetadata {
155
- readonly kind: Kind;
156
- readonly id: string;
157
- readonly familyId: TFamilyId;
158
- readonly targetId?: string;
271
+ readonly kind: Kind;
272
+ readonly id: string;
273
+ readonly familyId: TFamilyId;
274
+ readonly targetId?: string;
159
275
  }
160
276
  type TargetPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'target', TFamilyId> & {
161
- readonly targetId: TTargetId;
277
+ readonly targetId: TTargetId;
162
278
  };
163
279
  type AdapterPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'adapter', TFamilyId> & {
164
- readonly targetId: TTargetId;
280
+ readonly targetId: TTargetId;
165
281
  };
166
282
  type ExtensionPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'extension', TFamilyId> & {
167
- readonly targetId: TTargetId;
283
+ readonly targetId: TTargetId;
168
284
  };
169
285
  type DriverPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'driver', TFamilyId> & {
170
- readonly targetId: TTargetId;
286
+ readonly targetId: TTargetId;
171
287
  };
172
288
  /**
173
289
  * Descriptor for an adapter component.
@@ -198,10 +314,10 @@ type DriverPackRef<TFamilyId extends string = string, TTargetId extends string =
198
314
  * ```
199
315
  */
200
316
  interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'adapter'> {
201
- /** The family this adapter belongs to */
202
- readonly familyId: TFamilyId;
203
- /** The target this adapter is designed for */
204
- readonly targetId: TTargetId;
317
+ /** The family this adapter belongs to */
318
+ readonly familyId: TFamilyId;
319
+ /** The target this adapter is designed for */
320
+ readonly targetId: TTargetId;
205
321
  }
206
322
  /**
207
323
  * Descriptor for a driver component.
@@ -234,10 +350,10 @@ interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string>
234
350
  * ```
235
351
  */
236
352
  interface DriverDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'driver'> {
237
- /** The family this driver belongs to */
238
- readonly familyId: TFamilyId;
239
- /** The target this driver connects to */
240
- readonly targetId: TTargetId;
353
+ /** The family this driver belongs to */
354
+ readonly familyId: TFamilyId;
355
+ /** The target this driver connects to */
356
+ readonly targetId: TTargetId;
241
357
  }
242
358
  /**
243
359
  * Descriptor for an extension component.
@@ -267,10 +383,10 @@ interface DriverDescriptor<TFamilyId extends string, TTargetId extends string> e
267
383
  * ```
268
384
  */
269
385
  interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'extension'> {
270
- /** The family this extension belongs to */
271
- readonly familyId: TFamilyId;
272
- /** The target this extension is designed for */
273
- readonly targetId: TTargetId;
386
+ /** The family this extension belongs to */
387
+ readonly familyId: TFamilyId;
388
+ /** The target this extension is designed for */
389
+ readonly targetId: TTargetId;
274
390
  }
275
391
  /**
276
392
  * Union type for target-bound component descriptors.
@@ -313,8 +429,8 @@ type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends
313
429
  * ```
314
430
  */
315
431
  interface FamilyInstance<TFamilyId extends string> {
316
- /** The family identifier (e.g., 'sql', 'document') */
317
- readonly familyId: TFamilyId;
432
+ /** The family identifier (e.g., 'sql', 'document') */
433
+ readonly familyId: TFamilyId;
318
434
  }
319
435
  /**
320
436
  * Base interface for target instances.
@@ -334,10 +450,10 @@ interface FamilyInstance<TFamilyId extends string> {
334
450
  * ```
335
451
  */
336
452
  interface TargetInstance<TFamilyId extends string, TTargetId extends string> {
337
- /** The family this target belongs to */
338
- readonly familyId: TFamilyId;
339
- /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
340
- readonly targetId: TTargetId;
453
+ /** The family this target belongs to */
454
+ readonly familyId: TFamilyId;
455
+ /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
456
+ readonly targetId: TTargetId;
341
457
  }
342
458
  /**
343
459
  * Base interface for adapter instances.
@@ -357,10 +473,10 @@ interface TargetInstance<TFamilyId extends string, TTargetId extends string> {
357
473
  * ```
358
474
  */
359
475
  interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {
360
- /** The family this adapter belongs to */
361
- readonly familyId: TFamilyId;
362
- /** The target this adapter is designed for */
363
- readonly targetId: TTargetId;
476
+ /** The family this adapter belongs to */
477
+ readonly familyId: TFamilyId;
478
+ /** The target this adapter is designed for */
479
+ readonly targetId: TTargetId;
364
480
  }
365
481
  /**
366
482
  * Base interface for driver instances.
@@ -380,10 +496,10 @@ interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {
380
496
  * ```
381
497
  */
382
498
  interface DriverInstance<TFamilyId extends string, TTargetId extends string> {
383
- /** The family this driver belongs to */
384
- readonly familyId: TFamilyId;
385
- /** The target this driver connects to */
386
- readonly targetId: TTargetId;
499
+ /** The family this driver belongs to */
500
+ readonly familyId: TFamilyId;
501
+ /** The target this driver connects to */
502
+ readonly targetId: TTargetId;
387
503
  }
388
504
  /**
389
505
  * Base interface for extension instances.
@@ -403,10 +519,11 @@ interface DriverInstance<TFamilyId extends string, TTargetId extends string> {
403
519
  * ```
404
520
  */
405
521
  interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {
406
- /** The family this extension belongs to */
407
- readonly familyId: TFamilyId;
408
- /** The target this extension is designed for */
409
- readonly targetId: TTargetId;
522
+ /** The family this extension belongs to */
523
+ readonly familyId: TFamilyId;
524
+ /** The target this extension is designed for */
525
+ readonly targetId: TTargetId;
410
526
  }
411
-
412
- 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 PackRefBase, type TargetBoundComponentDescriptor, type TargetDescriptor, type TargetInstance, type TargetPackRef, checkContractComponentRequirements };
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":";;;;;;AAaA;AAiBA;AAgBA;AAYA;AAiBA;;;;;AAIwB,UAlEP,oBAAA,CAkEO;EAMP,SAAA,IAAA,EAAA,UAAsB;EAWvB;EA4BA,SAAA,QAAA,EAAA,MAAiB;AA8BjC;;;;;;;;;;;AA0EA;AAQiB,UA9MA,oBAAA,CA8MA;EAWA,SAAA,IAAA,EAAA,UAAA;EAMD;EA+DC,SAAA,MAAA,EAAA,CAAA,MAAgB,EA3RL,MA2RK,CAAA,MAAA,EAEZ,OAAA,CAAA,EAF+C,GAAA,EA3RV,iBA2R6B,EAAA,GAAA,MAAA;AAgCvF;;;;;AAaA;;;;;AAQA;AAG0B,KAtUd,kBAAA,GAsUc,MAAA;;;;AAI1B;;;;;AAOA;;AAGI,KAxUQ,uBAAA,GAwUR,CAAA,MAAA,EAvUM,MAuUN,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,EAtUG,iBAsUH,EAAA,GAAA,MAAA;;;AAIJ;;;;;AAmCA;;;;;AAuCiB,KArYL,YAAA,GACR,kBAoY6B,GAnY7B,uBAmY6B,GAlY7B,oBAkY6B,GAjY7B,oBAiY6B;;;;;AAoChB,UA/ZA,sBAAA,CA+ZmB;EAGf,SAAA,OAAA,EAAA,MAAA;EAGA,SAAA,MAAA,EAAA,CAAA,MAAA,EAnaO,MAmaP,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,EAnaqC,iBAmarC,EAAA,GAAA,MAAA;;;AA2BrB;;;;;AAEiC,iBAvbjB,uBAAA,CAubiB,QAAA,EAAA,MAAA,EAAA,MAAA,EArbvB,MAqbuB,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,EApb1B,iBAob0B,CAAA,EAAA,MAAA;;;;;;;;;AAmBjC;AAsBA;AAyBiB,iBA7dD,iBAAA,CA6dgB,OAAA,EAAA,MAEX,EAAA,QAGA,EAlewC,YAke/B,CAAA,EAle8C,sBAke9C;AAoB9B;AAyBA;;UAjfiB,iBAAA;;;;;;;;;;;0BAYS;;;;;;;;wBASF;;;;;;;;+BAQO,eAAe;;;;;;;;;6BASjB,cAAc;;;;;mCAKR;;;uBAEc;;uBAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BN,iDAAiD;;iBAEjD;;;;UAMA,uCAAA;;;;8BAIa;;;;iCAIG;;UAGhB,wCAAA;;;;;;;;;;;iBAMD,kCAAA,QACP,0CACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6Dc,mDAAmD;;qBAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BJ,6EACP;;qBAEW;;qBAGA;;;;;;UAOJ,mEACP;iBACO;;qBAEI;;;KAIT,sFAGR,sBAAsB;qBACL;;KAGT,uFAGR,uBAAuB;qBACN;;KAGT,yFAGR,yBAAyB;qBACR;;KAGT,sFAGR,sBAAsB;qBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+BJ,8EACP;;qBAEW;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiCJ,6EACP;;qBAEW;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BJ,gFACP;;qBAEW;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BT,qFACR,iBAAiB,WAAW,aAC5B,kBAAkB,WAAW,aAC7B,iBAAiB,WAAW,aAC5B,oBAAoB,WAAW;;;;;;;;;;;;;;;;UAiBlB;;qBAEI;;;;;;;;;;;;;;;;;;;UAoBJ;;qBAEI;;qBAGA;;;;;;;;;;;;;;;;;;;UAoBJ;;qBAEI;;qBAGA;;;;;;;;;;;;;;;;;;;UAoBJ;;qBAEI;;qBAGA;;;;;;;;;;;;;;;;;;;UAoBJ;;qBAEI;;qBAGA"}
@@ -0,0 +1,70 @@
1
+ //#region src/framework-components.ts
2
+ /**
3
+ * Interpolates a template string with params values.
4
+ * Used internally by normalizeRenderer to compile templates to functions.
5
+ *
6
+ * @throws Error if a placeholder key is not found in params (except 'CodecTypes')
7
+ */
8
+ function interpolateTypeTemplate(template, params, ctx) {
9
+ return template.replace(/\{\{(\w+)\}\}/g, (_, key) => {
10
+ if (key === "CodecTypes") return ctx.codecTypesName;
11
+ const value = params[key];
12
+ if (value === void 0) throw new Error(`Missing template parameter "${key}" in template "${template}". Available params: ${Object.keys(params).join(", ") || "(none)"}`);
13
+ return String(value);
14
+ });
15
+ }
16
+ /**
17
+ * Normalizes a TypeRenderer to function form.
18
+ * Called during pack assembly, not at emission time.
19
+ *
20
+ * Handles all TypeRenderer forms:
21
+ * - Raw string template: `'Vector<{{length}}>'`
22
+ * - Raw function: `(params, ctx) => ...`
23
+ * - Structured template: `{ kind: 'template', template: '...' }`
24
+ * - Structured function: `{ kind: 'function', render: fn }`
25
+ */
26
+ function normalizeRenderer(codecId, renderer) {
27
+ if (typeof renderer === "string") return {
28
+ codecId,
29
+ render: (params, ctx) => interpolateTypeTemplate(renderer, params, ctx)
30
+ };
31
+ if (typeof renderer === "function") return {
32
+ codecId,
33
+ render: renderer
34
+ };
35
+ if (renderer.kind === "function") return {
36
+ codecId,
37
+ render: renderer.render
38
+ };
39
+ const { template } = renderer;
40
+ return {
41
+ codecId,
42
+ render: (params, ctx) => interpolateTypeTemplate(template, params, ctx)
43
+ };
44
+ }
45
+ function checkContractComponentRequirements(input) {
46
+ const providedIds = /* @__PURE__ */ new Set();
47
+ for (const id of input.providedComponentIds) providedIds.add(id);
48
+ const missingExtensionPackIds = (input.contract.extensionPacks ? Object.keys(input.contract.extensionPacks) : []).filter((id) => !providedIds.has(id));
49
+ const expectedTargetFamily = input.expectedTargetFamily;
50
+ const contractTargetFamily = input.contract.targetFamily;
51
+ const familyMismatch = expectedTargetFamily !== void 0 && contractTargetFamily !== void 0 && contractTargetFamily !== expectedTargetFamily ? {
52
+ expected: expectedTargetFamily,
53
+ actual: contractTargetFamily
54
+ } : void 0;
55
+ const expectedTargetId = input.expectedTargetId;
56
+ const contractTargetId = input.contract.target;
57
+ const targetMismatch = expectedTargetId !== void 0 && contractTargetId !== expectedTargetId ? {
58
+ expected: expectedTargetId,
59
+ actual: contractTargetId
60
+ } : void 0;
61
+ return {
62
+ ...familyMismatch ? { familyMismatch } : {},
63
+ ...targetMismatch ? { targetMismatch } : {},
64
+ missingExtensionPackIds
65
+ };
66
+ }
67
+
68
+ //#endregion
69
+ export { checkContractComponentRequirements, interpolateTypeTemplate, normalizeRenderer };
70
+ //# sourceMappingURL=framework-components.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-components.mjs","names":[],"sources":["../src/framework-components.ts"],"sourcesContent":["import type { RenderTypeContext, TypesImportSpec } from './types';\n\n/**\n * A template-based type renderer (structured form).\n * Uses mustache-style placeholders (e.g., `Vector<{{length}}>`) that are\n * replaced with typeParams values during rendering.\n *\n * @example\n * ```ts\n * { kind: 'template', template: 'Vector<{{length}}>' }\n * // With typeParams { length: 1536 }, renders: 'Vector<1536>'\n * ```\n */\nexport interface TypeRendererTemplate {\n readonly kind: 'template';\n /** Template string with `{{key}}` placeholders for typeParams values */\n readonly template: string;\n}\n\n/**\n * A function-based type renderer for full control over type expression generation.\n *\n * @example\n * ```ts\n * {\n * kind: 'function',\n * render: (params, ctx) => `Vector<${params.length}>`\n * }\n * ```\n */\nexport interface TypeRendererFunction {\n readonly kind: 'function';\n /** Render function that produces a TypeScript type expression */\n readonly render: (params: Record<string, unknown>, ctx: RenderTypeContext) => string;\n}\n\n/**\n * A raw template string type renderer (convenience form).\n * Shorthand for TypeRendererTemplate - just the template string without wrapper.\n *\n * @example\n * ```ts\n * 'Vector<{{length}}>'\n * // Equivalent to: { kind: 'template', template: 'Vector<{{length}}>' }\n * ```\n */\nexport type TypeRendererString = string;\n\n/**\n * A raw function type renderer (convenience form).\n * Shorthand for TypeRendererFunction - just the function without wrapper.\n *\n * @example\n * ```ts\n * (params, ctx) => `Vector<${params.length}>`\n * // Equivalent to: { kind: 'function', render: ... }\n * ```\n */\nexport type TypeRendererRawFunction = (\n params: Record<string, unknown>,\n ctx: RenderTypeContext,\n) => string;\n\n/**\n * Union of type renderer formats.\n *\n * Supports both structured forms (with `kind` discriminator) and convenience forms:\n * - `string` - Template string with `{{key}}` placeholders (manifest-safe, JSON-serializable)\n * - `function` - Render function for full control (requires runtime execution)\n * - `{ kind: 'template', template: string }` - Structured template form\n * - `{ kind: 'function', render: fn }` - Structured function form\n *\n * Templates are normalized to functions during pack assembly.\n * **Prefer template strings** for most cases - they are JSON-serializable.\n */\nexport type TypeRenderer =\n | TypeRendererString\n | TypeRendererRawFunction\n | TypeRendererTemplate\n | TypeRendererFunction;\n\n/**\n * Normalized type renderer - always a function after assembly.\n * This is the form received by the emitter.\n */\nexport interface NormalizedTypeRenderer {\n readonly codecId: string;\n readonly render: (params: Record<string, unknown>, ctx: RenderTypeContext) => string;\n}\n\n/**\n * Interpolates a template string with params values.\n * Used internally by normalizeRenderer to compile templates to functions.\n *\n * @throws Error if a placeholder key is not found in params (except 'CodecTypes')\n */\nexport function interpolateTypeTemplate(\n template: string,\n params: Record<string, unknown>,\n ctx: RenderTypeContext,\n): string {\n return template.replace(/\\{\\{(\\w+)\\}\\}/g, (_, key: string) => {\n if (key === 'CodecTypes') return ctx.codecTypesName;\n const value = params[key];\n if (value === undefined) {\n throw new Error(\n `Missing template parameter \"${key}\" in template \"${template}\". ` +\n `Available params: ${Object.keys(params).join(', ') || '(none)'}`,\n );\n }\n return String(value);\n });\n}\n\n/**\n * Normalizes a TypeRenderer to function form.\n * Called during pack assembly, not at emission time.\n *\n * Handles all TypeRenderer forms:\n * - Raw string template: `'Vector<{{length}}>'`\n * - Raw function: `(params, ctx) => ...`\n * - Structured template: `{ kind: 'template', template: '...' }`\n * - Structured function: `{ kind: 'function', render: fn }`\n */\nexport function normalizeRenderer(codecId: string, renderer: TypeRenderer): NormalizedTypeRenderer {\n // Handle raw string (template shorthand)\n if (typeof renderer === 'string') {\n return {\n codecId,\n render: (params, ctx) => interpolateTypeTemplate(renderer, params, ctx),\n };\n }\n\n // Handle raw function (function shorthand)\n if (typeof renderer === 'function') {\n return { codecId, render: renderer };\n }\n\n // Handle structured function form\n if (renderer.kind === 'function') {\n return { codecId, render: renderer.render };\n }\n\n // Handle structured template form\n const { template } = renderer;\n return {\n codecId,\n render: (params, ctx) => interpolateTypeTemplate(template, params, ctx),\n };\n}\n\n/**\n * Declarative fields that describe component metadata.\n */\nexport interface ComponentMetadata {\n /** Component version (semver) */\n readonly version: string;\n\n /**\n * Capabilities this component provides.\n *\n * For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into\n * the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);\n * keep these declarations in sync. Targets are identifiers/descriptors and typically do not\n * declare capabilities.\n */\n readonly capabilities?: Record<string, unknown>;\n\n /** Type imports for contract.d.ts generation */\n readonly types?: {\n readonly codecTypes?: {\n /**\n * Base codec types import spec.\n * Optional: adapters typically provide this, extensions usually don't.\n */\n readonly import?: TypesImportSpec;\n /**\n * Optional renderers for parameterized codecs owned by this component.\n * Key is codecId (e.g., 'pg/vector@1'), value is the type renderer.\n *\n * Templates are normalized to functions during pack assembly.\n * Duplicate codecId across descriptors is a hard error.\n */\n readonly parameterized?: Record<string, TypeRenderer>;\n /**\n * Optional additional type-only imports required by parameterized renderers.\n *\n * These imports are included in generated `contract.d.ts` but are NOT treated as\n * codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).\n *\n * Example: `Vector<N>` for pgvector renderers that emit `Vector<{{length}}>`\n */\n readonly typeImports?: ReadonlyArray<TypesImportSpec>;\n /**\n * Optional control-plane hooks keyed by codecId.\n * Used by family-specific planners/verifiers to handle storage types.\n */\n readonly controlPlaneHooks?: Record<string, unknown>;\n };\n readonly operationTypes?: { readonly import: TypesImportSpec };\n readonly storage?: ReadonlyArray<{\n readonly typeId: string;\n readonly familyId: string;\n readonly targetId: string;\n readonly nativeType?: string;\n }>;\n };\n}\n\n/**\n * Base descriptor for any framework component.\n *\n * All component descriptors share these fundamental properties that identify\n * the component and provide its metadata. This interface is extended by\n * specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).\n *\n * @template Kind - Discriminator literal identifying the component type.\n * Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',\n * but the type accepts any string to allow ecosystem extensions.\n *\n * @example\n * ```ts\n * // All descriptors have these properties\n * descriptor.kind // The Kind type parameter (e.g., 'family', 'target', or custom kinds)\n * descriptor.id // Unique string identifier (e.g., 'sql', 'postgres')\n * descriptor.version // Component version (semver)\n * ```\n */\nexport interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {\n /** Discriminator identifying the component type */\n readonly kind: Kind;\n\n /** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */\n readonly id: string;\n}\n\nexport interface ContractComponentRequirementsCheckInput {\n readonly contract: {\n readonly target: string;\n readonly targetFamily?: string | undefined;\n readonly extensionPacks?: Record<string, unknown> | undefined;\n };\n readonly expectedTargetFamily?: string | undefined;\n readonly expectedTargetId?: string | undefined;\n readonly providedComponentIds: Iterable<string>;\n}\n\nexport interface ContractComponentRequirementsCheckResult {\n readonly familyMismatch?: { readonly expected: string; readonly actual: string } | undefined;\n readonly targetMismatch?: { readonly expected: string; readonly actual: string } | undefined;\n readonly missingExtensionPackIds: readonly string[];\n}\n\nexport function checkContractComponentRequirements(\n input: ContractComponentRequirementsCheckInput,\n): ContractComponentRequirementsCheckResult {\n const providedIds = new Set<string>();\n for (const id of input.providedComponentIds) {\n providedIds.add(id);\n }\n\n const requiredExtensionPackIds = input.contract.extensionPacks\n ? Object.keys(input.contract.extensionPacks)\n : [];\n const missingExtensionPackIds = requiredExtensionPackIds.filter((id) => !providedIds.has(id));\n\n const expectedTargetFamily = input.expectedTargetFamily;\n const contractTargetFamily = input.contract.targetFamily;\n const familyMismatch =\n expectedTargetFamily !== undefined &&\n contractTargetFamily !== undefined &&\n contractTargetFamily !== expectedTargetFamily\n ? { expected: expectedTargetFamily, actual: contractTargetFamily }\n : undefined;\n\n const expectedTargetId = input.expectedTargetId;\n const contractTargetId = input.contract.target;\n const targetMismatch =\n expectedTargetId !== undefined && contractTargetId !== expectedTargetId\n ? { expected: expectedTargetId, actual: contractTargetId }\n : undefined;\n\n return {\n ...(familyMismatch ? { familyMismatch } : {}),\n ...(targetMismatch ? { targetMismatch } : {}),\n missingExtensionPackIds,\n };\n}\n\n/**\n * Descriptor for a family component.\n *\n * A \"family\" represents a category of data sources with shared semantics\n * (e.g., SQL databases, document stores). Families define:\n * - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)\n * - Contract structure (tables vs collections, columns vs fields)\n * - Type system and codecs\n *\n * Families are the top-level grouping. Each family contains multiple targets\n * (e.g., SQL family contains Postgres, MySQL, SQLite targets).\n *\n * Extended by plane-specific descriptors:\n * - `ControlFamilyDescriptor` - adds `hook` for CLI/tooling operations\n * - `RuntimeFamilyDescriptor` - adds runtime-specific factory methods\n *\n * @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')\n *\n * @example\n * ```ts\n * import sql from '@prisma-next/family-sql/control';\n *\n * sql.kind // 'family'\n * sql.familyId // 'sql'\n * sql.id // 'sql'\n * ```\n */\nexport interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {\n /** The family identifier (e.g., 'sql', 'document') */\n readonly familyId: TFamilyId;\n}\n\n/**\n * Descriptor for a target component.\n *\n * A \"target\" represents a specific database or data store within a family\n * (e.g., Postgres, MySQL, MongoDB). Targets define:\n * - Native type mappings (e.g., Postgres int4 → TypeScript number)\n * - Target-specific capabilities (e.g., RETURNING, LATERAL joins)\n *\n * Targets are bound to a family and provide the target-specific implementation\n * details that adapters and drivers use.\n *\n * Extended by plane-specific descriptors:\n * - `ControlTargetDescriptor` - adds optional `migrations` capability\n * - `RuntimeTargetDescriptor` - adds runtime factory method\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')\n *\n * @example\n * ```ts\n * import postgres from '@prisma-next/target-postgres/control';\n *\n * postgres.kind // 'target'\n * postgres.familyId // 'sql'\n * postgres.targetId // 'postgres'\n * ```\n */\nexport interface TargetDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'target'> {\n /** The family this target belongs to */\n readonly familyId: TFamilyId;\n\n /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */\n readonly targetId: TTargetId;\n}\n\n/**\n * Base shape for any pack reference.\n * Pack refs are pure JSON-friendly objects safe to import in authoring flows.\n */\nexport interface PackRefBase<Kind extends string, TFamilyId extends string>\n extends ComponentMetadata {\n readonly kind: Kind;\n readonly id: string;\n readonly familyId: TFamilyId;\n readonly targetId?: string;\n}\n\nexport type TargetPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'target', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type AdapterPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'adapter', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type ExtensionPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'extension', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type DriverPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'driver', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\n/**\n * Descriptor for an adapter component.\n *\n * An \"adapter\" provides the protocol and dialect implementation for a target.\n * Adapters handle:\n * - SQL/query generation (lowering AST to target-specific syntax)\n * - Codec registration (encoding/decoding between JS and wire types)\n * - Type mappings and coercions\n *\n * Adapters are bound to a specific family+target combination and work with\n * any compatible driver for that target.\n *\n * Extended by plane-specific descriptors:\n * - `ControlAdapterDescriptor` - control-plane factory\n * - `RuntimeAdapterDescriptor` - runtime factory\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import postgresAdapter from '@prisma-next/adapter-postgres/control';\n *\n * postgresAdapter.kind // 'adapter'\n * postgresAdapter.familyId // 'sql'\n * postgresAdapter.targetId // 'postgres'\n * ```\n */\nexport interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'adapter'> {\n /** The family this adapter belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this adapter is designed for */\n readonly targetId: TTargetId;\n}\n\n/**\n * Descriptor for a driver component.\n *\n * A \"driver\" provides the connection and execution layer for a target.\n * Drivers handle:\n * - Connection management (pooling, timeouts, retries)\n * - Query execution (sending SQL/commands, receiving results)\n * - Transaction management\n * - Wire protocol communication\n *\n * Drivers are bound to a specific family+target and work with any compatible\n * adapter. Multiple drivers can exist for the same target (e.g., node-postgres\n * vs postgres.js for Postgres).\n *\n * Extended by plane-specific descriptors:\n * - `ControlDriverDescriptor` - creates driver from connection URL\n * - `RuntimeDriverDescriptor` - creates driver with runtime options\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import postgresDriver from '@prisma-next/driver-postgres/control';\n *\n * postgresDriver.kind // 'driver'\n * postgresDriver.familyId // 'sql'\n * postgresDriver.targetId // 'postgres'\n * ```\n */\nexport interface DriverDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'driver'> {\n /** The family this driver belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this driver connects to */\n readonly targetId: TTargetId;\n}\n\n/**\n * Descriptor for an extension component.\n *\n * An \"extension\" adds optional capabilities to a target. Extensions can provide:\n * - Additional operations (e.g., vector similarity search with pgvector)\n * - Custom types and codecs (e.g., vector type)\n * - Extended query capabilities\n *\n * Extensions are bound to a specific family+target and are registered in the\n * config alongside the core components. Multiple extensions can be used together.\n *\n * Extended by plane-specific descriptors:\n * - `ControlExtensionDescriptor` - control-plane extension factory\n * - `RuntimeExtensionDescriptor` - runtime extension factory\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import pgvector from '@prisma-next/extension-pgvector/control';\n *\n * pgvector.kind // 'extension'\n * pgvector.familyId // 'sql'\n * pgvector.targetId // 'postgres'\n * ```\n */\nexport interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'extension'> {\n /** The family this extension belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this extension is designed for */\n readonly targetId: TTargetId;\n}\n\n/**\n * Union type for target-bound component descriptors.\n *\n * Target-bound components are those that must be compatible with a specific\n * family+target combination. This includes targets, adapters, drivers, and\n * extensions. Families are not target-bound.\n *\n * This type is used in migration and verification interfaces to enforce\n * type-level compatibility between components.\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * // All these components must have matching familyId and targetId\n * const components: TargetBoundComponentDescriptor<'sql', 'postgres'>[] = [\n * postgresTarget,\n * postgresAdapter,\n * postgresDriver,\n * pgvectorExtension,\n * ];\n * ```\n */\nexport type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends string> =\n | TargetDescriptor<TFamilyId, TTargetId>\n | AdapterDescriptor<TFamilyId, TTargetId>\n | DriverDescriptor<TFamilyId, TTargetId>\n | ExtensionDescriptor<TFamilyId, TTargetId>;\n\n/**\n * Base interface for family instances.\n *\n * A family instance is created by a family descriptor's `create()` method.\n * This base interface carries only the identity; plane-specific interfaces\n * add domain actions (e.g., `emitContract`, `verify` on ControlFamilyInstance).\n *\n * @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')\n *\n * @example\n * ```ts\n * const instance = sql.create({ target, adapter, driver, extensions });\n * instance.familyId // 'sql'\n * ```\n */\nexport interface FamilyInstance<TFamilyId extends string> {\n /** The family identifier (e.g., 'sql', 'document') */\n readonly familyId: TFamilyId;\n}\n\n/**\n * Base interface for target instances.\n *\n * A target instance is created by a target descriptor's `create()` method.\n * This base interface carries only the identity; plane-specific interfaces\n * add target-specific behavior.\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')\n *\n * @example\n * ```ts\n * const instance = postgres.create();\n * instance.familyId // 'sql'\n * instance.targetId // 'postgres'\n * ```\n */\nexport interface TargetInstance<TFamilyId extends string, TTargetId extends string> {\n /** The family this target belongs to */\n readonly familyId: TFamilyId;\n\n /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */\n readonly targetId: TTargetId;\n}\n\n/**\n * Base interface for adapter instances.\n *\n * An adapter instance is created by an adapter descriptor's `create()` method.\n * This base interface carries only the identity; plane-specific interfaces\n * add adapter-specific behavior (e.g., codec registration, query lowering).\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * const instance = postgresAdapter.create();\n * instance.familyId // 'sql'\n * instance.targetId // 'postgres'\n * ```\n */\nexport interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {\n /** The family this adapter belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this adapter is designed for */\n readonly targetId: TTargetId;\n}\n\n/**\n * Base interface for driver instances.\n *\n * A driver instance is created by a driver descriptor's `create()` method.\n * This base interface carries only the identity; plane-specific interfaces\n * add driver-specific behavior (e.g., `query`, `close` on ControlDriverInstance).\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * const instance = postgresDriver.create({ databaseUrl });\n * instance.familyId // 'sql'\n * instance.targetId // 'postgres'\n * ```\n */\nexport interface DriverInstance<TFamilyId extends string, TTargetId extends string> {\n /** The family this driver belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this driver connects to */\n readonly targetId: TTargetId;\n}\n\n/**\n * Base interface for extension instances.\n *\n * An extension instance is created by an extension descriptor's `create()` method.\n * This base interface carries only the identity; plane-specific interfaces\n * add extension-specific behavior.\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * const instance = pgvector.create();\n * instance.familyId // 'sql'\n * instance.targetId // 'postgres'\n * ```\n */\nexport interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {\n /** The family this extension belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this extension is designed for */\n readonly targetId: TTargetId;\n}\n"],"mappings":";;;;;;;AAgGA,SAAgB,wBACd,UACA,QACA,KACQ;AACR,QAAO,SAAS,QAAQ,mBAAmB,GAAG,QAAgB;AAC5D,MAAI,QAAQ,aAAc,QAAO,IAAI;EACrC,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,OAAM,IAAI,MACR,+BAA+B,IAAI,iBAAiB,SAAS,uBACtC,OAAO,KAAK,OAAO,CAAC,KAAK,KAAK,IAAI,WAC1D;AAEH,SAAO,OAAO,MAAM;GACpB;;;;;;;;;;;;AAaJ,SAAgB,kBAAkB,SAAiB,UAAgD;AAEjG,KAAI,OAAO,aAAa,SACtB,QAAO;EACL;EACA,SAAS,QAAQ,QAAQ,wBAAwB,UAAU,QAAQ,IAAI;EACxE;AAIH,KAAI,OAAO,aAAa,WACtB,QAAO;EAAE;EAAS,QAAQ;EAAU;AAItC,KAAI,SAAS,SAAS,WACpB,QAAO;EAAE;EAAS,QAAQ,SAAS;EAAQ;CAI7C,MAAM,EAAE,aAAa;AACrB,QAAO;EACL;EACA,SAAS,QAAQ,QAAQ,wBAAwB,UAAU,QAAQ,IAAI;EACxE;;AAyGH,SAAgB,mCACd,OAC0C;CAC1C,MAAM,8BAAc,IAAI,KAAa;AACrC,MAAK,MAAM,MAAM,MAAM,qBACrB,aAAY,IAAI,GAAG;CAMrB,MAAM,2BAH2B,MAAM,SAAS,iBAC5C,OAAO,KAAK,MAAM,SAAS,eAAe,GAC1C,EAAE,EACmD,QAAQ,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC;CAE7F,MAAM,uBAAuB,MAAM;CACnC,MAAM,uBAAuB,MAAM,SAAS;CAC5C,MAAM,iBACJ,yBAAyB,UACzB,yBAAyB,UACzB,yBAAyB,uBACrB;EAAE,UAAU;EAAsB,QAAQ;EAAsB,GAChE;CAEN,MAAM,mBAAmB,MAAM;CAC/B,MAAM,mBAAmB,MAAM,SAAS;CACxC,MAAM,iBACJ,qBAAqB,UAAa,qBAAqB,mBACnD;EAAE,UAAU;EAAkB,QAAQ;EAAkB,GACxD;AAEN,QAAO;EACL,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;EAC5C,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;EAC5C;EACD"}