@prisma-next/sql-relational-core 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.
Files changed (72) hide show
  1. package/README.md +65 -1
  2. package/dist/{errors-D3xmG4h-.mjs → errors-Cb03_kgU.mjs} +2 -2
  3. package/dist/{errors-D3xmG4h-.mjs.map → errors-Cb03_kgU.mjs.map} +1 -1
  4. package/dist/{errors-ChY_dHam.d.mts → errors-DCg-36g-.d.mts} +2 -2
  5. package/dist/errors-DCg-36g-.d.mts.map +1 -0
  6. package/dist/exports/ast.d.mts +154 -85
  7. package/dist/exports/ast.d.mts.map +1 -1
  8. package/dist/exports/ast.mjs +229 -1289
  9. package/dist/exports/ast.mjs.map +1 -1
  10. package/dist/exports/codec-descriptor-registry.d.mts +17 -0
  11. package/dist/exports/codec-descriptor-registry.d.mts.map +1 -0
  12. package/dist/exports/codec-descriptor-registry.mjs +40 -0
  13. package/dist/exports/codec-descriptor-registry.mjs.map +1 -0
  14. package/dist/exports/errors.d.mts +1 -4
  15. package/dist/exports/errors.mjs +2 -3
  16. package/dist/exports/expression.d.mts +84 -0
  17. package/dist/exports/expression.d.mts.map +1 -0
  18. package/dist/exports/expression.mjs +62 -0
  19. package/dist/exports/expression.mjs.map +1 -0
  20. package/dist/exports/plan.d.mts +3 -2
  21. package/dist/exports/plan.mjs +1 -17
  22. package/dist/exports/query-lane-context.d.mts +2 -3
  23. package/dist/exports/query-lane-context.mjs +1 -1
  24. package/dist/exports/types.d.mts +3 -4
  25. package/dist/exports/types.mjs +1 -1
  26. package/dist/index.d.mts +10 -11
  27. package/dist/index.mjs +6 -5
  28. package/dist/plan-CZ6CFuSX.d.mts +24 -0
  29. package/dist/plan-CZ6CFuSX.d.mts.map +1 -0
  30. package/dist/query-lane-context-DaimN0zf.d.mts +174 -0
  31. package/dist/query-lane-context-DaimN0zf.d.mts.map +1 -0
  32. package/dist/sql-execution-plan-DgcD75jn.d.mts +32 -0
  33. package/dist/sql-execution-plan-DgcD75jn.d.mts.map +1 -0
  34. package/dist/types-BnLrX_Vr.d.mts +23 -0
  35. package/dist/types-BnLrX_Vr.d.mts.map +1 -0
  36. package/dist/{types-k9pir8XY.d.mts → types-Czw4j_wY.d.mts} +18 -25
  37. package/dist/types-Czw4j_wY.d.mts.map +1 -0
  38. package/dist/{types-C3Hg-CVz.d.mts → types-hwPoFZX2.d.mts} +36 -23
  39. package/dist/types-hwPoFZX2.d.mts.map +1 -0
  40. package/dist/types-vA5134SY.mjs +1072 -0
  41. package/dist/types-vA5134SY.mjs.map +1 -0
  42. package/package.json +16 -12
  43. package/src/ast/adapter-types.ts +6 -14
  44. package/src/ast/codec-types.ts +90 -372
  45. package/src/ast/sql-codec-helpers.ts +79 -0
  46. package/src/ast/sql-codecs.ts +285 -125
  47. package/src/ast/types.ts +170 -175
  48. package/src/ast/util.ts +23 -0
  49. package/src/ast/validate-param-refs.ts +39 -0
  50. package/src/codec-descriptor-registry.ts +52 -0
  51. package/src/exports/ast.ts +2 -0
  52. package/src/exports/codec-descriptor-registry.ts +1 -0
  53. package/src/exports/expression.ts +1 -0
  54. package/src/exports/plan.ts +1 -0
  55. package/src/exports/types.ts +1 -0
  56. package/src/expression.ts +134 -0
  57. package/src/index.ts +1 -0
  58. package/src/plan.ts +11 -30
  59. package/src/query-lane-context.ts +35 -55
  60. package/src/runtime-scope.ts +20 -0
  61. package/src/sql-execution-plan.ts +28 -0
  62. package/src/types.ts +9 -22
  63. package/dist/codec-types-DcEITed4.d.mts +0 -144
  64. package/dist/codec-types-DcEITed4.d.mts.map +0 -1
  65. package/dist/errors-ChY_dHam.d.mts.map +0 -1
  66. package/dist/exports/plan.mjs.map +0 -1
  67. package/dist/plan-Cs65hb-E.d.mts +0 -28
  68. package/dist/plan-Cs65hb-E.d.mts.map +0 -1
  69. package/dist/query-lane-context-UlR8vOkd.d.mts +0 -89
  70. package/dist/query-lane-context-UlR8vOkd.d.mts.map +0 -1
  71. package/dist/types-C3Hg-CVz.d.mts.map +0 -1
  72. package/dist/types-k9pir8XY.d.mts.map +0 -1
