@prisma-next/contract 0.3.0-pr.111.14 → 0.3.0-pr.111.16

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.
@@ -1,879 +0,0 @@
1
- import { t as ContractIR } from "./ir-B8zNqals.mjs";
2
- import { OperationRegistry } from "@prisma-next/operations";
3
-
4
- //#region src/types.d.ts
5
- declare const ___CoreHashBrand___: unique symbol;
6
- declare const ___ProfileHashBrand___: unique symbol;
7
- /**
8
- * Base type for core contract hashes.
9
- * Emitted contract.d.ts files use this with the hash value as a type parameter:
10
- * `type CoreHash = CoreHashBase<'sha256:abc123...'>`
11
- */
12
- type CoreHashBase<THash extends string> = THash & {
13
- readonly [___CoreHashBrand___]: true;
14
- };
15
- /**
16
- * Base type for profile contract hashes.
17
- * Emitted contract.d.ts files use this with the hash value as a type parameter:
18
- * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`
19
- */
20
- type ProfileHashBase<THash extends string> = THash & {
21
- readonly [___ProfileHashBrand___]: true;
22
- };
23
- interface ContractBase<TCoreHash extends CoreHashBase<string> = CoreHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> {
24
- readonly schemaVersion: string;
25
- readonly target: string;
26
- readonly targetFamily: string;
27
- readonly coreHash: TCoreHash;
28
- readonly profileHash?: TProfileHash | undefined;
29
- readonly capabilities: Record<string, Record<string, boolean>>;
30
- readonly extensionPacks: Record<string, unknown>;
31
- readonly meta: Record<string, unknown>;
32
- readonly sources: Record<string, Source>;
33
- }
34
- interface FieldType {
35
- readonly type: string;
36
- readonly nullable: boolean;
37
- readonly items?: FieldType;
38
- readonly properties?: Record<string, FieldType>;
39
- }
40
- interface Source {
41
- readonly readOnly: boolean;
42
- readonly projection: Record<string, FieldType>;
43
- readonly origin?: Record<string, unknown>;
44
- readonly capabilities?: Record<string, boolean>;
45
- }
46
- interface DocIndex {
47
- readonly name: string;
48
- readonly keys: Record<string, 'asc' | 'desc'>;
49
- readonly unique?: boolean;
50
- readonly where?: Expr;
51
- }
52
- type Expr = {
53
- readonly kind: 'eq';
54
- readonly path: ReadonlyArray<string>;
55
- readonly value: unknown;
56
- } | {
57
- readonly kind: 'exists';
58
- readonly path: ReadonlyArray<string>;
59
- };
60
- interface DocCollection {
61
- readonly name: string;
62
- readonly id?: {
63
- readonly strategy: 'auto' | 'client' | 'uuid' | 'cuid' | 'objectId';
64
- };
65
- readonly fields: Record<string, FieldType>;
66
- readonly indexes?: ReadonlyArray<DocIndex>;
67
- readonly readOnly?: boolean;
68
- }
69
- interface DocumentStorage {
70
- readonly document: {
71
- readonly collections: Record<string, DocCollection>;
72
- };
73
- }
74
- interface DocumentContract<TCoreHash extends CoreHashBase<string> = CoreHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> extends ContractBase<TCoreHash, TProfileHash> {
75
- readonly targetFamily: string;
76
- readonly storage: DocumentStorage;
77
- }
78
- interface ParamDescriptor {
79
- readonly index?: number;
80
- readonly name?: string;
81
- readonly codecId?: string;
82
- readonly nativeType?: string;
83
- readonly nullable?: boolean;
84
- readonly source: 'dsl' | 'raw';
85
- readonly refs?: {
86
- table: string;
87
- column: string;
88
- };
89
- }
90
- interface PlanRefs {
91
- readonly tables?: readonly string[];
92
- readonly columns?: ReadonlyArray<{
93
- table: string;
94
- column: string;
95
- }>;
96
- readonly indexes?: ReadonlyArray<{
97
- readonly table: string;
98
- readonly columns: ReadonlyArray<string>;
99
- readonly name?: string;
100
- }>;
101
- }
102
- interface PlanMeta {
103
- readonly target: string;
104
- readonly targetFamily?: string;
105
- readonly coreHash: string;
106
- readonly profileHash?: string;
107
- readonly lane: string;
108
- readonly annotations?: {
109
- codecs?: Record<string, string>;
110
- [key: string]: unknown;
111
- };
112
- readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;
113
- readonly refs?: PlanRefs;
114
- readonly projection?: Record<string, string> | ReadonlyArray<string>;
115
- /**
116
- * Optional mapping of projection alias → column type ID (fully qualified ns/name@version).
117
- * Used for codec resolution when AST+refs don't provide enough type info.
118
- */
119
- readonly projectionTypes?: Record<string, string>;
120
- }
121
- /**
122
- * Canonical execution plan shape used by runtimes.
123
- *
124
- * - Row is the inferred result row type (TypeScript-only).
125
- * - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).
126
- *
127
- * The payload executed by the runtime is represented by the sql + params pair
128
- * for now; future families can specialize this via Ast or additional metadata.
129
- */
130
- interface ExecutionPlan<Row = unknown, Ast = unknown> {
131
- readonly sql: string;
132
- readonly params: readonly unknown[];
133
- readonly ast?: Ast;
134
- readonly meta: PlanMeta;
135
- /**
136
- * Phantom property to carry the Row generic for type-level utilities.
137
- * Not set at runtime; used only for ResultType extraction.
138
- */
139
- readonly _row?: Row;
140
- }
141
- /**
142
- * Utility type to extract the Row type from an ExecutionPlan.
143
- * Example: `type Row = ResultType<typeof plan>`
144
- *
145
- * Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).
146
- * SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter
147
- * for type extraction.
148
- */
149
- type ResultType<P> = P extends ExecutionPlan<infer R, unknown> ? R : P extends {
150
- readonly _Row?: infer R;
151
- } ? R : never;
152
- /**
153
- * Type guard to check if a contract is a Document contract
154
- */
155
- declare function isDocumentContract(contract: unknown): contract is DocumentContract;
156
- /**
157
- * Contract marker record stored in the database.
158
- * Represents the current contract identity for a database.
159
- */
160
- interface ContractMarkerRecord {
161
- readonly coreHash: string;
162
- readonly profileHash: string;
163
- readonly contractJson: unknown | null;
164
- readonly canonicalVersion: number | null;
165
- readonly updatedAt: Date;
166
- readonly appTag: string | null;
167
- readonly meta: Record<string, unknown>;
168
- }
169
- /**
170
- * Specifies how to import TypeScript types from a package.
171
- * Used in extension pack manifests to declare codec and operation type imports.
172
- */
173
- interface TypesImportSpec {
174
- readonly package: string;
175
- readonly named: string;
176
- readonly alias: string;
177
- }
178
- /**
179
- * Validation context passed to TargetFamilyHook.validateTypes().
180
- * Contains pre-assembled operation registry, type imports, and extension IDs.
181
- */
182
- interface ValidationContext {
183
- readonly operationRegistry?: OperationRegistry;
184
- readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
185
- readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
186
- readonly extensionIds?: ReadonlyArray<string>;
187
- /**
188
- * Parameterized codec descriptors collected from adapters and extensions.
189
- * Map of codecId → descriptor for quick lookup during type generation.
190
- */
191
- readonly parameterizedCodecs?: Map<string, ParameterizedCodecDescriptor>;
192
- }
193
- /**
194
- * Context for rendering parameterized types during contract.d.ts generation.
195
- * Passed to type renderers so they can reference CodecTypes by name.
196
- */
197
- interface TypeRenderContext {
198
- readonly codecTypesName: string;
199
- }
200
- /**
201
- * A normalized type renderer for parameterized codecs.
202
- * This is the interface expected by TargetFamilyHook.generateContractTypes.
203
- */
204
- interface TypeRenderEntry {
205
- readonly codecId: string;
206
- readonly render: (params: Record<string, unknown>, ctx: TypeRenderContext) => string;
207
- }
208
- /**
209
- * Additional options for generateContractTypes.
210
- */
211
- interface GenerateContractTypesOptions {
212
- /**
213
- * Normalized parameterized type renderers, keyed by codecId.
214
- * When a column has typeParams and a renderer exists for its codecId,
215
- * the renderer is called to produce the TypeScript type expression.
216
- */
217
- readonly parameterizedRenderers?: Map<string, TypeRenderEntry>;
218
- /**
219
- * Type imports for parameterized codecs.
220
- * These are merged with codec and operation type imports in contract.d.ts.
221
- */
222
- readonly parameterizedTypeImports?: ReadonlyArray<TypesImportSpec>;
223
- }
224
- /**
225
- * SPI interface for target family hooks that extend emission behavior.
226
- * Implemented by family-specific emitter hooks (e.g., SQL family).
227
- */
228
- interface TargetFamilyHook {
229
- readonly id: string;
230
- /**
231
- * Validates that all type IDs in the contract come from referenced extension packs.
232
- * @param ir - Contract IR to validate
233
- * @param ctx - Validation context with operation registry and extension IDs
234
- */
235
- validateTypes(ir: ContractIR, ctx: ValidationContext): void;
236
- /**
237
- * Validates family-specific contract structure.
238
- * @param ir - Contract IR to validate
239
- */
240
- validateStructure(ir: ContractIR): void;
241
- /**
242
- * Generates contract.d.ts file content.
243
- * @param ir - Contract IR
244
- * @param codecTypeImports - Array of codec type import specs
245
- * @param operationTypeImports - Array of operation type import specs
246
- * @param hashes - Contract hash values (coreHash and profileHash)
247
- * @param options - Additional options including parameterized type renderers
248
- * @returns Generated TypeScript type definitions as string
249
- */
250
- generateContractTypes(ir: ContractIR, codecTypeImports: ReadonlyArray<TypesImportSpec>, operationTypeImports: ReadonlyArray<TypesImportSpec>, hashes: {
251
- readonly coreHash: string;
252
- readonly profileHash: string;
253
- }, options?: GenerateContractTypesOptions): string;
254
- }
255
- type ArgSpecManifest = {
256
- readonly kind: 'typeId';
257
- readonly type: string;
258
- } | {
259
- readonly kind: 'param';
260
- } | {
261
- readonly kind: 'literal';
262
- };
263
- type ReturnSpecManifest = {
264
- readonly kind: 'typeId';
265
- readonly type: string;
266
- } | {
267
- readonly kind: 'builtin';
268
- readonly type: 'number' | 'boolean' | 'string';
269
- };
270
- interface LoweringSpecManifest {
271
- readonly targetFamily: 'sql';
272
- readonly strategy: 'infix' | 'function';
273
- readonly template: string;
274
- }
275
- interface OperationManifest {
276
- readonly for: string;
277
- readonly method: string;
278
- readonly args: ReadonlyArray<ArgSpecManifest>;
279
- readonly returns: ReturnSpecManifest;
280
- readonly lowering: LoweringSpecManifest;
281
- readonly capabilities?: ReadonlyArray<string>;
282
- }
283
- /**
284
- * Declarative type renderer that produces a TypeScript type expression.
285
- *
286
- * Renderers can be:
287
- * - A template string with `{{paramName}}` placeholders (e.g., `Vector<{{length}}>`)
288
- * - A function that receives typeParams and context and returns a type expression
289
- *
290
- * **Prefer template strings** for most cases:
291
- * - Templates are JSON-serializable (safe for pack-ref metadata)
292
- * - Templates can be statically analyzed by tooling
293
- *
294
- * Function renderers are allowed but have tradeoffs:
295
- * - Require runtime execution during emission (the emitter runs code)
296
- * - Not JSON-serializable (can't be stored in contract.json)
297
- * - The emitted artifacts (contract.json, contract.d.ts) still contain no
298
- * executable code - this constraint applies to outputs, not the emission process
299
- */
300
- type TypeRenderer$1 = string | ((params: Record<string, unknown>, ctx: RenderTypeContext) => string);
301
- /**
302
- * Descriptor for a codec that supports type parameters.
303
- *
304
- * Parameterized codecs allow columns to carry additional metadata (typeParams)
305
- * that affects the generated TypeScript types. For example:
306
- * - A vector codec can use `{ length: 1536 }` to generate `Vector<1536>`
307
- * - A decimal codec can use `{ precision: 10, scale: 2 }` to generate `Decimal<10, 2>`
308
- *
309
- * The SQL family emitter uses these descriptors to generate precise types
310
- * without hard-coding knowledge of specific codec IDs.
311
- *
312
- * @example
313
- * ```typescript
314
- * const vectorCodecDescriptor: ParameterizedCodecDescriptor = {
315
- * codecId: 'pg/vector@1',
316
- * outputTypeRenderer: 'Vector<{{length}}>',
317
- * // Optional: paramsSchema for runtime validation
318
- * };
319
- * ```
320
- */
321
- interface ParameterizedCodecDescriptor {
322
- /** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */
323
- readonly codecId: string;
324
- /**
325
- * Renderer for the output (read) type.
326
- * Can be a template string or function.
327
- *
328
- * This is the primary renderer used by SQL emission to generate
329
- * model field types in contract.d.ts.
330
- */
331
- readonly outputTypeRenderer: TypeRenderer$1;
332
- /**
333
- * Optional renderer for the input (write) type.
334
- * If not provided, outputTypeRenderer is used for both.
335
- *
336
- * **Reserved for future use**: Currently, SQL emission only uses
337
- * outputTypeRenderer. This field is defined for future support of
338
- * asymmetric codecs where input and output types differ (e.g., a
339
- * codec that accepts `string | number` but always returns `number`).
340
- */
341
- readonly inputTypeRenderer?: TypeRenderer$1;
342
- /**
343
- * Optional import spec for types used by this codec's renderers.
344
- * The emitter will add this import to contract.d.ts.
345
- */
346
- readonly typesImport?: TypesImportSpec;
347
- }
348
- //#endregion
349
- //#region src/framework-components.d.ts
350
- /**
351
- * Context passed to type renderers during contract.d.ts generation.
352
- */
353
- interface RenderTypeContext {
354
- /** The name of the CodecTypes type alias (typically 'CodecTypes') */
355
- readonly codecTypesName: string;
356
- }
357
- /**
358
- * A template-based type renderer (structured form).
359
- * Uses mustache-style placeholders (e.g., `Vector<{{length}}>`) that are
360
- * replaced with typeParams values during rendering.
361
- *
362
- * @example
363
- * ```ts
364
- * { kind: 'template', template: 'Vector<{{length}}>' }
365
- * // With typeParams { length: 1536 }, renders: 'Vector<1536>'
366
- * ```
367
- */
368
- interface TypeRendererTemplate {
369
- readonly kind: 'template';
370
- /** Template string with `{{key}}` placeholders for typeParams values */
371
- readonly template: string;
372
- }
373
- /**
374
- * A function-based type renderer for full control over type expression generation.
375
- *
376
- * @example
377
- * ```ts
378
- * {
379
- * kind: 'function',
380
- * render: (params, ctx) => `Vector<${params.length}>`
381
- * }
382
- * ```
383
- */
384
- interface TypeRendererFunction {
385
- readonly kind: 'function';
386
- /** Render function that produces a TypeScript type expression */
387
- readonly render: (params: Record<string, unknown>, ctx: RenderTypeContext) => string;
388
- }
389
- /**
390
- * A raw template string type renderer (convenience form).
391
- * Shorthand for TypeRendererTemplate - just the template string without wrapper.
392
- *
393
- * @example
394
- * ```ts
395
- * 'Vector<{{length}}>'
396
- * // Equivalent to: { kind: 'template', template: 'Vector<{{length}}>' }
397
- * ```
398
- */
399
- type TypeRendererString = string;
400
- /**
401
- * A raw function type renderer (convenience form).
402
- * Shorthand for TypeRendererFunction - just the function without wrapper.
403
- *
404
- * @example
405
- * ```ts
406
- * (params, ctx) => `Vector<${params.length}>`
407
- * // Equivalent to: { kind: 'function', render: ... }
408
- * ```
409
- */
410
- type TypeRendererRawFunction = (params: Record<string, unknown>, ctx: RenderTypeContext) => string;
411
- /**
412
- * Union of type renderer formats.
413
- *
414
- * Supports both structured forms (with `kind` discriminator) and convenience forms:
415
- * - `string` - Template string with `{{key}}` placeholders (manifest-safe, JSON-serializable)
416
- * - `function` - Render function for full control (requires runtime execution)
417
- * - `{ kind: 'template', template: string }` - Structured template form
418
- * - `{ kind: 'function', render: fn }` - Structured function form
419
- *
420
- * Templates are normalized to functions during pack assembly.
421
- * **Prefer template strings** for most cases - they are JSON-serializable.
422
- */
423
- type TypeRenderer = TypeRendererString | TypeRendererRawFunction | TypeRendererTemplate | TypeRendererFunction;
424
- /**
425
- * Normalized type renderer - always a function after assembly.
426
- * This is the form received by the emitter.
427
- */
428
- interface NormalizedTypeRenderer {
429
- readonly codecId: string;
430
- readonly render: (params: Record<string, unknown>, ctx: RenderTypeContext) => string;
431
- }
432
- /**
433
- * Interpolates a template string with params values.
434
- * Used internally by normalizeRenderer to compile templates to functions.
435
- *
436
- * @throws Error if a placeholder key is not found in params (except 'CodecTypes')
437
- */
438
- declare function interpolateTypeTemplate(template: string, params: Record<string, unknown>, ctx: RenderTypeContext): string;
439
- /**
440
- * Normalizes a TypeRenderer to function form.
441
- * Called during pack assembly, not at emission time.
442
- *
443
- * Handles all TypeRenderer forms:
444
- * - Raw string template: `'Vector<{{length}}>'`
445
- * - Raw function: `(params, ctx) => ...`
446
- * - Structured template: `{ kind: 'template', template: '...' }`
447
- * - Structured function: `{ kind: 'function', render: fn }`
448
- */
449
- declare function normalizeRenderer(codecId: string, renderer: TypeRenderer): NormalizedTypeRenderer;
450
- /**
451
- * Declarative fields that describe component metadata.
452
- * These fields are owned directly by descriptors (not nested under a manifest).
453
- */
454
- interface ComponentMetadata {
455
- /** Component version (semver) */
456
- readonly version: string;
457
- /**
458
- * Capabilities this component provides.
459
- *
460
- * For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into
461
- * the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);
462
- * keep these declarations in sync. Targets are identifiers/descriptors and typically do not
463
- * declare capabilities.
464
- */
465
- readonly capabilities?: Record<string, unknown>;
466
- /** Type imports for contract.d.ts generation */
467
- readonly types?: {
468
- readonly codecTypes?: {
469
- /**
470
- * Base codec types import spec.
471
- * Optional: adapters typically provide this, extensions usually don't.
472
- */
473
- readonly import?: TypesImportSpec;
474
- /**
475
- * Optional renderers for parameterized codecs owned by this component.
476
- * Key is codecId (e.g., 'pg/vector@1'), value is the type renderer.
477
- *
478
- * Templates are normalized to functions during pack assembly.
479
- * Duplicate codecId across descriptors is a hard error.
480
- */
481
- readonly parameterized?: Record<string, TypeRenderer>;
482
- /**
483
- * Optional additional type-only imports required by parameterized renderers.
484
- *
485
- * These imports are included in generated `contract.d.ts` but are NOT treated as
486
- * codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
487
- *
488
- * Example: `Vector<N>` for pgvector renderers that emit `Vector<{{length}}>`
489
- */
490
- readonly typeImports?: ReadonlyArray<TypesImportSpec>;
491
- };
492
- readonly operationTypes?: {
493
- readonly import: TypesImportSpec;
494
- };
495
- readonly storage?: ReadonlyArray<{
496
- readonly typeId: string;
497
- readonly familyId: string;
498
- readonly targetId: string;
499
- readonly nativeType?: string;
500
- }>;
501
- };
502
- /** Operation manifests for building operation registries */
503
- readonly operations?: ReadonlyArray<OperationManifest>;
504
- }
505
- /**
506
- * Base descriptor for any framework component.
507
- *
508
- * All component descriptors share these fundamental properties that identify
509
- * the component and provide its metadata. This interface is extended by
510
- * specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
511
- *
512
- * @template Kind - Discriminator literal identifying the component type.
513
- * Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',
514
- * but the type accepts any string to allow ecosystem extensions.
515
- *
516
- * @example
517
- * ```ts
518
- * // All descriptors have these properties
519
- * descriptor.kind // The Kind type parameter (e.g., 'family', 'target', or custom kinds)
520
- * descriptor.id // Unique string identifier (e.g., 'sql', 'postgres')
521
- * descriptor.version // Component version (semver)
522
- * ```
523
- */
524
- interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {
525
- /** Discriminator identifying the component type */
526
- readonly kind: Kind;
527
- /** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */
528
- readonly id: string;
529
- }
530
- interface ContractComponentRequirementsCheckInput {
531
- readonly contract: {
532
- readonly target: string;
533
- readonly targetFamily?: string | undefined;
534
- readonly extensionPacks?: Record<string, unknown> | undefined;
535
- };
536
- readonly expectedTargetFamily?: string | undefined;
537
- readonly expectedTargetId?: string | undefined;
538
- readonly providedComponentIds: Iterable<string>;
539
- }
540
- interface ContractComponentRequirementsCheckResult {
541
- readonly familyMismatch?: {
542
- readonly expected: string;
543
- readonly actual: string;
544
- } | undefined;
545
- readonly targetMismatch?: {
546
- readonly expected: string;
547
- readonly actual: string;
548
- } | undefined;
549
- readonly missingExtensionPackIds: readonly string[];
550
- }
551
- declare function checkContractComponentRequirements(input: ContractComponentRequirementsCheckInput): ContractComponentRequirementsCheckResult;
552
- /**
553
- * Descriptor for a family component.
554
- *
555
- * A "family" represents a category of data sources with shared semantics
556
- * (e.g., SQL databases, document stores). Families define:
557
- * - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)
558
- * - Contract structure (tables vs collections, columns vs fields)
559
- * - Type system and codecs
560
- *
561
- * Families are the top-level grouping. Each family contains multiple targets
562
- * (e.g., SQL family contains Postgres, MySQL, SQLite targets).
563
- *
564
- * Extended by plane-specific descriptors:
565
- * - `ControlFamilyDescriptor` - adds `hook` for CLI/tooling operations
566
- * - `RuntimeFamilyDescriptor` - adds runtime-specific factory methods
567
- *
568
- * @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')
569
- *
570
- * @example
571
- * ```ts
572
- * import sql from '@prisma-next/family-sql/control';
573
- *
574
- * sql.kind // 'family'
575
- * sql.familyId // 'sql'
576
- * sql.id // 'sql'
577
- * ```
578
- */
579
- interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {
580
- /** The family identifier (e.g., 'sql', 'document') */
581
- readonly familyId: TFamilyId;
582
- }
583
- /**
584
- * Descriptor for a target component.
585
- *
586
- * A "target" represents a specific database or data store within a family
587
- * (e.g., Postgres, MySQL, MongoDB). Targets define:
588
- * - Native type mappings (e.g., Postgres int4 → TypeScript number)
589
- * - Target-specific capabilities (e.g., RETURNING, LATERAL joins)
590
- *
591
- * Targets are bound to a family and provide the target-specific implementation
592
- * details that adapters and drivers use.
593
- *
594
- * Extended by plane-specific descriptors:
595
- * - `ControlTargetDescriptor` - adds optional `migrations` capability
596
- * - `RuntimeTargetDescriptor` - adds runtime factory method
597
- *
598
- * @template TFamilyId - Literal type for the family identifier
599
- * @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')
600
- *
601
- * @example
602
- * ```ts
603
- * import postgres from '@prisma-next/target-postgres/control';
604
- *
605
- * postgres.kind // 'target'
606
- * postgres.familyId // 'sql'
607
- * postgres.targetId // 'postgres'
608
- * ```
609
- */
610
- interface TargetDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'target'> {
611
- /** The family this target belongs to */
612
- readonly familyId: TFamilyId;
613
- /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
614
- readonly targetId: TTargetId;
615
- }
616
- /**
617
- * Base shape for any pack reference.
618
- * Pack refs are pure JSON-friendly objects safe to import in authoring flows.
619
- */
620
- interface PackRefBase<Kind extends string, TFamilyId extends string> extends ComponentMetadata {
621
- readonly kind: Kind;
622
- readonly id: string;
623
- readonly familyId: TFamilyId;
624
- readonly targetId?: string;
625
- }
626
- type TargetPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'target', TFamilyId> & {
627
- readonly targetId: TTargetId;
628
- };
629
- type AdapterPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'adapter', TFamilyId> & {
630
- readonly targetId: TTargetId;
631
- };
632
- type ExtensionPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'extension', TFamilyId> & {
633
- readonly targetId: TTargetId;
634
- };
635
- type DriverPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'driver', TFamilyId> & {
636
- readonly targetId: TTargetId;
637
- };
638
- /**
639
- * Descriptor for an adapter component.
640
- *
641
- * An "adapter" provides the protocol and dialect implementation for a target.
642
- * Adapters handle:
643
- * - SQL/query generation (lowering AST to target-specific syntax)
644
- * - Codec registration (encoding/decoding between JS and wire types)
645
- * - Type mappings and coercions
646
- *
647
- * Adapters are bound to a specific family+target combination and work with
648
- * any compatible driver for that target.
649
- *
650
- * Extended by plane-specific descriptors:
651
- * - `ControlAdapterDescriptor` - control-plane factory
652
- * - `RuntimeAdapterDescriptor` - runtime factory
653
- *
654
- * @template TFamilyId - Literal type for the family identifier
655
- * @template TTargetId - Literal type for the target identifier
656
- *
657
- * @example
658
- * ```ts
659
- * import postgresAdapter from '@prisma-next/adapter-postgres/control';
660
- *
661
- * postgresAdapter.kind // 'adapter'
662
- * postgresAdapter.familyId // 'sql'
663
- * postgresAdapter.targetId // 'postgres'
664
- * ```
665
- */
666
- interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'adapter'> {
667
- /** The family this adapter belongs to */
668
- readonly familyId: TFamilyId;
669
- /** The target this adapter is designed for */
670
- readonly targetId: TTargetId;
671
- }
672
- /**
673
- * Descriptor for a driver component.
674
- *
675
- * A "driver" provides the connection and execution layer for a target.
676
- * Drivers handle:
677
- * - Connection management (pooling, timeouts, retries)
678
- * - Query execution (sending SQL/commands, receiving results)
679
- * - Transaction management
680
- * - Wire protocol communication
681
- *
682
- * Drivers are bound to a specific family+target and work with any compatible
683
- * adapter. Multiple drivers can exist for the same target (e.g., node-postgres
684
- * vs postgres.js for Postgres).
685
- *
686
- * Extended by plane-specific descriptors:
687
- * - `ControlDriverDescriptor` - creates driver from connection URL
688
- * - `RuntimeDriverDescriptor` - creates driver with runtime options
689
- *
690
- * @template TFamilyId - Literal type for the family identifier
691
- * @template TTargetId - Literal type for the target identifier
692
- *
693
- * @example
694
- * ```ts
695
- * import postgresDriver from '@prisma-next/driver-postgres/control';
696
- *
697
- * postgresDriver.kind // 'driver'
698
- * postgresDriver.familyId // 'sql'
699
- * postgresDriver.targetId // 'postgres'
700
- * ```
701
- */
702
- interface DriverDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'driver'> {
703
- /** The family this driver belongs to */
704
- readonly familyId: TFamilyId;
705
- /** The target this driver connects to */
706
- readonly targetId: TTargetId;
707
- }
708
- /**
709
- * Descriptor for an extension component.
710
- *
711
- * An "extension" adds optional capabilities to a target. Extensions can provide:
712
- * - Additional operations (e.g., vector similarity search with pgvector)
713
- * - Custom types and codecs (e.g., vector type)
714
- * - Extended query capabilities
715
- *
716
- * Extensions are bound to a specific family+target and are registered in the
717
- * config alongside the core components. Multiple extensions can be used together.
718
- *
719
- * Extended by plane-specific descriptors:
720
- * - `ControlExtensionDescriptor` - control-plane extension factory
721
- * - `RuntimeExtensionDescriptor` - runtime extension factory
722
- *
723
- * @template TFamilyId - Literal type for the family identifier
724
- * @template TTargetId - Literal type for the target identifier
725
- *
726
- * @example
727
- * ```ts
728
- * import pgvector from '@prisma-next/extension-pgvector/control';
729
- *
730
- * pgvector.kind // 'extension'
731
- * pgvector.familyId // 'sql'
732
- * pgvector.targetId // 'postgres'
733
- * ```
734
- */
735
- interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'extension'> {
736
- /** The family this extension belongs to */
737
- readonly familyId: TFamilyId;
738
- /** The target this extension is designed for */
739
- readonly targetId: TTargetId;
740
- }
741
- /**
742
- * Union type for target-bound component descriptors.
743
- *
744
- * Target-bound components are those that must be compatible with a specific
745
- * family+target combination. This includes targets, adapters, drivers, and
746
- * extensions. Families are not target-bound.
747
- *
748
- * This type is used in migration and verification interfaces to enforce
749
- * type-level compatibility between components.
750
- *
751
- * @template TFamilyId - Literal type for the family identifier
752
- * @template TTargetId - Literal type for the target identifier
753
- *
754
- * @example
755
- * ```ts
756
- * // All these components must have matching familyId and targetId
757
- * const components: TargetBoundComponentDescriptor<'sql', 'postgres'>[] = [
758
- * postgresTarget,
759
- * postgresAdapter,
760
- * postgresDriver,
761
- * pgvectorExtension,
762
- * ];
763
- * ```
764
- */
765
- type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends string> = TargetDescriptor<TFamilyId, TTargetId> | AdapterDescriptor<TFamilyId, TTargetId> | DriverDescriptor<TFamilyId, TTargetId> | ExtensionDescriptor<TFamilyId, TTargetId>;
766
- /**
767
- * Base interface for family instances.
768
- *
769
- * A family instance is created by a family descriptor's `create()` method.
770
- * This base interface carries only the identity; plane-specific interfaces
771
- * add domain actions (e.g., `emitContract`, `verify` on ControlFamilyInstance).
772
- *
773
- * @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')
774
- *
775
- * @example
776
- * ```ts
777
- * const instance = sql.create({ target, adapter, driver, extensions });
778
- * instance.familyId // 'sql'
779
- * ```
780
- */
781
- interface FamilyInstance<TFamilyId extends string> {
782
- /** The family identifier (e.g., 'sql', 'document') */
783
- readonly familyId: TFamilyId;
784
- }
785
- /**
786
- * Base interface for target instances.
787
- *
788
- * A target instance is created by a target descriptor's `create()` method.
789
- * This base interface carries only the identity; plane-specific interfaces
790
- * add target-specific behavior.
791
- *
792
- * @template TFamilyId - Literal type for the family identifier
793
- * @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')
794
- *
795
- * @example
796
- * ```ts
797
- * const instance = postgres.create();
798
- * instance.familyId // 'sql'
799
- * instance.targetId // 'postgres'
800
- * ```
801
- */
802
- interface TargetInstance<TFamilyId extends string, TTargetId extends string> {
803
- /** The family this target belongs to */
804
- readonly familyId: TFamilyId;
805
- /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
806
- readonly targetId: TTargetId;
807
- }
808
- /**
809
- * Base interface for adapter instances.
810
- *
811
- * An adapter instance is created by an adapter descriptor's `create()` method.
812
- * This base interface carries only the identity; plane-specific interfaces
813
- * add adapter-specific behavior (e.g., codec registration, query lowering).
814
- *
815
- * @template TFamilyId - Literal type for the family identifier
816
- * @template TTargetId - Literal type for the target identifier
817
- *
818
- * @example
819
- * ```ts
820
- * const instance = postgresAdapter.create();
821
- * instance.familyId // 'sql'
822
- * instance.targetId // 'postgres'
823
- * ```
824
- */
825
- interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {
826
- /** The family this adapter belongs to */
827
- readonly familyId: TFamilyId;
828
- /** The target this adapter is designed for */
829
- readonly targetId: TTargetId;
830
- }
831
- /**
832
- * Base interface for driver instances.
833
- *
834
- * A driver instance is created by a driver descriptor's `create()` method.
835
- * This base interface carries only the identity; plane-specific interfaces
836
- * add driver-specific behavior (e.g., `query`, `close` on ControlDriverInstance).
837
- *
838
- * @template TFamilyId - Literal type for the family identifier
839
- * @template TTargetId - Literal type for the target identifier
840
- *
841
- * @example
842
- * ```ts
843
- * const instance = postgresDriver.create({ databaseUrl });
844
- * instance.familyId // 'sql'
845
- * instance.targetId // 'postgres'
846
- * ```
847
- */
848
- interface DriverInstance<TFamilyId extends string, TTargetId extends string> {
849
- /** The family this driver belongs to */
850
- readonly familyId: TFamilyId;
851
- /** The target this driver connects to */
852
- readonly targetId: TTargetId;
853
- }
854
- /**
855
- * Base interface for extension instances.
856
- *
857
- * An extension instance is created by an extension descriptor's `create()` method.
858
- * This base interface carries only the identity; plane-specific interfaces
859
- * add extension-specific behavior.
860
- *
861
- * @template TFamilyId - Literal type for the family identifier
862
- * @template TTargetId - Literal type for the target identifier
863
- *
864
- * @example
865
- * ```ts
866
- * const instance = pgvector.create();
867
- * instance.familyId // 'sql'
868
- * instance.targetId // 'postgres'
869
- * ```
870
- */
871
- interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {
872
- /** The family this extension belongs to */
873
- readonly familyId: TFamilyId;
874
- /** The target this extension is designed for */
875
- readonly targetId: TTargetId;
876
- }
877
- //#endregion
878
- export { TypeRenderEntry as $, ContractBase as A, GenerateContractTypesOptions as B, TypeRenderer as C, interpolateTypeTemplate as D, checkContractComponentRequirements as E, DocumentContract as F, PlanMeta as G, OperationManifest as H, DocumentStorage as I, ResultType as J, PlanRefs as K, ExecutionPlan as L, CoreHashBase as M, DocCollection as N, normalizeRenderer as O, DocIndex as P, TypeRenderContext as Q, Expr as R, TargetPackRef as S, TypeRendererTemplate as T, ParamDescriptor as U, LoweringSpecManifest as V, ParameterizedCodecDescriptor as W, Source as X, ReturnSpecManifest as Y, TargetFamilyHook as Z, PackRefBase as _, ComponentMetadata as a, isDocumentContract as at, TargetDescriptor as b, DriverDescriptor as c, ExtensionDescriptor as d, TypeRenderer$1 as et, ExtensionInstance as f, NormalizedTypeRenderer as g, FamilyInstance as h, ComponentDescriptor as i, ___ProfileHashBrand___ as it, ContractMarkerRecord as j, ArgSpecManifest as k, DriverInstance as l, FamilyDescriptor as m, AdapterInstance as n, ValidationContext as nt, ContractComponentRequirementsCheckInput as o, ExtensionPackRef as p, ProfileHashBase as q, AdapterPackRef as r, ___CoreHashBrand___ as rt, ContractComponentRequirementsCheckResult as s, AdapterDescriptor as t, TypesImportSpec as tt, DriverPackRef as u, RenderTypeContext as v, TypeRendererFunction as w, TargetInstance as x, TargetBoundComponentDescriptor as y, FieldType as z };
879
- //# sourceMappingURL=framework-components-2yOmthS2.d.mts.map