@prisma-next/sql-relational-core 0.6.0-dev.6 → 0.6.0-dev.8
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 +1 -1
- package/dist/{codec-types-BUfBna4G.d.mts → codec-types-Cezo7k-i.d.mts} +9 -9
- package/dist/codec-types-Cezo7k-i.d.mts.map +1 -0
- package/dist/{errors-BgNpVAT8.d.mts → errors-D2KewtVl.d.mts} +2 -2
- package/dist/{errors-BgNpVAT8.d.mts.map → errors-D2KewtVl.d.mts.map} +1 -1
- package/dist/exports/ast.d.mts +3 -12
- package/dist/exports/ast.d.mts.map +1 -1
- package/dist/exports/ast.mjs +2 -32
- package/dist/exports/ast.mjs.map +1 -1
- package/dist/exports/codec-descriptor-registry.d.mts +20 -4
- package/dist/exports/codec-descriptor-registry.d.mts.map +1 -1
- package/dist/exports/codec-descriptor-registry.mjs +38 -2
- package/dist/exports/codec-descriptor-registry.mjs.map +1 -1
- package/dist/exports/errors.d.mts +1 -1
- package/dist/exports/expression.d.mts +17 -16
- package/dist/exports/expression.d.mts.map +1 -1
- package/dist/exports/expression.mjs +19 -25
- package/dist/exports/expression.mjs.map +1 -1
- package/dist/exports/middleware.d.mts +1 -1
- package/dist/exports/middleware.mjs +1 -1
- package/dist/exports/plan.d.mts +2 -2
- package/dist/exports/query-lane-context.d.mts +1 -1
- package/dist/exports/types.d.mts +2 -2
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +5 -5
- package/dist/{middleware-USDeR8p1.d.mts → middleware-CfWhG9hx.d.mts} +3 -9
- package/dist/middleware-CfWhG9hx.d.mts.map +1 -0
- package/dist/{middleware-D2Wv9QIf.mjs → middleware-DGoIUH9C.mjs} +5 -17
- package/dist/middleware-DGoIUH9C.mjs.map +1 -0
- package/dist/{plan-DFpOIsKB.d.mts → plan-DmBWXsDN.d.mts} +2 -2
- package/dist/{plan-DFpOIsKB.d.mts.map → plan-DmBWXsDN.d.mts.map} +1 -1
- package/dist/{query-lane-context-C2tLZGp4.d.mts → query-lane-context-DHsPbikl.d.mts} +16 -5
- package/dist/query-lane-context-DHsPbikl.d.mts.map +1 -0
- package/dist/{sql-execution-plan-ffz8TSfr.d.mts → sql-execution-plan-DM2Hcvvn.d.mts} +2 -2
- package/dist/{sql-execution-plan-ffz8TSfr.d.mts.map → sql-execution-plan-DM2Hcvvn.d.mts.map} +1 -1
- package/dist/{types-D6Pk1DTr.d.mts → types-BQK1PdQu.d.mts} +4 -4
- package/dist/{types-D6Pk1DTr.d.mts.map → types-BQK1PdQu.d.mts.map} +1 -1
- package/dist/{types-CL18G37a.d.mts → types-BWJCGyVL.d.mts} +3 -3
- package/dist/{types-CL18G37a.d.mts.map → types-BWJCGyVL.d.mts.map} +1 -1
- package/dist/{types-CK9ZJ6OU.mjs → types-DRYJSMk1.mjs} +27 -18
- package/dist/types-DRYJSMk1.mjs.map +1 -0
- package/dist/{types-BZcKgaYA.d.mts → types-juiKe2qf.d.mts} +18 -25
- package/dist/types-juiKe2qf.d.mts.map +1 -0
- package/package.json +10 -10
- package/src/ast/codec-types.ts +8 -6
- package/src/ast/types.ts +32 -38
- package/src/codec-descriptor-registry.ts +8 -1
- package/src/codec-ref-for-column.ts +34 -0
- package/src/exports/ast.ts +0 -1
- package/src/exports/codec-descriptor-registry.ts +1 -0
- package/src/expression.ts +35 -24
- package/src/middleware/param-ref-mutator.ts +3 -19
- package/src/query-lane-context.ts +14 -3
- package/dist/codec-types-BUfBna4G.d.mts.map +0 -1
- package/dist/middleware-D2Wv9QIf.mjs.map +0 -1
- package/dist/middleware-USDeR8p1.d.mts.map +0 -1
- package/dist/query-lane-context-C2tLZGp4.d.mts.map +0 -1
- package/dist/types-BZcKgaYA.d.mts.map +0 -1
- package/dist/types-CK9ZJ6OU.mjs.map +0 -1
- package/src/ast/validate-param-refs.ts +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.mjs","names":[],"sources":["../../src/expression.ts"],"sourcesContent":["import type { ParamSpec } from '@prisma-next/operations';\nimport type { QueryOperationReturn } from '@prisma-next/sql-contract/types';\nimport type { SqlLoweringSpec } from '@prisma-next/sql-operations';\nimport type { AnyExpression as AstExpression } from './ast/types';\nimport { OperationExpr, ParamRef } from './ast/types';\n\nexport type ScopeField = {
|
|
1
|
+
{"version":3,"file":"expression.mjs","names":[],"sources":["../../src/expression.ts"],"sourcesContent":["import { runtimeError } from '@prisma-next/framework-components/runtime';\nimport type { ParamSpec } from '@prisma-next/operations';\nimport type { QueryOperationReturn } from '@prisma-next/sql-contract/types';\nimport type { SqlLoweringSpec } from '@prisma-next/sql-operations';\nimport type { CodecRef } from './ast/codec-types';\nimport type { AnyExpression as AstExpression } from './ast/types';\nimport { OperationExpr, ParamRef } from './ast/types';\n\nexport type ScopeField = {\n codecId: string;\n nullable: boolean;\n /**\n * Optional {@link CodecRef} derived from contract storage at scope construction time. Builder paths that mint column-bound `ParamRef` / `ProjectionItem` nodes stamp this slot onto the AST so encode/decode dispatch resolves through `contractCodecs.forCodecRef`. Leave `undefined` when the scope was built without contract storage (rare — tests, ad-hoc scopes).\n */\n codec?: CodecRef;\n};\n\n/**\n * 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.\n */\nexport type Expression<T extends ScopeField> = QueryOperationReturn & {\n readonly returnType: T;\n buildAst(): AstExpression;\n};\n\ntype CodecIdsWithTrait<\n CT extends Record<string, { readonly input: unknown }>,\n RequiredTraits extends readonly string[],\n> = {\n [K in keyof CT & string]: CT[K] extends { readonly traits: infer T }\n ? [RequiredTraits[number]] extends [T]\n ? K\n : never\n : never;\n}[keyof CT & string];\n\ntype NullSuffix<N> = N extends true ? null : never;\n\n/**\n * An expression or literal value targeting a specific codec.\n *\n * Accepts any of:\n * - An `Expression` whose codec matches exactly\n * - A raw JS value of the codec's `input` type\n * - `null` when `Nullable` is true\n */\nexport type CodecExpression<\n CodecId extends string,\n Nullable extends boolean,\n CT extends Record<string, { readonly input: unknown }>,\n> =\n | Expression<{ codecId: CodecId; nullable: Nullable }>\n | (CodecId extends keyof CT ? CT[CodecId]['input'] : never)\n | NullSuffix<Nullable>;\n\n/**\n * An expression or literal value targeting any codec whose trait set contains all the required traits.\n *\n * Resolves the trait set to the union of matching codec identities via `CodecIdsWithTrait`, then reuses `CodecExpression` for the codec-id form.\n */\nexport type TraitExpression<\n Traits extends readonly string[],\n Nullable extends boolean,\n CT extends Record<string, { readonly input: unknown }>,\n> = CodecExpression<CodecIdsWithTrait<CT, Traits>, Nullable, CT>;\n\n/**\n * Resolve a raw value or an Expression into an AST expression node.\n *\n * 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 the caller-supplied {@link CodecRef} (when known). The runtime resolves the ref via `contractCodecs.forCodecRef(codec)`; content-keyed memoisation collapses repeated lookups for the same logical column onto one shared codec.\n *\n * Operation implementations that compare a column-bound expression to a user value derive the column's {@link CodecRef} from the column-bound side (via {@link codecOf}) and forward it here so encode-side dispatch resolves to the per-instance codec for parameterized codec ids (`vector(1024)` vs. `vector(1536)`).\n */\nexport function toExpr(value: unknown, codec?: CodecRef): AstExpression {\n if (isExpressionLike(value)) {\n return value.buildAst();\n }\n if (codec === undefined) {\n throw runtimeError(\n 'RUNTIME.PARAM_REF_CODEC_REQUIRED',\n `Cannot construct a ParamRef for a ${value === null ? 'null' : typeof value} value without an explicit codec. ` +\n 'Provide a CodecRef at the call site or use a column-bound builder path.',\n );\n }\n return ParamRef.of(value, { codec });\n}\n\n/**\n * Derive the {@link CodecRef} carried by an expression-like value.\n *\n * Resolution order:\n * 1. `wrapper.codec` — explicit column-bound {@link CodecRef} stamped at field-proxy time.\n * 2. `wrapper.returnType.codec` — scope-level codec when the scope was built from contract storage.\n * 3. `{ codecId: wrapper.returnType.codecId }` — minimal ref derived from the expression's declared codec id (covers synthetic expressions like `count()` whose returnType has a known codec id but no explicit column binding).\n *\n * Returns `undefined` for raw scalar values (non-expression-like).\n */\nexport function codecOf(value: unknown): CodecRef | undefined {\n if (!isExpressionLike(value)) return undefined;\n const wrapper = value as {\n codec?: CodecRef;\n returnType?: { codec?: CodecRef; codecId?: string };\n };\n if (wrapper.codec) return wrapper.codec;\n if (wrapper.returnType?.codec) return wrapper.returnType.codec;\n if (wrapper.returnType?.codecId) return { codecId: wrapper.returnType.codecId };\n return undefined;\n}\n\nfunction isExpressionLike(value: unknown): value is Expression<ScopeField> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'buildAst' in value &&\n typeof (value as { buildAst: unknown }).buildAst === 'function'\n );\n}\n\nexport interface BuildOperationSpec<R extends ScopeField> {\n readonly method: string;\n /**\n * 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.\n */\n readonly args: readonly [AstExpression, ...AstExpression[]];\n readonly returns: R & ParamSpec;\n readonly lowering: SqlLoweringSpec;\n}\n\n/**\n * 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.\n */\nexport function buildOperation<R extends ScopeField>(spec: BuildOperationSpec<R>): Expression<R> {\n const [self, ...rest] = spec.args;\n const op = new OperationExpr({\n method: spec.method,\n self,\n args: rest.length > 0 ? rest : undefined,\n returns: spec.returns,\n lowering: spec.lowering,\n });\n return {\n returnType: spec.returns,\n buildAst: () => op,\n };\n}\n"],"mappings":";;;;;;;;;;AAyEA,SAAgB,OAAO,OAAgB,OAAiC;CACtE,IAAI,iBAAiB,MAAM,EACzB,OAAO,MAAM,UAAU;CAEzB,IAAI,UAAU,KAAA,GACZ,MAAM,aACJ,oCACA,qCAAqC,UAAU,OAAO,SAAS,OAAO,MAAM,2GAE7E;CAEH,OAAO,SAAS,GAAG,OAAO,EAAE,OAAO,CAAC;;;;;;;;;;;;AAatC,SAAgB,QAAQ,OAAsC;CAC5D,IAAI,CAAC,iBAAiB,MAAM,EAAE,OAAO,KAAA;CACrC,MAAM,UAAU;CAIhB,IAAI,QAAQ,OAAO,OAAO,QAAQ;CAClC,IAAI,QAAQ,YAAY,OAAO,OAAO,QAAQ,WAAW;CACzD,IAAI,QAAQ,YAAY,SAAS,OAAO,EAAE,SAAS,QAAQ,WAAW,SAAS;;AAIjF,SAAS,iBAAiB,OAAiD;CACzE,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAc,SACd,OAAQ,MAAgC,aAAa;;;;;AAiBzD,SAAgB,eAAqC,MAA4C;CAC/F,MAAM,CAAC,MAAM,GAAG,QAAQ,KAAK;CAC7B,MAAM,KAAK,IAAI,cAAc;EAC3B,QAAQ,KAAK;EACb;EACA,MAAM,KAAK,SAAS,IAAI,OAAO,KAAA;EAC/B,SAAS,KAAK;EACd,UAAU,KAAK;EAChB,CAAC;CACF,OAAO;EACL,YAAY,KAAK;EACjB,gBAAgB;EACjB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "../middleware-
|
|
1
|
+
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "../middleware-CfWhG9hx.mjs";
|
|
2
2
|
export { ParamRefEntry, ParamRefEntryUnion, ParamRefHandle, SqlParamRefMutator, SqlParamRefMutatorInternal, createSqlParamRefMutator };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createSqlParamRefMutator } from "../middleware-
|
|
1
|
+
import { t as createSqlParamRefMutator } from "../middleware-DGoIUH9C.mjs";
|
|
2
2
|
export { createSqlParamRefMutator };
|
package/dist/exports/plan.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as SqlExecutionPlan } from "../sql-execution-plan-
|
|
2
|
-
import { n as planFromAst, t as SqlQueryPlan } from "../plan-
|
|
1
|
+
import { t as SqlExecutionPlan } from "../sql-execution-plan-DM2Hcvvn.mjs";
|
|
2
|
+
import { n as planFromAst, t as SqlQueryPlan } from "../plan-DmBWXsDN.mjs";
|
|
3
3
|
export { type SqlExecutionPlan, SqlQueryPlan, planFromAst };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MutationDefaultsOptions, i as MutationDefaultsOp, n as CodecDescriptorRegistry, o as TypeHelperRegistry, r as ExecutionContext, t as AppliedMutationDefault } from "../query-lane-context-
|
|
1
|
+
import { a as MutationDefaultsOptions, i as MutationDefaultsOp, n as CodecDescriptorRegistry, o as TypeHelperRegistry, r as ExecutionContext, t as AppliedMutationDefault } from "../query-lane-context-DHsPbikl.mjs";
|
|
2
2
|
export { AppliedMutationDefault, CodecDescriptorRegistry, ExecutionContext, MutationDefaultsOp, MutationDefaultsOptions, TypeHelperRegistry };
|
package/dist/exports/types.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as TableKey, S as TableDef, T as TablesOf, _ as RawTemplateFactory, a as ComputeColumnJsType, b as SqlBuilderOptions, c as META, d as ModelMetadata, f as OperationTypeSignature, g as RawFunctionOptions, h as RawFactory, i as ColumnsOf, l as Meta, m as OperationsForTypeId, n as BuildParamsMap, o as Expr, p as OperationTypes, r as CodecTypes, s as HasIncludeManyCapabilities, t as BuildOptions, u as ModelDef, v as RawTemplateOptions, w as TableMetadata, x as SqlPlan, y as RuntimeError } from "../types-
|
|
2
|
-
import { n as SqlOrmPlan, t as RuntimeScope } from "../types-
|
|
1
|
+
import { C as TableKey, S as TableDef, T as TablesOf, _ as RawTemplateFactory, a as ComputeColumnJsType, b as SqlBuilderOptions, c as META, d as ModelMetadata, f as OperationTypeSignature, g as RawFunctionOptions, h as RawFactory, i as ColumnsOf, l as Meta, m as OperationsForTypeId, n as BuildParamsMap, o as Expr, p as OperationTypes, r as CodecTypes, s as HasIncludeManyCapabilities, t as BuildOptions, u as ModelDef, v as RawTemplateOptions, w as TableMetadata, x as SqlPlan, y as RuntimeError } from "../types-BQK1PdQu.mjs";
|
|
2
|
+
import { n as SqlOrmPlan, t as RuntimeScope } from "../types-BWJCGyVL.mjs";
|
|
3
3
|
export { BuildOptions, BuildParamsMap, CodecTypes, ColumnsOf, ComputeColumnJsType, Expr, HasIncludeManyCapabilities, META, Meta, ModelDef, ModelMetadata, OperationTypeSignature, OperationTypes, OperationsForTypeId, RawFactory, RawFunctionOptions, RawTemplateFactory, RawTemplateOptions, RuntimeError, RuntimeScope, SqlBuilderOptions, SqlOrmPlan, SqlPlan, TableDef, TableKey, TableMetadata, TablesOf };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-
|
|
6
|
-
import { C as TableKey, S as TableDef, T as TablesOf, _ as RawTemplateFactory, a as ComputeColumnJsType, b as SqlBuilderOptions, c as META, d as ModelMetadata, f as OperationTypeSignature, g as RawFunctionOptions, h as RawFactory, i as ColumnsOf, l as Meta, m as OperationsForTypeId, n as BuildParamsMap, o as Expr, p as OperationTypes, r as CodecTypes, s as HasIncludeManyCapabilities, t as BuildOptions, u as ModelDef, v as RawTemplateOptions, w as TableMetadata, x as SqlPlan, y as RuntimeError } from "./types-
|
|
7
|
-
import { n as planUnsupported, t as planInvalid } from "./errors-
|
|
8
|
-
import { BuildOperationSpec, CodecExpression, Expression, ScopeField, TraitExpression, buildOperation,
|
|
9
|
-
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "./middleware-
|
|
10
|
-
import { n as planFromAst, t as SqlQueryPlan } from "./plan-
|
|
11
|
-
import { n as SqlOrmPlan, t as RuntimeScope } from "./types-
|
|
12
|
-
export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyQueryAst, AppliedMutationDefault, AstRewriter, BinaryExpr, BinaryOp, BuildOperationSpec, BuildOptions, BuildParamsMap, Codec, CodecCallContext, CodecDescriptor, CodecDescriptorRegistry, CodecExpression, CodecMeta, CodecTrait, CodecTypes, ColumnRef, ColumnsOf, ComputeColumnJsType, ContractCodecRegistry, DefaultValueExpr, DeleteAst, DerivedTableSource, DescriptorCodecId, DescriptorCodecInput, DescriptorCodecTraits, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExecutionContext, ExistsExpr, Expr, ExprVisitor, Expression, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, HasIncludeManyCapabilities, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, ListExpression, LiteralExpr, LoweredStatement, Lowerer, LowererContext, META, MarkerReadResult, MarkerStatement, Meta, ModelDef, ModelMetadata, MutationDefaultsOp, MutationDefaultsOptions, NotExpr, NullCheckExpr, OperationExpr, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrExpr, OrderByItem, ParamRef,
|
|
1
|
+
import { a as CodecMeta, c as ContractCodecRegistry, d as DescriptorCodecTraits, f as ExtractCodecTypes, h as SqlColumnRef, i as CodecDescriptor, l as DescriptorCodecId, m as SqlCodecInstanceContext, n as Codec, o as CodecRef, p as SqlCodecCallContext, r as CodecCallContext, s as CodecTrait, t as AnyCodecDescriptor, u as DescriptorCodecInput } from "./codec-types-Cezo7k-i.mjs";
|
|
2
|
+
import { $ as TableSource, A as InsertOnConflict, B as NotExpr, C as ExistsExpr, D as ExpressionSource, E as ExpressionRewriter, F as JsonObjectEntry, G as ParamRef, H as OperationExpr, I as JsonObjectExpr, J as RawSqlExpr, K as ProjectionExpr, L as ListExpression, M as JoinAst, N as JoinOnExpr, O as IdentifierRef, P as JsonArrayAggExpr, Q as TableRef, R as LiteralExpr, S as EqColJoinOn, T as ExpressionFolder, U as OrExpr, V as NullCheckExpr, W as OrderByItem, X as SelectAstOptions, Y as SelectAst, Z as SubqueryExpr, _ as DeleteAst, a as AndExpr, at as queryAstKinds, b as DoNothingConflictAction, c as AnyInsertOnConflictAction, d as AnyQueryAst, et as ToWhereExpr, f as AstRewriter, g as DefaultValueExpr, h as ColumnRef, i as AggregateOpFn, it as isWhereExpr, j as InsertValue, k as InsertAst, l as AnyInsertValue, m as BinaryOp, n as AggregateExpr, nt as WhereArg, o as AnyExpression, ot as whereExprKinds, p as BinaryExpr, q as ProjectionItem, r as AggregateFn, rt as isQueryAst, s as AnyFromSource, t as AggregateCountFn, tt as UpdateAst, u as AnyOperationArg, v as DerivedTableSource, w as ExprVisitor, x as DoUpdateSetConflictAction, y as Direction, z as LoweredStatement } from "./types-juiKe2qf.mjs";
|
|
3
|
+
import { Adapter, AdapterProfile, AdapterTarget, Lowerer, LowererContext, MarkerReadResult, MarkerStatement, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SqlCharCodec, SqlCharDescriptor, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlQueryResult, SqlQueryable, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlTransaction, SqlVarcharCodec, SqlVarcharDescriptor, collectOrderedParamRefs, compact, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType } from "./exports/ast.mjs";
|
|
4
|
+
import { a as MutationDefaultsOptions, i as MutationDefaultsOp, n as CodecDescriptorRegistry, o as TypeHelperRegistry, r as ExecutionContext, t as AppliedMutationDefault } from "./query-lane-context-DHsPbikl.mjs";
|
|
5
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-DM2Hcvvn.mjs";
|
|
6
|
+
import { C as TableKey, S as TableDef, T as TablesOf, _ as RawTemplateFactory, a as ComputeColumnJsType, b as SqlBuilderOptions, c as META, d as ModelMetadata, f as OperationTypeSignature, g as RawFunctionOptions, h as RawFactory, i as ColumnsOf, l as Meta, m as OperationsForTypeId, n as BuildParamsMap, o as Expr, p as OperationTypes, r as CodecTypes, s as HasIncludeManyCapabilities, t as BuildOptions, u as ModelDef, v as RawTemplateOptions, w as TableMetadata, x as SqlPlan, y as RuntimeError } from "./types-BQK1PdQu.mjs";
|
|
7
|
+
import { n as planUnsupported, t as planInvalid } from "./errors-D2KewtVl.mjs";
|
|
8
|
+
import { BuildOperationSpec, CodecExpression, Expression, ScopeField, TraitExpression, buildOperation, codecOf, toExpr } from "./exports/expression.mjs";
|
|
9
|
+
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "./middleware-CfWhG9hx.mjs";
|
|
10
|
+
import { n as planFromAst, t as SqlQueryPlan } from "./plan-DmBWXsDN.mjs";
|
|
11
|
+
import { n as SqlOrmPlan, t as RuntimeScope } from "./types-BWJCGyVL.mjs";
|
|
12
|
+
export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyQueryAst, AppliedMutationDefault, AstRewriter, BinaryExpr, BinaryOp, BuildOperationSpec, BuildOptions, BuildParamsMap, Codec, CodecCallContext, CodecDescriptor, CodecDescriptorRegistry, CodecExpression, CodecMeta, CodecRef, CodecTrait, CodecTypes, ColumnRef, ColumnsOf, ComputeColumnJsType, ContractCodecRegistry, DefaultValueExpr, DeleteAst, DerivedTableSource, DescriptorCodecId, DescriptorCodecInput, DescriptorCodecTraits, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExecutionContext, ExistsExpr, Expr, ExprVisitor, Expression, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, HasIncludeManyCapabilities, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, ListExpression, LiteralExpr, LoweredStatement, Lowerer, LowererContext, META, MarkerReadResult, MarkerStatement, Meta, ModelDef, ModelMetadata, MutationDefaultsOp, MutationDefaultsOptions, NotExpr, NullCheckExpr, OperationExpr, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrExpr, OrderByItem, ParamRef, ParamRefEntry, ParamRefEntryUnion, ParamRefHandle, ProjectionExpr, ProjectionItem, RawFactory, RawFunctionOptions, RawSqlExpr, RawTemplateFactory, RawTemplateOptions, RuntimeError, RuntimeScope, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, ScopeField, SelectAst, SelectAstOptions, SqlBuilderOptions, SqlCharCodec, SqlCharDescriptor, SqlCodecCallContext, SqlCodecInstanceContext, SqlColumnRef, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExecutionPlan, SqlExplainResult, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlOrmPlan, SqlParamRefMutator, SqlParamRefMutatorInternal, SqlPlan, SqlQueryPlan, SqlQueryResult, SqlQueryable, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlTransaction, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableDef, TableKey, TableMetadata, TableRef, TableSource, TablesOf, ToWhereExpr, TraitExpression, TypeHelperRegistry, UpdateAst, WhereArg, buildOperation, codecOf, collectOrderedParamRefs, compact, createSqlParamRefMutator, isQueryAst, isWhereExpr, planFromAst, planInvalid, planUnsupported, queryAstKinds, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType, toExpr, whereExprKinds };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A as TableSource, C as OrExpr, D as RawSqlExpr, E as ProjectionItem, F as whereExprKinds, M as isQueryAst, N as isWhereExpr, O as SelectAst, P as queryAstKinds, S as OperationExpr, T as ParamRef, _ as JsonObjectExpr, a as DefaultValueExpr, b as NotExpr, c as DoNothingConflictAction, d as ExistsExpr, f as IdentifierRef, g as JsonArrayAggExpr, h as JoinAst, i as ColumnRef, j as UpdateAst, k as SubqueryExpr, l as DoUpdateSetConflictAction, m as InsertOnConflict, n as AndExpr, o as DeleteAst, p as InsertAst, r as BinaryExpr, s as DerivedTableSource, t as AggregateExpr, u as EqColJoinOn, v as ListExpression, w as OrderByItem, x as NullCheckExpr, y as LiteralExpr } from "./types-
|
|
1
|
+
import { A as TableSource, C as OrExpr, D as RawSqlExpr, E as ProjectionItem, F as whereExprKinds, M as isQueryAst, N as isWhereExpr, O as SelectAst, P as queryAstKinds, S as OperationExpr, T as ParamRef, _ as JsonObjectExpr, a as DefaultValueExpr, b as NotExpr, c as DoNothingConflictAction, d as ExistsExpr, f as IdentifierRef, g as JsonArrayAggExpr, h as JoinAst, i as ColumnRef, j as UpdateAst, k as SubqueryExpr, l as DoUpdateSetConflictAction, m as InsertOnConflict, n as AndExpr, o as DeleteAst, p as InsertAst, r as BinaryExpr, s as DerivedTableSource, t as AggregateExpr, u as EqColJoinOn, v as ListExpression, w as OrderByItem, x as NullCheckExpr, y as LiteralExpr } from "./types-DRYJSMk1.mjs";
|
|
2
2
|
import { n as compact, t as collectOrderedParamRefs } from "./util-DWmhUCEO.mjs";
|
|
3
|
-
import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType
|
|
3
|
+
import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType } from "./exports/ast.mjs";
|
|
4
4
|
import { n as planUnsupported, t as planInvalid } from "./errors-BF7W5uUd.mjs";
|
|
5
|
-
import { buildOperation,
|
|
6
|
-
import { t as createSqlParamRefMutator } from "./middleware-
|
|
5
|
+
import { buildOperation, codecOf, toExpr } from "./exports/expression.mjs";
|
|
6
|
+
import { t as createSqlParamRefMutator } from "./middleware-DGoIUH9C.mjs";
|
|
7
7
|
import { planFromAst } from "./exports/plan.mjs";
|
|
8
8
|
import "./exports/query-lane-context.mjs";
|
|
9
9
|
import "./exports/types.mjs";
|
|
10
|
-
export { AggregateExpr, AndExpr, BinaryExpr, ColumnRef, DefaultValueExpr, DeleteAst, DerivedTableSource, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, IdentifierRef, InsertAst, InsertOnConflict, JoinAst, JsonArrayAggExpr, JsonObjectExpr, ListExpression, LiteralExpr, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, ProjectionItem, RawSqlExpr, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableSource, UpdateAst, buildOperation, collectOrderedParamRefs, compact, createSqlParamRefMutator, isQueryAst, isWhereExpr, planFromAst, planInvalid, planUnsupported, queryAstKinds,
|
|
10
|
+
export { AggregateExpr, AndExpr, BinaryExpr, ColumnRef, DefaultValueExpr, DeleteAst, DerivedTableSource, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, IdentifierRef, InsertAst, InsertOnConflict, JoinAst, JsonArrayAggExpr, JsonObjectExpr, ListExpression, LiteralExpr, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, ProjectionItem, RawSqlExpr, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableSource, UpdateAst, buildOperation, codecOf, collectOrderedParamRefs, compact, createSqlParamRefMutator, isQueryAst, isWhereExpr, planFromAst, planInvalid, planUnsupported, queryAstKinds, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType, toExpr, whereExprKinds };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-ffz8TSfr.mjs";
|
|
1
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-DM2Hcvvn.mjs";
|
|
3
2
|
import { ParamRefMutator } from "@prisma-next/framework-components/runtime";
|
|
4
3
|
|
|
5
4
|
//#region src/middleware/param-ref-mutator.d.ts
|
|
@@ -29,17 +28,12 @@ interface ParamRefHandle<TCodecId extends string | undefined = string | undefine
|
|
|
29
28
|
/**
|
|
30
29
|
* One outbound `ParamRef` slot in the plan exposed to middleware.
|
|
31
30
|
* `value` is the current value (post any prior middleware mutations);
|
|
32
|
-
* `codecId` is the codec id declared on the underlying `ParamRef
|
|
33
|
-
* `column` is populated for `ParamRef`s the lowering site could resolve
|
|
34
|
-
* to a single `(table, column)` via `ParamRef.refs` (encode-side column
|
|
35
|
-
* metadata is the middleware's domain — encode itself currently leaves
|
|
36
|
-
* `ctx.column` unset).
|
|
31
|
+
* `codecId` is the codec id declared on the underlying `ParamRef.codec`.
|
|
37
32
|
*/
|
|
38
33
|
interface ParamRefEntry<TCodecId extends string | undefined = string | undefined> {
|
|
39
34
|
readonly ref: ParamRefHandle<TCodecId>;
|
|
40
35
|
readonly value: unknown;
|
|
41
36
|
readonly codecId: TCodecId;
|
|
42
|
-
readonly column?: SqlColumnRef;
|
|
43
37
|
}
|
|
44
38
|
/**
|
|
45
39
|
* Discriminated entry union over a codec map. For each `K` in
|
|
@@ -118,4 +112,4 @@ interface SqlParamRefMutatorInternal<TCodecMap extends Record<string, unknown> =
|
|
|
118
112
|
declare function createSqlParamRefMutator<TCodecMap extends Record<string, unknown> = Record<string, unknown>>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap>;
|
|
119
113
|
//#endregion
|
|
120
114
|
export { SqlParamRefMutatorInternal as a, SqlParamRefMutator as i, ParamRefEntryUnion as n, createSqlParamRefMutator as o, ParamRefHandle as r, ParamRefEntry as t };
|
|
121
|
-
//# sourceMappingURL=middleware-
|
|
115
|
+
//# sourceMappingURL=middleware-CfWhG9hx.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-CfWhG9hx.d.mts","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"mappings":";;;;;;AAG8D;;;;;AAuB9D;;;cAXc,mBAAA;;;;;;AAoBd;;;;UATiB,cAAA;EAAA,UACL,mBAAA,GAAsB,QAAA;AAAA;;;;;;UAQjB,aAAA;EAAA,SACN,GAAA,EAAK,cAAA,CAAe,QAAA;EAAA,SACpB,KAAA;EAAA,SACA,OAAA,EAAS,QAAA;AAAA;AAWpB;;;;;;;;AAAA,KAAY,kBAAA,mBAAqC,MAAA,mCAC/B,SAAA,YAAqB,aAAA,CAAc,CAAA,UAAW,SAAA,aAC5D,aAAA;;;;;;;;;;;AAsBJ;;;;;;;;;;UAAiB,kBAAA,mBACG,MAAA,oBAA0B,MAAA,2BACpC,eAAA;EAYI;EAVZ,OAAA,IAAW,gBAAA,CAAiB,kBAAA,CAAmB,SAAA;EAY7B;;;;;;EAJlB,YAAA,wBAAoC,SAAA,WAClC,GAAA,EAAK,cAAA,CAAe,QAAA,GACpB,QAAA,EAAU,SAAA,CAAU,QAAA;EAEtB,YAAA,CAAa,GAAA,EAAK,cAAA,aAA2B,QAAA;EAf3B;EAkBlB,aAAA,CACE,OAAA,EAAS,QAAA;IAAA,SACE,GAAA,EAAK,cAAA,QAAsB,SAAA;IAAA,SAC3B,QAAA;EAAA;AAAA;;;;;;;;;;;UAeE,0BAAA,mBACG,MAAA,oBAA0B,MAAA,2BACpC,kBAAA,CAAmB,SAAA;EAC3B,aAAA;AAAA;;;;;;;;;;;AAHF;;;;;iBAuBgB,wBAAA,mBACI,MAAA,oBAA0B,MAAA,kBAAA,CAC5C,IAAA,EAAM,gBAAA,GAAmB,0BAAA,CAA2B,SAAA"}
|
|
@@ -35,22 +35,10 @@ function createSqlParamRefMutator(plan) {
|
|
|
35
35
|
for (let i = 0; i < refs.length; i++) {
|
|
36
36
|
const ref = refs[i];
|
|
37
37
|
if (!ref) continue;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
table: ref.refs.table,
|
|
43
|
-
name: ref.refs.column
|
|
44
|
-
} : void 0;
|
|
45
|
-
yield column ? {
|
|
46
|
-
ref: handle,
|
|
47
|
-
value,
|
|
48
|
-
codecId,
|
|
49
|
-
column
|
|
50
|
-
} : {
|
|
51
|
-
ref: handle,
|
|
52
|
-
value,
|
|
53
|
-
codecId
|
|
38
|
+
yield {
|
|
39
|
+
ref,
|
|
40
|
+
value: i < view.length ? view[i] : ref.value,
|
|
41
|
+
codecId: ref.codec?.codecId
|
|
54
42
|
};
|
|
55
43
|
}
|
|
56
44
|
}
|
|
@@ -79,4 +67,4 @@ function createSqlParamRefMutator(plan) {
|
|
|
79
67
|
//#endregion
|
|
80
68
|
export { createSqlParamRefMutator as t };
|
|
81
69
|
|
|
82
|
-
//# sourceMappingURL=middleware-
|
|
70
|
+
//# sourceMappingURL=middleware-DGoIUH9C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-DGoIUH9C.mjs","names":["handle"],"sources":["../src/middleware/param-ref-mutator.ts"],"sourcesContent":["import type { ParamRefMutator } from '@prisma-next/framework-components/runtime';\nimport type { ParamRef } from '../ast/types';\nimport { collectOrderedParamRefs } from '../ast/util';\nimport type { SqlExecutionPlan } from '../sql-execution-plan';\n\n/**\n * Brand applied to {@link ParamRefHandle} so user-constructed handles\n * are rejected by the type system. The mutator only accepts handles it\n * produced from `entries()`.\n *\n * The brand is a phantom type — there is no runtime token. At runtime\n * the handle is the underlying `ParamRef` instance from the plan's\n * `ast`; the brand only narrows the type-level surface so callers\n * cannot fabricate a handle from a fresh `ParamRef.of(...)`.\n */\ndeclare const paramRefHandleBrand: unique symbol;\n\n/**\n * Opaque token identifying a single `ParamRef` in the plan. Produced by\n * {@link SqlParamRefMutator.entries}; consumed by `replaceValue` /\n * `replaceValues`.\n *\n * The phantom `TCodecId` parameter records the codec id of the\n * referenced `ParamRef` so type-level inference can route replacement\n * values through `TCodecMap` to the codec's declared `TInput`.\n */\nexport interface ParamRefHandle<TCodecId extends string | undefined = string | undefined> {\n readonly [paramRefHandleBrand]: TCodecId;\n}\n\n/**\n * One outbound `ParamRef` slot in the plan exposed to middleware.\n * `value` is the current value (post any prior middleware mutations);\n * `codecId` is the codec id declared on the underlying `ParamRef.codec`.\n */\nexport interface ParamRefEntry<TCodecId extends string | undefined = string | undefined> {\n readonly ref: ParamRefHandle<TCodecId>;\n readonly value: unknown;\n readonly codecId: TCodecId;\n}\n\n/**\n * Discriminated entry union over a codec map. For each `K` in\n * `TCodecMap`, `entries()` may yield a `ParamRefEntry<K>`; ParamRefs\n * with no codec id (or a codec id outside the map) yield a\n * `ParamRefEntry<undefined>`. Pattern-matching on `entry.codecId`\n * narrows `entry.ref` to a `ParamRefHandle<K>`, which routes through\n * the typed `replaceValue` overload.\n */\nexport type ParamRefEntryUnion<TCodecMap extends Record<string, unknown>> =\n | { [K in keyof TCodecMap & string]: ParamRefEntry<K> }[keyof TCodecMap & string]\n | ParamRefEntry<undefined>;\n\n/**\n * SQL-family mutator threaded into `SqlMiddleware.beforeExecute` as\n * `params`. Scope is `ParamRef.value` slots only — middleware cannot\n * insert / remove `ParamRef`s, rewrite SQL, or modify projection. The\n * type-level `ParamRefHandle` brand and the `replaceValue(ref,\n * newValue)` shape enforce this at compile time.\n *\n * Allocation discipline: the mutator is constructed lazily from the\n * plan. `entries()` walks the plan's existing AST without allocating\n * an intermediate array; the working params buffer is only allocated\n * on the first `replaceValue` / `replaceValues` call. If no middleware\n * mutates, `currentParams()` returns the plan's original `params` by\n * reference identity.\n *\n * The `TCodecMap` parameter is a record keyed by codec id; `replaceValue`\n * infers `newValue` from `TCodecMap[H['codecId']]` for handles whose\n * codec id is statically resolvable. For codec ids the type system\n * cannot resolve, `newValue` falls back to `unknown` and the middleware\n * is on the hook for runtime correctness.\n */\nexport interface SqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends ParamRefMutator {\n /** Iterate every outbound `ParamRef` the plan currently carries, in canonical order. */\n entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>>;\n\n /**\n * Replace one `ParamRef`'s value with the result of bulk processing.\n * `newValue` is constrained to the codec's declared `TInput` for codec\n * ids the type system can resolve via `TCodecMap`; for unresolvable\n * codec ids `newValue` is `unknown` (the second overload).\n */\n replaceValue<TCodecId extends keyof TCodecMap & string>(\n ref: ParamRefHandle<TCodecId>,\n newValue: TCodecMap[TCodecId],\n ): void;\n replaceValue(ref: ParamRefHandle<undefined>, newValue: unknown): void;\n\n /** Replace many at once (typical for bulk-pattern middleware). */\n replaceValues(\n updates: Iterable<{\n readonly ref: ParamRefHandle<(keyof TCodecMap & string) | undefined>;\n readonly newValue: unknown;\n }>,\n ): void;\n}\n\n/**\n * Internal-only view of the mutator that exposes the post-mutation params\n * array to the SQL runtime. The runtime calls `currentParams()` after the\n * `beforeExecute` chain has run; the result is the plan's original\n * `params` by reference identity if no middleware mutated, otherwise a\n * frozen new array carrying the mutations applied in chain order.\n *\n * Family-internal contract — `SqlMiddleware` consumers never see this\n * shape; they receive the public `SqlParamRefMutator` view above.\n */\nexport interface SqlParamRefMutatorInternal<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends SqlParamRefMutator<TCodecMap> {\n currentParams(): readonly unknown[];\n}\n\ntype AnyHandle = ParamRefHandle<string | undefined>;\n\n/**\n * Build a {@link SqlParamRefMutatorInternal} for the given lowered plan.\n *\n * The mutator captures `plan.params` by reference and walks\n * `plan.ast` (via `collectOrderedParamRefs`) on demand to build\n * entries. Mutations write to a lazily-allocated working copy so the\n * fast path (no mutation) preserves bit-for-bit reference identity to\n * the original `plan.params`.\n *\n * Threading: `plan.ast` carries the canonical `ParamRef` ordering used\n * by every consumer (renderer's `$N` index map, encode-side metadata\n * walk, etc.). The mutator's `entries()` yields the same order so\n * middleware that filters by codec id sees ParamRefs in the order the\n * runtime will encode them.\n */\nexport function createSqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap> {\n const originalParams = plan.params;\n const refs: ReadonlyArray<ParamRef> = plan.ast ? collectOrderedParamRefs(plan.ast) : [];\n let workingParams: unknown[] | undefined;\n\n const indexOfRef = (handle: AnyHandle): number => {\n // The handle is the underlying ParamRef instance the mutator yielded\n // from entries(); equality is identity equality on the ParamRef. The\n // brand on ParamRefHandle is unforgeable from outside, so the only\n // legal handles came from this mutator's entries().\n return refs.indexOf(handle as unknown as ParamRef);\n };\n\n const ensureWorkingParams = (): unknown[] => {\n if (!workingParams) {\n workingParams = [...originalParams];\n }\n return workingParams;\n };\n\n const writeAt = (index: number, value: unknown): void => {\n const buffer = ensureWorkingParams();\n buffer[index] = value;\n };\n\n function* entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>> {\n const view = workingParams ?? originalParams;\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i];\n if (!ref) continue;\n const handle = ref as unknown as ParamRefHandle<string | undefined>;\n const value = i < view.length ? view[i] : ref.value;\n const codecId = ref.codec?.codecId;\n // The runtime erases the discriminated union to a single shape; the\n // public type pins each entry's `ref` to the matching `codecId`\n // arm at compile time.\n const entry: ParamRefEntry<string | undefined> = { ref: handle, value, codecId };\n yield entry as ParamRefEntryUnion<TCodecMap>;\n }\n }\n\n function replaceValue(handle: AnyHandle, newValue: unknown): void {\n const index = indexOfRef(handle);\n if (index < 0) {\n // Handle does not belong to this plan. The type system pins this\n // at the brand level; this runtime check guards against handles\n // smuggled across plans.\n return;\n }\n writeAt(index, newValue);\n }\n\n function replaceValues(\n updates: Iterable<{ readonly ref: AnyHandle; readonly newValue: unknown }>,\n ): void {\n for (const { ref, newValue } of updates) {\n const index = indexOfRef(ref);\n if (index < 0) continue;\n writeAt(index, newValue);\n }\n }\n\n // The public `SqlParamRefMutator` declares overloaded `replaceValue`\n // signatures (typed-by-codec / unresolvable-codec). The implementation\n // is one function with a permissive runtime signature; the cast is the\n // single point at which the runtime function meets the typed overload\n // surface, matching the overload-implementation pattern.\n return {\n entries,\n replaceValue: replaceValue as SqlParamRefMutator<TCodecMap>['replaceValue'],\n replaceValues,\n currentParams(): readonly unknown[] {\n if (!workingParams) {\n return originalParams;\n }\n return Object.freeze([...workingParams]);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqIA,SAAgB,yBAEd,MAA+D;CAC/D,MAAM,iBAAiB,KAAK;CAC5B,MAAM,OAAgC,KAAK,MAAM,wBAAwB,KAAK,IAAI,GAAG,EAAE;CACvF,IAAI;CAEJ,MAAM,cAAc,WAA8B;EAKhD,OAAO,KAAK,QAAQ,OAA8B;;CAGpD,MAAM,4BAAuC;EAC3C,IAAI,CAAC,eACH,gBAAgB,CAAC,GAAG,eAAe;EAErC,OAAO;;CAGT,MAAM,WAAW,OAAe,UAAyB;EACvD,MAAM,SAAS,qBAAqB;EACpC,OAAO,SAAS;;CAGlB,UAAU,UAA2D;EACnE,MAAM,OAAO,iBAAiB;EAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,MAAM,KAAK;GACjB,IAAI,CAAC,KAAK;GAQV,MAAM;IADkDA;IAAQ,OALlD,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI;IAKyB,SAJvD,IAAI,OAAO;IAKhB;;;CAIf,SAAS,aAAa,QAAmB,UAAyB;EAChE,MAAM,QAAQ,WAAW,OAAO;EAChC,IAAI,QAAQ,GAIV;EAEF,QAAQ,OAAO,SAAS;;CAG1B,SAAS,cACP,SACM;EACN,KAAK,MAAM,EAAE,KAAK,cAAc,SAAS;GACvC,MAAM,QAAQ,WAAW,IAAI;GAC7B,IAAI,QAAQ,GAAG;GACf,QAAQ,OAAO,SAAS;;;CAS5B,OAAO;EACL;EACc;EACd;EACA,gBAAoC;GAClC,IAAI,CAAC,eACH,OAAO;GAET,OAAO,OAAO,OAAO,CAAC,GAAG,cAAc,CAAC;;EAE3C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as AnyQueryAst } from "./types-
|
|
1
|
+
import { d as AnyQueryAst } from "./types-juiKe2qf.mjs";
|
|
2
2
|
import { QueryPlan } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
import { Contract } from "@prisma-next/contract/types";
|
|
4
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
@@ -41,4 +41,4 @@ interface SqlQueryPlan<Row = unknown> extends QueryPlan<Row> {
|
|
|
41
41
|
declare function planFromAst<Row = unknown>(ast: AnyQueryAst, contract: Contract<SqlStorage>, laneId?: string): SqlQueryPlan<Row>;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { planFromAst as n, SqlQueryPlan as t };
|
|
44
|
-
//# sourceMappingURL=plan-
|
|
44
|
+
//# sourceMappingURL=plan-DmBWXsDN.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-
|
|
1
|
+
{"version":3,"file":"plan-DmBWXsDN.d.mts","names":[],"sources":["../src/plan.ts"],"mappings":";;;;;;;;AAkBA;;;;;;;;;;;UAAiB,YAAA,wBAAoC,SAAA,CAAU,GAAA;EAAA,SACpD,GAAA,EAAK,WAAA;EAAA,SACL,MAAA;AAAA;;AAoBX;;;;;;;;;;;;;;;;iBAAgB,WAAA,eAAA,CACd,GAAA,EAAK,WAAA,EACL,QAAA,EAAU,QAAA,CAAS,UAAA,GACnB,MAAA,YACC,YAAA,CAAa,GAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CodecDescriptor } from "@prisma-next/framework-components/codec";
|
|
1
|
+
import { c as ContractCodecRegistry } from "./codec-types-Cezo7k-i.mjs";
|
|
2
|
+
import { CodecDescriptor, CodecRef } from "@prisma-next/framework-components/codec";
|
|
3
3
|
import { Contract } from "@prisma-next/contract/types";
|
|
4
4
|
import { SqlOperationRegistry } from "@prisma-next/sql-operations";
|
|
5
5
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
@@ -13,6 +13,18 @@ interface CodecDescriptorRegistry {
|
|
|
13
13
|
* Descriptors carry distinct param shapes per codec id; the registry is heterogeneous and the consumer narrows per codec.
|
|
14
14
|
*/
|
|
15
15
|
descriptorFor(codecId: string): CodecDescriptor<unknown> | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Derive the canonical {@link CodecRef} for a contract `(table, column)`. The builder side calls this at AST construction time to stamp `codec` onto every column-bound `ParamRef` / `ProjectionItem`; the runtime side uses the result as the cache key into the content-keyed codec resolver.
|
|
18
|
+
*
|
|
19
|
+
* Resolution rules over `storage.tables[table].columns[column]`:
|
|
20
|
+
*
|
|
21
|
+
* - `typeRef` column → emit `{codecId, typeParams}` from `storage.types[typeRef]` (multiple columns sharing the typeRef produce the same ref → same memoised codec).
|
|
22
|
+
* - inline `typeParams` column → emit `{codecId, typeParams}` from the column itself.
|
|
23
|
+
* - non-parameterized column → emit `{codecId}` with `typeParams` undefined (keys as `${codecId}:undefined` → one shared codec).
|
|
24
|
+
*
|
|
25
|
+
* Returns `undefined` when the registry was built without contract storage (package-scoped registries used purely as descriptor lookups), when the table or column is unknown, or when the column declares a `typeRef` that the storage doesn't define.
|
|
26
|
+
*/
|
|
27
|
+
codecRefForColumn(table: string, column: string): CodecRef | undefined;
|
|
16
28
|
/**
|
|
17
29
|
* All registered descriptors. Used by `validateCodecRegistryCompleteness` and other startup-time consumers that enumerate descriptors.
|
|
18
30
|
*/
|
|
@@ -49,8 +61,7 @@ type MutationDefaultsOptions = {
|
|
|
49
61
|
interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
|
|
50
62
|
readonly contract: TContract;
|
|
51
63
|
/**
|
|
52
|
-
* Contract-bound codec registry built once at context-construction time by walking the contract's columns and resolving each through its descriptor's factory.
|
|
53
|
-
* 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.
|
|
64
|
+
* Contract-bound codec registry built once at context-construction time by walking the contract's columns and resolving each through its descriptor's factory. Runtime dispatch (`encodeParam` / `decodeRow`) resolves codecs via `forCodecRef(ref)` — the single dispatch shape for AST-bound codec resolution.
|
|
54
65
|
*/
|
|
55
66
|
readonly contractCodecs: ContractCodecRegistry;
|
|
56
67
|
/**
|
|
@@ -69,4 +80,4 @@ interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<Sql
|
|
|
69
80
|
}
|
|
70
81
|
//#endregion
|
|
71
82
|
export { MutationDefaultsOptions as a, MutationDefaultsOp as i, CodecDescriptorRegistry as n, TypeHelperRegistry as o, ExecutionContext as r, AppliedMutationDefault as t };
|
|
72
|
-
//# sourceMappingURL=query-lane-context-
|
|
83
|
+
//# sourceMappingURL=query-lane-context-DHsPbikl.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-lane-context-DHsPbikl.d.mts","names":[],"sources":["../src/query-lane-context.ts"],"mappings":";;;;;;;;;AASA;UAAiB,uBAAA;;;;EAIf,aAAA,CAAc,OAAA,WAAkB,eAAA;EAgBtB;;;;;;;;;;;EAJV,iBAAA,CAAkB,KAAA,UAAe,MAAA,WAAiB,QAAA;EAIxC;;;EAAV,MAAA,IAAU,gBAAA,CAAiB,eAAA;EAIgB;;;EAA3C,YAAA,CAAa,UAAA,oBAA8B,eAAA;AAAA;;;;KAMjC,kBAAA,GAAqB,MAAA;AAAA,KAErB,kBAAA;AAAA,KAEA,sBAAA;EAAA,SACD,MAAA;EAAA,SACA,KAAA;AAAA;AAAA,KAGC,uBAAA;EAAA,SACD,EAAA,EAAI,kBAAA;EAAA,SACJ,KAAA;EAAA,SACA,MAAA,EAAQ,MAAA;EAHP;;;;EAAA,SAQD,iBAAA,GAAoB,GAAA;AAAA;;;;;;UAQd,gBAAA,mBAAmC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,SACzE,QAAA,EAAU,SAAA;EATV;;;EAAA,SAaA,cAAA,EAAgB,qBAAA;EALV;;;EAAA,SASN,gBAAA,EAAkB,uBAAA;EAAA,SAClB,eAAA,EAAiB,oBAAA;EAVwD;;;EAAA,SAczE,KAAA,EAAO,kBAAA;EALW;;;EAS3B,qBAAA,CAAsB,OAAA,EAAS,uBAAA,GAA0B,aAAA,CAAc,sBAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as AnyQueryAst } from "./types-
|
|
1
|
+
import { d as AnyQueryAst } from "./types-juiKe2qf.mjs";
|
|
2
2
|
import { ExecutionPlan } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/sql-execution-plan.d.ts
|
|
@@ -29,4 +29,4 @@ interface SqlExecutionPlan<Row = unknown> extends ExecutionPlan<Row> {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SqlExecutionPlan as t };
|
|
32
|
-
//# sourceMappingURL=sql-execution-plan-
|
|
32
|
+
//# sourceMappingURL=sql-execution-plan-DM2Hcvvn.d.mts.map
|
package/dist/{sql-execution-plan-ffz8TSfr.d.mts.map → sql-execution-plan-DM2Hcvvn.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-execution-plan-
|
|
1
|
+
{"version":3,"file":"sql-execution-plan-DM2Hcvvn.d.mts","names":[],"sources":["../src/sql-execution-plan.ts"],"mappings":";;;;;;AAuBA;;;;;;;;;;;;;;;;;;UAAiB,gBAAA,wBAAwC,aAAA,CAAc,GAAA;EAAA,SAC5D,GAAA;EAAA,SACA,MAAA;EAAA,SACA,GAAA,GAAM,WAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as ParamRef, h as ColumnRef } from "./types-
|
|
2
|
-
import { r as ExecutionContext } from "./query-lane-context-
|
|
3
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-
|
|
1
|
+
import { G as ParamRef, h as ColumnRef } from "./types-juiKe2qf.mjs";
|
|
2
|
+
import { r as ExecutionContext } from "./query-lane-context-DHsPbikl.mjs";
|
|
3
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-DM2Hcvvn.mjs";
|
|
4
4
|
import { Contract } from "@prisma-next/contract/types";
|
|
5
5
|
import { ParamSpec } from "@prisma-next/operations";
|
|
6
6
|
import { SqlLoweringSpec } from "@prisma-next/sql-operations";
|
|
@@ -190,4 +190,4 @@ interface SqlBuilderOptions<TContract extends Contract<SqlStorage> = Contract<Sq
|
|
|
190
190
|
}
|
|
191
191
|
//#endregion
|
|
192
192
|
export { TableKey as C, TableDef as S, TablesOf as T, RawTemplateFactory as _, ComputeColumnJsType as a, SqlBuilderOptions as b, META as c, ModelMetadata as d, OperationTypeSignature as f, RawFunctionOptions as g, RawFactory as h, ColumnsOf as i, Meta as l, OperationsForTypeId as m, BuildParamsMap as n, Expr as o, OperationTypes as p, CodecTypes as r, HasIncludeManyCapabilities as s, BuildOptions as t, ModelDef as u, RawTemplateOptions as v, TableMetadata as w, SqlPlan as x, RuntimeError as y };
|
|
193
|
-
//# sourceMappingURL=types-
|
|
193
|
+
//# sourceMappingURL=types-BQK1PdQu.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-BQK1PdQu.d.mts","names":[],"sources":["../src/types.ts"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-
|
|
2
|
-
import { t as SqlQueryPlan } from "./plan-
|
|
1
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-DM2Hcvvn.mjs";
|
|
2
|
+
import { t as SqlQueryPlan } from "./plan-DmBWXsDN.mjs";
|
|
3
3
|
import { RuntimeExecutor } from "@prisma-next/framework-components/runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/runtime-scope.d.ts
|
|
@@ -20,4 +20,4 @@ type SqlOrmPlan = SqlExecutionPlan | SqlQueryPlan;
|
|
|
20
20
|
type RuntimeScope = Pick<RuntimeExecutor<SqlOrmPlan>, 'execute'>;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { SqlOrmPlan as n, RuntimeScope as t };
|
|
23
|
-
//# sourceMappingURL=types-
|
|
23
|
+
//# sourceMappingURL=types-BWJCGyVL.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-BWJCGyVL.d.mts","names":[],"sources":["../src/runtime-scope.ts"],"mappings":";;;;;;;;AASA;;KAAY,UAAA,GAAa,gBAAA,GAAmB,YAAA;;;AAU5C;;;;;;KAAY,YAAA,GAAe,IAAA,CAAK,eAAA,CAAgB,UAAA"}
|
|
@@ -8,6 +8,13 @@ function frozenOptionalRecordCopy(value) {
|
|
|
8
8
|
function frozenRecordCopy(record) {
|
|
9
9
|
return Object.freeze({ ...record });
|
|
10
10
|
}
|
|
11
|
+
function frozenCodecRef(codec) {
|
|
12
|
+
const typeParams = codec.typeParams === void 0 ? void 0 : structuredClone(codec.typeParams);
|
|
13
|
+
return Object.freeze(typeParams === void 0 ? { codecId: codec.codecId } : {
|
|
14
|
+
codecId: codec.codecId,
|
|
15
|
+
typeParams
|
|
16
|
+
});
|
|
17
|
+
}
|
|
11
18
|
function freezeRows(rows) {
|
|
12
19
|
return Object.freeze(rows.map((row) => Object.freeze({ ...row })));
|
|
13
20
|
}
|
|
@@ -58,7 +65,7 @@ function rewriteTableSource(table, rewriter) {
|
|
|
58
65
|
}
|
|
59
66
|
function rewriteProjectionItem(item, rewriter) {
|
|
60
67
|
const rewrittenExpr = item.expr.kind === "literal" ? rewriter.literal ? rewriter.literal(item.expr) : item.expr : item.expr.rewrite(rewriter);
|
|
61
|
-
return new ProjectionItem(item.alias, rewrittenExpr, item.
|
|
68
|
+
return new ProjectionItem(item.alias, rewrittenExpr, item.codec);
|
|
62
69
|
}
|
|
63
70
|
function rewriteInsertValue(value, rewriter) {
|
|
64
71
|
switch (value.kind) {
|
|
@@ -216,14 +223,17 @@ var ParamRef = class ParamRef extends Expression {
|
|
|
216
223
|
kind = "param-ref";
|
|
217
224
|
value;
|
|
218
225
|
name;
|
|
219
|
-
|
|
220
|
-
|
|
226
|
+
/**
|
|
227
|
+
* Codec identity carried by every column-bound `ParamRef`. The encode-side dispatch path materialises the per-instance codec through `contractCodecs.forCodecRef(codec)` — content-keyed memoisation on `(codecId, canonicalize(typeParams))` keeps repeated lookups for the same logical column on one shared {@link Codec}.
|
|
228
|
+
*
|
|
229
|
+
* `codec` may be `undefined` for `ParamRef`s constructed without a column-bound site (literals, transient builder state); the runtime treats those as untyped passthroughs.
|
|
230
|
+
*/
|
|
231
|
+
codec;
|
|
221
232
|
constructor(value, options) {
|
|
222
233
|
super();
|
|
223
234
|
this.value = value;
|
|
224
235
|
this.name = options?.name;
|
|
225
|
-
this.
|
|
226
|
-
this.refs = options?.refs ? Object.freeze({ ...options.refs }) : void 0;
|
|
236
|
+
this.codec = options?.codec ? frozenCodecRef(options.codec) : void 0;
|
|
227
237
|
this.freeze();
|
|
228
238
|
}
|
|
229
239
|
static of(value, options) {
|
|
@@ -681,25 +691,24 @@ var ProjectionItem = class ProjectionItem extends AstNode {
|
|
|
681
691
|
kind = "projection-item";
|
|
682
692
|
alias;
|
|
683
693
|
expr;
|
|
684
|
-
codecId;
|
|
685
694
|
/**
|
|
686
|
-
*
|
|
687
|
-
*
|
|
695
|
+
* Codec identity for the projected cell. Decode-side dispatch resolves the per-instance codec through `contractCodecs.forCodecRef(codec)` — content-keyed memoisation collapses repeated lookups for the same logical column onto one shared {@link Codec}.
|
|
696
|
+
*
|
|
697
|
+
* Stays `undefined` for non-column-bound projections (computed expressions, subqueries, raw aliases) whose decoded type the runtime cannot infer from a single contract column.
|
|
688
698
|
*/
|
|
689
|
-
|
|
690
|
-
constructor(alias, expr,
|
|
699
|
+
codec;
|
|
700
|
+
constructor(alias, expr, codec) {
|
|
691
701
|
super();
|
|
692
702
|
this.alias = alias;
|
|
693
703
|
this.expr = expr;
|
|
694
|
-
this.
|
|
695
|
-
this.refs = refs ? Object.freeze({ ...refs }) : void 0;
|
|
704
|
+
this.codec = codec ? frozenCodecRef(codec) : void 0;
|
|
696
705
|
this.freeze();
|
|
697
706
|
}
|
|
698
|
-
static of(alias, expr,
|
|
699
|
-
return new ProjectionItem(alias, expr,
|
|
707
|
+
static of(alias, expr, codec) {
|
|
708
|
+
return new ProjectionItem(alias, expr, codec);
|
|
700
709
|
}
|
|
701
|
-
|
|
702
|
-
return new ProjectionItem(this.alias, this.expr,
|
|
710
|
+
withCodec(codec) {
|
|
711
|
+
return new ProjectionItem(this.alias, this.expr, codec);
|
|
703
712
|
}
|
|
704
713
|
};
|
|
705
714
|
var SelectAst = class SelectAst extends QueryAst {
|
|
@@ -830,7 +839,7 @@ var SelectAst = class SelectAst extends QueryAst {
|
|
|
830
839
|
const rewritten = new SelectAst({
|
|
831
840
|
from: this.from.rewrite(rewriter),
|
|
832
841
|
joins: this.joins?.map((join) => join.rewrite(rewriter)),
|
|
833
|
-
projection: this.projection.map((projection) => new ProjectionItem(projection.alias, projection.expr.kind === "literal" ? rewriter.literal ? rewriter.literal(projection.expr) : projection.expr : projection.expr.rewrite(rewriter), projection.
|
|
842
|
+
projection: this.projection.map((projection) => new ProjectionItem(projection.alias, projection.expr.kind === "literal" ? rewriter.literal ? rewriter.literal(projection.expr) : projection.expr : projection.expr.rewrite(rewriter), projection.codec)),
|
|
834
843
|
where: this.where?.rewrite(rewriter),
|
|
835
844
|
orderBy: this.orderBy?.map((orderItem) => orderItem.rewrite(rewriter)),
|
|
836
845
|
distinct: this.distinct,
|
|
@@ -1109,4 +1118,4 @@ function isWhereExpr(value) {
|
|
|
1109
1118
|
//#endregion
|
|
1110
1119
|
export { TableSource as A, OrExpr as C, RawSqlExpr as D, ProjectionItem as E, whereExprKinds as F, isQueryAst as M, isWhereExpr as N, SelectAst as O, queryAstKinds as P, OperationExpr as S, ParamRef as T, JsonObjectExpr as _, DefaultValueExpr as a, NotExpr as b, DoNothingConflictAction as c, ExistsExpr as d, IdentifierRef as f, JsonArrayAggExpr as g, JoinAst as h, ColumnRef as i, UpdateAst as j, SubqueryExpr as k, DoUpdateSetConflictAction as l, InsertOnConflict as m, AndExpr as n, DeleteAst as o, InsertAst as p, BinaryExpr as r, DerivedTableSource as s, AggregateExpr as t, EqColJoinOn as u, ListExpression as v, OrderByItem as w, NullCheckExpr as x, LiteralExpr as y };
|
|
1111
1120
|
|
|
1112
|
-
//# sourceMappingURL=types-
|
|
1121
|
+
//# sourceMappingURL=types-DRYJSMk1.mjs.map
|