@@ -1 +1,2 @@
1
1
  export * from '../plan';
2
+ export type { SqlExecutionPlan } from '../sql-execution-plan';
@@ -1 +1,2 @@
1
+ export type { RuntimeScope, SqlOrmPlan } from '../runtime-scope';
1
2
  export * from '../types';
@@ -0,0 +1,134 @@
1
+ import type { ParamSpec } from '@prisma-next/operations';
2
+ import type { QueryOperationReturn } from '@prisma-next/sql-contract/types';
3
+ import type { SqlLoweringSpec } from '@prisma-next/sql-operations';
4
+ import type { AnyExpression as AstExpression } from './ast/types';
5
+ import { OperationExpr, ParamRef } from './ast/types';
6
+
7
+ export type ScopeField = { codecId: string; nullable: boolean };
8
+
9
+ /**
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.
11
+ */
12
+ export type Expression<T extends ScopeField> = QueryOperationReturn & {
13
+ readonly returnType: T;
14
+ buildAst(): AstExpression;
15
+ };
16
+
17
+ type CodecIdsWithTrait<
18
+ CT extends Record<string, { readonly input: unknown }>,
19
+ RequiredTraits extends readonly string[],
20
+ > = {
21
+ [K in keyof CT & string]: CT[K] extends { readonly traits: infer T }
22
+ ? [RequiredTraits[number]] extends [T]
23
+ ? K
24
+ : never
25
+ : never;
26
+ }[keyof CT & string];
27
+
28
+ type NullSuffix<N> = N extends true ? null : never;
29
+
30
+ /**
31
+ * An expression or literal value targeting a specific codec.
32
+ *
33
+ * Accepts any of:
34
+ * - An `Expression` whose codec matches exactly
35
+ * - A raw JS value of the codec's `input` type
36
+ * - `null` when `Nullable` is true
37
+ */
38
+ export type CodecExpression<
39
+ CodecId extends string,
40
+ Nullable extends boolean,
41
+ CT extends Record<string, { readonly input: unknown }>,
42
+ > =
43
+ | Expression<{ codecId: CodecId; nullable: Nullable }>
44
+ | (CodecId extends keyof CT ? CT[CodecId]['input'] : never)
45
+ | NullSuffix<Nullable>;
46
+
47
+ /**
48
+ * An expression or literal value targeting any codec whose trait set contains all the required traits.
49
+ *
50
+ * Resolves the trait set to the union of matching codec identities via `CodecIdsWithTrait`, then reuses `CodecExpression` for the codec-id form.
51
+ */
52
+ export type TraitExpression<
53
+ Traits extends readonly string[],
54
+ Nullable extends boolean,
55
+ CT extends Record<string, { readonly input: unknown }>,
56
+ > = CodecExpression<CodecIdsWithTrait<CT, Traits>, Nullable, CT>;
57
+
58
+ /**
59
+ * Resolve a raw value or an Expression into an AST expression node.
60
+ *
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.
64
+ */
65
+ export function toExpr(
66
+ value: unknown,
67
+ codecId?: string,
68
+ refs?: { table: string; column: string },
69
+ ): AstExpression {
70
+ if (isExpressionLike(value)) {
71
+ return value.buildAst();
72
+ }
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;
97
+ }
98
+
99
+ function isExpressionLike(value: unknown): value is Expression<ScopeField> {
100
+ return (
101
+ typeof value === 'object' &&
102
+ value !== null &&
103
+ 'buildAst' in value &&
104
+ typeof (value as { buildAst: unknown }).buildAst === 'function'
105
+ );
106
+ }
107
+
108
+ export interface BuildOperationSpec<R extends ScopeField> {
109
+ readonly method: string;
110
+ /**
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.
112
+ */
113
+ readonly args: readonly [AstExpression, ...AstExpression[]];
114
+ readonly returns: R & ParamSpec;
115
+ readonly lowering: SqlLoweringSpec;
116
+ }
117
+
118
+ /**
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.
120
+ */
121
+ export function buildOperation<R extends ScopeField>(spec: BuildOperationSpec<R>): Expression<R> {
122
+ const [self, ...rest] = spec.args;
123
+ const op = new OperationExpr({
124
+ method: spec.method,
125
+ self,
126
+ args: rest.length > 0 ? rest : undefined,
127
+ returns: spec.returns,
128
+ lowering: spec.lowering,
129
+ });
130
+ return {
131
+ returnType: spec.returns,
132
+ buildAst: () => op,
133
+ };
134
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './exports/ast';
2
2
  export * from './exports/errors';
3
+ export * from './exports/expression';
3
4
  export * from './exports/plan';
4
5
  export * from './exports/query-lane-context';
5
6
  export * from './exports/types';
package/src/plan.ts CHANGED
@@ -1,39 +1,20 @@
1
- import type { ExecutionPlan, ParamDescriptor } from '@prisma-next/contract/types';
2
- import type { StorageColumn } from '@prisma-next/sql-contract/types';
1
+ import type { QueryPlan } from '@prisma-next/framework-components/runtime';
3
2
  import type { AnyQueryAst } from './ast/types';
4
3
 
5
4
  /**
6
5
  * SQL query plan produced by lanes before lowering.
7
6
  *
8
- * Lanes build ASTs and metadata but do not perform SQL lowering.
9
- * The `sql` field is absent - lowering happens in the runtime executor.
7
+ * Lanes build ASTs and metadata but do not perform SQL lowering. The `sql`
8
+ * field is absent `RuntimeCore` (the runtime base class in
9
+ * `@prisma-next/framework-components/runtime`) drives lowering via the
10
+ * SQL adapter and produces a `SqlExecutionPlan`.
10
11
  *
11
- * Structurally aligns with ExecutionPlan<Row, AnyQueryAst> (without sql field) to maintain
12
- * compatibility with ExecutionPlan/Plan-based utilities.
13
- * The generic parameter `_Row` is preserved for type extraction via ResultType.
12
+ * Extends the framework-level `QueryPlan<Row>` marker (`meta + _row`) and
13
+ * adds SQL-specific fields (`ast`, `params`). The phantom `_row` property
14
+ * (inherited from `QueryPlan`) is what `ResultType<P>` inspects to recover
15
+ * the row type.
14
16
  */
15
- export interface SqlQueryPlan<_Row = unknown>
16
- extends Pick<ExecutionPlan<_Row, AnyQueryAst>, 'params' | 'meta'> {
17
+ export interface SqlQueryPlan<Row = unknown> extends QueryPlan<Row> {
17
18
  readonly ast: AnyQueryAst;
18
- // Phantom property to preserve generic parameter for type extraction
19
- // This allows ResultType to extract _Row for SqlQueryPlan values.
20
- readonly _Row?: _Row;
21
- }
22
-
23
- /**
24
- * Augments the last ParamDescriptor in the array with codecId and nativeType from columnMeta.
25
- * This is used when building WHERE expressions to ensure param descriptors have type information.
26
- */
27
- export function augmentDescriptorWithColumnMeta(
28
- descriptors: ParamDescriptor[],
29
- columnMeta: StorageColumn | undefined,
30
- ): void {
31
- const descriptor = descriptors[descriptors.length - 1];
32
- if (descriptor && columnMeta) {
33
- descriptors[descriptors.length - 1] = {
34
- ...descriptor,
35
- codecId: columnMeta.codecId,
36
- nativeType: columnMeta.nativeType,
37
- };
38
- }
19
+ readonly params: readonly unknown[];
39
20
  }
@@ -1,55 +1,31 @@
1
1
  import type { Contract } from '@prisma-next/contract/types';
2
+ import type { CodecDescriptor } from '@prisma-next/framework-components/codec';
2
3
  import type { SqlStorage } from '@prisma-next/sql-contract/types';
3
4
  import type { SqlOperationRegistry } from '@prisma-next/sql-operations';
4
- import type { CodecRegistry } from './ast/codec-types';
5
+ import type { ContractCodecRegistry } from './ast/codec-types';
5
6
 
6
7
  /**
7
- * Registry of initialized type helpers from storage.types.
8
- * Each key is a type name from storage.types, and the value is:
9
- * - The result of the codec's init hook (if provided), or
10
- * - The full StorageTypeInstance metadata (codecId, nativeType, typeParams) if no init hook
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).
11
9
  */
12
- export type TypeHelperRegistry = Record<string, unknown>;
13
-
14
- // =============================================================================
15
- // JSON Schema Validation Types
16
- // =============================================================================
17
-
18
- /**
19
- * A single validation error from JSON Schema validation.
20
- */
21
- export interface JsonSchemaValidationError {
22
- readonly path: string;
23
- readonly message: string;
24
- readonly keyword: string;
10
+ export interface CodecDescriptorRegistry {
11
+ /**
12
+ * Descriptors carry distinct param shapes per codec id; the registry is heterogeneous and the consumer narrows per codec.
13
+ */
14
+ descriptorFor(codecId: string): CodecDescriptor<unknown> | undefined;
15
+ /**
16
+ * All registered descriptors. Used by `validateCodecRegistryCompleteness` and other startup-time consumers that enumerate descriptors.
17
+ */
18
+ values(): IterableIterator<CodecDescriptor<unknown>>;
19
+ /**
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.
21
+ */
22
+ byTargetType(targetType: string): readonly CodecDescriptor<unknown>[];
25
23
  }
26
24
 
27
25
  /**
28
- * Result of a JSON Schema validation.
29
- */
30
- export type JsonSchemaValidationResult =
31
- | { readonly valid: true }
32
- | { readonly valid: false; readonly errors: ReadonlyArray<JsonSchemaValidationError> };
33
-
34
- /**
35
- * A compiled JSON Schema validate function.
36
- * Returns a structured result indicating whether the value conforms to the schema.
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).
37
27
  */
38
- export type JsonSchemaValidateFn = (value: unknown) => JsonSchemaValidationResult;
39
-
40
- /**
41
- * Registry of compiled JSON Schema validators for columns with typed JSON/JSONB.
42
- *
43
- * Built during context creation by scanning the contract for columns whose codec
44
- * descriptor provides an `init` hook that returns a `{ validate }` helper.
45
- * Keys are `"table.column"` (e.g., `"user.metadata"`).
46
- */
47
- export interface JsonSchemaValidatorRegistry {
48
- /** Get the compiled validator for a column. Key format: "table.column". */
49
- get(key: string): JsonSchemaValidateFn | undefined;
50
- /** Number of registered validators. */
51
- readonly size: number;
52
- }
28
+ export type TypeHelperRegistry = Record<string, unknown>;
53
29
 
54
30
  export type MutationDefaultsOp = 'create' | 'update';
55
31
 
@@ -62,32 +38,36 @@ export type MutationDefaultsOptions = {
62
38
  readonly op: MutationDefaultsOp;
63
39
  readonly table: string;
64
40
  readonly values: Record<string, unknown>;
41
+ /**
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).
44
+ */
45
+ readonly defaultValueCache?: Map<string, unknown>;
65
46
  };
66
47
 
67
48
  /**
68
49
  * Minimal context interface for SQL query lanes.
69
50
  *
70
- * Lanes only need contract, operations, and codecs to build typed ASTs and attach
71
- * operation builders. This interface explicitly excludes runtime concerns like
72
- * 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.
73
52
  */
74
53
  export interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
75
54
  readonly contract: TContract;
76
- readonly codecs: CodecRegistry;
77
- readonly queryOperations: SqlOperationRegistry;
78
55
  /**
79
- * Type helper registry for parameterized types.
80
- * Schema builders expose these helpers via schema.types.
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.
81
58
  */
82
- readonly types: TypeHelperRegistry;
59
+ readonly contractCodecs: ContractCodecRegistry;
83
60
  /**
84
- * Compiled JSON Schema validators for typed JSON/JSONB columns.
85
- * Present only when the contract declares columns with JSON Schema typeParams.
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.
86
62
  */
87
- readonly jsonSchemaValidators?: JsonSchemaValidatorRegistry;
63
+ readonly codecDescriptors: CodecDescriptorRegistry;
64
+ readonly queryOperations: SqlOperationRegistry;
65
+ /**
66
+ * Type helper registry for parameterized types. Schema builders expose these helpers via schema.types.
67
+ */
68
+ readonly types: TypeHelperRegistry;
88
69
  /**
89
- * Applies execution-time mutation defaults for the given table.
90
- * 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).
91
71
  */
92
72
  applyMutationDefaults(options: MutationDefaultsOptions): ReadonlyArray<AppliedMutationDefault>;
93
73
  }
@@ -0,0 +1,20 @@
1
+ import type { RuntimeExecutor } from '@prisma-next/framework-components/runtime';
2
+ import type { SqlQueryPlan } from './plan';
3
+ import type { SqlExecutionPlan } from './sql-execution-plan';
4
+
5
+ /**
6
+ * The plan shape accepted by the SQL ORM client and SQL runtime: either a
7
+ * pre-lowering `SqlQueryPlan` (AST + meta) or a post-lowering
8
+ * `SqlExecutionPlan` (sql + params + meta).
9
+ */
10
+ export type SqlOrmPlan = SqlExecutionPlan | SqlQueryPlan;
11
+
12
+ /**
13
+ * The minimal SQL-runtime surface that the ORM client and SQL runtime both
14
+ * depend on: the `execute` method of `RuntimeExecutor<SqlOrmPlan>`.
15
+ *
16
+ * Owned by `sql-relational-core` (lanes layer) so both
17
+ * `@prisma-next/sql-runtime` and `@prisma-next/sql-orm-client` consume the
18
+ * same source of truth without a layering inversion.
19
+ */
20
+ export type RuntimeScope = Pick<RuntimeExecutor<SqlOrmPlan>, 'execute'>;
@@ -0,0 +1,28 @@
1
+ import type { ExecutionPlan } from '@prisma-next/framework-components/runtime';
2
+ import type { AnyQueryAst } from './ast/types';
3
+
4
+ /**
5
+ * SQL-domain execution plan: a query lowered to the wire-level shape that a
6
+ * SQL driver can run.
7
+ *
8
+ * The plan carries:
9
+ * - `sql` — the rendered SQL text
10
+ * - `params` — the bound parameter list
11
+ * - `ast` — optional pre-lowering AST, retained for telemetry / debugging
12
+ * - `meta` — family-agnostic plan metadata (target, lane, hashes, ...)
13
+ * - `_row` — phantom row type, propagated from the originating `SqlQueryPlan`
14
+ *
15
+ * Extends the framework-level `ExecutionPlan<Row>` marker so generic SPIs
16
+ * (`RuntimeExecutor<SqlExecutionPlan>`, `RuntimeMiddleware<SqlExecutionPlan>`)
17
+ * can be parameterized over it.
18
+ *
19
+ * Co-located with `SqlQueryPlan` (its pre-lowering counterpart) in the lanes
20
+ * layer because lane-level utilities (`RawTemplateFactory`, `RawFactory`,
21
+ * `SqlPlan`) compose against the executable shape and the lanes layer cannot
22
+ * depend on the runtime layer.
23
+ */
24
+ export interface SqlExecutionPlan<Row = unknown> extends ExecutionPlan<Row> {
25
+ readonly sql: string;
26
+ readonly params: readonly unknown[];
27
+ readonly ast?: AnyQueryAst;
28
+ }
package/src/types.ts CHANGED
@@ -1,9 +1,4 @@
1
- import type {
2
- Contract,
3
- ResultType as CoreResultType,
4
- ExecutionPlan,
5
- PlanRefs,
6
- } from '@prisma-next/contract/types';
1
+ import type { Contract } from '@prisma-next/contract/types';
7
2
  import type { ParamSpec } from '@prisma-next/operations';
8
3
  import type {
9
4
  ExtractFieldOutputTypes,
@@ -11,9 +6,9 @@ import type {
11
6
  StorageColumn,
12
7
  } from '@prisma-next/sql-contract/types';
13
8
  import type { SqlLoweringSpec } from '@prisma-next/sql-operations';
14
- import type { AnyQueryAst, ColumnRef, ParamRef } from './ast/types';
15
- import type { SqlQueryPlan } from './plan';
9
+ import type { ColumnRef, ParamRef } from './ast/types';
16
10
  import type { ExecutionContext } from './query-lane-context';
11
+ import type { SqlExecutionPlan } from './sql-execution-plan';
17
12
 
18
13
  export type Expr = ColumnRef | ParamRef;
19
14
 
@@ -179,10 +174,11 @@ export type HasIncludeManyCapabilities<TContract extends Contract<SqlStorage>> =
179
174
  : false;
180
175
 
181
176
  /**
182
- * SQL-specific Plan type that refines the ast field to use AnyQueryAst.
183
- * This is the type used by SQL query builders.
177
+ * Alias for the SQL-domain executable plan, exposed under the legacy
178
+ * `SqlPlan` name for compatibility with SQL builder/utility call sites.
179
+ * The canonical name is `SqlExecutionPlan` (`./sql-execution-plan`).
184
180
  */
185
- export type SqlPlan<Row = unknown> = ExecutionPlan<Row, AnyQueryAst>;
181
+ export type SqlPlan<Row = unknown> = SqlExecutionPlan<Row>;
186
182
 
187
183
  /**
188
184
  * Helper types for extracting contract structure.
@@ -248,9 +244,7 @@ export type ColumnsOf<
248
244
  : never;
249
245
 
250
246
  export interface RawTemplateOptions {
251
- readonly refs?: PlanRefs;
252
247
  readonly annotations?: Record<string, unknown>;
253
- readonly projection?: ReadonlyArray<string>;
254
248
  }
255
249
 
256
250
  export interface RawFunctionOptions extends RawTemplateOptions {
@@ -260,10 +254,10 @@ export interface RawFunctionOptions extends RawTemplateOptions {
260
254
  export type RawTemplateFactory = (
261
255
  strings: TemplateStringsArray,
262
256
  ...values: readonly unknown[]
263
- ) => ExecutionPlan;
257
+ ) => SqlExecutionPlan;
264
258
 
265
259
  export interface RawFactory extends RawTemplateFactory {
266
- (text: string, options: RawFunctionOptions): ExecutionPlan;
260
+ (text: string, options: RawFunctionOptions): SqlExecutionPlan;
267
261
  with(options: RawTemplateOptions): RawTemplateFactory;
268
262
  }
269
263
 
@@ -287,10 +281,3 @@ export interface BuildOptions {
287
281
  export interface SqlBuilderOptions<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
288
282
  readonly context: ExecutionContext<TContract>;
289
283
  }
290
-
291
- /**
292
- * SQL-specific ResultType that works with both Plan and SqlQueryPlan.
293
- * This extends the core ResultType to also handle SqlQueryPlan.
294
- * Example: `type Row = ResultType<typeof plan>`
295
- */
296
- export type ResultType<P> = P extends SqlQueryPlan<infer R> ? R : CoreResultType<P>;
@@ -1,144 +0,0 @@
1
- import { Type } from "arktype";
2
- import { JsonValue } from "@prisma-next/contract/types";
3
- import { Codec, 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
- * Descriptor for parameterized codecs that require type parameter validation.
10
- * Shared between adapter (compile-time) and runtime layers to avoid duplication.
11
- *
12
- * @template TParams - The shape of the type parameters (e.g., `{ length: number }`)
13
- * @template THelper - The type returned by the optional `init` hook
14
- */
15
- interface CodecParamsDescriptor<TParams = Record<string, unknown>, THelper = unknown> {
16
- /** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */
17
- readonly codecId: string;
18
- /**
19
- * Arktype schema for validating typeParams.
20
- * Used to validate both storage.types entries and inline column typeParams.
21
- */
22
- readonly paramsSchema: Type<TParams>;
23
- /**
24
- * Optional init hook called during runtime context creation.
25
- * Receives validated params and returns a helper object to be stored in context.types.
26
- * If not provided, the validated params are stored directly.
27
- */
28
- readonly init?: (params: TParams) => THelper;
29
- }
30
- /**
31
- * Codec metadata for database-specific type information.
32
- * Used for schema introspection and verification.
33
- */
34
- interface CodecMeta {
35
- readonly db?: {
36
- readonly sql?: {
37
- readonly postgres?: {
38
- readonly nativeType: string;
39
- };
40
- };
41
- };
42
- }
43
- /**
44
- * SQL codec interface — extends the framework base with SQL-specific fields.
45
- *
46
- * Codecs are pure, synchronous functions with no side effects or IO.
47
- * They provide deterministic conversion between database wire types and JS values,
48
- * and between JS values and contract JSON.
49
- */
50
- interface Codec$1<Id$1 extends string = string, TTraits$1 extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TJs = unknown, TParams = Record<string, unknown>, THelper = unknown> extends Codec<Id$1, TTraits$1, TWire, TJs> {
51
- readonly meta?: CodecMeta;
52
- readonly paramsSchema?: Type<TParams>;
53
- readonly init?: (params: TParams) => THelper;
54
- }
55
- /**
56
- * Registry interface for codecs organized by ID and by contract scalar type.
57
- *
58
- * The registry allows looking up codecs by their namespaced ID or by the
59
- * contract scalar types they handle. Multiple codecs may handle the same
60
- * scalar type; ordering in byScalar reflects preference (adapter first,
61
- * then packs, then app overrides).
62
- */
63
- interface CodecRegistry {
64
- get(id: string): Codec$1<string> | undefined;
65
- has(id: string): boolean;
66
- getByScalar(scalar: string): readonly Codec$1<string>[];
67
- getDefaultCodec(scalar: string): Codec$1<string> | undefined;
68
- register(codec: Codec$1<string>): void;
69
- /** Returns true if the codec with this ID has the given trait. */
70
- hasTrait(codecId: string, trait: CodecTrait): boolean;
71
- /** Returns all traits for a codec, or an empty array if not found. */
72
- traitsOf(codecId: string): readonly CodecTrait[];
73
- [Symbol.iterator](): Iterator<Codec$1<string>>;
74
- values(): IterableIterator<Codec$1<string>>;
75
- }
76
- /**
77
- * Codec factory - creates a codec with typeId and encode/decode functions.
78
- * Provides identity defaults for encodeJson/decodeJson when not supplied.
79
- */
80
- declare function codec<Id$1 extends string, const TTraits$1 extends readonly CodecTrait[], TWire, TJs, TParams = Record<string, unknown>, THelper = unknown>(config: {
81
- typeId: Id$1;
82
- targetTypes: readonly string[];
83
- encode: (value: TJs) => TWire;
84
- decode: (wire: TWire) => TJs;
85
- encodeJson?: (value: TJs) => JsonValue;
86
- decodeJson?: (json: JsonValue) => TJs;
87
- meta?: CodecMeta;
88
- paramsSchema?: Type<TParams>;
89
- init?: (params: TParams) => THelper;
90
- traits?: TTraits$1;
91
- renderOutputType?: (typeParams: Record<string, unknown>) => string | undefined;
92
- }): Codec$1<Id$1, TTraits$1, TWire, TJs, TParams, THelper>;
93
- /**
94
- * Type helpers to extract codec types.
95
- */
96
- type CodecId<T> = T extends Codec$1<infer Id> ? Id : T extends {
97
- readonly id: infer Id;
98
- } ? Id : never;
99
- type CodecInput<T> = T extends Codec$1<string, readonly CodecTrait[], unknown, infer JsT> ? JsT : never;
100
- type CodecOutput<T> = T extends Codec$1<string, readonly CodecTrait[], unknown, infer JsT> ? JsT : never;
101
- type CodecTraits<T> = T extends Codec$1<string, infer TTraits> ? TTraits[number] & CodecTrait : never;
102
- /**
103
- * Type helper to extract codec types from builder instance.
104
- */
105
- 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]: {
106
- readonly input: CodecInput<ScalarNames[K]>;
107
- readonly output: CodecOutput<ScalarNames[K]>;
108
- readonly traits: CodecTraits<ScalarNames[K]>;
109
- } };
110
- /**
111
- * Type helper to extract data type IDs from builder instance.
112
- * Uses ExtractCodecTypes which preserves literal types as keys.
113
- * Since ExtractCodecTypes<Record<K, ScalarNames[K]>> has exactly one key (the Id),
114
- * we extract it by creating a mapped type that uses the Id as both key and value,
115
- * then extract the value type. This preserves literal types.
116
- */
117
- 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]>>] };
118
- /**
119
- * Builder interface for declaring codecs.
120
- */
121
- interface CodecDefBuilder<ScalarNames extends { readonly [K in keyof ScalarNames]: Codec$1<string> } = Record<never, never>> {
122
- readonly CodecTypes: ExtractCodecTypes<ScalarNames>;
123
- add<ScalarName extends string, CodecImpl extends Codec$1<string>>(scalarName: ScalarName, codecImpl: CodecImpl): CodecDefBuilder<O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>>;
124
- readonly codecDefinitions: { readonly [K in keyof ScalarNames]: {
125
- readonly typeId: ScalarNames[K] extends Codec$1<infer Id extends string> ? Id : never;
126
- readonly scalar: K;
127
- readonly codec: ScalarNames[K];
128
- readonly input: CodecInput<ScalarNames[K]>;
129
- readonly output: CodecOutput<ScalarNames[K]>;
130
- readonly jsType: CodecOutput<ScalarNames[K]>;
131
- } };
132
- readonly dataTypes: { readonly [K in keyof ScalarNames]: { readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>] };
133
- }
134
- /**
135
- * Create a new codec registry.
136
- */
137
- declare function createCodecRegistry(): CodecRegistry;
138
- /**
139
- * Create a new codec definition builder.
140
- */
141
- declare function defineCodecs(): CodecDefBuilder<Record<never, never>>;
142
- //#endregion
143
- export { CodecMeta as a, CodecRegistry as c, ExtractCodecTypes as d, ExtractDataTypes as f, defineCodecs as h, CodecInput as i, CodecTrait$1 as l, createCodecRegistry as m, CodecDefBuilder as n, CodecOutput as o, codec as p, CodecId as r, CodecParamsDescriptor as s, Codec$1 as t, CodecTraits as u };
144
- //# sourceMappingURL=codec-types-DcEITed4.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec-types-DcEITed4.d.mts","names":[],"sources":["../src/ast/codec-types.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAeA;;;;;;AAe8C,UAf7B,qBAe6B,CAAA,UAfG,MAeH,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,UAAA,OAAA,CAAA,CAAA;EAO7B;EAiBA,SAAA,OAAK,EAAA,MAAA;EAEK;;;;EAKH,SAAA,YAAA,EAtCC,IAsCD,CAtCM,OAsCN,CAAA;EAAS;;;;;EAGN,SAAA,IAAA,CAAA,EAAA,CAAA,MAAA,EAlCA,OAkCA,EAAA,GAlCY,OAkCZ;;;;AAW3B;;AAGwC,UAzCvB,SAAA,CAyCuB;EACL,SAAA,EAAA,CAAA,EAAA;IACjB,SAAA,GAAA,CAAA,EAAA;MAEiB,SAAA,QAAA,CAAA,EAAA;QAEG,SAAA,UAAA,EAAA,MAAA;MACN,CAAA;IAAT,CAAA;EACM,CAAA;;;AAmG7B;;;;;;AAWiB,UA9IA,OA8IA,CAAA,aAAA,MAAA,GAAA,MAAA,EAAA,kBAAA,SA5IU,UA4IV,EAAA,GAAA,SA5IkC,UA4IlC,EAAA,EAAA,QAAA,OAAA,EAAA,MAAA,OAAA,EAAA,UAzIL,MAyIK,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,UAAA,OAAA,CAAA,SAvIP,KAuIO,CAvIG,IAuIH,EAvIO,SAuIP,EAvIgB,KAuIhB,EAvIuB,GAuIvB,CAAA,CAAA;EAAU,SAAA,IAAA,CAAA,EAtIT,SAsIS;EACJ,SAAA,YAAA,CAAA,EAtIG,IAsIH,CAtIQ,OAsIR,CAAA;EAAQ,SAAA,IAAA,CAAA,EAAA,CAAA,MAAA,EArIJ,OAqII,EAAA,GArIQ,OAqIR;;;;;;;;;;AAOrB,UAjIO,aAAA,CAiIP;EAAI,GAAA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AA,gBAAA,EAAA,iBAAY,MAIvB,WAJuB,GAAA;IAAnB,SAAA,MAAA,EAKN,WALM,CAKM,CALN,CAAA,SAKiB,OALjB,CAAA,KAAA,YAAA,MAAA,CAAA,GAAA,EAAA,GAAA,KAAA;IAAvB,SAAA,MAAA,EAMiB,CANjB;IAA+D,SAAA,KAAA,EAO/C,WAP+C,CAOnC,CAPmC,CAAA;IAAY,SAAA,KAAA,EAQ3D,UAR2D,CAQhD,WARgD,CAQpC,CARoC,CAAA,CAAA;IAAnB,SAAA,MAAA,EASvC,WATuC,CAS3B,WAT2B,CASf,CATe,CAAA,CAAA;IADzD,SAAA,MAAA,EAWkB,WAXlB,CAW8B,WAX9B,CAW0C,CAX1C,CAAA,CAAA;EAKoB,CAAA,EACF;EAAY,SAAA,SAAA,EAAA,iBAAW,MAUrB,WAVqB,GAAA,kBACvB,MAUK,iBAVL,CAUuB,MAVvB,CAU8B,CAV9B,EAUiC,WAVjC,CAU6C,CAV7C,CAAA,CAAA,CAAA,GAUoD,EAVpD,EACD,CAAA,MAUV,iBAVU,CAUQ,MAVR,CAUe,CAVf,EAUkB,WAVlB,CAU8B,CAV9B,CAAA,CAAA,CAAA,CAAA,EAAY;;;;;AAEa,iBAiI/B,mBAAA,CAAA,CAjI+B,EAiIR,aAjIQ;;;;AACxB,iBAuIP,YAAA,CAAA,CAvIO,EAuIS,eAvIT,CAuIyB,MAvIzB,CAAA,KAAA,EAAA,KAAA,CAAA,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-ChY_dHam.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,WAAA,4BAEJ,+EAGT;iBAkBa,eAAA,4BAEJ,+EAGT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plan.mjs","names":[],"sources":["../../src/plan.ts"],"sourcesContent":["import type { ExecutionPlan, ParamDescriptor } from '@prisma-next/contract/types';\nimport type { StorageColumn } from '@prisma-next/sql-contract/types';\nimport type { AnyQueryAst } from './ast/types';\n\n/**\n * SQL query plan produced by lanes before lowering.\n *\n * Lanes build ASTs and metadata but do not perform SQL lowering.\n * The `sql` field is absent - lowering happens in the runtime executor.\n *\n * Structurally aligns with ExecutionPlan<Row, AnyQueryAst> (without sql field) to maintain\n * compatibility with ExecutionPlan/Plan-based utilities.\n * The generic parameter `_Row` is preserved for type extraction via ResultType.\n */\nexport interface SqlQueryPlan<_Row = unknown>\n extends Pick<ExecutionPlan<_Row, AnyQueryAst>, 'params' | 'meta'> {\n readonly ast: AnyQueryAst;\n // Phantom property to preserve generic parameter for type extraction\n // This allows ResultType to extract _Row for SqlQueryPlan values.\n readonly _Row?: _Row;\n}\n\n/**\n * Augments the last ParamDescriptor in the array with codecId and nativeType from columnMeta.\n * This is used when building WHERE expressions to ensure param descriptors have type information.\n */\nexport function augmentDescriptorWithColumnMeta(\n descriptors: ParamDescriptor[],\n columnMeta: StorageColumn | undefined,\n): void {\n const descriptor = descriptors[descriptors.length - 1];\n if (descriptor && columnMeta) {\n descriptors[descriptors.length - 1] = {\n ...descriptor,\n codecId: columnMeta.codecId,\n nativeType: columnMeta.nativeType,\n };\n }\n}\n"],"mappings":";;;;;AA0BA,SAAgB,gCACd,aACA,YACM;CACN,MAAM,aAAa,YAAY,YAAY,SAAS;AACpD,KAAI,cAAc,WAChB,aAAY,YAAY,SAAS,KAAK;EACpC,GAAG;EACH,SAAS,WAAW;EACpB,YAAY,WAAW;EACxB"}
@@ -1,28 +0,0 @@
1
- import { d as AnyQueryAst } from "./types-C3Hg-CVz.mjs";
2
- import { ExecutionPlan, ParamDescriptor } from "@prisma-next/contract/types";
3
- import { StorageColumn } from "@prisma-next/sql-contract/types";
4
-
5
- //#region src/plan.d.ts
6
-
7
- /**
8
- * SQL query plan produced by lanes before lowering.
9
- *
10
- * Lanes build ASTs and metadata but do not perform SQL lowering.
11
- * The `sql` field is absent - lowering happens in the runtime executor.
12
- *
13
- * Structurally aligns with ExecutionPlan<Row, AnyQueryAst> (without sql field) to maintain
14
- * compatibility with ExecutionPlan/Plan-based utilities.
15
- * The generic parameter `_Row` is preserved for type extraction via ResultType.
16
- */
17
- interface SqlQueryPlan<_Row = unknown> extends Pick<ExecutionPlan<_Row, AnyQueryAst>, 'params' | 'meta'> {
18
- readonly ast: AnyQueryAst;
19
- readonly _Row?: _Row;
20
- }
21
- /**
22
- * Augments the last ParamDescriptor in the array with codecId and nativeType from columnMeta.
23
- * This is used when building WHERE expressions to ensure param descriptors have type information.
24
- */
25
- declare function augmentDescriptorWithColumnMeta(descriptors: ParamDescriptor[], columnMeta: StorageColumn | undefined): void;
26
- //#endregion
27
- export { augmentDescriptorWithColumnMeta as n, SqlQueryPlan as t };
28
- //# sourceMappingURL=plan-Cs65hb-E.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plan-Cs65hb-E.d.mts","names":[],"sources":["../src/plan.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAcA;;;;;;;;AAYgB,UAZC,YAYD,CAAA,OAAA,OAA+B,CAAA,SAXrC,IAYK,CAZA,aAaD,CAbe,IAaf,EAbqB,WAaR,CAAA,EAAA,QAAA,GAAA,MAAA,CAAA,CAAA;gBAZX;kBAGE;;;;;;iBAOF,+BAAA,cACD,+BACD"}