@prisma-next/framework-components 0.5.0-dev.7 → 0.5.0-dev.70
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 +63 -3
- package/dist/authoring.d.mts +2 -2
- package/dist/authoring.mjs +2 -122
- package/dist/codec-m_-FAyQn.d.mts +168 -0
- package/dist/codec-m_-FAyQn.d.mts.map +1 -0
- package/dist/codec.d.mts +48 -2
- package/dist/codec.d.mts.map +1 -0
- package/dist/codec.mjs +67 -4
- package/dist/codec.mjs.map +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.mjs +2 -3
- package/dist/control.d.mts +370 -72
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +82 -49
- package/dist/control.mjs.map +1 -1
- package/dist/emission-types-BKa4bR9m.d.mts +39 -0
- package/dist/emission-types-BKa4bR9m.d.mts.map +1 -0
- package/dist/emission.d.mts +2 -2
- package/dist/emission.mjs +1 -1
- package/dist/execution.d.mts +5 -5
- package/dist/execution.d.mts.map +1 -1
- package/dist/execution.mjs +4 -6
- package/dist/execution.mjs.map +1 -1
- package/dist/framework-authoring-BwWNqTlD.mjs +205 -0
- package/dist/framework-authoring-BwWNqTlD.mjs.map +1 -0
- package/dist/{framework-authoring-D1-JZ37B.d.mts → framework-authoring-Cm5f9U64.d.mts} +41 -12
- package/dist/framework-authoring-Cm5f9U64.d.mts.map +1 -0
- package/dist/{framework-components-EJXe-pum.d.mts → framework-components-DgIEy9eJ.d.mts} +45 -55
- package/dist/framework-components-DgIEy9eJ.d.mts.map +1 -0
- package/dist/{framework-components-C8ZhSwXe.mjs → framework-components-FdqmlGUj.mjs} +3 -3
- package/dist/framework-components-FdqmlGUj.mjs.map +1 -0
- package/dist/psl-ast-Ckn_G-jv.d.mts +159 -0
- package/dist/psl-ast-Ckn_G-jv.d.mts.map +1 -0
- package/dist/psl-ast.d.mts +2 -0
- package/dist/psl-ast.mjs +1 -0
- package/dist/runtime.d.mts +346 -19
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +254 -7
- package/dist/runtime.mjs.map +1 -1
- package/dist/{types-import-spec-C4sc7wbb.d.mts → types-import-spec-BxI5cSQy.d.mts} +2 -2
- package/dist/types-import-spec-BxI5cSQy.d.mts.map +1 -0
- package/package.json +11 -8
- package/src/control/control-capabilities.ts +95 -0
- package/src/{control-descriptors.ts → control/control-descriptors.ts} +7 -7
- package/src/{control-instances.ts → control/control-instances.ts} +52 -6
- package/src/{control-migration-types.ts → control/control-migration-types.ts} +202 -61
- package/src/control/control-operation-preview.ts +23 -0
- package/src/control/control-spaces.ts +82 -0
- package/src/{control-stack.ts → control/control-stack.ts} +77 -94
- package/src/control/emission-types.ts +49 -0
- package/src/control/psl-ast.ts +193 -0
- package/src/{execution-descriptors.ts → execution/execution-descriptors.ts} +7 -7
- package/src/{execution-instances.ts → execution/execution-instances.ts} +1 -1
- package/src/{execution-requirements.ts → execution/execution-requirements.ts} +1 -1
- package/src/execution/query-plan.ts +53 -0
- package/src/execution/race-against-abort.ts +85 -0
- package/src/execution/run-with-middleware.ts +132 -0
- package/src/execution/runtime-core.ts +133 -0
- package/src/execution/runtime-error.ts +83 -0
- package/src/execution/runtime-middleware.ts +182 -0
- package/src/exports/authoring.ts +5 -2
- package/src/exports/codec.ts +27 -2
- package/src/exports/components.ts +2 -2
- package/src/exports/control.ts +40 -13
- package/src/exports/emission.ts +2 -2
- package/src/exports/execution.ts +5 -5
- package/src/exports/psl-ast.ts +1 -0
- package/src/exports/runtime.ts +17 -5
- package/src/shared/codec-descriptor.ts +87 -0
- package/src/shared/codec-types.ts +79 -0
- package/src/shared/codec.ts +80 -0
- package/src/shared/column-spec.ts +83 -0
- package/src/{framework-authoring.ts → shared/framework-authoring.ts} +202 -23
- package/src/{framework-components.ts → shared/framework-components.ts} +22 -48
- package/src/{mutation-default-types.ts → shared/mutation-default-types.ts} +22 -2
- package/dist/authoring.mjs.map +0 -1
- package/dist/codec-types-B58nCJiu.d.mts +0 -40
- package/dist/codec-types-B58nCJiu.d.mts.map +0 -1
- package/dist/emission-types-BPAALJbF.d.mts +0 -24
- package/dist/emission-types-BPAALJbF.d.mts.map +0 -1
- package/dist/framework-authoring-D1-JZ37B.d.mts.map +0 -1
- package/dist/framework-components-C8ZhSwXe.mjs.map +0 -1
- package/dist/framework-components-EJXe-pum.d.mts.map +0 -1
- package/dist/types-import-spec-C4sc7wbb.d.mts.map +0 -1
- package/src/codec-types.ts +0 -46
- package/src/control-capabilities.ts +0 -34
- package/src/emission-types.ts +0 -28
- package/src/runtime-error.ts +0 -39
- package/src/runtime-middleware.ts +0 -83
- /package/src/{control-result-types.ts → control/control-result-types.ts} +0 -0
- /package/src/{control-schema-view.ts → control/control-schema-view.ts} +0 -0
- /package/src/{async-iterable-result.ts → execution/async-iterable-result.ts} +0 -0
- /package/src/{execution-stack.ts → execution/execution-stack.ts} +0 -0
- /package/src/{types-import-spec.ts → shared/types-import-spec.ts} +0 -0
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ColumnDefault,
|
|
3
|
+
ExecutionMutationDefaultPhases,
|
|
4
|
+
ExecutionMutationDefaultValue,
|
|
5
|
+
} from '@prisma-next/contract/types';
|
|
6
|
+
import {
|
|
7
|
+
isColumnDefaultLiteralInputValue,
|
|
8
|
+
isExecutionMutationDefaultValue,
|
|
9
|
+
} from '@prisma-next/contract/types';
|
|
1
10
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
2
11
|
|
|
3
12
|
export type AuthoringArgRef = {
|
|
@@ -63,10 +72,15 @@ export type AuthoringColumnDefaultTemplate =
|
|
|
63
72
|
| AuthoringColumnDefaultTemplateLiteral
|
|
64
73
|
| AuthoringColumnDefaultTemplateFunction;
|
|
65
74
|
|
|
75
|
+
export interface AuthoringExecutionDefaultsTemplate {
|
|
76
|
+
readonly onCreate?: AuthoringTemplateValue;
|
|
77
|
+
readonly onUpdate?: AuthoringTemplateValue;
|
|
78
|
+
}
|
|
79
|
+
|
|
66
80
|
export interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {
|
|
67
81
|
readonly nullable?: boolean;
|
|
68
82
|
readonly default?: AuthoringColumnDefaultTemplate;
|
|
69
|
-
readonly
|
|
83
|
+
readonly executionDefaults?: AuthoringExecutionDefaultsTemplate;
|
|
70
84
|
readonly id?: boolean;
|
|
71
85
|
readonly unique?: boolean;
|
|
72
86
|
}
|
|
@@ -132,6 +146,148 @@ export function isAuthoringFieldPresetDescriptor(
|
|
|
132
146
|
);
|
|
133
147
|
}
|
|
134
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
|
|
151
|
+
*
|
|
152
|
+
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
|
|
153
|
+
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
|
|
154
|
+
* registration must NOT be treated as a "namespace" with sub-paths. Callers
|
|
155
|
+
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
|
|
156
|
+
*/
|
|
157
|
+
export function hasRegisteredFieldNamespace(
|
|
158
|
+
contributions: AuthoringContributions | undefined,
|
|
159
|
+
namespace: string,
|
|
160
|
+
): boolean {
|
|
161
|
+
if (contributions?.field === undefined || !Object.hasOwn(contributions.field, namespace)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return !isAuthoringFieldPresetDescriptor(contributions.field[namespace]);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function isPlainNamespaceObject(value: unknown): value is Record<string, unknown> {
|
|
168
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Merges `source` into `target` recursively at the descriptor-namespace
|
|
173
|
+
* level. `leafGuard` decides which values are descriptors (terminal
|
|
174
|
+
* merge points; same-path registrations across components are reported
|
|
175
|
+
* as duplicates) versus sub-namespaces (recursion targets).
|
|
176
|
+
*
|
|
177
|
+
* Path segments are validated against prototype-pollution names
|
|
178
|
+
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
|
|
179
|
+
* recognized leaf nor a plain object — e.g. a malformed descriptor
|
|
180
|
+
* where the canonical leaf guard rejected it for missing `output` —
|
|
181
|
+
* is reported as an invalid contribution rather than recursed into,
|
|
182
|
+
* which would either silently mangle state or infinite-loop on
|
|
183
|
+
* primitive properties.
|
|
184
|
+
*
|
|
185
|
+
* Within-registry duplicate detection is this walker's job;
|
|
186
|
+
* cross-registry detection runs separately via
|
|
187
|
+
* `assertNoCrossRegistryCollisions` after merging completes.
|
|
188
|
+
*/
|
|
189
|
+
export function mergeAuthoringNamespaces(
|
|
190
|
+
target: Record<string, unknown>,
|
|
191
|
+
source: Record<string, unknown>,
|
|
192
|
+
path: readonly string[],
|
|
193
|
+
leafGuard: (value: unknown) => boolean,
|
|
194
|
+
label: string,
|
|
195
|
+
): void {
|
|
196
|
+
const assertSafePath = (currentPath: readonly string[]) => {
|
|
197
|
+
const blockedSegment = currentPath.find(
|
|
198
|
+
(segment) => segment === '__proto__' || segment === 'constructor' || segment === 'prototype',
|
|
199
|
+
);
|
|
200
|
+
if (blockedSegment) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`Invalid authoring ${label} helper "${currentPath.join('.')}". Helper path segments must not use "${blockedSegment}".`,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
for (const [key, sourceValue] of Object.entries(source)) {
|
|
208
|
+
const currentPath = [...path, key];
|
|
209
|
+
assertSafePath(currentPath);
|
|
210
|
+
const hasExistingValue = Object.hasOwn(target, key);
|
|
211
|
+
const existingValue = hasExistingValue ? target[key] : undefined;
|
|
212
|
+
|
|
213
|
+
if (!hasExistingValue) {
|
|
214
|
+
target[key] = sourceValue;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const existingIsLeaf = leafGuard(existingValue);
|
|
219
|
+
const sourceIsLeaf = leafGuard(sourceValue);
|
|
220
|
+
|
|
221
|
+
if (existingIsLeaf || sourceIsLeaf) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Duplicate authoring ${label} helper "${currentPath.join('.')}". Helper names must be unique across composed packs.`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!isPlainNamespaceObject(existingValue) || !isPlainNamespaceObject(sourceValue)) {
|
|
228
|
+
throw new Error(
|
|
229
|
+
`Invalid authoring ${label} helper "${currentPath.join('.')}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, leafGuard, label);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function collectAuthoringLeafPaths(
|
|
238
|
+
namespace: Readonly<Record<string, unknown>>,
|
|
239
|
+
isLeaf: (value: unknown) => boolean,
|
|
240
|
+
path: readonly string[] = [],
|
|
241
|
+
): string[] {
|
|
242
|
+
const paths: string[] = [];
|
|
243
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
244
|
+
const currentPath = [...path, key];
|
|
245
|
+
if (isLeaf(value)) {
|
|
246
|
+
paths.push(currentPath.join('.'));
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
250
|
+
paths.push(
|
|
251
|
+
...collectAuthoringLeafPaths(
|
|
252
|
+
value as Readonly<Record<string, unknown>>,
|
|
253
|
+
isLeaf,
|
|
254
|
+
currentPath,
|
|
255
|
+
),
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return paths;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function assertNoCrossRegistryCollisions(
|
|
263
|
+
typeNamespace: AuthoringTypeNamespace,
|
|
264
|
+
fieldNamespace: AuthoringFieldNamespace,
|
|
265
|
+
): void {
|
|
266
|
+
const typePaths = new Set(
|
|
267
|
+
collectAuthoringLeafPaths(typeNamespace, isAuthoringTypeConstructorDescriptor),
|
|
268
|
+
);
|
|
269
|
+
// Within-registry duplicate detection is handled upstream by the merge
|
|
270
|
+
// walker (`mergeAuthoringNamespaces` in control-stack.ts and
|
|
271
|
+
// `mergeHelperNamespaces` in composed-authoring-helpers.ts), which throws
|
|
272
|
+
// on same-path registrations within either registry before this check
|
|
273
|
+
// runs. This function only handles the cross-registry case — and an
|
|
274
|
+
// empty type namespace makes a cross-registry collision structurally
|
|
275
|
+
// impossible, so the early-out is sound.
|
|
276
|
+
if (typePaths.size === 0) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
for (const fieldPath of collectAuthoringLeafPaths(
|
|
280
|
+
fieldNamespace,
|
|
281
|
+
isAuthoringFieldPresetDescriptor,
|
|
282
|
+
)) {
|
|
283
|
+
if (typePaths.has(fieldPath)) {
|
|
284
|
+
throw new Error(
|
|
285
|
+
`Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. Register each path in only one of authoringContributions.field / authoringContributions.type.`,
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
135
291
|
export function resolveAuthoringTemplateValue(
|
|
136
292
|
template: AuthoringTemplateValue,
|
|
137
293
|
args: readonly unknown[],
|
|
@@ -295,20 +451,17 @@ function resolveAuthoringStorageTypeTemplate(
|
|
|
295
451
|
function resolveAuthoringColumnDefaultTemplate(
|
|
296
452
|
template: AuthoringColumnDefaultTemplate,
|
|
297
453
|
args: readonly unknown[],
|
|
298
|
-
):
|
|
299
|
-
| {
|
|
300
|
-
readonly kind: 'literal';
|
|
301
|
-
readonly value: unknown;
|
|
302
|
-
}
|
|
303
|
-
| {
|
|
304
|
-
readonly kind: 'function';
|
|
305
|
-
readonly expression: string;
|
|
306
|
-
} {
|
|
454
|
+
): ColumnDefault {
|
|
307
455
|
if (template.kind === 'literal') {
|
|
308
456
|
const value = resolveAuthoringTemplateValue(template.value, args);
|
|
309
457
|
if (value === undefined) {
|
|
310
458
|
throw new Error('Resolved authoring literal default must not be undefined');
|
|
311
459
|
}
|
|
460
|
+
if (!isColumnDefaultLiteralInputValue(value)) {
|
|
461
|
+
throw new Error(
|
|
462
|
+
`Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`,
|
|
463
|
+
);
|
|
464
|
+
}
|
|
312
465
|
return {
|
|
313
466
|
kind: 'literal',
|
|
314
467
|
value,
|
|
@@ -327,6 +480,40 @@ function resolveAuthoringColumnDefaultTemplate(
|
|
|
327
480
|
};
|
|
328
481
|
}
|
|
329
482
|
|
|
483
|
+
function resolveExecutionMutationDefaultPhase(
|
|
484
|
+
phase: 'onCreate' | 'onUpdate',
|
|
485
|
+
template: AuthoringTemplateValue,
|
|
486
|
+
args: readonly unknown[],
|
|
487
|
+
): ExecutionMutationDefaultValue {
|
|
488
|
+
const value = resolveAuthoringTemplateValue(template, args);
|
|
489
|
+
if (!isExecutionMutationDefaultValue(value)) {
|
|
490
|
+
throw new Error(
|
|
491
|
+
`Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`,
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function resolveAuthoringExecutionDefaultsTemplate(
|
|
498
|
+
template: AuthoringExecutionDefaultsTemplate,
|
|
499
|
+
args: readonly unknown[],
|
|
500
|
+
): ExecutionMutationDefaultPhases {
|
|
501
|
+
return {
|
|
502
|
+
...ifDefined(
|
|
503
|
+
'onCreate',
|
|
504
|
+
template.onCreate !== undefined
|
|
505
|
+
? resolveExecutionMutationDefaultPhase('onCreate', template.onCreate, args)
|
|
506
|
+
: undefined,
|
|
507
|
+
),
|
|
508
|
+
...ifDefined(
|
|
509
|
+
'onUpdate',
|
|
510
|
+
template.onUpdate !== undefined
|
|
511
|
+
? resolveExecutionMutationDefaultPhase('onUpdate', template.onUpdate, args)
|
|
512
|
+
: undefined,
|
|
513
|
+
),
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
330
517
|
export function instantiateAuthoringTypeConstructor(
|
|
331
518
|
descriptor: AuthoringTypeConstructorDescriptor,
|
|
332
519
|
args: readonly unknown[],
|
|
@@ -348,16 +535,8 @@ export function instantiateAuthoringFieldPreset(
|
|
|
348
535
|
readonly typeParams?: Record<string, unknown>;
|
|
349
536
|
};
|
|
350
537
|
readonly nullable: boolean;
|
|
351
|
-
readonly default?:
|
|
352
|
-
|
|
353
|
-
readonly kind: 'literal';
|
|
354
|
-
readonly value: unknown;
|
|
355
|
-
}
|
|
356
|
-
| {
|
|
357
|
-
readonly kind: 'function';
|
|
358
|
-
readonly expression: string;
|
|
359
|
-
};
|
|
360
|
-
readonly executionDefault?: unknown;
|
|
538
|
+
readonly default?: ColumnDefault;
|
|
539
|
+
readonly executionDefaults?: ExecutionMutationDefaultPhases;
|
|
361
540
|
readonly id: boolean;
|
|
362
541
|
readonly unique: boolean;
|
|
363
542
|
} {
|
|
@@ -371,9 +550,9 @@ export function instantiateAuthoringFieldPreset(
|
|
|
371
550
|
: undefined,
|
|
372
551
|
),
|
|
373
552
|
...ifDefined(
|
|
374
|
-
'
|
|
375
|
-
descriptor.output.
|
|
376
|
-
?
|
|
553
|
+
'executionDefaults',
|
|
554
|
+
descriptor.output.executionDefaults !== undefined
|
|
555
|
+
? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args)
|
|
377
556
|
: undefined,
|
|
378
557
|
),
|
|
379
558
|
id: descriptor.output.id ?? false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyCodecDescriptor } from './codec-descriptor';
|
|
2
2
|
import type { AuthoringContributions } from './framework-authoring';
|
|
3
3
|
import type { ControlMutationDefaults } from './mutation-default-types';
|
|
4
4
|
import type { TypesImportSpec } from './types-import-spec';
|
|
@@ -13,10 +13,7 @@ export interface ComponentMetadata {
|
|
|
13
13
|
/**
|
|
14
14
|
* Capabilities this component provides.
|
|
15
15
|
*
|
|
16
|
-
* For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into
|
|
17
|
-
* the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);
|
|
18
|
-
* keep these declarations in sync. Targets are identifiers/descriptors and typically do not
|
|
19
|
-
* declare capabilities.
|
|
16
|
+
* For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`); keep these declarations in sync. Targets are identifiers/descriptors and typically do not declare capabilities.
|
|
20
17
|
*/
|
|
21
18
|
readonly capabilities?: Record<string, unknown>;
|
|
22
19
|
|
|
@@ -24,29 +21,25 @@ export interface ComponentMetadata {
|
|
|
24
21
|
readonly types?: {
|
|
25
22
|
readonly codecTypes?: {
|
|
26
23
|
/**
|
|
27
|
-
* Base codec types import spec.
|
|
28
|
-
* Optional: adapters typically provide this, extensions usually don't.
|
|
24
|
+
* Base codec types import spec. Optional: adapters typically provide this, extensions usually don't.
|
|
29
25
|
*/
|
|
30
26
|
readonly import?: TypesImportSpec;
|
|
31
27
|
/**
|
|
32
28
|
* Additional type-only imports for parameterized codec branded types.
|
|
33
29
|
*
|
|
34
|
-
* These imports are included in generated `contract.d.ts` but are NOT treated as
|
|
35
|
-
* codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
|
|
30
|
+
* These imports are included in generated `contract.d.ts` but are NOT treated as codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
|
|
36
31
|
*
|
|
37
32
|
* Example: `Vector<N>` for pgvector codecs that emit `Vector<1536>`
|
|
38
33
|
*/
|
|
39
34
|
readonly typeImports?: ReadonlyArray<TypesImportSpec>;
|
|
40
35
|
/**
|
|
41
|
-
* Optional control-plane hooks keyed by codecId.
|
|
42
|
-
* Used by family-specific planners/verifiers to handle storage types.
|
|
36
|
+
* Optional control-plane hooks keyed by codecId. Used by family-specific planners/verifiers to handle storage types.
|
|
43
37
|
*/
|
|
44
38
|
readonly controlPlaneHooks?: Record<string, unknown>;
|
|
45
39
|
/**
|
|
46
|
-
* Codec
|
|
47
|
-
* Used to build a CodecLookup for codec-dispatched type rendering during emission.
|
|
40
|
+
* Codec descriptors contributed by this component. Source of truth for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`, `renderOutputType`) consumed by `extractCodecLookup`, and used to materialize representative `Codec` instances for codec-dispatched type rendering during emission.
|
|
48
41
|
*/
|
|
49
|
-
readonly
|
|
42
|
+
readonly codecDescriptors?: ReadonlyArray<AnyCodecDescriptor>;
|
|
50
43
|
};
|
|
51
44
|
readonly operationTypes?: { readonly import: TypesImportSpec };
|
|
52
45
|
readonly queryOperationTypes?: { readonly import: TypesImportSpec };
|
|
@@ -61,21 +54,17 @@ export interface ComponentMetadata {
|
|
|
61
54
|
/**
|
|
62
55
|
* Optional pure-data authoring contributions exposed by this component.
|
|
63
56
|
*
|
|
64
|
-
* These contributions are safe to include on pack refs and descriptors because
|
|
65
|
-
* they contain only declarative metadata. Higher-level authoring packages may
|
|
66
|
-
* project them into concrete helper functions for TS-first workflows.
|
|
57
|
+
* These contributions are safe to include on pack refs and descriptors because they contain only declarative metadata. Higher-level authoring packages may project them into concrete helper functions for TS-first workflows.
|
|
67
58
|
*/
|
|
68
59
|
readonly authoring?: AuthoringContributions;
|
|
69
60
|
|
|
70
61
|
/**
|
|
71
|
-
* Scalar type name to codec ID mapping contributed by this component.
|
|
72
|
-
* Assembled by `createControlStack` with duplicate detection.
|
|
62
|
+
* Scalar type name to codec ID mapping contributed by this component. Assembled by `createControlStack` with duplicate detection.
|
|
73
63
|
*/
|
|
74
64
|
readonly scalarTypeDescriptors?: ReadonlyMap<string, string>;
|
|
75
65
|
|
|
76
66
|
/**
|
|
77
|
-
* Mutation default function handlers and generator descriptors contributed
|
|
78
|
-
* by this component. Assembled by `createControlStack` with duplicate detection.
|
|
67
|
+
* Mutation default function handlers and generator descriptors contributed by this component. Assembled by `createControlStack` with duplicate detection.
|
|
79
68
|
*/
|
|
80
69
|
readonly controlMutationDefaults?: ControlMutationDefaults;
|
|
81
70
|
}
|
|
@@ -83,13 +72,9 @@ export interface ComponentMetadata {
|
|
|
83
72
|
/**
|
|
84
73
|
* Base descriptor for any framework component.
|
|
85
74
|
*
|
|
86
|
-
* All component descriptors share these fundamental properties that identify
|
|
87
|
-
* the component and provide its metadata. This interface is extended by
|
|
88
|
-
* specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
|
|
75
|
+
* All component descriptors share these fundamental properties that identify the component and provide its metadata. This interface is extended by specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
|
|
89
76
|
*
|
|
90
|
-
* @template Kind - Discriminator literal identifying the component type.
|
|
91
|
-
* Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',
|
|
92
|
-
* but the type accepts any string to allow ecosystem extensions.
|
|
77
|
+
* @template Kind - Discriminator literal identifying the component type. Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension', but the type accepts any string to allow ecosystem extensions.
|
|
93
78
|
*
|
|
94
79
|
* @example
|
|
95
80
|
* ```ts
|
|
@@ -163,14 +148,12 @@ export function checkContractComponentRequirements(
|
|
|
163
148
|
/**
|
|
164
149
|
* Descriptor for a family component.
|
|
165
150
|
*
|
|
166
|
-
* A "family" represents a category of data sources with shared semantics
|
|
167
|
-
* (e.g., SQL databases, document stores). Families define:
|
|
151
|
+
* A "family" represents a category of data sources with shared semantics (e.g., SQL databases, document stores). Families define:
|
|
168
152
|
* - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)
|
|
169
153
|
* - Contract structure (tables vs collections, columns vs fields)
|
|
170
154
|
* - Type system and codecs
|
|
171
155
|
*
|
|
172
|
-
* Families are the top-level grouping. Each family contains multiple targets
|
|
173
|
-
* (e.g., SQL family contains Postgres, MySQL, SQLite targets).
|
|
156
|
+
* Families are the top-level grouping. Each family contains multiple targets (e.g., SQL family contains Postgres, MySQL, SQLite targets).
|
|
174
157
|
*
|
|
175
158
|
* Extended by plane-specific descriptors:
|
|
176
159
|
* - `ControlFamilyDescriptor` - adds `emission` for CLI/tooling operations
|
|
@@ -195,13 +178,11 @@ export interface FamilyDescriptor<TFamilyId extends string> extends ComponentDes
|
|
|
195
178
|
/**
|
|
196
179
|
* Descriptor for a target component.
|
|
197
180
|
*
|
|
198
|
-
* A "target" represents a specific database or data store within a family
|
|
199
|
-
* (e.g., Postgres, MySQL, MongoDB). Targets define:
|
|
181
|
+
* A "target" represents a specific database or data store within a family (e.g., Postgres, MySQL, MongoDB). Targets define:
|
|
200
182
|
* - Native type mappings (e.g., Postgres int4 → TypeScript number)
|
|
201
183
|
* - Target-specific capabilities (e.g., RETURNING, LATERAL joins)
|
|
202
184
|
*
|
|
203
|
-
* Targets are bound to a family and provide the target-specific implementation
|
|
204
|
-
* details that adapters and drivers use.
|
|
185
|
+
* Targets are bound to a family and provide the target-specific implementation details that adapters and drivers use.
|
|
205
186
|
*
|
|
206
187
|
* Extended by plane-specific descriptors:
|
|
207
188
|
* - `ControlTargetDescriptor` - adds optional `migrations` capability
|
|
@@ -229,8 +210,7 @@ export interface TargetDescriptor<TFamilyId extends string, TTargetId extends st
|
|
|
229
210
|
}
|
|
230
211
|
|
|
231
212
|
/**
|
|
232
|
-
* Base shape for any pack reference.
|
|
233
|
-
* Pack refs are pure JSON-friendly objects safe to import in authoring flows.
|
|
213
|
+
* Base shape for any pack reference. Pack refs are pure JSON-friendly objects safe to import in authoring flows.
|
|
234
214
|
*/
|
|
235
215
|
export interface PackRefBase<Kind extends string, TFamilyId extends string>
|
|
236
216
|
extends ComponentMetadata {
|
|
@@ -274,14 +254,12 @@ export type DriverPackRef<
|
|
|
274
254
|
/**
|
|
275
255
|
* Descriptor for an adapter component.
|
|
276
256
|
*
|
|
277
|
-
* An "adapter" provides the protocol and dialect implementation for a target.
|
|
278
|
-
* Adapters handle:
|
|
257
|
+
* An "adapter" provides the protocol and dialect implementation for a target. Adapters handle:
|
|
279
258
|
* - SQL/query generation (lowering AST to target-specific syntax)
|
|
280
259
|
* - Codec registration (encoding/decoding between JS and wire types)
|
|
281
260
|
* - Type mappings and coercions
|
|
282
261
|
*
|
|
283
|
-
* Adapters are bound to a specific family+target combination and work with
|
|
284
|
-
* any compatible driver for that target.
|
|
262
|
+
* Adapters are bound to a specific family+target combination and work with any compatible driver for that target.
|
|
285
263
|
*
|
|
286
264
|
* Extended by plane-specific descriptors:
|
|
287
265
|
* - `ControlAdapterDescriptor` - control-plane factory
|
|
@@ -311,16 +289,13 @@ export interface AdapterDescriptor<TFamilyId extends string, TTargetId extends s
|
|
|
311
289
|
/**
|
|
312
290
|
* Descriptor for a driver component.
|
|
313
291
|
*
|
|
314
|
-
* A "driver" provides the connection and execution layer for a target.
|
|
315
|
-
* Drivers handle:
|
|
292
|
+
* A "driver" provides the connection and execution layer for a target. Drivers handle:
|
|
316
293
|
* - Connection management (pooling, timeouts, retries)
|
|
317
294
|
* - Query execution (sending SQL/commands, receiving results)
|
|
318
295
|
* - Transaction management
|
|
319
296
|
* - Wire protocol communication
|
|
320
297
|
*
|
|
321
|
-
* Drivers are bound to a specific family+target and work with any compatible
|
|
322
|
-
* adapter. Multiple drivers can exist for the same target (e.g., node-postgres
|
|
323
|
-
* vs postgres.js for Postgres).
|
|
298
|
+
* Drivers are bound to a specific family+target and work with any compatible adapter. Multiple drivers can exist for the same target (e.g., node-postgres vs postgres.js for Postgres).
|
|
324
299
|
*
|
|
325
300
|
* Extended by plane-specific descriptors:
|
|
326
301
|
* - `ControlDriverDescriptor` - creates driver from connection URL
|
|
@@ -355,8 +330,7 @@ export interface DriverDescriptor<TFamilyId extends string, TTargetId extends st
|
|
|
355
330
|
* - Custom types and codecs (e.g., vector type)
|
|
356
331
|
* - Extended query capabilities
|
|
357
332
|
*
|
|
358
|
-
* Extensions are bound to a specific family+target and are registered in the
|
|
359
|
-
* config alongside the core components. Multiple extensions can be used together.
|
|
333
|
+
* Extensions are bound to a specific family+target and are registered in the config alongside the core components. Multiple extensions can be used together.
|
|
360
334
|
*
|
|
361
335
|
* Extended by plane-specific descriptors:
|
|
362
336
|
* - `ControlExtensionDescriptor` - control-plane extension factory
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ColumnDefault,
|
|
3
|
+
ExecutionMutationDefaultPhases,
|
|
4
|
+
ExecutionMutationDefaultValue,
|
|
5
|
+
} from '@prisma-next/contract/types';
|
|
2
6
|
|
|
3
7
|
interface SourcePosition {
|
|
4
8
|
readonly offset: number;
|
|
@@ -60,7 +64,16 @@ export type DefaultFunctionRegistry = ReadonlyMap<string, DefaultFunctionRegistr
|
|
|
60
64
|
|
|
61
65
|
export interface MutationDefaultGeneratorDescriptor {
|
|
62
66
|
readonly id: string;
|
|
63
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Codec ids the generator is compatible with when the codec choice
|
|
69
|
+
* and the generator choice are made independently by the contract
|
|
70
|
+
* author. Set when the registry-coherence check is meaningful
|
|
71
|
+
* (the codec and the generator can be paired arbitrarily by the
|
|
72
|
+
* caller); omitted when the generator is only reachable through a
|
|
73
|
+
* descriptor that co-registers a fixed codec, so coherence is
|
|
74
|
+
* structural and the list would be tautological.
|
|
75
|
+
*/
|
|
76
|
+
readonly applicableCodecIds?: readonly string[];
|
|
64
77
|
readonly resolveGeneratedColumnDescriptor?: (input: {
|
|
65
78
|
readonly generated: ExecutionMutationDefaultValue;
|
|
66
79
|
}) =>
|
|
@@ -71,6 +84,13 @@ export interface MutationDefaultGeneratorDescriptor {
|
|
|
71
84
|
readonly typeParams?: Record<string, unknown>;
|
|
72
85
|
}
|
|
73
86
|
| undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Construct the `onCreate`/`onUpdate` phases value owned by this
|
|
89
|
+
* generator. Authoring layers (PSL `temporal.updatedAt()`, TS field presets) call
|
|
90
|
+
* this instead of building the literal inline so PSL/TS-authored
|
|
91
|
+
* contracts stay byte-equivalent for any future params-bearing generator.
|
|
92
|
+
*/
|
|
93
|
+
readonly buildPhases?: (args?: Record<string, unknown>) => ExecutionMutationDefaultPhases;
|
|
74
94
|
}
|
|
75
95
|
|
|
76
96
|
export interface ControlMutationDefaultEntry {
|
package/dist/authoring.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authoring.mjs","names":["resolved: Record<string, unknown>"],"sources":["../src/framework-authoring.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\n\nexport type AuthoringArgRef = {\n readonly kind: 'arg';\n readonly index: number;\n readonly path?: readonly string[];\n readonly default?: AuthoringTemplateValue;\n};\n\nexport type AuthoringTemplateValue =\n | string\n | number\n | boolean\n | null\n | AuthoringArgRef\n | readonly AuthoringTemplateValue[]\n | { readonly [key: string]: AuthoringTemplateValue };\n\ninterface AuthoringArgumentDescriptorCommon {\n readonly name?: string;\n readonly optional?: boolean;\n}\n\nexport type AuthoringArgumentDescriptor = AuthoringArgumentDescriptorCommon &\n (\n | { readonly kind: 'string' }\n | {\n readonly kind: 'number';\n readonly integer?: boolean;\n readonly minimum?: number;\n readonly maximum?: number;\n }\n | { readonly kind: 'stringArray' }\n | {\n readonly kind: 'object';\n readonly properties: Record<string, AuthoringArgumentDescriptor>;\n }\n );\n\nexport interface AuthoringStorageTypeTemplate {\n readonly codecId: string;\n readonly nativeType: AuthoringTemplateValue;\n readonly typeParams?: Record<string, AuthoringTemplateValue>;\n}\n\nexport interface AuthoringTypeConstructorDescriptor {\n readonly kind: 'typeConstructor';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringStorageTypeTemplate;\n}\n\nexport interface AuthoringColumnDefaultTemplateLiteral {\n readonly kind: 'literal';\n readonly value: AuthoringTemplateValue;\n}\n\nexport interface AuthoringColumnDefaultTemplateFunction {\n readonly kind: 'function';\n readonly expression: AuthoringTemplateValue;\n}\n\nexport type AuthoringColumnDefaultTemplate =\n | AuthoringColumnDefaultTemplateLiteral\n | AuthoringColumnDefaultTemplateFunction;\n\nexport interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {\n readonly nullable?: boolean;\n readonly default?: AuthoringColumnDefaultTemplate;\n readonly executionDefault?: AuthoringTemplateValue;\n readonly id?: boolean;\n readonly unique?: boolean;\n}\n\nexport interface AuthoringFieldPresetDescriptor {\n readonly kind: 'fieldPreset';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringFieldPresetOutput;\n}\n\nexport type AuthoringTypeNamespace = {\n readonly [name: string]: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace;\n};\n\nexport type AuthoringFieldNamespace = {\n readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;\n};\n\nexport interface AuthoringContributions {\n readonly type?: AuthoringTypeNamespace;\n readonly field?: AuthoringFieldNamespace;\n}\n\nexport function isAuthoringArgRef(value: unknown): value is AuthoringArgRef {\n if (typeof value !== 'object' || value === null || (value as { kind?: unknown }).kind !== 'arg') {\n return false;\n }\n const { index, path } = value as { index?: unknown; path?: unknown };\n if (typeof index !== 'number' || !Number.isInteger(index) || index < 0) {\n return false;\n }\n if (path !== undefined && (!Array.isArray(path) || path.some((s) => typeof s !== 'string'))) {\n return false;\n }\n return true;\n}\n\nfunction isAuthoringTemplateRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function isAuthoringTypeConstructorDescriptor(\n value: unknown,\n): value is AuthoringTypeConstructorDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'typeConstructor' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function isAuthoringFieldPresetDescriptor(\n value: unknown,\n): value is AuthoringFieldPresetDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'fieldPreset' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function resolveAuthoringTemplateValue(\n template: AuthoringTemplateValue,\n args: readonly unknown[],\n): unknown {\n if (isAuthoringArgRef(template)) {\n let value = args[template.index];\n\n for (const segment of template.path ?? []) {\n if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) {\n value = undefined;\n break;\n }\n value = (value as Record<string, unknown>)[segment];\n }\n\n if (value === undefined && template.default !== undefined) {\n return resolveAuthoringTemplateValue(template.default, args);\n }\n\n return value;\n }\n if (Array.isArray(template)) {\n return template.map((value) => resolveAuthoringTemplateValue(value, args));\n }\n if (typeof template === 'object' && template !== null) {\n const resolved: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(template)) {\n const resolvedValue = resolveAuthoringTemplateValue(value, args);\n if (resolvedValue !== undefined) {\n resolved[key] = resolvedValue;\n }\n }\n return resolved;\n }\n return template;\n}\n\nfunction validateAuthoringArgument(\n descriptor: AuthoringArgumentDescriptor,\n value: unknown,\n path: string,\n): void {\n if (value === undefined) {\n if (descriptor.optional) {\n return;\n }\n throw new Error(`Missing required authoring helper argument at ${path}`);\n }\n\n if (descriptor.kind === 'string') {\n if (typeof value !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be a string`);\n }\n return;\n }\n\n if (descriptor.kind === 'stringArray') {\n if (!Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n }\n return;\n }\n\n if (descriptor.kind === 'object') {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an object`);\n }\n\n const input = value as Record<string, unknown>;\n const expectedKeys = new Set(Object.keys(descriptor.properties));\n\n for (const key of Object.keys(input)) {\n if (!expectedKeys.has(key)) {\n throw new Error(`Authoring helper argument at ${path} contains unknown property \"${key}\"`);\n }\n }\n\n for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) {\n validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);\n }\n\n return;\n }\n\n if (typeof value !== 'number' || Number.isNaN(value)) {\n throw new Error(`Authoring helper argument at ${path} must be a number`);\n }\n\n if (descriptor.integer && !Number.isInteger(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an integer`);\n }\n if (descriptor.minimum !== undefined && value < descriptor.minimum) {\n throw new Error(\n `Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`,\n );\n }\n if (descriptor.maximum !== undefined && value > descriptor.maximum) {\n throw new Error(\n `Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`,\n );\n }\n}\n\nexport function validateAuthoringHelperArguments(\n helperPath: string,\n descriptors: readonly AuthoringArgumentDescriptor[] | undefined,\n args: readonly unknown[],\n): void {\n const expected = descriptors ?? [];\n const minimumArgs = expected.reduce(\n (count, descriptor, index) => (descriptor.optional ? count : index + 1),\n 0,\n );\n if (args.length < minimumArgs || args.length > expected.length) {\n throw new Error(\n `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`,\n );\n }\n\n expected.forEach((descriptor, index) => {\n validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);\n });\n}\n\nfunction resolveAuthoringStorageTypeTemplate(\n template: AuthoringStorageTypeTemplate,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n const nativeType = resolveAuthoringTemplateValue(template.nativeType, args);\n if (typeof nativeType !== 'string') {\n throw new Error(\n `Resolved authoring nativeType must be a string for codec \"${template.codecId}\", received ${String(nativeType)}`,\n );\n }\n const typeParams =\n template.typeParams === undefined\n ? undefined\n : resolveAuthoringTemplateValue(template.typeParams, args);\n if (typeParams !== undefined && !isAuthoringTemplateRecord(typeParams)) {\n throw new Error(\n `Resolved authoring typeParams must be an object for codec \"${template.codecId}\", received ${String(typeParams)}`,\n );\n }\n\n return {\n codecId: template.codecId,\n nativeType,\n ...(typeParams === undefined ? {} : { typeParams }),\n };\n}\n\nfunction resolveAuthoringColumnDefaultTemplate(\n template: AuthoringColumnDefaultTemplate,\n args: readonly unknown[],\n):\n | {\n readonly kind: 'literal';\n readonly value: unknown;\n }\n | {\n readonly kind: 'function';\n readonly expression: string;\n } {\n if (template.kind === 'literal') {\n const value = resolveAuthoringTemplateValue(template.value, args);\n if (value === undefined) {\n throw new Error('Resolved authoring literal default must not be undefined');\n }\n return {\n kind: 'literal',\n value,\n };\n }\n\n const expression = resolveAuthoringTemplateValue(template.expression, args);\n if (expression === undefined || (typeof expression === 'object' && expression !== null)) {\n throw new Error(\n `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`,\n );\n }\n return {\n kind: 'function',\n expression: String(expression),\n };\n}\n\nexport function instantiateAuthoringTypeConstructor(\n descriptor: AuthoringTypeConstructorDescriptor,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n return resolveAuthoringStorageTypeTemplate(descriptor.output, args);\n}\n\nexport function instantiateAuthoringFieldPreset(\n descriptor: AuthoringFieldPresetDescriptor,\n args: readonly unknown[],\n): {\n readonly descriptor: {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n };\n readonly nullable: boolean;\n readonly default?:\n | {\n readonly kind: 'literal';\n readonly value: unknown;\n }\n | {\n readonly kind: 'function';\n readonly expression: string;\n };\n readonly executionDefault?: unknown;\n readonly id: boolean;\n readonly unique: boolean;\n} {\n return {\n descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),\n nullable: descriptor.output.nullable ?? false,\n ...ifDefined(\n 'default',\n descriptor.output.default !== undefined\n ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args)\n : undefined,\n ),\n ...ifDefined(\n 'executionDefault',\n descriptor.output.executionDefault !== undefined\n ? resolveAuthoringTemplateValue(descriptor.output.executionDefault, args)\n : undefined,\n ),\n id: descriptor.output.id ?? false,\n unique: descriptor.output.unique ?? false,\n };\n}\n"],"mappings":"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"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { JsonValue } from "@prisma-next/contract/types";
|
|
2
|
-
|
|
3
|
-
//#region src/codec-types.d.ts
|
|
4
|
-
type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
|
|
5
|
-
/**
|
|
6
|
-
* Base codec interface for all target families.
|
|
7
|
-
*
|
|
8
|
-
* A codec maps between three representations of a value:
|
|
9
|
-
* - **JS** (`TJs`): the JavaScript type used in application code
|
|
10
|
-
* - **Wire** (`TWire`): the format sent to/from the database driver
|
|
11
|
-
* - **JSON** (`JsonValue`): the JSON-safe form stored in contract artifacts
|
|
12
|
-
*
|
|
13
|
-
* Family-specific codec interfaces (SQL `Codec`, Mongo `MongoCodec`) extend
|
|
14
|
-
* this base to add family-specific metadata.
|
|
15
|
-
*/
|
|
16
|
-
interface Codec<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TJs = unknown> {
|
|
17
|
-
/** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). */
|
|
18
|
-
readonly id: Id;
|
|
19
|
-
/** Database-native type names this codec handles (e.g. `['timestamptz']`). */
|
|
20
|
-
readonly targetTypes: readonly string[];
|
|
21
|
-
/** Semantic traits for operator gating (e.g. equality, order, numeric). */
|
|
22
|
-
readonly traits?: TTraits;
|
|
23
|
-
/** Converts a JS value to the wire format expected by the database driver. Optional when the driver accepts the JS type directly. */
|
|
24
|
-
encode?(value: TJs): TWire;
|
|
25
|
-
/** Converts a wire value from the database driver into the JS type. */
|
|
26
|
-
decode(wire: TWire): TJs;
|
|
27
|
-
/** Converts a JS value to a JSON-safe representation for contract serialization. Called during contract emission. */
|
|
28
|
-
encodeJson(value: TJs): JsonValue;
|
|
29
|
-
/** Converts a JSON representation back to the JS type. Called during contract loading via `validateContract`. */
|
|
30
|
-
decodeJson(json: JsonValue): TJs;
|
|
31
|
-
/** Produces the TypeScript output type expression for a field given its `typeParams`. Used during contract.d.ts emission. */
|
|
32
|
-
renderOutputType?(typeParams: Record<string, unknown>): string | undefined;
|
|
33
|
-
}
|
|
34
|
-
interface CodecLookup {
|
|
35
|
-
get(id: string): Codec | undefined;
|
|
36
|
-
}
|
|
37
|
-
declare const emptyCodecLookup: CodecLookup;
|
|
38
|
-
//#endregion
|
|
39
|
-
export { emptyCodecLookup as i, CodecLookup as n, CodecTrait as r, Codec as t };
|
|
40
|
-
//# sourceMappingURL=codec-types-B58nCJiu.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec-types-B58nCJiu.d.mts","names":[],"sources":["../src/codec-types.ts"],"sourcesContent":[],"mappings":";;;KAEY,UAAA;;AAAZ;AAaA;;;;;;;;;AAiBoB,UAjBH,KAiBG,CAAA,WAAA,MAAA,GAAA,MAAA,EAAA,gBAAA,SAfO,UAeP,EAAA,GAAA,SAf+B,UAe/B,EAAA,EAAA,QAAA,OAAA,EAAA,MAAA,OAAA,CAAA,CAAA;EAAM;EAEP,SAAA,EAAA,EAZJ,EAYI;EAAY;EAEC,SAAA,WAAA,EAAA,SAAA,MAAA,EAAA;EAAM;EAGrB,SAAA,MAAW,CAAA,EAbR,OAcD;EAGN;iBAfI,MAAM;;eAER,QAAQ;;oBAEH,MAAM;;mBAEP,YAAY;;gCAEC;;UAGf,WAAA;mBACE;;cAGN,kBAAkB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { t as TypesImportSpec } from "./types-import-spec-C4sc7wbb.mjs";
|
|
2
|
-
import { Contract, ContractModel } from "@prisma-next/contract/types";
|
|
3
|
-
|
|
4
|
-
//#region src/emission-types.d.ts
|
|
5
|
-
interface GenerateContractTypesOptions {
|
|
6
|
-
readonly queryOperationTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
7
|
-
}
|
|
8
|
-
interface ValidationContext {
|
|
9
|
-
readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
10
|
-
readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
11
|
-
readonly extensionIds?: ReadonlyArray<string>;
|
|
12
|
-
}
|
|
13
|
-
interface EmissionSpi {
|
|
14
|
-
readonly id: string;
|
|
15
|
-
generateStorageType(contract: Contract, storageHashTypeName: string): string;
|
|
16
|
-
generateModelStorageType(modelName: string, model: ContractModel): string;
|
|
17
|
-
getFamilyImports(): string[];
|
|
18
|
-
getFamilyTypeAliases(options?: GenerateContractTypesOptions): string;
|
|
19
|
-
getTypeMapsExpression(): string;
|
|
20
|
-
getContractWrapper(contractBaseName: string, typeMapsName: string): string;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { GenerateContractTypesOptions as n, ValidationContext as r, EmissionSpi as t };
|
|
24
|
-
//# sourceMappingURL=emission-types-BPAALJbF.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emission-types-BPAALJbF.d.mts","names":[],"sources":["../src/emission-types.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,4BAAA;uCACsB,cAAc;AADrD;AAIiB,UAAA,iBAAA,CAAiB;EACU,SAAA,gBAAA,CAAA,EAAd,aAAc,CAAA,eAAA,CAAA;EAAd,SAAA,oBAAA,CAAA,EACI,aADJ,CACkB,eADlB,CAAA;EACkB,SAAA,YAAA,CAAA,EACtB,aADsB,CAAA,MAAA,CAAA;;AACtB,UAGT,WAAA,CAHS;EAAa,SAAA,EAAA,EAAA,MAAA;EAGtB,mBAAW,CAAA,QAAA,EAGI,QAHJ,EAAA,mBAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAGI,wBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAEqB,aAFrB,CAAA,EAAA,MAAA;EAEqB,gBAAA,EAAA,EAAA,MAAA,EAAA;EAIpB,oBAAA,CAAA,OAAA,CAAA,EAAA,4BAAA,CAAA,EAAA,MAAA;EAA4B,qBAAA,EAAA,EAAA,MAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framework-authoring-D1-JZ37B.d.mts","names":[],"sources":["../src/framework-authoring.ts"],"sourcesContent":[],"mappings":";KAEY,eAAA;EAAA,SAAA,IAAA,EAAA,KAAe;EAOf,SAAA,KAAA,EAAA,MAAA;EAKR,SAAA,IAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EACS,SAAA,OAAA,CAAA,EATQ,sBASR;CACiB;AAAsB,KAPxC,sBAAA,GAOwC,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,IAAA,GAFhD,eAEgD,GAAA,SADvC,sBACuC,EAAA,GAAA;EAE1C,UAAA,GAAA,EAAA,MAAA,CAAA,EAFoB,sBAEa;AAK3C,CAAA;UALU,iCAAA,CAKgC;EAYE,SAAA,IAAA,CAAA,EAAA,MAAA;EAAf,SAAA,QAAA,CAAA,EAAA,OAAA;;AAIZ,KAhBL,2BAAA,GAA8B,iCAgBG,GAAA,CAAA;EAEtB,SAAA,IAAA,EAAA,QAAA;CACgB,GAAA;EAAf,SAAA,IAAA,EAAA,QAAA;EAAM,SAAA,OAAA,CAAA,EAAA,OAAA;EAGb,SAAA,OAAA,CAAA,EAAA,MAAA;EAMA,SAAA,OAAA,CAAA,EAAA,MAAA;AAKjB,CAAA,GAAiB;EAKL,SAAA,IAAA,EAAA,aAAA;AAIZ,CAAA,GAAiB;EAEI,SAAA,IAAA,EAAA,QAAA;EACS,SAAA,UAAA,EAjCD,MAiCC,CAAA,MAAA,EAjCc,2BAiCd,CAAA;CAHsB,CAAA;AAA4B,UA1B/D,4BAAA,CA0B+D;EAQ/D,SAAA,OAAA,EAAA,MAAA;EAML,SAAA,UAAA,EAtCW,sBAuCI;EAGf,SAAA,UAAA,CAAA,EAzCY,MAyCW,CAAA,MAAA,EAzCI,sBA0CZ,CAAA;AAG3B;AAKgB,UA/CC,kCAAA,CA+C2C;EAkB5C,SAAA,IAAA,EAAA,iBAAA;EAYA,SAAA,IAAA,CAAA,EAAA,SA3EW,2BA6Ef,EAAA;EAUI,SAAA,MAAA,EAtFG,4BAuFP;AA2GZ;AAuFgB,UAtRC,qCAAA,CAuRH;EAUE,SAAA,IAAA,EAAA,SAAA;kBA/RE;;UAGD,sCAAA;;uBAEM;;KAGX,8BAAA,GACR,wCACA;UAEa,0BAAA,SAAmC;;qBAE/B;8BACS;;;;UAKb,8BAAA;;2BAEU;mBACR;;KAGP,sBAAA;2BACe,qCAAqC;;KAGpD,uBAAA;2BACe,iCAAiC;;UAG3C,sBAAA;kBACC;mBACC;;iBAGH,iBAAA,2BAA4C;iBAkB5C,oCAAA,2BAEJ;iBAUI,gCAAA,2BAEJ;iBAUI,6BAAA,WACJ;iBA2GI,gCAAA,2CAEQ;iBAqFR,mCAAA,aACF;;;wBAKU;;iBAKR,+BAAA,aACF;;;;0BAMY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framework-components-C8ZhSwXe.mjs","names":[],"sources":["../src/framework-components.ts"],"sourcesContent":["import type { Codec } from './codec-types';\nimport type { AuthoringContributions } from './framework-authoring';\nimport type { ControlMutationDefaults } from './mutation-default-types';\nimport type { TypesImportSpec } from './types-import-spec';\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 * Additional type-only imports for parameterized codec branded types.\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 codecs that emit `Vector<1536>`\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 * Codec instances contributed by this component.\n * Used to build a CodecLookup for codec-dispatched type rendering during emission.\n */\n readonly codecInstances?: ReadonlyArray<Codec>;\n };\n readonly operationTypes?: { readonly import: TypesImportSpec };\n readonly queryOperationTypes?: { 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 * Optional pure-data authoring contributions exposed by this component.\n *\n * These contributions are safe to include on pack refs and descriptors because\n * they contain only declarative metadata. Higher-level authoring packages may\n * project them into concrete helper functions for TS-first workflows.\n */\n readonly authoring?: AuthoringContributions;\n\n /**\n * Scalar type name to codec ID mapping contributed by this component.\n * Assembled by `createControlStack` with duplicate detection.\n */\n readonly scalarTypeDescriptors?: ReadonlyMap<string, string>;\n\n /**\n * Mutation default function handlers and generator descriptors contributed\n * by this component. Assembled by `createControlStack` with duplicate detection.\n */\n readonly controlMutationDefaults?: ControlMutationDefaults;\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 `emission` 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 readonly authoring?: AuthoringContributions;\n}\n\nexport type FamilyPackRef<TFamilyId extends string = string> = PackRefBase<'family', TFamilyId>;\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/** Components bound to a specific family+target combination. */\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\nexport interface FamilyInstance<TFamilyId extends string> {\n readonly familyId: TFamilyId;\n}\n\nexport interface TargetInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface DriverInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n"],"mappings":";AA8HA,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"}
|