@prisma-next/sql-relational-core 0.5.0-dev.60 → 0.5.0-dev.62
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 +45 -47
- package/dist/{errors-p3Ou_n9J.d.mts → errors-Chs-ph28.d.mts} +2 -2
- package/dist/errors-Chs-ph28.d.mts.map +1 -0
- package/dist/{errors-D6kqqjHM.mjs → errors-kgKOaDM1.mjs} +1 -1
- package/dist/{errors-D6kqqjHM.mjs.map → errors-kgKOaDM1.mjs.map} +1 -1
- package/dist/exports/ast.d.mts +141 -87
- package/dist/exports/ast.d.mts.map +1 -1
- package/dist/exports/ast.mjs +242 -272
- package/dist/exports/ast.mjs.map +1 -1
- package/dist/exports/codec-descriptor-registry.d.mts +18 -0
- package/dist/exports/codec-descriptor-registry.d.mts.map +1 -0
- package/dist/exports/codec-descriptor-registry.mjs +40 -0
- package/dist/exports/codec-descriptor-registry.mjs.map +1 -0
- package/dist/exports/errors.d.mts +4 -4
- package/dist/exports/errors.mjs +1 -1
- package/dist/exports/expression.d.mts +29 -24
- package/dist/exports/expression.d.mts.map +1 -1
- package/dist/exports/expression.mjs +33 -11
- package/dist/exports/expression.mjs.map +1 -1
- package/dist/exports/plan.d.mts +2 -2
- package/dist/exports/query-lane-context.d.mts +2 -3
- package/dist/exports/types.d.mts +5 -4
- package/dist/index.d.mts +10 -11
- package/dist/index.mjs +5 -5
- package/dist/{plan-C7SiEWkN.d.mts → plan-nwFE15re.d.mts} +2 -2
- package/dist/plan-nwFE15re.d.mts.map +1 -0
- package/dist/query-lane-context-DlWgKvvt.d.mts +175 -0
- package/dist/query-lane-context-DlWgKvvt.d.mts.map +1 -0
- package/dist/{sql-execution-plan-Dgx7BGin.d.mts → sql-execution-plan-DTfj23Tj.d.mts} +2 -2
- package/dist/{sql-execution-plan-Dgx7BGin.d.mts.map → sql-execution-plan-DTfj23Tj.d.mts.map} +1 -1
- package/dist/{types-DUL-3vy6.mjs → types-CO7zrXfK.mjs} +15 -7
- package/dist/types-CO7zrXfK.mjs.map +1 -0
- package/dist/{types-DviRR7AL.d.mts → types-G3hdNPZZ.d.mts} +4 -4
- package/dist/{types-DviRR7AL.d.mts.map → types-G3hdNPZZ.d.mts.map} +1 -1
- package/dist/{types-B4dL4lc3.d.mts → types-U74HFwNI.d.mts} +22 -4
- package/dist/types-U74HFwNI.d.mts.map +1 -0
- package/dist/{types-BUlUvdIU.d.mts → types-dPxXIUPS.d.mts} +3 -3
- package/dist/{types-BUlUvdIU.d.mts.map → types-dPxXIUPS.d.mts.map} +1 -1
- package/package.json +10 -8
- package/src/ast/adapter-types.ts +3 -19
- package/src/ast/codec-types.ts +53 -541
- package/src/ast/sql-codec-helpers.ts +79 -0
- package/src/ast/sql-codecs.ts +280 -137
- package/src/ast/types.ts +33 -8
- package/src/ast/validate-param-refs.ts +39 -0
- package/src/codec-descriptor-registry.ts +52 -0
- package/src/exports/ast.ts +2 -0
- package/src/exports/codec-descriptor-registry.ts +1 -0
- package/src/expression.ts +40 -23
- package/src/query-lane-context.ts +14 -96
- package/dist/codec-types-DJEaWT36.d.mts +0 -313
- package/dist/codec-types-DJEaWT36.d.mts.map +0 -1
- package/dist/errors-p3Ou_n9J.d.mts.map +0 -1
- package/dist/plan-C7SiEWkN.d.mts.map +0 -1
- package/dist/query-lane-context-Bwca4sc8.d.mts +0 -150
- package/dist/query-lane-context-Bwca4sc8.d.mts.map +0 -1
- package/dist/types-B4dL4lc3.d.mts.map +0 -1
- package/dist/types-DUL-3vy6.mjs.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { CodecDescriptor } from '@prisma-next/framework-components/codec';
|
|
2
|
+
import type { AnyCodecDescriptor } from './ast/codec-types';
|
|
3
|
+
import type { CodecDescriptorRegistry } from './query-lane-context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build a {@link CodecDescriptorRegistry} from a flat descriptor list.
|
|
7
|
+
*
|
|
8
|
+
* Used by:
|
|
9
|
+
* - Each codec-shipping package's `core/registry.ts` to expose a package-scoped registry as the public consumer surface (replacing raw descriptor-array exports). See ADR 208.
|
|
10
|
+
* - The runtime's `buildExecutionContext` to construct the contract-bound combined registry from every contributor's `codecs:` slot.
|
|
11
|
+
*
|
|
12
|
+
* The descriptor map is heterogeneous in `P` — each codec id has its own params shape. The public {@link CodecDescriptorRegistry} interface widens to `CodecDescriptor<unknown>` and consumers narrow per codec id at the call site (the descriptor's `paramsSchema` validates JSON-sourced params before the factory ever sees them, so the runtime narrow is safe). The cast at registration goes through `unknown` because
|
|
13
|
+
* `CodecDescriptor<P>` is invariant in `P` (the `factory` and `renderOutputType` slots use `P` contravariantly).
|
|
14
|
+
*/
|
|
15
|
+
export function buildCodecDescriptorRegistry(
|
|
16
|
+
allDescriptors: ReadonlyArray<AnyCodecDescriptor>,
|
|
17
|
+
): CodecDescriptorRegistry {
|
|
18
|
+
type AnyDescriptor = CodecDescriptor<unknown>;
|
|
19
|
+
const byId = new Map<string, AnyDescriptor>();
|
|
20
|
+
const byTargetType = new Map<string, Array<AnyDescriptor>>();
|
|
21
|
+
|
|
22
|
+
for (const descriptor of allDescriptors) {
|
|
23
|
+
if (byId.has(descriptor.codecId)) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Duplicate codec descriptor id: '${descriptor.codecId}' — registered twice during registry construction. ` +
|
|
26
|
+
'Each codecId must be contributed by exactly one component (target / adapter / extension pack).',
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const widened = descriptor as unknown as AnyDescriptor;
|
|
30
|
+
byId.set(descriptor.codecId, widened);
|
|
31
|
+
for (const targetType of descriptor.targetTypes) {
|
|
32
|
+
const list = byTargetType.get(targetType);
|
|
33
|
+
if (list) {
|
|
34
|
+
list.push(widened);
|
|
35
|
+
} else {
|
|
36
|
+
byTargetType.set(targetType, [widened]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
descriptorFor(codecId: string): AnyDescriptor | undefined {
|
|
43
|
+
return byId.get(codecId);
|
|
44
|
+
},
|
|
45
|
+
*values(): IterableIterator<AnyDescriptor> {
|
|
46
|
+
yield* byId.values();
|
|
47
|
+
},
|
|
48
|
+
byTargetType(targetType: string): readonly AnyDescriptor[] {
|
|
49
|
+
return byTargetType.get(targetType) ?? Object.freeze([]);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
package/src/exports/ast.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from '../ast/adapter-types';
|
|
2
2
|
export * from '../ast/codec-types';
|
|
3
3
|
export * from '../ast/driver-types';
|
|
4
|
+
export * from '../ast/sql-codec-helpers';
|
|
4
5
|
export * from '../ast/sql-codecs';
|
|
5
6
|
export * from '../ast/types';
|
|
6
7
|
export * from '../ast/util';
|
|
8
|
+
export * from '../ast/validate-param-refs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../codec-descriptor-registry';
|
package/src/expression.ts
CHANGED
|
@@ -7,10 +7,7 @@ import { OperationExpr, ParamRef } from './ast/types';
|
|
|
7
7
|
export type ScopeField = { codecId: string; nullable: boolean };
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* A typed SQL expression. Identity is carried by the `returnType` descriptor
|
|
11
|
-
* (inherited from `QueryOperationReturn` and narrowed to `T`) — distinct `T`
|
|
12
|
-
* makes distinct Expression types structurally. `buildAst()` materialises the
|
|
13
|
-
* underlying AST node.
|
|
10
|
+
* A typed SQL expression. Identity is carried by the `returnType` descriptor (inherited from `QueryOperationReturn` and narrowed to `T`) — distinct `T` makes distinct Expression types structurally. `buildAst()` materialises the underlying AST node.
|
|
14
11
|
*/
|
|
15
12
|
export type Expression<T extends ScopeField> = QueryOperationReturn & {
|
|
16
13
|
readonly returnType: T;
|
|
@@ -34,9 +31,9 @@ type NullSuffix<N> = N extends true ? null : never;
|
|
|
34
31
|
* An expression or literal value targeting a specific codec.
|
|
35
32
|
*
|
|
36
33
|
* Accepts any of:
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
34
|
+
* - An `Expression` whose codec matches exactly
|
|
35
|
+
* - A raw JS value of the codec's `input` type
|
|
36
|
+
* - `null` when `Nullable` is true
|
|
40
37
|
*/
|
|
41
38
|
export type CodecExpression<
|
|
42
39
|
CodecId extends string,
|
|
@@ -48,11 +45,9 @@ export type CodecExpression<
|
|
|
48
45
|
| NullSuffix<Nullable>;
|
|
49
46
|
|
|
50
47
|
/**
|
|
51
|
-
* An expression or literal value targeting any codec whose trait set contains
|
|
52
|
-
* all the required traits.
|
|
48
|
+
* An expression or literal value targeting any codec whose trait set contains all the required traits.
|
|
53
49
|
*
|
|
54
|
-
* Resolves the trait set to the union of matching codec identities via
|
|
55
|
-
* `CodecIdsWithTrait`, then reuses `CodecExpression` for the codec-id form.
|
|
50
|
+
* Resolves the trait set to the union of matching codec identities via `CodecIdsWithTrait`, then reuses `CodecExpression` for the codec-id form.
|
|
56
51
|
*/
|
|
57
52
|
export type TraitExpression<
|
|
58
53
|
Traits extends readonly string[],
|
|
@@ -63,16 +58,42 @@ export type TraitExpression<
|
|
|
63
58
|
/**
|
|
64
59
|
* Resolve a raw value or an Expression into an AST expression node.
|
|
65
60
|
*
|
|
66
|
-
* When `value` is an Expression (duck-typed by its `buildAst` method), the AST
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* specific codec — most operations do.
|
|
61
|
+
* When `value` is an Expression (duck-typed by its `buildAst` method), the AST it wraps is returned. Otherwise the value is embedded as a ParamRef tagged with `codecId` (if given) and optionally `refs: { table, column }` (if the caller knows the column-bound site).
|
|
62
|
+
*
|
|
63
|
+
* For parameterized codec ids (e.g. `pg/vector@1`), encode-side dispatch requires `refs` to select the per-instance codec — so operation implementations that compare a column to a user-supplied value should derive `refs` from the column-bound side and pass it down. Non-parameterized codec ids (e.g. `pg/int4@1`) tolerate refs-less ParamRefs; the validator pass enforces refs only for parameterized ids.
|
|
70
64
|
*/
|
|
71
|
-
export function toExpr(
|
|
65
|
+
export function toExpr(
|
|
66
|
+
value: unknown,
|
|
67
|
+
codecId?: string,
|
|
68
|
+
refs?: { table: string; column: string },
|
|
69
|
+
): AstExpression {
|
|
72
70
|
if (isExpressionLike(value)) {
|
|
73
71
|
return value.buildAst();
|
|
74
72
|
}
|
|
75
|
-
|
|
73
|
+
if (codecId === undefined && refs === undefined) return ParamRef.of(value);
|
|
74
|
+
return ParamRef.of(value, {
|
|
75
|
+
...(codecId !== undefined ? { codecId } : {}),
|
|
76
|
+
...(refs !== undefined ? { refs } : {}),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Derive `(table, column)` refs from an expression-like value when it carries column-bound metadata. Returns `undefined` for non-column-bound expressions and for raw scalar values.
|
|
82
|
+
*
|
|
83
|
+
* Two sources are consulted, in order: 1. An optional `refs` slot on the `Expression` wrapper (the SQL builder's `ExpressionImpl` records `(table, column)` for top-level fields whose AST is `IdentifierRef` — the AST stays bare to preserve SQL rendering, the metadata lives on the wrapper). 2. The wrapped AST when it's already a `ColumnRef` (the namespaced field-proxy form, or operation impls passing column-bound exprs
|
|
84
|
+
* directly).
|
|
85
|
+
*
|
|
86
|
+
* Operation implementations call this on the column-bound side of a comparison and forward the refs to {@link toExpr} on the user-value side, so the resulting `ParamRef` carries the table+column required by encode-side `forColumn` dispatch.
|
|
87
|
+
*/
|
|
88
|
+
export function refsOf(value: unknown): { table: string; column: string } | undefined {
|
|
89
|
+
if (!isExpressionLike(value)) return undefined;
|
|
90
|
+
const wrapperRefs = (value as { refs?: { table: string; column: string } }).refs;
|
|
91
|
+
if (wrapperRefs) return { table: wrapperRefs.table, column: wrapperRefs.column };
|
|
92
|
+
const ast = value.buildAst();
|
|
93
|
+
if (ast.kind === 'column-ref') {
|
|
94
|
+
return { table: ast.table, column: ast.column };
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
76
97
|
}
|
|
77
98
|
|
|
78
99
|
function isExpressionLike(value: unknown): value is Expression<ScopeField> {
|
|
@@ -87,9 +108,7 @@ function isExpressionLike(value: unknown): value is Expression<ScopeField> {
|
|
|
87
108
|
export interface BuildOperationSpec<R extends ScopeField> {
|
|
88
109
|
readonly method: string;
|
|
89
110
|
/**
|
|
90
|
-
* The operation's arguments. The first element is the self argument (the
|
|
91
|
-
* value the operation is being applied to); the rest are the remaining
|
|
92
|
-
* user-supplied arguments.
|
|
111
|
+
* The operation's arguments. The first element is the self argument (the value the operation is being applied to); the rest are the remaining user-supplied arguments.
|
|
93
112
|
*/
|
|
94
113
|
readonly args: readonly [AstExpression, ...AstExpression[]];
|
|
95
114
|
readonly returns: R & ParamSpec;
|
|
@@ -97,9 +116,7 @@ export interface BuildOperationSpec<R extends ScopeField> {
|
|
|
97
116
|
}
|
|
98
117
|
|
|
99
118
|
/**
|
|
100
|
-
* Construct an OperationExpr AST node and wrap it as a typed Expression.
|
|
101
|
-
* Operation implementations use this to turn their user-facing arguments into
|
|
102
|
-
* the AST node the compilation pipeline eventually lowers to SQL.
|
|
119
|
+
* Construct an OperationExpr AST node and wrap it as a typed Expression. Operation implementations use this to turn their user-facing arguments into the AST node the compilation pipeline eventually lowers to SQL.
|
|
103
120
|
*/
|
|
104
121
|
export function buildOperation<R extends ScopeField>(spec: BuildOperationSpec<R>): Expression<R> {
|
|
105
122
|
const [self, ...rest] = spec.args;
|
|
@@ -2,83 +2,31 @@ import type { Contract } from '@prisma-next/contract/types';
|
|
|
2
2
|
import type { CodecDescriptor } from '@prisma-next/framework-components/codec';
|
|
3
3
|
import type { SqlStorage } from '@prisma-next/sql-contract/types';
|
|
4
4
|
import type { SqlOperationRegistry } from '@prisma-next/sql-operations';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ContractCodecRegistry } from './ast/codec-types';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Codec-id-keyed accessor for descriptor metadata. The unified read API
|
|
9
|
-
* for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`) — non-
|
|
10
|
-
* branching for parameterized vs. non-parameterized codecs since every
|
|
11
|
-
* codec ships as (or is synthesized into) a `CodecDescriptor`.
|
|
12
|
-
*
|
|
13
|
-
* See codec-registry-unification spec § Decision and AC-3.
|
|
8
|
+
* Codec-id-keyed accessor for descriptor metadata. The unified read API for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`) — non-branching for parameterized vs. non-parameterized codecs. Every codec ships natively as a `CodecDescriptor` through the unified `codecs:` contributor slot (see ADR 208).
|
|
14
9
|
*/
|
|
15
10
|
export interface CodecDescriptorRegistry {
|
|
16
11
|
/**
|
|
17
|
-
* Descriptors carry distinct param shapes per codec id; the registry is
|
|
18
|
-
* heterogeneous and the consumer narrows per codec.
|
|
12
|
+
* Descriptors carry distinct param shapes per codec id; the registry is heterogeneous and the consumer narrows per codec.
|
|
19
13
|
*/
|
|
20
14
|
descriptorFor(codecId: string): CodecDescriptor<unknown> | undefined;
|
|
21
15
|
/**
|
|
22
|
-
* All registered descriptors. Used by `validateCodecRegistryCompleteness`
|
|
23
|
-
* and other startup-time consumers that enumerate descriptors.
|
|
16
|
+
* All registered descriptors. Used by `validateCodecRegistryCompleteness` and other startup-time consumers that enumerate descriptors.
|
|
24
17
|
*/
|
|
25
18
|
values(): IterableIterator<CodecDescriptor<unknown>>;
|
|
26
19
|
/**
|
|
27
|
-
* Descriptors indexed by `targetTypes[i]` (each scalar type the codec
|
|
28
|
-
* advertises). Multiple descriptors may map to the same scalar type;
|
|
29
|
-
* ordering reflects registration order.
|
|
20
|
+
* Descriptors indexed by `targetTypes[i]` (each scalar type the codec advertises). Multiple descriptors may map to the same scalar type; ordering reflects registration order.
|
|
30
21
|
*/
|
|
31
22
|
byTargetType(targetType: string): readonly CodecDescriptor<unknown>[];
|
|
32
23
|
}
|
|
33
24
|
|
|
34
25
|
/**
|
|
35
|
-
* Registry of initialized type helpers from storage.types.
|
|
36
|
-
* Each key is a type name from storage.types, and the value is:
|
|
37
|
-
* - The result of the codec's init hook (if provided), or
|
|
38
|
-
* - The full StorageTypeInstance metadata (codecId, nativeType, typeParams) if no init hook
|
|
26
|
+
* Registry of initialized type helpers from storage.types. Each key is a type name from storage.types, and the value is the resolved codec materialized once for that named instance via `descriptor.factory(typeParams)(ctx)` (or the raw `StorageTypeInstance` metadata for codec ids whose descriptor isn't registered).
|
|
39
27
|
*/
|
|
40
28
|
export type TypeHelperRegistry = Record<string, unknown>;
|
|
41
29
|
|
|
42
|
-
// =============================================================================
|
|
43
|
-
// JSON Schema Validation Types
|
|
44
|
-
// =============================================================================
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* A single validation error from JSON Schema validation.
|
|
48
|
-
*/
|
|
49
|
-
export interface JsonSchemaValidationError {
|
|
50
|
-
readonly path: string;
|
|
51
|
-
readonly message: string;
|
|
52
|
-
readonly keyword: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Result of a JSON Schema validation.
|
|
57
|
-
*/
|
|
58
|
-
export type JsonSchemaValidationResult =
|
|
59
|
-
| { readonly valid: true }
|
|
60
|
-
| { readonly valid: false; readonly errors: ReadonlyArray<JsonSchemaValidationError> };
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* A compiled JSON Schema validate function.
|
|
64
|
-
* Returns a structured result indicating whether the value conforms to the schema.
|
|
65
|
-
*/
|
|
66
|
-
export type JsonSchemaValidateFn = (value: unknown) => JsonSchemaValidationResult;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Registry of compiled JSON Schema validators for columns with typed JSON/JSONB.
|
|
70
|
-
*
|
|
71
|
-
* Built during context creation by scanning the contract for columns whose codec
|
|
72
|
-
* descriptor provides an `init` hook that returns a `{ validate }` helper.
|
|
73
|
-
* Keys are `"table.column"` (e.g., `"user.metadata"`).
|
|
74
|
-
*/
|
|
75
|
-
export interface JsonSchemaValidatorRegistry {
|
|
76
|
-
/** Get the compiled validator for a column. Key format: "table.column". */
|
|
77
|
-
get(key: string): JsonSchemaValidateFn | undefined;
|
|
78
|
-
/** Number of registered validators. */
|
|
79
|
-
readonly size: number;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
30
|
export type MutationDefaultsOp = 'create' | 'update';
|
|
83
31
|
|
|
84
32
|
export type AppliedMutationDefault = {
|
|
@@ -91,14 +39,8 @@ export type MutationDefaultsOptions = {
|
|
|
91
39
|
readonly table: string;
|
|
92
40
|
readonly values: Record<string, unknown>;
|
|
93
41
|
/**
|
|
94
|
-
* Per-ORM-operation cache for generators that declare
|
|
95
|
-
*
|
|
96
|
-
* `applyMutationDefaults` invocation in one bulk operation; the
|
|
97
|
-
* framework keys by `generatorId` so the same value is reused across
|
|
98
|
-
* all rows and columns. Generators with `stability: 'row'` use a
|
|
99
|
-
* fresh per-call cache the framework manages internally; generators
|
|
100
|
-
* with `stability: 'field'` skip caching entirely. Omit to make every
|
|
101
|
-
* call independent (degrades `'query'` to per-call behavior).
|
|
42
|
+
* Per-ORM-operation cache for generators that declare `stability: 'query'`. The caller passes the same `Map` across every `applyMutationDefaults` invocation in one bulk operation; the framework keys by `generatorId` so the same value is reused across all rows and columns. Generators with `stability: 'row'` use a fresh per-call cache the framework manages internally; generators with `stability: 'field'` skip caching
|
|
43
|
+
* entirely. Omit to make every call independent (degrades `'query'` to per-call behavior).
|
|
102
44
|
*/
|
|
103
45
|
readonly defaultValueCache?: Map<string, unknown>;
|
|
104
46
|
};
|
|
@@ -106,50 +48,26 @@ export type MutationDefaultsOptions = {
|
|
|
106
48
|
/**
|
|
107
49
|
* Minimal context interface for SQL query lanes.
|
|
108
50
|
*
|
|
109
|
-
* Lanes only need contract, operations, and codecs to build typed ASTs and attach
|
|
110
|
-
* operation builders. This interface explicitly excludes runtime concerns like
|
|
111
|
-
* adapters, connection management, and transaction state.
|
|
51
|
+
* Lanes only need contract, operations, and codecs to build typed ASTs and attach operation builders. This interface explicitly excludes runtime concerns like adapters, connection management, and transaction state.
|
|
112
52
|
*/
|
|
113
53
|
export interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
|
|
114
54
|
readonly contract: TContract;
|
|
115
55
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* `forCodecId` boundary while AC-5's `ParamRef.refs` plumbing remains
|
|
119
|
-
* deferred (TML-2357).
|
|
120
|
-
*/
|
|
121
|
-
readonly codecs: CodecRegistry;
|
|
122
|
-
/**
|
|
123
|
-
* Contract-bound codec registry built once at context-construction time
|
|
124
|
-
* by walking the contract's columns and resolving each to its per-
|
|
125
|
-
* instance codec (parameterized columns) or the shared codec from the
|
|
126
|
-
* legacy registry (non-parameterized columns). The dispatch path
|
|
127
|
-
* (`encodeParam` / `decodeRow`) consults `forColumn(table, column)`
|
|
128
|
-
* when the call site has the ref, falling back to `forCodecId(codecId)`
|
|
129
|
-
* otherwise. Codec-registry-unification spec § AC-4.
|
|
56
|
+
* Contract-bound codec registry built once at context-construction time by walking the contract's columns and resolving each through its descriptor's factory. The dispatch path (`encodeParam` / `decodeRow`) consults `forColumn(table, column)` for column-bound call sites; `forCodecId(codecId)` is the refs-less fallback, permitted only for non-parameterized codec ids (the builder-pipeline validator pass enforces refs on
|
|
57
|
+
* every parameterized `ParamRef`). Pre-populated with one canonical instance per non-parameterized descriptor so `forCodecId` covers refs-less codec ids that no contract column declares.
|
|
130
58
|
*/
|
|
131
59
|
readonly contractCodecs: ContractCodecRegistry;
|
|
132
60
|
/**
|
|
133
|
-
* Codec-id-keyed descriptor map. Single source of truth for codec-id-
|
|
134
|
-
* keyed metadata (`traits`, `targetTypes`, `meta`) — every codec,
|
|
135
|
-
* parameterized or not, resolves through this map without branching.
|
|
136
|
-
* Codec-registry-unification spec § AC-3.
|
|
61
|
+
* Codec-id-keyed descriptor map. Single source of truth for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`) — every codec, parameterized or not, resolves through this map without branching.
|
|
137
62
|
*/
|
|
138
63
|
readonly codecDescriptors: CodecDescriptorRegistry;
|
|
139
64
|
readonly queryOperations: SqlOperationRegistry;
|
|
140
65
|
/**
|
|
141
|
-
* Type helper registry for parameterized types.
|
|
142
|
-
* Schema builders expose these helpers via schema.types.
|
|
66
|
+
* Type helper registry for parameterized types. Schema builders expose these helpers via schema.types.
|
|
143
67
|
*/
|
|
144
68
|
readonly types: TypeHelperRegistry;
|
|
145
69
|
/**
|
|
146
|
-
*
|
|
147
|
-
* Present only when the contract declares columns with JSON Schema typeParams.
|
|
148
|
-
*/
|
|
149
|
-
readonly jsonSchemaValidators?: JsonSchemaValidatorRegistry;
|
|
150
|
-
/**
|
|
151
|
-
* Applies execution-time mutation defaults for the given table.
|
|
152
|
-
* Returns the applied defaults (caller-provided values always win).
|
|
70
|
+
* Applies execution-time mutation defaults for the given table. Returns the applied defaults (caller-provided values always win).
|
|
153
71
|
*/
|
|
154
72
|
applyMutationDefaults(options: MutationDefaultsOptions): ReadonlyArray<AppliedMutationDefault>;
|
|
155
73
|
}
|
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import { Type } from "arktype";
|
|
2
|
-
import { JsonValue } from "@prisma-next/contract/types";
|
|
3
|
-
import { Codec, CodecCallContext, CodecCallContext as CodecCallContext$1, CodecInstanceContext, CodecTrait, CodecTrait as CodecTrait$1 } from "@prisma-next/framework-components/codec";
|
|
4
|
-
import { O } from "ts-toolbelt";
|
|
5
|
-
|
|
6
|
-
//#region src/ast/codec-types.d.ts
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* SQL-family addressing of a single column. The decode site populates a
|
|
10
|
-
* `SqlColumnRef` whenever it can resolve the cell to a single underlying
|
|
11
|
-
* `(table, column)` (the typical case for projected columns from a
|
|
12
|
-
* single-table source); cells the runtime cannot resolve (aggregate
|
|
13
|
-
* aliases, include aggregate fields, computed projections without a
|
|
14
|
-
* simple ref) get `column = undefined`.
|
|
15
|
-
*
|
|
16
|
-
* The shape is a structural projection of the runtime's `ColumnRef` so
|
|
17
|
-
* the SQL decode site can reuse the resolution it already performs for
|
|
18
|
-
* `RUNTIME.DECODE_FAILED` envelope construction without allocating
|
|
19
|
-
* twice per cell.
|
|
20
|
-
*/
|
|
21
|
-
interface SqlColumnRef {
|
|
22
|
-
readonly table: string;
|
|
23
|
-
readonly name: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* SQL-family per-call context. Extends the framework {@link CodecCallContext}
|
|
27
|
-
* (which carries `signal` only) with `column?: SqlColumnRef`, populated
|
|
28
|
-
* on **decode** call sites that can resolve a single underlying column
|
|
29
|
-
* ref. Encode call sites currently leave `column` undefined (encode-time
|
|
30
|
-
* column context is the middleware's domain).
|
|
31
|
-
*
|
|
32
|
-
* SQL codec authors writing a `(value, ctx)` author function for the SQL
|
|
33
|
-
* `codec()` factory observe this type. The framework codec dispatch
|
|
34
|
-
* surface (and Mongo) sees only the base `CodecCallContext`.
|
|
35
|
-
*/
|
|
36
|
-
interface SqlCodecCallContext extends CodecCallContext {
|
|
37
|
-
readonly column?: SqlColumnRef;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* SQL-family per-instance context. Extends the framework
|
|
41
|
-
* {@link CodecInstanceContext} (`name` only) with `usedAt`, the set of
|
|
42
|
-
* `(table, column)` pairs the resolved codec serves.
|
|
43
|
-
*
|
|
44
|
-
* - For `typeRef` columns sharing one named `storage.types` instance, the
|
|
45
|
-
* array lists every referencing column — a column-scoped stateful codec
|
|
46
|
-
* (e.g. encryption) can derive aggregated per-instance state across all
|
|
47
|
-
* the columns sharing the named instance.
|
|
48
|
-
* - For inline-`typeParams` columns, the array has exactly one entry —
|
|
49
|
-
* the column that owns the inline params.
|
|
50
|
-
* - For shared non-parameterized codecs, the array carries one
|
|
51
|
-
* representative entry (the column that triggered materialization);
|
|
52
|
-
* the codec is shared across every column with that codec id, so the
|
|
53
|
-
* `usedAt` is informational only.
|
|
54
|
-
*
|
|
55
|
-
* SQL extensions consuming `usedAt` (e.g. column-scoped state derivation)
|
|
56
|
-
* type their factory parameter as `SqlCodecInstanceContext`. Extensions
|
|
57
|
-
* that don't read `usedAt` type their factory parameter as the
|
|
58
|
-
* family-agnostic {@link CodecInstanceContext} — a `SqlCodecInstanceContext`
|
|
59
|
-
* is structurally assignable to the base.
|
|
60
|
-
*/
|
|
61
|
-
interface SqlCodecInstanceContext extends CodecInstanceContext {
|
|
62
|
-
readonly usedAt: ReadonlyArray<{
|
|
63
|
-
readonly table: string;
|
|
64
|
-
readonly column: string;
|
|
65
|
-
}>;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Legacy adapter-level descriptor for parameterized codecs that require
|
|
69
|
-
* type-parameter validation at compile time. The runtime descriptor
|
|
70
|
-
* (`RuntimeParameterizedCodecDescriptor` in `@prisma-next/sql-runtime`)
|
|
71
|
-
* has migrated to the unified `CodecDescriptor<P>` shape with
|
|
72
|
-
* `factory: (P) => (CodecInstanceContext) => Codec`; this descriptor stays only because
|
|
73
|
-
* the SQL `Adapter.parameterizedCodecs()` surface still returns
|
|
74
|
-
* `CodecParamsDescriptor[]` (compile-time typeParams validation only,
|
|
75
|
-
* not runtime materialization).
|
|
76
|
-
*
|
|
77
|
-
* Retirement is tracked under TML-2357 T3.5.4 (single registration slot)
|
|
78
|
-
* — the adapter-level `parameterizedCodecs()` collapses into the unified
|
|
79
|
-
* runtime descriptor map once contributors migrate fully.
|
|
80
|
-
*
|
|
81
|
-
* @template TParams - The shape of the type parameters (e.g., `{ length: number }`)
|
|
82
|
-
* @template THelper - The type returned by the optional `init` hook
|
|
83
|
-
*/
|
|
84
|
-
interface CodecParamsDescriptor<TParams = Record<string, unknown>, THelper = unknown> {
|
|
85
|
-
/** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */
|
|
86
|
-
readonly codecId: string;
|
|
87
|
-
/**
|
|
88
|
-
* Arktype schema for validating typeParams.
|
|
89
|
-
* Used to validate both storage.types entries and inline column typeParams.
|
|
90
|
-
*/
|
|
91
|
-
readonly paramsSchema: Type<TParams>;
|
|
92
|
-
/**
|
|
93
|
-
* Optional init hook called during runtime context creation.
|
|
94
|
-
* Receives validated params and returns a helper object to be stored in context.types.
|
|
95
|
-
* If not provided, the validated params are stored directly.
|
|
96
|
-
*
|
|
97
|
-
* Predecessor pattern. The runtime descriptor's curried
|
|
98
|
-
* `factory: (P) => (CodecInstanceContext) => Codec` subsumes this hook — per-instance
|
|
99
|
-
* state lives on the resolved codec rather than in a parallel
|
|
100
|
-
* `TypeHelperRegistry` entry. Retirement tracked under TML-2357 T3.5.2
|
|
101
|
-
* (narrow runtime `Codec` interface) and T3.5.4 (single registration
|
|
102
|
-
* slot). Adapter-level callers reading codec-self-carried `init` should
|
|
103
|
-
* migrate to the runtime descriptor map's factory instead.
|
|
104
|
-
*/
|
|
105
|
-
readonly init?: (params: TParams) => THelper;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Codec metadata for database-specific type information.
|
|
109
|
-
* Used for schema introspection and verification.
|
|
110
|
-
*/
|
|
111
|
-
interface CodecMeta {
|
|
112
|
-
readonly db?: {
|
|
113
|
-
readonly sql?: {
|
|
114
|
-
readonly postgres?: {
|
|
115
|
-
readonly nativeType: string;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* SQL codec — extends the framework codec base with SQL-specific metadata:
|
|
122
|
-
* driver-native type info (`meta.db.sql.<dialect>.nativeType`) and an
|
|
123
|
-
* optional parameterized-codec descriptor (`paramsSchema` + `init`) for
|
|
124
|
-
* codecs that require type-parameter validation (e.g. `pg/vector@1`).
|
|
125
|
-
*
|
|
126
|
-
* `encode` and `decode` are redeclared here to narrow the per-call
|
|
127
|
-
* context to the SQL-family {@link SqlCodecCallContext} (adds
|
|
128
|
-
* `column?: SqlColumnRef`). TypeScript treats method-syntax declarations
|
|
129
|
-
* bivariantly, so the SQL narrowing is structurally compatible with the
|
|
130
|
-
* framework {@link BaseCodec} super-interface.
|
|
131
|
-
*
|
|
132
|
-
* Note: `paramsSchema` and `init` here are the legacy adapter-level slots
|
|
133
|
-
* mirrored from {@link CodecParamsDescriptor}. The runtime materialization
|
|
134
|
-
* path uses `RuntimeParameterizedCodecDescriptor` (in
|
|
135
|
-
* `@prisma-next/sql-runtime`) via the unified `CodecDescriptor<P>` shape;
|
|
136
|
-
* codec-self-carried `paramsSchema`/`init` retire under TML-2357 (T3.5.2
|
|
137
|
-
* narrows the runtime `Codec` interface; T3.5.4 collapses the parallel
|
|
138
|
-
* registration slots).
|
|
139
|
-
*
|
|
140
|
-
* See `Codec` in `@prisma-next/framework-components/codec` for the codec
|
|
141
|
-
* contract that this interface extends.
|
|
142
|
-
*/
|
|
143
|
-
interface Codec$1<Id$1 extends string = string, TTraits$1 extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TInput = unknown, TParams = Record<string, unknown>, THelper = unknown> extends Codec<Id$1, TTraits$1, TWire, TInput> {
|
|
144
|
-
encode(value: TInput, ctx: SqlCodecCallContext): Promise<TWire>;
|
|
145
|
-
decode(wire: TWire, ctx: SqlCodecCallContext): Promise<TInput>;
|
|
146
|
-
readonly meta?: CodecMeta;
|
|
147
|
-
readonly paramsSchema?: Type<TParams>;
|
|
148
|
-
/**
|
|
149
|
-
* Predecessor init hook. Retirement tracked under TML-2357 (T3.5.2 /
|
|
150
|
-
* T3.5.4); the unified runtime descriptor's
|
|
151
|
-
* `factory: (P) => (CodecInstanceContext) => Codec` is the replacement.
|
|
152
|
-
*/
|
|
153
|
-
readonly init?: (params: TParams) => THelper;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Contract-bound codec registry.
|
|
157
|
-
*
|
|
158
|
-
* The dispatch interface for encode/decode at runtime: built once at
|
|
159
|
-
* `ExecutionContext` construction time by walking the contract's
|
|
160
|
-
* `storage.tables[].columns[]` and resolving each column to either a per-
|
|
161
|
-
* instance parameterized codec (via `descriptor.factory(typeParams)(ctx)`)
|
|
162
|
-
* or the shared codec instance from the legacy `CodecRegistry` (for non-
|
|
163
|
-
* parameterized codecs). The dispatch path calls
|
|
164
|
-
* `forColumn(table, column).encode/decode(...)` and doesn't know whether
|
|
165
|
-
* the codec is parameterized.
|
|
166
|
-
*
|
|
167
|
-
* `forCodecId(codecId)` is a fallback for sites that don't carry the
|
|
168
|
-
* `(table, column)` ref through to the encode/decode call site —
|
|
169
|
-
* primarily the param-encoding path, where `ParamRef.refs` is not
|
|
170
|
-
* populated by the SQL builder today (every `ParamRef` carries `codecId`
|
|
171
|
-
* but not the column it relates to). For the parameterized codecs shipped
|
|
172
|
-
* at Phase B, encode is per-instance-stateless (pgvector formats
|
|
173
|
-
* `[v1,v2,v3]` regardless of length; JSON's `encode` is `JSON.stringify`
|
|
174
|
-
* regardless of schema), so a codec-id-keyed lookup yields a structurally
|
|
175
|
-
* equivalent encoder; the fallback is the bridge that lets the legacy
|
|
176
|
-
* `codecs:` registration retire from the dispatch path while staying as
|
|
177
|
-
* the codec-id-only source for now.
|
|
178
|
-
*
|
|
179
|
-
* The encode-side fallback is the AC-5-deferred carve-out documented in
|
|
180
|
-
* the codec-registry-unification spec § Non-functional constraints.
|
|
181
|
-
* TML-2357 retires the fallback by threading `ParamRef.refs` through
|
|
182
|
-
* column-bound construction sites.
|
|
183
|
-
*/
|
|
184
|
-
interface ContractCodecRegistry {
|
|
185
|
-
/**
|
|
186
|
-
* Resolve the codec for `(table, column)`. Returns the per-instance
|
|
187
|
-
* parameterized codec for parameterized columns, the shared codec for
|
|
188
|
-
* non-parameterized columns, or `undefined` if the column is unknown
|
|
189
|
-
* or the codec isn't registered.
|
|
190
|
-
*/
|
|
191
|
-
forColumn(table: string, column: string): Codec$1 | undefined;
|
|
192
|
-
/**
|
|
193
|
-
* Resolve a codec by id. Returns the same codec instance the legacy
|
|
194
|
-
* `CodecRegistry.get(codecId)` would return — for non-parameterized
|
|
195
|
-
* codecs that's the shared instance; for parameterized codecs that's
|
|
196
|
-
* a representative resolved instance. Used by sites that don't carry
|
|
197
|
-
* `(table, column)` through to the encode/decode call site (the AC-5
|
|
198
|
-
* carve-out path).
|
|
199
|
-
*/
|
|
200
|
-
forCodecId(codecId: string): Codec$1 | undefined;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Registry interface for codecs organized by ID and by contract scalar type.
|
|
204
|
-
*
|
|
205
|
-
* The registry allows looking up codecs by their namespaced ID or by the
|
|
206
|
-
* contract scalar types they handle. Multiple codecs may handle the same
|
|
207
|
-
* scalar type; ordering in byScalar reflects preference (adapter first,
|
|
208
|
-
* then packs, then app overrides).
|
|
209
|
-
*/
|
|
210
|
-
interface CodecRegistry {
|
|
211
|
-
get(id: string): Codec$1<string> | undefined;
|
|
212
|
-
has(id: string): boolean;
|
|
213
|
-
getByScalar(scalar: string): readonly Codec$1<string>[];
|
|
214
|
-
getDefaultCodec(scalar: string): Codec$1<string> | undefined;
|
|
215
|
-
register(codec: Codec$1<string>): void;
|
|
216
|
-
/** Returns true if the codec with this ID has the given trait. */
|
|
217
|
-
hasTrait(codecId: string, trait: CodecTrait): boolean;
|
|
218
|
-
/** Returns all traits for a codec, or an empty array if not found. */
|
|
219
|
-
traitsOf(codecId: string): readonly CodecTrait[];
|
|
220
|
-
[Symbol.iterator](): Iterator<Codec$1<string>>;
|
|
221
|
-
values(): IterableIterator<Codec$1<string>>;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Conditional bundle for `encodeJson`/`decodeJson`: when `TInput` is
|
|
225
|
-
* structurally assignable to `JsonValue` the identity defaults are
|
|
226
|
-
* sound and both fields are optional; otherwise both fields are
|
|
227
|
-
* required so an author cannot silently produce a non-JSON-safe
|
|
228
|
-
* contract artifact.
|
|
229
|
-
*/
|
|
230
|
-
type JsonRoundTripConfig<TInput> = [TInput] extends [JsonValue] ? {
|
|
231
|
-
encodeJson?: (value: TInput) => JsonValue;
|
|
232
|
-
decodeJson?: (json: JsonValue) => TInput;
|
|
233
|
-
} : {
|
|
234
|
-
encodeJson: (value: TInput) => JsonValue;
|
|
235
|
-
decodeJson: (json: JsonValue) => TInput;
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* Construct a SQL codec from author functions and optional metadata.
|
|
239
|
-
*
|
|
240
|
-
* Author `encode` and `decode` as sync or async functions; the factory
|
|
241
|
-
* produces a {@link Codec} whose query-time methods follow the boundary
|
|
242
|
-
* contract documented on `Codec`. Authors receive a second `ctx` options
|
|
243
|
-
* argument carrying the SQL-family per-call context; ignore it if you
|
|
244
|
-
* don't need it.
|
|
245
|
-
*
|
|
246
|
-
* Both `encode` and `decode` are required so `TInput` and `TWire` are
|
|
247
|
-
* always covered by an explicit author function — the factory installs
|
|
248
|
-
* no identity fallback. `encodeJson` and `decodeJson` default to identity
|
|
249
|
-
* **only when `TInput` is assignable to `JsonValue`**; otherwise both are
|
|
250
|
-
* required so the contract artifact stays JSON-safe.
|
|
251
|
-
*/
|
|
252
|
-
declare function codec<Id$1 extends string, const TTraits$1 extends readonly CodecTrait[] = readonly [], TWire = unknown, TInput = unknown, TParams = Record<string, unknown>, THelper = unknown>(config: {
|
|
253
|
-
typeId: Id$1;
|
|
254
|
-
targetTypes: readonly string[];
|
|
255
|
-
encode: (value: TInput, ctx: SqlCodecCallContext) => TWire | Promise<TWire>;
|
|
256
|
-
decode: (wire: TWire, ctx: SqlCodecCallContext) => TInput | Promise<TInput>;
|
|
257
|
-
meta?: CodecMeta;
|
|
258
|
-
paramsSchema?: Type<TParams>;
|
|
259
|
-
init?: (params: TParams) => THelper;
|
|
260
|
-
traits?: TTraits$1;
|
|
261
|
-
renderOutputType?: (typeParams: Record<string, unknown>) => string | undefined;
|
|
262
|
-
} & JsonRoundTripConfig<TInput>): Codec$1<Id$1, TTraits$1, TWire, TInput, TParams, THelper>;
|
|
263
|
-
/**
|
|
264
|
-
* Type helpers to extract codec types.
|
|
265
|
-
*/
|
|
266
|
-
type CodecId<T> = T extends Codec$1<infer Id> ? Id : T extends {
|
|
267
|
-
readonly id: infer Id;
|
|
268
|
-
} ? Id : never;
|
|
269
|
-
type CodecInput<T> = T extends Codec$1<string, readonly CodecTrait[], unknown, infer In> ? In : never;
|
|
270
|
-
type CodecTraits<T> = T extends Codec$1<string, infer TTraits> ? TTraits[number] & CodecTrait : never;
|
|
271
|
-
/**
|
|
272
|
-
* Type helper to extract codec types from builder instance.
|
|
273
|
-
*/
|
|
274
|
-
type ExtractCodecTypes<ScalarNames extends { readonly [K in keyof ScalarNames]: Codec$1<string> } = Record<never, never>> = { readonly [K in keyof ScalarNames as ScalarNames[K] extends Codec$1<infer Id> ? Id : never]: {
|
|
275
|
-
readonly input: CodecInput<ScalarNames[K]>;
|
|
276
|
-
readonly output: CodecInput<ScalarNames[K]>;
|
|
277
|
-
readonly traits: CodecTraits<ScalarNames[K]>;
|
|
278
|
-
} };
|
|
279
|
-
/**
|
|
280
|
-
* Type helper to extract data type IDs from builder instance.
|
|
281
|
-
* Uses ExtractCodecTypes which preserves literal types as keys.
|
|
282
|
-
* Since ExtractCodecTypes<Record<K, ScalarNames[K]>> has exactly one key (the Id),
|
|
283
|
-
* we extract it by creating a mapped type that uses the Id as both key and value,
|
|
284
|
-
* then extract the value type. This preserves literal types.
|
|
285
|
-
*/
|
|
286
|
-
type ExtractDataTypes<ScalarNames extends { readonly [K in keyof ScalarNames]: Codec$1<string> }> = { readonly [K in keyof ScalarNames]: { readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>] };
|
|
287
|
-
/**
|
|
288
|
-
* Builder interface for declaring codecs.
|
|
289
|
-
*/
|
|
290
|
-
interface CodecDefBuilder<ScalarNames extends { readonly [K in keyof ScalarNames]: Codec$1<string> } = Record<never, never>> {
|
|
291
|
-
readonly CodecTypes: ExtractCodecTypes<ScalarNames>;
|
|
292
|
-
add<ScalarName extends string, CodecImpl extends Codec$1<string>>(scalarName: ScalarName, codecImpl: CodecImpl): CodecDefBuilder<O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>>;
|
|
293
|
-
readonly codecDefinitions: { readonly [K in keyof ScalarNames]: {
|
|
294
|
-
readonly typeId: ScalarNames[K] extends Codec$1<infer Id extends string> ? Id : never;
|
|
295
|
-
readonly scalar: K;
|
|
296
|
-
readonly codec: ScalarNames[K];
|
|
297
|
-
readonly input: CodecInput<ScalarNames[K]>;
|
|
298
|
-
readonly output: CodecInput<ScalarNames[K]>;
|
|
299
|
-
readonly jsType: CodecInput<ScalarNames[K]>;
|
|
300
|
-
} };
|
|
301
|
-
readonly dataTypes: { readonly [K in keyof ScalarNames]: { readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>] };
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Create a new codec registry.
|
|
305
|
-
*/
|
|
306
|
-
declare function createCodecRegistry(): CodecRegistry;
|
|
307
|
-
/**
|
|
308
|
-
* Create a new codec definition builder.
|
|
309
|
-
*/
|
|
310
|
-
declare function defineCodecs(): CodecDefBuilder<Record<never, never>>;
|
|
311
|
-
//#endregion
|
|
312
|
-
export { codec as _, CodecInput as a, CodecRegistry as c, ContractCodecRegistry as d, ExtractCodecTypes as f, SqlColumnRef as g, SqlCodecInstanceContext as h, CodecId as i, CodecTrait$1 as l, SqlCodecCallContext as m, CodecCallContext$1 as n, CodecMeta as o, ExtractDataTypes as p, CodecDefBuilder as r, CodecParamsDescriptor as s, Codec$1 as t, CodecTraits as u, createCodecRegistry as v, defineCodecs as y };
|
|
313
|
-
//# sourceMappingURL=codec-types-DJEaWT36.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec-types-DJEaWT36.d.mts","names":[],"sources":["../src/ast/codec-types.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA0BA;AAgBA;AA0BA;AAqBA;;;;;;;AA8BA;AAiCA;AAE2B,UAhIV,Y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