@prisma-next/contract 0.3.0-dev.9 → 0.3.0-dev.90

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.
Files changed (46) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +42 -6
  3. package/dist/framework-components.d.mts +529 -0
  4. package/dist/framework-components.d.mts.map +1 -0
  5. package/dist/framework-components.mjs +70 -0
  6. package/dist/framework-components.mjs.map +1 -0
  7. package/dist/ir-C9rRU5WS.d.mts +84 -0
  8. package/dist/ir-C9rRU5WS.d.mts.map +1 -0
  9. package/dist/ir.d.mts +2 -0
  10. package/dist/ir.mjs +51 -0
  11. package/dist/ir.mjs.map +1 -0
  12. package/dist/types-54JRJq9p.d.mts +395 -0
  13. package/dist/types-54JRJq9p.d.mts.map +1 -0
  14. package/dist/types.d.mts +2 -0
  15. package/dist/types.mjs +30 -0
  16. package/dist/types.mjs.map +1 -0
  17. package/package.json +24 -28
  18. package/schemas/data-contract-document-v1.json +9 -4
  19. package/src/exports/framework-components.ts +10 -1
  20. package/src/exports/types.ts +31 -7
  21. package/src/framework-components.ts +179 -46
  22. package/src/ir.ts +28 -12
  23. package/src/types.ts +274 -37
  24. package/dist/exports/framework-components.d.ts +0 -3
  25. package/dist/exports/framework-components.d.ts.map +0 -1
  26. package/dist/exports/framework-components.js +0 -24
  27. package/dist/exports/framework-components.js.map +0 -1
  28. package/dist/exports/ir.d.ts +0 -2
  29. package/dist/exports/ir.d.ts.map +0 -1
  30. package/dist/exports/ir.js +0 -35
  31. package/dist/exports/ir.js.map +0 -1
  32. package/dist/exports/pack-manifest-types.d.ts +0 -2
  33. package/dist/exports/pack-manifest-types.d.ts.map +0 -1
  34. package/dist/exports/pack-manifest-types.js +0 -1
  35. package/dist/exports/pack-manifest-types.js.map +0 -1
  36. package/dist/exports/types.d.ts +0 -3
  37. package/dist/exports/types.d.ts.map +0 -1
  38. package/dist/exports/types.js +0 -8
  39. package/dist/exports/types.js.map +0 -1
  40. package/dist/framework-components.d.ts +0 -408
  41. package/dist/framework-components.d.ts.map +0 -1
  42. package/dist/ir.d.ts +0 -76
  43. package/dist/ir.d.ts.map +0 -1
  44. package/dist/types.d.ts +0 -222
  45. package/dist/types.d.ts.map +0 -1
  46. package/src/exports/pack-manifest-types.ts +0 -6
@@ -0,0 +1,529 @@
1
+ import { O as RenderTypeContext, z as TypesImportSpec } from "./types-54JRJq9p.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":";;;;;;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"}