@prisma-next/sql-relational-core 0.11.0-dev.41 → 0.11.0-dev.43
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/dist/{errors-DH06zmF_.d.mts → errors-DgFS8WJZ.d.mts} +2 -2
- package/dist/{errors-DH06zmF_.d.mts.map → errors-DgFS8WJZ.d.mts.map} +1 -1
- package/dist/exports/ast.d.mts +2 -2
- package/dist/exports/ast.mjs +2 -2
- package/dist/exports/errors.d.mts +1 -1
- package/dist/exports/expression.d.mts +46 -2
- package/dist/exports/expression.d.mts.map +1 -1
- package/dist/exports/expression.mjs +55 -2
- package/dist/exports/expression.mjs.map +1 -1
- package/dist/exports/middleware.d.mts +1 -1
- package/dist/exports/plan.d.mts +2 -2
- package/dist/exports/types.d.mts +2 -2
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +3 -3
- package/dist/{middleware-BjQNVzwu.d.mts → middleware-EOcO8Ogo.d.mts} +2 -2
- package/dist/{middleware-BjQNVzwu.d.mts.map → middleware-EOcO8Ogo.d.mts.map} +1 -1
- package/dist/{plan-Cm7uk4B8.d.mts → plan-CG3sy5kw.d.mts} +2 -2
- package/dist/{plan-Cm7uk4B8.d.mts.map → plan-CG3sy5kw.d.mts.map} +1 -1
- package/dist/{sql-execution-plan-Cyrn58Gz.d.mts → sql-execution-plan-D4OimCVH.d.mts} +2 -2
- package/dist/{sql-execution-plan-Cyrn58Gz.d.mts.map → sql-execution-plan-D4OimCVH.d.mts.map} +1 -1
- package/dist/{types-ChVmNzZF.mjs → types-C4EdOD-s.mjs} +23 -2
- package/dist/types-C4EdOD-s.mjs.map +1 -0
- package/dist/{types-XUCMIR06.d.mts → types-C_1ZqLwZ.d.mts} +20 -3
- package/dist/types-C_1ZqLwZ.d.mts.map +1 -0
- package/dist/{types-CY3u7tcE.d.mts → types-CkTDkFcK.d.mts} +3 -3
- package/dist/{types-CY3u7tcE.d.mts.map → types-CkTDkFcK.d.mts.map} +1 -1
- package/dist/{types-CNmLX5wR.d.mts → types-Dhr7lWNQ.d.mts} +3 -3
- package/dist/{types-CNmLX5wR.d.mts.map → types-Dhr7lWNQ.d.mts.map} +1 -1
- package/package.json +11 -11
- package/src/ast/types.ts +44 -1
- package/src/expression.ts +108 -2
- package/dist/types-ChVmNzZF.mjs.map +0 -1
- package/dist/types-XUCMIR06.d.mts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { y as RuntimeError } from "./types-
|
|
1
|
+
import { y as RuntimeError } from "./types-Dhr7lWNQ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
declare function planInvalid(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
|
|
5
5
|
declare function planUnsupported(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { planUnsupported as n, planInvalid as t };
|
|
8
|
-
//# sourceMappingURL=errors-
|
|
8
|
+
//# sourceMappingURL=errors-DgFS8WJZ.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-DgFS8WJZ.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;iBAEgB,WAAA,CACd,OAAA,UACA,OAAA,GAAU,MAAA,mBACV,KAAA,sBACA,IAAA,uBACC,YAAY;AAAA,iBAkBC,eAAA,CACd,OAAA,UACA,OAAA,GAAU,MAAA,mBACV,KAAA,sBACA,IAAA,uBACC,YAAY"}
|
package/dist/exports/ast.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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
|
|
2
|
+
import { $ as RawSqlExpr, A as InsertAst, B as LiteralExpr, C as EqColJoinOn, D as ExpressionRewriter, E as ExpressionFolder, F as JsonArrayAggExpr, G as OperationExpr, H as LoweredStatement, I as JsonObjectEntry, J as ParamRef, K as OrExpr, L as JsonObjectExpr, M as InsertValue, N as JoinAst, O as ExpressionSource, P as JoinOnExpr, Q as RawExpr, R as LimitOffsetValue, S as DoUpdateSetConflictAction, T as ExprVisitor, U as NotExpr, V as LoweredParam, W as NullCheckExpr, X as ProjectionExpr, Y as PreparedParamRef, Z as ProjectionItem, _ as DefaultValueExpr, a as AndExpr, at as TableSource, b as Direction, c as AnyInsertOnConflictAction, ct as WhereArg, d as AnyParamRef, dt as isQueryAst, et as RawSqlLiteral, f as AnyQueryAst, ft as isWhereExpr, g as ColumnRef, h as BinaryOp, i as AggregateOpFn, it as TableRef, j as InsertOnConflict, k as IdentifierRef, l as AnyInsertValue, lt as WindowFn, m as BinaryExpr, mt as whereExprKinds, n as AggregateExpr, nt as SelectAstOptions, o as AnyExpression, ot as ToWhereExpr, p as AstRewriter, pt as queryAstKinds, q as OrderByItem, r as AggregateFn, rt as SubqueryExpr, s as AnyFromSource, st as UpdateAst, t as AggregateCountFn, tt as SelectAst, u as AnyOperationArg, ut as WindowFuncExpr, v as DeleteAst, w as ExistsExpr, x as DoNothingConflictAction, y as DerivedTableSource, z as ListExpression } from "../types-C_1ZqLwZ.mjs";
|
|
3
3
|
import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
|
|
4
4
|
import { CodecCallContext as CodecCallContext$1, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
|
|
5
5
|
import { ContractMarkerRecord, JsonValue } from "@prisma-next/contract/types";
|
|
@@ -266,5 +266,5 @@ declare function compact<T extends Record<string, unknown>>(o: T): T;
|
|
|
266
266
|
*/
|
|
267
267
|
declare function collectOrderedParamRefs(ast: AnyQueryAst): ReadonlyArray<AnyParamRef>;
|
|
268
268
|
//#endregion
|
|
269
|
-
export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyParamRef, AnyQueryAst, AstRewriter, BinaryExpr, BinaryOp, Codec, CodecCallContext, CodecDescriptor, CodecMeta, CodecRef, CodecTrait, ColumnRef, ContractCodecRegistry, DefaultValueExpr, DeleteAst, DerivedTableSource, DescriptorCodecId, DescriptorCodecInput, DescriptorCodecTraits, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, ExprVisitor, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, LimitOffsetValue, ListExpression, LiteralExpr, LoweredParam, LoweredStatement, Lowerer, LowererContext, MarkerReadResult, MarkerStatement, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, PreparedExecuteRequest, PreparedParamRef, ProjectionExpr, 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, SelectAstOptions, SqlCharCodec, SqlCharDescriptor, SqlCodecCallContext, SqlCodecInstanceContext, SqlColumnRef, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlQueryResult, SqlQueryable, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlTransaction, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableRef, TableSource, ToWhereExpr, UpdateAst, WhereArg, WindowFn, WindowFuncExpr, collectOrderedParamRefs, compact, isQueryAst, isWhereExpr, 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, whereExprKinds };
|
|
269
|
+
export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyParamRef, AnyQueryAst, AstRewriter, BinaryExpr, BinaryOp, Codec, CodecCallContext, CodecDescriptor, CodecMeta, CodecRef, CodecTrait, ColumnRef, ContractCodecRegistry, DefaultValueExpr, DeleteAst, DerivedTableSource, DescriptorCodecId, DescriptorCodecInput, DescriptorCodecTraits, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, ExprVisitor, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, LimitOffsetValue, ListExpression, LiteralExpr, LoweredParam, LoweredStatement, Lowerer, LowererContext, MarkerReadResult, MarkerStatement, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, PreparedExecuteRequest, PreparedParamRef, ProjectionExpr, ProjectionItem, RawExpr, RawSqlExpr, RawSqlLiteral, 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, SelectAstOptions, SqlCharCodec, SqlCharDescriptor, SqlCodecCallContext, SqlCodecInstanceContext, SqlColumnRef, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlQueryResult, SqlQueryable, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlTransaction, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableRef, TableSource, ToWhereExpr, UpdateAst, WhereArg, WindowFn, WindowFuncExpr, collectOrderedParamRefs, compact, isQueryAst, isWhereExpr, 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, whereExprKinds };
|
|
270
270
|
//# sourceMappingURL=ast.d.mts.map
|
package/dist/exports/ast.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as SelectAst, C as OrExpr, D as ProjectionItem, E as PreparedParamRef, F as isQueryAst, I as isWhereExpr, L as queryAstKinds, M as TableSource, N as UpdateAst, O as RawExpr, P as WindowFuncExpr, R as whereExprKinds, 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 SubqueryExpr, k as RawSqlExpr, 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-C4EdOD-s.mjs";
|
|
2
2
|
import { n as compact, t as collectOrderedParamRefs } from "../util-DWmhUCEO.mjs";
|
|
3
3
|
import { CodecDescriptorImpl, CodecImpl, column, voidParamsSchema } from "@prisma-next/framework-components/codec";
|
|
4
4
|
import { type } from "arktype";
|
|
@@ -230,6 +230,6 @@ var SqlTimestampDescriptor = class extends CodecDescriptorImpl {
|
|
|
230
230
|
const sqlTimestampDescriptor = new SqlTimestampDescriptor();
|
|
231
231
|
const sqlTimestampColumn = (params = {}) => column(sqlTimestampDescriptor.factory(params), sqlTimestampDescriptor.codecId, params, "timestamp");
|
|
232
232
|
//#endregion
|
|
233
|
-
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, PreparedParamRef, 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, WindowFuncExpr, collectOrderedParamRefs, compact, isQueryAst, isWhereExpr, 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, whereExprKinds };
|
|
233
|
+
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, PreparedParamRef, ProjectionItem, RawExpr, 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, WindowFuncExpr, collectOrderedParamRefs, compact, isQueryAst, isWhereExpr, 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, whereExprKinds };
|
|
234
234
|
|
|
235
235
|
//# sourceMappingURL=ast.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as planUnsupported, t as planInvalid } from "../errors-
|
|
1
|
+
import { n as planUnsupported, t as planInvalid } from "../errors-DgFS8WJZ.mjs";
|
|
2
2
|
export { planInvalid, planUnsupported };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as CodecRef } from "../codec-types-Cezo7k-i.mjs";
|
|
2
|
-
import { o as AnyExpression } from "../types-
|
|
2
|
+
import { J as ParamRef, et as RawSqlLiteral, o as AnyExpression } from "../types-C_1ZqLwZ.mjs";
|
|
3
3
|
import { QueryOperationReturn } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { ParamSpec } from "@prisma-next/operations";
|
|
5
5
|
import { SqlLoweringSpec } from "@prisma-next/sql-operations";
|
|
@@ -67,6 +67,12 @@ type TraitExpression<Traits extends readonly string[], Nullable extends boolean,
|
|
|
67
67
|
* 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)`).
|
|
68
68
|
*/
|
|
69
69
|
declare function toExpr(value: unknown, codec?: CodecRef): AnyExpression;
|
|
70
|
+
/**
|
|
71
|
+
* Construct a `ParamRef` for a value whose codec identity is known at call time. Use this when interpolating a value into a raw SQL expression and the codec cannot be inferred from context — e.g. `param(myDate, { codecId: 'pg/timestamptz@1' })`.
|
|
72
|
+
*/
|
|
73
|
+
declare function param<T>(value: T, opts: {
|
|
74
|
+
codecId: string;
|
|
75
|
+
}): ParamRef;
|
|
70
76
|
/**
|
|
71
77
|
* Derive the {@link CodecRef} carried by an expression-like value.
|
|
72
78
|
*
|
|
@@ -91,6 +97,44 @@ interface BuildOperationSpec<R extends ScopeField> {
|
|
|
91
97
|
* 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.
|
|
92
98
|
*/
|
|
93
99
|
declare function buildOperation<R extends ScopeField>(spec: BuildOperationSpec<R>): Expression<R>;
|
|
100
|
+
/**
|
|
101
|
+
* Resolves a codec id for a bare JavaScript value interpolated into a raw-SQL
|
|
102
|
+
* template — e.g. `` rawSql`SELECT ${42}` `` calls `inferCodec(42)` to pick
|
|
103
|
+
* the codec id (`pg/int4`, `sqlite/integer@1`, etc.) that will encode the
|
|
104
|
+
* value as a bound parameter.
|
|
105
|
+
*
|
|
106
|
+
* Targets implement this once per dialect: examine the JS value's runtime
|
|
107
|
+
* shape (number, bigint, string, boolean, `Uint8Array`) and return a codec
|
|
108
|
+
* id known to the target's codec registry. Throw when the value falls
|
|
109
|
+
* outside the supported set — callers should wrap such values with
|
|
110
|
+
* `param(value, { codecId })` to declare the codec explicitly.
|
|
111
|
+
*/
|
|
112
|
+
interface RawCodecInferer {
|
|
113
|
+
inferCodec(value: RawSqlLiteral): string;
|
|
114
|
+
}
|
|
115
|
+
/** The one-method builder returned by a `RawSqlTag` template call before `.returns()` is called. */
|
|
116
|
+
interface RawSqlBuilder {
|
|
117
|
+
returns<S extends string>(spec: S): Expression<{
|
|
118
|
+
codecId: S;
|
|
119
|
+
nullable: false;
|
|
120
|
+
}>;
|
|
121
|
+
returns<S extends string, N extends boolean = false>(spec: {
|
|
122
|
+
readonly codecId: S;
|
|
123
|
+
readonly nullable?: N;
|
|
124
|
+
}): Expression<{
|
|
125
|
+
codecId: S;
|
|
126
|
+
nullable: N;
|
|
127
|
+
}>;
|
|
128
|
+
}
|
|
129
|
+
/** Tagged-template function returned by {@link createRawSql}. */
|
|
130
|
+
type RawSqlTag = (strings: TemplateStringsArray, ...values: RawSqlInterpolation[]) => RawSqlBuilder;
|
|
131
|
+
type RawSqlInterpolation = Expression<ScopeField> | ParamRef | RawSqlLiteral;
|
|
132
|
+
/**
|
|
133
|
+
* Create a tagged-template builder for raw SQL expressions. The returned tag accepts SQL string fragments interleaved with typed {@link Expression}, {@link ParamRef}, or bare {@link RawSqlLiteral} interpolations. Call `.returns(spec)` on the result to obtain a typed {@link Expression} whose AST is a {@link RawExpr}.
|
|
134
|
+
*
|
|
135
|
+
* Bare {@link RawSqlLiteral} interpolations are wrapped as `ParamRef` nodes with the codec resolved via `adapter.inferCodec(value)`. Use {@link param} when the codec cannot be inferred from the value alone (e.g. `Date`).
|
|
136
|
+
*/
|
|
137
|
+
declare function createRawSql(adapter: RawCodecInferer): RawSqlTag;
|
|
94
138
|
//#endregion
|
|
95
|
-
export { BuildOperationSpec, CodecExpression, CodecTypesBase, CodecValue, Expression, ScopeField, TraitExpression, buildOperation, codecOf, toExpr };
|
|
139
|
+
export { BuildOperationSpec, CodecExpression, CodecTypesBase, CodecValue, Expression, RawCodecInferer, RawSqlBuilder, RawSqlTag, ScopeField, TraitExpression, buildOperation, codecOf, createRawSql, param, toExpr };
|
|
96
140
|
//# sourceMappingURL=expression.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.d.mts","names":[],"sources":["../../src/expression.ts"],"mappings":";;;;;;;KAQY,UAAA;EACV,OAAA;EACA,QAAA
|
|
1
|
+
{"version":3,"file":"expression.d.mts","names":[],"sources":["../../src/expression.ts"],"mappings":";;;;;;;KAQY,UAAA;EACV,OAAA;EACA,QAAA;;;;EAIA,KAAA,GAAQ,QAAQ;AAAA;AAAA,KAGN,cAAA,GAAiB,MAAM;EAAA,SAAoB,KAAA;EAAA,SAAyB,MAAA;AAAA;;;;KAKpE,UAAA,WAAqB,UAAA,IAAc,oBAAA;EAAA,SACpC,UAAA,EAAY,CAAA;EACrB,QAAA,IAAY,aAAA;AAAA;AAAA,KAGT,iBAAA,YACQ,MAAA;EAAA,SAA0B,KAAA;AAAA,8DAGzB,EAAA,YAAc,EAAA,CAAG,CAAA;EAAA,SAAsB,MAAA;AAAA,KAC9C,cAAA,mBAAiC,CAAA,IAChC,CAAA,yBAGA,EAAA;AAAA,KAEH,UAAA,MAAgB,CAAC;;;;;KAMV,UAAA,8DAGC,MAAA;EAAA,SAA0B,KAAA;AAAA,OAClC,OAAA,eAAsB,EAAA,GAAK,EAAA,CAAG,OAAA,sBAA6B,UAAA,CAAW,QAAA;;;;AAxBhD;AACzB;;;;KAiCU,eAAA,8DAGC,MAAA;EAAA,SAA0B,KAAA;AAAA,MACnC,UAAA;EAAa,OAAA,EAAS,OAAA;EAAS,QAAA,EAAU,QAAA;AAAA,KAAc,UAAA,CAAW,OAAA,EAAS,QAAA,EAAU,EAAA;;;;;;KAO7E,eAAA,wEAGC,MAAA;EAAA,SAA0B,KAAA;AAAA,MACnC,eAAA,CAAgB,iBAAA,CAAkB,EAAA,EAAI,MAAA,GAAS,QAAA,EAAU,EAAA;;;;;;;;iBAS7C,MAAA,CAAO,KAAA,WAAgB,KAAA,GAAQ,QAAA,GAAW,aAAa;;;AA9C7D;iBA+DM,KAAA,GAAA,CAAS,KAAA,EAAO,CAAA,EAAG,IAAA;EAAQ,OAAA;AAAA,IAAoB,QAAQ;;AA7DjD;AAMtB;;;;;;;;iBAqEgB,OAAA,CAAQ,KAAA,YAAiB,QAAQ;AAAA,UAqBhC,kBAAA,WAA6B,UAAA;EAAA,SACnC,MAAA;EAvF+D;;;EAAA,SA2F/D,IAAA,YAAgB,aAAA,KAAkB,aAAA;EAAA,SAClC,OAAA,EAAS,CAAA,GAAI,SAAA;EAAA,SACb,QAAA,EAAU,eAAA;AAAA;;;;iBAML,cAAA,WAAyB,UAAA,CAAA,CAAY,IAAA,EAAM,kBAAA,CAAmB,CAAA,IAAK,UAAA,CAAW,CAAA;;;AAnGX;AAUnF;;;;;;;;;UAoHiB,eAAA;EACf,UAAA,CAAW,KAAA,EAAO,aAAa;AAAA;;UAIhB,aAAA;EACf,OAAA,mBAA0B,IAAA,EAAM,CAAA,GAAI,UAAA;IAAa,OAAA,EAAS,CAAA;IAAG,QAAA;EAAA;EAC7D,OAAA,8CAAqD,IAAA;IAAA,SAC1C,OAAA,EAAS,CAAA;IAAA,SACT,QAAA,GAAW,CAAA;EAAA,IAClB,UAAA;IAAa,OAAA,EAAS,CAAA;IAAG,QAAA,EAAU,CAAA;EAAA;AAAA;;KAI7B,SAAA,IACV,OAAA,EAAS,oBAAA,KACN,MAAA,EAAQ,mBAAA,OACR,aAAA;AAAA,KAEA,mBAAA,GAAsB,UAAA,CAAW,UAAA,IAAc,QAAA,GAAW,aAAA;AA5H/D;;;;;AAAA,iBA8JgB,YAAA,CAAa,OAAA,EAAS,eAAA,GAAkB,SAAS"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as OperationExpr, T as ParamRef } from "../types-
|
|
1
|
+
import { O as RawExpr, S as OperationExpr, T as ParamRef } from "../types-C4EdOD-s.mjs";
|
|
2
2
|
import { runtimeError } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
//#region src/expression.ts
|
|
4
4
|
/**
|
|
@@ -14,6 +14,12 @@ function toExpr(value, codec) {
|
|
|
14
14
|
return ParamRef.of(value, { codec });
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
+
* Construct a `ParamRef` for a value whose codec identity is known at call time. Use this when interpolating a value into a raw SQL expression and the codec cannot be inferred from context — e.g. `param(myDate, { codecId: 'pg/timestamptz@1' })`.
|
|
18
|
+
*/
|
|
19
|
+
function param(value, opts) {
|
|
20
|
+
return ParamRef.of(value, { codec: { codecId: opts.codecId } });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
17
23
|
* Derive the {@link CodecRef} carried by an expression-like value.
|
|
18
24
|
*
|
|
19
25
|
* Resolution order:
|
|
@@ -50,7 +56,54 @@ function buildOperation(spec) {
|
|
|
50
56
|
buildAst: () => op
|
|
51
57
|
};
|
|
52
58
|
}
|
|
59
|
+
function resolveInterpolation(adapter, value) {
|
|
60
|
+
if (isExpressionLike(value)) return value.buildAst();
|
|
61
|
+
if (value instanceof ParamRef) return value;
|
|
62
|
+
if (typeof value === "number" || typeof value === "bigint" || typeof value === "string" || typeof value === "boolean" || value instanceof Uint8Array) return ParamRef.of(value, { codec: { codecId: adapter.inferCodec(value) } });
|
|
63
|
+
throw runtimeError("RUNTIME.RAW_SQL_UNSUPPORTED_INTERPOLATION", "unsupported JS value type for raw-SQL interpolation: wrap this value in `param(...)` with an explicit codec");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a tagged-template builder for raw SQL expressions. The returned tag accepts SQL string fragments interleaved with typed {@link Expression}, {@link ParamRef}, or bare {@link RawSqlLiteral} interpolations. Call `.returns(spec)` on the result to obtain a typed {@link Expression} whose AST is a {@link RawExpr}.
|
|
67
|
+
*
|
|
68
|
+
* Bare {@link RawSqlLiteral} interpolations are wrapped as `ParamRef` nodes with the codec resolved via `adapter.inferCodec(value)`. Use {@link param} when the codec cannot be inferred from the value alone (e.g. `Date`).
|
|
69
|
+
*/
|
|
70
|
+
function createRawSql(adapter) {
|
|
71
|
+
return (strings, ...values) => {
|
|
72
|
+
const parts = [];
|
|
73
|
+
parts.push(strings[0] ?? "");
|
|
74
|
+
values.forEach((value, i) => {
|
|
75
|
+
parts.push(resolveInterpolation(adapter, value));
|
|
76
|
+
parts.push(strings[i + 1] ?? "");
|
|
77
|
+
});
|
|
78
|
+
return new RawSqlBuilderImpl(parts);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
var RawSqlBuilderImpl = class {
|
|
82
|
+
parts;
|
|
83
|
+
constructor(parts) {
|
|
84
|
+
this.parts = parts;
|
|
85
|
+
}
|
|
86
|
+
returns(spec) {
|
|
87
|
+
const codecId = typeof spec === "string" ? spec : spec.codecId;
|
|
88
|
+
const nullable = typeof spec === "string" ? false : spec.nullable ?? false;
|
|
89
|
+
const paramSpec = {
|
|
90
|
+
codecId,
|
|
91
|
+
nullable
|
|
92
|
+
};
|
|
93
|
+
const node = new RawExpr({
|
|
94
|
+
parts: this.parts,
|
|
95
|
+
returns: paramSpec
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
returnType: {
|
|
99
|
+
codecId,
|
|
100
|
+
nullable
|
|
101
|
+
},
|
|
102
|
+
buildAst: () => node
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
53
106
|
//#endregion
|
|
54
|
-
export { buildOperation, codecOf, toExpr };
|
|
107
|
+
export { buildOperation, codecOf, createRawSql, param, toExpr };
|
|
55
108
|
|
|
56
109
|
//# sourceMappingURL=expression.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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\nexport type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;\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 * Runtime value type for a slot bound to `CodecId` with the given\n * nullability — `CT[CodecId]['input']`, plus `null` when `Nullable` is true.\n */\nexport type CodecValue<\n CodecId extends string,\n Nullable extends boolean,\n CT extends Record<string, { readonly input: unknown }>,\n> = (CodecId extends keyof CT ? CT[CodecId]['input'] : never) | NullSuffix<Nullable>;\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> = Expression<{ codecId: CodecId; nullable: Nullable }> | CodecValue<CodecId, Nullable, CT>;\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":";;;;;;;;;;AAkFA,SAAgB,OAAO,OAAgB,OAAiC;CACtE,IAAI,iBAAiB,KAAK,GACxB,OAAO,MAAM,SAAS;CAExB,IAAI,UAAU,KAAA,GACZ,MAAM,aACJ,oCACA,qCAAqC,UAAU,OAAO,SAAS,OAAO,MAAM,0GAE9E;CAEF,OAAO,SAAS,GAAG,OAAO,EAAE,MAAM,CAAC;AACrC;;;;;;;;;;;AAYA,SAAgB,QAAQ,OAAsC;CAC5D,IAAI,CAAC,iBAAiB,KAAK,GAAG,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,QAAQ;AAEhF;AAEA,SAAS,iBAAiB,OAAiD;CACzE,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAc,SACd,OAAQ,MAAgC,aAAa;AAEzD;;;;AAeA,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;CACjB,CAAC;CACD,OAAO;EACL,YAAY,KAAK;EACjB,gBAAgB;CAClB;AACF"}
|
|
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, RawSqlLiteral } from './ast/types';\nimport { OperationExpr, ParamRef, RawExpr } 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\nexport type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;\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 * Runtime value type for a slot bound to `CodecId` with the given\n * nullability — `CT[CodecId]['input']`, plus `null` when `Nullable` is true.\n */\nexport type CodecValue<\n CodecId extends string,\n Nullable extends boolean,\n CT extends Record<string, { readonly input: unknown }>,\n> = (CodecId extends keyof CT ? CT[CodecId]['input'] : never) | NullSuffix<Nullable>;\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> = Expression<{ codecId: CodecId; nullable: Nullable }> | CodecValue<CodecId, Nullable, CT>;\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 * Construct a `ParamRef` for a value whose codec identity is known at call time. Use this when interpolating a value into a raw SQL expression and the codec cannot be inferred from context — e.g. `param(myDate, { codecId: 'pg/timestamptz@1' })`.\n */\nexport function param<T>(value: T, opts: { codecId: string }): ParamRef {\n return ParamRef.of(value, { codec: { codecId: opts.codecId } });\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\n/**\n * Resolves a codec id for a bare JavaScript value interpolated into a raw-SQL\n * template — e.g. `` rawSql`SELECT ${42}` `` calls `inferCodec(42)` to pick\n * the codec id (`pg/int4`, `sqlite/integer@1`, etc.) that will encode the\n * value as a bound parameter.\n *\n * Targets implement this once per dialect: examine the JS value's runtime\n * shape (number, bigint, string, boolean, `Uint8Array`) and return a codec\n * id known to the target's codec registry. Throw when the value falls\n * outside the supported set — callers should wrap such values with\n * `param(value, { codecId })` to declare the codec explicitly.\n */\nexport interface RawCodecInferer {\n inferCodec(value: RawSqlLiteral): string;\n}\n\n/** The one-method builder returned by a `RawSqlTag` template call before `.returns()` is called. */\nexport interface RawSqlBuilder {\n returns<S extends string>(spec: S): Expression<{ codecId: S; nullable: false }>;\n returns<S extends string, N extends boolean = false>(spec: {\n readonly codecId: S;\n readonly nullable?: N;\n }): Expression<{ codecId: S; nullable: N }>;\n}\n\n/** Tagged-template function returned by {@link createRawSql}. */\nexport type RawSqlTag = (\n strings: TemplateStringsArray,\n ...values: RawSqlInterpolation[]\n) => RawSqlBuilder;\n\ntype RawSqlInterpolation = Expression<ScopeField> | ParamRef | RawSqlLiteral;\n\nfunction resolveInterpolation(\n adapter: RawCodecInferer,\n value: RawSqlInterpolation,\n): AstExpression | ParamRef {\n if (isExpressionLike(value)) {\n return value.buildAst();\n }\n if (value instanceof ParamRef) {\n return value;\n }\n if (\n typeof value === 'number' ||\n typeof value === 'bigint' ||\n typeof value === 'string' ||\n typeof value === 'boolean' ||\n value instanceof Uint8Array\n ) {\n return ParamRef.of(value, { codec: { codecId: adapter.inferCodec(value) } });\n }\n\n value satisfies never;\n throw runtimeError(\n 'RUNTIME.RAW_SQL_UNSUPPORTED_INTERPOLATION',\n 'unsupported JS value type for raw-SQL interpolation: wrap this value in `param(...)` with an explicit codec',\n );\n}\n\n/**\n * Create a tagged-template builder for raw SQL expressions. The returned tag accepts SQL string fragments interleaved with typed {@link Expression}, {@link ParamRef}, or bare {@link RawSqlLiteral} interpolations. Call `.returns(spec)` on the result to obtain a typed {@link Expression} whose AST is a {@link RawExpr}.\n *\n * Bare {@link RawSqlLiteral} interpolations are wrapped as `ParamRef` nodes with the codec resolved via `adapter.inferCodec(value)`. Use {@link param} when the codec cannot be inferred from the value alone (e.g. `Date`).\n */\nexport function createRawSql(adapter: RawCodecInferer): RawSqlTag {\n return (strings, ...values) => {\n const parts: (string | AstExpression | ParamRef)[] = [];\n parts.push(strings[0] ?? '');\n values.forEach((value, i) => {\n parts.push(resolveInterpolation(adapter, value));\n parts.push(strings[i + 1] ?? '');\n });\n return new RawSqlBuilderImpl(parts);\n };\n}\n\nclass RawSqlBuilderImpl implements RawSqlBuilder {\n constructor(private readonly parts: readonly (string | AstExpression | ParamRef)[]) {}\n\n returns<S extends string>(spec: S): Expression<{ codecId: S; nullable: false }>;\n returns<S extends string, N extends boolean = false>(spec: {\n readonly codecId: S;\n readonly nullable?: N;\n }): Expression<{ codecId: S; nullable: N }>;\n returns(\n spec: string | { readonly codecId: string; readonly nullable?: boolean },\n ): Expression<{ codecId: string; nullable: boolean }> {\n const codecId = typeof spec === 'string' ? spec : spec.codecId;\n const nullable = typeof spec === 'string' ? false : (spec.nullable ?? false);\n const paramSpec: ParamSpec = { codecId, nullable };\n const node = new RawExpr({ parts: this.parts, returns: paramSpec });\n return {\n returnType: { codecId, nullable },\n buildAst: () => node,\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAkFA,SAAgB,OAAO,OAAgB,OAAiC;CACtE,IAAI,iBAAiB,KAAK,GACxB,OAAO,MAAM,SAAS;CAExB,IAAI,UAAU,KAAA,GACZ,MAAM,aACJ,oCACA,qCAAqC,UAAU,OAAO,SAAS,OAAO,MAAM,0GAE9E;CAEF,OAAO,SAAS,GAAG,OAAO,EAAE,MAAM,CAAC;AACrC;;;;AAKA,SAAgB,MAAS,OAAU,MAAqC;CACtE,OAAO,SAAS,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAC;AAChE;;;;;;;;;;;AAYA,SAAgB,QAAQ,OAAsC;CAC5D,IAAI,CAAC,iBAAiB,KAAK,GAAG,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,QAAQ;AAEhF;AAEA,SAAS,iBAAiB,OAAiD;CACzE,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAc,SACd,OAAQ,MAAgC,aAAa;AAEzD;;;;AAeA,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;CACjB,CAAC;CACD,OAAO;EACL,YAAY,KAAK;EACjB,gBAAgB;CAClB;AACF;AAmCA,SAAS,qBACP,SACA,OAC0B;CAC1B,IAAI,iBAAiB,KAAK,GACxB,OAAO,MAAM,SAAS;CAExB,IAAI,iBAAiB,UACnB,OAAO;CAET,IACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,aACjB,iBAAiB,YAEjB,OAAO,SAAS,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,QAAQ,WAAW,KAAK,EAAE,EAAE,CAAC;CAI7E,MAAM,aACJ,6CACA,6GACF;AACF;;;;;;AAOA,SAAgB,aAAa,SAAqC;CAChE,QAAQ,SAAS,GAAG,WAAW;EAC7B,MAAM,QAA+C,CAAC;EACtD,MAAM,KAAK,QAAQ,MAAM,EAAE;EAC3B,OAAO,SAAS,OAAO,MAAM;GAC3B,MAAM,KAAK,qBAAqB,SAAS,KAAK,CAAC;GAC/C,MAAM,KAAK,QAAQ,IAAI,MAAM,EAAE;EACjC,CAAC;EACD,OAAO,IAAI,kBAAkB,KAAK;CACpC;AACF;AAEA,IAAM,oBAAN,MAAiD;CAClB;CAA7B,YAAY,OAAwE;EAAvD,KAAA,QAAA;CAAwD;CAOrF,QACE,MACoD;EACpD,MAAM,UAAU,OAAO,SAAS,WAAW,OAAO,KAAK;EACvD,MAAM,WAAW,OAAO,SAAS,WAAW,QAAS,KAAK,YAAY;EACtE,MAAM,YAAuB;GAAE;GAAS;EAAS;EACjD,MAAM,OAAO,IAAI,QAAQ;GAAE,OAAO,KAAK;GAAO,SAAS;EAAU,CAAC;EAClE,OAAO;GACL,YAAY;IAAE;IAAS;GAAS;GAChC,gBAAgB;EAClB;CACF;AACF"}
|
|
@@ -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-EOcO8Ogo.mjs";
|
|
2
2
|
export { ParamRefEntry, ParamRefEntryUnion, ParamRefHandle, SqlParamRefMutator, SqlParamRefMutatorInternal, 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-D4OimCVH.mjs";
|
|
2
|
+
import { n as planFromAst, t as SqlQueryPlan } from "../plan-CG3sy5kw.mjs";
|
|
3
3
|
export { type SqlExecutionPlan, SqlQueryPlan, planFromAst };
|
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-Dhr7lWNQ.mjs";
|
|
2
|
+
import { n as SqlOrmPlan, t as RuntimeScope } from "../types-CkTDkFcK.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
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
|
|
2
|
+
import { $ as RawSqlExpr, A as InsertAst, B as LiteralExpr, C as EqColJoinOn, D as ExpressionRewriter, E as ExpressionFolder, F as JsonArrayAggExpr, G as OperationExpr, H as LoweredStatement, I as JsonObjectEntry, J as ParamRef, K as OrExpr, L as JsonObjectExpr, M as InsertValue, N as JoinAst, O as ExpressionSource, P as JoinOnExpr, Q as RawExpr, R as LimitOffsetValue, S as DoUpdateSetConflictAction, T as ExprVisitor, U as NotExpr, V as LoweredParam, W as NullCheckExpr, X as ProjectionExpr, Y as PreparedParamRef, Z as ProjectionItem, _ as DefaultValueExpr, a as AndExpr, at as TableSource, b as Direction, c as AnyInsertOnConflictAction, ct as WhereArg, d as AnyParamRef, dt as isQueryAst, et as RawSqlLiteral, f as AnyQueryAst, ft as isWhereExpr, g as ColumnRef, h as BinaryOp, i as AggregateOpFn, it as TableRef, j as InsertOnConflict, k as IdentifierRef, l as AnyInsertValue, lt as WindowFn, m as BinaryExpr, mt as whereExprKinds, n as AggregateExpr, nt as SelectAstOptions, o as AnyExpression, ot as ToWhereExpr, p as AstRewriter, pt as queryAstKinds, q as OrderByItem, r as AggregateFn, rt as SubqueryExpr, s as AnyFromSource, st as UpdateAst, t as AggregateCountFn, tt as SelectAst, u as AnyOperationArg, ut as WindowFuncExpr, v as DeleteAst, w as ExistsExpr, x as DoNothingConflictAction, y as DerivedTableSource, z as ListExpression } from "./types-C_1ZqLwZ.mjs";
|
|
3
3
|
import { Adapter, AdapterProfile, AdapterTarget, Lowerer, LowererContext, MarkerReadResult, MarkerStatement, PreparedExecuteRequest, 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
4
|
import { a as MutationDefaultsOptions, i as MutationDefaultsOp, n as CodecDescriptorRegistry, o as TypeHelperRegistry, r as ExecutionContext, t as AppliedMutationDefault } from "./query-lane-context-Dw1Tz0kv.mjs";
|
|
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, CodecTypesBase, CodecValue, 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-
|
|
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, AnyParamRef, AnyQueryAst, AppliedMutationDefault, AstRewriter, BinaryExpr, BinaryOp, BuildOperationSpec, BuildOptions, BuildParamsMap, Codec, CodecCallContext, CodecDescriptor, CodecDescriptorRegistry, CodecExpression, CodecMeta, CodecRef, CodecTrait, CodecTypes, CodecTypesBase, CodecValue, 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, LimitOffsetValue, ListExpression, LiteralExpr, LoweredParam, LoweredStatement, Lowerer, LowererContext, META, MarkerReadResult, MarkerStatement, Meta, ModelDef, ModelMetadata, MutationDefaultsOp, MutationDefaultsOptions, NotExpr, NullCheckExpr, OperationExpr, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrExpr, OrderByItem, ParamRef, ParamRefEntry, ParamRefEntryUnion, ParamRefHandle, PreparedExecuteRequest, PreparedParamRef, 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, WindowFn, WindowFuncExpr, 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 };
|
|
5
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-D4OimCVH.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-Dhr7lWNQ.mjs";
|
|
7
|
+
import { n as planUnsupported, t as planInvalid } from "./errors-DgFS8WJZ.mjs";
|
|
8
|
+
import { BuildOperationSpec, CodecExpression, CodecTypesBase, CodecValue, Expression, RawCodecInferer, RawSqlBuilder, RawSqlTag, ScopeField, TraitExpression, buildOperation, codecOf, createRawSql, param, 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-EOcO8Ogo.mjs";
|
|
10
|
+
import { n as planFromAst, t as SqlQueryPlan } from "./plan-CG3sy5kw.mjs";
|
|
11
|
+
import { n as SqlOrmPlan, t as RuntimeScope } from "./types-CkTDkFcK.mjs";
|
|
12
|
+
export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyParamRef, AnyQueryAst, AppliedMutationDefault, AstRewriter, BinaryExpr, BinaryOp, BuildOperationSpec, BuildOptions, BuildParamsMap, Codec, CodecCallContext, CodecDescriptor, CodecDescriptorRegistry, CodecExpression, CodecMeta, CodecRef, CodecTrait, CodecTypes, CodecTypesBase, CodecValue, 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, LimitOffsetValue, ListExpression, LiteralExpr, LoweredParam, LoweredStatement, Lowerer, LowererContext, META, MarkerReadResult, MarkerStatement, Meta, ModelDef, ModelMetadata, MutationDefaultsOp, MutationDefaultsOptions, NotExpr, NullCheckExpr, OperationExpr, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrExpr, OrderByItem, ParamRef, ParamRefEntry, ParamRefEntryUnion, ParamRefHandle, PreparedExecuteRequest, PreparedParamRef, ProjectionExpr, ProjectionItem, RawCodecInferer, RawExpr, RawFactory, RawFunctionOptions, RawSqlBuilder, RawSqlExpr, RawSqlLiteral, RawSqlTag, 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, WindowFn, WindowFuncExpr, buildOperation, codecOf, collectOrderedParamRefs, compact, createRawSql, createSqlParamRefMutator, isQueryAst, isWhereExpr, param, 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
|
|
1
|
+
import { A as SelectAst, C as OrExpr, D as ProjectionItem, E as PreparedParamRef, F as isQueryAst, I as isWhereExpr, L as queryAstKinds, M as TableSource, N as UpdateAst, O as RawExpr, P as WindowFuncExpr, R as whereExprKinds, 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 SubqueryExpr, k as RawSqlExpr, 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-C4EdOD-s.mjs";
|
|
2
2
|
import { n as compact, t as collectOrderedParamRefs } from "./util-DWmhUCEO.mjs";
|
|
3
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, codecOf, toExpr } from "./exports/expression.mjs";
|
|
5
|
+
import { buildOperation, codecOf, createRawSql, param, toExpr } from "./exports/expression.mjs";
|
|
6
6
|
import { t as createSqlParamRefMutator } from "./middleware-B0yz0pff.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, PreparedParamRef, 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, WindowFuncExpr, 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 };
|
|
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, PreparedParamRef, ProjectionItem, RawExpr, 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, WindowFuncExpr, buildOperation, codecOf, collectOrderedParamRefs, compact, createRawSql, createSqlParamRefMutator, isQueryAst, isWhereExpr, param, 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,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-
|
|
1
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-D4OimCVH.mjs";
|
|
2
2
|
import { ParamRefMutator } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/param-ref-mutator.d.ts
|
|
@@ -116,4 +116,4 @@ interface SqlParamRefMutatorInternal<TCodecMap extends Record<string, unknown> =
|
|
|
116
116
|
declare function createSqlParamRefMutator<TCodecMap extends Record<string, unknown> = Record<string, unknown>>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap>;
|
|
117
117
|
//#endregion
|
|
118
118
|
export { SqlParamRefMutatorInternal as a, SqlParamRefMutator as i, ParamRefEntryUnion as n, createSqlParamRefMutator as o, ParamRefHandle as r, ParamRefEntry as t };
|
|
119
|
-
//# sourceMappingURL=middleware-
|
|
119
|
+
//# sourceMappingURL=middleware-EOcO8Ogo.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-
|
|
1
|
+
{"version":3,"file":"middleware-EOcO8Ogo.d.mts","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"mappings":";;;;;;AAG8D;;;;AAYd;AAWhD;;;cAXc,mBAAA;;;;;AAY4B;AAQ1C;;;;UATiB,cAAA;EAAA,UACL,mBAAmB,GAAG,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;;;;;;;;;;AAAa;AA0BjB;;;;;;;;;;;;;;UAAiB,kBAAA,mBACG,MAAA,oBAA0B,MAAA,2BACpC,eAAA;EAmBU;EAjBlB,OAAA,IAAW,gBAAA,CAAiB,kBAAA,CAAmB,SAAA;EAFvC;;;;;;EAUR,YAAA,wBAAoC,SAAA,WAClC,GAAA,EAAK,cAAA,CAAe,QAAA,GACpB,QAAA,EAAU,SAAA,CAAU,QAAA;EAEtB,YAAA,CAAa,GAAA,EAAK,cAAA,aAA2B,QAAA;EAZlC;EAeX,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;;;;;;AAjBI;AAcN;;;;;;;;;iBAuBgB,wBAAA,mBACI,MAAA,oBAA0B,MAAA,kBAAA,CAC5C,IAAA,EAAM,gBAAA,GAAmB,0BAAA,CAA2B,SAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as AnyQueryAst } from "./types-
|
|
1
|
+
import { f as AnyQueryAst } from "./types-C_1ZqLwZ.mjs";
|
|
2
2
|
import { QueryPlan } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { Contract } from "@prisma-next/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-CG3sy5kw.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-
|
|
1
|
+
{"version":3,"file":"plan-CG3sy5kw.d.mts","names":[],"sources":["../src/plan.ts"],"mappings":";;;;;;;;AAkBA;;;;;;;;;;;UAAiB,YAAA,wBAAoC,SAAA,CAAU,GAAA;EAAA,SACpD,GAAA,EAAK,WAAA;EAAA,SACL,MAAA;AAAA;AAAM;AAoBjB;;;;;;;;;;;;;;;;AApBiB,iBAoBD,WAAA,eAAA,CACd,GAAA,EAAK,WAAA,EACL,QAAA,EAAU,QAAA,CAAS,UAAA,GACnB,MAAA,YACC,YAAA,CAAa,GAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as AnyQueryAst } from "./types-
|
|
1
|
+
import { f as AnyQueryAst } from "./types-C_1ZqLwZ.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-D4OimCVH.d.mts.map
|
package/dist/{sql-execution-plan-Cyrn58Gz.d.mts.map → sql-execution-plan-D4OimCVH.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-execution-plan-
|
|
1
|
+
{"version":3,"file":"sql-execution-plan-D4OimCVH.d.mts","names":[],"sources":["../src/sql-execution-plan.ts"],"mappings":";;;;;;AAuBA;;;;;;;;;;;;;;;;AAG2B;;UAHV,gBAAA,wBAAwC,aAAA,CAAc,GAAA;EAAA,SAC5D,GAAA;EAAA,SACA,MAAA;EAAA,SACA,GAAA,EAAK,WAAA;AAAA"}
|
|
@@ -363,6 +363,27 @@ var OperationExpr = class OperationExpr extends Expression {
|
|
|
363
363
|
return this.self.baseColumnRef();
|
|
364
364
|
}
|
|
365
365
|
};
|
|
366
|
+
var RawExpr = class extends Expression {
|
|
367
|
+
kind = "raw-expr";
|
|
368
|
+
parts;
|
|
369
|
+
returns;
|
|
370
|
+
constructor(options) {
|
|
371
|
+
super();
|
|
372
|
+
this.parts = frozenArrayCopy(options.parts);
|
|
373
|
+
this.returns = options.returns;
|
|
374
|
+
this.freeze();
|
|
375
|
+
}
|
|
376
|
+
accept(visitor) {
|
|
377
|
+
return visitor.rawExpr(this);
|
|
378
|
+
}
|
|
379
|
+
rewrite(rewriter) {
|
|
380
|
+
return rewriter.rawExpr ? rewriter.rawExpr(this) : this;
|
|
381
|
+
}
|
|
382
|
+
fold(folder) {
|
|
383
|
+
if (folder.rawExpr) return folder.rawExpr(this);
|
|
384
|
+
return combineAll(folder, this.parts.filter((p) => typeof p !== "string").map((p) => () => p.fold(folder)));
|
|
385
|
+
}
|
|
386
|
+
};
|
|
366
387
|
var AggregateExpr = class AggregateExpr extends Expression {
|
|
367
388
|
kind = "aggregate";
|
|
368
389
|
fn;
|
|
@@ -1199,6 +1220,6 @@ function isWhereExpr(value) {
|
|
|
1199
1220
|
return typeof value === "object" && value !== null && "kind" in value && whereExprKinds.has(value.kind);
|
|
1200
1221
|
}
|
|
1201
1222
|
//#endregion
|
|
1202
|
-
export {
|
|
1223
|
+
export { SelectAst as A, OrExpr as C, ProjectionItem as D, PreparedParamRef as E, isQueryAst as F, isWhereExpr as I, queryAstKinds as L, TableSource as M, UpdateAst as N, RawExpr as O, WindowFuncExpr as P, whereExprKinds as R, 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, SubqueryExpr as j, RawSqlExpr 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 };
|
|
1203
1224
|
|
|
1204
|
-
//# sourceMappingURL=types-
|
|
1225
|
+
//# sourceMappingURL=types-C4EdOD-s.mjs.map
|